// Generated by purs bundle 0.14.2
var PS = {};
(function(exports) {
  /* global XMLHttpRequest */
  /* global process */
  "use strict";

  exports._ajax = function () {
    var platformSpecific = { };
    if (typeof module !== "undefined" && module.require && !(typeof process !== "undefined" && process.versions["electron"])) {
      // We are on node.js
      platformSpecific.newXHR = function () {
        var XHR = module.require("xhr2");
        return new XHR();
      };

      platformSpecific.fixupUrl = function (url, xhr) {
        if (xhr.nodejsBaseUrl === null) {
          var urllib = module.require("url");
          var u = urllib.parse(url);
          u.protocol = u.protocol || "http:";
          u.hostname = u.hostname || "localhost";
          return urllib.format(u);
        } else {
          return url || "/";
        }
      };

      platformSpecific.getResponse = function (xhr) {
        return xhr.response;
      };
    } else {
      // We are in the browser
      platformSpecific.newXHR = function () {
        return new XMLHttpRequest();
      };

      platformSpecific.fixupUrl = function (url) {
        return url || "/";
      };

      platformSpecific.getResponse = function (xhr) {
        return xhr.response;
      };
    }

    return function (timeoutErrorMessageIdent, requestFailedMessageIdent, mkHeader, options) {
      return function (errback, callback) {
        var xhr = platformSpecific.newXHR();
        var fixedUrl = platformSpecific.fixupUrl(options.url, xhr);
        xhr.open(options.method || "GET", fixedUrl, true, options.username, options.password);
        if (options.headers) {
          try {
            // eslint-disable-next-line no-eq-null,eqeqeq
            for (var i = 0, header; (header = options.headers[i]) != null; i++) {
              xhr.setRequestHeader(header.field, header.value);
            }
          } catch (e) {
            errback(e);
          }
        }
        var onerror = function (msgIdent) {
          return function () {
            errback(new Error(msgIdent));
          };
        };
        xhr.onerror = onerror(requestFailedMessageIdent);
        xhr.ontimeout = onerror(timeoutErrorMessageIdent);
        xhr.onload = function () {
          callback({
            status: xhr.status,
            statusText: xhr.statusText,
            headers: xhr.getAllResponseHeaders().split("\r\n")
              .filter(function (header) {
                return header.length > 0;
              })
              .map(function (header) {
                var i = header.indexOf(":");
                return mkHeader(header.substring(0, i))(header.substring(i + 2));
              }),
            body: platformSpecific.getResponse(xhr)
          });
        };
        xhr.responseType = options.responseType;
        xhr.withCredentials = options.withCredentials;
        xhr.timeout = options.timeout;
        xhr.send(options.content);

        return function (error, cancelErrback, cancelCallback) {
          try {
            xhr.abort();
          } catch (e) {
            return cancelErrback(e);
          }
          return cancelCallback();
        };
      };
    };
  }();
})(PS["Affjax"] = PS["Affjax"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Alt"] = $PS["Control.Alt"] || {};
  var exports = $PS["Control.Alt"];                          
  var Alt = function (Functor0, alt) {
      this.Functor0 = Functor0;
      this.alt = alt;
  };                                                       
  var alt = function (dict) {
      return dict.alt;
  };
  exports["Alt"] = Alt;
  exports["alt"] = alt;
})(PS);
(function(exports) {
  "use strict";

  exports.arrayApply = function (fs) {
    return function (xs) {
      var l = fs.length;
      var k = xs.length;
      var result = new Array(l*k);
      var n = 0;
      for (var i = 0; i < l; i++) {
        var f = fs[i];
        for (var j = 0; j < k; j++) {
          result[n++] = f(xs[j]);
        }
      }
      return result;
    };
  };
})(PS["Control.Apply"] = PS["Control.Apply"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Semigroupoid"] = $PS["Control.Semigroupoid"] || {};
  var exports = $PS["Control.Semigroupoid"];
  var Semigroupoid = function (compose) {
      this.compose = compose;
  };
  var semigroupoidFn = new Semigroupoid(function (f) {
      return function (g) {
          return function (x) {
              return f(g(x));
          };
      };
  });
  var compose = function (dict) {
      return dict.compose;
  };
  var composeFlipped = function (dictSemigroupoid) {
      return function (f) {
          return function (g) {
              return compose(dictSemigroupoid)(g)(f);
          };
      };
  };
  exports["compose"] = compose;
  exports["composeFlipped"] = composeFlipped;
  exports["semigroupoidFn"] = semigroupoidFn;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Category"] = $PS["Control.Category"] || {};
  var exports = $PS["Control.Category"];
  var Control_Semigroupoid = $PS["Control.Semigroupoid"];                
  var Category = function (Semigroupoid0, identity) {
      this.Semigroupoid0 = Semigroupoid0;
      this.identity = identity;
  };
  var identity = function (dict) {
      return dict.identity;
  };
  var categoryFn = new Category(function () {
      return Control_Semigroupoid.semigroupoidFn;
  }, function (x) {
      return x;
  });
  exports["identity"] = identity;
  exports["categoryFn"] = categoryFn;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Function"] = $PS["Data.Function"] || {};
  var exports = $PS["Data.Function"];                    
  var on = function (f) {
      return function (g) {
          return function (x) {
              return function (y) {
                  return f(g(x))(g(y));
              };
          };
      };
  };
  var flip = function (f) {
      return function (b) {
          return function (a) {
              return f(a)(b);
          };
      };
  };
  var $$const = function (a) {
      return function (v) {
          return a;
      };
  };
  var applyFlipped = function (x) {
      return function (f) {
          return f(x);
      };
  };
  exports["flip"] = flip;
  exports["const"] = $$const;
  exports["applyFlipped"] = applyFlipped;
  exports["on"] = on;
})(PS);
(function(exports) {
  "use strict";

  exports.arrayMap = function (f) {
    return function (arr) {
      var l = arr.length;
      var result = new Array(l);
      for (var i = 0; i < l; i++) {
        result[i] = f(arr[i]);
      }
      return result;
    };
  };
})(PS["Data.Functor"] = PS["Data.Functor"] || {});
(function(exports) {
  "use strict";

  exports.unit = {};
})(PS["Data.Unit"] = PS["Data.Unit"] || {});
(function(exports) {
  "use strict";

  exports.showIntImpl = function (n) {
    return n.toString();
  };

  exports.showNumberImpl = function (n) {
    var str = n.toString();
    return isNaN(str + ".0") ? str : str + ".0";
  };

  exports.showCharImpl = function (c) {
    var code = c.charCodeAt(0);
    if (code < 0x20 || code === 0x7F) {
      switch (c) {
        case "\x07": return "'\\a'";
        case "\b": return "'\\b'";
        case "\f": return "'\\f'";
        case "\n": return "'\\n'";
        case "\r": return "'\\r'";
        case "\t": return "'\\t'";
        case "\v": return "'\\v'";
      }
      return "'\\" + code.toString(10) + "'";
    }
    return c === "'" || c === "\\" ? "'\\" + c + "'" : "'" + c + "'";
  };

  exports.showStringImpl = function (s) {
    var l = s.length;
    return "\"" + s.replace(
      /[\0-\x1F\x7F"\\]/g, // eslint-disable-line no-control-regex
      function (c, i) {
        switch (c) {
          case "\"":
          case "\\":
            return "\\" + c;
          case "\x07": return "\\a";
          case "\b": return "\\b";
          case "\f": return "\\f";
          case "\n": return "\\n";
          case "\r": return "\\r";
          case "\t": return "\\t";
          case "\v": return "\\v";
        }
        var k = i + 1;
        var empty = k < l && s[k] >= "0" && s[k] <= "9" ? "\\&" : "";
        return "\\" + c.charCodeAt(0).toString(10) + empty;
      }
    ) + "\"";
  };

  exports.showArrayImpl = function (f) {
    return function (xs) {
      var ss = [];
      for (var i = 0, l = xs.length; i < l; i++) {
        ss[i] = f(xs[i]);
      }
      return "[" + ss.join(",") + "]";
    };
  };

  exports.cons = function (head) {
    return function (tail) {
      return [head].concat(tail);
    };
  };

  exports.join = function (separator) {
    return function (xs) {
      return xs.join(separator);
    };
  };
})(PS["Data.Show"] = PS["Data.Show"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Symbol"] = $PS["Data.Symbol"] || {};
  var exports = $PS["Data.Symbol"];                  
  var SProxy = (function () {
      function SProxy() {

      };
      SProxy.value = new SProxy();
      return SProxy;
  })();
  var IsSymbol = function (reflectSymbol) {
      this.reflectSymbol = reflectSymbol;
  };
  var reflectSymbol = function (dict) {
      return dict.reflectSymbol;
  };
  exports["IsSymbol"] = IsSymbol;
  exports["reflectSymbol"] = reflectSymbol;
  exports["SProxy"] = SProxy;
})(PS);
(function(exports) {
  "use strict";

  exports.unsafeGet = function (label) {
    return function (rec) {
      return rec[label];
    };
  };

  exports.unsafeSet = function (label) {
    return function (value) {
      return function (rec) {
        var copy = {};
        for (var key in rec) {
          if ({}.hasOwnProperty.call(rec, key)) {
            copy[key] = rec[key];
          }
        }
        copy[label] = value;
        return copy;
      };
    };
  };

  exports.unsafeDelete = function (label) {
    return function (rec) {
      var copy = {};
      for (var key in rec) {
        if (key !== label && {}.hasOwnProperty.call(rec, key)) {
          copy[key] = rec[key];
        }
      }
      return copy;
    };
  };
})(PS["Record.Unsafe"] = PS["Record.Unsafe"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Record.Unsafe"] = $PS["Record.Unsafe"] || {};
  var exports = $PS["Record.Unsafe"];
  var $foreign = $PS["Record.Unsafe"];
  exports["unsafeGet"] = $foreign.unsafeGet;
  exports["unsafeSet"] = $foreign.unsafeSet;
  exports["unsafeDelete"] = $foreign.unsafeDelete;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Type.Proxy"] = $PS["Type.Proxy"] || {};
  var exports = $PS["Type.Proxy"];
  var $$Proxy = (function () {
      function $$Proxy() {

      };
      $$Proxy.value = new $$Proxy();
      return $$Proxy;
  })();
  exports["Proxy"] = $$Proxy;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Show"] = $PS["Data.Show"] || {};
  var exports = $PS["Data.Show"];
  var $foreign = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Record_Unsafe = $PS["Record.Unsafe"];
  var Type_Proxy = $PS["Type.Proxy"];                
  var ShowRecordFields = function (showRecordFields) {
      this.showRecordFields = showRecordFields;
  };
  var Show = function (show) {
      this.show = show;
  };
  var showString = new Show($foreign.showStringImpl);
  var showRecordFieldsNil = new ShowRecordFields(function (v) {
      return function (v1) {
          return [  ];
      };
  });
  var showRecordFields = function (dict) {
      return dict.showRecordFields;
  };
  var showRecord = function (dictRowToList) {
      return function (dictShowRecordFields) {
          return new Show(function (record) {
              var v = showRecordFields(dictShowRecordFields)(Type_Proxy["Proxy"].value)(record);
              if (v.length === 0) {
                  return "{}";
              };
              return $foreign.join(" ")([ "{", $foreign.join(", ")(v), "}" ]);
          });
      };
  }; 
  var showNumber = new Show($foreign.showNumberImpl);
  var showInt = new Show($foreign.showIntImpl);
  var showChar = new Show($foreign.showCharImpl);
  var show = function (dict) {
      return dict.show;
  };
  var showArray = function (dictShow) {
      return new Show($foreign.showArrayImpl(show(dictShow)));
  };
  var showRecordFieldsCons = function (dictIsSymbol) {
      return function (dictShowRecordFields) {
          return function (dictShow) {
              return new ShowRecordFields(function (v) {
                  return function (record) {
                      var tail = showRecordFields(dictShowRecordFields)(Type_Proxy["Proxy"].value)(record);
                      var key = Data_Symbol.reflectSymbol(dictIsSymbol)(Type_Proxy["Proxy"].value);
                      var focus = Record_Unsafe.unsafeGet(key)(record);
                      return $foreign.cons($foreign.join(": ")([ key, show(dictShow)(focus) ]))(tail);
                  };
              });
          };
      };
  };
  exports["Show"] = Show;
  exports["show"] = show;
  exports["showInt"] = showInt;
  exports["showNumber"] = showNumber;
  exports["showChar"] = showChar;
  exports["showString"] = showString;
  exports["showArray"] = showArray;
  exports["showRecord"] = showRecord;
  exports["showRecordFieldsNil"] = showRecordFieldsNil;
  exports["showRecordFieldsCons"] = showRecordFieldsCons;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Unit"] = $PS["Data.Unit"] || {};
  var exports = $PS["Data.Unit"];
  var $foreign = $PS["Data.Unit"];
  var Data_Show = $PS["Data.Show"];                
  var showUnit = new Data_Show.Show(function (v) {
      return "unit";
  });
  exports["showUnit"] = showUnit;
  exports["unit"] = $foreign.unit;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Functor"] = $PS["Data.Functor"] || {};
  var exports = $PS["Data.Functor"];
  var $foreign = $PS["Data.Functor"];
  var Control_Semigroupoid = $PS["Control.Semigroupoid"];
  var Data_Function = $PS["Data.Function"];
  var Data_Unit = $PS["Data.Unit"];                  
  var Functor = function (map) {
      this.map = map;
  };
  var map = function (dict) {
      return dict.map;
  };
  var mapFlipped = function (dictFunctor) {
      return function (fa) {
          return function (f) {
              return map(dictFunctor)(f)(fa);
          };
      };
  };
  var $$void = function (dictFunctor) {
      return map(dictFunctor)(Data_Function["const"](Data_Unit.unit));
  };
  var voidLeft = function (dictFunctor) {
      return function (f) {
          return function (x) {
              return map(dictFunctor)(Data_Function["const"](x))(f);
          };
      };
  };
  var voidRight = function (dictFunctor) {
      return function (x) {
          return map(dictFunctor)(Data_Function["const"](x));
      };
  }; 
  var functorFn = new Functor(Control_Semigroupoid.compose(Control_Semigroupoid.semigroupoidFn));
  var functorArray = new Functor($foreign.arrayMap);
  exports["Functor"] = Functor;
  exports["map"] = map;
  exports["mapFlipped"] = mapFlipped;
  exports["void"] = $$void;
  exports["voidRight"] = voidRight;
  exports["voidLeft"] = voidLeft;
  exports["functorFn"] = functorFn;
  exports["functorArray"] = functorArray;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Apply"] = $PS["Control.Apply"] || {};
  var exports = $PS["Control.Apply"];
  var $foreign = $PS["Control.Apply"];
  var Control_Category = $PS["Control.Category"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];            
  var Apply = function (Functor0, apply) {
      this.Functor0 = Functor0;
      this.apply = apply;
  }; 
  var applyArray = new Apply(function () {
      return Data_Functor.functorArray;
  }, $foreign.arrayApply);
  var apply = function (dict) {
      return dict.apply;
  };
  var applyFirst = function (dictApply) {
      return function (a) {
          return function (b) {
              return apply(dictApply)(Data_Functor.map(dictApply.Functor0())(Data_Function["const"])(a))(b);
          };
      };
  };
  var applySecond = function (dictApply) {
      return function (a) {
          return function (b) {
              return apply(dictApply)(Data_Functor.map(dictApply.Functor0())(Data_Function["const"](Control_Category.identity(Control_Category.categoryFn)))(a))(b);
          };
      };
  };
  var lift2 = function (dictApply) {
      return function (f) {
          return function (a) {
              return function (b) {
                  return apply(dictApply)(Data_Functor.map(dictApply.Functor0())(f)(a))(b);
              };
          };
      };
  };
  exports["Apply"] = Apply;
  exports["apply"] = apply;
  exports["applyFirst"] = applyFirst;
  exports["applySecond"] = applySecond;
  exports["lift2"] = lift2;
  exports["applyArray"] = applyArray;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Applicative"] = $PS["Control.Applicative"] || {};
  var exports = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Data_Unit = $PS["Data.Unit"];                  
  var Applicative = function (Apply0, pure) {
      this.Apply0 = Apply0;
      this.pure = pure;
  };
  var pure = function (dict) {
      return dict.pure;
  };
  var unless = function (dictApplicative) {
      return function (v) {
          return function (v1) {
              if (!v) {
                  return v1;
              };
              if (v) {
                  return pure(dictApplicative)(Data_Unit.unit);
              };
              throw new Error("Failed pattern match at Control.Applicative (line 66, column 1 - line 66, column 65): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
  };
  var when = function (dictApplicative) {
      return function (v) {
          return function (v1) {
              if (v) {
                  return v1;
              };
              if (!v) {
                  return pure(dictApplicative)(Data_Unit.unit);
              };
              throw new Error("Failed pattern match at Control.Applicative (line 61, column 1 - line 61, column 63): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
  };
  var liftA1 = function (dictApplicative) {
      return function (f) {
          return function (a) {
              return Control_Apply.apply(dictApplicative.Apply0())(pure(dictApplicative)(f))(a);
          };
      };
  }; 
  var applicativeArray = new Applicative(function () {
      return Control_Apply.applyArray;
  }, function (x) {
      return [ x ];
  });
  exports["Applicative"] = Applicative;
  exports["pure"] = pure;
  exports["liftA1"] = liftA1;
  exports["unless"] = unless;
  exports["when"] = when;
  exports["applicativeArray"] = applicativeArray;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Plus"] = $PS["Control.Plus"] || {};
  var exports = $PS["Control.Plus"];                     
  var Plus = function (Alt0, empty) {
      this.Alt0 = Alt0;
      this.empty = empty;
  };       
  var empty = function (dict) {
      return dict.empty;
  };
  exports["Plus"] = Plus;
  exports["empty"] = empty;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Alternative"] = $PS["Control.Alternative"] || {};
  var exports = $PS["Control.Alternative"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Plus = $PS["Control.Plus"];
  var Data_Unit = $PS["Data.Unit"];                
  var Alternative = function (Applicative0, Plus1) {
      this.Applicative0 = Applicative0;
      this.Plus1 = Plus1;
  };
  var guard = function (dictAlternative) {
      return function (v) {
          if (v) {
              return Control_Applicative.pure(dictAlternative.Applicative0())(Data_Unit.unit);
          };
          if (!v) {
              return Control_Plus.empty(dictAlternative.Plus1());
          };
          throw new Error("Failed pattern match at Control.Alternative (line 48, column 1 - line 48, column 54): " + [ v.constructor.name ]);
      };
  };
  exports["Alternative"] = Alternative;
  exports["guard"] = guard;
})(PS);
(function(exports) {
  "use strict";

  exports.arrayBind = function (arr) {
    return function (f) {
      var result = [];
      for (var i = 0, l = arr.length; i < l; i++) {
        Array.prototype.push.apply(result, f(arr[i]));
      }
      return result;
    };
  };
})(PS["Control.Bind"] = PS["Control.Bind"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Bind"] = $PS["Control.Bind"] || {};
  var exports = $PS["Control.Bind"];
  var $foreign = $PS["Control.Bind"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Category = $PS["Control.Category"];
  var Data_Function = $PS["Data.Function"];          
  var Bind = function (Apply0, bind) {
      this.Apply0 = Apply0;
      this.bind = bind;
  };
  var Discard = function (discard) {
      this.discard = discard;
  };
  var discard = function (dict) {
      return dict.discard;
  }; 
  var bindArray = new Bind(function () {
      return Control_Apply.applyArray;
  }, $foreign.arrayBind);
  var bind = function (dict) {
      return dict.bind;
  };
  var bindFlipped = function (dictBind) {
      return Data_Function.flip(bind(dictBind));
  };
  var composeKleisliFlipped = function (dictBind) {
      return function (f) {
          return function (g) {
              return function (a) {
                  return bindFlipped(dictBind)(f)(g(a));
              };
          };
      };
  }; 
  var discardUnit = new Discard(function (dictBind) {
      return bind(dictBind);
  });
  var join = function (dictBind) {
      return function (m) {
          return bind(dictBind)(m)(Control_Category.identity(Control_Category.categoryFn));
      };
  };
  exports["Bind"] = Bind;
  exports["bind"] = bind;
  exports["bindFlipped"] = bindFlipped;
  exports["discard"] = discard;
  exports["join"] = join;
  exports["composeKleisliFlipped"] = composeKleisliFlipped;
  exports["bindArray"] = bindArray;
  exports["discardUnit"] = discardUnit;
})(PS);
(function(exports) {
  "use strict";

  var refEq = function (r1) {
    return function (r2) {
      return r1 === r2;
    };
  };

  exports.eqBooleanImpl = refEq;
  exports.eqIntImpl = refEq;
  exports.eqNumberImpl = refEq;
  exports.eqCharImpl = refEq;
  exports.eqStringImpl = refEq;

  exports.eqArrayImpl = function (f) {
    return function (xs) {
      return function (ys) {
        if (xs.length !== ys.length) return false;
        for (var i = 0; i < xs.length; i++) {
          if (!f(xs[i])(ys[i])) return false;
        }
        return true;
      };
    };
  };
})(PS["Data.Eq"] = PS["Data.Eq"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Eq"] = $PS["Data.Eq"] || {};
  var exports = $PS["Data.Eq"];
  var $foreign = $PS["Data.Eq"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Record_Unsafe = $PS["Record.Unsafe"];
  var Type_Proxy = $PS["Type.Proxy"];                
  var EqRecord = function (eqRecord) {
      this.eqRecord = eqRecord;
  };
  var Eq = function (eq) {
      this.eq = eq;
  };
  var Eq1 = function (eq1) {
      this.eq1 = eq1;
  }; 
  var eqUnit = new Eq(function (v) {
      return function (v1) {
          return true;
      };
  });
  var eqString = new Eq($foreign.eqStringImpl);
  var eqRowNil = new EqRecord(function (v) {
      return function (v1) {
          return function (v2) {
              return true;
          };
      };
  });
  var eqRecord = function (dict) {
      return dict.eqRecord;
  };
  var eqRec = function (dictRowToList) {
      return function (dictEqRecord) {
          return new Eq(eqRecord(dictEqRecord)(Type_Proxy["Proxy"].value));
      };
  }; 
  var eqNumber = new Eq($foreign.eqNumberImpl);
  var eqInt = new Eq($foreign.eqIntImpl);
  var eqChar = new Eq($foreign.eqCharImpl);
  var eqBoolean = new Eq($foreign.eqBooleanImpl);
  var eq1 = function (dict) {
      return dict.eq1;
  };
  var eq = function (dict) {
      return dict.eq;
  };
  var eqArray = function (dictEq) {
      return new Eq($foreign.eqArrayImpl(eq(dictEq)));
  }; 
  var eqRowCons = function (dictEqRecord) {
      return function (dictCons) {
          return function (dictIsSymbol) {
              return function (dictEq) {
                  return new EqRecord(function (v) {
                      return function (ra) {
                          return function (rb) {
                              var tail = eqRecord(dictEqRecord)(Type_Proxy["Proxy"].value)(ra)(rb);
                              var key = Data_Symbol.reflectSymbol(dictIsSymbol)(Type_Proxy["Proxy"].value);
                              var get = Record_Unsafe.unsafeGet(key);
                              return eq(dictEq)(get(ra))(get(rb)) && tail;
                          };
                      };
                  });
              };
          };
      };
  };
  var notEq = function (dictEq) {
      return function (x) {
          return function (y) {
              return eq(eqBoolean)(eq(dictEq)(x)(y))(false);
          };
      };
  };
  exports["Eq"] = Eq;
  exports["eq"] = eq;
  exports["notEq"] = notEq;
  exports["Eq1"] = Eq1;
  exports["eq1"] = eq1;
  exports["eqBoolean"] = eqBoolean;
  exports["eqInt"] = eqInt;
  exports["eqNumber"] = eqNumber;
  exports["eqChar"] = eqChar;
  exports["eqString"] = eqString;
  exports["eqUnit"] = eqUnit;
  exports["eqArray"] = eqArray;
  exports["eqRec"] = eqRec;
  exports["eqRowNil"] = eqRowNil;
  exports["eqRowCons"] = eqRowCons;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Maybe"] = $PS["Data.Maybe"] || {};
  var exports = $PS["Data.Maybe"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Alternative = $PS["Control.Alternative"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Control_Plus = $PS["Control.Plus"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Show = $PS["Data.Show"];
  var Data_Unit = $PS["Data.Unit"];                
  var Nothing = (function () {
      function Nothing() {

      };
      Nothing.value = new Nothing();
      return Nothing;
  })();
  var Just = (function () {
      function Just(value0) {
          this.value0 = value0;
      };
      Just.create = function (value0) {
          return new Just(value0);
      };
      return Just;
  })();
  var showMaybe = function (dictShow) {
      return new Data_Show.Show(function (v) {
          if (v instanceof Just) {
              return "(Just " + (Data_Show.show(dictShow)(v.value0) + ")");
          };
          if (v instanceof Nothing) {
              return "Nothing";
          };
          throw new Error("Failed pattern match at Data.Maybe (line 216, column 1 - line 218, column 28): " + [ v.constructor.name ]);
      });
  };
  var maybe$prime = function (v) {
      return function (v1) {
          return function (v2) {
              if (v2 instanceof Nothing) {
                  return v(Data_Unit.unit);
              };
              if (v2 instanceof Just) {
                  return v1(v2.value0);
              };
              throw new Error("Failed pattern match at Data.Maybe (line 243, column 1 - line 243, column 62): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
          };
      };
  };
  var maybe = function (v) {
      return function (v1) {
          return function (v2) {
              if (v2 instanceof Nothing) {
                  return v;
              };
              if (v2 instanceof Just) {
                  return v1(v2.value0);
              };
              throw new Error("Failed pattern match at Data.Maybe (line 230, column 1 - line 230, column 51): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
          };
      };
  };
  var isNothing = maybe(true)(Data_Function["const"](false));
  var isJust = maybe(false)(Data_Function["const"](true));
  var functorMaybe = new Data_Functor.Functor(function (v) {
      return function (v1) {
          if (v1 instanceof Just) {
              return new Just(v(v1.value0));
          };
          return Nothing.value;
      };
  });                                                                                                   
  var fromMaybe$prime = function (a) {
      return maybe$prime(a)(Control_Category.identity(Control_Category.categoryFn));
  };
  var fromMaybe = function (a) {
      return maybe(a)(Control_Category.identity(Control_Category.categoryFn));
  };
  var fromJust = function (dictPartial) {
      return function (v) {
          if (v instanceof Just) {
              return v.value0;
          };
          throw new Error("Failed pattern match at Data.Maybe (line 281, column 1 - line 281, column 46): " + [ v.constructor.name ]);
      };
  }; 
  var eqMaybe = function (dictEq) {
      return new Data_Eq.Eq(function (x) {
          return function (y) {
              if (x instanceof Nothing && y instanceof Nothing) {
                  return true;
              };
              if (x instanceof Just && y instanceof Just) {
                  return Data_Eq.eq(dictEq)(x.value0)(y.value0);
              };
              return false;
          };
      });
  };
  var applyMaybe = new Control_Apply.Apply(function () {
      return functorMaybe;
  }, function (v) {
      return function (v1) {
          if (v instanceof Just) {
              return Data_Functor.map(functorMaybe)(v.value0)(v1);
          };
          if (v instanceof Nothing) {
              return Nothing.value;
          };
          throw new Error("Failed pattern match at Data.Maybe (line 68, column 1 - line 70, column 30): " + [ v.constructor.name, v1.constructor.name ]);
      };
  });
  var bindMaybe = new Control_Bind.Bind(function () {
      return applyMaybe;
  }, function (v) {
      return function (v1) {
          if (v instanceof Just) {
              return v1(v.value0);
          };
          if (v instanceof Nothing) {
              return Nothing.value;
          };
          throw new Error("Failed pattern match at Data.Maybe (line 126, column 1 - line 128, column 28): " + [ v.constructor.name, v1.constructor.name ]);
      };
  });
  var applicativeMaybe = new Control_Applicative.Applicative(function () {
      return applyMaybe;
  }, Just.create);
  var altMaybe = new Control_Alt.Alt(function () {
      return functorMaybe;
  }, function (v) {
      return function (v1) {
          if (v instanceof Nothing) {
              return v1;
          };
          return v;
      };
  });
  var plusMaybe = new Control_Plus.Plus(function () {
      return altMaybe;
  }, Nothing.value);
  var alternativeMaybe = new Control_Alternative.Alternative(function () {
      return applicativeMaybe;
  }, function () {
      return plusMaybe;
  });
  exports["Nothing"] = Nothing;
  exports["Just"] = Just;
  exports["maybe"] = maybe;
  exports["maybe'"] = maybe$prime;
  exports["fromMaybe"] = fromMaybe;
  exports["fromMaybe'"] = fromMaybe$prime;
  exports["isJust"] = isJust;
  exports["isNothing"] = isNothing;
  exports["fromJust"] = fromJust;
  exports["functorMaybe"] = functorMaybe;
  exports["applyMaybe"] = applyMaybe;
  exports["applicativeMaybe"] = applicativeMaybe;
  exports["alternativeMaybe"] = alternativeMaybe;
  exports["bindMaybe"] = bindMaybe;
  exports["eqMaybe"] = eqMaybe;
  exports["showMaybe"] = showMaybe;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.MediaType.Common"] = $PS["Data.MediaType.Common"] || {};
  var exports = $PS["Data.MediaType.Common"];          
  var applicationJSON = "application/json";
  var applicationFormURLEncoded = "application/x-www-form-urlencoded";
  exports["applicationFormURLEncoded"] = applicationFormURLEncoded;
  exports["applicationJSON"] = applicationJSON;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Affjax.RequestBody"] = $PS["Affjax.RequestBody"] || {};
  var exports = $PS["Affjax.RequestBody"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_MediaType_Common = $PS["Data.MediaType.Common"];                
  var ArrayView = (function () {
      function ArrayView(value0) {
          this.value0 = value0;
      };
      ArrayView.create = function (value0) {
          return new ArrayView(value0);
      };
      return ArrayView;
  })();
  var Blob = (function () {
      function Blob(value0) {
          this.value0 = value0;
      };
      Blob.create = function (value0) {
          return new Blob(value0);
      };
      return Blob;
  })();
  var Document = (function () {
      function Document(value0) {
          this.value0 = value0;
      };
      Document.create = function (value0) {
          return new Document(value0);
      };
      return Document;
  })();
  var $$String = (function () {
      function $$String(value0) {
          this.value0 = value0;
      };
      $$String.create = function (value0) {
          return new $$String(value0);
      };
      return $$String;
  })();
  var FormData = (function () {
      function FormData(value0) {
          this.value0 = value0;
      };
      FormData.create = function (value0) {
          return new FormData(value0);
      };
      return FormData;
  })();
  var FormURLEncoded = (function () {
      function FormURLEncoded(value0) {
          this.value0 = value0;
      };
      FormURLEncoded.create = function (value0) {
          return new FormURLEncoded(value0);
      };
      return FormURLEncoded;
  })();
  var Json = (function () {
      function Json(value0) {
          this.value0 = value0;
      };
      Json.create = function (value0) {
          return new Json(value0);
      };
      return Json;
  })();
  var toMediaType = function (v) {
      if (v instanceof FormURLEncoded) {
          return new Data_Maybe.Just(Data_MediaType_Common.applicationFormURLEncoded);
      };
      if (v instanceof Json) {
          return new Data_Maybe.Just(Data_MediaType_Common.applicationJSON);
      };
      return Data_Maybe.Nothing.value;
  };
  var string = $$String.create;
  var formURLEncoded = FormURLEncoded.create;
  exports["ArrayView"] = ArrayView;
  exports["Blob"] = Blob;
  exports["Document"] = Document;
  exports["String"] = $$String;
  exports["FormData"] = FormData;
  exports["FormURLEncoded"] = FormURLEncoded;
  exports["Json"] = Json;
  exports["string"] = string;
  exports["formURLEncoded"] = formURLEncoded;
  exports["toMediaType"] = toMediaType;
})(PS);
(function(exports) {
  "use strict";

  // module Unsafe.Coerce

  exports.unsafeCoerce = function (x) {
    return x;
  };
})(PS["Unsafe.Coerce"] = PS["Unsafe.Coerce"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Unsafe.Coerce"] = $PS["Unsafe.Coerce"] || {};
  var exports = $PS["Unsafe.Coerce"];
  var $foreign = $PS["Unsafe.Coerce"];
  exports["unsafeCoerce"] = $foreign.unsafeCoerce;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Safe.Coerce"] = $PS["Safe.Coerce"] || {};
  var exports = $PS["Safe.Coerce"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
  var coerce = function (dictCoercible) {
      return Unsafe_Coerce.unsafeCoerce;
  };
  exports["coerce"] = coerce;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Newtype"] = $PS["Data.Newtype"] || {};
  var exports = $PS["Data.Newtype"];
  var Safe_Coerce = $PS["Safe.Coerce"];
  var wrap = function (dictNewtype) {
      return Safe_Coerce.coerce();
  };
  var unwrap = function (dictNewtype) {
      return Safe_Coerce.coerce();
  };
  var under = function (dictNewtype) {
      return function (dictNewtype1) {
          return function (v) {
              return Safe_Coerce.coerce();
          };
      };
  };
  var un = function (dictNewtype) {
      return function (v) {
          return unwrap();
      };
  };
  var over = function (dictNewtype) {
      return function (dictNewtype1) {
          return function (v) {
              return Safe_Coerce.coerce();
          };
      };
  };
  var alaF = function (dictCoercible) {
      return function (dictCoercible1) {
          return function (dictNewtype) {
              return function (dictNewtype1) {
                  return function (v) {
                      return Safe_Coerce.coerce();
                  };
              };
          };
      };
  };
  exports["wrap"] = wrap;
  exports["unwrap"] = unwrap;
  exports["un"] = un;
  exports["alaF"] = alaF;
  exports["over"] = over;
  exports["under"] = under;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Affjax.RequestHeader"] = $PS["Affjax.RequestHeader"] || {};
  var exports = $PS["Affjax.RequestHeader"];
  var Data_Newtype = $PS["Data.Newtype"];          
  var Accept = (function () {
      function Accept(value0) {
          this.value0 = value0;
      };
      Accept.create = function (value0) {
          return new Accept(value0);
      };
      return Accept;
  })();
  var ContentType = (function () {
      function ContentType(value0) {
          this.value0 = value0;
      };
      ContentType.create = function (value0) {
          return new ContentType(value0);
      };
      return ContentType;
  })();
  var RequestHeader = (function () {
      function RequestHeader(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      RequestHeader.create = function (value0) {
          return function (value1) {
              return new RequestHeader(value0, value1);
          };
      };
      return RequestHeader;
  })();
  var value = function (v) {
      if (v instanceof Accept) {
          return Data_Newtype.unwrap()(v.value0);
      };
      if (v instanceof ContentType) {
          return Data_Newtype.unwrap()(v.value0);
      };
      if (v instanceof RequestHeader) {
          return v.value1;
      };
      throw new Error("Failed pattern match at Affjax.RequestHeader (line 26, column 1 - line 26, column 33): " + [ v.constructor.name ]);
  }; 
  var name = function (v) {
      if (v instanceof Accept) {
          return "Accept";
      };
      if (v instanceof ContentType) {
          return "Content-Type";
      };
      if (v instanceof RequestHeader) {
          return v.value0;
      };
      throw new Error("Failed pattern match at Affjax.RequestHeader (line 21, column 1 - line 21, column 32): " + [ v.constructor.name ]);
  };
  exports["Accept"] = Accept;
  exports["ContentType"] = ContentType;
  exports["RequestHeader"] = RequestHeader;
  exports["name"] = name;
  exports["value"] = value;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Affjax.ResponseFormat"] = $PS["Affjax.ResponseFormat"] || {};
  var exports = $PS["Affjax.ResponseFormat"];
  var Control_Category = $PS["Control.Category"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_MediaType_Common = $PS["Data.MediaType.Common"];                
  var $$ArrayBuffer = (function () {
      function $$ArrayBuffer(value0) {
          this.value0 = value0;
      };
      $$ArrayBuffer.create = function (value0) {
          return new $$ArrayBuffer(value0);
      };
      return $$ArrayBuffer;
  })();
  var Blob = (function () {
      function Blob(value0) {
          this.value0 = value0;
      };
      Blob.create = function (value0) {
          return new Blob(value0);
      };
      return Blob;
  })();
  var Document = (function () {
      function Document(value0) {
          this.value0 = value0;
      };
      Document.create = function (value0) {
          return new Document(value0);
      };
      return Document;
  })();
  var Json = (function () {
      function Json(value0) {
          this.value0 = value0;
      };
      Json.create = function (value0) {
          return new Json(value0);
      };
      return Json;
  })();
  var $$String = (function () {
      function $$String(value0) {
          this.value0 = value0;
      };
      $$String.create = function (value0) {
          return new $$String(value0);
      };
      return $$String;
  })();
  var Ignore = (function () {
      function Ignore(value0) {
          this.value0 = value0;
      };
      Ignore.create = function (value0) {
          return new Ignore(value0);
      };
      return Ignore;
  })();
  var toResponseType = function (v) {
      if (v instanceof $$ArrayBuffer) {
          return "arraybuffer";
      };
      if (v instanceof Blob) {
          return "blob";
      };
      if (v instanceof Document) {
          return "document";
      };
      if (v instanceof Json) {
          return "text";
      };
      if (v instanceof $$String) {
          return "text";
      };
      if (v instanceof Ignore) {
          return "";
      };
      throw new Error("Failed pattern match at Affjax.ResponseFormat (line 44, column 3 - line 50, column 19): " + [ v.constructor.name ]);
  };
  var toMediaType = function (v) {
      if (v instanceof Json) {
          return new Data_Maybe.Just(Data_MediaType_Common.applicationJSON);
      };
      return Data_Maybe.Nothing.value;
  };                                                                                
  var json = new Json(Control_Category.identity(Control_Category.categoryFn));
  var ignore = new Ignore(Control_Category.identity(Control_Category.categoryFn));
  exports["ArrayBuffer"] = $$ArrayBuffer;
  exports["Blob"] = Blob;
  exports["Document"] = Document;
  exports["Json"] = Json;
  exports["String"] = $$String;
  exports["Ignore"] = Ignore;
  exports["json"] = json;
  exports["ignore"] = ignore;
  exports["toResponseType"] = toResponseType;
  exports["toMediaType"] = toMediaType;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Affjax.ResponseHeader"] = $PS["Affjax.ResponseHeader"] || {};
  var exports = $PS["Affjax.ResponseHeader"];      
  var ResponseHeader = (function () {
      function ResponseHeader(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      ResponseHeader.create = function (value0) {
          return function (value1) {
              return new ResponseHeader(value0, value1);
          };
      };
      return ResponseHeader;
  })();
  exports["ResponseHeader"] = ResponseHeader;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Either"] = $PS["Data.Either"] || {};
  var exports = $PS["Data.Either"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Unit = $PS["Data.Unit"];                
  var Left = (function () {
      function Left(value0) {
          this.value0 = value0;
      };
      Left.create = function (value0) {
          return new Left(value0);
      };
      return Left;
  })();
  var Right = (function () {
      function Right(value0) {
          this.value0 = value0;
      };
      Right.create = function (value0) {
          return new Right(value0);
      };
      return Right;
  })();
  var note = function (a) {
      return Data_Maybe.maybe(new Left(a))(Right.create);
  }; 
  var functorEither = new Data_Functor.Functor(function (f) {
      return function (m) {
          if (m instanceof Left) {
              return new Left(m.value0);
          };
          if (m instanceof Right) {
              return new Right(f(m.value0));
          };
          throw new Error("Failed pattern match at Data.Either (line 31, column 1 - line 31, column 52): " + [ m.constructor.name ]);
      };
  });                                                                                                     
  var fromRight$prime = function (v) {
      return function (v1) {
          if (v1 instanceof Right) {
              return v1.value0;
          };
          return v(Data_Unit.unit);
      };
  };
  var either = function (v) {
      return function (v1) {
          return function (v2) {
              if (v2 instanceof Left) {
                  return v(v2.value0);
              };
              if (v2 instanceof Right) {
                  return v1(v2.value0);
              };
              throw new Error("Failed pattern match at Data.Either (line 208, column 1 - line 208, column 64): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
          };
      };
  };
  var hush = either(Data_Function["const"](Data_Maybe.Nothing.value))(Data_Maybe.Just.create);
  var applyEither = new Control_Apply.Apply(function () {
      return functorEither;
  }, function (v) {
      return function (v1) {
          if (v instanceof Left) {
              return new Left(v.value0);
          };
          if (v instanceof Right) {
              return Data_Functor.map(functorEither)(v.value0)(v1);
          };
          throw new Error("Failed pattern match at Data.Either (line 70, column 1 - line 72, column 30): " + [ v.constructor.name, v1.constructor.name ]);
      };
  });
  var bindEither = new Control_Bind.Bind(function () {
      return applyEither;
  }, either(function (e) {
      return function (v) {
          return new Left(e);
      };
  })(function (a) {
      return function (f) {
          return f(a);
      };
  }));
  var applicativeEither = new Control_Applicative.Applicative(function () {
      return applyEither;
  }, Right.create);
  exports["Left"] = Left;
  exports["Right"] = Right;
  exports["either"] = either;
  exports["fromRight'"] = fromRight$prime;
  exports["note"] = note;
  exports["hush"] = hush;
  exports["functorEither"] = functorEither;
  exports["applicativeEither"] = applicativeEither;
  exports["bindEither"] = bindEither;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.Error.Class"] = $PS["Control.Monad.Error.Class"] || {};
  var exports = $PS["Control.Monad.Error.Class"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Either = $PS["Data.Either"];
  var Data_Functor = $PS["Data.Functor"];                        
  var MonadThrow = function (Monad0, throwError) {
      this.Monad0 = Monad0;
      this.throwError = throwError;
  };
  var MonadError = function (MonadThrow0, catchError) {
      this.MonadThrow0 = MonadThrow0;
      this.catchError = catchError;
  };
  var throwError = function (dict) {
      return dict.throwError;
  };                                                      
  var catchError = function (dict) {
      return dict.catchError;
  };
  var $$try = function (dictMonadError) {
      return function (a) {
          return catchError(dictMonadError)(Data_Functor.map(((((dictMonadError.MonadThrow0()).Monad0()).Bind1()).Apply0()).Functor0())(Data_Either.Right.create)(a))((function () {
              var $17 = Control_Applicative.pure(((dictMonadError.MonadThrow0()).Monad0()).Applicative0());
              return function ($18) {
                  return $17(Data_Either.Left.create($18));
              };
          })());
      };
  };
  exports["throwError"] = throwError;
  exports["MonadThrow"] = MonadThrow;
  exports["MonadError"] = MonadError;
  exports["try"] = $$try;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad"] = $PS["Control.Monad"] || {};
  var exports = $PS["Control.Monad"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];                
  var Monad = function (Applicative0, Bind1) {
      this.Applicative0 = Applicative0;
      this.Bind1 = Bind1;
  };
  var ap = function (dictMonad) {
      return function (f) {
          return function (a) {
              return Control_Bind.bind(dictMonad.Bind1())(f)(function (f$prime) {
                  return Control_Bind.bind(dictMonad.Bind1())(a)(function (a$prime) {
                      return Control_Applicative.pure(dictMonad.Applicative0())(f$prime(a$prime));
                  });
              });
          };
      };
  };
  exports["Monad"] = Monad;
  exports["ap"] = ap;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Tuple"] = $PS["Data.Tuple"] || {};
  var exports = $PS["Data.Tuple"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];          
  var Tuple = (function () {
      function Tuple(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Tuple.create = function (value0) {
          return function (value1) {
              return new Tuple(value0, value1);
          };
      };
      return Tuple;
  })();
  var uncurry = function (f) {
      return function (v) {
          return f(v.value0)(v.value1);
      };
  };
  var snd = function (v) {
      return v.value1;
  }; 
  var functorTuple = new Data_Functor.Functor(function (f) {
      return function (m) {
          return new Tuple(m.value0, f(m.value1));
      };
  });                                                                                                   
  var fst = function (v) {
      return v.value0;
  }; 
  var eqTuple = function (dictEq) {
      return function (dictEq1) {
          return new Data_Eq.Eq(function (x) {
              return function (y) {
                  return Data_Eq.eq(dictEq)(x.value0)(y.value0) && Data_Eq.eq(dictEq1)(x.value1)(y.value1);
              };
          });
      };
  };
  exports["Tuple"] = Tuple;
  exports["fst"] = fst;
  exports["snd"] = snd;
  exports["uncurry"] = uncurry;
  exports["eqTuple"] = eqTuple;
  exports["functorTuple"] = functorTuple;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.State.Class"] = $PS["Control.Monad.State.Class"] || {};
  var exports = $PS["Control.Monad.State.Class"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];                
  var MonadState = function (Monad0, state) {
      this.Monad0 = Monad0;
      this.state = state;
  };
  var state = function (dict) {
      return dict.state;
  };
  var put = function (dictMonadState) {
      return function (s) {
          return state(dictMonadState)(function (v) {
              return new Data_Tuple.Tuple(Data_Unit.unit, s);
          });
      };
  };
  var modify_ = function (dictMonadState) {
      return function (f) {
          return state(dictMonadState)(function (s) {
              return new Data_Tuple.Tuple(Data_Unit.unit, f(s));
          });
      };
  };
  var modify = function (dictMonadState) {
      return function (f) {
          return state(dictMonadState)(function (s) {
              var s$prime = f(s);
              return new Data_Tuple.Tuple(s$prime, s$prime);
          });
      };
  };
  var gets = function (dictMonadState) {
      return function (f) {
          return state(dictMonadState)(function (s) {
              return new Data_Tuple.Tuple(f(s), s);
          });
      };
  };
  var get = function (dictMonadState) {
      return state(dictMonadState)(function (s) {
          return new Data_Tuple.Tuple(s, s);
      });
  };
  exports["state"] = state;
  exports["MonadState"] = MonadState;
  exports["get"] = get;
  exports["gets"] = gets;
  exports["put"] = put;
  exports["modify"] = modify;
  exports["modify_"] = modify_;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.Trans.Class"] = $PS["Control.Monad.Trans.Class"] || {};
  var exports = $PS["Control.Monad.Trans.Class"];
  var MonadTrans = function (lift) {
      this.lift = lift;
  };
  var lift = function (dict) {
      return dict.lift;
  };
  exports["lift"] = lift;
  exports["MonadTrans"] = MonadTrans;
})(PS);
(function(exports) {
  "use strict";

  exports.concatString = function (s1) {
    return function (s2) {
      return s1 + s2;
    };
  };

  exports.concatArray = function (xs) {
    return function (ys) {
      if (xs.length === 0) return ys;
      if (ys.length === 0) return xs;
      return xs.concat(ys);
    };
  };
})(PS["Data.Semigroup"] = PS["Data.Semigroup"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Semigroup"] = $PS["Data.Semigroup"] || {};
  var exports = $PS["Data.Semigroup"];
  var $foreign = $PS["Data.Semigroup"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Record_Unsafe = $PS["Record.Unsafe"];
  var Type_Proxy = $PS["Type.Proxy"];                
  var SemigroupRecord = function (appendRecord) {
      this.appendRecord = appendRecord;
  };
  var Semigroup = function (append) {
      this.append = append;
  }; 
  var semigroupUnit = new Semigroup(function (v) {
      return function (v1) {
          return Data_Unit.unit;
      };
  });
  var semigroupString = new Semigroup($foreign.concatString);
  var semigroupRecordNil = new SemigroupRecord(function (v) {
      return function (v1) {
          return function (v2) {
              return {};
          };
      };
  });
  var semigroupArray = new Semigroup($foreign.concatArray);
  var appendRecord = function (dict) {
      return dict.appendRecord;
  };
  var semigroupRecord = function (dictRowToList) {
      return function (dictSemigroupRecord) {
          return new Semigroup(appendRecord(dictSemigroupRecord)(Type_Proxy["Proxy"].value));
      };
  };
  var append = function (dict) {
      return dict.append;
  };
  var semigroupFn = function (dictSemigroup) {
      return new Semigroup(function (f) {
          return function (g) {
              return function (x) {
                  return append(dictSemigroup)(f(x))(g(x));
              };
          };
      });
  };
  var semigroupRecordCons = function (dictIsSymbol) {
      return function (dictCons) {
          return function (dictSemigroupRecord) {
              return function (dictSemigroup) {
                  return new SemigroupRecord(function (v) {
                      return function (ra) {
                          return function (rb) {
                              var tail = appendRecord(dictSemigroupRecord)(Type_Proxy["Proxy"].value)(ra)(rb);
                              var key = Data_Symbol.reflectSymbol(dictIsSymbol)(Type_Proxy["Proxy"].value);
                              var insert = Record_Unsafe.unsafeSet(key);
                              var get = Record_Unsafe.unsafeGet(key);
                              return insert(append(dictSemigroup)(get(ra))(get(rb)))(tail);
                          };
                      };
                  });
              };
          };
      };
  };
  exports["Semigroup"] = Semigroup;
  exports["append"] = append;
  exports["semigroupString"] = semigroupString;
  exports["semigroupUnit"] = semigroupUnit;
  exports["semigroupFn"] = semigroupFn;
  exports["semigroupArray"] = semigroupArray;
  exports["semigroupRecord"] = semigroupRecord;
  exports["semigroupRecordNil"] = semigroupRecordNil;
  exports["semigroupRecordCons"] = semigroupRecordCons;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.Except.Trans"] = $PS["Control.Monad.Except.Trans"] || {};
  var exports = $PS["Control.Monad.Except.Trans"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad = $PS["Control.Monad"];
  var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
  var Control_Monad_State_Class = $PS["Control.Monad.State.Class"];
  var Control_Monad_Trans_Class = $PS["Control.Monad.Trans.Class"];
  var Data_Either = $PS["Data.Either"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Semigroup = $PS["Data.Semigroup"];            
  var ExceptT = function (x) {
      return x;
  };
  var withExceptT = function (dictFunctor) {
      return function (f) {
          return function (v) {
              var mapLeft = function (v1) {
                  return function (v2) {
                      if (v2 instanceof Data_Either.Right) {
                          return new Data_Either.Right(v2.value0);
                      };
                      if (v2 instanceof Data_Either.Left) {
                          return new Data_Either.Left(v1(v2.value0));
                      };
                      throw new Error("Failed pattern match at Control.Monad.Except.Trans (line 43, column 3 - line 43, column 32): " + [ v1.constructor.name, v2.constructor.name ]);
                  };
              };
              return ExceptT(Data_Functor.map(dictFunctor)(mapLeft(f))(v));
          };
      };
  };
  var runExceptT = function (v) {
      return v;
  }; 
  var monadTransExceptT = new Control_Monad_Trans_Class.MonadTrans(function (dictMonad) {
      return function (m) {
          return Control_Bind.bind(dictMonad.Bind1())(m)(function (a) {
              return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(a));
          });
      };
  });
  var mapExceptT = function (f) {
      return function (v) {
          return f(v);
      };
  };
  var functorExceptT = function (dictFunctor) {
      return new Data_Functor.Functor(function (f) {
          return mapExceptT(Data_Functor.map(dictFunctor)(Data_Functor.map(Data_Either.functorEither)(f)));
      });
  };
  var monadExceptT = function (dictMonad) {
      return new Control_Monad.Monad(function () {
          return applicativeExceptT(dictMonad);
      }, function () {
          return bindExceptT(dictMonad);
      });
  };
  var bindExceptT = function (dictMonad) {
      return new Control_Bind.Bind(function () {
          return applyExceptT(dictMonad);
      }, function (v) {
          return function (k) {
              return Control_Bind.bind(dictMonad.Bind1())(v)(Data_Either.either((function () {
                  var $91 = Control_Applicative.pure(dictMonad.Applicative0());
                  return function ($92) {
                      return $91(Data_Either.Left.create($92));
                  };
              })())(function (a) {
                  var v1 = k(a);
                  return v1;
              }));
          };
      });
  };
  var applyExceptT = function (dictMonad) {
      return new Control_Apply.Apply(function () {
          return functorExceptT(((dictMonad.Bind1()).Apply0()).Functor0());
      }, Control_Monad.ap(monadExceptT(dictMonad)));
  };
  var applicativeExceptT = function (dictMonad) {
      return new Control_Applicative.Applicative(function () {
          return applyExceptT(dictMonad);
      }, (function () {
          var $93 = Control_Applicative.pure(dictMonad.Applicative0());
          return function ($94) {
              return ExceptT($93(Data_Either.Right.create($94)));
          };
      })());
  };
  var monadStateExceptT = function (dictMonadState) {
      return new Control_Monad_State_Class.MonadState(function () {
          return monadExceptT(dictMonadState.Monad0());
      }, function (f) {
          return Control_Monad_Trans_Class.lift(monadTransExceptT)(dictMonadState.Monad0())(Control_Monad_State_Class.state(dictMonadState)(f));
      });
  };
  var monadThrowExceptT = function (dictMonad) {
      return new Control_Monad_Error_Class.MonadThrow(function () {
          return monadExceptT(dictMonad);
      }, (function () {
          var $103 = Control_Applicative.pure(dictMonad.Applicative0());
          return function ($104) {
              return ExceptT($103(Data_Either.Left.create($104)));
          };
      })());
  };
  var altExceptT = function (dictSemigroup) {
      return function (dictMonad) {
          return new Control_Alt.Alt(function () {
              return functorExceptT(((dictMonad.Bind1()).Apply0()).Functor0());
          }, function (v) {
              return function (v1) {
                  return Control_Bind.bind(dictMonad.Bind1())(v)(function (rm) {
                      if (rm instanceof Data_Either.Right) {
                          return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(rm.value0));
                      };
                      if (rm instanceof Data_Either.Left) {
                          return Control_Bind.bind(dictMonad.Bind1())(v1)(function (rn) {
                              if (rn instanceof Data_Either.Right) {
                                  return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Right(rn.value0));
                              };
                              if (rn instanceof Data_Either.Left) {
                                  return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Either.Left(Data_Semigroup.append(dictSemigroup)(rm.value0)(rn.value0)));
                              };
                              throw new Error("Failed pattern match at Control.Monad.Except.Trans (line 87, column 9 - line 89, column 49): " + [ rn.constructor.name ]);
                          });
                      };
                      throw new Error("Failed pattern match at Control.Monad.Except.Trans (line 83, column 5 - line 89, column 49): " + [ rm.constructor.name ]);
                  });
              };
          });
      };
  };
  exports["ExceptT"] = ExceptT;
  exports["runExceptT"] = runExceptT;
  exports["withExceptT"] = withExceptT;
  exports["mapExceptT"] = mapExceptT;
  exports["functorExceptT"] = functorExceptT;
  exports["applyExceptT"] = applyExceptT;
  exports["applicativeExceptT"] = applicativeExceptT;
  exports["bindExceptT"] = bindExceptT;
  exports["altExceptT"] = altExceptT;
  exports["monadThrowExceptT"] = monadThrowExceptT;
  exports["monadStateExceptT"] = monadStateExceptT;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Identity"] = $PS["Data.Identity"] || {};
  var exports = $PS["Data.Identity"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad = $PS["Control.Monad"];
  var Data_Functor = $PS["Data.Functor"];          
  var Identity = function (x) {
      return x;
  };
  var functorIdentity = new Data_Functor.Functor(function (f) {
      return function (m) {
          return f(m);
      };
  });
  var applyIdentity = new Control_Apply.Apply(function () {
      return functorIdentity;
  }, function (v) {
      return function (v1) {
          return v(v1);
      };
  });
  var bindIdentity = new Control_Bind.Bind(function () {
      return applyIdentity;
  }, function (v) {
      return function (f) {
          return f(v);
      };
  });
  var applicativeIdentity = new Control_Applicative.Applicative(function () {
      return applyIdentity;
  }, Identity);
  var monadIdentity = new Control_Monad.Monad(function () {
      return applicativeIdentity;
  }, function () {
      return bindIdentity;
  });
  exports["Identity"] = Identity;
  exports["functorIdentity"] = functorIdentity;
  exports["applicativeIdentity"] = applicativeIdentity;
  exports["bindIdentity"] = bindIdentity;
  exports["monadIdentity"] = monadIdentity;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.Except"] = $PS["Control.Monad.Except"] || {};
  var exports = $PS["Control.Monad.Except"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Newtype = $PS["Data.Newtype"];                
  var withExcept = Control_Monad_Except_Trans.withExceptT(Data_Identity.functorIdentity);
  var runExcept = (function () {
      var $0 = Data_Newtype.unwrap();
      return function ($1) {
          return $0(Control_Monad_Except_Trans.runExceptT($1));
      };
  })();
  exports["runExcept"] = runExcept;
  exports["withExcept"] = withExcept;
})(PS);
(function(exports) {
  /* eslint-disable no-eq-null, eqeqeq */
  "use strict";

  function id(x) {
    return x;
  }                      
  exports.fromObject = id;

  exports.stringify = function (j) {
    return JSON.stringify(j);
  };

  function isArray(a) {
    return Object.prototype.toString.call(a) === "[object Array]";
  }
})(PS["Data.Argonaut.Core"] = PS["Data.Argonaut.Core"] || {});
(function(exports) {
  "use strict";

  exports._copyST = function (m) {
    return function () {
      var r = {};
      for (var k in m) {
        if (hasOwnProperty.call(m, k)) {
          r[k] = m[k];
        }
      }
      return r;
    };
  };

  exports.empty = {};

  exports.runST = function (f) {
    return f();
  };

  exports._fmapObject = function (m0, f) {
    var m = {};
    for (var k in m0) {
      if (hasOwnProperty.call(m0, k)) {
        m[k] = f(m0[k]);
      }
    }
    return m;
  };

  exports._mapWithKey = function (m0, f) {
    var m = {};
    for (var k in m0) {
      if (hasOwnProperty.call(m0, k)) {
        m[k] = f(k)(m0[k]);
      }
    }
    return m;
  };

  exports._foldM = function (bind) {
    return function (f) {
      return function (mz) {
        return function (m) {
          var acc = mz;
          function g(k) {
            return function (z) {
              return f(z)(k)(m[k]);
            };
          }
          for (var k in m) {
            if (hasOwnProperty.call(m, k)) {
              acc = bind(acc)(g(k));
            }
          }
          return acc;
        };
      };
    };
  };

  function toArrayWithKey(f) {
    return function (m) {
      var r = [];
      for (var k in m) {
        if (hasOwnProperty.call(m, k)) {
          r.push(f(k)(m[k]));
        }
      }
      return r;
    };
  }

  exports.toArrayWithKey = toArrayWithKey;
})(PS["Foreign.Object"] = PS["Foreign.Object"] || {});
(function(exports) {
  "use strict";

  exports.map_ = function (f) {
    return function (a) {
      return function () {
        return f(a());
      };
    };
  };

  exports.pure_ = function (a) {
    return function () {
      return a;
    };
  };

  exports.bind_ = function (a) {
    return function (f) {
      return function () {
        return f(a())();
      };
    };
  };

  exports.foreach = function (as) {
    return function (f) {
      return function () {
        for (var i = 0, l = as.length; i < l; i++) {
          f(as[i])();
        }
      };
    };
  };
})(PS["Control.Monad.ST.Internal"] = PS["Control.Monad.ST.Internal"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.ST.Internal"] = $PS["Control.Monad.ST.Internal"] || {};
  var exports = $PS["Control.Monad.ST.Internal"];
  var $foreign = $PS["Control.Monad.ST.Internal"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad = $PS["Control.Monad"];
  var Data_Functor = $PS["Data.Functor"];
  var functorST = new Data_Functor.Functor($foreign.map_);
  var monadST = new Control_Monad.Monad(function () {
      return applicativeST;
  }, function () {
      return bindST;
  });
  var bindST = new Control_Bind.Bind(function () {
      return applyST;
  }, $foreign.bind_);
  var applyST = new Control_Apply.Apply(function () {
      return functorST;
  }, Control_Monad.ap(monadST));
  var applicativeST = new Control_Applicative.Applicative(function () {
      return applyST;
  }, $foreign.pure_);
  exports["functorST"] = functorST;
  exports["applicativeST"] = applicativeST;
  exports["bindST"] = bindST;
  exports["monadST"] = monadST;
  exports["foreach"] = $foreign.foreach;
})(PS);
(function(exports) {
  "use strict";

  //------------------------------------------------------------------------------
  // Array creation --------------------------------------------------------------
  //------------------------------------------------------------------------------

  exports.range = function (start) {
    return function (end) {
      var step = start > end ? -1 : 1;
      var result = new Array(step * (end - start) + 1);
      var i = start, n = 0;
      while (i !== end) {
        result[n++] = i;
        i += step;
      }
      result[n] = i;
      return result;
    };
  };                                                                                                 

  exports.fromFoldableImpl = (function () {
    function Cons(head, tail) {
      this.head = head;
      this.tail = tail;
    }
    var emptyList = {};

    function curryCons(head) {
      return function (tail) {
        return new Cons(head, tail);
      };
    }

    function listToArray(list) {
      var result = [];
      var count = 0;
      var xs = list;
      while (xs !== emptyList) {
        result[count++] = xs.head;
        xs = xs.tail;
      }
      return result;
    }

    return function (foldr) {
      return function (xs) {
        return listToArray(foldr(curryCons)(emptyList)(xs));
      };
    };
  })();

  //------------------------------------------------------------------------------
  // Array size ------------------------------------------------------------------
  //------------------------------------------------------------------------------

  exports.length = function (xs) {
    return xs.length;
  };

  //------------------------------------------------------------------------------
  // Non-indexed reads -----------------------------------------------------------
  //------------------------------------------------------------------------------

  exports.unconsImpl = function (empty) {
    return function (next) {
      return function (xs) {
        return xs.length === 0 ? empty({}) : next(xs[0])(xs.slice(1));
      };
    };
  };

  //------------------------------------------------------------------------------
  // Indexed operations ----------------------------------------------------------
  //------------------------------------------------------------------------------

  exports.indexImpl = function (just) {
    return function (nothing) {
      return function (xs) {
        return function (i) {
          return i < 0 || i >= xs.length ? nothing :  just(xs[i]);
        };
      };
    };
  };

  exports.findIndexImpl = function (just) {
    return function (nothing) {
      return function (f) {
        return function (xs) {
          for (var i = 0, l = xs.length; i < l; i++) {
            if (f(xs[i])) return just(i);
          }
          return nothing;
        };
      };
    };
  };

  exports._deleteAt = function (just) {
    return function (nothing) {
      return function (i) {
        return function (l) {
          if (i < 0 || i >= l.length) return nothing;
          var l1 = l.slice();
          l1.splice(i, 1);
          return just(l1);
        };
      };
    };
  };

  exports._updateAt = function (just) {
    return function (nothing) {
      return function (i) {
        return function (a) {
          return function (l) {
            if (i < 0 || i >= l.length) return nothing;
            var l1 = l.slice();
            l1[i] = a;
            return just(l1);
          };
        };
      };
    };
  };

  //------------------------------------------------------------------------------
  // Transformations -------------------------------------------------------------
  //------------------------------------------------------------------------------

  exports.reverse = function (l) {
    return l.slice().reverse();
  };

  exports.concat = function (xss) {
    if (xss.length <= 10000) {
      // This method is faster, but it crashes on big arrays.
      // So we use it when can and fallback to simple variant otherwise.
      return Array.prototype.concat.apply([], xss);
    }

    var result = [];
    for (var i = 0, l = xss.length; i < l; i++) {
      var xs = xss[i];
      for (var j = 0, m = xs.length; j < m; j++) {
        result.push(xs[j]);
      }
    }
    return result;
  };

  exports.filter = function (f) {
    return function (xs) {
      return xs.filter(f);
    };
  };

  //------------------------------------------------------------------------------
  // Sorting ---------------------------------------------------------------------
  //------------------------------------------------------------------------------

  exports.sortByImpl = (function () {
    function mergeFromTo(compare, fromOrdering, xs1, xs2, from, to) {
      var mid;
      var i;
      var j;
      var k;
      var x;
      var y;
      var c;

      mid = from + ((to - from) >> 1);
      if (mid - from > 1) mergeFromTo(compare, fromOrdering, xs2, xs1, from, mid);
      if (to - mid > 1) mergeFromTo(compare, fromOrdering, xs2, xs1, mid, to);

      i = from;
      j = mid;
      k = from;
      while (i < mid && j < to) {
        x = xs2[i];
        y = xs2[j];
        c = fromOrdering(compare(x)(y));
        if (c > 0) {
          xs1[k++] = y;
          ++j;
        }
        else {
          xs1[k++] = x;
          ++i;
        }
      }
      while (i < mid) {
        xs1[k++] = xs2[i++];
      }
      while (j < to) {
        xs1[k++] = xs2[j++];
      }
    }

    return function (compare) {
      return function (fromOrdering) {
        return function (xs) {
          var out;

          if (xs.length < 2) return xs;

          out = xs.slice(0);
          mergeFromTo(compare, fromOrdering, out, xs.slice(0), 0, xs.length);

          return out;
        };
      };
    };
  })();

  //------------------------------------------------------------------------------
  // Subarrays -------------------------------------------------------------------
  //------------------------------------------------------------------------------

  exports.slice = function (s) {
    return function (e) {
      return function (l) {
        return l.slice(s, e);
      };
    };
  };

  //------------------------------------------------------------------------------
  // Zipping ---------------------------------------------------------------------
  //------------------------------------------------------------------------------

  exports.zipWith = function (f) {
    return function (xs) {
      return function (ys) {
        var l = xs.length < ys.length ? xs.length : ys.length;
        var result = new Array(l);
        for (var i = 0; i < l; i++) {
          result[i] = f(xs[i])(ys[i]);
        }
        return result;
      };
    };
  };

  //------------------------------------------------------------------------------
  // Partial ---------------------------------------------------------------------
  //------------------------------------------------------------------------------

  exports.unsafeIndexImpl = function (xs) {
    return function (n) {
      return xs[n];
    };
  };
})(PS["Data.Array"] = PS["Data.Array"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Lazy"] = $PS["Control.Lazy"] || {};
  var exports = $PS["Control.Lazy"];               
  var Lazy = function (defer) {
      this.defer = defer;
  }; 
  var defer = function (dict) {
      return dict.defer;
  };
  var fix = function (dictLazy) {
      return function (f) {
          var go = defer(dictLazy)(function (v) {
              return f(go);
          });
          return go;
      };
  };
  exports["defer"] = defer;
  exports["Lazy"] = Lazy;
  exports["fix"] = fix;
})(PS);
(function(exports) {
  "use strict";

  exports.poke = function (i) {
    return function (a) {
      return function (xs) {
        return function () {
          var ret = i >= 0 && i < xs.length;
          if (ret) xs[i] = a;
          return ret;
        };
      };
    };
  };

  exports.pushAll = function (as) {
    return function (xs) {
      return function () {
        return xs.push.apply(xs, as);
      };
    };
  };

  exports.unsafeFreeze = function (xs) {
    return function () {
      return xs;
    };
  };

  function copyImpl(xs) {
    return function () {
      return xs.slice();
    };
  }                         

  exports.thaw = copyImpl;
})(PS["Data.Array.ST"] = PS["Data.Array.ST"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Array.ST"] = $PS["Data.Array.ST"] || {};
  var exports = $PS["Data.Array.ST"];
  var $foreign = $PS["Data.Array.ST"];                     
  var withArray = function (f) {
      return function (xs) {
          return function __do() {
              var result = $foreign.thaw(xs)();
              f(result)();
              return $foreign.unsafeFreeze(result)();
          };
      };
  };
  var push = function (a) {
      return $foreign.pushAll([ a ]);
  };
  exports["withArray"] = withArray;
  exports["push"] = push;
  exports["poke"] = $foreign.poke;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Boolean"] = $PS["Data.Boolean"] || {};
  var exports = $PS["Data.Boolean"];
  var otherwise = true;
  exports["otherwise"] = otherwise;
})(PS);
(function(exports) {
  "use strict";

  exports.foldrArray = function (f) {
    return function (init) {
      return function (xs) {
        var acc = init;
        var len = xs.length;
        for (var i = len - 1; i >= 0; i--) {
          acc = f(xs[i])(acc);
        }
        return acc;
      };
    };
  };

  exports.foldlArray = function (f) {
    return function (init) {
      return function (xs) {
        var acc = init;
        var len = xs.length;
        for (var i = 0; i < len; i++) {
          acc = f(acc)(xs[i]);
        }
        return acc;
      };
    };
  };
})(PS["Data.Foldable"] = PS["Data.Foldable"] || {});
(function(exports) {
  "use strict";

  exports.boolConj = function (b1) {
    return function (b2) {
      return b1 && b2;
    };
  };

  exports.boolDisj = function (b1) {
    return function (b2) {
      return b1 || b2;
    };
  };

  exports.boolNot = function (b) {
    return !b;
  };
})(PS["Data.HeytingAlgebra"] = PS["Data.HeytingAlgebra"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.HeytingAlgebra"] = $PS["Data.HeytingAlgebra"] || {};
  var exports = $PS["Data.HeytingAlgebra"];
  var $foreign = $PS["Data.HeytingAlgebra"];
  var HeytingAlgebra = function (conj, disj, ff, implies, not, tt) {
      this.conj = conj;
      this.disj = disj;
      this.ff = ff;
      this.implies = implies;
      this.not = not;
      this.tt = tt;
  };
  var tt = function (dict) {
      return dict.tt;
  };
  var not = function (dict) {
      return dict.not;
  };
  var implies = function (dict) {
      return dict.implies;
  };
  var ff = function (dict) {
      return dict.ff;
  };
  var disj = function (dict) {
      return dict.disj;
  };
  var heytingAlgebraBoolean = new HeytingAlgebra($foreign.boolConj, $foreign.boolDisj, false, function (a) {
      return function (b) {
          return disj(heytingAlgebraBoolean)(not(heytingAlgebraBoolean)(a))(b);
      };
  }, $foreign.boolNot, true);
  var conj = function (dict) {
      return dict.conj;
  };
  var heytingAlgebraFunction = function (dictHeytingAlgebra) {
      return new HeytingAlgebra(function (f) {
          return function (g) {
              return function (a) {
                  return conj(dictHeytingAlgebra)(f(a))(g(a));
              };
          };
      }, function (f) {
          return function (g) {
              return function (a) {
                  return disj(dictHeytingAlgebra)(f(a))(g(a));
              };
          };
      }, function (v) {
          return ff(dictHeytingAlgebra);
      }, function (f) {
          return function (g) {
              return function (a) {
                  return implies(dictHeytingAlgebra)(f(a))(g(a));
              };
          };
      }, function (f) {
          return function (a) {
              return not(dictHeytingAlgebra)(f(a));
          };
      }, function (v) {
          return tt(dictHeytingAlgebra);
      });
  };
  exports["tt"] = tt;
  exports["ff"] = ff;
  exports["conj"] = conj;
  exports["disj"] = disj;
  exports["not"] = not;
  exports["heytingAlgebraBoolean"] = heytingAlgebraBoolean;
  exports["heytingAlgebraFunction"] = heytingAlgebraFunction;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Monoid"] = $PS["Data.Monoid"] || {};
  var exports = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Record_Unsafe = $PS["Record.Unsafe"];
  var Type_Proxy = $PS["Type.Proxy"];                
  var MonoidRecord = function (SemigroupRecord0, memptyRecord) {
      this.SemigroupRecord0 = SemigroupRecord0;
      this.memptyRecord = memptyRecord;
  };
  var Monoid = function (Semigroup0, mempty) {
      this.Semigroup0 = Semigroup0;
      this.mempty = mempty;
  };
  var monoidUnit = new Monoid(function () {
      return Data_Semigroup.semigroupUnit;
  }, Data_Unit.unit);
  var monoidString = new Monoid(function () {
      return Data_Semigroup.semigroupString;
  }, "");
  var monoidRecordNil = new MonoidRecord(function () {
      return Data_Semigroup.semigroupRecordNil;
  }, function (v) {
      return {};
  });                        
  var monoidArray = new Monoid(function () {
      return Data_Semigroup.semigroupArray;
  }, [  ]);
  var memptyRecord = function (dict) {
      return dict.memptyRecord;
  };
  var monoidRecord = function (dictRowToList) {
      return function (dictMonoidRecord) {
          return new Monoid(function () {
              return Data_Semigroup.semigroupRecord()(dictMonoidRecord.SemigroupRecord0());
          }, memptyRecord(dictMonoidRecord)(Type_Proxy["Proxy"].value));
      };
  };
  var mempty = function (dict) {
      return dict.mempty;
  };
  var monoidFn = function (dictMonoid) {
      return new Monoid(function () {
          return Data_Semigroup.semigroupFn(dictMonoid.Semigroup0());
      }, function (v) {
          return mempty(dictMonoid);
      });
  };
  var monoidRecordCons = function (dictIsSymbol) {
      return function (dictMonoid) {
          return function (dictCons) {
              return function (dictMonoidRecord) {
                  return new MonoidRecord(function () {
                      return Data_Semigroup.semigroupRecordCons(dictIsSymbol)()(dictMonoidRecord.SemigroupRecord0())(dictMonoid.Semigroup0());
                  }, function (v) {
                      var tail = memptyRecord(dictMonoidRecord)(Type_Proxy["Proxy"].value);
                      var key = Data_Symbol.reflectSymbol(dictIsSymbol)(Type_Proxy["Proxy"].value);
                      var insert = Record_Unsafe.unsafeSet(key);
                      return insert(mempty(dictMonoid))(tail);
                  });
              };
          };
      };
  };
  exports["Monoid"] = Monoid;
  exports["mempty"] = mempty;
  exports["monoidUnit"] = monoidUnit;
  exports["monoidFn"] = monoidFn;
  exports["monoidString"] = monoidString;
  exports["monoidArray"] = monoidArray;
  exports["monoidRecord"] = monoidRecord;
  exports["monoidRecordNil"] = monoidRecordNil;
  exports["monoidRecordCons"] = monoidRecordCons;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Monoid.Conj"] = $PS["Data.Monoid.Conj"] || {};
  var exports = $PS["Data.Monoid.Conj"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];      
  var Conj = function (x) {
      return x;
  };
  var semigroupConj = function (dictHeytingAlgebra) {
      return new Data_Semigroup.Semigroup(function (v) {
          return function (v1) {
              return Data_HeytingAlgebra.conj(dictHeytingAlgebra)(v)(v1);
          };
      });
  };
  var monoidConj = function (dictHeytingAlgebra) {
      return new Data_Monoid.Monoid(function () {
          return semigroupConj(dictHeytingAlgebra);
      }, Data_HeytingAlgebra.tt(dictHeytingAlgebra));
  };
  exports["Conj"] = Conj;
  exports["monoidConj"] = monoidConj;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Monoid.Disj"] = $PS["Data.Monoid.Disj"] || {};
  var exports = $PS["Data.Monoid.Disj"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];      
  var Disj = function (x) {
      return x;
  };
  var semigroupDisj = function (dictHeytingAlgebra) {
      return new Data_Semigroup.Semigroup(function (v) {
          return function (v1) {
              return Data_HeytingAlgebra.disj(dictHeytingAlgebra)(v)(v1);
          };
      });
  };
  var monoidDisj = function (dictHeytingAlgebra) {
      return new Data_Monoid.Monoid(function () {
          return semigroupDisj(dictHeytingAlgebra);
      }, Data_HeytingAlgebra.ff(dictHeytingAlgebra));
  };
  exports["Disj"] = Disj;
  exports["monoidDisj"] = monoidDisj;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Monoid.Endo"] = $PS["Data.Monoid.Endo"] || {};
  var exports = $PS["Data.Monoid.Endo"];
  var Control_Category = $PS["Control.Category"];
  var Control_Semigroupoid = $PS["Control.Semigroupoid"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];      
  var Endo = function (x) {
      return x;
  };
  var semigroupEndo = function (dictSemigroupoid) {
      return new Data_Semigroup.Semigroup(function (v) {
          return function (v1) {
              return Control_Semigroupoid.compose(dictSemigroupoid)(v)(v1);
          };
      });
  };
  var monoidEndo = function (dictCategory) {
      return new Data_Monoid.Monoid(function () {
          return semigroupEndo(dictCategory.Semigroupoid0());
      }, Control_Category.identity(dictCategory));
  };
  exports["Endo"] = Endo;
  exports["monoidEndo"] = monoidEndo;
})(PS);
(function(exports) {
  "use strict";

  var unsafeCompareImpl = function (lt) {
    return function (eq) {
      return function (gt) {
        return function (x) {
          return function (y) {
            return x < y ? lt : x === y ? eq : gt;
          };
        };
      };
    };
  };

  exports.ordBooleanImpl = unsafeCompareImpl;
  exports.ordIntImpl = unsafeCompareImpl;
  exports.ordNumberImpl = unsafeCompareImpl;
  exports.ordStringImpl = unsafeCompareImpl;
  exports.ordCharImpl = unsafeCompareImpl;
})(PS["Data.Ord"] = PS["Data.Ord"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Ordering"] = $PS["Data.Ordering"] || {};
  var exports = $PS["Data.Ordering"];
  var Data_Eq = $PS["Data.Eq"];                    
  var LT = (function () {
      function LT() {

      };
      LT.value = new LT();
      return LT;
  })();
  var GT = (function () {
      function GT() {

      };
      GT.value = new GT();
      return GT;
  })();
  var EQ = (function () {
      function EQ() {

      };
      EQ.value = new EQ();
      return EQ;
  })();
  var invert = function (v) {
      if (v instanceof GT) {
          return LT.value;
      };
      if (v instanceof EQ) {
          return EQ.value;
      };
      if (v instanceof LT) {
          return GT.value;
      };
      throw new Error("Failed pattern match at Data.Ordering (line 33, column 1 - line 33, column 31): " + [ v.constructor.name ]);
  };
  var eqOrdering = new Data_Eq.Eq(function (v) {
      return function (v1) {
          if (v instanceof LT && v1 instanceof LT) {
              return true;
          };
          if (v instanceof GT && v1 instanceof GT) {
              return true;
          };
          if (v instanceof EQ && v1 instanceof EQ) {
              return true;
          };
          return false;
      };
  });
  exports["LT"] = LT;
  exports["GT"] = GT;
  exports["EQ"] = EQ;
  exports["invert"] = invert;
  exports["eqOrdering"] = eqOrdering;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Ord"] = $PS["Data.Ord"] || {};
  var exports = $PS["Data.Ord"];
  var $foreign = $PS["Data.Ord"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Ordering = $PS["Data.Ordering"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Record_Unsafe = $PS["Record.Unsafe"];
  var Type_Proxy = $PS["Type.Proxy"];                
  var OrdRecord = function (EqRecord0, compareRecord) {
      this.EqRecord0 = EqRecord0;
      this.compareRecord = compareRecord;
  };
  var Ord = function (Eq0, compare) {
      this.Eq0 = Eq0;
      this.compare = compare;
  }; 
  var ordString = new Ord(function () {
      return Data_Eq.eqString;
  }, $foreign.ordStringImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value));
  var ordRecordNil = new OrdRecord(function () {
      return Data_Eq.eqRowNil;
  }, function (v) {
      return function (v1) {
          return function (v2) {
              return Data_Ordering.EQ.value;
          };
      };
  });
  var ordNumber = new Ord(function () {
      return Data_Eq.eqNumber;
  }, $foreign.ordNumberImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value));
  var ordInt = new Ord(function () {
      return Data_Eq.eqInt;
  }, $foreign.ordIntImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value));
  var ordChar = new Ord(function () {
      return Data_Eq.eqChar;
  }, $foreign.ordCharImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value));
  var ordBoolean = new Ord(function () {
      return Data_Eq.eqBoolean;
  }, $foreign.ordBooleanImpl(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value));
  var compareRecord = function (dict) {
      return dict.compareRecord;
  };
  var ordRecord = function (dictRowToList) {
      return function (dictOrdRecord) {
          return new Ord(function () {
              return Data_Eq.eqRec()(dictOrdRecord.EqRecord0());
          }, compareRecord(dictOrdRecord)(Type_Proxy["Proxy"].value));
      };
  };
  var compare = function (dict) {
      return dict.compare;
  };
  var comparing = function (dictOrd) {
      return function (f) {
          return function (x) {
              return function (y) {
                  return compare(dictOrd)(f(x))(f(y));
              };
          };
      };
  };
  var greaterThan = function (dictOrd) {
      return function (a1) {
          return function (a2) {
              var v = compare(dictOrd)(a1)(a2);
              if (v instanceof Data_Ordering.GT) {
                  return true;
              };
              return false;
          };
      };
  };
  var greaterThanOrEq = function (dictOrd) {
      return function (a1) {
          return function (a2) {
              var v = compare(dictOrd)(a1)(a2);
              if (v instanceof Data_Ordering.LT) {
                  return false;
              };
              return true;
          };
      };
  };
  var lessThan = function (dictOrd) {
      return function (a1) {
          return function (a2) {
              var v = compare(dictOrd)(a1)(a2);
              if (v instanceof Data_Ordering.LT) {
                  return true;
              };
              return false;
          };
      };
  };
  var lessThanOrEq = function (dictOrd) {
      return function (a1) {
          return function (a2) {
              var v = compare(dictOrd)(a1)(a2);
              if (v instanceof Data_Ordering.GT) {
                  return false;
              };
              return true;
          };
      };
  };
  var max = function (dictOrd) {
      return function (x) {
          return function (y) {
              var v = compare(dictOrd)(x)(y);
              if (v instanceof Data_Ordering.LT) {
                  return y;
              };
              if (v instanceof Data_Ordering.EQ) {
                  return x;
              };
              if (v instanceof Data_Ordering.GT) {
                  return x;
              };
              throw new Error("Failed pattern match at Data.Ord (line 176, column 3 - line 179, column 12): " + [ v.constructor.name ]);
          };
      };
  };
  var min = function (dictOrd) {
      return function (x) {
          return function (y) {
              var v = compare(dictOrd)(x)(y);
              if (v instanceof Data_Ordering.LT) {
                  return x;
              };
              if (v instanceof Data_Ordering.EQ) {
                  return x;
              };
              if (v instanceof Data_Ordering.GT) {
                  return y;
              };
              throw new Error("Failed pattern match at Data.Ord (line 167, column 3 - line 170, column 12): " + [ v.constructor.name ]);
          };
      };
  }; 
  var ordRecordCons = function (dictOrdRecord) {
      return function (dictCons) {
          return function (dictIsSymbol) {
              return function (dictOrd) {
                  return new OrdRecord(function () {
                      return Data_Eq.eqRowCons(dictOrdRecord.EqRecord0())()(dictIsSymbol)(dictOrd.Eq0());
                  }, function (v) {
                      return function (ra) {
                          return function (rb) {
                              var key = Data_Symbol.reflectSymbol(dictIsSymbol)(Type_Proxy["Proxy"].value);
                              var left = compare(dictOrd)(Record_Unsafe.unsafeGet(key)(ra))(Record_Unsafe.unsafeGet(key)(rb));
                              var $55 = Data_Eq.notEq(Data_Ordering.eqOrdering)(left)(Data_Ordering.EQ.value);
                              if ($55) {
                                  return left;
                              };
                              return compareRecord(dictOrdRecord)(Type_Proxy["Proxy"].value)(ra)(rb);
                          };
                      };
                  });
              };
          };
      };
  };
  var clamp = function (dictOrd) {
      return function (low) {
          return function (hi) {
              return function (x) {
                  return min(dictOrd)(hi)(max(dictOrd)(low)(x));
              };
          };
      };
  };
  var between = function (dictOrd) {
      return function (low) {
          return function (hi) {
              return function (x) {
                  if (lessThan(dictOrd)(x)(low)) {
                      return false;
                  };
                  if (greaterThan(dictOrd)(x)(hi)) {
                      return false;
                  };
                  return true;
              };
          };
      };
  };
  exports["Ord"] = Ord;
  exports["compare"] = compare;
  exports["lessThan"] = lessThan;
  exports["lessThanOrEq"] = lessThanOrEq;
  exports["greaterThanOrEq"] = greaterThanOrEq;
  exports["comparing"] = comparing;
  exports["min"] = min;
  exports["max"] = max;
  exports["clamp"] = clamp;
  exports["between"] = between;
  exports["ordBoolean"] = ordBoolean;
  exports["ordInt"] = ordInt;
  exports["ordNumber"] = ordNumber;
  exports["ordString"] = ordString;
  exports["ordChar"] = ordChar;
  exports["ordRecordNil"] = ordRecordNil;
  exports["ordRecordCons"] = ordRecordCons;
  exports["ordRecord"] = ordRecord;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Foldable"] = $PS["Data.Foldable"] || {};
  var exports = $PS["Data.Foldable"];
  var $foreign = $PS["Data.Foldable"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Category = $PS["Control.Category"];
  var Control_Plus = $PS["Control.Plus"];
  var Data_Either = $PS["Data.Either"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Monoid_Conj = $PS["Data.Monoid.Conj"];
  var Data_Monoid_Disj = $PS["Data.Monoid.Disj"];
  var Data_Monoid_Endo = $PS["Data.Monoid.Endo"];
  var Data_Newtype = $PS["Data.Newtype"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ordering = $PS["Data.Ordering"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Unit = $PS["Data.Unit"];                
  var Foldable = function (foldMap, foldl, foldr) {
      this.foldMap = foldMap;
      this.foldl = foldl;
      this.foldr = foldr;
  };
  var foldr = function (dict) {
      return dict.foldr;
  };
  var oneOf = function (dictFoldable) {
      return function (dictPlus) {
          return foldr(dictFoldable)(Control_Alt.alt(dictPlus.Alt0()))(Control_Plus.empty(dictPlus));
      };
  };
  var traverse_ = function (dictApplicative) {
      return function (dictFoldable) {
          return function (f) {
              return foldr(dictFoldable)((function () {
                  var $313 = Control_Apply.applySecond(dictApplicative.Apply0());
                  return function ($314) {
                      return $313(f($314));
                  };
              })())(Control_Applicative.pure(dictApplicative)(Data_Unit.unit));
          };
      };
  };
  var sequence_ = function (dictApplicative) {
      return function (dictFoldable) {
          return traverse_(dictApplicative)(dictFoldable)(Control_Category.identity(Control_Category.categoryFn));
      };
  };
  var foldl = function (dict) {
      return dict.foldl;
  };
  var indexl = function (dictFoldable) {
      return function (idx) {
          var go = function (cursor) {
              return function (a) {
                  if (cursor.elem instanceof Data_Maybe.Just) {
                      return cursor;
                  };
                  var $155 = cursor.pos === idx;
                  if ($155) {
                      return {
                          elem: new Data_Maybe.Just(a),
                          pos: cursor.pos
                      };
                  };
                  return {
                      pos: cursor.pos + 1 | 0,
                      elem: cursor.elem
                  };
              };
          };
          var $315 = foldl(dictFoldable)(go)({
              elem: Data_Maybe.Nothing.value,
              pos: 0
          });
          return function ($316) {
              return (function (v) {
                  return v.elem;
              })($315($316));
          };
      };
  };
  var intercalate = function (dictFoldable) {
      return function (dictMonoid) {
          return function (sep) {
              return function (xs) {
                  var go = function (v) {
                      return function (x) {
                          if (v.init) {
                              return {
                                  init: false,
                                  acc: x
                              };
                          };
                          return {
                              init: false,
                              acc: Data_Semigroup.append(dictMonoid.Semigroup0())(v.acc)(Data_Semigroup.append(dictMonoid.Semigroup0())(sep)(x))
                          };
                      };
                  };
                  return (foldl(dictFoldable)(go)({
                      init: true,
                      acc: Data_Monoid.mempty(dictMonoid)
                  })(xs)).acc;
              };
          };
      };
  };
  var minimumBy = function (dictFoldable) {
      return function (cmp) {
          var min$prime = function (v) {
              return function (v1) {
                  if (v instanceof Data_Maybe.Nothing) {
                      return new Data_Maybe.Just(v1);
                  };
                  if (v instanceof Data_Maybe.Just) {
                      return new Data_Maybe.Just((function () {
                          var $166 = Data_Eq.eq(Data_Ordering.eqOrdering)(cmp(v.value0)(v1))(Data_Ordering.LT.value);
                          if ($166) {
                              return v.value0;
                          };
                          return v1;
                      })());
                  };
                  throw new Error("Failed pattern match at Data.Foldable (line 454, column 3 - line 454, column 27): " + [ v.constructor.name, v1.constructor.name ]);
              };
          };
          return foldl(dictFoldable)(min$prime)(Data_Maybe.Nothing.value);
      };
  };
  var minimum = function (dictOrd) {
      return function (dictFoldable) {
          return minimumBy(dictFoldable)(Data_Ord.compare(dictOrd));
      };
  }; 
  var foldableMaybe = new Foldable(function (dictMonoid) {
      return function (v) {
          return function (v1) {
              if (v1 instanceof Data_Maybe.Nothing) {
                  return Data_Monoid.mempty(dictMonoid);
              };
              if (v1 instanceof Data_Maybe.Just) {
                  return v(v1.value0);
              };
              throw new Error("Failed pattern match at Data.Foldable (line 138, column 1 - line 144, column 27): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
  }, function (v) {
      return function (z) {
          return function (v1) {
              if (v1 instanceof Data_Maybe.Nothing) {
                  return z;
              };
              if (v1 instanceof Data_Maybe.Just) {
                  return v(z)(v1.value0);
              };
              throw new Error("Failed pattern match at Data.Foldable (line 138, column 1 - line 144, column 27): " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]);
          };
      };
  }, function (v) {
      return function (z) {
          return function (v1) {
              if (v1 instanceof Data_Maybe.Nothing) {
                  return z;
              };
              if (v1 instanceof Data_Maybe.Just) {
                  return v(v1.value0)(z);
              };
              throw new Error("Failed pattern match at Data.Foldable (line 138, column 1 - line 144, column 27): " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]);
          };
      };
  });
  var foldableEither = new Foldable(function (dictMonoid) {
      return function (v) {
          return function (v1) {
              if (v1 instanceof Data_Either.Left) {
                  return Data_Monoid.mempty(dictMonoid);
              };
              if (v1 instanceof Data_Either.Right) {
                  return v(v1.value0);
              };
              throw new Error("Failed pattern match at Data.Foldable (line 181, column 1 - line 187, column 28): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
  }, function (v) {
      return function (z) {
          return function (v1) {
              if (v1 instanceof Data_Either.Left) {
                  return z;
              };
              if (v1 instanceof Data_Either.Right) {
                  return v(z)(v1.value0);
              };
              throw new Error("Failed pattern match at Data.Foldable (line 181, column 1 - line 187, column 28): " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]);
          };
      };
  }, function (v) {
      return function (z) {
          return function (v1) {
              if (v1 instanceof Data_Either.Left) {
                  return z;
              };
              if (v1 instanceof Data_Either.Right) {
                  return v(v1.value0)(z);
              };
              throw new Error("Failed pattern match at Data.Foldable (line 181, column 1 - line 187, column 28): " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]);
          };
      };
  });
  var foldMapDefaultR = function (dictFoldable) {
      return function (dictMonoid) {
          return function (f) {
              return foldr(dictFoldable)(function (x) {
                  return function (acc) {
                      return Data_Semigroup.append(dictMonoid.Semigroup0())(f(x))(acc);
                  };
              })(Data_Monoid.mempty(dictMonoid));
          };
      };
  };
  var foldableArray = new Foldable(function (dictMonoid) {
      return foldMapDefaultR(foldableArray)(dictMonoid);
  }, $foreign.foldlArray, $foreign.foldrArray);
  var foldMapDefaultL = function (dictFoldable) {
      return function (dictMonoid) {
          return function (f) {
              return foldl(dictFoldable)(function (acc) {
                  return function (x) {
                      return Data_Semigroup.append(dictMonoid.Semigroup0())(acc)(f(x));
                  };
              })(Data_Monoid.mempty(dictMonoid));
          };
      };
  };
  var foldMap = function (dict) {
      return dict.foldMap;
  };
  var foldrDefault = function (dictFoldable) {
      return function (c) {
          return function (u) {
              return function (xs) {
                  return Data_Newtype.unwrap()(foldMap(dictFoldable)(Data_Monoid_Endo.monoidEndo(Control_Category.categoryFn))(function ($319) {
                      return Data_Monoid_Endo.Endo(c($319));
                  })(xs))(u);
              };
          };
      };
  };
  var fold = function (dictFoldable) {
      return function (dictMonoid) {
          return foldMap(dictFoldable)(dictMonoid)(Control_Category.identity(Control_Category.categoryFn));
      };
  };
  var find = function (dictFoldable) {
      return function (p) {
          var go = function (v) {
              return function (v1) {
                  if (v instanceof Data_Maybe.Nothing && p(v1)) {
                      return new Data_Maybe.Just(v1);
                  };
                  return v;
              };
          };
          return foldl(dictFoldable)(go)(Data_Maybe.Nothing.value);
      };
  };
  var any = function (dictFoldable) {
      return function (dictHeytingAlgebra) {
          return Data_Newtype.alaF()()()()(Data_Monoid_Disj.Disj)(foldMap(dictFoldable)(Data_Monoid_Disj.monoidDisj(dictHeytingAlgebra)));
      };
  };
  var elem = function (dictFoldable) {
      return function (dictEq) {
          var $323 = any(dictFoldable)(Data_HeytingAlgebra.heytingAlgebraBoolean);
          var $324 = Data_Eq.eq(dictEq);
          return function ($325) {
              return $323($324($325));
          };
      };
  };
  var notElem = function (dictFoldable) {
      return function (dictEq) {
          return function (x) {
              var $326 = Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean);
              var $327 = elem(dictFoldable)(dictEq)(x);
              return function ($328) {
                  return $326($327($328));
              };
          };
      };
  };
  var all = function (dictFoldable) {
      return function (dictHeytingAlgebra) {
          return Data_Newtype.alaF()()()()(Data_Monoid_Conj.Conj)(foldMap(dictFoldable)(Data_Monoid_Conj.monoidConj(dictHeytingAlgebra)));
      };
  };
  exports["Foldable"] = Foldable;
  exports["foldr"] = foldr;
  exports["foldl"] = foldl;
  exports["foldMap"] = foldMap;
  exports["foldrDefault"] = foldrDefault;
  exports["foldMapDefaultL"] = foldMapDefaultL;
  exports["fold"] = fold;
  exports["traverse_"] = traverse_;
  exports["sequence_"] = sequence_;
  exports["oneOf"] = oneOf;
  exports["intercalate"] = intercalate;
  exports["all"] = all;
  exports["any"] = any;
  exports["elem"] = elem;
  exports["notElem"] = notElem;
  exports["indexl"] = indexl;
  exports["find"] = find;
  exports["minimum"] = minimum;
  exports["foldableArray"] = foldableArray;
  exports["foldableMaybe"] = foldableMaybe;
  exports["foldableEither"] = foldableEither;
})(PS);
(function(exports) {
  "use strict";

  exports.unfoldrArrayImpl = function (isNothing) {
    return function (fromJust) {
      return function (fst) {
        return function (snd) {
          return function (f) {
            return function (b) {
              var result = [];
              var value = b;
              while (true) { // eslint-disable-line no-constant-condition
                var maybe = f(value);
                if (isNothing(maybe)) return result;
                var tuple = fromJust(maybe);
                result.push(fst(tuple));
                value = snd(tuple);
              }
            };
          };
        };
      };
    };
  };
})(PS["Data.Unfoldable"] = PS["Data.Unfoldable"] || {});
(function(exports) {
  "use strict";

  exports.unfoldr1ArrayImpl = function (isNothing) {
    return function (fromJust) {
      return function (fst) {
        return function (snd) {
          return function (f) {
            return function (b) {
              var result = [];
              var value = b;
              while (true) { // eslint-disable-line no-constant-condition
                var tuple = f(value);
                result.push(fst(tuple));
                var maybe = snd(tuple);
                if (isNothing(maybe)) return result;
                value = fromJust(maybe);
              }
            };
          };
        };
      };
    };
  };
})(PS["Data.Unfoldable1"] = PS["Data.Unfoldable1"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Unfoldable1"] = $PS["Data.Unfoldable1"] || {};
  var exports = $PS["Data.Unfoldable1"];
  var $foreign = $PS["Data.Unfoldable1"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Tuple = $PS["Data.Tuple"];                
  var Unfoldable1 = function (unfoldr1) {
      this.unfoldr1 = unfoldr1;
  }; 
  var unfoldable1Array = new Unfoldable1($foreign.unfoldr1ArrayImpl(Data_Maybe.isNothing)(Data_Maybe.fromJust())(Data_Tuple.fst)(Data_Tuple.snd));
  exports["Unfoldable1"] = Unfoldable1;
  exports["unfoldable1Array"] = unfoldable1Array;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Unfoldable"] = $PS["Data.Unfoldable"] || {};
  var exports = $PS["Data.Unfoldable"];
  var $foreign = $PS["Data.Unfoldable"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable1 = $PS["Data.Unfoldable1"];  
  var Unfoldable = function (Unfoldable10, unfoldr) {
      this.Unfoldable10 = Unfoldable10;
      this.unfoldr = unfoldr;
  };
  var unfoldr = function (dict) {
      return dict.unfoldr;
  }; 
  var unfoldableArray = new Unfoldable(function () {
      return Data_Unfoldable1.unfoldable1Array;
  }, $foreign.unfoldrArrayImpl(Data_Maybe.isNothing)(Data_Maybe.fromJust())(Data_Tuple.fst)(Data_Tuple.snd));
  exports["Unfoldable"] = Unfoldable;
  exports["unfoldr"] = unfoldr;
  exports["unfoldableArray"] = unfoldableArray;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Array"] = $PS["Data.Array"] || {};
  var exports = $PS["Data.Array"];
  var $foreign = $PS["Data.Array"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Lazy = $PS["Control.Lazy"];
  var Control_Monad_ST_Internal = $PS["Control.Monad.ST.Internal"];
  var Data_Array_ST = $PS["Data.Array.ST"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ordering = $PS["Data.Ordering"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var zip = $foreign.zipWith(Data_Tuple.Tuple.create);
  var updateAtIndices = function (dictFoldable) {
      return function (us) {
          return function (xs) {
              return Data_Array_ST.withArray(function (res) {
                  return Data_Foldable.traverse_(Control_Monad_ST_Internal.applicativeST)(dictFoldable)(function (v) {
                      return Data_Array_ST.poke(v.value0)(v.value1)(res);
                  })(us);
              })(xs)();
          };
      };
  };
  var updateAt = $foreign["_updateAt"](Data_Maybe.Just.create)(Data_Maybe.Nothing.value);
  var unsafeIndex = function (dictPartial) {
      return $foreign.unsafeIndexImpl;
  };
  var uncons = $foreign.unconsImpl(Data_Function["const"](Data_Maybe.Nothing.value))(function (x) {
      return function (xs) {
          return new Data_Maybe.Just({
              head: x,
              tail: xs
          });
      };
  });
  var toUnfoldable = function (dictUnfoldable) {
      return function (xs) {
          var len = $foreign.length(xs);
          var f = function (i) {
              if (i < len) {
                  return new Data_Maybe.Just(new Data_Tuple.Tuple(unsafeIndex()(xs)(i), i + 1 | 0));
              };
              if (Data_Boolean.otherwise) {
                  return Data_Maybe.Nothing.value;
              };
              throw new Error("Failed pattern match at Data.Array (line 158, column 3 - line 160, column 26): " + [ i.constructor.name ]);
          };
          return Data_Unfoldable.unfoldr(dictUnfoldable)(f)(0);
      };
  };
  var take = function (n) {
      return function (xs) {
          var $67 = n < 1;
          if ($67) {
              return [  ];
          };
          return $foreign.slice(0)(n)(xs);
      };
  };
  var sortBy = function (comp) {
      return $foreign.sortByImpl(comp)(function (v) {
          if (v instanceof Data_Ordering.GT) {
              return 1;
          };
          if (v instanceof Data_Ordering.EQ) {
              return 0;
          };
          if (v instanceof Data_Ordering.LT) {
              return -1 | 0;
          };
          throw new Error("Failed pattern match at Data.Array (line 831, column 31 - line 834, column 11): " + [ v.constructor.name ]);
      });
  };
  var sortWith = function (dictOrd) {
      return function (f) {
          return sortBy(Data_Ord.comparing(dictOrd)(f));
      };
  };
  var snoc = function (xs) {
      return function (x) {
          return Data_Array_ST.withArray(Data_Array_ST.push(x))(xs)();
      };
  };
  var singleton = function (a) {
      return [ a ];
  };
  var $$null = function (xs) {
      return $foreign.length(xs) === 0;
  };
  var mapWithIndex = function (f) {
      return function (xs) {
          return $foreign.zipWith(f)($foreign.range(0)($foreign.length(xs) - 1 | 0))(xs);
      };
  };
  var index = $foreign.indexImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value);
  var last = function (xs) {
      return index(xs)($foreign.length(xs) - 1 | 0);
  };
  var modifyAt = function (i) {
      return function (f) {
          return function (xs) {
              var go = function (x) {
                  return updateAt(i)(f(x))(xs);
              };
              return Data_Maybe.maybe(Data_Maybe.Nothing.value)(go)(index(xs)(i));
          };
      };
  };
  var head = function (xs) {
      return index(xs)(0);
  };
  var fromFoldable = function (dictFoldable) {
      return $foreign.fromFoldableImpl(Data_Foldable.foldr(dictFoldable));
  };
  var foldr = Data_Foldable.foldr(Data_Foldable.foldableArray);
  var foldl = Data_Foldable.foldl(Data_Foldable.foldableArray);
  var findIndex = $foreign.findIndexImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value);
  var elemIndex = function (dictEq) {
      return function (x) {
          return findIndex(function (v) {
              return Data_Eq.eq(dictEq)(v)(x);
          });
      };
  };
  var elem = function (dictEq) {
      return function (a) {
          return function (arr) {
              return Data_Maybe.isJust(elemIndex(dictEq)(a)(arr));
          };
      };
  };
  var drop = function (n) {
      return function (xs) {
          var $89 = n < 1;
          if ($89) {
              return xs;
          };
          return $foreign.slice(n)($foreign.length(xs))(xs);
      };
  };
  var deleteAt = $foreign["_deleteAt"](Data_Maybe.Just.create)(Data_Maybe.Nothing.value);
  var cons = function (x) {
      return function (xs) {
          return Data_Semigroup.append(Data_Semigroup.semigroupArray)([ x ])(xs);
      };
  };
  var some = function (dictAlternative) {
      return function (dictLazy) {
          return function (v) {
              return Control_Apply.apply((dictAlternative.Applicative0()).Apply0())(Data_Functor.map(((dictAlternative.Plus1()).Alt0()).Functor0())(cons)(v))(Control_Lazy.defer(dictLazy)(function (v1) {
                  return many(dictAlternative)(dictLazy)(v);
              }));
          };
      };
  };
  var many = function (dictAlternative) {
      return function (dictLazy) {
          return function (v) {
              return Control_Alt.alt((dictAlternative.Plus1()).Alt0())(some(dictAlternative)(dictLazy)(v))(Control_Applicative.pure(dictAlternative.Applicative0())([  ]));
          };
      };
  };
  var concatMap = Data_Function.flip(Control_Bind.bind(Control_Bind.bindArray));
  var mapMaybe = function (f) {
      return concatMap((function () {
          var $109 = Data_Maybe.maybe([  ])(singleton);
          return function ($110) {
              return $109(f($110));
          };
      })());
  };
  exports["fromFoldable"] = fromFoldable;
  exports["toUnfoldable"] = toUnfoldable;
  exports["many"] = many;
  exports["null"] = $$null;
  exports["cons"] = cons;
  exports["snoc"] = snoc;
  exports["head"] = head;
  exports["last"] = last;
  exports["uncons"] = uncons;
  exports["index"] = index;
  exports["elem"] = elem;
  exports["elemIndex"] = elemIndex;
  exports["deleteAt"] = deleteAt;
  exports["updateAt"] = updateAt;
  exports["updateAtIndices"] = updateAtIndices;
  exports["modifyAt"] = modifyAt;
  exports["mapMaybe"] = mapMaybe;
  exports["mapWithIndex"] = mapWithIndex;
  exports["foldl"] = foldl;
  exports["sortBy"] = sortBy;
  exports["sortWith"] = sortWith;
  exports["take"] = take;
  exports["drop"] = drop;
  exports["zip"] = zip;
  exports["unsafeIndex"] = unsafeIndex;
  exports["range"] = $foreign.range;
  exports["length"] = $foreign.length;
  exports["reverse"] = $foreign.reverse;
  exports["concat"] = $foreign.concat;
  exports["filter"] = $foreign.filter;
  exports["slice"] = $foreign.slice;
})(PS);
(function(exports) {
  "use strict";

  exports.mapWithIndexArray = function (f) {
    return function (xs) {
      var l = xs.length;
      var result = Array(l);
      for (var i = 0; i < l; i++) {
        result[i] = f(i)(xs[i]);
      }
      return result;
    };
  };
})(PS["Data.FunctorWithIndex"] = PS["Data.FunctorWithIndex"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.FunctorWithIndex"] = $PS["Data.FunctorWithIndex"] || {};
  var exports = $PS["Data.FunctorWithIndex"];
  var $foreign = $PS["Data.FunctorWithIndex"];
  var Data_Functor = $PS["Data.Functor"];          
  var FunctorWithIndex = function (Functor0, mapWithIndex) {
      this.Functor0 = Functor0;
      this.mapWithIndex = mapWithIndex;
  };
  var mapWithIndex = function (dict) {
      return dict.mapWithIndex;
  };
  var functorWithIndexArray = new FunctorWithIndex(function () {
      return Data_Functor.functorArray;
  }, $foreign.mapWithIndexArray);
  exports["FunctorWithIndex"] = FunctorWithIndex;
  exports["mapWithIndex"] = mapWithIndex;
  exports["functorWithIndexArray"] = functorWithIndexArray;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.FoldableWithIndex"] = $PS["Data.FoldableWithIndex"] || {};
  var exports = $PS["Data.FoldableWithIndex"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_FunctorWithIndex = $PS["Data.FunctorWithIndex"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Tuple = $PS["Data.Tuple"];              
  var FoldableWithIndex = function (Foldable0, foldMapWithIndex, foldlWithIndex, foldrWithIndex) {
      this.Foldable0 = Foldable0;
      this.foldMapWithIndex = foldMapWithIndex;
      this.foldlWithIndex = foldlWithIndex;
      this.foldrWithIndex = foldrWithIndex;
  };
  var foldrWithIndex = function (dict) {
      return dict.foldrWithIndex;
  };
  var foldlWithIndex = function (dict) {
      return dict.foldlWithIndex;
  };
  var foldMapWithIndexDefaultR = function (dictFoldableWithIndex) {
      return function (dictMonoid) {
          return function (f) {
              return foldrWithIndex(dictFoldableWithIndex)(function (i) {
                  return function (x) {
                      return function (acc) {
                          return Data_Semigroup.append(dictMonoid.Semigroup0())(f(i)(x))(acc);
                      };
                  };
              })(Data_Monoid.mempty(dictMonoid));
          };
      };
  };
  var foldableWithIndexArray = new FoldableWithIndex(function () {
      return Data_Foldable.foldableArray;
  }, function (dictMonoid) {
      return foldMapWithIndexDefaultR(foldableWithIndexArray)(dictMonoid);
  }, function (f) {
      return function (z) {
          var $164 = Data_Foldable.foldl(Data_Foldable.foldableArray)(function (y) {
              return function (v) {
                  return f(v.value0)(y)(v.value1);
              };
          })(z);
          var $165 = Data_FunctorWithIndex.mapWithIndex(Data_FunctorWithIndex.functorWithIndexArray)(Data_Tuple.Tuple.create);
          return function ($166) {
              return $164($165($166));
          };
      };
  }, function (f) {
      return function (z) {
          var $167 = Data_Foldable.foldr(Data_Foldable.foldableArray)(function (v) {
              return function (y) {
                  return f(v.value0)(v.value1)(y);
              };
          })(z);
          var $168 = Data_FunctorWithIndex.mapWithIndex(Data_FunctorWithIndex.functorWithIndexArray)(Data_Tuple.Tuple.create);
          return function ($169) {
              return $167($168($169));
          };
      };
  });
  var foldMapWithIndex = function (dict) {
      return dict.foldMapWithIndex;
  };
  exports["FoldableWithIndex"] = FoldableWithIndex;
  exports["foldrWithIndex"] = foldrWithIndex;
  exports["foldlWithIndex"] = foldlWithIndex;
  exports["foldMapWithIndex"] = foldMapWithIndex;
  exports["foldableWithIndexArray"] = foldableWithIndexArray;
})(PS);
(function(exports) {
  "use strict";

  // jshint maxparams: 3

  exports.traverseArrayImpl = (function () {
    function array1(a) {
      return [a];
    }

    function array2(a) {
      return function (b) {
        return [a, b];
      };
    }

    function array3(a) {
      return function (b) {
        return function (c) {
          return [a, b, c];
        };
      };
    }

    function concat2(xs) {
      return function (ys) {
        return xs.concat(ys);
      };
    }

    return function (apply) {
      return function (map) {
        return function (pure) {
          return function (f) {
            return function (array) {
              function go(bot, top) {
                switch (top - bot) {
                case 0: return pure([]);
                case 1: return map(array1)(f(array[bot]));
                case 2: return apply(map(array2)(f(array[bot])))(f(array[bot + 1]));
                case 3: return apply(apply(map(array3)(f(array[bot])))(f(array[bot + 1])))(f(array[bot + 2]));
                default:
                  // This slightly tricky pivot selection aims to produce two
                  // even-length partitions where possible.
                  var pivot = bot + Math.floor((top - bot) / 4) * 2;
                  return apply(map(concat2)(go(bot, pivot)))(go(pivot, top));
                }
              }
              return go(0, array.length);
            };
          };
        };
      };
    };
  })();
})(PS["Data.Traversable"] = PS["Data.Traversable"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Traversable"] = $PS["Data.Traversable"] || {};
  var exports = $PS["Data.Traversable"];
  var $foreign = $PS["Data.Traversable"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Category = $PS["Control.Category"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];            
  var Traversable = function (Foldable1, Functor0, sequence, traverse) {
      this.Foldable1 = Foldable1;
      this.Functor0 = Functor0;
      this.sequence = sequence;
      this.traverse = traverse;
  };
  var traverse = function (dict) {
      return dict.traverse;
  }; 
  var sequenceDefault = function (dictTraversable) {
      return function (dictApplicative) {
          return traverse(dictTraversable)(dictApplicative)(Control_Category.identity(Control_Category.categoryFn));
      };
  };
  var traversableArray = new Traversable(function () {
      return Data_Foldable.foldableArray;
  }, function () {
      return Data_Functor.functorArray;
  }, function (dictApplicative) {
      return sequenceDefault(traversableArray)(dictApplicative);
  }, function (dictApplicative) {
      return $foreign.traverseArrayImpl(Control_Apply.apply(dictApplicative.Apply0()))(Data_Functor.map((dictApplicative.Apply0()).Functor0()))(Control_Applicative.pure(dictApplicative));
  });
  var sequence = function (dict) {
      return dict.sequence;
  };
  exports["Traversable"] = Traversable;
  exports["traverse"] = traverse;
  exports["sequence"] = sequence;
  exports["traversableArray"] = traversableArray;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.TraversableWithIndex"] = $PS["Data.TraversableWithIndex"] || {};
  var exports = $PS["Data.TraversableWithIndex"];
  var Data_FoldableWithIndex = $PS["Data.FoldableWithIndex"];
  var Data_FunctorWithIndex = $PS["Data.FunctorWithIndex"];
  var Data_Traversable = $PS["Data.Traversable"];  
  var TraversableWithIndex = function (FoldableWithIndex1, FunctorWithIndex0, Traversable2, traverseWithIndex) {
      this.FoldableWithIndex1 = FoldableWithIndex1;
      this.FunctorWithIndex0 = FunctorWithIndex0;
      this.Traversable2 = Traversable2;
      this.traverseWithIndex = traverseWithIndex;
  };
  var traverseWithIndexDefault = function (dictTraversableWithIndex) {
      return function (dictApplicative) {
          return function (f) {
              var $63 = Data_Traversable.sequence(dictTraversableWithIndex.Traversable2())(dictApplicative);
              var $64 = Data_FunctorWithIndex.mapWithIndex(dictTraversableWithIndex.FunctorWithIndex0())(f);
              return function ($65) {
                  return $63($64($65));
              };
          };
      };
  };
  var traverseWithIndex = function (dict) {
      return dict.traverseWithIndex;
  };
  var traversableWithIndexArray = new TraversableWithIndex(function () {
      return Data_FoldableWithIndex.foldableWithIndexArray;
  }, function () {
      return Data_FunctorWithIndex.functorWithIndexArray;
  }, function () {
      return Data_Traversable.traversableArray;
  }, function (dictApplicative) {
      return traverseWithIndexDefault(traversableWithIndexArray)(dictApplicative);
  });
  exports["TraversableWithIndex"] = TraversableWithIndex;
  exports["traverseWithIndex"] = traverseWithIndex;
  exports["traversableWithIndexArray"] = traversableWithIndexArray;
})(PS);
(function(exports) {
  "use strict";

  exports["new"] = function () {
    return {};
  };

  exports.poke = function (k) {
    return function (v) {
      return function (m) {
        return function () {
          m[k] = v;
          return m;
        };
      };
    };
  };
})(PS["Foreign.Object.ST"] = PS["Foreign.Object.ST"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Foreign.Object.ST"] = $PS["Foreign.Object.ST"] || {};
  var exports = $PS["Foreign.Object.ST"];
  var $foreign = $PS["Foreign.Object.ST"];
  exports["new"] = $foreign["new"];
  exports["poke"] = $foreign.poke;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Foreign.Object"] = $PS["Foreign.Object"] || {};
  var exports = $PS["Foreign.Object"];
  var $foreign = $PS["Foreign.Object"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Control_Monad_ST_Internal = $PS["Control.Monad.ST.Internal"];
  var Data_Array = $PS["Data.Array"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_FoldableWithIndex = $PS["Data.FoldableWithIndex"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_FunctorWithIndex = $PS["Data.FunctorWithIndex"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Data_TraversableWithIndex = $PS["Data.TraversableWithIndex"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Foreign_Object_ST = $PS["Foreign.Object.ST"];        
  var values = $foreign.toArrayWithKey(function (v) {
      return function (v1) {
          return v1;
      };
  });
  var toUnfoldable = function (dictUnfoldable) {
      var $36 = Data_Array.toUnfoldable(dictUnfoldable);
      var $37 = $foreign.toArrayWithKey(Data_Tuple.Tuple.create);
      return function ($38) {
          return $36($37($38));
      };
  };                                                             
  var thawST = $foreign["_copyST"];
  var singleton = function (k) {
      return function (v) {
          return $foreign.runST(Control_Bind.bindFlipped(Control_Monad_ST_Internal.bindST)(Foreign_Object_ST.poke(k)(v))(Foreign_Object_ST["new"]));
      };
  };
  var mutate = function (f) {
      return function (m) {
          return $foreign.runST(function __do() {
              var s = thawST(m)();
              f(s)();
              return s;
          });
      };
  };                                                                                                    
  var mapWithKey = function (f) {
      return function (m) {
          return $foreign["_mapWithKey"](m, f);
      };
  }; 
  var insert = function (k) {
      return function (v) {
          return mutate(Foreign_Object_ST.poke(k)(v));
      };
  };
  var functorObject = new Data_Functor.Functor(function (f) {
      return function (m) {
          return $foreign["_fmapObject"](m, f);
      };
  });
  var functorWithIndexObject = new Data_FunctorWithIndex.FunctorWithIndex(function () {
      return functorObject;
  }, mapWithKey);
  var fromFoldable = function (dictFoldable) {
      return function (l) {
          return $foreign.runST(function __do() {
              var s = Foreign_Object_ST["new"]();
              Control_Monad_ST_Internal.foreach(Data_Array.fromFoldable(dictFoldable)(l))(function (v) {
                  return Data_Functor["void"](Control_Monad_ST_Internal.functorST)(Foreign_Object_ST.poke(v.value0)(v.value1)(s));
              })();
              return s;
          });
      };
  };
  var foldM = function (dictMonad) {
      return function (f) {
          return function (z) {
              return $foreign["_foldM"](Control_Bind.bind(dictMonad.Bind1()))(f)(Control_Applicative.pure(dictMonad.Applicative0())(z));
          };
      };
  };
  var union = function (m) {
      return mutate(function (s) {
          return foldM(Control_Monad_ST_Internal.monadST)(function (s$prime) {
              return function (k) {
                  return function (v) {
                      return Foreign_Object_ST.poke(k)(v)(s$prime);
                  };
              };
          })(s)(m);
      });
  };
  var unions = function (dictFoldable) {
      return Data_Foldable.foldl(dictFoldable)(union)($foreign.empty);
  };
  var fold = $foreign["_foldM"](Data_Function.applyFlipped);
  var foldMap = function (dictMonoid) {
      return function (f) {
          return fold(function (acc) {
              return function (k) {
                  return function (v) {
                      return Data_Semigroup.append(dictMonoid.Semigroup0())(acc)(f(k)(v));
                  };
              };
          })(Data_Monoid.mempty(dictMonoid));
      };
  };
  var foldableObject = new Data_Foldable.Foldable(function (dictMonoid) {
      return function (f) {
          return foldMap(dictMonoid)(Data_Function["const"](f));
      };
  }, function (f) {
      return fold(function (z) {
          return function (v) {
              return f(z);
          };
      });
  }, function (f) {
      return function (z) {
          return function (m) {
              return Data_Foldable.foldr(Data_Foldable.foldableArray)(f)(z)(values(m));
          };
      };
  });
  var foldableWithIndexObject = new Data_FoldableWithIndex.FoldableWithIndex(function () {
      return foldableObject;
  }, function (dictMonoid) {
      return foldMap(dictMonoid);
  }, function (f) {
      return fold(Data_Function.flip(f));
  }, function (f) {
      return function (z) {
          return function (m) {
              return Data_Foldable.foldr(Data_Foldable.foldableArray)(Data_Tuple.uncurry(f))(z)($foreign.toArrayWithKey(Data_Tuple.Tuple.create)(m));
          };
      };
  });
  var traversableWithIndexObject = new Data_TraversableWithIndex.TraversableWithIndex(function () {
      return foldableWithIndexObject;
  }, function () {
      return functorWithIndexObject;
  }, function () {
      return traversableObject;
  }, function (dictApplicative) {
      return function (f) {
          return function (ms) {
              return fold(function (acc) {
                  return function (k) {
                      return function (v) {
                          return Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Function.flip(insert(k)))(acc))(f(k)(v));
                      };
                  };
              })(Control_Applicative.pure(dictApplicative)($foreign.empty))(ms);
          };
      };
  });
  var traversableObject = new Data_Traversable.Traversable(function () {
      return foldableObject;
  }, function () {
      return functorObject;
  }, function (dictApplicative) {
      return Data_Traversable.traverse(traversableObject)(dictApplicative)(Control_Category.identity(Control_Category.categoryFn));
  }, function (dictApplicative) {
      var $43 = Data_TraversableWithIndex.traverseWithIndex(traversableWithIndexObject)(dictApplicative);
      return function ($44) {
          return $43(Data_Function["const"]($44));
      };
  });
  exports["singleton"] = singleton;
  exports["toUnfoldable"] = toUnfoldable;
  exports["fromFoldable"] = fromFoldable;
  exports["mapWithKey"] = mapWithKey;
  exports["values"] = values;
  exports["unions"] = unions;
  exports["foldableWithIndexObject"] = foldableWithIndexObject;
  exports["traversableObject"] = traversableObject;
  exports["empty"] = $foreign.empty;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Argonaut.Core"] = $PS["Data.Argonaut.Core"] || {};
  var exports = $PS["Data.Argonaut.Core"];
  var $foreign = $PS["Data.Argonaut.Core"];
  var Foreign_Object = $PS["Foreign.Object"];   
  var jsonEmptyObject = $foreign.fromObject(Foreign_Object.empty);
  exports["jsonEmptyObject"] = jsonEmptyObject;
  exports["stringify"] = $foreign.stringify;
})(PS);
(function(exports) {
  "use strict";

  exports._jsonParser = function (fail, succ, s) {
    try {
      return succ(JSON.parse(s));
    }
    catch (e) {
      return fail(e.message);
    }
  };
})(PS["Data.Argonaut.Parser"] = PS["Data.Argonaut.Parser"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Argonaut.Parser"] = $PS["Data.Argonaut.Parser"] || {};
  var exports = $PS["Data.Argonaut.Parser"];
  var $foreign = $PS["Data.Argonaut.Parser"];
  var Data_Either = $PS["Data.Either"];                
  var jsonParser = function (j) {
      return $foreign["_jsonParser"](Data_Either.Left.create, Data_Either.Right.create, j);
  };
  exports["jsonParser"] = jsonParser;
})(PS);
(function(exports) {
  "use strict";

  exports.replace = function (s1) {
    return function (s2) {
      return function (s3) {
        return s3.replace(s1, s2);
      };
    };
  };

  exports.replaceAll = function (s1) {
    return function (s2) {
      return function (s3) {
        return s3.replace(new RegExp(s1.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"), "g"), s2); // eslint-disable-line no-useless-escape
      };
    };
  };

  exports.split = function (sep) {
    return function (s) {
      return s.split(sep);
    };
  };

  exports.toLower = function (s) {
    return s.toLowerCase();
  };

  exports.toUpper = function (s) {
    return s.toUpperCase();
  };

  exports.trim = function (s) {
    return s.trim();
  };

  exports.joinWith = function (s) {
    return function (xs) {
      return xs.join(s);
    };
  };
})(PS["Data.String.Common"] = PS["Data.String.Common"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.String.Common"] = $PS["Data.String.Common"] || {};
  var exports = $PS["Data.String.Common"];
  var $foreign = $PS["Data.String.Common"];                
  var $$null = function (s) {
      return s === "";
  };
  exports["null"] = $$null;
  exports["replace"] = $foreign.replace;
  exports["replaceAll"] = $foreign.replaceAll;
  exports["split"] = $foreign.split;
  exports["toLower"] = $foreign.toLower;
  exports["toUpper"] = $foreign.toUpper;
  exports["trim"] = $foreign.trim;
  exports["joinWith"] = $foreign.joinWith;
})(PS);
(function(exports) {
  "use strict";

  // A helper which transforms the result ofencodeURIComponent to be compliant
  // with RFC3896, as described in the MDN documentation here:
  //
  // https://web.archive.org/web/20201206001047/https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent
  function toRFC3896(input) {
    return input.replace(/[!'()*]/g, function (c) {
      return "%" + c.charCodeAt(0).toString(16);
    });
  }

  exports._encodeURIComponent = function encode(fail, succeed, input) {
    try {
      return succeed(toRFC3896(encodeURIComponent(input)));
    } catch (err) {
      return fail(err);
    }
  };

  function _decodeURIComponent(fail, succeed, input) {
    try {
      return succeed(decodeURIComponent(input));
    } catch (err) {
      return fail(err);
    }
  }

  exports._decodeURIComponent = _decodeURIComponent;
})(PS["JSURI"] = PS["JSURI"] || {});
(function(exports) {
  "use strict";

  exports.runFn2 = function (fn) {
    return function (a) {
      return function (b) {
        return fn(a, b);
      };
    };
  };

  exports.runFn3 = function (fn) {
    return function (a) {
      return function (b) {
        return function (c) {
          return fn(a, b, c);
        };
      };
    };
  };
})(PS["Data.Function.Uncurried"] = PS["Data.Function.Uncurried"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Function.Uncurried"] = $PS["Data.Function.Uncurried"] || {};
  var exports = $PS["Data.Function.Uncurried"];
  var $foreign = $PS["Data.Function.Uncurried"];
  var runFn1 = function (f) {
      return f;
  };
  exports["runFn1"] = runFn1;
  exports["runFn2"] = $foreign.runFn2;
  exports["runFn3"] = $foreign.runFn3;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["JSURI"] = $PS["JSURI"] || {};
  var exports = $PS["JSURI"];
  var $foreign = $PS["JSURI"];
  var Data_Function = $PS["Data.Function"];
  var Data_Function_Uncurried = $PS["Data.Function.Uncurried"];
  var Data_Maybe = $PS["Data.Maybe"];                
  var $$encodeURIComponent = Data_Function_Uncurried.runFn3($foreign["_encodeURIComponent"])(Data_Function["const"](Data_Maybe.Nothing.value))(Data_Maybe.Just.create);      
  var $$decodeURIComponent = Data_Function_Uncurried.runFn3($foreign["_decodeURIComponent"])(Data_Function["const"](Data_Maybe.Nothing.value))(Data_Maybe.Just.create);
  exports["encodeURIComponent"] = $$encodeURIComponent;
  exports["decodeURIComponent"] = $$decodeURIComponent;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.FormURLEncoded"] = $PS["Data.FormURLEncoded"] || {};
  var exports = $PS["Data.FormURLEncoded"];
  var Control_Apply = $PS["Control.Apply"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Traversable = $PS["Data.Traversable"];
  var JSURI = $PS["JSURI"];                
  var FormURLEncoded = function (x) {
      return x;
  };
  var toArray = function (v) {
      return v;
  };                                                 
  var fromArray = FormURLEncoded;                                                                                    
  var encode = (function () {
      var encodePart = function (v) {
          if (v.value1 instanceof Data_Maybe.Nothing) {
              return JSURI["encodeURIComponent"](v.value0);
          };
          if (v.value1 instanceof Data_Maybe.Just) {
              return Control_Apply.apply(Data_Maybe.applyMaybe)(Data_Functor.map(Data_Maybe.functorMaybe)(function (key) {
                  return function (val) {
                      return key + ("=" + val);
                  };
              })(JSURI["encodeURIComponent"](v.value0)))(JSURI["encodeURIComponent"](v.value1.value0));
          };
          throw new Error("Failed pattern match at Data.FormURLEncoded (line 37, column 18 - line 39, column 108): " + [ v.constructor.name ]);
      };
      var $16 = Data_Functor.map(Data_Maybe.functorMaybe)(Data_String_Common.joinWith("&"));
      var $17 = Data_Traversable.traverse(Data_Traversable.traversableArray)(Data_Maybe.applicativeMaybe)(encodePart);
      return function ($18) {
          return $16($17(toArray($18)));
      };
  })();
  exports["fromArray"] = fromArray;
  exports["encode"] = encode;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.HTTP.Method"] = $PS["Data.HTTP.Method"] || {};
  var exports = $PS["Data.HTTP.Method"];
  var Data_Either = $PS["Data.Either"];
  var Data_Show = $PS["Data.Show"];                                  
  var OPTIONS = (function () {
      function OPTIONS() {

      };
      OPTIONS.value = new OPTIONS();
      return OPTIONS;
  })();
  var GET = (function () {
      function GET() {

      };
      GET.value = new GET();
      return GET;
  })();
  var HEAD = (function () {
      function HEAD() {

      };
      HEAD.value = new HEAD();
      return HEAD;
  })();
  var POST = (function () {
      function POST() {

      };
      POST.value = new POST();
      return POST;
  })();
  var PUT = (function () {
      function PUT() {

      };
      PUT.value = new PUT();
      return PUT;
  })();
  var DELETE = (function () {
      function DELETE() {

      };
      DELETE.value = new DELETE();
      return DELETE;
  })();
  var TRACE = (function () {
      function TRACE() {

      };
      TRACE.value = new TRACE();
      return TRACE;
  })();
  var CONNECT = (function () {
      function CONNECT() {

      };
      CONNECT.value = new CONNECT();
      return CONNECT;
  })();
  var PROPFIND = (function () {
      function PROPFIND() {

      };
      PROPFIND.value = new PROPFIND();
      return PROPFIND;
  })();
  var PROPPATCH = (function () {
      function PROPPATCH() {

      };
      PROPPATCH.value = new PROPPATCH();
      return PROPPATCH;
  })();
  var MKCOL = (function () {
      function MKCOL() {

      };
      MKCOL.value = new MKCOL();
      return MKCOL;
  })();
  var COPY = (function () {
      function COPY() {

      };
      COPY.value = new COPY();
      return COPY;
  })();
  var MOVE = (function () {
      function MOVE() {

      };
      MOVE.value = new MOVE();
      return MOVE;
  })();
  var LOCK = (function () {
      function LOCK() {

      };
      LOCK.value = new LOCK();
      return LOCK;
  })();
  var UNLOCK = (function () {
      function UNLOCK() {

      };
      UNLOCK.value = new UNLOCK();
      return UNLOCK;
  })();
  var PATCH = (function () {
      function PATCH() {

      };
      PATCH.value = new PATCH();
      return PATCH;
  })();
  var unCustomMethod = function (v) {
      return v;
  };
  var showMethod = new Data_Show.Show(function (v) {
      if (v instanceof OPTIONS) {
          return "OPTIONS";
      };
      if (v instanceof GET) {
          return "GET";
      };
      if (v instanceof HEAD) {
          return "HEAD";
      };
      if (v instanceof POST) {
          return "POST";
      };
      if (v instanceof PUT) {
          return "PUT";
      };
      if (v instanceof DELETE) {
          return "DELETE";
      };
      if (v instanceof TRACE) {
          return "TRACE";
      };
      if (v instanceof CONNECT) {
          return "CONNECT";
      };
      if (v instanceof PROPFIND) {
          return "PROPFIND";
      };
      if (v instanceof PROPPATCH) {
          return "PROPPATCH";
      };
      if (v instanceof MKCOL) {
          return "MKCOL";
      };
      if (v instanceof COPY) {
          return "COPY";
      };
      if (v instanceof MOVE) {
          return "MOVE";
      };
      if (v instanceof LOCK) {
          return "LOCK";
      };
      if (v instanceof UNLOCK) {
          return "UNLOCK";
      };
      if (v instanceof PATCH) {
          return "PATCH";
      };
      throw new Error("Failed pattern match at Data.HTTP.Method (line 43, column 1 - line 59, column 23): " + [ v.constructor.name ]);
  });
  var print = Data_Either.either(Data_Show.show(showMethod))(unCustomMethod);
  exports["GET"] = GET;
  exports["POST"] = POST;
  exports["PUT"] = PUT;
  exports["DELETE"] = DELETE;
  exports["print"] = print;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.NonEmpty"] = $PS["Data.NonEmpty"] || {};
  var exports = $PS["Data.NonEmpty"];
  var Control_Plus = $PS["Control.Plus"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];                              
  var NonEmpty = (function () {
      function NonEmpty(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      NonEmpty.create = function (value0) {
          return function (value1) {
              return new NonEmpty(value0, value1);
          };
      };
      return NonEmpty;
  })();
  var singleton = function (dictPlus) {
      return function (a) {
          return new NonEmpty(a, Control_Plus.empty(dictPlus));
      };
  };
  var showNonEmpty = function (dictShow) {
      return function (dictShow1) {
          return new Data_Show.Show(function (v) {
              return "(NonEmpty " + (Data_Show.show(dictShow)(v.value0) + (" " + (Data_Show.show(dictShow1)(v.value1) + ")")));
          });
      };
  };
  var head = function (v) {
      return v.value0;
  };
  var functorNonEmpty = function (dictFunctor) {
      return new Data_Functor.Functor(function (f) {
          return function (m) {
              return new NonEmpty(f(m.value0), Data_Functor.map(dictFunctor)(f)(m.value1));
          };
      });
  };
  var foldableNonEmpty = function (dictFoldable) {
      return new Data_Foldable.Foldable(function (dictMonoid) {
          return function (f) {
              return function (v) {
                  return Data_Semigroup.append(dictMonoid.Semigroup0())(f(v.value0))(Data_Foldable.foldMap(dictFoldable)(dictMonoid)(f)(v.value1));
              };
          };
      }, function (f) {
          return function (b) {
              return function (v) {
                  return Data_Foldable.foldl(dictFoldable)(f)(f(b)(v.value0))(v.value1);
              };
          };
      }, function (f) {
          return function (b) {
              return function (v) {
                  return f(v.value0)(Data_Foldable.foldr(dictFoldable)(f)(b)(v.value1));
              };
          };
      });
  };
  exports["NonEmpty"] = NonEmpty;
  exports["singleton"] = singleton;
  exports["head"] = head;
  exports["showNonEmpty"] = showNonEmpty;
  exports["functorNonEmpty"] = functorNonEmpty;
  exports["foldableNonEmpty"] = foldableNonEmpty;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.List.Types"] = $PS["Data.List.Types"] || {};
  var exports = $PS["Data.List.Types"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Control_Plus = $PS["Control.Plus"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_FoldableWithIndex = $PS["Data.FoldableWithIndex"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_FunctorWithIndex = $PS["Data.FunctorWithIndex"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_NonEmpty = $PS["Data.NonEmpty"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Data_Unfoldable1 = $PS["Data.Unfoldable1"];                
  var Nil = (function () {
      function Nil() {

      };
      Nil.value = new Nil();
      return Nil;
  })();
  var Cons = (function () {
      function Cons(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Cons.create = function (value0) {
          return function (value1) {
              return new Cons(value0, value1);
          };
      };
      return Cons;
  })();
  var NonEmptyList = function (x) {
      return x;
  };
  var toList = function (v) {
      return new Cons(v.value0, v.value1);
  };
  var listMap = function (f) {
      var chunkedRevMap = function ($copy_chunksAcc) {
          return function ($copy_v) {
              var $tco_var_chunksAcc = $copy_chunksAcc;
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(chunksAcc, v) {
                  if (v instanceof Cons && (v.value1 instanceof Cons && v.value1.value1 instanceof Cons)) {
                      $tco_var_chunksAcc = new Cons(v, chunksAcc);
                      $copy_v = v.value1.value1.value1;
                      return;
                  };
                  var unrolledMap = function (v1) {
                      if (v1 instanceof Cons && (v1.value1 instanceof Cons && v1.value1.value1 instanceof Nil)) {
                          return new Cons(f(v1.value0), new Cons(f(v1.value1.value0), Nil.value));
                      };
                      if (v1 instanceof Cons && v1.value1 instanceof Nil) {
                          return new Cons(f(v1.value0), Nil.value);
                      };
                      return Nil.value;
                  };
                  var reverseUnrolledMap = function ($copy_v1) {
                      return function ($copy_acc) {
                          var $tco_var_v1 = $copy_v1;
                          var $tco_done1 = false;
                          var $tco_result;
                          function $tco_loop(v1, acc) {
                              if (v1 instanceof Cons && (v1.value0 instanceof Cons && (v1.value0.value1 instanceof Cons && v1.value0.value1.value1 instanceof Cons))) {
                                  $tco_var_v1 = v1.value1;
                                  $copy_acc = new Cons(f(v1.value0.value0), new Cons(f(v1.value0.value1.value0), new Cons(f(v1.value0.value1.value1.value0), acc)));
                                  return;
                              };
                              $tco_done1 = true;
                              return acc;
                          };
                          while (!$tco_done1) {
                              $tco_result = $tco_loop($tco_var_v1, $copy_acc);
                          };
                          return $tco_result;
                      };
                  };
                  $tco_done = true;
                  return reverseUnrolledMap(chunksAcc)(unrolledMap(v));
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($tco_var_chunksAcc, $copy_v);
              };
              return $tco_result;
          };
      };
      return chunkedRevMap(Nil.value);
  };
  var functorList = new Data_Functor.Functor(listMap);
  var functorNonEmptyList = Data_NonEmpty.functorNonEmpty(functorList);
  var foldableList = new Data_Foldable.Foldable(function (dictMonoid) {
      return function (f) {
          return Data_Foldable.foldl(foldableList)(function (acc) {
              var $205 = Data_Semigroup.append(dictMonoid.Semigroup0())(acc);
              return function ($206) {
                  return $205(f($206));
              };
          })(Data_Monoid.mempty(dictMonoid));
      };
  }, function (f) {
      var go = function ($copy_b) {
          return function ($copy_v) {
              var $tco_var_b = $copy_b;
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(b, v) {
                  if (v instanceof Nil) {
                      $tco_done = true;
                      return b;
                  };
                  if (v instanceof Cons) {
                      $tco_var_b = f(b)(v.value0);
                      $copy_v = v.value1;
                      return;
                  };
                  throw new Error("Failed pattern match at Data.List.Types (line 112, column 12 - line 114, column 30): " + [ v.constructor.name ]);
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($tco_var_b, $copy_v);
              };
              return $tco_result;
          };
      };
      return go;
  }, function (f) {
      return function (b) {
          var rev = (function () {
              var go = function ($copy_acc) {
                  return function ($copy_v) {
                      var $tco_var_acc = $copy_acc;
                      var $tco_done1 = false;
                      var $tco_result;
                      function $tco_loop(acc, v) {
                          if (v instanceof Nil) {
                              $tco_done1 = true;
                              return acc;
                          };
                          if (v instanceof Cons) {
                              $tco_var_acc = new Cons(v.value0, acc);
                              $copy_v = v.value1;
                              return;
                          };
                          throw new Error("Failed pattern match at Data.List.Types (line 108, column 7 - line 108, column 23): " + [ acc.constructor.name, v.constructor.name ]);
                      };
                      while (!$tco_done1) {
                          $tco_result = $tco_loop($tco_var_acc, $copy_v);
                      };
                      return $tco_result;
                  };
              };
              return go(Nil.value);
          })();
          var $207 = Data_Foldable.foldl(foldableList)(Data_Function.flip(f))(b);
          return function ($208) {
              return $207(rev($208));
          };
      };
  });
  var foldableNonEmptyList = Data_NonEmpty.foldableNonEmpty(foldableList);
  var foldableWithIndexList = new Data_FoldableWithIndex.FoldableWithIndex(function () {
      return foldableList;
  }, function (dictMonoid) {
      return function (f) {
          return Data_FoldableWithIndex.foldlWithIndex(foldableWithIndexList)(function (i) {
              return function (acc) {
                  var $209 = Data_Semigroup.append(dictMonoid.Semigroup0())(acc);
                  var $210 = f(i);
                  return function ($211) {
                      return $209($210($211));
                  };
              };
          })(Data_Monoid.mempty(dictMonoid));
      };
  }, function (f) {
      return function (acc) {
          var $212 = Data_Foldable.foldl(foldableList)(function (v) {
              return function (a) {
                  return new Data_Tuple.Tuple(v.value0 + 1 | 0, f(v.value0)(v.value1)(a));
              };
          })(new Data_Tuple.Tuple(0, acc));
          return function ($213) {
              return Data_Tuple.snd($212($213));
          };
      };
  }, function (f) {
      return function (b) {
          return function (xs) {
              var v = (function () {
                  var rev = Data_Foldable.foldl(foldableList)(function (v1) {
                      return function (a) {
                          return new Data_Tuple.Tuple(v1.value0 + 1 | 0, new Cons(a, v1.value1));
                      };
                  });
                  return rev(new Data_Tuple.Tuple(0, Nil.value))(xs);
              })();
              return Data_Tuple.snd(Data_Foldable.foldl(foldableList)(function (v1) {
                  return function (a) {
                      return new Data_Tuple.Tuple(v1.value0 - 1 | 0, f(v1.value0 - 1 | 0)(a)(v1.value1));
                  };
              })(new Data_Tuple.Tuple(v.value0, b))(v.value1));
          };
      };
  });
  var functorWithIndexList = new Data_FunctorWithIndex.FunctorWithIndex(function () {
      return functorList;
  }, function (f) {
      return Data_FoldableWithIndex.foldrWithIndex(foldableWithIndexList)(function (i) {
          return function (x) {
              return function (acc) {
                  return new Cons(f(i)(x), acc);
              };
          };
      })(Nil.value);
  });
  var semigroupList = new Data_Semigroup.Semigroup(function (xs) {
      return function (ys) {
          return Data_Foldable.foldr(foldableList)(Cons.create)(ys)(xs);
      };
  });
  var monoidList = new Data_Monoid.Monoid(function () {
      return semigroupList;
  }, Nil.value);
  var semigroupNonEmptyList = new Data_Semigroup.Semigroup(function (v) {
      return function (as$prime) {
          return new Data_NonEmpty.NonEmpty(v.value0, Data_Semigroup.append(semigroupList)(v.value1)(toList(as$prime)));
      };
  });
  var showList = function (dictShow) {
      return new Data_Show.Show(function (v) {
          if (v instanceof Nil) {
              return "Nil";
          };
          return "(" + (Data_Foldable.intercalate(foldableList)(Data_Monoid.monoidString)(" : ")(Data_Functor.map(functorList)(Data_Show.show(dictShow))(v)) + " : Nil)");
      });
  };
  var showNonEmptyList = function (dictShow) {
      return new Data_Show.Show(function (v) {
          return "(NonEmptyList " + (Data_Show.show(Data_NonEmpty.showNonEmpty(dictShow)(showList(dictShow)))(v) + ")");
      });
  };
  var traversableList = new Data_Traversable.Traversable(function () {
      return foldableList;
  }, function () {
      return functorList;
  }, function (dictApplicative) {
      return Data_Traversable.traverse(traversableList)(dictApplicative)(Control_Category.identity(Control_Category.categoryFn));
  }, function (dictApplicative) {
      return function (f) {
          var $222 = Data_Functor.map((dictApplicative.Apply0()).Functor0())(Data_Foldable.foldl(foldableList)(Data_Function.flip(Cons.create))(Nil.value));
          var $223 = Data_Foldable.foldl(foldableList)(function (acc) {
              var $225 = Control_Apply.lift2(dictApplicative.Apply0())(Data_Function.flip(Cons.create))(acc);
              return function ($226) {
                  return $225(f($226));
              };
          })(Control_Applicative.pure(dictApplicative)(Nil.value));
          return function ($224) {
              return $222($223($224));
          };
      };
  });
  var unfoldable1List = new Data_Unfoldable1.Unfoldable1(function (f) {
      return function (b) {
          var go = function ($copy_source) {
              return function ($copy_memo) {
                  var $tco_var_source = $copy_source;
                  var $tco_done = false;
                  var $tco_result;
                  function $tco_loop(source, memo) {
                      var v = f(source);
                      if (v.value1 instanceof Data_Maybe.Just) {
                          $tco_var_source = v.value1.value0;
                          $copy_memo = new Cons(v.value0, memo);
                          return;
                      };
                      if (v.value1 instanceof Data_Maybe.Nothing) {
                          $tco_done = true;
                          return Data_Foldable.foldl(foldableList)(Data_Function.flip(Cons.create))(Nil.value)(new Cons(v.value0, memo));
                      };
                      throw new Error("Failed pattern match at Data.List.Types (line 136, column 22 - line 138, column 61): " + [ v.constructor.name ]);
                  };
                  while (!$tco_done) {
                      $tco_result = $tco_loop($tco_var_source, $copy_memo);
                  };
                  return $tco_result;
              };
          };
          return go(b)(Nil.value);
      };
  });
  var unfoldableList = new Data_Unfoldable.Unfoldable(function () {
      return unfoldable1List;
  }, function (f) {
      return function (b) {
          var go = function ($copy_source) {
              return function ($copy_memo) {
                  var $tco_var_source = $copy_source;
                  var $tco_done = false;
                  var $tco_result;
                  function $tco_loop(source, memo) {
                      var v = f(source);
                      if (v instanceof Data_Maybe.Nothing) {
                          $tco_done = true;
                          return Data_Foldable.foldl(foldableList)(Data_Function.flip(Cons.create))(Nil.value)(memo);
                      };
                      if (v instanceof Data_Maybe.Just) {
                          $tco_var_source = v.value0.value1;
                          $copy_memo = new Cons(v.value0.value0, memo);
                          return;
                      };
                      throw new Error("Failed pattern match at Data.List.Types (line 143, column 22 - line 145, column 52): " + [ v.constructor.name ]);
                  };
                  while (!$tco_done) {
                      $tco_result = $tco_loop($tco_var_source, $copy_memo);
                  };
                  return $tco_result;
              };
          };
          return go(b)(Nil.value);
      };
  });
  var eq1List = new Data_Eq.Eq1(function (dictEq) {
      return function (xs) {
          return function (ys) {
              var go = function ($copy_v) {
                  return function ($copy_v1) {
                      return function ($copy_v2) {
                          var $tco_var_v = $copy_v;
                          var $tco_var_v1 = $copy_v1;
                          var $tco_done = false;
                          var $tco_result;
                          function $tco_loop(v, v1, v2) {
                              if (!v2) {
                                  $tco_done = true;
                                  return false;
                              };
                              if (v instanceof Nil && v1 instanceof Nil) {
                                  $tco_done = true;
                                  return v2;
                              };
                              if (v instanceof Cons && v1 instanceof Cons) {
                                  $tco_var_v = v.value1;
                                  $tco_var_v1 = v1.value1;
                                  $copy_v2 = v2 && Data_Eq.eq(dictEq)(v1.value0)(v.value0);
                                  return;
                              };
                              $tco_done = true;
                              return false;
                          };
                          while (!$tco_done) {
                              $tco_result = $tco_loop($tco_var_v, $tco_var_v1, $copy_v2);
                          };
                          return $tco_result;
                      };
                  };
              };
              return go(xs)(ys)(true);
          };
      };
  });                                                      
  var eqList = function (dictEq) {
      return new Data_Eq.Eq(Data_Eq.eq1(eq1List)(dictEq));
  }; 
  var applyList = new Control_Apply.Apply(function () {
      return functorList;
  }, function (v) {
      return function (v1) {
          if (v instanceof Nil) {
              return Nil.value;
          };
          if (v instanceof Cons) {
              return Data_Semigroup.append(semigroupList)(Data_Functor.map(functorList)(v.value0)(v1))(Control_Apply.apply(applyList)(v.value1)(v1));
          };
          throw new Error("Failed pattern match at Data.List.Types (line 158, column 1 - line 160, column 48): " + [ v.constructor.name, v1.constructor.name ]);
      };
  });
  var applyNonEmptyList = new Control_Apply.Apply(function () {
      return functorNonEmptyList;
  }, function (v) {
      return function (v1) {
          return new Data_NonEmpty.NonEmpty(v.value0(v1.value0), Data_Semigroup.append(semigroupList)(Control_Apply.apply(applyList)(v.value1)(new Cons(v1.value0, Nil.value)))(Control_Apply.apply(applyList)(new Cons(v.value0, v.value1))(v1.value1)));
      };
  });
  var bindList = new Control_Bind.Bind(function () {
      return applyList;
  }, function (v) {
      return function (v1) {
          if (v instanceof Nil) {
              return Nil.value;
          };
          if (v instanceof Cons) {
              return Data_Semigroup.append(semigroupList)(v1(v.value0))(Control_Bind.bind(bindList)(v.value1)(v1));
          };
          throw new Error("Failed pattern match at Data.List.Types (line 165, column 1 - line 167, column 37): " + [ v.constructor.name, v1.constructor.name ]);
      };
  });
  var applicativeList = new Control_Applicative.Applicative(function () {
      return applyList;
  }, function (a) {
      return new Cons(a, Nil.value);
  });                                              
  var altList = new Control_Alt.Alt(function () {
      return functorList;
  }, Data_Semigroup.append(semigroupList));
  var plusList = new Control_Plus.Plus(function () {
      return altList;
  }, Nil.value);
  var applicativeNonEmptyList = new Control_Applicative.Applicative(function () {
      return applyNonEmptyList;
  }, (function () {
      var $236 = Data_NonEmpty.singleton(plusList);
      return function ($237) {
          return NonEmptyList($236($237));
      };
  })());
  exports["Nil"] = Nil;
  exports["Cons"] = Cons;
  exports["NonEmptyList"] = NonEmptyList;
  exports["eqList"] = eqList;
  exports["semigroupList"] = semigroupList;
  exports["monoidList"] = monoidList;
  exports["functorList"] = functorList;
  exports["functorWithIndexList"] = functorWithIndexList;
  exports["foldableList"] = foldableList;
  exports["unfoldableList"] = unfoldableList;
  exports["traversableList"] = traversableList;
  exports["applicativeList"] = applicativeList;
  exports["bindList"] = bindList;
  exports["plusList"] = plusList;
  exports["showNonEmptyList"] = showNonEmptyList;
  exports["functorNonEmptyList"] = functorNonEmptyList;
  exports["applicativeNonEmptyList"] = applicativeNonEmptyList;
  exports["semigroupNonEmptyList"] = semigroupNonEmptyList;
  exports["foldableNonEmptyList"] = foldableNonEmptyList;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.List.NonEmpty"] = $PS["Data.List.NonEmpty"] || {};
  var exports = $PS["Data.List.NonEmpty"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_NonEmpty = $PS["Data.NonEmpty"];
  var singleton = (function () {
      var $172 = Data_NonEmpty.singleton(Data_List_Types.plusList);
      return function ($173) {
          return Data_List_Types.NonEmptyList($172($173));
      };
  })();
  var head = function (v) {
      return v.value0;
  };
  var cons$prime = function (x) {
      return function (xs) {
          return new Data_NonEmpty.NonEmpty(x, xs);
      };
  };
  exports["singleton"] = singleton;
  exports["cons'"] = cons$prime;
  exports["head"] = head;
})(PS);
(function(exports) {
  /* eslint-disable no-eq-null, eqeqeq */

  "use strict";

  exports["null"] = null;

  exports.nullable = function (a, r, f) {
    return a == null ? r : f(a);
  };

  exports.notNull = function (x) {
    return x;
  };
})(PS["Data.Nullable"] = PS["Data.Nullable"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Nullable"] = $PS["Data.Nullable"] || {};
  var exports = $PS["Data.Nullable"];
  var $foreign = $PS["Data.Nullable"];
  var Data_Maybe = $PS["Data.Maybe"];              
  var toNullable = Data_Maybe.maybe($foreign["null"])($foreign.notNull);
  var toMaybe = function (n) {
      return $foreign.nullable(n, Data_Maybe.Nothing.value, Data_Maybe.Just.create);
  };
  exports["toMaybe"] = toMaybe;
  exports["toNullable"] = toNullable;
  exports["null"] = $foreign["null"];
})(PS);
(function(exports) {
  /* globals setImmediate, clearImmediate, setTimeout, clearTimeout */
  /* eslint-disable no-unused-vars, no-prototype-builtins, no-use-before-define, no-unused-labels, no-param-reassign */
  "use strict";

  var Aff = function () {
    // A unique value for empty.
    var EMPTY = {};

    /*

  An awkward approximation. We elide evidence we would otherwise need in PS for
  efficiency sake.

  data Aff eff a
    = Pure a
    | Throw Error
    | Catch (Aff eff a) (Error -> Aff eff a)
    | Sync (Eff eff a)
    | Async ((Either Error a -> Eff eff Unit) -> Eff eff (Canceler eff))
    | forall b. Bind (Aff eff b) (b -> Aff eff a)
    | forall b. Bracket (Aff eff b) (BracketConditions eff b) (b -> Aff eff a)
    | forall b. Fork Boolean (Aff eff b) ?(Fiber eff b -> a)
    | Sequential (ParAff aff a)

  */  
    var PURE    = "Pure";
    var THROW   = "Throw";
    var CATCH   = "Catch";
    var SYNC    = "Sync";
    var ASYNC   = "Async";
    var BIND    = "Bind";
    var BRACKET = "Bracket";
    var FORK    = "Fork";
    var SEQ     = "Sequential";

    /*

  data ParAff eff a
    = forall b. Map (b -> a) (ParAff eff b)
    | forall b. Apply (ParAff eff (b -> a)) (ParAff eff b)
    | Alt (ParAff eff a) (ParAff eff a)
    | ?Par (Aff eff a)

  */  
    var MAP   = "Map";
    var APPLY = "Apply";
    var ALT   = "Alt";

    // Various constructors used in interpretation
    var CONS      = "Cons";      // Cons-list, for stacks
    var RESUME    = "Resume";    // Continue indiscriminately
    var RELEASE   = "Release";   // Continue with bracket finalizers
    var FINALIZER = "Finalizer"; // A non-interruptible effect
    var FINALIZED = "Finalized"; // Marker for finalization
    var FORKED    = "Forked";    // Reference to a forked fiber, with resumption stack
    var FIBER     = "Fiber";     // Actual fiber reference
    var THUNK     = "Thunk";     // Primed effect, ready to invoke

    function Aff(tag, _1, _2, _3) {
      this.tag = tag;
      this._1  = _1;
      this._2  = _2;
      this._3  = _3;
    }

    function AffCtr(tag) {
      var fn = function (_1, _2, _3) {
        return new Aff(tag, _1, _2, _3);
      };
      fn.tag = tag;
      return fn;
    }

    function nonCanceler(error) {
      return new Aff(PURE, void 0);
    }

    function runEff(eff) {
      try {
        eff();
      } catch (error) {
        setTimeout(function () {
          throw error;
        }, 0);
      }
    }

    function runSync(left, right, eff) {
      try {
        return right(eff());
      } catch (error) {
        return left(error);
      }
    }

    function runAsync(left, eff, k) {
      try {
        return eff(k)();
      } catch (error) {
        k(left(error))();
        return nonCanceler;
      }
    }

    var Scheduler = function () {
      var limit    = 1024;
      var size     = 0;
      var ix       = 0;
      var queue    = new Array(limit);
      var draining = false;

      function drain() {
        var thunk;
        draining = true;
        while (size !== 0) {
          size--;
          thunk     = queue[ix];
          queue[ix] = void 0;
          ix        = (ix + 1) % limit;
          thunk();
        }
        draining = false;
      }

      return {
        isDraining: function () {
          return draining;
        },
        enqueue: function (cb) {
          var i, tmp;
          if (size === limit) {
            tmp = draining;
            drain();
            draining = tmp;
          }

          queue[(ix + size) % limit] = cb;
          size++;

          if (!draining) {
            drain();
          }
        }
      };
    }();

    function Supervisor(util) {
      var fibers  = {};
      var fiberId = 0;
      var count   = 0;

      return {
        register: function (fiber) {
          var fid = fiberId++;
          fiber.onComplete({
            rethrow: true,
            handler: function (result) {
              return function () {
                count--;
                delete fibers[fid];
              };
            }
          })();
          fibers[fid] = fiber;
          count++;
        },
        isEmpty: function () {
          return count === 0;
        },
        killAll: function (killError, cb) {
          return function () {
            if (count === 0) {
              return cb();
            }

            var killCount = 0;
            var kills     = {};

            function kill(fid) {
              kills[fid] = fibers[fid].kill(killError, function (result) {
                return function () {
                  delete kills[fid];
                  killCount--;
                  if (util.isLeft(result) && util.fromLeft(result)) {
                    setTimeout(function () {
                      throw util.fromLeft(result);
                    }, 0);
                  }
                  if (killCount === 0) {
                    cb();
                  }
                };
              })();
            }

            for (var k in fibers) {
              if (fibers.hasOwnProperty(k)) {
                killCount++;
                kill(k);
              }
            }

            fibers  = {};
            fiberId = 0;
            count   = 0;

            return function (error) {
              return new Aff(SYNC, function () {
                for (var k in kills) {
                  if (kills.hasOwnProperty(k)) {
                    kills[k]();
                  }
                }
              });
            };
          };
        }
      };
    }

    // Fiber state machine
    var SUSPENDED   = 0; // Suspended, pending a join.
    var CONTINUE    = 1; // Interpret the next instruction.
    var STEP_BIND   = 2; // Apply the next bind.
    var STEP_RESULT = 3; // Handle potential failure from a result.
    var PENDING     = 4; // An async effect is running.
    var RETURN      = 5; // The current stack has returned.
    var COMPLETED   = 6; // The entire fiber has completed.

    function Fiber(util, supervisor, aff) {
      // Monotonically increasing tick, increased on each asynchronous turn.
      var runTick = 0;

      // The current branch of the state machine.
      var status = SUSPENDED;

      // The current point of interest for the state machine branch.
      var step      = aff;  // Successful step
      var fail      = null; // Failure step
      var interrupt = null; // Asynchronous interrupt

      // Stack of continuations for the current fiber.
      var bhead = null;
      var btail = null;

      // Stack of attempts and finalizers for error recovery. Every `Cons` is also
      // tagged with current `interrupt` state. We use this to track which items
      // should be ignored or evaluated as a result of a kill.
      var attempts = null;

      // A special state is needed for Bracket, because it cannot be killed. When
      // we enter a bracket acquisition or finalizer, we increment the counter,
      // and then decrement once complete.
      var bracketCount = 0;

      // Each join gets a new id so they can be revoked.
      var joinId  = 0;
      var joins   = null;
      var rethrow = true;

      // Each invocation of `run` requires a tick. When an asynchronous effect is
      // resolved, we must check that the local tick coincides with the fiber
      // tick before resuming. This prevents multiple async continuations from
      // accidentally resuming the same fiber. A common example may be invoking
      // the provided callback in `makeAff` more than once, but it may also be an
      // async effect resuming after the fiber was already cancelled.
      function run(localRunTick) {
        var tmp, result, attempt;
        while (true) {
          tmp       = null;
          result    = null;
          attempt   = null;

          switch (status) {
          case STEP_BIND:
            status = CONTINUE;
            try {
              step   = bhead(step);
              if (btail === null) {
                bhead = null;
              } else {
                bhead = btail._1;
                btail = btail._2;
              }
            } catch (e) {
              status = RETURN;
              fail   = util.left(e);
              step   = null;
            }
            break;

          case STEP_RESULT:
            if (util.isLeft(step)) {
              status = RETURN;
              fail   = step;
              step   = null;
            } else if (bhead === null) {
              status = RETURN;
            } else {
              status = STEP_BIND;
              step   = util.fromRight(step);
            }
            break;

          case CONTINUE:
            switch (step.tag) {
            case BIND:
              if (bhead) {
                btail = new Aff(CONS, bhead, btail);
              }
              bhead  = step._2;
              status = CONTINUE;
              step   = step._1;
              break;

            case PURE:
              if (bhead === null) {
                status = RETURN;
                step   = util.right(step._1);
              } else {
                status = STEP_BIND;
                step   = step._1;
              }
              break;

            case SYNC:
              status = STEP_RESULT;
              step   = runSync(util.left, util.right, step._1);
              break;

            case ASYNC:
              status = PENDING;
              step   = runAsync(util.left, step._1, function (result) {
                return function () {
                  if (runTick !== localRunTick) {
                    return;
                  }
                  runTick++;
                  Scheduler.enqueue(function () {
                    // It's possible to interrupt the fiber between enqueuing and
                    // resuming, so we need to check that the runTick is still
                    // valid.
                    if (runTick !== localRunTick + 1) {
                      return;
                    }
                    status = STEP_RESULT;
                    step   = result;
                    run(runTick);
                  });
                };
              });
              return;

            case THROW:
              status = RETURN;
              fail   = util.left(step._1);
              step   = null;
              break;

            // Enqueue the Catch so that we can call the error handler later on
            // in case of an exception.
            case CATCH:
              if (bhead === null) {
                attempts = new Aff(CONS, step, attempts, interrupt);
              } else {
                attempts = new Aff(CONS, step, new Aff(CONS, new Aff(RESUME, bhead, btail), attempts, interrupt), interrupt);
              }
              bhead    = null;
              btail    = null;
              status   = CONTINUE;
              step     = step._1;
              break;

            // Enqueue the Bracket so that we can call the appropriate handlers
            // after resource acquisition.
            case BRACKET:
              bracketCount++;
              if (bhead === null) {
                attempts = new Aff(CONS, step, attempts, interrupt);
              } else {
                attempts = new Aff(CONS, step, new Aff(CONS, new Aff(RESUME, bhead, btail), attempts, interrupt), interrupt);
              }
              bhead  = null;
              btail  = null;
              status = CONTINUE;
              step   = step._1;
              break;

            case FORK:
              status = STEP_RESULT;
              tmp    = Fiber(util, supervisor, step._2);
              if (supervisor) {
                supervisor.register(tmp);
              }
              if (step._1) {
                tmp.run();
              }
              step = util.right(tmp);
              break;

            case SEQ:
              status = CONTINUE;
              step   = sequential(util, supervisor, step._1);
              break;
            }
            break;

          case RETURN:
            bhead = null;
            btail = null;
            // If the current stack has returned, and we have no other stacks to
            // resume or finalizers to run, the fiber has halted and we can
            // invoke all join callbacks. Otherwise we need to resume.
            if (attempts === null) {
              status = COMPLETED;
              step   = interrupt || fail || step;
            } else {
              // The interrupt status for the enqueued item.
              tmp      = attempts._3;
              attempt  = attempts._1;
              attempts = attempts._2;

              switch (attempt.tag) {
              // We cannot recover from an unmasked interrupt. Otherwise we should
              // continue stepping, or run the exception handler if an exception
              // was raised.
              case CATCH:
                // We should compare the interrupt status as well because we
                // only want it to apply if there has been an interrupt since
                // enqueuing the catch.
                if (interrupt && interrupt !== tmp && bracketCount === 0) {
                  status = RETURN;
                } else if (fail) {
                  status = CONTINUE;
                  step   = attempt._2(util.fromLeft(fail));
                  fail   = null;
                }
                break;

              // We cannot resume from an unmasked interrupt or exception.
              case RESUME:
                // As with Catch, we only want to ignore in the case of an
                // interrupt since enqueing the item.
                if (interrupt && interrupt !== tmp && bracketCount === 0 || fail) {
                  status = RETURN;
                } else {
                  bhead  = attempt._1;
                  btail  = attempt._2;
                  status = STEP_BIND;
                  step   = util.fromRight(step);
                }
                break;

              // If we have a bracket, we should enqueue the handlers,
              // and continue with the success branch only if the fiber has
              // not been interrupted. If the bracket acquisition failed, we
              // should not run either.
              case BRACKET:
                bracketCount--;
                if (fail === null) {
                  result   = util.fromRight(step);
                  // We need to enqueue the Release with the same interrupt
                  // status as the Bracket that is initiating it.
                  attempts = new Aff(CONS, new Aff(RELEASE, attempt._2, result), attempts, tmp);
                  // We should only coninue as long as the interrupt status has not changed or
                  // we are currently within a non-interruptable finalizer.
                  if (interrupt === tmp || bracketCount > 0) {
                    status = CONTINUE;
                    step   = attempt._3(result);
                  }
                }
                break;

              // Enqueue the appropriate handler. We increase the bracket count
              // because it should not be cancelled.
              case RELEASE:
                attempts = new Aff(CONS, new Aff(FINALIZED, step, fail), attempts, interrupt);
                status   = CONTINUE;
                // It has only been killed if the interrupt status has changed
                // since we enqueued the item, and the bracket count is 0. If the
                // bracket count is non-zero then we are in a masked state so it's
                // impossible to be killed.
                if (interrupt && interrupt !== tmp && bracketCount === 0) {
                  step = attempt._1.killed(util.fromLeft(interrupt))(attempt._2);
                } else if (fail) {
                  step = attempt._1.failed(util.fromLeft(fail))(attempt._2);
                } else {
                  step = attempt._1.completed(util.fromRight(step))(attempt._2);
                }
                fail = null;
                bracketCount++;
                break;

              case FINALIZER:
                bracketCount++;
                attempts = new Aff(CONS, new Aff(FINALIZED, step, fail), attempts, interrupt);
                status   = CONTINUE;
                step     = attempt._1;
                break;

              case FINALIZED:
                bracketCount--;
                status = RETURN;
                step   = attempt._1;
                fail   = attempt._2;
                break;
              }
            }
            break;

          case COMPLETED:
            for (var k in joins) {
              if (joins.hasOwnProperty(k)) {
                rethrow = rethrow && joins[k].rethrow;
                runEff(joins[k].handler(step));
              }
            }
            joins = null;
            // If we have an interrupt and a fail, then the thread threw while
            // running finalizers. This should always rethrow in a fresh stack.
            if (interrupt && fail) {
              setTimeout(function () {
                throw util.fromLeft(fail);
              }, 0);
            // If we have an unhandled exception, and no other fiber has joined
            // then we need to throw the exception in a fresh stack.
            } else if (util.isLeft(step) && rethrow) {
              setTimeout(function () {
                // Guard on reathrow because a completely synchronous fiber can
                // still have an observer which was added after-the-fact.
                if (rethrow) {
                  throw util.fromLeft(step);
                }
              }, 0);
            }
            return;
          case SUSPENDED:
            status = CONTINUE;
            break;
          case PENDING: return;
          }
        }
      }

      function onComplete(join) {
        return function () {
          if (status === COMPLETED) {
            rethrow = rethrow && join.rethrow;
            join.handler(step)();
            return function () {};
          }

          var jid    = joinId++;
          joins      = joins || {};
          joins[jid] = join;

          return function() {
            if (joins !== null) {
              delete joins[jid];
            }
          };
        };
      }

      function kill(error, cb) {
        return function () {
          if (status === COMPLETED) {
            cb(util.right(void 0))();
            return function () {};
          }

          var canceler = onComplete({
            rethrow: false,
            handler: function (/* unused */) {
              return cb(util.right(void 0));
            }
          })();

          switch (status) {
          case SUSPENDED:
            interrupt = util.left(error);
            status    = COMPLETED;
            step      = interrupt;
            run(runTick);
            break;
          case PENDING:
            if (interrupt === null) {
              interrupt = util.left(error);
            }
            if (bracketCount === 0) {
              if (status === PENDING) {
                attempts = new Aff(CONS, new Aff(FINALIZER, step(error)), attempts, interrupt);
              }
              status   = RETURN;
              step     = null;
              fail     = null;
              run(++runTick);
            }
            break;
          default:
            if (interrupt === null) {
              interrupt = util.left(error);
            }
            if (bracketCount === 0) {
              status = RETURN;
              step   = null;
              fail   = null;
            }
          }

          return canceler;
        };
      }

      function join(cb) {
        return function () {
          var canceler = onComplete({
            rethrow: false,
            handler: cb
          })();
          if (status === SUSPENDED) {
            run(runTick);
          }
          return canceler;
        };
      }

      return {
        kill: kill,
        join: join,
        onComplete: onComplete,
        isSuspended: function () {
          return status === SUSPENDED;
        },
        run: function () {
          if (status === SUSPENDED) {
            if (!Scheduler.isDraining()) {
              Scheduler.enqueue(function () {
                run(runTick);
              });
            } else {
              run(runTick);
            }
          }
        }
      };
    }

    function runPar(util, supervisor, par, cb) {
      // Table of all forked fibers.
      var fiberId   = 0;
      var fibers    = {};

      // Table of currently running cancelers, as a product of `Alt` behavior.
      var killId    = 0;
      var kills     = {};

      // Error used for early cancelation on Alt branches.
      var early     = new Error("[ParAff] Early exit");

      // Error used to kill the entire tree.
      var interrupt = null;

      // The root pointer of the tree.
      var root      = EMPTY;

      // Walks a tree, invoking all the cancelers. Returns the table of pending
      // cancellation fibers.
      function kill(error, par, cb) {
        var step  = par;
        var head  = null;
        var tail  = null;
        var count = 0;
        var kills = {};
        var tmp, kid;

        loop: while (true) {
          tmp = null;

          switch (step.tag) {
          case FORKED:
            if (step._3 === EMPTY) {
              tmp = fibers[step._1];
              kills[count++] = tmp.kill(error, function (result) {
                return function () {
                  count--;
                  if (count === 0) {
                    cb(result)();
                  }
                };
              });
            }
            // Terminal case.
            if (head === null) {
              break loop;
            }
            // Go down the right side of the tree.
            step = head._2;
            if (tail === null) {
              head = null;
            } else {
              head = tail._1;
              tail = tail._2;
            }
            break;
          case MAP:
            step = step._2;
            break;
          case APPLY:
          case ALT:
            if (head) {
              tail = new Aff(CONS, head, tail);
            }
            head = step;
            step = step._1;
            break;
          }
        }

        if (count === 0) {
          cb(util.right(void 0))();
        } else {
          // Run the cancelation effects. We alias `count` because it's mutable.
          kid = 0;
          tmp = count;
          for (; kid < tmp; kid++) {
            kills[kid] = kills[kid]();
          }
        }

        return kills;
      }

      // When a fiber resolves, we need to bubble back up the tree with the
      // result, computing the applicative nodes.
      function join(result, head, tail) {
        var fail, step, lhs, rhs, tmp, kid;

        if (util.isLeft(result)) {
          fail = result;
          step = null;
        } else {
          step = result;
          fail = null;
        }

        loop: while (true) {
          lhs = null;
          rhs = null;
          tmp = null;
          kid = null;

          // We should never continue if the entire tree has been interrupted.
          if (interrupt !== null) {
            return;
          }

          // We've made it all the way to the root of the tree, which means
          // the tree has fully evaluated.
          if (head === null) {
            cb(fail || step)();
            return;
          }

          // The tree has already been computed, so we shouldn't try to do it
          // again. This should never happen.
          // TODO: Remove this?
          if (head._3 !== EMPTY) {
            return;
          }

          switch (head.tag) {
          case MAP:
            if (fail === null) {
              head._3 = util.right(head._1(util.fromRight(step)));
              step    = head._3;
            } else {
              head._3 = fail;
            }
            break;
          case APPLY:
            lhs = head._1._3;
            rhs = head._2._3;
            // If we have a failure we should kill the other side because we
            // can't possible yield a result anymore.
            if (fail) {
              head._3 = fail;
              tmp     = true;
              kid     = killId++;

              kills[kid] = kill(early, fail === lhs ? head._2 : head._1, function (/* unused */) {
                return function () {
                  delete kills[kid];
                  if (tmp) {
                    tmp = false;
                  } else if (tail === null) {
                    join(fail, null, null);
                  } else {
                    join(fail, tail._1, tail._2);
                  }
                };
              });

              if (tmp) {
                tmp = false;
                return;
              }
            } else if (lhs === EMPTY || rhs === EMPTY) {
              // We can only proceed if both sides have resolved.
              return;
            } else {
              step    = util.right(util.fromRight(lhs)(util.fromRight(rhs)));
              head._3 = step;
            }
            break;
          case ALT:
            lhs = head._1._3;
            rhs = head._2._3;
            // We can only proceed if both have resolved or we have a success
            if (lhs === EMPTY && util.isLeft(rhs) || rhs === EMPTY && util.isLeft(lhs)) {
              return;
            }
            // If both sides resolve with an error, we should continue with the
            // first error
            if (lhs !== EMPTY && util.isLeft(lhs) && rhs !== EMPTY && util.isLeft(rhs)) {
              fail    = step === lhs ? rhs : lhs;
              step    = null;
              head._3 = fail;
            } else {
              head._3 = step;
              tmp     = true;
              kid     = killId++;
              // Once a side has resolved, we need to cancel the side that is still
              // pending before we can continue.
              kills[kid] = kill(early, step === lhs ? head._2 : head._1, function (/* unused */) {
                return function () {
                  delete kills[kid];
                  if (tmp) {
                    tmp = false;
                  } else if (tail === null) {
                    join(step, null, null);
                  } else {
                    join(step, tail._1, tail._2);
                  }
                };
              });

              if (tmp) {
                tmp = false;
                return;
              }
            }
            break;
          }

          if (tail === null) {
            head = null;
          } else {
            head = tail._1;
            tail = tail._2;
          }
        }
      }

      function resolve(fiber) {
        return function (result) {
          return function () {
            delete fibers[fiber._1];
            fiber._3 = result;
            join(result, fiber._2._1, fiber._2._2);
          };
        };
      }

      // Walks the applicative tree, substituting non-applicative nodes with
      // `FORKED` nodes. In this tree, all applicative nodes use the `_3` slot
      // as a mutable slot for memoization. In an unresolved state, the `_3`
      // slot is `EMPTY`. In the cases of `ALT` and `APPLY`, we always walk
      // the left side first, because both operations are left-associative. As
      // we `RETURN` from those branches, we then walk the right side.
      function run() {
        var status = CONTINUE;
        var step   = par;
        var head   = null;
        var tail   = null;
        var tmp, fid;

        loop: while (true) {
          tmp = null;
          fid = null;

          switch (status) {
          case CONTINUE:
            switch (step.tag) {
            case MAP:
              if (head) {
                tail = new Aff(CONS, head, tail);
              }
              head = new Aff(MAP, step._1, EMPTY, EMPTY);
              step = step._2;
              break;
            case APPLY:
              if (head) {
                tail = new Aff(CONS, head, tail);
              }
              head = new Aff(APPLY, EMPTY, step._2, EMPTY);
              step = step._1;
              break;
            case ALT:
              if (head) {
                tail = new Aff(CONS, head, tail);
              }
              head = new Aff(ALT, EMPTY, step._2, EMPTY);
              step = step._1;
              break;
            default:
              // When we hit a leaf value, we suspend the stack in the `FORKED`.
              // When the fiber resolves, it can bubble back up the tree.
              fid    = fiberId++;
              status = RETURN;
              tmp    = step;
              step   = new Aff(FORKED, fid, new Aff(CONS, head, tail), EMPTY);
              tmp    = Fiber(util, supervisor, tmp);
              tmp.onComplete({
                rethrow: false,
                handler: resolve(step)
              })();
              fibers[fid] = tmp;
              if (supervisor) {
                supervisor.register(tmp);
              }
            }
            break;
          case RETURN:
            // Terminal case, we are back at the root.
            if (head === null) {
              break loop;
            }
            // If we are done with the right side, we need to continue down the
            // left. Otherwise we should continue up the stack.
            if (head._1 === EMPTY) {
              head._1 = step;
              status  = CONTINUE;
              step    = head._2;
              head._2 = EMPTY;
            } else {
              head._2 = step;
              step    = head;
              if (tail === null) {
                head  = null;
              } else {
                head  = tail._1;
                tail  = tail._2;
              }
            }
          }
        }

        // Keep a reference to the tree root so it can be cancelled.
        root = step;

        for (fid = 0; fid < fiberId; fid++) {
          fibers[fid].run();
        }
      }

      // Cancels the entire tree. If there are already subtrees being canceled,
      // we need to first cancel those joins. We will then add fresh joins for
      // all pending branches including those that were in the process of being
      // canceled.
      function cancel(error, cb) {
        interrupt = util.left(error);
        var innerKills;
        for (var kid in kills) {
          if (kills.hasOwnProperty(kid)) {
            innerKills = kills[kid];
            for (kid in innerKills) {
              if (innerKills.hasOwnProperty(kid)) {
                innerKills[kid]();
              }
            }
          }
        }

        kills = null;
        var newKills = kill(error, root, cb);

        return function (killError) {
          return new Aff(ASYNC, function (killCb) {
            return function () {
              for (var kid in newKills) {
                if (newKills.hasOwnProperty(kid)) {
                  newKills[kid]();
                }
              }
              return nonCanceler;
            };
          });
        };
      }

      run();

      return function (killError) {
        return new Aff(ASYNC, function (killCb) {
          return function () {
            return cancel(killError, killCb);
          };
        });
      };
    }

    function sequential(util, supervisor, par) {
      return new Aff(ASYNC, function (cb) {
        return function () {
          return runPar(util, supervisor, par, cb);
        };
      });
    }

    Aff.EMPTY       = EMPTY;
    Aff.Pure        = AffCtr(PURE);
    Aff.Throw       = AffCtr(THROW);
    Aff.Catch       = AffCtr(CATCH);
    Aff.Sync        = AffCtr(SYNC);
    Aff.Async       = AffCtr(ASYNC);
    Aff.Bind        = AffCtr(BIND);
    Aff.Bracket     = AffCtr(BRACKET);
    Aff.Fork        = AffCtr(FORK);
    Aff.Seq         = AffCtr(SEQ);
    Aff.ParMap      = AffCtr(MAP);
    Aff.ParApply    = AffCtr(APPLY);
    Aff.ParAlt      = AffCtr(ALT);
    Aff.Fiber       = Fiber;
    Aff.Supervisor  = Supervisor;
    Aff.Scheduler   = Scheduler;
    Aff.nonCanceler = nonCanceler;

    return Aff;
  }();

  exports._pure = Aff.Pure;

  exports._throwError = Aff.Throw;

  exports._catchError = function (aff) {
    return function (k) {
      return Aff.Catch(aff, k);
    };
  };

  exports._map = function (f) {
    return function (aff) {
      if (aff.tag === Aff.Pure.tag) {
        return Aff.Pure(f(aff._1));
      } else {
        return Aff.Bind(aff, function (value) {
          return Aff.Pure(f(value));
        });
      }
    };
  };

  exports._bind = function (aff) {
    return function (k) {
      return Aff.Bind(aff, k);
    };
  };

  exports._liftEffect = Aff.Sync;

  exports._parAffMap = function (f) {
    return function (aff) {
      return Aff.ParMap(f, aff);
    };
  };

  exports._parAffApply = function (aff1) {
    return function (aff2) {
      return Aff.ParApply(aff1, aff2);
    };
  };

  exports.makeAff = Aff.Async;

  exports._makeFiber = function (util, aff) {
    return function () {
      return Aff.Fiber(util, null, aff);
    };
  };  

  exports._sequential = Aff.Seq;
})(PS["Effect.Aff"] = PS["Effect.Aff"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Parallel.Class"] = $PS["Control.Parallel.Class"] || {};
  var exports = $PS["Control.Parallel.Class"];       
  var Parallel = function (Applicative1, Monad0, parallel, sequential) {
      this.Applicative1 = Applicative1;
      this.Monad0 = Monad0;
      this.parallel = parallel;
      this.sequential = sequential;
  };
  var sequential = function (dict) {
      return dict.sequential;
  };
  var parallel = function (dict) {
      return dict.parallel;
  };
  exports["parallel"] = parallel;
  exports["sequential"] = sequential;
  exports["Parallel"] = Parallel;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Parallel"] = $PS["Control.Parallel"] || {};
  var exports = $PS["Control.Parallel"];
  var Control_Category = $PS["Control.Category"];
  var Control_Parallel_Class = $PS["Control.Parallel.Class"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Traversable = $PS["Data.Traversable"];                
  var parTraverse_ = function (dictParallel) {
      return function (dictFoldable) {
          return function (f) {
              var $17 = Control_Parallel_Class.sequential(dictParallel);
              var $18 = Data_Foldable.traverse_(dictParallel.Applicative1())(dictFoldable)((function () {
                  var $20 = Control_Parallel_Class.parallel(dictParallel);
                  return function ($21) {
                      return $20(f($21));
                  };
              })());
              return function ($19) {
                  return $17($18($19));
              };
          };
      };
  };
  var parTraverse = function (dictParallel) {
      return function (dictTraversable) {
          return function (f) {
              var $22 = Control_Parallel_Class.sequential(dictParallel);
              var $23 = Data_Traversable.traverse(dictTraversable)(dictParallel.Applicative1())((function () {
                  var $25 = Control_Parallel_Class.parallel(dictParallel);
                  return function ($26) {
                      return $25(f($26));
                  };
              })());
              return function ($24) {
                  return $22($23($24));
              };
          };
      };
  };
  var parSequence_ = function (dictParallel) {
      return function (dictFoldable) {
          return parTraverse_(dictParallel)(dictFoldable)(Control_Category.identity(Control_Category.categoryFn));
      };
  };
  exports["parTraverse"] = parTraverse;
  exports["parSequence_"] = parSequence_;
})(PS);
(function(exports) {
  "use strict";

  exports.pureE = function (a) {
    return function () {
      return a;
    };
  };

  exports.bindE = function (a) {
    return function (f) {
      return function () {
        return f(a())();
      };
    };
  };
})(PS["Effect"] = PS["Effect"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect"] = $PS["Effect"] || {};
  var exports = $PS["Effect"];
  var $foreign = $PS["Effect"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad = $PS["Control.Monad"];
  var Data_Functor = $PS["Data.Functor"];                    
  var monadEffect = new Control_Monad.Monad(function () {
      return applicativeEffect;
  }, function () {
      return bindEffect;
  });
  var bindEffect = new Control_Bind.Bind(function () {
      return applyEffect;
  }, $foreign.bindE);
  var applyEffect = new Control_Apply.Apply(function () {
      return functorEffect;
  }, Control_Monad.ap(monadEffect));
  var applicativeEffect = new Control_Applicative.Applicative(function () {
      return applyEffect;
  }, $foreign.pureE);
  var functorEffect = new Data_Functor.Functor(Control_Applicative.liftA1(applicativeEffect));
  exports["functorEffect"] = functorEffect;
  exports["applyEffect"] = applyEffect;
  exports["applicativeEffect"] = applicativeEffect;
  exports["bindEffect"] = bindEffect;
  exports["monadEffect"] = monadEffect;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Class"] = $PS["Effect.Class"] || {};
  var exports = $PS["Effect.Class"];
  var Control_Category = $PS["Control.Category"];
  var Effect = $PS["Effect"];                
  var MonadEffect = function (Monad0, liftEffect) {
      this.Monad0 = Monad0;
      this.liftEffect = liftEffect;
  };
  var monadEffectEffect = new MonadEffect(function () {
      return Effect.monadEffect;
  }, Control_Category.identity(Control_Category.categoryFn));
  var liftEffect = function (dict) {
      return dict.liftEffect;
  };
  exports["liftEffect"] = liftEffect;
  exports["MonadEffect"] = MonadEffect;
  exports["monadEffectEffect"] = monadEffectEffect;
})(PS);
(function(exports) {
  "use strict";

  // module Partial.Unsafe

  exports._unsafePartial = function (f) {
    return f();
  };
})(PS["Partial.Unsafe"] = PS["Partial.Unsafe"] || {});
(function(exports) {
  "use strict";

  // module Partial

  exports._crashWith = function (msg) {
    throw new Error(msg);
  };
})(PS["Partial"] = PS["Partial"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Partial"] = $PS["Partial"] || {};
  var exports = $PS["Partial"];
  var $foreign = $PS["Partial"];         
  var crashWith = function (dictPartial) {
      return $foreign["_crashWith"];
  };
  exports["crashWith"] = crashWith;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Partial.Unsafe"] = $PS["Partial.Unsafe"] || {};
  var exports = $PS["Partial.Unsafe"];
  var $foreign = $PS["Partial.Unsafe"];
  var Partial = $PS["Partial"];                
  var unsafePartial = $foreign["_unsafePartial"];
  var unsafeCrashWith = function (msg) {
      return unsafePartial(function (dictPartial) {
          return Partial.crashWith()(msg);
      });
  };
  exports["unsafeCrashWith"] = unsafeCrashWith;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Aff"] = $PS["Effect.Aff"] || {};
  var exports = $PS["Effect.Aff"];
  var $foreign = $PS["Effect.Aff"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad = $PS["Control.Monad"];
  var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
  var Control_Parallel = $PS["Control.Parallel"];
  var Control_Parallel_Class = $PS["Control.Parallel.Class"];
  var Data_Either = $PS["Data.Either"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Class = $PS["Effect.Class"];
  var Partial_Unsafe = $PS["Partial.Unsafe"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];
  var Canceler = function (x) {
      return x;
  }; 
  var functorParAff = new Data_Functor.Functor($foreign["_parAffMap"]);
  var functorAff = new Data_Functor.Functor($foreign["_map"]);
  var ffiUtil = (function () {
      var unsafeFromRight = function (v) {
          if (v instanceof Data_Either.Right) {
              return v.value0;
          };
          if (v instanceof Data_Either.Left) {
              return Partial_Unsafe.unsafeCrashWith("unsafeFromRight: Left");
          };
          throw new Error("Failed pattern match at Effect.Aff (line 404, column 21 - line 406, column 54): " + [ v.constructor.name ]);
      };
      var unsafeFromLeft = function (v) {
          if (v instanceof Data_Either.Left) {
              return v.value0;
          };
          if (v instanceof Data_Either.Right) {
              return Partial_Unsafe.unsafeCrashWith("unsafeFromLeft: Right");
          };
          throw new Error("Failed pattern match at Effect.Aff (line 399, column 20 - line 401, column 54): " + [ v.constructor.name ]);
      };
      var isLeft = function (v) {
          if (v instanceof Data_Either.Left) {
              return true;
          };
          if (v instanceof Data_Either.Right) {
              return false;
          };
          throw new Error("Failed pattern match at Effect.Aff (line 394, column 12 - line 396, column 20): " + [ v.constructor.name ]);
      };
      return {
          isLeft: isLeft,
          fromLeft: unsafeFromLeft,
          fromRight: unsafeFromRight,
          left: Data_Either.Left.create,
          right: Data_Either.Right.create
      };
  })();
  var makeFiber = function (aff) {
      return $foreign["_makeFiber"](ffiUtil, aff);
  };
  var launchAff = function (aff) {
      return function __do() {
          var fiber = makeFiber(aff)();
          fiber.run();
          return fiber;
      };
  };
  var launchAff_ = (function () {
      var $40 = Data_Functor["void"](Effect.functorEffect);
      return function ($41) {
          return $40(launchAff($41));
      };
  })();
  var applyParAff = new Control_Apply.Apply(function () {
      return functorParAff;
  }, $foreign["_parAffApply"]);
  var monadAff = new Control_Monad.Monad(function () {
      return applicativeAff;
  }, function () {
      return bindAff;
  });
  var bindAff = new Control_Bind.Bind(function () {
      return applyAff;
  }, $foreign["_bind"]);
  var applyAff = new Control_Apply.Apply(function () {
      return functorAff;
  }, Control_Monad.ap(monadAff));
  var applicativeAff = new Control_Applicative.Applicative(function () {
      return applyAff;
  }, $foreign["_pure"]);
  var monadEffectAff = new Effect_Class.MonadEffect(function () {
      return monadAff;
  }, $foreign["_liftEffect"]);
  var effectCanceler = (function () {
      var $42 = Effect_Class.liftEffect(monadEffectAff);
      return function ($43) {
          return Canceler(Data_Function["const"]($42($43)));
      };
  })();
  var killFiber = function (e) {
      return function (v) {
          return Control_Bind.bind(bindAff)(Effect_Class.liftEffect(monadEffectAff)(v.isSuspended))(function (v1) {
              if (v1) {
                  return Effect_Class.liftEffect(monadEffectAff)(Data_Functor["void"](Effect.functorEffect)(v.kill(e, Data_Function["const"](Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit)))));
              };
              return $foreign.makeAff(function (k) {
                  return Data_Functor.map(Effect.functorEffect)(effectCanceler)(v.kill(e, k));
              });
          });
      };
  };   
  var monadThrowAff = new Control_Monad_Error_Class.MonadThrow(function () {
      return monadAff;
  }, $foreign["_throwError"]);
  var monadErrorAff = new Control_Monad_Error_Class.MonadError(function () {
      return monadThrowAff;
  }, $foreign["_catchError"]);
  var parallelAff = new Control_Parallel_Class.Parallel(function () {
      return applicativeParAff;
  }, function () {
      return monadAff;
  }, Unsafe_Coerce.unsafeCoerce, $foreign["_sequential"]);
  var applicativeParAff = new Control_Applicative.Applicative(function () {
      return applyParAff;
  }, (function () {
      var $50 = Control_Parallel_Class.parallel(parallelAff);
      var $51 = Control_Applicative.pure(applicativeAff);
      return function ($52) {
          return $50($51($52));
      };
  })());
  var semigroupCanceler = new Data_Semigroup.Semigroup(function (v) {
      return function (v1) {
          return function (err) {
              return Control_Parallel.parSequence_(parallelAff)(Data_Foldable.foldableArray)([ v(err), v1(err) ]);
          };
      };
  });
  var nonCanceler = Data_Function["const"](Control_Applicative.pure(applicativeAff)(Data_Unit.unit));
  var monoidCanceler = new Data_Monoid.Monoid(function () {
      return semigroupCanceler;
  }, nonCanceler);
  exports["launchAff"] = launchAff;
  exports["launchAff_"] = launchAff_;
  exports["killFiber"] = killFiber;
  exports["nonCanceler"] = nonCanceler;
  exports["functorAff"] = functorAff;
  exports["applyAff"] = applyAff;
  exports["applicativeAff"] = applicativeAff;
  exports["bindAff"] = bindAff;
  exports["monadThrowAff"] = monadThrowAff;
  exports["monadErrorAff"] = monadErrorAff;
  exports["monadEffectAff"] = monadEffectAff;
  exports["parallelAff"] = parallelAff;
  exports["monoidCanceler"] = monoidCanceler;
  exports["makeAff"] = $foreign.makeAff;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Aff.Compat"] = $PS["Effect.Aff.Compat"] || {};
  var exports = $PS["Effect.Aff.Compat"];
  var Data_Either = $PS["Data.Either"];
  var Effect_Aff = $PS["Effect.Aff"];
  var fromEffectFnAff = function (v) {
      return Effect_Aff.makeAff(function (k) {
          return function __do() {
              var v1 = v(function ($4) {
                  return k(Data_Either.Left.create($4))();
              }, function ($5) {
                  return k(Data_Either.Right.create($5))();
              });
              return function (e) {
                  return Effect_Aff.makeAff(function (k2) {
                      return function __do() {
                          v1(e, function ($6) {
                              return k2(Data_Either.Left.create($6))();
                          }, function ($7) {
                              return k2(Data_Either.Right.create($7))();
                          });
                          return Effect_Aff.nonCanceler;
                      };
                  });
              };
          };
      });
  };
  exports["fromEffectFnAff"] = fromEffectFnAff;
})(PS);
(function(exports) {
  "use strict";

  exports.error = function (msg) {
    return new Error(msg);
  };

  exports.message = function (e) {
    return e.message;
  };

  exports.throwException = function (e) {
    return function () {
      throw e;
    };
  };

  exports.catchException = function (c) {
    return function (t) {
      return function () {
        try {
          return t();
        } catch (e) {
          if (e instanceof Error || Object.prototype.toString.call(e) === "[object Error]") {
            return c(e)();
          } else {
            return c(new Error(e.toString()))();
          }
        }
      };
    };
  };
})(PS["Effect.Exception"] = PS["Effect.Exception"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Exception"] = $PS["Effect.Exception"] || {};
  var exports = $PS["Effect.Exception"];
  var $foreign = $PS["Effect.Exception"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Either = $PS["Data.Either"];
  var Data_Functor = $PS["Data.Functor"];
  var Effect = $PS["Effect"];                
  var $$try = function (action) {
      return $foreign.catchException((function () {
          var $0 = Control_Applicative.pure(Effect.applicativeEffect);
          return function ($1) {
              return $0(Data_Either.Left.create($1));
          };
      })())(Data_Functor.map(Effect.functorEffect)(Data_Either.Right.create)(action));
  };
  exports["try"] = $$try;
  exports["error"] = $foreign.error;
  exports["message"] = $foreign.message;
  exports["throwException"] = $foreign.throwException;
})(PS);
(function(exports) {
  "use strict";

  exports.typeOf = function (value) {
    return typeof value;
  };

  exports.tagOf = function (value) {
    return Object.prototype.toString.call(value).slice(8, -1);
  };

  exports.isNull = function (value) {
    return value === null;
  };

  exports.isUndefined = function (value) {
    return value === undefined;
  };

  exports.isArray = Array.isArray || function (value) {
    return Object.prototype.toString.call(value) === "[object Array]";
  };
})(PS["Foreign"] = PS["Foreign"] || {});
(function(exports) {
  "use strict";

  exports.fromNumberImpl = function (just) {
    return function (nothing) {
      return function (n) {
        /* jshint bitwise: false */
        return (n | 0) === n ? just(n) : nothing;
      };
    };
  };

  exports.toNumber = function (n) {
    return n;
  };

  exports.fromStringAsImpl = function (just) {
    return function (nothing) {
      return function (radix) {
        var digits;
        if (radix < 11) {
          digits = "[0-" + (radix - 1).toString() + "]";
        } else if (radix === 11) {
          digits = "[0-9a]";
        } else {
          digits = "[0-9a-" + String.fromCharCode(86 + radix) + "]";
        }
        var pattern = new RegExp("^[\\+\\-]?" + digits + "+$", "i");

        return function (s) {
          /* jshint bitwise: false */
          if (pattern.test(s)) {
            var i = parseInt(s, radix);
            return (i | 0) === i ? just(i) : nothing;
          } else {
            return nothing;
          }
        };
      };
    };
  };

  exports.toStringAs = function (radix) {
    return function (i) {
      return i.toString(radix);
    };
  };


  exports.quot = function (x) {
    return function (y) {
      /* jshint bitwise: false */
      return x / y | 0;
    };
  };
})(PS["Data.Int"] = PS["Data.Int"] || {});
(function(exports) {
  "use strict";

  exports.topInt = 2147483647;
  exports.bottomInt = -2147483648;

  exports.topChar = String.fromCharCode(65535);
  exports.bottomChar = String.fromCharCode(0);
})(PS["Data.Bounded"] = PS["Data.Bounded"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Bounded"] = $PS["Data.Bounded"] || {};
  var exports = $PS["Data.Bounded"];
  var $foreign = $PS["Data.Bounded"];
  var Data_Ord = $PS["Data.Ord"];
  var Bounded = function (Ord0, bottom, top) {
      this.Ord0 = Ord0;
      this.bottom = bottom;
      this.top = top;
  };
  var top = function (dict) {
      return dict.top;
  };                                            
  var boundedInt = new Bounded(function () {
      return Data_Ord.ordInt;
  }, $foreign.bottomInt, $foreign.topInt);
  var boundedChar = new Bounded(function () {
      return Data_Ord.ordChar;
  }, $foreign.bottomChar, $foreign.topChar);
  var bottom = function (dict) {
      return dict.bottom;
  };
  exports["Bounded"] = Bounded;
  exports["bottom"] = bottom;
  exports["top"] = top;
  exports["boundedInt"] = boundedInt;
  exports["boundedChar"] = boundedChar;
})(PS);
(function(exports) {
  /* globals exports */
  "use strict";     

  exports.isNaN = isNaN;      

  exports.isFinite = isFinite;

  exports.fromStringImpl = function(str, isFinite, just, nothing) {
    var num = parseFloat(str);
    if (isFinite(num)) {
      return just(num);
    } else {
      return nothing;
    }
  };
})(PS["Data.Number"] = PS["Data.Number"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Number"] = $PS["Data.Number"] || {};
  var exports = $PS["Data.Number"];
  var $foreign = $PS["Data.Number"];
  var Data_Maybe = $PS["Data.Maybe"];                
  var fromString = function (str) {
      return $foreign.fromStringImpl(str, $foreign["isFinite"], Data_Maybe.Just.create, Data_Maybe.Nothing.value);
  };
  exports["fromString"] = fromString;
  exports["isNaN"] = $foreign["isNaN"];
  exports["isFinite"] = $foreign["isFinite"];
})(PS);
(function(exports) {
  "use strict";

  // module Math

  exports.abs = Math.abs;

  exports.floor = Math.floor;

  function nativeImul(a) {
    return function (b) {
      return Math.imul(a, b);
    };
  }

  // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
  function emulatedImul(a) {
    /*jshint bitwise: false*/
    return function (b) {
      var ah = a >>> 16 & 0xffff;
      var al = a & 0xffff;
      var bh = b >>> 16 & 0xffff;
      var bl = b & 0xffff;
      // the shift by 0 fixes the sign on the high part
      // the final |0 converts the unsigned value into a signed value
      return al * bl + (ah * bl + al * bh << 16 >>> 0) | 0;
    };
  } 

  exports.log = Math.log;

  exports.remainder = function (n) {
    return function (m) {
      return n % m;
    };
  };

  exports.round = Math.round;

  exports.ln10 = Math.LN10;
})(PS["Math"] = PS["Math"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Math"] = $PS["Math"] || {};
  var exports = $PS["Math"];
  var $foreign = $PS["Math"];
  exports["abs"] = $foreign.abs;
  exports["floor"] = $foreign.floor;
  exports["log"] = $foreign.log;
  exports["round"] = $foreign.round;
  exports["remainder"] = $foreign.remainder;
  exports["ln10"] = $foreign.ln10;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Int"] = $PS["Data.Int"] || {};
  var exports = $PS["Data.Int"];
  var $foreign = $PS["Data.Int"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Bounded = $PS["Data.Bounded"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Number = $PS["Data.Number"];
  var $$Math = $PS["Math"];
  var hexadecimal = 16;
  var fromStringAs = $foreign.fromStringAsImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value);
  var fromString = fromStringAs(10);
  var fromNumber = $foreign.fromNumberImpl(Data_Maybe.Just.create)(Data_Maybe.Nothing.value);
  var unsafeClamp = function (x) {
      if (!Data_Number["isFinite"](x)) {
          return 0;
      };
      if (x >= $foreign.toNumber(Data_Bounded.top(Data_Bounded.boundedInt))) {
          return Data_Bounded.top(Data_Bounded.boundedInt);
      };
      if (x <= $foreign.toNumber(Data_Bounded.bottom(Data_Bounded.boundedInt))) {
          return Data_Bounded.bottom(Data_Bounded.boundedInt);
      };
      if (Data_Boolean.otherwise) {
          return Data_Maybe.fromMaybe(0)(fromNumber(x));
      };
      throw new Error("Failed pattern match at Data.Int (line 66, column 1 - line 66, column 29): " + [ x.constructor.name ]);
  };
  var round = function ($23) {
      return unsafeClamp($$Math.round($23));
  };
  var floor = function ($24) {
      return unsafeClamp($$Math.floor($24));
  };
  exports["fromNumber"] = fromNumber;
  exports["floor"] = floor;
  exports["round"] = round;
  exports["fromString"] = fromString;
  exports["hexadecimal"] = hexadecimal;
  exports["toNumber"] = $foreign.toNumber;
  exports["toStringAs"] = $foreign.toStringAs;
  exports["quot"] = $foreign.quot;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Foreign"] = $PS["Foreign"] || {};
  var exports = $PS["Foreign"];
  var $foreign = $PS["Foreign"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Either = $PS["Data.Either"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Int = $PS["Data.Int"];
  var Data_List_NonEmpty = $PS["Data.List.NonEmpty"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
  var ForeignError = (function () {
      function ForeignError(value0) {
          this.value0 = value0;
      };
      ForeignError.create = function (value0) {
          return new ForeignError(value0);
      };
      return ForeignError;
  })();
  var TypeMismatch = (function () {
      function TypeMismatch(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      TypeMismatch.create = function (value0) {
          return function (value1) {
              return new TypeMismatch(value0, value1);
          };
      };
      return TypeMismatch;
  })();
  var ErrorAtIndex = (function () {
      function ErrorAtIndex(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      ErrorAtIndex.create = function (value0) {
          return function (value1) {
              return new ErrorAtIndex(value0, value1);
          };
      };
      return ErrorAtIndex;
  })();
  var ErrorAtProperty = (function () {
      function ErrorAtProperty(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      ErrorAtProperty.create = function (value0) {
          return function (value1) {
              return new ErrorAtProperty(value0, value1);
          };
      };
      return ErrorAtProperty;
  })();
  var unsafeToForeign = Unsafe_Coerce.unsafeCoerce;
  var unsafeFromForeign = Unsafe_Coerce.unsafeCoerce;
  var showForeignError = new Data_Show.Show(function (v) {
      if (v instanceof ForeignError) {
          return "(ForeignError " + (Data_Show.show(Data_Show.showString)(v.value0) + ")");
      };
      if (v instanceof ErrorAtIndex) {
          return "(ErrorAtIndex " + (Data_Show.show(Data_Show.showInt)(v.value0) + (" " + (Data_Show.show(showForeignError)(v.value1) + ")")));
      };
      if (v instanceof ErrorAtProperty) {
          return "(ErrorAtProperty " + (Data_Show.show(Data_Show.showString)(v.value0) + (" " + (Data_Show.show(showForeignError)(v.value1) + ")")));
      };
      if (v instanceof TypeMismatch) {
          return "(TypeMismatch " + (Data_Show.show(Data_Show.showString)(v.value0) + (" " + (Data_Show.show(Data_Show.showString)(v.value1) + ")")));
      };
      throw new Error("Failed pattern match at Foreign (line 64, column 1 - line 68, column 89): " + [ v.constructor.name ]);
  });
  var renderForeignError = function (v) {
      if (v instanceof ForeignError) {
          return v.value0;
      };
      if (v instanceof ErrorAtIndex) {
          return "Error at array index " + (Data_Show.show(Data_Show.showInt)(v.value0) + (": " + renderForeignError(v.value1)));
      };
      if (v instanceof ErrorAtProperty) {
          return "Error at property " + (Data_Show.show(Data_Show.showString)(v.value0) + (": " + renderForeignError(v.value1)));
      };
      if (v instanceof TypeMismatch) {
          return "Type mismatch: expected " + (v.value0 + (", found " + v.value1));
      };
      throw new Error("Failed pattern match at Foreign (line 73, column 1 - line 73, column 45): " + [ v.constructor.name ]);
  };
  var readNullOrUndefined = function (dictMonad) {
      return function (value) {
          if ($foreign.isNull(value) || $foreign.isUndefined(value)) {
              return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(dictMonad))(Data_Maybe.Nothing.value);
          };
          if (Data_Boolean.otherwise) {
              return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(dictMonad))(new Data_Maybe.Just(value));
          };
          throw new Error("Failed pattern match at Foreign (line 166, column 1 - line 166, column 76): " + [ value.constructor.name ]);
      };
  };
  var fail = function (dictMonad) {
      var $118 = Control_Monad_Error_Class.throwError(Control_Monad_Except_Trans.monadThrowExceptT(dictMonad));
      return function ($119) {
          return $118(Data_List_NonEmpty.singleton($119));
      };
  };
  var readArray = function (dictMonad) {
      return function (value) {
          if ($foreign.isArray(value)) {
              return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(dictMonad))(unsafeFromForeign(value));
          };
          if (Data_Boolean.otherwise) {
              return fail(dictMonad)(new TypeMismatch("array", $foreign.tagOf(value)));
          };
          throw new Error("Failed pattern match at Foreign (line 151, column 1 - line 151, column 66): " + [ value.constructor.name ]);
      };
  };
  var unsafeReadTagged = function (dictMonad) {
      return function (tag) {
          return function (value) {
              if ($foreign.tagOf(value) === tag) {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(dictMonad))(unsafeFromForeign(value));
              };
              if (Data_Boolean.otherwise) {
                  return fail(dictMonad)(new TypeMismatch(tag, $foreign.tagOf(value)));
              };
              throw new Error("Failed pattern match at Foreign (line 110, column 1 - line 110, column 71): " + [ tag.constructor.name, value.constructor.name ]);
          };
      };
  };
  var readBoolean = function (dictMonad) {
      return unsafeReadTagged(dictMonad)("Boolean");
  };
  var readNumber = function (dictMonad) {
      return unsafeReadTagged(dictMonad)("Number");
  };
  var readInt = function (dictMonad) {
      return function (value) {
          var error = Data_Either.Left.create(Data_List_NonEmpty.singleton(new TypeMismatch("Int", $foreign.tagOf(value))));
          var fromNumber = (function () {
              var $120 = Data_Maybe.maybe(error)(Control_Applicative.pure(Data_Either.applicativeEither));
              return function ($121) {
                  return $120(Data_Int.fromNumber($121));
              };
          })();
          return Control_Monad_Except_Trans.mapExceptT(Data_Functor.map(((dictMonad.Bind1()).Apply0()).Functor0())(Data_Either.either(Data_Function["const"](error))(fromNumber)))(readNumber(dictMonad)(value));
      };
  };
  var readString = function (dictMonad) {
      return unsafeReadTagged(dictMonad)("String");
  };
  exports["ForeignError"] = ForeignError;
  exports["TypeMismatch"] = TypeMismatch;
  exports["ErrorAtIndex"] = ErrorAtIndex;
  exports["ErrorAtProperty"] = ErrorAtProperty;
  exports["renderForeignError"] = renderForeignError;
  exports["unsafeToForeign"] = unsafeToForeign;
  exports["unsafeFromForeign"] = unsafeFromForeign;
  exports["unsafeReadTagged"] = unsafeReadTagged;
  exports["readString"] = readString;
  exports["readBoolean"] = readBoolean;
  exports["readNumber"] = readNumber;
  exports["readInt"] = readInt;
  exports["readArray"] = readArray;
  exports["readNullOrUndefined"] = readNullOrUndefined;
  exports["fail"] = fail;
  exports["showForeignError"] = showForeignError;
  exports["typeOf"] = $foreign.typeOf;
  exports["tagOf"] = $foreign.tagOf;
  exports["isNull"] = $foreign.isNull;
  exports["isUndefined"] = $foreign.isUndefined;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Affjax"] = $PS["Affjax"] || {};
  var exports = $PS["Affjax"];
  var $foreign = $PS["Affjax"];
  var Affjax_RequestBody = $PS["Affjax.RequestBody"];
  var Affjax_RequestHeader = $PS["Affjax.RequestHeader"];
  var Affjax_ResponseFormat = $PS["Affjax.ResponseFormat"];
  var Affjax_ResponseHeader = $PS["Affjax.ResponseHeader"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
  var Control_Monad_Except = $PS["Control.Monad.Except"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Argonaut_Core = $PS["Data.Argonaut.Core"];
  var Data_Argonaut_Parser = $PS["Data.Argonaut.Parser"];
  var Data_Array = $PS["Data.Array"];
  var Data_Either = $PS["Data.Either"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_FormURLEncoded = $PS["Data.FormURLEncoded"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_HTTP_Method = $PS["Data.HTTP.Method"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_List_NonEmpty = $PS["Data.List.NonEmpty"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Aff_Compat = $PS["Effect.Aff.Compat"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Foreign = $PS["Foreign"];                
  var RequestContentError = (function () {
      function RequestContentError(value0) {
          this.value0 = value0;
      };
      RequestContentError.create = function (value0) {
          return new RequestContentError(value0);
      };
      return RequestContentError;
  })();
  var ResponseBodyError = (function () {
      function ResponseBodyError(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      ResponseBodyError.create = function (value0) {
          return function (value1) {
              return new ResponseBodyError(value0, value1);
          };
      };
      return ResponseBodyError;
  })();
  var TimeoutError = (function () {
      function TimeoutError() {

      };
      TimeoutError.value = new TimeoutError();
      return TimeoutError;
  })();
  var RequestFailedError = (function () {
      function RequestFailedError() {

      };
      RequestFailedError.value = new RequestFailedError();
      return RequestFailedError;
  })();
  var XHROtherError = (function () {
      function XHROtherError(value0) {
          this.value0 = value0;
      };
      XHROtherError.create = function (value0) {
          return new XHROtherError(value0);
      };
      return XHROtherError;
  })();
  var request = function (req) {
      var parseJSON = function (v) {
          if (v === "") {
              return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Data_Argonaut_Core.jsonEmptyObject);
          };
          return Data_Either.either((function () {
              var $51 = Foreign.fail(Data_Identity.monadIdentity);
              return function ($52) {
                  return $51(Foreign.ForeignError.create($52));
              };
          })())(Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity)))(Data_Argonaut_Parser.jsonParser(v));
      };
      var fromResponse = (function () {
          if (req.responseFormat instanceof Affjax_ResponseFormat["ArrayBuffer"]) {
              return Foreign.unsafeReadTagged(Data_Identity.monadIdentity)("ArrayBuffer");
          };
          if (req.responseFormat instanceof Affjax_ResponseFormat.Blob) {
              return Foreign.unsafeReadTagged(Data_Identity.monadIdentity)("Blob");
          };
          if (req.responseFormat instanceof Affjax_ResponseFormat.Document) {
              return function (x) {
                  return Control_Alt.alt(Control_Monad_Except_Trans.altExceptT(Data_List_Types.semigroupNonEmptyList)(Data_Identity.monadIdentity))(Control_Alt.alt(Control_Monad_Except_Trans.altExceptT(Data_List_Types.semigroupNonEmptyList)(Data_Identity.monadIdentity))(Foreign.unsafeReadTagged(Data_Identity.monadIdentity)("Document")(x))(Foreign.unsafeReadTagged(Data_Identity.monadIdentity)("XMLDocument")(x)))(Foreign.unsafeReadTagged(Data_Identity.monadIdentity)("HTMLDocument")(x));
              };
          };
          if (req.responseFormat instanceof Affjax_ResponseFormat.Json) {
              return Control_Bind.composeKleisliFlipped(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(function ($53) {
                  return req.responseFormat.value0(parseJSON($53));
              })(Foreign.unsafeReadTagged(Data_Identity.monadIdentity)("String"));
          };
          if (req.responseFormat instanceof Affjax_ResponseFormat["String"]) {
              return Foreign.unsafeReadTagged(Data_Identity.monadIdentity)("String");
          };
          if (req.responseFormat instanceof Affjax_ResponseFormat.Ignore) {
              return Data_Function["const"](req.responseFormat.value0(Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Data_Unit.unit)));
          };
          throw new Error("Failed pattern match at Affjax (line 257, column 18 - line 265, column 57): " + [ req.responseFormat.constructor.name ]);
      })();
      var extractContent = function (v) {
          if (v instanceof Affjax_RequestBody.ArrayView) {
              return Data_Either.Right.create(v.value0(Foreign.unsafeToForeign));
          };
          if (v instanceof Affjax_RequestBody.Blob) {
              return Data_Either.Right.create(Foreign.unsafeToForeign(v.value0));
          };
          if (v instanceof Affjax_RequestBody.Document) {
              return Data_Either.Right.create(Foreign.unsafeToForeign(v.value0));
          };
          if (v instanceof Affjax_RequestBody["String"]) {
              return Data_Either.Right.create(Foreign.unsafeToForeign(v.value0));
          };
          if (v instanceof Affjax_RequestBody.FormData) {
              return Data_Either.Right.create(Foreign.unsafeToForeign(v.value0));
          };
          if (v instanceof Affjax_RequestBody.FormURLEncoded) {
              return Data_Either.note("Body contains values that cannot be encoded as application/x-www-form-urlencoded")(Data_Functor.map(Data_Maybe.functorMaybe)(Foreign.unsafeToForeign)(Data_FormURLEncoded.encode(v.value0)));
          };
          if (v instanceof Affjax_RequestBody.Json) {
              return Data_Either.Right.create(Foreign.unsafeToForeign(Data_Argonaut_Core.stringify(v.value0)));
          };
          throw new Error("Failed pattern match at Affjax (line 217, column 20 - line 232, column 69): " + [ v.constructor.name ]);
      };
      var addHeader = function (mh) {
          return function (hs) {
              if (mh instanceof Data_Maybe.Just && !Data_Foldable.any(Data_Foldable.foldableArray)(Data_HeytingAlgebra.heytingAlgebraBoolean)(Data_Function.on(Data_Eq.eq(Data_Eq.eqString))(Affjax_RequestHeader.name)(mh.value0))(hs)) {
                  return Data_Array.snoc(hs)(mh.value0);
              };
              return hs;
          };
      };
      var headers = function (reqContent) {
          return addHeader(Data_Functor.map(Data_Maybe.functorMaybe)(Affjax_RequestHeader.ContentType.create)(Control_Bind.bindFlipped(Data_Maybe.bindMaybe)(Affjax_RequestBody.toMediaType)(reqContent)))(addHeader(Data_Functor.map(Data_Maybe.functorMaybe)(Affjax_RequestHeader.Accept.create)(Affjax_ResponseFormat.toMediaType(req.responseFormat)))(req.headers));
      };
      var ajaxRequest = function (v) {
          return {
              method: Data_HTTP_Method.print(req.method),
              url: req.url,
              headers: Data_Functor.map(Data_Functor.functorArray)(function (h) {
                  return {
                      field: Affjax_RequestHeader.name(h),
                      value: Affjax_RequestHeader.value(h)
                  };
              })(headers(req.content)),
              content: v,
              responseType: Affjax_ResponseFormat.toResponseType(req.responseFormat),
              username: Data_Nullable.toNullable(req.username),
              password: Data_Nullable.toNullable(req.password),
              withCredentials: req.withCredentials,
              timeout: Data_Maybe.fromMaybe(0.0)(Data_Functor.map(Data_Maybe.functorMaybe)(function (v1) {
                  return v1;
              })(req.timeout))
          };
      };
      var send = function (content) {
          return Data_Functor.mapFlipped(Effect_Aff.functorAff)(Control_Monad_Error_Class["try"](Effect_Aff.monadErrorAff)(Effect_Aff_Compat.fromEffectFnAff($foreign["_ajax"]("AffjaxTimeoutErrorMessageIdent", "AffjaxRequestFailedMessageIdent", Affjax_ResponseHeader.ResponseHeader.create, ajaxRequest(content)))))(function (v) {
              if (v instanceof Data_Either.Right) {
                  var v1 = Control_Monad_Except.runExcept(fromResponse(v.value0.body));
                  if (v1 instanceof Data_Either.Left) {
                      return new Data_Either.Left(new ResponseBodyError(Data_List_NonEmpty.head(v1.value0), v.value0));
                  };
                  if (v1 instanceof Data_Either.Right) {
                      return new Data_Either.Right({
                          body: v1.value0,
                          headers: v.value0.headers,
                          status: v.value0.status,
                          statusText: v.value0.statusText
                      });
                  };
                  throw new Error("Failed pattern match at Affjax (line 193, column 9 - line 195, column 52): " + [ v1.constructor.name ]);
              };
              if (v instanceof Data_Either.Left) {
                  var message = Effect_Exception.message(v.value0);
                  return Data_Either.Left.create((function () {
                      var $38 = message === "AffjaxTimeoutErrorMessageIdent";
                      if ($38) {
                          return TimeoutError.value;
                      };
                      var $39 = message === "AffjaxRequestFailedMessageIdent";
                      if ($39) {
                          return RequestFailedError.value;
                      };
                      return new XHROtherError(v.value0);
                  })());
              };
              throw new Error("Failed pattern match at Affjax (line 191, column 137 - line 201, column 33): " + [ v.constructor.name ]);
          });
      };
      if (req.content instanceof Data_Maybe.Nothing) {
          return send(Data_Nullable.toNullable(Data_Maybe.Nothing.value));
      };
      if (req.content instanceof Data_Maybe.Just) {
          var v = extractContent(req.content.value0);
          if (v instanceof Data_Either.Right) {
              return send(Data_Nullable.toNullable(new Data_Maybe.Just(v.value0)));
          };
          if (v instanceof Data_Either.Left) {
              return Control_Applicative.pure(Effect_Aff.applicativeAff)(new Data_Either.Left(new RequestContentError(v.value0)));
          };
          throw new Error("Failed pattern match at Affjax (line 183, column 7 - line 187, column 48): " + [ v.constructor.name ]);
      };
      throw new Error("Failed pattern match at Affjax (line 179, column 3 - line 187, column 48): " + [ req.content.constructor.name ]);
  };
  var printError = function (v) {
      if (v instanceof RequestContentError) {
          return "There was a problem with the request content: " + v.value0;
      };
      if (v instanceof ResponseBodyError) {
          return "There was a problem with the response body: " + Foreign.renderForeignError(v.value0);
      };
      if (v instanceof TimeoutError) {
          return "There was a problem making the request: timeout";
      };
      if (v instanceof RequestFailedError) {
          return "There was a problem making the request: request failed";
      };
      if (v instanceof XHROtherError) {
          return "There was a problem making the request: " + Effect_Exception.message(v.value0);
      };
      throw new Error("Failed pattern match at Affjax (line 97, column 14 - line 107, column 66): " + [ v.constructor.name ]);
  };
  var defaultRequest = {
      method: new Data_Either.Left(Data_HTTP_Method.GET.value),
      url: "/",
      headers: [  ],
      content: Data_Maybe.Nothing.value,
      username: Data_Maybe.Nothing.value,
      password: Data_Maybe.Nothing.value,
      withCredentials: false,
      responseFormat: Affjax_ResponseFormat.ignore,
      timeout: Data_Maybe.Nothing.value
  };
  exports["defaultRequest"] = defaultRequest;
  exports["printError"] = printError;
  exports["request"] = request;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["CSS.Common"] = $PS["CSS.Common"] || {};
  var exports = $PS["CSS.Common"];
  var Normal = function (normal) {
      this.normal = normal;
  };                                                                                        
  var normal = function (dict) {
      return dict.normal;
  };
  exports["normal"] = normal;
  exports["Normal"] = Normal;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["CSS.String"] = $PS["CSS.String"] || {};
  var exports = $PS["CSS.String"];                               
  var IsString = function (fromString) {
      this.fromString = fromString;
  };                                                                                        
  var fromString = function (dict) {
      return dict.fromString;
  };
  exports["fromString"] = fromString;
  exports["IsString"] = IsString;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["CSS.Property"] = $PS["CSS.Property"] || {};
  var exports = $PS["CSS.Property"];
  var CSS_String = $PS["CSS.String"];
  var Plain = (function () {
      function Plain(value0) {
          this.value0 = value0;
      };
      Plain.create = function (value0) {
          return new Plain(value0);
      };
      return Plain;
  })();
  var Value = function (x) {
      return x;
  };                                     
  var isStringPrefixed = new CSS_String.IsString(Plain.create);
  var isStringValue = new CSS_String.IsString((function () {
      var $102 = CSS_String.fromString(isStringPrefixed);
      return function ($103) {
          return Value($102($103));
      };
  })());
  exports["Plain"] = Plain;
  exports["isStringValue"] = isStringValue;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["CSS.Font"] = $PS["CSS.Font"] || {};
  var exports = $PS["CSS.Font"];
  var CSS_Common = $PS["CSS.Common"];
  var CSS_Property = $PS["CSS.Property"];
  var CSS_String = $PS["CSS.String"];                                                                
  var normalFontWeight = new CSS_Common.Normal(CSS_String.fromString(CSS_Property.isStringValue)("normal"));
  exports["normalFontWeight"] = normalFontWeight;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["CSS.FontStyle"] = $PS["CSS.FontStyle"] || {};
  var exports = $PS["CSS.FontStyle"];
  var CSS_Common = $PS["CSS.Common"];
  var Normal = (function () {
      function Normal() {

      };
      Normal.value = new Normal();
      return Normal;
  })();
  var Italic = (function () {
      function Italic() {

      };
      Italic.value = new Italic();
      return Italic;
  })();
  var Oblique = (function () {
      function Oblique(value0) {
          this.value0 = value0;
      };
      Oblique.create = function (value0) {
          return new Oblique(value0);
      };
      return Oblique;
  })();                                           
  var normalFontStyle = new CSS_Common.Normal(Normal.value);
  exports["Italic"] = Italic;
  exports["Oblique"] = Oblique;
  exports["normalFontStyle"] = normalFontStyle;
})(PS);
(function(exports) {
  "use strict";
  /* global Symbol */

  var hasArrayFrom = typeof Array.from === "function";
  var hasStringIterator =
    typeof Symbol !== "undefined" &&
    Symbol != null &&
    typeof Symbol.iterator !== "undefined" &&
    typeof String.prototype[Symbol.iterator] === "function";
  var hasFromCodePoint = typeof String.prototype.fromCodePoint === "function";
  var hasCodePointAt = typeof String.prototype.codePointAt === "function";

  exports._unsafeCodePointAt0 = function (fallback) {
    return hasCodePointAt
      ? function (str) { return str.codePointAt(0); }
      : fallback;
  };

  exports._singleton = function (fallback) {
    return hasFromCodePoint ? String.fromCodePoint : fallback;
  };

  exports._take = function (fallback) {
    return function (n) {
      if (hasStringIterator) {
        return function (str) {
          var accum = "";
          var iter = str[Symbol.iterator]();
          for (var i = 0; i < n; ++i) {
            var o = iter.next();
            if (o.done) return accum;
            accum += o.value;
          }
          return accum;
        };
      }
      return fallback(n);
    };
  };

  exports._toCodePointArray = function (fallback) {
    return function (unsafeCodePointAt0) {
      if (hasArrayFrom) {
        return function (str) {
          return Array.from(str, unsafeCodePointAt0);
        };
      }
      return fallback;
    };
  };
})(PS["Data.String.CodePoints"] = PS["Data.String.CodePoints"] || {});
(function(exports) {
  "use strict";

  exports.toCharCode = function (c) {
    return c.charCodeAt(0);
  };

  exports.fromCharCode = function (c) {
    return String.fromCharCode(c);
  };
})(PS["Data.Enum"] = PS["Data.Enum"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Enum"] = $PS["Data.Enum"] || {};
  var exports = $PS["Data.Enum"];
  var $foreign = $PS["Data.Enum"];
  var Data_Bounded = $PS["Data.Bounded"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];                  
  var Enum = function (Ord0, pred, succ) {
      this.Ord0 = Ord0;
      this.pred = pred;
      this.succ = succ;
  };
  var BoundedEnum = function (Bounded0, Enum1, cardinality, fromEnum, toEnum) {
      this.Bounded0 = Bounded0;
      this.Enum1 = Enum1;
      this.cardinality = cardinality;
      this.fromEnum = fromEnum;
      this.toEnum = toEnum;
  };
  var toEnum = function (dict) {
      return dict.toEnum;
  }; 
  var fromEnum = function (dict) {
      return dict.fromEnum;
  };
  var toEnumWithDefaults = function (dictBoundedEnum) {
      return function (low) {
          return function (high) {
              return function (x) {
                  var v = toEnum(dictBoundedEnum)(x);
                  if (v instanceof Data_Maybe.Just) {
                      return v.value0;
                  };
                  if (v instanceof Data_Maybe.Nothing) {
                      var $51 = x < fromEnum(dictBoundedEnum)(Data_Bounded.bottom(dictBoundedEnum.Bounded0()));
                      if ($51) {
                          return low;
                      };
                      return high;
                  };
                  throw new Error("Failed pattern match at Data.Enum (line 158, column 33 - line 160, column 62): " + [ v.constructor.name ]);
              };
          };
      };
  };
  var defaultSucc = function (toEnum$prime) {
      return function (fromEnum$prime) {
          return function (a) {
              return toEnum$prime(fromEnum$prime(a) + 1 | 0);
          };
      };
  };
  var defaultPred = function (toEnum$prime) {
      return function (fromEnum$prime) {
          return function (a) {
              return toEnum$prime(fromEnum$prime(a) - 1 | 0);
          };
      };
  };
  var charToEnum = function (v) {
      if (v >= Data_Bounded.bottom(Data_Bounded.boundedInt) && v <= Data_Bounded.top(Data_Bounded.boundedInt)) {
          return new Data_Maybe.Just($foreign.fromCharCode(v));
      };
      return Data_Maybe.Nothing.value;
  };
  var enumChar = new Enum(function () {
      return Data_Ord.ordChar;
  }, defaultPred(charToEnum)($foreign.toCharCode), defaultSucc(charToEnum)($foreign.toCharCode));
  var boundedEnumChar = new BoundedEnum(function () {
      return Data_Bounded.boundedChar;
  }, function () {
      return enumChar;
  }, $foreign.toCharCode(Data_Bounded.top(Data_Bounded.boundedChar)) - $foreign.toCharCode(Data_Bounded.bottom(Data_Bounded.boundedChar)) | 0, $foreign.toCharCode, charToEnum);
  exports["Enum"] = Enum;
  exports["BoundedEnum"] = BoundedEnum;
  exports["toEnum"] = toEnum;
  exports["fromEnum"] = fromEnum;
  exports["toEnumWithDefaults"] = toEnumWithDefaults;
  exports["defaultSucc"] = defaultSucc;
  exports["defaultPred"] = defaultPred;
  exports["boundedEnumChar"] = boundedEnumChar;
})(PS);
(function(exports) {
  "use strict";

  exports.intDegree = function (x) {
    return Math.min(Math.abs(x), 2147483647);
  };

  // See the Euclidean definition in
  // https://en.m.wikipedia.org/wiki/Modulo_operation.
  exports.intDiv = function (x) {
    return function (y) {
      if (y === 0) return 0;
      return y > 0 ? Math.floor(x / y) : -Math.floor(x / -y);
    };
  };

  exports.intMod = function (x) {
    return function (y) {
      if (y === 0) return 0;
      var yy = Math.abs(y);
      return ((x % yy) + yy) % yy;
    };
  };
})(PS["Data.EuclideanRing"] = PS["Data.EuclideanRing"] || {});
(function(exports) {
  "use strict";

  exports.intSub = function (x) {
    return function (y) {
      /* jshint bitwise: false */
      return x - y | 0;
    };
  };

  exports.numSub = function (n1) {
    return function (n2) {
      return n1 - n2;
    };
  };
})(PS["Data.Ring"] = PS["Data.Ring"] || {});
(function(exports) {
  "use strict";

  exports.intAdd = function (x) {
    return function (y) {
      /* jshint bitwise: false */
      return x + y | 0;
    };
  };

  exports.intMul = function (x) {
    return function (y) {
      /* jshint bitwise: false */
      return x * y | 0;
    };
  };

  exports.numAdd = function (n1) {
    return function (n2) {
      return n1 + n2;
    };
  };

  exports.numMul = function (n1) {
    return function (n2) {
      return n1 * n2;
    };
  };
})(PS["Data.Semiring"] = PS["Data.Semiring"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Semiring"] = $PS["Data.Semiring"] || {};
  var exports = $PS["Data.Semiring"];
  var $foreign = $PS["Data.Semiring"];
  var Semiring = function (add, mul, one, zero) {
      this.add = add;
      this.mul = mul;
      this.one = one;
      this.zero = zero;
  };
  var zero = function (dict) {
      return dict.zero;
  };                                                       
  var semiringNumber = new Semiring($foreign.numAdd, $foreign.numMul, 1.0, 0.0);
  var semiringInt = new Semiring($foreign.intAdd, $foreign.intMul, 1, 0);
  var one = function (dict) {
      return dict.one;
  };
  var mul = function (dict) {
      return dict.mul;
  };
  var add = function (dict) {
      return dict.add;
  };
  var semiringFn = function (dictSemiring) {
      return new Semiring(function (f) {
          return function (g) {
              return function (x) {
                  return add(dictSemiring)(f(x))(g(x));
              };
          };
      }, function (f) {
          return function (g) {
              return function (x) {
                  return mul(dictSemiring)(f(x))(g(x));
              };
          };
      }, function (v) {
          return one(dictSemiring);
      }, function (v) {
          return zero(dictSemiring);
      });
  };
  exports["Semiring"] = Semiring;
  exports["add"] = add;
  exports["zero"] = zero;
  exports["mul"] = mul;
  exports["one"] = one;
  exports["semiringInt"] = semiringInt;
  exports["semiringNumber"] = semiringNumber;
  exports["semiringFn"] = semiringFn;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Ring"] = $PS["Data.Ring"] || {};
  var exports = $PS["Data.Ring"];
  var $foreign = $PS["Data.Ring"];
  var Data_Semiring = $PS["Data.Semiring"];
  var Ring = function (Semiring0, sub) {
      this.Semiring0 = Semiring0;
      this.sub = sub;
  };
  var sub = function (dict) {
      return dict.sub;
  }; 
  var ringNumber = new Ring(function () {
      return Data_Semiring.semiringNumber;
  }, $foreign.numSub);
  var ringInt = new Ring(function () {
      return Data_Semiring.semiringInt;
  }, $foreign.intSub);
  var ringFn = function (dictRing) {
      return new Ring(function () {
          return Data_Semiring.semiringFn(dictRing.Semiring0());
      }, function (f) {
          return function (g) {
              return function (x) {
                  return sub(dictRing)(f(x))(g(x));
              };
          };
      });
  };
  var negate = function (dictRing) {
      return function (a) {
          return sub(dictRing)(Data_Semiring.zero(dictRing.Semiring0()))(a);
      };
  };
  exports["Ring"] = Ring;
  exports["sub"] = sub;
  exports["negate"] = negate;
  exports["ringInt"] = ringInt;
  exports["ringNumber"] = ringNumber;
  exports["ringFn"] = ringFn;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.CommutativeRing"] = $PS["Data.CommutativeRing"] || {};
  var exports = $PS["Data.CommutativeRing"];
  var Data_Ring = $PS["Data.Ring"];
  var CommutativeRing = function (Ring0) {
      this.Ring0 = Ring0;
  }; 
  var commutativeRingInt = new CommutativeRing(function () {
      return Data_Ring.ringInt;
  });
  exports["commutativeRingInt"] = commutativeRingInt;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.EuclideanRing"] = $PS["Data.EuclideanRing"] || {};
  var exports = $PS["Data.EuclideanRing"];
  var $foreign = $PS["Data.EuclideanRing"];
  var Data_CommutativeRing = $PS["Data.CommutativeRing"];  
  var EuclideanRing = function (CommutativeRing0, degree, div, mod) {
      this.CommutativeRing0 = CommutativeRing0;
      this.degree = degree;
      this.div = div;
      this.mod = mod;
  };
  var mod = function (dict) {
      return dict.mod;
  }; 
  var euclideanRingInt = new EuclideanRing(function () {
      return Data_CommutativeRing.commutativeRingInt;
  }, $foreign.intDegree, $foreign.intDiv, $foreign.intMod);
  var div = function (dict) {
      return dict.div;
  };
  exports["div"] = div;
  exports["mod"] = mod;
  exports["euclideanRingInt"] = euclideanRingInt;
})(PS);
(function(exports) {
  "use strict";

  exports.fromCharArray = function (a) {
    return a.join("");
  };

  exports.toCharArray = function (s) {
    return s.split("");
  };

  exports.singleton = function (c) {
    return c;
  };

  exports._charAt = function (just) {
    return function (nothing) {
      return function (i) {
        return function (s) {
          return i >= 0 && i < s.length ? just(s.charAt(i)) : nothing;
        };
      };
    };
  };

  exports.length = function (s) {
    return s.length;
  };

  exports.countPrefix = function (p) {
    return function (s) {
      var i = 0;
      while (i < s.length && p(s.charAt(i))) i++;
      return i;
    };
  };

  exports._indexOf = function (just) {
    return function (nothing) {
      return function (x) {
        return function (s) {
          var i = s.indexOf(x);
          return i === -1 ? nothing : just(i);
        };
      };
    };
  };

  exports.take = function (n) {
    return function (s) {
      return s.substr(0, n);
    };
  };

  exports.drop = function (n) {
    return function (s) {
      return s.substring(n);
    };
  };

  exports._slice = function (b) {
    return function (e) {
      return function (s) {
        return s.slice(b,e);
      };
    };
  };

  exports.splitAt = function (i) {
    return function (s) {
      return { before: s.substring(0, i), after: s.substring(i) };
    };
  };
})(PS["Data.String.CodeUnits"] = PS["Data.String.CodeUnits"] || {});
(function(exports) {
  "use strict";

  exports.charAt = function (i) {
    return function (s) {
      if (i >= 0 && i < s.length) return s.charAt(i);
      throw new Error("Data.String.Unsafe.charAt: Invalid index.");
    };
  };
})(PS["Data.String.Unsafe"] = PS["Data.String.Unsafe"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.String.Unsafe"] = $PS["Data.String.Unsafe"] || {};
  var exports = $PS["Data.String.Unsafe"];
  var $foreign = $PS["Data.String.Unsafe"];
  exports["charAt"] = $foreign.charAt;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.String.CodeUnits"] = $PS["Data.String.CodeUnits"] || {};
  var exports = $PS["Data.String.CodeUnits"];
  var $foreign = $PS["Data.String.CodeUnits"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_Unsafe = $PS["Data.String.Unsafe"];                
  var uncons = function (v) {
      if (v === "") {
          return Data_Maybe.Nothing.value;
      };
      return new Data_Maybe.Just({
          head: Data_String_Unsafe.charAt(0)(v),
          tail: $foreign.drop(1)(v)
      });
  };
  var stripPrefix = function (v) {
      return function (str) {
          var v1 = $foreign.splitAt($foreign.length(v))(str);
          var $15 = v1.before === v;
          if ($15) {
              return new Data_Maybe.Just(v1.after);
          };
          return Data_Maybe.Nothing.value;
      };
  };
  var slice = function (b) {
      return function (e) {
          return function (s) {
              var l = $foreign.length(s);
              var norm = function (x) {
                  if (x < 0) {
                      return l + x | 0;
                  };
                  if (Data_Boolean.otherwise) {
                      return x;
                  };
                  throw new Error("Failed pattern match at Data.String.CodeUnits (line 319, column 5 - line 320, column 27): " + [ x.constructor.name ]);
              };
              var e$prime = norm(e);
              var b$prime = norm(b);
              var $19 = b$prime < 0 || (b$prime >= l || (e$prime < 0 || (e$prime > l || b$prime > e$prime)));
              if ($19) {
                  return Data_Maybe.Nothing.value;
              };
              return new Data_Maybe.Just($foreign["_slice"](b)(e)(s));
          };
      };
  };                                                                                                   
  var indexOf = $foreign["_indexOf"](Data_Maybe.Just.create)(Data_Maybe.Nothing.value);
  var dropWhile = function (p) {
      return function (s) {
          return $foreign.drop($foreign.countPrefix(p)(s))(s);
      };
  };
  var contains = function (pat) {
      var $20 = indexOf(pat);
      return function ($21) {
          return Data_Maybe.isJust($20($21));
      };
  };
  var charAt = $foreign["_charAt"](Data_Maybe.Just.create)(Data_Maybe.Nothing.value);
  exports["stripPrefix"] = stripPrefix;
  exports["contains"] = contains;
  exports["uncons"] = uncons;
  exports["indexOf"] = indexOf;
  exports["dropWhile"] = dropWhile;
  exports["slice"] = slice;
  exports["singleton"] = $foreign.singleton;
  exports["fromCharArray"] = $foreign.fromCharArray;
  exports["toCharArray"] = $foreign.toCharArray;
  exports["length"] = $foreign.length;
  exports["countPrefix"] = $foreign.countPrefix;
  exports["take"] = $foreign.take;
  exports["drop"] = $foreign.drop;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.String.CodePoints"] = $PS["Data.String.CodePoints"] || {};
  var exports = $PS["Data.String.CodePoints"];
  var $foreign = $PS["Data.String.CodePoints"];
  var Data_Array = $PS["Data.Array"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Bounded = $PS["Data.Bounded"];
  var Data_Enum = $PS["Data.Enum"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_EuclideanRing = $PS["Data.EuclideanRing"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_String_Unsafe = $PS["Data.String.Unsafe"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];                
  var CodePoint = function (x) {
      return x;
  };
  var unsurrogate = function (lead) {
      return function (trail) {
          return (((lead - 55296 | 0) * 1024 | 0) + (trail - 56320 | 0) | 0) + 65536 | 0;
      };
  }; 
  var isTrail = function (cu) {
      return 56320 <= cu && cu <= 57343;
  };
  var isLead = function (cu) {
      return 55296 <= cu && cu <= 56319;
  };
  var uncons = function (s) {
      var v = Data_String_CodeUnits.length(s);
      if (v === 0) {
          return Data_Maybe.Nothing.value;
      };
      if (v === 1) {
          return new Data_Maybe.Just({
              head: Data_Enum.fromEnum(Data_Enum.boundedEnumChar)(Data_String_Unsafe.charAt(0)(s)),
              tail: ""
          });
      };
      var cu1 = Data_Enum.fromEnum(Data_Enum.boundedEnumChar)(Data_String_Unsafe.charAt(1)(s));
      var cu0 = Data_Enum.fromEnum(Data_Enum.boundedEnumChar)(Data_String_Unsafe.charAt(0)(s));
      var $21 = isLead(cu0) && isTrail(cu1);
      if ($21) {
          return new Data_Maybe.Just({
              head: unsurrogate(cu0)(cu1),
              tail: Data_String_CodeUnits.drop(2)(s)
          });
      };
      return new Data_Maybe.Just({
          head: cu0,
          tail: Data_String_CodeUnits.drop(1)(s)
      });
  };
  var unconsButWithTuple = function (s) {
      return Data_Functor.map(Data_Maybe.functorMaybe)(function (v) {
          return new Data_Tuple.Tuple(v.head, v.tail);
      })(uncons(s));
  };
  var toCodePointArrayFallback = function (s) {
      return Data_Unfoldable.unfoldr(Data_Unfoldable.unfoldableArray)(unconsButWithTuple)(s);
  };
  var unsafeCodePointAt0Fallback = function (s) {
      var cu0 = Data_Enum.fromEnum(Data_Enum.boundedEnumChar)(Data_String_Unsafe.charAt(0)(s));
      var $25 = isLead(cu0) && Data_String_CodeUnits.length(s) > 1;
      if ($25) {
          var cu1 = Data_Enum.fromEnum(Data_Enum.boundedEnumChar)(Data_String_Unsafe.charAt(1)(s));
          var $26 = isTrail(cu1);
          if ($26) {
              return unsurrogate(cu0)(cu1);
          };
          return cu0;
      };
      return cu0;
  };
  var unsafeCodePointAt0 = $foreign["_unsafeCodePointAt0"](unsafeCodePointAt0Fallback);
  var toCodePointArray = $foreign["_toCodePointArray"](toCodePointArrayFallback)(unsafeCodePointAt0);
  var length = function ($52) {
      return Data_Array.length(toCodePointArray($52));
  };
  var indexOf = function (p) {
      return function (s) {
          return Data_Functor.map(Data_Maybe.functorMaybe)(function (i) {
              return length(Data_String_CodeUnits.take(i)(s));
          })(Data_String_CodeUnits.indexOf(p)(s));
      };
  };
  var fromCharCode = (function () {
      var $53 = Data_Enum.toEnumWithDefaults(Data_Enum.boundedEnumChar)(Data_Bounded.bottom(Data_Bounded.boundedChar))(Data_Bounded.top(Data_Bounded.boundedChar));
      return function ($54) {
          return Data_String_CodeUnits.singleton($53($54));
      };
  })();
  var singletonFallback = function (v) {
      if (v <= 65535) {
          return fromCharCode(v);
      };
      var lead = Data_EuclideanRing.div(Data_EuclideanRing.euclideanRingInt)(v - 65536 | 0)(1024) + 55296 | 0;
      var trail = Data_EuclideanRing.mod(Data_EuclideanRing.euclideanRingInt)(v - 65536 | 0)(1024) + 56320 | 0;
      return fromCharCode(lead) + fromCharCode(trail);
  };                                                                          
  var singleton = $foreign["_singleton"](singletonFallback);
  var takeFallback = function (n) {
      return function (v) {
          if (n < 1) {
              return "";
          };
          var v1 = uncons(v);
          if (v1 instanceof Data_Maybe.Just) {
              return singleton(v1.value0.head) + takeFallback(n - 1 | 0)(v1.value0.tail);
          };
          return v;
      };
  };
  var take = $foreign["_take"](takeFallback);
  var splitAt = function (i) {
      return function (s) {
          var before = take(i)(s);
          return {
              before: before,
              after: Data_String_CodeUnits.drop(Data_String_CodeUnits.length(before))(s)
          };
      };
  };
  var eqCodePoint = new Data_Eq.Eq(function (x) {
      return function (y) {
          return x === y;
      };
  });
  var ordCodePoint = new Data_Ord.Ord(function () {
      return eqCodePoint;
  }, function (x) {
      return function (y) {
          return Data_Ord.compare(Data_Ord.ordInt)(x)(y);
      };
  });
  var drop = function (n) {
      return function (s) {
          return Data_String_CodeUnits.drop(Data_String_CodeUnits.length(take(n)(s)))(s);
      };
  };
  var codePointFromChar = (function () {
      var $55 = Data_Enum.fromEnum(Data_Enum.boundedEnumChar);
      return function ($56) {
          return CodePoint($55($56));
      };
  })();
  var boundedCodePoint = new Data_Bounded.Bounded(function () {
      return ordCodePoint;
  }, 0, 1114111);
  var boundedEnumCodePoint = new Data_Enum.BoundedEnum(function () {
      return boundedCodePoint;
  }, function () {
      return enumCodePoint;
  }, 1114111 + 1 | 0, function (v) {
      return v;
  }, function (n) {
      if (n >= 0 && n <= 1114111) {
          return new Data_Maybe.Just(n);
      };
      if (Data_Boolean.otherwise) {
          return Data_Maybe.Nothing.value;
      };
      throw new Error("Failed pattern match at Data.String.CodePoints (line 63, column 1 - line 68, column 26): " + [ n.constructor.name ]);
  });
  var enumCodePoint = new Data_Enum.Enum(function () {
      return ordCodePoint;
  }, Data_Enum.defaultPred(Data_Enum.toEnum(boundedEnumCodePoint))(Data_Enum.fromEnum(boundedEnumCodePoint)), Data_Enum.defaultSucc(Data_Enum.toEnum(boundedEnumCodePoint))(Data_Enum.fromEnum(boundedEnumCodePoint)));
  exports["codePointFromChar"] = codePointFromChar;
  exports["toCodePointArray"] = toCodePointArray;
  exports["length"] = length;
  exports["indexOf"] = indexOf;
  exports["take"] = take;
  exports["drop"] = drop;
  exports["splitAt"] = splitAt;
  exports["boundedEnumCodePoint"] = boundedEnumCodePoint;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Color"] = $PS["Color"] || {};
  var exports = $PS["Color"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Int = $PS["Data.Int"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var $$Math = $PS["Math"];
  var HSLA = (function () {
      function HSLA(value0, value1, value2, value3) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
      };
      HSLA.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return new HSLA(value0, value1, value2, value3);
                  };
              };
          };
      };
      return HSLA;
  })();
  var modPos = function (x) {
      return function (y) {
          return $$Math.remainder($$Math.remainder(x)(y) + y)(y);
      };
  };
  var rgba = function (red$prime) {
      return function (green$prime) {
          return function (blue$prime) {
              return function (alpha) {
                  var red = Data_Ord.clamp(Data_Ord.ordInt)(0)(255)(red$prime);
                  var r = Data_Int.toNumber(red) / 255.0;
                  var green = Data_Ord.clamp(Data_Ord.ordInt)(0)(255)(green$prime);
                  var g = Data_Int.toNumber(green) / 255.0;
                  var blue = Data_Ord.clamp(Data_Ord.ordInt)(0)(255)(blue$prime);
                  var maxChroma = Data_Ord.max(Data_Ord.ordInt)(Data_Ord.max(Data_Ord.ordInt)(red)(green))(blue);
                  var minChroma = Data_Ord.min(Data_Ord.ordInt)(Data_Ord.min(Data_Ord.ordInt)(red)(green))(blue);
                  var chroma = maxChroma - minChroma | 0;
                  var chroma$prime = Data_Int.toNumber(chroma) / 255.0;
                  var lightness = Data_Int.toNumber(maxChroma + minChroma | 0) / (255.0 * 2.0);
                  var saturation = (function () {
                      if (chroma === 0) {
                          return 0.0;
                      };
                      if (Data_Boolean.otherwise) {
                          return chroma$prime / (1.0 - $$Math.abs(2.0 * lightness - 1.0));
                      };
                      throw new Error("Failed pattern match at Color (line 157, column 5 - line 158, column 75): " + [  ]);
                  })();
                  var b = Data_Int.toNumber(blue) / 255.0;
                  var hue$prime = function (v) {
                      if (v === 0) {
                          return 0.0;
                      };
                      if (maxChroma === red) {
                          return modPos((g - b) / chroma$prime)(6.0);
                      };
                      if (maxChroma === green) {
                          return (b - r) / chroma$prime + 2.0;
                      };
                      if (Data_Boolean.otherwise) {
                          return (r - g) / chroma$prime + 4.0;
                      };
                      throw new Error("Failed pattern match at Color (line 148, column 5 - line 148, column 17): " + [ v.constructor.name ]);
                  };
                  var hue = 60.0 * hue$prime(chroma);
                  return new HSLA(hue, saturation, lightness, alpha);
              };
          };
      };
  };
  var rgb = function (r) {
      return function (g) {
          return function (b) {
              return rgba(r)(g)(b)(1.0);
          };
      };
  };                                   
  var clipHue = function (v) {
      var $65 = 360.0 === v;
      if ($65) {
          return v;
      };
      return modPos(v)(360.0);
  };
  var toRGBA$prime = function (v) {
      var h$prime = clipHue(v.value0) / 60.0;
      var chr = (1.0 - $$Math.abs(2.0 * v.value2 - 1.0)) * v.value1;
      var m = v.value2 - chr / 2.0;
      var x = chr * (1.0 - $$Math.abs($$Math.remainder(h$prime)(2.0) - 1.0));
      var col = (function () {
          if (h$prime < 1.0) {
              return {
                  r: chr,
                  g: x,
                  b: 0.0
              };
          };
          if (1.0 <= h$prime && h$prime < 2.0) {
              return {
                  r: x,
                  g: chr,
                  b: 0.0
              };
          };
          if (2.0 <= h$prime && h$prime < 3.0) {
              return {
                  r: 0.0,
                  g: chr,
                  b: x
              };
          };
          if (3.0 <= h$prime && h$prime < 4.0) {
              return {
                  r: 0.0,
                  g: x,
                  b: chr
              };
          };
          if (4.0 <= h$prime && h$prime < 5.0) {
              return {
                  r: x,
                  g: 0.0,
                  b: chr
              };
          };
          if (Data_Boolean.otherwise) {
              return {
                  r: chr,
                  g: 0.0,
                  b: x
              };
          };
          throw new Error("Failed pattern match at Color (line 342, column 5 - line 347, column 61): " + [  ]);
      })();
      return {
          r: col.r + m,
          g: col.g + m,
          b: col.b + m,
          a: v.value3
      };
  };
  var toRGBA = function (col) {
      var c = toRGBA$prime(col);
      var g = Data_Int.round(255.0 * c.g);
      var r = Data_Int.round(255.0 * c.r);
      var b = Data_Int.round(255.0 * c.b);
      return {
          r: r,
          g: g,
          b: b,
          a: c.a
      };
  }; 
  var toHexString = function (color) {
      var toHex = function (num) {
          var repr = Data_Int.toStringAs(Data_Int.hexadecimal)(num);
          var $93 = Data_String_CodePoints.length(repr) === 1;
          if ($93) {
              return "0" + repr;
          };
          return repr;
      };
      var c = toRGBA(color);
      return "#" + (toHex(c.r) + (toHex(c.g) + toHex(c.b)));
  };
  exports["rgba"] = rgba;
  exports["rgb"] = rgb;
  exports["toHexString"] = toHexString;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Color.Scheme.X11"] = $PS["Color.Scheme.X11"] || {};
  var exports = $PS["Color.Scheme.X11"];
  var Color = $PS["Color"];            
  var violet = Color.rgb(238)(130)(238);
  exports["violet"] = violet;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Extend"] = $PS["Control.Extend"] || {};
  var exports = $PS["Control.Extend"];                       
  var Extend = function (Functor0, extend) {
      this.Functor0 = Functor0;
      this.extend = extend;
  };                       
  var extend = function (dict) {
      return dict.extend;
  };
  exports["Extend"] = Extend;
  exports["extend"] = extend;
})(PS);
(function(exports) {
  "use strict";

  exports.defer = function (thunk) {
    var v = null;
    return function() {
      if (thunk === undefined) return v;

      v = thunk();
      thunk = undefined; // eslint-disable-line no-param-reassign
      return v;
    };
  };

  exports.force = function (l) {
    return l();
  };
})(PS["Data.Lazy"] = PS["Data.Lazy"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lazy"] = $PS["Data.Lazy"] || {};
  var exports = $PS["Data.Lazy"];
  var $foreign = $PS["Data.Lazy"];
  var Data_Functor = $PS["Data.Functor"];
  var functorLazy = new Data_Functor.Functor(function (f) {
      return function (l) {
          return $foreign.defer(function (v) {
              return f($foreign.force(l));
          });
      };
  });
  exports["functorLazy"] = functorLazy;
  exports["defer"] = $foreign.defer;
  exports["force"] = $foreign.force;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Comonad.Cofree"] = $PS["Control.Comonad.Cofree"] || {};
  var exports = $PS["Control.Comonad.Cofree"];
  var Control_Extend = $PS["Control.Extend"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Lazy = $PS["Data.Lazy"];
  var Data_Tuple = $PS["Data.Tuple"];
  var tail = function (v) {
      return Data_Tuple.snd(Data_Lazy.force(v));
  };
  var mkCofree = function (a) {
      return function (t) {
          return Data_Lazy.defer(function (v) {
              return new Data_Tuple.Tuple(a, t);
          });
      };
  };
  var head = function (v) {
      return Data_Tuple.fst(Data_Lazy.force(v));
  };
  var functorCofree = function (dictFunctor) {
      return new Data_Functor.Functor(function (f) {
          var loop = function (v) {
              return Data_Functor.map(Data_Lazy.functorLazy)(function (v1) {
                  return new Data_Tuple.Tuple(f(v1.value0), Data_Functor.map(dictFunctor)(loop)(v1.value1));
              })(v);
          };
          return loop;
      });
  };
  var extendCofree = function (dictFunctor) {
      return new Control_Extend.Extend(function () {
          return functorCofree(dictFunctor);
      }, function (f) {
          var loop = function (v) {
              return Data_Functor.map(Data_Lazy.functorLazy)(function (v1) {
                  return new Data_Tuple.Tuple(f(v), Data_Functor.map(dictFunctor)(loop)(v1.value1));
              })(v);
          };
          return loop;
      });
  };
  exports["mkCofree"] = mkCofree;
  exports["head"] = head;
  exports["tail"] = tail;
  exports["extendCofree"] = extendCofree;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.Rec.Class"] = $PS["Control.Monad.Rec.Class"] || {};
  var exports = $PS["Control.Monad.Rec.Class"];
  var Data_Identity = $PS["Data.Identity"];          
  var Loop = (function () {
      function Loop(value0) {
          this.value0 = value0;
      };
      Loop.create = function (value0) {
          return new Loop(value0);
      };
      return Loop;
  })();
  var Done = (function () {
      function Done(value0) {
          this.value0 = value0;
      };
      Done.create = function (value0) {
          return new Done(value0);
      };
      return Done;
  })();
  var MonadRec = function (Monad0, tailRecM) {
      this.Monad0 = Monad0;
      this.tailRecM = tailRecM;
  };
  var tailRecM = function (dict) {
      return dict.tailRecM;
  };
  var tailRec = function (f) {
      var go = function ($copy_v) {
          var $tco_done = false;
          var $tco_result;
          function $tco_loop(v) {
              if (v instanceof Loop) {
                  $copy_v = f(v.value0);
                  return;
              };
              if (v instanceof Done) {
                  $tco_done = true;
                  return v.value0;
              };
              throw new Error("Failed pattern match at Control.Monad.Rec.Class (line 93, column 3 - line 93, column 25): " + [ v.constructor.name ]);
          };
          while (!$tco_done) {
              $tco_result = $tco_loop($copy_v);
          };
          return $tco_result;
      };
      return function ($58) {
          return go(f($58));
      };
  }; 
  var monadRecIdentity = new MonadRec(function () {
      return Data_Identity.monadIdentity;
  }, function (f) {
      var runIdentity = function (v) {
          return v;
      };
      var $59 = tailRec(function ($61) {
          return runIdentity(f($61));
      });
      return function ($60) {
          return Data_Identity.Identity($59($60));
      };
  });
  exports["Loop"] = Loop;
  exports["Done"] = Done;
  exports["MonadRec"] = MonadRec;
  exports["tailRecM"] = tailRecM;
  exports["monadRecIdentity"] = monadRecIdentity;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.List"] = $PS["Data.List"] || {};
  var exports = $PS["Data.List"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Lazy = $PS["Control.Lazy"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_FunctorWithIndex = $PS["Data.FunctorWithIndex"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];                                  
  var uncons = function (v) {
      if (v instanceof Data_List_Types.Nil) {
          return Data_Maybe.Nothing.value;
      };
      if (v instanceof Data_List_Types.Cons) {
          return new Data_Maybe.Just({
              head: v.value0,
              tail: v.value1
          });
      };
      throw new Error("Failed pattern match at Data.List (line 263, column 1 - line 263, column 66): " + [ v.constructor.name ]);
  };
  var toUnfoldable = function (dictUnfoldable) {
      return Data_Unfoldable.unfoldr(dictUnfoldable)(function (xs) {
          return Data_Functor.map(Data_Maybe.functorMaybe)(function (rec) {
              return new Data_Tuple.Tuple(rec.head, rec.tail);
          })(uncons(xs));
      });
  };
  var tail = function (v) {
      if (v instanceof Data_List_Types.Nil) {
          return Data_Maybe.Nothing.value;
      };
      if (v instanceof Data_List_Types.Cons) {
          return new Data_Maybe.Just(v.value1);
      };
      throw new Error("Failed pattern match at Data.List (line 249, column 1 - line 249, column 43): " + [ v.constructor.name ]);
  };
  var span = function (v) {
      return function (v1) {
          if (v1 instanceof Data_List_Types.Cons && v(v1.value0)) {
              var v2 = span(v)(v1.value1);
              return {
                  init: new Data_List_Types.Cons(v1.value0, v2.init),
                  rest: v2.rest
              };
          };
          return {
              init: Data_List_Types.Nil.value,
              rest: v1
          };
      };
  };
  var snoc = function (xs) {
      return function (x) {
          return Data_Foldable.foldr(Data_List_Types.foldableList)(Data_List_Types.Cons.create)(new Data_List_Types.Cons(x, Data_List_Types.Nil.value))(xs);
      };
  };
  var singleton = function (a) {
      return new Data_List_Types.Cons(a, Data_List_Types.Nil.value);
  };
  var reverse = (function () {
      var go = function ($copy_acc) {
          return function ($copy_v) {
              var $tco_var_acc = $copy_acc;
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(acc, v) {
                  if (v instanceof Data_List_Types.Nil) {
                      $tco_done = true;
                      return acc;
                  };
                  if (v instanceof Data_List_Types.Cons) {
                      $tco_var_acc = new Data_List_Types.Cons(v.value0, acc);
                      $copy_v = v.value1;
                      return;
                  };
                  throw new Error("Failed pattern match at Data.List (line 372, column 3 - line 372, column 19): " + [ acc.constructor.name, v.constructor.name ]);
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($tco_var_acc, $copy_v);
              };
              return $tco_result;
          };
      };
      return go(Data_List_Types.Nil.value);
  })();
  var take = (function () {
      var go = function ($copy_acc) {
          return function ($copy_v) {
              return function ($copy_v1) {
                  var $tco_var_acc = $copy_acc;
                  var $tco_var_v = $copy_v;
                  var $tco_done = false;
                  var $tco_result;
                  function $tco_loop(acc, v, v1) {
                      if (v < 1) {
                          $tco_done = true;
                          return reverse(acc);
                      };
                      if (v1 instanceof Data_List_Types.Nil) {
                          $tco_done = true;
                          return reverse(acc);
                      };
                      if (v1 instanceof Data_List_Types.Cons) {
                          $tco_var_acc = new Data_List_Types.Cons(v1.value0, acc);
                          $tco_var_v = v - 1 | 0;
                          $copy_v1 = v1.value1;
                          return;
                      };
                      throw new Error("Failed pattern match at Data.List (line 524, column 3 - line 524, column 35): " + [ acc.constructor.name, v.constructor.name, v1.constructor.name ]);
                  };
                  while (!$tco_done) {
                      $tco_result = $tco_loop($tco_var_acc, $tco_var_v, $copy_v1);
                  };
                  return $tco_result;
              };
          };
      };
      return go(Data_List_Types.Nil.value);
  })();
  var unsnoc = function (lst) {
      var go = function ($copy_v) {
          return function ($copy_v1) {
              var $tco_var_v = $copy_v;
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(v, v1) {
                  if (v instanceof Data_List_Types.Nil) {
                      $tco_done = true;
                      return Data_Maybe.Nothing.value;
                  };
                  if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Nil) {
                      $tco_done = true;
                      return new Data_Maybe.Just({
                          revInit: v1,
                          last: v.value0
                      });
                  };
                  if (v instanceof Data_List_Types.Cons) {
                      $tco_var_v = v.value1;
                      $copy_v1 = new Data_List_Types.Cons(v.value0, v1);
                      return;
                  };
                  throw new Error("Failed pattern match at Data.List (line 274, column 3 - line 274, column 21): " + [ v.constructor.name, v1.constructor.name ]);
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($tco_var_v, $copy_v1);
              };
              return $tco_result;
          };
      };
      return Data_Functor.map(Data_Maybe.functorMaybe)(function (h) {
          return {
              init: reverse(h.revInit),
              last: h.last
          };
      })(go(lst)(Data_List_Types.Nil.value));
  };
  var zipWith = function (f) {
      return function (xs) {
          return function (ys) {
              var go = function ($copy_v) {
                  return function ($copy_v1) {
                      return function ($copy_acc) {
                          var $tco_var_v = $copy_v;
                          var $tco_var_v1 = $copy_v1;
                          var $tco_done = false;
                          var $tco_result;
                          function $tco_loop(v, v1, acc) {
                              if (v instanceof Data_List_Types.Nil) {
                                  $tco_done = true;
                                  return acc;
                              };
                              if (v1 instanceof Data_List_Types.Nil) {
                                  $tco_done = true;
                                  return acc;
                              };
                              if (v instanceof Data_List_Types.Cons && v1 instanceof Data_List_Types.Cons) {
                                  $tco_var_v = v.value1;
                                  $tco_var_v1 = v1.value1;
                                  $copy_acc = new Data_List_Types.Cons(f(v.value0)(v1.value0), acc);
                                  return;
                              };
                              throw new Error("Failed pattern match at Data.List (line 795, column 3 - line 795, column 21): " + [ v.constructor.name, v1.constructor.name, acc.constructor.name ]);
                          };
                          while (!$tco_done) {
                              $tco_result = $tco_loop($tco_var_v, $tco_var_v1, $copy_acc);
                          };
                          return $tco_result;
                      };
                  };
              };
              return reverse(go(xs)(ys)(Data_List_Types.Nil.value));
          };
      };
  };
  var zip = zipWith(Data_Tuple.Tuple.create);
  var range = function (start) {
      return function (end) {
          if (start === end) {
              return singleton(start);
          };
          if (Data_Boolean.otherwise) {
              var go = function ($copy_s) {
                  return function ($copy_e) {
                      return function ($copy_step) {
                          return function ($copy_rest) {
                              var $tco_var_s = $copy_s;
                              var $tco_var_e = $copy_e;
                              var $tco_var_step = $copy_step;
                              var $tco_done = false;
                              var $tco_result;
                              function $tco_loop(s, e, step, rest) {
                                  if (s === e) {
                                      $tco_done = true;
                                      return new Data_List_Types.Cons(s, rest);
                                  };
                                  if (Data_Boolean.otherwise) {
                                      $tco_var_s = s + step | 0;
                                      $tco_var_e = e;
                                      $tco_var_step = step;
                                      $copy_rest = new Data_List_Types.Cons(s, rest);
                                      return;
                                  };
                                  throw new Error("Failed pattern match at Data.List (line 152, column 3 - line 153, column 65): " + [ s.constructor.name, e.constructor.name, step.constructor.name, rest.constructor.name ]);
                              };
                              while (!$tco_done) {
                                  $tco_result = $tco_loop($tco_var_s, $tco_var_e, $tco_var_step, $copy_rest);
                              };
                              return $tco_result;
                          };
                      };
                  };
              };
              return go(end)(start)((function () {
                  var $226 = start > end;
                  if ($226) {
                      return 1;
                  };
                  return -1 | 0;
              })())(Data_List_Types.Nil.value);
          };
          throw new Error("Failed pattern match at Data.List (line 148, column 1 - line 148, column 32): " + [ start.constructor.name, end.constructor.name ]);
      };
  };
  var $$null = function (v) {
      if (v instanceof Data_List_Types.Nil) {
          return true;
      };
      return false;
  }; 
  var mapWithIndex = Data_FunctorWithIndex.mapWithIndex(Data_List_Types.functorWithIndexList);
  var some = function (dictAlternative) {
      return function (dictLazy) {
          return function (v) {
              return Control_Apply.apply((dictAlternative.Applicative0()).Apply0())(Data_Functor.map(((dictAlternative.Plus1()).Alt0()).Functor0())(Data_List_Types.Cons.create)(v))(Control_Lazy.defer(dictLazy)(function (v1) {
                  return many(dictAlternative)(dictLazy)(v);
              }));
          };
      };
  };
  var many = function (dictAlternative) {
      return function (dictLazy) {
          return function (v) {
              return Control_Alt.alt((dictAlternative.Plus1()).Alt0())(some(dictAlternative)(dictLazy)(v))(Control_Applicative.pure(dictAlternative.Applicative0())(Data_List_Types.Nil.value));
          };
      };
  };
  var length = Data_Foldable.foldl(Data_List_Types.foldableList)(function (acc) {
      return function (v) {
          return acc + 1 | 0;
      };
  })(0);
  var last = function ($copy_v) {
      var $tco_done = false;
      var $tco_result;
      function $tco_loop(v) {
          if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Nil) {
              $tco_done = true;
              return new Data_Maybe.Just(v.value0);
          };
          if (v instanceof Data_List_Types.Cons) {
              $copy_v = v.value1;
              return;
          };
          $tco_done = true;
          return Data_Maybe.Nothing.value;
      };
      while (!$tco_done) {
          $tco_result = $tco_loop($copy_v);
      };
      return $tco_result;
  };
  var init = function (lst) {
      return Data_Functor.map(Data_Maybe.functorMaybe)(function (v) {
          return v.init;
      })(unsnoc(lst));
  };
  var head = function (v) {
      if (v instanceof Data_List_Types.Nil) {
          return Data_Maybe.Nothing.value;
      };
      if (v instanceof Data_List_Types.Cons) {
          return new Data_Maybe.Just(v.value0);
      };
      throw new Error("Failed pattern match at Data.List (line 234, column 1 - line 234, column 22): " + [ v.constructor.name ]);
  };
  var fromFoldable = function (dictFoldable) {
      return Data_Foldable.foldr(dictFoldable)(Data_List_Types.Cons.create)(Data_List_Types.Nil.value);
  };
  var findIndex = function (fn) {
      var go = function ($copy_v) {
          return function ($copy_v1) {
              var $tco_var_v = $copy_v;
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(v, v1) {
                  if (v1 instanceof Data_List_Types.Cons) {
                      if (fn(v1.value0)) {
                          $tco_done = true;
                          return new Data_Maybe.Just(v);
                      };
                      if (Data_Boolean.otherwise) {
                          $tco_var_v = v + 1 | 0;
                          $copy_v1 = v1.value1;
                          return;
                      };
                  };
                  if (v1 instanceof Data_List_Types.Nil) {
                      $tco_done = true;
                      return Data_Maybe.Nothing.value;
                  };
                  throw new Error("Failed pattern match at Data.List (line 305, column 3 - line 305, column 35): " + [ v.constructor.name, v1.constructor.name ]);
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($tco_var_v, $copy_v1);
              };
              return $tco_result;
          };
      };
      return go(0);
  };
  var filter = function (p) {
      var go = function ($copy_acc) {
          return function ($copy_v) {
              var $tco_var_acc = $copy_acc;
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(acc, v) {
                  if (v instanceof Data_List_Types.Nil) {
                      $tco_done = true;
                      return reverse(acc);
                  };
                  if (v instanceof Data_List_Types.Cons) {
                      if (p(v.value0)) {
                          $tco_var_acc = new Data_List_Types.Cons(v.value0, acc);
                          $copy_v = v.value1;
                          return;
                      };
                      if (Data_Boolean.otherwise) {
                          $tco_var_acc = acc;
                          $copy_v = v.value1;
                          return;
                      };
                  };
                  throw new Error("Failed pattern match at Data.List (line 394, column 3 - line 394, column 27): " + [ acc.constructor.name, v.constructor.name ]);
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($tco_var_acc, $copy_v);
              };
              return $tco_result;
          };
      };
      return go(Data_List_Types.Nil.value);
  };
  var elemIndex = function (dictEq) {
      return function (x) {
          return findIndex(function (v) {
              return Data_Eq.eq(dictEq)(v)(x);
          });
      };
  };
  var drop = function ($copy_v) {
      return function ($copy_v1) {
          var $tco_var_v = $copy_v;
          var $tco_done = false;
          var $tco_result;
          function $tco_loop(v, v1) {
              if (v < 1) {
                  $tco_done = true;
                  return v1;
              };
              if (v1 instanceof Data_List_Types.Nil) {
                  $tco_done = true;
                  return Data_List_Types.Nil.value;
              };
              if (v1 instanceof Data_List_Types.Cons) {
                  $tco_var_v = v - 1 | 0;
                  $copy_v1 = v1.value1;
                  return;
              };
              throw new Error("Failed pattern match at Data.List (line 547, column 1 - line 547, column 42): " + [ v.constructor.name, v1.constructor.name ]);
          };
          while (!$tco_done) {
              $tco_result = $tco_loop($tco_var_v, $copy_v1);
          };
          return $tco_result;
      };
  };
  var deleteAt = function (v) {
      return function (v1) {
          if (v === 0 && v1 instanceof Data_List_Types.Cons) {
              return new Data_Maybe.Just(v1.value1);
          };
          if (v1 instanceof Data_List_Types.Cons) {
              return Data_Functor.map(Data_Maybe.functorMaybe)(function (v2) {
                  return new Data_List_Types.Cons(v1.value0, v2);
              })(deleteAt(v - 1 | 0)(v1.value1));
          };
          return Data_Maybe.Nothing.value;
      };
  };                                                                               
  var alterAt = function (v) {
      return function (v1) {
          return function (v2) {
              if (v === 0 && v2 instanceof Data_List_Types.Cons) {
                  return Data_Maybe.Just.create((function () {
                      var v3 = v1(v2.value0);
                      if (v3 instanceof Data_Maybe.Nothing) {
                          return v2.value1;
                      };
                      if (v3 instanceof Data_Maybe.Just) {
                          return new Data_List_Types.Cons(v3.value0, v2.value1);
                      };
                      throw new Error("Failed pattern match at Data.List (line 356, column 3 - line 358, column 23): " + [ v3.constructor.name ]);
                  })());
              };
              if (v2 instanceof Data_List_Types.Cons) {
                  return Data_Functor.map(Data_Maybe.functorMaybe)(function (v3) {
                      return new Data_List_Types.Cons(v2.value0, v3);
                  })(alterAt(v - 1 | 0)(v1)(v2.value1));
              };
              return Data_Maybe.Nothing.value;
          };
      };
  };
  var modifyAt = function (n) {
      return function (f) {
          return alterAt(n)(function ($354) {
              return Data_Maybe.Just.create(f($354));
          });
      };
  };
  exports["toUnfoldable"] = toUnfoldable;
  exports["fromFoldable"] = fromFoldable;
  exports["singleton"] = singleton;
  exports["range"] = range;
  exports["some"] = some;
  exports["many"] = many;
  exports["null"] = $$null;
  exports["length"] = length;
  exports["snoc"] = snoc;
  exports["head"] = head;
  exports["last"] = last;
  exports["unsnoc"] = unsnoc;
  exports["elemIndex"] = elemIndex;
  exports["deleteAt"] = deleteAt;
  exports["modifyAt"] = modifyAt;
  exports["reverse"] = reverse;
  exports["filter"] = filter;
  exports["mapWithIndex"] = mapWithIndex;
  exports["take"] = take;
  exports["drop"] = drop;
  exports["span"] = span;
  exports["zip"] = zip;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.CatQueue"] = $PS["Data.CatQueue"] || {};
  var exports = $PS["Data.CatQueue"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Tuple = $PS["Data.Tuple"];                            
  var CatQueue = (function () {
      function CatQueue(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      CatQueue.create = function (value0) {
          return function (value1) {
              return new CatQueue(value0, value1);
          };
      };
      return CatQueue;
  })();
  var uncons = function ($copy_v) {
      var $tco_done = false;
      var $tco_result;
      function $tco_loop(v) {
          if (v.value0 instanceof Data_List_Types.Nil && v.value1 instanceof Data_List_Types.Nil) {
              $tco_done = true;
              return Data_Maybe.Nothing.value;
          };
          if (v.value0 instanceof Data_List_Types.Nil) {
              $copy_v = new CatQueue(Data_List.reverse(v.value1), Data_List_Types.Nil.value);
              return;
          };
          if (v.value0 instanceof Data_List_Types.Cons) {
              $tco_done = true;
              return new Data_Maybe.Just(new Data_Tuple.Tuple(v.value0.value0, new CatQueue(v.value0.value1, v.value1)));
          };
          throw new Error("Failed pattern match at Data.CatQueue (line 83, column 1 - line 83, column 63): " + [ v.constructor.name ]);
      };
      while (!$tco_done) {
          $tco_result = $tco_loop($copy_v);
      };
      return $tco_result;
  };
  var snoc = function (v) {
      return function (a) {
          return new CatQueue(v.value0, new Data_List_Types.Cons(a, v.value1));
      };
  };
  var $$null = function (v) {
      if (v.value0 instanceof Data_List_Types.Nil && v.value1 instanceof Data_List_Types.Nil) {
          return true;
      };
      return false;
  };                                                                                                
  var empty = new CatQueue(Data_List_Types.Nil.value, Data_List_Types.Nil.value);
  exports["empty"] = empty;
  exports["null"] = $$null;
  exports["snoc"] = snoc;
  exports["uncons"] = uncons;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.CatList"] = $PS["Data.CatList"] || {};
  var exports = $PS["Data.CatList"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad = $PS["Control.Monad"];
  var Data_CatQueue = $PS["Data.CatQueue"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Tuple = $PS["Data.Tuple"];                            
  var CatNil = (function () {
      function CatNil() {

      };
      CatNil.value = new CatNil();
      return CatNil;
  })();
  var CatCons = (function () {
      function CatCons(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      CatCons.create = function (value0) {
          return function (value1) {
              return new CatCons(value0, value1);
          };
      };
      return CatCons;
  })();
  var link = function (v) {
      return function (v1) {
          if (v instanceof CatNil) {
              return v1;
          };
          if (v1 instanceof CatNil) {
              return v;
          };
          if (v instanceof CatCons) {
              return new CatCons(v.value0, Data_CatQueue.snoc(v.value1)(v1));
          };
          throw new Error("Failed pattern match at Data.CatList (line 109, column 1 - line 109, column 54): " + [ v.constructor.name, v1.constructor.name ]);
      };
  };
  var foldr = function (k) {
      return function (b) {
          return function (q) {
              var foldl = function ($copy_v) {
                  return function ($copy_c) {
                      return function ($copy_v1) {
                          var $tco_var_v = $copy_v;
                          var $tco_var_c = $copy_c;
                          var $tco_done = false;
                          var $tco_result;
                          function $tco_loop(v, c, v1) {
                              if (v1 instanceof Data_List_Types.Nil) {
                                  $tco_done = true;
                                  return c;
                              };
                              if (v1 instanceof Data_List_Types.Cons) {
                                  $tco_var_v = v;
                                  $tco_var_c = v(c)(v1.value0);
                                  $copy_v1 = v1.value1;
                                  return;
                              };
                              throw new Error("Failed pattern match at Data.CatList (line 125, column 3 - line 125, column 59): " + [ v.constructor.name, c.constructor.name, v1.constructor.name ]);
                          };
                          while (!$tco_done) {
                              $tco_result = $tco_loop($tco_var_v, $tco_var_c, $copy_v1);
                          };
                          return $tco_result;
                      };
                  };
              };
              var go = function ($copy_xs) {
                  return function ($copy_ys) {
                      var $tco_var_xs = $copy_xs;
                      var $tco_done1 = false;
                      var $tco_result;
                      function $tco_loop(xs, ys) {
                          var v = Data_CatQueue.uncons(xs);
                          if (v instanceof Data_Maybe.Nothing) {
                              $tco_done1 = true;
                              return foldl(function (x) {
                                  return function (i) {
                                      return i(x);
                                  };
                              })(b)(ys);
                          };
                          if (v instanceof Data_Maybe.Just) {
                              $tco_var_xs = v.value0.value1;
                              $copy_ys = new Data_List_Types.Cons(k(v.value0.value0), ys);
                              return;
                          };
                          throw new Error("Failed pattern match at Data.CatList (line 121, column 14 - line 123, column 67): " + [ v.constructor.name ]);
                      };
                      while (!$tco_done1) {
                          $tco_result = $tco_loop($tco_var_xs, $copy_ys);
                      };
                      return $tco_result;
                  };
              };
              return go(q)(Data_List_Types.Nil.value);
          };
      };
  };
  var uncons = function (v) {
      if (v instanceof CatNil) {
          return Data_Maybe.Nothing.value;
      };
      if (v instanceof CatCons) {
          return new Data_Maybe.Just(new Data_Tuple.Tuple(v.value0, (function () {
              var $45 = Data_CatQueue["null"](v.value1);
              if ($45) {
                  return CatNil.value;
              };
              return foldr(link)(CatNil.value)(v.value1);
          })()));
      };
      throw new Error("Failed pattern match at Data.CatList (line 100, column 1 - line 100, column 61): " + [ v.constructor.name ]);
  };
  var foldableCatList = new Data_Foldable.Foldable(function (dictMonoid) {
      return Data_Foldable.foldMapDefaultL(foldableCatList)(dictMonoid);
  }, function (f) {
      var go = function ($copy_acc) {
          return function ($copy_q) {
              var $tco_var_acc = $copy_acc;
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(acc, q) {
                  var v = uncons(q);
                  if (v instanceof Data_Maybe.Just) {
                      $tco_var_acc = f(acc)(v.value0.value0);
                      $copy_q = v.value0.value1;
                      return;
                  };
                  if (v instanceof Data_Maybe.Nothing) {
                      $tco_done = true;
                      return acc;
                  };
                  throw new Error("Failed pattern match at Data.CatList (line 157, column 16 - line 159, column 22): " + [ v.constructor.name ]);
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($tco_var_acc, $copy_q);
              };
              return $tco_result;
          };
      };
      return go;
  }, function (f) {
      return function (s) {
          return function (l) {
              return Data_Foldable.foldrDefault(foldableCatList)(f)(s)(l);
          };
      };
  });                                                                           
  var foldMap = function (dictMonoid) {
      return function (v) {
          return function (v1) {
              if (v1 instanceof CatNil) {
                  return Data_Monoid.mempty(dictMonoid);
              };
              if (v1 instanceof CatCons) {
                  var d = (function () {
                      var $54 = Data_CatQueue["null"](v1.value1);
                      if ($54) {
                          return CatNil.value;
                      };
                      return foldr(link)(CatNil.value)(v1.value1);
                  })();
                  return Data_Semigroup.append(dictMonoid.Semigroup0())(v(v1.value0))(foldMap(dictMonoid)(v)(d));
              };
              throw new Error("Failed pattern match at Data.CatList (line 135, column 1 - line 135, column 62): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
  };
  var empty = CatNil.value;
  var append = link;
  var cons = function (a) {
      return function (cat) {
          return append(new CatCons(a, Data_CatQueue.empty))(cat);
      };
  };
  var functorCatList = new Data_Functor.Functor(function (v) {
      return function (v1) {
          if (v1 instanceof CatNil) {
              return CatNil.value;
          };
          if (v1 instanceof CatCons) {
              var d = (function () {
                  var $59 = Data_CatQueue["null"](v1.value1);
                  if ($59) {
                      return CatNil.value;
                  };
                  return foldr(link)(CatNil.value)(v1.value1);
              })();
              return cons(v(v1.value0))(Data_Functor.map(functorCatList)(v)(d));
          };
          throw new Error("Failed pattern match at Data.CatList (line 185, column 1 - line 189, column 26): " + [ v.constructor.name, v1.constructor.name ]);
      };
  });
  var singleton = function (a) {
      return cons(a)(CatNil.value);
  }; 
  var semigroupCatList = new Data_Semigroup.Semigroup(append);
  var monoidCatList = new Data_Monoid.Monoid(function () {
      return semigroupCatList;
  }, CatNil.value);
  var monadCatList = new Control_Monad.Monad(function () {
      return applicativeCatList;
  }, function () {
      return bindCatList;
  });
  var bindCatList = new Control_Bind.Bind(function () {
      return applyCatList;
  }, Data_Function.flip(foldMap(monoidCatList)));
  var applyCatList = new Control_Apply.Apply(function () {
      return functorCatList;
  }, Control_Monad.ap(monadCatList));
  var applicativeCatList = new Control_Applicative.Applicative(function () {
      return applyCatList;
  }, singleton);
  var snoc = function (cat) {
      return function (a) {
          return append(cat)(new CatCons(a, Data_CatQueue.empty));
      };
  };
  exports["empty"] = empty;
  exports["snoc"] = snoc;
  exports["uncons"] = uncons;
  exports["semigroupCatList"] = semigroupCatList;
  exports["monoidCatList"] = monoidCatList;
  exports["foldableCatList"] = foldableCatList;
  exports["functorCatList"] = functorCatList;
  exports["applicativeCatList"] = applicativeCatList;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.Free"] = $PS["Control.Monad.Free"] || {};
  var exports = $PS["Control.Monad.Free"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad = $PS["Control.Monad"];
  var Control_Monad_Rec_Class = $PS["Control.Monad.Rec.Class"];
  var Data_CatList = $PS["Data.CatList"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Free = (function () {
      function Free(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Free.create = function (value0) {
          return function (value1) {
              return new Free(value0, value1);
          };
      };
      return Free;
  })();
  var Return = (function () {
      function Return(value0) {
          this.value0 = value0;
      };
      Return.create = function (value0) {
          return new Return(value0);
      };
      return Return;
  })();
  var Bind = (function () {
      function Bind(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Bind.create = function (value0) {
          return function (value1) {
              return new Bind(value0, value1);
          };
      };
      return Bind;
  })();
  var toView = function ($copy_v) {
      var $tco_done = false;
      var $tco_result;
      function $tco_loop(v) {
          var runExpF = function (v2) {
              return v2;
          };
          var concatF = function (v2) {
              return function (r) {
                  return new Free(v2.value0, Data_Semigroup.append(Data_CatList.semigroupCatList)(v2.value1)(r));
              };
          };
          if (v.value0 instanceof Return) {
              var v2 = Data_CatList.uncons(v.value1);
              if (v2 instanceof Data_Maybe.Nothing) {
                  $tco_done = true;
                  return new Return(v.value0.value0);
              };
              if (v2 instanceof Data_Maybe.Just) {
                  $copy_v = concatF(runExpF(v2.value0.value0)(v.value0.value0))(v2.value0.value1);
                  return;
              };
              throw new Error("Failed pattern match at Control.Monad.Free (line 227, column 7 - line 231, column 64): " + [ v2.constructor.name ]);
          };
          if (v.value0 instanceof Bind) {
              $tco_done = true;
              return new Bind(v.value0.value0, function (a) {
                  return concatF(v.value0.value1(a))(v.value1);
              });
          };
          throw new Error("Failed pattern match at Control.Monad.Free (line 225, column 3 - line 233, column 56): " + [ v.value0.constructor.name ]);
      };
      while (!$tco_done) {
          $tco_result = $tco_loop($copy_v);
      };
      return $tco_result;
  };
  var fromView = function (f) {
      return new Free(f, Data_CatList.empty);
  };
  var freeMonad = new Control_Monad.Monad(function () {
      return freeApplicative;
  }, function () {
      return freeBind;
  });
  var freeFunctor = new Data_Functor.Functor(function (k) {
      return function (f) {
          return Control_Bind.bindFlipped(freeBind)((function () {
              var $119 = Control_Applicative.pure(freeApplicative);
              return function ($120) {
                  return $119(k($120));
              };
          })())(f);
      };
  });
  var freeBind = new Control_Bind.Bind(function () {
      return freeApply;
  }, function (v) {
      return function (k) {
          return new Free(v.value0, Data_CatList.snoc(v.value1)(k));
      };
  });
  var freeApply = new Control_Apply.Apply(function () {
      return freeFunctor;
  }, Control_Monad.ap(freeMonad));
  var freeApplicative = new Control_Applicative.Applicative(function () {
      return freeApply;
  }, function ($121) {
      return fromView(Return.create($121));
  });
  var liftF = function (f) {
      return fromView(new Bind(f, (function () {
          var $122 = Control_Applicative.pure(freeApplicative);
          return function ($123) {
              return $122($123);
          };
      })()));
  };
  var substFree = function (k) {
      var go = function (f) {
          var v = toView(f);
          if (v instanceof Return) {
              return Control_Applicative.pure(freeApplicative)(v.value0);
          };
          if (v instanceof Bind) {
              return Control_Bind.bind(freeBind)(k(v.value0))(Data_Functor.map(Data_Functor.functorFn)(go)(v.value1));
          };
          throw new Error("Failed pattern match at Control.Monad.Free (line 168, column 10 - line 170, column 33): " + [ v.constructor.name ]);
      };
      return go;
  };
  var hoistFree = function (k) {
      return substFree(function ($124) {
          return liftF(k($124));
      });
  };
  var foldFree = function (dictMonadRec) {
      return function (k) {
          var go = function (f) {
              var v = toView(f);
              if (v instanceof Return) {
                  return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_Rec_Class.Done.create)(Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())(v.value0));
              };
              if (v instanceof Bind) {
                  return Data_Functor.map((((dictMonadRec.Monad0()).Bind1()).Apply0()).Functor0())(function ($135) {
                      return Control_Monad_Rec_Class.Loop.create(v.value1($135));
                  })(k(v.value0));
              };
              throw new Error("Failed pattern match at Control.Monad.Free (line 158, column 10 - line 160, column 37): " + [ v.constructor.name ]);
          };
          return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(go);
      };
  };
  exports["liftF"] = liftF;
  exports["hoistFree"] = hoistFree;
  exports["foldFree"] = foldFree;
  exports["freeBind"] = freeBind;
  exports["freeApplicative"] = freeApplicative;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.Reader"] = $PS["Control.Monad.Reader"] || {};
  var exports = $PS["Control.Monad.Reader"];
  var Data_Newtype = $PS["Data.Newtype"];                 
  var runReader = function (v) {
      var $2 = Data_Newtype.unwrap();
      return function ($3) {
          return $2(v($3));
      };
  };
  exports["runReader"] = runReader;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.Reader.Class"] = $PS["Control.Monad.Reader.Class"] || {};
  var exports = $PS["Control.Monad.Reader.Class"];       
  var MonadAsk = function (Monad0, ask) {
      this.Monad0 = Monad0;
      this.ask = ask;
  };
  var ask = function (dict) {
      return dict.ask;
  };
  exports["ask"] = ask;
  exports["MonadAsk"] = MonadAsk;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.Reader.Trans"] = $PS["Control.Monad.Reader.Trans"] || {};
  var exports = $PS["Control.Monad.Reader.Trans"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad = $PS["Control.Monad"];
  var Control_Monad_Reader_Class = $PS["Control.Monad.Reader.Class"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];                
  var ReaderT = function (x) {
      return x;
  }; 
  var mapReaderT = function (f) {
      return function (v) {
          return function ($65) {
              return f(v($65));
          };
      };
  };
  var functorReaderT = function (dictFunctor) {
      return new Data_Functor.Functor((function () {
          var $66 = Data_Functor.map(dictFunctor);
          return function ($67) {
              return mapReaderT($66($67));
          };
      })());
  };
  var applyReaderT = function (dictApply) {
      return new Control_Apply.Apply(function () {
          return functorReaderT(dictApply.Functor0());
      }, function (v) {
          return function (v1) {
              return function (r) {
                  return Control_Apply.apply(dictApply)(v(r))(v1(r));
              };
          };
      });
  };
  var bindReaderT = function (dictBind) {
      return new Control_Bind.Bind(function () {
          return applyReaderT(dictBind.Apply0());
      }, function (v) {
          return function (k) {
              return function (r) {
                  return Control_Bind.bind(dictBind)(v(r))(function (a) {
                      var v1 = k(a);
                      return v1(r);
                  });
              };
          };
      });
  };
  var applicativeReaderT = function (dictApplicative) {
      return new Control_Applicative.Applicative(function () {
          return applyReaderT(dictApplicative.Apply0());
      }, (function () {
          var $71 = Control_Applicative.pure(dictApplicative);
          return function ($72) {
              return ReaderT(Data_Function["const"]($71($72)));
          };
      })());
  };
  var monadReaderT = function (dictMonad) {
      return new Control_Monad.Monad(function () {
          return applicativeReaderT(dictMonad.Applicative0());
      }, function () {
          return bindReaderT(dictMonad.Bind1());
      });
  };
  var monadAskReaderT = function (dictMonad) {
      return new Control_Monad_Reader_Class.MonadAsk(function () {
          return monadReaderT(dictMonad);
      }, Control_Applicative.pure(dictMonad.Applicative0()));
  };
  exports["functorReaderT"] = functorReaderT;
  exports["applicativeReaderT"] = applicativeReaderT;
  exports["bindReaderT"] = bindReaderT;
  exports["monadAskReaderT"] = monadAskReaderT;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.State"] = $PS["Control.Monad.State"] || {};
  var exports = $PS["Control.Monad.State"];
  var execState = function (v) {
      return function (s) {
          var v1 = v(s);
          return v1.value1;
      };
  };
  var evalState = function (v) {
      return function (s) {
          var v1 = v(s);
          return v1.value0;
      };
  };
  exports["evalState"] = evalState;
  exports["execState"] = execState;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Monad.State.Trans"] = $PS["Control.Monad.State.Trans"] || {};
  var exports = $PS["Control.Monad.State.Trans"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Lazy = $PS["Control.Lazy"];
  var Control_Monad = $PS["Control.Monad"];
  var Control_Monad_Rec_Class = $PS["Control.Monad.Rec.Class"];
  var Control_Monad_State_Class = $PS["Control.Monad.State.Class"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];                      
  var StateT = function (x) {
      return x;
  };
  var runStateT = function (v) {
      return v;
  };
  var lazyStateT = new Control_Lazy.Lazy(function (f) {
      return function (s) {
          var v = f(Data_Unit.unit);
          return v(s);
      };
  });
  var functorStateT = function (dictFunctor) {
      return new Data_Functor.Functor(function (f) {
          return function (v) {
              return function (s) {
                  return Data_Functor.map(dictFunctor)(function (v1) {
                      return new Data_Tuple.Tuple(f(v1.value0), v1.value1);
                  })(v(s));
              };
          };
      });
  };
  var evalStateT = function (dictFunctor) {
      return function (v) {
          return function (s) {
              return Data_Functor.map(dictFunctor)(Data_Tuple.fst)(v(s));
          };
      };
  };
  var monadStateT = function (dictMonad) {
      return new Control_Monad.Monad(function () {
          return applicativeStateT(dictMonad);
      }, function () {
          return bindStateT(dictMonad);
      });
  };
  var bindStateT = function (dictMonad) {
      return new Control_Bind.Bind(function () {
          return applyStateT(dictMonad);
      }, function (v) {
          return function (f) {
              return function (s) {
                  return Control_Bind.bind(dictMonad.Bind1())(v(s))(function (v1) {
                      var v3 = f(v1.value0);
                      return v3(v1.value1);
                  });
              };
          };
      });
  };
  var applyStateT = function (dictMonad) {
      return new Control_Apply.Apply(function () {
          return functorStateT(((dictMonad.Bind1()).Apply0()).Functor0());
      }, Control_Monad.ap(monadStateT(dictMonad)));
  };
  var applicativeStateT = function (dictMonad) {
      return new Control_Applicative.Applicative(function () {
          return applyStateT(dictMonad);
      }, function (a) {
          return function (s) {
              return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(a, s));
          };
      });
  };
  var monadRecStateT = function (dictMonadRec) {
      return new Control_Monad_Rec_Class.MonadRec(function () {
          return monadStateT(dictMonadRec.Monad0());
      }, function (f) {
          return function (a) {
              var f$prime = function (v) {
                  var v1 = f(v.value0);
                  return Control_Bind.bind((dictMonadRec.Monad0()).Bind1())(v1(v.value1))(function (v2) {
                      return Control_Applicative.pure((dictMonadRec.Monad0()).Applicative0())((function () {
                          if (v2.value0 instanceof Control_Monad_Rec_Class.Loop) {
                              return new Control_Monad_Rec_Class.Loop(new Data_Tuple.Tuple(v2.value0.value0, v2.value1));
                          };
                          if (v2.value0 instanceof Control_Monad_Rec_Class.Done) {
                              return new Control_Monad_Rec_Class.Done(new Data_Tuple.Tuple(v2.value0.value0, v2.value1));
                          };
                          throw new Error("Failed pattern match at Control.Monad.State.Trans (line 88, column 16 - line 90, column 40): " + [ v2.value0.constructor.name ]);
                      })());
                  });
              };
              return function (s) {
                  return Control_Monad_Rec_Class.tailRecM(dictMonadRec)(f$prime)(new Data_Tuple.Tuple(a, s));
              };
          };
      });
  };
  var monadStateStateT = function (dictMonad) {
      return new Control_Monad_State_Class.MonadState(function () {
          return monadStateT(dictMonad);
      }, function (f) {
          return StateT((function () {
              var $113 = Control_Applicative.pure(dictMonad.Applicative0());
              return function ($114) {
                  return $113(f($114));
              };
          })());
      });
  };
  exports["StateT"] = StateT;
  exports["runStateT"] = runStateT;
  exports["evalStateT"] = evalStateT;
  exports["functorStateT"] = functorStateT;
  exports["applicativeStateT"] = applicativeStateT;
  exports["bindStateT"] = bindStateT;
  exports["monadStateT"] = monadStateT;
  exports["monadRecStateT"] = monadRecStateT;
  exports["lazyStateT"] = lazyStateT;
  exports["monadStateStateT"] = monadStateStateT;
})(PS);
(function(exports) {
    

  exports.thenImpl = function(promise) {
    return function(errCB) {
      return function(succCB) {
        return function() {
          promise.then(succCB, errCB);
        };
      };
    };
  };
})(PS["Control.Promise"] = PS["Control.Promise"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Control.Promise"] = $PS["Control.Promise"] || {};
  var exports = $PS["Control.Promise"];
  var $foreign = $PS["Control.Promise"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Control_Monad_Except = $PS["Control.Monad.Except"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Either = $PS["Data.Either"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Foreign = $PS["Foreign"];                
  var toAff$prime = function (customCoerce) {
      return function (p) {
          return Effect_Aff.makeAff(function (cb) {
              return Data_Functor.voidRight(Effect.functorEffect)(Data_Monoid.mempty(Effect_Aff.monoidCanceler))($foreign.thenImpl(p)(function ($1) {
                  return cb(Data_Either.Left.create(customCoerce($1)))();
              })(function ($2) {
                  return cb(Data_Either.Right.create($2))();
              }));
          });
      };
  };
  var coerce = function (fn) {
      return Data_Either.either(function (v) {
          return Effect_Exception.error("Promise failed, couldn't extract JS Error or String");
      })(Control_Category.identity(Control_Category.categoryFn))(Control_Monad_Except.runExcept(Control_Alt.alt(Control_Monad_Except_Trans.altExceptT(Data_List_Types.semigroupNonEmptyList)(Data_Identity.monadIdentity))(Foreign.unsafeReadTagged(Data_Identity.monadIdentity)("Error")(fn))(Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Effect_Exception.error)(Foreign.readString(Data_Identity.monadIdentity)(fn)))));
  };
  var toAff = toAff$prime(coerce);
  var toAffE = function (f) {
      return Control_Bind.bind(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(f))(toAff);
  };
  exports["toAffE"] = toAffE;
})(PS);
(function(exports) {
  'use strict';

  function args() { return arguments; }
  exports._args2 = args;                                        
  exports._apply = function apply(f, that, args) { return f.apply(that, args); };
})(PS["FFI.Simple.Functions"] = PS["FFI.Simple.Functions"] || {});
(function(exports) {
  'use strict';

  function typeOf(v) { return typeof v; }
  function instanceOf(obj, thing) { return obj instanceof thing; }
  function isIn(prop,obj) { return prop in obj; }
  function keys(obj) { return Object.keys(obj); };
  function hasOwnProperty(prop, obj) { return obj.hasOwnProperty(prop); }
  function getProperty(prop, obj) { return obj[prop]; }
  function setProperty(prop, obj, value) {
    obj[prop] = value;
    return obj;
  }
  function defineProperty(prop, obj, value) {
    Object.defineProperty(obj, prop, {value: value, writable: false});
    return obj;
  }
  function removeProperty(prop, obj) { delete obj[prop]; return obj; }
  exports._keys = keys;                    
  exports._getProperty = getProperty;
  exports._setProperty = setProperty;
  exports._defineProperty = defineProperty;
  exports._removeProperty = removeProperty;
})(PS["FFI.Simple.Objects"] = PS["FFI.Simple.Objects"] || {});
(function(exports) {
  'use strict';                                                                     
  exports._nullUndef = function nullUndef(v) { return (typeof v === 'undefined') ? null : v; };
})(PS["FFI.Simple.Undef"] = PS["FFI.Simple.Undef"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["FFI.Simple.Undef"] = $PS["FFI.Simple.Undef"] || {};
  var exports = $PS["FFI.Simple.Undef"];
  var $foreign = $PS["FFI.Simple.Undef"];
  var Data_Nullable = $PS["Data.Nullable"];
  var nullUndef = $foreign["_nullUndef"];
  var maybeUndef = function ($1) {
      return Data_Nullable.toMaybe(nullUndef($1));
  };
  exports["maybeUndef"] = maybeUndef;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["FFI.Simple.Objects"] = $PS["FFI.Simple.Objects"] || {};
  var exports = $PS["FFI.Simple.Objects"];
  var $foreign = $PS["FFI.Simple.Objects"];
  var Data_Function = $PS["Data.Function"];
  var Data_Function_Uncurried = $PS["Data.Function.Uncurried"];
  var FFI_Simple_Undef = $PS["FFI.Simple.Undef"];
  var setProperty = Data_Function_Uncurried.runFn3($foreign["_setProperty"]);
  var setProperty$prime = Data_Function.flip(setProperty);
  var removeProperty = Data_Function_Uncurried.runFn2($foreign["_removeProperty"]);
  var removeProperty$prime = Data_Function.flip(removeProperty);
  var keys = $foreign["_keys"];                                                    
  var getProperty = Data_Function_Uncurried.runFn2($foreign["_getProperty"]);
  var getProperty$prime = Data_Function.flip(getProperty);
  var maybeGetProperty = function (p) {
      var $1 = getProperty(p);
      return function ($2) {
          return FFI_Simple_Undef.maybeUndef($1($2));
      };
  };
  var maybeGetProperty$prime = Data_Function.flip(maybeGetProperty);
  var defineProperty = Data_Function_Uncurried.runFn3($foreign["_defineProperty"]);
  exports["keys"] = keys;
  exports["getProperty"] = getProperty;
  exports["getProperty'"] = getProperty$prime;
  exports["maybeGetProperty'"] = maybeGetProperty$prime;
  exports["setProperty'"] = setProperty$prime;
  exports["defineProperty"] = defineProperty;
  exports["removeProperty'"] = removeProperty$prime;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["FFI.Simple.Functions"] = $PS["FFI.Simple.Functions"] || {};
  var exports = $PS["FFI.Simple.Functions"];
  var $foreign = $PS["FFI.Simple.Functions"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Function = $PS["Data.Function"];
  var Data_Function_Uncurried = $PS["Data.Function.Uncurried"];
  var FFI_Simple_Objects = $PS["FFI.Simple.Objects"];                
  var Delay = function (Monad0, delay) {
      this.Monad0 = Monad0;
      this.delay = delay;
  };                                                           
  var delayMonad = function (dictMonad) {
      return new Delay(function () {
          return dictMonad;
      }, (function () {
          var $1 = Control_Bind.bind(dictMonad.Bind1());
          var $2 = Control_Applicative.pure(dictMonad.Applicative0());
          return function ($3) {
              return $1($2($3));
          };
      })());
  };
  var delay = function (dict) {
      return dict.delay;
  };                                                             
  var args2 = Data_Function_Uncurried.runFn2($foreign["_args2"]);
  var applyTo = Data_Function_Uncurried.runFn3($foreign["_apply"]);
  var applyMethod = function (n) {
      return function (o) {
          return applyTo(FFI_Simple_Objects.getProperty(n)(o))(o);
      };
  };
  var applyMethod$prime = Data_Function.flip(applyMethod);
  exports["delay"] = delay;
  exports["applyMethod'"] = applyMethod$prime;
  exports["args2"] = args2;
  exports["delayMonad"] = delayMonad;
})(PS);
(function(exports) {
  'use strict';

  const glob
    =  (typeof globalThis !== 'undefined' && globalThis)
    || (typeof window !== 'undefined' && window)
    || (typeof global !== 'undefined' && global)
    || false;

  exports._global
    = glob
    ? (function(name) { return glob[name]; })
    : (function() {
         console.warn("FFI.Simple.Globals.global: none of globalThis, window, global are defined, falling back to silently returning undef");
         return function() {};
    })();
})(PS["FFI.Simple.Globals"] = PS["FFI.Simple.Globals"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["FFI.Simple.Globals"] = $PS["FFI.Simple.Globals"] || {};
  var exports = $PS["FFI.Simple.Globals"];
  var $foreign = $PS["FFI.Simple.Globals"];                      
  var unsafeGlobal = $foreign["_global"];
  exports["unsafeGlobal"] = unsafeGlobal;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["DOM.Simple.Console"] = $PS["DOM.Simple.Console"] || {};
  var exports = $PS["DOM.Simple.Console"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
  var FFI_Simple_Globals = $PS["FFI.Simple.Globals"];                
  var console = FFI_Simple_Globals.unsafeGlobal("console");
  var log = function (a) {
      return FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v) {
          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](console)("log")([ a ]));
      });
  };
  var log2 = function (a) {
      return function (b) {
          return FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v) {
              return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](console)("log")(FFI_Simple_Functions.args2(a)(b)));
          });
      };
  };
  exports["log"] = log;
  exports["log2"] = log2;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["DOM.Simple.Document"] = $PS["DOM.Simple.Document"] || {};
  var exports = $PS["DOM.Simple.Document"];
  var FFI_Simple_Globals = $PS["FFI.Simple.Globals"];                
  var document = FFI_Simple_Globals.unsafeGlobal("document");
  exports["document"] = document;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["DOM.Simple.Element"] = $PS["DOM.Simple.Element"] || {};
  var exports = $PS["DOM.Simple.Element"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
  var boundingRect = function (dictIsElement) {
      return function (e) {
          return FFI_Simple_Functions["applyMethod'"](e)("getBoundingClientRect")([  ]);
      };
  };
  exports["boundingRect"] = boundingRect;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["DOM.Simple.Event"] = $PS["DOM.Simple.Event"] || {};
  var exports = $PS["DOM.Simple.Event"];
  var FFI_Simple_Objects = $PS["FFI.Simple.Objects"];                  
  var key = function (e) {
      return FFI_Simple_Objects["getProperty'"](e)("key");
  };                                                                     
  var clientY = function (e) {
      return FFI_Simple_Objects["getProperty'"](e)("clientY");
  };
  var clientX = function (e) {
      return FFI_Simple_Objects["getProperty'"](e)("clientX");
  };
  exports["key"] = key;
  exports["clientX"] = clientX;
  exports["clientY"] = clientY;
})(PS);
(function(exports) {
  "use strict";

  exports.mkEffectFn1 = function mkEffectFn1(fn) {
    return function(x) {
      return fn(x)();
    };
  };

  exports.runEffectFn1 = function runEffectFn1(fn) {
    return function(a) {
      return function() {
        return fn(a);
      };
    };
  };

  exports.runEffectFn2 = function runEffectFn2(fn) {
    return function(a) {
      return function(b) {
        return function() {
          return fn(a, b);
        };
      };
    };
  };

  exports.runEffectFn3 = function runEffectFn3(fn) {
    return function(a) {
      return function(b) {
        return function(c) {
          return function() {
            return fn(a, b, c);
          };
        };
      };
    };
  };

  exports.runEffectFn4 = function runEffectFn4(fn) {
    return function(a) {
      return function(b) {
        return function(c) {
          return function(d) {
            return function() {
              return fn(a, b, c, d);
            };
          };
        };
      };
    };
  };
})(PS["Effect.Uncurried"] = PS["Effect.Uncurried"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Uncurried"] = $PS["Effect.Uncurried"] || {};
  var exports = $PS["Effect.Uncurried"];
  var $foreign = $PS["Effect.Uncurried"];
  exports["mkEffectFn1"] = $foreign.mkEffectFn1;
  exports["runEffectFn1"] = $foreign.runEffectFn1;
  exports["runEffectFn2"] = $foreign.runEffectFn2;
  exports["runEffectFn3"] = $foreign.runEffectFn3;
  exports["runEffectFn4"] = $foreign.runEffectFn4;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["DOM.Simple.EventListener"] = $PS["DOM.Simple.EventListener"] || {};
  var exports = $PS["DOM.Simple.EventListener"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Uncurried = $PS["Effect.Uncurried"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];                
  var Callback = function (x) {
      return x;
  };
  var removeEventListener = function (dictIsEventListener) {
      return function (dictIsEvent) {
          return function (obj) {
              return function (name) {
                  return function (cb) {
                      return FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v) {
                          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](obj)("removeEventListener")(FFI_Simple_Functions.args2(name)(cb)));
                      });
                  };
              };
          };
      };
  };
  var callback = function ($7) {
      return Callback(Effect_Uncurried.mkEffectFn1($7));
  };
  var addEventListener = function (dictIsEventListener) {
      return function (dictIsEvent) {
          return function (obj) {
              return function (name) {
                  return function (cb) {
                      return FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v) {
                          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](obj)("addEventListener")(FFI_Simple_Functions.args2(name)(cb)));
                      });
                  };
              };
          };
      };
  };
  exports["callback"] = callback;
  exports["addEventListener"] = addEventListener;
  exports["removeEventListener"] = removeEventListener;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["DOM.Simple.Window"] = $PS["DOM.Simple.Window"] || {};
  var exports = $PS["DOM.Simple.Window"];
  var FFI_Simple_Globals = $PS["FFI.Simple.Globals"];                
  var window = FFI_Simple_Globals.unsafeGlobal("window");
  exports["window"] = window;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Array.NonEmpty.Internal"] = $PS["Data.Array.NonEmpty.Internal"] || {};
  var exports = $PS["Data.Array.NonEmpty.Internal"];             
  var NonEmptyArray = function (x) {
      return x;
  };
  exports["NonEmptyArray"] = NonEmptyArray;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Array.NonEmpty"] = $PS["Data.Array.NonEmpty"] || {};
  var exports = $PS["Data.Array.NonEmpty"];
  var Data_Array = $PS["Data.Array"];
  var Data_Array_NonEmpty_Internal = $PS["Data.Array.NonEmpty.Internal"];
  var unsafeFromArray = Data_Array_NonEmpty_Internal.NonEmptyArray;
  var toArray = function (v) {
      return v;
  };
  var cons$prime = function (x) {
      return function (xs) {
          return unsafeFromArray(Data_Array.cons(x)(xs));
      };
  };
  var fromNonEmpty = function (v) {
      return cons$prime(v.value0)(v.value1);
  };                                         
  var adaptAny = function (f) {
      return function ($78) {
          return f(toArray($78));
      };
  };
  var filter = function (f) {
      return adaptAny(Data_Array.filter(f));
  };
  var unsafeAdapt = function (f) {
      var $79 = adaptAny(f);
      return function ($80) {
          return unsafeFromArray($79($80));
      };
  };
  var cons = function (x) {
      return unsafeAdapt(Data_Array.cons(x));
  };
  exports["fromNonEmpty"] = fromNonEmpty;
  exports["filter"] = filter;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Array.Partial"] = $PS["Data.Array.Partial"] || {};
  var exports = $PS["Data.Array.Partial"];
  var Data_Array = $PS["Data.Array"];                
  var tail = function (dictPartial) {
      return function (xs) {
          return Data_Array.slice(1)(Data_Array.length(xs))(xs);
      };
  };
  var last = function (dictPartial) {
      return function (xs) {
          return xs[Data_Array.length(xs) - 1 | 0];
      };
  };
  var init = function (dictPartial) {
      return function (xs) {
          return Data_Array.slice(0)(Data_Array.length(xs) - 1 | 0)(xs);
      };
  };
  var head = function (dictPartial) {
      return function (xs) {
          return xs[0];
      };
  };
  exports["head"] = head;
  exports["tail"] = tail;
  exports["last"] = last;
  exports["init"] = init;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Bifunctor"] = $PS["Data.Bifunctor"] || {};
  var exports = $PS["Data.Bifunctor"];
  var Control_Category = $PS["Control.Category"];
  var Data_Either = $PS["Data.Either"];
  var Data_Tuple = $PS["Data.Tuple"];                
  var Bifunctor = function (bimap) {
      this.bimap = bimap;
  };
  var bimap = function (dict) {
      return dict.bimap;
  };
  var lmap = function (dictBifunctor) {
      return function (f) {
          return bimap(dictBifunctor)(f)(Control_Category.identity(Control_Category.categoryFn));
      };
  };
  var bifunctorTuple = new Bifunctor(function (f) {
      return function (g) {
          return function (v) {
              return new Data_Tuple.Tuple(f(v.value0), g(v.value1));
          };
      };
  });
  var bifunctorEither = new Bifunctor(function (v) {
      return function (v1) {
          return function (v2) {
              if (v2 instanceof Data_Either.Left) {
                  return new Data_Either.Left(v(v2.value0));
              };
              if (v2 instanceof Data_Either.Right) {
                  return new Data_Either.Right(v1(v2.value0));
              };
              throw new Error("Failed pattern match at Data.Bifunctor (line 32, column 1 - line 34, column 36): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
          };
      };
  });
  exports["lmap"] = lmap;
  exports["bifunctorEither"] = bifunctorEither;
  exports["bifunctorTuple"] = bifunctorTuple;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Char"] = $PS["Data.Char"] || {};
  var exports = $PS["Data.Char"];
  var Data_Enum = $PS["Data.Enum"];                
  var toCharCode = Data_Enum.fromEnum(Data_Enum.boundedEnumChar);
  exports["toCharCode"] = toCharCode;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.CodePoint.Unicode.Internal"] = $PS["Data.CodePoint.Unicode.Internal"] || {};
  var exports = $PS["Data.CodePoint.Unicode.Internal"];
  var Data_Array = $PS["Data.Array"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Int = $PS["Data.Int"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ordering = $PS["Data.Ordering"];        
  var NUMCAT_LU = (function () {
      function NUMCAT_LU() {

      };
      NUMCAT_LU.value = new NUMCAT_LU();
      return NUMCAT_LU;
  })();
  var NUMCAT_LL = (function () {
      function NUMCAT_LL() {

      };
      NUMCAT_LL.value = new NUMCAT_LL();
      return NUMCAT_LL;
  })();
  var NUMCAT_LT = (function () {
      function NUMCAT_LT() {

      };
      NUMCAT_LT.value = new NUMCAT_LT();
      return NUMCAT_LT;
  })();
  var NUMCAT_LM = (function () {
      function NUMCAT_LM() {

      };
      NUMCAT_LM.value = new NUMCAT_LM();
      return NUMCAT_LM;
  })();
  var NUMCAT_LO = (function () {
      function NUMCAT_LO() {

      };
      NUMCAT_LO.value = new NUMCAT_LO();
      return NUMCAT_LO;
  })();
  var NUMCAT_MN = (function () {
      function NUMCAT_MN() {

      };
      NUMCAT_MN.value = new NUMCAT_MN();
      return NUMCAT_MN;
  })();
  var NUMCAT_MC = (function () {
      function NUMCAT_MC() {

      };
      NUMCAT_MC.value = new NUMCAT_MC();
      return NUMCAT_MC;
  })();
  var NUMCAT_ME = (function () {
      function NUMCAT_ME() {

      };
      NUMCAT_ME.value = new NUMCAT_ME();
      return NUMCAT_ME;
  })();
  var NUMCAT_ND = (function () {
      function NUMCAT_ND() {

      };
      NUMCAT_ND.value = new NUMCAT_ND();
      return NUMCAT_ND;
  })();
  var NUMCAT_NL = (function () {
      function NUMCAT_NL() {

      };
      NUMCAT_NL.value = new NUMCAT_NL();
      return NUMCAT_NL;
  })();
  var NUMCAT_NO = (function () {
      function NUMCAT_NO() {

      };
      NUMCAT_NO.value = new NUMCAT_NO();
      return NUMCAT_NO;
  })();
  var NUMCAT_PC = (function () {
      function NUMCAT_PC() {

      };
      NUMCAT_PC.value = new NUMCAT_PC();
      return NUMCAT_PC;
  })();
  var NUMCAT_PD = (function () {
      function NUMCAT_PD() {

      };
      NUMCAT_PD.value = new NUMCAT_PD();
      return NUMCAT_PD;
  })();
  var NUMCAT_PS = (function () {
      function NUMCAT_PS() {

      };
      NUMCAT_PS.value = new NUMCAT_PS();
      return NUMCAT_PS;
  })();
  var NUMCAT_PE = (function () {
      function NUMCAT_PE() {

      };
      NUMCAT_PE.value = new NUMCAT_PE();
      return NUMCAT_PE;
  })();
  var NUMCAT_PI = (function () {
      function NUMCAT_PI() {

      };
      NUMCAT_PI.value = new NUMCAT_PI();
      return NUMCAT_PI;
  })();
  var NUMCAT_PF = (function () {
      function NUMCAT_PF() {

      };
      NUMCAT_PF.value = new NUMCAT_PF();
      return NUMCAT_PF;
  })();
  var NUMCAT_PO = (function () {
      function NUMCAT_PO() {

      };
      NUMCAT_PO.value = new NUMCAT_PO();
      return NUMCAT_PO;
  })();
  var NUMCAT_SM = (function () {
      function NUMCAT_SM() {

      };
      NUMCAT_SM.value = new NUMCAT_SM();
      return NUMCAT_SM;
  })();
  var NUMCAT_SC = (function () {
      function NUMCAT_SC() {

      };
      NUMCAT_SC.value = new NUMCAT_SC();
      return NUMCAT_SC;
  })();
  var NUMCAT_SK = (function () {
      function NUMCAT_SK() {

      };
      NUMCAT_SK.value = new NUMCAT_SK();
      return NUMCAT_SK;
  })();
  var NUMCAT_SO = (function () {
      function NUMCAT_SO() {

      };
      NUMCAT_SO.value = new NUMCAT_SO();
      return NUMCAT_SO;
  })();
  var NUMCAT_ZS = (function () {
      function NUMCAT_ZS() {

      };
      NUMCAT_ZS.value = new NUMCAT_ZS();
      return NUMCAT_ZS;
  })();
  var NUMCAT_ZL = (function () {
      function NUMCAT_ZL() {

      };
      NUMCAT_ZL.value = new NUMCAT_ZL();
      return NUMCAT_ZL;
  })();
  var NUMCAT_ZP = (function () {
      function NUMCAT_ZP() {

      };
      NUMCAT_ZP.value = new NUMCAT_ZP();
      return NUMCAT_ZP;
  })();
  var NUMCAT_CC = (function () {
      function NUMCAT_CC() {

      };
      NUMCAT_CC.value = new NUMCAT_CC();
      return NUMCAT_CC;
  })();
  var NUMCAT_CF = (function () {
      function NUMCAT_CF() {

      };
      NUMCAT_CF.value = new NUMCAT_CF();
      return NUMCAT_CF;
  })();
  var NUMCAT_CS = (function () {
      function NUMCAT_CS() {

      };
      NUMCAT_CS.value = new NUMCAT_CS();
      return NUMCAT_CS;
  })();
  var NUMCAT_CO = (function () {
      function NUMCAT_CO() {

      };
      NUMCAT_CO.value = new NUMCAT_CO();
      return NUMCAT_CO;
  })();
  var NUMCAT_CN = (function () {
      function NUMCAT_CN() {

      };
      NUMCAT_CN.value = new NUMCAT_CN();
      return NUMCAT_CN;
  })();              
  var numLat1Blocks = 63;  
  var numBlocks = 3396;    
  var gencatZS = 2;
  var rule1 = {
      category: gencatZS,
      unicodeCat: NUMCAT_ZS.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };  
  var gencatZP = 67108864;
  var rule162 = {
      category: gencatZP,
      unicodeCat: NUMCAT_ZP.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatZL = 33554432;
  var rule161 = {
      category: gencatZL,
      unicodeCat: NUMCAT_ZL.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatSO = 8192;
  var rule13 = {
      category: gencatSO,
      unicodeCat: NUMCAT_SO.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var rule170 = {
      category: gencatSO,
      unicodeCat: NUMCAT_SO.value,
      possible: 1,
      updist: 0,
      lowdist: 26,
      titledist: 0
  };
  var rule171 = {
      category: gencatSO,
      unicodeCat: NUMCAT_SO.value,
      possible: 1,
      updist: -26 | 0,
      lowdist: 0,
      titledist: -26 | 0
  };
  var gencatSM = 64;
  var rule6 = {
      category: gencatSM,
      unicodeCat: NUMCAT_SM.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatSK = 1024;
  var rule10 = {
      category: gencatSK,
      unicodeCat: NUMCAT_SK.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatSC = 8;
  var rule3 = {
      category: gencatSC,
      unicodeCat: NUMCAT_SC.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatPS = 16;
  var rule4 = {
      category: gencatPS,
      unicodeCat: NUMCAT_PS.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatPO = 4;
  var rule2 = {
      category: gencatPO,
      unicodeCat: NUMCAT_PO.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatPI = 32768;
  var rule15 = {
      category: gencatPI,
      unicodeCat: NUMCAT_PI.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatPF = 262144;
  var rule19 = {
      category: gencatPF,
      unicodeCat: NUMCAT_PF.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatPE = 32;
  var rule5 = {
      category: gencatPE,
      unicodeCat: NUMCAT_PE.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatPD = 128;
  var rule7 = {
      category: gencatPD,
      unicodeCat: NUMCAT_PD.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatPC = 2048;
  var rule11 = {
      category: gencatPC,
      unicodeCat: NUMCAT_PC.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatNO = 131072;
  var rule17 = {
      category: gencatNO,
      unicodeCat: NUMCAT_NO.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatNL = 16777216;
  var rule128 = {
      category: gencatNL,
      unicodeCat: NUMCAT_NL.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var rule168 = {
      category: gencatNL,
      unicodeCat: NUMCAT_NL.value,
      possible: 1,
      updist: 0,
      lowdist: 16,
      titledist: 0
  };
  var rule169 = {
      category: gencatNL,
      unicodeCat: NUMCAT_NL.value,
      possible: 1,
      updist: -16 | 0,
      lowdist: 0,
      titledist: -16 | 0
  };
  var gencatND = 256;
  var rule8 = {
      category: gencatND,
      unicodeCat: NUMCAT_ND.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatMN = 2097152;
  var rule92 = {
      category: gencatMN,
      unicodeCat: NUMCAT_MN.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var rule93 = {
      category: gencatMN,
      unicodeCat: NUMCAT_MN.value,
      possible: 1,
      updist: 84,
      lowdist: 0,
      titledist: 84
  };
  var gencatME = 4194304;
  var rule119 = {
      category: gencatME,
      unicodeCat: NUMCAT_ME.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatMC = 8388608;
  var rule124 = {
      category: gencatMC,
      unicodeCat: NUMCAT_MC.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatLU = 512;
  var nullrule = {
      category: gencatLU,
      unicodeCat: NUMCAT_CN.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var rule104 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 8,
      titledist: 0
  };
  var rule107 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var rule115 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -60 | 0,
      titledist: 0
  };
  var rule117 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -7 | 0,
      titledist: 0
  };
  var rule118 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 80,
      titledist: 0
  };
  var rule120 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 15,
      titledist: 0
  };
  var rule122 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 48,
      titledist: 0
  };
  var rule125 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 7264,
      titledist: 0
  };
  var rule127 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 38864,
      titledist: 0
  };
  var rule137 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -3008 | 0,
      titledist: 0
  };
  var rule142 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -7615 | 0,
      titledist: 0
  };
  var rule144 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -8 | 0,
      titledist: 0
  };
  var rule153 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -74 | 0,
      titledist: 0
  };
  var rule156 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -86 | 0,
      titledist: 0
  };
  var rule157 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -100 | 0,
      titledist: 0
  };
  var rule158 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -112 | 0,
      titledist: 0
  };
  var rule159 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -128 | 0,
      titledist: 0
  };
  var rule160 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -126 | 0,
      titledist: 0
  };
  var rule163 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -7517 | 0,
      titledist: 0
  };
  var rule164 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -8383 | 0,
      titledist: 0
  };
  var rule165 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -8262 | 0,
      titledist: 0
  };
  var rule166 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 28,
      titledist: 0
  };
  var rule172 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -10743 | 0,
      titledist: 0
  };
  var rule173 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -3814 | 0,
      titledist: 0
  };
  var rule174 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -10727 | 0,
      titledist: 0
  };
  var rule177 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -10780 | 0,
      titledist: 0
  };
  var rule178 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -10749 | 0,
      titledist: 0
  };
  var rule179 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -10783 | 0,
      titledist: 0
  };
  var rule180 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -10782 | 0,
      titledist: 0
  };
  var rule181 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -10815 | 0,
      titledist: 0
  };
  var rule183 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -35332 | 0,
      titledist: 0
  };
  var rule184 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -42280 | 0,
      titledist: 0
  };
  var rule186 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -42308 | 0,
      titledist: 0
  };
  var rule187 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -42319 | 0,
      titledist: 0
  };
  var rule188 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -42315 | 0,
      titledist: 0
  };
  var rule189 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -42305 | 0,
      titledist: 0
  };
  var rule190 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -42258 | 0,
      titledist: 0
  };
  var rule191 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -42282 | 0,
      titledist: 0
  };
  var rule192 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -42261 | 0,
      titledist: 0
  };
  var rule193 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 928,
      titledist: 0
  };
  var rule194 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -48 | 0,
      titledist: 0
  };
  var rule195 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -42307 | 0,
      titledist: 0
  };
  var rule196 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -35384 | 0,
      titledist: 0
  };
  var rule201 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 40,
      titledist: 0
  };
  var rule203 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 34,
      titledist: 0
  };
  var rule22 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 1,
      titledist: 0
  };
  var rule24 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -199 | 0,
      titledist: 0
  };
  var rule26 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -121 | 0,
      titledist: 0
  };
  var rule29 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 210,
      titledist: 0
  };
  var rule30 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 206,
      titledist: 0
  };
  var rule31 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 205,
      titledist: 0
  };
  var rule32 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 79,
      titledist: 0
  };
  var rule33 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 202,
      titledist: 0
  };
  var rule34 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 203,
      titledist: 0
  };
  var rule35 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 207,
      titledist: 0
  };
  var rule37 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 211,
      titledist: 0
  };
  var rule38 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 209,
      titledist: 0
  };
  var rule40 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 213,
      titledist: 0
  };
  var rule42 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 214,
      titledist: 0
  };
  var rule43 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 218,
      titledist: 0
  };
  var rule44 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 217,
      titledist: 0
  };
  var rule45 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 219,
      titledist: 0
  };
  var rule47 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 2,
      titledist: 1
  };
  var rule51 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -97 | 0,
      titledist: 0
  };
  var rule52 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -56 | 0,
      titledist: 0
  };
  var rule53 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -130 | 0,
      titledist: 0
  };
  var rule54 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 10795,
      titledist: 0
  };
  var rule55 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -163 | 0,
      titledist: 0
  };
  var rule56 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 10792,
      titledist: 0
  };
  var rule58 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: -195 | 0,
      titledist: 0
  };
  var rule59 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 69,
      titledist: 0
  };
  var rule60 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 71,
      titledist: 0
  };
  var rule9 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 32,
      titledist: 0
  };
  var rule94 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 116,
      titledist: 0
  };
  var rule95 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 38,
      titledist: 0
  };
  var rule96 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 37,
      titledist: 0
  };
  var rule97 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 64,
      titledist: 0
  };
  var rule98 = {
      category: gencatLU,
      unicodeCat: NUMCAT_LU.value,
      possible: 1,
      updist: 0,
      lowdist: 63,
      titledist: 0
  };
  var gencatLT = 524288;
  var rule151 = {
      category: gencatLT,
      unicodeCat: NUMCAT_LT.value,
      possible: 1,
      updist: 0,
      lowdist: -8 | 0,
      titledist: 0
  };
  var rule154 = {
      category: gencatLT,
      unicodeCat: NUMCAT_LT.value,
      possible: 1,
      updist: 0,
      lowdist: -9 | 0,
      titledist: 0
  };
  var rule48 = {
      category: gencatLT,
      unicodeCat: NUMCAT_LT.value,
      possible: 1,
      updist: -1 | 0,
      lowdist: 1,
      titledist: 0
  };
  var gencatLO = 16384;
  var rule14 = {
      category: gencatLO,
      unicodeCat: NUMCAT_LO.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatLM = 1048576;
  var rule91 = {
      category: gencatLM,
      unicodeCat: NUMCAT_LM.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatLL = 4096;
  var rule100 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -37 | 0,
      lowdist: 0,
      titledist: -37 | 0
  };
  var rule101 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -31 | 0,
      lowdist: 0,
      titledist: -31 | 0
  };
  var rule102 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -64 | 0,
      lowdist: 0,
      titledist: -64 | 0
  };
  var rule103 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -63 | 0,
      lowdist: 0,
      titledist: -63 | 0
  };
  var rule105 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -62 | 0,
      lowdist: 0,
      titledist: -62 | 0
  };
  var rule106 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -57 | 0,
      lowdist: 0,
      titledist: -57 | 0
  };
  var rule108 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -47 | 0,
      lowdist: 0,
      titledist: -47 | 0
  };
  var rule109 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -54 | 0,
      lowdist: 0,
      titledist: -54 | 0
  };
  var rule110 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -8 | 0,
      lowdist: 0,
      titledist: -8 | 0
  };
  var rule111 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -86 | 0,
      lowdist: 0,
      titledist: -86 | 0
  };
  var rule112 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -80 | 0,
      lowdist: 0,
      titledist: -80 | 0
  };
  var rule113 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 7,
      lowdist: 0,
      titledist: 7
  };
  var rule114 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -116 | 0,
      lowdist: 0,
      titledist: -116 | 0
  };
  var rule116 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -96 | 0,
      lowdist: 0,
      titledist: -96 | 0
  };
  var rule12 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -32 | 0,
      lowdist: 0,
      titledist: -32 | 0
  };
  var rule121 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -15 | 0,
      lowdist: 0,
      titledist: -15 | 0
  };
  var rule123 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -48 | 0,
      lowdist: 0,
      titledist: -48 | 0
  };
  var rule126 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 3008,
      lowdist: 0,
      titledist: 0
  };
  var rule129 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -6254 | 0,
      lowdist: 0,
      titledist: -6254 | 0
  };
  var rule130 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -6253 | 0,
      lowdist: 0,
      titledist: -6253 | 0
  };
  var rule131 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -6244 | 0,
      lowdist: 0,
      titledist: -6244 | 0
  };
  var rule132 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -6242 | 0,
      lowdist: 0,
      titledist: -6242 | 0
  };
  var rule133 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -6243 | 0,
      lowdist: 0,
      titledist: -6243 | 0
  };
  var rule134 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -6236 | 0,
      lowdist: 0,
      titledist: -6236 | 0
  };
  var rule135 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -6181 | 0,
      lowdist: 0,
      titledist: -6181 | 0
  };
  var rule136 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 35266,
      lowdist: 0,
      titledist: 35266
  };
  var rule138 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 35332,
      lowdist: 0,
      titledist: 35332
  };
  var rule139 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 3814,
      lowdist: 0,
      titledist: 3814
  };
  var rule140 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 35384,
      lowdist: 0,
      titledist: 35384
  };
  var rule141 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -59 | 0,
      lowdist: 0,
      titledist: -59 | 0
  };
  var rule143 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 8,
      lowdist: 0,
      titledist: 8
  };
  var rule145 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 74,
      lowdist: 0,
      titledist: 74
  };
  var rule146 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 86,
      lowdist: 0,
      titledist: 86
  };
  var rule147 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 100,
      lowdist: 0,
      titledist: 100
  };
  var rule148 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 128,
      lowdist: 0,
      titledist: 128
  };
  var rule149 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 112,
      lowdist: 0,
      titledist: 112
  };
  var rule150 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 126,
      lowdist: 0,
      titledist: 126
  };
  var rule152 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 9,
      lowdist: 0,
      titledist: 9
  };
  var rule155 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -7205 | 0,
      lowdist: 0,
      titledist: -7205 | 0
  };
  var rule167 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -28 | 0,
      lowdist: 0,
      titledist: -28 | 0
  };
  var rule175 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -10795 | 0,
      lowdist: 0,
      titledist: -10795 | 0
  };
  var rule176 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -10792 | 0,
      lowdist: 0,
      titledist: -10792 | 0
  };
  var rule18 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 743,
      lowdist: 0,
      titledist: 743
  };
  var rule182 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -7264 | 0,
      lowdist: 0,
      titledist: -7264 | 0
  };
  var rule185 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 48,
      lowdist: 0,
      titledist: 48
  };
  var rule197 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -928 | 0,
      lowdist: 0,
      titledist: -928 | 0
  };
  var rule198 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -38864 | 0,
      lowdist: 0,
      titledist: -38864 | 0
  };
  var rule20 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var rule202 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -40 | 0,
      lowdist: 0,
      titledist: -40 | 0
  };
  var rule204 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -34 | 0,
      lowdist: 0,
      titledist: -34 | 0
  };
  var rule21 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 121,
      lowdist: 0,
      titledist: 121
  };
  var rule23 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -1 | 0,
      lowdist: 0,
      titledist: -1 | 0
  };
  var rule25 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -232 | 0,
      lowdist: 0,
      titledist: -232 | 0
  };
  var rule27 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -300 | 0,
      lowdist: 0,
      titledist: -300 | 0
  };
  var rule28 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 195,
      lowdist: 0,
      titledist: 195
  };
  var rule36 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 97,
      lowdist: 0,
      titledist: 97
  };
  var rule39 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 163,
      lowdist: 0,
      titledist: 163
  };
  var rule41 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 130,
      lowdist: 0,
      titledist: 130
  };
  var rule46 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 56,
      lowdist: 0,
      titledist: 56
  };
  var rule49 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -2 | 0,
      lowdist: 0,
      titledist: -1 | 0
  };
  var rule50 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -79 | 0,
      lowdist: 0,
      titledist: -79 | 0
  };
  var rule57 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 10815,
      lowdist: 0,
      titledist: 10815
  };
  var rule61 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 10783,
      lowdist: 0,
      titledist: 10783
  };
  var rule62 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 10780,
      lowdist: 0,
      titledist: 10780
  };
  var rule63 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 10782,
      lowdist: 0,
      titledist: 10782
  };
  var rule64 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -210 | 0,
      lowdist: 0,
      titledist: -210 | 0
  };
  var rule65 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -206 | 0,
      lowdist: 0,
      titledist: -206 | 0
  };
  var rule66 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -205 | 0,
      lowdist: 0,
      titledist: -205 | 0
  };
  var rule67 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -202 | 0,
      lowdist: 0,
      titledist: -202 | 0
  };
  var rule68 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -203 | 0,
      lowdist: 0,
      titledist: -203 | 0
  };
  var rule69 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 42319,
      lowdist: 0,
      titledist: 42319
  };
  var rule70 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 42315,
      lowdist: 0,
      titledist: 42315
  };
  var rule71 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -207 | 0,
      lowdist: 0,
      titledist: -207 | 0
  };
  var rule72 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 42280,
      lowdist: 0,
      titledist: 42280
  };
  var rule73 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 42308,
      lowdist: 0,
      titledist: 42308
  };
  var rule74 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -209 | 0,
      lowdist: 0,
      titledist: -209 | 0
  };
  var rule75 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -211 | 0,
      lowdist: 0,
      titledist: -211 | 0
  };
  var rule76 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 10743,
      lowdist: 0,
      titledist: 10743
  };
  var rule77 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 42305,
      lowdist: 0,
      titledist: 42305
  };
  var rule78 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 10749,
      lowdist: 0,
      titledist: 10749
  };
  var rule79 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -213 | 0,
      lowdist: 0,
      titledist: -213 | 0
  };
  var rule80 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -214 | 0,
      lowdist: 0,
      titledist: -214 | 0
  };
  var rule81 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 10727,
      lowdist: 0,
      titledist: 10727
  };
  var rule82 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -218 | 0,
      lowdist: 0,
      titledist: -218 | 0
  };
  var rule83 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 42307,
      lowdist: 0,
      titledist: 42307
  };
  var rule84 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 42282,
      lowdist: 0,
      titledist: 42282
  };
  var rule85 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -69 | 0,
      lowdist: 0,
      titledist: -69 | 0
  };
  var rule86 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -217 | 0,
      lowdist: 0,
      titledist: -217 | 0
  };
  var rule87 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -71 | 0,
      lowdist: 0,
      titledist: -71 | 0
  };
  var rule88 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -219 | 0,
      lowdist: 0,
      titledist: -219 | 0
  };
  var rule89 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 42261,
      lowdist: 0,
      titledist: 42261
  };
  var rule90 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: 42258,
      lowdist: 0,
      titledist: 42258
  };
  var rule99 = {
      category: gencatLL,
      unicodeCat: NUMCAT_LL.value,
      possible: 1,
      updist: -38 | 0,
      lowdist: 0,
      titledist: -38 | 0
  };
  var gencatCS = 134217728;
  var rule199 = {
      category: gencatCS,
      unicodeCat: NUMCAT_CS.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatCO = 268435456;
  var rule200 = {
      category: gencatCO,
      unicodeCat: NUMCAT_CO.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatCF = 65536;
  var rule16 = {
      category: gencatCF,
      unicodeCat: NUMCAT_CF.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };
  var gencatCC = 1;
  var rule0 = {
      category: gencatCC,
      unicodeCat: NUMCAT_CC.value,
      possible: 0,
      updist: 0,
      lowdist: 0,
      titledist: 0
  };  
  var bsearch = function (a) {
      return function (array) {
          return function (size) {
              return function (compare) {
                  var go = function ($copy_i) {
                      return function ($copy_k) {
                          var $tco_var_i = $copy_i;
                          var $tco_done = false;
                          var $tco_result;
                          function $tco_loop(i, k) {
                              if (i > k || i >= Data_Array.length(array)) {
                                  $tco_done = true;
                                  return Data_Maybe.Nothing.value;
                              };
                              if (Data_Boolean.otherwise) {
                                  var j = Data_Int.floor(Data_Int.toNumber(i + k | 0) / 2.0);
                                  var v = compare(a)(array[j]);
                                  if (v instanceof Data_Ordering.EQ) {
                                      $tco_done = true;
                                      return new Data_Maybe.Just(array[j]);
                                  };
                                  if (v instanceof Data_Ordering.GT) {
                                      $tco_var_i = j + 1 | 0;
                                      $copy_k = k;
                                      return;
                                  };
                                  $tco_var_i = i;
                                  $copy_k = j - 1 | 0;
                                  return;
                              };
                              throw new Error("Failed pattern match at Data.CodePoint.Unicode.Internal (line 5611, column 5 - line 5617, column 49): " + [ i.constructor.name, k.constructor.name ]);
                          };
                          while (!$tco_done) {
                              $tco_result = $tco_loop($tco_var_i, $copy_k);
                          };
                          return $tco_result;
                      };
                  };
                  return go(0)(size);
              };
          };
      };
  };
  var blkCmp = function (v) {
      return function (v1) {
          if (v.start >= v1.start && v.start < (v1.start + v1.length | 0)) {
              return Data_Ordering.EQ.value;
          };
          if (v.start > v1.start) {
              return Data_Ordering.GT.value;
          };
          if (Data_Boolean.otherwise) {
              return Data_Ordering.LT.value;
          };
          throw new Error("Failed pattern match at Data.CodePoint.Unicode.Internal (line 5588, column 1 - line 5588, column 45): " + [ v.constructor.name, v1.constructor.name ]);
      };
  };
  var getRule = function (blocks) {
      return function (unichar) {
          return function (size) {
              var key = {
                  start: unichar,
                  length: 1,
                  convRule: nullrule
              };
              var maybeCharBlock = bsearch(key)(blocks)(size)(blkCmp);
              if (maybeCharBlock instanceof Data_Maybe.Nothing) {
                  return Data_Maybe.Nothing.value;
              };
              if (maybeCharBlock instanceof Data_Maybe.Just) {
                  return new Data_Maybe.Just(maybeCharBlock.value0.convRule);
              };
              throw new Error("Failed pattern match at Data.CodePoint.Unicode.Internal (line 5601, column 8 - line 5603, column 62): " + [ maybeCharBlock.constructor.name ]);
          };
      };
  };                                       
  var allchars = [ {
      start: 0,
      length: 32,
      convRule: rule0
  }, {
      start: 32,
      length: 1,
      convRule: rule1
  }, {
      start: 33,
      length: 3,
      convRule: rule2
  }, {
      start: 36,
      length: 1,
      convRule: rule3
  }, {
      start: 37,
      length: 3,
      convRule: rule2
  }, {
      start: 40,
      length: 1,
      convRule: rule4
  }, {
      start: 41,
      length: 1,
      convRule: rule5
  }, {
      start: 42,
      length: 1,
      convRule: rule2
  }, {
      start: 43,
      length: 1,
      convRule: rule6
  }, {
      start: 44,
      length: 1,
      convRule: rule2
  }, {
      start: 45,
      length: 1,
      convRule: rule7
  }, {
      start: 46,
      length: 2,
      convRule: rule2
  }, {
      start: 48,
      length: 10,
      convRule: rule8
  }, {
      start: 58,
      length: 2,
      convRule: rule2
  }, {
      start: 60,
      length: 3,
      convRule: rule6
  }, {
      start: 63,
      length: 2,
      convRule: rule2
  }, {
      start: 65,
      length: 26,
      convRule: rule9
  }, {
      start: 91,
      length: 1,
      convRule: rule4
  }, {
      start: 92,
      length: 1,
      convRule: rule2
  }, {
      start: 93,
      length: 1,
      convRule: rule5
  }, {
      start: 94,
      length: 1,
      convRule: rule10
  }, {
      start: 95,
      length: 1,
      convRule: rule11
  }, {
      start: 96,
      length: 1,
      convRule: rule10
  }, {
      start: 97,
      length: 26,
      convRule: rule12
  }, {
      start: 123,
      length: 1,
      convRule: rule4
  }, {
      start: 124,
      length: 1,
      convRule: rule6
  }, {
      start: 125,
      length: 1,
      convRule: rule5
  }, {
      start: 126,
      length: 1,
      convRule: rule6
  }, {
      start: 127,
      length: 33,
      convRule: rule0
  }, {
      start: 160,
      length: 1,
      convRule: rule1
  }, {
      start: 161,
      length: 1,
      convRule: rule2
  }, {
      start: 162,
      length: 4,
      convRule: rule3
  }, {
      start: 166,
      length: 1,
      convRule: rule13
  }, {
      start: 167,
      length: 1,
      convRule: rule2
  }, {
      start: 168,
      length: 1,
      convRule: rule10
  }, {
      start: 169,
      length: 1,
      convRule: rule13
  }, {
      start: 170,
      length: 1,
      convRule: rule14
  }, {
      start: 171,
      length: 1,
      convRule: rule15
  }, {
      start: 172,
      length: 1,
      convRule: rule6
  }, {
      start: 173,
      length: 1,
      convRule: rule16
  }, {
      start: 174,
      length: 1,
      convRule: rule13
  }, {
      start: 175,
      length: 1,
      convRule: rule10
  }, {
      start: 176,
      length: 1,
      convRule: rule13
  }, {
      start: 177,
      length: 1,
      convRule: rule6
  }, {
      start: 178,
      length: 2,
      convRule: rule17
  }, {
      start: 180,
      length: 1,
      convRule: rule10
  }, {
      start: 181,
      length: 1,
      convRule: rule18
  }, {
      start: 182,
      length: 2,
      convRule: rule2
  }, {
      start: 184,
      length: 1,
      convRule: rule10
  }, {
      start: 185,
      length: 1,
      convRule: rule17
  }, {
      start: 186,
      length: 1,
      convRule: rule14
  }, {
      start: 187,
      length: 1,
      convRule: rule19
  }, {
      start: 188,
      length: 3,
      convRule: rule17
  }, {
      start: 191,
      length: 1,
      convRule: rule2
  }, {
      start: 192,
      length: 23,
      convRule: rule9
  }, {
      start: 215,
      length: 1,
      convRule: rule6
  }, {
      start: 216,
      length: 7,
      convRule: rule9
  }, {
      start: 223,
      length: 1,
      convRule: rule20
  }, {
      start: 224,
      length: 23,
      convRule: rule12
  }, {
      start: 247,
      length: 1,
      convRule: rule6
  }, {
      start: 248,
      length: 7,
      convRule: rule12
  }, {
      start: 255,
      length: 1,
      convRule: rule21
  }, {
      start: 256,
      length: 1,
      convRule: rule22
  }, {
      start: 257,
      length: 1,
      convRule: rule23
  }, {
      start: 258,
      length: 1,
      convRule: rule22
  }, {
      start: 259,
      length: 1,
      convRule: rule23
  }, {
      start: 260,
      length: 1,
      convRule: rule22
  }, {
      start: 261,
      length: 1,
      convRule: rule23
  }, {
      start: 262,
      length: 1,
      convRule: rule22
  }, {
      start: 263,
      length: 1,
      convRule: rule23
  }, {
      start: 264,
      length: 1,
      convRule: rule22
  }, {
      start: 265,
      length: 1,
      convRule: rule23
  }, {
      start: 266,
      length: 1,
      convRule: rule22
  }, {
      start: 267,
      length: 1,
      convRule: rule23
  }, {
      start: 268,
      length: 1,
      convRule: rule22
  }, {
      start: 269,
      length: 1,
      convRule: rule23
  }, {
      start: 270,
      length: 1,
      convRule: rule22
  }, {
      start: 271,
      length: 1,
      convRule: rule23
  }, {
      start: 272,
      length: 1,
      convRule: rule22
  }, {
      start: 273,
      length: 1,
      convRule: rule23
  }, {
      start: 274,
      length: 1,
      convRule: rule22
  }, {
      start: 275,
      length: 1,
      convRule: rule23
  }, {
      start: 276,
      length: 1,
      convRule: rule22
  }, {
      start: 277,
      length: 1,
      convRule: rule23
  }, {
      start: 278,
      length: 1,
      convRule: rule22
  }, {
      start: 279,
      length: 1,
      convRule: rule23
  }, {
      start: 280,
      length: 1,
      convRule: rule22
  }, {
      start: 281,
      length: 1,
      convRule: rule23
  }, {
      start: 282,
      length: 1,
      convRule: rule22
  }, {
      start: 283,
      length: 1,
      convRule: rule23
  }, {
      start: 284,
      length: 1,
      convRule: rule22
  }, {
      start: 285,
      length: 1,
      convRule: rule23
  }, {
      start: 286,
      length: 1,
      convRule: rule22
  }, {
      start: 287,
      length: 1,
      convRule: rule23
  }, {
      start: 288,
      length: 1,
      convRule: rule22
  }, {
      start: 289,
      length: 1,
      convRule: rule23
  }, {
      start: 290,
      length: 1,
      convRule: rule22
  }, {
      start: 291,
      length: 1,
      convRule: rule23
  }, {
      start: 292,
      length: 1,
      convRule: rule22
  }, {
      start: 293,
      length: 1,
      convRule: rule23
  }, {
      start: 294,
      length: 1,
      convRule: rule22
  }, {
      start: 295,
      length: 1,
      convRule: rule23
  }, {
      start: 296,
      length: 1,
      convRule: rule22
  }, {
      start: 297,
      length: 1,
      convRule: rule23
  }, {
      start: 298,
      length: 1,
      convRule: rule22
  }, {
      start: 299,
      length: 1,
      convRule: rule23
  }, {
      start: 300,
      length: 1,
      convRule: rule22
  }, {
      start: 301,
      length: 1,
      convRule: rule23
  }, {
      start: 302,
      length: 1,
      convRule: rule22
  }, {
      start: 303,
      length: 1,
      convRule: rule23
  }, {
      start: 304,
      length: 1,
      convRule: rule24
  }, {
      start: 305,
      length: 1,
      convRule: rule25
  }, {
      start: 306,
      length: 1,
      convRule: rule22
  }, {
      start: 307,
      length: 1,
      convRule: rule23
  }, {
      start: 308,
      length: 1,
      convRule: rule22
  }, {
      start: 309,
      length: 1,
      convRule: rule23
  }, {
      start: 310,
      length: 1,
      convRule: rule22
  }, {
      start: 311,
      length: 1,
      convRule: rule23
  }, {
      start: 312,
      length: 1,
      convRule: rule20
  }, {
      start: 313,
      length: 1,
      convRule: rule22
  }, {
      start: 314,
      length: 1,
      convRule: rule23
  }, {
      start: 315,
      length: 1,
      convRule: rule22
  }, {
      start: 316,
      length: 1,
      convRule: rule23
  }, {
      start: 317,
      length: 1,
      convRule: rule22
  }, {
      start: 318,
      length: 1,
      convRule: rule23
  }, {
      start: 319,
      length: 1,
      convRule: rule22
  }, {
      start: 320,
      length: 1,
      convRule: rule23
  }, {
      start: 321,
      length: 1,
      convRule: rule22
  }, {
      start: 322,
      length: 1,
      convRule: rule23
  }, {
      start: 323,
      length: 1,
      convRule: rule22
  }, {
      start: 324,
      length: 1,
      convRule: rule23
  }, {
      start: 325,
      length: 1,
      convRule: rule22
  }, {
      start: 326,
      length: 1,
      convRule: rule23
  }, {
      start: 327,
      length: 1,
      convRule: rule22
  }, {
      start: 328,
      length: 1,
      convRule: rule23
  }, {
      start: 329,
      length: 1,
      convRule: rule20
  }, {
      start: 330,
      length: 1,
      convRule: rule22
  }, {
      start: 331,
      length: 1,
      convRule: rule23
  }, {
      start: 332,
      length: 1,
      convRule: rule22
  }, {
      start: 333,
      length: 1,
      convRule: rule23
  }, {
      start: 334,
      length: 1,
      convRule: rule22
  }, {
      start: 335,
      length: 1,
      convRule: rule23
  }, {
      start: 336,
      length: 1,
      convRule: rule22
  }, {
      start: 337,
      length: 1,
      convRule: rule23
  }, {
      start: 338,
      length: 1,
      convRule: rule22
  }, {
      start: 339,
      length: 1,
      convRule: rule23
  }, {
      start: 340,
      length: 1,
      convRule: rule22
  }, {
      start: 341,
      length: 1,
      convRule: rule23
  }, {
      start: 342,
      length: 1,
      convRule: rule22
  }, {
      start: 343,
      length: 1,
      convRule: rule23
  }, {
      start: 344,
      length: 1,
      convRule: rule22
  }, {
      start: 345,
      length: 1,
      convRule: rule23
  }, {
      start: 346,
      length: 1,
      convRule: rule22
  }, {
      start: 347,
      length: 1,
      convRule: rule23
  }, {
      start: 348,
      length: 1,
      convRule: rule22
  }, {
      start: 349,
      length: 1,
      convRule: rule23
  }, {
      start: 350,
      length: 1,
      convRule: rule22
  }, {
      start: 351,
      length: 1,
      convRule: rule23
  }, {
      start: 352,
      length: 1,
      convRule: rule22
  }, {
      start: 353,
      length: 1,
      convRule: rule23
  }, {
      start: 354,
      length: 1,
      convRule: rule22
  }, {
      start: 355,
      length: 1,
      convRule: rule23
  }, {
      start: 356,
      length: 1,
      convRule: rule22
  }, {
      start: 357,
      length: 1,
      convRule: rule23
  }, {
      start: 358,
      length: 1,
      convRule: rule22
  }, {
      start: 359,
      length: 1,
      convRule: rule23
  }, {
      start: 360,
      length: 1,
      convRule: rule22
  }, {
      start: 361,
      length: 1,
      convRule: rule23
  }, {
      start: 362,
      length: 1,
      convRule: rule22
  }, {
      start: 363,
      length: 1,
      convRule: rule23
  }, {
      start: 364,
      length: 1,
      convRule: rule22
  }, {
      start: 365,
      length: 1,
      convRule: rule23
  }, {
      start: 366,
      length: 1,
      convRule: rule22
  }, {
      start: 367,
      length: 1,
      convRule: rule23
  }, {
      start: 368,
      length: 1,
      convRule: rule22
  }, {
      start: 369,
      length: 1,
      convRule: rule23
  }, {
      start: 370,
      length: 1,
      convRule: rule22
  }, {
      start: 371,
      length: 1,
      convRule: rule23
  }, {
      start: 372,
      length: 1,
      convRule: rule22
  }, {
      start: 373,
      length: 1,
      convRule: rule23
  }, {
      start: 374,
      length: 1,
      convRule: rule22
  }, {
      start: 375,
      length: 1,
      convRule: rule23
  }, {
      start: 376,
      length: 1,
      convRule: rule26
  }, {
      start: 377,
      length: 1,
      convRule: rule22
  }, {
      start: 378,
      length: 1,
      convRule: rule23
  }, {
      start: 379,
      length: 1,
      convRule: rule22
  }, {
      start: 380,
      length: 1,
      convRule: rule23
  }, {
      start: 381,
      length: 1,
      convRule: rule22
  }, {
      start: 382,
      length: 1,
      convRule: rule23
  }, {
      start: 383,
      length: 1,
      convRule: rule27
  }, {
      start: 384,
      length: 1,
      convRule: rule28
  }, {
      start: 385,
      length: 1,
      convRule: rule29
  }, {
      start: 386,
      length: 1,
      convRule: rule22
  }, {
      start: 387,
      length: 1,
      convRule: rule23
  }, {
      start: 388,
      length: 1,
      convRule: rule22
  }, {
      start: 389,
      length: 1,
      convRule: rule23
  }, {
      start: 390,
      length: 1,
      convRule: rule30
  }, {
      start: 391,
      length: 1,
      convRule: rule22
  }, {
      start: 392,
      length: 1,
      convRule: rule23
  }, {
      start: 393,
      length: 2,
      convRule: rule31
  }, {
      start: 395,
      length: 1,
      convRule: rule22
  }, {
      start: 396,
      length: 1,
      convRule: rule23
  }, {
      start: 397,
      length: 1,
      convRule: rule20
  }, {
      start: 398,
      length: 1,
      convRule: rule32
  }, {
      start: 399,
      length: 1,
      convRule: rule33
  }, {
      start: 400,
      length: 1,
      convRule: rule34
  }, {
      start: 401,
      length: 1,
      convRule: rule22
  }, {
      start: 402,
      length: 1,
      convRule: rule23
  }, {
      start: 403,
      length: 1,
      convRule: rule31
  }, {
      start: 404,
      length: 1,
      convRule: rule35
  }, {
      start: 405,
      length: 1,
      convRule: rule36
  }, {
      start: 406,
      length: 1,
      convRule: rule37
  }, {
      start: 407,
      length: 1,
      convRule: rule38
  }, {
      start: 408,
      length: 1,
      convRule: rule22
  }, {
      start: 409,
      length: 1,
      convRule: rule23
  }, {
      start: 410,
      length: 1,
      convRule: rule39
  }, {
      start: 411,
      length: 1,
      convRule: rule20
  }, {
      start: 412,
      length: 1,
      convRule: rule37
  }, {
      start: 413,
      length: 1,
      convRule: rule40
  }, {
      start: 414,
      length: 1,
      convRule: rule41
  }, {
      start: 415,
      length: 1,
      convRule: rule42
  }, {
      start: 416,
      length: 1,
      convRule: rule22
  }, {
      start: 417,
      length: 1,
      convRule: rule23
  }, {
      start: 418,
      length: 1,
      convRule: rule22
  }, {
      start: 419,
      length: 1,
      convRule: rule23
  }, {
      start: 420,
      length: 1,
      convRule: rule22
  }, {
      start: 421,
      length: 1,
      convRule: rule23
  }, {
      start: 422,
      length: 1,
      convRule: rule43
  }, {
      start: 423,
      length: 1,
      convRule: rule22
  }, {
      start: 424,
      length: 1,
      convRule: rule23
  }, {
      start: 425,
      length: 1,
      convRule: rule43
  }, {
      start: 426,
      length: 2,
      convRule: rule20
  }, {
      start: 428,
      length: 1,
      convRule: rule22
  }, {
      start: 429,
      length: 1,
      convRule: rule23
  }, {
      start: 430,
      length: 1,
      convRule: rule43
  }, {
      start: 431,
      length: 1,
      convRule: rule22
  }, {
      start: 432,
      length: 1,
      convRule: rule23
  }, {
      start: 433,
      length: 2,
      convRule: rule44
  }, {
      start: 435,
      length: 1,
      convRule: rule22
  }, {
      start: 436,
      length: 1,
      convRule: rule23
  }, {
      start: 437,
      length: 1,
      convRule: rule22
  }, {
      start: 438,
      length: 1,
      convRule: rule23
  }, {
      start: 439,
      length: 1,
      convRule: rule45
  }, {
      start: 440,
      length: 1,
      convRule: rule22
  }, {
      start: 441,
      length: 1,
      convRule: rule23
  }, {
      start: 442,
      length: 1,
      convRule: rule20
  }, {
      start: 443,
      length: 1,
      convRule: rule14
  }, {
      start: 444,
      length: 1,
      convRule: rule22
  }, {
      start: 445,
      length: 1,
      convRule: rule23
  }, {
      start: 446,
      length: 1,
      convRule: rule20
  }, {
      start: 447,
      length: 1,
      convRule: rule46
  }, {
      start: 448,
      length: 4,
      convRule: rule14
  }, {
      start: 452,
      length: 1,
      convRule: rule47
  }, {
      start: 453,
      length: 1,
      convRule: rule48
  }, {
      start: 454,
      length: 1,
      convRule: rule49
  }, {
      start: 455,
      length: 1,
      convRule: rule47
  }, {
      start: 456,
      length: 1,
      convRule: rule48
  }, {
      start: 457,
      length: 1,
      convRule: rule49
  }, {
      start: 458,
      length: 1,
      convRule: rule47
  }, {
      start: 459,
      length: 1,
      convRule: rule48
  }, {
      start: 460,
      length: 1,
      convRule: rule49
  }, {
      start: 461,
      length: 1,
      convRule: rule22
  }, {
      start: 462,
      length: 1,
      convRule: rule23
  }, {
      start: 463,
      length: 1,
      convRule: rule22
  }, {
      start: 464,
      length: 1,
      convRule: rule23
  }, {
      start: 465,
      length: 1,
      convRule: rule22
  }, {
      start: 466,
      length: 1,
      convRule: rule23
  }, {
      start: 467,
      length: 1,
      convRule: rule22
  }, {
      start: 468,
      length: 1,
      convRule: rule23
  }, {
      start: 469,
      length: 1,
      convRule: rule22
  }, {
      start: 470,
      length: 1,
      convRule: rule23
  }, {
      start: 471,
      length: 1,
      convRule: rule22
  }, {
      start: 472,
      length: 1,
      convRule: rule23
  }, {
      start: 473,
      length: 1,
      convRule: rule22
  }, {
      start: 474,
      length: 1,
      convRule: rule23
  }, {
      start: 475,
      length: 1,
      convRule: rule22
  }, {
      start: 476,
      length: 1,
      convRule: rule23
  }, {
      start: 477,
      length: 1,
      convRule: rule50
  }, {
      start: 478,
      length: 1,
      convRule: rule22
  }, {
      start: 479,
      length: 1,
      convRule: rule23
  }, {
      start: 480,
      length: 1,
      convRule: rule22
  }, {
      start: 481,
      length: 1,
      convRule: rule23
  }, {
      start: 482,
      length: 1,
      convRule: rule22
  }, {
      start: 483,
      length: 1,
      convRule: rule23
  }, {
      start: 484,
      length: 1,
      convRule: rule22
  }, {
      start: 485,
      length: 1,
      convRule: rule23
  }, {
      start: 486,
      length: 1,
      convRule: rule22
  }, {
      start: 487,
      length: 1,
      convRule: rule23
  }, {
      start: 488,
      length: 1,
      convRule: rule22
  }, {
      start: 489,
      length: 1,
      convRule: rule23
  }, {
      start: 490,
      length: 1,
      convRule: rule22
  }, {
      start: 491,
      length: 1,
      convRule: rule23
  }, {
      start: 492,
      length: 1,
      convRule: rule22
  }, {
      start: 493,
      length: 1,
      convRule: rule23
  }, {
      start: 494,
      length: 1,
      convRule: rule22
  }, {
      start: 495,
      length: 1,
      convRule: rule23
  }, {
      start: 496,
      length: 1,
      convRule: rule20
  }, {
      start: 497,
      length: 1,
      convRule: rule47
  }, {
      start: 498,
      length: 1,
      convRule: rule48
  }, {
      start: 499,
      length: 1,
      convRule: rule49
  }, {
      start: 500,
      length: 1,
      convRule: rule22
  }, {
      start: 501,
      length: 1,
      convRule: rule23
  }, {
      start: 502,
      length: 1,
      convRule: rule51
  }, {
      start: 503,
      length: 1,
      convRule: rule52
  }, {
      start: 504,
      length: 1,
      convRule: rule22
  }, {
      start: 505,
      length: 1,
      convRule: rule23
  }, {
      start: 506,
      length: 1,
      convRule: rule22
  }, {
      start: 507,
      length: 1,
      convRule: rule23
  }, {
      start: 508,
      length: 1,
      convRule: rule22
  }, {
      start: 509,
      length: 1,
      convRule: rule23
  }, {
      start: 510,
      length: 1,
      convRule: rule22
  }, {
      start: 511,
      length: 1,
      convRule: rule23
  }, {
      start: 512,
      length: 1,
      convRule: rule22
  }, {
      start: 513,
      length: 1,
      convRule: rule23
  }, {
      start: 514,
      length: 1,
      convRule: rule22
  }, {
      start: 515,
      length: 1,
      convRule: rule23
  }, {
      start: 516,
      length: 1,
      convRule: rule22
  }, {
      start: 517,
      length: 1,
      convRule: rule23
  }, {
      start: 518,
      length: 1,
      convRule: rule22
  }, {
      start: 519,
      length: 1,
      convRule: rule23
  }, {
      start: 520,
      length: 1,
      convRule: rule22
  }, {
      start: 521,
      length: 1,
      convRule: rule23
  }, {
      start: 522,
      length: 1,
      convRule: rule22
  }, {
      start: 523,
      length: 1,
      convRule: rule23
  }, {
      start: 524,
      length: 1,
      convRule: rule22
  }, {
      start: 525,
      length: 1,
      convRule: rule23
  }, {
      start: 526,
      length: 1,
      convRule: rule22
  }, {
      start: 527,
      length: 1,
      convRule: rule23
  }, {
      start: 528,
      length: 1,
      convRule: rule22
  }, {
      start: 529,
      length: 1,
      convRule: rule23
  }, {
      start: 530,
      length: 1,
      convRule: rule22
  }, {
      start: 531,
      length: 1,
      convRule: rule23
  }, {
      start: 532,
      length: 1,
      convRule: rule22
  }, {
      start: 533,
      length: 1,
      convRule: rule23
  }, {
      start: 534,
      length: 1,
      convRule: rule22
  }, {
      start: 535,
      length: 1,
      convRule: rule23
  }, {
      start: 536,
      length: 1,
      convRule: rule22
  }, {
      start: 537,
      length: 1,
      convRule: rule23
  }, {
      start: 538,
      length: 1,
      convRule: rule22
  }, {
      start: 539,
      length: 1,
      convRule: rule23
  }, {
      start: 540,
      length: 1,
      convRule: rule22
  }, {
      start: 541,
      length: 1,
      convRule: rule23
  }, {
      start: 542,
      length: 1,
      convRule: rule22
  }, {
      start: 543,
      length: 1,
      convRule: rule23
  }, {
      start: 544,
      length: 1,
      convRule: rule53
  }, {
      start: 545,
      length: 1,
      convRule: rule20
  }, {
      start: 546,
      length: 1,
      convRule: rule22
  }, {
      start: 547,
      length: 1,
      convRule: rule23
  }, {
      start: 548,
      length: 1,
      convRule: rule22
  }, {
      start: 549,
      length: 1,
      convRule: rule23
  }, {
      start: 550,
      length: 1,
      convRule: rule22
  }, {
      start: 551,
      length: 1,
      convRule: rule23
  }, {
      start: 552,
      length: 1,
      convRule: rule22
  }, {
      start: 553,
      length: 1,
      convRule: rule23
  }, {
      start: 554,
      length: 1,
      convRule: rule22
  }, {
      start: 555,
      length: 1,
      convRule: rule23
  }, {
      start: 556,
      length: 1,
      convRule: rule22
  }, {
      start: 557,
      length: 1,
      convRule: rule23
  }, {
      start: 558,
      length: 1,
      convRule: rule22
  }, {
      start: 559,
      length: 1,
      convRule: rule23
  }, {
      start: 560,
      length: 1,
      convRule: rule22
  }, {
      start: 561,
      length: 1,
      convRule: rule23
  }, {
      start: 562,
      length: 1,
      convRule: rule22
  }, {
      start: 563,
      length: 1,
      convRule: rule23
  }, {
      start: 564,
      length: 6,
      convRule: rule20
  }, {
      start: 570,
      length: 1,
      convRule: rule54
  }, {
      start: 571,
      length: 1,
      convRule: rule22
  }, {
      start: 572,
      length: 1,
      convRule: rule23
  }, {
      start: 573,
      length: 1,
      convRule: rule55
  }, {
      start: 574,
      length: 1,
      convRule: rule56
  }, {
      start: 575,
      length: 2,
      convRule: rule57
  }, {
      start: 577,
      length: 1,
      convRule: rule22
  }, {
      start: 578,
      length: 1,
      convRule: rule23
  }, {
      start: 579,
      length: 1,
      convRule: rule58
  }, {
      start: 580,
      length: 1,
      convRule: rule59
  }, {
      start: 581,
      length: 1,
      convRule: rule60
  }, {
      start: 582,
      length: 1,
      convRule: rule22
  }, {
      start: 583,
      length: 1,
      convRule: rule23
  }, {
      start: 584,
      length: 1,
      convRule: rule22
  }, {
      start: 585,
      length: 1,
      convRule: rule23
  }, {
      start: 586,
      length: 1,
      convRule: rule22
  }, {
      start: 587,
      length: 1,
      convRule: rule23
  }, {
      start: 588,
      length: 1,
      convRule: rule22
  }, {
      start: 589,
      length: 1,
      convRule: rule23
  }, {
      start: 590,
      length: 1,
      convRule: rule22
  }, {
      start: 591,
      length: 1,
      convRule: rule23
  }, {
      start: 592,
      length: 1,
      convRule: rule61
  }, {
      start: 593,
      length: 1,
      convRule: rule62
  }, {
      start: 594,
      length: 1,
      convRule: rule63
  }, {
      start: 595,
      length: 1,
      convRule: rule64
  }, {
      start: 596,
      length: 1,
      convRule: rule65
  }, {
      start: 597,
      length: 1,
      convRule: rule20
  }, {
      start: 598,
      length: 2,
      convRule: rule66
  }, {
      start: 600,
      length: 1,
      convRule: rule20
  }, {
      start: 601,
      length: 1,
      convRule: rule67
  }, {
      start: 602,
      length: 1,
      convRule: rule20
  }, {
      start: 603,
      length: 1,
      convRule: rule68
  }, {
      start: 604,
      length: 1,
      convRule: rule69
  }, {
      start: 605,
      length: 3,
      convRule: rule20
  }, {
      start: 608,
      length: 1,
      convRule: rule66
  }, {
      start: 609,
      length: 1,
      convRule: rule70
  }, {
      start: 610,
      length: 1,
      convRule: rule20
  }, {
      start: 611,
      length: 1,
      convRule: rule71
  }, {
      start: 612,
      length: 1,
      convRule: rule20
  }, {
      start: 613,
      length: 1,
      convRule: rule72
  }, {
      start: 614,
      length: 1,
      convRule: rule73
  }, {
      start: 615,
      length: 1,
      convRule: rule20
  }, {
      start: 616,
      length: 1,
      convRule: rule74
  }, {
      start: 617,
      length: 1,
      convRule: rule75
  }, {
      start: 618,
      length: 1,
      convRule: rule73
  }, {
      start: 619,
      length: 1,
      convRule: rule76
  }, {
      start: 620,
      length: 1,
      convRule: rule77
  }, {
      start: 621,
      length: 2,
      convRule: rule20
  }, {
      start: 623,
      length: 1,
      convRule: rule75
  }, {
      start: 624,
      length: 1,
      convRule: rule20
  }, {
      start: 625,
      length: 1,
      convRule: rule78
  }, {
      start: 626,
      length: 1,
      convRule: rule79
  }, {
      start: 627,
      length: 2,
      convRule: rule20
  }, {
      start: 629,
      length: 1,
      convRule: rule80
  }, {
      start: 630,
      length: 7,
      convRule: rule20
  }, {
      start: 637,
      length: 1,
      convRule: rule81
  }, {
      start: 638,
      length: 2,
      convRule: rule20
  }, {
      start: 640,
      length: 1,
      convRule: rule82
  }, {
      start: 641,
      length: 1,
      convRule: rule20
  }, {
      start: 642,
      length: 1,
      convRule: rule83
  }, {
      start: 643,
      length: 1,
      convRule: rule82
  }, {
      start: 644,
      length: 3,
      convRule: rule20
  }, {
      start: 647,
      length: 1,
      convRule: rule84
  }, {
      start: 648,
      length: 1,
      convRule: rule82
  }, {
      start: 649,
      length: 1,
      convRule: rule85
  }, {
      start: 650,
      length: 2,
      convRule: rule86
  }, {
      start: 652,
      length: 1,
      convRule: rule87
  }, {
      start: 653,
      length: 5,
      convRule: rule20
  }, {
      start: 658,
      length: 1,
      convRule: rule88
  }, {
      start: 659,
      length: 1,
      convRule: rule20
  }, {
      start: 660,
      length: 1,
      convRule: rule14
  }, {
      start: 661,
      length: 8,
      convRule: rule20
  }, {
      start: 669,
      length: 1,
      convRule: rule89
  }, {
      start: 670,
      length: 1,
      convRule: rule90
  }, {
      start: 671,
      length: 17,
      convRule: rule20
  }, {
      start: 688,
      length: 18,
      convRule: rule91
  }, {
      start: 706,
      length: 4,
      convRule: rule10
  }, {
      start: 710,
      length: 12,
      convRule: rule91
  }, {
      start: 722,
      length: 14,
      convRule: rule10
  }, {
      start: 736,
      length: 5,
      convRule: rule91
  }, {
      start: 741,
      length: 7,
      convRule: rule10
  }, {
      start: 748,
      length: 1,
      convRule: rule91
  }, {
      start: 749,
      length: 1,
      convRule: rule10
  }, {
      start: 750,
      length: 1,
      convRule: rule91
  }, {
      start: 751,
      length: 17,
      convRule: rule10
  }, {
      start: 768,
      length: 69,
      convRule: rule92
  }, {
      start: 837,
      length: 1,
      convRule: rule93
  }, {
      start: 838,
      length: 42,
      convRule: rule92
  }, {
      start: 880,
      length: 1,
      convRule: rule22
  }, {
      start: 881,
      length: 1,
      convRule: rule23
  }, {
      start: 882,
      length: 1,
      convRule: rule22
  }, {
      start: 883,
      length: 1,
      convRule: rule23
  }, {
      start: 884,
      length: 1,
      convRule: rule91
  }, {
      start: 885,
      length: 1,
      convRule: rule10
  }, {
      start: 886,
      length: 1,
      convRule: rule22
  }, {
      start: 887,
      length: 1,
      convRule: rule23
  }, {
      start: 890,
      length: 1,
      convRule: rule91
  }, {
      start: 891,
      length: 3,
      convRule: rule41
  }, {
      start: 894,
      length: 1,
      convRule: rule2
  }, {
      start: 895,
      length: 1,
      convRule: rule94
  }, {
      start: 900,
      length: 2,
      convRule: rule10
  }, {
      start: 902,
      length: 1,
      convRule: rule95
  }, {
      start: 903,
      length: 1,
      convRule: rule2
  }, {
      start: 904,
      length: 3,
      convRule: rule96
  }, {
      start: 908,
      length: 1,
      convRule: rule97
  }, {
      start: 910,
      length: 2,
      convRule: rule98
  }, {
      start: 912,
      length: 1,
      convRule: rule20
  }, {
      start: 913,
      length: 17,
      convRule: rule9
  }, {
      start: 931,
      length: 9,
      convRule: rule9
  }, {
      start: 940,
      length: 1,
      convRule: rule99
  }, {
      start: 941,
      length: 3,
      convRule: rule100
  }, {
      start: 944,
      length: 1,
      convRule: rule20
  }, {
      start: 945,
      length: 17,
      convRule: rule12
  }, {
      start: 962,
      length: 1,
      convRule: rule101
  }, {
      start: 963,
      length: 9,
      convRule: rule12
  }, {
      start: 972,
      length: 1,
      convRule: rule102
  }, {
      start: 973,
      length: 2,
      convRule: rule103
  }, {
      start: 975,
      length: 1,
      convRule: rule104
  }, {
      start: 976,
      length: 1,
      convRule: rule105
  }, {
      start: 977,
      length: 1,
      convRule: rule106
  }, {
      start: 978,
      length: 3,
      convRule: rule107
  }, {
      start: 981,
      length: 1,
      convRule: rule108
  }, {
      start: 982,
      length: 1,
      convRule: rule109
  }, {
      start: 983,
      length: 1,
      convRule: rule110
  }, {
      start: 984,
      length: 1,
      convRule: rule22
  }, {
      start: 985,
      length: 1,
      convRule: rule23
  }, {
      start: 986,
      length: 1,
      convRule: rule22
  }, {
      start: 987,
      length: 1,
      convRule: rule23
  }, {
      start: 988,
      length: 1,
      convRule: rule22
  }, {
      start: 989,
      length: 1,
      convRule: rule23
  }, {
      start: 990,
      length: 1,
      convRule: rule22
  }, {
      start: 991,
      length: 1,
      convRule: rule23
  }, {
      start: 992,
      length: 1,
      convRule: rule22
  }, {
      start: 993,
      length: 1,
      convRule: rule23
  }, {
      start: 994,
      length: 1,
      convRule: rule22
  }, {
      start: 995,
      length: 1,
      convRule: rule23
  }, {
      start: 996,
      length: 1,
      convRule: rule22
  }, {
      start: 997,
      length: 1,
      convRule: rule23
  }, {
      start: 998,
      length: 1,
      convRule: rule22
  }, {
      start: 999,
      length: 1,
      convRule: rule23
  }, {
      start: 1000,
      length: 1,
      convRule: rule22
  }, {
      start: 1001,
      length: 1,
      convRule: rule23
  }, {
      start: 1002,
      length: 1,
      convRule: rule22
  }, {
      start: 1003,
      length: 1,
      convRule: rule23
  }, {
      start: 1004,
      length: 1,
      convRule: rule22
  }, {
      start: 1005,
      length: 1,
      convRule: rule23
  }, {
      start: 1006,
      length: 1,
      convRule: rule22
  }, {
      start: 1007,
      length: 1,
      convRule: rule23
  }, {
      start: 1008,
      length: 1,
      convRule: rule111
  }, {
      start: 1009,
      length: 1,
      convRule: rule112
  }, {
      start: 1010,
      length: 1,
      convRule: rule113
  }, {
      start: 1011,
      length: 1,
      convRule: rule114
  }, {
      start: 1012,
      length: 1,
      convRule: rule115
  }, {
      start: 1013,
      length: 1,
      convRule: rule116
  }, {
      start: 1014,
      length: 1,
      convRule: rule6
  }, {
      start: 1015,
      length: 1,
      convRule: rule22
  }, {
      start: 1016,
      length: 1,
      convRule: rule23
  }, {
      start: 1017,
      length: 1,
      convRule: rule117
  }, {
      start: 1018,
      length: 1,
      convRule: rule22
  }, {
      start: 1019,
      length: 1,
      convRule: rule23
  }, {
      start: 1020,
      length: 1,
      convRule: rule20
  }, {
      start: 1021,
      length: 3,
      convRule: rule53
  }, {
      start: 1024,
      length: 16,
      convRule: rule118
  }, {
      start: 1040,
      length: 32,
      convRule: rule9
  }, {
      start: 1072,
      length: 32,
      convRule: rule12
  }, {
      start: 1104,
      length: 16,
      convRule: rule112
  }, {
      start: 1120,
      length: 1,
      convRule: rule22
  }, {
      start: 1121,
      length: 1,
      convRule: rule23
  }, {
      start: 1122,
      length: 1,
      convRule: rule22
  }, {
      start: 1123,
      length: 1,
      convRule: rule23
  }, {
      start: 1124,
      length: 1,
      convRule: rule22
  }, {
      start: 1125,
      length: 1,
      convRule: rule23
  }, {
      start: 1126,
      length: 1,
      convRule: rule22
  }, {
      start: 1127,
      length: 1,
      convRule: rule23
  }, {
      start: 1128,
      length: 1,
      convRule: rule22
  }, {
      start: 1129,
      length: 1,
      convRule: rule23
  }, {
      start: 1130,
      length: 1,
      convRule: rule22
  }, {
      start: 1131,
      length: 1,
      convRule: rule23
  }, {
      start: 1132,
      length: 1,
      convRule: rule22
  }, {
      start: 1133,
      length: 1,
      convRule: rule23
  }, {
      start: 1134,
      length: 1,
      convRule: rule22
  }, {
      start: 1135,
      length: 1,
      convRule: rule23
  }, {
      start: 1136,
      length: 1,
      convRule: rule22
  }, {
      start: 1137,
      length: 1,
      convRule: rule23
  }, {
      start: 1138,
      length: 1,
      convRule: rule22
  }, {
      start: 1139,
      length: 1,
      convRule: rule23
  }, {
      start: 1140,
      length: 1,
      convRule: rule22
  }, {
      start: 1141,
      length: 1,
      convRule: rule23
  }, {
      start: 1142,
      length: 1,
      convRule: rule22
  }, {
      start: 1143,
      length: 1,
      convRule: rule23
  }, {
      start: 1144,
      length: 1,
      convRule: rule22
  }, {
      start: 1145,
      length: 1,
      convRule: rule23
  }, {
      start: 1146,
      length: 1,
      convRule: rule22
  }, {
      start: 1147,
      length: 1,
      convRule: rule23
  }, {
      start: 1148,
      length: 1,
      convRule: rule22
  }, {
      start: 1149,
      length: 1,
      convRule: rule23
  }, {
      start: 1150,
      length: 1,
      convRule: rule22
  }, {
      start: 1151,
      length: 1,
      convRule: rule23
  }, {
      start: 1152,
      length: 1,
      convRule: rule22
  }, {
      start: 1153,
      length: 1,
      convRule: rule23
  }, {
      start: 1154,
      length: 1,
      convRule: rule13
  }, {
      start: 1155,
      length: 5,
      convRule: rule92
  }, {
      start: 1160,
      length: 2,
      convRule: rule119
  }, {
      start: 1162,
      length: 1,
      convRule: rule22
  }, {
      start: 1163,
      length: 1,
      convRule: rule23
  }, {
      start: 1164,
      length: 1,
      convRule: rule22
  }, {
      start: 1165,
      length: 1,
      convRule: rule23
  }, {
      start: 1166,
      length: 1,
      convRule: rule22
  }, {
      start: 1167,
      length: 1,
      convRule: rule23
  }, {
      start: 1168,
      length: 1,
      convRule: rule22
  }, {
      start: 1169,
      length: 1,
      convRule: rule23
  }, {
      start: 1170,
      length: 1,
      convRule: rule22
  }, {
      start: 1171,
      length: 1,
      convRule: rule23
  }, {
      start: 1172,
      length: 1,
      convRule: rule22
  }, {
      start: 1173,
      length: 1,
      convRule: rule23
  }, {
      start: 1174,
      length: 1,
      convRule: rule22
  }, {
      start: 1175,
      length: 1,
      convRule: rule23
  }, {
      start: 1176,
      length: 1,
      convRule: rule22
  }, {
      start: 1177,
      length: 1,
      convRule: rule23
  }, {
      start: 1178,
      length: 1,
      convRule: rule22
  }, {
      start: 1179,
      length: 1,
      convRule: rule23
  }, {
      start: 1180,
      length: 1,
      convRule: rule22
  }, {
      start: 1181,
      length: 1,
      convRule: rule23
  }, {
      start: 1182,
      length: 1,
      convRule: rule22
  }, {
      start: 1183,
      length: 1,
      convRule: rule23
  }, {
      start: 1184,
      length: 1,
      convRule: rule22
  }, {
      start: 1185,
      length: 1,
      convRule: rule23
  }, {
      start: 1186,
      length: 1,
      convRule: rule22
  }, {
      start: 1187,
      length: 1,
      convRule: rule23
  }, {
      start: 1188,
      length: 1,
      convRule: rule22
  }, {
      start: 1189,
      length: 1,
      convRule: rule23
  }, {
      start: 1190,
      length: 1,
      convRule: rule22
  }, {
      start: 1191,
      length: 1,
      convRule: rule23
  }, {
      start: 1192,
      length: 1,
      convRule: rule22
  }, {
      start: 1193,
      length: 1,
      convRule: rule23
  }, {
      start: 1194,
      length: 1,
      convRule: rule22
  }, {
      start: 1195,
      length: 1,
      convRule: rule23
  }, {
      start: 1196,
      length: 1,
      convRule: rule22
  }, {
      start: 1197,
      length: 1,
      convRule: rule23
  }, {
      start: 1198,
      length: 1,
      convRule: rule22
  }, {
      start: 1199,
      length: 1,
      convRule: rule23
  }, {
      start: 1200,
      length: 1,
      convRule: rule22
  }, {
      start: 1201,
      length: 1,
      convRule: rule23
  }, {
      start: 1202,
      length: 1,
      convRule: rule22
  }, {
      start: 1203,
      length: 1,
      convRule: rule23
  }, {
      start: 1204,
      length: 1,
      convRule: rule22
  }, {
      start: 1205,
      length: 1,
      convRule: rule23
  }, {
      start: 1206,
      length: 1,
      convRule: rule22
  }, {
      start: 1207,
      length: 1,
      convRule: rule23
  }, {
      start: 1208,
      length: 1,
      convRule: rule22
  }, {
      start: 1209,
      length: 1,
      convRule: rule23
  }, {
      start: 1210,
      length: 1,
      convRule: rule22
  }, {
      start: 1211,
      length: 1,
      convRule: rule23
  }, {
      start: 1212,
      length: 1,
      convRule: rule22
  }, {
      start: 1213,
      length: 1,
      convRule: rule23
  }, {
      start: 1214,
      length: 1,
      convRule: rule22
  }, {
      start: 1215,
      length: 1,
      convRule: rule23
  }, {
      start: 1216,
      length: 1,
      convRule: rule120
  }, {
      start: 1217,
      length: 1,
      convRule: rule22
  }, {
      start: 1218,
      length: 1,
      convRule: rule23
  }, {
      start: 1219,
      length: 1,
      convRule: rule22
  }, {
      start: 1220,
      length: 1,
      convRule: rule23
  }, {
      start: 1221,
      length: 1,
      convRule: rule22
  }, {
      start: 1222,
      length: 1,
      convRule: rule23
  }, {
      start: 1223,
      length: 1,
      convRule: rule22
  }, {
      start: 1224,
      length: 1,
      convRule: rule23
  }, {
      start: 1225,
      length: 1,
      convRule: rule22
  }, {
      start: 1226,
      length: 1,
      convRule: rule23
  }, {
      start: 1227,
      length: 1,
      convRule: rule22
  }, {
      start: 1228,
      length: 1,
      convRule: rule23
  }, {
      start: 1229,
      length: 1,
      convRule: rule22
  }, {
      start: 1230,
      length: 1,
      convRule: rule23
  }, {
      start: 1231,
      length: 1,
      convRule: rule121
  }, {
      start: 1232,
      length: 1,
      convRule: rule22
  }, {
      start: 1233,
      length: 1,
      convRule: rule23
  }, {
      start: 1234,
      length: 1,
      convRule: rule22
  }, {
      start: 1235,
      length: 1,
      convRule: rule23
  }, {
      start: 1236,
      length: 1,
      convRule: rule22
  }, {
      start: 1237,
      length: 1,
      convRule: rule23
  }, {
      start: 1238,
      length: 1,
      convRule: rule22
  }, {
      start: 1239,
      length: 1,
      convRule: rule23
  }, {
      start: 1240,
      length: 1,
      convRule: rule22
  }, {
      start: 1241,
      length: 1,
      convRule: rule23
  }, {
      start: 1242,
      length: 1,
      convRule: rule22
  }, {
      start: 1243,
      length: 1,
      convRule: rule23
  }, {
      start: 1244,
      length: 1,
      convRule: rule22
  }, {
      start: 1245,
      length: 1,
      convRule: rule23
  }, {
      start: 1246,
      length: 1,
      convRule: rule22
  }, {
      start: 1247,
      length: 1,
      convRule: rule23
  }, {
      start: 1248,
      length: 1,
      convRule: rule22
  }, {
      start: 1249,
      length: 1,
      convRule: rule23
  }, {
      start: 1250,
      length: 1,
      convRule: rule22
  }, {
      start: 1251,
      length: 1,
      convRule: rule23
  }, {
      start: 1252,
      length: 1,
      convRule: rule22
  }, {
      start: 1253,
      length: 1,
      convRule: rule23
  }, {
      start: 1254,
      length: 1,
      convRule: rule22
  }, {
      start: 1255,
      length: 1,
      convRule: rule23
  }, {
      start: 1256,
      length: 1,
      convRule: rule22
  }, {
      start: 1257,
      length: 1,
      convRule: rule23
  }, {
      start: 1258,
      length: 1,
      convRule: rule22
  }, {
      start: 1259,
      length: 1,
      convRule: rule23
  }, {
      start: 1260,
      length: 1,
      convRule: rule22
  }, {
      start: 1261,
      length: 1,
      convRule: rule23
  }, {
      start: 1262,
      length: 1,
      convRule: rule22
  }, {
      start: 1263,
      length: 1,
      convRule: rule23
  }, {
      start: 1264,
      length: 1,
      convRule: rule22
  }, {
      start: 1265,
      length: 1,
      convRule: rule23
  }, {
      start: 1266,
      length: 1,
      convRule: rule22
  }, {
      start: 1267,
      length: 1,
      convRule: rule23
  }, {
      start: 1268,
      length: 1,
      convRule: rule22
  }, {
      start: 1269,
      length: 1,
      convRule: rule23
  }, {
      start: 1270,
      length: 1,
      convRule: rule22
  }, {
      start: 1271,
      length: 1,
      convRule: rule23
  }, {
      start: 1272,
      length: 1,
      convRule: rule22
  }, {
      start: 1273,
      length: 1,
      convRule: rule23
  }, {
      start: 1274,
      length: 1,
      convRule: rule22
  }, {
      start: 1275,
      length: 1,
      convRule: rule23
  }, {
      start: 1276,
      length: 1,
      convRule: rule22
  }, {
      start: 1277,
      length: 1,
      convRule: rule23
  }, {
      start: 1278,
      length: 1,
      convRule: rule22
  }, {
      start: 1279,
      length: 1,
      convRule: rule23
  }, {
      start: 1280,
      length: 1,
      convRule: rule22
  }, {
      start: 1281,
      length: 1,
      convRule: rule23
  }, {
      start: 1282,
      length: 1,
      convRule: rule22
  }, {
      start: 1283,
      length: 1,
      convRule: rule23
  }, {
      start: 1284,
      length: 1,
      convRule: rule22
  }, {
      start: 1285,
      length: 1,
      convRule: rule23
  }, {
      start: 1286,
      length: 1,
      convRule: rule22
  }, {
      start: 1287,
      length: 1,
      convRule: rule23
  }, {
      start: 1288,
      length: 1,
      convRule: rule22
  }, {
      start: 1289,
      length: 1,
      convRule: rule23
  }, {
      start: 1290,
      length: 1,
      convRule: rule22
  }, {
      start: 1291,
      length: 1,
      convRule: rule23
  }, {
      start: 1292,
      length: 1,
      convRule: rule22
  }, {
      start: 1293,
      length: 1,
      convRule: rule23
  }, {
      start: 1294,
      length: 1,
      convRule: rule22
  }, {
      start: 1295,
      length: 1,
      convRule: rule23
  }, {
      start: 1296,
      length: 1,
      convRule: rule22
  }, {
      start: 1297,
      length: 1,
      convRule: rule23
  }, {
      start: 1298,
      length: 1,
      convRule: rule22
  }, {
      start: 1299,
      length: 1,
      convRule: rule23
  }, {
      start: 1300,
      length: 1,
      convRule: rule22
  }, {
      start: 1301,
      length: 1,
      convRule: rule23
  }, {
      start: 1302,
      length: 1,
      convRule: rule22
  }, {
      start: 1303,
      length: 1,
      convRule: rule23
  }, {
      start: 1304,
      length: 1,
      convRule: rule22
  }, {
      start: 1305,
      length: 1,
      convRule: rule23
  }, {
      start: 1306,
      length: 1,
      convRule: rule22
  }, {
      start: 1307,
      length: 1,
      convRule: rule23
  }, {
      start: 1308,
      length: 1,
      convRule: rule22
  }, {
      start: 1309,
      length: 1,
      convRule: rule23
  }, {
      start: 1310,
      length: 1,
      convRule: rule22
  }, {
      start: 1311,
      length: 1,
      convRule: rule23
  }, {
      start: 1312,
      length: 1,
      convRule: rule22
  }, {
      start: 1313,
      length: 1,
      convRule: rule23
  }, {
      start: 1314,
      length: 1,
      convRule: rule22
  }, {
      start: 1315,
      length: 1,
      convRule: rule23
  }, {
      start: 1316,
      length: 1,
      convRule: rule22
  }, {
      start: 1317,
      length: 1,
      convRule: rule23
  }, {
      start: 1318,
      length: 1,
      convRule: rule22
  }, {
      start: 1319,
      length: 1,
      convRule: rule23
  }, {
      start: 1320,
      length: 1,
      convRule: rule22
  }, {
      start: 1321,
      length: 1,
      convRule: rule23
  }, {
      start: 1322,
      length: 1,
      convRule: rule22
  }, {
      start: 1323,
      length: 1,
      convRule: rule23
  }, {
      start: 1324,
      length: 1,
      convRule: rule22
  }, {
      start: 1325,
      length: 1,
      convRule: rule23
  }, {
      start: 1326,
      length: 1,
      convRule: rule22
  }, {
      start: 1327,
      length: 1,
      convRule: rule23
  }, {
      start: 1329,
      length: 38,
      convRule: rule122
  }, {
      start: 1369,
      length: 1,
      convRule: rule91
  }, {
      start: 1370,
      length: 6,
      convRule: rule2
  }, {
      start: 1376,
      length: 1,
      convRule: rule20
  }, {
      start: 1377,
      length: 38,
      convRule: rule123
  }, {
      start: 1415,
      length: 2,
      convRule: rule20
  }, {
      start: 1417,
      length: 1,
      convRule: rule2
  }, {
      start: 1418,
      length: 1,
      convRule: rule7
  }, {
      start: 1421,
      length: 2,
      convRule: rule13
  }, {
      start: 1423,
      length: 1,
      convRule: rule3
  }, {
      start: 1425,
      length: 45,
      convRule: rule92
  }, {
      start: 1470,
      length: 1,
      convRule: rule7
  }, {
      start: 1471,
      length: 1,
      convRule: rule92
  }, {
      start: 1472,
      length: 1,
      convRule: rule2
  }, {
      start: 1473,
      length: 2,
      convRule: rule92
  }, {
      start: 1475,
      length: 1,
      convRule: rule2
  }, {
      start: 1476,
      length: 2,
      convRule: rule92
  }, {
      start: 1478,
      length: 1,
      convRule: rule2
  }, {
      start: 1479,
      length: 1,
      convRule: rule92
  }, {
      start: 1488,
      length: 27,
      convRule: rule14
  }, {
      start: 1519,
      length: 4,
      convRule: rule14
  }, {
      start: 1523,
      length: 2,
      convRule: rule2
  }, {
      start: 1536,
      length: 6,
      convRule: rule16
  }, {
      start: 1542,
      length: 3,
      convRule: rule6
  }, {
      start: 1545,
      length: 2,
      convRule: rule2
  }, {
      start: 1547,
      length: 1,
      convRule: rule3
  }, {
      start: 1548,
      length: 2,
      convRule: rule2
  }, {
      start: 1550,
      length: 2,
      convRule: rule13
  }, {
      start: 1552,
      length: 11,
      convRule: rule92
  }, {
      start: 1563,
      length: 1,
      convRule: rule2
  }, {
      start: 1564,
      length: 1,
      convRule: rule16
  }, {
      start: 1566,
      length: 2,
      convRule: rule2
  }, {
      start: 1568,
      length: 32,
      convRule: rule14
  }, {
      start: 1600,
      length: 1,
      convRule: rule91
  }, {
      start: 1601,
      length: 10,
      convRule: rule14
  }, {
      start: 1611,
      length: 21,
      convRule: rule92
  }, {
      start: 1632,
      length: 10,
      convRule: rule8
  }, {
      start: 1642,
      length: 4,
      convRule: rule2
  }, {
      start: 1646,
      length: 2,
      convRule: rule14
  }, {
      start: 1648,
      length: 1,
      convRule: rule92
  }, {
      start: 1649,
      length: 99,
      convRule: rule14
  }, {
      start: 1748,
      length: 1,
      convRule: rule2
  }, {
      start: 1749,
      length: 1,
      convRule: rule14
  }, {
      start: 1750,
      length: 7,
      convRule: rule92
  }, {
      start: 1757,
      length: 1,
      convRule: rule16
  }, {
      start: 1758,
      length: 1,
      convRule: rule13
  }, {
      start: 1759,
      length: 6,
      convRule: rule92
  }, {
      start: 1765,
      length: 2,
      convRule: rule91
  }, {
      start: 1767,
      length: 2,
      convRule: rule92
  }, {
      start: 1769,
      length: 1,
      convRule: rule13
  }, {
      start: 1770,
      length: 4,
      convRule: rule92
  }, {
      start: 1774,
      length: 2,
      convRule: rule14
  }, {
      start: 1776,
      length: 10,
      convRule: rule8
  }, {
      start: 1786,
      length: 3,
      convRule: rule14
  }, {
      start: 1789,
      length: 2,
      convRule: rule13
  }, {
      start: 1791,
      length: 1,
      convRule: rule14
  }, {
      start: 1792,
      length: 14,
      convRule: rule2
  }, {
      start: 1807,
      length: 1,
      convRule: rule16
  }, {
      start: 1808,
      length: 1,
      convRule: rule14
  }, {
      start: 1809,
      length: 1,
      convRule: rule92
  }, {
      start: 1810,
      length: 30,
      convRule: rule14
  }, {
      start: 1840,
      length: 27,
      convRule: rule92
  }, {
      start: 1869,
      length: 89,
      convRule: rule14
  }, {
      start: 1958,
      length: 11,
      convRule: rule92
  }, {
      start: 1969,
      length: 1,
      convRule: rule14
  }, {
      start: 1984,
      length: 10,
      convRule: rule8
  }, {
      start: 1994,
      length: 33,
      convRule: rule14
  }, {
      start: 2027,
      length: 9,
      convRule: rule92
  }, {
      start: 2036,
      length: 2,
      convRule: rule91
  }, {
      start: 2038,
      length: 1,
      convRule: rule13
  }, {
      start: 2039,
      length: 3,
      convRule: rule2
  }, {
      start: 2042,
      length: 1,
      convRule: rule91
  }, {
      start: 2045,
      length: 1,
      convRule: rule92
  }, {
      start: 2046,
      length: 2,
      convRule: rule3
  }, {
      start: 2048,
      length: 22,
      convRule: rule14
  }, {
      start: 2070,
      length: 4,
      convRule: rule92
  }, {
      start: 2074,
      length: 1,
      convRule: rule91
  }, {
      start: 2075,
      length: 9,
      convRule: rule92
  }, {
      start: 2084,
      length: 1,
      convRule: rule91
  }, {
      start: 2085,
      length: 3,
      convRule: rule92
  }, {
      start: 2088,
      length: 1,
      convRule: rule91
  }, {
      start: 2089,
      length: 5,
      convRule: rule92
  }, {
      start: 2096,
      length: 15,
      convRule: rule2
  }, {
      start: 2112,
      length: 25,
      convRule: rule14
  }, {
      start: 2137,
      length: 3,
      convRule: rule92
  }, {
      start: 2142,
      length: 1,
      convRule: rule2
  }, {
      start: 2144,
      length: 11,
      convRule: rule14
  }, {
      start: 2208,
      length: 21,
      convRule: rule14
  }, {
      start: 2230,
      length: 18,
      convRule: rule14
  }, {
      start: 2259,
      length: 15,
      convRule: rule92
  }, {
      start: 2274,
      length: 1,
      convRule: rule16
  }, {
      start: 2275,
      length: 32,
      convRule: rule92
  }, {
      start: 2307,
      length: 1,
      convRule: rule124
  }, {
      start: 2308,
      length: 54,
      convRule: rule14
  }, {
      start: 2362,
      length: 1,
      convRule: rule92
  }, {
      start: 2363,
      length: 1,
      convRule: rule124
  }, {
      start: 2364,
      length: 1,
      convRule: rule92
  }, {
      start: 2365,
      length: 1,
      convRule: rule14
  }, {
      start: 2366,
      length: 3,
      convRule: rule124
  }, {
      start: 2369,
      length: 8,
      convRule: rule92
  }, {
      start: 2377,
      length: 4,
      convRule: rule124
  }, {
      start: 2381,
      length: 1,
      convRule: rule92
  }, {
      start: 2382,
      length: 2,
      convRule: rule124
  }, {
      start: 2384,
      length: 1,
      convRule: rule14
  }, {
      start: 2385,
      length: 7,
      convRule: rule92
  }, {
      start: 2392,
      length: 10,
      convRule: rule14
  }, {
      start: 2402,
      length: 2,
      convRule: rule92
  }, {
      start: 2404,
      length: 2,
      convRule: rule2
  }, {
      start: 2406,
      length: 10,
      convRule: rule8
  }, {
      start: 2416,
      length: 1,
      convRule: rule2
  }, {
      start: 2417,
      length: 1,
      convRule: rule91
  }, {
      start: 2418,
      length: 15,
      convRule: rule14
  }, {
      start: 2433,
      length: 1,
      convRule: rule92
  }, {
      start: 2434,
      length: 2,
      convRule: rule124
  }, {
      start: 2437,
      length: 8,
      convRule: rule14
  }, {
      start: 2447,
      length: 2,
      convRule: rule14
  }, {
      start: 2451,
      length: 22,
      convRule: rule14
  }, {
      start: 2474,
      length: 7,
      convRule: rule14
  }, {
      start: 2482,
      length: 1,
      convRule: rule14
  }, {
      start: 2486,
      length: 4,
      convRule: rule14
  }, {
      start: 2492,
      length: 1,
      convRule: rule92
  }, {
      start: 2493,
      length: 1,
      convRule: rule14
  }, {
      start: 2494,
      length: 3,
      convRule: rule124
  }, {
      start: 2497,
      length: 4,
      convRule: rule92
  }, {
      start: 2503,
      length: 2,
      convRule: rule124
  }, {
      start: 2507,
      length: 2,
      convRule: rule124
  }, {
      start: 2509,
      length: 1,
      convRule: rule92
  }, {
      start: 2510,
      length: 1,
      convRule: rule14
  }, {
      start: 2519,
      length: 1,
      convRule: rule124
  }, {
      start: 2524,
      length: 2,
      convRule: rule14
  }, {
      start: 2527,
      length: 3,
      convRule: rule14
  }, {
      start: 2530,
      length: 2,
      convRule: rule92
  }, {
      start: 2534,
      length: 10,
      convRule: rule8
  }, {
      start: 2544,
      length: 2,
      convRule: rule14
  }, {
      start: 2546,
      length: 2,
      convRule: rule3
  }, {
      start: 2548,
      length: 6,
      convRule: rule17
  }, {
      start: 2554,
      length: 1,
      convRule: rule13
  }, {
      start: 2555,
      length: 1,
      convRule: rule3
  }, {
      start: 2556,
      length: 1,
      convRule: rule14
  }, {
      start: 2557,
      length: 1,
      convRule: rule2
  }, {
      start: 2558,
      length: 1,
      convRule: rule92
  }, {
      start: 2561,
      length: 2,
      convRule: rule92
  }, {
      start: 2563,
      length: 1,
      convRule: rule124
  }, {
      start: 2565,
      length: 6,
      convRule: rule14
  }, {
      start: 2575,
      length: 2,
      convRule: rule14
  }, {
      start: 2579,
      length: 22,
      convRule: rule14
  }, {
      start: 2602,
      length: 7,
      convRule: rule14
  }, {
      start: 2610,
      length: 2,
      convRule: rule14
  }, {
      start: 2613,
      length: 2,
      convRule: rule14
  }, {
      start: 2616,
      length: 2,
      convRule: rule14
  }, {
      start: 2620,
      length: 1,
      convRule: rule92
  }, {
      start: 2622,
      length: 3,
      convRule: rule124
  }, {
      start: 2625,
      length: 2,
      convRule: rule92
  }, {
      start: 2631,
      length: 2,
      convRule: rule92
  }, {
      start: 2635,
      length: 3,
      convRule: rule92
  }, {
      start: 2641,
      length: 1,
      convRule: rule92
  }, {
      start: 2649,
      length: 4,
      convRule: rule14
  }, {
      start: 2654,
      length: 1,
      convRule: rule14
  }, {
      start: 2662,
      length: 10,
      convRule: rule8
  }, {
      start: 2672,
      length: 2,
      convRule: rule92
  }, {
      start: 2674,
      length: 3,
      convRule: rule14
  }, {
      start: 2677,
      length: 1,
      convRule: rule92
  }, {
      start: 2678,
      length: 1,
      convRule: rule2
  }, {
      start: 2689,
      length: 2,
      convRule: rule92
  }, {
      start: 2691,
      length: 1,
      convRule: rule124
  }, {
      start: 2693,
      length: 9,
      convRule: rule14
  }, {
      start: 2703,
      length: 3,
      convRule: rule14
  }, {
      start: 2707,
      length: 22,
      convRule: rule14
  }, {
      start: 2730,
      length: 7,
      convRule: rule14
  }, {
      start: 2738,
      length: 2,
      convRule: rule14
  }, {
      start: 2741,
      length: 5,
      convRule: rule14
  }, {
      start: 2748,
      length: 1,
      convRule: rule92
  }, {
      start: 2749,
      length: 1,
      convRule: rule14
  }, {
      start: 2750,
      length: 3,
      convRule: rule124
  }, {
      start: 2753,
      length: 5,
      convRule: rule92
  }, {
      start: 2759,
      length: 2,
      convRule: rule92
  }, {
      start: 2761,
      length: 1,
      convRule: rule124
  }, {
      start: 2763,
      length: 2,
      convRule: rule124
  }, {
      start: 2765,
      length: 1,
      convRule: rule92
  }, {
      start: 2768,
      length: 1,
      convRule: rule14
  }, {
      start: 2784,
      length: 2,
      convRule: rule14
  }, {
      start: 2786,
      length: 2,
      convRule: rule92
  }, {
      start: 2790,
      length: 10,
      convRule: rule8
  }, {
      start: 2800,
      length: 1,
      convRule: rule2
  }, {
      start: 2801,
      length: 1,
      convRule: rule3
  }, {
      start: 2809,
      length: 1,
      convRule: rule14
  }, {
      start: 2810,
      length: 6,
      convRule: rule92
  }, {
      start: 2817,
      length: 1,
      convRule: rule92
  }, {
      start: 2818,
      length: 2,
      convRule: rule124
  }, {
      start: 2821,
      length: 8,
      convRule: rule14
  }, {
      start: 2831,
      length: 2,
      convRule: rule14
  }, {
      start: 2835,
      length: 22,
      convRule: rule14
  }, {
      start: 2858,
      length: 7,
      convRule: rule14
  }, {
      start: 2866,
      length: 2,
      convRule: rule14
  }, {
      start: 2869,
      length: 5,
      convRule: rule14
  }, {
      start: 2876,
      length: 1,
      convRule: rule92
  }, {
      start: 2877,
      length: 1,
      convRule: rule14
  }, {
      start: 2878,
      length: 1,
      convRule: rule124
  }, {
      start: 2879,
      length: 1,
      convRule: rule92
  }, {
      start: 2880,
      length: 1,
      convRule: rule124
  }, {
      start: 2881,
      length: 4,
      convRule: rule92
  }, {
      start: 2887,
      length: 2,
      convRule: rule124
  }, {
      start: 2891,
      length: 2,
      convRule: rule124
  }, {
      start: 2893,
      length: 1,
      convRule: rule92
  }, {
      start: 2901,
      length: 2,
      convRule: rule92
  }, {
      start: 2903,
      length: 1,
      convRule: rule124
  }, {
      start: 2908,
      length: 2,
      convRule: rule14
  }, {
      start: 2911,
      length: 3,
      convRule: rule14
  }, {
      start: 2914,
      length: 2,
      convRule: rule92
  }, {
      start: 2918,
      length: 10,
      convRule: rule8
  }, {
      start: 2928,
      length: 1,
      convRule: rule13
  }, {
      start: 2929,
      length: 1,
      convRule: rule14
  }, {
      start: 2930,
      length: 6,
      convRule: rule17
  }, {
      start: 2946,
      length: 1,
      convRule: rule92
  }, {
      start: 2947,
      length: 1,
      convRule: rule14
  }, {
      start: 2949,
      length: 6,
      convRule: rule14
  }, {
      start: 2958,
      length: 3,
      convRule: rule14
  }, {
      start: 2962,
      length: 4,
      convRule: rule14
  }, {
      start: 2969,
      length: 2,
      convRule: rule14
  }, {
      start: 2972,
      length: 1,
      convRule: rule14
  }, {
      start: 2974,
      length: 2,
      convRule: rule14
  }, {
      start: 2979,
      length: 2,
      convRule: rule14
  }, {
      start: 2984,
      length: 3,
      convRule: rule14
  }, {
      start: 2990,
      length: 12,
      convRule: rule14
  }, {
      start: 3006,
      length: 2,
      convRule: rule124
  }, {
      start: 3008,
      length: 1,
      convRule: rule92
  }, {
      start: 3009,
      length: 2,
      convRule: rule124
  }, {
      start: 3014,
      length: 3,
      convRule: rule124
  }, {
      start: 3018,
      length: 3,
      convRule: rule124
  }, {
      start: 3021,
      length: 1,
      convRule: rule92
  }, {
      start: 3024,
      length: 1,
      convRule: rule14
  }, {
      start: 3031,
      length: 1,
      convRule: rule124
  }, {
      start: 3046,
      length: 10,
      convRule: rule8
  }, {
      start: 3056,
      length: 3,
      convRule: rule17
  }, {
      start: 3059,
      length: 6,
      convRule: rule13
  }, {
      start: 3065,
      length: 1,
      convRule: rule3
  }, {
      start: 3066,
      length: 1,
      convRule: rule13
  }, {
      start: 3072,
      length: 1,
      convRule: rule92
  }, {
      start: 3073,
      length: 3,
      convRule: rule124
  }, {
      start: 3076,
      length: 1,
      convRule: rule92
  }, {
      start: 3077,
      length: 8,
      convRule: rule14
  }, {
      start: 3086,
      length: 3,
      convRule: rule14
  }, {
      start: 3090,
      length: 23,
      convRule: rule14
  }, {
      start: 3114,
      length: 16,
      convRule: rule14
  }, {
      start: 3133,
      length: 1,
      convRule: rule14
  }, {
      start: 3134,
      length: 3,
      convRule: rule92
  }, {
      start: 3137,
      length: 4,
      convRule: rule124
  }, {
      start: 3142,
      length: 3,
      convRule: rule92
  }, {
      start: 3146,
      length: 4,
      convRule: rule92
  }, {
      start: 3157,
      length: 2,
      convRule: rule92
  }, {
      start: 3160,
      length: 3,
      convRule: rule14
  }, {
      start: 3168,
      length: 2,
      convRule: rule14
  }, {
      start: 3170,
      length: 2,
      convRule: rule92
  }, {
      start: 3174,
      length: 10,
      convRule: rule8
  }, {
      start: 3191,
      length: 1,
      convRule: rule2
  }, {
      start: 3192,
      length: 7,
      convRule: rule17
  }, {
      start: 3199,
      length: 1,
      convRule: rule13
  }, {
      start: 3200,
      length: 1,
      convRule: rule14
  }, {
      start: 3201,
      length: 1,
      convRule: rule92
  }, {
      start: 3202,
      length: 2,
      convRule: rule124
  }, {
      start: 3204,
      length: 1,
      convRule: rule2
  }, {
      start: 3205,
      length: 8,
      convRule: rule14
  }, {
      start: 3214,
      length: 3,
      convRule: rule14
  }, {
      start: 3218,
      length: 23,
      convRule: rule14
  }, {
      start: 3242,
      length: 10,
      convRule: rule14
  }, {
      start: 3253,
      length: 5,
      convRule: rule14
  }, {
      start: 3260,
      length: 1,
      convRule: rule92
  }, {
      start: 3261,
      length: 1,
      convRule: rule14
  }, {
      start: 3262,
      length: 1,
      convRule: rule124
  }, {
      start: 3263,
      length: 1,
      convRule: rule92
  }, {
      start: 3264,
      length: 5,
      convRule: rule124
  }, {
      start: 3270,
      length: 1,
      convRule: rule92
  }, {
      start: 3271,
      length: 2,
      convRule: rule124
  }, {
      start: 3274,
      length: 2,
      convRule: rule124
  }, {
      start: 3276,
      length: 2,
      convRule: rule92
  }, {
      start: 3285,
      length: 2,
      convRule: rule124
  }, {
      start: 3294,
      length: 1,
      convRule: rule14
  }, {
      start: 3296,
      length: 2,
      convRule: rule14
  }, {
      start: 3298,
      length: 2,
      convRule: rule92
  }, {
      start: 3302,
      length: 10,
      convRule: rule8
  }, {
      start: 3313,
      length: 2,
      convRule: rule14
  }, {
      start: 3328,
      length: 2,
      convRule: rule92
  }, {
      start: 3330,
      length: 2,
      convRule: rule124
  }, {
      start: 3332,
      length: 9,
      convRule: rule14
  }, {
      start: 3342,
      length: 3,
      convRule: rule14
  }, {
      start: 3346,
      length: 41,
      convRule: rule14
  }, {
      start: 3387,
      length: 2,
      convRule: rule92
  }, {
      start: 3389,
      length: 1,
      convRule: rule14
  }, {
      start: 3390,
      length: 3,
      convRule: rule124
  }, {
      start: 3393,
      length: 4,
      convRule: rule92
  }, {
      start: 3398,
      length: 3,
      convRule: rule124
  }, {
      start: 3402,
      length: 3,
      convRule: rule124
  }, {
      start: 3405,
      length: 1,
      convRule: rule92
  }, {
      start: 3406,
      length: 1,
      convRule: rule14
  }, {
      start: 3407,
      length: 1,
      convRule: rule13
  }, {
      start: 3412,
      length: 3,
      convRule: rule14
  }, {
      start: 3415,
      length: 1,
      convRule: rule124
  }, {
      start: 3416,
      length: 7,
      convRule: rule17
  }, {
      start: 3423,
      length: 3,
      convRule: rule14
  }, {
      start: 3426,
      length: 2,
      convRule: rule92
  }, {
      start: 3430,
      length: 10,
      convRule: rule8
  }, {
      start: 3440,
      length: 9,
      convRule: rule17
  }, {
      start: 3449,
      length: 1,
      convRule: rule13
  }, {
      start: 3450,
      length: 6,
      convRule: rule14
  }, {
      start: 3457,
      length: 1,
      convRule: rule92
  }, {
      start: 3458,
      length: 2,
      convRule: rule124
  }, {
      start: 3461,
      length: 18,
      convRule: rule14
  }, {
      start: 3482,
      length: 24,
      convRule: rule14
  }, {
      start: 3507,
      length: 9,
      convRule: rule14
  }, {
      start: 3517,
      length: 1,
      convRule: rule14
  }, {
      start: 3520,
      length: 7,
      convRule: rule14
  }, {
      start: 3530,
      length: 1,
      convRule: rule92
  }, {
      start: 3535,
      length: 3,
      convRule: rule124
  }, {
      start: 3538,
      length: 3,
      convRule: rule92
  }, {
      start: 3542,
      length: 1,
      convRule: rule92
  }, {
      start: 3544,
      length: 8,
      convRule: rule124
  }, {
      start: 3558,
      length: 10,
      convRule: rule8
  }, {
      start: 3570,
      length: 2,
      convRule: rule124
  }, {
      start: 3572,
      length: 1,
      convRule: rule2
  }, {
      start: 3585,
      length: 48,
      convRule: rule14
  }, {
      start: 3633,
      length: 1,
      convRule: rule92
  }, {
      start: 3634,
      length: 2,
      convRule: rule14
  }, {
      start: 3636,
      length: 7,
      convRule: rule92
  }, {
      start: 3647,
      length: 1,
      convRule: rule3
  }, {
      start: 3648,
      length: 6,
      convRule: rule14
  }, {
      start: 3654,
      length: 1,
      convRule: rule91
  }, {
      start: 3655,
      length: 8,
      convRule: rule92
  }, {
      start: 3663,
      length: 1,
      convRule: rule2
  }, {
      start: 3664,
      length: 10,
      convRule: rule8
  }, {
      start: 3674,
      length: 2,
      convRule: rule2
  }, {
      start: 3713,
      length: 2,
      convRule: rule14
  }, {
      start: 3716,
      length: 1,
      convRule: rule14
  }, {
      start: 3718,
      length: 5,
      convRule: rule14
  }, {
      start: 3724,
      length: 24,
      convRule: rule14
  }, {
      start: 3749,
      length: 1,
      convRule: rule14
  }, {
      start: 3751,
      length: 10,
      convRule: rule14
  }, {
      start: 3761,
      length: 1,
      convRule: rule92
  }, {
      start: 3762,
      length: 2,
      convRule: rule14
  }, {
      start: 3764,
      length: 9,
      convRule: rule92
  }, {
      start: 3773,
      length: 1,
      convRule: rule14
  }, {
      start: 3776,
      length: 5,
      convRule: rule14
  }, {
      start: 3782,
      length: 1,
      convRule: rule91
  }, {
      start: 3784,
      length: 6,
      convRule: rule92
  }, {
      start: 3792,
      length: 10,
      convRule: rule8
  }, {
      start: 3804,
      length: 4,
      convRule: rule14
  }, {
      start: 3840,
      length: 1,
      convRule: rule14
  }, {
      start: 3841,
      length: 3,
      convRule: rule13
  }, {
      start: 3844,
      length: 15,
      convRule: rule2
  }, {
      start: 3859,
      length: 1,
      convRule: rule13
  }, {
      start: 3860,
      length: 1,
      convRule: rule2
  }, {
      start: 3861,
      length: 3,
      convRule: rule13
  }, {
      start: 3864,
      length: 2,
      convRule: rule92
  }, {
      start: 3866,
      length: 6,
      convRule: rule13
  }, {
      start: 3872,
      length: 10,
      convRule: rule8
  }, {
      start: 3882,
      length: 10,
      convRule: rule17
  }, {
      start: 3892,
      length: 1,
      convRule: rule13
  }, {
      start: 3893,
      length: 1,
      convRule: rule92
  }, {
      start: 3894,
      length: 1,
      convRule: rule13
  }, {
      start: 3895,
      length: 1,
      convRule: rule92
  }, {
      start: 3896,
      length: 1,
      convRule: rule13
  }, {
      start: 3897,
      length: 1,
      convRule: rule92
  }, {
      start: 3898,
      length: 1,
      convRule: rule4
  }, {
      start: 3899,
      length: 1,
      convRule: rule5
  }, {
      start: 3900,
      length: 1,
      convRule: rule4
  }, {
      start: 3901,
      length: 1,
      convRule: rule5
  }, {
      start: 3902,
      length: 2,
      convRule: rule124
  }, {
      start: 3904,
      length: 8,
      convRule: rule14
  }, {
      start: 3913,
      length: 36,
      convRule: rule14
  }, {
      start: 3953,
      length: 14,
      convRule: rule92
  }, {
      start: 3967,
      length: 1,
      convRule: rule124
  }, {
      start: 3968,
      length: 5,
      convRule: rule92
  }, {
      start: 3973,
      length: 1,
      convRule: rule2
  }, {
      start: 3974,
      length: 2,
      convRule: rule92
  }, {
      start: 3976,
      length: 5,
      convRule: rule14
  }, {
      start: 3981,
      length: 11,
      convRule: rule92
  }, {
      start: 3993,
      length: 36,
      convRule: rule92
  }, {
      start: 4030,
      length: 8,
      convRule: rule13
  }, {
      start: 4038,
      length: 1,
      convRule: rule92
  }, {
      start: 4039,
      length: 6,
      convRule: rule13
  }, {
      start: 4046,
      length: 2,
      convRule: rule13
  }, {
      start: 4048,
      length: 5,
      convRule: rule2
  }, {
      start: 4053,
      length: 4,
      convRule: rule13
  }, {
      start: 4057,
      length: 2,
      convRule: rule2
  }, {
      start: 4096,
      length: 43,
      convRule: rule14
  }, {
      start: 4139,
      length: 2,
      convRule: rule124
  }, {
      start: 4141,
      length: 4,
      convRule: rule92
  }, {
      start: 4145,
      length: 1,
      convRule: rule124
  }, {
      start: 4146,
      length: 6,
      convRule: rule92
  }, {
      start: 4152,
      length: 1,
      convRule: rule124
  }, {
      start: 4153,
      length: 2,
      convRule: rule92
  }, {
      start: 4155,
      length: 2,
      convRule: rule124
  }, {
      start: 4157,
      length: 2,
      convRule: rule92
  }, {
      start: 4159,
      length: 1,
      convRule: rule14
  }, {
      start: 4160,
      length: 10,
      convRule: rule8
  }, {
      start: 4170,
      length: 6,
      convRule: rule2
  }, {
      start: 4176,
      length: 6,
      convRule: rule14
  }, {
      start: 4182,
      length: 2,
      convRule: rule124
  }, {
      start: 4184,
      length: 2,
      convRule: rule92
  }, {
      start: 4186,
      length: 4,
      convRule: rule14
  }, {
      start: 4190,
      length: 3,
      convRule: rule92
  }, {
      start: 4193,
      length: 1,
      convRule: rule14
  }, {
      start: 4194,
      length: 3,
      convRule: rule124
  }, {
      start: 4197,
      length: 2,
      convRule: rule14
  }, {
      start: 4199,
      length: 7,
      convRule: rule124
  }, {
      start: 4206,
      length: 3,
      convRule: rule14
  }, {
      start: 4209,
      length: 4,
      convRule: rule92
  }, {
      start: 4213,
      length: 13,
      convRule: rule14
  }, {
      start: 4226,
      length: 1,
      convRule: rule92
  }, {
      start: 4227,
      length: 2,
      convRule: rule124
  }, {
      start: 4229,
      length: 2,
      convRule: rule92
  }, {
      start: 4231,
      length: 6,
      convRule: rule124
  }, {
      start: 4237,
      length: 1,
      convRule: rule92
  }, {
      start: 4238,
      length: 1,
      convRule: rule14
  }, {
      start: 4239,
      length: 1,
      convRule: rule124
  }, {
      start: 4240,
      length: 10,
      convRule: rule8
  }, {
      start: 4250,
      length: 3,
      convRule: rule124
  }, {
      start: 4253,
      length: 1,
      convRule: rule92
  }, {
      start: 4254,
      length: 2,
      convRule: rule13
  }, {
      start: 4256,
      length: 38,
      convRule: rule125
  }, {
      start: 4295,
      length: 1,
      convRule: rule125
  }, {
      start: 4301,
      length: 1,
      convRule: rule125
  }, {
      start: 4304,
      length: 43,
      convRule: rule126
  }, {
      start: 4347,
      length: 1,
      convRule: rule2
  }, {
      start: 4348,
      length: 1,
      convRule: rule91
  }, {
      start: 4349,
      length: 3,
      convRule: rule126
  }, {
      start: 4352,
      length: 329,
      convRule: rule14
  }, {
      start: 4682,
      length: 4,
      convRule: rule14
  }, {
      start: 4688,
      length: 7,
      convRule: rule14
  }, {
      start: 4696,
      length: 1,
      convRule: rule14
  }, {
      start: 4698,
      length: 4,
      convRule: rule14
  }, {
      start: 4704,
      length: 41,
      convRule: rule14
  }, {
      start: 4746,
      length: 4,
      convRule: rule14
  }, {
      start: 4752,
      length: 33,
      convRule: rule14
  }, {
      start: 4786,
      length: 4,
      convRule: rule14
  }, {
      start: 4792,
      length: 7,
      convRule: rule14
  }, {
      start: 4800,
      length: 1,
      convRule: rule14
  }, {
      start: 4802,
      length: 4,
      convRule: rule14
  }, {
      start: 4808,
      length: 15,
      convRule: rule14
  }, {
      start: 4824,
      length: 57,
      convRule: rule14
  }, {
      start: 4882,
      length: 4,
      convRule: rule14
  }, {
      start: 4888,
      length: 67,
      convRule: rule14
  }, {
      start: 4957,
      length: 3,
      convRule: rule92
  }, {
      start: 4960,
      length: 9,
      convRule: rule2
  }, {
      start: 4969,
      length: 20,
      convRule: rule17
  }, {
      start: 4992,
      length: 16,
      convRule: rule14
  }, {
      start: 5008,
      length: 10,
      convRule: rule13
  }, {
      start: 5024,
      length: 80,
      convRule: rule127
  }, {
      start: 5104,
      length: 6,
      convRule: rule104
  }, {
      start: 5112,
      length: 6,
      convRule: rule110
  }, {
      start: 5120,
      length: 1,
      convRule: rule7
  }, {
      start: 5121,
      length: 620,
      convRule: rule14
  }, {
      start: 5741,
      length: 1,
      convRule: rule13
  }, {
      start: 5742,
      length: 1,
      convRule: rule2
  }, {
      start: 5743,
      length: 17,
      convRule: rule14
  }, {
      start: 5760,
      length: 1,
      convRule: rule1
  }, {
      start: 5761,
      length: 26,
      convRule: rule14
  }, {
      start: 5787,
      length: 1,
      convRule: rule4
  }, {
      start: 5788,
      length: 1,
      convRule: rule5
  }, {
      start: 5792,
      length: 75,
      convRule: rule14
  }, {
      start: 5867,
      length: 3,
      convRule: rule2
  }, {
      start: 5870,
      length: 3,
      convRule: rule128
  }, {
      start: 5873,
      length: 8,
      convRule: rule14
  }, {
      start: 5888,
      length: 13,
      convRule: rule14
  }, {
      start: 5902,
      length: 4,
      convRule: rule14
  }, {
      start: 5906,
      length: 3,
      convRule: rule92
  }, {
      start: 5920,
      length: 18,
      convRule: rule14
  }, {
      start: 5938,
      length: 3,
      convRule: rule92
  }, {
      start: 5941,
      length: 2,
      convRule: rule2
  }, {
      start: 5952,
      length: 18,
      convRule: rule14
  }, {
      start: 5970,
      length: 2,
      convRule: rule92
  }, {
      start: 5984,
      length: 13,
      convRule: rule14
  }, {
      start: 5998,
      length: 3,
      convRule: rule14
  }, {
      start: 6002,
      length: 2,
      convRule: rule92
  }, {
      start: 6016,
      length: 52,
      convRule: rule14
  }, {
      start: 6068,
      length: 2,
      convRule: rule92
  }, {
      start: 6070,
      length: 1,
      convRule: rule124
  }, {
      start: 6071,
      length: 7,
      convRule: rule92
  }, {
      start: 6078,
      length: 8,
      convRule: rule124
  }, {
      start: 6086,
      length: 1,
      convRule: rule92
  }, {
      start: 6087,
      length: 2,
      convRule: rule124
  }, {
      start: 6089,
      length: 11,
      convRule: rule92
  }, {
      start: 6100,
      length: 3,
      convRule: rule2
  }, {
      start: 6103,
      length: 1,
      convRule: rule91
  }, {
      start: 6104,
      length: 3,
      convRule: rule2
  }, {
      start: 6107,
      length: 1,
      convRule: rule3
  }, {
      start: 6108,
      length: 1,
      convRule: rule14
  }, {
      start: 6109,
      length: 1,
      convRule: rule92
  }, {
      start: 6112,
      length: 10,
      convRule: rule8
  }, {
      start: 6128,
      length: 10,
      convRule: rule17
  }, {
      start: 6144,
      length: 6,
      convRule: rule2
  }, {
      start: 6150,
      length: 1,
      convRule: rule7
  }, {
      start: 6151,
      length: 4,
      convRule: rule2
  }, {
      start: 6155,
      length: 3,
      convRule: rule92
  }, {
      start: 6158,
      length: 1,
      convRule: rule16
  }, {
      start: 6160,
      length: 10,
      convRule: rule8
  }, {
      start: 6176,
      length: 35,
      convRule: rule14
  }, {
      start: 6211,
      length: 1,
      convRule: rule91
  }, {
      start: 6212,
      length: 53,
      convRule: rule14
  }, {
      start: 6272,
      length: 5,
      convRule: rule14
  }, {
      start: 6277,
      length: 2,
      convRule: rule92
  }, {
      start: 6279,
      length: 34,
      convRule: rule14
  }, {
      start: 6313,
      length: 1,
      convRule: rule92
  }, {
      start: 6314,
      length: 1,
      convRule: rule14
  }, {
      start: 6320,
      length: 70,
      convRule: rule14
  }, {
      start: 6400,
      length: 31,
      convRule: rule14
  }, {
      start: 6432,
      length: 3,
      convRule: rule92
  }, {
      start: 6435,
      length: 4,
      convRule: rule124
  }, {
      start: 6439,
      length: 2,
      convRule: rule92
  }, {
      start: 6441,
      length: 3,
      convRule: rule124
  }, {
      start: 6448,
      length: 2,
      convRule: rule124
  }, {
      start: 6450,
      length: 1,
      convRule: rule92
  }, {
      start: 6451,
      length: 6,
      convRule: rule124
  }, {
      start: 6457,
      length: 3,
      convRule: rule92
  }, {
      start: 6464,
      length: 1,
      convRule: rule13
  }, {
      start: 6468,
      length: 2,
      convRule: rule2
  }, {
      start: 6470,
      length: 10,
      convRule: rule8
  }, {
      start: 6480,
      length: 30,
      convRule: rule14
  }, {
      start: 6512,
      length: 5,
      convRule: rule14
  }, {
      start: 6528,
      length: 44,
      convRule: rule14
  }, {
      start: 6576,
      length: 26,
      convRule: rule14
  }, {
      start: 6608,
      length: 10,
      convRule: rule8
  }, {
      start: 6618,
      length: 1,
      convRule: rule17
  }, {
      start: 6622,
      length: 34,
      convRule: rule13
  }, {
      start: 6656,
      length: 23,
      convRule: rule14
  }, {
      start: 6679,
      length: 2,
      convRule: rule92
  }, {
      start: 6681,
      length: 2,
      convRule: rule124
  }, {
      start: 6683,
      length: 1,
      convRule: rule92
  }, {
      start: 6686,
      length: 2,
      convRule: rule2
  }, {
      start: 6688,
      length: 53,
      convRule: rule14
  }, {
      start: 6741,
      length: 1,
      convRule: rule124
  }, {
      start: 6742,
      length: 1,
      convRule: rule92
  }, {
      start: 6743,
      length: 1,
      convRule: rule124
  }, {
      start: 6744,
      length: 7,
      convRule: rule92
  }, {
      start: 6752,
      length: 1,
      convRule: rule92
  }, {
      start: 6753,
      length: 1,
      convRule: rule124
  }, {
      start: 6754,
      length: 1,
      convRule: rule92
  }, {
      start: 6755,
      length: 2,
      convRule: rule124
  }, {
      start: 6757,
      length: 8,
      convRule: rule92
  }, {
      start: 6765,
      length: 6,
      convRule: rule124
  }, {
      start: 6771,
      length: 10,
      convRule: rule92
  }, {
      start: 6783,
      length: 1,
      convRule: rule92
  }, {
      start: 6784,
      length: 10,
      convRule: rule8
  }, {
      start: 6800,
      length: 10,
      convRule: rule8
  }, {
      start: 6816,
      length: 7,
      convRule: rule2
  }, {
      start: 6823,
      length: 1,
      convRule: rule91
  }, {
      start: 6824,
      length: 6,
      convRule: rule2
  }, {
      start: 6832,
      length: 14,
      convRule: rule92
  }, {
      start: 6846,
      length: 1,
      convRule: rule119
  }, {
      start: 6847,
      length: 2,
      convRule: rule92
  }, {
      start: 6912,
      length: 4,
      convRule: rule92
  }, {
      start: 6916,
      length: 1,
      convRule: rule124
  }, {
      start: 6917,
      length: 47,
      convRule: rule14
  }, {
      start: 6964,
      length: 1,
      convRule: rule92
  }, {
      start: 6965,
      length: 1,
      convRule: rule124
  }, {
      start: 6966,
      length: 5,
      convRule: rule92
  }, {
      start: 6971,
      length: 1,
      convRule: rule124
  }, {
      start: 6972,
      length: 1,
      convRule: rule92
  }, {
      start: 6973,
      length: 5,
      convRule: rule124
  }, {
      start: 6978,
      length: 1,
      convRule: rule92
  }, {
      start: 6979,
      length: 2,
      convRule: rule124
  }, {
      start: 6981,
      length: 7,
      convRule: rule14
  }, {
      start: 6992,
      length: 10,
      convRule: rule8
  }, {
      start: 7002,
      length: 7,
      convRule: rule2
  }, {
      start: 7009,
      length: 10,
      convRule: rule13
  }, {
      start: 7019,
      length: 9,
      convRule: rule92
  }, {
      start: 7028,
      length: 9,
      convRule: rule13
  }, {
      start: 7040,
      length: 2,
      convRule: rule92
  }, {
      start: 7042,
      length: 1,
      convRule: rule124
  }, {
      start: 7043,
      length: 30,
      convRule: rule14
  }, {
      start: 7073,
      length: 1,
      convRule: rule124
  }, {
      start: 7074,
      length: 4,
      convRule: rule92
  }, {
      start: 7078,
      length: 2,
      convRule: rule124
  }, {
      start: 7080,
      length: 2,
      convRule: rule92
  }, {
      start: 7082,
      length: 1,
      convRule: rule124
  }, {
      start: 7083,
      length: 3,
      convRule: rule92
  }, {
      start: 7086,
      length: 2,
      convRule: rule14
  }, {
      start: 7088,
      length: 10,
      convRule: rule8
  }, {
      start: 7098,
      length: 44,
      convRule: rule14
  }, {
      start: 7142,
      length: 1,
      convRule: rule92
  }, {
      start: 7143,
      length: 1,
      convRule: rule124
  }, {
      start: 7144,
      length: 2,
      convRule: rule92
  }, {
      start: 7146,
      length: 3,
      convRule: rule124
  }, {
      start: 7149,
      length: 1,
      convRule: rule92
  }, {
      start: 7150,
      length: 1,
      convRule: rule124
  }, {
      start: 7151,
      length: 3,
      convRule: rule92
  }, {
      start: 7154,
      length: 2,
      convRule: rule124
  }, {
      start: 7164,
      length: 4,
      convRule: rule2
  }, {
      start: 7168,
      length: 36,
      convRule: rule14
  }, {
      start: 7204,
      length: 8,
      convRule: rule124
  }, {
      start: 7212,
      length: 8,
      convRule: rule92
  }, {
      start: 7220,
      length: 2,
      convRule: rule124
  }, {
      start: 7222,
      length: 2,
      convRule: rule92
  }, {
      start: 7227,
      length: 5,
      convRule: rule2
  }, {
      start: 7232,
      length: 10,
      convRule: rule8
  }, {
      start: 7245,
      length: 3,
      convRule: rule14
  }, {
      start: 7248,
      length: 10,
      convRule: rule8
  }, {
      start: 7258,
      length: 30,
      convRule: rule14
  }, {
      start: 7288,
      length: 6,
      convRule: rule91
  }, {
      start: 7294,
      length: 2,
      convRule: rule2
  }, {
      start: 7296,
      length: 1,
      convRule: rule129
  }, {
      start: 7297,
      length: 1,
      convRule: rule130
  }, {
      start: 7298,
      length: 1,
      convRule: rule131
  }, {
      start: 7299,
      length: 2,
      convRule: rule132
  }, {
      start: 7301,
      length: 1,
      convRule: rule133
  }, {
      start: 7302,
      length: 1,
      convRule: rule134
  }, {
      start: 7303,
      length: 1,
      convRule: rule135
  }, {
      start: 7304,
      length: 1,
      convRule: rule136
  }, {
      start: 7312,
      length: 43,
      convRule: rule137
  }, {
      start: 7357,
      length: 3,
      convRule: rule137
  }, {
      start: 7360,
      length: 8,
      convRule: rule2
  }, {
      start: 7376,
      length: 3,
      convRule: rule92
  }, {
      start: 7379,
      length: 1,
      convRule: rule2
  }, {
      start: 7380,
      length: 13,
      convRule: rule92
  }, {
      start: 7393,
      length: 1,
      convRule: rule124
  }, {
      start: 7394,
      length: 7,
      convRule: rule92
  }, {
      start: 7401,
      length: 4,
      convRule: rule14
  }, {
      start: 7405,
      length: 1,
      convRule: rule92
  }, {
      start: 7406,
      length: 6,
      convRule: rule14
  }, {
      start: 7412,
      length: 1,
      convRule: rule92
  }, {
      start: 7413,
      length: 2,
      convRule: rule14
  }, {
      start: 7415,
      length: 1,
      convRule: rule124
  }, {
      start: 7416,
      length: 2,
      convRule: rule92
  }, {
      start: 7418,
      length: 1,
      convRule: rule14
  }, {
      start: 7424,
      length: 44,
      convRule: rule20
  }, {
      start: 7468,
      length: 63,
      convRule: rule91
  }, {
      start: 7531,
      length: 13,
      convRule: rule20
  }, {
      start: 7544,
      length: 1,
      convRule: rule91
  }, {
      start: 7545,
      length: 1,
      convRule: rule138
  }, {
      start: 7546,
      length: 3,
      convRule: rule20
  }, {
      start: 7549,
      length: 1,
      convRule: rule139
  }, {
      start: 7550,
      length: 16,
      convRule: rule20
  }, {
      start: 7566,
      length: 1,
      convRule: rule140
  }, {
      start: 7567,
      length: 12,
      convRule: rule20
  }, {
      start: 7579,
      length: 37,
      convRule: rule91
  }, {
      start: 7616,
      length: 58,
      convRule: rule92
  }, {
      start: 7675,
      length: 5,
      convRule: rule92
  }, {
      start: 7680,
      length: 1,
      convRule: rule22
  }, {
      start: 7681,
      length: 1,
      convRule: rule23
  }, {
      start: 7682,
      length: 1,
      convRule: rule22
  }, {
      start: 7683,
      length: 1,
      convRule: rule23
  }, {
      start: 7684,
      length: 1,
      convRule: rule22
  }, {
      start: 7685,
      length: 1,
      convRule: rule23
  }, {
      start: 7686,
      length: 1,
      convRule: rule22
  }, {
      start: 7687,
      length: 1,
      convRule: rule23
  }, {
      start: 7688,
      length: 1,
      convRule: rule22
  }, {
      start: 7689,
      length: 1,
      convRule: rule23
  }, {
      start: 7690,
      length: 1,
      convRule: rule22
  }, {
      start: 7691,
      length: 1,
      convRule: rule23
  }, {
      start: 7692,
      length: 1,
      convRule: rule22
  }, {
      start: 7693,
      length: 1,
      convRule: rule23
  }, {
      start: 7694,
      length: 1,
      convRule: rule22
  }, {
      start: 7695,
      length: 1,
      convRule: rule23
  }, {
      start: 7696,
      length: 1,
      convRule: rule22
  }, {
      start: 7697,
      length: 1,
      convRule: rule23
  }, {
      start: 7698,
      length: 1,
      convRule: rule22
  }, {
      start: 7699,
      length: 1,
      convRule: rule23
  }, {
      start: 7700,
      length: 1,
      convRule: rule22
  }, {
      start: 7701,
      length: 1,
      convRule: rule23
  }, {
      start: 7702,
      length: 1,
      convRule: rule22
  }, {
      start: 7703,
      length: 1,
      convRule: rule23
  }, {
      start: 7704,
      length: 1,
      convRule: rule22
  }, {
      start: 7705,
      length: 1,
      convRule: rule23
  }, {
      start: 7706,
      length: 1,
      convRule: rule22
  }, {
      start: 7707,
      length: 1,
      convRule: rule23
  }, {
      start: 7708,
      length: 1,
      convRule: rule22
  }, {
      start: 7709,
      length: 1,
      convRule: rule23
  }, {
      start: 7710,
      length: 1,
      convRule: rule22
  }, {
      start: 7711,
      length: 1,
      convRule: rule23
  }, {
      start: 7712,
      length: 1,
      convRule: rule22
  }, {
      start: 7713,
      length: 1,
      convRule: rule23
  }, {
      start: 7714,
      length: 1,
      convRule: rule22
  }, {
      start: 7715,
      length: 1,
      convRule: rule23
  }, {
      start: 7716,
      length: 1,
      convRule: rule22
  }, {
      start: 7717,
      length: 1,
      convRule: rule23
  }, {
      start: 7718,
      length: 1,
      convRule: rule22
  }, {
      start: 7719,
      length: 1,
      convRule: rule23
  }, {
      start: 7720,
      length: 1,
      convRule: rule22
  }, {
      start: 7721,
      length: 1,
      convRule: rule23
  }, {
      start: 7722,
      length: 1,
      convRule: rule22
  }, {
      start: 7723,
      length: 1,
      convRule: rule23
  }, {
      start: 7724,
      length: 1,
      convRule: rule22
  }, {
      start: 7725,
      length: 1,
      convRule: rule23
  }, {
      start: 7726,
      length: 1,
      convRule: rule22
  }, {
      start: 7727,
      length: 1,
      convRule: rule23
  }, {
      start: 7728,
      length: 1,
      convRule: rule22
  }, {
      start: 7729,
      length: 1,
      convRule: rule23
  }, {
      start: 7730,
      length: 1,
      convRule: rule22
  }, {
      start: 7731,
      length: 1,
      convRule: rule23
  }, {
      start: 7732,
      length: 1,
      convRule: rule22
  }, {
      start: 7733,
      length: 1,
      convRule: rule23
  }, {
      start: 7734,
      length: 1,
      convRule: rule22
  }, {
      start: 7735,
      length: 1,
      convRule: rule23
  }, {
      start: 7736,
      length: 1,
      convRule: rule22
  }, {
      start: 7737,
      length: 1,
      convRule: rule23
  }, {
      start: 7738,
      length: 1,
      convRule: rule22
  }, {
      start: 7739,
      length: 1,
      convRule: rule23
  }, {
      start: 7740,
      length: 1,
      convRule: rule22
  }, {
      start: 7741,
      length: 1,
      convRule: rule23
  }, {
      start: 7742,
      length: 1,
      convRule: rule22
  }, {
      start: 7743,
      length: 1,
      convRule: rule23
  }, {
      start: 7744,
      length: 1,
      convRule: rule22
  }, {
      start: 7745,
      length: 1,
      convRule: rule23
  }, {
      start: 7746,
      length: 1,
      convRule: rule22
  }, {
      start: 7747,
      length: 1,
      convRule: rule23
  }, {
      start: 7748,
      length: 1,
      convRule: rule22
  }, {
      start: 7749,
      length: 1,
      convRule: rule23
  }, {
      start: 7750,
      length: 1,
      convRule: rule22
  }, {
      start: 7751,
      length: 1,
      convRule: rule23
  }, {
      start: 7752,
      length: 1,
      convRule: rule22
  }, {
      start: 7753,
      length: 1,
      convRule: rule23
  }, {
      start: 7754,
      length: 1,
      convRule: rule22
  }, {
      start: 7755,
      length: 1,
      convRule: rule23
  }, {
      start: 7756,
      length: 1,
      convRule: rule22
  }, {
      start: 7757,
      length: 1,
      convRule: rule23
  }, {
      start: 7758,
      length: 1,
      convRule: rule22
  }, {
      start: 7759,
      length: 1,
      convRule: rule23
  }, {
      start: 7760,
      length: 1,
      convRule: rule22
  }, {
      start: 7761,
      length: 1,
      convRule: rule23
  }, {
      start: 7762,
      length: 1,
      convRule: rule22
  }, {
      start: 7763,
      length: 1,
      convRule: rule23
  }, {
      start: 7764,
      length: 1,
      convRule: rule22
  }, {
      start: 7765,
      length: 1,
      convRule: rule23
  }, {
      start: 7766,
      length: 1,
      convRule: rule22
  }, {
      start: 7767,
      length: 1,
      convRule: rule23
  }, {
      start: 7768,
      length: 1,
      convRule: rule22
  }, {
      start: 7769,
      length: 1,
      convRule: rule23
  }, {
      start: 7770,
      length: 1,
      convRule: rule22
  }, {
      start: 7771,
      length: 1,
      convRule: rule23
  }, {
      start: 7772,
      length: 1,
      convRule: rule22
  }, {
      start: 7773,
      length: 1,
      convRule: rule23
  }, {
      start: 7774,
      length: 1,
      convRule: rule22
  }, {
      start: 7775,
      length: 1,
      convRule: rule23
  }, {
      start: 7776,
      length: 1,
      convRule: rule22
  }, {
      start: 7777,
      length: 1,
      convRule: rule23
  }, {
      start: 7778,
      length: 1,
      convRule: rule22
  }, {
      start: 7779,
      length: 1,
      convRule: rule23
  }, {
      start: 7780,
      length: 1,
      convRule: rule22
  }, {
      start: 7781,
      length: 1,
      convRule: rule23
  }, {
      start: 7782,
      length: 1,
      convRule: rule22
  }, {
      start: 7783,
      length: 1,
      convRule: rule23
  }, {
      start: 7784,
      length: 1,
      convRule: rule22
  }, {
      start: 7785,
      length: 1,
      convRule: rule23
  }, {
      start: 7786,
      length: 1,
      convRule: rule22
  }, {
      start: 7787,
      length: 1,
      convRule: rule23
  }, {
      start: 7788,
      length: 1,
      convRule: rule22
  }, {
      start: 7789,
      length: 1,
      convRule: rule23
  }, {
      start: 7790,
      length: 1,
      convRule: rule22
  }, {
      start: 7791,
      length: 1,
      convRule: rule23
  }, {
      start: 7792,
      length: 1,
      convRule: rule22
  }, {
      start: 7793,
      length: 1,
      convRule: rule23
  }, {
      start: 7794,
      length: 1,
      convRule: rule22
  }, {
      start: 7795,
      length: 1,
      convRule: rule23
  }, {
      start: 7796,
      length: 1,
      convRule: rule22
  }, {
      start: 7797,
      length: 1,
      convRule: rule23
  }, {
      start: 7798,
      length: 1,
      convRule: rule22
  }, {
      start: 7799,
      length: 1,
      convRule: rule23
  }, {
      start: 7800,
      length: 1,
      convRule: rule22
  }, {
      start: 7801,
      length: 1,
      convRule: rule23
  }, {
      start: 7802,
      length: 1,
      convRule: rule22
  }, {
      start: 7803,
      length: 1,
      convRule: rule23
  }, {
      start: 7804,
      length: 1,
      convRule: rule22
  }, {
      start: 7805,
      length: 1,
      convRule: rule23
  }, {
      start: 7806,
      length: 1,
      convRule: rule22
  }, {
      start: 7807,
      length: 1,
      convRule: rule23
  }, {
      start: 7808,
      length: 1,
      convRule: rule22
  }, {
      start: 7809,
      length: 1,
      convRule: rule23
  }, {
      start: 7810,
      length: 1,
      convRule: rule22
  }, {
      start: 7811,
      length: 1,
      convRule: rule23
  }, {
      start: 7812,
      length: 1,
      convRule: rule22
  }, {
      start: 7813,
      length: 1,
      convRule: rule23
  }, {
      start: 7814,
      length: 1,
      convRule: rule22
  }, {
      start: 7815,
      length: 1,
      convRule: rule23
  }, {
      start: 7816,
      length: 1,
      convRule: rule22
  }, {
      start: 7817,
      length: 1,
      convRule: rule23
  }, {
      start: 7818,
      length: 1,
      convRule: rule22
  }, {
      start: 7819,
      length: 1,
      convRule: rule23
  }, {
      start: 7820,
      length: 1,
      convRule: rule22
  }, {
      start: 7821,
      length: 1,
      convRule: rule23
  }, {
      start: 7822,
      length: 1,
      convRule: rule22
  }, {
      start: 7823,
      length: 1,
      convRule: rule23
  }, {
      start: 7824,
      length: 1,
      convRule: rule22
  }, {
      start: 7825,
      length: 1,
      convRule: rule23
  }, {
      start: 7826,
      length: 1,
      convRule: rule22
  }, {
      start: 7827,
      length: 1,
      convRule: rule23
  }, {
      start: 7828,
      length: 1,
      convRule: rule22
  }, {
      start: 7829,
      length: 1,
      convRule: rule23
  }, {
      start: 7830,
      length: 5,
      convRule: rule20
  }, {
      start: 7835,
      length: 1,
      convRule: rule141
  }, {
      start: 7836,
      length: 2,
      convRule: rule20
  }, {
      start: 7838,
      length: 1,
      convRule: rule142
  }, {
      start: 7839,
      length: 1,
      convRule: rule20
  }, {
      start: 7840,
      length: 1,
      convRule: rule22
  }, {
      start: 7841,
      length: 1,
      convRule: rule23
  }, {
      start: 7842,
      length: 1,
      convRule: rule22
  }, {
      start: 7843,
      length: 1,
      convRule: rule23
  }, {
      start: 7844,
      length: 1,
      convRule: rule22
  }, {
      start: 7845,
      length: 1,
      convRule: rule23
  }, {
      start: 7846,
      length: 1,
      convRule: rule22
  }, {
      start: 7847,
      length: 1,
      convRule: rule23
  }, {
      start: 7848,
      length: 1,
      convRule: rule22
  }, {
      start: 7849,
      length: 1,
      convRule: rule23
  }, {
      start: 7850,
      length: 1,
      convRule: rule22
  }, {
      start: 7851,
      length: 1,
      convRule: rule23
  }, {
      start: 7852,
      length: 1,
      convRule: rule22
  }, {
      start: 7853,
      length: 1,
      convRule: rule23
  }, {
      start: 7854,
      length: 1,
      convRule: rule22
  }, {
      start: 7855,
      length: 1,
      convRule: rule23
  }, {
      start: 7856,
      length: 1,
      convRule: rule22
  }, {
      start: 7857,
      length: 1,
      convRule: rule23
  }, {
      start: 7858,
      length: 1,
      convRule: rule22
  }, {
      start: 7859,
      length: 1,
      convRule: rule23
  }, {
      start: 7860,
      length: 1,
      convRule: rule22
  }, {
      start: 7861,
      length: 1,
      convRule: rule23
  }, {
      start: 7862,
      length: 1,
      convRule: rule22
  }, {
      start: 7863,
      length: 1,
      convRule: rule23
  }, {
      start: 7864,
      length: 1,
      convRule: rule22
  }, {
      start: 7865,
      length: 1,
      convRule: rule23
  }, {
      start: 7866,
      length: 1,
      convRule: rule22
  }, {
      start: 7867,
      length: 1,
      convRule: rule23
  }, {
      start: 7868,
      length: 1,
      convRule: rule22
  }, {
      start: 7869,
      length: 1,
      convRule: rule23
  }, {
      start: 7870,
      length: 1,
      convRule: rule22
  }, {
      start: 7871,
      length: 1,
      convRule: rule23
  }, {
      start: 7872,
      length: 1,
      convRule: rule22
  }, {
      start: 7873,
      length: 1,
      convRule: rule23
  }, {
      start: 7874,
      length: 1,
      convRule: rule22
  }, {
      start: 7875,
      length: 1,
      convRule: rule23
  }, {
      start: 7876,
      length: 1,
      convRule: rule22
  }, {
      start: 7877,
      length: 1,
      convRule: rule23
  }, {
      start: 7878,
      length: 1,
      convRule: rule22
  }, {
      start: 7879,
      length: 1,
      convRule: rule23
  }, {
      start: 7880,
      length: 1,
      convRule: rule22
  }, {
      start: 7881,
      length: 1,
      convRule: rule23
  }, {
      start: 7882,
      length: 1,
      convRule: rule22
  }, {
      start: 7883,
      length: 1,
      convRule: rule23
  }, {
      start: 7884,
      length: 1,
      convRule: rule22
  }, {
      start: 7885,
      length: 1,
      convRule: rule23
  }, {
      start: 7886,
      length: 1,
      convRule: rule22
  }, {
      start: 7887,
      length: 1,
      convRule: rule23
  }, {
      start: 7888,
      length: 1,
      convRule: rule22
  }, {
      start: 7889,
      length: 1,
      convRule: rule23
  }, {
      start: 7890,
      length: 1,
      convRule: rule22
  }, {
      start: 7891,
      length: 1,
      convRule: rule23
  }, {
      start: 7892,
      length: 1,
      convRule: rule22
  }, {
      start: 7893,
      length: 1,
      convRule: rule23
  }, {
      start: 7894,
      length: 1,
      convRule: rule22
  }, {
      start: 7895,
      length: 1,
      convRule: rule23
  }, {
      start: 7896,
      length: 1,
      convRule: rule22
  }, {
      start: 7897,
      length: 1,
      convRule: rule23
  }, {
      start: 7898,
      length: 1,
      convRule: rule22
  }, {
      start: 7899,
      length: 1,
      convRule: rule23
  }, {
      start: 7900,
      length: 1,
      convRule: rule22
  }, {
      start: 7901,
      length: 1,
      convRule: rule23
  }, {
      start: 7902,
      length: 1,
      convRule: rule22
  }, {
      start: 7903,
      length: 1,
      convRule: rule23
  }, {
      start: 7904,
      length: 1,
      convRule: rule22
  }, {
      start: 7905,
      length: 1,
      convRule: rule23
  }, {
      start: 7906,
      length: 1,
      convRule: rule22
  }, {
      start: 7907,
      length: 1,
      convRule: rule23
  }, {
      start: 7908,
      length: 1,
      convRule: rule22
  }, {
      start: 7909,
      length: 1,
      convRule: rule23
  }, {
      start: 7910,
      length: 1,
      convRule: rule22
  }, {
      start: 7911,
      length: 1,
      convRule: rule23
  }, {
      start: 7912,
      length: 1,
      convRule: rule22
  }, {
      start: 7913,
      length: 1,
      convRule: rule23
  }, {
      start: 7914,
      length: 1,
      convRule: rule22
  }, {
      start: 7915,
      length: 1,
      convRule: rule23
  }, {
      start: 7916,
      length: 1,
      convRule: rule22
  }, {
      start: 7917,
      length: 1,
      convRule: rule23
  }, {
      start: 7918,
      length: 1,
      convRule: rule22
  }, {
      start: 7919,
      length: 1,
      convRule: rule23
  }, {
      start: 7920,
      length: 1,
      convRule: rule22
  }, {
      start: 7921,
      length: 1,
      convRule: rule23
  }, {
      start: 7922,
      length: 1,
      convRule: rule22
  }, {
      start: 7923,
      length: 1,
      convRule: rule23
  }, {
      start: 7924,
      length: 1,
      convRule: rule22
  }, {
      start: 7925,
      length: 1,
      convRule: rule23
  }, {
      start: 7926,
      length: 1,
      convRule: rule22
  }, {
      start: 7927,
      length: 1,
      convRule: rule23
  }, {
      start: 7928,
      length: 1,
      convRule: rule22
  }, {
      start: 7929,
      length: 1,
      convRule: rule23
  }, {
      start: 7930,
      length: 1,
      convRule: rule22
  }, {
      start: 7931,
      length: 1,
      convRule: rule23
  }, {
      start: 7932,
      length: 1,
      convRule: rule22
  }, {
      start: 7933,
      length: 1,
      convRule: rule23
  }, {
      start: 7934,
      length: 1,
      convRule: rule22
  }, {
      start: 7935,
      length: 1,
      convRule: rule23
  }, {
      start: 7936,
      length: 8,
      convRule: rule143
  }, {
      start: 7944,
      length: 8,
      convRule: rule144
  }, {
      start: 7952,
      length: 6,
      convRule: rule143
  }, {
      start: 7960,
      length: 6,
      convRule: rule144
  }, {
      start: 7968,
      length: 8,
      convRule: rule143
  }, {
      start: 7976,
      length: 8,
      convRule: rule144
  }, {
      start: 7984,
      length: 8,
      convRule: rule143
  }, {
      start: 7992,
      length: 8,
      convRule: rule144
  }, {
      start: 8000,
      length: 6,
      convRule: rule143
  }, {
      start: 8008,
      length: 6,
      convRule: rule144
  }, {
      start: 8016,
      length: 1,
      convRule: rule20
  }, {
      start: 8017,
      length: 1,
      convRule: rule143
  }, {
      start: 8018,
      length: 1,
      convRule: rule20
  }, {
      start: 8019,
      length: 1,
      convRule: rule143
  }, {
      start: 8020,
      length: 1,
      convRule: rule20
  }, {
      start: 8021,
      length: 1,
      convRule: rule143
  }, {
      start: 8022,
      length: 1,
      convRule: rule20
  }, {
      start: 8023,
      length: 1,
      convRule: rule143
  }, {
      start: 8025,
      length: 1,
      convRule: rule144
  }, {
      start: 8027,
      length: 1,
      convRule: rule144
  }, {
      start: 8029,
      length: 1,
      convRule: rule144
  }, {
      start: 8031,
      length: 1,
      convRule: rule144
  }, {
      start: 8032,
      length: 8,
      convRule: rule143
  }, {
      start: 8040,
      length: 8,
      convRule: rule144
  }, {
      start: 8048,
      length: 2,
      convRule: rule145
  }, {
      start: 8050,
      length: 4,
      convRule: rule146
  }, {
      start: 8054,
      length: 2,
      convRule: rule147
  }, {
      start: 8056,
      length: 2,
      convRule: rule148
  }, {
      start: 8058,
      length: 2,
      convRule: rule149
  }, {
      start: 8060,
      length: 2,
      convRule: rule150
  }, {
      start: 8064,
      length: 8,
      convRule: rule143
  }, {
      start: 8072,
      length: 8,
      convRule: rule151
  }, {
      start: 8080,
      length: 8,
      convRule: rule143
  }, {
      start: 8088,
      length: 8,
      convRule: rule151
  }, {
      start: 8096,
      length: 8,
      convRule: rule143
  }, {
      start: 8104,
      length: 8,
      convRule: rule151
  }, {
      start: 8112,
      length: 2,
      convRule: rule143
  }, {
      start: 8114,
      length: 1,
      convRule: rule20
  }, {
      start: 8115,
      length: 1,
      convRule: rule152
  }, {
      start: 8116,
      length: 1,
      convRule: rule20
  }, {
      start: 8118,
      length: 2,
      convRule: rule20
  }, {
      start: 8120,
      length: 2,
      convRule: rule144
  }, {
      start: 8122,
      length: 2,
      convRule: rule153
  }, {
      start: 8124,
      length: 1,
      convRule: rule154
  }, {
      start: 8125,
      length: 1,
      convRule: rule10
  }, {
      start: 8126,
      length: 1,
      convRule: rule155
  }, {
      start: 8127,
      length: 3,
      convRule: rule10
  }, {
      start: 8130,
      length: 1,
      convRule: rule20
  }, {
      start: 8131,
      length: 1,
      convRule: rule152
  }, {
      start: 8132,
      length: 1,
      convRule: rule20
  }, {
      start: 8134,
      length: 2,
      convRule: rule20
  }, {
      start: 8136,
      length: 4,
      convRule: rule156
  }, {
      start: 8140,
      length: 1,
      convRule: rule154
  }, {
      start: 8141,
      length: 3,
      convRule: rule10
  }, {
      start: 8144,
      length: 2,
      convRule: rule143
  }, {
      start: 8146,
      length: 2,
      convRule: rule20
  }, {
      start: 8150,
      length: 2,
      convRule: rule20
  }, {
      start: 8152,
      length: 2,
      convRule: rule144
  }, {
      start: 8154,
      length: 2,
      convRule: rule157
  }, {
      start: 8157,
      length: 3,
      convRule: rule10
  }, {
      start: 8160,
      length: 2,
      convRule: rule143
  }, {
      start: 8162,
      length: 3,
      convRule: rule20
  }, {
      start: 8165,
      length: 1,
      convRule: rule113
  }, {
      start: 8166,
      length: 2,
      convRule: rule20
  }, {
      start: 8168,
      length: 2,
      convRule: rule144
  }, {
      start: 8170,
      length: 2,
      convRule: rule158
  }, {
      start: 8172,
      length: 1,
      convRule: rule117
  }, {
      start: 8173,
      length: 3,
      convRule: rule10
  }, {
      start: 8178,
      length: 1,
      convRule: rule20
  }, {
      start: 8179,
      length: 1,
      convRule: rule152
  }, {
      start: 8180,
      length: 1,
      convRule: rule20
  }, {
      start: 8182,
      length: 2,
      convRule: rule20
  }, {
      start: 8184,
      length: 2,
      convRule: rule159
  }, {
      start: 8186,
      length: 2,
      convRule: rule160
  }, {
      start: 8188,
      length: 1,
      convRule: rule154
  }, {
      start: 8189,
      length: 2,
      convRule: rule10
  }, {
      start: 8192,
      length: 11,
      convRule: rule1
  }, {
      start: 8203,
      length: 5,
      convRule: rule16
  }, {
      start: 8208,
      length: 6,
      convRule: rule7
  }, {
      start: 8214,
      length: 2,
      convRule: rule2
  }, {
      start: 8216,
      length: 1,
      convRule: rule15
  }, {
      start: 8217,
      length: 1,
      convRule: rule19
  }, {
      start: 8218,
      length: 1,
      convRule: rule4
  }, {
      start: 8219,
      length: 2,
      convRule: rule15
  }, {
      start: 8221,
      length: 1,
      convRule: rule19
  }, {
      start: 8222,
      length: 1,
      convRule: rule4
  }, {
      start: 8223,
      length: 1,
      convRule: rule15
  }, {
      start: 8224,
      length: 8,
      convRule: rule2
  }, {
      start: 8232,
      length: 1,
      convRule: rule161
  }, {
      start: 8233,
      length: 1,
      convRule: rule162
  }, {
      start: 8234,
      length: 5,
      convRule: rule16
  }, {
      start: 8239,
      length: 1,
      convRule: rule1
  }, {
      start: 8240,
      length: 9,
      convRule: rule2
  }, {
      start: 8249,
      length: 1,
      convRule: rule15
  }, {
      start: 8250,
      length: 1,
      convRule: rule19
  }, {
      start: 8251,
      length: 4,
      convRule: rule2
  }, {
      start: 8255,
      length: 2,
      convRule: rule11
  }, {
      start: 8257,
      length: 3,
      convRule: rule2
  }, {
      start: 8260,
      length: 1,
      convRule: rule6
  }, {
      start: 8261,
      length: 1,
      convRule: rule4
  }, {
      start: 8262,
      length: 1,
      convRule: rule5
  }, {
      start: 8263,
      length: 11,
      convRule: rule2
  }, {
      start: 8274,
      length: 1,
      convRule: rule6
  }, {
      start: 8275,
      length: 1,
      convRule: rule2
  }, {
      start: 8276,
      length: 1,
      convRule: rule11
  }, {
      start: 8277,
      length: 10,
      convRule: rule2
  }, {
      start: 8287,
      length: 1,
      convRule: rule1
  }, {
      start: 8288,
      length: 5,
      convRule: rule16
  }, {
      start: 8294,
      length: 10,
      convRule: rule16
  }, {
      start: 8304,
      length: 1,
      convRule: rule17
  }, {
      start: 8305,
      length: 1,
      convRule: rule91
  }, {
      start: 8308,
      length: 6,
      convRule: rule17
  }, {
      start: 8314,
      length: 3,
      convRule: rule6
  }, {
      start: 8317,
      length: 1,
      convRule: rule4
  }, {
      start: 8318,
      length: 1,
      convRule: rule5
  }, {
      start: 8319,
      length: 1,
      convRule: rule91
  }, {
      start: 8320,
      length: 10,
      convRule: rule17
  }, {
      start: 8330,
      length: 3,
      convRule: rule6
  }, {
      start: 8333,
      length: 1,
      convRule: rule4
  }, {
      start: 8334,
      length: 1,
      convRule: rule5
  }, {
      start: 8336,
      length: 13,
      convRule: rule91
  }, {
      start: 8352,
      length: 32,
      convRule: rule3
  }, {
      start: 8400,
      length: 13,
      convRule: rule92
  }, {
      start: 8413,
      length: 4,
      convRule: rule119
  }, {
      start: 8417,
      length: 1,
      convRule: rule92
  }, {
      start: 8418,
      length: 3,
      convRule: rule119
  }, {
      start: 8421,
      length: 12,
      convRule: rule92
  }, {
      start: 8448,
      length: 2,
      convRule: rule13
  }, {
      start: 8450,
      length: 1,
      convRule: rule107
  }, {
      start: 8451,
      length: 4,
      convRule: rule13
  }, {
      start: 8455,
      length: 1,
      convRule: rule107
  }, {
      start: 8456,
      length: 2,
      convRule: rule13
  }, {
      start: 8458,
      length: 1,
      convRule: rule20
  }, {
      start: 8459,
      length: 3,
      convRule: rule107
  }, {
      start: 8462,
      length: 2,
      convRule: rule20
  }, {
      start: 8464,
      length: 3,
      convRule: rule107
  }, {
      start: 8467,
      length: 1,
      convRule: rule20
  }, {
      start: 8468,
      length: 1,
      convRule: rule13
  }, {
      start: 8469,
      length: 1,
      convRule: rule107
  }, {
      start: 8470,
      length: 2,
      convRule: rule13
  }, {
      start: 8472,
      length: 1,
      convRule: rule6
  }, {
      start: 8473,
      length: 5,
      convRule: rule107
  }, {
      start: 8478,
      length: 6,
      convRule: rule13
  }, {
      start: 8484,
      length: 1,
      convRule: rule107
  }, {
      start: 8485,
      length: 1,
      convRule: rule13
  }, {
      start: 8486,
      length: 1,
      convRule: rule163
  }, {
      start: 8487,
      length: 1,
      convRule: rule13
  }, {
      start: 8488,
      length: 1,
      convRule: rule107
  }, {
      start: 8489,
      length: 1,
      convRule: rule13
  }, {
      start: 8490,
      length: 1,
      convRule: rule164
  }, {
      start: 8491,
      length: 1,
      convRule: rule165
  }, {
      start: 8492,
      length: 2,
      convRule: rule107
  }, {
      start: 8494,
      length: 1,
      convRule: rule13
  }, {
      start: 8495,
      length: 1,
      convRule: rule20
  }, {
      start: 8496,
      length: 2,
      convRule: rule107
  }, {
      start: 8498,
      length: 1,
      convRule: rule166
  }, {
      start: 8499,
      length: 1,
      convRule: rule107
  }, {
      start: 8500,
      length: 1,
      convRule: rule20
  }, {
      start: 8501,
      length: 4,
      convRule: rule14
  }, {
      start: 8505,
      length: 1,
      convRule: rule20
  }, {
      start: 8506,
      length: 2,
      convRule: rule13
  }, {
      start: 8508,
      length: 2,
      convRule: rule20
  }, {
      start: 8510,
      length: 2,
      convRule: rule107
  }, {
      start: 8512,
      length: 5,
      convRule: rule6
  }, {
      start: 8517,
      length: 1,
      convRule: rule107
  }, {
      start: 8518,
      length: 4,
      convRule: rule20
  }, {
      start: 8522,
      length: 1,
      convRule: rule13
  }, {
      start: 8523,
      length: 1,
      convRule: rule6
  }, {
      start: 8524,
      length: 2,
      convRule: rule13
  }, {
      start: 8526,
      length: 1,
      convRule: rule167
  }, {
      start: 8527,
      length: 1,
      convRule: rule13
  }, {
      start: 8528,
      length: 16,
      convRule: rule17
  }, {
      start: 8544,
      length: 16,
      convRule: rule168
  }, {
      start: 8560,
      length: 16,
      convRule: rule169
  }, {
      start: 8576,
      length: 3,
      convRule: rule128
  }, {
      start: 8579,
      length: 1,
      convRule: rule22
  }, {
      start: 8580,
      length: 1,
      convRule: rule23
  }, {
      start: 8581,
      length: 4,
      convRule: rule128
  }, {
      start: 8585,
      length: 1,
      convRule: rule17
  }, {
      start: 8586,
      length: 2,
      convRule: rule13
  }, {
      start: 8592,
      length: 5,
      convRule: rule6
  }, {
      start: 8597,
      length: 5,
      convRule: rule13
  }, {
      start: 8602,
      length: 2,
      convRule: rule6
  }, {
      start: 8604,
      length: 4,
      convRule: rule13
  }, {
      start: 8608,
      length: 1,
      convRule: rule6
  }, {
      start: 8609,
      length: 2,
      convRule: rule13
  }, {
      start: 8611,
      length: 1,
      convRule: rule6
  }, {
      start: 8612,
      length: 2,
      convRule: rule13
  }, {
      start: 8614,
      length: 1,
      convRule: rule6
  }, {
      start: 8615,
      length: 7,
      convRule: rule13
  }, {
      start: 8622,
      length: 1,
      convRule: rule6
  }, {
      start: 8623,
      length: 31,
      convRule: rule13
  }, {
      start: 8654,
      length: 2,
      convRule: rule6
  }, {
      start: 8656,
      length: 2,
      convRule: rule13
  }, {
      start: 8658,
      length: 1,
      convRule: rule6
  }, {
      start: 8659,
      length: 1,
      convRule: rule13
  }, {
      start: 8660,
      length: 1,
      convRule: rule6
  }, {
      start: 8661,
      length: 31,
      convRule: rule13
  }, {
      start: 8692,
      length: 268,
      convRule: rule6
  }, {
      start: 8960,
      length: 8,
      convRule: rule13
  }, {
      start: 8968,
      length: 1,
      convRule: rule4
  }, {
      start: 8969,
      length: 1,
      convRule: rule5
  }, {
      start: 8970,
      length: 1,
      convRule: rule4
  }, {
      start: 8971,
      length: 1,
      convRule: rule5
  }, {
      start: 8972,
      length: 20,
      convRule: rule13
  }, {
      start: 8992,
      length: 2,
      convRule: rule6
  }, {
      start: 8994,
      length: 7,
      convRule: rule13
  }, {
      start: 9001,
      length: 1,
      convRule: rule4
  }, {
      start: 9002,
      length: 1,
      convRule: rule5
  }, {
      start: 9003,
      length: 81,
      convRule: rule13
  }, {
      start: 9084,
      length: 1,
      convRule: rule6
  }, {
      start: 9085,
      length: 30,
      convRule: rule13
  }, {
      start: 9115,
      length: 25,
      convRule: rule6
  }, {
      start: 9140,
      length: 40,
      convRule: rule13
  }, {
      start: 9180,
      length: 6,
      convRule: rule6
  }, {
      start: 9186,
      length: 69,
      convRule: rule13
  }, {
      start: 9280,
      length: 11,
      convRule: rule13
  }, {
      start: 9312,
      length: 60,
      convRule: rule17
  }, {
      start: 9372,
      length: 26,
      convRule: rule13
  }, {
      start: 9398,
      length: 26,
      convRule: rule170
  }, {
      start: 9424,
      length: 26,
      convRule: rule171
  }, {
      start: 9450,
      length: 22,
      convRule: rule17
  }, {
      start: 9472,
      length: 183,
      convRule: rule13
  }, {
      start: 9655,
      length: 1,
      convRule: rule6
  }, {
      start: 9656,
      length: 9,
      convRule: rule13
  }, {
      start: 9665,
      length: 1,
      convRule: rule6
  }, {
      start: 9666,
      length: 54,
      convRule: rule13
  }, {
      start: 9720,
      length: 8,
      convRule: rule6
  }, {
      start: 9728,
      length: 111,
      convRule: rule13
  }, {
      start: 9839,
      length: 1,
      convRule: rule6
  }, {
      start: 9840,
      length: 248,
      convRule: rule13
  }, {
      start: 10088,
      length: 1,
      convRule: rule4
  }, {
      start: 10089,
      length: 1,
      convRule: rule5
  }, {
      start: 10090,
      length: 1,
      convRule: rule4
  }, {
      start: 10091,
      length: 1,
      convRule: rule5
  }, {
      start: 10092,
      length: 1,
      convRule: rule4
  }, {
      start: 10093,
      length: 1,
      convRule: rule5
  }, {
      start: 10094,
      length: 1,
      convRule: rule4
  }, {
      start: 10095,
      length: 1,
      convRule: rule5
  }, {
      start: 10096,
      length: 1,
      convRule: rule4
  }, {
      start: 10097,
      length: 1,
      convRule: rule5
  }, {
      start: 10098,
      length: 1,
      convRule: rule4
  }, {
      start: 10099,
      length: 1,
      convRule: rule5
  }, {
      start: 10100,
      length: 1,
      convRule: rule4
  }, {
      start: 10101,
      length: 1,
      convRule: rule5
  }, {
      start: 10102,
      length: 30,
      convRule: rule17
  }, {
      start: 10132,
      length: 44,
      convRule: rule13
  }, {
      start: 10176,
      length: 5,
      convRule: rule6
  }, {
      start: 10181,
      length: 1,
      convRule: rule4
  }, {
      start: 10182,
      length: 1,
      convRule: rule5
  }, {
      start: 10183,
      length: 31,
      convRule: rule6
  }, {
      start: 10214,
      length: 1,
      convRule: rule4
  }, {
      start: 10215,
      length: 1,
      convRule: rule5
  }, {
      start: 10216,
      length: 1,
      convRule: rule4
  }, {
      start: 10217,
      length: 1,
      convRule: rule5
  }, {
      start: 10218,
      length: 1,
      convRule: rule4
  }, {
      start: 10219,
      length: 1,
      convRule: rule5
  }, {
      start: 10220,
      length: 1,
      convRule: rule4
  }, {
      start: 10221,
      length: 1,
      convRule: rule5
  }, {
      start: 10222,
      length: 1,
      convRule: rule4
  }, {
      start: 10223,
      length: 1,
      convRule: rule5
  }, {
      start: 10224,
      length: 16,
      convRule: rule6
  }, {
      start: 10240,
      length: 256,
      convRule: rule13
  }, {
      start: 10496,
      length: 131,
      convRule: rule6
  }, {
      start: 10627,
      length: 1,
      convRule: rule4
  }, {
      start: 10628,
      length: 1,
      convRule: rule5
  }, {
      start: 10629,
      length: 1,
      convRule: rule4
  }, {
      start: 10630,
      length: 1,
      convRule: rule5
  }, {
      start: 10631,
      length: 1,
      convRule: rule4
  }, {
      start: 10632,
      length: 1,
      convRule: rule5
  }, {
      start: 10633,
      length: 1,
      convRule: rule4
  }, {
      start: 10634,
      length: 1,
      convRule: rule5
  }, {
      start: 10635,
      length: 1,
      convRule: rule4
  }, {
      start: 10636,
      length: 1,
      convRule: rule5
  }, {
      start: 10637,
      length: 1,
      convRule: rule4
  }, {
      start: 10638,
      length: 1,
      convRule: rule5
  }, {
      start: 10639,
      length: 1,
      convRule: rule4
  }, {
      start: 10640,
      length: 1,
      convRule: rule5
  }, {
      start: 10641,
      length: 1,
      convRule: rule4
  }, {
      start: 10642,
      length: 1,
      convRule: rule5
  }, {
      start: 10643,
      length: 1,
      convRule: rule4
  }, {
      start: 10644,
      length: 1,
      convRule: rule5
  }, {
      start: 10645,
      length: 1,
      convRule: rule4
  }, {
      start: 10646,
      length: 1,
      convRule: rule5
  }, {
      start: 10647,
      length: 1,
      convRule: rule4
  }, {
      start: 10648,
      length: 1,
      convRule: rule5
  }, {
      start: 10649,
      length: 63,
      convRule: rule6
  }, {
      start: 10712,
      length: 1,
      convRule: rule4
  }, {
      start: 10713,
      length: 1,
      convRule: rule5
  }, {
      start: 10714,
      length: 1,
      convRule: rule4
  }, {
      start: 10715,
      length: 1,
      convRule: rule5
  }, {
      start: 10716,
      length: 32,
      convRule: rule6
  }, {
      start: 10748,
      length: 1,
      convRule: rule4
  }, {
      start: 10749,
      length: 1,
      convRule: rule5
  }, {
      start: 10750,
      length: 258,
      convRule: rule6
  }, {
      start: 11008,
      length: 48,
      convRule: rule13
  }, {
      start: 11056,
      length: 21,
      convRule: rule6
  }, {
      start: 11077,
      length: 2,
      convRule: rule13
  }, {
      start: 11079,
      length: 6,
      convRule: rule6
  }, {
      start: 11085,
      length: 39,
      convRule: rule13
  }, {
      start: 11126,
      length: 32,
      convRule: rule13
  }, {
      start: 11159,
      length: 105,
      convRule: rule13
  }, {
      start: 11264,
      length: 47,
      convRule: rule122
  }, {
      start: 11312,
      length: 47,
      convRule: rule123
  }, {
      start: 11360,
      length: 1,
      convRule: rule22
  }, {
      start: 11361,
      length: 1,
      convRule: rule23
  }, {
      start: 11362,
      length: 1,
      convRule: rule172
  }, {
      start: 11363,
      length: 1,
      convRule: rule173
  }, {
      start: 11364,
      length: 1,
      convRule: rule174
  }, {
      start: 11365,
      length: 1,
      convRule: rule175
  }, {
      start: 11366,
      length: 1,
      convRule: rule176
  }, {
      start: 11367,
      length: 1,
      convRule: rule22
  }, {
      start: 11368,
      length: 1,
      convRule: rule23
  }, {
      start: 11369,
      length: 1,
      convRule: rule22
  }, {
      start: 11370,
      length: 1,
      convRule: rule23
  }, {
      start: 11371,
      length: 1,
      convRule: rule22
  }, {
      start: 11372,
      length: 1,
      convRule: rule23
  }, {
      start: 11373,
      length: 1,
      convRule: rule177
  }, {
      start: 11374,
      length: 1,
      convRule: rule178
  }, {
      start: 11375,
      length: 1,
      convRule: rule179
  }, {
      start: 11376,
      length: 1,
      convRule: rule180
  }, {
      start: 11377,
      length: 1,
      convRule: rule20
  }, {
      start: 11378,
      length: 1,
      convRule: rule22
  }, {
      start: 11379,
      length: 1,
      convRule: rule23
  }, {
      start: 11380,
      length: 1,
      convRule: rule20
  }, {
      start: 11381,
      length: 1,
      convRule: rule22
  }, {
      start: 11382,
      length: 1,
      convRule: rule23
  }, {
      start: 11383,
      length: 5,
      convRule: rule20
  }, {
      start: 11388,
      length: 2,
      convRule: rule91
  }, {
      start: 11390,
      length: 2,
      convRule: rule181
  }, {
      start: 11392,
      length: 1,
      convRule: rule22
  }, {
      start: 11393,
      length: 1,
      convRule: rule23
  }, {
      start: 11394,
      length: 1,
      convRule: rule22
  }, {
      start: 11395,
      length: 1,
      convRule: rule23
  }, {
      start: 11396,
      length: 1,
      convRule: rule22
  }, {
      start: 11397,
      length: 1,
      convRule: rule23
  }, {
      start: 11398,
      length: 1,
      convRule: rule22
  }, {
      start: 11399,
      length: 1,
      convRule: rule23
  }, {
      start: 11400,
      length: 1,
      convRule: rule22
  }, {
      start: 11401,
      length: 1,
      convRule: rule23
  }, {
      start: 11402,
      length: 1,
      convRule: rule22
  }, {
      start: 11403,
      length: 1,
      convRule: rule23
  }, {
      start: 11404,
      length: 1,
      convRule: rule22
  }, {
      start: 11405,
      length: 1,
      convRule: rule23
  }, {
      start: 11406,
      length: 1,
      convRule: rule22
  }, {
      start: 11407,
      length: 1,
      convRule: rule23
  }, {
      start: 11408,
      length: 1,
      convRule: rule22
  }, {
      start: 11409,
      length: 1,
      convRule: rule23
  }, {
      start: 11410,
      length: 1,
      convRule: rule22
  }, {
      start: 11411,
      length: 1,
      convRule: rule23
  }, {
      start: 11412,
      length: 1,
      convRule: rule22
  }, {
      start: 11413,
      length: 1,
      convRule: rule23
  }, {
      start: 11414,
      length: 1,
      convRule: rule22
  }, {
      start: 11415,
      length: 1,
      convRule: rule23
  }, {
      start: 11416,
      length: 1,
      convRule: rule22
  }, {
      start: 11417,
      length: 1,
      convRule: rule23
  }, {
      start: 11418,
      length: 1,
      convRule: rule22
  }, {
      start: 11419,
      length: 1,
      convRule: rule23
  }, {
      start: 11420,
      length: 1,
      convRule: rule22
  }, {
      start: 11421,
      length: 1,
      convRule: rule23
  }, {
      start: 11422,
      length: 1,
      convRule: rule22
  }, {
      start: 11423,
      length: 1,
      convRule: rule23
  }, {
      start: 11424,
      length: 1,
      convRule: rule22
  }, {
      start: 11425,
      length: 1,
      convRule: rule23
  }, {
      start: 11426,
      length: 1,
      convRule: rule22
  }, {
      start: 11427,
      length: 1,
      convRule: rule23
  }, {
      start: 11428,
      length: 1,
      convRule: rule22
  }, {
      start: 11429,
      length: 1,
      convRule: rule23
  }, {
      start: 11430,
      length: 1,
      convRule: rule22
  }, {
      start: 11431,
      length: 1,
      convRule: rule23
  }, {
      start: 11432,
      length: 1,
      convRule: rule22
  }, {
      start: 11433,
      length: 1,
      convRule: rule23
  }, {
      start: 11434,
      length: 1,
      convRule: rule22
  }, {
      start: 11435,
      length: 1,
      convRule: rule23
  }, {
      start: 11436,
      length: 1,
      convRule: rule22
  }, {
      start: 11437,
      length: 1,
      convRule: rule23
  }, {
      start: 11438,
      length: 1,
      convRule: rule22
  }, {
      start: 11439,
      length: 1,
      convRule: rule23
  }, {
      start: 11440,
      length: 1,
      convRule: rule22
  }, {
      start: 11441,
      length: 1,
      convRule: rule23
  }, {
      start: 11442,
      length: 1,
      convRule: rule22
  }, {
      start: 11443,
      length: 1,
      convRule: rule23
  }, {
      start: 11444,
      length: 1,
      convRule: rule22
  }, {
      start: 11445,
      length: 1,
      convRule: rule23
  }, {
      start: 11446,
      length: 1,
      convRule: rule22
  }, {
      start: 11447,
      length: 1,
      convRule: rule23
  }, {
      start: 11448,
      length: 1,
      convRule: rule22
  }, {
      start: 11449,
      length: 1,
      convRule: rule23
  }, {
      start: 11450,
      length: 1,
      convRule: rule22
  }, {
      start: 11451,
      length: 1,
      convRule: rule23
  }, {
      start: 11452,
      length: 1,
      convRule: rule22
  }, {
      start: 11453,
      length: 1,
      convRule: rule23
  }, {
      start: 11454,
      length: 1,
      convRule: rule22
  }, {
      start: 11455,
      length: 1,
      convRule: rule23
  }, {
      start: 11456,
      length: 1,
      convRule: rule22
  }, {
      start: 11457,
      length: 1,
      convRule: rule23
  }, {
      start: 11458,
      length: 1,
      convRule: rule22
  }, {
      start: 11459,
      length: 1,
      convRule: rule23
  }, {
      start: 11460,
      length: 1,
      convRule: rule22
  }, {
      start: 11461,
      length: 1,
      convRule: rule23
  }, {
      start: 11462,
      length: 1,
      convRule: rule22
  }, {
      start: 11463,
      length: 1,
      convRule: rule23
  }, {
      start: 11464,
      length: 1,
      convRule: rule22
  }, {
      start: 11465,
      length: 1,
      convRule: rule23
  }, {
      start: 11466,
      length: 1,
      convRule: rule22
  }, {
      start: 11467,
      length: 1,
      convRule: rule23
  }, {
      start: 11468,
      length: 1,
      convRule: rule22
  }, {
      start: 11469,
      length: 1,
      convRule: rule23
  }, {
      start: 11470,
      length: 1,
      convRule: rule22
  }, {
      start: 11471,
      length: 1,
      convRule: rule23
  }, {
      start: 11472,
      length: 1,
      convRule: rule22
  }, {
      start: 11473,
      length: 1,
      convRule: rule23
  }, {
      start: 11474,
      length: 1,
      convRule: rule22
  }, {
      start: 11475,
      length: 1,
      convRule: rule23
  }, {
      start: 11476,
      length: 1,
      convRule: rule22
  }, {
      start: 11477,
      length: 1,
      convRule: rule23
  }, {
      start: 11478,
      length: 1,
      convRule: rule22
  }, {
      start: 11479,
      length: 1,
      convRule: rule23
  }, {
      start: 11480,
      length: 1,
      convRule: rule22
  }, {
      start: 11481,
      length: 1,
      convRule: rule23
  }, {
      start: 11482,
      length: 1,
      convRule: rule22
  }, {
      start: 11483,
      length: 1,
      convRule: rule23
  }, {
      start: 11484,
      length: 1,
      convRule: rule22
  }, {
      start: 11485,
      length: 1,
      convRule: rule23
  }, {
      start: 11486,
      length: 1,
      convRule: rule22
  }, {
      start: 11487,
      length: 1,
      convRule: rule23
  }, {
      start: 11488,
      length: 1,
      convRule: rule22
  }, {
      start: 11489,
      length: 1,
      convRule: rule23
  }, {
      start: 11490,
      length: 1,
      convRule: rule22
  }, {
      start: 11491,
      length: 1,
      convRule: rule23
  }, {
      start: 11492,
      length: 1,
      convRule: rule20
  }, {
      start: 11493,
      length: 6,
      convRule: rule13
  }, {
      start: 11499,
      length: 1,
      convRule: rule22
  }, {
      start: 11500,
      length: 1,
      convRule: rule23
  }, {
      start: 11501,
      length: 1,
      convRule: rule22
  }, {
      start: 11502,
      length: 1,
      convRule: rule23
  }, {
      start: 11503,
      length: 3,
      convRule: rule92
  }, {
      start: 11506,
      length: 1,
      convRule: rule22
  }, {
      start: 11507,
      length: 1,
      convRule: rule23
  }, {
      start: 11513,
      length: 4,
      convRule: rule2
  }, {
      start: 11517,
      length: 1,
      convRule: rule17
  }, {
      start: 11518,
      length: 2,
      convRule: rule2
  }, {
      start: 11520,
      length: 38,
      convRule: rule182
  }, {
      start: 11559,
      length: 1,
      convRule: rule182
  }, {
      start: 11565,
      length: 1,
      convRule: rule182
  }, {
      start: 11568,
      length: 56,
      convRule: rule14
  }, {
      start: 11631,
      length: 1,
      convRule: rule91
  }, {
      start: 11632,
      length: 1,
      convRule: rule2
  }, {
      start: 11647,
      length: 1,
      convRule: rule92
  }, {
      start: 11648,
      length: 23,
      convRule: rule14
  }, {
      start: 11680,
      length: 7,
      convRule: rule14
  }, {
      start: 11688,
      length: 7,
      convRule: rule14
  }, {
      start: 11696,
      length: 7,
      convRule: rule14
  }, {
      start: 11704,
      length: 7,
      convRule: rule14
  }, {
      start: 11712,
      length: 7,
      convRule: rule14
  }, {
      start: 11720,
      length: 7,
      convRule: rule14
  }, {
      start: 11728,
      length: 7,
      convRule: rule14
  }, {
      start: 11736,
      length: 7,
      convRule: rule14
  }, {
      start: 11744,
      length: 32,
      convRule: rule92
  }, {
      start: 11776,
      length: 2,
      convRule: rule2
  }, {
      start: 11778,
      length: 1,
      convRule: rule15
  }, {
      start: 11779,
      length: 1,
      convRule: rule19
  }, {
      start: 11780,
      length: 1,
      convRule: rule15
  }, {
      start: 11781,
      length: 1,
      convRule: rule19
  }, {
      start: 11782,
      length: 3,
      convRule: rule2
  }, {
      start: 11785,
      length: 1,
      convRule: rule15
  }, {
      start: 11786,
      length: 1,
      convRule: rule19
  }, {
      start: 11787,
      length: 1,
      convRule: rule2
  }, {
      start: 11788,
      length: 1,
      convRule: rule15
  }, {
      start: 11789,
      length: 1,
      convRule: rule19
  }, {
      start: 11790,
      length: 9,
      convRule: rule2
  }, {
      start: 11799,
      length: 1,
      convRule: rule7
  }, {
      start: 11800,
      length: 2,
      convRule: rule2
  }, {
      start: 11802,
      length: 1,
      convRule: rule7
  }, {
      start: 11803,
      length: 1,
      convRule: rule2
  }, {
      start: 11804,
      length: 1,
      convRule: rule15
  }, {
      start: 11805,
      length: 1,
      convRule: rule19
  }, {
      start: 11806,
      length: 2,
      convRule: rule2
  }, {
      start: 11808,
      length: 1,
      convRule: rule15
  }, {
      start: 11809,
      length: 1,
      convRule: rule19
  }, {
      start: 11810,
      length: 1,
      convRule: rule4
  }, {
      start: 11811,
      length: 1,
      convRule: rule5
  }, {
      start: 11812,
      length: 1,
      convRule: rule4
  }, {
      start: 11813,
      length: 1,
      convRule: rule5
  }, {
      start: 11814,
      length: 1,
      convRule: rule4
  }, {
      start: 11815,
      length: 1,
      convRule: rule5
  }, {
      start: 11816,
      length: 1,
      convRule: rule4
  }, {
      start: 11817,
      length: 1,
      convRule: rule5
  }, {
      start: 11818,
      length: 5,
      convRule: rule2
  }, {
      start: 11823,
      length: 1,
      convRule: rule91
  }, {
      start: 11824,
      length: 10,
      convRule: rule2
  }, {
      start: 11834,
      length: 2,
      convRule: rule7
  }, {
      start: 11836,
      length: 4,
      convRule: rule2
  }, {
      start: 11840,
      length: 1,
      convRule: rule7
  }, {
      start: 11841,
      length: 1,
      convRule: rule2
  }, {
      start: 11842,
      length: 1,
      convRule: rule4
  }, {
      start: 11843,
      length: 13,
      convRule: rule2
  }, {
      start: 11856,
      length: 2,
      convRule: rule13
  }, {
      start: 11858,
      length: 1,
      convRule: rule2
  }, {
      start: 11904,
      length: 26,
      convRule: rule13
  }, {
      start: 11931,
      length: 89,
      convRule: rule13
  }, {
      start: 12032,
      length: 214,
      convRule: rule13
  }, {
      start: 12272,
      length: 12,
      convRule: rule13
  }, {
      start: 12288,
      length: 1,
      convRule: rule1
  }, {
      start: 12289,
      length: 3,
      convRule: rule2
  }, {
      start: 12292,
      length: 1,
      convRule: rule13
  }, {
      start: 12293,
      length: 1,
      convRule: rule91
  }, {
      start: 12294,
      length: 1,
      convRule: rule14
  }, {
      start: 12295,
      length: 1,
      convRule: rule128
  }, {
      start: 12296,
      length: 1,
      convRule: rule4
  }, {
      start: 12297,
      length: 1,
      convRule: rule5
  }, {
      start: 12298,
      length: 1,
      convRule: rule4
  }, {
      start: 12299,
      length: 1,
      convRule: rule5
  }, {
      start: 12300,
      length: 1,
      convRule: rule4
  }, {
      start: 12301,
      length: 1,
      convRule: rule5
  }, {
      start: 12302,
      length: 1,
      convRule: rule4
  }, {
      start: 12303,
      length: 1,
      convRule: rule5
  }, {
      start: 12304,
      length: 1,
      convRule: rule4
  }, {
      start: 12305,
      length: 1,
      convRule: rule5
  }, {
      start: 12306,
      length: 2,
      convRule: rule13
  }, {
      start: 12308,
      length: 1,
      convRule: rule4
  }, {
      start: 12309,
      length: 1,
      convRule: rule5
  }, {
      start: 12310,
      length: 1,
      convRule: rule4
  }, {
      start: 12311,
      length: 1,
      convRule: rule5
  }, {
      start: 12312,
      length: 1,
      convRule: rule4
  }, {
      start: 12313,
      length: 1,
      convRule: rule5
  }, {
      start: 12314,
      length: 1,
      convRule: rule4
  }, {
      start: 12315,
      length: 1,
      convRule: rule5
  }, {
      start: 12316,
      length: 1,
      convRule: rule7
  }, {
      start: 12317,
      length: 1,
      convRule: rule4
  }, {
      start: 12318,
      length: 2,
      convRule: rule5
  }, {
      start: 12320,
      length: 1,
      convRule: rule13
  }, {
      start: 12321,
      length: 9,
      convRule: rule128
  }, {
      start: 12330,
      length: 4,
      convRule: rule92
  }, {
      start: 12334,
      length: 2,
      convRule: rule124
  }, {
      start: 12336,
      length: 1,
      convRule: rule7
  }, {
      start: 12337,
      length: 5,
      convRule: rule91
  }, {
      start: 12342,
      length: 2,
      convRule: rule13
  }, {
      start: 12344,
      length: 3,
      convRule: rule128
  }, {
      start: 12347,
      length: 1,
      convRule: rule91
  }, {
      start: 12348,
      length: 1,
      convRule: rule14
  }, {
      start: 12349,
      length: 1,
      convRule: rule2
  }, {
      start: 12350,
      length: 2,
      convRule: rule13
  }, {
      start: 12353,
      length: 86,
      convRule: rule14
  }, {
      start: 12441,
      length: 2,
      convRule: rule92
  }, {
      start: 12443,
      length: 2,
      convRule: rule10
  }, {
      start: 12445,
      length: 2,
      convRule: rule91
  }, {
      start: 12447,
      length: 1,
      convRule: rule14
  }, {
      start: 12448,
      length: 1,
      convRule: rule7
  }, {
      start: 12449,
      length: 90,
      convRule: rule14
  }, {
      start: 12539,
      length: 1,
      convRule: rule2
  }, {
      start: 12540,
      length: 3,
      convRule: rule91
  }, {
      start: 12543,
      length: 1,
      convRule: rule14
  }, {
      start: 12549,
      length: 43,
      convRule: rule14
  }, {
      start: 12593,
      length: 94,
      convRule: rule14
  }, {
      start: 12688,
      length: 2,
      convRule: rule13
  }, {
      start: 12690,
      length: 4,
      convRule: rule17
  }, {
      start: 12694,
      length: 10,
      convRule: rule13
  }, {
      start: 12704,
      length: 32,
      convRule: rule14
  }, {
      start: 12736,
      length: 36,
      convRule: rule13
  }, {
      start: 12784,
      length: 16,
      convRule: rule14
  }, {
      start: 12800,
      length: 31,
      convRule: rule13
  }, {
      start: 12832,
      length: 10,
      convRule: rule17
  }, {
      start: 12842,
      length: 30,
      convRule: rule13
  }, {
      start: 12872,
      length: 8,
      convRule: rule17
  }, {
      start: 12880,
      length: 1,
      convRule: rule13
  }, {
      start: 12881,
      length: 15,
      convRule: rule17
  }, {
      start: 12896,
      length: 32,
      convRule: rule13
  }, {
      start: 12928,
      length: 10,
      convRule: rule17
  }, {
      start: 12938,
      length: 39,
      convRule: rule13
  }, {
      start: 12977,
      length: 15,
      convRule: rule17
  }, {
      start: 12992,
      length: 320,
      convRule: rule13
  }, {
      start: 13312,
      length: 6592,
      convRule: rule14
  }, {
      start: 19904,
      length: 64,
      convRule: rule13
  }, {
      start: 19968,
      length: 20989,
      convRule: rule14
  }, {
      start: 40960,
      length: 21,
      convRule: rule14
  }, {
      start: 40981,
      length: 1,
      convRule: rule91
  }, {
      start: 40982,
      length: 1143,
      convRule: rule14
  }, {
      start: 42128,
      length: 55,
      convRule: rule13
  }, {
      start: 42192,
      length: 40,
      convRule: rule14
  }, {
      start: 42232,
      length: 6,
      convRule: rule91
  }, {
      start: 42238,
      length: 2,
      convRule: rule2
  }, {
      start: 42240,
      length: 268,
      convRule: rule14
  }, {
      start: 42508,
      length: 1,
      convRule: rule91
  }, {
      start: 42509,
      length: 3,
      convRule: rule2
  }, {
      start: 42512,
      length: 16,
      convRule: rule14
  }, {
      start: 42528,
      length: 10,
      convRule: rule8
  }, {
      start: 42538,
      length: 2,
      convRule: rule14
  }, {
      start: 42560,
      length: 1,
      convRule: rule22
  }, {
      start: 42561,
      length: 1,
      convRule: rule23
  }, {
      start: 42562,
      length: 1,
      convRule: rule22
  }, {
      start: 42563,
      length: 1,
      convRule: rule23
  }, {
      start: 42564,
      length: 1,
      convRule: rule22
  }, {
      start: 42565,
      length: 1,
      convRule: rule23
  }, {
      start: 42566,
      length: 1,
      convRule: rule22
  }, {
      start: 42567,
      length: 1,
      convRule: rule23
  }, {
      start: 42568,
      length: 1,
      convRule: rule22
  }, {
      start: 42569,
      length: 1,
      convRule: rule23
  }, {
      start: 42570,
      length: 1,
      convRule: rule22
  }, {
      start: 42571,
      length: 1,
      convRule: rule23
  }, {
      start: 42572,
      length: 1,
      convRule: rule22
  }, {
      start: 42573,
      length: 1,
      convRule: rule23
  }, {
      start: 42574,
      length: 1,
      convRule: rule22
  }, {
      start: 42575,
      length: 1,
      convRule: rule23
  }, {
      start: 42576,
      length: 1,
      convRule: rule22
  }, {
      start: 42577,
      length: 1,
      convRule: rule23
  }, {
      start: 42578,
      length: 1,
      convRule: rule22
  }, {
      start: 42579,
      length: 1,
      convRule: rule23
  }, {
      start: 42580,
      length: 1,
      convRule: rule22
  }, {
      start: 42581,
      length: 1,
      convRule: rule23
  }, {
      start: 42582,
      length: 1,
      convRule: rule22
  }, {
      start: 42583,
      length: 1,
      convRule: rule23
  }, {
      start: 42584,
      length: 1,
      convRule: rule22
  }, {
      start: 42585,
      length: 1,
      convRule: rule23
  }, {
      start: 42586,
      length: 1,
      convRule: rule22
  }, {
      start: 42587,
      length: 1,
      convRule: rule23
  }, {
      start: 42588,
      length: 1,
      convRule: rule22
  }, {
      start: 42589,
      length: 1,
      convRule: rule23
  }, {
      start: 42590,
      length: 1,
      convRule: rule22
  }, {
      start: 42591,
      length: 1,
      convRule: rule23
  }, {
      start: 42592,
      length: 1,
      convRule: rule22
  }, {
      start: 42593,
      length: 1,
      convRule: rule23
  }, {
      start: 42594,
      length: 1,
      convRule: rule22
  }, {
      start: 42595,
      length: 1,
      convRule: rule23
  }, {
      start: 42596,
      length: 1,
      convRule: rule22
  }, {
      start: 42597,
      length: 1,
      convRule: rule23
  }, {
      start: 42598,
      length: 1,
      convRule: rule22
  }, {
      start: 42599,
      length: 1,
      convRule: rule23
  }, {
      start: 42600,
      length: 1,
      convRule: rule22
  }, {
      start: 42601,
      length: 1,
      convRule: rule23
  }, {
      start: 42602,
      length: 1,
      convRule: rule22
  }, {
      start: 42603,
      length: 1,
      convRule: rule23
  }, {
      start: 42604,
      length: 1,
      convRule: rule22
  }, {
      start: 42605,
      length: 1,
      convRule: rule23
  }, {
      start: 42606,
      length: 1,
      convRule: rule14
  }, {
      start: 42607,
      length: 1,
      convRule: rule92
  }, {
      start: 42608,
      length: 3,
      convRule: rule119
  }, {
      start: 42611,
      length: 1,
      convRule: rule2
  }, {
      start: 42612,
      length: 10,
      convRule: rule92
  }, {
      start: 42622,
      length: 1,
      convRule: rule2
  }, {
      start: 42623,
      length: 1,
      convRule: rule91
  }, {
      start: 42624,
      length: 1,
      convRule: rule22
  }, {
      start: 42625,
      length: 1,
      convRule: rule23
  }, {
      start: 42626,
      length: 1,
      convRule: rule22
  }, {
      start: 42627,
      length: 1,
      convRule: rule23
  }, {
      start: 42628,
      length: 1,
      convRule: rule22
  }, {
      start: 42629,
      length: 1,
      convRule: rule23
  }, {
      start: 42630,
      length: 1,
      convRule: rule22
  }, {
      start: 42631,
      length: 1,
      convRule: rule23
  }, {
      start: 42632,
      length: 1,
      convRule: rule22
  }, {
      start: 42633,
      length: 1,
      convRule: rule23
  }, {
      start: 42634,
      length: 1,
      convRule: rule22
  }, {
      start: 42635,
      length: 1,
      convRule: rule23
  }, {
      start: 42636,
      length: 1,
      convRule: rule22
  }, {
      start: 42637,
      length: 1,
      convRule: rule23
  }, {
      start: 42638,
      length: 1,
      convRule: rule22
  }, {
      start: 42639,
      length: 1,
      convRule: rule23
  }, {
      start: 42640,
      length: 1,
      convRule: rule22
  }, {
      start: 42641,
      length: 1,
      convRule: rule23
  }, {
      start: 42642,
      length: 1,
      convRule: rule22
  }, {
      start: 42643,
      length: 1,
      convRule: rule23
  }, {
      start: 42644,
      length: 1,
      convRule: rule22
  }, {
      start: 42645,
      length: 1,
      convRule: rule23
  }, {
      start: 42646,
      length: 1,
      convRule: rule22
  }, {
      start: 42647,
      length: 1,
      convRule: rule23
  }, {
      start: 42648,
      length: 1,
      convRule: rule22
  }, {
      start: 42649,
      length: 1,
      convRule: rule23
  }, {
      start: 42650,
      length: 1,
      convRule: rule22
  }, {
      start: 42651,
      length: 1,
      convRule: rule23
  }, {
      start: 42652,
      length: 2,
      convRule: rule91
  }, {
      start: 42654,
      length: 2,
      convRule: rule92
  }, {
      start: 42656,
      length: 70,
      convRule: rule14
  }, {
      start: 42726,
      length: 10,
      convRule: rule128
  }, {
      start: 42736,
      length: 2,
      convRule: rule92
  }, {
      start: 42738,
      length: 6,
      convRule: rule2
  }, {
      start: 42752,
      length: 23,
      convRule: rule10
  }, {
      start: 42775,
      length: 9,
      convRule: rule91
  }, {
      start: 42784,
      length: 2,
      convRule: rule10
  }, {
      start: 42786,
      length: 1,
      convRule: rule22
  }, {
      start: 42787,
      length: 1,
      convRule: rule23
  }, {
      start: 42788,
      length: 1,
      convRule: rule22
  }, {
      start: 42789,
      length: 1,
      convRule: rule23
  }, {
      start: 42790,
      length: 1,
      convRule: rule22
  }, {
      start: 42791,
      length: 1,
      convRule: rule23
  }, {
      start: 42792,
      length: 1,
      convRule: rule22
  }, {
      start: 42793,
      length: 1,
      convRule: rule23
  }, {
      start: 42794,
      length: 1,
      convRule: rule22
  }, {
      start: 42795,
      length: 1,
      convRule: rule23
  }, {
      start: 42796,
      length: 1,
      convRule: rule22
  }, {
      start: 42797,
      length: 1,
      convRule: rule23
  }, {
      start: 42798,
      length: 1,
      convRule: rule22
  }, {
      start: 42799,
      length: 1,
      convRule: rule23
  }, {
      start: 42800,
      length: 2,
      convRule: rule20
  }, {
      start: 42802,
      length: 1,
      convRule: rule22
  }, {
      start: 42803,
      length: 1,
      convRule: rule23
  }, {
      start: 42804,
      length: 1,
      convRule: rule22
  }, {
      start: 42805,
      length: 1,
      convRule: rule23
  }, {
      start: 42806,
      length: 1,
      convRule: rule22
  }, {
      start: 42807,
      length: 1,
      convRule: rule23
  }, {
      start: 42808,
      length: 1,
      convRule: rule22
  }, {
      start: 42809,
      length: 1,
      convRule: rule23
  }, {
      start: 42810,
      length: 1,
      convRule: rule22
  }, {
      start: 42811,
      length: 1,
      convRule: rule23
  }, {
      start: 42812,
      length: 1,
      convRule: rule22
  }, {
      start: 42813,
      length: 1,
      convRule: rule23
  }, {
      start: 42814,
      length: 1,
      convRule: rule22
  }, {
      start: 42815,
      length: 1,
      convRule: rule23
  }, {
      start: 42816,
      length: 1,
      convRule: rule22
  }, {
      start: 42817,
      length: 1,
      convRule: rule23
  }, {
      start: 42818,
      length: 1,
      convRule: rule22
  }, {
      start: 42819,
      length: 1,
      convRule: rule23
  }, {
      start: 42820,
      length: 1,
      convRule: rule22
  }, {
      start: 42821,
      length: 1,
      convRule: rule23
  }, {
      start: 42822,
      length: 1,
      convRule: rule22
  }, {
      start: 42823,
      length: 1,
      convRule: rule23
  }, {
      start: 42824,
      length: 1,
      convRule: rule22
  }, {
      start: 42825,
      length: 1,
      convRule: rule23
  }, {
      start: 42826,
      length: 1,
      convRule: rule22
  }, {
      start: 42827,
      length: 1,
      convRule: rule23
  }, {
      start: 42828,
      length: 1,
      convRule: rule22
  }, {
      start: 42829,
      length: 1,
      convRule: rule23
  }, {
      start: 42830,
      length: 1,
      convRule: rule22
  }, {
      start: 42831,
      length: 1,
      convRule: rule23
  }, {
      start: 42832,
      length: 1,
      convRule: rule22
  }, {
      start: 42833,
      length: 1,
      convRule: rule23
  }, {
      start: 42834,
      length: 1,
      convRule: rule22
  }, {
      start: 42835,
      length: 1,
      convRule: rule23
  }, {
      start: 42836,
      length: 1,
      convRule: rule22
  }, {
      start: 42837,
      length: 1,
      convRule: rule23
  }, {
      start: 42838,
      length: 1,
      convRule: rule22
  }, {
      start: 42839,
      length: 1,
      convRule: rule23
  }, {
      start: 42840,
      length: 1,
      convRule: rule22
  }, {
      start: 42841,
      length: 1,
      convRule: rule23
  }, {
      start: 42842,
      length: 1,
      convRule: rule22
  }, {
      start: 42843,
      length: 1,
      convRule: rule23
  }, {
      start: 42844,
      length: 1,
      convRule: rule22
  }, {
      start: 42845,
      length: 1,
      convRule: rule23
  }, {
      start: 42846,
      length: 1,
      convRule: rule22
  }, {
      start: 42847,
      length: 1,
      convRule: rule23
  }, {
      start: 42848,
      length: 1,
      convRule: rule22
  }, {
      start: 42849,
      length: 1,
      convRule: rule23
  }, {
      start: 42850,
      length: 1,
      convRule: rule22
  }, {
      start: 42851,
      length: 1,
      convRule: rule23
  }, {
      start: 42852,
      length: 1,
      convRule: rule22
  }, {
      start: 42853,
      length: 1,
      convRule: rule23
  }, {
      start: 42854,
      length: 1,
      convRule: rule22
  }, {
      start: 42855,
      length: 1,
      convRule: rule23
  }, {
      start: 42856,
      length: 1,
      convRule: rule22
  }, {
      start: 42857,
      length: 1,
      convRule: rule23
  }, {
      start: 42858,
      length: 1,
      convRule: rule22
  }, {
      start: 42859,
      length: 1,
      convRule: rule23
  }, {
      start: 42860,
      length: 1,
      convRule: rule22
  }, {
      start: 42861,
      length: 1,
      convRule: rule23
  }, {
      start: 42862,
      length: 1,
      convRule: rule22
  }, {
      start: 42863,
      length: 1,
      convRule: rule23
  }, {
      start: 42864,
      length: 1,
      convRule: rule91
  }, {
      start: 42865,
      length: 8,
      convRule: rule20
  }, {
      start: 42873,
      length: 1,
      convRule: rule22
  }, {
      start: 42874,
      length: 1,
      convRule: rule23
  }, {
      start: 42875,
      length: 1,
      convRule: rule22
  }, {
      start: 42876,
      length: 1,
      convRule: rule23
  }, {
      start: 42877,
      length: 1,
      convRule: rule183
  }, {
      start: 42878,
      length: 1,
      convRule: rule22
  }, {
      start: 42879,
      length: 1,
      convRule: rule23
  }, {
      start: 42880,
      length: 1,
      convRule: rule22
  }, {
      start: 42881,
      length: 1,
      convRule: rule23
  }, {
      start: 42882,
      length: 1,
      convRule: rule22
  }, {
      start: 42883,
      length: 1,
      convRule: rule23
  }, {
      start: 42884,
      length: 1,
      convRule: rule22
  }, {
      start: 42885,
      length: 1,
      convRule: rule23
  }, {
      start: 42886,
      length: 1,
      convRule: rule22
  }, {
      start: 42887,
      length: 1,
      convRule: rule23
  }, {
      start: 42888,
      length: 1,
      convRule: rule91
  }, {
      start: 42889,
      length: 2,
      convRule: rule10
  }, {
      start: 42891,
      length: 1,
      convRule: rule22
  }, {
      start: 42892,
      length: 1,
      convRule: rule23
  }, {
      start: 42893,
      length: 1,
      convRule: rule184
  }, {
      start: 42894,
      length: 1,
      convRule: rule20
  }, {
      start: 42895,
      length: 1,
      convRule: rule14
  }, {
      start: 42896,
      length: 1,
      convRule: rule22
  }, {
      start: 42897,
      length: 1,
      convRule: rule23
  }, {
      start: 42898,
      length: 1,
      convRule: rule22
  }, {
      start: 42899,
      length: 1,
      convRule: rule23
  }, {
      start: 42900,
      length: 1,
      convRule: rule185
  }, {
      start: 42901,
      length: 1,
      convRule: rule20
  }, {
      start: 42902,
      length: 1,
      convRule: rule22
  }, {
      start: 42903,
      length: 1,
      convRule: rule23
  }, {
      start: 42904,
      length: 1,
      convRule: rule22
  }, {
      start: 42905,
      length: 1,
      convRule: rule23
  }, {
      start: 42906,
      length: 1,
      convRule: rule22
  }, {
      start: 42907,
      length: 1,
      convRule: rule23
  }, {
      start: 42908,
      length: 1,
      convRule: rule22
  }, {
      start: 42909,
      length: 1,
      convRule: rule23
  }, {
      start: 42910,
      length: 1,
      convRule: rule22
  }, {
      start: 42911,
      length: 1,
      convRule: rule23
  }, {
      start: 42912,
      length: 1,
      convRule: rule22
  }, {
      start: 42913,
      length: 1,
      convRule: rule23
  }, {
      start: 42914,
      length: 1,
      convRule: rule22
  }, {
      start: 42915,
      length: 1,
      convRule: rule23
  }, {
      start: 42916,
      length: 1,
      convRule: rule22
  }, {
      start: 42917,
      length: 1,
      convRule: rule23
  }, {
      start: 42918,
      length: 1,
      convRule: rule22
  }, {
      start: 42919,
      length: 1,
      convRule: rule23
  }, {
      start: 42920,
      length: 1,
      convRule: rule22
  }, {
      start: 42921,
      length: 1,
      convRule: rule23
  }, {
      start: 42922,
      length: 1,
      convRule: rule186
  }, {
      start: 42923,
      length: 1,
      convRule: rule187
  }, {
      start: 42924,
      length: 1,
      convRule: rule188
  }, {
      start: 42925,
      length: 1,
      convRule: rule189
  }, {
      start: 42926,
      length: 1,
      convRule: rule186
  }, {
      start: 42927,
      length: 1,
      convRule: rule20
  }, {
      start: 42928,
      length: 1,
      convRule: rule190
  }, {
      start: 42929,
      length: 1,
      convRule: rule191
  }, {
      start: 42930,
      length: 1,
      convRule: rule192
  }, {
      start: 42931,
      length: 1,
      convRule: rule193
  }, {
      start: 42932,
      length: 1,
      convRule: rule22
  }, {
      start: 42933,
      length: 1,
      convRule: rule23
  }, {
      start: 42934,
      length: 1,
      convRule: rule22
  }, {
      start: 42935,
      length: 1,
      convRule: rule23
  }, {
      start: 42936,
      length: 1,
      convRule: rule22
  }, {
      start: 42937,
      length: 1,
      convRule: rule23
  }, {
      start: 42938,
      length: 1,
      convRule: rule22
  }, {
      start: 42939,
      length: 1,
      convRule: rule23
  }, {
      start: 42940,
      length: 1,
      convRule: rule22
  }, {
      start: 42941,
      length: 1,
      convRule: rule23
  }, {
      start: 42942,
      length: 1,
      convRule: rule22
  }, {
      start: 42943,
      length: 1,
      convRule: rule23
  }, {
      start: 42946,
      length: 1,
      convRule: rule22
  }, {
      start: 42947,
      length: 1,
      convRule: rule23
  }, {
      start: 42948,
      length: 1,
      convRule: rule194
  }, {
      start: 42949,
      length: 1,
      convRule: rule195
  }, {
      start: 42950,
      length: 1,
      convRule: rule196
  }, {
      start: 42951,
      length: 1,
      convRule: rule22
  }, {
      start: 42952,
      length: 1,
      convRule: rule23
  }, {
      start: 42953,
      length: 1,
      convRule: rule22
  }, {
      start: 42954,
      length: 1,
      convRule: rule23
  }, {
      start: 42997,
      length: 1,
      convRule: rule22
  }, {
      start: 42998,
      length: 1,
      convRule: rule23
  }, {
      start: 42999,
      length: 1,
      convRule: rule14
  }, {
      start: 43000,
      length: 2,
      convRule: rule91
  }, {
      start: 43002,
      length: 1,
      convRule: rule20
  }, {
      start: 43003,
      length: 7,
      convRule: rule14
  }, {
      start: 43010,
      length: 1,
      convRule: rule92
  }, {
      start: 43011,
      length: 3,
      convRule: rule14
  }, {
      start: 43014,
      length: 1,
      convRule: rule92
  }, {
      start: 43015,
      length: 4,
      convRule: rule14
  }, {
      start: 43019,
      length: 1,
      convRule: rule92
  }, {
      start: 43020,
      length: 23,
      convRule: rule14
  }, {
      start: 43043,
      length: 2,
      convRule: rule124
  }, {
      start: 43045,
      length: 2,
      convRule: rule92
  }, {
      start: 43047,
      length: 1,
      convRule: rule124
  }, {
      start: 43048,
      length: 4,
      convRule: rule13
  }, {
      start: 43052,
      length: 1,
      convRule: rule92
  }, {
      start: 43056,
      length: 6,
      convRule: rule17
  }, {
      start: 43062,
      length: 2,
      convRule: rule13
  }, {
      start: 43064,
      length: 1,
      convRule: rule3
  }, {
      start: 43065,
      length: 1,
      convRule: rule13
  }, {
      start: 43072,
      length: 52,
      convRule: rule14
  }, {
      start: 43124,
      length: 4,
      convRule: rule2
  }, {
      start: 43136,
      length: 2,
      convRule: rule124
  }, {
      start: 43138,
      length: 50,
      convRule: rule14
  }, {
      start: 43188,
      length: 16,
      convRule: rule124
  }, {
      start: 43204,
      length: 2,
      convRule: rule92
  }, {
      start: 43214,
      length: 2,
      convRule: rule2
  }, {
      start: 43216,
      length: 10,
      convRule: rule8
  }, {
      start: 43232,
      length: 18,
      convRule: rule92
  }, {
      start: 43250,
      length: 6,
      convRule: rule14
  }, {
      start: 43256,
      length: 3,
      convRule: rule2
  }, {
      start: 43259,
      length: 1,
      convRule: rule14
  }, {
      start: 43260,
      length: 1,
      convRule: rule2
  }, {
      start: 43261,
      length: 2,
      convRule: rule14
  }, {
      start: 43263,
      length: 1,
      convRule: rule92
  }, {
      start: 43264,
      length: 10,
      convRule: rule8
  }, {
      start: 43274,
      length: 28,
      convRule: rule14
  }, {
      start: 43302,
      length: 8,
      convRule: rule92
  }, {
      start: 43310,
      length: 2,
      convRule: rule2
  }, {
      start: 43312,
      length: 23,
      convRule: rule14
  }, {
      start: 43335,
      length: 11,
      convRule: rule92
  }, {
      start: 43346,
      length: 2,
      convRule: rule124
  }, {
      start: 43359,
      length: 1,
      convRule: rule2
  }, {
      start: 43360,
      length: 29,
      convRule: rule14
  }, {
      start: 43392,
      length: 3,
      convRule: rule92
  }, {
      start: 43395,
      length: 1,
      convRule: rule124
  }, {
      start: 43396,
      length: 47,
      convRule: rule14
  }, {
      start: 43443,
      length: 1,
      convRule: rule92
  }, {
      start: 43444,
      length: 2,
      convRule: rule124
  }, {
      start: 43446,
      length: 4,
      convRule: rule92
  }, {
      start: 43450,
      length: 2,
      convRule: rule124
  }, {
      start: 43452,
      length: 2,
      convRule: rule92
  }, {
      start: 43454,
      length: 3,
      convRule: rule124
  }, {
      start: 43457,
      length: 13,
      convRule: rule2
  }, {
      start: 43471,
      length: 1,
      convRule: rule91
  }, {
      start: 43472,
      length: 10,
      convRule: rule8
  }, {
      start: 43486,
      length: 2,
      convRule: rule2
  }, {
      start: 43488,
      length: 5,
      convRule: rule14
  }, {
      start: 43493,
      length: 1,
      convRule: rule92
  }, {
      start: 43494,
      length: 1,
      convRule: rule91
  }, {
      start: 43495,
      length: 9,
      convRule: rule14
  }, {
      start: 43504,
      length: 10,
      convRule: rule8
  }, {
      start: 43514,
      length: 5,
      convRule: rule14
  }, {
      start: 43520,
      length: 41,
      convRule: rule14
  }, {
      start: 43561,
      length: 6,
      convRule: rule92
  }, {
      start: 43567,
      length: 2,
      convRule: rule124
  }, {
      start: 43569,
      length: 2,
      convRule: rule92
  }, {
      start: 43571,
      length: 2,
      convRule: rule124
  }, {
      start: 43573,
      length: 2,
      convRule: rule92
  }, {
      start: 43584,
      length: 3,
      convRule: rule14
  }, {
      start: 43587,
      length: 1,
      convRule: rule92
  }, {
      start: 43588,
      length: 8,
      convRule: rule14
  }, {
      start: 43596,
      length: 1,
      convRule: rule92
  }, {
      start: 43597,
      length: 1,
      convRule: rule124
  }, {
      start: 43600,
      length: 10,
      convRule: rule8
  }, {
      start: 43612,
      length: 4,
      convRule: rule2
  }, {
      start: 43616,
      length: 16,
      convRule: rule14
  }, {
      start: 43632,
      length: 1,
      convRule: rule91
  }, {
      start: 43633,
      length: 6,
      convRule: rule14
  }, {
      start: 43639,
      length: 3,
      convRule: rule13
  }, {
      start: 43642,
      length: 1,
      convRule: rule14
  }, {
      start: 43643,
      length: 1,
      convRule: rule124
  }, {
      start: 43644,
      length: 1,
      convRule: rule92
  }, {
      start: 43645,
      length: 1,
      convRule: rule124
  }, {
      start: 43646,
      length: 50,
      convRule: rule14
  }, {
      start: 43696,
      length: 1,
      convRule: rule92
  }, {
      start: 43697,
      length: 1,
      convRule: rule14
  }, {
      start: 43698,
      length: 3,
      convRule: rule92
  }, {
      start: 43701,
      length: 2,
      convRule: rule14
  }, {
      start: 43703,
      length: 2,
      convRule: rule92
  }, {
      start: 43705,
      length: 5,
      convRule: rule14
  }, {
      start: 43710,
      length: 2,
      convRule: rule92
  }, {
      start: 43712,
      length: 1,
      convRule: rule14
  }, {
      start: 43713,
      length: 1,
      convRule: rule92
  }, {
      start: 43714,
      length: 1,
      convRule: rule14
  }, {
      start: 43739,
      length: 2,
      convRule: rule14
  }, {
      start: 43741,
      length: 1,
      convRule: rule91
  }, {
      start: 43742,
      length: 2,
      convRule: rule2
  }, {
      start: 43744,
      length: 11,
      convRule: rule14
  }, {
      start: 43755,
      length: 1,
      convRule: rule124
  }, {
      start: 43756,
      length: 2,
      convRule: rule92
  }, {
      start: 43758,
      length: 2,
      convRule: rule124
  }, {
      start: 43760,
      length: 2,
      convRule: rule2
  }, {
      start: 43762,
      length: 1,
      convRule: rule14
  }, {
      start: 43763,
      length: 2,
      convRule: rule91
  }, {
      start: 43765,
      length: 1,
      convRule: rule124
  }, {
      start: 43766,
      length: 1,
      convRule: rule92
  }, {
      start: 43777,
      length: 6,
      convRule: rule14
  }, {
      start: 43785,
      length: 6,
      convRule: rule14
  }, {
      start: 43793,
      length: 6,
      convRule: rule14
  }, {
      start: 43808,
      length: 7,
      convRule: rule14
  }, {
      start: 43816,
      length: 7,
      convRule: rule14
  }, {
      start: 43824,
      length: 35,
      convRule: rule20
  }, {
      start: 43859,
      length: 1,
      convRule: rule197
  }, {
      start: 43860,
      length: 7,
      convRule: rule20
  }, {
      start: 43867,
      length: 1,
      convRule: rule10
  }, {
      start: 43868,
      length: 4,
      convRule: rule91
  }, {
      start: 43872,
      length: 9,
      convRule: rule20
  }, {
      start: 43881,
      length: 1,
      convRule: rule91
  }, {
      start: 43882,
      length: 2,
      convRule: rule10
  }, {
      start: 43888,
      length: 80,
      convRule: rule198
  }, {
      start: 43968,
      length: 35,
      convRule: rule14
  }, {
      start: 44003,
      length: 2,
      convRule: rule124
  }, {
      start: 44005,
      length: 1,
      convRule: rule92
  }, {
      start: 44006,
      length: 2,
      convRule: rule124
  }, {
      start: 44008,
      length: 1,
      convRule: rule92
  }, {
      start: 44009,
      length: 2,
      convRule: rule124
  }, {
      start: 44011,
      length: 1,
      convRule: rule2
  }, {
      start: 44012,
      length: 1,
      convRule: rule124
  }, {
      start: 44013,
      length: 1,
      convRule: rule92
  }, {
      start: 44016,
      length: 10,
      convRule: rule8
  }, {
      start: 44032,
      length: 11172,
      convRule: rule14
  }, {
      start: 55216,
      length: 23,
      convRule: rule14
  }, {
      start: 55243,
      length: 49,
      convRule: rule14
  }, {
      start: 55296,
      length: 896,
      convRule: rule199
  }, {
      start: 56192,
      length: 128,
      convRule: rule199
  }, {
      start: 56320,
      length: 1024,
      convRule: rule199
  }, {
      start: 57344,
      length: 6400,
      convRule: rule200
  }, {
      start: 63744,
      length: 366,
      convRule: rule14
  }, {
      start: 64112,
      length: 106,
      convRule: rule14
  }, {
      start: 64256,
      length: 7,
      convRule: rule20
  }, {
      start: 64275,
      length: 5,
      convRule: rule20
  }, {
      start: 64285,
      length: 1,
      convRule: rule14
  }, {
      start: 64286,
      length: 1,
      convRule: rule92
  }, {
      start: 64287,
      length: 10,
      convRule: rule14
  }, {
      start: 64297,
      length: 1,
      convRule: rule6
  }, {
      start: 64298,
      length: 13,
      convRule: rule14
  }, {
      start: 64312,
      length: 5,
      convRule: rule14
  }, {
      start: 64318,
      length: 1,
      convRule: rule14
  }, {
      start: 64320,
      length: 2,
      convRule: rule14
  }, {
      start: 64323,
      length: 2,
      convRule: rule14
  }, {
      start: 64326,
      length: 108,
      convRule: rule14
  }, {
      start: 64434,
      length: 16,
      convRule: rule10
  }, {
      start: 64467,
      length: 363,
      convRule: rule14
  }, {
      start: 64830,
      length: 1,
      convRule: rule5
  }, {
      start: 64831,
      length: 1,
      convRule: rule4
  }, {
      start: 64848,
      length: 64,
      convRule: rule14
  }, {
      start: 64914,
      length: 54,
      convRule: rule14
  }, {
      start: 65008,
      length: 12,
      convRule: rule14
  }, {
      start: 65020,
      length: 1,
      convRule: rule3
  }, {
      start: 65021,
      length: 1,
      convRule: rule13
  }, {
      start: 65024,
      length: 16,
      convRule: rule92
  }, {
      start: 65040,
      length: 7,
      convRule: rule2
  }, {
      start: 65047,
      length: 1,
      convRule: rule4
  }, {
      start: 65048,
      length: 1,
      convRule: rule5
  }, {
      start: 65049,
      length: 1,
      convRule: rule2
  }, {
      start: 65056,
      length: 16,
      convRule: rule92
  }, {
      start: 65072,
      length: 1,
      convRule: rule2
  }, {
      start: 65073,
      length: 2,
      convRule: rule7
  }, {
      start: 65075,
      length: 2,
      convRule: rule11
  }, {
      start: 65077,
      length: 1,
      convRule: rule4
  }, {
      start: 65078,
      length: 1,
      convRule: rule5
  }, {
      start: 65079,
      length: 1,
      convRule: rule4
  }, {
      start: 65080,
      length: 1,
      convRule: rule5
  }, {
      start: 65081,
      length: 1,
      convRule: rule4
  }, {
      start: 65082,
      length: 1,
      convRule: rule5
  }, {
      start: 65083,
      length: 1,
      convRule: rule4
  }, {
      start: 65084,
      length: 1,
      convRule: rule5
  }, {
      start: 65085,
      length: 1,
      convRule: rule4
  }, {
      start: 65086,
      length: 1,
      convRule: rule5
  }, {
      start: 65087,
      length: 1,
      convRule: rule4
  }, {
      start: 65088,
      length: 1,
      convRule: rule5
  }, {
      start: 65089,
      length: 1,
      convRule: rule4
  }, {
      start: 65090,
      length: 1,
      convRule: rule5
  }, {
      start: 65091,
      length: 1,
      convRule: rule4
  }, {
      start: 65092,
      length: 1,
      convRule: rule5
  }, {
      start: 65093,
      length: 2,
      convRule: rule2
  }, {
      start: 65095,
      length: 1,
      convRule: rule4
  }, {
      start: 65096,
      length: 1,
      convRule: rule5
  }, {
      start: 65097,
      length: 4,
      convRule: rule2
  }, {
      start: 65101,
      length: 3,
      convRule: rule11
  }, {
      start: 65104,
      length: 3,
      convRule: rule2
  }, {
      start: 65108,
      length: 4,
      convRule: rule2
  }, {
      start: 65112,
      length: 1,
      convRule: rule7
  }, {
      start: 65113,
      length: 1,
      convRule: rule4
  }, {
      start: 65114,
      length: 1,
      convRule: rule5
  }, {
      start: 65115,
      length: 1,
      convRule: rule4
  }, {
      start: 65116,
      length: 1,
      convRule: rule5
  }, {
      start: 65117,
      length: 1,
      convRule: rule4
  }, {
      start: 65118,
      length: 1,
      convRule: rule5
  }, {
      start: 65119,
      length: 3,
      convRule: rule2
  }, {
      start: 65122,
      length: 1,
      convRule: rule6
  }, {
      start: 65123,
      length: 1,
      convRule: rule7
  }, {
      start: 65124,
      length: 3,
      convRule: rule6
  }, {
      start: 65128,
      length: 1,
      convRule: rule2
  }, {
      start: 65129,
      length: 1,
      convRule: rule3
  }, {
      start: 65130,
      length: 2,
      convRule: rule2
  }, {
      start: 65136,
      length: 5,
      convRule: rule14
  }, {
      start: 65142,
      length: 135,
      convRule: rule14
  }, {
      start: 65279,
      length: 1,
      convRule: rule16
  }, {
      start: 65281,
      length: 3,
      convRule: rule2
  }, {
      start: 65284,
      length: 1,
      convRule: rule3
  }, {
      start: 65285,
      length: 3,
      convRule: rule2
  }, {
      start: 65288,
      length: 1,
      convRule: rule4
  }, {
      start: 65289,
      length: 1,
      convRule: rule5
  }, {
      start: 65290,
      length: 1,
      convRule: rule2
  }, {
      start: 65291,
      length: 1,
      convRule: rule6
  }, {
      start: 65292,
      length: 1,
      convRule: rule2
  }, {
      start: 65293,
      length: 1,
      convRule: rule7
  }, {
      start: 65294,
      length: 2,
      convRule: rule2
  }, {
      start: 65296,
      length: 10,
      convRule: rule8
  }, {
      start: 65306,
      length: 2,
      convRule: rule2
  }, {
      start: 65308,
      length: 3,
      convRule: rule6
  }, {
      start: 65311,
      length: 2,
      convRule: rule2
  }, {
      start: 65313,
      length: 26,
      convRule: rule9
  }, {
      start: 65339,
      length: 1,
      convRule: rule4
  }, {
      start: 65340,
      length: 1,
      convRule: rule2
  }, {
      start: 65341,
      length: 1,
      convRule: rule5
  }, {
      start: 65342,
      length: 1,
      convRule: rule10
  }, {
      start: 65343,
      length: 1,
      convRule: rule11
  }, {
      start: 65344,
      length: 1,
      convRule: rule10
  }, {
      start: 65345,
      length: 26,
      convRule: rule12
  }, {
      start: 65371,
      length: 1,
      convRule: rule4
  }, {
      start: 65372,
      length: 1,
      convRule: rule6
  }, {
      start: 65373,
      length: 1,
      convRule: rule5
  }, {
      start: 65374,
      length: 1,
      convRule: rule6
  }, {
      start: 65375,
      length: 1,
      convRule: rule4
  }, {
      start: 65376,
      length: 1,
      convRule: rule5
  }, {
      start: 65377,
      length: 1,
      convRule: rule2
  }, {
      start: 65378,
      length: 1,
      convRule: rule4
  }, {
      start: 65379,
      length: 1,
      convRule: rule5
  }, {
      start: 65380,
      length: 2,
      convRule: rule2
  }, {
      start: 65382,
      length: 10,
      convRule: rule14
  }, {
      start: 65392,
      length: 1,
      convRule: rule91
  }, {
      start: 65393,
      length: 45,
      convRule: rule14
  }, {
      start: 65438,
      length: 2,
      convRule: rule91
  }, {
      start: 65440,
      length: 31,
      convRule: rule14
  }, {
      start: 65474,
      length: 6,
      convRule: rule14
  }, {
      start: 65482,
      length: 6,
      convRule: rule14
  }, {
      start: 65490,
      length: 6,
      convRule: rule14
  }, {
      start: 65498,
      length: 3,
      convRule: rule14
  }, {
      start: 65504,
      length: 2,
      convRule: rule3
  }, {
      start: 65506,
      length: 1,
      convRule: rule6
  }, {
      start: 65507,
      length: 1,
      convRule: rule10
  }, {
      start: 65508,
      length: 1,
      convRule: rule13
  }, {
      start: 65509,
      length: 2,
      convRule: rule3
  }, {
      start: 65512,
      length: 1,
      convRule: rule13
  }, {
      start: 65513,
      length: 4,
      convRule: rule6
  }, {
      start: 65517,
      length: 2,
      convRule: rule13
  }, {
      start: 65529,
      length: 3,
      convRule: rule16
  }, {
      start: 65532,
      length: 2,
      convRule: rule13
  }, {
      start: 65536,
      length: 12,
      convRule: rule14
  }, {
      start: 65549,
      length: 26,
      convRule: rule14
  }, {
      start: 65576,
      length: 19,
      convRule: rule14
  }, {
      start: 65596,
      length: 2,
      convRule: rule14
  }, {
      start: 65599,
      length: 15,
      convRule: rule14
  }, {
      start: 65616,
      length: 14,
      convRule: rule14
  }, {
      start: 65664,
      length: 123,
      convRule: rule14
  }, {
      start: 65792,
      length: 3,
      convRule: rule2
  }, {
      start: 65799,
      length: 45,
      convRule: rule17
  }, {
      start: 65847,
      length: 9,
      convRule: rule13
  }, {
      start: 65856,
      length: 53,
      convRule: rule128
  }, {
      start: 65909,
      length: 4,
      convRule: rule17
  }, {
      start: 65913,
      length: 17,
      convRule: rule13
  }, {
      start: 65930,
      length: 2,
      convRule: rule17
  }, {
      start: 65932,
      length: 3,
      convRule: rule13
  }, {
      start: 65936,
      length: 13,
      convRule: rule13
  }, {
      start: 65952,
      length: 1,
      convRule: rule13
  }, {
      start: 66000,
      length: 45,
      convRule: rule13
  }, {
      start: 66045,
      length: 1,
      convRule: rule92
  }, {
      start: 66176,
      length: 29,
      convRule: rule14
  }, {
      start: 66208,
      length: 49,
      convRule: rule14
  }, {
      start: 66272,
      length: 1,
      convRule: rule92
  }, {
      start: 66273,
      length: 27,
      convRule: rule17
  }, {
      start: 66304,
      length: 32,
      convRule: rule14
  }, {
      start: 66336,
      length: 4,
      convRule: rule17
  }, {
      start: 66349,
      length: 20,
      convRule: rule14
  }, {
      start: 66369,
      length: 1,
      convRule: rule128
  }, {
      start: 66370,
      length: 8,
      convRule: rule14
  }, {
      start: 66378,
      length: 1,
      convRule: rule128
  }, {
      start: 66384,
      length: 38,
      convRule: rule14
  }, {
      start: 66422,
      length: 5,
      convRule: rule92
  }, {
      start: 66432,
      length: 30,
      convRule: rule14
  }, {
      start: 66463,
      length: 1,
      convRule: rule2
  }, {
      start: 66464,
      length: 36,
      convRule: rule14
  }, {
      start: 66504,
      length: 8,
      convRule: rule14
  }, {
      start: 66512,
      length: 1,
      convRule: rule2
  }, {
      start: 66513,
      length: 5,
      convRule: rule128
  }, {
      start: 66560,
      length: 40,
      convRule: rule201
  }, {
      start: 66600,
      length: 40,
      convRule: rule202
  }, {
      start: 66640,
      length: 78,
      convRule: rule14
  }, {
      start: 66720,
      length: 10,
      convRule: rule8
  }, {
      start: 66736,
      length: 36,
      convRule: rule201
  }, {
      start: 66776,
      length: 36,
      convRule: rule202
  }, {
      start: 66816,
      length: 40,
      convRule: rule14
  }, {
      start: 66864,
      length: 52,
      convRule: rule14
  }, {
      start: 66927,
      length: 1,
      convRule: rule2
  }, {
      start: 67072,
      length: 311,
      convRule: rule14
  }, {
      start: 67392,
      length: 22,
      convRule: rule14
  }, {
      start: 67424,
      length: 8,
      convRule: rule14
  }, {
      start: 67584,
      length: 6,
      convRule: rule14
  }, {
      start: 67592,
      length: 1,
      convRule: rule14
  }, {
      start: 67594,
      length: 44,
      convRule: rule14
  }, {
      start: 67639,
      length: 2,
      convRule: rule14
  }, {
      start: 67644,
      length: 1,
      convRule: rule14
  }, {
      start: 67647,
      length: 23,
      convRule: rule14
  }, {
      start: 67671,
      length: 1,
      convRule: rule2
  }, {
      start: 67672,
      length: 8,
      convRule: rule17
  }, {
      start: 67680,
      length: 23,
      convRule: rule14
  }, {
      start: 67703,
      length: 2,
      convRule: rule13
  }, {
      start: 67705,
      length: 7,
      convRule: rule17
  }, {
      start: 67712,
      length: 31,
      convRule: rule14
  }, {
      start: 67751,
      length: 9,
      convRule: rule17
  }, {
      start: 67808,
      length: 19,
      convRule: rule14
  }, {
      start: 67828,
      length: 2,
      convRule: rule14
  }, {
      start: 67835,
      length: 5,
      convRule: rule17
  }, {
      start: 67840,
      length: 22,
      convRule: rule14
  }, {
      start: 67862,
      length: 6,
      convRule: rule17
  }, {
      start: 67871,
      length: 1,
      convRule: rule2
  }, {
      start: 67872,
      length: 26,
      convRule: rule14
  }, {
      start: 67903,
      length: 1,
      convRule: rule2
  }, {
      start: 67968,
      length: 56,
      convRule: rule14
  }, {
      start: 68028,
      length: 2,
      convRule: rule17
  }, {
      start: 68030,
      length: 2,
      convRule: rule14
  }, {
      start: 68032,
      length: 16,
      convRule: rule17
  }, {
      start: 68050,
      length: 46,
      convRule: rule17
  }, {
      start: 68096,
      length: 1,
      convRule: rule14
  }, {
      start: 68097,
      length: 3,
      convRule: rule92
  }, {
      start: 68101,
      length: 2,
      convRule: rule92
  }, {
      start: 68108,
      length: 4,
      convRule: rule92
  }, {
      start: 68112,
      length: 4,
      convRule: rule14
  }, {
      start: 68117,
      length: 3,
      convRule: rule14
  }, {
      start: 68121,
      length: 29,
      convRule: rule14
  }, {
      start: 68152,
      length: 3,
      convRule: rule92
  }, {
      start: 68159,
      length: 1,
      convRule: rule92
  }, {
      start: 68160,
      length: 9,
      convRule: rule17
  }, {
      start: 68176,
      length: 9,
      convRule: rule2
  }, {
      start: 68192,
      length: 29,
      convRule: rule14
  }, {
      start: 68221,
      length: 2,
      convRule: rule17
  }, {
      start: 68223,
      length: 1,
      convRule: rule2
  }, {
      start: 68224,
      length: 29,
      convRule: rule14
  }, {
      start: 68253,
      length: 3,
      convRule: rule17
  }, {
      start: 68288,
      length: 8,
      convRule: rule14
  }, {
      start: 68296,
      length: 1,
      convRule: rule13
  }, {
      start: 68297,
      length: 28,
      convRule: rule14
  }, {
      start: 68325,
      length: 2,
      convRule: rule92
  }, {
      start: 68331,
      length: 5,
      convRule: rule17
  }, {
      start: 68336,
      length: 7,
      convRule: rule2
  }, {
      start: 68352,
      length: 54,
      convRule: rule14
  }, {
      start: 68409,
      length: 7,
      convRule: rule2
  }, {
      start: 68416,
      length: 22,
      convRule: rule14
  }, {
      start: 68440,
      length: 8,
      convRule: rule17
  }, {
      start: 68448,
      length: 19,
      convRule: rule14
  }, {
      start: 68472,
      length: 8,
      convRule: rule17
  }, {
      start: 68480,
      length: 18,
      convRule: rule14
  }, {
      start: 68505,
      length: 4,
      convRule: rule2
  }, {
      start: 68521,
      length: 7,
      convRule: rule17
  }, {
      start: 68608,
      length: 73,
      convRule: rule14
  }, {
      start: 68736,
      length: 51,
      convRule: rule97
  }, {
      start: 68800,
      length: 51,
      convRule: rule102
  }, {
      start: 68858,
      length: 6,
      convRule: rule17
  }, {
      start: 68864,
      length: 36,
      convRule: rule14
  }, {
      start: 68900,
      length: 4,
      convRule: rule92
  }, {
      start: 68912,
      length: 10,
      convRule: rule8
  }, {
      start: 69216,
      length: 31,
      convRule: rule17
  }, {
      start: 69248,
      length: 42,
      convRule: rule14
  }, {
      start: 69291,
      length: 2,
      convRule: rule92
  }, {
      start: 69293,
      length: 1,
      convRule: rule7
  }, {
      start: 69296,
      length: 2,
      convRule: rule14
  }, {
      start: 69376,
      length: 29,
      convRule: rule14
  }, {
      start: 69405,
      length: 10,
      convRule: rule17
  }, {
      start: 69415,
      length: 1,
      convRule: rule14
  }, {
      start: 69424,
      length: 22,
      convRule: rule14
  }, {
      start: 69446,
      length: 11,
      convRule: rule92
  }, {
      start: 69457,
      length: 4,
      convRule: rule17
  }, {
      start: 69461,
      length: 5,
      convRule: rule2
  }, {
      start: 69552,
      length: 21,
      convRule: rule14
  }, {
      start: 69573,
      length: 7,
      convRule: rule17
  }, {
      start: 69600,
      length: 23,
      convRule: rule14
  }, {
      start: 69632,
      length: 1,
      convRule: rule124
  }, {
      start: 69633,
      length: 1,
      convRule: rule92
  }, {
      start: 69634,
      length: 1,
      convRule: rule124
  }, {
      start: 69635,
      length: 53,
      convRule: rule14
  }, {
      start: 69688,
      length: 15,
      convRule: rule92
  }, {
      start: 69703,
      length: 7,
      convRule: rule2
  }, {
      start: 69714,
      length: 20,
      convRule: rule17
  }, {
      start: 69734,
      length: 10,
      convRule: rule8
  }, {
      start: 69759,
      length: 3,
      convRule: rule92
  }, {
      start: 69762,
      length: 1,
      convRule: rule124
  }, {
      start: 69763,
      length: 45,
      convRule: rule14
  }, {
      start: 69808,
      length: 3,
      convRule: rule124
  }, {
      start: 69811,
      length: 4,
      convRule: rule92
  }, {
      start: 69815,
      length: 2,
      convRule: rule124
  }, {
      start: 69817,
      length: 2,
      convRule: rule92
  }, {
      start: 69819,
      length: 2,
      convRule: rule2
  }, {
      start: 69821,
      length: 1,
      convRule: rule16
  }, {
      start: 69822,
      length: 4,
      convRule: rule2
  }, {
      start: 69837,
      length: 1,
      convRule: rule16
  }, {
      start: 69840,
      length: 25,
      convRule: rule14
  }, {
      start: 69872,
      length: 10,
      convRule: rule8
  }, {
      start: 69888,
      length: 3,
      convRule: rule92
  }, {
      start: 69891,
      length: 36,
      convRule: rule14
  }, {
      start: 69927,
      length: 5,
      convRule: rule92
  }, {
      start: 69932,
      length: 1,
      convRule: rule124
  }, {
      start: 69933,
      length: 8,
      convRule: rule92
  }, {
      start: 69942,
      length: 10,
      convRule: rule8
  }, {
      start: 69952,
      length: 4,
      convRule: rule2
  }, {
      start: 69956,
      length: 1,
      convRule: rule14
  }, {
      start: 69957,
      length: 2,
      convRule: rule124
  }, {
      start: 69959,
      length: 1,
      convRule: rule14
  }, {
      start: 69968,
      length: 35,
      convRule: rule14
  }, {
      start: 70003,
      length: 1,
      convRule: rule92
  }, {
      start: 70004,
      length: 2,
      convRule: rule2
  }, {
      start: 70006,
      length: 1,
      convRule: rule14
  }, {
      start: 70016,
      length: 2,
      convRule: rule92
  }, {
      start: 70018,
      length: 1,
      convRule: rule124
  }, {
      start: 70019,
      length: 48,
      convRule: rule14
  }, {
      start: 70067,
      length: 3,
      convRule: rule124
  }, {
      start: 70070,
      length: 9,
      convRule: rule92
  }, {
      start: 70079,
      length: 2,
      convRule: rule124
  }, {
      start: 70081,
      length: 4,
      convRule: rule14
  }, {
      start: 70085,
      length: 4,
      convRule: rule2
  }, {
      start: 70089,
      length: 4,
      convRule: rule92
  }, {
      start: 70093,
      length: 1,
      convRule: rule2
  }, {
      start: 70094,
      length: 1,
      convRule: rule124
  }, {
      start: 70095,
      length: 1,
      convRule: rule92
  }, {
      start: 70096,
      length: 10,
      convRule: rule8
  }, {
      start: 70106,
      length: 1,
      convRule: rule14
  }, {
      start: 70107,
      length: 1,
      convRule: rule2
  }, {
      start: 70108,
      length: 1,
      convRule: rule14
  }, {
      start: 70109,
      length: 3,
      convRule: rule2
  }, {
      start: 70113,
      length: 20,
      convRule: rule17
  }, {
      start: 70144,
      length: 18,
      convRule: rule14
  }, {
      start: 70163,
      length: 25,
      convRule: rule14
  }, {
      start: 70188,
      length: 3,
      convRule: rule124
  }, {
      start: 70191,
      length: 3,
      convRule: rule92
  }, {
      start: 70194,
      length: 2,
      convRule: rule124
  }, {
      start: 70196,
      length: 1,
      convRule: rule92
  }, {
      start: 70197,
      length: 1,
      convRule: rule124
  }, {
      start: 70198,
      length: 2,
      convRule: rule92
  }, {
      start: 70200,
      length: 6,
      convRule: rule2
  }, {
      start: 70206,
      length: 1,
      convRule: rule92
  }, {
      start: 70272,
      length: 7,
      convRule: rule14
  }, {
      start: 70280,
      length: 1,
      convRule: rule14
  }, {
      start: 70282,
      length: 4,
      convRule: rule14
  }, {
      start: 70287,
      length: 15,
      convRule: rule14
  }, {
      start: 70303,
      length: 10,
      convRule: rule14
  }, {
      start: 70313,
      length: 1,
      convRule: rule2
  }, {
      start: 70320,
      length: 47,
      convRule: rule14
  }, {
      start: 70367,
      length: 1,
      convRule: rule92
  }, {
      start: 70368,
      length: 3,
      convRule: rule124
  }, {
      start: 70371,
      length: 8,
      convRule: rule92
  }, {
      start: 70384,
      length: 10,
      convRule: rule8
  }, {
      start: 70400,
      length: 2,
      convRule: rule92
  }, {
      start: 70402,
      length: 2,
      convRule: rule124
  }, {
      start: 70405,
      length: 8,
      convRule: rule14
  }, {
      start: 70415,
      length: 2,
      convRule: rule14
  }, {
      start: 70419,
      length: 22,
      convRule: rule14
  }, {
      start: 70442,
      length: 7,
      convRule: rule14
  }, {
      start: 70450,
      length: 2,
      convRule: rule14
  }, {
      start: 70453,
      length: 5,
      convRule: rule14
  }, {
      start: 70459,
      length: 2,
      convRule: rule92
  }, {
      start: 70461,
      length: 1,
      convRule: rule14
  }, {
      start: 70462,
      length: 2,
      convRule: rule124
  }, {
      start: 70464,
      length: 1,
      convRule: rule92
  }, {
      start: 70465,
      length: 4,
      convRule: rule124
  }, {
      start: 70471,
      length: 2,
      convRule: rule124
  }, {
      start: 70475,
      length: 3,
      convRule: rule124
  }, {
      start: 70480,
      length: 1,
      convRule: rule14
  }, {
      start: 70487,
      length: 1,
      convRule: rule124
  }, {
      start: 70493,
      length: 5,
      convRule: rule14
  }, {
      start: 70498,
      length: 2,
      convRule: rule124
  }, {
      start: 70502,
      length: 7,
      convRule: rule92
  }, {
      start: 70512,
      length: 5,
      convRule: rule92
  }, {
      start: 70656,
      length: 53,
      convRule: rule14
  }, {
      start: 70709,
      length: 3,
      convRule: rule124
  }, {
      start: 70712,
      length: 8,
      convRule: rule92
  }, {
      start: 70720,
      length: 2,
      convRule: rule124
  }, {
      start: 70722,
      length: 3,
      convRule: rule92
  }, {
      start: 70725,
      length: 1,
      convRule: rule124
  }, {
      start: 70726,
      length: 1,
      convRule: rule92
  }, {
      start: 70727,
      length: 4,
      convRule: rule14
  }, {
      start: 70731,
      length: 5,
      convRule: rule2
  }, {
      start: 70736,
      length: 10,
      convRule: rule8
  }, {
      start: 70746,
      length: 2,
      convRule: rule2
  }, {
      start: 70749,
      length: 1,
      convRule: rule2
  }, {
      start: 70750,
      length: 1,
      convRule: rule92
  }, {
      start: 70751,
      length: 3,
      convRule: rule14
  }, {
      start: 70784,
      length: 48,
      convRule: rule14
  }, {
      start: 70832,
      length: 3,
      convRule: rule124
  }, {
      start: 70835,
      length: 6,
      convRule: rule92
  }, {
      start: 70841,
      length: 1,
      convRule: rule124
  }, {
      start: 70842,
      length: 1,
      convRule: rule92
  }, {
      start: 70843,
      length: 4,
      convRule: rule124
  }, {
      start: 70847,
      length: 2,
      convRule: rule92
  }, {
      start: 70849,
      length: 1,
      convRule: rule124
  }, {
      start: 70850,
      length: 2,
      convRule: rule92
  }, {
      start: 70852,
      length: 2,
      convRule: rule14
  }, {
      start: 70854,
      length: 1,
      convRule: rule2
  }, {
      start: 70855,
      length: 1,
      convRule: rule14
  }, {
      start: 70864,
      length: 10,
      convRule: rule8
  }, {
      start: 71040,
      length: 47,
      convRule: rule14
  }, {
      start: 71087,
      length: 3,
      convRule: rule124
  }, {
      start: 71090,
      length: 4,
      convRule: rule92
  }, {
      start: 71096,
      length: 4,
      convRule: rule124
  }, {
      start: 71100,
      length: 2,
      convRule: rule92
  }, {
      start: 71102,
      length: 1,
      convRule: rule124
  }, {
      start: 71103,
      length: 2,
      convRule: rule92
  }, {
      start: 71105,
      length: 23,
      convRule: rule2
  }, {
      start: 71128,
      length: 4,
      convRule: rule14
  }, {
      start: 71132,
      length: 2,
      convRule: rule92
  }, {
      start: 71168,
      length: 48,
      convRule: rule14
  }, {
      start: 71216,
      length: 3,
      convRule: rule124
  }, {
      start: 71219,
      length: 8,
      convRule: rule92
  }, {
      start: 71227,
      length: 2,
      convRule: rule124
  }, {
      start: 71229,
      length: 1,
      convRule: rule92
  }, {
      start: 71230,
      length: 1,
      convRule: rule124
  }, {
      start: 71231,
      length: 2,
      convRule: rule92
  }, {
      start: 71233,
      length: 3,
      convRule: rule2
  }, {
      start: 71236,
      length: 1,
      convRule: rule14
  }, {
      start: 71248,
      length: 10,
      convRule: rule8
  }, {
      start: 71264,
      length: 13,
      convRule: rule2
  }, {
      start: 71296,
      length: 43,
      convRule: rule14
  }, {
      start: 71339,
      length: 1,
      convRule: rule92
  }, {
      start: 71340,
      length: 1,
      convRule: rule124
  }, {
      start: 71341,
      length: 1,
      convRule: rule92
  }, {
      start: 71342,
      length: 2,
      convRule: rule124
  }, {
      start: 71344,
      length: 6,
      convRule: rule92
  }, {
      start: 71350,
      length: 1,
      convRule: rule124
  }, {
      start: 71351,
      length: 1,
      convRule: rule92
  }, {
      start: 71352,
      length: 1,
      convRule: rule14
  }, {
      start: 71360,
      length: 10,
      convRule: rule8
  }, {
      start: 71424,
      length: 27,
      convRule: rule14
  }, {
      start: 71453,
      length: 3,
      convRule: rule92
  }, {
      start: 71456,
      length: 2,
      convRule: rule124
  }, {
      start: 71458,
      length: 4,
      convRule: rule92
  }, {
      start: 71462,
      length: 1,
      convRule: rule124
  }, {
      start: 71463,
      length: 5,
      convRule: rule92
  }, {
      start: 71472,
      length: 10,
      convRule: rule8
  }, {
      start: 71482,
      length: 2,
      convRule: rule17
  }, {
      start: 71484,
      length: 3,
      convRule: rule2
  }, {
      start: 71487,
      length: 1,
      convRule: rule13
  }, {
      start: 71680,
      length: 44,
      convRule: rule14
  }, {
      start: 71724,
      length: 3,
      convRule: rule124
  }, {
      start: 71727,
      length: 9,
      convRule: rule92
  }, {
      start: 71736,
      length: 1,
      convRule: rule124
  }, {
      start: 71737,
      length: 2,
      convRule: rule92
  }, {
      start: 71739,
      length: 1,
      convRule: rule2
  }, {
      start: 71840,
      length: 32,
      convRule: rule9
  }, {
      start: 71872,
      length: 32,
      convRule: rule12
  }, {
      start: 71904,
      length: 10,
      convRule: rule8
  }, {
      start: 71914,
      length: 9,
      convRule: rule17
  }, {
      start: 71935,
      length: 8,
      convRule: rule14
  }, {
      start: 71945,
      length: 1,
      convRule: rule14
  }, {
      start: 71948,
      length: 8,
      convRule: rule14
  }, {
      start: 71957,
      length: 2,
      convRule: rule14
  }, {
      start: 71960,
      length: 24,
      convRule: rule14
  }, {
      start: 71984,
      length: 6,
      convRule: rule124
  }, {
      start: 71991,
      length: 2,
      convRule: rule124
  }, {
      start: 71995,
      length: 2,
      convRule: rule92
  }, {
      start: 71997,
      length: 1,
      convRule: rule124
  }, {
      start: 71998,
      length: 1,
      convRule: rule92
  }, {
      start: 71999,
      length: 1,
      convRule: rule14
  }, {
      start: 72000,
      length: 1,
      convRule: rule124
  }, {
      start: 72001,
      length: 1,
      convRule: rule14
  }, {
      start: 72002,
      length: 1,
      convRule: rule124
  }, {
      start: 72003,
      length: 1,
      convRule: rule92
  }, {
      start: 72004,
      length: 3,
      convRule: rule2
  }, {
      start: 72016,
      length: 10,
      convRule: rule8
  }, {
      start: 72096,
      length: 8,
      convRule: rule14
  }, {
      start: 72106,
      length: 39,
      convRule: rule14
  }, {
      start: 72145,
      length: 3,
      convRule: rule124
  }, {
      start: 72148,
      length: 4,
      convRule: rule92
  }, {
      start: 72154,
      length: 2,
      convRule: rule92
  }, {
      start: 72156,
      length: 4,
      convRule: rule124
  }, {
      start: 72160,
      length: 1,
      convRule: rule92
  }, {
      start: 72161,
      length: 1,
      convRule: rule14
  }, {
      start: 72162,
      length: 1,
      convRule: rule2
  }, {
      start: 72163,
      length: 1,
      convRule: rule14
  }, {
      start: 72164,
      length: 1,
      convRule: rule124
  }, {
      start: 72192,
      length: 1,
      convRule: rule14
  }, {
      start: 72193,
      length: 10,
      convRule: rule92
  }, {
      start: 72203,
      length: 40,
      convRule: rule14
  }, {
      start: 72243,
      length: 6,
      convRule: rule92
  }, {
      start: 72249,
      length: 1,
      convRule: rule124
  }, {
      start: 72250,
      length: 1,
      convRule: rule14
  }, {
      start: 72251,
      length: 4,
      convRule: rule92
  }, {
      start: 72255,
      length: 8,
      convRule: rule2
  }, {
      start: 72263,
      length: 1,
      convRule: rule92
  }, {
      start: 72272,
      length: 1,
      convRule: rule14
  }, {
      start: 72273,
      length: 6,
      convRule: rule92
  }, {
      start: 72279,
      length: 2,
      convRule: rule124
  }, {
      start: 72281,
      length: 3,
      convRule: rule92
  }, {
      start: 72284,
      length: 46,
      convRule: rule14
  }, {
      start: 72330,
      length: 13,
      convRule: rule92
  }, {
      start: 72343,
      length: 1,
      convRule: rule124
  }, {
      start: 72344,
      length: 2,
      convRule: rule92
  }, {
      start: 72346,
      length: 3,
      convRule: rule2
  }, {
      start: 72349,
      length: 1,
      convRule: rule14
  }, {
      start: 72350,
      length: 5,
      convRule: rule2
  }, {
      start: 72384,
      length: 57,
      convRule: rule14
  }, {
      start: 72704,
      length: 9,
      convRule: rule14
  }, {
      start: 72714,
      length: 37,
      convRule: rule14
  }, {
      start: 72751,
      length: 1,
      convRule: rule124
  }, {
      start: 72752,
      length: 7,
      convRule: rule92
  }, {
      start: 72760,
      length: 6,
      convRule: rule92
  }, {
      start: 72766,
      length: 1,
      convRule: rule124
  }, {
      start: 72767,
      length: 1,
      convRule: rule92
  }, {
      start: 72768,
      length: 1,
      convRule: rule14
  }, {
      start: 72769,
      length: 5,
      convRule: rule2
  }, {
      start: 72784,
      length: 10,
      convRule: rule8
  }, {
      start: 72794,
      length: 19,
      convRule: rule17
  }, {
      start: 72816,
      length: 2,
      convRule: rule2
  }, {
      start: 72818,
      length: 30,
      convRule: rule14
  }, {
      start: 72850,
      length: 22,
      convRule: rule92
  }, {
      start: 72873,
      length: 1,
      convRule: rule124
  }, {
      start: 72874,
      length: 7,
      convRule: rule92
  }, {
      start: 72881,
      length: 1,
      convRule: rule124
  }, {
      start: 72882,
      length: 2,
      convRule: rule92
  }, {
      start: 72884,
      length: 1,
      convRule: rule124
  }, {
      start: 72885,
      length: 2,
      convRule: rule92
  }, {
      start: 72960,
      length: 7,
      convRule: rule14
  }, {
      start: 72968,
      length: 2,
      convRule: rule14
  }, {
      start: 72971,
      length: 38,
      convRule: rule14
  }, {
      start: 73009,
      length: 6,
      convRule: rule92
  }, {
      start: 73018,
      length: 1,
      convRule: rule92
  }, {
      start: 73020,
      length: 2,
      convRule: rule92
  }, {
      start: 73023,
      length: 7,
      convRule: rule92
  }, {
      start: 73030,
      length: 1,
      convRule: rule14
  }, {
      start: 73031,
      length: 1,
      convRule: rule92
  }, {
      start: 73040,
      length: 10,
      convRule: rule8
  }, {
      start: 73056,
      length: 6,
      convRule: rule14
  }, {
      start: 73063,
      length: 2,
      convRule: rule14
  }, {
      start: 73066,
      length: 32,
      convRule: rule14
  }, {
      start: 73098,
      length: 5,
      convRule: rule124
  }, {
      start: 73104,
      length: 2,
      convRule: rule92
  }, {
      start: 73107,
      length: 2,
      convRule: rule124
  }, {
      start: 73109,
      length: 1,
      convRule: rule92
  }, {
      start: 73110,
      length: 1,
      convRule: rule124
  }, {
      start: 73111,
      length: 1,
      convRule: rule92
  }, {
      start: 73112,
      length: 1,
      convRule: rule14
  }, {
      start: 73120,
      length: 10,
      convRule: rule8
  }, {
      start: 73440,
      length: 19,
      convRule: rule14
  }, {
      start: 73459,
      length: 2,
      convRule: rule92
  }, {
      start: 73461,
      length: 2,
      convRule: rule124
  }, {
      start: 73463,
      length: 2,
      convRule: rule2
  }, {
      start: 73648,
      length: 1,
      convRule: rule14
  }, {
      start: 73664,
      length: 21,
      convRule: rule17
  }, {
      start: 73685,
      length: 8,
      convRule: rule13
  }, {
      start: 73693,
      length: 4,
      convRule: rule3
  }, {
      start: 73697,
      length: 17,
      convRule: rule13
  }, {
      start: 73727,
      length: 1,
      convRule: rule2
  }, {
      start: 73728,
      length: 922,
      convRule: rule14
  }, {
      start: 74752,
      length: 111,
      convRule: rule128
  }, {
      start: 74864,
      length: 5,
      convRule: rule2
  }, {
      start: 74880,
      length: 196,
      convRule: rule14
  }, {
      start: 77824,
      length: 1071,
      convRule: rule14
  }, {
      start: 78896,
      length: 9,
      convRule: rule16
  }, {
      start: 82944,
      length: 583,
      convRule: rule14
  }, {
      start: 92160,
      length: 569,
      convRule: rule14
  }, {
      start: 92736,
      length: 31,
      convRule: rule14
  }, {
      start: 92768,
      length: 10,
      convRule: rule8
  }, {
      start: 92782,
      length: 2,
      convRule: rule2
  }, {
      start: 92880,
      length: 30,
      convRule: rule14
  }, {
      start: 92912,
      length: 5,
      convRule: rule92
  }, {
      start: 92917,
      length: 1,
      convRule: rule2
  }, {
      start: 92928,
      length: 48,
      convRule: rule14
  }, {
      start: 92976,
      length: 7,
      convRule: rule92
  }, {
      start: 92983,
      length: 5,
      convRule: rule2
  }, {
      start: 92988,
      length: 4,
      convRule: rule13
  }, {
      start: 92992,
      length: 4,
      convRule: rule91
  }, {
      start: 92996,
      length: 1,
      convRule: rule2
  }, {
      start: 92997,
      length: 1,
      convRule: rule13
  }, {
      start: 93008,
      length: 10,
      convRule: rule8
  }, {
      start: 93019,
      length: 7,
      convRule: rule17
  }, {
      start: 93027,
      length: 21,
      convRule: rule14
  }, {
      start: 93053,
      length: 19,
      convRule: rule14
  }, {
      start: 93760,
      length: 32,
      convRule: rule9
  }, {
      start: 93792,
      length: 32,
      convRule: rule12
  }, {
      start: 93824,
      length: 23,
      convRule: rule17
  }, {
      start: 93847,
      length: 4,
      convRule: rule2
  }, {
      start: 93952,
      length: 75,
      convRule: rule14
  }, {
      start: 94031,
      length: 1,
      convRule: rule92
  }, {
      start: 94032,
      length: 1,
      convRule: rule14
  }, {
      start: 94033,
      length: 55,
      convRule: rule124
  }, {
      start: 94095,
      length: 4,
      convRule: rule92
  }, {
      start: 94099,
      length: 13,
      convRule: rule91
  }, {
      start: 94176,
      length: 2,
      convRule: rule91
  }, {
      start: 94178,
      length: 1,
      convRule: rule2
  }, {
      start: 94179,
      length: 1,
      convRule: rule91
  }, {
      start: 94180,
      length: 1,
      convRule: rule92
  }, {
      start: 94192,
      length: 2,
      convRule: rule124
  }, {
      start: 94208,
      length: 6136,
      convRule: rule14
  }, {
      start: 100352,
      length: 1238,
      convRule: rule14
  }, {
      start: 101632,
      length: 9,
      convRule: rule14
  }, {
      start: 110592,
      length: 287,
      convRule: rule14
  }, {
      start: 110928,
      length: 3,
      convRule: rule14
  }, {
      start: 110948,
      length: 4,
      convRule: rule14
  }, {
      start: 110960,
      length: 396,
      convRule: rule14
  }, {
      start: 113664,
      length: 107,
      convRule: rule14
  }, {
      start: 113776,
      length: 13,
      convRule: rule14
  }, {
      start: 113792,
      length: 9,
      convRule: rule14
  }, {
      start: 113808,
      length: 10,
      convRule: rule14
  }, {
      start: 113820,
      length: 1,
      convRule: rule13
  }, {
      start: 113821,
      length: 2,
      convRule: rule92
  }, {
      start: 113823,
      length: 1,
      convRule: rule2
  }, {
      start: 113824,
      length: 4,
      convRule: rule16
  }, {
      start: 118784,
      length: 246,
      convRule: rule13
  }, {
      start: 119040,
      length: 39,
      convRule: rule13
  }, {
      start: 119081,
      length: 60,
      convRule: rule13
  }, {
      start: 119141,
      length: 2,
      convRule: rule124
  }, {
      start: 119143,
      length: 3,
      convRule: rule92
  }, {
      start: 119146,
      length: 3,
      convRule: rule13
  }, {
      start: 119149,
      length: 6,
      convRule: rule124
  }, {
      start: 119155,
      length: 8,
      convRule: rule16
  }, {
      start: 119163,
      length: 8,
      convRule: rule92
  }, {
      start: 119171,
      length: 2,
      convRule: rule13
  }, {
      start: 119173,
      length: 7,
      convRule: rule92
  }, {
      start: 119180,
      length: 30,
      convRule: rule13
  }, {
      start: 119210,
      length: 4,
      convRule: rule92
  }, {
      start: 119214,
      length: 59,
      convRule: rule13
  }, {
      start: 119296,
      length: 66,
      convRule: rule13
  }, {
      start: 119362,
      length: 3,
      convRule: rule92
  }, {
      start: 119365,
      length: 1,
      convRule: rule13
  }, {
      start: 119520,
      length: 20,
      convRule: rule17
  }, {
      start: 119552,
      length: 87,
      convRule: rule13
  }, {
      start: 119648,
      length: 25,
      convRule: rule17
  }, {
      start: 119808,
      length: 26,
      convRule: rule107
  }, {
      start: 119834,
      length: 26,
      convRule: rule20
  }, {
      start: 119860,
      length: 26,
      convRule: rule107
  }, {
      start: 119886,
      length: 7,
      convRule: rule20
  }, {
      start: 119894,
      length: 18,
      convRule: rule20
  }, {
      start: 119912,
      length: 26,
      convRule: rule107
  }, {
      start: 119938,
      length: 26,
      convRule: rule20
  }, {
      start: 119964,
      length: 1,
      convRule: rule107
  }, {
      start: 119966,
      length: 2,
      convRule: rule107
  }, {
      start: 119970,
      length: 1,
      convRule: rule107
  }, {
      start: 119973,
      length: 2,
      convRule: rule107
  }, {
      start: 119977,
      length: 4,
      convRule: rule107
  }, {
      start: 119982,
      length: 8,
      convRule: rule107
  }, {
      start: 119990,
      length: 4,
      convRule: rule20
  }, {
      start: 119995,
      length: 1,
      convRule: rule20
  }, {
      start: 119997,
      length: 7,
      convRule: rule20
  }, {
      start: 120005,
      length: 11,
      convRule: rule20
  }, {
      start: 120016,
      length: 26,
      convRule: rule107
  }, {
      start: 120042,
      length: 26,
      convRule: rule20
  }, {
      start: 120068,
      length: 2,
      convRule: rule107
  }, {
      start: 120071,
      length: 4,
      convRule: rule107
  }, {
      start: 120077,
      length: 8,
      convRule: rule107
  }, {
      start: 120086,
      length: 7,
      convRule: rule107
  }, {
      start: 120094,
      length: 26,
      convRule: rule20
  }, {
      start: 120120,
      length: 2,
      convRule: rule107
  }, {
      start: 120123,
      length: 4,
      convRule: rule107
  }, {
      start: 120128,
      length: 5,
      convRule: rule107
  }, {
      start: 120134,
      length: 1,
      convRule: rule107
  }, {
      start: 120138,
      length: 7,
      convRule: rule107
  }, {
      start: 120146,
      length: 26,
      convRule: rule20
  }, {
      start: 120172,
      length: 26,
      convRule: rule107
  }, {
      start: 120198,
      length: 26,
      convRule: rule20
  }, {
      start: 120224,
      length: 26,
      convRule: rule107
  }, {
      start: 120250,
      length: 26,
      convRule: rule20
  }, {
      start: 120276,
      length: 26,
      convRule: rule107
  }, {
      start: 120302,
      length: 26,
      convRule: rule20
  }, {
      start: 120328,
      length: 26,
      convRule: rule107
  }, {
      start: 120354,
      length: 26,
      convRule: rule20
  }, {
      start: 120380,
      length: 26,
      convRule: rule107
  }, {
      start: 120406,
      length: 26,
      convRule: rule20
  }, {
      start: 120432,
      length: 26,
      convRule: rule107
  }, {
      start: 120458,
      length: 28,
      convRule: rule20
  }, {
      start: 120488,
      length: 25,
      convRule: rule107
  }, {
      start: 120513,
      length: 1,
      convRule: rule6
  }, {
      start: 120514,
      length: 25,
      convRule: rule20
  }, {
      start: 120539,
      length: 1,
      convRule: rule6
  }, {
      start: 120540,
      length: 6,
      convRule: rule20
  }, {
      start: 120546,
      length: 25,
      convRule: rule107
  }, {
      start: 120571,
      length: 1,
      convRule: rule6
  }, {
      start: 120572,
      length: 25,
      convRule: rule20
  }, {
      start: 120597,
      length: 1,
      convRule: rule6
  }, {
      start: 120598,
      length: 6,
      convRule: rule20
  }, {
      start: 120604,
      length: 25,
      convRule: rule107
  }, {
      start: 120629,
      length: 1,
      convRule: rule6
  }, {
      start: 120630,
      length: 25,
      convRule: rule20
  }, {
      start: 120655,
      length: 1,
      convRule: rule6
  }, {
      start: 120656,
      length: 6,
      convRule: rule20
  }, {
      start: 120662,
      length: 25,
      convRule: rule107
  }, {
      start: 120687,
      length: 1,
      convRule: rule6
  }, {
      start: 120688,
      length: 25,
      convRule: rule20
  }, {
      start: 120713,
      length: 1,
      convRule: rule6
  }, {
      start: 120714,
      length: 6,
      convRule: rule20
  }, {
      start: 120720,
      length: 25,
      convRule: rule107
  }, {
      start: 120745,
      length: 1,
      convRule: rule6
  }, {
      start: 120746,
      length: 25,
      convRule: rule20
  }, {
      start: 120771,
      length: 1,
      convRule: rule6
  }, {
      start: 120772,
      length: 6,
      convRule: rule20
  }, {
      start: 120778,
      length: 1,
      convRule: rule107
  }, {
      start: 120779,
      length: 1,
      convRule: rule20
  }, {
      start: 120782,
      length: 50,
      convRule: rule8
  }, {
      start: 120832,
      length: 512,
      convRule: rule13
  }, {
      start: 121344,
      length: 55,
      convRule: rule92
  }, {
      start: 121399,
      length: 4,
      convRule: rule13
  }, {
      start: 121403,
      length: 50,
      convRule: rule92
  }, {
      start: 121453,
      length: 8,
      convRule: rule13
  }, {
      start: 121461,
      length: 1,
      convRule: rule92
  }, {
      start: 121462,
      length: 14,
      convRule: rule13
  }, {
      start: 121476,
      length: 1,
      convRule: rule92
  }, {
      start: 121477,
      length: 2,
      convRule: rule13
  }, {
      start: 121479,
      length: 5,
      convRule: rule2
  }, {
      start: 121499,
      length: 5,
      convRule: rule92
  }, {
      start: 121505,
      length: 15,
      convRule: rule92
  }, {
      start: 122880,
      length: 7,
      convRule: rule92
  }, {
      start: 122888,
      length: 17,
      convRule: rule92
  }, {
      start: 122907,
      length: 7,
      convRule: rule92
  }, {
      start: 122915,
      length: 2,
      convRule: rule92
  }, {
      start: 122918,
      length: 5,
      convRule: rule92
  }, {
      start: 123136,
      length: 45,
      convRule: rule14
  }, {
      start: 123184,
      length: 7,
      convRule: rule92
  }, {
      start: 123191,
      length: 7,
      convRule: rule91
  }, {
      start: 123200,
      length: 10,
      convRule: rule8
  }, {
      start: 123214,
      length: 1,
      convRule: rule14
  }, {
      start: 123215,
      length: 1,
      convRule: rule13
  }, {
      start: 123584,
      length: 44,
      convRule: rule14
  }, {
      start: 123628,
      length: 4,
      convRule: rule92
  }, {
      start: 123632,
      length: 10,
      convRule: rule8
  }, {
      start: 123647,
      length: 1,
      convRule: rule3
  }, {
      start: 124928,
      length: 197,
      convRule: rule14
  }, {
      start: 125127,
      length: 9,
      convRule: rule17
  }, {
      start: 125136,
      length: 7,
      convRule: rule92
  }, {
      start: 125184,
      length: 34,
      convRule: rule203
  }, {
      start: 125218,
      length: 34,
      convRule: rule204
  }, {
      start: 125252,
      length: 7,
      convRule: rule92
  }, {
      start: 125259,
      length: 1,
      convRule: rule91
  }, {
      start: 125264,
      length: 10,
      convRule: rule8
  }, {
      start: 125278,
      length: 2,
      convRule: rule2
  }, {
      start: 126065,
      length: 59,
      convRule: rule17
  }, {
      start: 126124,
      length: 1,
      convRule: rule13
  }, {
      start: 126125,
      length: 3,
      convRule: rule17
  }, {
      start: 126128,
      length: 1,
      convRule: rule3
  }, {
      start: 126129,
      length: 4,
      convRule: rule17
  }, {
      start: 126209,
      length: 45,
      convRule: rule17
  }, {
      start: 126254,
      length: 1,
      convRule: rule13
  }, {
      start: 126255,
      length: 15,
      convRule: rule17
  }, {
      start: 126464,
      length: 4,
      convRule: rule14
  }, {
      start: 126469,
      length: 27,
      convRule: rule14
  }, {
      start: 126497,
      length: 2,
      convRule: rule14
  }, {
      start: 126500,
      length: 1,
      convRule: rule14
  }, {
      start: 126503,
      length: 1,
      convRule: rule14
  }, {
      start: 126505,
      length: 10,
      convRule: rule14
  }, {
      start: 126516,
      length: 4,
      convRule: rule14
  }, {
      start: 126521,
      length: 1,
      convRule: rule14
  }, {
      start: 126523,
      length: 1,
      convRule: rule14
  }, {
      start: 126530,
      length: 1,
      convRule: rule14
  }, {
      start: 126535,
      length: 1,
      convRule: rule14
  }, {
      start: 126537,
      length: 1,
      convRule: rule14
  }, {
      start: 126539,
      length: 1,
      convRule: rule14
  }, {
      start: 126541,
      length: 3,
      convRule: rule14
  }, {
      start: 126545,
      length: 2,
      convRule: rule14
  }, {
      start: 126548,
      length: 1,
      convRule: rule14
  }, {
      start: 126551,
      length: 1,
      convRule: rule14
  }, {
      start: 126553,
      length: 1,
      convRule: rule14
  }, {
      start: 126555,
      length: 1,
      convRule: rule14
  }, {
      start: 126557,
      length: 1,
      convRule: rule14
  }, {
      start: 126559,
      length: 1,
      convRule: rule14
  }, {
      start: 126561,
      length: 2,
      convRule: rule14
  }, {
      start: 126564,
      length: 1,
      convRule: rule14
  }, {
      start: 126567,
      length: 4,
      convRule: rule14
  }, {
      start: 126572,
      length: 7,
      convRule: rule14
  }, {
      start: 126580,
      length: 4,
      convRule: rule14
  }, {
      start: 126585,
      length: 4,
      convRule: rule14
  }, {
      start: 126590,
      length: 1,
      convRule: rule14
  }, {
      start: 126592,
      length: 10,
      convRule: rule14
  }, {
      start: 126603,
      length: 17,
      convRule: rule14
  }, {
      start: 126625,
      length: 3,
      convRule: rule14
  }, {
      start: 126629,
      length: 5,
      convRule: rule14
  }, {
      start: 126635,
      length: 17,
      convRule: rule14
  }, {
      start: 126704,
      length: 2,
      convRule: rule6
  }, {
      start: 126976,
      length: 44,
      convRule: rule13
  }, {
      start: 127024,
      length: 100,
      convRule: rule13
  }, {
      start: 127136,
      length: 15,
      convRule: rule13
  }, {
      start: 127153,
      length: 15,
      convRule: rule13
  }, {
      start: 127169,
      length: 15,
      convRule: rule13
  }, {
      start: 127185,
      length: 37,
      convRule: rule13
  }, {
      start: 127232,
      length: 13,
      convRule: rule17
  }, {
      start: 127245,
      length: 161,
      convRule: rule13
  }, {
      start: 127462,
      length: 29,
      convRule: rule13
  }, {
      start: 127504,
      length: 44,
      convRule: rule13
  }, {
      start: 127552,
      length: 9,
      convRule: rule13
  }, {
      start: 127568,
      length: 2,
      convRule: rule13
  }, {
      start: 127584,
      length: 6,
      convRule: rule13
  }, {
      start: 127744,
      length: 251,
      convRule: rule13
  }, {
      start: 127995,
      length: 5,
      convRule: rule10
  }, {
      start: 128000,
      length: 728,
      convRule: rule13
  }, {
      start: 128736,
      length: 13,
      convRule: rule13
  }, {
      start: 128752,
      length: 13,
      convRule: rule13
  }, {
      start: 128768,
      length: 116,
      convRule: rule13
  }, {
      start: 128896,
      length: 89,
      convRule: rule13
  }, {
      start: 128992,
      length: 12,
      convRule: rule13
  }, {
      start: 129024,
      length: 12,
      convRule: rule13
  }, {
      start: 129040,
      length: 56,
      convRule: rule13
  }, {
      start: 129104,
      length: 10,
      convRule: rule13
  }, {
      start: 129120,
      length: 40,
      convRule: rule13
  }, {
      start: 129168,
      length: 30,
      convRule: rule13
  }, {
      start: 129200,
      length: 2,
      convRule: rule13
  }, {
      start: 129280,
      length: 121,
      convRule: rule13
  }, {
      start: 129402,
      length: 82,
      convRule: rule13
  }, {
      start: 129485,
      length: 135,
      convRule: rule13
  }, {
      start: 129632,
      length: 14,
      convRule: rule13
  }, {
      start: 129648,
      length: 5,
      convRule: rule13
  }, {
      start: 129656,
      length: 3,
      convRule: rule13
  }, {
      start: 129664,
      length: 7,
      convRule: rule13
  }, {
      start: 129680,
      length: 25,
      convRule: rule13
  }, {
      start: 129712,
      length: 7,
      convRule: rule13
  }, {
      start: 129728,
      length: 3,
      convRule: rule13
  }, {
      start: 129744,
      length: 7,
      convRule: rule13
  }, {
      start: 129792,
      length: 147,
      convRule: rule13
  }, {
      start: 129940,
      length: 55,
      convRule: rule13
  }, {
      start: 130032,
      length: 10,
      convRule: rule8
  }, {
      start: 131072,
      length: 42718,
      convRule: rule14
  }, {
      start: 173824,
      length: 4149,
      convRule: rule14
  }, {
      start: 177984,
      length: 222,
      convRule: rule14
  }, {
      start: 178208,
      length: 5762,
      convRule: rule14
  }, {
      start: 183984,
      length: 7473,
      convRule: rule14
  }, {
      start: 194560,
      length: 542,
      convRule: rule14
  }, {
      start: 196608,
      length: 4939,
      convRule: rule14
  }, {
      start: 917505,
      length: 1,
      convRule: rule16
  }, {
      start: 917536,
      length: 96,
      convRule: rule16
  }, {
      start: 917760,
      length: 240,
      convRule: rule92
  }, {
      start: 983040,
      length: 65534,
      convRule: rule200
  }, {
      start: 1048576,
      length: 65534,
      convRule: rule200
  } ];
  var checkAttr = function (categories) {
      return function ($$char) {
          var numOfBlocks = (function () {
              var $28 = $$char < 256;
              if ($28) {
                  return numLat1Blocks;
              };
              return numBlocks;
          })();
          var maybeConversionRule = getRule(allchars)($$char)(numOfBlocks);
          if (maybeConversionRule instanceof Data_Maybe.Nothing) {
              return false;
          };
          if (maybeConversionRule instanceof Data_Maybe.Just) {
              return Data_Maybe.isJust(Data_Array.elemIndex(Data_Eq.eqInt)(maybeConversionRule.value0.category)(categories));
          };
          throw new Error("Failed pattern match at Data.CodePoint.Unicode.Internal (line 5628, column 8 - line 5630, column 92): " + [ maybeConversionRule.constructor.name ]);
      };
  };
  var uIswalnum = checkAttr([ gencatLT, gencatLU, gencatLL, gencatLM, gencatLO, gencatMC, gencatME, gencatMN, gencatNO, gencatND, gencatNL ]);
  exports["uIswalnum"] = uIswalnum;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.CodePoint.Unicode"] = $PS["Data.CodePoint.Unicode"] || {};
  var exports = $PS["Data.CodePoint.Unicode"];
  var Data_Char = $PS["Data.Char"];
  var Data_CodePoint_Unicode_Internal = $PS["Data.CodePoint.Unicode.Internal"];
  var Data_Enum = $PS["Data.Enum"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var isDecDigit = function (c) {
      var diff = Data_Enum.fromEnum(Data_String_CodePoints.boundedEnumCodePoint)(c) - Data_Char.toCharCode("0") | 0;
      return diff <= 9 && diff >= 0;
  };
  var isAlphaNum = (function () {
      var $62 = Data_Enum.fromEnum(Data_String_CodePoints.boundedEnumCodePoint);
      return function ($63) {
          return Data_CodePoint_Unicode_Internal.uIswalnum($62($63));
      };
  })();
  exports["isAlphaNum"] = isAlphaNum;
  exports["isDecDigit"] = isDecDigit;
})(PS);
(function(exports) {
  "use strict";

  var createDate = function (y, m, d) {
    var date = new Date(Date.UTC(y, m, d));
    if (y >= 0 && y < 100) {
      date.setUTCFullYear(y);
    }
    return date;
  };

  exports.canonicalDateImpl = function (ctor, y, m, d) {
    var date = createDate(y, m - 1, d);
    return ctor(date.getUTCFullYear())(date.getUTCMonth() + 1)(date.getUTCDate());
  };
})(PS["Data.Date"] = PS["Data.Date"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Date.Component"] = $PS["Data.Date.Component"] || {};
  var exports = $PS["Data.Date.Component"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Bounded = $PS["Data.Bounded"];
  var Data_Enum = $PS["Data.Enum"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ordering = $PS["Data.Ordering"];
  var January = (function () {
      function January() {

      };
      January.value = new January();
      return January;
  })();
  var February = (function () {
      function February() {

      };
      February.value = new February();
      return February;
  })();
  var March = (function () {
      function March() {

      };
      March.value = new March();
      return March;
  })();
  var April = (function () {
      function April() {

      };
      April.value = new April();
      return April;
  })();
  var May = (function () {
      function May() {

      };
      May.value = new May();
      return May;
  })();
  var June = (function () {
      function June() {

      };
      June.value = new June();
      return June;
  })();
  var July = (function () {
      function July() {

      };
      July.value = new July();
      return July;
  })();
  var August = (function () {
      function August() {

      };
      August.value = new August();
      return August;
  })();
  var September = (function () {
      function September() {

      };
      September.value = new September();
      return September;
  })();
  var October = (function () {
      function October() {

      };
      October.value = new October();
      return October;
  })();
  var November = (function () {
      function November() {

      };
      November.value = new November();
      return November;
  })();
  var December = (function () {
      function December() {

      };
      December.value = new December();
      return December;
  })();
  var ordYear = Data_Ord.ordInt;
  var ordDay = Data_Ord.ordInt;
  var eqMonth = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof January && y instanceof January) {
              return true;
          };
          if (x instanceof February && y instanceof February) {
              return true;
          };
          if (x instanceof March && y instanceof March) {
              return true;
          };
          if (x instanceof April && y instanceof April) {
              return true;
          };
          if (x instanceof May && y instanceof May) {
              return true;
          };
          if (x instanceof June && y instanceof June) {
              return true;
          };
          if (x instanceof July && y instanceof July) {
              return true;
          };
          if (x instanceof August && y instanceof August) {
              return true;
          };
          if (x instanceof September && y instanceof September) {
              return true;
          };
          if (x instanceof October && y instanceof October) {
              return true;
          };
          if (x instanceof November && y instanceof November) {
              return true;
          };
          if (x instanceof December && y instanceof December) {
              return true;
          };
          return false;
      };
  });
  var ordMonth = new Data_Ord.Ord(function () {
      return eqMonth;
  }, function (x) {
      return function (y) {
          if (x instanceof January && y instanceof January) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof January) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof January) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof February && y instanceof February) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof February) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof February) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof March && y instanceof March) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof March) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof March) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof April && y instanceof April) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof April) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof April) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof May && y instanceof May) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof May) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof May) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof June && y instanceof June) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof June) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof June) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof July && y instanceof July) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof July) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof July) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof August && y instanceof August) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof August) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof August) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof September && y instanceof September) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof September) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof September) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof October && y instanceof October) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof October) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof October) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof November && y instanceof November) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof November) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof November) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof December && y instanceof December) {
              return Data_Ordering.EQ.value;
          };
          throw new Error("Failed pattern match at Data.Date.Component (line 61, column 1 - line 61, column 38): " + [ x.constructor.name, y.constructor.name ]);
      };
  });                       
  var boundedYear = new Data_Bounded.Bounded(function () {
      return ordYear;
  }, -271820 | 0, 275759);       
  var boundedMonth = new Data_Bounded.Bounded(function () {
      return ordMonth;
  }, January.value, December.value);
  var boundedEnumYear = new Data_Enum.BoundedEnum(function () {
      return boundedYear;
  }, function () {
      return enumYear;
  }, 547580, function (v) {
      return v;
  }, function (n) {
      if (n >= (-271820 | 0) && n <= 275759) {
          return new Data_Maybe.Just(n);
      };
      if (Data_Boolean.otherwise) {
          return Data_Maybe.Nothing.value;
      };
      throw new Error("Failed pattern match at Data.Date.Component (line 35, column 1 - line 40, column 24): " + [ n.constructor.name ]);
  });
  var enumYear = new Data_Enum.Enum(function () {
      return ordYear;
  }, (function () {
      var $46 = Data_Enum.toEnum(boundedEnumYear);
      var $47 = Data_Enum.fromEnum(boundedEnumYear);
      return function ($48) {
          return $46((function (v) {
              return v - 1 | 0;
          })($47($48)));
      };
  })(), (function () {
      var $49 = Data_Enum.toEnum(boundedEnumYear);
      var $50 = Data_Enum.fromEnum(boundedEnumYear);
      return function ($51) {
          return $49((function (v) {
              return v + 1 | 0;
          })($50($51)));
      };
  })());
  var boundedEnumMonth = new Data_Enum.BoundedEnum(function () {
      return boundedMonth;
  }, function () {
      return enumMonth;
  }, 12, function (v) {
      if (v instanceof January) {
          return 1;
      };
      if (v instanceof February) {
          return 2;
      };
      if (v instanceof March) {
          return 3;
      };
      if (v instanceof April) {
          return 4;
      };
      if (v instanceof May) {
          return 5;
      };
      if (v instanceof June) {
          return 6;
      };
      if (v instanceof July) {
          return 7;
      };
      if (v instanceof August) {
          return 8;
      };
      if (v instanceof September) {
          return 9;
      };
      if (v instanceof October) {
          return 10;
      };
      if (v instanceof November) {
          return 11;
      };
      if (v instanceof December) {
          return 12;
      };
      throw new Error("Failed pattern match at Data.Date.Component (line 87, column 14 - line 99, column 19): " + [ v.constructor.name ]);
  }, function (v) {
      if (v === 1) {
          return new Data_Maybe.Just(January.value);
      };
      if (v === 2) {
          return new Data_Maybe.Just(February.value);
      };
      if (v === 3) {
          return new Data_Maybe.Just(March.value);
      };
      if (v === 4) {
          return new Data_Maybe.Just(April.value);
      };
      if (v === 5) {
          return new Data_Maybe.Just(May.value);
      };
      if (v === 6) {
          return new Data_Maybe.Just(June.value);
      };
      if (v === 7) {
          return new Data_Maybe.Just(July.value);
      };
      if (v === 8) {
          return new Data_Maybe.Just(August.value);
      };
      if (v === 9) {
          return new Data_Maybe.Just(September.value);
      };
      if (v === 10) {
          return new Data_Maybe.Just(October.value);
      };
      if (v === 11) {
          return new Data_Maybe.Just(November.value);
      };
      if (v === 12) {
          return new Data_Maybe.Just(December.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var enumMonth = new Data_Enum.Enum(function () {
      return ordMonth;
  }, (function () {
      var $58 = Data_Enum.toEnum(boundedEnumMonth);
      var $59 = Data_Enum.fromEnum(boundedEnumMonth);
      return function ($60) {
          return $58((function (v) {
              return v - 1 | 0;
          })($59($60)));
      };
  })(), (function () {
      var $61 = Data_Enum.toEnum(boundedEnumMonth);
      var $62 = Data_Enum.fromEnum(boundedEnumMonth);
      return function ($63) {
          return $61((function (v) {
              return v + 1 | 0;
          })($62($63)));
      };
  })());
  var boundedDay = new Data_Bounded.Bounded(function () {
      return ordDay;
  }, 1, 31);
  var boundedEnumDay = new Data_Enum.BoundedEnum(function () {
      return boundedDay;
  }, function () {
      return enumDay;
  }, 31, function (v) {
      return v;
  }, function (n) {
      if (n >= 1 && n <= 31) {
          return new Data_Maybe.Just(n);
      };
      if (Data_Boolean.otherwise) {
          return Data_Maybe.Nothing.value;
      };
      throw new Error("Failed pattern match at Data.Date.Component (line 133, column 1 - line 138, column 23): " + [ n.constructor.name ]);
  });
  var enumDay = new Data_Enum.Enum(function () {
      return ordDay;
  }, (function () {
      var $64 = Data_Enum.toEnum(boundedEnumDay);
      var $65 = Data_Enum.fromEnum(boundedEnumDay);
      return function ($66) {
          return $64((function (v) {
              return v - 1 | 0;
          })($65($66)));
      };
  })(), (function () {
      var $67 = Data_Enum.toEnum(boundedEnumDay);
      var $68 = Data_Enum.fromEnum(boundedEnumDay);
      return function ($69) {
          return $67((function (v) {
              return v + 1 | 0;
          })($68($69)));
      };
  })());
  exports["boundedEnumYear"] = boundedEnumYear;
  exports["boundedEnumMonth"] = boundedEnumMonth;
  exports["boundedEnumDay"] = boundedEnumDay;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Date"] = $PS["Data.Date"] || {};
  var exports = $PS["Data.Date"];
  var $foreign = $PS["Data.Date"];
  var Data_Date_Component = $PS["Data.Date.Component"];
  var Data_Enum = $PS["Data.Enum"];
  var Data_Maybe = $PS["Data.Maybe"];                                
  var $$Date = (function () {
      function $$Date(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      $$Date.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new $$Date(value0, value1, value2);
              };
          };
      };
      return $$Date;
  })();
  var year = function (v) {
      return v.value0;
  }; 
  var month = function (v) {
      return v.value1;
  };
  var day = function (v) {
      return v.value2;
  };
  var canonicalDate = function (y) {
      return function (m) {
          return function (d) {
              var mkDate = function (y$prime) {
                  return function (m$prime) {
                      return function (d$prime) {
                          return new $$Date(y$prime, Data_Maybe.fromJust()(Data_Enum.toEnum(Data_Date_Component.boundedEnumMonth)(m$prime)), d$prime);
                      };
                  };
              };
              return $foreign.canonicalDateImpl(mkDate, y, Data_Enum.fromEnum(Data_Date_Component.boundedEnumMonth)(m), d);
          };
      };
  };
  exports["canonicalDate"] = canonicalDate;
  exports["year"] = year;
  exports["month"] = month;
  exports["day"] = day;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.DateTime"] = $PS["Data.DateTime"] || {};
  var exports = $PS["Data.DateTime"];                                
  var DateTime = (function () {
      function DateTime(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      DateTime.create = function (value0) {
          return function (value1) {
              return new DateTime(value0, value1);
          };
      };
      return DateTime;
  })();
  var time = function (v) {
      return v.value1;
  };
  var date = function (v) {
      return v.value0;
  };
  exports["DateTime"] = DateTime;
  exports["date"] = date;
  exports["time"] = time;
})(PS);
(function(exports) {
  "use strict";

  exports.toDateTimeImpl = function (ctor) {
    return function (instant) {
      var dt = new Date(instant);
      return ctor (dt.getUTCFullYear())(dt.getUTCMonth() + 1)(dt.getUTCDate())(dt.getUTCHours())(dt.getUTCMinutes())(dt.getUTCSeconds())(dt.getUTCMilliseconds());
    };
  };
})(PS["Data.DateTime.Instant"] = PS["Data.DateTime.Instant"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Time"] = $PS["Data.Time"] || {};
  var exports = $PS["Data.Time"];          
  var Time = (function () {
      function Time(value0, value1, value2, value3) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
      };
      Time.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return new Time(value0, value1, value2, value3);
                  };
              };
          };
      };
      return Time;
  })();
  var second = function (v) {
      return v.value2;
  };
  var minute = function (v) {
      return v.value1;
  };
  var hour = function (v) {
      return v.value0;
  };
  exports["Time"] = Time;
  exports["hour"] = hour;
  exports["minute"] = minute;
  exports["second"] = second;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.DateTime.Instant"] = $PS["Data.DateTime.Instant"] || {};
  var exports = $PS["Data.DateTime.Instant"];
  var $foreign = $PS["Data.DateTime.Instant"];
  var Data_Date = $PS["Data.Date"];
  var Data_Date_Component = $PS["Data.Date.Component"];
  var Data_DateTime = $PS["Data.DateTime"];
  var Data_Enum = $PS["Data.Enum"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Time = $PS["Data.Time"];
  var toDateTime = (function () {
      var mkDateTime = function (y) {
          return function (mo) {
              return function (d) {
                  return function (h) {
                      return function (mi) {
                          return function (s) {
                              return function (ms) {
                                  return new Data_DateTime.DateTime(Data_Date.canonicalDate(y)(Data_Maybe.fromJust()(Data_Enum.toEnum(Data_Date_Component.boundedEnumMonth)(mo)))(d), new Data_Time.Time(h, mi, s, ms));
                              };
                          };
                      };
                  };
              };
          };
      };
      return $foreign.toDateTimeImpl(mkDateTime);
  })();
  exports["toDateTime"] = toDateTime;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Digit"] = $PS["Data.Digit"] || {};
  var exports = $PS["Data.Digit"];
  var Data_Char = $PS["Data.Char"];
  var Data_Maybe = $PS["Data.Maybe"];              
  var Digit = function (x) {
      return x;
  };
  var fromChar = function (c) {
      var code = Data_Char.toCharCode(c);
      var $16 = code >= 48 && code <= 57;
      if ($16) {
          return new Data_Maybe.Just(Digit(code - 48 | 0));
      };
      return Data_Maybe.Nothing.value;
  };
  exports["fromChar"] = fromChar;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Generic.Rep"] = $PS["Data.Generic.Rep"] || {};
  var exports = $PS["Data.Generic.Rep"];             
  var Inl = (function () {
      function Inl(value0) {
          this.value0 = value0;
      };
      Inl.create = function (value0) {
          return new Inl(value0);
      };
      return Inl;
  })();
  var Inr = (function () {
      function Inr(value0) {
          this.value0 = value0;
      };
      Inr.create = function (value0) {
          return new Inr(value0);
      };
      return Inr;
  })();
  var NoArguments = (function () {
      function NoArguments() {

      };
      NoArguments.value = new NoArguments();
      return NoArguments;
  })();
  var Generic = function (from, to) {
      this.from = from;
      this.to = to;
  };
  var Constructor = function (x) {
      return x;
  };
  var Argument = function (x) {
      return x;
  };
  var to = function (dict) {
      return dict.to;
  };
  var from = function (dict) {
      return dict.from;
  };
  exports["Generic"] = Generic;
  exports["to"] = to;
  exports["from"] = from;
  exports["NoArguments"] = NoArguments;
  exports["Inl"] = Inl;
  exports["Inr"] = Inr;
  exports["Constructor"] = Constructor;
  exports["Argument"] = Argument;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Eq.Generic"] = $PS["Data.Eq.Generic"] || {};
  var exports = $PS["Data.Eq.Generic"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];                
  var GenericEq = function (genericEq$prime) {
      this["genericEq'"] = genericEq$prime;
  }; 
  var genericEqNoArguments = new GenericEq(function (v) {
      return function (v1) {
          return true;
      };
  });
  var genericEqArgument = function (dictEq) {
      return new GenericEq(function (v) {
          return function (v1) {
              return Data_Eq.eq(dictEq)(v)(v1);
          };
      });
  };
  var genericEq$prime = function (dict) {
      return dict["genericEq'"];
  };
  var genericEqConstructor = function (dictGenericEq) {
      return new GenericEq(function (v) {
          return function (v1) {
              return genericEq$prime(dictGenericEq)(v)(v1);
          };
      });
  };
  var genericEqSum = function (dictGenericEq) {
      return function (dictGenericEq1) {
          return new GenericEq(function (v) {
              return function (v1) {
                  if (v instanceof Data_Generic_Rep.Inl && v1 instanceof Data_Generic_Rep.Inl) {
                      return genericEq$prime(dictGenericEq)(v.value0)(v1.value0);
                  };
                  if (v instanceof Data_Generic_Rep.Inr && v1 instanceof Data_Generic_Rep.Inr) {
                      return genericEq$prime(dictGenericEq1)(v.value0)(v1.value0);
                  };
                  return false;
              };
          });
      };
  };
  var genericEq = function (dictGeneric) {
      return function (dictGenericEq) {
          return function (x) {
              return function (y) {
                  return genericEq$prime(dictGenericEq)(Data_Generic_Rep.from(dictGeneric)(x))(Data_Generic_Rep.from(dictGeneric)(y));
              };
          };
      };
  };
  exports["genericEq"] = genericEq;
  exports["genericEqNoArguments"] = genericEqNoArguments;
  exports["genericEqSum"] = genericEqSum;
  exports["genericEqConstructor"] = genericEqConstructor;
  exports["genericEqArgument"] = genericEqArgument;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Sequence.Internal"] = $PS["Data.Sequence.Internal"] || {};
  var exports = $PS["Data.Sequence.Internal"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Lazy = $PS["Data.Lazy"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ordering = $PS["Data.Ordering"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
  var Measured = function (measure) {
      this.measure = measure;
  };
  var NoKey = (function () {
      function NoKey() {

      };
      NoKey.value = new NoKey();
      return NoKey;
  })();
  var Key = (function () {
      function Key(value0) {
          this.value0 = value0;
      };
      Key.create = function (value0) {
          return new Key(value0);
      };
      return Key;
  })();
  var semigroupKey = new Data_Semigroup.Semigroup(function (v) {
      return function (v1) {
          if (v1 instanceof NoKey) {
              return v;
          };
          return v1;
      };
  });
  var monoidKey = new Data_Monoid.Monoid(function () {
      return semigroupKey;
  }, NoKey.value);
  var measuredElemKey = new Measured(function (v) {
      return new Key(v);
  });
  var measuredElem = new Measured(function (v) {
      return 1;
  });
  var measure = function (dict) {
      return dict.measure;
  };
  var measuredArray = function (dictMonoid) {
      return function (dictMeasured) {
          return new Measured(function (xs) {
              return Data_Foldable.foldl(Data_Foldable.foldableArray)(function (i) {
                  return function (a) {
                      return Data_Semigroup.append(dictMonoid.Semigroup0())(i)(measure(dictMeasured)(a));
                  };
              })(Data_Monoid.mempty(dictMonoid))(xs);
          });
      };
  };
  var measuredLazy = function (dictMonoid) {
      return function (dictMeasured) {
          return new Measured(function (s) {
              return measure(dictMeasured)(Data_Lazy.force(s));
          });
      };
  };
  var mapmap = function (dictFunctor) {
      return function (dictFunctor1) {
          var $75 = Data_Functor.map(dictFunctor);
          var $76 = Data_Functor.map(dictFunctor1);
          return function ($77) {
              return $75($76($77));
          };
      };
  };
  var mapmapmap = function (dictFunctor) {
      return function (dictFunctor1) {
          return function (dictFunctor2) {
              var $78 = mapmap(dictFunctor)(dictFunctor1);
              var $79 = Data_Functor.map(dictFunctor2);
              return function ($80) {
                  return $78($79($80));
              };
          };
      };
  };
  var mapGetElem = function (dictFunctor) {
      return Unsafe_Coerce.unsafeCoerce;
  };
  var liftElem = Unsafe_Coerce.unsafeCoerce;
  var lift2Elem = Unsafe_Coerce.unsafeCoerce;
  var eqKey = function (dictEq) {
      return new Data_Eq.Eq(function (v) {
          return function (v1) {
              if (v instanceof Key && v1 instanceof Key) {
                  return Data_Eq.eq(dictEq)(v.value0)(v1.value0);
              };
              if (v instanceof NoKey && v1 instanceof NoKey) {
                  return true;
              };
              return false;
          };
      });
  };
  var ordKey = function (dictOrd) {
      return new Data_Ord.Ord(function () {
          return eqKey(dictOrd.Eq0());
      }, function (v) {
          return function (v1) {
              if (v instanceof NoKey) {
                  return Data_Ordering.LT.value;
              };
              if (v1 instanceof NoKey) {
                  return Data_Ordering.GT.value;
              };
              if (v instanceof Key && v1 instanceof Key) {
                  return Data_Ord.compare(dictOrd)(v.value0)(v1.value0);
              };
              throw new Error("Failed pattern match at Data.Sequence.Internal (line 114, column 1 - line 117, column 40): " + [ v.constructor.name, v1.constructor.name ]);
          };
      });
  };
  var eqElem = function (dictEq) {
      return new Data_Eq.Eq(function (v) {
          return function (v1) {
              return Data_Eq.eq(dictEq)(v)(v1);
          };
      });
  };
  exports["mapmapmap"] = mapmapmap;
  exports["Measured"] = Measured;
  exports["measure"] = measure;
  exports["mapGetElem"] = mapGetElem;
  exports["lift2Elem"] = lift2Elem;
  exports["liftElem"] = liftElem;
  exports["Key"] = Key;
  exports["measuredArray"] = measuredArray;
  exports["measuredLazy"] = measuredLazy;
  exports["measuredElem"] = measuredElem;
  exports["eqElem"] = eqElem;
  exports["ordKey"] = ordKey;
  exports["monoidKey"] = monoidKey;
  exports["measuredElemKey"] = measuredElemKey;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.FingerTree.Digit"] = $PS["Data.FingerTree.Digit"] || {};
  var exports = $PS["Data.FingerTree.Digit"];
  var Data_Array = $PS["Data.Array"];
  var Data_Array_Partial = $PS["Data.Array.Partial"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence_Internal = $PS["Data.Sequence.Internal"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
  var Digit = function (x) {
      return x;
  };
  var runDigit = function (v) {
      return v;
  };
  var tailDigit = (function () {
      var $14 = Data_Array_Partial.tail();
      return function ($15) {
          return $14(runDigit($15));
      };
  })();
  var overDigit = Unsafe_Coerce.unsafeCoerce;
  var snocDigit = function (dictPartial) {
      return function (dg) {
          return function (x) {
              return overDigit(function (xs) {
                  return Data_Array.snoc(xs)(x);
              })(dg);
          };
      };
  };
  var mkDigitMay = function (xs) {
      var $13 = Data_Ord.between(Data_Ord.ordInt)(1)(4)(Data_Array.length(xs));
      if ($13) {
          return new Data_Maybe.Just(xs);
      };
      return Data_Maybe.Nothing.value;
  };
  var mkDigit3 = function (x) {
      return function (y) {
          return function (z) {
              return [ x, y, z ];
          };
      };
  };
  var mkDigit2 = function (x) {
      return function (y) {
          return [ x, y ];
      };
  };
  var mkDigit1 = function (x) {
      return [ x ];
  };
  var mkDigit = function (dictPartial) {
      return Digit;
  };
  var measuredDigit = function (dictMonoid) {
      return function (dictMeasured) {
          return new Data_Sequence_Internal.Measured((function () {
              var $16 = Data_Sequence_Internal.measure(Data_Sequence_Internal.measuredArray(dictMonoid)(dictMeasured));
              return function ($17) {
                  return $16(runDigit($17));
              };
          })());
      };
  };
  var lastDigit = (function () {
      var $18 = Data_Array_Partial.last();
      return function ($19) {
          return $18(runDigit($19));
      };
  })();
  var initDigit = (function () {
      var $20 = Data_Array_Partial.init();
      return function ($21) {
          return $20(runDigit($21));
      };
  })();
  var headDigit = (function () {
      var $22 = Data_Array_Partial.head();
      return function ($23) {
          return $22(runDigit($23));
      };
  })();
  var functorDigit = Data_Functor.functorArray;
  var foldableDigit = Data_Foldable.foldableArray;
  var digitLength = function ($26) {
      return Data_Array.length(runDigit($26));
  };
  var consDigit = function (dictPartial) {
      return function (x) {
          return function (dg) {
              return overDigit(Data_Array.cons(x))(dg);
          };
      };
  };
  exports["mkDigit"] = mkDigit;
  exports["mkDigitMay"] = mkDigitMay;
  exports["mkDigit1"] = mkDigit1;
  exports["mkDigit2"] = mkDigit2;
  exports["mkDigit3"] = mkDigit3;
  exports["runDigit"] = runDigit;
  exports["headDigit"] = headDigit;
  exports["tailDigit"] = tailDigit;
  exports["initDigit"] = initDigit;
  exports["lastDigit"] = lastDigit;
  exports["snocDigit"] = snocDigit;
  exports["consDigit"] = consDigit;
  exports["digitLength"] = digitLength;
  exports["functorDigit"] = functorDigit;
  exports["foldableDigit"] = foldableDigit;
  exports["measuredDigit"] = measuredDigit;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.FingerTree"] = $PS["Data.FingerTree"] || {};
  var exports = $PS["Data.FingerTree"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_FingerTree_Digit = $PS["Data.FingerTree.Digit"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Lazy = $PS["Data.Lazy"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Sequence_Internal = $PS["Data.Sequence.Internal"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Partial = $PS["Partial"];                
  var NilR = (function () {
      function NilR() {

      };
      NilR.value = new NilR();
      return NilR;
  })();
  var SnocR = (function () {
      function SnocR(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      SnocR.create = function (value0) {
          return function (value1) {
              return new SnocR(value0, value1);
          };
      };
      return SnocR;
  })();
  var NilL = (function () {
      function NilL() {

      };
      NilL.value = new NilL();
      return NilL;
  })();
  var ConsL = (function () {
      function ConsL(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      ConsL.create = function (value0) {
          return function (value1) {
              return new ConsL(value0, value1);
          };
      };
      return ConsL;
  })();
  var Split = (function () {
      function Split(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      Split.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new Split(value0, value1, value2);
              };
          };
      };
      return Split;
  })();
  var Node2 = (function () {
      function Node2(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      Node2.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new Node2(value0, value1, value2);
              };
          };
      };
      return Node2;
  })();
  var Node3 = (function () {
      function Node3(value0, value1, value2, value3) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
      };
      Node3.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return new Node3(value0, value1, value2, value3);
                  };
              };
          };
      };
      return Node3;
  })();
  var LazySplit = (function () {
      function LazySplit(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      LazySplit.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new LazySplit(value0, value1, value2);
              };
          };
      };
      return LazySplit;
  })();
  var Empty = (function () {
      function Empty() {

      };
      Empty.value = new Empty();
      return Empty;
  })();
  var Single = (function () {
      function Single(value0) {
          this.value0 = value0;
      };
      Single.create = function (value0) {
          return new Single(value0);
      };
      return Single;
  })();
  var Deep = (function () {
      function Deep(value0, value1, value2, value3) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
      };
      Deep.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return new Deep(value0, value1, value2, value3);
                  };
              };
          };
      };
      return Deep;
  })();
  var splitDigit = function (dictMonoid) {
      return function (dictMeasured) {
          return function (p) {
              return function (i) {
                  return function (as) {
                      var v = Data_FingerTree_Digit.digitLength(as);
                      if (v === 1) {
                          return new Split([  ], Data_FingerTree_Digit.headDigit(as), [  ]);
                      };
                      var bs$prime = Data_FingerTree_Digit.tailDigit(as);
                      var bs = Data_FingerTree_Digit.mkDigit()(bs$prime);
                      var a = Data_FingerTree_Digit.headDigit(as);
                      var i$prime = Data_Semigroup.append(dictMonoid.Semigroup0())(i)(Data_Sequence_Internal.measure(dictMeasured)(a));
                      var $150 = p(i$prime);
                      if ($150) {
                          return new Split([  ], a, bs$prime);
                      };
                      var v1 = splitDigit(dictMonoid)(dictMeasured)(p)(i$prime)(bs);
                      return new Split(Data_Array.cons(a)(v1.value0), v1.value1, v1.value2);
                  };
              };
          };
      };
  };
  var nodeToDigit = (function () {
      var go = function (v) {
          if (v instanceof Node2) {
              return Data_FingerTree_Digit.mkDigit2(v.value1)(v.value2);
          };
          if (v instanceof Node3) {
              return Data_FingerTree_Digit.mkDigit3(v.value1)(v.value2)(v.value3);
          };
          throw new Error("Failed pattern match at Data.FingerTree (line 88, column 3 - line 88, column 34): " + [ v.constructor.name ]);
      };
      return go;
  })();
  var node3 = function (dictMonoid) {
      return function (dictMeasured) {
          return function (a) {
              return function (b) {
                  return function (c) {
                      return new Node3(Data_Semigroup.append(dictMonoid.Semigroup0())(Data_Sequence_Internal.measure(dictMeasured)(a))(Data_Semigroup.append(dictMonoid.Semigroup0())(Data_Sequence_Internal.measure(dictMeasured)(b))(Data_Sequence_Internal.measure(dictMeasured)(c))), a, b, c);
                  };
              };
          };
      };
  };
  var node2 = function (dictMonoid) {
      return function (dictMeasured) {
          return function (a) {
              return function (b) {
                  return new Node2(Data_Semigroup.append(dictMonoid.Semigroup0())(Data_Sequence_Internal.measure(dictMeasured)(a))(Data_Sequence_Internal.measure(dictMeasured)(b)), a, b);
              };
          };
      };
  };
  var nodes = function (dictMonoid) {
      return function (dictMeasured) {
          return function (xs) {
              if (xs.length === 2) {
                  return [ node2(dictMonoid)(dictMeasured)(xs[0])(xs[1]) ];
              };
              if (xs.length === 3) {
                  return [ node3(dictMonoid)(dictMeasured)(xs[0])(xs[1])(xs[2]) ];
              };
              if (xs.length === 4) {
                  return [ node2(dictMonoid)(dictMeasured)(xs[0])(xs[1]), node2(dictMonoid)(dictMeasured)(xs[2])(xs[3]) ];
              };
              var idx = Data_Array.unsafeIndex();
              return Data_Array.cons(node3(dictMonoid)(dictMeasured)(idx(xs)(0))(idx(xs)(1))(idx(xs)(2)))(nodes(dictMonoid)(dictMeasured)(Data_Array.drop(3)(xs)));
          };
      };
  };
  var measuredNode = new Data_Sequence_Internal.Measured(function (v) {
      if (v instanceof Node2) {
          return v.value0;
      };
      if (v instanceof Node3) {
          return v.value0;
      };
      throw new Error("Failed pattern match at Data.FingerTree (line 107, column 1 - line 109, column 30): " + [ v.constructor.name ]);
  });
  var measuredFingerTree = function (dictMonoid) {
      return function (dictMeasured) {
          return new Data_Sequence_Internal.Measured(function (v) {
              if (v instanceof Empty) {
                  return Data_Monoid.mempty(dictMonoid);
              };
              if (v instanceof Single) {
                  return Data_Sequence_Internal.measure(dictMeasured)(v.value0);
              };
              if (v instanceof Deep) {
                  return Data_Lazy.force(v.value0);
              };
              throw new Error("Failed pattern match at Data.FingerTree (line 228, column 1 - line 232, column 37): " + [ v.constructor.name ]);
          });
      };
  };
  var lazyEmpty = Data_Lazy.defer(function (v) {
      return Empty.value;
  });
  var functorNode = new Data_Functor.Functor(function (f) {
      return function (v) {
          if (v instanceof Node2) {
              return new Node2(v.value0, f(v.value1), f(v.value2));
          };
          if (v instanceof Node3) {
              return new Node3(v.value0, f(v.value1), f(v.value2), f(v.value3));
          };
          throw new Error("Failed pattern match at Data.FingerTree (line 91, column 1 - line 93, column 52): " + [ f.constructor.name, v.constructor.name ]);
      };
  });
  var functorFingerTree = new Data_Functor.Functor(function (f) {
      return function (v) {
          if (v instanceof Empty) {
              return Empty.value;
          };
          if (v instanceof Single) {
              return new Single(f(v.value0));
          };
          if (v instanceof Deep) {
              return new Deep(v.value0, Data_Functor.map(Data_FingerTree_Digit.functorDigit)(f)(v.value1), Data_Sequence_Internal.mapmapmap(Data_Lazy.functorLazy)(functorFingerTree)(functorNode)(f)(v.value2), Data_Functor.map(Data_FingerTree_Digit.functorDigit)(f)(v.value3));
          };
          throw new Error("Failed pattern match at Data.FingerTree (line 183, column 1 - line 186, column 68): " + [ f.constructor.name, v.constructor.name ]);
      };
  });
  var foldableNode = new Data_Foldable.Foldable(function (dictMonoid) {
      return function (f) {
          return function (xs) {
              return Data_Foldable.foldr(foldableNode)(function (x) {
                  return function (acc) {
                      return Data_Semigroup.append(dictMonoid.Semigroup0())(f(x))(acc);
                  };
              })(Data_Monoid.mempty(dictMonoid))(xs);
          };
      };
  }, function (l) {
      return function (z) {
          return function (v) {
              if (v instanceof Node2) {
                  return l(l(z)(v.value1))(v.value2);
              };
              if (v instanceof Node3) {
                  return l(l(l(z)(v.value1))(v.value2))(v.value3);
              };
              throw new Error("Failed pattern match at Data.FingerTree (line 95, column 1 - line 100, column 56): " + [ l.constructor.name, z.constructor.name, v.constructor.name ]);
          };
      };
  }, function (r) {
      return function (z) {
          return function (v) {
              if (v instanceof Node2) {
                  return r(v.value1)(r(v.value2)(z));
              };
              if (v instanceof Node3) {
                  return r(v.value1)(r(v.value2)(r(v.value3)(z)));
              };
              throw new Error("Failed pattern match at Data.FingerTree (line 95, column 1 - line 100, column 56): " + [ r.constructor.name, z.constructor.name, v.constructor.name ]);
          };
      };
  });
  var foldableFingerTree = new Data_Foldable.Foldable(function (dictMonoid) {
      return function (f) {
          return function (xs) {
              return Data_Foldable.foldr(foldableFingerTree)(function (x) {
                  return function (acc) {
                      return Data_Semigroup.append(dictMonoid.Semigroup0())(f(x))(acc);
                  };
              })(Data_Monoid.mempty(dictMonoid))(xs);
          };
      };
  }, function (v) {
      return function (z) {
          return function (v1) {
              if (v1 instanceof Empty) {
                  return z;
              };
              if (v1 instanceof Single) {
                  return v(z)(v1.value0);
              };
              if (v1 instanceof Deep) {
                  var leftFold = Data_Foldable.foldl(Data_FingerTree_Digit.foldableDigit)(v);
                  var deepLeftFold = Data_Foldable.foldl(foldableFingerTree)(Data_Foldable.foldl(foldableNode)(v));
                  return leftFold(deepLeftFold(leftFold(z)(v1.value1))(Data_Lazy.force(v1.value2)))(v1.value3);
              };
              throw new Error("Failed pattern match at Data.FingerTree (line 188, column 1 - line 212, column 56): " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]);
          };
      };
  }, function (v) {
      return function (z) {
          return function (v1) {
              if (v1 instanceof Empty) {
                  return z;
              };
              if (v1 instanceof Single) {
                  return v(v1.value0)(z);
              };
              if (v1 instanceof Deep) {
                  var flipFoldr$prime = Data_Function.flip(Data_Foldable.foldr(Data_FingerTree_Digit.foldableDigit)(v));
                  var flipFoldr = Data_Function.flip(Data_Foldable.foldr(Data_FingerTree_Digit.foldableDigit)(v));
                  var deepFlipFoldr = Data_Function.flip(Data_Foldable.foldr(foldableFingerTree)(Data_Function.flip(Data_Foldable.foldr(foldableNode)(v))));
                  return flipFoldr$prime(v1.value1)(deepFlipFoldr(Data_Lazy.force(v1.value2))(flipFoldr(v1.value3)(z)));
              };
              throw new Error("Failed pattern match at Data.FingerTree (line 188, column 1 - line 212, column 56): " + [ v.constructor.name, z.constructor.name, v1.constructor.name ]);
          };
      };
  });
  var deep = function (dictMonoid) {
      return function (dictMeasured) {
          return function (pr) {
              return function (m) {
                  return function (sf) {
                      return new Deep(Data_Lazy.defer(function (v) {
                          return Data_Semigroup.append(dictMonoid.Semigroup0())(Data_Sequence_Internal.measure(Data_FingerTree_Digit.measuredDigit(dictMonoid)(dictMeasured))(pr))(Data_Semigroup.append(dictMonoid.Semigroup0())(Data_Sequence_Internal.measure(Data_Sequence_Internal.measuredLazy(dictMonoid)(measuredFingerTree(dictMonoid)(measuredNode)))(m))(Data_Sequence_Internal.measure(Data_FingerTree_Digit.measuredDigit(dictMonoid)(dictMeasured))(sf)));
                      }), pr, m, sf);
                  };
              };
          };
      };
  };
  var snoc = function (dictMonoid) {
      return function (dictMeasured) {
          return function (v) {
              return function (a) {
                  if (v instanceof Empty) {
                      return new Single(a);
                  };
                  if (v instanceof Single) {
                      return deep(dictMonoid)(dictMeasured)(Data_FingerTree_Digit.mkDigit1(v.value0))(lazyEmpty)(Data_FingerTree_Digit.mkDigit1(a));
                  };
                  if (v instanceof Deep) {
                      var v1 = Data_FingerTree_Digit.runDigit(v.value3);
                      if (v1.length === 4) {
                          var forcedM = Data_Lazy.force(v.value2);
                          return deep(dictMonoid)(dictMeasured)(v.value1)(Data_Lazy.defer(function (v2) {
                              return snoc(dictMonoid)(measuredNode)(forcedM)(node3(dictMonoid)(dictMeasured)(v1[0])(v1[1])(v1[2]));
                          }))(Data_FingerTree_Digit.mkDigit2(v1[3])(a));
                      };
                      return deep(dictMonoid)(dictMeasured)(v.value1)(v.value2)(Data_FingerTree_Digit.snocDigit()(v.value3)(a));
                  };
                  throw new Error("Failed pattern match at Data.FingerTree (line 262, column 1 - line 263, column 40): " + [ v.constructor.name, a.constructor.name ]);
              };
          };
      };
  };
  var snocAll = function (dictMonoid) {
      return function (dictMeasured) {
          return function (dictFoldable) {
              return Data_Foldable.foldl(dictFoldable)(snoc(dictMonoid)(dictMeasured));
          };
      };
  };
  var toFingerTree = function (dictMonoid) {
      return function (dictMeasured) {
          return function (dictFoldable) {
              return function (s) {
                  return snocAll(dictMonoid)(dictMeasured)(dictFoldable)(Empty.value)(s);
              };
          };
      };
  };
  var viewL = function (dictMonoid) {
      return function (dictMeasured) {
          return function (v) {
              if (v instanceof Empty) {
                  return NilL.value;
              };
              if (v instanceof Single) {
                  return new ConsL(v.value0, lazyEmpty);
              };
              if (v instanceof Deep) {
                  return new ConsL(Data_FingerTree_Digit.headDigit(v.value1), Data_Lazy.defer(function (v1) {
                      return deepL(dictMonoid)(dictMeasured)(Data_FingerTree_Digit.tailDigit(v.value1))(v.value2)(v.value3);
                  }));
              };
              throw new Error("Failed pattern match at Data.FingerTree (line 294, column 1 - line 295, column 50): " + [ v.constructor.name ]);
          };
      };
  };
  var deepL = function (dictMonoid) {
      return function (dictMeasured) {
          return function (pr$prime) {
              return function (m) {
                  return function (sf) {
                      var v = Data_FingerTree_Digit.mkDigitMay(pr$prime);
                      if (v instanceof Data_Maybe.Just) {
                          return deep(dictMonoid)(dictMeasured)(v.value0)(m)(sf);
                      };
                      if (v instanceof Data_Maybe.Nothing) {
                          var v1 = viewL(dictMonoid)(measuredNode)(Data_Lazy.force(m));
                          if (v1 instanceof NilL) {
                              return toFingerTree(dictMonoid)(dictMeasured)(Data_FingerTree_Digit.foldableDigit)(sf);
                          };
                          if (v1 instanceof ConsL) {
                              return deep(dictMonoid)(dictMeasured)(nodeToDigit(v1.value0))(v1.value1)(sf);
                          };
                          throw new Error("Failed pattern match at Data.FingerTree (line 321, column 7 - line 323, column 49): " + [ v1.constructor.name ]);
                      };
                      throw new Error("Failed pattern match at Data.FingerTree (line 317, column 3 - line 323, column 49): " + [ v.constructor.name ]);
                  };
              };
          };
      };
  };
  var eqFingerTree = function ($copy_dictMonoid) {
      return function ($copy_dictMeasured) {
          return function ($copy_dictEq) {
              return function ($copy_xs) {
                  return function ($copy_ys) {
                      var $tco_var_dictMonoid = $copy_dictMonoid;
                      var $tco_var_dictMeasured = $copy_dictMeasured;
                      var $tco_var_dictEq = $copy_dictEq;
                      var $tco_var_xs = $copy_xs;
                      var $tco_done = false;
                      var $tco_result;
                      function $tco_loop(dictMonoid, dictMeasured, dictEq, xs, ys) {
                          var v = new Data_Tuple.Tuple(viewL(dictMonoid)(dictMeasured)(xs), viewL(dictMonoid)(dictMeasured)(ys));
                          if (v.value0 instanceof NilL && v.value1 instanceof NilL) {
                              $tco_done = true;
                              return true;
                          };
                          if (v.value0 instanceof NilL) {
                              $tco_done = true;
                              return false;
                          };
                          if (v.value1 instanceof NilL) {
                              $tco_done = true;
                              return false;
                          };
                          if (v.value0 instanceof ConsL && v.value1 instanceof ConsL) {
                              var $308 = Data_Eq.eq(dictEq)(v.value0.value0)(v.value1.value0);
                              if ($308) {
                                  var ys$prime$prime = Data_Lazy.force(v.value1.value1);
                                  var xs$prime$prime = Data_Lazy.force(v.value0.value1);
                                  $tco_var_dictMonoid = dictMonoid;
                                  $tco_var_dictMeasured = dictMeasured;
                                  $tco_var_dictEq = dictEq;
                                  $tco_var_xs = xs$prime$prime;
                                  $copy_ys = ys$prime$prime;
                                  return;
                              };
                              $tco_done = true;
                              return false;
                          };
                          throw new Error("Failed pattern match at Data.FingerTree (line 153, column 3 - line 164, column 17): " + [ v.constructor.name ]);
                      };
                      while (!$tco_done) {
                          $tco_result = $tco_loop($tco_var_dictMonoid, $tco_var_dictMeasured, $tco_var_dictEq, $tco_var_xs, $copy_ys);
                      };
                      return $tco_result;
                  };
              };
          };
      };
  };
  var head = function (dictMonoid) {
      return function (dictMeasured) {
          return function (x) {
              var v = viewL(dictMonoid)(dictMeasured)(x);
              if (v instanceof ConsL) {
                  return new Data_Maybe.Just(v.value0);
              };
              if (v instanceof NilL) {
                  return Data_Maybe.Nothing.value;
              };
              throw new Error("Failed pattern match at Data.FingerTree (line 331, column 10 - line 333, column 23): " + [ v.constructor.name ]);
          };
      };
  };
  var unfoldLeft = function (dictUnfoldable) {
      return function (dictMonoid) {
          return function (dictMeasured) {
              var step = function (tree) {
                  var v = viewL(dictMonoid)(dictMeasured)(tree);
                  if (v instanceof ConsL) {
                      return new Data_Maybe.Just(new Data_Tuple.Tuple(v.value0, Data_Lazy.force(v.value1)));
                  };
                  if (v instanceof NilL) {
                      return Data_Maybe.Nothing.value;
                  };
                  throw new Error("Failed pattern match at Data.FingerTree (line 482, column 15 - line 484, column 38): " + [ v.constructor.name ]);
              };
              return Data_Unfoldable.unfoldr(dictUnfoldable)(step);
          };
      };
  };
  var viewR = function (dictMonoid) {
      return function (dictMeasured) {
          return function (v) {
              if (v instanceof Empty) {
                  return NilR.value;
              };
              if (v instanceof Single) {
                  return new SnocR(lazyEmpty, v.value0);
              };
              if (v instanceof Deep) {
                  return new SnocR(Data_Lazy.defer(function (v1) {
                      return deepR(dictMonoid)(dictMeasured)(v.value1)(v.value2)(Data_FingerTree_Digit.initDigit(v.value3));
                  }), Data_FingerTree_Digit.lastDigit(v.value3));
              };
              throw new Error("Failed pattern match at Data.FingerTree (line 343, column 1 - line 344, column 50): " + [ v.constructor.name ]);
          };
      };
  };
  var deepR = function (dictMonoid) {
      return function (dictMeasured) {
          return function (pr) {
              return function (m) {
                  return function (sf$prime) {
                      var v = Data_FingerTree_Digit.mkDigitMay(sf$prime);
                      if (v instanceof Data_Maybe.Just) {
                          return deep(dictMonoid)(dictMeasured)(pr)(m)(v.value0);
                      };
                      if (v instanceof Data_Maybe.Nothing) {
                          var v1 = viewR(dictMonoid)(measuredNode)(Data_Lazy.force(m));
                          if (v1 instanceof NilR) {
                              return toFingerTree(dictMonoid)(dictMeasured)(Data_FingerTree_Digit.foldableDigit)(pr);
                          };
                          if (v1 instanceof SnocR) {
                              return deep(dictMonoid)(dictMeasured)(pr)(v1.value0)(nodeToDigit(v1.value1));
                          };
                          throw new Error("Failed pattern match at Data.FingerTree (line 357, column 7 - line 359, column 49): " + [ v1.constructor.name ]);
                      };
                      throw new Error("Failed pattern match at Data.FingerTree (line 353, column 3 - line 359, column 49): " + [ v.constructor.name ]);
                  };
              };
          };
      };
  };
  var splitTree = function (dictMonoid) {
      return function (dictMeasured) {
          return function (dictPartial) {
              return function (v) {
                  return function (v1) {
                      return function (v2) {
                          if (v2 instanceof Single) {
                              return new LazySplit(lazyEmpty, v2.value0, lazyEmpty);
                          };
                          if (v2 instanceof Empty) {
                              return Partial.crashWith()("Data.FingerTree.splitTree: Empty");
                          };
                          if (v2 instanceof Deep) {
                              var vpr = Data_Semigroup.append(dictMonoid.Semigroup0())(v1)(Data_Sequence_Internal.measure(Data_FingerTree_Digit.measuredDigit(dictMonoid)(dictMeasured))(v2.value1));
                              var $351 = v(vpr);
                              if ($351) {
                                  var v3 = splitDigit(dictMonoid)(dictMeasured)(v)(v1)(v2.value1);
                                  return new LazySplit(Data_Lazy.defer(function (v4) {
                                      return toFingerTree(dictMonoid)(dictMeasured)(Data_Foldable.foldableArray)(v3.value0);
                                  }), v3.value1, Data_Lazy.defer(function (v4) {
                                      return deepL(dictMonoid)(dictMeasured)(v3.value2)(v2.value2)(v2.value3);
                                  }));
                              };
                              var vm = Data_Semigroup.append(dictMonoid.Semigroup0())(vpr)(Data_Sequence_Internal.measure(Data_Sequence_Internal.measuredLazy(dictMonoid)(measuredFingerTree(dictMonoid)(measuredNode)))(v2.value2));
                              var $356 = v(vm);
                              if ($356) {
                                  var v3 = splitTree(dictMonoid)(measuredNode)()(v)(vpr)(Data_Lazy.force(v2.value2));
                                  var v4 = splitDigit(dictMonoid)(dictMeasured)(v)(Data_Semigroup.append(dictMonoid.Semigroup0())(vpr)(Data_Sequence_Internal.measure(Data_Sequence_Internal.measuredLazy(dictMonoid)(measuredFingerTree(dictMonoid)(measuredNode)))(v3.value0)))(nodeToDigit(v3.value1));
                                  return new LazySplit(Data_Lazy.defer(function (v5) {
                                      return deepR(dictMonoid)(dictMeasured)(v2.value1)(v3.value0)(v4.value0);
                                  }), v4.value1, Data_Lazy.defer(function (v5) {
                                      return deepL(dictMonoid)(dictMeasured)(v4.value2)(v3.value2)(v2.value3);
                                  }));
                              };
                              var v3 = splitDigit(dictMonoid)(dictMeasured)(v)(vm)(v2.value3);
                              return new LazySplit(Data_Lazy.defer(function (v4) {
                                  return deepR(dictMonoid)(dictMeasured)(v2.value1)(v2.value2)(v3.value0);
                              }), v3.value1, Data_Lazy.defer(function (v4) {
                                  return toFingerTree(dictMonoid)(dictMeasured)(Data_Foldable.foldableArray)(v3.value2);
                              }));
                          };
                          throw new Error("Failed pattern match at Data.FingerTree (line 428, column 1 - line 429, column 70): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
                      };
                  };
              };
          };
      };
  };
  var cons = function (dictMonoid) {
      return function (dictMeasured) {
          return function (a) {
              return function (v) {
                  if (v instanceof Empty) {
                      return new Single(a);
                  };
                  if (v instanceof Single) {
                      return deep(dictMonoid)(dictMeasured)(Data_FingerTree_Digit.mkDigit1(a))(lazyEmpty)(Data_FingerTree_Digit.mkDigit1(v.value0));
                  };
                  if (v instanceof Deep) {
                      var v1 = Data_FingerTree_Digit.runDigit(v.value1);
                      if (v1.length === 4) {
                          var forcedM = Data_Lazy.force(v.value2);
                          return deep(dictMonoid)(dictMeasured)(Data_FingerTree_Digit.mkDigit2(a)(v1[0]))(Data_Lazy.defer(function (v2) {
                              return cons(dictMonoid)(measuredNode)(node3(dictMonoid)(dictMeasured)(v1[1])(v1[2])(v1[3]))(forcedM);
                          }))(v.value3);
                      };
                      var pr$prime = Data_FingerTree_Digit.consDigit()(a)(v.value1);
                      return deep(dictMonoid)(dictMeasured)(pr$prime)(v.value2)(v.value3);
                  };
                  throw new Error("Failed pattern match at Data.FingerTree (line 234, column 1 - line 235, column 40): " + [ a.constructor.name, v.constructor.name ]);
              };
          };
      };
  };
  var consAll = function (dictMonoid) {
      return function (dictMeasured) {
          return function (dictFoldable) {
              return Data_Function.flip(Data_Foldable.foldr(dictFoldable)(cons(dictMonoid)(dictMeasured)));
          };
      };
  };
  var filter = function (dictMonoid) {
      return function (dictMeasured) {
          return function (p) {
              return Data_Foldable.foldr(foldableFingerTree)(function (x) {
                  return function (acc) {
                      var $385 = p(x);
                      if ($385) {
                          return cons(dictMonoid)(dictMeasured)(x)(acc);
                      };
                      return acc;
                  };
              })(Empty.value);
          };
      };
  };
  var split = function (dictMonoid) {
      return function (dictMeasured) {
          return function (dictPartial) {
              return function (p) {
                  return function (v) {
                      if (v instanceof Empty) {
                          return new Data_Tuple.Tuple(lazyEmpty, lazyEmpty);
                      };
                      var $388 = p(Data_Sequence_Internal.measure(measuredFingerTree(dictMonoid)(dictMeasured))(v));
                      if ($388) {
                          var v1 = splitTree(dictMonoid)(dictMeasured)()(p)(Data_Monoid.mempty(dictMonoid))(v);
                          return new Data_Tuple.Tuple(v1.value0, Data_Lazy.defer(function (v2) {
                              return cons(dictMonoid)(dictMeasured)(v1.value1)(Data_Lazy.force(v1.value2));
                          }));
                      };
                      return new Data_Tuple.Tuple(Data_Lazy.defer(function (v1) {
                          return v;
                      }), lazyEmpty);
                  };
              };
          };
      };
  };
  var app3 = function (dictMonoid) {
      return function (dictMeasured) {
          return function (v) {
              return function (ts) {
                  return function (v1) {
                      if (v instanceof Empty) {
                          return consAll(dictMonoid)(dictMeasured)(Data_Foldable.foldableArray)(ts)(v1);
                      };
                      if (v1 instanceof Empty) {
                          return snocAll(dictMonoid)(dictMeasured)(Data_Foldable.foldableArray)(v)(ts);
                      };
                      if (v instanceof Single) {
                          return cons(dictMonoid)(dictMeasured)(v.value0)(consAll(dictMonoid)(dictMeasured)(Data_Foldable.foldableArray)(ts)(v1));
                      };
                      if (v1 instanceof Single) {
                          return snoc(dictMonoid)(dictMeasured)(snocAll(dictMonoid)(dictMeasured)(Data_Foldable.foldableArray)(v)(ts))(v1.value0);
                      };
                      if (v instanceof Deep && v1 instanceof Deep) {
                          var computeM$prime = function (v2) {
                              return app3(dictMonoid)(measuredNode)(Data_Lazy.force(v.value2))(nodes(dictMonoid)(dictMeasured)(Data_Semigroup.append(Data_Semigroup.semigroupArray)(Data_FingerTree_Digit.runDigit(v.value3))(Data_Semigroup.append(Data_Semigroup.semigroupArray)(ts)(Data_FingerTree_Digit.runDigit(v1.value1)))))(Data_Lazy.force(v1.value2));
                          };
                          return deep(dictMonoid)(dictMeasured)(v.value1)(Data_Lazy.defer(computeM$prime))(v1.value3);
                      };
                      throw new Error("Failed pattern match at Data.FingerTree (line 372, column 1 - line 373, column 70): " + [ v.constructor.name, ts.constructor.name, v1.constructor.name ]);
                  };
              };
          };
      };
  };
  var append = function (dictMonoid) {
      return function (dictMeasured) {
          return function (xs) {
              return function (ys) {
                  return app3(dictMonoid)(dictMeasured)(xs)([  ])(ys);
              };
          };
      };
  };
  exports["Empty"] = Empty;
  exports["eqFingerTree"] = eqFingerTree;
  exports["cons"] = cons;
  exports["snoc"] = snoc;
  exports["head"] = head;
  exports["append"] = append;
  exports["split"] = split;
  exports["filter"] = filter;
  exports["unfoldLeft"] = unfoldLeft;
  exports["functorFingerTree"] = functorFingerTree;
  exports["foldableFingerTree"] = foldableFingerTree;
  exports["measuredFingerTree"] = measuredFingerTree;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Functor.Compose"] = $PS["Data.Functor.Compose"] || {};
  var exports = $PS["Data.Functor.Compose"];       
  var Compose = function (x) {
      return x;
  };
  exports["Compose"] = Compose;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.HugeNum"] = $PS["Data.HugeNum"] || {};
  var exports = $PS["Data.HugeNum"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Digit = $PS["Data.Digit"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Plus = (function () {
      function Plus() {

      };
      Plus.value = new Plus();
      return Plus;
  })();
  var Minus = (function () {
      function Minus() {

      };
      Minus.value = new Minus();
      return Minus;
  })();
  var fromString = function (s) {
      var charlist = Data_List.fromFoldable(Data_Foldable.foldableArray)(Data_String_CodeUnits.toCharArray(s));
      return Control_Bind.bind(Data_Maybe.bindMaybe)(Data_List.head(charlist))(function (leadingChar) {
          var signDigits = (function () {
              if (leadingChar === "-") {
                  return {
                      sign: Minus.value,
                      digits: Data_List.drop(1)(charlist)
                  };
              };
              return {
                  sign: Plus.value,
                  digits: charlist
              };
          })();
          return Control_Bind.bind(Data_Maybe.bindMaybe)(Data_List.elemIndex(Data_Eq.eqChar)(".")(signDigits.digits))(function (decimal) {
              return Control_Bind.bind(Data_Maybe.bindMaybe)(Data_List.deleteAt(decimal)(signDigits.digits))(function (newCharlist) {
                  return Control_Bind.bind(Data_Maybe.bindMaybe)(Data_Traversable.sequence(Data_List_Types.traversableList)(Data_Maybe.applicativeMaybe)(Data_Functor.map(Data_List_Types.functorList)(Data_Digit.fromChar)(newCharlist)))(function (digits) {
                      return Control_Applicative.pure(Data_Maybe.applicativeMaybe)({
                          sign: signDigits.sign,
                          decimal: decimal,
                          digits: digits
                      });
                  });
              });
          });
      });
  };
  exports["fromString"] = fromString;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Profunctor"] = $PS["Data.Profunctor"] || {};
  var exports = $PS["Data.Profunctor"];
  var Control_Category = $PS["Control.Category"];        
  var Profunctor = function (dimap) {
      this.dimap = dimap;
  };
  var profunctorFn = new Profunctor(function (a2b) {
      return function (c2d) {
          return function (b2c) {
              return function ($9) {
                  return c2d(b2c(a2b($9)));
              };
          };
      };
  });
  var dimap = function (dict) {
      return dict.dimap;
  };
  var rmap = function (dictProfunctor) {
      return function (b2c) {
          return dimap(dictProfunctor)(Control_Category.identity(Control_Category.categoryFn))(b2c);
      };
  };
  exports["dimap"] = dimap;
  exports["Profunctor"] = Profunctor;
  exports["rmap"] = rmap;
  exports["profunctorFn"] = profunctorFn;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Profunctor.Choice"] = $PS["Data.Profunctor.Choice"] || {};
  var exports = $PS["Data.Profunctor.Choice"];
  var Data_Either = $PS["Data.Either"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Profunctor = $PS["Data.Profunctor"];                
  var Choice = function (Profunctor0, left, right) {
      this.Profunctor0 = Profunctor0;
      this.left = left;
      this.right = right;
  };
  var right = function (dict) {
      return dict.right;
  };
  var choiceFn = new Choice(function () {
      return Data_Profunctor.profunctorFn;
  }, function (v) {
      return function (v1) {
          if (v1 instanceof Data_Either.Left) {
              return Data_Either.Left.create(v(v1.value0));
          };
          if (v1 instanceof Data_Either.Right) {
              return new Data_Either.Right(v1.value0);
          };
          throw new Error("Failed pattern match at Data.Profunctor.Choice (line 32, column 1 - line 35, column 16): " + [ v.constructor.name, v1.constructor.name ]);
      };
  }, Data_Functor.map(Data_Either.functorEither));
  exports["right"] = right;
  exports["Choice"] = Choice;
  exports["choiceFn"] = choiceFn;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Profunctor.Strong"] = $PS["Data.Profunctor.Strong"] || {};
  var exports = $PS["Data.Profunctor.Strong"];
  var Control_Category = $PS["Control.Category"];
  var Control_Semigroupoid = $PS["Control.Semigroupoid"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Profunctor = $PS["Data.Profunctor"];
  var Data_Tuple = $PS["Data.Tuple"];                
  var Strong = function (Profunctor0, first, second) {
      this.Profunctor0 = Profunctor0;
      this.first = first;
      this.second = second;
  };
  var strongFn = new Strong(function () {
      return Data_Profunctor.profunctorFn;
  }, function (a2b) {
      return function (v) {
          return new Data_Tuple.Tuple(a2b(v.value0), v.value1);
      };
  }, Data_Functor.map(Data_Tuple.functorTuple));
  var second = function (dict) {
      return dict.second;
  };
  var first = function (dict) {
      return dict.first;
  };
  var splitStrong = function (dictCategory) {
      return function (dictStrong) {
          return function (l) {
              return function (r) {
                  return Control_Semigroupoid.composeFlipped(dictCategory.Semigroupoid0())(first(dictStrong)(l))(second(dictStrong)(r));
              };
          };
      };
  };
  var fanout = function (dictCategory) {
      return function (dictStrong) {
          return function (l) {
              return function (r) {
                  var split = Data_Profunctor.dimap(dictStrong.Profunctor0())(Control_Category.identity(Control_Category.categoryFn))(function (a) {
                      return new Data_Tuple.Tuple(a, a);
                  })(Control_Category.identity(dictCategory));
                  return Control_Semigroupoid.composeFlipped(dictCategory.Semigroupoid0())(split)(splitStrong(dictCategory)(dictStrong)(l)(r));
              };
          };
      };
  };
  exports["first"] = first;
  exports["second"] = second;
  exports["Strong"] = Strong;
  exports["fanout"] = fanout;
  exports["strongFn"] = strongFn;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.AffineTraversal"] = $PS["Data.Lens.AffineTraversal"] || {};
  var exports = $PS["Data.Lens.AffineTraversal"];
  var Control_Category = $PS["Control.Category"];
  var Data_Either = $PS["Data.Either"];
  var Data_Profunctor = $PS["Data.Profunctor"];
  var Data_Profunctor_Choice = $PS["Data.Profunctor.Choice"];
  var Data_Profunctor_Strong = $PS["Data.Profunctor.Strong"];
  var affineTraversal$prime = function (to) {
      return function (dictStrong) {
          return function (dictChoice) {
              return function (pab) {
                  return Data_Profunctor.dimap(dictChoice.Profunctor0())(to)(function (v) {
                      return Data_Either.either(Control_Category.identity(Control_Category.categoryFn))(v.value0)(v.value1);
                  })(Data_Profunctor_Strong.second(dictStrong)(Data_Profunctor_Choice.right(dictChoice)(pab)));
              };
          };
      };
  };
  var affineTraversal = function (set) {
      return function (pre) {
          return function (dictStrong) {
              return function (dictChoice) {
                  return affineTraversal$prime(Data_Profunctor_Strong.fanout(Control_Category.categoryFn)(Data_Profunctor_Strong.strongFn)(set)(pre))(dictStrong)(dictChoice);
              };
          };
      };
  };
  exports["affineTraversal"] = affineTraversal;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.List.Lazy.Types"] = $PS["Data.List.Lazy.Types"] || {};
  var exports = $PS["Data.List.Lazy.Types"];
  var Control_Lazy = $PS["Control.Lazy"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Lazy = $PS["Data.Lazy"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Newtype = $PS["Data.Newtype"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Data_Unfoldable1 = $PS["Data.Unfoldable1"];                
  var List = function (x) {
      return x;
  };
  var Nil = (function () {
      function Nil() {

      };
      Nil.value = new Nil();
      return Nil;
  })();
  var Cons = (function () {
      function Cons(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Cons.create = function (value0) {
          return function (value1) {
              return new Cons(value0, value1);
          };
      };
      return Cons;
  })();
  var nil = List(Data_Lazy.defer(function (v) {
      return Nil.value;
  }));
  var step = (function () {
      var $225 = Data_Newtype.unwrap();
      return function ($226) {
          return Data_Lazy.force($225($226));
      };
  })();   
  var lazyList = new Control_Lazy.Lazy(function (f) {
      return List(Data_Lazy.defer(function ($227) {
          return step(f($227));
      }));
  });
  var cons = function (x) {
      return function (xs) {
          return List(Data_Lazy.defer(function (v) {
              return new Cons(x, xs);
          }));
      };
  };
  var foldableList = new Data_Foldable.Foldable(function (dictMonoid) {
      return function (f) {
          return Data_Foldable.foldl(foldableList)(function (b) {
              return function (a) {
                  return Data_Semigroup.append(dictMonoid.Semigroup0())(b)(f(a));
              };
          })(Data_Monoid.mempty(dictMonoid));
      };
  }, function (op) {
      var go = function ($copy_b) {
          return function ($copy_xs) {
              var $tco_var_b = $copy_b;
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(b, xs) {
                  var v = step(xs);
                  if (v instanceof Nil) {
                      $tco_done = true;
                      return b;
                  };
                  if (v instanceof Cons) {
                      $tco_var_b = op(b)(v.value0);
                      $copy_xs = v.value1;
                      return;
                  };
                  throw new Error("Failed pattern match at Data.List.Lazy.Types (line 128, column 7 - line 130, column 40): " + [ v.constructor.name ]);
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($tco_var_b, $copy_xs);
              };
              return $tco_result;
          };
      };
      return go;
  }, function (op) {
      return function (z) {
          return function (xs) {
              var rev = Data_Foldable.foldl(foldableList)(Data_Function.flip(cons))(nil);
              return Data_Foldable.foldl(foldableList)(Data_Function.flip(op))(z)(rev(xs));
          };
      };
  });
  var unfoldable1List = new Data_Unfoldable1.Unfoldable1((function () {
      var go = function (f) {
          return function (b) {
              return Control_Lazy.defer(lazyList)(function (v) {
                  var v1 = f(b);
                  if (v1.value1 instanceof Data_Maybe.Just) {
                      return cons(v1.value0)(go(f)(v1.value1.value0));
                  };
                  if (v1.value1 instanceof Data_Maybe.Nothing) {
                      return cons(v1.value0)(nil);
                  };
                  throw new Error("Failed pattern match at Data.List.Lazy.Types (line 152, column 28 - line 154, column 33): " + [ v1.constructor.name ]);
              });
          };
      };
      return go;
  })());
  var unfoldableList = new Data_Unfoldable.Unfoldable(function () {
      return unfoldable1List;
  }, (function () {
      var go = function (f) {
          return function (b) {
              return Control_Lazy.defer(lazyList)(function (v) {
                  var v1 = f(b);
                  if (v1 instanceof Data_Maybe.Nothing) {
                      return nil;
                  };
                  if (v1 instanceof Data_Maybe.Just) {
                      return cons(v1.value0.value0)(go(f)(v1.value0.value1));
                  };
                  throw new Error("Failed pattern match at Data.List.Lazy.Types (line 158, column 28 - line 160, column 39): " + [ v1.constructor.name ]);
              });
          };
      };
      return go;
  })());
  exports["List"] = List;
  exports["Nil"] = Nil;
  exports["Cons"] = Cons;
  exports["step"] = step;
  exports["foldableList"] = foldableList;
  exports["unfoldableList"] = unfoldableList;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.List.Lazy"] = $PS["Data.List.Lazy"] || {};
  var exports = $PS["Data.List.Lazy"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Lazy = $PS["Data.Lazy"];
  var Data_List_Lazy_Types = $PS["Data.List.Lazy.Types"];
  var Data_Newtype = $PS["Data.Newtype"];
  var filter = function (p) {
      var go = function ($copy_v) {
          var $tco_done = false;
          var $tco_result;
          function $tco_loop(v) {
              if (v instanceof Data_List_Lazy_Types.Nil) {
                  $tco_done = true;
                  return Data_List_Lazy_Types.Nil.value;
              };
              if (v instanceof Data_List_Lazy_Types.Cons) {
                  if (p(v.value0)) {
                      $tco_done = true;
                      return new Data_List_Lazy_Types.Cons(v.value0, filter(p)(v.value1));
                  };
                  if (Data_Boolean.otherwise) {
                      $copy_v = Data_List_Lazy_Types.step(v.value1);
                      return;
                  };
              };
              throw new Error("Failed pattern match at Data.List.Lazy (line 416, column 3 - line 416, column 15): " + [ v.constructor.name ]);
          };
          while (!$tco_done) {
              $tco_result = $tco_loop($copy_v);
          };
          return $tco_result;
      };
      var $268 = Data_Functor.map(Data_Lazy.functorLazy)(go);
      var $269 = Data_Newtype.unwrap();
      return function ($270) {
          return Data_List_Lazy_Types.List($268($269($270)));
      };
  };
  exports["filter"] = filter;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Map.Internal"] = $PS["Data.Map.Internal"] || {};
  var exports = $PS["Data.Map.Internal"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Category = $PS["Control.Category"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_FoldableWithIndex = $PS["Data.FoldableWithIndex"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_FunctorWithIndex = $PS["Data.FunctorWithIndex"];
  var Data_List_Lazy = $PS["Data.List.Lazy"];
  var Data_List_Lazy_Types = $PS["Data.List.Lazy.Types"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ordering = $PS["Data.Ordering"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Data_TraversableWithIndex = $PS["Data.TraversableWithIndex"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];                
  var Leaf = (function () {
      function Leaf() {

      };
      Leaf.value = new Leaf();
      return Leaf;
  })();
  var Two = (function () {
      function Two(value0, value1, value2, value3) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
      };
      Two.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return new Two(value0, value1, value2, value3);
                  };
              };
          };
      };
      return Two;
  })();
  var Three = (function () {
      function Three(value0, value1, value2, value3, value4, value5, value6) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
          this.value4 = value4;
          this.value5 = value5;
          this.value6 = value6;
      };
      Three.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return function (value4) {
                          return function (value5) {
                              return function (value6) {
                                  return new Three(value0, value1, value2, value3, value4, value5, value6);
                              };
                          };
                      };
                  };
              };
          };
      };
      return Three;
  })();
  var TwoLeft = (function () {
      function TwoLeft(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      TwoLeft.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new TwoLeft(value0, value1, value2);
              };
          };
      };
      return TwoLeft;
  })();
  var TwoRight = (function () {
      function TwoRight(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      TwoRight.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new TwoRight(value0, value1, value2);
              };
          };
      };
      return TwoRight;
  })();
  var ThreeLeft = (function () {
      function ThreeLeft(value0, value1, value2, value3, value4, value5) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
          this.value4 = value4;
          this.value5 = value5;
      };
      ThreeLeft.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return function (value4) {
                          return function (value5) {
                              return new ThreeLeft(value0, value1, value2, value3, value4, value5);
                          };
                      };
                  };
              };
          };
      };
      return ThreeLeft;
  })();
  var ThreeMiddle = (function () {
      function ThreeMiddle(value0, value1, value2, value3, value4, value5) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
          this.value4 = value4;
          this.value5 = value5;
      };
      ThreeMiddle.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return function (value4) {
                          return function (value5) {
                              return new ThreeMiddle(value0, value1, value2, value3, value4, value5);
                          };
                      };
                  };
              };
          };
      };
      return ThreeMiddle;
  })();
  var ThreeRight = (function () {
      function ThreeRight(value0, value1, value2, value3, value4, value5) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
          this.value4 = value4;
          this.value5 = value5;
      };
      ThreeRight.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return function (value4) {
                          return function (value5) {
                              return new ThreeRight(value0, value1, value2, value3, value4, value5);
                          };
                      };
                  };
              };
          };
      };
      return ThreeRight;
  })();
  var KickUp = (function () {
      function KickUp(value0, value1, value2, value3) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
      };
      KickUp.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return new KickUp(value0, value1, value2, value3);
                  };
              };
          };
      };
      return KickUp;
  })();
  var values = function (v) {
      if (v instanceof Leaf) {
          return Data_List_Types.Nil.value;
      };
      if (v instanceof Two) {
          return Data_Semigroup.append(Data_List_Types.semigroupList)(values(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value2))(values(v.value3)));
      };
      if (v instanceof Three) {
          return Data_Semigroup.append(Data_List_Types.semigroupList)(values(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value2))(Data_Semigroup.append(Data_List_Types.semigroupList)(values(v.value3))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value5))(values(v.value6)))));
      };
      throw new Error("Failed pattern match at Data.Map.Internal (line 626, column 1 - line 626, column 40): " + [ v.constructor.name ]);
  };
  var singleton = function (k) {
      return function (v) {
          return new Two(Leaf.value, k, v, Leaf.value);
      };
  };
  var toUnfoldable = function (dictUnfoldable) {
      return function (m) {
          var go = function ($copy_v) {
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(v) {
                  if (v instanceof Data_List_Types.Nil) {
                      $tco_done = true;
                      return Data_Maybe.Nothing.value;
                  };
                  if (v instanceof Data_List_Types.Cons) {
                      if (v.value0 instanceof Leaf) {
                          $copy_v = v.value1;
                          return;
                      };
                      if (v.value0 instanceof Two && (v.value0.value0 instanceof Leaf && v.value0.value3 instanceof Leaf)) {
                          $tco_done = true;
                          return Data_Maybe.Just.create(new Data_Tuple.Tuple(new Data_Tuple.Tuple(v.value0.value1, v.value0.value2), v.value1));
                      };
                      if (v.value0 instanceof Two && v.value0.value0 instanceof Leaf) {
                          $tco_done = true;
                          return Data_Maybe.Just.create(new Data_Tuple.Tuple(new Data_Tuple.Tuple(v.value0.value1, v.value0.value2), new Data_List_Types.Cons(v.value0.value3, v.value1)));
                      };
                      if (v.value0 instanceof Two) {
                          $copy_v = new Data_List_Types.Cons(v.value0.value0, new Data_List_Types.Cons(singleton(v.value0.value1)(v.value0.value2), new Data_List_Types.Cons(v.value0.value3, v.value1)));
                          return;
                      };
                      if (v.value0 instanceof Three) {
                          $copy_v = new Data_List_Types.Cons(v.value0.value0, new Data_List_Types.Cons(singleton(v.value0.value1)(v.value0.value2), new Data_List_Types.Cons(v.value0.value3, new Data_List_Types.Cons(singleton(v.value0.value4)(v.value0.value5), new Data_List_Types.Cons(v.value0.value6, v.value1)))));
                          return;
                      };
                      throw new Error("Failed pattern match at Data.Map.Internal (line 591, column 18 - line 600, column 71): " + [ v.value0.constructor.name ]);
                  };
                  throw new Error("Failed pattern match at Data.Map.Internal (line 590, column 3 - line 590, column 19): " + [ v.constructor.name ]);
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($copy_v);
              };
              return $tco_result;
          };
          return Data_Unfoldable.unfoldr(dictUnfoldable)(go)(new Data_List_Types.Cons(m, Data_List_Types.Nil.value));
      };
  };
  var toAscArray = toUnfoldable(Data_Unfoldable.unfoldableArray);
  var lookup = function (dictOrd) {
      return function (k) {
          var comp = Data_Ord.compare(dictOrd);
          var go = function ($copy_v) {
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(v) {
                  if (v instanceof Leaf) {
                      $tco_done = true;
                      return Data_Maybe.Nothing.value;
                  };
                  if (v instanceof Two) {
                      var v2 = comp(k)(v.value1);
                      if (v2 instanceof Data_Ordering.EQ) {
                          $tco_done = true;
                          return new Data_Maybe.Just(v.value2);
                      };
                      if (v2 instanceof Data_Ordering.LT) {
                          $copy_v = v.value0;
                          return;
                      };
                      $copy_v = v.value3;
                      return;
                  };
                  if (v instanceof Three) {
                      var v3 = comp(k)(v.value1);
                      if (v3 instanceof Data_Ordering.EQ) {
                          $tco_done = true;
                          return new Data_Maybe.Just(v.value2);
                      };
                      var v4 = comp(k)(v.value4);
                      if (v4 instanceof Data_Ordering.EQ) {
                          $tco_done = true;
                          return new Data_Maybe.Just(v.value5);
                      };
                      if (v3 instanceof Data_Ordering.LT) {
                          $copy_v = v.value0;
                          return;
                      };
                      if (v4 instanceof Data_Ordering.GT) {
                          $copy_v = v.value6;
                          return;
                      };
                      $copy_v = v.value3;
                      return;
                  };
                  throw new Error("Failed pattern match at Data.Map.Internal (line 211, column 5 - line 211, column 22): " + [ v.constructor.name ]);
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($copy_v);
              };
              return $tco_result;
          };
          return go;
      };
  };
  var member = function (dictOrd) {
      return function (k) {
          return function (m) {
              return Data_Maybe.isJust(lookup(dictOrd)(k)(m));
          };
      };
  };
  var keys = function (v) {
      if (v instanceof Leaf) {
          return Data_List_Types.Nil.value;
      };
      if (v instanceof Two) {
          return Data_Semigroup.append(Data_List_Types.semigroupList)(keys(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value1))(keys(v.value3)));
      };
      if (v instanceof Three) {
          return Data_Semigroup.append(Data_List_Types.semigroupList)(keys(v.value0))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value1))(Data_Semigroup.append(Data_List_Types.semigroupList)(keys(v.value3))(Data_Semigroup.append(Data_List_Types.semigroupList)(Control_Applicative.pure(Data_List_Types.applicativeList)(v.value4))(keys(v.value6)))));
      };
      throw new Error("Failed pattern match at Data.Map.Internal (line 620, column 1 - line 620, column 38): " + [ v.constructor.name ]);
  };
  var isEmpty = function (v) {
      if (v instanceof Leaf) {
          return true;
      };
      return false;
  };
  var functorMap = new Data_Functor.Functor(function (v) {
      return function (v1) {
          if (v1 instanceof Leaf) {
              return Leaf.value;
          };
          if (v1 instanceof Two) {
              return new Two(Data_Functor.map(functorMap)(v)(v1.value0), v1.value1, v(v1.value2), Data_Functor.map(functorMap)(v)(v1.value3));
          };
          if (v1 instanceof Three) {
              return new Three(Data_Functor.map(functorMap)(v)(v1.value0), v1.value1, v(v1.value2), Data_Functor.map(functorMap)(v)(v1.value3), v1.value4, v(v1.value5), Data_Functor.map(functorMap)(v)(v1.value6));
          };
          throw new Error("Failed pattern match at Data.Map.Internal (line 101, column 1 - line 104, column 110): " + [ v.constructor.name, v1.constructor.name ]);
      };
  });
  var functorWithIndexMap = new Data_FunctorWithIndex.FunctorWithIndex(function () {
      return functorMap;
  }, function (v) {
      return function (v1) {
          if (v1 instanceof Leaf) {
              return Leaf.value;
          };
          if (v1 instanceof Two) {
              return new Two(Data_FunctorWithIndex.mapWithIndex(functorWithIndexMap)(v)(v1.value0), v1.value1, v(v1.value1)(v1.value2), Data_FunctorWithIndex.mapWithIndex(functorWithIndexMap)(v)(v1.value3));
          };
          if (v1 instanceof Three) {
              return new Three(Data_FunctorWithIndex.mapWithIndex(functorWithIndexMap)(v)(v1.value0), v1.value1, v(v1.value1)(v1.value2), Data_FunctorWithIndex.mapWithIndex(functorWithIndexMap)(v)(v1.value3), v1.value4, v(v1.value4)(v1.value5), Data_FunctorWithIndex.mapWithIndex(functorWithIndexMap)(v)(v1.value6));
          };
          throw new Error("Failed pattern match at Data.Map.Internal (line 106, column 1 - line 109, column 152): " + [ v.constructor.name, v1.constructor.name ]);
      };
  });
  var fromZipper = function ($copy_dictOrd) {
      return function ($copy_v) {
          return function ($copy_tree) {
              var $tco_var_dictOrd = $copy_dictOrd;
              var $tco_var_v = $copy_v;
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(dictOrd, v, tree) {
                  if (v instanceof Data_List_Types.Nil) {
                      $tco_done = true;
                      return tree;
                  };
                  if (v instanceof Data_List_Types.Cons) {
                      if (v.value0 instanceof TwoLeft) {
                          $tco_var_dictOrd = dictOrd;
                          $tco_var_v = v.value1;
                          $copy_tree = new Two(tree, v.value0.value0, v.value0.value1, v.value0.value2);
                          return;
                      };
                      if (v.value0 instanceof TwoRight) {
                          $tco_var_dictOrd = dictOrd;
                          $tco_var_v = v.value1;
                          $copy_tree = new Two(v.value0.value0, v.value0.value1, v.value0.value2, tree);
                          return;
                      };
                      if (v.value0 instanceof ThreeLeft) {
                          $tco_var_dictOrd = dictOrd;
                          $tco_var_v = v.value1;
                          $copy_tree = new Three(tree, v.value0.value0, v.value0.value1, v.value0.value2, v.value0.value3, v.value0.value4, v.value0.value5);
                          return;
                      };
                      if (v.value0 instanceof ThreeMiddle) {
                          $tco_var_dictOrd = dictOrd;
                          $tco_var_v = v.value1;
                          $copy_tree = new Three(v.value0.value0, v.value0.value1, v.value0.value2, tree, v.value0.value3, v.value0.value4, v.value0.value5);
                          return;
                      };
                      if (v.value0 instanceof ThreeRight) {
                          $tco_var_dictOrd = dictOrd;
                          $tco_var_v = v.value1;
                          $copy_tree = new Three(v.value0.value0, v.value0.value1, v.value0.value2, v.value0.value3, v.value0.value4, v.value0.value5, tree);
                          return;
                      };
                      throw new Error("Failed pattern match at Data.Map.Internal (line 432, column 3 - line 437, column 88): " + [ v.value0.constructor.name ]);
                  };
                  throw new Error("Failed pattern match at Data.Map.Internal (line 429, column 1 - line 429, column 80): " + [ v.constructor.name, tree.constructor.name ]);
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($tco_var_dictOrd, $tco_var_v, $copy_tree);
              };
              return $tco_result;
          };
      };
  };
  var insert = function (dictOrd) {
      return function (k) {
          return function (v) {
              var up = function ($copy_v1) {
                  return function ($copy_v2) {
                      var $tco_var_v1 = $copy_v1;
                      var $tco_done = false;
                      var $tco_result;
                      function $tco_loop(v1, v2) {
                          if (v1 instanceof Data_List_Types.Nil) {
                              $tco_done = true;
                              return new Two(v2.value0, v2.value1, v2.value2, v2.value3);
                          };
                          if (v1 instanceof Data_List_Types.Cons) {
                              if (v1.value0 instanceof TwoLeft) {
                                  $tco_done = true;
                                  return fromZipper(dictOrd)(v1.value1)(new Three(v2.value0, v2.value1, v2.value2, v2.value3, v1.value0.value0, v1.value0.value1, v1.value0.value2));
                              };
                              if (v1.value0 instanceof TwoRight) {
                                  $tco_done = true;
                                  return fromZipper(dictOrd)(v1.value1)(new Three(v1.value0.value0, v1.value0.value1, v1.value0.value2, v2.value0, v2.value1, v2.value2, v2.value3));
                              };
                              if (v1.value0 instanceof ThreeLeft) {
                                  $tco_var_v1 = v1.value1;
                                  $copy_v2 = new KickUp(new Two(v2.value0, v2.value1, v2.value2, v2.value3), v1.value0.value0, v1.value0.value1, new Two(v1.value0.value2, v1.value0.value3, v1.value0.value4, v1.value0.value5));
                                  return;
                              };
                              if (v1.value0 instanceof ThreeMiddle) {
                                  $tco_var_v1 = v1.value1;
                                  $copy_v2 = new KickUp(new Two(v1.value0.value0, v1.value0.value1, v1.value0.value2, v2.value0), v2.value1, v2.value2, new Two(v2.value3, v1.value0.value3, v1.value0.value4, v1.value0.value5));
                                  return;
                              };
                              if (v1.value0 instanceof ThreeRight) {
                                  $tco_var_v1 = v1.value1;
                                  $copy_v2 = new KickUp(new Two(v1.value0.value0, v1.value0.value1, v1.value0.value2, v1.value0.value3), v1.value0.value4, v1.value0.value5, new Two(v2.value0, v2.value1, v2.value2, v2.value3));
                                  return;
                              };
                              throw new Error("Failed pattern match at Data.Map.Internal (line 468, column 5 - line 473, column 108): " + [ v1.value0.constructor.name, v2.constructor.name ]);
                          };
                          throw new Error("Failed pattern match at Data.Map.Internal (line 465, column 3 - line 465, column 56): " + [ v1.constructor.name, v2.constructor.name ]);
                      };
                      while (!$tco_done) {
                          $tco_result = $tco_loop($tco_var_v1, $copy_v2);
                      };
                      return $tco_result;
                  };
              };
              var comp = Data_Ord.compare(dictOrd);
              var down = function ($copy_ctx) {
                  return function ($copy_v1) {
                      var $tco_var_ctx = $copy_ctx;
                      var $tco_done1 = false;
                      var $tco_result;
                      function $tco_loop(ctx, v1) {
                          if (v1 instanceof Leaf) {
                              $tco_done1 = true;
                              return up(ctx)(new KickUp(Leaf.value, k, v, Leaf.value));
                          };
                          if (v1 instanceof Two) {
                              var v2 = comp(k)(v1.value1);
                              if (v2 instanceof Data_Ordering.EQ) {
                                  $tco_done1 = true;
                                  return fromZipper(dictOrd)(ctx)(new Two(v1.value0, k, v, v1.value3));
                              };
                              if (v2 instanceof Data_Ordering.LT) {
                                  $tco_var_ctx = new Data_List_Types.Cons(new TwoLeft(v1.value1, v1.value2, v1.value3), ctx);
                                  $copy_v1 = v1.value0;
                                  return;
                              };
                              $tco_var_ctx = new Data_List_Types.Cons(new TwoRight(v1.value0, v1.value1, v1.value2), ctx);
                              $copy_v1 = v1.value3;
                              return;
                          };
                          if (v1 instanceof Three) {
                              var v3 = comp(k)(v1.value1);
                              if (v3 instanceof Data_Ordering.EQ) {
                                  $tco_done1 = true;
                                  return fromZipper(dictOrd)(ctx)(new Three(v1.value0, k, v, v1.value3, v1.value4, v1.value5, v1.value6));
                              };
                              var v4 = comp(k)(v1.value4);
                              if (v4 instanceof Data_Ordering.EQ) {
                                  $tco_done1 = true;
                                  return fromZipper(dictOrd)(ctx)(new Three(v1.value0, v1.value1, v1.value2, v1.value3, k, v, v1.value6));
                              };
                              if (v3 instanceof Data_Ordering.LT) {
                                  $tco_var_ctx = new Data_List_Types.Cons(new ThreeLeft(v1.value1, v1.value2, v1.value3, v1.value4, v1.value5, v1.value6), ctx);
                                  $copy_v1 = v1.value0;
                                  return;
                              };
                              if (v3 instanceof Data_Ordering.GT && v4 instanceof Data_Ordering.LT) {
                                  $tco_var_ctx = new Data_List_Types.Cons(new ThreeMiddle(v1.value0, v1.value1, v1.value2, v1.value4, v1.value5, v1.value6), ctx);
                                  $copy_v1 = v1.value3;
                                  return;
                              };
                              $tco_var_ctx = new Data_List_Types.Cons(new ThreeRight(v1.value0, v1.value1, v1.value2, v1.value3, v1.value4, v1.value5), ctx);
                              $copy_v1 = v1.value6;
                              return;
                          };
                          throw new Error("Failed pattern match at Data.Map.Internal (line 448, column 3 - line 448, column 55): " + [ ctx.constructor.name, v1.constructor.name ]);
                      };
                      while (!$tco_done1) {
                          $tco_result = $tco_loop($tco_var_ctx, $copy_v1);
                      };
                      return $tco_result;
                  };
              };
              return down(Data_List_Types.Nil.value);
          };
      };
  };
  var pop = function (dictOrd) {
      return function (k) {
          var up = function ($copy_ctxs) {
              return function ($copy_tree) {
                  var $tco_var_ctxs = $copy_ctxs;
                  var $tco_done = false;
                  var $tco_result;
                  function $tco_loop(ctxs, tree) {
                      if (ctxs instanceof Data_List_Types.Nil) {
                          $tco_done = true;
                          return tree;
                      };
                      if (ctxs instanceof Data_List_Types.Cons) {
                          if (ctxs.value0 instanceof TwoLeft && (ctxs.value0.value2 instanceof Leaf && tree instanceof Leaf)) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Two(Leaf.value, ctxs.value0.value0, ctxs.value0.value1, Leaf.value));
                          };
                          if (ctxs.value0 instanceof TwoRight && (ctxs.value0.value0 instanceof Leaf && tree instanceof Leaf)) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Two(Leaf.value, ctxs.value0.value1, ctxs.value0.value2, Leaf.value));
                          };
                          if (ctxs.value0 instanceof TwoLeft && ctxs.value0.value2 instanceof Two) {
                              $tco_var_ctxs = ctxs.value1;
                              $copy_tree = new Three(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0, ctxs.value0.value2.value1, ctxs.value0.value2.value2, ctxs.value0.value2.value3);
                              return;
                          };
                          if (ctxs.value0 instanceof TwoRight && ctxs.value0.value0 instanceof Two) {
                              $tco_var_ctxs = ctxs.value1;
                              $copy_tree = new Three(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3, ctxs.value0.value1, ctxs.value0.value2, tree);
                              return;
                          };
                          if (ctxs.value0 instanceof TwoLeft && ctxs.value0.value2 instanceof Three) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Two(new Two(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0), ctxs.value0.value2.value1, ctxs.value0.value2.value2, new Two(ctxs.value0.value2.value3, ctxs.value0.value2.value4, ctxs.value0.value2.value5, ctxs.value0.value2.value6)));
                          };
                          if (ctxs.value0 instanceof TwoRight && ctxs.value0.value0 instanceof Three) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Two(new Two(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3), ctxs.value0.value0.value4, ctxs.value0.value0.value5, new Two(ctxs.value0.value0.value6, ctxs.value0.value1, ctxs.value0.value2, tree)));
                          };
                          if (ctxs.value0 instanceof ThreeLeft && (ctxs.value0.value2 instanceof Leaf && (ctxs.value0.value5 instanceof Leaf && tree instanceof Leaf))) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Three(Leaf.value, ctxs.value0.value0, ctxs.value0.value1, Leaf.value, ctxs.value0.value3, ctxs.value0.value4, Leaf.value));
                          };
                          if (ctxs.value0 instanceof ThreeMiddle && (ctxs.value0.value0 instanceof Leaf && (ctxs.value0.value5 instanceof Leaf && tree instanceof Leaf))) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Three(Leaf.value, ctxs.value0.value1, ctxs.value0.value2, Leaf.value, ctxs.value0.value3, ctxs.value0.value4, Leaf.value));
                          };
                          if (ctxs.value0 instanceof ThreeRight && (ctxs.value0.value0 instanceof Leaf && (ctxs.value0.value3 instanceof Leaf && tree instanceof Leaf))) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Three(Leaf.value, ctxs.value0.value1, ctxs.value0.value2, Leaf.value, ctxs.value0.value4, ctxs.value0.value5, Leaf.value));
                          };
                          if (ctxs.value0 instanceof ThreeLeft && ctxs.value0.value2 instanceof Two) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Two(new Three(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0, ctxs.value0.value2.value1, ctxs.value0.value2.value2, ctxs.value0.value2.value3), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5));
                          };
                          if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value0 instanceof Two) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Two(new Three(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3, ctxs.value0.value1, ctxs.value0.value2, tree), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5));
                          };
                          if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value5 instanceof Two) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Two(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Three(tree, ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5.value0, ctxs.value0.value5.value1, ctxs.value0.value5.value2, ctxs.value0.value5.value3)));
                          };
                          if (ctxs.value0 instanceof ThreeRight && ctxs.value0.value3 instanceof Two) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Two(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Three(ctxs.value0.value3.value0, ctxs.value0.value3.value1, ctxs.value0.value3.value2, ctxs.value0.value3.value3, ctxs.value0.value4, ctxs.value0.value5, tree)));
                          };
                          if (ctxs.value0 instanceof ThreeLeft && ctxs.value0.value2 instanceof Three) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Three(new Two(tree, ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2.value0), ctxs.value0.value2.value1, ctxs.value0.value2.value2, new Two(ctxs.value0.value2.value3, ctxs.value0.value2.value4, ctxs.value0.value2.value5, ctxs.value0.value2.value6), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5));
                          };
                          if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value0 instanceof Three) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Three(new Two(ctxs.value0.value0.value0, ctxs.value0.value0.value1, ctxs.value0.value0.value2, ctxs.value0.value0.value3), ctxs.value0.value0.value4, ctxs.value0.value0.value5, new Two(ctxs.value0.value0.value6, ctxs.value0.value1, ctxs.value0.value2, tree), ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5));
                          };
                          if (ctxs.value0 instanceof ThreeMiddle && ctxs.value0.value5 instanceof Three) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Three(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Two(tree, ctxs.value0.value3, ctxs.value0.value4, ctxs.value0.value5.value0), ctxs.value0.value5.value1, ctxs.value0.value5.value2, new Two(ctxs.value0.value5.value3, ctxs.value0.value5.value4, ctxs.value0.value5.value5, ctxs.value0.value5.value6)));
                          };
                          if (ctxs.value0 instanceof ThreeRight && ctxs.value0.value3 instanceof Three) {
                              $tco_done = true;
                              return fromZipper(dictOrd)(ctxs.value1)(new Three(ctxs.value0.value0, ctxs.value0.value1, ctxs.value0.value2, new Two(ctxs.value0.value3.value0, ctxs.value0.value3.value1, ctxs.value0.value3.value2, ctxs.value0.value3.value3), ctxs.value0.value3.value4, ctxs.value0.value3.value5, new Two(ctxs.value0.value3.value6, ctxs.value0.value4, ctxs.value0.value5, tree)));
                          };
                          throw new Error("Failed pattern match at Data.Map.Internal (line 525, column 9 - line 542, column 136): " + [ ctxs.value0.constructor.name, tree.constructor.name ]);
                      };
                      throw new Error("Failed pattern match at Data.Map.Internal (line 522, column 5 - line 542, column 136): " + [ ctxs.constructor.name ]);
                  };
                  while (!$tco_done) {
                      $tco_result = $tco_loop($tco_var_ctxs, $copy_tree);
                  };
                  return $tco_result;
              };
          };
          var removeMaxNode = function ($copy_ctx) {
              return function ($copy_m) {
                  var $tco_var_ctx = $copy_ctx;
                  var $tco_done1 = false;
                  var $tco_result;
                  function $tco_loop(ctx, m) {
                      if (m instanceof Two && (m.value0 instanceof Leaf && m.value3 instanceof Leaf)) {
                          $tco_done1 = true;
                          return up(ctx)(Leaf.value);
                      };
                      if (m instanceof Two) {
                          $tco_var_ctx = new Data_List_Types.Cons(new TwoRight(m.value0, m.value1, m.value2), ctx);
                          $copy_m = m.value3;
                          return;
                      };
                      if (m instanceof Three && (m.value0 instanceof Leaf && (m.value3 instanceof Leaf && m.value6 instanceof Leaf))) {
                          $tco_done1 = true;
                          return up(new Data_List_Types.Cons(new TwoRight(Leaf.value, m.value1, m.value2), ctx))(Leaf.value);
                      };
                      if (m instanceof Three) {
                          $tco_var_ctx = new Data_List_Types.Cons(new ThreeRight(m.value0, m.value1, m.value2, m.value3, m.value4, m.value5), ctx);
                          $copy_m = m.value6;
                          return;
                      };
                      throw new Error("Failed pattern match at Data.Map.Internal (line 554, column 5 - line 558, column 107): " + [ m.constructor.name ]);
                  };
                  while (!$tco_done1) {
                      $tco_result = $tco_loop($tco_var_ctx, $copy_m);
                  };
                  return $tco_result;
              };
          };
          var maxNode = function ($copy_m) {
              var $tco_done2 = false;
              var $tco_result;
              function $tco_loop(m) {
                  if (m instanceof Two && m.value3 instanceof Leaf) {
                      $tco_done2 = true;
                      return {
                          key: m.value1,
                          value: m.value2
                      };
                  };
                  if (m instanceof Two) {
                      $copy_m = m.value3;
                      return;
                  };
                  if (m instanceof Three && m.value6 instanceof Leaf) {
                      $tco_done2 = true;
                      return {
                          key: m.value4,
                          value: m.value5
                      };
                  };
                  if (m instanceof Three) {
                      $copy_m = m.value6;
                      return;
                  };
                  throw new Error("Failed pattern match at Data.Map.Internal (line 545, column 33 - line 549, column 45): " + [ m.constructor.name ]);
              };
              while (!$tco_done2) {
                  $tco_result = $tco_loop($copy_m);
              };
              return $tco_result;
          };
          var comp = Data_Ord.compare(dictOrd);
          var down = function ($copy_ctx) {
              return function ($copy_m) {
                  var $tco_var_ctx = $copy_ctx;
                  var $tco_done3 = false;
                  var $tco_result;
                  function $tco_loop(ctx, m) {
                      if (m instanceof Leaf) {
                          $tco_done3 = true;
                          return Data_Maybe.Nothing.value;
                      };
                      if (m instanceof Two) {
                          var v = comp(k)(m.value1);
                          if (m.value3 instanceof Leaf && v instanceof Data_Ordering.EQ) {
                              $tco_done3 = true;
                              return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, up(ctx)(Leaf.value)));
                          };
                          if (v instanceof Data_Ordering.EQ) {
                              var max = maxNode(m.value0);
                              $tco_done3 = true;
                              return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, removeMaxNode(new Data_List_Types.Cons(new TwoLeft(max.key, max.value, m.value3), ctx))(m.value0)));
                          };
                          if (v instanceof Data_Ordering.LT) {
                              $tco_var_ctx = new Data_List_Types.Cons(new TwoLeft(m.value1, m.value2, m.value3), ctx);
                              $copy_m = m.value0;
                              return;
                          };
                          $tco_var_ctx = new Data_List_Types.Cons(new TwoRight(m.value0, m.value1, m.value2), ctx);
                          $copy_m = m.value3;
                          return;
                      };
                      if (m instanceof Three) {
                          var leaves = (function () {
                              if (m.value0 instanceof Leaf && (m.value3 instanceof Leaf && m.value6 instanceof Leaf)) {
                                  return true;
                              };
                              return false;
                          })();
                          var v = comp(k)(m.value4);
                          var v3 = comp(k)(m.value1);
                          if (leaves && v3 instanceof Data_Ordering.EQ) {
                              $tco_done3 = true;
                              return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, fromZipper(dictOrd)(ctx)(new Two(Leaf.value, m.value4, m.value5, Leaf.value))));
                          };
                          if (leaves && v instanceof Data_Ordering.EQ) {
                              $tco_done3 = true;
                              return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value5, fromZipper(dictOrd)(ctx)(new Two(Leaf.value, m.value1, m.value2, Leaf.value))));
                          };
                          if (v3 instanceof Data_Ordering.EQ) {
                              var max = maxNode(m.value0);
                              $tco_done3 = true;
                              return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value2, removeMaxNode(new Data_List_Types.Cons(new ThreeLeft(max.key, max.value, m.value3, m.value4, m.value5, m.value6), ctx))(m.value0)));
                          };
                          if (v instanceof Data_Ordering.EQ) {
                              var max = maxNode(m.value3);
                              $tco_done3 = true;
                              return new Data_Maybe.Just(new Data_Tuple.Tuple(m.value5, removeMaxNode(new Data_List_Types.Cons(new ThreeMiddle(m.value0, m.value1, m.value2, max.key, max.value, m.value6), ctx))(m.value3)));
                          };
                          if (v3 instanceof Data_Ordering.LT) {
                              $tco_var_ctx = new Data_List_Types.Cons(new ThreeLeft(m.value1, m.value2, m.value3, m.value4, m.value5, m.value6), ctx);
                              $copy_m = m.value0;
                              return;
                          };
                          if (v3 instanceof Data_Ordering.GT && v instanceof Data_Ordering.LT) {
                              $tco_var_ctx = new Data_List_Types.Cons(new ThreeMiddle(m.value0, m.value1, m.value2, m.value4, m.value5, m.value6), ctx);
                              $copy_m = m.value3;
                              return;
                          };
                          $tco_var_ctx = new Data_List_Types.Cons(new ThreeRight(m.value0, m.value1, m.value2, m.value3, m.value4, m.value5), ctx);
                          $copy_m = m.value6;
                          return;
                      };
                      throw new Error("Failed pattern match at Data.Map.Internal (line 495, column 34 - line 518, column 80): " + [ m.constructor.name ]);
                  };
                  while (!$tco_done3) {
                      $tco_result = $tco_loop($tco_var_ctx, $copy_m);
                  };
                  return $tco_result;
              };
          };
          return down(Data_List_Types.Nil.value);
      };
  };
  var foldableMap = new Data_Foldable.Foldable(function (dictMonoid) {
      return function (f) {
          return function (m) {
              return Data_Foldable.foldMap(Data_List_Types.foldableList)(dictMonoid)(f)(values(m));
          };
      };
  }, function (f) {
      return function (z) {
          return function (m) {
              return Data_Foldable.foldl(Data_List_Types.foldableList)(f)(z)(values(m));
          };
      };
  }, function (f) {
      return function (z) {
          return function (m) {
              return Data_Foldable.foldr(Data_List_Types.foldableList)(f)(z)(values(m));
          };
      };
  });
  var traversableMap = new Data_Traversable.Traversable(function () {
      return foldableMap;
  }, function () {
      return functorMap;
  }, function (dictApplicative) {
      return Data_Traversable.traverse(traversableMap)(dictApplicative)(Control_Category.identity(Control_Category.categoryFn));
  }, function (dictApplicative) {
      return function (v) {
          return function (v1) {
              if (v1 instanceof Leaf) {
                  return Control_Applicative.pure(dictApplicative)(Leaf.value);
              };
              if (v1 instanceof Two) {
                  return Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(Two.create)(Data_Traversable.traverse(traversableMap)(dictApplicative)(v)(v1.value0)))(Control_Applicative.pure(dictApplicative)(v1.value1)))(v(v1.value2)))(Data_Traversable.traverse(traversableMap)(dictApplicative)(v)(v1.value3));
              };
              if (v1 instanceof Three) {
                  return Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(Three.create)(Data_Traversable.traverse(traversableMap)(dictApplicative)(v)(v1.value0)))(Control_Applicative.pure(dictApplicative)(v1.value1)))(v(v1.value2)))(Data_Traversable.traverse(traversableMap)(dictApplicative)(v)(v1.value3)))(Control_Applicative.pure(dictApplicative)(v1.value4)))(v(v1.value5)))(Data_Traversable.traverse(traversableMap)(dictApplicative)(v)(v1.value6));
              };
              throw new Error("Failed pattern match at Data.Map.Internal (line 127, column 1 - line 142, column 31): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
  });
  var eqMap = function (dictEq) {
      return function (dictEq1) {
          return new Data_Eq.Eq(function (m1) {
              return function (m2) {
                  return Data_Eq.eq(Data_Eq.eqArray(Data_Tuple.eqTuple(dictEq)(dictEq1)))(toAscArray(m1))(toAscArray(m2));
              };
          });
      };
  };
  var empty = Leaf.value;
  var fromFoldable = function (dictOrd) {
      return function (dictFoldable) {
          return Data_Foldable.foldl(dictFoldable)(function (m) {
              return function (v) {
                  return insert(dictOrd)(v.value0)(v.value1)(m);
              };
          })(empty);
      };
  };
  var filterWithKey = function (dictOrd) {
      return function (predicate) {
          var $764 = fromFoldable(dictOrd)(Data_List_Lazy_Types.foldableList);
          var $765 = Data_List_Lazy.filter(Data_Tuple.uncurry(predicate));
          var $766 = toUnfoldable(Data_List_Lazy_Types.unfoldableList);
          return function ($767) {
              return $764($765($766($767)));
          };
      };
  };
  var filter = function (dictOrd) {
      return function (predicate) {
          return filterWithKey(dictOrd)(Data_Function["const"](predicate));
      };
  };
  var $$delete = function (dictOrd) {
      return function (k) {
          return function (m) {
              return Data_Maybe.maybe(m)(Data_Tuple.snd)(pop(dictOrd)(k)(m));
          };
      };
  };
  var asList = Control_Category.identity(Control_Category.categoryFn);
  var foldableWithIndexMap = new Data_FoldableWithIndex.FoldableWithIndex(function () {
      return foldableMap;
  }, function (dictMonoid) {
      return function (f) {
          return function (m) {
              return Data_Foldable.foldMap(Data_List_Types.foldableList)(dictMonoid)(Data_Tuple.uncurry(f))(asList(toUnfoldable(Data_List_Types.unfoldableList)(m)));
          };
      };
  }, function (f) {
      return function (z) {
          return function (m) {
              return Data_Foldable.foldl(Data_List_Types.foldableList)((function () {
                  var $769 = Data_Function.flip(f);
                  return function ($770) {
                      return Data_Tuple.uncurry($769($770));
                  };
              })())(z)(asList(toUnfoldable(Data_List_Types.unfoldableList)(m)));
          };
      };
  }, function (f) {
      return function (z) {
          return function (m) {
              return Data_Foldable.foldr(Data_List_Types.foldableList)(Data_Tuple.uncurry(f))(z)(asList(toUnfoldable(Data_List_Types.unfoldableList)(m)));
          };
      };
  });
  var mapMaybeWithKey = function (dictOrd) {
      return function (f) {
          return Data_FoldableWithIndex.foldrWithIndex(foldableWithIndexMap)(function (k) {
              return function (a) {
                  return function (acc) {
                      return Data_Maybe.maybe(acc)(function (b) {
                          return insert(dictOrd)(k)(b)(acc);
                      })(f(k)(a));
                  };
              };
          })(empty);
      };
  };
  var mapMaybe = function (dictOrd) {
      var $771 = mapMaybeWithKey(dictOrd);
      return function ($772) {
          return $771(Data_Function["const"]($772));
      };
  };
  var traversableWithIndexMap = new Data_TraversableWithIndex.TraversableWithIndex(function () {
      return foldableWithIndexMap;
  }, function () {
      return functorWithIndexMap;
  }, function () {
      return traversableMap;
  }, function (dictApplicative) {
      return function (v) {
          return function (v1) {
              if (v1 instanceof Leaf) {
                  return Control_Applicative.pure(dictApplicative)(Leaf.value);
              };
              if (v1 instanceof Two) {
                  return Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(Two.create)(Data_TraversableWithIndex.traverseWithIndex(traversableWithIndexMap)(dictApplicative)(v)(v1.value0)))(Control_Applicative.pure(dictApplicative)(v1.value1)))(v(v1.value1)(v1.value2)))(Data_TraversableWithIndex.traverseWithIndex(traversableWithIndexMap)(dictApplicative)(v)(v1.value3));
              };
              if (v1 instanceof Three) {
                  return Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(Three.create)(Data_TraversableWithIndex.traverseWithIndex(traversableWithIndexMap)(dictApplicative)(v)(v1.value0)))(Control_Applicative.pure(dictApplicative)(v1.value1)))(v(v1.value1)(v1.value2)))(Data_TraversableWithIndex.traverseWithIndex(traversableWithIndexMap)(dictApplicative)(v)(v1.value3)))(Control_Applicative.pure(dictApplicative)(v1.value4)))(v(v1.value4)(v1.value5)))(Data_TraversableWithIndex.traverseWithIndex(traversableWithIndexMap)(dictApplicative)(v)(v1.value6));
              };
              throw new Error("Failed pattern match at Data.Map.Internal (line 144, column 1 - line 158, column 40): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
  });
  var alter = function (dictOrd) {
      return function (f) {
          return function (k) {
              return function (m) {
                  var v = f(lookup(dictOrd)(k)(m));
                  if (v instanceof Data_Maybe.Nothing) {
                      return $$delete(dictOrd)(k)(m);
                  };
                  if (v instanceof Data_Maybe.Just) {
                      return insert(dictOrd)(k)(v.value0)(m);
                  };
                  throw new Error("Failed pattern match at Data.Map.Internal (line 563, column 15 - line 565, column 25): " + [ v.constructor.name ]);
              };
          };
      };
  };
  var fromFoldableWith = function (dictOrd) {
      return function (dictFoldable) {
          return function (f) {
              var combine = function (v) {
                  return function (v1) {
                      if (v1 instanceof Data_Maybe.Just) {
                          return Data_Maybe.Just.create(f(v)(v1.value0));
                      };
                      if (v1 instanceof Data_Maybe.Nothing) {
                          return new Data_Maybe.Just(v);
                      };
                      throw new Error("Failed pattern match at Data.Map.Internal (line 580, column 3 - line 580, column 38): " + [ v.constructor.name, v1.constructor.name ]);
                  };
              };
              return Data_Foldable.foldl(dictFoldable)(function (m) {
                  return function (v) {
                      return alter(dictOrd)(combine(v.value1))(v.value0)(m);
                  };
              })(empty);
          };
      };
  };
  var unionWith = function (dictOrd) {
      return function (f) {
          return function (m1) {
              return function (m2) {
                  var go = function (m) {
                      return function (v) {
                          return alter(dictOrd)((function () {
                              var $777 = Data_Maybe.maybe(v.value1)(f(v.value1));
                              return function ($778) {
                                  return Data_Maybe.Just.create($777($778));
                              };
                          })())(v.value0)(m);
                      };
                  };
                  return Data_Foldable.foldl(Data_List_Types.foldableList)(go)(m2)(toUnfoldable(Data_List_Types.unfoldableList)(m1));
              };
          };
      };
  };
  var union = function (dictOrd) {
      return unionWith(dictOrd)(Data_Function["const"]);
  };
  var unions = function (dictOrd) {
      return function (dictFoldable) {
          return Data_Foldable.foldl(dictFoldable)(union(dictOrd))(empty);
      };
  };
  var update = function (dictOrd) {
      return function (f) {
          return function (k) {
              return function (m) {
                  return alter(dictOrd)(Data_Maybe.maybe(Data_Maybe.Nothing.value)(f))(k)(m);
              };
          };
      };
  };
  exports["empty"] = empty;
  exports["isEmpty"] = isEmpty;
  exports["singleton"] = singleton;
  exports["insert"] = insert;
  exports["lookup"] = lookup;
  exports["fromFoldable"] = fromFoldable;
  exports["fromFoldableWith"] = fromFoldableWith;
  exports["toUnfoldable"] = toUnfoldable;
  exports["delete"] = $$delete;
  exports["member"] = member;
  exports["alter"] = alter;
  exports["update"] = update;
  exports["keys"] = keys;
  exports["values"] = values;
  exports["union"] = union;
  exports["unionWith"] = unionWith;
  exports["unions"] = unions;
  exports["filter"] = filter;
  exports["mapMaybe"] = mapMaybe;
  exports["eqMap"] = eqMap;
  exports["functorMap"] = functorMap;
  exports["functorWithIndexMap"] = functorWithIndexMap;
  exports["traversableWithIndexMap"] = traversableWithIndexMap;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Index"] = $PS["Data.Lens.Index"] || {};
  var exports = $PS["Data.Lens.Index"];
  var Data_Either = $PS["Data.Either"];
  var Data_Lens_AffineTraversal = $PS["Data.Lens.AffineTraversal"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];                        
  var Index = function (ix) {
      this.ix = ix;
  };
  var ix = function (dict) {
      return dict.ix;
  }; 
  var indexMap = function (dictOrd) {
      return new Index(function (k) {
          return function (dictStrong) {
              return function (dictChoice) {
                  var set = function (s) {
                      return function (b) {
                          return Data_Map_Internal.update(dictOrd)(function (v) {
                              return new Data_Maybe.Just(b);
                          })(k)(s);
                      };
                  };
                  var pre = function (s) {
                      return Data_Maybe.maybe(new Data_Either.Left(s))(Data_Either.Right.create)(Data_Map_Internal.lookup(dictOrd)(k)(s));
                  };
                  return Data_Lens_AffineTraversal.affineTraversal(set)(pre)(dictStrong)(dictChoice);
              };
          };
      });
  };
  exports["Index"] = Index;
  exports["ix"] = ix;
  exports["indexMap"] = indexMap;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Internal.Shop"] = $PS["Data.Lens.Internal.Shop"] || {};
  var exports = $PS["Data.Lens.Internal.Shop"];
  var Data_Profunctor = $PS["Data.Profunctor"];
  var Data_Profunctor_Strong = $PS["Data.Profunctor.Strong"];
  var Data_Tuple = $PS["Data.Tuple"];                
  var Shop = (function () {
      function Shop(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Shop.create = function (value0) {
          return function (value1) {
              return new Shop(value0, value1);
          };
      };
      return Shop;
  })();
  var profunctorShop = new Data_Profunctor.Profunctor(function (f) {
      return function (g) {
          return function (v) {
              return new Shop(function ($30) {
                  return v.value0(f($30));
              }, function (s) {
                  var $31 = v.value1(f(s));
                  return function ($32) {
                      return g($31($32));
                  };
              });
          };
      };
  });
  var strongShop = new Data_Profunctor_Strong.Strong(function () {
      return profunctorShop;
  }, function (v) {
      return new Shop(function (v1) {
          return v.value0(v1.value0);
      }, function (v1) {
          return function (b) {
              return new Data_Tuple.Tuple(v.value1(v1.value0)(b), v1.value1);
          };
      });
  }, function (v) {
      return new Shop(function (v1) {
          return v.value0(v1.value1);
      }, function (v1) {
          return function (b) {
              return new Data_Tuple.Tuple(v1.value0, v.value1(v1.value1)(b));
          };
      });
  });
  exports["Shop"] = Shop;
  exports["strongShop"] = strongShop;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Lens"] = $PS["Data.Lens.Lens"] || {};
  var exports = $PS["Data.Lens.Lens"];
  var Control_Category = $PS["Control.Category"];
  var Data_Lens_Internal_Shop = $PS["Data.Lens.Internal.Shop"];
  var Data_Profunctor = $PS["Data.Profunctor"];
  var Data_Profunctor_Strong = $PS["Data.Profunctor.Strong"];
  var Data_Tuple = $PS["Data.Tuple"];                
  var withLens = function (l) {
      return function (f) {
          var v = l(new Data_Lens_Internal_Shop.Shop(Control_Category.identity(Control_Category.categoryFn), function (v1) {
              return function (b) {
                  return b;
              };
          }));
          return f(v.value0)(v.value1);
      };
  };
  var lens$prime = function (to) {
      return function (dictStrong) {
          return function (pab) {
              return Data_Profunctor.dimap(dictStrong.Profunctor0())(to)(function (v) {
                  return v.value1(v.value0);
              })(Data_Profunctor_Strong.first(dictStrong)(pab));
          };
      };
  };
  var lens = function (get) {
      return function (set) {
          return function (dictStrong) {
              return lens$prime(function (s) {
                  return new Data_Tuple.Tuple(get(s), function (b) {
                      return set(s)(b);
                  });
              })(dictStrong);
          };
      };
  };
  var cloneLens = function (l) {
      return function (dictStrong) {
          return withLens(l)(function (x) {
              return function (y) {
                  return function (p) {
                      return lens(x)(y)(dictStrong)(p);
                  };
              };
          });
      };
  };
  exports["lens"] = lens;
  exports["cloneLens"] = cloneLens;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.At"] = $PS["Data.Lens.At"] || {};
  var exports = $PS["Data.Lens.At"];
  var Data_Lens_Index = $PS["Data.Lens.Index"];
  var Data_Lens_Lens = $PS["Data.Lens.Lens"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];                        
  var At = function (Index0, at) {
      this.Index0 = Index0;
      this.at = at;
  }; 
  var atMap = function (dictOrd) {
      return new At(function () {
          return Data_Lens_Index.indexMap(dictOrd);
      }, function (k) {
          return function (dictStrong) {
              return Data_Lens_Lens.lens(Data_Map_Internal.lookup(dictOrd)(k))(function (m) {
                  return Data_Maybe["maybe'"](function (v) {
                      return Data_Map_Internal["delete"](dictOrd)(k)(m);
                  })(function (v) {
                      return Data_Map_Internal.insert(dictOrd)(k)(v)(m);
                  });
              })(dictStrong);
          };
      });
  }; 
  var at = function (dict) {
      return dict.at;
  };
  exports["At"] = At;
  exports["at"] = at;
  exports["atMap"] = atMap;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Internal.Forget"] = $PS["Data.Lens.Internal.Forget"] || {};
  var exports = $PS["Data.Lens.Internal.Forget"];
  var Data_Either = $PS["Data.Either"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Profunctor = $PS["Data.Profunctor"];
  var Data_Profunctor_Choice = $PS["Data.Profunctor.Choice"];
  var Data_Profunctor_Strong = $PS["Data.Profunctor.Strong"];
  var Data_Tuple = $PS["Data.Tuple"];                
  var Forget = function (x) {
      return x;
  };
  var profunctorForget = new Data_Profunctor.Profunctor(function (f) {
      return function (v) {
          return function (v1) {
              return function ($24) {
                  return v1(f($24));
              };
          };
      };
  });
  var strongForget = new Data_Profunctor_Strong.Strong(function () {
      return profunctorForget;
  }, function (v) {
      return function ($25) {
          return v(Data_Tuple.fst($25));
      };
  }, function (v) {
      return function ($26) {
          return v(Data_Tuple.snd($26));
      };
  });
  var choiceForget = function (dictMonoid) {
      return new Data_Profunctor_Choice.Choice(function () {
          return profunctorForget;
      }, function (v) {
          return Data_Either.either(v)(Data_Monoid.mempty(Data_Monoid.monoidFn(dictMonoid)));
      }, function (v) {
          return Data_Either.either(Data_Monoid.mempty(Data_Monoid.monoidFn(dictMonoid)))(v);
      });
  };
  exports["Forget"] = Forget;
  exports["profunctorForget"] = profunctorForget;
  exports["choiceForget"] = choiceForget;
  exports["strongForget"] = strongForget;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Maybe.First"] = $PS["Data.Maybe.First"] || {};
  var exports = $PS["Data.Maybe.First"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];      
  var First = function (x) {
      return x;
  };
  var semigroupFirst = new Data_Semigroup.Semigroup(function (v) {
      return function (v1) {
          if (v instanceof Data_Maybe.Just) {
              return v;
          };
          return v1;
      };
  });
  var monoidFirst = new Data_Monoid.Monoid(function () {
      return semigroupFirst;
  }, Data_Maybe.Nothing.value);
  exports["First"] = First;
  exports["monoidFirst"] = monoidFirst;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Fold"] = $PS["Data.Lens.Fold"] || {};
  var exports = $PS["Data.Lens.Fold"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Lens_Internal_Forget = $PS["Data.Lens.Internal.Forget"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Maybe_First = $PS["Data.Maybe.First"];
  var Data_Monoid_Endo = $PS["Data.Monoid.Endo"];
  var Data_Newtype = $PS["Data.Newtype"];
  var Data_Unit = $PS["Data.Unit"];
  var folded = function (dictMonoid) {
      return function (dictFoldable) {
          return function (v) {
              return Data_Foldable.foldMap(dictFoldable)(dictMonoid)(v);
          };
      };
  };
  var foldMapOf = Data_Newtype.under()()(Data_Lens_Internal_Forget.Forget);
  var foldrOf = function (p) {
      return function (f) {
          return function (r) {
              var $75 = Data_Function.flip(Data_Newtype.unwrap())(r);
              var $76 = foldMapOf(p)(function ($78) {
                  return Data_Monoid_Endo.Endo(f($78));
              });
              return function ($77) {
                  return $75($76($77));
              };
          };
      };
  };
  var toListOf = function (p) {
      return foldrOf(p)(Data_List_Types.Cons.create)(Data_List_Types.Nil.value);
  };
  var toListOfOn = function (s) {
      return function (p) {
          return toListOf(p)(s);
      };
  };
  var traverseOf_ = function (dictApplicative) {
      return function (p) {
          return function (f) {
              return foldrOf(p)(function (a) {
                  return function (fu) {
                      return Control_Apply.applySecond(dictApplicative.Apply0())(Data_Functor["void"]((dictApplicative.Apply0()).Functor0())(f(a)))(fu);
                  };
              })(Control_Applicative.pure(dictApplicative)(Data_Unit.unit));
          };
      };
  };
  var preview = function (p) {
      var $99 = Data_Newtype.unwrap();
      var $100 = foldMapOf(p)(function ($102) {
          return Data_Maybe_First.First(Data_Maybe.Just.create($102));
      });
      return function ($101) {
          return $99($100($101));
      };
  };
  var previewOn = function (s) {
      return function (p) {
          return preview(p)(s);
      };
  };
  exports["previewOn"] = previewOn;
  exports["toListOfOn"] = toListOfOn;
  exports["traverseOf_"] = traverseOf_;
  exports["folded"] = folded;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Getter"] = $PS["Data.Lens.Getter"] || {};
  var exports = $PS["Data.Lens.Getter"];
  var Control_Category = $PS["Control.Category"];
  var Control_Monad_State_Class = $PS["Control.Monad.State.Class"];
  var Data_Newtype = $PS["Data.Newtype"];                                    
  var view = function (l) {
      return Data_Newtype.unwrap()(l(Control_Category.identity(Control_Category.categoryFn)));
  };
  var viewOn = function (s) {
      return function (l) {
          return view(l)(s);
      };
  };
  var use = function (dictMonadState) {
      return function (p) {
          return Control_Monad_State_Class.gets(dictMonadState)(function (v) {
              return viewOn(v)(p);
          });
      };
  };
  var to = function (f) {
      return function (p) {
          var $3 = Data_Newtype.unwrap()(p);
          return function ($4) {
              return $3(f($4));
          };
      };
  };
  exports["viewOn"] = viewOn;
  exports["view"] = view;
  exports["to"] = to;
  exports["use"] = use;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Iso"] = $PS["Data.Lens.Iso"] || {};
  var exports = $PS["Data.Lens.Iso"];
  var Data_Profunctor = $PS["Data.Profunctor"];
  var iso = function (f) {
      return function (g) {
          return function (dictProfunctor) {
              return function (pab) {
                  return Data_Profunctor.dimap(dictProfunctor)(f)(g)(pab);
              };
          };
      };
  };
  exports["iso"] = iso;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Iso.Newtype"] = $PS["Data.Lens.Iso.Newtype"] || {};
  var exports = $PS["Data.Lens.Iso.Newtype"];
  var Data_Lens_Iso = $PS["Data.Lens.Iso"];
  var Data_Newtype = $PS["Data.Newtype"];                
  var _Newtype = function (dictNewtype) {
      return function (dictNewtype1) {
          return function (dictProfunctor) {
              return Data_Lens_Iso.iso(Data_Newtype.unwrap())(Data_Newtype.wrap())(dictProfunctor);
          };
      };
  };
  exports["_Newtype"] = _Newtype;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Prism"] = $PS["Data.Lens.Prism"] || {};
  var exports = $PS["Data.Lens.Prism"];
  var Control_Category = $PS["Control.Category"];
  var Data_Either = $PS["Data.Either"];
  var Data_Profunctor = $PS["Data.Profunctor"];
  var Data_Profunctor_Choice = $PS["Data.Profunctor.Choice"];           
  var prism = function (to) {
      return function (fro) {
          return function (dictChoice) {
              return function (pab) {
                  return Data_Profunctor.dimap(dictChoice.Profunctor0())(fro)(Data_Either.either(Control_Category.identity(Control_Category.categoryFn))(Control_Category.identity(Control_Category.categoryFn)))(Data_Profunctor_Choice.right(dictChoice)(Data_Profunctor.rmap(dictChoice.Profunctor0())(to)(pab)));
              };
          };
      };
  };
  exports["prism"] = prism;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Prism.Maybe"] = $PS["Data.Lens.Prism.Maybe"] || {};
  var exports = $PS["Data.Lens.Prism.Maybe"];
  var Data_Either = $PS["Data.Either"];
  var Data_Lens_Prism = $PS["Data.Lens.Prism"];
  var Data_Maybe = $PS["Data.Maybe"];
  var _Just = function (dictChoice) {
      return Data_Lens_Prism.prism(Data_Maybe.Just.create)(Data_Maybe.maybe(new Data_Either.Left(Data_Maybe.Nothing.value))(Data_Either.Right.create))(dictChoice);
  };
  exports["_Just"] = _Just;
})(PS);
(function(exports) {
  "use strict";

  exports.unsafeUnionFn = function(r1, r2) {
    var copy = {};
    for (var k1 in r2) {
      if ({}.hasOwnProperty.call(r2, k1)) {
        copy[k1] = r2[k1];
      }
    }
    for (var k2 in r1) {
      if ({}.hasOwnProperty.call(r1, k2)) {
        copy[k2] = r1[k2];
      }
    }
    return copy;
  };
})(PS["Record.Unsafe.Union"] = PS["Record.Unsafe.Union"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Record.Unsafe.Union"] = $PS["Record.Unsafe.Union"] || {};
  var exports = $PS["Record.Unsafe.Union"];
  var $foreign = $PS["Record.Unsafe.Union"];
  exports["unsafeUnionFn"] = $foreign.unsafeUnionFn;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Record"] = $PS["Record"] || {};
  var exports = $PS["Record"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Record_Unsafe = $PS["Record.Unsafe"];
  var Record_Unsafe_Union = $PS["Record.Unsafe.Union"];
  var set = function (dictIsSymbol) {
      return function (dictCons) {
          return function (dictCons1) {
              return function (l) {
                  return function (b) {
                      return function (r) {
                          return Record_Unsafe.unsafeSet(Data_Symbol.reflectSymbol(dictIsSymbol)(l))(b)(r);
                      };
                  };
              };
          };
      };
  };
  var merge = function (dictUnion) {
      return function (dictNub) {
          return function (l) {
              return function (r) {
                  return Record_Unsafe_Union.unsafeUnionFn(l, r);
              };
          };
      };
  };
  var insert = function (dictIsSymbol) {
      return function (dictLacks) {
          return function (dictCons) {
              return function (l) {
                  return function (a) {
                      return function (r) {
                          return Record_Unsafe.unsafeSet(Data_Symbol.reflectSymbol(dictIsSymbol)(l))(a)(r);
                      };
                  };
              };
          };
      };
  };
  var get = function (dictIsSymbol) {
      return function (dictCons) {
          return function (l) {
              return function (r) {
                  return Record_Unsafe.unsafeGet(Data_Symbol.reflectSymbol(dictIsSymbol)(l))(r);
              };
          };
      };
  };
  var $$delete = function (dictIsSymbol) {
      return function (dictLacks) {
          return function (dictCons) {
              return function (l) {
                  return function (r) {
                      return Record_Unsafe.unsafeDelete(Data_Symbol.reflectSymbol(dictIsSymbol)(l))(r);
                  };
              };
          };
      };
  };
  var rename = function (dictIsSymbol) {
      return function (dictIsSymbol1) {
          return function (dictCons) {
              return function (dictLacks) {
                  return function (dictCons1) {
                      return function (dictLacks1) {
                          return function (prev) {
                              return function (next) {
                                  return function (record) {
                                      return insert(dictIsSymbol1)()()(next)(get(dictIsSymbol)()(prev)(record))($$delete(dictIsSymbol)()()(prev)(record));
                                  };
                              };
                          };
                      };
                  };
              };
          };
      };
  };
  exports["get"] = get;
  exports["set"] = set;
  exports["delete"] = $$delete;
  exports["rename"] = rename;
  exports["merge"] = merge;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Record"] = $PS["Data.Lens.Record"] || {};
  var exports = $PS["Data.Lens.Record"];
  var Data_Function = $PS["Data.Function"];
  var Data_Lens_Lens = $PS["Data.Lens.Lens"];
  var Record = $PS["Record"];                
  var prop = function (dictIsSymbol) {
      return function (dictCons) {
          return function (dictCons1) {
              return function (l) {
                  return function (dictStrong) {
                      return Data_Lens_Lens.lens(Record.get(dictIsSymbol)()(l))(Data_Function.flip(Record.set(dictIsSymbol)()()(l)))(dictStrong);
                  };
              };
          };
      };
  };
  exports["prop"] = prop;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Lens.Setter"] = $PS["Data.Lens.Setter"] || {};
  var exports = $PS["Data.Lens.Setter"];
  var Control_Monad_State_Class = $PS["Control.Monad.State.Class"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];                
  var over = function (l) {
      return l;
  };
  var set = function (l) {
      return function (b) {
          return over(l)(Data_Function["const"](b));
      };
  };
  var modifying = function (dictMonadState) {
      return function (p) {
          return function (f) {
              return Data_Functor["void"]((((dictMonadState.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_State_Class.modify(dictMonadState)(over(p)(f)));
          };
      };
  };
  var assign = function (dictMonadState) {
      return function (p) {
          return function (b) {
              return Data_Functor["void"]((((dictMonadState.Monad0()).Bind1()).Apply0()).Functor0())(Control_Monad_State_Class.modify(dictMonadState)(set(p)(b)));
          };
      };
  };
  var assignJust = function (dictMonadState) {
      return function (p) {
          var $56 = assign(dictMonadState)(p);
          return function ($57) {
              return $56(Data_Maybe.Just.create($57));
          };
      };
  };
  exports["over"] = over;
  exports["set"] = set;
  exports["modifying"] = modifying;
  exports["assignJust"] = assignJust;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Set"] = $PS["Data.Set"] || {};
  var exports = $PS["Data.Set"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Unit = $PS["Data.Unit"];                
  var $$Set = function (x) {
      return x;
  };
  var union = function (dictOrd) {
      return function (v) {
          return function (v1) {
              return Data_Map_Internal.union(dictOrd)(v)(v1);
          };
      };
  };
  var toList = function (v) {
      return Data_Map_Internal.keys(v);
  };
  var toUnfoldable = function (dictUnfoldable) {
      var $66 = Data_List.toUnfoldable(dictUnfoldable);
      return function ($67) {
          return $66(toList($67));
      };
  };
  var singleton = function (a) {
      return Data_Map_Internal.singleton(a)(Data_Unit.unit);
  };
  var semigroupSet = function (dictOrd) {
      return new Data_Semigroup.Semigroup(union(dictOrd));
  };
  var member = function (dictOrd) {
      return function (a) {
          return function (v) {
              return Data_Map_Internal.member(dictOrd)(a)(v);
          };
      };
  };
  var isEmpty = function (v) {
      return Data_Map_Internal.isEmpty(v);
  };
  var insert = function (dictOrd) {
      return function (a) {
          return function (v) {
              return Data_Map_Internal.insert(dictOrd)(a)(Data_Unit.unit)(v);
          };
      };
  };
  var fromMap = $$Set;
  var foldableSet = new Data_Foldable.Foldable(function (dictMonoid) {
      return function (f) {
          var $68 = Data_Foldable.foldMap(Data_List_Types.foldableList)(dictMonoid)(f);
          return function ($69) {
              return $68(toList($69));
          };
      };
  }, function (f) {
      return function (x) {
          var $70 = Data_Foldable.foldl(Data_List_Types.foldableList)(f)(x);
          return function ($71) {
              return $70(toList($71));
          };
      };
  }, function (f) {
      return function (x) {
          var $72 = Data_Foldable.foldr(Data_List_Types.foldableList)(f)(x);
          return function ($73) {
              return $72(toList($73));
          };
      };
  });
  var eqSet = function (dictEq) {
      return new Data_Eq.Eq(function (v) {
          return function (v1) {
              return Data_Eq.eq(Data_Map_Internal.eqMap(dictEq)(Data_Eq.eqUnit))(v)(v1);
          };
      });
  }; 
  var empty = Data_Map_Internal.empty;
  var fromFoldable = function (dictFoldable) {
      return function (dictOrd) {
          return Data_Foldable.foldl(dictFoldable)(function (m) {
              return function (a) {
                  return insert(dictOrd)(a)(m);
              };
          })(empty);
      };
  };
  var monoidSet = function (dictOrd) {
      return new Data_Monoid.Monoid(function () {
          return semigroupSet(dictOrd);
      }, empty);
  };
  var unions = function (dictFoldable) {
      return function (dictOrd) {
          return Data_Foldable.foldl(dictFoldable)(union(dictOrd))(empty);
      };
  };
  var $$delete = function (dictOrd) {
      return function (a) {
          return function (v) {
              return Data_Map_Internal["delete"](dictOrd)(a)(v);
          };
      };
  };
  var difference = function (dictOrd) {
      return function (s1) {
          return function (s2) {
              return Data_Foldable.foldl(Data_List_Types.foldableList)(Data_Function.flip($$delete(dictOrd)))(s1)(toList(s2));
          };
      };
  };
  exports["fromFoldable"] = fromFoldable;
  exports["toUnfoldable"] = toUnfoldable;
  exports["empty"] = empty;
  exports["isEmpty"] = isEmpty;
  exports["singleton"] = singleton;
  exports["insert"] = insert;
  exports["member"] = member;
  exports["delete"] = $$delete;
  exports["union"] = union;
  exports["unions"] = unions;
  exports["difference"] = difference;
  exports["fromMap"] = fromMap;
  exports["eqSet"] = eqSet;
  exports["monoidSet"] = monoidSet;
  exports["semigroupSet"] = semigroupSet;
  exports["foldableSet"] = foldableSet;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Map"] = $PS["Data.Map"] || {};
  var exports = $PS["Data.Map"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Set = $PS["Data.Set"];                
  var SemigroupMap = function (x) {
      return x;
  };
  var semigroupSemigroupMap = function (dictOrd) {
      return function (dictSemigroup) {
          return new Data_Semigroup.Semigroup(function (v) {
              return function (v1) {
                  return Data_Map_Internal.unionWith(dictOrd)(Data_Semigroup.append(dictSemigroup))(v)(v1);
              };
          });
      };
  }; 
  var monoidSemigroupMap = function (dictOrd) {
      return function (dictSemigroup) {
          return new Data_Monoid.Monoid(function () {
              return semigroupSemigroupMap(dictOrd)(dictSemigroup);
          }, Data_Map_Internal.empty);
      };
  };
  var keys = (function () {
      var $20 = Data_Functor["void"](Data_Map_Internal.functorMap);
      return function ($21) {
          return Data_Set.fromMap($20($21));
      };
  })();
  exports["keys"] = keys;
  exports["SemigroupMap"] = SemigroupMap;
  exports["monoidSemigroupMap"] = monoidSemigroupMap;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Monoid.Additive"] = $PS["Data.Monoid.Additive"] || {};
  var exports = $PS["Data.Monoid.Additive"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Semiring = $PS["Data.Semiring"];        
  var Additive = function (x) {
      return x;
  };
  var semigroupAdditive = function (dictSemiring) {
      return new Data_Semigroup.Semigroup(function (v) {
          return function (v1) {
              return Data_Semiring.add(dictSemiring)(v)(v1);
          };
      });
  };
  var monoidAdditive = function (dictSemiring) {
      return new Data_Monoid.Monoid(function () {
          return semigroupAdditive(dictSemiring);
      }, Data_Semiring.zero(dictSemiring));
  }; 
  var eqAdditive = function (dictEq) {
      return dictEq;
  };
  exports["Additive"] = Additive;
  exports["eqAdditive"] = eqAdditive;
  exports["semigroupAdditive"] = semigroupAdditive;
  exports["monoidAdditive"] = monoidAdditive;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Ord.Down"] = $PS["Data.Ord.Down"] || {};
  var exports = $PS["Data.Ord.Down"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ordering = $PS["Data.Ordering"];        
  var Down = function (x) {
      return x;
  }; 
  var eqDown = function (dictEq) {
      return dictEq;
  };
  var ordDown = function (dictOrd) {
      return new Data_Ord.Ord(function () {
          return eqDown(dictOrd.Eq0());
      }, function (v) {
          return function (v1) {
              return Data_Ordering.invert(Data_Ord.compare(dictOrd)(v)(v1));
          };
      });
  };
  exports["Down"] = Down;
  exports["ordDown"] = ordDown;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Ord.Generic"] = $PS["Data.Ord.Generic"] || {};
  var exports = $PS["Data.Ord.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ordering = $PS["Data.Ordering"];                
  var GenericOrd = function (genericCompare$prime) {
      this["genericCompare'"] = genericCompare$prime;
  }; 
  var genericOrdNoArguments = new GenericOrd(function (v) {
      return function (v1) {
          return Data_Ordering.EQ.value;
      };
  });
  var genericOrdArgument = function (dictOrd) {
      return new GenericOrd(function (v) {
          return function (v1) {
              return Data_Ord.compare(dictOrd)(v)(v1);
          };
      });
  };
  var genericCompare$prime = function (dict) {
      return dict["genericCompare'"];
  };
  var genericOrdConstructor = function (dictGenericOrd) {
      return new GenericOrd(function (v) {
          return function (v1) {
              return genericCompare$prime(dictGenericOrd)(v)(v1);
          };
      });
  };
  var genericOrdSum = function (dictGenericOrd) {
      return function (dictGenericOrd1) {
          return new GenericOrd(function (v) {
              return function (v1) {
                  if (v instanceof Data_Generic_Rep.Inl && v1 instanceof Data_Generic_Rep.Inl) {
                      return genericCompare$prime(dictGenericOrd)(v.value0)(v1.value0);
                  };
                  if (v instanceof Data_Generic_Rep.Inr && v1 instanceof Data_Generic_Rep.Inr) {
                      return genericCompare$prime(dictGenericOrd1)(v.value0)(v1.value0);
                  };
                  if (v instanceof Data_Generic_Rep.Inl && v1 instanceof Data_Generic_Rep.Inr) {
                      return Data_Ordering.LT.value;
                  };
                  if (v instanceof Data_Generic_Rep.Inr && v1 instanceof Data_Generic_Rep.Inl) {
                      return Data_Ordering.GT.value;
                  };
                  throw new Error("Failed pattern match at Data.Ord.Generic (line 19, column 1 - line 23, column 39): " + [ v.constructor.name, v1.constructor.name ]);
              };
          });
      };
  };
  var genericCompare = function (dictGeneric) {
      return function (dictGenericOrd) {
          return function (x) {
              return function (y) {
                  return genericCompare$prime(dictGenericOrd)(Data_Generic_Rep.from(dictGeneric)(x))(Data_Generic_Rep.from(dictGeneric)(y));
              };
          };
      };
  };
  exports["genericCompare"] = genericCompare;
  exports["genericOrdNoArguments"] = genericOrdNoArguments;
  exports["genericOrdSum"] = genericOrdSum;
  exports["genericOrdConstructor"] = genericOrdConstructor;
  exports["genericOrdArgument"] = genericOrdArgument;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Semiring.Free"] = $PS["Data.Semiring.Free"] || {};
  var exports = $PS["Data.Semiring.Free"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Semiring = $PS["Data.Semiring"];
  var semiringFree = new Data_Semiring.Semiring(function (v) {
      return function (v1) {
          return Data_Semigroup.append(Data_List_Types.semigroupList)(v)(v1);
      };
  }, function (v) {
      return function (v1) {
          return Control_Bind.bind(Data_List_Types.bindList)(v)(function (xs) {
              return Control_Bind.bind(Data_List_Types.bindList)(v1)(function (ys) {
                  return Control_Applicative.pure(Data_List_Types.applicativeList)(Data_Semigroup.append(Data_List_Types.semigroupList)(xs)(ys));
              });
          });
      };
  }, Data_List.singleton(Data_List_Types.Nil.value), Data_List_Types.Nil.value);
  var free = function (a) {
      return Data_List.singleton(Data_List.singleton(a));
  };
  exports["free"] = free;
  exports["semiringFree"] = semiringFree;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Sequence"] = $PS["Data.Sequence"] || {};
  var exports = $PS["Data.Sequence"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_FingerTree = $PS["Data.FingerTree"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Lazy = $PS["Data.Lazy"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Monoid_Additive = $PS["Data.Monoid.Additive"];
  var Data_Newtype = $PS["Data.Newtype"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Semiring = $PS["Data.Semiring"];
  var Data_Sequence_Internal = $PS["Data.Sequence.Internal"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Data_Unfoldable1 = $PS["Data.Unfoldable1"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];
  var toUnfoldable = function (dictFunctor) {
      return function (dictUnfoldable) {
          return function (v) {
              return Data_Sequence_Internal.mapGetElem(dictFunctor)(Data_FingerTree.unfoldLeft(dictUnfoldable)(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt))(Data_Sequence_Internal.measuredElem)(v));
          };
      };
  };
  var splitAt$prime = function (i) {
      return function (v) {
          var tuple = Data_FingerTree.split(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt))(Data_Sequence_Internal.measuredElem)()(function (n) {
              return i < Data_Newtype.unwrap()(n);
          })(v);
          var seqify = function (dictFunctor) {
              return Unsafe_Coerce.unsafeCoerce;
          };
          return seqify(Data_Lazy.functorLazy)(tuple);
      };
  };
  var take = function (i) {
      var $119 = splitAt$prime(i);
      return function ($120) {
          return Data_Lazy.force(Data_Tuple.fst($119($120)));
      };
  };
  var snoc = function (v) {
      return function (x) {
          return Data_FingerTree.snoc(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt))(Data_Sequence_Internal.measuredElem)(v)(x);
      };
  };
  var $$null = function (v) {
      if (v instanceof Data_FingerTree.Empty) {
          return true;
      };
      return false;
  };
  var map = function (f) {
      return function (v) {
          return Data_Functor.map(Data_FingerTree.functorFingerTree)(f)(v);
      };
  };
  var length = function (v) {
      return Data_Newtype.un()(Data_Monoid_Additive.Additive)(Data_Sequence_Internal.measure(Data_FingerTree.measuredFingerTree(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt))(Data_Sequence_Internal.measuredElem))(v));
  };
  var head = function (v) {
      return Data_Sequence_Internal.mapGetElem(Data_Maybe.functorMaybe)(Data_FingerTree.head(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt))(Data_Sequence_Internal.measuredElem)(v));
  };
  var functorSeq = new Data_Functor.Functor(map);
  var foldableSeq = new Data_Foldable.Foldable(function (dictMonoid) {
      return function (f) {
          return function (v) {
              return Data_Foldable.foldMap(Data_FingerTree.foldableFingerTree)(dictMonoid)(Data_Sequence_Internal.liftElem(f))(v);
          };
      };
  }, function (f) {
      return function (z) {
          return function (v) {
              return Data_Foldable.foldl(Data_FingerTree.foldableFingerTree)(Data_Sequence_Internal.lift2Elem(f))(z)(v);
          };
      };
  }, function (f) {
      return function (z) {
          return function (v) {
              return Data_Foldable.foldr(Data_FingerTree.foldableFingerTree)(Data_Sequence_Internal.liftElem(f))(z)(v);
          };
      };
  });
  var filter = function (p) {
      return function (v) {
          return Data_FingerTree.filter(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt))(Data_Sequence_Internal.measuredElem)(p)(v);
      };
  };
  var eqSeq = function (dictEq) {
      return new Data_Eq.Eq(function (v) {
          return function (v1) {
              return Data_FingerTree.eqFingerTree(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt))(Data_Sequence_Internal.measuredElem)(Data_Sequence_Internal.eqElem(dictEq))(v)(v1);
          };
      });
  };
  var empty = Data_FingerTree.Empty.value;
  var unfoldable1Seq = new Data_Unfoldable1.Unfoldable1(function (f) {
      return function (xs) {
          var go = function ($copy_source) {
              return function ($copy_memo) {
                  var $tco_var_source = $copy_source;
                  var $tco_done = false;
                  var $tco_result;
                  function $tco_loop(source, memo) {
                      var v = f(source);
                      if (v.value1 instanceof Data_Maybe.Nothing) {
                          $tco_done = true;
                          return snoc(memo)(v.value0);
                      };
                      if (v.value1 instanceof Data_Maybe.Just) {
                          $tco_var_source = v.value1.value0;
                          $copy_memo = snoc(memo)(v.value0);
                          return;
                      };
                      throw new Error("Failed pattern match at Data.Sequence (line 128, column 9 - line 133, column 32): " + [ v.constructor.name ]);
                  };
                  while (!$tco_done) {
                      $tco_result = $tco_loop($tco_var_source, $copy_memo);
                  };
                  return $tco_result;
              };
          };
          return go(xs)(empty);
      };
  });
  var unfoldableSeq = new Data_Unfoldable.Unfoldable(function () {
      return unfoldable1Seq;
  }, function (f) {
      return function (xs) {
          var go = function ($copy_source) {
              return function ($copy_memo) {
                  var $tco_var_source = $copy_source;
                  var $tco_done = false;
                  var $tco_result;
                  function $tco_loop(source, memo) {
                      var v = f(source);
                      if (v instanceof Data_Maybe.Nothing) {
                          $tco_done = true;
                          return memo;
                      };
                      if (v instanceof Data_Maybe.Just) {
                          $tco_var_source = v.value0.value1;
                          $copy_memo = snoc(memo)(v.value0.value0);
                          return;
                      };
                      throw new Error("Failed pattern match at Data.Sequence (line 139, column 7 - line 144, column 30): " + [ v.constructor.name ]);
                  };
                  while (!$tco_done) {
                      $tco_result = $tco_loop($tco_var_source, $copy_memo);
                  };
                  return $tco_result;
              };
          };
          return go(xs)(empty);
      };
  });
  var drop = function (i) {
      var $121 = splitAt$prime(i);
      return function ($122) {
          return Data_Lazy.force(Data_Tuple.snd($121($122)));
      };
  };
  var cons = function (x) {
      return function (v) {
          return Data_FingerTree.cons(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt))(Data_Sequence_Internal.measuredElem)(x)(v);
      };
  };
  var fromFoldable = function (dictFoldable) {
      return Data_Foldable.foldr(dictFoldable)(cons)(empty);
  };
  var singleton = function (x) {
      return cons(x)(empty);
  };
  var append = function (v) {
      return function (v1) {
          return Data_FingerTree.append(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt))(Data_Sequence_Internal.measuredElem)(v)(v1);
      };
  };
  var concat = Data_Foldable.foldr(foldableSeq)(append)(empty);
  var concatMap = function (f) {
      var $123 = map(f);
      return function ($124) {
          return concat($123($124));
      };
  };            
  var semigroupSeq = new Data_Semigroup.Semigroup(append);
  var monoidSeq = new Data_Monoid.Monoid(function () {
      return semigroupSeq;
  }, empty);
  exports["empty"] = empty;
  exports["singleton"] = singleton;
  exports["cons"] = cons;
  exports["map"] = map;
  exports["concatMap"] = concatMap;
  exports["fromFoldable"] = fromFoldable;
  exports["length"] = length;
  exports["null"] = $$null;
  exports["head"] = head;
  exports["toUnfoldable"] = toUnfoldable;
  exports["take"] = take;
  exports["drop"] = drop;
  exports["filter"] = filter;
  exports["eqSeq"] = eqSeq;
  exports["monoidSeq"] = monoidSeq;
  exports["foldableSeq"] = foldableSeq;
  exports["unfoldableSeq"] = unfoldableSeq;
  exports["functorSeq"] = functorSeq;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Sequence.Ordered"] = $PS["Data.Sequence.Ordered"] || {};
  var exports = $PS["Data.Sequence.Ordered"];
  var Data_FingerTree = $PS["Data.FingerTree"];
  var Data_Lazy = $PS["Data.Lazy"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence_Internal = $PS["Data.Sequence.Internal"];
  var Data_Tuple = $PS["Data.Tuple"];
  var toUnfoldable = function (dictFunctor) {
      return function (dictUnfoldable) {
          return function (v) {
              return Data_Sequence_Internal.mapGetElem(dictFunctor)(Data_FingerTree.unfoldLeft(dictUnfoldable)(Data_Sequence_Internal.monoidKey)(Data_Sequence_Internal.measuredElemKey)(v));
          };
      };
  };
  var split = function (dictPartial) {
      return function (f) {
          return function (x) {
              return Data_FingerTree.split(Data_Sequence_Internal.monoidKey)(Data_Sequence_Internal.measuredElemKey)()(function (y) {
                  return f(y)(new Data_Sequence_Internal.Key(x));
              });
          };
      };
  };
  var splitGEQ = function (dictOrd) {
      return split()(Data_Ord.greaterThanOrEq(Data_Sequence_Internal.ordKey(dictOrd)));
  };
  var insert = function (dictOrd) {
      return function (x) {
          return function (v) {
              var t = splitGEQ(dictOrd)(x)(v);
              var r = Data_Tuple.snd(t);
              var l = Data_Tuple.fst(t);
              return Data_FingerTree.append(Data_Sequence_Internal.monoidKey)(Data_Sequence_Internal.measuredElemKey)(Data_Lazy.force(l))(Data_FingerTree.cons(Data_Sequence_Internal.monoidKey)(Data_Sequence_Internal.measuredElemKey)(x)(Data_Lazy.force(r)));
          };
      };
  };
  var empty = Data_FingerTree.Empty.value;
  exports["empty"] = empty;
  exports["insert"] = insert;
  exports["toUnfoldable"] = toUnfoldable;
})(PS);
(function(exports) {
  "use strict";

  exports.intercalate = function (separator) {
    return function (xs) {
      var len = xs.length;
      if (len === 0) return "";

      var res = xs[0];
      for (var i = 1; i < len; i++) {
        res = res + separator + xs[i];
      }
      return res;
    };
  };
})(PS["Data.Show.Generic"] = PS["Data.Show.Generic"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Show.Generic"] = $PS["Data.Show.Generic"] || {};
  var exports = $PS["Data.Show.Generic"];
  var $foreign = $PS["Data.Show.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Type_Proxy = $PS["Type.Proxy"];                
  var GenericShowArgs = function (genericShowArgs) {
      this.genericShowArgs = genericShowArgs;
  };
  var GenericShow = function (genericShow$prime) {
      this["genericShow'"] = genericShow$prime;
  };
  var genericShowArgsNoArguments = new GenericShowArgs(function (v) {
      return [  ];
  });
  var genericShowArgsArgument = function (dictShow) {
      return new GenericShowArgs(function (v) {
          return [ Data_Show.show(dictShow)(v) ];
      });
  };
  var genericShowArgs = function (dict) {
      return dict.genericShowArgs;
  };
  var genericShowConstructor = function (dictGenericShowArgs) {
      return function (dictIsSymbol) {
          return new GenericShow(function (v) {
              var ctor = Data_Symbol.reflectSymbol(dictIsSymbol)(Type_Proxy["Proxy"].value);
              var v1 = genericShowArgs(dictGenericShowArgs)(v);
              if (v1.length === 0) {
                  return ctor;
              };
              return "(" + ($foreign.intercalate(" ")(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ ctor ])(v1)) + ")");
          });
      };
  };
  var genericShow$prime = function (dict) {
      return dict["genericShow'"];
  }; 
  var genericShowSum = function (dictGenericShow) {
      return function (dictGenericShow1) {
          return new GenericShow(function (v) {
              if (v instanceof Data_Generic_Rep.Inl) {
                  return genericShow$prime(dictGenericShow)(v.value0);
              };
              if (v instanceof Data_Generic_Rep.Inr) {
                  return genericShow$prime(dictGenericShow1)(v.value0);
              };
              throw new Error("Failed pattern match at Data.Show.Generic (line 26, column 1 - line 28, column 40): " + [ v.constructor.name ]);
          });
      };
  };
  var genericShow = function (dictGeneric) {
      return function (dictGenericShow) {
          return function (x) {
              return genericShow$prime(dictGenericShow)(Data_Generic_Rep.from(dictGeneric)(x));
          };
      };
  };
  exports["genericShow"] = genericShow;
  exports["genericShowArgsNoArguments"] = genericShowArgsNoArguments;
  exports["genericShowSum"] = genericShowSum;
  exports["genericShowConstructor"] = genericShowConstructor;
  exports["genericShowArgsArgument"] = genericShowArgsArgument;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.String.Pattern"] = $PS["Data.String.Pattern"] || {};
  var exports = $PS["Data.String.Pattern"];
  var Pattern = function (x) {
      return x;
  };
  exports["Pattern"] = Pattern;
})(PS);
(function(exports) {
  "use strict";

  exports.regexImpl = function (left) {
    return function (right) {
      return function (s1) {
        return function (s2) {
          try {
            return right(new RegExp(s1, s2));
          } catch (e) {
            return left(e.message);
          }
        };
      };
    };
  };

  exports.test = function (r) {
    return function (s) {
      var lastIndex = r.lastIndex;
      var result = r.test(s);
      r.lastIndex = lastIndex;
      return result;
    };
  };

  exports.replace = function (r) {
    return function (s1) {
      return function (s2) {
        return s2.replace(r, s1);
      };
    };
  };
})(PS["Data.String.Regex"] = PS["Data.String.Regex"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.String.Regex"] = $PS["Data.String.Regex"] || {};
  var exports = $PS["Data.String.Regex"];
  var $foreign = $PS["Data.String.Regex"];
  var Data_Either = $PS["Data.Either"];                                                        
  var renderFlags = function (v) {
      return (function () {
          if (v.value0.global) {
              return "g";
          };
          return "";
      })() + ((function () {
          if (v.value0.ignoreCase) {
              return "i";
          };
          return "";
      })() + ((function () {
          if (v.value0.multiline) {
              return "m";
          };
          return "";
      })() + ((function () {
          if (v.value0.dotAll) {
              return "s";
          };
          return "";
      })() + ((function () {
          if (v.value0.sticky) {
              return "y";
          };
          return "";
      })() + (function () {
          if (v.value0.unicode) {
              return "u";
          };
          return "";
      })()))));
  };
  var regex = function (s) {
      return function (f) {
          return $foreign.regexImpl(Data_Either.Left.create)(Data_Either.Right.create)(s)(renderFlags(f));
      };
  };
  exports["regex"] = regex;
  exports["test"] = $foreign.test;
  exports["replace"] = $foreign.replace;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.String.Regex.Flags"] = $PS["Data.String.Regex.Flags"] || {};
  var exports = $PS["Data.String.Regex.Flags"];
  var Data_Semigroup = $PS["Data.Semigroup"];                        
  var RegexFlags = (function () {
      function RegexFlags(value0) {
          this.value0 = value0;
      };
      RegexFlags.create = function (value0) {
          return new RegexFlags(value0);
      };
      return RegexFlags;
  })();
  var unicode = new RegexFlags({
      global: false,
      ignoreCase: false,
      multiline: false,
      dotAll: false,
      sticky: false,
      unicode: true
  });
  var sticky = new RegexFlags({
      global: false,
      ignoreCase: false,
      multiline: false,
      dotAll: false,
      sticky: true,
      unicode: false
  });
  var semigroupRegexFlags = new Data_Semigroup.Semigroup(function (v) {
      return function (v1) {
          return new RegexFlags({
              global: v.value0.global || v1.value0.global,
              ignoreCase: v.value0.ignoreCase || v1.value0.ignoreCase,
              multiline: v.value0.multiline || v1.value0.multiline,
              dotAll: v.value0.dotAll || v1.value0.dotAll,
              sticky: v.value0.sticky || v1.value0.sticky,
              unicode: v.value0.unicode || v1.value0.unicode
          });
      };
  });
  var noFlags = new RegexFlags({
      global: false,
      ignoreCase: false,
      multiline: false,
      dotAll: false,
      sticky: false,
      unicode: false
  });
  var multiline = new RegexFlags({
      global: false,
      ignoreCase: false,
      multiline: true,
      dotAll: false,
      sticky: false,
      unicode: false
  });         
  var ignoreCase = new RegexFlags({
      global: false,
      ignoreCase: true,
      multiline: false,
      dotAll: false,
      sticky: false,
      unicode: false
  });
  var global = new RegexFlags({
      global: true,
      ignoreCase: false,
      multiline: false,
      dotAll: false,
      sticky: false,
      unicode: false
  });
  var dotAll = new RegexFlags({
      global: false,
      ignoreCase: false,
      multiline: false,
      dotAll: true,
      sticky: false,
      unicode: false
  });
  exports["noFlags"] = noFlags;
  exports["global"] = global;
  exports["multiline"] = multiline;
  exports["semigroupRegexFlags"] = semigroupRegexFlags;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.String.Regex.Unsafe"] = $PS["Data.String.Regex.Unsafe"] || {};
  var exports = $PS["Data.String.Regex.Unsafe"];
  var Control_Category = $PS["Control.Category"];
  var Data_Either = $PS["Data.Either"];
  var Data_String_Regex = $PS["Data.String.Regex"];
  var Partial_Unsafe = $PS["Partial.Unsafe"];                
  var unsafeRegex = function (s) {
      return function (f) {
          return Data_Either.either(Partial_Unsafe.unsafeCrashWith)(Control_Category.identity(Control_Category.categoryFn))(Data_String_Regex.regex(s)(f));
      };
  };
  exports["unsafeRegex"] = unsafeRegex;
})(PS);
(function(exports) {
  "use strict";

  function codePointAtImpl (just, nothing, i, s) {
    var codePointArray = Array.from(s);
    var isWithinRange  = i >= 0 && i < codePointArray.length;

    return isWithinRange ? just(codePointArray[i].codePointAt(0)) : nothing;
  }

  function codePointAtPrimeImpl (just, nothing, i, s) {
    return i >= 0 && i < s.length ? just(s.codePointAt(i)) : nothing;
  }

  function endsWithImpl (searchString, s) {
    return s.endsWith(searchString);
  }

  function endsWithPrimeImpl (searchString, position, s) {
    return s.endsWith(searchString, position);
  }

  function escapeRegexImpl (str) {
    return str.replace(/[.*+?^${}()|[\]\-\\]/g, "\\$&");
  }

  function fromCharArrayImpl (array) {
    return array.join("");
  }

  function includesImpl (searchString, str) {
    return str.includes(searchString);
  }

  function includesPrimeImpl (needle, position, haystack) {
    // For negative `position` values, we search from the beginning of the
    // string. This is in accordance with the native
    // `String.prototype.include` function.
    var pos = Math.max(0, position);

    // Converting to arrays takes care of any surrogate code points
    var needleA    = Array.from(needle);
    var haystackA  = Array.from(haystack).slice(pos);
    var needleALen = needleA.length;

    var maxIndex = haystackA.length + 1 - needleALen;
    var found    = false;
    var i;

    // Naive implementation, at some point we should check whether Boyer-Moore
    // or Knuth-Morris-Pratt are worthwhile
    for (i = 0; i < maxIndex; i++) {
      if (needleA.every(function (e, j) { return e === haystackA[i+j]; })) {
        found = true;
        break;
      }
    }

    return found;
  }

  function lengthImpl (str) {
    return Array.from(str).length;
  }

  function linesImpl (str) {
    // See http://www.unicode.org/reports/tr18/#RL1.6
    return str.split(/\r\n|[\n\v\f\r\u0085\u2028\u2029]/);
  }

  function normalizeImpl (str) {
    return str.normalize();
  }

  function normalizePrimeImpl (normalizationForm, str) {
    return str.normalize(normalizationForm);
  }

  function padEndPrimeImpl (targetLength, str) {
    return str.padEnd(targetLength);
  }

  function padStartPrimeImpl (targetLength, str) {
    return str.padStart(targetLength);
  }

  function repeatImpl (just, nothing, n, str) {
    var result;

    try {
      result = just(str.repeat(n));
    }
    catch (error) {
      result = nothing;
    }

    return result;
  }

  function startsWithImpl (searchString, s) {
    return s.startsWith(searchString);
  }

  function startsWithPrimeImpl (searchString, position, s) {
    return s.startsWith(searchString, position);
  }

  function stripCharsImpl (chars, s) {
    return s.replace(RegExp("[" + escapeRegexImpl(chars) + "]", "g"), "");
  }

  function stripDiacriticsImpl (str) {
    return str.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
  }

  function toCharArrayImpl (str) {
    return Array.from(str);
  }

  function unsafeCodePointAtImpl (i, s) {
    var codePointArray = Array.from(s);
    var isWithinRange = i >= 0 && i < codePointArray.length;

    if (isWithinRange) {
      return codePointArray[i].codePointAt(0);
    }
    else {
      throw new Error("Data.String.Utils.unsafeCodePointAt: Invalid index");
    }
  }

  function unsafeCodePointAtPrimeImpl (i, s) {
    if (i >= 0 && i < s.length) {
      return s.codePointAt(i);
    }
    else {
      throw new Error("Data.String.Utils.unsafeCodePointAt': Invalid index");
    }
  }

  function unsafeRepeatImpl (n, str) {
    try {
      return str.repeat(n);
    }
    catch (error) {
      throw new Error("Data.String.Utils.unsafeRepeat: Invalid count");
    }
  }

  function wordsImpl (s) {
    // Split at every Unicode whitespace character (25 as of Unicode 12.1)
    return s.split(/[\u000a-\u000d\u0085\u2028\u2029\u0009\u0020\u00a0\u1680\u2000-\u200a\u202f\u205f\u3000]+/);
  }                                                         
  exports.endsWithImpl               = endsWithImpl;
  exports.startsWithImpl             = startsWithImpl;  
  exports.wordsImpl                  = wordsImpl;
})(PS["Data.String.Utils"] = PS["Data.String.Utils"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.String.Utils"] = $PS["Data.String.Utils"] || {};
  var exports = $PS["Data.String.Utils"];
  var $foreign = $PS["Data.String.Utils"];
  var words = function (s) {
      return $foreign.wordsImpl(s);
  };
  var startsWith = function (searchString) {
      return function (s) {
          return $foreign.startsWithImpl(searchString, s);
      };
  };
  var endsWith = function (searchString) {
      return function (s) {
          return $foreign.endsWithImpl(searchString, s);
      };
  };
  exports["endsWith"] = endsWith;
  exports["startsWith"] = startsWith;
  exports["words"] = words;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Time.Component"] = $PS["Data.Time.Component"] || {};
  var exports = $PS["Data.Time.Component"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Bounded = $PS["Data.Bounded"];
  var Data_Enum = $PS["Data.Enum"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var ordSecond = Data_Ord.ordInt;
  var ordMinute = Data_Ord.ordInt;
  var ordMillisecond = Data_Ord.ordInt;
  var ordHour = Data_Ord.ordInt;
  var boundedSecond = new Data_Bounded.Bounded(function () {
      return ordSecond;
  }, 0, 59);
  var boundedMinute = new Data_Bounded.Bounded(function () {
      return ordMinute;
  }, 0, 59);
  var boundedMillisecond = new Data_Bounded.Bounded(function () {
      return ordMillisecond;
  }, 0, 999);
  var boundedHour = new Data_Bounded.Bounded(function () {
      return ordHour;
  }, 0, 23);
  var boundedEnumSecond = new Data_Enum.BoundedEnum(function () {
      return boundedSecond;
  }, function () {
      return enumSecond;
  }, 60, function (v) {
      return v;
  }, function (n) {
      if (n >= 0 && n <= 59) {
          return new Data_Maybe.Just(n);
      };
      if (Data_Boolean.otherwise) {
          return Data_Maybe.Nothing.value;
      };
      throw new Error("Failed pattern match at Data.Time.Component (line 90, column 1 - line 95, column 26): " + [ n.constructor.name ]);
  });
  var enumSecond = new Data_Enum.Enum(function () {
      return ordSecond;
  }, (function () {
      var $28 = Data_Enum.toEnum(boundedEnumSecond);
      var $29 = Data_Enum.fromEnum(boundedEnumSecond);
      return function ($30) {
          return $28((function (v) {
              return v - 1 | 0;
          })($29($30)));
      };
  })(), (function () {
      var $31 = Data_Enum.toEnum(boundedEnumSecond);
      var $32 = Data_Enum.fromEnum(boundedEnumSecond);
      return function ($33) {
          return $31((function (v) {
              return v + 1 | 0;
          })($32($33)));
      };
  })());
  var boundedEnumMinute = new Data_Enum.BoundedEnum(function () {
      return boundedMinute;
  }, function () {
      return enumMinute;
  }, 60, function (v) {
      return v;
  }, function (n) {
      if (n >= 0 && n <= 59) {
          return new Data_Maybe.Just(n);
      };
      if (Data_Boolean.otherwise) {
          return Data_Maybe.Nothing.value;
      };
      throw new Error("Failed pattern match at Data.Time.Component (line 61, column 1 - line 66, column 26): " + [ n.constructor.name ]);
  });
  var enumMinute = new Data_Enum.Enum(function () {
      return ordMinute;
  }, (function () {
      var $34 = Data_Enum.toEnum(boundedEnumMinute);
      var $35 = Data_Enum.fromEnum(boundedEnumMinute);
      return function ($36) {
          return $34((function (v) {
              return v - 1 | 0;
          })($35($36)));
      };
  })(), (function () {
      var $37 = Data_Enum.toEnum(boundedEnumMinute);
      var $38 = Data_Enum.fromEnum(boundedEnumMinute);
      return function ($39) {
          return $37((function (v) {
              return v + 1 | 0;
          })($38($39)));
      };
  })());
  var boundedEnumHour = new Data_Enum.BoundedEnum(function () {
      return boundedHour;
  }, function () {
      return enumHour;
  }, 24, function (v) {
      return v;
  }, function (n) {
      if (n >= 0 && n <= 23) {
          return new Data_Maybe.Just(n);
      };
      if (Data_Boolean.otherwise) {
          return Data_Maybe.Nothing.value;
      };
      throw new Error("Failed pattern match at Data.Time.Component (line 32, column 1 - line 37, column 24): " + [ n.constructor.name ]);
  });
  var enumHour = new Data_Enum.Enum(function () {
      return ordHour;
  }, (function () {
      var $46 = Data_Enum.toEnum(boundedEnumHour);
      var $47 = Data_Enum.fromEnum(boundedEnumHour);
      return function ($48) {
          return $46((function (v) {
              return v - 1 | 0;
          })($47($48)));
      };
  })(), (function () {
      var $49 = Data_Enum.toEnum(boundedEnumHour);
      var $50 = Data_Enum.fromEnum(boundedEnumHour);
      return function ($51) {
          return $49((function (v) {
              return v + 1 | 0;
          })($50($51)));
      };
  })());
  exports["boundedEnumHour"] = boundedEnumHour;
  exports["boundedEnumMinute"] = boundedEnumMinute;
  exports["boundedEnumSecond"] = boundedEnumSecond;
  exports["boundedMillisecond"] = boundedMillisecond;
})(PS);
(function(exports) {
  'use strict';

  exports.prjImpl = function projImpl1 (n, t) {
    return t[n];
  };
})(PS["Data.Tuple.Native"] = PS["Data.Tuple.Native"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Typelevel.Num.Sets"] = $PS["Data.Typelevel.Num.Sets"] || {};
  var exports = $PS["Data.Typelevel.Num.Sets"];              
  var Nat = function (toInt) {
      this.toInt = toInt;
  };
  var toInt = function (dict) {
      return dict.toInt;
  }; 
  var natD1 = new Nat(function (v) {
      return 1;
  });
  var natD0 = new Nat(function (v) {
      return 0;
  });
  exports["toInt"] = toInt;
  exports["natD0"] = natD0;
  exports["natD1"] = natD1;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Tuple.Native"] = $PS["Data.Tuple.Native"] || {};
  var exports = $PS["Data.Tuple.Native"];
  var $foreign = $PS["Data.Tuple.Native"];
  var Data_Typelevel_Num_Sets = $PS["Data.Typelevel.Num.Sets"];
  var prj = function (dictTupleSize) {
      return function (dictLt) {
          return function (dictShowNat) {
              return function (dictListToRow) {
                  return function (dictCons) {
                      return function (dictNat) {
                          return function (n) {
                              return function (t) {
                                  return $foreign.prjImpl(Data_Typelevel_Num_Sets.toInt(dictNat)(n), t);
                              };
                          };
                      };
                  };
              };
          };
      };
  };
  exports["prj"] = prj;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Typelevel.Undefined"] = $PS["Data.Typelevel.Undefined"] || {};
  var exports = $PS["Data.Typelevel.Undefined"];
  var Data_Unit = $PS["Data.Unit"];                
  var $$undefined = Data_Unit.unit;
  exports["undefined"] = $$undefined;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Typelevel.Num.Reps"] = $PS["Data.Typelevel.Num.Reps"] || {};
  var exports = $PS["Data.Typelevel.Num.Reps"];
  var Data_Typelevel_Undefined = $PS["Data.Typelevel.Undefined"];
  var d1 = Data_Typelevel_Undefined["undefined"];
  var d0 = Data_Typelevel_Undefined["undefined"];
  exports["d0"] = d0;
  exports["d1"] = d1;
})(PS);
(function(exports) {
  "use strict";

  exports.from = function (val) {
      return val >>> 0;
  };

  exports.uintAdd = function (x) {
      return function (y) {
          return (x + y) >>> 0;
      };
  };

  exports.uintMul = function (x) {
      return function (y) {
          return (x * y) >>> 0;
      };
  };

  exports.uintSub = function (x) {
      return function (y) {
          return (x - y) >>> 0;
      };
  };

  exports.uintEq = function (x) {
      return function (y) {
          return x == y;
      };
  };

  exports.uintCmp = function (lt) {
      return function (eq) {
          return function (gt) {
              return function (x) {
                  return function (y) {
                      if (x < y) return lt;
                      if (x === y) return eq;
                      return gt;
                  };
              };
          };
      };
  };

  exports.shl = function (n1) {
      return function (n2) {
          return (n1 << n2) >>> 0;
      };
  };
})(PS["Data.UInt"] = PS["Data.UInt"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.UInt"] = $PS["Data.UInt"] || {};
  var exports = $PS["Data.UInt"];
  var $foreign = $PS["Data.UInt"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ordering = $PS["Data.Ordering"];
  var Data_Ring = $PS["Data.Ring"];
  var Data_Semiring = $PS["Data.Semiring"];
  var uintEqInstance = new Data_Eq.Eq($foreign.uintEq);
  var uintOrd = new Data_Ord.Ord(function () {
      return uintEqInstance;
  }, $foreign.uintCmp(Data_Ordering.LT.value)(Data_Ordering.EQ.value)(Data_Ordering.GT.value));
  var fromInt = $foreign.from;    
  var uintSemiring = new Data_Semiring.Semiring($foreign.uintAdd, $foreign.uintMul, fromInt(1), fromInt(0));
  var uintRing = new Data_Ring.Ring(function () {
      return uintSemiring;
  }, $foreign.uintSub);
  exports["fromInt"] = fromInt;
  exports["uintSemiring"] = uintSemiring;
  exports["uintRing"] = uintRing;
  exports["uintOrd"] = uintOrd;
  exports["shl"] = $foreign.shl;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Data.Validation.Semiring"] = $PS["Data.Validation.Semiring"] || {};
  var exports = $PS["Data.Validation.Semiring"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Data_Either = $PS["Data.Either"];
  var Data_Semiring = $PS["Data.Semiring"];                      
  var V = function (x) {
      return x;
  };
  var validation = function (v) {
      return function (v1) {
          return function (v2) {
              if (v2 instanceof Data_Either.Left) {
                  return v(v2.value0);
              };
              if (v2 instanceof Data_Either.Right) {
                  return v1(v2.value0);
              };
              throw new Error("Failed pattern match at Data.Validation.Semiring (line 51, column 1 - line 51, column 84): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
          };
      };
  };
  var invalid = function ($69) {
      return V(Data_Either.Left.create($69));
  };
  var functorV = Data_Either.functorEither;       
  var applyV = function (dictSemiring) {
      return new Control_Apply.Apply(function () {
          return functorV;
      }, function (v) {
          return function (v1) {
              if (v instanceof Data_Either.Left && v1 instanceof Data_Either.Left) {
                  return new Data_Either.Left(Data_Semiring.mul(dictSemiring)(v.value0)(v1.value0));
              };
              if (v instanceof Data_Either.Left) {
                  return new Data_Either.Left(v.value0);
              };
              if (v1 instanceof Data_Either.Left) {
                  return new Data_Either.Left(v1.value0);
              };
              if (v instanceof Data_Either.Right && v1 instanceof Data_Either.Right) {
                  return new Data_Either.Right(v.value0(v1.value0));
              };
              throw new Error("Failed pattern match at Data.Validation.Semiring (line 96, column 1 - line 100, column 54): " + [ v.constructor.name, v1.constructor.name ]);
          };
      });
  };
  var applicativeV = function (dictSemiring) {
      return new Control_Applicative.Applicative(function () {
          return applyV(dictSemiring);
      }, function ($78) {
          return V(Data_Either.Right.create($78));
      });
  };
  var altV = function (dictSemiring) {
      return new Control_Alt.Alt(function () {
          return functorV;
      }, function (v) {
          return function (v1) {
              if (v instanceof Data_Either.Left && v1 instanceof Data_Either.Left) {
                  return new Data_Either.Left(Data_Semiring.add(dictSemiring)(v.value0)(v1.value0));
              };
              if (v instanceof Data_Either.Left) {
                  return v1;
              };
              if (v instanceof Data_Either.Right) {
                  return new Data_Either.Right(v.value0);
              };
              throw new Error("Failed pattern match at Data.Validation.Semiring (line 111, column 1 - line 114, column 36): " + [ v.constructor.name, v1.constructor.name ]);
          };
      });
  };
  exports["validation"] = validation;
  exports["invalid"] = invalid;
  exports["applicativeV"] = applicativeV;
  exports["altV"] = altV;
})(PS);
(function(exports) {
  "use strict";

  exports.error = function (s) {
    return function () {
      console.error(s);
    };
  };
})(PS["Effect.Console"] = PS["Effect.Console"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Console"] = $PS["Effect.Console"] || {};
  var exports = $PS["Effect.Console"];
  var $foreign = $PS["Effect.Console"];
  exports["error"] = $foreign.error;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Class.Console"] = $PS["Effect.Class.Console"] || {};
  var exports = $PS["Effect.Class.Console"];
  var Effect_Class = $PS["Effect.Class"];
  var Effect_Console = $PS["Effect.Console"];
  var error = function (dictMonadEffect) {
      var $40 = Effect_Class.liftEffect(dictMonadEffect);
      return function ($41) {
          return $40(Effect_Console.error($41));
      };
  };
  exports["error"] = error;
})(PS);
(function(exports) {
  "use strict";

  exports.unsafePerformEffect = function (f) {
    return f();
  };
})(PS["Effect.Unsafe"] = PS["Effect.Unsafe"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Unsafe"] = $PS["Effect.Unsafe"] || {};
  var exports = $PS["Effect.Unsafe"];
  var $foreign = $PS["Effect.Unsafe"];
  exports["unsafePerformEffect"] = $foreign.unsafePerformEffect;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Exception.Unsafe"] = $PS["Effect.Exception.Unsafe"] || {};
  var exports = $PS["Effect.Exception.Unsafe"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Effect_Unsafe = $PS["Effect.Unsafe"];                
  var unsafeThrowException = function ($0) {
      return Effect_Unsafe.unsafePerformEffect(Effect_Exception.throwException($0));
  };
  var unsafeThrow = function ($1) {
      return unsafeThrowException(Effect_Exception.error($1));
  };
  exports["unsafeThrow"] = unsafeThrow;
})(PS);
(function(exports) {
  "use strict";

  exports.now = function () {
    return Date.now();
  };
})(PS["Effect.Now"] = PS["Effect.Now"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Now"] = $PS["Effect.Now"] || {};
  var exports = $PS["Effect.Now"];
  var $foreign = $PS["Effect.Now"];
  exports["now"] = $foreign.now;
})(PS);
(function(exports) {
  "use strict";

  exports.new = function (val) {
    return function () {
      return { value: val };
    };
  };

  exports.read = function (ref) {
    return function () {
      return ref.value;
    };
  };

  exports.write = function (val) {
    return function (ref) {
      return function () {
        ref.value = val;
      };
    };
  };
})(PS["Effect.Ref"] = PS["Effect.Ref"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Ref"] = $PS["Effect.Ref"] || {};
  var exports = $PS["Effect.Ref"];
  var $foreign = $PS["Effect.Ref"];
  exports["new"] = $foreign["new"];
  exports["read"] = $foreign.read;
  exports["write"] = $foreign.write;
})(PS);
(function(exports) {
  /* no-redeclare global exports */
  "use strict";

  exports.setTimeout = function (ms) {
    return function (fn) {
      return function () {
        return setTimeout(fn, ms);
      };
    };
  };

  exports.clearTimeout = function (id) {
    return function () {
      clearTimeout(id);
    };
  };

  exports.setInterval = function (ms) {
    return function (fn) {
      return function () {
        return setInterval(fn, ms);
      };
    };
  };

  exports.clearInterval = function (id) {
    return function () {
      clearInterval(id);
    };
  };
})(PS["Effect.Timer"] = PS["Effect.Timer"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Effect.Timer"] = $PS["Effect.Timer"] || {};
  var exports = $PS["Effect.Timer"];
  var $foreign = $PS["Effect.Timer"];
  exports["setTimeout"] = $foreign.setTimeout;
  exports["clearTimeout"] = $foreign.clearTimeout;
  exports["setInterval"] = $foreign.setInterval;
  exports["clearInterval"] = $foreign.clearInterval;
})(PS);
(function(exports) {
  'use strict';
  exports._from = function(a) { return Array.from(a); };                           
  exports._unshift = function(i,a) { a.unshift(i); return a; };
})(PS["FFI.Simple.PseudoArray"] = PS["FFI.Simple.PseudoArray"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["FFI.Simple.PseudoArray"] = $PS["FFI.Simple.PseudoArray"] || {};
  var exports = $PS["FFI.Simple.PseudoArray"];
  var $foreign = $PS["FFI.Simple.PseudoArray"];
  var Data_Function_Uncurried = $PS["Data.Function.Uncurried"];      
  var unshift = Data_Function_Uncurried.runFn2($foreign["_unshift"]);
  var from = $foreign["_from"];
  exports["from"] = from;
  exports["unshift"] = unshift;
})(PS);
(function(exports) {
  "use strict";

  exports.unsafeReadPropImpl = function (f, s, key, value) {
    return value == null ? f : s(value[key]);
  };
})(PS["Foreign.Index"] = PS["Foreign.Index"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Foreign.Index"] = $PS["Foreign.Index"] || {};
  var exports = $PS["Foreign.Index"];
  var $foreign = $PS["Foreign.Index"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Foreign = $PS["Foreign"];
  var unsafeReadProp = function (dictMonad) {
      return function (k) {
          return function (value) {
              return $foreign.unsafeReadPropImpl(Foreign.fail(dictMonad)(new Foreign.TypeMismatch("object", Foreign.typeOf(value))), Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(dictMonad)), k, value);
          };
      };
  };
  var readProp = function (dictMonad) {
      return unsafeReadProp(dictMonad);
  };
  exports["readProp"] = readProp;
})(PS);
(function(exports) {
  'use strict';
  exports.react = require("react");
  exports.reactDOM = require('react-dom');
})(PS["Reactix.React"] = PS["Reactix.React"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Reactix.React"] = $PS["Reactix.React"] || {};
  var exports = $PS["Reactix.React"];
  var $foreign = $PS["Reactix.React"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad = $PS["Control.Monad"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Uncurried = $PS["Effect.Uncurried"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
  var FFI_Simple_Objects = $PS["FFI.Simple.Objects"];
  var FFI_Simple_PseudoArray = $PS["FFI.Simple.PseudoArray"];                
  var MonadDelay = function (Monad0) {
      this.Monad0 = Monad0;
  };
  var Hooks = function (x) {
      return x;
  };
  var IsComponent = function (createElement) {
      this.createElement = createElement;
  };
  var Component = function (x) {
      return x;
  };
  var unsafeHooksEffect = Hooks;
  var setRef = function (r) {
      return function (v) {
          return FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v1) {
              return Control_Apply.applySecond(Effect.applyEffect)(Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Objects["setProperty'"](r)("current")(v)))(Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit));
          });
      };
  };
  var runHooks = function (v) {
      return v;
  };
  var readRef = function (r) {
      return FFI_Simple_Objects["getProperty'"](r)("current");
  };
  var readRefM = function (dictMonadDelay) {
      return function (r) {
          return FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(dictMonadDelay.Monad0()))(r)((function () {
              var $17 = Control_Applicative.pure((dictMonadDelay.Monad0()).Applicative0());
              return function ($18) {
                  return $17(readRef($18));
              };
          })());
      };
  };
  var readNullableRef = function (r) {
      return Data_Nullable.toMaybe(FFI_Simple_Objects["getProperty'"](r)("current"));
  };
  var rawCreateElement = function (c) {
      return function (p) {
          return function (cs) {
              var args = FFI_Simple_PseudoArray.unshift(c)(FFI_Simple_PseudoArray.unshift(p)(cs));
              return FFI_Simple_Functions["applyMethod'"]($foreign.react)("createElement")(args);
          };
      };
  };
  var named = Data_Function.flip(FFI_Simple_Objects.defineProperty("name"));
  var monadDelayEffect = new MonadDelay(function () {
      return Effect.monadEffect;
  });
  var memoIsComponent = new IsComponent(rawCreateElement);
  var memo$prime = function (c) {
      return FFI_Simple_Functions["applyMethod'"]($foreign.react)("memo")([ c ]);
  };
  var functorHooks = new Data_Functor.Functor(function (f) {
      return function (v) {
          return Data_Functor.map(Effect.functorEffect)(f)(v);
      };
  });
  var fragment = function (es) {
      return rawCreateElement(FFI_Simple_Objects["getProperty'"]($foreign.react)("Fragment"))({})(es);
  };
  var semigroupElement = new Data_Semigroup.Semigroup(function (a) {
      return function (b) {
          return fragment([ a, b ]);
      };
  });
  var monoidElement = new Data_Monoid.Monoid(function () {
      return semigroupElement;
  }, fragment([  ]));
  var createPortal = function (es) {
      return function (e) {
          return FFI_Simple_Functions["applyMethod'"]($foreign.reactDOM)("createPortal")(FFI_Simple_Functions.args2(es)(e));
      };
  };
  var createElement = function (dict) {
      return dict.createElement;
  };
  var createDOMElement = rawCreateElement;
  var componentIsComponent = new IsComponent(rawCreateElement);
  var children = function (a) {
      return FFI_Simple_Functions["applyMethod'"](FFI_Simple_Objects["getProperty'"]($foreign.react)("Children"))("toArray")([ FFI_Simple_Objects["getProperty'"](a)("children") ]);
  };
  var hooksComponent = function (name) {
      return function (c) {
          var c$prime = function (props) {
              return runHooks(c(props)(children(props)));
          };
          return Component(named(name)(Effect_Uncurried.mkEffectFn1(c$prime)));
      };
  };
  var hooksComponentWithModule = function (module$prime) {
      return function (name) {
          return function (c) {
              return hooksComponent(module$prime + ("." + name))(c);
          };
      };
  };
  var applyHooks = new Control_Apply.Apply(function () {
      return functorHooks;
  }, function (v) {
      return function (v1) {
          return Control_Apply.apply(Effect.applyEffect)(v)(v1);
      };
  });
  var bindHooks = new Control_Bind.Bind(function () {
      return applyHooks;
  }, function (v) {
      return function (f) {
          return function __do() {
              var $21 = v();
              return runHooks(f($21))();
          };
      };
  });
  var applicativeHooks = new Control_Applicative.Applicative(function () {
      return applyHooks;
  }, (function () {
      var $22 = Control_Applicative.pure(Effect.applicativeEffect);
      return function ($23) {
          return Hooks($22($23));
      };
  })());
  var monadHooks = new Control_Monad.Monad(function () {
      return applicativeHooks;
  }, function () {
      return bindHooks;
  });
  var monadDelayHooks = new MonadDelay(function () {
      return monadHooks;
  });
  exports["unsafeHooksEffect"] = unsafeHooksEffect;
  exports["runHooks"] = runHooks;
  exports["createPortal"] = createPortal;
  exports["createElement"] = createElement;
  exports["createDOMElement"] = createDOMElement;
  exports["rawCreateElement"] = rawCreateElement;
  exports["hooksComponent"] = hooksComponent;
  exports["hooksComponentWithModule"] = hooksComponentWithModule;
  exports["fragment"] = fragment;
  exports["readRef"] = readRef;
  exports["readRefM"] = readRefM;
  exports["readNullableRef"] = readNullableRef;
  exports["setRef"] = setRef;
  exports["memo'"] = memo$prime;
  exports["functorHooks"] = functorHooks;
  exports["applyHooks"] = applyHooks;
  exports["applicativeHooks"] = applicativeHooks;
  exports["bindHooks"] = bindHooks;
  exports["monadDelayEffect"] = monadDelayEffect;
  exports["monadDelayHooks"] = monadDelayHooks;
  exports["componentIsComponent"] = componentIsComponent;
  exports["memoIsComponent"] = memoIsComponent;
  exports["monoidElement"] = monoidElement;
  exports["react"] = $foreign.react;
  exports["reactDOM"] = $foreign.reactDOM;
})(PS);
(function(exports) {
  'use strict';
  exports._tuple = function tuple(ctor, v) { return ctor(v[0])(v[1]); };
})(PS["Reactix.Utils"] = PS["Reactix.Utils"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Reactix.Utils"] = $PS["Reactix.Utils"] || {};
  var exports = $PS["Reactix.Utils"];
  var $foreign = $PS["Reactix.Utils"];
  var Data_Function_Uncurried = $PS["Data.Function.Uncurried"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Uncurried = $PS["Effect.Uncurried"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
  var Reactix_React = $PS["Reactix.React"];                
  var ucFirst = (function () {
      var help = function (v) {
          return Data_String_Common.toUpper(v.before) + v.after;
      };
      var $8 = Data_String_CodePoints.splitAt(1);
      return function ($9) {
          return help($8($9));
      };
  })();
  var tuple = Data_Function_Uncurried.runFn2($foreign["_tuple"])(Data_Tuple.Tuple.create);
  var hook = function (f) {
      return Reactix_React.unsafeHooksEffect(FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(f));
  };
  var currySecond = function (v) {
      return new Data_Tuple.Tuple(v.value0, Effect_Uncurried.runEffectFn1(v.value1));
  };
  exports["tuple"] = tuple;
  exports["currySecond"] = currySecond;
  exports["hook"] = hook;
  exports["ucFirst"] = ucFirst;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Reactix.DOM.HTML"] = $PS["Reactix.DOM.HTML"] || {};
  var exports = $PS["Reactix.DOM.HTML"];
  var Control_Category = $PS["Control.Category"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Effect_Uncurried = $PS["Effect.Uncurried"];
  var FFI_Simple_Objects = $PS["FFI.Simple.Objects"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_Utils = $PS["Reactix.Utils"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
  var text = Unsafe_Coerce.unsafeCoerce;
  var mapCopyAll = function (xf) {
      return function (yf) {
          return function (dest) {
              return function (src) {
                  var f = function (dest$prime) {
                      return function (k) {
                          return FFI_Simple_Objects["setProperty'"](dest$prime)(xf(k))(yf(FFI_Simple_Objects["getProperty'"](src)(k)));
                      };
                  };
                  return Data_Foldable.foldl(Data_Foldable.foldableArray)(f)(dest)(FFI_Simple_Objects.keys(src));
              };
          };
      };
  };
  var prefixCopyAll = function (pre$prime) {
      return mapCopyAll(function (v) {
          return pre$prime + v;
      })(Control_Category.identity(Control_Category.categoryFn));
  };
  var xformEventProps = function (props) {
      var eventPropName = function (other) {
          return "on" + Reactix_Utils.ucFirst(other);
      };
      var help = mapCopyAll(eventPropName)(Effect_Uncurried.mkEffectFn1)(props);
      return Data_Maybe.maybe(props)(help)(FFI_Simple_Objects["maybeGetProperty'"](props)("on"));
  };
  var magicPrefixProp = function (prop) {
      return function (pre$prime) {
          return function (props) {
              var help = function (val) {
                  return FFI_Simple_Objects["removeProperty'"](prefixCopyAll(pre$prime)(props)(val))(prop);
              };
              return Data_Maybe.maybe(props)(help)(FFI_Simple_Objects["maybeGetProperty'"](props)(prop));
          };
      };
  };
  var magicProps = (function () {
      var xformDataProps = magicPrefixProp("data")("data-");
      var xformAriaProps = magicPrefixProp("aria")("aria-");
      return function ($1) {
          return xformAriaProps(xformDataProps(xformEventProps($1)));
      };
  })();
  var createDOM = function (e) {
      return function (props) {
          return Reactix_React.createDOMElement(e)(magicProps(props));
      };
  };
  var createLeafDOM = function (e) {
      return function (props) {
          return createDOM(e)(props)([  ]);
      };
  };                                 
  var hr = createLeafDOM("hr");
  var img = createLeafDOM("img");
  var input = createLeafDOM("input");
  var div = createDOM("div");      
  var footer = createDOM("footer");
  var form = createDOM("form");
  var h1 = createDOM("h1");
  var h2 = createDOM("h2");
  var h3 = createDOM("h3");
  var h4 = createDOM("h4");
  var h5 = createDOM("h5");
  var h6 = createDOM("h6");        
  var i = createDOM("i");
  var iframe = createDOM("iframe");
  var label = createDOM("label");  
  var li = createDOM("li");      
  var nav = createDOM("nav");          
  var option = createDOM("option");
  var p = createDOM("p");            
  var pre = createDOM("pre");        
  var span = createDOM("span");
  var table = createDOM("table");
  var tbody = createDOM("tbody");
  var td = createDOM("td");            
  var textarea = createDOM("textarea");
  var th = createDOM("th");
  var thead = createDOM("thead");
  var tr = createDOM("tr");
  var u = createDOM("u");
  var ul = createDOM("ul");    
  var video = createDOM("video");  
  var button = createDOM("button");
  var br = createLeafDOM("br");
  var b = createDOM("b");      
  var a = createDOM("a");
  exports["createDOM"] = createDOM;
  exports["text"] = text;
  exports["a"] = a;
  exports["b"] = b;
  exports["br"] = br;
  exports["button"] = button;
  exports["div"] = div;
  exports["footer"] = footer;
  exports["form"] = form;
  exports["h1"] = h1;
  exports["h2"] = h2;
  exports["h3"] = h3;
  exports["h4"] = h4;
  exports["h5"] = h5;
  exports["h6"] = h6;
  exports["hr"] = hr;
  exports["i"] = i;
  exports["iframe"] = iframe;
  exports["img"] = img;
  exports["input"] = input;
  exports["label"] = label;
  exports["li"] = li;
  exports["nav"] = nav;
  exports["option"] = option;
  exports["p"] = p;
  exports["pre"] = pre;
  exports["span"] = span;
  exports["table"] = table;
  exports["tbody"] = tbody;
  exports["td"] = td;
  exports["textarea"] = textarea;
  exports["th"] = th;
  exports["thead"] = thead;
  exports["tr"] = tr;
  exports["u"] = u;
  exports["ul"] = ul;
  exports["video"] = video;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Reactix.SyntheticEvent"] = $PS["Reactix.SyntheticEvent"] || {};
  var exports = $PS["Reactix.SyntheticEvent"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
  var FFI_Simple_Objects = $PS["FFI.Simple.Objects"];
  var unsafeEventValue = function (e) {
      return e.target.value;
  };
  var unsafeEventTarget = function (e) {
      return e.target;
  };
  var target = function (dictIsEvent) {
      return function (e) {
          return FFI_Simple_Objects["getProperty'"](e)("target");
      };
  };
  var preventDefault = function (dictIsEvent) {
      return function (e) {
          return FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v) {
              return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](e)("preventDefault")([  ]));
          });
      };
  };
  var clientY = function (dictIsMouseEvent) {
      return function (e) {
          return FFI_Simple_Objects["getProperty'"](e)("clientY");
      };
  };
  var clientX = function (dictIsMouseEvent) {
      return function (e) {
          return FFI_Simple_Objects["getProperty'"](e)("clientX");
      };
  };
  exports["unsafeEventValue"] = unsafeEventValue;
  exports["unsafeEventTarget"] = unsafeEventTarget;
  exports["preventDefault"] = preventDefault;
  exports["clientX"] = clientX;
  exports["clientY"] = clientY;
})(PS);
(function(exports) {
  "use strict";

  exports.copyRecord = function(rec) {
    var copy = {};
    for (var key in rec) {
      if ({}.hasOwnProperty.call(rec, key)) {
        copy[key] = rec[key];
      }
    }
    return copy;
  };

  exports.unsafeInsert = function(l) {
    return function(a) {
      return function(rec) {
        rec[l] = a;
        return rec;
      };
    };
  };

  exports.unsafeModify = function(l) {
    return function (f) {
      return function(rec) {
        rec[l] = f(rec[l]);
        return rec;
      };
    };
  };

  exports.unsafeDelete = function(l) {
    return function(rec) {
      delete rec[l];
      return rec;
    };
  };
})(PS["Record.Builder"] = PS["Record.Builder"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Record.Builder"] = $PS["Record.Builder"] || {};
  var exports = $PS["Record.Builder"];
  var $foreign = $PS["Record.Builder"];
  var Control_Category = $PS["Control.Category"];
  var Control_Semigroupoid = $PS["Control.Semigroupoid"];
  var Data_Symbol = $PS["Data.Symbol"];
  var semigroupoidBuilder = Control_Semigroupoid.semigroupoidFn;
  var modify = function (dictCons) {
      return function (dictCons1) {
          return function (dictIsSymbol) {
              return function (l) {
                  return function (f) {
                      return function (r1) {
                          return $foreign.unsafeModify(Data_Symbol.reflectSymbol(dictIsSymbol)(l))(f)(r1);
                      };
                  };
              };
          };
      };
  };
  var insert = function (dictCons) {
      return function (dictLacks) {
          return function (dictIsSymbol) {
              return function (l) {
                  return function (a) {
                      return function (r1) {
                          return $foreign.unsafeInsert(Data_Symbol.reflectSymbol(dictIsSymbol)(l))(a)(r1);
                      };
                  };
              };
          };
      };
  };
  var $$delete = function (dictIsSymbol) {
      return function (dictLacks) {
          return function (dictCons) {
              return function (l) {
                  return function (r2) {
                      return $foreign.unsafeDelete(Data_Symbol.reflectSymbol(dictIsSymbol)(l))(r2);
                  };
              };
          };
      };
  };
  var categoryBuilder = Control_Category.categoryFn;
  var build = function (v) {
      return function (r1) {
          return v($foreign.copyRecord(r1));
      };
  };
  exports["build"] = build;
  exports["insert"] = insert;
  exports["modify"] = modify;
  exports["delete"] = $$delete;
  exports["semigroupoidBuilder"] = semigroupoidBuilder;
  exports["categoryBuilder"] = categoryBuilder;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Reactix.Hooks"] = $PS["Reactix.Hooks"] || {};
  var exports = $PS["Reactix.Hooks"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Data_Function = $PS["Data.Function"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
  var FFI_Simple_PseudoArray = $PS["FFI.Simple.PseudoArray"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_Utils = $PS["Reactix.Utils"];                
  var useRef = function (r) {
      return Reactix_Utils.hook(function (v) {
          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](Reactix_React.react)("useRef")([ r ]));
      });
  };
  var useEffect = function (e) {
      return Reactix_Utils.hook(function (v) {
          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](Reactix_React.react)("useEffect")([ e ]));
      });
  };
  var unsafeUseLayoutEffect = function (e) {
      return function (a) {
          return Reactix_Utils.hook(function (v) {
              return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](Reactix_React.react)("useLayoutEffect")(FFI_Simple_Functions.args2(e)(FFI_Simple_PseudoArray.from(a))));
          });
      };
  };
  var useLayoutEffect1 = function (a) {
      return function (e) {
          return unsafeUseLayoutEffect(e)([ a ]);
      };
  };
  var useLayoutEffect2 = function (a) {
      return function (b) {
          return function (e) {
              return unsafeUseLayoutEffect(e)(FFI_Simple_Functions.args2(a)(b));
          };
      };
  };
  var unsafeUseEffect = function (e) {
      return function (a) {
          return Reactix_Utils.hook(function (v) {
              return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](Reactix_React.react)("useEffect")(FFI_Simple_Functions.args2(e)(FFI_Simple_PseudoArray.from(a))));
          });
      };
  };
  var useEffect1 = function (a) {
      return function (e) {
          return unsafeUseEffect(e)([ a ]);
      };
  };
  var useEffect2 = function (a) {
      return function (b) {
          return function (e) {
              return unsafeUseEffect(e)(FFI_Simple_Functions.args2(a)(b));
          };
      };
  };
  var useEffectOnce = function (e) {
      return unsafeUseEffect(e)([  ]);
  };
  var nothing = Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
  var thenNothing = function (e) {
      return Control_Apply.applySecond(Effect.applyEffect)(e)(Control_Applicative.pure(Effect.applicativeEffect)(nothing));
  };
  var useEffect$prime = function ($19) {
      return useEffect(thenNothing($19));
  };
  var useEffect1$prime = function (a) {
      var $20 = useEffect1(a);
      return function ($21) {
          return $20(thenNothing($21));
      };
  };
  var useEffect2$prime = function (a) {
      return function (b) {
          var $22 = useEffect2(a)(b);
          return function ($23) {
              return $22(thenNothing($23));
          };
      };
  };
  var useEffectOnce$prime = function ($30) {
      return useEffectOnce(thenNothing($30));
  };
  var delayEffect = FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect));
  var useState = function (s) {
      return Reactix_Utils.hook(function (v) {
          return Control_Applicative.pure(Effect.applicativeEffect)(Reactix_Utils.currySecond(Reactix_Utils.tuple(FFI_Simple_Functions["applyMethod'"](Reactix_React.react)("useState")([ delayEffect(Data_Unit.unit)((function () {
              var $42 = Control_Applicative.pure(Effect.applicativeEffect);
              return function ($43) {
                  return $42(s($43));
              };
          })()) ]))));
      });
  };
  var useState$prime = function ($44) {
      return useState(Data_Function["const"]($44));
  };
  exports["useState'"] = useState$prime;
  exports["useRef"] = useRef;
  exports["nothing"] = nothing;
  exports["useEffectOnce"] = useEffectOnce;
  exports["useEffectOnce'"] = useEffectOnce$prime;
  exports["useEffect'"] = useEffect$prime;
  exports["useEffect1'"] = useEffect1$prime;
  exports["useEffect2'"] = useEffect2$prime;
  exports["useLayoutEffect1"] = useLayoutEffect1;
  exports["useLayoutEffect2"] = useLayoutEffect2;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Toestand.Changes"] = $PS["Toestand.Changes"] || {};
  var exports = $PS["Toestand.Changes"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Eq = $PS["Data.Eq"];
  var Effect = $PS["Effect"];                
  var unequal = function (dictEq) {
      return function (v) {
          return Control_Applicative.pure(Effect.applicativeEffect)(Data_Eq.notEq(dictEq)(v["new"])(v.old));
      };
  };
  var mapChange = function (f) {
      return function (v) {
          return {
              "new": f(v["new"]),
              old: f(v.old)
          };
      };
  };
  exports["mapChange"] = mapChange;
  exports["unequal"] = unequal;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Toestand.Classes"] = $PS["Toestand.Classes"] || {};
  var exports = $PS["Toestand.Classes"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Effect = $PS["Effect"];
  var Reactix_React = $PS["Reactix.React"];                
  var Write = function (write) {
      this.write = write;
  };
  var Read = function (listen, read) {
      this.listen = listen;
      this.read = read;
  };
  var ReadWrite = function (Read0, Write1) {
      this.Read0 = Read0;
      this.Write1 = Write1;
  };
  var write = function (dict) {
      return dict.write;
  };
  var write_ = function (dictWrite) {
      return function (v) {
          return function (box) {
              return Data_Functor["void"](Effect.functorEffect)(write(dictWrite)(v)(box));
          };
      };
  };
  var readWrite = function (dictRead) {
      return function (dictWrite) {
          return new ReadWrite(function () {
              return dictRead;
          }, function () {
              return dictWrite;
          });
      };
  };
  var read = function (dict) {
      return dict.read;
  };
  var modify = function (dictReadWrite) {
      return function (f) {
          return function (box) {
              return Control_Bind.bind(Effect.bindEffect)(Data_Functor.map(Effect.functorEffect)(f)(read(dictReadWrite.Read0())(Reactix_React.monadDelayEffect)(box)))(Data_Function.flip(write(dictReadWrite.Write1()))(box));
          };
      };
  };
  var modify_ = function (dictReadWrite) {
      return function (f) {
          return function (box) {
              return Data_Functor["void"](Effect.functorEffect)(modify(dictReadWrite)(f)(box));
          };
      };
  };
  var listen = function (dict) {
      return dict.listen;
  };
  exports["Read"] = Read;
  exports["Write"] = Write;
  exports["read"] = read;
  exports["listen"] = listen;
  exports["write"] = write;
  exports["write_"] = write_;
  exports["modify"] = modify;
  exports["modify_"] = modify_;
  exports["readWrite"] = readWrite;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Toestand.Watches"] = $PS["Toestand.Watches"] || {};
  var exports = $PS["Toestand.Watches"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Effect = $PS["Effect"];                
  var Watches = (function () {
      function Watches(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Watches.create = function (value0) {
          return function (value1) {
              return new Watches(value0, value1);
          };
      };
      return Watches;
  })();
  var watches = new Watches(0, Data_Map_Internal.empty);
  var unlisten = function (v) {
      return function (id) {
          return new Watches(v.value0, Data_Map_Internal["delete"](Data_Ord.ordInt)(id)(v.value1));
      };
  };
  var notify = function (v) {
      return function (change) {
          return Control_Apply.applyFirst(Effect.applyEffect)(Control_Applicative.pure(Effect.applicativeEffect)(change))(Data_Foldable.traverse_(Effect.applicativeEffect)(Data_List_Types.foldableList)(function (v1) {
              return v1(change);
          })(Data_Map_Internal.values(v.value1)));
      };
  };
  var listen = function (f) {
      return function (v) {
          return Data_Tuple.Tuple.create(v.value0)(new Watches(v.value0 + 1 | 0, Data_Map_Internal.insert(Data_Ord.ordInt)(v.value0)(f)(v.value1)));
      };
  };
  exports["watches"] = watches;
  exports["listen"] = listen;
  exports["notify"] = notify;
  exports["unlisten"] = unlisten;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Toestand.Boxes"] = $PS["Toestand.Boxes"] || {};
  var exports = $PS["Toestand.Boxes"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var Toestand_Watches = $PS["Toestand.Watches"];                
  var R = (function () {
      function R(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      R.create = function (value0) {
          return function (value1) {
              return new R(value0, value1);
          };
      };
      return R;
  })();
  var Root = (function () {
      function Root(value0) {
          this.value0 = value0;
      };
      Root.create = function (value0) {
          return new Root(value0);
      };
      return Root;
  })();
  var Focus = (function () {
      function Focus(value0) {
          this.value0 = value0;
      };
      Focus.create = function (value0) {
          return new Focus(value0);
      };
      return Focus;
  })();
  var writeWith = function (dictReadWrite) {
      return function (w) {
          return function (v) {
              return function (c) {
                  return function (box) {
                      return Control_Apply.applyFirst(Effect.applyEffect)(Control_Applicative.pure(Effect.applicativeEffect)(v))(Toestand_Classes.write(dictReadWrite.Write1())(w(v)(c))(box));
                  };
              };
          };
      };
  };
  var writeBox = new Toestand_Classes.Write(function ($$new) {
      return function (v) {
          if (v instanceof Root) {
              var write$prime = function (v1) {
                  return Control_Apply.applyFirst(Effect.applyEffect)(Reactix_React.setRef(v.value0)(new R($$new, v1.value1)))(Toestand_Watches.notify(v1.value1)({
                      "new": $$new,
                      old: v1.value0
                  }));
              };
              return Control_Apply.applyFirst(Effect.applyEffect)(Control_Applicative.pure(Effect.applicativeEffect)($$new))(Control_Bind.bind(Effect.bindEffect)(Reactix_React.readRefM(Reactix_React.monadDelayEffect)(v.value0))(write$prime));
          };
          if (v instanceof Focus) {
              return function __do() {
                  var v1 = Reactix_React.readRefM(Reactix_React.monadDelayEffect)(v.value0)();
                  return v1.write($$new)();
              };
          };
          throw new Error("Failed pattern match at Toestand.Boxes (line 40, column 1 - line 43, column 67): " + [ $$new.constructor.name, v.constructor.name ]);
      };
  });
  var useLive = function (dictRead) {
      return function (shouldReload) {
          return function (box) {
              var uL = function (v) {
                  var listener = function (change) {
                      var maybeReload = function (check) {
                          return Control_Applicative.when(Effect.applicativeEffect)(check)(v.value1(function (v1) {
                              return v1 + 1 | 0;
                          }));
                      };
                      return Control_Bind.bind(Effect.bindEffect)(shouldReload(change))(maybeReload);
                  };
                  return Reactix_Hooks.useEffectOnce(Toestand_Classes.listen(dictRead)(listener)(box));
              };
              return Control_Apply.applyFirst(Reactix_React.applyHooks)(Toestand_Classes.read(dictRead)(Reactix_React.monadDelayHooks)(box))(Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks["useState'"](0))(uL));
          };
      };
  };
  var useBox = function (value) {
      return Data_Functor.map(Reactix_React.functorHooks)(Root.create)(Reactix_Hooks.useRef(new R(value, Toestand_Watches.watches)));
  };
  var readWith = function (dictRead) {
      return function (r) {
          return function (box) {
              return function (dictMonadDelay) {
                  return Data_Functor.map((((dictMonadDelay.Monad0()).Bind1()).Apply0()).Functor0())(r)(Toestand_Classes.read(dictRead)(dictMonadDelay)(box));
              };
          };
      };
  };
  var readRoot = function (v) {
      return v.value0;
  };
  var readFocus = function (v) {
      return function (dictMonadDelay) {
          return function (u) {
              return v.read(dictMonadDelay)(u);
          };
      };
  };
  var readBox = new Toestand_Classes.Read(function (l) {
      return function (v) {
          if (v instanceof Root) {
              var on = function (v1) {
                  var v2 = Toestand_Watches.listen(l)(v1.value1);
                  return Control_Apply.applyFirst(Effect.applyEffect)(Control_Applicative.pure(Effect.applicativeEffect)(v2.value0))(Reactix_React.setRef(v.value0)(new R(v1.value0, v2.value1)));
              };
              var off = function (id) {
                  var off$prime = function (v1) {
                      return Reactix_React.setRef(v.value0)(R.create(v1.value0)(Toestand_Watches.unlisten(v1.value1)(id)));
                  };
                  return Control_Bind.bind(Effect.bindEffect)(Reactix_React.readRefM(Reactix_React.monadDelayEffect)(v.value0))(off$prime);
              };
              return Data_Functor.map(Effect.functorEffect)(off)(Control_Bind.bind(Effect.bindEffect)(Reactix_React.readRefM(Reactix_React.monadDelayEffect)(v.value0))(on));
          };
          if (v instanceof Focus) {
              return function __do() {
                  var v1 = Reactix_React.readRefM(Reactix_React.monadDelayEffect)(v.value0)();
                  return v1.listen(l)();
              };
          };
          throw new Error("Failed pattern match at Toestand.Boxes (line 24, column 1 - line 32, column 65): " + [ l.constructor.name, v.constructor.name ]);
      };
  }, function (dictMonadDelay) {
      return function (v) {
          if (v instanceof Root) {
              return Data_Functor.map((((dictMonadDelay.Monad0()).Bind1()).Apply0()).Functor0())(readRoot)(Reactix_React.readRefM(dictMonadDelay)(v.value0));
          };
          if (v instanceof Focus) {
              return Control_Bind.bind((dictMonadDelay.Monad0()).Bind1())(Reactix_React.readRefM(dictMonadDelay)(v.value0))(function (f) {
                  return readFocus(f)(dictMonadDelay)(Data_Unit.unit);
              });
          };
          throw new Error("Failed pattern match at Toestand.Boxes (line 24, column 1 - line 32, column 65): " + [ v.constructor.name ]);
      };
  });
  var listenWith = function (dictRead) {
      return function (l) {
          return function (r) {
              return function (box) {
                  return Toestand_Classes.listen(dictRead)((function () {
                      var $58 = Toestand_Changes.mapChange(r);
                      return function ($59) {
                          return l($58($59));
                      };
                  })())(box);
              };
          };
      };
  };
  var useFocused = function (dictReadWrite) {
      return function (r) {
          return function (w) {
              return function (box) {
                  var write$prime = function (v) {
                      return function __do() {
                          var c = Toestand_Classes.read(dictReadWrite.Read0())(Reactix_React.monadDelayEffect)(box)();
                          return writeWith(dictReadWrite)(w)(v)(c)(box)();
                      };
                  };
                  var read$prime = function (dictMonadDelay) {
                      return function (v) {
                          return readWith(dictReadWrite.Read0())(r)(box)(dictMonadDelay);
                      };
                  };
                  var listen$prime = function (l) {
                      return listenWith(dictReadWrite.Read0())(l)(r)(box);
                  };
                  var f = {
                      read: function (dictMonadDelay) {
                          return read$prime(dictMonadDelay);
                      },
                      listen: listen$prime,
                      write: write$prime
                  };
                  return Data_Functor.map(Reactix_React.functorHooks)(Focus.create)(Reactix_Hooks.useRef(f));
              };
          };
      };
  };
  exports["useBox"] = useBox;
  exports["useFocused"] = useFocused;
  exports["useLive"] = useLive;
  exports["readBox"] = readBox;
  exports["writeBox"] = writeBox;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Formula"] = $PS["Formula"] || {};
  var exports = $PS["Formula"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Semigroupoid = $PS["Control.Semigroupoid"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Effect = $PS["Effect"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Record_Builder = $PS["Record.Builder"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var viewTextCpt = function (dictRead) {
      var cpt = function (v) {
          return function (v1) {
              return Data_Functor.map(Reactix_React.functorHooks)(Reactix_DOM_HTML.text)(Toestand_Boxes.useLive(dictRead)(Toestand_Changes.unequal(Data_Eq.eqString))(v.text));
          };
      };
      return Reactix_React["memo'"](Reactix_React.hooksComponent("viewText")(cpt));
  };
  var viewText = function (dictRead) {
      return function (props) {
          return Reactix_React.createElement(Reactix_React.memoIsComponent)(viewTextCpt(dictRead))(props)([  ]);
      };
  };
  var bindInputCpt = function (dictReadWrite) {
      return function (dictCons2) {
          return function (dictCons) {
              var cpt = function (v) {
                  return function (v1) {
                      var change = function (e) {
                          return Data_Functor["void"](Effect.functorEffect)(Toestand_Classes.write(dictReadWrite.Write1())(Reactix_SyntheticEvent.unsafeEventValue(e))(v.value));
                      };
                      var adjust = function (val) {
                          return Control_Semigroupoid.compose(Record_Builder.semigroupoidBuilder)(Record_Builder.insert()()(new Data_Symbol.IsSymbol(function () {
                              return "on";
                          }))(Data_Symbol.SProxy.value)({
                              change: change
                          }))(Control_Semigroupoid.compose(Record_Builder.semigroupoidBuilder)(Record_Builder.insert()()(new Data_Symbol.IsSymbol(function () {
                              return "defaultValue";
                          }))(Data_Symbol.SProxy.value)(val))(Record_Builder["delete"](new Data_Symbol.IsSymbol(function () {
                              return "value";
                          }))()()(Data_Symbol.SProxy.value)));
                      };
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(dictReadWrite.Read0())(Toestand_Changes.unequal(Data_Eq.eqString))(v.value))(function (val) {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.input(Record_Builder.build(adjust(val))(v)));
                      });
                  };
              };
              return Reactix_React["memo'"](Reactix_React.hooksComponent("bindInput")(cpt));
          };
      };
  };
  var bindInput = function (dictReadWrite) {
      return function (dictCons2) {
          return function (dictCons) {
              return function (props) {
                  return Reactix_React.createElement(Reactix_React.memoIsComponent)(bindInputCpt(dictReadWrite)(dictCons2)(dictCons))(props)([  ]);
              };
          };
      };
  };
  var bindCheckboxCpt = function (dictReadWrite) {
      return function (dictCons3) {
          return function (dictCons) {
              var cpt = function (v) {
                  return function (v1) {
                      var adjust = function (val) {
                          var changeChecked = Record_Builder.modify()()(new Data_Symbol.IsSymbol(function () {
                              return "checked";
                          }))(Data_Symbol.SProxy.value)(Data_Function["const"](val));
                          var change = function (e) {
                              return Data_Functor["void"](Effect.functorEffect)(Toestand_Classes.write(dictReadWrite.Write1())(!val)(v.checked));
                          };
                          var addType = Record_Builder.insert()()(new Data_Symbol.IsSymbol(function () {
                              return "type";
                          }))(Data_Symbol.SProxy.value)("checkbox");
                          var addOn = Record_Builder.insert()()(new Data_Symbol.IsSymbol(function () {
                              return "on";
                          }))(Data_Symbol.SProxy.value)({
                              change: change
                          });
                          return Control_Semigroupoid.compose(Record_Builder.semigroupoidBuilder)(addType)(Control_Semigroupoid.compose(Record_Builder.semigroupoidBuilder)(addOn)(changeChecked));
                      };
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(dictReadWrite.Read0())(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.checked))(function (val) {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.input(Record_Builder.build(adjust(val))(v)));
                      });
                  };
              };
              return Reactix_React["memo'"](Reactix_React.hooksComponent("bindCheckbox")(cpt));
          };
      };
  };
  var bindCheckbox = function (dictReadWrite) {
      return function (dictCons3) {
          return function (dictCons) {
              return function (props) {
                  return Reactix_React.createElement(Reactix_React.memoIsComponent)(bindCheckboxCpt(dictReadWrite)(dictCons3)(dictCons))(props)([  ]);
              };
          };
      };
  };
  exports["viewText"] = viewText;
  exports["bindInput"] = bindInput;
  exports["bindCheckbox"] = bindCheckbox;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Prelude"] = $PS["Gargantext.Prelude"] || {};
  var exports = $PS["Gargantext.Prelude"];     
  var Read = function (read) {
      this.read = read;
  };
  var read = function (dict) {
      return dict.read;
  };
  exports["Read"] = Read;
  exports["read"] = read;
})(PS);
(function(exports) {
  exports._parseJSON = JSON.parse;

  exports._undefined = undefined;

  exports._unsafeStringify = JSON.stringify;
})(PS["Simple.JSON"] = PS["Simple.JSON"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Simple.JSON"] = $PS["Simple.JSON"] || {};
  var exports = $PS["Simple.JSON"];
  var $foreign = $PS["Simple.JSON"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Control_Monad_Except = $PS["Control.Monad.Except"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Control_Semigroupoid = $PS["Control.Semigroupoid"];
  var Data_Bifunctor = $PS["Data.Bifunctor"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Either = $PS["Data.Either"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Data_TraversableWithIndex = $PS["Data.TraversableWithIndex"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Effect_Uncurried = $PS["Effect.Uncurried"];
  var Effect_Unsafe = $PS["Effect.Unsafe"];
  var Foreign = $PS["Foreign"];
  var Foreign_Index = $PS["Foreign.Index"];
  var Foreign_Object = $PS["Foreign.Object"];
  var Record = $PS["Record"];
  var Record_Builder = $PS["Record.Builder"];
  var Type_Proxy = $PS["Type.Proxy"];
  var WriteForeignFields = function (writeImplFields) {
      this.writeImplFields = writeImplFields;
  };
  var WriteForeign = function (writeImpl) {
      this.writeImpl = writeImpl;
  };
  var ReadForeignFields = function (getFields) {
      this.getFields = getFields;
  };
  var ReadForeign = function (readImpl) {
      this.readImpl = readImpl;
  };
  var writeImplFields = function (dict) {
      return dict.writeImplFields;
  };
  var writeImpl = function (dict) {
      return dict.writeImpl;
  };
  var writeJSON = function (dictWriteForeign) {
      var $87 = writeImpl(dictWriteForeign);
      return function ($88) {
          return $foreign["_unsafeStringify"]($87($88));
      };
  };
  var writeForeignString = new WriteForeign(Foreign.unsafeToForeign);
  var writeForeignObject = function (dictWriteForeign) {
      return new WriteForeign((function () {
          var $89 = Foreign_Object.mapWithKey(Data_Function["const"](writeImpl(dictWriteForeign)));
          return function ($90) {
              return Foreign.unsafeToForeign($89($90));
          };
      })());
  };
  var writeForeignNumber = new WriteForeign(Foreign.unsafeToForeign);
  var writeForeignInt = new WriteForeign(Foreign.unsafeToForeign);
  var writeForeignForeign = new WriteForeign(Control_Category.identity(Control_Category.categoryFn));
  var writeForeignBoolean = new WriteForeign(Foreign.unsafeToForeign);
  var writeForeignArray = function (dictWriteForeign) {
      return new WriteForeign(function (xs) {
          return Foreign.unsafeToForeign(Data_Functor.map(Data_Functor.functorArray)(writeImpl(dictWriteForeign))(xs));
      });
  };                                                 
  var $$undefined = $foreign["_undefined"];
  var writeForeignMaybe = function (dictWriteForeign) {
      return new WriteForeign(Data_Maybe.maybe($$undefined)(writeImpl(dictWriteForeign)));
  };
  var recordWriteForeign = function (dictRowToList) {
      return function (dictWriteForeignFields) {
          return new WriteForeign(function (rec) {
              var steps = writeImplFields(dictWriteForeignFields)(Type_Proxy["Proxy"].value)(rec);
              return Foreign.unsafeToForeign(Record_Builder.build(steps)({}));
          });
      };
  };
  var readString = new ReadForeign(Foreign.readString(Data_Identity.monadIdentity));
  var readNumber = new ReadForeign(Foreign.readNumber(Data_Identity.monadIdentity));
  var readInt = new ReadForeign(Foreign.readInt(Data_Identity.monadIdentity));
  var readImpl = function (dict) {
      return dict.readImpl;
  };
  var readMaybe = function (dictReadForeign) {
      return new ReadForeign((function () {
          var readNullOrUndefined = function (v) {
              return function (value) {
                  if (Foreign.isNull(value) || Foreign.isUndefined(value)) {
                      return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Data_Maybe.Nothing.value);
                  };
                  return Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Data_Maybe.Just.create)(v(value));
              };
          };
          return readNullOrUndefined(readImpl(dictReadForeign));
      })());
  };
  var readObject = function (dictReadForeign) {
      return new ReadForeign((function () {
          var readObject$prime = function (value) {
              if (Foreign.tagOf(value) === "Object") {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Foreign.unsafeFromForeign(value));
              };
              if (Data_Boolean.otherwise) {
                  return Foreign.fail(Data_Identity.monadIdentity)(new Foreign.TypeMismatch("Object", Foreign.tagOf(value)));
              };
              throw new Error("Failed pattern match at Simple.JSON (line 197, column 7 - line 197, column 51): " + [ value.constructor.name ]);
          };
          return Control_Bind.composeKleisliFlipped(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))((function () {
              var $93 = Data_Traversable.sequence(Foreign_Object.traversableObject)(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity));
              var $94 = Foreign_Object.mapWithKey(Data_Function["const"](readImpl(dictReadForeign)));
              return function ($95) {
                  return $93($94($95));
              };
          })())(readObject$prime);
      })());
  };                                                                                                                                      
  var readFieldsNil = new ReadForeignFields(function (v) {
      return function (v1) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Control_Category.identity(Record_Builder.categoryBuilder));
      };
  });                                                                           
  var readBoolean = new ReadForeign(Foreign.readBoolean(Data_Identity.monadIdentity));
  var readArray = function (dictReadForeign) {
      return new ReadForeign((function () {
          var readAtIdx = function (i) {
              return function (f) {
                  return Control_Monad_Except.withExcept(Data_Functor.map(Data_List_Types.functorNonEmptyList)(Foreign.ErrorAtIndex.create(i)))(readImpl(dictReadForeign)(f));
              };
          };
          return Control_Bind.composeKleisliFlipped(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Data_TraversableWithIndex.traverseWithIndex(Data_TraversableWithIndex.traversableWithIndexArray)(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(readAtIdx))(Foreign.readArray(Data_Identity.monadIdentity));
      })());
  };
  var parseJSON = (function () {
      var $102 = Data_Bifunctor.lmap(Data_Bifunctor.bifunctorEither)((function () {
          var $105 = Control_Applicative.pure(Data_List_Types.applicativeNonEmptyList);
          return function ($106) {
              return $105(Foreign.ForeignError.create(Effect_Exception.message($106)));
          };
      })());
      var $103 = Effect_Uncurried.runEffectFn1($foreign["_parseJSON"]);
      return function ($104) {
          return Control_Monad_Except_Trans.ExceptT(Data_Identity.Identity($102(Effect_Unsafe.unsafePerformEffect(Effect_Exception["try"]($103($104))))));
      };
  })();
  var readJSON = function (dictReadForeign) {
      var $107 = Control_Bind.composeKleisliFlipped(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(readImpl(dictReadForeign))(parseJSON);
      return function ($108) {
          return Control_Monad_Except.runExcept($107($108));
      };
  }; 
  var nilWriteForeignFields = new WriteForeignFields(function (v) {
      return function (v1) {
          return Control_Category.identity(Record_Builder.categoryBuilder);
      };
  });
  var getFields = function (dict) {
      return dict.getFields;
  };
  var readRecord = function (dictRowToList) {
      return function (dictReadForeignFields) {
          return new ReadForeign(function (o) {
              return Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Data_Function.flip(Record_Builder.build)({}))(getFields(dictReadForeignFields)(Type_Proxy["Proxy"].value)(o));
          });
      };
  };
  var consWriteForeignFields = function (dictIsSymbol) {
      return function (dictWriteForeign) {
          return function (dictWriteForeignFields) {
              return function (dictCons) {
                  return function (dictLacks) {
                      return function (dictCons1) {
                          return new WriteForeignFields(function (v) {
                              return function (rec) {
                                  var rest = writeImplFields(dictWriteForeignFields)(Type_Proxy["Proxy"].value)(rec);
                                  var value = writeImpl(dictWriteForeign)(Record.get(dictIsSymbol)()(Data_Symbol.SProxy.value)(rec));
                                  var result = Control_Semigroupoid.compose(Record_Builder.semigroupoidBuilder)(Record_Builder.insert()()(dictIsSymbol)(Data_Symbol.SProxy.value)(value))(rest);
                                  return result;
                              };
                          });
                      };
                  };
              };
          };
      };
  };
  var applyEither = function (dictSemigroup) {
      return function (v) {
          return function (v1) {
              if (v instanceof Data_Either.Left && v1 instanceof Data_Either.Right) {
                  return new Data_Either.Left(v.value0);
              };
              if (v instanceof Data_Either.Left && v1 instanceof Data_Either.Left) {
                  return new Data_Either.Left(Data_Semigroup.append(dictSemigroup)(v.value0)(v1.value0));
              };
              if (v instanceof Data_Either.Right && v1 instanceof Data_Either.Left) {
                  return new Data_Either.Left(v1.value0);
              };
              if (v instanceof Data_Either.Right && v1 instanceof Data_Either.Right) {
                  return new Data_Either.Right(v.value0(v1.value0));
              };
              throw new Error("Failed pattern match at Simple.JSON (line 241, column 1 - line 241, column 90): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
  };
  var exceptTApply = function (dictSemigroup) {
      return function (dictApplicative) {
          return function (fun) {
              return function (a) {
                  return Control_Monad_Except_Trans.ExceptT(Control_Apply.apply(dictApplicative.Apply0())(Data_Functor.map((dictApplicative.Apply0()).Functor0())(applyEither(dictSemigroup))(Control_Monad_Except_Trans.runExceptT(fun)))(Control_Monad_Except_Trans.runExceptT(a)));
              };
          };
      };
  };
  var readFieldsCons = function (dictIsSymbol) {
      return function (dictReadForeign) {
          return function (dictReadForeignFields) {
              return function (dictLacks) {
                  return function (dictCons) {
                      return new ReadForeignFields(function (v) {
                          return function (obj) {
                              var rest = getFields(dictReadForeignFields)(Type_Proxy["Proxy"].value)(obj);
                              var name = Data_Symbol.reflectSymbol(dictIsSymbol)(Data_Symbol.SProxy.value);
                              var withExcept$prime = Control_Monad_Except.withExcept(Data_Functor.map(Data_List_Types.functorNonEmptyList)(Foreign.ErrorAtProperty.create(name)));
                              var first = Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(withExcept$prime(Control_Bind.bindFlipped(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(readImpl(dictReadForeign))(Foreign_Index.readProp(Data_Identity.monadIdentity)(name)(obj))))(function (value) {
                                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Record_Builder.insert()()(dictIsSymbol)(Data_Symbol.SProxy.value)(value));
                              });
                              return exceptTApply(Data_List_Types.semigroupNonEmptyList)(Data_Identity.applicativeIdentity)(Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Control_Semigroupoid.compose(Record_Builder.semigroupoidBuilder))(first))(rest);
                          };
                      });
                  };
              };
          };
      };
  };
  exports["readJSON"] = readJSON;
  exports["writeJSON"] = writeJSON;
  exports["ReadForeign"] = ReadForeign;
  exports["readImpl"] = readImpl;
  exports["WriteForeign"] = WriteForeign;
  exports["writeImpl"] = writeImpl;
  exports["readNumber"] = readNumber;
  exports["readInt"] = readInt;
  exports["readString"] = readString;
  exports["readBoolean"] = readBoolean;
  exports["readArray"] = readArray;
  exports["readMaybe"] = readMaybe;
  exports["readObject"] = readObject;
  exports["readRecord"] = readRecord;
  exports["readFieldsCons"] = readFieldsCons;
  exports["readFieldsNil"] = readFieldsNil;
  exports["writeForeignForeign"] = writeForeignForeign;
  exports["writeForeignString"] = writeForeignString;
  exports["writeForeignInt"] = writeForeignInt;
  exports["writeForeignNumber"] = writeForeignNumber;
  exports["writeForeignBoolean"] = writeForeignBoolean;
  exports["writeForeignArray"] = writeForeignArray;
  exports["writeForeignMaybe"] = writeForeignMaybe;
  exports["writeForeignObject"] = writeForeignObject;
  exports["recordWriteForeign"] = recordWriteForeign;
  exports["consWriteForeignFields"] = consWriteForeignFields;
  exports["nilWriteForeignFields"] = nilWriteForeignFields;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Simple.JSON.Generics.EnumSumRep"] = $PS["Simple.JSON.Generics.EnumSumRep"] || {};
  var exports = $PS["Simple.JSON.Generics.EnumSumRep"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Foreign = $PS["Foreign"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var GenericEnumSumRep = function (genericEnumReadForeign) {
      this.genericEnumReadForeign = genericEnumReadForeign;
  };
  var genericEnumReadForeign = function (dict) {
      return dict.genericEnumReadForeign;
  };
  var sumEnumSumRep = function (dictGenericEnumSumRep) {
      return function (dictGenericEnumSumRep1) {
          return new GenericEnumSumRep(function (f) {
              return Control_Alt.alt(Control_Monad_Except_Trans.altExceptT(Data_List_Types.semigroupNonEmptyList)(Data_Identity.monadIdentity))(Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Data_Generic_Rep.Inl.create)(genericEnumReadForeign(dictGenericEnumSumRep)(f)))(Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Data_Generic_Rep.Inr.create)(genericEnumReadForeign(dictGenericEnumSumRep1)(f)));
          });
      };
  };
  var enumSumRep = function (dictGeneric) {
      return function (dictGenericEnumSumRep) {
          return function (f) {
              return Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Data_Generic_Rep.to(dictGeneric))(genericEnumReadForeign(dictGenericEnumSumRep)(f));
          };
      };
  };
  var constructorEnumSumRep = function (dictIsSymbol) {
      return new GenericEnumSumRep(function (f) {
          var name = Data_Symbol.reflectSymbol(dictIsSymbol)(Data_Symbol.SProxy.value);
          return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readString)(f))(function (s) {
              var $5 = s === name;
              if ($5) {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Data_Generic_Rep.NoArguments.value);
              };
              return Foreign.fail(Data_Identity.monadIdentity)(Foreign.ForeignError.create("Enum string " + (s + (" did not match expected string " + name))));
          });
      });
  };
  exports["enumSumRep"] = enumSumRep;
  exports["sumEnumSumRep"] = sumEnumSumRep;
  exports["constructorEnumSumRep"] = constructorEnumSumRep;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Types"] = $PS["Gargantext.Types"] || {};
  var exports = $PS["Gargantext.Types"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Int = $PS["Data.Int"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ord_Generic = $PS["Data.Ord.Generic"];
  var Data_Show = $PS["Data.Show"];
  var Data_Show_Generic = $PS["Data.Show.Generic"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Foreign = $PS["Foreign"];
  var Gargantext_Prelude = $PS["Gargantext.Prelude"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Simple_JSON_Generics_EnumSumRep = $PS["Simple.JSON.Generics.EnumSumRep"];
  var MonoTerm = (function () {
      function MonoTerm() {

      };
      MonoTerm.value = new MonoTerm();
      return MonoTerm;
  })();
  var MultiTerm = (function () {
      function MultiTerm() {

      };
      MultiTerm.value = new MultiTerm();
      return MultiTerm;
  })();
  var MapTerm = (function () {
      function MapTerm() {

      };
      MapTerm.value = new MapTerm();
      return MapTerm;
  })();
  var StopTerm = (function () {
      function StopTerm() {

      };
      StopTerm.value = new StopTerm();
      return StopTerm;
  })();
  var CandidateTerm = (function () {
      function CandidateTerm() {

      };
      CandidateTerm.value = new CandidateTerm();
      return CandidateTerm;
  })();
  var TabDocs = (function () {
      function TabDocs() {

      };
      TabDocs.value = new TabDocs();
      return TabDocs;
  })();
  var TabNgramType = (function () {
      function TabNgramType(value0) {
          this.value0 = value0;
      };
      TabNgramType.create = function (value0) {
          return new TabNgramType(value0);
      };
      return TabNgramType;
  })();
  var TabTrash = (function () {
      function TabTrash() {

      };
      TabTrash.value = new TabTrash();
      return TabTrash;
  })();
  var TabMoreLikeFav = (function () {
      function TabMoreLikeFav() {

      };
      TabMoreLikeFav.value = new TabMoreLikeFav();
      return TabMoreLikeFav;
  })();
  var TabMoreLikeTrash = (function () {
      function TabMoreLikeTrash() {

      };
      TabMoreLikeTrash.value = new TabMoreLikeTrash();
      return TabMoreLikeTrash;
  })();
  var InitialClosed = (function () {
      function InitialClosed() {

      };
      InitialClosed.value = new InitialClosed();
      return InitialClosed;
  })();
  var Opened = (function () {
      function Opened() {

      };
      Opened.value = new Opened();
      return Opened;
  })();
  var Closed = (function () {
      function Closed() {

      };
      Closed.value = new Closed();
      return Closed;
  })();
  var SessionId = function (x) {
      return x;
  };
  var Occurrences = (function () {
      function Occurrences() {

      };
      Occurrences.value = new Occurrences();
      return Occurrences;
  })();
  var PTabPatents = (function () {
      function PTabPatents() {

      };
      PTabPatents.value = new PTabPatents();
      return PTabPatents;
  })();
  var PTabBooks = (function () {
      function PTabBooks() {

      };
      PTabBooks.value = new PTabBooks();
      return PTabBooks;
  })();
  var PTabCommunication = (function () {
      function PTabCommunication() {

      };
      PTabCommunication.value = new PTabCommunication();
      return PTabCommunication;
  })();
  var DateAsc = (function () {
      function DateAsc() {

      };
      DateAsc.value = new DateAsc();
      return DateAsc;
  })();
  var DateDesc = (function () {
      function DateDesc() {

      };
      DateDesc.value = new DateDesc();
      return DateDesc;
  })();
  var TitleAsc = (function () {
      function TitleAsc() {

      };
      TitleAsc.value = new TitleAsc();
      return TitleAsc;
  })();
  var TitleDesc = (function () {
      function TitleDesc() {

      };
      TitleDesc.value = new TitleDesc();
      return TitleDesc;
  })();
  var ScoreAsc = (function () {
      function ScoreAsc() {

      };
      ScoreAsc.value = new ScoreAsc();
      return ScoreAsc;
  })();
  var ScoreDesc = (function () {
      function ScoreDesc() {

      };
      ScoreDesc.value = new ScoreDesc();
      return ScoreDesc;
  })();
  var TermAsc = (function () {
      function TermAsc() {

      };
      TermAsc.value = new TermAsc();
      return TermAsc;
  })();
  var TermDesc = (function () {
      function TermDesc() {

      };
      TermDesc.value = new TermDesc();
      return TermDesc;
  })();
  var SourceAsc = (function () {
      function SourceAsc() {

      };
      SourceAsc.value = new SourceAsc();
      return SourceAsc;
  })();
  var SourceDesc = (function () {
      function SourceDesc() {

      };
      SourceDesc.value = new SourceDesc();
      return SourceDesc;
  })();             
  var Annuaire = (function () {
      function Annuaire() {

      };
      Annuaire.value = new Annuaire();
      return Annuaire;
  })();
  var Corpus = (function () {
      function Corpus() {

      };
      Corpus.value = new Corpus();
      return Corpus;
  })();
  var Dashboard = (function () {
      function Dashboard() {

      };
      Dashboard.value = new Dashboard();
      return Dashboard;
  })();
  var $$Error = (function () {
      function $$Error() {

      };
      $$Error.value = new $$Error();
      return $$Error;
  })();
  var Folder = (function () {
      function Folder() {

      };
      Folder.value = new Folder();
      return Folder;
  })();
  var FolderPrivate = (function () {
      function FolderPrivate() {

      };
      FolderPrivate.value = new FolderPrivate();
      return FolderPrivate;
  })();
  var FolderPublic = (function () {
      function FolderPublic() {

      };
      FolderPublic.value = new FolderPublic();
      return FolderPublic;
  })();
  var FolderShared = (function () {
      function FolderShared() {

      };
      FolderShared.value = new FolderShared();
      return FolderShared;
  })();
  var Graph = (function () {
      function Graph() {

      };
      Graph.value = new Graph();
      return Graph;
  })();
  var Individu = (function () {
      function Individu() {

      };
      Individu.value = new Individu();
      return Individu;
  })();
  var Node = (function () {
      function Node() {

      };
      Node.value = new Node();
      return Node;
  })();
  var NodeContact = (function () {
      function NodeContact() {

      };
      NodeContact.value = new NodeContact();
      return NodeContact;
  })();
  var NodeList = (function () {
      function NodeList() {

      };
      NodeList.value = new NodeList();
      return NodeList;
  })();
  var NodeUser = (function () {
      function NodeUser() {

      };
      NodeUser.value = new NodeUser();
      return NodeUser;
  })();
  var Nodes = (function () {
      function Nodes() {

      };
      Nodes.value = new Nodes();
      return Nodes;
  })();
  var Phylo = (function () {
      function Phylo() {

      };
      Phylo.value = new Phylo();
      return Phylo;
  })();
  var Team = (function () {
      function Team() {

      };
      Team.value = new Team();
      return Team;
  })();
  var Texts = (function () {
      function Texts() {

      };
      Texts.value = new Texts();
      return Texts;
  })();
  var Tree = (function () {
      function Tree() {

      };
      Tree.value = new Tree();
      return Tree;
  })();
  var Url_Document = (function () {
      function Url_Document() {

      };
      Url_Document.value = new Url_Document();
      return Url_Document;
  })();
  var NodeFile = (function () {
      function NodeFile() {

      };
      NodeFile.value = new NodeFile();
      return NodeFile;
  })();
  var NodeFrameCalc = (function () {
      function NodeFrameCalc() {

      };
      NodeFrameCalc.value = new NodeFrameCalc();
      return NodeFrameCalc;
  })();
  var NodeFrameNotebook = (function () {
      function NodeFrameNotebook() {

      };
      NodeFrameNotebook.value = new NodeFrameNotebook();
      return NodeFrameNotebook;
  })();
  var NodeFrameWrite = (function () {
      function NodeFrameWrite() {

      };
      NodeFrameWrite.value = new NodeFrameWrite();
      return NodeFrameWrite;
  })();
  var NodeFrameVisio = (function () {
      function NodeFrameVisio() {

      };
      NodeFrameVisio.value = new NodeFrameVisio();
      return NodeFrameVisio;
  })();
  var NodePublic = (function () {
      function NodePublic(value0) {
          this.value0 = value0;
      };
      NodePublic.create = function (value0) {
          return new NodePublic(value0);
      };
      return NodePublic;
  })();
  var Authors = (function () {
      function Authors() {

      };
      Authors.value = new Authors();
      return Authors;
  })();
  var Sources = (function () {
      function Sources() {

      };
      Sources.value = new Sources();
      return Sources;
  })();
  var Institutes = (function () {
      function Institutes() {

      };
      Institutes.value = new Institutes();
      return Institutes;
  })();
  var Terms = (function () {
      function Terms() {

      };
      Terms.value = new Terms();
      return Terms;
  })();
  var NodePath = (function () {
      function NodePath(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      NodePath.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new NodePath(value0, value1, value2);
              };
          };
      };
      return NodePath;
  })();
  var LeftHanded = (function () {
      function LeftHanded() {

      };
      LeftHanded.value = new LeftHanded();
      return LeftHanded;
  })();
  var RightHanded = (function () {
      function RightHanded() {

      };
      RightHanded.value = new RightHanded();
      return RightHanded;
  })();
  var Histo = (function () {
      function Histo() {

      };
      Histo.value = new Histo();
      return Histo;
  })();
  var Scatter = (function () {
      function Scatter() {

      };
      Scatter.value = new Scatter();
      return Scatter;
  })();
  var ChartPie = (function () {
      function ChartPie() {

      };
      ChartPie.value = new ChartPie();
      return ChartPie;
  })();
  var ChartBar = (function () {
      function ChartBar() {

      };
      ChartBar.value = new ChartBar();
      return ChartBar;
  })();
  var ChartTree = (function () {
      function ChartTree() {

      };
      ChartTree.value = new ChartTree();
      return ChartTree;
  })();
  var CTabTerms = (function () {
      function CTabTerms() {

      };
      CTabTerms.value = new CTabTerms();
      return CTabTerms;
  })();
  var CTabSources = (function () {
      function CTabSources() {

      };
      CTabSources.value = new CTabSources();
      return CTabSources;
  })();
  var CTabAuthors = (function () {
      function CTabAuthors() {

      };
      CTabAuthors.value = new CTabAuthors();
      return CTabAuthors;
  })();
  var CTabInstitutes = (function () {
      function CTabInstitutes() {

      };
      CTabInstitutes.value = new CTabInstitutes();
      return CTabInstitutes;
  })();
  var TabCorpus = (function () {
      function TabCorpus(value0) {
          this.value0 = value0;
      };
      TabCorpus.create = function (value0) {
          return new TabCorpus(value0);
      };
      return TabCorpus;
  })();
  var TabPairing = (function () {
      function TabPairing(value0) {
          this.value0 = value0;
      };
      TabPairing.create = function (value0) {
          return new TabPairing(value0);
      };
      return TabPairing;
  })();
  var TabDocument = (function () {
      function TabDocument(value0) {
          this.value0 = value0;
      };
      TabDocument.create = function (value0) {
          return new TabDocument(value0);
      };
      return TabDocument;
  })();
  var AddNode = (function () {
      function AddNode() {

      };
      AddNode.value = new AddNode();
      return AddNode;
  })();
  var Form = (function () {
      function Form() {

      };
      Form.value = new Form();
      return Form;
  })();
  var GraphRecompute = (function () {
      function GraphRecompute() {

      };
      GraphRecompute.value = new GraphRecompute();
      return GraphRecompute;
  })();
  var Query = (function () {
      function Query() {

      };
      Query.value = new Query();
      return Query;
  })();
  var UpdateNgramsCharts = (function () {
      function UpdateNgramsCharts() {

      };
      UpdateNgramsCharts.value = new UpdateNgramsCharts();
      return UpdateNgramsCharts;
  })();
  var UpdateNode = (function () {
      function UpdateNode() {

      };
      UpdateNode.value = new UpdateNode();
      return UpdateNode;
  })();
  var UploadFile = (function () {
      function UploadFile() {

      };
      UploadFile.value = new UploadFile();
      return UploadFile;
  })();
  var IsRunning = (function () {
      function IsRunning() {

      };
      IsRunning.value = new IsRunning();
      return IsRunning;
  })();
  var IsPending = (function () {
      function IsPending() {

      };
      IsPending.value = new IsPending();
      return IsPending;
  })();
  var IsReceived = (function () {
      function IsReceived() {

      };
      IsReceived.value = new IsReceived();
      return IsReceived;
  })();
  var IsStarted = (function () {
      function IsStarted() {

      };
      IsStarted.value = new IsStarted();
      return IsStarted;
  })();
  var IsFailure = (function () {
      function IsFailure() {

      };
      IsFailure.value = new IsFailure();
      return IsFailure;
  })();
  var IsFinished = (function () {
      function IsFinished() {

      };
      IsFinished.value = new IsFinished();
      return IsFinished;
  })();
  var IsKilled = (function () {
      function IsKilled() {

      };
      IsKilled.value = new IsKilled();
      return IsKilled;
  })();
  var V0 = (function () {
      function V0() {

      };
      V0.value = new V0();
      return V0;
  })();
  var V10 = (function () {
      function V10() {

      };
      V10.value = new V10();
      return V10;
  })();
  var V11 = (function () {
      function V11() {

      };
      V11.value = new V11();
      return V11;
  })();
  var toggleSidePanelState = function (v) {
      if (v instanceof InitialClosed) {
          return Opened.value;
      };
      if (v instanceof Closed) {
          return Opened.value;
      };
      if (v instanceof Opened) {
          return Closed.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 690, column 1 - line 690, column 57): " + [ v.constructor.name ]);
  };
  var termSizes = [ {
      desc: "All types",
      mval: Data_Maybe.Nothing.value
  }, {
      desc: "One-word terms",
      mval: new Data_Maybe.Just(MonoTerm.value)
  }, {
      desc: "Multi-word terms",
      mval: new Data_Maybe.Just(MultiTerm.value)
  } ];
  var termLists = [ {
      desc: "All terms",
      mval: Data_Maybe.Nothing.value
  }, {
      desc: "Map terms",
      mval: new Data_Maybe.Just(MapTerm.value)
  }, {
      desc: "Stop terms",
      mval: new Data_Maybe.Just(StopTerm.value)
  }, {
      desc: "Candidate terms",
      mval: new Data_Maybe.Just(CandidateTerm.value)
  } ];
  var termListName = function (v) {
      if (v instanceof MapTerm) {
          return "Map List";
      };
      if (v instanceof StopTerm) {
          return "Stop List";
      };
      if (v instanceof CandidateTerm) {
          return "Candidate List";
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 92, column 1 - line 92, column 35): " + [ v.constructor.name ]);
  };
  var switchHanded = function (v) {
      return function (v1) {
          return function (v2) {
              if (v2 instanceof LeftHanded) {
                  return v;
              };
              if (v2 instanceof RightHanded) {
                  return v1;
              };
              throw new Error("Failed pattern match at Gargantext.Types (line 25, column 1 - line 25, column 48): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
          };
      };
  };
  var reverseHanded = function (v) {
      return function (a) {
          if (v instanceof LeftHanded) {
              return Data_Array.reverse(a);
          };
          if (v instanceof RightHanded) {
              return a;
          };
          throw new Error("Failed pattern match at Gargantext.Types (line 29, column 1 - line 29, column 56): " + [ v.constructor.name, a.constructor.name ]);
      };
  };
  var publicize = function (v) {
      if (v instanceof NodePublic) {
          return new NodePublic(v.value0);
      };
      return new NodePublic(v);
  };
  var progressPercent = function (v) {
      var perc = (function () {
          var v1 = Data_Array.head(v.log);
          if (v1 instanceof Data_Maybe.Nothing) {
              return 0.0;
          };
          if (v1 instanceof Data_Maybe.Just) {
              var nom = Data_Int.toNumber(v1.value0.failed + v1.value0.succeeded | 0);
              var denom = Data_Int.toNumber((v1.value0.failed + v1.value0.succeeded | 0) + v1.value0.remaining | 0);
              return (100.0 * nom) / denom;
          };
          throw new Error("Failed pattern match at Gargantext.Types (line 668, column 12 - line 673, column 60): " + [ v1.constructor.name ]);
      })();
      return perc;
  };
  var nodeTypePath = function ($copy_v) {
      var $tco_done = false;
      var $tco_result;
      function $tco_loop(v) {
          if (v instanceof Folder) {
              $tco_done = true;
              return "folder";
          };
          if (v instanceof FolderPrivate) {
              $tco_done = true;
              return "folderPrivate";
          };
          if (v instanceof FolderShared) {
              $tco_done = true;
              return "folderShared";
          };
          if (v instanceof FolderPublic) {
              $tco_done = true;
              return "folderPublic";
          };
          if (v instanceof Annuaire) {
              $tco_done = true;
              return "annuaire";
          };
          if (v instanceof Corpus) {
              $tco_done = true;
              return "corpus";
          };
          if (v instanceof Dashboard) {
              $tco_done = true;
              return "dashboard";
          };
          if (v instanceof Url_Document) {
              $tco_done = true;
              return "document";
          };
          if (v instanceof $$Error) {
              $tco_done = true;
              return "ErrorNodeType";
          };
          if (v instanceof Graph) {
              $tco_done = true;
              return "graph";
          };
          if (v instanceof Phylo) {
              $tco_done = true;
              return "phylo";
          };
          if (v instanceof Individu) {
              $tco_done = true;
              return "individu";
          };
          if (v instanceof Node) {
              $tco_done = true;
              return "node";
          };
          if (v instanceof Nodes) {
              $tco_done = true;
              return "nodes";
          };
          if (v instanceof NodeUser) {
              $tco_done = true;
              return "user";
          };
          if (v instanceof NodeContact) {
              $tco_done = true;
              return "contact";
          };
          if (v instanceof Tree) {
              $tco_done = true;
              return "tree";
          };
          if (v instanceof NodeList) {
              $tco_done = true;
              return "lists";
          };
          if (v instanceof Texts) {
              $tco_done = true;
              return "texts";
          };
          if (v instanceof Team) {
              $tco_done = true;
              return "team";
          };
          if (v instanceof NodeFrameWrite) {
              $tco_done = true;
              return "write";
          };
          if (v instanceof NodeFrameCalc) {
              $tco_done = true;
              return "calc";
          };
          if (v instanceof NodeFrameNotebook) {
              $tco_done = true;
              return "code";
          };
          if (v instanceof NodeFrameVisio) {
              $tco_done = true;
              return "visio";
          };
          if (v instanceof NodePublic) {
              $copy_v = v.value0;
              return;
          };
          if (v instanceof NodeFile) {
              $tco_done = true;
              return "file";
          };
          throw new Error("Failed pattern match at Gargantext.Types (line 303, column 1 - line 303, column 35): " + [ v.constructor.name ]);
      };
      while (!$tco_done) {
          $tco_result = $tco_loop($copy_v);
      };
      return $tco_result;
  };
  var modeTabType = function (v) {
      if (v instanceof Authors) {
          return CTabAuthors.value;
      };
      if (v instanceof Institutes) {
          return CTabInstitutes.value;
      };
      if (v instanceof Sources) {
          return CTabSources.value;
      };
      if (v instanceof Terms) {
          return CTabTerms.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 558, column 1 - line 558, column 37): " + [ v.constructor.name ]);
  };
  var modeFromString = function (v) {
      if (v === "Authors") {
          return new Data_Maybe.Just(Authors.value);
      };
      if (v === "Institutes") {
          return new Data_Maybe.Just(Institutes.value);
      };
      if (v === "Sources") {
          return new Data_Maybe.Just(Sources.value);
      };
      if (v === "Terms") {
          return new Data_Maybe.Just(Terms.value);
      };
      return Data_Maybe.Nothing.value;
  };
  var isPublic = function (v) {
      if (v instanceof NodePublic) {
          return true;
      };
      if (v instanceof FolderPublic) {
          return true;
      };
      return false;
  };
  var flipHanded = function (l) {
      return function (r) {
          return function (v) {
              if (v instanceof LeftHanded) {
                  return Reactix_React.fragment([ r, l ]);
              };
              if (v instanceof RightHanded) {
                  return Reactix_React.fragment([ l, r ]);
              };
              throw new Error("Failed pattern match at Gargantext.Types (line 33, column 1 - line 33, column 60): " + [ l.constructor.name, r.constructor.name, v.constructor.name ]);
          };
      };
  };
  var fldr = function ($copy_v) {
      return function ($copy_v1) {
          var $tco_var_v = $copy_v;
          var $tco_done = false;
          var $tco_result;
          function $tco_loop(v, v1) {
              if (v instanceof NodeUser && !v1) {
                  $tco_done = true;
                  return "fa fa-user-circle";
              };
              if (v instanceof NodeUser && v1) {
                  $tco_done = true;
                  return "fa fa-user";
              };
              if (v instanceof Folder && !v1) {
                  $tco_done = true;
                  return "fa fa-folder";
              };
              if (v instanceof Folder && v1) {
                  $tco_done = true;
                  return "fa fa-folder-open-o";
              };
              if (v instanceof FolderPrivate && v1) {
                  $tco_done = true;
                  return "fa fa-lock";
              };
              if (v instanceof FolderPrivate && !v1) {
                  $tco_done = true;
                  return "fa fa-lock-circle";
              };
              if (v instanceof FolderShared && v1) {
                  $tco_done = true;
                  return "fa fa-share-alt";
              };
              if (v instanceof FolderShared && !v1) {
                  $tco_done = true;
                  return "fa fa-share-circle";
              };
              if (v instanceof Team && v1) {
                  $tco_done = true;
                  return "fa fa-users";
              };
              if (v instanceof Team && !v1) {
                  $tco_done = true;
                  return "fa fa-users-closed";
              };
              if (v instanceof FolderPublic && v1) {
                  $tco_done = true;
                  return "fa fa-globe-circle";
              };
              if (v instanceof FolderPublic && !v1) {
                  $tco_done = true;
                  return "fa fa-globe";
              };
              if (v instanceof Corpus && v1) {
                  $tco_done = true;
                  return "fa fa-book";
              };
              if (v instanceof Corpus && !v1) {
                  $tco_done = true;
                  return "fa fa-book-circle";
              };
              if (v instanceof Phylo) {
                  $tco_done = true;
                  return "fa fa-code-fork";
              };
              if (v instanceof Graph) {
                  $tco_done = true;
                  return "fa fa-hubzilla";
              };
              if (v instanceof Texts) {
                  $tco_done = true;
                  return "fa fa-newspaper-o";
              };
              if (v instanceof Dashboard) {
                  $tco_done = true;
                  return "fa fa-signal";
              };
              if (v instanceof NodeList) {
                  $tco_done = true;
                  return "fa fa-list";
              };
              if (v instanceof NodeFile) {
                  $tco_done = true;
                  return "fa fa-file";
              };
              if (v instanceof Annuaire && v1) {
                  $tco_done = true;
                  return "fa fa-address-card-o";
              };
              if (v instanceof Annuaire && !v1) {
                  $tco_done = true;
                  return "fa fa-address-card";
              };
              if (v instanceof NodeContact && v1) {
                  $tco_done = true;
                  return "fa fa-address-card-o";
              };
              if (v instanceof NodeContact && !v1) {
                  $tco_done = true;
                  return "fa fa-address-card";
              };
              if (v instanceof NodeFrameWrite && v1) {
                  $tco_done = true;
                  return "fa fa-file-text-o";
              };
              if (v instanceof NodeFrameWrite && !v1) {
                  $tco_done = true;
                  return "fa fa-file-text";
              };
              if (v instanceof NodeFrameCalc && v1) {
                  $tco_done = true;
                  return "fa fa-calculator";
              };
              if (v instanceof NodeFrameCalc && !v1) {
                  $tco_done = true;
                  return "fa fa-calculator";
              };
              if (v instanceof NodeFrameNotebook && v1) {
                  $tco_done = true;
                  return "fa fa-file-code-o";
              };
              if (v instanceof NodeFrameNotebook && !v1) {
                  $tco_done = true;
                  return "fa fa-code";
              };
              if (v instanceof NodeFrameVisio && v1) {
                  $tco_done = true;
                  return "fa fa-video-camera";
              };
              if (v instanceof NodeFrameVisio && !v1) {
                  $tco_done = true;
                  return "fa fa-video-camera";
              };
              if (v instanceof NodePublic) {
                  $tco_var_v = v.value0;
                  $copy_v1 = v1;
                  return;
              };
              if (v1) {
                  $tco_done = true;
                  return "fa fa-folder-open";
              };
              if (!v1) {
                  $tco_done = true;
                  return "fa fa-folder-o";
              };
              throw new Error("Failed pattern match at Gargantext.Types (line 229, column 1 - line 229, column 38): " + [ v.constructor.name, v1.constructor.name ]);
          };
          while (!$tco_done) {
              $tco_result = $tco_loop($tco_var_v, $copy_v1);
          };
          return $tco_result;
      };
  };
  var asyncTaskTypePath = function (v) {
      if (v instanceof AddNode) {
          return "async/nobody/";
      };
      if (v instanceof Form) {
          return "add/form/async/";
      };
      if (v instanceof GraphRecompute) {
          return "async/recompute/";
      };
      if (v instanceof Query) {
          return "query/";
      };
      if (v instanceof UpdateNgramsCharts) {
          return "ngrams/async/charts/update/";
      };
      if (v instanceof UpdateNode) {
          return "update/";
      };
      if (v instanceof UploadFile) {
          return "async/file/add/";
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 590, column 1 - line 590, column 45): " + [ v.constructor.name ]);
  };
  var $dollar_WriteForeignTabType_151 = new Simple_JSON.WriteForeign(function (v) {
      if (v instanceof TabCorpus && v.value0 instanceof TabDocs) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Docs");
      };
      if (v instanceof TabCorpus && (v.value0 instanceof TabNgramType && v.value0.value0 instanceof CTabAuthors)) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Authors");
      };
      if (v instanceof TabCorpus && (v.value0 instanceof TabNgramType && v.value0.value0 instanceof CTabInstitutes)) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Institutes");
      };
      if (v instanceof TabCorpus && (v.value0 instanceof TabNgramType && v.value0.value0 instanceof CTabSources)) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Sources");
      };
      if (v instanceof TabCorpus && (v.value0 instanceof TabNgramType && v.value0.value0 instanceof CTabTerms)) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Terms");
      };
      if (v instanceof TabCorpus && v.value0 instanceof TabMoreLikeFav) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("MoreFav");
      };
      if (v instanceof TabCorpus && v.value0 instanceof TabMoreLikeTrash) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("MoreTrash");
      };
      if (v instanceof TabCorpus && v.value0 instanceof TabTrash) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Trash");
      };
      if (v instanceof TabDocument && v.value0 instanceof TabDocs) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Docs");
      };
      if (v instanceof TabDocument && (v.value0 instanceof TabNgramType && v.value0.value0 instanceof CTabAuthors)) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Authors");
      };
      if (v instanceof TabDocument && (v.value0 instanceof TabNgramType && v.value0.value0 instanceof CTabInstitutes)) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Institutes");
      };
      if (v instanceof TabDocument && (v.value0 instanceof TabNgramType && v.value0.value0 instanceof CTabSources)) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Sources");
      };
      if (v instanceof TabDocument && (v.value0 instanceof TabNgramType && v.value0.value0 instanceof CTabTerms)) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Terms");
      };
      if (v instanceof TabDocument && v.value0 instanceof TabMoreLikeFav) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("MoreFav");
      };
      if (v instanceof TabDocument && v.value0 instanceof TabMoreLikeTrash) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("MoreTrash");
      };
      if (v instanceof TabDocument && v.value0 instanceof TabTrash) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("Trash");
      };
      if (v instanceof TabPairing) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("TabPairing");
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 513, column 1 - line 530, column 86): " + [ v.constructor.name ]);
  });
  var $dollar_WriteForeignApiVersion_129 = new Simple_JSON.WriteForeign(function (v) {
      if (v instanceof V0) {
          return Foreign.unsafeToForeign(Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("v0"));
      };
      if (v instanceof V10) {
          return Foreign.unsafeToForeign(Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("v1.0"));
      };
      if (v instanceof V11) {
          return Foreign.unsafeToForeign(Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("v1.1"));
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 429, column 1 - line 432, column 60): " + [ v.constructor.name ]);
  });
  var $dollar_ShowTermSize_100 = new Data_Show.Show(function (v) {
      if (v instanceof MonoTerm) {
          return "MonoTerm";
      };
      if (v instanceof MultiTerm) {
          return "MultiTerm";
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 66, column 1 - line 68, column 31): " + [ v.constructor.name ]);
  });
  var $dollar_ShowTabSubType_146 = function (dictShow) {
      return new Data_Show.Show(function (v) {
          if (v instanceof TabDocs) {
              return "Docs";
          };
          if (v instanceof TabNgramType) {
              return Data_Show.show(dictShow)(v.value0);
          };
          if (v instanceof TabTrash) {
              return "Trash";
          };
          if (v instanceof TabMoreLikeFav) {
              return "MoreFav";
          };
          if (v instanceof TabMoreLikeTrash) {
              return "MoreTrash";
          };
          throw new Error("Failed pattern match at Gargantext.Types (line 497, column 1 - line 502, column 38): " + [ v.constructor.name ]);
      });
  };
  var $dollar_ShowSessionId_97 = new Data_Show.Show(function (v) {
      return v;
  });
  var nodePath = function (v) {
      var id = Data_Maybe.maybe("")(function (j) {
          return "/" + Data_Show.show(Data_Show.showInt)(j);
      })(v.value2);
      return nodeTypePath(v.value1) + ("/" + (Data_Show.show($dollar_ShowSessionId_97)(v.value0) + id));
  };
  var $dollar_ShowPTabNgramType_140 = new Data_Show.Show(function (v) {
      if (v instanceof PTabPatents) {
          return "Patents";
      };
      if (v instanceof PTabBooks) {
          return "Books";
      };
      if (v instanceof PTabCommunication) {
          return "Communication";
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 462, column 1 - line 465, column 43): " + [ v.constructor.name ]);
  });   
  var $dollar_ShowNodeType_117 = new Data_Show.Show(function (v) {
      if (v instanceof NodeUser) {
          return "NodeUser";
      };
      if (v instanceof Folder) {
          return "NodeFolder";
      };
      if (v instanceof FolderPrivate) {
          return "NodeFolderPrivate";
      };
      if (v instanceof FolderShared) {
          return "NodeFolderShared";
      };
      if (v instanceof FolderPublic) {
          return "NodeFolderPublic";
      };
      if (v instanceof Annuaire) {
          return "NodeAnnuaire";
      };
      if (v instanceof NodeContact) {
          return "NodeContact";
      };
      if (v instanceof Corpus) {
          return "NodeCorpus";
      };
      if (v instanceof Dashboard) {
          return "NodeDashboard";
      };
      if (v instanceof Url_Document) {
          return "NodeDocument";
      };
      if (v instanceof $$Error) {
          return "NodeError";
      };
      if (v instanceof Graph) {
          return "NodeGraph";
      };
      if (v instanceof Phylo) {
          return "NodePhylo";
      };
      if (v instanceof Individu) {
          return "NodeIndividu";
      };
      if (v instanceof Node) {
          return "Node";
      };
      if (v instanceof Nodes) {
          return "Nodes";
      };
      if (v instanceof Tree) {
          return "NodeTree";
      };
      if (v instanceof Team) {
          return "NodeTeam";
      };
      if (v instanceof NodeList) {
          return "NodeList";
      };
      if (v instanceof Texts) {
          return "NodeDocs";
      };
      if (v instanceof NodeFrameWrite) {
          return "NodeFrameWrite";
      };
      if (v instanceof NodeFrameCalc) {
          return "NodeFrameCalc";
      };
      if (v instanceof NodeFrameNotebook) {
          return "NodeFrameNotebook";
      };
      if (v instanceof NodeFrameVisio) {
          return "NodeFrameVisio";
      };
      if (v instanceof NodePublic) {
          return "NodePublic" + Data_Show.show($dollar_ShowNodeType_117)(v.value0);
      };
      if (v instanceof NodeFile) {
          return "NodeFile";
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 168, column 1 - line 196, column 36): " + [ v.constructor.name ]);
  });
  var $dollar_WriteForeignNodeType_116 = new Simple_JSON.WriteForeign((function () {
      var $872 = Simple_JSON.writeImpl(Simple_JSON.writeForeignString);
      var $873 = Data_Show.show($dollar_ShowNodeType_117);
      return function ($874) {
          return $872($873($874));
      };
  })());
  var prettyNodeType = function (nt) {
      return Data_String_Common.replace("Node")(" ")(Data_String_Common.replace("Folder")(" ")(Data_Show.show($dollar_ShowNodeType_117)(nt)));
  };
  var $dollar_ShowChartType_122 = new Data_Show.Show(function (v) {
      if (v instanceof Histo) {
          return "chart";
      };
      if (v instanceof Scatter) {
          return "scatter";
      };
      if (v instanceof ChartBar) {
          return "bar";
      };
      if (v instanceof ChartPie) {
          return "pie";
      };
      if (v instanceof ChartTree) {
          return "tree";
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 393, column 1 - line 399, column 28): " + [ v.constructor.name ]);
  });
  var $dollar_ShowCTabNgramType_135 = new Data_Show.Show(function (v) {
      if (v instanceof CTabTerms) {
          return "Terms";
      };
      if (v instanceof CTabSources) {
          return "Sources";
      };
      if (v instanceof CTabAuthors) {
          return "Authors";
      };
      if (v instanceof CTabInstitutes) {
          return "Institutes";
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 451, column 1 - line 455, column 37): " + [ v.constructor.name ]);
  });   
  var showTabType$prime = function (v) {
      if (v instanceof TabCorpus) {
          return Data_Show.show($dollar_ShowTabSubType_146($dollar_ShowCTabNgramType_135))(v.value0);
      };
      if (v instanceof TabDocument) {
          return Data_Show.show($dollar_ShowTabSubType_146($dollar_ShowCTabNgramType_135))(v.value0);
      };
      if (v instanceof TabPairing) {
          return Data_Show.show($dollar_ShowTabSubType_146($dollar_ShowPTabNgramType_140))(v.value0);
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 115, column 1 - line 115, column 34): " + [ v.constructor.name ]);
  };
  var $dollar_ShowApiVersion_130 = new Data_Show.Show(function (v) {
      if (v instanceof V0) {
          return "v0";
      };
      if (v instanceof V10) {
          return "v1.0";
      };
      if (v instanceof V11) {
          return "v1.1";
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 434, column 1 - line 437, column 20): " + [ v.constructor.name ]);
  });
  var $dollar_ReadTermSize_101 = new Gargantext_Prelude.Read(function (v) {
      if (v === "MonoTerm") {
          return new Data_Maybe.Just(MonoTerm.value);
      };
      if (v === "MultiTerm") {
          return new Data_Maybe.Just(MultiTerm.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var $dollar_ReadTermList_108 = new Gargantext_Prelude.Read(function (v) {
      if (v === "MapTerm") {
          return new Data_Maybe.Just(MapTerm.value);
      };
      if (v === "StopTerm") {
          return new Data_Maybe.Just(StopTerm.value);
      };
      if (v === "CandidateTerm") {
          return new Data_Maybe.Just(CandidateTerm.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var $dollar_ReadNodeType_118 = new Gargantext_Prelude.Read(function (v) {
      if (v === "NodeUser") {
          return new Data_Maybe.Just(NodeUser.value);
      };
      if (v === "NodeFolder") {
          return new Data_Maybe.Just(Folder.value);
      };
      if (v === "NodeFolderPrivate") {
          return new Data_Maybe.Just(FolderPrivate.value);
      };
      if (v === "NodeFolderShared") {
          return new Data_Maybe.Just(FolderShared.value);
      };
      if (v === "NodeFolderPublic") {
          return new Data_Maybe.Just(FolderPublic.value);
      };
      if (v === "NodeAnnuaire") {
          return new Data_Maybe.Just(Annuaire.value);
      };
      if (v === "NodeDashboard") {
          return new Data_Maybe.Just(Dashboard.value);
      };
      if (v === "Document") {
          return new Data_Maybe.Just(Url_Document.value);
      };
      if (v === "NodeGraph") {
          return new Data_Maybe.Just(Graph.value);
      };
      if (v === "NodePhylo") {
          return new Data_Maybe.Just(Phylo.value);
      };
      if (v === "Individu") {
          return new Data_Maybe.Just(Individu.value);
      };
      if (v === "Node") {
          return new Data_Maybe.Just(Node.value);
      };
      if (v === "Nodes") {
          return new Data_Maybe.Just(Nodes.value);
      };
      if (v === "NodeCorpus") {
          return new Data_Maybe.Just(Corpus.value);
      };
      if (v === "NodeContact") {
          return new Data_Maybe.Just(NodeContact.value);
      };
      if (v === "Tree") {
          return new Data_Maybe.Just(Tree.value);
      };
      if (v === "NodeTeam") {
          return new Data_Maybe.Just(Team.value);
      };
      if (v === "NodeList") {
          return new Data_Maybe.Just(NodeList.value);
      };
      if (v === "NodeTexts") {
          return new Data_Maybe.Just(Texts.value);
      };
      if (v === "Annuaire") {
          return new Data_Maybe.Just(Annuaire.value);
      };
      if (v === "NodeFrameWrite") {
          return new Data_Maybe.Just(NodeFrameWrite.value);
      };
      if (v === "NodeFrameCalc") {
          return new Data_Maybe.Just(NodeFrameCalc.value);
      };
      if (v === "NodeFrameNotebook") {
          return new Data_Maybe.Just(NodeFrameNotebook.value);
      };
      if (v === "NodeFrameVisio") {
          return new Data_Maybe.Just(NodeFrameVisio.value);
      };
      if (v === "NodeFile") {
          return new Data_Maybe.Just(NodeFile.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var $dollar_ReadForeignNodeType_115 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Foreign.readString(Data_Identity.monadIdentity)(f))(function (s) {
          var v = Gargantext_Prelude.read($dollar_ReadNodeType_118)(s);
          if (v instanceof Data_Maybe.Nothing) {
              return Foreign.fail(Data_Identity.monadIdentity)(Foreign.ErrorAtProperty.create(s)(new Foreign.ForeignError("unknown property")));
          };
          if (v instanceof Data_Maybe.Just) {
              return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(v.value0);
          };
          throw new Error("Failed pattern match at Gargantext.Types (line 163, column 5 - line 165, column 25): " + [ v.constructor.name ]);
      });
  });
  var $dollar_ReadForeignAsyncTaskLog_178 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "events";
  }))(Simple_JSON.readArray(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "failed";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "remaining";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "succeeded";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()())()())()());
  var $dollar_GenericTermSize__98 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof MonoTerm) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof MultiTerm) {
          return new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value);
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 59, column 1 - line 59, column 35): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return MonoTerm.value;
      };
      if (x instanceof Data_Generic_Rep.Inr) {
          return MultiTerm.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 59, column 1 - line 59, column 35): " + [ x.constructor.name ]);
  });
  var $dollar_GenericTermList__102 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof MapTerm) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof StopTerm) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof CandidateTerm) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value));
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 84, column 1 - line 84, column 35): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return MapTerm.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return StopTerm.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inr) {
          return CandidateTerm.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 84, column 1 - line 84, column 35): " + [ x.constructor.name ]);
  });
  var $dollar_ReadForeignTermList_106 = new Simple_JSON.ReadForeign(Simple_JSON_Generics_EnumSumRep.enumSumRep($dollar_GenericTermList__102)(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "MapTerm";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "StopTerm";
  })))(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "CandidateTerm";
  }))))));
  var $dollar_ShowTermList_107 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericTermList__102)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "MapTerm";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "StopTerm";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "CandidateTerm";
  }))))));
  var $dollar_WriteForeignTermList_105 = new Simple_JSON.WriteForeign((function () {
      var $878 = Simple_JSON.writeImpl(Simple_JSON.writeForeignString);
      var $879 = Data_Show.show($dollar_ShowTermList_107);
      return function ($880) {
          return $878($879($880));
      };
  })());  
  var $dollar_GenericTabSubType__142 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof TabDocs) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof TabNgramType) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(x.value0));
      };
      if (x instanceof TabTrash) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof TabMoreLikeFav) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
      };
      if (x instanceof TabMoreLikeTrash) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))));
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 469, column 1 - line 469, column 41): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return TabDocs.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return new TabNgramType(x.value0.value0);
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return TabTrash.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
          return TabMoreLikeFav.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inr))) {
          return TabMoreLikeTrash.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 469, column 1 - line 469, column 41): " + [ x.constructor.name ]);
  });
  var $dollar_GenericSidePanelState__179 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof InitialClosed) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof Opened) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof Closed) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value));
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 686, column 1 - line 686, column 41): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return InitialClosed.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return Opened.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inr) {
          return Closed.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 686, column 1 - line 686, column 41): " + [ x.constructor.name ]);
  });
  var $dollar_GenericSessionId__95 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericScoreType__119 = new Data_Generic_Rep.Generic(function (x) {
      return Data_Generic_Rep.NoArguments.value;
  }, function (x) {
      return Occurrences.value;
  });
  var $dollar_ShowScoreType_121 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericScoreType__119)(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Occurrences";
  }))));
  var $dollar_GenericPTabNgramType__137 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof PTabPatents) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof PTabBooks) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof PTabCommunication) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value));
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 459, column 1 - line 459, column 40): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return PTabPatents.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return PTabBooks.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inr) {
          return PTabCommunication.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 459, column 1 - line 459, column 40): " + [ x.constructor.name ]);
  });
  var $dollar_GenericOrderBy__123 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof DateAsc) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof DateDesc) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof TitleAsc) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof TitleDesc) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
      };
      if (x instanceof ScoreAsc) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)))));
      };
      if (x instanceof ScoreDesc) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))))));
      };
      if (x instanceof TermAsc) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)))))));
      };
      if (x instanceof TermDesc) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))))))));
      };
      if (x instanceof SourceAsc) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)))))))));
      };
      if (x instanceof SourceDesc) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value)))))))));
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 418, column 1 - line 418, column 34): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return DateAsc.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return DateDesc.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return TitleAsc.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
          return TitleDesc.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl)))) {
          return ScoreAsc.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl))))) {
          return ScoreDesc.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl)))))) {
          return TermAsc.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl))))))) {
          return TermDesc.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl)))))))) {
          return SourceAsc.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr)))))))) {
          return SourceDesc.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 418, column 1 - line 418, column 34): " + [ x.constructor.name ]);
  });            
  var $dollar_ShowOrderBy_124 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericOrderBy__123)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "DateAsc";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "DateDesc";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "TitleAsc";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "TitleDesc";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "ScoreAsc";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "ScoreDesc";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "TermAsc";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "TermDesc";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "SourceAsc";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "SourceDesc";
  })))))))))))));
  var $dollar_GenericMode__152 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Authors) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof Sources) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof Institutes) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof Terms) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value)));
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 552, column 1 - line 552, column 31): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return Authors.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return Sources.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return Institutes.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inr)) {
          return Terms.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 552, column 1 - line 552, column 31): " + [ x.constructor.name ]);
  });   
  var $dollar_GenericHanded__93 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof LeftHanded) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof RightHanded) {
          return new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value);
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 37, column 1 - line 37, column 33): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return LeftHanded.value;
      };
      if (x instanceof Data_Generic_Rep.Inr) {
          return RightHanded.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 37, column 1 - line 37, column 33): " + [ x.constructor.name ]);
  });
  var $dollar_GenericAsyncTask__165 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericAsyncTaskWithType__169 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericAsyncTaskType__157 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof AddNode) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof Form) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof GraphRecompute) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof Query) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
      };
      if (x instanceof UpdateNgramsCharts) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)))));
      };
      if (x instanceof UpdateNode) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))))));
      };
      if (x instanceof UploadFile) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))))));
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 582, column 1 - line 582, column 40): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return AddNode.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return Form.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return GraphRecompute.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
          return Query.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl)))) {
          return UpdateNgramsCharts.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl))))) {
          return UpdateNode.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr))))) {
          return UploadFile.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 582, column 1 - line 582, column 40): " + [ x.constructor.name ]);
  });
  var $dollar_ReadForeignAsyncTaskType_158 = new Simple_JSON.ReadForeign(Simple_JSON_Generics_EnumSumRep.enumSumRep($dollar_GenericAsyncTaskType__157)(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "AddNode";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "Form";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "GraphRecompute";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "Query";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "UpdateNgramsCharts";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "UpdateNode";
  })))(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "UploadFile";
  }))))))))));
  var $dollar_GenericAsyncTaskStatus__161 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof IsRunning) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof IsPending) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof IsReceived) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof IsStarted) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
      };
      if (x instanceof IsFailure) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)))));
      };
      if (x instanceof IsFinished) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))))));
      };
      if (x instanceof IsKilled) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))))));
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 609, column 1 - line 609, column 42): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return IsRunning.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return IsPending.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return IsReceived.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
          return IsStarted.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl)))) {
          return IsFailure.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl))))) {
          return IsFinished.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr))))) {
          return IsKilled.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 609, column 1 - line 609, column 42): " + [ x.constructor.name ]);
  });
  var $dollar_ReadForeignAsyncTaskStatu_162 = new Simple_JSON.ReadForeign(Simple_JSON_Generics_EnumSumRep.enumSumRep($dollar_GenericAsyncTaskStatus__161)(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "IsRunning";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "IsPending";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "IsReceived";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "IsStarted";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "IsFailure";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "IsFinished";
  })))(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "IsKilled";
  }))))))))));
  var $dollar_ReadForeignAsyncProgress_175 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "log";
  }))(Simple_JSON.readArray($dollar_ReadForeignAsyncTaskLog_178))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "status";
  }))($dollar_ReadForeignAsyncTaskStatu_162)(Simple_JSON.readFieldsNil)()())()())()());
  var $dollar_ReadForeignAsyncTask_167 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "status";
  }))($dollar_ReadForeignAsyncTaskStatu_162)(Simple_JSON.readFieldsNil)()())()());
  var $dollar_ReadForeignAsyncTaskWithT_171 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "task";
  }))($dollar_ReadForeignAsyncTask_167)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "typ";
  }))($dollar_ReadForeignAsyncTaskType_158)(Simple_JSON.readFieldsNil)()())()());
  var $dollar_GenericApiVersion__127 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof V0) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof V10) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof V11) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value));
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 427, column 1 - line 427, column 37): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return V0.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return V10.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inr) {
          return V11.value;
      };
      throw new Error("Failed pattern match at Gargantext.Types (line 427, column 1 - line 427, column 37): " + [ x.constructor.name ]);
  });
  var $dollar_ReadForeignApiVersion_128 = new Simple_JSON.ReadForeign(Simple_JSON_Generics_EnumSumRep.enumSumRep($dollar_GenericApiVersion__127)(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "V0";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "V10";
  })))(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "V11";
  }))))));
  var $dollar_EqTermSize_99 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericTermSize__98)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))));
  var $dollar_EqTermList_103 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericTermList__102)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)))));
  var $dollar_OrdTermList_104 = new Data_Ord.Ord(function () {
      return $dollar_EqTermList_103;
  }, Data_Ord_Generic.genericCompare($dollar_GenericTermList__102)(Data_Ord_Generic.genericOrdSum(Data_Ord_Generic.genericOrdConstructor(Data_Ord_Generic.genericOrdNoArguments))(Data_Ord_Generic.genericOrdSum(Data_Ord_Generic.genericOrdConstructor(Data_Ord_Generic.genericOrdNoArguments))(Data_Ord_Generic.genericOrdConstructor(Data_Ord_Generic.genericOrdNoArguments)))));
  var $dollar_EqTabSubType_143 = function (dictEq) {
      return new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericTabSubType__142)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(dictEq)))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)))))));
  };
  var $dollar_EqSidePanelState_180 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericSidePanelState__179)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)))));
  var $dollar_EqSessionId_96 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericSessionId__95)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqString))));
  var $dollar_EqScoreType_120 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericScoreType__119)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)));
  var $dollar_EqPTabNgramType_138 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericPTabNgramType__137)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)))));
  var $dollar_EqNodeType_114 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof Annuaire && y instanceof Annuaire) {
              return true;
          };
          if (x instanceof Corpus && y instanceof Corpus) {
              return true;
          };
          if (x instanceof Dashboard && y instanceof Dashboard) {
              return true;
          };
          if (x instanceof $$Error && y instanceof $$Error) {
              return true;
          };
          if (x instanceof Folder && y instanceof Folder) {
              return true;
          };
          if (x instanceof FolderPrivate && y instanceof FolderPrivate) {
              return true;
          };
          if (x instanceof FolderPublic && y instanceof FolderPublic) {
              return true;
          };
          if (x instanceof FolderShared && y instanceof FolderShared) {
              return true;
          };
          if (x instanceof Graph && y instanceof Graph) {
              return true;
          };
          if (x instanceof Individu && y instanceof Individu) {
              return true;
          };
          if (x instanceof Node && y instanceof Node) {
              return true;
          };
          if (x instanceof NodeContact && y instanceof NodeContact) {
              return true;
          };
          if (x instanceof NodeList && y instanceof NodeList) {
              return true;
          };
          if (x instanceof NodeUser && y instanceof NodeUser) {
              return true;
          };
          if (x instanceof Nodes && y instanceof Nodes) {
              return true;
          };
          if (x instanceof Phylo && y instanceof Phylo) {
              return true;
          };
          if (x instanceof Team && y instanceof Team) {
              return true;
          };
          if (x instanceof Texts && y instanceof Texts) {
              return true;
          };
          if (x instanceof Tree && y instanceof Tree) {
              return true;
          };
          if (x instanceof Url_Document && y instanceof Url_Document) {
              return true;
          };
          if (x instanceof NodeFile && y instanceof NodeFile) {
              return true;
          };
          if (x instanceof NodeFrameCalc && y instanceof NodeFrameCalc) {
              return true;
          };
          if (x instanceof NodeFrameNotebook && y instanceof NodeFrameNotebook) {
              return true;
          };
          if (x instanceof NodeFrameWrite && y instanceof NodeFrameWrite) {
              return true;
          };
          if (x instanceof NodeFrameVisio && y instanceof NodeFrameVisio) {
              return true;
          };
          if (x instanceof NodePublic && y instanceof NodePublic) {
              return Data_Eq.eq($dollar_EqNodeType_114)(x.value0)(y.value0);
          };
          return false;
      };
  });
  var $dollar_EqMode_154 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericMode__152)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))))));
  var $dollar_OrdMode_155 = new Data_Ord.Ord(function () {
      return $dollar_EqMode_154;
  }, Data_Ord_Generic.genericCompare($dollar_GenericMode__152)(Data_Ord_Generic.genericOrdSum(Data_Ord_Generic.genericOrdConstructor(Data_Ord_Generic.genericOrdNoArguments))(Data_Ord_Generic.genericOrdSum(Data_Ord_Generic.genericOrdConstructor(Data_Ord_Generic.genericOrdNoArguments))(Data_Ord_Generic.genericOrdSum(Data_Ord_Generic.genericOrdConstructor(Data_Ord_Generic.genericOrdNoArguments))(Data_Ord_Generic.genericOrdConstructor(Data_Ord_Generic.genericOrdNoArguments))))));
  var $dollar_EqHanded_94 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHanded__93)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))));
  var $dollar_EqCTabNgramType_133 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof CTabTerms && y instanceof CTabTerms) {
              return true;
          };
          if (x instanceof CTabSources && y instanceof CTabSources) {
              return true;
          };
          if (x instanceof CTabAuthors && y instanceof CTabAuthors) {
              return true;
          };
          if (x instanceof CTabInstitutes && y instanceof CTabInstitutes) {
              return true;
          };
          return false;
      };
  });
  var $dollar_EqTabType_148 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof TabCorpus && y instanceof TabCorpus) {
              return Data_Eq.eq($dollar_EqTabSubType_143($dollar_EqCTabNgramType_133))(x.value0)(y.value0);
          };
          if (x instanceof TabPairing && y instanceof TabPairing) {
              return Data_Eq.eq($dollar_EqTabSubType_143($dollar_EqPTabNgramType_138))(x.value0)(y.value0);
          };
          if (x instanceof TabDocument && y instanceof TabDocument) {
              return Data_Eq.eq($dollar_EqTabSubType_143($dollar_EqCTabNgramType_133))(x.value0)(y.value0);
          };
          return false;
      };
  });
  var $dollar_EqAsyncTaskType_159 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericAsyncTaskType__157)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)))))))));
  var $dollar_EqAsyncTaskStatus_164 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof IsRunning && y instanceof IsRunning) {
              return true;
          };
          if (x instanceof IsPending && y instanceof IsPending) {
              return true;
          };
          if (x instanceof IsReceived && y instanceof IsReceived) {
              return true;
          };
          if (x instanceof IsStarted && y instanceof IsStarted) {
              return true;
          };
          if (x instanceof IsFailure && y instanceof IsFailure) {
              return true;
          };
          if (x instanceof IsFinished && y instanceof IsFinished) {
              return true;
          };
          if (x instanceof IsKilled && y instanceof IsKilled) {
              return true;
          };
          return false;
      };
  });
  var $dollar_EqAsyncTask_168 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericAsyncTask__165)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "status";
  }))($dollar_EqAsyncTaskStatus_164))()(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Data_Eq.eqString))))));
  var $dollar_EqAsyncTaskWithType_172 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericAsyncTaskWithType__169)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "typ";
  }))($dollar_EqAsyncTaskType_159))()(new Data_Symbol.IsSymbol(function () {
      return "task";
  }))($dollar_EqAsyncTask_168))))));
  var $dollar_EqApiVersion_131 = new Data_Eq.Eq(function (v) {
      return function (v1) {
          if (v instanceof V10 && v1 instanceof V10) {
              return true;
          };
          if (v instanceof V11 && v1 instanceof V11) {
              return true;
          };
          return false;
      };
  });
  exports["LeftHanded"] = LeftHanded;
  exports["RightHanded"] = RightHanded;
  exports["switchHanded"] = switchHanded;
  exports["reverseHanded"] = reverseHanded;
  exports["flipHanded"] = flipHanded;
  exports["SessionId"] = SessionId;
  exports["MonoTerm"] = MonoTerm;
  exports["MultiTerm"] = MultiTerm;
  exports["termSizes"] = termSizes;
  exports["MapTerm"] = MapTerm;
  exports["StopTerm"] = StopTerm;
  exports["CandidateTerm"] = CandidateTerm;
  exports["termListName"] = termListName;
  exports["termLists"] = termLists;
  exports["showTabType'"] = showTabType$prime;
  exports["Annuaire"] = Annuaire;
  exports["Corpus"] = Corpus;
  exports["Dashboard"] = Dashboard;
  exports["Error"] = $$Error;
  exports["Folder"] = Folder;
  exports["FolderPrivate"] = FolderPrivate;
  exports["FolderPublic"] = FolderPublic;
  exports["FolderShared"] = FolderShared;
  exports["Graph"] = Graph;
  exports["Node"] = Node;
  exports["NodeContact"] = NodeContact;
  exports["NodeList"] = NodeList;
  exports["NodeUser"] = NodeUser;
  exports["Phylo"] = Phylo;
  exports["Team"] = Team;
  exports["Texts"] = Texts;
  exports["Tree"] = Tree;
  exports["Url_Document"] = Url_Document;
  exports["NodeFile"] = NodeFile;
  exports["NodeFrameCalc"] = NodeFrameCalc;
  exports["NodeFrameNotebook"] = NodeFrameNotebook;
  exports["NodeFrameWrite"] = NodeFrameWrite;
  exports["NodeFrameVisio"] = NodeFrameVisio;
  exports["NodePublic"] = NodePublic;
  exports["fldr"] = fldr;
  exports["publicize"] = publicize;
  exports["isPublic"] = isPublic;
  exports["nodeTypePath"] = nodeTypePath;
  exports["Occurrences"] = Occurrences;
  exports["NodePath"] = NodePath;
  exports["nodePath"] = nodePath;
  exports["Histo"] = Histo;
  exports["Scatter"] = Scatter;
  exports["ChartPie"] = ChartPie;
  exports["ChartBar"] = ChartBar;
  exports["ChartTree"] = ChartTree;
  exports["DateAsc"] = DateAsc;
  exports["DateDesc"] = DateDesc;
  exports["TitleAsc"] = TitleAsc;
  exports["TitleDesc"] = TitleDesc;
  exports["ScoreAsc"] = ScoreAsc;
  exports["ScoreDesc"] = ScoreDesc;
  exports["TermAsc"] = TermAsc;
  exports["TermDesc"] = TermDesc;
  exports["SourceAsc"] = SourceAsc;
  exports["SourceDesc"] = SourceDesc;
  exports["V10"] = V10;
  exports["CTabTerms"] = CTabTerms;
  exports["CTabSources"] = CTabSources;
  exports["CTabAuthors"] = CTabAuthors;
  exports["CTabInstitutes"] = CTabInstitutes;
  exports["PTabPatents"] = PTabPatents;
  exports["PTabBooks"] = PTabBooks;
  exports["PTabCommunication"] = PTabCommunication;
  exports["TabDocs"] = TabDocs;
  exports["TabNgramType"] = TabNgramType;
  exports["TabTrash"] = TabTrash;
  exports["TabMoreLikeFav"] = TabMoreLikeFav;
  exports["TabMoreLikeTrash"] = TabMoreLikeTrash;
  exports["TabCorpus"] = TabCorpus;
  exports["TabPairing"] = TabPairing;
  exports["TabDocument"] = TabDocument;
  exports["Authors"] = Authors;
  exports["Sources"] = Sources;
  exports["Institutes"] = Institutes;
  exports["Terms"] = Terms;
  exports["modeTabType"] = modeTabType;
  exports["modeFromString"] = modeFromString;
  exports["Form"] = Form;
  exports["Query"] = Query;
  exports["UpdateNgramsCharts"] = UpdateNgramsCharts;
  exports["UpdateNode"] = UpdateNode;
  exports["UploadFile"] = UploadFile;
  exports["asyncTaskTypePath"] = asyncTaskTypePath;
  exports["IsFailure"] = IsFailure;
  exports["IsFinished"] = IsFinished;
  exports["IsKilled"] = IsKilled;
  exports["progressPercent"] = progressPercent;
  exports["prettyNodeType"] = prettyNodeType;
  exports["InitialClosed"] = InitialClosed;
  exports["Opened"] = Opened;
  exports["Closed"] = Closed;
  exports["toggleSidePanelState"] = toggleSidePanelState;
  exports["$_EqHanded_94"] = $dollar_EqHanded_94;
  exports["$_EqSessionId_96"] = $dollar_EqSessionId_96;
  exports["$_ShowSessionId_97"] = $dollar_ShowSessionId_97;
  exports["$_EqTermSize_99"] = $dollar_EqTermSize_99;
  exports["$_ShowTermSize_100"] = $dollar_ShowTermSize_100;
  exports["$_ReadTermSize_101"] = $dollar_ReadTermSize_101;
  exports["$_EqTermList_103"] = $dollar_EqTermList_103;
  exports["$_OrdTermList_104"] = $dollar_OrdTermList_104;
  exports["$_WriteForeignTermList_105"] = $dollar_WriteForeignTermList_105;
  exports["$_ReadForeignTermList_106"] = $dollar_ReadForeignTermList_106;
  exports["$_ShowTermList_107"] = $dollar_ShowTermList_107;
  exports["$_ReadTermList_108"] = $dollar_ReadTermList_108;
  exports["$_EqNodeType_114"] = $dollar_EqNodeType_114;
  exports["$_ReadForeignNodeType_115"] = $dollar_ReadForeignNodeType_115;
  exports["$_WriteForeignNodeType_116"] = $dollar_WriteForeignNodeType_116;
  exports["$_ShowNodeType_117"] = $dollar_ShowNodeType_117;
  exports["$_ReadNodeType_118"] = $dollar_ReadNodeType_118;
  exports["$_EqScoreType_120"] = $dollar_EqScoreType_120;
  exports["$_ShowScoreType_121"] = $dollar_ShowScoreType_121;
  exports["$_ShowChartType_122"] = $dollar_ShowChartType_122;
  exports["$_ShowOrderBy_124"] = $dollar_ShowOrderBy_124;
  exports["$_ReadForeignApiVersion_128"] = $dollar_ReadForeignApiVersion_128;
  exports["$_WriteForeignApiVersion_129"] = $dollar_WriteForeignApiVersion_129;
  exports["$_ShowApiVersion_130"] = $dollar_ShowApiVersion_130;
  exports["$_EqApiVersion_131"] = $dollar_EqApiVersion_131;
  exports["$_ShowCTabNgramType_135"] = $dollar_ShowCTabNgramType_135;
  exports["$_ShowTabSubType_146"] = $dollar_ShowTabSubType_146;
  exports["$_EqTabType_148"] = $dollar_EqTabType_148;
  exports["$_WriteForeignTabType_151"] = $dollar_WriteForeignTabType_151;
  exports["$_EqMode_154"] = $dollar_EqMode_154;
  exports["$_OrdMode_155"] = $dollar_OrdMode_155;
  exports["$_EqAsyncTaskStatus_164"] = $dollar_EqAsyncTaskStatus_164;
  exports["$_ReadForeignAsyncTask_167"] = $dollar_ReadForeignAsyncTask_167;
  exports["$_ReadForeignAsyncTaskWithT_171"] = $dollar_ReadForeignAsyncTaskWithT_171;
  exports["$_EqAsyncTaskWithType_172"] = $dollar_EqAsyncTaskWithType_172;
  exports["$_ReadForeignAsyncProgress_175"] = $dollar_ReadForeignAsyncProgress_175;
  exports["$_EqSidePanelState_180"] = $dollar_EqSidePanelState_180;
})(PS);
(function(exports) {
  "use strict";

  exports.window = function () {
    return window;
  };
})(PS["Web.HTML"] = PS["Web.HTML"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.HTML"] = $PS["Web.HTML"] || {};
  var exports = $PS["Web.HTML"];
  var $foreign = $PS["Web.HTML"];
  exports["window"] = $foreign.window;
})(PS);
(function(exports) {
  "use strict";

  exports.hash = function (location) {
    return function () {
      return location.hash;
    };
  };

  // ----------------------------------------------------------------------------

  exports.href = function (location) {
    return function () {
      return location.href;
    };
  };
})(PS["Web.HTML.Location"] = PS["Web.HTML.Location"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.HTML.Location"] = $PS["Web.HTML.Location"] || {};
  var exports = $PS["Web.HTML.Location"];
  var $foreign = $PS["Web.HTML.Location"];
  exports["hash"] = $foreign.hash;
  exports["href"] = $foreign.href;
})(PS);
(function(exports) {
  "use strict";

  exports.location = function (window) {
    return function () {
      return window.location;
    };
  };

  exports.localStorage = function (window) {
    return function () {
      return window.localStorage;
    };
  };
})(PS["Web.HTML.Window"] = PS["Web.HTML.Window"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.HTML.Window"] = $PS["Web.HTML.Window"] || {};
  var exports = $PS["Web.HTML.Window"];
  var $foreign = $PS["Web.HTML.Window"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];
  var toEventTarget = Unsafe_Coerce.unsafeCoerce;
  exports["toEventTarget"] = toEventTarget;
  exports["location"] = $foreign.location;
  exports["localStorage"] = $foreign.localStorage;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils"] = $PS["Gargantext.Utils"] || {};
  var exports = $PS["Gargantext.Utils"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Either = $PS["Data.Either"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence_Ordered = $PS["Data.Sequence.Ordered"];
  var Data_Set = $PS["Data.Set"];
  var Data_Show = $PS["Data.Show"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_String_Pattern = $PS["Data.String.Pattern"];
  var Web_HTML = $PS["Web.HTML"];
  var Web_HTML_Location = $PS["Web.HTML.Location"];
  var Web_HTML_Window = $PS["Web.HTML.Window"];                
  var On = (function () {
      function On(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      On.create = function (value0) {
          return function (value1) {
              return new On(value0, value1);
          };
      };
      return On;
  })();
  var zeroPad = function (pad) {
      return function (num) {
          var zeros$prime = function (v) {
              if (v === 0) {
                  return "";
              };
              return "0" + zeros$prime(v - 1 | 0);
          };
          var numDigits = Data_String_CodePoints.length(Data_Show.show(Data_Show.showInt)(num));
          var zeros = (function () {
              var $25 = numDigits < pad;
              if ($25) {
                  return zeros$prime(pad - numDigits | 0);
              };
              return "";
          })();
          return zeros + Data_Show.show(Data_Show.showInt)(num);
      };
  };
  var toggleSet = function (dictOrd) {
      return function (a) {
          return function (s) {
              if (Data_Set.member(dictOrd)(a)(s)) {
                  return Data_Set["delete"](dictOrd)(a)(s);
              };
              if (Data_Boolean.otherwise) {
                  return Data_Set.insert(dictOrd)(a)(s);
              };
              throw new Error("Failed pattern match at Gargantext.Utils (line 46, column 1 - line 46, column 52): " + [ a.constructor.name, s.constructor.name ]);
          };
      };
  };
  var queryMatchesLabel = function (q) {
      return function (l) {
          return Data_String_CodeUnits.contains(Data_String_Pattern.Pattern(Data_String_Common.toLower(q)))(Data_String_Common.toLower(l));
      };
  };
  var mapLeft = function (v) {
      return function (v1) {
          if (v1 instanceof Data_Either.Left) {
              return new Data_Either.Left(v(v1.value0));
          };
          if (v1 instanceof Data_Either.Right) {
              return new Data_Either.Right(v1.value0);
          };
          throw new Error("Failed pattern match at Gargantext.Utils (line 82, column 1 - line 82, column 62): " + [ v.constructor.name, v1.constructor.name ]);
      };
  };
  var href = function __do() {
      var w = Web_HTML.window();
      var loc = Web_HTML_Window.location(w)();
      return Web_HTML_Location.href(loc)();
  };
  var glyphicon = function (t) {
      return "btn glyphitem fa fa-" + t;
  };
  var glyphiconActive = function (icon) {
      return function (b) {
          return glyphicon(icon) + (function () {
              if (b) {
                  return " active";
              };
              return "";
          })();
      };
  };
  var csrfMiddlewareToken = "Wy52D2nor8kC1r1Y4GrsrSIxQ2eqW8UwkdiQQshMoRwobzU4uldknRUhP0j4WcEM";
  var $dollar_EqOn_11 = function (dictEq) {
      return new Data_Eq.Eq(function (v) {
          return function (v1) {
              return Data_Eq.eq(dictEq)(v.value0)(v1.value0);
          };
      });
  };
  var $dollar_OrdOn_12 = function (dictOrd) {
      return new Data_Ord.Ord(function () {
          return $dollar_EqOn_11(dictOrd.Eq0());
      }, function (v) {
          return function (v1) {
              return Data_Ord.compare(dictOrd)(v.value0)(v1.value0);
          };
      });
  };
  var sortWith = function (dictFunctor) {
      return function (dictFoldable) {
          return function (dictUnfoldable) {
              return function (dictOrd) {
                  return function (f) {
                      var $54 = Data_Functor.map(dictFunctor)(function (v) {
                          return v.value1;
                      });
                      var $55 = Data_Sequence_Ordered.toUnfoldable(dictFunctor)(dictUnfoldable);
                      var $56 = Data_Foldable.foldr(dictFoldable)(function (x) {
                          return Data_Sequence_Ordered.insert($dollar_OrdOn_12(dictOrd))(new On(f(x), x));
                      })(Data_Sequence_Ordered.empty);
                      return function ($57) {
                          return $54($55($56($57)));
                      };
                  };
              };
          };
      };
  };
  exports["csrfMiddlewareToken"] = csrfMiddlewareToken;
  exports["toggleSet"] = toggleSet;
  exports["glyphicon"] = glyphicon;
  exports["glyphiconActive"] = glyphiconActive;
  exports["zeroPad"] = zeroPad;
  exports["queryMatchesLabel"] = queryMatchesLabel;
  exports["mapLeft"] = mapLeft;
  exports["sortWith"] = sortWith;
  exports["href"] = href;
})(PS);
(function($PS) {
  "use strict";
  $PS["Gargantext.Utils.JSON"] = $PS["Gargantext.Utils.JSON"] || {};
  var exports = $PS["Gargantext.Utils.JSON"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except = $PS["Control.Monad.Except"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Int = $PS["Data.Int"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Data_TraversableWithIndex = $PS["Data.TraversableWithIndex"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Foreign = $PS["Foreign"];
  var Foreign_Object = $PS["Foreign.Object"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var writeSequence = function (dictWriteForeign) {
      return function (xs) {
          return Foreign.unsafeToForeign(Data_Functor.map(Data_Sequence.functorSeq)(Simple_JSON.writeImpl(dictWriteForeign))(xs));
      };
  };
  var writeList = function (dictWriteForeign) {
      return function (xs) {
          return Foreign.unsafeToForeign(Data_Functor.map(Data_List_Types.functorList)(Simple_JSON.writeImpl(dictWriteForeign))(xs));
      };
  };
  var readSequence = function (dictReadForeign) {
      return function (f) {
          var readAtIdx = function (i) {
              return function (f$prime) {
                  return Control_Monad_Except.withExcept(Data_Functor.map(Data_List_Types.functorNonEmptyList)(Foreign.ErrorAtIndex.create(i)))(Simple_JSON.readImpl(dictReadForeign)(f$prime));
              };
          };
          return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Foreign.readArray(Data_Identity.monadIdentity)(f))(function (arr) {
              return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Data_TraversableWithIndex.traverseWithIndex(Data_TraversableWithIndex.traversableWithIndexArray)(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(readAtIdx)(arr))(function (y) {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Data_Sequence.fromFoldable(Data_Foldable.foldableArray)(y));
              });
          });
      };
  };
  var readMapInt = function (dictReadForeign) {
      return function (f) {
          var readObject$prime = function (value) {
              if (Foreign.tagOf(value) === "Object") {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Foreign.unsafeFromForeign(value));
              };
              if (Data_Boolean.otherwise) {
                  return Foreign.fail(Data_Identity.monadIdentity)(Foreign.TypeMismatch.create("Object")(Foreign.tagOf(value)));
              };
              throw new Error("Failed pattern match at Gargantext.Utils.JSON (line 57, column 5 - line 57, column 56): " + [ value.constructor.name ]);
          };
          return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(readObject$prime(f))(function (v) {
              var v1 = Data_Functor.map(Data_Functor.functorArray)(function (v2) {
                  var v4 = Data_Int.fromString(v2.value0);
                  if (v4 instanceof Data_Maybe.Nothing) {
                      return Foreign.fail(Data_Identity.monadIdentity)(Foreign.ErrorAtProperty.create(v2.value0)(new Foreign.ForeignError("Cannot convert to int")));
                  };
                  if (v4 instanceof Data_Maybe.Just) {
                      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(dictReadForeign)(v2.value1))(function (v$prime) {
                          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(new Data_Tuple.Tuple(v4.value0, v$prime));
                      });
                  };
                  throw new Error("Failed pattern match at Gargantext.Utils.JSON (line 48, column 47 - line 52, column 71): " + [ v4.constructor.name ]);
              })(Foreign_Object.toUnfoldable(Data_Unfoldable.unfoldableArray)(v));
              return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Data_Traversable.sequence(Data_Traversable.traversableArray)(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(v1))(function (seq) {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Data_Map_Internal.fromFoldable(Data_Ord.ordInt)(Data_Foldable.foldableArray)(seq));
              });
          });
      };
  };
  var readList = function (dictReadForeign) {
      return function (f) {
          var readAtIdx = function (i) {
              return function (f$prime) {
                  return Control_Monad_Except.withExcept(Data_Functor.map(Data_List_Types.functorNonEmptyList)(Foreign.ErrorAtIndex.create(i)))(Simple_JSON.readImpl(dictReadForeign)(f$prime));
              };
          };
          return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Foreign.readArray(Data_Identity.monadIdentity)(f))(function (arr) {
              return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Data_TraversableWithIndex.traverseWithIndex(Data_TraversableWithIndex.traversableWithIndexArray)(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(readAtIdx)(arr))(function (y) {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Data_List.fromFoldable(Data_Foldable.foldableArray)(y));
              });
          });
      };
  };
  exports["readSequence"] = readSequence;
  exports["writeSequence"] = writeSequence;
  exports["readList"] = readList;
  exports["writeList"] = writeList;
  exports["readMapInt"] = readMapInt;
})(PS);
(function(exports) {
  'use strict';

  function addRootElement(rootElem) {
    document.body.insertBefore(
      rootElem,
      document.body.lastElementChild.nextElementSibling
    );
  }

  function getSelection(_u) {
    return window.getSelection();
  }

  function stringify(j, indent) {
    return JSON.stringify(j, null, indent);
  }

  function postMessage(obj, msg, src) {
      obj.contentWindow.postMessage(msg, src);
  }

  function setCookie(c) {
    document.cookie = c;
  }

  function domRectFromRect(obj) {
    return DOMRectReadOnly.fromRect(obj)
  }                                    
  exports._stringify = stringify;
  exports._postMessage = postMessage;
  exports._setCookie = setCookie;
  exports._domRectFromRect = domRectFromRect;

  exports._keyCode = function(e) {
    // https://www.w3schools.com/jsref/event_key_keycode.asp
    return e.which || e.keyCode;
  }
})(PS["Gargantext.Utils.Reactix"] = PS["Gargantext.Utils.Reactix"] || {});
(function(exports) {
  "use strict";

  exports.name = function (file) { return file.name; };
})(PS["Web.File.File"] = PS["Web.File.File"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.File.File"] = $PS["Web.File.File"] || {};
  var exports = $PS["Web.File.File"];
  var $foreign = $PS["Web.File.File"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];
  var toBlob = Unsafe_Coerce.unsafeCoerce;
  exports["toBlob"] = toBlob;
  exports["name"] = $foreign.name;
})(PS);
(function(exports) {
  "use strict";                                                    

  exports._item = function (index) {
    return function (fileList) {
      return fileList.item(index);
    };
  };
})(PS["Web.File.FileList"] = PS["Web.File.FileList"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.File.FileList"] = $PS["Web.File.FileList"] || {};
  var exports = $PS["Web.File.FileList"];
  var $foreign = $PS["Web.File.FileList"];
  var Data_Nullable = $PS["Data.Nullable"];                    
  var item = function (i) {
      var $1 = $foreign["_item"](i);
      return function ($2) {
          return Data_Nullable.toMaybe($1($2));
      };
  };
  exports["item"] = item;
})(PS);
(function(exports) {
  "use strict";

  exports._getItem = function (key) {
    return function (storage) {
      return function () {
        return storage.getItem(key);
      };
    };
  };

  exports.setItem = function (key) {
    return function (value) {
      return function (storage) {
        return function () {
          storage.setItem(key, value);
        };
      };
    };
  };

  exports.removeItem = function (key) {
    return function (storage) {
      return function () {
        storage.removeItem(key);
      };
    };
  };
})(PS["Web.Storage.Storage"] = PS["Web.Storage.Storage"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.Storage.Storage"] = $PS["Web.Storage.Storage"] || {};
  var exports = $PS["Web.Storage.Storage"];
  var $foreign = $PS["Web.Storage.Storage"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Effect = $PS["Effect"];
  var getItem = function (s) {
      var $3 = Data_Functor.map(Effect.functorEffect)(Data_Nullable.toMaybe);
      var $4 = $foreign["_getItem"](s);
      return function ($5) {
          return $3($4($5));
      };
  };
  exports["getItem"] = getItem;
  exports["setItem"] = $foreign.setItem;
  exports["removeItem"] = $foreign.removeItem;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.Reactix"] = $PS["Gargantext.Utils.Reactix"] || {};
  var exports = $PS["Gargantext.Utils.Reactix"];
  var $foreign = $PS["Gargantext.Utils.Reactix"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var DOM_Simple_Document = $PS["DOM.Simple.Document"];
  var DOM_Simple_Element = $PS["DOM.Simple.Element"];
  var DOM_Simple_Event = $PS["DOM.Simple.Event"];
  var Data_Array = $PS["Data.Array"];
  var Data_Either = $PS["Data.Either"];
  var Data_Function = $PS["Data.Function"];
  var Data_Function_Uncurried = $PS["Data.Function.Uncurried"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Show = $PS["Data.Show"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Effect_Uncurried = $PS["Effect.Uncurried"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
  var FFI_Simple_Objects = $PS["FFI.Simple.Objects"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];
  var Web_File_File = $PS["Web.File.File"];
  var Web_File_FileList = $PS["Web.File.FileList"];
  var Web_HTML = $PS["Web.HTML"];
  var Web_HTML_Window = $PS["Web.HTML.Window"];
  var Web_Storage_Storage = $PS["Web.Storage.Storage"];
  var NTIsComponent = function (ntCreateElement) {
      this.ntCreateElement = ntCreateElement;
  };
  var NTComponent = function (x) {
      return x;
  };
  var useLayoutEffect1$prime = function (a) {
      return function (f) {
          return Reactix_Hooks.useLayoutEffect1(a)(function __do() {
              Effect_Class.liftEffect(Effect_Class.monadEffectEffect)(f(Data_Unit.unit))();
              return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
          });
      };
  };
  var stringify = function (j) {
      return function (indent) {
          return $foreign["_stringify"](j, indent);
      };
  };
  var small = Reactix_DOM_HTML.createDOM("small");
  var showText = function (dictShow) {
      var $63 = Data_Show.show(dictShow);
      return function ($64) {
          return Reactix_DOM_HTML.text($63($64));
      };
  };
  var setIndeterminateCheckbox = function (el) {
      return function (val) {
          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Objects["setProperty'"](el)("indeterminate")(val));
      };
  };
  var setCookie = Effect_Uncurried.runEffectFn1($foreign["_setCookie"]);
  var select = Reactix_DOM_HTML.createDOM("select");
  var row = function (children1) {
      return Reactix_DOM_HTML.div({
          className: "row"
      })(children1);
  };
  var render = function (e) {
      return function (d) {
          return FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v) {
              return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](Reactix_React.reactDOM)("render")(FFI_Simple_Functions.args2(e)(d)));
          });
      };
  };
  var readPositionRef = function (el) {
      var posRef = Reactix_React.readRef(el);
      return Data_Functor.map(Data_Maybe.functorMaybe)(DOM_Simple_Element.boundingRect())(Data_Nullable.toMaybe(posRef));
  };
  var postMessage = function (ref) {
      return function (msg) {
          var v = Reactix_React.readNullableRef(ref);
          if (v instanceof Data_Maybe.Just) {
              return function () {
                  return $foreign["_postMessage"](v.value0, msg, FFI_Simple_Objects["getProperty'"](v.value0)("src"));
              };
          };
          if (v instanceof Data_Maybe.Nothing) {
              return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
          };
          throw new Error("Failed pattern match at Gargantext.Utils.Reactix (line 372, column 3 - line 375, column 27): " + [ v.constructor.name ]);
      };
  };
  var openNodesKey = "garg-open-nodes";                     
  var ntCreateElement = function (dict) {
      return dict.ntCreateElement;
  };
  var nothingRef = Reactix_Hooks.useRef(Data_Maybe.Nothing.value);
  var named = Data_Function.flip(FFI_Simple_Objects.defineProperty("name"));
  var mousePosition = function (e) {
      return {
          x: Reactix_SyntheticEvent.clientX()(e),
          y: Reactix_SyntheticEvent.clientY()(e)
      };
  };
  var mouseClickInElement = function (e) {
      return function (el) {
          var v = DOM_Simple_Element.boundingRect()(el);
          var cy = DOM_Simple_Event.clientY(e);
          var cx = DOM_Simple_Event.clientX(e);
          return v.x <= cx && (cx <= v.x + v.width && (v.y <= cy && cy <= v.y + v.height));
      };
  };                                            
  var keyCode = Effect_Uncurried.runEffectFn1($foreign["_keyCode"]);
  var inputFile = function (n) {
      return function (e) {
          var el = FFI_Simple_Objects["getProperty'"](e)("target");
          return Web_File_FileList.item(n)(FFI_Simple_Objects["getProperty'"](el)("files"));
      };
  };
  var inputFileNameWithBlob = function (n) {
      return function (e) {
          var ff = inputFile(n)(e);
          if (ff instanceof Data_Maybe.Nothing) {
              return Data_Maybe.Nothing.value;
          };
          if (ff instanceof Data_Maybe.Just) {
              return new Data_Maybe.Just({
                  blob: Web_File_File.toBlob(ff.value0),
                  name: Web_File_File.name(ff.value0)
              });
          };
          throw new Error("Failed pattern match at Gargantext.Utils.Reactix (line 296, column 29 - line 298, column 57): " + [ ff.constructor.name ]);
      };
  };
  var getls = Control_Bind.bind(Effect.bindEffect)(Web_HTML.window)(Web_HTML_Window.localStorage);
  var listenLocalStorageState = function (dictWriteForeign) {
      return function (key) {
          return function (v) {
              var json = Simple_JSON.writeJSON(dictWriteForeign)(v["new"]);
              return function __do() {
                  var storage = getls();
                  return Web_Storage_Storage.setItem(key)(json)(storage)();
              };
          };
      };
  };
  var loadLocalStorageState = function (dictReadForeign) {
      return function (key) {
          return function (cell) {
              return function __do() {
                  var storage = getls();
                  var v = Web_Storage_Storage.getItem(key)(storage)();
                  var parsed = Data_Either.hush(Simple_JSON.readJSON(dictReadForeign)(Data_Maybe.fromMaybe("")(v)));
                  if (parsed instanceof Data_Maybe.Nothing) {
                      return Data_Unit.unit;
                  };
                  if (parsed instanceof Data_Maybe.Just) {
                      return Data_Functor["void"](Effect.functorEffect)(Toestand_Classes.write(Toestand_Boxes.writeBox)(parsed.value0)(cell))();
                  };
                  throw new Error("Failed pattern match at Gargantext.Utils.Reactix (line 347, column 3 - line 349, column 37): " + [ parsed.constructor.name ]);
              };
          };
      };
  };                                                                          
  var getPortalHost = Reactix_React.unsafeHooksEffect(FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v) {
      return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](DOM_Simple_Document.document)("getElementById")([ "portal" ]));
  }));
  var getMessageOrigin = function (me) {
      return FFI_Simple_Objects["getProperty'"](me)("origin");
  };
  var getMessageData = function (me) {
      return FFI_Simple_Objects["getProperty'"](me)("data");
  };                                     
  var getElementById = (function () {
      var h = function (id) {
          return Control_Applicative.pure(Effect.applicativeEffect)(Data_Nullable.toMaybe(FFI_Simple_Functions["applyMethod'"](DOM_Simple_Document.document)("getElementById")([ id ])));
      };
      return Data_Function.flip(FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect)))(h);
  })();
  var effectLink = function (eff) {
      return function (msg) {
          return Reactix_DOM_HTML.a({
              on: {
                  click: Data_Function["const"](eff)
              }
          })([ Reactix_DOM_HTML.text(msg) ]);
      };
  };
  var domRectFromRect = Data_Function_Uncurried.runFn1($foreign["_domRectFromRect"]);
  var domMousePosition = function ($65) {
      return mousePosition($65);
  };
  var dataTransferFileBlob = function (dictApplicative) {
      return function (e) {
          var ff = Data_Maybe.fromJust()(Web_File_FileList.item(0)(FFI_Simple_Objects["getProperty'"](FFI_Simple_Objects["getProperty'"](e)("dataTransfer"))("files")));
          return Control_Applicative.pure(dictApplicative)(Web_File_File.toBlob(ff));
      };
  };
  var componentIsNTComponent = new NTIsComponent(Reactix_React.rawCreateElement);
  var col = function (n) {
      return function (children1) {
          return Reactix_DOM_HTML.div({
              className: "col-md-" + Data_Show.show(Data_Show.showInt)(n)
          })(children1);
      };
  };
  var children = function (a) {
      return FFI_Simple_Functions["applyMethod'"](FFI_Simple_Objects["getProperty'"](Reactix_React.react)("Children"))("toArray")([ FFI_Simple_Objects["getProperty'"](a)("children") ]);
  };
  var ntHooksComponent = function (name) {
      return function (c) {
          var c$prime = function (props) {
              return Reactix_React.runHooks(c(props)(children(props)));
          };
          return NTComponent(named(name)(Effect_Uncurried.mkEffectFn1(c$prime)));
      };
  };
  var ntHooksComponentWithModule = function (module$prime) {
      return function (name) {
          return function (c) {
              return ntHooksComponent(module$prime + ("." + name))(c);
          };
      };
  };
  var here = function (mod) {
      return {
          component: Reactix_React.hooksComponentWithModule(mod),
          log: DOM_Simple_Console.log2("[" + (mod + "]")),
          log2: function (msg) {
              return DOM_Simple_Console.log2("[" + (mod + ("] " + msg)));
          },
          ntComponent: ntHooksComponentWithModule(mod)
      };
  };
  var buff = Unsafe_Coerce.unsafeCoerce;
  var boundingRect = function (dictIsElement) {
      return function (els) {
          var v = Data_Array.uncons(els);
          if (v instanceof Data_Maybe.Nothing) {
              return domRectFromRect({
                  x: 0.0,
                  y: 0.0,
                  width: 0.0,
                  height: 0.0
              });
          };
          if (v instanceof Data_Maybe.Just) {
              var br = DOM_Simple_Element.boundingRect()(v.value0.head);
              if (v.value0.tail.length === 0) {
                  return br;
              };
              var brs = boundingRect()(v.value0.tail);
              var maxx = Data_Ord.max(Data_Ord.ordNumber)(br.right)(brs.right);
              var maxy = Data_Ord.max(Data_Ord.ordNumber)(br.bottom)(brs.bottom);
              var minx = Data_Ord.min(Data_Ord.ordNumber)(br.left)(brs.left);
              var miny = Data_Ord.min(Data_Ord.ordNumber)(br.top)(brs.top);
              return domRectFromRect({
                  x: minx,
                  y: miny,
                  width: maxx - minx,
                  height: maxy - miny
              });
          };
          throw new Error("Failed pattern match at Gargantext.Utils.Reactix (line 422, column 3 - line 439, column 51): " + [ v.constructor.name ]);
      };
  };
  var blur = function (el) {
      return FFI_Simple_Functions["applyMethod'"](el)("blur")([  ]);
  };
  var affEffect = function (errmsg) {
      return function (aff) {
          return function __do() {
              var fiber = Effect_Aff.launchAff(aff)();
              return Effect_Aff.launchAff_(Effect_Aff.killFiber(Effect_Exception.error(errmsg))(fiber));
          };
      };
  };
  exports["ntCreateElement"] = ntCreateElement;
  exports["here"] = here;
  exports["buff"] = buff;
  exports["affEffect"] = affEffect;
  exports["mouseClickInElement"] = mouseClickInElement;
  exports["domMousePosition"] = domMousePosition;
  exports["named"] = named;
  exports["small"] = small;
  exports["select"] = select;
  exports["keyCode"] = keyCode;
  exports["nothingRef"] = nothingRef;
  exports["useLayoutEffect1'"] = useLayoutEffect1$prime;
  exports["readPositionRef"] = readPositionRef;
  exports["getElementById"] = getElementById;
  exports["getPortalHost"] = getPortalHost;
  exports["showText"] = showText;
  exports["render"] = render;
  exports["effectLink"] = effectLink;
  exports["inputFileNameWithBlob"] = inputFileNameWithBlob;
  exports["dataTransferFileBlob"] = dataTransferFileBlob;
  exports["blur"] = blur;
  exports["row"] = row;
  exports["col"] = col;
  exports["stringify"] = stringify;
  exports["getls"] = getls;
  exports["openNodesKey"] = openNodesKey;
  exports["loadLocalStorageState"] = loadLocalStorageState;
  exports["listenLocalStorageState"] = listenLocalStorageState;
  exports["getMessageOrigin"] = getMessageOrigin;
  exports["getMessageData"] = getMessageData;
  exports["postMessage"] = postMessage;
  exports["setCookie"] = setCookie;
  exports["setIndeterminateCheckbox"] = setIndeterminateCheckbox;
  exports["domRectFromRect"] = domRectFromRect;
  exports["componentIsNTComponent"] = componentIsNTComponent;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.AsyncTasks"] = $PS["Gargantext.AsyncTasks"] || {};
  var exports = $PS["Gargantext.AsyncTasks"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var Data_Array = $PS["Data.Array"];
  var Data_Either = $PS["Data.Either"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Effect = $PS["Effect"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils = $PS["Gargantext.Utils"];
  var Gargantext_Utils_JSON = $PS["Gargantext.Utils.JSON"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var Web_Storage_Storage = $PS["Web.Storage.Storage"];                
  var Storage = function (x) {
      return x;
  };
  var setTasks = function (id) {
      return function (tasks) {
          return function (v) {
              return Storage(Data_Map_Internal.insert(Data_Ord.ordInt)(id)(tasks)(v));
          };
      };
  };
  var removeTaskFromList = function (ts) {
      return function (v) {
          return Data_Array.filter(function (v1) {
              return v.task.id !== v1.task.id;
          })(ts);
      };
  };
  var remove = function (id) {
      return function (task) {
          return function (storage) {
              var newStorage = function (v) {
                  return Storage(Data_Map_Internal.alter(Data_Ord.ordInt)(Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (ts) {
                      return Data_Maybe.Just.create(removeTaskFromList(ts)(task));
                  }))(id)(v));
              };
              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(newStorage)(storage);
          };
      };
  };
  var localStorageKey = "garg-async-tasks";
  var insert = function (id) {
      return function (task) {
          return function (storage) {
              var newStorage = function (v) {
                  return Storage(Data_Map_Internal.alter(Data_Ord.ordInt)(Data_Maybe.maybe(new Data_Maybe.Just([ task ]))(function (ts) {
                      return Data_Maybe.Just.create(Data_Array.cons(task)(ts));
                  }))(id)(v));
              };
              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(newStorage)(storage);
          };
      };
  };
  var getTasks = function (nodeId) {
      return function (v) {
          return Data_Maybe.fromMaybe([  ])(Data_Map_Internal.lookup(Data_Ord.ordInt)(nodeId)(v));
      };
  };
  var focus = function (id) {
      return function (tasks) {
          return Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(getTasks(id))(setTasks(id))(tasks);
      };
  };
  var finish = function (id) {
      return function (task) {
          return function (storage) {
              return remove(id)(task)(storage);
          };
      };
  };
  var empty = Storage(Data_Map_Internal.empty);
  var asyncTaskTriggersTreeReload = function (v) {
      if (v instanceof Gargantext_Types.Form) {
          return true;
      };
      if (v instanceof Gargantext_Types.UploadFile) {
          return true;
      };
      return false;
  };
  var asyncTaskTriggersMainPageReload = function (v) {
      if (v instanceof Gargantext_Types.UpdateNgramsCharts) {
          return true;
      };
      return false;
  };
  var asyncTaskTriggersAppReload = function (v) {
      return false;
  };
  var asyncTaskTTriggersTreeReload = function (v) {
      return asyncTaskTriggersTreeReload(v.typ);
  };
  var asyncTaskTTriggersMainPageReload = function (v) {
      return asyncTaskTriggersMainPageReload(v.typ);
  };
  var asyncTaskTTriggersAppReload = function (v) {
      return asyncTaskTriggersAppReload(v.typ);
  };
  var $dollar_ReadForeignStorage_14 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Gargantext_Utils_JSON.readMapInt(Simple_JSON.readArray(Gargantext_Types["$_ReadForeignAsyncTaskWithT_171"]))(f))(function (m) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(m);
      });
  });
  var getAsyncTasks = (function () {
      var parse = function (s) {
          return Gargantext_Utils.mapLeft(DOM_Simple_Console.log2("Error parsing serialised sessions:"))(Simple_JSON.readJSON($dollar_ReadForeignStorage_14)(s));
      };
      var handleEither = function (v) {
          if (v instanceof Data_Either.Left) {
              return Control_Apply.applySecond(Effect.applyEffect)(v.value0)(Control_Applicative.pure(Effect.applicativeEffect)(empty));
          };
          if (v instanceof Data_Either.Right) {
              return Control_Applicative.pure(Effect.applicativeEffect)(v.value0);
          };
          throw new Error("Failed pattern match at Gargantext.AsyncTasks (line 44, column 5 - line 44, column 48): " + [ v.constructor.name ]);
      };
      var handleMaybe = function (v) {
          if (v instanceof Data_Maybe.Just) {
              return handleEither(parse(v.value0));
          };
          if (v instanceof Data_Maybe.Nothing) {
              return Control_Applicative.pure(Effect.applicativeEffect)(empty);
          };
          throw new Error("Failed pattern match at Gargantext.AsyncTasks (line 40, column 5 - line 40, column 54): " + [ v.constructor.name ]);
      };
      return Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Gargantext_Utils_Reactix.getls)(Web_Storage_Storage.getItem(localStorageKey)))(handleMaybe);
  })();
  exports["empty"] = empty;
  exports["getAsyncTasks"] = getAsyncTasks;
  exports["focus"] = focus;
  exports["insert"] = insert;
  exports["finish"] = finish;
  exports["asyncTaskTTriggersAppReload"] = asyncTaskTTriggersAppReload;
  exports["asyncTaskTTriggersMainPageReload"] = asyncTaskTTriggersMainPageReload;
  exports["asyncTaskTTriggersTreeReload"] = asyncTaskTTriggersTreeReload;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Annotation.Utils"] = $PS["Gargantext.Components.Annotation.Utils"] || {};
  var exports = $PS["Gargantext.Components.Annotation.Utils"];
  var Gargantext_Types = $PS["Gargantext.Types"];                
  var termClass = function (v) {
      if (v instanceof Gargantext_Types.CandidateTerm) {
          return "candidate-term";
      };
      if (v instanceof Gargantext_Types.MapTerm) {
          return "graph-term";
      };
      if (v instanceof Gargantext_Types.StopTerm) {
          return "stop-term";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Annotation.Utils (line 5, column 1 - line 5, column 32): " + [ v.constructor.name ]);
  };
  var termBootstrapClass = function (v) {
      if (v instanceof Gargantext_Types.MapTerm) {
          return "success";
      };
      if (v instanceof Gargantext_Types.StopTerm) {
          return "danger";
      };
      if (v instanceof Gargantext_Types.CandidateTerm) {
          return "primary";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Annotation.Utils (line 10, column 1 - line 10, column 41): " + [ v.constructor.name ]);
  };
  exports["termClass"] = termClass;
  exports["termBootstrapClass"] = termBootstrapClass;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.ContextMenu.ContextMenu"] = $PS["Gargantext.Components.ContextMenu.ContextMenu"] || {};
  var exports = $PS["Gargantext.Components.ContextMenu.ContextMenu"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var DOM_Simple_Document = $PS["DOM.Simple.Document"];
  var DOM_Simple_Element = $PS["DOM.Simple.Element"];
  var DOM_Simple_EventListener = $PS["DOM.Simple.EventListener"];
  var DOM_Simple_Window = $PS["DOM.Simple.Window"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var FFI_Simple_Objects = $PS["FFI.Simple.Objects"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var position = function (mouse) {
      return function (v) {
          var screenWidth = FFI_Simple_Objects["getProperty'"](DOM_Simple_Window.window)("innerWidth");
          var screenHeight = FFI_Simple_Objects["getProperty'"](DOM_Simple_Window.window)("innerHeight");
          var isRight = screenWidth - mouse.x > v.width;
          var left = (function () {
              if (isRight) {
                  return mouse.x;
              };
              return mouse.x - v.width;
          })();
          var isAbove = screenHeight - mouse.y > v.height;
          var top = (function () {
              if (isAbove) {
                  return mouse.y;
              };
              return mouse.y - v.height;
          })();
          return {
              left: left,
              top: top
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.ContextMenu.ContextMenu");
  var documentScrollHandler = function (onClose) {
      return Gargantext_Utils_Reactix.named("hideMenuOnScroll")(DOM_Simple_EventListener.callback(function (e) {
          return onClose;
      }));
  };
  var documentClickHandler = function (onClose) {
      return function (menu) {
          return Gargantext_Utils_Reactix.named("hideMenuOnClickOutside")(DOM_Simple_EventListener.callback(function (e) {
              return Control_Applicative.when(Effect.applicativeEffect)(Gargantext_Utils_Reactix.mouseClickInElement(e)(menu))(function __do() {
                  here.log("mouse in element")();
                  return onClose();
              });
          }));
      };
  };
  var contextMenuItemCpt = (function () {
      var cpt = function (_props) {
          return function (children) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.li({
                  className: "context-menu-item"
              })(children));
          };
      };
      return here.component("contextMenuItem")(cpt);
  })();
  var contextMenuItem = Reactix_React.createElement(Reactix_React.componentIsComponent)(contextMenuItemCpt);
  var contextMenuEffect = function (onClose) {
      return function (rootRef) {
          var v = Reactix_React.readNullableRef(rootRef);
          if (v instanceof Data_Maybe.Just) {
              var onClick = documentClickHandler(onClose)(v.value0);
              var onScroll = documentScrollHandler(onClose);
              return function __do() {
                  DOM_Simple_EventListener.addEventListener()()(DOM_Simple_Document.document)("click")(onClick)();
                  DOM_Simple_EventListener.addEventListener()()(DOM_Simple_Document.document)("scroll")(onScroll)();
                  return function __do() {
                      DOM_Simple_EventListener.removeEventListener()()(DOM_Simple_Document.document)("click")(onClick)();
                      return DOM_Simple_EventListener.removeEventListener()()(DOM_Simple_Document.document)("scroll")(onScroll)();
                  };
              };
          };
          if (v instanceof Data_Maybe.Nothing) {
              return Control_Applicative.pure(Effect.applicativeEffect)(Reactix_Hooks.nothing);
          };
          throw new Error("Failed pattern match at Gargantext.Components.ContextMenu.ContextMenu (line 81, column 3 - line 90, column 30): " + [ v.constructor.name ]);
      };
  };
  var contextMenuCpt = (function () {
      var elems = function (ref) {
          return function (menu) {
              return function (v) {
                  if (v instanceof Data_Maybe.Just) {
                      return Reactix_DOM_HTML.div({
                          ref: ref,
                          key: "context-menu",
                          className: "context-menu",
                          style: position(menu)(v.value0),
                          data: {
                              placement: "right",
                              toggle: "popover"
                          }
                      });
                  };
                  if (v instanceof Data_Maybe.Nothing) {
                      return Reactix_DOM_HTML.div({
                          ref: ref,
                          key: "context-menu",
                          className: "context-menu",
                          data: {
                              placement: "right",
                              toggle: "popover"
                          }
                      });
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.ContextMenu.ContextMenu (line 61, column 5 - line 67, column 10): " + [ ref.constructor.name, menu.constructor.name, v.constructor.name ]);
              };
          };
      };
      var cpt = function (v) {
          return function (children) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Gargantext_Utils_Reactix.getPortalHost)(function (host) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (root) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Maybe.Just.create(Gargantext_Utils_Reactix.domRectFromRect({
                          x: v.x,
                          y: v.y,
                          width: 100.0,
                          height: 100.0
                      }))))(function (rect) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "y";
                          }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                              return "x";
                          }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                              return "width";
                          }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                              return "top";
                          }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                              return "right";
                          }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                              return "left";
                          }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                              return "height";
                          }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                              return "bottom";
                          }))(Data_Eq.eqNumber)))))(rect))(function (rect$prime) {
                              return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks.useLayoutEffect1(Reactix_React.readRef(root))(function __do() {
                                  Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Foldable.foldableMaybe)(function (r) {
                                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(new Data_Maybe.Just(DOM_Simple_Element.boundingRect()(r)))(rect);
                                  })(Data_Nullable.toMaybe(Reactix_React.readRef(root)))();
                                  return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                              }))(function () {
                                  return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks.useLayoutEffect2(Reactix_React.readRef(root))(rect$prime)(contextMenuEffect(v.onClose)(root)))(function () {
                                      var cs = [ Reactix_DOM_HTML.div({
                                          className: "popover-content"
                                      })([ Reactix_DOM_HTML.div({
                                          className: "card"
                                      })([ Reactix_DOM_HTML.ul({
                                          className: "list-group"
                                      })(children) ]) ]) ];
                                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.createPortal([ elems(root)(v)(rect$prime)(cs) ])(host));
                                  });
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("contextMenu")(cpt);
  })();
  var contextMenu = Reactix_React.createElement(Reactix_React.componentIsComponent)(contextMenuCpt);
  exports["contextMenu"] = contextMenu;
  exports["contextMenuItem"] = contextMenuItem;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Annotation.Menu"] = $PS["Gargantext.Components.Annotation.Menu"] || {};
  var exports = $PS["Gargantext.Components.Annotation.Menu"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Gargantext_Components_Annotation_Utils = $PS["Gargantext.Components.Annotation.Utils"];
  var Gargantext_Components_ContextMenu_ContextMenu = $PS["Gargantext.Components.ContextMenu.ContextMenu"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];                
  var NewNgram = (function () {
      function NewNgram() {

      };
      NewNgram.value = new NewNgram();
      return NewNgram;
  })();
  var SetTermListItem = (function () {
      function SetTermListItem() {

      };
      SetTermListItem.value = new SetTermListItem();
      return SetTermListItem;
  })();
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Annotation.Menu");
  var addToList = function (v) {
      return function (t) {
          if (v.list instanceof Data_Maybe.Just && Data_Eq.eq(Gargantext_Types["$_EqTermList_103"])(t)(v.list.value0)) {
              return Data_Maybe.Nothing.value;
          };
          var label = function (v1) {
              if (v1 instanceof NewNgram) {
                  return "Add to " + Gargantext_Types.termListName(t);
              };
              if (v1 instanceof SetTermListItem) {
                  return "Change to " + Gargantext_Types.termListName(t);
              };
              throw new Error("Failed pattern match at Gargantext.Components.Annotation.Menu (line 98, column 5 - line 98, column 49): " + [ v1.constructor.name ]);
          };
          var click = function (v1) {
              return v.setList(t);
          };
          var className = "list-group-item list-group-item-" + Gargantext_Components_Annotation_Utils.termBootstrapClass(t);
          var link = Reactix_DOM_HTML.a({
              on: {
                  click: click
              },
              className: className
          })([ Reactix_DOM_HTML.text(label(v.menuType)) ]);
          return Data_Maybe.Just.create(Gargantext_Components_ContextMenu_ContextMenu.contextMenuItem({})([ link ]));
      };
  };
  var annotationMenuInnerCpt = (function () {
      var cpt = function (props) {
          return function (v) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment(Data_Array.mapMaybe(addToList(props))([ Gargantext_Types.MapTerm.value, Gargantext_Types.CandidateTerm.value, Gargantext_Types.StopTerm.value ])));
          };
      };
      return here.component("annotationMenuInner")(cpt);
  })();
  var annotationMenuInner = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(annotationMenuInnerCpt)(p)([  ]);
  };
  var annotationMenuCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.redrawMenu))(function (redrawMenu$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_ContextMenu_ContextMenu.contextMenu({
                      x: v.x,
                      y: v.y,
                      onClose: v.onClose
                  })([ annotationMenuInner({
                      list: v.list,
                      menuType: v.menuType,
                      setList: v.setList
                  }) ]));
              });
          };
      };
      return here.component("annotationMenu")(cpt);
  })();
  var annotationMenu = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(annotationMenuCpt)(p)([  ]);
  };
  var annotationMenuWrapperCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var v2 = Reactix_React.readRef(v.menuRef);
              if (v2 instanceof Data_Maybe.Nothing) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
              };
              if (v2 instanceof Data_Maybe.Just) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(annotationMenu(v2.value0));
              };
              throw new Error("Failed pattern match at Gargantext.Components.Annotation.Menu (line 68, column 5 - line 70, column 46): " + [ v2.constructor.name ]);
          };
      };
      return here.component("annotationMenuWrapper")(cpt);
  })();
  var annotationMenuWrapper = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(annotationMenuWrapperCpt)(p)([  ]);
  };
  exports["NewNgram"] = NewNgram;
  exports["SetTermListItem"] = SetTermListItem;
  exports["annotationMenuWrapper"] = annotationMenuWrapper;
})(PS);
(function(exports) {
  'use strict';

  exports.back = function() {
    return function() {
      history.back();
    }
  }

  exports.link = function (url) {
    return function() {
      window.location.href = url
    }
  }
})(PS["Gargantext.Components.FolderView"] = PS["Gargantext.Components.FolderView"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Contact.Types"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Contact.Types"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Contact.Types"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Simple_JSON = $PS["Simple.JSON"];
  var $dollar_WriteForeignAddContactPar_11 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "firstname";
  }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "lastname";
  }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()());
  var $dollar_EqAddContactParams_6 = new Data_Eq.Eq(function (x) {
      return function (y) {
          return x.firstname === y.firstname && x.lastname === y.lastname;
      };
  });
  exports["$_EqAddContactParams_6"] = $dollar_EqAddContactParams_6;
  exports["$_WriteForeignAddContactPar_11"] = $dollar_WriteForeignAddContactPar_11;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Update.Types"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Update.Types"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Update.Types"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Show_Generic = $PS["Data.Show.Generic"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Prelude = $PS["Gargantext.Prelude"];
  var Simple_JSON = $PS["Simple.JSON"];                                                                
  var Basic = (function () {
      function Basic() {

      };
      Basic.value = new Basic();
      return Basic;
  })();
  var Advanced = (function () {
      function Advanced() {

      };
      Advanced.value = new Advanced();
      return Advanced;
  })();
  var WithModel = (function () {
      function WithModel() {

      };
      WithModel.value = new WithModel();
      return WithModel;
  })();
  var Order1 = (function () {
      function Order1() {

      };
      Order1.value = new Order1();
      return Order1;
  })();
  var Order2 = (function () {
      function Order2() {

      };
      Order2.value = new Order2();
      return Order2;
  })();
  var NewNgrams = (function () {
      function NewNgrams() {

      };
      NewNgrams.value = new NewNgrams();
      return NewNgrams;
  })();
  var NewTexts = (function () {
      function NewTexts() {

      };
      NewTexts.value = new NewTexts();
      return NewTexts;
  })();
  var Both = (function () {
      function Both() {

      };
      Both.value = new Both();
      return Both;
  })();
  var Sources = (function () {
      function Sources() {

      };
      Sources.value = new Sources();
      return Sources;
  })();
  var Authors = (function () {
      function Authors() {

      };
      Authors.value = new Authors();
      return Authors;
  })();
  var Institutes = (function () {
      function Institutes() {

      };
      Institutes.value = new Institutes();
      return Institutes;
  })();
  var Ngrams = (function () {
      function Ngrams() {

      };
      Ngrams.value = new Ngrams();
      return Ngrams;
  })();
  var All = (function () {
      function All() {

      };
      All.value = new All();
      return All;
  })();
  var UpdateNodeParamsList = (function () {
      function UpdateNodeParamsList(value0) {
          this.value0 = value0;
      };
      UpdateNodeParamsList.create = function (value0) {
          return new UpdateNodeParamsList(value0);
      };
      return UpdateNodeParamsList;
  })();
  var UpdateNodeParamsGraph = (function () {
      function UpdateNodeParamsGraph(value0) {
          this.value0 = value0;
      };
      UpdateNodeParamsGraph.create = function (value0) {
          return new UpdateNodeParamsGraph(value0);
      };
      return UpdateNodeParamsGraph;
  })();
  var UpdateNodeParamsTexts = (function () {
      function UpdateNodeParamsTexts(value0) {
          this.value0 = value0;
      };
      UpdateNodeParamsTexts.create = function (value0) {
          return new UpdateNodeParamsTexts(value0);
      };
      return UpdateNodeParamsTexts;
  })();
  var UpdateNodeParamsBoard = (function () {
      function UpdateNodeParamsBoard(value0) {
          this.value0 = value0;
      };
      UpdateNodeParamsBoard.create = function (value0) {
          return new UpdateNodeParamsBoard(value0);
      };
      return UpdateNodeParamsBoard;
  })();
  var $dollar_ReadMethod_43 = new Gargantext_Prelude.Read(function (v) {
      if (v === "Basic") {
          return new Data_Maybe.Just(Basic.value);
      };
      if (v === "Advanced") {
          return new Data_Maybe.Just(Advanced.value);
      };
      if (v === "WithModel") {
          return new Data_Maybe.Just(WithModel.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var $dollar_ReadGraphMetric_47 = new Gargantext_Prelude.Read(function (v) {
      if (v === "Order1") {
          return new Data_Maybe.Just(Order1.value);
      };
      if (v === "Order2") {
          return new Data_Maybe.Just(Order2.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var $dollar_ReadGranularity_53 = new Gargantext_Prelude.Read(function (v) {
      if (v === "NewNgrams") {
          return new Data_Maybe.Just(NewNgrams.value);
      };
      if (v === "NewTexts") {
          return new Data_Maybe.Just(NewTexts.value);
      };
      if (v === "Both") {
          return new Data_Maybe.Just(Both.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var $dollar_ReadCharts_59 = new Gargantext_Prelude.Read(function (v) {
      if (v === "Sources ") {
          return new Data_Maybe.Just(Sources.value);
      };
      if (v === "Authors") {
          return new Data_Maybe.Just(Authors.value);
      };
      if (v === "Institutes") {
          return new Data_Maybe.Just(Institutes.value);
      };
      if (v === "Ngrams") {
          return new Data_Maybe.Just(Ngrams.value);
      };
      if (v === "AllCharts") {
          return new Data_Maybe.Just(All.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var $dollar_GenericMethod__38 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Basic) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof Advanced) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof WithModel) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value));
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Update.Types (line 30, column 1 - line 30, column 33): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return Basic.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return Advanced.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inr) {
          return WithModel.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Update.Types (line 30, column 1 - line 30, column 33): " + [ x.constructor.name ]);
  });     
  var $dollar_ShowMethod_40 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericMethod__38)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Basic";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Advanced";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "WithModel";
  }))))));
  var $dollar_WriteForeignMethod_42 = new Simple_JSON.WriteForeign((function () {
      var $143 = Simple_JSON.writeImpl(Simple_JSON.writeForeignString);
      var $144 = Data_Show.show($dollar_ShowMethod_40);
      return function ($145) {
          return $143($144($145));
      };
  })());
  var $dollar_GenericGraphMetric__44 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Order1) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof Order2) {
          return new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Update.Types (line 43, column 1 - line 43, column 38): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return Order1.value;
      };
      if (x instanceof Data_Generic_Rep.Inr) {
          return Order2.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Update.Types (line 43, column 1 - line 43, column 38): " + [ x.constructor.name ]);
  });    
  var $dollar_ShowGraphMetric_46 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericGraphMetric__44)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Order1";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Order2";
  })))));
  var $dollar_WriteForeignGraphMetric_49 = new Simple_JSON.WriteForeign((function () {
      var $146 = Simple_JSON.writeImpl(Simple_JSON.writeForeignString);
      var $147 = Data_Show.show($dollar_ShowGraphMetric_46);
      return function ($148) {
          return $146($147($148));
      };
  })());
  var $dollar_GenericGranularity__50 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof NewNgrams) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof NewTexts) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof Both) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value));
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Update.Types (line 56, column 1 - line 56, column 38): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return NewNgrams.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return NewTexts.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inr) {
          return Both.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Update.Types (line 56, column 1 - line 56, column 38): " + [ x.constructor.name ]);
  });     
  var $dollar_ShowGranularity_52 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericGranularity__50)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "NewNgrams";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "NewTexts";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Both";
  }))))));
  var $dollar_WriteForeignGranularity_55 = new Simple_JSON.WriteForeign((function () {
      var $149 = Simple_JSON.writeImpl(Simple_JSON.writeForeignString);
      var $150 = Data_Show.show($dollar_ShowGranularity_52);
      return function ($151) {
          return $149($150($151));
      };
  })());
  var $dollar_GenericCharts__56 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Sources) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof Authors) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof Institutes) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof Ngrams) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
      };
      if (x instanceof All) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))));
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Update.Types (line 69, column 1 - line 69, column 33): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return Sources.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return Authors.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return Institutes.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
          return Ngrams.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inr))) {
          return All.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Update.Types (line 69, column 1 - line 69, column 33): " + [ x.constructor.name ]);
  });                                                                      
  var $dollar_ShowCharts_58 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericCharts__56)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Sources";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Authors";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Institutes";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Ngrams";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "All";
  }))))))));
  var $dollar_WriteForeignCharts_61 = new Simple_JSON.WriteForeign(function (v) {
      if (v instanceof All) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)("AllCharts");
      };
      return Simple_JSON.writeImpl(Simple_JSON.writeForeignString)(Data_Show.show($dollar_ShowCharts_58)(v));
  });
  var $dollar_WriteForeignUpdateNodePar_37 = new Simple_JSON.WriteForeign(function (v) {
      if (v instanceof UpdateNodeParamsList) {
          return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "methodList";
          }))($dollar_WriteForeignMethod_42)(Simple_JSON.nilWriteForeignFields)()()()))({
              methodList: v.value0.methodList
          });
      };
      if (v instanceof UpdateNodeParamsGraph) {
          return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "methodGraph";
          }))($dollar_WriteForeignGraphMetric_49)(Simple_JSON.nilWriteForeignFields)()()()))({
              methodGraph: v.value0.methodGraph
          });
      };
      if (v instanceof UpdateNodeParamsTexts) {
          return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "methodTexts";
          }))($dollar_WriteForeignGranularity_55)(Simple_JSON.nilWriteForeignFields)()()()))({
              methodTexts: v.value0.methodTexts
          });
      };
      if (v instanceof UpdateNodeParamsBoard) {
          return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "methodBoard";
          }))($dollar_WriteForeignCharts_61)(Simple_JSON.nilWriteForeignFields)()()()))({
              methodBoard: v.value0.methodBoard
          });
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Update.Types (line 22, column 1 - line 26, column 85): " + [ v.constructor.name ]);
  });
  var $dollar_EqMethod_39 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof Basic && y instanceof Basic) {
              return true;
          };
          if (x instanceof Advanced && y instanceof Advanced) {
              return true;
          };
          if (x instanceof WithModel && y instanceof WithModel) {
              return true;
          };
          return false;
      };
  });
  var $dollar_EqGraphMetric_45 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof Order1 && y instanceof Order1) {
              return true;
          };
          if (x instanceof Order2 && y instanceof Order2) {
              return true;
          };
          return false;
      };
  });
  var $dollar_EqGranularity_51 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof NewNgrams && y instanceof NewNgrams) {
              return true;
          };
          if (x instanceof NewTexts && y instanceof NewTexts) {
              return true;
          };
          if (x instanceof Both && y instanceof Both) {
              return true;
          };
          return false;
      };
  });
  var $dollar_EqCharts_57 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof Sources && y instanceof Sources) {
              return true;
          };
          if (x instanceof Authors && y instanceof Authors) {
              return true;
          };
          if (x instanceof Institutes && y instanceof Institutes) {
              return true;
          };
          if (x instanceof Ngrams && y instanceof Ngrams) {
              return true;
          };
          if (x instanceof All && y instanceof All) {
              return true;
          };
          return false;
      };
  });
  var $dollar_EqUpdateNodeParams_33 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof UpdateNodeParamsList && y instanceof UpdateNodeParamsList) {
              return Data_Eq.eq($dollar_EqMethod_39)(x.value0.methodList)(y.value0.methodList);
          };
          if (x instanceof UpdateNodeParamsGraph && y instanceof UpdateNodeParamsGraph) {
              return Data_Eq.eq($dollar_EqGraphMetric_45)(x.value0.methodGraph)(y.value0.methodGraph);
          };
          if (x instanceof UpdateNodeParamsTexts && y instanceof UpdateNodeParamsTexts) {
              return Data_Eq.eq($dollar_EqGranularity_51)(x.value0.methodTexts)(y.value0.methodTexts);
          };
          if (x instanceof UpdateNodeParamsBoard && y instanceof UpdateNodeParamsBoard) {
              return Data_Eq.eq($dollar_EqCharts_57)(x.value0.methodBoard)(y.value0.methodBoard);
          };
          return false;
      };
  });
  exports["UpdateNodeParamsList"] = UpdateNodeParamsList;
  exports["UpdateNodeParamsGraph"] = UpdateNodeParamsGraph;
  exports["UpdateNodeParamsTexts"] = UpdateNodeParamsTexts;
  exports["UpdateNodeParamsBoard"] = UpdateNodeParamsBoard;
  exports["Basic"] = Basic;
  exports["Advanced"] = Advanced;
  exports["WithModel"] = WithModel;
  exports["Order1"] = Order1;
  exports["Order2"] = Order2;
  exports["NewNgrams"] = NewNgrams;
  exports["NewTexts"] = NewTexts;
  exports["Both"] = Both;
  exports["Sources"] = Sources;
  exports["Authors"] = Authors;
  exports["Institutes"] = Institutes;
  exports["Ngrams"] = Ngrams;
  exports["All"] = All;
  exports["$_EqUpdateNodeParams_33"] = $dollar_EqUpdateNodeParams_33;
  exports["$_WriteForeignUpdateNodePar_37"] = $dollar_WriteForeignUpdateNodePar_37;
  exports["$_EqMethod_39"] = $dollar_EqMethod_39;
  exports["$_ShowMethod_40"] = $dollar_ShowMethod_40;
  exports["$_ReadMethod_43"] = $dollar_ReadMethod_43;
  exports["$_EqGraphMetric_45"] = $dollar_EqGraphMetric_45;
  exports["$_ShowGraphMetric_46"] = $dollar_ShowGraphMetric_46;
  exports["$_ReadGraphMetric_47"] = $dollar_ReadGraphMetric_47;
  exports["$_EqGranularity_51"] = $dollar_EqGranularity_51;
  exports["$_ShowGranularity_52"] = $dollar_ShowGranularity_52;
  exports["$_ReadGranularity_53"] = $dollar_ReadGranularity_53;
  exports["$_EqCharts_57"] = $dollar_EqCharts_57;
  exports["$_ShowCharts_58"] = $dollar_ShowCharts_58;
  exports["$_ReadCharts_59"] = $dollar_ReadCharts_59;
})(PS);
(function(exports) {
  "use strict";

  exports.size = function (blob) { return blob.size; };
})(PS["Web.File.Blob"] = PS["Web.File.Blob"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.File.Blob"] = $PS["Web.File.Blob"] || {};
  var exports = $PS["Web.File.Blob"];
  var $foreign = $PS["Web.File.Blob"];
  exports["size"] = $foreign.size;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload.Types"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload.Types"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload.Types"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Show_Generic = $PS["Data.Show.Generic"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Prelude = $PS["Gargantext.Prelude"];
  var Web_File_Blob = $PS["Web.File.Blob"];
  var CSV = (function () {
      function CSV() {

      };
      CSV.value = new CSV();
      return CSV;
  })();
  var CSV_HAL = (function () {
      function CSV_HAL() {

      };
      CSV_HAL.value = new CSV_HAL();
      return CSV_HAL;
  })();
  var WOS = (function () {
      function WOS() {

      };
      WOS.value = new WOS();
      return WOS;
  })();
  var PresseRIS = (function () {
      function PresseRIS() {

      };
      PresseRIS.value = new PresseRIS();
      return PresseRIS;
  })();
  var Arbitrary = (function () {
      function Arbitrary() {

      };
      Arbitrary.value = new Arbitrary();
      return Arbitrary;
  })();
  var $dollar_ReadFileType_9 = new Gargantext_Prelude.Read(function (v) {
      if (v === "Arbitrary") {
          return new Data_Maybe.Just(Arbitrary.value);
      };
      if (v === "CSV") {
          return new Data_Maybe.Just(CSV.value);
      };
      if (v === "CSV_HAL") {
          return new Data_Maybe.Just(CSV_HAL.value);
      };
      if (v === "PresseRIS") {
          return new Data_Maybe.Just(PresseRIS.value);
      };
      if (v === "WOS") {
          return new Data_Maybe.Just(WOS.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var $dollar_GenericFileType__6 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof CSV) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof CSV_HAL) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof WOS) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof PresseRIS) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
      };
      if (x instanceof Arbitrary) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))));
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (line 14, column 1 - line 14, column 35): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return CSV.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return CSV_HAL.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return WOS.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
          return PresseRIS.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inr))) {
          return Arbitrary.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Upload.Types (line 14, column 1 - line 14, column 35): " + [ x.constructor.name ]);
  });
  var $dollar_ShowFileType_8 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericFileType__6)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "CSV";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "CSV_HAL";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "WOS";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "PresseRIS";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Arbitrary";
  }))))))));
  var $dollar_EqUploadFileBlob_11 = new Data_Eq.Eq(function (v) {
      return function (v1) {
          return Web_File_Blob.size(v) === Web_File_Blob.size(v1);
      };
  });
  var $dollar_EqFileType_7 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericFileType__6)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)))))));
  exports["CSV"] = CSV;
  exports["CSV_HAL"] = CSV_HAL;
  exports["WOS"] = WOS;
  exports["PresseRIS"] = PresseRIS;
  exports["Arbitrary"] = Arbitrary;
  exports["$_EqFileType_7"] = $dollar_EqFileType_7;
  exports["$_ShowFileType_8"] = $dollar_ShowFileType_8;
  exports["$_ReadFileType_9"] = $dollar_ReadFileType_9;
  exports["$_EqUploadFileBlob_11"] = $dollar_EqUploadFileBlob_11;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types"] = $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Types = $PS["Gargantext.Types"];                
  var SubTreeParams = (function () {
      function SubTreeParams(value0) {
          this.value0 = value0;
      };
      SubTreeParams.create = function (value0) {
          return new SubTreeParams(value0);
      };
      return SubTreeParams;
  })();
  var SubTreeOut = (function () {
      function SubTreeOut(value0) {
          this.value0 = value0;
      };
      SubTreeOut.create = function (value0) {
          return new SubTreeOut(value0);
      };
      return SubTreeOut;
  })();
  var $dollar_GenericSubTreeParams__7 = new Data_Generic_Rep.Generic(function (x) {
      return x.value0;
  }, function (x) {
      return new SubTreeParams(x);
  });   
  var $dollar_GenericSubTreeOut__4 = new Data_Generic_Rep.Generic(function (x) {
      return x.value0;
  }, function (x) {
      return new SubTreeOut(x);
  });   
  var $dollar_EqSubTreeParams_8 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericSubTreeParams__7)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "valitypes";
  }))(Data_Eq.eqArray(Gargantext_Types["$_EqNodeType_114"])))()(new Data_Symbol.IsSymbol(function () {
      return "showtypes";
  }))(Data_Eq.eqArray(Gargantext_Types["$_EqNodeType_114"])))))));
  var $dollar_EqSubTreeOut_5 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericSubTreeOut__4)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "out";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "in";
  }))(Data_Eq.eqInt))))));
  exports["SubTreeOut"] = SubTreeOut;
  exports["SubTreeParams"] = SubTreeParams;
  exports["$_EqSubTreeOut_5"] = $dollar_EqSubTreeOut_5;
  exports["$_EqSubTreeParams_8"] = $dollar_EqSubTreeParams_8;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Settings"] = $PS["Gargantext.Components.Forest.Tree.Node.Settings"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Settings"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types = $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];                
  var Documentation = (function () {
      function Documentation(value0) {
          this.value0 = value0;
      };
      Documentation.create = function (value0) {
          return new Documentation(value0);
      };
      return Documentation;
  })();
  var SearchBox = (function () {
      function SearchBox() {

      };
      SearchBox.value = new SearchBox();
      return SearchBox;
  })();
  var Download = (function () {
      function Download() {

      };
      Download.value = new Download();
      return Download;
  })();
  var Upload = (function () {
      function Upload() {

      };
      Upload.value = new Upload();
      return Upload;
  })();
  var Refresh = (function () {
      function Refresh() {

      };
      Refresh.value = new Refresh();
      return Refresh;
  })();
  var Config = (function () {
      function Config() {

      };
      Config.value = new Config();
      return Config;
  })();
  var Delete = (function () {
      function Delete() {

      };
      Delete.value = new Delete();
      return Delete;
  })();
  var Share = (function () {
      function Share() {

      };
      Share.value = new Share();
      return Share;
  })();
  var Publish = (function () {
      function Publish(value0) {
          this.value0 = value0;
      };
      Publish.create = function (value0) {
          return new Publish(value0);
      };
      return Publish;
  })();
  var Add = (function () {
      function Add(value0) {
          this.value0 = value0;
      };
      Add.create = function (value0) {
          return new Add(value0);
      };
      return Add;
  })();
  var Merge = (function () {
      function Merge(value0) {
          this.value0 = value0;
      };
      Merge.create = function (value0) {
          return new Merge(value0);
      };
      return Merge;
  })();
  var Move = (function () {
      function Move(value0) {
          this.value0 = value0;
      };
      Move.create = function (value0) {
          return new Move(value0);
      };
      return Move;
  })();
  var Link = (function () {
      function Link(value0) {
          this.value0 = value0;
      };
      Link.create = function (value0) {
          return new Link(value0);
      };
      return Link;
  })();
  var Clone = (function () {
      function Clone() {

      };
      Clone.value = new Clone();
      return Clone;
  })();
  var AddingContact = (function () {
      function AddingContact() {

      };
      AddingContact.value = new AddingContact();
      return AddingContact;
  })();
  var CloseNodePopover = (function () {
      function CloseNodePopover() {

      };
      CloseNodePopover.value = new CloseNodePopover();
      return CloseNodePopover;
  })();
  var SettingsBox = (function () {
      function SettingsBox(value0) {
          this.value0 = value0;
      };
      SettingsBox.create = function (value0) {
          return new SettingsBox(value0);
      };
      return SettingsBox;
  })();
  var publishParams = {
      subTreeParams: new Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types.SubTreeParams({
          showtypes: [ Gargantext_Types.FolderPublic.value ],
          valitypes: [ Gargantext_Types.FolderPublic.value ]
      })
  };
  var moveParameters = {
      subTreeParams: new Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types.SubTreeParams({
          showtypes: [ Gargantext_Types.FolderPrivate.value, Gargantext_Types.FolderShared.value, Gargantext_Types.Team.value, Gargantext_Types.FolderPublic.value, Gargantext_Types.Folder.value ],
          valitypes: [ Gargantext_Types.FolderPrivate.value, Gargantext_Types.Team.value, Gargantext_Types.Folder.value ]
      })
  };
  var moveFrameParameters = {
      subTreeParams: new Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types.SubTreeParams({
          showtypes: [ Gargantext_Types.FolderPrivate.value, Gargantext_Types.FolderShared.value, Gargantext_Types.Team.value, Gargantext_Types.FolderPublic.value, Gargantext_Types.Folder.value, Gargantext_Types.Corpus.value, Gargantext_Types.NodeFrameWrite.value, Gargantext_Types.NodeFrameCalc.value ],
          valitypes: [ Gargantext_Types.FolderPrivate.value, Gargantext_Types.Team.value, Gargantext_Types.Folder.value, Gargantext_Types.Corpus.value, Gargantext_Types.NodeFrameWrite.value, Gargantext_Types.NodeFrameCalc.value ]
      })
  };
  var linkParams = function (nodeType) {
      return {
          subTreeParams: new Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types.SubTreeParams({
              showtypes: [ Gargantext_Types.FolderPrivate.value, Gargantext_Types.FolderShared.value, Gargantext_Types.Team.value, Gargantext_Types.FolderPublic.value, Gargantext_Types.Folder.value, nodeType ],
              valitypes: [ nodeType ]
          })
      };
  };
  var settingsBox = function (v) {
      if (v instanceof Gargantext_Types.NodeUser) {
          return new SettingsBox({
              show: true,
              edit: false,
              doc: new Documentation(Gargantext_Types.NodeUser.value),
              buttons: [ new Add([ Gargantext_Types.FolderPrivate.value, Gargantext_Types.FolderShared.value, Gargantext_Types.FolderPublic.value ]), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.FolderPrivate) {
          return new SettingsBox({
              show: true,
              edit: false,
              doc: new Documentation(Gargantext_Types.FolderPrivate.value),
              buttons: [ new Add([ Gargantext_Types.Corpus.value, Gargantext_Types.Folder.value, Gargantext_Types.Annuaire.value, Gargantext_Types.NodeFrameWrite.value, Gargantext_Types.NodeFrameCalc.value ]), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.Team) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.Team.value),
              buttons: [ new Add([ Gargantext_Types.Corpus.value, Gargantext_Types.Folder.value, Gargantext_Types.Annuaire.value, Gargantext_Types.NodeFrameWrite.value, Gargantext_Types.NodeFrameCalc.value, Gargantext_Types.Team.value, Gargantext_Types.FolderShared.value, Gargantext_Types.NodeFrameVisio.value ]), Share.value, Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.FolderShared) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.FolderShared.value),
              buttons: [ new Add([ Gargantext_Types.Team.value, Gargantext_Types.FolderShared.value ]), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.FolderPublic) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.FolderPublic.value),
              buttons: [ new Add([ Gargantext_Types.FolderPublic.value ]), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.Folder) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.Folder.value),
              buttons: [ new Add([ Gargantext_Types.Corpus.value, Gargantext_Types.Folder.value, Gargantext_Types.Annuaire.value, Gargantext_Types.NodeFrameWrite.value, Gargantext_Types.NodeFrameCalc.value ]), new Move(moveParameters), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.Corpus) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.Corpus.value),
              buttons: [ Upload.value, SearchBox.value, Download.value, new Add([ Gargantext_Types.NodeList.value, Gargantext_Types.Graph.value, Gargantext_Types.Dashboard.value, Gargantext_Types.NodeFrameWrite.value, Gargantext_Types.NodeFrameCalc.value, Gargantext_Types.Phylo.value ]), new Link(linkParams(Gargantext_Types.Annuaire.value)), new Move(moveParameters), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.Texts) {
          return new SettingsBox({
              show: true,
              edit: false,
              doc: new Documentation(Gargantext_Types.Texts.value),
              buttons: [ Refresh.value, Upload.value, Download.value, Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.Graph) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.Graph.value),
              buttons: [ Refresh.value, Config.value, Download.value, Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.NodePublic && v.value0 instanceof Gargantext_Types.Graph) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.Graph.value),
              buttons: [ Download.value, Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.NodePublic && v.value0 instanceof Gargantext_Types.Dashboard) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.Dashboard.value),
              buttons: [ Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.NodePublic && v.value0 instanceof Gargantext_Types.NodeFile) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.NodeFile.value),
              buttons: [ Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.NodePublic && v.value0 instanceof Gargantext_Types.FolderPublic) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.FolderPublic.value),
              buttons: [ new Add([ Gargantext_Types.FolderPublic.value ]), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.NodeList) {
          return new SettingsBox({
              show: true,
              edit: false,
              doc: new Documentation(Gargantext_Types.NodeList.value),
              buttons: [ Refresh.value, Config.value, Download.value, Upload.value, new Merge({
                  subTreeParams: new Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types.SubTreeParams({
                      showtypes: [ Gargantext_Types.FolderPrivate.value, Gargantext_Types.FolderShared.value, Gargantext_Types.Team.value, Gargantext_Types.FolderPublic.value, Gargantext_Types.Folder.value, Gargantext_Types.Corpus.value, Gargantext_Types.NodeList.value ],
                      valitypes: [ Gargantext_Types.NodeList.value ]
                  })
              }), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.Dashboard) {
          return new SettingsBox({
              show: true,
              edit: false,
              doc: new Documentation(Gargantext_Types.Dashboard.value),
              buttons: [ Refresh.value, new Publish(publishParams), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.Annuaire) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.Annuaire.value),
              buttons: [ Upload.value, AddingContact.value, new Move(moveParameters), new Link(linkParams(Gargantext_Types.Corpus.value)), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.NodeFrameWrite) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.NodeFrameWrite.value),
              buttons: [ new Add([ Gargantext_Types.NodeFrameWrite.value, Gargantext_Types.NodeFrameCalc.value ]), new Move(moveFrameParameters), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.NodeFrameCalc) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.NodeFrameCalc.value),
              buttons: [ new Add([ Gargantext_Types.NodeFrameCalc.value, Gargantext_Types.NodeFrameWrite.value ]), new Move(moveFrameParameters), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.NodeFrameNotebook) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.NodeFrameNotebook.value),
              buttons: [ new Add([ Gargantext_Types.NodeFrameCalc.value, Gargantext_Types.NodeFrameWrite.value, Gargantext_Types.NodeFrameNotebook.value ]), new Move(moveFrameParameters), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.NodeFrameVisio) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.NodeFrameVisio.value),
              buttons: [ new Add([ Gargantext_Types.NodeFrameVisio.value, Gargantext_Types.NodeFrameWrite.value, Gargantext_Types.NodeFrameCalc.value ]), Delete.value ]
          });
      };
      if (v instanceof Gargantext_Types.NodeFile) {
          return new SettingsBox({
              show: true,
              edit: true,
              doc: new Documentation(Gargantext_Types.NodeFile.value),
              buttons: [ new Publish(publishParams), Delete.value ]
          });
      };
      return new SettingsBox({
          show: false,
          edit: false,
          doc: new Documentation(Gargantext_Types.NodeUser.value),
          buttons: [  ]
      });
  };
  var glyphiconNodeAction = function (v) {
      if (v instanceof Documentation) {
          return "question-circle";
      };
      if (v instanceof Delete) {
          return "trash";
      };
      if (v instanceof Add) {
          return "plus";
      };
      if (v instanceof SearchBox) {
          return "search";
      };
      if (v instanceof Upload) {
          return "upload";
      };
      if (v instanceof Link) {
          return "arrows-h";
      };
      if (v instanceof Download) {
          return "download";
      };
      if (v instanceof Merge) {
          return "random";
      };
      if (v instanceof Refresh) {
          return "refresh";
      };
      if (v instanceof Config) {
          return "wrench";
      };
      if (v instanceof Share) {
          return "user-plus";
      };
      if (v instanceof AddingContact) {
          return "user-plus";
      };
      if (v instanceof Move) {
          return "share-square-o";
      };
      if (v instanceof Publish) {
          return Gargantext_Types.fldr(Gargantext_Types.FolderPublic.value)(true);
      };
      if (v instanceof CloseNodePopover) {
          return "close";
      };
      return "";
  };
  var $dollar_ShowNodeAction_6 = new Data_Show.Show(function (v) {
      if (v instanceof Documentation) {
          return "Documentation of " + Data_Show.show(Gargantext_Types["$_ShowNodeType_117"])(v.value0);
      };
      if (v instanceof SearchBox) {
          return "SearchBox";
      };
      if (v instanceof Download) {
          return "Download";
      };
      if (v instanceof Upload) {
          return "Upload";
      };
      if (v instanceof Refresh) {
          return "Refresh";
      };
      if (v instanceof Move) {
          return "Move with subtree params";
      };
      if (v instanceof Clone) {
          return "Clone";
      };
      if (v instanceof Delete) {
          return "Delete";
      };
      if (v instanceof Share) {
          return "Share";
      };
      if (v instanceof Config) {
          return "Config";
      };
      if (v instanceof Link) {
          return "Link to ";
      };
      if (v instanceof Add) {
          return "Add Child";
      };
      if (v instanceof Merge) {
          return "Merge with subtree";
      };
      if (v instanceof Publish) {
          return "Publish";
      };
      if (v instanceof AddingContact) {
          return "AddingContact";
      };
      if (v instanceof CloseNodePopover) {
          return "CloseNodePopover";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Settings (line 52, column 1 - line 68, column 46): " + [ v.constructor.name ]);
  });
  var $dollar_EqNodeAction_5 = new Data_Eq.Eq(function (v) {
      return function (v1) {
          if (v instanceof Documentation && v1 instanceof Documentation) {
              return true && Data_Eq.eq(Gargantext_Types["$_EqNodeType_114"])(v.value0)(v1.value0);
          };
          if (v instanceof SearchBox && v1 instanceof SearchBox) {
              return true;
          };
          if (v instanceof Download && v1 instanceof Download) {
              return true;
          };
          if (v instanceof Upload && v1 instanceof Upload) {
              return true;
          };
          if (v instanceof Refresh && v1 instanceof Refresh) {
              return true;
          };
          if (v instanceof Move && v1 instanceof Move) {
              return Data_Eq.eq(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "subTreeParams";
              }))(Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types["$_EqSubTreeParams_8"])))(v.value0)(v1.value0);
          };
          if (v instanceof Clone && v1 instanceof Clone) {
              return true;
          };
          if (v instanceof Delete && v1 instanceof Delete) {
              return true;
          };
          if (v instanceof Share && v1 instanceof Share) {
              return true;
          };
          if (v instanceof Link && v1 instanceof Link) {
              return Data_Eq.eq(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "subTreeParams";
              }))(Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types["$_EqSubTreeParams_8"])))(v.value0)(v1.value0);
          };
          if (v instanceof Add && v1 instanceof Add) {
              return Data_Eq.eq(Data_Eq.eqArray(Gargantext_Types["$_EqNodeType_114"]))(v.value0)(v1.value0);
          };
          if (v instanceof Merge && v1 instanceof Merge) {
              return Data_Eq.eq(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "subTreeParams";
              }))(Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types["$_EqSubTreeParams_8"])))(v.value0)(v1.value0);
          };
          if (v instanceof Config && v1 instanceof Config) {
              return true;
          };
          if (v instanceof Publish && v1 instanceof Publish) {
              return Data_Eq.eq(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "subTreeParams";
              }))(Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types["$_EqSubTreeParams_8"])))(v.value0)(v1.value0);
          };
          if (v instanceof AddingContact && v1 instanceof AddingContact) {
              return true;
          };
          if (v instanceof CloseNodePopover && v1 instanceof CloseNodePopover) {
              return true;
          };
          return false;
      };
  });
  exports["Documentation"] = Documentation;
  exports["SearchBox"] = SearchBox;
  exports["Download"] = Download;
  exports["Upload"] = Upload;
  exports["Refresh"] = Refresh;
  exports["Config"] = Config;
  exports["Delete"] = Delete;
  exports["Share"] = Share;
  exports["Publish"] = Publish;
  exports["Add"] = Add;
  exports["Merge"] = Merge;
  exports["Move"] = Move;
  exports["Link"] = Link;
  exports["AddingContact"] = AddingContact;
  exports["CloseNodePopover"] = CloseNodePopover;
  exports["glyphiconNodeAction"] = glyphiconNodeAction;
  exports["settingsBox"] = settingsBox;
  exports["$_EqNodeAction_5"] = $dollar_EqNodeAction_5;
  exports["$_ShowNodeAction_6"] = $dollar_ShowNodeAction_6;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action"] = $PS["Gargantext.Components.Forest.Tree.Node.Action"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_Forest_Tree_Node_Action_Contact_Types = $PS["Gargantext.Components.Forest.Tree.Node.Action.Contact.Types"];
  var Gargantext_Components_Forest_Tree_Node_Action_Update_Types = $PS["Gargantext.Components.Forest.Tree.Node.Action.Update.Types"];
  var Gargantext_Components_Forest_Tree_Node_Action_Upload_Types = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload.Types"];
  var Gargantext_Components_Forest_Tree_Node_Settings = $PS["Gargantext.Components.Forest.Tree.Node.Settings"];
  var Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types = $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];                
  var AddNode = (function () {
      function AddNode(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      AddNode.create = function (value0) {
          return function (value1) {
              return new AddNode(value0, value1);
          };
      };
      return AddNode;
  })();
  var DeleteNode = (function () {
      function DeleteNode(value0) {
          this.value0 = value0;
      };
      DeleteNode.create = function (value0) {
          return new DeleteNode(value0);
      };
      return DeleteNode;
  })();
  var RenameNode = (function () {
      function RenameNode(value0) {
          this.value0 = value0;
      };
      RenameNode.create = function (value0) {
          return new RenameNode(value0);
      };
      return RenameNode;
  })();
  var UpdateNode = (function () {
      function UpdateNode(value0) {
          this.value0 = value0;
      };
      UpdateNode.create = function (value0) {
          return new UpdateNode(value0);
      };
      return UpdateNode;
  })();
  var DoSearch = (function () {
      function DoSearch(value0) {
          this.value0 = value0;
      };
      DoSearch.create = function (value0) {
          return new DoSearch(value0);
      };
      return DoSearch;
  })();
  var UploadFile = (function () {
      function UploadFile(value0, value1, value2, value3) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
      };
      UploadFile.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return new UploadFile(value0, value1, value2, value3);
                  };
              };
          };
      };
      return UploadFile;
  })();
  var UploadArbitraryFile = (function () {
      function UploadArbitraryFile(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      UploadArbitraryFile.create = function (value0) {
          return function (value1) {
              return new UploadArbitraryFile(value0, value1);
          };
      };
      return UploadArbitraryFile;
  })();
  var DownloadNode = (function () {
      function DownloadNode() {

      };
      DownloadNode.value = new DownloadNode();
      return DownloadNode;
  })();
  var RefreshTree = (function () {
      function RefreshTree() {

      };
      RefreshTree.value = new RefreshTree();
      return RefreshTree;
  })();
  var ClosePopover = (function () {
      function ClosePopover() {

      };
      ClosePopover.value = new ClosePopover();
      return ClosePopover;
  })();
  var ShareTeam = (function () {
      function ShareTeam(value0) {
          this.value0 = value0;
      };
      ShareTeam.create = function (value0) {
          return new ShareTeam(value0);
      };
      return ShareTeam;
  })();
  var AddContact = (function () {
      function AddContact(value0) {
          this.value0 = value0;
      };
      AddContact.create = function (value0) {
          return new AddContact(value0);
      };
      return AddContact;
  })();
  var SharePublic = (function () {
      function SharePublic(value0) {
          this.value0 = value0;
      };
      SharePublic.create = function (value0) {
          return new SharePublic(value0);
      };
      return SharePublic;
  })();
  var MoveNode = (function () {
      function MoveNode(value0) {
          this.value0 = value0;
      };
      MoveNode.create = function (value0) {
          return new MoveNode(value0);
      };
      return MoveNode;
  })();
  var MergeNode = (function () {
      function MergeNode(value0) {
          this.value0 = value0;
      };
      MergeNode.create = function (value0) {
          return new MergeNode(value0);
      };
      return MergeNode;
  })();
  var LinkNode = (function () {
      function LinkNode(value0) {
          this.value0 = value0;
      };
      LinkNode.create = function (value0) {
          return new LinkNode(value0);
      };
      return LinkNode;
  })();
  var NoAction = (function () {
      function NoAction() {

      };
      NoAction.value = new NoAction();
      return NoAction;
  })();
  var text = function (v) {
      if (v instanceof AddNode) {
          return "Add !";
      };
      if (v instanceof DeleteNode) {
          return "Delete !";
      };
      if (v instanceof RenameNode) {
          return "Rename !";
      };
      if (v instanceof UpdateNode) {
          return "Update !";
      };
      if (v instanceof ShareTeam) {
          return "Share with team !";
      };
      if (v instanceof AddContact) {
          return "Add contact !";
      };
      if (v instanceof SharePublic) {
          return "Publish !";
      };
      if (v instanceof DoSearch) {
          return "Launch search !";
      };
      if (v instanceof UploadFile) {
          return "Upload File !";
      };
      if (v instanceof UploadArbitraryFile) {
          return "Upload arbitrary file !";
      };
      if (v instanceof RefreshTree) {
          return "Refresh Tree !";
      };
      if (v instanceof ClosePopover) {
          return "Close Popover !";
      };
      if (v instanceof DownloadNode) {
          return "Download !";
      };
      if (v instanceof MoveNode) {
          return "Move !";
      };
      if (v instanceof MergeNode) {
          return "Merge !";
      };
      if (v instanceof LinkNode) {
          return "Link !";
      };
      if (v instanceof NoAction) {
          return "No Action";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action (line 125, column 1 - line 125, column 25): " + [ v.constructor.name ]);
  };
  var subTreeOut = function (v) {
      if (v instanceof MoveNode) {
          return v.value0.params;
      };
      if (v instanceof MergeNode) {
          return v.value0.params;
      };
      if (v instanceof LinkNode) {
          return v.value0.params;
      };
      if (v instanceof SharePublic) {
          return v.value0.params;
      };
      return Data_Maybe.Nothing.value;
  };
  var setTreeOut = function (v) {
      return function (v1) {
          if (v instanceof MoveNode) {
              return new MoveNode({
                  params: v1
              });
          };
          if (v instanceof MergeNode) {
              return new MergeNode({
                  params: v1
              });
          };
          if (v instanceof LinkNode) {
              return new LinkNode({
                  nodeType: v.value0.nodeType,
                  params: v1
              });
          };
          if (v instanceof SharePublic) {
              return new SharePublic({
                  params: v1
              });
          };
          return v;
      };
  };
  var icon = function (v) {
      if (v instanceof AddNode) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(new Gargantext_Components_Forest_Tree_Node_Settings.Add([  ]));
      };
      if (v instanceof DeleteNode) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(Gargantext_Components_Forest_Tree_Node_Settings.Delete.value);
      };
      if (v instanceof RenameNode) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(Gargantext_Components_Forest_Tree_Node_Settings.Config.value);
      };
      if (v instanceof UpdateNode) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(Gargantext_Components_Forest_Tree_Node_Settings.Refresh.value);
      };
      if (v instanceof ShareTeam) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(Gargantext_Components_Forest_Tree_Node_Settings.Share.value);
      };
      if (v instanceof AddContact) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(Gargantext_Components_Forest_Tree_Node_Settings.Share.value);
      };
      if (v instanceof SharePublic) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(new Gargantext_Components_Forest_Tree_Node_Settings.Publish({
              subTreeParams: new Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types.SubTreeParams({
                  showtypes: [  ],
                  valitypes: [  ]
              })
          }));
      };
      if (v instanceof DoSearch) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(Gargantext_Components_Forest_Tree_Node_Settings.SearchBox.value);
      };
      if (v instanceof UploadFile) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(Gargantext_Components_Forest_Tree_Node_Settings.Upload.value);
      };
      if (v instanceof UploadArbitraryFile) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(Gargantext_Components_Forest_Tree_Node_Settings.Upload.value);
      };
      if (v instanceof RefreshTree) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(Gargantext_Components_Forest_Tree_Node_Settings.Refresh.value);
      };
      if (v instanceof ClosePopover) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(Gargantext_Components_Forest_Tree_Node_Settings.CloseNodePopover.value);
      };
      if (v instanceof DownloadNode) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(Gargantext_Components_Forest_Tree_Node_Settings.Download.value);
      };
      if (v instanceof MoveNode) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(new Gargantext_Components_Forest_Tree_Node_Settings.Move({
              subTreeParams: new Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types.SubTreeParams({
                  showtypes: [  ],
                  valitypes: [  ]
              })
          }));
      };
      if (v instanceof MergeNode) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(new Gargantext_Components_Forest_Tree_Node_Settings.Merge({
              subTreeParams: new Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types.SubTreeParams({
                  showtypes: [  ],
                  valitypes: [  ]
              })
          }));
      };
      if (v instanceof LinkNode) {
          return Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(new Gargantext_Components_Forest_Tree_Node_Settings.Link({
              subTreeParams: new Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types.SubTreeParams({
                  showtypes: [  ],
                  valitypes: [  ]
              })
          }));
      };
      if (v instanceof NoAction) {
          return "hand-o-right";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action (line 103, column 1 - line 103, column 25): " + [ v.constructor.name ]);
  };
  var $dollar_ShowAction_29 = new Data_Show.Show(function (v) {
      if (v instanceof AddNode) {
          return "AddNode";
      };
      if (v instanceof DeleteNode) {
          return "DeleteNode";
      };
      if (v instanceof RenameNode) {
          return "RenameNode";
      };
      if (v instanceof UpdateNode) {
          return "UpdateNode";
      };
      if (v instanceof ShareTeam) {
          return "ShareTeam";
      };
      if (v instanceof AddContact) {
          return "AddContact";
      };
      if (v instanceof SharePublic) {
          return "SharePublic";
      };
      if (v instanceof DoSearch) {
          return "SearchQuery";
      };
      if (v instanceof UploadFile) {
          return "UploadFile";
      };
      if (v instanceof UploadArbitraryFile) {
          return "UploadArbitraryFile";
      };
      if (v instanceof RefreshTree) {
          return "RefreshTree";
      };
      if (v instanceof ClosePopover) {
          return "ClosePopover";
      };
      if (v instanceof DownloadNode) {
          return "Download";
      };
      if (v instanceof MoveNode) {
          return "MoveNode";
      };
      if (v instanceof MergeNode) {
          return "MergeNode";
      };
      if (v instanceof LinkNode) {
          return "LinkNode";
      };
      if (v instanceof NoAction) {
          return "NoAction";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action (line 83, column 1 - line 100, column 47): " + [ v.constructor.name ]);
  });
  var $dollar_EqAction_28 = new Data_Eq.Eq(function (v) {
      return function (v1) {
          if (v instanceof AddNode && v1 instanceof AddNode) {
              return v.value0 === v1.value0 && Data_Eq.eq(Gargantext_Types["$_EqNodeType_114"])(v.value1)(v1.value1);
          };
          if (v instanceof DeleteNode && v1 instanceof DeleteNode) {
              return Data_Eq.eq(Gargantext_Types["$_EqNodeType_114"])(v.value0)(v1.value0);
          };
          if (v instanceof RenameNode && v1 instanceof RenameNode) {
              return v.value0 === v1.value0;
          };
          if (v instanceof UpdateNode && v1 instanceof UpdateNode) {
              return Data_Eq.eq(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_EqUpdateNodeParams_33"])(v.value0)(v1.value0);
          };
          if (v instanceof DoSearch && v1 instanceof DoSearch) {
              return Data_Eq.eq(Gargantext_Types["$_EqAsyncTaskWithType_172"])(v.value0)(v1.value0);
          };
          if (v instanceof UploadFile && v1 instanceof UploadFile) {
              return Data_Eq.eq(Gargantext_Types["$_EqNodeType_114"])(v.value0)(v1.value0) && (Data_Eq.eq(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_EqFileType_7"])(v.value1)(v1.value1) && Data_Eq.eq(Data_Maybe.eqMaybe(Data_Eq.eqString))(v.value2)(v1.value2));
          };
          if (v instanceof UploadArbitraryFile && v1 instanceof UploadArbitraryFile) {
              return Data_Eq.eq(Data_Maybe.eqMaybe(Data_Eq.eqString))(v.value0)(v1.value0);
          };
          if (v instanceof DownloadNode && v1 instanceof DownloadNode) {
              return true;
          };
          if (v instanceof RefreshTree && v1 instanceof RefreshTree) {
              return true;
          };
          if (v instanceof ClosePopover && v1 instanceof ClosePopover) {
              return true;
          };
          if (v instanceof ShareTeam && v1 instanceof ShareTeam) {
              return v.value0 === v1.value0;
          };
          if (v instanceof AddContact && v1 instanceof AddContact) {
              return Data_Eq.eq(Gargantext_Components_Forest_Tree_Node_Action_Contact_Types["$_EqAddContactParams_6"])(v.value0)(v1.value0);
          };
          if (v instanceof SharePublic && v1 instanceof SharePublic) {
              return Data_Eq.eq(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "params";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types["$_EqSubTreeOut_5"]))))(v.value0)(v1.value0);
          };
          if (v instanceof MoveNode && v1 instanceof MoveNode) {
              return Data_Eq.eq(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "params";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types["$_EqSubTreeOut_5"]))))(v.value0)(v1.value0);
          };
          if (v instanceof MergeNode && v1 instanceof MergeNode) {
              return Data_Eq.eq(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "params";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types["$_EqSubTreeOut_5"]))))(v.value0)(v1.value0);
          };
          if (v instanceof LinkNode && v1 instanceof LinkNode) {
              return Data_Eq.eq(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "params";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types["$_EqSubTreeOut_5"])))()(new Data_Symbol.IsSymbol(function () {
                  return "nodeType";
              }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqNodeType_114"]))))(v.value0)(v1.value0);
          };
          if (v instanceof NoAction && v1 instanceof NoAction) {
              return true;
          };
          return false;
      };
  });
  exports["AddNode"] = AddNode;
  exports["DeleteNode"] = DeleteNode;
  exports["RenameNode"] = RenameNode;
  exports["UpdateNode"] = UpdateNode;
  exports["DoSearch"] = DoSearch;
  exports["UploadFile"] = UploadFile;
  exports["UploadArbitraryFile"] = UploadArbitraryFile;
  exports["DownloadNode"] = DownloadNode;
  exports["RefreshTree"] = RefreshTree;
  exports["ClosePopover"] = ClosePopover;
  exports["ShareTeam"] = ShareTeam;
  exports["AddContact"] = AddContact;
  exports["SharePublic"] = SharePublic;
  exports["MoveNode"] = MoveNode;
  exports["MergeNode"] = MergeNode;
  exports["LinkNode"] = LinkNode;
  exports["NoAction"] = NoAction;
  exports["subTreeOut"] = subTreeOut;
  exports["setTreeOut"] = setTreeOut;
  exports["icon"] = icon;
  exports["text"] = text;
  exports["$_EqAction_28"] = $dollar_EqAction_28;
  exports["$_ShowAction_29"] = $dollar_ShowAction_29;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.InputWithEnter"] = $PS["Gargantext.Components.InputWithEnter"] || {};
  var exports = $PS["Gargantext.Components.InputWithEnter"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Unit = $PS["Data.Unit"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.InputWithEnter");
  var inputWithEnterCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onKeyPress = function (e) {
                  return function __do() {
                      var $$char = Gargantext_Utils_Reactix.keyCode(e)();
                      var $4 = $$char === 13;
                      if ($4) {
                          return v.onEnter(Data_Unit.unit)();
                      };
                      return Data_Unit.unit;
                  };
              };
              var onInput = function (e) {
                  return v.onValueChanged(Reactix_SyntheticEvent.unsafeEventValue(e));
              };
              var onBlur$prime = function (e) {
                  return v.onBlur(Reactix_SyntheticEvent.unsafeEventValue(e));
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.input({
                  on: {
                      blur: onBlur$prime,
                      input: onInput,
                      keyPress: onKeyPress
                  },
                  autoFocus: v.autoFocus,
                  className: v.className,
                  defaultValue: v.defaultValue,
                  placeholder: v.placeholder,
                  type: v.type
              }));
          };
      };
      return here.component("inputWithEnter")(cpt);
  })();
  var inputWithEnter = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(inputWithEnterCpt)(props)([  ]);
  };
  exports["inputWithEnter"] = inputWithEnter;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Routes"] = $PS["Gargantext.Routes"] || {};
  var exports = $PS["Gargantext.Routes"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Gargantext_Types = $PS["Gargantext.Types"];                
  var Tab = (function () {
      function Tab(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Tab.create = function (value0) {
          return function (value1) {
              return new Tab(value0, value1);
          };
      };
      return Tab;
  })();
  var Children = (function () {
      function Children(value0, value1, value2, value3, value4) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
          this.value4 = value4;
      };
      Children.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return function (value4) {
                          return new Children(value0, value1, value2, value3, value4);
                      };
                  };
              };
          };
      };
      return Children;
  })();
  var GetNgrams = (function () {
      function GetNgrams(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      GetNgrams.create = function (value0) {
          return function (value1) {
              return new GetNgrams(value0, value1);
          };
      };
      return GetNgrams;
  })();
  var GetNgramsTableAll = (function () {
      function GetNgramsTableAll(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      GetNgramsTableAll.create = function (value0) {
          return function (value1) {
              return new GetNgramsTableAll(value0, value1);
          };
      };
      return GetNgramsTableAll;
  })();
  var GetNgramsTableVersion = (function () {
      function GetNgramsTableVersion(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      GetNgramsTableVersion.create = function (value0) {
          return function (value1) {
              return new GetNgramsTableVersion(value0, value1);
          };
      };
      return GetNgramsTableVersion;
  })();
  var PutNgrams = (function () {
      function PutNgrams(value0, value1, value2, value3) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
      };
      PutNgrams.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return new PutNgrams(value0, value1, value2, value3);
                  };
              };
          };
      };
      return PutNgrams;
  })();
  var PostNgramsChartsAsync = (function () {
      function PostNgramsChartsAsync(value0) {
          this.value0 = value0;
      };
      PostNgramsChartsAsync.create = function (value0) {
          return new PostNgramsChartsAsync(value0);
      };
      return PostNgramsChartsAsync;
  })();
  var RecomputeNgrams = (function () {
      function RecomputeNgrams(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      RecomputeNgrams.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new RecomputeNgrams(value0, value1, value2);
              };
          };
      };
      return RecomputeNgrams;
  })();
  var RecomputeListChart = (function () {
      function RecomputeListChart(value0, value1, value2, value3) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
      };
      RecomputeListChart.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return new RecomputeListChart(value0, value1, value2, value3);
                  };
              };
          };
      };
      return RecomputeListChart;
  })();
  var NodeAPI = (function () {
      function NodeAPI(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      NodeAPI.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new NodeAPI(value0, value1, value2);
              };
          };
      };
      return NodeAPI;
  })();
  var TreeFirstLevel = (function () {
      function TreeFirstLevel(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      TreeFirstLevel.create = function (value0) {
          return function (value1) {
              return new TreeFirstLevel(value0, value1);
          };
      };
      return TreeFirstLevel;
  })();
  var GraphAPI = (function () {
      function GraphAPI(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      GraphAPI.create = function (value0) {
          return function (value1) {
              return new GraphAPI(value0, value1);
          };
      };
      return GraphAPI;
  })();
  var ListsRoute = (function () {
      function ListsRoute(value0) {
          this.value0 = value0;
      };
      ListsRoute.create = function (value0) {
          return new ListsRoute(value0);
      };
      return ListsRoute;
  })();
  var ListDocument = (function () {
      function ListDocument(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      ListDocument.create = function (value0) {
          return function (value1) {
              return new ListDocument(value0, value1);
          };
      };
      return ListDocument;
  })();
  var Search = (function () {
      function Search(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Search.create = function (value0) {
          return function (value1) {
              return new Search(value0, value1);
          };
      };
      return Search;
  })();
  var CorpusMetrics = (function () {
      function CorpusMetrics(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      CorpusMetrics.create = function (value0) {
          return function (value1) {
              return new CorpusMetrics(value0, value1);
          };
      };
      return CorpusMetrics;
  })();
  var CorpusMetricsHash = (function () {
      function CorpusMetricsHash(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      CorpusMetricsHash.create = function (value0) {
          return function (value1) {
              return new CorpusMetricsHash(value0, value1);
          };
      };
      return CorpusMetricsHash;
  })();
  var Chart = (function () {
      function Chart(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Chart.create = function (value0) {
          return function (value1) {
              return new Chart(value0, value1);
          };
      };
      return Chart;
  })();
  var ChartHash = (function () {
      function ChartHash(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      ChartHash.create = function (value0) {
          return function (value1) {
              return new ChartHash(value0, value1);
          };
      };
      return ChartHash;
  })();
  var Annuaire = (function () {
      function Annuaire(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Annuaire.create = function (value0) {
          return function (value1) {
              return new Annuaire(value0, value1);
          };
      };
      return Annuaire;
  })();
  var ContactPage = (function () {
      function ContactPage(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      ContactPage.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new ContactPage(value0, value1, value2);
              };
          };
      };
      return ContactPage;
  })();
  var Corpus = (function () {
      function Corpus(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Corpus.create = function (value0) {
          return function (value1) {
              return new Corpus(value0, value1);
          };
      };
      return Corpus;
  })();
  var CorpusDocument = (function () {
      function CorpusDocument(value0, value1, value2, value3) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
      };
      CorpusDocument.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return new CorpusDocument(value0, value1, value2, value3);
                  };
              };
          };
      };
      return CorpusDocument;
  })();
  var Dashboard = (function () {
      function Dashboard(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Dashboard.create = function (value0) {
          return function (value1) {
              return new Dashboard(value0, value1);
          };
      };
      return Dashboard;
  })();
  var Document = (function () {
      function Document(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      Document.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new Document(value0, value1, value2);
              };
          };
      };
      return Document;
  })();
  var Folder = (function () {
      function Folder(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Folder.create = function (value0) {
          return function (value1) {
              return new Folder(value0, value1);
          };
      };
      return Folder;
  })();
  var FolderPrivate = (function () {
      function FolderPrivate(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      FolderPrivate.create = function (value0) {
          return function (value1) {
              return new FolderPrivate(value0, value1);
          };
      };
      return FolderPrivate;
  })();
  var FolderPublic = (function () {
      function FolderPublic(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      FolderPublic.create = function (value0) {
          return function (value1) {
              return new FolderPublic(value0, value1);
          };
      };
      return FolderPublic;
  })();
  var FolderShared = (function () {
      function FolderShared(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      FolderShared.create = function (value0) {
          return function (value1) {
              return new FolderShared(value0, value1);
          };
      };
      return FolderShared;
  })();
  var Home = (function () {
      function Home() {

      };
      Home.value = new Home();
      return Home;
  })();
  var Lists = (function () {
      function Lists(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Lists.create = function (value0) {
          return function (value1) {
              return new Lists(value0, value1);
          };
      };
      return Lists;
  })();
  var Login = (function () {
      function Login() {

      };
      Login.value = new Login();
      return Login;
  })();
  var PGraphExplorer = (function () {
      function PGraphExplorer(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      PGraphExplorer.create = function (value0) {
          return function (value1) {
              return new PGraphExplorer(value0, value1);
          };
      };
      return PGraphExplorer;
  })();
  var PhyloExplorer = (function () {
      function PhyloExplorer(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      PhyloExplorer.create = function (value0) {
          return function (value1) {
              return new PhyloExplorer(value0, value1);
          };
      };
      return PhyloExplorer;
  })();
  var RouteFile = (function () {
      function RouteFile(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      RouteFile.create = function (value0) {
          return function (value1) {
              return new RouteFile(value0, value1);
          };
      };
      return RouteFile;
  })();
  var RouteFrameCalc = (function () {
      function RouteFrameCalc(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      RouteFrameCalc.create = function (value0) {
          return function (value1) {
              return new RouteFrameCalc(value0, value1);
          };
      };
      return RouteFrameCalc;
  })();
  var RouteFrameCode = (function () {
      function RouteFrameCode(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      RouteFrameCode.create = function (value0) {
          return function (value1) {
              return new RouteFrameCode(value0, value1);
          };
      };
      return RouteFrameCode;
  })();
  var RouteFrameWrite = (function () {
      function RouteFrameWrite(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      RouteFrameWrite.create = function (value0) {
          return function (value1) {
              return new RouteFrameWrite(value0, value1);
          };
      };
      return RouteFrameWrite;
  })();
  var RouteFrameVisio = (function () {
      function RouteFrameVisio(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      RouteFrameVisio.create = function (value0) {
          return function (value1) {
              return new RouteFrameVisio(value0, value1);
          };
      };
      return RouteFrameVisio;
  })();
  var Team = (function () {
      function Team(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Team.create = function (value0) {
          return function (value1) {
              return new Team(value0, value1);
          };
      };
      return Team;
  })();
  var Texts = (function () {
      function Texts(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Texts.create = function (value0) {
          return function (value1) {
              return new Texts(value0, value1);
          };
      };
      return Texts;
  })();
  var UserPage = (function () {
      function UserPage(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      UserPage.create = function (value0) {
          return function (value1) {
              return new UserPage(value0, value1);
          };
      };
      return UserPage;
  })();
  var nodeTypeAppRoute = function (v) {
      return function (v1) {
          return function (v2) {
              if (v instanceof Gargantext_Types.Annuaire) {
                  return Data_Maybe.Just.create(new Annuaire(v1, v2));
              };
              if (v instanceof Gargantext_Types.Corpus) {
                  return Data_Maybe.Just.create(new Corpus(v1, v2));
              };
              if (v instanceof Gargantext_Types.Dashboard) {
                  return Data_Maybe.Just.create(new Dashboard(v1, v2));
              };
              if (v instanceof Gargantext_Types.Folder) {
                  return Data_Maybe.Just.create(new Folder(v1, v2));
              };
              if (v instanceof Gargantext_Types.FolderPrivate) {
                  return Data_Maybe.Just.create(new FolderPrivate(v1, v2));
              };
              if (v instanceof Gargantext_Types.FolderPublic) {
                  return Data_Maybe.Just.create(new FolderPublic(v1, v2));
              };
              if (v instanceof Gargantext_Types.FolderShared) {
                  return Data_Maybe.Just.create(new FolderShared(v1, v2));
              };
              if (v instanceof Gargantext_Types.Graph) {
                  return Data_Maybe.Just.create(new PGraphExplorer(v1, v2));
              };
              if (v instanceof Gargantext_Types.Phylo) {
                  return Data_Maybe.Just.create(new PhyloExplorer(v1, v2));
              };
              if (v instanceof Gargantext_Types.NodeContact) {
                  return Data_Maybe.Just.create(new Annuaire(v1, v2));
              };
              if (v instanceof Gargantext_Types.NodeFile) {
                  return Data_Maybe.Just.create(new RouteFile(v1, v2));
              };
              if (v instanceof Gargantext_Types.NodeList) {
                  return Data_Maybe.Just.create(new Lists(v1, v2));
              };
              if (v instanceof Gargantext_Types.NodeUser) {
                  return Data_Maybe.Just.create(new UserPage(v1, v2));
              };
              if (v instanceof Gargantext_Types.Team) {
                  return Data_Maybe.Just.create(new Team(v1, v2));
              };
              if (v instanceof Gargantext_Types.Texts) {
                  return Data_Maybe.Just.create(new Texts(v1, v2));
              };
              if (v instanceof Gargantext_Types.NodeFrameWrite) {
                  return Data_Maybe.Just.create(new RouteFrameWrite(v1, v2));
              };
              if (v instanceof Gargantext_Types.NodeFrameCalc) {
                  return Data_Maybe.Just.create(new RouteFrameCalc(v1, v2));
              };
              if (v instanceof Gargantext_Types.NodeFrameVisio) {
                  return Data_Maybe.Just.create(new RouteFrameVisio(v1, v2));
              };
              return Data_Maybe.Nothing.value;
          };
      };
  };
  var appPath = function (v) {
      if (v instanceof Home) {
          return "";
      };
      if (v instanceof Login) {
          return "login";
      };
      if (v instanceof Folder) {
          return "folder/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof FolderPrivate) {
          return "folderPrivate/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof FolderPublic) {
          return "folderPublic/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof FolderShared) {
          return "folderShared/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof Team) {
          return "team/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof CorpusDocument) {
          return "corpus/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + (Data_Show.show(Data_Show.showInt)(v.value1) + ("/list/" + (Data_Show.show(Data_Show.showInt)(v.value2) + ("/document/" + Data_Show.show(Data_Show.showInt)(v.value3)))))));
      };
      if (v instanceof Corpus) {
          return "corpus/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof Document) {
          return "list/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + (Data_Show.show(Data_Show.showInt)(v.value1) + ("/document/" + Data_Show.show(Data_Show.showInt)(v.value2)))));
      };
      if (v instanceof Dashboard) {
          return "dashboard/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof PGraphExplorer) {
          return "graph/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof PhyloExplorer) {
          return "phylo/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof Texts) {
          return "texts/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof Lists) {
          return "lists/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof Annuaire) {
          return "annuaire/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof UserPage) {
          return "user/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof ContactPage) {
          return "annuaire/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + (Data_Show.show(Data_Show.showInt)(v.value1) + ("/contact/" + Data_Show.show(Data_Show.showInt)(v.value2)))));
      };
      if (v instanceof RouteFrameWrite) {
          return "write/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof RouteFrameCalc) {
          return "calc/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof RouteFrameCode) {
          return "code/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof RouteFrameVisio) {
          return "visio/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      if (v instanceof RouteFile) {
          return "file/" + (Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(v.value0) + ("/" + Data_Show.show(Data_Show.showInt)(v.value1)));
      };
      throw new Error("Failed pattern match at Gargantext.Routes (line 89, column 1 - line 89, column 30): " + [ v.constructor.name ]);
  }; 
  var $dollar_EqAppRoute_99 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof Annuaire && y instanceof Annuaire) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof ContactPage && y instanceof ContactPage) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1 && x.value2 === y.value2;
          };
          if (x instanceof Corpus && y instanceof Corpus) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof CorpusDocument && y instanceof CorpusDocument) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1 && x.value2 === y.value2 && x.value3 === y.value3;
          };
          if (x instanceof Dashboard && y instanceof Dashboard) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof Document && y instanceof Document) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1 && x.value2 === y.value2;
          };
          if (x instanceof Folder && y instanceof Folder) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof FolderPrivate && y instanceof FolderPrivate) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof FolderPublic && y instanceof FolderPublic) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof FolderShared && y instanceof FolderShared) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof Home && y instanceof Home) {
              return true;
          };
          if (x instanceof Lists && y instanceof Lists) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof Login && y instanceof Login) {
              return true;
          };
          if (x instanceof PGraphExplorer && y instanceof PGraphExplorer) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof PhyloExplorer && y instanceof PhyloExplorer) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof RouteFile && y instanceof RouteFile) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof RouteFrameCalc && y instanceof RouteFrameCalc) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof RouteFrameCode && y instanceof RouteFrameCode) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof RouteFrameWrite && y instanceof RouteFrameWrite) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof RouteFrameVisio && y instanceof RouteFrameVisio) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof Team && y instanceof Team) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof Texts && y instanceof Texts) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          if (x instanceof UserPage && y instanceof UserPage) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(x.value0)(y.value0) && x.value1 === y.value1;
          };
          return false;
      };
  });
  exports["Annuaire"] = Annuaire;
  exports["ContactPage"] = ContactPage;
  exports["Corpus"] = Corpus;
  exports["CorpusDocument"] = CorpusDocument;
  exports["Dashboard"] = Dashboard;
  exports["Document"] = Document;
  exports["Folder"] = Folder;
  exports["FolderPrivate"] = FolderPrivate;
  exports["FolderPublic"] = FolderPublic;
  exports["FolderShared"] = FolderShared;
  exports["Home"] = Home;
  exports["Lists"] = Lists;
  exports["Login"] = Login;
  exports["PGraphExplorer"] = PGraphExplorer;
  exports["PhyloExplorer"] = PhyloExplorer;
  exports["RouteFile"] = RouteFile;
  exports["RouteFrameCalc"] = RouteFrameCalc;
  exports["RouteFrameCode"] = RouteFrameCode;
  exports["RouteFrameWrite"] = RouteFrameWrite;
  exports["RouteFrameVisio"] = RouteFrameVisio;
  exports["Team"] = Team;
  exports["Texts"] = Texts;
  exports["UserPage"] = UserPage;
  exports["Tab"] = Tab;
  exports["Children"] = Children;
  exports["GetNgrams"] = GetNgrams;
  exports["GetNgramsTableAll"] = GetNgramsTableAll;
  exports["GetNgramsTableVersion"] = GetNgramsTableVersion;
  exports["PutNgrams"] = PutNgrams;
  exports["PostNgramsChartsAsync"] = PostNgramsChartsAsync;
  exports["RecomputeNgrams"] = RecomputeNgrams;
  exports["RecomputeListChart"] = RecomputeListChart;
  exports["NodeAPI"] = NodeAPI;
  exports["TreeFirstLevel"] = TreeFirstLevel;
  exports["GraphAPI"] = GraphAPI;
  exports["ListsRoute"] = ListsRoute;
  exports["ListDocument"] = ListDocument;
  exports["Search"] = Search;
  exports["CorpusMetrics"] = CorpusMetrics;
  exports["CorpusMetricsHash"] = CorpusMetricsHash;
  exports["Chart"] = Chart;
  exports["ChartHash"] = ChartHash;
  exports["appPath"] = appPath;
  exports["nodeTypeAppRoute"] = nodeTypeAppRoute;
  exports["$_EqAppRoute_99"] = $dollar_EqAppRoute_99;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Ends"] = $PS["Gargantext.Ends"] || {};
  var exports = $PS["Gargantext.Ends"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var ToUrl = function (toUrl) {
      this.toUrl = toUrl;
  };
  var toUrl = function (dict) {
      return dict.toUrl;
  };
  var url = function (dictToUrl) {
      return toUrl(dictToUrl);
  };
  var orderUrl = function (dictShow) {
      return Data_Maybe.maybe("")(function (x) {
          return "&order=" + Data_Show.show(dictShow)(x);
      });
  };
  var orderByUrl = function (dictShow) {
      return Data_Maybe.maybe("")(function (x) {
          return "&orderBy=" + Data_Show.show(dictShow)(x);
      });
  };
  var offsetUrl = function (o) {
      return "&offset=" + Data_Show.show(Data_Show.showInt)(o);
  };
  var limitUrl = function (l) {
      return "&limit=" + Data_Show.show(Data_Show.showInt)(l);
  };
  var frontendUrl = function (v) {
      return function (path) {
          return v.baseUrl + (v.prePath + path);
      };
  };
  var frontend = function (baseUrl) {
      return function (prePath) {
          return function (name) {
              return {
                  name: name,
                  baseUrl: baseUrl,
                  prePath: prePath
              };
          };
      };
  };
  var defaultListAddMaybe = function (v) {
      if (v instanceof Data_Maybe.Nothing) {
          return "";
      };
      if (v instanceof Data_Maybe.Just) {
          return "&list=" + Data_Show.show(Data_Show.showInt)(v.value0);
      };
      throw new Error("Failed pattern match at Gargantext.Ends (line 226, column 1 - line 226, column 43): " + [ v.constructor.name ]);
  };
  var defaultList = function (n) {
      var $46 = n === 0;
      if ($46) {
          return "";
      };
      return "list=" + Data_Show.show(Data_Show.showInt)(n);
  };
  var sessionPath = function (v) {
      if (v instanceof Gargantext_Routes.Tab) {
          return sessionPath(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, v.value1, Gargantext_Types["showTabType'"](v.value0)));
      };
      if (v instanceof Gargantext_Routes.Children) {
          return sessionPath(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, v.value4, "children?type=" + (Data_Show.show(Gargantext_Types["$_ShowNodeType_117"])(v.value0) + (offsetUrl(v.value1) + (limitUrl(v.value2) + orderUrl(Gargantext_Types["$_ShowOrderBy_124"])(v.value3))))));
      };
      if (v instanceof Gargantext_Routes.NodeAPI && v.value0 instanceof Gargantext_Types.Phylo) {
          return "phyloscape?nodeId=" + (Data_Show.show(Data_Show.showInt)(Data_Maybe.fromMaybe(0)(v.value1)) + v.value2);
      };
      if (v instanceof Gargantext_Routes.RecomputeNgrams) {
          return "node/" + (Data_Show.show(Data_Show.showInt)(v.value1) + ("/ngrams/recompute?" + (defaultList(v.value2) + ("&ngramsType=" + Data_Show.show(Gargantext_Types["$_ShowTabSubType_146"](Gargantext_Types["$_ShowCTabNgramType_135"]))(v.value0)))));
      };
      if (v instanceof Gargantext_Routes.RecomputeListChart && v.value0 instanceof Gargantext_Types.ChartBar) {
          return "node/" + (Data_Show.show(Data_Show.showInt)(v.value2) + ("/pie?" + (defaultList(v.value3) + ("&ngramsType=" + Data_Show.show(Gargantext_Types["$_ShowCTabNgramType_135"])(v.value1)))));
      };
      if (v instanceof Gargantext_Routes.RecomputeListChart && v.value0 instanceof Gargantext_Types.ChartPie) {
          return "node/" + (Data_Show.show(Data_Show.showInt)(v.value2) + ("/pie?" + (defaultList(v.value3) + ("&ngramsType=" + Data_Show.show(Gargantext_Types["$_ShowCTabNgramType_135"])(v.value1)))));
      };
      if (v instanceof Gargantext_Routes.RecomputeListChart && v.value0 instanceof Gargantext_Types.ChartTree) {
          return "node/" + (Data_Show.show(Data_Show.showInt)(v.value2) + ("/tree?" + (defaultList(v.value3) + ("&ngramsType=" + (Data_Show.show(Gargantext_Types["$_ShowCTabNgramType_135"])(v.value1) + ("&listType=" + Data_Show.show(Gargantext_Types["$_ShowTermList_107"])(Gargantext_Types.MapTerm.value)))))));
      };
      if (v instanceof Gargantext_Routes.RecomputeListChart && v.value0 instanceof Gargantext_Types.Histo) {
          return "node/" + (Data_Show.show(Data_Show.showInt)(v.value2) + ("/chart?" + (defaultList(v.value3) + ("&ngramsType=" + Data_Show.show(Gargantext_Types["$_ShowCTabNgramType_135"])(v.value1)))));
      };
      if (v instanceof Gargantext_Routes.RecomputeListChart && v.value0 instanceof Gargantext_Types.Scatter) {
          return "node/" + (Data_Show.show(Data_Show.showInt)(v.value2) + ("/metrics?" + (defaultList(v.value3) + ("&ngramsType=" + Data_Show.show(Gargantext_Types["$_ShowCTabNgramType_135"])(v.value1)))));
      };
      if (v instanceof Gargantext_Routes.RecomputeListChart) {
          return "node/" + (Data_Show.show(Data_Show.showInt)(v.value2) + ("/recompute-chart?" + (defaultList(v.value3) + ("&ngramsType=" + Data_Show.show(Gargantext_Types["$_ShowCTabNgramType_135"])(v.value1)))));
      };
      if (v instanceof Gargantext_Routes.GraphAPI) {
          return "graph/" + (Data_Show.show(Data_Show.showInt)(v.value0) + ("/" + v.value1));
      };
      if (v instanceof Gargantext_Routes.GetNgrams) {
          var termSizeFilter = function (v1) {
              if (v1 instanceof Gargantext_Types.MonoTerm) {
                  return "&minTermSize=0&maxTermSize=1";
              };
              if (v1 instanceof Gargantext_Types.MultiTerm) {
                  return "&minTermSize=2";
              };
              throw new Error("Failed pattern match at Gargantext.Ends (line 136, column 5 - line 136, column 61): " + [ v1.constructor.name ]);
          };
          var search = function (v1) {
              if (v1 === "") {
                  return "";
              };
              return "&search=" + v1;
          };
          var offset = function (v1) {
              if (v1 instanceof Data_Maybe.Nothing) {
                  return "";
              };
              if (v1 instanceof Data_Maybe.Just) {
                  return offsetUrl(v1.value0);
              };
              throw new Error("Failed pattern match at Gargantext.Ends (line 134, column 5 - line 134, column 24): " + [ v1.constructor.name ]);
          };
          var base = function (v1) {
              if (v1 instanceof Gargantext_Types.TabCorpus) {
                  var $166 = Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value)(v.value1);
                  return function ($167) {
                      return sessionPath($166($167));
                  };
              };
              var $168 = Gargantext_Routes.NodeAPI.create(Gargantext_Types.Url_Document.value)(v.value1);
              return function ($169) {
                  return sessionPath($168($169));
              };
          };
          return base(v.value0.tabType)("ngrams?ngramsType=" + (Gargantext_Types["showTabType'"](v.value0.tabType) + (limitUrl(v.value0.limit) + (offset(v.value0.offset) + (orderByUrl(Gargantext_Types["$_ShowOrderBy_124"])(v.value0.orderBy) + (Data_Foldable.foldMap(Data_Foldable.foldableArray)(Data_Monoid.monoidString)(function (x) {
              var $93 = x !== 0;
              if ($93) {
                  return "&list=" + Data_Show.show(Data_Show.showInt)(x);
              };
              return "";
          })(v.value0.listIds) + (Data_Foldable.foldMap(Data_Foldable.foldableMaybe)(Data_Monoid.monoidString)(function (x) {
              return "&listType=" + Data_Show.show(Gargantext_Types["$_ShowTermList_107"])(x);
          })(v.value0.termListFilter) + (Data_Foldable.foldMap(Data_Foldable.foldableMaybe)(Data_Monoid.monoidString)(termSizeFilter)(v.value0.termSizeFilter) + search(v.value0.searchQuery)))))))));
      };
      if (v instanceof Gargantext_Routes.GetNgramsTableAll) {
          return sessionPath(Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value)(v.value1)("ngrams?ngramsType=" + (Gargantext_Types["showTabType'"](v.value0.tabType) + (Data_Foldable.foldMap(Data_Foldable.foldableArray)(Data_Monoid.monoidString)(function (x) {
              return "&list=" + Data_Show.show(Data_Show.showInt)(x);
          })(v.value0.listIds) + limitUrl(100000)))));
      };
      if (v instanceof Gargantext_Routes.GetNgramsTableVersion) {
          return sessionPath(Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value)(v.value1)("ngrams/version?ngramsType=" + (Gargantext_Types["showTabType'"](v.value0.tabType) + ("&list=" + Data_Show.show(Data_Show.showInt)(v.value0.listId)))));
      };
      if (v instanceof Gargantext_Routes.ListDocument) {
          return sessionPath(new Gargantext_Routes.NodeAPI(Gargantext_Types.NodeList.value, v.value0, "document/" + Data_Show.show(Data_Show.showInt)(Data_Maybe.fromMaybe(0)(v.value1))));
      };
      if (v instanceof Gargantext_Routes.ListsRoute) {
          return "lists/" + Data_Show.show(Data_Show.showInt)(v.value0);
      };
      if (v instanceof Gargantext_Routes.PutNgrams) {
          return sessionPath(Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value)(v.value3)("ngrams?ngramsType=" + (Gargantext_Types["showTabType'"](v.value0) + (Data_Maybe.maybe("")(function (x) {
              return "&list=" + Data_Show.show(Data_Show.showInt)(x);
          })(v.value1) + Data_Foldable.foldMap(Data_Foldable.foldableMaybe)(Data_Monoid.monoidString)(function (x) {
              return "&listType=" + Data_Show.show(Gargantext_Types["$_ShowTermList_107"])(x);
          })(v.value2)))));
      };
      if (v instanceof Gargantext_Routes.PostNgramsChartsAsync) {
          return sessionPath(Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value)(v.value0)("ngrams/async/charts/update"));
      };
      if (v instanceof Gargantext_Routes.NodeAPI) {
          return Gargantext_Types.nodeTypePath(v.value0) + (Data_Maybe.maybe("")(function (i$prime) {
              return "/" + Data_Show.show(Data_Show.showInt)(i$prime);
          })(v.value1) + (function () {
              var $108 = v.value2 === "";
              if ($108) {
                  return "";
              };
              return "/" + v.value2;
          })());
      };
      if (v instanceof Gargantext_Routes.TreeFirstLevel) {
          return Gargantext_Types.nodeTypePath(Gargantext_Types.Tree.value) + (Data_Maybe.maybe("")(function (nId$prime) {
              return "/" + Data_Show.show(Data_Show.showInt)(nId$prime);
          })(v.value0) + ("/first-level" + v.value1));
      };
      if (v instanceof Gargantext_Routes.Search && v.value1 instanceof Data_Maybe.Nothing) {
          return sessionPath(Gargantext_Routes.NodeAPI.create(Gargantext_Types.Corpus.value)(Data_Maybe.Nothing.value)("search?list_id=" + (Data_Show.show(Data_Show.showInt)(v.value0.listId) + (offsetUrl(v.value0.offset) + (limitUrl(v.value0.limit) + orderUrl(Gargantext_Types["$_ShowOrderBy_124"])(v.value0.orderBy))))));
      };
      if (v instanceof Gargantext_Routes.Search && v.value1 instanceof Data_Maybe.Just) {
          return sessionPath(Gargantext_Routes.NodeAPI.create(Gargantext_Types.Corpus.value)(new Data_Maybe.Just(v.value1.value0))("search?list_id=" + (Data_Show.show(Data_Show.showInt)(v.value0.listId) + (offsetUrl(v.value0.offset) + (limitUrl(v.value0.limit) + orderUrl(Gargantext_Types["$_ShowOrderBy_124"])(v.value0.orderBy))))));
      };
      if (v instanceof Gargantext_Routes.CorpusMetrics) {
          return sessionPath(Gargantext_Routes.NodeAPI.create(Gargantext_Types.Corpus.value)(v.value1)("metrics" + ("?ngrams=" + (Data_Show.show(Data_Show.showInt)(v.value0.listId) + ("&ngramsType=" + (Gargantext_Types["showTabType'"](v.value0.tabType) + Data_Maybe.maybe("")(limitUrl)(v.value0.limit)))))));
      };
      if (v instanceof Gargantext_Routes.CorpusMetricsHash) {
          return sessionPath(Gargantext_Routes.NodeAPI.create(Gargantext_Types.Corpus.value)(v.value1)("metrics/hash" + ("?ngrams=" + (Data_Show.show(Data_Show.showInt)(v.value0.listId) + ("&ngramsType=" + Gargantext_Types["showTabType'"](v.value0.tabType))))));
      };
      if (v instanceof Gargantext_Routes.Chart) {
          var limitPath = (function () {
              if (v.value0.limit instanceof Data_Maybe.Just) {
                  return "&limit=" + Data_Show.show(Data_Show.showInt)(v.value0.limit.value0);
              };
              if (v.value0.limit instanceof Data_Maybe.Nothing) {
                  return "";
              };
              throw new Error("Failed pattern match at Gargantext.Ends (line 205, column 19 - line 207, column 22): " + [ v.value0.limit.constructor.name ]);
          })();
          return sessionPath(Gargantext_Routes.NodeAPI.create(Gargantext_Types.Corpus.value)(v.value1)(Data_Show.show(Gargantext_Types["$_ShowChartType_122"])(v.value0.chartType) + ("?ngramsType=" + (Gargantext_Types["showTabType'"](v.value0.tabType) + ("&listType=" + (Data_Show.show(Gargantext_Types["$_ShowTermList_107"])(Gargantext_Types.MapTerm.value) + defaultListAddMaybe(v.value0.listId)))))));
      };
      if (v instanceof Gargantext_Routes.ChartHash) {
          return sessionPath(Gargantext_Routes.NodeAPI.create(Gargantext_Types.Corpus.value)(v.value1)(Data_Show.show(Gargantext_Types["$_ShowChartType_122"])(v.value0.chartType) + ("/hash?ngramsType=" + (Gargantext_Types["showTabType'"](v.value0.tabType) + ("&listType=" + (Data_Show.show(Gargantext_Types["$_ShowTermList_107"])(Gargantext_Types.MapTerm.value) + defaultListAddMaybe(v.value0.listId)))))));
      };
      throw new Error("Failed pattern match at Gargantext.Ends (line 109, column 1 - line 109, column 40): " + [ v.constructor.name ]);
  };
  var backendUrl = function (v) {
      return function (path) {
          return v.baseUrl + (v.prePath + (Data_Show.show(Gargantext_Types["$_ShowApiVersion_130"])(v.version) + ("/" + path)));
      };
  };
  var backend = function (version) {
      return function (prePath) {
          return function (baseUrl) {
              return function (name) {
                  return {
                      name: name,
                      version: version,
                      prePath: prePath,
                      baseUrl: baseUrl
                  };
              };
          };
      };
  };
  var appUrl = function (v) {
      return frontendUrl(v.app);
  };
  var $dollar_WriteForeignBackend_24 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "baseUrl";
  }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "prePath";
  }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "version";
  }))(Gargantext_Types["$_WriteForeignApiVersion_129"])(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()());
  var $dollar_ToUrlFrontendsNodePath_36 = new ToUrl(function (v) {
      return function (np) {
          return frontendUrl(v.app)(Gargantext_Types.nodePath(np));
      };
  });
  var $dollar_ToUrlFrontendsAppRoute_35 = new ToUrl(function (f) {
      return function (r) {
          return appUrl(f)(Gargantext_Routes.appPath(r));
      };
  });
  var $dollar_ToUrlBackendString_27 = new ToUrl(backendUrl);
  var $dollar_ShowBackend_26 = new Data_Show.Show(function (v) {
      return v.name;
  });
  var $dollar_ReadForeignBackend_23 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "baseUrl";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "prePath";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "version";
  }))(Gargantext_Types["$_ReadForeignApiVersion_128"])(Simple_JSON.readFieldsNil)()())()())()())()());
  var $dollar_GenericBackend__21 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqBackend_25 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericBackend__21)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "version";
  }))(Gargantext_Types["$_EqApiVersion_131"]))()(new Data_Symbol.IsSymbol(function () {
      return "prePath";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "baseUrl";
  }))(Data_Eq.eqString))))));
  exports["toUrl"] = toUrl;
  exports["ToUrl"] = ToUrl;
  exports["url"] = url;
  exports["backend"] = backend;
  exports["backendUrl"] = backendUrl;
  exports["frontend"] = frontend;
  exports["sessionPath"] = sessionPath;
  exports["$_ReadForeignBackend_23"] = $dollar_ReadForeignBackend_23;
  exports["$_WriteForeignBackend_24"] = $dollar_WriteForeignBackend_24;
  exports["$_EqBackend_25"] = $dollar_EqBackend_25;
  exports["$_ShowBackend_26"] = $dollar_ShowBackend_26;
  exports["$_ToUrlBackendString_27"] = $dollar_ToUrlBackendString_27;
  exports["$_ToUrlFrontendsAppRoute_35"] = $dollar_ToUrlFrontendsAppRoute_35;
  exports["$_ToUrlFrontendsNodePath_36"] = $dollar_ToUrlFrontendsNodePath_36;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Lists.Types"] = $PS["Gargantext.Components.Nodes.Lists.Types"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Lists.Types"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Show_Generic = $PS["Data.Show.Generic"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Simple_JSON_Generics_EnumSumRep = $PS["Simple.JSON.Generics.EnumSumRep"];                
  var CacheOn = (function () {
      function CacheOn() {

      };
      CacheOn.value = new CacheOn();
      return CacheOn;
  })();
  var CacheOff = (function () {
      function CacheOff() {

      };
      CacheOff.value = new CacheOff();
      return CacheOff;
  })();
  var initialSidePanel = Data_Maybe.Nothing.value;                                    
  var $dollar_GenericCacheState__1 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof CacheOn) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof CacheOff) {
          return new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Lists.Types (line 18, column 1 - line 18, column 37): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return CacheOn.value;
      };
      if (x instanceof Data_Generic_Rep.Inr) {
          return CacheOff.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Lists.Types (line 18, column 1 - line 18, column 37): " + [ x.constructor.name ]);
  });
  var $dollar_ReadForeignCacheState_2 = new Simple_JSON.ReadForeign(Simple_JSON_Generics_EnumSumRep.enumSumRep($dollar_GenericCacheState__1)(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "CacheOn";
  })))(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "CacheOff";
  })))));
  var $dollar_ShowCacheState_5 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericCacheState__1)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "CacheOn";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "CacheOff";
  })))));
  var $dollar_WriteForeignCacheState_3 = new Simple_JSON.WriteForeign((function () {
      var $10 = Simple_JSON.writeImpl(Simple_JSON.writeForeignString);
      var $11 = Data_Show.show($dollar_ShowCacheState_5);
      return function ($12) {
          return $10($11($12));
      };
  })());
  var $dollar_EqCacheState_4 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericCacheState__1)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))));
  exports["CacheOn"] = CacheOn;
  exports["CacheOff"] = CacheOff;
  exports["initialSidePanel"] = initialSidePanel;
  exports["$_ReadForeignCacheState_2"] = $dollar_ReadForeignCacheState_2;
  exports["$_WriteForeignCacheState_3"] = $dollar_WriteForeignCacheState_3;
  exports["$_EqCacheState_4"] = $dollar_EqCacheState_4;
  exports["$_ShowCacheState_5"] = $dollar_ShowCacheState_5;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.Tuple"] = $PS["Gargantext.Utils.Tuple"] || {};
  var exports = $PS["Gargantext.Utils.Tuple"];
  var Data_Tuple = $PS["Data.Tuple"];                
  var mapFst = function (f) {
      return function (v) {
          return new Data_Tuple.Tuple(f(v.value0), v.value1);
      };
  };
  exports["mapFst"] = mapFst;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Sessions.Types"] = $PS["Gargantext.Sessions.Types"] || {};
  var exports = $PS["Gargantext.Sessions.Types"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Array = $PS["Data.Array"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Either = $PS["Data.Either"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Int = $PS["Data.Int"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Set = $PS["Data.Set"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Data_Unit = $PS["Data.Unit"];
  var Foreign_Object = $PS["Foreign.Object"];
  var Gargantext_Components_Nodes_Lists_Types = $PS["Gargantext.Components.Nodes.Lists.Types"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_JSON = $PS["Gargantext.Utils.JSON"];
  var Gargantext_Utils_Tuple = $PS["Gargantext.Utils.Tuple"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];                
  var Session = function (x) {
      return x;
  };
  var OpenNodes = function (x) {
      return x;
  };
  var unSessions = function (v) {
      return Data_Array.fromFoldable(Data_Sequence.foldableSeq)(v.sessions);
  };
  var toggleSet = function (val) {
      return function (v) {
          return function (v1) {
              if (v) {
                  return OpenNodes(Data_Set.insert(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
                      return "treeId";
                  }))(Data_Ord.ordInt))()(new Data_Symbol.IsSymbol(function () {
                      return "baseUrl";
                  }))(Data_Ord.ordString)))(val)(v1));
              };
              if (!v) {
                  return OpenNodes(Data_Set["delete"](Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
                      return "treeId";
                  }))(Data_Ord.ordInt))()(new Data_Symbol.IsSymbol(function () {
                      return "baseUrl";
                  }))(Data_Ord.ordString)))(val)(v1));
              };
              throw new Error("Failed pattern match at Gargantext.Sessions.Types (line 169, column 1 - line 169, column 57): " + [ val.constructor.name, v.constructor.name, v1.constructor.name ]);
          };
      };
  };
  var useOpenNodesMemberBox = function (dictReadWrite) {
      return function (val) {
          return function (box) {
              return Toestand_Boxes.useFocused(dictReadWrite)(function (v) {
                  return Data_Set.member(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
                      return "treeId";
                  }))(Data_Ord.ordInt))()(new Data_Symbol.IsSymbol(function () {
                      return "baseUrl";
                  }))(Data_Ord.ordString)))(val)(v);
              })(toggleSet(val))(box);
          };
      };
  };
  var sessionUrl = function (v) {
      return Gargantext_Ends.backendUrl(v.backend);
  };
  var openNodesInsert = function (nodeId) {
      return function (v) {
          return OpenNodes(Data_Set.insert(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
              return "treeId";
          }))(Data_Ord.ordInt))()(new Data_Symbol.IsSymbol(function () {
              return "baseUrl";
          }))(Data_Ord.ordString)))(nodeId)(v));
      };
  };
  var openNodesDelete = function (nodeId) {
      return function (v) {
          return OpenNodes(Data_Set["delete"](Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
              return "treeId";
          }))(Data_Ord.ordInt))()(new Data_Symbol.IsSymbol(function () {
              return "baseUrl";
          }))(Data_Ord.ordString)))(nodeId)(v));
      };
  };
  var $$null = function (v) {
      return Data_Sequence["null"](v.sessions);
  };
  var mkNodeId = function (v) {
      return function (treeId) {
          return {
              treeId: treeId,
              baseUrl: v.backend.baseUrl
          };
      };
  };
  var empty = {
      sessions: Data_Sequence.empty
  };
  var cons = function (s) {
      return function (v) {
          return {
              sessions: Data_Sequence.cons(s)(v.sessions)
          };
      };
  };
  var $dollar_WriteForeignSession_32 = new Simple_JSON.WriteForeign(function (v) {
      var caches$prime = Simple_JSON.writeImpl(Simple_JSON.writeForeignObject(Gargantext_Components_Nodes_Lists_Types["$_WriteForeignCacheState_3"]))(Foreign_Object.fromFoldable(Data_Foldable.foldableArray)(Data_Functor.map(Data_Functor.functorArray)(Gargantext_Utils_Tuple.mapFst(Data_Show.show(Data_Show.showInt)))(Data_Map_Internal.toUnfoldable(Data_Unfoldable.unfoldableArray)(v.caches))));
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "backend";
      }))(Gargantext_Ends["$_WriteForeignBackend_24"])(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "caches";
      }))(Simple_JSON.writeForeignForeign)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "token";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "treeId";
      }))(Simple_JSON.writeForeignInt)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "username";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()()))({
          backend: v.backend,
          caches: caches$prime,
          token: v.token,
          treeId: v.treeId,
          username: v.username
      });
  });
  var $dollar_WriteForeignSessions_41 = new Simple_JSON.WriteForeign(function (v) {
      return Gargantext_Utils_JSON.writeSequence($dollar_WriteForeignSession_32)(v.sessions);
  });
  var $dollar_WriteForeignOpenNodes_46 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.writeForeignArray(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "baseUrl";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "treeId";
      }))(Simple_JSON.writeForeignInt)(Simple_JSON.nilWriteForeignFields)()()())()()())))(Data_Set.toUnfoldable(Data_Unfoldable.unfoldableArray)(v));
  });
  var $dollar_ToUrlSessionString_37 = new Gargantext_Ends.ToUrl(sessionUrl);
  var $dollar_ToUrlSessionSessionRoute_35 = new Gargantext_Ends.ToUrl(function (v) {
      return function (r) {
          return Gargantext_Ends.backendUrl(v.backend)(Gargantext_Ends.sessionPath(r));
      };
  });
  var $dollar_ToUrlSessionNodePath_36 = new Gargantext_Ends.ToUrl(function (v) {
      return function (np) {
          return Gargantext_Ends.backendUrl(v.backend)(Gargantext_Types.nodePath(np));
      };
  });
  var $dollar_ShowSession_34 = new Data_Show.Show(function (v) {
      return v.username + ("@" + Data_Show.show(Gargantext_Ends["$_ShowBackend_26"])(v.backend));
  });
  var sessionId = (function () {
      var $104 = Data_Show.show($dollar_ShowSession_34);
      return function ($105) {
          return Gargantext_Types.SessionId($104($105));
      };
  })();
  var lookup = function (sid) {
      return function (v) {
          var f = function (s) {
              return Data_Eq.eq(Gargantext_Types["$_EqSessionId_96"])(sid)(sessionId(s));
          };
          return Data_Sequence.head(Data_Sequence.filter(f)(v.sessions));
      };
  };
  var remove = function (sid) {
      return function (v) {
          var f = function (s) {
              return Data_Eq.notEq(Gargantext_Types["$_EqSessionId_96"])(sid)(sessionId(s));
          };
          return {
              sessions: Data_Sequence.filter(f)(v.sessions)
          };
      };
  };
  var tryCons = function (s) {
      return function (ss) {
          var $$try = function (v) {
              if (v instanceof Data_Maybe.Nothing) {
                  return new Data_Either.Right(cons(s)(ss));
              };
              return new Data_Either.Left(Data_Unit.unit);
          };
          var sid = sessionId(s);
          return $$try(lookup(sid)(ss));
      };
  };
  var update = function (s) {
      return function (ss) {
          var sid = sessionId(s);
          var up = function (v) {
              if (v instanceof Data_Maybe.Nothing) {
                  return cons(s)(ss);
              };
              return cons(s)(remove(sid)(ss));
          };
          return up(lookup(sid)(ss));
      };
  };
  var $dollar_ReadForeignSession_31 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "backend";
      }))(Gargantext_Ends["$_ReadForeignBackend_23"])(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "caches";
      }))(Simple_JSON.readObject(Gargantext_Components_Nodes_Lists_Types["$_ReadForeignCacheState_2"]))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "token";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "treeId";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "username";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()())()())()()))(f))(function (r) {
          var objTuple = Foreign_Object.toUnfoldable(Data_Unfoldable.unfoldableArray)(r.caches);
          var rUp = {
              caches: Data_Map_Internal.fromFoldable(Data_Ord.ordInt)(Data_Foldable.foldableArray)(Data_Functor.map(Data_Functor.functorArray)(Gargantext_Utils_Tuple.mapFst((function () {
                  var $106 = Data_Maybe.fromMaybe(0);
                  return function ($107) {
                      return $106(Data_Int.fromString($107));
                  };
              })()))(objTuple)),
              backend: r.backend,
              token: r.token,
              treeId: r.treeId,
              username: r.username
          };
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(rUp);
      });
  });
  var $dollar_ReadForeignSessions_40 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Gargantext_Utils_JSON.readSequence($dollar_ReadForeignSession_31)(f))(function (sessions) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))({
              sessions: sessions
          });
      });
  });
  var $dollar_ReadForeignOpenNodes_45 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readArray(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "baseUrl";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "treeId";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()())))(f))(function (v) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(OpenNodes(Data_Set.fromFoldable(Data_Foldable.foldableArray)(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
              return "treeId";
          }))(Data_Ord.ordInt))()(new Data_Symbol.IsSymbol(function () {
              return "baseUrl";
          }))(Data_Ord.ordString)))(v)));
      });
  });
  var $dollar_GenericSessions__38 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericSession__29 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqSession_33 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericSession__29)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "username";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "treeId";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "token";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "caches";
  }))(Data_Map_Internal.eqMap(Data_Eq.eqInt)(Gargantext_Components_Nodes_Lists_Types["$_EqCacheState_4"])))()(new Data_Symbol.IsSymbol(function () {
      return "backend";
  }))(Gargantext_Ends["$_EqBackend_25"]))))));
  var $dollar_EqSessions_42 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericSessions__38)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "sessions";
  }))(Data_Sequence.eqSeq($dollar_EqSession_33)))))));
  var tryRemove = function (sid) {
      return function (v) {
          var $$new = remove(sid)(v);
          var ret = (function () {
              if (Data_Eq.eq($dollar_EqSessions_42)($$new)(v)) {
                  return new Data_Either.Left(Data_Unit.unit);
              };
              if (Data_Boolean.otherwise) {
                  return new Data_Either.Right($$new);
              };
              throw new Error("Failed pattern match at Gargantext.Sessions.Types (line 138, column 3 - line 140, column 29): " + [  ]);
          })();
          return ret;
      };
  };
  exports["Session"] = Session;
  exports["OpenNodes"] = OpenNodes;
  exports["mkNodeId"] = mkNodeId;
  exports["sessionId"] = sessionId;
  exports["empty"] = empty;
  exports["null"] = $$null;
  exports["unSessions"] = unSessions;
  exports["lookup"] = lookup;
  exports["tryCons"] = tryCons;
  exports["update"] = update;
  exports["tryRemove"] = tryRemove;
  exports["useOpenNodesMemberBox"] = useOpenNodesMemberBox;
  exports["openNodesInsert"] = openNodesInsert;
  exports["openNodesDelete"] = openNodesDelete;
  exports["$_EqSession_33"] = $dollar_EqSession_33;
  exports["$_ShowSession_34"] = $dollar_ShowSession_34;
  exports["$_ToUrlSessionSessionRoute_35"] = $dollar_ToUrlSessionSessionRoute_35;
  exports["$_ToUrlSessionNodePath_36"] = $dollar_ToUrlSessionNodePath_36;
  exports["$_ToUrlSessionString_37"] = $dollar_ToUrlSessionString_37;
  exports["$_ReadForeignSessions_40"] = $dollar_ReadForeignSessions_40;
  exports["$_WriteForeignSessions_41"] = $dollar_WriteForeignSessions_41;
  exports["$_EqSessions_42"] = $dollar_EqSessions_42;
  exports["$_ReadForeignOpenNodes_45"] = $dollar_ReadForeignOpenNodes_45;
  exports["$_WriteForeignOpenNodes_46"] = $dollar_WriteForeignOpenNodes_46;
})(PS);
(function(exports) {
  'use strict';

  const reactTooltip = require('react-tooltip');

  if (typeof window !== 'undefined') {
      window.ReactTooltip = reactTooltip;
  }

  exports.reactTooltipCpt = reactTooltip;
})(PS["Gargantext.Utils.ReactTooltip"] = PS["Gargantext.Utils.ReactTooltip"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.ReactTooltip"] = $PS["Gargantext.Utils.ReactTooltip"] || {};
  var exports = $PS["Gargantext.Utils.ReactTooltip"];
  var $foreign = $PS["Gargantext.Utils.ReactTooltip"];
  var Reactix_React = $PS["Reactix.React"];                
  var reactTooltip = Reactix_React.rawCreateElement($foreign.reactTooltipCpt);
  exports["reactTooltip"] = reactTooltip;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Tools"] = $PS["Gargantext.Components.Forest.Tree.Node.Tools"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Set = $PS["Data.Set"];
  var Data_Show = $PS["Data.Show"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_InputWithEnter = $PS["Gargantext.Components.InputWithEnter"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Prelude = $PS["Gargantext.Prelude"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils = $PS["Gargantext.Utils"];
  var Gargantext_Utils_ReactTooltip = $PS["Gargantext.Utils.ReactTooltip"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var tooltipId = function (id) {
      return "node-link-" + Data_Show.show(Data_Show.showInt)(id);
  };
  var submitButtonHref = function (action) {
      return function (href) {
          var className = "btn btn-primary fa fa-" + Gargantext_Components_Forest_Tree_Node_Action.icon(action);
          return Reactix_DOM_HTML.a({
              className: className,
              href: href,
              target: "_blank"
          })([ Reactix_DOM_HTML.text(" " + Gargantext_Components_Forest_Tree_Node_Action.text(action)) ]);
      };
  };
  var submitButton = function (action) {
      return function (dispatch) {
          return Reactix_DOM_HTML.button({
              className: "btn btn-primary fa fa-" + Gargantext_Components_Forest_Tree_Node_Action.icon(action),
              type: "button",
              id: Data_String_Common.toLower(Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action["$_ShowAction_29"])(action)),
              title: Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action["$_ShowAction_29"])(action),
              on: {
                  click: function (v) {
                      return Effect_Aff.launchAff(dispatch(action));
                  }
              }
          })([ Reactix_DOM_HTML.text(" " + Gargantext_Components_Forest_Tree_Node_Action.text(action)) ]);
      };
  };
  var prettyNodeType = (function () {
      var $72 = Data_String_Common.replace("Node")(" ");
      var $73 = Data_String_Common.replace("Folder")(" ");
      var $74 = Data_Show.show(Gargantext_Types["$_ShowNodeType_117"]);
      return function ($75) {
          return $72($73($74($75)));
      };
  })();
  var panel = function (bodies) {
      return function (submit) {
          return Reactix_React.fragment([ Reactix_DOM_HTML.div({
              className: "card-body"
          })([ Reactix_DOM_HTML.div({
              className: "row"
          })([ Reactix_DOM_HTML.div({
              className: "col-12"
          })(bodies) ]) ]), Reactix_DOM_HTML.div({
              className: "card-footer"
          })([ Reactix_DOM_HTML.div({
              className: "row"
          })([ Reactix_DOM_HTML.div({
              className: "mx-auto"
          })([ submit ]) ]) ]) ]);
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Tools");
  var nodeTextCpt = (function () {
      var name_ = function (len) {
          return function (n) {
              var $32 = Data_String_CodePoints.length(n) < len;
              if ($32) {
                  return n;
              };
              var v = Data_String_CodeUnits.slice(0)(len)(n);
              if (v instanceof Data_Maybe.Nothing) {
                  return "???";
              };
              if (v instanceof Data_Maybe.Just) {
                  return v.value0 + "...";
              };
              throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Tools (line 323, column 10 - line 325, column 28): " + [ v.constructor.name ]);
          };
      };
      var name15 = name_(15);
      var cpt = function (v) {
          return function (v1) {
              var r = Reactix_DOM_HTML.text(name15(v.name));
              var l = Reactix_DOM_HTML.text("...");
              return Control_Applicative.pure(Reactix_React.applicativeHooks)((function () {
                  if (v.isSelected) {
                      return Reactix_DOM_HTML.u({
                          className: "node-text"
                      })([ Reactix_DOM_HTML.b({})([ Reactix_DOM_HTML.text("| " + (name15(v.name) + " |    ")) ]) ]);
                  };
                  return Gargantext_Types.flipHanded(l)(r)(v.handed);
              })());
          };
      };
      return here.component("nodeText")(cpt);
  })();
  var nodeText = Reactix_React.createElement(Reactix_React.componentIsComponent)(nodeTextCpt);
  var nodeLinkCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var href = Gargantext_Ends.url(Gargantext_Ends["$_ToUrlFrontendsNodePath_36"])(v.frontends)(new Gargantext_Types.NodePath(Gargantext_Sessions_Types.sessionId(v.session), v.nodeType, new Data_Maybe.Just(v.id)));
              var click = function (v2) {
                  return Control_Applicative.when(Effect.applicativeEffect)(!v.isSelected)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(true)(v.folderOpen));
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (popoverRef) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "node-link",
                      on: {
                          click: click
                      }
                  })([ Reactix_DOM_HTML.a({
                      href: href,
                      data: {
                          "for": tooltipId(v.id),
                          tip: true
                      }
                  })([ nodeText({
                      handed: v.handed,
                      isSelected: v.isSelected,
                      name: v.name
                  })([  ]), Gargantext_Utils_ReactTooltip.reactTooltip({
                      effect: "float",
                      id: tooltipId(v.id),
                      type: "dark"
                  })([ Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.h4({
                      className: Gargantext_Types.fldr(v.nodeType)(true)
                  })([ Reactix_DOM_HTML.text(Gargantext_Types.prettyNodeType(v.nodeType)) ]) ]), Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.span({})([ Reactix_DOM_HTML.text(v.name) ]) ]) ]) ]) ]));
              });
          };
      };
      return here.component("nodeLink")(cpt);
  })();
  var nodeLink = Reactix_React.createElement(Reactix_React.componentIsComponent)(nodeLinkCpt);
  var textInputBoxCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var submit = function (ref) {
                  return function (v2) {
                      return function __do() {
                          Effect_Aff.launchAff_(v.dispatch(v.boxAction(Reactix_React.readRef(ref))))();
                          return Toestand_Classes.write_(Toestand_Boxes.writeBox)(false)(v.isOpen)();
                      };
                  };
              };
              var submitBtn = function (renameNodeNameRef) {
                  return Reactix_DOM_HTML.a({
                      type: "button",
                      title: "Submit",
                      on: {
                          click: submit(renameNodeNameRef)
                      },
                      className: "col-2 " + Gargantext_Utils.glyphicon("floppy-o")
                  })([  ]);
              };
              var textInput = function (renameNodeNameRef) {
                  return Reactix_DOM_HTML.div({
                      className: "col-8"
                  })([ Gargantext_Components_InputWithEnter.inputWithEnter({
                      autoFocus: true,
                      className: "form-control",
                      defaultValue: v.text,
                      onBlur: Reactix_React.setRef(renameNodeNameRef),
                      onEnter: submit(renameNodeNameRef),
                      onValueChanged: Reactix_React.setRef(renameNodeNameRef),
                      placeholder: v.boxName + " Node",
                      type: "text"
                  }) ]);
              };
              var click = function (v2) {
                  return Toestand_Classes.write_(Toestand_Boxes.writeBox)(false)(v.isOpen);
              };
              var cancelBtn = Reactix_DOM_HTML.a({
                  type: "button",
                  title: "Cancel",
                  on: {
                      click: click
                  },
                  className: "text-danger col-2 " + Gargantext_Utils.glyphicon("times")
              })([  ]);
              var content = function (v2) {
                  return function (v3) {
                      if (!v2) {
                          return Reactix_React.fragment([  ]);
                      };
                      if (v2) {
                          return Reactix_DOM_HTML.div({
                              className: "from-group row"
                          })([ textInput(v3), submitBtn(v3), cancelBtn ]);
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Tools (line 69, column 7 - line 69, column 40): " + [ v2.constructor.name, v3.constructor.name ]);
                  };
              };
              return Control_Apply.apply(Reactix_React.applyHooks)(Data_Functor.map(Reactix_React.functorHooks)(content)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.isOpen)))(Reactix_Hooks.useRef(v.text));
          };
      };
      return here.component("textInputBox")(cpt);
  })();
  var textInputBox = Reactix_React.createElement(Reactix_React.componentIsComponent)(textInputBoxCpt);
  var fragmentPT = function (text) {
      return Reactix_DOM_HTML.div({
          style: {
              margin: "10px"
          }
      })([ Reactix_DOM_HTML.text(text) ]);
  };
  var formChoice = function (dictRead) {
      return function (dictShow) {
          return function (nodeTypes) {
              return function (defaultNodeType) {
                  return function (setNodeType) {
                      return Reactix_DOM_HTML.div({
                          className: "form-group"
                      })([ Gargantext_Utils_Reactix.select({
                          className: "form-control",
                          on: {
                              change: function (e) {
                                  return setNodeType(Data_Maybe.fromMaybe(defaultNodeType)(Gargantext_Prelude.read(dictRead)(Reactix_SyntheticEvent.unsafeEventValue(e))));
                              }
                          }
                      })(Data_Functor.map(Data_Functor.functorArray)(function (opt) {
                          return Reactix_DOM_HTML.option({})([ Reactix_DOM_HTML.text(Data_Show.show(dictShow)(opt)) ]);
                      })(nodeTypes)) ]);
                  };
              };
          };
      };
  };
  var formButton = function (dictShow) {
      return function (nodeType) {
          return function (setNodeType) {
              var bouton = Reactix_DOM_HTML.button({
                  className: "cold-md-5 btn btn-primary center",
                  type: "button",
                  title: "Form Button",
                  style: {
                      width: "100%"
                  },
                  on: {
                      click: function (v) {
                          return setNodeType(nodeType);
                      }
                  }
              })([ Reactix_DOM_HTML.text("Confirmation") ]);
              return Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.text("Confirm the selection of: " + Data_Show.show(dictShow)(nodeType)), bouton ]);
          };
      };
  };
  var formChoiceSafe = function (dictRead) {
      return function (dictShow) {
          return function (v) {
              return function (v1) {
                  return function (v2) {
                      if (v.length === 0) {
                          return Reactix_DOM_HTML.div({})([  ]);
                      };
                      if (v.length === 1) {
                          return formButton(dictShow)(v[0])(v2);
                      };
                      return formChoice(dictRead)(dictShow)(v)(v1)(v2);
                  };
              };
          };
      };
  };
  var checkboxesListGroupCpt = function (dictOrd) {
      return function (dictShow) {
          var cpt = function (v) {
              return function (v1) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Set.eqSet(dictOrd.Eq0())))(v.options))(function (options$prime) {
                      var one = function (a) {
                          return Reactix_DOM_HTML.li({
                              className: "list-group-item"
                          })([ Reactix_DOM_HTML.div({
                              className: "form-check"
                          })([ Reactix_DOM_HTML.input({
                              defaultChecked: Data_Set.member(dictOrd)(a)(options$prime),
                              on: {
                                  click: function (v2) {
                                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Utils.toggleSet(dictOrd)(a)(options$prime))(v.options);
                                  },
                                  type: "checkbox"
                              },
                              className: "form-check-input"
                          }), Reactix_DOM_HTML.label({
                              className: "form-check-label"
                          })([ Reactix_DOM_HTML.text(Data_Show.show(dictShow)(a)) ]) ]) ]);
                      };
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment(Data_Functor.map(Data_Functor.functorArray)(one)(Data_Set.toUnfoldable(Data_Unfoldable.unfoldableArray)(options$prime))));
                  });
              };
          };
          return here.component("checkboxesListGroup")(cpt);
      };
  };
  var checkboxesListGroup = function (dictOrd) {
      return function (dictShow) {
          return Reactix_React.createElement(Reactix_React.componentIsComponent)(checkboxesListGroupCpt(dictOrd)(dictShow));
      };
  };
  var checkboxCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var click = function (v2) {
                  return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(v.value);
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.value))(function (value$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.input({
                      className: "form-check-input",
                      on: {
                          click: click
                      },
                      type: "checkbox",
                      value: value$prime
                  }));
              });
          };
      };
      return here.component("checkbox")(cpt);
  })();
  var checkbox = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(checkboxCpt)(props)([  ]);
  };
  exports["fragmentPT"] = fragmentPT;
  exports["panel"] = panel;
  exports["textInputBox"] = textInputBox;
  exports["formChoiceSafe"] = formChoiceSafe;
  exports["submitButton"] = submitButton;
  exports["submitButtonHref"] = submitButtonHref;
  exports["checkbox"] = checkbox;
  exports["checkboxesListGroup"] = checkboxesListGroup;
  exports["nodeLink"] = nodeLink;
  exports["nodeText"] = nodeText;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Login.Types"] = $PS["Gargantext.Components.Login.Types"] || {};
  var exports = $PS["Gargantext.Components.Login.Types"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Simple_JSON = $PS["Simple.JSON"];
  var $dollar_WriteForeignAuthRequest_12 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "password";
  }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "username";
  }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()());
  var $dollar_ReadForeignAuthInvalid_19 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "message";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()());
  var $dollar_ReadForeignAuthData_23 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "token";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "tree_id";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()());
  var $dollar_ReadForeignAuthResponse_15 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "inval";
  }))(Simple_JSON.readMaybe($dollar_ReadForeignAuthInvalid_19))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "valid";
  }))(Simple_JSON.readMaybe($dollar_ReadForeignAuthData_23))(Simple_JSON.readFieldsNil)()())()());
  exports["$_WriteForeignAuthRequest_12"] = $dollar_WriteForeignAuthRequest_12;
  exports["$_ReadForeignAuthResponse_15"] = $dollar_ReadForeignAuthResponse_15;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Config.REST"] = $PS["Gargantext.Config.REST"] || {};
  var exports = $PS["Gargantext.Config.REST"];
  var Affjax = $PS["Affjax"];
  var Affjax_RequestBody = $PS["Affjax.RequestBody"];
  var Affjax_RequestHeader = $PS["Affjax.RequestHeader"];
  var Affjax_ResponseFormat = $PS["Affjax.ResponseFormat"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var Data_Argonaut_Core = $PS["Data.Argonaut.Core"];
  var Data_Either = $PS["Data.Either"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_FormURLEncoded = $PS["Data.FormURLEncoded"];
  var Data_HTTP_Method = $PS["Data.HTTP.Method"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_MediaType_Common = $PS["Data.MediaType.Common"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Foreign = $PS["Foreign"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Simple_JSON = $PS["Simple.JSON"];                          
  var readJSONOrFail = function (dictBind) {
      return function (dictMonadEffect) {
          return function (dictMonadThrow) {
              return function (dictReadForeign) {
                  return function (affResp) {
                      if (affResp instanceof Data_Either.Left) {
                          return Control_Bind.bind(dictBind)(Effect_Class.liftEffect(dictMonadEffect)(DOM_Simple_Console.log(Affjax.printError(affResp.value0))))(function () {
                              return Control_Monad_Error_Class.throwError(dictMonadThrow)(Effect_Exception.error(Affjax.printError(affResp.value0)));
                          });
                      };
                      if (affResp instanceof Data_Either.Right) {
                          var v = Simple_JSON.readJSON(dictReadForeign)(Data_Argonaut_Core.stringify(affResp.value0.body));
                          if (v instanceof Data_Either.Left) {
                              return Control_Monad_Error_Class.throwError(dictMonadThrow)(Effect_Exception.error("decodeJson affResp.body: " + Data_Show.show(Data_List_Types.showNonEmptyList(Foreign.showForeignError))(v.value0)));
                          };
                          if (v instanceof Data_Either.Right) {
                              return Control_Applicative.pure((dictMonadEffect.Monad0()).Applicative0())(v.value0);
                          };
                          throw new Error("Failed pattern match at Gargantext.Config.REST (line 39, column 7 - line 41, column 26): " + [ v.constructor.name ]);
                      };
                      throw new Error("Failed pattern match at Gargantext.Config.REST (line 31, column 3 - line 41, column 26): " + [ affResp.constructor.name ]);
                  };
              };
          };
      };
  };
  var send = function (dictWriteForeign) {
      return function (dictReadForeign) {
          return function (m) {
              return function (mtoken) {
                  return function (url) {
                      return function (reqbody) {
                          var req = {
                              url: url,
                              responseFormat: Affjax_ResponseFormat.json,
                              method: new Data_Either.Left(m),
                              headers: Data_Semigroup.append(Data_Semigroup.semigroupArray)([ new Affjax_RequestHeader.ContentType(Data_MediaType_Common.applicationJSON), new Affjax_RequestHeader.Accept(Data_MediaType_Common.applicationJSON) ])(Data_Foldable.foldMap(Data_Foldable.foldableMaybe)(Data_Monoid.monoidArray)(function (token) {
                                  return [ Affjax_RequestHeader.RequestHeader.create("Authorization")("Bearer " + token) ];
                              })(mtoken)),
                              content: Data_Maybe.Just.create(Affjax_RequestBody.string(Simple_JSON.writeJSON(Simple_JSON.writeForeignMaybe(dictWriteForeign))(reqbody))),
                              password: Affjax.defaultRequest.password,
                              timeout: Affjax.defaultRequest.timeout,
                              username: Affjax.defaultRequest.username,
                              withCredentials: Affjax.defaultRequest.withCredentials
                          };
                          return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)((function () {
                              if (mtoken instanceof Data_Maybe.Nothing) {
                                  return Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Unit.unit);
                              };
                              if (mtoken instanceof Data_Maybe.Just) {
                                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)((function () {
                                      var cookie = "JWT-Cookie=" + (mtoken.value0 + "; Path=/;");
                                      return Gargantext_Utils_Reactix.setCookie(cookie);
                                  })());
                              };
                              throw new Error("Failed pattern match at Gargantext.Config.REST (line 59, column 3 - line 63, column 26): " + [ mtoken.constructor.name ]);
                          })())(function () {
                              return Control_Bind.bind(Effect_Aff.bindAff)(Affjax.request(req))(function (affResp) {
                                  return readJSONOrFail(Effect_Aff.bindAff)(Effect_Aff.monadEffectAff)(Effect_Aff.monadThrowAff)(dictReadForeign)(affResp);
                              });
                          });
                      };
                  };
              };
          };
      };
  };
  var put = function (dictWriteForeign) {
      return function (dictReadForeign) {
          return function (mtoken) {
              return function (url) {
                  var $29 = send(dictWriteForeign)(dictReadForeign)(Data_HTTP_Method.PUT.value)(mtoken)(url);
                  return function ($30) {
                      return $29(Data_Maybe.Just.create($30));
                  };
              };
          };
      };
  };
  var postWwwUrlencoded = function (dictReadForeign) {
      return function (mtoken) {
          return function (url) {
              return function (bodyParams) {
                  var urlEncodedBody = Data_FormURLEncoded.fromArray(bodyParams);
                  return Control_Bind.bind(Effect_Aff.bindAff)(Affjax.request({
                      method: new Data_Either.Left(Data_HTTP_Method.POST.value),
                      url: url,
                      headers: Data_Semigroup.append(Data_Semigroup.semigroupArray)([ new Affjax_RequestHeader.ContentType(Data_MediaType_Common.applicationFormURLEncoded), new Affjax_RequestHeader.Accept(Data_MediaType_Common.applicationJSON) ])(Data_Foldable.foldMap(Data_Foldable.foldableMaybe)(Data_Monoid.monoidArray)(function (token) {
                          return [ Affjax_RequestHeader.RequestHeader.create("Authorization")("Bearer " + token) ];
                      })(mtoken)),
                      content: Data_Maybe.Just.create(Affjax_RequestBody.formURLEncoded(urlEncodedBody)),
                      username: Affjax.defaultRequest.username,
                      password: Affjax.defaultRequest.password,
                      withCredentials: Affjax.defaultRequest.withCredentials,
                      responseFormat: Affjax_ResponseFormat.json,
                      timeout: Affjax.defaultRequest.timeout
                  }))(function (affResp) {
                      return readJSONOrFail(Effect_Aff.bindAff)(Effect_Aff.monadEffectAff)(Effect_Aff.monadThrowAff)(dictReadForeign)(affResp);
                  });
              };
          };
      };
  };
  var post = function (dictWriteForeign) {
      return function (dictReadForeign) {
          return function (mtoken) {
              return function (url) {
                  var $31 = send(dictWriteForeign)(dictReadForeign)(Data_HTTP_Method.POST.value)(mtoken)(url);
                  return function ($32) {
                      return $31(Data_Maybe.Just.create($32));
                  };
              };
          };
      };
  };
  var noReqBody = new Data_Maybe.Just("");
  var put_ = function (dictReadForeign) {
      return function (mtoken) {
          return function (url) {
              return send(Simple_JSON.writeForeignString)(dictReadForeign)(Data_HTTP_Method.PUT.value)(mtoken)(url)(noReqBody);
          };
      };
  };
  var get = function (dictReadForeign) {
      return function (mtoken) {
          return function (url) {
              return send(Simple_JSON.writeForeignString)(dictReadForeign)(Data_HTTP_Method.GET.value)(mtoken)(url)(noReqBody);
          };
      };
  };
  var $$delete = function (dictReadForeign) {
      return function (mtoken) {
          return function (url) {
              return send(Simple_JSON.writeForeignString)(dictReadForeign)(Data_HTTP_Method.DELETE.value)(mtoken)(url)(noReqBody);
          };
      };
  };
  exports["get"] = get;
  exports["put"] = put;
  exports["put_"] = put_;
  exports["delete"] = $$delete;
  exports["post"] = post;
  exports["postWwwUrlencoded"] = postWwwUrlencoded;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Sessions"] = $PS["Gargantext.Sessions"] || {};
  var exports = $PS["Gargantext.Sessions"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Either = $PS["Data.Either"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_Login_Types = $PS["Gargantext.Components.Login.Types"];
  var Gargantext_Config_REST = $PS["Gargantext.Config.REST"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var Web_Storage_Storage = $PS["Web.Storage.Storage"];                
  var Login = (function () {
      function Login(value0) {
          this.value0 = value0;
      };
      Login.create = function (value0) {
          return new Login(value0);
      };
      return Login;
  })();
  var Logout = (function () {
      function Logout(value0) {
          this.value0 = value0;
      };
      Logout.create = function (value0) {
          return new Logout(value0);
      };
      return Logout;
  })();
  var Update = (function () {
      function Update(value0) {
          this.value0 = value0;
      };
      Update.create = function (value0) {
          return new Update(value0);
      };
      return Update;
  })();
  var setCacheState = function (v) {
      return function (nodeId) {
          return function (cacheState) {
              return Gargantext_Sessions_Types.Session({
                  backend: v.backend,
                  caches: Data_Map_Internal.insert(Data_Ord.ordInt)(nodeId)(cacheState)(v.caches),
                  token: v.token,
                  treeId: v.treeId,
                  username: v.username
              });
          };
      };
  };
  var put_ = function (dictReadForeign) {
      return function (dictToUrl) {
          return function (v) {
              return function (p) {
                  return Gargantext_Config_REST.put_(dictReadForeign)(new Data_Maybe.Just(v.token))(Gargantext_Ends.toUrl(dictToUrl)(v)(p));
              };
          };
      };
  };
  var put = function (dictWriteForeign) {
      return function (dictReadForeign) {
          return function (dictToUrl) {
              return function (v) {
                  return function (p) {
                      return Gargantext_Config_REST.put(dictWriteForeign)(dictReadForeign)(new Data_Maybe.Just(v.token))(Gargantext_Ends.toUrl(dictToUrl)(v)(p));
                  };
              };
          };
      };
  };
  var postWwwUrlencoded = function (dictReadForeign) {
      return function (dictToUrl) {
          return function (v) {
              return function (p) {
                  return Gargantext_Config_REST.postWwwUrlencoded(dictReadForeign)(new Data_Maybe.Just(v.token))(Gargantext_Ends.toUrl(dictToUrl)(v)(p));
              };
          };
      };
  };
  var postAuthRequest = function (backend) {
      return function (v) {
          var decode = function (v1) {
              var v2 = function (v3) {
                  var v4 = function (v5) {
                      if (Data_Boolean.otherwise) {
                          return new Data_Either.Left("Invalid response from server");
                      };
                      throw new Error("Failed pattern match at Gargantext.Sessions (line 126, column 1 - line 126, column 73): " + [ v1.constructor.name ]);
                  };
                  if (v1.valid instanceof Data_Maybe.Just) {
                      return Data_Either.Right.create({
                          backend: backend,
                          caches: Data_Map_Internal.empty,
                          token: v1.valid.value0.token,
                          treeId: v1.valid.value0.tree_id,
                          username: v.username
                      });
                  };
                  return v4(true);
              };
              if (v1.inval instanceof Data_Maybe.Just) {
                  return new Data_Either.Left(v1.inval.value0.message);
              };
              return v2(true);
          };
          return Data_Functor.map(Effect_Aff.functorAff)(decode)(Gargantext_Config_REST.post(Gargantext_Components_Login_Types["$_WriteForeignAuthRequest_12"])(Gargantext_Components_Login_Types["$_ReadForeignAuthResponse_15"])(Data_Maybe.Nothing.value)(Gargantext_Ends.toUrl(Gargantext_Ends["$_ToUrlBackendString_27"])(backend)("auth"))(v));
      };
  };
  var post = function (dictWriteForeign) {
      return function (dictReadForeign) {
          return function (dictToUrl) {
              return function (v) {
                  return function (p) {
                      return Gargantext_Config_REST.post(dictWriteForeign)(dictReadForeign)(new Data_Maybe.Just(v.token))(Gargantext_Ends.toUrl(dictToUrl)(v)(p));
                  };
              };
          };
      };
  };
  var localStorageKey = "garg-sessions";
  var saveSessions = function (sessions) {
      var set = function (v) {
          return Control_Bind.bind(Effect.bindEffect)(Gargantext_Utils_Reactix.getls)(Web_Storage_Storage.setItem(localStorageKey)(v));
      };
      var rem = Control_Bind.bind(Effect.bindEffect)(Gargantext_Utils_Reactix.getls)(Web_Storage_Storage.removeItem(localStorageKey));
      var effect = (function () {
          if (Gargantext_Sessions_Types["null"](sessions)) {
              return rem;
          };
          if (Data_Boolean.otherwise) {
              return set(Simple_JSON.writeJSON(Gargantext_Sessions_Types["$_WriteForeignSessions_41"])(sessions));
          };
          throw new Error("Failed pattern match at Gargantext.Sessions (line 116, column 3 - line 118, column 48): " + [  ]);
      })();
      return Control_Apply.applySecond(Effect.applyEffect)(effect)(Control_Applicative.pure(Effect.applicativeEffect)(sessions));
  };
  var loadSessions = function __do() {
      var storage = Gargantext_Utils_Reactix.getls();
      var v = Web_Storage_Storage.getItem(localStorageKey)(storage)();
      if (v instanceof Data_Maybe.Nothing) {
          return Gargantext_Sessions_Types.empty;
      };
      if (v instanceof Data_Maybe.Just) {
          var r = Simple_JSON.readJSON(Gargantext_Sessions_Types["$_ReadForeignSessions_40"])(v.value0);
          var v1 = Data_Either.hush(r);
          if (v1 instanceof Data_Maybe.Nothing) {
              return Gargantext_Sessions_Types.empty;
          };
          if (v1 instanceof Data_Maybe.Just) {
              return v1.value0;
          };
          throw new Error("Failed pattern match at Gargantext.Sessions (line 95, column 7 - line 97, column 25): " + [ v1.constructor.name ]);
      };
      throw new Error("Failed pattern match at Gargantext.Sessions (line 91, column 3 - line 97, column 25): " + [ v.constructor.name ]);
  };
  var load = function (dictWrite) {
      return function (cell) {
          return function __do() {
              var sessions = loadSessions();
              return Toestand_Classes.write(dictWrite)(sessions)(cell)();
          };
      };
  };
  var getCacheState = function (defaultCacheState) {
      return function (v) {
          return function (nodeId) {
              return Data_Maybe.fromMaybe(defaultCacheState)(Data_Map_Internal.lookup(Data_Ord.ordInt)(nodeId)(v.caches));
          };
      };
  };
  var get = function (dictReadForeign) {
      return function (dictToUrl) {
          return function (v) {
              return function (p) {
                  return Gargantext_Config_REST.get(dictReadForeign)(new Data_Maybe.Just(v.token))(Gargantext_Ends.toUrl(dictToUrl)(v)(p));
              };
          };
      };
  };
  var $$delete = function (dictReadForeign) {
      return function (dictToUrl) {
          return function (v) {
              return function (p) {
                  return Gargantext_Config_REST["delete"](dictReadForeign)(new Data_Maybe.Just(v.token))(Gargantext_Ends.toUrl(dictToUrl)(v)(p));
              };
          };
      };
  };
  var act = function (v) {
      return function (v1) {
          if (v1 instanceof Login) {
              var v2 = Gargantext_Sessions_Types.tryCons(v1.value0)(v);
              if (v2 instanceof Data_Either.Right) {
                  return Control_Applicative.pure(Effect.applicativeEffect)(v2.value0);
              };
              return Control_Apply.applyFirst(Effect.applyEffect)(Control_Applicative.pure(Effect.applicativeEffect)(v))(DOM_Simple_Console.log2("Cannot overwrite existing session: ")(Gargantext_Sessions_Types.sessionId(v1.value0)));
          };
          if (v1 instanceof Logout) {
              var v2 = Gargantext_Sessions_Types.tryRemove(Gargantext_Sessions_Types.sessionId(v1.value0))(v);
              if (v2 instanceof Data_Either.Right) {
                  return Control_Applicative.pure(Effect.applicativeEffect)(v2.value0);
              };
              return Control_Apply.applyFirst(Effect.applyEffect)(Control_Applicative.pure(Effect.applicativeEffect)(v))(DOM_Simple_Console.log2("Logged out of stale session:")(Gargantext_Sessions_Types.sessionId(v1.value0)));
          };
          if (v1 instanceof Update) {
              return saveSessions(Gargantext_Sessions_Types.update(v1.value0)(v));
          };
          throw new Error("Failed pattern match at Gargantext.Sessions (line 62, column 1 - line 62, column 45): " + [ v.constructor.name, v1.constructor.name ]);
      };
  };
  var change = function (dictRead) {
      return function (dictWrite) {
          return function (action) {
              return function (cell) {
                  return function __do() {
                      var cur = Toestand_Classes.read(dictRead)(Reactix_React.monadDelayEffect)(cell)();
                      var $$new = act(cur)(action)();
                      return Control_Apply.applySecond(Effect.applyEffect)(saveSessions($$new))(Toestand_Classes.write(dictWrite)($$new)(cell))();
                  };
              };
          };
      };
  };
  exports["load"] = load;
  exports["change"] = change;
  exports["Login"] = Login;
  exports["Logout"] = Logout;
  exports["delete"] = $$delete;
  exports["get"] = get;
  exports["post"] = post;
  exports["put"] = put;
  exports["put_"] = put_;
  exports["postAuthRequest"] = postAuthRequest;
  exports["postWwwUrlencoded"] = postWwwUrlencoded;
  exports["getCacheState"] = getCacheState;
  exports["setCacheState"] = setCacheState;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Add"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Add"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Add"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Settings = $PS["Gargantext.Components.Forest.Tree.Node.Settings"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Components_InputWithEnter = $PS["Gargantext.Components.InputWithEnter"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var NodePopup = (function () {
      function NodePopup() {

      };
      NodePopup.value = new NodePopup();
      return NodePopup;
  })();
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Add");
  var addNodeViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox("Name"))(function (nodeName) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqString))(nodeName))(function (nodeName$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Maybe.fromMaybe(Gargantext_Types.Folder.value)(Data_Array.head(v.nodeTypes))))(function (nodeType) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqNodeType_114"]))(nodeType))(function (nodeType$prime) {
                              var v2 = Gargantext_Components_Forest_Tree_Node_Settings.settingsBox(nodeType$prime);
                              var setNodeType$prime = function (nt) {
                                  return function __do() {
                                      Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Types.prettyNodeType(nt))(nodeName)();
                                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(nt)(nodeType)();
                                  };
                              };
                              var v3 = (function () {
                                  var defaultNt = Data_Maybe.fromMaybe(Gargantext_Types["Error"].value)(Data_Array.head(v.nodeTypes));
                                  var $16 = Data_Array.length(v.nodeTypes) > 1;
                                  if ($16) {
                                      return new Data_Tuple.Tuple([ Gargantext_Components_Forest_Tree_Node_Tools.formChoiceSafe(Gargantext_Types["$_ReadNodeType_118"])(Gargantext_Types["$_ShowNodeType_117"])(v.nodeTypes)(Gargantext_Types["Error"].value)(setNodeType$prime) ], nodeType$prime);
                                  };
                                  return new Data_Tuple.Tuple([ Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.text("Creating a node of type " + (Data_Show.show(Gargantext_Types["$_ShowNodeType_117"])(defaultNt) + " with name:")) ]) ], defaultNt);
                              })();
                              var maybeEdit = [ (function () {
                                  if (v2.value0.edit) {
                                      return Gargantext_Components_InputWithEnter.inputWithEnter({
                                          onBlur: function (val) {
                                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(val)(nodeName);
                                          },
                                          onEnter: function (v4) {
                                              return Effect_Aff.launchAff_(v.dispatch(new Gargantext_Components_Forest_Tree_Node_Action.AddNode(nodeName$prime, v3.value1)));
                                          },
                                          onValueChanged: function (val) {
                                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(val)(nodeName);
                                          },
                                          autoFocus: true,
                                          className: "form-control",
                                          defaultValue: nodeName$prime,
                                          placeholder: nodeName$prime,
                                          type: "text"
                                      });
                                  };
                                  return Reactix_DOM_HTML.div({})([  ]);
                              })() ];
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel(Data_Semigroup.append(Data_Semigroup.semigroupArray)(v3.value0)(maybeEdit))(Gargantext_Components_Forest_Tree_Node_Tools.submitButton(new Gargantext_Components_Forest_Tree_Node_Action.AddNode(nodeName$prime, v3.value1))(v.dispatch)));
                          });
                      });
                  });
              });
          };
      };
      return here.component("addNodeView")(cpt);
  })();
  var addNodeView = Reactix_React.createElement(Reactix_React.componentIsComponent)(addNodeViewCpt);
  var $dollar_WriteForeignAddNodeValue_9 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "pn_name";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "pn_typename";
      }))(Gargantext_Types["$_WriteForeignNodeType_116"])(Simple_JSON.nilWriteForeignFields)()()())()()()))({
          pn_name: v.name,
          pn_typename: v.nodeType
      });
  });
  var addNode = function (session) {
      return function (parentId) {
          return Gargantext_Sessions.post($dollar_WriteForeignAddNodeValue_9)(Simple_JSON.readArray(Simple_JSON.readInt))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(parentId), ""));
      };
  };
  exports["addNode"] = addNode;
  exports["NodePopup"] = NodePopup;
  exports["addNodeView"] = addNodeView;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Typisch.Row"] = $PS["Typisch.Row"] || {};
  var exports = $PS["Typisch.Row"];
  var Lacks = function (IsSymbol0, Lacks1) {
      this.IsSymbol0 = IsSymbol0;
      this.Lacks1 = Lacks1;
  };
  var Cons = function (Cons1, Lacks0) {
      this.Cons1 = Cons1;
      this.Lacks0 = Lacks0;
  };
  var Cons2 = function (Cons1, Cons2, Lacks0) {
      this.Cons1 = Cons1;
      this.Cons2 = Cons2;
      this.Lacks0 = Lacks0;
  };
  var Cons3 = function (Cons2, Cons3, Cons4, Lacks0, Lacks1) {
      this.Cons2 = Cons2;
      this.Cons3 = Cons3;
      this.Cons4 = Cons4;
      this.Lacks0 = Lacks0;
      this.Lacks1 = Lacks1;
  };
  var lacks = function (dictIsSymbol) {
      return function (dictLacks) {
          return new Lacks(function () {
              return dictIsSymbol;
          }, function () {
              return undefined;
          });
      };
  };
  var cons3 = function (dictLacks) {
      return function (dictLacks1) {
          return function (dictCons) {
              return function (dictCons1) {
                  return function (dictCons2) {
                      return new Cons3(function () {
                          return dictCons;
                      }, function () {
                          return dictCons1;
                      }, function () {
                          return dictCons2;
                      }, function () {
                          return dictLacks;
                      }, function () {
                          return dictLacks1;
                      });
                  };
              };
          };
      };
  };
  var cons2 = function (dictLacks) {
      return function (dictCons) {
          return function (dictCons1) {
              return new Cons2(function () {
                  return dictCons;
              }, function () {
                  return dictCons1;
              }, function () {
                  return dictLacks;
              });
          };
      };
  };
  var cons = function (dictLacks) {
      return function (dictCons) {
          return new Cons(function () {
              return undefined;
          }, function () {
              return dictLacks;
          });
      };
  };
  exports["lacks"] = lacks;
  exports["cons"] = cons;
  exports["cons2"] = cons2;
  exports["cons3"] = cons3;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Contact"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Contact"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Contact"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Formula = $PS["Formula"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Action_Contact_Types = $PS["Gargantext.Components.Forest.Tree.Node.Action.Contact.Types"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var Typisch_Row = $PS["Typisch.Row"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Contact");
  var textInputBoxCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var content = function (v2) {
                  return function (v3) {
                      return function (v4) {
                          if (!v2) {
                              return Reactix_DOM_HTML.div({})([  ]);
                          };
                          if (v2) {
                              var textInput = function (value) {
                                  return Reactix_DOM_HTML.div({
                                      className: "col-md-8"
                                  })([ Formula.bindInput(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons2(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                                      return "on";
                                  }))())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                                      return "defaultValue";
                                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                                      return "on";
                                  }))())()))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                                      return "value";
                                  }))())())({
                                      value: value,
                                      className: "form-control",
                                      type: "text",
                                      placeholder: v.boxName + " Node"
                                  }) ]);
                              };
                              var submitBtn = function (first) {
                                  return function (last) {
                                      var click = function (v5) {
                                          return function __do() {
                                              var f = Toestand_Classes.read(Toestand_Boxes.readBox)(Reactix_React.monadDelayEffect)(first)();
                                              var l = Toestand_Classes.read(Toestand_Boxes.readBox)(Reactix_React.monadDelayEffect)(last)();
                                              Toestand_Classes.write_(Toestand_Boxes.writeBox)(false)(v.isOpen)();
                                              return Effect_Aff.launchAff(v.dispatch(v.boxAction({
                                                  firstname: f,
                                                  lastname: l
                                              })))();
                                          };
                                      };
                                      return Reactix_DOM_HTML.a({
                                          className: "btn glyphitem fa fa-ok col-md-2 pull-left",
                                          type: "button",
                                          on: {
                                              click: click
                                          },
                                          title: "Submit"
                                      })([  ]);
                                  };
                              };
                              var cancelBtn = (function () {
                                  var click = function (v5) {
                                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(false)(v.isOpen);
                                  };
                                  return Reactix_DOM_HTML.a({
                                      className: "btn text-danger glyphitem fa fa-remove col-md-2 pull-left",
                                      on: {
                                          click: click
                                      },
                                      title: "Cancel",
                                      type: "button"
                                  })([  ]);
                              })();
                              return Reactix_DOM_HTML.div({
                                  className: "from-group row"
                              })([ textInput(v3), textInput(v4), submitBtn(v3)(v4), cancelBtn ]);
                          };
                          throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Contact (line 64, column 7 - line 64, column 38): " + [ v2.constructor.name, v3.constructor.name, v4.constructor.name ]);
                      };
                  };
              };
              return Control_Apply.apply(Reactix_React.applyHooks)(Control_Apply.apply(Reactix_React.applyHooks)(Data_Functor.map(Reactix_React.functorHooks)(content)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.isOpen)))(Toestand_Boxes.useBox(v.params.firstname)))(Toestand_Boxes.useBox(v.params.lastname));
          };
      };
      return here.component("textInputBox")(cpt);
  })();
  var textInputBox = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(textInputBoxCpt)(props)([  ]);
  };
  var contactReq = function (session) {
      return function (nodeId) {
          return Gargantext_Sessions.post(Gargantext_Components_Forest_Tree_Node_Action_Contact_Types["$_WriteForeignAddContactPar_11"])(Simple_JSON.readInt)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Annuaire.value, new Data_Maybe.Just(nodeId), "contact"));
      };
  };
  var actionAddContactCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(true))(function (isOpen) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(textInputBox({
                      boxAction: function (p) {
                          return new Gargantext_Components_Forest_Tree_Node_Action.AddContact(p);
                      },
                      boxName: "addContact",
                      dispatch: v.dispatch,
                      id: v.id,
                      isOpen: isOpen,
                      params: {
                          firstname: "First Name",
                          lastname: "Last Name"
                      }
                  }));
              });
          };
      };
      return here.component("actionAddContact")(cpt);
  })();
  var actionAddContact = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionAddContactCpt);
  exports["contactReq"] = contactReq;
  exports["actionAddContact"] = actionAddContact;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Delete"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Delete"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Delete"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var unpublishNode = function (s) {
      return function (p) {
          return function (n) {
              return Gargantext_Sessions.put_(Simple_JSON.readInt)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(s)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, p, "unpublish/" + Data_Show.show(Data_Show.showInt)(n)));
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Delete");
  var deleteNode = function (session) {
      return function (nt) {
          return function (nodeId) {
              return Gargantext_Sessions["delete"](Simple_JSON.readInt)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(nodeId), ""));
          };
      };
  };
  var actionDeleteUserCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Reactix_DOM_HTML.div({
                  style: {
                      margin: "10px"
                  }
              })([ Reactix_DOM_HTML.text("Yes, we are RGPD compliant!" + (" But you can not delete User Node yet." + (" We are still on development." + " Thanks for your comprehensin."))) ]) ])(Reactix_DOM_HTML.div({})([  ])));
          };
      };
      return here.component("actionDeleteUser")(cpt);
  })();
  var actionDeleteUser = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionDeleteUserCpt);
  var actionDeleteOtherCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel(Data_Functor.map(Data_Functor.functorArray)(function (t) {
                  return Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.text(t) ]);
              })([ "Are your sure you want to delete it ?", "If yes, click again below." ]))(Gargantext_Components_Forest_Tree_Node_Tools.submitButton(new Gargantext_Components_Forest_Tree_Node_Action.DeleteNode(v.nodeType))(v.dispatch)));
          };
      };
      return here.component("actionDeleteOther")(cpt);
  })();
  var actionDeleteOther = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionDeleteOtherCpt);
  var actionDeleteCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              if (v.nodeType instanceof Gargantext_Types.NodeUser) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(actionDeleteUser(v)([  ]));
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(actionDeleteOther(v)([  ]));
          };
      };
      return here.component("actionDelete")(cpt);
  })();
  var actionDelete = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionDeleteCpt);
  exports["deleteNode"] = deleteNode;
  exports["unpublishNode"] = unpublishNode;
  exports["actionDelete"] = actionDelete;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Tools.FTree"] = $PS["Gargantext.Components.Forest.Tree.Node.Tools.FTree"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Tools.FTree"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var NTree = (function () {
      function NTree(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      NTree.create = function (value0) {
          return function (value1) {
              return new NTree(value0, value1);
          };
      };
      return NTree;
  })();
  var fTreeID = function (v) {
      return v.value0.id;
  };
  var addParent = function (id) {
      return function (v) {
          return new NTree({
              id: v.value0.id,
              name: v.value0.name,
              nodeType: v.value0.nodeType,
              parent_id: new Data_Maybe.Just(id)
          }, Data_Functor.map(Data_Functor.functorArray)(addParent(v.value0.id))(v.value1));
      };
  };
  var $dollar_ReadForeignLNode_20 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "id";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "name";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "parent_id";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "type";
      }))(Gargantext_Types["$_ReadForeignNodeType_115"])(Simple_JSON.readFieldsNil)()())()())()())()()))(f))(function (v) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))({
              id: v.id,
              name: v.name,
              nodeType: v.type,
              parent_id: Data_Maybe.Nothing.value
          });
      });
  });
  var $dollar_ReadForeignNTreeLNode_14 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "children";
      }))(Simple_JSON.readArray($dollar_ReadForeignNTreeLNode_14))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "node";
      }))($dollar_ReadForeignLNode_20)(Simple_JSON.readFieldsNil)()())()()))(f))(function (v) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(new NTree(v.node, Data_Functor.map(Data_Functor.functorArray)(addParent(v.node.id))(v.children)));
      });
  });
  var $dollar_GenericLNode__18 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_FunctorNTree_16 = new Data_Functor.Functor(function (f) {
      return function (v) {
          return new NTree(f(v.value0), Data_Functor.map(Data_Functor.functorArray)(Data_Functor.map($dollar_FunctorNTree_16)(f))(v.value1));
      };
  });
  var $dollar_EqNTree_15 = function (dictEq) {
      return new Data_Eq.Eq(function (v) {
          return function (v1) {
              return Data_Eq.eq(dictEq)(v.value0)(v1.value0) && Data_Eq.eq(Data_Eq.eqArray($dollar_EqNTree_15(dictEq)))(v.value1)(v1.value1);
          };
      });
  };
  var $dollar_EqLNode_19 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericLNode__18)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "parent_id";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "nodeType";
  }))(Gargantext_Types["$_EqNodeType_114"]))()(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Data_Eq.eqInt))))));
  exports["fTreeID"] = fTreeID;
  exports["$_ReadForeignNTreeLNode_14"] = $dollar_ReadForeignNTreeLNode_14;
  exports["$_EqNTree_15"] = $dollar_EqNTree_15;
  exports["$_FunctorNTree_16"] = $dollar_FunctorNTree_16;
  exports["$_EqLNode_19"] = $dollar_EqLNode_19;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.LoadingSpinner"] = $PS["Gargantext.Components.LoadingSpinner"] || {};
  var exports = $PS["Gargantext.Components.LoadingSpinner"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.LoadingSpinner");
  var loadingSpinnerCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.i({
                  className: "fa fa-spinner fa-pulse fa-3x fa-fw"
              })([ Reactix_DOM_HTML.text("") ]));
          };
      };
      return here.component("LoadingSpinner")(cpt);
  })();
  var loadingSpinner = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(loadingSpinnerCpt)(props)([  ]);
  };
  exports["loadingSpinner"] = loadingSpinner;
})(PS);
(function(exports) {
  exports._makeRequest = function() {
      return function(url) {
          return function(options) {
              return new Request(url, options);

          }
      }
  }

  exports._openCache = function(cacheName) {
      return function() {
          return window.caches.open(cacheName);
      }
  }

  exports._delete = function(cacheName) {
      return function() {
          return caches.delete(cacheName);
      }
  }

  exports._deleteReq = function(cache) {
      return function(req) {
          return function() {
              return cache.delete(req);
          }
      }
  }

  exports._add = function(cache) {
      return function(req) {
          return function() {
              return cache.add(req);
          }
      }
  }

  exports._match = function(cache) {
      return function(req) {
          return function() {
              return cache.match(req);
          }
      }
  }
})(PS["Gargantext.Utils.CacheAPI"] = PS["Gargantext.Utils.CacheAPI"] || {});
(function(exports) {
    

  exports.textImpl = function(response) {
    return function() {
      return response.text();
    };
  };
})(PS["Milkis"] = PS["Milkis"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Milkis"] = $PS["Milkis"] || {};
  var exports = $PS["Milkis"];
  var $foreign = $PS["Milkis"];
  var Control_Promise = $PS["Control.Promise"];    
  var URL = function (x) {
      return x;
  };
  var text = function (res) {
      return Control_Promise.toAffE($foreign.textImpl(res));
  };                      
  var getMethod = "GET";
  exports["URL"] = URL;
  exports["getMethod"] = getMethod;
  exports["text"] = text;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.CacheAPI"] = $PS["Gargantext.Utils.CacheAPI"] || {};
  var exports = $PS["Gargantext.Utils.CacheAPI"];
  var $foreign = $PS["Gargantext.Utils.CacheAPI"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
  var Control_Monad_Except = $PS["Control.Monad.Except"];
  var Control_Promise = $PS["Control.Promise"];
  var Data_Either = $PS["Data.Either"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Foreign = $PS["Foreign"];
  var Foreign_Object = $PS["Foreign.Object"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Milkis = $PS["Milkis"];
  var Simple_JSON = $PS["Simple.JSON"];
  var openCache = function (v) {
      return Control_Promise.toAffE($foreign["_openCache"](v));
  };
  var match = function (cache) {
      return function (req) {
          return Control_Bind.bind(Effect_Aff.bindAff)(Control_Promise.toAffE($foreign["_match"](cache)(req)))(function (res) {
              var v = Control_Monad_Except.runExcept(Foreign.readNullOrUndefined(Data_Identity.monadIdentity)(res));
              if (v instanceof Data_Either.Left) {
                  return Control_Monad_Error_Class.throwError(Effect_Aff.monadThrowAff)(Effect_Exception.error(Data_Show.show(Data_List_Types.showNonEmptyList(Foreign.showForeignError))(v.value0)));
              };
              if (v instanceof Data_Either.Right) {
                  return Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Functor.map(Data_Maybe.functorMaybe)(Foreign.unsafeFromForeign)(v.value0));
              };
              throw new Error("Failed pattern match at Gargantext.Utils.CacheAPI (line 72, column 3 - line 74, column 48): " + [ v.constructor.name ]);
          });
      };
  };
  var makeRequest = function (dictUnion) {
      return function (url) {
          return function (options) {
              return $foreign["_makeRequest"](url)(options);
          };
      };
  };
  var makeTokenRequest = function (dictUnion) {
      return function (url) {
          return function (mToken) {
              return function (options) {
                  var defaultOptions = Foreign_Object.fromFoldable(Data_Foldable.foldableArray)([ new Data_Tuple.Tuple("Accept", "application/json"), new Data_Tuple.Tuple("Content-Type", "application/json") ]);
                  var mkHeaders = function (t) {
                      return Foreign_Object.unions(Data_Foldable.foldableArray)([ options.headers, defaultOptions, t ]);
                  };
                  if (mToken instanceof Data_Maybe.Nothing) {
                      return makeRequest()(url)((function () {
                          var $21 = {};
                          for (var $22 in options) {
                              if ({}.hasOwnProperty.call(options, $22)) {
                                  $21[$22] = options[$22];
                              };
                          };
                          $21.headers = mkHeaders(Foreign_Object.empty);
                          return $21;
                      })());
                  };
                  if (mToken instanceof Data_Maybe.Just) {
                      return makeRequest()(url)((function () {
                          var $24 = {};
                          for (var $25 in options) {
                              if ({}.hasOwnProperty.call(options, $25)) {
                                  $24[$25] = options[$25];
                              };
                          };
                          $24.headers = mkHeaders(Foreign_Object.singleton("Authorization")("Bearer " + mToken.value0));
                          return $24;
                      })());
                  };
                  throw new Error("Failed pattern match at Gargantext.Utils.CacheAPI (line 45, column 39 - line 47, column 110): " + [ mToken.constructor.name ]);
              };
          };
      };
  };
  var makeGetRequest = function (dictToUrl) {
      return function (v) {
          return function (p) {
              var url = Milkis.URL(Gargantext_Ends.toUrl(dictToUrl)(v)(p));
              return makeTokenRequest()(url)(new Data_Maybe.Just(v.token))({
                  method: Milkis.getMethod,
                  headers: Foreign_Object.empty
              });
          };
      };
  };
  var deleteReq = function (cache) {
      return function (req) {
          return Control_Promise.toAffE($foreign["_deleteReq"](cache)(req));
      };
  };
  var $$delete = function (v) {
      return Control_Promise.toAffE($foreign["_delete"](v));
  };
  var add = function (cache) {
      return function (req) {
          return Control_Promise.toAffE($foreign["_add"](cache)(req));
      };
  };
  var cached = function (cache) {
      return function (req) {
          return Control_Bind.bind(Effect_Aff.bindAff)(match(cache)(req))(function (mRes) {
              if (mRes instanceof Data_Maybe.Just) {
                  return Control_Applicative.pure(Effect_Aff.applicativeAff)(mRes.value0);
              };
              if (mRes instanceof Data_Maybe.Nothing) {
                  return Control_Bind.bind(Effect_Aff.bindAff)(add(cache)(req))(function () {
                      return Control_Bind.bind(Effect_Aff.bindAff)(match(cache)(req))(function (mResFresh) {
                          if (mResFresh instanceof Data_Maybe.Just) {
                              return Control_Applicative.pure(Effect_Aff.applicativeAff)(mResFresh.value0);
                          };
                          if (mResFresh instanceof Data_Maybe.Nothing) {
                              return Control_Monad_Error_Class.throwError(Effect_Aff.monadThrowAff)(Effect_Exception.error("Cannot add to cache"));
                          };
                          throw new Error("Failed pattern match at Gargantext.Utils.CacheAPI (line 87, column 7 - line 89, column 62): " + [ mResFresh.constructor.name ]);
                      });
                  });
              };
              throw new Error("Failed pattern match at Gargantext.Utils.CacheAPI (line 79, column 3 - line 89, column 62): " + [ mRes.constructor.name ]);
          });
      };
  };
  var cachedJson = function (dictReadForeign) {
      return function (cache) {
          return function (req) {
              return Control_Bind.bind(Effect_Aff.bindAff)(cached(cache)(req))(function (res) {
                  return Control_Bind.bind(Effect_Aff.bindAff)(Milkis.text(res))(function (j) {
                      var v = Simple_JSON.readJSON(dictReadForeign)(j);
                      if (v instanceof Data_Either.Left) {
                          return Control_Monad_Error_Class.throwError(Effect_Aff.monadThrowAff)(Effect_Exception.error("[cachedJson] decodeJson affResp.body: " + Data_Show.show(Data_List_Types.showNonEmptyList(Foreign.showForeignError))(v.value0)));
                      };
                      if (v instanceof Data_Either.Right) {
                          return Control_Applicative.pure(Effect_Aff.applicativeAff)(v.value0);
                      };
                      throw new Error("Failed pattern match at Gargantext.Utils.CacheAPI (line 98, column 3 - line 100, column 22): " + [ v.constructor.name ]);
                  });
              });
          };
      };
  };
  exports["makeGetRequest"] = makeGetRequest;
  exports["openCache"] = openCache;
  exports["delete"] = $$delete;
  exports["cachedJson"] = cachedJson;
  exports["deleteReq"] = deleteReq;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Hooks.Loader"] = $PS["Gargantext.Hooks.Loader"] || {};
  var exports = $PS["Gargantext.Hooks.Loader"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Gargantext_Components_LoadingSpinner = $PS["Gargantext.Components.LoadingSpinner"];
  var Gargantext_Utils_CacheAPI = $PS["Gargantext.Utils.CacheAPI"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var useLoaderEffect = function (dictEq) {
      return function (dictEq1) {
          return function (path) {
              return function (state) {
                  return function (loader1) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(dictEq1)))(state))(function (state$prime) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(path))(function (oPath) {
                              return Reactix_Hooks["useEffect'"](function __do() {
                                  var path$prime = Reactix_React.readRefM(Reactix_React.monadDelayEffect)(oPath)();
                                  var $29 = Data_Eq.eq(dictEq)(path$prime)(path) && Data_Maybe.isJust(state$prime);
                                  if ($29) {
                                      return Reactix_Hooks.nothing;
                                  };
                                  Reactix_React.setRef(oPath)(path)();
                                  return Gargantext_Utils_Reactix.affEffect("G.H.Loader.useLoaderEffect")(Control_Bind.bind(Effect_Aff.bindAff)(loader1(path))(function (l) {
                                      return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(new Data_Maybe.Just(l))(state));
                                  }))();
                              });
                          });
                      });
                  };
              };
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Hooks.Loader");
  var loaderCpt = function (dictEq) {
      return function (dictEq1) {
          var cpt = function (v) {
              return function (v1) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(dictEq1)))(v.state))(function (state$prime) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Data_Maybe.maybe(Gargantext_Components_LoadingSpinner.loadingSpinner({}))(v.render)(state$prime));
                  });
              };
          };
          return here.component("loader")(cpt);
      };
  };
  var loader = function (dictEq) {
      return function (dictEq1) {
          return Reactix_React.createElement(Reactix_React.componentIsComponent)(loaderCpt(dictEq)(dictEq1));
      };
  };
  var useLoader = function (dictEq) {
      return function (dictEq1) {
          return function (path) {
              return function (loader$prime) {
                  return function (render) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Maybe.Nothing.value))(function (state) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(useLoaderEffect(dictEq)(dictEq1)(path)(state)(loader$prime))(function () {
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)(loader(dictEq)(dictEq1)({
                                  path: path,
                                  render: render,
                                  state: state
                              })([  ]));
                          });
                      });
                  };
              };
          };
      };
  };
  var cacheName = "cache-api-loader";
  var clearCache = function (v) {
      return Gargantext_Utils_CacheAPI["delete"](cacheName);
  };
  var $dollar_ReadForeignHashedResponse_11 = function (dictReadForeign) {
      return Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "hash";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "value";
      }))(dictReadForeign)(Simple_JSON.readFieldsNil)()())()());
  };
  var useCachedAPILoaderEffect = function (dictEq) {
      return function (dictEq1) {
          return function (dictReadForeign) {
              return function (v) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(dictEq)))(v.state))(function (state$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(v.path))(function (oPath) {
                          return Reactix_Hooks["useEffect'"]((function () {
                              var $36 = Data_Eq.eq(dictEq1)(Reactix_React.readRef(oPath))(v.path) && Data_Maybe.isJust(state$prime);
                              if ($36) {
                                  return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                              };
                              return function __do() {
                                  Reactix_React.setRef(oPath)(v.path)();
                                  var req = v.mkRequest(v.path);
                                  return Effect_Aff.launchAff_(Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Utils_CacheAPI.openCache(cacheName))(function (cache) {
                                      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Utils_CacheAPI.cachedJson($dollar_ReadForeignHashedResponse_11(dictReadForeign))(cache)(req))(function (v1) {
                                          return Control_Bind.bind(Effect_Aff.bindAff)(v.cacheEndpoint(v.path))(function (cacheReal) {
                                              return Control_Bind.bind(Effect_Aff.bindAff)((function () {
                                                  var $38 = v1.hash === cacheReal;
                                                  if ($38) {
                                                      return Control_Applicative.pure(Effect_Aff.applicativeAff)(v1);
                                                  };
                                                  return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Utils_CacheAPI.deleteReq(cache)(req))(function () {
                                                      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Utils_CacheAPI.cachedJson($dollar_ReadForeignHashedResponse_11(dictReadForeign))(cache)(req))(function (v2) {
                                                          var $40 = v2.hash === cacheReal;
                                                          if ($40) {
                                                              return Control_Applicative.pure(Effect_Aff.applicativeAff)(v2);
                                                          };
                                                          return Control_Monad_Error_Class.throwError(Effect_Aff.monadThrowAff)(Effect_Exception.error("[Hooks.Loader] Fetched clean cache but hashes don't match: " + (v2.hash + (" != " + cacheReal))));
                                                      });
                                                  });
                                              })())(function (val) {
                                                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Just.create(v.handleResponse(val)))(v.state));
                                              });
                                          });
                                      });
                                  }))();
                              };
                          })());
                      });
                  });
              };
          };
      };
  };
  var useLoaderWithCacheAPI = function (dictEq) {
      return function (dictEq1) {
          return function (dictReadForeign) {
              return function (v) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Maybe.Nothing.value))(function (state) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(dictEq)))(state))(function (state$prime) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(useCachedAPILoaderEffect(dictEq)(dictEq1)(dictReadForeign)({
                              cacheEndpoint: v.cacheEndpoint,
                              handleResponse: v.handleResponse,
                              mkRequest: v.mkRequest,
                              path: v.path,
                              state: state
                          }))(function () {
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Data_Maybe.maybe(Gargantext_Components_LoadingSpinner.loadingSpinner({}))(v.renderer)(state$prime));
                          });
                      });
                  });
              };
          };
      };
  };
  exports["clearCache"] = clearCache;
  exports["useLoader"] = useLoader;
  exports["useLoaderWithCacheAPI"] = useLoaderWithCacheAPI;
  exports["$_ReadForeignHashedResponse_11"] = $dollar_ReadForeignHashedResponse_11;
})(PS);
(function(exports) {
  'use strict';

  exports.preventDefault = function preventDefault(event) {
    return function() {
      return event.preventDefault();
    };
  };

  exports.stopPropagation = function stopPropagation(event) {
    return function() {
      return event.stopPropagation();
    };
  };
})(PS["React.SyntheticEvent"] = PS["React.SyntheticEvent"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["React.SyntheticEvent"] = $PS["React.SyntheticEvent"] || {};
  var exports = $PS["React.SyntheticEvent"];
  var $foreign = $PS["React.SyntheticEvent"];
  exports["preventDefault"] = $foreign.preventDefault;
  exports["stopPropagation"] = $foreign.stopPropagation;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree"] = $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Show = $PS["Data.Show"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Components_Forest_Tree_Node_Tools_FTree = $PS["Gargantext.Components.Forest.Tree.Node.Tools.FTree"];
  var Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types = $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree.Types"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var React_SyntheticEvent = $PS["React.SyntheticEvent"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Tools.SubTree");
  var subTreeTreeViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var nodeClass = function (vnt) {
                  var validNodeTypeClass = (function () {
                      if (vnt) {
                          return "node-type-valid";
                      };
                      return "";
                  })();
                  return "node " + (Gargantext_Types.fldr(v.tree.value0.nodeType)(true) + (" " + validNodeTypeClass));
              };
              var validNodeType = Data_Array.elem(Gargantext_Types["$_EqNodeType_114"])(v.tree.value0.nodeType)(v.subTreeParams.value0.valitypes) && v.id !== v.tree.value0.id;
              var sortedAry = Data_Array.sortWith(Data_Ord.ordInt)(function (v2) {
                  return v2.value0.id;
              })(Data_Array.filter(function (v2) {
                  return v2.value0.id !== v.id;
              })(v.tree.value1));
              var isSelected = function (n) {
                  return function (action$prime) {
                      var v2 = Gargantext_Components_Forest_Tree_Node_Action.subTreeOut(action$prime);
                      if (v2 instanceof Data_Maybe.Nothing) {
                          return false;
                      };
                      if (v2 instanceof Data_Maybe.Just) {
                          return n === v2.value0.value0.out;
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Tools.SubTree (line 146, column 30 - line 148, column 46): " + [ v2.constructor.name ]);
                  };
              };
              var clickable = (function () {
                  if (validNodeType) {
                      return "clickable";
                  };
                  return "";
              })();
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Forest_Tree_Node_Action["$_EqAction_28"]))(v.action))(function (action$prime) {
                  var click = function (e) {
                      var action$prime$prime = (function () {
                          var $27 = !validNodeType;
                          if ($27) {
                              return Data_Maybe.Nothing.value;
                          };
                          return Data_Maybe.Just.create(new Gargantext_Components_Forest_Tree_Node_Tools_SubTree_Types.SubTreeOut({
                              "in": v.id,
                              out: v.tree.value0.id
                          }));
                      })();
                      return function __do() {
                          React_SyntheticEvent.preventDefault(e)();
                          React_SyntheticEvent.stopPropagation(e)();
                          return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (a) {
                              return Gargantext_Components_Forest_Tree_Node_Action.setTreeOut(a)(action$prime$prime);
                          })(v.action)();
                      };
                  };
                  var children = Data_Functor.map(Data_Functor.functorArray)(function (ctree) {
                      return v.render({
                          render: v.render,
                          tree: ctree,
                          action: v.action,
                          handed: v.handed,
                          subTreeParams: v.subTreeParams,
                          dispatch: v.dispatch,
                          id: v.id,
                          nodeType: v.nodeType,
                          session: v.session
                      })([  ]);
                  })(sortedAry);
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})(Gargantext_Types.reverseHanded(v.handed)([ Reactix_DOM_HTML.div({
                      className: nodeClass(validNodeType)
                  })([ Reactix_DOM_HTML.span({
                      className: "text",
                      on: {
                          click: click
                      }
                  })([ Gargantext_Components_Forest_Tree_Node_Tools.nodeText({
                      handed: v.handed,
                      isSelected: isSelected(v.tree.value0.id)(action$prime),
                      name: " " + v.tree.value0.name
                  })([  ]), Reactix_DOM_HTML.span({
                      className: "children"
                  })(children) ]) ]) ])));
              });
          };
      };
      return here.ntComponent("subTreeTreeView")(cpt);
  })();
  var subTreeTreeView = Gargantext_Utils_Reactix.ntCreateElement(Gargantext_Utils_Reactix.componentIsNTComponent)(subTreeTreeViewCpt);
  var subTreeViewLoadedCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var pRender = Record.merge()()({
                  render: subTreeTreeView
              })(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "tree"
              })([ Reactix_DOM_HTML.div({
                  className: (function () {
                      var $44 = Data_Eq.eq(Gargantext_Types["$_EqHanded_94"])(v.handed)(Gargantext_Types.RightHanded.value);
                      if ($44) {
                          return "righthanded";
                      };
                      return "lefthanded";
                  })()
              })([ subTreeTreeView(pRender)([  ]) ]) ]));
          };
      };
      return here.component("subTreeViewLoaded")(cpt);
  })();
  var subTreeViewLoaded = Reactix_React.createElement(Reactix_React.componentIsComponent)(subTreeViewLoadedCpt);
  var getSubTree = function (session) {
      return function (treeId) {
          return function (showtypes) {
              var nodeTypes = Data_Array.foldl(function (a) {
                  return function (b) {
                      return a + ("type=" + (Data_Show.show(Gargantext_Types["$_ShowNodeType_117"])(b) + "&"));
                  };
              })("?")(showtypes);
              return Gargantext_Sessions.get(Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_ReadForeignNTreeLNode_14"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Tree.value, new Data_Maybe.Just(treeId), nodeTypes));
          };
      };
  };
  var loadSubTree = function (nodetypes) {
      return function (session) {
          return getSubTree(session)(session.treeId)(nodetypes);
      };
  };
  var subTreeViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Gargantext_Hooks_Loader.useLoader(Gargantext_Sessions_Types["$_EqSession_33"])(Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_EqNTree_15"](Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_EqLNode_19"]))(v.session)(loadSubTree(v.subTreeParams.value0.showtypes))(function (tree) {
                  return subTreeViewLoaded({
                      action: v.action,
                      dispatch: v.dispatch,
                      handed: v.handed,
                      id: v.id,
                      nodeType: v.nodeType,
                      session: v.session,
                      subTreeParams: v.subTreeParams,
                      tree: tree
                  })([  ]);
              });
          };
      };
      return here.component("subTreeView")(cpt);
  })();
  var subTreeView = Reactix_React.createElement(Reactix_React.componentIsComponent)(subTreeViewCpt);
  exports["subTreeView"] = subTreeView;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Link"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Link"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Link"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Components_Forest_Tree_Node_Tools_SubTree = $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var linkNodeType = function (v) {
      if (v instanceof Data_Maybe.Just && v.value0 instanceof Gargantext_Types.Corpus) {
          return Gargantext_Types.Annuaire.value;
      };
      if (v instanceof Data_Maybe.Just && v.value0 instanceof Gargantext_Types.Annuaire) {
          return Gargantext_Types.Corpus.value;
      };
      return Gargantext_Types["Error"].value;
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Link");
  var linkNodeCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(new Gargantext_Components_Forest_Tree_Node_Action.LinkNode({
                  nodeType: Data_Maybe.Nothing.value,
                  params: Data_Maybe.Nothing.value
              })))(function (action) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Forest_Tree_Node_Action["$_EqAction_28"]))(action))(function (action$prime) {
                      var button = (function () {
                          if (action$prime instanceof Gargantext_Components_Forest_Tree_Node_Action.LinkNode) {
                              if (action$prime.value0.params instanceof Data_Maybe.Just) {
                                  return Gargantext_Components_Forest_Tree_Node_Tools.submitButton(new Gargantext_Components_Forest_Tree_Node_Action.LinkNode({
                                      nodeType: new Data_Maybe.Just(v.nodeType),
                                      params: new Data_Maybe.Just(action$prime.value0.params.value0)
                                  }))(v.dispatch);
                              };
                              if (action$prime.value0.params instanceof Data_Maybe.Nothing) {
                                  return Reactix_DOM_HTML.div({})([  ]);
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Link (line 57, column 38 - line 59, column 39): " + [ action$prime.value0.params.constructor.name ]);
                          };
                          return Reactix_DOM_HTML.div({})([  ]);
                      })();
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Gargantext_Components_Forest_Tree_Node_Tools_SubTree.subTreeView({
                          action: action,
                          dispatch: v.dispatch,
                          handed: v.handed,
                          id: v.id,
                          nodeType: v.nodeType,
                          session: v.session,
                          subTreeParams: v.subTreeParams
                      })([  ]) ])(button));
                  });
              });
          };
      };
      return here.component("linkNode")(cpt);
  })();
  var linkNode = Reactix_React.createElement(Reactix_React.componentIsComponent)(linkNodeCpt);
  var $dollar_WriteForeignLinkNodeReq_13 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Simple_JSON.writeForeignInt)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "nodeType";
  }))(Gargantext_Types["$_WriteForeignNodeType_116"])(Simple_JSON.nilWriteForeignFields)()()())()()());
  var linkNodeReq = function (session) {
      return function (nt) {
          return function (fromId) {
              return function (toId) {
                  return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.post($dollar_WriteForeignLinkNodeReq_13)(Gargantext_Types["$_ReadForeignAsyncTask_167"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(fromId), "update"))({
                      nodeType: linkNodeType(nt),
                      id: toId
                  }))(function (task) {
                      return Control_Applicative.pure(Effect_Aff.applicativeAff)({
                          task: task,
                          typ: Gargantext_Types.UpdateNode.value
                      });
                  });
              };
          };
      };
  };
  exports["linkNodeReq"] = linkNodeReq;
  exports["linkNode"] = linkNode;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Merge"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Merge"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Merge"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Set = $PS["Data.Set"];
  var Data_Show = $PS["Data.Show"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Components_Forest_Tree_Node_Tools_SubTree = $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];                
  var mergeNodeReq = function (session) {
      return function (fromId) {
          return function (toId) {
              return Gargantext_Sessions.put_(Simple_JSON.readArray(Simple_JSON.readInt))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(fromId), "merge/" + Data_Show.show(Data_Show.showInt)(toId)));
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Merge");
  var mergeNodeCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(new Gargantext_Components_Forest_Tree_Node_Action.MergeNode({
                  params: Data_Maybe.Nothing.value
              })))(function (action) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Forest_Tree_Node_Action["$_EqAction_28"]))(action))(function (action$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(false))(function (merge) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Set.singleton(Gargantext_Types.MapTerm.value)))(function (options) {
                              var button = (function () {
                                  if (action$prime instanceof Gargantext_Components_Forest_Tree_Node_Action.MergeNode) {
                                      if (action$prime.value0.params instanceof Data_Maybe.Just) {
                                          return Gargantext_Components_Forest_Tree_Node_Tools.submitButton(new Gargantext_Components_Forest_Tree_Node_Action.MergeNode({
                                              params: new Data_Maybe.Just(action$prime.value0.params.value0)
                                          }))(v.dispatch);
                                      };
                                      if (action$prime.value0.params instanceof Data_Maybe.Nothing) {
                                          return Reactix_DOM_HTML.div({})([  ]);
                                      };
                                      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Merge (line 39, column 35 - line 41, column 37): " + [ action$prime.value0.params.constructor.name ]);
                                  };
                                  return Reactix_DOM_HTML.div({})([  ]);
                              })();
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Gargantext_Components_Forest_Tree_Node_Tools_SubTree.subTreeView({
                                  action: action,
                                  dispatch: v.dispatch,
                                  handed: v.handed,
                                  id: v.id,
                                  nodeType: v.nodeType,
                                  session: v.session,
                                  subTreeParams: v.subTreeParams
                              })([  ]), Reactix_DOM_HTML.ul({
                                  className: "merge mx-auto list-group"
                              })([ Reactix_DOM_HTML.li({
                                  className: "list-group-item"
                              })([ Reactix_DOM_HTML.h5({
                                  className: "mb-1"
                              })([ Reactix_DOM_HTML.text("Merge which list?") ]), Gargantext_Components_Forest_Tree_Node_Tools.checkboxesListGroup(Gargantext_Types["$_OrdTermList_104"])(Gargantext_Types["$_ShowTermList_107"])({
                                  groups: [ Gargantext_Types.MapTerm.value, Gargantext_Types.CandidateTerm.value, Gargantext_Types.StopTerm.value ],
                                  options: options
                              })([  ]) ]) ]), Reactix_DOM_HTML.ul({
                                  className: "merge mx-auto list-group"
                              })([ Reactix_DOM_HTML.li({
                                  className: "list-group-item"
                              })([ Reactix_DOM_HTML.h5({
                                  className: "mb-1"
                              })([ Reactix_DOM_HTML.text("Title") ]) ]), Reactix_DOM_HTML.li({
                                  className: "list-group-item"
                              })([ Reactix_DOM_HTML.div({
                                  className: " form-check"
                              })([ Gargantext_Components_Forest_Tree_Node_Tools.checkbox({
                                  value: merge
                              }), Reactix_DOM_HTML.label({
                                  className: "form-check-label"
                              })([ Reactix_DOM_HTML.text("Merge data?") ]) ]) ]) ]) ])(button));
                          });
                      });
                  });
              });
          };
      };
      return here.component("mergeNode")(cpt);
  })();
  var mergeNode = Reactix_React.createElement(Reactix_React.componentIsComponent)(mergeNodeCpt);
  exports["mergeNodeReq"] = mergeNodeReq;
  exports["mergeNode"] = mergeNode;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Move"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Move"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Move"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Components_Forest_Tree_Node_Tools_SubTree = $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];                
  var moveNodeReq = function (session) {
      return function (fromId) {
          return function (toId) {
              return Gargantext_Sessions.put_(Simple_JSON.readArray(Simple_JSON.readInt))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(fromId), "move/" + Data_Show.show(Data_Show.showInt)(toId)));
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Move");
  var moveNodeCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(new Gargantext_Components_Forest_Tree_Node_Action.MoveNode({
                  params: Data_Maybe.Nothing.value
              })))(function (v2) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Forest_Tree_Node_Action["$_EqAction_28"]))(v2))(function (action$prime) {
                      var button = (function () {
                          if (action$prime instanceof Gargantext_Components_Forest_Tree_Node_Action.MoveNode) {
                              if (action$prime.value0.params instanceof Data_Maybe.Just) {
                                  return Gargantext_Components_Forest_Tree_Node_Tools.submitButton(new Gargantext_Components_Forest_Tree_Node_Action.MoveNode({
                                      params: new Data_Maybe.Just(action$prime.value0.params.value0)
                                  }))(v.dispatch);
                              };
                              if (action$prime.value0.params instanceof Data_Maybe.Nothing) {
                                  return Reactix_DOM_HTML.div({})([  ]);
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Move (line 36, column 38 - line 38, column 39): " + [ action$prime.value0.params.constructor.name ]);
                          };
                          return Reactix_DOM_HTML.div({})([  ]);
                      })();
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Gargantext_Components_Forest_Tree_Node_Tools_SubTree.subTreeView({
                          action: v2,
                          dispatch: v.dispatch,
                          handed: v.handed,
                          id: v.id,
                          nodeType: v.nodeType,
                          session: v.session,
                          subTreeParams: v.subTreeParams
                      })([  ]) ])(button));
                  });
              });
          };
      };
      return here.component("moveNode")(cpt);
  })();
  var moveNode = Reactix_React.createElement(Reactix_React.componentIsComponent)(moveNodeCpt);
  exports["moveNodeReq"] = moveNodeReq;
  exports["moveNode"] = moveNode;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Rename"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Rename"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Rename"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Simple_JSON = $PS["Simple.JSON"];
  var renameAction = function (newName) {
      return new Gargantext_Components_Forest_Tree_Node_Action.RenameNode(newName);
  };
  var $dollar_WriteForeignRenameValue_5 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "name";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()()))({
          name: v.text
      });
  });
  var rename = function (session) {
      return function (renameNodeId) {
          return Gargantext_Sessions.put($dollar_WriteForeignRenameValue_5)(Simple_JSON.readArray(Simple_JSON.readInt))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(renameNodeId), "rename"));
      };
  };
  exports["rename"] = rename;
  exports["renameAction"] = renameAction;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Share"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Share"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Share"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Show_Generic = $PS["Data.Show.Generic"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Components_Forest_Tree_Node_Tools_SubTree = $PS["Gargantext.Components.Forest.Tree.Node.Tools.SubTree"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];                
  var ShareTeamParams = (function () {
      function ShareTeamParams(value0) {
          this.value0 = value0;
      };
      ShareTeamParams.create = function (value0) {
          return new ShareTeamParams(value0);
      };
      return ShareTeamParams;
  })();
  var SharePublicParams = (function () {
      function SharePublicParams(value0) {
          this.value0 = value0;
      };
      SharePublicParams.create = function (value0) {
          return new SharePublicParams(value0);
      };
      return SharePublicParams;
  })();
  var shareAction = function (username) {
      return new Gargantext_Components_Forest_Tree_Node_Action.ShareTeam(username);
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Share");
  var publishNodeCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(new Gargantext_Components_Forest_Tree_Node_Action.SharePublic({
                  params: Data_Maybe.Nothing.value
              })))(function (action) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Forest_Tree_Node_Action["$_EqAction_28"]))(action))(function (action$prime) {
                      var button = (function () {
                          if (action$prime instanceof Gargantext_Components_Forest_Tree_Node_Action.SharePublic) {
                              if (action$prime.value0.params instanceof Data_Maybe.Just) {
                                  return Gargantext_Components_Forest_Tree_Node_Tools.submitButton(new Gargantext_Components_Forest_Tree_Node_Action.SharePublic({
                                      params: new Data_Maybe.Just(action$prime.value0.params.value0)
                                  }))(v.dispatch);
                              };
                              if (action$prime.value0.params instanceof Data_Maybe.Nothing) {
                                  return Reactix_DOM_HTML.div({})([  ]);
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Share (line 79, column 48 - line 81, column 39): " + [ action$prime.value0.params.constructor.name ]);
                          };
                          return Reactix_DOM_HTML.div({})([  ]);
                      })();
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Gargantext_Components_Forest_Tree_Node_Tools_SubTree.subTreeView({
                          action: action,
                          dispatch: v.dispatch,
                          handed: v.handed,
                          id: v.id,
                          nodeType: v.nodeType,
                          session: v.session,
                          subTreeParams: v.subTreeParams
                      })([  ]) ])(button));
                  });
              });
          };
      };
      return here.component("publishNode")(cpt);
  })();
  var publishNode = Reactix_React.createElement(Reactix_React.componentIsComponent)(publishNodeCpt);
  var shareNodeCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(true))(function (isOpen) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Gargantext_Components_Forest_Tree_Node_Tools.textInputBox({
                      boxAction: shareAction,
                      boxName: "Share",
                      dispatch: v.dispatch,
                      id: v.id,
                      isOpen: isOpen,
                      text: "username"
                  })([  ]) ])(Reactix_DOM_HTML.div({})([  ])));
              });
          };
      };
      return here.component("shareNode")(cpt);
  })();
  var shareNode = Reactix_React.createElement(Reactix_React.componentIsComponent)(shareNodeCpt);
  var $dollar_GenericShareNodeParams__14 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof ShareTeamParams) {
          return new Data_Generic_Rep.Inl(x.value0);
      };
      if (x instanceof SharePublicParams) {
          return new Data_Generic_Rep.Inr(x.value0);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Share (line 43, column 1 - line 43, column 42): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return new ShareTeamParams(x.value0);
      };
      if (x instanceof Data_Generic_Rep.Inr) {
          return new SharePublicParams(x.value0);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Share (line 43, column 1 - line 43, column 42): " + [ x.constructor.name ]);
  });                                                           
  var $dollar_ShowShareNodeParams_17 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericShareNodeParams__14)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsArgument(Data_Show.showRecord()(Data_Show.showRecordFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "username";
  }))(Data_Show.showRecordFieldsNil)(Data_Show.showString))))(new Data_Symbol.IsSymbol(function () {
      return "ShareTeamParams";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsArgument(Data_Show.showRecord()(Data_Show.showRecordFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "node_id";
  }))(Data_Show.showRecordFieldsNil)(Data_Show.showInt))))(new Data_Symbol.IsSymbol(function () {
      return "SharePublicParams";
  })))));
  var $dollar_WriteForeignShareNodePara_16 = new Simple_JSON.WriteForeign((function () {
      var $47 = Simple_JSON.writeImpl(Simple_JSON.writeForeignString);
      var $48 = Data_Show.show($dollar_ShowShareNodeParams_17);
      return function ($49) {
          return $47($48($49));
      };
  })());
  var shareReq = function (session) {
      return function (nodeId) {
          return Gargantext_Sessions.post($dollar_WriteForeignShareNodePara_16)(Simple_JSON.readInt)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(nodeId), "share"));
      };
  };
  exports["shareReq"] = shareReq;
  exports["ShareTeamParams"] = ShareTeamParams;
  exports["SharePublicParams"] = SharePublicParams;
  exports["shareNode"] = shareNode;
  exports["publishNode"] = publishNode;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Update"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Update"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Update"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Action_Update_Types = $PS["Gargantext.Components.Forest.Tree.Node.Action.Update.Types"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var updateRequest = function (updateNodeParams) {
      return function (session) {
          return function (nodeId) {
              var p = new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(nodeId), "update");
              return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.post(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_WriteForeignUpdateNodePar_37"])(Gargantext_Types["$_ReadForeignAsyncTask_167"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(p)(updateNodeParams))(function (task) {
                  return Control_Applicative.pure(Effect_Aff.applicativeAff)({
                      task: task,
                      typ: Gargantext_Types.UpdateNode.value
                  });
              });
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Update");
  var updateDashboardCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_Forest_Tree_Node_Action_Update_Types.All.value))(function (methodBoard) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_EqCharts_57"]))(methodBoard))(function (methodBoard$prime) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Gargantext_Components_Forest_Tree_Node_Tools.formChoiceSafe(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_ReadCharts_59"])(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_ShowCharts_58"])([ Gargantext_Components_Forest_Tree_Node_Action_Update_Types.All.value, Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Sources.value, Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Authors.value, Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Institutes.value, Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Ngrams.value ])(Gargantext_Components_Forest_Tree_Node_Action_Update_Types.All.value)(function (val) {
                          return Toestand_Classes.write_(Toestand_Boxes.writeBox)(val)(methodBoard);
                      }) ])(Gargantext_Components_Forest_Tree_Node_Tools.submitButton(Gargantext_Components_Forest_Tree_Node_Action.UpdateNode.create(new Gargantext_Components_Forest_Tree_Node_Action_Update_Types.UpdateNodeParamsBoard({
                          methodBoard: methodBoard$prime
                      })))(v.dispatch)));
                  });
              });
          };
      };
      return here.component("updateDashboard")(cpt);
  })();
  var updateDashboard = Reactix_React.createElement(Reactix_React.componentIsComponent)(updateDashboardCpt);
  var updateGraphCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Order1.value))(function (methodGraph) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_EqGraphMetric_45"]))(methodGraph))(function (methodGraph$prime) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Gargantext_Components_Forest_Tree_Node_Tools.formChoiceSafe(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_ReadGraphMetric_47"])(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_ShowGraphMetric_46"])([ Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Order1.value, Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Order2.value ])(Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Order1.value)(function (val) {
                          return Toestand_Classes.write_(Toestand_Boxes.writeBox)(val)(methodGraph);
                      }) ])(Gargantext_Components_Forest_Tree_Node_Tools.submitButton(Gargantext_Components_Forest_Tree_Node_Action.UpdateNode.create(new Gargantext_Components_Forest_Tree_Node_Action_Update_Types.UpdateNodeParamsGraph({
                          methodGraph: methodGraph$prime
                      })))(v.dispatch)));
                  });
              });
          };
      };
      return here.component("updateGraph")(cpt);
  })();
  var updateGraph = Reactix_React.createElement(Reactix_React.componentIsComponent)(updateGraphCpt);
  var updateNodeListCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Basic.value))(function (methodList) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_EqMethod_39"]))(methodList))(function (methodList$prime) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Gargantext_Components_Forest_Tree_Node_Tools.formChoiceSafe(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_ReadMethod_43"])(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_ShowMethod_40"])([ Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Basic.value, Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Advanced.value, Gargantext_Components_Forest_Tree_Node_Action_Update_Types.WithModel.value ])(Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Basic.value)(function (val) {
                          return Toestand_Classes.write_(Toestand_Boxes.writeBox)(val)(methodList);
                      }) ])(Gargantext_Components_Forest_Tree_Node_Tools.submitButton(Gargantext_Components_Forest_Tree_Node_Action.UpdateNode.create(new Gargantext_Components_Forest_Tree_Node_Action_Update_Types.UpdateNodeParamsList({
                          methodList: methodList$prime
                      })))(v.dispatch)));
                  });
              });
          };
      };
      return here.component("updateNodeList")(cpt);
  })();
  var updateNodeList = Reactix_React.createElement(Reactix_React.componentIsComponent)(updateNodeListCpt);
  var updateOtherCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
          };
      };
      return here.component("updateOther")(cpt);
  })();
  var updateOther = Reactix_React.createElement(Reactix_React.componentIsComponent)(updateOtherCpt);
  var updateTextsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_Forest_Tree_Node_Action_Update_Types.NewNgrams.value))(function (methodTexts) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_EqGranularity_51"]))(methodTexts))(function (methodTexts$prime) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Gargantext_Components_Forest_Tree_Node_Tools.formChoiceSafe(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_ReadGranularity_53"])(Gargantext_Components_Forest_Tree_Node_Action_Update_Types["$_ShowGranularity_52"])([ Gargantext_Components_Forest_Tree_Node_Action_Update_Types.NewNgrams.value, Gargantext_Components_Forest_Tree_Node_Action_Update_Types.NewTexts.value, Gargantext_Components_Forest_Tree_Node_Action_Update_Types.Both.value ])(Gargantext_Components_Forest_Tree_Node_Action_Update_Types.NewNgrams.value)(function (val) {
                          return Toestand_Classes.write_(Toestand_Boxes.writeBox)(val)(methodTexts);
                      }) ])(Gargantext_Components_Forest_Tree_Node_Tools.submitButton(Gargantext_Components_Forest_Tree_Node_Action.UpdateNode.create(new Gargantext_Components_Forest_Tree_Node_Action_Update_Types.UpdateNodeParamsTexts({
                          methodTexts: methodTexts$prime
                      })))(v.dispatch)));
                  });
              });
          };
      };
      return here.component("updateTexts")(cpt);
  })();
  var updateTexts = Reactix_React.createElement(Reactix_React.componentIsComponent)(updateTextsCpt);
  var updateCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              if (v.nodeType instanceof Gargantext_Types.Dashboard) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(updateDashboard(v)([  ]));
              };
              if (v.nodeType instanceof Gargantext_Types.Graph) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(updateGraph(v)([  ]));
              };
              if (v.nodeType instanceof Gargantext_Types.NodeList) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(updateNodeList(v)([  ]));
              };
              if (v.nodeType instanceof Gargantext_Types.Texts) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(updateTexts(v)([  ]));
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(updateOther(v)([  ]));
          };
      };
      return here.component("update")(cpt);
  })();
  var update = Reactix_React.createElement(Reactix_React.componentIsComponent)(updateCpt);
  exports["updateRequest"] = updateRequest;
  exports["update"] = update;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Lang"] = $PS["Gargantext.Components.Lang"] || {};
  var exports = $PS["Gargantext.Components.Lang"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Gargantext_Prelude = $PS["Gargantext.Prelude"];                
  var FR = (function () {
      function FR() {

      };
      FR.value = new FR();
      return FR;
  })();
  var EN = (function () {
      function EN() {

      };
      EN.value = new EN();
      return EN;
  })();
  var Universal = (function () {
      function Universal() {

      };
      Universal.value = new Universal();
      return Universal;
  })();
  var No_extraction = (function () {
      function No_extraction() {

      };
      No_extraction.value = new No_extraction();
      return No_extraction;
  })();
  var LL_EN = (function () {
      function LL_EN() {

      };
      LL_EN.value = new LL_EN();
      return LL_EN;
  })();
  var LL_FR = (function () {
      function LL_FR() {

      };
      LL_FR.value = new LL_FR();
      return LL_FR;
  })();
  var allLangs = [ EN.value, FR.value, Universal.value, No_extraction.value ];
  var $dollar_ShowLang_4 = new Data_Show.Show(function (v) {
      if (v instanceof FR) {
          return "FR";
      };
      if (v instanceof EN) {
          return "EN";
      };
      if (v instanceof Universal) {
          return "All";
      };
      if (v instanceof No_extraction) {
          return "Nothing";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Lang (line 17, column 1 - line 21, column 33): " + [ v.constructor.name ]);
  });
  var $dollar_ReadLang_6 = new Gargantext_Prelude.Read(function (v) {
      if (v === "FR") {
          return new Data_Maybe.Just(FR.value);
      };
      if (v === "EN") {
          return new Data_Maybe.Just(EN.value);
      };
      if (v === "All") {
          return new Data_Maybe.Just(Universal.value);
      };
      if (v === "Nothing") {
          return new Data_Maybe.Just(No_extraction.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var $dollar_EqLang_5 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof FR && y instanceof FR) {
              return true;
          };
          if (x instanceof EN && y instanceof EN) {
              return true;
          };
          if (x instanceof Universal && y instanceof Universal) {
              return true;
          };
          if (x instanceof No_extraction && y instanceof No_extraction) {
              return true;
          };
          return false;
      };
  });
  exports["allLangs"] = allLangs;
  exports["FR"] = FR;
  exports["EN"] = EN;
  exports["Universal"] = Universal;
  exports["No_extraction"] = No_extraction;
  exports["LL_EN"] = LL_EN;
  exports["LL_FR"] = LL_FR;
  exports["$_ShowLang_4"] = $dollar_ShowLang_4;
  exports["$_EqLang_5"] = $dollar_EqLang_5;
  exports["$_ReadLang_6"] = $dollar_ReadLang_6;
})(PS);
(function(exports) {
  "use strict";

  exports.eventListener = function (fn) {
    return function () {
      return function (event) {
        return fn(event)();
      };
    };
  };

  exports.addEventListener = function (type) {
    return function (listener) {
      return function (useCapture) {
        return function (target) {
          return function () {
            return target.addEventListener(type, listener, useCapture);
          };
        };
      };
    };
  };

  exports.removeEventListener = function (type) {
    return function (listener) {
      return function (useCapture) {
        return function (target) {
          return function () {
            return target.removeEventListener(type, listener, useCapture);
          };
        };
      };
    };
  };
})(PS["Web.Event.EventTarget"] = PS["Web.Event.EventTarget"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.Event.EventTarget"] = $PS["Web.Event.EventTarget"] || {};
  var exports = $PS["Web.Event.EventTarget"];
  var $foreign = $PS["Web.Event.EventTarget"];
  exports["eventListener"] = $foreign.eventListener;
  exports["addEventListener"] = $foreign.addEventListener;
  exports["removeEventListener"] = $foreign.removeEventListener;
})(PS);
(function(exports) {
  "use strict";

  exports.fileReader = function () {
    return new FileReader();
  };

  exports.result = function (fr) {
    return function () {
      return fr.result;
    };
  };

  exports.readAsText = function (blob) {
    return function (fr) {
      return function () {
        fr.readAsText(blob);
      };
    };
  };

  exports.readAsDataURL = function (blob) {
    return function (fr) {
      return function () {
        fr.readAsDataURL(blob);
      };
    };
  };
})(PS["Web.File.FileReader"] = PS["Web.File.FileReader"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.File.FileReader"] = $PS["Web.File.FileReader"] || {};
  var exports = $PS["Web.File.FileReader"];
  var $foreign = $PS["Web.File.FileReader"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];                      
  var toEventTarget = Unsafe_Coerce.unsafeCoerce;
  exports["toEventTarget"] = toEventTarget;
  exports["fileReader"] = $foreign.fileReader;
  exports["result"] = $foreign.result;
  exports["readAsText"] = $foreign.readAsText;
  exports["readAsDataURL"] = $foreign.readAsDataURL;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.HTML.Event.EventTypes"] = $PS["Web.HTML.Event.EventTypes"] || {};
  var exports = $PS["Web.HTML.Event.EventTypes"];
  var load = "load";  
  var error = "error";
  exports["error"] = error;
  exports["load"] = load;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.File.FileReader.Aff"] = $PS["Web.File.FileReader.Aff"] || {};
  var exports = $PS["Web.File.FileReader.Aff"];
  var Control_Monad_Except = $PS["Control.Monad.Except"];
  var Data_Either = $PS["Data.Either"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Show = $PS["Data.Show"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Foreign = $PS["Foreign"];
  var Web_Event_EventTarget = $PS["Web.Event.EventTarget"];
  var Web_File_FileReader = $PS["Web.File.FileReader"];
  var Web_HTML_Event_EventTypes = $PS["Web.HTML.Event.EventTypes"];                
  var readAs = function (readMethod) {
      return function (getResult) {
          return function (blob) {
              return Effect_Aff.makeAff(function (fun) {
                  var succ = function ($2) {
                      return fun(Data_Either.Right.create($2));
                  };
                  var err = function ($3) {
                      return fun(Data_Either.Left.create($3));
                  };
                  return function __do() {
                      var fr = Web_File_FileReader.fileReader();
                      var et = Web_File_FileReader.toEventTarget(fr);
                      var errorListener = Web_Event_EventTarget.eventListener(function (v) {
                          return err(Effect_Exception.error("error"));
                      })();
                      var loadListener = Web_Event_EventTarget.eventListener(function (v) {
                          return function __do() {
                              var res = Web_File_FileReader.result(fr)();
                              return Data_Either.either(function (errs) {
                                  return err(Effect_Exception.error(Data_Show.show(Data_List_Types.showNonEmptyList(Foreign.showForeignError))(errs)));
                              })(succ)(Control_Monad_Except.runExcept(readMethod(res)))();
                          };
                      })();
                      Web_Event_EventTarget.addEventListener(Web_HTML_Event_EventTypes.error)(errorListener)(false)(et)();
                      Web_Event_EventTarget.addEventListener(Web_HTML_Event_EventTypes.load)(loadListener)(false)(et)();
                      getResult(blob)(fr)();
                      return Data_Monoid.mempty(Effect_Aff.monoidCanceler);
                  };
              });
          };
      };
  };                                                                                                                                          
  var readAsDataURL = readAs(Foreign.readString(Data_Identity.monadIdentity))(Web_File_FileReader.readAsDataURL);
  var readAsText = readAs(Foreign.readString(Data_Identity.monadIdentity))(Web_File_FileReader.readAsText);
  exports["readAsText"] = readAsText;
  exports["readAsDataURL"] = readAsDataURL;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var Data_Either = $PS["Data.Either"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_String_Regex = $PS["Data.String.Regex"];
  var Data_String_Regex_Flags = $PS["Data.String.Regex.Flags"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Action_Upload_Types = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload.Types"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Components_Lang = $PS["Gargantext.Components.Lang"];
  var Gargantext_Prelude = $PS["Gargantext.Prelude"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Partial_Unsafe = $PS["Partial.Unsafe"];
  var React_SyntheticEvent = $PS["React.SyntheticEvent"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var Web_File_FileReader_Aff = $PS["Web.File.FileReader.Aff"];
  var DroppedFile = (function () {
      function DroppedFile(value0) {
          this.value0 = value0;
      };
      DroppedFile.create = function (value0) {
          return new DroppedFile(value0);
      };
      return DroppedFile;
  })();
  var uploadFile = function (session) {
      return function (nodeType) {
          return function (id) {
              return function (fileType) {
                  return function (v) {
                      var p = (function () {
                          if (nodeType instanceof Gargantext_Types.Corpus) {
                              return Gargantext_Routes.NodeAPI.create(nodeType)(new Data_Maybe.Just(id))(Gargantext_Types.asyncTaskTypePath(Gargantext_Types.Form.value));
                          };
                          if (nodeType instanceof Gargantext_Types.Annuaire) {
                              return new Gargantext_Routes.NodeAPI(nodeType, new Data_Maybe.Just(id), "annuaire");
                          };
                          return new Gargantext_Routes.NodeAPI(nodeType, new Data_Maybe.Just(id), "");
                      })();
                      var bodyParams = function (c) {
                          return [ new Data_Tuple.Tuple("_wf_data", new Data_Maybe.Just(c)), new Data_Tuple.Tuple("_wf_filetype", Data_Maybe.Just.create(Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_ShowFileType_8"])(fileType))), new Data_Tuple.Tuple("_wf_name", v.mName) ];
                      };
                      return Control_Bind.bind(Effect_Aff.bindAff)(Web_File_FileReader_Aff.readAsText(v.blob))(function (contents) {
                          return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.postWwwUrlencoded(Gargantext_Types["$_ReadForeignAsyncTask_167"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(p)(bodyParams(contents)))(function (task) {
                              return Control_Applicative.pure(Effect_Aff.applicativeAff)({
                                  task: task,
                                  typ: Gargantext_Types.Form.value
                              });
                          });
                      });
                  };
              };
          };
      };
  };
  var uploadArbitraryDataURL = function (session) {
      return function (id) {
          return function (mName) {
              return function (contents$prime) {
                  var p = Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value)(new Data_Maybe.Just(id))(Gargantext_Types.asyncTaskTypePath(Gargantext_Types.UploadFile.value));
                  var bodyParams = function (c) {
                      return [ new Data_Tuple.Tuple("_wfi_b64_data", new Data_Maybe.Just(c)), new Data_Tuple.Tuple("_wfi_name", mName) ];
                  };
                  var re = Data_Either["fromRight'"](function (v) {
                      return Partial_Unsafe.unsafeCrashWith("Unexpected Left");
                  })(Data_String_Regex.regex("data:.*;base64,")(Data_String_Regex_Flags.noFlags));
                  var contents = Data_String_Regex.replace(re)("")(contents$prime);
                  return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.postWwwUrlencoded(Gargantext_Types["$_ReadForeignAsyncTask_167"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(p)(bodyParams(contents)))(function (task) {
                      return Control_Applicative.pure(Effect_Aff.applicativeAff)({
                          task: task,
                          typ: Gargantext_Types.Form.value
                      });
                  });
              };
          };
      };
  };
  var uploadArbitraryFile = function (session) {
      return function (id) {
          return function (v) {
              return Control_Bind.bind(Effect_Aff.bindAff)(Web_File_FileReader_Aff.readAsDataURL(v.blob))(function (contents) {
                  return uploadArbitraryDataURL(session)(id)(v.mName)(contents);
              });
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Upload");
  var uploadButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onClick = function (fileType$prime) {
                  return function (mFile$prime) {
                      return function (e) {
                          var v2 = Data_Maybe.fromJust()(mFile$prime);
                          return function __do() {
                              DOM_Simple_Console.log2("[uploadButton] fileType")(fileType$prime)();
                              return Data_Functor["void"](Effect.functorEffect)(Effect_Aff.launchAff(Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)((function () {
                                  if (fileType$prime instanceof Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.Arbitrary) {
                                      return v.dispatch(new Gargantext_Components_Forest_Tree_Node_Action.UploadArbitraryFile(new Data_Maybe.Just(v2.name), v2.blob));
                                  };
                                  return v.dispatch(new Gargantext_Components_Forest_Tree_Node_Action.UploadFile(v.nodeType, fileType$prime, new Data_Maybe.Just(v2.name), v2.blob));
                              })())(function () {
                                  return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                                      Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Nothing.value)(v.mFile)();
                                      Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.CSV.value)(v.fileType)();
                                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Components_Lang.EN.value)(v.lang)();
                                  }))(function () {
                                      return v.dispatch(Gargantext_Components_Forest_Tree_Node_Action.ClosePopover.value);
                                  });
                              })))();
                          };
                      };
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_EqFileType_7"]))(v.fileType))(function (fileType$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "name";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "blob";
                  }))(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_EqUploadFileBlob_11"])))))(v.mFile))(function (mFile$prime) {
                      var disabled = (function () {
                          if (mFile$prime instanceof Data_Maybe.Nothing) {
                              return "1";
                          };
                          if (mFile$prime instanceof Data_Maybe.Just) {
                              return "";
                          };
                          throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Upload (line 187, column 22 - line 189, column 26): " + [ mFile$prime.constructor.name ]);
                      })();
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.button({
                          className: "btn btn-primary",
                          type: "button",
                          disabled: disabled,
                          style: {
                              width: "100%"
                          },
                          on: {
                              click: onClick(fileType$prime)(mFile$prime)
                          }
                      })([ Reactix_DOM_HTML.text("Upload") ]));
                  });
              });
          };
      };
      return here.component("uploadButton")(cpt);
  })();
  var uploadButton = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(uploadButtonCpt)(props)([  ]);
  };
  var uploadFileViewCpt = (function () {
      var renderOptionLang = function (opt) {
          return Reactix_DOM_HTML.option({})([ Reactix_DOM_HTML.text(Data_Show.show(Gargantext_Components_Lang["$_ShowLang_4"])(opt)) ]);
      };
      var renderOptionFT = function (opt) {
          return Reactix_DOM_HTML.option({})([ Reactix_DOM_HTML.text(Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_ShowFileType_8"])(opt)) ]);
      };
      var onChangeContents = function (mFile) {
          return function (e) {
              var mF = Gargantext_Utils_Reactix.inputFileNameWithBlob(0)(e);
              return function __do() {
                  React_SyntheticEvent.preventDefault(e)();
                  React_SyntheticEvent.stopPropagation(e)();
                  if (mF instanceof Data_Maybe.Nothing) {
                      return Data_Unit.unit;
                  };
                  if (mF instanceof Data_Maybe.Just) {
                      return Data_Functor["void"](Effect.functorEffect)(Effect_Aff.launchAff(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Just.create({
                          blob: mF.value0.blob,
                          name: mF.value0.name
                      }))(mFile))))();
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Upload (line 153, column 7 - line 159, column 70): " + [ mF.constructor.name ]);
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Maybe.Nothing.value))(function (mFile) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.CSV.value))(function (fileType) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_Lang.EN.value))(function (lang) {
                          var setFileType$prime = function (val) {
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(val)(fileType);
                          };
                          var setLang$prime = function (val) {
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(val)(lang);
                          };
                          var bodies = [ Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.div({
                              className: "col-12 flex-space-around"
                          })([ Reactix_DOM_HTML.div({
                              className: "form-group"
                          })([ Reactix_DOM_HTML.input({
                              type: "file",
                              className: "form-control",
                              placeholder: "Choose file",
                              on: {
                                  change: onChangeContents(mFile)
                              }
                          }) ]) ]) ]), Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.div({
                              className: "col-6 flex-space-around"
                          })([ Gargantext_Components_Forest_Tree_Node_Tools.formChoiceSafe(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_ReadFileType_9"])(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_ShowFileType_8"])([ Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.CSV.value, Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.CSV_HAL.value, Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.WOS.value, Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.PresseRIS.value, Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.Arbitrary.value ])(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.CSV.value)(setFileType$prime) ]) ]), Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.div({
                              className: "col-6 flex-space-around"
                          })([ Gargantext_Components_Forest_Tree_Node_Tools.formChoiceSafe(Gargantext_Components_Lang["$_ReadLang_6"])(Gargantext_Components_Lang["$_ShowLang_4"])([ Gargantext_Components_Lang.EN.value, Gargantext_Components_Lang.FR.value, Gargantext_Components_Lang.No_extraction.value, Gargantext_Components_Lang.Universal.value ])(Gargantext_Components_Lang.EN.value)(setLang$prime) ]) ]) ];
                          var footer = Reactix_DOM_HTML.div({})([ uploadButton({
                              dispatch: v.dispatch,
                              fileType: fileType,
                              lang: lang,
                              id: v.id,
                              mFile: mFile,
                              nodeType: v.nodeType
                          }) ]);
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel(bodies)(footer));
                      });
                  });
              });
          };
      };
      return here.component("uploadFileView")(cpt);
  })();
  var uploadFileView = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(uploadFileViewCpt)(props)([  ]);
  };
  var uploadTermButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onClick = function (mFile$prime) {
                  return function (e) {
                      var v2 = Data_Maybe.fromJust()(mFile$prime);
                      return Data_Functor["void"](Effect.functorEffect)(Effect_Aff.launchAff(Control_Bind.bind(Effect_Aff.bindAff)(v.dispatch(new Gargantext_Components_Forest_Tree_Node_Action.UploadFile(v.nodeType, Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.CSV.value, new Data_Maybe.Just(v2.name), v2.blob)))(function () {
                          return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Nothing.value)(v.mFile));
                      })));
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "name";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "blob";
              }))(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_EqUploadFileBlob_11"])))))(v.mFile))(function (mFile$prime) {
                  var disabled = (function () {
                      if (mFile$prime instanceof Data_Maybe.Nothing) {
                          return "1";
                      };
                      if (mFile$prime instanceof Data_Maybe.Just) {
                          return "";
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Upload (line 421, column 23 - line 423, column 27): " + [ mFile$prime.constructor.name ]);
                  })();
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.button({
                      className: "btn btn-primary",
                      disabled: disabled,
                      on: {
                          click: onClick(mFile$prime)
                      }
                  })([ Reactix_DOM_HTML.text("Upload") ]));
              });
          };
      };
      return here.component("uploadTermButton")(cpt);
  })();
  var uploadTermButton = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(uploadTermButtonCpt)(props)([  ]);
  };
  var uploadTermListViewCpt = (function () {
      var onChangeContents = function (mFile) {
          return function (e) {
              var mF = Gargantext_Utils_Reactix.inputFileNameWithBlob(0)(e);
              return function __do() {
                  React_SyntheticEvent.preventDefault(e)();
                  React_SyntheticEvent.stopPropagation(e)();
                  if (mF instanceof Data_Maybe.Nothing) {
                      return Data_Unit.unit;
                  };
                  if (mF instanceof Data_Maybe.Just) {
                      return Data_Functor["void"](Effect.functorEffect)(Effect_Aff.launchAff(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Just.create({
                          blob: mF.value0.blob,
                          name: mF.value0.name
                      }))(mFile))))();
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Upload (line 393, column 7 - line 399, column 45): " + [ mF.constructor.name ]);
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Maybe.Nothing.value))(function (mFile) {
                  var body = Reactix_DOM_HTML.input({
                      type: "file",
                      placeholder: "Choose file",
                      on: {
                          change: onChangeContents(mFile)
                      }
                  });
                  var footer = Reactix_DOM_HTML.div({})([ uploadTermButton({
                      dispatch: v.dispatch,
                      id: v.id,
                      mFile: mFile,
                      nodeType: v.nodeType
                  }) ]);
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ body ])(footer));
              });
          };
      };
      return here.component("uploadTermListView")(cpt);
  })();
  var uploadTermListView = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(uploadTermListViewCpt)(props)([  ]);
  };
  var actionUploadOtherCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.fragmentPT("Soon, upload for this NodeType."));
          };
      };
      return here.component("actionUploadOther")(cpt);
  })();
  var actionUploadOther = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionUploadOtherCpt);
  var actionUploadCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              if (v.nodeType instanceof Gargantext_Types.Corpus) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(uploadFileView({
                      dispatch: v.dispatch,
                      id: v.id,
                      nodeType: Gargantext_Types.Corpus.value,
                      session: v.session
                  }));
              };
              if (v.nodeType instanceof Gargantext_Types.NodeList) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(uploadTermListView({
                      dispatch: v.dispatch,
                      id: v.id,
                      nodeType: Gargantext_Types.NodeList.value,
                      session: v.session
                  }));
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(actionUploadOther(v)([  ]));
          };
      };
      return here.component("actionUpload")(cpt);
  })();
  var actionUpload = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionUploadCpt);
  var $dollar_GenericDroppedFile__24 = new Data_Generic_Rep.Generic(function (x) {
      return x.value0;
  }, function (x) {
      return new DroppedFile(x);
  });
  var $dollar_EqDroppedFile_25 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericDroppedFile__24)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "lang";
  }))(Gargantext_Components_Lang["$_EqLang_5"]))()(new Data_Symbol.IsSymbol(function () {
      return "fileType";
  }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_EqFileType_7"])))()(new Data_Symbol.IsSymbol(function () {
      return "blob";
  }))(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_EqUploadFileBlob_11"]))))));
  var fileTypeViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var tooltipProps = {
                  className: "",
                  id: "file-type-tooltip",
                  title: "Choose file type",
                  data: {
                      toggle: "tooltip",
                      placement: "right"
                  }
              };
              var panelHeading = Reactix_DOM_HTML.div({
                  className: "card-header"
              })([ Reactix_DOM_HTML.div({
                  className: "row"
              })([ Reactix_DOM_HTML.div({
                  className: "col-md-10"
              })([ Reactix_DOM_HTML.h5({})([ Reactix_DOM_HTML.text("Choose file type") ]) ]), Reactix_DOM_HTML.div({
                  className: "col-md-2"
              })([ Reactix_DOM_HTML.a({
                  className: "btn glyphitem fa fa-remove-circle",
                  on: {
                      click: function (v2) {
                          return function __do() {
                              Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Nothing.value)(v.droppedFile)();
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(false)(v.isDragOver)();
                          };
                      }
                  },
                  title: "Close"
              })([  ]) ]) ]) ]);
              var panelFooter = function (v2) {
                  return Reactix_DOM_HTML.div({
                      className: "card-footer"
                  })([ (function () {
                      if (v2.value0.fileType instanceof Data_Maybe.Just) {
                          return Reactix_DOM_HTML.button({
                              className: "btn btn-success",
                              type: "button",
                              on: {
                                  click: function (v3) {
                                      return function __do() {
                                          Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Nothing.value)(v.droppedFile)();
                                          return Effect_Aff.launchAff(v.dispatch(new Gargantext_Components_Forest_Tree_Node_Action.UploadFile(v.nodeType, v2.value0.fileType.value0, Data_Maybe.Nothing.value, v2.value0.blob)))();
                                      };
                                  }
                              }
                          })([ Reactix_DOM_HTML.text("Upload") ]);
                      };
                      if (v2.value0.fileType instanceof Data_Maybe.Nothing) {
                          return Reactix_DOM_HTML.button({
                              className: "btn btn-success disabled",
                              type: "button"
                          })([ Reactix_DOM_HTML.text("Upload") ]);
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Upload (line 286, column 13 - line 298, column 45): " + [ v2.value0.fileType.constructor.name ]);
                  })() ]);
              };
              var panelBody = function (v2) {
                  var renderOption = function (opt) {
                      return Reactix_DOM_HTML.option({})([ Reactix_DOM_HTML.text(Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_ShowFileType_8"])(opt)) ]);
                  };
                  var onChange = function (blob1) {
                      return function (e) {
                          return function (l) {
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Just.create(DroppedFile.create({
                                  blob: blob1,
                                  fileType: Gargantext_Prelude.read(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types["$_ReadFileType_9"])(Reactix_SyntheticEvent.unsafeEventValue(e)),
                                  lang: Data_Maybe.fromMaybe(Gargantext_Components_Lang.EN.value)(Gargantext_Prelude.read(Gargantext_Components_Lang["$_ReadLang_6"])(Reactix_SyntheticEvent.unsafeEventValue(l)))
                              })))(v.droppedFile);
                          };
                      };
                  };
                  return Reactix_DOM_HTML.div({
                      className: "card-body"
                  })([ Gargantext_Utils_Reactix.select({
                      className: "col-md-12 form-control",
                      on: {
                          change: onChange(v2.value0.blob)
                      }
                  })(Data_Functor.map(Data_Functor.functorArray)(renderOption)([ Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.CSV.value, Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.CSV_HAL.value, Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.WOS.value ])) ]);
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe($dollar_EqDroppedFile_25)))(v.droppedFile))(function (droppedFile$prime) {
                  if (droppedFile$prime instanceof Data_Maybe.Nothing) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
                  };
                  if (droppedFile$prime instanceof Data_Maybe.Just) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div(tooltipProps)([ Reactix_DOM_HTML.div({
                          className: "card"
                      })([ panelHeading, panelBody(droppedFile$prime.value0), panelFooter(droppedFile$prime.value0) ]) ]));
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Upload (line 235, column 7 - line 243, column 38): " + [ droppedFile$prime.constructor.name ]);
              });
          };
      };
      return here.component("fileTypeView")(cpt);
  })();
  var fileTypeView = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(fileTypeViewCpt)(p)([  ]);
  };
  exports["actionUpload"] = actionUpload;
  exports["DroppedFile"] = DroppedFile;
  exports["fileTypeView"] = fileTypeView;
  exports["uploadFile"] = uploadFile;
  exports["uploadArbitraryFile"] = uploadArbitraryFile;
  exports["uploadArbitraryDataURL"] = uploadArbitraryDataURL;
  exports["$_EqDroppedFile_25"] = $dollar_EqDroppedFile_25;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Documentation"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Documentation"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Documentation"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Documentation");
  var docOf = function (v) {
      if (v instanceof Gargantext_Types.NodeUser) {
          return [ "This account is personal", "See the instances terms of uses." ];
      };
      if (v instanceof Gargantext_Types.FolderPrivate) {
          return [ "This folder and its children are private only." ];
      };
      if (v instanceof Gargantext_Types.FolderPublic) {
          return [ "Soon, you will be able to build public folders to share your work with the world!" ];
      };
      if (v instanceof Gargantext_Types.FolderShared) {
          return [ "Soon, you will be able to build teams folders to share your work" ];
      };
      return [ "More information on " + Data_Show.show(Gargantext_Types["$_ShowNodeType_117"])(v) ];
  };
  var actionDocCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var infoTitle = function (nt) {
                  return Reactix_DOM_HTML.div({
                      style: {
                          margin: "10px"
                      }
                  })([ Reactix_DOM_HTML.h3({})([ Reactix_DOM_HTML.text("Documentation about ") ]), Reactix_DOM_HTML.h3({
                      className: Gargantext_Types.fldr(nt)(true)
                  })([ Reactix_DOM_HTML.text(Data_Show.show(Gargantext_Types["$_ShowNodeType_117"])(nt)) ]) ]);
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ infoTitle(v.nodeType) ])(Data_Functor.map(Data_Functor.functorArray)(function (info) {
                  return Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.text(info) ]);
              })(docOf(v.nodeType))))(Reactix_DOM_HTML.div({})([  ])));
          };
      };
      return here.component("actionDoc")(cpt);
  })();
  var actionDoc = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionDocCpt);
  exports["actionDoc"] = actionDoc;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Download"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Download"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Download"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Documentation");
  var actionDownloadOtherCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.fragmentPT("Soon, you will be able to download your file here "));
          };
      };
      return here.component("actionDownloadOther")(cpt);
  })();
  var actionDownloadOther = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionDownloadOtherCpt);
  var actionDownloadNodeListCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var href = Gargantext_Ends.url(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.NodeList.value, new Data_Maybe.Just(v.id), ""));
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.text("Info about the List as JSON format") ]) ])(Gargantext_Components_Forest_Tree_Node_Tools.submitButtonHref(Gargantext_Components_Forest_Tree_Node_Action.DownloadNode.value)(href)));
          };
      };
      return here.component("actionDownloadNodeList")(cpt);
  })();
  var actionDownloadNodeList = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionDownloadNodeListCpt);
  var actionDownloadGraphCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var href = Gargantext_Ends.url(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Graph.value, new Data_Maybe.Just(v.id), "gexf"));
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.text("Info about the Graph as GEXF format") ]) ])(Gargantext_Components_Forest_Tree_Node_Tools.submitButtonHref(Gargantext_Components_Forest_Tree_Node_Action.DownloadNode.value)(href)));
          };
      };
      return here.component("actionDownloadGraph")(cpt);
  })();
  var actionDownloadGraph = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionDownloadGraphCpt);
  var actionDownloadCorpusCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var href = Gargantext_Ends.url(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Corpus.value, new Data_Maybe.Just(v.id), "export"));
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.panel([ Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.text("Download as JSON") ]) ])(Gargantext_Components_Forest_Tree_Node_Tools.submitButtonHref(Gargantext_Components_Forest_Tree_Node_Action.DownloadNode.value)(href)));
          };
      };
      return here.component("actionDownloadCorpus")(cpt);
  })();
  var actionDownloadCorpus = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionDownloadCorpusCpt);
  var actionDownloadCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              if (v.nodeType instanceof Gargantext_Types.Corpus) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(actionDownloadCorpus(v)([  ]));
              };
              if (v.nodeType instanceof Gargantext_Types.Graph) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(actionDownloadGraph(v)([  ]));
              };
              if (v.nodeType instanceof Gargantext_Types.NodeList) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(actionDownloadNodeList(v)([  ]));
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(actionDownloadOther(v)([  ]));
          };
      };
      return here.component("actionDownload")(cpt);
  })();
  var actionDownload = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionDownloadCpt);
  exports["actionDownload"] = actionDownload;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.Types"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.Types"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.Types"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ordering = $PS["Data.Ordering"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Set = $PS["Data.Set"];
  var Data_Show = $PS["Data.Show"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_Lang = $PS["Gargantext.Components.Lang"];
  var Gargantext_Prelude = $PS["Gargantext.Prelude"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Simple_JSON = $PS["Simple.JSON"];
  var All_IMT = (function () {
      function All_IMT() {

      };
      All_IMT.value = new All_IMT();
      return All_IMT;
  })();
  var ARMINES = (function () {
      function ARMINES() {

      };
      ARMINES.value = new ARMINES();
      return ARMINES;
  })();
  var Eurecom = (function () {
      function Eurecom() {

      };
      Eurecom.value = new Eurecom();
      return Eurecom;
  })();
  var IMT_Atlantique = (function () {
      function IMT_Atlantique() {

      };
      IMT_Atlantique.value = new IMT_Atlantique();
      return IMT_Atlantique;
  })();
  var IMT_Business_School = (function () {
      function IMT_Business_School() {

      };
      IMT_Business_School.value = new IMT_Business_School();
      return IMT_Business_School;
  })();
  var IMT_Lille_Douai = (function () {
      function IMT_Lille_Douai() {

      };
      IMT_Lille_Douai.value = new IMT_Lille_Douai();
      return IMT_Lille_Douai;
  })();
  var IMT_Mines_ALES = (function () {
      function IMT_Mines_ALES() {

      };
      IMT_Mines_ALES.value = new IMT_Mines_ALES();
      return IMT_Mines_ALES;
  })();
  var IMT_Mines_Albi = (function () {
      function IMT_Mines_Albi() {

      };
      IMT_Mines_Albi.value = new IMT_Mines_Albi();
      return IMT_Mines_Albi;
  })();
  var Institut_MinesTelecom_Paris = (function () {
      function Institut_MinesTelecom_Paris() {

      };
      Institut_MinesTelecom_Paris.value = new Institut_MinesTelecom_Paris();
      return Institut_MinesTelecom_Paris;
  })();
  var MINES_ParisTech = (function () {
      function MINES_ParisTech() {

      };
      MINES_ParisTech.value = new MINES_ParisTech();
      return MINES_ParisTech;
  })();
  var Mines_Douai = (function () {
      function Mines_Douai() {

      };
      Mines_Douai.value = new Mines_Douai();
      return Mines_Douai;
  })();
  var Mines_Nantes = (function () {
      function Mines_Nantes() {

      };
      Mines_Nantes.value = new Mines_Nantes();
      return Mines_Nantes;
  })();
  var Mines_SaintEtienne = (function () {
      function Mines_SaintEtienne() {

      };
      Mines_SaintEtienne.value = new Mines_SaintEtienne();
      return Mines_SaintEtienne;
  })();
  var Telecom_Bretagne = (function () {
      function Telecom_Bretagne() {

      };
      Telecom_Bretagne.value = new Telecom_Bretagne();
      return Telecom_Bretagne;
  })();
  var Telecom_Ecole_de_Management = (function () {
      function Telecom_Ecole_de_Management() {

      };
      Telecom_Ecole_de_Management.value = new Telecom_Ecole_de_Management();
      return Telecom_Ecole_de_Management;
  })();
  var Telecom_Lille = (function () {
      function Telecom_Lille() {

      };
      Telecom_Lille.value = new Telecom_Lille();
      return Telecom_Lille;
  })();
  var Telecom_ParisTech = (function () {
      function Telecom_ParisTech() {

      };
      Telecom_ParisTech.value = new Telecom_ParisTech();
      return Telecom_ParisTech;
  })();
  var Telecom_SudParis = (function () {
      function Telecom_SudParis() {

      };
      Telecom_SudParis.value = new Telecom_SudParis();
      return Telecom_SudParis;
  })();
  var All_Orgs = (function () {
      function All_Orgs() {

      };
      All_Orgs.value = new All_Orgs();
      return All_Orgs;
  })();
  var CNRS = (function () {
      function CNRS(value0) {
          this.value0 = value0;
      };
      CNRS.create = function (value0) {
          return new CNRS(value0);
      };
      return CNRS;
  })();
  var Others = (function () {
      function Others(value0) {
          this.value0 = value0;
      };
      Others.create = function (value0) {
          return new Others(value0);
      };
      return Others;
  })();
  var IMT = (function () {
      function IMT(value0) {
          this.value0 = value0;
      };
      IMT.create = function (value0) {
          return new IMT(value0);
      };
      return IMT;
  })();
  var Doc = function (doc) {
      this.doc = doc;
  };
  var All_Databases = (function () {
      function All_Databases() {

      };
      All_Databases.value = new All_Databases();
      return All_Databases;
  })();
  var Empty = (function () {
      function Empty() {

      };
      Empty.value = new Empty();
      return Empty;
  })();
  var PubMed = (function () {
      function PubMed() {

      };
      PubMed.value = new PubMed();
      return PubMed;
  })();
  var HAL = (function () {
      function HAL(value0) {
          this.value0 = value0;
      };
      HAL.create = function (value0) {
          return new HAL(value0);
      };
      return HAL;
  })();
  var IsTex = (function () {
      function IsTex() {

      };
      IsTex.value = new IsTex();
      return IsTex;
  })();
  var IsTex_Advanced = (function () {
      function IsTex_Advanced() {

      };
      IsTex_Advanced.value = new IsTex_Advanced();
      return IsTex_Advanced;
  })();
  var Isidore = (function () {
      function Isidore() {

      };
      Isidore.value = new Isidore();
      return Isidore;
  })();
  var Gargantext = (function () {
      function Gargantext() {

      };
      Gargantext.value = new Gargantext();
      return Gargantext;
  })();
  var External = (function () {
      function External(value0) {
          this.value0 = value0;
      };
      External.create = function (value0) {
          return new External(value0);
      };
      return External;
  })();
  var Web = (function () {
      function Web() {

      };
      Web.value = new Web();
      return Web;
  })();
  var Files = (function () {
      function Files() {

      };
      Files.value = new Files();
      return Files;
  })();
  var SearchQuery = function (x) {
      return x;
  };
  var isIsTex_Advanced = function (v) {
      if (v instanceof Data_Maybe.Just && (v.value0 instanceof External && (v.value0.value0 instanceof Data_Maybe.Just && v.value0.value0.value0 instanceof IsTex_Advanced))) {
          return true;
      };
      return false;
  };
  var doc = function (dict) {
      return dict.doc;
  };
  var defaultSearchQuery = {
      query: "",
      databases: Empty.value,
      datafield: Data_Maybe.Nothing.value,
      files_id: [  ],
      lang: Data_Maybe.Nothing.value,
      limit: Data_Maybe.Nothing.value,
      node_id: Data_Maybe.Nothing.value,
      offset: Data_Maybe.Nothing.value,
      order: Data_Maybe.Nothing.value
  };
  var datafield2database = function (v) {
      if (v instanceof External && v.value0 instanceof Data_Maybe.Just) {
          return v.value0.value0;
      };
      return Empty.value;
  };
  var dataFields = [ Gargantext.value, new External(Data_Maybe.Nothing.value), Web.value ];
  var allIMTSubOrgs = [ ARMINES.value, Eurecom.value, IMT_Atlantique.value, IMT_Business_School.value, IMT_Lille_Douai.value, IMT_Mines_ALES.value, IMT_Mines_Albi.value, Institut_MinesTelecom_Paris.value, MINES_ParisTech.value, Mines_Douai.value, Mines_Nantes.value, Mines_SaintEtienne.value, Telecom_Bretagne.value, Telecom_Ecole_de_Management.value, Telecom_Lille.value, Telecom_ParisTech.value, Telecom_SudParis.value ];
  var allIMTorgs = Data_Semigroup.append(Data_Semigroup.semigroupArray)([ All_IMT.value ])(allIMTSubOrgs);
  var allDatabases = [ Empty.value, PubMed.value, new HAL(Data_Maybe.Nothing.value), IsTex.value, IsTex_Advanced.value, Isidore.value ];
  var $dollar_ShowOrg_75 = new Data_Show.Show(function (v) {
      if (v instanceof All_Orgs) {
          return "All_Orgs";
      };
      if (v instanceof CNRS) {
          return "CNRS";
      };
      if (v instanceof IMT) {
          return "IMT";
      };
      if (v instanceof Others) {
          return "Others";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Search.Types (line 179, column 1 - line 183, column 29): " + [ v.constructor.name ]);
  });   
  var $dollar_ShowIMT_org_81 = new Data_Show.Show(function (v) {
      if (v instanceof All_IMT) {
          return "All_IMT";
      };
      if (v instanceof ARMINES) {
          return "ARMINES";
      };
      if (v instanceof Eurecom) {
          return "Eurecom";
      };
      if (v instanceof IMT_Atlantique) {
          return "IMT_Atlantique";
      };
      if (v instanceof IMT_Business_School) {
          return "IMT_Business_School";
      };
      if (v instanceof IMT_Lille_Douai) {
          return "IMT_Lille_Douai";
      };
      if (v instanceof IMT_Mines_ALES) {
          return "IMT_Mines_ALES";
      };
      if (v instanceof IMT_Mines_Albi) {
          return "IMT_Mines_Albi";
      };
      if (v instanceof Institut_MinesTelecom_Paris) {
          return "Institut_MinesTelecom_Paris";
      };
      if (v instanceof MINES_ParisTech) {
          return "MINES_ParisTech";
      };
      if (v instanceof Mines_Douai) {
          return "Mines_Douai";
      };
      if (v instanceof Mines_Nantes) {
          return "Mines_Nantes";
      };
      if (v instanceof Mines_SaintEtienne) {
          return "Mines_SaintEtienne";
      };
      if (v instanceof Telecom_Bretagne) {
          return "Telecom_Bretagne";
      };
      if (v instanceof Telecom_Ecole_de_Management) {
          return "Telecom_Ecole_de_Management";
      };
      if (v instanceof Telecom_Lille) {
          return "Telecom_Lille";
      };
      if (v instanceof Telecom_ParisTech) {
          return "Telecom_ParisTech";
      };
      if (v instanceof Telecom_SudParis) {
          return "Telecom_SudParis";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Search.Types (line 241, column 1 - line 259, column 48): " + [ v.constructor.name ]);
  });
  var $dollar_ShowDatabase_69 = new Data_Show.Show(function (v) {
      if (v instanceof All_Databases) {
          return "All Databases";
      };
      if (v instanceof PubMed) {
          return "PubMed";
      };
      if (v instanceof HAL) {
          return "HAL";
      };
      if (v instanceof IsTex) {
          return "IsTex";
      };
      if (v instanceof IsTex_Advanced) {
          return "IsTex_Advanced";
      };
      if (v instanceof Isidore) {
          return "Isidore";
      };
      if (v instanceof Empty) {
          return "Empty";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Search.Types (line 125, column 1 - line 132, column 24): " + [ v.constructor.name ]);
  });
  var $dollar_WriteForeignDatabase_73 = new Simple_JSON.WriteForeign((function () {
      var $235 = Simple_JSON.writeImpl(Simple_JSON.writeForeignString);
      var $236 = Data_Show.show($dollar_ShowDatabase_69);
      return function ($237) {
          return $235($236($237));
      };
  })());
  var $dollar_WriteForeignSearchQuery_88 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "databases";
      }))($dollar_WriteForeignDatabase_73)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "lang";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "node_id";
      }))(Simple_JSON.writeForeignInt)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "query";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()()))({
          query: Data_String_Common.replace("\"")("\\\"")(v.query),
          databases: v.databases,
          lang: Data_Maybe.maybe("EN")(Data_Show.show(Gargantext_Components_Lang["$_ShowLang_4"]))(v.lang),
          node_id: Data_Maybe.fromMaybe(0)(v.node_id)
      });
  });
  var performSearch = function (session) {
      return function (nodeId) {
          return function (q) {
              var p = Gargantext_Routes.NodeAPI.create(Gargantext_Types.Corpus.value)(new Data_Maybe.Just(nodeId))(Gargantext_Types.asyncTaskTypePath(Gargantext_Types.Query.value));
              return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.post($dollar_WriteForeignSearchQuery_88)(Gargantext_Types["$_ReadForeignAsyncTask_167"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(p)(q))(function (task) {
                  return Control_Applicative.pure(Effect_Aff.applicativeAff)({
                      task: task,
                      typ: Gargantext_Types.Query.value
                  });
              });
          };
      };
  }; 
  var $dollar_ShowDataField_60 = new Data_Show.Show(function (v) {
      if (v instanceof Gargantext) {
          return "Gargantext";
      };
      if (v instanceof External) {
          return "Databases (APIs)";
      };
      if (v instanceof Web) {
          return "Soon: web";
      };
      if (v instanceof Files) {
          return "Files";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Search.Types (line 64, column 1 - line 68, column 30): " + [ v.constructor.name ]);
  });
  var $dollar_ReadDatabase_71 = new Gargantext_Prelude.Read(function (v) {
      if (v === "All Databases") {
          return new Data_Maybe.Just(All_Databases.value);
      };
      if (v === "PubMed") {
          return new Data_Maybe.Just(PubMed.value);
      };
      if (v === "HAL") {
          return Data_Maybe.Just.create(new HAL(Data_Maybe.Nothing.value));
      };
      if (v === "Isidore") {
          return new Data_Maybe.Just(Isidore.value);
      };
      if (v === "IsTex") {
          return new Data_Maybe.Just(IsTex.value);
      };
      if (v === "IsTex_Advanced") {
          return new Data_Maybe.Just(IsTex_Advanced.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var $dollar_EqIMT_org_80 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof All_IMT && y instanceof All_IMT) {
              return true;
          };
          if (x instanceof ARMINES && y instanceof ARMINES) {
              return true;
          };
          if (x instanceof Eurecom && y instanceof Eurecom) {
              return true;
          };
          if (x instanceof IMT_Atlantique && y instanceof IMT_Atlantique) {
              return true;
          };
          if (x instanceof IMT_Business_School && y instanceof IMT_Business_School) {
              return true;
          };
          if (x instanceof IMT_Lille_Douai && y instanceof IMT_Lille_Douai) {
              return true;
          };
          if (x instanceof IMT_Mines_ALES && y instanceof IMT_Mines_ALES) {
              return true;
          };
          if (x instanceof IMT_Mines_Albi && y instanceof IMT_Mines_Albi) {
              return true;
          };
          if (x instanceof Institut_MinesTelecom_Paris && y instanceof Institut_MinesTelecom_Paris) {
              return true;
          };
          if (x instanceof MINES_ParisTech && y instanceof MINES_ParisTech) {
              return true;
          };
          if (x instanceof Mines_Douai && y instanceof Mines_Douai) {
              return true;
          };
          if (x instanceof Mines_Nantes && y instanceof Mines_Nantes) {
              return true;
          };
          if (x instanceof Mines_SaintEtienne && y instanceof Mines_SaintEtienne) {
              return true;
          };
          if (x instanceof Telecom_Bretagne && y instanceof Telecom_Bretagne) {
              return true;
          };
          if (x instanceof Telecom_Ecole_de_Management && y instanceof Telecom_Ecole_de_Management) {
              return true;
          };
          if (x instanceof Telecom_Lille && y instanceof Telecom_Lille) {
              return true;
          };
          if (x instanceof Telecom_ParisTech && y instanceof Telecom_ParisTech) {
              return true;
          };
          if (x instanceof Telecom_SudParis && y instanceof Telecom_SudParis) {
              return true;
          };
          return false;
      };
  });
  var $dollar_EqOrg_77 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof All_Orgs && y instanceof All_Orgs) {
              return true;
          };
          if (x instanceof CNRS && y instanceof CNRS) {
              return Data_Eq.eq(Data_Set.eqSet(Data_Eq.eqInt))(x.value0)(y.value0);
          };
          if (x instanceof Others && y instanceof Others) {
              return Data_Eq.eq(Data_Set.eqSet(Data_Eq.eqInt))(x.value0)(y.value0);
          };
          if (x instanceof IMT && y instanceof IMT) {
              return Data_Eq.eq(Data_Set.eqSet($dollar_EqIMT_org_80))(x.value0)(y.value0);
          };
          return false;
      };
  });
  var $dollar_OrdIMT_org_79 = new Data_Ord.Ord(function () {
      return $dollar_EqIMT_org_80;
  }, function (x) {
      return function (y) {
          if (x instanceof All_IMT && y instanceof All_IMT) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof All_IMT) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof All_IMT) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof ARMINES && y instanceof ARMINES) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof ARMINES) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof ARMINES) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof Eurecom && y instanceof Eurecom) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof Eurecom) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof Eurecom) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof IMT_Atlantique && y instanceof IMT_Atlantique) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof IMT_Atlantique) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof IMT_Atlantique) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof IMT_Business_School && y instanceof IMT_Business_School) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof IMT_Business_School) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof IMT_Business_School) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof IMT_Lille_Douai && y instanceof IMT_Lille_Douai) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof IMT_Lille_Douai) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof IMT_Lille_Douai) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof IMT_Mines_ALES && y instanceof IMT_Mines_ALES) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof IMT_Mines_ALES) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof IMT_Mines_ALES) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof IMT_Mines_Albi && y instanceof IMT_Mines_Albi) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof IMT_Mines_Albi) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof IMT_Mines_Albi) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof Institut_MinesTelecom_Paris && y instanceof Institut_MinesTelecom_Paris) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof Institut_MinesTelecom_Paris) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof Institut_MinesTelecom_Paris) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof MINES_ParisTech && y instanceof MINES_ParisTech) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof MINES_ParisTech) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof MINES_ParisTech) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof Mines_Douai && y instanceof Mines_Douai) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof Mines_Douai) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof Mines_Douai) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof Mines_Nantes && y instanceof Mines_Nantes) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof Mines_Nantes) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof Mines_Nantes) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof Mines_SaintEtienne && y instanceof Mines_SaintEtienne) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof Mines_SaintEtienne) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof Mines_SaintEtienne) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof Telecom_Bretagne && y instanceof Telecom_Bretagne) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof Telecom_Bretagne) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof Telecom_Bretagne) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof Telecom_Ecole_de_Management && y instanceof Telecom_Ecole_de_Management) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof Telecom_Ecole_de_Management) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof Telecom_Ecole_de_Management) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof Telecom_Lille && y instanceof Telecom_Lille) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof Telecom_Lille) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof Telecom_Lille) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof Telecom_ParisTech && y instanceof Telecom_ParisTech) {
              return Data_Ordering.EQ.value;
          };
          if (x instanceof Telecom_ParisTech) {
              return Data_Ordering.LT.value;
          };
          if (y instanceof Telecom_ParisTech) {
              return Data_Ordering.GT.value;
          };
          if (x instanceof Telecom_SudParis && y instanceof Telecom_SudParis) {
              return Data_Ordering.EQ.value;
          };
          throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Search.Types (line 238, column 1 - line 238, column 28): " + [ x.constructor.name, y.constructor.name ]);
      };
  });
  var $dollar_ReadOrg_76 = new Gargantext_Prelude.Read(function (v) {
      if (v === "All_Orgs") {
          return Data_Maybe.Just.create(All_Orgs.value);
      };
      if (v === "CNRS") {
          return Data_Maybe.Just.create(CNRS.create(Data_Set.fromFoldable(Data_Foldable.foldableArray)(Data_Ord.ordInt)([  ])));
      };
      if (v === "IMT") {
          return Data_Maybe.Just.create(IMT.create(Data_Set.fromFoldable(Data_Foldable.foldableArray)($dollar_OrdIMT_org_79)([  ])));
      };
      if (v === "Others") {
          return Data_Maybe.Just.create(Others.create(Data_Set.fromFoldable(Data_Foldable.foldableArray)(Data_Ord.ordInt)([  ])));
      };
      return Data_Maybe.Nothing.value;
  });
  var allOrgs = [ All_Orgs.value, IMT.create(Data_Set.fromFoldable(Data_Foldable.foldableArray)($dollar_OrdIMT_org_79)([  ])), CNRS.create(Data_Set.fromFoldable(Data_Foldable.foldableArray)(Data_Ord.ordInt)([  ])) ];
  var $dollar_EqDatabase_72 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof All_Databases && y instanceof All_Databases) {
              return true;
          };
          if (x instanceof Empty && y instanceof Empty) {
              return true;
          };
          if (x instanceof PubMed && y instanceof PubMed) {
              return true;
          };
          if (x instanceof HAL && y instanceof HAL) {
              return Data_Eq.eq(Data_Maybe.eqMaybe($dollar_EqOrg_77))(x.value0)(y.value0);
          };
          if (x instanceof IsTex && y instanceof IsTex) {
              return true;
          };
          if (x instanceof IsTex_Advanced && y instanceof IsTex_Advanced) {
              return true;
          };
          if (x instanceof Isidore && y instanceof Isidore) {
              return true;
          };
          return false;
      };
  });
  var $dollar_EqDataField_62 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof Gargantext && y instanceof Gargantext) {
              return true;
          };
          if (x instanceof External && y instanceof External) {
              return Data_Eq.eq(Data_Maybe.eqMaybe($dollar_EqDatabase_72))(x.value0)(y.value0);
          };
          if (x instanceof Web && y instanceof Web) {
              return true;
          };
          if (x instanceof Files && y instanceof Files) {
              return true;
          };
          return false;
      };
  });
  var $dollar_DocDatabase_70 = new Doc(function (v) {
      if (v instanceof All_Databases) {
          return "All databases";
      };
      if (v instanceof PubMed) {
          return "All Medical publications";
      };
      if (v instanceof HAL) {
          return "All open science (archives ouvertes)";
      };
      if (v instanceof IsTex) {
          return "All Elsevier enriched by CNRS/INIST";
      };
      if (v instanceof IsTex_Advanced) {
          return "IsTex advanced search";
      };
      if (v instanceof Isidore) {
          return "All (French) Social Sciences";
      };
      if (v instanceof Empty) {
          return "Empty";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Search.Types (line 136, column 1 - line 143, column 28): " + [ v.constructor.name ]);
  });
  var $dollar_DocDataField_61 = new Doc(function (v) {
      if (v instanceof Gargantext) {
          return "All Gargantext Database";
      };
      if (v instanceof External) {
          return "External (scientific) databases";
      };
      if (v instanceof Web) {
          return "All the web crawled with meta-search-engine SearX";
      };
      if (v instanceof Files) {
          return "Zip files with formats..";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Search.Types (line 69, column 1 - line 73, column 48): " + [ v.constructor.name ]);
  });
  exports["doc"] = doc;
  exports["isIsTex_Advanced"] = isIsTex_Advanced;
  exports["dataFields"] = dataFields;
  exports["Gargantext"] = Gargantext;
  exports["External"] = External;
  exports["Web"] = Web;
  exports["datafield2database"] = datafield2database;
  exports["allDatabases"] = allDatabases;
  exports["Empty"] = Empty;
  exports["HAL"] = HAL;
  exports["allOrgs"] = allOrgs;
  exports["CNRS"] = CNRS;
  exports["IMT"] = IMT;
  exports["allIMTorgs"] = allIMTorgs;
  exports["All_IMT"] = All_IMT;
  exports["SearchQuery"] = SearchQuery;
  exports["defaultSearchQuery"] = defaultSearchQuery;
  exports["performSearch"] = performSearch;
  exports["$_ShowDataField_60"] = $dollar_ShowDataField_60;
  exports["$_DocDataField_61"] = $dollar_DocDataField_61;
  exports["$_EqDataField_62"] = $dollar_EqDataField_62;
  exports["$_ShowDatabase_69"] = $dollar_ShowDatabase_69;
  exports["$_DocDatabase_70"] = $dollar_DocDatabase_70;
  exports["$_ReadDatabase_71"] = $dollar_ReadDatabase_71;
  exports["$_EqDatabase_72"] = $dollar_EqDatabase_72;
  exports["$_ShowOrg_75"] = $dollar_ShowOrg_75;
  exports["$_ReadOrg_76"] = $dollar_ReadOrg_76;
  exports["$_OrdIMT_org_79"] = $dollar_OrdIMT_org_79;
  exports["$_EqIMT_org_80"] = $dollar_EqIMT_org_80;
  exports["$_ShowIMT_org_81"] = $dollar_ShowIMT_org_81;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Parsing.Parser.Pos"] = $PS["Text.Parsing.Parser.Pos"] || {};
  var exports = $PS["Text.Parsing.Parser.Pos"];
  var Data_EuclideanRing = $PS["Data.EuclideanRing"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Newtype = $PS["Data.Newtype"];
  var Data_String_Common = $PS["Data.String.Common"];
  var updatePosString = function (pos$prime) {
      return function (str) {
          var updatePosChar = function (v) {
              return function (c) {
                  if (c === "\x0a") {
                      return {
                          line: v.line + 1 | 0,
                          column: 1
                      };
                  };
                  if (c === "\x0d") {
                      return {
                          line: v.line + 1 | 0,
                          column: 1
                      };
                  };
                  if (c === "\x09") {
                      return {
                          line: v.line,
                          column: (v.column + 8 | 0) - Data_EuclideanRing.mod(Data_EuclideanRing.euclideanRingInt)(v.column - 1 | 0)(8) | 0
                      };
                  };
                  return {
                      line: v.line,
                      column: v.column + 1 | 0
                  };
              };
          };
          return Data_Foldable.foldl(Data_Foldable.foldableArray)(updatePosChar)(pos$prime)(Data_String_Common.split(Data_Newtype.wrap()(""))(str));
      };
  }; 
  var initialPos = {
      line: 1,
      column: 1
  };
  exports["initialPos"] = initialPos;
  exports["updatePosString"] = updatePosString;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Parsing.Parser"] = $PS["Text.Parsing.Parser"] || {};
  var exports = $PS["Text.Parsing.Parser"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Alternative = $PS["Control.Alternative"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Lazy = $PS["Control.Lazy"];
  var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Control_Monad_State_Class = $PS["Control.Monad.State.Class"];
  var Control_Monad_State_Trans = $PS["Control.Monad.State.Trans"];
  var Control_Plus = $PS["Control.Plus"];
  var Data_Either = $PS["Data.Either"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Newtype = $PS["Data.Newtype"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Text_Parsing_Parser_Pos = $PS["Text.Parsing.Parser.Pos"];                
  var ParseState = (function () {
      function ParseState(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      ParseState.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new ParseState(value0, value1, value2);
              };
          };
      };
      return ParseState;
  })();
  var ParseError = (function () {
      function ParseError(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      ParseError.create = function (value0) {
          return function (value1) {
              return new ParseError(value0, value1);
          };
      };
      return ParseError;
  })();
  var ParserT = function (x) {
      return x;
  };
  var parseErrorMessage = function (v) {
      return v.value0;
  }; 
  var runParserT = function (dictMonad) {
      return function (s) {
          return function (p) {
              var initialState = new ParseState(s, Text_Parsing_Parser_Pos.initialPos, false);
              return Control_Monad_State_Trans.evalStateT(((dictMonad.Bind1()).Apply0()).Functor0())(Control_Monad_Except_Trans.runExceptT(Data_Newtype.unwrap()(p)))(initialState);
          };
      };
  };
  var runParser = function (s) {
      var $88 = Data_Newtype.unwrap();
      var $89 = runParserT(Data_Identity.monadIdentity)(s);
      return function ($90) {
          return $88($89($90));
      };
  }; 
  var monadThrowParserT = function (dictMonad) {
      return Control_Monad_Except_Trans.monadThrowExceptT(Control_Monad_State_Trans.monadStateT(dictMonad));
  };
  var monadStateParserT = function (dictMonad) {
      return Control_Monad_Except_Trans.monadStateExceptT(Control_Monad_State_Trans.monadStateStateT(dictMonad));
  };
  var position = function (dictMonad) {
      return Control_Monad_State_Class.gets(monadStateParserT(dictMonad))(function (v) {
          return v.value1;
      });
  };   
  var lazyParserT = new Control_Lazy.Lazy(function (f) {
      return Control_Lazy.defer(Control_Monad_State_Trans.lazyStateT)((function () {
          var $96 = Data_Newtype.unwrap();
          return function ($97) {
              return Control_Monad_Except_Trans.runExceptT($96(f($97)));
          };
      })());
  });                           
  var functorParserT = function (dictFunctor) {
      return Control_Monad_Except_Trans.functorExceptT(Control_Monad_State_Trans.functorStateT(dictFunctor));
  };
  var failWithPosition = function (dictMonad) {
      return function (message) {
          return function (pos) {
              return Control_Monad_Error_Class.throwError(monadThrowParserT(dictMonad))(new ParseError(message, pos));
          };
      };
  };
  var bindParserT = function (dictMonad) {
      return Control_Monad_Except_Trans.bindExceptT(Control_Monad_State_Trans.monadStateT(dictMonad));
  };
  var fail = function (dictMonad) {
      return function (message) {
          return Control_Bind.bindFlipped(bindParserT(dictMonad))(failWithPosition(dictMonad)(message))(position(dictMonad));
      };
  };
  var applyParserT = function (dictMonad) {
      return Control_Monad_Except_Trans.applyExceptT(Control_Monad_State_Trans.monadStateT(dictMonad));
  };
  var applicativeParserT = function (dictMonad) {
      return Control_Monad_Except_Trans.applicativeExceptT(Control_Monad_State_Trans.monadStateT(dictMonad));
  };
  var altParserT = function (dictMonad) {
      return new Control_Alt.Alt(function () {
          return functorParserT(((dictMonad.Bind1()).Apply0()).Functor0());
      }, function (p1) {
          return function (p2) {
              return ParserT(Control_Monad_Except_Trans.ExceptT(Control_Monad_State_Trans.StateT(function (v) {
                  return Control_Bind.bind(dictMonad.Bind1())(Control_Monad_State_Trans.runStateT(Control_Monad_Except_Trans.runExceptT(Data_Newtype.unwrap()(p1)))(new ParseState(v.value0, v.value1, false)))(function (v1) {
                      if (v1.value0 instanceof Data_Either.Left && !v1.value1.value2) {
                          return Control_Monad_State_Trans.runStateT(Control_Monad_Except_Trans.runExceptT(Data_Newtype.unwrap()(p2)))(v);
                      };
                      return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(v1.value0, v1.value1));
                  });
              })));
          };
      });
  };
  var plusParserT = function (dictMonad) {
      return new Control_Plus.Plus(function () {
          return altParserT(dictMonad);
      }, fail(dictMonad)("No alternative"));
  };
  var alternativeParserT = function (dictMonad) {
      return new Control_Alternative.Alternative(function () {
          return applicativeParserT(dictMonad);
      }, function () {
          return plusParserT(dictMonad);
      });
  };
  exports["ParseError"] = ParseError;
  exports["parseErrorMessage"] = parseErrorMessage;
  exports["ParseState"] = ParseState;
  exports["ParserT"] = ParserT;
  exports["runParser"] = runParser;
  exports["fail"] = fail;
  exports["lazyParserT"] = lazyParserT;
  exports["functorParserT"] = functorParserT;
  exports["applyParserT"] = applyParserT;
  exports["applicativeParserT"] = applicativeParserT;
  exports["bindParserT"] = bindParserT;
  exports["monadStateParserT"] = monadStateParserT;
  exports["altParserT"] = altParserT;
  exports["alternativeParserT"] = alternativeParserT;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Parsing.Parser.Combinators"] = $PS["Text.Parsing.Parser.Combinators"] || {};
  var exports = $PS["Text.Parsing.Parser.Combinators"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Control_Monad_State_Trans = $PS["Control.Monad.State.Trans"];
  var Data_Either = $PS["Data.Either"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_List = $PS["Data.List"];
  var Data_List_NonEmpty = $PS["Data.List.NonEmpty"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Newtype = $PS["Data.Newtype"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Text_Parsing_Parser = $PS["Text.Parsing.Parser"];                
  var withErrorMessage = function (dictMonad) {
      return function (p) {
          return function (msg) {
              return Control_Alt.alt(Text_Parsing_Parser.altParserT(dictMonad))(p)(Text_Parsing_Parser.fail(dictMonad)("Expected " + msg));
          };
      };
  };
  var tryRethrow = function (dictMonad) {
      return function (p) {
          return Text_Parsing_Parser.ParserT(Control_Monad_Except_Trans.ExceptT(Control_Monad_State_Trans.StateT(function (v) {
              return Control_Bind.bind(dictMonad.Bind1())(Control_Monad_State_Trans.runStateT(Control_Monad_Except_Trans.runExceptT(Data_Newtype.unwrap()(p)))(v))(function (v1) {
                  if (v1.value0 instanceof Data_Either.Left) {
                      return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(new Data_Either.Left(new Text_Parsing_Parser.ParseError(v1.value0.value0.value0, v.value1)), new Text_Parsing_Parser.ParseState(v1.value1.value0, v1.value1.value1, v.value2)));
                  };
                  return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(v1.value0, v1.value1));
              });
          })));
      };
  };
  var $$try = function (dictMonad) {
      return function (p) {
          return Text_Parsing_Parser.ParserT(Control_Monad_Except_Trans.ExceptT(Control_Monad_State_Trans.StateT(function (v) {
              return Control_Bind.bind(dictMonad.Bind1())(Control_Monad_State_Trans.runStateT(Control_Monad_Except_Trans.runExceptT(Data_Newtype.unwrap()(p)))(v))(function (v1) {
                  if (v1.value0 instanceof Data_Either.Left) {
                      return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(v1.value0, new Text_Parsing_Parser.ParseState(v1.value1.value0, v1.value1.value1, v.value2)));
                  };
                  return Control_Applicative.pure(dictMonad.Applicative0())(new Data_Tuple.Tuple(v1.value0, v1.value1));
              });
          })));
      };
  };
  var skipMany1 = function (dictMonad) {
      return function (p) {
          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(p)(function () {
              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(skipMany(dictMonad)(p))(function () {
                  return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(dictMonad))(Data_Unit.unit);
              });
          });
      };
  };
  var skipMany = function (dictMonad) {
      return function (p) {
          return Control_Alt.alt(Text_Parsing_Parser.altParserT(dictMonad))(skipMany1(dictMonad)(p))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(dictMonad))(Data_Unit.unit));
      };
  };
  var sepBy = function (dictMonad) {
      return function (p) {
          return function (sep) {
              return Control_Alt.alt(Text_Parsing_Parser.altParserT(dictMonad))(Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(p)(function (a) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(Data_List.many(Text_Parsing_Parser.alternativeParserT(dictMonad))(Text_Parsing_Parser.lazyParserT)(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(dictMonad))(sep)(p)))(function (as) {
                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(dictMonad))(new Data_List_Types.Cons(a, as));
                  });
              }))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(dictMonad))(Data_List_Types.Nil.value));
          };
      };
  };
  var option = function (dictMonad) {
      return function (a) {
          return function (p) {
              return Control_Alt.alt(Text_Parsing_Parser.altParserT(dictMonad))(p)(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(dictMonad))(a));
          };
      };
  };
  var optionMaybe = function (dictMonad) {
      return function (p) {
          return option(dictMonad)(Data_Maybe.Nothing.value)(Data_Functor.map(Text_Parsing_Parser.functorParserT(((dictMonad.Bind1()).Apply0()).Functor0()))(Data_Maybe.Just.create)(p));
      };
  };
  var manyTill = function (dictMonad) {
      return function (p) {
          return function (end) {
              var scan = Control_Alt.alt(Text_Parsing_Parser.altParserT(dictMonad))(Data_Functor.voidLeft(Text_Parsing_Parser.functorParserT(((dictMonad.Bind1()).Apply0()).Functor0()))(end)(Data_List_Types.Nil.value))(Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(p)(function (x) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(scan)(function (xs) {
                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(dictMonad))(new Data_List_Types.Cons(x, xs));
                  });
              }));
              return scan;
          };
      };
  };
  var many1Till = function (dictMonad) {
      return function (p) {
          return function (end) {
              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(p)(function (x) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(manyTill(dictMonad)(p)(end))(function (xs) {
                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(dictMonad))(Data_List_NonEmpty["cons'"](x)(xs));
                  });
              });
          };
      };
  };
  exports["withErrorMessage"] = withErrorMessage;
  exports["option"] = option;
  exports["optionMaybe"] = optionMaybe;
  exports["try"] = $$try;
  exports["tryRethrow"] = tryRethrow;
  exports["sepBy"] = sepBy;
  exports["skipMany"] = skipMany;
  exports["manyTill"] = manyTill;
  exports["many1Till"] = many1Till;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Parsing.Parser.String"] = $PS["Text.Parsing.Parser.String"] || {};
  var exports = $PS["Text.Parsing.Parser.String"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_State_Class = $PS["Control.Monad.State.Class"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Newtype = $PS["Data.Newtype"];
  var Data_Show = $PS["Data.Show"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Text_Parsing_Parser = $PS["Text.Parsing.Parser"];
  var Text_Parsing_Parser_Combinators = $PS["Text.Parsing.Parser.Combinators"];
  var Text_Parsing_Parser_Pos = $PS["Text.Parsing.Parser.Pos"];                
  var StringLike = function (drop, $$null, stripPrefix, uncons) {
      this.drop = drop;
      this["null"] = $$null;
      this.stripPrefix = stripPrefix;
      this.uncons = uncons;
  };
  var uncons = function (dict) {
      return dict.uncons;
  };
  var stripPrefix = function (dict) {
      return dict.stripPrefix;
  };
  var stringLikeString = new StringLike(Data_String_CodePoints.drop, Data_String_Common["null"], Data_String_CodeUnits.stripPrefix, Data_String_CodeUnits.uncons);
  var string = function (dictStringLike) {
      return function (dictMonad) {
          return function (str) {
              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(Control_Monad_State_Class.gets(Text_Parsing_Parser.monadStateParserT(dictMonad))(function (v) {
                  return v.value0;
              }))(function (input) {
                  var v = stripPrefix(dictStringLike)(Data_Newtype.wrap()(str))(input);
                  if (v instanceof Data_Maybe.Just) {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(dictMonad))(Control_Monad_State_Class.modify_(Text_Parsing_Parser.monadStateParserT(dictMonad))(function (v1) {
                          return new Text_Parsing_Parser.ParseState(v.value0, Text_Parsing_Parser_Pos.updatePosString(v1.value1)(str), true);
                      }))(function () {
                          return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(dictMonad))(str);
                      });
                  };
                  return Text_Parsing_Parser.fail(dictMonad)("Expected " + Data_Show.show(Data_Show.showString)(str));
              });
          };
      };
  };
  var $$null = function (dict) {
      return dict["null"];
  };
  var eof = function (dictStringLike) {
      return function (dictMonad) {
          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(Control_Monad_State_Class.gets(Text_Parsing_Parser.monadStateParserT(dictMonad))(function (v) {
              return v.value0;
          }))(function (input) {
              return Control_Applicative.unless(Text_Parsing_Parser.applicativeParserT(dictMonad))($$null(dictStringLike)(input))(Text_Parsing_Parser.fail(dictMonad)("Expected EOF"));
          });
      };
  };
  var drop = function (dict) {
      return dict.drop;
  };
  var anyChar = function (dictStringLike) {
      return function (dictMonad) {
          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(Control_Monad_State_Class.gets(Text_Parsing_Parser.monadStateParserT(dictMonad))(function (v) {
              return v.value0;
          }))(function (input) {
              var v = uncons(dictStringLike)(input);
              if (v instanceof Data_Maybe.Nothing) {
                  return Text_Parsing_Parser.fail(dictMonad)("Unexpected EOF");
              };
              if (v instanceof Data_Maybe.Just) {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(dictMonad))(Control_Monad_State_Class.modify_(Text_Parsing_Parser.monadStateParserT(dictMonad))(function (v1) {
                      return new Text_Parsing_Parser.ParseState(v.value0.tail, Text_Parsing_Parser_Pos.updatePosString(v1.value1)(Data_String_CodeUnits.singleton(v.value0.head)), true);
                  }))(function () {
                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(dictMonad))(v.value0.head);
                  });
              };
              throw new Error("Failed pattern match at Text.Parsing.Parser.String (line 56, column 3 - line 63, column 16): " + [ v.constructor.name ]);
          });
      };
  };
  var satisfy = function (dictStringLike) {
      return function (dictMonad) {
          return function (f) {
              return Text_Parsing_Parser_Combinators.tryRethrow(dictMonad)(Control_Bind.bind(Text_Parsing_Parser.bindParserT(dictMonad))(anyChar(dictStringLike)(dictMonad))(function (c) {
                  var $52 = f(c);
                  if ($52) {
                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(dictMonad))(c);
                  };
                  return Text_Parsing_Parser.fail(dictMonad)("Character '" + (Data_String_CodeUnits.singleton(c) + "' did not satisfy predicate"));
              }));
          };
      };
  };
  var $$char = function (dictStringLike) {
      return function (dictMonad) {
          return function (c) {
              return Text_Parsing_Parser_Combinators.withErrorMessage(dictMonad)(satisfy(dictStringLike)(dictMonad)(function (v) {
                  return v === c;
              }))(Data_Show.show(Data_Show.showChar)(c));
          };
      };
  };
  var noneOf = function (dictStringLike) {
      return function (dictMonad) {
          return function (ss) {
              return Text_Parsing_Parser_Combinators.withErrorMessage(dictMonad)(satisfy(dictStringLike)(dictMonad)(Data_Function.flip(Data_Foldable.notElem(Data_Foldable.foldableArray)(Data_Eq.eqChar))(ss)))("none of " + Data_Show.show(Data_Show.showArray(Data_Show.showChar))(ss));
          };
      };
  };
  var oneOf = function (dictStringLike) {
      return function (dictMonad) {
          return function (ss) {
              return Text_Parsing_Parser_Combinators.withErrorMessage(dictMonad)(satisfy(dictStringLike)(dictMonad)(Data_Function.flip(Data_Foldable.elem(Data_Foldable.foldableArray)(Data_Eq.eqChar))(ss)))("one of " + Data_Show.show(Data_Show.showArray(Data_Show.showChar))(ss));
          };
      };
  };
  exports["eof"] = eof;
  exports["string"] = string;
  exports["anyChar"] = anyChar;
  exports["satisfy"] = satisfy;
  exports["char"] = $$char;
  exports["oneOf"] = oneOf;
  exports["noneOf"] = noneOf;
  exports["stringLikeString"] = stringLikeString;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Parsing.Parser.Token"] = $PS["Text.Parsing.Parser.Token"] || {};
  var exports = $PS["Text.Parsing.Parser.Token"];
  var Data_CodePoint_Unicode = $PS["Data.CodePoint.Unicode"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Text_Parsing_Parser_Combinators = $PS["Text.Parsing.Parser.Combinators"];
  var Text_Parsing_Parser_String = $PS["Text.Parsing.Parser.String"];
  var satisfyCP = function (dictMonad) {
      return function (p) {
          return Text_Parsing_Parser_String.satisfy(Text_Parsing_Parser_String.stringLikeString)(dictMonad)(function ($117) {
              return p(Data_String_CodePoints.codePointFromChar($117));
          });
      };
  };
  var digit = function (dictMonad) {
      return Text_Parsing_Parser_Combinators.withErrorMessage(dictMonad)(satisfyCP(dictMonad)(Data_CodePoint_Unicode.isDecDigit))("digit");
  };
  exports["digit"] = digit;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["URI.Common"] = $PS["URI.Common"] || {};
  var exports = $PS["URI.Common"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Category = $PS["Control.Category"];
  var Data_Array = $PS["Data.Array"];
  var Data_Either = $PS["Data.Either"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_String_Common = $PS["Data.String.Common"];
  var JSURI = $PS["JSURI"];
  var Text_Parsing_Parser = $PS["Text.Parsing.Parser"];
  var Text_Parsing_Parser_String = $PS["Text.Parsing.Parser.String"];
  var Text_Parsing_Parser_Token = $PS["Text.Parsing.Parser.Token"];                                                                                                                     
  var printEncoded = function (p) {
      return function (s) {
          var simpleChar = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_String_CodeUnits.singleton)(p);
          var encodedChar = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
              var $18 = Data_Maybe.fromJust();
              return function ($19) {
                  return $18(JSURI["encodeURIComponent"](Data_String_CodeUnits.singleton($19)));
              };
          })())(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity));
          var parse = Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_String_Common.joinWith(""))(Data_Array.many(Text_Parsing_Parser.alternativeParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser.lazyParserT)(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(simpleChar)(encodedChar))))(Text_Parsing_Parser_String.eof(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity));
          return Data_Either.either(Data_Function["const"](s))(Control_Category.identity(Control_Category.categoryFn))(Text_Parsing_Parser.runParser(s)(parse));
      };
  };   
  var alpha = Text_Parsing_Parser_String.satisfy(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(function (c) {
      return c >= "a" && c <= "z" || c >= "A" && c <= "Z";
  });
  var alphaNum = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(alpha)(Text_Parsing_Parser_Token.digit(Data_Identity.monadIdentity));
  var unreserved = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(alphaNum)(Text_Parsing_Parser_String["char"](Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("-")))(Text_Parsing_Parser_String["char"](Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(".")))(Text_Parsing_Parser_String["char"](Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("_")))(Text_Parsing_Parser_String["char"](Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("~"));
  exports["unreserved"] = unreserved;
  exports["printEncoded"] = printEncoded;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["URI.Query"] = $PS["URI.Query"] || {};
  var exports = $PS["URI.Query"];                    
  var Query = function (x) {
      return x;
  };
  var unsafeFromString = Query;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
  var print = function (v) {
      return "?" + v;
  };
  exports["unsafeFromString"] = unsafeFromString;
  exports["print"] = print;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["URI.Extra.QueryPairs"] = $PS["URI.Extra.QueryPairs"] || {};
  var exports = $PS["URI.Extra.QueryPairs"];
  var Control_Alt = $PS["Control.Alt"];
  var Data_Array = $PS["Data.Array"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Text_Parsing_Parser = $PS["Text.Parsing.Parser"];
  var Text_Parsing_Parser_String = $PS["Text.Parsing.Parser.String"];
  var URI_Common = $PS["URI.Common"];
  var URI_Query = $PS["URI.Query"];                
  var Value = function (x) {
      return x;
  };
  var Key = function (x) {
      return x;
  };
  var unsafeValueToString = function (v) {
      return v;
  };                                
  var unsafeKeyToString = function (v) {
      return v;
  };                                                
  var print = function (printK) {
      return function (printV) {
          return function (v) {
              var printPart = function (v1) {
                  if (v1.value1 instanceof Data_Maybe.Nothing) {
                      return unsafeKeyToString(printK(v1.value0));
                  };
                  if (v1.value1 instanceof Data_Maybe.Just) {
                      return unsafeKeyToString(printK(v1.value0)) + ("=" + unsafeValueToString(printV(v1.value1.value0)));
                  };
                  throw new Error("Failed pattern match at URI.Extra.QueryPairs (line 102, column 17 - line 106, column 78): " + [ v1.constructor.name ]);
              };
              return URI_Query.unsafeFromString(Data_String_Common.joinWith("&")(Data_Array.fromFoldable(Data_Foldable.foldableArray)(Data_Functor.map(Data_Functor.functorArray)(printPart)(v))));
          };
      };
  };
  var keyPartChar = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(URI_Common.unreserved)(Text_Parsing_Parser_String.oneOf(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)([ "!", "$", "'", "(", ")", "*", "+", ",", ":", "@", "/", "?" ]));
  var valueFromString = (function () {
      var $39 = URI_Common.printEncoded(keyPartChar);
      return function ($40) {
          return Value($39($40));
      };
  })();
  var keyFromString = (function () {
      var $46 = URI_Common.printEncoded(keyPartChar);
      return function ($47) {
          return Key($46($47));
      };
  })();
  exports["print"] = print;
  exports["keyFromString"] = keyFromString;
  exports["valueFromString"] = valueFromString;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.Frame"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.Frame"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.Frame"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var DOM_Simple_EventListener = $PS["DOM.Simple.EventListener"];
  var DOM_Simple_Window = $PS["DOM.Simple.Window"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Gargantext_Components_Forest_Tree_Node_Action_Search_Types = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.Types"];
  var Gargantext_Components_Lang = $PS["Gargantext.Components.Lang"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var URI_Extra_QueryPairs = $PS["URI.Extra.QueryPairs"];
  var URI_Query = $PS["URI.Query"];                
  var Istex = (function () {
      function Istex() {

      };
      Istex.value = new Istex();
      return Istex;
  })();
  var Searx = (function () {
      function Searx() {

      };
      Searx.value = new Searx();
      return Searx;
  })();
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Search.Frame");
  var frameUrl = function (v) {
      if (v instanceof Istex) {
          return "https://istex.frame.gargantext.org";
      };
      if (v instanceof Searx) {
          return "https://searx.frame.gargantext.org";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Search.Frame (line 78, column 1 - line 78, column 34): " + [ v.constructor.name ]);
  };
  var iframeWithCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var url = frameUrl(v.frameSource);
              var searxTermUrl = function (term) {
                  var qp = [ new Data_Tuple.Tuple(URI_Extra_QueryPairs.keyFromString("q"), Data_Maybe.Just.create(URI_Extra_QueryPairs.valueFromString(term))) ];
                  var query = URI_Query.print(URI_Extra_QueryPairs.print(Control_Category.identity(Control_Category.categoryFn))(Control_Category.identity(Control_Category.categoryFn))(qp));
                  return url + query;
              };
              var isTexTermUrl = function (term) {
                  var qp = [ new Data_Tuple.Tuple(URI_Extra_QueryPairs.keyFromString("query"), new Data_Maybe.Just(URI_Extra_QueryPairs.valueFromString(term))) ];
                  var query = URI_Query.print(URI_Extra_QueryPairs.print(Control_Category.identity(Control_Category.categoryFn))(Control_Category.identity(Control_Category.categoryFn))(qp));
                  return url + query;
              };
              var src = function (v2) {
                  return function (term) {
                      if (v2 instanceof Istex) {
                          return isTexTermUrl(term);
                      };
                      if (v2 instanceof Searx) {
                          return searxTermUrl(term);
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Search.Frame (line 130, column 9 - line 130, column 47): " + [ v2.constructor.name, term.constructor.name ]);
                  };
              };
              var changeSearchOnMessage = function (url$prime) {
                  return DOM_Simple_EventListener.callback(function (m) {
                      var $18 = Gargantext_Utils_Reactix.getMessageOrigin(m) === url$prime;
                      if ($18) {
                          var v2 = Gargantext_Utils_Reactix.getMessageData(m);
                          return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v3) {
                              var $20 = {};
                              for (var $21 in v3) {
                                  if ({}.hasOwnProperty.call(v3, $21)) {
                                      $20[$21] = v3[$21];
                                  };
                              };
                              $20.url = v2["url''"];
                              $20.term = v2.term;
                              return $20;
                          })(v.search);
                      };
                      return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                  });
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "url";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "term";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "node_id";
              }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                  return "lang";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Lang["$_EqLang_5"])))()(new Data_Symbol.IsSymbol(function () {
                  return "datafield";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDataField_62"])))()(new Data_Symbol.IsSymbol(function () {
                  return "databases";
              }))(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDatabase_72"]))))(v.search))(function (search$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.iframe({
                      src: src(v.frameSource)(search$prime.term),
                      width: "100%",
                      height: "100%",
                      ref: v.iframeRef,
                      on: {
                          load: function (v2) {
                              return function __do() {
                                  DOM_Simple_EventListener.addEventListener()()(DOM_Simple_Window.window)("message")(changeSearchOnMessage(url))();
                                  return Gargantext_Utils_Reactix.postMessage(v.iframeRef)(search$prime.term)();
                              };
                          }
                      }
                  })([  ]));
              });
          };
      };
      return here.component("iframeWith")(cpt);
  })();
  var iframeWith = Reactix_React.createElement(Reactix_React.componentIsComponent)(iframeWithCpt);
  var divIframeCpt = (function () {
      var cpt = function (props) {
          return function (v) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "frame-search card"
              })([ iframeWith(props)([  ]) ]));
          };
      };
      return here.component("divIframe")(cpt);
  })();
  var divIframe = Reactix_React.createElement(Reactix_React.componentIsComponent)(divIframeCpt);
  var searchIframesCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "url";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "term";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "node_id";
              }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                  return "lang";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Lang["$_EqLang_5"])))()(new Data_Symbol.IsSymbol(function () {
                  return "datafield";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDataField_62"])))()(new Data_Symbol.IsSymbol(function () {
                  return "databases";
              }))(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDatabase_72"]))))(v.search))(function (search$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)((function () {
                      var $30 = Gargantext_Components_Forest_Tree_Node_Action_Search_Types.isIsTex_Advanced(search$prime.datafield);
                      if ($30) {
                          return divIframe({
                              frameSource: Istex.value,
                              iframeRef: v.iframeRef,
                              search: v.search
                          })([  ]);
                      };
                      var $31 = Data_Eq.eq(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDataField_62"]))(new Data_Maybe.Just(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.Web.value))(search$prime.datafield);
                      if ($31) {
                          return divIframe({
                              frameSource: Searx.value,
                              iframeRef: v.iframeRef,
                              search: v.search
                          })([  ]);
                      };
                      return Reactix_DOM_HTML.div({})([  ]);
                  })());
              });
          };
      };
      return here.component("searchIframes")(cpt);
  })();
  var searchIframes = Reactix_React.createElement(Reactix_React.componentIsComponent)(searchIframesCpt);
  exports["searchIframes"] = searchIframes;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Newtype = $PS["Data.Newtype"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Set = $PS["Data.Set"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_Components_Forest_Tree_Node_Action_Search_Frame = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.Frame"];
  var Gargantext_Components_Forest_Tree_Node_Action_Search_Types = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.Types"];
  var Gargantext_Components_InputWithEnter = $PS["Gargantext.Components.InputWithEnter"];
  var Gargantext_Components_Lang = $PS["Gargantext.Components.Lang"];
  var Gargantext_Prelude = $PS["Gargantext.Prelude"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var updateFilter = function (org) {
      return function (v) {
          if (v instanceof Data_Maybe.Just && (v.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External && (v.value0.value0 instanceof Data_Maybe.Just && (v.value0.value0.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.HAL && (v.value0.value0.value0.value0 instanceof Data_Maybe.Just && v.value0.value0.value0.value0.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.IMT))))) {
              var imtOrgs$prime = (function () {
                  var $48 = Data_Set.member(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_OrdIMT_org_79"])(org)(v.value0.value0.value0.value0.value0.value0);
                  if ($48) {
                      var $49 = Data_Eq.eq(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqIMT_org_80"])(org)(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.All_IMT.value);
                      if ($49) {
                          return Data_Set.empty;
                      };
                      return Data_Set["delete"](Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_OrdIMT_org_79"])(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.All_IMT.value)(Data_Set["delete"](Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_OrdIMT_org_79"])(org)(v.value0.value0.value0.value0.value0.value0));
                  };
                  var $50 = Data_Eq.eq(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqIMT_org_80"])(org)(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.All_IMT.value);
                  if ($50) {
                      return Data_Set.fromFoldable(Data_Foldable.foldableArray)(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_OrdIMT_org_79"])(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.allIMTorgs);
                  };
                  return Data_Set.insert(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_OrdIMT_org_79"])(org)(v.value0.value0.value0.value0.value0.value0);
              })();
              return new Data_Maybe.Just(new Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External(new Data_Maybe.Just(new Gargantext_Components_Forest_Tree_Node_Action_Search_Types.HAL(Data_Maybe.Just.create(new Gargantext_Components_Forest_Tree_Node_Action_Search_Types.IMT(imtOrgs$prime))))));
          };
          var imtOrgs$prime = (function () {
              var $57 = Data_Eq.eq(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqIMT_org_80"])(org)(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.All_IMT.value);
              if ($57) {
                  return Data_Set.fromFoldable(Data_Foldable.foldableArray)(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_OrdIMT_org_79"])(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.allIMTorgs);
              };
              return Data_Set.fromFoldable(Data_Foldable.foldableArray)(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_OrdIMT_org_79"])([ org ]);
          })();
          return new Data_Maybe.Just(new Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External(new Data_Maybe.Just(new Gargantext_Components_Forest_Tree_Node_Action_Search_Types.HAL(new Data_Maybe.Just(new Gargantext_Components_Forest_Tree_Node_Action_Search_Types.IMT(imtOrgs$prime))))));
      };
  };
  var searchQuery = function (v) {
      if (v.datafield instanceof Data_Maybe.Nothing) {
          return Data_Newtype.over()()(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.SearchQuery)(function (v1) {
              return {
                  query: v.term,
                  databases: v1.databases,
                  datafield: v1.datafield,
                  files_id: v1.files_id,
                  lang: v1.lang,
                  limit: v1.limit,
                  node_id: v1.node_id,
                  offset: v1.offset,
                  order: v1.order
              };
          })(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.defaultSearchQuery);
      };
      return Data_Newtype.over()()(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.SearchQuery)(function (v1) {
          return {
              databases: v.databases,
              datafield: v.datafield,
              lang: v.lang,
              query: v.term,
              node_id: v.node_id,
              files_id: v1.files_id,
              limit: v1.limit,
              offset: v1.offset,
              order: v1.order
          };
      })(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.defaultSearchQuery);
  };
  var triggerSearch = function (os) {
      return function (s) {
          return function (q) {
              return Effect_Aff.launchAff_(Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                  DOM_Simple_Console.log2("[triggerSearch] Searching " + "databases: ")(Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ShowDatabase_69"])(q.databases))();
                  DOM_Simple_Console.log2("[triggerSearch] Searching " + "datafield: ")(Data_Show.show(Data_Maybe.showMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ShowDataField_60"]))(q.datafield))();
                  DOM_Simple_Console.log2("[triggerSearch] Searching " + "term: ")(q.term)();
                  return DOM_Simple_Console.log2("[triggerSearch] Searching " + "lang: ")(Data_Show.show(Data_Maybe.showMaybe(Gargantext_Components_Lang["$_ShowLang_4"]))(q.lang))();
              }))(function () {
                  if (q.node_id instanceof Data_Maybe.Nothing) {
                      return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(DOM_Simple_Console.log("[triggerSearch] node_id is Nothing, don't know what to do"));
                  };
                  if (q.node_id instanceof Data_Maybe.Just) {
                      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.performSearch(s)(q.node_id.value0)(searchQuery(q)))(function (task) {
                          return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                              DOM_Simple_Console.log2("[triggerSearch] task")(task)();
                              return os(task)();
                          });
                      });
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField (line 471, column 5 - line 477, column 18): " + [ q.node_id.constructor.name ]);
              }));
          };
      };
  };
  var needsLang = function (v) {
      if (v instanceof Data_Maybe.Just && v.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.Gargantext) {
          return true;
      };
      if (v instanceof Data_Maybe.Just && v.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.Web) {
          return true;
      };
      if (v instanceof Data_Maybe.Just && (v.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External && (v.value0.value0 instanceof Data_Maybe.Just && v.value0.value0.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.HAL))) {
          return true;
      };
      return false;
  };
  var isIn = function (v) {
      return function (v1) {
          if (v1 instanceof Data_Maybe.Just && (v1.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External && (v1.value0.value0 instanceof Data_Maybe.Just && (v1.value0.value0.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.HAL && (v1.value0.value0.value0.value0 instanceof Data_Maybe.Just && v1.value0.value0.value0.value0.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.IMT))))) {
              return Data_Set.member(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_OrdIMT_org_79"])(v)(v1.value0.value0.value0.value0.value0.value0);
          };
          return false;
      };
  };
  var isIMT = function (v) {
      if (v instanceof Data_Maybe.Just && (v.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External && (v.value0.value0 instanceof Data_Maybe.Just && (v.value0.value0.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.HAL && (v.value0.value0.value0.value0 instanceof Data_Maybe.Just && v.value0.value0.value0.value0.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.IMT))))) {
          return true;
      };
      return false;
  };
  var isHAL = function (v) {
      if (v instanceof Data_Maybe.Just && (v.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External && (v.value0.value0 instanceof Data_Maybe.Just && v.value0.value0.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.HAL))) {
          return true;
      };
      return false;
  };
  var isExternal = function (v) {
      if (v instanceof Data_Maybe.Just && v.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External) {
          return true;
      };
      return false;
  };
  var isCNRS = function (v) {
      if (v instanceof Data_Maybe.Just && (v.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External && (v.value0.value0 instanceof Data_Maybe.Just && (v.value0.value0.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.HAL && (v.value0.value0.value0.value0 instanceof Data_Maybe.Just && v.value0.value0.value0.value0.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.CNRS))))) {
          return true;
      };
      return false;
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField");
  var langNavCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var liItem = function (v2) {
                  return function (lang$prime) {
                      return Reactix_DOM_HTML.div({
                          className: "nav-item nav-link" + (function () {
                              var $113 = Data_Eq.eq(Data_Maybe.eqMaybe(Gargantext_Components_Lang["$_EqLang_5"]))(new Data_Maybe.Just(lang$prime))(v2.lang);
                              if ($113) {
                                  return " active";
                              };
                              return "";
                          })(),
                          on: {
                              click: function (v3) {
                                  return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v4) {
                                      var $114 = {};
                                      for (var $115 in v4) {
                                          if ({}.hasOwnProperty.call(v4, $115)) {
                                              $114[$115] = v4[$115];
                                          };
                                      };
                                      $114.lang = new Data_Maybe.Just(lang$prime);
                                      return $114;
                                  })(v.search);
                              }
                          }
                      })([ Reactix_DOM_HTML.text(Data_Show.show(Gargantext_Components_Lang["$_ShowLang_4"])(lang$prime)) ]);
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "url";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "term";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "node_id";
              }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                  return "lang";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Lang["$_EqLang_5"])))()(new Data_Symbol.IsSymbol(function () {
                  return "datafield";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDataField_62"])))()(new Data_Symbol.IsSymbol(function () {
                  return "databases";
              }))(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDatabase_72"]))))(v.search))(function (search$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ Reactix_DOM_HTML.div({
                      className: "text-primary center"
                  })([ Reactix_DOM_HTML.text("with lang") ]), Reactix_DOM_HTML.div({
                      className: "nav nav-tabs"
                  })(Data_Functor.map(Data_Functor.functorArray)(liItem(search$prime))(v.langs)) ]));
              });
          };
      };
      return here.component("langNav")(cpt);
  })();
  var langNav = Reactix_React.createElement(Reactix_React.componentIsComponent)(langNavCpt);
  var orgInputCpt = (function () {
      var liItem = function (org) {
          return Reactix_DOM_HTML.option({
              className: "text-primary center"
          })([ Reactix_DOM_HTML.text(Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ShowOrg_75"])(org)) ]);
      };
      var cpt = function (v) {
          return function (v1) {
              var change = function (e) {
                  var value = Reactix_SyntheticEvent.unsafeEventValue(e);
                  return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v2) {
                      var $122 = {};
                      for (var $123 in v2) {
                          if ({}.hasOwnProperty.call(v2, $123)) {
                              $122[$123] = v2[$123];
                          };
                      };
                      $122.datafield = Data_Maybe.Just.create(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External.create(Data_Maybe.Just.create(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.HAL.create(Gargantext_Prelude.read(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ReadOrg_76"])(value)))));
                      return $122;
                  })(v.search);
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "form-group"
              })([ Reactix_DOM_HTML.div({
                  className: "text-primary center"
              })([ Reactix_DOM_HTML.text("filter with organization: ") ]), Gargantext_Utils_Reactix.select({
                  className: "form-control",
                  on: {
                      change: change
                  }
              })(Data_Functor.map(Data_Functor.functorArray)(liItem)(v.orgs)) ]));
          };
      };
      return here.component("orgInput")(cpt);
  })();
  var orgInput = Reactix_React.createElement(Reactix_React.componentIsComponent)(orgInputCpt);
  var searchInputCpt = (function () {
      var onValueChanged = function (valueRef) {
          return function (value) {
              return Reactix_React.setRef(valueRef)(value);
          };
      };
      var onEnter = function (valueRef) {
          return function (search) {
              return function (v) {
                  return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v1) {
                      var $127 = {};
                      for (var $128 in v1) {
                          if ({}.hasOwnProperty.call(v1, $128)) {
                              $127[$128] = v1[$128];
                          };
                      };
                      $127.term = Reactix_React.readRef(valueRef);
                      return $127;
                  })(search);
              };
          };
      };
      var onBlur = function (valueRef) {
          return function (search) {
              return function (value) {
                  return function __do() {
                      Reactix_React.setRef(valueRef)(value)();
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v) {
                          var $130 = {};
                          for (var $131 in v) {
                              if ({}.hasOwnProperty.call(v, $131)) {
                                  $130[$131] = v[$131];
                              };
                          };
                          $130.term = value;
                          return $130;
                      })(search)();
                  };
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "url";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "term";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "node_id";
              }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                  return "lang";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Lang["$_EqLang_5"])))()(new Data_Symbol.IsSymbol(function () {
                  return "datafield";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDataField_62"])))()(new Data_Symbol.IsSymbol(function () {
                  return "databases";
              }))(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDatabase_72"]))))(v.search))(function (v2) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(v2.term))(function (valueRef) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                          className: ""
                      })([ Gargantext_Components_InputWithEnter.inputWithEnter({
                          onBlur: onBlur(valueRef)(v.search),
                          onEnter: onEnter(valueRef)(v.search),
                          onValueChanged: onValueChanged(valueRef),
                          autoFocus: false,
                          className: "form-control",
                          defaultValue: Reactix_React.readRef(valueRef),
                          placeholder: "Your query here",
                          type: "text"
                      }) ]));
                  });
              });
          };
      };
      return here.component("searchInput")(cpt);
  })();
  var searchInput = Reactix_React.createElement(Reactix_React.componentIsComponent)(searchInputCpt);
  var submitButtonComponent = (function () {
      var doSearch = function (os) {
          return function (s) {
              return function (q) {
                  return function (v) {
                      return function __do() {
                          DOM_Simple_Console.log2("[submitButton] searching")(q)();
                          return triggerSearch(os)(s)(q)();
                      };
                  };
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "url";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "term";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "node_id";
              }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                  return "lang";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Lang["$_EqLang_5"])))()(new Data_Symbol.IsSymbol(function () {
                  return "datafield";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDataField_62"])))()(new Data_Symbol.IsSymbol(function () {
                  return "databases";
              }))(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDatabase_72"]))))(v.search))(function (search$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.button({
                      className: "btn btn-primary",
                      type: "button",
                      on: {
                          click: doSearch(v.onSearch)(v.session)(search$prime)
                      },
                      style: {
                          width: "100%"
                      }
                  })([ Reactix_DOM_HTML.text("Launch Search") ]));
              });
          };
      };
      return here.component("submitButton")(cpt);
  })();
  var submitButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(submitButtonComponent);
  var defaultSearch = {
      databases: Gargantext_Components_Forest_Tree_Node_Action_Search_Types.Empty.value,
      datafield: Data_Maybe.Nothing.value,
      node_id: Data_Maybe.Nothing.value,
      lang: Data_Maybe.Nothing.value,
      term: "",
      url: ""
  };
  var databaseInputCpt = (function () {
      var defaultValue = function (datafield) {
          return Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ShowDatabase_69"])(Data_Maybe.maybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.Empty.value)(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.datafield2database)(datafield));
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "url";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "term";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "node_id";
              }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                  return "lang";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Lang["$_EqLang_5"])))()(new Data_Symbol.IsSymbol(function () {
                  return "datafield";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDataField_62"])))()(new Data_Symbol.IsSymbol(function () {
                  return "databases";
              }))(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDatabase_72"]))))(v.search))(function (search$prime) {
                  var liItem = function (db$prime) {
                      return Reactix_DOM_HTML.option({
                          className: "text-primary center",
                          value: Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ShowDatabase_69"])(db$prime)
                      })([ Reactix_DOM_HTML.text(Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ShowDatabase_69"])(db$prime)) ]);
                  };
                  var db = (function () {
                      if (search$prime.datafield instanceof Data_Maybe.Just && (search$prime.datafield.value0 instanceof Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External && search$prime.datafield.value0.value0 instanceof Data_Maybe.Just)) {
                          return new Data_Maybe.Just(search$prime.datafield.value0.value0.value0);
                      };
                      return Data_Maybe.Nothing.value;
                  })();
                  var change = function (e) {
                      var value = Gargantext_Prelude.read(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ReadDatabase_71"])(Reactix_SyntheticEvent.unsafeEventValue(e));
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v2) {
                          var $149 = {};
                          for (var $150 in v2) {
                              if ({}.hasOwnProperty.call(v2, $150)) {
                                  $149[$150] = v2[$150];
                              };
                          };
                          $149.datafield = Data_Maybe.Just.create(new Gargantext_Components_Forest_Tree_Node_Action_Search_Types.External(value));
                          $149.databases = Data_Maybe.fromMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.Empty.value)(value);
                          return $149;
                      })(v.search);
                  };
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "form-group"
                  })([ Reactix_DOM_HTML.div({
                      className: "text-primary center"
                  })([ Reactix_DOM_HTML.text("in database") ]), Gargantext_Utils_Reactix.select({
                      className: "form-control",
                      defaultValue: defaultValue(search$prime.datafield),
                      on: {
                          change: change
                      }
                  })(Data_Functor.map(Data_Functor.functorArray)(liItem)(v.databases)), Reactix_DOM_HTML.div({
                      className: "center"
                  })([ Reactix_DOM_HTML.text(Data_Maybe.maybe("")(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.doc(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_DocDatabase_70"]))(db)) ]) ]));
              });
          };
      };
      return here.component("databaseInput")(cpt);
  })();
  var databaseInput = Reactix_React.createElement(Reactix_React.componentIsComponent)(databaseInputCpt);
  var dataFieldNavCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var liItem = function (v2) {
                  return function (df$prime) {
                      var isActive = Data_Show.show(Data_Maybe.showMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ShowDataField_60"]))(new Data_Maybe.Just(df$prime)) === Data_Show.show(Data_Maybe.showMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ShowDataField_60"]))(v2.datafield);
                      return Reactix_DOM_HTML.div({
                          className: "nav-item nav-link" + (function () {
                              if (isActive) {
                                  return " active";
                              };
                              return "";
                          })(),
                          on: {
                              click: function (v3) {
                                  return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v4) {
                                      var $159 = {};
                                      for (var $160 in v4) {
                                          if ({}.hasOwnProperty.call(v4, $160)) {
                                              $159[$160] = v4[$160];
                                          };
                                      };
                                      $159.datafield = new Data_Maybe.Just(df$prime);
                                      $159.databases = Gargantext_Components_Forest_Tree_Node_Action_Search_Types.datafield2database(df$prime);
                                      return $159;
                                  })(v.search);
                              }
                          }
                      })([ Reactix_DOM_HTML.text(Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ShowDataField_60"])(df$prime)) ]);
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "url";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "term";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "node_id";
              }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                  return "lang";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Lang["$_EqLang_5"])))()(new Data_Symbol.IsSymbol(function () {
                  return "datafield";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDataField_62"])))()(new Data_Symbol.IsSymbol(function () {
                  return "databases";
              }))(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDatabase_72"]))))(v.search))(function (v2) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ Reactix_DOM_HTML.div({
                      className: "text-primary center"
                  })([ Reactix_DOM_HTML.text("with DataField") ]), Reactix_DOM_HTML.div({
                      className: "nav nav-tabs"
                  })(Data_Functor.map(Data_Functor.functorArray)(liItem(v2))(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.dataFields)), Reactix_DOM_HTML.div({
                      className: "center"
                  })([ Reactix_DOM_HTML.text(Data_Maybe.maybe("TODO: add Doc Instance")(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.doc(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_DocDataField_61"]))(v2.datafield)) ]) ]));
              });
          };
      };
      return here.component("dataFieldNav")(cpt);
  })();
  var dataFieldNav = Reactix_React.createElement(Reactix_React.componentIsComponent)(dataFieldNavCpt);
  var componentIMTCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "url";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "term";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "node_id";
              }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                  return "lang";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Lang["$_EqLang_5"])))()(new Data_Symbol.IsSymbol(function () {
                  return "datafield";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDataField_62"])))()(new Data_Symbol.IsSymbol(function () {
                  return "databases";
              }))(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDatabase_72"]))))(v.search))(function (search$prime) {
                  var liCpt = function (org) {
                      return Reactix_DOM_HTML.li({})([ Reactix_DOM_HTML.input({
                          type: "checkbox",
                          checked: isIn(org)(search$prime.datafield),
                          on: {
                              change: function (v2) {
                                  return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v3) {
                                      var $169 = {};
                                      for (var $170 in v3) {
                                          if ({}.hasOwnProperty.call(v3, $170)) {
                                              $169[$170] = v3[$170];
                                          };
                                      };
                                      $169.datafield = updateFilter(org)(search$prime.datafield);
                                      return $169;
                                  })(v.search);
                              }
                          }
                      }), (function () {
                          var $172 = Data_Eq.eq(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqIMT_org_80"])(org)(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.All_IMT.value);
                          if ($172) {
                              return Reactix_DOM_HTML.i({})([ Reactix_DOM_HTML.text(" " + Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ShowIMT_org_81"])(org)) ]);
                          };
                          return Reactix_DOM_HTML.text(" " + Data_Show.show(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_ShowIMT_org_81"])(org));
                      })() ]);
                  };
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ Reactix_DOM_HTML.ul({})(Data_Functor.map(Data_Functor.functorArray)(liCpt)(Gargantext_Components_Forest_Tree_Node_Action_Search_Types.allIMTorgs)) ]));
              });
          };
      };
      return here.component("componentIMT")(cpt);
  })();
  var componentIMT = Reactix_React.createElement(Reactix_React.componentIsComponent)(componentIMTCpt);
  var componentCNRSCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ Reactix_DOM_HTML.div({})([  ]) ]));
          };
      };
      return here.component("componentCNRS")(cpt);
  })();
  var componentCNRS = Reactix_React.createElement(Reactix_React.componentIsComponent)(componentCNRSCpt);
  var searchFieldCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "url";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "term";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "node_id";
              }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                  return "lang";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Lang["$_EqLang_5"])))()(new Data_Symbol.IsSymbol(function () {
                  return "datafield";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDataField_62"])))()(new Data_Symbol.IsSymbol(function () {
                  return "databases";
              }))(Gargantext_Components_Forest_Tree_Node_Action_Search_Types["$_EqDatabase_72"]))))(v.search))(function (search$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (iframeRef) {
                      var params = [ searchInput({
                          search: v.search
                      })([  ]), Reactix_DOM_HTML.div({})([ dataFieldNav({
                          datafields: Gargantext_Components_Forest_Tree_Node_Action_Search_Types.dataFields,
                          search: v.search
                      })([  ]), (function () {
                          var $179 = isExternal(search$prime.datafield);
                          if ($179) {
                              return databaseInput({
                                  databases: v.databases,
                                  search: v.search
                              })([  ]);
                          };
                          return Reactix_DOM_HTML.div({})([  ]);
                      })(), (function () {
                          var $180 = isHAL(search$prime.datafield);
                          if ($180) {
                              return orgInput({
                                  orgs: Gargantext_Components_Forest_Tree_Node_Action_Search_Types.allOrgs,
                                  search: v.search
                              })([  ]);
                          };
                          return Reactix_DOM_HTML.div({})([  ]);
                      })(), (function () {
                          var $181 = isIMT(search$prime.datafield);
                          if ($181) {
                              return componentIMT({
                                  search: v.search
                              })([  ]);
                          };
                          return Reactix_DOM_HTML.div({})([  ]);
                      })(), (function () {
                          var $182 = isCNRS(search$prime.datafield);
                          if ($182) {
                              return componentCNRS({
                                  search: v.search
                              })([  ]);
                          };
                          return Reactix_DOM_HTML.div({})([  ]);
                      })(), (function () {
                          var $183 = needsLang(search$prime.datafield);
                          if ($183) {
                              return langNav({
                                  langs: v.langs,
                                  search: v.search
                              })([  ]);
                          };
                          return Reactix_DOM_HTML.div({})([  ]);
                      })(), Reactix_DOM_HTML.div({})([ Gargantext_Components_Forest_Tree_Node_Action_Search_Frame.searchIframes({
                          iframeRef: iframeRef,
                          search: v.search
                      })([  ]) ]) ]) ];
                      var button = submitButton({
                          onSearch: v.onSearch,
                          search: v.search,
                          session: v.session
                      })([  ]);
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                          className: "search-field"
                      })([ Reactix_DOM_HTML.div({
                          className: "row"
                      })([ Reactix_DOM_HTML.div({
                          className: "col-12"
                      })(params) ]), Reactix_DOM_HTML.div({
                          className: "row"
                      })([ Reactix_DOM_HTML.div({
                          className: "col-12"
                      })([ button ]) ]) ]));
                  });
              });
          };
      };
      return here.component("searchField")(cpt);
  })();
  var searchField = Reactix_React.createElement(Reactix_React.componentIsComponent)(searchFieldCpt);
  exports["defaultSearch"] = defaultSearch;
  exports["searchField"] = searchField;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Gargantext_Components_Forest_Tree_Node_Action_Search_SearchField = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField"];
  var Gargantext_Components_Forest_Tree_Node_Action_Search_Types = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar");
  var searchBarCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "search-bar"
              })([ Gargantext_Components_Forest_Tree_Node_Action_Search_SearchField.searchField({
                  databases: Gargantext_Components_Forest_Tree_Node_Action_Search_Types.allDatabases,
                  langs: v.langs,
                  onSearch: v.onSearch,
                  search: v.search,
                  session: v.session
              })([  ]) ]));
          };
      };
      return here.component("searchBar")(cpt);
  })();
  var searchBar = Reactix_React.createElement(Reactix_React.componentIsComponent)(searchBarCpt);
  exports["searchBar"] = searchBar;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Action.Search"] = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Action_Search_SearchBar = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.SearchBar"];
  var Gargantext_Components_Forest_Tree_Node_Action_Search_SearchField = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search.SearchField"];
  var Gargantext_Components_Lang = $PS["Gargantext.Components.Lang"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Action.Search");
  var actionSearchCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var searchOn = function (dispatch$prime) {
                  return function (p) {
                      return function (task) {
                          return function __do() {
                              Effect_Aff.launchAff(dispatch$prime(new Gargantext_Components_Forest_Tree_Node_Action.DoSearch(task)))();
                              Effect_Aff.launchAff(dispatch$prime(Gargantext_Components_Forest_Tree_Node_Action.ClosePopover.value))();
                              return Data_Unit.unit;
                          };
                      };
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox({
                  node_id: v.id,
                  databases: Gargantext_Components_Forest_Tree_Node_Action_Search_SearchField.defaultSearch.databases,
                  datafield: Gargantext_Components_Forest_Tree_Node_Action_Search_SearchField.defaultSearch.datafield,
                  lang: Gargantext_Components_Forest_Tree_Node_Action_Search_SearchField.defaultSearch.lang,
                  term: Gargantext_Components_Forest_Tree_Node_Action_Search_SearchField.defaultSearch.term,
                  url: Gargantext_Components_Forest_Tree_Node_Action_Search_SearchField.defaultSearch.url
              }))(function (search) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ Reactix_DOM_HTML.p({
                      className: "action-search"
                  })([ Reactix_DOM_HTML.text("Search and create a private " + "corpus with the search query as corpus name.") ]), Gargantext_Components_Forest_Tree_Node_Action_Search_SearchBar.searchBar({
                      langs: Gargantext_Components_Lang.allLangs,
                      onSearch: searchOn(v.dispatch)(v.nodePopup),
                      search: search,
                      session: v.session
                  })([  ]) ]));
              });
          };
      };
      return here.component("actionSearch")(cpt);
  })();
  var actionSearch = Reactix_React.createElement(Reactix_React.componentIsComponent)(actionSearchCpt);
  exports["actionSearch"] = actionSearch;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Status"] = $PS["Gargantext.Components.Forest.Tree.Node.Status"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Status"];
  var Gargantext_Components_Forest_Tree_Node_Settings = $PS["Gargantext.Components.Forest.Tree.Node.Settings"];
  var Gargantext_Types = $PS["Gargantext.Types"];                
  var Stable = (function () {
      function Stable() {

      };
      Stable.value = new Stable();
      return Stable;
  })();
  var Test = (function () {
      function Test() {

      };
      Test.value = new Test();
      return Test;
  })();
  var Dev = (function () {
      function Dev() {

      };
      Dev.value = new Dev();
      return Dev;
  })();
  var hasStatus = function (v) {
      return function (v1) {
          if (v1 instanceof Gargantext_Components_Forest_Tree_Node_Settings.SearchBox) {
              return Test.value;
          };
          if (v1 instanceof Gargantext_Components_Forest_Tree_Node_Settings.Refresh) {
              return Dev.value;
          };
          if (v1 instanceof Gargantext_Components_Forest_Tree_Node_Settings.Config) {
              return Dev.value;
          };
          if (v1 instanceof Gargantext_Components_Forest_Tree_Node_Settings.Merge) {
              return Dev.value;
          };
          if (v1 instanceof Gargantext_Components_Forest_Tree_Node_Settings.Documentation) {
              return Dev.value;
          };
          if (v instanceof Gargantext_Types.Annuaire && v1 instanceof Gargantext_Components_Forest_Tree_Node_Settings.Upload) {
              return Dev.value;
          };
          if (v instanceof Gargantext_Types.Texts && v1 instanceof Gargantext_Components_Forest_Tree_Node_Settings.Upload) {
              return Dev.value;
          };
          if (v instanceof Gargantext_Types.Corpus && v1 instanceof Gargantext_Components_Forest_Tree_Node_Settings.Add) {
              return Dev.value;
          };
          return Stable.value;
      };
  };
  exports["Stable"] = Stable;
  exports["Test"] = Test;
  exports["Dev"] = Dev;
  exports["hasStatus"] = hasStatus;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Box"] = $PS["Gargantext.Components.Forest.Tree.Node.Box"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Box"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_Forest_Tree_Node_Action_Add = $PS["Gargantext.Components.Forest.Tree.Node.Action.Add"];
  var Gargantext_Components_Forest_Tree_Node_Action_Contact = $PS["Gargantext.Components.Forest.Tree.Node.Action.Contact"];
  var Gargantext_Components_Forest_Tree_Node_Action_Delete = $PS["Gargantext.Components.Forest.Tree.Node.Action.Delete"];
  var Gargantext_Components_Forest_Tree_Node_Action_Documentation = $PS["Gargantext.Components.Forest.Tree.Node.Action.Documentation"];
  var Gargantext_Components_Forest_Tree_Node_Action_Download = $PS["Gargantext.Components.Forest.Tree.Node.Action.Download"];
  var Gargantext_Components_Forest_Tree_Node_Action_Link = $PS["Gargantext.Components.Forest.Tree.Node.Action.Link"];
  var Gargantext_Components_Forest_Tree_Node_Action_Merge = $PS["Gargantext.Components.Forest.Tree.Node.Action.Merge"];
  var Gargantext_Components_Forest_Tree_Node_Action_Move = $PS["Gargantext.Components.Forest.Tree.Node.Action.Move"];
  var Gargantext_Components_Forest_Tree_Node_Action_Rename = $PS["Gargantext.Components.Forest.Tree.Node.Action.Rename"];
  var Gargantext_Components_Forest_Tree_Node_Action_Search = $PS["Gargantext.Components.Forest.Tree.Node.Action.Search"];
  var Gargantext_Components_Forest_Tree_Node_Action_Share = $PS["Gargantext.Components.Forest.Tree.Node.Action.Share"];
  var Gargantext_Components_Forest_Tree_Node_Action_Update = $PS["Gargantext.Components.Forest.Tree.Node.Action.Update"];
  var Gargantext_Components_Forest_Tree_Node_Action_Upload = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload"];
  var Gargantext_Components_Forest_Tree_Node_Settings = $PS["Gargantext.Components.Forest.Tree.Node.Settings"];
  var Gargantext_Components_Forest_Tree_Node_Status = $PS["Gargantext.Components.Forest.Tree.Node.Status"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils = $PS["Gargantext.Utils"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Box");
  var panelActionCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Documentation) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Documentation.actionDoc({
                      nodeType: v.action.value0
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Download) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Download.actionDownload({
                      id: v.id,
                      nodeType: v.nodeType,
                      session: v.session
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Upload) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Upload.actionUpload({
                      dispatch: v.dispatch,
                      id: v.id,
                      nodeType: v.nodeType,
                      session: v.session
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Delete) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Delete.actionDelete({
                      dispatch: v.dispatch,
                      nodeType: v.nodeType
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Add) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Add.addNodeView({
                      dispatch: v.dispatch,
                      id: v.id,
                      name: v.name,
                      nodeType: v.nodeType,
                      nodeTypes: v.action.value0
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Refresh) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Update.update({
                      dispatch: v.dispatch,
                      nodeType: v.nodeType
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Config) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Tools.fragmentPT("Config " + Data_Show.show(Gargantext_Types["$_ShowNodeType_117"])(v.nodeType)));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Merge) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Merge.mergeNode({
                      dispatch: v.dispatch,
                      id: v.id,
                      nodeType: v.nodeType,
                      session: v.session,
                      subTreeParams: v.action.value0.subTreeParams,
                      handed: v.handed
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Move) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Move.moveNode({
                      dispatch: v.dispatch,
                      id: v.id,
                      nodeType: v.nodeType,
                      session: v.session,
                      subTreeParams: v.action.value0.subTreeParams,
                      handed: v.handed
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Link) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Link.linkNode({
                      dispatch: v.dispatch,
                      id: v.id,
                      nodeType: v.nodeType,
                      session: v.session,
                      subTreeParams: v.action.value0.subTreeParams,
                      handed: v.handed
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Share) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Share.shareNode({
                      dispatch: v.dispatch,
                      id: v.id
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.AddingContact) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Contact.actionAddContact({
                      dispatch: v.dispatch,
                      id: v.id
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.Publish) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Share.publishNode({
                      dispatch: v.dispatch,
                      handed: v.handed,
                      id: v.id,
                      nodeType: v.nodeType,
                      session: v.session,
                      subTreeParams: v.action.value0.subTreeParams
                  })([  ]));
              };
              if (v.action instanceof Gargantext_Components_Forest_Tree_Node_Settings.SearchBox) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest_Tree_Node_Action_Search.actionSearch({
                      dispatch: v.dispatch,
                      id: new Data_Maybe.Just(v.id),
                      nodePopup: v.nodePopup,
                      session: v.session
                  })([  ]));
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
          };
      };
      return here.component("panelAction")(cpt);
  })();
  var panelAction = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(panelActionCpt)(p)([  ]);
  };
  var hasColor = function (v) {
      if (v instanceof Gargantext_Components_Forest_Tree_Node_Status.Stable) {
          return "black";
      };
      if (v instanceof Gargantext_Components_Forest_Tree_Node_Status.Test) {
          return "orange";
      };
      if (v instanceof Gargantext_Components_Forest_Tree_Node_Status.Dev) {
          return "red";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Box (line 142, column 1 - line 142, column 29): " + [ v.constructor.name ]);
  };
  var buttonClickCpt = (function () {
      var iconAStyle = function (n) {
          return function (a) {
              return {
                  color: hasColor(Gargantext_Components_Forest_Tree_Node_Status.hasStatus(n)(a)),
                  paddingTop: "6px",
                  paddingBottom: "6px"
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Settings["$_EqNodeAction_5"])))(v.state))(function (action) {
                  var className = Gargantext_Utils.glyphiconActive(Gargantext_Components_Forest_Tree_Node_Settings.glyphiconNodeAction(v.action))(Data_Eq.eq(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Settings["$_EqNodeAction_5"]))(action)(new Data_Maybe.Just(v.action)));
                  var style = iconAStyle(v.nodeType)(v.action);
                  var click = function (v2) {
                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)((function () {
                          var $99 = Data_Eq.eq(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Settings["$_EqNodeAction_5"]))(action)(new Data_Maybe.Just(v.action));
                          if ($99) {
                              return Data_Maybe.Nothing.value;
                          };
                          return new Data_Maybe.Just(v.action);
                      })())(v.state);
                  };
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "col-1"
                  })([ Reactix_DOM_HTML.a({
                      style: style,
                      className: className,
                      id: Data_Show.show(Gargantext_Components_Forest_Tree_Node_Settings["$_ShowNodeAction_6"])(v.action),
                      title: Data_Show.show(Gargantext_Components_Forest_Tree_Node_Settings["$_ShowNodeAction_6"])(v.action),
                      on: {
                          click: click
                      }
                  })([  ]) ]));
              });
          };
      };
      return here.component("buttonClick")(cpt);
  })();
  var buttonClick = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(buttonClickCpt)(p)([  ]);
  };
  var nodePopupCpt = (function () {
      var tooltipProps = {
          id: "node-popup-tooltip",
          title: "Node settings",
          data: {
              toggle: "tooltip",
              placement: "right"
          }
      };
      var panelBody = function (nodePopupState) {
          return function (v) {
              var v1 = Gargantext_Components_Forest_Tree_Node_Settings.settingsBox(v.nodeType);
              return Reactix_DOM_HTML.div({
                  className: "card-body flex-space-between"
              })(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ Reactix_DOM_HTML.p({
                  className: "spacer"
              })([  ]), Reactix_DOM_HTML.div({
                  className: "flex-center"
              })([ buttonClick({
                  action: v1.value0.doc,
                  state: nodePopupState,
                  nodeType: v.nodeType
              }) ]), Reactix_DOM_HTML.div({
                  className: "flex-center"
              })(Data_Functor.map(Data_Functor.functorArray)(function (t) {
                  return buttonClick({
                      action: t,
                      state: nodePopupState,
                      nodeType: v.nodeType
                  });
              })(v1.value0.buttons)) ])((function () {
                  var $106 = Data_Array.length(v1.value0.buttons) < 2;
                  if ($106) {
                      return [ Reactix_DOM_HTML.div({
                          className: "col-4"
                      })([  ]) ];
                  };
                  return [  ];
              })()));
          };
      };
      var mPanelAction = function (v) {
          return function (v1) {
              if (v.action instanceof Data_Maybe.Just) {
                  return panelAction({
                      action: v.action.value0,
                      dispatch: v1.dispatch,
                      id: v1.id,
                      name: v1.name,
                      nodeType: v1.nodeType,
                      session: v1.session,
                      handed: v1.handed,
                      nodePopup: new Data_Maybe.Just(Gargantext_Components_Forest_Tree_Node_Action_Add.NodePopup.value)
                  });
              };
              if (v.action instanceof Data_Maybe.Nothing) {
                  return Reactix_DOM_HTML.div({
                      className: "card-footer"
                  })([ Reactix_DOM_HTML.div({
                      className: "center fa-hand-pointer-o"
                  })([ Reactix_DOM_HTML.h5({})([ Reactix_DOM_HTML.text(" Select available actions of this node") ]), Reactix_DOM_HTML.ul({
                      className: "panel-actions"
                  })([ Reactix_DOM_HTML.div({
                      className: "fa-thumbs-o-up ok-to-use"
                  })([ Reactix_DOM_HTML.text(" Black: usable") ]), Reactix_DOM_HTML.div({
                      className: "fa-exclamation-triangle almost-useable"
                  })([ Reactix_DOM_HTML.text(" Orange: almost useable") ]), Reactix_DOM_HTML.div({
                      className: "fa-rocket development-in-progress"
                  })([ Reactix_DOM_HTML.text(" Red: development in progress") ]) ]) ]) ]);
              };
              throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Box (line 95, column 3 - line 95, column 74): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
      var editIcon = function (v) {
          return function (v1) {
              if (v1) {
                  return Reactix_DOM_HTML.div({})([  ]);
              };
              if (!v1) {
                  return Reactix_DOM_HTML.a({
                      className: Gargantext_Utils.glyphicon("pencil"),
                      id: "rename1",
                      title: "Rename",
                      on: {
                          click: function (v2) {
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(true)(v);
                          }
                      }
                  })([  ]);
              };
              throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Box (line 78, column 3 - line 78, column 32): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
      var closePopover = function (p) {
          return function ($147) {
              return p.onPopoverClose(Reactix_SyntheticEvent.unsafeEventTarget($147));
          };
      };
      var panelHeading = function (renameIsOpen) {
          return function (open) {
              return function (v) {
                  var v1 = Gargantext_Components_Forest_Tree_Node_Settings.settingsBox(v.nodeType);
                  return Reactix_DOM_HTML.div({
                      className: "card-header"
                  })([ Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.div({
                      className: "col-4"
                  })([ Reactix_DOM_HTML.span({
                      className: Gargantext_Types.fldr(v.nodeType)(true)
                  })([  ]), Reactix_DOM_HTML.span({
                      className: "h5"
                  })([ Reactix_DOM_HTML.text(Gargantext_Types.prettyNodeType(v.nodeType)) ]) ]), Reactix_DOM_HTML.div({
                      className: "col-6"
                  })([ (function () {
                      if (open) {
                          return Gargantext_Components_Forest_Tree_Node_Tools.textInputBox({
                              boxAction: Gargantext_Components_Forest_Tree_Node_Action_Rename.renameAction,
                              boxName: "Rename",
                              dispatch: v.dispatch,
                              id: v.id,
                              text: v.name,
                              isOpen: renameIsOpen
                          })([  ]);
                      };
                      return Reactix_DOM_HTML.span({
                          className: "text-primary center"
                      })([ Reactix_DOM_HTML.text(v.name) ]);
                  })() ]), Reactix_DOM_HTML.div({
                      className: "col-1"
                  })([ editIcon(renameIsOpen)(open) ]), Reactix_DOM_HTML.div({
                      className: "col-1"
                  })([ Reactix_DOM_HTML.a({
                      type: "button",
                      on: {
                          click: closePopover(v)
                      },
                      title: "Close",
                      className: Gargantext_Utils.glyphicon("window-close")
                  })([  ]) ]) ]) ]);
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(false))(function (renameIsOpen) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(renameIsOpen))(function (open) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox({
                          action: Data_Maybe.Nothing.value,
                          id: v.id,
                          name: v.name,
                          nodeType: v.nodeType
                      }))(function (nodePopup) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v2) {
                              return v2.action;
                          })(function (a) {
                              return function (b) {
                                  var $141 = {};
                                  for (var $142 in b) {
                                      if ({}.hasOwnProperty.call(b, $142)) {
                                          $141[$142] = b[$142];
                                      };
                                  };
                                  $141.action = a;
                                  return $141;
                              };
                          })(nodePopup))(function (action) {
                              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                                  return "nodeType";
                              }))(Gargantext_Types["$_EqNodeType_114"]))()(new Data_Symbol.IsSymbol(function () {
                                  return "name";
                              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                                  return "id";
                              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                                  return "action";
                              }))(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Settings["$_EqNodeAction_5"])))))(nodePopup))(function (nodePopup$prime) {
                                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div(tooltipProps)([ Reactix_DOM_HTML.div({
                                      className: "popup-container"
                                  })([ Reactix_DOM_HTML.div({
                                      className: "card"
                                  })([ panelHeading(renameIsOpen)(open)(v), panelBody(action)(v), mPanelAction(nodePopup$prime)(v) ]) ]) ]));
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("nodePopupView")(cpt);
  })();
  var nodePopupView = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(nodePopupCpt)(p)([  ]);
  };
  exports["nodePopupView"] = nodePopupView;
})(PS);
(function(exports) {
  'use strict';

  const popover = require('react-awesome-popover');

  if (typeof window !== 'undefined') {
      window.Popover = popover;
  }

  exports.popoverCpt = popover;
  exports._setState = function(el, val) {
      el.setState(val);
  }
})(PS["Gargantext.Utils.Popover"] = PS["Gargantext.Utils.Popover"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.Popover"] = $PS["Gargantext.Utils.Popover"] || {};
  var exports = $PS["Gargantext.Utils.Popover"];
  var $foreign = $PS["Gargantext.Utils.Popover"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Uncurried = $PS["Effect.Uncurried"];
  var Reactix_React = $PS["Reactix.React"];                
  var setState = Effect_Uncurried.runEffectFn2($foreign["_setState"]);
  var setOpen = function (ref) {
      return function (val) {
          return Data_Maybe.maybe(Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit))(function (p) {
              return setState(p)({
                  open: val
              });
          })(Data_Nullable.toMaybe(Reactix_React.readRef(ref)));
      };
  };
  var popover = Reactix_React.rawCreateElement($foreign.popoverCpt);
  exports["popover"] = popover;
  exports["setOpen"] = setOpen;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.Toestand"] = $PS["Gargantext.Utils.Toestand"] || {};
  var exports = $PS["Gargantext.Utils.Toestand"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var Reloadable = function (reload) {
      this.reload = reload;
  };
  var reload = function (dict) {
      return dict.reload;
  };
  var newReload = 0;
  var $dollar_ReloadableBoxInt_2 = new Reloadable(function (box) {
      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v) {
          return v + 1 | 0;
      })(box);
  });
  exports["reload"] = reload;
  exports["newReload"] = newReload;
  exports["$_ReloadableBoxInt_2"] = $dollar_ReloadableBoxInt_2;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.FolderView"] = $PS["Gargantext.Components.FolderView"] || {};
  var exports = $PS["Gargantext.Components.FolderView"];
  var $foreign = $PS["Gargantext.Components.FolderView"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_AsyncTasks = $PS["Gargantext.AsyncTasks"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Action_Add = $PS["Gargantext.Components.Forest.Tree.Node.Action.Add"];
  var Gargantext_Components_Forest_Tree_Node_Action_Contact = $PS["Gargantext.Components.Forest.Tree.Node.Action.Contact"];
  var Gargantext_Components_Forest_Tree_Node_Action_Delete = $PS["Gargantext.Components.Forest.Tree.Node.Action.Delete"];
  var Gargantext_Components_Forest_Tree_Node_Action_Link = $PS["Gargantext.Components.Forest.Tree.Node.Action.Link"];
  var Gargantext_Components_Forest_Tree_Node_Action_Merge = $PS["Gargantext.Components.Forest.Tree.Node.Action.Merge"];
  var Gargantext_Components_Forest_Tree_Node_Action_Move = $PS["Gargantext.Components.Forest.Tree.Node.Action.Move"];
  var Gargantext_Components_Forest_Tree_Node_Action_Rename = $PS["Gargantext.Components.Forest.Tree.Node.Action.Rename"];
  var Gargantext_Components_Forest_Tree_Node_Action_Share = $PS["Gargantext.Components.Forest.Tree.Node.Action.Share"];
  var Gargantext_Components_Forest_Tree_Node_Action_Update = $PS["Gargantext.Components.Forest.Tree.Node.Action.Update"];
  var Gargantext_Components_Forest_Tree_Node_Action_Upload = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload"];
  var Gargantext_Components_Forest_Tree_Node_Box = $PS["Gargantext.Components.Forest.Tree.Node.Box"];
  var Gargantext_Components_Forest_Tree_Node_Tools_FTree = $PS["Gargantext.Components.Forest.Tree.Node.Tools.FTree"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Popover = $PS["Gargantext.Utils.Popover"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];                
  var FolderUp = (function () {
      function FolderUp() {

      };
      FolderUp.value = new FolderUp();
      return FolderUp;
  })();
  var FolderChild = (function () {
      function FolderChild() {

      };
      FolderChild.value = new FolderChild();
      return FolderChild;
  })();
  var performAction = (function () {
      var uploadFile$prime = function (nodeType) {
          return function (fileType) {
              return function (mName) {
                  return function (blob) {
                      return function (v) {
                          return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_Forest_Tree_Node_Action_Upload.uploadFile(v.session)(nodeType)(v.nodeId)(fileType)({
                              mName: mName,
                              blob: blob
                          }))(function (task) {
                              return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                                  Gargantext_AsyncTasks.insert(v.nodeId)(task)(v.tasks)();
                                  return DOM_Simple_Console.log2("[performAction] UploadFile, uploaded, task:")(task)();
                              });
                          });
                      };
                  };
              };
          };
      };
      var uploadArbitraryFile$prime = function (mName) {
          return function (blob) {
              return function (v) {
                  return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_Forest_Tree_Node_Action_Upload.uploadArbitraryFile(v.session)(v.nodeId)({
                      blob: blob,
                      mName: mName
                  }))(function (task) {
                      return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                          Gargantext_AsyncTasks.insert(v.nodeId)(task)(v.tasks)();
                          return DOM_Simple_Console.log2("[performAction] UploadArbitraryFile, uploaded, task:")(task)();
                      });
                  });
              };
          };
      };
      var updateNode = function (params) {
          return function (v) {
              return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_Forest_Tree_Node_Action_Update.updateRequest(params)(v.session)(v.nodeId))(function (task) {
                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                      Gargantext_AsyncTasks.insert(v.nodeId)(task)(v.tasks)();
                      return DOM_Simple_Console.log2("[performAction] UpdateNode task:")(task)();
                  });
              });
          };
      };
      var shareTeam = function (username) {
          return function (v) {
              return Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Share.shareReq(v.session)(v.nodeId)(new Gargantext_Components_Forest_Tree_Node_Action_Share.ShareTeamParams({
                  username: username
              })));
          };
      };
      var doSearch = function (task) {
          return function (v) {
              return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                  Gargantext_AsyncTasks.insert(v.nodeId)(task)(v.tasks)();
                  return DOM_Simple_Console.log2("[performAction] DoSearch task:")(task)();
              });
          };
      };
      var closePopover = function (v) {
          return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Foldable.foldableMaybe)(function (set) {
              return set(false);
          })(Reactix_React.readRef(v.setPopoverRef)));
      };
      var refreshFolders = function (p) {
          return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(p.reload)))(function () {
              return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(p.reloadForest)))(function () {
                  return closePopover(p);
              });
          });
      };
      var deleteNode$prime = function (nt) {
          return function (v) {
              return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)((function () {
                  if (nt instanceof Gargantext_Types.NodePublic && nt.value0 instanceof Gargantext_Types.FolderPublic) {
                      return Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Delete.deleteNode(v.session)(nt)(v.nodeId));
                  };
                  if (nt instanceof Gargantext_Types.NodePublic) {
                      return Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Delete.unpublishNode(v.session)(new Data_Maybe.Just(v.parentId))(v.nodeId));
                  };
                  return Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Delete.deleteNode(v.session)(nt)(v.nodeId));
              })())(function () {
                  return refreshFolders(v);
              });
          };
      };
      var linkNode = function (nodeType) {
          return function (params) {
              return function (p) {
                  var f = function (v) {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Link.linkNodeReq(p.session)(nodeType)(v["value0"]["in"])(v.value0.out)))(function () {
                          return refreshFolders(p);
                      });
                  };
                  return Data_Foldable.traverse_(Effect_Aff.applicativeAff)(Data_Foldable.foldableMaybe)(f)(params);
              };
          };
      };
      var mergeNode = function (params) {
          return function (p) {
              var f = function (v) {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Merge.mergeNodeReq(p.session)(v["value0"]["in"])(v.value0.out)))(function () {
                      return refreshFolders(p);
                  });
              };
              return Data_Foldable.traverse_(Effect_Aff.applicativeAff)(Data_Foldable.foldableMaybe)(f)(params);
          };
      };
      var moveNode = function (params) {
          return function (v) {
              var f = function (v1) {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Move.moveNodeReq(v.session)(v1["value0"]["in"])(v1.value0.out)))(function () {
                      return refreshFolders(v);
                  });
              };
              return Data_Foldable.traverse_(Effect_Aff.applicativeAff)(Data_Foldable.foldableMaybe)(f)(params);
          };
      };
      var renameNode = function (name) {
          return function (v) {
              return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Rename.rename(v.session)(v.nodeId)({
                  text: name
              })))(function () {
                  return refreshFolders(v);
              });
          };
      };
      var sharePublic = function (params) {
          return function (p) {
              var f = function (v) {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Share.shareReq(p.session)(v["value0"]["in"])(new Gargantext_Components_Forest_Tree_Node_Action_Share.SharePublicParams({
                      node_id: v.value0.out
                  }))))(function () {
                      return refreshFolders(p);
                  });
              };
              return Data_Foldable.traverse_(Effect_Aff.applicativeAff)(Data_Foldable.foldableMaybe)(f)(params);
          };
      };
      var addNode$prime = function (name) {
          return function (nodeType) {
              return function (v) {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Add.addNode(v.session)(v.nodeId)({
                      name: name,
                      nodeType: nodeType
                  })))(function () {
                      return refreshFolders(v);
                  });
              };
          };
      };
      var addContact = function (params) {
          return function (v) {
              return Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Contact.contactReq(v.session)(v.nodeId)(params));
          };
      };
      var performAction$prime = function (v) {
          return function (v1) {
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.DeleteNode) {
                  return deleteNode$prime(v.value0)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.DoSearch) {
                  return doSearch(v.value0)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.UpdateNode) {
                  return updateNode(v.value0)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.RenameNode) {
                  return renameNode(v.value0)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.ShareTeam) {
                  return shareTeam(v.value0)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.SharePublic) {
                  return sharePublic(v.value0.params)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.AddContact) {
                  return addContact(v.value0)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.AddNode) {
                  return addNode$prime(v.value0)(v.value1)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.UploadFile) {
                  return uploadFile$prime(v.value0)(v.value1)(v.value2)(v.value3)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.UploadArbitraryFile) {
                  return uploadArbitraryFile$prime(v.value0)(v.value1)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.DownloadNode) {
                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(DOM_Simple_Console.log("[performAction] DownloadNode"));
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.MoveNode) {
                  return moveNode(v.value0.params)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.MergeNode) {
                  return mergeNode(v.value0.params)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.LinkNode) {
                  return linkNode(v.value0.nodeType)(v.value0.params)(v1);
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.NoAction) {
                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(DOM_Simple_Console.log("[performAction] NoAction"));
              };
              if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.ClosePopover) {
                  return closePopover(v1);
              };
              return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(DOM_Simple_Console.log("[performAction] unsupported action"));
          };
      };
      return performAction$prime;
  })();
  var loadFolders = function (v) {
      return Gargantext_Sessions.get(Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_ReadForeignNTreeLNode_14"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(new Gargantext_Routes.TreeFirstLevel(new Data_Maybe.Just(v.nodeId), ""));
  };
  var homeButton = Reactix_DOM_HTML.a({
      className: "btn btn-primary",
      href: Gargantext_Routes.appPath(Gargantext_Routes.Home.value)
  })([ Reactix_DOM_HTML.i({
      className: "fa fa-home",
      title: "Back to home"
  })([  ]) ]);
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.FolderView");
  var folderSimpleCpt = (function () {
      var icon = function (v) {
          return function (v1) {
              if (v instanceof FolderUp) {
                  return "fa fa-folder-open";
              };
              return Gargantext_Types.fldr(v1)(false);
          };
      };
      var getFolderPath = function (nodeType) {
          return function (sid) {
              return function (nodeId) {
                  return Gargantext_Routes.appPath(Data_Maybe.fromMaybe(Gargantext_Routes.Home.value)(Gargantext_Routes.nodeTypeAppRoute(nodeType)(sid)(nodeId)));
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              var sid = Gargantext_Sessions_Types.sessionId(v.session);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.a({
                  className: "btn btn-primary",
                  href: "/#/" + getFolderPath(v.nodeType)(sid)(v.nodeId)
              })([ Reactix_DOM_HTML.i({
                  className: icon(v.style)(v.nodeType)
              })([  ]), Reactix_DOM_HTML.br({}), Reactix_DOM_HTML.text(v.text) ]));
          };
      };
      return here.component("folderSimpleCpt")(cpt);
  })();
  var folderSimple = Reactix_React.createElement(Reactix_React.componentIsComponent)(folderSimpleCpt);
  var folderCpt = (function () {
      var popOverIcon = Reactix_DOM_HTML.span({
          className: "fv action"
      })([ Reactix_DOM_HTML.a({
          className: "settings fa fa-cog",
          title: "Each node of the Tree can perform some actions.\x0a" + "Click here to execute one of them."
      })([  ]) ]);
      var onPopoverClose = function (popoverRef) {
          return function (v) {
              return Gargantext_Utils_Popover.setOpen(popoverRef)(false);
          };
      };
      var mNodePopupView = function (props) {
          return function (opc) {
              return Gargantext_Components_Forest_Tree_Node_Box.nodePopupView({
                  onPopoverClose: opc,
                  nodeType: props.nodeType,
                  name: props.text,
                  id: props.nodeId,
                  dispatch: props.dispatch,
                  session: props.session,
                  handed: Gargantext_Types.RightHanded.value
              });
          };
      };
      var icon = function (v) {
          return function (v1) {
              if (v instanceof FolderUp) {
                  return "fa fa-folder-open";
              };
              return Gargantext_Types.fldr(v1)(false);
          };
      };
      var getFolderPath = function (nodeType) {
          return function (sid) {
              return function (nodeId) {
                  return Gargantext_Routes.appPath(Data_Maybe.fromMaybe(Gargantext_Routes.Home.value)(Gargantext_Routes.nodeTypeAppRoute(nodeType)(sid)(nodeId)));
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              var sid = Gargantext_Sessions_Types.sessionId(v.session);
              var dispatch = function (a) {
                  return performAction(a)({
                      setPopoverRef: v.setPopoverRef,
                      session: v.session,
                      nodeId: v.nodeId,
                      parentId: v.parentId,
                      tasks: v.tasks,
                      reload: v.reload,
                      reloadForest: v.reloadForest
                  });
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (popoverRef) {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect'"](Reactix_React.setRef(v.setPopoverRef)(Data_Maybe.Just.create(Gargantext_Utils_Popover.setOpen(popoverRef)))))(function () {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.span({
                          style: {
                              position: "absolute"
                          }
                      })([ Gargantext_Utils_Popover.popover({
                          arrow: false,
                          open: false,
                          onClose: function (v2) {
                              return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                          },
                          onOpen: function (v2) {
                              return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                          },
                          ref: popoverRef
                      })([ popOverIcon, mNodePopupView(Record.merge()()(v)({
                          dispatch: dispatch
                      }))(onPopoverClose(popoverRef)) ]) ]), Reactix_DOM_HTML.button({
                          on: {
                              click: $foreign.link("/#/" + getFolderPath(v.nodeType)(sid)(v.nodeId))
                          },
                          className: "btn btn-primary fv btn"
                      })([ Reactix_DOM_HTML.i({
                          className: icon(v.style)(v.nodeType)
                      })([  ]), Reactix_DOM_HTML.br({}), Reactix_DOM_HTML.text(v.text) ]) ]));
                  });
              });
          };
      };
      return here.component("folderCpt")(cpt);
  })();
  var folder = Reactix_React.createElement(Reactix_React.componentIsComponent)(folderCpt);
  var folderViewMainCpt = (function () {
      var sortFolders = function (a) {
          return function (b) {
              return Data_Ord.compare(Data_Ord.ordInt)(Gargantext_Components_Forest_Tree_Node_Tools_FTree.fTreeID(a))(Gargantext_Components_Forest_Tree_Node_Tools_FTree.fTreeID(b));
          };
      };
      var makeParentFolder = function (v) {
          return function (v1) {
              return function (v2) {
                  return function (v3) {
                      if (v instanceof Data_Maybe.Just) {
                          return [ folderSimple({
                              style: FolderUp.value,
                              text: "..",
                              nodeId: v.value0,
                              nodeType: Gargantext_Types.FolderPrivate.value,
                              session: v1
                          })([  ]) ];
                      };
                      if (v instanceof Data_Maybe.Nothing && v3) {
                          return [ Reactix_DOM_HTML.a({
                              className: "btn btn-primary",
                              href: Gargantext_Routes.appPath(Gargantext_Routes.Home.value)
                          })([ Reactix_DOM_HTML.i({
                              className: "fa fa-folder-open"
                          })([  ]), Reactix_DOM_HTML.br({}), Reactix_DOM_HTML.text("..") ]) ];
                      };
                      if (v instanceof Data_Maybe.Nothing && v2) {
                          return [ Reactix_DOM_HTML.button({
                              className: "btn btn-primary",
                              on: {
                                  click: $foreign.back
                              }
                          })([ Reactix_DOM_HTML.i({
                              className: "fa fa-folder-open"
                          })([  ]), Reactix_DOM_HTML.br({}), Reactix_DOM_HTML.text("..") ]) ];
                      };
                      if (v instanceof Data_Maybe.Nothing) {
                          return [  ];
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.FolderView (line 106, column 3 - line 106, column 84): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name, v3.constructor.name ]);
                  };
              };
          };
      };
      var makeFolderElements = function (foldersS) {
          return function (props) {
              var makeFolderElementsMap = function (v) {
                  return folder({
                      style: FolderChild.value,
                      text: v.value0.name,
                      nodeId: v.value0.id,
                      nodeType: v.value0.nodeType,
                      session: props.session,
                      setPopoverRef: props.setPopoverRef,
                      parentId: props.nodeId,
                      tasks: props.tasks,
                      reload: props.reload,
                      reloadForest: props.reloadForest
                  })([  ]);
              };
              return Data_Functor.map(Data_Functor.functorArray)(makeFolderElementsMap)(foldersS);
          };
      };
      var isBackHome = function (v) {
          if (v instanceof Gargantext_Types.FolderPrivate) {
              return true;
          };
          if (v instanceof Gargantext_Types.FolderPublic) {
              return true;
          };
          if (v instanceof Gargantext_Types.FolderShared) {
              return true;
          };
          return false;
      };
      var cpt = function (v) {
          return function (v1) {
              var foldersS = Data_Array.sortBy(sortFolders)(v.folders.value1);
              var backHome = isBackHome(v.folders.value0.nodeType);
              var parent = makeParentFolder(v.folders.value0.parent_id)(v.session)(v.backFolder)(backHome);
              var children = makeFolderElements(foldersS)({
                  session: v.session,
                  setPopoverRef: v.setPopoverRef,
                  nodeId: v.nodeId,
                  tasks: v.tasks,
                  reload: v.reload,
                  reloadForest: v.reloadForest
              });
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "fv folders"
              })(Data_Semigroup.append(Data_Semigroup.semigroupArray)(parent)(children)));
          };
      };
      return here.component("folderViewMainCpt")(cpt);
  })();
  var folderViewMain = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(folderViewMainCpt)(props)([  ]);
  };
  var folderViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Maybe.Nothing.value))(function (setPopoverRef) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(reload))(function (reload$prime) {
                          return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "session";
                          }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                              return "reload";
                          }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                              return "nodeId";
                          }))(Data_Eq.eqInt)))(Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_EqNTree_15"](Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_EqLNode_19"]))({
                              nodeId: v.nodeId,
                              session: v.session,
                              reload: reload$prime
                          })(loadFolders)(function (folders) {
                              return folderViewMain({
                                  folders: folders,
                                  nodeId: v.nodeId,
                                  session: v.session,
                                  backFolder: v.backFolder,
                                  tasks: v.tasks,
                                  reload: reload,
                                  setPopoverRef: setPopoverRef,
                                  reloadForest: v.reloadForest
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("folderViewCpt")(cpt);
  })();
  var folderView = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(folderViewCpt)(props)([  ]);
  };
  var backButton = Reactix_DOM_HTML.button({
      className: "btn btn-primary",
      on: {
          click: $foreign.back
      }
  })([ Reactix_DOM_HTML.i({
      className: "fa fa-arrow-left",
      title: "Previous view"
  })([  ]) ]);
  exports["folderView"] = folderView;
  exports["backButton"] = backButton;
  exports["homeButton"] = homeButton;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Simple.JSON.Generics.UntaggedSumRep"] = $PS["Simple.JSON.Generics.UntaggedSumRep"] || {};
  var exports = $PS["Simple.JSON.Generics.UntaggedSumRep"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var GenericUntaggedSumRep = function (genericUntaggedSumRep) {
      this.genericUntaggedSumRep = genericUntaggedSumRep;
  };
  var untaggedSumRepArgument = function (dictReadForeign) {
      return new GenericUntaggedSumRep(function (f) {
          return Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Data_Generic_Rep.Argument)(Simple_JSON.readImpl(dictReadForeign)(f));
      });
  };
  var genericUntaggedSumRep = function (dict) {
      return dict.genericUntaggedSumRep;
  };
  var untaggedSumRep = function (dictGeneric) {
      return function (dictGenericUntaggedSumRep) {
          return function (f) {
              return Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Data_Generic_Rep.to(dictGeneric))(genericUntaggedSumRep(dictGenericUntaggedSumRep)(f));
          };
      };
  };
  var untaggedSumRepConstructor = function (dictGenericUntaggedSumRep) {
      return new GenericUntaggedSumRep(function (f) {
          return Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Data_Generic_Rep.Constructor)(genericUntaggedSumRep(dictGenericUntaggedSumRep)(f));
      });
  };
  var untaggedSumRepSum = function (dictGenericUntaggedSumRep) {
      return function (dictGenericUntaggedSumRep1) {
          return new GenericUntaggedSumRep(function (f) {
              return Control_Alt.alt(Control_Monad_Except_Trans.altExceptT(Data_List_Types.semigroupNonEmptyList)(Data_Identity.monadIdentity))(Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Data_Generic_Rep.Inl.create)(genericUntaggedSumRep(dictGenericUntaggedSumRep)(f)))(Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(Data_Generic_Rep.Inr.create)(genericUntaggedSumRep(dictGenericUntaggedSumRep1)(f)));
          });
      };
  };
  exports["untaggedSumRep"] = untaggedSumRep;
  exports["untaggedSumRepSum"] = untaggedSumRepSum;
  exports["untaggedSumRepConstructor"] = untaggedSumRepConstructor;
  exports["untaggedSumRepArgument"] = untaggedSumRepArgument;
})(PS);
(function($PS) {
  "use strict";
  $PS["Gargantext.Components.Search"] = $PS["Gargantext.Components.Search"] || {};
  var exports = $PS["Gargantext.Components.Search"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Show = $PS["Data.Show"];
  var Data_Show_Generic = $PS["Data.Show.Generic"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Simple_JSON_Generics_UntaggedSumRep = $PS["Simple.JSON.Generics.UntaggedSumRep"];                

  //----------------------------------------------------------------------
  var SearchDoc = (function () {
      function SearchDoc() {

      };
      SearchDoc.value = new SearchDoc();
      return SearchDoc;
  })();

  //----------------------------------------------------------------------
  var SearchContact = (function () {
      function SearchContact() {

      };
      SearchContact.value = new SearchContact();
      return SearchContact;
  })();

  //----------------------------------------------------------------------
  var SearchResultDoc = (function () {
      function SearchResultDoc(value0) {
          this.value0 = value0;
      };
      SearchResultDoc.create = function (value0) {
          return new SearchResultDoc(value0);
      };
      return SearchResultDoc;
  })();

  //----------------------------------------------------------------------
  var SearchNoResult = (function () {
      function SearchNoResult(value0) {
          this.value0 = value0;
      };
      SearchNoResult.create = function (value0) {
          return new SearchNoResult(value0);
      };
      return SearchNoResult;
  })();

  //----------------------------------------------------------------------
  var SearchResultContact = (function () {
      function SearchResultContact(value0) {
          this.value0 = value0;
      };
      SearchResultContact.create = function (value0) {
          return new SearchResultContact(value0);
      };
      return SearchResultContact;
  })();                                                                                                                                                            
  var $dollar_ReadForeignHyperdataRowDo_57 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "abstract";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "authors";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "bdd";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "doi";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "institutes";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "language_iso2";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "page";
  }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "publication_date";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "publication_day";
  }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "publication_hour";
  }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "publication_minute";
  }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "publication_month";
  }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "publication_second";
  }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "publication_year";
  }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "source";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "uniqId";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "uniqIdBdd";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "url";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()())()())()())()())()())()())()())()())()())()())()())()())()());
  var $dollar_ReadForeignHyperdataRowCo_67 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "firstname";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "labs";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "lastname";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()());
  var $dollar_ReadForeignDocument_52 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "category";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "created";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "hyperdata";
  }))($dollar_ReadForeignHyperdataRowDo_57)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "score";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()())()())()())()());
  var $dollar_ReadForeignContact_62 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "c_annuaireId";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "c_created";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "c_hyperdata";
  }))($dollar_ReadForeignHyperdataRowCo_67)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "c_id";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "c_score";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()())()())()())()());
  var $dollar_GenericSearchType__26 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof SearchDoc) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof SearchContact) {
          return new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Search (line 20, column 1 - line 20, column 37): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return SearchDoc.value;
      };
      if (x instanceof Data_Generic_Rep.Inr) {
          return SearchContact.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Search (line 20, column 1 - line 20, column 37): " + [ x.constructor.name ]);
  });                                                                                     
  var $dollar_ShowSearchType_28 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericSearchType__26)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "SearchDoc";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "SearchContact";
  })))));
  var $dollar_WriteForeignSearchType_30 = new Simple_JSON.WriteForeign((function () {
      var $127 = Simple_JSON.writeImpl(Simple_JSON.writeForeignString);
      var $128 = Data_Show.show($dollar_ShowSearchType_28);
      return function ($129) {
          return $127($128($129));
      };
  })());
  var $dollar_WriteForeignSearchQuery_36 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "expected";
  }))($dollar_WriteForeignSearchType_30)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "query";
  }))(Simple_JSON.writeForeignArray(Simple_JSON.writeForeignString))(Simple_JSON.nilWriteForeignFields)()()())()()());
  var $dollar_GenericSearchResultTypes__43 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof SearchResultDoc) {
          return new Data_Generic_Rep.Inl(x.value0);
      };
      if (x instanceof SearchNoResult) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(x.value0));
      };
      if (x instanceof SearchResultContact) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(x.value0));
      };
      throw new Error("Failed pattern match at Gargantext.Components.Search (line 49, column 1 - line 49, column 44): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return new SearchResultDoc(x.value0);
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return new SearchNoResult(x.value0.value0);
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inr) {
          return new SearchResultContact(x.value0.value0);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Search (line 49, column 1 - line 49, column 44): " + [ x.constructor.name ]);
  });
  var $dollar_ReadForeignSearchResultTy_46 = new Simple_JSON.ReadForeign(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRep($dollar_GenericSearchResultTypes__43)(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepSum(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepConstructor(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepArgument(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "docs";
  }))(Simple_JSON.readArray($dollar_ReadForeignDocument_52))(Simple_JSON.readFieldsNil)()()))))(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepSum(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepConstructor(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepArgument(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "message";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()()))))(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepConstructor(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepArgument(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "contacts";
  }))(Simple_JSON.readArray($dollar_ReadForeignContact_62))(Simple_JSON.readFieldsNil)()())))))));
  var $dollar_ReadForeignSearchResult_41 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "result";
  }))($dollar_ReadForeignSearchResultTy_46)(Simple_JSON.readFieldsNil)()());
  var $dollar_GenericSearchQuery__31 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });   
  var $dollar_GenericHyperdataRowContac_64 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });   
  var $dollar_EqSearchType_27 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericSearchType__26)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))));
  var $dollar_EqSearchQuery_33 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericSearchQuery__31)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "query";
  }))(Data_Eq.eqArray(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "expected";
  }))($dollar_EqSearchType_27))))));             
  var $dollar_EqHyperdataRowContact_65 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHyperdataRowContac_64)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "lastname";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "labs";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "firstname";
  }))(Data_Eq.eqString))))));
  exports["SearchDoc"] = SearchDoc;
  exports["SearchContact"] = SearchContact;
  exports["SearchResultDoc"] = SearchResultDoc;
  exports["SearchResultContact"] = SearchResultContact;
  exports["$_EqSearchType_27"] = $dollar_EqSearchType_27;
  exports["$_ShowSearchType_28"] = $dollar_ShowSearchType_28;
  exports["$_EqSearchQuery_33"] = $dollar_EqSearchQuery_33;
  exports["$_WriteForeignSearchQuery_36"] = $dollar_WriteForeignSearchQuery_36;
  exports["$_ReadForeignSearchResult_41"] = $dollar_ReadForeignSearchResult_41;
  exports["$_EqHyperdataRowContact_65"] = $dollar_EqHyperdataRowContact_65;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Table.Types"] = $PS["Gargantext.Components.Table.Types"] || {};
  var exports = $PS["Gargantext.Components.Table.Types"];
  var Data_Eq = $PS["Data.Eq"];                        
  var ASC = (function () {
      function ASC(value0) {
          this.value0 = value0;
      };
      ASC.create = function (value0) {
          return new ASC(value0);
      };
      return ASC;
  })();
  var DESC = (function () {
      function DESC(value0) {
          this.value0 = value0;
      };
      DESC.create = function (value0) {
          return new DESC(value0);
      };
      return DESC;
  })();
  var ColumnName = function (x) {
      return x;
  };
  var orderByToForm = function (v) {
      if (v instanceof ASC) {
          return v.value0 + "Asc";
      };
      if (v instanceof DESC) {
          return v.value0 + "Desc";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Table.Types (line 27, column 1 - line 27, column 55): " + [ v.constructor.name ]);
  };
  var columnName = function (v) {
      return v;
  };    
  var $dollar_EqOrderByDirection_19 = function (dictEq) {
      return new Data_Eq.Eq(function (x) {
          return function (y) {
              if (x instanceof ASC && y instanceof ASC) {
                  return Data_Eq.eq(dictEq)(x.value0)(y.value0);
              };
              if (x instanceof DESC && y instanceof DESC) {
                  return Data_Eq.eq(dictEq)(x.value0)(y.value0);
              };
              return false;
          };
      });
  };
  var $dollar_EqColumnName_22 = new Data_Eq.Eq(function (x) {
      return function (y) {
          return x === y;
      };
  });
  exports["ASC"] = ASC;
  exports["DESC"] = DESC;
  exports["orderByToForm"] = orderByToForm;
  exports["ColumnName"] = ColumnName;
  exports["columnName"] = columnName;
  exports["$_EqOrderByDirection_19"] = $dollar_EqOrderByDirection_19;
  exports["$_EqColumnName_22"] = $dollar_EqColumnName_22;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Table"] = $PS["Gargantext.Components.Table"] || {};
  var exports = $PS["Gargantext.Components.Table"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_EuclideanRing = $PS["Data.EuclideanRing"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Effect = $PS["Effect"];
  var Gargantext_Components_FolderView = $PS["Gargantext.Components.FolderView"];
  var Gargantext_Components_Nodes_Lists_Types = $PS["Gargantext.Components.Nodes.Lists.Types"];
  var Gargantext_Components_Search = $PS["Gargantext.Components.Search"];
  var Gargantext_Components_Table_Types = $PS["Gargantext.Components.Table.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var PS10 = (function () {
      function PS10() {

      };
      PS10.value = new PS10();
      return PS10;
  })();
  var PS20 = (function () {
      function PS20() {

      };
      PS20.value = new PS20();
      return PS20;
  })();
  var PS50 = (function () {
      function PS50() {

      };
      PS50.value = new PS50();
      return PS50;
  })();
  var PS100 = (function () {
      function PS100() {

      };
      PS100.value = new PS100();
      return PS100;
  })();
  var PS200 = (function () {
      function PS200() {

      };
      PS200.value = new PS200();
      return PS200;
  })();
  var string2PageSize = function (v) {
      if (v === "10") {
          return PS10.value;
      };
      if (v === "20") {
          return PS20.value;
      };
      if (v === "50") {
          return PS50.value;
      };
      if (v === "100") {
          return PS100.value;
      };
      if (v === "200") {
          return PS200.value;
      };
      return PS10.value;
  };
  var pageSizes2Int = function (v) {
      if (v instanceof PS10) {
          return 10;
      };
      if (v instanceof PS20) {
          return 20;
      };
      if (v instanceof PS50) {
          return 50;
      };
      if (v instanceof PS100) {
          return 100;
      };
      if (v instanceof PS200) {
          return 200;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Table (line 313, column 1 - line 313, column 34): " + [ v.constructor.name ]);
  };
  var stateParams = function (v) {
      var limit = pageSizes2Int(v.pageSize);
      var offset = limit * (v.page - 1 | 0) | 0;
      return {
          offset: offset,
          limit: limit,
          orderBy: v.orderBy,
          searchType: v.searchType
      };
  };
  var textDescription = function (currPage) {
      return function (pageSize) {
          return function (totalRecords) {
              var start = ((currPage - 1 | 0) * pageSizes2Int(pageSize) | 0) + 1 | 0;
              var end$prime = currPage * pageSizes2Int(pageSize) | 0;
              var end = (function () {
                  var $39 = end$prime > totalRecords;
                  if ($39) {
                      return totalRecords;
                  };
                  return end$prime;
              })();
              var msg = "Showing " + (Data_Show.show(Data_Show.showInt)(start) + (" to " + (Data_Show.show(Data_Show.showInt)(end) + (" of " + Data_Show.show(Data_Show.showInt)(totalRecords)))));
              return Reactix_DOM_HTML.div({
                  className: "row1"
              })([ Reactix_DOM_HTML.div({
                  className: ""
              })([ Reactix_DOM_HTML.text(msg) ]) ]);
          };
      };
  };
  var pageSizes = [ PS10.value, PS20.value, PS50.value, PS100.value, PS200.value ];
  var makeRow = function (els) {
      return Reactix_DOM_HTML.tr({})(Data_Functor.map(Data_Functor.functorArray)(function (c) {
          return Reactix_DOM_HTML.td({})([ c ]);
      })(els));
  };
  var int2PageSizes = function (i) {
      return string2PageSize(Data_Show.show(Data_Show.showInt)(i));
  };
  var paramsState = function (v) {
      var pageSize = int2PageSizes(v.limit);
      var page = Data_EuclideanRing.div(Data_EuclideanRing.euclideanRingInt)(v.offset)(v.limit) + 1 | 0;
      return {
          pageSize: pageSize,
          page: page,
          orderBy: v.orderBy,
          searchType: v.searchType
      };
  };
  var initialParams = stateParams({
      page: 1,
      pageSize: PS10.value,
      orderBy: Data_Maybe.Nothing.value,
      searchType: Gargantext_Components_Search.SearchDoc.value
  });
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Table");
  var tableHeaderLayoutCpt = (function () {
      var cacheToggle = function (v) {
          if (v instanceof Gargantext_Components_Nodes_Lists_Types.CacheOn) {
              return "fa-toggle-on";
          };
          if (v instanceof Gargantext_Components_Nodes_Lists_Types.CacheOff) {
              return "fa-toggle-off";
          };
          throw new Error("Failed pattern match at Gargantext.Components.Table (line 103, column 5 - line 103, column 44): " + [ v.constructor.name ]);
      };
      var cacheText = function (v) {
          if (v instanceof Gargantext_Components_Nodes_Lists_Types.CacheOn) {
              return "Cache On";
          };
          if (v instanceof Gargantext_Components_Nodes_Lists_Types.CacheOff) {
              return "Cache Off";
          };
          throw new Error("Failed pattern match at Gargantext.Components.Table (line 106, column 5 - line 106, column 38): " + [ v.constructor.name ]);
      };
      var cacheStateToggle = function (v) {
          if (v instanceof Gargantext_Components_Nodes_Lists_Types.CacheOn) {
              return Gargantext_Components_Nodes_Lists_Types.CacheOff.value;
          };
          if (v instanceof Gargantext_Components_Nodes_Lists_Types.CacheOff) {
              return Gargantext_Components_Nodes_Lists_Types.CacheOn.value;
          };
          throw new Error("Failed pattern match at Gargantext.Components.Table (line 112, column 5 - line 112, column 46): " + [ v.constructor.name ]);
      };
      var cacheClick = function (cacheState) {
          return function (v) {
              return Toestand_Classes.modify(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(cacheStateToggle)(cacheState);
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Nodes_Lists_Types["$_EqCacheState_4"]))(v.cacheState))(function (cacheState$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ Gargantext_Utils_Reactix.row([ Gargantext_Components_FolderView.backButton, Gargantext_Components_FolderView.homeButton ]), Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.div({
                      className: "col-md-3"
                  })([ Reactix_DOM_HTML.h3({})([ Reactix_DOM_HTML.text(v.title) ]) ]), Reactix_DOM_HTML.div({
                      className: "col-md-9"
                  })([ Reactix_DOM_HTML.hr({
                      style: {
                          height: "2px",
                          backgroundColor: "black"
                      }
                  }) ]) ]), Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.div({
                      className: "col-md-8 content"
                  })([ Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.span({
                      className: "fa fa-globe"
                  })([  ]), Reactix_DOM_HTML.text(" " + v.desc) ]), Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.span({
                      className: "fa fa-search-plus"
                  })([  ]), Reactix_DOM_HTML.text(" " + v.query) ]), Reactix_DOM_HTML.p({
                      className: "cache-toggle",
                      on: {
                          click: cacheClick(v.cacheState)
                      }
                  })([ Reactix_DOM_HTML.span({
                      className: "fa " + cacheToggle(cacheState$prime)
                  })([  ]), Reactix_DOM_HTML.text(cacheText(cacheState$prime)) ]) ]), Reactix_DOM_HTML.div({
                      className: "col-md-4 content"
                  })([ Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.span({
                      className: "fa fa-calendar"
                  })([  ]), Reactix_DOM_HTML.text(" " + v.date) ]), Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.span({
                      className: "fa fa-user"
                  })([  ]), Reactix_DOM_HTML.text(" " + v.user) ]) ]) ]) ]));
              });
          };
      };
      return here.component("tableHeaderLayout")(cpt);
  })();
  var tableHeaderLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(tableHeaderLayoutCpt);
  var graphContainer = function (v) {
      return function (props) {
          return Reactix_DOM_HTML.table({
              className: "table"
          })([ Reactix_DOM_HTML.thead({
              className: ""
          })([ props.tableHead ]), Reactix_DOM_HTML.tbody({})(props.tableBody) ]);
      };
  };
  var filterRows = function (v) {
      return function (rs) {
          var newRs = Data_Sequence.take(v.params.limit)(Data_Sequence.drop(v.params.offset)(rs));
          return newRs;
      };
  };
  var defaultContainer = function (v) {
      return function (props) {
          var controls = [ Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.div({
              className: "col-md-4"
          })([ props.pageSizeDescription ]), Reactix_DOM_HTML.div({
              className: "col-md-4"
          })([ props.paginationLinks ]), Reactix_DOM_HTML.div({
              className: "col-md-4"
          })([ props.pageSizeControl ]) ]), Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.table({
              className: "col-md-12 table"
          })([ Reactix_DOM_HTML.thead({
              className: ""
          })([ props.tableHead ]), Reactix_DOM_HTML.tbody({})(props.tableBody) ]) ]) ];
          return Reactix_React.fragment(Data_Semigroup.append(Data_Semigroup.semigroupArray)(props.syncResetButton)(controls));
      };
  };
  var changePage = function (page) {
      return function (params) {
          return Data_Functor["void"](Effect.functorEffect)(Toestand_Classes.modify(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (p) {
              return stateParams((function () {
                  var v = paramsState(p);
                  return {
                      page: page,
                      pageSize: v.pageSize,
                      orderBy: v.orderBy,
                      searchType: v.searchType
                  };
              })());
          })(params));
      };
  };
  var paginationCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var changePageLink = function (i) {
                  return function (s) {
                      return Reactix_DOM_HTML.span({})([ Reactix_DOM_HTML.text(" "), Gargantext_Utils_Reactix.effectLink(changePage(i)(v.params))(s), Reactix_DOM_HTML.text(" ") ]);
                  };
              };
              var changePageLink$prime = function (i) {
                  return changePageLink(i)(Data_Show.show(Data_Show.showInt)(i));
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "searchType";
              }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                  return "orderBy";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                  return "offset";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "limit";
              }))(Data_Eq.eqInt))))(v.params))(function (params$prime) {
                  var v2 = paramsState(params$prime);
                  var rnums = Data_Functor.map(Data_Functor.functorArray)(changePageLink$prime)(Data_Array.filter(function (v3) {
                      return v.totalPages > v3;
                  })([ v2.page + 1 | 0, v2.page + 2 | 0 ]));
                  var rdots = (function () {
                      var $71 = (v2.page + 3 | 0) < v.totalPages;
                      if ($71) {
                          return Reactix_DOM_HTML.text(" ... ");
                      };
                      return Reactix_DOM_HTML.text("");
                  })();
                  var prev = (function () {
                      var $72 = v2.page === 1;
                      if ($72) {
                          return Reactix_DOM_HTML.text(" Prev. ");
                      };
                      return changePageLink(v2.page - 1 | 0)("Prev.");
                  })();
                  var next = (function () {
                      var $73 = v2.page === v.totalPages;
                      if ($73) {
                          return Reactix_DOM_HTML.text(" Next ");
                      };
                      return changePageLink(v2.page + 1 | 0)("Next");
                  })();
                  var lnums = Data_Functor.map(Data_Functor.functorArray)(changePageLink$prime)(Data_Array.filter(function (v3) {
                      return 1 < v3;
                  })([ v2.page - 2 | 0, v2.page - 1 | 0 ]));
                  var ldots = (function () {
                      var $74 = v2.page >= 5;
                      if ($74) {
                          return Reactix_DOM_HTML.text(" ... ");
                      };
                      return Reactix_DOM_HTML.text("");
                  })();
                  var last = (function () {
                      var $75 = v2.page === v.totalPages;
                      if ($75) {
                          return Reactix_DOM_HTML.text("");
                      };
                      return changePageLink$prime(v.totalPages);
                  })();
                  var first = (function () {
                      var $76 = v2.page === 1;
                      if ($76) {
                          return Reactix_DOM_HTML.text("");
                      };
                      return changePageLink$prime(1);
                  })();
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.span({})(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ Reactix_DOM_HTML.text(" "), prev, first, ldots ])(Data_Semigroup.append(Data_Semigroup.semigroupArray)(lnums)(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ Reactix_DOM_HTML.b({})([ Reactix_DOM_HTML.text(" " + (Data_Show.show(Data_Show.showInt)(v2.page) + " ")) ]) ])(Data_Semigroup.append(Data_Semigroup.semigroupArray)(rnums)([ rdots, last, next ]))))));
              });
          };
      };
      return here.component("pagination")(cpt);
  })();
  var pagination = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(paginationCpt)(props)([  ]);
  };
  var $dollar_ShowPageSizes_29 = new Data_Show.Show(function (v) {
      if (v instanceof PS10) {
          return "10";
      };
      if (v instanceof PS20) {
          return "20";
      };
      if (v instanceof PS50) {
          return "50";
      };
      if (v instanceof PS100) {
          return "100";
      };
      if (v instanceof PS200) {
          return "200";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Table (line 303, column 1 - line 308, column 21): " + [ v.constructor.name ]);
  });
  var sizeDDCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var option = function (size) {
                  var value = Data_Show.show($dollar_ShowPageSizes_29)(size);
                  return Reactix_DOM_HTML.option({
                      value: value
                  })([ Reactix_DOM_HTML.text(value) ]);
              };
              var sizes = Data_Functor.map(Data_Functor.functorArray)(option)(pageSizes);
              var change = function (e) {
                  var ps = string2PageSize(Reactix_SyntheticEvent.unsafeEventValue(e));
                  return Toestand_Classes.modify(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (p) {
                      return stateParams((function () {
                          var v2 = paramsState(p);
                          return {
                              page: v2.page,
                              pageSize: ps,
                              orderBy: v2.orderBy,
                              searchType: v2.searchType
                          };
                      })());
                  })(v.params);
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "searchType";
              }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                  return "orderBy";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                  return "offset";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "limit";
              }))(Data_Eq.eqInt))))(v.params))(function (params$prime) {
                  var v2 = paramsState(params$prime);
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.span({})([ Gargantext_Utils_Reactix.select({
                      className: "form-control",
                      defaultValue: Data_Show.show($dollar_ShowPageSizes_29)(v2.pageSize),
                      on: {
                          change: change
                      }
                  })(sizes) ]));
              });
          };
      };
      return here.component("sizeDD")(cpt);
  })();
  var sizeDD = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(sizeDDCpt)(p)([  ]);
  };
  var tableCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "searchType";
              }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                  return "orderBy";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                  return "offset";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "limit";
              }))(Data_Eq.eqInt))))(v.params))(function (params$prime) {
                  var state = paramsState(params$prime);
                  var ps = pageSizes2Int(state.pageSize);
                  var totalPages = Data_EuclideanRing.div(Data_EuclideanRing.euclideanRingInt)(v.totalRecords)(ps) + Data_Ord.min(Data_Ord.ordInt)(1)(Data_EuclideanRing.mod(Data_EuclideanRing.euclideanRingInt)(v.totalRecords)(ps)) | 0;
                  var colHeader = function (c) {
                      var lnk = function (mc) {
                          return Gargantext_Utils_Reactix.effectLink(Data_Functor["void"](Effect.functorEffect)(Toestand_Classes.modify(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v2) {
                              var $88 = {};
                              for (var $89 in v2) {
                                  if ({}.hasOwnProperty.call(v2, $89)) {
                                      $88[$89] = v2[$89];
                                  };
                              };
                              $88.orderBy = mc;
                              return $88;
                          })(v.params)));
                      };
                      var cs = v.wrapColElts(c)((function () {
                          if (state.orderBy instanceof Data_Maybe.Just && (state.orderBy.value0 instanceof Gargantext_Components_Table_Types.ASC && Data_Eq.eq(Gargantext_Components_Table_Types["$_EqColumnName_22"])(c)(state.orderBy.value0.value0))) {
                              return [ lnk(new Data_Maybe.Just(new Gargantext_Components_Table_Types.DESC(c)))("ASC "), lnk(Data_Maybe.Nothing.value)(Gargantext_Components_Table_Types.columnName(c)) ];
                          };
                          if (state.orderBy instanceof Data_Maybe.Just && (state.orderBy.value0 instanceof Gargantext_Components_Table_Types.DESC && Data_Eq.eq(Gargantext_Components_Table_Types["$_EqColumnName_22"])(c)(state.orderBy.value0.value0))) {
                              return [ lnk(new Data_Maybe.Just(new Gargantext_Components_Table_Types.ASC(c)))("DESC "), lnk(Data_Maybe.Nothing.value)(Gargantext_Components_Table_Types.columnName(c)) ];
                          };
                          return [ lnk(new Data_Maybe.Just(new Gargantext_Components_Table_Types.ASC(c)))(Gargantext_Components_Table_Types.columnName(c)) ];
                      })());
                      return Reactix_DOM_HTML.th({
                          scope: "col"
                      })([ Reactix_DOM_HTML.b({})(cs) ]);
                  };
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(v.container({
                      pageSizeControl: sizeDD({
                          params: v.params
                      }),
                      pageSizeDescription: textDescription(state.page)(state.pageSize)(v.totalRecords),
                      paginationLinks: pagination({
                          params: v.params,
                          totalPages: totalPages
                      }),
                      syncResetButton: v.syncResetButton,
                      tableBody: Data_Functor.map(Data_Functor.functorArray)(function (v2) {
                          return v2.row;
                      })(Data_Array.fromFoldable(Data_Sequence.foldableSeq)(v.rows)),
                      tableHead: Reactix_DOM_HTML.tr({})(Data_Functor.map(Data_Functor.functorArray)(colHeader)(v.colNames))
                  }));
              });
          };
      };
      return here.component("table")(cpt);
  })();
  var table = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(tableCpt)(props)([  ]);
  };
  exports["initialParams"] = initialParams;
  exports["tableHeaderLayout"] = tableHeaderLayout;
  exports["table"] = table;
  exports["makeRow"] = makeRow;
  exports["filterRows"] = filterRows;
  exports["defaultContainer"] = defaultContainer;
  exports["graphContainer"] = graphContainer;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.KarpRabin"] = $PS["Gargantext.Utils.KarpRabin"] || {};
  var exports = $PS["Gargantext.Utils.KarpRabin"];
  var Data_Array = $PS["Data.Array"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Enum = $PS["Data.Enum"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Int = $PS["Data.Int"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ring = $PS["Data.Ring"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Semiring = $PS["Data.Semiring"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_UInt = $PS["Data.UInt"];                
  var minimum1 = function (dictOrd) {
      return function (dictFoldable) {
          return function (a) {
              return function (fa) {
                  var v = Data_Foldable.minimum(dictOrd)(dictFoldable)(fa);
                  if (v instanceof Data_Maybe.Nothing) {
                      return a;
                  };
                  if (v instanceof Data_Maybe.Just) {
                      return Data_Ord.min(dictOrd)(a)(v.value0);
                  };
                  throw new Error("Failed pattern match at Gargantext.Utils.KarpRabin (line 116, column 3 - line 118, column 23): " + [ v.constructor.name ]);
              };
          };
      };
  };
  var fromCodePoint = function (c) {
      return Data_UInt.fromInt(Data_Enum.fromEnum(Data_String_CodePoints.boundedEnumCodePoint)(c));
  };
  var rehash$prime = function (shDi) {
      return function (out) {
          return function (h) {
              return function (o) {
                  return function (n) {
                      return Data_Semiring.add(Data_UInt.uintSemiring)(Data_Ring.sub(Data_UInt.uintRing)(Data_UInt.shl(h)(shDi))(Data_UInt.shl(fromCodePoint(o))(out)))(fromCodePoint(n));
                  };
              };
          };
      };
  };
  var strictMatcher = function (pats) {
      var patNum = Data_Array.length(pats);
      var hLen = minimum1(Data_Ord.ordInt)(Data_Foldable.foldableArray)(32)(Data_Functor.map(Data_Functor.functorArray)(Data_String_CodePoints.length)(pats));
      var hLen$prime = Data_UInt.fromInt(hLen);
      var shDi = (function () {
          var v = Data_Int.quot(32)(hLen);
          if (v < 4) {
              return v;
          };
          if (Data_Boolean.otherwise) {
              return 4;
          };
          throw new Error("Failed pattern match at Gargantext.Utils.KarpRabin (line 125, column 12 - line 127, column 33): " + [ v.constructor.name ]);
      })();
      var hash = (function () {
          var $19 = Data_Foldable.foldl(Data_Foldable.foldableArray)(function (h) {
              return function (w) {
                  return Data_Semiring.add(Data_UInt.uintSemiring)(Data_UInt.shl(h)(Data_UInt.fromInt(shDi)))(fromCodePoint(w));
              };
          })(Data_UInt.fromInt(0));
          var $20 = Data_String_CodePoints.take(hLen);
          return function ($21) {
              return $19(Data_String_CodePoints.toCodePointArray($20($21)));
          };
      })();
      var hashMap = Data_Map_Internal.fromFoldableWith(Data_UInt.uintOrd)(Data_Foldable.foldableArray)(Data_Function.flip(Data_Semigroup.append(Data_Semigroup.semigroupArray)))(Data_Array.mapWithIndex(function (i) {
          return function (a) {
              return new Data_Tuple.Tuple(hash(a), [ i ]);
          };
      })(pats));
      var outS = Data_UInt.fromInt(shDi * hLen | 0);
      var rehash = (function () {
          if (shDi === 1) {
              return rehash$prime(Data_UInt.fromInt(1))(hLen$prime);
          };
          if (shDi === 2) {
              return rehash$prime(Data_UInt.fromInt(2))(outS);
          };
          if (shDi === 3) {
              return rehash$prime(Data_UInt.fromInt(3))(outS);
          };
          return rehash$prime(Data_UInt.fromInt(4))(outS);
      })();
      var search = function (dictPartial) {
          return function (str) {
              var strLen = Data_String_CodePoints.length(str);
              var shash = hash(str);
              var maxIdx = strLen - hLen | 0;
              var arr = Data_String_CodePoints.toCodePointArray(str);
              var strAt = function (i) {
                  return arr[i];
              };
              var go = function (sI) {
                  return function (h) {
                      var v = Data_Map_Internal.lookup(Data_UInt.uintOrd)(h)(hashMap);
                      if (v instanceof Data_Maybe.Nothing) {
                          var $13 = sI === maxIdx;
                          if ($13) {
                              return Data_List_Types.Nil.value;
                          };
                          return go(sI + 1 | 0)(rehash(h)(strAt(sI))(strAt(sI + hLen | 0)));
                      };
                      if (v instanceof Data_Maybe.Just) {
                          var rst = Data_String_CodePoints.drop(sI)(str);
                          var okay = function (bs) {
                              return Data_Maybe.isJust(Data_String_CodeUnits.stripPrefix(bs)(rst));
                          };
                          var hd = strAt(sI);
                          var more = (function () {
                              var $14 = sI === maxIdx;
                              if ($14) {
                                  return Data_List_Types.Nil.value;
                              };
                              return go(sI + 1 | 0)(rehash(h)(hd)(strAt(sI + hLen | 0)));
                          })();
                          var v1 = Data_Array.filter(function (x) {
                              return okay(pats[x]);
                          })(v.value0);
                          if (v1.length === 0) {
                              return more;
                          };
                          return new Data_List_Types.Cons(new Data_Tuple.Tuple(sI, v1), more);
                      };
                      throw new Error("Failed pattern match at Gargantext.Utils.KarpRabin (line 153, column 15 - line 167, column 54): " + [ v.constructor.name ]);
                  };
              };
              var $17 = strLen < hLen;
              if ($17) {
                  return [  ];
              };
              return Data_Array.fromFoldable(Data_List_Types.foldableList)(go(0)(shash));
          };
      };
      return search();
  };
  var indicesOfAny = function (pats) {
      var nepats = Data_Array.filter((function () {
          var $22 = Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean);
          return function ($23) {
              return $22(Data_String_Common["null"]($23));
          };
      })())(pats);
      var $18 = Data_Array["null"](nepats);
      if ($18) {
          return Data_Function["const"]([  ]);
      };
      return strictMatcher(nepats);
  };
  exports["indicesOfAny"] = indicesOfAny;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.NgramsTable.Core"] = $PS["Gargantext.Components.NgramsTable.Core"] || {};
  var exports = $PS["Gargantext.Components.NgramsTable.Core"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Control_Monad_State = $PS["Control.Monad.State"];
  var Control_Monad_State_Trans = $PS["Control.Monad.State.Trans"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var Data_Array = $PS["Data.Array"];
  var Data_Bifunctor = $PS["Data.Bifunctor"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Either = $PS["Data.Either"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_FoldableWithIndex = $PS["Data.FoldableWithIndex"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Lens_At = $PS["Data.Lens.At"];
  var Data_Lens_Fold = $PS["Data.Lens.Fold"];
  var Data_Lens_Getter = $PS["Data.Lens.Getter"];
  var Data_Lens_Index = $PS["Data.Lens.Index"];
  var Data_Lens_Internal_Forget = $PS["Data.Lens.Internal.Forget"];
  var Data_Lens_Iso_Newtype = $PS["Data.Lens.Iso.Newtype"];
  var Data_Lens_Prism_Maybe = $PS["Data.Lens.Prism.Maybe"];
  var Data_Lens_Record = $PS["Data.Lens.Record"];
  var Data_Lens_Setter = $PS["Data.Lens.Setter"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Map = $PS["Data.Map"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Maybe_First = $PS["Data.Maybe.First"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Monoid_Additive = $PS["Data.Monoid.Additive"];
  var Data_Monoid_Endo = $PS["Data.Monoid.Endo"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ord_Generic = $PS["Data.Ord.Generic"];
  var Data_Ordering = $PS["Data.Ordering"];
  var Data_Profunctor = $PS["Data.Profunctor"];
  var Data_Profunctor_Choice = $PS["Data.Profunctor.Choice"];
  var Data_Profunctor_Strong = $PS["Data.Profunctor.Strong"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Set = $PS["Data.Set"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_String_Regex = $PS["Data.String.Regex"];
  var Data_String_Regex_Flags = $PS["Data.String.Regex.Flags"];
  var Data_String_Utils = $PS["Data.String.Utils"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Data_TraversableWithIndex = $PS["Data.TraversableWithIndex"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Effect_Exception_Unsafe = $PS["Effect.Exception.Unsafe"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
  var Foreign = $PS["Foreign"];
  var Foreign_Object = $PS["Foreign.Object"];
  var Gargantext_AsyncTasks = $PS["Gargantext.AsyncTasks"];
  var Gargantext_Components_Table = $PS["Gargantext.Components.Table"];
  var Gargantext_Components_Table_Types = $PS["Gargantext.Components.Table.Types"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_KarpRabin = $PS["Gargantext.Utils.KarpRabin"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Partial = $PS["Partial"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var Keep = (function () {
      function Keep() {

      };
      Keep.value = new Keep();
      return Keep;
  })();
  var Replace = (function () {
      function Replace(value0) {
          this.value0 = value0;
      };
      Replace.create = function (value0) {
          return new Replace(value0);
      };
      return Replace;
  })();
  var PatchMap = function (x) {
      return x;
  };
  var NormNgramsTerm = function (x) {
      return x;
  };
  var NgramsRepoElement = function (x) {
      return x;
  };
  var NgramsTable = function (x) {
      return x;
  };
  var NgramsReplace = (function () {
      function NgramsReplace(value0) {
          this.value0 = value0;
      };
      NgramsReplace.create = function (value0) {
          return new NgramsReplace(value0);
      };
      return NgramsReplace;
  })();
  var NgramsPatch = (function () {
      function NgramsPatch(value0) {
          this.value0 = value0;
      };
      NgramsPatch.create = function (value0) {
          return new NgramsPatch(value0);
      };
      return NgramsPatch;
  })();
  var NgramsElement = function (x) {
      return x;
  };
  var CommitPatch = (function () {
      function CommitPatch(value0) {
          this.value0 = value0;
      };
      CommitPatch.create = function (value0) {
          return new CommitPatch(value0);
      };
      return CommitPatch;
  })();
  var Synchronize = (function () {
      function Synchronize(value0) {
          this.value0 = value0;
      };
      Synchronize.create = function (value0) {
          return new Synchronize(value0);
      };
      return Synchronize;
  })();
  var ResetPatches = (function () {
      function ResetPatches() {

      };
      ResetPatches.value = new ResetPatches();
      return ResetPatches;
  })();
  var CoreAction = (function () {
      function CoreAction(value0) {
          this.value0 = value0;
      };
      CoreAction.create = function (value0) {
          return new CoreAction(value0);
      };
      return CoreAction;
  })();
  var SetParentResetChildren = (function () {
      function SetParentResetChildren(value0) {
          this.value0 = value0;
      };
      SetParentResetChildren.create = function (value0) {
          return new SetParentResetChildren(value0);
      };
      return SetParentResetChildren;
  })();
  var ToggleChild = (function () {
      function ToggleChild(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      ToggleChild.create = function (value0) {
          return function (value1) {
              return new ToggleChild(value0, value1);
          };
      };
      return ToggleChild;
  })();
  var AddTermChildren = (function () {
      function AddTermChildren() {

      };
      AddTermChildren.value = new AddTermChildren();
      return AddTermChildren;
  })();
  var ToggleSelect = (function () {
      function ToggleSelect(value0) {
          this.value0 = value0;
      };
      ToggleSelect.create = function (value0) {
          return new ToggleSelect(value0);
      };
      return ToggleSelect;
  })();
  var ToggleSelectAll = (function () {
      function ToggleSelectAll() {

      };
      ToggleSelectAll.value = new ToggleSelectAll();
      return ToggleSelectAll;
  })();
  var wordBoundaryChars = "[ .,;:!?'\\{}()]";
  var wordBoundaryReg = (function () {
      var v = Data_String_Regex.regex("(" + (wordBoundaryChars + ")"))(Data_Semigroup.append(Data_String_Regex_Flags.semigroupRegexFlags)(Data_String_Regex_Flags.global)(Data_String_Regex_Flags.multiline));
      if (v instanceof Data_Either.Left) {
          return Partial.crashWith()(v.value0);
      };
      if (v instanceof Data_Either.Right) {
          return v.value0;
      };
      throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 488, column 19 - line 490, column 15): " + [ v.constructor.name ]);
  })();
  var wordBoundaryReg2 = (function () {
      var v = Data_String_Regex.regex("(" + (wordBoundaryChars + ")\\1"))(Data_Semigroup.append(Data_String_Regex_Flags.semigroupRegexFlags)(Data_String_Regex_Flags.global)(Data_String_Regex_Flags.multiline));
      if (v instanceof Data_Either.Left) {
          return Partial.crashWith()(v.value0);
      };
      if (v instanceof Data_Either.Right) {
          return v.value0;
      };
      throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 493, column 20 - line 495, column 15): " + [ v.constructor.name ]);
  })();
  var toVersioned = function (v) {
      return Data_Tuple.Tuple.create(v.count)({
          data: v.data,
          version: v.version
      });
  };
  var singletonPatchMap = function (k) {
      return function (p) {
          return Data_Map_Internal.singleton(k)(p);
      };
  };
  var replace = function (dictEq) {
      return function (old) {
          return function ($$new) {
              if (Data_Eq.eq(dictEq)(old)($$new)) {
                  return Keep.value;
              };
              if (Data_Boolean.otherwise) {
                  return new Replace({
                      old: old,
                      "new": $$new
                  });
              };
              throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 574, column 1 - line 574, column 49): " + [ old.constructor.name, $$new.constructor.name ]);
          };
      };
  };
  var reRootMaxDepth = 100;
  var patchSetFromMap = function (dictOrd) {
      return function (m) {
          return {
              rem: Data_Map.keys(Data_Map_Internal.filter(dictOrd)(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(m)),
              add: Data_Map.keys(Data_Map_Internal.filter(dictOrd)(Control_Category.identity(Control_Category.categoryFn))(m))
          };
      };
  };
  var normNgramInternal = function (v) {
      if (v instanceof Gargantext_Types.CTabAuthors) {
          return Control_Category.identity(Control_Category.categoryFn);
      };
      if (v instanceof Gargantext_Types.CTabSources) {
          return Control_Category.identity(Control_Category.categoryFn);
      };
      if (v instanceof Gargantext_Types.CTabInstitutes) {
          return Control_Category.identity(Control_Category.categoryFn);
      };
      if (v instanceof Gargantext_Types.CTabTerms) {
          var $620 = Data_String_Regex.replace(wordBoundaryReg)(" ");
          return function ($621) {
              return Data_String_Common.toLower($620($621));
          };
      };
      throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 299, column 1 - line 299, column 55): " + [ v.constructor.name ]);
  };
  var normNgramWithTrim = function (nt) {
      var $622 = normNgramInternal(nt);
      return function ($623) {
          return Data_String_Common.trim($622($623));
      };
  };
  var normNgram = function (tabType) {
      var $624 = normNgramWithTrim(tabType);
      return function ($625) {
          return NormNgramsTerm($624($625));
      };
  };
  var ngramsTermText = function (v) {
      return v;
  };
  var ngramsRepoElementToNgramsElement = function (ngrams) {
      return function (occurrences) {
          return function (v) {
              return {
                  children: v.children,
                  list: v.list,
                  ngrams: ngrams,
                  occurrences: occurrences,
                  parent: v.parent,
                  root: v.root,
                  size: v.size
              };
          };
      };
  };
  var ngramsReplace = function (patch_old) {
      return function (patch_new) {
          return new NgramsReplace({
              patch_old: patch_old,
              patch_new: patch_new
          });
      };
  };
  var isSingleNgramsTerm = function (nt) {
      var isSingleTerm = function (s) {
          var words = Data_Array.filter(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraFunction(Data_HeytingAlgebra.heytingAlgebraBoolean))(Data_String_Common["null"]))(Data_Functor.map(Data_Functor.functorArray)(Data_String_Common.trim)(Data_String_Utils.words(s)));
          return Data_Array.length(words) === 1;
      };
      return isSingleTerm(ngramsTermText(nt));
  };
  var isEmptyPatchMap = function (v) {
      return Data_Map_Internal.isEmpty(v);
  };
  var isEmptyNgramsTablePatch = function (v) {
      return isEmptyPatchMap(v.ngramsPatches);
  };
  var invert = function (v) {
      return Effect_Exception_Unsafe.unsafeThrow("invert: TODO");
  };
  var initialPageParams = function (session) {
      return function (nodeId) {
          return function (listIds) {
              return function (tabType) {
                  var params = {
                      orderBy: new Data_Maybe.Just(Gargantext_Components_Table_Types.DESC.create("Score")),
                      limit: Gargantext_Components_Table.initialParams.limit,
                      offset: Gargantext_Components_Table.initialParams.offset,
                      searchType: Gargantext_Components_Table.initialParams.searchType
                  };
                  return {
                      listIds: listIds,
                      nodeId: nodeId,
                      params: params,
                      tabType: tabType,
                      termSizeFilter: Data_Maybe.Nothing.value,
                      termListFilter: new Data_Maybe.Just(Gargantext_Types.MapTerm.value),
                      searchQuery: "",
                      scoreType: Gargantext_Types.Occurrences.value,
                      session: session
                  };
              };
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.NgramsTable.Core");
  var fromNgramsPatches = function (ngramsPatches) {
      return {
          ngramsPatches: ngramsPatches
      };
  };
  var singletonNgramsTablePatch = function (n) {
      return function (p) {
          return fromNgramsPatches(singletonPatchMap(n)(p));
      };
  };
  var fromMap = function (dictOrd) {
      return function (dictEq) {
          return function (dictMonoid) {
              var $626 = Data_Map_Internal.filter(dictOrd)(function (v) {
                  return Data_Eq.notEq(dictEq)(v)(Data_Monoid.mempty(dictMonoid));
              });
              return function ($627) {
                  return PatchMap($626($627));
              };
          };
      };
  };
  var traversePatchMapWithIndex = function (dictApplicative) {
      return function (dictOrd) {
          return function (dictEq) {
              return function (dictMonoid) {
                  return function (f) {
                      return function (v) {
                          return Data_Functor.map((dictApplicative.Apply0()).Functor0())(fromMap(dictOrd)(dictEq)(dictMonoid))(Data_TraversableWithIndex.traverseWithIndex(Data_Map_Internal.traversableWithIndexMap)(dictApplicative)(f)(v));
                      };
                  };
              };
          };
      };
  };
  var filterTermSize = function (v) {
      return function (v1) {
          if (v instanceof Data_Maybe.Just && v.value0 instanceof Gargantext_Types.MonoTerm) {
              return isSingleNgramsTerm(v1);
          };
          if (v instanceof Data_Maybe.Just && v.value0 instanceof Gargantext_Types.MultiTerm) {
              return !isSingleNgramsTerm(v1);
          };
          return true;
      };
  };
  var convOrderBy = function (v) {
      if (v instanceof Gargantext_Components_Table_Types.ASC && v.value0 === "Score") {
          return Gargantext_Types.ScoreAsc.value;
      };
      if (v instanceof Gargantext_Components_Table_Types.DESC && v.value0 === "Score") {
          return Gargantext_Types.ScoreDesc.value;
      };
      if (v instanceof Gargantext_Components_Table_Types.ASC) {
          return Gargantext_Types.TermAsc.value;
      };
      if (v instanceof Gargantext_Components_Table_Types.DESC) {
          return Gargantext_Types.TermDesc.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 1005, column 1 - line 1005, column 58): " + [ v.constructor.name ]);
  };
  var applyReplace = function (dictEq) {
      return function (v) {
          return function (a) {
              if (v instanceof Keep) {
                  return a;
              };
              if (v instanceof Replace) {
                  if (Data_Eq.eq(dictEq)(a)(v.value0.old)) {
                      return v["value0"]["new"];
                  };
                  if (Data_Boolean.otherwise) {
                      return a;
                  };
              };
              throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 589, column 1 - line 589, column 54): " + [ v.constructor.name, a.constructor.name ]);
          };
      };
  };
  var applyPatchSet = function (dictOrd) {
      return function (v) {
          return function (s) {
              return Data_Semigroup.append(Data_Set.semigroupSet(dictOrd))(Data_Set.difference(dictOrd)(s)(v.rem))(v.add);
          };
      };
  };
  var applyPatchMap = function (dictOrd) {
      return function (applyPatchValue) {
          return function (v) {
              return function (m) {
                  var go = function (m$prime) {
                      return function (v1) {
                          return Data_Map_Internal.alter(dictOrd)(applyPatchValue(v1.value1))(v1.value0)(m$prime);
                      };
                  };
                  return Data_Foldable.foldl(Data_List_Types.foldableList)(go)(m)(Data_Map_Internal.toUnfoldable(Data_List_Types.unfoldableList)(v));
              };
          };
      };
  };
  var _root = function (dictStrong) {
      return Data_Lens_Record.prop(new Data_Symbol.IsSymbol(function () {
          return "root";
      }))()()(Data_Symbol.SProxy.value)(dictStrong);
  };
  var _parent = function (dictStrong) {
      return Data_Lens_Record.prop(new Data_Symbol.IsSymbol(function () {
          return "parent";
      }))()()(Data_Symbol.SProxy.value)(dictStrong);
  };
  var _occurrences = function (dictStrong) {
      return Data_Lens_Record.prop(new Data_Symbol.IsSymbol(function () {
          return "occurrences";
      }))()()(Data_Symbol.SProxy.value)(dictStrong);
  };
  var _ngrams_scores = function (dictStrong) {
      return Data_Lens_Record.prop(new Data_Symbol.IsSymbol(function () {
          return "ngrams_scores";
      }))()()(Data_Symbol.SProxy.value)(dictStrong);
  };
  var _ngrams_repo_elements = function (dictStrong) {
      return Data_Lens_Record.prop(new Data_Symbol.IsSymbol(function () {
          return "ngrams_repo_elements";
      }))()()(Data_Symbol.SProxy.value)(dictStrong);
  };
  var _ngrams = function (dictStrong) {
      return Data_Lens_Record.prop(new Data_Symbol.IsSymbol(function () {
          return "ngrams";
      }))()()(Data_Symbol.SProxy.value)(dictStrong);
  };
  var _list = function (dictStrong) {
      return Data_Lens_Record.prop(new Data_Symbol.IsSymbol(function () {
          return "list";
      }))()()(Data_Symbol.SProxy.value)(dictStrong);
  };
  var _children = function (dictStrong) {
      return Data_Lens_Record.prop(new Data_Symbol.IsSymbol(function () {
          return "children";
      }))()()(Data_Symbol.SProxy.value)(dictStrong);
  };
  var $dollar_WriteForeignVersioned_145 = function (dictWriteForeign) {
      return Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "data";
      }))(dictWriteForeign)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "version";
      }))(Simple_JSON.writeForeignInt)(Simple_JSON.nilWriteForeignFields)()()())()()());
  };
  var $dollar_WriteForeignReplace_193 = function (dictWriteForeign) {
      return new Simple_JSON.WriteForeign(function (v) {
          if (v instanceof Keep) {
              return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                  return "tag";
              }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()()))({
                  tag: "Keep"
              });
          };
          if (v instanceof Replace) {
              return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                  return "new";
              }))(dictWriteForeign)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                  return "old";
              }))(dictWriteForeign)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                  return "tag";
              }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()())()()()))({
                  old: v.value0.old,
                  "new": v["value0"]["new"],
                  tag: "Replace"
              });
          };
          throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 595, column 1 - line 597, column 79): " + [ v.constructor.name ]);
      });
  };
  var $dollar_WriteForeignPatchSet_199 = function (dictWriteForeign) {
      return new Simple_JSON.WriteForeign(function (v) {
          return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "add";
          }))(Simple_JSON.writeForeignArray(dictWriteForeign))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "rem";
          }))(Simple_JSON.writeForeignArray(dictWriteForeign))(Simple_JSON.nilWriteForeignFields)()()())()()()))({
              rem: Data_Set.toUnfoldable(Data_Unfoldable.unfoldableArray)(v.rem),
              add: Data_Set.toUnfoldable(Data_Unfoldable.unfoldableArray)(v.add)
          });
      });
  };
  var $dollar_WriteForeignPatchMapNgram_154 = function (dictWriteForeign) {
      return new Simple_JSON.WriteForeign(function (v) {
          return Simple_JSON.writeImpl(Simple_JSON.writeForeignObject(dictWriteForeign))(Foreign_Object.fromFoldable(Data_Foldable.foldableArray)(Data_Functor.map(Data_Functor.functorArray)(Data_Bifunctor.lmap(Data_Bifunctor.bifunctorTuple)(ngramsTermText))(Data_Map_Internal.toUnfoldable(Data_Unfoldable.unfoldableArray)(v))));
      });
  };
  var $dollar_WriteForeignNgramsTerm_168 = Simple_JSON.writeForeignString;
  var $dollar_WriteForeignNgramsRepoEle_180 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "children";
      }))(Simple_JSON.writeForeignArray($dollar_WriteForeignNgramsTerm_168))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "list";
      }))(Gargantext_Types["$_WriteForeignTermList_105"])(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "parent";
      }))(Simple_JSON.writeForeignMaybe($dollar_WriteForeignNgramsTerm_168))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "root";
      }))(Simple_JSON.writeForeignMaybe($dollar_WriteForeignNgramsTerm_168))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "size";
      }))(Simple_JSON.writeForeignInt)(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()()))({
          children: Data_Set.toUnfoldable(Data_Unfoldable.unfoldableArray)(v.children),
          list: v.list,
          parent: v.parent,
          root: v.root,
          size: v.size
      });
  });
  var $dollar_WriteForeignNgramsPatch_160 = new Simple_JSON.WriteForeign(function (v) {
      if (v instanceof NgramsReplace) {
          return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "patch_new";
          }))(Simple_JSON.writeForeignMaybe($dollar_WriteForeignNgramsRepoEle_180))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "patch_old";
          }))(Simple_JSON.writeForeignMaybe($dollar_WriteForeignNgramsRepoEle_180))(Simple_JSON.nilWriteForeignFields)()()())()()()))({
              patch_old: v.value0.patch_old,
              patch_new: v.value0.patch_new
          });
      };
      if (v instanceof NgramsPatch) {
          return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "patch_children";
          }))($dollar_WriteForeignPatchSet_199($dollar_WriteForeignNgramsTerm_168))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "patch_list";
          }))($dollar_WriteForeignReplace_193(Gargantext_Types["$_WriteForeignTermList_105"]))(Simple_JSON.nilWriteForeignFields)()()())()()()))({
              patch_children: v.value0.patch_children,
              patch_list: v.value0.patch_list
          });
      };
      throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 230, column 1 - line 232, column 105): " + [ v.constructor.name ]);
  });
  var $dollar_WriteForeignAsyncNgramsCh_208 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "list_id";
      }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignInt))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "tab_type";
      }))(Gargantext_Types["$_WriteForeignTabType_151"])(Simple_JSON.nilWriteForeignFields)()()())()()()))({
          list_id: v.listId,
          tab_type: v.tabType
      });
  });
  var postNgramsChartsAsync = function (v) {
      var putNgramsAsync = new Gargantext_Routes.PostNgramsChartsAsync(new Data_Maybe.Just(v.nodeId));
      var acu = {
          listId: Data_Array.head(v.listIds),
          tabType: v.tabType
      };
      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.post($dollar_WriteForeignAsyncNgramsCh_208)(Gargantext_Types["$_ReadForeignAsyncTask_167"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(putNgramsAsync)(acu))(function (task) {
          return Control_Applicative.pure(Effect_Aff.applicativeAff)({
              task: task,
              typ: Gargantext_Types.UpdateNgramsCharts.value
          });
      });
  };
  var chartsAfterSync = function (v) {
      return function (tasks) {
          return function (v1) {
              return Control_Bind.bind(Effect_Aff.bindAff)(postNgramsChartsAsync(v))(function (task) {
                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                      DOM_Simple_Console.log2("[chartsAfterSync] Synchronize task")(task)();
                      return Gargantext_AsyncTasks.insert(v.nodeId)(task)(tasks)();
                  });
              });
          };
      };
  };
  var $dollar_SemigroupReplace_191 = function (dictEq) {
      return new Data_Semigroup.Semigroup(function (v) {
          return function (v1) {
              if (v instanceof Keep) {
                  return v1;
              };
              if (v1 instanceof Keep) {
                  return v;
              };
              if (v instanceof Replace && (v1 instanceof Replace && Data_Eq.notEq(dictEq)(v.value0.old)(v1["value0"]["new"]))) {
                  return Effect_Exception_Unsafe.unsafeThrow("old != new");
              };
              if (v instanceof Replace && v1 instanceof Replace) {
                  return replace(dictEq)(v1.value0.old)(v["value0"]["new"]);
              };
              throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 581, column 1 - line 585, column 63): " + [ v.constructor.name, v1.constructor.name ]);
          };
      });
  };
  var $dollar_SemigroupPatchSet_197 = function (dictOrd) {
      return new Data_Semigroup.Semigroup(function (v) {
          return function (v1) {
              return {
                  rem: Data_Semigroup.append(Data_Set.semigroupSet(dictOrd))(v1.rem)(v.rem),
                  add: Data_Semigroup.append(Data_Set.semigroupSet(dictOrd))(Data_Set.difference(dictOrd)(v1.add)(v.rem))(v.add)
              };
          };
      });
  };
  var $dollar_SemigroupPatchMap_202 = function (dictOrd) {
      return function (dictEq) {
          return function (dictMonoid) {
              return new Data_Semigroup.Semigroup(function (v) {
                  return function (v1) {
                      return fromMap(dictOrd)(dictEq)(dictMonoid)(Data_Map_Internal.unionWith(dictOrd)(Data_Semigroup.append(dictMonoid.Semigroup0()))(v)(v1));
                  };
              });
          };
      };
  };
  var $dollar_ReadForeignVersioned_144 = function (dictReadForeign) {
      return Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "data";
      }))(dictReadForeign)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "version";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()());
  };
  var $dollar_ReadForeignVersionedWithC_149 = function (dictReadForeign) {
      return Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "count";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "data";
      }))(dictReadForeign)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "version";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()())()());
  };
  var $dollar_ReadForeignReplace_194 = function (dictReadForeign) {
      return function (dictEq) {
          return new Simple_JSON.ReadForeign(function (f) {
              return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                  return "new";
              }))(Simple_JSON.readMaybe(dictReadForeign))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                  return "old";
              }))(Simple_JSON.readMaybe(dictReadForeign))(Simple_JSON.readFieldsNil)()())()()))(f))(function (v) {
                  var v1 = new Data_Tuple.Tuple(v.old, v["new"]);
                  if (v1.value0 instanceof Data_Maybe.Just && v1.value1 instanceof Data_Maybe.Just) {
                      return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(replace(dictEq)(v1.value0.value0)(v1.value1.value0));
                  };
                  if (v1.value0 instanceof Data_Maybe.Nothing && v1.value1 instanceof Data_Maybe.Nothing) {
                      return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Keep.value);
                  };
                  return Foreign.fail(Data_Identity.monadIdentity)(new Foreign.ForeignError("decodeJsonReplace"));
              });
          });
      };
  };
  var $dollar_ReadForeignPatchSet_200 = function (dictOrd) {
      return function (dictReadForeign) {
          return new Simple_JSON.ReadForeign(function (f) {
              var mkSet = function (dictOrd1) {
                  return Data_Set.fromFoldable(Data_Foldable.foldableArray)(dictOrd1);
              };
              return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                  return "add";
              }))(Simple_JSON.readArray(dictReadForeign))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                  return "rem";
              }))(Simple_JSON.readArray(dictReadForeign))(Simple_JSON.readFieldsNil)()())()()))(f))(function (v) {
                  var rem = mkSet(dictOrd)(v.rem);
                  var add = mkSet(dictOrd)(v.add);
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))({
                      rem: rem,
                      add: add
                  });
              });
          });
      };
  };
  var $dollar_ReadForeignNgramsTerm_167 = Simple_JSON.readString;
  var _PatchMap = function (dictProfunctor) {
      return Data_Lens_Iso_Newtype["_Newtype"]()()(dictProfunctor);
  }; 
  var _NgramsTable = function (dictProfunctor) {
      return Data_Lens_Iso_Newtype["_Newtype"]()()(dictProfunctor);
  }; 
  var _NgramsRepoElement = function (dictProfunctor) {
      return Data_Lens_Iso_Newtype["_Newtype"]()()(dictProfunctor);
  }; 
  var _NgramsElement = function (dictProfunctor) {
      return Data_Lens_Iso_Newtype["_Newtype"]()()(dictProfunctor);
  }; 
  var $dollar_MonoidReplace_192 = function (dictEq) {
      return new Data_Monoid.Monoid(function () {
          return $dollar_SemigroupReplace_191(dictEq);
      }, Keep.value);
  };
  var $dollar_MonoidPatchSet_198 = function (dictOrd) {
      return new Data_Monoid.Monoid(function () {
          return $dollar_SemigroupPatchSet_197(dictOrd);
      }, {
          rem: Data_Set.empty,
          add: Data_Set.empty
      });
  };
  var $dollar_MonoidPatchMap_203 = function (dictOrd) {
      return function (dictEq) {
          return function (dictMonoid) {
              return new Data_Monoid.Monoid(function () {
                  return $dollar_SemigroupPatchMap_202(dictOrd)(dictEq)(dictMonoid);
              }, Data_Map_Internal.empty);
          };
      };
  };                                                          
  var $dollar_GenericVersioned__141 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericVersionedWithCount_146 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericNgramsTerm__162 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });   
  var $dollar_GenericNgramsTable__183 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqVersioned_143 = function (dictEq) {
      return new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericVersioned__141)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
          return "version";
      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
          return "data";
      }))(dictEq))))));
  };
  var $dollar_EqVersionedWithCount_148 = function (dictEq) {
      return new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericVersionedWithCount_146)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
          return "version";
      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
          return "data";
      }))(dictEq))()(new Data_Symbol.IsSymbol(function () {
          return "count";
      }))(Data_Eq.eqInt))))));
  };
  var $dollar_EqReplace_190 = function (dictEq) {
      return new Data_Eq.Eq(function (x) {
          return function (y) {
              if (x instanceof Keep && y instanceof Keep) {
                  return true;
              };
              if (x instanceof Replace && y instanceof Replace) {
                  return Data_Eq.eq(dictEq)(x["value0"]["new"])(y["value0"]["new"]) && Data_Eq.eq(dictEq)(x.value0.old)(y.value0.old);
              };
              return false;
          };
      });
  };
  var $dollar_EqPatchMap_153 = function (dictEq) {
      return function (dictEq1) {
          return new Data_Eq.Eq(function (x) {
              return function (y) {
                  return Data_Eq.eq(Data_Map_Internal.eqMap(dictEq)(dictEq1))(x)(y);
              };
          });
      };
  };
  var $dollar_EqNgramsTerm_164 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericNgramsTerm__162)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqString))));
  var $dollar_EqPatchSetNgramsTerm_201 = new Data_Eq.Eq(function (x) {
      return function (y) {
          return Data_Eq.eq(Data_Set.eqSet($dollar_EqNgramsTerm_164))(x.add)(y.add) && Data_Eq.eq(Data_Set.eqSet($dollar_EqNgramsTerm_164))(x.rem)(y.rem);
      };
  });
  var $dollar_OrdNgramsTerm_165 = new Data_Ord.Ord(function () {
      return $dollar_EqNgramsTerm_164;
  }, Data_Ord_Generic.genericCompare($dollar_GenericNgramsTerm__162)(Data_Ord_Generic.genericOrdConstructor(Data_Ord_Generic.genericOrdArgument(Data_Ord.ordString))));
  var $dollar_IndexNgramsTableNgramsTer_186 = new Data_Lens_Index.Index(function (k) {
      return function (dictStrong) {
          return function (dictChoice) {
              var $628 = _NgramsTable(dictChoice.Profunctor0());
              var $629 = _ngrams_repo_elements(dictStrong);
              var $630 = Data_Lens_Index.ix(Data_Lens_Index.indexMap($dollar_OrdNgramsTerm_165))(k)(dictStrong)(dictChoice);
              return function ($631) {
                  return $628($629($630($631)));
              };
          };
      };
  });
  var $dollar_ReadForeignNgramsElement_174 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "children";
      }))(Simple_JSON.readArray($dollar_ReadForeignNgramsTerm_167))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "list";
      }))(Gargantext_Types["$_ReadForeignTermList_106"])(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "ngrams";
      }))($dollar_ReadForeignNgramsTerm_167)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "occurrences";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "parent";
      }))(Simple_JSON.readMaybe($dollar_ReadForeignNgramsTerm_167))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "root";
      }))(Simple_JSON.readMaybe($dollar_ReadForeignNgramsTerm_167))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "size";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()()))(f))(function (v) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(NgramsElement({
              ngrams: v.ngrams,
              size: v.size,
              list: v.list,
              root: v.root,
              parent: v.parent,
              children: Data_Set.fromFoldable(Data_Foldable.foldableArray)($dollar_OrdNgramsTerm_165)(v.children),
              occurrences: v.occurrences
          }));
      });
  });
  var $dollar_ReadForeignNgramsRepoElem_179 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "children";
      }))(Simple_JSON.readArray($dollar_ReadForeignNgramsTerm_167))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "list";
      }))(Gargantext_Types["$_ReadForeignTermList_106"])(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "parent";
      }))(Simple_JSON.readMaybe($dollar_ReadForeignNgramsTerm_167))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "root";
      }))(Simple_JSON.readMaybe($dollar_ReadForeignNgramsTerm_167))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "size";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()())()())()())()()))(f))(function (v) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(NgramsRepoElement({
              children: Data_Set.fromFoldable(Data_Foldable.foldableArray)($dollar_OrdNgramsTerm_165)(v.children),
              size: v.size,
              list: v.list,
              root: v.root,
              parent: v.parent
          }));
      });
  });
  var $dollar_ReadForeignNgramsPatch_161 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "patch_children";
      }))($dollar_ReadForeignPatchSet_200($dollar_OrdNgramsTerm_165)($dollar_ReadForeignNgramsTerm_167))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "patch_list";
      }))($dollar_ReadForeignReplace_194(Gargantext_Types["$_ReadForeignTermList_106"])(Gargantext_Types["$_EqTermList_103"]))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "patch_new";
      }))(Simple_JSON.readMaybe($dollar_ReadForeignNgramsRepoElem_179))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "patch_old";
      }))(Simple_JSON.readMaybe($dollar_ReadForeignNgramsRepoElem_179))(Simple_JSON.readFieldsNil)()())()())()())()()))(f))(function (v) {
          var $452 = Data_Maybe.isJust(v.patch_new) || Data_Maybe.isJust(v.patch_old);
          if ($452) {
              return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(new NgramsReplace({
                  patch_old: v.patch_old,
                  patch_new: v.patch_new
              }));
          };
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(new NgramsPatch({
              patch_list: v.patch_list,
              patch_children: v.patch_children
          }));
      });
  });
  var $dollar_ReadForeignNgramsTable_188 = new Simple_JSON.ReadForeign(function (ff) {
      var g = function (v) {
          return new Data_Tuple.Tuple(v.ngrams, v.occurrences);
      };
      var f = function (v) {
          return new Data_Tuple.Tuple(v.ngrams, {
              size: v.size,
              list: v.list,
              root: v.root,
              parent: v.parent,
              children: v.children
          });
      };
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readArray($dollar_ReadForeignNgramsElement_174))(ff))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))({
              ngrams_repo_elements: Data_Map_Internal.fromFoldable($dollar_OrdNgramsTerm_165)(Data_Foldable.foldableArray)(Data_Functor.map(Data_Functor.functorArray)(f)(inst)),
              ngrams_scores: Data_Map_Internal.fromFoldable($dollar_OrdNgramsTerm_165)(Data_Foldable.foldableArray)(Data_Functor.map(Data_Functor.functorArray)(g)(inst))
          });
      });
  });
  var loadNgramsTable = function (v) {
      var query = new Gargantext_Routes.GetNgramsTableAll({
          listIds: v.listIds,
          tabType: v.tabType
      }, new Data_Maybe.Just(v.nodeId));
      return Gargantext_Sessions.get($dollar_ReadForeignVersioned_144($dollar_ReadForeignNgramsTable_188))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(query);
  };
  var $dollar_ReadForeignPatchMapNgrams_155 = function (dictReadForeign) {
      return function (dictMonoid) {
          return new Simple_JSON.ReadForeign(function (f) {
              return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readObject(dictReadForeign))(f))(function (inst) {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(PatchMap(Data_FoldableWithIndex.foldlWithIndex(Foreign_Object.foldableWithIndexObject)(function (k) {
                      return function (m) {
                          return function (v) {
                              return Data_Map_Internal.insert($dollar_OrdNgramsTerm_165)(k)(v)(m);
                          };
                      };
                  })(Data_Map_Internal.empty)(inst)));
              });
          });
      };
  };
  var applyNgramsPatch$prime = function (p) {
      return function (e) {
          var $480 = {};
          for (var $481 in e) {
              if ({}.hasOwnProperty.call(e, $481)) {
                  $480[$481] = e[$481];
              };
          };
          $480.list = applyReplace(Gargantext_Types["$_EqTermList_103"])(p.patch_list)(e.list);
          $480.children = applyPatchSet($dollar_OrdNgramsTerm_165)(p.patch_children)(e.children);
          return $480;
      };
  };
  var applyNgramsPatch = function (v) {
      return function (v1) {
          if (v instanceof NgramsReplace) {
              return v.value0.patch_new;
          };
          if (v instanceof NgramsPatch) {
              return Data_Lens_Setter.over((function () {
                  var $632 = Data_Lens_Prism_Maybe["_Just"](Data_Profunctor_Choice.choiceFn);
                  var $633 = Data_Lens_Iso_Newtype["_Newtype"]()()(Data_Profunctor.profunctorFn);
                  return function ($634) {
                      return $632($633($634));
                  };
              })())(applyNgramsPatch$prime(v.value0))(v1);
          };
          throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 673, column 1 - line 673, column 86): " + [ v.constructor.name, v1.constructor.name ]);
      };
  };
  var findNgramRoot = function (v) {
      return function (n) {
          return Data_Maybe.fromMaybe(n)(Data_Lens_Fold.previewOn(v.ngrams_repo_elements)((function () {
              var $635 = Data_Lens_At.at(Data_Lens_At.atMap($dollar_OrdNgramsTerm_165))(n)(Data_Lens_Internal_Forget.strongForget);
              var $636 = Data_Lens_Prism_Maybe["_Just"](Data_Lens_Internal_Forget.choiceForget(Data_Maybe_First.monoidFirst));
              var $637 = _NgramsRepoElement(Data_Lens_Internal_Forget.profunctorForget);
              var $638 = _root(Data_Lens_Internal_Forget.strongForget);
              var $639 = Data_Lens_Prism_Maybe["_Just"](Data_Lens_Internal_Forget.choiceForget(Data_Maybe_First.monoidFirst));
              return function ($640) {
                  return $635($636($637($638($639($640)))));
              };
          })()));
      };
  };
  var findNgramTermList = function (v) {
      return function (n) {
          var r = findNgramRoot(v)(n);
          return Data_Lens_Fold.previewOn(v.ngrams_repo_elements)((function () {
              var $641 = Data_Lens_At.at(Data_Lens_At.atMap($dollar_OrdNgramsTerm_165))(r)(Data_Lens_Internal_Forget.strongForget);
              var $642 = Data_Lens_Prism_Maybe["_Just"](Data_Lens_Internal_Forget.choiceForget(Data_Maybe_First.monoidFirst));
              var $643 = _NgramsRepoElement(Data_Lens_Internal_Forget.profunctorForget);
              var $644 = _list(Data_Lens_Internal_Forget.strongForget);
              return function ($645) {
                  return $641($642($643($644($645))));
              };
          })());
      };
  };
  var lookupRootList = function (ngram) {
      return function (v) {
          var v1 = Data_Map_Internal.lookup($dollar_OrdNgramsTerm_165)(ngram)(v.ngrams_repo_elements);
          if (v1 instanceof Data_Maybe.Nothing) {
              return Data_Maybe.Nothing.value;
          };
          if (v1 instanceof Data_Maybe.Just && v1.value0.root instanceof Data_Maybe.Nothing) {
              return new Data_Maybe.Just(v1.value0.list);
          };
          if (v1 instanceof Data_Maybe.Just && v1.value0.root instanceof Data_Maybe.Just) {
              var v2 = Data_Map_Internal.lookup($dollar_OrdNgramsTerm_165)(v1.value0.root.value0)(v.ngrams_repo_elements);
              if (v2 instanceof Data_Maybe.Nothing) {
                  return Data_Maybe.Nothing.value;
              };
              if (v2 instanceof Data_Maybe.Just) {
                  return new Data_Maybe.Just(v2.value0.list);
              };
              throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 480, column 7 - line 482, column 53): " + [ v2.constructor.name ]);
          };
          throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 476, column 3 - line 482, column 53): " + [ v1.constructor.name ]);
      };
  };
  var highlightNgrams = function (ntype) {
      return function (v) {
          return function (input0) {
              var undb = Data_String_Regex.replace(wordBoundaryReg2)("$1");
              var splitAcc = function (dictPartial) {
                  return function (i) {
                      var go = function ($copy_j) {
                          return function ($copy_pref) {
                              return function ($copy_acc) {
                                  var $tco_var_j = $copy_j;
                                  var $tco_var_pref = $copy_pref;
                                  var $tco_done = false;
                                  var $tco_result;
                                  function $tco_loop(j, pref, acc) {
                                      var v1 = Data_Ord.compare(Data_Ord.ordInt)(i)(j);
                                      if (v1 instanceof Data_Ordering.LT) {
                                          $tco_done = true;
                                          return Partial.crashWith()("highlightNgrams: splitAcc': i < j");
                                      };
                                      if (v1 instanceof Data_Ordering.EQ) {
                                          $tco_done = true;
                                          return new Data_Tuple.Tuple(Data_List.reverse(pref), acc);
                                      };
                                      if (v1 instanceof Data_Ordering.GT) {
                                          if (acc instanceof Data_List_Types.Nil) {
                                              $tco_done = true;
                                              return Partial.crashWith()("highlightNgrams: splitAcc': acc=Nil");
                                          };
                                          if (acc instanceof Data_List_Types.Cons) {
                                              var slen = Data_String_CodePoints.length(acc.value0.value0);
                                              var v2 = Data_Ord.compare(Data_Ord.ordInt)(i)(j + slen | 0);
                                              if (v2 instanceof Data_Ordering.LT) {
                                                  var v3 = Data_String_CodePoints.splitAt(i - j | 0)(acc.value0.value0);
                                                  $tco_done = true;
                                                  return new Data_Tuple.Tuple(Data_List.reverse(new Data_List_Types.Cons(new Data_Tuple.Tuple(v3.before, acc.value0.value1), pref)), new Data_List_Types.Cons(new Data_Tuple.Tuple(v3.after, acc.value0.value1), acc.value1));
                                              };
                                              if (v2 instanceof Data_Ordering.EQ) {
                                                  $tco_done = true;
                                                  return new Data_Tuple.Tuple(Data_List.reverse(new Data_List_Types.Cons(acc.value0, pref)), acc.value1);
                                              };
                                              if (v2 instanceof Data_Ordering.GT) {
                                                  $tco_var_j = j + slen | 0;
                                                  $tco_var_pref = new Data_List_Types.Cons(acc.value0, pref);
                                                  $copy_acc = acc.value1;
                                                  return;
                                              };
                                              throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 529, column 17 - line 533, column 56): " + [ v2.constructor.name ]);
                                          };
                                          throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 525, column 13 - line 533, column 56): " + [ acc.constructor.name ]);
                                      };
                                      throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 521, column 9 - line 533, column 56): " + [ v1.constructor.name ]);
                                  };
                                  while (!$tco_done) {
                                      $tco_result = $tco_loop($tco_var_j, $tco_var_pref, $copy_acc);
                                  };
                                  return $tco_result;
                              };
                          };
                      };
                      return go(0)(Data_List_Types.Nil.value);
                  };
              };
              var spR = function (x) {
                  return " " + (Data_String_Regex.replace(wordBoundaryReg)("$1$1")(x) + " ");
              };
              var reR = Data_String_Regex.replace(wordBoundaryReg)(" ");
              var pats = Data_Array.fromFoldable(Data_Set.foldableSet)(Data_Map.keys(v.ngrams_repo_elements));
              var input = spR(input0);
              var extractInputTextMatch = function (i) {
                  return function (len) {
                      return function (input1) {
                          return undb(Data_String_CodePoints.take(len)(Data_String_CodePoints.drop(i + 1 | 0)(input1)));
                      };
                  };
              };
              var db = Data_String_Common.replaceAll(" ")("  ");
              var sp = function (x) {
                  return " " + (db(x) + " ");
              };
              var ixs = Gargantext_Utils_KarpRabin.indicesOfAny(Data_Functor.map(Data_Functor.functorArray)(function ($646) {
                  return sp(ngramsTermText($646));
              })(pats))(normNgramInternal(ntype)(input));
              var addNgramElt = function (ng) {
                  return function (ne_list) {
                      return function (v1) {
                          return new Data_Tuple.Tuple(v1.value0, new Data_List_Types.Cons(new Data_Tuple.Tuple(ng, ne_list), v1.value1));
                      };
                  };
              };
              var goAcc = function (dictPartial) {
                  return function (i) {
                      return function (acc) {
                          return function (v1) {
                              var v2 = lookupRootList(v1.value0)(v);
                              if (v2 instanceof Data_Maybe.Nothing) {
                                  return Partial.crashWith()("highlightNgrams: pattern missing from table");
                              };
                              if (v2 instanceof Data_Maybe.Just) {
                                  var v3 = splitAcc()(i)(acc);
                                  var v4 = splitAcc()(v1.value1 + 1 | 0)(v3.value1);
                                  var text = extractInputTextMatch(i)(v1.value1)(input);
                                  var ng = normNgram(ntype)(text);
                                  return Data_Semigroup.append(Data_List_Types.semigroupList)(v3.value0)(Data_Semigroup.append(Data_List_Types.semigroupList)(Data_Functor.map(Data_List_Types.functorList)(addNgramElt(ng)(v2.value0))(v4.value0))(v4.value1));
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 543, column 7 - line 553, column 62): " + [ v2.constructor.name ]);
                          };
                      };
                  };
              };
              var goFold = function (dictPartial) {
                  return function (acc) {
                      return function (v1) {
                          return Data_Foldable.foldl(Data_Foldable.foldableArray)(goAcc()(v1.value0))(acc)(Data_Functor.map(Data_Functor.functorArray)(function (pat) {
                              return new Data_Tuple.Tuple(pat, Data_String_CodePoints.length(db(ngramsTermText(pat))));
                          })(Data_Maybe["fromMaybe'"](function (v2) {
                              return Partial.crashWith()("highlightNgrams: out of bounds pattern");
                          })(Data_Traversable.traverse(Data_Traversable.traversableArray)(Data_Maybe.applicativeMaybe)(Data_Array.index(pats))(v1.value1))));
                      };
                  };
              };
              return Data_Array.fromFoldable(Data_List_Types.foldableList)(Data_Functor.map(Data_List_Types.functorList)(function (v1) {
                  return new Data_Tuple.Tuple(undb(v1.value0), v1.value1);
              })(Data_Foldable.foldl(Data_Foldable.foldableArray)(goFold())(new Data_List_Types.Cons(new Data_Tuple.Tuple(input, Data_List_Types.Nil.value), Data_List_Types.Nil.value))(ixs)));
          };
      };
  };
  var newNgramPatch = function (list) {
      return new NgramsReplace({
          patch_old: Data_Maybe.Nothing.value,
          patch_new: Data_Maybe.Just.create({
              size: 1,
              list: list,
              root: Data_Maybe.Nothing.value,
              parent: Data_Maybe.Nothing.value,
              children: Data_Monoid.mempty(Data_Set.monoidSet($dollar_OrdNgramsTerm_165))
          })
      });
  };
  var addNewNgramP = function (ngrams) {
      return function (list) {
          return {
              ngramsPatches: singletonPatchMap(ngrams)(newNgramPatch(list))
          };
      };
  };
  var addNewNgramA = function (ngrams) {
      return function (list) {
          return CommitPatch.create(addNewNgramP(ngrams)(list));
      };
  };
  var rootsOf = function (v) {
      var isRoot = function (v1) {
          return v1.parent;
      };
      return Data_Map.keys(Data_Map_Internal.mapMaybe($dollar_OrdNgramsTerm_165)(isRoot)(v.ngrams_repo_elements));
  };
  var setTermListP = function (ngram) {
      return function (patch_list) {
          var pe = new NgramsPatch({
              patch_list: patch_list,
              patch_children: Data_Monoid.mempty($dollar_MonoidPatchSet_198($dollar_OrdNgramsTerm_165))
          });
          return singletonNgramsTablePatch(ngram)(pe);
      };
  };
  var setTermListA = function (ngram) {
      return function (termList) {
          return CommitPatch.create(setTermListP(ngram)(termList));
      };
  };
  var $dollar_EqNgramsRepoElement_178 = new Data_Eq.Eq(function (x) {
      return function (y) {
          return Data_Eq.eq(Data_Set.eqSet($dollar_EqNgramsTerm_164))(x.children)(y.children) && Data_Eq.eq(Gargantext_Types["$_EqTermList_103"])(x.list)(y.list) && Data_Eq.eq(Data_Maybe.eqMaybe($dollar_EqNgramsTerm_164))(x.parent)(y.parent) && Data_Eq.eq(Data_Maybe.eqMaybe($dollar_EqNgramsTerm_164))(x.root)(y.root) && x.size === y.size;
      };
  });
  var $dollar_EqNgramsTable_184 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericNgramsTable__183)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "ngrams_scores";
  }))(Data_Map_Internal.eqMap($dollar_EqNgramsTerm_164)(Data_Monoid_Additive.eqAdditive(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
      return "ngrams_repo_elements";
  }))(Data_Map_Internal.eqMap($dollar_EqNgramsTerm_164)($dollar_EqNgramsRepoElement_178)))))));
  var $dollar_SemigroupNgramsPatch_159 = new Data_Semigroup.Semigroup(function (v) {
      return function (v1) {
          if (v instanceof NgramsReplace && v1 instanceof NgramsReplace) {
              if (Data_Eq.notEq(Data_Maybe.eqMaybe($dollar_EqNgramsRepoElement_178))(v.value0.patch_old)(v1.value0.patch_new)) {
                  return Effect_Exception_Unsafe.unsafeThrow("append/NgramsPatch: old != new");
              };
              if (Data_Boolean.otherwise) {
                  return ngramsReplace(v1.value0.patch_old)(v.value0.patch_new);
              };
          };
          if (v instanceof NgramsPatch && v1 instanceof NgramsPatch) {
              return new NgramsPatch({
                  patch_children: Data_Semigroup.append($dollar_SemigroupPatchSet_197($dollar_OrdNgramsTerm_165))(v.value0.patch_children)(v1.value0.patch_children),
                  patch_list: Data_Semigroup.append($dollar_SemigroupReplace_191(Gargantext_Types["$_EqTermList_103"]))(v.value0.patch_list)(v1.value0.patch_list)
              });
          };
          if (v instanceof NgramsPatch && v1 instanceof NgramsReplace) {
              return ngramsReplace(v1.value0.patch_old)(Data_Lens_Setter.over((function () {
                  var $647 = Data_Lens_Prism_Maybe["_Just"](Data_Profunctor_Choice.choiceFn);
                  var $648 = Data_Lens_Iso_Newtype["_Newtype"]()()(Data_Profunctor.profunctorFn);
                  return function ($649) {
                      return $647($648($649));
                  };
              })())(applyNgramsPatch$prime(v.value0))(v1.value0.patch_new));
          };
          if (v instanceof NgramsReplace && v1 instanceof NgramsPatch) {
              return ngramsReplace(Data_Lens_Setter.over((function () {
                  var $650 = Data_Lens_Prism_Maybe["_Just"](Data_Profunctor_Choice.choiceFn);
                  var $651 = Data_Lens_Iso_Newtype["_Newtype"]()()(Data_Profunctor.profunctorFn);
                  return function ($652) {
                      return $650($651($652));
                  };
              })())(applyNgramsPatch$prime(invert(v1.value0)))(v.value0.patch_old))(v.value0.patch_new);
          };
          throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 220, column 1 - line 229, column 138): " + [ v.constructor.name, v1.constructor.name ]);
      };
  });
  var $dollar_MonoidNgramsPatch_158 = new Data_Monoid.Monoid(function () {
      return $dollar_SemigroupNgramsPatch_159;
  }, new NgramsPatch({
      patch_children: Data_Monoid.mempty($dollar_MonoidPatchSet_198($dollar_OrdNgramsTerm_165)),
      patch_list: Data_Monoid.mempty($dollar_MonoidReplace_192(Gargantext_Types["$_EqTermList_103"]))
  }));
  var putNgramsPatches = function (v) {
      var putNgrams = new Gargantext_Routes.PutNgrams(v.tabType, Data_Array.head(v.listIds), Data_Maybe.Nothing.value, new Data_Maybe.Just(v.nodeId));
      return Gargantext_Sessions.put($dollar_WriteForeignVersioned_145($dollar_WriteForeignPatchMapNgram_154($dollar_WriteForeignNgramsPatch_160)))($dollar_ReadForeignVersioned_144($dollar_ReadForeignPatchMapNgrams_155($dollar_ReadForeignNgramsPatch_161)($dollar_MonoidNgramsPatch_158)))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(putNgrams);
  };
  var $dollar_EqNgramsPatch_157 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof NgramsReplace && y instanceof NgramsReplace) {
              return Data_Eq.eq(Data_Maybe.eqMaybe($dollar_EqNgramsRepoElement_178))(x.value0.patch_new)(y.value0.patch_new) && Data_Eq.eq(Data_Maybe.eqMaybe($dollar_EqNgramsRepoElement_178))(x.value0.patch_old)(y.value0.patch_old);
          };
          if (x instanceof NgramsPatch && y instanceof NgramsPatch) {
              return Data_Eq.eq($dollar_EqPatchSetNgramsTerm_201)(x.value0.patch_children)(y.value0.patch_children) && Data_Eq.eq($dollar_EqReplace_190(Gargantext_Types["$_EqTermList_103"]))(x.value0.patch_list)(y.value0.patch_list);
          };
          return false;
      };
  });
  var commitPatch = function (tablePatch) {
      return function (state) {
          return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (s) {
              var $570 = {};
              for (var $571 in s) {
                  if ({}.hasOwnProperty.call(s, $571)) {
                      $570[$571] = s[$571];
                  };
              };
              $570.ngramsLocalPatch = Data_Semigroup.append(Data_Semigroup.semigroupRecord()(Data_Semigroup.semigroupRecordCons(new Data_Symbol.IsSymbol(function () {
                  return "ngramsPatches";
              }))()(Data_Semigroup.semigroupRecordNil)($dollar_SemigroupPatchMap_202($dollar_OrdNgramsTerm_165)($dollar_EqNgramsPatch_157)($dollar_MonoidNgramsPatch_158))))(tablePatch)(s.ngramsLocalPatch);
              return $570;
          })(state);
      };
  };
  var syncPatches = function (props) {
      return function (state) {
          return function (callback) {
              return function __do() {
                  var v = Toestand_Classes.read(Toestand_Boxes.readBox)(Reactix_React.monadDelayEffect)(state)();
                  return Control_Applicative.when(Effect.applicativeEffect)(isEmptyNgramsTablePatch(v.ngramsStagePatch))((function () {
                      var pt = {
                          data: v.ngramsLocalPatch.ngramsPatches,
                          version: v.ngramsVersion
                      };
                      return function __do() {
                          Effect_Aff.launchAff_(Control_Bind.bind(Effect_Aff.bindAff)(putNgramsPatches(props)(pt))(function (v1) {
                              return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(callback(Data_Unit.unit))(function () {
                                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                                      DOM_Simple_Console.log2("[syncPatches] setting state, newVersion")(v1.version)();
                                      Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (s) {
                                          var $575 = {};
                                          for (var $576 in s) {
                                              if ({}.hasOwnProperty.call(s, $576)) {
                                                  $575[$576] = s[$576];
                                              };
                                          };
                                          $575.ngramsLocalPatch = fromNgramsPatches(Data_Monoid.mempty($dollar_MonoidPatchMap_203($dollar_OrdNgramsTerm_165)($dollar_EqNgramsPatch_157)($dollar_MonoidNgramsPatch_158)));
                                          $575.ngramsStagePatch = fromNgramsPatches(Data_Monoid.mempty($dollar_MonoidPatchMap_203($dollar_OrdNgramsTerm_165)($dollar_EqNgramsPatch_157)($dollar_MonoidNgramsPatch_158)));
                                          $575.ngramsValidPatch = Data_Semigroup.append(Data_Semigroup.semigroupRecord()(Data_Semigroup.semigroupRecordCons(new Data_Symbol.IsSymbol(function () {
                                              return "ngramsPatches";
                                          }))()(Data_Semigroup.semigroupRecordNil)($dollar_SemigroupPatchMap_202($dollar_OrdNgramsTerm_165)($dollar_EqNgramsPatch_157)($dollar_MonoidNgramsPatch_158))))(fromNgramsPatches(v1.data))(Data_Semigroup.append(Data_Semigroup.semigroupRecord()(Data_Semigroup.semigroupRecordCons(new Data_Symbol.IsSymbol(function () {
                                              return "ngramsPatches";
                                          }))()(Data_Semigroup.semigroupRecordNil)($dollar_SemigroupPatchMap_202($dollar_OrdNgramsTerm_165)($dollar_EqNgramsPatch_157)($dollar_MonoidNgramsPatch_158))))(v.ngramsLocalPatch)(s.ngramsValidPatch));
                                          $575.ngramsVersion = v1.version;
                                          return $575;
                                      })(state)();
                                      return DOM_Simple_Console.log2("[syncPatches] ngramsVersion")(v1.version)();
                                  });
                              });
                          }))();
                          return Data_Unit.unit;
                      };
                  })())();
              };
          };
      };
  };
  var coreDispatch = function (v) {
      return function (state) {
          return function (v1) {
              if (v1 instanceof Synchronize) {
                  return syncPatches(v)(state)(v1.value0.afterSync);
              };
              if (v1 instanceof CommitPatch) {
                  return commitPatch(v1.value0)(state);
              };
              if (v1 instanceof ResetPatches) {
                  return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v2) {
                      var $591 = {};
                      for (var $592 in v2) {
                          if ({}.hasOwnProperty.call(v2, $592)) {
                              $591[$592] = v2[$592];
                          };
                      };
                      $591.ngramsLocalPatch = {
                          ngramsPatches: Data_Monoid.mempty($dollar_MonoidPatchMap_203($dollar_OrdNgramsTerm_165)($dollar_EqNgramsPatch_157)($dollar_MonoidNgramsPatch_158))
                      };
                      return $591;
                  })(state);
              };
              throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 1033, column 1 - line 1033, column 80): " + [ v.constructor.name, state.constructor.name, v1.constructor.name ]);
          };
      };
  };
  var syncResetButtonsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(false))(function (synchronizing) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(synchronizing))(function (synchronizing$prime) {
                      var synchronizingClass = (function () {
                          if (synchronizing$prime) {
                              return " disabled";
                          };
                          return "";
                      })();
                      var resetClick = function (v2) {
                          return v.performAction(ResetPatches.value);
                      };
                      var newAfterSync = function (x) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(v.afterSync(x))(function () {
                              return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(false)(synchronizing));
                          });
                      };
                      var synchronizeClick = function (v2) {
                          return FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v3) {
                              return function __do() {
                                  Toestand_Classes.write_(Toestand_Boxes.writeBox)(true)(synchronizing)();
                                  return v.performAction(new Synchronize({
                                      afterSync: newAfterSync
                                  }))();
                              };
                          });
                      };
                      var hasChanges = Data_Eq.notEq(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "ngramsPatches";
                      }))($dollar_EqPatchMap_153($dollar_EqNgramsTerm_164)($dollar_EqNgramsPatch_157))))(v.ngramsLocalPatch)(Data_Monoid.mempty(Data_Monoid.monoidRecord()(Data_Monoid.monoidRecordCons(new Data_Symbol.IsSymbol(function () {
                          return "ngramsPatches";
                      }))($dollar_MonoidPatchMap_203($dollar_OrdNgramsTerm_165)($dollar_EqNgramsPatch_157)($dollar_MonoidNgramsPatch_158))()(Data_Monoid.monoidRecordNil))));
                      var hasChangesClass = (function () {
                          if (hasChanges) {
                              return "";
                          };
                          return " disabled";
                      })();
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                          className: "btn-toolbar"
                      })([ Reactix_DOM_HTML.div({
                          className: "btn-group mr-2"
                      })([ Reactix_DOM_HTML.button({
                          className: "btn btn-danger " + (hasChangesClass + synchronizingClass),
                          on: {
                              click: resetClick
                          }
                      })([ Reactix_DOM_HTML.text("Reset") ]) ]), Reactix_DOM_HTML.div({
                          className: "btn-group mr-2"
                      })([ Reactix_DOM_HTML.button({
                          className: "btn btn-primary " + (hasChangesClass + synchronizingClass),
                          on: {
                              click: synchronizeClick
                          }
                      })([ Reactix_DOM_HTML.text("Sync") ]) ]) ]));
                  });
              });
          };
      };
      return here.component("syncResetButtons")(cpt);
  })();
  var syncResetButtons = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(syncResetButtonsCpt)(p)([  ]);
  }; 
  var $dollar_AtNgramsTableNgramsTermNg_187 = new Data_Lens_At.At(function () {
      return $dollar_IndexNgramsTableNgramsTer_186;
  }, function (k) {
      return function (dictStrong) {
          var $653 = _NgramsTable(dictStrong.Profunctor0());
          var $654 = _ngrams_repo_elements(dictStrong);
          var $655 = Data_Lens_At.at(Data_Lens_At.atMap($dollar_OrdNgramsTerm_165))(k)(dictStrong);
          return function ($656) {
              return $653($654($655($656)));
          };
      };
  });
  var reRootChildren = function (v) {
      return function (v1) {
          return function (dictMonadState) {
              return function (v2) {
                  if (v === 0) {
                      return Control_Applicative.pure((dictMonadState.Monad0()).Applicative0())(Data_Unit.unit);
                  };
                  return Control_Bind.bind((dictMonadState.Monad0()).Bind1())(Data_Lens_Getter.use(dictMonadState)(Data_Lens_At.at($dollar_AtNgramsTableNgramsTermNg_187)(v2)(Data_Lens_Internal_Forget.strongForget)))(function (nre) {
                      return Data_Lens_Fold.traverseOf_((dictMonadState.Monad0()).Applicative0())((function () {
                          var $657 = Data_Lens_Prism_Maybe["_Just"](Data_Lens_Internal_Forget.choiceForget(Data_Monoid_Endo.monoidEndo(Control_Category.categoryFn)));
                          var $658 = _NgramsRepoElement(Data_Lens_Internal_Forget.profunctorForget);
                          var $659 = _children(Data_Lens_Internal_Forget.strongForget);
                          var $660 = Data_Lens_Fold.folded(Data_Monoid_Endo.monoidEndo(Control_Category.categoryFn))(Data_Set.foldableSet);
                          return function ($661) {
                              return $657($658($659($660($661))));
                          };
                      })())(function (child) {
                          return Control_Bind.discard(Control_Bind.discardUnit)((dictMonadState.Monad0()).Bind1())(Data_Lens_Setter.assignJust(dictMonadState)((function () {
                              var $662 = Data_Lens_At.at($dollar_AtNgramsTableNgramsTermNg_187)(child)(Data_Profunctor_Strong.strongFn);
                              var $663 = Data_Lens_Prism_Maybe["_Just"](Data_Profunctor_Choice.choiceFn);
                              var $664 = _NgramsRepoElement(Data_Profunctor.profunctorFn);
                              var $665 = _root(Data_Profunctor_Strong.strongFn);
                              return function ($666) {
                                  return $662($663($664($665($666))));
                              };
                          })())(v1))(function () {
                              return reRootChildren(v - 1 | 0)(v1)(dictMonadState)(child);
                          });
                      })(nre);
                  });
              };
          };
      };
  };
  var reParent = function (mrp) {
      return function (dictMonadState) {
          return function (child) {
              return Control_Bind.discard(Control_Bind.discardUnit)((dictMonadState.Monad0()).Bind1())(Data_Lens_Setter.modifying(dictMonadState)((function () {
                  var $667 = Data_Lens_At.at($dollar_AtNgramsTableNgramsTermNg_187)(child)(Data_Profunctor_Strong.strongFn);
                  var $668 = Data_Lens_Prism_Maybe["_Just"](Data_Profunctor_Choice.choiceFn);
                  var $669 = _NgramsRepoElement(Data_Profunctor.profunctorFn);
                  return function ($670) {
                      return $667($668($669($670)));
                  };
              })())((function () {
                  var $671 = Data_Lens_Setter.set(_parent(Data_Profunctor_Strong.strongFn))(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Lens_Getter.view(_parent(Data_Lens_Internal_Forget.strongForget)))(mrp));
                  var $672 = Data_Lens_Setter.set(_root(Data_Profunctor_Strong.strongFn))(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Lens_Getter.view(_root(Data_Lens_Internal_Forget.strongForget)))(mrp));
                  return function ($673) {
                      return $671($672($673));
                  };
              })()))(function () {
                  return reRootChildren(reRootMaxDepth)(Data_Maybe.fromMaybe(child)(Data_Lens_Fold.previewOn(mrp)((function () {
                      var $674 = Data_Lens_Prism_Maybe["_Just"](Data_Lens_Internal_Forget.choiceForget(Data_Maybe_First.monoidFirst));
                      var $675 = _root(Data_Lens_Internal_Forget.strongForget);
                      return function ($676) {
                          return $674($675($676));
                      };
                  })())))(dictMonadState)(child);
              });
          };
      };
  };
  var reParentNgramsPatch = function (dictMonadState) {
      return function (v) {
          return function (v1) {
              if (v1 instanceof NgramsReplace) {
                  return Control_Applicative.pure((dictMonadState.Monad0()).Applicative0())(Data_Unit.unit);
              };
              if (v1 instanceof NgramsPatch) {
                  return Control_Bind.bind((dictMonadState.Monad0()).Bind1())(Data_Lens_Getter.use(dictMonadState)(Data_Lens_At.at($dollar_AtNgramsTableNgramsTermNg_187)(v)(Data_Lens_Internal_Forget.strongForget)))(function (s) {
                      var root_of_parent = Data_Lens_Fold.previewOn(s)((function () {
                          var $677 = Data_Lens_Prism_Maybe["_Just"](Data_Lens_Internal_Forget.choiceForget(Data_Maybe_First.monoidFirst));
                          var $678 = _NgramsRepoElement(Data_Lens_Internal_Forget.profunctorForget);
                          var $679 = _root(Data_Lens_Internal_Forget.strongForget);
                          var $680 = Data_Lens_Prism_Maybe["_Just"](Data_Lens_Internal_Forget.choiceForget(Data_Maybe_First.monoidFirst));
                          return function ($681) {
                              return $677($678($679($680($681))));
                          };
                      })());
                      var rp = {
                          root: Data_Maybe.fromMaybe(v)(root_of_parent),
                          parent: v
                      };
                      return Control_Bind.discard(Control_Bind.discardUnit)((dictMonadState.Monad0()).Bind1())(Data_Foldable.traverse_((dictMonadState.Monad0()).Applicative0())(Data_Set.foldableSet)(reParent(Data_Maybe.Nothing.value)(dictMonadState))(v1.value0.patch_children.rem))(function () {
                          return Data_Foldable.traverse_((dictMonadState.Monad0()).Applicative0())(Data_Set.foldableSet)(reParent(new Data_Maybe.Just(rp))(dictMonadState))(v1.value0.patch_children.add);
                      });
                  });
              };
              throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Core (line 810, column 1 - line 811, column 59): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
  };
  var reParentNgramsTablePatch = function (dictMonadState) {
      var $682 = Data_Functor["void"]((((dictMonadState.Monad0()).Bind1()).Apply0()).Functor0());
      var $683 = traversePatchMapWithIndex((dictMonadState.Monad0()).Applicative0())($dollar_OrdNgramsTerm_165)(Data_Eq.eqUnit)(Data_Monoid.monoidUnit)(reParentNgramsPatch(dictMonadState));
      return function ($684) {
          return $682($683($684));
      };
  };
  var applyNgramsTablePatch = function (v) {
      return function (v1) {
          return Control_Monad_State.execState(reParentNgramsTablePatch(Control_Monad_State_Trans.monadStateStateT(Data_Identity.monadIdentity))(v.ngramsPatches))(NgramsTable({
              ngrams_repo_elements: applyPatchMap($dollar_OrdNgramsTerm_165)(applyNgramsPatch)(v.ngramsPatches)(v1.ngrams_repo_elements),
              ngrams_scores: v1.ngrams_scores
          }));
      };
  };
  var applyNgramsPatches = function (v) {
      return applyNgramsTablePatch(Data_Semigroup.append(Data_Semigroup.semigroupRecord()(Data_Semigroup.semigroupRecordCons(new Data_Symbol.IsSymbol(function () {
          return "ngramsPatches";
      }))()(Data_Semigroup.semigroupRecordNil)($dollar_SemigroupPatchMap_202($dollar_OrdNgramsTerm_165)($dollar_EqNgramsPatch_157)($dollar_MonoidNgramsPatch_158))))(v.ngramsLocalPatch)(Data_Semigroup.append(Data_Semigroup.semigroupRecord()(Data_Semigroup.semigroupRecordCons(new Data_Symbol.IsSymbol(function () {
          return "ngramsPatches";
      }))()(Data_Semigroup.semigroupRecordNil)($dollar_SemigroupPatchMap_202($dollar_OrdNgramsTerm_165)($dollar_EqNgramsPatch_157)($dollar_MonoidNgramsPatch_158))))(v.ngramsStagePatch)(v.ngramsValidPatch)));
  };
  exports["_NgramsElement"] = _NgramsElement;
  exports["_NgramsRepoElement"] = _NgramsRepoElement;
  exports["ngramsRepoElementToNgramsElement"] = ngramsRepoElementToNgramsElement;
  exports["NgramsPatch"] = NgramsPatch;
  exports["_NgramsTable"] = _NgramsTable;
  exports["normNgram"] = normNgram;
  exports["ngramsTermText"] = ngramsTermText;
  exports["findNgramRoot"] = findNgramRoot;
  exports["findNgramTermList"] = findNgramTermList;
  exports["toVersioned"] = toVersioned;
  exports["highlightNgrams"] = highlightNgrams;
  exports["initialPageParams"] = initialPageParams;
  exports["loadNgramsTable"] = loadNgramsTable;
  exports["convOrderBy"] = convOrderBy;
  exports["Replace"] = Replace;
  exports["replace"] = replace;
  exports["PatchMap"] = PatchMap;
  exports["_PatchMap"] = _PatchMap;
  exports["patchSetFromMap"] = patchSetFromMap;
  exports["applyPatchSet"] = applyPatchSet;
  exports["applyNgramsPatches"] = applyNgramsPatches;
  exports["rootsOf"] = rootsOf;
  exports["singletonPatchMap"] = singletonPatchMap;
  exports["fromNgramsPatches"] = fromNgramsPatches;
  exports["singletonNgramsTablePatch"] = singletonNgramsTablePatch;
  exports["_list"] = _list;
  exports["_occurrences"] = _occurrences;
  exports["_children"] = _children;
  exports["_ngrams"] = _ngrams;
  exports["_root"] = _root;
  exports["_ngrams_repo_elements"] = _ngrams_repo_elements;
  exports["_ngrams_scores"] = _ngrams_scores;
  exports["commitPatch"] = commitPatch;
  exports["putNgramsPatches"] = putNgramsPatches;
  exports["postNgramsChartsAsync"] = postNgramsChartsAsync;
  exports["addNewNgramA"] = addNewNgramA;
  exports["setTermListA"] = setTermListA;
  exports["CommitPatch"] = CommitPatch;
  exports["Synchronize"] = Synchronize;
  exports["CoreAction"] = CoreAction;
  exports["SetParentResetChildren"] = SetParentResetChildren;
  exports["ToggleChild"] = ToggleChild;
  exports["AddTermChildren"] = AddTermChildren;
  exports["ToggleSelect"] = ToggleSelect;
  exports["ToggleSelectAll"] = ToggleSelectAll;
  exports["coreDispatch"] = coreDispatch;
  exports["filterTermSize"] = filterTermSize;
  exports["syncResetButtons"] = syncResetButtons;
  exports["chartsAfterSync"] = chartsAfterSync;
  exports["$_EqVersioned_143"] = $dollar_EqVersioned_143;
  exports["$_ReadForeignVersioned_144"] = $dollar_ReadForeignVersioned_144;
  exports["$_EqVersionedWithCount_148"] = $dollar_EqVersionedWithCount_148;
  exports["$_ReadForeignVersionedWithC_149"] = $dollar_ReadForeignVersionedWithC_149;
  exports["$_EqPatchMap_153"] = $dollar_EqPatchMap_153;
  exports["$_EqNgramsPatch_157"] = $dollar_EqNgramsPatch_157;
  exports["$_MonoidNgramsPatch_158"] = $dollar_MonoidNgramsPatch_158;
  exports["$_EqNgramsTerm_164"] = $dollar_EqNgramsTerm_164;
  exports["$_OrdNgramsTerm_165"] = $dollar_OrdNgramsTerm_165;
  exports["$_EqNgramsTable_184"] = $dollar_EqNgramsTable_184;
  exports["$_IndexNgramsTableNgramsTer_186"] = $dollar_IndexNgramsTableNgramsTer_186;
  exports["$_AtNgramsTableNgramsTermNg_187"] = $dollar_AtNgramsTableNgramsTermNg_187;
  exports["$_ReadForeignNgramsTable_188"] = $dollar_ReadForeignNgramsTable_188;
  exports["$_MonoidReplace_192"] = $dollar_MonoidReplace_192;
  exports["$_MonoidPatchSet_198"] = $dollar_MonoidPatchSet_198;
  exports["$_MonoidPatchMap_203"] = $dollar_MonoidPatchMap_203;
})(PS);
(function(exports) {
  exports._getSelection = function() { return window.getSelection() || null; };
})(PS["Gargantext.Utils.Selection"] = PS["Gargantext.Utils.Selection"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.Selection"] = $PS["Gargantext.Utils.Selection"] || {};
  var exports = $PS["Gargantext.Utils.Selection"];
  var $foreign = $PS["Gargantext.Utils.Selection"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Effect = $PS["Effect"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];            
  var selectionToString = function (s) {
      return FFI_Simple_Functions["applyMethod'"](s)("toString")([  ]);
  };
  var getSelection = Data_Functor.map(Effect.functorEffect)(Data_Nullable.toMaybe)($foreign["_getSelection"]);
  exports["selectionToString"] = selectionToString;
  exports["getSelection"] = getSelection;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Annotation.AnnotatedField"] = $PS["Gargantext.Components.Annotation.AnnotatedField"] || {};
  var exports = $PS["Gargantext.Components.Annotation.AnnotatedField"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Gargantext_Components_Annotation_Menu = $PS["Gargantext.Components.Annotation.Menu"];
  var Gargantext_Components_Annotation_Utils = $PS["Gargantext.Components.Annotation.Utils"];
  var Gargantext_Components_NgramsTable_Core = $PS["Gargantext.Components.NgramsTable.Core"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Selection = $PS["Gargantext.Utils.Selection"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Record = $PS["Record"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var hideMenu = function (dictRead) {
      return function (dictWrite) {
          return function (dictHeytingAlgebra) {
              return function (v) {
                  return function __do() {
                      Reactix_React.setRef(v.menuRef)(Data_Maybe.Nothing.value)();
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(dictRead)(dictWrite))(Data_HeytingAlgebra.not(dictHeytingAlgebra))(v.redrawMenu)();
                  };
              };
          };
      };
  };
  var showMenu = function (dictIsMouseEvent) {
      return function (v) {
          var y = Reactix_SyntheticEvent.clientY()(v.event);
          var x = Reactix_SyntheticEvent.clientX()(v.event);
          var list = v.getList(v.ngram);
          var setList = function (t) {
              return function __do() {
                  v.setTermList(v.ngram)(list)(t)();
                  return hideMenu(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox)(Data_HeytingAlgebra.heytingAlgebraBoolean)({
                      menuRef: v.menuRef,
                      redrawMenu: v.redrawMenu
                  })();
              };
          };
          return function __do() {
              Reactix_SyntheticEvent.preventDefault()(v.event)();
              var menu = new Data_Maybe.Just({
                  list: list,
                  menuType: v.menuType,
                  onClose: hideMenu(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox)(Data_HeytingAlgebra.heytingAlgebraBoolean)({
                      menuRef: v.menuRef,
                      redrawMenu: v.redrawMenu
                  }),
                  redrawMenu: v.redrawMenu,
                  setList: setList,
                  x: x,
                  y: y
              });
              Reactix_React.setRef(v.menuRef)(menu)();
              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(v.redrawMenu)();
          };
      };
  };
  var onAnnotationSelect = function (dictIsMouseEvent) {
      return function (v) {
          return function (v1) {
              return function (event) {
                  if (v1 instanceof Data_Maybe.Nothing) {
                      return function __do() {
                          var s = Gargantext_Utils_Selection.getSelection();
                          if (s instanceof Data_Maybe.Just) {
                              var v2 = Gargantext_Utils_Selection.selectionToString(s.value0);
                              if (v2 === "") {
                                  return hideMenu(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox)(Data_HeytingAlgebra.heytingAlgebraBoolean)({
                                      menuRef: v.menuRef,
                                      redrawMenu: v.redrawMenu
                                  })();
                              };
                              return showMenu()({
                                  event: event,
                                  getList: Gargantext_Components_NgramsTable_Core.findNgramTermList(v.ngrams),
                                  menuRef: v.menuRef,
                                  menuType: Gargantext_Components_Annotation_Menu.NewNgram.value,
                                  ngram: Gargantext_Components_NgramsTable_Core.normNgram(Gargantext_Types.CTabTerms.value)(v2),
                                  redrawMenu: v.redrawMenu,
                                  setTermList: v.setTermList
                              })();
                          };
                          if (s instanceof Data_Maybe.Nothing) {
                              return hideMenu(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox)(Data_HeytingAlgebra.heytingAlgebraBoolean)({
                                  menuRef: v.menuRef,
                                  redrawMenu: v.redrawMenu
                              })();
                          };
                          throw new Error("Failed pattern match at Gargantext.Components.Annotation.AnnotatedField (line 99, column 3 - line 111, column 48): " + [ s.constructor.name ]);
                      };
                  };
                  if (v1 instanceof Data_Maybe.Just) {
                      return showMenu()({
                          event: event,
                          getList: Data_Function["const"](new Data_Maybe.Just(v1.value0.value1)),
                          menuRef: v.menuRef,
                          menuType: Gargantext_Components_Annotation_Menu.SetTermListItem.value,
                          ngram: v1.value0.value0,
                          redrawMenu: v.redrawMenu,
                          setTermList: v.setTermList
                      });
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Annotation.AnnotatedField (line 92, column 1 - line 96, column 96): " + [ v.constructor.name, v1.constructor.name, event.constructor.name ]);
              };
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Annotation.AnnotatedField");
  var compile = function (ngrams) {
      return Data_Maybe.maybe([  ])(Gargantext_Components_NgramsTable_Core.highlightNgrams(Gargantext_Types.CTabTerms.value)(ngrams));
  };
  var annotatedRunCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var el = (function () {
                  if (v.list instanceof Data_List_Types.Nil) {
                      return Reactix_DOM_HTML.span({
                          on: {
                              mouseUp: v.onSelect(Data_Maybe.Nothing.value)
                          }
                      })([ Reactix_DOM_HTML.text(v.text) ]);
                  };
                  if (v.list instanceof Data_List_Types.Cons) {
                      var bgClasses = Data_String_Common.joinWith(" ")(Data_Array.fromFoldable(Data_List_Types.foldableList)(Data_Functor.map(Data_List_Types.functorList)(function ($64) {
                          return Gargantext_Components_Annotation_Utils.termClass(Data_Tuple.snd($64));
                      })(v.list)));
                      var className = "annotation-run " + bgClasses;
                      return Reactix_DOM_HTML.span({
                          className: className,
                          on: {
                              click: v.onSelect(new Data_Maybe.Just(new Data_Tuple.Tuple(v.list.value0.value0, v.list.value0.value1)))
                          }
                      })([ Reactix_DOM_HTML.text(v.text) ]);
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Annotation.AnnotatedField (line 170, column 16 - line 177, column 95): " + [ v.list.constructor.name ]);
              })();
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(el);
          };
      };
      return here.component("annotatedRun")(cpt);
  })();
  var annotateRun = Reactix_React.createElement(Reactix_React.componentIsComponent)(annotatedRunCpt);
  var annotatedFieldInnerCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.redrawMenu))(function (redrawMenu$prime) {
                  var wrap = function (v2) {
                      return {
                          list: v2.value1,
                          onSelect: onAnnotationSelect()({
                              menuRef: v.menuRef,
                              ngrams: v.ngrams,
                              redrawMenu: v.redrawMenu,
                              setTermList: v.setTermList
                          }),
                          text: v2.value0
                      };
                  };
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "annotated-field-wrapper"
                  })([ Gargantext_Components_Annotation_Menu.annotationMenuWrapper({
                      menuRef: v.menuRef
                  }), Reactix_DOM_HTML.div({
                      className: "annotated-field-runs"
                  })(Data_Functor.map(Data_Functor.functorArray)(Data_Functor.map(Data_Functor.functorFn)(function (p) {
                      return annotateRun(p)([  ]);
                  })(wrap))(compile(v.ngrams)(v.text))) ]));
              });
          };
      };
      return here.component("annotatedFieldInner")(cpt);
  })();
  var annotatedFieldInner = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(annotatedFieldInnerCpt)(p)([  ]);
  };
  var annotatedFieldCpt = (function () {
      var cpt = function (props) {
          return function (v) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Maybe.Nothing.value))(function (menuRef) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(false))(function (redrawMenu) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(annotatedFieldInner(Record.merge()()({
                          menuRef: menuRef,
                          redrawMenu: redrawMenu
                      })(props)));
                  });
              });
          };
      };
      return here.component("annotatedField")(cpt);
  })();
  var annotatedField = Reactix_React.createElement(Reactix_React.componentIsComponent)(annotatedFieldCpt);
  exports["annotatedField"] = annotatedField;
})(PS);
(function($PS) {
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.Types"] = $PS["Gargantext.Components.GraphExplorer.Types"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_EuclideanRing = $PS["Data.EuclideanRing"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Record = $PS["Record"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var SideTabLegend = (function () {
      function SideTabLegend() {

      };
      SideTabLegend.value = new SideTabLegend();
      return SideTabLegend;
  })();
  var SideTabData = (function () {
      function SideTabData() {

      };
      SideTabData.value = new SideTabData();
      return SideTabData;
  })();
  var SideTabCommunity = (function () {
      function SideTabCommunity() {

      };
      SideTabCommunity.value = new SideTabCommunity();
      return SideTabCommunity;
  })();
  var Edge = function (x) {
      return x;
  };
  var Cluster = function (x) {
      return x;
  };
  var Node = function (x) {
      return x;
  };
  var GraphData = function (x) {
      return x;
  };
  var HyperdataGraph = function (x) {
      return x;
  };
  var y_coordP = Data_Symbol.SProxy.value;
  var yP = Data_Symbol.SProxy.value;
  var x_coordP = Data_Symbol.SProxy.value;
  var xP = Data_Symbol.SProxy.value;
  var mCameraP = Data_Symbol.SProxy.value;
  var id_P = Data_Symbol.SProxy.value;
  var idP = Data_Symbol.SProxy.value;
  var defaultPalette = [ "#5fa571", "#ab9ba2", "#da876d", "#bdd3ff", "#b399df", "#ffdfed", "#33c8f3", "#739e9a", "#caeca3", "#f6f7e5", "#f9bcca", "#ccb069", "#c9ffde", "#c58683", "#6c9eb0", "#ffd3cf", "#ccffc7", "#52a1b0", "#d2ecff", "#99fffe", "#9295ae", "#5ea38b", "#fff0b3", "#d99e68" ];

  // clusterColor :: Cluster -> Color
  // clusterColor (Cluster {clustDefault}) = unsafePartial $ fromJust $ defaultPalette !! (clustDefault `mod` length defaultPalette)
  var intColor = function (i) {
      return Data_Maybe.fromJust()(Data_Array.index(defaultPalette)(Data_EuclideanRing.mod(Data_EuclideanRing.euclideanRingInt)(i)(Data_Array.length(defaultPalette))));
  };
  var clust_defaultP = Data_Symbol.SProxy.value;
  var clustDefaultP = Data_Symbol.SProxy.value;
  var cameraP = Data_Symbol.SProxy.value;
  var $dollar_WriteForeignLegend_80 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "color";
  }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "id_";
  }))(Simple_JSON.writeForeignInt)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "label";
  }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()())()()());
  var $dollar_WriteForeignMetaData_69 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "corpusId";
  }))(Simple_JSON.writeForeignArray(Simple_JSON.writeForeignInt))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "legend";
  }))(Simple_JSON.writeForeignArray($dollar_WriteForeignLegend_80))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "list";
  }))(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "listId";
  }))(Simple_JSON.writeForeignInt)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "version";
  }))(Simple_JSON.writeForeignInt)(Simple_JSON.nilWriteForeignFields)()()())()()()))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "metric";
  }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "startForceAtlas";
  }))(Simple_JSON.writeForeignBoolean)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()())()()());
  var $dollar_WriteForeignEdge_57 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "confluence";
      }))(Simple_JSON.writeForeignNumber)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "id";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "source";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "target";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "weight";
      }))(Simple_JSON.writeForeignNumber)(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()()))(Record.rename(new Data_Symbol.IsSymbol(function () {
          return "id_";
      }))(new Data_Symbol.IsSymbol(function () {
          return "id";
      }))()()()()(id_P)(idP)(v));
  });
  var $dollar_WriteForeignCluster_51 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "clust_default";
      }))(Simple_JSON.writeForeignInt)(Simple_JSON.nilWriteForeignFields)()()()))(Record.rename(new Data_Symbol.IsSymbol(function () {
          return "clustDefault";
      }))(new Data_Symbol.IsSymbol(function () {
          return "clust_default";
      }))()()()()(clustDefaultP)(clust_defaultP)(v));
  });
  var $dollar_WriteForeignNode_46 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "attributes";
      }))($dollar_WriteForeignCluster_51)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "id_";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "label";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "size";
      }))(Simple_JSON.writeForeignInt)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "type_";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "x_coord";
      }))(Simple_JSON.writeForeignNumber)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "y_coord";
      }))(Simple_JSON.writeForeignNumber)(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()())()()())()()()))(Record.rename(new Data_Symbol.IsSymbol(function () {
          return "x";
      }))(new Data_Symbol.IsSymbol(function () {
          return "x_coord";
      }))()()()()(xP)(x_coordP)(Record.rename(new Data_Symbol.IsSymbol(function () {
          return "y";
      }))(new Data_Symbol.IsSymbol(function () {
          return "y_coord";
      }))()()()()(yP)(y_coordP)(v)));
  });
  var $dollar_WriteForeignGraphData_64 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "edges";
      }))(Simple_JSON.writeForeignArray($dollar_WriteForeignEdge_57))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "metadata";
      }))(Simple_JSON.writeForeignMaybe($dollar_WriteForeignMetaData_69))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "nodes";
      }))(Simple_JSON.writeForeignArray($dollar_WriteForeignNode_46))(Simple_JSON.nilWriteForeignFields)()()())()()())()()()))({
          nodes: v.nodes,
          edges: v.edges,
          metadata: v.metaData
      });
  });
  var $dollar_WriteForeignCamera_87 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "ratio";
  }))(Simple_JSON.writeForeignNumber)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "x";
  }))(Simple_JSON.writeForeignNumber)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "y";
  }))(Simple_JSON.writeForeignNumber)(Simple_JSON.nilWriteForeignFields)()()())()()())()()());
  var $dollar_WriteForeignHyperdataGrap_92 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "camera";
      }))(Simple_JSON.writeForeignMaybe($dollar_WriteForeignCamera_87))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "graph";
      }))($dollar_WriteForeignGraphData_64)(Simple_JSON.nilWriteForeignFields)()()())()()()))(Record.rename(new Data_Symbol.IsSymbol(function () {
          return "mCamera";
      }))(new Data_Symbol.IsSymbol(function () {
          return "camera";
      }))()()()()(mCameraP)(cameraP)(v));
  });
  var $dollar_ShowSideTab_82 = new Data_Show.Show(function (v) {
      if (v instanceof SideTabLegend) {
          return "Legend";
      };
      if (v instanceof SideTabData) {
          return "Data";
      };
      if (v instanceof SideTabCommunity) {
          return "Community";
      };
      throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.Types (line 212, column 1 - line 215, column 38): " + [ v.constructor.name ]);
  });
  var $dollar_ReadForeignLegend_79 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "color";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "id_";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "label";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()());
  var $dollar_ReadForeignMetaData_68 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "corpusId";
  }))(Simple_JSON.readArray(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "legend";
  }))(Simple_JSON.readArray($dollar_ReadForeignLegend_79))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "list";
  }))(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "listId";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "version";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()()))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "metric";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "startForceAtlas";
  }))(Simple_JSON.readBoolean)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()())()())()())()());
  var $dollar_ReadForeignEdge_56 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "confluence";
      }))(Simple_JSON.readNumber)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "id";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "source";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "target";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "weight";
      }))(Simple_JSON.readNumber)(Simple_JSON.readFieldsNil)()())()())()())()())()()))(f))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Edge(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "id";
          }))(new Data_Symbol.IsSymbol(function () {
              return "id_";
          }))()()()()(idP)(id_P)(inst)));
      });
  });
  var $dollar_ReadForeignCluster_50 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "clust_default";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()()))(f))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Cluster(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "clust_default";
          }))(new Data_Symbol.IsSymbol(function () {
              return "clustDefault";
          }))()()()()(clust_defaultP)(clustDefaultP)(inst)));
      });
  });
  var $dollar_ReadForeignNode_45 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "attributes";
      }))($dollar_ReadForeignCluster_50)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "id_";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "label";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "size";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "type_";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "x_coord";
      }))(Simple_JSON.readNumber)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "y_coord";
      }))(Simple_JSON.readNumber)(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()()))(f))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Node(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "x_coord";
          }))(new Data_Symbol.IsSymbol(function () {
              return "x";
          }))()()()()(x_coordP)(xP)(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "y_coord";
          }))(new Data_Symbol.IsSymbol(function () {
              return "y";
          }))()()()()(y_coordP)(yP)(inst))));
      });
  });
  var $dollar_ReadForeignGraphData_63 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "corpusId";
      }))(Simple_JSON.readArray(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "edges";
      }))(Simple_JSON.readArray($dollar_ReadForeignEdge_56))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "listId";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "metadata";
      }))(Simple_JSON.readMaybe($dollar_ReadForeignMetaData_68))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "nodes";
      }))(Simple_JSON.readArray($dollar_ReadForeignNode_45))(Simple_JSON.readFieldsNil)()())()())()())()())()()))(f))(function (v) {
          var side = function (x) {
              return {
                  corpusId: x,
                  corpusLabel: "Publications",
                  listId: v.listId
              };
          };
          var sides = Data_Functor.map(Data_Functor.functorArray)(side)(v.corpusId);
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))({
              nodes: v.nodes,
              edges: v.edges,
              sides: sides,
              metaData: v.metadata
          });
      });
  });
  var $dollar_ReadForeignCamera_86 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "ratio";
  }))(Simple_JSON.readNumber)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "x";
  }))(Simple_JSON.readNumber)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "y";
  }))(Simple_JSON.readNumber)(Simple_JSON.readFieldsNil)()())()())()());
  var $dollar_ReadForeignHyperdataGraph_91 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "camera";
      }))(Simple_JSON.readMaybe($dollar_ReadForeignCamera_86))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "graph";
      }))($dollar_ReadForeignGraphData_63)(Simple_JSON.readFieldsNil)()())()()))(f))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(HyperdataGraph(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "camera";
          }))(new Data_Symbol.IsSymbol(function () {
              return "mCamera";
          }))()()()()(cameraP)(mCameraP)(inst)));
      });
  });
  var $dollar_GenericNode__41 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericMetaData__65 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericHyperdataGraph__88 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericGraphSideCorpus__58 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericGraphData__61 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericEdge__52 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericCluster__47 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericCamera__83 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqSideTab_81 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof SideTabLegend && y instanceof SideTabLegend) {
              return true;
          };
          if (x instanceof SideTabData && y instanceof SideTabData) {
              return true;
          };
          if (x instanceof SideTabCommunity && y instanceof SideTabCommunity) {
              return true;
          };
          return false;
      };
  });                          
  var $dollar_EqLegend_77 = new Data_Eq.Eq(function (v) {
      return function (v1) {
          return v.id_ === v1.id_;
      };
  });
  var $dollar_EqMetaData_67 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericMetaData__65)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "startForceAtlas";
  }))(Data_Eq.eqBoolean))()(new Data_Symbol.IsSymbol(function () {
      return "metric";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "list";
  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "version";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "listId";
  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
      return "legend";
  }))(Data_Eq.eqArray($dollar_EqLegend_77)))()(new Data_Symbol.IsSymbol(function () {
      return "corpusId";
  }))(Data_Eq.eqArray(Data_Eq.eqInt)))))));
  var $dollar_EqGraphSideCorpus_59 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericGraphSideCorpus__58)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "listId";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "corpusLabel";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "corpusId";
  }))(Data_Eq.eqInt))))));
  var $dollar_EqEdge_54 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericEdge__52)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "weight";
  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
      return "target";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "source";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "id_";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "confluence";
  }))(Data_Eq.eqNumber))))));
  var $dollar_EqCluster_49 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericCluster__47)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "clustDefault";
  }))(Data_Eq.eqInt))))));
  var $dollar_EqNode_43 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericNode__41)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "y";
  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
      return "x";
  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
      return "type_";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "size";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "label";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "id_";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "attributes";
  }))($dollar_EqCluster_49))))));
  var $dollar_EqGraphData_62 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericGraphData__61)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "sides";
  }))(Data_Eq.eqArray($dollar_EqGraphSideCorpus_59)))()(new Data_Symbol.IsSymbol(function () {
      return "nodes";
  }))(Data_Eq.eqArray($dollar_EqNode_43)))()(new Data_Symbol.IsSymbol(function () {
      return "metaData";
  }))(Data_Maybe.eqMaybe($dollar_EqMetaData_67)))()(new Data_Symbol.IsSymbol(function () {
      return "edges";
  }))(Data_Eq.eqArray($dollar_EqEdge_54)))))));
  var $dollar_OrdNode_44 = new Data_Ord.Ord(function () {
      return $dollar_EqNode_43;
  }, function (v) {
      return function (v1) {
          return Data_Ord.compare(Data_Ord.ordString)(v.id_)(v1.id_);
      };
  });
  var $dollar_EqCamera_85 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericCamera__83)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "y";
  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
      return "x";
  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
      return "ratio";
  }))(Data_Eq.eqNumber))))));
  var $dollar_EqHyperdataGraph_90 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHyperdataGraph__88)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "mCamera";
  }))(Data_Maybe.eqMaybe($dollar_EqCamera_85)))()(new Data_Symbol.IsSymbol(function () {
      return "graph";
  }))($dollar_EqGraphData_62))))));
  exports["Node"] = Node;
  exports["GraphData"] = GraphData;
  exports["intColor"] = intColor;
  exports["SideTabLegend"] = SideTabLegend;
  exports["SideTabData"] = SideTabData;
  exports["SideTabCommunity"] = SideTabCommunity;
  exports["$_EqNode_43"] = $dollar_EqNode_43;
  exports["$_OrdNode_44"] = $dollar_OrdNode_44;
  exports["$_EqEdge_54"] = $dollar_EqEdge_54;
  exports["$_ReadForeignGraphData_63"] = $dollar_ReadForeignGraphData_63;
  exports["$_EqMetaData_67"] = $dollar_EqMetaData_67;
  exports["$_EqSideTab_81"] = $dollar_EqSideTab_81;
  exports["$_ShowSideTab_82"] = $dollar_ShowSideTab_82;
  exports["$_EqHyperdataGraph_90"] = $dollar_EqHyperdataGraph_90;
  exports["$_ReadForeignHyperdataGraph_91"] = $dollar_ReadForeignHyperdataGraph_91;
  exports["$_WriteForeignHyperdataGrap_92"] = $dollar_WriteForeignHyperdataGrap_92;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.Sidebar.Types"] = $PS["Gargantext.Components.GraphExplorer.Sidebar.Types"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.Sidebar.Types"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Set = $PS["Data.Set"];
  var Gargantext_Components_GraphExplorer_Types = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var initialSidePanel = Data_Maybe.Nothing.value;
  var focusedSidePanel = function (sidePanel) {
      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (v) {
          return v.mGraph;
      }))(function (val) {
          return Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (sp) {
              return Data_Maybe.Just.create((function () {
                  var $14 = {};
                  for (var $15 in sp) {
                      if ({}.hasOwnProperty.call(sp, $15)) {
                          $14[$15] = sp[$15];
                      };
                  };
                  $14.mGraph = val;
                  return $14;
              })());
          });
      })(sidePanel))(function (mGraph) {
          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (v) {
              return v.mMetaData;
          }))(function (val) {
              return Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (sp) {
                  return Data_Maybe.Just.create((function () {
                      var $17 = {};
                      for (var $18 in sp) {
                          if ({}.hasOwnProperty.call(sp, $18)) {
                              $17[$18] = sp[$18];
                          };
                      };
                      $17.mMetaData = val;
                      return $17;
                  })());
              });
          })(sidePanel))(function (mMetaData) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_Maybe.maybe(false)(function (v) {
                  return v.multiSelectEnabled;
              }))(function (val) {
                  return Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (sp) {
                      return Data_Maybe.Just.create((function () {
                          var $20 = {};
                          for (var $21 in sp) {
                              if ({}.hasOwnProperty.call(sp, $21)) {
                                  $20[$21] = sp[$21];
                              };
                          };
                          $20.multiSelectEnabled = val;
                          return $20;
                      })());
                  });
              })(sidePanel))(function (multiSelectEnabled) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_Maybe.maybe(Data_Set.empty)(function (v) {
                      return v.removedNodeIds;
                  }))(function (val) {
                      return Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (sp) {
                          return Data_Maybe.Just.create((function () {
                              var $23 = {};
                              for (var $24 in sp) {
                                  if ({}.hasOwnProperty.call(sp, $24)) {
                                      $23[$24] = sp[$24];
                                  };
                              };
                              $23.removedNodeIds = val;
                              return $23;
                          })());
                      });
                  })(sidePanel))(function (removedNodeIds) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_Maybe.maybe(Data_Set.empty)(function (v) {
                          return v.selectedNodeIds;
                      }))(function (val) {
                          return Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (sp) {
                              return Data_Maybe.Just.create((function () {
                                  var $26 = {};
                                  for (var $27 in sp) {
                                      if ({}.hasOwnProperty.call(sp, $27)) {
                                          $26[$27] = sp[$27];
                                      };
                                  };
                                  $26.selectedNodeIds = val;
                                  return $26;
                              })());
                          });
                      })(sidePanel))(function (selectedNodeIds) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_Maybe.maybe(false)(function (v) {
                              return v.showControls;
                          }))(function (val) {
                              return Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (sp) {
                                  return Data_Maybe.Just.create((function () {
                                      var $29 = {};
                                      for (var $30 in sp) {
                                          if ({}.hasOwnProperty.call(sp, $30)) {
                                              $29[$30] = sp[$30];
                                          };
                                      };
                                      $29.showControls = val;
                                      return $29;
                                  })());
                              });
                          })(sidePanel))(function (showControls) {
                              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_Maybe.maybe(Gargantext_Components_GraphExplorer_Types.SideTabLegend.value)(function (v) {
                                  return v.sideTab;
                              }))(function (val) {
                                  return Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (sp) {
                                      return Data_Maybe.Just.create((function () {
                                          var $32 = {};
                                          for (var $33 in sp) {
                                              if ({}.hasOwnProperty.call(sp, $33)) {
                                                  $32[$33] = sp[$33];
                                              };
                                          };
                                          $32.sideTab = val;
                                          return $32;
                                      })());
                                  });
                              })(sidePanel))(function (sideTab) {
                                  return Control_Applicative.pure(Reactix_React.applicativeHooks)({
                                      mGraph: mGraph,
                                      mMetaData: mMetaData,
                                      multiSelectEnabled: multiSelectEnabled,
                                      removedNodeIds: removedNodeIds,
                                      selectedNodeIds: selectedNodeIds,
                                      showControls: showControls,
                                      sideTab: sideTab
                                  });
                              });
                          });
                      });
                  });
              });
          });
      });
  };
  exports["initialSidePanel"] = initialSidePanel;
  exports["focusedSidePanel"] = focusedSidePanel;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Texts.Types"] = $PS["Gargantext.Components.Nodes.Texts.Types"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Texts.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var initialSidePanel = Data_Maybe.Nothing.value;
  exports["initialSidePanel"] = initialSidePanel;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.App.Data"] = $PS["Gargantext.Components.App.Data"] || {};
  var exports = $PS["Gargantext.Components.App.Data"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Set = $PS["Data.Set"];
  var Gargantext_AsyncTasks = $PS["Gargantext.AsyncTasks"];
  var Gargantext_Components_GraphExplorer_Sidebar_Types = $PS["Gargantext.Components.GraphExplorer.Sidebar.Types"];
  var Gargantext_Components_Nodes_Lists_Types = $PS["Gargantext.Components.Nodes.Lists.Types"];
  var Gargantext_Components_Nodes_Texts_Types = $PS["Gargantext.Components.Nodes.Texts.Types"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];                
  var emptyApp = {
      backend: Data_Maybe.Nothing.value,
      forestOpen: Gargantext_Sessions_Types.OpenNodes(Data_Set.empty),
      graphVersion: Gargantext_Utils_Toestand.newReload,
      handed: Gargantext_Types.RightHanded.value,
      reloadForest: Gargantext_Utils_Toestand.newReload,
      reloadMainPage: Gargantext_Utils_Toestand.newReload,
      reloadRoot: Gargantext_Utils_Toestand.newReload,
      route: Gargantext_Routes.Home.value,
      session: Data_Maybe.Nothing.value,
      sessions: Gargantext_Sessions_Types.empty,
      showCorpus: false,
      showLogin: false,
      showTree: true,
      sidePanelGraph: Gargantext_Components_GraphExplorer_Sidebar_Types.initialSidePanel,
      sidePanelLists: Gargantext_Components_Nodes_Lists_Types.initialSidePanel,
      sidePanelTexts: Gargantext_Components_Nodes_Texts_Types.initialSidePanel,
      sidePanelState: Gargantext_Types.InitialClosed.value,
      tasks: Gargantext_AsyncTasks.empty
  };
  exports["emptyApp"] = emptyApp;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Footer"] = $PS["Gargantext.Components.Footer"] || {};
  var exports = $PS["Gargantext.Components.Footer"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Footer");
  var footerCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "container"
              })([ Reactix_DOM_HTML.hr({}), Reactix_DOM_HTML.footer({})([  ]) ]));
          };
      };
      return here.component("footer")(cpt);
  })();
  var footer = Reactix_React.createElement(Reactix_React.componentIsComponent)(footerCpt);
  exports["footer"] = footer;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar"] = $PS["Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Int = $PS["Data.Int"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Show = $PS["Data.Show"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Effect_Timer = $PS["Effect.Timer"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var Bar = (function () {
      function Bar() {

      };
      Bar.value = new Bar();
      return Bar;
  })();
  var Pie = (function () {
      function Pie() {

      };
      Pie.value = new Pie();
      return Pie;
  })();
  var queryProgress = function (v) {
      var path = Gargantext_Types.asyncTaskTypePath(v.asyncTask.typ);
      var p = function (v1) {
          if (v1 instanceof Gargantext_Types.UpdateNgramsCharts) {
              return Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value)(new Data_Maybe.Just(v.nodeId))(path + (v.asyncTask.task.id + "/poll?limit=1"));
          };
          if (v1 instanceof Gargantext_Types.UpdateNode) {
              return Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value)(new Data_Maybe.Just(v.nodeId))(path + (v.asyncTask.task.id + "/poll?limit=1"));
          };
          return Gargantext_Routes.NodeAPI.create(Gargantext_Types.Corpus.value)(new Data_Maybe.Just(v.nodeId))(path + (v.asyncTask.task.id + "/poll?limit=1"));
      };
      return Gargantext_Sessions.get(Gargantext_Types["$_ReadForeignAsyncProgress_175"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(p(v.asyncTask.typ));
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar");
  var progressIndicatorCpt = (function () {
      var toInt = function (n) {
          var v = Data_Int.fromNumber(n);
          if (v instanceof Data_Maybe.Nothing) {
              return 0;
          };
          if (v instanceof Data_Maybe.Just) {
              return v.value0;
          };
          throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar (line 103, column 15 - line 105, column 21): " + [ v.constructor.name ]);
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqNumber))(v.progress))(function (progress$prime) {
                  var progressInt = toInt(progress$prime);
                  if (v.barType instanceof Bar) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                          className: "progress"
                      })([ Reactix_DOM_HTML.div({
                          className: "progress-bar",
                          role: "progressbar",
                          style: {
                              width: Data_Show.show(Data_Show.showInt)(progressInt) + "%"
                          }
                      })([ Reactix_DOM_HTML.text(v.label) ]) ]));
                  };
                  if (v.barType instanceof Pie) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                          className: "progress-pie"
                      })([ Reactix_DOM_HTML.div({
                          className: "progress-pie-segment",
                          style: {
                              "--over50": (function () {
                                  var $22 = progressInt < 50;
                                  if ($22) {
                                      return "0";
                                  };
                                  return "1";
                              })(),
                              "--value": Data_Show.show(Data_Show.showInt)(progressInt)
                          }
                      })([  ]) ]));
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar (line 86, column 7 - line 100, column 20): " + [ v.barType.constructor.name ]);
              });
          };
      };
      return here.component("progressIndicator")(cpt);
  })();
  var progressIndicator = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(progressIndicatorCpt)(p)([  ]);
  };
  var asyncProgressBarCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(0.0))(function (progress) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Maybe.Nothing.value))(function (intervalIdRef) {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffectOnce'"](function __do() {
                          var intervalId = Effect_Timer.setInterval(1000)(Effect_Aff.launchAff_(Control_Bind.bind(Effect_Aff.bindAff)(queryProgress(v))(function (v2) {
                              return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                                  Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Ord.min(Data_Ord.ordNumber)(100.0)(Gargantext_Types.progressPercent(v2)))(progress)();
                                  var $29 = Data_Eq.eq(Gargantext_Types["$_EqAsyncTaskStatus_164"])(v2.status)(Gargantext_Types.IsFinished.value) || (Data_Eq.eq(Gargantext_Types["$_EqAsyncTaskStatus_164"])(v2.status)(Gargantext_Types.IsKilled.value) || Data_Eq.eq(Gargantext_Types["$_EqAsyncTaskStatus_164"])(v2.status)(Gargantext_Types.IsFailure.value));
                                  if ($29) {
                                      (function () {
                                          var v3 = Reactix_React.readRef(intervalIdRef);
                                          if (v3 instanceof Data_Maybe.Nothing) {
                                              return Data_Unit.unit;
                                          };
                                          if (v3 instanceof Data_Maybe.Just) {
                                              return Effect_Timer.clearInterval(v3.value0)();
                                          };
                                          throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar (line 56, column 22 - line 58, column 48): " + [ v3.constructor.name ]);
                                      })();
                                      return v.onFinish(Data_Unit.unit)();
                                  };
                                  return Data_Unit.unit;
                              });
                          })))();
                          Reactix_React.setRef(intervalIdRef)(new Data_Maybe.Just(intervalId))();
                          return Data_Unit.unit;
                      }))(function () {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(progressIndicator({
                              barType: v.barType,
                              label: v.asyncTask.task.id,
                              progress: progress
                          }));
                      });
                  });
              });
          };
      };
      return here.component("asyncProgressBar")(cpt);
  })();
  var asyncProgressBar = Reactix_React.createElement(Reactix_React.componentIsComponent)(asyncProgressBarCpt);
  exports["Pie"] = Pie;
  exports["asyncProgressBar"] = asyncProgressBar;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.API"] = $PS["Gargantext.Components.GraphExplorer.API"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.API"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_GraphExplorer_Types = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var updateGraphVersions = function (v) {
      return Gargantext_Sessions.post(Simple_JSON.recordWriteForeign()(Simple_JSON.nilWriteForeignFields))(Gargantext_Components_GraphExplorer_Types["$_ReadForeignGraphData_63"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(Gargantext_Routes.GraphAPI.create(v.graphId)("versions"))({});
  };
  var graphVersions = function (v) {
      return Gargantext_Sessions.get(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "gv_graph";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "gv_repo";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()()))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(Gargantext_Routes.GraphAPI.create(v.graphId)("versions"));
  };
  var cloneGraph = function (v) {
      return Gargantext_Sessions.post(Gargantext_Components_GraphExplorer_Types["$_WriteForeignHyperdataGrap_92"])(Simple_JSON.readInt)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(Gargantext_Routes.GraphAPI.create(v.id)("clone"))(v.hyperdataGraph);
  };
  exports["graphVersions"] = graphVersions;
  exports["updateGraphVersions"] = updateGraphVersions;
  exports["cloneGraph"] = cloneGraph;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node.Tools.Sync"] = $PS["Gargantext.Components.Forest.Tree.Node.Tools.Sync"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node.Tools.Sync"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_Components_GraphExplorer_API = $PS["Gargantext.Components.GraphExplorer.API"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node.Tools.Sync");
  var nodeListUpdateButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
          };
      };
      return here.component("nodeListUpdateButton")(cpt);
  })();
  var nodeListUpdateButton = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(nodeListUpdateButtonCpt)(p)([  ]);
  };
  var nodeActionsNodeListCpt = (function () {
      var cpt = function (props) {
          return function (v) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "node-actions"
              })([ nodeListUpdateButton(props) ]));
          };
      };
      return here.component("nodeActionsNodeList")(cpt);
  })();
  var nodeActionsNodeList = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(nodeActionsNodeListCpt)(p)([  ]);
  };
  var graphUpdateButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onClick = function (v2) {
                  return function (v3) {
                      if (!v2) {
                          return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                      };
                      if (v2) {
                          return function __do() {
                              Effect_Aff.launchAff_(Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(false)(v3)))(function () {
                                  return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_GraphExplorer_API.updateGraphVersions({
                                      graphId: v.id,
                                      session: v.session
                                  }))(function (g) {
                                      return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(true)(v3)))(function () {
                                          return v.refresh(Data_Unit.unit);
                                      });
                                  });
                              }))();
                              return Data_Unit.unit;
                          };
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node.Tools.Sync (line 68, column 9 - line 68, column 36): " + [ v2.constructor.name, v3.constructor.name ]);
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(true))(function (enabled) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(enabled))(function (enabled$prime) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                          className: "update-button " + (function () {
                              if (enabled$prime) {
                                  return "enabled";
                              };
                              return "disabled text-muted";
                          })()
                      })([ Reactix_DOM_HTML.span({
                          className: "fa fa-refresh",
                          on: {
                              click: onClick(enabled$prime)(enabled)
                          }
                      })([  ]) ]));
                  });
              });
          };
      };
      return here.component("graphUpdateButton")(cpt);
  })();
  var graphUpdateButton = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(graphUpdateButtonCpt)(p)([  ]);
  };
  var nodeActionsGraphCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "node-actions"
              })([ (function () {
                  var $26 = Data_Eq.eq(Data_Maybe.eqMaybe(Data_Eq.eqInt))(v.graphVersions.gv_graph)(new Data_Maybe.Just(v.graphVersions.gv_repo));
                  if ($26) {
                      return Reactix_DOM_HTML.div({})([  ]);
                  };
                  return graphUpdateButton({
                      id: v.id,
                      session: v.session,
                      refresh: v.refresh
                  });
              })() ]));
          };
      };
      return here.component("nodeActionsGraph")(cpt);
  })();
  var nodeActionsGraph = Reactix_React.createElement(Reactix_React.componentIsComponent)(nodeActionsGraphCpt);
  exports["nodeActionsGraph"] = nodeActionsGraph;
  exports["nodeActionsNodeList"] = nodeActionsNodeList;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Node"] = $PS["Gargantext.Components.Node"] || {};
  var exports = $PS["Gargantext.Components.Node"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Simple_JSON = $PS["Simple.JSON"];
  var $dollar_ReadForeignNodePoly_8 = function (dictReadForeign) {
      return new Simple_JSON.ReadForeign(function (f) {
          return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
              return "date";
          }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
              return "hyperdata";
          }))(dictReadForeign)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
              return "id";
          }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
              return "name";
          }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
              return "parent_id";
          }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
              return "typename";
          }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
              return "user_id";
          }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()()))(f))(function (v) {
              return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))({
                  id: v.id,
                  typename: v.typename,
                  userId: v.user_id,
                  parentId: v.parent_id,
                  name: v.name,
                  date: v.date,
                  hyperdata: v.hyperdata
              });
          });
      });
  };
  var $dollar_ReadForeignHyperdataList_11 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "preferences";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()());
  var $dollar_GenericNodePoly__5 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqNodePoly_7 = function (dictEq) {
      return new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericNodePoly__5)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
          return "userId";
      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
          return "typename";
      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
          return "parentId";
      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
          return "name";
      }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
          return "id";
      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
          return "hyperdata";
      }))(dictEq))()(new Data_Symbol.IsSymbol(function () {
          return "date";
      }))(Data_Eq.eqString))))));
  };
  exports["$_EqNodePoly_7"] = $dollar_EqNodePoly_7;
  exports["$_ReadForeignNodePoly_8"] = $dollar_ReadForeignNodePoly_8;
  exports["$_ReadForeignHyperdataList_11"] = $dollar_ReadForeignHyperdataList_11;
})(PS);
(function(exports) {
  'use strict';

  const hljs = require('highlightjs/highlight.pack.min.js');

  function highlightBlock(el) {
      hljs.highlightBlock(el);
  }

  exports._highlightBlock = highlightBlock;
})(PS["Gargantext.Utils.HighlightJS"] = PS["Gargantext.Utils.HighlightJS"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.HighlightJS"] = $PS["Gargantext.Utils.HighlightJS"] || {};
  var exports = $PS["Gargantext.Utils.HighlightJS"];
  var $foreign = $PS["Gargantext.Utils.HighlightJS"];
  var highlightBlock = function (el) {
      return function () {
          return $foreign["_highlightBlock"](el);
      };
  };
  exports["highlightBlock"] = highlightBlock;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.SlamDown.Parser.Utils"] = $PS["Text.Markdown.SlamDown.Parser.Utils"] || {};
  var exports = $PS["Text.Markdown.SlamDown.Parser.Utils"];
  var Control_Apply = $PS["Control.Apply"];
  var Data_Either = $PS["Data.Either"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_String_Regex = $PS["Data.String.Regex"];
  var Data_String_Regex_Flags = $PS["Data.String.Regex.Flags"];
  var Partial_Unsafe = $PS["Partial.Unsafe"];
  var Text_Parsing_Parser = $PS["Text.Parsing.Parser"];
  var Text_Parsing_Parser_Combinators = $PS["Text.Parsing.Parser.Combinators"];
  var Text_Parsing_Parser_String = $PS["Text.Parsing.Parser.String"];                
  var isWhitespace = (function () {
      var wsRegex = Data_Either["fromRight'"](function (v) {
          return Partial_Unsafe.unsafeCrashWith("Error parsing whitespace regex");
      })(Data_String_Regex.regex("^\\s$")(Data_String_Regex_Flags.noFlags));
      var $2 = Data_String_Regex.test(wsRegex);
      return function ($3) {
          return $2(Data_String_CodeUnits.singleton($3));
      };
  })();
  var skipSpaces = Text_Parsing_Parser_Combinators.skipMany(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.satisfy(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(isWhitespace));
  var parens = function (p) {
      return Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("("))(skipSpaces))(p))(skipSpaces))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(")"));
  };
  var squares = function (p) {
      return Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("["))(skipSpaces))(p))(skipSpaces))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("]"));
  };
  var isEmailAddress = (function () {
      var wsEmail = Data_Either["fromRight'"](function (v) {
          return Partial_Unsafe.unsafeCrashWith("Error parsing isEmail regex");
      })(Data_String_Regex.regex("^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$")(Data_String_Regex_Flags.noFlags));
      return Data_String_Regex.test(wsEmail);
  })();
  var braces = function (p) {
      return Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("{"))(skipSpaces))(p))(skipSpaces))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("}"));
  };
  exports["isWhitespace"] = isWhitespace;
  exports["isEmailAddress"] = isEmailAddress;
  exports["parens"] = parens;
  exports["braces"] = braces;
  exports["squares"] = squares;
  exports["skipSpaces"] = skipSpaces;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.SlamDown.Syntax.FormField"] = $PS["Text.Markdown.SlamDown.Syntax.FormField"] || {};
  var exports = $PS["Text.Markdown.SlamDown.Syntax.FormField"];                                        
  var TextBox = (function () {
      function TextBox(value0) {
          this.value0 = value0;
      };
      TextBox.create = function (value0) {
          return new TextBox(value0);
      };
      return TextBox;
  })();
  var RadioButtons = (function () {
      function RadioButtons(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      RadioButtons.create = function (value0) {
          return function (value1) {
              return new RadioButtons(value0, value1);
          };
      };
      return RadioButtons;
  })();
  var CheckBoxes = (function () {
      function CheckBoxes(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      CheckBoxes.create = function (value0) {
          return function (value1) {
              return new CheckBoxes(value0, value1);
          };
      };
      return CheckBoxes;
  })();
  var DropDown = (function () {
      function DropDown(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      DropDown.create = function (value0) {
          return function (value1) {
              return new DropDown(value0, value1);
          };
      };
      return DropDown;
  })();
  var Literal = (function () {
      function Literal(value0) {
          this.value0 = value0;
      };
      Literal.create = function (value0) {
          return new Literal(value0);
      };
      return Literal;
  })();
  var Unevaluated = (function () {
      function Unevaluated(value0) {
          this.value0 = value0;
      };
      Unevaluated.create = function (value0) {
          return new Unevaluated(value0);
      };
      return Unevaluated;
  })();
  exports["TextBox"] = TextBox;
  exports["RadioButtons"] = RadioButtons;
  exports["CheckBoxes"] = CheckBoxes;
  exports["DropDown"] = DropDown;
  exports["Literal"] = Literal;
  exports["Unevaluated"] = Unevaluated;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.SlamDown.Syntax.Inline"] = $PS["Text.Markdown.SlamDown.Syntax.Inline"] || {};
  var exports = $PS["Text.Markdown.SlamDown.Syntax.Inline"];                                               
  var InlineLink = (function () {
      function InlineLink(value0) {
          this.value0 = value0;
      };
      InlineLink.create = function (value0) {
          return new InlineLink(value0);
      };
      return InlineLink;
  })();
  var ReferenceLink = (function () {
      function ReferenceLink(value0) {
          this.value0 = value0;
      };
      ReferenceLink.create = function (value0) {
          return new ReferenceLink(value0);
      };
      return ReferenceLink;
  })();
  var Str = (function () {
      function Str(value0) {
          this.value0 = value0;
      };
      Str.create = function (value0) {
          return new Str(value0);
      };
      return Str;
  })();
  var Entity = (function () {
      function Entity(value0) {
          this.value0 = value0;
      };
      Entity.create = function (value0) {
          return new Entity(value0);
      };
      return Entity;
  })();
  var Space = (function () {
      function Space() {

      };
      Space.value = new Space();
      return Space;
  })();
  var SoftBreak = (function () {
      function SoftBreak() {

      };
      SoftBreak.value = new SoftBreak();
      return SoftBreak;
  })();
  var LineBreak = (function () {
      function LineBreak() {

      };
      LineBreak.value = new LineBreak();
      return LineBreak;
  })();
  var Emph = (function () {
      function Emph(value0) {
          this.value0 = value0;
      };
      Emph.create = function (value0) {
          return new Emph(value0);
      };
      return Emph;
  })();
  var Strong = (function () {
      function Strong(value0) {
          this.value0 = value0;
      };
      Strong.create = function (value0) {
          return new Strong(value0);
      };
      return Strong;
  })();
  var Code = (function () {
      function Code(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Code.create = function (value0) {
          return function (value1) {
              return new Code(value0, value1);
          };
      };
      return Code;
  })();
  var Link = (function () {
      function Link(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Link.create = function (value0) {
          return function (value1) {
              return new Link(value0, value1);
          };
      };
      return Link;
  })();
  var Image = (function () {
      function Image(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Image.create = function (value0) {
          return function (value1) {
              return new Image(value0, value1);
          };
      };
      return Image;
  })();
  var FormField = (function () {
      function FormField(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      FormField.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new FormField(value0, value1, value2);
              };
          };
      };
      return FormField;
  })();
  exports["Str"] = Str;
  exports["Entity"] = Entity;
  exports["Space"] = Space;
  exports["SoftBreak"] = SoftBreak;
  exports["LineBreak"] = LineBreak;
  exports["Emph"] = Emph;
  exports["Strong"] = Strong;
  exports["Code"] = Code;
  exports["Link"] = Link;
  exports["Image"] = Image;
  exports["FormField"] = FormField;
  exports["InlineLink"] = InlineLink;
  exports["ReferenceLink"] = ReferenceLink;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.SlamDown.Syntax.TextBox"] = $PS["Text.Markdown.SlamDown.Syntax.TextBox"] || {};
  var exports = $PS["Text.Markdown.SlamDown.Syntax.TextBox"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Newtype = $PS["Data.Newtype"];                              
  var Minutes = (function () {
      function Minutes() {

      };
      Minutes.value = new Minutes();
      return Minutes;
  })();
  var Seconds = (function () {
      function Seconds() {

      };
      Seconds.value = new Seconds();
      return Seconds;
  })();
  var PlainText = (function () {
      function PlainText(value0) {
          this.value0 = value0;
      };
      PlainText.create = function (value0) {
          return new PlainText(value0);
      };
      return PlainText;
  })();
  var Numeric = (function () {
      function Numeric(value0) {
          this.value0 = value0;
      };
      Numeric.create = function (value0) {
          return new Numeric(value0);
      };
      return Numeric;
  })();
  var $$Date = (function () {
      function $$Date(value0) {
          this.value0 = value0;
      };
      $$Date.create = function (value0) {
          return new $$Date(value0);
      };
      return $$Date;
  })();
  var Time = (function () {
      function Time(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Time.create = function (value0) {
          return function (value1) {
              return new Time(value0, value1);
          };
      };
      return Time;
  })();
  var DateTime = (function () {
      function DateTime(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      DateTime.create = function (value0) {
          return function (value1) {
              return new DateTime(value0, value1);
          };
      };
      return DateTime;
  })();
  var traverseTextBox = function (dictApplicative) {
      return function (eta) {
          return function (v) {
              if (v instanceof PlainText) {
                  return Data_Functor.map((dictApplicative.Apply0()).Functor0())(PlainText.create)(eta(v.value0));
              };
              if (v instanceof Numeric) {
                  return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Numeric.create)(eta(v.value0));
              };
              if (v instanceof $$Date) {
                  return Data_Functor.map((dictApplicative.Apply0()).Functor0())($$Date.create)(eta(v.value0));
              };
              if (v instanceof Time) {
                  return Data_Functor.map((dictApplicative.Apply0()).Functor0())(Time.create(v.value0))(eta(v.value1));
              };
              if (v instanceof DateTime) {
                  return Data_Functor.map((dictApplicative.Apply0()).Functor0())(DateTime.create(v.value0))(eta(v.value1));
              };
              throw new Error("Failed pattern match at Text.Markdown.SlamDown.Syntax.TextBox (line 44, column 23 - line 49, column 48): " + [ v.constructor.name ]);
          };
      };
  };
  var transTextBox = function (eta) {
      var $122 = Data_Newtype.unwrap();
      var $123 = traverseTextBox(Data_Identity.applicativeIdentity)(function ($125) {
          return Data_Identity.Identity(eta($125));
      });
      return function ($124) {
          return $122($123($124));
      };
  };
  var eqTimePrecision = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof Minutes && y instanceof Minutes) {
              return true;
          };
          if (x instanceof Seconds && y instanceof Seconds) {
              return true;
          };
          return false;
      };
  });
  exports["Minutes"] = Minutes;
  exports["Seconds"] = Seconds;
  exports["PlainText"] = PlainText;
  exports["Numeric"] = Numeric;
  exports["Date"] = $$Date;
  exports["Time"] = Time;
  exports["DateTime"] = DateTime;
  exports["transTextBox"] = transTextBox;
  exports["eqTimePrecision"] = eqTimePrecision;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.SlamDown.Syntax.Value"] = $PS["Text.Markdown.SlamDown.Syntax.Value"] || {};
  var exports = $PS["Text.Markdown.SlamDown.Syntax.Value"];
  var Control_Category = $PS["Control.Category"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Ord = $PS["Data.Ord"];                
  var Value = function (Eq0, Ord1, renderValue, stringValue) {
      this.Eq0 = Eq0;
      this.Ord1 = Ord1;
      this.renderValue = renderValue;
      this.stringValue = stringValue;
  };
  var valueString = new Value(function () {
      return Data_Eq.eqString;
  }, function () {
      return Data_Ord.ordString;
  }, Control_Category.identity(Control_Category.categoryFn), Control_Category.identity(Control_Category.categoryFn));
  var stringValue = function (dict) {
      return dict.stringValue;
  };
  exports["stringValue"] = stringValue;
  exports["valueString"] = valueString;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.SlamDown.Parser.Inline"] = $PS["Text.Markdown.SlamDown.Parser.Inline"] || {};
  var exports = $PS["Text.Markdown.SlamDown.Parser.Inline"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Control_Lazy = $PS["Control.Lazy"];
  var Data_Array = $PS["Data.Array"];
  var Data_Bifunctor = $PS["Data.Bifunctor"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Bounded = $PS["Data.Bounded"];
  var Data_CodePoint_Unicode = $PS["Data.CodePoint.Unicode"];
  var Data_Date = $PS["Data.Date"];
  var Data_Date_Component = $PS["Data.Date.Component"];
  var Data_DateTime = $PS["Data.DateTime"];
  var Data_Either = $PS["Data.Either"];
  var Data_Enum = $PS["Data.Enum"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Functor_Compose = $PS["Data.Functor.Compose"];
  var Data_HugeNum = $PS["Data.HugeNum"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Int = $PS["Data.Int"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Time = $PS["Data.Time"];
  var Data_Time_Component = $PS["Data.Time.Component"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Text_Markdown_SlamDown_Parser_Utils = $PS["Text.Markdown.SlamDown.Parser.Utils"];
  var Text_Markdown_SlamDown_Syntax_FormField = $PS["Text.Markdown.SlamDown.Syntax.FormField"];
  var Text_Markdown_SlamDown_Syntax_Inline = $PS["Text.Markdown.SlamDown.Syntax.Inline"];
  var Text_Markdown_SlamDown_Syntax_TextBox = $PS["Text.Markdown.SlamDown.Syntax.TextBox"];
  var Text_Markdown_SlamDown_Syntax_Value = $PS["Text.Markdown.SlamDown.Syntax.Value"];
  var Text_Parsing_Parser = $PS["Text.Parsing.Parser"];
  var Text_Parsing_Parser_Combinators = $PS["Text.Parsing.Parser.Combinators"];
  var Text_Parsing_Parser_String = $PS["Text.Parsing.Parser.String"];
  var someOf = (function () {
      var $87 = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
          var $91 = Data_Array.fromFoldable(Data_List_Types.foldableList);
          return function ($92) {
              return Data_String_CodeUnits.fromCharArray($91($92));
          };
      })());
      var $88 = Data_List.some(Text_Parsing_Parser.alternativeParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser.lazyParserT);
      var $89 = Text_Parsing_Parser_String.satisfy(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity);
      return function ($90) {
          return $87($88($89($90)));
      };
  })();
  var unevaluated = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("!"))(function () {
      return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(someOf(function (x) {
          return Data_String_CodeUnits.singleton(x) === "`";
      }))(function (ticks) {
          return Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
              var $93 = Data_Array.fromFoldable(Data_List_Types.foldableList);
              return function ($94) {
                  return Text_Markdown_SlamDown_Syntax_FormField.Unevaluated.create(Data_String_CodeUnits.fromCharArray($93($94)));
              };
          })())(Text_Parsing_Parser_Combinators.manyTill(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(ticks)));
      });
  });
  var manyOf = (function () {
      var $95 = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
          var $99 = Data_Array.fromFoldable(Data_List_Types.foldableList);
          return function ($100) {
              return Data_String_CodeUnits.fromCharArray($99($100));
          };
      })());
      var $96 = Data_List.many(Text_Parsing_Parser.alternativeParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser.lazyParserT);
      var $97 = Text_Parsing_Parser_String.satisfy(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity);
      return function ($98) {
          return $95($96($97($98)));
      };
  })();
  var hash = Data_Functor["void"](Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("#"));
  var expr = function (f) {
      return function (p) {
          return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(f(unevaluated)))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_FormField.Literal.create)(p));
      };
  };
  var dot = Data_Functor["void"](Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("."));
  var dash = Data_Functor["void"](Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("-"));
  var consolidate = function (xs) {
      if (xs instanceof Data_List_Types.Nil) {
          return Data_List_Types.Nil.value;
      };
      if (xs instanceof Data_List_Types.Cons && (xs.value0 instanceof Text_Markdown_SlamDown_Syntax_Inline.Str && (xs.value1 instanceof Data_List_Types.Cons && xs.value1.value0 instanceof Text_Markdown_SlamDown_Syntax_Inline.Str))) {
          return consolidate(new Data_List_Types.Cons(new Text_Markdown_SlamDown_Syntax_Inline.Str(xs.value0.value0 + xs.value1.value0.value0), xs.value1.value1));
      };
      if (xs instanceof Data_List_Types.Cons) {
          return Data_List_Types.Cons.create(xs.value0)(consolidate(xs.value1));
      };
      throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 55, column 3 - line 59, column 44): " + [ xs.constructor.name ]);
  };
  var colon = Data_Functor["void"](Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(":"));
  var parseTextBox = function (isPlainText) {
      return function (eta) {
          return function (template) {
              var parsePlainTextValue = manyOf(isPlainText);
              var digit = Text_Parsing_Parser_String.oneOf(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)([ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ]);
              var digitN = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(digit)(function (ds) {
                  return Data_Maybe.maybe(Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Failed parsing digit"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity)))(Data_Int.fromString(Data_String_CodeUnits.fromCharArray(Control_Applicative.pure(Control_Applicative.applicativeArray)(ds))));
              });
              var parseYear = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(digitN)(function (millenia) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(digitN)(function (centuries) {
                      return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(digitN)(function (decades) {
                          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(digitN)(function (years) {
                              return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))((((1000 * millenia | 0) + (100 * centuries | 0) | 0) + (10 * decades | 0) | 0) + years | 0);
                          });
                      });
                  });
              });
              var digits = Data_Functor.mapFlipped(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_List.some(Text_Parsing_Parser.alternativeParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser.lazyParserT)(digit))((function () {
                  var $101 = Data_Array.fromFoldable(Data_List_Types.foldableList);
                  return function ($102) {
                      return Data_String_CodeUnits.fromCharArray($101($102));
                  };
              })());
              var natural = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(digits)(function (xs) {
                  return Data_Maybe.maybe(Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Failed parsing natural"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity)))(Data_Int.fromString(xs));
              });
              var parseDateValue = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(parseYear)(function (year) {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(dash))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces))(function () {
                      return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(natural)(function (month) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Applicative.when(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(month > 12)(Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Invalid month")))(function () {
                              return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(dash))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces))(function () {
                                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(natural)(function (day) {
                                      return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Applicative.when(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(day > 31)(Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Invalid day")))(function () {
                                          var v = Control_Apply.apply(Data_Maybe.applyMaybe)(Control_Apply.apply(Data_Maybe.applyMaybe)(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Date.canonicalDate)(Data_Enum.toEnum(Data_Date_Component.boundedEnumYear)(year)))(Data_Enum.toEnum(Data_Date_Component.boundedEnumMonth)(month)))(Data_Enum.toEnum(Data_Date_Component.boundedEnumDay)(day));
                                          if (v instanceof Data_Maybe.Nothing) {
                                              return Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Invalid date");
                                          };
                                          if (v instanceof Data_Maybe.Just) {
                                              return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v.value0);
                                          };
                                          throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 436, column 7 - line 438, column 28): " + [ v.constructor.name ]);
                                      });
                                  });
                              });
                          });
                      });
                  });
              });
              var parseTimeValue = function (prec) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(natural)(function (hours) {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Applicative.when(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(hours > 23)(Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Invalid hours")))(function () {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(colon))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces))(function () {
                              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(natural)(function (minutes) {
                                  return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Applicative.when(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(minutes > 59)(Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Invalid minutes")))(function () {
                                      return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))((function () {
                                          if (prec instanceof Text_Markdown_SlamDown_Syntax_TextBox.Minutes) {
                                              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(colon))))(function (scolon) {
                                                  return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Applicative.when(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_Maybe.isJust(scolon))(Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Unexpected seconds component")))(function () {
                                                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_Maybe.Nothing.value);
                                                  });
                                              });
                                          };
                                          if (prec instanceof Text_Markdown_SlamDown_Syntax_TextBox.Seconds) {
                                              return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(colon))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces))(function () {
                                                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(natural)(function (secs) {
                                                      return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Applicative.when(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(secs > 59)(Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Invalid seconds")))(function () {
                                                          return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                                                              return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Data_Maybe.Just(secs));
                                                          });
                                                      });
                                                  });
                                              });
                                          };
                                          throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 447, column 17 - line 457, column 29): " + [ prec.constructor.name ]);
                                      })())(function (seconds) {
                                          return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                                              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Data_Functor.voidRight(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(false)(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("PM"))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("pm"))))(Data_Functor.voidRight(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(true)(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("AM"))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("am"))))))(function (amPm) {
                                                  var hours$prime = (function () {
                                                      if (amPm instanceof Data_Maybe.Nothing) {
                                                          return hours;
                                                      };
                                                      if (amPm instanceof Data_Maybe.Just) {
                                                          var $40 = !amPm.value0 && hours < 12;
                                                          if ($40) {
                                                              return hours + 12 | 0;
                                                          };
                                                          var $41 = amPm.value0 && hours === 12;
                                                          if ($41) {
                                                              return 0;
                                                          };
                                                          return hours;
                                                      };
                                                      throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 464, column 13 - line 471, column 27): " + [ amPm.constructor.name ]);
                                                  })();
                                                  var v = Control_Apply.apply(Data_Maybe.applyMaybe)(Control_Apply.apply(Data_Maybe.applyMaybe)(Control_Apply.apply(Data_Maybe.applyMaybe)(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Time.Time.create)(Data_Enum.toEnum(Data_Time_Component.boundedEnumHour)(hours$prime)))(Data_Enum.toEnum(Data_Time_Component.boundedEnumMinute)(minutes)))(Data_Enum.toEnum(Data_Time_Component.boundedEnumSecond)(Data_Maybe.fromMaybe(0)(seconds))))(Control_Applicative.pure(Data_Maybe.applicativeMaybe)(Data_Bounded.bottom(Data_Time_Component.boundedMillisecond)));
                                                  if (v instanceof Data_Maybe.Nothing) {
                                                      return Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Invalid time");
                                                  };
                                                  if (v instanceof Data_Maybe.Just) {
                                                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v.value0);
                                                  };
                                                  throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 472, column 7 - line 474, column 26): " + [ v.constructor.name ]);
                                              });
                                          });
                                      });
                                  });
                              });
                          });
                      });
                  });
              };
              var parseDateTimeValue = function (prec) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(parseDateValue)(function (date) {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Data_Functor["void"](Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("T"))))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces))(function () {
                          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(parseTimeValue(prec))(function (time) {
                              return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Data_DateTime.DateTime(date, time));
                          });
                      });
                  });
              };
              var parseNumericValue = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Data_Functor.voidRight(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(-1 | 0)(Text_Parsing_Parser_String["char"](Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("-"))))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(1)))(function (sign) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(digits)(function (ms) {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(dot))(function (gotDot) {
                              return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))((function () {
                                      if (gotDot instanceof Data_Maybe.Just) {
                                          return Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(digits));
                                      };
                                      if (gotDot instanceof Data_Maybe.Nothing) {
                                          return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_Maybe.Nothing.value);
                                      };
                                      throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 484, column 9 - line 488, column 27): " + [ gotDot.constructor.name ]);
                                  })())(function (ns) {
                                      return Data_Maybe.maybe(Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Failed parsing decimal"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity)))(Data_HugeNum.fromString(ms + ("." + Data_Maybe.fromMaybe("")(ns))));
                                  });
                              });
                          });
                      });
                  });
              });
              if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox.DateTime) {
                  return Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_TextBox.DateTime.create(template.value0))(eta(parseDateTimeValue(template.value0)));
              };
              if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox["Date"]) {
                  return Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_TextBox["Date"].create)(eta(parseDateValue));
              };
              if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox.Time) {
                  return Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_TextBox.Time.create(template.value0))(eta(parseTimeValue(template.value0)));
              };
              if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox.Numeric) {
                  return Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_TextBox.Numeric.create)(eta(parseNumericValue));
              };
              if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox.PlainText) {
                  return Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_TextBox.PlainText.create)(eta(parsePlainTextValue));
              };
              throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 412, column 3 - line 417, column 62): " + [ template.constructor.name ]);
          };
      };
  };
  var inlines = function (dictValue) {
      var space = (function () {
          var toSpace = function (cs) {
              if (Data_Foldable.elem(Data_List_Types.foldableList)(Data_Eq.eqString)("\x0a")(cs)) {
                  var v = Data_List.take(2)(cs);
                  if (v instanceof Data_List_Types.Cons && (v.value0 === " " && (v.value1 instanceof Data_List_Types.Cons && (v.value1.value0 === " " && v.value1.value1 instanceof Data_List_Types.Nil)))) {
                      return Text_Markdown_SlamDown_Syntax_Inline.LineBreak.value;
                  };
                  return Text_Markdown_SlamDown_Syntax_Inline.SoftBreak.value;
              };
              if (Data_Boolean.otherwise) {
                  return Text_Markdown_SlamDown_Syntax_Inline.Space.value;
              };
              throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 188, column 5 - line 193, column 29): " + [ cs.constructor.name ]);
          };
          return Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(function ($103) {
              return toSpace((function (v) {
                  return Data_Functor.map(Data_List_Types.functorList)(Data_String_CodeUnits.singleton)(v);
              })($103));
          })(Data_List.some(Text_Parsing_Parser.alternativeParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser.lazyParserT)(Text_Parsing_Parser_String.satisfy(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(Text_Markdown_SlamDown_Parser_Utils.isWhitespace)));
      })();
      var other = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_String_CodeUnits.singleton)(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)))(function (c) {
          var $61 = c === "\\";
          if ($61) {
              return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(function ($104) {
                  return Text_Markdown_SlamDown_Syntax_Inline.Str.create(Data_String_CodeUnits.singleton($104));
              })(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.satisfy(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(function (x) {
                  return Data_String_CodeUnits.singleton(x) === "\x0a";
              }))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Syntax_Inline.LineBreak.value))))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Text_Markdown_SlamDown_Syntax_Inline.Str("\\")));
          };
          return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Text_Markdown_SlamDown_Syntax_Inline.Str(c));
      });
      var formElement = (function () {
          var und = someOf(function (x) {
              return x === "_";
          });
          var radioButtons = (function () {
              var literalRadioButtons = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Data_List.some(Text_Parsing_Parser.alternativeParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser.lazyParserT)(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)((function () {
                  var item = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
                      var $105 = Text_Markdown_SlamDown_Syntax_Value.stringValue(dictValue);
                      return function ($106) {
                          return $105(Data_String_Common.trim($106));
                      };
                  })())(manyOf(function (c) {
                      return !Data_Foldable.elem(Data_Foldable.foldableArray)(Data_Eq.eqChar)(c)([ "(", ")", "!", "`" ]);
                  }));
                  return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                      return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("(x)"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(true)))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("()"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(false))))(function (b) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(item)(function (l) {
                                  return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Data_Tuple.Tuple(b, l));
                              });
                          });
                      });
                  });
              })())))(function (ls) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))((function () {
                      var v = Data_List.filter(Data_Tuple.fst)(ls);
                      if (v instanceof Data_List_Types.Cons && v.value1 instanceof Data_List_Types.Nil) {
                          return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(v.value0.value1);
                      };
                      return Text_Parsing_Parser.fail(Data_Identity.monadIdentity)("Invalid number of selected radio buttons");
                  })())(function (sel) {
                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Text_Markdown_SlamDown_Syntax_FormField.RadioButtons(new Text_Markdown_SlamDown_Syntax_FormField.Literal(sel), new Text_Markdown_SlamDown_Syntax_FormField.Literal(Data_Functor.map(Data_List_Types.functorList)(Data_Tuple.snd)(ls))));
                  });
              });
              var evaluatedRadioButtons = Control_Apply.apply(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_FormField.RadioButtons.create)(Text_Markdown_SlamDown_Parser_Utils.parens(unevaluated)))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(unevaluated));
              return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(literalRadioButtons)(evaluatedRadioButtons);
          })();
          var parseTextBoxTemplate = (function () {
              var parseTimeTemplate = function (prec) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(und)(function () {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(colon))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces))(function () {
                          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(und)(function () {
                              return Control_Applicative.when(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_Eq.eq(Text_Markdown_SlamDown_Syntax_TextBox.eqTimePrecision)(prec)(Text_Markdown_SlamDown_Syntax_TextBox.Seconds.value))(Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(colon))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces))(function () {
                                  return Data_Functor["void"](Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(und);
                              }));
                          });
                      });
                  });
              };
              var parseNumericTemplate = Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(hash)(function () {
                  return und;
              });
              var parseDateTemplate = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(und)(function () {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(dash))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces))(function () {
                      return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(und)(function () {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(dash))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces))(function () {
                              return und;
                          });
                      });
                  });
              });
              var parseDateTimeTemplate = function (prec) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(parseDateTemplate)(function () {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                          return parseTimeTemplate(prec);
                      });
                  });
              };
              return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Data_Functor.voidRight(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(new Text_Markdown_SlamDown_Syntax_TextBox.DateTime(Text_Markdown_SlamDown_Syntax_TextBox.Seconds.value, Data_Unit.unit))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(parseDateTimeTemplate(Text_Markdown_SlamDown_Syntax_TextBox.Seconds.value))))(Data_Functor.voidRight(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(new Text_Markdown_SlamDown_Syntax_TextBox.DateTime(Text_Markdown_SlamDown_Syntax_TextBox.Minutes.value, Data_Unit.unit))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(parseDateTimeTemplate(Text_Markdown_SlamDown_Syntax_TextBox.Minutes.value)))))(Data_Functor.voidRight(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(new Text_Markdown_SlamDown_Syntax_TextBox["Date"](Data_Unit.unit))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(parseDateTemplate))))(Data_Functor.voidRight(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(new Text_Markdown_SlamDown_Syntax_TextBox.Time(Text_Markdown_SlamDown_Syntax_TextBox.Seconds.value, Data_Unit.unit))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(parseTimeTemplate(Text_Markdown_SlamDown_Syntax_TextBox.Seconds.value)))))(Data_Functor.voidRight(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(new Text_Markdown_SlamDown_Syntax_TextBox.Time(Text_Markdown_SlamDown_Syntax_TextBox.Minutes.value, Data_Unit.unit))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(parseTimeTemplate(Text_Markdown_SlamDown_Syntax_TextBox.Minutes.value)))))(Data_Functor.voidRight(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(new Text_Markdown_SlamDown_Syntax_TextBox.Numeric(Data_Unit.unit))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(parseNumericTemplate))))(Data_Functor.voidRight(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(new Text_Markdown_SlamDown_Syntax_TextBox.PlainText(Data_Unit.unit))(und));
          })();
          var textBox = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(parseTextBoxTemplate)(function (template) {
              return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("(")))(function (defVal) {
                      if (defVal instanceof Data_Maybe.Nothing) {
                          return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_Either.Right.create(Text_Markdown_SlamDown_Syntax_FormField.TextBox.create(Text_Markdown_SlamDown_Syntax_TextBox.transTextBox(Data_Function["const"](Data_Maybe.Nothing.value))(template))));
                      };
                      if (defVal instanceof Data_Maybe.Just) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(parseTextBox(function (v) {
                                  return v !== ")";
                              })(expr(Control_Category.identity(Control_Category.categoryFn)))(template))))(function (mdef) {
                                  if (mdef instanceof Data_Maybe.Just) {
                                      return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                                          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(")"))(function () {
                                              return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_Either.Right.create(Text_Markdown_SlamDown_Syntax_FormField.TextBox.create(Text_Markdown_SlamDown_Syntax_TextBox.transTextBox(function ($107) {
                                                  return Data_Functor_Compose.Compose(Data_Maybe.Just.create($107));
                                              })(mdef.value0))));
                                          });
                                      });
                                  };
                                  if (mdef instanceof Data_Maybe.Nothing) {
                                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Data_Either.Left((function () {
                                          if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox.DateTime && template.value0 instanceof Text_Markdown_SlamDown_Syntax_TextBox.Minutes) {
                                              return "Invalid datetime default value, please use \"YYYY-MM-DD HH:mm\" format";
                                          };
                                          if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox.DateTime && template.value0 instanceof Text_Markdown_SlamDown_Syntax_TextBox.Seconds) {
                                              return "Invalid datetime default value, please use \"YYYY-MM-DD HH:mm:ss\" format";
                                          };
                                          if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox["Date"]) {
                                              return "Invalid date default value, please use \"YYYY-MM-DD\" format";
                                          };
                                          if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox.Time && template.value0 instanceof Text_Markdown_SlamDown_Syntax_TextBox.Minutes) {
                                              return "Invalid time default value, please use \"HH:mm\" format";
                                          };
                                          if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox.Time && template.value0 instanceof Text_Markdown_SlamDown_Syntax_TextBox.Seconds) {
                                              return "Invalid time default value, please use \"HH:mm:ss\" format";
                                          };
                                          if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox.Numeric) {
                                              return "Invalid numeric default value";
                                          };
                                          if (template instanceof Text_Markdown_SlamDown_Syntax_TextBox.PlainText) {
                                              return "Invalid default value";
                                          };
                                          throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 290, column 27 - line 304, column 42): " + [ template.constructor.name ]);
                                      })()));
                                  };
                                  throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 284, column 11 - line 304, column 42): " + [ mdef.constructor.name ]);
                              });
                          });
                      };
                      throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 279, column 7 - line 304, column 42): " + [ defVal.constructor.name ]);
                  });
              });
          });
          var dropDown = (function () {
              var item = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
                  var $108 = Text_Markdown_SlamDown_Syntax_Value.stringValue(dictValue);
                  return function ($109) {
                      return $108(Data_String_Common.trim($109));
                  };
              })())(manyOf(function (c) {
                  return !Data_Foldable.elem(Data_Foldable.foldableArray)(Data_Eq.eqChar)(c)([ "{", "}", ",", "!", "`", "(", ")" ]);
              }));
              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.braces(expr(Control_Category.identity(Control_Category.categoryFn))(Text_Parsing_Parser_Combinators.sepBy(Data_Identity.monadIdentity)(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(item)))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(","))))))(function (ls) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(Text_Markdown_SlamDown_Parser_Utils.parens(expr(Control_Category.identity(Control_Category.categoryFn))(item)))))(function (sel) {
                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Text_Markdown_SlamDown_Syntax_FormField.DropDown(sel, ls));
                  });
              });
          })();
          var checkBoxes = (function () {
              var literalCheckBoxes = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Data_List.some(Text_Parsing_Parser.alternativeParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser.lazyParserT)(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)((function () {
                  var item = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
                      var $110 = Text_Markdown_SlamDown_Syntax_Value.stringValue(dictValue);
                      return function ($111) {
                          return $110(Data_String_Common.trim($111));
                      };
                  })())(manyOf(function (c) {
                      return !Data_Foldable.elem(Data_Foldable.foldableArray)(Data_Eq.eqChar)(c)([ "[", "]", "!", "`" ]);
                  }));
                  return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                      return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("[x]"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(true)))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("[]"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(false))))(function (b) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(item)(function (l) {
                                  return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Data_Tuple.Tuple(b, l));
                              });
                          });
                      });
                  });
              })())))(function (ls) {
                  return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Text_Markdown_SlamDown_Syntax_FormField.CheckBoxes(Text_Markdown_SlamDown_Syntax_FormField.Literal.create(Data_Functor.map(Data_List_Types.functorList)(Data_Tuple.snd)(Data_List.filter(Data_Tuple.fst)(ls))), Text_Markdown_SlamDown_Syntax_FormField.Literal.create(Data_Functor.map(Data_List_Types.functorList)(Data_Tuple.snd)(ls))));
              });
              var evaluatedCheckBoxes = Control_Apply.apply(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_FormField.CheckBoxes.create)(Text_Markdown_SlamDown_Parser_Utils.squares(unevaluated)))(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(unevaluated));
              return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(literalCheckBoxes)(evaluatedCheckBoxes);
          })();
          return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(textBox))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_Either.Right.create)(radioButtons))))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_Either.Right.create)(checkBoxes))))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_Either.Right.create)(dropDown)));
      })();
      var formField = (function () {
          var required = Text_Parsing_Parser_Combinators.option(Data_Identity.monadIdentity)(false)(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("*"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(true)));
          var label = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(someOf(function ($112) {
              return Data_CodePoint_Unicode.isAlphaNum(Data_String_CodePoints.codePointFromChar($112));
          }))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
              var $113 = Data_Array.fromFoldable(Data_List_Types.foldableList);
              return function ($114) {
                  return Data_String_CodeUnits.fromCharArray($113($114));
              };
          })())(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("["))(Text_Parsing_Parser_Combinators.manyTill(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("]")))));
          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(label)(function (l) {
              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                  return required;
              }))(function (r) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                      return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("="))(function () {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                              return formElement;
                          });
                      });
                  }))(function (fe) {
                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Data_Functor.map(Data_Either.functorEither)(Text_Markdown_SlamDown_Syntax_Inline.FormField.create(l)(r))(fe));
                  });
              });
          });
      })();
      var entity = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("&"))(function () {
          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
              var $115 = Data_Array.fromFoldable(Data_List_Types.foldableNonEmptyList);
              return function ($116) {
                  return Data_String_CodeUnits.fromCharArray($115($116));
              };
          })())(Text_Parsing_Parser_Combinators.many1Till(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.noneOf(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(Data_String_CodeUnits.toCharArray(";")))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(";"))))(function (s) {
              return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Syntax_Inline.Entity.create("&" + (s + ";")));
          });
      });
      var emphasis = function (p) {
          return function (f) {
              return function (s) {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(s))(function () {
                      return Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(f)(Text_Parsing_Parser_Combinators.manyTill(Data_Identity.monadIdentity)(p)(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(s)));
                  });
              };
          };
      };
      var strong = function (p) {
          return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(emphasis(p)(Text_Markdown_SlamDown_Syntax_Inline.Strong.create)("**"))(emphasis(p)(Text_Markdown_SlamDown_Syntax_Inline.Strong.create)("__"));
      };
      var strongEmph = function (p) {
          var f = function (is) {
              return Text_Markdown_SlamDown_Syntax_Inline.Strong.create(Data_List.singleton(new Text_Markdown_SlamDown_Syntax_Inline.Emph(is)));
          };
          return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(emphasis(p)(f)("***"))(emphasis(p)(f)("___"));
      };
      var emph = function (p) {
          return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(emphasis(p)(Text_Markdown_SlamDown_Syntax_Inline.Emph.create)("*"))(emphasis(p)(Text_Markdown_SlamDown_Syntax_Inline.Emph.create)("_"));
      };
      var code = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators.option(Data_Identity.monadIdentity)(false)(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("!"))(Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(true))))(function ($$eval) {
          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(someOf(function (x) {
              return Data_String_CodeUnits.singleton(x) === "`";
          }))(function (ticks) {
              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
                  var $117 = Data_Array.fromFoldable(Data_List_Types.foldableList);
                  return function ($118) {
                      return Data_String_CodeUnits.fromCharArray($117($118));
                  };
              })())(Text_Parsing_Parser_Combinators.manyTill(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(ticks))))(function (contents) {
                  return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Syntax_Inline.Code.create($$eval)(Data_String_Common.trim(contents)));
              });
          });
      });
      var autolink = (function () {
          var autoLabel = function (s) {
              if (Text_Markdown_SlamDown_Parser_Utils.isEmailAddress(s)) {
                  return "mailto:" + s;
              };
              if (Data_Boolean.otherwise) {
                  return s;
              };
              throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 233, column 5 - line 233, column 32): " + [ s.constructor.name ]);
          };
          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("<"))(function () {
              return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
                  var $119 = Data_Array.fromFoldable(Data_List_Types.foldableNonEmptyList);
                  return function ($120) {
                      return Data_String_CodeUnits.fromCharArray($119($120));
                  };
              })())(Text_Parsing_Parser_Combinators.many1Till(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(">"))))(function (url) {
                  return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Text_Markdown_SlamDown_Syntax_Inline.Link(Data_List.singleton(new Text_Markdown_SlamDown_Syntax_Inline.Str(autoLabel(url))), new Text_Markdown_SlamDown_Syntax_Inline.InlineLink(url)));
              });
          });
      })();
      var alphaNumStr = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_Inline.Str.create)(someOf(function ($121) {
          return Data_CodePoint_Unicode.isAlphaNum(Data_String_CodePoints.codePointFromChar($121));
      }));
      var inline0 = Control_Lazy.fix(Text_Parsing_Parser.lazyParserT)(function (p) {
          return Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(alphaNumStr)(space))(strongEmph(p)))(strong(p)))(emph(p)))(code))(autolink))(entity);
      });
      var link = (function () {
          var referenceLink = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_Inline.ReferenceLink.create)(Text_Parsing_Parser_Combinators.optionMaybe(Data_Identity.monadIdentity)(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
              var $122 = Data_Array.fromFoldable(Data_List_Types.foldableList);
              return function ($123) {
                  return Data_String_CodeUnits.fromCharArray($122($123));
              };
          })())(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("["))(Text_Parsing_Parser_Combinators.manyTill(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("]"))))));
          var linkLabel = Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("["))(Text_Parsing_Parser_Combinators.manyTill(Data_Identity.monadIdentity)(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(inline0)(other))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("]")));
          var inlineLink = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
              var $124 = Data_Array.fromFoldable(Data_List_Types.foldableList);
              return function ($125) {
                  return Text_Markdown_SlamDown_Syntax_Inline.InlineLink.create(Data_String_CodeUnits.fromCharArray($124($125)));
              };
          })())(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("("))(Text_Parsing_Parser_Combinators.manyTill(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(")"))));
          var linkTarget = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(inlineLink)(referenceLink);
          return Control_Apply.apply(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_Inline.Link.create)(linkLabel))(linkTarget);
      })();
      var inline1 = Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(inline0))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(link));
      var image = (function () {
          var imageUrl = Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))((function () {
              var $126 = Data_Array.fromFoldable(Data_List_Types.foldableList);
              return function ($127) {
                  return Data_String_CodeUnits.fromCharArray($126($127));
              };
          })())(Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("("))(Text_Parsing_Parser_Combinators.manyTill(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(")"))));
          var imageLabel = Control_Apply.applySecond(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("!["))(Text_Parsing_Parser_Combinators.manyTill(Data_Identity.monadIdentity)(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(inline1)(other))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("]")));
          return Control_Apply.apply(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Text_Markdown_SlamDown_Syntax_Inline.Image.create)(imageLabel))(imageUrl);
      })();
      var inline2 = Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Control_Alt.alt(Text_Parsing_Parser.altParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(formField))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_Either.Right.create)(inline1))))(Text_Parsing_Parser_Combinators["try"](Data_Identity.monadIdentity)(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_Either.Right.create)(image))))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(Data_Either.Right.create)(other)))(function (res) {
          if (res instanceof Data_Either.Right) {
              return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(res.value0);
          };
          if (res instanceof Data_Either.Left) {
              return Text_Parsing_Parser.fail(Data_Identity.monadIdentity)(res.value0);
          };
          throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser.Inline (line 158, column 5 - line 160, column 24): " + [ res.constructor.name ]);
      });
      return Control_Apply.applyFirst(Text_Parsing_Parser.applyParserT(Data_Identity.monadIdentity))(Data_List.many(Text_Parsing_Parser.alternativeParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser.lazyParserT)(inline2))(Text_Parsing_Parser_String.eof(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity));
  };
  var parseInlines = function (dictValue) {
      return function (s) {
          return Data_Functor.map(Data_Either.functorEither)(consolidate)(Data_Bifunctor.lmap(Data_Bifunctor.bifunctorEither)(Text_Parsing_Parser.parseErrorMessage)(Text_Parsing_Parser.runParser(Data_String_Common.joinWith("\x0a")(Data_Array.fromFoldable(Data_List_Types.foldableList)(s)))(inlines(dictValue))));
      };
  };
  exports["parseInlines"] = parseInlines;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.SlamDown.Syntax.Block"] = $PS["Text.Markdown.SlamDown.Syntax.Block"] || {};
  var exports = $PS["Text.Markdown.SlamDown.Syntax.Block"];
  var Data_Eq = $PS["Data.Eq"];                                                                          
  var Bullet = (function () {
      function Bullet(value0) {
          this.value0 = value0;
      };
      Bullet.create = function (value0) {
          return new Bullet(value0);
      };
      return Bullet;
  })();
  var Ordered = (function () {
      function Ordered(value0) {
          this.value0 = value0;
      };
      Ordered.create = function (value0) {
          return new Ordered(value0);
      };
      return Ordered;
  })();
  var Indented = (function () {
      function Indented() {

      };
      Indented.value = new Indented();
      return Indented;
  })();
  var Fenced = (function () {
      function Fenced(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Fenced.create = function (value0) {
          return function (value1) {
              return new Fenced(value0, value1);
          };
      };
      return Fenced;
  })();
  var Paragraph = (function () {
      function Paragraph(value0) {
          this.value0 = value0;
      };
      Paragraph.create = function (value0) {
          return new Paragraph(value0);
      };
      return Paragraph;
  })();
  var Header = (function () {
      function Header(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Header.create = function (value0) {
          return function (value1) {
              return new Header(value0, value1);
          };
      };
      return Header;
  })();
  var Blockquote = (function () {
      function Blockquote(value0) {
          this.value0 = value0;
      };
      Blockquote.create = function (value0) {
          return new Blockquote(value0);
      };
      return Blockquote;
  })();
  var Lst = (function () {
      function Lst(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Lst.create = function (value0) {
          return function (value1) {
              return new Lst(value0, value1);
          };
      };
      return Lst;
  })();
  var CodeBlock = (function () {
      function CodeBlock(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      CodeBlock.create = function (value0) {
          return function (value1) {
              return new CodeBlock(value0, value1);
          };
      };
      return CodeBlock;
  })();
  var LinkReference = (function () {
      function LinkReference(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      LinkReference.create = function (value0) {
          return function (value1) {
              return new LinkReference(value0, value1);
          };
      };
      return LinkReference;
  })();
  var Rule = (function () {
      function Rule() {

      };
      Rule.value = new Rule();
      return Rule;
  })();
  var eqListType = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof Bullet && y instanceof Bullet) {
              return x.value0 === y.value0;
          };
          if (x instanceof Ordered && y instanceof Ordered) {
              return x.value0 === y.value0;
          };
          return false;
      };
  });
  exports["Paragraph"] = Paragraph;
  exports["Header"] = Header;
  exports["Blockquote"] = Blockquote;
  exports["Lst"] = Lst;
  exports["CodeBlock"] = CodeBlock;
  exports["LinkReference"] = LinkReference;
  exports["Rule"] = Rule;
  exports["Bullet"] = Bullet;
  exports["Ordered"] = Ordered;
  exports["Indented"] = Indented;
  exports["Fenced"] = Fenced;
  exports["eqListType"] = eqListType;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.SlamDown.Parser.References"] = $PS["Text.Markdown.SlamDown.Parser.References"] || {};
  var exports = $PS["Text.Markdown.SlamDown.Parser.References"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Either = $PS["Data.Either"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Text_Markdown_SlamDown_Parser_Utils = $PS["Text.Markdown.SlamDown.Parser.Utils"];
  var Text_Markdown_SlamDown_Syntax_Block = $PS["Text.Markdown.SlamDown.Syntax.Block"];
  var Text_Parsing_Parser = $PS["Text.Parsing.Parser"];
  var Text_Parsing_Parser_Combinators = $PS["Text.Parsing.Parser.Combinators"];
  var Text_Parsing_Parser_String = $PS["Text.Parsing.Parser.String"];                
  var linkReference = (function () {
      var charsToString = (function () {
          var $0 = Data_Array.fromFoldable(Data_List_Types.foldableList);
          return function ($1) {
              return Data_String_Common.trim(Data_String_CodeUnits.fromCharArray($0($1)));
          };
      })();
      return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(charsToString)(Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("["))(function () {
          return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
              return Text_Parsing_Parser_Combinators.manyTill(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)("]"));
          });
      })))(function (l) {
          return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.string(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity)(":"))(function () {
              return Control_Bind.discard(Control_Bind.discardUnit)(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Text_Markdown_SlamDown_Parser_Utils.skipSpaces)(function () {
                  return Control_Bind.bind(Text_Parsing_Parser.bindParserT(Data_Identity.monadIdentity))(Data_Functor.map(Text_Parsing_Parser.functorParserT(Data_Identity.functorIdentity))(charsToString)(Text_Parsing_Parser_Combinators.manyTill(Data_Identity.monadIdentity)(Text_Parsing_Parser_String.anyChar(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))(Text_Parsing_Parser_String.eof(Text_Parsing_Parser_String.stringLikeString)(Data_Identity.monadIdentity))))(function (uri) {
                      return Control_Applicative.pure(Text_Parsing_Parser.applicativeParserT(Data_Identity.monadIdentity))(new Text_Markdown_SlamDown_Syntax_Block.LinkReference(l, uri));
                  });
              });
          });
      });
  })();
  var parseLinkReference = (function () {
      var $2 = Data_Either.either(Data_Function["const"](Data_Maybe.Nothing.value))(Data_Maybe.Just.create);
      var $3 = Data_Function.flip(Text_Parsing_Parser.runParser)(linkReference);
      return function ($4) {
          return $2($3($4));
      };
  })();
  exports["parseLinkReference"] = parseLinkReference;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.SlamDown.Syntax"] = $PS["Text.Markdown.SlamDown.Syntax"] || {};
  var exports = $PS["Text.Markdown.SlamDown.Syntax"];                                                    
  var SlamDown = function (x) {
      return x;
  };
  exports["SlamDown"] = SlamDown;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.SlamDown.Parser"] = $PS["Text.Markdown.SlamDown.Parser"] || {};
  var exports = $PS["Text.Markdown.SlamDown.Parser"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Either = $PS["Data.Either"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_String_Regex = $PS["Data.String.Regex"];
  var Data_String_Regex_Flags = $PS["Data.String.Regex.Flags"];
  var Data_String_Regex_Unsafe = $PS["Data.String.Regex.Unsafe"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Text_Markdown_SlamDown_Parser_Inline = $PS["Text.Markdown.SlamDown.Parser.Inline"];
  var Text_Markdown_SlamDown_Parser_References = $PS["Text.Markdown.SlamDown.Parser.References"];
  var Text_Markdown_SlamDown_Syntax = $PS["Text.Markdown.SlamDown.Syntax"];
  var Text_Markdown_SlamDown_Syntax_Block = $PS["Text.Markdown.SlamDown.Syntax.Block"];                
  var CText = (function () {
      function CText(value0) {
          this.value0 = value0;
      };
      CText.create = function (value0) {
          return new CText(value0);
      };
      return CText;
  })();
  var CBlank = (function () {
      function CBlank() {

      };
      CBlank.value = new CBlank();
      return CBlank;
  })();
  var CRule = (function () {
      function CRule() {

      };
      CRule.value = new CRule();
      return CRule;
  })();
  var CATXHeader = (function () {
      function CATXHeader(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      CATXHeader.create = function (value0) {
          return function (value1) {
              return new CATXHeader(value0, value1);
          };
      };
      return CATXHeader;
  })();
  var CSetextHeader = (function () {
      function CSetextHeader(value0) {
          this.value0 = value0;
      };
      CSetextHeader.create = function (value0) {
          return new CSetextHeader(value0);
      };
      return CSetextHeader;
  })();
  var CBlockquote = (function () {
      function CBlockquote(value0) {
          this.value0 = value0;
      };
      CBlockquote.create = function (value0) {
          return new CBlockquote(value0);
      };
      return CBlockquote;
  })();
  var CListItem = (function () {
      function CListItem(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      CListItem.create = function (value0) {
          return function (value1) {
              return new CListItem(value0, value1);
          };
      };
      return CListItem;
  })();
  var CCodeBlockFenced = (function () {
      function CCodeBlockFenced(value0, value1, value2) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
      };
      CCodeBlockFenced.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return new CCodeBlockFenced(value0, value1, value2);
              };
          };
      };
      return CCodeBlockFenced;
  })();
  var CCodeBlockIndented = (function () {
      function CCodeBlockIndented(value0) {
          this.value0 = value0;
      };
      CCodeBlockIndented.create = function (value0) {
          return new CCodeBlockIndented(value0);
      };
      return CCodeBlockIndented;
  })();
  var CLinkReference = (function () {
      function CLinkReference(value0) {
          this.value0 = value0;
      };
      CLinkReference.create = function (value0) {
          return new CLinkReference(value0);
      };
      return CLinkReference;
  })();
  var tabsToSpaces = Data_String_Common.replace("\x09")("    ");
  var splitATXHeader = function (s) {
      var level = Data_String_CodeUnits.countPrefix(function (c) {
          return Data_String_CodeUnits.singleton(c) === "#";
      })(s);
      var contents = Data_String_CodePoints.drop(level + 1 | 0)(s);
      return {
          level: level,
          contents: contents
      };
  };
  var setextLevel = function (s) {
      if (Data_String_CodePoints.take(1)(s) === "=") {
          return 1;
      };
      if (Data_Boolean.otherwise) {
          return 2;
      };
      throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser (line 101, column 1 - line 101, column 27): " + [ s.constructor.name ]);
  };
  var min = function (dictOrd) {
      return function (n) {
          return function (m) {
              var $33 = Data_Ord.lessThan(dictOrd)(n)(m);
              if ($33) {
                  return n;
              };
              return m;
          };
      };
  };
  var isTextContainer = function (v) {
      if (v instanceof CText) {
          return true;
      };
      return false;
  };
  var isSpace = function (v) {
      if (v === " ") {
          return true;
      };
      return false;
  };
  var removeNonIndentingSpaces = function (s) {
      if (Data_String_CodeUnits.countPrefix(function ($99) {
          return isSpace(Data_String_CodeUnits.singleton($99));
      })(s) < 4) {
          return Data_String_CodeUnits.dropWhile(function ($100) {
              return isSpace(Data_String_CodeUnits.singleton($100));
          })(s);
      };
      if (Data_Boolean.otherwise) {
          return s;
      };
      throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser (line 60, column 1 - line 60, column 43): " + [ s.constructor.name ]);
  };
  var isRuleChar = function (v) {
      if (v === "*") {
          return true;
      };
      if (v === "-") {
          return true;
      };
      if (v === "_") {
          return true;
      };
      return false;
  };
  var isListItem = function (v) {
      return function (v1) {
          if (v1 instanceof CListItem) {
              return Data_Eq.eq(Text_Markdown_SlamDown_Syntax_Block.eqListType)(v)(v1.value0);
          };
          return false;
      };
  };
  var isLinkReference = function (s) {
      return Data_String_CodePoints.take(1)(s) === "[" && Data_Maybe.isJust(Text_Markdown_SlamDown_Parser_References.parseLinkReference(s));
  };
  var isFenceChar = function (v) {
      if (v === "~") {
          return true;
      };
      if (v === "`") {
          return true;
      };
      return false;
  };
  var isEvaluatedCode = function (s) {
      return Data_String_CodePoints.take(1)(s) === "!";
  };
  var isDigit = function (v) {
      if (v === "0") {
          return true;
      };
      if (v === "1") {
          return true;
      };
      if (v === "2") {
          return true;
      };
      if (v === "3") {
          return true;
      };
      if (v === "4") {
          return true;
      };
      if (v === "5") {
          return true;
      };
      if (v === "6") {
          return true;
      };
      if (v === "7") {
          return true;
      };
      if (v === "8") {
          return true;
      };
      if (v === "9") {
          return true;
      };
      return false;
  };
  var isCodeFence = function (s) {
      var isSimpleFence = function (s$prime) {
          return Data_String_CodeUnits.countPrefix(function ($101) {
              return isFenceChar(Data_String_CodeUnits.singleton($101));
          })(s$prime) >= 3;
      };
      return isSimpleFence(s) || isEvaluatedCode(s) && isSimpleFence(Data_String_CodePoints.drop(1)(s));
  };
  var isBlockquoteLine = function (s) {
      return Data_String_CodePoints.take(1)(removeNonIndentingSpaces(s)) === ">";
  };
  var splitBlockquote = function (ss) {
      var blockquoteContents = function (s) {
          return Data_String_CodePoints.drop((function () {
              var $45 = Data_String_CodePoints.take(2)(s) === "> ";
              if ($45) {
                  return 2;
              };
              return 1;
          })())(s);
      };
      var sp = Data_List.span(isBlockquoteLine)(ss);
      var bq = Data_Functor.map(Data_List_Types.functorList)(function ($102) {
          return blockquoteContents(removeNonIndentingSpaces($102));
      })(sp.init);
      return {
          blockquoteLines: bq,
          otherLines: sp.rest
      };
  };
  var isATXHeader = function (s) {
      var level = Data_String_CodeUnits.countPrefix(function (c) {
          return Data_String_CodeUnits.singleton(c) === "#";
      })(s);
      var rest = Data_String_CodePoints.drop(level)(s);
      return level >= 1 && (level <= 6 && Data_String_CodePoints.take(1)(rest) === " ");
  };
  var getCText = function (v) {
      if (v instanceof CText) {
          return v.value0;
      };
      return "";
  };
  var getCListItem = function (v) {
      if (v instanceof CListItem) {
          return v.value1;
      };
      return Data_List_Types.Nil.value;
  };
  var parseBlocks = function (dictValue) {
      return function (v) {
          if (v instanceof Data_List_Types.Nil) {
              return Control_Applicative.pure(Data_Either.applicativeEither)(Data_List_Types.Nil.value);
          };
          if (v instanceof Data_List_Types.Cons && (v.value0 instanceof CText && (v.value1 instanceof Data_List_Types.Cons && v.value1.value0 instanceof CSetextHeader))) {
              return Control_Bind.bind(Data_Either.bindEither)(Text_Markdown_SlamDown_Parser_Inline.parseInlines(dictValue)(Data_List.singleton(v.value0.value0)))(function (hd) {
                  return Control_Bind.bind(Data_Either.bindEither)(parseBlocks(dictValue)(v.value1.value1))(function (tl) {
                      return Control_Applicative.pure(Data_Either.applicativeEither)(new Data_List_Types.Cons(new Text_Markdown_SlamDown_Syntax_Block.Header(v.value1.value0.value0, hd), tl));
                  });
              });
          };
          if (v instanceof Data_List_Types.Cons && v.value0 instanceof CText) {
              var sp = Data_List.span(isTextContainer)(v.value1);
              return Control_Bind.bind(Data_Either.bindEither)(Text_Markdown_SlamDown_Parser_Inline.parseInlines(dictValue)(new Data_List_Types.Cons(v.value0.value0, Data_Functor.map(Data_List_Types.functorList)(getCText)(sp.init))))(function (is) {
                  return Control_Bind.bind(Data_Either.bindEither)(parseBlocks(dictValue)(sp.rest))(function (tl) {
                      return Control_Applicative.pure(Data_Either.applicativeEither)(new Data_List_Types.Cons(new Text_Markdown_SlamDown_Syntax_Block.Paragraph(is), tl));
                  });
              });
          };
          if (v instanceof Data_List_Types.Cons && v.value0 instanceof CRule) {
              return Data_Functor.map(Data_Either.functorEither)(function (v1) {
                  return new Data_List_Types.Cons(Text_Markdown_SlamDown_Syntax_Block.Rule.value, v1);
              })(parseBlocks(dictValue)(v.value1));
          };
          if (v instanceof Data_List_Types.Cons && v.value0 instanceof CATXHeader) {
              return Control_Bind.bind(Data_Either.bindEither)(Text_Markdown_SlamDown_Parser_Inline.parseInlines(dictValue)(Data_List.singleton(v.value0.value1)))(function (hd) {
                  return Control_Bind.bind(Data_Either.bindEither)(parseBlocks(dictValue)(v.value1))(function (tl) {
                      return Control_Applicative.pure(Data_Either.applicativeEither)(new Data_List_Types.Cons(new Text_Markdown_SlamDown_Syntax_Block.Header(v.value0.value0, hd), tl));
                  });
              });
          };
          if (v instanceof Data_List_Types.Cons && v.value0 instanceof CBlockquote) {
              return Control_Bind.bind(Data_Either.bindEither)(parseBlocks(dictValue)(v.value0.value0))(function (hd) {
                  return Control_Bind.bind(Data_Either.bindEither)(parseBlocks(dictValue)(v.value1))(function (tl) {
                      return Control_Applicative.pure(Data_Either.applicativeEither)(new Data_List_Types.Cons(new Text_Markdown_SlamDown_Syntax_Block.Blockquote(hd), tl));
                  });
              });
          };
          if (v instanceof Data_List_Types.Cons && v.value0 instanceof CListItem) {
              var sp = Data_List.span(isListItem(v.value0.value0))(v.value1);
              return Control_Bind.bind(Data_Either.bindEither)(parseBlocks(dictValue)(v.value0.value1))(function (bs) {
                  return Control_Bind.bind(Data_Either.bindEither)(Data_Traversable.traverse(Data_List_Types.traversableList)(Data_Either.applicativeEither)((function () {
                      var $103 = parseBlocks(dictValue);
                      return function ($104) {
                          return $103(getCListItem($104));
                      };
                  })())(sp.init))(function (bss) {
                      return Control_Bind.bind(Data_Either.bindEither)(parseBlocks(dictValue)(sp.rest))(function (tl) {
                          return Control_Applicative.pure(Data_Either.applicativeEither)(new Data_List_Types.Cons(new Text_Markdown_SlamDown_Syntax_Block.Lst(v.value0.value0, new Data_List_Types.Cons(bs, bss)), tl));
                      });
                  });
              });
          };
          if (v instanceof Data_List_Types.Cons && v.value0 instanceof CCodeBlockIndented) {
              return Data_Functor.map(Data_Either.functorEither)(function (v1) {
                  return new Data_List_Types.Cons(new Text_Markdown_SlamDown_Syntax_Block.CodeBlock(Text_Markdown_SlamDown_Syntax_Block.Indented.value, v.value0.value0), v1);
              })(parseBlocks(dictValue)(v.value1));
          };
          if (v instanceof Data_List_Types.Cons && v.value0 instanceof CCodeBlockFenced) {
              return Data_Functor.map(Data_Either.functorEither)(function (v1) {
                  return new Data_List_Types.Cons(new Text_Markdown_SlamDown_Syntax_Block.CodeBlock(new Text_Markdown_SlamDown_Syntax_Block.Fenced(v.value0.value0, v.value0.value1), v.value0.value2), v1);
              })(parseBlocks(dictValue)(v.value1));
          };
          if (v instanceof Data_List_Types.Cons && v.value0 instanceof CLinkReference) {
              return Data_Functor.map(Data_Either.functorEither)(function (v1) {
                  return new Data_List_Types.Cons(v.value0.value0, v1);
              })(parseBlocks(dictValue)(v.value1));
          };
          if (v instanceof Data_List_Types.Cons) {
              return parseBlocks(dictValue)(v.value1);
          };
          throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser (line 322, column 3 - line 358, column 21): " + [ v.constructor.name ]);
      };
  };
  var fromIndentedChunk = Data_String_CodePoints.drop(4);
  var countLeadingSpaces = Data_String_CodeUnits.countPrefix(function ($105) {
      return isSpace(Data_String_CodeUnits.singleton($105));
  });
  var isBulleted = function (s) {
      var isBullet = function (v) {
          if (v === "*") {
              return true;
          };
          if (v === "+") {
              return true;
          };
          if (v === "-") {
              return true;
          };
          return false;
      };
      var ls = countLeadingSpaces(Data_String_CodePoints.drop(1)(s));
      var b = Data_String_CodePoints.take(1)(s);
      return isBullet(b) && (ls > 0 && ls < 5);
  };
  var listItemType = function (s) {
      if (isBulleted(s)) {
          return new Text_Markdown_SlamDown_Syntax_Block.Bullet(Data_String_CodePoints.take(1)(s));
      };
      if (Data_Boolean.otherwise) {
          var n = Data_String_CodeUnits.countPrefix(function ($106) {
              return isDigit(Data_String_CodeUnits.singleton($106));
          })(s);
          return new Text_Markdown_SlamDown_Syntax_Block.Ordered(Data_String_CodePoints.take(1)(Data_String_CodePoints.drop(n)(s)));
      };
      throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser (line 148, column 1 - line 148, column 36): " + [ s.constructor.name ]);
  };
  var isIndentedTo = function (n) {
      return function (s) {
          return countLeadingSpaces(s) >= n;
      };
  };
  var isIndentedChunk = function (s) {
      return isIndentedTo(4)(s);
  };
  var splitIndentedChunks = function (ss) {
      var sp = Data_List.span(isIndentedChunk)(ss);
      var codeLines = Data_Functor.map(Data_List_Types.functorList)(fromIndentedChunk)(sp.init);
      return {
          codeLines: codeLines,
          otherLines: sp.rest
      };
  };
  var isOrderedListMarker = function (s) {
      var n = Data_String_CodeUnits.countPrefix(function ($107) {
          return isDigit(Data_String_CodeUnits.singleton($107));
      })(s);
      var next = Data_String_CodePoints.take(1)(Data_String_CodePoints.drop(n)(s));
      var ls = countLeadingSpaces(Data_String_CodePoints.drop(n + 1 | 0)(s));
      return n > 0 && ((next === "." || next === ")") && ls > 0);
  };
  var isListItemLine = function (s) {
      var s$prime = removeNonIndentingSpaces(s);
      return isBulleted(s$prime) || isOrderedListMarker(s$prime);
  };
  var listItemIndent = function (s) {
      if (isBulleted(s)) {
          return 1 + min(Data_Ord.ordInt)(4)(countLeadingSpaces(Data_String_CodePoints.drop(1)(s))) | 0;
      };
      if (Data_Boolean.otherwise) {
          var n = Data_String_CodeUnits.countPrefix(function ($108) {
              return isDigit(Data_String_CodeUnits.singleton($108));
          })(s);
          return (n + 1 | 0) + min(Data_Ord.ordInt)(4)(countLeadingSpaces(Data_String_CodePoints.drop(n + 1 | 0)(s))) | 0;
      };
      throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser (line 155, column 1 - line 155, column 30): " + [ s.constructor.name ]);
  };
  var splitListItem = function (s) {
      return function (ss) {
          var s1 = removeNonIndentingSpaces(s);
          var listType = listItemType(s1);
          var indent = listItemIndent(s1);
          var sp = Data_List.span(isIndentedTo(indent))(ss);
          var listItemLines = Data_List_Types.Cons.create(Data_String_CodePoints.drop(indent)(s1))(Data_Functor.map(Data_List_Types.functorList)(Data_String_CodePoints.drop(indent))(sp.init));
          return {
              listType: listType,
              listItemLines: listItemLines,
              otherLines: sp.rest
          };
      };
  };
  var splitCodeFence = function (indent) {
      return function (fence) {
          return function (ss) {
              var removeIndentTo = function (s) {
                  return Data_String_CodePoints.drop(min(Data_Ord.ordInt)(indent)(countLeadingSpaces(s)))(s);
              };
              var isClosingFence = function (s) {
                  return Data_String_CodeUnits.countPrefix(function (c) {
                      return Data_String_CodeUnits.singleton(c) === fence;
                  })(removeNonIndentingSpaces(s)) >= 3;
              };
              var sp = Data_List.span((function () {
                  var $109 = Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean);
                  return function ($110) {
                      return $109(isClosingFence($110));
                  };
              })())(ss);
              var codeLines = Data_Functor.map(Data_List_Types.functorList)(removeIndentTo)(sp.init);
              return {
                  codeLines: codeLines,
                  otherLines: Data_List.drop(1)(sp.rest)
              };
          };
      };
  };
  var codeFenceInfo = (function () {
      var $111 = Data_String_CodeUnits.dropWhile(function ($113) {
          return isFenceChar(Data_String_CodeUnits.singleton($113));
      });
      return function ($112) {
          return Data_String_Common.trim($111($112));
      };
  })();
  var codeFenceChar = Data_String_CodePoints.take(1);
  var allChars = function (p) {
      var $114 = Data_Foldable.all(Data_Foldable.foldableArray)(Data_HeytingAlgebra.heytingAlgebraBoolean)(p);
      var $115 = Data_String_Common.split("");
      return function ($116) {
          return $114($115($116));
      };
  };
  var isRule = function (s) {
      return allChars(isRuleChar)(s) && (Data_String_CodePoints.length(s) >= 3 && allChars(Data_Eq.eq(Data_Eq.eqString)(Data_String_CodePoints.take(1)(s)))(s));
  };
  var isSetextHeader = function (v) {
      return function (v1) {
          if (v1 instanceof Data_Maybe.Just && v1.value0 instanceof CText) {
              return Data_String_CodePoints.length(v) >= 1 && Data_Foldable.any(Data_Foldable.foldableArray)(Data_HeytingAlgebra.heytingAlgebraBoolean)(function (c) {
                  return allChars(Data_Eq.eq(Data_Eq.eqString)(c))(v);
              })([ "=", "-" ]);
          };
          return false;
      };
  };
  var parseContainers = function (acc) {
      return function (v) {
          if (v instanceof Data_List_Types.Nil) {
              return Data_List.reverse(acc);
          };
          if (v instanceof Data_List_Types.Cons) {
              if (allChars(isSpace)(v.value0)) {
                  return parseContainers(new Data_List_Types.Cons(CBlank.value, acc))(v.value1);
              };
              if (isATXHeader(removeNonIndentingSpaces(v.value0))) {
                  var o = splitATXHeader(removeNonIndentingSpaces(v.value0));
                  return parseContainers(new Data_List_Types.Cons(new CATXHeader(o.level, o.contents), acc))(v.value1);
              };
              if (isSetextHeader(removeNonIndentingSpaces(Data_String_Common.trim(v.value0)))(Data_List.last(acc))) {
                  return parseContainers(new Data_List_Types.Cons(CSetextHeader.create(setextLevel(removeNonIndentingSpaces(Data_String_Common.trim(v.value0)))), acc))(v.value1);
              };
              if (isRule(removeNonIndentingSpaces(v.value0))) {
                  return parseContainers(new Data_List_Types.Cons(CRule.value, acc))(v.value1);
              };
              if (isBlockquoteLine(v.value0)) {
                  var o = splitBlockquote(new Data_List_Types.Cons(v.value0, v.value1));
                  return parseContainers(new Data_List_Types.Cons(new CBlockquote(parseContainers(Data_Monoid.mempty(Data_List_Types.monoidList))(o.blockquoteLines)), acc))(o.otherLines);
              };
              if (isListItemLine(v.value0)) {
                  var o = splitListItem(v.value0)(v.value1);
                  return parseContainers(new Data_List_Types.Cons(CListItem.create(o.listType)(parseContainers(Data_Monoid.mempty(Data_List_Types.monoidList))(o.listItemLines)), acc))(o.otherLines);
              };
              if (isIndentedChunk(v.value0)) {
                  var o = splitIndentedChunks(new Data_List_Types.Cons(v.value0, v.value1));
                  return parseContainers(new Data_List_Types.Cons(new CCodeBlockIndented(o.codeLines), acc))(o.otherLines);
              };
              if (isCodeFence(removeNonIndentingSpaces(v.value0))) {
                  var s1 = removeNonIndentingSpaces(v.value0);
                  var $$eval = isEvaluatedCode(s1);
                  var s2 = (function () {
                      if ($$eval) {
                          return Data_String_CodePoints.drop(1)(s1);
                      };
                      return s1;
                  })();
                  var info = codeFenceInfo(s2);
                  var ch = codeFenceChar(s2);
                  var o = splitCodeFence(countLeadingSpaces(v.value0))(ch)(v.value1);
                  return parseContainers(new Data_List_Types.Cons(new CCodeBlockFenced($$eval, info, o.codeLines), acc))(o.otherLines);
              };
              if (isLinkReference(removeNonIndentingSpaces(v.value0))) {
                  var s1 = removeNonIndentingSpaces(v.value0);
                  var b = Data_Maybe.fromJust()(Text_Markdown_SlamDown_Parser_References.parseLinkReference(s1));
                  return parseContainers(new Data_List_Types.Cons(new CLinkReference(b), acc))(v.value1);
              };
              if (Data_Boolean.otherwise) {
                  return parseContainers(new Data_List_Types.Cons(new CText(v.value0), acc))(v.value1);
              };
          };
          throw new Error("Failed pattern match at Text.Markdown.SlamDown.Parser (line 257, column 1 - line 261, column 25): " + [ acc.constructor.name, v.constructor.name ]);
      };
  };
  var parseMd = function (dictValue) {
      return function (s) {
          var slashR = Data_String_Regex_Unsafe.unsafeRegex("\\r")(Data_String_Regex_Flags.global);
          var lines = Data_List.fromFoldable(Data_Foldable.foldableArray)(Data_String_Common.split("\x0a")(Data_String_Regex.replace(slashR)("")(tabsToSpaces(s))));
          var ctrs = parseContainers(Data_Monoid.mempty(Data_List_Types.monoidList))(lines);
          var bs = parseBlocks(dictValue)(ctrs);
          return Data_Functor.map(Data_Either.functorEither)(Text_Markdown_SlamDown_Syntax.SlamDown)(bs);
      };
  };
  exports["parseMd"] = parseMd;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Smolder.Markup"] = $PS["Text.Smolder.Markup"] || {};
  var exports = $PS["Text.Smolder.Markup"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Monad_Free = $PS["Control.Monad.Free"];
  var Data_CatList = $PS["Data.CatList"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Unit = $PS["Data.Unit"];                
  var HTMLns = (function () {
      function HTMLns() {

      };
      HTMLns.value = new HTMLns();
      return HTMLns;
  })();
  var SVGns = (function () {
      function SVGns() {

      };
      SVGns.value = new SVGns();
      return SVGns;
  })();
  var Attr = (function () {
      function Attr(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Attr.create = function (value0) {
          return function (value1) {
              return new Attr(value0, value1);
          };
      };
      return Attr;
  })();
  var SafeAttr = (function () {
      function SafeAttr(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      SafeAttr.create = function (value0) {
          return function (value1) {
              return new SafeAttr(value0, value1);
          };
      };
      return SafeAttr;
  })();
  var Attribute = (function () {
      function Attribute(value0) {
          this.value0 = value0;
      };
      Attribute.create = function (value0) {
          return new Attribute(value0);
      };
      return Attribute;
  })();
  var Attributable = function ($$with) {
      this["with"] = $$with;
  };
  var Element = (function () {
      function Element(value0, value1, value2, value3, value4, value5) {
          this.value0 = value0;
          this.value1 = value1;
          this.value2 = value2;
          this.value3 = value3;
          this.value4 = value4;
          this.value5 = value5;
      };
      Element.create = function (value0) {
          return function (value1) {
              return function (value2) {
                  return function (value3) {
                      return function (value4) {
                          return function (value5) {
                              return new Element(value0, value1, value2, value3, value4, value5);
                          };
                      };
                  };
              };
          };
      };
      return Element;
  })();
  var Doctype = (function () {
      function Doctype(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Doctype.create = function (value0) {
          return function (value1) {
              return new Doctype(value0, value1);
          };
      };
      return Doctype;
  })();
  var Content = (function () {
      function Content(value0, value1) {
          this.value0 = value0;
          this.value1 = value1;
      };
      Content.create = function (value0) {
          return function (value1) {
              return new Content(value0, value1);
          };
      };
      return Content;
  })();
  var Empty = (function () {
      function Empty(value0) {
          this.value0 = value0;
      };
      Empty.create = function (value0) {
          return new Empty(value0);
      };
      return Empty;
  })();
  var $$with = function (dict) {
      return dict["with"];
  };
  var text = function (s) {
      return Control_Monad_Free.liftF(new Content(s, Data_Unit.unit));
  };
  var parent = function (ns) {
      return function (el) {
          return function (kids) {
              return Control_Monad_Free.liftF(new Element(ns, el, kids, Data_Monoid.mempty(Data_CatList.monoidCatList), Data_Monoid.mempty(Data_CatList.monoidCatList), Data_Unit.unit));
          };
      };
  };                                                                
  var leaf = function (ns) {
      return function (el) {
          return Control_Monad_Free.liftF(new Element(ns, el, Control_Monad_Free.liftF(new Empty(Data_Unit.unit)), Data_Monoid.mempty(Data_CatList.monoidCatList), Data_Monoid.mempty(Data_CatList.monoidCatList), Data_Unit.unit));
      };
  }; 
  var eqNS = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof HTMLns && y instanceof HTMLns) {
              return true;
          };
          if (x instanceof SVGns && y instanceof SVGns) {
              return true;
          };
          return false;
      };
  });
  var empty = Control_Monad_Free.liftF(new Empty(Data_Unit.unit));
  var attribute = function (key) {
      return function (value) {
          return new Attribute(Control_Applicative.pure(Data_CatList.applicativeCatList)(new Attr(key, value)));
      };
  };
  var attributableMarkup = new Attributable(function (f) {
      return function (v) {
          var withF = function (v1) {
              if (v1 instanceof Element) {
                  return new Element(v1.value0, v1.value1, v1.value2, Data_Semigroup.append(Data_CatList.semigroupCatList)(v1.value3)(v.value0), v1.value4, v1.value5);
              };
              return v1;
          };
          return Control_Monad_Free.hoistFree(withF)(f);
      };
  });
  var attributableMarkupF = new Attributable(function (k) {
      return function (xs) {
          return function (m) {
              return $$with(attributableMarkup)(k(m))(xs);
          };
      };
  });
  exports["Element"] = Element;
  exports["Doctype"] = Doctype;
  exports["Content"] = Content;
  exports["Empty"] = Empty;
  exports["HTMLns"] = HTMLns;
  exports["Attr"] = Attr;
  exports["SafeAttr"] = SafeAttr;
  exports["parent"] = parent;
  exports["leaf"] = leaf;
  exports["text"] = text;
  exports["empty"] = empty;
  exports["with"] = $$with;
  exports["attribute"] = attribute;
  exports["eqNS"] = eqNS;
  exports["attributableMarkup"] = attributableMarkup;
  exports["attributableMarkupF"] = attributableMarkupF;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Smolder.HTML"] = $PS["Text.Smolder.HTML"] || {};
  var exports = $PS["Text.Smolder.HTML"];
  var Text_Smolder_Markup = $PS["Text.Smolder.Markup"];                
  var parent = Text_Smolder_Markup.parent(Text_Smolder_Markup.HTMLns.value);
  var pre = parent("pre");  
  var strong = parent("strong");
  var ul = parent("ul");      
  var p = parent("p");              
  var ol = parent("ol");    
  var li = parent("li");        
  var leaf = Text_Smolder_Markup.leaf(Text_Smolder_Markup.HTMLns.value);
  var img = leaf("img");    
  var hr = leaf("hr");      
  var em = parent("em");
  var code = parent("code");    
  var br = leaf("br");      
  var blockquote = parent("blockquote");
  var a = parent("a");
  exports["parent"] = parent;
  exports["a"] = a;
  exports["blockquote"] = blockquote;
  exports["code"] = code;
  exports["em"] = em;
  exports["li"] = li;
  exports["ol"] = ol;
  exports["p"] = p;
  exports["pre"] = pre;
  exports["strong"] = strong;
  exports["ul"] = ul;
  exports["br"] = br;
  exports["hr"] = hr;
  exports["img"] = img;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Smolder.HTML.Attributes"] = $PS["Text.Smolder.HTML.Attributes"] || {};
  var exports = $PS["Text.Smolder.HTML.Attributes"];
  var Text_Smolder_Markup = $PS["Text.Smolder.Markup"];
  var src = Text_Smolder_Markup.attribute("src");    
  var id = Text_Smolder_Markup.attribute("id");            
  var href = Text_Smolder_Markup.attribute("href");
  var className = Text_Smolder_Markup.attribute("class");
  var alt = Text_Smolder_Markup.attribute("alt");
  exports["alt"] = alt;
  exports["className"] = className;
  exports["href"] = href;
  exports["id"] = id;
  exports["src"] = src;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.Smolder.Internal.Inline"] = $PS["Text.Markdown.Smolder.Internal.Inline"] || {};
  var exports = $PS["Text.Markdown.Smolder.Internal.Inline"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Control_Monad_Free = $PS["Control.Monad.Free"];
  var Control_Monad_Reader_Class = $PS["Control.Monad.Reader.Class"];
  var Control_Monad_Reader_Trans = $PS["Control.Monad.Reader.Trans"];
  var Data_Either = $PS["Data.Either"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_String_Regex = $PS["Data.String.Regex"];
  var Data_String_Regex_Flags = $PS["Data.String.Regex.Flags"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Text_Markdown_SlamDown_Syntax_Inline = $PS["Text.Markdown.SlamDown.Syntax.Inline"];
  var Text_Smolder_HTML = $PS["Text.Smolder.HTML"];
  var Text_Smolder_HTML_Attributes = $PS["Text.Smolder.HTML.Attributes"];
  var Text_Smolder_Markup = $PS["Text.Smolder.Markup"];                
  var toInline = function (il) {
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Str) {
          return il.value0;
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Entity) {
          return il.value0;
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Space) {
          return " ";
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.SoftBreak) {
          return "\x0a";
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.LineBreak) {
          return "\x0a";
      };
      return "";
  };
  var toInlines = function (is) {
      return Data_Foldable.foldl(Data_List_Types.foldableList)(function (str) {
          return function (il) {
              return str + toInline(il);
          };
      })("")(is);
  };
  var toInlineElements = function (is) {
      return Data_Functor.map(Control_Monad_Reader_Trans.functorReaderT(Data_Identity.functorIdentity))(Data_Foldable.sequence_(Control_Monad_Free.freeApplicative)(Data_List_Types.foldableList))(Data_Traversable.traverse(Data_List_Types.traversableList)(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(toInlineElement)(is));
  };
  var toInlineElement = function (il) {
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Str) {
          return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_Markup.text(il.value0));
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Entity) {
          return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_Markup.text(il.value0));
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Space) {
          return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_Markup.text(" "));
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.SoftBreak) {
          return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_Markup.text("\x0a"));
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.LineBreak) {
          return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_HTML.br);
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Emph) {
          return Control_Bind.bindFlipped(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))((function () {
              var $29 = Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity));
              return function ($30) {
                  return $29(Text_Smolder_HTML.em($30));
              };
          })())(toInlineElements(il.value0));
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Strong) {
          return Control_Bind.bindFlipped(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))((function () {
              var $31 = Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity));
              return function ($32) {
                  return $31(Text_Smolder_HTML.strong($32));
              };
          })())(toInlineElements(il.value0));
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Code) {
          return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_HTML.code(Text_Smolder_Markup.text(il.value1)));
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Link && il.value1 instanceof Text_Markdown_SlamDown_Syntax_Inline.InlineLink) {
          return Control_Bind.bind(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))(toInlineElements(il.value0))((function () {
              var $33 = Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity));
              var $34 = Text_Smolder_Markup["with"](Text_Smolder_Markup.attributableMarkupF)(Text_Smolder_HTML.a)(Text_Smolder_HTML_Attributes.href(il.value1.value0));
              return function ($35) {
                  return $33($34($35));
              };
          })());
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Link && il.value1 instanceof Text_Markdown_SlamDown_Syntax_Inline.ReferenceLink) {
          return Control_Bind.bind(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))(toInlineElements(il.value0))(function (el) {
              return Control_Bind.bind(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))(Control_Monad_Reader_Class.ask(Control_Monad_Reader_Trans.monadAskReaderT(Data_Identity.monadIdentity)))(function (v) {
                  var url = Data_Maybe.maybe("")(function (k) {
                      return Data_Maybe.fromMaybe("")(Data_Map_Internal.lookup(Data_Ord.ordString)(k)(v.referenceLinks));
                  })(il.value1.value0);
                  var urlAttr = Text_Smolder_HTML_Attributes.href(url);
                  return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_Markup["with"](Text_Smolder_Markup.attributableMarkupF)(Text_Smolder_HTML.a)(urlAttr)(el));
              });
          });
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.Image) {
          return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_Markup["with"](Text_Smolder_Markup.attributableMarkup)(Text_Smolder_Markup["with"](Text_Smolder_Markup.attributableMarkup)(Text_Smolder_HTML.img)(Text_Smolder_HTML_Attributes.src(il.value1)))(Text_Smolder_HTML_Attributes.alt(toInlines(il.value0))));
      };
      if (il instanceof Text_Markdown_SlamDown_Syntax_Inline.FormField) {
          return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_Markup.empty);
      };
      throw new Error("Failed pattern match at Text.Markdown.Smolder.Internal.Inline (line 29, column 3 - line 50, column 41): " + [ il.constructor.name ]);
  };
  var encodeInlines = function (inlines) {
      var stripInvalidChars = function (pattern) {
          return Data_String_Regex.replace(pattern)("");
      };
      var replaceSpaces = Data_String_Common.replaceAll(" ")("_");
      var encoded = function (stripFn) {
          return replaceSpaces(Data_Foldable.intercalate(Data_List_Types.foldableList)(Data_Monoid.monoidString)("")(Data_List.filter(function (v) {
              return v !== "\x0a";
          })(Data_Functor.map(Data_List_Types.functorList)(function ($36) {
              return stripFn(toInline($36));
          })(inlines))));
      };
      var v = Data_String_Regex.regex("[^\\w -]")(Data_String_Regex_Flags.global);
      if (v instanceof Data_Either.Left) {
          return encoded(Control_Category.identity(Control_Category.categoryFn));
      };
      if (v instanceof Data_Either.Right) {
          return encoded(stripInvalidChars(v.value0));
      };
      throw new Error("Failed pattern match at Text.Markdown.Smolder.Internal.Inline (line 69, column 3 - line 71, column 57): " + [ v.constructor.name ]);
  };
  exports["toInlineElements"] = toInlineElements;
  exports["encodeInlines"] = encodeInlines;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.Smolder.Internal.Block"] = $PS["Text.Markdown.Smolder.Internal.Block"] || {};
  var exports = $PS["Text.Markdown.Smolder.Internal.Block"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Free = $PS["Control.Monad.Free"];
  var Control_Monad_Reader_Class = $PS["Control.Monad.Reader.Class"];
  var Control_Monad_Reader_Trans = $PS["Control.Monad.Reader.Trans"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Text_Markdown_SlamDown_Syntax_Block = $PS["Text.Markdown.SlamDown.Syntax.Block"];
  var Text_Markdown_Smolder_Internal_Inline = $PS["Text.Markdown.Smolder.Internal.Inline"];
  var Text_Smolder_HTML = $PS["Text.Smolder.HTML"];
  var Text_Smolder_HTML_Attributes = $PS["Text.Smolder.HTML.Attributes"];
  var Text_Smolder_Markup = $PS["Text.Smolder.Markup"];                
  var toParagraphElement = function (is) {
      return Control_Bind.bind(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))(Control_Monad_Reader_Class.ask(Control_Monad_Reader_Trans.monadAskReaderT(Data_Identity.monadIdentity)))(function (v) {
          var p$prime = (function () {
              var $6 = v.options.pClass === "";
              if ($6) {
                  return Text_Smolder_HTML.p;
              };
              return Text_Smolder_Markup["with"](Text_Smolder_Markup.attributableMarkupF)(Text_Smolder_HTML.p)(Text_Smolder_HTML_Attributes.className(v.options.pClass));
          })();
          return Control_Bind.bindFlipped(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))((function () {
              var $44 = Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity));
              return function ($45) {
                  return $44(p$prime($45));
              };
          })())(Text_Markdown_Smolder_Internal_Inline.toInlineElements(is));
      });
  };
  var toHeaderElement = function (level) {
      return function (is) {
          return Control_Bind.bind(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))(Control_Monad_Reader_Class.ask(Control_Monad_Reader_Trans.monadAskReaderT(Data_Identity.monadIdentity)))(function (v) {
              return Control_Bind.bind(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))(Text_Markdown_Smolder_Internal_Inline.toInlineElements(is))(function (inlineEls) {
                  var el = Text_Smolder_HTML.parent("h" + Data_Show.show(Data_Show.showInt)(level))(inlineEls);
                  var hWithId = (function () {
                      if (v.options.hideHeadingId) {
                          return el;
                      };
                      return Text_Smolder_Markup["with"](Text_Smolder_Markup.attributableMarkup)(el)(Text_Smolder_HTML_Attributes.id(Text_Markdown_Smolder_Internal_Inline.encodeInlines(is)));
                  })();
                  var cls = Data_Functor.map(Data_Maybe.functorMaybe)(Data_Tuple.snd)(Data_Foldable.find(Data_Foldable.foldableArray)((function () {
                      var $46 = Data_Eq.eq(Data_Eq.eqInt)(level);
                      return function ($47) {
                          return $46(Data_Tuple.fst($47));
                      };
                  })())(v.options.hClasses));
                  return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Data_Maybe.maybe(hWithId)(function (c) {
                      return Text_Smolder_Markup["with"](Text_Smolder_Markup.attributableMarkup)(hWithId)(Text_Smolder_HTML_Attributes.className(c));
                  })(cls));
              });
          });
      };
  };
  var toCodeBlockContent = function (ss) {
      return Data_Function.flip(Data_Foldable.traverse_(Control_Monad_Free.freeApplicative)(Data_List_Types.foldableList))(Data_List.zip(Data_List.range(1)(Data_List.length(ss)))(ss))(function (v) {
          var $15 = v.value0 === 1;
          if ($15) {
              return Text_Smolder_Markup.text(v.value1);
          };
          return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_Free.freeBind)(Text_Smolder_HTML.br)(function () {
              return Text_Smolder_Markup.text(v.value1);
          });
      });
  };
  var toListElements = function (lstType) {
      return function (bss) {
          var toBlockItems = function (b) {
              return Data_Functor.map(Control_Monad_Reader_Trans.functorReaderT(Data_Identity.functorIdentity))(Data_Foldable.sequence_(Control_Monad_Free.freeApplicative)(Data_List_Types.foldableList))(Data_Traversable.traverse(Data_List_Types.traversableList)(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(toListElement)(b));
          };
          var lstItems = Data_Functor.map(Control_Monad_Reader_Trans.functorReaderT(Data_Identity.functorIdentity))(Data_Foldable.sequence_(Control_Monad_Free.freeApplicative)(Data_List_Types.foldableList))(Data_Traversable.traverse(Data_List_Types.traversableList)(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(function (bs) {
              return Data_Functor.map(Control_Monad_Reader_Trans.functorReaderT(Data_Identity.functorIdentity))(Text_Smolder_HTML.li)(toBlockItems(bs));
          })(bss));
          return Control_Bind.bind(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))(Control_Monad_Reader_Class.ask(Control_Monad_Reader_Trans.monadAskReaderT(Data_Identity.monadIdentity)))(function (v) {
              if (lstType instanceof Text_Markdown_SlamDown_Syntax_Block.Bullet) {
                  var ul$prime = (function () {
                      var $20 = v.options.ulClass === "";
                      if ($20) {
                          return Text_Smolder_HTML.ul;
                      };
                      return Text_Smolder_Markup["with"](Text_Smolder_Markup.attributableMarkupF)(Text_Smolder_HTML.ul)(Text_Smolder_HTML_Attributes.className(v.options.ulClass));
                  })();
                  return Data_Functor.map(Control_Monad_Reader_Trans.functorReaderT(Data_Identity.functorIdentity))(ul$prime)(lstItems);
              };
              if (lstType instanceof Text_Markdown_SlamDown_Syntax_Block.Ordered) {
                  var ol$prime = (function () {
                      var $22 = v.options.olClass === "";
                      if ($22) {
                          return Text_Smolder_HTML.ol;
                      };
                      return Text_Smolder_Markup["with"](Text_Smolder_Markup.attributableMarkupF)(Text_Smolder_HTML.ol)(Text_Smolder_HTML_Attributes.className(v.options.olClass));
                  })();
                  return Data_Functor.map(Control_Monad_Reader_Trans.functorReaderT(Data_Identity.functorIdentity))(ol$prime)(lstItems);
              };
              throw new Error("Failed pattern match at Text.Markdown.Smolder.Internal.Block (line 50, column 3 - line 62, column 26): " + [ lstType.constructor.name ]);
          });
      };
  };
  var toListElement = function (block) {
      if (block instanceof Text_Markdown_SlamDown_Syntax_Block.Paragraph) {
          return Text_Markdown_Smolder_Internal_Inline.toInlineElements(block.value0);
      };
      return toElement(block);
  };
  var toElements = function (bs) {
      return Data_Functor.map(Control_Monad_Reader_Trans.functorReaderT(Data_Identity.functorIdentity))(Data_Foldable.sequence_(Control_Monad_Free.freeApplicative)(Data_List_Types.foldableList))(Data_Traversable.traverse(Data_List_Types.traversableList)(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(toElement)(bs));
  };
  var toElement = function (block) {
      return Control_Bind.bind(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))(Control_Monad_Reader_Class.ask(Control_Monad_Reader_Trans.monadAskReaderT(Data_Identity.monadIdentity)))(function (v) {
          if (block instanceof Text_Markdown_SlamDown_Syntax_Block.Paragraph) {
              return toParagraphElement(block.value0);
          };
          if (block instanceof Text_Markdown_SlamDown_Syntax_Block.Header) {
              return toHeaderElement(block.value0)(block.value1);
          };
          if (block instanceof Text_Markdown_SlamDown_Syntax_Block.Blockquote) {
              return Control_Bind.bindFlipped(Control_Monad_Reader_Trans.bindReaderT(Data_Identity.bindIdentity))((function () {
                  var $48 = Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity));
                  return function ($49) {
                      return $48(Text_Smolder_HTML.blockquote($49));
                  };
              })())(toElements(block.value0));
          };
          if (block instanceof Text_Markdown_SlamDown_Syntax_Block.Lst) {
              return toListElements(block.value0)(block.value1);
          };
          if (block instanceof Text_Markdown_SlamDown_Syntax_Block.CodeBlock && block.value0 instanceof Text_Markdown_SlamDown_Syntax_Block.Indented) {
              return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_HTML.pre(Text_Smolder_HTML.code(toCodeBlockContent(block.value1))));
          };
          if (block instanceof Text_Markdown_SlamDown_Syntax_Block.CodeBlock && block.value0 instanceof Text_Markdown_SlamDown_Syntax_Block.Fenced) {
              return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(v.options.renderFencedCodeBlock(block.value0.value1)(block.value1));
          };
          if (block instanceof Text_Markdown_SlamDown_Syntax_Block.Rule) {
              return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_HTML.hr);
          };
          return Control_Applicative.pure(Control_Monad_Reader_Trans.applicativeReaderT(Data_Identity.applicativeIdentity))(Text_Smolder_Markup.empty);
      });
  };
  var renderFencedCodeBlock = function (info) {
      return function (ss) {
          return Text_Smolder_Markup["with"](Text_Smolder_Markup.attributableMarkupF)(Text_Smolder_Markup["with"](Text_Smolder_Markup.attributableMarkupF)(Text_Smolder_HTML.pre)(Text_Smolder_HTML_Attributes.className("code")))(Text_Smolder_Markup.attribute("data-lang")(info))(Text_Smolder_HTML.code(toCodeBlockContent(ss)));
      };
  };
  exports["toElements"] = toElements;
  exports["renderFencedCodeBlock"] = renderFencedCodeBlock;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Markdown.SlamDown.Smolder"] = $PS["Text.Markdown.SlamDown.Smolder"] || {};
  var exports = $PS["Text.Markdown.SlamDown.Smolder"];
  var Control_Monad_Reader = $PS["Control.Monad.Reader"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Map = $PS["Data.Map"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Text_Markdown_SlamDown_Syntax_Block = $PS["Text.Markdown.SlamDown.Syntax.Block"];
  var Text_Markdown_Smolder_Internal_Block = $PS["Text.Markdown.Smolder.Internal.Block"];              
  var getBlockLinkRefs = (function () {
      var getBlockLinkRefs$prime = function (links) {
          return function (block) {
              if (block instanceof Text_Markdown_SlamDown_Syntax_Block.LinkReference) {
                  return Data_Map_Internal.insert(Data_Ord.ordString)(block.value0)(block.value1)(links);
              };
              if (block instanceof Text_Markdown_SlamDown_Syntax_Block.Blockquote) {
                  return Data_Foldable.foldl(Data_List_Types.foldableList)(getBlockLinkRefs$prime)(links)(block.value0);
              };
              if (block instanceof Text_Markdown_SlamDown_Syntax_Block.Lst) {
                  return Data_Map_Internal.unions(Data_Ord.ordString)(Data_List_Types.foldableList)(new Data_List_Types.Cons(links, Data_Functor.map(Data_List_Types.functorList)(Data_Foldable.foldl(Data_List_Types.foldableList)(getBlockLinkRefs$prime)(Data_Map_Internal.empty))(block.value1)));
              };
              return links;
          };
      };
      return getBlockLinkRefs$prime(Data_Map_Internal.empty);
  })();
  var toMarkup$prime = function (options) {
      return function (v) {
          var referenceLinks = (function (v1) {
              return v1;
          })(Data_Foldable.foldMap(Data_List_Types.foldableList)(Data_Map.monoidSemigroupMap(Data_Ord.ordString)(Data_Semigroup.semigroupString))(function ($11) {
              return Data_Map.SemigroupMap(getBlockLinkRefs($11));
          })(v));
          return Control_Monad_Reader.runReader(Text_Markdown_Smolder_Internal_Block.toElements(v))({
              referenceLinks: referenceLinks,
              options: options
          });
      };
  };
  var defaultToMarkupOptions = {
      hideHeadingId: false,
      renderFencedCodeBlock: Text_Markdown_Smolder_Internal_Block.renderFencedCodeBlock,
      olClass: "",
      ulClass: "",
      hClasses: [  ],
      pClass: ""
  };
  exports["defaultToMarkupOptions"] = defaultToMarkupOptions;
  exports["toMarkup'"] = toMarkup$prime;
})(PS);
(function(exports) {
  /* globals exports, JSON */
  "use strict";                       
  exports.unsafeEncodeURI = encodeURI;
})(PS["Global.Unsafe"] = PS["Global.Unsafe"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Global.Unsafe"] = $PS["Global.Unsafe"] || {};
  var exports = $PS["Global.Unsafe"];
  var $foreign = $PS["Global.Unsafe"];
  exports["unsafeEncodeURI"] = $foreign.unsafeEncodeURI;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Text.Smolder.Renderer.String"] = $PS["Text.Smolder.Renderer.String"] || {};
  var exports = $PS["Text.Smolder.Renderer.String"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Comonad_Cofree = $PS["Control.Comonad.Cofree"];
  var Control_Extend = $PS["Control.Extend"];
  var Control_Monad_Free = $PS["Control.Monad.Free"];
  var Control_Monad_Rec_Class = $PS["Control.Monad.Rec.Class"];
  var Control_Monad_State = $PS["Control.Monad.State"];
  var Control_Monad_State_Class = $PS["Control.Monad.State.Class"];
  var Control_Monad_State_Trans = $PS["Control.Monad.State.Trans"];
  var Data_Array = $PS["Data.Array"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_CatList = $PS["Data.CatList"];
  var Data_Char = $PS["Data.Char"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Set = $PS["Data.Set"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Global_Unsafe = $PS["Global.Unsafe"];
  var Text_Smolder_Markup = $PS["Text.Smolder.Markup"];                
  var voidElements = Data_Set.fromFoldable(Data_Foldable.foldableArray)(Data_Ord.ordString)([ "area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr" ]);
  var toStream = function (s) {
      var cs = Data_String_CodeUnits.toCharArray(s);
      return Data_Foldable.foldr(Data_Foldable.foldableArray)(function (c) {
          return function (t) {
              return Control_Comonad_Cofree.mkCofree(c)(new Data_Maybe.Just(t));
          };
      })(Control_Comonad_Cofree.mkCofree("\x00")(Data_Maybe.Nothing.value))(cs);
  };
  var isURLAttr = function (tag) {
      return function (attr) {
          if (attr === "href" && tag === "a") {
              return true;
          };
          if (attr === "href" && tag === "area") {
              return true;
          };
          if (attr === "href" && tag === "base") {
              return true;
          };
          if (attr === "href" && tag === "link") {
              return true;
          };
          if (attr === "src" && tag === "audio") {
              return true;
          };
          if (attr === "src" && tag === "embed") {
              return true;
          };
          if (attr === "src" && tag === "iframe") {
              return true;
          };
          if (attr === "src" && tag === "img") {
              return true;
          };
          if (attr === "src" && tag === "input") {
              return true;
          };
          if (attr === "src" && tag === "script") {
              return true;
          };
          if (attr === "src" && tag === "source") {
              return true;
          };
          if (attr === "src" && tag === "track") {
              return true;
          };
          if (attr === "src" && tag === "video") {
              return true;
          };
          if (attr === "code" && tag === "applet") {
              return true;
          };
          if (attr === "codebase" && tag === "applet") {
              return true;
          };
          if (attr === "data" && tag === "object") {
              return true;
          };
          if (attr === "manifest" && tag === "html") {
              return true;
          };
          if (attr === "poster" && tag === "video") {
              return true;
          };
          if (Data_Boolean.otherwise) {
              return false;
          };
          throw new Error("Failed pattern match at Text.Smolder.Renderer.String (line 75, column 1 - line 75, column 41): " + [ tag.constructor.name, attr.constructor.name ]);
      };
  };
  var isMIMEAttr = function (tag) {
      return function (attr) {
          if (attr === "type" && tag === "embed") {
              return true;
          };
          if (attr === "type" && tag === "object") {
              return true;
          };
          if (attr === "type" && tag === "script") {
              return true;
          };
          if (attr === "type" && tag === "source") {
              return true;
          };
          if (attr === "type" && tag === "style") {
              return true;
          };
          if (Data_Boolean.otherwise) {
              return false;
          };
          throw new Error("Failed pattern match at Text.Smolder.Renderer.String (line 64, column 1 - line 64, column 42): " + [ tag.constructor.name, attr.constructor.name ]);
      };
  };
  var fromStream = (function () {
      var go = function ($copy_result) {
          return function ($copy_cof) {
              var $tco_var_result = $copy_result;
              var $tco_done = false;
              var $tco_result;
              function $tco_loop(result, cof) {
                  var v = Control_Comonad_Cofree.tail(cof);
                  var v1 = Control_Comonad_Cofree.head(cof);
                  if (v instanceof Data_Maybe.Nothing) {
                      $tco_done = true;
                      return result;
                  };
                  if (v instanceof Data_Maybe.Just) {
                      $tco_var_result = result + v1;
                      $copy_cof = v.value0;
                      return;
                  };
                  throw new Error("Failed pattern match at Text.Smolder.Renderer.String (line 107, column 7 - line 109, column 48): " + [ v1.constructor.name, v.constructor.name ]);
              };
              while (!$tco_done) {
                  $tco_result = $tco_loop($tco_var_result, $copy_cof);
              };
              return $tco_result;
          };
      };
      return go("");
  })();
  var escapeMap = Data_Map_Internal.fromFoldable(Data_Ord.ordChar)(Data_Foldable.foldableArray)([ new Data_Tuple.Tuple("&", "&amp;"), new Data_Tuple.Tuple("<", "&lt;"), new Data_Tuple.Tuple(">", "&gt;"), new Data_Tuple.Tuple("\"", "&quot;"), new Data_Tuple.Tuple("'", "&#39;"), new Data_Tuple.Tuple("/", "&#x2F;") ]);
  var escapeMIMEMap = Data_Map_Internal.fromFoldable(Data_Ord.ordChar)(Data_Foldable.foldableArray)([ new Data_Tuple.Tuple("&", "&amp;"), new Data_Tuple.Tuple("<", "&lt;"), new Data_Tuple.Tuple("\"", "&quot;"), new Data_Tuple.Tuple("'", "&#39;") ]);
  var $$escape = function (m) {
      var checkTail = function (allowed) {
          var checkTail$prime = function (w) {
              var v = Data_Char.toCharCode(Control_Comonad_Cofree.head(w));
              if (Data_Foldable.elem(Data_Foldable.foldableArray)(Data_Eq.eqInt)(v)(allowed)) {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Control_Monad_State_Trans.bindStateT(Data_Identity.monadIdentity))(Control_Monad_State_Class.put(Control_Monad_State_Trans.monadStateStateT(Data_Identity.monadIdentity))(true))(function () {
                      return Data_Maybe.fromMaybe(Control_Applicative.pure(Control_Monad_State_Trans.applicativeStateT(Data_Identity.monadIdentity))(false))(Data_Functor.map(Data_Maybe.functorMaybe)(checkTail$prime)(Control_Comonad_Cofree.tail(w)));
                  });
              };
              if (v === 59) {
                  return Control_Monad_State_Class.get(Control_Monad_State_Trans.monadStateStateT(Data_Identity.monadIdentity));
              };
              if (Data_Boolean.otherwise) {
                  return Control_Applicative.pure(Control_Monad_State_Trans.applicativeStateT(Data_Identity.monadIdentity))(false);
              };
              throw new Error("Failed pattern match at Text.Smolder.Renderer.String (line 128, column 11 - line 133, column 42): " + [ v.constructor.name ]);
          };
          var $44 = Data_Function.flip(Control_Monad_State.evalState)(false);
          return function ($45) {
              return $44(checkTail$prime($45));
          };
      };
      var startsEntity = function (v) {
          if (v instanceof Data_Maybe.Just) {
              var v1 = Control_Comonad_Cofree.tail(v.value0);
              var v2 = Control_Comonad_Cofree.head(v.value0);
              if (v2 === "#" && v1 instanceof Data_Maybe.Just) {
                  return checkTail(Data_Array.range(48)(57))(v1.value0);
              };
              if (v2 === "#" && v1 instanceof Data_Maybe.Nothing) {
                  return false;
              };
              return checkTail(Data_Semigroup.append(Data_Semigroup.semigroupArray)(Data_Array.range(65)(90))(Data_Array.range(97)(122)))(v.value0);
          };
          if (v instanceof Data_Maybe.Nothing) {
              return false;
          };
          throw new Error("Failed pattern match at Text.Smolder.Renderer.String (line 114, column 5 - line 114, column 57): " + [ v.constructor.name ]);
      };
      var escapeS = function (w) {
          var v = Control_Comonad_Cofree.head(w);
          if (v === "&") {
              if (startsEntity(Control_Comonad_Cofree.tail(w))) {
                  return "&";
              };
              if (Data_Boolean.otherwise) {
                  return "&amp;";
              };
          };
          return Data_Maybe.fromMaybe(Data_String_CodeUnits.fromCharArray([ v ]))(Data_Map_Internal.lookup(Data_Ord.ordChar)(v)(m));
      };
      var $46 = Control_Extend.extend(Control_Comonad_Cofree.extendCofree(Data_Maybe.functorMaybe))(escapeS);
      return function ($47) {
          return fromStream($46(toStream($47)));
      };
  };
  var escapeAttrValue = function (tag) {
      return function (key) {
          return function (value) {
              if (isURLAttr(tag)(key)) {
                  return Global_Unsafe.unsafeEncodeURI(value);
              };
              if (isMIMEAttr(tag)(key)) {
                  return $$escape(escapeMIMEMap)(value);
              };
              if (Data_Boolean.otherwise) {
                  return $$escape(escapeMap)(value);
              };
              throw new Error("Failed pattern match at Text.Smolder.Renderer.String (line 142, column 1 - line 142, column 56): " + [ tag.constructor.name, key.constructor.name, value.constructor.name ]);
          };
      };
  };
  var showAttrs = function (tag) {
      var showAttr = function (v) {
          if (v instanceof Text_Smolder_Markup.SafeAttr) {
              return " " + (v.value0 + ("=\"" + (v.value1 + "\"")));
          };
          if (v instanceof Text_Smolder_Markup.Attr) {
              return " " + (v.value0 + ("=\"" + (escapeAttrValue(tag)(v.value0)(v.value1) + "\"")));
          };
          throw new Error("Failed pattern match at Text.Smolder.Renderer.String (line 151, column 5 - line 151, column 73): " + [ v.constructor.name ]);
      };
      var $48 = Data_Foldable.fold(Data_CatList.foldableCatList)(Data_Monoid.monoidString);
      var $49 = Data_Functor.map(Data_CatList.functorCatList)(showAttr);
      return function ($50) {
          return $48($49($50));
      };
  };
  var renderItem = function (v) {
      if (v instanceof Text_Smolder_Markup.Element) {
          var c = render(v.value2);
          var b = "<" + (v.value1 + (showAttrs(v.value1)(v.value3) + (function () {
              var $32 = Data_String_CodePoints.length(c) > 0 || Data_Eq.eq(Text_Smolder_Markup.eqNS)(v.value0)(Text_Smolder_Markup.HTMLns.value) && Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraFunction(Data_HeytingAlgebra.heytingAlgebraFunction(Data_HeytingAlgebra.heytingAlgebraBoolean)))(Data_Set.member(Data_Ord.ordString))(v.value1)(voidElements);
              if ($32) {
                  return ">" + (c + ("</" + (v.value1 + ">")));
              };
              return "/>";
          })()));
          return Control_Monad_State_Class.state(Control_Monad_State_Trans.monadStateStateT(Data_Identity.monadIdentity))(function (s) {
              return Data_Tuple.Tuple.create(v.value5)(s + b);
          });
      };
      if (v instanceof Text_Smolder_Markup.Content) {
          return Control_Monad_State_Class.state(Control_Monad_State_Trans.monadStateStateT(Data_Identity.monadIdentity))(function (s) {
              return Data_Tuple.Tuple.create(v.value1)(s + $$escape(escapeMap)(v.value0));
          });
      };
      if (v instanceof Text_Smolder_Markup.Doctype) {
          return Control_Monad_State_Class.state(Control_Monad_State_Trans.monadStateStateT(Data_Identity.monadIdentity))(function (s) {
              return Data_Tuple.Tuple.create(v.value1)(s + ("<!DOCTYPE " + (v.value0 + ">")));
          });
      };
      if (v instanceof Text_Smolder_Markup.Empty) {
          return Control_Applicative.pure(Control_Monad_State_Trans.applicativeStateT(Data_Identity.monadIdentity))(v.value0);
      };
      throw new Error("Failed pattern match at Text.Smolder.Renderer.String (line 158, column 1 - line 158, column 45): " + [ v.constructor.name ]);
  };
  var render = function (f) {
      return Control_Monad_State.execState(Control_Monad_Free.foldFree(Control_Monad_State_Trans.monadRecStateT(Control_Monad_Rec_Class.monadRecIdentity))(renderItem)(f))("");
  };
  exports["render"] = render;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.CodeEditor"] = $PS["Gargantext.Components.CodeEditor"] || {};
  var exports = $PS["Gargantext.Components.CodeEditor"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Data_Argonaut_Parser = $PS["Data.Argonaut.Parser"];
  var Data_Either = $PS["Data.Either"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Show = $PS["Data.Show"];
  var Data_Show_Generic = $PS["Data.Show.Generic"];
  var Data_String_Utils = $PS["Data.String.Utils"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var FFI_Simple_Objects = $PS["FFI.Simple.Objects"];
  var Gargantext_Utils_HighlightJS = $PS["Gargantext.Utils.HighlightJS"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Text_Markdown_SlamDown_Parser = $PS["Text.Markdown.SlamDown.Parser"];
  var Text_Markdown_SlamDown_Smolder = $PS["Text.Markdown.SlamDown.Smolder"];
  var Text_Markdown_SlamDown_Syntax_Value = $PS["Text.Markdown.SlamDown.Syntax.Value"];
  var Text_Smolder_Renderer_String = $PS["Text.Smolder.Renderer.String"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var Code = (function () {
      function Code() {

      };
      Code.value = new Code();
      return Code;
  })();
  var Preview = (function () {
      function Preview() {

      };
      Preview.value = new Preview();
      return Preview;
  })();
  var Both = (function () {
      function Both() {

      };
      Both.value = new Both();
      return Both;
  })();
  var Haskell = (function () {
      function Haskell() {

      };
      Haskell.value = new Haskell();
      return Haskell;
  })();
  var $$JSON = (function () {
      function $$JSON() {

      };
      $$JSON.value = new $$JSON();
      return $$JSON;
  })();
  var Markdown = (function () {
      function Markdown() {

      };
      Markdown.value = new Markdown();
      return Markdown;
  })();
  var Python = (function () {
      function Python() {

      };
      Python.value = new Python();
      return Python;
  })();
  var renderPython = function (s) {
      return s;
  };
  var renderMd$prime = function (options) {
      return function (input) {
          return Data_Either.either(Control_Category.identity(Control_Category.categoryFn))((function () {
              var $105 = Text_Markdown_SlamDown_Smolder["toMarkup'"](options);
              return function ($106) {
                  return Text_Smolder_Renderer_String.render($105($106));
              };
          })())(Text_Markdown_SlamDown_Parser.parseMd(Text_Markdown_SlamDown_Syntax_Value.valueString)(input));
      };
  };
  var renderMd = renderMd$prime(Text_Markdown_SlamDown_Smolder.defaultToMarkupOptions);
  var renderHaskell = function (s) {
      return s;
  };
  var previewPostProcess = function (v) {
      return function (v1) {
          if (v instanceof Haskell) {
              return Gargantext_Utils_HighlightJS.highlightBlock(v1);
          };
          if (v instanceof Python) {
              return Gargantext_Utils_HighlightJS.highlightBlock(v1);
          };
          if (v instanceof $$JSON) {
              return Gargantext_Utils_HighlightJS.highlightBlock(v1);
          };
          if (v instanceof Markdown) {
              return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
          };
          throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 75, column 1 - line 75, column 57): " + [ v.constructor.name, v1.constructor.name ]);
      };
  };
  var initControls = function (code) {
      return function (defaultCodeType) {
          return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (htmlElRef) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(code))(function (codeS) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (codeElRef) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (codeOverlayElRef) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(defaultCodeType))(function (codeType) {
                              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Maybe.Nothing.value))(function (error) {
                                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Preview.value))(function (viewType) {
                                      return Control_Applicative.pure(Reactix_React.applicativeHooks)({
                                          codeElRef: codeElRef,
                                          codeS: codeS,
                                          codeType: codeType,
                                          codeOverlayElRef: codeOverlayElRef,
                                          error: error,
                                          htmlElRef: htmlElRef,
                                          viewType: viewType
                                      });
                                  });
                              });
                          });
                      });
                  });
              });
          });
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.CodeEditor");
  var errorComponentCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Data_Eq.eqString)))(v.error))(function (error$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)((function () {
                      if (error$prime instanceof Data_Maybe.Nothing) {
                          return Reactix_DOM_HTML.div({})([  ]);
                      };
                      if (error$prime instanceof Data_Maybe.Just) {
                          return Reactix_DOM_HTML.div({
                              className: "text-danger"
                          })([ Reactix_DOM_HTML.text(error$prime.value0) ]);
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 250, column 14 - line 252, column 70): " + [ error$prime.constructor.name ]);
                  })());
              });
          };
      };
      return here.component("errorComponent")(cpt);
  })();
  var errorComponent = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(errorComponentCpt)(p)([  ]);
  };
  var codeNlFix = function (v) {
      return function (v1) {
          if (v1 === "") {
              return " ";
          };
          var $47 = Data_String_Utils.endsWith("\x0a")(v1);
          if ($47) {
              return v1 + " ";
          };
          return v1;
      };
  };
  var render = function (v) {
      return function (code) {
          if (v instanceof Haskell) {
              return Data_Either.Right.create(renderHaskell(codeNlFix(Haskell.value)(code)));
          };
          if (v instanceof Python) {
              return Data_Either.Right.create(renderPython(codeNlFix(Python.value)(code)));
          };
          if (v instanceof $$JSON) {
              var parsedE = Data_Argonaut_Parser.jsonParser(code);
              var result = (function () {
                  if (parsedE instanceof Data_Either.Left) {
                      return new Data_Either.Left(parsedE.value0);
                  };
                  if (parsedE instanceof Data_Either.Right) {
                      return Data_Either.Right.create(Gargantext_Utils_Reactix.stringify(parsedE.value0)(2));
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 70, column 14 - line 72, column 52): " + [ parsedE.constructor.name ]);
              })();
              return result;
          };
          if (v instanceof Markdown) {
              return Data_Either.Right.create(renderMd(codeNlFix(Markdown.value)(code)));
          };
          throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 64, column 1 - line 64, column 48): " + [ v.constructor.name, code.constructor.name ]);
      };
  };
  var renderHtml = function (code) {
      return function (codeType) {
          return function (htmlElRef) {
              return function (error) {
                  var v = Data_Nullable.toMaybe(Reactix_React.readRef(htmlElRef));
                  if (v instanceof Data_Maybe.Nothing) {
                      return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                  };
                  if (v instanceof Data_Maybe.Just) {
                      var v1 = render(codeType)(code);
                      if (v1 instanceof Data_Either.Left) {
                          return Toestand_Classes.write_(Toestand_Boxes.writeBox)(new Data_Maybe.Just(v1.value0))(error);
                      };
                      if (v1 instanceof Data_Either.Right) {
                          return function __do() {
                              Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Nothing.value)(error)();
                              FFI_Simple_Objects["setProperty'"](v.value0)("innerHTML")(v1.value0);
                              previewPostProcess(codeType)(v.value0)();
                              return Data_Unit.unit;
                          };
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 195, column 7 - line 202, column 20): " + [ v1.constructor.name ]);
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 192, column 3 - line 202, column 20): " + [ v.constructor.name ]);
              };
          };
      };
  };
  var setCodeOverlay = function (codeOverlayElRef) {
      return function (codeType) {
          return function (code) {
              var mCodeOverlayEl = Data_Nullable.toMaybe(Reactix_React.readRef(codeOverlayElRef));
              return function __do() {
                  (function () {
                      if (mCodeOverlayEl instanceof Data_Maybe.Nothing) {
                          return Data_Unit.unit;
                      };
                      if (mCodeOverlayEl instanceof Data_Maybe.Just) {
                          FFI_Simple_Objects["setProperty'"](mCodeOverlayEl.value0)("innerText")(codeNlFix(codeType)(code));
                          Gargantext_Utils_HighlightJS.highlightBlock(mCodeOverlayEl.value0)();
                          return Data_Unit.unit;
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 182, column 8 - line 187, column 16): " + [ mCodeOverlayEl.constructor.name ]);
                  })();
                  return Data_Unit.unit;
              };
          };
      };
  };
  var $dollar_GenericViewType__27 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Code) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof Preview) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof Both) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value));
      };
      throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 46, column 1 - line 46, column 35): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return Code.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return Preview.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inr) {
          return Both.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 46, column 1 - line 46, column 35): " + [ x.constructor.name ]);
  });     
  var $dollar_GenericCodeType__24 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Haskell) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof $$JSON) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof Markdown) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof Python) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value)));
      };
      throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 39, column 1 - line 39, column 35): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return Haskell.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return $$JSON.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return Markdown.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inr)) {
          return Python.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 39, column 1 - line 39, column 35): " + [ x.constructor.name ]);
  });
  var $dollar_ShowCodeType_26 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericCodeType__24)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Haskell";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "JSON";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Markdown";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "Python";
  })))))));
  var $dollar_EqViewType_28 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericViewType__27)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)))));
  var viewTypeSelectorCpt = (function () {
      var icon = function (v) {
          if (v instanceof Preview) {
              return "fa-eye";
          };
          if (v instanceof Both) {
              return "fa-columns";
          };
          if (v instanceof Code) {
              return "fa-pencil";
          };
          throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 325, column 5 - line 325, column 28): " + [ v.constructor.name ]);
      };
      var viewTypeButton = function (viewType) {
          return function (state$prime) {
              return function (state) {
                  var active = (function () {
                      var $79 = Data_Eq.eq($dollar_EqViewType_28)(viewType)(state$prime);
                      if ($79) {
                          return " active";
                      };
                      return "";
                  })();
                  return Reactix_DOM_HTML.button({
                      className: "btn btn-primary" + active,
                      on: {
                          click: function (v) {
                              return Toestand_Classes.write(Toestand_Boxes.writeBox)(viewType)(state);
                          }
                      },
                      type: "button"
                  })([ Reactix_DOM_HTML.i({
                      className: "fa " + icon(viewType)
                  })([  ]) ]);
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal($dollar_EqViewType_28))(v.state))(function (state$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "btn-group",
                      role: "group"
                  })([ viewTypeButton(Code.value)(state$prime)(v.state), viewTypeButton(Both.value)(state$prime)(v.state), viewTypeButton(Preview.value)(state$prime)(v.state) ]));
              });
          };
      };
      return here.component("viewTypeSelector")(cpt);
  })();
  var viewTypeSelector = Reactix_React.createElement(Reactix_React.componentIsComponent)(viewTypeSelectorCpt);
  var $dollar_EqCodeType_25 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericCodeType__24)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))))));
  var codeTypeSelectorCpt = (function () {
      var option = function (value) {
          return Reactix_DOM_HTML.option({
              value: Data_Show.show($dollar_ShowCodeType_26)(value)
          })([ Reactix_DOM_HTML.text(Data_Show.show($dollar_ShowCodeType_26)(value)) ]);
      };
      var onSelectChange = function (codeType) {
          return function (onChange) {
              return function (e) {
                  var value = Reactix_SyntheticEvent.unsafeEventValue(e);
                  var ct = (function () {
                      if (value === "Haskell") {
                          return Haskell.value;
                      };
                      if (value === "JSON") {
                          return $$JSON.value;
                      };
                      if (value === "Markdown") {
                          return Markdown.value;
                      };
                      if (value === "Python") {
                          return Python.value;
                      };
                      return Markdown.value;
                  })();
                  return function __do() {
                      Toestand_Classes.write_(Toestand_Boxes.writeBox)(ct)(codeType)();
                      return onChange(ct)();
                  };
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal($dollar_EqCodeType_25))(v.codeType))(function (codeType$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Utils_Reactix.select({
                      className: "form-control",
                      defaultValue: Data_Show.show($dollar_ShowCodeType_26)(codeType$prime),
                      on: {
                          change: onSelectChange(v.codeType)(v.onChange)
                      },
                      style: {
                          width: "150px"
                      }
                  })(Data_Functor.map(Data_Functor.functorArray)(option)([ $$JSON.value, Markdown.value, Haskell.value, Python.value ])));
              });
          };
      };
      return here.component("codeTypeSelector")(cpt);
  })();
  var codeTypeSelector = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(codeTypeSelectorCpt)(p)([  ]);
  };
  var toolbarCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqString))(v.controls.codeS))(function (codeS$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal($dollar_EqCodeType_25))(v.controls.codeType))(function (codeType$prime) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                          className: "row toolbar"
                      })([ Reactix_DOM_HTML.div({
                          className: "col-2"
                      })([ codeTypeSelector({
                          codeType: v.controls.codeType,
                          onChange: function (ct) {
                              return v.onChange(ct)(codeS$prime);
                          }
                      }) ]), Reactix_DOM_HTML.div({
                          className: "col-1"
                      })([ viewTypeSelector({
                          state: v.controls.viewType
                      })([  ]) ]) ]));
                  });
              });
          };
      };
      return here.component("toolbar")(cpt);
  })();
  var toolbar = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(toolbarCpt)(p)([  ]);
  };
  var codeEditorCpt = (function () {
      var previewHidden = function (v) {
          if (v instanceof Preview) {
              return "";
          };
          if (v instanceof Both) {
              return "";
          };
          return " d-none";
      };
      var onEditChange = function (codeS) {
          return function (codeType) {
              return function (onChange) {
                  return function (e) {
                      var code = Reactix_SyntheticEvent.unsafeEventValue(e);
                      return function __do() {
                          Toestand_Classes.write_(Toestand_Boxes.writeBox)(code)(codeS)();
                          return onChange(codeType)(code)();
                      };
                  };
              };
          };
      };
      var langClass = function (v) {
          if (v instanceof Haskell) {
              return " language-haskell";
          };
          if (v instanceof $$JSON) {
              return " language-json";
          };
          if (v instanceof Markdown) {
              return " language-md";
          };
          if (v instanceof Python) {
              return " language-python";
          };
          throw new Error("Failed pattern match at Gargantext.Components.CodeEditor (line 162, column 5 - line 162, column 36): " + [ v.constructor.name ]);
      };
      var dividerHidden = function (v) {
          if (v instanceof Both) {
              return "";
          };
          return " d-none";
      };
      var codeHidden = function (v) {
          if (v instanceof Code) {
              return "";
          };
          if (v instanceof Both) {
              return "";
          };
          return " d-none";
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(initControls(v.code)(v.defaultCodeType))(function (controls) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqString))(controls.codeS))(function (codeS$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal($dollar_EqCodeType_25))(controls.codeType))(function (codeType$prime) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal($dollar_EqViewType_28))(controls.viewType))(function (viewType$prime) {
                              return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect2'"](codeS$prime)(codeType$prime)(function __do() {
                                  setCodeOverlay(controls.codeOverlayElRef)(codeType$prime)(codeS$prime)();
                                  return renderHtml(codeS$prime)(codeType$prime)(controls.htmlElRef)(controls.error)();
                              }))(function () {
                                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                                      className: "code-editor"
                                  })([ toolbar({
                                      controls: controls,
                                      onChange: v.onChange
                                  }), Reactix_DOM_HTML.div({
                                      className: "row error"
                                  })([ errorComponent({
                                      error: controls.error
                                  }) ]), Reactix_DOM_HTML.div({
                                      className: "row editor"
                                  })([ Reactix_DOM_HTML.div({
                                      className: "code-area " + codeHidden(viewType$prime)
                                  })([ Reactix_DOM_HTML.div({
                                      className: "code-container"
                                  })([ Reactix_DOM_HTML.textarea({
                                      defaultValue: codeS$prime,
                                      on: {
                                          change: onEditChange(controls.codeS)(codeType$prime)(v.onChange)
                                      },
                                      placeholder: "Type some code...",
                                      ref: controls.codeElRef
                                  })([  ]), Reactix_DOM_HTML.pre({
                                      className: langClass(codeType$prime),
                                      ref: controls.codeOverlayElRef,
                                      rows: 30
                                  })([  ]) ]) ]), Reactix_DOM_HTML.div({
                                      className: "v-divider " + dividerHidden(viewType$prime)
                                  })([ Reactix_DOM_HTML.text(" ") ]), Reactix_DOM_HTML.div({
                                      className: "html " + (langClass(codeType$prime) + previewHidden(viewType$prime)),
                                      ref: controls.htmlElRef
                                  })([  ]) ]) ]));
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("codeEditor")(cpt);
  })();
  var codeEditor = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(codeEditorCpt)(p)([  ]);
  };
  exports["Haskell"] = Haskell;
  exports["JSON"] = $$JSON;
  exports["Markdown"] = Markdown;
  exports["Python"] = Python;
  exports["codeEditor"] = codeEditor;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Types"] = $PS["Gargantext.Components.Nodes.Types"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Types"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Foreign = $PS["Foreign"];
  var Gargantext_Utils_JSON = $PS["Gargantext.Utils.JSON"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var Field = function (x) {
      return x;
  };
  var Haskell = (function () {
      function Haskell(value0) {
          this.value0 = value0;
      };
      Haskell.create = function (value0) {
          return new Haskell(value0);
      };
      return Haskell;
  })();
  var $$JSON = (function () {
      function $$JSON(value0) {
          this.value0 = value0;
      };
      $$JSON.create = function (value0) {
          return new $$JSON(value0);
      };
      return $$JSON;
  })();
  var Markdown = (function () {
      function Markdown(value0) {
          this.value0 = value0;
      };
      Markdown.create = function (value0) {
          return new Markdown(value0);
      };
      return Markdown;
  })();
  var Python = (function () {
      function Python(value0) {
          this.value0 = value0;
      };
      Python.create = function (value0) {
          return new Python(value0);
      };
      return Python;
  })();
  var FTFieldList = function (x) {
      return x;
  };
  var FTFieldsWithIndex = function (x) {
      return x;
  };
  var isJSON = function (v) {
      var isJSON$prime = function (v1) {
          if (v1 instanceof $$JSON) {
              return true;
          };
          return false;
      };
      return isJSON$prime(v.typ);
  };
  var defaultPython$prime = {
      python: "import Foo",
      tag: "PythonField"
  };                                                  
  var defaultMarkdown$prime = {
      tag: "MarkdownField",
      text: "# New file"
  };
  var defaultMarkdown = new Markdown(defaultMarkdown$prime);
  var defaultJSON$prime = {
      authors: "",
      desc: "",
      query: "",
      tag: "JSONField",
      title: ""
  };                                              
  var defaultHaskell$prime = {
      haskell: "",
      tag: "HaskellField"
  };                                                     
  var defaultField = {
      name: "New file",
      typ: defaultMarkdown
  };
  var $dollar_WriteForeignFieldType_31 = new Simple_JSON.WriteForeign(function (v) {
      if (v instanceof Haskell) {
          return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "haskell";
          }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "tag";
          }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()()))({
              haskell: v.value0.haskell,
              tag: "HaskellField"
          });
      };
      if (v instanceof $$JSON) {
          return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "authors";
          }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "desc";
          }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "query";
          }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "tag";
          }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "title";
          }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()()))({
              authors: v.value0.authors,
              desc: v.value0.desc,
              query: v.value0.query,
              tag: "JsonField",
              title: v.value0.title
          });
      };
      if (v instanceof Markdown) {
          return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "tag";
          }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "text";
          }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()()))({
              tag: "MarkdownField",
              text: v.value0.text
          });
      };
      if (v instanceof Python) {
          return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "python";
          }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
              return "tag";
          }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()()))({
              python: v.value0.python,
              tag: "PythonField"
          });
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Types (line 111, column 1 - line 115, column 80): " + [ v.constructor.name ]);
  });
  var $dollar_WriteForeignFieldFieldTyp_27 = new Simple_JSON.WriteForeign(function (v) {
      var typ$prime = function (v1) {
          if (v1 instanceof Haskell) {
              return "Haskell";
          };
          if (v1 instanceof $$JSON) {
              return "JSON";
          };
          if (v1 instanceof Markdown) {
              return "Markdown";
          };
          if (v1 instanceof Python) {
              return "Python";
          };
          throw new Error("Failed pattern match at Gargantext.Components.Nodes.Types (line 98, column 7 - line 98, column 36): " + [ v1.constructor.name ]);
      };
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "data";
      }))($dollar_WriteForeignFieldType_31)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "name";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "type";
      }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()())()()()))({
          data: v.typ,
          name: v.name,
          type: typ$prime(v.typ)
      });
  });
  var $dollar_WriteForeignFTFieldList_38 = new Simple_JSON.WriteForeign(function (v) {
      return Gargantext_Utils_JSON.writeList($dollar_WriteForeignFieldFieldTyp_27)(v);
  });
  var $dollar_ReadForeignFieldFieldType_26 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "data";
      }))(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "authors";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "desc";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "haskell";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "python";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "query";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "tag";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "text";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "title";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()())()()))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "name";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "type";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()()))(f))(function (v) {
          return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))((function () {
              if (v.type === "Haskell") {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(new Haskell({
                      haskell: Data_Maybe.fromMaybe("")(v.data.haskell),
                      tag: v.data.tag
                  }));
              };
              if (v.type === "JSON") {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(new $$JSON({
                      authors: Data_Maybe.fromMaybe("")(v.data.authors),
                      desc: Data_Maybe.fromMaybe("")(v.data.desc),
                      query: Data_Maybe.fromMaybe("")(v.data.query),
                      tag: v.data.tag,
                      title: Data_Maybe.fromMaybe("")(v.data.title)
                  }));
              };
              if (v.type === "Markdown") {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(new Markdown({
                      tag: v.data.tag,
                      text: Data_Maybe.fromMaybe("")(v.data.text)
                  }));
              };
              if (v.type === "Python") {
                  return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(new Python({
                      python: Data_Maybe.fromMaybe("")(v.data.python),
                      tag: v.data.tag
                  }));
              };
              return Foreign.fail(Data_Identity.monadIdentity)(Foreign.ErrorAtProperty.create("type")(new Foreign.ForeignError("Unknown type")));
          })())(function (typ) {
              return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))({
                  name: v.name,
                  typ: typ
              });
          });
      });
  });
  var $dollar_ReadForeignFTFieldList_37 = new Simple_JSON.ReadForeign(function (f) {
      return Data_Functor.map(Control_Monad_Except_Trans.functorExceptT(Data_Identity.functorIdentity))(FTFieldList)(Gargantext_Utils_JSON.readList($dollar_ReadForeignFieldFieldType_26)(f));
  });
  var $dollar_GenericFieldType__30 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Haskell) {
          return new Data_Generic_Rep.Inl(x.value0);
      };
      if (x instanceof $$JSON) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(x.value0));
      };
      if (x instanceof Markdown) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(x.value0)));
      };
      if (x instanceof Python) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(x.value0)));
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Types (line 110, column 1 - line 110, column 36): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return new Haskell(x.value0);
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return new $$JSON(x.value0.value0);
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return new Markdown(x.value0.value0.value0);
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inr)) {
          return new Python(x.value0.value0.value0);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Types (line 110, column 1 - line 110, column 36): " + [ x.constructor.name ]);
  });      
  var $dollar_GenericFieldFieldType__24 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });   
  var $dollar_GenericFTFieldsWithIndex__19 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericFTFieldList__34 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqFieldType_32 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericFieldType__30)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "tag";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "haskell";
  }))(Data_Eq.eqString)))))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "tag";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "query";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "desc";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "authors";
  }))(Data_Eq.eqString)))))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "text";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "tag";
  }))(Data_Eq.eqString)))))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "tag";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "python";
  }))(Data_Eq.eqString)))))))));
  var $dollar_EqFieldFieldType_28 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericFieldFieldType__24)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "typ";
  }))($dollar_EqFieldType_32))()(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Data_Eq.eqString))))));
  var $dollar_EqFTFieldsWithIndex_21 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericFTFieldsWithIndex__19)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_List_Types.eqList(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "idx";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "ftField";
  }))($dollar_EqFieldFieldType_28)))))));
  var $dollar_EqFTFieldList_36 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericFTFieldList__34)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_List_Types.eqList($dollar_EqFieldFieldType_28)))));
  exports["FTFieldsWithIndex"] = FTFieldsWithIndex;
  exports["Field"] = Field;
  exports["Haskell"] = Haskell;
  exports["JSON"] = $$JSON;
  exports["Markdown"] = Markdown;
  exports["Python"] = Python;
  exports["FTFieldList"] = FTFieldList;
  exports["isJSON"] = isJSON;
  exports["defaultPython'"] = defaultPython$prime;
  exports["defaultHaskell'"] = defaultHaskell$prime;
  exports["defaultJSON'"] = defaultJSON$prime;
  exports["defaultMarkdown'"] = defaultMarkdown$prime;
  exports["defaultField"] = defaultField;
  exports["$_EqFTFieldsWithIndex_21"] = $dollar_EqFTFieldsWithIndex_21;
  exports["$_EqFieldFieldType_28"] = $dollar_EqFieldFieldType_28;
  exports["$_EqFTFieldList_36"] = $dollar_EqFTFieldList_36;
  exports["$_ReadForeignFTFieldList_37"] = $dollar_ReadForeignFTFieldList_37;
  exports["$_WriteForeignFTFieldList_38"] = $dollar_WriteForeignFTFieldList_38;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Types"] = $PS["Gargantext.Components.Nodes.Corpus.Types"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Types"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_List = $PS["Data.List"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_Nodes_Types = $PS["Gargantext.Components.Nodes.Types"];
  var Simple_JSON = $PS["Simple.JSON"];
  var getCorpusInfo = function (v) {
      var v1 = Data_List.head(Data_List.filter(Gargantext_Components_Nodes_Types.isJSON)(v));
      if (v1 instanceof Data_Maybe.Just && v1.value0.typ instanceof Gargantext_Components_Nodes_Types["JSON"]) {
          return {
              title: v1.value0.typ.value0.title,
              desc: v1.value0.typ.value0.desc,
              query: v1.value0.typ.value0.query,
              authors: v1.value0.typ.value0.authors,
              totalRecords: 0
          };
      };
      return {
          title: "Empty",
          desc: "",
          query: "",
          authors: "",
          totalRecords: 0
      };
  };
  var $dollar_WriteForeignHyperdata_10 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "fields";
  }))(Gargantext_Components_Nodes_Types["$_WriteForeignFTFieldList_38"])(Simple_JSON.nilWriteForeignFields)()()());
  var $dollar_ReadForeignHyperdata_9 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "fields";
  }))(Gargantext_Components_Nodes_Types["$_ReadForeignFTFieldList_37"])(Simple_JSON.readFieldsNil)()());
  var $dollar_GenericHyperdata__6 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqHyperdata_8 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHyperdata__6)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "fields";
  }))(Gargantext_Components_Nodes_Types["$_EqFTFieldList_36"]))))));
  exports["getCorpusInfo"] = getCorpusInfo;
  exports["$_EqHyperdata_8"] = $dollar_EqHyperdata_8;
  exports["$_ReadForeignHyperdata_9"] = $dollar_ReadForeignHyperdata_9;
  exports["$_WriteForeignHyperdata_10"] = $dollar_WriteForeignHyperdata_10;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Data.Array"] = $PS["Gargantext.Data.Array"] || {};
  var exports = $PS["Gargantext.Data.Array"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_List = $PS["Data.List"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];                
  var swap = function (i) {
      return function (j) {
          return function (arr) {
              var updates = (function () {
                  var v = Data_Array.index(arr)(i);
                  if (v instanceof Data_Maybe.Nothing) {
                      return [  ];
                  };
                  if (v instanceof Data_Maybe.Just) {
                      var v1 = Data_Array.index(arr)(j);
                      if (v1 instanceof Data_Maybe.Nothing) {
                          return [  ];
                      };
                      if (v1 instanceof Data_Maybe.Just) {
                          return [ new Data_Tuple.Tuple(i, v1.value0), new Data_Tuple.Tuple(j, v.value0) ];
                      };
                      throw new Error("Failed pattern match at Gargantext.Data.Array (line 59, column 19 - line 61, column 49): " + [ v1.constructor.name ]);
                  };
                  throw new Error("Failed pattern match at Gargantext.Data.Array (line 57, column 15 - line 61, column 49): " + [ v.constructor.name ]);
              })();
              return Data_Array.updateAtIndices(Data_Foldable.foldableArray)(updates)(arr);
          };
      };
  };
  var swapList = function (i) {
      return function (j) {
          return function (seq) {
              return Data_List.fromFoldable(Data_Foldable.foldableArray)(swap(i)(j)(Data_List.toUnfoldable(Data_Unfoldable.unfoldableArray)(seq)));
          };
      };
  };
  var singleton = function (a) {
      return [ a ];
  };                                                                                     
  var concatMap = Data_Function.flip(Control_Bind.bind(Control_Bind.bindArray));
  var mapMaybe = function (f) {
      return concatMap((function () {
          var $20 = Data_Maybe.maybe([  ])(singleton);
          return function ($21) {
              return $20(f($21));
          };
      })());
  };
  exports["mapMaybe"] = mapMaybe;
  exports["swapList"] = swapList;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus"] = $PS["Gargantext.Components.Nodes.Corpus"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var Data_Array = $PS["Data.Array"];
  var Data_Either = $PS["Data.Either"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Gargantext_Components_CodeEditor = $PS["Gargantext.Components.CodeEditor"];
  var Gargantext_Components_FolderView = $PS["Gargantext.Components.FolderView"];
  var Gargantext_Components_InputWithEnter = $PS["Gargantext.Components.InputWithEnter"];
  var Gargantext_Components_Node = $PS["Gargantext.Components.Node"];
  var Gargantext_Components_Nodes_Corpus_Types = $PS["Gargantext.Components.Nodes.Corpus.Types"];
  var Gargantext_Components_Nodes_Types = $PS["Gargantext.Components.Nodes.Types"];
  var Gargantext_Data_Array = $PS["Gargantext.Data.Array"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var Code = (function () {
      function Code() {

      };
      Code.value = new Code();
      return Code;
  })();
  var Folders = (function () {
      function Folders() {

      };
      Folders.value = new Folders();
      return Folders;
  })();
  var saveCorpus = function (v) {
      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.put(Gargantext_Components_Nodes_Corpus_Types["$_WriteForeignHyperdata_10"])(Simple_JSON.readInt)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Corpus.value, new Data_Maybe.Just(v.nodeId), ""))(v.hyperdata))(function (id_) {
          return Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Unit.unit);
      });
  };
  var loadCorpusWithChild = function (v) {
      var listNodeRoute = (function () {
          var $273 = Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value);
          return function ($274) {
              return $273(Data_Maybe.Just.create($274));
          };
      })();
      var defaultListIdsRoute = (function () {
          var $275 = Gargantext_Routes.Children.create(Gargantext_Types.NodeList.value)(0)(1)(Data_Maybe.Nothing.value);
          return function ($276) {
              return $275(Data_Maybe.Just.create($276));
          };
      })();
      var corpusNodeRoute = (function () {
          var $277 = Gargantext_Routes.NodeAPI.create(Gargantext_Types.Corpus.value);
          return function ($278) {
              return $277(Data_Maybe.Just.create($278));
          };
      })();
      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.get(Gargantext_Components_Node["$_ReadForeignNodePoly_8"](Simple_JSON.readRecord()(Simple_JSON.readFieldsNil)))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(listNodeRoute(v.nodeId)("")))(function (v1) {
          return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.get(Gargantext_Components_Node["$_ReadForeignNodePoly_8"](Gargantext_Components_Nodes_Corpus_Types["$_ReadForeignHyperdata_9"]))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(corpusNodeRoute(v1.parentId)("")))(function (corpusNode) {
              return Control_Bind.bind(Effect_Aff.bindAff)((function (dictReadForeign) {
                  return Gargantext_Sessions.get(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                      return "count";
                  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                      return "docs";
                  }))(Simple_JSON.readArray(Gargantext_Components_Node["$_ReadForeignNodePoly_8"](dictReadForeign)))(Simple_JSON.readFieldsNil)()())()()))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(defaultListIdsRoute(v1.parentId));
              })(Gargantext_Components_Node["$_ReadForeignHyperdataList_11"]))(function (defaultListIds) {
                  var v2 = Data_Array.head(defaultListIds.docs);
                  if (v2 instanceof Data_Maybe.Just) {
                      return Control_Applicative.pure(Effect_Aff.applicativeAff)({
                          corpusId: v1.parentId,
                          corpusNode: corpusNode,
                          defaultListId: v2.value0.id
                      });
                  };
                  if (v2 instanceof Data_Maybe.Nothing) {
                      return Control_Monad_Error_Class.throwError(Effect_Aff.monadThrowAff)(Effect_Exception.error("Missing default list"));
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus (line 501, column 3 - line 505, column 48): " + [ v2.constructor.name ]);
              });
          });
      });
  };
  var loadCorpus$prime = function (v) {
      return Gargantext_Sessions.get(Gargantext_Components_Node["$_ReadForeignNodePoly_8"](Gargantext_Components_Nodes_Corpus_Types["$_ReadForeignHyperdata_9"]))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Corpus.value, new Data_Maybe.Just(v.nodeId), ""));
  };
  var loadCorpusWithReload = function (v) {
      return loadCorpus$prime({
          nodeId: v.nodeId,
          session: v.session
      });
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Corpus");
  var changeCode = function (onc) {
      return function (v) {
          return function (v1) {
              return function (v2) {
                  if (v instanceof Gargantext_Components_Nodes_Types.Haskell && v1 instanceof Gargantext_Components_CodeEditor.Haskell) {
                      return onc(Gargantext_Components_Nodes_Types.Haskell.create({
                          tag: v.value0.tag,
                          haskell: v2
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types.Haskell && v1 instanceof Gargantext_Components_CodeEditor.Python) {
                      return onc(Gargantext_Components_Nodes_Types.Python.create({
                          tag: Gargantext_Components_Nodes_Types["defaultPython'"].tag,
                          python: v2
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types.Haskell && v1 instanceof Gargantext_Components_CodeEditor["JSON"]) {
                      return onc(Gargantext_Components_Nodes_Types["JSON"].create({
                          tag: Gargantext_Components_Nodes_Types["defaultJSON'"].tag,
                          authors: Gargantext_Components_Nodes_Types["defaultJSON'"].authors,
                          desc: v.value0.haskell,
                          query: Gargantext_Components_Nodes_Types["defaultJSON'"].query,
                          title: Gargantext_Components_Nodes_Types["defaultJSON'"].title
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types.Haskell && v1 instanceof Gargantext_Components_CodeEditor.Markdown) {
                      return onc(Gargantext_Components_Nodes_Types.Markdown.create({
                          tag: Gargantext_Components_Nodes_Types["defaultMarkdown'"].tag,
                          text: v.value0.haskell
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types.Python && v1 instanceof Gargantext_Components_CodeEditor.Python) {
                      return onc(Gargantext_Components_Nodes_Types.Python.create({
                          tag: v.value0.tag,
                          python: v2
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types.Python && v1 instanceof Gargantext_Components_CodeEditor.Haskell) {
                      return onc(Gargantext_Components_Nodes_Types.Haskell.create({
                          tag: Gargantext_Components_Nodes_Types["defaultHaskell'"].tag,
                          haskell: v2
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types.Python && v1 instanceof Gargantext_Components_CodeEditor["JSON"]) {
                      return onc(Gargantext_Components_Nodes_Types["JSON"].create({
                          tag: Gargantext_Components_Nodes_Types["defaultJSON'"].tag,
                          authors: Gargantext_Components_Nodes_Types["defaultJSON'"].authors,
                          desc: v.value0.python,
                          query: Gargantext_Components_Nodes_Types["defaultJSON'"].query,
                          title: Gargantext_Components_Nodes_Types["defaultJSON'"].title
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types.Python && v1 instanceof Gargantext_Components_CodeEditor.Markdown) {
                      return onc(Gargantext_Components_Nodes_Types.Markdown.create({
                          tag: Gargantext_Components_Nodes_Types["defaultMarkdown'"].tag,
                          text: v.value0.python
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types.Markdown && v1 instanceof Gargantext_Components_CodeEditor.Haskell) {
                      return onc(Gargantext_Components_Nodes_Types.Haskell.create({
                          tag: Gargantext_Components_Nodes_Types["defaultHaskell'"].tag,
                          haskell: v2
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types.Markdown && v1 instanceof Gargantext_Components_CodeEditor.Python) {
                      return onc(Gargantext_Components_Nodes_Types.Python.create({
                          tag: Gargantext_Components_Nodes_Types["defaultPython'"].tag,
                          python: v2
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types.Markdown && v1 instanceof Gargantext_Components_CodeEditor["JSON"]) {
                      return onc(Gargantext_Components_Nodes_Types.Markdown.create({
                          tag: Gargantext_Components_Nodes_Types["defaultMarkdown'"].tag,
                          text: v2
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types.Markdown && v1 instanceof Gargantext_Components_CodeEditor.Markdown) {
                      return onc(Gargantext_Components_Nodes_Types.Markdown.create({
                          tag: v.value0.tag,
                          text: v2
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types["JSON"] && v1 instanceof Gargantext_Components_CodeEditor.Haskell) {
                      var haskell = Gargantext_Utils_Reactix.stringify(Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "authors";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "desc";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "query";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "tag";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "title";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()()))(v.value0))(2);
                      return onc(Gargantext_Components_Nodes_Types.Haskell.create({
                          tag: Gargantext_Components_Nodes_Types["defaultHaskell'"].tag,
                          haskell: haskell
                      }));
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types["JSON"] && v1 instanceof Gargantext_Components_CodeEditor.Python) {
                      var toCode = Gargantext_Utils_Reactix.stringify(Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "authors";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "desc";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "query";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "tag";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "title";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()()))(v.value0))(2);
                      return onc(Gargantext_Components_Nodes_Types.Python.create({
                          tag: Gargantext_Components_Nodes_Types["defaultPython'"].tag,
                          python: toCode
                      }));
                  };
                  if (v1 instanceof Gargantext_Components_CodeEditor["JSON"]) {
                      var v3 = Simple_JSON.readJSON(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                          return "authors";
                      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                          return "desc";
                      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                          return "query";
                      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                          return "tag";
                      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                          return "title";
                      }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()())()())()()))(v2);
                      if (v3 instanceof Data_Either.Left) {
                          return DOM_Simple_Console.log2("[fieldCodeEditor'] cannot parse json")(v2);
                      };
                      if (v3 instanceof Data_Either.Right) {
                          return onc(new Gargantext_Components_Nodes_Types["JSON"](v3.value0));
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus (line 439, column 3 - line 441, column 30): " + [ v3.constructor.name ]);
                  };
                  if (v instanceof Gargantext_Components_Nodes_Types["JSON"] && v1 instanceof Gargantext_Components_CodeEditor.Markdown) {
                      var text = Gargantext_Utils_Reactix.stringify(Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "authors";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "desc";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "query";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "tag";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                          return "title";
                      }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()()))(v.value0))(2);
                      return onc(Gargantext_Components_Nodes_Types.Markdown.create({
                          tag: Gargantext_Components_Nodes_Types["defaultMarkdown'"].tag,
                          text: text
                      }));
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus (line 416, column 1 - line 416, column 95): " + [ onc.constructor.name, v.constructor.name, v1.constructor.name, v2.constructor.name ]);
              };
          };
      };
  };
  var fieldCodeEditorCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              if (v.field.typ instanceof Gargantext_Components_Nodes_Types.Haskell) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_CodeEditor.codeEditor({
                      code: v.field.typ.value0.haskell,
                      defaultCodeType: Gargantext_Components_CodeEditor.Haskell.value,
                      onChange: changeCode(v.onChange)(v.field.typ)
                  }));
              };
              if (v.field.typ instanceof Gargantext_Components_Nodes_Types.Python) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_CodeEditor.codeEditor({
                      code: v.field.typ.value0.python,
                      defaultCodeType: Gargantext_Components_CodeEditor.Python.value,
                      onChange: changeCode(v.onChange)(v.field.typ)
                  }));
              };
              if (v.field.typ instanceof Gargantext_Components_Nodes_Types["JSON"]) {
                  var code = Gargantext_Utils_Reactix.stringify(Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                      return "authors";
                  }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                      return "desc";
                  }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                      return "query";
                  }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                      return "tag";
                  }))(Simple_JSON.writeForeignString)(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
                      return "title";
                  }))(Simple_JSON.writeForeignString)(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()()))(v.field.typ.value0))(2);
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_CodeEditor.codeEditor({
                      code: code,
                      defaultCodeType: Gargantext_Components_CodeEditor["JSON"].value,
                      onChange: changeCode(v.onChange)(v.field.typ)
                  }));
              };
              if (v.field.typ instanceof Gargantext_Components_Nodes_Types.Markdown) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_CodeEditor.codeEditor({
                      code: v.field.typ.value0.text,
                      defaultCodeType: Gargantext_Components_CodeEditor.Markdown.value,
                      onChange: changeCode(v.onChange)(v.field.typ)
                  }));
              };
              throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus (line 397, column 5 - line 398, column 107): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
      return here.component("fieldCodeEditorCpt")(cpt);
  })();
  var fieldCodeEditor = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(fieldCodeEditorCpt)(props)([  ]);
  };
  var fieldCodeEditorWrapperCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var moveUpButton = Reactix_DOM_HTML.div({
                  className: "btn btn-primary",
                  on: {
                      click: function (v2) {
                          return v.onMoveUp(Data_Unit.unit);
                      }
                  }
              })([ Reactix_DOM_HTML.span({
                  className: "fa fa-arrow-up"
              })([  ]) ]);
              var moveDownButton = Reactix_DOM_HTML.div({
                  className: "btn btn-primary",
                  on: {
                      click: function (v2) {
                          return v.onMoveDown(Data_Unit.unit);
                      }
                  }
              })([ Reactix_DOM_HTML.span({
                  className: "fa fa-arrow-down"
              })([  ]) ]);
              var moveButtons = Data_Semigroup.append(Data_Semigroup.semigroupArray)([  ])(Data_Semigroup.append(Data_Semigroup.semigroupArray)((function () {
                  if (v.canMoveDown) {
                      return [ moveDownButton ];
                  };
                  return [  ];
              })())((function () {
                  if (v.canMoveUp) {
                      return [ moveUpButton ];
                  };
                  return [  ];
              })()));
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "row card"
              })([ Reactix_DOM_HTML.div({
                  className: "card-header"
              })([ Reactix_DOM_HTML.div({
                  className: "code-editor-heading row"
              })([ Reactix_DOM_HTML.div({
                  className: "col-4"
              })([ Gargantext_Components_InputWithEnter.inputWithEnter({
                  onBlur: v.onRename,
                  onEnter: function (v2) {
                      return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                  },
                  onValueChanged: v.onRename,
                  autoFocus: false,
                  className: "form-control",
                  defaultValue: v.field.name,
                  placeholder: "Enter file name",
                  type: "text"
              }) ]), Reactix_DOM_HTML.div({
                  className: "col-7"
              })([  ]), Reactix_DOM_HTML.div({
                  className: "buttons-right col-1"
              })(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ Reactix_DOM_HTML.div({
                  className: "btn btn-danger",
                  on: {
                      click: function (v2) {
                          return v.onRemove(Data_Unit.unit);
                      }
                  }
              })([ Reactix_DOM_HTML.span({
                  className: "fa fa-trash"
              })([  ]) ]) ])(moveButtons)) ]) ]), Reactix_DOM_HTML.div({
                  className: "card-body"
              })([ fieldCodeEditor(v) ]) ]));
          };
      };
      return here.component("fieldCodeEditorWrapperCpt")(cpt);
  })();
  var fieldCodeEditorWrapper = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(fieldCodeEditorWrapperCpt)(props)([  ]);
  };
  var fieldsCodeEditorCpt = (function () {
      var recomputeIndices = function (v) {
          return Gargantext_Components_Nodes_Types.FTFieldsWithIndex(Data_List.mapWithIndex(function (idx) {
              return function (v1) {
                  return {
                      idx: idx,
                      ftField: v1.ftField
                  };
              };
          })(v));
      };
      var cpt = function (v) {
          return function (v1) {
              var onRename = function (idx) {
                  return function (newName) {
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v2) {
                          return Gargantext_Components_Nodes_Types.FTFieldsWithIndex(Data_Maybe.fromMaybe(v2)(Data_List.modifyAt(idx)(function (v3) {
                              return {
                                  idx: idx,
                                  ftField: Gargantext_Components_Nodes_Types.Field({
                                      name: newName,
                                      typ: v3.ftField.typ
                                  })
                              };
                          })(v2)));
                      })(v.fields);
                  };
              };
              var onRemove = function (idx) {
                  return function (v2) {
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v3) {
                          return Gargantext_Components_Nodes_Types.FTFieldsWithIndex(Data_Maybe.fromMaybe(v3)(Data_List.deleteAt(idx)(v3)));
                      })(v.fields);
                  };
              };
              var onMoveUp = function (masterKey) {
                  return function (idx) {
                      return function (v2) {
                          return function __do() {
                              Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(masterKey)();
                              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v3) {
                                  return recomputeIndices(Gargantext_Components_Nodes_Types.FTFieldsWithIndex(Gargantext_Data_Array.swapList(idx)(idx - 1 | 0)(v3)));
                              })(v.fields)();
                          };
                      };
                  };
              };
              var onMoveDown = function (masterKey) {
                  return function (idx) {
                      return function (v2) {
                          return function __do() {
                              Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(masterKey)();
                              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v3) {
                                  return recomputeIndices(Gargantext_Components_Nodes_Types.FTFieldsWithIndex(Gargantext_Data_Array.swapList(idx)(idx + 1 | 0)(v3)));
                              })(v.fields)();
                          };
                      };
                  };
              };
              var onChange = function (idx) {
                  return function (typ) {
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v2) {
                          return Gargantext_Components_Nodes_Types.FTFieldsWithIndex(Data_Maybe.fromMaybe(v2)(Data_List.modifyAt(idx)(function (v3) {
                              return {
                                  idx: idx,
                                  ftField: Gargantext_Components_Nodes_Types.Field({
                                      name: v3.ftField.name,
                                      typ: typ
                                  })
                              };
                          })(v2)));
                      })(v.fields);
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Nodes_Types["$_EqFTFieldsWithIndex_21"]))(v.fields))(function (v2) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (masterKey) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(masterKey))(function (masterKey$prime) {
                          var editorsMap = function (v3) {
                              return fieldCodeEditorWrapper({
                                  canMoveDown: v3.idx < (Data_List.length(v2) - 1 | 0),
                                  canMoveUp: v3.idx > 0,
                                  field: v3.ftField,
                                  key: Data_Show.show(Data_Show.showInt)(masterKey$prime) + ("-" + Data_Show.show(Data_Show.showInt)(v3.idx)),
                                  onChange: onChange(v3.idx),
                                  onMoveDown: onMoveDown(masterKey)(v3.idx),
                                  onMoveUp: onMoveUp(masterKey)(v3.idx),
                                  onRemove: onRemove(v3.idx),
                                  onRename: onRename(v3.idx)
                              });
                          };
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})(Data_List.toUnfoldable(Data_Unfoldable.unfoldableArray)(Data_Functor.map(Data_List_Types.functorList)(editorsMap)(v2))));
                      });
                  });
              });
          };
      };
      return here.component("fieldsCodeEditorCpt")(cpt);
  })();
  var fieldsCodeEditor = Reactix_React.createElement(Reactix_React.componentIsComponent)(fieldsCodeEditorCpt);
  var corpusLayoutViewCpt = (function () {
      var saveEnabled = function (fs) {
          return function (fsS) {
              var $216 = Data_Eq.eq(Gargantext_Components_Nodes_Types["$_EqFTFieldsWithIndex_21"])(fs)(fsS);
              if ($216) {
                  return "disabled";
              };
              return "enabled";
          };
      };
      var onClickSave = function (v) {
          return function (v1) {
              return Effect_Aff.launchAff_(Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(saveCorpus({
                  hyperdata: {
                      fields: Gargantext_Components_Nodes_Types.FTFieldList(Data_Functor.map(Data_List_Types.functorList)(function (v2) {
                          return v2.ftField;
                      })(v.fields))
                  },
                  nodeId: v.nodeId,
                  session: v.session
              }))(function () {
                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(v.reload));
              }));
          };
      };
      var onClickAdd = function (fieldsS) {
          return function (v) {
              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v1) {
                  return Gargantext_Components_Nodes_Types.FTFieldsWithIndex(Data_List.snoc(v1)({
                      idx: Data_List.length(v1),
                      ftField: Gargantext_Components_Nodes_Types.defaultField
                  }));
              })(fieldsS);
          };
      };
      var cpt = function (v) {
          return function (v1) {
              var fieldsWithIndex = Gargantext_Components_Nodes_Types.FTFieldsWithIndex(Data_List.mapWithIndex(function (idx) {
                  return function (ftField) {
                      return {
                          idx: idx,
                          ftField: ftField
                      };
                  };
              })(v.corpus.hyperdata.fields));
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(fieldsWithIndex))(function (fieldsS) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Nodes_Types["$_EqFTFieldsWithIndex_21"]))(fieldsS))(function (fields$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(v.corpus.hyperdata.fields))(function (fieldsRef) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect1'"](v.corpus.hyperdata.fields)((function () {
                              var $226 = Data_Eq.eq(Data_List_Types.eqList(Gargantext_Components_Nodes_Types["$_EqFieldFieldType_28"]))(Reactix_React.readRef(fieldsRef))(v.corpus.hyperdata.fields);
                              if ($226) {
                                  return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                              };
                              return function __do() {
                                  Reactix_React.setRef(fieldsRef)(v.corpus.hyperdata.fields)();
                                  return Toestand_Classes.write_(Toestand_Boxes.writeBox)(fieldsWithIndex)(fieldsS)();
                              };
                          })()))(function () {
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.div({
                                  className: "row"
                              })([ Reactix_DOM_HTML.div({
                                  className: "btn btn-primary " + saveEnabled(fieldsWithIndex)(fields$prime),
                                  on: {
                                      click: onClickSave({
                                          fields: fields$prime,
                                          nodeId: v.nodeId,
                                          reload: v.reload,
                                          session: v.session
                                      })
                                  }
                              })([ Reactix_DOM_HTML.span({
                                  className: "fa fa-floppy-o"
                              })([  ]) ]) ]), Reactix_DOM_HTML.div({})([ fieldsCodeEditor({
                                  fields: fieldsS,
                                  nodeId: v.nodeId,
                                  session: v.session
                              })([  ]) ]), Reactix_DOM_HTML.div({
                                  className: "row"
                              })([ Reactix_DOM_HTML.div({
                                  className: "btn btn-primary",
                                  on: {
                                      click: onClickAdd(fieldsS)
                                  }
                              })([ Reactix_DOM_HTML.span({
                                  className: "fa fa-plus"
                              })([  ]) ]) ]) ]));
                          });
                      });
                  });
              });
          };
      };
      return here.component("corpusLayoutView")(cpt);
  })();
  var corpusLayoutView = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(corpusLayoutViewCpt)(props)([  ]);
  };
  var corpusLayoutWithKeyCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(reload))(function (reload$prime) {
                      return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "session";
                      }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                          return "reload";
                      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                          return "nodeId";
                      }))(Data_Eq.eqInt)))(Gargantext_Components_Node["$_EqNodePoly_7"](Gargantext_Components_Nodes_Corpus_Types["$_EqHyperdata_8"]))({
                          nodeId: v.nodeId,
                          reload: reload$prime,
                          session: v.session
                      })(loadCorpusWithReload)(function (corpus) {
                          return corpusLayoutView({
                              corpus: corpus,
                              nodeId: v.nodeId,
                              reload: reload,
                              session: v.session
                          });
                      });
                  });
              });
          };
      };
      return here.component("corpusLayoutWithKey")(cpt);
  })();
  var corpusLayoutWithKey = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(corpusLayoutWithKeyCpt)(props)([  ]);
  };
  var $dollar_GenericViewType__81 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Code) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof Folders) {
          return new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus (line 524, column 1 - line 524, column 35): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return Code.value;
      };
      if (x instanceof Data_Generic_Rep.Inr) {
          return Folders.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus (line 524, column 1 - line 524, column 35): " + [ x.constructor.name ]);
  });    
  var $dollar_EqViewType_82 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericViewType__81)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))));
  var corpusLayoutSelectionCpt = (function () {
      var renderContent = function (v) {
          return function (nodeId) {
              return function (session) {
                  return function (key) {
                      return function (tasks) {
                          return function (v1) {
                              if (v instanceof Folders) {
                                  return Gargantext_Components_FolderView.folderView({
                                      nodeId: nodeId,
                                      session: session,
                                      backFolder: true,
                                      tasks: tasks,
                                      reloadForest: v1
                                  });
                              };
                              if (v instanceof Code) {
                                  return corpusLayoutWithKey({
                                      key: key,
                                      nodeId: nodeId,
                                      session: session
                                  });
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus (line 100, column 3 - line 100, column 137): " + [ v.constructor.name, nodeId.constructor.name, session.constructor.name, key.constructor.name, tasks.constructor.name, v1.constructor.name ]);
                          };
                      };
                  };
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal($dollar_EqViewType_82))(v.state))(function (state$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Classes.read(Toestand_Boxes.readBox)(Reactix_React.monadDelayHooks)(v.state))(function (viewType) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(renderContent(viewType)(v.nodeId)(v.session)(v.key)(v.tasks)(v.reloadForest));
                  });
              });
          };
      };
      return here.component("corpusLayoutSelection")(cpt);
  })();
  var corpusLayoutSelection = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(corpusLayoutSelectionCpt)(props)([  ]);
  };
  var viewTypeSelectorCpt = (function () {
      var icon = function (v) {
          if (v instanceof Folders) {
              return "fa-folder";
          };
          if (v instanceof Code) {
              return "fa-code";
          };
          throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus (line 560, column 5 - line 560, column 31): " + [ v.constructor.name ]);
      };
      var viewTypeButton = function (viewType) {
          return function (state$prime) {
              return function (state) {
                  var active = (function () {
                      var $256 = Data_Eq.eq($dollar_EqViewType_82)(viewType)(state$prime);
                      if ($256) {
                          return " active";
                      };
                      return "";
                  })();
                  return Reactix_DOM_HTML.button({
                      className: "btn btn-primary" + active,
                      on: {
                          click: function (v) {
                              return Toestand_Classes.write(Toestand_Boxes.writeBox)(viewType)(state);
                          }
                      },
                      type: "button"
                  })([ Reactix_DOM_HTML.i({
                      className: "fa " + icon(viewType)
                  })([  ]) ]);
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal($dollar_EqViewType_82))(v.state))(function (state$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "btn-group",
                      role: "group"
                  })([ viewTypeButton(Folders.value)(state$prime)(v.state), viewTypeButton(Code.value)(state$prime)(v.state) ]));
              });
          };
      };
      return here.component("viewTypeSelector")(cpt);
  })();
  var viewTypeSelector = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(viewTypeSelectorCpt)(p)([  ]);
  };
  var corpusLayoutMainCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Folders.value))(function (viewType) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.div({
                      className: "row"
                  })([ Reactix_DOM_HTML.div({
                      className: "col-1"
                  })([ viewTypeSelector({
                      state: viewType
                  }) ]), Reactix_DOM_HTML.div({
                      className: "col-1"
                  })([ Gargantext_Components_FolderView.homeButton ]) ]) ]), Reactix_DOM_HTML.div({})([ corpusLayoutSelection({
                      state: viewType,
                      key: v.key,
                      session: v.session,
                      nodeId: v.nodeId,
                      tasks: v.tasks,
                      reloadForest: v.reloadForest
                  }) ]) ]));
              });
          };
      };
      return here.component("corpusLayoutMain")(cpt);
  })();
  var corpusLayoutMain = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(corpusLayoutMainCpt)(props)([  ]);
  };
  var corpusLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var key = Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(Gargantext_Sessions_Types.sessionId(v.session)) + ("-" + Data_Show.show(Data_Show.showInt)(v.nodeId));
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(corpusLayoutMain({
                  key: key,
                  nodeId: v.nodeId,
                  session: v.session,
                  tasks: v.tasks,
                  reloadForest: v.reloadForest
              }));
          };
      };
      return here.component("corpusLayout")(cpt);
  })();
  var corpusLayout = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(corpusLayoutCpt)(props)([  ]);
  };
  exports["corpusLayout"] = corpusLayout;
  exports["fieldsCodeEditor"] = fieldsCodeEditor;
  exports["loadCorpusWithChild"] = loadCorpusWithChild;
})(PS);
(function(exports) {
  'use strict';

  const pkg = require('../../package.json');

  exports.version = pkg.version;
})(PS["Gargantext.Version"] = PS["Gargantext.Version"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Version"] = $PS["Gargantext.Version"] || {};
  var exports = $PS["Gargantext.Version"];
  var $foreign = $PS["Gargantext.Version"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_Config_REST = $PS["Gargantext.Config.REST"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Version");
  var getBackendVersion = function (v) {
      return Gargantext_Config_REST.get(Simple_JSON.readString)(Data_Maybe.Nothing.value)(Gargantext_Ends.toUrl(Gargantext_Ends["$_ToUrlBackendString_27"])(v.backend)("version"));
  };
  var versionCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox("No Backend Version"))(function (versionBack) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqString))(versionBack))(function (versionBack$prime) {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect'"](Effect_Aff.launchAff_(Control_Bind.bind(Effect_Aff.bindAff)(getBackendVersion(v.session))(function (v2) {
                          return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(v2)(versionBack));
                      }))))(function () {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)((function () {
                              var v2 = $foreign.version === versionBack$prime;
                              if (v2) {
                                  return Reactix_DOM_HTML.a({
                                      className: "fa fa-check-circle-o",
                                      textDecoration: "none",
                                      title: "Versions match: frontend (" + ($foreign.version + ("), backend (" + (versionBack$prime + ")")))
                                  })([  ]);
                              };
                              if (!v2) {
                                  return Reactix_DOM_HTML.a({
                                      className: "fa fa-exclamation-triangle",
                                      textDecoration: "none",
                                      title: "Versions mismatch: frontend (" + ($foreign.version + ("), backend (" + (versionBack$prime + ")")))
                                  })([  ]);
                              };
                              throw new Error("Failed pattern match at Gargantext.Version (line 49, column 14 - line 65, column 26): " + [ v2.constructor.name ]);
                          })());
                      });
                  });
              });
          };
      };
      return here.component("version")(cpt);
  })();
  var versionView = Reactix_React.createElement(Reactix_React.componentIsComponent)(versionCpt);
  exports["versionView"] = versionView;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree.Node"] = $PS["Gargantext.Components.Forest.Tree.Node"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree.Node"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_AsyncTasks = $PS["Gargantext.AsyncTasks"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Action_Upload = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload"];
  var Gargantext_Components_Forest_Tree_Node_Action_Upload_Types = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload.Types"];
  var Gargantext_Components_Forest_Tree_Node_Box = $PS["Gargantext.Components.Forest.Tree.Node.Box"];
  var Gargantext_Components_Forest_Tree_Node_Settings = $PS["Gargantext.Components.Forest.Tree.Node.Settings"];
  var Gargantext_Components_Forest_Tree_Node_Tools = $PS["Gargantext.Components.Forest.Tree.Node.Tools"];
  var Gargantext_Components_Forest_Tree_Node_Tools_ProgressBar = $PS["Gargantext.Components.Forest.Tree.Node.Tools.ProgressBar"];
  var Gargantext_Components_Forest_Tree_Node_Tools_Sync = $PS["Gargantext.Components.Forest.Tree.Node.Tools.Sync"];
  var Gargantext_Components_GraphExplorer_API = $PS["Gargantext.Components.GraphExplorer.API"];
  var Gargantext_Components_Lang = $PS["Gargantext.Components.Lang"];
  var Gargantext_Components_Node = $PS["Gargantext.Components.Node"];
  var Gargantext_Components_Nodes_Corpus = $PS["Gargantext.Components.Nodes.Corpus"];
  var Gargantext_Components_Nodes_Corpus_Types = $PS["Gargantext.Components.Nodes.Corpus.Types"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Popover = $PS["Gargantext.Utils.Popover"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Gargantext_Version = $PS["Gargantext.Version"];
  var React_SyntheticEvent = $PS["React.SyntheticEvent"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree.Node");
  var listNodeActionsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "session";
              }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                  return "nodeId";
              }))(Data_Eq.eqInt)))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "defaultListId";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "corpusNode";
              }))(Gargantext_Components_Node["$_EqNodePoly_7"](Gargantext_Components_Nodes_Corpus_Types["$_EqHyperdata_8"])))()(new Data_Symbol.IsSymbol(function () {
                  return "corpusId";
              }))(Data_Eq.eqInt)))({
                  nodeId: v.id,
                  session: v.session
              })(Gargantext_Components_Nodes_Corpus.loadCorpusWithChild)(function (v2) {
                  return Gargantext_Components_Forest_Tree_Node_Tools_Sync.nodeActionsNodeList({
                      listId: v.id,
                      nodeId: v2.corpusId,
                      session: v.session,
                      refresh: v.refresh,
                      nodeType: new Gargantext_Types.TabNgramType(Gargantext_Types.CTabTerms.value)
                  });
              });
          };
      };
      return here.component("listNodeActions")(cpt);
  })();
  var listNodeActions = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(listNodeActionsCpt)(props)([  ]);
  };
  var graphNodeActionsCpt = (function () {
      var graphVersions = function (session) {
          return function (graphId) {
              return Gargantext_Components_GraphExplorer_API.graphVersions({
                  graphId: graphId,
                  session: session
              });
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqInt)(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "gv_repo";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "gv_graph";
              }))(Data_Maybe.eqMaybe(Data_Eq.eqInt))))(v.id)(graphVersions(v.session))(function (gv) {
                  return Gargantext_Components_Forest_Tree_Node_Tools_Sync.nodeActionsGraph({
                      graphVersions: gv,
                      session: v.session,
                      id: v.id,
                      refresh: v.refresh
                  })([  ]);
              });
          };
      };
      return here.component("graphNodeActions")(cpt);
  })();
  var graphNodeActions = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(graphNodeActionsCpt)(props)([  ]);
  };
  var nodeActionsCpt = (function () {
      var cpt = function (props) {
          return function (v) {
              var childProps = Record["delete"](new Data_Symbol.IsSymbol(function () {
                  return "nodeType";
              }))()()(Data_Symbol.SProxy.value)(props);
              var child = function (v1) {
                  if (v1 instanceof Gargantext_Types.NodeList) {
                      return listNodeActions(childProps);
                  };
                  if (v1 instanceof Gargantext_Types.Graph) {
                      return graphNodeActions(childProps);
                  };
                  return Reactix_DOM_HTML.div({})([  ]);
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(child(props.nodeType));
          };
      };
      return here.component("nodeActions")(cpt);
  })();
  var nodeActions = Reactix_React.createElement(Reactix_React.componentIsComponent)(nodeActionsCpt);
  var folderIconCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.folderOpen))(function (open) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.a({
                      className: "folder-icon",
                      on: {
                          click: function (v2) {
                              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(v.folderOpen);
                          }
                      }
                  })([ Reactix_DOM_HTML.i({
                      className: Gargantext_Types.fldr(v.nodeType)(open)
                  })([  ]) ]));
              });
          };
      };
      return here.component("folderIcon")(cpt);
  })();
  var folderIcon = Reactix_React.createElement(Reactix_React.componentIsComponent)(folderIconCpt);
  var chevronIconCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              if (v.isLeaf) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
              };
              if (!v.isLeaf) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.folderOpen))(function (open) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.a({
                          className: "chevron-icon",
                          on: {
                              click: function (v2) {
                                  return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(v.folderOpen);
                              }
                          }
                      })([ Reactix_DOM_HTML.i({
                          className: (function () {
                              if (open) {
                                  return "fa fa-chevron-down";
                              };
                              var $50 = Data_Eq.eq(Gargantext_Types["$_EqHanded_94"])(v.handed)(Gargantext_Types.RightHanded.value);
                              if ($50) {
                                  return "fa fa-chevron-right";
                              };
                              return "fa fa-chevron-left";
                          })()
                      })([  ]) ]));
                  });
              };
              throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node (line 259, column 5 - line 260, column 25): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
      return here.component("chevronIcon")(cpt);
  })();
  var chevronIcon = Reactix_React.createElement(Reactix_React.componentIsComponent)(chevronIconCpt);
  var nodeMainSpanCpt = (function () {
      var popOverIcon = Reactix_DOM_HTML.a({
          className: "settings fa fa-cog",
          title: "Each node of the Tree can perform some actions.\x0a" + "Click here to execute one of them."
      })([  ]);
      var onDragOverHandler = function (isDragOver) {
          return function (e) {
              return function __do() {
                  React_SyntheticEvent.preventDefault(e)();
                  React_SyntheticEvent.stopPropagation(e)();
                  return Toestand_Classes.write_(Toestand_Boxes.writeBox)(true)(isDragOver)();
              };
          };
      };
      var onDragLeave = function (isDragOver) {
          return function (v) {
              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(false)(isDragOver);
          };
      };
      var dropProps = function (droppedFile) {
          return function (droppedFile$prime) {
              return function (isDragOver) {
                  return function (isDragOver$prime) {
                      var dropHandler = function (droppedFile1) {
                          return function (e) {
                              return function __do() {
                                  React_SyntheticEvent.preventDefault(e)();
                                  React_SyntheticEvent.stopPropagation(e)();
                                  var blob = Gargantext_Utils_Reactix.dataTransferFileBlob(Effect.applicativeEffect)(e)();
                                  return Data_Functor["void"](Effect.functorEffect)(Effect_Aff.launchAff(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Just.create(new Gargantext_Components_Forest_Tree_Node_Action_Upload.DroppedFile({
                                      blob: blob,
                                      fileType: new Data_Maybe.Just(Gargantext_Components_Forest_Tree_Node_Action_Upload_Types.CSV.value),
                                      lang: Gargantext_Components_Lang.EN.value
                                  })))(droppedFile1))))();
                              };
                          };
                      };
                      var dropClass = function (v) {
                          return function (v1) {
                              if (v instanceof Data_Maybe.Just) {
                                  return "file-dropped";
                              };
                              if (v1) {
                                  return "file-dropped";
                              };
                              if (v instanceof Data_Maybe.Nothing) {
                                  return "";
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node (line 205, column 9 - line 205, column 49): " + [ v.constructor.name, v1.constructor.name ]);
                          };
                      };
                      return {
                          className: "leaf " + dropClass(droppedFile$prime)(isDragOver$prime),
                          on: {
                              dragLeave: onDragLeave(isDragOver),
                              dragOver: onDragOverHandler(isDragOver),
                              drop: dropHandler(droppedFile)
                          }
                      };
                  };
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              var onTaskFinish = function (id$prime) {
                  return function (t) {
                      return function (v2) {
                          return function __do() {
                              Gargantext_AsyncTasks.finish(id$prime)(t)(v.tasks)();
                              var $60 = Gargantext_AsyncTasks.asyncTaskTTriggersAppReload(t);
                              if ($60) {
                                  here.log2("reloading root for task")(t)();
                                  return Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(v.reloadRoot)();
                              };
                              (function () {
                                  var $61 = Gargantext_AsyncTasks.asyncTaskTTriggersTreeReload(t);
                                  if ($61) {
                                      here.log2("reloading tree for task")(t)();
                                      return Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(v.reload)();
                                  };
                                  here.log2("task doesn't trigger a tree reload")(t)();
                                  return Data_Unit.unit;
                              })();
                              var $62 = Gargantext_AsyncTasks.asyncTaskTTriggersMainPageReload(t);
                              if ($62) {
                                  here.log2("reloading main page for task")(t)();
                                  return Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(v.reloadMainPage)();
                              };
                              here.log2("task doesn't trigger a main page reload")(t)();
                              return Data_Unit.unit;
                          };
                      };
                  };
              };
              var v2 = Gargantext_Components_Forest_Tree_Node_Settings.settingsBox(v.nodeType);
              var onPopoverClose = function (popoverRef) {
                  return function (v3) {
                      return Gargantext_Utils_Popover.setOpen(popoverRef)(false);
                  };
              };
              var name$prime = function (v3) {
                  var $65 = Data_Eq.eq(Gargantext_Types["$_EqNodeType_114"])(v3.nodeType)(Gargantext_Types.NodeUser.value);
                  if ($65) {
                      return Data_Show.show(Gargantext_Sessions_Types["$_ShowSession_34"])(v.session);
                  };
                  return v3.name;
              };
              var mNodePopupView = function (v3) {
                  return function (opc) {
                      return Gargantext_Components_Forest_Tree_Node_Box.nodePopupView({
                          dispatch: v.dispatch,
                          handed: v3.handed,
                          id: v3.id,
                          name: name$prime(v3),
                          nodeType: v3.nodeType,
                          onPopoverClose: opc,
                          session: v.session
                      });
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Routes["$_EqAppRoute_99"]))(v.route))(function (route$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Maybe.Nothing.value))(function (droppedFile) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Gargantext_Components_Forest_Tree_Node_Action_Upload["$_EqDroppedFile_25"])))(droppedFile))(function (droppedFile$prime) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(false))(function (isDragOver) {
                              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(isDragOver))(function (isDragOver$prime) {
                                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (popoverRef) {
                                      return Control_Bind.bind(Reactix_React.bindHooks)(Gargantext_AsyncTasks.focus(v.id)(v.tasks))(function (currentTasks) {
                                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqArray(Gargantext_Types["$_EqAsyncTaskWithType_172"])))(currentTasks))(function (currentTasks$prime) {
                                              return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect'"](Reactix_React.setRef(v.setPopoverRef)(Data_Maybe.Just.create(Gargantext_Utils_Popover.setOpen(popoverRef)))))(function () {
                                                  var isSelected = Data_Eq.eq(Data_Maybe.eqMaybe(Gargantext_Routes["$_EqAppRoute_99"]))(new Data_Maybe.Just(route$prime))(Gargantext_Routes.nodeTypeAppRoute(v.nodeType)(Gargantext_Sessions_Types.sessionId(v.session))(v.id));
                                                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.span(dropProps(droppedFile)(droppedFile$prime)(isDragOver)(isDragOver$prime))(Gargantext_Types.reverseHanded(v.handed)([ folderIcon({
                                                      folderOpen: v.folderOpen,
                                                      nodeType: v.nodeType
                                                  })([  ]), chevronIcon({
                                                      folderOpen: v.folderOpen,
                                                      handed: v.handed,
                                                      isLeaf: v.isLeaf,
                                                      nodeType: v.nodeType
                                                  })([  ]), Gargantext_Components_Forest_Tree_Node_Tools.nodeLink({
                                                      frontends: v.frontends,
                                                      handed: v.handed,
                                                      folderOpen: v.folderOpen,
                                                      id: v.id,
                                                      isSelected: isSelected,
                                                      name: name$prime(v),
                                                      nodeType: v.nodeType,
                                                      session: v.session
                                                  })([  ]), Gargantext_Components_Forest_Tree_Node_Action_Upload.fileTypeView({
                                                      dispatch: v.dispatch,
                                                      droppedFile: droppedFile,
                                                      id: v.id,
                                                      isDragOver: isDragOver,
                                                      nodeType: v.nodeType
                                                  }), Reactix_DOM_HTML.div({})(Data_Functor.map(Data_Functor.functorArray)(function (t) {
                                                      return Gargantext_Components_Forest_Tree_Node_Tools_ProgressBar.asyncProgressBar({
                                                          asyncTask: t,
                                                          barType: Gargantext_Components_Forest_Tree_Node_Tools_ProgressBar.Pie.value,
                                                          nodeId: v.id,
                                                          onFinish: onTaskFinish(v.id)(t),
                                                          session: v.session
                                                      })([  ]);
                                                  })(currentTasks$prime)), (function () {
                                                      var $73 = Data_Eq.eq(Gargantext_Types["$_EqNodeType_114"])(v.nodeType)(Gargantext_Types.NodeUser.value);
                                                      if ($73) {
                                                          return Gargantext_Version.versionView({
                                                              session: v.session
                                                          })([  ]);
                                                      };
                                                      return Reactix_DOM_HTML.div({})([  ]);
                                                  })(), (function () {
                                                      if (v2.value0.show) {
                                                          return Gargantext_Utils_Popover.popover({
                                                              arrow: false,
                                                              open: false,
                                                              onClose: function (v3) {
                                                                  return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                                                              },
                                                              onOpen: function (v3) {
                                                                  return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                                                              },
                                                              ref: popoverRef
                                                          })([ popOverIcon, mNodePopupView(v)(onPopoverClose(popoverRef)) ]);
                                                      };
                                                      return Reactix_DOM_HTML.div({})([  ]);
                                                  })(), nodeActions({
                                                      id: v.id,
                                                      nodeType: v.nodeType,
                                                      refresh: Data_Function["const"](v.dispatch(Gargantext_Components_Forest_Tree_Node_Action.RefreshTree.value)),
                                                      session: v.session
                                                  })([  ]) ])));
                                              });
                                          });
                                      });
                                  });
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("nodeMainSpan")(cpt);
  })();
  var nodeMainSpan = Reactix_React.createElement(Reactix_React.componentIsComponent)(nodeMainSpanCpt);
  var nodeSpanCpt = (function () {
      var cpt = function (v) {
          return function (children) {
              var className = (function () {
                  if (v.handed instanceof Gargantext_Types.LeftHanded) {
                      return "lefthanded";
                  };
                  if (v.handed instanceof Gargantext_Types.RightHanded) {
                      return "righthanded";
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree.Node (line 72, column 23 - line 74, column 44): " + [ v.handed.constructor.name ]);
              })();
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: className
              })(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ nodeMainSpan(v)([  ]) ])(children)));
          };
      };
      return here.component("nodeSpan")(cpt);
  })();
  var nodeSpan = Reactix_React.createElement(Reactix_React.componentIsComponent)(nodeSpanCpt);
  exports["nodeSpan"] = nodeSpan;
})(PS);
(function(exports) {
  "use strict";

  exports.pickFn = function(ks, r) {
    var copy = {};
    for(var i = 0; i < ks.length; i++) {
        copy[ks[i]] = r[ks[i]];
    }
    return copy;
  };
})(PS["Record.Extra"] = PS["Record.Extra"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Record.Extra"] = $PS["Record.Extra"] || {};
  var exports = $PS["Record.Extra"];
  var $foreign = $PS["Record.Extra"];
  var Data_Array = $PS["Data.Array"];
  var Data_Function_Uncurried = $PS["Data.Function.Uncurried"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Type_Proxy = $PS["Type.Proxy"];
  var Keys = function (keysImpl) {
      this.keysImpl = keysImpl;
  }; 
  var nilKeys = new Keys(function (v) {
      return Data_Monoid.mempty(Data_List_Types.monoidList);
  });
  var keysImpl = function (dict) {
      return dict.keysImpl;
  };
  var keys = function (dictRowToList) {
      return function (dictKeys) {
          return function (v) {
              return keysImpl(dictKeys)(Type_Proxy["Proxy"].value);
          };
      };
  };
  var pick = function (dictUnion) {
      return function (dictRowToList) {
          return function (dictKeys) {
              var ks = Data_Array.fromFoldable(Data_List_Types.foldableList)(keys()(dictKeys)(Type_Proxy["Proxy"].value));
              return Data_Function_Uncurried.runFn2($foreign.pickFn)(ks);
          };
      };
  };
  var consKeys = function (dictIsSymbol) {
      return function (dictKeys) {
          return new Keys(function (v) {
              var rest = keysImpl(dictKeys)(Type_Proxy["Proxy"].value);
              var first = Data_Symbol.reflectSymbol(dictIsSymbol)(Type_Proxy["Proxy"].value);
              return new Data_List_Types.Cons(first, rest);
          });
      };
  };
  exports["pick"] = pick;
  exports["nilKeys"] = nilKeys;
  exports["consKeys"] = consKeys;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest.Tree"] = $PS["Gargantext.Components.Forest.Tree"] || {};
  var exports = $PS["Gargantext.Components.Forest.Tree"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_AsyncTasks = $PS["Gargantext.AsyncTasks"];
  var Gargantext_Components_Forest_Tree_Node = $PS["Gargantext.Components.Forest.Tree.Node"];
  var Gargantext_Components_Forest_Tree_Node_Action = $PS["Gargantext.Components.Forest.Tree.Node.Action"];
  var Gargantext_Components_Forest_Tree_Node_Action_Add = $PS["Gargantext.Components.Forest.Tree.Node.Action.Add"];
  var Gargantext_Components_Forest_Tree_Node_Action_Contact = $PS["Gargantext.Components.Forest.Tree.Node.Action.Contact"];
  var Gargantext_Components_Forest_Tree_Node_Action_Delete = $PS["Gargantext.Components.Forest.Tree.Node.Action.Delete"];
  var Gargantext_Components_Forest_Tree_Node_Action_Link = $PS["Gargantext.Components.Forest.Tree.Node.Action.Link"];
  var Gargantext_Components_Forest_Tree_Node_Action_Merge = $PS["Gargantext.Components.Forest.Tree.Node.Action.Merge"];
  var Gargantext_Components_Forest_Tree_Node_Action_Move = $PS["Gargantext.Components.Forest.Tree.Node.Action.Move"];
  var Gargantext_Components_Forest_Tree_Node_Action_Rename = $PS["Gargantext.Components.Forest.Tree.Node.Action.Rename"];
  var Gargantext_Components_Forest_Tree_Node_Action_Share = $PS["Gargantext.Components.Forest.Tree.Node.Action.Share"];
  var Gargantext_Components_Forest_Tree_Node_Action_Update = $PS["Gargantext.Components.Forest.Tree.Node.Action.Update"];
  var Gargantext_Components_Forest_Tree_Node_Action_Upload = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload"];
  var Gargantext_Components_Forest_Tree_Node_Tools_FTree = $PS["Gargantext.Components.Forest.Tree.Node.Tools.FTree"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Record_Extra = $PS["Record.Extra"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var uploadFile$prime = function (nodeType) {
      return function (fileType) {
          return function (mName) {
              return function (blob) {
                  return function (v) {
                      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_Forest_Tree_Node_Action_Upload.uploadFile(v.session)(nodeType)(v.tree.value0.id)(fileType)({
                          mName: mName,
                          blob: blob
                      }))(function (task) {
                          return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                              Gargantext_AsyncTasks.insert(v.tree.value0.id)(task)(v.tasks)();
                              return DOM_Simple_Console.log2("[performAction] UploadFile, uploaded, task:")(task)();
                          });
                      });
                  };
              };
          };
      };
  };
  var uploadArbitraryFile$prime = function (mName) {
      return function (blob) {
          return function (v) {
              return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_Forest_Tree_Node_Action_Upload.uploadArbitraryFile(v.session)(v.tree.value0.id)({
                  blob: blob,
                  mName: mName
              }))(function (task) {
                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                      Gargantext_AsyncTasks.insert(v.tree.value0.id)(task)(v.tasks)();
                      return DOM_Simple_Console.log2("[performAction] UploadArbitraryFile, uploaded, task:")(task)();
                  });
              });
          };
      };
  };
  var updateNode = function (params) {
      return function (v) {
          return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_Forest_Tree_Node_Action_Update.updateRequest(params)(v.session)(v.tree.value0.id))(function (task) {
              return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                  Gargantext_AsyncTasks.insert(v.tree.value0.id)(task)(v.tasks)();
                  return DOM_Simple_Console.log2("[performAction] UpdateNode task:")(task)();
              });
          });
      };
  };
  var shareTeam = function (username) {
      return function (v) {
          return Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Share.shareReq(v.session)(v.tree.value0.id)(new Gargantext_Components_Forest_Tree_Node_Action_Share.ShareTeamParams({
              username: username
          })));
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest.Tree");
  var getNodeTreeFirstLevel = function (session) {
      return function (nodeId) {
          return Gargantext_Sessions.get(Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_ReadForeignNTreeLNode_14"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.TreeFirstLevel(new Data_Maybe.Just(nodeId), ""));
      };
  };
  var getNodeTree = function (session) {
      return function (nodeId) {
          return Gargantext_Sessions.get(Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_ReadForeignNTreeLNode_14"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Tree.value, new Data_Maybe.Just(nodeId), ""));
      };
  };
  var doSearch = function (dictMonadEffect) {
      return function (task) {
          return function (v) {
              return Effect_Class.liftEffect(dictMonadEffect)(function __do() {
                  Gargantext_AsyncTasks.insert(v.tree.value0.id)(task)(v.tasks)();
                  return DOM_Simple_Console.log2("[performAction] DoSearch task:")(task)();
              });
          };
      };
  };
  var closePopover = function (dictMonadEffect) {
      return function (dictFoldable) {
          return function (v) {
              return Effect_Class.liftEffect(dictMonadEffect)(Data_Foldable.traverse_(Effect.applicativeEffect)(dictFoldable)(function (set) {
                  return set(false);
              })(Reactix_React.readRef(v.setPopoverRef)));
          };
      };
  };
  var refreshTree = function (dictMonadEffect) {
      return function (dictReloadable) {
          return function (dictFoldable) {
              return function (p) {
                  return Effect_Class.liftEffect(dictMonadEffect)(Control_Apply.applySecond(Effect.applyEffect)(Gargantext_Utils_Toestand.reload(dictReloadable)(p.reloadTree))(closePopover(Effect_Class.monadEffectEffect)(dictFoldable)(p)));
              };
          };
      };
  };
  var deleteNode$prime = function (dictRead) {
      return function (dictWrite) {
          return function (dictReloadable) {
              return function (dictFoldable) {
                  return function (nt) {
                      return function (v) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)((function () {
                              if (nt instanceof Gargantext_Types.NodePublic && nt.value0 instanceof Gargantext_Types.FolderPublic) {
                                  return Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Delete.deleteNode(v.session)(nt)(v.tree.value0.id));
                              };
                              if (nt instanceof Gargantext_Types.NodePublic) {
                                  return Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Delete.unpublishNode(v.session)(v.tree.value0.parent_id)(v.tree.value0.id));
                              };
                              return Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Delete.deleteNode(v.session)(nt)(v.tree.value0.id));
                          })())(function () {
                              return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.modify_(Toestand_Classes.readWrite(dictRead)(dictWrite))(Gargantext_Sessions_Types.openNodesDelete(Gargantext_Sessions_Types.mkNodeId(v.session)(v.tree.value0.id)))(v.forestOpen)))(function () {
                                  return refreshTree(Effect_Aff.monadEffectAff)(dictReloadable)(dictFoldable)(v);
                              });
                          });
                      };
                  };
              };
          };
      };
  };
  var linkNode = function (dictReloadable) {
      return function (dictFoldable) {
          return function (dictFoldable1) {
              return function (nodeType) {
                  return function (params) {
                      return function (p) {
                          var f = function (v) {
                              return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Link.linkNodeReq(p.session)(nodeType)(v["value0"]["in"])(v.value0.out)))(function () {
                                  return refreshTree(Effect_Aff.monadEffectAff)(dictReloadable)(dictFoldable)(p);
                              });
                          };
                          return Data_Foldable.traverse_(Effect_Aff.applicativeAff)(dictFoldable1)(f)(params);
                      };
                  };
              };
          };
      };
  };
  var mergeNode = function (dictReloadable) {
      return function (dictFoldable) {
          return function (dictFoldable1) {
              return function (params) {
                  return function (p) {
                      var f = function (v) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Merge.mergeNodeReq(p.session)(v["value0"]["in"])(v.value0.out)))(function () {
                              return refreshTree(Effect_Aff.monadEffectAff)(dictReloadable)(dictFoldable)(p);
                          });
                      };
                      return Data_Foldable.traverse_(Effect_Aff.applicativeAff)(dictFoldable1)(f)(params);
                  };
              };
          };
      };
  };
  var moveNode = function (dictRead) {
      return function (dictWrite) {
          return function (dictReloadable) {
              return function (dictFoldable) {
                  return function (dictFoldable1) {
                      return function (params) {
                          return function (v) {
                              var f = function (v1) {
                                  return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Move.moveNodeReq(v.session)(v1["value0"]["in"])(v1.value0.out)))(function () {
                                      return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.modify_(Toestand_Classes.readWrite(dictRead)(dictWrite))(Gargantext_Sessions_Types.openNodesInsert(Gargantext_Sessions_Types.mkNodeId(v.session)(v1.value0.out)))(v.forestOpen)))(function () {
                                          return refreshTree(Effect_Aff.monadEffectAff)(dictReloadable)(dictFoldable)(v);
                                      });
                                  });
                              };
                              return Data_Foldable.traverse_(Effect_Aff.applicativeAff)(dictFoldable1)(f)(params);
                          };
                      };
                  };
              };
          };
      };
  };
  var renameNode = function (dictReloadable) {
      return function (dictFoldable) {
          return function (name) {
              return function (v) {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Rename.rename(v.session)(v.tree.value0.id)({
                      text: name
                  })))(function () {
                      return refreshTree(Effect_Aff.monadEffectAff)(dictReloadable)(dictFoldable)(v);
                  });
              };
          };
      };
  };
  var sharePublic = function (dictRead) {
      return function (dictWrite) {
          return function (dictReloadable) {
              return function (dictFoldable) {
                  return function (dictFoldable1) {
                      return function (params) {
                          return function (v) {
                              var f = function (v1) {
                                  return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Share.shareReq(v.session)(v1["value0"]["in"])(new Gargantext_Components_Forest_Tree_Node_Action_Share.SharePublicParams({
                                      node_id: v1.value0.out
                                  }))))(function () {
                                      return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.modify_(Toestand_Classes.readWrite(dictRead)(dictWrite))(Gargantext_Sessions_Types.openNodesInsert(Gargantext_Sessions_Types.mkNodeId(v.session)(v1.value0.out)))(v.forestOpen)))(function () {
                                          return refreshTree(Effect_Aff.monadEffectAff)(dictReloadable)(dictFoldable)(v);
                                      });
                                  });
                              };
                              return Data_Foldable.traverse_(Effect_Aff.applicativeAff)(dictFoldable1)(f)(params);
                          };
                      };
                  };
              };
          };
      };
  };
  var childLoaderCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var paint = function (reload) {
                  return function (tree$prime) {
                      var nodeProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "forestOpen";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "frontends";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "handed";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "reload";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "reloadMainPage";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "reloadRoot";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "reloadTree";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "route";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "session";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "tasks";
                      }))(Record_Extra.nilKeys)))))))))))(v);
                      var extra = {
                          tree: tree$prime
                      };
                      var base = {
                          reload: reload,
                          forestOpen: nodeProps.forestOpen,
                          frontends: nodeProps.frontends,
                          handed: nodeProps.handed,
                          reloadMainPage: nodeProps.reloadMainPage,
                          reloadRoot: nodeProps.reloadRoot,
                          reloadTree: nodeProps.reloadTree,
                          route: nodeProps.route,
                          session: nodeProps.session,
                          tasks: nodeProps.tasks
                      };
                      return v.render(Record.merge()()(base)(extra));
                  };
              };
              var fetch = function (v2) {
                  return getNodeTreeFirstLevel(v.session)(v.id);
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  var reloads = [ reload, v.reloadRoot, v.reloadTree ];
                  return Control_Bind.bind(Reactix_React.bindHooks)(Data_Functor.map(Reactix_React.functorHooks)(Data_Array.cons(v.id))(Data_Traversable.traverse(Data_Traversable.traversableArray)(Reactix_React.applicativeHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt)))(reloads)))(function (cache) {
                      return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqArray(Data_Eq.eqInt))(Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_EqNTree_15"](Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_EqLNode_19"]))(cache)(fetch)(paint(reload));
                  });
              });
          };
      };
      return here.component("childLoader")(cpt);
  })();
  var childLoader = Reactix_React.createElement(Reactix_React.componentIsComponent)(childLoaderCpt);
  var renderTreeChildrenCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var nodeProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "forestOpen";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "frontends";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "handed";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reload";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reloadMainPage";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reloadRoot";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reloadTree";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "route";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "session";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "tasks";
              }))(Record_Extra.nilKeys)))))))))))(v);
              var renderChild = function (v2) {
                  var props = Record.merge()()(nodeProps)({
                      id: v2.value0.id,
                      render: v.childProps.render
                  });
                  return childLoader(props)([  ]);
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment(Data_Functor.map(Data_Functor.functorArray)(renderChild)(v["childProps"]["children'"])));
          };
      };
      return here.component("renderTreeChildren")(cpt);
  })();
  var renderTreeChildren = Reactix_React.createElement(Reactix_React.componentIsComponent)(renderTreeChildrenCpt);
  var renderChildrenCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.childProps.folderOpen))(function (folderOpen$prime) {
                  if (folderOpen$prime) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(renderTreeChildren(v)([  ]));
                  };
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
              });
          };
      };
      return here.component("renderChildren")(cpt);
  })();
  var renderChildren = Reactix_React.createElement(Reactix_React.componentIsComponent)(renderChildrenCpt);
  var addNode$prime = function (dictRead) {
      return function (dictWrite) {
          return function (dictReloadable) {
              return function (dictFoldable) {
                  return function (name) {
                      return function (nodeType) {
                          return function (v) {
                              return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_Forest_Tree_Node_Action_Add.addNode(v.session)(v.tree.value0.id)({
                                  name: name,
                                  nodeType: nodeType
                              }))(function (task) {
                                  return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.modify_(Toestand_Classes.readWrite(dictRead)(dictWrite))(Gargantext_Sessions_Types.openNodesInsert(Gargantext_Sessions_Types.mkNodeId(v.session)(v.tree.value0.id)))(v.forestOpen)))(function () {
                                      return refreshTree(Effect_Aff.monadEffectAff)(dictReloadable)(dictFoldable)(v);
                                  });
                              });
                          };
                      };
                  };
              };
          };
      };
  };
  var addContact = function (params) {
      return function (v) {
          return Data_Functor["void"](Effect_Aff.functorAff)(Gargantext_Components_Forest_Tree_Node_Action_Contact.contactReq(v.session)(v.tree.value0.id)(params));
      };
  };
  var performAction = function (v) {
      return function (v1) {
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.DeleteNode) {
              return deleteNode$prime(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox)(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(Data_Foldable.foldableMaybe)(v.value0)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.DoSearch) {
              return doSearch(Effect_Aff.monadEffectAff)(v.value0)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.UpdateNode) {
              return updateNode(v.value0)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.RenameNode) {
              return renameNode(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(Data_Foldable.foldableMaybe)(v.value0)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.ShareTeam) {
              return shareTeam(v.value0)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.SharePublic) {
              return sharePublic(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox)(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(Data_Foldable.foldableMaybe)(Data_Foldable.foldableMaybe)(v.value0.params)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.AddContact) {
              return addContact(v.value0)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.AddNode) {
              return addNode$prime(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox)(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(Data_Foldable.foldableMaybe)(v.value0)(v.value1)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.UploadFile) {
              return uploadFile$prime(v.value0)(v.value1)(v.value2)(v.value3)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.UploadArbitraryFile) {
              return uploadArbitraryFile$prime(v.value0)(v.value1)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.DownloadNode) {
              return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(DOM_Simple_Console.log("[performAction] DownloadNode"));
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.MoveNode) {
              return moveNode(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox)(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(Data_Foldable.foldableMaybe)(Data_Foldable.foldableMaybe)(v.value0.params)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.MergeNode) {
              return mergeNode(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(Data_Foldable.foldableMaybe)(Data_Foldable.foldableMaybe)(v.value0.params)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.LinkNode) {
              return linkNode(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(Data_Foldable.foldableMaybe)(Data_Foldable.foldableMaybe)(v.value0.nodeType)(v.value0.params)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.RefreshTree) {
              return refreshTree(Effect_Aff.monadEffectAff)(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(Data_Foldable.foldableMaybe)(v1);
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.NoAction) {
              return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(DOM_Simple_Console.log("[performAction] NoAction"));
          };
          if (v instanceof Gargantext_Components_Forest_Tree_Node_Action.ClosePopover) {
              return closePopover(Effect_Aff.monadEffectAff)(Data_Foldable.foldableMaybe)(v1);
          };
          throw new Error("Failed pattern match at Gargantext.Components.Forest.Tree (line 270, column 1 - line 270, column 65): " + [ v.constructor.name, v1.constructor.name ]);
      };
  };
  var treeCpt = (function () {
      var pub = function (v) {
          return {
              id: v.id,
              name: v.name,
              nodeType: Gargantext_Types.publicize(v.nodeType),
              parent_id: v.parent_id
          };
      };
      var childrenClass = function (v) {
          if (v.length === 0) {
              return "no-children";
          };
          return "with-children";
      };
      var cpt = function (v) {
          return function (v1) {
              var ulClass = Gargantext_Types.switchHanded("ml left")("mr right")(v.handed) + "-auto tree handed";
              var pubChildren = (function () {
                  var $208 = Gargantext_Types.isPublic(v.tree.value0.nodeType);
                  if ($208) {
                      return Data_Functor.map(Data_Functor.functorArray)(Data_Functor.map(Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_FunctorNTree_16"])(pub))(v.tree.value1);
                  };
                  return v.tree.value1;
              })();
              var nsprops = function (extra) {
                  var extra$prime = (function () {
                      var dispatch = function (a) {
                          var spr = {
                              setPopoverRef: extra.setPopoverRef
                          };
                          var common$prime = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                              return "forestOpen";
                          }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                              return "reloadMainPage";
                          }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                              return "reloadRoot";
                          }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                              return "reloadTree";
                          }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                              return "session";
                          }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                              return "tasks";
                          }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                              return "tree";
                          }))(Record_Extra.nilKeys))))))))(v);
                          return performAction(a)(Record.merge()()(common$prime)(spr));
                      };
                      return Record.merge()()(extra)({
                          dispatch: dispatch,
                          reload: v.reload
                      });
                  })();
                  var common = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "frontends";
                  }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "handed";
                  }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "reloadMainPage";
                  }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "reloadRoot";
                  }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "route";
                  }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "session";
                  }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "tasks";
                  }))(Record_Extra.nilKeys))))))))(v);
                  return Record.merge()()(common)(extra$prime);
              };
              var nodeId = Gargantext_Sessions_Types.mkNodeId(v.session)(v.tree.value0.id);
              var isLeaf = Data_Array["null"](v.tree.value1);
              var children$prime = Data_Array.sortWith(Data_Ord.ordInt)(Gargantext_Components_Forest_Tree_Node_Tools_FTree.fTreeID)(pubChildren);
              return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Maybe.Nothing.value))(function (setPopoverRef) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Gargantext_Sessions_Types.useOpenNodesMemberBox(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(nodeId)(v.forestOpen))(function (folderOpen) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.ul({
                          className: ulClass
                      })([ Reactix_DOM_HTML.li({
                          className: childrenClass(children$prime)
                      })([ Gargantext_Components_Forest_Tree_Node.nodeSpan(nsprops({
                          folderOpen: folderOpen,
                          name: v.tree.value0.name,
                          id: v.tree.value0.id,
                          nodeType: v.tree.value0.nodeType,
                          setPopoverRef: setPopoverRef,
                          isLeaf: isLeaf
                      }))([ renderChildren(Record.merge()()(v)({
                          childProps: {
                              "children'": children$prime,
                              folderOpen: folderOpen,
                              render: tree
                          }
                      }))([  ]) ]) ]) ]));
                  });
              });
          };
      };
      return here.component("tree")(cpt);
  })();
  var tree = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(treeCpt)(props)([  ]);
  };
  var treeLoaderCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var loaded = function (tree$prime) {
                  var props = (function () {
                      var extra = {
                          tree: tree$prime,
                          reloadTree: v.reload,
                          session: v.session
                      };
                      var common = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "forestOpen";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "frontends";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "handed";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "reload";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "reloadMainPage";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "reloadRoot";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "route";
                      }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                          return "tasks";
                      }))(Record_Extra.nilKeys)))))))))(v);
                      return Record.merge()()(common)(extra);
                  })();
                  return tree(props);
              };
              var fetch = function (v2) {
                  return getNodeTree(v.session)(v2.root);
              };
              return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "root";
              }))(Data_Eq.eqInt)))(Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_EqNTree_15"](Gargantext_Components_Forest_Tree_Node_Tools_FTree["$_EqLNode_19"]))({
                  root: v.root
              })(fetch)(loaded);
          };
      };
      return here.component("treeLoader")(cpt);
  })();
  var treeLoader = Reactix_React.createElement(Reactix_React.componentIsComponent)(treeLoaderCpt);
  exports["treeLoader"] = treeLoader;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forest"] = $PS["Gargantext.Components.Forest"] || {};
  var exports = $PS["Gargantext.Components.Forest"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_Forest_Tree = $PS["Gargantext.Components.Forest.Tree"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Record_Extra = $PS["Record.Extra"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Forest");
  var plusCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var click = function (v2) {
                  return function __do() {
                      Toestand_Classes.write(Toestand_Boxes.writeBox)(Data_Maybe.Nothing.value)(v.backend)();
                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(true)(v.showLogin)();
                  };
              };
              var buttonClass = function (handed$prime) {
                  return "btn btn-primary col-5 " + Gargantext_Types.switchHanded("mr-1 ml-auto")("ml-1 mr-auto")(handed$prime);
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqHanded_94"]))(v.handed))(function (handed$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "row"
                  })([ Reactix_DOM_HTML.button({
                      className: buttonClass(handed$prime),
                      on: {
                          click: click
                      },
                      title: "Add or remove connections to the server(s)."
                  })([ Reactix_DOM_HTML.div({
                      className: "fa fa-universal-access"
                  })([ Reactix_DOM_HTML.text(" Log in/out ") ]), Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.text("    ") ]) ]) ]));
              });
          };
      };
      return here.component("plus")(cpt);
  })();
  var plus = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(plusCpt)(p)([  ]);
  };
  var forestCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var tree = function (handed$prime) {
                  return function (v2) {
                      return Gargantext_Components_Forest_Tree.treeLoader({
                          forestOpen: v.forestOpen,
                          frontends: v.frontends,
                          handed: handed$prime,
                          reload: v.reloadForest,
                          reloadMainPage: v.reloadMainPage,
                          reloadRoot: v.reloadRoot,
                          root: v2.treeId,
                          route: v.route,
                          session: v2,
                          tasks: v.tasks
                      })([  ]);
                  };
              };
              var trees = function (handed$prime) {
                  return function (sessions$prime) {
                      return Data_Functor.map(Data_Functor.functorArray)(tree(handed$prime))(Gargantext_Sessions_Types.unSessions(sessions$prime));
                  };
              };
              var common = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "frontends";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "handed";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reloadMainPage";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reloadRoot";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "route";
              }))(Record_Extra.nilKeys))))))(v);
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqHanded_94"]))(v.handed))(function (handed$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Sessions_Types["$_EqSessions_42"]))(v.sessions))(function (sessions$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.showTree))(function (showTree$prime) {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                              className: "forest " + (function () {
                                  if (showTree$prime) {
                                      return "";
                                  };
                                  return "d-none";
                              })()
                          })(Data_Array.cons(plus({
                              backend: v.backend,
                              handed: v.handed,
                              showLogin: v.showLogin
                          }))(trees(handed$prime)(sessions$prime))));
                      });
                  });
              });
          };
      };
      return here.component("forest")(cpt);
  })();
  var forest = Reactix_React.createElement(Reactix_React.componentIsComponent)(forestCpt);
  var forestLayoutCpt = (function () {
      var cpt = function (p) {
          return function (v) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "forest-layout"
              })([ forest(p)([  ]) ]));
          };
      };
      return here.component("forestLayout")(cpt);
  })();
  var forestLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(forestLayoutCpt);
  exports["forestLayout"] = forestLayout;
})(PS);
(function(exports) {
  'use strict';

  const sigma = require('sigma/src/garg.js').sigma;

  if (typeof window !== 'undefined') {
    window.sigma = sigma;
  }

  const CustomShapes = require('sigma/plugins/garg.js').init(sigma, window).customShapes;
  require('sigma/src/utils/sigma.utils.js').init(sigma);

  // Black circle around a node
  (function() {
    var originalDef = sigma.canvas.nodes.def;

    sigma.canvas.nodes.def = (node, context, settings) => {
      var prefix = settings('prefix') || '';

      originalDef(node, context, settings);

      context.strokeStyle = '#000';
      context.lineWidth = 1;
      context.beginPath();
      context.arc(
        node[prefix + 'x'],
        node[prefix + 'y'],
        node[prefix + 'size'],
        0,
        Math.PI * 2,
        true
      );
      context.stroke();
    }
  })()

  sigma.canvas.nodes.selected = (node, context, settings) => {
    // hack
    // We need to temporarily set node.type to 'def'. This is for 2 reasons
    // 1. Make it render as a normal node
    // 2. Avoid infinite recursion (hovers.def calls node renderer and we would end up here back
    //    again with node.type = 'hovered')
    node.type = 'def';
    sigma.canvas.hovers.def(node, context, settings);
    node.type = 'selected';
    //console.log('hovers, settings:', settings);
  };

  CustomShapes.init();

  let sigmaMouseSelector = (sigma, options) => {
    sigma.plugins = sigma.plugins || {};

    sigma.plugins.mouseSelector = (s, renderer) => {
      var _self = this;
      var _offset = null;
      const _s = s;
      const _renderer = renderer;
      const _container = _renderer.container;
      //renderer.initDOM('canvas', 'mouseSelector');
      // A hack to force resize to be called (there is a width/height equality
      // check which can't be escaped in any other way).
      //renderer.resize(renderer.width - 1, renderer.height - 1);
      //renderer.resize(renderer.width + 1, renderer.height + 1);
      const _context = _renderer.contexts.mouseSelector;
      // These are used to prevent using the 'click' event when in fact this was a drag
      let _clickPositionX = null;
      let _clickPositionY = null;
      let _isValidClick = false;

      _container.onmousemove = function(e) { return mouseMove(e); };
      _context.canvas.onclick = function(e) { return onClick(e); };
      _container.onmousedown = function(e) { return onMouseDown(e); }
      _container.onmouseup = function(e) { return onMouseUp(e); }
      s.bind('click', function(e) { return onClick(e); })
      // The mouseSelector canvas will pass its events down to the "mouse" canvas.
      _context.canvas.style.pointerEvents = 'none';

      s.bind('kill', () => _self.unbindAll());

      this.unbindAll = () => {
        console.log('[sigmaMouseSelector] unbinding');
        _container.onclick = null;
        _context.canvas.onmousemove = null;
        _container.onmousedown = null;
        _container.onmouseup = null;
      }

      const onMouseDown = (e) => {
        _clickPositionX = e.clientX;
        _clickPositionY = e.clientY;
      }

      const onMouseUp = (e) => {
        // Prevent triggering click when in fact this was a drag
        if ((_clickPositionX != e.clientX) || (_clickPositionY != e.clientY)) {
          _clickPositionX = null;
          _clickPositionY = null;
          _isValidClick = false;
        } else {
          _isValidClick = true;
        }
      }

      const mouseMove = (e) => {
        const size = _s.settings('mouseSelectorSize') || 3;
        const x = e.clientX + document.body.scrollLeft - _offset.left - size/2;
        const y = e.clientY + document.body.scrollTop - _offset.top - size/2;
        _context.clearRect(0, 0, _context.canvas.width, _context.canvas.height);

        _context.fillStyle = 'rgba(91, 192, 222, 0.7)';
        _context.beginPath();
        _context.arc(
          x,
          y,
          size,
          0,
          Math.PI * 2,
          true
        );
        _context.closePath();
        _context.fill();
      }

      const onClick = (e) => {
        if(!_isValidClick) {
          return;
        }
        const size = _s.settings('mouseSelectorSize') || 3;
        const x = e.data.clientX + document.body.scrollLeft - _offset.left - size/2;
        const y = e.data.clientY + document.body.scrollTop - _offset.top - size/2;
        const prefix = _renderer.options.prefix;
        //console.log('[sigmaMouseSelector] clicked', e, x, y, size);
        let nodes = [];
        _s.graph.nodes().forEach((node) => {
          const nodeX = node[prefix + 'x'];
          const nodeY = node[prefix + 'y'];
          if(sigma.utils.getDistance(x, y, nodeX, nodeY) <= size) {
            nodes.push(node);
          }
        });
        //console.log('[sigmaMouseSelector] nodes', nodes);
        _renderer.dispatchEvent('clickNodes', {
          node: nodes,
          captor: e.data
        })
        _clickPositionX = null;
        _clickPositionY = null;
      }

      const calculateOffset = (element) => {
        var style = window.getComputedStyle(element);
        var getCssProperty = function(prop) {
          return parseInt(style.getPropertyValue(prop).replace('px', '')) || 0;
        };
        return {
          left: element.getBoundingClientRect().left + getCssProperty('padding-left'),
          top: element.getBoundingClientRect().top + getCssProperty('padding-top')
        };
      };

      _offset = calculateOffset(renderer.container);

    }
  }

  sigmaMouseSelector(sigma);

  function _sigma(left, right, opts) {
    try {
      return right(new sigma(opts));
    } catch(e) {
      return left(e);
    }
  }

  function addRenderer(left, right, sigma, renderer) {
    try {
      return right(sigma.addRenderer(renderer));
    } catch(e) {
      return left(e);
    }
  }
  function bindMouseSelectorPlugin(left, right, sig) {
    try {
      return right(sigma.plugins.mouseSelector(sig, sig.renderers[0]));
    } catch(e) {
      console.log('[bindMouseSelectorPlugin] error', e);
      return left(e);
    }
  }
  function bind(sigma, event, handler) { sigma.bind(event, handler); }

  function takeScreenshot(sigma) {
    let c = sigma.renderers[0].container;
    let edges = c.getElementsByClassName('sigma-edges')[0];
    let scene = c.getElementsByClassName('sigma-scene')[0];
    // let sceneCtx = scene.getContext('2d');
    // sceneCtx.globalAlpha = 1;
    // sceneCtx.drawImage(edges, 0, 0);
    // return scene.toDataURL('image/png');
    let edgesCtx = edges.getContext('2d');
    edgesCtx.globalAlpha = 1;
    edgesCtx.drawImage(scene, 0, 0);
    return edges.toDataURL('image/png');
  }

  function getEdges(sigma) {
    return sigma.graph.edges();
  }

  function getNodes(sigma) {
    return sigma.graph.nodes();
  }

  exports._sigma = _sigma;
  exports._addRenderer = addRenderer;
  exports._bindMouseSelectorPlugin = bindMouseSelectorPlugin;
  exports._bind = bind;
  exports._takeScreenshot = takeScreenshot;
  exports._getEdges = getEdges;
  exports._getNodes = getNodes;
})(PS["Gargantext.Hooks.Sigmax.Sigma"] = PS["Gargantext.Hooks.Sigmax.Sigma"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Hooks.Sigmax.Sigma"] = $PS["Gargantext.Hooks.Sigmax.Sigma"] || {};
  var exports = $PS["Gargantext.Hooks.Sigmax.Sigma"];
  var $foreign = $PS["Gargantext.Hooks.Sigmax.Sigma"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Either = $PS["Data.Either"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Set = $PS["Data.Set"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Effect_Timer = $PS["Effect.Timer"];
  var Effect_Uncurried = $PS["Effect.Uncurried"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
  var FFI_Simple_Objects = $PS["FFI.Simple.Objects"];
  var Foreign_Object = $PS["Foreign.Object"];
  var updateCamera = function (sig) {
      return function (v) {
          var camera = FFI_Simple_Objects["getProperty'"](sig)("camera");
          return function __do() {
              FFI_Simple_Objects["setProperty'"](camera)("ratio")(v.ratio);
              FFI_Simple_Objects["setProperty'"](camera)("x")(v.x);
              FFI_Simple_Objects["setProperty'"](camera)("y")(v.y);
              return Data_Unit.unit;
          };
      };
  };
  var toCamera = function (c) {
      var y = FFI_Simple_Objects["getProperty'"](c)("y");
      var x = FFI_Simple_Objects["getProperty'"](c)("x");
      var ratio = FFI_Simple_Objects["getProperty'"](c)("ratio");
      var angle = FFI_Simple_Objects["getProperty'"](c)("angle");
      return {
          angle: angle,
          ratio: ratio,
          x: x,
          y: y
      };
  };
  var takeScreenshot = Effect_Uncurried.runEffectFn1($foreign["_takeScreenshot"]);
  var stopForceAtlas2 = function (s) {
      return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](s)("stopForceAtlas2")([  ]));
  };
  var startForceAtlas2 = function (s) {
      return function (settings) {
          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](s)("startForceAtlas2")([ settings ]));
      };
  };
  var sigma = Effect_Uncurried.runEffectFn3($foreign["_sigma"])(Data_Either.Left.create)(Data_Either.Right.create);
  var restartForceAtlas2 = function (s) {
      return function (settings) {
          return startForceAtlas2(s)(settings);
      };
  };
  var removeNode = function (sg) {
      return function (nId) {
          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](sg)("dropNode")([ nId ]));
      };
  };
  var removeEdge = function (sg) {
      return function (eId) {
          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](sg)("dropEdge")([ eId ]));
      };
  };
  var refresh = function (s) {
      return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](s)("refresh")([  ]));
  };
  var setSettings = function (s) {
      return function (settings) {
          return function __do() {
              FFI_Simple_Functions["applyMethod'"](s)("settings")([ settings ]);
              return refresh(s)();
          };
      };
  };
  var nodes_ = function (sg) {
      return FFI_Simple_Functions["applyMethod'"](sg)("nodes")([  ]);
  };
  var nodes = (function () {
      var $13 = Data_Sequence.fromFoldable(Data_Foldable.foldableArray);
      return function ($14) {
          return $13(nodes_($14));
      };
  })();
  var sigmaNodeIds = function (sg) {
      var nodeIds = Data_Functor.map(Data_Sequence.functorSeq)(function (v) {
          return v.id;
      })(nodes(sg));
      return Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordString)(nodeIds);
  };
  var killForceAtlas2 = function (s) {
      return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](s)("killForceAtlas2")([  ]));
  };
  var kill = function (sigma1) {
      return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](sigma1)("kill")([  ]));
  };
  var isForceAtlas2Running = function (s) {
      return FFI_Simple_Functions["applyMethod'"](s)("isForceAtlas2Running")([  ]);
  };
  var refreshForceAtlas = function (s) {
      return function (settings) {
          var isRunning = isForceAtlas2Running(s);
          if (isRunning) {
              return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
          };
          return function __do() {
              Effect_Timer.setTimeout(100)(function __do() {
                  restartForceAtlas2(s)(settings)();
                  Effect_Timer.setTimeout(100)(stopForceAtlas2(s))();
                  return Data_Unit.unit;
              })();
              return Data_Unit.unit;
          };
      };
  };
  var graphRead = function (dictNodeProps) {
      return function (dictEdgeProps) {
          return function (sg) {
              return function (g) {
                  return Effect_Exception["try"](Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](sg)("read")([ g ])));
              };
          };
      };
  };
  var graph = function (s) {
      return FFI_Simple_Objects["getProperty'"](s)("graph");
  };
  var goTo = function (props) {
      return function (cam) {
          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](cam)("goTo")([ props ]));
      };
  };
  var getNodes = Effect_Uncurried.runEffectFn1($foreign["_getNodes"]);
  var getEdges = Effect_Uncurried.runEffectFn1($foreign["_getEdges"]);
  var forEachNode = function (sg) {
      return function (f) {
          return Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Sequence.foldableSeq)(f)(nodes(sg));
      };
  };
  var edges_ = function (sg) {
      return FFI_Simple_Functions["applyMethod'"](sg)("edges")([  ]);
  };
  var edges = (function () {
      var $15 = Data_Sequence.fromFoldable(Data_Foldable.foldableArray);
      return function ($16) {
          return $15(edges_($16));
      };
  })();
  var forEachEdge = function (sg) {
      return function (f) {
          return Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Sequence.foldableSeq)(f)(edges(sg));
      };
  };
  var sigmaEdgeIds = function (sg) {
      var edgeIds = Data_Functor.map(Data_Sequence.functorSeq)(function (v) {
          return v.id;
      })(edges(sg));
      return Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordString)(edgeIds);
  };
  var clear = function (sg) {
      return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](sg)("clear")([  ]));
  };
  var cameras = function (s) {
      var cs = FFI_Simple_Objects["getProperty'"](s)("cameras");
      return Foreign_Object.values(cs);
  };
  var goToAllCameras = function (s) {
      return function (props) {
          return Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Foldable.foldableArray)(goTo(props))(cameras(s));
      };
  };
  var bind_ = function (s) {
      return function (e) {
          return function (h) {
              return function () {
                  return $foreign["_bind"](s, e, Effect_Uncurried.mkEffectFn1(h));
              };
          };
      };
  };
  var bindMouseSelectorPlugin = Effect_Uncurried.runEffectFn3($foreign["_bindMouseSelectorPlugin"])(Data_Either.Left.create)(Data_Either.Right.create);
  var bindClickNodes = function (s) {
      return function (f) {
          return bind_(s)("clickNodes")(function (e) {
              var ns = FFI_Simple_Objects["getProperty'"](FFI_Simple_Objects["getProperty'"](e)("data"))("node");
              return f(ns);
          });
      };
  };
  var addRenderer = Effect_Uncurried.runEffectFn4($foreign["_addRenderer"])(Data_Either.Left.create)(Data_Either.Right.create);
  var addNode = function (sg) {
      return function (n) {
          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](sg)("addNode")([ n ]));
      };
  };
  var addEdge = function (sg) {
      return function (e) {
          return Control_Applicative.pure(Effect.applicativeEffect)(FFI_Simple_Functions["applyMethod'"](sg)("addEdge")([ e ]));
      };
  };
  exports["sigma"] = sigma;
  exports["kill"] = kill;
  exports["refresh"] = refresh;
  exports["addRenderer"] = addRenderer;
  exports["bindMouseSelectorPlugin"] = bindMouseSelectorPlugin;
  exports["graph"] = graph;
  exports["graphRead"] = graphRead;
  exports["clear"] = clear;
  exports["sigmaEdgeIds"] = sigmaEdgeIds;
  exports["sigmaNodeIds"] = sigmaNodeIds;
  exports["addEdge"] = addEdge;
  exports["removeEdge"] = removeEdge;
  exports["addNode"] = addNode;
  exports["removeNode"] = removeNode;
  exports["forEachEdge"] = forEachEdge;
  exports["forEachNode"] = forEachNode;
  exports["bindClickNodes"] = bindClickNodes;
  exports["setSettings"] = setSettings;
  exports["startForceAtlas2"] = startForceAtlas2;
  exports["restartForceAtlas2"] = restartForceAtlas2;
  exports["stopForceAtlas2"] = stopForceAtlas2;
  exports["killForceAtlas2"] = killForceAtlas2;
  exports["isForceAtlas2Running"] = isForceAtlas2Running;
  exports["refreshForceAtlas"] = refreshForceAtlas;
  exports["cameras"] = cameras;
  exports["toCamera"] = toCamera;
  exports["updateCamera"] = updateCamera;
  exports["goToAllCameras"] = goToAllCameras;
  exports["takeScreenshot"] = takeScreenshot;
  exports["getEdges"] = getEdges;
  exports["getNodes"] = getNodes;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Hooks.Sigmax.Types"] = $PS["Gargantext.Hooks.Sigmax.Types"] || {};
  var exports = $PS["Gargantext.Hooks.Sigmax.Types"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_EuclideanRing = $PS["Data.EuclideanRing"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Set = $PS["Data.Set"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Gargantext_Components_GraphExplorer_Types = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];                
  var EShow = (function () {
      function EShow() {

      };
      EShow.value = new EShow();
      return EShow;
  })();
  var EHide = (function () {
      function EHide() {

      };
      EHide.value = new EHide();
      return EHide;
  })();
  var ETempHiddenThenShow = (function () {
      function ETempHiddenThenShow() {

      };
      ETempHiddenThenShow.value = new ETempHiddenThenShow();
      return ETempHiddenThenShow;
  })();
  var InitialRunning = (function () {
      function InitialRunning() {

      };
      InitialRunning.value = new InitialRunning();
      return InitialRunning;
  })();
  var InitialStopped = (function () {
      function InitialStopped() {

      };
      InitialStopped.value = new InitialStopped();
      return InitialStopped;
  })();
  var Running = (function () {
      function Running() {

      };
      Running.value = new Running();
      return Running;
  })();
  var Paused = (function () {
      function Paused() {

      };
      Paused.value = new Paused();
      return Paused;
  })();
  var Killed = (function () {
      function Killed() {

      };
      Killed.value = new Killed();
      return Killed;
  })();
  var toggleForceAtlasState = function (v) {
      if (v instanceof InitialRunning) {
          return Paused.value;
      };
      if (v instanceof InitialStopped) {
          return InitialRunning.value;
      };
      if (v instanceof Running) {
          return Paused.value;
      };
      if (v instanceof Paused) {
          return Running.value;
      };
      if (v instanceof Killed) {
          return InitialRunning.value;
      };
      throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax.Types (line 166, column 1 - line 166, column 60): " + [ v.constructor.name ]);
  };
  var nodesMap = function (nodes) {
      return Data_Map_Internal.fromFoldable(Data_Ord.ordString)(Data_Sequence.foldableSeq)(Data_Functor.map(Data_Sequence.functorSeq)(function (n) {
          return new Data_Tuple.Tuple(n.id, n);
      })(nodes));
  };
  var nodesFilter = function (f) {
      return function (v) {
          return {
              edges: v.edges,
              nodes: Data_Sequence.filter(f)(v.nodes)
          };
      };
  };
  var nodesById = function (g) {
      return function (nodeIds) {
          return nodesFilter(function (n) {
              return Data_Set.member(Data_Ord.ordString)(n.id)(nodeIds);
          })(g);
      };
  };
  var graphNodes = function (v) {
      return v.nodes;
  };
  var louvainNodes = function (g) {
      return Data_Sequence.toUnfoldable(Data_Functor.functorArray)(Data_Unfoldable.unfoldableArray)(Data_Sequence.map(function (v) {
          return v.id;
      })(graphNodes(g)));
  };
  var nodesGraphMap = function (graph) {
      return nodesMap(graphNodes(graph));
  };
  var graphEdges = function (v) {
      return v.edges;
  };
  var louvainEdges = function (g) {
      return Data_Sequence.toUnfoldable(Data_Functor.functorArray)(Data_Unfoldable.unfoldableArray)(Data_Sequence.map(function (v) {
          return {
              source: v.source,
              target: v.target,
              weight: v.weight
          };
      })(graphEdges(g)));
  };
  var neighbouringEdges = function (g) {
      return function (nodeIds) {
          var condition = function (v) {
              return Data_Set.member(Data_Ord.ordString)(v.source)(nodeIds) || Data_Set.member(Data_Ord.ordString)(v.target)(nodeIds);
          };
          return Data_Sequence.filter(condition)(graphEdges(g));
      };
  };
  var neighbours = function (g) {
      return function (nodes) {
          var nodeIds = Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordString)(Data_Sequence.map(function (v) {
              return v.id;
          })(nodes));
          var selectedEdges = neighbouringEdges(g)(nodeIds);
          var sources = Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
              return "y";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "x";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "type";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "size";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "label";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "id";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "hidden";
          }))(Data_Ord.ordBoolean))()(new Data_Symbol.IsSymbol(function () {
              return "gargType";
          }))(Gargantext_Types["$_OrdMode_155"]))()(new Data_Symbol.IsSymbol(function () {
              return "equilateral";
          }))(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
              return "numPoints";
          }))(Data_Ord.ordInt))))()(new Data_Symbol.IsSymbol(function () {
              return "color";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "borderColor";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "_original";
          }))(Gargantext_Components_GraphExplorer_Types["$_OrdNode_44"])))(graphNodes(nodesById(g)(Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordString)(Data_Sequence.map(function (v) {
              return v.source;
          })(selectedEdges)))));
          var targets = Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
              return "y";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "x";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "type";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "size";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "label";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "id";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "hidden";
          }))(Data_Ord.ordBoolean))()(new Data_Symbol.IsSymbol(function () {
              return "gargType";
          }))(Gargantext_Types["$_OrdMode_155"]))()(new Data_Symbol.IsSymbol(function () {
              return "equilateral";
          }))(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
              return "numPoints";
          }))(Data_Ord.ordInt))))()(new Data_Symbol.IsSymbol(function () {
              return "color";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "borderColor";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "_original";
          }))(Gargantext_Components_GraphExplorer_Types["$_OrdNode_44"])))(graphNodes(nodesById(g)(Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordString)(Data_Sequence.map(function (v) {
              return v.target;
          })(selectedEdges)))));
          return Data_Sequence.fromFoldable(Data_Set.foldableSet)(Data_Set.unions(Data_Foldable.foldableArray)(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
              return "y";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "x";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "type";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "size";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "label";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "id";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "hidden";
          }))(Data_Ord.ordBoolean))()(new Data_Symbol.IsSymbol(function () {
              return "gargType";
          }))(Gargantext_Types["$_OrdMode_155"]))()(new Data_Symbol.IsSymbol(function () {
              return "equilateral";
          }))(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
              return "numPoints";
          }))(Data_Ord.ordInt))))()(new Data_Symbol.IsSymbol(function () {
              return "color";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "borderColor";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "_original";
          }))(Gargantext_Components_GraphExplorer_Types["$_OrdNode_44"])))([ Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
              return "y";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "x";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "type";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "size";
          }))(Data_Ord.ordNumber))()(new Data_Symbol.IsSymbol(function () {
              return "label";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "id";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "hidden";
          }))(Data_Ord.ordBoolean))()(new Data_Symbol.IsSymbol(function () {
              return "gargType";
          }))(Gargantext_Types["$_OrdMode_155"]))()(new Data_Symbol.IsSymbol(function () {
              return "equilateral";
          }))(Data_Ord.ordRecord()(Data_Ord.ordRecordCons(Data_Ord.ordRecordNil)()(new Data_Symbol.IsSymbol(function () {
              return "numPoints";
          }))(Data_Ord.ordInt))))()(new Data_Symbol.IsSymbol(function () {
              return "color";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "borderColor";
          }))(Data_Ord.ordString))()(new Data_Symbol.IsSymbol(function () {
              return "_original";
          }))(Gargantext_Components_GraphExplorer_Types["$_OrdNode_44"])))(nodes), sources, targets ]));
      };
  };
  var emptyNodeIds = Data_Set.empty;
  var edgesGraphMap = function (graph) {
      return Data_Map_Internal.fromFoldable(Data_Ord.ordString)(Data_Sequence.foldableSeq)(Data_Functor.map(Data_Sequence.functorSeq)(function (e) {
          return new Data_Tuple.Tuple(e.id, e);
      })(graphEdges(graph)));
  };
  var edgesFilter = function (f) {
      return function (v) {
          return {
              edges: Data_Sequence.filter(f)(v.edges),
              nodes: v.nodes
          };
      };
  };
  var sigmaDiff = function (sigmaEdges) {
      return function (sigmaNodes) {
          return function (v) {
              var removeNodes = Data_Set.difference(Data_Ord.ordString)(sigmaNodes)(Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordString)(Data_Sequence.map(function (v1) {
                  return v1.id;
              })(v.nodes)));
              var removeEdges = Data_Set.difference(Data_Ord.ordString)(sigmaEdges)(Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordString)(Data_Sequence.map(function (v1) {
                  return v1.id;
              })(v.edges)));
              var remove = new Data_Tuple.Tuple(removeEdges, removeNodes);
              var addG = edgesFilter(function (e) {
                  return !Data_Set.member(Data_Ord.ordString)(e.id)(sigmaEdges);
              })(nodesFilter(function (n) {
                  return !Data_Set.member(Data_Ord.ordString)(n.id)(sigmaNodes);
              })(v));
              var addNodes = graphNodes(addG);
              var addEdges = graphEdges(addG);
              var add = new Data_Tuple.Tuple(addEdges, addNodes);
              return {
                  add: add,
                  remove: remove
              };
          };
      };
  };
  var edgeStateHidden = function (v) {
      if (v instanceof EHide) {
          return true;
      };
      if (v instanceof ETempHiddenThenShow) {
          return true;
      };
      return false;
  };
  var toggleShowEdgesState = function (s) {
      var $87 = edgeStateHidden(s);
      if ($87) {
          return EShow.value;
      };
      return EHide.value;
  };
  var edgeClusterColor = function (dictOrd) {
      return function (cluster) {
          return function (nm) {
              return function (e) {
                  var targetNode = (function () {
                      var v = Data_Map_Internal.lookup(dictOrd)(e.target)(nm);
                      if (v instanceof Data_Maybe.Just) {
                          return v.value0;
                      };
                      if (v instanceof Data_Maybe.Nothing) {
                          return e.targetNode;
                      };
                      throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax.Types (line 246, column 18 - line 248, column 30): " + [ v.constructor.name ]);
                  })();
                  var sourceNode = (function () {
                      var v = Data_Map_Internal.lookup(dictOrd)(e.source)(nm);
                      if (v instanceof Data_Maybe.Just) {
                          return v.value0;
                      };
                      if (v instanceof Data_Maybe.Nothing) {
                          return e.sourceNode;
                      };
                      throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax.Types (line 243, column 18 - line 245, column 30): " + [ v.constructor.name ]);
                  })();
                  var $92 = {};
                  for (var $93 in e) {
                      if ({}.hasOwnProperty.call(e, $93)) {
                          $92[$93] = e[$93];
                      };
                  };
                  $92.color = sourceNode.color;
                  $92.sourceNode = sourceNode;
                  $92.targetNode = targetNode;
                  return $92;
              };
          };
      };
  };
  var defaultPalette = [ "#5fa571", "#ab9ba2", "#da876d", "#bdd3ff", "#b399df", "#ffdfed", "#33c8f3", "#739e9a", "#caeca3", "#f6f7e5", "#f9bcca", "#ccb069", "#c9ffde", "#c58683", "#6c9eb0", "#ffd3cf", "#ccffc7", "#52a1b0", "#d2ecff", "#99fffe", "#9295ae", "#5ea38b", "#fff0b3", "#d99e68" ];
  var nodeClusterColor = function (dictOrd) {
      return function (cluster) {
          return function (n) {
              var newColor = (function () {
                  var v = Data_Map_Internal.lookup(dictOrd)(n.id)(cluster);
                  if (v instanceof Data_Maybe.Nothing) {
                      return n.color;
                  };
                  if (v instanceof Data_Maybe.Just) {
                      var idx = Data_EuclideanRing.mod(Data_EuclideanRing.euclideanRingInt)(v.value0)(Data_Array.length(defaultPalette));
                      return Data_Maybe.fromJust()(Data_Array.index(defaultPalette)(idx));
                  };
                  throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax.Types (line 252, column 16 - line 256, column 59): " + [ v.constructor.name ]);
              })();
              var $97 = {};
              for (var $98 in n) {
                  if ({}.hasOwnProperty.call(n, $98)) {
                      $97[$98] = n[$98];
                  };
              };
              $97.color = newColor;
              return $97;
          };
      };
  };
  var louvainGraph = function (g) {
      return function (cluster) {
          var nodes = graphNodes(g);
          var newNodes = Data_Functor.map(Data_Sequence.functorSeq)(nodeClusterColor(Data_Ord.ordString)(cluster))(nodes);
          var nm = nodesMap(newNodes);
          var edges = graphEdges(g);
          var newEdges = Data_Functor.map(Data_Sequence.functorSeq)(edgeClusterColor(Data_Ord.ordString)(cluster)(nm))(edges);
          return {
              nodes: newNodes,
              edges: newEdges
          };
      };
  };
  var $dollar_GenericShowEdgesState__35 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof EShow) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof EHide) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof ETempHiddenThenShow) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value));
      };
      throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax.Types (line 178, column 1 - line 178, column 41): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return EShow.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return EHide.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inr) {
          return ETempHiddenThenShow.value;
      };
      throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax.Types (line 178, column 1 - line 178, column 41): " + [ x.constructor.name ]);
  });     
  var $dollar_GenericGraph__31 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericForceAtlasState__33 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof InitialRunning) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof InitialStopped) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof Running) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof Paused) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
      };
      if (x instanceof Killed) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))));
      };
      throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax.Types (line 162, column 1 - line 162, column 42): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return InitialRunning.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return InitialStopped.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return Running.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
          return Paused.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inr))) {
          return Killed.value;
      };
      throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax.Types (line 162, column 1 - line 162, column 42): " + [ x.constructor.name ]);
  });
  var $dollar_EqShowEdgesState_36 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericShowEdgesState__35)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)))));
  var $dollar_EqGraph_32 = function (dictEq) {
      return function (dictEq1) {
          return new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericGraph__31)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
              return "nodes";
          }))(Data_Sequence.eqSeq(dictEq)))()(new Data_Symbol.IsSymbol(function () {
              return "edges";
          }))(Data_Sequence.eqSeq(dictEq1)))))));
      };
  };
  var $dollar_EqForceAtlasState_34 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericForceAtlasState__33)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)))))));
  exports["emptyNodeIds"] = emptyNodeIds;
  exports["graphEdges"] = graphEdges;
  exports["graphNodes"] = graphNodes;
  exports["edgesGraphMap"] = edgesGraphMap;
  exports["nodesMap"] = nodesMap;
  exports["nodesGraphMap"] = nodesGraphMap;
  exports["nodesById"] = nodesById;
  exports["sigmaDiff"] = sigmaDiff;
  exports["neighbours"] = neighbours;
  exports["neighbouringEdges"] = neighbouringEdges;
  exports["InitialRunning"] = InitialRunning;
  exports["InitialStopped"] = InitialStopped;
  exports["Running"] = Running;
  exports["Paused"] = Paused;
  exports["Killed"] = Killed;
  exports["toggleForceAtlasState"] = toggleForceAtlasState;
  exports["EShow"] = EShow;
  exports["edgeStateHidden"] = edgeStateHidden;
  exports["toggleShowEdgesState"] = toggleShowEdgesState;
  exports["louvainEdges"] = louvainEdges;
  exports["louvainNodes"] = louvainNodes;
  exports["louvainGraph"] = louvainGraph;
  exports["$_EqGraph_32"] = $dollar_EqGraph_32;
  exports["$_EqForceAtlasState_34"] = $dollar_EqForceAtlasState_34;
  exports["$_EqShowEdgesState_36"] = $dollar_EqShowEdgesState_36;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Hooks.Sigmax"] = $PS["Gargantext.Hooks.Sigmax"] || {};
  var exports = $PS["Gargantext.Hooks.Sigmax"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var Data_Array = $PS["Data.Array"];
  var Data_Either = $PS["Data.Either"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Set = $PS["Data.Set"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Class = $PS["Effect.Class"];
  var Effect_Class_Console = $PS["Effect.Class.Console"];
  var Effect_Timer = $PS["Effect.Timer"];
  var FFI_Simple_Objects = $PS["FFI.Simple.Objects"];
  var Gargantext_Hooks_Sigmax_Sigma = $PS["Gargantext.Hooks.Sigmax.Sigma"];
  var Gargantext_Hooks_Sigmax_Types = $PS["Gargantext.Hooks.Sigmax.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var writeSigma = function (sigma) {
      return Reactix_React.setRef(sigma.sigma);
  };
  var updateNodes = function (sigma) {
      return function (nodesMap) {
          return Gargantext_Hooks_Sigmax_Sigma.forEachNode(Gargantext_Hooks_Sigmax_Sigma.graph(sigma))(function (n) {
              var mTNode = Data_Map_Internal.lookup(Data_Ord.ordString)(n.id)(nodesMap);
              if (mTNode instanceof Data_Maybe.Nothing) {
                  return Effect_Class_Console.error(Effect_Class.monadEffectEffect)("Node id " + (n.id + " not found in nodesMap"));
              };
              if (mTNode instanceof Data_Maybe.Just) {
                  return function __do() {
                      FFI_Simple_Objects["setProperty'"](n)("borderColor")(mTNode.value0.borderColor);
                      FFI_Simple_Objects["setProperty'"](n)("color")(mTNode.value0.color);
                      FFI_Simple_Objects["setProperty'"](n)("equilateral")(mTNode.value0.equilateral);
                      FFI_Simple_Objects["setProperty'"](n)("hidden")(mTNode.value0.hidden);
                      FFI_Simple_Objects["setProperty'"](n)("type")(mTNode.value0.type);
                      return Data_Unit.unit;
                  };
              };
              throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax (line 161, column 5 - line 173, column 18): " + [ mTNode.constructor.name ]);
          });
      };
  };
  var updateEdges = function (sigma) {
      return function (edgesMap) {
          return Gargantext_Hooks_Sigmax_Sigma.forEachEdge(Gargantext_Hooks_Sigmax_Sigma.graph(sigma))(function (e) {
              var mTEdge = Data_Map_Internal.lookup(Data_Ord.ordString)(e.id)(edgesMap);
              if (mTEdge instanceof Data_Maybe.Nothing) {
                  return Effect_Class_Console.error(Effect_Class.monadEffectEffect)("Edge id " + (e.id + " not found in edgesMap"));
              };
              if (mTEdge instanceof Data_Maybe.Just) {
                  return function __do() {
                      FFI_Simple_Objects["setProperty'"](e)("color")(mTEdge.value0.color);
                      FFI_Simple_Objects["setProperty'"](e)("hidden")(mTEdge.value0.hidden);
                      return Data_Unit.unit;
                  };
              };
              throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax (line 148, column 5 - line 153, column 18): " + [ mTEdge.constructor.name ]);
          });
      };
  };
  var sigmafy = function (v) {
      var nodes = Data_Array.fromFoldable(Data_Sequence.foldableSeq)(v.nodes);
      var edges = Data_Array.fromFoldable(Data_Sequence.foldableSeq)(v.edges);
      return {
          nodes: nodes,
          edges: edges
      };
  };
  var setEdges = function (sigma) {
      return function (val) {
          var settings = {
              drawEdges: val,
              drawEdgeLabels: val,
              hideEdgesOnMove: !val
          };
          return Gargantext_Hooks_Sigmax_Sigma.setSettings(sigma)(settings);
      };
  };
  var refreshData = function (sigma) {
      return function (graph) {
          var sigmaGraph = Gargantext_Hooks_Sigmax_Sigma.graph(sigma);
          var refresh = function (v) {
              return Control_Apply.applySecond(Effect.applyEffect)(DOM_Simple_Console.log("[refreshData] Refreshing graph"))(Gargantext_Hooks_Sigmax_Sigma.refresh(sigma));
          };
          return Control_Bind.bind(Effect.bindEffect)(Control_Apply.applySecond(Effect.applyEffect)(Control_Apply.applySecond(Effect.applyEffect)(Control_Apply.applySecond(Effect.applyEffect)(DOM_Simple_Console.log("[refreshData] Clearing existing graph data"))(Gargantext_Hooks_Sigmax_Sigma.clear(sigmaGraph)))(DOM_Simple_Console.log("[refreshData] Reading graph data")))(Gargantext_Hooks_Sigmax_Sigma.graphRead()()(sigmaGraph)(graph)))(Data_Either.either(DOM_Simple_Console.log2("[refreshData] Error reading graph data:"))(refresh));
      };
  };
  var readSigma = function (sigma) {
      return Reactix_React.readRef(sigma.sigma);
  };
  var performDiff = function (sigma) {
      return function (g) {
          var sigmaGraph = Gargantext_Hooks_Sigmax_Sigma.graph(sigma);
          var sigmaNodeIds = Gargantext_Hooks_Sigmax_Sigma.sigmaNodeIds(sigmaGraph);
          var sigmaEdgeIds = Gargantext_Hooks_Sigmax_Sigma.sigmaEdgeIds(sigmaGraph);
          var v = Gargantext_Hooks_Sigmax_Types.sigmaDiff(sigmaEdgeIds)(sigmaNodeIds)(g);
          var $25 = Data_Sequence["null"](v.add.value0) && (Data_Sequence["null"](v.add.value1) && (Data_Set.isEmpty(v.remove.value0) && Data_Set.isEmpty(v.remove.value1)));
          if ($25) {
              return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
          };
          return function __do() {
              Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Sequence.foldableSeq)(Gargantext_Hooks_Sigmax_Sigma.addNode(sigmaGraph))(v.add.value1)();
              Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Sequence.foldableSeq)(Gargantext_Hooks_Sigmax_Sigma.addEdge(sigmaGraph))(v.add.value0)();
              Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Set.foldableSet)(Gargantext_Hooks_Sigmax_Sigma.removeEdge(sigmaGraph))(v.remove.value0)();
              Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Set.foldableSet)(Gargantext_Hooks_Sigmax_Sigma.removeNode(sigmaGraph))(v.remove.value1)();
              Gargantext_Hooks_Sigmax_Sigma.refresh(sigma)();
              return Gargantext_Hooks_Sigmax_Sigma.killForceAtlas2(sigma)();
          };
      };
  };
  var multiSelectUpdate = function ($$new) {
      return function (selected) {
          var fld = function (selectedAcc) {
              return function (item) {
                  var $32 = Data_Set.member(Data_Ord.ordString)(item)(selectedAcc);
                  if ($32) {
                      return Data_Set["delete"](Data_Ord.ordString)(item)(selectedAcc);
                  };
                  return Data_Set.insert(Data_Ord.ordString)(item)(selectedAcc);
              };
          };
          return Data_Foldable.foldl(Data_Set.foldableSet)(fld)(selected)($$new);
      };
  };
  var initSigma = Control_Bind.bind(Reactix_React.bindHooks)(Gargantext_Utils_Reactix.nothingRef)(function (s) {
      return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Sequence.empty))(function (c) {
          return Control_Applicative.pure(Reactix_React.applicativeHooks)({
              sigma: s,
              cleanup: c
          });
      });
  });
  var getNodes = function (sigma) {
      return Gargantext_Hooks_Sigmax_Sigma.getNodes(sigma);
  };
  var getEdges = function (sigma) {
      return Gargantext_Hooks_Sigmax_Sigma.getEdges(sigma);
  };
  var dependOnSigma = function (sigma) {
      return function (notFoundMsg) {
          return function (f) {
              var v = readSigma(sigma);
              if (v instanceof Data_Maybe.Nothing) {
                  return DOM_Simple_Console.log(notFoundMsg);
              };
              if (v instanceof Data_Maybe.Just) {
                  return f(v.value0);
              };
              throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax (line 100, column 3 - line 102, column 22): " + [ v.constructor.name ]);
          };
      };
  };
  var handleForceAtlas2Pause = function (sigmaRef) {
      return function (forceAtlasState) {
          return function (mFAPauseRef) {
              return function (settings) {
                  var sigma = Reactix_React.readRef(sigmaRef);
                  return function __do() {
                      var toggled = Toestand_Classes.read(Toestand_Boxes.readBox)(Reactix_React.monadDelayEffect)(forceAtlasState)();
                      return dependOnSigma(sigma)("[handleForceAtlas2Pause] sigma: Nothing")(function (s) {
                          var isFARunning = Gargantext_Hooks_Sigmax_Sigma.isForceAtlas2Running(s);
                          var v = new Data_Tuple.Tuple(toggled, isFARunning);
                          if (v.value0 instanceof Gargantext_Hooks_Sigmax_Types.InitialRunning && !v.value1) {
                              return Gargantext_Hooks_Sigmax_Sigma.restartForceAtlas2(s)(settings);
                          };
                          if (v.value0 instanceof Gargantext_Hooks_Sigmax_Types.Running && !v.value1) {
                              return function __do() {
                                  Gargantext_Hooks_Sigmax_Sigma.restartForceAtlas2(s)(settings)();
                                  var v1 = Reactix_React.readRef(mFAPauseRef);
                                  if (v1 instanceof Data_Maybe.Nothing) {
                                      return Data_Unit.unit;
                                  };
                                  if (v1 instanceof Data_Maybe.Just) {
                                      return Effect_Timer.clearTimeout(v1.value0)();
                                  };
                                  throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax (line 127, column 9 - line 129, column 51): " + [ v1.constructor.name ]);
                              };
                          };
                          if (v.value0 instanceof Gargantext_Hooks_Sigmax_Types.Paused && v.value1) {
                              return Gargantext_Hooks_Sigmax_Sigma.stopForceAtlas2(s);
                          };
                          return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                      })();
                  };
              };
          };
      };
  };
  var dependOnContainer = function (container) {
      return function (notFoundMsg) {
          return function (f) {
              var v = Reactix_React.readNullableRef(container);
              if (v instanceof Data_Maybe.Nothing) {
                  return DOM_Simple_Console.log(notFoundMsg);
              };
              if (v instanceof Data_Maybe.Just) {
                  return f(v.value0);
              };
              throw new Error("Failed pattern match at Gargantext.Hooks.Sigmax (line 106, column 3 - line 108, column 18): " + [ v.constructor.name ]);
          };
      };
  };
  var bindSelectedNodesClick = function (sigma) {
      return function (selectedNodeIds) {
          return function (multiSelectEnabledRef) {
              return Gargantext_Hooks_Sigmax_Sigma.bindClickNodes(sigma)(function (nodes) {
                  var multiSelectEnabled = Reactix_React.readRef(multiSelectEnabledRef);
                  var nodeIds = Data_Set.fromFoldable(Data_Foldable.foldableArray)(Data_Ord.ordString)(Data_Functor.map(Data_Functor.functorArray)(function (v) {
                      return v.id;
                  })(nodes));
                  if (multiSelectEnabled) {
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(multiSelectUpdate(nodeIds))(selectedNodeIds);
                  };
                  return Toestand_Classes.write_(Toestand_Boxes.writeBox)(nodeIds)(selectedNodeIds);
              });
          };
      };
  };
  exports["initSigma"] = initSigma;
  exports["readSigma"] = readSigma;
  exports["writeSigma"] = writeSigma;
  exports["refreshData"] = refreshData;
  exports["sigmafy"] = sigmafy;
  exports["dependOnSigma"] = dependOnSigma;
  exports["dependOnContainer"] = dependOnContainer;
  exports["handleForceAtlas2Pause"] = handleForceAtlas2Pause;
  exports["setEdges"] = setEdges;
  exports["updateEdges"] = updateEdges;
  exports["updateNodes"] = updateNodes;
  exports["bindSelectedNodesClick"] = bindSelectedNodesClick;
  exports["performDiff"] = performDiff;
  exports["getEdges"] = getEdges;
  exports["getNodes"] = getNodes;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Graph"] = $PS["Gargantext.Components.Graph"] || {};
  var exports = $PS["Gargantext.Components.Graph"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Either = $PS["Data.Either"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Gargantext_Hooks_Sigmax = $PS["Gargantext.Hooks.Sigmax"];
  var Gargantext_Hooks_Sigmax_Sigma = $PS["Gargantext.Hooks.Sigmax.Sigma"];
  var Gargantext_Hooks_Sigmax_Types = $PS["Gargantext.Hooks.Sigmax.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var Init = (function () {
      function Init() {

      };
      Init.value = new Init();
      return Init;
  })();
  var Ready = (function () {
      function Ready() {

      };
      Ready.value = new Ready();
      return Ready;
  })();
  var Cleanup = (function () {
      function Cleanup() {

      };
      Cleanup.value = new Cleanup();
      return Cleanup;
  })();
  var sigmaSettings = {
      animationsTime: 30000.0,
      autoRescale: true,
      autoResize: true,
      batchEdgesDrawing: true,
      borderSize: 1.0,
      defaultEdgeHoverColor: "#f00",
      defaultEdgeType: "curve",
      defaultHoverLabelBGColor: "#fff",
      defaultHoverLabelColor: "#000",
      defaultLabelColor: "#000",
      defaultLabelSize: 15.0,
      defaultNodeBorderColor: "#000",
      defaultNodeColor: "#FFF",
      doubleClickEnabled: false,
      drawEdgeLabels: true,
      drawEdges: true,
      drawLabels: true,
      drawNodes: true,
      enableEdgeHovering: false,
      edgeHoverExtremities: true,
      edgeHoverColor: "edge",
      edgeHoverPrecision: 2.0,
      edgeHoverSizeRatio: 2.0,
      enableHovering: true,
      font: "arial",
      fontStyle: "",
      hideEdgesOnMove: true,
      labelSize: "proportional",
      labelSizeRatio: 2.0,
      labelThreshold: 9.0,
      maxEdgeSize: 1.0,
      maxNodeSize: 10.0,
      minEdgeSize: 0.5,
      minNodeSize: 1.0,
      mouseEnabled: true,
      mouseSelectorSize: 15.0,
      mouseZoomDuration: 150.0,
      nodeBorderColor: "default",
      rescaleIgnoreSize: false,
      singleHover: true,
      touchEnabled: true,
      twBorderGreyColor: "rgba(100, 100, 100, 0.9)",
      twEdgeDefaultOpacity: 0.4,
      twEdgeGreyColor: "rgba(100, 100, 100, 0.25)",
      twNodeRendBorderColor: "#FFF",
      twNodeRendBorderSize: 2.5,
      twNodesGreyOpacity: 5.5,
      twSelectedColor: "node",
      verbose: true,
      zoomMax: 1.7,
      zoomMin: 0.0,
      zoomingRatio: 1.4
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Graph");
  var forceAtlas2Settings = {
      adjustSizes: true,
      barnesHutOptimize: true,
      edgeWeightInfluence: 1.0,
      gravity: 1.0e-2,
      includeHiddenEdges: false,
      includeHiddenNodes: true,
      iterationsPerRender: 50.0,
      linLogMode: false,
      outboundAttractionDistribution: false,
      scalingRatio: 1000.0,
      skipHidden: false,
      slowDown: 1.0,
      startingIterations: 10.0,
      strongGravityMode: false
  }; 
  var $dollar_EqStage_7 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof Init && y instanceof Init) {
              return true;
          };
          if (x instanceof Ready && y instanceof Ready) {
              return true;
          };
          if (x instanceof Cleanup && y instanceof Cleanup) {
              return true;
          };
          return false;
      };
  });
  var graphCpt = (function () {
      var stageHooks = function (v) {
          if (v["stage'"] instanceof Init) {
              return Reactix_Hooks["useEffectOnce'"]((function () {
                  var rSigma = Reactix_React.readRef(v.sigmaRef);
                  return function __do() {
                      (function () {
                          var v1 = Gargantext_Hooks_Sigmax.readSigma(rSigma);
                          if (v1 instanceof Data_Maybe.Nothing) {
                              var eSigma = Gargantext_Hooks_Sigmax_Sigma.sigma({
                                  settings: sigmaSettings
                              })();
                              if (eSigma instanceof Data_Either.Left) {
                                  return here.log2("[graphCpt] error creating sigma")(eSigma.value0)();
                              };
                              if (eSigma instanceof Data_Either.Right) {
                                  Gargantext_Hooks_Sigmax.writeSigma(rSigma)(new Data_Maybe.Just(eSigma.value0))();
                                  Gargantext_Hooks_Sigmax.dependOnContainer(v.elRef)("[graphCpt (Ready)] container not found")(function (c) {
                                      return function __do() {
                                          Gargantext_Hooks_Sigmax_Sigma.addRenderer(eSigma.value0)({
                                              type: "canvas",
                                              container: c,
                                              additionalContexts: [ "mouseSelector" ]
                                          })();
                                          return Data_Unit.unit;
                                      };
                                  })();
                                  Gargantext_Hooks_Sigmax.refreshData(eSigma.value0)(Gargantext_Hooks_Sigmax.sigmafy(v.graph))();
                                  Gargantext_Hooks_Sigmax.dependOnSigma(Reactix_React.readRef(v.sigmaRef))("[graphCpt (Ready)] no sigma")(function (sigma) {
                                      return function __do() {
                                          Gargantext_Hooks_Sigmax.bindSelectedNodesClick(sigma)(v.selectedNodeIds)(v.multiSelectEnabledRef)();
                                          Gargantext_Hooks_Sigmax_Sigma.bindMouseSelectorPlugin(sigma)();
                                          return Data_Unit.unit;
                                      };
                                  })();
                                  Gargantext_Hooks_Sigmax.setEdges(eSigma.value0)(false)();
                                  (function () {
                                      if (v.startForceAtlas) {
                                          return Gargantext_Hooks_Sigmax_Sigma.startForceAtlas2(eSigma.value0)(v.forceAtlas2Settings)();
                                      };
                                      return Gargantext_Hooks_Sigmax_Sigma.stopForceAtlas2(eSigma.value0)();
                                  })();
                                  (function () {
                                      if (v.mCamera instanceof Data_Maybe.Nothing) {
                                          return Data_Unit.unit;
                                      };
                                      if (v.mCamera instanceof Data_Maybe.Just) {
                                          return Gargantext_Hooks_Sigmax_Sigma.updateCamera(eSigma.value0)({
                                              ratio: v.mCamera.value0.ratio,
                                              x: v.mCamera.value0.x,
                                              y: v.mCamera.value0.y
                                          })();
                                      };
                                      throw new Error("Failed pattern match at Gargantext.Components.Graph (line 123, column 17 - line 126, column 59): " + [ v.mCamera.constructor.name ]);
                                  })();
                                  return Data_Unit.unit;
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.Graph (line 94, column 13 - line 128, column 26): " + [ eSigma.constructor.name ]);
                          };
                          if (v1 instanceof Data_Maybe.Just) {
                              return Data_Unit.unit;
                          };
                          throw new Error("Failed pattern match at Gargantext.Components.Graph (line 91, column 9 - line 130, column 22): " + [ v1.constructor.name ]);
                      })();
                      return Toestand_Classes.write(Toestand_Boxes.writeBox)(Ready.value)(v.stage)();
                  };
              })());
          };
          if (v["stage'"] instanceof Ready) {
              var tEdgesMap = Gargantext_Hooks_Sigmax_Types.edgesGraphMap(v.transformedGraph);
              var tNodesMap = Gargantext_Hooks_Sigmax_Types.nodesGraphMap(v.transformedGraph);
              return Reactix_Hooks["useEffect'"](Gargantext_Hooks_Sigmax.dependOnSigma(Reactix_React.readRef(v.sigmaRef))("[graphCpt (Ready)] no sigma")(function (sigma) {
                  return function __do() {
                      Gargantext_Hooks_Sigmax.performDiff(sigma)(v.transformedGraph)();
                      Gargantext_Hooks_Sigmax.updateEdges(sigma)(tEdgesMap)();
                      Gargantext_Hooks_Sigmax.updateNodes(sigma)(tNodesMap)();
                      return Gargantext_Hooks_Sigmax.setEdges(sigma)(!Gargantext_Hooks_Sigmax_Types.edgeStateHidden(v["showEdges'"]))();
                  };
              }));
          };
          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Data_Unit.unit);
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Hooks_Sigmax_Types["$_EqShowEdgesState_36"]))(v.showEdges))(function (showEdges$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal($dollar_EqStage_7))(v.stage))(function (stage$prime) {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(stageHooks(Record.merge()()({
                          "showEdges'": showEdges$prime,
                          "stage'": stage$prime
                      })(v)))(function () {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks.useEffectOnce(Control_Applicative.pure(Effect.applicativeEffect)(function __do() {
                              here.log("[graphCpt (Cleanup)]")();
                              return Gargantext_Hooks_Sigmax.dependOnSigma(Reactix_React.readRef(v.sigmaRef))("[graphCpt (Cleanup)] no sigma")(function (sigma) {
                                  return function __do() {
                                      Gargantext_Hooks_Sigmax_Sigma.stopForceAtlas2(sigma)();
                                      here.log2("[graphCpt (Cleanup)] forceAtlas stopped for")(sigma)();
                                      Gargantext_Hooks_Sigmax_Sigma.kill(sigma)();
                                      return here.log("[graphCpt (Cleanup)] sigma killed")();
                                  };
                              })();
                          })))(function () {
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)((function () {
                                  var v2 = Reactix_React.readNullableRef(v.elRef);
                                  if (v2 instanceof Data_Maybe.Nothing) {
                                      return Reactix_DOM_HTML.div({})([  ]);
                                  };
                                  if (v2 instanceof Data_Maybe.Just) {
                                      return Reactix_React.createPortal([  ])(v2.value0);
                                  };
                                  throw new Error("Failed pattern match at Gargantext.Components.Graph (line 82, column 14 - line 84, column 40): " + [ v2.constructor.name ]);
                              })());
                          });
                      });
                  });
              });
          };
      };
      return here.component("graph")(cpt);
  })();
  var graph = Reactix_React.createElement(Reactix_React.componentIsComponent)(graphCpt);
  exports["Init"] = Init;
  exports["graph"] = graph;
  exports["sigmaSettings"] = sigmaSettings;
  exports["forceAtlas2Settings"] = forceAtlas2Settings;
  exports["$_EqStage_7"] = $dollar_EqStage_7;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.Array"] = $PS["Gargantext.Utils.Array"] || {};
  var exports = $PS["Gargantext.Utils.Array"];
  var Data_Array = $PS["Data.Array"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];                             
  var min = function (dictOrd) {
      return function (xs) {
          var reducer = function (v) {
              return function (v1) {
                  if (v1 instanceof Data_Maybe.Nothing) {
                      return Data_Maybe.Nothing.value;
                  };
                  if (v1 instanceof Data_Maybe.Just) {
                      return Data_Maybe.Just.create(Data_Ord.min(dictOrd)(v1.value0)(v));
                  };
                  throw new Error("Failed pattern match at Gargantext.Utils.Array (line 27, column 5 - line 27, column 32): " + [ v.constructor.name, v1.constructor.name ]);
              };
          };
          return Data_Foldable.foldr(Data_Foldable.foldableArray)(reducer)(Data_Array.head(xs))(xs);
      };
  };
  var max = function (dictOrd) {
      return function (xs) {
          var reducer = function (v) {
              return function (v1) {
                  if (v1 instanceof Data_Maybe.Nothing) {
                      return Data_Maybe.Nothing.value;
                  };
                  if (v1 instanceof Data_Maybe.Just) {
                      return Data_Maybe.Just.create(Data_Ord.max(dictOrd)(v1.value0)(v));
                  };
                  throw new Error("Failed pattern match at Gargantext.Utils.Array (line 21, column 5 - line 21, column 32): " + [ v.constructor.name, v1.constructor.name ]);
              };
          };
          return Data_Foldable.foldr(Data_Foldable.foldableArray)(reducer)(Data_Array.head(xs))(xs);
      };
  };
  exports["max"] = max;
  exports["min"] = min;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.Utils"] = $PS["Gargantext.Components.GraphExplorer.Utils"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.Utils"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Gargantext_Components_GraphExplorer_Types = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Gargantext_Utils_Array = $PS["Gargantext.Utils.Array"];                
  var stNodeToGET = function (v) {
      return {
          attributes: v["_original"].attributes,
          id_: v.id,
          label: v.label,
          size: v["_original"].size,
          type_: v["_original"].type_,
          x: v.x,
          y: v.y
      };
  };
  var stEdgeToGET = function (v) {
      return v["_original"];
  };
  var normalizeNodes = function (ns) {
      var ys = Data_Functor.map(Data_Functor.functorArray)(function (v) {
          return v.y;
      })(ns);
      var xs = Data_Functor.map(Data_Functor.functorArray)(function (v) {
          return v.x;
      })(ns);
      var mMiny = Gargantext_Utils_Array.min(Data_Ord.ordNumber)(ys);
      var mMinx = Gargantext_Utils_Array.min(Data_Ord.ordNumber)(xs);
      var mMaxy = Gargantext_Utils_Array.max(Data_Ord.ordNumber)(ys);
      var mYrange = Control_Bind.bind(Data_Maybe.bindMaybe)(mMiny)(function (miny) {
          return Control_Bind.bind(Data_Maybe.bindMaybe)(mMaxy)(function (maxy) {
              return Control_Applicative.pure(Data_Maybe.applicativeMaybe)(maxy - miny);
          });
      });
      var ydivisor = (function () {
          if (mYrange instanceof Data_Maybe.Nothing) {
              return 1.0;
          };
          if (mYrange instanceof Data_Maybe.Just) {
              return 1.0 / mYrange.value0;
          };
          throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.Utils (line 46, column 16 - line 48, column 30): " + [ mYrange.constructor.name ]);
      })();
      var mMaxx = Gargantext_Utils_Array.max(Data_Ord.ordNumber)(xs);
      var mXrange = Control_Bind.bind(Data_Maybe.bindMaybe)(mMinx)(function (minx) {
          return Control_Bind.bind(Data_Maybe.bindMaybe)(mMaxx)(function (maxx) {
              return Control_Applicative.pure(Data_Maybe.applicativeMaybe)(maxx - minx);
          });
      });
      var xdivisor = (function () {
          if (mXrange instanceof Data_Maybe.Nothing) {
              return 1.0;
          };
          if (mXrange instanceof Data_Maybe.Just) {
              return 1.0 / mXrange.value0;
          };
          throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.Utils (line 43, column 16 - line 45, column 30): " + [ mXrange.constructor.name ]);
      })();
      var normalizeNode = function (v) {
          return Gargantext_Components_GraphExplorer_Types.Node({
              attributes: v.attributes,
              id_: v.id_,
              label: v.label,
              size: v.size,
              type_: v.type_,
              x: v.x * xdivisor,
              y: v.y * ydivisor
          });
      };
      return Data_Functor.map(Data_Functor.functorArray)(normalizeNode)(ns);
  };
  exports["stEdgeToGET"] = stEdgeToGET;
  exports["stNodeToGET"] = stNodeToGET;
  exports["normalizeNodes"] = normalizeNodes;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.Button"] = $PS["Gargantext.Components.GraphExplorer.Button"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.Button"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Date = $PS["Data.Date"];
  var Data_Date_Component = $PS["Data.Date.Component"];
  var Data_DateTime = $PS["Data.DateTime"];
  var Data_DateTime_Instant = $PS["Data.DateTime.Instant"];
  var Data_Enum = $PS["Data.Enum"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Time = $PS["Data.Time"];
  var Data_Time_Component = $PS["Data.Time.Component"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Effect_Now = $PS["Effect.Now"];
  var Gargantext_Components_Forest_Tree_Node_Action_Upload = $PS["Gargantext.Components.Forest.Tree.Node.Action.Upload"];
  var Gargantext_Components_GraphExplorer_API = $PS["Gargantext.Components.GraphExplorer.API"];
  var Gargantext_Components_GraphExplorer_Types = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Gargantext_Components_GraphExplorer_Utils = $PS["Gargantext.Components.GraphExplorer.Utils"];
  var Gargantext_Hooks_Sigmax = $PS["Gargantext.Hooks.Sigmax"];
  var Gargantext_Hooks_Sigmax_Sigma = $PS["Gargantext.Hooks.Sigmax.Sigma"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.GraphExplorer.Button");
  var simpleButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.button({
                  className: "btn btn-outline-primary",
                  on: {
                      click: v.onClick
                  }
              })([ Gargantext_Utils_Reactix.small({})([ Reactix_DOM_HTML.text(v.text) ]) ]));
          };
      };
      return here.component("simpleButton")(cpt);
  })();
  var simpleButton = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(simpleButtonCpt)(props)([  ]);
  };
  var centerButton = function (sigmaRef) {
      return simpleButton({
          onClick: function (v) {
              var sigma = Reactix_React.readRef(sigmaRef);
              return Gargantext_Hooks_Sigmax.dependOnSigma(sigma)("[centerButton] sigma: Nothing")(function (s) {
                  return Gargantext_Hooks_Sigmax_Sigma.goToAllCameras(s)({
                      x: 0.0,
                      y: 0.0,
                      ratio: 1.0,
                      angle: 0.0
                  });
              });
          },
          text: "Center"
      });
  };
  var cameraButton = function (v) {
      return simpleButton({
          onClick: function (v1) {
              var sigma = Reactix_React.readRef(v.sigmaRef);
              return Gargantext_Hooks_Sigmax.dependOnSigma(sigma)("[cameraButton] sigma: Nothing")(function (s) {
                  return function __do() {
                      var screen = Gargantext_Hooks_Sigmax_Sigma.takeScreenshot(s)();
                      var now = Effect_Now.now();
                      var nowdt = Data_DateTime_Instant.toDateTime(now);
                      var nowt = Data_DateTime.time(nowdt);
                      var nowd = Data_DateTime.date(nowdt);
                      var nowStr = Data_String_Common.joinWith("-")([ Data_Show.show(Data_Show.showInt)(Data_Enum.fromEnum(Data_Date_Component.boundedEnumYear)(Data_Date.year(nowd))), Data_Show.show(Data_Show.showInt)(Data_Enum.fromEnum(Data_Date_Component.boundedEnumMonth)(Data_Date.month(nowd))), Data_Show.show(Data_Show.showInt)(Data_Enum.fromEnum(Data_Date_Component.boundedEnumDay)(Data_Date.day(nowd))), Data_Show.show(Data_Show.showInt)(Data_Enum.fromEnum(Data_Time_Component.boundedEnumHour)(Data_Time.hour(nowt))), Data_Show.show(Data_Show.showInt)(Data_Enum.fromEnum(Data_Time_Component.boundedEnumMinute)(Data_Time.minute(nowt))), Data_Show.show(Data_Show.showInt)(Data_Enum.fromEnum(Data_Time_Component.boundedEnumSecond)(Data_Time.second(nowt))) ]);
                      var edges = Gargantext_Hooks_Sigmax.getEdges(s)();
                      var nodes = Gargantext_Hooks_Sigmax.getNodes(s)();
                      var graphData = Gargantext_Components_GraphExplorer_Types.GraphData({
                          nodes: Gargantext_Components_GraphExplorer_Utils.normalizeNodes(Data_Functor.map(Data_Functor.functorArray)(Gargantext_Components_GraphExplorer_Utils.stNodeToGET)(nodes)),
                          edges: Data_Functor.map(Data_Functor.functorArray)(Gargantext_Components_GraphExplorer_Utils.stEdgeToGET)(edges),
                          sides: v.hyperdataGraph.graph.sides,
                          metaData: v.hyperdataGraph.graph.metaData
                      });
                      var cameras = Data_Functor.map(Data_Functor.functorArray)(Gargantext_Hooks_Sigmax_Sigma.toCamera)(Gargantext_Hooks_Sigmax_Sigma.cameras(s));
                      var camera = (function () {
                          if (cameras.length === 1) {
                              return {
                                  ratio: cameras[0].ratio,
                                  x: cameras[0].x,
                                  y: cameras[0].y
                              };
                          };
                          return {
                              ratio: 1.0,
                              x: 0.0,
                              y: 0.0
                          };
                      })();
                      var hyperdataGraph$prime = {
                          graph: graphData,
                          mCamera: new Data_Maybe.Just(camera)
                      };
                      return Effect_Aff.launchAff_(Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_GraphExplorer_API.cloneGraph({
                          id: v.id,
                          hyperdataGraph: hyperdataGraph$prime,
                          session: v.session
                      }))(function (clonedGraphId) {
                          return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_Forest_Tree_Node_Action_Upload.uploadArbitraryDataURL(v.session)(clonedGraphId)(Data_Maybe.Just.create(nowStr + ("-" + "screenshot.png")))(screen))(function (ret) {
                              return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(v.reloadForest)))(function () {
                                  return Control_Applicative.pure(Effect_Aff.applicativeAff)(ret);
                              });
                          });
                      }))();
                  };
              });
          },
          text: "Screenshot"
      });
  };
  exports["centerButton"] = centerButton;
  exports["cameraButton"] = cameraButton;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.Math"] = $PS["Gargantext.Utils.Math"] || {};
  var exports = $PS["Gargantext.Utils.Math"];
  var $$Math = $PS["Math"];                
  var roundToMultiple = function (eps) {
      return function (num) {
          return eps * $$Math.round(num / eps);
      };
  };
  exports["roundToMultiple"] = roundToMultiple;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.Range"] = $PS["Gargantext.Utils.Range"] || {};
  var exports = $PS["Gargantext.Utils.Range"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Ord = $PS["Data.Ord"];                
  var Range = function (clamp, within) {
      this.clamp = clamp;
      this.within = within;
  };
  var within = function (dict) {
      return dict.within;
  };
  var withMin = function (v) {
      return function (min) {
          return {
              min: min,
              max: v.max
          };
      };
  };
  var withMax = function (v) {
      return function (max) {
          return {
              min: v.min,
              max: max
          };
      };
  };
  var range = function (v) {
      return v.max - v.min;
  };
  var closedProbability = {
      min: 0.0,
      max: 1.0
  };
  var clamp = function (dict) {
      return dict.clamp;
  };
  var $dollar_RangeClosed_10 = function (dictOrd) {
      return new Range(function (v) {
          var $32 = Data_Ord.max(dictOrd)(v.min);
          var $33 = Data_Ord.min(dictOrd)(v.max);
          return function ($34) {
              return $32($33($34));
          };
      }, function (v) {
          return function (v1) {
              return Data_Ord.lessThanOrEq(dictOrd)(v1)(v.max) && Data_Ord.greaterThanOrEq(dictOrd)(v1)(v.min);
          };
      });
  };
  var normalise = function (v) {
      return function (v1) {
          return (clamp($dollar_RangeClosed_10(Data_Ord.ordNumber))(v)(v1) - v.min) / range(v);
      };
  };
  var projectNormal = function (v) {
      return function (v1) {
          return clamp($dollar_RangeClosed_10(Data_Ord.ordNumber))(closedProbability)(v1) * range(v) + v.min;
      };
  }; 
  var $dollar_EqClosed_11 = function (dictEq) {
      return new Data_Eq.Eq(function (v) {
          return function (v1) {
              return Data_Eq.eq(dictEq)(v.min)(v1.min) && Data_Eq.eq(dictEq)(v.max)(v1.max);
          };
      });
  };
  exports["clamp"] = clamp;
  exports["within"] = within;
  exports["normalise"] = normalise;
  exports["projectNormal"] = projectNormal;
  exports["withMin"] = withMin;
  exports["withMax"] = withMax;
  exports["$_RangeClosed_10"] = $dollar_RangeClosed_10;
  exports["$_EqClosed_11"] = $dollar_EqClosed_11;
})(PS);
(function(exports) {
  /* globals exports */
  "use strict";

  exports.readFloat = parseFloat;

  var formatNumber = function (format) {
    return function (fail, succ, digits, n) {
      try {
        return succ(n[format](digits));
      }
      catch (e) {
        return fail(e.message);
      }
    };
  };

  exports._toFixed = formatNumber("toFixed");
})(PS["Global"] = PS["Global"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Global"] = $PS["Global"] || {};
  var exports = $PS["Global"];
  var $foreign = $PS["Global"];
  var Data_Function = $PS["Data.Function"];
  var Data_Maybe = $PS["Data.Maybe"];
  var toFixed = function (digits) {
      return function (n) {
          return $foreign["_toFixed"](Data_Function["const"](Data_Maybe.Nothing.value), Data_Maybe.Just.create, digits, n);
      };
  };
  exports["toFixed"] = toFixed;
  exports["readFloat"] = $foreign.readFloat;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.RangeSlider"] = $PS["Gargantext.Components.RangeSlider"] || {};
  var exports = $PS["Gargantext.Components.RangeSlider"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var DOM_Simple_Document = $PS["DOM.Simple.Document"];
  var DOM_Simple_EventListener = $PS["DOM.Simple.EventListener"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Int = $PS["Data.Int"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ring = $PS["Data.Ring"];
  var Data_Show = $PS["Data.Show"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Gargantext_Utils_Math = $PS["Gargantext.Utils.Math"];
  var Gargantext_Utils_Range = $PS["Gargantext.Utils.Range"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Global = $PS["Global"];
  var $$Math = $PS["Math"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var MinKnob = (function () {
      function MinKnob() {

      };
      MinKnob.value = new MinKnob();
      return MinKnob;
  })();
  var MaxKnob = (function () {
      function MaxKnob() {

      };
      MaxKnob.value = new MaxKnob();
      return MaxKnob;
  })();
  var round = function (epsilon) {
      return function (bounds) {
          var $73 = Gargantext_Utils_Math.roundToMultiple(epsilon);
          var $74 = Gargantext_Utils_Range.clamp(Gargantext_Utils_Range["$_RangeClosed_10"](Data_Ord.ordNumber))(bounds);
          return function ($75) {
              return $73($74($75));
          };
      };
  };
  var roundRange = function (epsilon) {
      return function (bounds) {
          return function (v) {
              var min = round(epsilon)(bounds)(v.min);
              var max = round(epsilon)(bounds)(v.max);
              return {
                  min: min,
                  max: max
              };
          };
      };
  };
  var renderScaleSel = function (ref) {
      return function (props) {
          return function (v) {
              var percOffsetMin = Gargantext_Utils_Range.normalise(props.bounds)(v.min);
              var percOffsetMax = Gargantext_Utils_Range.normalise(props.bounds)(v.max);
              var computeWidth = Data_Show.show(Data_Show.showNumber)(100.0 * (percOffsetMax - percOffsetMin)) + "%";
              var computeLeft = Data_Show.show(Data_Show.showNumber)(100.0 * percOffsetMin) + "%";
              var style = {
                  left: computeLeft,
                  width: computeWidth
              };
              return Reactix_DOM_HTML.div({
                  ref: ref,
                  className: "scale-sel",
                  style: style
              })([  ]);
          };
      };
  };
  var renderScale = function (ref) {
      return function (v) {
          return function (v1) {
              var aria = {
                  label: "Scale running from " + (Data_Show.show(Data_Show.showNumber)(v1.min) + (" to " + Data_Show.show(Data_Show.showNumber)(v1.max)))
              };
              return Reactix_DOM_HTML.div({
                  ref: ref,
                  className: "scale",
                  width: v.width,
                  height: v.height,
                  aria: aria
              })([  ]);
          };
      };
  };
  var renderKnob = function (knob) {
      return function (ref) {
          return function (v) {
              return function (bounds) {
                  return function (set) {
                      return function (precision) {
                          var val = (function () {
                              if (knob instanceof MinKnob) {
                                  return v.min;
                              };
                              if (knob instanceof MaxKnob) {
                                  return v.max;
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.RangeSlider (line 195, column 11 - line 197, column 27): " + [ knob.constructor.name ]);
                          })();
                          var text = function (v1) {
                              if (v1 instanceof Data_Maybe.Just) {
                                  return v1.value0;
                              };
                              if (v1 instanceof Data_Maybe.Nothing) {
                                  return "error";
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.RangeSlider (line 185, column 5 - line 185, column 26): " + [ v1.constructor.name ]);
                          };
                          var percOffset = Gargantext_Utils_Range.normalise(bounds)(val);
                          var style = {
                              left: Data_Show.show(Data_Show.showNumber)(100.0 * percOffset) + "%"
                          };
                          var onMouseDown = function (v1) {
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(new Data_Maybe.Just(knob))(set);
                          };
                          var labelPrefix = function (v1) {
                              if (v1 instanceof MinKnob) {
                                  return "Minimum ";
                              };
                              if (v1 instanceof MaxKnob) {
                                  return "Maximum ";
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.RangeSlider (line 190, column 5 - line 190, column 37): " + [ v1.constructor.name ]);
                          };
                          var aria = {
                              label: labelPrefix(knob) + ("value: " + Data_Show.show(Data_Show.showNumber)(val))
                          };
                          return Reactix_DOM_HTML.div({
                              ref: ref,
                              tabIndex: 0,
                              className: "knob",
                              aria: aria,
                              on: {
                                  mouseDown: onMouseDown
                              },
                              style: style
                          })([ Reactix_DOM_HTML.div({
                              className: "button"
                          })([ Reactix_DOM_HTML.text(text(Global.toFixed(precision)(val))) ]) ]);
                      };
                  };
              };
          };
      };
  };
  var rectRange = function (rect) {
      return {
          min: rect.left,
          max: rect.right
      };
  };
  var reproject = function (drag) {
      return function (scalePos) {
          return function (bounds) {
              return function (epsilon) {
                  return function (v) {
                      return Control_Bind.bind(Data_Maybe.bindMaybe)(drag)(function (drag_) {
                          return Control_Bind.bind(Data_Maybe.bindMaybe)(Data_Functor.map(Data_Maybe.functorMaybe)(rectRange)(scalePos))(function (scale_) {
                              var normal = Gargantext_Utils_Range.normalise(scale_)(Gargantext_Utils_Range.clamp(Gargantext_Utils_Range["$_RangeClosed_10"](Data_Ord.ordNumber))(drag_)(v.x));
                              var val = Gargantext_Utils_Range.projectNormal(bounds)(normal);
                              return Control_Applicative.pure(Data_Maybe.applicativeMaybe)(round(epsilon)(bounds)(val));
                          });
                      });
                  };
              };
          };
      };
  };
  var knobSetter = function (v) {
      if (v instanceof MinKnob) {
          return Gargantext_Utils_Range.withMin;
      };
      if (v instanceof MaxKnob) {
          return Gargantext_Utils_Range.withMax;
      };
      throw new Error("Failed pattern match at Gargantext.Components.RangeSlider (line 141, column 1 - line 141, column 71): " + [ v.constructor.name ]);
  };
  var setKnob = function (knob) {
      return function (value) {
          return function (r) {
              return function (val) {
                  return Toestand_Classes.write_(Toestand_Boxes.writeBox)(knobSetter(knob)(r)(val))(value);
              };
          };
      };
  };
  var initialValue = function (props) {
      return roundRange(props.epsilon)(props.bounds)(props.initialValue);
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.RangeSlider");
  var getDragScale = function (knob) {
      return function (scalePos) {
          return function (lowPos) {
              return function (highPos) {
                  var min = function (v) {
                      return function (v1) {
                          return function (v2) {
                              if (v instanceof MinKnob) {
                                  return v1.left;
                              };
                              if (v instanceof MaxKnob) {
                                  return v2.left;
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.RangeSlider (line 152, column 5 - line 152, column 37): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
                          };
                      };
                  };
                  var max = function (v) {
                      return function (v1) {
                          return function (v2) {
                              if (v instanceof MinKnob) {
                                  return v2.left;
                              };
                              if (v instanceof MaxKnob) {
                                  return v1.right;
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.RangeSlider (line 154, column 5 - line 154, column 35): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
                          };
                      };
                  };
                  return Control_Bind.bind(Data_Maybe.bindMaybe)(scalePos)(function (scale) {
                      return Control_Bind.bind(Data_Maybe.bindMaybe)(lowPos)(function (low) {
                          return Control_Bind.bind(Data_Maybe.bindMaybe)(highPos)(function (high) {
                              return Control_Applicative.pure(Data_Maybe.applicativeMaybe)({
                                  min: min(knob)(scale)(low),
                                  max: max(knob)(scale)(high)
                              });
                          });
                      });
                  });
              };
          };
      };
  };
  var destroyEventHandler = function (dictIsEvent) {
      return function (name) {
          return function (ref) {
              var destroy = function (handler) {
                  return function __do() {
                      DOM_Simple_EventListener.removeEventListener()()(DOM_Simple_Document.document)(name)(handler)();
                      return Reactix_React.setRef(ref)(Data_Maybe.Nothing.value)();
                  };
              };
              return Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Foldable.foldableMaybe)(destroy)(Reactix_React.readRef(ref));
          };
      };
  };
  var $dollar_GenericKnob__22 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof MinKnob) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof MaxKnob) {
          return new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value);
      };
      throw new Error("Failed pattern match at Gargantext.Components.RangeSlider (line 57, column 1 - line 57, column 31): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return MinKnob.value;
      };
      if (x instanceof Data_Generic_Rep.Inr) {
          return MaxKnob.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.RangeSlider (line 57, column 1 - line 57, column 31): " + [ x.constructor.name ]);
  });
  var $dollar_EqKnob_23 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericKnob__22)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))));
  var rangeSliderCpt = (function () {
      var aria = {
          label: "Range Slider Control. Expresses filtering data by a minimum and maximum value range through two slider knobs. Knobs can be adjusted with the arrow keys."
      };
      var cpt = function (props) {
          return function (v) {
              var precision = Data_Maybe.fromMaybe(0)(Data_Int.fromNumber(Data_Ord.max(Data_Ord.ordNumber)(0.0)(Data_Ring.negate(Data_Ring.ringFn(Data_Ring.ringNumber))($$Math.floor)($$Math.log(props.epsilon) / $$Math.ln10))));
              return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (scaleElem) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (scaleSelElem) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (lowElem) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (highElem) {
                              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(initialValue(props)))(function (value) {
                                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Utils_Range["$_EqClosed_11"](Data_Eq.eqNumber)))(value))(function (value$prime) {
                                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Maybe.Nothing.value))(function (dragKnob) {
                                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe($dollar_EqKnob_23)))(dragKnob))(function (dragKnob$prime) {
                                              return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Maybe.Nothing.value))(function (mouseMoveHandler) {
                                                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Maybe.Nothing.value))(function (mouseUpHandler) {
                                                      var destroy = function (v1) {
                                                          return function __do() {
                                                              destroyEventHandler()("mousemove")(mouseMoveHandler)();
                                                              destroyEventHandler()("mouseup")(mouseUpHandler)();
                                                              Reactix_React.setRef(mouseMoveHandler)(Data_Maybe.Nothing.value)();
                                                              return Reactix_React.setRef(mouseUpHandler)(Data_Maybe.Nothing.value)();
                                                          };
                                                      };
                                                      return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Gargantext_Utils_Reactix["useLayoutEffect1'"](dragKnob$prime)(function (v1) {
                                                          var scalePos = Gargantext_Utils_Reactix.readPositionRef(scaleElem);
                                                          var lowPos = Gargantext_Utils_Reactix.readPositionRef(lowElem);
                                                          var highPos = Gargantext_Utils_Reactix.readPositionRef(highElem);
                                                          if (dragKnob$prime instanceof Data_Maybe.Just) {
                                                              var drag = getDragScale(dragKnob$prime.value0)(scalePos)(lowPos)(highPos);
                                                              var onMouseMove = DOM_Simple_EventListener.callback(function (v2) {
                                                                  var v3 = reproject(drag)(scalePos)(props.bounds)(props.epsilon)(Gargantext_Utils_Reactix.domMousePosition(v2));
                                                                  if (v3 instanceof Data_Maybe.Just) {
                                                                      return function __do() {
                                                                          setKnob(dragKnob$prime.value0)(value)(value$prime)(v3.value0)();
                                                                          return props.onChange(knobSetter(dragKnob$prime.value0)(value$prime)(v3.value0))();
                                                                      };
                                                                  };
                                                                  if (v3 instanceof Data_Maybe.Nothing) {
                                                                      return destroy(Data_Unit.unit);
                                                                  };
                                                                  throw new Error("Failed pattern match at Gargantext.Components.RangeSlider (line 105, column 19 - line 109, column 44): " + [ v3.constructor.name ]);
                                                              });
                                                              var onMouseUp = DOM_Simple_EventListener.callback(function (v2) {
                                                                  return function __do() {
                                                                      Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Nothing.value)(dragKnob)();
                                                                      return destroy(Data_Unit.unit)();
                                                                  };
                                                              });
                                                              return function __do() {
                                                                  DOM_Simple_EventListener.addEventListener()()(DOM_Simple_Document.document)("mousemove")(onMouseMove)();
                                                                  DOM_Simple_EventListener.addEventListener()()(DOM_Simple_Document.document)("mouseup")(onMouseUp)();
                                                                  Reactix_React.setRef(mouseMoveHandler)(new Data_Maybe.Just(onMouseMove))();
                                                                  return Reactix_React.setRef(mouseUpHandler)(new Data_Maybe.Just(onMouseUp))();
                                                              };
                                                          };
                                                          if (dragKnob$prime instanceof Data_Maybe.Nothing) {
                                                              return destroy(Data_Unit.unit);
                                                          };
                                                          throw new Error("Failed pattern match at Gargantext.Components.RangeSlider (line 100, column 9 - line 118, column 34): " + [ dragKnob$prime.constructor.name ]);
                                                      }))(function () {
                                                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                                                              className: "range-slider",
                                                              aria: aria
                                                          })([ renderScale(scaleElem)(props)(value$prime), renderScaleSel(scaleSelElem)(props)(value$prime), renderKnob(MinKnob.value)(lowElem)(value$prime)(props.bounds)(dragKnob)(precision), renderKnob(MaxKnob.value)(highElem)(value$prime)(props.bounds)(dragKnob)(precision) ]));
                                                      });
                                                  });
                                              });
                                          });
                                      });
                                  });
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("rangeSlider")(cpt);
  })();
  var rangeSlider = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(rangeSliderCpt)(props)([  ]);
  };
  exports["rangeSlider"] = rangeSlider;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.RangeControl"] = $PS["Gargantext.Components.GraphExplorer.RangeControl"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.RangeControl"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Gargantext_Components_RangeSlider = $PS["Gargantext.Components.RangeSlider"];
  var Gargantext_Utils_Range = $PS["Gargantext.Utils.Range"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.GraphExplorer.RangeControl");
  var rangeControlCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.span({
                  className: "range text-center"
              })([ Reactix_DOM_HTML.label({})([ Gargantext_Utils_Reactix.small({})([ Reactix_DOM_HTML.text(v.caption) ]) ]), Gargantext_Components_RangeSlider.rangeSlider(v.sliderProps) ]));
          };
      };
      return here.component("rangeButton")(cpt);
  })();
  var rangeControl = Reactix_React.createElement(Reactix_React.componentIsComponent)(rangeControlCpt);
  var nodeSizeControlCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Utils_Range["$_EqClosed_11"](Data_Eq.eqNumber)))(v.state))(function (state$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(rangeControl({
                      caption: "Node Size",
                      sliderProps: {
                          bounds: {
                              min: v.range.min,
                              max: v.range.max
                          },
                          initialValue: state$prime,
                          epsilon: 0.1,
                          step: 1.0,
                          width: 10.0,
                          height: 5.0,
                          onChange: function (rng) {
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(rng)(v.state);
                          }
                      }
                  })([  ]));
              });
          };
      };
      return here.component("nodeSizeControl")(cpt);
  })();
  var nodeSizeControl = Reactix_React.createElement(Reactix_React.componentIsComponent)(nodeSizeControlCpt);
  var edgeWeightControlCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Utils_Range["$_EqClosed_11"](Data_Eq.eqNumber)))(v.state))(function (state$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(rangeControl({
                      caption: "Edge Weight",
                      sliderProps: {
                          bounds: {
                              min: v.range.min,
                              max: v.range.max
                          },
                          initialValue: state$prime,
                          epsilon: 1.0,
                          step: 1.0,
                          width: 10.0,
                          height: 5.0,
                          onChange: function (rng) {
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(rng)(v.state);
                          }
                      }
                  })([  ]));
              });
          };
      };
      return here.component("edgeWeightControl")(cpt);
  })();
  var edgeWeightControl = Reactix_React.createElement(Reactix_React.componentIsComponent)(edgeWeightControlCpt);
  var edgeConfluenceControlCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Utils_Range["$_EqClosed_11"](Data_Eq.eqNumber)))(v.state))(function (state$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(rangeControl({
                      caption: "Edge Confluence Weight",
                      sliderProps: {
                          bounds: {
                              min: v.range.min,
                              max: v.range.max
                          },
                          initialValue: state$prime,
                          epsilon: 1.0e-2,
                          step: 1.0,
                          width: 10.0,
                          height: 5.0,
                          onChange: function (rng) {
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(rng)(v.state);
                          }
                      }
                  })([  ]));
              });
          };
      };
      return here.component("edgeConfluenceControl")(cpt);
  })();
  var edgeConfluenceControl = Reactix_React.createElement(Reactix_React.componentIsComponent)(edgeConfluenceControlCpt);
  exports["edgeConfluenceControl"] = edgeConfluenceControl;
  exports["edgeWeightControl"] = edgeWeightControl;
  exports["nodeSizeControl"] = nodeSizeControl;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.SlideButton"] = $PS["Gargantext.Components.GraphExplorer.SlideButton"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.SlideButton"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Show = $PS["Data.Show"];
  var Gargantext_Hooks_Sigmax = $PS["Gargantext.Hooks.Sigmax"];
  var Gargantext_Hooks_Sigmax_Sigma = $PS["Gargantext.Hooks.Sigmax.Sigma"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Global = $PS["Global"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.GraphExplorer.SlideButton");
  var sizeButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqNumber))(v.state))(function (defaultValue) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.span({
                      className: "range-simple"
                  })([ Reactix_DOM_HTML.label({})([ Gargantext_Utils_Reactix.small({})([ Reactix_DOM_HTML.text(v.caption) ]) ]), Reactix_DOM_HTML.input({
                      type: "range",
                      className: "form-control",
                      min: Data_Show.show(Data_Show.showNumber)(v.min),
                      max: Data_Show.show(Data_Show.showNumber)(v.max),
                      defaultValue: defaultValue,
                      on: {
                          input: v.onChange
                      }
                  }) ]));
              });
          };
      };
      return here.component("sizeButton")(cpt);
  })();
  var sizeButton = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(sizeButtonCpt)(props)([  ]);
  };
  var labelSizeButton = function (sigmaRef) {
      return function (state) {
          return sizeButton({
              state: state,
              caption: "Label Size",
              min: 1.0,
              max: 30.0,
              onChange: function (e) {
                  var sigma = Reactix_React.readRef(sigmaRef);
                  var newValue = Global.readFloat(Reactix_SyntheticEvent.unsafeEventValue(e));
                  return function __do() {
                      Gargantext_Hooks_Sigmax.dependOnSigma(sigma)("[labelSizeButton] sigma: Nothing")(function (s) {
                          return Gargantext_Hooks_Sigmax_Sigma.setSettings(s)({
                              defaultLabelSize: newValue,
                              drawLabels: true,
                              maxNodeSize: newValue / 2.5
                          });
                      })();
                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(newValue)(state)();
                  };
              }
          });
      };
  };
  var mouseSelectorSizeButton = function (sigmaRef) {
      return function (state) {
          return sizeButton({
              state: state,
              caption: "Selector Size",
              min: 1.0,
              max: 50.0,
              onChange: function (e) {
                  var sigma = Reactix_React.readRef(sigmaRef);
                  var newValue = Global.readFloat(Reactix_SyntheticEvent.unsafeEventValue(e));
                  return function __do() {
                      Gargantext_Hooks_Sigmax.dependOnSigma(sigma)("[mouseSelectorSizeButton] sigma: Nothing")(function (s) {
                          return Gargantext_Hooks_Sigmax_Sigma.setSettings(s)({
                              mouseSelectorSize: newValue
                          });
                      })();
                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(newValue)(state)();
                  };
              }
          });
      };
  };
  exports["labelSizeButton"] = labelSizeButton;
  exports["mouseSelectorSizeButton"] = mouseSelectorSizeButton;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.ToggleButton"] = $PS["Gargantext.Components.GraphExplorer.ToggleButton"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.ToggleButton"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Gargantext_Components_Graph = $PS["Gargantext.Components.Graph"];
  var Gargantext_Hooks_Sigmax = $PS["Gargantext.Hooks.Sigmax"];
  var Gargantext_Hooks_Sigmax_Sigma = $PS["Gargantext.Hooks.Sigmax.Sigma"];
  var Gargantext_Hooks_Sigmax_Types = $PS["Gargantext.Hooks.Sigmax.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.GraphExplorer.ToggleButton");
  var pauseForceAtlasButtonCpt = (function () {
      var text = function (v) {
          if (v instanceof Gargantext_Hooks_Sigmax_Types.InitialRunning) {
              return "Pause Force Atlas";
          };
          if (v instanceof Gargantext_Hooks_Sigmax_Types.InitialStopped) {
              return "Start Force Atlas";
          };
          if (v instanceof Gargantext_Hooks_Sigmax_Types.Running) {
              return "Pause Force Atlas";
          };
          if (v instanceof Gargantext_Hooks_Sigmax_Types.Paused) {
              return "Start Force Atlas";
          };
          if (v instanceof Gargantext_Hooks_Sigmax_Types.Killed) {
              return "Start Force Atlas";
          };
          throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.ToggleButton (line 158, column 5 - line 158, column 58): " + [ v.constructor.name ]);
      };
      var onClick = function (state) {
          return function (v) {
              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Gargantext_Hooks_Sigmax_Types.toggleForceAtlasState)(state);
          };
      };
      var cls = function (v) {
          if (v instanceof Gargantext_Hooks_Sigmax_Types.InitialRunning) {
              return "active";
          };
          if (v instanceof Gargantext_Hooks_Sigmax_Types.Running) {
              return "active";
          };
          return "";
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Hooks_Sigmax_Types["$_EqForceAtlasState_34"]))(v.state))(function (state$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.button({
                      className: "btn btn-outline-primary " + cls(state$prime),
                      on: {
                          click: onClick(v.state)
                      }
                  })([ Gargantext_Utils_Reactix.small({})([ Reactix_DOM_HTML.text(text(state$prime)) ]) ]));
              });
          };
      };
      return here.component("forceAtlasToggleButton")(cpt);
  })();
  var pauseForceAtlasButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(pauseForceAtlasButtonCpt);
  var resetForceAtlasButtonCpt = (function () {
      var onClick = function (forceAtlasState) {
          return function (sigmaRef) {
              return function (v) {
                  return Gargantext_Hooks_Sigmax.dependOnSigma(Reactix_React.readRef(sigmaRef))("[resetForceAtlasButton] no sigma")(function (sigma) {
                      return function __do() {
                          Gargantext_Hooks_Sigmax_Sigma.killForceAtlas2(sigma)();
                          Gargantext_Hooks_Sigmax_Sigma.refreshForceAtlas(sigma)(Gargantext_Components_Graph.forceAtlas2Settings)();
                          return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Hooks_Sigmax_Types.Killed.value)(forceAtlasState)();
                      };
                  });
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.button({
                  className: "btn btn-outline-primary",
                  on: {
                      click: onClick(v.forceAtlasState)(v.sigmaRef)
                  }
              })([ Gargantext_Utils_Reactix.small({})([ Reactix_DOM_HTML.text("Reset Force Atlas") ]) ]));
          };
      };
      return here.component("resetForceAtlasToggleButton")(cpt);
  })();
  var resetForceAtlasButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(resetForceAtlasButtonCpt);
  var sidebarToggleButtonCpt = (function () {
      var text = function (v) {
          return function (v1) {
              return function (v2) {
                  if (v2 instanceof Gargantext_Types.Opened) {
                      return v;
                  };
                  if (v2 instanceof Gargantext_Types.InitialClosed) {
                      return v1;
                  };
                  if (v2 instanceof Gargantext_Types.Closed) {
                      return v1;
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.ToggleButton (line 228, column 5 - line 228, column 39): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
              };
          };
      };
      var onClick = function (state) {
          return function (v) {
              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Gargantext_Types.toggleSidePanelState)(state);
          };
      };
      var cls = function (v) {
          if (v instanceof Gargantext_Types.Opened) {
              return "active";
          };
          return "";
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqSidePanelState_180"]))(v.state))(function (state$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "btn btn-outline-light " + cls(state$prime),
                      on: {
                          click: onClick(v.state)
                      }
                  })([ Gargantext_Utils_Reactix.small({})([ Reactix_DOM_HTML.text(text("Hide Sidebar")("Show Sidebar")(state$prime)) ]) ]));
              });
          };
      };
      return here.component("sidebarToggleButton")(cpt);
  })();
  var sidebarToggleButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(sidebarToggleButtonCpt);
  var toggleButtonCpt = (function () {
      var text = function (v) {
          return function (v1) {
              return function (v2) {
                  if (v2) {
                      return v;
                  };
                  if (!v2) {
                      return v1;
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.ToggleButton (line 57, column 5 - line 57, column 27): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
              };
          };
      };
      var cls = function (v) {
          if (v) {
              return "active";
          };
          if (!v) {
              return "";
          };
          throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.ToggleButton (line 55, column 5 - line 55, column 24): " + [ v.constructor.name ]);
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.state))(function (state$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "btn btn-outline-" + (v.style + (" " + (cls(state$prime) + " mx-2"))),
                      on: {
                          click: v.onClick
                      }
                  })([ Gargantext_Utils_Reactix.small({})([ Reactix_DOM_HTML.text(text(v.onMessage)(v.offMessage)(state$prime)) ]) ]));
              });
          };
      };
      return here.component("toggleButton")(cpt);
  })();
  var toggleButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(toggleButtonCpt);
  var louvainToggleButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(toggleButton({
                  state: v.state,
                  onMessage: "Louvain off",
                  offMessage: "Louvain on",
                  onClick: function (v2) {
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(v.state);
                  },
                  style: "primary"
              })([  ]));
          };
      };
      return here.component("louvainToggleButton")(cpt);
  })();
  var louvainToggleButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(louvainToggleButtonCpt);
  var multiSelectEnabledButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(toggleButton({
                  state: v.state,
                  onMessage: "Single-node",
                  offMessage: "Multi-node",
                  onClick: function (v2) {
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(v.state);
                  },
                  style: "primary"
              })([  ]));
          };
      };
      return here.component("lmultiSelectEnabledButton")(cpt);
  })();
  var multiSelectEnabledButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(multiSelectEnabledButtonCpt);
  var treeToggleButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(toggleButton({
                  state: v.state,
                  onMessage: "Hide Tree",
                  offMessage: "Show Tree",
                  onClick: function (v2) {
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(v.state);
                  },
                  style: "light"
              })([  ]));
          };
      };
      return here.component("treeToggleButton")(cpt);
  })();
  var treeToggleButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(treeToggleButtonCpt);
  var edgesToggleButtonCpt = (function () {
      var text = function (s) {
          var $73 = Gargantext_Hooks_Sigmax_Types.edgeStateHidden(s);
          if ($73) {
              return "Show edges";
          };
          return "Hide edges";
      };
      var onClick = function (state) {
          return function (v) {
              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Gargantext_Hooks_Sigmax_Types.toggleShowEdgesState)(state);
          };
      };
      var cls = function (v) {
          if (v instanceof Gargantext_Hooks_Sigmax_Types.EShow) {
              return "";
          };
          return "active";
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Hooks_Sigmax_Types["$_EqShowEdgesState_36"]))(v.state))(function (state$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.button({
                      className: "btn btn-outline-primary " + cls(state$prime),
                      on: {
                          click: onClick(v.state)
                      }
                  })([ Gargantext_Utils_Reactix.small({})([ Reactix_DOM_HTML.text(text(state$prime)) ]) ]));
              });
          };
      };
      return here.component("edgesToggleButton")(cpt);
  })();
  var edgesToggleButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(edgesToggleButtonCpt);
  var controlsToggleButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(toggleButton({
                  state: v.state,
                  onMessage: "Hide Controls",
                  offMessage: "Show Controls",
                  onClick: function (v2) {
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(v.state);
                  },
                  style: "light"
              })([  ]));
          };
      };
      return here.component("controlsToggleButton")(cpt);
  })();
  var controlsToggleButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(controlsToggleButtonCpt);
  exports["controlsToggleButton"] = controlsToggleButton;
  exports["edgesToggleButton"] = edgesToggleButton;
  exports["louvainToggleButton"] = louvainToggleButton;
  exports["multiSelectEnabledButton"] = multiSelectEnabledButton;
  exports["sidebarToggleButton"] = sidebarToggleButton;
  exports["pauseForceAtlasButton"] = pauseForceAtlasButton;
  exports["resetForceAtlasButton"] = resetForceAtlasButton;
  exports["treeToggleButton"] = treeToggleButton;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.Controls"] = $PS["Gargantext.Components.GraphExplorer.Controls"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.Controls"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Int = $PS["Data.Int"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Set = $PS["Data.Set"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Timer = $PS["Effect.Timer"];
  var Gargantext_Components_Graph = $PS["Gargantext.Components.Graph"];
  var Gargantext_Components_GraphExplorer_Button = $PS["Gargantext.Components.GraphExplorer.Button"];
  var Gargantext_Components_GraphExplorer_RangeControl = $PS["Gargantext.Components.GraphExplorer.RangeControl"];
  var Gargantext_Components_GraphExplorer_Sidebar_Types = $PS["Gargantext.Components.GraphExplorer.Sidebar.Types"];
  var Gargantext_Components_GraphExplorer_SlideButton = $PS["Gargantext.Components.GraphExplorer.SlideButton"];
  var Gargantext_Components_GraphExplorer_ToggleButton = $PS["Gargantext.Components.GraphExplorer.ToggleButton"];
  var Gargantext_Components_GraphExplorer_Types = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Gargantext_Hooks_Sigmax = $PS["Gargantext.Hooks.Sigmax"];
  var Gargantext_Hooks_Sigmax_Types = $PS["Gargantext.Hooks.Sigmax.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var useGraphControls = function (v) {
      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox({
          min: 0.0,
          max: 1.0
      }))(function (edgeConfluence) {
          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox({
              min: 0.0,
              max: Data_Int.toNumber(Data_Sequence.length(Gargantext_Hooks_Sigmax_Types.graphEdges(v.graph)))
          }))(function (edgeWeight) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(v.forceAtlasS))(function (forceAtlasState) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_Graph.Init.value))(function (graphStage) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox({
                          min: 0.0,
                          max: 100.0
                      }))(function (nodeSize) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Hooks_Sigmax_Types.EShow.value))(function (showEdges) {
                              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(false))(function (showLouvain) {
                                  return Control_Bind.bind(Reactix_React.bindHooks)(Gargantext_Hooks_Sigmax.initSigma)(function (sigma) {
                                      return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(sigma))(function (sigmaRef) {
                                          return Control_Bind.bind(Reactix_React.bindHooks)(Gargantext_Components_GraphExplorer_Sidebar_Types.focusedSidePanel(v.sidePanel))(function (v1) {
                                              return Control_Applicative.pure(Reactix_React.applicativeHooks)({
                                                  edgeConfluence: edgeConfluence,
                                                  edgeWeight: edgeWeight,
                                                  forceAtlasState: forceAtlasState,
                                                  graph: v.graph,
                                                  graphId: v.graphId,
                                                  graphStage: graphStage,
                                                  hyperdataGraph: v.hyperdataGraph,
                                                  multiSelectEnabled: v1.multiSelectEnabled,
                                                  nodeSize: nodeSize,
                                                  removedNodeIds: v1.removedNodeIds,
                                                  selectedNodeIds: v1.selectedNodeIds,
                                                  session: v.session,
                                                  showControls: v1.showControls,
                                                  showEdges: showEdges,
                                                  showLouvain: showLouvain,
                                                  sidePanelState: v.sidePanelState,
                                                  showTree: v.showTree,
                                                  sideTab: v1.sideTab,
                                                  sigmaRef: sigmaRef,
                                                  reloadForest: v.reloadForest
                                              });
                                          });
                                      });
                                  });
                              });
                          });
                      });
                  });
              });
          });
      });
  };
  var initialLocalControls = Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(14.0))(function (labelSize) {
      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(15.0))(function (mouseSelectorSize) {
          return Control_Applicative.pure(Reactix_React.applicativeHooks)({
              labelSize: labelSize,
              mouseSelectorSize: mouseSelectorSize
          });
      });
  });
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.GraphExplorer.Controls");
  var controlsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var navItem = Reactix_DOM_HTML.li({
                  className: "nav-item"
              });
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Hooks_Sigmax_Types["$_EqForceAtlasState_34"]))(v.forceAtlasState))(function (forceAtlasState$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Graph["$_EqStage_7"]))(v.graphStage))(function (graphStage$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Set.eqSet(Data_Eq.eqString)))(v.selectedNodeIds))(function (selectedNodeIds$prime) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.showControls))(function (showControls$prime) {
                              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqSidePanelState_180"]))(v.sidePanelState))(function (sidePanelState$prime) {
                                  return Control_Bind.bind(Reactix_React.bindHooks)(initialLocalControls)(function (localControls) {
                                      return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Maybe.Nothing.value))(function (mFAPauseRef) {
                                          return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect'"]((function () {
                                              if (graphStage$prime instanceof Gargantext_Components_Graph.Init) {
                                                  return Reactix_React.setRef(mFAPauseRef)(Data_Maybe.Nothing.value);
                                              };
                                              return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                                          })()))(function () {
                                              return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect'"](Gargantext_Hooks_Sigmax.handleForceAtlas2Pause(v.sigmaRef)(v.forceAtlasState)(mFAPauseRef)(Gargantext_Components_Graph.forceAtlas2Settings)))(function () {
                                                  return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect'"]((function () {
                                                      var $29 = Data_Eq.eq(Gargantext_Types["$_EqSidePanelState_180"])(sidePanelState$prime)(Gargantext_Types.InitialClosed.value) && Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraFunction(Data_HeytingAlgebra.heytingAlgebraBoolean))(Data_Set.isEmpty)(selectedNodeIds$prime);
                                                      if ($29) {
                                                          return function __do() {
                                                              Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Types.Opened.value)(v.sidePanelState)();
                                                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Components_GraphExplorer_Types.SideTabData.value)(v.sideTab)();
                                                          };
                                                      };
                                                      return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                                                  })()))(function () {
                                                      return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect1'"](forceAtlasState$prime)((function () {
                                                          var $30 = Data_Eq.eq(Gargantext_Hooks_Sigmax_Types["$_EqForceAtlasState_34"])(forceAtlasState$prime)(Gargantext_Hooks_Sigmax_Types.InitialRunning.value);
                                                          if ($30) {
                                                              return function __do() {
                                                                  var timeoutId = Effect_Timer.setTimeout(9000)(function __do() {
                                                                      (function () {
                                                                          if (forceAtlasState$prime instanceof Gargantext_Hooks_Sigmax_Types.InitialRunning) {
                                                                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Hooks_Sigmax_Types.Paused.value)(v.forceAtlasState)();
                                                                          };
                                                                          return Data_Unit.unit;
                                                                      })();
                                                                      return Reactix_React.setRef(mFAPauseRef)(Data_Maybe.Nothing.value)();
                                                                  })();
                                                                  Reactix_React.setRef(mFAPauseRef)(new Data_Maybe.Just(timeoutId))();
                                                                  return Data_Unit.unit;
                                                              };
                                                          };
                                                          return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                                                      })()))(function () {
                                                          var edgesConfluenceSorted = Data_Array.sortWith(Data_Ord.ordNumber)(function (v2) {
                                                              return v2.confluence;
                                                          })(Data_Sequence.toUnfoldable(Data_Functor.functorArray)(Data_Unfoldable.unfoldableArray)(Gargantext_Hooks_Sigmax_Types.graphEdges(v.graph)));
                                                          var edgeConfluenceMin = Data_Maybe.maybe(0.0)(function (v2) {
                                                              return v2.confluence;
                                                          })(Data_Array.head(edgesConfluenceSorted));
                                                          var edgeConfluenceMax = Data_Maybe.maybe(100.0)(function (v2) {
                                                              return v2.confluence;
                                                          })(Data_Array.last(edgesConfluenceSorted));
                                                          var edgeConfluenceRange = {
                                                              min: edgeConfluenceMin,
                                                              max: edgeConfluenceMax
                                                          };
                                                          var edgeWeightRange = {
                                                              min: 0.0,
                                                              max: Data_Int.toNumber(Data_Sequence.length(Gargantext_Hooks_Sigmax_Types.graphEdges(v.graph)))
                                                          };
                                                          var nodesSorted = Data_Array.sortWith(Data_Ord.ordNumber)(function (v2) {
                                                              return v2.size;
                                                          })(Data_Sequence.toUnfoldable(Data_Functor.functorArray)(Data_Unfoldable.unfoldableArray)(Gargantext_Hooks_Sigmax_Types.graphNodes(v.graph)));
                                                          var nodeSizeMin = Data_Maybe.maybe(0.0)(function (v2) {
                                                              return v2.size;
                                                          })(Data_Array.head(nodesSorted));
                                                          var nodeSizeMax = Data_Maybe.maybe(100.0)(function (v2) {
                                                              return v2.size;
                                                          })(Data_Array.last(nodesSorted));
                                                          var nodeSizeRange = {
                                                              min: nodeSizeMin,
                                                              max: nodeSizeMax
                                                          };
                                                          var className = "navbar navbar-expand-lg " + (function () {
                                                              if (showControls$prime) {
                                                                  return "";
                                                              };
                                                              return "d-none";
                                                          })();
                                                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.nav({
                                                              className: className
                                                          })([ Reactix_DOM_HTML.ul({
                                                              className: "navbar-nav mx-auto"
                                                          })([ navItem([ Gargantext_Components_GraphExplorer_Button.centerButton(v.sigmaRef) ]), navItem([ Gargantext_Components_GraphExplorer_ToggleButton.resetForceAtlasButton({
                                                              forceAtlasState: v.forceAtlasState,
                                                              sigmaRef: v.sigmaRef
                                                          })([  ]) ]), navItem([ Gargantext_Components_GraphExplorer_ToggleButton.pauseForceAtlasButton({
                                                              state: v.forceAtlasState
                                                          })([  ]) ]), navItem([ Gargantext_Components_GraphExplorer_ToggleButton.edgesToggleButton({
                                                              state: v.showEdges
                                                          })([  ]) ]), navItem([ Gargantext_Components_GraphExplorer_ToggleButton.louvainToggleButton({
                                                              state: v.showLouvain
                                                          })([  ]) ]), navItem([ Gargantext_Components_GraphExplorer_RangeControl.edgeConfluenceControl({
                                                              range: edgeConfluenceRange,
                                                              state: v.edgeConfluence
                                                          })([  ]) ]), navItem([ Gargantext_Components_GraphExplorer_RangeControl.edgeWeightControl({
                                                              range: edgeWeightRange,
                                                              state: v.edgeWeight
                                                          })([  ]) ]), navItem([ Gargantext_Components_GraphExplorer_SlideButton.labelSizeButton(v.sigmaRef)(localControls.labelSize) ]), navItem([ Gargantext_Components_GraphExplorer_RangeControl.nodeSizeControl({
                                                              range: nodeSizeRange,
                                                              state: v.nodeSize
                                                          })([  ]) ]), navItem([ Gargantext_Components_GraphExplorer_ToggleButton.multiSelectEnabledButton({
                                                              state: v.multiSelectEnabled
                                                          })([  ]) ]), navItem([ Gargantext_Components_GraphExplorer_SlideButton.mouseSelectorSizeButton(v.sigmaRef)(localControls.mouseSelectorSize) ]), navItem([ Gargantext_Components_GraphExplorer_Button.cameraButton({
                                                              id: v.graphId,
                                                              hyperdataGraph: v.hyperdataGraph,
                                                              session: v.session,
                                                              sigmaRef: v.sigmaRef,
                                                              reloadForest: v.reloadForest
                                                          }) ]) ]) ]));
                                                      });
                                                  });
                                              });
                                          });
                                      });
                                  });
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("controls")(cpt);
  })();
  var controls = Reactix_React.createElement(Reactix_React.componentIsComponent)(controlsCpt);
  exports["useGraphControls"] = useGraphControls;
  exports["controls"] = controls;
})(PS);
(function(exports) {
  /* 
Author: Corneliu S. (github.com/upphiminn)

This is a javascript implementation of the Louvain 
community detection algorithm (http://arxiv.org/abs/0803.0476)
Based on https://bitbucket.org/taynaud/python-louvain/overview 

*/  
  exports._jLouvain = (function(){
	  return function(){
		  //Constants
		  var __PASS_MAX = -1
		  var __MIN 	 = 0.0000001

		  //Local vars
		  var original_graph_nodes;
		  var original_graph_edges;
		  var original_graph = {};
		  var partition_init;

		  //Helpers
		  function make_set(array){
			  var set = {};
			  array.forEach(function(d,i){
				  set[d] = true;
			  });
			  return Object.keys(set);
		  };

		  function obj_values(obj){
			  return Object.values(obj);
			  /*
			 var vals = [];
			 for( var key in obj ) {
			     if ( obj.hasOwnProperty(key) ) {
			         vals.push(obj[key]);
			     }
			 }
			 return vals;
			*/  
		  };

		  function get_degree_for_node(graph, node){
			  var neighbours = get_neighbours_of_node(graph, node);
			  var weight = 0;
			  neighbours.forEach(function(neighbour,i){
				  var value = graph._assoc_mat[node][neighbour] || 1;
				  if(node == neighbour)
					  value *= 2;
				  weight += value;
			  });
			  return weight;
		  };
		
		  function get_neighbours_of_node(graph, node){
			  if(typeof graph._assoc_mat[node] == 'undefined')
				  return [];

			  return Object.keys(graph._assoc_mat[node]);
		  }
		
		
		  function get_edge_weight(graph, node1, node2){
			  return graph._assoc_mat[node1] ? graph._assoc_mat[node1][node2] : undefined;
		  }

		  function get_graph_size(graph){
			  var size = 0;
			  graph.edges.forEach(function(edge){
				  size += edge.weight;
			  });
			  return size;
		  }

		  function add_edge_to_graph(graph, edge){
			  update_assoc_mat(graph, edge);

			  var edge_index = graph.edges.map(function(d){
				  return d.source+'_'+d.target;
			  }).indexOf(edge.source+'_'+edge.target);

			  if(edge_index != -1)
				  graph.edges[edge_index].weight = edge.weight;
			  else
				  graph.edges.push(edge);
		  }

		  function make_assoc_mat(edge_list){
			  var mat = {};
			  edge_list.forEach(function(edge, i){
				  mat[edge.source] = mat[edge.source] || {};
				  mat[edge.source][edge.target] = edge.weight;
				  mat[edge.target] = mat[edge.target] || {};
				  mat[edge.target][edge.source] = edge.weight;
			  });

			  return mat;
		  }

		  function update_assoc_mat(graph, edge){
			  graph._assoc_mat[edge.source] = graph._assoc_mat[edge.source] || {};
			  graph._assoc_mat[edge.source][edge.target] = edge.weight;
			  graph._assoc_mat[edge.target] = graph._assoc_mat[edge.target] || {};
			  graph._assoc_mat[edge.target][edge.source] = edge.weight;
		  }

		  function clone(obj){
		      if(obj == null || typeof(obj) != 'object')
		          return obj;

		      var temp = obj.constructor();

		      for(var key in obj)
		          temp[key] = clone(obj[key]);
		      return temp;
		  }

		  //Core-Algorithm Related 
		  function init_status(graph, status, part){
			  status['nodes_to_com'] = {};
			  status['total_weight'] = 0;
			  status['internals'] = {};
			  status['degrees'] = {};
			  status['gdegrees'] = {};
			  status['loops'] = {};
			  status['total_weight'] = get_graph_size(graph);

			  if(typeof part == 'undefined'){
				  graph.nodes.forEach(function(node,i){
					  status.nodes_to_com[node] = i;
					  var deg = get_degree_for_node(graph, node);
					  if (deg < 0)
						  throw 'Bad graph type, use positive weights!';
					  status.degrees[i] = deg;
					  status.gdegrees[node] = deg;
					  status.loops[node] = get_edge_weight(graph, node, node) || 0;
					  status.internals[i] = status.loops[node];
				  });
			  }else{
				  graph.nodes.forEach(function(node,i){
					  var com = part[node];
					  status.nodes_to_com[node] = com;
					  var deg = get_degree_for_node(graph, node);
					  status.degrees[com] = (status.degrees[com] || 0) + deg;
					  status.gdegrees[node] = deg;
					  var inc = 0.0;

					  var neighbours  = get_neighbours_of_node(graph, node);
					  neighbours.forEach(function(neighbour, i){
						  var weight = graph._assoc_mat[node][neighbour];
						  if (weight <= 0){
							  throw "Bad graph type, use positive weights";
						  }

						  if(part[neighbour] == com){
							  if (neighbour == node){
								  inc += weight;
							  }else{
								  inc += weight/2.0;
							  }
						  }
					  });
					  status.internals[com] = (status.internals[com] || 0) + inc;
				  });
			  }
		  }

		  function __modularity(status){
			  var links = status.total_weight;
			  var result = 0.0;
			  var communities = make_set(obj_values(status.nodes_to_com));

			  communities.forEach(function(com,i){
				  var in_degree = status.internals[com] || 0 ;
				  var degree = status.degrees[com] || 0 ;
				  if(links > 0){
					  result = result + in_degree / links - Math.pow((degree / (2.0*links)), 2);
				  }
			  });
			  return result;
		  }

		  function __neighcom(node, graph, status){
			  // compute the communities in the neighb. of the node, with the graph given by
			  // node_to_com

			  var weights = {};
			  var neighboorhood = get_neighbours_of_node(graph, node);//make iterable;
			
			  neighboorhood.forEach(function(neighbour, i){
				  if(neighbour != node){
					  var weight = graph._assoc_mat[node][neighbour] || 1; 
					  var neighbourcom = status.nodes_to_com[neighbour];
					  weights[neighbourcom] = (weights[neighbourcom] || 0) + weight;
				  }	
			  });

			  return weights;
		  }

		  function __insert(node, com, weight, status){
			  //insert node into com and modify status
			  status.nodes_to_com[node] = +com;
			  status.degrees[com] = (status.degrees[com] || 0) + (status.gdegrees[node]||0);
			  status.internals[com] = (status.internals[com] || 0) + weight + (status.loops[node]||0);
		  }

		  function __remove(node, com, weight, status){
			  //remove node from com and modify status
			  status.degrees[com] = ((status.degrees[com] || 0) - (status.gdegrees[node] || 0));
			  status.internals[com] = ((status.internals[com] || 0) - weight -(status.loops[node] ||0));
			  status.nodes_to_com[node] = -1;
		  }

		  function __renumber(dict){
			  var count = 0;
			  var ret = clone(dict); //deep copy :) 
			  var new_values = {};
			  var dict_keys = Object.keys(dict);
			  dict_keys.forEach(function(key){
				  var value = dict[key];
				  var new_value =  typeof new_values[value] =='undefined' ? -1 : new_values[value];
				  if(new_value == -1){
					  new_values[value] = count;
					  new_value = count;
					  count = count + 1;
				  }
				  ret[key] = new_value;
			  });
			  return ret;
		  }

		  function __one_level(graph, status){
			  //Compute one level of the Communities Dendogram.
			  var modif = true,
				  nb_pass_done = 0,
				  cur_mod = __modularity(status),
				  new_mod = cur_mod;

			  while (modif && nb_pass_done != __PASS_MAX){
				  cur_mod = new_mod;
				  modif = false;
				  nb_pass_done += 1

				  graph.nodes.forEach(function(node,i){
					  var com_node = status.nodes_to_com[node];
					  var degc_totw = (status.gdegrees[node] || 0) / (status.total_weight * 2.0);
					  var neigh_communities = __neighcom(node, graph, status);
					  __remove(node, com_node, (neigh_communities[com_node] || 0.0), status);
					  var best_com = com_node;
					  var best_increase = 0;
					  var neigh_communities_entries = Object.keys(neigh_communities);//make iterable;

					  neigh_communities_entries.forEach(function(com,i){
						  var incr = neigh_communities[com] - (status.degrees[com] || 0.0) * degc_totw;
						  if (incr > best_increase){
							  best_increase = incr;
							  best_com = com;
						  }
					  });	

					  __insert(node, best_com, neigh_communities[best_com] || 0, status);

					  if(best_com != com_node)
						  modif = true;
				  });
				  new_mod = __modularity(status);
				  if(new_mod - cur_mod < __MIN)
					  break;
			  }
		  }

		  function induced_graph(partition, graph){
			  var ret = {nodes:[], edges:[], _assoc_mat: {}};
			  var w_prec, weight;
			  //add nodes from partition values
			  var partition_values = obj_values(partition);
			  ret.nodes = ret.nodes.concat(make_set(partition_values)); //make set
			  graph.edges.forEach(function(edge,i){
				  weight = edge.weight || 1;
				  var com1 = partition[edge.source];
				  var com2 = partition[edge.target];
				  w_prec = (get_edge_weight(ret, com1, com2) || 0); 
				  var new_weight = (w_prec + weight);
				  add_edge_to_graph(ret, {'source': com1, 'target': com2, 'weight': new_weight});
			  });
			  return ret;
		  }

		  function partition_at_level(dendogram, level){
			  var partition = clone(dendogram[0]);
			  for(var i = 1; i < level + 1; i++ )
				  Object.keys(partition).forEach(function(key,j){
					  var node = key;
					  var com  = partition[key];
					  partition[node] = dendogram[i][com];
				  });
			  return partition;
		  }


		  function generate_dendogram(graph, part_init){
			
			  if(graph.edges.length == 0){
				  var part = {};
				  graph.nodes.forEach(function(node,i){
					  part[node] = node;
				  });
				  return part;
			  }
			  var status = {};

			  init_status(original_graph, status, part_init);
			  var mod = __modularity(status);
			  var status_list = [];
			  __one_level(original_graph, status);
			  var new_mod = __modularity(status);
			  var partition = __renumber(status.nodes_to_com);
			  status_list.push(partition);
			  mod = new_mod;
			  var current_graph = induced_graph(partition, original_graph);
			  init_status(current_graph, status);

			  while (true){
				  __one_level(current_graph, status);
				  new_mod = __modularity(status);
				  if(new_mod - mod < __MIN)
					  break;

				  partition = __renumber(status.nodes_to_com);
				  status_list.push(partition); 

				  mod = new_mod;
				  current_graph = induced_graph(partition, current_graph);
				  init_status(current_graph, status);
			  }

			  return status_list; 
		  }

		  var core = function(){
			  var status = {};
			  var dendogram = generate_dendogram(original_graph, partition_init);
			  return partition_at_level(dendogram, dendogram.length - 1);
		  };

		  core.nodes = function(nds){
			  if(arguments.length > 0){
				  original_graph_nodes = nds;
				  return core;
			  } else {
				  return original_graph_nodes;
			  }
		  };

		  core.edges = function(edgs){
			  if(typeof original_graph_nodes == 'undefined')
				  throw 'Please provide the graph nodes first!';

			  if(arguments.length > 0){
				  original_graph_edges = edgs;
				  var assoc_mat = make_assoc_mat(edgs);
				  original_graph = { 'nodes': original_graph_nodes,
						  		   'edges': original_graph_edges,
						  		   '_assoc_mat': assoc_mat };
				  return core;
			  } else {
				  return original_graph_edges;
			  }

		  };

		  core.partition_init = function(prttn){
			  if(arguments.length > 0){
				  partition_init = prttn;
			  }
			  return core;
		  };

		  return core;
	  }
  })();

  exports._init = function(louvain, nodes, edges) {
	  return Object.entries(louvain.nodes(nodes).edges(edges)());
  }
})(PS["Gargantext.Data.Louvain"] = PS["Gargantext.Data.Louvain"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Data.Louvain"] = $PS["Gargantext.Data.Louvain"] || {};
  var exports = $PS["Gargantext.Data.Louvain"];
  var $foreign = $PS["Gargantext.Data.Louvain"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Tuple_Native = $PS["Data.Tuple.Native"];
  var Data_Typelevel_Num_Reps = $PS["Data.Typelevel.Num.Reps"];
  var Data_Typelevel_Num_Sets = $PS["Data.Typelevel.Num.Sets"];                
  var louvain = function (unit) {
      return $foreign["_jLouvain"](unit);
  };
  var init = function (l) {
      return function (nds) {
          return function (edgs) {
              var clusterArr = $foreign["_init"](l, nds, edgs);
              var clusterTuples = Data_Functor.map(Data_Functor.functorArray)(function (t2) {
                  return new Data_Tuple.Tuple(Data_Tuple_Native.prj()()()()()(Data_Typelevel_Num_Sets.natD0)(Data_Typelevel_Num_Reps.d0)(t2), Data_Tuple_Native.prj()()()()()(Data_Typelevel_Num_Sets.natD1)(Data_Typelevel_Num_Reps.d1)(t2));
              })(clusterArr);
              return Data_Map_Internal.fromFoldable(Data_Ord.ordString)(Data_Foldable.foldableArray)(clusterTuples);
          };
      };
  };
  exports["louvain"] = louvain;
  exports["init"] = init;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer"] = $PS["Gargantext.Components.GraphExplorer"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_FoldableWithIndex = $PS["Data.FoldableWithIndex"];
  var Data_Int = $PS["Data.Int"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Set = $PS["Data.Set"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Gargantext_Components_Graph = $PS["Gargantext.Components.Graph"];
  var Gargantext_Components_GraphExplorer_Controls = $PS["Gargantext.Components.GraphExplorer.Controls"];
  var Gargantext_Components_GraphExplorer_Sidebar_Types = $PS["Gargantext.Components.GraphExplorer.Sidebar.Types"];
  var Gargantext_Components_GraphExplorer_Types = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Gargantext_Data_Louvain = $PS["Gargantext.Data.Louvain"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Hooks_Sigmax_Types = $PS["Gargantext.Hooks.Sigmax.Types"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Range = $PS["Gargantext.Utils.Range"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var $$Math = $PS["Math"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Record_Extra = $PS["Record.Extra"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var transformGraph = function (graph) {
      return function (v) {
          var selectedEdgeIds = Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordString)(Data_Sequence.map(function (v1) {
              return v1.id;
          })(Gargantext_Hooks_Sigmax_Types.neighbouringEdges(graph)(v["selectedNodeIds'"])));
          var nodes = Gargantext_Hooks_Sigmax_Types.graphNodes(graph);
          var nodeSizeFilter = function (v1) {
              return Gargantext_Utils_Range.within(Gargantext_Utils_Range["$_RangeClosed_10"](Data_Ord.ordNumber))(v["nodeSize'"])(v1.size);
          };
          var nodeRemovedFilter = function (v1) {
              return !Data_Set.member(Data_Ord.ordString)(v1.id)(v["removedNodeIds'"]);
          };
          var nodeMarked = function (v1) {
              var $49 = Data_Set.member(Data_Ord.ordString)(v1.id)(v["selectedNodeIds'"]);
              if ($49) {
                  return {
                      borderColor: "#000",
                      color: v1.color,
                      equilateral: v1.equilateral,
                      gargType: v1.gargType,
                      hidden: v1.hidden,
                      id: v1.id,
                      label: v1.label,
                      size: v1.size,
                      type: "selected",
                      x: v1.x,
                      y: v1.y,
                      "_original": v1["_original"]
                  };
              };
              return v1;
          };
          var nodeHideSize = function (v1) {
              var $52 = Gargantext_Utils_Range.within(Gargantext_Utils_Range["$_RangeClosed_10"](Data_Ord.ordNumber))(v["nodeSize'"])(v1.size);
              if ($52) {
                  return v1;
              };
              return {
                  borderColor: v1.borderColor,
                  color: v1.color,
                  equilateral: v1.equilateral,
                  gargType: v1.gargType,
                  hidden: true,
                  id: v1.id,
                  label: v1.label,
                  size: v1.size,
                  type: v1.type,
                  x: v1.x,
                  y: v1.y,
                  "_original": v1["_original"]
              };
          };
          var nodeFilter = function (n) {
              return nodeRemovedFilter(n);
          };
          var newNodes = Data_Sequence.filter(nodeFilter)(Data_Sequence.map(function ($141) {
              return nodeMarked(nodeHideSize($141));
          })(nodes));
          var hasSelection = !Data_Set.isEmpty(v["selectedNodeIds'"]);
          var edges = Gargantext_Hooks_Sigmax_Types.graphEdges(graph);
          var edgeWeightFilter = function (v1) {
              return Gargantext_Utils_Range.within(Gargantext_Utils_Range["$_RangeClosed_10"](Data_Ord.ordNumber))(v["edgeWeight'"])(Data_Int.toNumber(v1.weightIdx));
          };
          var edgeShowFilter = function (edge) {
              var $56 = Gargantext_Hooks_Sigmax_Types.edgeStateHidden(v["showEdges'"]);
              if ($56) {
                  return {
                      color: edge.color,
                      confluence: edge.confluence,
                      id: edge.id,
                      hidden: true,
                      size: edge.size,
                      source: edge.source,
                      sourceNode: edge.sourceNode,
                      target: edge.target,
                      targetNode: edge.targetNode,
                      weight: edge.weight,
                      weightIdx: edge.weightIdx,
                      "_original": edge["_original"]
                  };
              };
              return edge;
          };
          var edgeMarked = function (v1) {
              var isSelected = Data_Set.member(Data_Ord.ordString)(v1.id)(selectedEdgeIds);
              var v2 = new Data_Tuple.Tuple(hasSelection, isSelected);
              if (!v2.value0 && v2.value1) {
                  return {
                      color: "#ff0000",
                      confluence: v1.confluence,
                      id: v1.id,
                      hidden: v1.hidden,
                      size: v1.size,
                      source: v1.source,
                      sourceNode: v1.sourceNode,
                      target: v1.target,
                      targetNode: v1.targetNode,
                      weight: v1.weight,
                      weightIdx: v1.weightIdx,
                      "_original": v1["_original"]
                  };
              };
              if (v2.value0 && v2.value1) {
                  return {
                      color: v1.sourceNode.color,
                      confluence: v1.confluence,
                      id: v1.id,
                      hidden: v1.hidden,
                      size: v1.size,
                      source: v1.source,
                      sourceNode: v1.sourceNode,
                      target: v1.target,
                      targetNode: v1.targetNode,
                      weight: v1.weight,
                      weightIdx: v1.weightIdx,
                      "_original": v1["_original"]
                  };
              };
              if (v2.value0 && !v2.value1) {
                  return {
                      color: "rgba(221, 221, 221, 0.5)",
                      confluence: v1.confluence,
                      id: v1.id,
                      hidden: v1.hidden,
                      size: v1.size,
                      source: v1.source,
                      sourceNode: v1.sourceNode,
                      target: v1.target,
                      targetNode: v1.targetNode,
                      weight: v1.weight,
                      weightIdx: v1.weightIdx,
                      "_original": v1["_original"]
                  };
              };
              return v1;
          };
          var edgeInGraph = function (nodeIds) {
              return function (e) {
                  return Data_Set.member(Data_Ord.ordString)(e.source)(nodeIds) && Data_Set.member(Data_Ord.ordString)(e.target)(nodeIds);
              };
          };
          var edgeHideWeight = function (v1) {
              var $68 = Gargantext_Utils_Range.within(Gargantext_Utils_Range["$_RangeClosed_10"](Data_Ord.ordNumber))(v["edgeWeight'"])(Data_Int.toNumber(v1.weightIdx));
              if ($68) {
                  return v1;
              };
              return {
                  color: v1.color,
                  confluence: v1.confluence,
                  id: v1.id,
                  hidden: true,
                  size: v1.size,
                  source: v1.source,
                  sourceNode: v1.sourceNode,
                  target: v1.target,
                  targetNode: v1.targetNode,
                  weight: v1.weight,
                  weightIdx: v1.weightIdx,
                  "_original": v1["_original"]
              };
          };
          var edgeHideConfluence = function (v1) {
              var $71 = Gargantext_Utils_Range.within(Gargantext_Utils_Range["$_RangeClosed_10"](Data_Ord.ordNumber))(v["edgeConfluence'"])(v1.confluence);
              if ($71) {
                  return v1;
              };
              return {
                  color: v1.color,
                  confluence: v1.confluence,
                  id: v1.id,
                  hidden: true,
                  size: v1.size,
                  source: v1.source,
                  sourceNode: v1.sourceNode,
                  target: v1.target,
                  targetNode: v1.targetNode,
                  weight: v1.weight,
                  weightIdx: v1.weightIdx,
                  "_original": v1["_original"]
              };
          };
          var edgeFilter = function (e) {
              return true;
          };
          var newEdges$prime = Data_Sequence.filter(edgeFilter)(Data_Sequence.map(function ($142) {
              return edgeHideWeight(edgeHideConfluence(edgeShowFilter(edgeMarked($142))));
          })(edges));
          var newEdges = Data_Sequence.filter(edgeInGraph(Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordString)(Data_Sequence.map(function (v1) {
              return v1.id;
          })(newNodes))))(newEdges$prime);
          var edgeConfluenceFilter = function (v1) {
              return Gargantext_Utils_Range.within(Gargantext_Utils_Range["$_RangeClosed_10"](Data_Ord.ordNumber))(v["edgeConfluence'"])(v1.confluence);
          };
          return {
              nodes: newNodes,
              edges: newEdges
          };
      };
  };
  var modeGraphType = function (v) {
      if (v instanceof Gargantext_Types.Authors) {
          return "square";
      };
      if (v instanceof Gargantext_Types.Institutes) {
          return "equilateral";
      };
      if (v instanceof Gargantext_Types.Sources) {
          return "star";
      };
      if (v instanceof Gargantext_Types.Terms) {
          return "def";
      };
      throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer (line 282, column 1 - line 282, column 38): " + [ v.constructor.name ]);
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.GraphExplorer");
  var graphViewCpt = (function () {
      var cpt = function (v) {
          return function (_children) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Utils_Range["$_EqClosed_11"](Data_Eq.eqNumber)))(v.controls.edgeConfluence))(function (edgeConfluence$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Utils_Range["$_EqClosed_11"](Data_Eq.eqNumber)))(v.controls.edgeWeight))(function (edgeWeight$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Gargantext_Components_GraphExplorer_Types["$_EqMetaData_67"])))(v.mMetaData))(function (mMetaData$prime) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.controls.multiSelectEnabled))(function (multiSelectEnabled$prime) {
                              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Utils_Range["$_EqClosed_11"](Data_Eq.eqNumber)))(v.controls.nodeSize))(function (nodeSize$prime) {
                                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Set.eqSet(Data_Eq.eqString)))(v.controls.removedNodeIds))(function (removedNodeIds$prime) {
                                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Set.eqSet(Data_Eq.eqString)))(v.controls.selectedNodeIds))(function (selectedNodeIds$prime) {
                                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Hooks_Sigmax_Types["$_EqShowEdgesState_36"]))(v.controls.showEdges))(function (showEdges$prime) {
                                              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.controls.showLouvain))(function (showLouvain$prime) {
                                                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(multiSelectEnabled$prime))(function (multiSelectEnabledRef) {
                                                      var louvainGraph = (function () {
                                                          if (showLouvain$prime) {
                                                              var louvain = Gargantext_Data_Louvain.louvain(Data_Unit.unit);
                                                              var cluster = Gargantext_Data_Louvain.init(louvain)(Gargantext_Hooks_Sigmax_Types.louvainNodes(v.graph))(Gargantext_Hooks_Sigmax_Types.louvainEdges(v.graph));
                                                              return Gargantext_Hooks_Sigmax_Types.louvainGraph(v.graph)(cluster);
                                                          };
                                                          return v.graph;
                                                      })();
                                                      var transformedGraph = transformGraph(louvainGraph)({
                                                          "edgeConfluence'": edgeConfluence$prime,
                                                          "edgeWeight'": edgeWeight$prime,
                                                          "nodeSize'": nodeSize$prime,
                                                          "removedNodeIds'": removedNodeIds$prime,
                                                          "selectedNodeIds'": selectedNodeIds$prime,
                                                          "showEdges'": showEdges$prime
                                                      });
                                                      var startForceAtlas = Data_Maybe.maybe(true)(function (v1) {
                                                          return v1.startForceAtlas;
                                                      })(mMetaData$prime);
                                                      return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect1'"](multiSelectEnabled$prime)(Reactix_React.setRef(multiSelectEnabledRef)(multiSelectEnabled$prime)))(function () {
                                                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Graph.graph({
                                                              elRef: v.elRef,
                                                              forceAtlas2Settings: Gargantext_Components_Graph.forceAtlas2Settings,
                                                              graph: v.graph,
                                                              mCamera: v.hyperdataGraph.mCamera,
                                                              multiSelectEnabledRef: multiSelectEnabledRef,
                                                              selectedNodeIds: v.controls.selectedNodeIds,
                                                              showEdges: v.controls.showEdges,
                                                              sigmaRef: v.controls.sigmaRef,
                                                              sigmaSettings: Gargantext_Components_Graph.sigmaSettings,
                                                              stage: v.controls.graphStage,
                                                              startForceAtlas: startForceAtlas,
                                                              transformedGraph: transformedGraph
                                                          })([  ]));
                                                      });
                                                  });
                                              });
                                          });
                                      });
                                  });
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("graphView")(cpt);
  })();
  var graphView = Reactix_React.createElement(Reactix_React.componentIsComponent)(graphViewCpt);
  var getNodes = function (session) {
      return function (graphVersion) {
          return function (graphId) {
              return Gargantext_Sessions.get(Gargantext_Components_GraphExplorer_Types["$_ReadForeignHyperdataGraph_91"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Graph.value, new Data_Maybe.Just(graphId), "?version=" + Data_Show.show(Data_Show.showInt)(graphVersion)));
          };
      };
  };
  var explorerCpt = (function () {
      var hClass = function (h) {
          if (h instanceof Gargantext_Types.LeftHanded) {
              return "lefthanded";
          };
          if (h instanceof Gargantext_Types.RightHanded) {
              return "righthanded";
          };
          throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer (line 169, column 16 - line 171, column 41): " + [ h.constructor.name ]);
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Gargantext_Components_GraphExplorer_Sidebar_Types.focusedSidePanel(v.boxes.sidePanelGraph))(function (v2) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(v.boxes.graphVersion))(function (graphVersion$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqHanded_94"]))(v.boxes.handed))(function (handed$prime) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Gargantext_Components_GraphExplorer_Types["$_EqMetaData_67"])))(v2.mMetaData))(function (mMetaData$prime) {
                              var startForceAtlas = Data_Maybe.maybe(true)(function (v3) {
                                  return v3.startForceAtlas;
                              })(mMetaData$prime);
                              var forceAtlasS = (function () {
                                  if (startForceAtlas) {
                                      return Gargantext_Hooks_Sigmax_Types.InitialRunning.value;
                                  };
                                  return Gargantext_Hooks_Sigmax_Types.InitialStopped.value;
                              })();
                              return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(v.graph))(function (dataRef) {
                                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (graphRef) {
                                      return Control_Bind.bind(Reactix_React.bindHooks)(Gargantext_Components_GraphExplorer_Controls.useGraphControls({
                                          forceAtlasS: forceAtlasS,
                                          graph: v.graph,
                                          graphId: v.graphId,
                                          hyperdataGraph: v.hyperdataGraph,
                                          reloadForest: v.boxes.reloadForest,
                                          session: v.session,
                                          showTree: v.boxes.showTree,
                                          sidePanel: v.boxes.sidePanelGraph,
                                          sidePanelState: v.boxes.sidePanelState
                                      }))(function (controls) {
                                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                                              className: "graph-meta-container"
                                          })([ Reactix_DOM_HTML.div({
                                              className: "graph-container"
                                          })([ Reactix_DOM_HTML.div({
                                              className: "container-fluid " + hClass(handed$prime)
                                          })([ Reactix_DOM_HTML.div({
                                              id: "controls-container"
                                          })([ Gargantext_Components_GraphExplorer_Controls.controls(controls)([  ]) ]), Reactix_DOM_HTML.div({
                                              className: "row graph-row"
                                          })([ Reactix_DOM_HTML.div({
                                              ref: graphRef,
                                              id: "graph-view",
                                              className: "col-md-12"
                                          })([  ]), graphView({
                                              controls: controls,
                                              elRef: graphRef,
                                              graph: v.graph,
                                              hyperdataGraph: v.hyperdataGraph,
                                              mMetaData: v2.mMetaData
                                          })([  ]) ]) ]) ]) ]));
                                      });
                                  });
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("explorer")(cpt);
  })();
  var explorer = Reactix_React.createElement(Reactix_React.componentIsComponent)(explorerCpt);
  var explorerWriteGraphCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffectOnce'"](Toestand_Classes.write_(Toestand_Boxes.writeBox)(new Data_Maybe.Just({
                  mGraph: new Data_Maybe.Just(v.graph),
                  mMetaData: v["mMetaData'"],
                  multiSelectEnabled: false,
                  removedNodeIds: Data_Set.empty,
                  selectedNodeIds: Data_Set.empty,
                  showControls: false,
                  sideTab: Gargantext_Components_GraphExplorer_Types.SideTabLegend.value
              }))(v.boxes.sidePanelGraph)))(function () {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(explorer(Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "boxes";
                  }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "graph";
                  }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "graphId";
                  }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "hyperdataGraph";
                  }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                      return "session";
                  }))(Record_Extra.nilKeys))))))(v))([  ]));
              });
          };
      };
      return here.component("explorerWriteGraph")(cpt);
  })();
  var explorerWriteGraph = Reactix_React.createElement(Reactix_React.componentIsComponent)(explorerWriteGraphCpt);
  var convert = function (v) {
      var nodeFn = function (_i) {
          return function (v1) {
              var gargType = Data_Maybe.fromJust()(Gargantext_Types.modeFromString(v1.type_));
              var cDef = function (v2) {
                  return v2.clustDefault;
              };
              var color = Gargantext_Components_GraphExplorer_Types.intColor(cDef(v1.attributes));
              return Data_Sequence.singleton({
                  borderColor: color,
                  color: color,
                  equilateral: {
                      numPoints: 3
                  },
                  gargType: gargType,
                  hidden: false,
                  id: v1.id_,
                  label: v1.label,
                  size: $$Math.log(Data_Int.toNumber(v1.size) + 1.0),
                  type: modeGraphType(gargType),
                  x: v1.x,
                  y: v1.y,
                  "_original": v1
              });
          };
      };
      var nodes = Data_FoldableWithIndex.foldMapWithIndex(Data_FoldableWithIndex.foldableWithIndexArray)(Data_Sequence.monoidSeq)(nodeFn)(v.nodes);
      var nodesMap = Gargantext_Hooks_Sigmax_Types.nodesMap(nodes);
      var edgeFn = function (i) {
          return function (v1) {
              var targetNode = Data_Maybe.fromJust()(Data_Map_Internal.lookup(Data_Ord.ordString)(v1.target)(nodesMap));
              var sourceNode = Data_Maybe.fromJust()(Data_Map_Internal.lookup(Data_Ord.ordString)(v1.source)(nodesMap));
              return Data_Sequence.singleton({
                  id: v1.id_,
                  color: sourceNode.color,
                  confluence: v1.confluence,
                  hidden: false,
                  size: 1.0,
                  source: v1.source,
                  sourceNode: sourceNode,
                  target: v1.target,
                  targetNode: targetNode,
                  weight: v1.weight,
                  weightIdx: i,
                  "_original": v1
              });
          };
      };
      var edges = Data_FoldableWithIndex.foldMapWithIndex(Data_FoldableWithIndex.foldableWithIndexArray)(Data_Sequence.monoidSeq)(edgeFn)(Data_Array.sortWith(Data_Ord.ordNumber)(function (v1) {
          return v1.weight;
      })(v.edges));
      return Data_Tuple.Tuple.create(v.metaData)({
          nodes: nodes,
          edges: edges
      });
  };
  var explorerLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var handler = function (v2) {
                  var v3 = convert(v2.graph);
                  return explorerWriteGraph(Record.merge()()(v)({
                      graph: v3.value1,
                      hyperdataGraph: v2,
                      "mMetaData'": v3.value0
                  }))([  ]);
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(v.boxes.graphVersion))(function (graphVersion$prime) {
                  return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqInt)(Gargantext_Components_GraphExplorer_Types["$_EqHyperdataGraph_90"])(v.graphId)(getNodes(v.session)(graphVersion$prime))(handler);
              });
          };
      };
      return here.component("explorerLayout")(cpt);
  })();
  var explorerLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(explorerLayoutCpt);
  exports["explorerLayout"] = explorerLayout;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.Legend"] = $PS["Gargantext.Components.GraphExplorer.Legend"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.Legend"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Gargantext_Components_GraphExplorer_Types = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.GraphExplorer.Legend");
  var entry = function (v) {
      return Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.span({
          style: {
              width: 10,
              height: 10,
              backgroundColor: Gargantext_Components_GraphExplorer_Types.intColor(v.id_),
              display: "inline-block"
          }
      })([  ]), Reactix_DOM_HTML.text(" " + v.label) ]);
  };
  var legendCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([ Data_Foldable.foldMap(Data_Sequence.foldableSeq)(Reactix_React.monoidElement)(entry)(v.items) ]));
          };
      };
      return here.component("legend")(cpt);
  })();
  var legend = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(legendCpt)(props)([  ]);
  };
  exports["legend"] = legend;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Category.Types"] = $PS["Gargantext.Components.Category.Types"] || {};
  var exports = $PS["Gargantext.Components.Category.Types"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var Star_0 = (function () {
      function Star_0() {

      };
      Star_0.value = new Star_0();
      return Star_0;
  })();
  var Star_1 = (function () {
      function Star_1() {

      };
      Star_1.value = new Star_1();
      return Star_1;
  })();
  var Star_2 = (function () {
      function Star_2() {

      };
      Star_2.value = new Star_2();
      return Star_2;
  })();
  var Star_3 = (function () {
      function Star_3() {

      };
      Star_3.value = new Star_3();
      return Star_3;
  })();
  var Star_4 = (function () {
      function Star_4() {

      };
      Star_4.value = new Star_4();
      return Star_4;
  })();
  var Trash = (function () {
      function Trash() {

      };
      Trash.value = new Trash();
      return Trash;
  })();
  var UnRead = (function () {
      function UnRead() {

      };
      UnRead.value = new UnRead();
      return UnRead;
  })();
  var Checked = (function () {
      function Checked() {

      };
      Checked.value = new Checked();
      return Checked;
  })();
  var Topic = (function () {
      function Topic() {

      };
      Topic.value = new Topic();
      return Topic;
  })();
  var Favorite = (function () {
      function Favorite() {

      };
      Favorite.value = new Favorite();
      return Favorite;
  })();
  var stars = [ Star_0.value, Star_1.value, Star_2.value, Star_3.value, Star_4.value ];
  var star2score = function (v) {
      if (v instanceof Star_0) {
          return 0;
      };
      if (v instanceof Star_1) {
          return 1;
      };
      if (v instanceof Star_2) {
          return 2;
      };
      if (v instanceof Star_3) {
          return 3;
      };
      if (v instanceof Star_4) {
          return 4;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Category.Types (line 33, column 1 - line 33, column 26): " + [ v.constructor.name ]);
  };
  var favCategory = function (v) {
      if (v instanceof Favorite) {
          return Topic.value;
      };
      return Favorite.value;
  };
  var decodeStar = function (v) {
      if (v === 0) {
          return Star_0.value;
      };
      if (v === 1) {
          return Star_1.value;
      };
      if (v === 2) {
          return Star_2.value;
      };
      if (v === 3) {
          return Star_3.value;
      };
      if (v === 4) {
          return Star_4.value;
      };
      return Star_4.value;
  };
  var decodeCategory = function (v) {
      if (v === 0) {
          return Trash.value;
      };
      if (v === 1) {
          return UnRead.value;
      };
      if (v === 2) {
          return Checked.value;
      };
      if (v === 3) {
          return Topic.value;
      };
      if (v === 4) {
          return Favorite.value;
      };
      return UnRead.value;
  };
  var clickAgain = function (v) {
      if (v instanceof Star_0) {
          return Star_1.value;
      };
      return decodeStar(star2score(v) - 1 | 0);
  };                                                                                         
  var cat2score = function (v) {
      if (v instanceof Trash) {
          return 0;
      };
      if (v instanceof UnRead) {
          return 1;
      };
      if (v instanceof Checked) {
          return 2;
      };
      if (v instanceof Topic) {
          return 3;
      };
      if (v instanceof Favorite) {
          return 4;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Category.Types (line 78, column 1 - line 78, column 29): " + [ v.constructor.name ]);
  };
  var $dollar_WriteForeignStar_13 = new Simple_JSON.WriteForeign((function () {
      var $57 = Simple_JSON.writeImpl(Simple_JSON.writeForeignInt);
      return function ($58) {
          return $57(star2score($58));
      };
  })());
  var $dollar_WriteForeignCategory_18 = new Simple_JSON.WriteForeign((function () {
      var $59 = Simple_JSON.writeImpl(Simple_JSON.writeForeignInt);
      return function ($60) {
          return $59(cat2score($60));
      };
  })());
  var $dollar_GenericStar__9 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Star_0) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof Star_1) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof Star_2) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof Star_3) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
      };
      if (x instanceof Star_4) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))));
      };
      throw new Error("Failed pattern match at Gargantext.Components.Category.Types (line 16, column 1 - line 16, column 31): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return Star_0.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return Star_1.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return Star_2.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
          return Star_3.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inr))) {
          return Star_4.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Category.Types (line 16, column 1 - line 16, column 31): " + [ x.constructor.name ]);
  });       
  var $dollar_GenericCategory__14 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Trash) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof UnRead) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof Checked) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof Topic) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
      };
      if (x instanceof Favorite) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))));
      };
      throw new Error("Failed pattern match at Gargantext.Components.Category.Types (line 52, column 1 - line 52, column 35): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return Trash.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return UnRead.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return Checked.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
          return Topic.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inr))) {
          return Favorite.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Category.Types (line 52, column 1 - line 52, column 35): " + [ x.constructor.name ]);
  });       
  var $dollar_EqStar_11 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericStar__9)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)))))));
  var $dollar_EqCategory_16 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericCategory__14)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqNoArguments)))))));
  exports["Star_0"] = Star_0;
  exports["Star_1"] = Star_1;
  exports["stars"] = stars;
  exports["decodeStar"] = decodeStar;
  exports["star2score"] = star2score;
  exports["clickAgain"] = clickAgain;
  exports["Trash"] = Trash;
  exports["Favorite"] = Favorite;
  exports["favCategory"] = favCategory;
  exports["decodeCategory"] = decodeCategory;
  exports["$_EqStar_11"] = $dollar_EqStar_11;
  exports["$_WriteForeignStar_13"] = $dollar_WriteForeignStar_13;
  exports["$_EqCategory_16"] = $dollar_EqCategory_16;
  exports["$_WriteForeignCategory_18"] = $dollar_WriteForeignCategory_18;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Category"] = $PS["Gargantext.Components.Category"] || {};
  var exports = $PS["Gargantext.Components.Category"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_Category_Types = $PS["Gargantext.Components.Category.Types"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Category");
  var categoryRoute = function (nodeId) {
      return new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(nodeId), "category");
  };
  var $dollar_WriteForeignRatingQuery_20 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "ntc_category";
      }))(Gargantext_Components_Category_Types["$_WriteForeignStar_13"])(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "ntc_nodesId";
      }))(Simple_JSON.writeForeignArray(Simple_JSON.writeForeignInt))(Simple_JSON.nilWriteForeignFields)()()())()()()))({
          ntc_nodesId: v.nodeIds,
          ntc_category: v.rating
      });
  });
  var putRating = function (session) {
      return function (nodeId) {
          var ratingRoute = new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(nodeId), "category");
          return Gargantext_Sessions.put($dollar_WriteForeignRatingQuery_20)(Simple_JSON.readArray(Simple_JSON.readInt))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(ratingRoute);
      };
  };
  var ratingCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onClick = function (c) {
                  return function (v2) {
                      var c$prime = (function () {
                          var $32 = Data_Eq.eq(Gargantext_Components_Category_Types["$_EqStar_11"])(v.score)(c);
                          if ($32) {
                              return Gargantext_Components_Category_Types.clickAgain(c);
                          };
                          return c;
                      })();
                      return function __do() {
                          v.setLocalCategories(Data_Map_Internal.insert(Data_Ord.ordInt)(v["row"]["_id"])(c$prime))();
                          return Data_Functor["void"](Effect.functorEffect)(Effect_Aff.launchAff(putRating(v.session)(v.nodeId)({
                              nodeIds: [ v["row"]["_id"] ],
                              rating: c$prime
                          })))();
                      };
                  };
              };
              var icon$prime = function (v2) {
                  return function (v3) {
                      if (v2 instanceof Gargantext_Components_Category_Types.Star_0 && v3 instanceof Gargantext_Components_Category_Types.Star_0) {
                          return "fa fa-times-circle";
                      };
                      if (v3 instanceof Gargantext_Components_Category_Types.Star_0) {
                          return "fa fa-times";
                      };
                      var $35 = Gargantext_Components_Category_Types.star2score(v2) < Gargantext_Components_Category_Types.star2score(v3);
                      if ($35) {
                          return "fa fa-star-o";
                      };
                      return "fa fa-star";
                  };
              };
              var divs = Data_Functor.map(Data_Functor.functorArray)(function (s) {
                  return Reactix_DOM_HTML.div({
                      className: icon$prime(v.score)(s),
                      on: {
                          click: onClick(s)
                      }
                  })([  ]);
              })(Gargantext_Components_Category_Types.stars);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "flex"
              })(divs));
          };
      };
      return here.component("rating")(cpt);
  })();
  var rating = Reactix_React.createElement(Reactix_React.componentIsComponent)(ratingCpt);
  var $dollar_WriteForeignCategoryQuery_22 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "ntc_category";
      }))(Gargantext_Components_Category_Types["$_WriteForeignCategory_18"])(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "ntc_nodesId";
      }))(Simple_JSON.writeForeignArray(Simple_JSON.writeForeignInt))(Simple_JSON.nilWriteForeignFields)()()())()()()))({
          ntc_nodesId: v.nodeIds,
          ntc_category: v.category
      });
  });
  var putCategories = function (session) {
      return function (nodeId) {
          return Gargantext_Sessions.put($dollar_WriteForeignCategoryQuery_22)(Simple_JSON.readArray(Simple_JSON.readInt))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(categoryRoute(nodeId));
      };
  };
  exports["rating"] = rating;
  exports["putCategories"] = putCategories;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.FacetsTable"] = $PS["Gargantext.Components.FacetsTable"] || {};
  var exports = $PS["Gargantext.Components.FacetsTable"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Set = $PS["Data.Set"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_Category = $PS["Gargantext.Components.Category"];
  var Gargantext_Components_Category_Types = $PS["Gargantext.Components.Category.Types"];
  var Gargantext_Components_Search = $PS["Gargantext.Components.Search"];
  var Gargantext_Components_Table = $PS["Gargantext.Components.Table"];
  var Gargantext_Components_Table_Types = $PS["Gargantext.Components.Table.Types"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils = $PS["Gargantext.Utils"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var Docs = (function () {
      function Docs(value0) {
          this.value0 = value0;
      };
      Docs.create = function (value0) {
          return new Docs(value0);
      };
      return Docs;
  })();
  var Contacts = (function () {
      function Contacts(value0) {
          this.value0 = value0;
      };
      Contacts.create = function (value0) {
          return new Contacts(value0);
      };
      return Contacts;
  })();
  var publicationDate = function (v) {
      return Gargantext_Utils.zeroPad(2)(v.publication_year) + ("-" + Gargantext_Utils.zeroPad(2)(v.publication_month));
  };
  var markCategory = function (session) {
      return function (nodeId) {
          return function (category) {
              return function (nids) {
                  var q = {
                      nodeIds: nids,
                      category: Gargantext_Components_Category_Types.favCategory(category)
                  };
                  return Data_Functor["void"](Effect.functorEffect)(Effect_Aff.launchAff_(Gargantext_Components_Category.putCategories(session)(nodeId)(q)));
              };
          };
      };
  };
  var initialPagePath = function (v) {
      return {
          session: v.session,
          nodeId: v.nodeId,
          listId: v.listId,
          query: v.query,
          params: Gargantext_Components_Table.initialParams
      };
  };
  var initialDeletions = {
      pending: Data_Monoid.mempty(Data_Set.monoidSet(Data_Ord.ordInt)),
      deleted: Data_Monoid.mempty(Data_Set.monoidSet(Data_Ord.ordInt))
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.FacetsTable");
  var pageCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var wrapColElts = Data_Function["const"](Control_Category.identity(Control_Category.categoryFn));
              var pairUrl = function (v2) {
                  if (v2.id > 1) {
                      var href = Gargantext_Ends.url(Gargantext_Sessions_Types["$_ToUrlSessionNodePath_36"])(v.session)(new Gargantext_Types.NodePath(Gargantext_Sessions_Types.sessionId(v.session), Gargantext_Types.NodeContact.value, new Data_Maybe.Just(v2.id)));
                      return Reactix_DOM_HTML.a({
                          href: href,
                          target: "blank"
                      })([ Reactix_DOM_HTML.text(v2.label) ]);
                  };
                  if (Data_Boolean.otherwise) {
                      return Reactix_DOM_HTML.text(v2.label);
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.FacetsTable (line 370, column 9 - line 373, column 37): " + [ v2.constructor.name ]);
              };
              var maybeStricken = function ($$delete) {
                  if ($$delete) {
                      return Reactix_DOM_HTML.div({
                          style: {
                              textDecoration: "line-through"
                          }
                      });
                  };
                  if (Data_Boolean.otherwise) {
                      return Reactix_DOM_HTML.div({});
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.FacetsTable (line 403, column 9 - line 405, column 33): " + [ $$delete.constructor.name ]);
              };
              var gi = function (v2) {
                  if (v2 instanceof Gargantext_Components_Category_Types.Trash) {
                      return "fa fa-star-empty";
                  };
                  return "fa fa-star";
              };
              var documentUrl = function (id) {
                  return function (v2) {
                      return Gargantext_Ends.url(Gargantext_Ends["$_ToUrlFrontendsAppRoute_35"])(v.frontends)(new Gargantext_Routes.CorpusDocument(Gargantext_Sessions_Types.sessionId(v.session), v2.nodeId, v2.listId, id));
                  };
              };
              var docRow = function (path$prime) {
                  return function (v2) {
                      var markClick = function (v3) {
                          return function (v4) {
                              return markCategory(v.session)(v3.nodeId)(v2.category)([ v2.id ]);
                          };
                      };
                      return {
                          row: Gargantext_Components_Table.makeRow([ Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.a({
                              className: gi(v2.category),
                              on: {
                                  click: markClick(path$prime)
                              }
                          })([  ]) ]), maybeStricken(v2["delete"])([ Reactix_DOM_HTML.text(publicationDate(v2)) ]), maybeStricken(v2["delete"])([ Reactix_DOM_HTML.a({
                              target: "_blank",
                              href: documentUrl(v2.id)(path$prime)
                          })([ Reactix_DOM_HTML.text(v2.title) ]) ]), maybeStricken(v2["delete"])([ Reactix_DOM_HTML.text(v2.source) ]) ]),
                          "delete": true
                      };
                  };
              };
              var contactRow = function (path$prime) {
                  return function (v2) {
                      var markClick = function (v3) {
                          return function (v4) {
                              return markCategory(v.session)(v3.nodeId)(Gargantext_Components_Category_Types.Favorite.value)([ v2.id ]);
                          };
                      };
                      var contactUrl = function (aId) {
                          return function (id$prime) {
                              return Gargantext_Ends.url(Gargantext_Ends["$_ToUrlFrontendsAppRoute_35"])(v.frontends)(new Gargantext_Routes.ContactPage(Gargantext_Sessions_Types.sessionId(v.session), v2.annuaireId, id$prime));
                          };
                      };
                      return {
                          row: Gargantext_Components_Table.makeRow([ Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.a({
                              className: gi(Gargantext_Components_Category_Types.Favorite.value),
                              on: {
                                  click: markClick(path$prime)
                              }
                          })([  ]) ]), maybeStricken(v2["delete"])([ Reactix_DOM_HTML.a({
                              target: "_blank",
                              href: contactUrl(v2.annuaireId)(v2.id)
                          })([ Reactix_DOM_HTML.text(v2.hyperdata.firstname + (" " + v2.hyperdata.lastname)) ]) ]), maybeStricken(v2["delete"])([ Reactix_DOM_HTML.text(v2.hyperdata.labs) ]) ]),
                          "delete": true
                      };
                  };
              };
              var colNames = (function () {
                  if (v.rowsLoaded instanceof Docs) {
                      return Data_Functor.map(Data_Functor.functorArray)(Gargantext_Components_Table_Types.ColumnName)([ "", "Date", "Title", "Journal", "", "" ]);
                  };
                  if (v.rowsLoaded instanceof Contacts) {
                      return Data_Functor.map(Data_Functor.functorArray)(Gargantext_Components_Table_Types.ColumnName)([ "", "Contact", "Organization", "", "", "" ]);
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.FacetsTable (line 358, column 20 - line 360, column 89): " + [ v.rowsLoaded.constructor.name ]);
              })();
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "session";
              }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                  return "query";
              }))(Gargantext_Components_Search["$_EqSearchQuery_33"]))()(new Data_Symbol.IsSymbol(function () {
                  return "params";
              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "searchType";
              }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                  return "orderBy";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                  return "offset";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "limit";
              }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                  return "nodeId";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "listId";
              }))(Data_Eq.eqInt))))(v.path))(function (v2) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v3) {
                      return v3.params;
                  })(function (a) {
                      return function (b) {
                          var $114 = {};
                          for (var $115 in b) {
                              if ({}.hasOwnProperty.call(b, $115)) {
                                  $114[$115] = b[$115];
                              };
                          };
                          $114.params = a;
                          return $114;
                      };
                  })(v.path))(function (params) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "pending";
                      }))(Data_Set.eqSet(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                          return "deleted";
                      }))(Data_Set.eqSet(Data_Eq.eqInt)))))(v.deletions))(function (deletions$prime) {
                          var isDeleted = function (v3) {
                              return Data_Set.member(Data_Ord.ordInt)(v3.id)(deletions$prime.deleted);
                          };
                          var rows = function (path$prime1) {
                              if (v.rowsLoaded instanceof Docs) {
                                  return Data_Functor.map(Data_Sequence.functorSeq)(docRow(path$prime1))(Data_Sequence.filter((function () {
                                      var $222 = Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean);
                                      return function ($223) {
                                          return $222(isDeleted($223));
                                      };
                                  })())(v.rowsLoaded.value0.docs));
                              };
                              if (v.rowsLoaded instanceof Contacts) {
                                  return Data_Functor.map(Data_Sequence.functorSeq)(contactRow(path$prime1))(v.rowsLoaded.value0.contacts);
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.FacetsTable (line 345, column 24 - line 347, column 66): " + [ v.rowsLoaded.constructor.name ]);
                          };
                          var isChecked = function (id) {
                              return Data_Set.member(Data_Ord.ordInt)(id)(deletions$prime.pending);
                          };
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Table.table({
                              colNames: colNames,
                              container: v.container,
                              params: params,
                              rows: rows(v2),
                              syncResetButton: [ Reactix_DOM_HTML.div({})([  ]) ],
                              totalRecords: v.totalRecords,
                              wrapColElts: wrapColElts
                          }));
                      });
                  });
              });
          };
      };
      return here.component("page")(cpt);
  })();
  var page = Reactix_React.createElement(Reactix_React.componentIsComponent)(pageCpt);
  var err2view = function (message) {
      return {
          id: 1,
          date: "",
          title: "SearchNoResult",
          source: "",
          score: 1,
          authors: "",
          category: Gargantext_Components_Category_Types.decodeCategory(1),
          pairs: [  ],
          "delete": false,
          publication_year: 2020,
          publication_month: 10,
          publication_day: 1
      };
  };
  var doc2view = function (v) {
      return {
          id: v.id,
          date: v.created,
          title: Data_Maybe.fromMaybe("Title")(v.hyperdata.title),
          source: Data_Maybe.fromMaybe("Source")(v.hyperdata.source),
          score: v.score,
          authors: Data_Maybe.fromMaybe("Authors")(v.hyperdata.authors),
          category: Gargantext_Components_Category_Types.decodeCategory(v.category),
          pairs: [  ],
          "delete": false,
          publication_year: Data_Maybe.fromMaybe(2020)(v.hyperdata.publication_year),
          publication_month: Data_Maybe.fromMaybe(1)(v.hyperdata.publication_month),
          publication_day: Data_Maybe.fromMaybe(1)(v.hyperdata.publication_day)
      };
  };
  var contact2view = function (v) {
      return {
          id: v.c_id,
          hyperdata: v.c_hyperdata,
          score: v.c_score,
          annuaireId: v.c_annuaireId,
          "delete": false
      };
  };
  var loadPage = function (v) {
      var convOrderBy = function (v1) {
          if (v1 instanceof Gargantext_Components_Table_Types.ASC && v1.value0 === "Date") {
              return Gargantext_Types.DateAsc.value;
          };
          if (v1 instanceof Gargantext_Components_Table_Types.DESC && v1.value0 === "Date") {
              return Gargantext_Types.DateDesc.value;
          };
          if (v1 instanceof Gargantext_Components_Table_Types.ASC && v1.value0 === "Title") {
              return Gargantext_Types.TitleAsc.value;
          };
          if (v1 instanceof Gargantext_Components_Table_Types.DESC && v1.value0 === "Title") {
              return Gargantext_Types.TitleDesc.value;
          };
          if (v1 instanceof Gargantext_Components_Table_Types.ASC && v1.value0 === "Source") {
              return Gargantext_Types.SourceAsc.value;
          };
          if (v1 instanceof Gargantext_Components_Table_Types.DESC && v1.value0 === "Source") {
              return Gargantext_Types.SourceDesc.value;
          };
          return Gargantext_Types.DateAsc.value;
      };
      var p = new Gargantext_Routes.Search({
          listId: v.listId,
          offset: v.params.offset,
          limit: v.params.limit,
          orderBy: Data_Functor.map(Data_Maybe.functorMaybe)(convOrderBy)(v.params.orderBy)
      }, new Data_Maybe.Just(v.nodeId));
      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.post(Gargantext_Components_Search["$_WriteForeignSearchQuery_36"])(Gargantext_Components_Search["$_ReadForeignSearchResult_41"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(p)(v.query))(function (v1) {
          return Control_Applicative.pure(Effect_Aff.applicativeAff)((function () {
              if (v1.result instanceof Gargantext_Components_Search.SearchResultDoc) {
                  return new Docs({
                      docs: Data_Functor.map(Data_Sequence.functorSeq)(doc2view)(Data_Sequence.fromFoldable(Data_Foldable.foldableArray)(v1.result.value0.docs))
                  });
              };
              if (v1.result instanceof Gargantext_Components_Search.SearchResultContact) {
                  return new Contacts({
                      contacts: Data_Functor.map(Data_Sequence.functorSeq)(contact2view)(Data_Sequence.fromFoldable(Data_Foldable.foldableArray)(v1.result.value0.contacts))
                  });
              };
              return new Docs({
                  docs: Data_Sequence.fromFoldable(Data_Foldable.foldableArray)([ err2view(v1.result) ])
              });
          })());
      });
  }; 
  var $dollar_GenericRows__53 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Docs) {
          return new Data_Generic_Rep.Inl(x.value0);
      };
      if (x instanceof Contacts) {
          return new Data_Generic_Rep.Inr(x.value0);
      };
      throw new Error("Failed pattern match at Gargantext.Components.FacetsTable (line 118, column 1 - line 118, column 31): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return new Docs(x.value0);
      };
      if (x instanceof Data_Generic_Rep.Inr) {
          return new Contacts(x.value0);
      };
      throw new Error("Failed pattern match at Gargantext.Components.FacetsTable (line 118, column 1 - line 118, column 31): " + [ x.constructor.name ]);
  });
  var $dollar_GenericPair__44 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });   
  var $dollar_GenericDocumentsView__47 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericContactsView__50 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });   
  var $dollar_EqPair_45 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericPair__44)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "label";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Data_Eq.eqInt))))));
  var $dollar_EqDocumentsView_48 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericDocumentsView__47)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "source";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "score";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "publication_year";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "publication_month";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "publication_day";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "pairs";
  }))(Data_Eq.eqArray($dollar_EqPair_45)))()(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "delete";
  }))(Data_Eq.eqBoolean))()(new Data_Symbol.IsSymbol(function () {
      return "date";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "category";
  }))(Gargantext_Components_Category_Types["$_EqCategory_16"]))()(new Data_Symbol.IsSymbol(function () {
      return "authors";
  }))(Data_Eq.eqString))))));
  var $dollar_EqContactsView_51 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericContactsView__50)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "score";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "hyperdata";
  }))(Gargantext_Components_Search["$_EqHyperdataRowContact_65"]))()(new Data_Symbol.IsSymbol(function () {
      return "delete";
  }))(Data_Eq.eqBoolean))()(new Data_Symbol.IsSymbol(function () {
      return "annuaireId";
  }))(Data_Eq.eqInt))))));
  var $dollar_EqRows_54 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericRows__53)(Data_Eq_Generic.genericEqSum(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "docs";
  }))(Data_Sequence.eqSeq($dollar_EqDocumentsView_48))))))(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "contacts";
  }))(Data_Sequence.eqSeq($dollar_EqContactsView_51))))))));
  var pageLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "session";
              }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                  return "query";
              }))(Gargantext_Components_Search["$_EqSearchQuery_33"]))()(new Data_Symbol.IsSymbol(function () {
                  return "params";
              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "searchType";
              }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                  return "orderBy";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                  return "offset";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "limit";
              }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                  return "nodeId";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "listId";
              }))(Data_Eq.eqInt))))(v.path))(function (path$prime) {
                  return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "session";
                  }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                      return "query";
                  }))(Gargantext_Components_Search["$_EqSearchQuery_33"]))()(new Data_Symbol.IsSymbol(function () {
                      return "params";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "searchType";
                  }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                      return "orderBy";
                  }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                      return "offset";
                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                      return "limit";
                  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                      return "nodeId";
                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                      return "listId";
                  }))(Data_Eq.eqInt)))($dollar_EqRows_54)(path$prime)(loadPage)(function (rowsLoaded) {
                      return page({
                          container: v.container,
                          deletions: v.deletions,
                          frontends: v.frontends,
                          path: v.path,
                          rowsLoaded: rowsLoaded,
                          session: v.session,
                          totalRecords: v.totalRecords
                      })([  ]);
                  });
              });
          };
      };
      return here.component("pageLayout")(cpt);
  })();
  var pageLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(pageLayoutCpt);
  var docViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var buttonStyle = {
                  backgroundColor: "peru",
                  border: "white",
                  color: "white",
                  "float": "right",
                  padding: "9px"
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(initialDeletions))(function (deletions) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(initialPagePath({
                      nodeId: v.nodeId,
                      listId: v.listId,
                      query: v.query,
                      session: v.session
                  })))(function (path) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "session";
                      }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                          return "query";
                      }))(Gargantext_Components_Search["$_EqSearchQuery_33"]))()(new Data_Symbol.IsSymbol(function () {
                          return "params";
                      }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "searchType";
                      }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                          return "orderBy";
                      }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                          return "offset";
                      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                          return "limit";
                      }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                          return "nodeId";
                      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                          return "listId";
                      }))(Data_Eq.eqInt))))(path))(function (path$prime) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect'"]((function () {
                              var ipp = initialPagePath({
                                  nodeId: v.nodeId,
                                  listId: v.listId,
                                  query: v.query,
                                  session: v.session
                              });
                              var $203 = Data_Eq.eq(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                                  return "session";
                              }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                                  return "query";
                              }))(Gargantext_Components_Search["$_EqSearchQuery_33"]))()(new Data_Symbol.IsSymbol(function () {
                                  return "params";
                              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                                  return "searchType";
                              }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                                  return "orderBy";
                              }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                                  return "offset";
                              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                                  return "limit";
                              }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                                  return "nodeId";
                              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                                  return "listId";
                              }))(Data_Eq.eqInt)))(path$prime)(ipp);
                              if ($203) {
                                  return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                              };
                              return Data_Functor["void"](Effect.functorEffect)(Toestand_Classes.write(Toestand_Boxes.writeBox)(ipp)(path));
                          })()))(function () {
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                                  className: "facets-doc-view container1"
                              })([ Gargantext_Utils_Reactix.row([ v.chart, Reactix_DOM_HTML.div({
                                  className: "col-md-12"
                              })([ pageLayout({
                                  container: v.container,
                                  deletions: deletions,
                                  frontends: v.frontends,
                                  path: path,
                                  session: v.session,
                                  totalRecords: v.totalRecords
                              })([  ]) ]) ]) ]));
                          });
                      });
                  });
              });
          };
      };
      return here.component("docView")(cpt);
  })();
  var docView = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(docViewCpt)(props)([  ]);
  };
  exports["docView"] = docView;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Tab"] = $PS["Gargantext.Components.Tab"] || {};
  var exports = $PS["Gargantext.Components.Tab"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_FunctorWithIndex = $PS["Data.FunctorWithIndex"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Tab");
  var tabCpt = (function () {
      var cpt = function (v) {
          return function (children) {
              var same = v.selected === v.index;
              var className = "tab-pane" + (function () {
                  if (same) {
                      return "show active";
                  };
                  return "fade";
              })();
              var children$prime = (function () {
                  if (same) {
                      return children;
                  };
                  return [  ];
              })();
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: className
              })(children$prime));
          };
      };
      return here.component("tab")(cpt);
  })();
  var tab = Reactix_React.createElement(Reactix_React.componentIsComponent)(tabCpt);
  var tabsCpt = (function () {
      var item = function (selected) {
          return function (index) {
              return function (v) {
                  return tab({
                      selected: selected,
                      index: index
                  })([ v.value1 ]);
              };
          };
      };
      var button = function (activeTab) {
          return function (selected) {
              return function (index) {
                  return function (v) {
                      var eq = index === selected;
                      var click = function (e) {
                          return Toestand_Classes.write_(Toestand_Boxes.writeBox)(index)(activeTab);
                      };
                      var className = "nav-item nav-link" + (function () {
                          if (eq) {
                              return " active";
                          };
                          return "";
                      })();
                      return Reactix_DOM_HTML.a({
                          className: className,
                          on: {
                              click: click
                          }
                      })([ Reactix_DOM_HTML.text(v.value0) ]);
                  };
              };
          };
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(v.activeTab))(function (activeTab$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.nav({})([ Reactix_DOM_HTML.br({}), Reactix_DOM_HTML.div({
                      className: "nav nav-tabs",
                      title: "Search result"
                  })(Data_FunctorWithIndex.mapWithIndex(Data_FunctorWithIndex.functorWithIndexArray)(button(v.activeTab)(activeTab$prime))(v.tabs)) ]), Reactix_DOM_HTML.div({
                      className: "tab-content"
                  })(Data_FunctorWithIndex.mapWithIndex(Data_FunctorWithIndex.functorWithIndexArray)(item(activeTab$prime))(v.tabs)) ]));
              });
          };
      };
      return here.component("tabs")(cpt);
  })();
  var tabs = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(tabsCpt)(props)([  ]);
  };
  exports["tabs"] = tabs;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Graph.Tabs"] = $PS["Gargantext.Components.Nodes.Corpus.Graph.Tabs"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Graph.Tabs"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Gargantext_Components_FacetsTable = $PS["Gargantext.Components.FacetsTable"];
  var Gargantext_Components_Tab = $PS["Gargantext.Components.Tab"];
  var Gargantext_Components_Table = $PS["Gargantext.Components.Table"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];                
  var tab = function (frontends) {
      return function (session) {
          return function (query) {
              return function (v) {
                  var container = Gargantext_Components_Table.graphContainer({
                      title: v.corpusLabel
                  });
                  var dvProps = {
                      frontends: frontends,
                      session: session,
                      nodeId: v.corpusId,
                      listId: v.listId,
                      query: query,
                      chart: Data_Monoid.mempty(Reactix_React.monoidElement),
                      totalRecords: 0,
                      container: container
                  };
                  return new Data_Tuple.Tuple(v.corpusLabel, Gargantext_Components_FacetsTable.docView(dvProps));
              };
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Corpus.Graph.Tabs");
  var tabsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var tabs$prime = Data_Array.fromFoldable(Data_Foldable.foldableArray)(Data_Functor.map(Data_Functor.functorArray)(tab(v.frontends)(v.session)(v.query))(v.sides));
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(0))(function (activeTab) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Tab.tabs({
                      activeTab: activeTab,
                      tabs: tabs$prime
                  }));
              });
          };
      };
      return here.component("tabs")(cpt);
  })();
  var tabs = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(tabsCpt)(props)([  ]);
  };
  exports["tabs"] = tabs;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.RandomText"] = $PS["Gargantext.Components.RandomText"] || {};
  var exports = $PS["Gargantext.Components.RandomText"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_String_Common = $PS["Data.String.Common"];
  var words = function (sentence) {
      return Data_Array.filter(Data_Eq.notEq(Data_Eq.eqString)(""))(Data_String_Common.split(" ")(sentence));
  };
  exports["words"] = words;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.Sidebar"] = $PS["Gargantext.Components.GraphExplorer.Sidebar"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.Sidebar"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Parallel = $PS["Control.Parallel"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Int = $PS["Data.Int"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Set = $PS["Data.Set"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_Components_GraphExplorer_Legend = $PS["Gargantext.Components.GraphExplorer.Legend"];
  var Gargantext_Components_GraphExplorer_Types = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Gargantext_Components_Lang = $PS["Gargantext.Components.Lang"];
  var Gargantext_Components_NgramsTable_Core = $PS["Gargantext.Components.NgramsTable.Core"];
  var Gargantext_Components_Nodes_Corpus_Graph_Tabs = $PS["Gargantext.Components.Nodes.Corpus.Graph.Tabs"];
  var Gargantext_Components_RandomText = $PS["Gargantext.Components.RandomText"];
  var Gargantext_Components_Search = $PS["Gargantext.Components.Search"];
  var Gargantext_Data_Array = $PS["Gargantext.Data.Array"];
  var Gargantext_Hooks_Sigmax_Types = $PS["Gargantext.Hooks.Sigmax.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Record_Extra = $PS["Record.Extra"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var neighbourBadges = function (graph) {
      return function (selectedNodeIds) {
          var selectedNodes$prime = Gargantext_Hooks_Sigmax_Types.graphNodes(Gargantext_Hooks_Sigmax_Types.nodesById(graph)(selectedNodeIds));
          return Gargantext_Hooks_Sigmax_Types.neighbours(graph)(selectedNodes$prime);
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.GraphExplorer.Sidebar");
  var queryCpt$prime = (function () {
      var cpt = function (v) {
          return function (v1) {
              var toQuery = function (id) {
                  var v2 = Data_Map_Internal.lookup(Data_Ord.ordString)(id)(v.nodesMap);
                  if (v2 instanceof Data_Maybe.Nothing) {
                      return [  ];
                  };
                  if (v2 instanceof Data_Maybe.Just) {
                      return Gargantext_Components_RandomText.words(v2.value0.label);
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.Sidebar (line 411, column 20 - line 413, column 32): " + [ v2.constructor.name ]);
              };
              var side = function (corpusId) {
                  return {
                      corpusId: corpusId,
                      corpusLabel: v.metaData.title,
                      listId: v.metaData.list.listId
                  };
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)((function () {
                  var v2 = Data_Array.head(v.metaData.corpusId);
                  if (v2 instanceof Data_Maybe.Nothing) {
                      return Reactix_DOM_HTML.div({})([  ]);
                  };
                  if (v2 instanceof Data_Maybe.Just) {
                      return Gargantext_Components_Nodes_Corpus_Graph_Tabs.tabs({
                          frontends: v.frontends,
                          query: {
                              expected: v.searchType,
                              query: Data_Array.concat(Data_Functor.map(Data_Functor.functorArray)(toQuery)(Data_Set.toUnfoldable(Data_Unfoldable.unfoldableArray)(v.selectedNodeIds)))
                          },
                          session: v.session,
                          sides: [ side(v2.value0) ]
                      });
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.Sidebar (line 399, column 12 - line 408, column 19): " + [ v2.constructor.name ]);
              })());
          };
      };
      return here.component("query'")(cpt);
  })();
  var query$prime = Reactix_React.createElement(Reactix_React.componentIsComponent)(queryCpt$prime);
  var queryCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)((function () {
                  var $40 = Data_Set.isEmpty(v.selectedNodeIds);
                  if ($40) {
                      return Reactix_DOM_HTML.div({})([  ]);
                  };
                  return query$prime(v)([  ]);
              })());
          };
      };
      return here.component("query")(cpt);
  })();
  var query = Reactix_React.createElement(Reactix_React.componentIsComponent)(queryCpt);
  var sideTabNavCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var liItem = function (sideTab$prime) {
                  return function (tab) {
                      return Reactix_DOM_HTML.div({
                          className: "nav-item nav-link" + (function () {
                              var $44 = Data_Eq.eq(Gargantext_Components_GraphExplorer_Types["$_EqSideTab_81"])(tab)(sideTab$prime);
                              if ($44) {
                                  return " active";
                              };
                              return "";
                          })(),
                          on: {
                              click: function (v2) {
                                  return Toestand_Classes.write_(Toestand_Boxes.writeBox)(tab)(v.sideTab);
                              }
                          }
                      })([ Reactix_DOM_HTML.text(Data_Show.show(Gargantext_Components_GraphExplorer_Types["$_ShowSideTab_82"])(tab)) ]);
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_GraphExplorer_Types["$_EqSideTab_81"]))(v.sideTab))(function (sideTab$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ Reactix_DOM_HTML.div({
                      className: "text-primary center"
                  })([ Reactix_DOM_HTML.text("") ]), Reactix_DOM_HTML.div({
                      className: "nav nav-tabs"
                  })(Data_Functor.map(Data_Functor.functorArray)(liItem(sideTab$prime))(v.sideTabs)) ]));
              });
          };
      };
      return here.component("sideTabNav")(cpt);
  })();
  var sideTabNav = Reactix_React.createElement(Reactix_React.componentIsComponent)(sideTabNavCpt);
  var documentation = function (v) {
      var ul = function (ts) {
          return Reactix_DOM_HTML.ul({})(Data_Functor.map(Data_Functor.functorArray)(function (t) {
              return Reactix_DOM_HTML.li({})([ Reactix_DOM_HTML.text(t) ]);
          })(ts));
      };
      return Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.h2({})([ Reactix_DOM_HTML.text("What is Graph ?") ]), ul([ "Graph is a conveniant tool to explore your documents. ", "Nodes are terms selected in your Map List. " + "Node size is proportional to the number of documents with the associated term. ", "Edges between nodes represent proximities of terms according to a specific distance between your documents. " + "Link strength is proportional to the strenght of terms association." ]), Reactix_DOM_HTML.h3({})([ Reactix_DOM_HTML.text("Basic Interactions:") ]), ul([ "Click on a node to select/unselect and get its information. ", "In case of multiple selection, the button unselect clears all selections. " + "Use your mouse scroll to zoom in and out in the graph. ", "Use the node filter to create a subgraph with nodes of a given size " + "range (e.g. display only generic terms). ", "Use the edge filter so create a subgraph with links in a given range (e.g. keep the strongest association)." ]) ]);
  };
  var sideTabLegendCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([ Gargantext_Components_GraphExplorer_Legend.legend({
                  items: Data_Sequence.fromFoldable(Data_Foldable.foldableArray)(v.metaData.legend)
              }), documentation(Gargantext_Components_Lang.EN.value) ]));
          };
      };
      return here.component("sideTabLegend")(cpt);
  })();
  var sideTabLegend = Reactix_React.createElement(Reactix_React.componentIsComponent)(sideTabLegendCpt);
  var deleteNode = function (termList) {
      return function (session) {
          return function (v) {
              return function (node) {
                  var tabNgramType = Gargantext_Types.modeTabType(node.gargType);
                  var tabType = new Gargantext_Types.TabCorpus(new Gargantext_Types.TabNgramType(tabNgramType));
                  var term = Gargantext_Components_NgramsTable_Core.normNgram(tabNgramType)(node.label);
                  var patch_list = new Gargantext_Components_NgramsTable_Core.Replace({
                      "new": termList,
                      old: Gargantext_Types.MapTerm.value
                  });
                  var np = Gargantext_Components_NgramsTable_Core.singletonPatchMap(term)(new Gargantext_Components_NgramsTable_Core.NgramsPatch({
                      patch_children: Data_Monoid.mempty(Gargantext_Components_NgramsTable_Core["$_MonoidPatchSet_198"](Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])),
                      patch_list: patch_list
                  }));
                  var pt = Gargantext_Components_NgramsTable_Core.fromNgramsPatches(np);
                  var versioned = {
                      version: v.list.version,
                      data: np
                  };
                  var nodeId = Data_Maybe.fromJust()(Data_Int.fromString(node.id));
                  var coreParams = {
                      session: session,
                      nodeId: nodeId,
                      listIds: [ v.list.listId ],
                      tabType: tabType
                  };
                  return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_NgramsTable_Core.putNgramsPatches(coreParams)(versioned))(function (ret) {
                      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_NgramsTable_Core.postNgramsChartsAsync(coreParams))(function (task) {
                          return Control_Applicative.pure(Effect_Aff.applicativeAff)(ret);
                      });
                  });
              };
          };
      };
  };
  var deleteNodes = function (v) {
      return Effect_Aff.launchAff_(Control_Bind.bind(Effect_Aff.bindAff)(Control_Parallel.parTraverse(Effect_Aff.parallelAff)(Data_Traversable.traversableArray)(deleteNode(v.termList)(v.session)(v.metaData))(v.nodes))(function (patches) {
          var mPatch = Data_Array.last(patches);
          if (mPatch instanceof Data_Maybe.Nothing) {
              return Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Unit.unit);
          };
          if (mPatch instanceof Data_Maybe.Just) {
              return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(v.reloadForest));
          };
          throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.Sidebar (line 326, column 5 - line 329, column 44): " + [ mPatch.constructor.name ]);
      }));
  };
  var removeButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onClickRemove = function (selectedNodeIds$prime) {
                  return function (e) {
                      var nodes = Gargantext_Data_Array.mapMaybe(function (id) {
                          return Data_Map_Internal.lookup(Data_Ord.ordString)(id)(v.nodesMap);
                      })(Data_Set.toUnfoldable(Data_Unfoldable.unfoldableArray)(selectedNodeIds$prime));
                      return function __do() {
                          deleteNodes({
                              graphId: v.graphId,
                              metaData: v.metaData,
                              nodes: nodes,
                              session: v.session,
                              termList: v.rType,
                              reloadForest: v.reloadForest
                          })();
                          Toestand_Classes.write_(Toestand_Boxes.writeBox)(selectedNodeIds$prime)(v.removedNodeIds)();
                          return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Hooks_Sigmax_Types.emptyNodeIds)(v.selectedNodeIds)();
                      };
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Set.eqSet(Data_Eq.eqString)))(v.selectedNodeIds))(function (selectedNodeIds$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)((function () {
                      var $66 = Data_Set.isEmpty(selectedNodeIds$prime);
                      if ($66) {
                          return Reactix_DOM_HTML.div({})([  ]);
                      };
                      return Reactix_DOM_HTML.button({
                          className: "btn btn-sm btn-" + v.buttonType,
                          on: {
                              click: onClickRemove(selectedNodeIds$prime)
                          }
                      })([ Reactix_DOM_HTML.text(v.text) ]);
                  })());
              });
          };
      };
      return here.component("removeButton")(cpt);
  })();
  var removeButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(removeButtonCpt);
  var badges = function (graph) {
      return function (selectedNodeIds) {
          return Gargantext_Hooks_Sigmax_Types.graphNodes(Gargantext_Hooks_Sigmax_Types.nodesById(graph)(selectedNodeIds));
      };
  };
  var badge = function (selectedNodeIds) {
      return function (v) {
          var onClick = function (e) {
              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Set.singleton(v.id))(selectedNodeIds);
          };
          return Reactix_DOM_HTML.a({
              className: "badge badge-pill badge-light",
              on: {
                  click: onClick
              }
          })([ Reactix_DOM_HTML.h6({})([ Reactix_DOM_HTML.text(v.label) ]) ]);
      };
  };
  var neighborhoodCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Set.eqSet(Data_Eq.eqString)))(v.selectedNodeIds))(function (selectedNodeIds$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "tab-content",
                      id: "myTabContent"
                  })([ Reactix_DOM_HTML.div({
                      className: "d-flex flex-wrap flex-space-around",
                      id: "home",
                      role: "tabpanel"
                  })(Data_Sequence.toUnfoldable(Data_Functor.functorArray)(Data_Unfoldable.unfoldableArray)(Data_Sequence.map(badge(v.selectedNodeIds))(neighbourBadges(v.graph)(selectedNodeIds$prime)))) ]));
              });
          };
      };
      return here.component("neighborhood")(cpt);
  })();
  var neighborhood = Reactix_React.createElement(Reactix_React.componentIsComponent)(neighborhoodCpt);
  var selectedNodesCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var commonProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "graphId";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "metaData";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reloadForest";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "removedNodeIds";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "selectedNodeIds";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "session";
              }))(Record_Extra.nilKeys)))))))(v);
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Set.eqSet(Data_Eq.eqString)))(v.selectedNodeIds))(function (selectedNodeIds$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Utils_Reactix.row([ Gargantext_Utils_Reactix.col(12)([ Reactix_DOM_HTML.ul({
                      className: "nav nav-tabs d-flex justify-content-center",
                      id: "myTab",
                      role: "tablist"
                  })([ Reactix_DOM_HTML.div({
                      className: "tab-content"
                  })([ Reactix_DOM_HTML.div({
                      className: "d-flex flex-wrap justify-content-center",
                      role: "tabpanel"
                  })(Data_Sequence.toUnfoldable(Data_Functor.functorArray)(Data_Unfoldable.unfoldableArray)(Data_Sequence.map(badge(v.selectedNodeIds))(badges(v.graph)(selectedNodeIds$prime)))), Reactix_DOM_HTML.br({}) ]) ]), Reactix_DOM_HTML.div({
                      className: "tab-content flex-space-between"
                  })([ removeButton(Record.merge()()({
                      buttonType: "primary",
                      rType: Gargantext_Types.CandidateTerm.value,
                      nodesMap: v.nodesMap,
                      text: "Move as candidate"
                  })(commonProps))([  ]), Reactix_DOM_HTML.br({}), removeButton(Record.merge()()({
                      buttonType: "danger",
                      nodesMap: v.nodesMap,
                      rType: Gargantext_Types.StopTerm.value,
                      text: "Move as stop"
                  })(commonProps))([  ]) ]) ]) ]));
              });
          };
      };
      return here.component("selectedNodes")(cpt);
  })();
  var selectedNodes = Reactix_React.createElement(Reactix_React.componentIsComponent)(selectedNodesCpt);
  var sideTabCommunityCpt = (function () {
      var cpt = function (props) {
          return function (v) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Set.eqSet(Data_Eq.eqString)))(props.selectedNodeIds))(function (selectedNodeIds$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "col-md-12",
                      id: "query"
                  })([ selectedNodes(Record.merge()()({
                      nodesMap: Gargantext_Hooks_Sigmax_Types.nodesGraphMap(props.graph)
                  })(props))([  ]), neighborhood(props)([  ]), query({
                      frontends: props.frontends,
                      metaData: props.metaData,
                      nodesMap: Gargantext_Hooks_Sigmax_Types.nodesGraphMap(props.graph),
                      searchType: Gargantext_Components_Search.SearchContact.value,
                      selectedNodeIds: selectedNodeIds$prime,
                      session: props.session
                  })([  ]) ]));
              });
          };
      };
      return here.component("sideTabCommunity")(cpt);
  })();
  var sideTabCommunity = Reactix_React.createElement(Reactix_React.componentIsComponent)(sideTabCommunityCpt);
  var sideTabDataCpt = (function () {
      var cpt = function (props) {
          return function (v) {
              var checkbox = function (text) {
                  return Reactix_DOM_HTML.li({})([ Reactix_DOM_HTML.span({})([ Reactix_DOM_HTML.text(text) ]), Reactix_DOM_HTML.input({
                      type: "checkbox",
                      className: "checkbox",
                      defaultChecked: true,
                      title: "Mark as completed"
                  }) ]);
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Set.eqSet(Data_Eq.eqString)))(props.selectedNodeIds))(function (selectedNodeIds$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([ selectedNodes(Record.merge()()({
                      nodesMap: Gargantext_Hooks_Sigmax_Types.nodesGraphMap(props.graph)
                  })(props))([  ]), neighborhood(props)([  ]), Reactix_DOM_HTML.div({
                      className: "col-md-12",
                      id: "query"
                  })([ query({
                      frontends: props.frontends,
                      metaData: props.metaData,
                      nodesMap: Gargantext_Hooks_Sigmax_Types.nodesGraphMap(props.graph),
                      searchType: Gargantext_Components_Search.SearchDoc.value,
                      selectedNodeIds: selectedNodeIds$prime,
                      session: props.session
                  })([  ]) ]) ]));
              });
          };
      };
      return here.component("sideTabData")(cpt);
  })();
  var sideTabData = Reactix_React.createElement(Reactix_React.componentIsComponent)(sideTabDataCpt);
  var sidebarCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sideTabProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "frontends";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "graph";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "graphId";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "graphVersion";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "metaData";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reloadForest";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "removedNodeIds";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "selectedNodeIds";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "session";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sideTab";
              }))(Record_Extra.nilKeys)))))))))))(v);
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_GraphExplorer_Types["$_EqSideTab_81"]))(v.sideTab))(function (sideTab$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      id: "sp-container"
                  })([ sideTabNav({
                      sideTab: v.sideTab,
                      sideTabs: [ Gargantext_Components_GraphExplorer_Types.SideTabLegend.value, Gargantext_Components_GraphExplorer_Types.SideTabData.value, Gargantext_Components_GraphExplorer_Types.SideTabCommunity.value ]
                  })([  ]), (function () {
                      if (sideTab$prime instanceof Gargantext_Components_GraphExplorer_Types.SideTabLegend) {
                          return sideTabLegend(sideTabProps)([  ]);
                      };
                      if (sideTab$prime instanceof Gargantext_Components_GraphExplorer_Types.SideTabData) {
                          return sideTabData(sideTabProps)([  ]);
                      };
                      if (sideTab$prime instanceof Gargantext_Components_GraphExplorer_Types.SideTabCommunity) {
                          return sideTabCommunity(sideTabProps)([  ]);
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.Sidebar (line 72, column 11 - line 75, column 69): " + [ sideTab$prime.constructor.name ]);
                  })() ]));
              });
          };
      };
      return here.component("sidebar")(cpt);
  })();
  var sidebar = Reactix_React.createElement(Reactix_React.componentIsComponent)(sidebarCpt);
  exports["sidebar"] = sidebar;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.InputWithAutocomplete"] = $PS["Gargantext.Components.InputWithAutocomplete"] || {};
  var exports = $PS["Gargantext.Components.InputWithAutocomplete"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var DOM_Simple_Event = $PS["DOM.Simple.Event"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Timer = $PS["Effect.Timer"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.InputWithAutocomplete");
  var completionsCptCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onClick = function (c) {
                  return function (v2) {
                      return function __do() {
                          Toestand_Classes.write_(Toestand_Boxes.writeBox)(c)(v.state)();
                          return v.onAutocompleteClick(c)();
                      };
                  };
              };
              var cCpt = function (c) {
                  return Reactix_DOM_HTML.button({
                      type: "button",
                      className: "list-group-item",
                      on: {
                          click: onClick(c)
                      }
                  })([ Reactix_DOM_HTML.text(c) ]);
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqArray(Data_Eq.eqString)))(v.completions))(function (completions$prime) {
                  var className = "completions " + (function () {
                      var $7 = Data_Eq.eq(Data_Eq.eqArray(Data_Eq.eqString))(completions$prime)([  ]);
                      if ($7) {
                          return "d-none";
                      };
                      return "";
                  })();
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: className
                  })([ Reactix_DOM_HTML.div({
                      className: "list-group"
                  })(Data_Functor.map(Data_Functor.functorArray)(cCpt)(completions$prime)) ]));
              });
          };
      };
      return here.component("completionsCpt")(cpt);
  })();
  var completionsCpt = Reactix_React.createElement(Reactix_React.componentIsComponent)(completionsCptCpt);
  var inputWithAutocompleteCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onInputKeyUp = function (inputRef) {
                  return function (e) {
                      var $13 = DOM_Simple_Event.key(e) === "Enter";
                      if ($13) {
                          var val = Reactix_SyntheticEvent.unsafeEventValue(e);
                          var mInput = Data_Nullable.toMaybe(Reactix_React.readRef(inputRef));
                          return function __do() {
                              Toestand_Classes.write_(Toestand_Boxes.writeBox)(val)(v.state)();
                              v.onEnterPress(val)();
                              if (mInput instanceof Data_Maybe.Nothing) {
                                  return Data_Unit.unit;
                              };
                              if (mInput instanceof Data_Maybe.Just) {
                                  return Gargantext_Utils_Reactix.blur(mInput.value0)();
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.InputWithAutocomplete (line 87, column 13 - line 89, column 42): " + [ mInput.constructor.name ]);
                          };
                      };
                      return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                  };
              };
              var onInput = function (completions) {
                  return function (e) {
                      var val = Reactix_SyntheticEvent.unsafeEventValue(e);
                      return function __do() {
                          Toestand_Classes.write_(Toestand_Boxes.writeBox)(val)(v.state)();
                          return Toestand_Classes.write_(Toestand_Boxes.writeBox)(v.autocompleteSearch(val))(completions)();
                      };
                  };
              };
              var onBlur = function (completions) {
                  return function (e) {
                      return Effect_Timer.setTimeout(100)(Toestand_Classes.write_(Toestand_Boxes.writeBox)([  ])(completions));
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqString))(v.state))(function (state$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (inputRef) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(v.autocompleteSearch(state$prime)))(function (completions) {
                          var onFocus = function (completions1) {
                              return function (e) {
                                  return Toestand_Classes.write_(Toestand_Boxes.writeBox)(v.autocompleteSearch(state$prime))(completions1);
                              };
                          };
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.span({
                              className: "input-with-autocomplete " + v.classes
                          })([ completionsCpt({
                              completions: completions,
                              onAutocompleteClick: v.onAutocompleteClick,
                              state: v.state
                          })([  ]), Reactix_DOM_HTML.input({
                              type: "text",
                              ref: inputRef,
                              className: "form-control",
                              value: state$prime,
                              on: {
                                  blur: onBlur(completions),
                                  focus: onFocus(completions),
                                  input: onInput(completions),
                                  change: onInput(completions),
                                  keyUp: onInputKeyUp(inputRef)
                              }
                          }) ]));
                      });
                  });
              });
          };
      };
      return here.component("inputWithAutocomplete")(cpt);
  })();
  var inputWithAutocomplete = Reactix_React.createElement(Reactix_React.componentIsComponent)(inputWithAutocompleteCpt);
  exports["inputWithAutocomplete"] = inputWithAutocomplete;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.Search"] = $PS["Gargantext.Components.GraphExplorer.Search"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.Search"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Set = $PS["Data.Set"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Gargantext_Components_InputWithAutocomplete = $PS["Gargantext.Components.InputWithAutocomplete"];
  var Gargantext_Hooks_Sigmax_Types = $PS["Gargantext.Hooks.Sigmax.Types"];
  var Gargantext_Utils = $PS["Gargantext.Utils"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var nodeMatchesSearch = function (s) {
      return function (n) {
          return Gargantext_Utils.queryMatchesLabel(s)(n.label);
      };
  };
  var searchNodes = function (v) {
      return function (v1) {
          if (v === "") {
              return Data_Sequence.empty;
          };
          return Data_Sequence.filter(nodeMatchesSearch(v))(v1);
      };
  };
  var triggerSearch = function (graph) {
      return function (search) {
          return function (multiSelectEnabled) {
              return function (selectedNodeIds) {
                  var graphNodes = Gargantext_Hooks_Sigmax_Types.graphNodes(graph);
                  var matching = Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Data_Ord.ordString)(Data_Functor.map(Data_Sequence.functorSeq)(function (v) {
                      return v.id;
                  })(searchNodes(search)(graphNodes)));
                  return function __do() {
                      DOM_Simple_Console.log2("[triggerSearch] search")(search)();
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (nodes) {
                          return Data_Set.union(Data_Ord.ordString)(matching)((function () {
                              if (multiSelectEnabled) {
                                  return nodes;
                              };
                              return Gargantext_Hooks_Sigmax_Types.emptyNodeIds;
                          })());
                      })(selectedNodeIds)();
                  };
              };
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.GraphExplorer.Search");
  var autocompleteSearch = function (graph) {
      return function (s) {
          var nodes = Gargantext_Hooks_Sigmax_Types.graphNodes(graph);
          return Data_Sequence.toUnfoldable(Data_Functor.functorArray)(Data_Unfoldable.unfoldableArray)(Data_Functor.map(Data_Sequence.functorSeq)(function (v) {
              return v.label;
          })(searchNodes(s)(nodes)));
      };
  };
  var sizeButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(""))(function (search) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqString))(search))(function (search$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.multiSelectEnabled))(function (multiSelectEnabled$prime) {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ Gargantext_Components_InputWithAutocomplete.inputWithAutocomplete({
                              autocompleteSearch: autocompleteSearch(v.graph),
                              classes: "mx-2",
                              onAutocompleteClick: function (s) {
                                  return triggerSearch(v.graph)(s)(multiSelectEnabled$prime)(v.selectedNodeIds);
                              },
                              onEnterPress: function (s) {
                                  return triggerSearch(v.graph)(s)(multiSelectEnabled$prime)(v.selectedNodeIds);
                              },
                              state: search
                          })([  ]), Reactix_DOM_HTML.div({
                              className: "btn input-group-addon",
                              on: {
                                  click: function (v2) {
                                      return triggerSearch(v.graph)(search$prime)(multiSelectEnabled$prime)(v.selectedNodeIds);
                                  }
                              }
                          })([ Reactix_DOM_HTML.span({
                              className: "fa fa-search"
                          })([  ]) ]) ]));
                      });
                  });
              });
          };
      };
      return here.component("nodeSearchControl")(cpt);
  })();
  var nodeSearchControl = Reactix_React.createElement(Reactix_React.componentIsComponent)(sizeButtonCpt);
  exports["nodeSearchControl"] = nodeSearchControl;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.GraphExplorer.TopBar"] = $PS["Gargantext.Components.GraphExplorer.TopBar"] || {};
  var exports = $PS["Gargantext.Components.GraphExplorer.TopBar"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_GraphExplorer_Search = $PS["Gargantext.Components.GraphExplorer.Search"];
  var Gargantext_Components_GraphExplorer_Sidebar_Types = $PS["Gargantext.Components.GraphExplorer.Sidebar.Types"];
  var Gargantext_Components_GraphExplorer_ToggleButton = $PS["Gargantext.Components.GraphExplorer.ToggleButton"];
  var Gargantext_Components_GraphExplorer_Types = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Gargantext_Hooks_Sigmax_Types = $PS["Gargantext.Hooks.Sigmax.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.GraphExplorer.TopBar");
  var topBarCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var spaces = Reactix_DOM_HTML.a({
                  className: "nav-link"
              });
              var rowToggle = Reactix_DOM_HTML.ul({
                  className: "navbar-nav ml-auto mr-auto"
              });
              var col = Reactix_DOM_HTML.li({
                  className: "nav-item"
              });
              return Control_Bind.bind(Reactix_React.bindHooks)(Gargantext_Components_GraphExplorer_Sidebar_Types.focusedSidePanel(v.boxes.sidePanelGraph))(function (v2) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Gargantext_Hooks_Sigmax_Types["$_EqGraph_32"](Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "y";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "x";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "type";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "size";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "label";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "id";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "hidden";
                  }))(Data_Eq.eqBoolean))()(new Data_Symbol.IsSymbol(function () {
                      return "gargType";
                  }))(Gargantext_Types["$_EqMode_154"]))()(new Data_Symbol.IsSymbol(function () {
                      return "equilateral";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "numPoints";
                  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                      return "color";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "borderColor";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "_original";
                  }))(Gargantext_Components_GraphExplorer_Types["$_EqNode_43"])))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "weightIdx";
                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                      return "weight";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "targetNode";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "y";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "x";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "type";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "size";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "label";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "id";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "hidden";
                  }))(Data_Eq.eqBoolean))()(new Data_Symbol.IsSymbol(function () {
                      return "gargType";
                  }))(Gargantext_Types["$_EqMode_154"]))()(new Data_Symbol.IsSymbol(function () {
                      return "equilateral";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "numPoints";
                  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                      return "color";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "borderColor";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "_original";
                  }))(Gargantext_Components_GraphExplorer_Types["$_EqNode_43"]))))()(new Data_Symbol.IsSymbol(function () {
                      return "target";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "sourceNode";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "y";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "x";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "type";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "size";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "label";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "id";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "hidden";
                  }))(Data_Eq.eqBoolean))()(new Data_Symbol.IsSymbol(function () {
                      return "gargType";
                  }))(Gargantext_Types["$_EqMode_154"]))()(new Data_Symbol.IsSymbol(function () {
                      return "equilateral";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "numPoints";
                  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                      return "color";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "borderColor";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "_original";
                  }))(Gargantext_Components_GraphExplorer_Types["$_EqNode_43"]))))()(new Data_Symbol.IsSymbol(function () {
                      return "source";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "size";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "id";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "hidden";
                  }))(Data_Eq.eqBoolean))()(new Data_Symbol.IsSymbol(function () {
                      return "confluence";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "color";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "_original";
                  }))(Gargantext_Components_GraphExplorer_Types["$_EqEdge_54"]))))))(v2.mGraph))(function (mGraph$prime) {
                      var search = (function () {
                          if (mGraph$prime instanceof Data_Maybe.Just) {
                              return Gargantext_Components_GraphExplorer_Search.nodeSearchControl({
                                  graph: mGraph$prime.value0,
                                  multiSelectEnabled: v2.multiSelectEnabled,
                                  selectedNodeIds: v2.selectedNodeIds
                              })([  ]);
                          };
                          if (mGraph$prime instanceof Data_Maybe.Nothing) {
                              return Reactix_DOM_HTML.div({})([  ]);
                          };
                          throw new Error("Failed pattern match at Gargantext.Components.GraphExplorer.TopBar (line 35, column 18 - line 39, column 34): " + [ mGraph$prime.constructor.name ]);
                      })();
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.form({
                          className: "d-flex"
                      })([ Gargantext_Components_GraphExplorer_ToggleButton.controlsToggleButton({
                          state: v2.showControls
                      })([  ]), Gargantext_Components_GraphExplorer_ToggleButton.sidebarToggleButton({
                          state: v.boxes.sidePanelState
                      })([  ]), search ]));
                  });
              });
          };
      };
      return here.component("topBar")(cpt);
  })();
  var topBar = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(topBarCpt)(p)([  ]);
  };
  exports["topBar"] = topBar;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Forms"] = $PS["Gargantext.Components.Forms"] || {};
  var exports = $PS["Gargantext.Components.Forms"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];                
  var formGroup = Reactix_DOM_HTML.div({
      className: "form-group"
  });
  var clearfix = Reactix_DOM_HTML.div({
      className: "clearfix"
  })([  ]);
  exports["clearfix"] = clearfix;
  exports["formGroup"] = formGroup;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Type.Data.RowList"] = $PS["Type.Data.RowList"] || {};
  var exports = $PS["Type.Data.RowList"];
  var RLProxy = (function () {
      function RLProxy() {

      };
      RLProxy.value = new RLProxy();
      return RLProxy;
  })();
  exports["RLProxy"] = RLProxy;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Toestand.Records"] = $PS["Toestand.Records"] || {};
  var exports = $PS["Toestand.Records"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Category = $PS["Control.Category"];
  var Control_Semigroupoid = $PS["Control.Semigroupoid"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Record_Builder = $PS["Record.Builder"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Type_Data_RowList = $PS["Type.Data.RowList"];                
  var UseFocusedFields = function (useFocusedFieldsImpl) {
      this.useFocusedFieldsImpl = useFocusedFieldsImpl;
  };
  var useFocusedFieldsImpl = function (dict) {
      return dict.useFocusedFieldsImpl;
  };
  var useFocusedFields = function (dictRowToList) {
      return function (dictReadWrite) {
          return function (dictUseFocusedFields) {
              return function (box) {
                  return function (base) {
                      return Data_Functor.map(Reactix_React.functorHooks)(function (b) {
                          return Record_Builder.build(b)(base);
                      })(useFocusedFieldsImpl(dictUseFocusedFields)(Type_Data_RowList.RLProxy.value)(box));
                  };
              };
          };
      };
  };
  var nilUseFocusedFields = new UseFocusedFields(function (v) {
      return function (v1) {
          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Control_Category.identity(Record_Builder.categoryBuilder));
      };
  });
  var consUseFocusedFields = function (dictReadWrite) {
      return function (dictCons) {
          return function (dictCons1) {
              return function (dictLacks) {
                  return function (dictUseFocusedFields) {
                      return new UseFocusedFields(function (v) {
                          return function (box) {
                              var rest = useFocusedFieldsImpl(dictUseFocusedFields)(Type_Data_RowList.RLProxy.value)(box);
                              var step = function (box$prime) {
                                  return function (next) {
                                      return Control_Semigroupoid.compose(Record_Builder.semigroupoidBuilder)(Record_Builder.insert()()((dictCons.Lacks0()).IsSymbol0())(Data_Symbol.SProxy.value)(box$prime))(next);
                                  };
                              };
                              var useFocus = (function () {
                                  var write = Record.set((dictCons.Lacks0()).IsSymbol0())()()(Data_Symbol.SProxy.value);
                                  var read = Record.get((dictCons.Lacks0()).IsSymbol0())()(Data_Symbol.SProxy.value);
                                  return Toestand_Boxes.useFocused(dictReadWrite)(read)(write)(box);
                              })();
                              return Control_Apply.apply(Reactix_React.applyHooks)(Data_Functor.map(Reactix_React.functorHooks)(step)(useFocus))(rest);
                          };
                      });
                  };
              };
          };
      };
  };
  exports["useFocusedFields"] = useFocusedFields;
  exports["nilUseFocusedFields"] = nilUseFocusedFields;
  exports["consUseFocusedFields"] = consUseFocusedFields;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Login.Form"] = $PS["Gargantext.Components.Login.Form"] || {};
  var exports = $PS["Gargantext.Components.Login.Form"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Either = $PS["Data.Either"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Formula = $PS["Formula"];
  var Gargantext_Components_Forms = $PS["Gargantext.Components.Forms"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Utils = $PS["Gargantext.Utils"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var Toestand_Records = $PS["Toestand.Records"];
  var Typisch_Row = $PS["Typisch.Row"];                
  var usernameInput = function (dictReadWrite) {
      return function (value) {
          return Formula.bindInput(dictReadWrite)(Typisch_Row.cons2(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "on";
          }))())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "defaultValue";
          }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "on";
          }))())()))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "value";
          }))())())({
              value: value,
              type: "text",
              className: "form-control",
              id: "id_username",
              placeholder: "username",
              name: "username",
              maxLength: "254"
          });
      };
  };
  var termsCheckbox = function (dictReadWrite) {
      return function (checked) {
          return Reactix_DOM_HTML.div({
              className: "form-group form-check text-center"
          })([ Formula.bindCheckbox(dictReadWrite)(Typisch_Row.cons3(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "on";
          }))())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "type";
          }))())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "checked";
          }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "on";
          }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "type";
          }))())()))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "checked";
          }))())())({
              checked: checked,
              className: "form-check-input"
          }), Reactix_DOM_HTML.label({
              className: "form-check-label"
          })([ Reactix_DOM_HTML.text("I hereby accept the "), Reactix_DOM_HTML.a({
              target: "_blank",
              href: "http://gitlab.iscpif.fr/humanities/tofu/tree/master"
          })([ Reactix_DOM_HTML.text("terms of use") ]) ]) ]);
      };
  };
  var submitForm = function (dictReadWrite) {
      return function (dictWrite) {
          return function (v) {
              return function (cell) {
                  return function (e) {
                      var req = function (v1) {
                          return {
                              username: v1.username,
                              password: v1.password
                          };
                      };
                      return function __do() {
                          Reactix_SyntheticEvent.preventDefault()(e)();
                          var state = Toestand_Classes.read(Toestand_Boxes.readBox)(Reactix_React.monadDelayEffect)(cell)();
                          return Effect_Aff.launchAff_(Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.postAuthRequest(v.backend)(req(state)))(function (res) {
                              if (res instanceof Data_Either.Left) {
                                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write(Toestand_Boxes.writeBox)((function () {
                                      var $29 = {};
                                      for (var $30 in state) {
                                          if ({}.hasOwnProperty.call(state, $30)) {
                                              $29[$30] = state[$30];
                                          };
                                      };
                                      $29.error = res.value0;
                                      return $29;
                                  })())(cell));
                              };
                              if (res instanceof Data_Either.Right) {
                                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Control_Apply.applySecond(Effect.applyEffect)(Control_Apply.applySecond(Effect.applyEffect)(Gargantext_Sessions.change(dictReadWrite.Read0())(dictReadWrite.Write1())(new Gargantext_Sessions.Login(res.value0))(v.sessions))(Toestand_Classes.write(dictWrite)(false)(v.visible)))(Toestand_Classes.write(Toestand_Boxes.writeBox)((function () {
                                      var $33 = {};
                                      for (var $34 in state) {
                                          if ({}.hasOwnProperty.call(state, $34)) {
                                              $33[$34] = state[$34];
                                          };
                                      };
                                      $33.error = "";
                                      return $33;
                                  })())(cell)));
                              };
                              throw new Error("Failed pattern match at Gargantext.Components.Login.Form (line 111, column 5 - line 117, column 49): " + [ res.constructor.name ]);
                          }))();
                      };
                  };
              };
          };
      };
  };
  var requestAccessLink = Reactix_DOM_HTML.div({
      className: "text-center"
  })([ Reactix_DOM_HTML.a({
      href: "https://iscpif.fr/apply-for-a-services-account/",
      target: "_blank"
  })([ Reactix_DOM_HTML.text("request access") ]) ]);
  var passwordInput = function (dictReadWrite) {
      return function (value) {
          return Formula.bindInput(dictReadWrite)(Typisch_Row.cons2(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "on";
          }))())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "defaultValue";
          }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "on";
          }))())()))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
              return "value";
          }))())())({
              value: value,
              type: "password",
              className: "form-control",
              name: "password",
              placeholder: "password",
              id: "id_password"
          });
      };
  };
  var loginSubmit = function (click) {
      return Reactix_DOM_HTML.button({
          id: "login-button",
          className: "btn btn-primary btn-rounded",
          type: "submit",
          on: {
              click: click
          }
      })([ Reactix_DOM_HTML.text("Login") ]);
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Login.Form");
  var submitButtonCpt = function (dictReadWrite) {
      return function (dictWrite) {
          var cpt = function (v) {
              return function (v1) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "username";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "password";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "error";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "agreed";
                  }))(Data_Eq.eqBoolean))))(v.cell))(function (v2) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)((function () {
                          var $43 = v2.agreed && (v2.username !== "" && v2.password !== "");
                          if ($43) {
                              return Reactix_DOM_HTML.div({
                                  className: "text-center"
                              })([ loginSubmit(submitForm(dictReadWrite)(dictWrite)({
                                  backend: v.backend,
                                  sessions: v.sessions,
                                  visible: v.visible
                              })(v.cell)) ]);
                          };
                          return Reactix_DOM_HTML.div({})([  ]);
                      })());
                  });
              };
          };
          return here.component("submitButton")(cpt);
      };
  };
  var submitButton = function (dictReadWrite) {
      return function (dictWrite) {
          return function (props) {
              return Reactix_React.createElement(Reactix_React.componentIsComponent)(submitButtonCpt(dictReadWrite)(dictWrite))(props)([  ]);
          };
      };
  };
  var formLoginLink = function (backend) {
      return Reactix_DOM_HTML.h4({
          className: "text-center"
      })([ Reactix_DOM_HTML.text("Login to garg://" + Data_Show.show(Gargantext_Ends["$_ShowBackend_26"])(backend)) ]);
  };
  var emptyForm = {
      error: "",
      username: "",
      password: "",
      agreed: false
  };
  var csrfTokenInput = Reactix_DOM_HTML.input({
      type: "hidden",
      name: "csrfmiddlewaretoken",
      value: Gargantext_Utils.csrfMiddlewareToken
  });
  var formCpt = function (dictReadWrite) {
      return function (dictReadWrite1) {
          var cpt = function (v) {
              return function (v1) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(emptyForm))(function (cell) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Records.useFocusedFields()(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "agreed";
                      }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "agreed";
                      }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "agreed";
                      }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "error";
                      }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "error";
                      }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "error";
                      }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "password";
                      }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "password";
                      }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "password";
                      }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "username";
                      }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "username";
                      }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                          return "username";
                      }))())(Toestand_Records.nilUseFocusedFields)))))(cell)({}))(function (cursors) {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.form({
                              className: "col-md-12"
                          })([ formLoginLink(v.backend), requestAccessLink, csrfTokenInput, Gargantext_Components_Forms.formGroup([ Reactix_DOM_HTML.p({})([ Formula.viewText(Toestand_Boxes.readBox)({
                              text: cursors.error
                          }) ]), usernameInput(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(cursors.username) ]), Gargantext_Components_Forms.formGroup([ passwordInput(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(cursors.password), Gargantext_Components_Forms.clearfix ]), termsCheckbox(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(cursors.agreed), submitButton(dictReadWrite)(dictReadWrite1.Write1())({
                              backend: v.backend,
                              sessions: v.sessions,
                              visible: v.visible,
                              cell: cell
                          }) ]) ]));
                      });
                  });
              };
          };
          return here.component("form")(cpt);
      };
  };
  var form = function (dictReadWrite) {
      return function (dictReadWrite1) {
          return function (props) {
              return Reactix_React.createElement(Reactix_React.componentIsComponent)(formCpt(dictReadWrite)(dictReadWrite1))(props)([  ]);
          };
      };
  };
  exports["form"] = form;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Login.Modal"] = $PS["Gargantext.Components.Login.Modal"] || {};
  var exports = $PS["Gargantext.Components.Login.Modal"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Effect = $PS["Effect"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Login.Modal");
  var modalCpt = function (dictReadWrite) {
      var cpt = function (v) {
          return function (children) {
              var modalClass = function (s) {
                  return "modal myModal" + (function () {
                      if (s) {
                          return "";
                      };
                      return " fade";
                  })();
              };
              var click = function (v1) {
                  return Control_Apply.applyFirst(Effect.applyEffect)(here.log("click!"))(Toestand_Classes.write(dictReadWrite.Write1())(false)(v.visible));
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(dictReadWrite.Read0())(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.visible))(function (v1) {
                  return Data_Functor.map(Reactix_React.functorHooks)(Reactix_React.createPortal([ Reactix_DOM_HTML.div({
                      id: "loginModal",
                      className: modalClass(v1),
                      key: 0,
                      role: "dialog",
                      data: {
                          show: true
                      },
                      style: {
                          display: "block"
                      }
                  })([ Reactix_DOM_HTML.div({
                      className: "modal-dialog modal-lg",
                      role: "document"
                  })([ Reactix_DOM_HTML.div({
                      className: "modal-content"
                  })([ Reactix_DOM_HTML.div({
                      className: "modal-header"
                  })([ Reactix_DOM_HTML.div({
                      className: "col-md-10 col-md-push-1"
                  })([ Reactix_DOM_HTML.h2({
                      className: "text-primary center m-a-2"
                  })([ Reactix_DOM_HTML.span({
                      className: "icon-text"
                  })([ Reactix_DOM_HTML.text("GarganText") ]) ]) ]), Reactix_DOM_HTML.button({
                      type: "button",
                      className: "close",
                      data: {
                          dismiss: "modal"
                      }
                  })([ Reactix_DOM_HTML.a({
                      on: {
                          click: click
                      },
                      className: "btn fa fa-times"
                  })([  ]) ]) ]), Reactix_DOM_HTML.div({
                      className: "modal-body"
                  })(children) ]) ]) ]) ]))(Gargantext_Utils_Reactix.getPortalHost);
              });
          };
      };
      return here.component("modal")(cpt);
  };
  var modal = function (dictReadWrite) {
      return function (props) {
          return function (child) {
              return Reactix_React.createElement(Reactix_React.componentIsComponent)(modalCpt(dictReadWrite))(props)([ child ]);
          };
      };
  };
  exports["modal"] = modal;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.NgramsTable.Loader"] = $PS["Gargantext.Components.NgramsTable.Loader"] || {};
  var exports = $PS["Gargantext.Components.NgramsTable.Loader"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Error_Class = $PS["Control.Monad.Error.Class"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Effect_Exception = $PS["Effect.Exception"];
  var Gargantext_Components_LoadingSpinner = $PS["Gargantext.Components.LoadingSpinner"];
  var Gargantext_Components_NgramsTable_Core = $PS["Gargantext.Components.NgramsTable.Core"];
  var Gargantext_Utils_CacheAPI = $PS["Gargantext.Utils.CacheAPI"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var cacheName = "ngrams-cache-api-loader";
  var clearCache = function (v) {
      return Gargantext_Utils_CacheAPI["delete"](cacheName);
  };
  var useCachedAPILoaderEffect = function (dictEq) {
      return function (dictReadForeign) {
          return function (dictEq1) {
              return function (v) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(v.path))(function (oPath) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(dictEq1)))(v.state))(function (state$prime) {
                          return Reactix_Hooks["useEffect'"]((function () {
                              var $12 = Data_Eq.eq(dictEq)(Reactix_React.readRef(oPath))(v.path) && Data_Maybe.isJust(state$prime);
                              if ($12) {
                                  return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                              };
                              return function __do() {
                                  Reactix_React.setRef(oPath)(v.path)();
                                  var req = v.mkRequest(v.path);
                                  return Effect_Aff.launchAff_(Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Utils_CacheAPI.openCache(cacheName))(function (cache) {
                                      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Utils_CacheAPI.cachedJson(Gargantext_Components_NgramsTable_Core["$_ReadForeignVersioned_144"](dictReadForeign))(cache)(req))(function (v1) {
                                          return Control_Bind.bind(Effect_Aff.bindAff)(v.cacheEndpoint(v.path))(function (cacheReal) {
                                              return Control_Bind.bind(Effect_Aff.bindAff)((function () {
                                                  var $14 = v1.version === cacheReal;
                                                  if ($14) {
                                                      return Control_Applicative.pure(Effect_Aff.applicativeAff)(v1);
                                                  };
                                                  return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Utils_CacheAPI.deleteReq(cache)(req))(function () {
                                                      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Utils_CacheAPI.cachedJson(Gargantext_Components_NgramsTable_Core["$_ReadForeignVersioned_144"](dictReadForeign))(cache)(req))(function (v2) {
                                                          var $16 = v2.version === cacheReal;
                                                          if ($16) {
                                                              return Control_Applicative.pure(Effect_Aff.applicativeAff)(v2);
                                                          };
                                                          return Control_Monad_Error_Class.throwError(Effect_Aff.monadThrowAff)(Effect_Exception.error("[NgramsTable.Loader] Fetched clean cache but hashes don't match: " + (Data_Show.show(Data_Show.showInt)(v1.version) + (" != " + Data_Show.show(Data_Show.showInt)(cacheReal)))));
                                                      });
                                                  });
                                              })())(function (val) {
                                                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Just.create(v.handleResponse(val)))(v.state));
                                              });
                                          });
                                      });
                                  }))();
                              };
                          })());
                      });
                  });
              };
          };
      };
  };
  var useLoaderWithCacheAPI = function (dictEq) {
      return function (dictReadForeign) {
          return function (dictEq1) {
              return function (v) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Maybe.Nothing.value))(function (state) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(dictEq1)))(state))(function (state$prime) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(useCachedAPILoaderEffect(dictEq)(dictReadForeign)(dictEq1)({
                              cacheEndpoint: v.cacheEndpoint,
                              handleResponse: v.handleResponse,
                              mkRequest: v.mkRequest,
                              path: v.path,
                              state: state
                          }))(function () {
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Data_Maybe.maybe(Gargantext_Components_LoadingSpinner.loadingSpinner({}))(v.renderer)(state$prime));
                          });
                      });
                  });
              };
          };
      };
  };
  exports["clearCache"] = clearCache;
  exports["useLoaderWithCacheAPI"] = useLoaderWithCacheAPI;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Login"] = $PS["Gargantext.Components.Login"] || {};
  var exports = $PS["Gargantext.Components.Login"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_Components_Login_Form = $PS["Gargantext.Components.Login.Form"];
  var Gargantext_Components_Login_Modal = $PS["Gargantext.Components.Login.Modal"];
  var Gargantext_Components_NgramsTable_Loader = $PS["Gargantext.Components.NgramsTable.Loader"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var signOutButton = function (dictReadWrite) {
      return function (sessions) {
          return function (session) {
              var click = function (v) {
                  return Gargantext_Sessions.change(dictReadWrite.Read0())(dictReadWrite.Write1())(new Gargantext_Sessions.Logout(session))(sessions);
              };
              return Reactix_DOM_HTML.a({
                  className: "glyphitem fa fa-sign-out",
                  on: {
                      click: click
                  },
                  id: "log-out",
                  title: "Log out"
              })([  ]);
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Login");
  var clearCacheButton = (function () {
      var click = function (v) {
          return Effect_Aff.launchAff_(Control_Apply.applySecond(Effect_Aff.applyAff)(Control_Apply.applySecond(Effect_Aff.applyAff)(Gargantext_Hooks_Loader.clearCache(Data_Unit.unit))(Gargantext_Components_NgramsTable_Loader.clearCache(Data_Unit.unit)))(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(here.log("cache cleared"))));
      };
      return Reactix_DOM_HTML.a({
          className: "glyphitem fa fa-eraser",
          on: {
              click: click
          },
          id: "log-out",
          title: "Clear cache"
      })([  ]);
  })();
  var renderSessions = function (dictReadWrite) {
      return function (sessions) {
          return function (sessions$prime) {
              var renderSession = function (session) {
                  return Reactix_DOM_HTML.li({})([ Reactix_DOM_HTML.text(Data_Show.show(Gargantext_Sessions_Types["$_ShowSession_34"])(session)), signOutButton(dictReadWrite)(sessions)(session), clearCacheButton ]);
              };
              return Reactix_React.fragment(Data_Functor.map(Data_Functor.functorArray)(renderSession)(Gargantext_Sessions_Types.unSessions(sessions$prime)));
          };
      };
  };
  var backendLabel = (function () {
      var $30 = Data_Maybe.fromMaybe("");
      var $31 = Data_String_Common.split(".");
      return function ($32) {
          return Data_String_Common.toUpper($30(Data_Array.head($31($32))));
      };
  })();
  var renderBackend = function (dictWrite) {
      return function (cursor) {
          return function (v) {
              var click = function (v1) {
                  return Toestand_Classes.write_(dictWrite)(new Data_Maybe.Just(v))(cursor);
              };
              return Reactix_DOM_HTML.tr({})([ Reactix_DOM_HTML.td({})([ Reactix_DOM_HTML.a({
                  on: {
                      click: click
                  },
                  title: "Log In",
                  className: "fa fa-hand-o-right"
              })([  ]) ]), Reactix_DOM_HTML.td({})([ Reactix_DOM_HTML.a({
                  on: {
                      click: click
                  }
              })([ Reactix_DOM_HTML.text(backendLabel(v.name)) ]) ]), Reactix_DOM_HTML.td({})([ Reactix_DOM_HTML.text("garg://" + v.name) ]) ]);
          };
      };
  };
  var activeConnections = function (dictReadWrite) {
      return function (sessions) {
          return function (sessions$prime) {
              if (Gargantext_Sessions_Types["null"](sessions$prime)) {
                  return [  ];
              };
              return [ Reactix_DOM_HTML.h3({})([ Reactix_DOM_HTML.text("Active connection(s)") ]), Reactix_DOM_HTML.ul({})([ renderSessions(dictReadWrite)(sessions)(sessions$prime) ]) ];
          };
      };
  };
  var chooserCpt = (function () {
      var headers = [ "", "Label of instance", "Gargurl" ];
      var header = function (label) {
          return Reactix_DOM_HTML.th({})([ Reactix_DOM_HTML.text(label) ]);
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Sessions_Types["$_EqSessions_42"]))(v.sessions))(function (sessions$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ Reactix_DOM_HTML.h2({
                      className: "center modal-title"
                  })([ Reactix_DOM_HTML.text("Instances manager") ]) ])(Data_Semigroup.append(Data_Semigroup.semigroupArray)(activeConnections(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(v.sessions)(sessions$prime))([ Reactix_DOM_HTML.h3({})([ Reactix_DOM_HTML.text("Existing connections") ]), Reactix_DOM_HTML.table({
                      className: "table"
                  })([ Reactix_DOM_HTML.thead({
                      className: "thead-light"
                  })([ Reactix_DOM_HTML.tr({})(Data_Functor.map(Data_Functor.functorArray)(header)(headers)) ]), Reactix_DOM_HTML.tbody({})(Data_Functor.map(Data_Functor.functorArray)(renderBackend(Toestand_Boxes.writeBox)(v.backend))(v.backends)) ]), Reactix_DOM_HTML.input({
                      className: "form-control",
                      type: "text",
                      placeholder: "Search for your institute"
                  }) ]))));
              });
          };
      };
      return here.component("chooser")(cpt);
  })();
  var chooser = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(chooserCpt)(props)([  ]);
  };
  var loginCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var inner = function (v2) {
                  if (v2 instanceof Data_Maybe.Nothing) {
                      return chooser(v);
                  };
                  if (v2 instanceof Data_Maybe.Just) {
                      return Gargantext_Components_Login_Form.form(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))({
                          backend: v2.value0,
                          sessions: v.sessions,
                          visible: v.visible
                      });
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Login (line 48, column 7 - line 48, column 36): " + [ v2.constructor.name ]);
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Gargantext_Ends["$_EqBackend_25"])))(v.backend))(function (b) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Login_Modal.modal(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))({
                      visible: v.visible
                  })(inner(b)));
              });
          };
      };
      return here.component("login")(cpt);
  })();
  var login = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(loginCpt)(props)([  ]);
  };
  exports["login"] = login;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.MainPage"] = $PS["Gargantext.Components.MainPage"] || {};
  var exports = $PS["Gargantext.Components.MainPage"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.MainPage");
  var mainPageCpt = (function () {
      var cpt = function (v) {
          return function (children) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqHanded_94"]))(v.boxes.handed))(function (handed$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Routes["$_EqAppRoute_99"]))(v.boxes.route))(function (route$prime) {
                      var v1 = (function () {
                          if (route$prime instanceof Gargantext_Routes.PGraphExplorer) {
                              return new Data_Tuple.Tuple("", new Data_Tuple.Tuple("col-md-12", ""));
                          };
                          if (handed$prime instanceof Gargantext_Types.LeftHanded) {
                              return new Data_Tuple.Tuple("", new Data_Tuple.Tuple("col-md-10", "col-md-2"));
                          };
                          if (handed$prime instanceof Gargantext_Types.RightHanded) {
                              return new Data_Tuple.Tuple("col-md-2", new Data_Tuple.Tuple("col-md-10", ""));
                          };
                          throw new Error("Failed pattern match at Gargantext.Components.MainPage (line 36, column 38 - line 38, column 64): " + [ handed$prime.constructor.name ]);
                      })();
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                          className: "row"
                      })([ Reactix_DOM_HTML.div({
                          className: v1.value0
                      })([  ]), Reactix_DOM_HTML.div({
                          className: v1.value1.value0
                      })([ Reactix_DOM_HTML.div({
                          id: "page-wrapper"
                      })([ Reactix_DOM_HTML.div({
                          className: "container-fluid"
                      })(children) ]) ]), Reactix_DOM_HTML.div({
                          className: v1.value1.value1
                      })([  ]) ]));
                  });
              });
          };
      };
      return here.component("mainPage")(cpt);
  })();
  var mainPage = Reactix_React.createElement(Reactix_React.componentIsComponent)(mainPageCpt);
  exports["mainPage"] = mainPage;
})(PS);
(function($PS) {
  "use strict";
  $PS["Gargantext.Components.Nodes.Annuaire.User.Contacts.Types"] = $PS["Gargantext.Components.Nodes.Annuaire.User.Contacts.Types"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Annuaire.User.Contacts.Types"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Lens_Lens = $PS["Data.Lens.Lens"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Record = $PS["Record"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var ContactWho = function (x) {
      return x;
  };
  var ContactTouch = function (x) {
      return x;
  };
  var ContactWhere = function (x) {
      return x;
  };
  var HyperdataContact = function (x) {
      return x;
  };
  var HyperdataUser = function (x) {
      return x;
  };

  // TODO: should it be a NodePoly HyperdataContact ?
  var NodeContact = function (x) {
      return x;
  };

  //--------------------------------------------------------------------------
  var Contact$prime = function (x) {
      return x;
  };

  // | TODO rename Contact with User
  // and fix shared decodeJson
  var Contact = function (x) {
      return x;
  };
  var user_idP = Data_Symbol.SProxy.value;
  var userIdP = Data_Symbol.SProxy.value;
  var parent_idP = Data_Symbol.SProxy.value;
  var parentIdP = Data_Symbol.SProxy.value;
  var defaultHyperdataContact = {
      bdd: Data_Maybe.Nothing.value,
      who: Data_Maybe.Nothing.value,
      ou: [  ],
      title: Data_Maybe.Nothing.value,
      source: Data_Maybe.Nothing.value,
      lastValidation: Data_Maybe.Nothing.value,
      uniqId: Data_Maybe.Nothing.value,
      uniqIdBdd: Data_Maybe.Nothing.value
  };
  var defaultContactWho = {
      idWho: Data_Maybe.Nothing.value,
      firstName: Data_Maybe.Nothing.value,
      lastName: Data_Maybe.Nothing.value,
      keywords: [  ],
      freetags: [  ]
  };
  var defaultContactWhere = {
      organization: [  ],
      labTeamDepts: [  ],
      role: Data_Maybe.Nothing.value,
      office: Data_Maybe.Nothing.value,
      country: Data_Maybe.Nothing.value,
      city: Data_Maybe.Nothing.value,
      touch: Data_Maybe.Nothing.value,
      entry: Data_Maybe.Nothing.value,
      exit: Data_Maybe.Nothing.value
  };
  var defaultContactTouch = {
      mail: Data_Maybe.Nothing.value,
      phone: Data_Maybe.Nothing.value,
      url: Data_Maybe.Nothing.value
  };
  var _who = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return HyperdataContact({
                  ou: v.ou,
                  bdd: v.bdd,
                  lastValidation: v.lastValidation,
                  source: v.source,
                  title: v.title,
                  uniqId: v.uniqId,
                  uniqIdBdd: v.uniqIdBdd,
                  who: new Data_Maybe.Just(val)
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe(defaultContactWho)(v.who);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _touch = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return ContactWhere({
                  organization: v.organization,
                  labTeamDepts: v.labTeamDepts,
                  role: v.role,
                  office: v.office,
                  country: v.country,
                  city: v.city,
                  touch: new Data_Maybe.Just(val),
                  entry: v.entry,
                  exit: v.exit
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe(defaultContactTouch)(v.touch);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _shared = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return HyperdataUser({
                  shared: new Data_Maybe.Just(val)
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe(defaultHyperdataContact)(v.shared);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _role = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return ContactWhere({
                  organization: v.organization,
                  labTeamDepts: v.labTeamDepts,
                  role: new Data_Maybe.Just(val),
                  office: v.office,
                  country: v.country,
                  city: v.city,
                  touch: v.touch,
                  entry: v.entry,
                  exit: v.exit
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe("")(v.role);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _phone = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return ContactTouch({
                  mail: v.mail,
                  phone: new Data_Maybe.Just(val),
                  url: v.url
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe("")(v.phone);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _ouFirst = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return HyperdataContact({
                  ou: Data_Maybe.fromMaybe([ val ])(Data_Array.updateAt(0)(val)(v.ou)),
                  bdd: v.bdd,
                  lastValidation: v.lastValidation,
                  source: v.source,
                  title: v.title,
                  uniqId: v.uniqId,
                  uniqIdBdd: v.uniqIdBdd,
                  who: v.who
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe(defaultContactWhere)(Data_Array.head(v.ou));
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _organizationJoinComma = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return ContactWhere({
                  organization: Data_String_Common.split(", ")(val),
                  labTeamDepts: v.labTeamDepts,
                  role: v.role,
                  office: v.office,
                  country: v.country,
                  city: v.city,
                  touch: v.touch,
                  entry: v.entry,
                  exit: v.exit
              });
          };
      };
      var getter = function (v) {
          return Data_String_Common.joinWith(", ")(v.organization);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _office = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return ContactWhere({
                  organization: v.organization,
                  labTeamDepts: v.labTeamDepts,
                  role: v.role,
                  office: new Data_Maybe.Just(val),
                  country: v.country,
                  city: v.city,
                  touch: v.touch,
                  entry: v.entry,
                  exit: v.exit
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe("")(v.office);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _mail = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return ContactTouch({
                  mail: new Data_Maybe.Just(val),
                  phone: v.phone,
                  url: v.url
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe("")(v.mail);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _lastName = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return ContactWho({
                  idWho: v.idWho,
                  firstName: v.firstName,
                  lastName: new Data_Maybe.Just(val),
                  keywords: v.keywords,
                  freetags: v.freetags
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe("")(v.lastName);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _labTeamDeptsJoinComma = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return ContactWhere({
                  organization: v.organization,
                  labTeamDepts: Data_String_Common.split(", ")(val),
                  role: v.role,
                  office: v.office,
                  country: v.country,
                  city: v.city,
                  touch: v.touch,
                  entry: v.entry,
                  exit: v.exit
              });
          };
      };
      var getter = function (v) {
          return Data_String_Common.joinWith(", ")(v.labTeamDepts);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _firstName = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return ContactWho({
                  idWho: v.idWho,
                  firstName: new Data_Maybe.Just(val),
                  lastName: v.lastName,
                  keywords: v.keywords,
                  freetags: v.freetags
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe("")(v.firstName);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _country = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return ContactWhere({
                  organization: v.organization,
                  labTeamDepts: v.labTeamDepts,
                  role: v.role,
                  office: v.office,
                  country: new Data_Maybe.Just(val),
                  city: v.city,
                  touch: v.touch,
                  entry: v.entry,
                  exit: v.exit
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe("")(v.country);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var _city = function (dictStrong) {
      var setter = function (v) {
          return function (val) {
              return ContactWhere({
                  organization: v.organization,
                  labTeamDepts: v.labTeamDepts,
                  role: v.role,
                  office: v.office,
                  country: v.country,
                  city: new Data_Maybe.Just(val),
                  touch: v.touch,
                  entry: v.entry,
                  exit: v.exit
              });
          };
      };
      var getter = function (v) {
          return Data_Maybe.fromMaybe("")(v.city);
      };
      return Data_Lens_Lens.lens(getter)(setter)(dictStrong);
  };
  var $dollar_WriteForeignContactWho_83 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "firstName";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "freetags";
  }))(Simple_JSON.writeForeignArray(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "idWho";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "keywords";
  }))(Simple_JSON.writeForeignArray(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "lastName";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()());
  var $dollar_WriteForeignContactTouch_93 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "mail";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "phone";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "url";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.nilWriteForeignFields)()()())()()())()()());
  var $dollar_WriteForeignContactWhere_88 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "city";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "country";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "entry";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "exit";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "labTeamDepts";
  }))(Simple_JSON.writeForeignArray(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "office";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "organization";
  }))(Simple_JSON.writeForeignArray(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "role";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "touch";
  }))(Simple_JSON.writeForeignMaybe($dollar_WriteForeignContactTouch_93))(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()())()()())()()())()()())()()());
  var $dollar_WriteForeignHyperdataCont_98 = new Simple_JSON.WriteForeign(function (v) {
      return Simple_JSON.writeImpl(Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "bdd";
      }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "lastValidation";
      }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "source";
      }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "title";
      }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "uniqId";
      }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "uniqIdBdd";
      }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "where";
      }))(Simple_JSON.writeForeignArray($dollar_WriteForeignContactWhere_88))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
          return "who";
      }))(Simple_JSON.writeForeignMaybe($dollar_WriteForeignContactWho_83))(Simple_JSON.nilWriteForeignFields)()()())()()())()()())()()())()()())()()())()()())()()()))({
          bdd: v.bdd,
          lastValidation: v.lastValidation,
          where: v.ou,
          source: v.source,
          title: v.title,
          uniqId: v.uniqId,
          uniqIdBdd: v.uniqIdBdd,
          who: v.who
      });
  });
  var $dollar_WriteForeignHyperdataUser_103 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "shared";
  }))(Simple_JSON.writeForeignMaybe($dollar_WriteForeignHyperdataCont_98))(Simple_JSON.nilWriteForeignFields)()()());
  var $dollar_ReadForeignContactWho_82 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "firstName";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "freetags";
      }))(Simple_JSON.readMaybe(Simple_JSON.readArray(Simple_JSON.readString)))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "idWho";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "keywords";
      }))(Simple_JSON.readMaybe(Simple_JSON.readArray(Simple_JSON.readString)))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "lastName";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsNil)()())()())()())()())()()))(f))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(ContactWho({
              idWho: inst.idWho,
              firstName: inst.firstName,
              lastName: inst.lastName,
              keywords: Data_Maybe.fromMaybe([  ])(inst.keywords),
              freetags: Data_Maybe.fromMaybe([  ])(inst.freetags)
          }));
      });
  });
  var $dollar_ReadForeignContactTouch_92 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "mail";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "phone";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "url";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsNil)()())()())()());
  var $dollar_ReadForeignContactWhere_87 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "city";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "country";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "entry";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "exit";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "labTeamDepts";
      }))(Simple_JSON.readMaybe(Simple_JSON.readArray(Simple_JSON.readString)))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "office";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "organization";
      }))(Simple_JSON.readMaybe(Simple_JSON.readArray(Simple_JSON.readString)))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "role";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "touch";
      }))(Simple_JSON.readMaybe($dollar_ReadForeignContactTouch_92))(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()())()())()()))(f))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(ContactWhere({
              organization: Data_Maybe.fromMaybe([  ])(inst.organization),
              labTeamDepts: Data_Maybe.fromMaybe([  ])(inst.labTeamDepts),
              role: inst.role,
              office: inst.office,
              country: inst.country,
              city: inst.city,
              touch: inst.touch,
              entry: inst.entry,
              exit: inst.exit
          }));
      });
  });
  var $dollar_ReadForeignHyperdataConta_97 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "bdd";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "lastValidation";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "source";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "title";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "uniqId";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "uniqIdBdd";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "where";
      }))(Simple_JSON.readMaybe(Simple_JSON.readArray($dollar_ReadForeignContactWhere_87)))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "who";
      }))(Simple_JSON.readMaybe($dollar_ReadForeignContactWho_82))(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()())()()))(f))(function (v) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))({
              bdd: v.bdd,
              lastValidation: v.lastValidation,
              ou: Data_Maybe.fromMaybe([  ])(v.where),
              source: v.source,
              title: v.title,
              uniqId: v.uniqId,
              uniqIdBdd: v.uniqIdBdd,
              who: v.who
          });
      });
  });
  var $dollar_ReadForeignHyperdataUser_102 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "shared";
  }))(Simple_JSON.readMaybe($dollar_ReadForeignHyperdataConta_97))(Simple_JSON.readFieldsNil)()());
  var $dollar_ReadForeignContact_75 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "date";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "hyperdata";
      }))($dollar_ReadForeignHyperdataUser_102)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "id";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "name";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "parent_id";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "typename";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "user_id";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()()))(f))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Contact(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "parent_id";
          }))(new Data_Symbol.IsSymbol(function () {
              return "parentId";
          }))()()()()(parent_idP)(parentIdP)(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "user_id";
          }))(new Data_Symbol.IsSymbol(function () {
              return "userId";
          }))()()()()(user_idP)(userIdP)(inst))));
      });
  });
  var $dollar_ReadForeignNodeContact_67 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "date";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "hyperdata";
      }))($dollar_ReadForeignHyperdataConta_97)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "id";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "name";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "parent_id";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "typename";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "user_id";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()()))(f))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(NodeContact(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "parent_id";
          }))(new Data_Symbol.IsSymbol(function () {
              return "parentId";
          }))()()()()(parent_idP)(parentIdP)(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "user_id";
          }))(new Data_Symbol.IsSymbol(function () {
              return "userId";
          }))()()()()(user_idP)(userIdP)(inst))));
      });
  });
  var $dollar_ReadForeignContact$prime_71 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "date";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "hyperdata";
      }))($dollar_ReadForeignHyperdataConta_97)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "id";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "name";
      }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "parent_id";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "typename";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "user_id";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()()))(f))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(Contact$prime(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "parent_id";
          }))(new Data_Symbol.IsSymbol(function () {
              return "parentId";
          }))()()()()(parent_idP)(parentIdP)(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "user_id";
          }))(new Data_Symbol.IsSymbol(function () {
              return "userId";
          }))()()()()(user_idP)(userIdP)(inst))));
      });
  });
  var $dollar_GenericNodeContact__64 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericHyperdataUser__100 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericHyperdataContact__95 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericContact__72 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericContactWho__80 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericContactWhere__85 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericContactTouch__90 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericContact$prime__68 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqContactWho_81 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericContactWho__80)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "lastName";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "keywords";
  }))(Data_Eq.eqArray(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "idWho";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "freetags";
  }))(Data_Eq.eqArray(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "firstName";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))))));
  var $dollar_EqContactTouch_91 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericContactTouch__90)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "url";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "phone";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "mail";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))))));
  var $dollar_EqContactWhere_86 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericContactWhere__85)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "touch";
  }))(Data_Maybe.eqMaybe($dollar_EqContactTouch_91)))()(new Data_Symbol.IsSymbol(function () {
      return "role";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "organization";
  }))(Data_Eq.eqArray(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "office";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "labTeamDepts";
  }))(Data_Eq.eqArray(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "exit";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "entry";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "country";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "city";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))))));
  var $dollar_EqHyperdataContact_96 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHyperdataContact__95)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "who";
  }))(Data_Maybe.eqMaybe($dollar_EqContactWho_81)))()(new Data_Symbol.IsSymbol(function () {
      return "uniqIdBdd";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "uniqId";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "source";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "ou";
  }))(Data_Eq.eqArray($dollar_EqContactWhere_86)))()(new Data_Symbol.IsSymbol(function () {
      return "lastValidation";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "bdd";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))))));
  var $dollar_EqHyperdataUser_101 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHyperdataUser__100)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "shared";
  }))(Data_Maybe.eqMaybe($dollar_EqHyperdataContact_96)))))));
  var $dollar_EqContact_74 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericContact__72)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "userId";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "typename";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "parentId";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "hyperdata";
  }))($dollar_EqHyperdataUser_101))()(new Data_Symbol.IsSymbol(function () {
      return "date";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))))));
  var $dollar_EqNodeContact_66 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericNodeContact__64)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "userId";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "typename";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "parentId";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "hyperdata";
  }))($dollar_EqHyperdataContact_96))()(new Data_Symbol.IsSymbol(function () {
      return "date";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))))));
  var $dollar_EqContact$prime_70 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericContact$prime__68)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "userId";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "typename";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "parentId";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "hyperdata";
  }))($dollar_EqHyperdataContact_96))()(new Data_Symbol.IsSymbol(function () {
      return "date";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))))));
  exports["_shared"] = _shared;
  exports["_who"] = _who;
  exports["_ouFirst"] = _ouFirst;
  exports["_lastName"] = _lastName;
  exports["_firstName"] = _firstName;
  exports["_organizationJoinComma"] = _organizationJoinComma;
  exports["_labTeamDeptsJoinComma"] = _labTeamDeptsJoinComma;
  exports["_office"] = _office;
  exports["_city"] = _city;
  exports["_country"] = _country;
  exports["_role"] = _role;
  exports["_touch"] = _touch;
  exports["_mail"] = _mail;
  exports["_phone"] = _phone;
  exports["$_EqNodeContact_66"] = $dollar_EqNodeContact_66;
  exports["$_ReadForeignNodeContact_67"] = $dollar_ReadForeignNodeContact_67;
  exports["$_EqContact'_70"] = $dollar_EqContact$prime_70;
  exports["$_ReadForeignContact'_71"] = $dollar_ReadForeignContact$prime_71;
  exports["$_EqContact_74"] = $dollar_EqContact_74;
  exports["$_ReadForeignContact_75"] = $dollar_ReadForeignContact_75;
  exports["$_WriteForeignHyperdataCont_98"] = $dollar_WriteForeignHyperdataCont_98;
  exports["$_WriteForeignHyperdataUser_103"] = $dollar_WriteForeignHyperdataUser_103;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Annuaire"] = $PS["Gargantext.Components.Nodes.Annuaire"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Annuaire"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_NgramsTable_Loader = $PS["Gargantext.Components.NgramsTable.Loader"];
  var Gargantext_Components_Nodes_Annuaire_User_Contacts_Types = $PS["Gargantext.Components.Nodes.Annuaire.User.Contacts.Types"];
  var Gargantext_Components_Nodes_Lists_Types = $PS["Gargantext.Components.Nodes.Lists.Types"];
  var Gargantext_Components_Search = $PS["Gargantext.Components.Search"];
  var Gargantext_Components_Table = $PS["Gargantext.Components.Table"];
  var Gargantext_Components_Table_Types = $PS["Gargantext.Components.Table.Types"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var AnnuaireInfo = function (x) {
      return x;
  };
  var loadPage = function (session) {
      return function (v) {
          var children = new Gargantext_Routes.Children(Gargantext_Types.NodeContact.value, v.params.offset, v.params.limit, Data_Maybe.Nothing.value, new Data_Maybe.Just(v.nodeId));
          return Gargantext_Sessions.get(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
              return "count";
          }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
              return "docs";
          }))(Simple_JSON.readArray(Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["$_ReadForeignNodeContact_67"]))(Simple_JSON.readFieldsNil)()())()()))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(children);
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Annuaire");
  var contactCellsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              if (v.contact.hyperdata.who instanceof Data_Maybe.Nothing) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Table.makeRow([ Reactix_DOM_HTML.text(""), Reactix_DOM_HTML.span({})([ Reactix_DOM_HTML.text("Name") ]), Reactix_DOM_HTML.text("No ContactWhere"), Reactix_DOM_HTML.text("No ContactWhereDept"), Reactix_DOM_HTML.div({
                      className: "nooverflow"
                  })([ Reactix_DOM_HTML.text("No ContactWhereRole") ]) ]));
              };
              if (v.contact.hyperdata.who instanceof Data_Maybe.Just) {
                  var nodepath = new Gargantext_Routes.ContactPage(Gargantext_Sessions_Types.sessionId(v.session), v.annuaireId, v.contact.id);
                  var href = Gargantext_Ends.url(Gargantext_Ends["$_ToUrlFrontendsAppRoute_35"])(v.frontends)(nodepath);
                  var contactWhereRole = function (v2) {
                      if (v2.role instanceof Data_Maybe.Nothing) {
                          return "Empty Role";
                      };
                      if (v2.role instanceof Data_Maybe.Just) {
                          return v2.role.value0;
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Annuaire (line 237, column 9 - line 237, column 76): " + [ v2.constructor.name ]);
                  };
                  var contactWhereOrg = function (v2) {
                      if (v2.organization.length === 0) {
                          return "No Organization";
                      };
                      return Data_Maybe.fromMaybe("No orga (list)")(Data_Array.head(v2.organization));
                  };
                  var contactWhereDept = function (v2) {
                      if (v2.labTeamDepts.length === 0) {
                          return "Empty Dept";
                      };
                      return Data_Maybe.fromMaybe("No Dept (list)")(Data_Array.head(v2.labTeamDepts));
                  };
                  var contactUrl = function (aId) {
                      return function (id$prime) {
                          return Gargantext_Ends.url(Gargantext_Ends["$_ToUrlFrontendsAppRoute_35"])(v.frontends)(new Gargantext_Routes.ContactPage(Gargantext_Sessions_Types.sessionId(v.session), aId, id$prime));
                      };
                  };
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Table.makeRow([ Reactix_DOM_HTML.text(""), Reactix_DOM_HTML.a({
                      target: "_blank",
                      href: contactUrl(v.annuaireId)(v.contact.id)
                  })([ Reactix_DOM_HTML.text(Data_Maybe.fromMaybe("First Name")(v.contact.hyperdata.who.value0.firstName)) ]), Reactix_DOM_HTML.text(Data_Maybe.fromMaybe("First Name")(v.contact.hyperdata.who.value0.lastName)), Reactix_DOM_HTML.text(Data_Maybe.maybe("No ContactWhere")(contactWhereOrg)(Data_Array.head(v.contact.hyperdata.ou))), Reactix_DOM_HTML.text(Data_Maybe.maybe("No ContactWhereDept")(contactWhereDept)(Data_Array.head(v.contact.hyperdata.ou))) ]));
              };
              throw new Error("Failed pattern match at Gargantext.Components.Nodes.Annuaire (line 197, column 3 - line 208, column 6): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
      return here.component("contactCells")(cpt);
  })();
  var contactCells = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(contactCellsCpt)(p)([  ]);
  };
  var pageCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var wrapColElts = Data_Function["const"](Control_Category.identity(Control_Category.categoryFn));
              var row = function (v2) {
                  return function (contact) {
                      return {
                          row: contactCells({
                              annuaireId: v2.nodeId,
                              frontends: v.frontends,
                              contact: contact,
                              session: v.session
                          }),
                          "delete": false
                      };
                  };
              };
              var rows = function (pagePath$prime) {
                  return Data_Functor.map(Data_Sequence.functorSeq)(row(pagePath$prime))(Data_Sequence.fromFoldable(Data_Foldable.foldableArray)(v.table.docs));
              };
              var container = Gargantext_Components_Table.defaultContainer({
                  title: "Annuaire"
              });
              var colNames = Data_Functor.map(Data_Functor.functorArray)(Gargantext_Components_Table_Types.ColumnName)([ "", "First Name", "Last Name", "Company", "Role" ]);
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "params";
              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "searchType";
              }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                  return "orderBy";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                  return "offset";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "limit";
              }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                  return "nodeId";
              }))(Data_Eq.eqInt))))(v.pagePath))(function (pagePath$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v2) {
                      return v2.params;
                  })(function (a) {
                      return function (b) {
                          var $74 = {};
                          for (var $75 in b) {
                              if ({}.hasOwnProperty.call(b, $75)) {
                                  $74[$75] = b[$75];
                              };
                          };
                          $74.params = a;
                          return $74;
                      };
                  })(v.pagePath))(function (params) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Table.table({
                          colNames: colNames,
                          container: container,
                          params: params,
                          rows: rows(pagePath$prime),
                          syncResetButton: [ Reactix_DOM_HTML.div({})([  ]) ],
                          totalRecords: v.table.count,
                          wrapColElts: wrapColElts
                      }));
                  });
              });
          };
      };
      return here.component("page")(cpt);
  })();
  var page = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(pageCpt)(props)([  ]);
  };
  var pageLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "params";
              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "searchType";
              }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                  return "orderBy";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                  return "offset";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "limit";
              }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                  return "nodeId";
              }))(Data_Eq.eqInt))))(v.pagePath))(function (pagePath$prime) {
                  return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "params";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "searchType";
                  }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                      return "orderBy";
                  }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                      return "offset";
                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                      return "limit";
                  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                      return "nodeId";
                  }))(Data_Eq.eqInt)))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "docs";
                  }))(Data_Eq.eqArray(Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["$_EqNodeContact_66"])))()(new Data_Symbol.IsSymbol(function () {
                      return "count";
                  }))(Data_Eq.eqInt)))(pagePath$prime)(loadPage(v.session))(function (table) {
                      return page({
                          session: v.session,
                          table: table,
                          frontends: v.frontends,
                          pagePath: v.pagePath
                      });
                  });
              });
          };
      };
      return here.component("pageLayout")(cpt);
  })();
  var pageLayout = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(pageLayoutCpt)(props)([  ]);
  };
  var annuaireCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var style = {
                  width: "250px",
                  display: "inline-block"
              };
              var initialPagePath = function (nodeId) {
                  return {
                      nodeId: nodeId,
                      params: Gargantext_Components_Table.initialParams
                  };
              };
              var date = "Last update: " + v.info.date;
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(v.path))(function (path$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(initialPagePath(path$prime)))(function (pagePath) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_Nodes_Lists_Types.CacheOff.value))(function (cacheState) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Nodes_Lists_Types["$_EqCacheState_4"]))(cacheState))(function (cacheState$prime) {
                              return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffectOnce'"](Toestand_Classes.listen(Toestand_Boxes.readBox)(function (v2) {
                                  return Effect_Aff.launchAff_(Gargantext_Components_NgramsTable_Loader.clearCache(Data_Unit.unit));
                              })(cacheState)))(function () {
                                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ Gargantext_Components_Table.tableHeaderLayout({
                                      cacheState: cacheState,
                                      date: date,
                                      desc: v.info.name,
                                      key: "annuaire-" + Data_Show.show(Gargantext_Components_Nodes_Lists_Types["$_ShowCacheState_5"])(cacheState$prime),
                                      query: "",
                                      title: v.info.name,
                                      user: ""
                                  })([  ]), Reactix_DOM_HTML.p({})([  ]), Reactix_DOM_HTML.br({}), pageLayout({
                                      info: v.info,
                                      session: v.session,
                                      pagePath: pagePath,
                                      frontends: v.frontends
                                  }) ]));
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("annuaire")(cpt);
  })();
  var annuaire = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(annuaireCpt)(props)([  ]);
  };
  var $dollar_ReadForeignHyperdataAnnua_27 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "desc";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsNil)()())()());
  var $dollar_ReadForeignAnnuaireInfo_31 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "date";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "hyperdata";
      }))($dollar_ReadForeignHyperdataAnnua_27)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "id";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "name";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "parent_id";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "typename";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "user_id";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()()))(f))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(AnnuaireInfo(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "user_id";
          }))(new Data_Symbol.IsSymbol(function () {
              return "userId";
          }))()()()()(Data_Symbol.SProxy.value)(Data_Symbol.SProxy.value)(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "parent_id";
          }))(new Data_Symbol.IsSymbol(function () {
              return "parentId";
          }))()()()()(Data_Symbol.SProxy.value)(Data_Symbol.SProxy.value)(inst))));
      });
  });
  var getAnnuaireInfo = function (session) {
      return function (id) {
          return Gargantext_Sessions.get($dollar_ReadForeignAnnuaireInfo_31)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(id), ""));
      };
  }; 
  var $dollar_GenericHyperdataAnnuaire__24 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericAnnuaireInfo__28 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqHyperdataAnnuaire_26 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHyperdataAnnuaire__24)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "desc";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))))));
  var $dollar_EqAnnuaireInfo_30 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericAnnuaireInfo__28)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "userId";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "typename";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "parentId";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "hyperdata";
  }))($dollar_EqHyperdataAnnuaire_26))()(new Data_Symbol.IsSymbol(function () {
      return "date";
  }))(Data_Eq.eqString))))));
  var annuaireLayoutWithKeyCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(v.nodeId))(function (path) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(path))(function (path$prime) {
                      return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqInt)($dollar_EqAnnuaireInfo_30)(path$prime)(getAnnuaireInfo(v.session))(function (info) {
                          return annuaire({
                              frontends: v.frontends,
                              info: info,
                              path: path,
                              session: v.session
                          });
                      });
                  });
              });
          };
      };
      return here.component("annuaireLayoutWithKey")(cpt);
  })();
  var annuaireLayoutWithKey = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(annuaireLayoutWithKeyCpt)(props)([  ]);
  };
  var annuaireLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var key = Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(Gargantext_Sessions_Types.sessionId(v.session)) + ("-" + Data_Show.show(Data_Show.showInt)(v.nodeId));
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(annuaireLayoutWithKey({
                  frontends: v.frontends,
                  key: key,
                  nodeId: v.nodeId,
                  session: v.session
              }));
          };
      };
      return here.component("annuaireLayout")(cpt);
  })();
  var annuaireLayout = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(annuaireLayoutCpt)(props)([  ]);
  };
  exports["annuaireLayout"] = annuaireLayout;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.DocsTable.Types"] = $PS["Gargantext.Components.DocsTable.Types"] || {};
  var exports = $PS["Gargantext.Components.DocsTable.Types"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Gargantext_Components_Category_Types = $PS["Gargantext.Components.Category.Types"];
  var Simple_JSON = $PS["Simple.JSON"];
  var sampleDocuments = [ new Data_Tuple.Tuple("Macroscopic dynamics of the fusion process", "Journal de Physique Lettres"), new Data_Tuple.Tuple("Effects of static and cyclic fatigue at high temperature upon reaction bonded silicon nitride", "Journal de Physique Colloques"), new Data_Tuple.Tuple("Reliability of metal/glass-ceramic junctions made by solid state bonding", "Journal de Physique Colloques"), new Data_Tuple.Tuple("High temperature mechanical properties and intergranular structure of sialons", "Journal de Physique Colloques"), new Data_Tuple.Tuple("SOLUTIONS OF THE LANDAU-VLASOV EQUATION IN NUCLEAR PHYSICS", "Journal de Physique Colloques"), new Data_Tuple.Tuple("A STUDY ON THE FUSION REACTION 139La + 12C AT 50 MeV/u WITH THE VUU EQUATION", "Journal de Physique Colloques"), new Data_Tuple.Tuple("Atomic structure of \"vitreous\" interfacial films in sialon", "Journal de Physique Colloques"), new Data_Tuple.Tuple("MICROSTRUCTURAL AND ANALYTICAL CHARACTERIZATION OF Al2O3/Al-Mg COMPOSITE INTERFACES", "Journal de Physique Colloques"), new Data_Tuple.Tuple("Development of oxidation resistant high temperature NbTiAl alloys and intermetallics", "Journal de Physique IV Colloque"), new Data_Tuple.Tuple("Determination of brazed joint constitutive law by inverse method", "Journal de Physique IV Colloque"), new Data_Tuple.Tuple("Two dimensional estimates from ocean SAR images", "Nonlinear Processes in Geophysics"), new Data_Tuple.Tuple("Comparison Between New Carbon Nanostructures Produced by Plasma with Industrial Carbon Black Grades", "Journal de Physique III"), new Data_Tuple.Tuple("<i>Letter to the Editor:</i> SCIPION, a new flexible ionospheric sounder in Senegal", "Annales Geophysicae"), new Data_Tuple.Tuple("Is reducibility in nuclear multifragmentation related to thermal scaling?", "Physics Letters B"), new Data_Tuple.Tuple("Independence of fragment charge distributions of the size of heavy multifragmenting sources", "Physics Letters B"), new Data_Tuple.Tuple("Hard photons and neutral pions as probes of hot and dense nuclear matter", "Nuclear Physics A"), new Data_Tuple.Tuple("Surveying the nuclear caloric curve", "Physics Letters B"), new Data_Tuple.Tuple("A hot expanding source in 50 A MeV Xe+Sn central reactions", "Physics Letters B") ];
  var sampleData = Data_Functor.map(Data_Functor.functorArray)(function (v) {
      return {
          "_id": 1,
          url: "",
          date: 2017,
          title: v.value0,
          source: v.value1,
          category: Gargantext_Components_Category_Types.Star_1.value,
          ngramCount: new Data_Maybe.Just(10),
          score: new Data_Maybe.Just(1)
      };
  })(sampleDocuments);
  var $dollar_ReadForeignHyperdata_15 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "publication_year";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "source";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "title";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()()))(f))(function (v) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))({
              pub_year: v.publication_year,
              title: v.title,
              source: v.source
          });
      });
  });
  var $dollar_ReadForeignResponse_13 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "category";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "hyperdata";
      }))($dollar_ReadForeignHyperdata_15)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "id";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "ngramCount";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "score";
      }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "title";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()())()())()())()()))(f))(function (v) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))({
              category: Gargantext_Components_Category_Types.decodeStar(v.category),
              cid: v.id,
              hyperdata: v.hyperdata,
              ngramCount: v.ngramCount,
              score: v.score,
              title: v.title
          });
      });
  });
  var $dollar_GenericDocumentsView__9 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqDocumentsView_10 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericDocumentsView__9)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "url";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "source";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "score";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "ngramCount";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "date";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "category";
  }))(Gargantext_Components_Category_Types["$_EqStar_11"]))()(new Data_Symbol.IsSymbol(function () {
      return "_id";
  }))(Data_Eq.eqInt))))));
  exports["sampleData"] = sampleData;
  exports["$_EqDocumentsView_10"] = $dollar_EqDocumentsView_10;
  exports["$_ReadForeignResponse_13"] = $dollar_ReadForeignResponse_13;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.QueryString"] = $PS["Gargantext.Utils.QueryString"] || {};
  var exports = $PS["Gargantext.Utils.QueryString"];
  var Data_Array = $PS["Data.Array"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_String_Common = $PS["Data.String.Common"];                
  var queryParamS = function (key) {
      return function (value) {
          return key + ("=" + value);
      };
  };
  var queryParam = function (dictShow) {
      return function (key) {
          return function (value) {
              return key + ("=" + Data_Show.show(dictShow)(value));
          };
      };
  };
  var mQueryParamS = function (v) {
      return function (v1) {
          return function (v2) {
              if (v2 instanceof Data_Maybe.Nothing) {
                  return "";
              };
              if (v2 instanceof Data_Maybe.Just) {
                  return queryParamS(v)(v1(v2.value0));
              };
              throw new Error("Failed pattern match at Gargantext.Utils.QueryString (line 19, column 1 - line 19, column 72): " + [ v.constructor.name, v1.constructor.name, v2.constructor.name ]);
          };
      };
  };
  var joinQueryStrings = function (qs) {
      var v = Data_Array.uncons(qs);
      if (v instanceof Data_Maybe.Nothing) {
          return "";
      };
      if (v instanceof Data_Maybe.Just) {
          var joinQS = function (ys) {
              var v1 = Data_Array.uncons(ys);
              if (v1 instanceof Data_Maybe.Nothing) {
                  return "";
              };
              if (v1 instanceof Data_Maybe.Just) {
                  return "&" + Data_String_Common.joinWith("&")(v1.value0.tail);
              };
              throw new Error("Failed pattern match at Gargantext.Utils.QueryString (line 30, column 11 - line 32, column 58): " + [ v1.constructor.name ]);
          };
          return "?" + (v.value0.head + joinQS(v.value0.tail));
      };
      throw new Error("Failed pattern match at Gargantext.Utils.QueryString (line 25, column 3 - line 32, column 58): " + [ v.constructor.name ]);
  };
  exports["queryParam"] = queryParam;
  exports["queryParamS"] = queryParamS;
  exports["mQueryParamS"] = mQueryParamS;
  exports["joinQueryStrings"] = joinQueryStrings;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.DocsTable"] = $PS["Gargantext.Components.DocsTable"] || {};
  var exports = $PS["Gargantext.Components.DocsTable"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var DOM_Simple_Event = $PS["DOM.Simple.Event"];
  var Data_Array = $PS["Data.Array"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Lens_At = $PS["Data.Lens.At"];
  var Data_Lens_Getter = $PS["Data.Lens.Getter"];
  var Data_Lens_Internal_Forget = $PS["Data.Lens.Internal.Forget"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ord_Down = $PS["Data.Ord.Down"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Show = $PS["Data.Show"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_String_Pattern = $PS["Data.String.Pattern"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_Components_Category = $PS["Gargantext.Components.Category"];
  var Gargantext_Components_Category_Types = $PS["Gargantext.Components.Category.Types"];
  var Gargantext_Components_DocsTable_Types = $PS["Gargantext.Components.DocsTable.Types"];
  var Gargantext_Components_Nodes_Lists_Types = $PS["Gargantext.Components.Nodes.Lists.Types"];
  var Gargantext_Components_Search = $PS["Gargantext.Components.Search"];
  var Gargantext_Components_Table = $PS["Gargantext.Components.Table"];
  var Gargantext_Components_Table_Types = $PS["Gargantext.Components.Table.Types"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils = $PS["Gargantext.Utils"];
  var Gargantext_Utils_CacheAPI = $PS["Gargantext.Utils.CacheAPI"];
  var Gargantext_Utils_QueryString = $PS["Gargantext.Utils.QueryString"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var tableRouteWithPage = function (v) {
      var tt = Gargantext_Utils_QueryString.queryParamS("tabType")(Gargantext_Types["showTabType'"](v.tabType));
      var st = Gargantext_Utils_QueryString.queryParam(Gargantext_Components_Search["$_ShowSearchType_28"])("searchType")(v.params.searchType);
      var q = Gargantext_Utils_QueryString.queryParamS("query")(v.query);
      var ofs = Gargantext_Utils_QueryString.queryParam(Data_Show.showInt)("offset")(v.params.offset);
      var odb = Gargantext_Utils_QueryString.mQueryParamS("orderBy")(Gargantext_Components_Table_Types.orderByToForm)(v.params.orderBy);
      var lst = Gargantext_Utils_QueryString.queryParam(Data_Show.showInt)("list")(v.listId);
      var lmt = Gargantext_Utils_QueryString.queryParam(Data_Show.showInt)("limit")(v.params.limit);
      return Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value)(new Data_Maybe.Just(v.nodeId))("table" + Gargantext_Utils_QueryString.joinQueryStrings([ tt, lst, lmt, odb, ofs, st, q ]));
  };
  var tableRoute = function (v) {
      return Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value)(new Data_Maybe.Just(v.nodeId))("table" + ("?tabType=" + (Gargantext_Types["showTabType'"](v.tabType) + ("&list=" + Data_Show.show(Data_Show.showInt)(v.listId)))));
  };
  var tableHashRoute = function (nodeId) {
      return function (tabType) {
          return Gargantext_Routes.NodeAPI.create(Gargantext_Types.Node.value)(new Data_Maybe.Just(nodeId))("table/hash" + ("?tabType=" + Gargantext_Types["showTabType'"](tabType)));
      };
  };
  var res2corpus = function (v) {
      return {
          "_id": v.cid,
          category: v.category,
          date: (function (v1) {
              return v1.pub_year;
          })(v.hyperdata),
          ngramCount: v.ngramCount,
          score: v.score,
          source: (function (v1) {
              return v1.source;
          })(v.hyperdata),
          title: (function (v1) {
              return v1.title;
          })(v.hyperdata),
          url: ""
      };
  };
  var mock = false;
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.DocsTable");
  var searchBarCpt = (function () {
      var searchButton = function (query) {
          return function (queryText$prime) {
              return Reactix_DOM_HTML.button({
                  className: "btn btn-primary",
                  on: {
                      click: function (e) {
                          return Toestand_Classes.write_(Toestand_Boxes.writeBox)(queryText$prime)(query);
                      }
                  },
                  type: "submit"
              })([ Reactix_DOM_HTML.span({
                  className: "fa fa-search"
              })([  ]) ]);
          };
      };
      var onSearchKeyup = function (query) {
          return function (queryText) {
              return function (e) {
                  var $74 = DOM_Simple_Event.key(e) === "Enter";
                  if ($74) {
                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(queryText)(query);
                  };
                  return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
              };
          };
      };
      var onSearchChange = function (queryText) {
          return function (e) {
              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Reactix_SyntheticEvent.unsafeEventValue(e))(queryText);
          };
      };
      var clearButton = function (query) {
          return Reactix_DOM_HTML.button({
              className: "btn btn-danger",
              on: {
                  click: function (e) {
                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)("")(query);
                  }
              }
          })([ Reactix_DOM_HTML.span({
              className: "fa fa-times"
          })([  ]) ]);
      };
      var cpt = function (v) {
          return function (_children) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqString))(v.query))(function (query$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(query$prime))(function (queryText) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqString))(queryText))(function (queryText$prime) {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                              className: "col-md-12 row"
                          })([ Reactix_DOM_HTML.div({
                              className: "col-md-3"
                          })([  ]), Reactix_DOM_HTML.div({
                              className: "col-md-1"
                          })([ (function () {
                              var $77 = query$prime !== "";
                              if ($77) {
                                  return clearButton(v.query);
                              };
                              return Reactix_DOM_HTML.div({})([  ]);
                          })() ]), Reactix_DOM_HTML.div({
                              className: "col-md-3 form-group"
                          })([ Reactix_DOM_HTML.input({
                              className: "form-control",
                              defaultValue: query$prime,
                              on: {
                                  change: onSearchChange(queryText),
                                  keyUp: onSearchKeyup(v.query)(queryText$prime)
                              },
                              placeholder: query$prime,
                              type: "text"
                          }) ]), Reactix_DOM_HTML.div({
                              className: "col-md-1"
                          })([ searchButton(v.query)(queryText$prime) ]) ]));
                      });
                  });
              });
          };
      };
      return here.component("searchBar")(cpt);
  })();
  var searchBar = Reactix_React.createElement(Reactix_React.componentIsComponent)(searchBarCpt);
  var getPageHash = function (session) {
      return function (v) {
          return Gargantext_Sessions.get(Simple_JSON.readString)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(tableHashRoute(v.nodeId)(v.tabType));
      };
  };
  var filterDocs = function (query) {
      return function (docs) {
          var filterFunc = function (v) {
              return Data_Maybe.isJust(Data_String_CodePoints.indexOf(Data_String_Pattern.Pattern(Data_String_Common.toLower(query)))(Data_String_Common.toLower(v.hyperdata.title)));
          };
          return Data_Array.filter(filterFunc)(docs);
      };
  };
  var docChooserCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              if (v.mCorpusId instanceof Data_Maybe.Nothing) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
              };
              if (v.mCorpusId instanceof Data_Maybe.Just) {
                  var onClick = function (selected) {
                      return function (v2) {
                          return function __do() {
                              (function () {
                                  if (selected) {
                                      Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Nothing.value)(v.sidePanel)();
                                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Types.Closed.value)(v.sidePanelState)();
                                  };
                                  Toestand_Classes.write_(Toestand_Boxes.writeBox)(new Data_Maybe.Just({
                                      corpusId: v.mCorpusId.value0,
                                      listId: v.listId,
                                      mCurrentDocId: new Data_Maybe.Just(v.nodeId),
                                      nodeId: v.nodeId
                                  }))(v.sidePanel)();
                                  return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Types.Opened.value)(v.sidePanelState)();
                              })();
                              return DOM_Simple_Console.log2("[docChooser] sidePanel opened")(v.sidePanelState)();
                          };
                      };
                  };
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (v2) {
                      return v2.mCurrentDocId;
                  }))(function (val) {
                      return Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (sp) {
                          return Data_Maybe.Just.create((function () {
                              var $90 = {};
                              for (var $91 in sp) {
                                  if ({}.hasOwnProperty.call(sp, $91)) {
                                      $90[$91] = sp[$91];
                                  };
                              };
                              $90.mCurrentDocId = val;
                              return $90;
                          })());
                      });
                  })(v.sidePanel))(function (mCurrentDocId) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Data_Eq.eqInt)))(mCurrentDocId))(function (mCurrentDocId$prime) {
                          var selected = Data_Eq.eq(Data_Maybe.eqMaybe(Data_Eq.eqInt))(mCurrentDocId$prime)(new Data_Maybe.Just(v.nodeId));
                          var eyeClass = (function () {
                              if (selected) {
                                  return "fa-eye";
                              };
                              return "fa-eye-slash";
                          })();
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                              className: "btn"
                          })([ Reactix_DOM_HTML.span({
                              className: "fa " + eyeClass,
                              on: {
                                  click: onClick(selected)
                              }
                          })([  ]) ]));
                      });
                  });
              };
              throw new Error("Failed pattern match at Gargantext.Components.DocsTable (line 466, column 5 - line 467, column 25): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
      return here.component("docChooser")(cpt);
  })();
  var docChooser = Reactix_React.createElement(Reactix_React.componentIsComponent)(docChooserCpt);
  var pagePaintRawCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var wrapColElts = Data_Function["const"](Control_Category.identity(Control_Category.categoryFn));
              var trashClassName = function (v2) {
                  return function (v3) {
                      if (v2 instanceof Gargantext_Components_Category_Types.Star_0) {
                          return "trash";
                      };
                      if (v3) {
                          return "active";
                      };
                      if (!v3) {
                          return "";
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.DocsTable (line 405, column 9 - line 405, column 42): " + [ v2.constructor.name, v3.constructor.name ]);
                  };
              };
              var sid = Gargantext_Sessions_Types.sessionId(v.layout.session);
              var gi = function (v2) {
                  if (v2 instanceof Gargantext_Components_Category_Types.Star_1) {
                      return "fa fa-star";
                  };
                  return "fa fa-star-empty";
              };
              var corpusDocument = (function () {
                  var v2 = function (v3) {
                      if (Data_Boolean.otherwise) {
                          return Gargantext_Routes.Document.create(sid)(v.layout.listId);
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.DocsTable (line 371, column 1 - line 371, column 49): " + [  ]);
                  };
                  if (v.layout.mCorpusId instanceof Data_Maybe.Just) {
                      return Gargantext_Routes.CorpusDocument.create(sid)(v.layout.mCorpusId.value0)(v.layout.listId);
                  };
                  return v2(true);
              })();
              var rows = function (reload) {
                  return function (localCategories$prime) {
                      return function (mCurrentDocId$prime) {
                          var row = function (v2) {
                              var selected = Data_Eq.eq(Data_Maybe.eqMaybe(Data_Eq.eqInt))(mCurrentDocId$prime)(new Data_Maybe.Just(v2["_id"]));
                              var cat = Data_Maybe.fromMaybe(v2.category)(Data_Lens_Getter.viewOn(localCategories$prime)(Data_Lens_At.at(Data_Lens_At.atMap(Data_Ord.ordInt))(v2["_id"])(Data_Lens_Internal_Forget.strongForget)));
                              var className = gi(cat);
                              var tClassName = trashClassName(cat)(selected);
                              return {
                                  row: Gargantext_Components_Table.makeRow([ Reactix_DOM_HTML.div({
                                      className: ""
                                  })([ docChooser({
                                      listId: v.layout.listId,
                                      mCorpusId: v.layout.mCorpusId,
                                      nodeId: v2["_id"],
                                      sidePanel: v.layout.sidePanel,
                                      sidePanelState: v.layout.sidePanelState,
                                      tableReload: reload
                                  })([  ]) ]), Reactix_DOM_HTML.div({
                                      className: "column-tag flex"
                                  })([ Gargantext_Components_Category.rating({
                                      nodeId: v.layout.nodeId,
                                      row: v2,
                                      score: cat,
                                      setLocalCategories: function (lc) {
                                          return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(lc)(v.localCategories);
                                      },
                                      session: v.layout.session
                                  })([  ]) ]), Reactix_DOM_HTML.div({
                                      className: tClassName
                                  })([ Gargantext_Utils_Reactix.showText(Data_Show.showInt)(v2.date) ]), Reactix_DOM_HTML.div({
                                      className: tClassName
                                  })([ Reactix_DOM_HTML.a({
                                      href: Gargantext_Ends.url(Gargantext_Ends["$_ToUrlFrontendsAppRoute_35"])(v.layout.frontends)(corpusDocument(v2["_id"])),
                                      target: "_blank"
                                  })([ Reactix_DOM_HTML.text(v2.title) ]) ]), Reactix_DOM_HTML.div({
                                      className: tClassName
                                  })([ Reactix_DOM_HTML.text((function () {
                                      var $109 = v2.source === "";
                                      if ($109) {
                                          return "Source";
                                      };
                                      return v2.source;
                                  })()) ]), Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.text(Data_Maybe.maybe("-")(Data_Show.show(Data_Show.showInt))(v2.ngramCount)) ]) ]),
                                  "delete": true
                              };
                          };
                          return Data_Functor.map(Data_Sequence.functorSeq)(row)(Data_Array.toUnfoldable(Data_Sequence.unfoldableSeq)(v.documents));
                      };
                  };
              };
              var colNames = Data_Functor.map(Data_Functor.functorArray)(Gargantext_Components_Table_Types.ColumnName)([ "Show", "Tag", "Date", "Title", "Source", "Score" ]);
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (v2) {
                      return v2.mCurrentDocId;
                  }))(function (val) {
                      return Data_Maybe.maybe(Data_Maybe.Nothing.value)(function (sp) {
                          return Data_Maybe.Just.create((function () {
                              var $112 = {};
                              for (var $113 in sp) {
                                  if ({}.hasOwnProperty.call(sp, $113)) {
                                      $112[$113] = sp[$113];
                                  };
                              };
                              $112.mCurrentDocId = val;
                              return $112;
                          })());
                      });
                  })(v.layout.sidePanel))(function (mCurrentDocId) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Data_Eq.eqInt)))(mCurrentDocId))(function (mCurrentDocId$prime) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Map_Internal.eqMap(Data_Eq.eqInt)(Gargantext_Components_Category_Types["$_EqStar_11"])))(v.localCategories))(function (localCategories$prime) {
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Table.table({
                                  colNames: colNames,
                                  container: Gargantext_Components_Table.defaultContainer({
                                      title: "Documents"
                                  }),
                                  params: v.params,
                                  rows: rows(reload)(localCategories$prime)(mCurrentDocId$prime),
                                  syncResetButton: [ Reactix_DOM_HTML.div({})([  ]) ],
                                  totalRecords: v.layout.totalRecords,
                                  wrapColElts: wrapColElts
                              }));
                          });
                      });
                  });
              });
          };
      };
      return here.component("pagePaintRawCpt")(cpt);
  })();
  var pagePaintRaw = Reactix_React.createElement(Reactix_React.componentIsComponent)(pagePaintRawCpt);
  var convOrderBy = function (v) {
      if (v instanceof Data_Maybe.Just && (v.value0 instanceof Gargantext_Components_Table_Types.ASC && v.value0.value0 === "Date")) {
          return new Data_Maybe.Just(Gargantext_Types.DateAsc.value);
      };
      if (v instanceof Data_Maybe.Just && (v.value0 instanceof Gargantext_Components_Table_Types.DESC && v.value0.value0 === "Date")) {
          return new Data_Maybe.Just(Gargantext_Types.DateDesc.value);
      };
      if (v instanceof Data_Maybe.Just && (v.value0 instanceof Gargantext_Components_Table_Types.ASC && v.value0.value0 === "Title")) {
          return new Data_Maybe.Just(Gargantext_Types.TitleAsc.value);
      };
      if (v instanceof Data_Maybe.Just && (v.value0 instanceof Gargantext_Components_Table_Types.DESC && v.value0.value0 === "Title")) {
          return new Data_Maybe.Just(Gargantext_Types.TitleDesc.value);
      };
      if (v instanceof Data_Maybe.Just && (v.value0 instanceof Gargantext_Components_Table_Types.ASC && v.value0.value0 === "Source")) {
          return new Data_Maybe.Just(Gargantext_Types.SourceAsc.value);
      };
      if (v instanceof Data_Maybe.Just && (v.value0 instanceof Gargantext_Components_Table_Types.DESC && v.value0.value0 === "Source")) {
          return new Data_Maybe.Just(Gargantext_Types.SourceDesc.value);
      };
      return Data_Maybe.Nothing.value;
  };
  var pagePaintCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var orderWith = function (v2) {
                  var v3 = convOrderBy(v2.orderBy);
                  if (v3 instanceof Data_Maybe.Just && v3.value0 instanceof Gargantext_Types.DateAsc) {
                      return Gargantext_Utils.sortWith(Data_Sequence.functorSeq)(Data_Sequence.foldableSeq)(Data_Sequence.unfoldableSeq)(Data_Ord.ordInt)(function (v4) {
                          return v4.date;
                      });
                  };
                  if (v3 instanceof Data_Maybe.Just && v3.value0 instanceof Gargantext_Types.DateDesc) {
                      return Gargantext_Utils.sortWith(Data_Sequence.functorSeq)(Data_Sequence.foldableSeq)(Data_Sequence.unfoldableSeq)(Data_Ord_Down.ordDown(Data_Ord.ordInt))(function (v4) {
                          return v4.date;
                      });
                  };
                  if (v3 instanceof Data_Maybe.Just && v3.value0 instanceof Gargantext_Types.SourceAsc) {
                      return Gargantext_Utils.sortWith(Data_Sequence.functorSeq)(Data_Sequence.foldableSeq)(Data_Sequence.unfoldableSeq)(Data_Ord.ordString)(function (v4) {
                          return Data_String_Common.toLower(v4.source);
                      });
                  };
                  if (v3 instanceof Data_Maybe.Just && v3.value0 instanceof Gargantext_Types.SourceDesc) {
                      return Gargantext_Utils.sortWith(Data_Sequence.functorSeq)(Data_Sequence.foldableSeq)(Data_Sequence.unfoldableSeq)(Data_Ord_Down.ordDown(Data_Ord.ordString))(function (v4) {
                          return Data_Ord_Down.Down(Data_String_Common.toLower(v4.source));
                      });
                  };
                  if (v3 instanceof Data_Maybe.Just && v3.value0 instanceof Gargantext_Types.TitleAsc) {
                      return Gargantext_Utils.sortWith(Data_Sequence.functorSeq)(Data_Sequence.foldableSeq)(Data_Sequence.unfoldableSeq)(Data_Ord.ordString)(function (v4) {
                          return Data_String_Common.toLower(v4.title);
                      });
                  };
                  if (v3 instanceof Data_Maybe.Just && v3.value0 instanceof Gargantext_Types.TitleDesc) {
                      return Gargantext_Utils.sortWith(Data_Sequence.functorSeq)(Data_Sequence.foldableSeq)(Data_Sequence.unfoldableSeq)(Data_Ord_Down.ordDown(Data_Ord.ordString))(function (v4) {
                          return Data_Ord_Down.Down(Data_String_Common.toLower(v4.title));
                      });
                  };
                  return Control_Category.identity(Control_Category.categoryFn);
              };
              var filteredRows = function (params$prime) {
                  return Gargantext_Components_Table.filterRows({
                      params: params$prime
                  })(orderWith(params$prime)(Data_Array.toUnfoldable(Data_Sequence.unfoldableSeq)(v.documents)));
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "searchType";
              }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                  return "orderBy";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                  return "offset";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "limit";
              }))(Data_Eq.eqInt))))(v.params))(function (params$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Map_Internal.empty))(function (localCategories) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(pagePaintRaw({
                          documents: Data_Array.fromFoldable(Data_Sequence.foldableSeq)(filteredRows(params$prime)),
                          layout: v.layout,
                          localCategories: localCategories,
                          params: v.params
                      })([  ]));
                  });
              });
          };
      };
      return here.component("pagePaintCpt")(cpt);
  })();
  var pagePaint = Reactix_React.createElement(Reactix_React.componentIsComponent)(pagePaintCpt);
  var pageCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(v.params))(function (paramsS) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(pagePaint({
                      documents: v.documents,
                      layout: v.layout,
                      params: paramsS
                  })([  ]));
              });
          };
      };
      return here.component("pageCpt")(cpt);
  })();
  var page = Reactix_React.createElement(Reactix_React.componentIsComponent)(pageCpt);
  var pageLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Nodes_Lists_Types["$_EqCacheState_4"]))(v.cacheState))(function (cacheState$prime) {
                  var path = {
                      listId: v.listId,
                      mCorpusId: v.mCorpusId,
                      nodeId: v.nodeId,
                      params: v.params,
                      query: v.query,
                      tabType: v.tabType
                  };
                  var handleResponse = function (v2) {
                      var docs = Data_Functor.map(Data_Functor.functorArray)(res2corpus)(filterDocs(v.query)(v2.value.docs));
                      var ret = (function () {
                          if (mock) {
                              return new Data_Tuple.Tuple(0, Gargantext_Components_DocsTable_Types.sampleData);
                          };
                          return new Data_Tuple.Tuple(v2.value.count, docs);
                      })();
                      return ret;
                  };
                  if (cacheState$prime instanceof Gargantext_Components_Nodes_Lists_Types.CacheOn) {
                      var paint = function (v2) {
                          return page({
                              documents: v2.value1,
                              layout: {
                                  key: v.key,
                                  params: v.params,
                                  query: v.query,
                                  cacheState: v.cacheState,
                                  frontends: v.frontends,
                                  listId: v.listId,
                                  mCorpusId: v.mCorpusId,
                                  nodeId: v.nodeId,
                                  session: v.session,
                                  sidePanel: v.sidePanel,
                                  sidePanelState: v.sidePanelState,
                                  tabType: v.tabType,
                                  totalRecords: v2.value0
                              },
                              params: v.params
                          })([  ]);
                      };
                      var mkRequest = function (p) {
                          return Gargantext_Utils_CacheAPI.makeGetRequest(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(tableRoute(p));
                      };
                      return Gargantext_Hooks_Loader.useLoaderWithCacheAPI(Data_Tuple.eqTuple(Data_Eq.eqInt)(Data_Eq.eqArray(Gargantext_Components_DocsTable_Types["$_EqDocumentsView_10"])))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "tabType";
                      }))(Gargantext_Types["$_EqTabType_148"]))()(new Data_Symbol.IsSymbol(function () {
                          return "query";
                      }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                          return "params";
                      }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "searchType";
                      }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                          return "orderBy";
                      }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                          return "offset";
                      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                          return "limit";
                      }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                          return "nodeId";
                      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                          return "mCorpusId";
                      }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                          return "listId";
                      }))(Data_Eq.eqInt)))(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                          return "count";
                      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                          return "docs";
                      }))(Simple_JSON.readArray(Gargantext_Components_DocsTable_Types["$_ReadForeignResponse_13"]))(Simple_JSON.readFieldsNil)()())()()))({
                          cacheEndpoint: getPageHash(v.session),
                          handleResponse: handleResponse,
                          mkRequest: mkRequest,
                          path: path,
                          renderer: paint
                      });
                  };
                  if (cacheState$prime instanceof Gargantext_Components_Nodes_Lists_Types.CacheOff) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Data_Map_Internal.empty))(function (localCategories) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(v.params))(function (paramsS) {
                              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                                  return "searchType";
                              }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                                  return "orderBy";
                              }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                                  return "offset";
                              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                                  return "limit";
                              }))(Data_Eq.eqInt))))(paramsS))(function (paramsS$prime) {
                                  var render = function (v2) {
                                      return pagePaintRaw({
                                          documents: v2.value1,
                                          layout: {
                                              key: v.key,
                                              params: paramsS$prime,
                                              query: v.query,
                                              cacheState: v.cacheState,
                                              frontends: v.frontends,
                                              listId: v.listId,
                                              mCorpusId: v.mCorpusId,
                                              nodeId: v.nodeId,
                                              session: v.session,
                                              sidePanel: v.sidePanel,
                                              sidePanelState: v.sidePanelState,
                                              tabType: v.tabType,
                                              totalRecords: v2.value0
                                          },
                                          localCategories: localCategories,
                                          params: paramsS
                                      })([  ]);
                                  };
                                  var loader = function (p) {
                                      var route = tableRouteWithPage({
                                          listId: p.listId,
                                          nodeId: p.nodeId,
                                          params: paramsS$prime,
                                          query: v.query,
                                          tabType: p.tabType,
                                          mCorpusId: p.mCorpusId
                                      });
                                      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.get(Gargantext_Hooks_Loader["$_ReadForeignHashedResponse_11"](Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                                          return "count";
                                      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
                                          return "docs";
                                      }))(Simple_JSON.readArray(Gargantext_Components_DocsTable_Types["$_ReadForeignResponse_13"]))(Simple_JSON.readFieldsNil)()())()())))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(route))(function (res) {
                                          return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(function __do() {
                                              here.log2("table route")(route)();
                                              return here.log2("table res")(res)();
                                          }))(function () {
                                              return Control_Applicative.pure(Effect_Aff.applicativeAff)(handleResponse(res));
                                          });
                                      });
                                  };
                                  return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                                      return "tabType";
                                  }))(Gargantext_Types["$_EqTabType_148"]))()(new Data_Symbol.IsSymbol(function () {
                                      return "query";
                                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                                      return "params";
                                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                                      return "searchType";
                                  }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                                      return "orderBy";
                                  }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                                      return "offset";
                                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                                      return "limit";
                                  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                                      return "nodeId";
                                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                                      return "mCorpusId";
                                  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                                      return "listId";
                                  }))(Data_Eq.eqInt)))(Data_Tuple.eqTuple(Data_Eq.eqInt)(Data_Eq.eqArray(Gargantext_Components_DocsTable_Types["$_EqDocumentsView_10"])))({
                                      params: paramsS$prime,
                                      listId: path.listId,
                                      mCorpusId: path.mCorpusId,
                                      nodeId: path.nodeId,
                                      query: path.query,
                                      tabType: path.tabType
                                  })(loader)(render);
                              });
                          });
                      });
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.DocsTable (line 279, column 5 - line 310, column 61): " + [ cacheState$prime.constructor.name ]);
              });
          };
      };
      return here.component("pageLayout")(cpt);
  })();
  var pageLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(pageLayoutCpt);
  var docViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Nodes_Lists_Types["$_EqCacheState_4"]))(v.layout.cacheState))(function (cacheState$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqString))(v.query))(function (query$prime) {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                          className: "doc-table-doc-view container1"
                      })([ Gargantext_Utils_Reactix.row([ v.layout.chart, (function () {
                          if (v.layout.showSearch) {
                              return searchBar({
                                  query: v.query
                              })([  ]);
                          };
                          return Reactix_DOM_HTML.div({})([  ]);
                      })(), Reactix_DOM_HTML.div({
                          className: "col-md-12"
                      })([ pageLayout({
                          cacheState: v.layout.cacheState,
                          frontends: v.layout.frontends,
                          key: "docView-" + Data_Show.show(Gargantext_Components_Nodes_Lists_Types["$_ShowCacheState_5"])(cacheState$prime),
                          listId: v.layout.listId,
                          mCorpusId: v.layout.mCorpusId,
                          nodeId: v.layout.nodeId,
                          params: v.params,
                          query: query$prime,
                          session: v.layout.session,
                          sidePanel: v.layout.sidePanel,
                          sidePanelState: v.layout.sidePanelState,
                          tabType: v.layout.tabType,
                          totalRecords: v.layout.totalRecords
                      })([  ]) ]) ]) ]));
                  });
              });
          };
      };
      return here.component("docView")(cpt);
  })();
  var docView = Reactix_React.createElement(Reactix_React.componentIsComponent)(docViewCpt);
  var docViewLayoutCpt = (function () {
      var cpt = function (layout) {
          return function (_children) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(""))(function (query) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(docView({
                      layout: layout,
                      params: Gargantext_Components_Table.initialParams,
                      query: query
                  })([  ]));
              });
          };
      };
      return here.component("docViewLayout")(cpt);
  })();
  var docViewLayout = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(docViewLayoutCpt)(props)([  ]);
  };
  exports["docViewLayout"] = docViewLayout;
})(PS);
(function(exports) {
  /* global exports */
  "use strict";
  var React =require("react"); 

  function createClass(baseClass) {
    function bindProperty(instance, prop, value) {
      switch (prop) {
        case 'state':
        case 'render':
        case 'componentDidMount':
        case 'componentWillUnmount':
          instance[prop] = value;
          break;

        case 'componentDidCatch':
        case 'componentWillUpdate':
        case 'shouldComponentUpdate':
        case 'getSnapshotBeforeUpdate':
          instance[prop] = function (a, b) { return value(a)(b)(); };
          break;

        case 'componentDidUpdate':
          instance[prop] = function (a, b, c) { return value(a)(b)(c)(); };
          break;

        case 'unsafeComponentWillMount':
          instance['UNSAFE_componentWillMount'] = value;
          break;

        case 'unsafeComponentWillReceiveProps':
          instance['UNSAFE_componentWillReceiveProps'] = function (a) { return value(a)(); };
          break;

        case 'unsafeComponentWillUpdate':
          instance['UNSAFE_componentWillUpdate'] = function (a, b) { return value(a)(b)(); };
          break;

        default:
          throw new Error('[purescript-react] Not a component property: ' + prop);
      }
    }

    return function (displayName) {
      return function (ctrFn) {
        var Constructor = function (props) {
          baseClass.call(this, props);
          var spec = ctrFn(this)();
          for (var k in spec) {
            bindProperty(this, k, spec[k]);
          }
        };

        Constructor.displayName = displayName;
        Constructor.prototype = Object.create(baseClass.prototype);
        Constructor.prototype.constructor = Constructor;

        return Constructor;
      };
    };
  }

  function createClassWithDerivedState(classCtr) {
    return function(displayName) {
      return function(getDerivedStateFromProps) {
        return function(ctrFn) {
          var Constructor = componentImpl(displayName)(ctrFn);
          Constructor.getDerivedStateFromProps = function(a, b) { return getDerivedStateFromProps(a)(b); };
          return Constructor;
        };
      };
    };
  }

  var componentImpl = createClass(React.Component);
  exports.componentImpl = componentImpl;

  function getProps(this_) {
    return function(){
      return this_.props;
    };
  }
  exports.getProps = getProps;                 

  function setStateImpl(this_) {
    return function(state){
      return function(){
        this_.setState(state);
      };
    };
  }
  exports.setStateImpl = setStateImpl;

  function setStateWithCallbackImpl(this_) {
    return function(state){
      return function(cb){
        return function() {
          this_.setState(state, cb);
        };
      };
    };
  }                                                           

  function getState(this_) {
    return function(){
      if (!this_.state) {
        throw new Error('[purescript-react] Cannot get state within constructor');
      }
      return this_.state;
    };
  }
  exports.getState = getState;

  function forceUpdateWithCallback(this_) {
    return function(cb) {
      return function() {
        this_.forceUpdate(cb);
      };
    };
  }                                                         

  function createElement(class_) {
    return function(props){
      return function(children){
        return React.createElement.apply(React, [class_, props].concat(children));
      };
    };
  }
  exports.createElementImpl = createElement;
  exports.createElementTagName = createElement;

  function createLeafElement(class_) {
    return function(props) {
      return React.createElement(class_, props);
    };
  }                                                 

  function createElementDynamic(class_) {
    return function(props) {
      return function(children){
        return React.createElement(class_, props, children);
      };
    };
  };
  exports.createElementDynamicImpl = createElementDynamic;
  exports.createElementTagNameDynamic = createElementDynamic;

  function createContext(defaultValue) {
    var context = React.createContext(defaultValue);
    return {
      consumer: context.Consumer,
      provider: context.Provider
    };
  }
})(PS["React"] = PS["React"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["React"] = $PS["React"] || {};
  var exports = $PS["React"];
  var $foreign = $PS["React"];                                 
  var unsafeCreateElementDynamic = $foreign.createElementDynamicImpl;
  var setState = function (dictUnion) {
      return $foreign.setStateImpl;
  };
  var createElement = function (dictReactPropFields) {
      return $foreign.createElementImpl;
  };
  var component = function (dictReactComponentSpec) {
      return $foreign.componentImpl;
  };
  exports["component"] = component;
  exports["setState"] = setState;
  exports["createElement"] = createElement;
  exports["unsafeCreateElementDynamic"] = unsafeCreateElementDynamic;
  exports["getProps"] = $foreign.getProps;
  exports["getState"] = $foreign.getState;
  exports["createElementTagName"] = $foreign.createElementTagName;
  exports["createElementTagNameDynamic"] = $foreign.createElementTagNameDynamic;
})(PS);
(function(exports) {
  /* global exports */
  "use strict";
  var React =require("react"); 

  function unsafeMkProps(key) {
    return function(value){
      var result = {};
      result[key] = value;
      return result;
    };
  }
  exports.unsafeMkProps = unsafeMkProps;

  function unsafeUnfoldProps(key) {
    return function(value){
      var result = {};
      var props = {};
      props[key] = result;

      for (var subprop in value) {
        if (value.hasOwnProperty(subprop)) {
          result[subprop] = value[subprop];
        }
      }

      return props;
    };
  }
  exports.unsafeUnfoldProps = unsafeUnfoldProps;

  function unsafePrefixProps(prefix) {
    return function(value){
      var result = {};

      for (var prop in value) {
        if (value.hasOwnProperty(prop)) {
          result[prefix + prop] = value[prop];
        }
      }

      return result;
    };
  }                                             

  function unsafeFromPropsArray(props) {
    var result = {};

    for (var i = 0, len = props.length; i < len; i++) {
      var prop = props[i];

      for (var key in prop) {
        if (prop.hasOwnProperty(key)) {
          result[key] = prop[key];
        }
      }
    }

    return result;
  };
  exports.unsafeFromPropsArray = unsafeFromPropsArray;
})(PS["React.DOM.Props"] = PS["React.DOM.Props"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["React.DOM.Props"] = $PS["React.DOM.Props"] || {};
  var exports = $PS["React.DOM.Props"];
  var $foreign = $PS["React.DOM.Props"];
  var Effect_Uncurried = $PS["Effect.Uncurried"]; 
  var style = $foreign.unsafeUnfoldProps("style");
  var onClick = function (f) {
      return $foreign.unsafeMkProps("onClick")(Effect_Uncurried.mkEffectFn1(f));
  };
  exports["style"] = style;
  exports["onClick"] = onClick;
  exports["unsafeFromPropsArray"] = $foreign.unsafeFromPropsArray;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["React.DOM"] = $PS["React.DOM"] || {};
  var exports = $PS["React.DOM"];
  var React = $PS["React"];
  var React_DOM_Props = $PS["React.DOM.Props"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];
  var text = Unsafe_Coerce.unsafeCoerce;  
  var mkDOM = function (dynamic) {
      return function (tag) {
          return function (props) {
              var createElement = (function () {
                  if (!dynamic) {
                      return React.createElementTagName;
                  };
                  if (dynamic) {
                      return React.createElementTagNameDynamic;
                  };
                  throw new Error("Failed pattern match at React.DOM (line 15, column 5 - line 17, column 55): " + [ dynamic.constructor.name ]);
              })();
              return createElement(tag)(React_DOM_Props.unsafeFromPropsArray(props));
          };
      };
  };                              
  var span = mkDOM(false)("span");
  var div = mkDOM(false)("div");
  var div$prime = div([  ]);  
  var a = mkDOM(false)("a");
  exports["text"] = text;
  exports["a"] = a;
  exports["div'"] = div$prime;
  exports["span"] = span;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.AutoUpdate"] = $PS["Gargantext.Components.AutoUpdate"] || {};
  var exports = $PS["Gargantext.Components.AutoUpdate"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Effect = $PS["Effect"];
  var Effect_Timer = $PS["Effect.Timer"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var React = $PS["React"];
  var React_DOM = $PS["React.DOM"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.AutoUpdate");
  var autoUpdateCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Maybe.Nothing.value))(function (intervalRef) {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect'"]((function () {
                      var mInterval = Reactix_React.readRef(intervalRef);
                      if (mInterval instanceof Data_Maybe.Nothing) {
                          return function __do() {
                              var intervalId = Effect_Timer.setInterval(v.duration)(v.effect)();
                              return Reactix_React.setRef(intervalRef)(new Data_Maybe.Just(intervalId))();
                          };
                      };
                      if (mInterval instanceof Data_Maybe.Just) {
                          return function __do() {
                              Effect_Timer.clearInterval(mInterval.value0)();
                              var intervalId1 = Effect_Timer.setInterval(v.duration)(v.effect)();
                              return Reactix_React.setRef(intervalRef)(new Data_Maybe.Just(intervalId1))();
                          };
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.AutoUpdate (line 59, column 9 - line 66, column 51): " + [ mInterval.constructor.name ]);
                  })()))(function () {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
                  });
              });
          };
      };
      return here.component("autoUpdate")(cpt);
  })();
  var autoUpdateClass = React.component()("AutoUpdate")(function ($$this) {
      return Control_Applicative.pure(Effect.applicativeEffect)({
          state: {
              intervalId: Data_Maybe.Nothing.value
          },
          render: Control_Applicative.pure(Effect.applicativeEffect)(React_DOM["div'"]([  ])),
          componentDidMount: function __do() {
              var v = React.getProps($$this)();
              var intervalId = Effect_Timer.setInterval(v.duration)(v.effect)();
              return React.setState()($$this)({
                  intervalId: new Data_Maybe.Just(intervalId)
              })();
          },
          componentWillUnmount: function __do() {
              var v = React.getState($$this)();
              return Data_Foldable.traverse_(Effect.applicativeEffect)(Data_Foldable.foldableMaybe)(Effect_Timer.clearInterval)(v.intervalId)();
          }
      });
  });
  var autoUpdateElt = function (props) {
      return React.createElement()(autoUpdateClass)(props)([  ]);
  };
  var autoUpdate = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(autoUpdateCpt)(props)([  ]);
  };
  exports["autoUpdateElt"] = autoUpdateElt;
  exports["autoUpdate"] = autoUpdate;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.NgramsTable.Components"] = $PS["Gargantext.Components.NgramsTable.Components"] || {};
  var exports = $PS["Gargantext.Components.NgramsTable.Components"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Lens_At = $PS["Data.Lens.At"];
  var Data_Lens_Fold = $PS["Data.Lens.Fold"];
  var Data_Lens_Getter = $PS["Data.Lens.Getter"];
  var Data_Lens_Index = $PS["Data.Lens.Index"];
  var Data_Lens_Internal_Forget = $PS["Data.Lens.Internal.Forget"];
  var Data_List = $PS["Data.List"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid_Endo = $PS["Data.Monoid.Endo"];
  var Data_Nullable = $PS["Data.Nullable"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Set = $PS["Data.Set"];
  var Data_Show = $PS["Data.Show"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
  var Gargantext_Components_NgramsTable_Core = $PS["Gargantext.Components.NgramsTable.Core"];
  var Gargantext_Components_Table = $PS["Gargantext.Components.Table"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var React_DOM = $PS["React.DOM"];
  var React_DOM_Props = $PS["React.DOM.Props"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var termStyle = function (v) {
      return function (opacity) {
          if (v instanceof Gargantext_Types.MapTerm) {
              return React_DOM_Props.style({
                  color: "green",
                  opacity: opacity
              });
          };
          if (v instanceof Gargantext_Types.StopTerm) {
              return React_DOM_Props.style({
                  color: "red",
                  opacity: opacity,
                  textDecoration: "line-through"
              });
          };
          if (v instanceof Gargantext_Types.CandidateTerm) {
              return React_DOM_Props.style({
                  color: "#767676",
                  opacity: opacity
              });
          };
          throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Components (line 295, column 1 - line 295, column 47): " + [ v.constructor.name, opacity.constructor.name ]);
      };
  };
  var tablePatchHasNgrams = function (ngramsTablePatch) {
      return function (ngrams) {
          return Data_Maybe.isJust(Data_Lens_Getter.viewOn(ngramsTablePatch.ngramsPatches)((function () {
              var $64 = Gargantext_Components_NgramsTable_Core["_PatchMap"](Data_Lens_Internal_Forget.profunctorForget);
              var $65 = Data_Lens_At.at(Data_Lens_At.atMap(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"]))(ngrams)(Data_Lens_Internal_Forget.strongForget);
              return function ($66) {
                  return $64($65($66));
              };
          })()));
      };
  };
  var nextTermList = function (v) {
      if (v instanceof Gargantext_Types.MapTerm) {
          return Gargantext_Types.StopTerm.value;
      };
      if (v instanceof Gargantext_Types.StopTerm) {
          return Gargantext_Types.CandidateTerm.value;
      };
      if (v instanceof Gargantext_Types.CandidateTerm) {
          return Gargantext_Types.MapTerm.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Components (line 306, column 1 - line 306, column 41): " + [ v.constructor.name ]);
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.NgramsTable.Components");
  var searchInputCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var removeButton = Reactix_DOM_HTML.button({
                  className: "btn btn-danger",
                  on: {
                      click: function (e) {
                          return Toestand_Classes.write(Toestand_Boxes.writeBox)("")(v.searchQuery);
                      }
                  }
              })([ Reactix_DOM_HTML.span({
                  className: "fa fa-times"
              })([  ]) ]);
              var searchButton = function (searchQuery$prime) {
                  return Reactix_DOM_HTML.div({
                      className: "input-group-prepend"
                  })([ (function () {
                      var $22 = searchQuery$prime !== "";
                      if ($22) {
                          return removeButton;
                      };
                      return Reactix_DOM_HTML.span({
                          className: "fa fa-search input-group-text"
                      })([  ]);
                  })() ]);
              };
              var fieldInput = function (searchQuery$prime) {
                  return Reactix_DOM_HTML.input({
                      className: "form-control",
                      defaultValue: searchQuery$prime,
                      name: "search",
                      on: {
                          input: function (e) {
                              return Toestand_Classes.write(Toestand_Boxes.writeBox)(Reactix_SyntheticEvent.unsafeEventValue(e))(v.searchQuery);
                          }
                      },
                      placeholder: "Search",
                      type: "value"
                  });
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqString))(v.searchQuery))(function (searchQuery$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.div({
                      className: "col-12"
                  })([ Reactix_DOM_HTML.div({
                      className: "input-group"
                  })([ searchButton(searchQuery$prime), fieldInput(searchQuery$prime) ]) ]) ]));
              });
          };
      };
      return here.component("searchInput")(cpt);
  })();
  var searchInput = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(searchInputCpt)(props)([  ]);
  };
  var selectionCheckboxCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(Data_Nullable["null"]))(function (ref) {
                  return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect'"](FFI_Simple_Functions.delay(FFI_Simple_Functions.delayMonad(Effect.monadEffect))(Data_Unit.unit)(function (v2) {
                      var mCb = Data_Nullable.toMaybe(Reactix_React.readRef(ref));
                      if (mCb instanceof Data_Maybe.Nothing) {
                          return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                      };
                      if (mCb instanceof Data_Maybe.Just) {
                          return function __do() {
                              (function () {
                                  var $27 = v.allNgramsSelected || Data_Set.isEmpty(v.ngramsSelection);
                                  if ($27) {
                                      return Gargantext_Utils_Reactix.setIndeterminateCheckbox(mCb.value0)(false)();
                                  };
                                  return Gargantext_Utils_Reactix.setIndeterminateCheckbox(mCb.value0)(true)();
                              })();
                              return Data_Unit.unit;
                          };
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Components (line 96, column 9 - line 103, column 22): " + [ mCb.constructor.name ]);
                  })))(function () {
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.input({
                          checked: v.allNgramsSelected,
                          className: "checkbox",
                          on: {
                              change: Data_Function["const"](v.dispatch(Gargantext_Components_NgramsTable_Core.ToggleSelectAll.value))
                          },
                          ref: ref,
                          type: "checkbox"
                      }));
                  });
              });
          };
      };
      return here.component("selectionCheckbox")(cpt);
  })();
  var selectionCheckbox = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(selectionCheckboxCpt)(props)([  ]);
  };
  var treeCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var tag = (function () {
                  var v2 = v.ngramsClick(v.ngramsDepth);
                  if (v2 instanceof Data_Maybe.Just) {
                      return React_DOM.a(Data_Semigroup.append(Data_Semigroup.semigroupArray)(v.ngramsStyle)([ React_DOM_Props.onClick(Data_Function["const"](v2.value0)) ]));
                  };
                  if (v2 instanceof Data_Maybe.Nothing) {
                      return React_DOM.span(v.ngramsStyle);
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Components (line 182, column 11 - line 186, column 31): " + [ v2.constructor.name ]);
              })();
              var forest = (function () {
                  var depth = v.ngramsDepth.depth + 1 | 0;
                  var $36 = depth > 10;
                  if ($36) {
                      return Data_Function["const"](Reactix_DOM_HTML.text("ERROR DEPTH > 10"));
                  };
                  var $67 = Reactix_DOM_HTML.ul({});
                  var $68 = Data_Functor.map(Data_Functor.functorArray)(function (ngrams) {
                      return tree({
                          ngramsEdit: v.ngramsEdit,
                          ngramsTable: v.ngramsTable,
                          ngramsClick: v.ngramsClick,
                          ngramsDepth: {
                              depth: depth,
                              ngrams: ngrams
                          },
                          ngramsStyle: v.ngramsStyle
                      });
                  });
                  var $69 = Data_List.toUnfoldable(Data_Unfoldable.unfoldableArray);
                  return function ($70) {
                      return $67($68($69($70)));
                  };
              })();
              var edit = function (effect) {
                  return [ Reactix_DOM_HTML.text(" "), Reactix_DOM_HTML.i({
                      className: "fa fa-pencil",
                      on: {
                          click: Data_Function["const"](effect)
                      }
                  })([  ]) ];
              };
              var cs = Data_Lens_Fold.toListOfOn(v.ngramsTable)((function () {
                  var $71 = Data_Lens_Index.ix(Gargantext_Components_NgramsTable_Core["$_IndexNgramsTableNgramsTer_186"])(v.ngramsDepth.ngrams)(Data_Lens_Internal_Forget.strongForget)(Data_Lens_Internal_Forget.choiceForget(Data_Monoid_Endo.monoidEndo(Control_Category.categoryFn)));
                  var $72 = Gargantext_Components_NgramsTable_Core["_NgramsRepoElement"](Data_Lens_Internal_Forget.profunctorForget);
                  var $73 = Gargantext_Components_NgramsTable_Core["_children"](Data_Lens_Internal_Forget.strongForget);
                  var $74 = Data_Lens_Fold.folded(Data_Monoid_Endo.monoidEndo(Control_Category.categoryFn))(Data_Set.foldableSet);
                  return function ($75) {
                      return $71($72($73($74($75))));
                  };
              })());
              var leaf = Data_List["null"](cs);
              var open = !leaf || false;
              var style = (function () {
                  if (leaf) {
                      return {
                          color: "#adb5bd"
                      };
                  };
                  return {
                      color: ""
                  };
              })();
              var className = "fa fa-chevron-" + (function () {
                  if (open) {
                      return "down";
                  };
                  return "right";
              })();
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.li({
                  style: {
                      width: "100%"
                  }
              })(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ Reactix_DOM_HTML.i({
                  className: className,
                  style: style
              })([  ]) ])(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ Gargantext_Utils_Reactix.buff(tag([ React_DOM.text(" " + Gargantext_Components_NgramsTable_Core.ngramsTermText(v.ngramsDepth.ngrams)) ])) ])(Data_Semigroup.append(Data_Semigroup.semigroupArray)(Data_Maybe.maybe([  ])(edit)(v.ngramsEdit(v.ngramsDepth)))([ forest(cs) ])))));
          };
      };
      return here.component("tree")(cpt);
  })();
  var tree = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(treeCpt)(p)([  ]);
  };
  var renderNgramsTreeCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.ul({})([ Reactix_DOM_HTML.span({
                  className: "tree"
              })([ Reactix_DOM_HTML.span({
                  className: "righthanded"
              })([ tree({
                  ngramsClick: v.ngramsClick,
                  ngramsDepth: {
                      ngrams: v.ngrams,
                      depth: 0
                  },
                  ngramsEdit: v.ngramsEdit,
                  ngramsStyle: v.ngramsStyle,
                  ngramsTable: v.ngramsTable
              }) ]) ]) ]));
          };
      };
      return here.component("renderNgramsTree")(cpt);
  })();
  var renderNgramsTree = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(renderNgramsTreeCpt)(p)([  ]);
  };
  var renderNgramsItemCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var termList = Data_Lens_Getter.viewOn(v.ngramsElement)((function () {
                  var $76 = Gargantext_Components_NgramsTable_Core["_NgramsElement"](Data_Lens_Internal_Forget.profunctorForget);
                  var $77 = Gargantext_Components_NgramsTable_Core["_list"](Data_Lens_Internal_Forget.strongForget);
                  return function ($78) {
                      return $76($77($78));
                  };
              })());
              var selected = Reactix_DOM_HTML.input({
                  checked: Data_Set.member(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(v.ngrams)(v.ngramsSelection),
                  className: "checkbox",
                  on: {
                      change: Data_Function["const"](v.dispatch(new Gargantext_Components_NgramsTable_Core.ToggleSelect(v.ngrams)))
                  },
                  type: "checkbox"
              });
              var onClick = function (v2) {
                  return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
              };
              var ngramsTransient = tablePatchHasNgrams(v.ngramsLocalPatch)(v.ngrams);
              var ngramsOpacity = (function () {
                  if (ngramsTransient) {
                      return 0.5;
                  };
                  if (Data_Boolean.otherwise) {
                      return 1.0;
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Components (line 288, column 9 - line 290, column 34): " + [  ]);
              })();
              var ngramsStyle = [ termStyle(termList)(ngramsOpacity) ];
              var ngramsEdit = (function () {
                  var $79 = Data_Lens_Getter.view(Gargantext_Components_NgramsTable_Core["_ngrams"](Data_Lens_Internal_Forget.strongForget));
                  return function ($80) {
                      return Data_Maybe.Just.create(v.dispatch(Gargantext_Components_NgramsTable_Core.SetParentResetChildren.create(Data_Maybe.Just.create($79($80)))));
                  };
              })();
              var ngramsDepth = {
                  ngrams: v.ngrams,
                  depth: 0
              };
              var cycleTermListItem = function (n) {
                  return Gargantext_Components_NgramsTable_Core.setTermListA(n)(Gargantext_Components_NgramsTable_Core.replace(Gargantext_Types["$_EqTermList_103"])(termList)(nextTermList(termList)));
              };
              var ngramsClick = (function () {
                  var $81 = Data_Lens_Getter.view(Gargantext_Components_NgramsTable_Core["_ngrams"](Data_Lens_Internal_Forget.strongForget));
                  return function ($82) {
                      return Data_Maybe.Just.create(v.dispatch(Gargantext_Components_NgramsTable_Core.CoreAction.create(cycleTermListItem($81($82)))));
                  };
              })();
              var tag = (function () {
                  var v2 = ngramsClick(ngramsDepth);
                  if (v2 instanceof Data_Maybe.Just) {
                      return React_DOM.a(Data_Semigroup.append(Data_Semigroup.semigroupArray)(ngramsStyle)([ React_DOM_Props.onClick(Data_Function["const"](v2.value0)) ]));
                  };
                  if (v2 instanceof Data_Maybe.Nothing) {
                      return React_DOM.span(ngramsStyle);
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.NgramsTable.Components (line 250, column 11 - line 254, column 31): " + [ v2.constructor.name ]);
              })();
              var checkbox = function (termList$prime) {
                  var chkd = Data_Eq.eq(Gargantext_Types["$_EqTermList_103"])(termList)(termList$prime);
                  var termList$prime$prime = (function () {
                      if (chkd) {
                          return Gargantext_Types.CandidateTerm.value;
                      };
                      return termList$prime;
                  })();
                  return Reactix_DOM_HTML.input({
                      checked: chkd,
                      className: "checkbox",
                      on: {
                          change: Data_Function["const"](v.dispatch(Gargantext_Components_NgramsTable_Core.CoreAction.create(Gargantext_Components_NgramsTable_Core.setTermListA(v.ngrams)(Gargantext_Components_NgramsTable_Core.replace(Gargantext_Types["$_EqTermList_103"])(termList)(termList$prime$prime)))))
                      },
                      readOnly: ngramsTransient,
                      type: "checkbox"
                  });
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Table.makeRow([ Reactix_DOM_HTML.div({
                  className: "ngrams-selector"
              })([ Reactix_DOM_HTML.span({
                  className: "ngrams-chooser fa fa-eye-slash",
                  on: {
                      click: onClick
                  }
              })([  ]) ]), selected, checkbox(Gargantext_Types.MapTerm.value), checkbox(Gargantext_Types.StopTerm.value), Reactix_DOM_HTML.div({})((function () {
                  var $56 = Data_Eq.eq(Data_Maybe.eqMaybe(Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"]))(v.ngramsParent)(Data_Maybe.Nothing.value);
                  if ($56) {
                      return [ renderNgramsTree({
                          ngramsTable: v.ngramsTable,
                          ngrams: v.ngrams,
                          ngramsStyle: ngramsStyle,
                          ngramsClick: ngramsClick,
                          ngramsEdit: ngramsEdit
                      }) ];
                  };
                  return [ Reactix_DOM_HTML.a({
                      on: {
                          click: Data_Function["const"](v.dispatch(new Gargantext_Components_NgramsTable_Core.ToggleChild(true, v.ngrams)))
                      }
                  })([ Reactix_DOM_HTML.i({
                      className: "fa fa-plus"
                  })([  ]) ]), Gargantext_Utils_Reactix.buff(tag([ React_DOM.text(" " + Gargantext_Components_NgramsTable_Core.ngramsTermText(ngramsDepth.ngrams)) ])) ];
              })()), Reactix_DOM_HTML.text(Data_Show.show(Data_Show.showInt)(Data_Lens_Getter.viewOn(v.ngramsElement)((function () {
                  var $83 = Gargantext_Components_NgramsTable_Core["_NgramsElement"](Data_Lens_Internal_Forget.profunctorForget);
                  var $84 = Gargantext_Components_NgramsTable_Core["_occurrences"](Data_Lens_Internal_Forget.strongForget);
                  return function ($85) {
                      return $83($84($85));
                  };
              })()))) ]));
          };
      };
      return here.component("renderNgramsItem")(cpt);
  })();
  var renderNgramsItem = Reactix_React.createElement(Reactix_React.componentIsComponent)(renderNgramsItemCpt);
  exports["searchInput"] = searchInput;
  exports["selectionCheckbox"] = selectionCheckbox;
  exports["renderNgramsTree"] = renderNgramsTree;
  exports["renderNgramsItem"] = renderNgramsItem;
  exports["tablePatchHasNgrams"] = tablePatchHasNgrams;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Utils.Seq"] = $PS["Gargantext.Utils.Seq"] || {};
  var exports = $PS["Gargantext.Utils.Seq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Sequence = $PS["Data.Sequence"];                
  var mapMaybe = function (f) {
      return Data_Sequence.concatMap((function () {
          var $0 = Data_Maybe.maybe(Data_Sequence.empty)(Data_Sequence.singleton);
          return function ($1) {
              return $0(f($1));
          };
      })());
  };
  exports["mapMaybe"] = mapMaybe;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.NgramsTable"] = $PS["Gargantext.Components.NgramsTable"] || {};
  var exports = $PS["Gargantext.Components.NgramsTable"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Data_Array = $PS["Data.Array"];
  var Data_Boolean = $PS["Data.Boolean"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_FunctorWithIndex = $PS["Data.FunctorWithIndex"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Lens_At = $PS["Data.Lens.At"];
  var Data_Lens_Fold = $PS["Data.Lens.Fold"];
  var Data_Lens_Getter = $PS["Data.Lens.Getter"];
  var Data_Lens_Index = $PS["Data.Lens.Index"];
  var Data_Lens_Internal_Forget = $PS["Data.Lens.Internal.Forget"];
  var Data_Lens_Prism_Maybe = $PS["Data.Lens.Prism.Maybe"];
  var Data_Lens_Setter = $PS["Data.Lens.Setter"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Maybe_First = $PS["Data.Maybe.First"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Monoid_Additive = $PS["Data.Monoid.Additive"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Ord_Down = $PS["Data.Ord.Down"];
  var Data_Profunctor = $PS["Data.Profunctor"];
  var Data_Profunctor_Choice = $PS["Data.Profunctor.Choice"];
  var Data_Profunctor_Strong = $PS["Data.Profunctor.Strong"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Semiring = $PS["Data.Semiring"];
  var Data_Sequence = $PS["Data.Sequence"];
  var Data_Set = $PS["Data.Set"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_AutoUpdate = $PS["Gargantext.Components.AutoUpdate"];
  var Gargantext_Components_NgramsTable_Components = $PS["Gargantext.Components.NgramsTable.Components"];
  var Gargantext_Components_NgramsTable_Core = $PS["Gargantext.Components.NgramsTable.Core"];
  var Gargantext_Components_NgramsTable_Loader = $PS["Gargantext.Components.NgramsTable.Loader"];
  var Gargantext_Components_Nodes_Lists_Types = $PS["Gargantext.Components.Nodes.Lists.Types"];
  var Gargantext_Components_Search = $PS["Gargantext.Components.Search"];
  var Gargantext_Components_Table = $PS["Gargantext.Components.Table"];
  var Gargantext_Components_Table_Types = $PS["Gargantext.Components.Table.Types"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Prelude = $PS["Gargantext.Prelude"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils = $PS["Gargantext.Utils"];
  var Gargantext_Utils_CacheAPI = $PS["Gargantext.Utils.CacheAPI"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Seq = $PS["Gargantext.Utils.Seq"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var wrapColElts = function (dictShow) {
      return function (v) {
          return function (v1) {
              return function (v2) {
                  if (v2 === "Select") {
                      return Data_Function["const"]([ Gargantext_Components_NgramsTable_Components.selectionCheckbox(v) ]);
                  };
                  if (v2 === "Score") {
                      return function (v3) {
                          return Data_Semigroup.append(Data_Semigroup.semigroupArray)(v3)([ Reactix_DOM_HTML.text("(" + (Data_Show.show(dictShow)(v1) + ")")) ]);
                      };
                  };
                  return Control_Category.identity(Control_Category.categoryFn);
              };
          };
      };
  };
  var sumOccurrences = function (nt) {
      var sumOccTerm = function (seen) {
          return function (label) {
              if (Data_Set.member(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(label)(seen)) {
                  return 0;
              };
              if (Data_Boolean.otherwise) {
                  return sumOccChildren(Data_Set.insert(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(label)(seen))({
                      occurrences: Data_Lens_Getter.viewOn(nt)((function () {
                          var $273 = Gargantext_Components_NgramsTable_Core["_NgramsTable"](Data_Lens_Internal_Forget.profunctorForget);
                          var $274 = Gargantext_Components_NgramsTable_Core["_ngrams_scores"](Data_Lens_Internal_Forget.strongForget);
                          var $275 = Data_Lens_Index.ix(Data_Lens_Index.indexMap(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"]))(label)(Data_Lens_Internal_Forget.strongForget)(Data_Lens_Internal_Forget.choiceForget(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt)));
                          return function ($276) {
                              return $273($274($275($276)));
                          };
                      })()),
                      children: Data_Lens_Getter.viewOn(nt)((function () {
                          var $277 = Data_Lens_Index.ix(Gargantext_Components_NgramsTable_Core["$_IndexNgramsTableNgramsTer_186"])(label)(Data_Lens_Internal_Forget.strongForget)(Data_Lens_Internal_Forget.choiceForget(Data_Set.monoidSet(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])));
                          var $278 = Gargantext_Components_NgramsTable_Core["_NgramsRepoElement"](Data_Lens_Internal_Forget.profunctorForget);
                          var $279 = Gargantext_Components_NgramsTable_Core["_children"](Data_Lens_Internal_Forget.strongForget);
                          return function ($280) {
                              return $277($278($279($280)));
                          };
                      })())
                  });
              };
              throw new Error("Failed pattern match at Gargantext.Components.NgramsTable (line 716, column 7 - line 716, column 65): " + [ seen.constructor.name, label.constructor.name ]);
          };
      };
      var sumOccChildren = function (seen) {
          return function (v) {
              return Data_Semigroup.append(Data_Monoid_Additive.semigroupAdditive(Data_Semiring.semiringInt))(v.occurrences)(Data_Lens_Getter.viewOn(v.children)((function () {
                  var $281 = Data_Lens_Fold.folded(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt))(Data_Set.foldableSet);
                  var $282 = Data_Lens_Getter.to(sumOccTerm(seen));
                  return function ($283) {
                      return $281($282($283));
                  };
              })()));
          };
      };
      return sumOccChildren(Data_Monoid.mempty(Data_Set.monoidSet(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])));
  };
  var setTermListSetA = function (ngramsTable) {
      return function (ns) {
          return function (new_list) {
              var f = function (n) {
                  return function (unit) {
                      var cur_list = Data_Lens_Fold.previewOn(ngramsTable)((function () {
                          var $284 = Data_Lens_At.at(Gargantext_Components_NgramsTable_Core["$_AtNgramsTableNgramsTermNg_187"])(n)(Data_Lens_Internal_Forget.strongForget);
                          var $285 = Data_Lens_Prism_Maybe["_Just"](Data_Lens_Internal_Forget.choiceForget(Data_Maybe_First.monoidFirst));
                          var $286 = Gargantext_Components_NgramsTable_Core["_NgramsRepoElement"](Data_Lens_Internal_Forget.profunctorForget);
                          var $287 = Gargantext_Components_NgramsTable_Core["_list"](Data_Lens_Internal_Forget.strongForget);
                          return function ($288) {
                              return $284($285($286($287($288))));
                          };
                      })());
                      var patch_list = Data_Maybe.maybe(Data_Monoid.mempty(Gargantext_Components_NgramsTable_Core["$_MonoidReplace_192"](Gargantext_Types["$_EqTermList_103"])))(function (c) {
                          return Gargantext_Components_NgramsTable_Core.replace(Gargantext_Types["$_EqTermList_103"])(c)(new_list);
                      })(cur_list);
                      return new Gargantext_Components_NgramsTable_Core.NgramsPatch({
                          patch_list: patch_list,
                          patch_children: Data_Monoid.mempty(Gargantext_Components_NgramsTable_Core["$_MonoidPatchSet_198"](Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"]))
                      });
                  };
              };
              return Gargantext_Components_NgramsTable_Core.CoreAction.create(Gargantext_Components_NgramsTable_Core.CommitPatch.create(Gargantext_Components_NgramsTable_Core.fromNgramsPatches(Gargantext_Components_NgramsTable_Core.PatchMap(Data_FunctorWithIndex.mapWithIndex(Data_Map_Internal.functorWithIndexMap)(f)(ns)))));
          };
      };
  };
  var selectNgramsOnFirstPage = function (rows) {
      return Data_Set.fromFoldable(Data_Sequence.foldableSeq)(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(Data_Functor.map(Data_Sequence.functorSeq)(Data_Lens_Getter.view((function () {
          var $289 = Gargantext_Components_NgramsTable_Core["_NgramsElement"](Data_Lens_Internal_Forget.profunctorForget);
          var $290 = Gargantext_Components_NgramsTable_Core["_ngrams"](Data_Lens_Internal_Forget.strongForget);
          return function ($291) {
              return $289($290($291));
          };
      })()))(rows));
  };
  var optps1 = function (dictShow) {
      return function (v) {
          var value = Data_Maybe.maybe("")(Data_Show.show(dictShow))(v.mval);
          return Reactix_DOM_HTML.option({
              value: value
          })([ Reactix_DOM_HTML.text(v.desc) ]);
      };
  };
  var ngramsTableOrderWith = function (dictFunctor) {
      return function (dictFoldable) {
          return function (dictUnfoldable) {
              return function (orderBy) {
                  var v = Data_Functor.map(Data_Maybe.functorMaybe)(Gargantext_Components_NgramsTable_Core.convOrderBy)(orderBy);
                  if (v instanceof Data_Maybe.Just && v.value0 instanceof Gargantext_Types.ScoreAsc) {
                      return Gargantext_Utils.sortWith(dictFunctor)(dictFoldable)(dictUnfoldable)(Data_Ord.ordInt)(function (x) {
                          return Data_Lens_Getter.viewOn(x)((function () {
                              var $292 = Gargantext_Components_NgramsTable_Core["_NgramsElement"](Data_Lens_Internal_Forget.profunctorForget);
                              var $293 = Gargantext_Components_NgramsTable_Core["_occurrences"](Data_Lens_Internal_Forget.strongForget);
                              return function ($294) {
                                  return $292($293($294));
                              };
                          })());
                      });
                  };
                  if (v instanceof Data_Maybe.Just && v.value0 instanceof Gargantext_Types.ScoreDesc) {
                      return Gargantext_Utils.sortWith(dictFunctor)(dictFoldable)(dictUnfoldable)(Data_Ord_Down.ordDown(Data_Ord.ordInt))(function (x) {
                          return Data_Ord_Down.Down(Data_Lens_Getter.viewOn(x)((function () {
                              var $295 = Gargantext_Components_NgramsTable_Core["_NgramsElement"](Data_Lens_Internal_Forget.profunctorForget);
                              var $296 = Gargantext_Components_NgramsTable_Core["_occurrences"](Data_Lens_Internal_Forget.strongForget);
                              return function ($297) {
                                  return $295($296($297));
                              };
                          })()));
                      });
                  };
                  if (v instanceof Data_Maybe.Just && v.value0 instanceof Gargantext_Types.TermAsc) {
                      return Gargantext_Utils.sortWith(dictFunctor)(dictFoldable)(dictUnfoldable)(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(function (x) {
                          return Data_Lens_Getter.viewOn(x)((function () {
                              var $298 = Gargantext_Components_NgramsTable_Core["_NgramsElement"](Data_Lens_Internal_Forget.profunctorForget);
                              var $299 = Gargantext_Components_NgramsTable_Core["_ngrams"](Data_Lens_Internal_Forget.strongForget);
                              return function ($300) {
                                  return $298($299($300));
                              };
                          })());
                      });
                  };
                  if (v instanceof Data_Maybe.Just && v.value0 instanceof Gargantext_Types.TermDesc) {
                      return Gargantext_Utils.sortWith(dictFunctor)(dictFoldable)(dictUnfoldable)(Data_Ord_Down.ordDown(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"]))(function (x) {
                          return Data_Ord_Down.Down(Data_Lens_Getter.viewOn(x)((function () {
                              var $301 = Gargantext_Components_NgramsTable_Core["_NgramsElement"](Data_Lens_Internal_Forget.profunctorForget);
                              var $302 = Gargantext_Components_NgramsTable_Core["_ngrams"](Data_Lens_Internal_Forget.strongForget);
                              return function ($303) {
                                  return $301($302($303));
                              };
                          })()));
                      });
                  };
                  return Control_Category.identity(Control_Category.categoryFn);
              };
          };
      };
  };
  var ngramsElementToNgramsOcc = function (v) {
      return {
          occurrences: v.occurrences,
          children: v.children
      };
  };
  var initialState = function (v) {
      return {
          ngramsChildren: Data_Map_Internal.empty,
          ngramsLocalPatch: Data_Monoid.mempty(Data_Monoid.monoidRecord()(Data_Monoid.monoidRecordCons(new Data_Symbol.IsSymbol(function () {
              return "ngramsPatches";
          }))(Gargantext_Components_NgramsTable_Core["$_MonoidPatchMap_203"](Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])(Gargantext_Components_NgramsTable_Core["$_MonoidNgramsPatch_158"]))()(Data_Monoid.monoidRecordNil))),
          ngramsParent: Data_Maybe.Nothing.value,
          ngramsSelection: Data_Monoid.mempty(Data_Set.monoidSet(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])),
          ngramsStagePatch: Data_Monoid.mempty(Data_Monoid.monoidRecord()(Data_Monoid.monoidRecordCons(new Data_Symbol.IsSymbol(function () {
              return "ngramsPatches";
          }))(Gargantext_Components_NgramsTable_Core["$_MonoidPatchMap_203"](Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])(Gargantext_Components_NgramsTable_Core["$_MonoidNgramsPatch_158"]))()(Data_Monoid.monoidRecordNil))),
          ngramsValidPatch: Data_Monoid.mempty(Data_Monoid.monoidRecord()(Data_Monoid.monoidRecordCons(new Data_Symbol.IsSymbol(function () {
              return "ngramsPatches";
          }))(Gargantext_Components_NgramsTable_Core["$_MonoidPatchMap_203"](Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])(Gargantext_Components_NgramsTable_Core["$_MonoidNgramsPatch_158"]))()(Data_Monoid.monoidRecordNil))),
          ngramsVersion: v.version
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.NgramsTable");
  var tableContainerCpt = function (v) {
      var setTermSizeFilter = function (x) {
          return Toestand_Classes.modify(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v1) {
              var $84 = {};
              for (var $85 in v1) {
                  if ({}.hasOwnProperty.call(v1, $85)) {
                      $84[$85] = v1[$85];
                  };
              };
              $84.termSizeFilter = x;
              return $84;
          })(v.path);
      };
      var setTermListFilter = function (x) {
          return Toestand_Classes.modify(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v1) {
              var $87 = {};
              for (var $88 in v1) {
                  if ({}.hasOwnProperty.call(v1, $88)) {
                      $87[$88] = v1[$88];
                  };
              };
              $87.termListFilter = x;
              return $87;
          })(v.path);
      };
      var setSelection = (function () {
          var $304 = setTermListSetA(v.ngramsTable)(v.ngramsSelection);
          return function ($305) {
              return v.dispatch($304($305));
          };
      })();
      var selectionsExist = (function () {
          var $306 = Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean);
          return function ($307) {
              return $306(Data_Set.isEmpty($307));
          };
      })();
      var selectButtons = function (v1) {
          if (!v1) {
              return Reactix_DOM_HTML.div({})([  ]);
          };
          if (v1) {
              return Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.button({
                  className: "btn btn-primary",
                  on: {
                      click: Data_Function["const"](setSelection(Gargantext_Types.MapTerm.value))
                  }
              })([ Reactix_DOM_HTML.text("Map") ]), Reactix_DOM_HTML.button({
                  className: "btn btn-primary",
                  on: {
                      click: Data_Function["const"](setSelection(Gargantext_Types.StopTerm.value))
                  }
              })([ Reactix_DOM_HTML.text("Stop") ]), Reactix_DOM_HTML.button({
                  className: "btn btn-primary",
                  on: {
                      click: Data_Function["const"](setSelection(Gargantext_Types.CandidateTerm.value))
                  }
              })([ Reactix_DOM_HTML.text("Candidate") ]) ]);
          };
          throw new Error("Failed pattern match at Gargantext.Components.NgramsTable (line 244, column 5 - line 244, column 38): " + [ v1.constructor.name ]);
      };
      var editor = (function () {
          var f = function (ngrams) {
              var ngramsTable = Data_Lens_Setter.over((function () {
                  var $308 = Data_Lens_At.at(Gargantext_Components_NgramsTable_Core["$_AtNgramsTableNgramsTermNg_187"])(ngrams)(Data_Profunctor_Strong.strongFn);
                  var $309 = Data_Lens_Prism_Maybe["_Just"](Data_Profunctor_Choice.choiceFn);
                  var $310 = Gargantext_Components_NgramsTable_Core["_NgramsRepoElement"](Data_Profunctor.profunctorFn);
                  var $311 = Gargantext_Components_NgramsTable_Core["_children"](Data_Profunctor_Strong.strongFn);
                  return function ($312) {
                      return $308($309($310($311($312))));
                  };
              })())(Gargantext_Components_NgramsTable_Core.applyPatchSet(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(Gargantext_Components_NgramsTable_Core.patchSetFromMap(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(v.ngramsChildren)))(v.ngramsTable);
              var ngramsEdit = function (v1) {
                  return Data_Maybe.Nothing.value;
              };
              var ngramsClick = function (v1) {
                  if (v1.depth === 1) {
                      return Data_Maybe.Just.create(v.dispatch(new Gargantext_Components_NgramsTable_Core.ToggleChild(false, v1.ngrams)));
                  };
                  return Data_Maybe.Nothing.value;
              };
              return [ Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.text("Editing " + Gargantext_Components_NgramsTable_Core.ngramsTermText(ngrams)) ]), Gargantext_Components_NgramsTable_Components.renderNgramsTree({
                  ngramsTable: ngramsTable,
                  ngrams: ngrams,
                  ngramsStyle: [  ],
                  ngramsClick: ngramsClick,
                  ngramsEdit: ngramsEdit
              }), Reactix_DOM_HTML.button({
                  className: "btn btn-primary",
                  on: {
                      click: Data_Function["const"](v.dispatch(Gargantext_Components_NgramsTable_Core.AddTermChildren.value))
                  }
              })([ Reactix_DOM_HTML.text("Save") ]), Reactix_DOM_HTML.button({
                  className: "btn btn-primary",
                  on: {
                      click: Data_Function["const"](v.dispatch(new Gargantext_Components_NgramsTable_Core.SetParentResetChildren(Data_Maybe.Nothing.value)))
                  }
              })([ Reactix_DOM_HTML.text("Cancel") ]) ];
          };
          return Reactix_DOM_HTML.div({})(Data_Maybe.maybe([  ])(f)(v.ngramsParent));
      })();
      var cpt = function (props) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "termSizeFilter";
              }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermSize_99"])))()(new Data_Symbol.IsSymbol(function () {
                  return "termListFilter";
              }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermList_103"])))()(new Data_Symbol.IsSymbol(function () {
                  return "tabType";
              }))(Gargantext_Types["$_EqTabType_148"]))()(new Data_Symbol.IsSymbol(function () {
                  return "session";
              }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                  return "searchQuery";
              }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                  return "scoreType";
              }))(Gargantext_Types["$_EqScoreType_120"]))()(new Data_Symbol.IsSymbol(function () {
                  return "params";
              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "searchType";
              }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                  return "orderBy";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                  return "offset";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "limit";
              }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                  return "nodeId";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "listIds";
              }))(Data_Eq.eqArray(Data_Eq.eqInt)))))(v.path))(function (v2) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "container-fluid"
                  })([ Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.div({
                      className: "card col-12"
                  })([ Reactix_DOM_HTML.div({
                      className: "card-header"
                  })([ Gargantext_Utils_Reactix.row([ Reactix_DOM_HTML.div({
                      className: "col-md-2",
                      style: {
                          marginTop: "6px"
                      }
                  })([ Reactix_DOM_HTML.div({})(v.syncResetButton), (function () {
                      var $95 = Data_Array["null"](props.tableBody) && v2.searchQuery !== "";
                      if ($95) {
                          return Reactix_DOM_HTML.li({
                              className: "list-group-item"
                          })([ Reactix_DOM_HTML.button({
                              className: "btn btn-primary",
                              on: {
                                  click: Data_Function["const"](v.dispatch(Gargantext_Components_NgramsTable_Core.CoreAction.create(Gargantext_Components_NgramsTable_Core.addNewNgramA(Gargantext_Components_NgramsTable_Core.normNgram(v.tabNgramType)(v2.searchQuery))(Gargantext_Types.MapTerm.value))))
                              }
                          })([ Reactix_DOM_HTML.text("Add " + v2.searchQuery) ]) ]);
                      };
                      return Reactix_DOM_HTML.div({})([  ]);
                  })() ]), Reactix_DOM_HTML.div({
                      className: "col-md-2",
                      style: {
                          marginTop: "6px"
                      }
                  })([ Reactix_DOM_HTML.li({
                      className: "list-group-item"
                  })([ Gargantext_Utils_Reactix.select({
                      id: "picklistmenu",
                      className: "form-control custom-select",
                      defaultValue: Data_Maybe.maybe("")(Data_Show.show(Gargantext_Types["$_ShowTermList_107"]))(v2.termListFilter),
                      on: {
                          change: (function () {
                              var $313 = Gargantext_Prelude.read(Gargantext_Types["$_ReadTermList_108"]);
                              return function ($314) {
                                  return setTermListFilter($313(Reactix_SyntheticEvent.unsafeEventValue($314)));
                              };
                          })()
                      }
                  })(Data_Functor.map(Data_Functor.functorArray)(optps1(Gargantext_Types["$_ShowTermList_107"]))(Gargantext_Types.termLists)) ]) ]), Reactix_DOM_HTML.div({
                      className: "col-md-2",
                      style: {
                          marginTop: "6px"
                      }
                  })([ Reactix_DOM_HTML.li({
                      className: "list-group-item"
                  })([ Gargantext_Utils_Reactix.select({
                      id: "picktermtype",
                      className: "form-control custom-select",
                      defaultValue: Data_Maybe.maybe("")(Data_Show.show(Gargantext_Types["$_ShowTermSize_100"]))(v2.termSizeFilter),
                      on: {
                          change: (function () {
                              var $315 = Gargantext_Prelude.read(Gargantext_Types["$_ReadTermSize_101"]);
                              return function ($316) {
                                  return setTermSizeFilter($315(Reactix_SyntheticEvent.unsafeEventValue($316)));
                              };
                          })()
                      }
                  })(Data_Functor.map(Data_Functor.functorArray)(optps1(Gargantext_Types["$_ShowTermSize_100"]))(Gargantext_Types.termSizes)) ]) ]), Reactix_DOM_HTML.div({
                      className: "col-md-2",
                      style: {
                          marginTop: "6px"
                      }
                  })([ Reactix_DOM_HTML.li({
                      className: "list-group-item"
                  })([ Reactix_DOM_HTML.div({
                      className: "form-inline"
                  })([ Reactix_DOM_HTML.div({
                      className: "form-group"
                  })([ props.pageSizeControl, Reactix_DOM_HTML.label({})([ Reactix_DOM_HTML.text(" items") ]) ]) ]) ]) ]), Reactix_DOM_HTML.div({
                      className: "col-md-4",
                      style: {
                          marginTop: "6px",
                          marginBottom: "1px"
                      }
                  })([ Reactix_DOM_HTML.li({
                      className: "list-group-item"
                  })([ props.pageSizeDescription, props.paginationLinks ]) ]) ]) ]), editor, (function () {
                      var $96 = selectionsExist(v.ngramsSelection);
                      if ($96) {
                          return Reactix_DOM_HTML.li({
                              className: "list-group-item"
                          })([ selectButtons(true) ]);
                      };
                      return Reactix_DOM_HTML.div({})([  ]);
                  })(), Reactix_DOM_HTML.div({
                      id: "terms_table",
                      className: "card-body"
                  })([ Reactix_DOM_HTML.table({
                      className: "table able"
                  })([ Reactix_DOM_HTML.thead({
                      className: ""
                  })([ props.tableHead ]), Reactix_DOM_HTML.tbody({})(props.tableBody) ]), Reactix_DOM_HTML.li({
                      className: "list-group-item"
                  })([ Reactix_DOM_HTML.div({
                      className: "row"
                  })([ Reactix_DOM_HTML.div({
                      className: "col-md-4"
                  })([ selectButtons(selectionsExist(v.ngramsSelection)) ]), Reactix_DOM_HTML.div({
                      className: "col-md-4 col-md-offset-4"
                  })([ props.paginationLinks ]) ]) ]) ]) ]) ]) ]));
              });
          };
      };
      return here.component("tableContainer")(cpt);
  };
  var tableContainer = function (p) {
      return function (q) {
          return Reactix_React.createElement(Reactix_React.componentIsComponent)(tableContainerCpt(p))(q)([  ]);
      };
  };
  var displayRow = function (v) {
      return (Data_Maybe.isNothing(v.ngramsElement.root) && (Data_Maybe.maybe(true)(function (v1) {
          return Data_Eq.eq(Gargantext_Types["$_EqTermList_103"])(v1)(v.ngramsElement.list);
      })(v.termListFilter) && (Data_Eq.notEq(Data_Maybe.eqMaybe(Data_Eq.eqBoolean))(Data_Lens_Getter.viewOn(v.state.ngramsChildren)(Data_Lens_At.at(Data_Lens_At.atMap(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"]))(v.ngramsElement.ngrams)(Data_Lens_Internal_Forget.strongForget)))(new Data_Maybe.Just(true)) && (Data_Eq.notEq(Data_Maybe.eqMaybe(Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"]))(new Data_Maybe.Just(v.ngramsElement.ngrams))(v.state.ngramsParent) && (Data_Eq.notEq(Data_Maybe.eqMaybe(Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"]))(new Data_Maybe.Just(v.ngramsElement.ngrams))(v.ngramsParentRoot) && Gargantext_Components_NgramsTable_Core.filterTermSize(v.termSizeFilter)(v.ngramsElement.ngrams))))) || (Data_Eq.eq(Data_Maybe.eqMaybe(Data_Eq.eqBoolean))(Data_Lens_Getter.viewOn(v.state.ngramsChildren)(Data_Lens_At.at(Data_Lens_At.atMap(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"]))(v.ngramsElement.ngrams)(Data_Lens_Internal_Forget.strongForget)))(new Data_Maybe.Just(false)) || Gargantext_Components_NgramsTable_Components.tablePatchHasNgrams(v.state.ngramsLocalPatch)(v.ngramsElement.ngrams))) && Gargantext_Utils.queryMatchesLabel(v.searchQuery)(Gargantext_Components_NgramsTable_Core.ngramsTermText(v.ngramsElement.ngrams));
  };
  var allNgramsSelectedOnFirstPage = function (selected) {
      return function (rows) {
          return Data_Eq.eq(Data_Set.eqSet(Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"]))(selected)(selectNgramsOnFirstPage(rows));
      };
  };
  var mkDispatch = function (v) {
      var setParentResetChildren = function (p) {
          return function (v1) {
              return {
                  ngramsLocalPatch: v1.ngramsLocalPatch,
                  ngramsStagePatch: v1.ngramsStagePatch,
                  ngramsValidPatch: v1.ngramsValidPatch,
                  ngramsVersion: v1.ngramsVersion,
                  ngramsChildren: Data_Map_Internal.empty,
                  ngramsParent: p,
                  ngramsSelection: v1.ngramsSelection
              };
          };
      };
      var allNgramsSelected = allNgramsSelectedOnFirstPage(v["state'"].ngramsSelection)(v.filteredRows);
      var performAction = function (v1) {
          if (v1 instanceof Gargantext_Components_NgramsTable_Core.SetParentResetChildren) {
              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(setParentResetChildren(v1.value0))(v.state);
          };
          if (v1 instanceof Gargantext_Components_NgramsTable_Core.ToggleChild) {
              var newNC = function (nc) {
                  return Data_Map_Internal.alter(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(Data_Maybe.maybe(new Data_Maybe.Just(v1.value0))(Data_Function["const"](Data_Maybe.Nothing.value)))(v1.value1)(nc);
              };
              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v2) {
                  var $126 = {};
                  for (var $127 in v2) {
                      if ({}.hasOwnProperty.call(v2, $127)) {
                          $126[$127] = v2[$127];
                      };
                  };
                  $126.ngramsChildren = newNC(v2.ngramsChildren);
                  return $126;
              })(v.state);
          };
          if (v1 instanceof Gargantext_Components_NgramsTable_Core.ToggleSelect) {
              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v2) {
                  var $133 = {};
                  for (var $134 in v2) {
                      if ({}.hasOwnProperty.call(v2, $134)) {
                          $133[$134] = v2[$134];
                      };
                  };
                  $133.ngramsSelection = Gargantext_Utils.toggleSet(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(v1.value0)(v2.ngramsSelection);
                  return $133;
              })(v.state);
          };
          if (v1 instanceof Gargantext_Components_NgramsTable_Core.ToggleSelectAll) {
              var toggler = function (s) {
                  if (allNgramsSelected) {
                      var $139 = {};
                      for (var $140 in s) {
                          if ({}.hasOwnProperty.call(s, $140)) {
                              $139[$140] = s[$140];
                          };
                      };
                      $139.ngramsSelection = Data_Set.empty;
                      return $139;
                  };
                  var $142 = {};
                  for (var $143 in s) {
                      if ({}.hasOwnProperty.call(s, $143)) {
                          $142[$143] = s[$143];
                      };
                  };
                  $142.ngramsSelection = selectNgramsOnFirstPage(v.filteredRows);
                  return $142;
              };
              return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(toggler)(v.state);
          };
          if (v1 instanceof Gargantext_Components_NgramsTable_Core.AddTermChildren) {
              if (v["state'"].ngramsParent instanceof Data_Maybe.Nothing) {
                  return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
              };
              if (v["state'"].ngramsParent instanceof Data_Maybe.Just) {
                  var pc = Gargantext_Components_NgramsTable_Core.patchSetFromMap(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(v["state'"].ngramsChildren);
                  var pe = new Gargantext_Components_NgramsTable_Core.NgramsPatch({
                      patch_list: Data_Monoid.mempty(Gargantext_Components_NgramsTable_Core["$_MonoidReplace_192"](Gargantext_Types["$_EqTermList_103"])),
                      patch_children: pc
                  });
                  var pt = Gargantext_Components_NgramsTable_Core.singletonNgramsTablePatch(v["state'"].ngramsParent.value0)(pe);
                  return function __do() {
                      Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(setParentResetChildren(Data_Maybe.Nothing.value))(v.state)();
                      return Gargantext_Components_NgramsTable_Core.commitPatch(pt)(v.state)();
                  };
              };
              throw new Error("Failed pattern match at Gargantext.Components.NgramsTable (line 467, column 7 - line 476, column 31): " + [ v["state'"].ngramsParent.constructor.name ]);
          };
          if (v1 instanceof Gargantext_Components_NgramsTable_Core.CoreAction) {
              return Gargantext_Components_NgramsTable_Core.coreDispatch(v.path)(v.state)(v1.value0);
          };
          throw new Error("Failed pattern match at Gargantext.Components.NgramsTable (line 449, column 5 - line 449, column 43): " + [ v1.constructor.name ]);
      };
      return performAction;
  };
  var loadedNgramsTableCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var colNames = Data_Functor.map(Data_Functor.functorArray)(Gargantext_Components_Table_Types.ColumnName)([ "Show", "Select", "Map", "Stop", "Terms", "Score" ]);
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsVersion";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsValidPatch";
              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsPatches";
              }))(Gargantext_Components_NgramsTable_Core["$_EqPatchMap_153"](Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])))))()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsStagePatch";
              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsPatches";
              }))(Gargantext_Components_NgramsTable_Core["$_EqPatchMap_153"](Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])))))()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsSelection";
              }))(Data_Set.eqSet(Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"])))()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsParent";
              }))(Data_Maybe.eqMaybe(Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"])))()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsLocalPatch";
              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsPatches";
              }))(Gargantext_Components_NgramsTable_Core["$_EqPatchMap_153"](Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])))))()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsChildren";
              }))(Data_Map_Internal.eqMap(Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"])(Data_Eq.eqBoolean)))))(v.state))(function (v2) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "termSizeFilter";
                  }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermSize_99"])))()(new Data_Symbol.IsSymbol(function () {
                      return "termListFilter";
                  }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermList_103"])))()(new Data_Symbol.IsSymbol(function () {
                      return "tabType";
                  }))(Gargantext_Types["$_EqTabType_148"]))()(new Data_Symbol.IsSymbol(function () {
                      return "session";
                  }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                      return "searchQuery";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "scoreType";
                  }))(Gargantext_Types["$_EqScoreType_120"]))()(new Data_Symbol.IsSymbol(function () {
                      return "params";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "searchType";
                  }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                      return "orderBy";
                  }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                      return "offset";
                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                      return "limit";
                  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                      return "nodeId";
                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                      return "listIds";
                  }))(Data_Eq.eqArray(Data_Eq.eqInt)))))(v.path))(function (v3) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v4) {
                          return v4.params;
                      })(function (a) {
                          return function (b) {
                              var $161 = {};
                              for (var $162 in b) {
                                  if ({}.hasOwnProperty.call(b, $162)) {
                                      $161[$162] = b[$162];
                                  };
                              };
                              $161.params = a;
                              return $161;
                          };
                      })(v.path))(function (params1) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "searchType";
                          }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                              return "orderBy";
                          }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                              return "offset";
                          }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                              return "limit";
                          }))(Data_Eq.eqInt))))(params1))(function (v4) {
                              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useFocused(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v5) {
                                  return v5.searchQuery;
                              })(function (a) {
                                  return function (b) {
                                      var $165 = {};
                                      for (var $166 in b) {
                                          if ({}.hasOwnProperty.call(b, $166)) {
                                              $165[$166] = b[$166];
                                          };
                                      };
                                      $165.searchQuery = a;
                                      return $165;
                                  };
                              })(v.path))(function (searchQuery) {
                                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqString))(searchQuery))(function (searchQuery$prime) {
                                      var ngramsTable = Gargantext_Components_NgramsTable_Core.applyNgramsPatches(v2)(v.versioned.data);
                                      var roots = Gargantext_Components_NgramsTable_Core.rootsOf(ngramsTable);
                                      var ngramsParentRoot = Control_Bind.bindFlipped(Data_Maybe.bindMaybe)(function (np) {
                                          return Data_Lens_Fold.previewOn(ngramsTable)((function () {
                                              var $317 = Data_Lens_At.at(Gargantext_Components_NgramsTable_Core["$_AtNgramsTableNgramsTermNg_187"])(np)(Data_Lens_Internal_Forget.strongForget);
                                              var $318 = Data_Lens_Prism_Maybe["_Just"](Data_Lens_Internal_Forget.choiceForget(Data_Maybe_First.monoidFirst));
                                              var $319 = Gargantext_Components_NgramsTable_Core["_NgramsRepoElement"](Data_Lens_Internal_Forget.profunctorForget);
                                              var $320 = Gargantext_Components_NgramsTable_Core["_root"](Data_Lens_Internal_Forget.strongForget);
                                              var $321 = Data_Lens_Prism_Maybe["_Just"](Data_Lens_Internal_Forget.choiceForget(Data_Maybe_First.monoidFirst));
                                              return function ($322) {
                                                  return $317($318($319($320($321($322)))));
                                              };
                                          })());
                                      })(v2.ngramsParent);
                                      var rowsFilter = function (ngramsElement) {
                                          var $168 = displayRow({
                                              ngramsElement: ngramsElement,
                                              ngramsParentRoot: ngramsParentRoot,
                                              ngramsTable: ngramsTable,
                                              searchQuery: searchQuery$prime,
                                              state: v2,
                                              termListFilter: v3.termListFilter,
                                              termSizeFilter: v3.termSizeFilter
                                          });
                                          if ($168) {
                                              return new Data_Maybe.Just(ngramsElement);
                                          };
                                          return Data_Maybe.Nothing.value;
                                      };
                                      var rowMap = function (v5) {
                                          var ng_scores = Data_Lens_Getter.viewOn(ngramsTable)((function () {
                                              var $323 = Gargantext_Components_NgramsTable_Core["_NgramsTable"](Data_Lens_Internal_Forget.profunctorForget);
                                              var $324 = Gargantext_Components_NgramsTable_Core["_ngrams_scores"](Data_Lens_Internal_Forget.strongForget);
                                              return function ($325) {
                                                  return $323($324($325));
                                              };
                                          })());
                                          var v6 = Data_Lens_Getter.viewOn(ng_scores)((function () {
                                              var $326 = Data_Lens_At.at(Data_Lens_At.atMap(Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"]))(v5.value0)(Data_Lens_Internal_Forget.strongForget);
                                              var $327 = Data_Lens_Prism_Maybe["_Just"](Data_Lens_Internal_Forget.choiceForget(Data_Monoid_Additive.monoidAdditive(Data_Semiring.semiringInt)));
                                              return function ($328) {
                                                  return $326($327($328));
                                              };
                                          })());
                                          var addOcc = function (ne) {
                                              var v7 = sumOccurrences(ngramsTable)(ngramsElementToNgramsOcc(ne));
                                              return Data_Lens_Setter.set((function () {
                                                  var $329 = Gargantext_Components_NgramsTable_Core["_NgramsElement"](Data_Profunctor.profunctorFn);
                                                  var $330 = Gargantext_Components_NgramsTable_Core["_occurrences"](Data_Profunctor_Strong.strongFn);
                                                  return function ($331) {
                                                      return $329($330($331));
                                                  };
                                              })())(v7)(ne);
                                          };
                                          return Data_Functor.map(Data_Maybe.functorMaybe)(addOcc)(rowsFilter(Gargantext_Components_NgramsTable_Core.ngramsRepoElementToNgramsElement(v5.value0)(v6)(v5.value1)));
                                      };
                                      var rows = ngramsTableOrderWith(Data_Sequence.functorSeq)(Data_Sequence.foldableSeq)(Data_Sequence.unfoldableSeq)(v4.orderBy)(Gargantext_Utils_Seq.mapMaybe(rowMap)(Data_Map_Internal.toUnfoldable(Data_Sequence.unfoldableSeq)(Data_Lens_Getter.viewOn(ngramsTable)((function () {
                                          var $332 = Gargantext_Components_NgramsTable_Core["_NgramsTable"](Data_Lens_Internal_Forget.profunctorForget);
                                          var $333 = Gargantext_Components_NgramsTable_Core["_ngrams_repo_elements"](Data_Lens_Internal_Forget.strongForget);
                                          return function ($334) {
                                              return $332($333($334));
                                          };
                                      })()))));
                                      var totalRecords = Data_Maybe.fromMaybe(Data_Sequence.length(rows))(v.mTotalRows);
                                      var filteredRows = (function () {
                                          var $174 = Data_Eq.eq(Gargantext_Components_Nodes_Lists_Types["$_EqCacheState_4"])(v.cacheState)(Gargantext_Components_Nodes_Lists_Types.CacheOn.value);
                                          if ($174) {
                                              return Gargantext_Components_Table.filterRows({
                                                  params: v4
                                              })(rows);
                                          };
                                          return rows;
                                      })();
                                      var performAction = mkDispatch({
                                          filteredRows: filteredRows,
                                          path: v3,
                                          state: v.state,
                                          "state'": v2
                                      });
                                      var convertRow = function (ngramsElement) {
                                          return {
                                              row: Gargantext_Components_NgramsTable_Components.renderNgramsItem({
                                                  dispatch: performAction,
                                                  ngrams: Data_Lens_Getter.viewOn(ngramsElement)((function () {
                                                      var $335 = Gargantext_Components_NgramsTable_Core["_NgramsElement"](Data_Lens_Internal_Forget.profunctorForget);
                                                      var $336 = Gargantext_Components_NgramsTable_Core["_ngrams"](Data_Lens_Internal_Forget.strongForget);
                                                      return function ($337) {
                                                          return $335($336($337));
                                                      };
                                                  })()),
                                                  ngramsElement: ngramsElement,
                                                  ngramsLocalPatch: v2.ngramsLocalPatch,
                                                  ngramsParent: v2.ngramsParent,
                                                  ngramsSelection: v2.ngramsSelection,
                                                  ngramsTable: ngramsTable
                                              })([  ]),
                                              "delete": false
                                          };
                                      };
                                      var filteredConvertedRows = Data_Functor.map(Data_Sequence.functorSeq)(convertRow)(filteredRows);
                                      var allNgramsSelected = allNgramsSelectedOnFirstPage(v2.ngramsSelection)(filteredRows);
                                      var afterSync$prime = function (v5) {
                                          return Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Gargantext_Components_NgramsTable_Core.chartsAfterSync(v3)(v.tasks)(Data_Unit.unit))(function () {
                                              return v.afterSync(Data_Unit.unit);
                                          });
                                      };
                                      var autoUpdate = function (path$prime1) {
                                          if (v.withAutoUpdate) {
                                              return [ Gargantext_Utils_Reactix.buff(Gargantext_Components_AutoUpdate.autoUpdateElt({
                                                  duration: 5000,
                                                  effect: performAction(Gargantext_Components_NgramsTable_Core.CoreAction.create(new Gargantext_Components_NgramsTable_Core.Synchronize({
                                                      afterSync: afterSync$prime
                                                  })))
                                              })) ];
                                          };
                                          return [  ];
                                      };
                                      var syncResetButton = Gargantext_Components_NgramsTable_Core.syncResetButtons({
                                          afterSync: afterSync$prime,
                                          ngramsLocalPatch: v2.ngramsLocalPatch,
                                          performAction: function ($338) {
                                              return performAction(Gargantext_Components_NgramsTable_Core.CoreAction.create($338));
                                          }
                                      });
                                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment(Data_Semigroup.append(Data_Semigroup.semigroupArray)(autoUpdate(v3))([ Reactix_DOM_HTML.h4({
                                          style: {
                                              textAlign: "center"
                                          }
                                      })([ Reactix_DOM_HTML.span({
                                          className: "fa fa-hand-o-down"
                                      })([  ]), Reactix_DOM_HTML.text("Extracted Terms") ]), Gargantext_Components_NgramsTable_Components.searchInput({
                                          key: "search-input",
                                          searchQuery: searchQuery
                                      }), Gargantext_Components_Table.table({
                                          colNames: colNames,
                                          container: tableContainer({
                                              dispatch: performAction,
                                              ngramsChildren: v2.ngramsChildren,
                                              ngramsParent: v2.ngramsParent,
                                              ngramsSelection: v2.ngramsSelection,
                                              ngramsTable: ngramsTable,
                                              path: v.path,
                                              syncResetButton: [ syncResetButton ],
                                              tabNgramType: v.tabNgramType
                                          }),
                                          params: params1,
                                          rows: filteredConvertedRows,
                                          syncResetButton: [ syncResetButton ],
                                          totalRecords: totalRecords,
                                          wrapColElts: wrapColElts(Gargantext_Types["$_ShowScoreType_121"])({
                                              allNgramsSelected: allNgramsSelected,
                                              dispatch: performAction,
                                              ngramsSelection: v2.ngramsSelection
                                          })(v3.scoreType)
                                      }), syncResetButton ])));
                                  });
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("loadedNgramsTable")(cpt);
  })();
  var loadedNgramsTable = Reactix_React.createElement(Reactix_React.componentIsComponent)(loadedNgramsTableCpt);
  var mainNgramsTablePaintCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(initialState(v.versioned)))(function (state) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(loadedNgramsTable({
                      afterSync: v.afterSync,
                      cacheState: v.cacheState,
                      mTotalRows: Data_Maybe.Nothing.value,
                      path: v.path,
                      reloadForest: v.reloadForest,
                      reloadRoot: v.reloadRoot,
                      state: state,
                      tabNgramType: v.tabNgramType,
                      tasks: v.tasks,
                      versioned: v.versioned,
                      withAutoUpdate: v.withAutoUpdate
                  })([  ]));
              });
          };
      };
      return here.component("mainNgramsTablePaint")(cpt);
  })();
  var mainNgramsTablePaint = Reactix_React.createElement(Reactix_React.componentIsComponent)(mainNgramsTablePaintCpt);
  var mainNgramsTablePaintNoCacheCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var v2 = Gargantext_Components_NgramsTable_Core.toVersioned(v.versionedWithCount);
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(initialState(v2.value1)))(function (state) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(loadedNgramsTable({
                      afterSync: v.afterSync,
                      cacheState: v.cacheState,
                      mTotalRows: new Data_Maybe.Just(v2.value0),
                      path: v.path,
                      reloadForest: v.reloadForest,
                      reloadRoot: v.reloadRoot,
                      state: state,
                      tabNgramType: v.tabNgramType,
                      tasks: v.tasks,
                      versioned: v2.value1,
                      withAutoUpdate: v.withAutoUpdate
                  })([  ]));
              });
          };
      };
      return here.component("mainNgramsTablePaintNoCache")(cpt);
  })();
  var mainNgramsTablePaintNoCache = Reactix_React.createElement(Reactix_React.componentIsComponent)(mainNgramsTablePaintNoCacheCpt);
  var mainNgramsTableCpt = (function () {
      var versionEndpoint = function (v) {
          return function (v1) {
              return Gargantext_Sessions.get(Simple_JSON.readInt)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.path.session)(new Gargantext_Routes.GetNgramsTableVersion({
                  listId: v.defaultListId,
                  tabType: v.path.tabType
              }, new Data_Maybe.Just(v.path.nodeId)));
          };
      };
      var mkRequest = function (v) {
          var url = function (v1) {
              return new Gargantext_Routes.GetNgramsTableAll({
                  listIds: v1.listIds,
                  tabType: v1.tabType
              }, new Data_Maybe.Just(v1.nodeId));
          };
          return Gargantext_Utils_CacheAPI.makeGetRequest(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(url(v));
      };
      var loader = function (v) {
          var params = {
              limit: v.params.limit,
              listIds: v.listIds,
              offset: new Data_Maybe.Just(v.params.offset),
              orderBy: Data_Maybe.Nothing.value,
              searchQuery: v.searchQuery,
              tabType: v.tabType,
              termListFilter: v.termListFilter,
              termSizeFilter: v.termSizeFilter
          };
          return Gargantext_Sessions.get(Gargantext_Components_NgramsTable_Core["$_ReadForeignVersionedWithC_149"](Gargantext_Components_NgramsTable_Core["$_ReadForeignNgramsTable_188"]))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(new Gargantext_Routes.GetNgrams(params, new Data_Maybe.Just(v.nodeId)));
      };
      var handleResponse = function (v) {
          return v;
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Nodes_Lists_Types["$_EqCacheState_4"]))(v.cacheState))(function (cacheState$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "termSizeFilter";
                  }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermSize_99"])))()(new Data_Symbol.IsSymbol(function () {
                      return "termListFilter";
                  }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermList_103"])))()(new Data_Symbol.IsSymbol(function () {
                      return "tabType";
                  }))(Gargantext_Types["$_EqTabType_148"]))()(new Data_Symbol.IsSymbol(function () {
                      return "session";
                  }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                      return "searchQuery";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "scoreType";
                  }))(Gargantext_Types["$_EqScoreType_120"]))()(new Data_Symbol.IsSymbol(function () {
                      return "params";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "searchType";
                  }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                      return "orderBy";
                  }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                      return "offset";
                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                      return "limit";
                  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                      return "nodeId";
                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                      return "listIds";
                  }))(Data_Eq.eqArray(Data_Eq.eqInt)))))(v.path))(function (v2) {
                      if (cacheState$prime instanceof Gargantext_Components_Nodes_Lists_Types.CacheOn) {
                          var render = function (versioned) {
                              return mainNgramsTablePaint({
                                  afterSync: v.afterSync,
                                  cacheState: cacheState$prime,
                                  path: v.path,
                                  reloadForest: v.reloadForest,
                                  reloadRoot: v.reloadRoot,
                                  tabNgramType: v.tabNgramType,
                                  tasks: v.tasks,
                                  versioned: versioned,
                                  withAutoUpdate: v.withAutoUpdate
                              })([  ]);
                          };
                          return Gargantext_Components_NgramsTable_Loader.useLoaderWithCacheAPI(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "termSizeFilter";
                          }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermSize_99"])))()(new Data_Symbol.IsSymbol(function () {
                              return "termListFilter";
                          }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermList_103"])))()(new Data_Symbol.IsSymbol(function () {
                              return "tabType";
                          }))(Gargantext_Types["$_EqTabType_148"]))()(new Data_Symbol.IsSymbol(function () {
                              return "session";
                          }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                              return "searchQuery";
                          }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                              return "scoreType";
                          }))(Gargantext_Types["$_EqScoreType_120"]))()(new Data_Symbol.IsSymbol(function () {
                              return "params";
                          }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "searchType";
                          }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                              return "orderBy";
                          }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                              return "offset";
                          }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                              return "limit";
                          }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                              return "nodeId";
                          }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                              return "listIds";
                          }))(Data_Eq.eqArray(Data_Eq.eqInt))))(Gargantext_Components_NgramsTable_Core["$_ReadForeignNgramsTable_188"])(Gargantext_Components_NgramsTable_Core["$_EqVersioned_143"](Gargantext_Components_NgramsTable_Core["$_EqNgramsTable_184"]))({
                              cacheEndpoint: versionEndpoint({
                                  defaultListId: v.defaultListId,
                                  path: v2
                              }),
                              handleResponse: handleResponse,
                              mkRequest: mkRequest,
                              path: v2,
                              renderer: render
                          });
                      };
                      if (cacheState$prime instanceof Gargantext_Components_Nodes_Lists_Types.CacheOff) {
                          var render = function (versionedWithCount) {
                              return mainNgramsTablePaintNoCache({
                                  afterSync: v.afterSync,
                                  cacheState: cacheState$prime,
                                  path: v.path,
                                  reloadForest: v.reloadForest,
                                  reloadRoot: v.reloadRoot,
                                  tabNgramType: v.tabNgramType,
                                  tasks: v.tasks,
                                  versionedWithCount: versionedWithCount,
                                  withAutoUpdate: v.withAutoUpdate
                              })([  ]);
                          };
                          return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "termSizeFilter";
                          }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermSize_99"])))()(new Data_Symbol.IsSymbol(function () {
                              return "termListFilter";
                          }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermList_103"])))()(new Data_Symbol.IsSymbol(function () {
                              return "tabType";
                          }))(Gargantext_Types["$_EqTabType_148"]))()(new Data_Symbol.IsSymbol(function () {
                              return "session";
                          }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                              return "searchQuery";
                          }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                              return "scoreType";
                          }))(Gargantext_Types["$_EqScoreType_120"]))()(new Data_Symbol.IsSymbol(function () {
                              return "params";
                          }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "searchType";
                          }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                              return "orderBy";
                          }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                              return "offset";
                          }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                              return "limit";
                          }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                              return "nodeId";
                          }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                              return "listIds";
                          }))(Data_Eq.eqArray(Data_Eq.eqInt))))(Gargantext_Components_NgramsTable_Core["$_EqVersionedWithCount_148"](Gargantext_Components_NgramsTable_Core["$_EqNgramsTable_184"]))(v2)(loader)(render);
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.NgramsTable (line 555, column 7 - line 584, column 40): " + [ cacheState$prime.constructor.name ]);
                  });
              });
          };
      };
      return here.component("mainNgramsTable")(cpt);
  })();
  var mainNgramsTable = Reactix_React.createElement(Reactix_React.componentIsComponent)(mainNgramsTableCpt);
  exports["mainNgramsTable"] = mainNgramsTable;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Annuaire.Tabs"] = $PS["Gargantext.Components.Nodes.Annuaire.Tabs"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Annuaire.Tabs"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_DocsTable = $PS["Gargantext.Components.DocsTable"];
  var Gargantext_Components_NgramsTable = $PS["Gargantext.Components.NgramsTable"];
  var Gargantext_Components_NgramsTable_Core = $PS["Gargantext.Components.NgramsTable.Core"];
  var Gargantext_Components_Tab = $PS["Gargantext.Components.Tab"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Record_Extra = $PS["Record.Extra"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];                
  var Patents = (function () {
      function Patents() {

      };
      Patents.value = new Patents();
      return Patents;
  })();
  var Books = (function () {
      function Books() {

      };
      Books.value = new Books();
      return Books;
  })();
  var Communication = (function () {
      function Communication() {

      };
      Communication.value = new Communication();
      return Communication;
  })();
  var modeTabType$prime = function (v) {
      if (v instanceof Patents) {
          return Gargantext_Types.CTabAuthors.value;
      };
      if (v instanceof Books) {
          return Gargantext_Types.CTabAuthors.value;
      };
      if (v instanceof Communication) {
          return Gargantext_Types.CTabAuthors.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Annuaire.Tabs (line 49, column 1 - line 49, column 38): " + [ v.constructor.name ]);
  };
  var modeTabType = function (v) {
      if (v instanceof Patents) {
          return Gargantext_Types.PTabPatents.value;
      };
      if (v instanceof Books) {
          return Gargantext_Types.PTabBooks.value;
      };
      if (v instanceof Communication) {
          return Gargantext_Types.PTabCommunication.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Annuaire.Tabs (line 43, column 1 - line 43, column 37): " + [ v.constructor.name ]);
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs");
  var ngramsViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var most = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "cacheState";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "defaultListId";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reloadForest";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reloadRoot";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "session";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "tasks";
              }))(Record_Extra.nilKeys)))))))(v);
              var props$prime = function (path) {
                  var afterSync = function (v2) {
                      return Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Unit.unit);
                  };
                  return Record.merge()()(most)({
                      afterSync: afterSync,
                      path: path,
                      tabType: new Gargantext_Types.TabPairing(Gargantext_Types.TabNgramType.create(modeTabType(v.mode))),
                      tabNgramType: modeTabType$prime(v.mode),
                      withAutoUpdate: false
                  });
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_NgramsTable_Core.initialPageParams(v.session)(v.nodeId)([ v.defaultListId ])(new Gargantext_Types.TabDocument(Gargantext_Types.TabDocs.value))))(function (path) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_NgramsTable.mainNgramsTable(props$prime(path))([  ]));
              });
          };
      };
      return here.component("ngramsView")(cpt);
  })();
  var ngramsView = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(ngramsViewCpt)(props)([  ]);
  };
  var tabsCpt = (function () {
      var tabs$prime = function (v) {
          var viewProps = function (mode) {
              return Record.merge()()(v)({
                  defaultListId: v.contactData.defaultListId,
                  mode: mode
              });
          };
          var dtExtra = {
              chart: Data_Monoid.mempty(Reactix_React.monoidElement),
              listId: v.contactData.defaultListId,
              mCorpusId: Data_Maybe.Nothing.value,
              showSearch: true,
              tabType: new Gargantext_Types.TabPairing(Gargantext_Types.TabDocs.value),
              totalRecords: 4736
          };
          var dtCommon = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
              return "cacheState";
          }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
              return "frontends";
          }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
              return "nodeId";
          }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
              return "session";
          }))(Record_Extra.nilKeys)))))(v);
          var docs = Gargantext_Components_DocsTable.docViewLayout(Record.merge()()({
              sidePanel: v.sidePanel,
              sidePanelState: v.sidePanelState
          })(Record.merge()()(dtCommon)(dtExtra)));
          return [ new Data_Tuple.Tuple("Documents", docs), new Data_Tuple.Tuple("Patents", ngramsView(viewProps(Patents.value))), new Data_Tuple.Tuple("Books", ngramsView(viewProps(Books.value))), new Data_Tuple.Tuple("Communication", ngramsView(viewProps(Communication.value))), new Data_Tuple.Tuple("Trash", docs) ];
      };
      var cpt = function (props) {
          return function (v) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(0))(function (activeTab) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Tab.tabs({
                      activeTab: activeTab,
                      tabs: tabs$prime(props)
                  }));
              });
          };
      };
      return here.component("tabs")(cpt);
  })();
  var tabs = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(tabsCpt)(props)([  ]);
  };
  exports["tabs"] = tabs;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Annuaire.User"] = $PS["Gargantext.Components.Nodes.Annuaire.User"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Annuaire.User"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Lens_Getter = $PS["Data.Lens.Getter"];
  var Data_Lens_Internal_Forget = $PS["Data.Lens.Internal.Forget"];
  var Data_Lens_Internal_Shop = $PS["Data.Lens.Internal.Shop"];
  var Data_Lens_Lens = $PS["Data.Lens.Lens"];
  var Data_Lens_Setter = $PS["Data.Lens.Setter"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Profunctor_Strong = $PS["Data.Profunctor.Strong"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_Components_InputWithEnter = $PS["Gargantext.Components.InputWithEnter"];
  var Gargantext_Components_Nodes_Annuaire_Tabs = $PS["Gargantext.Components.Nodes.Annuaire.Tabs"];
  var Gargantext_Components_Nodes_Annuaire_User_Contacts_Types = $PS["Gargantext.Components.Nodes.Annuaire.User.Contacts.Types"];
  var Gargantext_Components_Nodes_Lists_Types = $PS["Gargantext.Components.Nodes.Lists.Types"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var saveContactHyperdata = function (session) {
      return function (id) {
          return function (h) {
              return Gargantext_Sessions.put(Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["$_WriteForeignHyperdataUser_103"])(Simple_JSON.readInt)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(id), ""))(h);
          };
      };
  }; 
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Annuaire.User");
  var getContact = function (session) {
      return function (id) {
          return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.get(Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["$_ReadForeignContact_75"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(id), "")))(function (v) {
              return Control_Applicative.pure(Effect_Aff.applicativeAff)({
                  contactNode: v,
                  defaultListId: 424242
              });
          });
      };
  };
  var getUserWithReload = function (v) {
      return getContact(v.session)(v.nodeId);
  };
  var displayCpt = (function () {
      var cpt = function (v) {
          return function (children) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "container-fluid"
              })([ Reactix_DOM_HTML.div({
                  className: "row",
                  id: "contact-page-header"
              })([ Reactix_DOM_HTML.div({
                  className: "col-md-6"
              })([ Reactix_DOM_HTML.h3({})([ Reactix_DOM_HTML.text(v.title) ]) ]), Reactix_DOM_HTML.div({
                  className: "col-md-8"
              })([  ]), Reactix_DOM_HTML.div({
                  className: "col-md-2"
              })([ Reactix_DOM_HTML.span({})([ Reactix_DOM_HTML.text("") ]) ]) ]), Reactix_DOM_HTML.div({
                  className: "row",
                  id: "contact-page-info"
              })([ Reactix_DOM_HTML.div({
                  className: "col-md-12"
              })([ Reactix_DOM_HTML.div({
                  className: "row"
              })([ Reactix_DOM_HTML.div({
                  className: "col-md-2"
              })([ Reactix_DOM_HTML.img({
                  src: "/images/Gargantextuel-212x300.jpg"
              }) ]), Reactix_DOM_HTML.div({
                  className: "col-md-1"
              })([  ]), Reactix_DOM_HTML.div({
                  className: "col-md-8"
              })(children) ]) ]) ]) ]));
          };
      };
      return here.component("display")(cpt);
  })();
  var display = Reactix_React.createElement(Reactix_React.componentIsComponent)(displayCpt);
  var contactInfoItems = [ {
      label: "Last Name",
      defaultVal: "Empty Last Name",
      lens: (function () {
          var $60 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_shared"](Data_Lens_Internal_Shop.strongShop);
          var $61 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_who"](Data_Lens_Internal_Shop.strongShop);
          var $62 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_lastName"](Data_Lens_Internal_Shop.strongShop);
          return function ($63) {
              return $60($61($62($63)));
          };
      })()
  }, {
      label: "First Name",
      defaultVal: "Empty First Name",
      lens: (function () {
          var $64 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_shared"](Data_Lens_Internal_Shop.strongShop);
          var $65 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_who"](Data_Lens_Internal_Shop.strongShop);
          var $66 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_firstName"](Data_Lens_Internal_Shop.strongShop);
          return function ($67) {
              return $64($65($66($67)));
          };
      })()
  }, {
      label: "Organisation",
      defaultVal: "Empty Organisation",
      lens: (function () {
          var $68 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_shared"](Data_Lens_Internal_Shop.strongShop);
          var $69 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $70 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_organizationJoinComma"](Data_Lens_Internal_Shop.strongShop);
          return function ($71) {
              return $68($69($70($71)));
          };
      })()
  }, {
      label: "Lab/Team/Dept",
      defaultVal: "Empty Lab/Team/Dept",
      lens: (function () {
          var $72 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_shared"](Data_Lens_Internal_Shop.strongShop);
          var $73 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $74 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_labTeamDeptsJoinComma"](Data_Lens_Internal_Shop.strongShop);
          return function ($75) {
              return $72($73($74($75)));
          };
      })()
  }, {
      label: "Office",
      defaultVal: "Empty Office",
      lens: (function () {
          var $76 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_shared"](Data_Lens_Internal_Shop.strongShop);
          var $77 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $78 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_office"](Data_Lens_Internal_Shop.strongShop);
          return function ($79) {
              return $76($77($78($79)));
          };
      })()
  }, {
      label: "City",
      defaultVal: "Empty City",
      lens: (function () {
          var $80 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_shared"](Data_Lens_Internal_Shop.strongShop);
          var $81 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $82 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_city"](Data_Lens_Internal_Shop.strongShop);
          return function ($83) {
              return $80($81($82($83)));
          };
      })()
  }, {
      label: "Country",
      defaultVal: "Empty Country",
      lens: (function () {
          var $84 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_shared"](Data_Lens_Internal_Shop.strongShop);
          var $85 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $86 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_country"](Data_Lens_Internal_Shop.strongShop);
          return function ($87) {
              return $84($85($86($87)));
          };
      })()
  }, {
      label: "Role",
      defaultVal: "Empty Role",
      lens: (function () {
          var $88 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_shared"](Data_Lens_Internal_Shop.strongShop);
          var $89 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $90 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_role"](Data_Lens_Internal_Shop.strongShop);
          return function ($91) {
              return $88($89($90($91)));
          };
      })()
  }, {
      label: "Phone",
      defaultVal: "Empty Phone",
      lens: (function () {
          var $92 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_shared"](Data_Lens_Internal_Shop.strongShop);
          var $93 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $94 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_touch"](Data_Lens_Internal_Shop.strongShop);
          var $95 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_phone"](Data_Lens_Internal_Shop.strongShop);
          return function ($96) {
              return $92($93($94($95($96))));
          };
      })()
  }, {
      label: "Mail",
      defaultVal: "Empty Mail",
      lens: (function () {
          var $97 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_shared"](Data_Lens_Internal_Shop.strongShop);
          var $98 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $99 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_touch"](Data_Lens_Internal_Shop.strongShop);
          var $100 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_mail"](Data_Lens_Internal_Shop.strongShop);
          return function ($101) {
              return $97($98($99($100($101))));
          };
      })()
  } ];
  var contactInfoItemCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var cLens = Data_Lens_Lens.cloneLens(v.lens);
              var item = function (v2) {
                  return function (isEditing) {
                      return function (valueRef) {
                          if (!v2) {
                              var placeholder$prime = Reactix_React.readRef(valueRef);
                              var onClick = function (v3) {
                                  return Toestand_Classes.write_(Toestand_Boxes.writeBox)(true)(isEditing);
                              };
                              return Reactix_DOM_HTML.div({
                                  className: "input-group col-sm-6"
                              })([ Reactix_DOM_HTML.input({
                                  className: "form-control",
                                  defaultValue: placeholder$prime,
                                  disabled: 1,
                                  type: "text"
                              }), Reactix_DOM_HTML.div({
                                  className: "btn input-group-append",
                                  on: {
                                      click: onClick
                                  }
                              })([ Reactix_DOM_HTML.div({
                                  className: "input-group-text fa fa-pencil"
                              })([  ]) ]) ]);
                          };
                          if (v2) {
                              var onClick = function (v3) {
                                  return function __do() {
                                      Toestand_Classes.write_(Toestand_Boxes.writeBox)(true)(isEditing)();
                                      var newHyperdata = Data_Lens_Setter.over(cLens(Data_Profunctor_Strong.strongFn))(function (v4) {
                                          return Reactix_React.readRef(valueRef);
                                      })(v.hyperdata);
                                      return v.onUpdateHyperdata(newHyperdata)();
                                  };
                              };
                              return Reactix_DOM_HTML.div({
                                  className: "input-group col-sm-6"
                              })([ Gargantext_Components_InputWithEnter.inputWithEnter({
                                  autoFocus: true,
                                  className: "form-control",
                                  defaultValue: Reactix_React.readRef(valueRef),
                                  onBlur: Reactix_React.setRef(valueRef),
                                  onEnter: onClick,
                                  onValueChanged: Reactix_React.setRef(valueRef),
                                  placeholder: v.placeholder,
                                  type: "text"
                              }), Reactix_DOM_HTML.div({
                                  className: "btn input-group-append",
                                  on: {
                                      click: onClick
                                  }
                              })([ Reactix_DOM_HTML.div({
                                  className: "input-group-text fa fa-floppy-o"
                              })([  ]) ]) ]);
                          };
                          throw new Error("Failed pattern match at Gargantext.Components.Nodes.Annuaire.User (line 113, column 9 - line 126, column 48): " + [ v2.constructor.name, isEditing.constructor.name, valueRef.constructor.name ]);
                      };
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(false))(function (isEditing) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(isEditing))(function (isEditing$prime) {
                      var value = Data_Lens_Getter.view(cLens(Data_Lens_Internal_Forget.strongForget))(v.hyperdata);
                      return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(value))(function (valueRef) {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                              className: "form-group row"
                          })([ Reactix_DOM_HTML.span({
                              className: "col-sm-2 col-form-label"
                          })([ Reactix_DOM_HTML.text(v.label) ]), item(isEditing$prime)(isEditing)(valueRef) ]));
                      });
                  });
              });
          };
      };
      return here.component("contactInfoItem")(cpt);
  })();
  var contactInfoItem = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(contactInfoItemCpt)(props)([  ]);
  };
  var contactInfos = function (h) {
      return function (onUpdateHyperdata) {
          var item = function (v) {
              return contactInfoItem({
                  hyperdata: h,
                  label: v.label,
                  lens: v.lens,
                  onUpdateHyperdata: onUpdateHyperdata,
                  placeholder: v.defaultVal
              });
          };
          return Data_Functor.map(Data_Functor.functorArray)(item)(contactInfoItems);
      };
  };
  var userLayoutWithKeyCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onUpdateHyperdata = function (reload) {
                  return function (hd) {
                      return Effect_Aff.launchAff_(Control_Bind.bind(Effect_Aff.bindAff)(saveContactHyperdata(v.session)(v.nodeId)(hd))(function () {
                          return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(reload));
                      }));
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(reload))(function (reload$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_Nodes_Lists_Types.CacheOn.value))(function (cacheState) {
                          return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "session";
                          }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                              return "reload";
                          }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                              return "nodeId";
                          }))(Data_Eq.eqInt)))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "defaultListId";
                          }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                              return "contactNode";
                          }))(Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["$_EqContact_74"])))({
                              nodeId: v.nodeId,
                              reload: reload$prime,
                              session: v.session
                          })(getUserWithReload)(function (v2) {
                              return Reactix_DOM_HTML.ul({
                                  className: "col-md-12 list-group"
                              })([ display({
                                  title: Data_Maybe.fromMaybe("no name")(v2.contactNode.name)
                              })(contactInfos(v2.contactNode.hyperdata)(onUpdateHyperdata(reload))), Gargantext_Components_Nodes_Annuaire_Tabs.tabs({
                                  cacheState: cacheState,
                                  contactData: v2,
                                  frontends: v.frontends,
                                  nodeId: v.nodeId,
                                  reloadForest: v.reloadForest,
                                  reloadRoot: v.reloadRoot,
                                  session: v.session,
                                  sidePanel: v.sidePanel,
                                  sidePanelState: v.sidePanelState,
                                  tasks: v.tasks
                              }) ]);
                          });
                      });
                  });
              });
          };
      };
      return here.component("userLayoutWithKey")(cpt);
  })();
  var userLayoutWithKey = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(userLayoutWithKeyCpt)(props)([  ]);
  };
  var userLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sid = Gargantext_Sessions_Types.sessionId(v.session);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(userLayoutWithKey({
                  frontends: v.frontends,
                  key: Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(sid) + ("-" + Data_Show.show(Data_Show.showInt)(v.nodeId)),
                  nodeId: v.nodeId,
                  reloadForest: v.reloadForest,
                  reloadRoot: v.reloadRoot,
                  session: v.session,
                  sidePanel: v.sidePanel,
                  sidePanelState: v.sidePanelState,
                  tasks: v.tasks
              }));
          };
      };
      return here.component("userLayout")(cpt);
  })();
  var userLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(userLayoutCpt);
  exports["userLayout"] = userLayout;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs"] = $PS["Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_DocsTable = $PS["Gargantext.Components.DocsTable"];
  var Gargantext_Components_NgramsTable = $PS["Gargantext.Components.NgramsTable"];
  var Gargantext_Components_NgramsTable_Core = $PS["Gargantext.Components.NgramsTable.Core"];
  var Gargantext_Components_Tab = $PS["Gargantext.Components.Tab"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];                
  var Patents = (function () {
      function Patents() {

      };
      Patents.value = new Patents();
      return Patents;
  })();
  var Books = (function () {
      function Books() {

      };
      Books.value = new Books();
      return Books;
  })();
  var Communication = (function () {
      function Communication() {

      };
      Communication.value = new Communication();
      return Communication;
  })();
  var modeTabType$prime = function (v) {
      if (v instanceof Patents) {
          return Gargantext_Types.CTabAuthors.value;
      };
      if (v instanceof Books) {
          return Gargantext_Types.CTabAuthors.value;
      };
      if (v instanceof Communication) {
          return Gargantext_Types.CTabAuthors.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs (line 46, column 1 - line 46, column 38): " + [ v.constructor.name ]);
  };
  var modeTabType = function (v) {
      if (v instanceof Patents) {
          return Gargantext_Types.PTabPatents.value;
      };
      if (v instanceof Books) {
          return Gargantext_Types.PTabBooks.value;
      };
      if (v instanceof Communication) {
          return Gargantext_Types.PTabCommunication.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs (line 40, column 1 - line 40, column 37): " + [ v.constructor.name ]);
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs");
  var ngramsViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var tabType = Gargantext_Types.TabPairing.create(Gargantext_Types.TabNgramType.create(modeTabType(v.mode)));
              var tabNgramType = modeTabType$prime(v.mode);
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_NgramsTable_Core.initialPageParams(v.session)(v.nodeId)([ v.defaultListId ])(new Gargantext_Types.TabDocument(Gargantext_Types.TabDocs.value))))(function (path) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_NgramsTable.mainNgramsTable({
                      afterSync: function (v2) {
                          return Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Unit.unit);
                      },
                      cacheState: v.cacheState,
                      defaultListId: v.defaultListId,
                      path: path,
                      reloadForest: v.reloadForest,
                      reloadRoot: v.reloadRoot,
                      session: v.session,
                      tabNgramType: tabNgramType,
                      tabType: tabType,
                      tasks: v.tasks,
                      withAutoUpdate: false
                  })([  ]));
              });
          };
      };
      return here.component("ngramsView")(cpt);
  })();
  var ngramsView = Reactix_React.createElement(Reactix_React.componentIsComponent)(ngramsViewCpt);
  var tabsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var tabs$prime = (function () {
                  var patentsView = {
                      reloadRoot: v.reloadRoot,
                      tasks: v.tasks,
                      cacheState: v.cacheState,
                      defaultListId: v.contactData.defaultListId,
                      mode: Patents.value,
                      nodeId: v.nodeId,
                      reloadForest: v.reloadForest,
                      session: v.session
                  };
                  var commView = {
                      reloadRoot: v.reloadRoot,
                      tasks: v.tasks,
                      cacheState: v.cacheState,
                      defaultListId: v.contactData.defaultListId,
                      mode: Communication.value,
                      nodeId: v.nodeId,
                      reloadForest: v.reloadForest,
                      session: v.session
                  };
                  var docs = Gargantext_Components_DocsTable.docViewLayout({
                      cacheState: v.cacheState,
                      chart: Data_Monoid.mempty(Reactix_React.monoidElement),
                      frontends: v.frontends,
                      listId: v.contactData.defaultListId,
                      mCorpusId: Data_Maybe.Nothing.value,
                      nodeId: v.nodeId,
                      session: v.session,
                      showSearch: true,
                      sidePanel: v.sidePanel,
                      sidePanelState: v.sidePanelState,
                      tabType: new Gargantext_Types.TabPairing(Gargantext_Types.TabDocs.value),
                      totalRecords: 4736
                  });
                  var booksView = {
                      reloadRoot: v.reloadRoot,
                      tasks: v.tasks,
                      cacheState: v.cacheState,
                      defaultListId: v.contactData.defaultListId,
                      mode: Books.value,
                      nodeId: v.nodeId,
                      reloadForest: v.reloadForest,
                      session: v.session
                  };
                  return [ new Data_Tuple.Tuple("Documents", docs), new Data_Tuple.Tuple("Patents", ngramsView(patentsView)([  ])), new Data_Tuple.Tuple("Books", ngramsView(booksView)([  ])), new Data_Tuple.Tuple("Communication", ngramsView(commView)([  ])), new Data_Tuple.Tuple("Trash", docs) ];
              })();
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(0))(function (activeTab) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Tab.tabs({
                      activeTab: activeTab,
                      tabs: tabs$prime
                  }));
              });
          };
      };
      return here.component("tabs")(cpt);
  })();
  var tabs = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(tabsCpt)(props)([  ]);
  };
  exports["tabs"] = tabs;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Annuaire.User.Contact"] = $PS["Gargantext.Components.Nodes.Annuaire.User.Contact"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Annuaire.User.Contact"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Lens_Getter = $PS["Data.Lens.Getter"];
  var Data_Lens_Internal_Forget = $PS["Data.Lens.Internal.Forget"];
  var Data_Lens_Internal_Shop = $PS["Data.Lens.Internal.Shop"];
  var Data_Lens_Lens = $PS["Data.Lens.Lens"];
  var Data_Lens_Setter = $PS["Data.Lens.Setter"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Profunctor_Strong = $PS["Data.Profunctor.Strong"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_Components_InputWithEnter = $PS["Gargantext.Components.InputWithEnter"];
  var Gargantext_Components_Nodes_Annuaire_User_Contacts_Tabs = $PS["Gargantext.Components.Nodes.Annuaire.User.Contacts.Tabs"];
  var Gargantext_Components_Nodes_Annuaire_User_Contacts_Types = $PS["Gargantext.Components.Nodes.Annuaire.User.Contacts.Types"];
  var Gargantext_Components_Nodes_Lists_Types = $PS["Gargantext.Components.Nodes.Lists.Types"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var saveContactHyperdata = function (session) {
      return function (id) {
          return Gargantext_Sessions.put(Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["$_WriteForeignHyperdataCont_98"])(Simple_JSON.readInt)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(id), ""));
      };
  }; 
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Annuaire.User.Contact");
  var getAnnuaireContact = function (session) {
      return function (annuaireId) {
          return function (id) {
              return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.get(Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["$_ReadForeignContact'_71"])(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(Gargantext_Routes.NodeAPI.create(Gargantext_Types.Annuaire.value)(new Data_Maybe.Just(annuaireId))(Data_Show.show(Data_Show.showInt)(id))))(function (v) {
                  return Control_Applicative.pure(Effect_Aff.applicativeAff)({
                      contactNode: v,
                      defaultListId: 424242
                  });
              });
          };
      };
  };
  var displayCpt = (function () {
      var cpt = function (v) {
          return function (children) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "container-fluid"
              })([ Reactix_DOM_HTML.div({
                  className: "row",
                  id: "contact-page-header"
              })([ Reactix_DOM_HTML.div({
                  className: "col-md-6"
              })([ Reactix_DOM_HTML.h3({})([ Reactix_DOM_HTML.text(v.title) ]) ]), Reactix_DOM_HTML.div({
                  className: "col-md-8"
              })([  ]), Reactix_DOM_HTML.div({
                  className: "col-md-2"
              })([ Reactix_DOM_HTML.span({})([ Reactix_DOM_HTML.text("") ]) ]) ]), Reactix_DOM_HTML.div({
                  className: "row",
                  id: "contact-page-info"
              })([ Reactix_DOM_HTML.div({
                  className: "col-md-12"
              })([ Reactix_DOM_HTML.div({
                  className: "row"
              })([ Reactix_DOM_HTML.div({
                  className: "col-md-2"
              })([ Reactix_DOM_HTML.img({
                  src: "/images/Gargantextuel-212x300.jpg"
              }) ]), Reactix_DOM_HTML.div({
                  className: "col-md-1"
              })([  ]), Reactix_DOM_HTML.div({
                  className: "col-md-8"
              })(children) ]) ]) ]) ]));
          };
      };
      return here.component("display")(cpt);
  })();
  var display = Reactix_React.createElement(Reactix_React.componentIsComponent)(displayCpt);
  var contactInfoItems = [ {
      label: "Last Name",
      defaultVal: "Empty Last Name",
      lens: (function () {
          var $58 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_who"](Data_Lens_Internal_Shop.strongShop);
          var $59 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_lastName"](Data_Lens_Internal_Shop.strongShop);
          return function ($60) {
              return $58($59($60));
          };
      })()
  }, {
      label: "First Name",
      defaultVal: "Empty First Name",
      lens: (function () {
          var $61 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_who"](Data_Lens_Internal_Shop.strongShop);
          var $62 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_firstName"](Data_Lens_Internal_Shop.strongShop);
          return function ($63) {
              return $61($62($63));
          };
      })()
  }, {
      label: "Organisation",
      defaultVal: "Empty Organisation",
      lens: (function () {
          var $64 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $65 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_organizationJoinComma"](Data_Lens_Internal_Shop.strongShop);
          return function ($66) {
              return $64($65($66));
          };
      })()
  }, {
      label: "Lab/Team/Dept",
      defaultVal: "Empty Lab/Team/Dept",
      lens: (function () {
          var $67 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $68 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_labTeamDeptsJoinComma"](Data_Lens_Internal_Shop.strongShop);
          return function ($69) {
              return $67($68($69));
          };
      })()
  }, {
      label: "Office",
      defaultVal: "Empty Office",
      lens: (function () {
          var $70 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $71 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_office"](Data_Lens_Internal_Shop.strongShop);
          return function ($72) {
              return $70($71($72));
          };
      })()
  }, {
      label: "City",
      defaultVal: "Empty City",
      lens: (function () {
          var $73 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $74 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_city"](Data_Lens_Internal_Shop.strongShop);
          return function ($75) {
              return $73($74($75));
          };
      })()
  }, {
      label: "Country",
      defaultVal: "Empty Country",
      lens: (function () {
          var $76 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $77 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_country"](Data_Lens_Internal_Shop.strongShop);
          return function ($78) {
              return $76($77($78));
          };
      })()
  }, {
      label: "Role",
      defaultVal: "Empty Role",
      lens: (function () {
          var $79 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $80 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_role"](Data_Lens_Internal_Shop.strongShop);
          return function ($81) {
              return $79($80($81));
          };
      })()
  }, {
      label: "Phone",
      defaultVal: "Empty Phone",
      lens: (function () {
          var $82 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $83 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_touch"](Data_Lens_Internal_Shop.strongShop);
          var $84 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_phone"](Data_Lens_Internal_Shop.strongShop);
          return function ($85) {
              return $82($83($84($85)));
          };
      })()
  }, {
      label: "Mail",
      defaultVal: "Empty Mail",
      lens: (function () {
          var $86 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_ouFirst"](Data_Lens_Internal_Shop.strongShop);
          var $87 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_touch"](Data_Lens_Internal_Shop.strongShop);
          var $88 = Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["_mail"](Data_Lens_Internal_Shop.strongShop);
          return function ($89) {
              return $86($87($88($89)));
          };
      })()
  } ];
  var contactInfoItemCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var cLens = Data_Lens_Lens.cloneLens(v.lens);
              var item = function (v2) {
                  return function (isEditing) {
                      return function (valueRef) {
                          if (!v2) {
                              var placeholder$prime = Reactix_React.readRef(valueRef);
                              var click = function (v3) {
                                  return Toestand_Classes.write_(Toestand_Boxes.writeBox)(true)(isEditing);
                              };
                              return Reactix_DOM_HTML.div({
                                  className: "input-group col-sm-6"
                              })([ Reactix_DOM_HTML.input({
                                  className: "form-control",
                                  type: "text",
                                  defaultValue: placeholder$prime,
                                  disabled: true
                              }), Reactix_DOM_HTML.div({
                                  className: "btn input-group-append",
                                  on: {
                                      click: click
                                  }
                              })([ Reactix_DOM_HTML.div({
                                  className: "input-group-text fa fa-pencil"
                              })([  ]) ]) ]);
                          };
                          if (v2) {
                              var click = function (v3) {
                                  return function __do() {
                                      Toestand_Classes.write_(Toestand_Boxes.writeBox)(false)(isEditing)();
                                      var newHyperdata = Data_Lens_Setter.over(cLens(Data_Profunctor_Strong.strongFn))(function (v4) {
                                          return Reactix_React.readRef(valueRef);
                                      })(v.hyperdata);
                                      return v.onUpdateHyperdata(newHyperdata)();
                                  };
                              };
                              return Reactix_DOM_HTML.div({
                                  className: "input-group col-sm-6"
                              })([ Gargantext_Components_InputWithEnter.inputWithEnter({
                                  autoFocus: true,
                                  className: "form-control",
                                  defaultValue: Reactix_React.readRef(valueRef),
                                  onBlur: Reactix_React.setRef(valueRef),
                                  onEnter: click,
                                  onValueChanged: Reactix_React.setRef(valueRef),
                                  placeholder: v.placeholder,
                                  type: "text"
                              }), Reactix_DOM_HTML.div({
                                  className: "btn input-group-append",
                                  on: {
                                      click: click
                                  }
                              })([ Reactix_DOM_HTML.div({
                                  className: "input-group-text fa fa-floppy-o"
                              })([  ]) ]) ]);
                          };
                          throw new Error("Failed pattern match at Gargantext.Components.Nodes.Annuaire.User.Contact (line 112, column 9 - line 121, column 46): " + [ v2.constructor.name, isEditing.constructor.name, valueRef.constructor.name ]);
                      };
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(false))(function (isEditing) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(isEditing))(function (isEditing$prime) {
                      var value = Data_Lens_Getter.view(cLens(Data_Lens_Internal_Forget.strongForget))(v.hyperdata);
                      return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(value))(function (valueRef) {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                              className: "form-group row"
                          })([ Reactix_DOM_HTML.span({
                              className: "col-sm-2 col-form-label"
                          })([ Reactix_DOM_HTML.text(v.label) ]), item(isEditing$prime)(isEditing)(valueRef) ]));
                      });
                  });
              });
          };
      };
      return here.component("contactInfoItem")(cpt);
  })();
  var contactInfoItem = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(contactInfoItemCpt)(props)([  ]);
  };
  var contactInfos = function (h) {
      return function (onUpdateHyperdata) {
          var item = function (v) {
              return contactInfoItem({
                  label: v.label,
                  lens: v.lens,
                  onUpdateHyperdata: onUpdateHyperdata,
                  placeholder: v.defaultVal,
                  hyperdata: h
              });
          };
          return Data_Functor.map(Data_Functor.functorArray)(item)(contactInfoItems);
      };
  };
  var contactLayoutWithKeyCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onUpdateHyperdata = function (reload) {
                  return function (hd) {
                      return Effect_Aff.launchAff_(Control_Apply.applySecond(Effect_Aff.applyAff)(saveContactHyperdata(v.session)(v.nodeId)(hd))(Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(reload))));
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(reload))(function () {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_Nodes_Lists_Types.CacheOn.value))(function (cacheState) {
                          return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqInt)(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "defaultListId";
                          }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                              return "contactNode";
                          }))(Gargantext_Components_Nodes_Annuaire_User_Contacts_Types["$_EqContact'_70"])))(v.nodeId)(getAnnuaireContact(v.session)(v.annuaireId))(function (v2) {
                              return Reactix_DOM_HTML.ul({
                                  className: "col-md-12 list-group"
                              })([ display({
                                  title: Data_Maybe.fromMaybe("no name")(v2.contactNode.name)
                              })(contactInfos(v2.contactNode.hyperdata)(onUpdateHyperdata(reload))), Gargantext_Components_Nodes_Annuaire_User_Contacts_Tabs.tabs({
                                  cacheState: cacheState,
                                  contactData: v2,
                                  frontends: v.frontends,
                                  nodeId: v.nodeId,
                                  session: v.session,
                                  sidePanel: v.sidePanel,
                                  sidePanelState: v.sidePanelState,
                                  reloadForest: v.reloadForest,
                                  reloadRoot: v.reloadRoot,
                                  tasks: v.tasks
                              }) ]);
                          });
                      });
                  });
              });
          };
      };
      return here.component("contactLayoutWithKey")(cpt);
  })();
  var contactLayoutWithKey = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(contactLayoutWithKeyCpt)(props)([  ]);
  };
  var contactLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var key = Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(Gargantext_Sessions_Types.sessionId(v.session)) + ("-" + Data_Show.show(Data_Show.showInt)(v.nodeId));
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(contactLayoutWithKey({
                  annuaireId: v.annuaireId,
                  frontends: v.frontends,
                  key: key,
                  nodeId: v.nodeId,
                  reloadForest: v.reloadForest,
                  reloadRoot: v.reloadRoot,
                  session: v.session,
                  sidePanel: v.sidePanel,
                  sidePanelState: v.sidePanelState,
                  tasks: v.tasks
              }));
          };
      };
      return here.component("contactLayout")(cpt);
  })();
  var contactLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(contactLayoutCpt);
  exports["contactLayout"] = contactLayout;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Charts.Options.Color"] = $PS["Gargantext.Components.Charts.Options.Color"] || {};
  var exports = $PS["Gargantext.Components.Charts.Options.Color"];
  var Color = $PS["Color"];
  var Color_Scheme_X11 = $PS["Color.Scheme.X11"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
  var stringColor = Unsafe_Coerce.unsafeCoerce;
  var red = stringColor("red");        
  var grey = stringColor("grey");
  var green = stringColor("green");
  var cssColor = function ($0) {
      return stringColor(Color.toHexString($0));
  };
  var transparent = cssColor(Color.rgba(255)(255)(255)(0.0));
  var violet = cssColor(Color_Scheme_X11.violet);
  var blue = cssColor(Color.rgba(100)(150)(200)(0.0));
  var black = stringColor("black");
  exports["transparent"] = transparent;
  exports["red"] = red;
  exports["blue"] = blue;
  exports["violet"] = violet;
  exports["black"] = black;
  exports["grey"] = grey;
  exports["green"] = green;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Charts.Options.Data"] = $PS["Gargantext.Components.Charts.Options.Data"] || {};
  var exports = $PS["Gargantext.Components.Charts.Options.Data"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
  var dataSerie = function (dictOptional) {
      return Unsafe_Coerce.unsafeCoerce;
  };
  exports["dataSerie"] = dataSerie;
})(PS);
(function(exports) {
  "use strict";
  var ReactEcharts =require("echarts-for-react"); 

  exports.eChartsClass = ReactEcharts.default;
})(PS["Gargantext.Components.Charts.Options.ECharts"] = PS["Gargantext.Components.Charts.Options.ECharts"] || {});
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Charts.Options.Font"] = $PS["Gargantext.Components.Charts.Options.Font"] || {};
  var exports = $PS["Gargantext.Components.Charts.Options.Font"];
  var CSS_FontStyle = $PS["CSS.FontStyle"];
  var CSS_Property = $PS["CSS.Property"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Show_Generic = $PS["Data.Show.Generic"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
  var Circle = (function () {
      function Circle() {

      };
      Circle.value = new Circle();
      return Circle;
  })();
  var Rect = (function () {
      function Rect() {

      };
      Rect.value = new Rect();
      return Rect;
  })();
  var RoundRect = (function () {
      function RoundRect() {

      };
      RoundRect.value = new RoundRect();
      return RoundRect;
  })();
  var Triangle = (function () {
      function Triangle() {

      };
      Triangle.value = new Triangle();
      return Triangle;
  })();
  var Diamond = (function () {
      function Diamond() {

      };
      Diamond.value = new Diamond();
      return Diamond;
  })();
  var Pin = (function () {
      function Pin() {

      };
      Pin.value = new Pin();
      return Pin;
  })();
  var Arrow = (function () {
      function Arrow() {

      };
      Arrow.value = new Arrow();
      return Arrow;
  })();
  var Shape = (function () {
      function Shape(value0) {
          this.value0 = value0;
      };
      Shape.create = function (value0) {
          return new Shape(value0);
      };
      return Shape;
  })();
  var Image = (function () {
      function Image(value0) {
          this.value0 = value0;
      };
      Image.create = function (value0) {
          return new Image(value0);
      };
      return Image;
  })();
  var Icon = function (x) {
      return x;
  };
  var templateFormatter = Unsafe_Coerce.unsafeCoerce;
  var mkTooltip = function (dictOptional) {
      return Unsafe_Coerce.unsafeCoerce;
  };
  var mkToolBox = {
      feature: {
          dataView: {
              show: true,
              readOnly: false,
              title: "Data"
          },
          saveAsImage: {
              show: true,
              pixelRatio: 10,
              title: "Image"
          }
      },
      orient: "vertical"
  };
  var itemStyle = function (dictOptional) {
      return Unsafe_Coerce.unsafeCoerce;
  };
  var chartFontWeight = function (v) {
      if (v instanceof CSS_Property.Plain && v.value0 === "bold") {
          return "bold";
      };
      if (v instanceof CSS_Property.Plain && v.value0 === "bolder") {
          return "bolder";
      };
      if (v instanceof CSS_Property.Plain && v.value0 === "lighter") {
          return "lighter";
      };
      return "normal";
  };
  var chartFontStyle = function (v) {
      if (v instanceof CSS_FontStyle.Italic) {
          return "italic";
      };
      if (v instanceof CSS_FontStyle.Oblique) {
          return "oblique";
      };
      return "normal";
  };
  var $dollar_GenericShape__4 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Circle) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof Rect) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof RoundRect) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof Triangle) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
      };
      if (x instanceof Diamond) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)))));
      };
      if (x instanceof Pin) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))))));
      };
      if (x instanceof Arrow) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))))));
      };
      throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.Font (line 85, column 1 - line 85, column 32): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return Circle.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return Rect.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return RoundRect.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
          return Triangle.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl)))) {
          return Diamond.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inl))))) {
          return Pin.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0.value0.value0 instanceof Data_Generic_Rep.Inr))))) {
          return Arrow.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.Font (line 85, column 1 - line 85, column 32): " + [ x.constructor.name ]);
  });
  var icon = function (v) {
      if (v instanceof Shape) {
          return Icon(Data_String_Common.toLower(Data_Show_Generic.genericShow($dollar_GenericShape__4)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
              return "Circle";
          })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
              return "Rect";
          })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
              return "RoundRect";
          })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
              return "Triangle";
          })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
              return "Diamond";
          })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
              return "Pin";
          })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
              return "Arrow";
          })))))))))(v.value0)));
      };
      if (v instanceof Image) {
          return Icon("image://" + v.value0);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.Font (line 89, column 1 - line 89, column 28): " + [ v.constructor.name ]);
  };
  exports["itemStyle"] = itemStyle;
  exports["chartFontStyle"] = chartFontStyle;
  exports["chartFontWeight"] = chartFontWeight;
  exports["Circle"] = Circle;
  exports["Shape"] = Shape;
  exports["icon"] = icon;
  exports["templateFormatter"] = templateFormatter;
  exports["mkTooltip"] = mkTooltip;
  exports["mkToolBox"] = mkToolBox;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Charts.Options.Legend"] = $PS["Gargantext.Components.Charts.Options.Legend"] || {};
  var exports = $PS["Gargantext.Components.Charts.Options.Legend"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Show = $PS["Data.Show"];
  var Data_Show_Generic = $PS["Data.Show.Generic"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Symbol = $PS["Data.Symbol"];                
  var Plain = (function () {
      function Plain() {

      };
      Plain.value = new Plain();
      return Plain;
  })();
  var Scroll = (function () {
      function Scroll() {

      };
      Scroll.value = new Scroll();
      return Scroll;
  })();
  var Horizontal = (function () {
      function Horizontal() {

      };
      Horizontal.value = new Horizontal();
      return Horizontal;
  })();
  var Vertical = (function () {
      function Vertical() {

      };
      Vertical.value = new Vertical();
      return Vertical;
  })();
  var Orient = function (x) {
      return x;
  };
  var LegendType = function (x) {
      return x;
  };
  var Bool = (function () {
      function Bool(value0) {
          this.value0 = value0;
      };
      Bool.create = function (value0) {
          return new Bool(value0);
      };
      return Bool;
  })();
  var Single = (function () {
      function Single() {

      };
      Single.value = new Single();
      return Single;
  })();
  var Multiple = (function () {
      function Multiple() {

      };
      Multiple.value = new Multiple();
      return Multiple;
  })();
  var selectedMode = function (v) {
      if (v instanceof Bool) {
          return v.value0;
      };
      if (v instanceof Single) {
          return "single";
      };
      if (v instanceof Multiple) {
          return "multiple";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.Legend (line 46, column 1 - line 46, column 43): " + [ v.constructor.name ]);
  };
  var $dollar_ShowPlainOrScroll_5 = new Data_Show.Show(function (v) {
      if (v instanceof Plain) {
          return "plain";
      };
      if (v instanceof Scroll) {
          return "scroll";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.Legend (line 24, column 1 - line 26, column 27): " + [ v.constructor.name ]);
  });
  var legendType = (function () {
      var $23 = Data_Show.show($dollar_ShowPlainOrScroll_5);
      return function ($24) {
          return LegendType(Data_String_Common.toLower($23($24)));
      };
  })();
  var $dollar_GenericOrientation__6 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof Horizontal) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof Vertical) {
          return new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.Legend (line 35, column 1 - line 35, column 38): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return Horizontal.value;
      };
      if (x instanceof Data_Generic_Rep.Inr) {
          return Vertical.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.Legend (line 35, column 1 - line 35, column 38): " + [ x.constructor.name ]);
  });
  var orient = (function () {
      var $25 = Data_Show_Generic.genericShow($dollar_GenericOrientation__6)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
          return "Horizontal";
      })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
          return "Vertical";
      }))));
      return function ($26) {
          return Orient(Data_String_Common.toLower($25($26)));
      };
  })();
  exports["Plain"] = Plain;
  exports["legendType"] = legendType;
  exports["Horizontal"] = Horizontal;
  exports["orient"] = orient;
  exports["Bool"] = Bool;
  exports["selectedMode"] = selectedMode;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Charts.Options.Position"] = $PS["Gargantext.Components.Charts.Options.Position"] || {};
  var exports = $PS["Gargantext.Components.Charts.Options.Position"];
  var Data_Show = $PS["Data.Show"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
  var Top = (function () {
      function Top() {

      };
      Top.value = new Top();
      return Top;
  })();
  var Middle = (function () {
      function Middle() {

      };
      Middle.value = new Middle();
      return Middle;
  })();
  var Bottom = (function () {
      function Bottom() {

      };
      Bottom.value = new Bottom();
      return Bottom;
  })();
  var LeftPos = (function () {
      function LeftPos() {

      };
      LeftPos.value = new LeftPos();
      return LeftPos;
  })();
  var Center = (function () {
      function Center() {

      };
      Center.value = new Center();
      return Center;
  })();
  var RightPos = (function () {
      function RightPos() {

      };
      RightPos.value = new RightPos();
      return RightPos;
  })();
  var Auto = (function () {
      function Auto() {

      };
      Auto.value = new Auto();
      return Auto;
  })();
  var Relative = (function () {
      function Relative(value0) {
          this.value0 = value0;
      };
      Relative.create = function (value0) {
          return new Relative(value0);
      };
      return Relative;
  })();
  var relativePosition = function (dictShow) {
      return function (v) {
          if (v instanceof Auto) {
              return "auto";
          };
          if (v instanceof Relative) {
              return Data_Show.show(dictShow)(v.value0);
          };
          throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.Position (line 30, column 1 - line 30, column 62): " + [ v.constructor.name ]);
      };
  };
  var percentPosition = function (n) {
      return Data_Show.show(Data_Show.showNumber)(n) + "%";
  };
  var numberPosition = Unsafe_Coerce.unsafeCoerce;
  var $dollar_ShowTopRelativePosition_3 = new Data_Show.Show(function (v) {
      if (v instanceof Top) {
          return "top";
      };
      if (v instanceof Middle) {
          return "middle";
      };
      if (v instanceof Bottom) {
          return "bottom";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.Position (line 37, column 1 - line 40, column 33): " + [ v.constructor.name ]);
  });
  var $dollar_ShowLeftRelativePosition_4 = new Data_Show.Show(function (v) {
      if (v instanceof LeftPos) {
          return "left";
      };
      if (v instanceof Center) {
          return "center";
      };
      if (v instanceof RightPos) {
          return "right";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.Position (line 43, column 1 - line 46, column 34): " + [ v.constructor.name ]);
  });
  exports["numberPosition"] = numberPosition;
  exports["percentPosition"] = percentPosition;
  exports["relativePosition"] = relativePosition;
  exports["Auto"] = Auto;
  exports["Relative"] = Relative;
  exports["Top"] = Top;
  exports["Bottom"] = Bottom;
  exports["LeftPos"] = LeftPos;
  exports["RightPos"] = RightPos;
  exports["$_ShowTopRelativePosition_3"] = $dollar_ShowTopRelativePosition_3;
  exports["$_ShowLeftRelativePosition_4"] = $dollar_ShowLeftRelativePosition_4;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Charts.Options.Type"] = $PS["Gargantext.Components.Charts.Options.Type"] || {};
  var exports = $PS["Gargantext.Components.Charts.Options.Type"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];
  var yAxis = function (dictOptional) {
      return Unsafe_Coerce.unsafeCoerce;
  };
  var xAxis = function (dictOptional) {
      return Unsafe_Coerce.unsafeCoerce;
  };
  exports["xAxis"] = xAxis;
  exports["yAxis"] = yAxis;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Charts.Options.ECharts"] = $PS["Gargantext.Components.Charts.Options.ECharts"] || {};
  var exports = $PS["Gargantext.Components.Charts.Options.ECharts"];
  var $foreign = $PS["Gargantext.Components.Charts.Options.ECharts"];
  var CSS_Common = $PS["CSS.Common"];
  var CSS_Font = $PS["CSS.Font"];
  var CSS_FontStyle = $PS["CSS.FontStyle"];
  var Data_Show = $PS["Data.Show"];
  var Data_Unit = $PS["Data.Unit"];
  var Gargantext_Components_Charts_Options_Color = $PS["Gargantext.Components.Charts.Options.Color"];
  var Gargantext_Components_Charts_Options_Font = $PS["Gargantext.Components.Charts.Options.Font"];
  var Gargantext_Components_Charts_Options_Legend = $PS["Gargantext.Components.Charts.Options.Legend"];
  var Gargantext_Components_Charts_Options_Position = $PS["Gargantext.Components.Charts.Options.Position"];
  var Gargantext_Components_Charts_Options_Type = $PS["Gargantext.Components.Charts.Options.Type"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var React = $PS["React"];                
  var Slider = (function () {
      function Slider() {

      };
      Slider.value = new Slider();
      return Slider;
  })();
  var Inside = (function () {
      function Inside() {

      };
      Inside.value = new Inside();
      return Inside;
  })();
  var Options = (function () {
      function Options(value0) {
          this.value0 = value0;
      };
      Options.create = function (value0) {
          return new Options(value0);
      };
      return Options;
  })();
  var yAxis$prime = function (v) {
      return Gargantext_Components_Charts_Options_Type.yAxis()({
          type: "value",
          name: "",
          min: v.min,
          axisLabel: {
              formatter: "{value}"
          },
          position: v.position,
          show: v.show
      });
  };
  var xAxis$prime = function (v) {
      if (v.length === 0) {
          return {
              show: false
          };
      };
      return Gargantext_Components_Charts_Options_Type.xAxis()({
          data: v,
          type: "category",
          axisTick: {
              alignWithLabel: true
          },
          show: true,
          axisLabel: {
              formatter: "{value}"
          }
      });
  }; 
  var textStyle2 = {
      color: Gargantext_Components_Charts_Options_Color.black,
      fontStyle: Gargantext_Components_Charts_Options_Font.chartFontStyle(CSS_FontStyle.Italic.value),
      fontWeight: Gargantext_Components_Charts_Options_Font.chartFontWeight(CSS_Common.normal(CSS_Font.normalFontWeight)),
      fontFamily: "sans-serif",
      fontSize: 11,
      align: Gargantext_Components_Charts_Options_Position.relativePosition(Gargantext_Components_Charts_Options_Position["$_ShowLeftRelativePosition_4"])(new Gargantext_Components_Charts_Options_Position.Relative(Gargantext_Components_Charts_Options_Position.RightPos.value)),
      verticalAlign: Gargantext_Components_Charts_Options_Position.relativePosition(Gargantext_Components_Charts_Options_Position["$_ShowTopRelativePosition_3"])(new Gargantext_Components_Charts_Options_Position.Relative(Gargantext_Components_Charts_Options_Position.Bottom.value)),
      lineHeight: Gargantext_Components_Charts_Options_Position.percentPosition(0.0),
      width: Gargantext_Components_Charts_Options_Position.percentPosition(100.0),
      height: Gargantext_Components_Charts_Options_Position.percentPosition(100.0),
      textBorderColor: Gargantext_Components_Charts_Options_Color.black,
      textBorderWidth: 0.0,
      textShadowColor: Gargantext_Components_Charts_Options_Color.black,
      textShadowBlur: Gargantext_Components_Charts_Options_Color.black,
      textShadowOffsetX: 0.0,
      textShadowOffsetY: 0.0
  };
  var textStyle$prime = {
      color: Gargantext_Components_Charts_Options_Color.black,
      fontStyle: Gargantext_Components_Charts_Options_Font.chartFontStyle(CSS_Common.normal(CSS_FontStyle.normalFontStyle)),
      fontWeight: Gargantext_Components_Charts_Options_Font.chartFontWeight(CSS_Common.normal(CSS_Font.normalFontWeight)),
      fontFamily: "sans-serif",
      fontSize: 15,
      align: Gargantext_Components_Charts_Options_Position.relativePosition(Gargantext_Components_Charts_Options_Position["$_ShowLeftRelativePosition_4"])(new Gargantext_Components_Charts_Options_Position.Relative(Gargantext_Components_Charts_Options_Position.LeftPos.value)),
      verticalAlign: Gargantext_Components_Charts_Options_Position.relativePosition(Gargantext_Components_Charts_Options_Position["$_ShowTopRelativePosition_3"])(new Gargantext_Components_Charts_Options_Position.Relative(Gargantext_Components_Charts_Options_Position.Top.value)),
      lineHeight: Gargantext_Components_Charts_Options_Position.percentPosition(0.0),
      width: Gargantext_Components_Charts_Options_Position.percentPosition(100.0),
      height: Gargantext_Components_Charts_Options_Position.percentPosition(100.0),
      textBorderColor: Gargantext_Components_Charts_Options_Color.black,
      textBorderWidth: 1.0,
      textShadowColor: Gargantext_Components_Charts_Options_Color.black,
      textShadowBlur: Gargantext_Components_Charts_Options_Color.black,
      textShadowOffsetX: 0.0,
      textShadowOffsetY: 0.0
  };
  var textStyle = {
      color: Gargantext_Components_Charts_Options_Color.black,
      fontStyle: Gargantext_Components_Charts_Options_Font.chartFontStyle(CSS_Common.normal(CSS_FontStyle.normalFontStyle)),
      fontWeight: Gargantext_Components_Charts_Options_Font.chartFontWeight(CSS_Common.normal(CSS_Font.normalFontWeight)),
      fontFamily: "sans-serif",
      fontSize: 10,
      align: Gargantext_Components_Charts_Options_Position.relativePosition(Gargantext_Components_Charts_Options_Position["$_ShowLeftRelativePosition_4"])(new Gargantext_Components_Charts_Options_Position.Relative(Gargantext_Components_Charts_Options_Position.LeftPos.value)),
      verticalAlign: Gargantext_Components_Charts_Options_Position.relativePosition(Gargantext_Components_Charts_Options_Position["$_ShowTopRelativePosition_3"])(new Gargantext_Components_Charts_Options_Position.Relative(Gargantext_Components_Charts_Options_Position.Top.value)),
      lineHeight: Gargantext_Components_Charts_Options_Position.percentPosition(10.0),
      width: Gargantext_Components_Charts_Options_Position.percentPosition(100.0),
      height: Gargantext_Components_Charts_Options_Position.percentPosition(100.0),
      textBorderColor: Gargantext_Components_Charts_Options_Color.black,
      textBorderWidth: 1.0,
      textShadowColor: Gargantext_Components_Charts_Options_Color.black,
      textShadowBlur: Gargantext_Components_Charts_Options_Color.black,
      textShadowOffsetX: 0.0,
      textShadowOffsetY: 0.0
  };
  var title = function (mainTitle) {
      return function (subTitle) {
          return {
              id: "",
              show: true,
              text: mainTitle,
              link: "",
              target: "blank",
              textStyle: textStyle,
              subtext: subTitle,
              sublink: "",
              subtarget: "blank",
              subtextStyle: textStyle2,
              padding: 10.0,
              itemGap: 0.0,
              zlevel: 2.0,
              z: 2.0,
              left: Gargantext_Components_Charts_Options_Position.relativePosition(Gargantext_Components_Charts_Options_Position["$_ShowLeftRelativePosition_4"])(new Gargantext_Components_Charts_Options_Position.Relative(Gargantext_Components_Charts_Options_Position.RightPos.value)),
              top: Gargantext_Components_Charts_Options_Position.relativePosition(Gargantext_Components_Charts_Options_Position["$_ShowTopRelativePosition_3"])(new Gargantext_Components_Charts_Options_Position.Relative(Gargantext_Components_Charts_Options_Position.Top.value)),
              right: Gargantext_Components_Charts_Options_Position.numberPosition(60.0),
              bottom: Gargantext_Components_Charts_Options_Position.percentPosition(40.0),
              backgroundColor: Gargantext_Components_Charts_Options_Color.transparent,
              borderColor: Gargantext_Components_Charts_Options_Color.transparent,
              borderWidth: 0.0,
              borderRadius: 0.0,
              shadowBlur: 0.0,
              shadowColor: Gargantext_Components_Charts_Options_Color.transparent,
              shadowOffsetX: 0.0,
              shadowOffsetY: 0.0
          };
      };
  };    
  var echarts = function (c) {
      return Gargantext_Utils_Reactix.buff(React.unsafeCreateElementDynamic($foreign.eChartsClass)(c)([  ]));
  };
  var data1 = {
      name: "Map terms coverage",
      icon: Gargantext_Components_Charts_Options_Font.icon(new Gargantext_Components_Charts_Options_Font.Shape(Gargantext_Components_Charts_Options_Font.Circle.value)),
      textStyle: textStyle$prime
  };
  var legend = {
      id: "Muda",
      type: Gargantext_Components_Charts_Options_Legend.legendType(Gargantext_Components_Charts_Options_Legend.Plain.value),
      show: true,
      zlevel: 0.0,
      z: 2.0,
      left: Gargantext_Components_Charts_Options_Position.relativePosition(Gargantext_Components_Charts_Options_Position["$_ShowLeftRelativePosition_4"])(Gargantext_Components_Charts_Options_Position.Auto.value),
      top: Gargantext_Components_Charts_Options_Position.relativePosition(Gargantext_Components_Charts_Options_Position["$_ShowTopRelativePosition_3"])(Gargantext_Components_Charts_Options_Position.Auto.value),
      right: Gargantext_Components_Charts_Options_Position.relativePosition(Data_Unit.showUnit)(Gargantext_Components_Charts_Options_Position.Auto.value),
      bottom: Gargantext_Components_Charts_Options_Position.relativePosition(Data_Unit.showUnit)(Gargantext_Components_Charts_Options_Position.Auto.value),
      width: Gargantext_Components_Charts_Options_Position.relativePosition(Data_Unit.showUnit)(Gargantext_Components_Charts_Options_Position.Auto.value),
      height: Gargantext_Components_Charts_Options_Position.relativePosition(Data_Unit.showUnit)(Gargantext_Components_Charts_Options_Position.Auto.value),
      orient: Gargantext_Components_Charts_Options_Legend.orient(Gargantext_Components_Charts_Options_Legend.Horizontal.value),
      align: Gargantext_Components_Charts_Options_Position.relativePosition(Gargantext_Components_Charts_Options_Position["$_ShowLeftRelativePosition_4"])(Gargantext_Components_Charts_Options_Position.Auto.value),
      padding: 5.0,
      itemGap: 10.0,
      itemWidth: 25.0,
      itemHeight: 14.0,
      selectedMode: Gargantext_Components_Charts_Options_Legend.selectedMode(new Gargantext_Components_Charts_Options_Legend.Bool(true)),
      inactiveColor: Gargantext_Components_Charts_Options_Color.violet,
      textStyle: textStyle,
      data: [ data1 ]
  };
  var chartWith = function (option) {
      return {
          option: option
      };
  };
  var $dollar_ShowZoom_4 = new Data_Show.Show(function (v) {
      if (v instanceof Slider) {
          return "slider";
      };
      if (v instanceof Inside) {
          return "inside";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.ECharts (line 186, column 1 - line 188, column 25): " + [ v.constructor.name ]);
  });
  var zoom = function (z) {
      return {
          type: Data_Show.show($dollar_ShowZoom_4)(z),
          xAxisIndex: 0,
          filterMode: "empty",
          start: 0,
          end: 100
      };
  };
  var opts = function (v) {
      return {
          title: title(v.value0.mainTitle)(v.value0.subTitle),
          legend: legend,
          tooltip: v.value0.tooltip,
          grid: {
              containLabel: true
          },
          series: v.value0.series,
          xAxis: v.value0.xAxis,
          yAxis: v.value0.yAxis,
          dataZoom: (function () {
              if (v.value0.addZoom) {
                  return [ zoom(Slider.value), zoom(Inside.value) ];
              };
              return [  ];
          })(),
          children: [  ],
          toolbox: Gargantext_Components_Charts_Options_Font.mkToolBox
      };
  };
  var chart = function ($21) {
      return echarts(chartWith(opts($21)));
  };
  exports["chart"] = chart;
  exports["xAxis'"] = xAxis$prime;
  exports["yAxis'"] = yAxis$prime;
  exports["Options"] = Options;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Charts.Options.Series"] = $PS["Gargantext.Components.Charts.Options.Series"] || {};
  var exports = $PS["Gargantext.Components.Charts.Options.Series"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Semiring = $PS["Data.Semiring"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Record = $PS["Record"];
  var Record_Unsafe = $PS["Record.Unsafe"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Unsafe_Coerce = $PS["Unsafe.Coerce"];                
  var TreeLine = (function () {
      function TreeLine() {

      };
      TreeLine.value = new TreeLine();
      return TreeLine;
  })();
  var TreeRadial = (function () {
      function TreeRadial() {

      };
      TreeRadial.value = new TreeRadial();
      return TreeRadial;
  })();
  var TreeMap = (function () {
      function TreeMap() {

      };
      TreeMap.value = new TreeMap();
      return TreeMap;
  })();
  var TreeNode = function (x) {
      return x;
  };   
  var SeriesType = function (x) {
      return x;
  };
  var Line = (function () {
      function Line() {

      };
      Line.value = new Line();
      return Line;
  })();
  var Bar = (function () {
      function Bar() {

      };
      Bar.value = new Bar();
      return Bar;
  })();
  var Pie = (function () {
      function Pie() {

      };
      Pie.value = new Pie();
      return Pie;
  })();
  var Scatter = (function () {
      function Scatter() {

      };
      Scatter.value = new Scatter();
      return Scatter;
  })();
  var EffectScatter = (function () {
      function EffectScatter() {

      };
      EffectScatter.value = new EffectScatter();
      return EffectScatter;
  })();
  var Sunburst = (function () {
      function Sunburst() {

      };
      Sunburst.value = new Sunburst();
      return Sunburst;
  })();
  var Heatmap = (function () {
      function Heatmap() {

      };
      Heatmap.value = new Heatmap();
      return Heatmap;
  })();
  var Sankey = (function () {
      function Sankey() {

      };
      Sankey.value = new Sankey();
      return Sankey;
  })();
  var Funnel = (function () {
      function Funnel() {

      };
      Funnel.value = new Funnel();
      return Funnel;
  })();
  var unsafeSeries = Unsafe_Coerce.unsafeCoerce;
  var treeValue = function (v) {
      return Data_Array.foldl(Data_Semiring.add(Data_Semiring.semiringInt))(0)(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ v.value ])(Data_Functor.map(Data_Functor.functorArray)(treeValue)(v.children)));
  };
  var toJsTree = function (maybeSurname) {
      return function (v) {
          var name = Data_Maybe.maybe("")(function (x$prime) {
              return x$prime + ">";
          })(maybeSurname) + v.name;
          return {
              name: name,
              value: Data_Array.foldl(Data_Semiring.add(Data_Semiring.semiringInt))(0)(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ v.value ])(Data_Functor.map(Data_Functor.functorArray)(treeValue)(v.children))),
              children: Data_Functor.map(Data_Functor.functorArray)(toJsTree(new Data_Maybe.Just(name)))(v.children)
          };
      };
  };
  var seriesTree = function (dictOptional) {
      return unsafeSeries;
  };
  var nameP = Data_Symbol.SProxy.value;
  var labelP = Data_Symbol.SProxy.value;
  var $dollar_ShowTrees_13 = new Data_Show.Show(function (v) {
      if (v instanceof TreeLine) {
          return "tree";
      };
      if (v instanceof TreeRadial) {
          return "tree";
      };
      if (v instanceof TreeMap) {
          return "treemap";
      };
      throw new Error("Failed pattern match at Gargantext.Components.Charts.Options.Series (line 136, column 1 - line 139, column 31): " + [ v.constructor.name ]);
  });
  var mkTree = function (t) {
      return function (ts) {
          var layout = (function () {
              if (t instanceof TreeRadial) {
                  return "radial";
              };
              return "none";
          })();
          return seriesTree()({
              type: Data_Show.show($dollar_ShowTrees_13)(t),
              data: Data_Functor.map(Data_Functor.functorArray)(toJsTree(Data_Maybe.Nothing.value))(ts),
              layout: layout
          });
      };
  };
  var $dollar_ShowChart_12 = new Data_Show.Show(function (v) {
      if (v instanceof Bar) {
          return "bar";
      };
      if (v instanceof EffectScatter) {
          return "effectScatter";
      };
      if (v instanceof Funnel) {
          return "funnel";
      };
      if (v instanceof Heatmap) {
          return "heatmap";
      };
      if (v instanceof Line) {
          return "line";
      };
      if (v instanceof Pie) {
          return "pie";
      };
      if (v instanceof Sankey) {
          return "sankey";
      };
      if (v instanceof Scatter) {
          return "scatter";
      };
      if (v instanceof Sunburst) {
          return "sunburst";
      };
      return "not implemented yet: should throw error here";
  });
  var seriesType = (function () {
      var $41 = Data_Show.show($dollar_ShowChart_12);
      return function ($42) {
          return SeriesType($41($42));
      };
  })();
  var seriesBarD1 = function (dictOptional) {
      return function (o) {
          return function (ds) {
              return unsafeSeries(Record_Unsafe.unsafeSet("data")(ds)(Record_Unsafe.unsafeSet("type")(seriesType(Bar.value))(o)));
          };
      };
  };
  var seriesPieD1 = function (dictOptional) {
      return function (o) {
          return function (ds) {
              return unsafeSeries(Record_Unsafe.unsafeSet("data")(ds)(Record_Unsafe.unsafeSet("type")(seriesType(Pie.value))(o)));
          };
      };
  };
  var seriesScatterD2 = function (dictOptional) {
      return function (o) {
          return function (ds) {
              return Record_Unsafe.unsafeSet("data")(ds)(Record_Unsafe.unsafeSet("type")(seriesType(Scatter.value))(o));
          };
      };
  };
  var $dollar_ReadForeignTreeNode_17 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "children";
      }))(Simple_JSON.readArray($dollar_ReadForeignTreeNode_17))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "label";
      }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "value";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()())()()))(f))(function (inst) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))(TreeNode(Record.rename(new Data_Symbol.IsSymbol(function () {
              return "label";
          }))(new Data_Symbol.IsSymbol(function () {
              return "name";
          }))()()()()(labelP)(nameP)(inst)));
      });
  });
  var $dollar_EqTreeNode_16 = new Data_Eq.Eq(function (x) {
      return function (y) {
          return Data_Eq.eq(Data_Eq.eqArray($dollar_EqTreeNode_16))(x.children)(y.children) && x.name === y.name && x.value === y.value;
      };
  });
  exports["seriesBarD1"] = seriesBarD1;
  exports["seriesPieD1"] = seriesPieD1;
  exports["seriesScatterD2"] = seriesScatterD2;
  exports["TreeMap"] = TreeMap;
  exports["mkTree"] = mkTree;
  exports["$_EqTreeNode_16"] = $dollar_EqTreeNode_16;
  exports["$_ReadForeignTreeNode_17"] = $dollar_ReadForeignTreeNode_17;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Chart.Common"] = $PS["Gargantext.Components.Nodes.Corpus.Chart.Common"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Chart.Common"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Corpus.Chart.Common");
  var metricsWithCacheLoadViewCpt = function (dictEq) {
      return function (dictReadForeign) {
          var cpt = function (v) {
              return function (v1) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(v.reload))(function (reload$prime) {
                      return Gargantext_Hooks_Loader.useLoaderWithCacheAPI(dictEq)(Data_Tuple.eqTuple(Data_Eq.eqInt)(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "tabType";
                      }))(Gargantext_Types["$_EqTabType_148"]))()(new Data_Symbol.IsSymbol(function () {
                          return "listId";
                      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                          return "limit";
                      }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                          return "corpusId";
                      }))(Data_Eq.eqInt))))(dictReadForeign)({
                          cacheEndpoint: v.getMetricsHash(v.session),
                          handleResponse: v.handleResponse,
                          mkRequest: v.mkRequest,
                          path: new Data_Tuple.Tuple(reload$prime, v.path),
                          renderer: v.loaded({
                              path: v.path,
                              reload: v.reload,
                              session: v.session
                          })
                      });
                  });
              };
          };
          return here.component("metricsWithCacheLoadView")(cpt);
      };
  };
  var metricsWithCacheLoadView = function (dictEq) {
      return function (dictReadForeign) {
          return function (p) {
              return Reactix_React.createElement(Reactix_React.componentIsComponent)(metricsWithCacheLoadViewCpt(dictEq)(dictReadForeign))(p)([  ]);
          };
      };
  };
  exports["metricsWithCacheLoadView"] = metricsWithCacheLoadView;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Chart.Histo"] = $PS["Gargantext.Components.Nodes.Corpus.Chart.Histo"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Chart.Histo"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_Charts_Options_Color = $PS["Gargantext.Components.Charts.Options.Color"];
  var Gargantext_Components_Charts_Options_Data = $PS["Gargantext.Components.Charts.Options.Data"];
  var Gargantext_Components_Charts_Options_ECharts = $PS["Gargantext.Components.Charts.Options.ECharts"];
  var Gargantext_Components_Charts_Options_Font = $PS["Gargantext.Components.Charts.Options.Font"];
  var Gargantext_Components_Charts_Options_Series = $PS["Gargantext.Components.Charts.Options.Series"];
  var Gargantext_Components_Nodes_Corpus_Chart_Common = $PS["Gargantext.Components.Nodes.Corpus.Chart.Common"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_CacheAPI = $PS["Gargantext.Utils.CacheAPI"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Corpus.Chart.Histo");
  var handleResponse = function (v) {
      return v.value.data;
  };
  var getMetricsHash = function (session) {
      return function (v) {
          var mListId = (function () {
              var $25 = v.value1.listId === 0;
              if ($25) {
                  return Data_Maybe.Nothing.value;
              };
              return new Data_Maybe.Just(v.value1.listId);
          })();
          return Gargantext_Sessions.get(Simple_JSON.readString)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.ChartHash({
              chartType: Gargantext_Types.Histo.value,
              listId: mListId,
              tabType: v.value1.tabType
          }, new Data_Maybe.Just(v.value1.corpusId)));
      };
  };
  var chartUrl = function (v) {
      var mListId = (function () {
          var $33 = v.listId === 0;
          if ($33) {
              return Data_Maybe.Nothing.value;
          };
          return new Data_Maybe.Just(v.listId);
      })();
      return new Gargantext_Routes.Chart({
          chartType: Gargantext_Types.Histo.value,
          limit: v.limit,
          listId: mListId,
          tabType: v.tabType
      }, new Data_Maybe.Just(v.corpusId));
  };
  var mkRequest = function (session) {
      return function (v) {
          return Gargantext_Utils_CacheAPI.makeGetRequest(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(chartUrl(v.value1));
      };
  };
  var chartOptions = function (v) {
      return new Gargantext_Components_Charts_Options_ECharts.Options({
          mainTitle: "Histogram",
          subTitle: "Distribution of publications over time",
          xAxis: Gargantext_Components_Charts_Options_ECharts["xAxis'"](v.dates),
          yAxis: Gargantext_Components_Charts_Options_ECharts["yAxis'"]({
              position: "left",
              show: true,
              min: 0
          }),
          addZoom: true,
          tooltip: Gargantext_Components_Charts_Options_Font.mkTooltip()({
              formatter: Gargantext_Components_Charts_Options_Font.templateFormatter("{b0}")
          }),
          series: [ Gargantext_Components_Charts_Options_Series.seriesBarD1()({
              name: "Number of publication / year"
          })(Data_Functor.map(Data_Functor.functorArray)(function (n) {
              return Gargantext_Components_Charts_Options_Data.dataSerie()({
                  value: n,
                  itemStyle: Gargantext_Components_Charts_Options_Font.itemStyle()({
                      color: Gargantext_Components_Charts_Options_Color.grey
                  })
              });
          })(v.count)) ]
      });
  };
  var loaded = function (v) {
      return function (l) {
          return Reactix_DOM_HTML.div({})([ Gargantext_Components_Charts_Options_ECharts.chart(chartOptions(l)) ]);
      };
  };                                                                                                                  
  var $dollar_ReadForeignHistoMetrics_19 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "count";
  }))(Simple_JSON.readArray(Simple_JSON.readNumber))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "dates";
  }))(Simple_JSON.readArray(Simple_JSON.readString))(Simple_JSON.readFieldsNil)()())()());
  var $dollar_ReadForeignChartMetrics_15 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "data";
  }))($dollar_ReadForeignHistoMetrics_19)(Simple_JSON.readFieldsNil)()());
  var $dollar_GenericHistoMetrics__16 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqHistoMetrics_18 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHistoMetrics__16)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "dates";
  }))(Data_Eq.eqArray(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "count";
  }))(Data_Eq.eqArray(Data_Eq.eqNumber)))))));
  var histoCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Nodes_Corpus_Chart_Common.metricsWithCacheLoadView($dollar_EqHistoMetrics_18)($dollar_ReadForeignChartMetrics_15)({
                      getMetricsHash: getMetricsHash,
                      handleResponse: handleResponse,
                      loaded: loaded,
                      mkRequest: mkRequest(v.session),
                      path: v.path,
                      reload: reload,
                      session: v.session
                  }));
              });
          };
      };
      return here.component("histo")(cpt);
  })();
  var histo = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(histoCpt)(props)([  ]);
  };
  exports["histo"] = histo;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Chart.Metrics"] = $PS["Gargantext.Components.Nodes.Corpus.Chart.Metrics"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Chart.Metrics"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unfoldable = $PS["Data.Unfoldable"];
  var Gargantext_Components_Charts_Options_Color = $PS["Gargantext.Components.Charts.Options.Color"];
  var Gargantext_Components_Charts_Options_Data = $PS["Gargantext.Components.Charts.Options.Data"];
  var Gargantext_Components_Charts_Options_ECharts = $PS["Gargantext.Components.Charts.Options.ECharts"];
  var Gargantext_Components_Charts_Options_Font = $PS["Gargantext.Components.Charts.Options.Font"];
  var Gargantext_Components_Charts_Options_Series = $PS["Gargantext.Components.Charts.Options.Series"];
  var Gargantext_Components_Charts_Options_Type = $PS["Gargantext.Components.Charts.Options.Type"];
  var Gargantext_Components_Nodes_Corpus_Chart_Common = $PS["Gargantext.Components.Nodes.Corpus.Chart.Common"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_CacheAPI = $PS["Gargantext.Utils.CacheAPI"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var scatterOptions = function (metrics$prime) {
      var metric2map = function (ds) {
          return Data_Map_Internal.fromFoldableWith(Gargantext_Types["$_OrdTermList_104"])(Data_Foldable.foldableArray)(Data_Semigroup.append(Data_Semigroup.semigroupArray))(Data_Functor.map(Data_Functor.functorArray)(function (v) {
              return new Data_Tuple.Tuple(v.cat, [ v ]);
          })(ds));
      };
      var map2series = function (ms) {
          var toSeries = function (v) {
              var toSerie = function (color$prime) {
                  return function (v1) {
                      return Gargantext_Components_Charts_Options_Data.dataSerie()({
                          name: v1.label,
                          itemStyle: Gargantext_Components_Charts_Options_Font.itemStyle()({
                              color: color$prime
                          }),
                          value: [ v1.x, v1.y ]
                      });
                  };
              };
              var color = (function () {
                  if (v.value0 instanceof Gargantext_Types.StopTerm) {
                      return Gargantext_Components_Charts_Options_Color.red;
                  };
                  if (v.value0 instanceof Gargantext_Types.MapTerm) {
                      return Gargantext_Components_Charts_Options_Color.green;
                  };
                  if (v.value0 instanceof Gargantext_Types.CandidateTerm) {
                      return Gargantext_Components_Charts_Options_Color.grey;
                  };
                  throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus.Chart.Metrics (line 83, column 15 - line 86, column 38): " + [ v.value0.constructor.name ]);
              })();
              return Gargantext_Components_Charts_Options_Series.seriesScatterD2()({
                  symbolSize: 5.0
              })(Data_Functor.map(Data_Functor.functorArray)(toSerie(color))(v.value1));
          };
          return Data_Functor.map(Data_Functor.functorArray)(toSeries)(Data_Map_Internal.toUnfoldable(Data_Unfoldable.unfoldableArray)(ms));
      };
      return new Gargantext_Components_Charts_Options_ECharts.Options({
          mainTitle: "Ngrams Selection Metrics",
          subTitle: "Local metrics (Inc/Exc, Spe/Gen), Global metrics (TFICF maillage)",
          xAxis: Gargantext_Components_Charts_Options_Type.xAxis()({
              min: -1 | 0
          }),
          yAxis: Gargantext_Components_Charts_Options_ECharts["yAxis'"]({
              position: "",
              show: true,
              min: -2 | 0
          }),
          series: map2series(metric2map(metrics$prime)),
          addZoom: false,
          tooltip: Gargantext_Components_Charts_Options_Font.mkTooltip()({
              formatter: Gargantext_Components_Charts_Options_Font.templateFormatter("{b0}")
          })
      });
  };
  var loaded = function (v) {
      return function (loaded$prime) {
          return Reactix_DOM_HTML.div({})([ Gargantext_Components_Charts_Options_ECharts.chart(scatterOptions(loaded$prime)) ]);
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Corpus.Chart.Metrics");
  var handleResponse = function (v) {
      return v.value.data;
  };
  var getMetricsHash = function (session) {
      return function (v) {
          return Gargantext_Sessions.get(Simple_JSON.readString)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.CorpusMetricsHash({
              listId: v.value1.listId,
              tabType: v.value1.tabType
          }, new Data_Maybe.Just(v.value1.corpusId)));
      };
  };
  var chartUrl = function (v) {
      return new Gargantext_Routes.CorpusMetrics({
          limit: v.limit,
          listId: v.listId,
          tabType: v.tabType
      }, new Data_Maybe.Just(v.corpusId));
  };
  var mkRequest = function (session) {
      return function (v) {
          return Gargantext_Utils_CacheAPI.makeGetRequest(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(chartUrl(v.value1));
      };
  };                                                                                                 
  var $dollar_ReadForeignMetric_17 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "cat";
  }))(Gargantext_Types["$_ReadForeignTermList_106"])(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "label";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "x";
  }))(Simple_JSON.readNumber)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "y";
  }))(Simple_JSON.readNumber)(Simple_JSON.readFieldsNil)()())()())()())()());
  var $dollar_ReadForeignMetrics_21 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "data";
  }))(Simple_JSON.readArray($dollar_ReadForeignMetric_17))(Simple_JSON.readFieldsNil)()());
  var $dollar_GenericMetric__14 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqMetric_16 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericMetric__14)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "y";
  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
      return "x";
  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
      return "label";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "cat";
  }))(Gargantext_Types["$_EqTermList_103"]))))));
  var metricsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Nodes_Corpus_Chart_Common.metricsWithCacheLoadView(Data_Eq.eqArray($dollar_EqMetric_16))($dollar_ReadForeignMetrics_21)({
                      getMetricsHash: getMetricsHash,
                      handleResponse: handleResponse,
                      loaded: loaded,
                      mkRequest: mkRequest(v.session),
                      path: v.path,
                      reload: reload,
                      session: v.session
                  }));
              });
          };
      };
      return here.component("etrics")(cpt);
  })();
  var metrics = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(metricsCpt)(props)([  ]);
  };
  exports["metrics"] = metrics;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Chart.Pie"] = $PS["Gargantext.Components.Nodes.Corpus.Chart.Pie"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Chart.Pie"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_Charts_Options_Color = $PS["Gargantext.Components.Charts.Options.Color"];
  var Gargantext_Components_Charts_Options_Data = $PS["Gargantext.Components.Charts.Options.Data"];
  var Gargantext_Components_Charts_Options_ECharts = $PS["Gargantext.Components.Charts.Options.ECharts"];
  var Gargantext_Components_Charts_Options_Font = $PS["Gargantext.Components.Charts.Options.Font"];
  var Gargantext_Components_Charts_Options_Series = $PS["Gargantext.Components.Charts.Options.Series"];
  var Gargantext_Components_Nodes_Corpus_Chart_Common = $PS["Gargantext.Components.Nodes.Corpus.Chart.Common"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_CacheAPI = $PS["Gargantext.Utils.CacheAPI"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Corpus.Chart.Pie");
  var handleResponse = function (v) {
      return v.value.data;
  };
  var getMetricsHash = function (session) {
      return function (v) {
          var mListId = (function () {
              var $29 = v.value1.listId === 0;
              if ($29) {
                  return Data_Maybe.Nothing.value;
              };
              return new Data_Maybe.Just(v.value1.listId);
          })();
          return Gargantext_Sessions.get(Simple_JSON.readString)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.ChartHash({
              chartType: Gargantext_Types.ChartPie.value,
              listId: mListId,
              tabType: v.value1.tabType
          }, new Data_Maybe.Just(v.value1.corpusId)));
      };
  };
  var chartUrl = function (v) {
      var mListId = (function () {
          var $37 = v.listId === 0;
          if ($37) {
              return Data_Maybe.Nothing.value;
          };
          return new Data_Maybe.Just(v.listId);
      })();
      return new Gargantext_Routes.Chart({
          chartType: Gargantext_Types.ChartPie.value,
          limit: v.limit,
          listId: mListId,
          tabType: v.tabType
      }, new Data_Maybe.Just(v.corpusId));
  };
  var mkRequest = function (session) {
      return function (v) {
          return Gargantext_Utils_CacheAPI.makeGetRequest(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(chartUrl(v.value1));
      };
  };
  var chartOptionsPie = function (v) {
      return new Gargantext_Components_Charts_Options_ECharts.Options({
          mainTitle: "Pie",
          subTitle: "Distribution by MapTerm",
          xAxis: Gargantext_Components_Charts_Options_ECharts["xAxis'"]([  ]),
          yAxis: Gargantext_Components_Charts_Options_ECharts["yAxis'"]({
              position: "",
              show: false,
              min: 0
          }),
          series: [ Gargantext_Components_Charts_Options_Series.seriesPieD1()({
              name: "Data"
          })(Data_Functor.map(Data_Functor.functorArray)(function (v1) {
              return Gargantext_Components_Charts_Options_Data.dataSerie()({
                  name: v1.value0,
                  value: v1.value1
              });
          })(Data_Array.zip(v.dates)(v.count))) ],
          addZoom: false,
          tooltip: Gargantext_Components_Charts_Options_Font.mkTooltip()({
              formatter: Gargantext_Components_Charts_Options_Font.templateFormatter("{b0}")
          })
      });
  };
  var loadedPie = function (v) {
      return function (loaded) {
          return Reactix_DOM_HTML.div({})([ Gargantext_Components_Charts_Options_ECharts.chart(chartOptionsPie(loaded)) ]);
      };
  };
  var chartOptionsBar = function (v) {
      return new Gargantext_Components_Charts_Options_ECharts.Options({
          mainTitle: "Bar",
          subTitle: "Count of MapTerm",
          xAxis: Gargantext_Components_Charts_Options_ECharts["xAxis'"](Data_Functor.map(Data_Functor.functorArray)(function (t) {
              return Data_String_Common.joinWith(" ")(Data_Functor.map(Data_Functor.functorArray)(Data_String_CodePoints.take(3))(Data_Array.take(3)(Data_Array.filter(function (s) {
                  return Data_String_CodePoints.length(s) > 3;
              })(Data_String_Common.split(" ")(t)))));
          })(v.dates)),
          yAxis: Gargantext_Components_Charts_Options_ECharts["yAxis'"]({
              position: "left",
              show: true,
              min: 0
          }),
          series: [ Gargantext_Components_Charts_Options_Series.seriesBarD1()({
              name: "Number of publication / year"
          })(Data_Functor.map(Data_Functor.functorArray)(function (n) {
              return Gargantext_Components_Charts_Options_Data.dataSerie()({
                  name: "",
                  itemStyle: Gargantext_Components_Charts_Options_Font.itemStyle()({
                      color: Gargantext_Components_Charts_Options_Color.blue
                  }),
                  value: n
              });
          })(v.count)) ],
          addZoom: false,
          tooltip: Gargantext_Components_Charts_Options_Font.mkTooltip()({
              formatter: Gargantext_Components_Charts_Options_Font.templateFormatter("{b0}")
          })
      });
  };
  var loadedBar = function (v) {
      return function (loaded) {
          return Reactix_DOM_HTML.div({})([ Gargantext_Components_Charts_Options_ECharts.chart(chartOptionsBar(loaded)) ]);
      };
  };                                                                                                                  
  var $dollar_ReadForeignHistoMetrics_23 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "count";
  }))(Simple_JSON.readArray(Simple_JSON.readNumber))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "dates";
  }))(Simple_JSON.readArray(Simple_JSON.readString))(Simple_JSON.readFieldsNil)()())()());
  var $dollar_ReadForeignChartMetrics_19 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "data";
  }))($dollar_ReadForeignHistoMetrics_23)(Simple_JSON.readFieldsNil)()());
  var $dollar_GenericHistoMetrics__20 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqHistoMetrics_22 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHistoMetrics__20)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "dates";
  }))(Data_Eq.eqArray(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "count";
  }))(Data_Eq.eqArray(Data_Eq.eqNumber)))))));
  var barCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Nodes_Corpus_Chart_Common.metricsWithCacheLoadView($dollar_EqHistoMetrics_22)($dollar_ReadForeignChartMetrics_19)({
                      getMetricsHash: getMetricsHash,
                      handleResponse: handleResponse,
                      loaded: loadedBar,
                      mkRequest: mkRequest(v.session),
                      path: v.path,
                      reload: reload,
                      session: v.session
                  }));
              });
          };
      };
      return here.component("bar")(cpt);
  })();
  var bar = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(barCpt)(props)([  ]);
  };
  var pieCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Nodes_Corpus_Chart_Common.metricsWithCacheLoadView($dollar_EqHistoMetrics_22)($dollar_ReadForeignChartMetrics_19)({
                      getMetricsHash: getMetricsHash,
                      handleResponse: handleResponse,
                      loaded: loadedPie,
                      mkRequest: mkRequest(v.session),
                      path: v.path,
                      reload: reload,
                      session: v.session
                  }));
              });
          };
      };
      return here.component("pie")(cpt);
  })();
  var pie = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(pieCpt)(props)([  ]);
  };
  exports["pie"] = pie;
  exports["bar"] = bar;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Chart.Tree"] = $PS["Gargantext.Components.Nodes.Corpus.Chart.Tree"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Chart.Tree"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_Charts_Options_ECharts = $PS["Gargantext.Components.Charts.Options.ECharts"];
  var Gargantext_Components_Charts_Options_Font = $PS["Gargantext.Components.Charts.Options.Font"];
  var Gargantext_Components_Charts_Options_Series = $PS["Gargantext.Components.Charts.Options.Series"];
  var Gargantext_Components_Nodes_Corpus_Chart_Common = $PS["Gargantext.Components.Nodes.Corpus.Chart.Common"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_CacheAPI = $PS["Gargantext.Utils.CacheAPI"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var scatterOptions = function (nodes) {
      return new Gargantext_Components_Charts_Options_ECharts.Options({
          mainTitle: "Tree",
          subTitle: "Tree Sub Title",
          xAxis: Gargantext_Components_Charts_Options_ECharts["xAxis'"]([  ]),
          yAxis: Gargantext_Components_Charts_Options_ECharts["yAxis'"]({
              position: "",
              show: false,
              min: 0
          }),
          series: [ Gargantext_Components_Charts_Options_Series.mkTree(Gargantext_Components_Charts_Options_Series.TreeMap.value)(nodes) ],
          addZoom: false,
          tooltip: Gargantext_Components_Charts_Options_Font.mkTooltip()({
              formatter: Gargantext_Components_Charts_Options_Font.templateFormatter("{b0}")
          })
      });
  };
  var loaded = function (v) {
      return function (loaded$prime) {
          return Reactix_DOM_HTML.div({})([ Gargantext_Components_Charts_Options_ECharts.chart(scatterOptions(loaded$prime)) ]);
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Corpus.Chart.Tree");
  var handleResponse = function (v) {
      return v.value.data;
  };
  var getMetricsHash = function (session) {
      return function (v) {
          var mListId = (function () {
              var $22 = v.value1.listId === 0;
              if ($22) {
                  return Data_Maybe.Nothing.value;
              };
              return new Data_Maybe.Just(v.value1.listId);
          })();
          return Gargantext_Sessions.get(Simple_JSON.readString)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.ChartHash({
              chartType: Gargantext_Types.ChartTree.value,
              listId: mListId,
              tabType: v.value1.tabType
          }, new Data_Maybe.Just(v.value1.corpusId)));
      };
  };
  var chartUrl = function (v) {
      var mListId = (function () {
          var $30 = v.listId === 0;
          if ($30) {
              return Data_Maybe.Nothing.value;
          };
          return new Data_Maybe.Just(v.listId);
      })();
      return new Gargantext_Routes.Chart({
          chartType: Gargantext_Types.ChartTree.value,
          limit: v.limit,
          listId: mListId,
          tabType: v.tabType
      }, new Data_Maybe.Just(v.corpusId));
  };
  var mkRequest = function (session) {
      return function (v) {
          return Gargantext_Utils_CacheAPI.makeGetRequest(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(chartUrl(v.value1));
      };
  };                                                                                                                                                     
  var $dollar_ReadForeignMetrics_11 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "data";
  }))(Simple_JSON.readArray(Gargantext_Components_Charts_Options_Series["$_ReadForeignTreeNode_17"]))(Simple_JSON.readFieldsNil)()());
  var treeCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Nodes_Corpus_Chart_Common.metricsWithCacheLoadView(Data_Eq.eqArray(Gargantext_Components_Charts_Options_Series["$_EqTreeNode_16"]))($dollar_ReadForeignMetrics_11)({
                      getMetricsHash: getMetricsHash,
                      handleResponse: handleResponse,
                      loaded: loaded,
                      mkRequest: mkRequest(v.session),
                      path: v.path,
                      reload: reload,
                      session: v.session
                  }));
              });
          };
      };
      return here.component("tree")(cpt);
  })();
  var tree = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(treeCpt)(props)([  ]);
  };
  exports["tree"] = tree;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Chart.Predefined"] = $PS["Gargantext.Components.Nodes.Corpus.Chart.Predefined"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Chart.Predefined"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Show_Generic = $PS["Data.Show.Generic"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_Nodes_Corpus_Chart_Histo = $PS["Gargantext.Components.Nodes.Corpus.Chart.Histo"];
  var Gargantext_Components_Nodes_Corpus_Chart_Metrics = $PS["Gargantext.Components.Nodes.Corpus.Chart.Metrics"];
  var Gargantext_Components_Nodes_Corpus_Chart_Pie = $PS["Gargantext.Components.Nodes.Corpus.Chart.Pie"];
  var Gargantext_Components_Nodes_Corpus_Chart_Tree = $PS["Gargantext.Components.Nodes.Corpus.Chart.Tree"];
  var Gargantext_Prelude = $PS["Gargantext.Prelude"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Simple_JSON_Generics_EnumSumRep = $PS["Simple.JSON.Generics.EnumSumRep"];                
  var CDocsHistogram = (function () {
      function CDocsHistogram() {

      };
      CDocsHistogram.value = new CDocsHistogram();
      return CDocsHistogram;
  })();
  var CAuthorsPie = (function () {
      function CAuthorsPie() {

      };
      CAuthorsPie.value = new CAuthorsPie();
      return CAuthorsPie;
  })();
  var CSourcesBar = (function () {
      function CSourcesBar() {

      };
      CSourcesBar.value = new CSourcesBar();
      return CSourcesBar;
  })();
  var CInstitutesTree = (function () {
      function CInstitutesTree() {

      };
      CInstitutesTree.value = new CInstitutesTree();
      return CInstitutesTree;
  })();
  var CTermsMetrics = (function () {
      function CTermsMetrics() {

      };
      CTermsMetrics.value = new CTermsMetrics();
      return CTermsMetrics;
  })();
  var render = function (v) {
      return function (v1) {
          if (v instanceof CDocsHistogram) {
              var path = {
                  corpusId: v1.corpusId,
                  listId: Data_Maybe.fromMaybe(0)(v1.listId),
                  limit: Data_Maybe.Nothing.value,
                  tabType: new Gargantext_Types.TabCorpus(Gargantext_Types.TabDocs.value)
              };
              return Gargantext_Components_Nodes_Corpus_Chart_Histo.histo({
                  path: path,
                  session: v1.session
              });
          };
          if (v instanceof CAuthorsPie) {
              var path = {
                  corpusId: v1.corpusId,
                  listId: Data_Maybe.fromMaybe(0)(v1.listId),
                  limit: Data_Maybe.Nothing.value,
                  tabType: new Gargantext_Types.TabCorpus(Gargantext_Types.TabNgramType.create(Gargantext_Types.modeTabType(Gargantext_Types.Authors.value)))
              };
              return Gargantext_Components_Nodes_Corpus_Chart_Pie.pie({
                  path: path,
                  session: v1.session
              });
          };
          if (v instanceof CInstitutesTree) {
              var path = {
                  corpusId: v1.corpusId,
                  limit: v1.limit,
                  listId: Data_Maybe.fromMaybe(0)(v1.listId),
                  tabType: new Gargantext_Types.TabCorpus(Gargantext_Types.TabNgramType.create(Gargantext_Types.modeTabType(Gargantext_Types.Institutes.value)))
              };
              return Gargantext_Components_Nodes_Corpus_Chart_Tree.tree({
                  path: path,
                  session: v1.session
              });
          };
          if (v instanceof CTermsMetrics) {
              var path = {
                  corpusId: v1.corpusId,
                  limit: v1.limit,
                  listId: Data_Maybe.fromMaybe(0)(v1.listId),
                  tabType: new Gargantext_Types.TabCorpus(Gargantext_Types.TabNgramType.create(Gargantext_Types.modeTabType(Gargantext_Types.Terms.value)))
              };
              return Gargantext_Components_Nodes_Corpus_Chart_Metrics.metrics({
                  path: path,
                  session: v1.session
              });
          };
          if (v instanceof CSourcesBar) {
              var path = {
                  corpusId: v1.corpusId,
                  limit: v1.limit,
                  listId: Data_Maybe.fromMaybe(0)(v1.listId),
                  tabType: new Gargantext_Types.TabCorpus(Gargantext_Types.TabNgramType.create(Gargantext_Types.modeTabType(Gargantext_Types.Sources.value)))
              };
              return Gargantext_Components_Nodes_Corpus_Chart_Metrics.metrics({
                  path: path,
                  session: v1.session
              });
          };
          throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus.Chart.Predefined (line 63, column 1 - line 63, column 56): " + [ v.constructor.name, v1.constructor.name ]);
      };
  };
  var allPredefinedCharts = [ CDocsHistogram.value, CAuthorsPie.value, CInstitutesTree.value, CSourcesBar.value ];
  var $dollar_ReadPredefinedChart_12 = new Gargantext_Prelude.Read(function (v) {
      if (v === "CDocsHistogram") {
          return new Data_Maybe.Just(CDocsHistogram.value);
      };
      if (v === "CAuthorsPie") {
          return new Data_Maybe.Just(CAuthorsPie.value);
      };
      if (v === "CSourcesBar") {
          return new Data_Maybe.Just(CSourcesBar.value);
      };
      if (v === "CInstitutesTree") {
          return new Data_Maybe.Just(CInstitutesTree.value);
      };
      if (v === "CTermsMetrics") {
          return new Data_Maybe.Just(CTermsMetrics.value);
      };
      return Data_Maybe.Nothing.value;
  });
  var $dollar_GenericPredefinedChart__6 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof CDocsHistogram) {
          return new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value);
      };
      if (x instanceof CAuthorsPie) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value));
      };
      if (x instanceof CSourcesBar) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value)));
      };
      if (x instanceof CInstitutesTree) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inl(Data_Generic_Rep.NoArguments.value))));
      };
      if (x instanceof CTermsMetrics) {
          return new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(new Data_Generic_Rep.Inr(Data_Generic_Rep.NoArguments.value))));
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus.Chart.Predefined (line 27, column 1 - line 27, column 42): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return CDocsHistogram.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && x.value0 instanceof Data_Generic_Rep.Inl) {
          return CAuthorsPie.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0 instanceof Data_Generic_Rep.Inl)) {
          return CSourcesBar.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inl))) {
          return CInstitutesTree.value;
      };
      if (x instanceof Data_Generic_Rep.Inr && (x.value0 instanceof Data_Generic_Rep.Inr && (x.value0.value0 instanceof Data_Generic_Rep.Inr && x.value0.value0.value0 instanceof Data_Generic_Rep.Inr))) {
          return CTermsMetrics.value;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus.Chart.Predefined (line 27, column 1 - line 27, column 42): " + [ x.constructor.name ]);
  });
  var $dollar_ReadForeignPredefinedChar_7 = new Simple_JSON.ReadForeign(Simple_JSON_Generics_EnumSumRep.enumSumRep($dollar_GenericPredefinedChart__6)(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "CDocsHistogram";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "CAuthorsPie";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "CSourcesBar";
  })))(Simple_JSON_Generics_EnumSumRep.sumEnumSumRep(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "CInstitutesTree";
  })))(Simple_JSON_Generics_EnumSumRep.constructorEnumSumRep(new Data_Symbol.IsSymbol(function () {
      return "CTermsMetrics";
  }))))))));
  var $dollar_ShowPredefinedChart_9 = new Data_Show.Show(Data_Show_Generic.genericShow($dollar_GenericPredefinedChart__6)(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "CDocsHistogram";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "CAuthorsPie";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "CSourcesBar";
  })))(Data_Show_Generic.genericShowSum(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "CInstitutesTree";
  })))(Data_Show_Generic.genericShowConstructor(Data_Show_Generic.genericShowArgsNoArguments)(new Data_Symbol.IsSymbol(function () {
      return "CTermsMetrics";
  }))))))));
  var $dollar_WriteForeignPredefinedCha_8 = new Simple_JSON.WriteForeign((function () {
      var $52 = Simple_JSON.writeImpl(Simple_JSON.writeForeignString);
      var $53 = Data_Show.show($dollar_ShowPredefinedChart_9);
      return function ($54) {
          return $52($53($54));
      };
  })());
  var $dollar_EqPredefinedChart_10 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof CDocsHistogram && y instanceof CDocsHistogram) {
              return true;
          };
          if (x instanceof CAuthorsPie && y instanceof CAuthorsPie) {
              return true;
          };
          if (x instanceof CSourcesBar && y instanceof CSourcesBar) {
              return true;
          };
          if (x instanceof CInstitutesTree && y instanceof CInstitutesTree) {
              return true;
          };
          if (x instanceof CTermsMetrics && y instanceof CTermsMetrics) {
              return true;
          };
          return false;
      };
  });
  exports["CDocsHistogram"] = CDocsHistogram;
  exports["allPredefinedCharts"] = allPredefinedCharts;
  exports["render"] = render;
  exports["$_ReadForeignPredefinedChar_7"] = $dollar_ReadForeignPredefinedChar_7;
  exports["$_WriteForeignPredefinedCha_8"] = $dollar_WriteForeignPredefinedCha_8;
  exports["$_ShowPredefinedChart_9"] = $dollar_ShowPredefinedChart_9;
  exports["$_EqPredefinedChart_10"] = $dollar_EqPredefinedChart_10;
  exports["$_ReadPredefinedChart_12"] = $dollar_ReadPredefinedChart_12;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Dashboard.Types"] = $PS["Gargantext.Components.Nodes.Dashboard.Types"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Dashboard.Types"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Monad_Except_Trans = $PS["Control.Monad.Except.Trans"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Identity = $PS["Data.Identity"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_Nodes_Corpus_Chart_Predefined = $PS["Gargantext.Components.Nodes.Corpus.Chart.Predefined"];
  var Gargantext_Components_Nodes_Types = $PS["Gargantext.Components.Nodes.Types"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Simple_JSON = $PS["Simple.JSON"];                
  var Hyperdata = function (x) {
      return x;
  };
  var $dollar_WriteForeignHyperdata_12 = Simple_JSON.recordWriteForeign()(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "charts";
  }))(Simple_JSON.writeForeignArray(Gargantext_Components_Nodes_Corpus_Chart_Predefined["$_WriteForeignPredefinedCha_8"]))(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "fields";
  }))(Gargantext_Components_Nodes_Types["$_WriteForeignFTFieldList_38"])(Simple_JSON.consWriteForeignFields(new Data_Symbol.IsSymbol(function () {
      return "preferences";
  }))(Simple_JSON.writeForeignMaybe(Simple_JSON.writeForeignString))(Simple_JSON.nilWriteForeignFields)()()())()()())()()());
  var saveDashboard = function (v) {
      return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Sessions.put($dollar_WriteForeignHyperdata_12)(Simple_JSON.readInt)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(v.nodeId), ""))(v.hyperdata))(function (id_) {
          return Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Unit.unit);
      });
  }; 
  var $dollar_ReadForeignHyperdata_11 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "charts";
  }))(Simple_JSON.readArray(Gargantext_Components_Nodes_Corpus_Chart_Predefined["$_ReadForeignPredefinedChar_7"]))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "fields";
  }))(Gargantext_Components_Nodes_Types["$_ReadForeignFTFieldList_37"])(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "preferences";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsNil)()())()())()());
  var $dollar_ReadForeignDashboardData_16 = new Simple_JSON.ReadForeign(function (f) {
      return Control_Bind.bind(Control_Monad_Except_Trans.bindExceptT(Data_Identity.monadIdentity))(Simple_JSON.readImpl(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "hyperdata";
      }))($dollar_ReadForeignHyperdata_11)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "id";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
          return "parent_id";
      }))(Simple_JSON.readInt)(Simple_JSON.readFieldsNil)()())()())()()))(f))(function (v) {
          return Control_Applicative.pure(Control_Monad_Except_Trans.applicativeExceptT(Data_Identity.monadIdentity))({
              id: v.id,
              hyperdata: v.hyperdata,
              parentId: v.parent_id
          });
      });
  });
  var loadDashboard$prime = function (v) {
      return Gargantext_Sessions.get($dollar_ReadForeignDashboardData_16)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(v.nodeId), ""));
  };
  var loadDashboardWithReload = function (v) {
      return loadDashboard$prime({
          nodeId: v.nodeId,
          session: v.session
      });
  }; 
  var $dollar_GenericHyperdata__9 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericDashboardData__14 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqHyperdata_13 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHyperdata__9)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "preferences";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "fields";
  }))(Gargantext_Components_Nodes_Types["$_EqFTFieldList_36"]))()(new Data_Symbol.IsSymbol(function () {
      return "charts";
  }))(Data_Eq.eqArray(Gargantext_Components_Nodes_Corpus_Chart_Predefined["$_EqPredefinedChart_10"])))))));
  var $dollar_EqDashboardData_18 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericDashboardData__14)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "parentId";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "hyperdata";
  }))($dollar_EqHyperdata_13))))));
  exports["Hyperdata"] = Hyperdata;
  exports["loadDashboardWithReload"] = loadDashboardWithReload;
  exports["saveDashboard"] = saveDashboard;
  exports["$_EqDashboardData_18"] = $dollar_EqDashboardData_18;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Dashboard"] = $PS["Gargantext.Components.Nodes.Corpus.Dashboard"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Dashboard"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_Components_Nodes_Corpus = $PS["Gargantext.Components.Nodes.Corpus"];
  var Gargantext_Components_Nodes_Corpus_Chart_Predefined = $PS["Gargantext.Components.Nodes.Corpus.Chart.Predefined"];
  var Gargantext_Components_Nodes_Dashboard_Types = $PS["Gargantext.Components.Nodes.Dashboard.Types"];
  var Gargantext_Components_Nodes_Types = $PS["Gargantext.Components.Nodes.Types"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Prelude = $PS["Gargantext.Prelude"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Corpus.Dashboard");
  var renderChartCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var params = {
                  corpusId: v.corpusId,
                  limit: new Data_Maybe.Just(1000),
                  listId: new Data_Maybe.Just(v.defaultListId),
                  session: v.session
              };
              var option = function (pc) {
                  return Reactix_DOM_HTML.option({
                      value: Data_Show.show(Gargantext_Components_Nodes_Corpus_Chart_Predefined["$_ShowPredefinedChart_9"])(pc)
                  })([ Reactix_DOM_HTML.text(Data_Show.show(Gargantext_Components_Nodes_Corpus_Chart_Predefined["$_ShowPredefinedChart_9"])(pc)) ]);
              };
              var onSelectChange = function (e) {
                  var value = Reactix_SyntheticEvent.unsafeEventValue(e);
                  return v.onChange(Data_Maybe.fromMaybe(Gargantext_Components_Nodes_Corpus_Chart_Predefined.CDocsHistogram.value)(Gargantext_Prelude.read(Gargantext_Components_Nodes_Corpus_Chart_Predefined["$_ReadPredefinedChart_12"])(value)));
              };
              var onRemoveClick = function (v2) {
                  return v.onRemove(Data_Unit.unit);
              };
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "row chart card"
              })([ Reactix_DOM_HTML.div({
                  className: "card-header"
              })([ Reactix_DOM_HTML.div({
                  className: "row"
              })([ Reactix_DOM_HTML.div({
                  className: "col-2"
              })([ Gargantext_Utils_Reactix.select({
                  defaultValue: Data_Show.show(Gargantext_Components_Nodes_Corpus_Chart_Predefined["$_ShowPredefinedChart_9"])(v.chart),
                  on: {
                      change: onSelectChange
                  }
              })(Data_Functor.map(Data_Functor.functorArray)(option)(Gargantext_Components_Nodes_Corpus_Chart_Predefined.allPredefinedCharts)) ]), Reactix_DOM_HTML.div({
                  className: "col-9"
              })([  ]), Reactix_DOM_HTML.div({
                  className: "col-1"
              })([ Reactix_DOM_HTML.span({
                  className: "btn btn-danger",
                  on: {
                      click: onRemoveClick
                  }
              })([ Reactix_DOM_HTML.span({
                  className: "fa fa-trash"
              })([  ]) ]) ]) ]) ]), Reactix_DOM_HTML.div({
                  className: "card-body"
              })([ Reactix_DOM_HTML.div({
                  className: "row"
              })([ Reactix_DOM_HTML.div({
                  className: "col-12 chart"
              })([ Gargantext_Components_Nodes_Corpus_Chart_Predefined.render(v.chart)(params) ]) ]) ]) ]));
          };
      };
      return here.component("renderChart")(cpt);
  })();
  var renderChart = Reactix_React.createElement(Reactix_React.componentIsComponent)(renderChartCpt);
  var dashboardCodeEditorCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var saveEnabled = function (fs) {
                  return function (fsS) {
                      var $32 = Data_Eq.eq(Gargantext_Components_Nodes_Types["$_EqFTFieldsWithIndex_21"])(fs)(fsS);
                      if ($32) {
                          return "disabled";
                      };
                      return "enabled";
                  };
              };
              var onClickSave = function (v2) {
                  return function (v3) {
                      return function __do() {
                          here.log("saving (TODO)")();
                          return v.onChange(Gargantext_Components_Nodes_Types.FTFieldList(Data_Functor.map(Data_List_Types.functorList)(function (v4) {
                              return v4.ftField;
                          })(v2)))();
                      };
                  };
              };
              var onClickAddField = function (fieldsS) {
                  return function (v2) {
                      return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (v3) {
                          return Gargantext_Components_Nodes_Types.FTFieldsWithIndex(Data_List.snoc(v3)({
                              idx: Data_List.length(v3),
                              ftField: Gargantext_Components_Nodes_Types.defaultField
                          }));
                      })(fieldsS);
                  };
              };
              var fieldsWithIndex = Gargantext_Components_Nodes_Types.FTFieldsWithIndex(Data_List.mapWithIndex(function (idx) {
                  return function (ftField) {
                      return {
                          idx: idx,
                          ftField: ftField
                      };
                  };
              })(v.fields));
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(fieldsWithIndex))(function (fieldsS) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Nodes_Types["$_EqFTFieldsWithIndex_21"]))(fieldsS))(function (fields$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Reactix_Hooks.useRef(fields$prime))(function (fieldsRef) {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect1'"](v.fields)((function () {
                              var $36 = Data_Eq.eq(Gargantext_Components_Nodes_Types["$_EqFTFieldsWithIndex_21"])(Reactix_React.readRef(fieldsRef))(fields$prime);
                              if ($36) {
                                  return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                              };
                              return function __do() {
                                  Reactix_React.setRef(fieldsRef)(fields$prime)();
                                  return Toestand_Classes.write_(Toestand_Boxes.writeBox)(fieldsWithIndex)(fieldsS)();
                              };
                          })()))(function () {
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ Reactix_DOM_HTML.div({
                                  className: "row"
                              })([ Reactix_DOM_HTML.div({
                                  className: "btn btn-primary " + saveEnabled(fieldsWithIndex)(fields$prime),
                                  on: {
                                      click: onClickSave(fields$prime)
                                  }
                              })([ Reactix_DOM_HTML.span({
                                  className: "fa fa-floppy-o"
                              })([  ]) ]) ]), Reactix_DOM_HTML.div({
                                  className: "row"
                              })([ Reactix_DOM_HTML.div({
                                  className: "col-12"
                              })([ Gargantext_Components_Nodes_Corpus.fieldsCodeEditor({
                                  fields: fieldsS,
                                  nodeId: v.nodeId,
                                  session: v.session
                              })([  ]) ]) ]), Reactix_DOM_HTML.div({
                                  className: "row"
                              })([ Reactix_DOM_HTML.div({
                                  className: "btn btn-primary",
                                  on: {
                                      click: onClickAddField(fieldsS)
                                  }
                              })([ Reactix_DOM_HTML.span({
                                  className: "fa fa-plus"
                              })([  ]) ]) ]) ]));
                          });
                      });
                  });
              });
          };
      };
      return here.component("dashboardCodeEditor")(cpt);
  })();
  var dashboardCodeEditor = Reactix_React.createElement(Reactix_React.componentIsComponent)(dashboardCodeEditorCpt);
  var dashboardLayoutLoadedCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var chartIdx = function (idx) {
                  return function (chart) {
                      var onRemove = function (v2) {
                          return v.onChange({
                              charts: Data_Maybe.fromMaybe(v.charts)(Data_Array.deleteAt(idx)(v.charts)),
                              fields: v.fields
                          });
                      };
                      var onChangeChart = function (c) {
                          return v.onChange({
                              charts: Data_Maybe.fromMaybe(v.charts)(Data_Array.modifyAt(idx)(function (v2) {
                                  return c;
                              })(v.charts)),
                              fields: v.fields
                          });
                      };
                      return renderChart({
                          chart: chart,
                          corpusId: v.corpusId,
                          defaultListId: v.defaultListId,
                          onChange: onChangeChart,
                          onRemove: onRemove,
                          session: v.session
                      })([  ]);
                  };
              };
              var chartsEls = Data_Array.mapWithIndex(chartIdx)(v.charts);
              var addNew = (function () {
                  var onClickAddChart = function (v2) {
                      return v.onChange({
                          charts: Data_Array.cons(Gargantext_Components_Nodes_Corpus_Chart_Predefined.CDocsHistogram.value)(v.charts),
                          fields: v.fields
                      });
                  };
                  return Reactix_DOM_HTML.div({
                      className: "row"
                  })([ Reactix_DOM_HTML.span({
                      className: "btn btn-primary",
                      on: {
                          click: onClickAddChart
                      }
                  })([ Reactix_DOM_HTML.span({
                      className: "fa fa-plus"
                  })([  ]) ]) ]);
              })();
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([ dashboardCodeEditor({
                  fields: v.fields,
                  nodeId: v.nodeId,
                  onChange: function (fs) {
                      return v.onChange({
                          charts: v.charts,
                          fields: fs
                      });
                  },
                  session: v.session
              })([  ]), Reactix_DOM_HTML.div({
                  className: "row"
              })([ Reactix_DOM_HTML.div({
                  className: "col-12"
              })(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ Reactix_DOM_HTML.h1({})([ Reactix_DOM_HTML.text("Board") ]), Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.text("Summary of all your charts here") ]) ])(Data_Semigroup.append(Data_Semigroup.semigroupArray)(chartsEls)([ addNew ]))) ]) ]));
          };
      };
      return here.component("dashboardLayoutLoaded")(cpt);
  })();
  var dashboardLayoutLoaded = Reactix_React.createElement(Reactix_React.componentIsComponent)(dashboardLayoutLoadedCpt);
  var dashboardLayoutWithKeyCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onChange = function (nodeId$prime) {
                  return function (reload) {
                      return function (v2) {
                          return function (v3) {
                              return Effect_Aff.launchAff_(Control_Bind.discard(Control_Bind.discardUnit)(Effect_Aff.bindAff)(Gargantext_Components_Nodes_Dashboard_Types.saveDashboard({
                                  hyperdata: Gargantext_Components_Nodes_Dashboard_Types.Hyperdata({
                                      charts: v3.charts,
                                      fields: v3.fields,
                                      preferences: v2.preferences
                                  }),
                                  nodeId: nodeId$prime,
                                  session: v.session
                              }))(function () {
                                  return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(reload));
                              }));
                          };
                      };
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(reload))(function (reload$prime) {
                      return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "session";
                      }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                          return "reload";
                      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                          return "nodeId";
                      }))(Data_Eq.eqInt)))(Gargantext_Components_Nodes_Dashboard_Types["$_EqDashboardData_18"])({
                          nodeId: v.nodeId,
                          reload: reload$prime,
                          session: v.session
                      })(Gargantext_Components_Nodes_Dashboard_Types.loadDashboardWithReload)(function (v2) {
                          return dashboardLayoutLoaded({
                              charts: v2.hyperdata.charts,
                              corpusId: v2.parentId,
                              defaultListId: 0,
                              fields: v2.hyperdata.fields,
                              nodeId: v.nodeId,
                              onChange: onChange(v.nodeId)(reload)(v2.hyperdata),
                              session: v.session
                          })([  ]);
                      });
                  });
              });
          };
      };
      return here.component("dashboardLayoutWithKey")(cpt);
  })();
  var dashboardLayoutWithKey = Reactix_React.createElement(Reactix_React.componentIsComponent)(dashboardLayoutWithKeyCpt);
  var dashboardLayoutCpt = (function () {
      var cpt = function (v) {
          return function (content) {
              var key = Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(Gargantext_Sessions_Types.sessionId(v.session)) + ("-" + Data_Show.show(Data_Show.showInt)(v.nodeId));
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(dashboardLayoutWithKey({
                  key: key,
                  nodeId: v.nodeId,
                  session: v.session
              })(content));
          };
      };
      return here.component("dashboardLayout")(cpt);
  })();
  var dashboardLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(dashboardLayoutCpt);
  exports["dashboardLayout"] = dashboardLayout;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Document.Types"] = $PS["Gargantext.Components.Nodes.Corpus.Document.Types"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Document.Types"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_NgramsTable_Core = $PS["Gargantext.Components.NgramsTable.Core"];
  var Simple_JSON = $PS["Simple.JSON"];
  var initialState = function (v) {
      return {
          ngramsLocalPatch: Data_Monoid.mempty(Data_Monoid.monoidRecord()(Data_Monoid.monoidRecordCons(new Data_Symbol.IsSymbol(function () {
              return "ngramsPatches";
          }))(Gargantext_Components_NgramsTable_Core["$_MonoidPatchMap_203"](Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])(Gargantext_Components_NgramsTable_Core["$_MonoidNgramsPatch_158"]))()(Data_Monoid.monoidRecordNil))),
          ngramsStagePatch: Data_Monoid.mempty(Data_Monoid.monoidRecord()(Data_Monoid.monoidRecordCons(new Data_Symbol.IsSymbol(function () {
              return "ngramsPatches";
          }))(Gargantext_Components_NgramsTable_Core["$_MonoidPatchMap_203"](Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])(Gargantext_Components_NgramsTable_Core["$_MonoidNgramsPatch_158"]))()(Data_Monoid.monoidRecordNil))),
          ngramsValidPatch: Data_Monoid.mempty(Data_Monoid.monoidRecord()(Data_Monoid.monoidRecordCons(new Data_Symbol.IsSymbol(function () {
              return "ngramsPatches";
          }))(Gargantext_Components_NgramsTable_Core["$_MonoidPatchMap_203"](Gargantext_Components_NgramsTable_Core["$_OrdNgramsTerm_165"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])(Gargantext_Components_NgramsTable_Core["$_MonoidNgramsPatch_158"]))()(Data_Monoid.monoidRecordNil))),
          ngramsVersion: v.loaded.ngramsTable.version
      };
  };                                                                 
  var $dollar_ReadForeignDocument_19 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "abstract";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "authors";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "bdd";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "doi";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "institutes";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "language_iso2";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "publication_date";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "publication_day";
  }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "publication_month";
  }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "publication_year";
  }))(Simple_JSON.readMaybe(Simple_JSON.readInt))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "source";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "uniqId";
  }))(Simple_JSON.readMaybe(Simple_JSON.readString))(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()())()())()())()())()())()())()());
  var $dollar_GenericDocument__17 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });   
  var $dollar_EqDocument_21 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericDocument__17)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "uniqId";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "source";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "publication_year";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "publication_month";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "publication_day";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
      return "publication_date";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "language_iso2";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "institutes";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "doi";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "bdd";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "authors";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))()(new Data_Symbol.IsSymbol(function () {
      return "abstract";
  }))(Data_Maybe.eqMaybe(Data_Eq.eqString)))))));
  exports["initialState"] = initialState;
  exports["$_ReadForeignDocument_19"] = $dollar_ReadForeignDocument_19;
  exports["$_EqDocument_21"] = $dollar_EqDocument_21;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Document"] = $PS["Gargantext.Components.Nodes.Corpus.Document"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Document"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_Annotation_AnnotatedField = $PS["Gargantext.Components.Annotation.AnnotatedField"];
  var Gargantext_Components_AutoUpdate = $PS["Gargantext.Components.AutoUpdate"];
  var Gargantext_Components_NgramsTable_Core = $PS["Gargantext.Components.NgramsTable.Core"];
  var Gargantext_Components_Node = $PS["Gargantext.Components.Node"];
  var Gargantext_Components_Nodes_Corpus_Document_Types = $PS["Gargantext.Components.Nodes.Corpus.Document.Types"];
  var Gargantext_Components_Search = $PS["Gargantext.Components.Search"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils = $PS["Gargantext.Utils"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];                
  var publicationDate = function (v) {
      if (v.publication_year instanceof Data_Maybe.Nothing) {
          return "";
      };
      if (v.publication_year instanceof Data_Maybe.Just && v.publication_month instanceof Data_Maybe.Nothing) {
          return Gargantext_Utils.zeroPad(2)(v.publication_year.value0);
      };
      if (v.publication_year instanceof Data_Maybe.Just && (v.publication_month instanceof Data_Maybe.Just && v.publication_day instanceof Data_Maybe.Nothing)) {
          return Gargantext_Utils.zeroPad(2)(v.publication_year.value0) + ("-" + Gargantext_Utils.zeroPad(2)(v.publication_month.value0));
      };
      if (v.publication_year instanceof Data_Maybe.Just && (v.publication_month instanceof Data_Maybe.Just && v.publication_day instanceof Data_Maybe.Just)) {
          return Gargantext_Utils.zeroPad(2)(v.publication_year.value0) + ("-" + (Gargantext_Utils.zeroPad(2)(v.publication_month.value0) + ("-" + Gargantext_Utils.zeroPad(2)(v.publication_day.value0))));
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus.Document (line 34, column 1 - line 34, column 38): " + [ v.constructor.name ]);
  };
  var loadDocument = function (session) {
      return function (nodeId) {
          return Gargantext_Sessions.get(Gargantext_Components_Node["$_ReadForeignNodePoly_8"](Gargantext_Components_Nodes_Corpus_Document_Types["$_ReadForeignDocument_19"]))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(nodeId), ""));
      };
  };
  var loadData = function (v) {
      return Control_Bind.bind(Effect_Aff.bindAff)(loadDocument(v.session)(v.nodeId))(function (document) {
          return Control_Bind.bind(Effect_Aff.bindAff)(Gargantext_Components_NgramsTable_Core.loadNgramsTable({
              listIds: v.listIds,
              nodeId: v.nodeId,
              params: {
                  offset: 0,
                  limit: 100,
                  orderBy: Data_Maybe.Nothing.value,
                  searchType: Gargantext_Components_Search.SearchDoc.value
              },
              scoreType: Gargantext_Types.Occurrences.value,
              searchQuery: "",
              session: v.session,
              tabType: v.tabType,
              termListFilter: Data_Maybe.Nothing.value,
              termSizeFilter: Data_Maybe.Nothing.value
          }))(function (ngramsTable) {
              return Control_Applicative.pure(Effect_Aff.applicativeAff)({
                  document: document,
                  ngramsTable: ngramsTable
              });
          });
      });
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Corpus.Document");
  var docViewCpt = (function () {
      var cpt = function (v) {
          return function (_children) {
              var text$prime = function (x) {
                  return Reactix_DOM_HTML.span({
                      className: "list-group-item-text"
                  })([ Reactix_DOM_HTML.text(Data_Maybe.fromMaybe("Nothing")(x)) ]);
              };
              var li$prime = Reactix_DOM_HTML.li({
                  className: "list-group-item justify-content-between"
              });
              var dispatch = Gargantext_Components_NgramsTable_Core.coreDispatch(v.path)(v.state);
              var badgeLi = function (s) {
                  return Reactix_DOM_HTML.span({
                      className: "list-group-item-heading"
                  })([ Reactix_DOM_HTML.span({
                      className: "badge-container"
                  })([ Reactix_DOM_HTML.span({
                      className: "badge badge-default badge-pill"
                  })([ Reactix_DOM_HTML.text(s) ]) ]) ]);
              };
              var badge = function (s) {
                  return Reactix_DOM_HTML.span({
                      className: "badge badge-default badge-pill"
                  })([ Reactix_DOM_HTML.text(s) ]);
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsVersion";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsValidPatch";
              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsPatches";
              }))(Gargantext_Components_NgramsTable_Core["$_EqPatchMap_153"](Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])))))()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsStagePatch";
              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsPatches";
              }))(Gargantext_Components_NgramsTable_Core["$_EqPatchMap_153"](Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])))))()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsLocalPatch";
              }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsPatches";
              }))(Gargantext_Components_NgramsTable_Core["$_EqPatchMap_153"](Gargantext_Components_NgramsTable_Core["$_EqNgramsTerm_164"])(Gargantext_Components_NgramsTable_Core["$_EqNgramsPatch_157"])))))))(v.state))(function (v1) {
                  var setTermListOrAddA = function (ngram) {
                      return function (v2) {
                          if (v2 instanceof Data_Maybe.Nothing) {
                              return Gargantext_Components_NgramsTable_Core.addNewNgramA(ngram);
                          };
                          if (v2 instanceof Data_Maybe.Just) {
                              var $65 = Gargantext_Components_NgramsTable_Core.setTermListA(ngram);
                              var $66 = Gargantext_Components_NgramsTable_Core.replace(Gargantext_Types["$_EqTermList_103"])(v2.value0);
                              return function ($67) {
                                  return $65($66($67));
                              };
                          };
                          throw new Error("Failed pattern match at Gargantext.Components.Nodes.Corpus.Document (line 80, column 9 - line 80, column 68): " + [ ngram.constructor.name, v2.constructor.name ]);
                      };
                  };
                  var ngrams = Gargantext_Components_NgramsTable_Core.applyNgramsPatches(v1)(v.loaded.ngramsTable.data);
                  var setTermList = function (ngram) {
                      return function (mOldList) {
                          var $68 = setTermListOrAddA(Gargantext_Components_NgramsTable_Core.findNgramRoot(ngrams)(ngram))(mOldList);
                          return function ($69) {
                              return dispatch($68($69));
                          };
                      };
                  };
                  var annotate = function (text) {
                      return Gargantext_Components_Annotation_AnnotatedField.annotatedField({
                          ngrams: ngrams,
                          setTermList: setTermList,
                          text: text
                      });
                  };
                  var afterSync = function (v2) {
                      return Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Unit.unit);
                  };
                  var autoUpd = (function () {
                      if (false) {
                          return [ Gargantext_Components_AutoUpdate.autoUpdate({
                              duration: 5000,
                              effect: dispatch(new Gargantext_Components_NgramsTable_Core.Synchronize({
                                  afterSync: afterSync
                              }))
                          }) ];
                      };
                      return [  ];
                  })();
                  var syncResetBtns = [ Gargantext_Components_NgramsTable_Core.syncResetButtons({
                      afterSync: afterSync,
                      ngramsLocalPatch: v1.ngramsLocalPatch,
                      performAction: dispatch
                  }) ];
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})(Data_Semigroup.append(Data_Semigroup.semigroupArray)(autoUpd)(Data_Semigroup.append(Data_Semigroup.semigroupArray)(syncResetBtns)([ Reactix_DOM_HTML.div({
                      className: "corpus-doc-view container1"
                  })([ Gargantext_Utils_Reactix.row([ Gargantext_Utils_Reactix.col(12)([ Reactix_DOM_HTML.h4({})([ Reactix_DOM_HTML.span({})([ badge("title"), annotate(v.loaded.document.hyperdata.title)([  ]) ]) ]), Reactix_DOM_HTML.ul({
                      className: "list-group"
                  })([ li$prime([ badgeLi("source"), text$prime(v.loaded.document.hyperdata.source) ]), li$prime([ badgeLi("authors"), text$prime(v.loaded.document.hyperdata.authors) ]), li$prime([ badgeLi("date"), Reactix_DOM_HTML.text(publicationDate(v.loaded.document.hyperdata)) ]) ]), Reactix_DOM_HTML.span({})([ badge("abstract"), annotate(v["loaded"]["document"]["hyperdata"]["abstract"])([  ]) ]), Reactix_DOM_HTML.div({
                      className: "jumbotron"
                  })([ Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.text("Empty Full Text") ]) ]) ]) ]) ]) ]))));
              });
          };
      };
      return here.component("docView")(cpt);
  })();
  var docView = Reactix_React.createElement(Reactix_React.componentIsComponent)(docViewCpt);
  var docViewWrapperCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_Nodes_Corpus_Document_Types.initialState({
                  loaded: v.loaded
              })))(function (state) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(docView(Record.merge()()(v)({
                      state: state
                  }))([  ]));
              });
          };
      };
      return here.component("docViewWrapper")(cpt);
  })();
  var docViewWrapper = Reactix_React.createElement(Reactix_React.componentIsComponent)(docViewWrapperCpt);
  var documentLayoutWithKeyCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var tabType = new Gargantext_Types.TabDocument(new Gargantext_Types.TabNgramType(Gargantext_Types.CTabTerms.value));
              var path = {
                  listIds: [ v.listId ],
                  mCorpusId: v.mCorpusId,
                  nodeId: v.nodeId,
                  session: v.session,
                  tabType: tabType
              };
              return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "tabType";
              }))(Gargantext_Types["$_EqTabType_148"]))()(new Data_Symbol.IsSymbol(function () {
                  return "session";
              }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                  return "nodeId";
              }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                  return "mCorpusId";
              }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                  return "listIds";
              }))(Data_Eq.eqArray(Data_Eq.eqInt))))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "ngramsTable";
              }))(Gargantext_Components_NgramsTable_Core["$_EqVersioned_143"](Gargantext_Components_NgramsTable_Core["$_EqNgramsTable_184"])))()(new Data_Symbol.IsSymbol(function () {
                  return "document";
              }))(Gargantext_Components_Node["$_EqNodePoly_7"](Gargantext_Components_Nodes_Corpus_Document_Types["$_EqDocument_21"]))))(path)(loadData)(function (loaded) {
                  return docViewWrapper({
                      loaded: loaded,
                      path: path
                  })([  ]);
              });
          };
      };
      return here.component("documentLayoutWithKey")(cpt);
  })();
  var documentLayoutWithKey = Reactix_React.createElement(Reactix_React.componentIsComponent)(documentLayoutWithKeyCpt);
  var documentLayoutCpt = (function () {
      var cpt = function (v) {
          return function (children) {
              var key = Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(Gargantext_Sessions_Types.sessionId(v.session)) + ("-" + Data_Show.show(Data_Show.showInt)(v.nodeId));
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(documentLayoutWithKey({
                  key: key,
                  listId: v.listId,
                  mCorpusId: v.mCorpusId,
                  nodeId: v.nodeId,
                  session: v.session
              })(children));
          };
      };
      return here.component("documentLayout")(cpt);
  })();
  var documentLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(documentLayoutCpt);
  var documentMainLayoutCpt = (function () {
      var cpt = function (props) {
          return function (v) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Utils_Reactix.row([ Gargantext_Utils_Reactix.col(10)([ documentLayout(props)([  ]) ]) ]));
          };
      };
      return here.component("documentMainLayout")(cpt);
  })();
  var documentMainLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(documentMainLayoutCpt);
  exports["documentMainLayout"] = documentMainLayout;
  exports["documentLayout"] = documentLayout;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Phylo"] = $PS["Gargantext.Components.Nodes.Corpus.Phylo"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Phylo"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Corpus.Phylo");
  var phyloLayoutCpt = (function () {
      var cpt = function (v) {
          return function (content) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.h1({})([ Reactix_DOM_HTML.text("Hello Phylo") ]));
          };
      };
      return here.component("phyloLayout")(cpt);
  })();
  var phyloLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(phyloLayoutCpt);
  exports["phyloLayout"] = phyloLayout;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.File"] = $PS["Gargantext.Components.Nodes.File"] || {};
  var exports = $PS["Gargantext.Components.Nodes.File"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.File");
  var fileLayoutLoadedCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var href = Gargantext_Ends.toUrl(Gargantext_Sessions_Types["$_ToUrlSessionString_37"])(v.session)("node/" + (Data_Show.show(Data_Show.showInt)(v.nodeId) + "/file/download"));
              return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect'"](here.log(v.loaded.hyperdata)))(function () {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "col-md-12"
                  })([ Reactix_DOM_HTML.div({
                      className: "row"
                  })([ Reactix_DOM_HTML.h2({})([ Reactix_DOM_HTML.text(v.loaded.hyperdata.name) ]) ]), Reactix_DOM_HTML.div({
                      className: "row"
                  })([ Reactix_DOM_HTML.div({
                      className: "btn btn-primary"
                  })([ Reactix_DOM_HTML.a({
                      href: href,
                      target: "_blank"
                  })([ Reactix_DOM_HTML.text("Download") ]) ]) ]) ]));
              });
          };
      };
      return here.component("fileLayoutLoaded")(cpt);
  })();
  var fileLayoutLoaded = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(fileLayoutLoadedCpt)(props)([  ]);
  };
  var $dollar_ReadForeignHyperdataFile_10 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "mime";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "path";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()());
  var $dollar_ReadForeignFile_14 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "date";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "hyperdata";
  }))($dollar_ReadForeignHyperdataFile_10)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Simple_JSON.readInt)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()())()());
  var loadFile = function (session) {
      return function (nodeId) {
          return Gargantext_Sessions.get($dollar_ReadForeignFile_14)(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(nodeId), ""));
      };
  }; 
  var $dollar_GenericHyperdataFile__8 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_GenericFile__12 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqHyperdataFile_11 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHyperdataFile__8)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "path";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "mime";
  }))(Data_Eq.eqString))))));
  var $dollar_EqFile_15 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericFile__12)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "id";
  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
      return "hyperdata";
  }))($dollar_EqHyperdataFile_11))()(new Data_Symbol.IsSymbol(function () {
      return "date";
  }))(Data_Eq.eqString))))));
  var fileLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onLoad = function (loaded) {
                  return fileLayoutLoaded({
                      loaded: loaded,
                      nodeId: v.nodeId,
                      session: v.session
                  });
              };
              var key = Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(Gargantext_Sessions_Types.sessionId(v.session)) + ("-" + Data_Show.show(Data_Show.showInt)(v.nodeId));
              return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqInt)($dollar_EqFile_15)(v.nodeId)(loadFile(v.session))(onLoad);
          };
      };
      return here.component("fileLayout")(cpt);
  })();
  var fileLayout = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(fileLayoutCpt)(props)([  ]);
  };
  exports["fileLayout"] = fileLayout;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Frame"] = $PS["Gargantext.Components.Nodes.Frame"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Frame"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Components_FolderView = $PS["Gargantext.Components.FolderView"];
  var Gargantext_Components_Node = $PS["Gargantext.Components.Node"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var hframeUrl = function (v) {
      return function (v1) {
          return function (frame_id) {
              if (v instanceof Gargantext_Types.NodeFrameNotebook) {
                  return frame_id;
              };
              if (v instanceof Gargantext_Types.NodeFrameCalc) {
                  return v1 + ("/" + frame_id);
              };
              if (v instanceof Gargantext_Types.NodeFrameVisio) {
                  return v1 + ("/" + frame_id);
              };
              return v1 + ("/" + (frame_id + "?view"));
          };
      };
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Frame");
  var frameLayoutViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([ Gargantext_Components_FolderView.backButton, Gargantext_Components_FolderView.homeButton, Reactix_DOM_HTML.div({
                  className: "frame",
                  rows: "100%,*"
              })([ Reactix_DOM_HTML.iframe({
                  src: hframeUrl(v.nodeType)(v.frame.hyperdata.base)(v.frame.hyperdata.frame_id),
                  width: "100%",
                  height: "100%"
              })([  ]) ]) ]));
          };
      };
      return here.component("frameLayoutView")(cpt);
  })();
  var frameLayoutView = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(frameLayoutViewCpt)(props)([  ]);
  };                                                                                   
  var $dollar_ReadForeignHyperdata_16 = Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "base";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "frame_id";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()());
  var loadframe$prime = function (v) {
      return Gargantext_Sessions.get(Gargantext_Components_Node["$_ReadForeignNodePoly_8"]($dollar_ReadForeignHyperdata_16))(Gargantext_Sessions_Types["$_ToUrlSessionSessionRoute_35"])(v.session)(new Gargantext_Routes.NodeAPI(Gargantext_Types.Node.value, new Data_Maybe.Just(v.nodeId), ""));
  };
  var loadframeWithReload = function (v) {
      return loadframe$prime({
          nodeId: v.nodeId,
          session: v.session
      });
  }; 
  var $dollar_GenericHyperdata__12 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });   
  var $dollar_EqHyperdata_14 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericHyperdata__12)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "frame_id";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "base";
  }))(Data_Eq.eqString))))));
  var frameLayoutWithKeyCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (reload) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(reload))(function (reload$prime) {
                      return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "session";
                      }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                          return "reload";
                      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                          return "nodeId";
                      }))(Data_Eq.eqInt)))(Gargantext_Components_Node["$_EqNodePoly_7"]($dollar_EqHyperdata_14))({
                          nodeId: v.nodeId,
                          reload: reload$prime,
                          session: v.session
                      })(loadframeWithReload)(function (frame) {
                          return frameLayoutView({
                              frame: frame,
                              nodeId: v.nodeId,
                              reload: reload,
                              session: v.session,
                              nodeType: v.nodeType
                          });
                      });
                  });
              });
          };
      };
      return here.component("frameLayoutWithKey")(cpt);
  })();
  var frameLayoutWithKey = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(frameLayoutWithKeyCpt)(props)([  ]);
  };
  var frameLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var key = Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(Gargantext_Sessions_Types.sessionId(v.session)) + ("-" + Data_Show.show(Data_Show.showInt)(v.nodeId));
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(frameLayoutWithKey({
                  key: key,
                  nodeId: v.nodeId,
                  nodeType: v.nodeType,
                  session: v.session
              }));
          };
      };
      return here.component("frameLayout")(cpt);
  })();
  var frameLayout = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(frameLayoutCpt)(props)([  ]);
  };
  exports["frameLayout"] = frameLayout;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Data.Landing"] = $PS["Gargantext.Components.Data.Landing"] || {};
  var exports = $PS["Gargantext.Components.Data.Landing"];
  var Button = (function () {
      function Button(value0) {
          this.value0 = value0;
      };
      Button.create = function (value0) {
          return new Button(value0);
      };
      return Button;
  })();
  var BlockText = (function () {
      function BlockText(value0) {
          this.value0 = value0;
      };
      BlockText.create = function (value0) {
          return new BlockText(value0);
      };
      return BlockText;
  })();
  var BlockTexts = (function () {
      function BlockTexts(value0) {
          this.value0 = value0;
      };
      BlockTexts.create = function (value0) {
          return new BlockTexts(value0);
      };
      return BlockTexts;
  })();
  var LandingData = (function () {
      function LandingData(value0) {
          this.value0 = value0;
      };
      LandingData.create = function (value0) {
          return new LandingData(value0);
      };
      return LandingData;
  })();
  exports["LandingData"] = LandingData;
  exports["BlockTexts"] = BlockTexts;
  exports["BlockText"] = BlockText;
  exports["Button"] = Button;
})(PS);
(function($PS) {
  "use strict";
  $PS["Gargantext.Components.Lang.Landing.EnUS"] = $PS["Gargantext.Components.Lang.Landing.EnUS"] || {};
  var exports = $PS["Gargantext.Components.Lang.Landing.EnUS"];
  var Gargantext_Components_Data_Landing = $PS["Gargantext.Components.Data.Landing"];                
  var blockTexts = [ new Gargantext_Components_Data_Landing.BlockText({
      title: "Random sentences in Gargantua's Books chapters, historically true",
      href: "#",
      icon: "fa fa-random",
      titleText: "Historic",
      text: "Chapter 1.XV. How Gargantua was put under other schoolmasters. Chapter 2.XXII. How Panurge served a Parisian lady a trick that pleased her not very well. Chapter 3.XXXVII. How Pantagruel persuaded Panurge to take counsel of a fool. Chapter 4.LXI. How Gaster invented means to get and preserve corn. Chapter 5.XXXVIII. Of the temple's admirable pavement.",
      docButton: new Gargantext_Components_Data_Landing.Button({
          title: "Your first map in less than 5 minutes",
          text: " Documentation",
          href: "https://iscpif.fr/gargantext/your-first-map/"
      })
  }), new Gargantext_Components_Data_Landing.BlockText({
      title: "Randomized words, semantically and syntaxically falses.",
      href: "#",
      icon: "fa fa-random",
      titleText: "Presentation",
      text: "Autem nascetur iaculis, sedfusce enimsed cursus posuere consectetuer eu justo aliquammauris. Phasellus vero nisi porttitor elit quod, leo feliscras ultricies non tempor sagittis. Liberoduis facilisinam erat dapibusnam, lacus dui duis tristique volutpatut quis vestibulum magna. Nobis faucibusvestibulum dolores minim. Bibendumin malesuada adipiscing ante, mattis fames nequeetiam lorem. No diam id. Litora quisaenean commodo lobortisetiam neque, libero mollis scelerisque inceptos ullamcorper sea congue delenit possim.",
      docButton: new Gargantext_Components_Data_Landing.Button({
          title: "Your first map in less than 5 minutes",
          text: " Documentation",
          href: "https://iscpif.fr/gargantext/your-first-map/"
      })
  }), new Gargantext_Components_Data_Landing.BlockText({
      title: "Randomized letters, true or false ?",
      href: "#",
      icon: "fa fa-random",
      titleText: "Tutoreil",
      text: "Il para\xeet que l'rdore des lettres dans un mot n'a pas d'imtraopnce. La premi\xe8re et la derni\xe8re lettre doeivnt \xeatre \xe0 la bonne place. Le reste peut \xeatre dans un d\xe9sordre total et on peut touojurs lire sans prol\xe8bme. On ne lit donc pas chaque lettre en ell\xeaem-me, mais le mot comme un tout. Un chaegmnent de r\xe9f\xe9rentiel et nous tranpossons ce r\xe9sultat au texte luim\xea-me: l'rdore des mots est failbement important copamr\xe9 au contexte du texte qui, lui, est copmt\xe9: comptexter avec Gargantext.",
      docButton: new Gargantext_Components_Data_Landing.Button({
          title: "Your first map in less than 5 minutes",
          text: " Documentation",
          href: "https://iscpif.fr/gargantext/your-first-map/"
      })
  }) ];
  var landingData = new Gargantext_Components_Data_Landing.LandingData({
      name: "Gargantext",
      signature: "search map share",
      logoTitle: "Project hosted by CNRS (France, Europa)",
      imageTitle: "Click and test by yourself",
      blockTexts: new Gargantext_Components_Data_Landing.BlockTexts({
          blocks: blockTexts
      })
  });
  exports["landingData"] = landingData;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Lang.Landing.FrFR"] = $PS["Gargantext.Components.Lang.Landing.FrFR"] || {};
  var exports = $PS["Gargantext.Components.Lang.Landing.FrFR"];
  var Gargantext_Components_Data_Landing = $PS["Gargantext.Components.Data.Landing"];                
  var blockTexts = [ new Gargantext_Components_Data_Landing.BlockText({
      title: "Phrases al\xe9atoires issues de l'oeuvre de Fran\xe7ois Rabelais. L'ordre historique des chapitres est pr\xe9serv\xe9.",
      href: "#",
      icon: "fa fa-random",
      titleText: "Historique",
      text: "Chapitre 1",
      docButton: new Gargantext_Components_Data_Landing.Button({
          title: "Your first map in less than 5 minutes",
          text: " Documentation",
          href: "https://iscpif.fr/gargantext/your-first-map/"
      })
  }), new Gargantext_Components_Data_Landing.BlockText({
      title: "Mots al\xe9atoires.",
      href: "#",
      icon: "fa fa-random",
      titleText: "Presentation",
      text: "Autem nascetur iaculis, sedfusce enimsed cursus posuere consectetuer eu justo aliquammauris. Phasellus vero nisi porttitor elit quod, leo feliscras ultricies non tempor sagittis. Liberoduis facilisinam erat dapibusnam, lacus dui duis tristique volutpatut quis vestibulum magna. Nobis faucibusvestibulum dolores minim. Bibendumin malesuada adipiscing ante, mattis fames nequeetiam lorem. No diam id. Litora quisaenean commodo lobortisetiam neque, libero mollis scelerisque inceptos ullamcorper sea congue delenit possim.",
      docButton: new Gargantext_Components_Data_Landing.Button({
          title: "Your first map in less than 5 minutes",
          text: " Documentation",
          href: "https://iscpif.fr/gargantext/your-first-map/"
      })
  }), new Gargantext_Components_Data_Landing.BlockText({
      title: "Lettres al\xe9taoires, exp\xe9rience",
      href: "#",
      icon: "fa fa-random",
      titleText: "Tutoreil",
      text: "Il para\xeet que l'rdore des lettres dans un mot n'a pas d'imtraopnce. La premi\xe8re et la derni\xe8re lettre doeivnt \xeatre \xe0 la bonne place. Le reste peut \xeatre dans un d\xe9sordre total et on peut touojurs lire sans prol\xe8bme. On ne lit donc pas chaque lettre en ell\xeaem-me, mais le mot comme un tout. Un chaegmnent de r\xe9f\xe9rentiel et nous tranpossons ce r\xe9sultat au texte luim\xea-me: l'rdore des mots est failbement important copamr\xe9 au contexte du texte qui, lui, est copmt\xe9: comptexter avec Gargantext.",
      docButton: new Gargantext_Components_Data_Landing.Button({
          title: "Your first map in less than 5 minutes",
          text: " Documentation",
          href: "https://iscpif.fr/gargantext/your-first-map/"
      })
  }) ];
  var landingData = new Gargantext_Components_Data_Landing.LandingData({
      name: "Gargantext",
      signature: "chercher cartographier partgager",
      logoTitle: "Projet d\xe9velopp\xe9 par le CNRS (France, Europe)",
      imageTitle: "Cliquez et testez vous-m\xeames",
      blockTexts: new Gargantext_Components_Data_Landing.BlockTexts({
          blocks: blockTexts
      })
  });
  exports["landingData"] = landingData;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Config"] = $PS["Gargantext.Config"] || {};
  var exports = $PS["Gargantext.Config"];
  var Data_Array = $PS["Data.Array"];
  var Data_Array_NonEmpty = $PS["Data.Array.NonEmpty"];
  var Data_NonEmpty = $PS["Data.NonEmpty"];
  var Data_String_Utils = $PS["Data.String.Utils"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils = $PS["Gargantext.Utils"];
  var prodUrl = "https://v4.gargantext.org";
  var partnerUrl = "https://imtv4.gargantext.org";
  var localUrl = "http://localhost:8008";
  var devUrl = "https://dev.gargantext.org";
  var demoUrl = "https://demo.gargantext.org";
  var defaultStatics = (function () {
      var relative = Gargantext_Ends.frontend("")("/")("relative");
      return new Data_NonEmpty.NonEmpty(relative, [  ]);
  })();
  var defaultStatic = Data_NonEmpty.head(defaultStatics);
  var defaultApps = (function () {
      var relative = Gargantext_Ends.frontend("/#/")("")("Relative");
      var python = Gargantext_Ends.frontend("/#/")("http://localhost:8000")("localhost.python");
      var prod = Gargantext_Ends.frontend("/#/")("https://v4.gargantext.org")("v4.gargantext.org");
      var haskell = Gargantext_Ends.frontend("/#/")("http://localhost:8008")("localhost.gargantext");
      var dev = Gargantext_Ends.frontend("/#/")("https://dev.gargantext.org")("gargantext.org (dev)");
      var demo = Gargantext_Ends.frontend("/#/")("https://demo.gargantext.org")("gargantext.org (demo)");
      var caddy = Gargantext_Ends.frontend("/#/")("http://localhost:2015")("localhost.caddy");
      return new Data_NonEmpty.NonEmpty(relative, [ prod, dev, demo, haskell, caddy ]);
  })();
  var defaultApp = Data_NonEmpty.head(defaultApps);
  var defaultFrontends = {
      app: defaultApp,
      "static": defaultStatic
  };                                                                                              
  var backend_prod = Gargantext_Ends.backend(Gargantext_Types.V10.value)("/api/")(prodUrl)("iscpif.cnrs");
  var backend_partner = Gargantext_Ends.backend(Gargantext_Types.V10.value)("/api/")(partnerUrl)("institut-mines-telecom.imt");
  var backend_local = Gargantext_Ends.backend(Gargantext_Types.V10.value)("/api/")(localUrl)("local.cnrs");
  var publicBackend = backend_local;
  var backend_dev = Gargantext_Ends.backend(Gargantext_Types.V10.value)("/api/")(devUrl)("devel.inshs.cnrs");
  var backend_demo = Gargantext_Ends.backend(Gargantext_Types.V10.value)("/api/")(demoUrl)("demo.inshs.cnrs");
  var defaultBackends = new Data_NonEmpty.NonEmpty(backend_local, [ backend_prod, backend_partner, backend_demo, backend_dev ]);
  var matchCurrentLocation = function __do() {
      var href = Gargantext_Utils.href();
      var starts = Data_Array_NonEmpty.filter(function (v) {
          return Data_String_Utils.startsWith(v.baseUrl)(href);
      })(Data_Array_NonEmpty.fromNonEmpty(defaultBackends));
      return Data_Array.head(starts);
  };
  exports["defaultBackends"] = defaultBackends;
  exports["matchCurrentLocation"] = matchCurrentLocation;
  exports["publicBackend"] = publicBackend;
  exports["defaultFrontends"] = defaultFrontends;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Home.Public"] = $PS["Gargantext.Components.Nodes.Home.Public"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Home.Public"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Gargantext_Config = $PS["Gargantext.Config"];
  var Gargantext_Config_REST = $PS["Gargantext.Config.REST"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Simple_JSON = $PS["Simple.JSON"];
  var Simple_JSON_Generics_UntaggedSumRep = $PS["Simple.JSON.Generics.UntaggedSumRep"];                
  var PublicData = (function () {
      function PublicData(value0) {
          this.value0 = value0;
      };
      PublicData.create = function (value0) {
          return new PublicData(value0);
      };
      return PublicData;
  })();
  var NoData = (function () {
      function NoData(value0) {
          this.value0 = value0;
      };
      NoData.create = function (value0) {
          return new NoData(value0);
      };
      return NoData;
  })();
  var tableau = function (v) {
      if (v instanceof NoData) {
          return Reactix_DOM_HTML.div({
              className: "center"
          })([ Reactix_DOM_HTML.h2({})([ Reactix_DOM_HTML.text("Create a corpus and publicize it") ]) ]);
      };
      if (v instanceof PublicData) {
          return Reactix_DOM_HTML.div({
              className: "card mb-6 box-shadow"
          })([ Reactix_DOM_HTML.a({
              target: "_blank",
              href: v.value0.url
          })([ Reactix_DOM_HTML.div({
              className: "center"
          })([ Reactix_DOM_HTML.img({
              src: v.value0.img,
              width: "50%"
          }) ]) ]), Reactix_DOM_HTML.div({
              className: "card-body"
          })([ Reactix_DOM_HTML.h3({})([ Reactix_DOM_HTML.text(v.value0.title) ]), Reactix_DOM_HTML.p({
              className: "card-text"
          })([ Reactix_DOM_HTML.text(Data_String_CodePoints.take(252)(v["value0"]["abstract"]) + "...") ]), Reactix_DOM_HTML.div({
              className: "center justify-content-between align-items-center"
          })([ Reactix_DOM_HTML.div({
              className: "btn-group"
          })([ Reactix_DOM_HTML.div({
              className: "small text-muted flex-end"
          })([ Reactix_DOM_HTML.text("Made by " + (v.value0.author + (" on " + (v.value0.date + (" with " + v.value0.database))))) ]) ]) ]) ]) ]);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Home.Public (line 104, column 1 - line 104, column 35): " + [ v.constructor.name ]);
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Home.Public");
  var album = function (pd) {
      var content = function (tab) {
          return Reactix_DOM_HTML.div({
              className: "col-md-6 content"
          })([ tableau(tab) ]);
      };
      return Reactix_DOM_HTML.div({
          className: "album py-5 bg-light"
      })([ Reactix_DOM_HTML.div({
          className: "container"
      })([ Reactix_DOM_HTML.div({
          className: "row"
      })(Data_Functor.map(Data_Functor.functorArray)(content)(pd)) ]) ]);
  };
  var publicLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.span({})([ Reactix_DOM_HTML.div({
                  className: "text-center"
              })([ Reactix_DOM_HTML.div({
                  className: "container1",
                  style: {
                      marginBottom: "15px"
                  }
              })([ Reactix_DOM_HTML.h2({})([ Reactix_DOM_HTML.text("Discover knowledge"), Reactix_DOM_HTML.p({
                  className: "lead text-muted center"
              })([ Reactix_DOM_HTML.text("maps made with "), Reactix_DOM_HTML.span({
                  className: "fa fa-heart"
              })([  ]) ]) ]) ]) ]), album(v.publicData) ]));
          };
      };
      return here.component("publicLayout")(cpt);
  })();
  var publicLayout = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(publicLayoutCpt)(props)([  ]);
  };
  var $dollar_GenericPublicData__15 = new Data_Generic_Rep.Generic(function (x) {
      if (x instanceof PublicData) {
          return new Data_Generic_Rep.Inl(x.value0);
      };
      if (x instanceof NoData) {
          return new Data_Generic_Rep.Inr(x.value0);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Home.Public (line 38, column 1 - line 38, column 37): " + [ x.constructor.name ]);
  }, function (x) {
      if (x instanceof Data_Generic_Rep.Inl) {
          return new PublicData(x.value0);
      };
      if (x instanceof Data_Generic_Rep.Inr) {
          return new NoData(x.value0);
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Home.Public (line 38, column 1 - line 38, column 37): " + [ x.constructor.name ]);
  });
  var $dollar_ReadForeignPublicData_16 = new Simple_JSON.ReadForeign(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRep($dollar_GenericPublicData__15)(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepSum(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepConstructor(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepArgument(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "abstract";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "author";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "database";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "date";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "img";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "title";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "url";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()())()())()())()())()())()())()()))))(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepConstructor(Simple_JSON_Generics_UntaggedSumRep.untaggedSumRepArgument(Simple_JSON.readRecord()(Simple_JSON.readFieldsCons(new Data_Symbol.IsSymbol(function () {
      return "nodata";
  }))(Simple_JSON.readString)(Simple_JSON.readFieldsNil)()()))))));
  var loadPublicData = function (_l) {
      return Gargantext_Config_REST.get(Simple_JSON.readArray($dollar_ReadForeignPublicData_16))(Data_Maybe.Nothing.value)(Gargantext_Ends.backendUrl(Gargantext_Config.publicBackend)("public"));
  };     
  var $dollar_EqPublicData_14 = new Data_Eq.Eq(function (x) {
      return function (y) {
          if (x instanceof PublicData && y instanceof PublicData) {
              return x["value0"]["abstract"] === y["value0"]["abstract"] && x.value0.author === y.value0.author && x.value0.database === y.value0.database && x.value0.date === y.value0.date && x.value0.img === y.value0.img && x.value0.title === y.value0.title && x.value0.url === y.value0.url;
          };
          if (x instanceof NoData && y instanceof NoData) {
              return x.value0.nodata === y.value0.nodata;
          };
          return false;
      };
  });
  var renderPublicCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var loaded = function (publicData) {
                  return publicLayout({
                      publicData: publicData
                  });
              };
              return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                  return "reload";
              }))(Data_Eq.eqInt)))(Data_Eq.eqArray($dollar_EqPublicData_14))({
                  reload: 0
              })(loadPublicData)(loaded);
          };
      };
      return here.component("renderPublic")(cpt);
  })();
  var renderPublic = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(renderPublicCpt)(props)([  ]);
  };
  exports["renderPublic"] = renderPublic;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.License"] = $PS["Gargantext.License"] || {};
  var exports = $PS["Gargantext.License"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];                
  var license = Reactix_DOM_HTML.p({
      className: "license"
  })([ Reactix_DOM_HTML.text("GarganText "), Reactix_DOM_HTML.span({
      className: "fa fa-registered"
  })([  ]), Reactix_DOM_HTML.text(" is made by "), Reactix_DOM_HTML.a({
      href: "https://iscpif.fr",
      target: "blank"
  })([ Reactix_DOM_HTML.text("CNRS/ISCPIF") ]), Reactix_DOM_HTML.a({
      href: "http://gitlab.iscpif.fr/humanities/gargantext/blob/stable/LICENSE",
      target: "blank",
      title: "Legal instructions of the project."
  })([ Reactix_DOM_HTML.text(", with licences aGPLV3 and CECILL variant Affero compliant, ") ]), Reactix_DOM_HTML.span({
      className: "fa fa-copyright"
  })([  ]), Reactix_DOM_HTML.a({
      href: "https://cnrs.fr",
      target: "blank"
  })([ Reactix_DOM_HTML.text(" CNRS 2017-Present ") ]), Reactix_DOM_HTML.text(".") ]);
  exports["license"] = license;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Home"] = $PS["Gargantext.Components.Nodes.Home"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Home"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Unit = $PS["Data.Unit"];
  var Gargantext_Components_FolderView = $PS["Gargantext.Components.FolderView"];
  var Gargantext_Components_Lang = $PS["Gargantext.Components.Lang"];
  var Gargantext_Components_Lang_Landing_EnUS = $PS["Gargantext.Components.Lang.Landing.EnUS"];
  var Gargantext_Components_Lang_Landing_FrFR = $PS["Gargantext.Components.Lang.Landing.FrFR"];
  var Gargantext_Components_Nodes_Home_Public = $PS["Gargantext.Components.Nodes.Home.Public"];
  var Gargantext_Config = $PS["Gargantext.Config"];
  var Gargantext_Ends = $PS["Gargantext.Ends"];
  var Gargantext_License = $PS["Gargantext.License"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var langLandingData = function (v) {
      if (v instanceof Gargantext_Components_Lang.LL_FR) {
          return Gargantext_Components_Lang_Landing_FrFR.landingData;
      };
      if (v instanceof Gargantext_Components_Lang.LL_EN) {
          return Gargantext_Components_Lang_Landing_EnUS.landingData;
      };
      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Home (line 51, column 1 - line 51, column 46): " + [ v.constructor.name ]);
  };
  var jumboTitle = function (v) {
      return Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.div({
          className: "row"
      })([ Reactix_DOM_HTML.div({
          className: "mx-auto"
      })([ Reactix_DOM_HTML.div({
          id: "logo-designed"
      })([ Reactix_DOM_HTML.img({
          src: "images/logo.png",
          title: v.value0.logoTitle
      }) ]) ]) ]) ]);
  };
  var joinButton = function (click) {
      return Reactix_DOM_HTML.div({
          className: "flex-space-around d-flex justify-content-center",
          style: {
              paddingTop: "100px",
              paddingBottom: "100px"
          }
      })([ Reactix_DOM_HTML.button({
          className: "btn btn-primary btn-lg btn-block",
          title: "Connect to the server",
          on: {
              click: click
          }
      })([ Reactix_DOM_HTML.text("Log in") ]) ]);
  };
  var incompatible = "Sorry your browser is not compatible: use Firefox or Chromium instead.";
  var video = function (fileDuration) {
      var src = "http://dl.gargantext.org/" + fileDuration;
      var id = "source_" + fileDuration;
      return Reactix_DOM_HTML.div({
          className: "col-12 d-flex justify-content-center"
      })([ Reactix_DOM_HTML.video({
          src: src,
          title: "tutorial video here",
          id: id,
          width: "900",
          type: "video/ogg",
          controls: true,
          muted: true
      })([ Reactix_DOM_HTML.text(incompatible) ]) ]);
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Home");
  var tutorialCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var makeTuto = function (class$prime) {
                  return function (v2) {
                      return Reactix_DOM_HTML.div({
                          className: "alert " + class$prime,
                          id: v2.value0.id
                      })([ video(v2.value0.id), Reactix_DOM_HTML.h4({})([ Reactix_DOM_HTML.text(v2.value0.title) ]), Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.text(v2.value0.text) ]) ]);
                  };
              };
              var section = function (name) {
                  return function (class$prime) {
                      return function (tutos) {
                          return Reactix_DOM_HTML.div({})(Data_Array.cons(Reactix_DOM_HTML.h4({})([ Reactix_DOM_HTML.text(name) ]))(Data_Functor.map(Data_Functor.functorArray)(makeTuto(class$prime))(tutos)));
                      };
                  };
              };
              var makeFolders = function (s) {
                  var sessionToFolder = function (v2) {
                      return Reactix_DOM_HTML.span({
                          className: "folder"
                      })([ Reactix_DOM_HTML.div({
                          className: "d-flex justify-content-center"
                      })([ Reactix_DOM_HTML.text(v2.username + ("@" + v2.backend.name)) ]), Reactix_DOM_HTML.div({})([ Gargantext_Components_FolderView.folderView({
                          session: v2,
                          tasks: v.tasks,
                          reloadForest: v.reloadForest,
                          nodeId: v2.treeId,
                          backFolder: false
                      }) ]) ]);
                  };
                  return Data_Functor.map(Data_Functor.functorArray)(sessionToFolder)(s);
              };
              var folders = makeFolders(v.sessions);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                  className: "mx-auto container"
              })([ Reactix_DOM_HTML.div({
                  className: "d-flex justify-content-center"
              })([ Reactix_DOM_HTML.div({
                  className: "folders"
              })(folders) ]) ]));
          };
      };
      return here.component("tutorial")(cpt);
  })();
  var tutorial = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(tutorialCpt)(props)([  ]);
  };
  var joinButtonOrTutorial = function (tasks) {
      return function (reloadForest) {
          return function (sessions) {
              return function (click) {
                  var $43 = Gargantext_Sessions_Types["null"](sessions);
                  if ($43) {
                      return joinButton(click);
                  };
                  return tutorial({
                      tasks: tasks,
                      reloadForest: reloadForest,
                      sessions: Gargantext_Sessions_Types.unSessions(sessions)
                  });
              };
          };
      };
  };                     
  var docButton = function (v) {
      return Reactix_DOM_HTML.a({
          className: "btn btn-outline-primary btn-sm spacing-class",
          href: v.value0.href,
          target: "blank",
          title: v.value0.title
      })([ Reactix_DOM_HTML.span({
          aria: {
              hidden: true
          },
          className: "fa fa-hand-right"
      })([  ]), Reactix_DOM_HTML.text(v.value0.text) ]);
  };
  var blocksRandomText = function (v) {
      var showBlock = function (v1) {
          return Reactix_DOM_HTML.div({
              className: "col-md-4 content"
          })([ Reactix_DOM_HTML.h3({})([ Reactix_DOM_HTML.a({
              href: v1.value0.href,
              title: v1.value0.title
          })([ Reactix_DOM_HTML.i({
              className: v1.value0.icon
          })([  ]), Reactix_DOM_HTML.text("   " + v1.value0.titleText) ]) ]), Reactix_DOM_HTML.p({})([ Reactix_DOM_HTML.text(v1.value0.text) ]), Reactix_DOM_HTML.p({})([ docButton(v1.value0.docButton) ]) ]);
      };
      return Reactix_DOM_HTML.div({
          className: "row"
      })(Data_Functor.map(Data_Functor.functorArray)(showBlock)(v.value0.blocks));
  };
  var blocksRandomText$prime = function (v) {
      return blocksRandomText(v.value0.blockTexts);
  };
  var homeLayoutCpt = function (dictRead) {
      return function (dictReadWrite) {
          var cpt = function (v) {
              return function (v1) {
                  var click = function (mBackend) {
                      return function (v2) {
                          if (mBackend instanceof Data_Maybe.Nothing) {
                              return function __do() {
                                  var mLoc = Gargantext_Config.matchCurrentLocation();
                                  if (mLoc instanceof Data_Maybe.Nothing) {
                                      return Data_Unit.unit;
                                  };
                                  if (mLoc instanceof Data_Maybe.Just) {
                                      Toestand_Classes.write_(Toestand_Boxes.writeBox)(new Data_Maybe.Just(mLoc.value0))(v.backend)();
                                      return Toestand_Classes.write_(dictReadWrite.Write1())(true)(v.showLogin)();
                                  };
                                  throw new Error("Failed pattern match at Gargantext.Components.Nodes.Home (line 96, column 15 - line 100, column 42): " + [ mLoc.constructor.name ]);
                              };
                          };
                          if (mBackend instanceof Data_Maybe.Just) {
                              return Toestand_Classes.write_(dictReadWrite.Write1())(true)(v.showLogin);
                          };
                          throw new Error("Failed pattern match at Gargantext.Components.Nodes.Home (line 93, column 11 - line 101, column 46): " + [ mBackend.constructor.name ]);
                      };
                  };
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Gargantext_Ends["$_EqBackend_25"])))(v.backend))(function (backend$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(dictRead)(Toestand_Changes.unequal(Gargantext_Sessions_Types["$_EqSessions_42"]))(v.sessions))(function (sessions$prime) {
                          var landingData = langLandingData(v.lang);
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.span({})([ Reactix_DOM_HTML.div({
                              className: "home-title container1"
                          })([ jumboTitle(landingData) ]), Reactix_DOM_HTML.div({
                              className: "home-research-form container1"
                          })([  ]), joinButtonOrTutorial(v.tasks)(v.reloadForest)(sessions$prime)(click(backend$prime)), Reactix_DOM_HTML.div({
                              className: "home-public container1"
                          })([ Gargantext_Components_Nodes_Home_Public.renderPublic({}), Reactix_DOM_HTML.div({
                              className: "col-12 d-flex justify-content-center"
                          })([ Reactix_DOM_HTML.h1({})([ Reactix_DOM_HTML.text("") ]) ]), Reactix_DOM_HTML.div({
                              className: "home-landing-data container1"
                          })([ blocksRandomText$prime(landingData) ]), Gargantext_License.license ]) ]));
                      });
                  });
              };
          };
          return here.component("homeLayout")(cpt);
      };
  };
  var homeLayout = function (dictRead) {
      return function (dictReadWrite) {
          return function (props) {
              return Reactix_React.createElement(Reactix_React.componentIsComponent)(homeLayoutCpt(dictRead)(dictReadWrite))(props)([  ]);
          };
      };
  };
  exports["homeLayout"] = homeLayout;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Corpus.Chart.Utils"] = $PS["Gargantext.Components.Nodes.Corpus.Chart.Utils"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Corpus.Chart.Utils"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var mNgramsTypeFromTabType = function (v) {
      if (v instanceof Gargantext_Types.TabCorpus && v.value0 instanceof Gargantext_Types.TabNgramType) {
          return new Data_Maybe.Just(v.value0.value0);
      };
      if (v instanceof Gargantext_Types.TabDocument && v.value0 instanceof Gargantext_Types.TabNgramType) {
          return new Data_Maybe.Just(v.value0.value0);
      };
      return Data_Maybe.Nothing.value;
  };
  exports["mNgramsTypeFromTabType"] = mNgramsTypeFromTabType;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Lists.Tabs"] = $PS["Gargantext.Components.Nodes.Lists.Tabs"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Lists.Tabs"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Effect_Class = $PS["Effect.Class"];
  var Gargantext_Components_NgramsTable = $PS["Gargantext.Components.NgramsTable"];
  var Gargantext_Components_NgramsTable_Core = $PS["Gargantext.Components.NgramsTable.Core"];
  var Gargantext_Components_Nodes_Corpus_Chart_Metrics = $PS["Gargantext.Components.Nodes.Corpus.Chart.Metrics"];
  var Gargantext_Components_Nodes_Corpus_Chart_Pie = $PS["Gargantext.Components.Nodes.Corpus.Chart.Pie"];
  var Gargantext_Components_Nodes_Corpus_Chart_Tree = $PS["Gargantext.Components.Nodes.Corpus.Chart.Tree"];
  var Gargantext_Components_Nodes_Corpus_Chart_Utils = $PS["Gargantext.Components.Nodes.Corpus.Chart.Utils"];
  var Gargantext_Components_Search = $PS["Gargantext.Components.Search"];
  var Gargantext_Components_Tab = $PS["Gargantext.Components.Tab"];
  var Gargantext_Components_Table_Types = $PS["Gargantext.Components.Table.Types"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Gargantext_Utils_Toestand = $PS["Gargantext.Utils.Toestand"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Record_Extra = $PS["Record.Extra"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Lists.Tabs");
  var ngramsViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var tabNgramType = Gargantext_Types.modeTabType(v.mode);
              var tabType = new Gargantext_Types.TabCorpus(new Gargantext_Types.TabNgramType(tabNgramType));
              var mNgramsType = Gargantext_Components_Nodes_Corpus_Chart_Utils.mNgramsTypeFromTabType(tabType);
              var initialPath = {
                  corpusId: v.corpusId,
                  listId: v.corpusData.defaultListId,
                  tabType: tabType
              };
              var chart = function (path) {
                  return function (v2) {
                      if (v2 instanceof Gargantext_Types.Authors) {
                          return Gargantext_Components_Nodes_Corpus_Chart_Pie.pie({
                              path: path,
                              session: v.session
                          });
                      };
                      if (v2 instanceof Gargantext_Types.Institutes) {
                          return Gargantext_Components_Nodes_Corpus_Chart_Tree.tree({
                              path: path,
                              session: v.session
                          });
                      };
                      if (v2 instanceof Gargantext_Types.Sources) {
                          return Gargantext_Components_Nodes_Corpus_Chart_Pie.bar({
                              path: path,
                              session: v.session
                          });
                      };
                      if (v2 instanceof Gargantext_Types.Terms) {
                          return Gargantext_Components_Nodes_Corpus_Chart_Metrics.metrics({
                              path: path,
                              session: v.session
                          });
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Lists.Tabs (line 166, column 9 - line 166, column 58): " + [ path.constructor.name, v2.constructor.name ]);
                  };
              };
              var charts = function (params) {
                  return function (v2) {
                      if (v2 instanceof Gargantext_Types.CTabTerms) {
                          return [ Reactix_DOM_HTML.div({
                              className: "row"
                          })([ Reactix_DOM_HTML.div({
                              className: "col-12 d-flex justify-content-center"
                          })([ Reactix_DOM_HTML.img({
                              src: "images/Gargantextuel-212x300.jpg",
                              id: "funnyimg"
                          }) ]) ]) ];
                      };
                      return [ chart(params)(v.mode) ];
                  };
              };
              var afterSync = function (chartsReload) {
                  return function (v2) {
                      if (mNgramsType instanceof Data_Maybe.Just) {
                          return Effect_Class.liftEffect(Effect_Aff.monadEffectAff)(Gargantext_Utils_Toestand.reload(Gargantext_Utils_Toestand["$_ReloadableBoxInt_2"])(chartsReload));
                      };
                      if (mNgramsType instanceof Data_Maybe.Nothing) {
                          return Control_Applicative.pure(Effect_Aff.applicativeAff)(Data_Unit.unit);
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Nodes.Lists.Tabs (line 115, column 11 - line 122, column 41): " + [ mNgramsType.constructor.name ]);
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Utils_Toestand.newReload))(function (chartsReload) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_NgramsTable_Core.initialPageParams(v.session)(initialPath.corpusId)([ initialPath.listId ])(initialPath.tabType)))(function (path) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "termSizeFilter";
                      }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermSize_99"])))()(new Data_Symbol.IsSymbol(function () {
                          return "termListFilter";
                      }))(Data_Maybe.eqMaybe(Gargantext_Types["$_EqTermList_103"])))()(new Data_Symbol.IsSymbol(function () {
                          return "tabType";
                      }))(Gargantext_Types["$_EqTabType_148"]))()(new Data_Symbol.IsSymbol(function () {
                          return "session";
                      }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                          return "searchQuery";
                      }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                          return "scoreType";
                      }))(Gargantext_Types["$_EqScoreType_120"]))()(new Data_Symbol.IsSymbol(function () {
                          return "params";
                      }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                          return "searchType";
                      }))(Gargantext_Components_Search["$_EqSearchType_27"]))()(new Data_Symbol.IsSymbol(function () {
                          return "orderBy";
                      }))(Data_Maybe.eqMaybe(Gargantext_Components_Table_Types["$_EqOrderByDirection_19"](Gargantext_Components_Table_Types["$_EqColumnName_22"]))))()(new Data_Symbol.IsSymbol(function () {
                          return "offset";
                      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                          return "limit";
                      }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                          return "nodeId";
                      }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                          return "listIds";
                      }))(Data_Eq.eqArray(Data_Eq.eqInt)))))(path))(function (v2) {
                          var path$prime = {
                              corpusId: v2.nodeId,
                              limit: v2.params.limit,
                              listId: Data_Maybe.fromMaybe(v.corpusData.defaultListId)(Data_Array.head(v2.listIds)),
                              tabType: v2.tabType
                          };
                          var chartParams = {
                              corpusId: path$prime.corpusId,
                              limit: new Data_Maybe.Just(path$prime.limit),
                              listId: path$prime.listId,
                              tabType: path$prime.tabType
                          };
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment(Data_Semigroup.append(Data_Semigroup.semigroupArray)(charts(chartParams)(tabNgramType))([ Gargantext_Components_NgramsTable.mainNgramsTable({
                              afterSync: afterSync(chartsReload),
                              cacheState: v.cacheState,
                              defaultListId: v.corpusData.defaultListId,
                              path: path,
                              reloadForest: v.reloadForest,
                              reloadRoot: v.reloadRoot,
                              session: v.session,
                              tabNgramType: tabNgramType,
                              tabType: v2.tabType,
                              tasks: v.tasks,
                              withAutoUpdate: false
                          })([  ]) ])));
                      });
                  });
              });
          };
      };
      return here.component("ngramsView")(cpt);
  })();
  var ngramsView = Reactix_React.createElement(Reactix_React.componentIsComponent)(ngramsViewCpt);
  var tabsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var common = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "activeTab";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "cacheState";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "corpusData";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "corpusId";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reloadForest";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "reloadRoot";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "session";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "tasks";
              }))(Record_Extra.nilKeys)))))))))(v);
              var view = function (mode) {
                  return ngramsView(Record.merge()()(common)({
                      mode: mode
                  }));
              };
              var tabs$prime = [ new Data_Tuple.Tuple("Terms", view(Gargantext_Types.Terms.value)([  ])), new Data_Tuple.Tuple("Authors", view(Gargantext_Types.Authors.value)([  ])), new Data_Tuple.Tuple("Institutes", view(Gargantext_Types.Institutes.value)([  ])), new Data_Tuple.Tuple("Sources", view(Gargantext_Types.Sources.value)([  ])) ];
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Tab.tabs({
                  activeTab: v.activeTab,
                  tabs: tabs$prime
              }));
          };
      };
      return here.component("tabs")(cpt);
  })();
  var tabs = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(tabsCpt)(props)([  ]);
  };
  exports["tabs"] = tabs;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Lists"] = $PS["Gargantext.Components.Nodes.Lists"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Lists"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_NgramsTable_Loader = $PS["Gargantext.Components.NgramsTable.Loader"];
  var Gargantext_Components_Node = $PS["Gargantext.Components.Node"];
  var Gargantext_Components_Nodes_Corpus = $PS["Gargantext.Components.Nodes.Corpus"];
  var Gargantext_Components_Nodes_Corpus_Types = $PS["Gargantext.Components.Nodes.Corpus.Types"];
  var Gargantext_Components_Nodes_Lists_Tabs = $PS["Gargantext.Components.Nodes.Lists.Tabs"];
  var Gargantext_Components_Nodes_Lists_Types = $PS["Gargantext.Components.Nodes.Lists.Types"];
  var Gargantext_Components_Table = $PS["Gargantext.Components.Table"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Lists");
  var listsLayoutWithKeyCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var afterCacheStateChange = function (cacheState) {
                  return function __do() {
                      Effect_Aff.launchAff_(Gargantext_Components_NgramsTable_Loader.clearCache(Data_Unit.unit))();
                      return v.sessionUpdate(Gargantext_Sessions.setCacheState(v.session)(v.nodeId)(cacheState))();
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(0))(function (activeTab) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqInt))(v.reloadMainPage))(function (reloadMainPage$prime) {
                      var path = {
                          nodeId: v.nodeId,
                          session: v.session
                      };
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Sessions.getCacheState(Gargantext_Components_Nodes_Lists_Types.CacheOn.value)(v.session)(v.nodeId)))(function (cacheState) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Nodes_Lists_Types["$_EqCacheState_4"]))(cacheState))(function (cacheState$prime) {
                              return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffectOnce'"](Toestand_Classes.listen(Toestand_Boxes.readBox)(function (v2) {
                                  return afterCacheStateChange(v2["new"]);
                              })(cacheState)))(function () {
                                  return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                                      return "session";
                                  }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                                      return "nodeId";
                                  }))(Data_Eq.eqInt)))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                                      return "defaultListId";
                                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                                      return "corpusNode";
                                  }))(Gargantext_Components_Node["$_EqNodePoly_7"](Gargantext_Components_Nodes_Corpus_Types["$_EqHyperdata_8"])))()(new Data_Symbol.IsSymbol(function () {
                                      return "corpusId";
                                  }))(Data_Eq.eqInt)))(path)(Gargantext_Components_Nodes_Corpus.loadCorpusWithChild)(function (v2) {
                                      var v3 = Gargantext_Components_Nodes_Corpus_Types.getCorpusInfo(v2.corpusNode.hyperdata.fields);
                                      return Reactix_React.fragment([ Gargantext_Components_Table.tableHeaderLayout({
                                          cacheState: cacheState,
                                          date: v2.corpusNode.date,
                                          desc: v3.desc,
                                          key: "listsLayoutWithKey-header-" + Data_Show.show(Gargantext_Components_Nodes_Lists_Types["$_ShowCacheState_5"])(cacheState$prime),
                                          query: v3.query,
                                          title: "Corpus " + v2.corpusNode.name,
                                          user: v3.authors
                                      })([  ]), Gargantext_Components_Nodes_Lists_Tabs.tabs({
                                          activeTab: activeTab,
                                          cacheState: cacheState,
                                          corpusData: v2,
                                          corpusId: v2.corpusId,
                                          key: "listsLayoutWithKey-tabs-" + Data_Show.show(Gargantext_Components_Nodes_Lists_Types["$_ShowCacheState_5"])(cacheState$prime),
                                          reloadForest: v.reloadForest,
                                          reloadRoot: v.reloadRoot,
                                          session: v.session,
                                          tasks: v.tasks
                                      }) ]);
                                  });
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("listsLayoutWithKey")(cpt);
  })();
  var listsLayoutWithKey = Reactix_React.createElement(Reactix_React.componentIsComponent)(listsLayoutWithKeyCpt);
  var listsLayoutCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sid = Gargantext_Sessions_Types.sessionId(v.session);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(listsLayoutWithKey(Record.merge()()(v)({
                  key: Data_Show.show(Gargantext_Types["$_ShowSessionId_97"])(sid) + ("-" + Data_Show.show(Data_Show.showInt)(v.nodeId))
              }))([  ]));
          };
      };
      return here.component("listsLayout")(cpt);
  })();
  var listsLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(listsLayoutCpt);
  var sidePanelDocViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([ Reactix_DOM_HTML.text("Hello ngrams") ]));
          };
      };
      return here.component("sidePanelDocView")(cpt);
  })();
  var sidePanelDocView = Reactix_React.createElement(Reactix_React.componentIsComponent)(sidePanelDocViewCpt);
  var sidePanelCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqSidePanelState_180"]))(v.sidePanelState))(function (sidePanelState$prime) {
                  var mainStyle = (function () {
                      if (sidePanelState$prime instanceof Gargantext_Types.Opened) {
                          return {
                              display: "block"
                          };
                      };
                      return {
                          display: "none"
                      };
                  })();
                  var closeSidePanel = function (v2) {
                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Types.Closed.value)(v.sidePanelState);
                  };
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      style: mainStyle
                  })([ Reactix_DOM_HTML.div({
                      className: "header"
                  })([ Reactix_DOM_HTML.span({
                      className: "btn btn-danger",
                      on: {
                          click: closeSidePanel
                      }
                  })([ Reactix_DOM_HTML.span({
                      className: "fa fa-times"
                  })([  ]) ]) ]), sidePanelDocView({
                      session: v.session
                  })([  ]) ]));
              });
          };
      };
      return here.component("sidePanel")(cpt);
  })();
  var sidePanel = Reactix_React.createElement(Reactix_React.componentIsComponent)(sidePanelCpt);
  exports["listsLayout"] = listsLayout;
  exports["sidePanel"] = sidePanel;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Nodes.Texts"] = $PS["Gargantext.Components.Nodes.Texts"] || {};
  var exports = $PS["Gargantext.Components.Nodes.Texts"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Show = $PS["Data.Show"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect_Aff = $PS["Effect.Aff"];
  var Gargantext_Components_DocsTable = $PS["Gargantext.Components.DocsTable"];
  var Gargantext_Components_NgramsTable_Loader = $PS["Gargantext.Components.NgramsTable.Loader"];
  var Gargantext_Components_Node = $PS["Gargantext.Components.Node"];
  var Gargantext_Components_Nodes_Corpus = $PS["Gargantext.Components.Nodes.Corpus"];
  var Gargantext_Components_Nodes_Corpus_Chart_Histo = $PS["Gargantext.Components.Nodes.Corpus.Chart.Histo"];
  var Gargantext_Components_Nodes_Corpus_Document = $PS["Gargantext.Components.Nodes.Corpus.Document"];
  var Gargantext_Components_Nodes_Corpus_Types = $PS["Gargantext.Components.Nodes.Corpus.Types"];
  var Gargantext_Components_Nodes_Lists_Types = $PS["Gargantext.Components.Nodes.Lists.Types"];
  var Gargantext_Components_Tab = $PS["Gargantext.Components.Tab"];
  var Gargantext_Components_Table = $PS["Gargantext.Components.Table"];
  var Gargantext_Hooks_Loader = $PS["Gargantext.Hooks.Loader"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Nodes.Texts");
  var sidePanelDocViewCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              if (v.mSidePanel instanceof Data_Maybe.Nothing) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
              };
              if (v.mSidePanel instanceof Data_Maybe.Just) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Nodes_Corpus_Document.documentLayout({
                      listId: v.mSidePanel.value0.listId,
                      mCorpusId: new Data_Maybe.Just(v.mSidePanel.value0.corpusId),
                      nodeId: v.mSidePanel.value0.nodeId,
                      session: v.session
                  })([  ]));
              };
              throw new Error("Failed pattern match at Gargantext.Components.Nodes.Texts (line 411, column 5 - line 412, column 25): " + [ v.constructor.name, v1.constructor.name ]);
          };
      };
      return here.component("sidePanelDocView")(cpt);
  })();
  var sidePanelDocView = Reactix_React.createElement(Reactix_React.componentIsComponent)(sidePanelDocViewCpt);
  var sidePanelCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqSidePanelState_180"]))(v.sidePanelState))(function (sidePanelState$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "nodeId";
                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                      return "mCurrentDocId";
                  }))(Data_Maybe.eqMaybe(Data_Eq.eqInt)))()(new Data_Symbol.IsSymbol(function () {
                      return "listId";
                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                      return "corpusId";
                  }))(Data_Eq.eqInt)))))(v.sidePanel))(function (sidePanel$prime) {
                      var mainStyle = (function () {
                          if (sidePanelState$prime instanceof Gargantext_Types.Opened) {
                              return {
                                  display: "block"
                              };
                          };
                          return {
                              display: "none"
                          };
                      })();
                      var closeSidePanel = function (v2) {
                          return function __do() {
                              Toestand_Classes.write_(Toestand_Boxes.writeBox)(Gargantext_Types.Closed.value)(v.sidePanelState)();
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(Data_Maybe.Nothing.value)(v.sidePanel)();
                          };
                      };
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                          style: mainStyle
                      })([ Reactix_DOM_HTML.div({
                          className: "header"
                      })([ Reactix_DOM_HTML.span({
                          className: "btn btn-danger",
                          on: {
                              click: closeSidePanel
                          }
                      })([ Reactix_DOM_HTML.span({
                          className: "fa fa-times"
                      })([  ]) ]) ]), sidePanelDocView({
                          mSidePanel: sidePanel$prime,
                          session: v.session
                      })([  ]) ]));
                  });
              });
          };
      };
      return here.component("sidePanel")(cpt);
  })();
  var sidePanel = Reactix_React.createElement(Reactix_React.componentIsComponent)(sidePanelCpt);
  var docViewLayoutRec = function (v) {
      if (v.tabType instanceof Gargantext_Types.TabDocs) {
          return {
              cacheState: v.cacheState,
              chart: Reactix_DOM_HTML.div({})([  ]),
              frontends: v.frontends,
              listId: v.listId,
              mCorpusId: new Data_Maybe.Just(v.corpusId),
              nodeId: v.corpusId,
              session: v.session,
              showSearch: true,
              sidePanel: v.sidePanel,
              sidePanelState: v.sidePanelState,
              tabType: new Gargantext_Types.TabCorpus(Gargantext_Types.TabDocs.value),
              totalRecords: 4737
          };
      };
      if (v.tabType instanceof Gargantext_Types.TabMoreLikeFav) {
          return {
              cacheState: v.cacheState,
              chart: Reactix_DOM_HTML.div({})([  ]),
              frontends: v.frontends,
              listId: v.listId,
              mCorpusId: new Data_Maybe.Just(v.corpusId),
              nodeId: v.corpusId,
              session: v.session,
              showSearch: false,
              sidePanel: v.sidePanel,
              sidePanelState: v.sidePanelState,
              tabType: new Gargantext_Types.TabCorpus(Gargantext_Types.TabMoreLikeFav.value),
              totalRecords: 4737
          };
      };
      if (v.tabType instanceof Gargantext_Types.TabMoreLikeTrash) {
          return {
              cacheState: v.cacheState,
              chart: Reactix_DOM_HTML.div({})([  ]),
              frontends: v.frontends,
              listId: v.listId,
              mCorpusId: new Data_Maybe.Just(v.corpusId),
              nodeId: v.corpusId,
              session: v.session,
              showSearch: false,
              sidePanel: v.sidePanel,
              sidePanelState: v.sidePanelState,
              tabType: new Gargantext_Types.TabCorpus(Gargantext_Types.TabMoreLikeTrash.value),
              totalRecords: 4737
          };
      };
      if (v.tabType instanceof Gargantext_Types.TabTrash) {
          return {
              cacheState: v.cacheState,
              chart: Reactix_DOM_HTML.div({})([  ]),
              frontends: v.frontends,
              listId: v.listId,
              mCorpusId: new Data_Maybe.Just(v.corpusId),
              nodeId: v.corpusId,
              session: v.session,
              showSearch: true,
              sidePanel: v.sidePanel,
              sidePanelState: v.sidePanelState,
              tabType: new Gargantext_Types.TabCorpus(Gargantext_Types.TabTrash.value),
              totalRecords: 4737
          };
      };
      return {
          cacheState: v.cacheState,
          chart: Reactix_DOM_HTML.div({})([  ]),
          frontends: v.frontends,
          listId: v.listId,
          mCorpusId: new Data_Maybe.Just(v.corpusId),
          nodeId: v.corpusId,
          session: v.session,
          showSearch: true,
          sidePanel: v.sidePanel,
          sidePanelState: v.sidePanelState,
          tabType: new Gargantext_Types.TabCorpus(Gargantext_Types.TabTrash.value),
          totalRecords: 4737
      };
  };
  var docViewCpt = (function () {
      var cpt = function (props) {
          return function (_children) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_DocsTable.docViewLayout(docViewLayoutRec(props)));
          };
      };
      return here.component("docView")(cpt);
  })();
  var docView = Reactix_React.createElement(Reactix_React.componentIsComponent)(docViewCpt);
  var tabsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var initialPath = {
                  corpusId: v.corpusId,
                  listId: v.corpusData.defaultListId,
                  limit: Data_Maybe.Nothing.value,
                  tabType: new Gargantext_Types.TabCorpus(Gargantext_Types.TabDocs.value)
              };
              var docView$prime = function (path) {
                  return function (tabType) {
                      return docView({
                          cacheState: v.cacheState,
                          corpusData: v.corpusData,
                          corpusId: v.corpusId,
                          frontends: v.frontends,
                          listId: path.listId,
                          session: v.session,
                          tabType: tabType,
                          sidePanel: v.sidePanel,
                          sidePanelState: v.sidePanelState
                      })([  ]);
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(0))(function (activeTab) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Tab.tabs({
                      activeTab: activeTab,
                      tabs: [ new Data_Tuple.Tuple("Documents", Reactix_React.fragment([ Gargantext_Components_Nodes_Corpus_Chart_Histo.histo({
                          path: initialPath,
                          session: v.session
                      }), docView$prime(initialPath)(Gargantext_Types.TabDocs.value) ])), new Data_Tuple.Tuple("Trash", docView$prime(initialPath)(Gargantext_Types.TabTrash.value)) ]
                  }));
              });
          };
      };
      return here.component("tabs")(cpt);
  })();
  var tabs = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(tabsCpt)(props)([  ]);
  };
  var textsLayoutWithKeyCpt = (function () {
      var cpt = function (v) {
          return function (_children) {
              var afterCacheStateChange = function (cacheState) {
                  return Effect_Aff.launchAff_(Gargantext_Components_NgramsTable_Loader.clearCache(Data_Unit.unit));
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Sessions.getCacheState(Gargantext_Components_Nodes_Lists_Types.CacheOff.value)(v.session)(v.nodeId)))(function (cacheState) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Components_Nodes_Lists_Types["$_EqCacheState_4"]))(cacheState))(function (cacheState$prime) {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffectOnce'"](Toestand_Classes.listen(Toestand_Boxes.readBox)(function (v1) {
                          return afterCacheStateChange(v1["new"]);
                      })(cacheState)))(function () {
                          return Gargantext_Hooks_Loader.useLoader(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "session";
                          }))(Gargantext_Sessions_Types["$_EqSession_33"]))()(new Data_Symbol.IsSymbol(function () {
                              return "nodeId";
                          }))(Data_Eq.eqInt)))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                              return "defaultListId";
                          }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                              return "corpusNode";
                          }))(Gargantext_Components_Node["$_EqNodePoly_7"](Gargantext_Components_Nodes_Corpus_Types["$_EqHyperdata_8"])))()(new Data_Symbol.IsSymbol(function () {
                              return "corpusId";
                          }))(Data_Eq.eqInt)))({
                              nodeId: v.nodeId,
                              session: v.session
                          })(Gargantext_Components_Nodes_Corpus.loadCorpusWithChild)(function (v1) {
                              var v2 = Gargantext_Components_Nodes_Corpus_Types.getCorpusInfo(v1.corpusNode.hyperdata.fields);
                              var title = "Corpus " + v1.corpusNode.name;
                              return Reactix_React.fragment([ Gargantext_Components_Table.tableHeaderLayout({
                                  cacheState: cacheState,
                                  date: v1.corpusNode.date,
                                  desc: v2.desc,
                                  query: v2.query,
                                  title: title,
                                  user: v2.authors,
                                  key: "textsLayoutWithKey-" + Data_Show.show(Gargantext_Components_Nodes_Lists_Types["$_ShowCacheState_5"])(cacheState$prime)
                              })([  ]), tabs({
                                  cacheState: cacheState,
                                  corpusData: v1,
                                  corpusId: v1.corpusId,
                                  frontends: v.frontends,
                                  session: v.session,
                                  sidePanel: v.sidePanel,
                                  sidePanelState: v.sidePanelState
                              }) ]);
                          });
                      });
                  });
              });
          };
      };
      return here.component("textsLayoutWithKey")(cpt);
  })();
  var textsLayoutWithKey = Reactix_React.createElement(Reactix_React.componentIsComponent)(textsLayoutWithKeyCpt);
  var textsLayoutCpt = (function () {
      var cpt = function (v) {
          return function (children) {
              var key = Data_Show.show(Data_Show.showInt)(v.nodeId);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(textsLayoutWithKey({
                  frontends: v.frontends,
                  key: key,
                  nodeId: v.nodeId,
                  session: v.session,
                  sidePanel: v.sidePanel,
                  sidePanelState: v.sidePanelState
              })(children));
          };
      };
      return here.component("textsLayout")(cpt);
  })();
  var textsLayout = Reactix_React.createElement(Reactix_React.componentIsComponent)(textsLayoutCpt);
  exports["textsLayout"] = textsLayout;
  exports["sidePanel"] = sidePanel;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Themes"] = $PS["Gargantext.Components.Themes"] || {};
  var exports = $PS["Gargantext.Components.Themes"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Eq_Generic = $PS["Data.Eq.Generic"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Generic_Rep = $PS["Data.Generic.Rep"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var FFI_Simple_Objects = $PS["FFI.Simple.Objects"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Reactix_SyntheticEvent = $PS["Reactix.SyntheticEvent"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var themeName = function (v) {
      return v.name;
  };
  var stylesheetElId = "bootstrap-css";
  var switchTheme = function (v) {
      return function __do() {
          var mEl = Gargantext_Utils_Reactix.getElementById(stylesheetElId)();
          if (mEl instanceof Data_Maybe.Nothing) {
              return Data_Unit.unit;
          };
          if (mEl instanceof Data_Maybe.Just) {
              FFI_Simple_Objects["setProperty'"](mEl.value0)("href")(v.location);
              return Data_Unit.unit;
          };
          throw new Error("Failed pattern match at Gargantext.Components.Themes (line 57, column 3 - line 61, column 16): " + [ mEl.constructor.name ]);
      };
  };
  var monotonyTheme = {
      name: "monotony",
      location: "styles/bootstrap-monotony.css"
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Themes");
  var herbieTheme = {
      name: "herbie",
      location: "styles/bootstrap-herbie.css"
  };
  var greysonTheme = {
      name: "greyson",
      location: "styles/bootstrap-greyson.css"
  };
  var defaultTheme = {
      name: "default",
      location: "styles/bootstrap-default.css"
  };
  var darksterTheme = {
      name: "darkster (b\xeata)",
      location: "styles/bootstrap-darkster.css"
  };
  var allThemes = [ defaultTheme, greysonTheme, monotonyTheme, herbieTheme, darksterTheme ];
  var $dollar_GenericTheme__8 = new Data_Generic_Rep.Generic(function (x) {
      return x;
  }, function (x) {
      return x;
  });
  var $dollar_EqTheme_9 = new Data_Eq.Eq(Data_Eq_Generic.genericEq($dollar_GenericTheme__8)(Data_Eq_Generic.genericEqConstructor(Data_Eq_Generic.genericEqArgument(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
      return "name";
  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
      return "location";
  }))(Data_Eq.eqString))))));
  var themeSwitcherCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var onChange = function (currentTheme) {
                  return function (e) {
                      var value = Reactix_SyntheticEvent.unsafeEventValue(e);
                      var mTheme = Data_Array.head(Data_Array.filter(function (v2) {
                          return value === v2.name;
                      })(v.themes));
                      if (mTheme instanceof Data_Maybe.Nothing) {
                          return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                      };
                      if (mTheme instanceof Data_Maybe.Just) {
                          return function __do() {
                              switchTheme(mTheme.value0)();
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(mTheme.value0)(currentTheme)();
                          };
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Themes (line 89, column 11 - line 93, column 38): " + [ mTheme.constructor.name ]);
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(v.theme))(function (currentTheme) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal($dollar_EqTheme_9))(currentTheme))(function (currentTheme$prime) {
                      var option = function (v2) {
                          return Reactix_DOM_HTML.option({
                              value: v2.name
                          })([ Reactix_DOM_HTML.text(v2.name) ]);
                      };
                      var options = Data_Functor.map(Data_Functor.functorArray)(option)(v.themes);
                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Utils_Reactix.select({
                          className: "form-control",
                          defaultValue: themeName(currentTheme$prime),
                          on: {
                              change: onChange(currentTheme)
                          }
                      })(options));
                  });
              });
          };
      };
      return here.component("themeSwitcher")(cpt);
  })();
  var themeSwitcher = Reactix_React.createElement(Reactix_React.componentIsComponent)(themeSwitcherCpt);
  exports["defaultTheme"] = defaultTheme;
  exports["allThemes"] = allThemes;
  exports["themeSwitcher"] = themeSwitcher;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.TopBar"] = $PS["Gargantext.Components.TopBar"] || {};
  var exports = $PS["Gargantext.Components.TopBar"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_HeytingAlgebra = $PS["Data.HeytingAlgebra"];
  var Data_Monoid = $PS["Data.Monoid"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Gargantext_Components_GraphExplorer_ToggleButton = $PS["Gargantext.Components.GraphExplorer.ToggleButton"];
  var Gargantext_Components_Themes = $PS["Gargantext.Components.Themes"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var LiNav = (function () {
      function LiNav(value0) {
          this.value0 = value0;
      };
      LiNav.create = function (value0) {
          return new LiNav(value0);
      };
      return LiNav;
  })();
  var logo = Reactix_DOM_HTML.a({
      className: "navbar-brand logoSmall",
      href: "#/"
  })([ Reactix_DOM_HTML.img({
      src: "images/logoSmall.png",
      title: "Back home.",
      width: "30",
      height: "28"
  }) ]);
  var liNav = function (v) {
      return Reactix_DOM_HTML.li({
          className: "dropdown-item"
      })([ Reactix_DOM_HTML.a({
          tabIndex: -1 | 0,
          target: "blank",
          title: v.value0.title,
          href: v.value0.href
      })([ Reactix_DOM_HTML.span({
          className: v.value0.icon
      })([  ]), Reactix_DOM_HTML.text(" " + v.value0.text) ]) ]);
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.TopBar");
  var menuButtonCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.a({
                  className: "dropdown-toggle navbar-text",
                  title: v.element.value0.title,
                  on: {
                      click: function (v2) {
                          return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Data_HeytingAlgebra.not(Data_HeytingAlgebra.heytingAlgebraBoolean))(v.show);
                      }
                  },
                  role: "button"
              })([ Reactix_DOM_HTML.span({
                  aria: {
                      hidden: true
                  },
                  className: v.element.value0.icon
              })([  ]), Reactix_DOM_HTML.text(" " + v.element.value0.text) ]));
          };
      };
      return here.component("menuButton")(cpt);
  })();
  var menuButton = Reactix_React.createElement(Reactix_React.componentIsComponent)(menuButtonCpt);
  var menuElementsCpt = (function () {
      var divider = [ Reactix_DOM_HTML.li({
          className: "dropdown-divider"
      })([  ]) ];
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.show))(function (show$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)((function () {
                      if (show$prime) {
                          return Reactix_DOM_HTML.ul({
                              className: "dropdown-menu",
                              on: {
                                  click: function (v2) {
                                      return Toestand_Classes.write_(Toestand_Boxes.writeBox)(false)(v.show);
                                  }
                              },
                              style: {
                                  display: "block"
                              }
                          })(Data_Foldable.intercalate(Data_Foldable.foldableArray)(Data_Monoid.monoidArray)(divider)(Data_Functor.map(Data_Functor.functorArray)(Data_Functor.map(Data_Functor.functorArray)(liNav))(v.elements)));
                      };
                      return Reactix_DOM_HTML.div({})([  ]);
                  })());
              });
          };
      };
      return here.component("menuElements")(cpt);
  })();
  var menuElements = Reactix_React.createElement(Reactix_React.componentIsComponent)(menuElementsCpt);
  var handedChooserCpt = (function () {
      var onClick = function (handed) {
          return Toestand_Classes.modify_(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(function (h) {
              if (h instanceof Gargantext_Types.LeftHanded) {
                  return Gargantext_Types.RightHanded.value;
              };
              if (h instanceof Gargantext_Types.RightHanded) {
                  return Gargantext_Types.LeftHanded.value;
              };
              throw new Error("Failed pattern match at Gargantext.Components.TopBar (line 252, column 39 - line 254, column 32): " + [ h.constructor.name ]);
          })(handed);
      };
      var handedClass = function (v) {
          if (v instanceof Gargantext_Types.LeftHanded) {
              return "fa fa-hand-o-left";
          };
          if (v instanceof Gargantext_Types.RightHanded) {
              return "fa fa-hand-o-right";
          };
          throw new Error("Failed pattern match at Gargantext.Components.TopBar (line 249, column 5 - line 249, column 49): " + [ v.constructor.name ]);
      };
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqHanded_94"]))(v.handed))(function (handed$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.a({
                      className: "nav-link"
                  })([ Reactix_DOM_HTML.span({
                      className: handedClass(handed$prime),
                      on: {
                          click: onClick(v.handed)
                      }
                  })([  ]) ]));
              });
          };
      };
      return here.component("handedChooser")(cpt);
  })();
  var handedChooser = Reactix_React.createElement(Reactix_React.componentIsComponent)(handedChooserCpt);
  var divDropdownLeftCpt = (function () {
      var menuElement = new LiNav({
          title: "About Gargantext",
          href: "#",
          icon: "fa fa-info-circle",
          text: "Info"
      });
      var elements = [ [ new LiNav({
          title: "Quick start, tutorials and methodology",
          href: "https://iscpif.fr/gargantext/your-first-map/",
          icon: "fa fa-lightbulb-o",
          text: "Tutorials"
      }), new LiNav({
          title: "Report bug here",
          href: "https://www.iscpif.fr/gargantext/feedback-and-bug-reports/",
          icon: "fa fa-bullhorn",
          text: "Feedback"
      }) ], [ new LiNav({
          title: "Chat",
          href: "https://chat.iscpif.fr/channel/gargantext",
          icon: "fa fa-rocket",
          text: "Chat"
      }), new LiNav({
          title: "Forums",
          href: "https://discourse.iscpif.fr/c/gargantext",
          icon: "fa fa-weixin",
          text: "Forum"
      }) ], [ new LiNav({
          title: "Code documentation",
          href: "https://doc.gargantext.org",
          icon: "fa fa-book",
          text: "Source Code Documentation"
      }), new LiNav({
          title: "API documentation",
          href: "https://v4.gargantext.org/swagger-ui",
          icon: "fa fa-code-fork",
          text: "API documentation"
      }), new LiNav({
          title: "Source code",
          href: "https://gitlab.iscpif.fr/gargantext/haskell-gargantext",
          icon: "fa fa-code",
          text: "Source Code"
      }) ], [ new LiNav({
          title: "More about us (you)",
          href: "https://iscpif.fr",
          icon: "fa fa-question",
          text: "About"
      }) ] ];
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(false))(function (show) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.li({
                      className: "nav-item dropdown"
                  })([ menuButton({
                      element: menuElement,
                      show: show
                  })([  ]), menuElements({
                      elements: elements,
                      show: show
                  })([  ]) ]));
              });
          };
      };
      return here.component("divDropdownLeft")(cpt);
  })();
  var divDropdownLeft = Reactix_React.createElement(Reactix_React.componentIsComponent)(divDropdownLeftCpt);
  var topBarCpt = (function () {
      var cpt = function (v) {
          return function (children) {
              var smiley = Reactix_DOM_HTML.li({
                  title: "Hello! Looking for the tree ?\x0a" + ("Just watch on the other side!\x0a" + "Click on the hand again to see it back."),
                  className: "nav-item"
              })([ Reactix_DOM_HTML.a({
                  className: "nav-link"
              })([ Reactix_DOM_HTML.span({
                  className: "fa fa-question-circle-o"
              })([  ]) ]) ]);
              var handButton = function (handed$prime) {
                  return Reactix_DOM_HTML.li({
                      title: "If you are Left Handed you can change\x0a" + ("the interface by clicking on me. Click\x0a" + "again to come back to previous state."),
                      className: "nav-item"
                  })([ handedChooser({
                      handed: v.handed
                  })([  ]) ]);
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqHanded_94"]))(v.handed))(function (handed$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({
                      className: "navbar navbar-expand-lg navbar-dark bg-dark fixed-top",
                      id: "dafixedtop",
                      role: "navigation"
                  })([ Reactix_DOM_HTML.div({
                      className: "container-fluid"
                  })(Gargantext_Types.reverseHanded(handed$prime)([ logo, Reactix_DOM_HTML.div({
                      className: "collapse navbar-collapse"
                  })([ Reactix_DOM_HTML.ul({
                      className: "navbar-nav " + (function () {
                          var $42 = Data_Eq.eq(Gargantext_Types["$_EqHanded_94"])(handed$prime)(Gargantext_Types.LeftHanded.value);
                          if ($42) {
                              return "ml-auto";
                          };
                          return "";
                      })()
                  })(Gargantext_Types.reverseHanded(handed$prime)(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ divDropdownLeft({})([  ]), handButton(handed$prime), smiley, Reactix_DOM_HTML.li({
                      className: "nav-item"
                  })([ Gargantext_Components_Themes.themeSwitcher({
                      theme: Gargantext_Components_Themes.defaultTheme,
                      themes: Gargantext_Components_Themes.allThemes
                  })([  ]) ]), Gargantext_Components_GraphExplorer_ToggleButton.treeToggleButton({
                      state: v.showTree
                  })([  ]) ])(children))) ]) ])) ]));
              });
          };
      };
      return here.component("topBar")(cpt);
  })();
  var topBar = Reactix_React.createElement(Reactix_React.componentIsComponent)(topBarCpt);
  exports["topBar"] = topBar;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.Router"] = $PS["Gargantext.Components.Router"] || {};
  var exports = $PS["Gargantext.Components.Router"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Eq = $PS["Data.Eq"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_NonEmpty = $PS["Data.NonEmpty"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Effect = $PS["Effect"];
  var Gargantext_Components_Footer = $PS["Gargantext.Components.Footer"];
  var Gargantext_Components_Forest = $PS["Gargantext.Components.Forest"];
  var Gargantext_Components_GraphExplorer = $PS["Gargantext.Components.GraphExplorer"];
  var Gargantext_Components_GraphExplorer_Sidebar = $PS["Gargantext.Components.GraphExplorer.Sidebar"];
  var Gargantext_Components_GraphExplorer_Sidebar_Types = $PS["Gargantext.Components.GraphExplorer.Sidebar.Types"];
  var Gargantext_Components_GraphExplorer_TopBar = $PS["Gargantext.Components.GraphExplorer.TopBar"];
  var Gargantext_Components_GraphExplorer_Types = $PS["Gargantext.Components.GraphExplorer.Types"];
  var Gargantext_Components_Lang = $PS["Gargantext.Components.Lang"];
  var Gargantext_Components_Login = $PS["Gargantext.Components.Login"];
  var Gargantext_Components_MainPage = $PS["Gargantext.Components.MainPage"];
  var Gargantext_Components_Nodes_Annuaire = $PS["Gargantext.Components.Nodes.Annuaire"];
  var Gargantext_Components_Nodes_Annuaire_User = $PS["Gargantext.Components.Nodes.Annuaire.User"];
  var Gargantext_Components_Nodes_Annuaire_User_Contact = $PS["Gargantext.Components.Nodes.Annuaire.User.Contact"];
  var Gargantext_Components_Nodes_Corpus = $PS["Gargantext.Components.Nodes.Corpus"];
  var Gargantext_Components_Nodes_Corpus_Dashboard = $PS["Gargantext.Components.Nodes.Corpus.Dashboard"];
  var Gargantext_Components_Nodes_Corpus_Document = $PS["Gargantext.Components.Nodes.Corpus.Document"];
  var Gargantext_Components_Nodes_Corpus_Phylo = $PS["Gargantext.Components.Nodes.Corpus.Phylo"];
  var Gargantext_Components_Nodes_File = $PS["Gargantext.Components.Nodes.File"];
  var Gargantext_Components_Nodes_Frame = $PS["Gargantext.Components.Nodes.Frame"];
  var Gargantext_Components_Nodes_Home = $PS["Gargantext.Components.Nodes.Home"];
  var Gargantext_Components_Nodes_Lists = $PS["Gargantext.Components.Nodes.Lists"];
  var Gargantext_Components_Nodes_Texts = $PS["Gargantext.Components.Nodes.Texts"];
  var Gargantext_Components_TopBar = $PS["Gargantext.Components.TopBar"];
  var Gargantext_Config = $PS["Gargantext.Config"];
  var Gargantext_Hooks_Sigmax_Types = $PS["Gargantext.Hooks.Sigmax.Types"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_DOM_HTML = $PS["Reactix.DOM.HTML"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Record = $PS["Record"];
  var Record_Extra = $PS["Record.Extra"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Changes = $PS["Toestand.Changes"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var login$prime = function (v) {
      return Gargantext_Components_Login.login({
          backend: v.backend,
          backends: Data_Array.fromFoldable(Data_NonEmpty.foldableNonEmpty(Data_Foldable.foldableArray))(Gargantext_Config.defaultBackends),
          sessions: v.sessions,
          visible: v.showLogin
      });
  };
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.Router");
  var homeCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Nodes_Home.homeLayout(Toestand_Boxes.readBox)(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))({
                  backend: v.boxes.backend,
                  lang: Gargantext_Components_Lang.LL_EN.value,
                  sessions: v.boxes.sessions,
                  showLogin: v.boxes.showLogin,
                  tasks: v.boxes.tasks,
                  reloadForest: v.boxes.reloadForest
              }));
          };
      };
      return here.component("home")(cpt);
  })();
  var home = Reactix_React.createElement(Reactix_React.componentIsComponent)(homeCpt);
  var loginModalCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Eq.eqBoolean))(v.boxes.showLogin))(function (showLogin$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)((function () {
                      if (showLogin$prime) {
                          return login$prime(v.boxes);
                      };
                      return Reactix_DOM_HTML.div({})([  ]);
                  })());
              });
          };
      };
      return here.component("loginModal")(cpt);
  })();
  var loginModal = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(loginModalCpt)(p)([  ]);
  };
  var openedSidePanelCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Gargantext_Components_GraphExplorer_Sidebar_Types.focusedSidePanel(v.boxes.sidePanelGraph))(function (v2) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Gargantext_Hooks_Sigmax_Types["$_EqGraph_32"](Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "y";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "x";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "type";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "size";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "label";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "id";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "hidden";
                  }))(Data_Eq.eqBoolean))()(new Data_Symbol.IsSymbol(function () {
                      return "gargType";
                  }))(Gargantext_Types["$_EqMode_154"]))()(new Data_Symbol.IsSymbol(function () {
                      return "equilateral";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "numPoints";
                  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                      return "color";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "borderColor";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "_original";
                  }))(Gargantext_Components_GraphExplorer_Types["$_EqNode_43"])))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "weightIdx";
                  }))(Data_Eq.eqInt))()(new Data_Symbol.IsSymbol(function () {
                      return "weight";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "targetNode";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "y";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "x";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "type";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "size";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "label";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "id";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "hidden";
                  }))(Data_Eq.eqBoolean))()(new Data_Symbol.IsSymbol(function () {
                      return "gargType";
                  }))(Gargantext_Types["$_EqMode_154"]))()(new Data_Symbol.IsSymbol(function () {
                      return "equilateral";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "numPoints";
                  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                      return "color";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "borderColor";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "_original";
                  }))(Gargantext_Components_GraphExplorer_Types["$_EqNode_43"]))))()(new Data_Symbol.IsSymbol(function () {
                      return "target";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "sourceNode";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "y";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "x";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "type";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "size";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "label";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "id";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "hidden";
                  }))(Data_Eq.eqBoolean))()(new Data_Symbol.IsSymbol(function () {
                      return "gargType";
                  }))(Gargantext_Types["$_EqMode_154"]))()(new Data_Symbol.IsSymbol(function () {
                      return "equilateral";
                  }))(Data_Eq.eqRec()(Data_Eq.eqRowCons(Data_Eq.eqRowNil)()(new Data_Symbol.IsSymbol(function () {
                      return "numPoints";
                  }))(Data_Eq.eqInt))))()(new Data_Symbol.IsSymbol(function () {
                      return "color";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "borderColor";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "_original";
                  }))(Gargantext_Components_GraphExplorer_Types["$_EqNode_43"]))))()(new Data_Symbol.IsSymbol(function () {
                      return "source";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "size";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "id";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "hidden";
                  }))(Data_Eq.eqBoolean))()(new Data_Symbol.IsSymbol(function () {
                      return "confluence";
                  }))(Data_Eq.eqNumber))()(new Data_Symbol.IsSymbol(function () {
                      return "color";
                  }))(Data_Eq.eqString))()(new Data_Symbol.IsSymbol(function () {
                      return "_original";
                  }))(Gargantext_Components_GraphExplorer_Types["$_EqEdge_54"]))))))(v2.mGraph))(function (mGraph$prime) {
                      return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Gargantext_Components_GraphExplorer_Types["$_EqMetaData_67"])))(v2.mMetaData))(function (mGraphMetaData$prime) {
                          return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Routes["$_EqAppRoute_99"]))(v.boxes.route))(function (route$prime) {
                              var wrapper = Reactix_DOM_HTML.div({
                                  className: "side-panel"
                              });
                              if (route$prime instanceof Gargantext_Routes.Lists) {
                                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(wrapper([ Gargantext_Components_Nodes_Lists.sidePanel({
                                      session: v.session,
                                      sidePanel: v.boxes.sidePanelLists,
                                      sidePanelState: v.boxes.sidePanelState
                                  })([  ]) ]));
                              };
                              if (route$prime instanceof Gargantext_Routes.PGraphExplorer) {
                                  var v3 = new Data_Tuple.Tuple(mGraph$prime, mGraphMetaData$prime);
                                  if (v3.value0 instanceof Data_Maybe.Nothing) {
                                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(wrapper([  ]));
                                  };
                                  if (v3.value1 instanceof Data_Maybe.Nothing) {
                                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(wrapper([  ]));
                                  };
                                  if (v3.value0 instanceof Data_Maybe.Just && v3.value1 instanceof Data_Maybe.Just) {
                                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(wrapper([ Gargantext_Components_GraphExplorer_Sidebar.sidebar({
                                          frontends: Gargantext_Config.defaultFrontends,
                                          graph: v3.value0.value0,
                                          graphId: route$prime.value1,
                                          graphVersion: v.boxes.graphVersion,
                                          metaData: v3.value1.value0,
                                          reloadForest: v.boxes.reloadForest,
                                          removedNodeIds: v2.removedNodeIds,
                                          selectedNodeIds: v2.selectedNodeIds,
                                          session: v.session,
                                          sideTab: v2.sideTab
                                      })([  ]) ]));
                                  };
                                  throw new Error("Failed pattern match at Gargantext.Components.Router (line 245, column 9 - line 260, column 35): " + [ v3.constructor.name ]);
                              };
                              if (route$prime instanceof Gargantext_Routes.Texts) {
                                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(wrapper([ Gargantext_Components_Nodes_Texts.sidePanel({
                                      session: v.session,
                                      sidePanel: v.boxes.sidePanelTexts,
                                      sidePanelState: v.boxes.sidePanelState
                                  })([  ]) ]));
                              };
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)(wrapper([  ]));
                          });
                      });
                  });
              });
          };
      };
      return here.component("openedSidePanel")(cpt);
  })();
  var openedSidePanel = Reactix_React.createElement(Reactix_React.componentIsComponent)(openedSidePanelCpt);
  var sidePanelCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Data_Maybe.eqMaybe(Gargantext_Sessions_Types["$_EqSession_33"])))(v.boxes.session))(function (session$prime) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqSidePanelState_180"]))(v.boxes.sidePanelState))(function (sidePanelState$prime) {
                      if (session$prime instanceof Data_Maybe.Nothing) {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
                      };
                      if (session$prime instanceof Data_Maybe.Just) {
                          if (sidePanelState$prime instanceof Gargantext_Types.Opened) {
                              return Control_Applicative.pure(Reactix_React.applicativeHooks)(openedSidePanel(Record.merge()()({
                                  session: session$prime.value0
                              })(v))([  ]));
                          };
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_DOM_HTML.div({})([  ]));
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Router (line 153, column 5 - line 158, column 39): " + [ session$prime.constructor.name ]);
                  });
              });
          };
      };
      return here.component("sidePanel")(cpt);
  })();
  var sidePanel = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(sidePanelCpt)(p)([  ]);
  };
  var topBarCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Routes["$_EqAppRoute_99"]))(v.boxes.route))(function (route$prime) {
                  var children = (function () {
                      if (route$prime instanceof Gargantext_Routes.PGraphExplorer) {
                          return [ Gargantext_Components_GraphExplorer_TopBar.topBar({
                              boxes: v.boxes
                          }) ];
                      };
                      return [  ];
                  })();
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_TopBar.topBar({
                      handed: v.boxes.handed,
                      showTree: v.boxes.showTree
                  })(children));
              });
          };
      };
      return here.component("topBar")(cpt);
  })();
  var topBar = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(topBarCpt)(p)([  ]);
  };
  var forestCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Forest.forestLayout({
                  backend: v.boxes.backend,
                  forestOpen: v.boxes.forestOpen,
                  frontends: Gargantext_Config.defaultFrontends,
                  handed: v.boxes.handed,
                  reloadForest: v.boxes.reloadForest,
                  reloadMainPage: v.boxes.reloadMainPage,
                  reloadRoot: v.boxes.reloadRoot,
                  route: v.boxes.route,
                  sessions: v.boxes.sessions,
                  showLogin: v.boxes.showLogin,
                  showTree: v.boxes.showTree,
                  tasks: v.boxes.tasks
              })([  ]));
          };
      };
      return here.component("forest")(cpt);
  })();
  var forest = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(forestCpt)(p)([  ]);
  };
  var authedCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var homeProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.nilKeys))(v);
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Sessions_Types["$_EqSessions_42"]))(v.boxes.sessions))(function (sessions$prime) {
                  var session$prime = Gargantext_Sessions_Types.lookup(v.sessionId)(sessions$prime);
                  return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffect'"](Toestand_Classes.write_(Toestand_Boxes.writeBox)(session$prime)(v.boxes.session)))(function () {
                      if (session$prime instanceof Data_Maybe.Nothing) {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(home(homeProps)([  ]));
                      };
                      if (session$prime instanceof Data_Maybe.Just) {
                          return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ v.content(session$prime.value0), Gargantext_Components_Footer.footer({})([  ]) ]));
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Router (line 213, column 5 - line 215, column 63): " + [ session$prime.constructor.name ]);
                  });
              });
          };
      };
      return here.component("authed")(cpt);
  })();
  var authed = Reactix_React.createElement(Reactix_React.componentIsComponent)(authedCpt);
  var contactCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              var forestedProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.nilKeys))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Annuaire_User_Contact.contactLayout({
                          annuaireId: v.annuaireId,
                          frontends: Gargantext_Config.defaultFrontends,
                          nodeId: v.nodeId,
                          reloadForest: v.boxes.reloadForest,
                          reloadRoot: v.boxes.reloadRoot,
                          session: session,
                          sidePanel: v.boxes.sidePanelTexts,
                          sidePanelState: v.boxes.sidePanelState,
                          tasks: v.boxes.tasks
                      })([  ]);
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("contact")(cpt);
  })();
  var contact = Reactix_React.createElement(Reactix_React.componentIsComponent)(contactCpt);
  var corpusCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Corpus.corpusLayout({
                          nodeId: v.nodeId,
                          session: session,
                          tasks: v.boxes.tasks,
                          reloadForest: v.boxes.reloadForest
                      });
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("corpus")(cpt);
  })();
  var corpus = Reactix_React.createElement(Reactix_React.componentIsComponent)(corpusCpt);
  var corpusDocumentCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Corpus_Document.documentMainLayout({
                          mCorpusId: new Data_Maybe.Just(v.corpusId),
                          listId: v.listId,
                          nodeId: v.nodeId,
                          session: session
                      })([  ]);
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("corpusDocument")(cpt);
  })();
  var corpusDocument = Reactix_React.createElement(Reactix_React.componentIsComponent)(corpusDocumentCpt);
  var dashboardCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Corpus_Dashboard.dashboardLayout({
                          nodeId: v.nodeId,
                          session: session
                      })([  ]);
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("dashboard")(cpt);
  })();
  var dashboard = Reactix_React.createElement(Reactix_React.componentIsComponent)(dashboardCpt);
  var documentCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Corpus_Document.documentMainLayout({
                          listId: v.listId,
                          nodeId: v.nodeId,
                          mCorpusId: Data_Maybe.Nothing.value,
                          session: session
                      })([  ]);
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("document")(cpt);
  })();
  var document = Reactix_React.createElement(Reactix_React.componentIsComponent)(documentCpt);
  var graphExplorerCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_GraphExplorer.explorerLayout({
                          boxes: v.boxes,
                          graphId: v.nodeId,
                          session: session
                      })([  ]);
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("graphExplorer")(cpt);
  })();
  var graphExplorer = Reactix_React.createElement(Reactix_React.componentIsComponent)(graphExplorerCpt);
  var listsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Lists.listsLayout({
                          nodeId: v.nodeId,
                          reloadForest: v.boxes.reloadForest,
                          reloadMainPage: v.boxes.reloadMainPage,
                          reloadRoot: v.boxes.reloadRoot,
                          session: session,
                          sessionUpdate: function (v2) {
                              return Control_Applicative.pure(Effect.applicativeEffect)(Data_Unit.unit);
                          },
                          sidePanel: v.boxes.sidePanelLists,
                          sidePanelState: v.boxes.sidePanelState,
                          tasks: v.boxes.tasks
                      })([  ]);
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("lists")(cpt);
  })();
  var lists = Reactix_React.createElement(Reactix_React.componentIsComponent)(listsCpt);
  var phyloExplorerCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Corpus_Phylo.phyloLayout({
                          nodeId: v.nodeId,
                          session: session
                      })([  ]);
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("phylo")(cpt);
  })();
  var phyloExplorer = Reactix_React.createElement(Reactix_React.componentIsComponent)(phyloExplorerCpt);
  var routeFileCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_File.fileLayout({
                          nodeId: v.nodeId,
                          session: session
                      });
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("routeFile")(cpt);
  })();
  var routeFile = Reactix_React.createElement(Reactix_React.componentIsComponent)(routeFileCpt);
  var routeFrameCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Frame.frameLayout({
                          nodeId: v.nodeId,
                          nodeType: v.nodeType,
                          session: session
                      });
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("routeFrame")(cpt);
  })();
  var routeFrame = Reactix_React.createElement(Reactix_React.componentIsComponent)(routeFrameCpt);
  var teamCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Corpus.corpusLayout({
                          nodeId: v.nodeId,
                          session: session,
                          tasks: v.boxes.tasks,
                          reloadForest: v.boxes.reloadForest
                      });
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("team")(cpt);
  })();
  var team = Reactix_React.createElement(Reactix_React.componentIsComponent)(teamCpt);
  var textsCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Texts.textsLayout({
                          frontends: Gargantext_Config.defaultFrontends,
                          nodeId: v.nodeId,
                          session: session,
                          sidePanel: v.boxes.sidePanelTexts,
                          sidePanelState: v.boxes.sidePanelState
                      })([  ]);
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("texts")(cpt);
  })();
  var texts = Reactix_React.createElement(Reactix_React.componentIsComponent)(textsCpt);
  var userCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Annuaire_User.userLayout({
                          frontends: Gargantext_Config.defaultFrontends,
                          nodeId: v.nodeId,
                          reloadForest: v.boxes.reloadForest,
                          reloadRoot: v.boxes.reloadRoot,
                          session: session,
                          sidePanel: v.boxes.sidePanelTexts,
                          sidePanelState: v.boxes.sidePanelState,
                          tasks: v.boxes.tasks
                      })([  ]);
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("user")(cpt);
  })();
  var user = Reactix_React.createElement(Reactix_React.componentIsComponent)(userCpt);
  var annuaireCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionProps = Record_Extra.pick()()(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "boxes";
              }))(Record_Extra.consKeys(new Data_Symbol.IsSymbol(function () {
                  return "sessionId";
              }))(Record_Extra.nilKeys)))(v);
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(authed(Record.merge()()({
                  content: function (session) {
                      return Gargantext_Components_Nodes_Annuaire.annuaireLayout({
                          frontends: Gargantext_Config.defaultFrontends,
                          nodeId: v.nodeId,
                          session: session
                      });
                  }
              })(sessionProps))([  ]));
          };
      };
      return here.component("annuaire")(cpt);
  })();
  var annuaire = Reactix_React.createElement(Reactix_React.componentIsComponent)(annuaireCpt);
  var renderRouteCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              var sessionNodeProps = function (sId) {
                  return function (nId) {
                      return Record.merge()()({
                          nodeId: nId,
                          sessionId: sId
                      })(v);
                  };
              };
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Routes["$_EqAppRoute_99"]))(v.boxes.route))(function (route$prime) {
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment([ (function () {
                      if (route$prime instanceof Gargantext_Routes.Annuaire) {
                          return annuaire(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.ContactPage) {
                          return contact(Record.merge()()({
                              annuaireId: route$prime.value1
                          })(sessionNodeProps(route$prime.value0)(route$prime.value2)))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.Corpus) {
                          return corpus(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.CorpusDocument) {
                          return corpusDocument(Record.merge()()({
                              corpusId: route$prime.value1,
                              listId: route$prime.value2
                          })(sessionNodeProps(route$prime.value0)(route$prime.value3)))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.Dashboard) {
                          return dashboard(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.Document) {
                          return document(Record.merge()()({
                              listId: route$prime.value1
                          })(sessionNodeProps(route$prime.value0)(route$prime.value2)))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.Folder) {
                          return corpus(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.FolderPrivate) {
                          return corpus(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.FolderPublic) {
                          return corpus(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.FolderShared) {
                          return corpus(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.Home) {
                          return home({
                              boxes: v.boxes
                          })([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.Lists) {
                          return lists(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.Login) {
                          return login$prime(v.boxes);
                      };
                      if (route$prime instanceof Gargantext_Routes.PGraphExplorer) {
                          return graphExplorer(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.PhyloExplorer) {
                          return phyloExplorer(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.RouteFile) {
                          return routeFile(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.RouteFrameWrite) {
                          return routeFrame(Record.merge()()({
                              nodeType: Gargantext_Types.NodeFrameWrite.value
                          })(sessionNodeProps(route$prime.value0)(route$prime.value1)))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.RouteFrameCalc) {
                          return routeFrame(Record.merge()()({
                              nodeType: Gargantext_Types.NodeFrameCalc.value
                          })(sessionNodeProps(route$prime.value0)(route$prime.value1)))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.RouteFrameCode) {
                          return routeFrame(Record.merge()()({
                              nodeType: Gargantext_Types.NodeFrameNotebook.value
                          })(sessionNodeProps(route$prime.value0)(route$prime.value1)))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.RouteFrameVisio) {
                          return routeFrame(Record.merge()()({
                              nodeType: Gargantext_Types.NodeFrameVisio.value
                          })(sessionNodeProps(route$prime.value0)(route$prime.value1)))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.Team) {
                          return team(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.Texts) {
                          return texts(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      if (route$prime instanceof Gargantext_Routes.UserPage) {
                          return user(sessionNodeProps(route$prime.value0)(route$prime.value1))([  ]);
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Router (line 170, column 9 - line 193, column 68): " + [ route$prime.constructor.name ]);
                  })() ]));
              });
          };
      };
      return here.component("renderRoute")(cpt);
  })();
  var renderRoute = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(renderRouteCpt)(p)([  ]);
  };
  var mainPageCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_MainPage.mainPage({
                  boxes: v.boxes
              })([ renderRoute({
                  boxes: v.boxes
              }) ]));
          };
      };
      return here.component("mainPage")(cpt);
  })();
  var mainPage = function (p) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(mainPageCpt)(p)([  ]);
  };
  var routerCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useLive(Toestand_Boxes.readBox)(Toestand_Changes.unequal(Gargantext_Types["$_EqHanded_94"]))(v.boxes.handed))(function (handed$prime) {
                  var handedClassName = (function () {
                      if (handed$prime instanceof Gargantext_Types.LeftHanded) {
                          return "left-handed";
                      };
                      if (handed$prime instanceof Gargantext_Types.RightHanded) {
                          return "right-handed";
                      };
                      throw new Error("Failed pattern match at Gargantext.Components.Router (line 64, column 27 - line 66, column 40): " + [ handed$prime.constructor.name ]);
                  })();
                  return Control_Applicative.pure(Reactix_React.applicativeHooks)(Reactix_React.fragment(Data_Semigroup.append(Data_Semigroup.semigroupArray)([ loginModal({
                      boxes: v.boxes
                  }), topBar({
                      boxes: v.boxes
                  }) ])([ Reactix_DOM_HTML.div({
                      className: handedClassName
                  })(Gargantext_Types.reverseHanded(handed$prime)([ forest({
                      boxes: v.boxes
                  }), mainPage({
                      boxes: v.boxes
                  }), sidePanel({
                      boxes: v.boxes
                  }) ])) ])));
              });
          };
      };
      return here.component("router")(cpt);
  })();
  var router = function (props) {
      return Reactix_React.createElement(Reactix_React.componentIsComponent)(routerCpt)(props)([  ]);
  };
  exports["router"] = router;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Routing.Match.Error"] = $PS["Routing.Match.Error"] || {};
  var exports = $PS["Routing.Match.Error"];
  var UnexpectedPath = (function () {
      function UnexpectedPath(value0) {
          this.value0 = value0;
      };
      UnexpectedPath.create = function (value0) {
          return new UnexpectedPath(value0);
      };
      return UnexpectedPath;
  })();
  var ExpectedBoolean = (function () {
      function ExpectedBoolean() {

      };
      ExpectedBoolean.value = new ExpectedBoolean();
      return ExpectedBoolean;
  })();
  var ExpectedEnd = (function () {
      function ExpectedEnd() {

      };
      ExpectedEnd.value = new ExpectedEnd();
      return ExpectedEnd;
  })();
  var ExpectedNumber = (function () {
      function ExpectedNumber() {

      };
      ExpectedNumber.value = new ExpectedNumber();
      return ExpectedNumber;
  })();
  var ExpectedInt = (function () {
      function ExpectedInt() {

      };
      ExpectedInt.value = new ExpectedInt();
      return ExpectedInt;
  })();
  var ExpectedString = (function () {
      function ExpectedString() {

      };
      ExpectedString.value = new ExpectedString();
      return ExpectedString;
  })();
  var ExpectedQuery = (function () {
      function ExpectedQuery() {

      };
      ExpectedQuery.value = new ExpectedQuery();
      return ExpectedQuery;
  })();
  var ExpectedPathPart = (function () {
      function ExpectedPathPart() {

      };
      ExpectedPathPart.value = new ExpectedPathPart();
      return ExpectedPathPart;
  })();
  var KeyNotFound = (function () {
      function KeyNotFound(value0) {
          this.value0 = value0;
      };
      KeyNotFound.create = function (value0) {
          return new KeyNotFound(value0);
      };
      return KeyNotFound;
  })();
  var Fail = (function () {
      function Fail(value0) {
          this.value0 = value0;
      };
      Fail.create = function (value0) {
          return new Fail(value0);
      };
      return Fail;
  })();
  var showMatchError = function (err) {
      if (err instanceof UnexpectedPath) {
          return "expected path part: " + err.value0;
      };
      if (err instanceof KeyNotFound) {
          return "key: " + (err.value0 + " has not found in query part");
      };
      if (err instanceof ExpectedQuery) {
          return "expected query - found path";
      };
      if (err instanceof ExpectedNumber) {
          return "expected number";
      };
      if (err instanceof ExpectedInt) {
          return "expected int";
      };
      if (err instanceof ExpectedBoolean) {
          return "expected boolean";
      };
      if (err instanceof ExpectedEnd) {
          return "expected end";
      };
      if (err instanceof ExpectedString) {
          return "expected string var";
      };
      if (err instanceof ExpectedPathPart) {
          return "expected path part, found query";
      };
      if (err instanceof Fail) {
          return "match error: " + err.value0;
      };
      throw new Error("Failed pattern match at Routing.Match.Error (line 29, column 3 - line 39, column 39): " + [ err.constructor.name ]);
  };
  exports["UnexpectedPath"] = UnexpectedPath;
  exports["ExpectedNumber"] = ExpectedNumber;
  exports["ExpectedString"] = ExpectedString;
  exports["ExpectedPathPart"] = ExpectedPathPart;
  exports["showMatchError"] = showMatchError;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Routing.Types"] = $PS["Routing.Types"] || {};
  var exports = $PS["Routing.Types"];                      
  var Path = (function () {
      function Path(value0) {
          this.value0 = value0;
      };
      Path.create = function (value0) {
          return new Path(value0);
      };
      return Path;
  })();
  var Query = (function () {
      function Query(value0) {
          this.value0 = value0;
      };
      Query.create = function (value0) {
          return new Query(value0);
      };
      return Query;
  })();
  exports["Path"] = Path;
  exports["Query"] = Query;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Routing.Match"] = $PS["Routing.Match"] || {};
  var exports = $PS["Routing.Match"];
  var Control_Alt = $PS["Control.Alt"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Control_Category = $PS["Control.Category"];
  var Control_Plus = $PS["Control.Plus"];
  var Data_Either = $PS["Data.Either"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Newtype = $PS["Data.Newtype"];
  var Data_Number = $PS["Data.Number"];
  var Data_Semiring = $PS["Data.Semiring"];
  var Data_Semiring_Free = $PS["Data.Semiring.Free"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Data_Unit = $PS["Data.Unit"];
  var Data_Validation_Semiring = $PS["Data.Validation.Semiring"];
  var Routing_Match_Error = $PS["Routing.Match.Error"];
  var Routing_Types = $PS["Routing.Types"];                
  var Match = function (x) {
      return x;
  };
  var str = function (route) {
      if (route instanceof Data_List_Types.Cons && route.value0 instanceof Routing_Types.Path) {
          return Control_Applicative.pure(Data_Validation_Semiring.applicativeV(Data_Semiring_Free.semiringFree))(new Data_Tuple.Tuple(route.value1, route.value0.value0));
      };
      return Data_Validation_Semiring.invalid(Data_Semiring_Free.free(Routing_Match_Error.ExpectedString.value));
  };
  var runMatch = function (v) {
      return function (route) {
          var foldErrors = function (errs) {
              return Data_Either.Left.create(Data_Foldable.foldl(Data_List_Types.foldableList)(function (b) {
                  return function (a) {
                      return a + ("\x0a" + b);
                  };
              })("")(Control_Bind.bind(Data_List_Types.bindList)(Data_Functor.map(Data_List_Types.functorList)(Data_List.reverse)(Data_Newtype.unwrap()(errs)))(function (es) {
                  return Control_Applicative.pure(Data_List_Types.applicativeList)(Data_Foldable.foldl(Data_List_Types.foldableList)(function (b) {
                      return function (a) {
                          return a + (";" + b);
                      };
                  })("")(Data_Functor.map(Data_List_Types.functorList)(Routing_Match_Error.showMatchError)(es)));
              })));
          };
          return Data_Validation_Semiring.validation(foldErrors)(function ($89) {
              return Data_Either.Right.create(Data_Tuple.snd($89));
          })(v(route));
      };
  };
  var num = function (route) {
      if (route instanceof Data_List_Types.Cons && route.value0 instanceof Routing_Types.Path) {
          var v = Data_Number.fromString(route.value0.value0);
          if (v instanceof Data_Maybe.Just && !Data_Number["isNaN"](v.value0)) {
              return Control_Applicative.pure(Data_Validation_Semiring.applicativeV(Data_Semiring_Free.semiringFree))(new Data_Tuple.Tuple(route.value1, v.value0));
          };
          return Data_Validation_Semiring.invalid(Data_Semiring_Free.free(Routing_Match_Error.ExpectedNumber.value));
      };
      return Data_Validation_Semiring.invalid(Data_Semiring_Free.free(Routing_Match_Error.ExpectedNumber.value));
  }; 
  var matchFunctor = new Data_Functor.Functor(function (fn) {
      return function (v) {
          return Match(function (r) {
              return Data_Validation_Semiring.validation(Data_Validation_Semiring.invalid)(function (v1) {
                  return Control_Applicative.pure(Data_Validation_Semiring.applicativeV(Data_Semiring_Free.semiringFree))(new Data_Tuple.Tuple(v1.value0, fn(v1.value1)));
              })(v(r));
          });
      };
  });
  var matchApply = new Control_Apply.Apply(function () {
      return matchFunctor;
  }, function (v) {
      return function (v1) {
          var processFnRes = function (v2) {
              return Data_Validation_Semiring.validation(Data_Validation_Semiring.invalid)(function (v3) {
                  return Control_Applicative.pure(Data_Validation_Semiring.applicativeV(Data_Semiring_Free.semiringFree))(new Data_Tuple.Tuple(v3.value0, v2.value1(v3.value1)));
              })(v1(v2.value0));
          };
          var processFnErr = function (r) {
              return function (err) {
                  return Data_Validation_Semiring.invalid(Data_Semiring.mul(Data_Semiring_Free.semiringFree)(err)(Data_Validation_Semiring.validation(Control_Category.identity(Control_Category.categoryFn))(Data_Function["const"](Data_Semiring.one(Data_Semiring_Free.semiringFree)))(v1(r))));
              };
          };
          return Match(function (r) {
              return Data_Validation_Semiring.validation(processFnErr(r))(processFnRes)(v(r));
          });
      };
  });
  var matchAlt = new Control_Alt.Alt(function () {
      return matchFunctor;
  }, function (v) {
      return function (v1) {
          return Match(function (r) {
              return Control_Alt.alt(Data_Validation_Semiring.altV(Data_Semiring_Free.semiringFree))(v(r))(v1(r));
          });
      };
  });
  var matchPlus = new Control_Plus.Plus(function () {
      return matchAlt;
  }, Match(Data_Function["const"](Data_Validation_Semiring.invalid(Data_Semiring.one(Data_Semiring_Free.semiringFree)))));
  var lit = function (input) {
      return function (route) {
          if (route instanceof Data_List_Types.Cons && (route.value0 instanceof Routing_Types.Path && route.value0.value0 === input)) {
              return Control_Applicative.pure(Data_Validation_Semiring.applicativeV(Data_Semiring_Free.semiringFree))(new Data_Tuple.Tuple(route.value1, Data_Unit.unit));
          };
          if (route instanceof Data_List_Types.Cons && route.value0 instanceof Routing_Types.Path) {
              return Data_Validation_Semiring.invalid(Data_Semiring_Free.free(new Routing_Match_Error.UnexpectedPath(input)));
          };
          return Data_Validation_Semiring.invalid(Data_Semiring_Free.free(Routing_Match_Error.ExpectedPathPart.value));
      };
  };
  exports["lit"] = lit;
  exports["num"] = num;
  exports["str"] = str;
  exports["runMatch"] = runMatch;
  exports["matchFunctor"] = matchFunctor;
  exports["matchPlus"] = matchPlus;
  exports["matchApply"] = matchApply;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Routing.Parser"] = $PS["Routing.Parser"] || {};
  var exports = $PS["Routing.Parser"];
  var Control_Alternative = $PS["Control.Alternative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Array = $PS["Data.Array"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_List = $PS["Data.List"];
  var Data_List_Types = $PS["Data.List.Types"];
  var Data_Map_Internal = $PS["Data.Map.Internal"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Ord = $PS["Data.Ord"];
  var Data_Semigroup = $PS["Data.Semigroup"];
  var Data_String_CodePoints = $PS["Data.String.CodePoints"];
  var Data_String_Common = $PS["Data.String.Common"];
  var Data_Traversable = $PS["Data.Traversable"];
  var Data_Tuple = $PS["Data.Tuple"];
  var Routing_Types = $PS["Routing.Types"];                
  var parseQueryPart = function (decoder) {
      var part2tuple = function (input) {
          var keyVal = Data_Functor.map(Data_Functor.functorArray)(decoder)(Data_String_Common.split("=")(input));
          return Control_Bind.discard(Control_Bind.discardUnit)(Data_Maybe.bindMaybe)(Control_Alternative.guard(Data_Maybe.alternativeMaybe)(Data_Array.length(keyVal) <= 2))(function () {
              return Control_Apply.apply(Data_Maybe.applyMaybe)(Data_Functor.map(Data_Maybe.functorMaybe)(Data_Tuple.Tuple.create)(Data_Array.head(keyVal)))(Data_Array.index(keyVal)(1));
          });
      };
      var $11 = Data_Functor.map(Data_Maybe.functorMaybe)(Data_Map_Internal.fromFoldable(Data_Ord.ordString)(Data_Foldable.foldableArray));
      var $12 = Data_Traversable.traverse(Data_Traversable.traversableArray)(Data_Maybe.applicativeMaybe)(part2tuple);
      var $13 = Data_String_Common.split("&");
      return function ($14) {
          return $11($12($13($14)));
      };
  };
  var parse = function (decoder) {
      return function (hash) {
          var pathParts = function (str) {
              var parts = Data_List.fromFoldable(Data_Foldable.foldableArray)(Data_Functor.map(Data_Functor.functorArray)(function ($15) {
                  return Routing_Types.Path.create(decoder($15));
              })(Data_String_Common.split("/")(str)));
              var v = Data_List.unsnoc(parts);
              if (v instanceof Data_Maybe.Just && (v.value0.last instanceof Routing_Types.Path && v.value0.last.value0 === "")) {
                  return v.value0.init;
              };
              return parts;
          };
          var v = Data_Functor.map(Data_Maybe.functorMaybe)(Data_Function.flip(Data_String_CodePoints.splitAt)(hash))(Data_String_CodePoints.indexOf("?")(hash));
          if (v instanceof Data_Maybe.Just) {
              return Data_Semigroup.append(Data_List_Types.semigroupList)(pathParts(v.value0.before))(Data_Functor.map(Data_List_Types.functorList)(Routing_Types.Query.create)(Data_List.fromFoldable(Data_Foldable.foldableMaybe)(parseQueryPart(decoder)(Data_String_CodePoints.drop(1)(v.value0.after)))));
          };
          if (v instanceof Data_Maybe.Nothing) {
              return pathParts(hash);
          };
          throw new Error("Failed pattern match at Routing.Parser (line 32, column 3 - line 37, column 21): " + [ v.constructor.name ]);
      };
  };
  exports["parse"] = parse;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Routing"] = $PS["Routing"] || {};
  var exports = $PS["Routing"];
  var Data_Maybe = $PS["Data.Maybe"];
  var JSURI = $PS["JSURI"];
  var Routing_Match = $PS["Routing.Match"];
  var Routing_Parser = $PS["Routing.Parser"];                
  var matchWith = function (decoder) {
      return function (matcher) {
          var $1 = Routing_Match.runMatch(matcher);
          var $2 = Routing_Parser.parse(decoder);
          return function ($3) {
              return $1($2($3));
          };
      };
  };
  var match = matchWith((function () {
      var $4 = Data_Maybe.fromJust();
      return function ($5) {
          return $4(JSURI["decodeURIComponent"]($5));
      };
  })());
  exports["match"] = match;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Web.HTML.Event.HashChangeEvent.EventTypes"] = $PS["Web.HTML.Event.HashChangeEvent.EventTypes"] || {};
  var exports = $PS["Web.HTML.Event.HashChangeEvent.EventTypes"];
  var hashchange = "hashchange";
  exports["hashchange"] = hashchange;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Routing.Hash"] = $PS["Routing.Hash"] || {};
  var exports = $PS["Routing.Hash"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Apply = $PS["Control.Apply"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Function = $PS["Data.Function"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_String_CodeUnits = $PS["Data.String.CodeUnits"];
  var Effect = $PS["Effect"];
  var Effect_Ref = $PS["Effect.Ref"];
  var Routing = $PS["Routing"];
  var Web_Event_EventTarget = $PS["Web.Event.EventTarget"];
  var Web_HTML = $PS["Web.HTML"];
  var Web_HTML_Event_HashChangeEvent_EventTypes = $PS["Web.HTML.Event.HashChangeEvent.EventTypes"];
  var Web_HTML_Location = $PS["Web.HTML.Location"];
  var Web_HTML_Window = $PS["Web.HTML.Window"];
  var getHash = Control_Bind.bind(Effect.bindEffect)(Control_Bind.bind(Effect.bindEffect)(Web_HTML.window)(Web_HTML_Window.location))((function () {
      var $2 = Data_Functor.map(Effect.functorEffect)((function () {
          var $4 = Data_Maybe.fromMaybe("");
          var $5 = Data_String_CodeUnits.stripPrefix("#");
          return function ($6) {
              return $4($5($6));
          };
      })());
      return function ($3) {
          return $2(Web_HTML_Location.hash($3));
      };
  })());
  var foldHashes = function (cb) {
      return function (init) {
          return function __do() {
              var ref = Control_Bind.bindFlipped(Effect.bindEffect)(Effect_Ref["new"])(Control_Bind.bindFlipped(Effect.bindEffect)(init)(getHash))();
              var win = Data_Functor.map(Effect.functorEffect)(Web_HTML_Window.toEventTarget)(Web_HTML.window)();
              var listener = Web_Event_EventTarget.eventListener(function (v) {
                  return Control_Bind.bindFlipped(Effect.bindEffect)(Data_Function.flip(Effect_Ref.write)(ref))(Control_Bind.join(Effect.bindEffect)(Control_Apply.apply(Effect.applyEffect)(Data_Functor.map(Effect.functorEffect)(cb)(Effect_Ref.read(ref)))(getHash)));
              })();
              Web_Event_EventTarget.addEventListener(Web_HTML_Event_HashChangeEvent_EventTypes.hashchange)(listener)(false)(win)();
              return Web_Event_EventTarget.removeEventListener(Web_HTML_Event_HashChangeEvent_EventTypes.hashchange)(listener)(false)(win);
          };
      };
  };
  var matchesWith = function (dictFoldable) {
      return function (parser) {
          return function (cb) {
              var go = function (a) {
                  var $7 = Data_Maybe.maybe(Control_Applicative.pure(Effect.applicativeEffect)(a))(function (b) {
                      return Data_Functor.voidRight(Effect.functorEffect)(new Data_Maybe.Just(b))(cb(a)(b));
                  });
                  var $8 = Data_Foldable.indexl(dictFoldable)(0);
                  return function ($9) {
                      return $7($8(parser($9)));
                  };
              };
              return foldHashes(go)(go(Data_Maybe.Nothing.value));
          };
      };
  };                                                                            
  var matches = (function () {
      var $10 = matchesWith(Data_Foldable.foldableEither);
      return function ($11) {
          return $10(Routing.match($11));
      };
  })();
  exports["matches"] = matches;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Hooks"] = $PS["Gargantext.Hooks"] || {};
  var exports = $PS["Gargantext.Hooks"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Routing_Hash = $PS["Routing.Hash"];
  var Toestand_Classes = $PS["Toestand.Classes"];                
  var useHashRouter = function (dictWrite) {
      return function (routes) {
          return function (cell) {
              var h = function (_old) {
                  return function ($$new) {
                      return Toestand_Classes.write_(dictWrite)($$new)(cell);
                  };
              };
              return Reactix_Hooks.useEffectOnce(Routing_Hash.matches(routes)(h));
          };
      };
  };
  exports["useHashRouter"] = useHashRouter;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Router"] = $PS["Gargantext.Router"] || {};
  var exports = $PS["Gargantext.Router"];
  var Control_Apply = $PS["Control.Apply"];
  var Data_Foldable = $PS["Data.Foldable"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Int = $PS["Data.Int"];
  var Gargantext_Routes = $PS["Gargantext.Routes"];
  var Gargantext_Types = $PS["Gargantext.Types"];
  var Routing_Match = $PS["Routing.Match"];                
  var router = (function () {
      var sid = Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Types.SessionId)(Routing_Match.str);
      var route = function (str) {
          return Control_Apply.applySecond(Routing_Match.matchApply)(Routing_Match.lit(""))(Routing_Match.lit(str));
      };
      var $$int = Data_Functor.map(Routing_Match.matchFunctor)(Data_Int.floor)(Routing_Match.num);
      return Data_Foldable.oneOf(Data_Foldable.foldableArray)(Routing_Match.matchPlus)([ Data_Functor.voidRight(Routing_Match.matchFunctor)(Gargantext_Routes.Login.value)(route("login")), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.Folder.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("folder"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.FolderPrivate.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("folderPrivate"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.FolderPublic.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("folderPublic"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.FolderShared.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("folderShared"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.Team.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("team"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Control_Apply.apply(Routing_Match.matchApply)(Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.CorpusDocument.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("corpus"))(sid)))($$int))(Control_Apply.applySecond(Routing_Match.matchApply)(Routing_Match.lit("list"))($$int)))(Control_Apply.applySecond(Routing_Match.matchApply)(Routing_Match.lit("document"))($$int)), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.Corpus.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("corpus"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.Document.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("list"))(sid)))($$int))(Control_Apply.applySecond(Routing_Match.matchApply)(Routing_Match.lit("document"))($$int)), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.Dashboard.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("dashboard"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.PGraphExplorer.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("graph"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.PhyloExplorer.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("phylo"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.Texts.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("texts"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.Lists.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("lists"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.ContactPage.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("annuaire"))(sid)))($$int))(Control_Apply.applySecond(Routing_Match.matchApply)(Routing_Match.lit("contact"))($$int)), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.Annuaire.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("annuaire"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.UserPage.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("user"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.RouteFrameWrite.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("write"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.RouteFrameCalc.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("calc"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.RouteFrameCode.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("code"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.RouteFrameVisio.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("visio"))(sid)))($$int), Control_Apply.apply(Routing_Match.matchApply)(Data_Functor.map(Routing_Match.matchFunctor)(Gargantext_Routes.RouteFile.create)(Control_Apply.applySecond(Routing_Match.matchApply)(route("file"))(sid)))($$int), Data_Functor.voidRight(Routing_Match.matchFunctor)(Gargantext_Routes.Home.value)(Routing_Match.lit("")) ]);
  })();
  exports["router"] = router;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Gargantext.Components.App"] = $PS["Gargantext.Components.App"] || {};
  var exports = $PS["Gargantext.Components.App"];
  var Control_Applicative = $PS["Control.Applicative"];
  var Control_Bind = $PS["Control.Bind"];
  var Data_Functor = $PS["Data.Functor"];
  var Data_Symbol = $PS["Data.Symbol"];
  var Effect = $PS["Effect"];
  var Gargantext_AsyncTasks = $PS["Gargantext.AsyncTasks"];
  var Gargantext_Components_App_Data = $PS["Gargantext.Components.App.Data"];
  var Gargantext_Components_Router = $PS["Gargantext.Components.Router"];
  var Gargantext_Hooks = $PS["Gargantext.Hooks"];
  var Gargantext_Router = $PS["Gargantext.Router"];
  var Gargantext_Sessions = $PS["Gargantext.Sessions"];
  var Gargantext_Sessions_Types = $PS["Gargantext.Sessions.Types"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];
  var Reactix_Hooks = $PS["Reactix.Hooks"];
  var Reactix_React = $PS["Reactix.React"];
  var Toestand_Boxes = $PS["Toestand.Boxes"];
  var Toestand_Classes = $PS["Toestand.Classes"];
  var Toestand_Records = $PS["Toestand.Records"];
  var Typisch_Row = $PS["Typisch.Row"];                
  var here = Gargantext_Utils_Reactix.here("Gargantext.Components.App");
  var appCpt = (function () {
      var cpt = function (v) {
          return function (v1) {
              return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Boxes.useBox(Gargantext_Components_App_Data.emptyApp))(function (box) {
                  return Control_Bind.bind(Reactix_React.bindHooks)(Toestand_Records.useFocusedFields()(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "backend";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "backend";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "backend";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "forestOpen";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "forestOpen";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "forestOpen";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "graphVersion";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "graphVersion";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "graphVersion";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "handed";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "handed";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "handed";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "reloadForest";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "reloadForest";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "reloadForest";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "reloadMainPage";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "reloadMainPage";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "reloadMainPage";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "reloadRoot";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "reloadRoot";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "reloadRoot";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "route";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "route";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "route";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "session";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "session";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "session";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sessions";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sessions";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sessions";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "showCorpus";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "showCorpus";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "showCorpus";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "showLogin";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "showLogin";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "showLogin";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "showTree";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "showTree";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "showTree";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelGraph";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelGraph";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelGraph";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelLists";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelLists";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelLists";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelState";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelState";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelState";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelTexts";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelTexts";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "sidePanelTexts";
                  }))())(Toestand_Records.consUseFocusedFields(Toestand_Classes.readWrite(Toestand_Boxes.readBox)(Toestand_Boxes.writeBox))(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "tasks";
                  }))())())(Typisch_Row.cons(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "tasks";
                  }))())())(Typisch_Row.lacks(new Data_Symbol.IsSymbol(function () {
                      return "tasks";
                  }))())(Toestand_Records.nilUseFocusedFields)))))))))))))))))))(box)({}))(function (boxes) {
                      return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffectOnce'"](Data_Functor["void"](Effect.functorEffect)(Gargantext_Sessions.load(Toestand_Boxes.writeBox)(boxes.sessions))))(function () {
                          return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffectOnce'"](function __do() {
                              var tasksStorage = Gargantext_AsyncTasks.getAsyncTasks();
                              return Toestand_Classes.write_(Toestand_Boxes.writeBox)(tasksStorage)(boxes.tasks)();
                          }))(function () {
                              return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Reactix_Hooks["useEffectOnce'"](function __do() {
                                  Gargantext_Utils_Reactix.loadLocalStorageState(Gargantext_Sessions_Types["$_ReadForeignOpenNodes_45"])(Gargantext_Utils_Reactix.openNodesKey)(boxes.forestOpen)();
                                  return Toestand_Classes.listen(Toestand_Boxes.readBox)(Gargantext_Utils_Reactix.listenLocalStorageState(Gargantext_Sessions_Types["$_WriteForeignOpenNodes_46"])(Gargantext_Utils_Reactix.openNodesKey))(boxes.forestOpen)();
                              }))(function () {
                                  return Control_Bind.discard(Control_Bind.discardUnit)(Reactix_React.bindHooks)(Gargantext_Hooks.useHashRouter(Toestand_Boxes.writeBox)(Gargantext_Router.router)(boxes.route))(function () {
                                      return Control_Applicative.pure(Reactix_React.applicativeHooks)(Gargantext_Components_Router.router({
                                          boxes: boxes
                                      }));
                                  });
                              });
                          });
                      });
                  });
              });
          };
      };
      return here.component("app")(cpt);
  })();
  var app = Reactix_React.createElement(Reactix_React.componentIsComponent)(appCpt);
  exports["app"] = app;
})(PS);
(function($PS) {
  // Generated by purs version 0.14.2
  "use strict";
  $PS["Main"] = $PS["Main"] || {};
  var exports = $PS["Main"];
  var DOM_Simple_Console = $PS["DOM.Simple.Console"];
  var DOM_Simple_Document = $PS["DOM.Simple.Document"];
  var Data_Maybe = $PS["Data.Maybe"];
  var Data_Nullable = $PS["Data.Nullable"];
  var FFI_Simple_Functions = $PS["FFI.Simple.Functions"];
  var Gargantext_Components_App = $PS["Gargantext.Components.App"];
  var Gargantext_Utils_Reactix = $PS["Gargantext.Utils.Reactix"];                
  var paint = function (v) {
      if (v instanceof Data_Maybe.Nothing) {
          return DOM_Simple_Console.log("[main] Container not found");
      };
      if (v instanceof Data_Maybe.Just) {
          return Gargantext_Utils_Reactix.render(Gargantext_Components_App.app({})([  ]))(v.value0);
      };
      throw new Error("Failed pattern match at Main (line 18, column 1 - line 18, column 38): " + [ v.constructor.name ]);
  };
  var main = paint(Data_Nullable.toMaybe(FFI_Simple_Functions["applyMethod'"](DOM_Simple_Document.document)("getElementById")([ "app" ])));
  exports["main"] = main;
})(PS);
PS["Main"].main();