text: // Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE
  'use strict';
  
  var Rebase = require("@glennsl/rebase/lib/js/src/Rebase.bs.js");
  var Log$AgdaMode = require("../Log.bs.js");
  var Task$AgdaMode = require("./Task.bs.js");
  var Editors$AgdaMode = require("../Editors.bs.js");
  var Connection$AgdaMode = require("../Connection.bs.js");
  var Caml_chrome_debugger = require("bs-platform/lib/js/caml_chrome_debugger.js");
  
  function handle(param) {
    if (typeof param === "number") {
      if (param === /* Cancelled */0) {
        return /* :: */Caml_chrome_debugger.simpleVariant("::", [
                  /* Display */Caml_chrome_debugger.variant("Display", 2, [
                      "Query Cancelled",
                      /* Error */1,
                      /* Emacs */Caml_chrome_debugger.simpleVariant("Emacs", [/* PlainText */Caml_chrome_debugger.variant("PlainText", 8, [""])])
                    ]),
                  /* :: */Caml_chrome_debugger.simpleVariant("::", [
                      /* WithInstance */Caml_chrome_debugger.variant("WithInstance", 0, [(function (instance) {
                              Editors$AgdaMode.Focus.on(/* Source */0, instance.editors);
                              return Task$AgdaMode.$$return(/* [] */0);
                            })]),
                      /* [] */0
                    ])
                ]);
      } else {
        return /* :: */Caml_chrome_debugger.simpleVariant("::", [
                  /* Display */Caml_chrome_debugger.variant("Display", 2, [
                      "Out of goal",
                      /* Error */1,
                      /* Emacs */Caml_chrome_debugger.simpleVariant("Emacs", [/* PlainText */Caml_chrome_debugger.variant("PlainText", 8, ["Please place the cursor in a goal"])])
                    ]),
                  /* :: */Caml_chrome_debugger.simpleVariant("::", [
                      /* WithInstance */Caml_chrome_debugger.variant("WithInstance", 0, [(function (instance) {
                              Editors$AgdaMode.Focus.on(/* Source */0, instance.editors);
                              return Task$AgdaMode.$$return(/* [] */0);
                            })]),
                      /* [] */0
                    ])
                ]);
      }
    } else if (param.tag) {
      var match = Connection$AgdaMode.$$Error.toString(param[0]);
      return /* :: */Caml_chrome_debugger.simpleVariant("::", [
                /* Display */Caml_chrome_debugger.variant("Display", 2, [
                    "Connection-related Error: " + match[0],
                    /* Error */1,
                    /* Emacs */Caml_chrome_debugger.simpleVariant("Emacs", [/* PlainText */Caml_chrome_debugger.variant("PlainText", 8, [match[1]])])
                  ]),
                /* :: */Caml_chrome_debugger.simpleVariant("::", [
                    /* WithInstance */Caml_chrome_debugger.variant("WithInstance", 0, [(function (instance) {
                            Editors$AgdaMode.Focus.on(/* Source */0, instance.editors);
                            return Task$AgdaMode.$$return(/* [] */0);
                          })]),
                    /* [] */0
                  ])
              ]);
    } else {
      var errors = param[0];
      return /* :: */Caml_chrome_debugger.simpleVariant("::", [
                /* WithConnection */Caml_chrome_debugger.variant("WithConnection", 1, [(function (conn) {
                        Rebase.$$Array.forEach((function (e) {
                                return Log$AgdaMode.logError(e)(conn.log);
                              }), errors);
                        return Task$AgdaMode.$$return(/* :: */Caml_chrome_debugger.simpleVariant("::", [
                                      /* Display */Caml_chrome_debugger.variant("Display", 2, [
                                          "Parse Error",
                                          /* Error */1,
                                          /* Emacs */Caml_chrome_debugger.simpleVariant("Emacs", [/* ParseError */Caml_chrome_debugger.variant("ParseError", 7, [conn])])
                                        ]),
                                      /* [] */0
                                    ]));
                      })]),
                /* :: */Caml_chrome_debugger.simpleVariant("::", [
                    /* WithInstance */Caml_chrome_debugger.variant("WithInstance", 0, [(function (instance) {
                            Editors$AgdaMode.Focus.on(/* Source */0, instance.editors);
                            return Task$AgdaMode.$$return(/* [] */0);
                          })]),
                    /* [] */0
                  ])
              ]);
    }
  }
  
  exports.handle = handle;
  /* Log-AgdaMode Not a pure module */
  