(function() {
  var fn = function() {
    
    (function(root) {
      function now() {
        return new Date();
      }
    
      var force = false;
    
      if (typeof (root._bokeh_onload_callbacks) === "undefined" || force === true) {
        root._bokeh_onload_callbacks = [];
        root._bokeh_is_loading = undefined;
      }
    
      
      
    
      
      
    
      function run_callbacks() {
        try {
          root._bokeh_onload_callbacks.forEach(function(callback) { callback() });
        }
        finally {
          delete root._bokeh_onload_callbacks
        }
        console.info("Bokeh: all callbacks have finished");
      }
    
      function load_libs(js_urls, callback) {
        root._bokeh_onload_callbacks.push(callback);
        if (root._bokeh_is_loading > 0) {
          console.log("Bokeh: BokehJS is being loaded, scheduling callback at", now());
          return null;
        }
        if (js_urls == null || js_urls.length === 0) {
          run_callbacks();
          return null;
        }
        console.log("Bokeh: BokehJS not loaded, scheduling load and callback at", now());
        root._bokeh_is_loading = js_urls.length;
        for (var i = 0; i < js_urls.length; i++) {
          var url = js_urls[i];
          var s = document.createElement('script');
          s.src = url;
          s.async = false;
          s.onreadystatechange = s.onload = function() {
            root._bokeh_is_loading--;
            if (root._bokeh_is_loading === 0) {
              console.log("Bokeh: all BokehJS libraries loaded");
              run_callbacks()
            }
          };
          s.onerror = function() {
            console.warn("failed to load library " + url);
          };
          console.log("Bokeh: injecting script tag for BokehJS library: ", url);
          document.getElementsByTagName("head")[0].appendChild(s);
        }
      };var element = document.getElementById("140b6a4f-8f28-49ff-b853-273d7787d179");
      if (element == null) {
        console.log("Bokeh: ERROR: autoload.js configured with elementid '140b6a4f-8f28-49ff-b853-273d7787d179' but no matching script tag was found. ")
        return false;
      }
    
      var js_urls = ["https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.js", "https://cdn.pydata.org/bokeh/release/bokeh-0.12.9.min.js", "https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.9.min.js", "https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.9.min.js", "https://cdn.pydata.org/bokeh/release/bokeh-gl-0.12.9.min.js"];
    
      var inline_js = [
        function(Bokeh) {
          Bokeh.set_log_level("info");
        },
        
        function(Bokeh) {
          (function(root, factory) {
          //  if(typeof exports === 'object' && typeof module === 'object')
          //    factory(require("Bokeh"));
          //  else if(typeof define === 'function' && define.amd)
          //    define(["Bokeh"], factory);
          //  else if(typeof exports === 'object')
          //    factory(require("Bokeh"));
          //  else
              factory(root["Bokeh"]);
          })(this, function(Bokeh) {
            var define;
            return (function outer(modules, entry) {
            if (Bokeh != null) {
              return Bokeh.register_plugin(modules, {}, entry);
            } else {
              throw new Error("Cannot find Bokeh. You have to load it prior to loading plugins.");
            }
          })
          ({
            "custom/main": function(require, module, exports) {
              var models = {
                "DrawTool": require("custom/bk_script_a6b7155103794f3a9d6e5b21d8027d12.draw_tool").DrawTool,
          "LatexLabel": require("custom/bk_script_bfb9623b3cb142b39dad9fa1403dc95a.latex_label").LatexLabel,
          "MyFormatter": require("custom/bk_script_de11d510a75f413fb86b6e84959f4258.my_formatter").MyFormatter
              };
              require("base").register_models(models);
              module.exports = models;
            },
            "custom/bk_script_a6b7155103794f3a9d6e5b21d8027d12.draw_tool": function(require, module, exports) {
          "use strict";
          Object.defineProperty(exports, "__esModule", { value: true });
          var extend = function (child, parent) { for (var key in parent) {
              if (hasProp.call(parent, key))
                  child[key] = parent[key];
          } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty;
          var p = require("core/properties");
          var gesture_tool_1 = require("models/tools/gestures/gesture_tool");
          exports.DrawToolView = (function (superClass) {
              extend(DrawToolView, superClass);
              function DrawToolView() {
                  return DrawToolView.__super__.constructor.apply(this, arguments);
              }
              DrawToolView.prototype._pan_start = function (e) {
                  return this.model.source.data = {
                      x: [],
                      y: []
                  };
              };
              DrawToolView.prototype._pan = function (e) {
                  var canvas, frame, vx, vy, x, y;
                  frame = this.plot_model.frame;
                  canvas = this.plot_view.canvas;
                  vx = canvas.sx_to_vx(e.bokeh.sx);
                  vy = canvas.sy_to_vy(e.bokeh.sy);
                  if (!frame.contains(vx, vy)) {
                      return null;
                  }
                  x = frame.xscales['default'].invert(vx);
                  y = frame.yscales['default'].invert(vy);
                  this.model.source.data.x.push(x);
                  this.model.source.data.y.push(y);
                  return this.model.source.change.emit();
              };
              DrawToolView.prototype._pan_end = function (e) {
                  return null;
              };
              return DrawToolView;
          })(gesture_tool_1.GestureToolView);
          exports.DrawTool = (function (superClass) {
              extend(DrawTool, superClass);
              function DrawTool() {
                  return DrawTool.__super__.constructor.apply(this, arguments);
              }
              DrawTool.prototype.default_view = exports.DrawToolView;
              DrawTool.prototype.type = "DrawTool";
              DrawTool.prototype.tool_name = "Drag Span";
              DrawTool.prototype.icon = "bk-tool-icon-lasso-select";
              DrawTool.prototype.event_type = "pan";
              DrawTool.prototype.default_order = 12;
              DrawTool.define({
                  source: [p.Instance]
              });
              return DrawTool;
          })(gesture_tool_1.GestureTool);
          
          },
          "custom/bk_script_bfb9623b3cb142b39dad9fa1403dc95a.latex_label": function(require, module, exports) {
          "use strict";
          Object.defineProperty(exports, "__esModule", { value: true });
          var extend = function (child, parent) { for (var key in parent) {
              if (hasProp.call(parent, key))
                  child[key] = parent[key];
          } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty;
          var label_1 = require("models/annotations/label");
          exports.LatexLabelView = (function (superClass) {
              extend(LatexLabelView, superClass);
              function LatexLabelView() {
                  return LatexLabelView.__super__.constructor.apply(this, arguments);
              }
              LatexLabelView.prototype.render = function () {
                  var angle, ctx, panel_offset, sx, sy, vx, vy;
                  ctx = this.plot_view.canvas_view.ctx;
                  switch (this.model.angle_units) {
                      case "rad":
                          angle = -1 * this.model.angle;
                          break;
                      case "deg":
                          angle = -1 * this.model.angle * Math.PI / 180.0;
                  }
                  if (this.model.x_units === "data") {
                      vx = this.xscale.compute(this.model.x);
                  }
                  else {
                      vx = this.model.x;
                  }
                  sx = this.canvas.vx_to_sx(vx);
                  if (this.model.y_units === "data") {
                      vy = this.yscale.compute(this.model.y);
                  }
                  else {
                      vy = this.model.y;
                  }
                  sy = this.canvas.vy_to_sy(vy);
                  if (this.model.panel != null) {
                      panel_offset = this._get_panel_offset();
                      sx += panel_offset.x;
                      sy += panel_offset.y;
                  }
                  this._css_text(ctx, "", sx + this.model.x_offset, sy - this.model.y_offset, angle);
                  return katex.render(this.model.text, this.el, {
                      displayMode: true
                  });
              };
              return LatexLabelView;
          })(label_1.LabelView);
          exports.LatexLabel = (function (superClass) {
              extend(LatexLabel, superClass);
              function LatexLabel() {
                  return LatexLabel.__super__.constructor.apply(this, arguments);
              }
              LatexLabel.prototype.type = 'LatexLabel';
              LatexLabel.prototype.default_view = exports.LatexLabelView;
              return LatexLabel;
          })(label_1.Label);
          
          },
          "custom/bk_script_de11d510a75f413fb86b6e84959f4258.my_formatter": function(require, module, exports) {
          "use strict";
          Object.defineProperty(exports, "__esModule", { value: true });
          var extend = function (child, parent) { for (var key in parent) {
              if (hasProp.call(parent, key))
                  child[key] = parent[key];
          } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty;
          var tick_formatter_1 = require("models/formatters/tick_formatter");
          exports.MyFormatter = (function (superClass) {
              extend(MyFormatter, superClass);
              function MyFormatter() {
                  return MyFormatter.__super__.constructor.apply(this, arguments);
              }
              MyFormatter.prototype.type = "MyFormatter";
              MyFormatter.prototype.doFormat = function (ticks) {
                  var formatted, i, j, ref;
                  formatted = ["" + ticks[0]];
                  for (i = j = 1, ref = ticks.length; 1 <= ref ? j < ref : j > ref; i = 1 <= ref ? ++j : --j) {
                      formatted.push("+" + ((ticks[i] - ticks[0]).toPrecision(2)));
                  }
                  return formatted;
              };
              return MyFormatter;
          })(tick_formatter_1.TickFormatter);
          
          }
          }, "custom/main");
          ;
          });
        },
        
        function(Bokeh) {
          (function() {
            var fn = function() {
              Bokeh.safely(function() {
                (function(root) {
                  function embed_document(root) {
                    var docs_json = {"f9ac8b8d-21f9-4c69-863c-0a9322d7e8ad":{"roots":{"references":[{"attributes":{"callback":null,"end":10},"id":"504fd33c-217f-4f24-a755-eab9e5d90da2","type":"Range1d"},{"attributes":{},"id":"07b50b1d-01a0-4f1c-a700-571cf7ae8f92","type":"BasicTickFormatter"},{"attributes":{"callback":null,"column_names":["y","x"],"data":{"x":[],"y":[]}},"id":"daf981ae-5425-409b-b988-f96a5fdd7efd","type":"ColumnDataSource"},{"attributes":{},"id":"35d4d7a9-e620-46ec-86de-a0f4cc891c1a","type":"BasicTicker"},{"attributes":{},"id":"ea285ce8-da35-47a5-bf8a-d85102883cdf","type":"LinearScale"},{"attributes":{"source":{"id":"daf981ae-5425-409b-b988-f96a5fdd7efd","type":"ColumnDataSource"}},"id":"a92aaead-009a-42d4-a81e-aed8a5da8e04","type":"DrawTool"},{"attributes":{"formatter":{"id":"07b50b1d-01a0-4f1c-a700-571cf7ae8f92","type":"BasicTickFormatter"},"plot":{"id":"257102a7-f438-47f4-8a20-29ab3d6f08a6","subtype":"Figure","type":"Plot"},"ticker":{"id":"2d7ac8f2-4d60-4564-8240-e2cf654a5fc0","type":"BasicTicker"}},"id":"efe2a471-3295-4afd-b7fb-0f9751936903","type":"LinearAxis"},{"attributes":{"formatter":{"id":"f2a1bcb9-92c4-4c92-9f42-e69c07f8084b","type":"BasicTickFormatter"},"plot":{"id":"257102a7-f438-47f4-8a20-29ab3d6f08a6","subtype":"Figure","type":"Plot"},"ticker":{"id":"35d4d7a9-e620-46ec-86de-a0f4cc891c1a","type":"BasicTicker"}},"id":"779f95ef-ebd4-42ac-90cc-535e1024b49d","type":"LinearAxis"},{"attributes":{"plot":null,"text":"Drag to draw on the plot"},"id":"e47d99c6-ac0b-4f7d-b19a-330ae7424594","type":"Title"},{"attributes":{"plot":{"id":"257102a7-f438-47f4-8a20-29ab3d6f08a6","subtype":"Figure","type":"Plot"},"ticker":{"id":"2d7ac8f2-4d60-4564-8240-e2cf654a5fc0","type":"BasicTicker"}},"id":"6b89d0fd-3bcb-45cd-86e4-954e13e0ad84","type":"Grid"},{"attributes":{"active_drag":"auto","active_inspect":"auto","active_scroll":"auto","active_tap":"auto","tools":[{"id":"a92aaead-009a-42d4-a81e-aed8a5da8e04","type":"DrawTool"}]},"id":"f7d336ce-661c-4dd4-a16d-011d9ce98648","type":"Toolbar"},{"attributes":{"callback":null,"end":10},"id":"8c13464e-e0c1-4541-9261-f8ed6a3779b8","type":"Range1d"},{"attributes":{"below":[{"id":"efe2a471-3295-4afd-b7fb-0f9751936903","type":"LinearAxis"}],"left":[{"id":"779f95ef-ebd4-42ac-90cc-535e1024b49d","type":"LinearAxis"}],"renderers":[{"id":"efe2a471-3295-4afd-b7fb-0f9751936903","type":"LinearAxis"},{"id":"6b89d0fd-3bcb-45cd-86e4-954e13e0ad84","type":"Grid"},{"id":"779f95ef-ebd4-42ac-90cc-535e1024b49d","type":"LinearAxis"},{"id":"b72b52e8-c568-418f-a9bf-bc2372e70242","type":"Grid"},{"id":"c6ffc7bb-e0ee-40f2-8e79-ccd4c8ded544","type":"GlyphRenderer"}],"title":{"id":"e47d99c6-ac0b-4f7d-b19a-330ae7424594","type":"Title"},"toolbar":{"id":"f7d336ce-661c-4dd4-a16d-011d9ce98648","type":"Toolbar"},"x_range":{"id":"8c13464e-e0c1-4541-9261-f8ed6a3779b8","type":"Range1d"},"x_scale":{"id":"ea285ce8-da35-47a5-bf8a-d85102883cdf","type":"LinearScale"},"y_range":{"id":"504fd33c-217f-4f24-a755-eab9e5d90da2","type":"Range1d"},"y_scale":{"id":"01cdbfc8-326e-49c9-a858-dc1b47a6b7ee","type":"LinearScale"}},"id":"257102a7-f438-47f4-8a20-29ab3d6f08a6","subtype":"Figure","type":"Plot"},{"attributes":{},"id":"01cdbfc8-326e-49c9-a858-dc1b47a6b7ee","type":"LinearScale"},{"attributes":{"line_color":{"value":"#1f77b4"},"x":{"field":"x"},"y":{"field":"y"}},"id":"87e6740e-1f5f-404d-8c22-c09493228d94","type":"Line"},{"attributes":{},"id":"f2a1bcb9-92c4-4c92-9f42-e69c07f8084b","type":"BasicTickFormatter"},{"attributes":{},"id":"2d7ac8f2-4d60-4564-8240-e2cf654a5fc0","type":"BasicTicker"},{"attributes":{"source":{"id":"daf981ae-5425-409b-b988-f96a5fdd7efd","type":"ColumnDataSource"}},"id":"343bf361-d87f-4977-a83a-2840c6b88ff9","type":"CDSView"},{"attributes":{"line_alpha":{"value":0.1},"line_color":{"value":"#1f77b4"},"x":{"field":"x"},"y":{"field":"y"}},"id":"fa423b13-148b-427b-9360-3361e5289628","type":"Line"},{"attributes":{"data_source":{"id":"daf981ae-5425-409b-b988-f96a5fdd7efd","type":"ColumnDataSource"},"glyph":{"id":"87e6740e-1f5f-404d-8c22-c09493228d94","type":"Line"},"hover_glyph":null,"muted_glyph":null,"nonselection_glyph":{"id":"fa423b13-148b-427b-9360-3361e5289628","type":"Line"},"selection_glyph":null,"view":{"id":"343bf361-d87f-4977-a83a-2840c6b88ff9","type":"CDSView"}},"id":"c6ffc7bb-e0ee-40f2-8e79-ccd4c8ded544","type":"GlyphRenderer"},{"attributes":{"dimension":1,"plot":{"id":"257102a7-f438-47f4-8a20-29ab3d6f08a6","subtype":"Figure","type":"Plot"},"ticker":{"id":"35d4d7a9-e620-46ec-86de-a0f4cc891c1a","type":"BasicTicker"}},"id":"b72b52e8-c568-418f-a9bf-bc2372e70242","type":"Grid"}],"root_ids":["257102a7-f438-47f4-8a20-29ab3d6f08a6"]},"title":"Bokeh Application","version":"0.12.9"}};
                    var render_items = [{"docid":"f9ac8b8d-21f9-4c69-863c-0a9322d7e8ad","elementid":"140b6a4f-8f28-49ff-b853-273d7787d179","modelid":"257102a7-f438-47f4-8a20-29ab3d6f08a6"}];
                
                    root.Bokeh.embed.embed_items(docs_json, render_items);
                  }
                
                  if (root.Bokeh !== undefined) {
                    embed_document(root);
                  } else {
                    var attempts = 0;
                    var timer = setInterval(function(root) {
                      if (root.Bokeh !== undefined) {
                        embed_document(root);
                        clearInterval(timer);
                      }
                      attempts++;
                      if (attempts > 100) {
                        console.log("Bokeh: ERROR: Unable to embed document because BokehJS library is missing")
                        clearInterval(timer);
                      }
                    }, 10, root)
                  }
                })(window);
              });
            };
            if (document.readyState != "loading") fn();
            else document.addEventListener("DOMContentLoaded", fn);
          })();
        },
        function(Bokeh) {
          console.log("Bokeh: injecting CSS: https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css");
          Bokeh.embed.inject_css("https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.6.0/katex.min.css");
          console.log("Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-0.12.9.min.css");
          Bokeh.embed.inject_css("https://cdn.pydata.org/bokeh/release/bokeh-0.12.9.min.css");
          console.log("Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.9.min.css");
          Bokeh.embed.inject_css("https://cdn.pydata.org/bokeh/release/bokeh-widgets-0.12.9.min.css");
          console.log("Bokeh: injecting CSS: https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.9.min.css");
          Bokeh.embed.inject_css("https://cdn.pydata.org/bokeh/release/bokeh-tables-0.12.9.min.css");
        }
      ];
    
      function run_inline_js() {
        
        for (var i = 0; i < inline_js.length; i++) {
          inline_js[i].call(root, root.Bokeh);
        }
        
      }
    
      if (root._bokeh_is_loading === 0) {
        console.log("Bokeh: BokehJS loaded, going straight to plotting");
        run_inline_js();
      } else {
        load_libs(js_urls, function() {
          console.log("Bokeh: BokehJS plotting callback run at", now());
          run_inline_js();
        });
      }
    }(window));
  };
  if (document.readyState != "loading") fn();
  else document.addEventListener("DOMContentLoaded", fn);
})();
