UNPKG

@bokeh/bokehjs

Version:

Interactive, novel data visualization

181 lines (156 loc) 1.13 MB
'use strict'; /*! * Copyright (c) Anaconda, Inc., and Bokeh Contributors * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * Neither the name of Anaconda nor the names of any contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF * THE POSSIBILITY OF SUCH DAMAGE. */ (function(root, factory) { const bokeh = factory(); bokeh.__bokeh__ = true; if (typeof root.Bokeh === "undefined" || typeof root.Bokeh.__bokeh__ === "undefined") { root.Bokeh = bokeh; } const Bokeh = root.Bokeh; Bokeh[bokeh.version] = bokeh; })(this, function() { let define; const parent_require = typeof require === "function" && require return (function(modules, entry, aliases, externals) { if (aliases === undefined) aliases = {}; if (externals === undefined) externals = {}; const cache = {}; const normalize = function(name) { if (typeof name === "number") return name; if (name === "bokehjs") return entry; if (!externals[name]) { const prefix = "@bokehjs/" if (name.slice(0, prefix.length) === prefix) name = name.slice(prefix.length) } const alias = aliases[name] if (alias != null) return alias; const trailing = name.length > 0 && name[name.length-1] === "/"; const index = aliases[name + (trailing ? "" : "/") + "index"]; if (index != null) return index; return name; } const require = function(name) { let mod = cache[name]; if (!mod) { const id = normalize(name); mod = cache[id]; if (!mod) { if (!modules[id]) { if (externals[id] === false || (externals[id] == true && parent_require)) { try { mod = {exports: externals[id] ? parent_require(id) : {}}; cache[id] = cache[name] = mod; return mod.exports; } catch (e) {} } const err = new Error("Cannot find module '" + name + "'"); err.code = 'MODULE_NOT_FOUND'; throw err; } mod = {exports: {}}; cache[id] = cache[name] = mod; function __esModule() { Object.defineProperty(mod.exports, "__esModule", {value: true}); } function __esExport(name, value) { Object.defineProperty(mod.exports, name, { enumerable: true, get: function () { return value; } }); } modules[id].call(mod.exports, require, mod, mod.exports, __esModule, __esExport); } else { cache[name] = mod; } } return mod.exports; } require.resolve = function(name) { return "" } const main = require(entry); main.require = require; if (typeof Proxy !== "undefined") { // allow Bokeh.loader["@bokehjs/module/name"] syntax main.loader = new Proxy({}, { get: function(_obj, module) { return require(module); } }); } main.register_plugin = function(plugin_modules, plugin_entry, plugin_aliases, plugin_externals) { if (plugin_aliases === undefined) plugin_aliases = {}; if (plugin_externals === undefined) plugin_externals = {}; for (let name in plugin_modules) { modules[name] = plugin_modules[name]; } for (let name in plugin_aliases) { aliases[name] = plugin_aliases[name]; } for (let name in plugin_externals) { externals[name] = plugin_externals[name]; } const plugin = require(plugin_entry); for (let name in plugin) { main[name] = plugin[name]; } return plugin; } return main; }) ([ function _(t,_,n,o,r){o();t(1).__exportStar(t(2),n),t(76)}, function _(e,t,r,n,o){n(),r.__extends=i,r.__rest=c,r.__decorate=s,r.__param=u,r.__esDecorate=f,r.__runInitializers=l,r.__propKey=p,r.__setFunctionName=_,r.__metadata=y,r.__awaiter=d,r.__generator=h,r.__exportStar=v,r.__values=b,r.__read=w,r.__spread=m,r.__spreadArrays=g,r.__spreadArray=O,r.__await=j,r.__asyncGenerator=P,r.__asyncDelegator=S,r.__asyncValues=E,r.__makeTemplateObject=x,r.__importStar=D,r.__importDefault=R,r.__classPrivateFieldGet=k,r.__classPrivateFieldSet=A,r.__classPrivateFieldIn=F,r.__addDisposableResource=C,r.__disposeResources=G,r.__rewriteRelativeImportExtension=z;var a=function(e,t){return a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},a(e,t)};function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}a(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}function c(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r}function s(e,t,r,n){var o,a=arguments.length,i=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,n);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(i=(a<3?o(i):a>3?o(t,r,i):o(t,r))||i);return a>3&&i&&Object.defineProperty(t,r,i),i}function u(e,t){return function(r,n){t(r,n,e)}}function f(e,t,r,n,o,a){function i(e){if(void 0!==e&&"function"!=typeof e)throw new TypeError("Function expected");return e}for(var c,s=n.kind,u="getter"===s?"get":"setter"===s?"set":"value",f=!t&&e?n.static?e:e.prototype:null,l=t||(f?Object.getOwnPropertyDescriptor(f,n.name):{}),p=!1,_=r.length-1;_>=0;_--){var y={};for(var d in n)y[d]="access"===d?{}:n[d];for(var d in n.access)y.access[d]=n.access[d];y.addInitializer=function(e){if(p)throw new TypeError("Cannot add initializers after decoration has completed");a.push(i(e||null))};var h=(0,r[_])("accessor"===s?{get:l.get,set:l.set}:l[u],y);if("accessor"===s){if(void 0===h)continue;if(null===h||"object"!=typeof h)throw new TypeError("Object expected");(c=i(h.get))&&(l.get=c),(c=i(h.set))&&(l.set=c),(c=i(h.init))&&o.unshift(c)}else(c=i(h))&&("field"===s?o.unshift(c):l[u]=c)}f&&Object.defineProperty(f,n.name,l),p=!0}function l(e,t,r){for(var n=arguments.length>2,o=0;o<t.length;o++)r=n?t[o].call(e,r):t[o].call(e);return n?r:void 0}function p(e){return"symbol"==typeof e?e:"".concat(e)}function _(e,t,r){return"symbol"==typeof t&&(t=t.description?"[".concat(t.description,"]"):""),Object.defineProperty(e,"name",{configurable:!0,value:r?"".concat(r," ",t):t})}function y(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function d(e,t,r,n){return new(r||(r=Promise))((function(o,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function c(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,c)}s((n=n.apply(e,t||[])).next())}))}function h(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&c[0]?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,n=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=t.call(e,a)}catch(e){c=[6,e],n=0}finally{r=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}function v(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||(0,r.__createBinding)(t,e,n)}function b(e){var t="function"==typeof Symbol&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function w(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,o,a=r.call(e),i=[];try{for(;(void 0===t||t-- >0)&&!(n=a.next()).done;)i.push(n.value)}catch(e){o={error:e}}finally{try{n&&!n.done&&(r=a.return)&&r.call(a)}finally{if(o)throw o.error}}return i}function m(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(w(arguments[t]));return e}function g(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;var n=Array(e),o=0;for(t=0;t<r;t++)for(var a=arguments[t],i=0,c=a.length;i<c;i++,o++)n[o]=a[i];return n}function O(e,t,r){if(r||2===arguments.length)for(var n,o=0,a=t.length;o<a;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))}function j(e){return this instanceof j?(this.v=e,this):new j(e)}function P(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n,o=r.apply(e,t||[]),a=[];return n=Object.create(("function"==typeof AsyncIterator?AsyncIterator:Object).prototype),i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,u)}})),n[Symbol.asyncIterator]=function(){return this},n;function i(e,t){o[e]&&(n[e]=function(t){return new Promise((function(r,n){a.push([e,t,r,n])>1||c(e,t)}))},t&&(n[e]=t(n[e])))}function c(e,t){try{(r=o[e](t)).value instanceof j?Promise.resolve(r.value.v).then(s,u):f(a[0][2],r)}catch(e){f(a[0][3],e)}var r}function s(e){c("next",e)}function u(e){c("throw",e)}function f(e,t){e(t),a.shift(),a.length&&c(a[0][0],a[0][1])}}function S(e){var t,r;return t={},n("next"),n("throw",(function(e){throw e})),n("return"),t[Symbol.iterator]=function(){return this},t;function n(n,o){t[n]=e[n]?function(t){return(r=!r)?{value:j(e[n](t)),done:!1}:o?o(t):t}:o}}function E(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,r=e[Symbol.asyncIterator];return r?r.call(e):(e=b(e),t={},n("next"),n("throw"),n("return"),t[Symbol.asyncIterator]=function(){return this},t);function n(r){t[r]=e[r]&&function(t){return new Promise((function(n,o){(function(e,t,r,n){Promise.resolve(n).then((function(t){e({value:t,done:r})}),t)})(n,o,(t=e[r](t)).done,t.value)}))}}}function x(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}r.__assign=function(){return r.__assign=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.__assign.apply(this,arguments)},r.__createBinding=Object.create?function(e,t,r,n){void 0===n&&(n=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,o)}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]};var T=Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t},I=function(e){return I=Object.getOwnPropertyNames||function(e){var t=[];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[t.length]=r);return t},I(e)};function D(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=I(e),o=0;o<n.length;o++)"default"!==n[o]&&(0,r.__createBinding)(t,e,n[o]);return T(t,e),t}function R(e){return e&&e.__esModule?e:{default:e}}function k(e,t,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(e):n?n.value:t.get(e)}function A(e,t,r,n,o){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!o)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!o:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?o.call(e,r):o?o.value=r:t.set(e,r),r}function F(e,t){if(null===t||"object"!=typeof t&&"function"!=typeof t)throw new TypeError("Cannot use 'in' operator on non-object");return"function"==typeof e?t===e:e.has(t)}function C(e,t,r){if(null!=t){if("object"!=typeof t&&"function"!=typeof t)throw new TypeError("Object expected.");var n,o;if(r){if(!Symbol.asyncDispose)throw new TypeError("Symbol.asyncDispose is not defined.");n=t[Symbol.asyncDispose]}if(void 0===n){if(!Symbol.dispose)throw new TypeError("Symbol.dispose is not defined.");n=t[Symbol.dispose],r&&(o=n)}if("function"!=typeof n)throw new TypeError("Object not disposable.");o&&(n=function(){try{o.call(this)}catch(e){return Promise.reject(e)}}),e.stack.push({value:t,dispose:n,async:r})}else r&&e.stack.push({async:!0});return t}var B="function"==typeof SuppressedError?SuppressedError:function(e,t,r){var n=new Error(r);return n.name="SuppressedError",n.error=e,n.suppressed=t,n};function G(e){function t(t){e.error=e.hasError?new B(t,e.error,"An error was suppressed during disposal."):t,e.hasError=!0}var r,n=0;return function o(){for(;r=e.stack.pop();)try{if(!r.async&&1===n)return n=0,e.stack.push(r),Promise.resolve().then(o);if(r.dispose){var a=r.dispose.call(r.value);if(r.async)return n|=2,Promise.resolve(a).then(o,(function(e){return t(e),o()}))}else n|=1}catch(e){t(e)}if(1===n)return e.hasError?Promise.reject(e.error):Promise.resolve();if(e.hasError)throw e.error}()}function z(e,t){return"string"==typeof e&&/^\.\.?\//.test(e)?e.replace(/\.(tsx)$|((?:\.d)?)((?:\.[^./]+?)?)\.([cm]?)ts$/i,(function(e,r,n,o,a){return r?t?".jsx":".js":!n||o&&a?n+o+"."+a.toLowerCase()+"js":e})):e}r.default={__extends:i,__assign:r.__assign,__rest:c,__decorate:s,__param:u,__esDecorate:f,__runInitializers:l,__propKey:p,__setFunctionName:_,__metadata:y,__awaiter:d,__generator:h,__createBinding:r.__createBinding,__exportStar:v,__values:b,__read:w,__spread:m,__spreadArrays:g,__spreadArray:O,__await:j,__asyncGenerator:P,__asyncDelegator:S,__asyncValues:E,__makeTemplateObject:x,__importStar:D,__importDefault:R,__classPrivateFieldGet:k,__classPrivateFieldSet:A,__classPrivateFieldIn:F,__addDisposableResource:C,__disposeResources:G,__rewriteRelativeImportExtension:z}}, function _(e,o,s,t,l){t();const n=e(1);l("version",e(3).version),l("index",e(4).index),s.embed=n.__importStar(e(4)),s.protocol=n.__importStar(e(74));var r=e(20);l("logger",r.logger),l("set_log_level",r.set_log_level),l("settings",e(30).settings),l("Models",e(7).Models),l("documents",e(5).documents),l("safely",e(75).safely)}, function _(n,i,o,c,e){c(),o.version="3.7.2"}, function _(e,o,t,n,r){n(),t.embed_item=async function(e,o){const t={},n=(0,_.uuid4)();t[n]=e.doc,null==o&&(o=e.target_id);const r={roots:{[e.root_id]:o},root_ids:[e.root_id],docid:n};await(0,u.defer)();const[s]=await k(t,[r]);return s},t.embed_items=async function(e,o,t,n){return await(0,u.defer)(),k(e,o,t,n)};const s=e(5),d=e(30),i=e(20),_=e(40),c=e(9),a=e(8),u=e(17),l=e(54),m=e(67),f=e(72);var w=e(54);r("add_document_standalone",w.add_document_standalone),r("index",w.index),r("add_document_from_session",e(67).add_document_from_session);var g=e(73);async function k(e,o,t,n){(0,a.isString)(e)&&(e=JSON.parse((0,_.unescape)(e)));const r={};for(const[o,t]of(0,c.entries)(e))r[o]=s.Document.from_json(t);const u=[];for(const e of o){const o=(0,f._resolve_element)(e),s=(0,f._resolve_root_elements)(e);if(null!=e.docid)u.push(await(0,l.add_document_standalone)(r[e.docid],o,s,e.use_for_title));else{if(null==e.token)throw new Error("Error rendering Bokeh items: either 'docid' or 'token' was expected.");{const r=(0,m._get_ws_url)(t,n);i.logger.debug(`embed: computed ws url: ${r}`);try{u.push(await(0,m.add_document_from_session)(r,e.token,o,s,e.use_for_title)),console.log("Bokeh items were rendered successfully")}catch(e){if(d.settings.dev)throw e;console.error("Error rendering Bokeh items:",e)}}}}return u}r("embed_items_notebook",g.embed_items_notebook),r("kernels",g.kernels)}, function _(t,_,o,r,n){r();const a=t(1);a.__exportStar(t(6),o),a.__exportStar(t(41),o)}, function _(e,t,s,o,_){o();const n=e(1),i=e(7),l=e(3),r=e(20),a=e(15),c=e(46),h=e(33),d=e(47),m=e(49),u=e(16),f=e(8),p=e(27),g=e(10),v=e(9),w=n.__importStar(e(44)),y=e(50),b=e(12),k=e(51),z=e(52),S=e(53),E=e(53),D=e(41);d.Deserializer.register("model",z.decode_def);class M{constructor(e){this.subscribed_models=new Set,this.document=e}send_event(e){if(e.publish){const t=new D.MessageSentEvent(this.document,"bokeh_event",e);this.document._trigger_on_change(t)}this.document._trigger_on_event(e)}trigger(e){for(const t of this.subscribed_models)null!=e.origin&&e.origin!=t||t._process_event(e)}}s.EventManager=M,M.__name__="EventManager",s.documents=[],s.DEFAULT_TITLE="Bokeh Application";class j{constructor(e={}){this._hold_models_freeze=!1,this._recompute_timer=null,s.documents.push(this),this._init_timestamp=Date.now(),this._resolver=e.resolver??new c.ModelResolver(i.default_resolver),this._title=s.DEFAULT_TITLE,this._roots=[],this._all_models=new Map,this._new_models=new Set,this._all_models_freeze_count=0,this._callbacks=new Map,this._document_callbacks=new Map,this._message_callbacks=new Map,this.event_manager=new M(this),this.idle=new u.Signal0(this,"idle"),this._idle_roots=new WeakSet,this._interactive_timestamp=null,this._interactive_plot=null,this._recompute_timeout=e.recompute_timeout??3e4,null!=e.roots&&this._add_roots(...e.roots),this.on_message("bokeh_event",(e=>{(0,b.assert)(e instanceof S.ModelEvent),this.event_manager.trigger(e)}))}[p.equals](e,t){return this==e}get all_models(){return new Set(this._all_models.values())}get is_idle(){for(const e of this._roots)if(!this._idle_roots.has(e))return!1;return!0}notify_idle(e){this._idle_roots.add(e),this.is_idle&&(r.logger.info(`document idle at ${Date.now()-this._init_timestamp} ms`),this.event_manager.send_event(new E.DocumentReady),this.idle.emit())}clear(){this._push_all_models_freeze();try{for(;this._roots.length>0;)this.remove_root(this._roots[0])}finally{this._pop_all_models_freeze()}}interactive_start(e,t=null){null==this._interactive_plot&&(this._interactive_plot=e,this._interactive_plot.trigger_event(new E.LODStart)),this._interactive_finalize=t,this._interactive_timestamp=Date.now()}interactive_stop(){null!=this._interactive_plot&&(this._interactive_plot.trigger_event(new E.LODEnd),null!=this._interactive_finalize&&this._interactive_finalize()),this._interactive_plot=null,this._interactive_timestamp=null,this._interactive_finalize=null}interactive_duration(){return null==this._interactive_timestamp?-1:Date.now()-this._interactive_timestamp}destructively_move(e){if(e===this)throw new Error("Attempted to overwrite a document with itself");e.clear();const t=(0,g.copy)(this._roots);this.clear();for(const e of t)if(null!=e.document)throw new Error(`Somehow we didn't detach ${e}`);if(0!=this._all_models.size)throw new Error(`this._all_models still had stuff in it: ${this._all_models}`);for(const s of t)e.add_root(s);e.set_title(this._title)}_push_all_models_freeze(){this._hold_models_freeze||(this._all_models_freeze_count+=1)}_pop_all_models_freeze(){this._hold_models_freeze||(this._all_models_freeze_count-=1,0===this._all_models_freeze_count&&this._recompute_all_models())}_cancel_recompute_all_models(){null!=this._recompute_timer&&(clearTimeout(this._recompute_timer),this._recompute_timer=null)}_schedule_recompute_all_models(){const e=this._recompute_timeout;isNaN(e)||e<=0?this._recompute_all_models():isFinite(e)&&(this._cancel_recompute_all_models(),this._recompute_timer=setTimeout((()=>{this._recompute_all_models()}),e))}_recompute_all_models(){this._cancel_recompute_all_models();let e=new Set;for(const t of this._roots)e=w.union(e,t.references());const t=new Set(this._all_models.values()),s=w.difference(t,e),o=w.difference(e,t),_=new Map;for(const t of e)_.set(t.id,t);for(const e of s)e.detach_document();for(const e of o)e.attach_document(this),this._new_models.add(e);this._all_models=_}partially_update_all_models(e){const t=new Set;a.HasProps._value_record_references(e,t,{recursive:!1});for(const e of t)this._all_models.has(e.id)||(e.attach_document(this),this._new_models.add(e),this._all_models.set(e.id,e));this._schedule_recompute_all_models()}roots(){return this._roots}_add_roots(...e){if(0==(e=e.filter((e=>!this._roots.includes(e)))).length)return!1;this._push_all_models_freeze();try{this._roots.push(...e)}finally{this._pop_all_models_freeze()}return!0}_remove_root(e){const t=this._roots.indexOf(e);if(t<0)return!1;this._push_all_models_freeze();try{this._roots.splice(t,1)}finally{this._pop_all_models_freeze()}return!0}_set_title(e){const t=e!=this._title;return t&&(this._title=e),t}add_root(e,{sync:t}={}){if(this._add_roots(e)){const s=new D.RootAddedEvent(this,e);s.sync=t??!0,this._trigger_on_change(s)}}remove_root(e,{sync:t}={}){if(this._remove_root(e)){const s=new D.RootRemovedEvent(this,e);s.sync=t??!0,this._trigger_on_change(s)}}set_title(e,{sync:t}={}){if(this._set_title(e)){const s=new D.TitleChangedEvent(this,e);s.sync=t??!0,this._trigger_on_change(s)}}title(){return this._title}get_model_by_id(e){return this._all_models.get(e)??null}get_model_by_name(e){const t=[];for(const s of this._all_models.values())s instanceof k.Model&&s.name==e&&t.push(s);switch(t.length){case 0:return null;case 1:return t[0];default:throw new Error(`Multiple models are named '${e}'`)}}on_message(e,t){const s=this._message_callbacks.get(e);null==s?this._message_callbacks.set(e,new Set([t])):s.add(t)}remove_on_message(e,t){this._message_callbacks.get(e)?.delete(t)}_trigger_on_message(e,t){const s=this._message_callbacks.get(e);if(null!=s)for(const e of s)e(t)}on_change(e,t=!1){this._callbacks.has(e)||this._callbacks.set(e,t)}remove_on_change(e){this._callbacks.delete(e)}_trigger_on_change(e){for(const[t,s]of this._callbacks)if(!s&&e instanceof D.DocumentEventBatch)for(const s of e.events)t(s);else t(e)}_trigger_on_event(e){const t=this._document_callbacks.get(e.event_name);if(null!=t)for(const s of t)(0,y.execute)(s,this,e)}on_event(e,...t){const s=(0,f.isString)(e)?e:e.prototype.event_name,o=this._document_callbacks.get(s)??[],_=t;this._document_callbacks.set(s,[...o,..._])}to_json_string(e=!0){return JSON.stringify(this.to_json(e))}to_json(e=!0){const t=new h.Serializer({include_defaults:e}).encode(this._roots);return{version:l.version,title:this._title,roots:t}}static from_json_string(e,t){const s=JSON.parse(e);return j.from_json(s,t)}static _handle_version(e){null==e.version&&r.logger.warn("'version' field is missing");const t=e.version??"0.0.0",s=m.Version.from(t),o=m.Version.from(l.version),_=`new document using Bokeh ${t} and BokehJS ${l.version}`;(0,p.is_equal)(s,o)?r.logger.debug(_):r.logger.warn(`Bokeh/BokehJS version mismatch: ${_}`)}static from_json(e,t){r.logger.debug("Creating Document from JSON"),j._handle_version(e);const s=new c.ModelResolver(i.default_resolver);if(null!=e.defs){new d.Deserializer(s).decode(e.defs)}const o=new j({resolver:s});o._push_all_models_freeze();const _=e=>t?.push(e);o.on_change(_,!0);const n=new d.Deserializer(s,o._all_models,(e=>e.attach_document(o))),l=n.decode(e.roots),a=null!=e.callbacks?n.decode(e.callbacks):{};o.remove_on_change(_);for(const[e,t]of(0,v.entries)(a))o.on_event(e,...t);for(const e of l)o.add_root(e);return null!=e.title&&o.set_title(e.title),o._pop_all_models_freeze(),o}replace_with_json(e){j.from_json(e).destructively_move(this)}create_json_patch(e){for(const t of e)if(t.document!=this)throw new Error("Cannot create a patch using events from a different document");const t=new Map;for(const e of this._all_models.values())this._new_models.has(e)||t.set(e,e.ref());const s={events:new h.Serializer({references:t,binary:!0}).encode(e)};return this._new_models.clear(),s}apply_json_patch(e,t=new Map){const{_hold_models_freeze:s}=this;this._hold_models_freeze=!0;try{this._apply_json_patch(e,t)}finally{this._hold_models_freeze=s}this._schedule_recompute_all_models()}_apply_json_patch(e,t=new Map){const s=new d.Deserializer(this._resolver,this._all_models,(e=>{e.attach_document(this),this._new_models.add(e),this._all_models.set(e.id,e)})).decode(e.events,t);for(const e of s)switch(e.kind){case"MessageSent":{const{msg_type:t,msg_data:s}=e;this._trigger_on_message(t,s);break}case"ModelChanged":{const{model:t,attr:s,new:o}=e;t.setv({[s]:o},{sync:!1});break}case"ColumnDataChanged":{const{model:t,attr:s,data:o,cols:_}=e;if(null!=_){const e=(0,v.dict)(o),_=(0,v.dict)(t.property(s).get_value());for(const[t,s]of _)e.has(t)||e.set(t,s)}t.setv({data:o},{sync:!1,check_eq:!1});break}case"ColumnsStreamed":{const{model:t,attr:s,data:o,rollover:_}=e,n=t.property(s);t.stream_to(n,o,_,{sync:!1});break}case"ColumnsPatched":{const{model:t,attr:s,patches:o}=e,_=t.property(s);t.patch_to(_,o,{sync:!1});break}case"RootAdded":this.add_root(e.model,{sync:!1});break;case"RootRemoved":this.remove_root(e.model,{sync:!1});break;case"TitleChanged":this.set_title(e.title,{sync:!1});break;default:throw new Error(`unknown patch event type '${e.kind}'`)}}}s.Document=j,j.__name__="Document"}, function _(e,r,t,n,s){n(),t.register_models=function(e,r=!1){for(const s of(0,l.isArray)(e)?e:(0,o.values)(e))n=s,(0,l.isObject)(n)&&n.prototype instanceof u.HasProps&&t.default_resolver.register(s,r);var n};const l=e(8),o=e(9),i=e(8),u=e(15),f=e(46);t.default_resolver=new f.ModelResolver(null),t.Models=new Proxy(t.default_resolver,{get(e,r,t){if((0,i.isString)(r)){const t=e.get(r);if(null!=t)return t}return Reflect.get(e,r,t)},has(e,r){if((0,i.isString)(r)){if(null!=e.get(r))return!0}return Reflect.has(e,r)},ownKeys:e=>e.names,getOwnPropertyDescriptor(e,r){if((0,i.isString)(r)){const t=e.get(r);if(null!=t)return{configurable:!0,enumerable:!0,writable:!1,value:t}}return Reflect.getOwnPropertyDescriptor(e,r)}})}, function _(n,r,t,e,i){e(),t.is_undefined=function(n){return void 0===n},t.is_defined=function(n){return void 0!==n},t.is_nullish=u,t.isBoolean=c,t.isNumber=f,t.isInteger=function(n){return f(n)&&Number.isInteger(n)},t.isString=s,t.isSymbol=a,t.isPrimitive=function(n){return null===n||c(n)||f(n)||s(n)||a(n)},t.isFunction=function(n){switch(o.call(n)){case"[object Function]":case"[object AsyncFunction]":case"[object GeneratorFunction]":case"[object AsyncGeneratorFunction]":return!0;default:return!1}},t.isArray=l,t.isArrayOf=function(n,r){if(!l(n))return!1;for(const t of n)if(!r(t))return!1;return!0},t.isArrayableOf=function(n,r){if(!j(n))return!1;for(const t of n)if(!r(t))return!1;return!0},t.isTypedArray=function(n){return ArrayBuffer.isView(n)&&!(n instanceof DataView)},t.isObject=b,t.isBasicObject=function(n){return b(n)&&u(n.constructor)},t.isPlainObject=y,t.isDict=function(n){return n instanceof Map||y(n)},t.isIterable=A,t.isArrayable=j,t.is_ArrayBufferLike=function(n){return n instanceof ArrayBuffer||"undefined"!=typeof SharedArrayBuffer&&n instanceof SharedArrayBuffer}; // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Underscore may be freely distributed under the MIT license. const{toString:o}=Object.prototype;function u(n){return null==n}function c(n){return!0===n||!1===n||"[object Boolean]"===o.call(n)}function f(n){return"[object Number]"===o.call(n)}function s(n){return"[object String]"===o.call(n)}function a(n){return"symbol"==typeof n}function l(n){return Array.isArray(n)}function b(n){const r=typeof n;return"function"===r||"object"===r&&!!n}function y(n){return b(n)&&(u(n.constructor)||n.constructor===Object)}function A(n){return b(n)&&Symbol.iterator in n}function j(n){return A(n)&&"length"in n}}, function _(e,t,n,s,i){var o;s(),n.to_object=function(e){return(0,r.isPlainObject)(e)?e:Object.fromEntries(e)},n.keys=a,n.values=u,n.entries=b,n.clone=function(e){return e instanceof Map?new Map(e):{...e}},n.merge=function(e,t){const n=new Map,s=[...e.keys(),...t.keys()];for(const i of s){const s=e.get(i),o=t.get(i),r=void 0===s?[]:s,a=void 0===o?[]:o;n.set(i,(0,c.union)(r,a))}return n},n.size=l,n.is_empty=function(e){return 0==l(e)},n.dict=function(e){return(0,r.isPlainObject)(e)?new h(e):e};const r=e(8),c=e(10);function a(e){return e instanceof Map?[...e.keys()]:Object.keys(e)}function u(e){return e instanceof Map?[...e.values()]:Object.values(e)}function b(e){return e instanceof Map?[...e.entries()]:Object.entries(e)}function l(e){return e instanceof Map?e.size:Object.keys(e).length}n.assign=Object.assign,n.extend=n.assign,n.typed_keys=Object.keys,n.typed_values=Object.values,n.typed_entries=Object.entries;const{hasOwnProperty:j}=Object.prototype;class h{constructor(e){this[o]="PlainObjectProxy",this.obj=e}clear(){for(const e of this.keys())delete this.obj[e]}delete(e){const t=this.has(e);return t&&delete this.obj[e],t}has(e){return j.call(this.obj,e)}get(e){return this.has(e)?this.obj[e]:void 0}set(e,t){return this.obj[e]=t,this}get size(){return l(this.obj)}[(o=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}*keys(){yield*a(this.obj)}*values(){yield*u(this.obj)}*entries(){yield*b(this.obj)}forEach(e,t){for(const[n,s]of this.entries())e.call(t,s,n,this)}}n.PlainObjectProxy=h,h.__name__="PlainObjectProxy"}, function _(n,t,e,r,o){r(),e.head=function(n){if(0!=n.length)return n[0];throw new Error("out of bounds access")},e.last=function(n){if(0!=n.length)return n[n.length-1];throw new Error("out of bounds access")},e.copy=a,e.concat=function(n){return[].concat(...n)},e.nth=function(n,t){return n[t>=0?t:n.length+t]},e.zip=function(...n){if(0==n.length)return[];const t=(0,u.min)(n.map((n=>n.length))),e=n.length,r=new Array(t);for(let o=0;o<t;o++){r[o]=new Array(e);for(let t=0;t<e;t++)r[o][t]=n[t][o]}return r},e.unzip=function(n){const t=n.length;if(0==t)return[];const e=(0,u.min)(n.map((n=>n.length))),r=Array(e);for(let n=0;n<e;n++)r[n]=new Array(t);for(let o=0;o<t;o++)for(let t=0;t<e;t++)r[t][o]=n[o][t];return r},e.range=h,e.linspace=function(n,t,e=100){const r=1==e?0:(t-n)/(e-1),o=new Array(e);for(let t=0;t<e;t++)o[t]=n+t*r;return o},e.logspace=function(n,t,e=100,r=10){const o=1==e?0:(t-n)/(e-1),c=new Array(e);for(let t=0;t<e;t++)c[t]=r**(n+t*o);return c},e.transpose=function(n){const t=n.length,e=n[0].length,r=[];for(let o=0;o<e;o++){r[o]=[];for(let e=0;e<t;e++)r[o][e]=n[e][o]}return r},e.argmin=function(n){return(0,u.min_by)(h(n.length),(t=>n[t]))},e.argmax=function(n){return(0,u.max_by)(h(n.length),(t=>n[t]))},e.argsort=function(n){const t=Array.from(n.keys());return t.sort(((t,e)=>n[t]-n[e])),t},e.uniq=function(n){const t=new Set;for(const e of n)t.add(e);return[...t]},e.uniq_by=function(n,t){const e=[],r=[];for(const o of n){const n=t(o);(0,u.includes)(r,n)||(r.push(n),e.push(o))}return e},e._union=m,e.union=function(...n){return[...m(n)]},e.intersection=function(n,...t){const e=[];n:for(const r of n)if(!(0,u.includes)(e,r)){for(const n of t)if(!(0,u.includes)(n,r))continue n;e.push(r)}return e},e.difference=function(n,...t){const e=m(t);return(0,u.filter)(n,(n=>!e.has(n)))},e.symmetric_difference=function(n,t){const e=new Set(n),r=new Set(t),o=[];for(const n of e)r.has(n)||o.push(n);for(const n of r)e.has(n)||o.push(n);return o},e.remove_at=function(n,t){(0,i.assert)((0,s.isInteger)(t)&&t>=0);const e=a(n);return e.splice(t,1),e},e.remove=function(n,t){d(n,(n=>n==t))},e.remove_by=d,e.clear=function(n){n.splice(0,n.length)},e.split=function(n,t){const e=[],r=n.length;let o=0,c=0;for(;c<r;)n[c]===t?(e.push(n.slice(o,c)),o=++c):++c;return e.push(n.slice(o)),e},e.shuffle=function(n){const t=n.length,e=new Array(t);for(let r=0;r<t;r++){const t=(0,c.randomIn)(0,r);t!==r&&(e[r]=e[t]),e[t]=n[r]}return e},e.pairwise=function(n,t){const e=n.length,r=new Array(e-1);for(let o=0;o<e-1;o++)r[o]=t(n[o],n[o+1]);return r},e.elementwise=function(n,t,e){const r=Math.min(n.length,t.length),o=Array(r);for(let c=0;c<r;c++)o[c]=e(n[c],t[c]);return o},e.reversed=function(n){const t=n.length,e=new Array(t);for(let r=0;r<t;r++)e[t-r-1]=n[r];return e},e.repeat=function(n,t){return new Array(t).fill(n)},e.resize=function(n,t,e){if(n.length>=t)return n.slice(0,t);{const r=new Array(t-n.length);return void 0!==e&&r.fill(e),n.concat(r)}}; // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors // Underscore may be freely distributed under the MIT license. const c=n(11),i=n(12),s=n(8),u=n(13);var f=n(13);o("map",f.map),o("reduce",f.reduce),o("min",f.min),o("min_by",f.min_by),o("max",f.max),o("max_by",f.max_by),o("sum",f.sum),o("cumsum",f.cumsum),o("every",f.every),o("some",f.some),o("find",f.find),o("find_last",f.find_last),o("find_index",f.find_index),o("find_last_index",f.find_last_index),o("sorted_index",f.sorted_index),o("is_empty",f.is_empty),o("includes",f.includes),o("contains",f.contains),o("sort_by",f.sort_by);const{slice:l}=Array.prototype;function a(n){return l.call(n)}function h(n,t,e=1){(0,i.assert)(e>0,"'step' must be a positive number"),null==t&&(t=n,n=0);const{max:r,ceil:o,abs:c}=Math,s=n<=t?e:-e,u=r(o(c(t-n)/e),0),f=new Array(u);for(let t=0;t<u;t++,n+=s)f[t]=n;return f}function m(n){const t=new Set;for(const e of n)for(const n of e)t.add(n);return t}function d(n,t){for(let e=0;e<n.length;)t(n[e])?n.splice(e,1):e++}}, function _(n,t,r,o,e){o(),r.angle_norm=s,r.angle_dist=h,r.angle_between=function(n,t,r,o=!1){const e=h(t,r);if(0==e)return!1;if(e==2*u)return!0;const a=s(n),c=h(t,a)<=e&&h(a,r)<=e;return o?!c:c},r.randomIn=function(n,t){null==t&&(t=n,n=0);return n+Math.floor(Math.random()*(t-n+1))},r.atan2=function(n,t){return Math.atan2(t[1]-n[1],t[0]-n[0])},r.radians=function(n){return n*(u/180)},r.degrees=function(n){return n/(u/180)},r.compute_angle=g,r.invert_angle=function(n,t,r="anticlock"){const o="anticlock"==r?1:-1;return-o*n/m(t)},r.to_radians_coeff=m,r.minmax=function(n,t){return n<=t?[n,t]:[t,n]},r.clamp=function(n,t,r){return n<t?t:n>r?r:n},r.cycle=function(n,t,r){if(n>r)return t;if(n<t)return r;return n},r.log=function(n,t=Math.E){return Math.log(n)/Math.log(t)},r.gcd=_,r.lcm=function(n,...t){for(const r of t)n=Math.floor(n*r/_(n,r));return n},r.is_Floating=function(n){return(0,a.isObject)(n)&&r.float in n},r.factorial=M,r.hermite=function(n){const t=new Array(n+1);t.fill(0);const r=M(n);for(let o=0;o<=Math.floor(n/2);o++){const e=(-1)**o*r/(M(o)*M(n-2*o))*2**(n-2*o);t[2*o]=e}return t},r.eval_poly=function(n,t){const r=n.length-1;let o=0,e=1;for(let a=r;a>=0;a--)o+=e*n[a],e*=t;return o};const a=n(8),c=n(12),{PI:u,abs:i,sign:f,sqrt:l}=Math;function s(n){if(0==n)return 0;for(;n<=0;)n+=2*u;for(;n>2*u;)n-=2*u;return n}function h(n,t){return s(n-t)}function g(n,t,r="anticlock"){return-("anticlock"==r?1:-1)*n*m(t)}function m(n){switch(n){case"deg":return u/180;case"rad":return 1;case"grad":return u/200;case"turn":return 2*u}}function _(n,t){for(n=Math.abs(n),t=Math.abs(t);0!=t;)[n,t]=[t,n%t];return n}r.PI=u,r.abs=i,r.sqrt=l,r.resolve_angle=g,r.float=Symbol("float");class d{constructor(n,t){(0,c.assert)(0!=t,"Zero divisor");const r=_(n,t),o=f(n)*f(t);this.numer=o*i(n)/r,this.denom=i(t)/r}[r.float](){return this.numer/this.denom}toString(){return`${this.numer}/${this.denom}`}}function M(n){let t=1;for(let r=2;r<=n;r++)t*=r;return t}r.Fraction=d,d.__name__="Fraction",r.float32_epsilon=1.1920928955078125e-7}, function _(r,e,n,o,s){o(),n.assert=c,n.assert_debug=function(r,e){"undefined"!=typeof DEBUG&&DEBUG&&c(r,e)},n.unreachable=function(r){throw new t("unreachable code"+(null!=r?`: ${r}`:""))};class a extends Error{}n.AssertionError=a,a.__name__="AssertionError";class t extends Error{}function c(r,e){if(!(!0===r||!1!==r&&r()))throw new a(e??"Assertion failed")}n.UnreachableError=t,t.__name__="UnreachableError"}, function _(n,t,e,r,o){r(),e.is_empty=function(n){return 0==n.length},e.is_sorted=l,e.copy=s,e.splice=a,e.head=h,e.insert=function(n,t,e){return a(n,e,0,t)},e.append=function(n,t){return a(n,n.length,0,t)},e.prepend=function(n,t){return a(n,0,0,t)},e.index_of=function(n,t){return n.indexOf(t)},e.includes=g,e.subselect=function(n,t){const e=t.length,r=new n.constructor(e);for(let o=0;o<e;o++)r[o]=n[t[o]];return r},e.mul=function(n,t,e){const r=n.length,o=e??new n.constructor(r);for(let e=0;e<r;e++)o[e]=n[e]*t;return o},e.map=d,e.inplace_map=function(n,t,e){const r=n.length,o=e??n;for(let e=0;e<r;e++)o[e]=t(n[e],e)},e.filter=function(n,t){const e=n.length,r=new n.constructor(e);let o=0;for(let i=0;i<e;i++){const e=n[i];t(e,i,n)&&(r[o++]=e)}return h(r,o)},e.reduce=_,e.sort_by=function(n,t){const e=Array.from(n,((n,e)=>({index:e,key:t(n)})));return e.sort(((n,t)=>{const e=n.key,r=t.key;if(e!==r){if(e>r)return 1;if(e<r)return-1}return n.index-t.index})),d(n,((t,r)=>n[e[r].index]))},e.minmax2=function(n,t){let e,r,o=1/0,i=-1/0,c=1/0,u=-1/0;const f=Math.min(n.length,t.length);for(let l=0;l<f;l++)e=n[l],r=t[l],isNaN(e)||isNaN(r)||(e<o&&(o=e),e>i&&(i=e),r<c&&(c=r),r>u&&(u=r));return[o,i,c,u]},e.min_by=function(n,t){if(0==n.length)throw new Error("min_by() called with an empty array");let e=n[0],r=t(e,0);for(let o=1,i=n.length;o<i;o++){const i=n[o],c=t(i,o);c<r&&(e=i,r=c)}return e},e.max_by=function(n,t){if(0==n.length)throw new Error("max_by() called with an empty array");let e=n[0],r=t(e,0);for(let o=1,i=n.length;o<i;o++){const i=n[o],c=t(i,o);c>r&&(e=i,r=c)}return e},e.sum=function(n){let t=0;for(let e=0,r=n.length;e<r;e++)t+=n[e];return t},e.cumsum=function(n){const t=new n.constructor(n.length);return _(n,((n,e,r)=>t[r]=n+e),0),t},e.every=function(n,t){for(const e of n)if(!t(e))return!1;return!0},e.some=function(n,t){for(const e of n)if(t(e))return!0;return!1},e.find=function(n,t){const r=(0,e.find_index)(n,t);return-1==r?void 0:n[r]},e.find_last=function(n,t){const r=(0,e.find_last_index)(n,t);return-1==r?void 0:n[r]},e.bisect_left_by=y,e.bisect_right_by=x,e.bisect_left=p,e.bisect_right=function(n,t,e=0,r){return x(n,t,(n=>n),e,r)},e.binary_search=function(n,t){const e=p(n,t);return e!=n.length&&n[e]==t?e:null},e.bin_counts=function(n,t){const r=t.length-1,o=Array(r).fill(0);for(let c=0;c<n.length;c++){const u=n[c],f=(0,e.sorted_index)(t,u);o[(0,i.clamp)(f-1,0,r-1)]+=1}return o},e.interpolate=function(n,t,e){const r=n.length,o=new Array(r);for(let i=0;i<r;i++){const r=n[i];if(isNaN(r)||0==t.length){o[i]=NaN;continue}const c=b(r,t);if(-1==c)o[i]=e[0];else if(c==t.length)o[i]=e[e.length-1];else if(c==t.length-1||t[c]==r)o[i]=e[c];else{const n=t[c],u=e[c],f=t[c+1],l=e[c+1];o[i]=w(r,n,u,f,l)}}return o},e.left_edge_index=b,e.norm=function(n,t,e){const r=e-t;return d(n,(n=>(n-t)/r))};const i=n(11),c=n(12);var u=n(14);o("min",u.min),o("max",u.max),o("minmax",u.minmax);const{floor:f}=Math;function l(n){const t=n.length;if(0==t)return!0;let e=n[0];for(let r=1;r<t;r++){const t=n[r];if(!(e<=t))return!1;e=t}return!0}function s(n){return Array.isArray(n)?n.slice():new n.constructor(n)}function a(n,t,e,...r){if(Array.isArray(n)){const o=s(n);return void 0===e?o.splice(t):o.splice(t,e,...r),o}const o=n.length;t<0&&(t+=o),t<0?t=0:t>o&&(t=o),null==e||e>o-t?e=o-t:e<0&&(e=0);const i=o-e+r.length,c=new n.constructor(i);let u=0;for(;u<t;u++)c[u]=n[u];for(const n of r)c[u++]=n;for(let r=t+e;r<o;r++)c[u++]=n[r];return c}function h(n,t){return a(n,t,n.length-t)}function g(n,t){return-1!==n.indexOf(t)}function d(n,t){const e=n.length,r=new n.constructor(e);for(let o=0;o<e;o++)r[o]=t(n[o],o,n);return r}function _(n,t,e){const r=n.length;if(void 0===e&&0==r)throw new Error("can't reduce an empty array without an initial value");let o,i;for(void 0===e?(o=n[0],i=1):(o=e,i=0);i<r;i++)o=t(o,n[i],i,n);return o}function m(n){return function(t,e){const r=t.length;let o=n>0?0:r-1;for(;o>=0&&o<r;o+=n)if(e(t[o]))return o;return-1}}function y(n,t,e,r=0,o=n.length){for((0,c.assert_debug)((()=>l(n))),(0,c.assert)(0<=r&&o<=n.length);r<o;){const i=f((r+o)/2);e(n[i])<t?r=i+1:o=i}return r}function x(n,t,e,r=0,o=n.length){for((0,c.assert_debug)((()=>l(n))),(0,c.assert)(0<=r&&o<=n.length);r<o;){const i=f((r+o)/2);e(n[i])<=t?r=i+1:o=i}return r}function p(n,t,e=0,r){return y(n,t,(n=>n),e,r)}function w(n,t,e,r,o){const i=(o-e)/(r-t);let c=i*(n-t)+e;return isFinite(c)||(c=i*(n-r)+o,isFinite(c)||e!=o||(c=e)),c}function b(n,t){if(n<t[0])return-1;if(n>t[t.length-1])return t.length;if(1==t.length)return 0;let e=0,r=t.length-1;for(;r-e!=1;){const o=e+Math.floor((r-e)/2);n>=t[o]?e=o:r=o}return e}e.contains=g,e.find_index=m(1),e.find_last_index=m(-1),e.sorted_index=p}, function _(n,o,t,e,f){e(),t.range=r,t.reverse=function*(n){const o=n.length;for(let t=0;t<o;t++)yield n[o-t-1]},t.enumerate=function*(n){let o=0;for(const t of n)yield[t,o++]},t.take=function*(n,o){(0,i.assert)(o>=0);let t=0;for(const e of n){if(!(t++<o))break;yield e}},t.skip=l,t.tail=function*(n){yield*l(n,1)},t.join=function*(n,o){let t=!0;for(const e of n)t?t=!1:null!=o&&(yield o()),yield*e},t.zip=function*(n,o){const t=n[Symbol.iterator](),e=o[Symbol.iterator]();for(;;){const n=t.next(),o=e.next();if(!0===n.done||!0===o.done)break;yield[n.value,o.value]}},t.interleave=function*(n,o){let t=!0;for(const e of n)t?t=!1:yield o(),yield e},t.map=function*(n,o){let t=0;for(const e of n)yield o(e,t++)},t.flat_map=function*(n,o){let t=0;for(const e of n)yield*o(e,t++)},t.filter=function*(n,o){let t=0;for(const e of n)o(e,t++)&&(yield e)},t.no_repeated=function*(n){let o=c;for(const t of n)t!==o&&(yield t),o=t},t.every=function(n,o){for(const t of n)if(!o(t))return!1;return!0},t.some=function(n,o){for(const t of n)if(o(t))return!0;return!1},t.combinations=s,t.subsets=function*(n){for(const o of r(n.length+1))yield*s(n,o)},t.min=function(n){let o=1/0;for(const t of n)!isNaN(t)&&t<o&&(o=t);return o},t.max=function(n){let o=-1/0;for(const t of n)!isNaN(t)&&t>o&&(o=t);return o},t.minmax=function(n){let o=1/0,t=-1/0;for(const e of n)isNaN(e)||(e<o&&(o=e),e>t&&(t=e));return[o,t]};const i=n(12);function*r(n,o,t=1){(0,i.assert)(t>0);const{abs:e,ceil:f,max:r}=Math;null==o&&(o=n,n=0);const l=n<=o?t:-t,c=r(f(e(o-n)/e(t)),0);for(let o=0;o<c;o++,n+=l)yield n}function*l(n,o){(0,i.assert)(o>=0);for(const t of n)0==o?yield t:o-=1}const c=Symbol("nothing");function*s(n,o){const t=n.length;if(o>t)return;const e=[...r(o)];for(yield e.map((o=>n[o]));;){let f;for(const n of r(o-1,-1))if(e[n]!=n+t-o){f=n;break}if(null==f)return;e[f]+=1;for(const n of r(f+1,o))e[n]=e[n-1]+1;yield e.map((o=>n[o]))}}}, function _(t,e,s,i,n){var r;i();const o=t(1),c=t(16),a=t(18),h=o.__importStar(t(19)),_=o.__importStar(t(22)),p=t(12),u=t(40),l=t(9),f=t(8),d=t(33),g=t(41),y=t(27),m=t(42),v=t(32),w=o.__importStar(t(22)),b=t(29),$=t(43),S=new WeakMap;class x extends((0,c.Signalable)()){get is_syncable(){return!0}get type(){return this.constructor.__qualified__}static get __qualified__(){let t=S.get(this);if(null==t){const{__module__:e,__name__:s}=this;t=null!=e?`${e}.${s}`:s,S.set(this,t)}return t}static set __qualified__(t){S.set(this,t)}get[Symbol.toStringTag](){return this.constructor.__qualified__}static _fix_default(t,e){if(void 0===t||t===h.unset)return()=>h.unset;if((0,f.isFunction)(t))return t;if((0,f.isPrimitive)(t))return()=>t;{const e=new v.Cloner;return()=>e.clone(t)}}static define(t){for(const[e,s]of(0,l.entries)((0,f.isFunction)(t)?t(w):t)){if(e in this.prototype._props)throw new Error(`attempted to redefine property '${this.prototype.type}.${e}'`);if(e in this.prototype)throw new Error(`attempted to redefine attribute '${this.prototype.type}.${e}'`);Object.defineProperty(this.prototype,e,{get(){return this.properties[e].get_value()},set(t){return this.setv({[e]:t}),this},configurable:!1,enumerable:!0});const[t,i,n={}]=s,r={type:t,default_value:this._fix_default(i,e),options:n};this.prototype._props={...this.prototype._props,[e]:r}}}static internal(t){const e={};for(const[s,i]of(0,l.entries)((0,f.isFunction)(t)?t(w):t)){const[t,n,r={}]=i;e[s]=[t,n,{...r,internal:!0}]}this.define(e)}static mixins(t){function e(t,e){const s={};for(const[i,n]of(0,l.entries)(e))s[t+i]=n;return s}const s={},i=[];for(const n of(0,f.isArray)(t)?t:[t])if((0,f.isArray)(n)){const[t,r]=n;(0,l.extend)(s,e(t,r)),i.push([t,r])}else{const t=n;(0,l.extend)(s,t),i.push(["",t])}this.define(s),this.prototype._mixins=[...this.prototype._mixins,...i]}static override(t){for(const[e,s]of(0,l.entries)(t)){const t=this._fix_default(s,e);if(!(e in this.prototype._props))throw new Error(`attempted to override nonexistent '${this.prototype.type}.${e}'`);const i=this.prototype._props[e],n={...this.prototype._props};n[e]={...i,default_value:t},this.prototype._props=n}}static override_options(t){for(const[e,s]of(0,l.entries)(t)){if(!(e in this.prototype._props))throw new Error(`attempted to override nonexistent '${this.prototype.type}.${e}'`);const t=this.prototype._props[e],i={...this.prototype._props,[e]:{...t,options:{...t.options,...s}}};this.prototype._props=i}}static toString(){return this.__qualified__}toString(){return`${this.type}(${this.id})`}property(t){if(t in this.properties)return this.properties[t];throw new Error(`unknown property ${this.type}.${t}`)}get attributes(){const t={};for(const e of this)e.is_unset||(t[e.attr]=e.get_value());return t}get dirty_attributes(){const t={};for(const e of this)!e.is_unset&&e.dirty&&(t[e.attr]=e.get_value());return t}[v.clone](t){const e=new Map;for(const s of this)s.dirty&&e.set(s.attr,t.clone(s.get_value()));return new this.constructor(e)}[y.equals](t,e){for(const s of this){const i=t.property(s.attr);if(!e.eq(s.get_value(),i.get_value()))return!1}return!0}[m.pretty](t){const e=t.token,s=[];for(const i of this)if(i.dirty){const n=i.get_value();s.push(`${i.attr}${e(":")} ${t.to_string(n)}`)}return`${this.constructor.__qualified__}${e("(")}${e("{")}${s.join(`${e(",")} `)}${e("}")}${e(")")}`}[d.serialize](t){const e=this.ref();t.add_ref(this,e);const s={};for(const e of this)if(e.syncable&&(t.include_defaults||e.dirty)&&(!e.readonly||!e.is_unset)){const i=e.get_value();s[e.attr]=t.encode(i)}const{type:i,id:n}=this,r={type:"object",name:i,id:n};return(0,l.is_empty)(s)?r:{...r,attributes:s}}constructor(t={}){super(),this.document=null,this.destroyed=new c.Signal0(this,"destroyed"),this.change=new c.Signal0(this,"change"),this.transformchange=new c.Signal0(this,"transformchange"),this.exprchange=new c.Signal0(this,"exprchange"),this.streaming=new c.Signal0(this,"streaming"),this.patching=new c.Signal(this,"patching"),this.properties={},this._watchers=new WeakMap,this._pending=!1,this._changing=!1;const e=(0,f.isPlainObject)(t)&&"id"in t;this.id=e?t.id:(0,u.unique_id)();for(const[t,{type:e,default_value:s,options:i}]of(0,l.entries)(this._props)){let n;if(e instanceof h.PropertyAlias){const s=this.properties[e.attr];if(void 0===s)throw new Error(`can't resolve ${e.attr} before ${t} to create an alias`);Object.defineProperty(this.properties,t,{get:()=>s,configurable:!1,enumerable:!1})}else n=e instanceof _.Kind?new h.PrimitiveProperty(this,t,e,s,i):new e(this,t,_.Any,s,i),this.properties[t]=n}e?(0,p.assert)(1==(0,l.keys)(t).length,"'id' cannot be used together with property initializers"):(this.initialize_props(t),this.finalize(),this.connect_signals())}initialize_props(t){const e=(0,l.dict)(t),s=new Set;for(const t of this){const i=e.get(t.attr);t.initialize(i),s.add(t.attr)}for(const[t,i]of e)s.has(t)||this.property(t).set_value(i)}finalize(){this.initialize()}initialize(){}assert_initialized(){for(const t of this)t.syncable&&!t.readonly&&t.get_value()}connect_signals(){for(const t of this){if(!(t instanceof h.VectorSpec||t instanceof h.ScalarSpec))continue;if(t.is_unset)continue;const e=t.get_value();null!=e.transform&&this.connect(e.transform.change,(()=>this.transformchange.emit())),(0,b.isExpr)(e)&&this.connect(e.expr.change,(()=>this.exprchange.emit()))}}disconnect_signals(){c.Signal.disconnect_receiver(this)}destroy(){this.disconnect_signals(),this.destroyed.emit()}clone(t){const e=(new v.Cloner).clone(this);return null!=t&&e.setv(t),e}_clear_watchers(){this._watchers=new WeakMap}changed_for(t){const e=this._watchers.get(t);return this._watchers.set(t,!1),e??!0}_setv(t,e){const s=e.check_eq,i=new Set,n=this._changing;this._changing=!0;for(const[e,n]of t)!1!==s&&!e.is_unset&&(0,y.is_equal)(e.get_value(),n)||(e.set_value(n),i.add(e));i.size>0&&(this._clear_watchers(),this._pending=!0);for(const t of i)t.change.emit();if(!n){if(!e.no_change)for(;this