//***********************************************************************************
// 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: 30101,

  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 = (re.hasOwnProperty('stack')) ? re.stack : re;
    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) {
      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 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 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) {
        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){
      if (t.Create){
        throw t.$create("Create");
      } else if (t.create){
        throw t.$create("create");
      }
    }
    if (typename === "EInvalidCast") throw "invalid type cast";
    if (typename === "EAbstractError") throw "Abstract method called";
    if (typename === "ERangeError") throw "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) {
      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;
  },

  _ReleaseArray: function(a,dim){
    if (!a) return null;
    for (var i=0; i<a.length; i++){
      if (dim<=1){
        if (a[i]) a[i]._Release();
      } else {
        rtl._ReleaseArray(a[i],dim-1);
      }
    }
    return null;
  },

  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',1);
    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 lastlen = 0;
    var item = null;
    var a = null;
    var src = arr;
    var srclen = 0, oldlen = 0;
    do{
      if (depth>0){
        item=stack[depth-1];
        src = (item.src && item.src.length>item.i)?item.src[item.i]:null;
      }
      if (!src){
        a = [];
        srclen = 0;
        oldlen = 0;
      } else if (src.$pas2jsrefcnt>0 || depth>=s){
        a = [];
        srclen = src.length;
        oldlen = srclen;
      } else {
        a = src;
        srclen = 0;
        oldlen = a.length;
      }
      lastlen = stack[depth].dim;
      a.length = lastlen;
      if (depth>0){
        item.a[item.i]=a;
        item.i++;
        if ((lastlen===0) && (item.i<item.a.length)) continue;
      }
      if (lastlen>0){
        if (depth<dimmax){
          item = stack[depth];
          item.a = a;
          item.i = 0;
          item.src = src;
          depth++;
          continue;
        } else {
          if (srclen>lastlen) srclen=lastlen;
          if (rtl.isArray(defaultvalue)){
            // array of dyn array
            for (var i=0; i<srclen; i++) a[i]=src[i];
            for (var i=oldlen; i<lastlen; i++) a[i]=[];
          } else if (rtl.isObject(defaultvalue)) {
            if (rtl.isTRecord(defaultvalue)){
              // array of record
              for (var i=0; i<srclen; i++) a[i]=defaultvalue.$clone(src[i]);
              for (var i=oldlen; i<lastlen; i++) a[i]=defaultvalue.$new();
            } else {
              // array of set
              for (var i=0; i<srclen; i++) a[i]=rtl.refSet(src[i]);
              for (var i=oldlen; i<lastlen; i++) a[i]={};
            }
          } else {
            for (var i=0; i<srclen; i++) a[i]=src[i];
            for (var i=oldlen; i<lastlen; i++) a[i]=defaultvalue;
          }
        }
      }
      // backtrack
      while ((depth>0) && (stack[depth-1].i>=stack[depth-1].dim)){
        depth--;
      };
      if (depth===0){
        if (dimmax===0) return a;
        return 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, "refset" for calling refSet(), a function for new type()
    // src must not be null
    // 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 {
      for (; srcpos<endpos; srcpos++) dst[dstpos++] = src[srcpos]; // reference
    };
  },

  arrayConcat: function(type){
    // type: see rtl.arrayClone
    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;
    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(a) does not clone
      } else if (a['$pas2jsrefcnt']){
        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=[];
    } else if (a['$pas2jsrefcnt']){
      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']){
      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 [];
    if (index < 0) index = 0;
    if (count === undefined) count=srcarray.length;
    var end = index+count;
    if (end>srcarray.length) end = srcarray.length;
    if (index>=end) return [];
    if (type===0){
      return srcarray.slice(index,end);
    } else {
      var a = [];
      a.length = end-index;
      rtl.arrayClone(type,srcarray,index,end,a,0);
      return a;
    }
  },

  arrayInsert: function(item, arr, index){
    if (arr){
      arr.splice(index,0,item);
      return arr;
    } else {
      return [item];
    }
  },

  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);
    newBaseTI("char",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,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);
      if (rtl.isObject(options)){
        for (var key in options) if (options.hasOwnProperty(key)) t[key] = options[key];
      };
      return t;
    };
    tis.addField = function(name,type,options){
      var t = this.$addMember(name,rtl.tTypeMemberField,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,result,flags,options){
      var t = this.$addMember(name,rtl.tTypeMemberMethod,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,options){
      var t = this.$addMember(name,rtl.tTypeMemberProperty,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){ 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",{});
    $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",{});
    $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]],rtl.longint);
    $r.addMethod("_AddRef",1,[],rtl.longint);
    $r.addMethod("_Release",1,[],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,[],$mod.$rtti["TObject"]);
    $r.addMethod("MoveNext",1,[],rtl.boolean);
    $r.addMethod("Reset",0,[]);
    $r.addProperty("Current",1,$mod.$rtti["TObject"],"GetCurrent","");
  });
  rtl.createInterface(this,"IEnumerable","{9791C368-4E51-3424-A3CE-D4911D54F385}",["GetEnumerator"],this.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetEnumerator",1,[],$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",{});
    $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",{});
    $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",{});
    $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",{});
    $r.addField("Left",rtl.longint);
    $r.addField("Top",rtl.longint);
    $r.addField("Right",rtl.longint);
    $r.addField("Bottom",rtl.longint);
  });
  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",{});
    $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",{});
    $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",{});
    $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,[],$r,1);
    $r.addMethod("Create$1",5,[["ALocale",rtl.string,2]],$r,1);
    $r.addMethod("Invariant",5,[],$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",{});
    $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",{});
    $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.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",{});
      $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AStrings",$mod.$rtti["TStrings"]]]);
  });
  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);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
  });
  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",{});
    $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();
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["AOwnsObjects",rtl.boolean]]);
    $r.addMethod("Create$3",2,[["AQuoteChar",rtl.char],["ADelimiter",rtl.char]]);
    $r.addMethod("Create$4",2,[["AQuoteChar",rtl.char],["ADelimiter",rtl.char],["AOptions",$mod.$rtti["TStringsOptions"]]]);
    $r.addMethod("Create$5",2,[["ADuplicates",pas.Types.$rtti["TDuplicates"]],["ASorted",rtl.boolean],["ACaseSensitive",rtl.boolean]]);
  });
  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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ACollection",$mod.$rtti["TCollection"]]]);
  });
  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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ACollection",$mod.$rtti["TCollection"]]]);
  });
  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();
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AItemClass",$mod.$rtti["TCollectionItemClass"]]]);
  });
  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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["AOwner",$mod.$rtti["TPersistent"]],["AItemClass",$mod.$rtti["TCollectionItemClass"]]]);
  });
  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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AComponent",$mod.$rtti["TComponent"]]]);
  });
  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.addMethod("Create$1",2,[["AOwner",$r]]);
    $r.addProperty("Name",6,$mod.$rtti["TComponentName"],"FName","SetName");
    $r.addProperty("Tag",0,rtl.nativeint,"FTag","FTag",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ABytes",pas.SysUtils.$rtti["TBytes"],2]]);
  });
  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));
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $r.addMethod("Create$2",2,[["aString",rtl.string,2]]);
    $r.addMethod("Create$3",2,[["AString",rtl.string,2],["AEncoding",pas.SysUtils.$rtti["TEncoding"]],["AOwnsEncoding",rtl.boolean]]);
  });
  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);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["aInfo",pas.p2jsres.$rtti["TResourceInfo"]]]);
    $r.addMethod("Create$2",2,[["Instance",rtl.nativeint],["ResName",rtl.string,2],["ResType",rtl.string,2]]);
    $r.addMethod("CreateFromID",2,[["Instance",rtl.nativeint],["ResID",rtl.longint],["ResType",rtl.string]]);
  });
  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();
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["Stream",$mod.$rtti["TStream"]]]);
  });
  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());
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["Stream",$mod.$rtti["TStream"]]]);
  });
  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")]);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["Stream",$mod.$rtti["TStream"]]]);
  });
  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);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ADriver",$mod.$rtti["TAbstractObjectWriter"]]]);
    $r.addMethod("Create$2",2,[["Stream",$mod.$rtti["TStream"]]]);
  });
  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});
    $r.addMethod("Create$1",2,[["Stream",$mod.$rtti["TStream"]]]);
  });
  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.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TComponent"]]]);
    $r.addMethod("CreateNew",2,[["AOwner",$mod.$rtti["TComponent"]]]);
    $r.addMethod("CreateNew$1",2,[["AOwner",$mod.$rtti["TComponent"]],["CreateMode",rtl.longint]]);
    $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",{});
    $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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["Platforms",rtl.longword,2]]);
  });
  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;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["AIntegerType",rtl.pointer],["AIdentToInt",$mod.$rtti["TIdentToInt"]],["AIntToIdent",$mod.$rtti["TIntToIdent"]]]);
    });
    $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"]);
    });
    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"]]],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;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["ARoot",$mod.$rtti["TComponent"]],["ARef",rtl.string,2]]);
    });
    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;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["ARoot",$mod.$rtti["TComponent"]],["AList",$mod.$rtti["TStrings"]]]);
    });
    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;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["ARoot",$mod.$rtti["TComponent"]],["ARef",rtl.string,2],["AList",$mod.$rtti["TStrings"]]]);
    });
    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;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["ARoot",$mod.$rtti["TComponent"]],["AOld",rtl.string,2],["ANew",rtl.string,2]]);
    });
    $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;
      };
      var $r = this.$rtti;
      $r.addMethod("Create$1",2,[["APos",rtl.longint],["AComponent",$mod.$rtti["TComponent"]]]);
    });
    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"]);
      $r.addField("AClass",$mod.$rtti["TComponentClass"]);
    });
    $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",{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;
      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 {
        Result.style.setProperty("width","100px");
        Result.style.setProperty("margin-left","5px");
        if (this.FElementButtonClassName !== "") {
          Result.setAttribute("class",this.FElementButtonClassName + " " + AClass)}
         else if (pas["WEBLib.Forms"].Application.FThemeButtonClassName !== "") Result.setAttribute("class",pas["WEBLib.Forms"].Application.FThemeButtonClassName + " " + AClass);
      };
      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-white 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",{Default: true});
    $r.addProperty("Buttons",0,$mod.$rtti["TMsgDlgButtons"],"FButtons","FButtons",{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",{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",{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"]);
    $r.addField("FInputValue",rtl.string);
    $r.addField("FKeydownHandler",rtl.pointer);
    $r.addField("FKeypressHandler",rtl.pointer);
    $r.addProperty("InputValue",1,rtl.string,"GetInputElementValue","FInputValue");
    $r.addProperty("InputType",0,pas["WEBLib.Controls"].$rtti["TInputType"],"FInputType","FInputType",{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");
      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.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();
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Accept",2,rtl.string,"FAccept","SetAccept");
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: 14670536});
    $r.addProperty("DragCaption",2,rtl.string,"FDragCaption","SetDragCaption");
    $r.addProperty("DragColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FDragColor","FDragColor",{Default: -1});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{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",{Default: 13877049});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Multifile",0,rtl.boolean,"FMultiFile","FMultiFile",{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("ShowFiles",0,rtl.boolean,"FShowFiles","FShowFiles",{Default: false});
    $r.addProperty("ShowPicture",2,rtl.boolean,"FShowPicture","SetShowPicture",{Default: true});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: 0});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{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",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Multifile",2,rtl.boolean,"FMultiFile","SetMultiFile");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addMethod("Create$3",2,[]);
    $r.addProperty("Accept",0,rtl.string,"FAccept","FAccept");
    $r.addProperty("MultiFile",0,rtl.boolean,"FMultiFile","FMultiFile",{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$G1 = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.longint,Result);
      return Result;
    };
    this.From$G2 = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.double,Result);
      return Result;
    };
    this.From$G3 = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.string,Result);
      return Result;
    };
    this.From$G4 = function (Value) {
      var Result = $mod.TValue.$new();
      $mod.TValue.Make(Value,rtl.boolean,Result);
      return Result;
    };
    var $r = $mod.$rtti.$Record("TValue",{});
    $r.addMethod("Empty",5,[],$r,1);
    $r.addMethod("FromArray",5,[["TypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["Values",pas.System.$rtti["TArray<RTTI.TValue>"],2]],$r,1);
    $r.addMethod("FromJSValue",5,[["v",rtl.jsvalue]],$r,1);
    $r.addMethod("FromOrdinal",5,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["AValue",rtl.jsvalue]],$r,1);
    $r.addMethod("Make",4,[["ABuffer",rtl.jsvalue,2],["ATypeInfo",rtl.pointer,2],["Result",$r,1]],null,1);
    $r.addMethod("AsBoolean",1,[],rtl.boolean);
    $r.addMethod("AsClass",1,[],pas.System.$rtti["TClass"]);
    $r.addMethod("AsExtended",1,[],pas.System.$rtti["Extended"]);
    $r.addMethod("AsInteger",1,[],rtl.longint);
    $r.addMethod("AsInterface",1,[],pas.System.$rtti["IUnknown"]);
    $r.addMethod("AsJSValue",1,[],rtl.jsvalue);
    $r.addMethod("AsNativeInt",1,[],rtl.nativeint);
    $r.addMethod("AsObject",1,[],pas.System.$rtti["TObject"]);
    $r.addMethod("AsOrdinal",1,[],rtl.nativeint);
    $r.addMethod("AsString",1,[],rtl.string);
    $r.addMethod("AsUnicodeString",1,[],rtl.string);
    $r.addMethod("Cast",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["EmptyAsAnyType",rtl.boolean,2]],$r);
    $r.addMethod("IsType",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["EmptyAsAnyType",rtl.boolean,2]],rtl.boolean);
    $r.addMethod("GetArrayElement",1,[["aIndex",rtl.nativeint]],$r);
    $r.addMethod("GetArrayLength",1,[],rtl.nativeint);
    $r.addMethod("IsArray",1,[],rtl.boolean);
    $r.addMethod("IsClass",1,[],rtl.boolean);
    $r.addMethod("IsObject",1,[],rtl.boolean);
    $r.addMethod("IsObjectInstance",1,[],rtl.boolean);
    $r.addMethod("IsOrdinal",1,[],rtl.boolean);
    $r.addMethod("IsType$2",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]]],rtl.boolean);
    $r.addMethod("ToString",1,[],rtl.string);
    $r.addMethod("TryCast",1,[["ATypeInfo",pas.TypInfo.$rtti["TTypeInfo"]],["AResult",$r,4],["EmptyAsAnyType",rtl.boolean,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","");
    $r.addProperty("Kind",1,pas.System.$rtti["TTypeKind"],"GetTypeKind","");
    $r.addProperty("TypeInfo",0,pas.TypInfo.$rtti["TTypeInfo"],"FTypeInfo","");
  });
  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",{});
    $r.addMethod("Create",5,[],$r,1);
    $r.addMethod("Free",0,[]);
    $r.addMethod("FindType",1,[["AQualifiedName",rtl.string,2]],$mod.$rtti["TRttiType"]);
    $r.addMethod("GetType",1,[["aTypeInfo",rtl.pointer]],$mod.$rtti["TRttiType"]);
    $r.addMethod("GetType$1",1,[["aClass",pas.System.$rtti["TClass"]]],$mod.$rtti["TRttiType"]);
    $r.addMethod("GetTypes",1,[],pas.System.$rtti["TArray<RTTI.TRttiType>"]);
    $r.addMethod("KeepContext",4,[],null,1);
    $r.addMethod("DropContext",4,[],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.sessionStorage.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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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",{Default: $mod.THTTPRequestResponseType.rtDefault});
    $r.addProperty("Timeout",0,rtl.longint,"FTimeout","FTimeout",{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",{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.addMethod("Create$1",2,[]);
    $r.addProperty("Key",0,rtl.string,"FKey","FKey");
    $r.addProperty("Enabled",0,rtl.boolean,"FEnabled","FEnabled",{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",{});
    $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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("App",2,$mod.$rtti["TRESTApp"],"FApp","SetApp");
    $r.addProperty("LoginHeight",0,rtl.longint,"FLoginHeight","FLoginHeight",{Default: 600});
    $r.addProperty("LoginWidth",0,rtl.longint,"FLoginWidth","FLoginWidth",{Default: 800});
    $r.addProperty("PersistTokens",2,$mod.$rtti["TPersistTokens"],"FPersistTokens","SetPersistTokens");
    $r.addProperty("ResponseType",0,$mod.$rtti["THTTPRequestResponseType"],"FResponseType","FResponseType",{Default: $mod.THTTPRequestResponseType.rtDefault});
    $r.addProperty("Scopes",2,pas.Classes.$rtti["TStrings"],"FScopes","SetScopes");
    $r.addProperty("WithCredentials",0,rtl.boolean,"FWithCredentials","FWithCredentials",{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("");
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[]);
    $r.addMethod("Create$3",2,[["AString",rtl.string,2]]);
    $r.addMethod("Create$4",2,[["AString",rtl.string,2],["AEncoding",pas.SysUtils.$rtti["TEncoding"]],["AOwnsEncoding",rtl.boolean]]);
  });
  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]],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,[],$mod.$rtti["TInterfaceList"]);
    $r.addMethod("First",1,[],pas.System.$rtti["IUnknown"]);
    $r.addMethod("get_Capacity",1,[],rtl.longint);
    $r.addMethod("get_Count",1,[],rtl.longint);
    $r.addMethod("get_Items",1,[["AIndex",rtl.longint,2]],pas.System.$rtti["IUnknown"]);
    $r.addMethod("IndexOf",1,[["AItem",pas.System.$rtti["IUnknown"],2]],rtl.longint);
    $r.addMethod("IndexOfItem",1,[["AItem",pas.System.$rtti["IUnknown"],2],["ADirection",pas.Types.$rtti["TDirection"],2]],rtl.longint);
    $r.addMethod("Insert",0,[["AIndex",rtl.longint,2],["AItem",pas.System.$rtti["IUnknown"],2]]);
    $r.addMethod("Last",1,[],pas.System.$rtti["IUnknown"]);
    $r.addMethod("Lock",0,[]);
    $r.addMethod("Remove",1,[["AItem",pas.System.$rtti["IUnknown"],2]],rtl.longint);
    $r.addMethod("RemoveItem",1,[["AItem",pas.System.$rtti["IUnknown"],2],["ADirection",pas.Types.$rtti["TDirection"],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");
    $r.addProperty("Items",3,pas.System.$rtti["IUnknown"],"get_Items","set_Items");
  });
  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,[],$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",{});
    $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$G3("" + AValue));
            Prop.SetValue(AObject,v);
          };
          if (pn === "longint") {
            v.$assign(pas.RTTI.TValue.From$G1(rtl.trunc(AValue)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "boolean") {
            v.$assign(pas.RTTI.TValue.From$G4(("" + AValue) === "true"));
            Prop.SetValue(AObject,v);
          };
          if (pn === "double") {
            v.$assign(pas.RTTI.TValue.From$G2(rtl.getNumber(AValue)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "TDateTime") {
            v.$assign(pas.RTTI.TValue.From$G2(pas["WEBLib.REST"].TRESTClient.IsoToDateTime$1("" + AValue,true)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "TDate") {
            v.$assign(pas.RTTI.TValue.From$G2(pas["WEBLib.REST"].TRESTClient.IsoToDate("" + AValue)));
            Prop.SetValue(AObject,v);
          };
          if (pn === "TTime") {
            v.$assign(pas.RTTI.TValue.From$G2(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.$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};
  this.$rtti.$Enum("TElementEvent",{minvalue: 0, maxvalue: 7, 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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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.addMethod("Create$1",2,[]);
    $r.addProperty("Left",2,rtl.longint,"FLeft","SetLeft",{Default: 3});
    $r.addProperty("Top",2,rtl.longint,"FTop","SetTop",{Default: 3});
    $r.addProperty("Right",2,rtl.longint,"FRight","SetRight",{Default: 3});
    $r.addProperty("Bottom",2,rtl.longint,"FBottom","SetBottom",{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",{Default: false});
    $r.addProperty("Vertical",2,rtl.boolean,"FVertical","SetVertical",{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.addMethod("Create$1",2,[]);
    $r.addProperty("Left",2,rtl.longint,"FLeft","SetLeft",{Default: 0});
    $r.addProperty("Top",2,rtl.longint,"FTop","SetTop",{Default: 0});
    $r.addProperty("Right",2,rtl.longint,"FRight","SetRight",{Default: 0});
    $r.addProperty("Bottom",2,rtl.longint,"FBottom","SetBottom",{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]],rtl.boolean);
    $r.addMethod("ExitChildren",1,[["AObject",$r]],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 $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.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;
      Result = false;
      return Result;
    };
    this.ExitChildren = function (AObject) {
      var Result = false;
      Result = false;
      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;
      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;
      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();
      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;
      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 === "") {
        if (!this.GetIsLinked()) {
          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();
      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);
      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.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});
    $r.addMethod("Create$2",2,[["ID",rtl.string]]);
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AControl",$mod.$rtti["TControl"]],["AKind",$mod.$rtti["TScrollBarKind"]]]);
  });
  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",{Default: 0});
    $r.addProperty("ElementClassName",2,$mod.$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: false});
    $r.addProperty("Tag",0,rtl.longint,"FTag$1","FTag$1",{Default: 0});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{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",{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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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.addMethod("Create$1",2,[["Collection",pas.Classes.$rtti["TCollection"]]]);
    $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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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,[],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",{});
    $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",{});
    $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",{});
    $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",{});
    $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",{});
    $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.addMethod("Create$1",2,[]);
    $r.addProperty("Color",2,$mod.$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Mode",0,$mod.$rtti["TPenMode"],"FMode","FMode",{Default: $mod.TPenMode.pmCopy});
    $r.addProperty("Width",0,rtl.longint,"FWidth","FWidth",{Default: 1});
    $r.addProperty("Style",0,$mod.$rtti["TPenStyle"],"FStyle","FStyle",{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.addMethod("Create$1",2,[]);
    $r.addProperty("Stop",0,rtl.double,"FStop","FStop");
    $r.addProperty("Color",0,$mod.$rtti["TColor"],"FColor","FColor",{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.addMethod("Create$1",2,[]);
    $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.addMethod("Create$1",2,[]);
    $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.addMethod("Create$1",2,[["URL",rtl.string]]);
    $r.addMethod("Create$2",2,[["Img",pas.JS.$rtti["TJSObject"]]]);
    $r.addMethod("Create$3",2,[]);
    $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",{});
    $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.addMethod("CreateNew",2,[["AOwner",pas.Classes.$rtti["TComponent"]],["Dummy",rtl.longint]]);
    $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 () {
      if (this.FOnClick != null) this.FOnClick(this);
    };
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("AutoCheck",0,rtl.boolean,"FAutoCheck","FAutoCheck",{Default: false});
    $r.addProperty("AutoHotkeys",0,$mod.$rtti["TMenuItemAutoFlag"],"FAutoHotkeys","FAutoHotkeys",{Default: $mod.TMenuItemAutoFlag.maParent});
    $r.addProperty("AutoLineReduction",0,$mod.$rtti["TMenuItemAutoFlag"],"FAutoLineReduction","FAutoLineReduction",{Default: $mod.TMenuItemAutoFlag.maParent});
    $r.addProperty("Break",0,$mod.$rtti["TMenuBreak"],"FBreak","FBreak",{Default: $mod.TMenuBreak.mbNone});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Checked",2,rtl.boolean,"FChecked","SetChecked",{Default: false});
    $r.addProperty("Default",0,rtl.boolean,"FDefault","FDefault",{Default: false});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("GroupIndex",0,rtl.byte,"FGroupIndex","FGroupIndex",{Default: 0});
    $r.addProperty("HelpContext",0,$mod.$rtti["THelpContext"],"FHelpContext","FHelpContext",{Default: 0});
    $r.addProperty("Hint",0,rtl.string,"FHint","FHint");
    $r.addProperty("ImageIndex",2,rtl.longint,"FImageIndex","SetImageIndex",{Default: -1});
    $r.addProperty("RadioItem",0,rtl.boolean,"FRadioItem","FRadioItem",{Default: false});
    $r.addProperty("ShortCut",0,$mod.$rtti["TShortCut"],"FShortCut","FShortCut",{Default: 0});
    $r.addProperty("Visible",0,rtl.boolean,"FVisible","FVisible",{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.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TMainMenuAppearance"]]]);
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("CaptionColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FCaptionColor","SetCaptionColor",{Default: 16777215});
    $r.addProperty("BackgroundColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBackgroundColor","SetBackgroundColor",{Default: 12632256});
    $r.addProperty("Visible",2,$mod.$rtti["TMainMenuHamburgerMenuVisible"],"FVisible","SetVisible",{Default: $mod.TMainMenuHamburgerMenuVisible.hmResponsive});
    $r.addProperty("ResponsiveMaxWidth",2,rtl.longint,"FResponsiveMaxWidth","SetResponsiveMaxWidth",{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.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TMainMenu"]]]);
    $r.addProperty("BackgroundColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBackgroundColor","SetBackgroundColor",{Default: 15790320});
    $r.addProperty("HamburgerMenu",0,$mod.$rtti["THamburgerMenu"],"FHamburgerMenu","FHamburgerMenu");
    $r.addProperty("HoverColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FHoverColor","SetHoverColor",{Default: 14120960});
    $r.addProperty("HoverFontColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FHoverFontColor","SetHoverFontColor",{Default: 197379});
    $r.addProperty("ImageURLs",2,pas.Classes.$rtti["TStringList"],"FImageURLs","SetImageURLs");
    $r.addProperty("ImageSize",2,rtl.longint,"FImageSize","SetImageSize",{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.$final = function () {
      this.FMenu = undefined;
      this.FAppearance = undefined;
      this.FContainer$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.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");
      };
      this.FMenu = ElHandle.firstChild;
      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.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) Result.setAttribute("onMouseLeave",this.GetID() + "MenuOut(this);");
      };
      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",{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",{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) {
      if (this.FOnPopup != null) this.FOnPopup(this);
      this.SetTop(Y);
      this.SetLeft(X);
      this.FShowPopup = true;
      this.UpdateElement();
      this.FShowPopup = false;
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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 frm = null;
      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)));
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if ((frm != null) && (frm.GetContainer() != null)) {
          r = frm.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 frm = null;
      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)));
        frm = pas["WEBLib.Forms"].GetParentForm(this);
        if ((frm != null) && frm.FPopup && (frm.GetContainer() != null)) {
          r = frm.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);
    });
    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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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.1.0";
  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",{});
    $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",{});
    $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",{});
    $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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AControl",pas["WEBLib.Controls"].$rtti["TControl"]]]);
  });
  rtl.createClass(this,"TSizeConstraints",this.TCustomSizeConstraints,function () {
    var $r = this.$rtti;
    $r.addProperty("MaxHeight",18,$mod.$rtti["TConstraintSize"],"FMaxHeight","SetConstraints",{index: 0, Default: 0});
    $r.addProperty("MaxWidth",18,$mod.$rtti["TConstraintSize"],"FMaxWidth","SetConstraints",{index: 1, Default: 0});
    $r.addProperty("MinHeight",18,$mod.$rtti["TConstraintSize"],"FMinHeight","SetConstraints",{index: 2, Default: 0});
    $r.addProperty("MinWidth",18,$mod.$rtti["TConstraintSize"],"FMinWidth","SetConstraints",{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.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.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.$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)) {
        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.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.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.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"));
              };
              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.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 () {
      var Result = "";
      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.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.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.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.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();
      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();
      if (AFileName !== "") {
        $mod.Application.LoadForm(this,AFileName)}
       else if (this.FCreatedProc != null) this.FCreatedProc(this);
      return this;
    };
    this.CreateDialog = function (ACaption) {
      var AFileName = "";
      this.FCreating = true;
      AFileName = this.$class.GetHTMLFileName();
      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();
      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.Loading();
      if (this.FFormFileName === "") {
        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 = $mod.TCloseAction.caHide;
        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;
      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.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.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);
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["id",rtl.string]]);
    $r.addMethod("Create$5",2,[["id",rtl.string],["AReference",null,1]]);
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addMethod("Create$7",2,[["AOwner",pas.Classes.$rtti["TComponent"]],["IsPopup",rtl.boolean],["ABorder",$mod.$rtti["TFormBorderStyle"]],["ATitle",rtl.string]]);
    $r.addMethod("CreateNew",2,[["AOwner",pas.Classes.$rtti["TComponent"]],["Dummy",rtl.longint]]);
    $r.addMethod("CreateNew$1",2,[["AFileName",rtl.string]]);
    $r.addMethod("CreateNew$2",2,[]);
    $r.addMethod("CreateNew$3",2,[["AProc",$mod.$rtti["TFormCreatedProc"]]]);
    $r.addMethod("CreateNew$4",2,[["AElementID",rtl.string],["AProc",$mod.$rtti["TFormCreatedProc"]]]);
    $r.addMethod("CreateNew$5",2,[["AElementID",rtl.string],["AFileName",rtl.string],["AProc",$mod.$rtti["TFormCreatedProc"]]]);
    $r.addMethod("CreateDialog",2,[["ACaption",rtl.string]]);
    $r.addMethod("CreateDialogNew",2,[["ACaption",rtl.string]]);
  });
  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",{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",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{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",{Default: true});
    $r.addProperty("Shadow",2,rtl.boolean,"FShadow","SetShadow",{Default: true});
    $r.addProperty("ShowClose",0,rtl.boolean,"FShowClose","FShowClose",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{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.$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;
      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);
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["AId",rtl.string]]);
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addMethod("CreateNew",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoScroll",0,rtl.boolean,"FAutoScroll","FAutoScroll",{Default: false});
    $r.addProperty("AutoSize",0,rtl.boolean,"FAutoSize","FAutoSize",{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",{Default: false});
    $r.addProperty("DoubleBuffered",0,rtl.boolean,"FDoubleBuffered","FDoubleBuffered",{Default: false});
    $r.addProperty("DragCursor",0,pas["WEBLib.Controls"].$rtti["TCursor"],"FDragCursor","FDragCursor",{Default: 12});
    $r.addProperty("DragKind",0,pas["WEBLib.Controls"].$rtti["TDragKind"],"FDragKind","FDragKind",{Default: pas["WEBLib.Controls"].TDragKind.dkDrag});
    $r.addProperty("DragMode",0,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode$1","FDragMode$1",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: true});
    $r.addProperty("ParentBiDiMode",0,rtl.boolean,"FParentBiDiMode","FParentBiDiMode",{Default: true});
    $r.addProperty("ParentColor",2,rtl.boolean,"FParentColor","SetParentColor",{Default: false});
    $r.addProperty("ParentCtl3D",0,rtl.boolean,"FParentCtl3D$1","FParentCtl3D$1",{Default: true});
    $r.addProperty("ParentDoubleBuffered",0,rtl.boolean,"FParentDoubleBuffered","FParentDoubleBuffered",{Default: true});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{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",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{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",{});
    $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,"black");
          op.style.setProperty("opacity",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();
      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();
      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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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 = "";
  $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");
        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.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("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",{});
    $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]],$r);
    $r.addMethod("Duration",1,[],$r);
    $r.addMethod("Negate",1,[],$r);
    $r.addMethod("Subtract",1,[["ATimeSpan",$r,2]],$r);
    $r.addMethod("ToString",1,[],rtl.string);
    $r.addMethod("FromDays",5,[["AValue",rtl.double,2]],$r,1);
    $r.addMethod("FromHours",5,[["AValue",rtl.double,2]],$r,1);
    $r.addMethod("FromMinutes",5,[["AValue",rtl.double,2]],$r,1);
    $r.addMethod("FromSeconds",5,[["AValue",rtl.double,2]],$r,1);
    $r.addMethod("FromMilliseconds",5,[["AValue",rtl.double,2]],$r,1);
    $r.addMethod("FromTicks",5,[["AValue",rtl.nativeint,2]],$r,1);
    $r.addMethod("Subtract$1",5,[["ADateTimeLeft",pas.System.$rtti["TDateTime"],2],["ADateTimeRight",pas.System.$rtti["TDateTime"],2]],$r,1);
    $r.addMethod("Parse",5,[["AValue",rtl.string,2]],$r,1);
    $r.addMethod("TryParse",5,[["AValue",rtl.string,2],["ATimeSpan",$r,4]],rtl.boolean,1);
    $r.addProperty("Ticks",0,rtl.nativeint,"FTicks","");
    $r.addProperty("Days",1,rtl.longint,"GetDays","");
    $r.addProperty("Hours",1,rtl.longint,"GetHours","");
    $r.addProperty("Minutes",1,rtl.longint,"GetMinutes","");
    $r.addProperty("Seconds",1,rtl.longint,"GetSeconds","");
    $r.addProperty("Milliseconds",1,rtl.longint,"GetMilliseconds","");
    $r.addProperty("TotalDays",1,rtl.double,"GetTotalDays","");
    $r.addProperty("TotalHours",1,rtl.double,"GetTotalHours","");
    $r.addProperty("TotalMinutes",1,rtl.double,"GetTotalMinutes","");
    $r.addProperty("TotalSeconds",1,rtl.double,"GetTotalSeconds","");
    $r.addProperty("TotalMilliseconds",1,rtl.double,"GetTotalMilliseconds","");
    $r.addProperty("MinValue",1,$r,"get_MinValue","");
    $r.addProperty("MaxValue",1,$r,"get_MaxValue","");
    $r.addProperty("Zero",1,$r,"get_Zero","");
  },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",{});
      $r.addMethod("CurrentChar",1,[],rtl.char);
      $r.addMethod("NextChar",1,[],rtl.char);
      $r.addMethod("NextNonDigit",1,[],rtl.char);
      $r.addMethod("Convert",1,[["AValue",rtl.string,2]],rtl.nativeint);
      $r.addMethod("TryConvert",1,[["AString",rtl.string,2],["AValue",rtl.nativeint,4]],$mod.$rtti["TTimeSpanParser.TParseError"]);
      $r.addMethod("NextInt",1,[["AMaxValue",rtl.longint],["AValue",rtl.longint,4]],$mod.$rtti["TTimeSpanParser.TParseError"]);
      $r.addMethod("ConvertTime",1,[["ATime",rtl.nativeint,4]],$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]],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]],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]],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,[],pas.System.$rtti["TObject"]);
    $r.addMethod("MoveNext",1,[],rtl.boolean);
    $r.addMethod("Reset",0,[]);
    $r.addProperty("Current",1,pas.System.$rtti["TObject"],"GetCurrent","");
  },"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,[],$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,[],rtl.string);
    $r.addMethod("MoveNext",1,[],rtl.boolean);
    $r.addMethod("Reset",0,[]);
    $r.addProperty("Current",1,rtl.string,"GetCurrent","");
  },"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,[],$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,[],rtl.longint);
    $r.addMethod("MoveNext",1,[],rtl.boolean);
    $r.addMethod("Reset",0,[]);
    $r.addProperty("Current",1,rtl.longint,"GetCurrent","");
  },"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,[],$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]],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,[],rtl.double);
    $r.addMethod("MoveNext",1,[],rtl.boolean);
    $r.addMethod("Reset",0,[]);
    $r.addProperty("Current",1,rtl.double,"GetCurrent","");
  },"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,[],$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]],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,[],pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCObjectReference"]);
      $r.addMethod("MoveNext",1,[],rtl.boolean);
      $r.addMethod("Reset",0,[]);
      $r.addProperty("Current",1,pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCObjectReference"],"GetCurrent","");
    };
  },"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,[],$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]],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,[],pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassProperty"]);
      $r.addMethod("MoveNext",1,[],rtl.boolean);
      $r.addMethod("Reset",0,[]);
      $r.addProperty("Current",1,pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassProperty"],"GetCurrent","");
    };
  },"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,[],$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]],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,[],pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassItem"]);
      $r.addMethod("MoveNext",1,[],rtl.boolean);
      $r.addMethod("Reset",0,[]);
      $r.addProperty("Current",1,pas["WEBLib.TMSFNCPersistence"].$rtti["TTMSFNCJSONToClassItem"],"GetCurrent","");
    };
  },"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,[],$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",{});
    $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>",{});
    $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>>",{});
    $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>",{});
    $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>",{});
    $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>",{});
    $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>",{});
    $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>",{});
    $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.$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));
    };
    Result = true;
    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("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",{});
    $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.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("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.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"]]],rtl.boolean);
    $r.addMethod("CanLoadProperty",1,[["AObject",pas.System.$rtti["TObject"]],["APropertyName",rtl.string],["APropertyType",pas.System.$rtti["TTypeKind"]]],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,[],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]],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]],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]],rtl.boolean);
    $r.addMethod("GetObjectReference",1,[["AObject",pas.System.$rtti["TObject"],2]],rtl.string);
    $r.addMethod("FindObject",1,[["AReference",rtl.string,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",{});
    $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;
  rtl.createInterface(this,"ITMSFNCProductInfo","{C53329EA-7B3A-4507-AD9E-88ACD6A85054}",["GetVersion","GetDocURL","GetTipsURL"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("GetVersion",1,[],rtl.string);
    $r.addMethod("GetDocURL",1,[],rtl.string);
    $r.addMethod("GetTipsURL",1,[],rtl.string);
  });
  this.TTMSFNCBaseDocURL = "https://download.tmssoftware.com/doc/";
  this.TTMSFNCBaseTipsURL = "https://www.tmssoftware.com/site/tmsfnccore.asp?s=faq";
  this.pidWeb = 0x1000;
  this.ssCommand = pas.Classes.TShiftState$a.ssCtrl;
  this.TMSPlatformsWinOnly = 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",{});
    $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",{});
    $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",{});
    $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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $r.addProperty("GrayScale",0,rtl.boolean,"FGrayScale","FGrayScale",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("CreateFromStream",2,[["AStream",pas.Classes.$rtti["TStream"],2]]);
  });
  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.addMethod("Create$1",2,[]);
    $r.addMethod("Create$2",2,[["ARect",$mod.$rtti["TRectF"],2]]);
    $r.addProperty("Left",14,rtl.double,"FLeft","SetLeft",{stored: "IsLeftStored"});
    $r.addProperty("Top",14,rtl.double,"FTop","SetTop",{stored: "IsTopStored"});
    $r.addProperty("Right",14,rtl.double,"FRight","SetRight",{stored: "IsRightStored"});
    $r.addProperty("Bottom",14,rtl.double,"FBottom","SetBottom",{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.addMethod("Create$1",2,[]);
    $r.addMethod("Create$2",2,[["APoint",$mod.$rtti["TPointF"],2]]);
    $r.addProperty("X",14,rtl.double,"FX","SetX",{stored: "IsXStored"});
    $r.addProperty("Y",14,rtl.double,"FY","SetY",{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.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $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",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TPersistent"]]]);
  });
  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,[],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;
  };
},["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",{});
    $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",{});
    $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]);
      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);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
  });
  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.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $r.addProperty("Opacity",14,rtl.double,"FOpacity","SetOpacity",{stored: "IsOpacityStored"});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: 16777215});
    $r.addProperty("Position",14,rtl.double,"FPosition","SetPosition",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",$mod.$rtti["TTMSFNCCustomGraphicsFill"]]]);
  });
  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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AKind",$mod.$rtti["TTMSFNCGraphicsFillKind"],2],["AColor",pas["WEBLib.Graphics"].$rtti["TColor"],2],["AColorTo",pas["WEBLib.Graphics"].$rtti["TColor"],2],["AColorMirror",pas["WEBLib.Graphics"].$rtti["TColor"],2],["AColorMirrorTo",pas["WEBLib.Graphics"].$rtti["TColor"],2]]);
  });
  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",{stored: "IsKindStored"});
    $r.addProperty("Orientation",2,$mod.$rtti["TTMSFNCGraphicsFillOrientation"],"FOrientation","SetOrientation",{Default: $mod.TTMSFNCGraphicsFillOrientation.gfoVertical});
    $r.addProperty("Color",14,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{stored: "IsColorStored"});
    $r.addProperty("ColorTo",14,pas["WEBLib.Graphics"].$rtti["TColor"],"FColorTo","SetColorTo",{stored: "IsColorToStored"});
    $r.addProperty("ColorMirror",14,pas["WEBLib.Graphics"].$rtti["TColor"],"FColorMirror","SetColorMirror",{stored: "IsColorMirrorStored"});
    $r.addProperty("ColorMirrorTo",14,pas["WEBLib.Graphics"].$rtti["TColor"],"FColorMirrorTo","SetColorMirrorTo",{stored: "IsColorMirrorToStored"});
    $r.addProperty("TextureMode",2,$mod.$rtti["TTMSFNCGraphicsTextureMode"],"FTextureMode","SetTextureMode",{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);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[]);
  });
  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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TPersistent"]]]);
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: -1});
    $r.addProperty("Size",14,rtl.double,"FSize","SetSize",{stored: "IsSizeStored"});
    $r.addProperty("Name",14,rtl.string,"FName","SetName",{stored: "IsNameStored"});
    $r.addProperty("Scale",14,rtl.double,"FScale","SetScale",{stored: "IsScaleStored"});
    $r.addProperty("Style",14,pas["WEBLib.Graphics"].$rtti["TFontStyles"],"FStyle","SetStyle",{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.$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 !== 1;
      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) {
      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.FWidth = 1;
      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();
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AKind",$mod.$rtti["TTMSFNCGraphicsStrokeKind"],2],["AColor",pas["WEBLib.Graphics"].$rtti["TColor"],2]]);
  });
  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",{stored: "IsKindStored"});
    $r.addProperty("Color",14,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{stored: "IsColorStored"});
    $r.addProperty("Width",14,rtl.double,"FWidth","SetWidth",{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",{});
    $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;
        };
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
  });
  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.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,[],rtl.boolean);
    $r.addMethod("SetAdaptToStyle",0,[["Value",rtl.boolean,2]]);
    $r.addProperty("AdaptToStyle",3,rtl.boolean,"GetAdaptToStyle","SetAdaptToStyle");
  });
  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,[],$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.addMethod("Create$1",2,[]);
    $r.addProperty("AdaptFormColor",0,rtl.boolean,"FAdaptFormColor","FAdaptFormColor",{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)) 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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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]],$mod.$rtti["IMenuItem"]);
    $r.addMethod("SameAs",1,[["AItem",pas.System.$rtti["IUnknown"],2]],rtl.boolean);
    $r.addMethod("Find",1,[["ACaption",pas.System.$rtti["WideString"],2]],$mod.$rtti["IMenuItem"]);
    $r.addMethod("FindByName",1,[["AName",rtl.string,2]],$mod.$rtti["IMenuItem"]);
    $r.addMethod("Count",1,[],rtl.longint);
    $r.addProperty("Items",1,$mod.$rtti["IMenuItem"],"GetItem","");
    $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]],$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]],$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]],$mod.$rtti["IMenuItem"]);
    $r.addMethod("AddLine",1,[["AName",rtl.string,2]],$mod.$rtti["IMenuItem"]);
    $r.addMethod("InsertLine",1,[["AName",rtl.string,2]],$mod.$rtti["IMenuItem"]);
    $r.addMethod("InsertLine$1",1,[["Index",rtl.longint],["AName",rtl.string,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,[],$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,[],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,[],pas.System.$rtti["WideString"]);
    $r.addMethod("SetCaption",0,[["ACaption",pas.System.$rtti["WideString"],2]]);
    $r.addMethod("GetChecked",1,[],rtl.boolean);
    $r.addMethod("SetChecked",0,[["AChecked",rtl.boolean]]);
    $r.addMethod("GetEnabled",1,[],rtl.boolean);
    $r.addMethod("SetEnabled",0,[["AEnabled",rtl.boolean]]);
    $r.addMethod("GetGroupIndex",1,[],rtl.byte);
    $r.addMethod("SetGroupIndex",0,[["AGroupIndex",rtl.byte]]);
    $r.addMethod("GetHelpContext",1,[],pas["WEBLib.Menus"].$rtti["THelpContext"]);
    $r.addMethod("SetHelpContext",0,[["AHelpContext",pas["WEBLib.Menus"].$rtti["THelpContext"]]]);
    $r.addMethod("GetHint",1,[],rtl.string);
    $r.addMethod("SetHint",0,[["AHint",rtl.string,2]]);
    $r.addMethod("GetRadioItem",1,[],rtl.boolean);
    $r.addMethod("SetRadioItem",0,[["ARadioItem",rtl.boolean]]);
    $r.addMethod("GetShortCut",1,[],pas["WEBLib.Menus"].$rtti["TShortCut"]);
    $r.addMethod("SetShortCut",0,[["AShortCut",pas["WEBLib.Menus"].$rtti["TShortCut"]]]);
    $r.addMethod("GetTag",1,[],rtl.longint);
    $r.addMethod("SetTag",0,[["AValue",rtl.longint]]);
    $r.addMethod("GetVisible",1,[],rtl.boolean);
    $r.addMethod("SetVisible",0,[["AVisible",rtl.boolean]]);
    $r.addMethod("Name",1,[],pas.Classes.$rtti["TComponentName"]);
    $r.addMethod("MenuIndex",1,[],rtl.longint);
    $r.addMethod("Parent",1,[],$r);
    $r.addMethod("HasParent",1,[],rtl.boolean);
    $r.addMethod("IsLine",1,[],rtl.boolean);
    $r.addProperty("Caption",3,pas.System.$rtti["WideString"],"GetCaption","SetCaption");
    $r.addProperty("Checked",3,rtl.boolean,"GetChecked","SetChecked");
    $r.addProperty("Enabled",3,rtl.boolean,"GetEnabled","SetEnabled");
    $r.addProperty("GroupIndex",3,rtl.byte,"GetGroupIndex","SetGroupIndex");
    $r.addProperty("HelpContext",3,pas["WEBLib.Menus"].$rtti["THelpContext"],"GetHelpContext","SetHelpContext");
    $r.addProperty("Hint",3,rtl.string,"GetHint","SetHint");
    $r.addProperty("RadioItem",3,rtl.boolean,"GetRadioItem","SetRadioItem");
    $r.addProperty("ShortCut",3,pas["WEBLib.Menus"].$rtti["TShortCut"],"GetShortCut","SetShortCut");
    $r.addProperty("Tag",3,rtl.longint,"GetTag","SetTag");
    $r.addProperty("Visible",3,rtl.boolean,"GetVisible","SetVisible");
  });
  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]],rtl.longint);
    $r.addMethod("Get",1,[["Index",rtl.longint]],pas.Classes.$rtti["TPersistent"]);
    $r.addMethod("GetCount",1,[],rtl.longint);
    $r.addProperty("Count",1,rtl.longint,"GetCount","");
    $r.addProperty("Items",1,pas.Classes.$rtti["TPersistent"],"Get","");
  });
  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, Operation) {
      pas.Classes.TComponent.Notification.apply(this,arguments);
      if ((AComponent === this.FNameLabel) && (Operation === 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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{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,[],$mod.$rtti["TTMSFNCBitmapContainer"]);
    $r.addProperty("BitmapContainer",3,$mod.$rtti["TTMSFNCBitmapContainer"],"GetBitmapContainer","SetBitmapContainer");
  });
  rtl.createInterface(this,"ITMSFNCBitmapContainerGetItem","{98F65D59-B40C-4574-AF9C-3CA68E86AE10}",["ItemCount","GetItem"],pas.System.IUnknown,function () {
    var $r = this.$rtti;
    $r.addMethod("ItemCount",1,[],rtl.longint);
    $r.addMethod("GetItem",1,[["AIndex",rtl.longint]],$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.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",$mod.$rtti["TTMSFNCBitmapContainer"]]]);
  });
  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, Operation) {
      var i = 0;
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Notification.apply(this,arguments);
      if ((Operation === 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.addMethod("Create$5",2,[]);
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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;
  };
  var TFloatStyle = {"0": "fsNone", fsNone: 0, "1": "fsLeft", fsLeft: 1, "2": "fsRight", fsRight: 2};
  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 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 = "";
      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);
      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 + h.get())),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) {
          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) {
                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") {
                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 = TFloatStyle.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 = TFloatStyle.fsLeft;
                    ir.Left = fr.Left;
                  };
                  if (Tagp === "RIGHT") imgfloat = TFloatStyle.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 === TFloatStyle.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 === TFloatStyle.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 === TFloatStyle.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) Align.set(pas.Classes.TAlignment.taRightJustify);
                  if (pas.System.Pos("LEFT",Prop) > 0) Align.set(pas.Classes.TAlignment.taLeftJustify);
                  if (pas.System.Pos("CENTER",Prop) > 0) Align.set(pas.Classes.TAlignment.taCenter);
                };
                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(TFloatStyle.fsLeft);
                  if (Prop === "RIGHT") txtfloat.set(TFloatStyle.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 = TFloatStyle.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 !== TFloatStyle.fsNone) && (txtfloat !== txtfloatbefore)) {
        r.Left = floatpt.x;
        r.Top = floatpt.y;
        txtfloat = TFloatStyle.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.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 () {
      if (this.GetCanvas() != null) {
        this.GetCanvas().BeginScene();
        this.GetCanvas().Clear();
      };
    };
    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]);
      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 () {
      if (!(this.FNCanvas != null)) return;
    };
    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]);
      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]);
      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 () {
      this.GetContext().BeginScene();
    };
    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.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);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
  });
  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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["AObject",pas.System.$rtti["TObject"]]]);
  });
},["SysUtils","WEBLib.TMSFNCPersistence"]);
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;
    };
    var $r = this.$rtti;
    $r.addMethod("create$3",2,[["ADataset",$mod.$rtti["TDataSet"]],["AOwner",pas.Classes.$rtti["TPersistent"]],["AClass",pas.Classes.$rtti["TCollectionItemClass"]]]);
  });
  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.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $r.addMethod("Create$3",2,[["AOwner",$mod.$rtti["TFieldDefs"]],["AName",rtl.string,2],["ADataType",$mod.$rtti["TFieldType"]],["ASize",rtl.longint],["ARequired",rtl.boolean],["AFieldNo",rtl.longint]]);
    $r.addProperty("Attributes",2,$mod.$rtti["TFieldAttributes"],"FAttributes","SetAttributes",{Default: {}});
    $r.addProperty("DataType",2,$mod.$rtti["TFieldType"],"FDataType","SetDataType");
    $r.addProperty("Precision",2,rtl.longint,"FPrecision","SetPrecision",{Default: 0});
    $r.addProperty("Size",2,rtl.longint,"FSize","SetSize",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$4",2,[["ADataSet",$mod.$rtti["TDataSet"]]]);
  });
  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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{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",{stored: "IsDisplayLabelStored"});
    $r.addProperty("DisplayWidth",15,rtl.longint,"GetDisplayWidth","SetDisplayWidth",{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",{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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Size",2,rtl.longint,"FSize","SetSize",{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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("MaxValue",2,rtl.longint,"FMaxValue","SetMaxValue",{Default: 0});
    $r.addProperty("MinValue",2,rtl.longint,"FMinValue","SetMinValue",{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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("MaxValue",2,rtl.nativeint,"FMaxValue","SetMaxValue",{Default: 0});
    $r.addProperty("MinValue",2,rtl.nativeint,"FMinValue","SetMinValue",{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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Currency",2,rtl.boolean,"FCurrency","SetCurrency",{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",{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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Size",2,rtl.longint,"FSize","SetSize",{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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("DisplayValue",2,$mod.$rtti["TBlobDisplayValue"],"FDisplayValue","SetDisplayValue",{Default: $mod.TBlobDisplayValue.dvClass});
    $r.addProperty("BlobType",3,$mod.$rtti["TBlobType"],"GetBlobType","SetBlobType");
    $r.addProperty("Size",2,rtl.longint,"FSize","SetSize",{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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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.addMethod("Create$2",2,[["Owner",$mod.$rtti["TIndexDefs"]],["AName",rtl.string,2],["TheFields",rtl.string,2],["TheOptions",$mod.$rtti["TIndexOptions"]]]);
    $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;
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$4",2,[["ADataSet",$mod.$rtti["TDataSet"]]]);
  });
  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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["AOwner",pas.Classes.$rtti["TPersistent"]]]);
  });
  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.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $r.addMethod("Create$3",2,[["AParams",$mod.$rtti["TParams"]],["AParamType",$mod.$rtti["TParamType"]]]);
    $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",{Default: 0});
    $r.addProperty("ParamType",0,$mod.$rtti["TParamType"],"FParamType","FParamType");
    $r.addProperty("Precision",0,rtl.longint,"FPrecision","FPrecision",{Default: 0});
    $r.addProperty("Size",0,rtl.longint,"FSize","FSize",{Default: 0});
    $r.addProperty("Value",15,rtl.jsvalue,"GetAsJSValue","SetAsJSValue",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["AOwner",pas.Classes.$rtti["TPersistent"]],["AItemClass",pas.Classes.$rtti["TCollectionItemClass"]]]);
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TPersistent"]]]);
    $r.addMethod("Create$4",2,[]);
  });
  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",{});
    $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",{});
    $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",{});
    $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",{});
    $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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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;
      };
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
  });
  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);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["ADataSet",$mod.$rtti["TDataSet"]]]);
  });
  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);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["ADataSet",$mod.$rtti["TDataSet"]]]);
  });
  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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("AutoEdit",0,rtl.boolean,"FAutoEdit","FAutoEdit",{Default: true});
    $r.addProperty("DataSet",2,$mod.$rtti["TDataSet"],"FDataSet","SetDataSet");
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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);
  });
  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,null,null,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,null,this.TLargeintField,null,null,null,this.TDataSetField,this.TBlobField,this.TMemoField,this.TVariantField,null,null,null,null,null,null,null,null,this.TStringField,null,null,null,null,null,null,null,null,null,null];
  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("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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: true});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor$1","SetColorEx",{Default: 16777215});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EllipsisPosition",2,$mod.$rtti["TEllipsisPosition"],"FEllipsisPosition","SetEllipsisPosition",{Default: $mod.TEllipsisPosition.epNone});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: $mod.THTMLType.tLABELTAG});
    $r.addProperty("Layout",2,$mod.$rtti["TTextLayout"],"FLayout","SetLayout",{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",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowAccelChar",0,rtl.boolean,"FShowAccelChar","FShowAccelChar",{Default: true});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Transparent",2,rtl.boolean,"FTransparent","SetTransparent",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("WordWrap",0,rtl.boolean,"FWordWrap","FWordWrap",{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.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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoCompletion",2,$mod.$rtti["TAutoCompletion"],"FAutoCompletion","SetAutoCompletion",{Default: $mod.TAutoCompletion.acOff});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",{Default: true});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{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",{Default: $mod.TEditCharCase.wecNormal});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EditType",2,$mod.$rtti["TEditType"],"FEditType","SetEditType",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: true});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",{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",{Default: 0});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("SpellCheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{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",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: 100});
    $r.addProperty("MinValue",2,rtl.longint,"FMinValue","SetMinValue",{Default: 0});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{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",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Value",3,rtl.longint,"GetValue","SetValue");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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) {
        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.FTabStop) {
          el.setAttribute("tabindex",pas.SysUtils.IntToStr(this.FTabOrder))}
         else el.setAttribute("tabindex","-1");
        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 () {
      if (this.GetElementPicker() != null) {
        this.GetElementPicker().focus();
      };
    };
    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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoDropDown",0,rtl.boolean,"FAutoDropDown","FAutoDropDown",{Default: false});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Checked",2,rtl.boolean,"FChecked","SetChecked",{Default: false});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{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",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: true});
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowCheckBox",2,rtl.boolean,"FShowCheckBox","SetShowCheckBox",{Default: false});
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("ShowSeconds",2,rtl.boolean,"FShowSeconds","SetShowSeconds",{Default: true});
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{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",{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",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{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",{Default: false});
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("Default",2,rtl.boolean,"FDefault","SetDefault",{Default: false});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{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",{Default: true});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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 (btn.style != null) btn.style.setProperty("margin-right","4px");
          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.setProperty("float","left");
              } 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("vertical-align","middle");
              lbl.style.setProperty("min-height","100%");
              lbl.style.setProperty("height","100%");
              lbl.style.setProperty("position","absolute");
              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;
      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;
      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;
      };
      this.DoCheckClick();
      Result = true;
      return Result;
    };
    this.Click = function () {
      pas["WEBLib.Controls"].TControl.Click.call(this);
      if (!this.FAllowGrayed) {
        this.FChecked = this.GetChecked();
        if (this.FChecked) {
          this.FState = $mod.TCheckBoxState.cbChecked}
         else this.FState = $mod.TCheckBoxState.cbUnchecked;
      };
      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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{Default: pas.Classes.TAlignment.taRightJustify});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("AllowGrayed",0,rtl.boolean,"FAllowGrayed","FAllowGrayed",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{Default: false});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: -1});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{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",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("State",3,$mod.$rtti["TCheckBoxState"],"GetState","SetState",{Default: $mod.TCheckBoxState.cbUnchecked});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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 === "") {
              btn.style.setProperty("float","left");
              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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{Default: false});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: -1});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{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",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{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",{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{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",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",{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",{Default: true});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{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",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{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",{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{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",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: -1});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{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",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",{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",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{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",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",{Default: -1});
    $r.addProperty("Left",3,rtl.longint,"GetLeft","SetLeft");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{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",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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.$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.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.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()) {
          this.GetElementInputHandle().style.setProperty("resize","none");
        };
        this.GetElementInputHandle().readOnly = this.IsReadOnly();
        if (this.FTextHint !== "") this.GetElementInputHandle().placeholder = this.FTextHint;
        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.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.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.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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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("ParentColor",2,rtl.boolean,"FParentColor","SetParentColor",{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{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",{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",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("Spellcheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{Default: pas["WEBLib.Controls"].TTextDirection.tdDefault});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{Default: 0});
    $r.addProperty("Columns",2,rtl.longint,"FColumns","SetColumns");
    $r.addProperty("ControlPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FControlPosition","SetControlPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{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",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{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",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{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",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{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.FBlockScrolling = false;
      this.FScrolling = 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();
      };
    };
    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.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;
      if (!this.FBlockScrolling) {
        this.FScrolling = true;
        if (this.FOnChange != null) this.FOnChange(this);
        this.FScrolling = false;
        Result = true;
      } else Result = false;
      this.FBlockScrolling = false;
      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.FBlockScrolling = true;
      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.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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{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("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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: true});
    $r.addProperty("Caption",2,rtl.string,"FCaption","SetCaption");
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor$1","SetColorEx",{Default: 16777215});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EllipsisPosition",2,pas["WEBLib.StdCtrls"].$rtti["TEllipsisPosition"],"FEllipsisPosition","SetEllipsisPosition",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{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",{Default: false});
    $r.addProperty("Target",2,$mod.$rtti["TLinkTarget"],"FTarget","SetTarget",{Default: $mod.TLinkTarget.ltCurrentTab});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Transparent",2,rtl.boolean,"FTransparent","SetTransparent",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WordWrap",0,rtl.boolean,"FWordWrap","FWordWrap",{Default: false});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle$1","SetHeightStyle$1",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle$1","SetWidthStyle$1",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent$1","SetHeightPercent$1",{Default: 100});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent$1","SetWidthPercent$1",{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",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: 10});
    $r.addProperty("Min",2,rtl.longint,"FMin","SetMin",{Default: 0});
    $r.addProperty("Orientation",2,$mod.$rtti["TTrackBarOrientation"],"FOrientation","SetOrientation",{Default: $mod.TTrackBarOrientation.trHorizontal});
    $r.addProperty("Position",3,rtl.longint,"GetPosition","SetPosition",{Default: 0});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Interval",2,rtl.longint,"FInterval","SetInterval",{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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("HighPrecision",0,rtl.boolean,"FHighPrecision","FHighPrecision",{Default: false});
    $r.addProperty("TimeOut",0,rtl.longint,"FTimeOut","FTimeOut",{Default: 60000});
    $r.addProperty("MaximumAge",0,rtl.longint,"FMaximumAge","FMaximumAge",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",0,rtl.boolean,"FAutoSize","FAutoSize",{Default: false});
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{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",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: false});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TImageZoomControl"]]]);
    $r.addProperty("HeightPercent",2,rtl.longint,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("WidthPercent",2,rtl.longint,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("ResponsiveHeightPercent",2,rtl.longint,"FResponsiveHeightPercent","SetResponsiveHeightPercent",{Default: 100});
    $r.addProperty("ResponsiveWidthPercent",2,rtl.longint,"FResponsiveWidthPercent","SetResponsiveWidthPercent",{Default: 100});
    $r.addProperty("ResponsiveMaxWidth",2,rtl.longint,"FResponsiveMaxWidth","SetResponsiveMaxWidth",{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",{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.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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{Default: pas.Classes.TAlignment.taCenter});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",{Default: 12632256});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{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",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{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",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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.$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.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) {
        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.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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",{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",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{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",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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);
      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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{Default: 12632256});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{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",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{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",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{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",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("GripColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FGripColor","SetGripColor",{Default: 16777215});
    $r.addProperty("Margins",2,pas["WEBLib.Controls"].$rtti["TMargins"],"FMargins","SetMargins");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $r.addProperty("Alignment",0,$mod.$rtti["TVerticalAlignment"],"FAlignment","FAlignment",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $r.addProperty("Alignment",0,pas.Classes.$rtti["TAlignment"],"FAlignment","FAlignment",{Default: pas.Classes.TAlignment.taLeftJustify});
    $r.addProperty("ElementClassName",0,rtl.string,"FElementClassName","FElementClassName");
    $r.addProperty("MarginLeft",2,rtl.longint,"FMarginLeft","SetMarginLeft",{Default: 0});
    $r.addProperty("MarginRight",2,rtl.longint,"FMarginRight","SetMarginRight",{Default: 0});
    $r.addProperty("SizeStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FSizeStyle","SetSizeStyle",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{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",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("ExpandStyle",0,$mod.$rtti["TGridPanelExpandStyle"],"FExpandStyle","FExpandStyle",{Default: $mod.TGridPanelExpandStyle.esAddRows});
    $r.addProperty("GridLineWidth",0,rtl.longint,"FGridLineWidth","FGridLineWidth",{Default: 0});
    $r.addProperty("GridLineColor",0,pas["WEBLib.Graphics"].$rtti["TColor"],"FGridLineColor","FGridLineColor",{Default: 0});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{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",{Default: true});
    $r.addProperty("HideControls",2,$mod.$rtti["TMultiMediaControls"],"FHideControls","SetHideControls");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{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",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{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",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: 255});
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{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",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{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",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TCollection"]]]);
    $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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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) {
          this.FControlCollection.Delete(i);
          break;
        };
      };
    };
    this.RemoveControls = function () {
      var i = 0;
      for (var $l = this.FControlCollection.GetCount() - 1; $l >= 0; $l--) {
        i = $l;
        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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{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",{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",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: false});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ItemIndex",3,rtl.longint,"GetItemIndex","SetItemIndex",{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",{Default: true});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{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",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: false});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{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",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.StdCtrls"].TAutoCompletion.acOff});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",{Default: true});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("CharCase",2,pas["WEBLib.StdCtrls"].$rtti["TEditCharCase"],"FCharCase","SetCharCase",{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",{Default: 0});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",{Default: "\x00"});
    $r.addProperty("Pattern",2,rtl.string,"FPattern","SetPattern");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("TextHint",2,rtl.string,"FTextHint","SetTextHint");
    $r.addMethod("SetFocus",0,[]);
    $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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoCompletion",2,pas["WEBLib.StdCtrls"].$rtti["TAutoCompletion"],"FAutoCompletion","SetAutoCompletion",{Default: pas["WEBLib.StdCtrls"].TAutoCompletion.acOff});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",{Default: true});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("CharCase",2,pas["WEBLib.StdCtrls"].$rtti["TEditCharCase"],"FCharCase","SetCharCase",{Default: pas["WEBLib.StdCtrls"].TEditCharCase.wecNormal});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{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",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EditType",2,pas["WEBLib.StdCtrls"].$rtti["TEditType"],"FEditType","SetEditType",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: true});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",{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",{Default: 0});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{Default: false});
    $r.addProperty("SearchImageURL",2,rtl.string,"FSearchImageURL","SetSearchImageURL");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("SpellCheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{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",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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.addMethod("Create$1",2,[]);
    $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",{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",{Default: pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal});
    $r.addProperty("Width",2,rtl.longint,"FWidth","SetWidth",{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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoCompletion",2,pas["WEBLib.StdCtrls"].$rtti["TAutoCompletion"],"FAutoCompletion","SetAutoCompletion",{Default: pas["WEBLib.StdCtrls"].TAutoCompletion.acOff});
    $r.addProperty("AutoFocus",2,rtl.boolean,"FAutoFocus","SetAutoFocus",{Default: false});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("AutoSelect",2,rtl.boolean,"FAutoSelect","SetAutoSelect",{Default: true});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{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",{Default: pas["WEBLib.StdCtrls"].TEditCharCase.wecNormal});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("EditType",2,pas["WEBLib.StdCtrls"].$rtti["TEditType"],"FEditType","SetEditType",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: true});
    $r.addProperty("PasswordChar",2,rtl.char,"FPasswordChar","SetPasswordChar",{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",{Default: 0});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ReadOnly",2,rtl.boolean,"FReadOnly","SetReadOnly",{Default: false});
    $r.addProperty("Required",2,rtl.boolean,"FRequired","SetRequired",{Default: false});
    $r.addProperty("RequiredText",0,rtl.string,"FRequiredText","FRequiredText");
    $r.addProperty("ShowFocus",2,rtl.boolean,"FShowFocus","SetShowFocus",{Default: false});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("SpellCheck",2,rtl.boolean,"FSpellCheck","SetSpellCheck",{Default: true});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Text",3,rtl.string,"GetText","SetText");
    $r.addProperty("TextDirection",0,pas["WEBLib.Controls"].$rtti["TTextDirection"],"FTextDirection","FTextDirection",{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",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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]);
      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")]);
      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")]);
      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")]);
      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]);
      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.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TTMSFNCCustomEditorButton"]]]);
    $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",{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("TextAlignVertical",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FTextAlignVertical","SetTextAlignVertical",{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",{Default: $mod.TTMSFNCEditorButtonPosition.ebpAlone});
    $r.addProperty("ModalResult",0,rtl.longint,"FModalResult","FModalResult",{Default: 0});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{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]);
      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")]);
      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.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TTMSFNCCustomEditorPanel"]]]);
    $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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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",{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",{});
    $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",{});
    $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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TTreeNodes"]]]);
  });
  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);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
},["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 + '" 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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Flat",2,rtl.boolean,"FFlat","SetFlat",{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",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Layout",0,$mod.$rtti["TButtonLayout"],"FLayout","FLayout",{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",{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",{Default: pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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 + '" 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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Alignment",2,pas.Classes.$rtti["TAlignment"],"FAlignment","SetAlignment",{Default: pas.Classes.TAlignment.taCenter});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Cancel",0,rtl.boolean,"FCancel","FCancel",{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",{Default: false});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Font",2,pas["WEBLib.Graphics"].$rtti["TFont"],"FFont","SetFont");
    $r.addProperty("Flat",2,rtl.boolean,"FFlat","SetFlat",{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",{Default: 0});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Hint",2,rtl.string,"FHint","SetHint");
    $r.addProperty("Layout",2,$mod.$rtti["TButtonLayout"],"FLayout","SetLayout",{Default: $mod.TButtonLayout.blGlyphLeft});
    $r.addProperty("MaterialGlyph",2,rtl.string,"FMaterialGlyph","SetMaterialGlyph");
    $r.addProperty("MaterialGlyphColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FMaterialGlyphColor","SetMaterialGyphColor",{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",{Default: pas["WEBLib.Controls"].TMaterialGlyphType.mgNormal});
    $r.addProperty("ModalResult",0,rtl.longint,"FModalResult","FModalResult",{Default: 0});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor",{Default: 13619151});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: false});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{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",{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",{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",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Style",2,$mod.$rtti["TToggleButtonStyle"],"FStyle","SetStyle",{Default: $mod.TToggleButtonStyle.tsRectangular});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{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();
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TCustomRichEdit"]]]);
  });
  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",{});
    $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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("AutoSize",2,rtl.boolean,"FAutoSize","SetAutoSize",{Default: false});
    $r.addProperty("ElementClassName",2,pas["WEBLib.Controls"].$rtti["TElementClassName"],"FElementClassName","SetElementClassName");
    $r.addProperty("ElementFont",2,pas["WEBLib.Controls"].$rtti["TElementFont"],"FElementFont","SetElementFont",{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",{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",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("InsertLineBreaks",0,rtl.boolean,"FInsertLineBreaks","FInsertLineBreaks",{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",{Default: false});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("WantTabs",0,rtl.boolean,"FWantTabs","FWantTabs",{Default: false});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{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",{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",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("SelectedColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedColor","SetSelectedColor",{Default: 12632256});
    $r.addProperty("SelectedTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedTextColor","SetSelectedTextColor",{Default: 0});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("UseHash",0,rtl.boolean,"FUseHash","FUseHash",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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.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",{Default: pas.Classes.TAlignment.taCenter});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("BorderColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FBorderColor","SetBorderColor",{Default: 12632256});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{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",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: -1});
    $r.addProperty("MaterialGlyphSize",2,rtl.longint,"FMaterialGlyphSize","SetMaterialGlyphSize",{Default: 18});
    $r.addProperty("MaterialGlyphType",2,pas["WEBLib.Controls"].$rtti["TMaterialGlyphType"],"FMaterialGlyphType","SetMaterialGlyphType",{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",{Default: true});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("TabVisible",2,rtl.boolean,"FTabVisible","SetTabVisible",{Default: true});
    $r.addProperty("TabEnabled",2,rtl.boolean,"FTabEnabled","SetTabEnabled",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{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 + '" 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;
            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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsNone});
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("DisabledTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FDisabledTextColor","SetDisabledTextColor",{Default: 8421504});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{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",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{Default: false});
    $r.addProperty("ShowTabs",2,rtl.boolean,"FShowTabs","SetShowTabs",{Default: true});
    $r.addProperty("SelectedColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedColor","SetSelectedColor",{Default: 12632256});
    $r.addProperty("SelectedTextColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FSelectedTextColor","SetSelectedTextColor",{Default: 0});
    $r.addProperty("TabOrder",2,rtl.longint,"FTabOrder","SetTabOrder");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("Top",3,rtl.longint,"GetTop","SetTop");
    $r.addProperty("UseHash",0,rtl.boolean,"FUseHash","FUseHash",{Default: true});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{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",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Height",3,rtl.longint,"GetHeight","SetHeight");
    $r.addProperty("HeightPercent",2,rtl.double,"FHeightPercent","SetHeightPercent",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: -1});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Width",3,rtl.longint,"GetWidth","SetWidth");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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 n = null;
      var Allow = false;
      el = Event.srcElement;
      if ((el != null) && el.hasAttribute("id")) {
        n = this.GetNodeFromID(el.getAttribute("id"));
        Allow = true;
        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;
        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.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",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{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",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: true});
    $r.addProperty("PopupMenu",0,pas["WEBLib.Menus"].$rtti["TPopupMenu"],"FPopupMenu","FPopupMenu");
    $r.addProperty("WidthPercent",2,rtl.double,"FWidthPercent","SetWidthPercent",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{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, Operation) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Notification.apply(this,arguments);
      if ((Operation === 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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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);
    var $r = this.$rtti;
    $r.addMethod("CreateDialogNew$1",2,[["ABitmapEditor",$mod.$rtti["TTMSFNCBitmapEditor"]],["ACaption",rtl.string]]);
  });
  $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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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]);
      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]);
      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")]);
      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")]);
      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")]);
      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")]);
      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]);
      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")]);
      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")]);
      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")]);
      this.FSplitter = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.HTMLToColor("#1BADF8")]);
      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.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TTMSFNCEditorListView"]]]);
    $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",{stored: "IsItemVerticalSpacingStored"});
    $r.addProperty("ItemHorizontalTextMargin",14,rtl.double,"FItemHorizontalTextMargin","SetItemHorizontalTextMargin",{stored: "IsItemHorizontalTextMarginStored"});
    $r.addProperty("ItemHorizontalSpacing",14,rtl.double,"FItemHorizontalSpacing","SetItemHorizontalSpacing",{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",{Default: 4});
    $r.addProperty("SplitterMarginRight",2,rtl.longint,"FSplitterMarginRight","SetSplitterMarginRight",{Default: 4});
    $r.addProperty("DrawItemImageStroke",2,rtl.boolean,"FDrawItemImageStroke","SetDrawItemImageStroke",{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 ((ACollection != 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.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $r.addProperty("Control",2,pas["WEBLib.Controls"].$rtti["TControl"],"FControl","SetControl");
    $r.addProperty("ControlAlignment",2,pas["WEBLib.TMSFNCCustomControl"].$rtti["TTMSFNCControlAlignment"],"FControlAlignment","SetControlAlignment",{Default: pas["WEBLib.TMSFNCCustomControl"].TTMSFNCControlAlignment.caNone});
    $r.addProperty("ControlPosition",2,pas["WEBLib.TMSFNCCustomControl"].$rtti["TTMSFNCControlPosition"],"FControlPosition","SetControlPosition",{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",{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",{Default: false});
    $r.addProperty("IsSplitter",2,rtl.boolean,"FIsSplitter","SetIsSplitter",{Default: false});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("HorizontalNameAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorizontalNameAlign","SetHorizontalNameAlign",{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading});
    $r.addProperty("HorizontalNoteAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorizontalNoteAlign","SetHorizontalNoteAlign",{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaLeading});
    $r.addProperty("AccessoryClickable",2,rtl.boolean,"FAccessoryClickable","SetAccessoryClickable",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",$mod.$rtti["TTMSFNCEditorListView"]]]);
  });
  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",{});
    $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",{});
    $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",{});
    $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",{});
    $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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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",{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",{stored: "IsDefaultItemHeightStored"});
    $r.addProperty("ItemsReadOnly",2,rtl.boolean,"FItemsReadOnly","SetItemsReadOnly",{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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("DrawNoteText",2,rtl.boolean,"FDrawNoteText","SetDrawNoteText",{Default: false});
    $r.addProperty("DrawDataString",2,rtl.boolean,"FDrawNoteText","SetDrawNoteText",{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",{stored: "IsDefaultItemHeightStored"});
    $r.addProperty("ItemsReadOnly",2,rtl.boolean,"FItemsReadOnly","SetItemsReadOnly",{Default: false});
    $r.addProperty("LastSelectedItemIndex",0,rtl.longint,"FLastSelectedItemIndex","",{Default: -1});
    $r.addProperty("MultiSelect",2,rtl.boolean,"FMultiSelect","SetMultiSelect",{Default: true});
    $r.addProperty("CanUnselectItems",0,rtl.boolean,"FCanUnselectItems","FCanUnselectItems",{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",{});
    $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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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",{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",{});
    $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, Operation) {
      pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent.Notification.apply(this,arguments);
      if (Operation === 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);
              };
            };
            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);
              };
            };
            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);
        };
        if (this.FComboBoxColumnsSubPropertyName.FParent != null) {
          this.FComboBoxColumnsSubPropertyName.SetItemIndex(-1);
          this.FComboBoxColumnsSubPropertyName.SetText(this.FBuildItem.Item.FColumnsSubPropertyName);
        };
        if (this.FComboBoxPropertyName.FParent != null) {
          this.FComboBoxPropertyName.SetItemIndex(-1);
          this.FComboBoxPropertyName.SetText(this.FBuildItem.Item.FPropertyName);
        };
        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.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.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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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);
    var $r = this.$rtti;
    $r.addMethod("CreateDialogNew$1",2,[["ADataBindingEditor",$mod.$rtti["TTMSFNCDataBindingEditor"]],["ACaption",rtl.string]]);
  });
  $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 = 1;
  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,[],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,[],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,[],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");
  });
  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);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$2",2,[["ADataBinderItem",$mod.$rtti["TTMSFNCDataBinderItem"]]]);
  });
  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.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",$mod.$rtti["TTMSFNCDataBinderItem"]]]);
  });
  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.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",$mod.$rtti["TTMSFNCDataBinderItem"]]]);
  });
  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.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $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",{Default: true});
    $r.addProperty("BindType",2,$mod.$rtti["TTMSFNCDataBinderBindType"],"FBindType","SetBindType",{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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",$mod.$rtti["TTMSFNCDataBinder"]]]);
  });
  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,1);
      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, Operation) {
      var i = 0;
      if ((Operation === 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.addMethod("Create$5",2,[]);
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $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",{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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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.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.setIntfP(this,"FManager",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]);
        g.BeginScene();
      } 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]);
      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.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
    $r.addProperty("AdaptToStyle",3,rtl.boolean,"GetAdaptToStyle","SetAdaptToStyle",{Default: false});
    $r.addProperty("AllowFocus",3,rtl.boolean,"GetAllowFocus","SetAllowFocus",{Default: true});
    $r.addProperty("Align",2,pas["WEBLib.Controls"].$rtti["TAlign"],"FAlign","SetAlign",{Default: pas["WEBLib.Controls"].TAlign.alNone});
    $r.addProperty("AlignWithMargins",2,rtl.boolean,"FAlignWithMargins","SetAlignWithMargins",{Default: false});
    $r.addProperty("Anchors",2,pas["WEBLib.Controls"].$rtti["TAnchors"],"FAnchors","SetAnchors",{Default: rtl.createSet(pas["WEBLib.Controls"].TAnchorKind.akLeft,pas["WEBLib.Controls"].TAnchorKind.akTop)});
    $r.addProperty("BiDiMode",2,pas["WEBLib.Controls"].$rtti["TBiDiMode"],"FBiDiMode","SetBiDiMode",{Default: pas["WEBLib.Controls"].TBiDiMode.bdLeftToRight});
    $r.addProperty("BorderStyle",2,pas["WEBLib.Controls"].$rtti["TBorderStyle"],"FBorderStyle","SetBorderStyle",{Default: pas["WEBLib.Controls"].TBorderStyle.bsSingle});
    $r.addProperty("Center",0,pas["WEBLib.Controls"].$rtti["TCenter"],"FCenter","");
    $r.addProperty("ChildOrder",2,rtl.longint,"FChildOrder","SetChildOrderEx",{Default: 0});
    $r.addProperty("Color",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FColor","SetColor");
    $r.addProperty("DragMode",2,pas["WEBLib.Controls"].$rtti["TDragMode"],"FDragMode","SetDragMode",{Default: pas["WEBLib.Controls"].TDragMode.dmManual});
    $r.addProperty("DoubleBuffered",0,rtl.boolean,"FDoubleBuffered","FDoubleBuffered",{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",{Default: pas["WEBLib.Controls"].TElementFont.efProperty});
    $r.addProperty("ElementPosition",2,pas["WEBLib.Controls"].$rtti["TElementPosition"],"FElementPosition","SetElementPosition",{Default: pas["WEBLib.Controls"].TElementPosition.epAbsolute});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{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",{Default: 100});
    $r.addProperty("HeightStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FHeightStyle","SetHeightStyle",{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",{Default: true});
    $r.addProperty("ParentFont",2,rtl.boolean,"FParentFont","SetParentFont",{Default: true});
    $r.addProperty("Role",3,rtl.string,"GetRole","SetRole");
    $r.addProperty("TabStop",2,rtl.boolean,"FTabStop","SetTabStop",{Default: true});
    $r.addProperty("ShowHint",2,rtl.boolean,"FShowHint","SetShowHint",{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",{Default: 100});
    $r.addProperty("WidthStyle",2,pas["WEBLib.Controls"].$rtti["TSizeStyle"],"FWidthStyle","SetWidthStyle",{Default: pas["WEBLib.Controls"].TSizeStyle.ssAbsolute});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{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",{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)]);
      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)]);
      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)]);
      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)]);
      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)]);
      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)]);
      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)]);
      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)]);
      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)]);
      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)]);
      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)]);
      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)]);
      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)]);
      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.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TTMSFNCCustomScrollBar"]]]);
    $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",{stored: "IsThumbButtonSizeStored"});
    $r.addProperty("ScrollButtonSize",14,rtl.double,"FScrollButtonSize","SetScrollButtonSize",{stored: "IsScrollButtonSizeStored"});
    $r.addProperty("FixedThumb",2,rtl.boolean,"FFixedThumb","SetFixedThumb",{Default: false});
    $r.addProperty("ArrowColor",2,pas["WEBLib.Graphics"].$rtti["TColor"],"FArrowColor","SetArrowColor",{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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  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",{Default: $mod.TTMSFNCScrollBarKind.sbkVertical});
    $r.addProperty("LargeChange",12,rtl.double,"FLargeChange","FLargeChange",{stored: "IsLargeChangeStored"});
    $r.addProperty("Max",14,rtl.double,"FMax","SetMax",{stored: "IsMaxStored"});
    $r.addProperty("Tracking",2,rtl.boolean,"FTracking","SetTracking",{Default: true});
    $r.addProperty("Min",14,rtl.double,"FMin","SetMin",{stored: "IsMinStored"});
    $r.addProperty("PageSize",14,rtl.double,"FPageSize","SetPageSize",{stored: "IsPageSizeStored"});
    $r.addProperty("Value",14,rtl.double,"FValue","SetValue",{stored: "IsValueStored"});
    $r.addProperty("SmallChange",12,rtl.double,"FSmallChange","FSmallChange",{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);
      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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  $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.TMSFNCTileList",["System","Classes","WEBLib.TMSFNCTypes","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCCustomScrollControl","WEBLib.TMSFNCBitmapContainer","WEBLib.TMSFNCCustomComponent","WEBLib.Controls","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 = 3;
  this.$rtti.$Class("TTMSFNCCustomTileList");
  this.$rtti.$Class("TTMSFNCTileListVisualizer");
  this.TTMSFNCTileListItemState = {"0": "isNormal", isNormal: 0, "1": "isHover", isHover: 1, "2": "isDown", isDown: 2, "3": "isSelected", isSelected: 3, "4": "isDisabled", isDisabled: 4};
  this.$rtti.$Enum("TTMSFNCTileListItemState",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCTileListItemState});
  this.TTMSFNCTileListItemType = {"0": "lbtDefault", lbtDefault: 0, "1": "lbtDropDown", lbtDropDown: 1};
  this.$rtti.$Enum("TTMSFNCTileListItemType",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTileListItemType});
  this.TTMSFNCTileListReorderMode = {"0": "rmNone", rmNone: 0, "1": "rmRearrange", rmRearrange: 1, "2": "rmSwap", rmSwap: 2, "3": "rmShift", rmShift: 3};
  this.$rtti.$Enum("TTMSFNCTileListReorderMode",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCTileListReorderMode});
  this.TTMSFNCTileListControlPosition = {"0": "tcpBottom", tcpBottom: 0, "1": "tcpLeft", tcpLeft: 1, "2": "tcpRight", tcpRight: 2, "3": "tcpClient", tcpClient: 3, "4": "tcpCustom", tcpCustom: 4};
  this.$rtti.$Enum("TTMSFNCTileListControlPosition",{minvalue: 0, maxvalue: 4, ordtype: 1, enumtype: this.TTMSFNCTileListControlPosition});
  this.TTMSFNCTileListImagePosition = {"0": "tipLeft", tipLeft: 0, "1": "tipRight", tipRight: 1, "2": "tipTop", tipTop: 2, "3": "tipBottom", tipBottom: 3, "4": "tipClient", tipClient: 4, "5": "tipCustom", tipCustom: 5};
  this.$rtti.$Enum("TTMSFNCTileListImagePosition",{minvalue: 0, maxvalue: 5, ordtype: 1, enumtype: this.TTMSFNCTileListImagePosition});
  this.TTMSFNCTileListFiltering = {"0": "tlfAny", tlfAny: 0, "1": "tlfStart", tlfStart: 1};
  this.$rtti.$Enum("TTMSFNCTileListFiltering",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTileListFiltering});
  rtl.createClass(this,"TTMSFNCTileListItem",pas.Classes.TCollectionItem,function () {
    this.$init = function () {
      pas.Classes.TCollectionItem.$init.call(this);
      this.FRowSpan = 0;
      this.FColumnSpan = 0;
      this.FVisible = false;
      this.FDescription = "";
      this.FEnabled = false;
      this.FMargins = null;
      this.FCanDeselect = false;
      this.FCanSelect = false;
      this.FVerticalTitleAlign = 0;
      this.FHorizontalTitleAlign = 0;
      this.FHint = "";
      this.FDataBoolean = false;
      this.FDataString = "";
      this.FDataObject = null;
      this.FDataInteger = 0;
      this.FEmpty = false;
      this.FSelected = false;
      this.FControl = null;
      this.FBadge = "";
      this.FTitle = "";
      this.FVisualizer = null;
      this.FControlTop = 0.0;
      this.FControlLeft = 0.0;
      this.FControlHeight = 0.0;
      this.FControlPosition = 0;
      this.FTitleHeight = 0.0;
      this.FControlWidth = 0.0;
      this.FImagePosition = 0;
      this.FImageTop = 0.0;
      this.FImageLeft = 0.0;
      this.FImageHeight = 0.0;
      this.FImageWidth = 0.0;
      this.FImage = null;
      this.FImageName = "";
      this.FVerticalDescriptionAlign = 0;
      this.FHorizontalDescriptionAlign = 0;
      this.FOwner = null;
      this.FOldParent = null;
    };
    this.$final = function () {
      this.FMargins = undefined;
      this.FDataObject = undefined;
      this.FControl = undefined;
      this.FVisualizer = undefined;
      this.FImage = undefined;
      this.FOwner = undefined;
      this.FOldParent = undefined;
      pas.Classes.TCollectionItem.$final.call(this);
    };
    this.SetColumnSpan = function (Value) {
      if (this.FColumnSpan !== Value) {
        if (Value > -1) {
          if ((this.FOwner != null) && (Value > this.FOwner.FColumns)) {
            this.FColumnSpan = this.FOwner.FRows}
           else this.FColumnSpan = Value;
          if (this.FOwner != null) this.FOwner.CalculateItems(true);
        };
      };
    };
    this.SetRowSpan = function (Value) {
      if (this.FRowSpan !== Value) {
        if (Value > -1) {
          if ((this.FOwner != null) && (Value > this.FOwner.FRows)) {
            this.FRowSpan = this.FOwner.FRows}
           else this.FRowSpan = Value;
          if (this.FOwner != null) this.FOwner.CalculateItems(true);
        };
      };
    };
    this.SetVisible = function (Value) {
      if (this.FVisible !== Value) {
        this.FVisible = Value;
        this.FOwner.CalculateItems(true);
      };
    };
    this.SetDescription = function (Value) {
      if (this.FDescription !== Value) {
        this.FDescription = Value;
        this.InvalidateItems();
      };
    };
    this.SetEnabled = function (Value) {
      if (this.FEnabled !== Value) {
        this.FEnabled = Value;
        this.InvalidateItems();
      };
    };
    this.SetMargins = function (Value) {
      this.FMargins.Assign(Value);
    };
    this.SetCanDeselect = function (Value) {
      this.FCanDeselect = Value;
    };
    this.SetCanSelect = function (Value) {
      this.FCanSelect = Value;
    };
    this.SetHorizontalTitleAlign = function (Value) {
      if (this.FHorizontalTitleAlign !== Value) {
        this.FHorizontalTitleAlign = Value;
        if (this.FTitle !== "") this.InvalidateItems();
      };
    };
    this.SetVerticalTitleAlign = function (Value) {
      if (this.FVerticalTitleAlign !== Value) {
        this.FVerticalTitleAlign = Value;
        if (this.FTitle !== "") this.InvalidateItems();
      };
    };
    this.SetEmpty = function (Value) {
      if (this.FEmpty !== Value) {
        this.FEmpty = Value;
        this.InvalidateItems();
      };
    };
    this.SetSelected = function (Value) {
      if (this.FSelected !== Value) {
        this.FSelected = Value;
        this.InvalidateItems();
      };
    };
    this.SetControl = function (Value) {
      if ((this.FOldParent != null) && (this.FControl != null)) this.FControl.SetParent(this.FOldParent);
      if (Value != null) {
        this.FOldParent = Value.FParent}
       else this.FOldParent = null;
      this.FControl = Value;
      if ((this.FControl != null) && (this.GetTileOwner() != null)) this.FControl.SetParent(this.GetTileOwner());
    };
    this.SetBadge = function (Value) {
      if (this.FBadge !== Value) {
        this.FBadge = Value;
        this.InvalidateItems();
      };
    };
    this.SetTitle = function (Value) {
      if (this.FTitle !== Value) {
        this.FTitle = Value;
        this.InvalidateItems();
      };
    };
    this.SetControlHeight = function (Value) {
      if (this.FControlHeight !== Value) {
        if (Value >= 0) {
          this.FControlHeight = Value}
         else this.FControlHeight = 0;
        this.InvalidateItems();
      };
    };
    this.SetControlLeft = function (Value) {
      if (this.FControlLeft !== Value) {
        this.FControlLeft = Value;
        this.InvalidateItems();
      };
    };
    this.SetControlPosition = function (Value) {
      if (this.FControlPosition !== Value) {
        this.FControlPosition = Value;
        this.InvalidateItems();
      };
    };
    this.SetControlTop = function (Value) {
      if (this.FControlTop !== Value) {
        this.FControlTop = Value;
        this.InvalidateItems();
      };
    };
    this.SetControlWidth = function (Value) {
      if (this.FControlWidth !== Value) {
        if (Value >= 0) {
          this.FControlWidth = Value}
         else this.FControlWidth = 0;
        this.InvalidateItems();
      };
    };
    this.SetTitleHeight = function (Value) {
      if (this.FTitleHeight !== Value) {
        if (Value >= 0) {
          this.FTitleHeight = Value}
         else this.FTitleHeight = 0;
        this.InvalidateItems();
      };
    };
    this.SetImagePosition = function (Value) {
      if (this.FImagePosition !== Value) {
        this.FImagePosition = Value;
        this.InvalidateItems();
      };
    };
    this.SetImageHeight = function (Value) {
      if (this.FImageHeight !== Value) {
        if (Value >= 0) {
          this.FImageHeight = Value}
         else this.FImageHeight = 0;
        this.InvalidateItems();
      };
    };
    this.SetImageLeft = function (Value) {
      if (this.FImageLeft !== Value) {
        this.FImageLeft = Value;
        this.InvalidateItems();
      };
    };
    this.SetImageTop = function (Value) {
      if (this.FImageTop !== Value) {
        this.FImageTop = Value;
        this.InvalidateItems();
      };
    };
    this.SetImageWidth = function (Value) {
      if (this.FImageWidth !== Value) {
        if (Value >= 0) {
          this.FImageWidth = Value}
         else this.FImageWidth = 0;
        this.InvalidateItems();
      };
    };
    this.SetImage = function (Value) {
      this.FImage.Assign(Value);
    };
    this.SetImageName = function (Value) {
      if (this.FImageName !== Value) {
        this.FImageName = Value;
        this.InvalidateItems();
      };
    };
    this.SetHorizontalDescriptionAlign = function (Value) {
      if (this.FHorizontalDescriptionAlign !== Value) {
        this.FHorizontalDescriptionAlign = Value;
        if (this.FDescription !== "") this.InvalidateItems();
      };
    };
    this.SetVerticalDescriptionAlign = function (Value) {
      if (this.FVerticalDescriptionAlign !== Value) {
        this.FVerticalDescriptionAlign = Value;
        if (this.FDescription !== "") this.InvalidateItems();
      };
    };
    this.GetTileOwner = function () {
      var Result = null;
      Result = this.FOwner;
      return Result;
    };
    this.IsImageWidthStored = function () {
      var Result = false;
      Result = this.FImageWidth !== 40;
      return Result;
    };
    this.IsImageHeightStored = function () {
      var Result = false;
      Result = this.FImageHeight !== 40;
      return Result;
    };
    this.IsImageLeftStored = function () {
      var Result = false;
      Result = this.FImageLeft !== 0;
      return Result;
    };
    this.IsImageTopStored = function () {
      var Result = false;
      Result = this.FImageTop !== 0;
      return Result;
    };
    this.IsTitleHeightStored = function () {
      var Result = false;
      Result = this.FTitleHeight !== 20;
      return Result;
    };
    this.IsControlHeightStored = function () {
      var Result = false;
      Result = this.FControlHeight !== 40;
      return Result;
    };
    this.IsControlLeftStored = function () {
      var Result = false;
      Result = this.FControlLeft !== 0;
      return Result;
    };
    this.IsControlTopStored = function () {
      var Result = false;
      Result = this.FControlTop !== 0;
      return Result;
    };
    this.IsControlWidthStored = function () {
      var Result = false;
      Result = this.FControlWidth !== 40;
      return Result;
    };
    this.InvalidateItems = function () {
      if (this.FOwner != null) this.FOwner.InvalidateItems();
    };
    this.MarginsChanged = function (Sender) {
      this.FOwner.CalculateItems(true);
    };
    this.BitmapChanged = function (Sender) {
      this.InvalidateItems();
    };
    this.GetImage = function () {
      var Result = null;
      Result = null;
      if (this.FImage != null) Result = this.FImage;
      if (pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(Result)) {
        if (this.FOwner != null) {
          if (this.FOwner.GetBitmapContainer() != null) Result = this.FOwner.GetBitmapContainer().FindBitmap$1(this.FImageName);
        };
      };
      return Result;
    };
    this.Create$1 = function (ACollection) {
      pas.Classes.TCollectionItem.Create$1.apply(this,arguments);
      if (this.FCollection != null) this.FOwner = rtl.as(this.FCollection,$mod.TTMSFNCTileListItems).FOwner$1;
      this.FSelected = false;
      this.FHorizontalTitleAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FVerticalTitleAlign = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter;
      this.FColumnSpan = 1;
      this.FCanDeselect = true;
      this.FCanSelect = true;
      this.FBadge = "";
      this.FTitle = "";
      this.FDescription = "";
      this.FRowSpan = 1;
      this.FMargins = pas["WEBLib.TMSFNCTypes"].TTMSFNCMargins.$create("Create$1");
      this.FMargins.FOnChange = rtl.createCallback(this,"MarginsChanged");
      this.FEnabled = true;
      this.FVisible = true;
      this.FEmpty = false;
      this.FTitleHeight = 20;
      this.FControlHeight = 40;
      this.FControlWidth = 40;
      this.FControlLeft = 0;
      this.FControlTop = 0;
      this.FControlPosition = $mod.TTMSFNCTileListControlPosition.tcpBottom;
      this.FImagePosition = $mod.TTMSFNCTileListImagePosition.tipRight;
      this.FImageHeight = 40;
      this.FImageWidth = 40;
      this.FImageLeft = 0;
      this.FImageTop = 0;
      this.FImageName = "";
      this.FImage = pas["WEBLib.TMSFNCTypes"].TTMSFNCBitmap.$create("Create$3");
      this.FImage.FOnChange = rtl.createCallback(this,"BitmapChanged");
      if (this.FOwner != null) this.FOwner.CalculateItems(true);
      return this;
    };
    this.Destroy = function () {
      if (this.FOwner != null) {
        if (this.GetIndex() === this.FOwner.FSelectedItemIndex) this.FOwner.ClearSelectedItem();
      };
      rtl.free(this,"FMargins");
      rtl.free(this,"FImage");
      pas.Classes.TCollectionItem.Destroy.call(this);
      if (this.FOwner != null) this.FOwner.CalculateItems(true);
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTileListItem.isPrototypeOf(Source)) {
        this.FBadge = rtl.as(Source,$mod.TTMSFNCTileListItem).FBadge;
        this.FRowSpan = rtl.as(Source,$mod.TTMSFNCTileListItem).FRowSpan;
        this.FColumnSpan = rtl.as(Source,$mod.TTMSFNCTileListItem).FColumnSpan;
        this.FVisible = rtl.as(Source,$mod.TTMSFNCTileListItem).FVisible;
        this.FEmpty = rtl.as(Source,$mod.TTMSFNCTileListItem).FEmpty;
        this.FDescription = rtl.as(Source,$mod.TTMSFNCTileListItem).FDescription;
        this.FEnabled = rtl.as(Source,$mod.TTMSFNCTileListItem).FEnabled;
        this.FMargins.Assign(rtl.as(Source,$mod.TTMSFNCTileListItem).FMargins);
        this.FCanDeselect = rtl.as(Source,$mod.TTMSFNCTileListItem).FCanDeselect;
        this.FCanSelect = rtl.as(Source,$mod.TTMSFNCTileListItem).FCanSelect;
        this.FHint = rtl.as(Source,$mod.TTMSFNCTileListItem).FHint;
        this.FVerticalTitleAlign = rtl.as(Source,$mod.TTMSFNCTileListItem).FVerticalTitleAlign;
        this.FHorizontalTitleAlign = rtl.as(Source,$mod.TTMSFNCTileListItem).FHorizontalTitleAlign;
        this.FSelected = rtl.as(Source,$mod.TTMSFNCTileListItem).FSelected;
        this.FTitle = rtl.as(Source,$mod.TTMSFNCTileListItem).FTitle;
        this.FTitleHeight = rtl.as(Source,$mod.TTMSFNCTileListItem).FTitleHeight;
        this.FControlHeight = rtl.as(Source,$mod.TTMSFNCTileListItem).FControlHeight;
        this.FControlWidth = rtl.as(Source,$mod.TTMSFNCTileListItem).FControlWidth;
        this.FControlTop = rtl.as(Source,$mod.TTMSFNCTileListItem).FControlTop;
        this.FControlLeft = rtl.as(Source,$mod.TTMSFNCTileListItem).FControlLeft;
        this.FControlPosition = rtl.as(Source,$mod.TTMSFNCTileListItem).FControlPosition;
        this.FImagePosition = rtl.as(Source,$mod.TTMSFNCTileListItem).FImagePosition;
        this.FImageHeight = rtl.as(Source,$mod.TTMSFNCTileListItem).FImageHeight;
        this.FImageLeft = rtl.as(Source,$mod.TTMSFNCTileListItem).FImageLeft;
        this.FImageTop = rtl.as(Source,$mod.TTMSFNCTileListItem).FImageTop;
        this.FImageWidth = rtl.as(Source,$mod.TTMSFNCTileListItem).FImageWidth;
        this.FImage.Assign(rtl.as(Source,$mod.TTMSFNCTileListItem).FImage);
        this.FImageName = rtl.as(Source,$mod.TTMSFNCTileListItem).FImageName;
      };
    };
    this.State = function () {
      var Result = 0;
      Result = $mod.TTMSFNCTileListItemState.isNormal;
      if (this.FEnabled) {
        if (this.GetIndex() === this.FOwner.FDownItemIndex) {
          Result = $mod.TTMSFNCTileListItemState.isDown}
         else if (this.GetIndex() === this.FOwner.FHoveredItemIndex) {
          Result = $mod.TTMSFNCTileListItemState.isHover}
         else if (this.FSelected) Result = $mod.TTMSFNCTileListItemState.isSelected;
      } else Result = $mod.TTMSFNCTileListItemState.isDisabled;
      return Result;
    };
    this.AllowDisplay = function () {
      var Result = false;
      var str = "";
      Result = true;
      if (this.FOwner.FFilter !== "") {
        str = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.HTMLStrip(this.FTitle);
        if (this.FOwner.FFiltering === $mod.TTMSFNCTileListFiltering.tlfStart) {
          Result = pas.StrUtils.AnsiStartsStr(this.FOwner.FFilter,str)}
         else Result = pas.StrUtils.ContainsText(str,this.FOwner.FFilter);
      };
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ACollection",pas.Classes.$rtti["TCollection"]]]);
    $r.addProperty("Title",2,rtl.string,"FTitle","SetTitle");
    $r.addProperty("Description",2,rtl.string,"FDescription","SetDescription");
    $r.addProperty("Image",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCBitmap"],"FImage","SetImage");
    $r.addProperty("ImageName",2,rtl.string,"FImageName","SetImageName");
    $r.addProperty("Empty",2,rtl.boolean,"FEmpty","SetEmpty",{Default: false});
    $r.addProperty("Control",2,pas["WEBLib.Controls"].$rtti["TControl"],"FControl","SetControl");
    $r.addProperty("Badge",2,rtl.string,"FBadge","SetBadge");
    $r.addProperty("ColumnSpan",2,rtl.longint,"FColumnSpan","SetColumnSpan",{Default: 1});
    $r.addProperty("RowSpan",2,rtl.longint,"FRowSpan","SetRowSpan",{Default: 1});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Enabled",2,rtl.boolean,"FEnabled","SetEnabled",{Default: true});
    $r.addProperty("Margins",2,pas["WEBLib.TMSFNCTypes"].$rtti["TTMSFNCMargins"],"FMargins","SetMargins");
    $r.addProperty("Hint",0,rtl.string,"FHint","FHint");
    $r.addProperty("CanSelect",2,rtl.boolean,"FCanSelect","SetCanSelect",{Default: true});
    $r.addProperty("CanDeselect",2,rtl.boolean,"FCanDeselect","SetCanDeselect",{Default: true});
    $r.addProperty("Visualizer",0,$mod.$rtti["TTMSFNCTileListVisualizer"],"FVisualizer","FVisualizer");
    $r.addProperty("TitleHeight",14,rtl.double,"FTitleHeight","SetTitleHeight",{stored: "IsTitleHeightStored"});
    $r.addProperty("ControlHeight",14,rtl.double,"FControlHeight","SetControlHeight",{stored: "IsControlHeightStored"});
    $r.addProperty("ControlWidth",14,rtl.double,"FControlWidth","SetControlWidth",{stored: "IsControlWidthStored"});
    $r.addProperty("ControlLeft",14,rtl.double,"FControlLeft","SetControlLeft",{stored: "IsControlLeftStored"});
    $r.addProperty("ControlTop",14,rtl.double,"FControlTop","SetControlTop",{stored: "IsControlTopStored"});
    $r.addProperty("ControlPosition",2,$mod.$rtti["TTMSFNCTileListControlPosition"],"FControlPosition","SetControlPosition",{Default: $mod.TTMSFNCTileListControlPosition.tcpBottom});
    $r.addProperty("ImagePosition",2,$mod.$rtti["TTMSFNCTileListImagePosition"],"FImagePosition","SetImagePosition",{Default: $mod.TTMSFNCTileListImagePosition.tipRight});
    $r.addProperty("ImageWidth",14,rtl.double,"FImageWidth","SetImageWidth",{stored: "IsImageWidthStored"});
    $r.addProperty("ImageHeight",14,rtl.double,"FImageHeight","SetImageHeight",{stored: "IsImageHeightStored"});
    $r.addProperty("ImageLeft",14,rtl.double,"FImageLeft","SetImageLeft",{stored: "IsImageLeftStored"});
    $r.addProperty("ImageTop",14,rtl.double,"FImageTop","SetImageTop",{stored: "IsImageTopStored"});
    $r.addProperty("HorizontalTitleAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorizontalTitleAlign","SetHorizontalTitleAlign",{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("VerticalTitleAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FVerticalTitleAlign","SetVerticalTitleAlign",{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("HorizontalDescriptionAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FHorizontalDescriptionAlign","SetHorizontalDescriptionAlign",{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
    $r.addProperty("VerticalDescriptionAlign",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsTextAlign"],"FVerticalDescriptionAlign","SetVerticalDescriptionAlign",{Default: pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter});
  });
  rtl.createClass(this,"TTMSFNCTileListItems",pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCTypes"].TTMSFNCOwnedCollection.$init.call(this);
      this.FOwner$1 = null;
      this.FOnChanged = null;
    };
    this.$final = function () {
      this.FOwner$1 = undefined;
      this.FOnChanged = 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.DoChange = function () {
      if (this.FOnChanged != null) this.FOnChanged(this);
    };
    this.CreateItemClass = function () {
      var Result = null;
      Result = $mod.TTMSFNCTileListItem;
      return Result;
    };
    this.GetOwner = function () {
      var Result = null;
      Result = this.FOwner$1;
      return Result;
    };
    this.Update = function (Item) {
      pas.Classes.TCollection.Update.apply(this,arguments);
      this.DoChange();
    };
    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;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$3",2,[["AOwner",$mod.$rtti["TTMSFNCCustomTileList"]]]);
  });
  rtl.createClass(this,"TTMSFNCTileListAppearance",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.FFont = null;
      this.FItemHeight = 0.0;
      this.FItemWidth = 0.0;
      this.FBadgeFont = null;
      this.FBadgeFill = null;
      this.FBadgeStroke = null;
      this.FDescriptionFont = 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.FFont = undefined;
      this.FBadgeFont = undefined;
      this.FBadgeFill = undefined;
      this.FBadgeStroke = undefined;
      this.FDescriptionFont = 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.SetFont = function (Value) {
      this.FFont.Assign(Value);
    };
    this.IsHorizontalSpacingStored = function () {
      var Result = false;
      Result = this.FHorizontalSpacing !== 8;
      return Result;
    };
    this.IsVerticalSpacingStored = function () {
      var Result = false;
      Result = this.FVerticalSpacing !== 8;
      return Result;
    };
    this.IsItemHeightStored = function () {
      var Result = false;
      Result = this.FItemHeight !== -1;
      return Result;
    };
    this.IsItemWidthStored = function () {
      var Result = false;
      Result = this.FItemWidth !== -1;
      return Result;
    };
    this.SetItemHeight = function (Value) {
      if (this.FItemHeight !== Value) {
        this.FItemHeight = Value;
        this.Changed();
      };
    };
    this.SetItemWidth = function (Value) {
      if (this.FItemWidth !== Value) {
        this.FItemWidth = Value;
        this.Changed();
      };
    };
    this.SetBadgeFill = function (Value) {
      this.FBadgeFill.Assign(Value);
    };
    this.SetBadgeFont = function (Value) {
      this.FBadgeFont.Assign(Value);
    };
    this.SetBadgeStroke = function (Value) {
      this.FBadgeStroke.Assign(Value);
    };
    this.SetDescriptionFont = function (Value) {
      this.FDescriptionFont.Assign(Value);
    };
    this.Changed = function () {
      this.FOwner.CalculateItems(true);
    };
    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.FItemHeight = -1;
      this.FItemWidth = -1;
      this.FFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      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.FBadgeFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FBadgeFill.SetColor(255);
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256]);
      this.FStroke.SetColor(11119017);
      this.FStrokeHover = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256]);
      this.FStrokeHover.SetColor(10061943);
      this.FStrokeDown = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256]);
      this.FStrokeDown.SetColor(9470064);
      this.FStrokeSelected = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256]);
      this.FStrokeSelected.SetColor(5197615);
      this.FStrokeDisabled = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256]);
      this.FStrokeDisabled.SetColor(11119017);
      this.FBadgeStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256]);
      this.FBadgeStroke.SetColor(255);
      this.FBadgeStroke.SetWidth(2);
      this.FFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FFont.FOnChanged = rtl.createCallback(this,"FontChanged");
      this.FDescriptionFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FDescriptionFont.FOnChanged = rtl.createCallback(this,"FontChanged");
      this.FBadgeFont = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFont.$create("Create$2");
      this.FBadgeFont.SetColor(16777215);
      this.FBadgeFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
      this.FBadgeFont.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.FBadgeFill.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.FBadgeStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FHorizontalSpacing = 8;
      this.FVerticalSpacing = 8;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTileListAppearance.isPrototypeOf(Source)) {
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FFill);
        this.FFillHover.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FFillHover);
        this.FFillSelected.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FFillSelected);
        this.FFillDisabled.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FFillDisabled);
        this.FFillDown.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FFillDown);
        this.FBadgeFill.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FBadgeFill);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FStroke);
        this.FStrokeHover.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FStrokeHover);
        this.FStrokeSelected.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FStrokeSelected);
        this.FStrokeDown.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FStrokeDown);
        this.FStrokeDisabled.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FStrokeDisabled);
        this.FBadgeStroke.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FBadgeStroke);
        this.FBadgeFont.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FBadgeFont);
        this.FVerticalSpacing = rtl.as(Source,$mod.TTMSFNCTileListAppearance).FVerticalSpacing;
        this.FHorizontalSpacing = rtl.as(Source,$mod.TTMSFNCTileListAppearance).FHorizontalSpacing;
        this.FFont.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FFont);
        this.FDescriptionFont.Assign(rtl.as(Source,$mod.TTMSFNCTileListAppearance).FDescriptionFont);
      };
    };
    this.Destroy = function () {
      rtl.free(this,"FFont");
      rtl.free(this,"FDescriptionFont");
      rtl.free(this,"FFill");
      rtl.free(this,"FFillDown");
      rtl.free(this,"FFillSelected");
      rtl.free(this,"FFillHover");
      rtl.free(this,"FFillDisabled");
      rtl.free(this,"FStroke");
      rtl.free(this,"FStrokeDown");
      rtl.free(this,"FStrokeSelected");
      rtl.free(this,"FStrokeHover");
      rtl.free(this,"FStrokeDisabled");
      rtl.free(this,"FBadgeFont");
      rtl.free(this,"FBadgeStroke");
      rtl.free(this,"FBadgeFill");
      pas.System.TObject.Destroy.call(this);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",$mod.$rtti["TTMSFNCCustomTileList"]]]);
    $r.addProperty("ItemWidth",14,rtl.double,"FItemWidth","SetItemWidth",{stored: "IsItemWidthStored"});
    $r.addProperty("ItemHeight",14,rtl.double,"FItemHeight","SetItemHeight",{stored: "IsItemHeightStored"});
    $r.addProperty("BadgeFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FBadgeFill","SetBadgeFill");
    $r.addProperty("BadgeStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FBadgeStroke","SetBadgeStroke");
    $r.addProperty("BadgeFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FBadgeFont","SetBadgeFont");
    $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",{stored: "IsVerticalSpacingStored"});
    $r.addProperty("HorizontalSpacing",14,rtl.double,"FHorizontalSpacing","SetHorizontalSpacing",{stored: "IsHorizontalSpacingStored"});
    $r.addProperty("TitleFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FFont","SetFont");
    $r.addProperty("DescriptionFont",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFont"],"FDescriptionFont","SetDescriptionFont");
  });
  rtl.createClass(this,"TTMSFNCTileListArrow",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FLeft = false;
      this.FHoverStroke = null;
      this.FOnChanged = null;
      this.FDownFill = null;
      this.FDownStroke = null;
      this.FArrowFill = null;
      this.FArrowHoverFill = null;
      this.FFill = null;
      this.FHoverFill = null;
      this.FStroke = null;
      this.FArrowDownFill = null;
      this.FVisible = false;
      this.FSize = 0.0;
    };
    this.$final = function () {
      this.FHoverStroke = undefined;
      this.FOnChanged = undefined;
      this.FDownFill = undefined;
      this.FDownStroke = undefined;
      this.FArrowFill = undefined;
      this.FArrowHoverFill = undefined;
      this.FFill = undefined;
      this.FHoverFill = undefined;
      this.FStroke = undefined;
      this.FArrowDownFill = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetArrowDownFill = function (Value) {
      this.FArrowDownFill.Assign(Value);
    };
    this.SetArrowFill = function (Value) {
      this.FArrowFill.Assign(Value);
    };
    this.SetArrowHoverFill = function (Value) {
      this.FArrowHoverFill.Assign(Value);
    };
    this.SetDownFill = function (Value) {
      this.FDownFill.Assign(Value);
    };
    this.SetDownStroke = function (Value) {
      this.FDownStroke.Assign(Value);
    };
    this.SetFill = function (Value) {
      this.FFill.Assign(Value);
    };
    this.SetHoverFill = function (Value) {
      this.FHoverFill.Assign(Value);
    };
    this.SetHoverStroke = function (Value) {
      this.FHoverStroke.Assign(Value);
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
    };
    this.SetVisible = function (Value) {
      if (this.FVisible !== Value) {
        this.FVisible = Value;
        this.Changed();
      };
    };
    this.IsSizeStored = function () {
      var Result = false;
      Result = this.FSize !== 40;
      return Result;
    };
    this.SetSize = function (Value) {
      this.FSize = Value;
    };
    this.FillChanged = function (Sender) {
      this.Changed();
    };
    this.StrokeChanged = function (Sender) {
      this.Changed();
    };
    this.Changed = function () {
      if (this.FOnChanged != null) this.FOnChanged(this);
    };
    this.Create$1 = function (ALeft) {
      this.FLeft = ALeft;
      this.FVisible = true;
      this.FSize = 40;
      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.FHoverFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FHoverFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FDownFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FDownFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FArrowFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FArrowFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FArrowHoverFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FArrowHoverFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FArrowDownFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FArrowDownFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256]);
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FHoverStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256]);
      this.FHoverStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FDownStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256]);
      this.FDownStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTileListArrow.isPrototypeOf(Source)) {
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCTileListArrow).FFill);
        this.FHoverFill.Assign(rtl.as(Source,$mod.TTMSFNCTileListArrow).FHoverFill);
        this.FDownFill.Assign(rtl.as(Source,$mod.TTMSFNCTileListArrow).FDownFill);
        this.FArrowFill.Assign(rtl.as(Source,$mod.TTMSFNCTileListArrow).FArrowFill);
        this.FArrowHoverFill.Assign(rtl.as(Source,$mod.TTMSFNCTileListArrow).FArrowHoverFill);
        this.FArrowDownFill.Assign(rtl.as(Source,$mod.TTMSFNCTileListArrow).FArrowDownFill);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCTileListArrow).FStroke);
        this.FHoverStroke.Assign(rtl.as(Source,$mod.TTMSFNCTileListArrow).FHoverStroke);
        this.FDownStroke.Assign(rtl.as(Source,$mod.TTMSFNCTileListArrow).FDownStroke);
        this.FVisible = rtl.as(Source,$mod.TTMSFNCTileListArrow).FVisible;
        this.FSize = rtl.as(Source,$mod.TTMSFNCTileListArrow).FSize;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    this.Destroy = function () {
      rtl.free(this,"FFill");
      rtl.free(this,"FHoverFill");
      rtl.free(this,"FDownFill");
      rtl.free(this,"FArrowFill");
      rtl.free(this,"FArrowHoverFill");
      rtl.free(this,"FArrowDownFill");
      rtl.free(this,"FStroke");
      rtl.free(this,"FHoverStroke");
      rtl.free(this,"FDownStroke");
      pas.System.TObject.Destroy.call(this);
    };
    this.IsLeft = function () {
      var Result = false;
      Result = this.FLeft;
      return Result;
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["ALeft",rtl.boolean]]);
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("DownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FDownFill","SetDownFill");
    $r.addProperty("DownStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FDownStroke","SetDownStroke");
    $r.addProperty("HoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FHoverFill","SetHoverFill");
    $r.addProperty("HoverStroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FHoverStroke","SetHoverStroke");
    $r.addProperty("ArrowFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FArrowFill","SetArrowFill");
    $r.addProperty("ArrowDownFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FArrowDownFill","SetArrowDownFill");
    $r.addProperty("ArrowHoverFill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FArrowHoverFill","SetArrowHoverFill");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Size",14,rtl.double,"FSize","SetSize",{stored: "IsSizeStored"});
  });
  rtl.createClass(this,"TTMSFNCTileListBullets",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FOnChanged = null;
      this.FSelectedFill = null;
      this.FSelectedStroke = null;
      this.FFill = null;
      this.FStroke = null;
      this.FVisible = false;
      this.FSpacing = 0.0;
    };
    this.$final = function () {
      this.FOnChanged = undefined;
      this.FSelectedFill = undefined;
      this.FSelectedStroke = undefined;
      this.FFill = undefined;
      this.FStroke = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetFill = function (Value) {
      this.FFill.Assign(Value);
    };
    this.SetSelectedFill = function (Value) {
      this.FSelectedFill.Assign(Value);
    };
    this.SetSelectedStroke = function (Value) {
      this.FSelectedStroke.Assign(Value);
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
    };
    this.SetSpacing = function (Value) {
      if (this.FSpacing !== Value) {
        this.FSpacing = Value;
        this.Changed();
      };
    };
    this.SetVisible = function (Value) {
      if (this.FVisible !== Value) {
        this.FVisible = Value;
        this.Changed();
      };
    };
    this.IsSpacingStored = function () {
      var Result = false;
      Result = this.FSpacing !== 3;
      return Result;
    };
    this.FillChanged = function (Sender) {
      this.Changed();
    };
    this.StrokeChanged = function (Sender) {
      this.Changed();
    };
    this.Changed = function () {
      if (this.FOnChanged != null) this.FOnChanged(this);
    };
    this.Create$1 = function () {
      this.FVisible = true;
      this.FSpacing = 3;
      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]);
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FSelectedFill = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFill.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsFillKind.gfkSolid,16777215,8421504,-1,-1]);
      this.FSelectedFill.FOnChanged = rtl.createCallback(this,"FillChanged");
      this.FSelectedStroke = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStroke.$create("Create$1",[pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid,12632256]);
      this.FSelectedStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTileListBullets.isPrototypeOf(Source)) {
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCTileListBullets).FFill);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCTileListBullets).FStroke);
        this.FSelectedFill.Assign(rtl.as(Source,$mod.TTMSFNCTileListBullets).FSelectedFill);
        this.FSelectedStroke.Assign(rtl.as(Source,$mod.TTMSFNCTileListBullets).FSelectedStroke);
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    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);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
    $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("Spacing",14,rtl.double,"FSpacing","SetSpacing",{stored: "IsSpacingStored"});
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
  });
  rtl.createClass(this,"TTMSFNCTileListHeaderFooterBase",pas.Classes.TPersistent,function () {
    this.$init = function () {
      pas.Classes.TPersistent.$init.call(this);
      this.FVisible = false;
      this.FFill = null;
      this.FStroke = null;
      this.FOnChanged = null;
      this.FBullets = null;
      this.FArrowLeft = null;
      this.FArrowRight = null;
      this.FSize = 0.0;
    };
    this.$final = function () {
      this.FFill = undefined;
      this.FStroke = undefined;
      this.FOnChanged = undefined;
      this.FBullets = undefined;
      this.FArrowLeft = undefined;
      this.FArrowRight = undefined;
      pas.Classes.TPersistent.$final.call(this);
    };
    this.SetFill = function (Value) {
      this.FFill.Assign(Value);
    };
    this.SetStroke = function (Value) {
      this.FStroke.Assign(Value);
    };
    this.SetVisible = function (Value) {
      if (this.FVisible !== Value) {
        this.FVisible = Value;
        this.Changed();
      };
    };
    this.SetArrowLeft = function (Value) {
      this.FArrowLeft.Assign(Value);
    };
    this.SetArrowRight = function (Value) {
      this.FArrowRight.Assign(Value);
    };
    this.SetBullets = function (Value) {
      this.FBullets.Assign(Value);
    };
    this.SetSize = function (Value) {
      if (this.FSize !== Value) {
        this.FSize = Value;
        this.Changed();
      };
    };
    this.IsSizeStored = function () {
      var Result = false;
      Result = this.FSize !== 32;
      return Result;
    };
    this.FillChanged = function (Sender) {
      this.Changed();
    };
    this.StrokeChanged = function (Sender) {
      this.Changed();
    };
    this.BulletsChanged = function (Sender) {
      this.Changed();
    };
    this.ArrowChanged = function (Sender) {
      this.Changed();
    };
    this.Changed = function () {
      if (this.FOnChanged != null) this.FOnChanged(this);
    };
    this.Create$1 = function () {
      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]);
      this.FStroke.FOnChanged = rtl.createCallback(this,"StrokeChanged");
      this.FBullets = $mod.TTMSFNCTileListBullets.$create("Create$1");
      this.FBullets.FOnChanged = rtl.createCallback(this,"BulletsChanged");
      this.FArrowLeft = $mod.TTMSFNCTileListArrow.$create("Create$1",[true]);
      this.FArrowLeft.FOnChanged = rtl.createCallback(this,"ArrowChanged");
      this.FArrowRight = $mod.TTMSFNCTileListArrow.$create("Create$1",[false]);
      this.FArrowRight.FOnChanged = rtl.createCallback(this,"ArrowChanged");
      this.FSize = 32;
      this.FVisible = true;
      return this;
    };
    this.Assign = function (Source) {
      if ($mod.TTMSFNCTileListHeaderFooterBase.isPrototypeOf(Source)) {
        this.FFill.Assign(rtl.as(Source,$mod.TTMSFNCTileListHeaderFooterBase).FFill);
        this.FStroke.Assign(rtl.as(Source,$mod.TTMSFNCTileListHeaderFooterBase).FStroke);
        this.FBullets.Assign(rtl.as(Source,$mod.TTMSFNCTileListHeaderFooterBase).FBullets);
        this.FArrowLeft.Assign(rtl.as(Source,$mod.TTMSFNCTileListHeaderFooterBase).FArrowLeft);
        this.FArrowRight.Assign(rtl.as(Source,$mod.TTMSFNCTileListHeaderFooterBase).FArrowRight);
        this.FVisible = rtl.as(Source,$mod.TTMSFNCTileListHeaderFooterBase).FVisible;
        this.FSize = rtl.as(Source,$mod.TTMSFNCTileListHeaderFooterBase).FSize;
      } else pas.Classes.TPersistent.Assign.apply(this,arguments);
    };
    this.Destroy = function () {
      rtl.free(this,"FFill");
      rtl.free(this,"FStroke");
      rtl.free(this,"FBullets");
      rtl.free(this,"FArrowLeft");
      rtl.free(this,"FArrowRight");
      pas.System.TObject.Destroy.call(this);
    };
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[]);
  });
  rtl.createClass(this,"TTMSFNCTileListHeader",this.TTMSFNCTileListHeaderFooterBase,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");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Bullets",2,$mod.$rtti["TTMSFNCTileListBullets"],"FBullets","SetBullets");
    $r.addProperty("ArrowLeft",2,$mod.$rtti["TTMSFNCTileListArrow"],"FArrowLeft","SetArrowLeft");
    $r.addProperty("ArrowRight",2,$mod.$rtti["TTMSFNCTileListArrow"],"FArrowRight","SetArrowRight");
    $r.addProperty("Size",14,rtl.double,"FSize","SetSize",{stored: "IsSizeStored"});
  });
  rtl.createClass(this,"TTMSFNCTileListFooter",this.TTMSFNCTileListHeaderFooterBase,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");
    $r.addProperty("Visible",2,rtl.boolean,"FVisible","SetVisible",{Default: true});
    $r.addProperty("Bullets",2,$mod.$rtti["TTMSFNCTileListBullets"],"FBullets","SetBullets");
    $r.addProperty("ArrowLeft",2,$mod.$rtti["TTMSFNCTileListArrow"],"FArrowLeft","SetArrowLeft");
    $r.addProperty("ArrowRight",2,$mod.$rtti["TTMSFNCTileListArrow"],"FArrowRight","SetArrowRight");
    $r.addProperty("Size",14,rtl.double,"FSize","SetSize",{stored: "IsSizeStored"});
  });
  rtl.recNewT(this,"TTMSFNCTileListDisplayItem",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();
      r.AbsRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      r.DrawRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      return r;
    };
    this.$eq = function (b) {
      return this.Rect.$eq(b.Rect) && this.AbsRect.$eq(b.AbsRect) && this.DrawRect.$eq(b.DrawRect) && (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.AbsRect.$assign(s.AbsRect);
      this.DrawRect.$assign(s.DrawRect);
      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("TTMSFNCTileListDisplayItem",{});
    $r.addField("Rect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("AbsRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("DrawRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("Item",$mod.$rtti["TTMSFNCTileListItem"]);
    $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);
  });
  rtl.recNewT(this,"TTMSFNCTileListRecalcItem",function () {
    this.ItemIndex = 0;
    this.Column = 0;
    this.Row = 0;
    this.ColumnSpan = 0;
    this.RowSpan = 0;
    this.PageIndex = 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.ItemIndex === b.ItemIndex) && (this.Column === b.Column) && (this.Row === b.Row) && (this.ColumnSpan === b.ColumnSpan) && (this.RowSpan === b.RowSpan) && (this.PageIndex === b.PageIndex);
    };
    this.$assign = function (s) {
      this.Rect.$assign(s.Rect);
      this.ItemIndex = s.ItemIndex;
      this.Column = s.Column;
      this.Row = s.Row;
      this.ColumnSpan = s.ColumnSpan;
      this.RowSpan = s.RowSpan;
      this.PageIndex = s.PageIndex;
      return this;
    };
    var $r = $mod.$rtti.$Record("TTMSFNCTileListRecalcItem",{});
    $r.addField("Rect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]);
    $r.addField("ItemIndex",rtl.longint);
    $r.addField("Column",rtl.longint);
    $r.addField("Row",rtl.longint);
    $r.addField("ColumnSpan",rtl.longint);
    $r.addField("RowSpan",rtl.longint);
    $r.addField("PageIndex",rtl.longint);
  });
  rtl.createClass(this,"TTMSFNCTileListDragControl",pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$init.call(this);
      this.FDisplayItem = $mod.TTMSFNCTileListDisplayItem.$new();
      this.FVisualizer = null;
    };
    this.$final = function () {
      this.FDisplayItem = undefined;
      this.FVisualizer = undefined;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.$final.call(this);
    };
    this.GetControl = function () {
      var Result = null;
      Result = null;
      if ((this.FDisplayItem.Item != null) && (this.FDisplayItem.Item.FControl != null)) Result = this.FDisplayItem.Item.FControl;
      return Result;
    };
    this.Draw = function (AGraphics, ARect) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Draw.apply(this,arguments);
      if (this.FVisualizer != null) this.FVisualizer.Draw($mod.TTMSFNCTileListDisplayItem.$clone(this.FDisplayItem),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.Create$1.apply(this,arguments);
      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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  rtl.createClass(this,"TTMSFNCTileListVisualizer",pas["WEBLib.TMSFNCCustomComponent"].TTMSFNCCustomComponent,function () {
    this.GetTitleRect = function (ATile) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (!(ATile.Item != null) || !(ATile.Item.GetTileOwner() != null)) return Result;
      if (ATile.Item.FTitle !== "") {
        Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left,ATile.DrawRect.Top,ATile.DrawRect.Right - ATile.DrawRect.Left,ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FTitleHeight)))}
       else Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left,ATile.DrawRect.Top,0,0));
      return Result;
    };
    this.GetControlRect = function (ATile) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var tr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (!(ATile.Item != null) || !(ATile.Item.GetTileOwner() != null)) return Result;
      tr.$assign(this.GetTitleRect($mod.TTMSFNCTileListDisplayItem.$clone(ATile)));
      if (ATile.Item.FControl != null) {
        var $tmp = ATile.Item.FControlPosition;
        if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpBottom) {
          Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left,ATile.DrawRect.Bottom - ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FControlHeight),ATile.DrawRect.Right - ATile.DrawRect.Left,ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FControlHeight)))}
         else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpLeft) {
          Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left,tr.Bottom,ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FControlWidth),ATile.DrawRect.Bottom - tr.Bottom))}
         else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpRight) {
          Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Right - ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FControlWidth),tr.Bottom,ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FControlWidth),ATile.DrawRect.Bottom - tr.Bottom))}
         else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpClient) {
          Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left,tr.Bottom,ATile.DrawRect.Right - ATile.DrawRect.Left,ATile.DrawRect.Bottom - tr.Bottom))}
         else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpCustom) Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left + ATile.Item.FControlLeft,tr.Bottom + ATile.Item.FControlTop,ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FControlWidth),ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FControlHeight)));
      } else Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left,ATile.DrawRect.Top,0,0));
      return Result;
    };
    this.GetDescriptionRect = function (ATile) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var tr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (!(ATile.Item != null)) return Result;
      tr.$assign(this.GetTitleRect($mod.TTMSFNCTileListDisplayItem.$clone(ATile)));
      if (ATile.Item.FControl != null) {
        var $tmp = ATile.Item.FControlPosition;
        if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpBottom) {
          r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left,tr.Bottom,ATile.DrawRect.Right - ATile.DrawRect.Left,ATile.DrawRect.Bottom - tr.Bottom - ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FControlHeight)))}
         else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpLeft) {
          r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left + ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FControlWidth),tr.Bottom,ATile.DrawRect.Right - (ATile.DrawRect.Left + ATile.Item.FControlWidth),ATile.DrawRect.Bottom - tr.Bottom))}
         else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpRight) {
          r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left,tr.Bottom,ATile.DrawRect.Right - ATile.DrawRect.Left - ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FControlWidth),ATile.DrawRect.Bottom - tr.Bottom))}
         else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpClient) {
          r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left,ATile.DrawRect.Top,0,0))}
         else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpCustom) r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left,tr.Bottom,ATile.DrawRect.Right - ATile.DrawRect.Left,ATile.DrawRect.Bottom - tr.Bottom));
      } else r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ATile.DrawRect.Left,tr.Bottom,ATile.DrawRect.Right - ATile.DrawRect.Left,ATile.DrawRect.Bottom - tr.Bottom));
      if ((ATile.Item.FControlPosition !== $mod.TTMSFNCTileListControlPosition.tcpClient) || !(ATile.Item.FControl != null)) {
        if (!pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(ATile.Item.GetImage())) {
          var $tmp1 = ATile.Item.FImagePosition;
          if ($tmp1 === $mod.TTMSFNCTileListImagePosition.tipLeft) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left + ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FImageWidth),r.Top,r.Right - r.Left - ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FImageWidth),r.Bottom - r.Top))}
           else if ($tmp1 === $mod.TTMSFNCTileListImagePosition.tipRight) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,r.Right - r.Left - ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FImageWidth),r.Bottom - r.Top))}
           else if ($tmp1 === $mod.TTMSFNCTileListImagePosition.tipTop) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top + ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FImageHeight),r.Right - r.Left,r.Bottom - (r.Top + ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FImageHeight))))}
           else if ($tmp1 === $mod.TTMSFNCTileListImagePosition.tipBottom) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,r.Right - r.Left,r.Bottom - ATile.Item.GetTileOwner().ScalePaintValue$1(ATile.Item.FImageHeight) - r.Top))}
           else if ($tmp1 === $mod.TTMSFNCTileListImagePosition.tipCustom) Result.$assign(r);
        } else Result.$assign(r);
        if (ATile.Item.FDescription !== "") {
          pas["WEBLib.TMSFNCTypes"].InflateRectEx(Result,-1,-1);
        };
      };
      return Result;
    };
    this.DoMouseDown = function (Tile, Button, Shift, X, Y) {
      var s = "";
      s = this.XYToAnchor($mod.TTMSFNCTileListDisplayItem.$clone(Tile),X,Y);
      if (s !== "") {
        if ((Tile.Item != null) && (Tile.Item.GetTileOwner() != null)) Tile.Item.GetTileOwner().DoItemAnchorClick(Tile.Item.GetIndex(),s);
      };
    };
    this.DoMouseUp = function (Tile, Button, Shift, X, Y) {
    };
    this.DoMouseMove = function (Tile, Shift, X, Y) {
      var s = "";
      var t = null;
      t = Tile.Item;
      if (!(t.GetTileOwner() != null)) return;
      s = this.XYToAnchor($mod.TTMSFNCTileListDisplayItem.$clone(Tile),X,Y);
      if (s !== "") {
        t.GetTileOwner().SetControlCursor(21)}
       else t.GetTileOwner().SetControlCursor(0);
    };
    this.DoMouseLeaveTile = function (Tile) {
    };
    this.DoMouseEnterTile = function (Tile) {
    };
    this.XYToAnchor = function (Tile, X, Y) {
      var Result = "";
      var ti = false;
      var de = false;
      var tr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var g = null;
      var ha = 0;
      var va = 0;
      var t = null;
      Result = "";
      t = Tile.Item;
      if (!(t != null) || !(t.GetTileOwner() != null)) return Result;
      ti = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHTML(t.FTitle);
      de = pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.IsHTML(t.FDescription);
      if (ti || de) {
        g = pas["WEBLib.TMSFNCGraphics"].TTMSFNCGraphics.$create("CreateBitmapCanvas",[1,1,false,true]);
        g.BeginScene();
        g.FOptimizedHTMLDrawing = t.GetTileOwner().FOptimizedHTMLDrawing;
        g.FBitmapContainer = t.GetTileOwner().GetBitmapContainer();
        try {
          if (ti) {
            g.FFont.Assign(t.GetTileOwner().FAppearance.FFont);
            ha = t.FHorizontalTitleAlign;
            va = t.FVerticalTitleAlign;
            tr.$assign(this.GetTitleRect($mod.TTMSFNCTileListDisplayItem.$clone(Tile)));
            Result = g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(tr),t.FTitle,false,ha,va,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,true,X,Y);
          };
          if (de) {
            g.FFont.Assign(t.GetTileOwner().FAppearance.FDescriptionFont);
            ha = t.FHorizontalDescriptionAlign;
            va = t.FVerticalDescriptionAlign;
            tr.$assign(this.GetDescriptionRect($mod.TTMSFNCTileListDisplayItem.$clone(Tile)));
            Result = g.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(tr),t.FDescription,true,ha,va,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,true,X,Y);
          };
        } finally {
          g.EndScene();
          g = rtl.freeLoc(g);
        };
      };
      return Result;
    };
    this.DoBeforeDraw = function (ATile, AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if ((ATile.Item != null) && (ATile.Item.GetTileOwner() != null)) ATile.Item.GetTileOwner().DoBeforeDrawItemContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoAfterDraw = function (ATile, AGraphics, ARect, AItemIndex) {
      if ((ATile.Item != null) && (ATile.Item.GetTileOwner() != null)) ATile.Item.GetTileOwner().DoAfterDrawItemContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoBeforeDrawControl = function (ATile, AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if ((ATile.Item != null) && (ATile.Item.GetTileOwner() != null)) ATile.Item.GetTileOwner().DoBeforeDrawItemControl(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoAfterDrawControl = function (ATile, AGraphics, ARect, AItemIndex) {
      if ((ATile.Item != null) && (ATile.Item.GetTileOwner() != null)) ATile.Item.GetTileOwner().DoAfterDrawItemControl(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoBeforeDrawImage = function (ATile, AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if ((ATile.Item != null) && (ATile.Item.GetTileOwner() != null)) ATile.Item.GetTileOwner().DoBeforeDrawItemImage(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoAfterDrawImage = function (ATile, AGraphics, ARect, AItemIndex) {
      if ((ATile.Item != null) && (ATile.Item.GetTileOwner() != null)) ATile.Item.GetTileOwner().DoAfterDrawItemImage(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoBeforeDrawTitle = function (ATile, AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if ((ATile.Item != null) && (ATile.Item.GetTileOwner() != null)) ATile.Item.GetTileOwner().DoBeforeDrawItemTitle(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoAfterDrawTitle = function (ATile, AGraphics, ARect, AItemIndex) {
      if ((ATile.Item != null) && (ATile.Item.GetTileOwner() != null)) ATile.Item.GetTileOwner().DoAfterDrawItemTitle(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoBeforeDrawDescription = function (ATile, AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if ((ATile.Item != null) && (ATile.Item.GetTileOwner() != null)) ATile.Item.GetTileOwner().DoBeforeDrawItemDescription(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoAfterDrawDescription = function (ATile, AGraphics, ARect, AItemIndex) {
      if ((ATile.Item != null) && (ATile.Item.GetTileOwner() != null)) ATile.Item.GetTileOwner().DoAfterDrawItemDescription(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.Draw = function (ATile, AGraphics, ARect) {
      var tr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var cr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ir = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var dr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var b = false;
      var t = null;
      t = ATile.Item;
      if (!(ATile.Item != null)) return;
      b = true;
      this.DoBeforeDraw($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),t.GetIndex(),{get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }});
      if (b) {
        if (t.FTitle !== "") {
          tr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,ARect.Top,ARect.Right - ARect.Left,t.GetTileOwner().ScalePaintValue$1(t.FTitleHeight)));
          this.DrawTitle($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(tr));
        } else tr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,ARect.Top,0,0));
        if (t.FControl != null) {
          var $tmp = t.FControlPosition;
          if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpBottom) {
            cr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,ARect.Bottom - t.GetTileOwner().ScalePaintValue$1(t.FControlHeight),ARect.Right - ARect.Left,t.GetTileOwner().ScalePaintValue$1(t.FControlHeight)));
            r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,tr.Bottom,ARect.Right - ARect.Left,ARect.Bottom - tr.Bottom - t.GetTileOwner().ScalePaintValue$1(t.FControlHeight)));
          } else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpLeft) {
            cr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,tr.Bottom,t.GetTileOwner().ScalePaintValue$1(t.FControlWidth),ARect.Bottom - tr.Bottom));
            r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(cr.Right,tr.Bottom,ARect.Right - cr.Right,ARect.Bottom - tr.Bottom));
          } else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpRight) {
            cr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Right - t.GetTileOwner().ScalePaintValue$1(t.FControlWidth),tr.Bottom,t.GetTileOwner().ScalePaintValue$1(t.FControlWidth),ARect.Bottom - tr.Bottom));
            r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,tr.Bottom,ARect.Right - ARect.Left - t.GetTileOwner().ScalePaintValue$1(t.FControlWidth),ARect.Bottom - tr.Bottom));
          } else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpClient) {
            cr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,tr.Bottom,ARect.Right - ARect.Left,ARect.Bottom - tr.Bottom));
            r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,ARect.Top,0,0));
          } else if ($tmp === $mod.TTMSFNCTileListControlPosition.tcpCustom) {
            cr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left + t.FControlLeft,tr.Bottom + t.FControlTop,t.GetTileOwner().ScalePaintValue$1(t.FControlWidth),t.GetTileOwner().ScalePaintValue$1(t.FControlHeight)));
            r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,tr.Bottom,ARect.Right - ARect.Left,ARect.Bottom - tr.Bottom));
          };
          this.DrawControl($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(cr));
        } else r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,tr.Bottom,ARect.Right - ARect.Left,ARect.Bottom - tr.Bottom));
        if ((t.FControlPosition !== $mod.TTMSFNCTileListControlPosition.tcpClient) || !(t.FControl != null)) {
          if (!pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(t.GetImage())) {
            var $tmp1 = t.FImagePosition;
            if ($tmp1 === $mod.TTMSFNCTileListImagePosition.tipLeft) {
              ir.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,t.GetTileOwner().ScalePaintValue$1(t.FImageWidth),r.Bottom - r.Top));
              dr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ir.Right,r.Top,r.Right - r.Left - t.GetTileOwner().ScalePaintValue$1(t.FImageWidth),r.Bottom - r.Top));
            } else if ($tmp1 === $mod.TTMSFNCTileListImagePosition.tipRight) {
              ir.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Right - t.GetTileOwner().ScalePaintValue$1(t.FImageWidth),r.Top,t.GetTileOwner().ScalePaintValue$1(t.FImageWidth),r.Bottom - r.Top));
              dr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,r.Right - r.Left - t.GetTileOwner().ScalePaintValue$1(t.FImageWidth),r.Bottom - r.Top));
            } else if ($tmp1 === $mod.TTMSFNCTileListImagePosition.tipTop) {
              ir.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,r.Right - r.Left,t.GetTileOwner().ScalePaintValue$1(t.FImageHeight)));
              dr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,ir.Bottom,r.Right - r.Left,r.Bottom - ir.Bottom));
            } else if ($tmp1 === $mod.TTMSFNCTileListImagePosition.tipBottom) {
              ir.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Bottom - t.GetTileOwner().ScalePaintValue$1(t.FImageHeight),r.Right - r.Left,t.GetTileOwner().ScalePaintValue$1(t.FImageHeight)));
              dr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,r.Right - r.Left,ir.Top - r.Top));
            } else if ($tmp1 === $mod.TTMSFNCTileListImagePosition.tipClient) {
              ir.$assign(r);
              dr.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(0,0,0,0));
            } else if ($tmp1 === $mod.TTMSFNCTileListImagePosition.tipCustom) {
              ir.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left + t.FImageLeft,r.Top + t.FImageTop,t.GetTileOwner().ScalePaintValue$1(t.FImageWidth),t.GetTileOwner().ScalePaintValue$1(t.FImageHeight)));
              dr.$assign(r);
            };
            pas["WEBLib.TMSFNCTypes"].InflateRectEx(ir,-1,-1);
            this.DrawImage($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ir));
          } else dr.$assign(r);
          if ((t.FDescription !== "") && (t.FImagePosition !== $mod.TTMSFNCTileListImagePosition.tipClient)) {
            pas["WEBLib.TMSFNCTypes"].InflateRectEx(dr,-1,-1);
            this.DrawDescription($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(dr));
          };
        };
        this.DoAfterDraw($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),t.GetIndex());
      };
    };
    this.DrawTitle = function (ATile, AGraphics, ARect) {
      var b = false;
      var t = null;
      t = ATile.Item;
      if (!(t != null) || (t.FTitle === "")) return;
      if (t.GetTileOwner() != null) AGraphics.FFont.AssignSource(t.GetTileOwner().FAppearance.FFont);
      b = true;
      this.DoBeforeDrawTitle($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),t.GetIndex(),{get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }});
      AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),t.FTitle,false,t.FHorizontalTitleAlign,t.FVerticalTitleAlign,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttCharacter,0,-1,-1,true,false,-1,-1);
      this.DoAfterDrawTitle($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),t.GetIndex());
    };
    this.DrawControl = function (ATile, AGraphics, ARect) {
      var t = null;
      t = ATile.Item;
      if (!(t != null) || !(t.FControl != null)) return;
      t.FControl.SetBounds(Math.round(ARect.Left),Math.round(ARect.Top),Math.round(ARect.Right - ARect.Left),Math.round(ARect.Bottom - ARect.Top));
    };
    this.DrawImage = function (ATile, AGraphics, ARect) {
      var b = false;
      var t = null;
      t = ATile.Item;
      if (!(t != null)) return;
      if ((t.FControlPosition === $mod.TTMSFNCTileListControlPosition.tcpClient) || pas["WEBLib.TMSFNCTypes"].IsBitmapEmpty(t.GetImage())) return;
      b = true;
      this.DoBeforeDrawImage($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),t.GetIndex(),{get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }});
      if (b) {
        AGraphics.DrawBitmap$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),t.GetImage(),true,true,true,false);
        this.DoAfterDrawImage($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),t.GetIndex());
      };
    };
    this.DrawDescription = function (ATile, AGraphics, ARect) {
      var b = false;
      var t = null;
      t = ATile.Item;
      if (!(t != null)) return;
      if ((t.FControlPosition === $mod.TTMSFNCTileListControlPosition.tcpClient) || (t.FDescription === "")) return;
      if (t.GetTileOwner() != null) AGraphics.FFont.AssignSource(t.GetTileOwner().FAppearance.FDescriptionFont);
      b = true;
      this.DoBeforeDrawDescription($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),t.GetIndex(),{get: function () {
          return b;
        }, set: function (v) {
          b = v;
        }});
      if (b) {
        AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),t.FDescription,true,t.FHorizontalDescriptionAlign,t.FVerticalDescriptionAlign,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttCharacter,0,-1,-1,true,false,-1,-1);
        this.DoAfterDrawDescription($mod.TTMSFNCTileListDisplayItem.$clone(ATile),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),t.GetIndex());
      };
    };
    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.$DynArray("TTMSFNCTileListItemPosArray$a",{eltype: rtl.boolean});
  this.$rtti.$DynArray("TTMSFNCTileListItemPosArray",{eltype: this.$rtti["TTMSFNCTileListItemPosArray$a"]});
  this.$rtti.$DynArray("TTMSFNCTileListItemDisplayPosArray$a",{eltype: rtl.longint});
  this.$rtti.$DynArray("TTMSFNCTileListItemDisplayPosArray",{eltype: this.$rtti["TTMSFNCTileListItemDisplayPosArray$a"]});
  this.$rtti.$DynArray("TTMSFNCTileListItemIndexArray",{eltype: rtl.longint});
  this.$rtti.$MethodVar("TTMSFNCTileListItemFilterEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AFilter",rtl.string,1],["AAllow",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTileListItemSelectedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItemIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTileListItemDeselectedEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItemIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTileListItemClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AItemIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTileListBeforeDrawItemBackgroundEvent",{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("TTMSFNCTileListAfterDrawItemBackgroundEvent",{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("TTMSFNCTileListBeforeDrawItemContentEvent",{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("TTMSFNCTileListAfterDrawItemContentEvent",{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("TTMSFNCTileListBeforeDrawItemTextEvent",{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("TTMSFNCTileListAfterDrawItemTextEvent",{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("TTMSFNCTileListBeforeDrawEvent",{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("TTMSFNCTileListAfterDrawEvent",{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("TTMSFNCTileListBeforeDrawArrowEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ALeft",rtl.boolean],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTileListAfterDrawArrowEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ALeft",rtl.boolean]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTileListBeforeDrawBulletEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["ARect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AIndex",rtl.longint],["ASelected",rtl.boolean],["ADefaultDraw",null,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTileListAfterDrawBulletEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["Aect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["AIndex",rtl.longint],["ASelected",rtl.boolean]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTileListBulletClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["APageIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTileListBeforeDrawBadgeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["AItemRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ABadgeRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ABadgeText",rtl.string],["AItemIndex",rtl.longint],["ADefaultDraw",rtl.boolean,1]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTileListAfterDrawBadgeEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AGraphics",pas["WEBLib.TMSFNCGraphics"].$rtti["TTMSFNCGraphics"]],["AItemRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ABadgeRect",pas["WEBLib.TMSFNCTypes"].$rtti["TRectF"]],["ABadgeText",rtl.string],["AItemIndex",rtl.longint]]), methodkind: 0});
  this.$rtti.$MethodVar("TTMSFNCTileListItemAnchorClickEvent",{procsig: rtl.newTIProcSig([["Sender",pas.System.$rtti["TObject"]],["AAnchor",rtl.string],["AItemIndex",rtl.longint]]), methodkind: 0});
  rtl.createClass(this,"TTMSFNCTileListDisplayList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = $mod.TTMSFNCTileListDisplayItem.$new();
      Result.$assign(rtl.getObject(this.Get(Index)));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      var v = $mod.TTMSFNCTileListDisplayItem.$new();
      v.$assign(Value);
      this.Put(Index,v);
    };
  });
  rtl.createClass(this,"TTMSFNCTileListCollectionItems",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = null;
      Result = rtl.getObject(this.Get(Index));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      var v = null;
      v = Value;
      this.Put(Index,v);
    };
  });
  rtl.createClass(this,"TTMSFNCTileListRecalcList",pas.Classes.TList,function () {
    this.GetItem = function (Index) {
      var Result = $mod.TTMSFNCTileListRecalcItem.$new();
      Result.$assign(rtl.getObject(this.Get(Index)));
      return Result;
    };
    this.SetItem = function (Index, Value) {
      var v = $mod.TTMSFNCTileListRecalcItem.$new();
      v.$assign(Value);
      this.Put(Index,v);
    };
  });
  this.TTMSFNCTileListTileDirection = {"0": "tldAbove", tldAbove: 0, "1": "tldBelow", tldBelow: 1, "2": "tldLeft", tldLeft: 2, "3": "tldRight", tldRight: 3};
  this.$rtti.$Enum("TTMSFNCTileListTileDirection",{minvalue: 0, maxvalue: 3, ordtype: 1, enumtype: this.TTMSFNCTileListTileDirection});
  this.TTMSFNCTileListMode = {"0": "bsmBlocks", bsmBlocks: 0, "1": "bsmLines", bsmLines: 1};
  this.$rtti.$Enum("TTMSFNCTileListMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTileListMode});
  this.TTMSFNCTileListOrientation = {"0": "tloVertical", tloVertical: 0, "1": "tloHorizontal", tloHorizontal: 1};
  this.$rtti.$Enum("TTMSFNCTileListOrientation",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTileListOrientation});
  this.TTMSFNCTileListNavigationMode = {"0": "tlnmPage", tlnmPage: 0, "1": "tlnmScroll", tlnmScroll: 1};
  this.$rtti.$Enum("TTMSFNCTileListNavigationMode",{minvalue: 0, maxvalue: 1, ordtype: 1, enumtype: this.TTMSFNCTileListNavigationMode});
  rtl.createClass(this,"TTMSFNCCustomTileList",pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl,function () {
    this.$init = function () {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.$init.call(this);
      this.FPageAnimationTimer = null;
      this.FTileAnimationTimer = null;
      this.FDragTimer = null;
      this.FDownX$1 = 0.0;
      this.FDownY$1 = 0.0;
      this.FMoveX = 0.0;
      this.FMoveY = 0.0;
      this.FDownRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FDragRect = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      this.FDragItem = $mod.TTMSFNCTileListDisplayItem.$new();
      this.FDisplayList = null;
      this.FUpdateCount$2 = 0;
      this.FRows = 0;
      this.FColumns = 0;
      this.FPageCount = 0;
      this.FItems = null;
      this.FAppearance = null;
      this.FSelectedItemIndex = 0;
      this.FFocusedItemIndex = 0;
      this.FHoveredItemIndex = 0;
      this.FPrevHoverIndex = 0;
      this.FDownItemIndex = 0;
      this.FDragItemIndex = 0;
      this.FOnAfterDraw$1 = null;
      this.FOnAfterDrawItemBackground = null;
      this.FOnItemSelected = null;
      this.FOnBeforeDraw$1 = null;
      this.FOnBeforeDrawItemBackground = null;
      this.FOnItemDeselected = null;
      this.FOnItemClick = null;
      this.FOnBeforeDrawItemContent = null;
      this.FOnAfterDrawItemContent = null;
      this.FOnInternalItemInserting = null;
      this.FOrientation = 0;
      this.FMultiSelect = false;
      this.FPageIndex = 0;
      this.FPageWidth = 0.0;
      this.FPageHeight = 0.0;
      this.FNavigationMode = 0;
      this.FScrollVTo$1 = 0.0;
      this.FScrollHTo$1 = 0.0;
      this.FHoldCounter = 0;
      this.FDragItemPage = 0;
      this.FReorderMode = 0;
      this.FHeader = null;
      this.FFooter = null;
      this.FOnBeforeDrawHeader = null;
      this.FOnBeforeDrawFooter = null;
      this.FOnAfterDrawHeader = null;
      this.FOnAfterDrawFooter = null;
      this.FOnAfterDrawArrow = null;
      this.FOnBeforeDrawArrow = null;
      this.FHeaderArrowLeftHover = false;
      this.FHeaderArrowLeftDown = false;
      this.FHeaderArrowRightHover = false;
      this.FHeaderArrowRightDown = false;
      this.FFooterArrowLeftHover = false;
      this.FFooterArrowLeftDown = false;
      this.FFooterArrowRightHover = false;
      this.FFooterArrowRightDown = false;
      this.FPageDownIndex = 0;
      this.FOnAfterDrawBullet = null;
      this.FOnBeforeDrawBullet = null;
      this.FOnPreviousPageClick = null;
      this.FOnBulletClick = null;
      this.FOnNextPageClick = null;
      this.FBitmapContainer = null;
      this.FOnAfterDrawBadge = null;
      this.FOnBeforeDrawBadge = null;
      this.FFilter = "";
      this.FRecalcList = null;
      this.FVisualizer = null;
      this.FDefaultVisualizer = null;
      this.FOnBeforeDrawItemDescription = null;
      this.FOnAfterDrawItemControl = null;
      this.FOnAfterDrawItemImage = null;
      this.FOnAfterDrawItemTitle = null;
      this.FOnAfterDrawItemDescription = null;
      this.FOnBeforeDrawItemControl = null;
      this.FOnBeforeDrawItemImage = null;
      this.FOnBeforeDrawItemTitle = null;
      this.FOnFilter = null;
      this.FFiltering = 0;
      this.FDragControl = null;
      this.FOnItemAnchorClick = null;
      this.FDblClickDown = false;
      this.FOnItemDoubleClick = null;
    };
    this.$final = function () {
      this.FPageAnimationTimer = undefined;
      this.FTileAnimationTimer = undefined;
      this.FDragTimer = undefined;
      this.FDownRect = undefined;
      this.FDragRect = undefined;
      this.FDragItem = undefined;
      this.FDisplayList = undefined;
      this.FItems = undefined;
      this.FAppearance = undefined;
      this.FOnAfterDraw$1 = undefined;
      this.FOnAfterDrawItemBackground = undefined;
      this.FOnItemSelected = undefined;
      this.FOnBeforeDraw$1 = undefined;
      this.FOnBeforeDrawItemBackground = undefined;
      this.FOnItemDeselected = undefined;
      this.FOnItemClick = undefined;
      this.FOnBeforeDrawItemContent = undefined;
      this.FOnAfterDrawItemContent = undefined;
      this.FOnInternalItemInserting = undefined;
      this.FHeader = undefined;
      this.FFooter = undefined;
      this.FOnBeforeDrawHeader = undefined;
      this.FOnBeforeDrawFooter = undefined;
      this.FOnAfterDrawHeader = undefined;
      this.FOnAfterDrawFooter = undefined;
      this.FOnAfterDrawArrow = undefined;
      this.FOnBeforeDrawArrow = undefined;
      this.FOnAfterDrawBullet = undefined;
      this.FOnBeforeDrawBullet = undefined;
      this.FOnPreviousPageClick = undefined;
      this.FOnBulletClick = undefined;
      this.FOnNextPageClick = undefined;
      this.FBitmapContainer = undefined;
      this.FOnAfterDrawBadge = undefined;
      this.FOnBeforeDrawBadge = undefined;
      this.FRecalcList = undefined;
      this.FVisualizer = undefined;
      this.FDefaultVisualizer = undefined;
      this.FOnBeforeDrawItemDescription = undefined;
      this.FOnAfterDrawItemControl = undefined;
      this.FOnAfterDrawItemImage = undefined;
      this.FOnAfterDrawItemTitle = undefined;
      this.FOnAfterDrawItemDescription = undefined;
      this.FOnBeforeDrawItemControl = undefined;
      this.FOnBeforeDrawItemImage = undefined;
      this.FOnBeforeDrawItemTitle = undefined;
      this.FOnFilter = undefined;
      this.FDragControl = undefined;
      this.FOnItemAnchorClick = undefined;
      this.FOnItemDoubleClick = undefined;
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.$final.call(this);
    };
    this.SetColumns = function (Value) {
      if (this.FColumns !== Value) {
        if (Value > 0) {
          this.FColumns = Value;
          this.CalculateItems(true);
        };
      };
    };
    this.SetRows = function (Value) {
      if (this.FRows !== Value) {
        if (Value > 0) {
          this.FRows = Value;
          this.CalculateItems(true);
        };
      };
    };
    this.SetAppearance = function (Value) {
      this.FAppearance.Assign(Value);
    };
    this.SetSelectedItemIndex = function (Value) {
      if (this.FSelectedItemIndex !== Value) {
        this.FSelectedItemIndex = Value;
        this.FFocusedItemIndex = Value;
        if ((this.FSelectedItemIndex >= 0) && (this.FSelectedItemIndex < this.FItems.GetCount())) this.FItems.GetItem$1(this.FSelectedItemIndex).SetSelected(true);
      };
    };
    this.SetMultiSelect = function (Value) {
      this.FMultiSelect = Value;
    };
    this.SetItems = function (Value) {
      this.FItems.Assign(Value);
    };
    this.SetPageIndex = function (Value) {
      if (this.FPageIndex !== Value) {
        if (this.IsDesignTime()) {
          if ((this.FPageIndex > -1) && (this.FPageIndex < this.FPageCount)) this.JumpToPage(Value);
        } else {
          this.StopAnimationTimer();
          this.AnimateToPage(Value);
        };
      };
    };
    this.SetNavigationMode = function (Value) {
      if (this.FNavigationMode !== Value) {
        this.FNavigationMode = Value;
        if (this.FNavigationMode === $mod.TTMSFNCTileListNavigationMode.tlnmPage) {
          this.SetHorizontalScrollBarVisible(false);
          this.SetVerticalScrollBarVisible(false);
        } else {
          this.SetHorizontalScrollBarVisible(true);
          this.SetVerticalScrollBarVisible(true);
        };
        this.CalculateItems(true);
      };
    };
    this.SetReorderMode = function (Value) {
      if (this.FReorderMode !== Value) this.FReorderMode = Value;
    };
    this.SetFooter = function (Value) {
      this.FFooter.Assign(Value);
    };
    this.SetHeader = function (Value) {
      this.FHeader.Assign(Value);
    };
    this.GetBitmapContainer = function () {
      var Result = null;
      Result = this.FBitmapContainer;
      return Result;
    };
    this.SetBitmapContainer = function (Value) {
      this.FBitmapContainer = Value;
    };
    this.SetFiltering = function (Value) {
      if (this.FFiltering !== Value) this.FFiltering = Value;
    };
    this.GetPageCount = function () {
      var Result = 0;
      Result = this.FPageCount;
      return Result;
    };
    this.ClearSelectedItem = function () {
      this.FSelectedItemIndex = -1;
    };
    this.CreateDragControl = function (ADisplayItem) {
      var Result = null;
      Result = $mod.TTMSFNCTileListDragControl.$create("Create$1",[this]);
      Result.FEventStopPropagation = rtl.diffSet(Result.FEventStopPropagation,rtl.createSet(pas["WEBLib.Controls"].TElementEvent.eeMouseMove,pas["WEBLib.Controls"].TElementEvent.eeMouseUp));
      Result.SetLeft(Math.round(ADisplayItem.DrawRect.Left / this.FPaintScaleFactor));
      Result.SetTop(Math.round(ADisplayItem.DrawRect.Top / this.FPaintScaleFactor));
      Result.SetWidth(Math.round((ADisplayItem.DrawRect.Right - ADisplayItem.DrawRect.Left) / this.FPaintScaleFactor));
      Result.SetHeight(Math.round((ADisplayItem.DrawRect.Bottom - ADisplayItem.DrawRect.Top) / this.FPaintScaleFactor));
      Result.FFill.Assign(this.FAppearance.FFillDown);
      Result.FStroke.Assign(this.FAppearance.FStrokeDown);
      Result.FDisplayItem.$assign(ADisplayItem);
      Result.FVisualizer = this.GetVisualizer($mod.TTMSFNCTileListDisplayItem.$clone(ADisplayItem));
      if ((ADisplayItem.Item != null) && (ADisplayItem.Item.FControl != null)) ADisplayItem.Item.FControl.SetParent(Result);
      Result.SetParent(this);
      return Result;
    };
    this.RemoveDragControl = function () {
      if (this.FDragControl != null) {
        if (this.FDragControl.GetControl() != null) this.FDragControl.GetControl().SetParent(this);
        pas.SysUtils.FreeAndNil({p: this, get: function () {
            return this.p.FDragControl;
          }, set: function (v) {
            this.p.FDragControl = v;
          }});
        this.Invalidate();
      };
    };
    this.UpdateTileControls = function () {
    };
    this.GetVisualizer = function (ADisplayItem) {
      var Result = null;
      if (ADisplayItem.Item.FVisualizer != null) {
        Result = ADisplayItem.Item.FVisualizer}
       else if (this.FVisualizer != null) {
        Result = this.FVisualizer}
       else Result = this.FDefaultVisualizer;
      return Result;
    };
    this.IsBulletRect = function (X, Y, AIndex) {
      var $Self = this;
      var Result = false;
      function GetBulletIndex(AOrientation, ARect, AX, AY, ASpacing) {
        var Result = 0;
        var m = 0.0;
        var l = 0.0;
        var ar = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
        var br = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
        var I = 0;
        Result = -1;
        if (AOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
          m = (ARect.Bottom - ARect.Top) / 4;
          l = (m * $Self.FPageCount) + (ASpacing * ($Self.FPageCount - 1));
          ar.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left + ((ARect.Right - ARect.Left - l) / 2),ARect.Top + ((ARect.Bottom - ARect.Top - m) / 2),l,m));
        } else {
          m = (ARect.Right - ARect.Left) / 4;
          l = (m * $Self.FPageCount) + (ASpacing * ($Self.FPageCount - 1));
          ar.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left + ((ARect.Right - ARect.Left - m) / 2),ARect.Top + ((ARect.Bottom - ARect.Top - l) / 2),m,l));
        };
        if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(ar,pas["WEBLib.TMSFNCTypes"].PointF(AX,AY))) {
          for (var $l = 0, $end = $Self.FPageCount - 1; $l <= $end; $l++) {
            I = $l;
            if ($Self.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
              br.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ar.Left + (I * $Self.FHeader.FBullets.FSpacing) + (I * m),ar.Top,m,m))}
             else br.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ar.Left,ar.Top + (I * $Self.FHeader.FBullets.FSpacing) + (I * m),m,m));
            if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(br,pas["WEBLib.TMSFNCTypes"].PointF(AX,AY))) {
              Result = I;
              return Result;
            };
          };
        };
        return Result;
      };
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result = false;
      if (this.FHeader.FVisible && this.FHeader.FBullets.FVisible) {
        r.$assign(this.GetHeaderRect());
        AIndex.set(GetBulletIndex(this.FOrientation,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),X,Y,this.FHeader.FBullets.FSpacing));
        Result = AIndex.get() !== -1;
      };
      if (!Result && this.FFooter.FVisible && this.FFooter.FBullets.FVisible) {
        r.$assign(this.GetFooterRect());
        AIndex.set(GetBulletIndex(this.FOrientation,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),X,Y,this.FFooter.FBullets.FSpacing));
        Result = AIndex.get() !== -1;
      };
      return Result;
    };
    this.GetArrowRect = function (AHeader, ALeft) {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
      r.$assign(this.GetContentRect());
      if (AHeader && this.FHeader.FVisible) {
        if (ALeft) {
          if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,this.FHeader.FArrowLeft.FSize,this.FHeader.FSize))}
           else Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,this.FHeader.FSize,this.FHeader.FArrowLeft.FSize));
        } else {
          if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Right - this.FHeader.FArrowRight.FSize,r.Top,this.FHeader.FArrowRight.FSize,this.FHeader.FSize))}
           else Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Bottom - this.FHeader.FArrowRight.FSize,this.FHeader.FSize,this.FHeader.FArrowRight.FSize));
        };
      } else if (!AHeader && this.FFooter.FVisible) {
        if (ALeft) {
          if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Bottom - this.FFooter.FSize,this.FFooter.FArrowLeft.FSize,this.FFooter.FSize))}
           else Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Right - this.FFooter.FSize,r.Top,this.FFooter.FSize,this.FFooter.FArrowLeft.FSize));
        } else {
          if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
            Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Right - this.FFooter.FArrowRight.FSize,r.Bottom - this.FFooter.FSize,this.FFooter.FArrowRight.FSize,this.FFooter.FSize))}
           else Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Right - this.FFooter.FSize,r.Bottom - this.FFooter.FArrowRight.FSize,this.FFooter.FSize,this.FFooter.FArrowRight.FSize));
        };
      };
      return Result;
    };
    this.GetHeaderRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
      if (this.FHeader.FVisible) {
        r.$assign(this.GetContentRect());
        if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
          Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,r.Right - r.Left,this.FHeader.FSize))}
         else Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top,this.FHeader.FSize,r.Bottom - r.Top));
      };
      return Result;
    };
    this.GetFooterRect = function () {
      var Result = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      Result.$assign(pas["WEBLib.TMSFNCTypes"].RectF(0,0,0,0));
      if (this.FFooter.FVisible) {
        r.$assign(this.GetContentRect());
        if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
          Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Bottom - this.FFooter.FSize,r.Right - r.Left,this.FFooter.FSize))}
         else Result.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Right - this.FFooter.FSize,r.Top,this.FFooter.FSize,r.Bottom - r.Top));
      };
      return Result;
    };
    this.IsPageAnimating = function () {
      var Result = false;
      Result = this.FPageAnimationTimer.FEnabled;
      return Result;
    };
    this.IsTileAnimating = function () {
      var Result = false;
      Result = this.FTileAnimationTimer.FEnabled;
      return Result;
    };
    this.IsItemDragged = function () {
      var Result = false;
      Result = this.FDragItemIndex !== -1;
      return Result;
    };
    this.IsDraggingAllowed = function () {
      var Result = false;
      Result = (this.FReorderMode !== $mod.TTMSFNCTileListReorderMode.rmNone) && !this.FMultiSelect;
      return Result;
    };
    this.XYToDisplayItem = function (X, Y) {
      var Result = $mod.TTMSFNCTileListDisplayItem.$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;
        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.FEmpty) {
            Result.$assign(this.FDisplayList.GetItem(I));
            break;
          };
        };
      };
      return Result;
    };
    this.CalculatePageIndex = function () {
      if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
        if (this.GetWidth() !== 0) {
          this.FPageIndex = rtl.trunc(Math.round(this.GetHScrollValue() + (this.GetWidth() / 2)) / Math.round(this.GetWidth()))}
         else this.FPageIndex = 0;
      } else {
        if (this.GetHeight() !== 0) {
          this.FPageIndex = rtl.trunc(Math.round(this.GetVScrollValue() + (this.GetHeight() / 2)) / Math.round(this.GetHeight()))}
         else this.FPageIndex = 0;
      };
    };
    this.AnimateToPage = function (AToPage) {
      if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
        this.FScrollHTo$1 = AToPage * this.GetWidth();
        this.FScrollVTo$1 = 0;
      } else {
        this.FScrollVTo$1 = AToPage * this.GetHeight();
        this.FScrollHTo$1 = 0;
      };
      this.FPageAnimationTimer.SetEnabled(true);
    };
    this.JumpToPage = function (AToPage) {
      if (this.FPageIndex !== AToPage) {
        this.FPageIndex = AToPage;
        if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
          this.FScrollHTo$1 = AToPage * this.GetWidth();
          this.FScrollVTo$1 = 0;
        } else {
          this.FScrollVTo$1 = AToPage * this.GetHeight();
          this.FScrollHTo$1 = 0;
        };
        this.Scroll(this.FScrollHTo$1,this.FScrollVTo$1);
      };
    };
    this.EnableDragTimer = function () {
      if (!this.FDragTimer.FEnabled) {
        this.FDragTimer.SetEnabled(true);
      };
    };
    this.StopDragTimer = function () {
      if (this.FDragTimer.FEnabled) this.FDragTimer.SetEnabled(false);
      this.FHoldCounter = 0;
    };
    this.ItemsChanged = function (Sender) {
      this.CalculatePageIndex();
      this.CalculateItems(true);
    };
    this.HeaderChanged = function (Sender) {
      this.CalculateItems(true);
    };
    this.FooterChanged = function (Sender) {
      this.CalculateItems(true);
    };
    this.DoPageAnimationTimer = function (Sender) {
      var dx = 0.0;
      var dy = 0.0;
      var posx = 0.0;
      var posy = 0.0;
      var animh = false;
      var animv = false;
      var anim = false;
      posy = this.GetVScrollValue();
      posx = this.GetHScrollValue();
      dx = Math.abs(this.FScrollHTo$1 - posx) / 3;
      dy = Math.abs(this.FScrollVTo$1 - posy) / 3;
      animv = false;
      if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloVertical) 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,1);
      animh = false;
      if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) 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,1);
      anim = animv || animh;
      if (anim) {
        this.Scroll(posx,posy)}
       else this.FPageAnimationTimer.SetEnabled(false);
    };
    this.DoTileAnimationTimer = function (Sender) {
      var dx = 0.0;
      var dy = 0.0;
      var posx = 0.0;
      var posy = 0.0;
      var x = 0.0;
      var y = 0.0;
      var w = 0.0;
      var h = 0.0;
      var animh = false;
      var animv = false;
      var anim = false;
      this.FDragItem.$assign(this.GetDisplayItem(this.FDragItemIndex));
      if (this.FDragItem.Item != null) {
        x = this.FDragItem.Rect.Left;
        y = this.FDragItem.Rect.Top;
        posx = this.FDragControl.GetLeft();
        posy = this.FDragControl.GetTop();
        dx = Math.abs(x - posx) / 3;
        dy = Math.abs(y - posy) / 3;
        animv = $impl.AnimateDouble({get: function () {
            return posy;
          }, set: function (v) {
            posy = v;
          }},{get: function () {
            return y;
          }, set: function (v) {
            y = v;
          }},dy,1);
        animh = $impl.AnimateDouble({get: function () {
            return posx;
          }, set: function (v) {
            posx = v;
          }},{get: function () {
            return x;
          }, set: function (v) {
            x = v;
          }},dx,1);
        anim = animv || animh;
        if (anim) {
          w = this.FDragRect.Right - this.FDragRect.Left;
          h = this.FDragRect.Bottom - this.FDragRect.Top;
          this.FDragControl.SetLeft(Math.round(posx));
          this.FDragControl.SetTop(Math.round(posy));
          this.FDragRect.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(posx,posy,w,h));
          this.InvalidateItems();
        } else {
          this.FDragItemIndex = -1;
          this.FDragItemPage = -1;
          this.FTileAnimationTimer.SetEnabled(false);
          this.RemoveDragControl();
        };
      } else {
        this.FDragItemIndex = -1;
        this.FDragItemPage = -1;
        this.FTileAnimationTimer.SetEnabled(false);
        this.RemoveDragControl();
      };
    };
    this.DoDragTimer = function (Sender) {
      this.FHoldCounter += 1;
      if (this.FHoldCounter > 9) {
        this.StopDragTimer();
        this.DoHandleTileDrag();
      };
    };
    this.DoHandleTileDrag = function () {
      if ((this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) && (this.FDragRect.Left < (-(this.FDragRect.Right - this.FDragRect.Left) / 3))) {
        this.PreviousPage();
        if (this.FPageIndex > 0) this.EnableDragTimer();
      } else if ((this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) && (this.FDragRect.Right > (this.GetWidth() + ((this.FDragRect.Right - this.FDragRect.Left) / 3)))) {
        this.NextPage();
        if (this.FPageIndex < (this.FPageCount - 1)) this.EnableDragTimer();
      } else if ((this.FOrientation === $mod.TTMSFNCTileListOrientation.tloVertical) && (this.FDragRect.Top < (-(this.FDragRect.Bottom - this.FDragRect.Top) / 3))) {
        this.PreviousPage();
        if (this.FPageIndex > 0) this.EnableDragTimer();
      } else if ((this.FOrientation === $mod.TTMSFNCTileListOrientation.tloVertical) && (this.FDragRect.Bottom > (this.GetHeight() + ((this.FDragRect.Bottom - this.FDragRect.Top) / 3)))) {
        this.NextPage();
        if (this.FPageIndex < (this.FPageCount - 1)) this.EnableDragTimer();
      } else {
        if (this.FReorderMode === $mod.TTMSFNCTileListReorderMode.rmSwap) {
          this.SwapTiles()}
         else if (this.FReorderMode === $mod.TTMSFNCTileListReorderMode.rmShift) {
          this.ShiftTiles()}
         else if (this.FReorderMode === $mod.TTMSFNCTileListReorderMode.rmRearrange) {
          if (this.FHoveredItemIndex !== -1) {
            this.FItems.GetItem$1(this.FDragItemIndex).SetIndex(this.FHoveredItemIndex);
            this.FDragItemIndex = this.FHoveredItemIndex;
            this.FSelectedItemIndex = this.FDragItemIndex;
            this.FFocusedItemIndex = this.FDragItemIndex;
            this.FHoveredItemIndex = -1;
            this.CalculateItems(true);
          };
        };
      };
    };
    this.DoItemDoubleClick = function (AItemIndex) {
      if (this.FOnItemDoubleClick != null) this.FOnItemDoubleClick(this,AItemIndex);
    };
    this.Notification = function (AComponent, Operation) {
      var I = 0;
      pas["WEBLib.Menus"].TWebCustomControl.Notification.apply(this,arguments);
      if (Operation === pas.Classes.TOperation.opRemove) {
        if (AComponent === this.FBitmapContainer) this.FBitmapContainer = null;
        if (AComponent === this.FVisualizer) this.FVisualizer = null;
        if (!(this.FItems != null)) return;
        for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
          I = $l;
          if (AComponent === this.FItems.GetItem$1(I).FVisualizer) this.FItems.GetItem$1(I).FVisualizer = null;
          if (AComponent === this.FItems.GetItem$1(I).FControl) this.FItems.GetItem$1(I).SetControl(null);
        };
      };
    };
    this.SwapTiles = function () {
      var posArr = [];
      var di = $mod.TTMSFNCTileListDisplayItem.$new();
      var arr = [];
      var ind = [];
      var I = 0;
      var J = 0;
      var K = 0;
      var c = 0;
      var r = 0;
      var rf = 0;
      var cf = 0;
      var rl = 0;
      var cl = 0;
      var lInd = 0;
      var fInd = 0;
      var itmC = 0;
      var firstItem = 0;
      var pc = 0;
      fInd = 0;
      lInd = 0;
      if ((this.FHoveredItemIndex !== -1) && (this.FHoveredItemIndex !== this.FDragItemIndex)) {
        di.$assign(this.GetDisplayItem(this.FHoveredItemIndex));
        if ((this.FDragItem.Item.FRowSpan === di.Item.FRowSpan) && (this.FDragItem.Item.FColumnSpan === di.Item.FColumnSpan)) {
          this.FItems.GetItem$1(this.FDragItemIndex).SetIndex(this.FHoveredItemIndex);
          this.FItems.GetItem$1(di.Item.GetIndex()).SetIndex(this.FDragItemIndex);
          this.FDragItemIndex = this.FHoveredItemIndex;
          this.FSelectedItemIndex = this.FDragItemIndex;
          this.FFocusedItemIndex = this.FDragItemIndex;
          this.FHoveredItemIndex = -1;
          this.CalculateItems(true);
        } else {
          if (this.FDragItemPage === -1) this.FDragItemPage = this.FPageIndex;
          pc = Math.abs(this.FPageIndex - this.FDragItemPage) + 1;
          $impl.InitMatrixWithDefaultValues({get: function () {
              return posArr;
            }, set: function (v) {
              posArr = v;
            }},this.FRows * pc,this.FColumns,-1);
          itmC = 0;
          firstItem = -1;
          c = Math.min(this.FPageIndex,this.FDragItemPage);
          for (var $l = 0, $end = this.FRecalcList.GetCount() - 1; $l <= $end; $l++) {
            I = $l;
            itmC += 1;
            if (firstItem === -1) firstItem = this.FRecalcList.GetItem(I).ItemIndex;
            r = this.FRecalcList.GetItem(I).PageIndex - c;
            for (var $l1 = (r * this.FRows) + this.FRecalcList.GetItem(I).Row, $end1 = ((r * this.FRows) + this.FRecalcList.GetItem(I).Row + this.FRecalcList.GetItem(I).RowSpan) - 1; $l1 <= $end1; $l1++) {
              J = $l1;
              for (var $l2 = this.FRecalcList.GetItem(I).Column, $end2 = (this.FRecalcList.GetItem(I).Column + this.FRecalcList.GetItem(I).ColumnSpan) - 1; $l2 <= $end2; $l2++) {
                K = $l2;
                posArr[J][K] = this.FRecalcList.GetItem(I).ItemIndex;
              };
            };
            if ($impl.CoversAtLeastPercent(this.FRecalcList.GetItem(I).Rect,this.FDragRect,0.45) && (this.FRecalcList.GetItem(I).RowSpan <= this.FDragItem.RowSpan) && (this.FRecalcList.GetItem(I).ColumnSpan <= this.FDragItem.ColumnSpan)) {
              arr = rtl.arraySetLength(arr,$mod.TTMSFNCTileListRecalcItem,rtl.length(arr) + 1);
              arr[rtl.length(arr) - 1].$assign(this.FRecalcList.GetItem(I));
            };
          };
          r = 0;
          c = 0;
          if (rtl.length(arr) > 0) {
            fInd = arr[0].ItemIndex;
            r = arr[0].Row;
            c = arr[0].Column;
          };
          cf = 0;
          rf = 0;
          cl = 0;
          rl = 0;
          for (var $l3 = 0, $end3 = rtl.length(arr) - 1; $l3 <= $end3; $l3++) {
            I = $l3;
            if ((c === arr[I].Column) && (((arr[I].Row - r) + arr[I].RowSpan) <= this.FDragItem.RowSpan)) rf = rf + arr[I].RowSpan;
            if ((r === arr[I].Row) && (((arr[I].Column - c) + arr[I].ColumnSpan) <= this.FDragItem.ColumnSpan)) cf = cf + arr[I].ColumnSpan;
            if (((arr[I].Row - r) + arr[I].RowSpan) === this.FDragItem.RowSpan) cl = cl + arr[I].ColumnSpan;
            if (((arr[I].Column - c) + arr[I].ColumnSpan) === this.FDragItem.ColumnSpan) rl = rl + arr[I].RowSpan;
          };
          if ((Math.min(rf,rl) === this.FDragItem.RowSpan) && (Math.min(cf,cl) === this.FDragItem.ColumnSpan)) {
            r = -1;
            c = -1;
            cf = -1;
            rf = -1;
            for (var $l4 = 0, $end4 = (pc * this.FRows) - 1; $l4 <= $end4; $l4++) {
              I = $l4;
              for (var $l5 = 0, $end5 = this.FColumns - 1; $l5 <= $end5; $l5++) {
                J = $l5;
                if ((posArr[I][J] === this.FDragItemIndex) && (r === -1)) {
                  r = I;
                  c = J;
                } else if ((posArr[I][J] === arr[0].ItemIndex) && (rf === -1)) {
                  rf = I;
                  cf = J;
                };
              };
            };
            for (var $l6 = r, $end6 = (r + this.FDragItem.RowSpan) - 1; $l6 <= $end6; $l6++) {
              I = $l6;
              for (var $l7 = c, $end7 = (c + this.FDragItem.ColumnSpan) - 1; $l7 <= $end7; $l7++) {
                J = $l7;
                posArr[I][J] = posArr[(rf + I) - r][(cf + J) - c];
                posArr[(rf + I) - r][(cf + J) - c] = this.FDragItemIndex;
              };
            };
            K = 0;
            $impl.InitArrayWithDefaultValues({get: function () {
                return ind;
              }, set: function (v) {
                ind = v;
              }},itmC,-1);
            for (var $l8 = 0, $end8 = (pc * this.FRows) - 1; $l8 <= $end8; $l8++) {
              I = $l8;
              for (var $l9 = 0, $end9 = this.FColumns - 1; $l9 <= $end9; $l9++) {
                J = $l9;
                if ((posArr[I][J] !== -1) && !$impl.ContainsIndex(ind,posArr[I][J])) {
                  ind[K] = posArr[I][J];
                  K += 1;
                };
              };
            };
            $impl.RearrangeCollectionItems(this.FItems,ind,firstItem,(firstItem + rtl.length(ind)) - 1);
            if (this.FDragItemIndex < fInd) {
              for (var $l10 = 0, $end10 = rtl.length(ind) - 1; $l10 <= $end10; $l10++) {
                I = $l10;
                if (ind[I] === this.FDragItemIndex) {
                  lInd = I;
                  break;
                };
              };
              this.FDragItemIndex = firstItem + lInd;
            } else this.FDragItemIndex = fInd;
            this.FSelectedItemIndex = this.FDragItemIndex;
            this.FFocusedItemIndex = this.FDragItemIndex;
            this.FHoveredItemIndex = -1;
            this.CalculateItems(true);
          };
        };
      };
    };
    var TShiftDirection = {"0": "sdLeft", sdLeft: 0, "1": "sdTop", sdTop: 1, "2": "sdRight", sdRight: 2, "3": "sdBottom", sdBottom: 3};
    var cMargin = 10;
    this.ShiftTiles = function () {
      var ar = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var I = 0;
      var J = 0;
      var K = 0;
      var itmC = 0;
      var firstItem = 0;
      var ind = [];
      var posArr = [];
      var itmPos = [];
      var arr = [];
      var fInd = 0;
      var cf = 0;
      var rf = 0;
      var cl = 0;
      var rl = 0;
      var fillsArea = false;
      var hv = false;
      var sd = 0;
      if ((this.FDragItemPage !== -1) && (this.FDragItemPage !== this.FPageIndex)) return;
      hv = false;
      if (((this.FDragItem.Rect.Top - 10) < this.FDragRect.Top) && ((this.FDragItem.Rect.Bottom + 10) > this.FDragRect.Bottom)) {
        if (this.FDragRect.Left < this.FDragItem.Rect.Left) {
          ar.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(this.FDragRect.Left,Math.min(this.FDragRect.Top,this.FDragItem.Rect.Top),this.FDragItem.Rect.Left - this.FDragRect.Left,Math.max(this.FDragRect.Bottom,this.FDragItem.Rect.Bottom) - Math.min(this.FDragRect.Top,this.FDragItem.Rect.Top)));
          sd = TShiftDirection.sdRight;
        } else {
          ar.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(this.FDragItem.Rect.Right,Math.min(this.FDragRect.Top,this.FDragItem.Rect.Top),this.FDragRect.Right - this.FDragItem.Rect.Right,Math.max(this.FDragRect.Bottom,this.FDragItem.Rect.Bottom) - Math.min(this.FDragRect.Top,this.FDragItem.Rect.Top)));
          sd = TShiftDirection.sdLeft;
        };
        hv = true;
      } else if (((this.FDragItem.Rect.Left - 10) < this.FDragRect.Left) && ((this.FDragItem.Rect.Right + 10) > this.FDragRect.Right)) {
        if (this.FDragRect.Top < this.FDragItem.Rect.Top) {
          ar.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(Math.min(this.FDragRect.Left,this.FDragItem.Rect.Left),this.FDragRect.Top,Math.max(this.FDragRect.Right,this.FDragItem.Rect.Right) - Math.min(this.FDragRect.Left,this.FDragItem.Rect.Left),this.FDragItem.Rect.Top - this.FDragRect.Top));
          sd = TShiftDirection.sdBottom;
        } else {
          ar.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(Math.min(this.FDragRect.Left,this.FDragItem.Rect.Left),this.FDragItem.Rect.Bottom,Math.max(this.FDragRect.Right,this.FDragItem.Rect.Right) - Math.min(this.FDragRect.Left,this.FDragItem.Rect.Left),this.FDragRect.Bottom - this.FDragItem.Rect.Bottom));
          sd = TShiftDirection.sdTop;
        };
        hv = true;
      } else sd = TShiftDirection.sdLeft;
      if (!hv) return;
      $impl.InitMatrixWithDefaultValues({get: function () {
          return posArr;
        }, set: function (v) {
          posArr = v;
        }},this.FRows,this.FColumns,-1);
      itmC = 0;
      firstItem = -1;
      for (var $l = 0, $end = this.FRecalcList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        itmC += 1;
        if (firstItem === -1) firstItem = this.FRecalcList.GetItem(I).ItemIndex;
        for (var $l1 = this.FRecalcList.GetItem(I).Row, $end1 = (this.FRecalcList.GetItem(I).Row + this.FRecalcList.GetItem(I).RowSpan) - 1; $l1 <= $end1; $l1++) {
          J = $l1;
          for (var $l2 = this.FRecalcList.GetItem(I).Column, $end2 = (this.FRecalcList.GetItem(I).Column + this.FRecalcList.GetItem(I).ColumnSpan) - 1; $l2 <= $end2; $l2++) {
            K = $l2;
            posArr[J][K] = this.FRecalcList.GetItem(I).ItemIndex;
          };
        };
        if ($impl.CoversAtLeastPercent(this.FRecalcList.GetItem(I).Rect,ar,0.80)) {
          arr = rtl.arraySetLength(arr,$mod.TTMSFNCTileListRecalcItem,rtl.length(arr) + 1);
          arr[rtl.length(arr) - 1].$assign(this.FRecalcList.GetItem(I));
        };
      };
      itmPos = rtl.arraySetLength(itmPos,false,this.FRows,this.FColumns);
      for (var $l3 = 0, $end3 = this.FRows - 1; $l3 <= $end3; $l3++) {
        I = $l3;
        for (var $l4 = 0, $end4 = this.FColumns - 1; $l4 <= $end4; $l4++) {
          J = $l4;
          itmPos[I][J] = false;
        };
      };
      cf = 0;
      rf = 0;
      cl = 0;
      rl = 0;
      if (rtl.length(arr) > 0) {
        rf = arr[0].Row;
        cf = arr[0].Column;
      };
      for (var $l5 = 0, $end5 = rtl.length(arr) - 1; $l5 <= $end5; $l5++) {
        I = $l5;
        cf = Math.min(cf,arr[I].Column);
        rf = Math.min(rf,arr[I].Row);
        cl = Math.max(cl,(arr[I].Column + arr[I].ColumnSpan) - 1);
        rl = Math.max(rl,(arr[I].Row + arr[I].RowSpan) - 1);
        for (var $l6 = arr[I].Row, $end6 = (arr[I].Row + arr[I].RowSpan) - 1; $l6 <= $end6; $l6++) {
          J = $l6;
          for (var $l7 = arr[I].Column, $end7 = (arr[I].Column + arr[I].ColumnSpan) - 1; $l7 <= $end7; $l7++) {
            K = $l7;
            itmPos[J][K] = true;
          };
        };
      };
      fillsArea = true;
      for (var $l8 = rf, $end8 = rl; $l8 <= $end8; $l8++) {
        I = $l8;
        for (var $l9 = cf, $end9 = cl; $l9 <= $end9; $l9++) {
          J = $l9;
          if (!itmPos[I][J]) {
            fillsArea = false;
            break;
          };
        };
      };
      if (fillsArea) {
        var $tmp = sd;
        if ($tmp === TShiftDirection.sdLeft) {
          for (var $l10 = rf, $end10 = rl; $l10 <= $end10; $l10++) {
            I = $l10;
            for (var $l11 = cf, $end11 = cl; $l11 <= $end11; $l11++) {
              J = $l11;
              posArr[I][J - this.FDragItem.ColumnSpan] = posArr[I][J];
              if (pas.Math.InRange(J,(cl - this.FDragItem.ColumnSpan) + 1,cl)) posArr[I][J] = this.FDragItemIndex;
            };
          };
        } else if ($tmp === TShiftDirection.sdTop) {
          for (var $l12 = rf, $end12 = rl; $l12 <= $end12; $l12++) {
            I = $l12;
            for (var $l13 = cf, $end13 = cl; $l13 <= $end13; $l13++) {
              J = $l13;
              posArr[I - this.FDragItem.RowSpan][J] = posArr[I][J];
              if (pas.Math.InRange(I,(rl - this.FDragItem.RowSpan) + 1,rl)) posArr[I][J] = this.FDragItemIndex;
            };
          };
        } else if ($tmp === TShiftDirection.sdBottom) {
          for (var $l14 = rl, $end14 = rf; $l14 >= $end14; $l14--) {
            I = $l14;
            for (var $l15 = cl, $end15 = cf; $l15 >= $end15; $l15--) {
              J = $l15;
              posArr[I + this.FDragItem.RowSpan][J] = posArr[I][J];
              if (pas.Math.InRange(I,rf,(rf + this.FDragItem.RowSpan) - 1)) posArr[I][J] = this.FDragItemIndex;
            };
          };
        } else if ($tmp === TShiftDirection.sdRight) {
          for (var $l16 = rl, $end16 = rf; $l16 >= $end16; $l16--) {
            I = $l16;
            for (var $l17 = cl, $end17 = cf; $l17 >= $end17; $l17--) {
              J = $l17;
              posArr[I][J + this.FDragItem.ColumnSpan] = posArr[I][J];
              if (pas.Math.InRange(J,cf,(cf + this.FDragItem.ColumnSpan) - 1)) posArr[I][J] = this.FDragItemIndex;
            };
          };
        };
        K = 0;
        $impl.InitArrayWithDefaultValues({get: function () {
            return ind;
          }, set: function (v) {
            ind = v;
          }},itmC,-1);
        for (var $l18 = 0, $end18 = this.FRows - 1; $l18 <= $end18; $l18++) {
          I = $l18;
          for (var $l19 = 0, $end19 = this.FColumns - 1; $l19 <= $end19; $l19++) {
            J = $l19;
            if ((posArr[I][J] !== -1) && !$impl.ContainsIndex(ind,posArr[I][J])) {
              ind[K] = posArr[I][J];
              K += 1;
            };
          };
        };
        $impl.RearrangeCollectionItems(this.FItems,ind,firstItem,(firstItem + rtl.length(ind)) - 1);
        fInd = 0;
        for (var $l20 = 0, $end20 = rtl.length(ind) - 1; $l20 <= $end20; $l20++) {
          I = $l20;
          if (ind[I] === this.FDragItemIndex) {
            fInd = I;
            break;
          };
        };
        this.FDragItemIndex = firstItem + fInd;
        this.FSelectedItemIndex = this.FDragItemIndex;
        this.FFocusedItemIndex = this.FDragItemIndex;
        this.CalculateItems(true);
      };
    };
    this.GetTotalContentHeight = function () {
      var Result = 0.0;
      if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloVertical) {
        Result = this.FPageHeight}
       else Result = 0;
      return Result;
    };
    this.GetTotalContentWidth = function () {
      var Result = 0.0;
      if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
        Result = this.GetWidth() * Math.max(this.FPageCount,1)}
       else Result = 0;
      return Result;
    };
    this.SetOrientation = function (Value) {
      if (this.FOrientation !== Value) {
        this.FOrientation = Value;
        this.CalculateItems(true);
        this.StopAnimationTimer();
        if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloVertical) {
          this.Scroll(0,this.FPageIndex * this.GetHeight())}
         else this.Scroll(this.FPageIndex * this.GetWidth(),0);
      };
    };
    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,2,3);
      return Result;
    };
    this.GetDisplayItem = function (AItemIndex) {
      var Result = $mod.TTMSFNCTileListDisplayItem.$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.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.GetIndex() < this.FFocusedItemIndex)) {
          Result = it.GetIndex();
          break;
        };
      };
      return Result;
    };
    this.GetNextSelectableRowItem = function () {
      var Result = 0;
      var I = 0;
      var it = null;
      var disp = $mod.TTMSFNCTileListDisplayItem.$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.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.TTMSFNCTileListDisplayItem.$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.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) {
          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) {
          Result = it.GetIndex();
          break;
        };
      };
      return Result;
    };
    this.CreateItemsCollection = function () {
      var Result = null;
      Result = $mod.TTMSFNCTileListItems.$create("Create$3",[this]);
      return Result;
    };
    this.ColumnStretchingActive = function () {
      var Result = false;
      Result = false;
      return Result;
    };
    this.ChangeDPIScale = function (M, D) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.ChangeDPIScale.apply(this,arguments);
      this.BeginUpdate();
      this.FAppearance.FFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FFont.FHeight,M,D));
      this.FAppearance.FBadgeFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FBadgeFont.FHeight,M,D));
      this.FAppearance.FDescriptionFont.SetHeight(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivInt(this.FAppearance.FDescriptionFont.FHeight,M,D));
      this.FHeader.SetSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FHeader.FSize,M,D));
      this.FHeader.FBullets.SetSpacing(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FHeader.FBullets.FSpacing,M,D));
      this.FHeader.FArrowLeft.SetSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FHeader.FArrowLeft.FSize,M,D));
      this.FHeader.FArrowRight.SetSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FHeader.FArrowRight.FSize,M,D));
      this.FFooter.SetSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FFooter.FSize,M,D));
      this.FFooter.FBullets.SetSpacing(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FFooter.FBullets.FSpacing,M,D));
      this.FFooter.FArrowLeft.SetSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FFooter.FArrowLeft.FSize,M,D));
      this.FFooter.FArrowRight.SetSize(pas["WEBLib.TMSFNCUtils"].TTMSFNCUtils.MulDivSingle(this.FFooter.FArrowRight.FSize,M,D));
      this.EndUpdate();
    };
    this.VerticalScrollPositionChanged = function () {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.VerticalScrollPositionChanged.call(this);
      this.CalculatePageIndex();
      this.CalculateItems(true);
    };
    this.HorizontalScrollPositionChanged = function () {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.HorizontalScrollPositionChanged.call(this);
      this.CalculatePageIndex();
      this.CalculateItems(true);
    };
    this.CalculateItems = function (ARealign) {
      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 txx = 0.0;
      var tyy = 0.0;
      var pw = 0.0;
      var ph = 0.0;
      var sch = 0.0;
      var scv = 0.0;
      var itd = $mod.TTMSFNCTileListDisplayItem.$new();
      var itp = $mod.TTMSFNCTileListRecalcItem.$new();
      var rc = pas["WEBLib.TMSFNCTypes"].TRectF.$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);
        ANewR.set(0);
        ANewC.set(0);
        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;
            if ((AItem.FRowSpan > Math.min(AItem.FRowSpan,$Self.FRows - ANewR.get())) || (AItem.FColumnSpan > Math.min(AItem.FColumnSpan,$Self.FColumns - ANewC.get()))) break;
            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]) 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$2 > 0)) return;
      this.FDisplayList.Clear();
      this.FRecalcList.Clear();
      this.FPageCount = 0;
      if (this.FItems.GetCount() === 0) return;
      rc.$assign(this.GetContentRect());
      pw = rc.Right - rc.Left;
      if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloVertical) pw = pw - this.GetHeaderOffset() - this.GetFooterOffset();
      ph = rc.Bottom - rc.Top;
      if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) ph = ph - this.GetHeaderOffset() - this.GetFooterOffset();
      sch = -this.GetHorizontalScrollPosition();
      scv = -this.GetVerticalScrollPosition();
      hs = this.FAppearance.FHorizontalSpacing;
      vs = this.FAppearance.FVerticalSpacing;
      w = pw - vs;
      iw = w;
      if (this.FAppearance.FItemWidth > -1) {
        iw = this.ScalePaintValue$1(this.FAppearance.FItemWidth)}
       else if (this.FColumns > 0) iw = (w - (this.FColumns * hs)) / this.FColumns;
      h = ph - vs;
      sepc = 0;
      ih = h;
      if (this.FAppearance.FItemHeight > -1) {
        ih = this.ScalePaintValue$1(this.FAppearance.FItemHeight)}
       else if (((this.FRows - sepc) > 0) && (this.FRows > 0)) ih = (h - (this.FRows * vs)) / this.FRows;
      AItemIndex = 0;
      APageIndex = 0;
      while (AItemIndex <= (this.FItems.GetCount() - 1)) {
        c = 0;
        r = 0;
        itposarr = rtl.arraySetLength(itposarr,false,0,0);
        itposarr = rtl.arraySetLength(itposarr,false,this.FRows,this.FColumns);
        while (r < this.FRows) {
          while (c < this.FColumns) {
            if ((AItemIndex >= 0) && (AItemIndex <= (this.FItems.GetCount() - 1))) {
              AItem = this.FItems.GetItem$1(AItemIndex);
              if (!AItem.FVisible || !AItem.AllowDisplay()) {
                AItemIndex += 1;
                continue;
              };
              if (this.FDragItemIndex === AItemIndex) this.FDragItemPage = APageIndex;
              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));
              exh = (ih * rspan) + (vs * (rspan - 1));
              if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
                txx = (pw * APageIndex) + hs + (iw * c) + (hs * c);
                tyy = vs + (ih * r) + (vs * r) + this.GetHeaderOffset();
              } else {
                txx = hs + (iw * c) + (hs * c) + this.GetHeaderOffset();
                tyy = (ph * APageIndex) + vs + (ih * r) + (vs * r);
              };
              tx = txx + sch;
              ty = tyy + scv;
              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.DrawRect.$assign(itd.Rect);
              itd.AbsRect.$assign(pas["WEBLib.TMSFNCTypes"].RectF(txx + AItem.FMargins.FLeft,tyy + AItem.FMargins.FTop,(txx + exw) - AItem.FMargins.FRight,(tyy + exh) - AItem.FMargins.FBottom));
              itd.Item = AItem;
              itd.PageIndex = APageIndex;
              itd.Column = c;
              itd.Row = r;
              itd.ColumnSpan = cspan;
              itd.RowSpan = rspan;
              if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
                if (pas.Math.InRange$1(itd.Rect.Left,0,pw) || pas.Math.InRange$1(itd.Rect.Right,0,pw) || (itd.Item.GetIndex() === this.FDragItemIndex)) {
                  if ((itd.Item != null) && (itd.Item.FControl != null) && !itd.Item.FControl.FVisible) itd.Item.FControl.SetVisible(true);
                  this.FDisplayList.Add($mod.TTMSFNCTileListDisplayItem.$clone(itd));
                } else {
                  if ((itd.Item != null) && (itd.Item.FControl != null) && itd.Item.FControl.FVisible) itd.Item.FControl.SetVisible(false);
                };
              } else {
                if (pas.Math.InRange$1(itd.Rect.Top,0,ph) || pas.Math.InRange$1(itd.Rect.Bottom,0,ph) || (itd.Item.GetIndex() === this.FDragItemIndex)) {
                  if ((itd.Item != null) && (itd.Item.FControl != null) && !itd.Item.FControl.FVisible) itd.Item.FControl.SetVisible(true);
                  this.FDisplayList.Add($mod.TTMSFNCTileListDisplayItem.$clone(itd));
                } else {
                  if ((itd.Item != null) && (itd.Item.FControl != null) && itd.Item.FControl.FVisible) itd.Item.FControl.SetVisible(false);
                };
              };
              itp.Rect.$assign(itd.Rect);
              itp.PageIndex = APageIndex;
              itp.Column = c;
              itp.Row = r;
              itp.ColumnSpan = cspan;
              itp.RowSpan = rspan;
              itp.ItemIndex = AItem.GetIndex();
              if (this.FDragItemPage !== -1) {
                if (pas.Math.InRange(APageIndex,Math.min(this.FPageIndex,this.FDragItemPage),Math.max(this.FPageIndex,this.FDragItemPage))) this.FRecalcList.Add($mod.TTMSFNCTileListRecalcItem.$clone(itp));
              } else {
                if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
                  if (pas.Math.InRange$1(itp.Rect.Left,0,pw) || pas.Math.InRange$1(itp.Rect.Right,0,pw)) this.FRecalcList.Add($mod.TTMSFNCTileListRecalcItem.$clone(itp));
                } else {
                  if (pas.Math.InRange$1(itp.Rect.Top,0,ph) || pas.Math.InRange$1(itp.Rect.Bottom,0,ph)) this.FRecalcList.Add($mod.TTMSFNCTileListRecalcItem.$clone(itp));
                };
              };
              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] = true;
                };
              };
            };
            AItemIndex += 1;
            c += 1;
            newc = c;
            newr = r;
            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;
          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.FPageWidth = this.GetWidth() * this.FPageCount;
      this.FPageHeight = this.GetHeight() * this.FPageCount;
      if (ARealign) {
        this.UpdateControlScrollBars(true,true);
        this.CalculateItems(false);
      } else this.InvalidateItems();
    };
    this.GetHeaderOffset = function () {
      var Result = 0.0;
      if (this.FHeader.FVisible) {
        Result = this.FHeader.FSize}
       else Result = 0;
      return Result;
    };
    this.GetFooterOffset = function () {
      var Result = 0.0;
      if (this.FFooter.FVisible) {
        Result = this.FFooter.FSize}
       else Result = 0;
      return Result;
    };
    this.AdjustScrollPosition = function () {
      var sv = 0.0;
      if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
        sv = this.GetHScrollValue();
        this.UpdateControlScrollBars(true,true);
        if (this.FPageWidth > 0) this.Scroll(sv * ((this.GetWidth() * this.FPageCount) / this.FPageWidth),this.GetVScrollValue());
      } else {
        sv = this.GetVScrollValue();
        this.UpdateControlScrollBars(true,true);
        if (this.FPageHeight > 0) this.Scroll(this.GetHScrollValue(),sv * ((this.GetHeight() * this.FPageCount) / this.FPageHeight));
      };
    };
    this.UpdateControlScroll = function (AHorizontalPos, AVerticalPos, ANewHorizontalPos, ANewVerticalPos) {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.UpdateControlScroll.apply(this,arguments);
      this.CalculatePageIndex();
      this.CalculateItems(true);
    };
    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.FAppearance.FDescriptionFont.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.FHeader.FFill.SetColor(0xF9F2EE);
      this.FHeader.FArrowLeft.FFill.SetColor(0xF9F2EE);
      this.FHeader.FArrowRight.FFill.SetColor(0xF9F2EE);
      this.FHeader.FArrowLeft.FDownFill.SetColor(0xF9F2EE);
      this.FHeader.FArrowRight.FDownFill.SetColor(0xF9F2EE);
      this.FHeader.FArrowLeft.FHoverFill.SetColor(0xF9F2EE);
      this.FHeader.FArrowRight.FHoverFill.SetColor(0xF9F2EE);
      this.FHeader.FArrowLeft.FArrowFill.SetColor(6908265);
      this.FHeader.FArrowLeft.FArrowHoverFill.SetColor(6908265);
      this.FHeader.FArrowLeft.FArrowDownFill.SetColor(6908265);
      this.FHeader.FArrowRight.FArrowFill.SetColor(6908265);
      this.FHeader.FArrowRight.FArrowHoverFill.SetColor(6908265);
      this.FHeader.FArrowRight.FArrowDownFill.SetColor(6908265);
      this.FHeader.FBullets.FSelectedFill.SetColor(8421504);
      this.FHeader.FStroke.SetKind(pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsStrokeKind.gskSolid);
      this.FHeader.FStroke.SetColor(12632256);
      this.FHeader.FArrowLeft.FStroke.SetColor(12632256);
      this.FHeader.FArrowRight.FStroke.SetColor(12632256);
      this.FHeader.FBullets.FSelectedStroke.SetColor(8421504);
      this.FFooter.FFill.Assign(this.FHeader.FFill);
      this.FFooter.FStroke.Assign(this.FHeader.FStroke);
      this.FFooter.FArrowRight.Assign(this.FHeader.FArrowRight);
      this.FFooter.FArrowLeft.Assign(this.FHeader.FArrowLeft);
      this.FFooter.FBullets.Assign(this.FHeader.FBullets);
      this.FAppearance.FFill.SetColor(0xFCF8F6);
      this.FAppearance.FFillHover.SetColor(0xFADEBB);
      this.FAppearance.FFillDown.SetColor(0xF4BD74);
      this.FAppearance.FFillSelected.SetColor(0xF4BD74);
      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.FBadgeFont.SetColor(16777215);
      this.FAppearance.FDescriptionFont.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.InvalidateItems = function () {
      this.Invalidate();
    };
    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.DoNextPageClick = function () {
      if (this.FOnNextPageClick != null) this.FOnNextPageClick(this);
    };
    this.DoPreviousPageClick = function () {
      if (this.FOnPreviousPageClick != null) this.FOnPreviousPageClick(this);
    };
    this.DoBulletClick = function (APageIndex) {
      if (this.FOnBulletClick != null) this.FOnBulletClick(this,APageIndex);
    };
    this.DoItemAnchorClick = function (ATileIndex, AAnchor) {
      if (this.FOnItemAnchorClick != null) this.FOnItemAnchorClick(this,AAnchor,ATileIndex);
    };
    this.DoBeforeDrawItemBackground = function (AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if (this.FOnBeforeDrawItemBackground != null) this.FOnBeforeDrawItemBackground(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoAfterDrawItemBackground = function (AGraphics, ARect, AItemIndex) {
      if (this.FOnAfterDrawItemBackground != null) this.FOnAfterDrawItemBackground(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoBeforeDrawItemContent = function (AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if (this.FOnBeforeDrawItemContent != null) this.FOnBeforeDrawItemContent(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoAfterDrawItemContent = function (AGraphics, ARect, AItemIndex) {
      if (this.FOnAfterDrawItemContent != null) this.FOnAfterDrawItemContent(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoBeforeDrawItemTitle = function (AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if (this.FOnBeforeDrawItemTitle != null) this.FOnBeforeDrawItemTitle(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoAfterDrawItemTitle = function (AGraphics, ARect, AItemIndex) {
      if (this.FOnAfterDrawItemTitle != null) this.FOnAfterDrawItemTitle(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoBeforeDrawItemDescription = function (AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if (this.FOnBeforeDrawItemDescription != null) this.FOnBeforeDrawItemDescription(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoAfterDrawItemDescription = function (AGraphics, ARect, AItemIndex) {
      if (this.FOnAfterDrawItemDescription != null) this.FOnAfterDrawItemDescription(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoBeforeDrawItemImage = function (AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if (this.FOnBeforeDrawItemImage != null) this.FOnBeforeDrawItemImage(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoAfterDrawItemImage = function (AGraphics, ARect, AItemIndex) {
      if (this.FOnAfterDrawItemImage != null) this.FOnAfterDrawItemImage(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    this.DoBeforeDrawItemControl = function (AGraphics, ARect, AItemIndex, ADefaultDraw) {
      if (this.FOnBeforeDrawItemControl != null) this.FOnBeforeDrawItemControl(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex,ADefaultDraw);
    };
    this.DoAfterDrawItemControl = function (AGraphics, ARect, AItemIndex) {
      if (this.FOnAfterDrawItemControl != null) this.FOnAfterDrawItemControl(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AItemIndex);
    };
    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.DoBeforeDrawHeader = function (AGraphics, ARect, ADefaultDraw) {
      if (this.FOnBeforeDrawHeader != null) this.FOnBeforeDrawHeader(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ADefaultDraw);
    };
    this.DoAfterDrawHeader = function (AGraphics, ARect) {
      if (this.FOnAfterDrawHeader != null) this.FOnAfterDrawHeader(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.DoBeforeDrawFooter = function (AGraphics, ARect, ADefaultDraw) {
      if (this.FOnBeforeDrawFooter != null) this.FOnBeforeDrawFooter(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ADefaultDraw);
    };
    this.DoAfterDrawFooter = function (AGraphics, ARect) {
      if (this.FOnAfterDrawFooter != null) this.FOnAfterDrawFooter(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.DoBeforeDrawArrow = function (AGraphics, ARect, ALeft, ADefaultDraw) {
      if (this.FOnBeforeDrawArrow != null) this.FOnBeforeDrawArrow(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ALeft,ADefaultDraw);
    };
    this.DoAfterDrawArrow = function (AGraphics, ARect, ALeft) {
      if (this.FOnAfterDrawArrow != null) this.FOnAfterDrawArrow(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),ALeft);
    };
    this.DoBeforeDrawBullet = function (AGraphics, ARect, AIndex, ASelected, ADefaultDraw) {
      if (this.FOnBeforeDrawBullet != null) this.FOnBeforeDrawBullet(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AIndex,ASelected,ADefaultDraw);
    };
    this.DoAfterDrawBullet = function (AGraphics, ARect, AIndex, ASelected) {
      if (this.FOnAfterDrawBullet != null) this.FOnAfterDrawBullet(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),AIndex,ASelected);
    };
    this.DoBeforeDrawBadge = function (AGraphics, AItemRect, ABadgeRect, ABadgeText, AItemIndex, ADefaultDraw) {
      if (this.FOnBeforeDrawBadge != null) this.FOnBeforeDrawBadge(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(AItemRect),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ABadgeRect),ABadgeText,AItemIndex,ADefaultDraw);
    };
    this.DoAfterDrawBadge = function (AGraphics, AItemRect, ABadgeRect, ABadgeText, AItemIndex) {
      if (this.FOnAfterDrawBadge != null) this.FOnAfterDrawBadge(this,AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(AItemRect),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ABadgeRect),ABadgeText,AItemIndex);
    };
    this.DrawItems = function (AGraphics) {
      var I = 0;
      for (var $l = 0, $end = this.FDisplayList.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FDisplayList.GetItem(I).Item.GetIndex() !== this.FDragItemIndex) this.DrawItem(AGraphics,$mod.TTMSFNCTileListDisplayItem.$clone(this.FDisplayList.GetItem(I)));
      };
    };
    this.Draw = function (AGraphics, ARect) {
      var a = false;
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.Draw.apply(this,arguments);
      AGraphics.FBitmapContainer = this.GetBitmapContainer();
      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.DrawHeader(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
        this.DrawFooter(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(this.GetContentRect()));
        this.DoAfterDraw$1(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
      };
    };
    this.DrawHeader = function (AGraphics, ARect) {
      var b = false;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (this.FHeader.FVisible) {
        AGraphics.FFill.Assign(this.FHeader.FFill);
        AGraphics.FStroke.Assign(this.FHeader.FStroke);
        if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
          r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,ARect.Top,ARect.Right - ARect.Left,this.FHeader.FSize))}
         else r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,ARect.Top,this.FHeader.FSize,ARect.Bottom - ARect.Top));
        b = true;
        this.DoBeforeDrawHeader(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),{get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }});
        if (b) {
          AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
          this.DrawBullets(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FHeader.FBullets);
          this.DrawArrow(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FHeader.FArrowLeft,this.FHeaderArrowLeftHover,this.FHeaderArrowLeftDown);
          this.DrawArrow(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FHeader.FArrowRight,this.FHeaderArrowRightHover,this.FHeaderArrowRightDown);
          this.DoAfterDrawHeader(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
        };
      };
    };
    this.DrawFooter = function (AGraphics, ARect) {
      var b = false;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      if (this.FFooter.FVisible) {
        AGraphics.FFill.Assign(this.FFooter.FFill);
        AGraphics.FStroke.Assign(this.FFooter.FStroke);
        if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
          r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,ARect.Bottom - this.FFooter.FSize,ARect.Right - ARect.Left,this.FFooter.FSize))}
         else r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Right - this.FFooter.FSize,ARect.Top,this.FFooter.FSize,ARect.Bottom - ARect.Top));
        b = true;
        this.DoBeforeDrawFooter(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),{get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }});
        if (b) {
          AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
          this.DrawBullets(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FFooter.FBullets);
          this.DrawArrow(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FFooter.FArrowLeft,this.FFooterArrowLeftHover,this.FFooterArrowLeftDown);
          this.DrawArrow(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.FFooter.FArrowRight,this.FFooterArrowRightHover,this.FFooterArrowRightDown);
          this.DoAfterDrawFooter(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r));
        };
      };
    };
    this.DrawItemBadge = function (AGraphics, AItemRect, ADisplayItem) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var b = false;
      if (ADisplayItem.Item.FBadge !== "") {
        r.$assign(AGraphics.CalculateText(ADisplayItem.Item.FBadge,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(AItemRect),false,true));
        pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(r,this.ScalePaintValue(-5),this.ScalePaintValue(-5));
        pas["WEBLib.TMSFNCTypes"].InflateRectEx(r,this.ScalePaintValue(8),this.ScalePaintValue(4));
        AGraphics.FFill.Assign(this.FAppearance.FBadgeFill);
        AGraphics.FStroke.Assign(this.FAppearance.FBadgeStroke);
        AGraphics.FFont.AssignSource(this.FAppearance.FBadgeFont);
        b = true;
        this.DoBeforeDrawBadge(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(AItemRect),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),ADisplayItem.Item.FBadge,ADisplayItem.Item.GetIndex(),{get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }});
        if (b) {
          AGraphics.DrawRoundRectangle$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),this.ScalePaintValue(10),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);
          AGraphics.DrawText$1(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),ADisplayItem.Item.FBadge,false,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextAlign.gtaCenter,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsTextTrimming.gttNone,0,-1,-1,true,false,-1,-1);
          this.DoAfterDrawBadge(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(AItemRect),pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),ADisplayItem.Item.FBadge,ADisplayItem.Item.GetIndex());
        };
      };
    };
    this.DrawArrow = function (AGraphics, ARect, AArrow, AHover, ADown) {
      var b = false;
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var ar = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var m = 0.0;
      if (AArrow.FVisible) {
        if (ADown) {
          AGraphics.FFill.Assign(AArrow.FDownFill);
          AGraphics.FStroke.Assign(AArrow.FDownStroke);
        } else if (AHover) {
          AGraphics.FFill.Assign(AArrow.FHoverFill);
          AGraphics.FStroke.Assign(AArrow.FHoverStroke);
        } else {
          AGraphics.FFill.Assign(AArrow.FFill);
          AGraphics.FStroke.Assign(AArrow.FStroke);
        };
        if (AArrow.IsLeft()) {
          if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
            r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,ARect.Top,AArrow.FSize,ARect.Bottom - ARect.Top))}
           else r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,ARect.Top,ARect.Right - ARect.Left,AArrow.FSize));
        } else {
          if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
            r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Right - AArrow.FSize,ARect.Top,AArrow.FSize,ARect.Bottom - ARect.Top))}
           else r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left,ARect.Bottom - AArrow.FSize,ARect.Right - ARect.Left,AArrow.FSize));
        };
        b = true;
        this.DoBeforeDrawArrow(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),AArrow.IsLeft(),{get: function () {
            return b;
          }, set: function (v) {
            b = v;
          }});
        if (b) {
          AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
          if (ADown) {
            AGraphics.FFill.Assign(AArrow.FArrowDownFill)}
           else if (AHover) {
            AGraphics.FFill.Assign(AArrow.FArrowHoverFill)}
           else AGraphics.FFill.Assign(AArrow.FArrowFill);
          m = Math.min((r.Right - r.Left) / 3,(r.Bottom - r.Top) / 3);
          ar.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left + ((r.Right - r.Left - m) / 2),r.Top + ((r.Bottom - r.Top - m) / 2),m,m));
          this.DrawArrowIcon(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ar),AArrow.IsLeft());
          this.DoAfterDrawArrow(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(r),AArrow.IsLeft());
        };
      };
    };
    this.DrawArrowIcon = function (AGraphics, ARect, ALeft) {
      var arrPath = null;
      var p = pas["WEBLib.TMSFNCTypes"].TPointF.$new();
      if (ALeft) {
        arrPath = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
        try {
          if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
            p.$assign(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Top + ((ARect.Right - ARect.Left) / 2)))}
           else p.$assign(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left + ((ARect.Right - ARect.Left) / 2),ARect.Top));
          arrPath.MoveTo(p);
          if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
            arrPath.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Top))}
           else arrPath.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Bottom));
          arrPath.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Bottom));
          arrPath.ClosePath();
          AGraphics.FStroke.SetWidth(1);
          AGraphics.DrawPath(arrPath,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon);
        } finally {
          arrPath = rtl.freeLoc(arrPath);
        };
      } else {
        arrPath = pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPath.$create("Create$1");
        try {
          if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
            p.$assign(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Top + ((ARect.Right - ARect.Left) / 2)))}
           else p.$assign(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left + ((ARect.Right - ARect.Left) / 2),ARect.Bottom));
          arrPath.MoveTo(p);
          if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
            arrPath.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Bottom))}
           else arrPath.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Right,ARect.Top));
          arrPath.LineTo(pas["WEBLib.TMSFNCTypes"].PointF(ARect.Left,ARect.Top));
          arrPath.ClosePath();
          AGraphics.FStroke.SetWidth(1);
          AGraphics.DrawPath(arrPath,pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsPathDrawMode.pdmPolygon);
        } finally {
          arrPath = rtl.freeLoc(arrPath);
        };
      };
    };
    this.DrawBullets = function (AGraphics, ARect, ABullets) {
      var r = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var br = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      var l = 0.0;
      var m = 0.0;
      var I = 0;
      var b = false;
      if (ABullets.FVisible) {
        if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
          m = (ARect.Bottom - ARect.Top) / 4;
          l = (m * this.FPageCount) + (ABullets.FSpacing * (this.FPageCount - 1));
          r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left + ((ARect.Right - ARect.Left - l) / 2),ARect.Top + ((ARect.Bottom - ARect.Top - m) / 2),l,m));
        } else {
          m = (ARect.Right - ARect.Left) / 4;
          l = (m * this.FPageCount) + (ABullets.FSpacing * (this.FPageCount - 1));
          r.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(ARect.Left + ((ARect.Right - ARect.Left - m) / 2),ARect.Top + ((ARect.Bottom - ARect.Top - l) / 2),m,l));
        };
        for (var $l = 0, $end = this.FPageCount - 1; $l <= $end; $l++) {
          I = $l;
          if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
            br.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left + (I * ABullets.FSpacing) + (I * m),r.Top,m,m))}
           else br.$assign(pas["WEBLib.TMSFNCTypes"].MakeRectF(r.Left,r.Top + (I * ABullets.FSpacing) + (I * m),m,m));
          if (I === this.FPageIndex) {
            AGraphics.FFill.Assign(ABullets.FSelectedFill);
            AGraphics.FStroke.Assign(ABullets.FSelectedStroke);
          } else {
            AGraphics.FFill.Assign(ABullets.FFill);
            AGraphics.FStroke.Assign(ABullets.FStroke);
          };
          b = true;
          this.DoBeforeDrawBullet(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(br),I,I === this.FPageIndex,{get: function () {
              return b;
            }, set: function (v) {
              b = v;
            }});
          if (b) {
            AGraphics.DrawEllipse$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(br),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
            this.DoAfterDrawBullet(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(br),I,I === this.FPageIndex);
          };
        };
      };
    };
    this.DrawItem = function (AGraphics, ADisplayItem) {
      if (!(ADisplayItem.Item != null) || ADisplayItem.Item.FEmpty) return;
      if (this.FDragItemIndex === ADisplayItem.Item.GetIndex()) {
        ADisplayItem.DrawRect.$assign(this.FDragRect)}
       else ADisplayItem.DrawRect.$assign(ADisplayItem.Rect);
      this.DrawItemBackGround(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.DrawRect),$mod.TTMSFNCTileListDisplayItem.$clone(ADisplayItem));
      this.DrawItemContent(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.DrawRect),$mod.TTMSFNCTileListDisplayItem.$clone(ADisplayItem));
      this.DrawItemBadge(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.DrawRect),$mod.TTMSFNCTileListDisplayItem.$clone(ADisplayItem));
    };
    this.DrawItemContent = function (AGraphics, ARect, ADisplayItem) {
      this.GetVisualizer($mod.TTMSFNCTileListDisplayItem.$clone(ADisplayItem)).Draw($mod.TTMSFNCTileListDisplayItem.$clone(ADisplayItem),AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect));
    };
    this.DrawItemBackGround = function (AGraphics, ARect, ADisplayItem) {
      var it = null;
      var a = false;
      var fr = pas["WEBLib.TMSFNCTypes"].TRectF.$new();
      it = ADisplayItem.Item;
      if (it != null) {
        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.FSelected) {
            AGraphics.FFill.Assign(this.FAppearance.FFillSelected);
            AGraphics.FStroke.Assign(this.FAppearance.FStrokeSelected);
          } else if (it.GetIndex() === this.FHoveredItemIndex) {
            AGraphics.FFill.Assign(this.FAppearance.FFillHover);
            AGraphics.FStroke.Assign(this.FAppearance.FStrokeHover);
          };
        } else {
          AGraphics.FFill.Assign(this.FAppearance.FFillDisabled);
          AGraphics.FStroke.Assign(this.FAppearance.FStrokeDisabled);
        };
        a = true;
        this.DoBeforeDrawItemBackground(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.Rect),it.GetIndex(),{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }});
        if (a) {
          AGraphics.DrawRectangle$2(pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ARect),pas["WEBLib.TMSFNCGraphicsTypes"].TTMSFNCGraphicsModifyRectMode.gcrmShrinkAll);
          if (this.IsFocused() && (this.FFocusedItemIndex === it.GetIndex())) {
            fr.$assign(ARect);
            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.DoAfterDrawItemBackground(AGraphics,pas["WEBLib.TMSFNCTypes"].TRectF.$clone(ADisplayItem.Rect),it.GetIndex());
        };
      };
    };
    this.HandleMouseWheel = function (Shift, WheelDelta, Handled) {
      var vpos = 0.0;
      var hpos = 0.0;
      var sz = 0.0;
      var dsp = $mod.TTMSFNCTileListDisplayItem.$new();
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseWheel.apply(this,arguments);
      if (Handled.get()) return;
      if (this.FNavigationMode === $mod.TTMSFNCTileListNavigationMode.tlnmScroll) {
        vpos = this.GetVScrollValue();
        hpos = this.GetHScrollValue();
        sz = 0;
        if (this.FOrientation === $mod.TTMSFNCTileListOrientation.tloHorizontal) {
          if ((this.FDisplayList != null) && (this.FDisplayList.GetCount() > 0)) {
            dsp.$assign(this.FDisplayList.GetItem(this.FDisplayList.GetCount() - 1));
            sz = (dsp.AbsRect.Right - dsp.AbsRect.Left) + this.FAppearance.FHorizontalSpacing;
          };
          if (WheelDelta > 0) {
            this.Scroll(hpos - sz,vpos)}
           else this.Scroll(hpos + sz,vpos);
        } else {
          if ((this.FDisplayList != null) && (this.FDisplayList.GetCount() > 0)) {
            dsp.$assign(this.FDisplayList.GetItem(this.FDisplayList.GetCount() - 1));
            sz = (dsp.AbsRect.Bottom - dsp.AbsRect.Top) + this.FAppearance.FVerticalSpacing;
          };
          if (WheelDelta > 0) {
            this.Scroll(hpos,vpos - sz)}
           else this.Scroll(hpos,vpos + sz);
        };
        Handled.set(true);
      };
    };
    this.HandleMouseDown = function (Button, Shift, X, Y) {
      var i = 0;
      var it = $mod.TTMSFNCTileListDisplayItem.$new();
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.HandleMouseDown.apply(this,arguments);
      this.CaptureEx();
      this.FDownItemIndex = -1;
      this.FDownX$1 = X;
      this.FDownY$1 = Y;
      this.FMoveX = X;
      this.FMoveY = Y;
      this.FDragItemIndex = -1;
      this.FDragItemPage = -1;
      it.$assign(this.XYToDisplayItem(X,Y));
      if (it.Item != null) {
        this.FDownItemIndex = it.Item.GetIndex();
        this.GetVisualizer($mod.TTMSFNCTileListDisplayItem.$clone(it)).DoMouseDown($mod.TTMSFNCTileListDisplayItem.$clone(it),Button,rtl.refSet(Shift),X,Y);
        if (this.IsDraggingAllowed() && (this.FSelectedItemIndex === it.Item.GetIndex()) && !(this.FDragControl != null)) {
          this.FDragItemIndex = this.FDownItemIndex;
          this.FDragControl = this.CreateDragControl($mod.TTMSFNCTileListDisplayItem.$clone(it));
        };
      };
      this.FHeaderArrowLeftDown = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(true,true),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && this.FHeader.FArrowLeft.FVisible;
      this.FHeaderArrowRightDown = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(true,false),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && this.FHeader.FArrowRight.FVisible;
      this.FFooterArrowLeftDown = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(false,true),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && this.FFooter.FArrowLeft.FVisible;
      this.FFooterArrowRightDown = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(false,false),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && this.FFooter.FArrowRight.FVisible;
      if (pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetHeaderRect(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) || pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetFooterRect(),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
        if (this.IsBulletRect(X,Y,{get: function () {
            return i;
          }, set: function (v) {
            i = v;
          }}) && (i !== this.FPageIndex) && !this.FHeaderArrowLeftDown && !this.FHeaderArrowRightDown && !this.FFooterArrowLeftDown && !this.FFooterArrowRightDown) this.FPageDownIndex = i;
        this.FIsMouseDown = false;
      };
      this.InvalidateItems();
    };
    this.HandleMouseUp = function (Button, Shift, X, Y) {
      var s = 0;
      var it = $mod.TTMSFNCTileListDisplayItem.$new();
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.HandleMouseUp.apply(this,arguments);
      this.ReleaseCaptureEx();
      this.StopDragTimer();
      if (this.FNavigationMode === $mod.TTMSFNCTileListNavigationMode.tlnmPage) this.StopAnimationTimer();
      if (((Math.abs(X - this.FDownX$1) <= 3) && (Math.abs(Y - this.FDownY$1) <= 3) && !this.FAnimating) || this.FScrolling) {
        it.$assign(this.XYToDisplayItem(X,Y));
        if (it.Item != null) {
          s = it.Item.GetIndex()}
         else s = -1;
        if ((s === this.FDownItemIndex) && (this.FDownItemIndex !== -1)) {
          this.ProcessSelection(s,pas.Classes.TShiftState$a.ssCtrl in Shift,pas.Classes.TShiftState$a.ssShift in Shift);
          if (s !== -1) {
            this.GetVisualizer($mod.TTMSFNCTileListDisplayItem.$clone(it)).DoMouseUp($mod.TTMSFNCTileListDisplayItem.$clone(it),Button,rtl.refSet(Shift),X,Y);
            if (this.FDblClickDown) this.DoItemDoubleClick(s);
            this.DoItemClick(s);
          };
        };
      } else {
        if (this.FNavigationMode === $mod.TTMSFNCTileListNavigationMode.tlnmPage) this.AnimateToPage(this.FPageIndex);
      };
      if (this.FDragItemIndex !== -1) this.FTileAnimationTimer.SetEnabled(true);
      this.FDownItemIndex = -1;
      this.FHoveredItemIndex = -1;
      this.FDownX$1 = -1;
      this.FDownY$1 = -1;
      if (this.FHeaderArrowLeftDown && pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(true,true),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
        this.PreviousPage();
        this.DoPreviousPageClick();
      };
      if (this.FHeaderArrowRightDown && pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(true,false),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
        this.NextPage();
        this.DoNextPageClick();
      };
      if (this.FFooterArrowLeftDown && pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(false,true),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
        this.PreviousPage();
        this.DoPreviousPageClick();
      };
      if (this.FFooterArrowRightDown && pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(false,false),pas["WEBLib.TMSFNCTypes"].PointF(X,Y))) {
        this.NextPage();
        this.DoNextPageClick();
      };
      this.FHeaderArrowLeftDown = false;
      this.FHeaderArrowRightDown = false;
      this.FFooterArrowLeftDown = false;
      this.FFooterArrowRightDown = false;
      if (this.FPageDownIndex !== -1) {
        this.GoToPage(this.FPageDownIndex);
        this.DoBulletClick(this.FPageDownIndex);
        this.FPageDownIndex = -1;
      };
    };
    var MoveDelta = 2;
    this.HandleMouseMove = function (Shift, X, Y) {
      var i = 0;
      var ind = 0;
      var it = $mod.TTMSFNCTileListDisplayItem.$new();
      var hdi = $mod.TTMSFNCTileListDisplayItem.$new();
      if (this.IsDraggingAllowed()) {
        if ((this.FDownItemIndex !== -1) && (this.FDownItemIndex === this.FSelectedItemIndex)) {
          this.FIsMouseDown = false;
          this.FDragItemIndex = this.FDownItemIndex;
          this.FDragItem.$assign(this.GetDisplayItem(this.FDragItemIndex));
          this.FDownRect.$assign(this.FDragItem.Rect);
          this.FDragRect.$assign(this.FDownRect);
          this.FDownItemIndex = -1;
          this.FHoveredItemIndex = -1;
          this.InvalidateItems();
        };
      };
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.HandleMouseMove.apply(this,arguments);
      if ((this.FDownItemIndex > -1) || this.FHeaderArrowLeftDown || this.FHeaderArrowRightDown || this.FFooterArrowLeftDown || this.FFooterArrowRightDown) return;
      ind = -1;
      it.$assign(this.XYToDisplayItem(X,Y));
      if (it.Item != null) ind = it.Item.GetIndex();
      if (ind !== this.FPrevHoverIndex) {
        this.FPrevHoverIndex = ind;
      };
      if (ind !== this.FHoveredItemIndex) {
        if (this.FHoveredItemIndex === -1) {
          this.GetVisualizer($mod.TTMSFNCTileListDisplayItem.$clone(it)).DoMouseEnterTile($mod.TTMSFNCTileListDisplayItem.$clone(it))}
         else {
          if (ind === -1) {
            hdi.$assign(this.GetDisplayItem(this.FHoveredItemIndex));
            if (hdi.Item != null) this.GetVisualizer($mod.TTMSFNCTileListDisplayItem.$clone(hdi)).DoMouseLeaveTile($mod.TTMSFNCTileListDisplayItem.$clone(hdi));
          };
        };
        this.FHoveredItemIndex = ind;
        this.CancelHint();
      };
      if (this.IsDraggingAllowed() && (this.FDragItemIndex !== -1) && (this.FDownX$1 !== -1) && (this.FDownY$1 !== -1)) {
        if ((Math.abs(X - this.FMoveX) > 2) || (Math.abs(Y - this.FMoveY) > 2)) {
          this.StopDragTimer();
          this.FMoveX = X;
          this.FMoveY = Y;
          this.FDragItem.$assign(this.GetDisplayItem(this.FDragItemIndex));
          this.FDragRect.$assign(this.FDownRect);
          pas["WEBLib.TMSFNCTypes"].OffsetRectEx$1(this.FDragRect,X - this.FDownX$1,Y - this.FDownY$1);
          if (this.FDragControl != null) {
            this.FDragControl.SetLeft(Math.round(this.FDragRect.Left));
            this.FDragControl.SetTop(Math.round(this.FDragRect.Top));
            this.UpdateTileControls();
          };
          this.FDragRect.Right = this.FDragRect.Left + (this.FDragItem.Rect.Right - this.FDragItem.Rect.Left);
          this.FDragRect.Bottom = this.FDragRect.Top + (this.FDragItem.Rect.Bottom - this.FDragItem.Rect.Top);
        };
        this.EnableDragTimer();
        this.InvalidateItems();
        return;
      };
      this.FHeaderArrowLeftHover = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(true,true),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && this.FHeader.FArrowLeft.FVisible;
      this.FHeaderArrowRightHover = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(true,false),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && this.FHeader.FArrowRight.FVisible;
      this.FFooterArrowLeftHover = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(false,true),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && this.FFooter.FArrowLeft.FVisible;
      this.FFooterArrowRightHover = pas["WEBLib.TMSFNCTypes"].PtInRectEx(this.GetArrowRect(false,false),pas["WEBLib.TMSFNCTypes"].PointF(X,Y)) && this.FFooter.FArrowRight.FVisible;
      if (this.FHeaderArrowLeftHover || this.FHeaderArrowRightHover || this.FFooterArrowLeftHover || this.FFooterArrowRightHover) {
        this.SetControlCursor(21);
        if (!this.IsPageAnimating() && !this.IsTileAnimating() && !this.FAnimating) this.InvalidateItems();
      } else if (this.IsBulletRect(X,Y,{get: function () {
          return i;
        }, set: function (v) {
          i = v;
        }})) {
        this.SetControlCursor(21);
      } else {
        if (it.Item != null) {
          this.GetVisualizer($mod.TTMSFNCTileListDisplayItem.$clone(it)).DoMouseMove($mod.TTMSFNCTileListDisplayItem.$clone(it),rtl.refSet(Shift),X,Y);
        } else {
          if (this.FCursor !== 0) this.SetControlCursor(0);
        };
        if (!this.IsPageAnimating() && !this.IsTileAnimating() && !this.FAnimating) this.InvalidateItems();
      };
    };
    this.HandleKeyDown = function (Key, Shift) {
      var temp = 0;
      var fi = 0;
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleKeyDown.apply(this,arguments);
      if (Key.get() in rtl.createSet(38,40,37,39,36,35,33,34)) {
        var $tmp = Key.get();
        if ($tmp === 38) {
          this.FFocusedItemIndex = this.GetPreviousSelectableRowItem()}
         else if ($tmp === 37) {
          temp = this.GetFirstSelectableItem();
          fi = this.GetPreviousSelectableItem();
          if (temp === this.FFocusedItemIndex) {
            if (this.FPageIndex !== 0) {
              this.FFocusedItemIndex = fi - 1;
              this.PreviousPage();
            };
          } else this.FFocusedItemIndex = fi;
        } else if ($tmp === 40) {
          this.FFocusedItemIndex = this.GetNextSelectableRowItem()}
         else if ($tmp === 39) {
          temp = this.GetLastSelectableItem();
          fi = this.GetNextSelectableItem();
          if (temp === this.FFocusedItemIndex) {
            if (this.FPageCount !== (this.FPageIndex + 1)) {
              this.FFocusedItemIndex = fi + 1;
              this.NextPage();
            };
          } else this.FFocusedItemIndex = fi;
        } else if ($tmp === 36) {
          this.FFocusedItemIndex = this.GetFirstSelectableItem()}
         else if ($tmp === 35) {
          this.FFocusedItemIndex = this.GetLastSelectableItem()}
         else if ($tmp === 33) {
          this.PreviousPage()}
         else if ($tmp === 34) this.NextPage();
        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,pas.Classes.TShiftState$a.ssCtrl in Shift,pas.Classes.TShiftState$a.ssShift in Shift);
        this.InvalidateItems();
      };
    };
    this.HandleMouseLeave = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleMouseLeave.call(this);
      this.FHoveredItemIndex = -1;
      this.FHeaderArrowLeftHover = false;
      this.FHeaderArrowRightHover = false;
      this.FFooterArrowLeftHover = false;
      this.FFooterArrowRightHover = false;
      this.InvalidateItems();
    };
    this.HandleDblClick = function (X, Y) {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControlBaseCommon.HandleDblClick.apply(this,arguments);
      this.FDblClickDown = true;
    };
    this.GetDocURL = function () {
      var Result = "";
      Result = pas["WEBLib.TMSFNCTypes"].TTMSFNCBaseDocURL + "tmsfncuipack/components/" + pas.SysUtils.LowerCase(this.$classname);
      return Result;
    };
    this.ProcessSelection = function (AItemIndex, ACtrl, AShift) {
      var it = null;
      var prev = 0;
      var curr = 0;
      if ((AItemIndex >= 0) && (AItemIndex <= (this.FItems.GetCount() - 1))) {
        it = this.FItems.GetItem$1(AItemIndex);
        prev = this.FSelectedItemIndex;
        curr = it.GetIndex();
        if (it.FCanDeselect) {
          if (this.FMultiSelect && ACtrl && it.FSelected) {
            this.FSelectedItemIndex = -1;
            it.SetSelected(false);
            this.DoItemDeselected(AItemIndex);
            return;
          } else if ((prev !== -1) && (prev !== curr) && ((this.FMultiSelect && !ACtrl) || !this.FMultiSelect)) {
            if (this.FItems.GetItem$1(prev).FCanDeselect && (prev >= 0) && (prev <= (this.FItems.GetCount() - 1))) {
              this.DeselectAllItems();
            };
          };
        };
        if (it.FCanSelect) {
          if (this.FMultiSelect && AShift) {
            this.SelectItemsBetween(this.FSelectedItemIndex,it.GetIndex())}
           else {
            this.FSelectedItemIndex = it.GetIndex();
            it.SetSelected(true);
            this.DoItemSelected(this.FSelectedItemIndex);
          };
        };
      };
    };
    this.Create$1 = function (AOwner) {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.Create$1.apply(this,arguments);
      this.FTouchScrolling = true;
      this.FPrevHoverIndex = -1;
      this.FColumns = 3;
      this.FPageIndex = 0;
      this.FRows = 3;
      this.FItems = this.CreateItemsCollection();
      this.FItems.FOnChanged = rtl.createCallback(this,"ItemsChanged");
      this.FDisplayList = $mod.TTMSFNCTileListDisplayList.$create("Create$1");
      this.FRecalcList = $mod.TTMSFNCTileListRecalcList.$create("Create$1");
      this.FAppearance = $mod.TTMSFNCTileListAppearance.$create("Create$1",[this]);
      this.FDblClickDown = false;
      this.FDragItemIndex = -1;
      this.FDragItemPage = -1;
      this.FSelectedItemIndex = -1;
      this.FFocusedItemIndex = -1;
      this.FHoveredItemIndex = -1;
      this.FDownItemIndex = -1;
      this.FPageDownIndex = -1;
      this.FOrientation = $mod.TTMSFNCTileListOrientation.tloHorizontal;
      this.FNavigationMode = $mod.TTMSFNCTileListNavigationMode.tlnmPage;
      this.FMultiSelect = false;
      this.FPageWidth = 0;
      this.FPageHeight = 0;
      this.FHoldCounter = 0;
      this.FReorderMode = $mod.TTMSFNCTileListReorderMode.rmNone;
      this.FFiltering = $mod.TTMSFNCTileListFiltering.tlfAny;
      this.FPageAnimationTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FPageAnimationTimer.SetEnabled(false);
      this.FPageAnimationTimer.SetInterval(1);
      this.FPageAnimationTimer.FOnTimer = rtl.createCallback(this,"DoPageAnimationTimer");
      this.FTileAnimationTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FTileAnimationTimer.SetEnabled(false);
      this.FTileAnimationTimer.SetInterval(1);
      this.FTileAnimationTimer.FOnTimer = rtl.createCallback(this,"DoTileAnimationTimer");
      this.FDragTimer = pas["WEBLib.ExtCtrls"].TTimer.$create("Create$1",[this]);
      this.FDragTimer.SetEnabled(false);
      this.FDragTimer.SetInterval(50);
      this.FDragTimer.FOnTimer = rtl.createCallback(this,"DoDragTimer");
      this.SetHorizontalScrollBarVisible(false);
      this.SetVerticalScrollBarVisible(false);
      this.FHeader = $mod.TTMSFNCTileListHeader.$create("Create$1");
      this.FHeader.FOnChanged = rtl.createCallback(this,"HeaderChanged");
      this.FFooter = $mod.TTMSFNCTileListFooter.$create("Create$1");
      this.FFooter.FOnChanged = rtl.createCallback(this,"FooterChanged");
      this.FHeaderArrowLeftHover = false;
      this.FHeaderArrowRightHover = false;
      this.FFooterArrowLeftHover = false;
      this.FFooterArrowRightHover = false;
      this.FHeaderArrowLeftDown = false;
      this.FHeaderArrowRightDown = false;
      this.FFooterArrowLeftDown = false;
      this.FFooterArrowRightDown = false;
      this.FDefaultVisualizer = $mod.TTMSFNCTileListVisualizer.$create("Create$1",[this]);
      this.SetWidth(400);
      this.SetHeight(400);
      if ((pas.Classes.TComponentStateItem.csDesigning in this.FComponentState) && !((pas.Classes.TComponentStateItem.csReading in this.FOwner.FComponentState) || (pas.Classes.TComponentStateItem.csLoading in this.FOwner.FComponentState))) this.InitSample();
      return this;
    };
    this.Destroy = function () {
      rtl.free(this,"FAppearance");
      rtl.free(this,"FDisplayList");
      rtl.free(this,"FRecalcList");
      rtl.free(this,"FPageAnimationTimer");
      rtl.free(this,"FTileAnimationTimer");
      rtl.free(this,"FDragTimer");
      rtl.free(this,"FHeader");
      rtl.free(this,"FFooter");
      rtl.free(this,"FDefaultVisualizer");
      rtl.free(this,"FItems");
      this.FItems = null;
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.Destroy.call(this);
    };
    this.Assign = function (Source) {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.Assign.apply(this,arguments);
      if ($mod.TTMSFNCTileList.isPrototypeOf(Source)) {
        this.FItems.Assign(rtl.as(Source,$mod.TTMSFNCTileList).FItems);
        this.FAppearance.Assign(rtl.as(Source,$mod.TTMSFNCTileList).FAppearance);
        this.FRows = rtl.as(Source,$mod.TTMSFNCTileList).FRows;
        this.FColumns = rtl.as(Source,$mod.TTMSFNCTileList).FColumns;
      };
    };
    this.BeginUpdate = function () {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.BeginUpdate.call(this);
      this.FUpdateCount$2 += 1;
    };
    this.EndUpdate = function () {
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.EndUpdate.call(this);
      this.FUpdateCount$2 -= 1;
      if (this.FUpdateCount$2 === 0) this.CalculateItems(true);
    };
    this.InitSample = function () {
      var itm = null;
      this.BeginUpdate();
      itm = this.FItems.Add$1();
      itm.SetTitle("Title A");
      itm.SetDescription("Some default description");
      itm = this.FItems.Add$1();
      itm.SetTitle("Title B");
      itm.SetDescription('<p align="center">Each title and description <b>supports</b> <u>HTML</u> <i>formatting</i></p>');
      itm = this.FItems.Add$1();
      itm.SetTitle("Title C");
      itm.SetDescription('<p align="center"><a href="https://tmssoftware.com">Anchors</a> are also supported</p>');
      itm = this.FItems.Add$1();
      itm.SetTitle("Title D");
      itm.SetColumnSpan(2);
      itm.SetRowSpan(2);
      itm.SetDescription("Row and column span can be set per tile");
      itm = this.FItems.Add$1();
      itm.SetTitle("Title E");
      itm.SetRowSpan(2);
      itm.SetBadge("123");
      itm.SetDescription("Tiles can have badges with a custom text");
      this.ResetToDefaultStyle();
      this.EndUpdate();
    };
    this.ApplyFilter = function (AFilter) {
      var a = false;
      a = true;
      if (AFilter !== "") {
        if (this.FOnFilter != null) this.FOnFilter(this,{get: function () {
            return AFilter;
          }, set: function (v) {
            AFilter = v;
          }},{get: function () {
            return a;
          }, set: function (v) {
            a = v;
          }});
      };
      if (a) {
        this.FFilter = AFilter;
        this.DeselectAllItems();
        this.CalculateItems(true);
      };
    };
    this.ClearFilter = function () {
      this.ApplyFilter("");
    };
    this.UpdateControlAfterResize = function () {
      if (!(pas.Classes.TComponentStateItem.csDesigning in this.FComponentState)) this.AdjustScrollPosition();
      pas["WEBLib.TMSFNCCustomScrollControl"].TTMSFNCCustomScrollControl.UpdateControlAfterResize.call(this);
      this.CalculateItems(true);
    };
    this.DeselectAllItems = function () {
      var I = 0;
      this.BeginUpdate();
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FItems.GetItem$1(I).FSelected && this.FItems.GetItem$1(I).FCanDeselect) {
          this.FItems.GetItem$1(I).SetSelected(false);
          this.DoItemDeselected(I);
        };
      };
      this.EndUpdate();
    };
    this.SelectItemsBetween = function (AFromIndex, AToIndex) {
      var minI = 0;
      var maxI = 0;
      var I = 0;
      if (!this.FMultiSelect) return;
      minI = Math.min(AFromIndex,AToIndex);
      maxI = Math.max(AFromIndex,AToIndex);
      this.BeginUpdate();
      for (var $l = minI, $end = maxI; $l <= $end; $l++) {
        I = $l;
        if ((I >= 0) && (I <= (this.FItems.GetCount() - 1))) {
          if (this.FItems.GetItem$1(I).FCanSelect) {
            this.FItems.GetItem$1(I).SetSelected(true);
            this.DoItemSelected(I);
          };
        };
      };
      this.EndUpdate();
    };
    this.SelectAllItems = function () {
      var I = 0;
      if (!this.FMultiSelect) return;
      this.BeginUpdate();
      for (var $l = 0, $end = this.FItems.GetCount() - 1; $l <= $end; $l++) {
        I = $l;
        if (this.FItems.GetItem$1(I).FCanSelect) {
          this.FItems.GetItem$1(I).SetSelected(true);
          this.DoItemSelected(I);
        };
      };
      this.EndUpdate();
    };
    this.SelectItem = function (AIndex) {
      var I = 0;
      this.BeginUpdate();
      if ((this.FItems.GetCount() > 0) && (AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        if (!this.FMultiSelect && (this.FSelectedItemIndex !== -1)) {
          if (this.FItems.GetItem$1(this.FSelectedItemIndex).FCanDeselect) {
            I = this.FSelectedItemIndex;
            this.FItems.GetItem$1(this.FSelectedItemIndex).SetSelected(false);
            this.DoItemDeselected(I);
          };
        };
        if (this.FItems.GetItem$1(AIndex).FCanSelect) {
          this.FItems.GetItem$1(AIndex).SetSelected(true);
          this.DoItemSelected(AIndex);
        };
      };
      this.EndUpdate();
    };
    this.SelectItems = function (AIndexes) {
      var I = 0;
      this.BeginUpdate();
      if (this.FMultiSelect && (this.FItems.GetCount() > 0)) {
        for (var $l = 0, $end = rtl.length(AIndexes) - 1; $l <= $end; $l++) {
          I = $l;
          if ((AIndexes[I] >= 0) && (AIndexes[I] < this.FItems.GetCount())) {
            if (this.FItems.GetItem$1(AIndexes[I]).FCanSelect) {
              this.FItems.GetItem$1(AIndexes[I]).SetSelected(true);
              this.DoItemSelected(I);
            };
          };
        };
      };
      this.EndUpdate();
    };
    this.DeselectItem = function (AIndex) {
      if ((AIndex >= 0) && (AIndex < this.FItems.GetCount())) {
        if (this.FItems.GetItem$1(AIndex).FSelected && this.FItems.GetItem$1(AIndex).FCanDeselect) {
          this.FItems.GetItem$1(AIndex).SetSelected(false);
          this.DoItemDeselected(AIndex);
        };
      };
    };
    this.XYToItem = function (X, Y) {
      var Result = null;
      Result = this.XYToDisplayItem(X,Y).Item;
      return Result;
    };
    this.XYToItemIndex = 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.FEmpty) {
            Result = it.GetIndex();
            break;
          };
        };
      };
      return Result;
    };
    this.NextPage = function () {
      this.GoToPage(this.FPageIndex + 1);
    };
    this.PreviousPage = function () {
      this.GoToPage(this.FPageIndex - 1);
    };
    this.FirstPage = function () {
      this.GoToPage(0);
    };
    this.LastPage = function () {
      this.GoToPage(this.FPageCount - 1);
    };
    this.GoToPage = function (APageIndex) {
      if ((APageIndex >= 0) && (APageIndex < this.FPageCount)) this.SetPageIndex(APageIndex);
    };
    this.FindTileIndexBy = function (ARow, AColumn) {
      var Result = 0;
      var di = $mod.TTMSFNCTileListDisplayItem.$new();
      var i = 0;
      Result = -1;
      for (var $l = 0, $end = this.FDisplayList.GetCount() - 1; $l <= $end; $l++) {
        i = $l;
        di.$assign(this.FDisplayList.GetItem(i));
        if ((di.Row === ARow) && (di.Column === AColumn)) {
          if (di.Item != null) Result = di.Item.GetIndex();
          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);
    var $r = this.$rtti;
    $r.addMethod("Create$1",2,[["AOwner",pas.Classes.$rtti["TComponent"]]]);
  });
  rtl.createClass(this,"TTMSFNCTileList",this.TTMSFNCCustomTileList,function () {
    this.RegisterRuntimeClasses = function () {
      pas["WEBLib.TMSFNCCustomControl"].TTMSFNCCustomControl.RegisterRuntimeClasses.call(this);
      pas.Classes.RegisterClass($mod.TTMSFNCTileList);
      pas.Classes.RegisterClass($mod.TTMSFNCTileListItem);
    };
    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("MultiSelect",2,rtl.boolean,"FMultiSelect","SetMultiSelect",{Default: false});
    $r.addProperty("Items",2,$mod.$rtti["TTMSFNCTileListItems"],"FItems","SetItems");
    $r.addProperty("Rows",2,rtl.longint,"FRows","SetRows");
    $r.addProperty("Appearance",2,$mod.$rtti["TTMSFNCTileListAppearance"],"FAppearance","SetAppearance");
    $r.addProperty("PageIndex",2,rtl.longint,"FPageIndex","SetPageIndex",{Default: 0});
    $r.addProperty("Columns",2,rtl.longint,"FColumns","SetColumns");
    $r.addProperty("NavigationMode",2,$mod.$rtti["TTMSFNCTileListNavigationMode"],"FNavigationMode","SetNavigationMode",{Default: $mod.TTMSFNCTileListNavigationMode.tlnmPage});
    $r.addProperty("Orientation",2,$mod.$rtti["TTMSFNCTileListOrientation"],"FOrientation","SetOrientation",{Default: $mod.TTMSFNCTileListOrientation.tloHorizontal});
    $r.addProperty("ReorderMode",2,$mod.$rtti["TTMSFNCTileListReorderMode"],"FReorderMode","SetReorderMode",{Default: $mod.TTMSFNCTileListReorderMode.rmNone});
    $r.addProperty("Header",2,$mod.$rtti["TTMSFNCTileListHeader"],"FHeader","SetHeader");
    $r.addProperty("Footer",2,$mod.$rtti["TTMSFNCTileListFooter"],"FFooter","SetFooter");
    $r.addProperty("Filtering",2,$mod.$rtti["TTMSFNCTileListFiltering"],"FFiltering","SetFiltering",{Default: $mod.TTMSFNCTileListFiltering.tlfAny});
    $r.addProperty("Visualizer",0,$mod.$rtti["TTMSFNCTileListVisualizer"],"FVisualizer","FVisualizer");
    $r.addProperty("Fill",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsFill"],"FFill","SetFill");
    $r.addProperty("Stroke",2,pas["WEBLib.TMSFNCGraphicsTypes"].$rtti["TTMSFNCGraphicsStroke"],"FStroke","SetStroke");
    $r.addProperty("OnItemSelected",0,$mod.$rtti["TTMSFNCTileListItemSelectedEvent"],"FOnItemSelected","FOnItemSelected");
    $r.addProperty("OnItemDeselected",0,$mod.$rtti["TTMSFNCTileListItemDeselectedEvent"],"FOnItemDeselected","FOnItemDeselected");
    $r.addProperty("OnItemClick",0,$mod.$rtti["TTMSFNCTileListItemClickEvent"],"FOnItemClick","FOnItemClick");
    $r.addProperty("OnBeforeDrawBadge",0,$mod.$rtti["TTMSFNCTileListBeforeDrawBadgeEvent"],"FOnBeforeDrawBadge","FOnBeforeDrawBadge");
    $r.addProperty("OnAfterDrawBadge",0,$mod.$rtti["TTMSFNCTileListAfterDrawBadgeEvent"],"FOnAfterDrawBadge","FOnAfterDrawBadge");
    $r.addProperty("OnBeforeDrawBullet",0,$mod.$rtti["TTMSFNCTileListBeforeDrawBulletEvent"],"FOnBeforeDrawBullet","FOnBeforeDrawBullet");
    $r.addProperty("OnAfterDrawBullet",0,$mod.$rtti["TTMSFNCTileListAfterDrawBulletEvent"],"FOnAfterDrawBullet","FOnAfterDrawBullet");
    $r.addProperty("OnBeforeDrawArrow",0,$mod.$rtti["TTMSFNCTileListBeforeDrawArrowEvent"],"FOnBeforeDrawArrow","FOnBeforeDrawArrow");
    $r.addProperty("OnAfterDrawArrow",0,$mod.$rtti["TTMSFNCTileListAfterDrawArrowEvent"],"FOnAfterDrawArrow","FOnAfterDrawArrow");
    $r.addProperty("OnBeforeDrawHeader",0,$mod.$rtti["TTMSFNCTileListBeforeDrawEvent"],"FOnBeforeDrawHeader","FOnBeforeDrawHeader");
    $r.addProperty("OnBeforeDrawFooter",0,$mod.$rtti["TTMSFNCTileListBeforeDrawEvent"],"FOnBeforeDrawFooter","FOnBeforeDrawFooter");
    $r.addProperty("OnAfterDrawHeader",0,$mod.$rtti["TTMSFNCTileListAfterDrawEvent"],"FOnAfterDrawHeader","FOnAfterDrawHeader");
    $r.addProperty("OnAfterDrawFooter",0,$mod.$rtti["TTMSFNCTileListAfterDrawEvent"],"FOnAfterDrawFooter","FOnAfterDrawFooter");
    $r.addProperty("OnBeforeDrawItemBackground",0,$mod.$rtti["TTMSFNCTileListBeforeDrawItemBackgroundEvent"],"FOnBeforeDrawItemBackground","FOnBeforeDrawItemBackground");
    $r.addProperty("OnAfterDrawItemBackground",0,$mod.$rtti["TTMSFNCTileListAfterDrawItemBackgroundEvent"],"FOnAfterDrawItemBackground","FOnAfterDrawItemBackground");
    $r.addProperty("OnBeforeDrawItemContent",0,$mod.$rtti["TTMSFNCTileListBeforeDrawItemContentEvent"],"FOnBeforeDrawItemContent","FOnBeforeDrawItemContent");
    $r.addProperty("OnAfterDrawItemContent",0,$mod.$rtti["TTMSFNCTileListAfterDrawItemContentEvent"],"FOnAfterDrawItemContent","FOnAfterDrawItemContent");
    $r.addProperty("OnBeforeDrawItemTitle",0,$mod.$rtti["TTMSFNCTileListBeforeDrawItemContentEvent"],"FOnBeforeDrawItemTitle","FOnBeforeDrawItemTitle");
    $r.addProperty("OnAfterDrawItemTitle",0,$mod.$rtti["TTMSFNCTileListAfterDrawItemContentEvent"],"FOnAfterDrawItemTitle","FOnAfterDrawItemTitle");
    $r.addProperty("OnBeforeDrawItemDescription",0,$mod.$rtti["TTMSFNCTileListBeforeDrawItemContentEvent"],"FOnBeforeDrawItemDescription","FOnBeforeDrawItemDescription");
    $r.addProperty("OnAfterDrawItemDescription",0,$mod.$rtti["TTMSFNCTileListAfterDrawItemContentEvent"],"FOnAfterDrawItemDescription","FOnAfterDrawItemDescription");
    $r.addProperty("OnBeforeDrawItemImage",0,$mod.$rtti["TTMSFNCTileListBeforeDrawItemContentEvent"],"FOnBeforeDrawItemImage","FOnBeforeDrawItemImage");
    $r.addProperty("OnAfterDrawItemImage",0,$mod.$rtti["TTMSFNCTileListAfterDrawItemContentEvent"],"FOnAfterDrawItemImage","FOnAfterDrawItemImage");
    $r.addProperty("OnBeforeDrawItemControl",0,$mod.$rtti["TTMSFNCTileListBeforeDrawItemContentEvent"],"FOnBeforeDrawItemControl","FOnBeforeDrawItemControl");
    $r.addProperty("OnAfterDrawItemControl",0,$mod.$rtti["TTMSFNCTileListAfterDrawItemContentEvent"],"FOnAfterDrawItemControl","FOnAfterDrawItemControl");
    $r.addProperty("OnBeforeDraw",0,$mod.$rtti["TTMSFNCTileListBeforeDrawEvent"],"FOnBeforeDraw$1","FOnBeforeDraw$1");
    $r.addProperty("OnAfterDraw",0,$mod.$rtti["TTMSFNCTileListAfterDrawEvent"],"FOnAfterDraw$1","FOnAfterDraw$1");
    $r.addProperty("OnBulletClick",0,$mod.$rtti["TTMSFNCTileListBulletClickEvent"],"FOnBulletClick","FOnBulletClick");
    $r.addProperty("OnPreviousPageClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnPreviousPageClick","FOnPreviousPageClick");
    $r.addProperty("OnNextPageClick",0,pas["WEBLib.Controls"].$rtti["TNotifyEvent"],"FOnNextPageClick","FOnNextPageClick");
    $r.addProperty("OnFilter",0,$mod.$rtti["TTMSFNCTileListItemFilterEvent"],"FOnFilter","FOnFilter");
    $r.addProperty("OnItemAnchorClick",0,$mod.$rtti["TTMSFNCTileListItemAnchorClickEvent"],"FOnItemAnchorClick","FOnItemAnchorClick");
    $r.addProperty("OnItemDoubleClick",0,$mod.$rtti["TTMSFNCTileListItemClickEvent"],"FOnItemDoubleClick","FOnItemDoubleClick");
    $r.attr = [pas.Classes.ComponentPlatformsAttribute,"Create$1",[0]];
  });
  $mod.$implcode = function () {
    $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.CalculateOverlap = function (ARect1, ARect2) {
      var Result = 0.0;
      var Left = 0.0;
      var Right = 0.0;
      var Top = 0.0;
      var Bottom = 0.0;
      Left = Math.max(ARect1.Left,ARect2.Left);
      Right = Math.min(ARect1.Left + (ARect1.Right - ARect1.Left),ARect2.Left + (ARect2.Right - ARect2.Left));
      Top = Math.max(ARect1.Top,ARect2.Top);
      Bottom = Math.min(ARect1.Top + (ARect1.Bottom - ARect1.Top),ARect2.Top + (ARect2.Bottom - ARect2.Top));
      Result = Math.max(0,Right - Left) * Math.max(0,Bottom - Top);
      return Result;
    };
    $impl.ContainsIndex = function (AArray, AItem) {
      var Result = false;
      var i = 0;
      Result = false;
      for (var $l = 0, $end = rtl.length(AArray) - 1; $l <= $end; $l++) {
        i = $l;
        if (AArray[i] === AItem) {
          Result = true;
          return Result;
        };
      };
      return Result;
    };
    $impl.CoversAtLeastPercent = function (ARect1, ARect2, APercent) {
      var Result = false;
      var overlapArea = 0.0;
      var smallerRectArea = 0.0;
      overlapArea = $impl.CalculateOverlap(ARect1,ARect2);
      smallerRectArea = Math.min((ARect1.Right - ARect1.Left) * (ARect1.Bottom - ARect1.Top),(ARect2.Right - ARect2.Left) * (ARect2.Bottom - ARect2.Top));
      Result = overlapArea >= (APercent * smallerRectArea);
      return Result;
    };
    $impl.RearrangeCollectionItems = function (ACollection, ANewOrder, AStartIndex, AEndIndex) {
      var I = 0;
      var oldIndex = 0;
      var tempList = null;
      tempList = $mod.TTMSFNCTileListCollectionItems.$create("Create$1");
      try {
        for (var $l = 0, $end = rtl.length(ANewOrder) - 1; $l <= $end; $l++) {
          I = $l;
          oldIndex = ANewOrder[I];
          if ((oldIndex >= AStartIndex) && (oldIndex <= AEndIndex)) {
            tempList.Add(ACollection.GetItem(oldIndex));
          };
        };
        for (var $l1 = 0, $end1 = tempList.GetCount() - 1; $l1 <= $end1; $l1++) {
          I = $l1;
          tempList.GetItem(I).SetIndex(AStartIndex + I);
          tempList.GetItem(I).SetCollection(ACollection);
        };
      } finally {
        tempList = rtl.freeLoc(tempList);
      };
    };
    $impl.InitMatrixWithDefaultValues = function (AMatrix, ARows, AColumns, ADefaultValue) {
      var I = 0;
      var J = 0;
      AMatrix.set(rtl.arraySetLength(AMatrix.get(),0,ARows,AColumns));
      for (var $l = 0, $end = ARows - 1; $l <= $end; $l++) {
        I = $l;
        for (var $l1 = 0, $end1 = AColumns - 1; $l1 <= $end1; $l1++) {
          J = $l1;
          AMatrix.get()[I][J] = ADefaultValue;
        };
      };
    };
    $impl.InitArrayWithDefaultValues = function (AArray, ALength, ADefaultValue) {
      var I = 0;
      AArray.set(rtl.arraySetLength(AArray.get(),0,ALength));
      for (var $l = 0, $end = ALength - 1; $l <= $end; $l++) {
        I = $l;
        AArray.get()[I] = ADefaultValue;
      };
    };
  };
},["SysUtils","WEBLib.Graphics","Math","StrUtils","WEBLib.Forms","WEBLib.TMSFNCUtils","WEBLib.TMSFNCStyles"]);
rtl.module("Unit1",["System","SysUtils","Classes","JS","Web","WEBLib.Graphics","WEBLib.Controls","WEBLib.Forms","WEBLib.Dialogs","WEBLib.TMSFNCTypes","WEBLib.TMSFNCUtils","WEBLib.TMSFNCGraphics","WEBLib.TMSFNCGraphicsTypes","WEBLib.Controls","WEBLib.TMSFNCCustomControl","WEBLib.TMSFNCCustomScrollControl","WEBLib.TMSFNCTileList"],function () {
  "use strict";
  var $mod = this;
  rtl.createClass(this,"TForm1",pas["WEBLib.Forms"].TForm,function () {
    this.$init = function () {
      pas["WEBLib.Forms"].TForm.$init.call(this);
      this.TMSFNCTileList1 = null;
    };
    this.$final = function () {
      this.TMSFNCTileList1 = undefined;
      pas["WEBLib.Forms"].TForm.$final.call(this);
    };
    this.LoadDFMValues = function () {
      pas["WEBLib.Forms"].TCustomForm.LoadDFMValues.call(this);
      this.TMSFNCTileList1 = pas["WEBLib.TMSFNCTileList"].TTMSFNCTileList.$create("Create$1",[this]);
      this.TMSFNCTileList1.BeforeLoadDFMValues();
      try {
        this.SetName("Form1");
        this.SetWidth(640);
        this.SetHeight(480);
        this.TMSFNCTileList1.SetParentComponent(this);
        this.TMSFNCTileList1.SetName("TMSFNCTileList1");
        this.TMSFNCTileList1.SetLeft(120);
        this.TMSFNCTileList1.SetTop(40);
        this.TMSFNCTileList1.SetWidth(400);
        this.TMSFNCTileList1.SetHeight(400);
        this.TMSFNCTileList1.FParentDoubleBuffered = false;
        this.TMSFNCTileList1.FDoubleBuffered = true;
        this.TMSFNCTileList1.FParentShowHint = false;
        this.TMSFNCTileList1.SetShowHint(true);
        this.TMSFNCTileList1.SetTabOrder(0);
        this.TMSFNCTileList1.FItems.Clear();
        var $with = this.TMSFNCTileList1.FItems.Add$1();
        $with.SetTitle("Title A");
        $with.SetDescription("Some default description");
        $with.FHint = "Title A";
        var $with1 = this.TMSFNCTileList1.FItems.Add$1();
        $with1.SetTitle("Title B");
        $with1.SetDescription('<p align="center">Each title and description <b>supports</b> <u>HTML</u> <i>formatting</i></p>');
        $with1.FHint = "Title B";
        var $with2 = this.TMSFNCTileList1.FItems.Add$1();
        $with2.SetTitle("Title C");
        $with2.SetDescription('<p align="center"><a href="https://tmssoftware.com">Anchors</a> are also supported</p>');
        $with2.FHint = "Title C";
        var $with3 = this.TMSFNCTileList1.FItems.Add$1();
        $with3.SetTitle("Title D");
        $with3.SetDescription("Row and column span can be set per tile");
        $with3.SetColumnSpan(2);
        $with3.SetRowSpan(2);
        $with3.FHint = "Title D";
        var $with4 = this.TMSFNCTileList1.FItems.Add$1();
        $with4.SetTitle("Title E");
        $with4.SetDescription("Tiles can have badges with a custom text");
        $with4.SetBadge("123");
        $with4.SetRowSpan(2);
        $with4.FHint = "Title E";
        this.TMSFNCTileList1.SetRows(3);
        this.TMSFNCTileList1.FAppearance.FBadgeFill.SetColor(255);
        this.TMSFNCTileList1.FAppearance.FBadgeStroke.SetColor(255);
        this.TMSFNCTileList1.FAppearance.FBadgeStroke.SetWidth(2.000000000000000000);
        this.TMSFNCTileList1.FAppearance.FBadgeFont.FCharset = 1;
        this.TMSFNCTileList1.FAppearance.FBadgeFont.SetColor(16777215);
        this.TMSFNCTileList1.FAppearance.FBadgeFont.SetHeight(-12);
        this.TMSFNCTileList1.FAppearance.FBadgeFont.SetName("Tahoma");
        this.TMSFNCTileList1.FAppearance.FBadgeFont.SetStyle(rtl.createSet(pas["WEBLib.Graphics"].TFontStyle.fsBold));
        this.TMSFNCTileList1.FAppearance.FStroke.SetColor(11119017);
        this.TMSFNCTileList1.FAppearance.FFill.SetColor(16578806);
        this.TMSFNCTileList1.FAppearance.FStrokeHover.SetColor(10061943);
        this.TMSFNCTileList1.FAppearance.FFillHover.SetColor(16441019);
        this.TMSFNCTileList1.FAppearance.FStrokeDown.SetColor(9470064);
        this.TMSFNCTileList1.FAppearance.FFillDown.SetColor(16039284);
        this.TMSFNCTileList1.FAppearance.FStrokeSelected.SetColor(5197615);
        this.TMSFNCTileList1.FAppearance.FFillSelected.SetColor(16039284);
        this.TMSFNCTileList1.FAppearance.FStrokeDisabled.SetColor(11119017);
        this.TMSFNCTileList1.FAppearance.FFillDisabled.SetColor(12632256);
        this.TMSFNCTileList1.FAppearance.FFont.FCharset = 1;
        this.TMSFNCTileList1.FAppearance.FFont.SetColor(0);
        this.TMSFNCTileList1.FAppearance.FFont.SetHeight(-12);
        this.TMSFNCTileList1.FAppearance.FFont.SetName("Tahoma");
        this.TMSFNCTileList1.FAppearance.FFont.SetStyle({});
        this.TMSFNCTileList1.FAppearance.FDescriptionFont.FCharset = 1;
        this.TMSFNCTileList1.FAppearance.FDescriptionFont.SetColor(0);
        this.TMSFNCTileList1.FAppearance.FDescriptionFont.SetHeight(-12);
        this.TMSFNCTileList1.FAppearance.FDescriptionFont.SetName("Tahoma");
        this.TMSFNCTileList1.FAppearance.FDescriptionFont.SetStyle({});
        this.TMSFNCTileList1.SetColumns(3);
        this.TMSFNCTileList1.FHeader.FFill.SetColor(16380654);
        this.TMSFNCTileList1.FHeader.FBullets.FSelectedFill.SetColor(8421504);
        this.TMSFNCTileList1.FHeader.FBullets.FSelectedStroke.SetColor(8421504);
        this.TMSFNCTileList1.FHeader.FArrowLeft.FFill.SetColor(16380654);
        this.TMSFNCTileList1.FHeader.FArrowLeft.FDownFill.SetColor(16380654);
        this.TMSFNCTileList1.FHeader.FArrowLeft.FHoverFill.SetColor(16380654);
        this.TMSFNCTileList1.FHeader.FArrowLeft.FArrowFill.SetColor(6908265);
        this.TMSFNCTileList1.FHeader.FArrowLeft.FArrowDownFill.SetColor(6908265);
        this.TMSFNCTileList1.FHeader.FArrowLeft.FArrowHoverFill.SetColor(6908265);
        this.TMSFNCTileList1.FHeader.FArrowRight.FFill.SetColor(16380654);
        this.TMSFNCTileList1.FHeader.FArrowRight.FDownFill.SetColor(16380654);
        this.TMSFNCTileList1.FHeader.FArrowRight.FHoverFill.SetColor(16380654);
        this.TMSFNCTileList1.FHeader.FArrowRight.FArrowFill.SetColor(6908265);
        this.TMSFNCTileList1.FHeader.FArrowRight.FArrowDownFill.SetColor(6908265);
        this.TMSFNCTileList1.FHeader.FArrowRight.FArrowHoverFill.SetColor(6908265);
        this.TMSFNCTileList1.FFooter.FFill.SetColor(16380654);
        this.TMSFNCTileList1.FFooter.FBullets.FSelectedFill.SetColor(8421504);
        this.TMSFNCTileList1.FFooter.FBullets.FSelectedStroke.SetColor(8421504);
        this.TMSFNCTileList1.FFooter.FArrowLeft.FFill.SetColor(16380654);
        this.TMSFNCTileList1.FFooter.FArrowLeft.FDownFill.SetColor(16380654);
        this.TMSFNCTileList1.FFooter.FArrowLeft.FHoverFill.SetColor(16380654);
        this.TMSFNCTileList1.FFooter.FArrowLeft.FArrowFill.SetColor(6908265);
        this.TMSFNCTileList1.FFooter.FArrowLeft.FArrowDownFill.SetColor(6908265);
        this.TMSFNCTileList1.FFooter.FArrowLeft.FArrowHoverFill.SetColor(6908265);
        this.TMSFNCTileList1.FFooter.FArrowRight.FFill.SetColor(16380654);
        this.TMSFNCTileList1.FFooter.FArrowRight.FDownFill.SetColor(16380654);
        this.TMSFNCTileList1.FFooter.FArrowRight.FHoverFill.SetColor(16380654);
        this.TMSFNCTileList1.FFooter.FArrowRight.FArrowFill.SetColor(6908265);
        this.TMSFNCTileList1.FFooter.FArrowRight.FArrowDownFill.SetColor(6908265);
        this.TMSFNCTileList1.FFooter.FArrowRight.FArrowHoverFill.SetColor(6908265);
      } finally {
        this.TMSFNCTileList1.AfterLoadDFMValues();
      };
    };
    rtl.addIntf(this,pas["WEBLib.Controls"].IControl);
    rtl.addIntf(this,pas.System.IUnknown);
    var $r = this.$rtti;
    $r.addField("TMSFNCTileList1",pas["WEBLib.TMSFNCTileList"].$rtti["TTMSFNCTileList"]);
  });
  this.Form1 = null;
});
rtl.module("program",["System","WEBLib.Forms","WEBLib.Forms","Unit1"],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.Unit1.TForm1,{p: pas.Unit1, get: function () {
        return this.p.Form1;
      }, set: function (v) {
        this.p.Form1 = v;
      }});
    pas["WEBLib.Forms"].Application.Run();
  };
});
//# sourceMappingURL=Project1.js.map
