PageSourceSearch

https://toootiz-mikutts.hf.space/assets/Index-BOG-LPoW.js

js toootiz-mikutts.hf.space collected 2026-10-03 17:28:37 UTC 1,152,564 bytes, 41,012 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./auto-render-DTMSUk0Z-BeunX3LV.js","./katex-BnZ5CZRo-BMBmxj1Y.js","./mermaid.core-vMMZVCDT-alxhRXoZ.js","./index-Bq2njFOY.js","./index-JtiO_h80.css","./i18n-CGlVUOvE.js","./i18n-DmEW90TJ.css","./utils.svelte-Bi9ASwv9.js","./index-DnoGeqVF.js","./dsv-BhAd467f.js","./props-o1aFOJaB.js","./misc-D8a4ZbMA.js","./index-By61_kAe.js","./Upload-xR3P-2U5.js","./snippet-BG7qkY_1.js","./actions-CgRQ2lHA.js","./Upload-B9AbOy1B.css","./ScrollFade.svelte_svelte_type_style_lang-D0JPkGar.js","./ScrollFade-DXC81vHi.css","./MarkdownCode.svelte_svelte_type_style_lang-B29zDiob.js","./prism-python-NrKIQnfs.js","./MarkdownCode-hl0Esrgh.css","./html-Bwif0JPw.js","./input-CXpCw23l.js","./event-modifiers-DanhKw3_.js","./MarkdownCode-BYKuypS7.js","./StreamingBar.svelte_svelte_type_style_lang-DWGn5tT_.js","./StreamingBar-M0OJiclA.css","./Checkbox-dsIC6373.js","./Checkbox-CJBAs2gn.css","./size-CWi277d_.js","./Check-BKMHx_DF.js","./DropdownArrow-3lFHYtTD.js","./Copy-BQlJe6-D.js","./FullscreenButton-C6RgeACK.js","./Maximize-2N5airbC.js","./Example-CSyNUPmz.js","./Example-B0qjHn8W.css"])))=>i.map(i=>d[i]);
2import { j as get, w as writable$1, p as prop, e as init$1, b as set_class, a as set_attribute, h as clsx, i as if_block, d as bind_this, f as set_style$1, s as slot, k as each, t as remove_input_defaults, F as set_value, u as index, q as store_get, m as setup_stores, r as rest_props } from './i18n-CGlVUOvE.js';
3import { ag as __vitePreload, aw as setContext$1, I as tick$1, M as push, Y as legacy_pre_effect, y as deep_read_state, Z as get$1, _ as legacy_pre_effect_reset, t as template_effect, U as event, a as append$1, O as pop, a0 as mutable_source, P as flushSync, Q as child, R as from_html, $ as set, T as reset, a1 as createEventDispatcher$1, N as first_child, S as sibling, u as effect, w as untrack, aj as remove_textarea_child, a3 as comment, ae as derived_safe_equal, a4 as text$1, X as set_text, f as from_svg, a8 as onMount$1, ar as mutate, af as onDestroy$1, aA as afterUpdate$1, av as $window, ad as user_effect } from './index-Bq2njFOY.js';
4import { G as Gradio } from './utils.svelte-Bi9ASwv9.js';
5import { d as dequal$2 } from './index-DnoGeqVF.js';
6import { d as dsvFormat$1 } from './dsv-BhAd467f.js';
7import { b as bind_prop } from './props-o1aFOJaB.js';
8import { b as bubble_event } from './misc-D8a4ZbMA.js';
9import { d as dequal$3 } from './index-By61_kAe.js';
10import { U as Upload } from './Upload-xR3P-2U5.js';
11import { c as component, I as IconButton$1 } from './ScrollFade.svelte_svelte_type_style_lang-D0JPkGar.js';
12import './MarkdownCode.svelte_svelte_type_style_lang-B29zDiob.js';
13import { h as html$1 } from './html-Bwif0JPw.js';
14import { a as action } from './actions-CgRQ2lHA.js';
15import { b as bind_value } from './input-CXpCw23l.js';
16import { s as stopPropagation, p as preventDefault } from './event-modifiers-DanhKw3_.js';
17import { M as MarkdownCode$1 } from './MarkdownCode-BYKuypS7.js';
18import './StreamingBar.svelte_svelte_type_style_lang-DWGn5tT_.js';
19import { C as Checkbox$1 } from './Checkbox-dsIC6373.js';
20import { b as bind_element_size, a as bind_resize_observer } from './size-CWi277d_.js';
21import { C as Check$1 } from './Check-BKMHx_DF.js';
22import { D as DropdownArrow$1 } from './DropdownArrow-3lFHYtTD.js';
23import { C as Copy$1 } from './Copy-BQlJe6-D.js';
24import { F as FullscreenButton$1 } from './FullscreenButton-C6RgeACK.js';
25import Example from './Example-CSyNUPmz.js';
26
27var __defProp = Object.defineProperty;
28var __typeError = (msg) => {
29  throw TypeError(msg);
30};
31var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
32var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
33var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
34var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), member.get(obj));
35var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
36var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
37var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
38var _Marked_instances, parseMarkdown_fn, onError_fn, _currentLine;
39function noop() {
40}
41const identity = (x) => x;
42function assign(tar, src) {
43  for (const k in src) tar[k] = src[k];
44  return (
45    /** @type {T & S} */
46    tar
47  );
48}
49function run(fn) {
50  return fn();
51}
52function blank_object() {
53  return /* @__PURE__ */ Object.create(null);
54}
55function run_all(fns) {
56  fns.forEach(run);
57}
58function is_function(thing) {
59  return typeof thing === "function";
60}
61function safe_not_equal(a, b) {
62  return a != a ? b == b : a !== b || a && typeof a === "object" || typeof a === "function";
63}
64let src_url_equal_anchor;
65function src_url_equal(element_src, url) {
66  if (element_src === url) return true;
67  if (!src_url_equal_anchor) {
68    src_url_equal_anchor = document.createElement("a");
69  }
70  src_url_equal_anchor.href = url;
71  return element_src === src_url_equal_anchor.href;
72}
73function is_empty(obj) {
74  return Object.keys(obj).length === 0;
75}
76function subscribe(store, ...callbacks) {
77  if (store == null) {
78    for (const callback of callbacks) {
79      callback(void 0);
80    }
81    return noop;
82  }
83  const unsub = store.subscribe(...callbacks);
84  return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
85}
86function get_store_value(store) {
87  let value;
88  subscribe(store, (_) => value = _)();
89  return value;
90}
91function component_subscribe(component, store, callback) {
92  component.$$.on_destroy.push(subscribe(store, callback));
93}
94function create_slot(definition, ctx, $$scope, fn) {
95  if (definition) {
96    const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);
97    return definition[0](slot_ctx);
98  }
99}
100function get_slot_context(definition, ctx, $$scope, fn) {
101  return definition[1] && fn ? assign($$scope.ctx.slice(), definition[1](fn(ctx))) : $$scope.ctx;
102}
103function get_slot_changes(definition, $$scope, dirty, fn) {
104  if (definition[2] && fn) {
105    const lets = definition[2](fn(dirty));
106    if ($$scope.dirty === void 0) {
107      return lets;
108    }
109    if (typeof lets === "object") {
110      const merged = [];
111      const len = Math.max($$scope.dirty.length, lets.length);
112      for (let i = 0; i < len; i += 1) {
113        merged[i] = $$scope.dirty[i] | lets[i];
114      }
115      return merged;
116    }
117    return $$scope.dirty | lets;
118  }
119  return $$scope.dirty;
120}
121function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {
122  if (slot_changes) {
123    const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
124    slot.p(slot_context, slot_changes);
125  }
126}
127function get_all_dirty_from_scope($$scope) {
128  if ($$scope.ctx.length > 32) {
129    const dirty = [];
130    const length = $$scope.ctx.length / 32;
131    for (let i = 0; i < length; i++) {
132      dirty[i] = -1;
133    }
134    return dirty;
135  }
136  return -1;
137}
138function exclude_internal_props(props) {
139  const result = {};
140  for (const k in props) if (k[0] !== "$") result[k] = props[k];
141  return result;
142}
143function compute_rest_props(props, keys) {
144  const rest = {};
145  keys = new Set(keys);
146  for (const k in props) if (!keys.has(k) && k[0] !== "$") rest[k] = props[k];
147  return rest;
148}
149function null_to_empty(value) {
150  return value == null ? "" : value;
151}
152function action_destroyer(action_result) {
153  return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;
154}
155const is_client = typeof window !== "undefined";
156let now = is_client ? () => window.performance.now() : () => Date.now();
157let raf$1 = is_client ? (cb) => requestAnimationFrame(cb) : noop;
158const tasks = /* @__PURE__ */ new Set();
159function run_tasks(now2) {
160  tasks.forEach((task) => {
161    if (!task.c(now2)) {
162      tasks.delete(task);
163      task.f();
164    }
165  });
166  if (tasks.size !== 0) raf$1(run_tasks);
167}
168function loop(callback) {
169  let task;
170  if (tasks.size === 0) raf$1(run_tasks);
171  return {
172    promise: new Promise((fulfill) => {
173      tasks.add(task = { c: callback, f: fulfill });
174    }),
175    abort() {
176      tasks.delete(task);
177    }
178  };
179}
180const globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : (
181  // @ts-ignore Node typings have this
182  global
183);
184class ResizeObserverSingleton {
185  /** @param {ResizeObserverOptions} options */
186  constructor(options) {
187    /**
188     * @private
189     * @readonly
190     * @type {WeakMap<Element, import('./private.js').Listener>}
191     */
192    __publicField(this, "_listeners", "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0);
193    /**
194     * @private
195     * @type {ResizeObserver}
196     */
197    __publicField(this, "_observer");
198    /** @type {ResizeObserverOptions} */
199    __publicField(this, "options");
200    this.options = options;
201  }
202  /**
203   * @param {Element} element
204   * @param {import('./private.js').Listener} listener
205   * @returns {() => void}
206   */
207  observe(element2, listener) {
208    this._listeners.set(element2, listener);
209    this._getObserver().observe(element2, this.options);
210    return () => {
211      this._listeners.delete(element2);
212      this._observer.unobserve(element2);
213    };
214  }
215  /**
216   * @private
217   */
218  _getObserver() {
219    return this._observer ?? (this._observer = new ResizeObserver((entries) => {
220      var _a;
221      for (const entry of entries) {
222        ResizeObserverSingleton.entries.set(entry.target, entry);
223        (_a = this._listeners.get(entry.target)) == null ? void 0 : _a(entry);
224      }
225    }));
226  }
227}
228ResizeObserverSingleton.entries = "WeakMap" in globals ? /* @__PURE__ */ new WeakMap() : void 0;
229function append(target, node) {
230  target.appendChild(node);
231}
232function get_root_for_style(node) {
233  if (!node) return document;
234  const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;
235  if (root && /** @type {ShadowRoot} */
236  root.host) {
237    return (
238      /** @type {ShadowRoot} */
239      root
240    );
241  }
242  return node.ownerDocument;
243}
244function append_empty_stylesheet(node) {
245  const style_element = element("style");
246  style_element.textContent = "/* empty */";
247  append_stylesheet(get_root_for_style(node), style_element);
248  return style_element.sheet;
249}
250function append_stylesheet(node, style) {
251  append(
252    /** @type {Document} */
253    node.head || node,
254    style
255  );
256  return style.sheet;
257}
258function insert(target, node, anchor) {
259  target.insertBefore(node, anchor || null);
260}
261function detach(node) {
262  if (node.parentNode) {
263    node.parentNode.removeChild(node);
264  }
265}
266function destroy_each(iterations, detaching) {
267  for (let i = 0; i < iterations.length; i += 1) {
268    if (iterations[i]) iterations[i].d(detaching);
269  }
270}
271function element(name) {
272  return document.createElement(name);
273}
274function svg_element(name) {
275  return document.createElementNS("http://www.w3.org/2000/svg", name);
276}
277function text(data) {
278  return document.createTextNode(data);
279}
280function space() {
281  return text(" ");
282}
283function empty() {
284  return text("");
285}
286function listen(node, event, handler, options) {
287  node.addEventListener(event, handler, options);
288  return () => node.removeEventListener(event, handler, options);
289}
290function prevent_default(fn) {
291  return function(event) {
292    event.preventDefault();
293    return fn.call(this, event);
294  };
295}
296function stop_propagation(fn) {
297  return function(event) {
298    event.stopPropagation();
299    return fn.call(this, event);
300  };
301}
302function attr(node, attribute, value) {
303  if (value == null) node.removeAttribute(attribute);
304  else if (node.getAttribute(attribute) !== value) node.setAttribute(attribute, value);
305}
306const always_set_through_set_attribute = ["width", "height"];
307function set_attributes(node, attributes) {
308  const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);
309  for (const key in attributes) {
310    if (attributes[key] == null) {
311      node.removeAttribute(key);
312    } else if (key === "style") {
313      node.style.cssText = attributes[key];
314    } else if (key === "__value") {
315      node.value = node[key] = attributes[key];
316    } else if (descriptors[key] && descriptors[key].set && always_set_through_set_attribute.indexOf(key) === -1) {
317      node[key] = attributes[key];
318    } else {
319      attr(node, key, attributes[key]);
320    }
321  }
322}
323function set_custom_element_data_map(node, data_map) {
324  Object.keys(data_map).forEach((key) => {
325    set_custom_element_data(node, key, data_map[key]);
326  });
327}
328function set_custom_element_data(node, prop, value) {
329  const lower = prop.toLowerCase();
330  if (lower in node) {
331    node[lower] = typeof node[lower] === "boolean" && value === "" ? true : value;
332  } else if (prop in node) {
333    node[prop] = typeof node[prop] === "boolean" && value === "" ? true : value;
334  } else {
335    attr(node, prop, value);
336  }
337}
338function set_dynamic_element_data(tag2) {
339  return /-/.test(tag2) ? set_custom_element_data_map : set_attributes;
340}
341function children(element2) {
342  return Array.from(element2.childNodes);
343}
344function set_data(text2, data) {
345  data = "" + data;
346  if (text2.data === data) return;
347  text2.data = /** @type {string} */
348  data;
349}
350function set_input_value(input, value) {
351  input.value = value == null ? "" : value;
352}
353function set_style(node, key, value, important) {
354  if (value == null) {
355    node.style.removeProperty(key);
356  } else {
357    node.style.setProperty(key, value, "");
358  }
359}
360let crossorigin;
361function is_crossorigin() {
362  if (crossorigin === void 0) {
363    crossorigin = false;
364    try {
365      if (typeof window !== "undefined" && window.parent) {
366        void window.parent.document;
367      }
368    } catch (error) {
369      crossorigin = true;
370    }
371  }
372  return crossorigin;
373}
374function add_iframe_resize_listener(node, fn) {
375  const computed_style = getComputedStyle(node);
376  if (computed_style.position === "static") {
377    node.style.position = "relative";
378  }
379  const iframe = element("iframe");
380  iframe.setAttribute(
381    "style",
382    "display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;"
383  );
384  iframe.setAttribute("aria-hidden", "true");
385  iframe.tabIndex = -1;
386  const crossorigin2 = is_crossorigin();
387  let unsubscribe;
388  if (crossorigin2) {
389    iframe.src = "data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}<\/script>";
390    unsubscribe = listen(
391      window,
392      "message",
393      /** @param {MessageEvent} event */
394      (event) => {
395        if (event.source === iframe.contentWindow) fn();
396      }
397    );
398  } else {
399    iframe.src = "about:blank";
400    iframe.onload = () => {
401      unsubscribe = listen(iframe.contentWindow, "resize", fn);
402      fn();
403    };
404  }
405  append(node, iframe);
406  return () => {
407    if (crossorigin2) {
408      unsubscribe();
409    } else if (unsubscribe && iframe.contentWindow) {
410      unsubscribe();
411    }
412    detach(iframe);
413  };
414}
415const resize_observer_content_box = /* @__PURE__ */ new ResizeObserverSingleton({
416  box: "content-box"
417});
418function toggle_class(element2, name, toggle) {
419  element2.classList.toggle(name, !!toggle);
420}
421function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
422  return new CustomEvent(type, { detail, bubbles, cancelable });
423}
424class HtmlTag {
425  constructor(is_svg = false) {
426    /**
427     * @private
428     * @default false
429     */
430    __publicField(this, "is_svg", false);
431    /** parent for creating node */
432    __publicField(this, "e");
433    /** html tag nodes */
434    __publicField(this, "n");
435    /** target */
436    __publicField(this, "t");
437    /** anchor */
438    __publicField(this, "a");
439    this.is_svg = is_svg;
440    this.e = this.n = null;
441  }
442  /**
443   * @param {string} html
444   * @returns {void}
445   */
446  c(html2) {
447    this.h(html2);
448  }
449  /**
450   * @param {string} html
451   * @param {HTMLElement | SVGElement} target
452   * @param {HTMLElement | SVGElement} anchor
453   * @returns {void}
454   */
455  m(html2, target, anchor = null) {
456    if (!this.e) {
457      if (this.is_svg)
458        this.e = svg_element(
459          /** @type {keyof SVGElementTagNameMap} */
460          target.nodeName
461        );
462      else
463        this.e = element(
464          /** @type {keyof HTMLElementTagNameMap} */
465          target.nodeType === 11 ? "TEMPLATE" : target.nodeName
466        );
467      this.t = target.tagName !== "TEMPLATE" ? target : (
468        /** @type {HTMLTemplateElement} */
469        target.content
470      );
471      this.c(html2);
472    }
473    this.i(anchor);
474  }
475  /**
476   * @param {string} html
477   * @returns {void}
478   */
479  h(html2) {
480    this.e.innerHTML = html2;
481    this.n = Array.from(
482      this.e.nodeName === "TEMPLATE" ? this.e.content.childNodes : this.e.childNodes
483    );
484  }
485  /**
486   * @returns {void} */
487  i(anchor) {
488    for (let i = 0; i < this.n.length; i += 1) {
489      insert(this.t, this.n[i], anchor);
490    }
491  }
492  /**
493   * @param {string} html
494   * @returns {void}
495   */
496  p(html2) {
497    this.d();
498    this.h(html2);
499    this.i(this.a);
500  }
501  /**
502   * @returns {void} */
503  d() {
504    this.n.forEach(detach);
505  }
506}
507function construct_svelte_component(component, props) {
508  return new component(props);
509}
510const managed_styles = /* @__PURE__ */ new Map();
511let active = 0;
512function hash(str) {
513  let hash2 = 5381;
514  let i = str.length;
515  while (i--) hash2 = (hash2 << 5) - hash2 ^ str.charCodeAt(i);
516  return hash2 >>> 0;
517}
518function create_style_information(doc, node) {
519  const info = { stylesheet: append_empty_stylesheet(node), rules: {} };
520  managed_styles.set(doc, info);
521  return info;
522}
523function create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {
524  const step = 16.666 / duration;
525  let keyframes = "{\n";
526  for (let p = 0; p <= 1; p += step) {
527    const t = a + (b - a) * ease(p);
528    keyframes += p * 100 + `%{${fn(t, 1 - t)}}
529`;
530  }
531  const rule = keyframes + `100% {${fn(b, 1 - b)}}
532}`;
533  const name = `__svelte_${hash(rule)}_${uid}`;
534  const doc = get_root_for_style(node);
535  const { stylesheet, rules } = managed_styles.get(doc) || create_style_information(doc, node);
536  if (!rules[name]) {
537    rules[name] = true;
538    stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);
539  }
540  const animation = node.style.animation || "";
541  node.style.animation = `${animation ? `${animation}, ` : ""}${name} ${duration}ms linear ${delay}ms 1 both`;
542  active += 1;
543  return name;
544}
545function delete_rule(node, name) {
546  const previous = (node.style.animation || "").split(", ");
547  const next = previous.filter(
548    name ? (anim) => anim.indexOf(name) < 0 : (anim) => anim.indexOf("__svelte") === -1
549    // remove all Svelte animations
550  );
551  const deleted = previous.length - next.length;
552  if (deleted) {
553    node.style.animation = next.join(", ");
554    active -= deleted;
555    if (!active) clear_rules();
556  }
557}
558function clear_rules() {
559  raf$1(() => {
560    if (active) return;
561    managed_styles.forEach((info) => {
562      const { ownerNode } = info.stylesheet;
563      if (ownerNode) detach(ownerNode);
564    });
565    managed_styles.clear();
566  });
567}
568let current_component;
569function set_current_component(component) {
570  current_component = component;
571}
572function get_current_component() {
573  if (!current_component) throw new Error("Function called outside component initialization");
574  return current_component;
575}
576function onMount(fn) {
577  get_current_component().$$.on_mount.push(fn);
578}
579function afterUpdate(fn) {
580  get_current_component().$$.after_update.push(fn);
581}
582function onDestroy(fn) {
583  get_current_component().$$.on_destroy.push(fn);
584}
585function createEventDispatcher() {
586  const component = get_current_component();
587  return (type, detail, { cancelable = false } = {}) => {
588    const callbacks = component.$$.callbacks[type];
589    if (callbacks) {
590      const event = custom_event(
591        /** @type {string} */
592        type,
593        detail,
594        { cancelable }
595      );
596      callbacks.slice().forEach((fn) => {
597        fn.call(component, event);
598      });
599      return !event.defaultPrevented;
600    }
601    return true;
602  };
603}
604function setContext(key, context) {
605  get_current_component().$$.context.set(key, context);
606  return context;
607}
608function bubble(component, event) {
609  const callbacks = component.$$.callbacks[event.type];
610  if (callbacks) {
611    callbacks.slice().forEach((fn) => fn.call(this, event));
612  }
613}
614const dirty_components = [];
615const binding_callbacks = [];
616let render_callbacks = [];
617const flush_callbacks = [];
618const resolved_promise = /* @__PURE__ */ Promise.resolve();
619let update_scheduled = false;
620function schedule_update() {
621  if (!update_scheduled) {
622    update_scheduled = true;
623    resolved_promise.then(flush);
624  }
625}
626function tick() {
627  schedule_update();
628  return resolved_promise;
629}
630function add_render_callback(fn) {
631  render_callbacks.push(fn);
632}
633function add_flush_callback(fn) {
634  flush_callbacks.push(fn);
635}
636const seen_callbacks = /* @__PURE__ */ new Set();
637let flushidx = 0;
638function flush() {
639  if (flushidx !== 0) {
640    return;
641  }
642  const saved_component = current_component;
643  do {
644    try {
645      while (flushidx < dirty_components.length) {
646        const component = dirty_components[flushidx];
647        flushidx++;
648        set_current_component(component);
649        update(component.$$);
650      }
651    } catch (e) {
652      dirty_components.length = 0;
653      flushidx = 0;
654      throw e;
655    }
656    set_current_component(null);
657    dirty_components.length = 0;
658    flushidx = 0;
659    while (binding_callbacks.length) binding_callbacks.pop()();
660    for (let i = 0; i < render_callbacks.length; i += 1) {
661      const callback = render_callbacks[i];
662      if (!seen_callbacks.has(callback)) {
663        seen_callbacks.add(callback);
664        callback();
665      }
666    }
667    render_callbacks.length = 0;
668  } while (dirty_components.length);
669  while (flush_callbacks.length) {
670    flush_callbacks.pop()();
671  }
672  update_scheduled = false;
vendor: 7,561 bytes, lines 673-957
673  seen_callbacks.clear();
674  set_current_component(saved_component);
675}
676function update($$) {
677  if ($$.fragment !== null) {
678    $$.update();
679    run_all($$.before_update);
680    const dirty = $$.dirty;
681    $$.dirty = [-1];
682    $$.fragment && $$.fragment.p($$.ctx, dirty);
683    $$.after_update.forEach(add_render_callback);
684  }
685}
686function flush_render_callbacks(fns) {
687  const filtered = [];
688  const targets = [];
689  render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c));
690  targets.forEach((c) => c());
691  render_callbacks = filtered;
692}
693let promise;
694function wait() {
695  if (!promise) {
696    promise = Promise.resolve();
697    promise.then(() => {
698      promise = null;
699    });
700  }
701  return promise;
702}
703function dispatch(node, direction, kind) {
704  node.dispatchEvent(custom_event(`${"intro"}${kind}`));
705}
706const outroing = /* @__PURE__ */ new Set();
707let outros;
708function group_outros() {
709  outros = {
710    r: 0,
711    c: [],
712    p: outros
713    // parent group
714  };
715}
716function check_outros() {
717  if (!outros.r) {
718    run_all(outros.c);
719  }
720  outros = outros.p;
721}
722function transition_in(block2, local) {
723  if (block2 && block2.i) {
724    outroing.delete(block2);
725    block2.i(local);
726  }
727}
728function transition_out(block2, local, detach2, callback) {
729  if (block2 && block2.o) {
730    if (outroing.has(block2)) return;
731    outroing.add(block2);
732    outros.c.push(() => {
733      outroing.delete(block2);
734      if (callback) {
735        if (detach2) block2.d(1);
736        callback();
737      }
738    });
739    block2.o(local);
740  } else if (callback) {
741    callback();
742  }
743}
744const null_transition = { duration: 0 };
745function create_in_transition(node, fn, params) {
746  const options = { direction: "in" };
747  let config = fn(node, params, options);
748  let running = false;
749  let animation_name;
750  let task;
751  let uid = 0;
752  function cleanup() {
753    if (animation_name) delete_rule(node, animation_name);
754  }
755  function go() {
756    const {
757      delay = 0,
758      duration = 300,
759      easing = identity,
760      tick: tick2 = noop,
761      css
762    } = config || null_transition;
763    if (css) animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++);
764    tick2(0, 1);
765    const start_time = now() + delay;
766    const end_time = start_time + duration;
767    if (task) task.abort();
768    running = true;
769    add_render_callback(() => dispatch(node, true, "start"));
770    task = loop((now2) => {
771      if (running) {
772        if (now2 >= end_time) {
773          tick2(1, 0);
774          dispatch(node, true, "end");
775          cleanup();
776          return running = false;
777        }
778        if (now2 >= start_time) {
779          const t = easing((now2 - start_time) / duration);
780          tick2(t, 1 - t);
781        }
782      }
783      return running;
784    });
785  }
786  let started = false;
787  return {
788    start() {
789      if (started) return;
790      started = true;
791      delete_rule(node);
792      if (is_function(config)) {
793        config = config(options);
794        wait().then(go);
795      } else {
796        go();
797      }
798    },
799    invalidate() {
800      started = false;
801    },
802    end() {
803      if (running) {
804        cleanup();
805        running = false;
806      }
807    }
808  };
809}
810function ensure_array_like(array_like_or_iterator) {
811  return (array_like_or_iterator == null ? void 0 : array_like_or_iterator.length) !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
812}
813function outro_and_destroy_block(block2, lookup) {
814  transition_out(block2, 1, 1, () => {
815    lookup.delete(block2.key);
816  });
817}
818function update_keyed_each(old_blocks, dirty, get_key, dynamic, ctx, list2, lookup, node, destroy, create_each_block2, next, get_context) {
819  let o = old_blocks.length;
820  let n = list2.length;
821  let i = o;
822  const old_indexes = {};
823  while (i--) old_indexes[old_blocks[i].key] = i;
824  const new_blocks = [];
825  const new_lookup = /* @__PURE__ */ new Map();
826  const deltas = /* @__PURE__ */ new Map();
827  const updates = [];
828  i = n;
829  while (i--) {
830    const child_ctx = get_context(ctx, list2, i);
831    const key = get_key(child_ctx);
832    let block2 = lookup.get(key);
833    if (!block2) {
834      block2 = create_each_block2(key, child_ctx);
835      block2.c();
836    } else {
837      updates.push(() => block2.p(child_ctx, dirty));
838    }
839    new_lookup.set(key, new_blocks[i] = block2);
840    if (key in old_indexes) deltas.set(key, Math.abs(i - old_indexes[key]));
841  }
842  const will_move = /* @__PURE__ */ new Set();
843  const did_move = /* @__PURE__ */ new Set();
844  function insert2(block2) {
845    transition_in(block2, 1);
846    block2.m(node, next);
847    lookup.set(block2.key, block2);
848    next = block2.first;
849    n--;
850  }
851  while (o && n) {
852    const new_block = new_blocks[n - 1];
853    const old_block = old_blocks[o - 1];
854    const new_key = new_block.key;
855    const old_key = old_block.key;
856    if (new_block === old_block) {
857      next = new_block.first;
858      o--;
859      n--;
860    } else if (!new_lookup.has(old_key)) {
861      destroy(old_block, lookup);
862      o--;
863    } else if (!lookup.has(new_key) || will_move.has(new_key)) {
864      insert2(new_block);
865    } else if (did_move.has(old_key)) {
866      o--;
867    } else if (deltas.get(new_key) > deltas.get(old_key)) {
868      did_move.add(new_key);
869      insert2(new_block);
870    } else {
871      will_move.add(old_key);
872      o--;
873    }
874  }
875  while (o--) {
876    const old_block = old_blocks[o];
877    if (!new_lookup.has(old_block.key)) destroy(old_block, lookup);
878  }
879  while (n) insert2(new_blocks[n - 1]);
880  run_all(updates);
881  return new_blocks;
882}
883function get_spread_update(levels, updates) {
884  const update2 = {};
885  const to_null_out = {};
886  const accounted_for = { $$scope: 1 };
887  let i = levels.length;
888  while (i--) {
889    const o = levels[i];
890    const n = updates[i];
891    if (n) {
892      for (const key in o) {
893        if (!(key in n)) to_null_out[key] = 1;
894      }
895      for (const key in n) {
896        if (!accounted_for[key]) {
897          update2[key] = n[key];
898          accounted_for[key] = 1;
899        }
900      }
901      levels[i] = n;
902    } else {
903      for (const key in o) {
904        accounted_for[key] = 1;
905      }
906    }
907  }
908  for (const key in to_null_out) {
909    if (!(key in update2)) update2[key] = void 0;
910  }
911  return update2;
912}
913function get_spread_object(spread_props) {
914  return typeof spread_props === "object" && spread_props !== null ? spread_props : {};
915}
916function bind(component, name, callback) {
917  const index = component.$$.props[name];
918  if (index !== void 0) {
919    component.$$.bound[index] = callback;
920    callback(component.$$.ctx[index]);
921  }
922}
923function create_component(block2) {
924  block2 && block2.c();
925}
926function mount_component(component, target, anchor) {
927  const { fragment, after_update } = component.$$;
928  fragment && fragment.m(target, anchor);
929  add_render_callback(() => {
930    const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
931    if (component.$$.on_destroy) {
932      component.$$.on_destroy.push(...new_on_destroy);
933    } else {
934      run_all(new_on_destroy);
935    }
936    component.$$.on_mount = [];
937  });
938  after_update.forEach(add_render_callback);
939}
940function destroy_component(component, detaching) {
941  const $$ = component.$$;
942  if ($$.fragment !== null) {
943    flush_render_callbacks($$.after_update);
944    run_all($$.on_destroy);
945    $$.fragment && $$.fragment.d(detaching);
946    $$.on_destroy = $$.fragment = null;
947    $$.ctx = [];
948  }
949}
950function make_dirty(component, i) {
951  if (component.$$.dirty[0] === -1) {
952    dirty_components.push(component);
953    schedule_update();
954    component.$$.dirty.fill(0);
955  }
956  component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
957}
vendor: 4,164 bytes, lines 958-1112
958function init(component, options, instance2, create_fragment2, not_equal, props, append_styles = null, dirty = [-1]) {
959  const parent_component = current_component;
960  set_current_component(component);
961  const $$ = component.$$ = {
962    fragment: null,
963    ctx: [],
964    // state
965    props,
966    update: noop,
967    not_equal,
968    bound: blank_object(),
969    // lifecycle
970    on_mount: [],
971    on_destroy: [],
972    on_disconnect: [],
973    before_update: [],
974    after_update: [],
975    context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
976    // everything else
977    callbacks: blank_object(),
978    dirty,
979    skip_bound: false,
980    root: options.target || parent_component.$$.root
981  };
982  append_styles && append_styles($$.root);
983  let ready = false;
984  $$.ctx = instance2 ? instance2(component, options.props || {}, (i, ret, ...rest) => {
985    const value = rest.length ? rest[0] : ret;
986    if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
987      if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value);
988      if (ready) make_dirty(component, i);
989    }
990    return ret;
991  }) : [];
992  $$.update();
993  ready = true;
994  run_all($$.before_update);
995  $$.fragment = create_fragment2 ? create_fragment2($$.ctx) : false;
996  if (options.target) {
997    if (options.hydrate) {
998      const nodes = children(options.target);
999      $$.fragment && $$.fragment.l(nodes);
1000      nodes.forEach(detach);
1001    } else {
1002      $$.fragment && $$.fragment.c();
1003    }
1004    if (options.intro) transition_in(component.$$.fragment);
1005    mount_component(component, options.target, options.anchor);
1006    flush();
1007  }
1008  set_current_component(parent_component);
1009}
1010class SvelteComponent {
1011  constructor() {
1012    /**
1013     * ### PRIVATE API
1014     *
1015     * Do not use, may change at any time
1016     *
1017     * @type {any}
1018     */
1019    __publicField(this, "$$");
1020    /**
1021     * ### PRIVATE API
1022     *
1023     * Do not use, may change at any time
1024     *
1025     * @type {any}
1026     */
1027    __publicField(this, "$$set");
1028  }
1029  /** @returns {void} */
1030  $destroy() {
1031    destroy_component(this, 1);
1032    this.$destroy = noop;
1033  }
1034  /**
1035   * @template {Extract<keyof Events, string>} K
1036   * @param {K} type
1037   * @param {((e: Events[K]) => void) | null | undefined} callback
1038   * @returns {() => void}
1039   */
1040  $on(type, callback) {
1041    if (!is_function(callback)) {
1042      return noop;
1043    }
1044    const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
1045    callbacks.push(callback);
1046    return () => {
1047      const index = callbacks.indexOf(callback);
1048      if (index !== -1) callbacks.splice(index, 1);
1049    };
1050  }
1051  /**
1052   * @param {Partial<Props>} props
1053   * @returns {void}
1054   */
1055  $set(props) {
1056    if (this.$$set && !is_empty(props)) {
1057      this.$$.skip_bound = true;
1058      this.$$set(props);
1059      this.$$.skip_bound = false;
1060    }
1061  }
1062}
1063const PUBLIC_VERSION = "4";
1064if (typeof window !== "undefined")
1065  (window.__svelte || (window.__svelte = { v: /* @__PURE__ */ new Set() })).v.add(PUBLIC_VERSION);
1066function create_if_block_1$f(ctx) {
1067  let svg;
1068  let line0;
1069  let line1;
1070  let mounted;
1071  let dispose;
1072  return {
1073    c() {
1074      svg = svg_element("svg");
1075      line0 = svg_element("line");
1076      line1 = svg_element("line");
1077      attr(line0, "x1", "1");
1078      attr(line0, "y1", "9");
1079      attr(line0, "x2", "9");
1080      attr(line0, "y2", "1");
1081      attr(line0, "stroke", "gray");
1082      attr(line0, "stroke-width", "0.5");
1083      attr(line1, "x1", "5");
1084      attr(line1, "y1", "9");
1085      attr(line1, "x2", "9");
1086      attr(line1, "y2", "5");
1087      attr(line1, "stroke", "gray");
1088      attr(line1, "stroke-width", "0.5");
1089      attr(svg, "class", "resize-handle svelte-239wnu");
1090      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
1091      attr(svg, "viewBox", "0 0 10 10");
1092    },
1093    m(target, anchor) {
1094      insert(target, svg, anchor);
1095      append(svg, line0);
1096      append(svg, line1);
1097      if (!mounted) {
1098        dispose = listen(
1099          svg,
1100          "mousedown",
1101          /*resize*/
1102          ctx[27]
1103        );
1104        mounted = true;
1105      }
1106    },
1107    p: noop,
1108    d(detaching) {
1109      if (detaching) {
1110        detach(svg);
1111      }
1112      mounted = false;
1113      dispose();
1114    }
1115  };
1116}
1117function create_dynamic_element(ctx) {
1118  var _a;
1119  let svelte_element;
1120  let t;
1121  let svelte_element_class_value;
1122  let svelte_element_dir_value;
1123  let current;
1124  const default_slot_template = (
1125    /*#slots*/
1126    ctx[31].default
1127  );
1128  const default_slot = create_slot(
1129    default_slot_template,
1130    ctx,
1131    /*$$scope*/
1132    ctx[30],
1133    null
1134  );
1135  let if_block = (
1136    /*resizable*/
1137    ctx[19] && create_if_block_1$f(ctx)
1138  );
1139  let svelte_element_levels = [
1140    { "data-testid": (
1141      /*test_id*/
1142      ctx[11]
1143    ) },
1144    { id: (
1145      /*elem_id*/
1146      ctx[6]
1147    ) },
1148    {
1149      class: svelte_element_class_value = "block " + /*elem_classes*/
1150      (((_a = ctx[7]) == null ? void 0 : _a.join(" ")) || "") + " svelte-239wnu"
1151    },
1152    {
1153      dir: svelte_element_dir_value = /*rtl*/
1154      ctx[20] ? "rtl" : "ltr"
1155    }
1156  ];
1157  let svelte_element_data = {};
1158  for (let i = 0; i < svelte_element_levels.length; i += 1) {
1159    svelte_element_data = assign(svelte_element_data, svelte_element_levels[i]);
1160  }
1161  return {
1162    c() {
1163      svelte_element = element(
1164        /*tag*/
1165        ctx[25]
1166      );
1167      if (default_slot) default_slot.c();
1168      t = space();
1169      if (if_block) if_block.c();
1170      set_dynamic_element_data(
1171        /*tag*/
1172        ctx[25]
1173      )(svelte_element, svelte_element_data);
1174      toggle_class(
1175        svelte_element,
1176        "hidden",
1177        /*visible*/
1178        ctx[14] === false || /*visible*/
1179        ctx[14] === "hidden"
1180      );
1181      toggle_class(
1182        svelte_element,
1183        "padded",
1184        /*padding*/
1185        ctx[10]
1186      );
1187      toggle_class(
1188        svelte_element,
1189        "flex",
1190        /*flex*/
1191        ctx[1]
1192      );
1193      toggle_class(
1194        svelte_element,
1195        "border_focus",
1196        /*border_mode*/
1197        ctx[9] === "focus"
1198      );
1199      toggle_class(
1200        svelte_element,
1201        "border_contrast",
1202        /*border_mode*/
1203        ctx[9] === "contrast"
1204      );
1205      toggle_class(svelte_element, "hide-container", !/*explicit_call*/
1206      ctx[12] && !/*container*/
1207      ctx[13]);
1208      toggle_class(
1209        svelte_element,
1210        "fullscreen",
1211        /*fullscreen*/
1212        ctx[0]
1213      );
1214      toggle_class(
1215        svelte_element,
1216        "animating",
1217        /*fullscreen*/
1218        ctx[0] && /*preexpansionBoundingRect*/
1219        ctx[24] !== null
1220      );
1221      toggle_class(
1222        svelte_element,
1223        "auto-margin",
1224        /*scale*/
1225        ctx[17] === null
1226      );
1227      set_style(
1228        svelte_element,
1229        "height",
1230        /*fullscreen*/
1231        ctx[0] ? void 0 : (
1232          /*get_dimension*/
1233          ctx[26](
1234            /*height*/
1235            ctx[2]
1236          )
1237        )
1238      );
1239      set_style(
1240        svelte_element,
1241        "min-height",
1242        /*fullscreen*/
1243        ctx[0] ? void 0 : (
1244          /*get_dimension*/
1245          ctx[26](
1246            /*min_height*/
1247            ctx[3]
1248          )
1249        )
1250      );
1251      set_style(
1252        svelte_element,
1253        "max-height",
1254        /*fullscreen*/
1255        ctx[0] ? void 0 : (
1256          /*get_dimension*/
1257          ctx[26](
1258            /*max_height*/
1259            ctx[4]
1260          )
1261        )
1262      );
1263      set_style(
1264        svelte_element,
1265        "--start-top",
1266        /*preexpansionBoundingRect*/
1267        ctx[24] ? `${/*preexpansionBoundingRect*/
1268        ctx[24].top}px` : "0px"
1269      );
1270      set_style(
1271        svelte_element,
1272        "--start-left",
1273        /*preexpansionBoundingRect*/
1274        ctx[24] ? `${/*preexpansionBoundingRect*/
1275        ctx[24].left}px` : "0px"
1276      );
1277      set_style(
1278        svelte_element,
1279        "--start-width",
1280        /*preexpansionBoundingRect*/
1281        ctx[24] ? `${/*preexpansionBoundingRect*/
1282        ctx[24].width}px` : "0px"
1283      );
1284      set_style(
1285        svelte_element,
1286        "--start-height",
1287        /*preexpansionBoundingRect*/
1288        ctx[24] ? `${/*preexpansionBoundingRect*/
1289        ctx[24].height}px` : "0px"
1290      );
1291      set_style(
1292        svelte_element,
1293        "width",
1294        /*fullscreen*/
1295        ctx[0] ? void 0 : typeof /*width*/
1296        ctx[5] === "number" ? `calc(min(${/*width*/
1297        ctx[5]}px, 100%))` : (
1298          /*get_dimension*/
1299          ctx[26](
1300            /*width*/
1301            ctx[5]
1302          )
1303        )
1304      );
1305      set_style(
1306        svelte_element,
1307        "border-style",
1308        /*variant*/
1309        ctx[8]
1310      );
1311      set_style(
1312        svelte_element,
1313        "overflow",
1314        /*allow_overflow*/
1315        ctx[15] ? (
1316          /*overflow_behavior*/
1317          ctx[16]
1318        ) : "hidden"
1319      );
1320      set_style(
1321        svelte_element,
1322        "flex-grow",
1323        /*scale*/
1324        ctx[17]
1325      );
1326      set_style(svelte_element, "min-width", `calc(min(${/*min_width*/
1327      ctx[18]}px, 100%))`);
1328      set_style(svelte_element, "border-width", `var(--block-border-width)`);
1329    },
1330    m(target, anchor) {
1331      insert(target, svelte_element, anchor);
1332      if (default_slot) {
1333        default_slot.m(svelte_element, null);
1334      }
1335      append(svelte_element, t);
1336      if (if_block) if_block.m(svelte_element, null);
1337      ctx[32](svelte_element);
1338      current = true;
1339    },
1340    p(ctx2, dirty) {
1341      var _a2;
1342      if (default_slot) {
1343        if (default_slot.p && (!current || dirty[0] & /*$$scope*/
1344        1073741824)) {
1345          update_slot_base(
1346            default_slot,
1347            default_slot_template,
1348            ctx2,
1349            /*$$scope*/
1350            ctx2[30],
1351            !current ? get_all_dirty_from_scope(
1352              /*$$scope*/
1353              ctx2[30]
1354            ) : get_slot_changes(
1355              default_slot_template,
1356              /*$$scope*/
1357              ctx2[30],
1358              dirty,
1359              null
1360            ),
1361            null
1362          );
1363        }
1364      }
1365      if (
1366        /*resizable*/
1367        ctx2[19]
1368      ) {
1369        if (if_block) {
1370          if_block.p(ctx2, dirty);
1371        } else {
1372          if_block = create_if_block_1$f(ctx2);
1373          if_block.c();
1374          if_block.m(svelte_element, null);
1375        }
1376      } else if (if_block) {
1377        if_block.d(1);
1378        if_block = null;
1379      }
1380      set_dynamic_element_data(
1381        /*tag*/
1382        ctx2[25]
1383      )(svelte_element, svelte_element_data = get_spread_update(svelte_element_levels, [
1384        (!current || dirty[0] & /*test_id*/
1385        2048) && { "data-testid": (
1386          /*test_id*/
1387          ctx2[11]
1388        ) },
1389        (!current || dirty[0] & /*elem_id*/
1390        64) && { id: (
1391          /*elem_id*/
1392          ctx2[6]
1393        ) },
1394        (!current || dirty[0] & /*elem_classes*/
1395        128 && svelte_element_class_value !== (svelte_element_class_value = "block " + /*elem_classes*/
1396        (((_a2 = ctx2[7]) == null ? void 0 : _a2.join(" ")) || "") + " svelte-239wnu")) && { class: svelte_element_class_value },
1397        (!current || dirty[0] & /*rtl*/
1398        1048576 && svelte_element_dir_value !== (svelte_element_dir_value = /*rtl*/
1399        ctx2[20] ? "rtl" : "ltr")) && { dir: svelte_element_dir_value }
1400      ]));
1401      toggle_class(
1402        svelte_element,
1403        "hidden",
1404        /*visible*/
1405        ctx2[14] === false || /*visible*/
1406        ctx2[14] === "hidden"
1407      );
1408      toggle_class(
1409        svelte_element,
1410        "padded",
1411        /*padding*/
1412        ctx2[10]
1413      );
1414      toggle_class(
1415        svelte_element,
1416        "flex",
1417        /*flex*/
1418        ctx2[1]
1419      );
1420      toggle_class(
1421        svelte_element,
1422        "border_focus",
1423        /*border_mode*/
1424        ctx2[9] === "focus"
1425      );
1426      toggle_class(
1427        svelte_element,
1428        "border_contrast",
1429        /*border_mode*/
1430        ctx2[9] === "contrast"
1431      );
1432      toggle_class(svelte_element, "hide-container", !/*explicit_call*/
1433      ctx2[12] && !/*container*/
1434      ctx2[13]);
1435      toggle_class(
1436        svelte_element,
1437        "fullscreen",
1438        /*fullscreen*/
1439        ctx2[0]
1440      );
1441      toggle_class(
1442        svelte_element,
1443        "animating",
1444        /*fullscreen*/
1445        ctx2[0] && /*preexpansionBoundingRect*/
1446        ctx2[24] !== null
1447      );
1448      toggle_class(
1449        svelte_element,
1450        "auto-margin",
1451        /*scale*/
1452        ctx2[17] === null
1453      );
1454      if (dirty[0] & /*fullscreen, height*/
1455      5) {
1456        set_style(
1457          svelte_element,
1458          "height",
1459          /*fullscreen*/
1460          ctx2[0] ? void 0 : (
1461            /*get_dimension*/
1462            ctx2[26](
1463              /*height*/
1464              ctx2[2]
1465            )
1466          )
1467        );
1468      }
1469      if (dirty[0] & /*fullscreen, min_height*/
1470      9) {
1471        set_style(
1472          svelte_element,
1473          "min-height",
1474          /*fullscreen*/
1475          ctx2[0] ? void 0 : (
1476            /*get_dimension*/
1477            ctx2[26](
1478              /*min_height*/
1479              ctx2[3]
1480            )
1481          )
1482        );
1483      }
1484      if (dirty[0] & /*fullscreen, max_height*/
1485      17) {
1486        set_style(
1487          svelte_element,
1488          "max-height",
1489          /*fullscreen*/
1490          ctx2[0] ? void 0 : (
1491            /*get_dimension*/
1492            ctx2[26](
1493              /*max_height*/
1494              ctx2[4]
1495            )
1496          )
1497        );
1498      }
1499      if (dirty[0] & /*preexpansionBoundingRect*/
1500      16777216) {
1501        set_style(
1502          svelte_element,
1503          "--start-top",
1504          /*preexpansionBoundingRect*/
1505          ctx2[24] ? `${/*preexpansionBoundingRect*/
1506          ctx2[24].top}px` : "0px"
1507        );
1508      }
1509      if (dirty[0] & /*preexpansionBoundingRect*/
1510      16777216) {
1511        set_style(
1512          svelte_element,
1513          "--start-left",
1514          /*preexpansionBoundingRect*/
1515          ctx2[24] ? `${/*preexpansionBoundingRect*/
1516          ctx2[24].left}px` : "0px"
1517        );
1518      }
1519      if (dirty[0] & /*preexpansionBoundingRect*/
1520      16777216) {
1521        set_style(
1522          svelte_element,
1523          "--start-width",
1524          /*preexpansionBoundingRect*/
1525          ctx2[24] ? `${/*preexpansionBoundingRect*/
1526          ctx2[24].width}px` : "0px"
1527        );
1528      }
1529      if (dirty[0] & /*preexpansionBoundingRect*/
1530      16777216) {
1531        set_style(
1532          svelte_element,
1533          "--start-height",
1534          /*preexpansionBoundingRect*/
1535          ctx2[24] ? `${/*preexpansionBoundingRect*/
1536          ctx2[24].height}px` : "0px"
1537        );
1538      }
1539      if (dirty[0] & /*fullscreen, width*/
1540      33) {
1541        set_style(
1542          svelte_element,
1543          "width",
1544          /*fullscreen*/
1545          ctx2[0] ? void 0 : typeof /*width*/
1546          ctx2[5] === "number" ? `calc(min(${/*width*/
1547          ctx2[5]}px, 100%))` : (
1548            /*get_dimension*/
1549            ctx2[26](
1550              /*width*/
1551              ctx2[5]
1552            )
1553          )
1554        );
1555      }
1556      if (dirty[0] & /*variant*/
1557      256) {
1558        set_style(
1559          svelte_element,
1560          "border-style",
1561          /*variant*/
1562          ctx2[8]
1563        );
1564      }
1565      if (dirty[0] & /*allow_overflow, overflow_behavior*/
1566      98304) {
1567        set_style(
1568          svelte_element,
1569          "overflow",
1570          /*allow_overflow*/
1571          ctx2[15] ? (
1572            /*overflow_behavior*/
1573            ctx2[16]
1574          ) : "hidden"
1575        );
1576      }
1577      if (dirty[0] & /*scale*/
1578      131072) {
1579        set_style(
1580          svelte_element,
1581          "flex-grow",
1582          /*scale*/
1583          ctx2[17]
1584        );
1585      }
1586      if (dirty[0] & /*min_width*/
1587      262144) {
1588        set_style(svelte_element, "min-width", `calc(min(${/*min_width*/
1589        ctx2[18]}px, 100%))`);
1590      }
1591    },
1592    i(local) {
1593      if (current) return;
1594      transition_in(default_slot, local);
1595      current = true;
1596    },
1597    o(local) {
1598      transition_out(default_slot, local);
1599      current = false;
1600    },
1601    d(detaching) {
1602      if (detaching) {
1603        detach(svelte_element);
1604      }
1605      if (default_slot) default_slot.d(detaching);
1606      if (if_block) if_block.d();
1607      ctx[32](null);
1608    }
1609  };
1610}
1611function create_if_block$m(ctx) {
1612  let div;
1613  return {
1614    c() {
1615      div = element("div");
1616      attr(div, "class", "placeholder svelte-239wnu");
1617      set_style(
1618        div,
1619        "height",
1620        /*placeholder_height*/
1621        ctx[22] + "px"
1622      );
1623      set_style(
1624        div,
1625        "width",
1626        /*placeholder_width*/
1627        ctx[23] + "px"
1628      );
1629    },
1630    m(target, anchor) {
1631      insert(target, div, anchor);
1632    },
1633    p(ctx2, dirty) {
1634      if (dirty[0] & /*placeholder_height*/
1635      4194304) {
1636        set_style(
1637          div,
1638          "height",
1639          /*placeholder_height*/
1640          ctx2[22] + "px"
1641        );
1642      }
1643      if (dirty[0] & /*placeholder_width*/
1644      8388608) {
1645        set_style(
1646          div,
1647          "width",
1648          /*placeholder_width*/
1649          ctx2[23] + "px"
1650        );
1651      }
1652    },
1653    d(detaching) {
1654      if (detaching) {
1655        detach(div);
1656      }
1657    }
1658  };
1659}
1660function create_fragment$W(ctx) {
1661  let t;
1662  let if_block_anchor;
1663  let current;
1664  let svelte_element = (
1665    /*tag*/
1666    ctx[25] && create_dynamic_element(ctx)
1667  );
1668  let if_block = (
1669    /*fullscreen*/
1670    ctx[0] && create_if_block$m(ctx)
1671  );
1672  return {
1673    c() {
1674      if (svelte_element) svelte_element.c();
1675      t = space();
1676      if (if_block) if_block.c();
1677      if_block_anchor = empty();
1678    },
1679    m(target, anchor) {
1680      if (svelte_element) svelte_element.m(target, anchor);
1681      insert(target, t, anchor);
1682      if (if_block) if_block.m(target, anchor);
1683      insert(target, if_block_anchor, anchor);
1684      current = true;
1685    },
1686    p(ctx2, dirty) {
1687      if (
1688        /*tag*/
1689        ctx2[25]
1690      ) {
1691        svelte_element.p(ctx2, dirty);
1692      }
1693      if (
1694        /*fullscreen*/
1695        ctx2[0]
1696      ) {
1697        if (if_block) {
1698          if_block.p(ctx2, dirty);
1699        } else {
1700          if_block = create_if_block$m(ctx2);
1701          if_block.c();
1702          if_block.m(if_block_anchor.parentNode, if_block_anchor);
1703        }
1704      } else if (if_block) {
1705        if_block.d(1);
1706        if_block = null;
1707      }
1708    },
1709    i(local) {
1710      if (current) return;
1711      transition_in(svelte_element, local);
1712      current = true;
1713    },
1714    o(local) {
1715      transition_out(svelte_element, local);
1716      current = false;
1717    },
1718    d(detaching) {
1719      if (detaching) {
1720        detach(t);
1721        detach(if_block_anchor);
1722      }
1723      if (svelte_element) svelte_element.d(detaching);
1724      if (if_block) if_block.d(detaching);
1725    }
1726  };
1727}
1728function instance$F($$self, $$props, $$invalidate) {
1729  let { $$slots: slots = {}, $$scope } = $$props;
1730  let { height: height2 = void 0 } = $$props;
1731  let { min_height = void 0 } = $$props;
1732  let { max_height = void 0 } = $$props;
1733  let { width = void 0 } = $$props;
1734  let { elem_id = "" } = $$props;
1735  let { elem_classes = [] } = $$props;
1736  let { variant = "solid" } = $$props;
1737  let { border_mode = "base" } = $$props;
1738  let { padding = true } = $$props;
1739  let { type = "normal" } = $$props;
1740  let { test_id = void 0 } = $$props;
1741  let { explicit_call = false } = $$props;
1742  let { container = true } = $$props;
1743  let { visible = true } = $$props;
1744  let { allow_overflow = true } = $$props;
1745  let { overflow_behavior = "auto" } = $$props;
1746  let { scale = null } = $$props;
1747  let { min_width = 0 } = $$props;
1748  let { flex = false } = $$props;
1749  let { resizable = false } = $$props;
1750  let { rtl = false } = $$props;
1751  let { fullscreen = false } = $$props;
1752  let old_fullscreen = fullscreen;
1753  let element2;
1754  let tag2 = type === "fieldset" ? "fieldset" : "div";
1755  let placeholder_height = 0;
1756  let placeholder_width = 0;
1757  let preexpansionBoundingRect = null;
1758  function handleKeydown(event) {
1759    if (fullscreen && event.key === "Escape") {
1760      $$invalidate(0, fullscreen = false);
1761    }
1762  }
1763  const get_dimension = (dimension_value) => {
1764    if (dimension_value === void 0) {
1765      return void 0;
1766    }
1767    if (typeof dimension_value === "number") {
1768      return dimension_value + "px";
1769    } else if (typeof dimension_value === "string") {
1770      return dimension_value;
1771    }
1772  };
1773  const resize = (e) => {
1774    let prevY = e.clientY;
1775    const onMouseMove = (e2) => {
1776      const dy = e2.clientY - prevY;
1777      prevY = e2.clientY;
1778      $$invalidate(21, element2.style.height = `${element2.offsetHeight + dy}px`, element2);
1779    };
1780    const onMouseUp = () => {
1781      window.removeEventListener("mousemove", onMouseMove);
1782      window.removeEventListener("mouseup", onMouseUp);
1783    };
1784    window.addEventListener("mousemove", onMouseMove);
1785    window.addEventListener("mouseup", onMouseUp);
1786  };
1787  function svelte_element_binding($$value) {
1788    binding_callbacks[$$value ? "unshift" : "push"](() => {
1789      element2 = $$value;
1790      $$invalidate(21, element2);
1791    });
1792  }
1793  $$self.$$set = ($$props2) => {
1794    if ("height" in $$props2) $$invalidate(2, height2 = $$props2.height);
1795    if ("min_height" in $$props2) $$invalidate(3, min_height = $$props2.min_height);
1796    if ("max_height" in $$props2) $$invalidate(4, max_height = $$props2.max_height);
1797    if ("width" in $$props2) $$invalidate(5, width = $$props2.width);
1798    if ("elem_id" in $$props2) $$invalidate(6, elem_id = $$props2.elem_id);
1799    if ("elem_classes" in $$props2) $$invalidate(7, elem_classes = $$props2.elem_classes);
1800    if ("variant" in $$props2) $$invalidate(8, variant = $$props2.variant);
1801    if ("border_mode" in $$props2) $$invalidate(9, border_mode = $$props2.border_mode);
1802    if ("padding" in $$props2) $$invalidate(10, padding = $$props2.padding);
1803    if ("type" in $$props2) $$invalidate(28, type = $$props2.type);
1804    if ("test_id" in $$props2) $$invalidate(11, test_id = $$props2.test_id);
1805    if ("explicit_call" in $$props2) $$invalidate(12, explicit_call = $$props2.explicit_call);
1806    if ("container" in $$props2) $$invalidate(13, container = $$props2.container);
1807    if ("visible" in $$props2) $$invalidate(14, visible = $$props2.visible);
1808    if ("allow_overflow" in $$props2) $$invalidate(15, allow_overflow = $$props2.allow_overflow);
1809    if ("overflow_behavior" in $$props2) $$invalidate(16, overflow_behavior = $$props2.overflow_behavior);
1810    if ("scale" in $$props2) $$invalidate(17, scale = $$props2.scale);
1811    if ("min_width" in $$props2) $$invalidate(18, min_width = $$props2.min_width);
1812    if ("flex" in $$props2) $$invalidate(1, flex = $$props2.flex);
1813    if ("resizable" in $$props2) $$invalidate(19, resizable = $$props2.resizable);
1814    if ("rtl" in $$props2) $$invalidate(20, rtl = $$props2.rtl);
1815    if ("fullscreen" in $$props2) $$invalidate(0, fullscreen = $$props2.fullscreen);
1816    if ("$$scope" in $$props2) $$invalidate(30, $$scope = $$props2.$$scope);
1817  };
1818  $$self.$$.update = () => {
1819    if ($$self.$$.dirty[0] & /*fullscreen, old_fullscreen, element*/
1820    538968065) {
1821      if (fullscreen !== old_fullscreen) {
1822        $$invalidate(29, old_fullscreen = fullscreen);
1823        if (fullscreen) {
1824          $$invalidate(24, preexpansionBoundingRect = element2.getBoundingClientRect());
1825          $$invalidate(22, placeholder_height = element2.offsetHeight);
1826          $$invalidate(23, placeholder_width = element2.offsetWidth);
1827          window.addEventListener("keydown", handleKeydown);
1828        } else {
1829          $$invalidate(24, preexpansionBoundingRect = null);
1830          window.removeEventListener("keydown", handleKeydown);
1831        }
1832      }
1833    }
1834    if ($$self.$$.dirty[0] & /*visible*/
1835    16384) {
1836      if (!visible) {
1837        $$invalidate(1, flex = false);
1838      }
1839    }
1840  };
1841  return [
1842    fullscreen,
1843    flex,
1844    height2,
1845    min_height,
1846    max_height,
1847    width,
1848    elem_id,
1849    elem_classes,
1850    variant,
1851    border_mode,
1852    padding,
1853    test_id,
1854    explicit_call,
1855    container,
1856    visible,
1857    allow_overflow,
1858    overflow_behavior,
1859    scale,
1860    min_width,
1861    resizable,
1862    rtl,
1863    element2,
1864    placeholder_height,
1865    placeholder_width,
1866    preexpansionBoundingRect,
1867    tag2,
1868    get_dimension,
1869    resize,
1870    type,
1871    old_fullscreen,
1872    $$scope,
1873    slots,
1874    svelte_element_binding
1875  ];
1876}
1877class Block extends SvelteComponent {
1878  constructor(options) {
1879    super();
1880    init(
1881      this,
1882      options,
1883      instance$F,
1884      create_fragment$W,
1885      safe_not_equal,
1886      {
1887        height: 2,
1888        min_height: 3,
1889        max_height: 4,
1890        width: 5,
1891        elem_id: 6,
1892        elem_classes: 7,
1893        variant: 8,
1894        border_mode: 9,
1895        padding: 10,
1896        type: 28,
1897        test_id: 11,
1898        explicit_call: 12,
1899        container: 13,
1900        visible: 14,
1901        allow_overflow: 15,
1902        overflow_behavior: 16,
1903        scale: 17,
1904        min_width: 18,
1905        flex: 1,
1906        resizable: 19,
1907        rtl: 20,
1908        fullscreen: 0
1909      },
1910      null,
1911      [-1, -1]
1912    );
1913  }
1914}
1915function _getDefaults() {
1916  return {
1917    async: false,
1918    breaks: false,
1919    extensions: null,
1920    gfm: true,
1921    hooks: null,
1922    pedantic: false,
1923    renderer: null,
1924    silent: false,
1925    tokenizer: null,
1926    walkTokens: null
1927  };
1928}
1929let _defaults = _getDefaults();
1930function changeDefaults(newDefaults) {
1931  _defaults = newDefaults;
1932}
1933const escapeTest$1 = /[&<>"']/;
1934const escapeReplace$1 = new RegExp(escapeTest$1.source, "g");
1935const escapeTestNoEncode$1 = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
1936const escapeReplaceNoEncode$1 = new RegExp(escapeTestNoEncode$1.source, "g");
1937const escapeReplacements$1 = {
1938  "&": "&amp;",
1939  "<": "&lt;",
1940  ">": "&gt;",
1941  '"': "&quot;",
1942  "'": "&#39;"
1943};
1944const getEscapeReplacement$1 = (ch) => escapeReplacements$1[ch];
1945function escape$1$1(html2, encode) {
1946  if (encode) {
1947    if (escapeTest$1.test(html2)) {
1948      return html2.replace(escapeReplace$1, getEscapeReplacement$1);
1949    }
1950  } else {
1951    if (escapeTestNoEncode$1.test(html2)) {
1952      return html2.replace(escapeReplaceNoEncode$1, getEscapeReplacement$1);
1953    }
1954  }
1955  return html2;
1956}
1957const unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
1958function unescape(html2) {
1959  return html2.replace(unescapeTest, (_, n) => {
1960    n = n.toLowerCase();
1961    if (n === "colon")
1962      return ":";
1963    if (n.charAt(0) === "#") {
1964      return n.charAt(1) === "x" ? String.fromCharCode(parseInt(n.substring(2), 16)) : String.fromCharCode(+n.substring(1));
1965    }
1966    return "";
1967  });
1968}
1969const caret = /(^|[^\[])\^/g;
1970function edit(regex2, opt) {
1971  let source = typeof regex2 === "string" ? regex2 : regex2.source;
1972  opt = opt || "";
1973  const obj = {
1974    replace: (name, val) => {
1975      let valSource = typeof val === "string" ? val : val.source;
1976      valSource = valSource.replace(caret, "$1");
1977      source = source.replace(name, valSource);
1978      return obj;
1979    },
1980    getRegex: () => {
1981      return new RegExp(source, opt);
1982    }
1983  };
1984  return obj;
1985}
1986function cleanUrl(href) {
1987  try {
1988    href = encodeURI(href).replace(/%25/g, "%");
1989  } catch (e) {
1990    return null;
1991  }
1992  return href;
1993}
1994const noopTest = { exec: () => null };
1995function splitCells(tableRow, count) {
1996  const row = tableRow.replace(/\|/g, (match, offset, str) => {
1997    let escaped = false;
1998    let curr = offset;
1999    while (--curr >= 0 && str[curr] === "\\")
2000      escaped = !escaped;
2001    if (escaped) {
2002      return "|";
2003    } else {
2004      return " |";
2005    }
2006  }), cells = row.split(/ \|/);
2007  let i = 0;
2008  if (!cells[0].trim()) {
2009    cells.shift();
2010  }
2011  if (cells.length > 0 && !cells[cells.length - 1].trim()) {
2012    cells.pop();
2013  }
2014  if (count) {
2015    if (cells.length > count) {
2016      cells.splice(count);
2017    } else {
2018      while (cells.length < count)
2019        cells.push("");
2020    }
2021  }
2022  for (; i < cells.length; i++) {
2023    cells[i] = cells[i].trim().replace(/\\\|/g, "|");
2024  }
2025  return cells;
2026}
2027function rtrim(str, c, invert) {
2028  const l = str.length;
2029  if (l === 0) {
2030    return "";
2031  }
2032  let suffLen = 0;
2033  while (suffLen < l) {
2034    const currChar = str.charAt(l - suffLen - 1);
2035    if (currChar === c && true) {
2036      suffLen++;
2037    } else {
2038      break;
2039    }
2040  }
2041  return str.slice(0, l - suffLen);
2042}
2043function findClosingBracket(str, b) {
2044  if (str.indexOf(b[1]) === -1) {
2045    return -1;
2046  }
2047  let level = 0;
2048  for (let i = 0; i < str.length; i++) {
2049    if (str[i] === "\\") {
2050      i++;
2051    } else if (str[i] === b[0]) {
2052      level++;
2053    } else if (str[i] === b[1]) {
2054      level--;
2055      if (level < 0) {
2056        return i;
2057      }
2058    }
2059  }
2060  return -1;
2061}
2062function outputLink(cap, link2, raw, lexer) {
2063  const href = link2.href;
2064  const title = link2.title ? escape$1$1(link2.title) : null;
2065  const text2 = cap[1].replace(/\\([\[\]])/g, "$1");
2066  if (cap[0].charAt(0) !== "!") {
2067    lexer.state.inLink = true;
2068    const token = {
2069      type: "link",
2070      raw,
2071      href,
2072      title,
2073      text: text2,
2074      tokens: lexer.inlineTokens(text2)
2075    };
2076    lexer.state.inLink = false;
2077    return token;
2078  }
2079  return {
2080    type: "image",
2081    raw,
2082    href,
2083    title,
2084    text: escape$1$1(text2)
2085  };
2086}
2087function indentCodeCompensation(raw, text2) {
2088  const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
2089  if (matchIndentToCode === null) {
2090    return text2;
2091  }
2092  const indentToCode = matchIndentToCode[1];
2093  return text2.split("\n").map((node) => {
2094    const matchIndentInNode = node.match(/^\s+/);
2095    if (matchIndentInNode === null) {
2096      return node;
2097    }
2098    const [indentInNode] = matchIndentInNode;
2099    if (indentInNode.length >= indentToCode.length) {
2100      return node.slice(indentToCode.length);
2101    }
2102    return node;
2103  }).join("\n");
2104}
2105class _Tokenizer {
2106  // set by the lexer
2107  constructor(options) {
2108    __publicField(this, "options");
2109    __publicField(this, "rules");
2110    // set by the lexer
2111    __publicField(this, "lexer");
2112    this.options = options || _defaults;
2113  }
2114  space(src) {
2115    const cap = this.rules.block.newline.exec(src);
2116    if (cap && cap[0].length > 0) {
2117      return {
2118        type: "space",
2119        raw: cap[0]
2120      };
2121    }
2122  }
2123  code(src) {
2124    const cap = this.rules.block.code.exec(src);
2125    if (cap) {
2126      const text2 = cap[0].replace(/^ {1,4}/gm, "");
2127      return {
2128        type: "code",
2129        raw: cap[0],
2130        codeBlockStyle: "indented",
2131        text: !this.options.pedantic ? rtrim(text2, "\n") : text2
2132      };
2133    }
2134  }
2135  fences(src) {
2136    const cap = this.rules.block.fences.exec(src);
2137    if (cap) {
2138      const raw = cap[0];
2139      const text2 = indentCodeCompensation(raw, cap[3] || "");
2140      return {
2141        type: "code",
2142        raw,
2143        lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
2144        text: text2
2145      };
2146    }
2147  }
2148  heading(src) {
2149    const cap = this.rules.block.heading.exec(src);
2150    if (cap) {
2151      let text2 = cap[2].trim();
2152      if (/#$/.test(text2)) {
2153        const trimmed = rtrim(text2, "#");
2154        if (this.options.pedantic) {
2155          text2 = trimmed.trim();
2156        } else if (!trimmed || / $/.test(trimmed)) {
2157          text2 = trimmed.trim();
2158        }
2159      }
2160      return {
2161        type: "heading",
2162        raw: cap[0],
2163        depth: cap[1].length,
2164        text: text2,
2165        tokens: this.lexer.inline(text2)
2166      };
2167    }
2168  }
2169  hr(src) {
2170    const cap = this.rules.block.hr.exec(src);
2171    if (cap) {
2172      return {
2173        type: "hr",
2174        raw: cap[0]
2175      };
2176    }
2177  }
2178  blockquote(src) {
2179    const cap = this.rules.block.blockquote.exec(src);
2180    if (cap) {
2181      let text2 = cap[0].replace(/\n {0,3}((?:=+|-+) *)(?=\n|$)/g, "\n    $1");
2182      text2 = rtrim(text2.replace(/^ *>[ \t]?/gm, ""), "\n");
2183      const top = this.lexer.state.top;
2184      this.lexer.state.top = true;
2185      const tokens = this.lexer.blockTokens(text2);
2186      this.lexer.state.top = top;
2187      return {
2188        type: "blockquote",
2189        raw: cap[0],
2190        tokens,
2191        text: text2
2192      };
2193    }
2194  }
2195  list(src) {
vendor: 10,440 bytes, lines 2196-2533
2196    let cap = this.rules.block.list.exec(src);
2197    if (cap) {
2198      let bull = cap[1].trim();
2199      const isordered = bull.length > 1;
2200      const list2 = {
2201        type: "list",
2202        raw: "",
2203        ordered: isordered,
2204        start: isordered ? +bull.slice(0, -1) : "",
2205        loose: false,
2206        items: []
2207      };
2208      bull = isordered ? `\\d{1,9}\\${bull.slice(-1)}` : `\\${bull}`;
2209      if (this.options.pedantic) {
2210        bull = isordered ? bull : "[*+-]";
2211      }
2212      const itemRegex = new RegExp(`^( {0,3}${bull})((?:[	 ][^\\n]*)?(?:\\n|$))`);
2213      let raw = "";
2214      let itemContents = "";
2215      let endsWithBlankLine = false;
2216      while (src) {
2217        let endEarly = false;
2218        if (!(cap = itemRegex.exec(src))) {
2219          break;
2220        }
2221        if (this.rules.block.hr.test(src)) {
2222          break;
2223        }
2224        raw = cap[0];
2225        src = src.substring(raw.length);
2226        let line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t) => " ".repeat(3 * t.length));
2227        let nextLine = src.split("\n", 1)[0];
2228        let indent = 0;
2229        if (this.options.pedantic) {
2230          indent = 2;
2231          itemContents = line.trimStart();
2232        } else {
2233          indent = cap[2].search(/[^ ]/);
2234          indent = indent > 4 ? 1 : indent;
2235          itemContents = line.slice(indent);
2236          indent += cap[1].length;
2237        }
2238        let blankLine = false;
2239        if (!line && /^ *$/.test(nextLine)) {
2240          raw += nextLine + "\n";
2241          src = src.substring(nextLine.length + 1);
2242          endEarly = true;
2243        }
2244        if (!endEarly) {
2245          const nextBulletRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ 	][^\\n]*)?(?:\\n|$))`);
2246          const hrRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`);
2247          const fencesBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}(?:\`\`\`|~~~)`);
2248          const headingBeginRegex = new RegExp(`^ {0,${Math.min(3, indent - 1)}}#`);
2249          while (src) {
2250            const rawLine = src.split("\n", 1)[0];
2251            nextLine = rawLine;
2252            if (this.options.pedantic) {
2253              nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, "  ");
2254            }
2255            if (fencesBeginRegex.test(nextLine)) {
2256              break;
2257            }
2258            if (headingBeginRegex.test(nextLine)) {
2259              break;
2260            }
2261            if (nextBulletRegex.test(nextLine)) {
2262              break;
2263            }
2264            if (hrRegex.test(src)) {
2265              break;
2266            }
2267            if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
2268              itemContents += "\n" + nextLine.slice(indent);
2269            } else {
2270              if (blankLine) {
2271                break;
2272              }
2273              if (line.search(/[^ ]/) >= 4) {
2274                break;
2275              }
2276              if (fencesBeginRegex.test(line)) {
2277                break;
2278              }
2279              if (headingBeginRegex.test(line)) {
2280                break;
2281              }
2282              if (hrRegex.test(line)) {
2283                break;
2284              }
2285              itemContents += "\n" + nextLine;
2286            }
2287            if (!blankLine && !nextLine.trim()) {
2288              blankLine = true;
2289            }
2290            raw += rawLine + "\n";
2291            src = src.substring(rawLine.length + 1);
2292            line = nextLine.slice(indent);
2293          }
2294        }
2295        if (!list2.loose) {
2296          if (endsWithBlankLine) {
2297            list2.loose = true;
2298          } else if (/\n *\n *$/.test(raw)) {
2299            endsWithBlankLine = true;
2300          }
2301        }
2302        let istask = null;
2303        let ischecked;
2304        if (this.options.gfm) {
2305          istask = /^\[[ xX]\] /.exec(itemContents);
2306          if (istask) {
2307            ischecked = istask[0] !== "[ ] ";
2308            itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
2309          }
2310        }
2311        list2.items.push({
2312          type: "list_item",
2313          raw,
2314          task: !!istask,
2315          checked: ischecked,
2316          loose: false,
2317          text: itemContents,
2318          tokens: []
2319        });
2320        list2.raw += raw;
2321      }
2322      list2.items[list2.items.length - 1].raw = raw.trimEnd();
2323      list2.items[list2.items.length - 1].text = itemContents.trimEnd();
2324      list2.raw = list2.raw.trimEnd();
2325      for (let i = 0; i < list2.items.length; i++) {
2326        this.lexer.state.top = false;
2327        list2.items[i].tokens = this.lexer.blockTokens(list2.items[i].text, []);
2328        if (!list2.loose) {
2329          const spacers = list2.items[i].tokens.filter((t) => t.type === "space");
2330          const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t) => /\n.*\n/.test(t.raw));
2331          list2.loose = hasMultipleLineBreaks;
2332        }
2333      }
2334      if (list2.loose) {
2335        for (let i = 0; i < list2.items.length; i++) {
2336          list2.items[i].loose = true;
2337        }
2338      }
2339      return list2;
2340    }
2341  }
2342  html(src) {
2343    const cap = this.rules.block.html.exec(src);
2344    if (cap) {
2345      const token = {
2346        type: "html",
2347        block: true,
2348        raw: cap[0],
2349        pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
2350        text: cap[0]
2351      };
2352      return token;
2353    }
2354  }
2355  def(src) {
2356    const cap = this.rules.block.def.exec(src);
2357    if (cap) {
2358      const tag2 = cap[1].toLowerCase().replace(/\s+/g, " ");
2359      const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
2360      const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
2361      return {
2362        type: "def",
2363        tag: tag2,
2364        raw: cap[0],
2365        href,
2366        title
2367      };
2368    }
2369  }
2370  table(src) {
2371    const cap = this.rules.block.table.exec(src);
2372    if (!cap) {
2373      return;
2374    }
2375    if (!/[:|]/.test(cap[2])) {
2376      return;
2377    }
2378    const headers = splitCells(cap[1]);
2379    const aligns = cap[2].replace(/^\||\| *$/g, "").split("|");
2380    const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : [];
2381    const item = {
2382      type: "table",
2383      raw: cap[0],
2384      header: [],
2385      align: [],
2386      rows: []
2387    };
2388    if (headers.length !== aligns.length) {
2389      return;
2390    }
2391    for (const align of aligns) {
2392      if (/^ *-+: *$/.test(align)) {
2393        item.align.push("right");
2394      } else if (/^ *:-+: *$/.test(align)) {
2395        item.align.push("center");
2396      } else if (/^ *:-+ *$/.test(align)) {
2397        item.align.push("left");
2398      } else {
2399        item.align.push(null);
2400      }
2401    }
2402    for (const header of headers) {
2403      item.header.push({
2404        text: header,
2405        tokens: this.lexer.inline(header)
2406      });
2407    }
2408    for (const row of rows) {
2409      item.rows.push(splitCells(row, item.header.length).map((cell) => {
2410        return {
2411          text: cell,
2412          tokens: this.lexer.inline(cell)
2413        };
2414      }));
2415    }
2416    return item;
2417  }
2418  lheading(src) {
2419    const cap = this.rules.block.lheading.exec(src);
2420    if (cap) {
2421      return {
2422        type: "heading",
2423        raw: cap[0],
2424        depth: cap[2].charAt(0) === "=" ? 1 : 2,
2425        text: cap[1],
2426        tokens: this.lexer.inline(cap[1])
2427      };
2428    }
2429  }
2430  paragraph(src) {
2431    const cap = this.rules.block.paragraph.exec(src);
2432    if (cap) {
2433      const text2 = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
2434      return {
2435        type: "paragraph",
2436        raw: cap[0],
2437        text: text2,
2438        tokens: this.lexer.inline(text2)
2439      };
2440    }
2441  }
2442  text(src) {
2443    const cap = this.rules.block.text.exec(src);
2444    if (cap) {
2445      return {
2446        type: "text",
2447        raw: cap[0],
2448        text: cap[0],
2449        tokens: this.lexer.inline(cap[0])
2450      };
2451    }
2452  }
2453  escape(src) {
2454    const cap = this.rules.inline.escape.exec(src);
2455    if (cap) {
2456      return {
2457        type: "escape",
2458        raw: cap[0],
2459        text: escape$1$1(cap[1])
2460      };
2461    }
2462  }
2463  tag(src) {
2464    const cap = this.rules.inline.tag.exec(src);
2465    if (cap) {
2466      if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
2467        this.lexer.state.inLink = true;
2468      } else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
2469        this.lexer.state.inLink = false;
2470      }
2471      if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
2472        this.lexer.state.inRawBlock = true;
2473      } else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
2474        this.lexer.state.inRawBlock = false;
2475      }
2476      return {
2477        type: "html",
2478        raw: cap[0],
2479        inLink: this.lexer.state.inLink,
2480        inRawBlock: this.lexer.state.inRawBlock,
2481        block: false,
2482        text: cap[0]
2483      };
2484    }
2485  }
2486  link(src) {
2487    const cap = this.rules.inline.link.exec(src);
2488    if (cap) {
2489      const trimmedUrl = cap[2].trim();
2490      if (!this.options.pedantic && /^</.test(trimmedUrl)) {
2491        if (!/>$/.test(trimmedUrl)) {
2492          return;
2493        }
2494        const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
2495        if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
2496          return;
2497        }
2498      } else {
2499        const lastParenIndex = findClosingBracket(cap[2], "()");
2500        if (lastParenIndex > -1) {
2501          const start = cap[0].indexOf("!") === 0 ? 5 : 4;
2502          const linkLen = start + cap[1].length + lastParenIndex;
2503          cap[2] = cap[2].substring(0, lastParenIndex);
2504          cap[0] = cap[0].substring(0, linkLen).trim();
2505          cap[3] = "";
2506        }
2507      }
2508      let href = cap[2];
2509      let title = "";
2510      if (this.options.pedantic) {
2511        const link2 = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
2512        if (link2) {
2513          href = link2[1];
2514          title = link2[3];
2515        }
2516      } else {
2517        title = cap[3] ? cap[3].slice(1, -1) : "";
2518      }
2519      href = href.trim();
2520      if (/^</.test(href)) {
2521        if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
2522          href = href.slice(1);
2523        } else {
2524          href = href.slice(1, -1);
2525        }
2526      }
2527      return outputLink(cap, {
2528        href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
2529        title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
2530      }, cap[0], this.lexer);
2531    }
2532  }
2533  reflink(src, links) {
2534    let cap;
2535    if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
2536      const linkString = (cap[2] || cap[1]).replace(/\s+/g, " ");
2537      const link2 = links[linkString.toLowerCase()];
2538      if (!link2) {
2539        const text2 = cap[0].charAt(0);
2540        return {
2541          type: "text",
2542          raw: text2,
2543          text: text2
2544        };
2545      }
2546      return outputLink(cap, link2, cap[0], this.lexer);
2547    }
2548  }
2549  emStrong(src, maskedSrc, prevChar = "") {
2550    let match = this.rules.inline.emStrongLDelim.exec(src);
2551    if (!match)
2552      return;
2553    if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
2554      return;
2555    const nextChar = match[1] || match[2] || "";
2556    if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
2557      const lLength = [...match[0]].length - 1;
2558      let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
2559      const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
2560      endReg.lastIndex = 0;
2561      maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
2562      while ((match = endReg.exec(maskedSrc)) != null) {
2563        rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
2564        if (!rDelim)
2565          continue;
2566        rLength = [...rDelim].length;
2567        if (match[3] || match[4]) {
2568          delimTotal += rLength;
2569          continue;
2570        } else if (match[5] || match[6]) {
2571          if (lLength % 3 && !((lLength + rLength) % 3)) {
2572            midDelimTotal += rLength;
2573            continue;
2574          }
2575        }
2576        delimTotal -= rLength;
2577        if (delimTotal > 0)
2578          continue;
2579        rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
2580        const lastCharLength = [...match[0]][0].length;
2581        const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
2582        if (Math.min(lLength, rLength) % 2) {
2583          const text3 = raw.slice(1, -1);
2584          return {
2585            type: "em",
2586            raw,
2587            text: text3,
2588            tokens: this.lexer.inlineTokens(text3)
2589          };
2590        }
2591        const text2 = raw.slice(2, -2);
2592        return {
2593          type: "strong",
2594          raw,
2595          text: text2,
2596          tokens: this.lexer.inlineTokens(text2)
2597        };
2598      }
2599    }
2600  }
2601  codespan(src) {
2602    const cap = this.rules.inline.code.exec(src);
2603    if (cap) {
2604      let text2 = cap[2].replace(/\n/g, " ");
2605      const hasNonSpaceChars = /[^ ]/.test(text2);
2606      const hasSpaceCharsOnBothEnds = /^ /.test(text2) && / $/.test(text2);
2607      if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
2608        text2 = text2.substring(1, text2.length - 1);
2609      }
2610      text2 = escape$1$1(text2, true);
2611      return {
2612        type: "codespan",
2613        raw: cap[0],
2614        text: text2
2615      };
2616    }
2617  }
2618  br(src) {
2619    const cap = this.rules.inline.br.exec(src);
2620    if (cap) {
2621      return {
2622        type: "br",
2623        raw: cap[0]
2624      };
2625    }
2626  }
2627  del(src) {
2628    const cap = this.rules.inline.del.exec(src);
2629    if (cap) {
2630      return {
2631        type: "del",
2632        raw: cap[0],
2633        text: cap[2],
2634        tokens: this.lexer.inlineTokens(cap[2])
2635      };
2636    }
2637  }
2638  autolink(src) {
2639    const cap = this.rules.inline.autolink.exec(src);
2640    if (cap) {
2641      let text2, href;
2642      if (cap[2] === "@") {
2643        text2 = escape$1$1(cap[1]);
2644        href = "mailto:" + text2;
2645      } else {
2646        text2 = escape$1$1(cap[1]);
2647        href = text2;
2648      }
2649      return {
2650        type: "link",
2651        raw: cap[0],
2652        text: text2,
2653        href,
2654        tokens: [
2655          {
2656            type: "text",
2657            raw: text2,
2658            text: text2
2659          }
2660        ]
2661      };
2662    }
2663  }
2664  url(src) {
2665    var _a;
2666    let cap;
2667    if (cap = this.rules.inline.url.exec(src)) {
2668      let text2, href;
2669      if (cap[2] === "@") {
2670        text2 = escape$1$1(cap[0]);
2671        href = "mailto:" + text2;
2672      } else {
2673        let prevCapZero;
2674        do {
2675          prevCapZero = cap[0];
2676          cap[0] = ((_a = this.rules.inline._backpedal.exec(cap[0])) == null ? void 0 : _a[0]) ?? "";
2677        } while (prevCapZero !== cap[0]);
2678        text2 = escape$1$1(cap[0]);
2679        if (cap[1] === "www.") {
2680          href = "http://" + cap[0];
2681        } else {
2682          href = cap[0];
2683        }
2684      }
2685      return {
2686        type: "link",
2687        raw: cap[0],
2688        text: text2,
2689        href,
2690        tokens: [
2691          {
2692            type: "text",
2693            raw: text2,
2694            text: text2
2695          }
2696        ]
2697      };
2698    }
2699  }
2700  inlineText(src) {
2701    const cap = this.rules.inline.text.exec(src);
2702    if (cap) {
2703      let text2;
2704      if (this.lexer.state.inRawBlock) {
2705        text2 = cap[0];
2706      } else {
2707        text2 = escape$1$1(cap[0]);
2708      }
2709      return {
2710        type: "text",
2711        raw: cap[0],
2712        text: text2
2713      };
2714    }
2715  }
2716}
2717const newline = /^(?: *(?:\n|$))+/;
2718const blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
2719const fences = /^ {0,3}(`{3,}
2719(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
2720const hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
2721const heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
2722const bullet = /(?:[*+-]|\d{1,9}[.)])/;
2723const lheading = edit(/^(?!bull |blockCode|fences|blockquote|heading|html)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).replace(/blockCode/g, / {4}/).replace(/fences/g, / {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g, / {0,3}>/).replace(/heading/g, / {0,3}#{1,6}/).replace(/html/g, / {0,3}<[^\n>]+>\n/).getRegex();
2724const _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
2725const blockText = /^[^\n]+/;
2726const _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
2727const def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
2728const list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
2729const _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
2730const _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
2731const html = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))", "i").replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
2732const paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
2733const blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
2734const blockNormal = {
2735  blockquote,
2736  code: blockCode,
2737  def,
2738  fences,
2739  heading,
2740  hr,
2741  html,
2742  lheading,
2743  list,
2744  newline,
2745  paragraph,
2746  table: noopTest,
2747  text: blockText
2748};
2749const gfmTable = edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
2750const blockGfm = {
2751  ...blockNormal,
2752  table: gfmTable,
2753  paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
2754};
2755const blockPedantic = {
2756  ...blockNormal,
2757  html: edit(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment", _comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
2758  def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
2759  heading: /^(#{1,6})(.*)(?:\n+|$)/,
2760  fences: noopTest,
2761  // fences not supported
2762  lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
2763  paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
2764};
2765const escape$2 = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
2766const inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
2767const br = /^( {2,}|\\)\n(?!\s*$)/;
2768const inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
2769const _punctuation = "\\p{P}\\p{S}";
2770const punctuation = edit(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, _punctuation).getRegex();
2771const blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
2772const emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex();
2773const emStrongRDelimAst = edit("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, _punctuation).getRegex();
2774const emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, _punctuation).getRegex();
2775const anyPunctuation = edit(/\\([punct])/, "gu").replace(/punct/g, _punctuation).getRegex();
2776const autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[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])?)+(?![-_])/).getRegex();
2777const _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
2778const tag = edit("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
2779const _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
2780const link = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
2781const reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
2782const nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
2783const reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
2784const inlineNormal = {
2785  _backpedal: noopTest,
2786  // only used for GFM url
2787  anyPunctuation,
2788  autolink,
2789  blockSkip,
2790  br,
vendor: 15,001 bytes, lines 2791-3257
2791  code: inlineCode,
2792  del: noopTest,
2793  emStrongLDelim,
2794  emStrongRDelimAst,
2795  emStrongRDelimUnd,
2796  escape: escape$2,
2797  link,
2798  nolink,
2799  punctuation,
2800  reflink,
2801  reflinkSearch,
2802  tag,
2803  text: inlineText,
2804  url: noopTest
2805};
2806const inlinePedantic = {
2807  ...inlineNormal,
2808  link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
2809  reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
2810};
2811const inlineGfm = {
2812  ...inlineNormal,
2813  escape: edit(escape$2).replace("])", "~|])").getRegex(),
2814  url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
2815  _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
2816  del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
2817  text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
2818};
2819const inlineBreaks = {
2820  ...inlineGfm,
2821  br: edit(br).replace("{2,}", "*").getRegex(),
2822  text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
2823};
2824const block = {
2825  normal: blockNormal,
2826  gfm: blockGfm,
2827  pedantic: blockPedantic
2828};
2829const inline = {
2830  normal: inlineNormal,
2831  gfm: inlineGfm,
2832  breaks: inlineBreaks,
2833  pedantic: inlinePedantic
2834};
2835class _Lexer {
2836  constructor(options) {
2837    __publicField(this, "tokens");
2838    __publicField(this, "options");
2839    __publicField(this, "state");
2840    __publicField(this, "tokenizer");
2841    __publicField(this, "inlineQueue");
2842    this.tokens = [];
2843    this.tokens.links = /* @__PURE__ */ Object.create(null);
2844    this.options = options || _defaults;
2845    this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
2846    this.tokenizer = this.options.tokenizer;
2847    this.tokenizer.options = this.options;
2848    this.tokenizer.lexer = this;
2849    this.inlineQueue = [];
2850    this.state = {
2851      inLink: false,
2852      inRawBlock: false,
2853      top: true
2854    };
2855    const rules = {
2856      block: block.normal,
2857      inline: inline.normal
2858    };
2859    if (this.options.pedantic) {
2860      rules.block = block.pedantic;
2861      rules.inline = inline.pedantic;
2862    } else if (this.options.gfm) {
2863      rules.block = block.gfm;
2864      if (this.options.breaks) {
2865        rules.inline = inline.breaks;
2866      } else {
2867        rules.inline = inline.gfm;
2868      }
2869    }
2870    this.tokenizer.rules = rules;
2871  }
2872  /**
2873   * Expose Rules
2874   */
2875  static get rules() {
2876    return {
2877      block,
2878      inline
2879    };
2880  }
2881  /**
2882   * Static Lex Method
2883   */
2884  static lex(src, options) {
2885    const lexer = new _Lexer(options);
2886    return lexer.lex(src);
2887  }
2888  /**
2889   * Static Lex Inline Method
2890   */
2891  static lexInline(src, options) {
2892    const lexer = new _Lexer(options);
2893    return lexer.inlineTokens(src);
2894  }
2895  /**
2896   * Preprocessing
2897   */
2898  lex(src) {
2899    src = src.replace(/\r\n|\r/g, "\n");
2900    this.blockTokens(src, this.tokens);
2901    for (let i = 0; i < this.inlineQueue.length; i++) {
2902      const next = this.inlineQueue[i];
2903      this.inlineTokens(next.src, next.tokens);
2904    }
2905    this.inlineQueue = [];
2906    return this.tokens;
2907  }
2908  blockTokens(src, tokens = []) {
2909    if (this.options.pedantic) {
2910      src = src.replace(/\t/g, "    ").replace(/^ +$/gm, "");
2911    } else {
2912      src = src.replace(/^( *)(\t+)/gm, (_, leading, tabs) => {
2913        return leading + "    ".repeat(tabs.length);
2914      });
2915    }
2916    let token;
2917    let lastToken;
2918    let cutSrc;
2919    let lastParagraphClipped;
2920    while (src) {
2921      if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
2922        if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
2923          src = src.substring(token.raw.length);
2924          tokens.push(token);
2925          return true;
2926        }
2927        return false;
2928      })) {
2929        continue;
2930      }
2931      if (token = this.tokenizer.space(src)) {
2932        src = src.substring(token.raw.length);
2933        if (token.raw.length === 1 && tokens.length > 0) {
2934          tokens[tokens.length - 1].raw += "\n";
2935        } else {
2936          tokens.push(token);
2937        }
2938        continue;
2939      }
2940      if (token = this.tokenizer.code(src)) {
2941        src = src.substring(token.raw.length);
2942        lastToken = tokens[tokens.length - 1];
2943        if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
2944          lastToken.raw += "\n" + token.raw;
2945          lastToken.text += "\n" + token.text;
2946          this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
2947        } else {
2948          tokens.push(token);
2949        }
2950        continue;
2951      }
2952      if (token = this.tokenizer.fences(src)) {
2953        src = src.substring(token.raw.length);
2954        tokens.push(token);
2955        continue;
2956      }
2957      if (token = this.tokenizer.heading(src)) {
2958        src = src.substring(token.raw.length);
2959        tokens.push(token);
2960        continue;
2961      }
2962      if (token = this.tokenizer.hr(src)) {
2963        src = src.substring(token.raw.length);
2964        tokens.push(token);
2965        continue;
2966      }
2967      if (token = this.tokenizer.blockquote(src)) {
2968        src = src.substring(token.raw.length);
2969        tokens.push(token);
2970        continue;
2971      }
2972      if (token = this.tokenizer.list(src)) {
2973        src = src.substring(token.raw.length);
2974        tokens.push(token);
2975        continue;
2976      }
2977      if (token = this.tokenizer.html(src)) {
2978        src = src.substring(token.raw.length);
2979        tokens.push(token);
2980        continue;
2981      }
2982      if (token = this.tokenizer.def(src)) {
2983        src = src.substring(token.raw.length);
2984        lastToken = tokens[tokens.length - 1];
2985        if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
2986          lastToken.raw += "\n" + token.raw;
2987          lastToken.text += "\n" + token.raw;
2988          this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
2989        } else if (!this.tokens.links[token.tag]) {
2990          this.tokens.links[token.tag] = {
2991            href: token.href,
2992            title: token.title
2993          };
2994        }
2995        continue;
2996      }
2997      if (token = this.tokenizer.table(src)) {
2998        src = src.substring(token.raw.length);
2999        tokens.push(token);
3000        continue;
3001      }
3002      if (token = this.tokenizer.lheading(src)) {
3003        src = src.substring(token.raw.length);
3004        tokens.push(token);
3005        continue;
3006      }
3007      cutSrc = src;
3008      if (this.options.extensions && this.options.extensions.startBlock) {
3009        let startIndex = Infinity;
3010        const tempSrc = src.slice(1);
3011        let tempStart;
3012        this.options.extensions.startBlock.forEach((getStartIndex) => {
3013          tempStart = getStartIndex.call({ lexer: this }, tempSrc);
3014          if (typeof tempStart === "number" && tempStart >= 0) {
3015            startIndex = Math.min(startIndex, tempStart);
3016          }
3017        });
3018        if (startIndex < Infinity && startIndex >= 0) {
3019          cutSrc = src.substring(0, startIndex + 1);
3020        }
3021      }
3022      if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
3023        lastToken = tokens[tokens.length - 1];
3024        if (lastParagraphClipped && lastToken.type === "paragraph") {
3025          lastToken.raw += "\n" + token.raw;
3026          lastToken.text += "\n" + token.text;
3027          this.inlineQueue.pop();
3028          this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
3029        } else {
3030          tokens.push(token);
3031        }
3032        lastParagraphClipped = cutSrc.length !== src.length;
3033        src = src.substring(token.raw.length);
3034        continue;
3035      }
3036      if (token = this.tokenizer.text(src)) {
3037        src = src.substring(token.raw.length);
3038        lastToken = tokens[tokens.length - 1];
3039        if (lastToken && lastToken.type === "text") {
3040          lastToken.raw += "\n" + token.raw;
3041          lastToken.text += "\n" + token.text;
3042          this.inlineQueue.pop();
3043          this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
3044        } else {
3045          tokens.push(token);
3046        }
3047        continue;
3048      }
3049      if (src) {
3050        const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
3051        if (this.options.silent) {
3052          console.error(errMsg);
3053          break;
3054        } else {
3055          throw new Error(errMsg);
3056        }
3057      }
3058    }
3059    this.state.top = true;
3060    return tokens;
3061  }
3062  inline(src, tokens = []) {
3063    this.inlineQueue.push({ src, tokens });
3064    return tokens;
3065  }
3066  /**
3067   * Lexing/Compiling
3068   */
3069  inlineTokens(src, tokens = []) {
3070    let token, lastToken, cutSrc;
3071    let maskedSrc = src;
3072    let match;
3073    let keepPrevChar, prevChar;
3074    if (this.tokens.links) {
3075      const links = Object.keys(this.tokens.links);
3076      if (links.length > 0) {
3077        while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
3078          if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
3079            maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
3080          }
3081        }
3082      }
3083    }
3084    while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
3085      maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
3086    }
3087    while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
3088      maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
3089    }
3090    while (src) {
3091      if (!keepPrevChar) {
3092        prevChar = "";
3093      }
3094      keepPrevChar = false;
3095      if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((extTokenizer) => {
3096        if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
3097          src = src.substring(token.raw.length);
3098          tokens.push(token);
3099          return true;
3100        }
3101        return false;
3102      })) {
3103        continue;
3104      }
3105      if (token = this.tokenizer.escape(src)) {
3106        src = src.substring(token.raw.length);
3107        tokens.push(token);
3108        continue;
3109      }
3110      if (token = this.tokenizer.tag(src)) {
3111        src = src.substring(token.raw.length);
3112        lastToken = tokens[tokens.length - 1];
3113        if (lastToken && token.type === "text" && lastToken.type === "text") {
3114          lastToken.raw += token.raw;
3115          lastToken.text += token.text;
3116        } else {
3117          tokens.push(token);
3118        }
3119        continue;
3120      }
3121      if (token = this.tokenizer.link(src)) {
3122        src = src.substring(token.raw.length);
3123        tokens.push(token);
3124        continue;
3125      }
3126      if (token = this.tokenizer.reflink(src, this.tokens.links)) {
3127        src = src.substring(token.raw.length);
3128        lastToken = tokens[tokens.length - 1];
3129        if (lastToken && token.type === "text" && lastToken.type === "text") {
3130          lastToken.raw += token.raw;
3131          lastToken.text += token.text;
3132        } else {
3133          tokens.push(token);
3134        }
3135        continue;
3136      }
3137      if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
3138        src = src.substring(token.raw.length);
3139        tokens.push(token);
3140        continue;
3141      }
3142      if (token = this.tokenizer.codespan(src)) {
3143        src = src.substring(token.raw.length);
3144        tokens.push(token);
3145        continue;
3146      }
3147      if (token = this.tokenizer.br(src)) {
3148        src = src.substring(token.raw.length);
3149        tokens.push(token);
3150        continue;
3151      }
3152      if (token = this.tokenizer.del(src)) {
3153        src = src.substring(token.raw.length);
3154        tokens.push(token);
3155        continue;
3156      }
3157      if (token = this.tokenizer.autolink(src)) {
3158        src = src.substring(token.raw.length);
3159        tokens.push(token);
3160        continue;
3161      }
3162      if (!this.state.inLink && (token = this.tokenizer.url(src))) {
3163        src = src.substring(token.raw.length);
3164        tokens.push(token);
3165        continue;
3166      }
3167      cutSrc = src;
3168      if (this.options.extensions && this.options.extensions.startInline) {
3169        let startIndex = Infinity;
3170        const tempSrc = src.slice(1);
3171        let tempStart;
3172        this.options.extensions.startInline.forEach((getStartIndex) => {
3173          tempStart = getStartIndex.call({ lexer: this }, tempSrc);
3174          if (typeof tempStart === "number" && tempStart >= 0) {
3175            startIndex = Math.min(startIndex, tempStart);
3176          }
3177        });
3178        if (startIndex < Infinity && startIndex >= 0) {
3179          cutSrc = src.substring(0, startIndex + 1);
3180        }
3181      }
3182      if (token = this.tokenizer.inlineText(cutSrc)) {
3183        src = src.substring(token.raw.length);
3184        if (token.raw.slice(-1) !== "_") {
3185          prevChar = token.raw.slice(-1);
3186        }
3187        keepPrevChar = true;
3188        lastToken = tokens[tokens.length - 1];
3189        if (lastToken && lastToken.type === "text") {
3190          lastToken.raw += token.raw;
3191          lastToken.text += token.text;
3192        } else {
3193          tokens.push(token);
3194        }
3195        continue;
3196      }
3197      if (src) {
3198        const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
3199        if (this.options.silent) {
3200          console.error(errMsg);
3201          break;
3202        } else {
3203          throw new Error(errMsg);
3204        }
3205      }
3206    }
3207    return tokens;
3208  }
3209}
3210class _Renderer {
3211  constructor(options) {
3212    __publicField(this, "options");
3213    this.options = options || _defaults;
3214  }
3215  code(code, infostring, escaped) {
3216    var _a;
3217    const lang = (_a = (infostring || "").match(/^\S*/)) == null ? void 0 : _a[0];
3218    code = code.replace(/\n$/, "") + "\n";
3219    if (!lang) {
3220      return "<pre><code>" + (escaped ? code : escape$1$1(code, true)) + "</code></pre>\n";
3221    }
3222    return '<pre><code class="language-' + escape$1$1(lang) + '">' + (escaped ? code : escape$1$1(code, true)) + "</code></pre>\n";
3223  }
3224  blockquote(quote) {
3225    return `<blockquote>
3226${quote}</blockquote>
3227`;
3228  }
3229  html(html2, block2) {
3230    return html2;
3231  }
3232  heading(text2, level, raw) {
3233    return `<h${level}>${text2}</h${level}>
3234`;
3235  }
3236  hr() {
3237    return "<hr>\n";
3238  }
3239  list(body, ordered, start) {
3240    const type = ordered ? "ol" : "ul";
3241    const startatt = ordered && start !== 1 ? ' start="' + start + '"' : "";
3242    return "<" + type + startatt + ">\n" + body + "</" + type + ">\n";
3243  }
3244  listitem(text2, task, checked) {
3245    return `<li>${text2}</li>
3246`;
3247  }
3248  checkbox(checked) {
3249    return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
3250  }
3251  paragraph(text2) {
3252    return `<p>${text2}</p>
3253`;
3254  }
3255  table(header, body) {
3256    if (body)
3257      body = `<tbody>${body}
3257</tbody>`;
3258    return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
3259  }
3260  tablerow(content) {
3261    return `<tr>
3262${content}</tr>
3263`;
3264  }
3265  tablecell(content, flags) {
3266    const type = flags.header ? "th" : "td";
3267    const tag2 = flags.align ? `<${type} align="${flags.align}">` : `<${type}>`;
3268    return tag2 + content + `</${type}>
3269`;
3270  }
3271  /**
3272   * span level renderer
3273   */
3274  strong(text2) {
3275    return `<strong>${text2}</strong>`;
3276  }
3277  em(text2) {
3278    return `<em>${text2}</em>`;
3279  }
3280  codespan(text2) {
3281    return `<code>${text2}</code>`;
3282  }
3283  br() {
3284    return "<br>";
3285  }
3286  del(text2) {
3287    return `<del>${text2}</del>`;
3288  }
3289  link(href, title, text2) {
3290    const cleanHref = cleanUrl(href);
3291    if (cleanHref === null) {
3292      return text2;
3293    }
3294    href = cleanHref;
3295    let out = '<a href="' + href + '"';
3296    if (title) {
3297      out += ' title="' + title + '"';
3298    }
3299    out += ">" + text2 + "</a>";
3300    return out;
3301  }
3302  image(href, title, text2) {
3303    const cleanHref = cleanUrl(href);
3304    if (cleanHref === null) {
3305      return text2;
3306    }
3307    href = cleanHref;
3308    let out = `<img src="${href}" alt="${text2}"`;
3309    if (title) {
3310      out += ` title="${title}"`;
3311    }
3312    out += ">";
3313    return out;
3314  }
3315  text(text2) {
3316    return text2;
3317  }
3318}
3319class _TextRenderer {
3320  // no need for block level renderers
3321  strong(text2) {
3322    return text2;
3323  }
3324  em(text2) {
3325    return text2;
3326  }
3327  codespan(text2) {
3328    return text2;
3329  }
3330  del(text2) {
3331    return text2;
3332  }
3333  html(text2) {
3334    return text2;
3335  }
3336  text(text2) {
3337    return text2;
3338  }
3339  link(href, title, text2) {
3340    return "" + text2;
3341  }
3342  image(href, title, text2) {
3343    return "" + text2;
3344  }
3345  br() {
3346    return "";
3347  }
3348}
3349class _Parser {
3350  constructor(options) {
3351    __publicField(this, "options");
3352    __publicField(this, "renderer");
3353    __publicField(this, "textRenderer");
3354    this.options = options || _defaults;
3355    this.options.renderer = this.options.renderer || new _Renderer();
3356    this.renderer = this.options.renderer;
3357    this.renderer.options = this.options;
3358    this.textRenderer = new _TextRenderer();
3359  }
3360  /**
3361   * Static Parse Method
3362   */
3363  static parse(tokens, options) {
3364    const parser = new _Parser(options);
3365    return parser.parse(tokens);
3366  }
3367  /**
3368   * Static Parse Inline Method
3369   */
3370  static parseInline(tokens, options) {
3371    const parser = new _Parser(options);
3372    return parser.parseInline(tokens);
3373  }
3374  /**
3375   * Parse Loop
3376   */
3377  parse(tokens, top = true) {
3378    let out = "";
3379    for (let i = 0; i < tokens.length; i++) {
3380      const token = tokens[i];
3381      if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
3382        const genericToken = token;
3383        const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
3384        if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
3385          out += ret || "";
3386          continue;
3387        }
3388      }
3389      switch (token.type) {
3390        case "space": {
3391          continue;
3392        }
3393        case "hr": {
3394          out += this.renderer.hr();
3395          continue;
3396        }
3397        case "heading": {
3398          const headingToken = token;
3399          out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape(this.parseInline(headingToken.tokens, this.textRenderer)));
3400          continue;
3401        }
3402        case "code": {
3403          const codeToken = token;
3404          out += this.renderer.code(codeToken.text, codeToken.lang, !!codeToken.escaped);
3405          continue;
3406        }
3407        case "table": {
3408          const tableToken = token;
3409          let header = "";
3410          let cell = "";
3411          for (let j = 0; j < tableToken.header.length; j++) {
3412            cell += this.renderer.tablecell(this.parseInline(tableToken.header[j].tokens), { header: true, align: tableToken.align[j] });
3413          }
3414          header += this.renderer.tablerow(cell);
3415          let body = "";
3416          for (let j = 0; j < tableToken.rows.length; j++) {
vendor: 2,786 bytes, lines 3417-3484
3417            const row = tableToken.rows[j];
3418            cell = "";
3419            for (let k = 0; k < row.length; k++) {
3420              cell += this.renderer.tablecell(this.parseInline(row[k].tokens), { header: false, align: tableToken.align[k] });
3421            }
3422            body += this.renderer.tablerow(cell);
3423          }
3424          out += this.renderer.table(header, body);
3425          continue;
3426        }
3427        case "blockquote": {
3428          const blockquoteToken = token;
3429          const body = this.parse(blockquoteToken.tokens);
3430          out += this.renderer.blockquote(body);
3431          continue;
3432        }
3433        case "list": {
3434          const listToken = token;
3435          const ordered = listToken.ordered;
3436          const start = listToken.start;
3437          const loose = listToken.loose;
3438          let body = "";
3439          for (let j = 0; j < listToken.items.length; j++) {
3440            const item = listToken.items[j];
3441            const checked = item.checked;
3442            const task = item.task;
3443            let itemBody = "";
3444            if (item.task) {
3445              const checkbox = this.renderer.checkbox(!!checked);
3446              if (loose) {
3447                if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
3448                  item.tokens[0].text = checkbox + " " + item.tokens[0].text;
3449                  if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
3450                    item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
3451                  }
3452                } else {
3453                  item.tokens.unshift({
3454                    type: "text",
3455                    text: checkbox + " "
3456                  });
3457                }
3458              } else {
3459                itemBody += checkbox + " ";
3460              }
3461            }
3462            itemBody += this.parse(item.tokens, loose);
3463            body += this.renderer.listitem(itemBody, task, !!checked);
3464          }
3465          out += this.renderer.list(body, ordered, start);
3466          continue;
3467        }
3468        case "html": {
3469          const htmlToken = token;
3470          out += this.renderer.html(htmlToken.text, htmlToken.block);
3471          continue;
3472        }
3473        case "paragraph": {
3474          const paragraphToken = token;
3475          out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens));
3476          continue;
3477        }
3478        case "text": {
3479          let textToken = token;
3480          let body = textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text;
3481          while (i + 1 < tokens.length && tokens[i + 1].type === "text") {
3482            textToken = tokens[++i];
3483            body += "\n" + (textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text);
3484          }
3485          out += top ? this.renderer.paragraph(body) : body;
3486          continue;
3487        }
3488        default: {
3489          const errMsg = 'Token with "' + token.type + '" type was not found.';
3490          if (this.options.silent) {
3491            console.error(errMsg);
3492            return "";
3493          } else {
3494            throw new Error(errMsg);
3495          }
3496        }
3497      }
3498    }
3499    return out;
3500  }
3501  /**
3502   * Parse Inline Tokens
3503   */
3504  parseInline(tokens, renderer2) {
3505    renderer2 = renderer2 || this.renderer;
3506    let out = "";
3507    for (let i = 0; i < tokens.length; i++) {
3508      const token = tokens[i];
3509      if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
3510        const ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
3511        if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
3512          out += ret || "";
3513          continue;
3514        }
3515      }
3516      switch (token.type) {
3517        case "escape": {
3518          const escapeToken = token;
3519          out += renderer2.text(escapeToken.text);
3520          break;
3521        }
3522        case "html": {
3523          const tagToken = token;
3524          out += renderer2.html(tagToken.text);
3525          break;
3526        }
3527        case "link": {
3528          const linkToken = token;
3529          out += renderer2.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer2));
3530          break;
3531        }
3532        case "image": {
3533          const imageToken = token;
3534          out += renderer2.image(imageToken.href, imageToken.title, imageToken.text);
3535          break;
3536        }
3537        case "strong": {
3538          const strongToken = token;
3539          out += renderer2.strong(this.parseInline(strongToken.tokens, renderer2));
3540          break;
3541        }
3542        case "em": {
3543          const emToken = token;
3544          out += renderer2.em(this.parseInline(emToken.tokens, renderer2));
3545          break;
3546        }
3547        case "codespan": {
3548          const codespanToken = token;
3549          out += renderer2.codespan(codespanToken.text);
3550          break;
3551        }
3552        case "br": {
3553          out += renderer2.br();
3554          break;
3555        }
3556        case "del": {
3557          const delToken = token;
3558          out += renderer2.del(this.parseInline(delToken.tokens, renderer2));
3559          break;
3560        }
3561        case "text": {
3562          const textToken = token;
3563          out += renderer2.text(textToken.text);
3564          break;
3565        }
3566        default: {
3567          const errMsg = 'Token with "' + token.type + '" type was not found.';
3568          if (this.options.silent) {
3569            console.error(errMsg);
3570            return "";
3571          } else {
3572            throw new Error(errMsg);
3573          }
3574        }
3575      }
3576    }
3577    return out;
3578  }
3579}
3580class _Hooks {
3581  constructor(options) {
3582    __publicField(this, "options");
3583    this.options = options || _defaults;
3584  }
3585  /**
3586   * Process markdown before marked
3587   */
3588  preprocess(markdown) {
3589    return markdown;
3590  }
3591  /**
3592   * Process HTML after marked is finished
3593   */
3594  postprocess(html2) {
3595    return html2;
3596  }
3597  /**
3598   * Process all tokens before walk tokens
3599   */
3600  processAllTokens(tokens) {
3601    return tokens;
3602  }
3603}
3604__publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
3605  "preprocess",
3606  "postprocess",
3607  "processAllTokens"
3608]));
3609class Marked {
3610  constructor(...args) {
3611    __privateAdd(this, _Marked_instances);
3612    __publicField(this, "defaults", _getDefaults());
3613    __publicField(this, "options", this.setOptions);
3614    __publicField(this, "parse", __privateMethod(this, _Marked_instances, parseMarkdown_fn).call(this, _Lexer.lex, _Parser.parse));
3615    __publicField(this, "parseInline", __privateMethod(this, _Marked_instances, parseMarkdown_fn).call(this, _Lexer.lexInline, _Parser.parseInline));
3616    __publicField(this, "Parser", _Parser);
3617    __publicField(this, "Renderer", _Renderer);
3618    __publicField(this, "TextRenderer", _TextRenderer);
3619    __publicField(this, "Lexer", _Lexer);
3620    __publicField(this, "Tokenizer", _Tokenizer);
3621    __publicField(this, "Hooks", _Hooks);
3622    this.use(...args);
3623  }
3624  /**
3625   * Run callback for every token
3626   */
3627  walkTokens(tokens, callback) {
3628    var _a, _b;
3629    let values = [];
3630    for (const token of tokens) {
3631      values = values.concat(callback.call(this, token));
3632      switch (token.type) {
3633        case "table": {
3634          const tableToken = token;
3635          for (const cell of tableToken.header) {
3636            values = values.concat(this.walkTokens(cell.tokens, callback));
3637          }
3638          for (const row of tableToken.rows) {
3639            for (const cell of row) {
3640              values = values.concat(this.walkTokens(cell.tokens, callback));
3641            }
3642          }
3643          break;
3644        }
3645        case "list": {
3646          const listToken = token;
3647          values = values.concat(this.walkTokens(listToken.items, c
vendor: 4,161 bytes, lines 3647-3755
3647allback));
3648          break;
3649        }
3650        default: {
3651          const genericToken = token;
3652          if ((_b = (_a = this.defaults.extensions) == null ? void 0 : _a.childTokens) == null ? void 0 : _b[genericToken.type]) {
3653            this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
3654              const tokens2 = genericToken[childTokens].flat(Infinity);
3655              values = values.concat(this.walkTokens(tokens2, callback));
3656            });
3657          } else if (genericToken.tokens) {
3658            values = values.concat(this.walkTokens(genericToken.tokens, callback));
3659          }
3660        }
3661      }
3662    }
3663    return values;
3664  }
3665  use(...args) {
3666    const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
3667    args.forEach((pack) => {
3668      const opts = { ...pack };
3669      opts.async = this.defaults.async || opts.async || false;
3670      if (pack.extensions) {
3671        pack.extensions.forEach((ext) => {
3672          if (!ext.name) {
3673            throw new Error("extension name required");
3674          }
3675          if ("renderer" in ext) {
3676            const prevRenderer = extensions.renderers[ext.name];
3677            if (prevRenderer) {
3678              extensions.renderers[ext.name] = function(...args2) {
3679                let ret = ext.renderer.apply(this, args2);
3680                if (ret === false) {
3681                  ret = prevRenderer.apply(this, args2);
3682                }
3683                return ret;
3684              };
3685            } else {
3686              extensions.renderers[ext.name] = ext.renderer;
3687            }
3688          }
3689          if ("tokenizer" in ext) {
3690            if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
3691              throw new Error("extension level must be 'block' or 'inline'");
3692            }
3693            const extLevel = extensions[ext.level];
3694            if (extLevel) {
3695              extLevel.unshift(ext.tokenizer);
3696            } else {
3697              extensions[ext.level] = [ext.tokenizer];
3698            }
3699            if (ext.start) {
3700              if (ext.level === "block") {
3701                if (extensions.startBlock) {
3702                  extensions.startBlock.push(ext.start);
3703                } else {
3704                  extensions.startBlock = [ext.start];
3705                }
3706              } else if (ext.level === "inline") {
3707                if (extensions.startInline) {
3708                  extensions.startInline.push(ext.start);
3709                } else {
3710                  extensions.startInline = [ext.start];
3711                }
3712              }
3713            }
3714          }
3715          if ("childTokens" in ext && ext.childTokens) {
3716            extensions.childTokens[ext.name] = ext.childTokens;
3717          }
3718        });
3719        opts.extensions = extensions;
3720      }
3721      if (pack.renderer) {
3722        const renderer2 = this.defaults.renderer || new _Renderer(this.defaults);
3723        for (const prop in pack.renderer) {
3724          if (!(prop in renderer2)) {
3725            throw new Error(`renderer '${prop}' does not exist`);
3726          }
3727          if (prop === "options") {
3728            continue;
3729          }
3730          const rendererProp = prop;
3731          const rendererFunc = pack.renderer[rendererProp];
3732          const prevRenderer = renderer2[rendererProp];
3733          renderer2[rendererProp] = (...args2) => {
3734            let ret = rendererFunc.apply(renderer2, args2);
3735            if (ret === false) {
3736              ret = prevRenderer.apply(renderer2, args2);
3737            }
3738            return ret || "";
3739          };
3740        }
3741        opts.renderer = renderer2;
3742      }
3743      if (pack.tokenizer) {
3744        const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
3745        for (const prop in pack.tokenizer) {
3746          if (!(prop in tokenizer)) {
3747            throw new Error(`tokenizer '${prop}' does not exist`);
3748          }
3749          if (["options", "rules", "lexer"].includes(prop)) {
3750            continue;
3751          }
3752          const tokenizerProp = prop;
3753          const tokenizerFunc = pack.tokenizer[tokenizerProp];
3754          const prevTokenizer = tokenizer[tokenizerProp];
3755          tokenizer[tokenizerProp] = (...args2) => {
3756            let ret = tokenizerFunc.apply(tokenizer, args2);
3757            if (ret === false) {
3758              ret = prevTokenizer.apply(tokenizer, args2);
3759            }
3760            return ret;
3761          };
3762        }
3763        opts.tokenizer = tokenizer;
3764      }
3765      if (pack.hooks) {
3766        const hooks = this.defaults.hooks || new _Hooks();
3767        for (const prop in pack.hooks) {
3768          if (!(prop in hooks)) {
3769            throw new Error(`hook '${prop}' does not exist`);
3770          }
3771          if (prop === "options") {
3772            continue;
3773          }
3774          const hooksProp = prop;
3775          const hooksFunc = pack.hooks[hooksProp];
3776          const prevHook = hooks[hooksProp];
3777          if (_Hooks.passThroughHooks.has(prop)) {
3778            hooks[hooksProp] = (arg) => {
3779              if (this.defaults.async) {
3780                return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
3781                  return prevHook.call(hooks, ret2);
3782                });
3783              }
3784              const ret = hooksFunc.call(hooks, arg);
3785              return prevHook.call(hooks, ret);
3786            };
3787          } else {
3788            hooks[hooksProp] = (...args2) => {
3789              let ret = hooksFunc.apply(hooks, args2);
3790              if (ret === false) {
3791                ret = prevHook.apply(hooks, args2);
3792              }
3793              return ret;
3794            };
3795          }
3796        }
3797        opts.hooks = hooks;
3798      }
3799      if (pack.walkTokens) {
3800        const walkTokens = this.defaults.walkTokens;
3801        const packWalktokens = pack.walkTokens;
3802        opts.walkTokens = function(token) {
3803          let values = [];
3804          values.push(packWalktokens.call(this, token));
3805          if (walkTokens) {
3806            values = values.concat(walkTokens.call(this, token));
3807          }
3808          return values;
3809        };
3810      }
3811      this.defaults = { ...this.defaults, ...opts };
3812    });
3813    return this;
3814  }
3815  setOptions(opt) {
3816    this.defaults = { ...this.defaults, ...opt };
3817    return this;
3818  }
3819  lexer(src, options) {
3820    return _Lexer.lex(src, options ?? this.defaults);
3821  }
3822  parser(tokens, options) {
3823    return _Parser.parse(tokens, options ?? this.defaults);
3824  }
3825}
3826_Marked_instances = new WeakSet();
3827parseMarkdown_fn = function(lexer, parser) {
3828  return (src, options) => {
3829    const origOpt = { ...options };
3830    const opt = { ...this.defaults, ...origOpt };
3831    if (this.defaults.async === true && origOpt.async === false) {
3832      if (!opt.silent) {
3833        console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.");
3834      }
3835      opt.async = true;
3836    }
3837    const throwError = __privateMethod(this, _Marked_instances, onError_fn).call(this, !!opt.silent, !!opt.async);
3838    if (typeof src === "undefined" || src === null) {
3839      return throwError(new Error("marked(): input parameter is undefined or null"));
3840    }
3841    if (typeof src !== "string") {
3842      return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
3843    }
3844    if (opt.hooks) {
3845      opt.hooks.options = opt;
3846    }
3847    if (opt.async) {
3848      return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser(tokens, opt)).then((html2) => opt.hooks ? opt.hooks.postprocess(html2) : html2).catch(throwError);
3849    }
3850    try {
3851      if (opt.hooks) {
3852        src = opt.hooks.preprocess(src);
3853      }
3854      let tokens = lexer(src, opt);
3855      if (opt.hooks) {
3856        tokens = opt.hooks.processAllTokens(tokens);
3857      }
3858      if (opt.walkTokens) {
3859        this.walkTokens(tokens, opt.walkTokens);
3860      }
3861      let html2 = parser(tokens, opt);
3862      if (opt.hooks) {
3863        html2 = opt.hooks.postprocess(html2);
3864      }
3865      return html2;
3866    } catch (e) {
3867      return throwError(e);
3868    }
3869  };
3870};
3871onError_fn = function(silent, async) {
3872  return (e) => {
3873    e.message += "\nPlease report this to https://github.com/markedjs/marked.";
3874    if (silent) {
3875      const msg = "<p>An error occurred:</p><pre>" + escape$1$1(e.message + "", true) + "</pre>";
3876      if (async) {
3877        return Promise.resolve(msg);
3878      }
3879      return msg;
3880    }
3881    if (async) {
3882      return Promise.reject(e);
3883    }
3884    throw e;
3885  };
3886};
3887const markedInstance = new Marked();
3888function marked(src, opt) {
3889  return markedInstance.parse(src, opt);
3890}
3891marked.options = marked.setOptions = function(options) {
3892  markedInstance.setOptions(options);
3893  marked.defaults = markedInstance.defaults;
3894  changeDefaults(marked.defaults);
3895  return marked;
3896};
3897marked.getDefaults = _getDefaults;
3898marked.defaults = _defaults;
3899marked.use = function(...args) {
3900  markedInstance.use(...args);
3901  marked.defaults = markedInstance.defaults;
3902  changeDefaults(marked.defaults);
3903  return marked;
3904};
3905marked.walkTokens = function(tokens, callback) {
3906  return markedInstance.walkTokens(tokens, callback);
3907};
3908marked.parseInline = markedInstance.parseInline;
3909marked.Parser = _Parser;
3910marked.parser = _Parser.parse;
3911marked.Renderer = _Renderer;
3912marked.TextRenderer = _TextRenderer;
3913marked.Lexer = _Lexer;
3914marked.lexer = _Lexer.lex;
3915marked.Tokenizer = _Tokenizer;
3916marked.Hooks = _Hooks;
3917marked.parse = marked;
3918marked.options;
3919marked.setOptions;
3920marked.use;
3921marked.walkTokens;
3922marked.parseInline;
3923_Parser.parse;
3924_Lexer.lex;
3925function markedHighlight(options) {
3926  if (typeof options === "function") {
3927    options = {
3928      highlight: options
3929    };
3930  }
3931  if (!options || typeof options.highlight !== "function") {
3932    throw new Error("Must provide highlight function");
3933  }
3934  if (typeof options.langPrefix !== "string") {
3935    options.langPrefix = "language-";
3936  }
3937  if (typeof options.emptyLangClass !== "string") {
3938    options.emptyLangClass = "";
3939  }
3940  return {
3941    async: !!options.async,
3942    walkTokens(token) {
3943      if (token.type !== "code") {
3944        return;
3945      }
3946      const lang = getLang(token.lang);
3947      if (options.async) {
3948        return Promise.resolve(options.highlight(token.text, lang, token.lang || "")).then(updateToken(token));
3949      }
3950      const code = options.highlight(token.text, lang, token.lang || "");
3951      if (code instanceof Promise) {
3952        throw new Error("markedHighlight is not set to async but the highlight function is async. Set the async option to true on markedHighlight to await the async highlight function.");
3953      }
3954      updateToken(token)(code);
3955    },
3956    useNewRenderer: true,
3957    renderer: {
3958      code(code, infoString, escaped) {
3959        if (typeof code === "object") {
3960          escaped = code.escaped;
3961          infoString = code.lang;
3962          code = code.text;
3963        }
3964        const lang = getLang(infoString);
3965        const classValue = lang ? options.langPrefix + escape$1(lang) : options.emptyLangClass;
3966        const classAttr = classValue ? ` class="${classValue}"` : "";
3967        code = code.replace(/\n$/, "");
3968        return `<pre><code${classAttr}>${escaped ? code : escape$1(code, true)}
3969</code></pre>`;
3970      }
3971    }
3972  };
3973}
3974function getLang(lang) {
3975  return (lang || "").match(/\S*/)[0];
3976}
3977function updateToken(token) {
3978  return (code) => {
3979    if (typeof code === "string" && code !== token.text) {
3980      token.escaped = true;
3981      token.text = code;
3982    }
3983  };
3984}
3985const escapeTest = /[&<>"']/;
3986const escapeReplace = new RegExp(escapeTest.source, "g");
3987const escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
3988const escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
3989const escapeReplacements = {
3990  "&": "&amp;",
3991  "<": "&lt;",
3992  ">": "&gt;",
3993  '"': "&quot;",
3994  "'": "&#39;"
3995};
3996const getEscapeReplacement = (ch) => escapeReplacements[ch];
3997function escape$1(html2, encode) {
3998  if (encode) {
3999    if (escapeTest.test(html2)) {
4000      return html2.replace(escapeReplace, getEscapeReplacement);
4001    }
4002  } else {
4003    if (escapeTestNoEncode.test(html2)) {
4004      return html2.replace(escapeReplaceNoEncode, getEscapeReplacement);
4005    }
4006  }
4007  return html2;
4008}
4009const regex = /[\0-\x1F!-,\.\/:-@\[-\^`\{-\xA9\xAB-\xB4\xB6-\xB9\xBB-\xBF\xD7\xF7\u02C2-\u02C5\u02D2-\u02DF\u02E5-\u02EB\u02ED\u02EF-\u02FF\u0375\u0378\u0379\u037E\u0380-\u0385\u0387\u038B\u038D\u03A2\u03F6\u0482\u0530\u0557\u0558\u055A-\u055F\u0589-\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05EB-\u05EE\u05F3-\u060F\u061B-\u061F\u066A-\u066D\u06D4\u06DD\u06DE\u06E9\u06FD\u06FE\u0700-\u070F\u074B\u074C\u07B2-\u07BF\u07F6-\u07F9\u07FB\u07FC\u07FE\u07FF\u082E-\u083F\u085C-\u085F\u086B-\u089F\u08B5\u08C8-\u08D2\u08E2\u0964\u0965\u0970\u0984\u098D\u098E\u0991\u0992\u09A9\u09B1\u09B3-\u09B5\u09BA\u09BB\u09C5\u09C6\u09C9\u09CA\u09CF-\u09D6\u09D8-\u09DB\u09DE\u09E4\u09E5\u09F2-\u09FB\u09FD\u09FF\u0A00\u0A04\u0A0B-\u0A0E\u0A11\u0A12\u0A29\u0A31\u0A34\u0A37\u0A3A\u0A3B\u0A3D\u0A43-\u0A46\u0A49\u0A4A\u0A4E-\u0A50\u0A52-\u0A58\u0A5D\u0A5F-\u0A65\u0A76-\u0A80\u0A84\u0A8E\u0A92\u0AA9\u0AB1\u0AB4\u0ABA\u0ABB\u0AC6\u0ACA\u0ACE\u0ACF\u0AD1-\u0ADF\u0AE4\u0AE5\u0AF0-\u0AF8\u0B00\u0B04\u0B0D\u0B0E\u0B11\u0B12\u0B29\u0B31\u0B34\u0B3A\u0B3B\u0B45\u0B46\u0B49\u0B4A\u0B4E-\u0B54\u0B58-\u0B5B\u0B5E\u0B64\u0B65\u0B70\u0B72-\u0B81\u0B84\u0B8B-\u0B8D\u0B91\u0B96-\u0B98\u0B9B\u0B9D\u0BA0-\u0BA2\u0BA5-\u0BA7\u0BAB-\u0BAD\u0BBA-\u0BBD\u0BC3-\u0BC5\u0BC9\u0BCE\u0BCF\u0BD1-\u0BD6\u0BD8-\u0BE5\u0BF0-\u0BFF\u0C0D\u0C11\u0C29\u0C3A-\u0C3C\u0C45\u0C49\u0C4E-\u0C54\u0C57\u0C5B-\u0C5F\u0C64\u0C65\u0C70-\u0C7F\u0C84\u0C8D\u0C91\u0CA9\u0CB4\u0CBA\u0CBB\u0CC5\u0CC9\u0CCE-\u0CD4\u0CD7-\u0CDD\u0CDF\u0CE4\u0CE5\u0CF0\u0CF3-\u0CFF\u0D0D\u0D11\u0D45\u0D49\u0D4F-\u0D53\u0D58-\u0D5E\u0D64\u0D65\u0D70-\u0D79\u0D80\u0D84\u0D97-\u0D99\u0DB2\u0DBC\u0DBE\u0DBF\u0DC7-\u0DC9\u0DCB-\u0DCE\u0DD5\u0DD7\u0DE0-\u0DE5\u0DF0\u0DF1\u0DF4-\u0E00\u0E3B-\u0E3F\u0E4F\u0E5A-\u0E80\u0E83\u0E85\u0E8B\u0EA4\u0EA6\u0EBE\u0EBF\u0EC5\u0EC7\u0ECE\u0ECF\u0EDA\u0EDB\u0EE0-\u0EFF\u0F01-\u0F17\u0F1A-\u0F1F\u0F2A-\u0F34\u0F36\u0F38\u
40090F3A-\u0F3D\u0F48\u0F6D-\u0F70\u0F85\u0F98\u0FBD-\u0FC5\u0FC7-\u0FFF\u104A-\u104F\u109E\u109F\u10C6\u10C8-\u10CC\u10CE\u10CF\u10FB\u1249\u124E\u124F\u1257\u1259\u125E\u125F\u1289\u128E\u128F\u12B1\u12B6\u12B7\u12BF\u12C1\u12C6\u12C7\u12D7\u1311\u1316\u1317\u135B\u135C\u1360-\u137F\u1390-\u139F\u13F6\u13F7\u13FE-\u1400\u166D\u166E\u1680\u169B-\u169F\u16EB-\u16ED\u16F9-\u16FF\u170D\u1715-\u171F\u1735-\u173F\u1754-\u175F\u176D\u1771\u1774-\u177F\u17D4-\u17D6\u17D8-\u17DB\u17DE\u17DF\u17EA-\u180A\u180E\u180F\u181A-\u181F\u1879-\u187F\u18AB-\u18AF\u18F6-\u18FF\u191F\u192C-\u192F\u193C-\u1945\u196E\u196F\u1975-\u197F\u19AC-\u19AF\u19CA-\u19CF\u19DA-\u19FF\u1A1C-\u1A1F\u1A5F\u1A7D\u1A7E\u1A8A-\u1A8F\u1A9A-\u1AA6\u1AA8-\u1AAF\u1AC1-\u1AFF\u1B4C-\u1B4F\u1B5A-\u1B6A\u1B74-\u1B7F\u1BF4-\u1BFF\u1C38-\u1C3F\u1C4A-\u1C4C\u1C7E\u1C7F\u1C89-\u1C8F\u1CBB\u1CBC\u1CC0-\u1CCF\u1CD3\u1CFB-\u1CFF\u1DFA\u1F16\u1F17\u1F1E\u1F1F\u1F46\u1F47\u1F4E\u1F4F\u1F58\u1F5A\u1F5C\u1F5E\u1F7E\u1F7F\u1FB5\u1FBD\u1FBF-\u1FC1\u1FC5\u1FCD-\u1FCF\u1FD4\u1FD5\u1FDC-\u1FDF\u1FED-\u1FF1\u1FF5\u1FFD-\u203E\u2041-\u2053\u2055-\u2070\u2072-\u207E\u2080-\u208F\u209D-\u20CF\u20F1-\u2101\u2103-\u2106\u2108\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A\u213B\u2140-\u2144\u214A-\u214D\u214F-\u215F\u2189-\u24B5\u24EA-\u2BFF\u2C2F\u2C5F\u2CE5-\u2CEA\u2CF4-\u2CFF\u2D26\u2D28-\u2D2C\u2D2E\u2D2F\u2D68-\u2D6E\u2D70-\u2D7E\u2D97-\u2D9F\u2DA7\u2DAF\u2DB7\u2DBF\u2DC7\u2DCF\u2DD7\u2DDF\u2E00-\u2E2E\u2E30-\u3004\u3008-\u3020\u3030\u3036\u3037\u303D-\u3040\u3097\u3098\u309B\u309C\u30A0\u30FB\u3100-\u3104\u3130\u318F-\u319F\u31C0-\u31EF\u3200-\u33FF\u4DC0-\u4DFF\u9FFD-\u9FFF\uA48D-\uA4CF\uA4FE\uA4FF\uA60D-\uA60F\uA62C-\uA63F\uA673\uA67E\uA6F2-\uA716\uA720\uA721\uA789\uA78A\uA7C0\uA7C1\uA7CB-\uA7F4\uA828-\uA82B\uA82D-\uA83F\uA874-\uA87F\uA8C6-\uA8CF\uA8DA-\uA8DF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA954-\uA95F\uA97D-\uA97F\uA9C1-\uA9CE\uA9DA-\uA9DF\uA9FF\uAA37-\uAA3F\uAA4E\uAA4F\uAA5A-\uAA5F\uAA77-\uAA79\uAAC3-\uAADA\uAADE\uAADF\uAAF0\uAAF1\uAAF7-\uAB00\uAB07\uAB08\uAB0F\uAB10\uAB17-\uAB1F\uAB27\uAB2F\uAB5B\uAB6A-\uAB6F\uABEB\uABEE\uABEF\uABFA-\uABFF\uD7A4-\uD7AF\uD7C7-\uD7CA\uD7FC-\uD7FF\uE000-\uF8FF\uFA6E\uFA6F\uFADA-\uFAFF\uFB07-\uFB12\uFB18-\uFB1C\uFB29\uFB37\uFB3D\uFB3F\uFB42\uFB45\uFBB2-\uFBD2\uFD3E-\uFD4F\uFD90\uFD91\uFDC8-\uFDEF\uFDFC-\uFDFF\uFE10-\uFE1F\uFE30-\uFE32\uFE35-\uFE4C\uFE50-\uFE6F\uFE75\uFEFD-\uFF0F\uFF1A-\uFF20\uFF3B-\uFF3E\uFF40\uFF5B-\uFF65\uFFBF-\uFFC1\uFFC8\uFFC9\uFFD0\uFFD1\uFFD8\uFFD9\uFFDD-\uFFFF]|\uD800[\uDC0C\uDC27\uDC3B\uDC3E\uDC4E\uDC4F\uDC5E-\uDC7F\uDCFB-\uDD3F\uDD75-\uDDFC\uDDFE-\uDE7F\uDE9D-\uDE9F\uDED1-\uDEDF\uDEE1-\uDEFF\uDF20-\uDF2C\uDF4B-\uDF4F\uDF7B-\uDF7F\uDF9E\uDF9F\uDFC4-\uDFC7\uDFD0\uDFD6-\uDFFF]|\uD801[\uDC9E\uDC9F\uDCAA-\uDCAF\uDCD4-\uDCD7\uDCFC-\uDCFF\uDD28-\uDD2F\uDD64-\uDDFF\uDF37-\uDF3F\uDF56-\uDF5F\uDF68-\uDFFF]|\uD802[\uDC06\uDC07\uDC09\uDC36\uDC39-\uDC3B\uDC3D\uDC3E\uDC56-\uDC5F\uDC77-\uDC7F\uDC9F-\uDCDF\uDCF3\uDCF6-\uDCFF\uDD16-\uDD1F\uDD3A-\uDD7F\uDDB8-\uDDBD\uDDC0-\uDDFF\uDE04\uDE07-\uDE0B\uDE14\uDE18\uDE36\uDE37\uDE3B-\uDE3E\uDE40-\uDE5F\uDE7D-\uDE7F\uDE9D-\uDEBF\uDEC8\uDEE7-\uDEFF\uDF36-\uDF3F\uDF56-\uDF5F\uDF73-\uDF7F\uDF92-\uDFFF]|\uD803[\uDC49-\uDC7F\uDCB3-\uDCBF\uDCF3-\uDCFF\uDD28-\uDD2F\uDD3A-\uDE7F\uDEAA\uDEAD-\uDEAF\uDEB2-\uDEFF\uDF1D-\uDF26\uDF28-\uDF2F\uDF51-\uDFAF\uDFC5-\uDFDF\uDFF7-\uDFFF]|\uD804[\uDC47-\uDC65\uDC70-\uDC7E\uDCBB-\uDCCF\uDCE9-\uDCEF\uDCFA-\uDCFF\uDD35\uDD40-\uDD43\uDD48-\uDD4F\uDD74\uDD75\uDD77-\uDD7F\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDFF\uDE12\uDE38-\uDE3D\uDE3F-\uDE7F\uDE87\uDE89\uDE8E\uDE9E\uDEA9-\uDEAF\uDEEB-\uDEEF\uDEFA-\uDEFF\uDF04\uDF0D\uDF0E\uDF11\uDF12\uDF29\uDF31\uDF34\uDF3A\uDF45\uDF46\uDF49\uDF4A\uDF4E\uDF4F\uDF51-\uDF56\uDF58-\uDF5C\uDF64\uDF65\uDF6D-\uDF6F\uDF75-\uDFFF]|\uD805[\uDC4B-\uDC4F\uDC5A-\uDC5D\uDC62-\uDC7F\uDCC6\uDCC8-\uDCCF\uDCDA-\uDD7F\uDDB6\uDDB7\uDDC1-\uDDD7\uDDDE-\uDDFF\uDE41-\uDE43\uDE45-\uDE4F\uDE5A-\uDE7F\uDEB9-\uDEBF\uDECA-\uDEFF\uDF1B\uDF1C\uDF2C-\uDF2F\uDF3A-\uDFFF]|\uD806[\uDC3B-\uDC9F\uDCEA-\uDCFE\uDD07\uDD08\uDD0A\uDD0B\uDD14\uDD17\uDD36\uDD39\uDD3A\uDD44-\uDD4F\uDD5A-\uDD9F\uDDA8\uDDA9\uDDD8\uDDD9\uDDE2\uDDE5-\uDDFF\uDE3F-\uDE46\uDE48-\uDE4F\uDE9A-\uDE9C\uDE9E-\uDEBF\uDEF9-\uDFFF]|\uD807[\uDC09\uDC37\uDC41-\uDC4F\uDC5A-\uDC71\uDC90\uDC91\uDCA8\uDCB7-\uDCFF\uDD07\uDD0A\uDD37-\uDD39\uDD3B\uDD3E\uDD48-\uDD4F\uDD5A-\uDD5F\uDD66\uDD69\uDD8F\uDD92\uDD99-\uDD9F\uDDAA-\uDEDF\uDEF7-\uDFAF\uDFB1-\uDFFF]|\uD808[\uDF9A-\uDFFF]|\uD809[\uDC6F-\uDC7F\uDD44-\uDFFF]|[\uD80A\uD80B\uD80E-\uD810\uD812-\uD819\uD824-\uD82B\uD82D\uD82E\uD830-\uD833\uD837\uD839\uD83D\uD83F\uD87B-\uD87D\uD87F\uD885-\uDB3F\uDB41-\uDBFF][\uDC00-\uDFFF]|\uD80D[\uDC2F-\uDFFF]|\uD811[\uDE47-\uDFFF]|\uD81A[\uDE39-\uDE3F\uDE5F\uDE6A-\uDECF\uDEEE\uDEEF\uDEF5-\uDEFF\uDF37-\uDF3F\uDF44-\uDF4F\uDF5A-\uDF62\uDF78-\uDF7C\uDF90-\uDFFF]|\uD81B[\uDC00-\uDE3F\uDE80-\uDEFF\uDF4B-\uDF4E\uDF88-\uDF8E\uDFA0-\uDFDF\uDFE2\uDFE5-\uDFEF\uDFF2-\uDFFF]|\uD821[\uDFF8-\uDFFF]|\uD823[\uDCD6-\uDCFF\uDD09-\uDFFF]|\uD82C[\uDD1F-\uDD4F\uDD53-\uDD63\uDD68-\uDD6F\uDEFC-\uDFFF]|\uD82F[\uDC6B-\uDC6F\uDC7D-\uDC7F\uDC89-\uDC8F\uDC9A-\uDC9C\uDC9F-\uDFFF]|\uD834[\uDC00-\uDD64\uDD6A-\uDD6C\uDD73-\uDD7A\uDD83\uDD84\uDD8C-\uDDA9\uDDAE-\uDE41\uDE45-\uDFFF]|\uD835[\uDC55\uDC9D\uDCA0\uDCA1\uDCA3\uDCA4\uDCA7\uDCA8\uDCAD\uDCBA\uDCBC\uDCC4\uDD06\uDD0B\uDD0C\uDD15\uDD1D\uDD3A\uDD3F\uDD45\uDD47-\uDD49\uDD51\uDEA6\uDEA7\uDEC1\uDEDB\uDEFB\uDF15\uDF35\uDF4F\uDF6F\uDF89\uDFA9\uDFC3\uDFCC\uDFCD]|\uD836[\uDC00-\uDDFF\uDE37-\uDE3A\uDE6D-\uDE74\uDE76-\uDE83\uDE85-\uDE9A\uDEA0\uDEB0-\uDFFF]|\uD838[\uDC07\uDC19\uDC1A\uDC22\uDC25\uDC2B-\uDCFF\uDD2D-\uDD2F\uDD3E\uDD3F\uDD4A-\uDD4D\uDD4F-\uDEBF\uDEFA-\uDFFF]|\uD83A[\uDCC5-\uDCCF\uDCD7-\uDCFF\uDD4C-\uDD4F\uDD5A-\uDFFF]|\uD83B[\uDC00-\uDDFF\uDE04\uDE20\uDE23\uDE25\uDE26\uDE28\uDE33\uDE38\uDE3A\uDE3C-\uDE41\uDE43-\uDE46\uDE48\uDE4A\uDE4C\uDE50\uDE53\uDE55\uDE56\uDE58\uDE5A\uDE5C\uDE5E\uDE60\uDE63\uDE65\uDE66\uDE6B\uDE73\uDE78\uDE7D\uDE7F\uDE8A\uDE9C-\uDEA0\uDEA4\uDEAA\uDEBC-\uDFFF]|\uD83C[\uDC00-\uDD2F\uDD4A-\uDD4F\uDD6A-\uDD6F\uDD8A-\uDFFF]|\uD83E[\uDC00-\uDFEF\uDFFA-\uDFFF]|\uD869[\uDEDE-\uDEFF]|\uD86D[\uDF35-\uDF3F]|\uD86E[\uDC1E\uDC1F]|\uD873[\uDEA2-\uDEAF]|\uD87A[\uDFE1-\uDFFF]|\uD87E[\uDE1E-\uDFFF]|\uD884[\uDF4B-\uDFFF]|\uDB40[\uDC00-\uDCFF\uDDF0-\uDFFF]/g;
4010const own = Object.hasOwnProperty;
4011class BananaSlug {
4012  /**
4013   * Create a new slug class.
4014   */
4015  constructor() {
4016    this.occurrences;
4017    this.reset();
4018  }
4019  /**
4020   * Generate a unique slug.
4021  *
4022  * Tracks previously generated slugs: repeated calls with the same value
4023  * will result in different slugs.
4024  * Use the `slug` function to get same slugs.
4025   *
4026   * @param  {string} value
4027   *   String of text to slugify
4028   * @param  {boolean} [maintainCase=false]
4029   *   Keep the current case, otherwise make all lowercase
4030   * @return {string}
4031   *   A unique slug string
4032   */
4033  slug(value, maintainCase) {
4034    const self2 = this;
4035    let result = slug(value, maintainCase === true);
4036    const originalSlug = result;
4037    while (own.call(self2.occurrences, result)) {
4038      self2.occurrences[originalSlug]++;
4039      result = originalSlug + "-" + self2.occurrences[originalSlug];
4040    }
4041    self2.occurrences[result] = 0;
4042    return result;
4043  }
4044  /**
4045   * Reset - Forget all previous slugs
4046   *
4047   * @return void
4048   */
4049  reset() {
4050    this.occurrences = /* @__PURE__ */ Object.create(null);
4051  }
4052}
4053function slug(value, maintainCase) {
4054  if (typeof value !== "string") return "";
4055  if (!maintainCase) value = value.toLowerCase();
4056  return value.replace(regex, "").replace(/ /g, "-");
4057}
4058let slugger$1 = new BananaSlug();
4059let headings = [];
4060function gfmHeadingId({ prefix = "", globalSlugs = false } = {}) {
4061  return {
4062    headerIds: false,
4063    // prevent deprecation warning; remove this once headerIds option is removed
4064    hooks: {
4065      preprocess(src) {
4066        if (!globalSlugs) {
4067          resetHeadings();
4068        }
4069        return src;
4070      }
4071    },
4072    renderer: {
4073      heading(text2, level, raw) {
4074        raw = raw.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi, "");
4075        const id = `${prefix}${slugger$1.slug(raw)}`;
4076        const heading2 = { level, text: text2, id };
4077        headings.push(heading2);
4078        return `<h${level} id="${id}">${text2}</h${level}>
4079`;
4080      }
4081    }
4082  };
4083}
4084function resetHeadings() {
4085  headings = [];
4086  slugger$1 = new BananaSlug();
4087}
vendor: 8,412 bytes, lines 4088-4319
4088var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
4089function getDefaultExportFromCjs(x) {
4090  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
4091}
4092var prism = { exports: {} };
4093(function(module) {
4094  var _self = typeof window !== "undefined" ? window : typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope ? self : {};
4095  /**
4096   * Prism: Lightweight, robust, elegant syntax highlighting
4097   *
4098   * @license MIT <https://opensource.org/licenses/MIT>
4099   * @author Lea Verou <https://lea.verou.me>
4100   * @namespace
4101   * @public
4102   */
4103  var Prism2 = function(_self2) {
4104    var lang = /(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i;
4105    var uniqueId = 0;
4106    var plainTextGrammar = {};
4107    var _ = {
4108      /**
4109       * By default, Prism will attempt to highlight all code elements (by calling {@link Prism.highlightAll}) on the
4110       * current page after the page finished loading. This might be a problem if e.g. you wanted to asynchronously load
4111       * additional languages or plugins yourself.
4112       *
4113       * By setting this value to `true`, Prism will not automatically highlight all code elements on the page.
4114       *
4115       * You obviously have to change this value before the automatic highlighting started. To do this, you can add an
4116       * empty Prism object into the global scope before loading the Prism script like this:
4117       *
4118       * ```js
4119       * window.Prism = window.Prism || {};
4120       * Prism.manual = true;
4121       * // add a new <script> to load Prism's script
4122       * ```
4123       *
4124       * @default false
4125       * @type {boolean}
4126       * @memberof Prism
4127       * @public
4128       */
4129      manual: _self2.Prism && _self2.Prism.manual,
4130      /**
4131       * By default, if Prism is in a web worker, it assumes that it is in a worker it created itself, so it uses
4132       * `addEventListener` to communicate with its parent instance. However, if you're using Prism manually in your
4133       * own worker, you don't want it to do this.
4134       *
4135       * By setting this value to `true`, Prism will not add its own listeners to the worker.
4136       *
4137       * You obviously have to change this value before Prism executes. To do this, you can add an
4138       * empty Prism object into the global scope before loading the Prism script like this:
4139       *
4140       * ```js
4141       * window.Prism = window.Prism || {};
4142       * Prism.disableWorkerMessageHandler = true;
4143       * // Load Prism's script
4144       * ```
4145       *
4146       * @default false
4147       * @type {boolean}
4148       * @memberof Prism
4149       * @public
4150       */
4151      disableWorkerMessageHandler: _self2.Prism && _self2.Prism.disableWorkerMessageHandler,
4152      /**
4153       * A namespace for utility methods.
4154       *
4155       * All function in this namespace that are not explicitly marked as _public_ are for __internal use only__ and may
4156       * change or disappear at any time.
4157       *
4158       * @namespace
4159       * @memberof Prism
4160       */
4161      util: {
4162        encode: function encode(tokens) {
4163          if (tokens instanceof Token) {
4164            return new Token(tokens.type, encode(tokens.content), tokens.alias);
4165          } else if (Array.isArray(tokens)) {
4166            return tokens.map(encode);
4167          } else {
4168            return tokens.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/\u00a0/g, " ");
4169          }
4170        },
4171        /**
4172         * Returns the name of the type of the given value.
4173         *
4174         * @param {any} o
4175         * @returns {string}
4176         * @example
4177         * type(null)      === 'Null'
4178         * type(undefined) === 'Undefined'
4179         * type(123)       === 'Number'
4180         * type('foo')     === 'String'
4181         * type(true)      === 'Boolean'
4182         * type([1, 2])    === 'Array'
4183         * type({})        === 'Object'
4184         * type(String)    === 'Function'
4185         * type(/abc+/)    === 'RegExp'
4186         */
4187        type: function(o) {
4188          return Object.prototype.toString.call(o).slice(8, -1);
4189        },
4190        /**
4191         * Returns a unique number for the given object. Later calls will still return the same number.
4192         *
4193         * @param {Object} obj
4194         * @returns {number}
4195         */
4196        objId: function(obj) {
4197          if (!obj["__id"]) {
4198            Object.defineProperty(obj, "__id", { value: ++uniqueId });
4199          }
4200          return obj["__id"];
4201        },
4202        /**
4203         * Creates a deep clone of the given object.
4204         *
4205         * The main intended use of this function is to clone language definitions.
4206         *
4207         * @param {T} o
4208         * @param {Record<number, any>} [visited]
4209         * @returns {T}
4210         * @template T
4211         */
4212        clone: function deepClone(o, visited) {
4213          visited = visited || {};
4214          var clone;
4215          var id;
4216          switch (_.util.type(o)) {
4217            case "Object":
4218              id = _.util.objId(o);
4219              if (visited[id]) {
4220                return visited[id];
4221              }
4222              clone = /** @type {Record<string, any>} */
4223              {};
4224              visited[id] = clone;
4225              for (var key in o) {
4226                if (o.hasOwnProperty(key)) {
4227                  clone[key] = deepClone(o[key], visited);
4228                }
4229              }
4230              return (
4231                /** @type {any} */
4232                clone
4233              );
4234            case "Array":
4235              id = _.util.objId(o);
4236              if (visited[id]) {
4237                return visited[id];
4238              }
4239              clone = [];
4240              visited[id] = clone;
4241              /** @type {Array} */
4242              /** @type {any} */
4243              o.forEach(function(v, i) {
4244                clone[i] = deepClone(v, visited);
4245              });
4246              return (
4247                /** @type {any} */
4248                clone
4249              );
4250            default:
4251              return o;
4252          }
4253        },
4254        /**
4255         * Returns the Prism language of the given element set by a `language-xxxx` or `lang-xxxx` class.
4256         *
4257         * If no language is set for the element or the element is `null` or `undefined`, `none` will be returned.
4258         *
4259         * @param {Element} element
4260         * @returns {string}
4261         */
4262        getLanguage: function(element2) {
4263          while (element2) {
4264            var m = lang.exec(element2.className);
4265            if (m) {
4266              return m[1].toLowerCase();
4267            }
4268            element2 = element2.parentElement;
4269          }
4270          return "none";
4271        },
4272        /**
4273         * Sets the Prism `language-xxxx` class of the given element.
4274         *
4275         * @param {Element} element
4276         * @param {string} language
4277         * @returns {void}
4278         */
4279        setLanguage: function(element2, language) {
4280          element2.className = element2.className.replace(RegExp(lang, "gi"), "");
4281          element2.classList.add("language-" + language);
4282        },
4283        /**
4284         * Returns the script element that is currently executing.
4285         *
4286         * This does __not__ work for line script element.
4287         *
4288         * @returns {HTMLScriptElement | null}
4289         */
4290        currentScript: function() {
4291          if (typeof document === "undefined") {
4292            return null;
4293          }
4294          if (document.currentScript && document.currentScript.tagName === "SCRIPT" && 1 < 2) {
4295            return (
4296              /** @type {any} */
4297              document.currentScript
4298            );
4299          }
4300          try {
4301            throw new Error();
4302          } catch (err) {
4303            var src = (/at [^(\r\n]*\((.*):[^:]+:[^:]+\)$/i.exec(err.stack) || [])[1];
4304            if (src) {
4305              var scripts = document.getElementsByTagName("script");
4306              for (var i in scripts) {
4307                if (scripts[i].src == src) {
4308                  return scripts[i];
4309                }
4310              }
4311            }
4312            return null;
4313          }
4314        },
4315        /**
4316         * Returns whether a given class is active for `element`.
4317         *
4318         * The class can be activated if `element` or one of its ancestors has the given class and it can be deactivated
4319         * if `element` or one of its ancestors has the negated ver
4319sion of the given class. The _negated version_ of the
4320         * given class is just the given class with a `no-` prefix.
4321         *
4322         * Whether the class is active is determined by the closest ancestor of `element` (where `element` itself is
4323         * closest ancestor) that has the given class or the negated version of it. If neither `element` nor any of its
4324         * ancestors have the given class or the negated version of it, then the default activation will be returned.
4325         *
4326         * In the paradoxical situation where the closest ancestor contains __both__ the given class and the negated
4327         * version of it, the class is considered active.
4328         *
4329         * @param {Element} element
4330         * @param {string} className
4331         * @param {boolean} [defaultActivation=false]
4332         * @returns {boolean}
4333         */
4334        isActive: function(element2, className, defaultActivation) {
4335          var no = "no-" + className;
4336          while (element2) {
4337            var classList = element2.classList;
4338            if (classList.contains(className)) {
4339              return true;
4340            }
4341            if (classList.contains(no)) {
4342              return false;
4343            }
4344            element2 = element2.parentElement;
4345          }
4346          return !!defaultActivation;
4347        }
4348      },
4349      /**
4350       * This namespace contains all currently loaded languages and the some helper functions to create and modify languages.
4351       *
4352       * @namespace
4353       * @memberof Prism
4354       * @public
4355       */
4356      languages: {
4357        /**
4358         * The grammar for plain, unformatted text.
4359         */
4360        plain: plainTextGrammar,
4361        plaintext: plainTextGrammar,
4362        text: plainTextGrammar,
4363        txt: plainTextGrammar,
4364        /**
4365         * Creates a deep copy of the language with the given id and appends the given tokens.
4366         *
4367         * If a token in `redef` also appears in the copied language, then the existing token in the copied language
4368         * will be overwritten at its original position.
4369         *
4370         * ## Best practices
4371         *
4372         * Since the position of overwriting tokens (token in `redef` that overwrite tokens in the copied language)
4373         * doesn't matter, they can technically be in any order. However, this can be confusing to others that trying to
4374         * understand the language definition because, normally, the order of tokens matters in Prism grammars.
4375         *
4376         * Therefore, it is encouraged to order overwriting tokens according to the positions of the overwritten tokens.
4377         * Furthermore, all non-overwriting tokens should be placed after the overwriting ones.
4378         *
4379         * @param {string} id The id of the language to extend. This has to be a key in `Prism.languages`.
4380         * @param {Grammar} redef The new tokens to append.
4381         * @returns {Grammar} The new language created.
4382         * @public
4383         * @example
4384         * Prism.languages['css-with-colors'] = Prism.languages.extend('css', {
4385         *     // Prism.languages.css already has a 'comment' token, so this token will overwrite CSS' 'comment' token
4386         *     // at its original position
4387         *     'comment': { ... },
4388         *     // CSS doesn't have a 'color' token, so this token will be appended
4389         *     'color': /\b(?:red|green|blue)\b/
4390         * });
4391         */
4392        extend: function(id, redef) {
4393          var lang2 = _.util.clone(_.languages[id]);
4394          for (var key in redef) {
4395            lang2[key] = redef[key];
4396          }
4397          return lang2;
4398        },
4399        /**
4400         * Inserts tokens _before_ another token in a language definition or any other grammar.
4401         *
4402         * ## Usage
4403         *
4404         * This helper method makes it easy to modify existing languages. For example, the CSS language definition
4405         * not only defines CSS highlighting for CSS documents, but also needs to define highlighting for CSS embedded
4406         * in HTML through `<style>` elements. To do this, it needs to modify `Prism.languages.markup` and add the
4407         * appropriate tokens. However, `Prism.languages.markup` is a regular JavaScript object literal, so if you do
4408         * this:
4409         *
4410         * ```js
4411         * Prism.languages.markup.style = {
4412         *     // token
4413         * };
4414         * ```
4415         *
4416         * then the `style` token will be added (and processed) at the end. `insertBefore` allows you to insert tokens
4417         * before existing tokens. For the CSS example above, you would use it like this:
4418         *
4419         * ```js
4420         * Prism.languages.insertBefore('markup', 'cdata', {
4421         *     'style': {
4422         *         // token
4423         *     }
4424         * });
4425         * ```
4426         *
4427         * ## Special cases
4428         *
4429         * If the grammars of `inside` and `insert` have tokens with the same name, the tokens in `inside`'s grammar
4430         * will be ignored.
4431         *
4432         * This behavior can be used to insert tokens after `before`:
4433         *
4434         * ```js
4435         * Prism.languages.insertBefore('markup', 'comment', {
4436         *     'comment': Prism.languages.markup.comment,
4437         *     // tokens after 'comment'
4438         * });
4439         * ```
4440         *
4441         * ## Limitations
4442         *
4443         * The main problem `insertBefore` has to solve is iteration order. Since ES2015, the iteration order for object
4444         * properties is guaranteed to be the insertion order (except for integer keys) but some browsers behave
4445         * differently when keys are deleted and re-inserted. So `insertBefore` can't be implemented by temporarily
4446         * deleting properties which is necessary to insert at arbitrary positions.
4447         *
4448         * To solve this problem, `insertBefore` doesn't actually insert the given tokens into the target object.
4449         * Instead, it will create a new object and replace all references to the target object with the new one. This
4450         * can be done without temporarily deleting properties, so the iteration order is well-defined.
4451         *
4452         * However, only references that can be reached from `Prism.languages` or `insert` will be replaced. I.e. if
4453         * you hold the target object in a variable, then the value of the variable will not change.
4454         *
4455         * ```js
4456         * var oldMarkup = Prism.languages.markup;
4457         * var newMarkup = Prism.languages.insertBefore('markup', 'comment', { ... });
4458         *
4459         * assert(oldMarkup !== Prism.languages.markup);
4460         * assert(newMarkup === Prism.languages.markup);
4461         * ```
4462         *
4463         * @param {string} inside The property of `root` (e.g. a language id in `Prism.languages`) that contains the
4464         * object to be modified.
4465         * @param {string} before The key to insert before.
4466         * @param {Grammar}
4466 insert An object containing the key-value pairs to be inserted.
4467         * @param {Object<string, any>} [root] The object containing `inside`, i.e. the object that contains the
4468         * object to be modified.
4469         *
4470         * Defaults to `Prism.languages`.
4471         * @returns {Grammar} The new grammar object.
4472         * @public
4473         */
4474        insertBefore: function(inside, before, insert2, root) {
4475          root = root || /** @type {any} */
4476          _.languages;
4477          var grammar = root[inside];
4478          var ret = {};
4479          for (var token in grammar) {
4480            if (grammar.hasOwnProperty(token)) {
4481              if (token == before) {
4482                for (var newToken in insert2) {
4483                  if (insert2.hasOwnProperty(newToken)) {
4484                    ret[newToken] = insert2[newToken];
4485                  }
4486                }
4487              }
4488              if (!insert2.hasOwnProperty(token)) {
4489                ret[token] = grammar[token];
4490              }
4491            }
4492          }
4493          var old = root[inside];
4494          root[inside] = ret;
4495          _.languages.DFS(_.languages, function(key, value) {
4496            if (value === old && key != inside) {
4497              this[key] = ret;
4498            }
4499          });
4500          return ret;
4501        },
4502        // Traverse a language definition with Depth First Search
4503        DFS: function DFS(o, callback, type, visited) {
4504          visited = visited || {};
4505          var objId = _.util.objId;
4506          for (var i in o) {
4507            if (o.hasOwnProperty(i)) {
4508              callback.call(o, i, o[i], type || i);
4509              var property = o[i];
4510              var propertyType = _.util.type(property);
4511              if (propertyType === "Object" && !visited[objId(property)]) {
4512                visited[objId(property)] = true;
4513                DFS(property, callback, null, visited);
4514              } else if (propertyType === "Array" && !visited[objId(property)]) {
4515                visited[objId(property)] = true;
4516                DFS(property, callback, i, visited);
4517              }
4518            }
4519          }
4520        }
4521      },
4522      plugins: {},
4523      /**
4524       * This is the most high-level function in Prism’s API.
4525       * It fetches all the elements that have a `.language-xxxx` class and then calls {@link Prism.highlightElement} on
4526       * each one of them.
4527       *
4528       * This is equivalent to `Prism.highlightAllUnder(document, async, callback)`.
4529       *
4530       * @param {boolean} [async=false] Same as in {@link Prism.highlightAllUnder}.
4531       * @param {HighlightCallback} [callback] Same as in {@link Prism.highlightAllUnder}.
4532       * @memberof Prism
4533       * @public
4534       */
4535      highlightAll: function(async, callback) {
4536        _.highlightAllUnder(document, async, callback);
4537      },
4538      /**
4539       * Fetches all the descendants of `container` that have a `.language-xxxx` class and then calls
4540       * {@link Prism.highlightElement} on each one of them.
4541       *
4542       * The following hooks will be run:
4543       * 1. `before-highlightall`
4544       * 2. `before-all-elements-highlight`
4545       * 3. All hooks of {@link Prism.highlightElement} for each element.
4546       *
4547       * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted.
4548       * @param {boolean} [async=false] Whether each element is to be highlighted asynchronously using Web Workers.
4549       * @param {HighlightCallback} [callback] An optional callback to be invoked on each element after its highlighting is done.
4550       * @memberof Prism
4551       * @public
4552       */
4553      highlightAllUnder: function(container, async, callback) {
4554        var env = {
4555          callback,
4556          container,
4557          selector: 'code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'
4558        };
4559        _.hooks.run("before-highlightall", env);
4560        env.elements = Array.prototype.slice.apply(env.container.querySelectorAll(env.selector));
4561        _.hooks.run("before-all-elements-highlight", env);
4562        for (var i = 0, element2; element2 = env.elements[i++]; ) {
4563          _.highlightElement(element2, async === true, env.callback);
4564        }
4565      },
4566      /**
4567       * Highlights the code inside a single element.
4568       *
4569       * The following hooks will be run:
4570       * 1. `before-sanity-check`
4571       * 2. `before-highlight`
4572       * 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`.
4573       * 4. `before-insert`
4574       * 5. `after-highlight`
4575       * 6. `complete`
4576       *
4577       * Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for
4578       * the element's language.
4579       *
4580       * @param {Element} element The element containing the code.
4581       * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier.
4582       * @param {boolean} [async=false] Whether the element is to be highlighted asynchronously using Web Workers
4583       * to improve performance and avoid blocking the UI when highlighting very large chunks of code. This option is
4584       * [disabled by default](https://prismjs.com/faq.html#why-is-asynchronous-highlighting-disabled-by-default).
4585       *
4586       * Note: All language definitions required to highlight the code must be included in the main `prism.js` file for
4587       * asynchronous highlighting to work. You can build your own bundle on the
4588       * [Download page](https://prismjs.com/download.html).
4589       * @param {HighlightCallback} [callback] An optional callback to be invoked after the highlighting is done.
4590       * Mostly useful when `async` is `true`, since in that case, the highlighting is done asynchronously.
4591       * @memberof Prism
4592       * @public
4593       */
4594      highlightElement: function(element2, async, callback) {
4595        var language = _.util.getLanguage(element2);
4596        var grammar = _.languages[language];
4597        _.util.setLanguage(element2, language);
4598        var parent = element2.parentElement;
4599        if (parent && parent.nodeName.toLowerCase() === "pre") {
4600          _.util.setLanguage(parent, language);
4601        }
4602        var code = element2.textContent;
4603        var env = {
4604          element: element2,
4605          language,
4606          grammar,
4607          code
4608        };
4609        function insertHighlightedCode(highlightedCode) {
4610          env.highlightedCode = highlightedCode;
4611          _.hooks.run("before-insert", env);
4612          env.element.innerHTML = env.highlightedCode;
4613          _.hooks.run("after-highlight", env);
4614          _.hooks.run("complete", env);
4615          callback && callback.call(env.element);
4616        }
4617        _.hooks.run("before-sanity-check", env);
4618        parent = env.element.parentElement;
4619        if (parent && parent.nodeName.toLowerCase() === "pre" && !parent.hasAttribute("tabindex")) {
4620          parent.setAttribute("tabindex", "0");
4621        }
4622        if (!env.code) {
4623          _.hooks.run("complete", env);
4624          callback && callback.call(env.element);
4625          return;
4626        }
4627        _.hooks.run("before-highlight", env);
4628        if (!env.grammar) {
4629          insertHighlightedCode(_.util.encode(env.code));
4630          return;
4631        }
4632        if (async && _self2.Worker) {
4633          var worker = new Worker(_.filename);
4634          worker.onmessage = function(evt) {
4635            insertHighlightedCode(evt.data);
4636          };
4637          worker.postMessage(JSON.stringify({
4638            language: env.language,
4639            code: env.code,
4640            immediateClose: true
4641          }));
4642        } else {
4643          insertHighlightedCode(_.highlight(env.code, env.grammar, env.language));
4644        }
4645      },
4646      /**
4647       * Low-level function, only use if you know what you’re doing. It accepts a string of text as input
4648       * and the language definitions to use, and returns a string with the HTML produced.
4649       *
4650       * The following hooks will be run:
4651       * 1. `before-tokenize`
4652       * 2. `after-tokenize`
4653       * 3. `wrap`: On each {@link Token}.
4654       *
4655       * @param {string} text A string with the code to be highlighted.
4656       * @param {Grammar} grammar An object containing the tokens to use.
4657       *
4658       * Usually a language definition like `Prism.languages.markup`.
4659       * @param {string} language The name of the language definition passed to `grammar`.
4660       * @returns {string} The highlighted HTML.
4661       * @memberof Prism
4662       * @public
4663       * @example
4664       * Prism.highlight('var foo = true;', Prism.languages.javascript, 'javascript');
4665       */
4666      highlight: function(text2, grammar, language) {
4667        var env = {
4668          code: text2,
4669          grammar,
4670          language
4671        };
4672        _.hooks.run("before-tokenize", env);
4673        if (!env.grammar) {
4674          throw new Error('The language "' + env.language + '" has no grammar.');
4675        }
4676        env.tokens = _.tokenize(env.code, env.grammar);
4677        _.hooks.run("after-tokenize", env);
4678        return Token.stringify(_.util.encode(env.tokens), env.language);
4679      },
4680      /**
4681       * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input
4682       * and the language definitions to use, and returns an array with the tokenized code.
4683       *
4684       * When the language definition includes nested tokens, the function is called recursively on each of these tokens.
4685       *
4686       * This method could be useful in other contexts as well, as a very crude parser.
4687       *
4688       * @param {string} text A string with the code to be highlighted.
4689       * @param {Grammar} grammar An object containing the tokens to use.
4690       *
4691       * Usually a language definition like `Prism.languages.markup`.
4692       * @returns {TokenStream} An array of strings and tokens, a token stream.
4693       * @memberof Prism
4694       * @public
4695       * @example
4696       * let code = `var foo = 0;`;
4697       * let tokens = Prism.tokenize(code, Prism.languages.javascript);
4698       * tokens.forEach(token => {
4699       *     if (token instanceof Prism.Token && token.type === 'number') {
4700       *         console.log(`Found numeric literal: ${token.content}`);
4701       *     }
4702       * });
4703       */
4704      tokenize: function(text2, grammar) {
4705        var rest = grammar.rest;
4706        if (rest) {
4707          for (var token in rest) {
4708            grammar[token] = rest[token];
4709          }
4710          delete grammar.rest;
4711        }
4712        var tokenList = new LinkedList();
4713        addAfter(tokenList, tokenList.head, text2);
4714        matchGrammar(text2, tokenList, grammar, tokenList.head, 0);
4715        return toArray(tokenList);
4716      },
4717      /**
4718       * @namespace
4719       * @memberof Prism
4720       * @public
4721       */
4722      hooks: {
4723        all: {},
4724        /**
4725         * Adds the given callback to the list of callbacks for the given hook.
4726         *
4727         * The callback will be invoked when the hook it is registered for is run.
4728         * Hooks are usually directly run by a highlight function but you can also run hooks yourself.
4729         *
4730         * One callback function can be registered to multiple hooks and the same hook multiple times.
4731         *
4732         * @param {string} name The name of the hook.
4733         * @param {HookCallback} callback The callback function which is given environment variables.
4734         * @public
4735         */
4736        add: function(name, callback) {
4737          var hooks = _.hooks.all;
4738          hooks[name] = hooks[name] || [];
4739          hooks[name].push(callback);
4740        },
4741        /**
4742         * Runs a hook invoking all registered callbacks with the given environment variables.
4743         *
4744         * Callbacks will be invoked synchronously and in the order in which they were registered.
4745         *
4746         * @param {string} name The name of the hook.
4747         * @param {Object<string, any>} env The environment variables of the hook passed to all callbacks registered.
4748         * @public
4749         */
4750        run: function(name, env) {
4751          var callbacks = _.hooks.all[name];
4752          if (!callbacks || !callbacks.length) {
4753            return;
4754          }
4755          for (var i = 0, callback; callback = callbacks[i++]; ) {
4756            callback(env);
4757          }
4758        }
4759      },
4760      Token
4761    };
4762    _self2.Prism = _;
4763    function Token(type, content, alias, matchedStr) {
4764      this.type = type;
4765      this.content = content;
4766      this.alias = alias;
4767      this.length = (matchedStr || "").length | 0;
4768    }
4769    Token.stringify = function stringify(o, language) {
4770      if (typeof o == "string") {
4771        return o;
4772      }
4773      if (Array.isArray(o)) {
4774        var s = "";
4775        o.forEach(function(e) {
4776          s += stringify(e, language);
4777        });
4778        return s;
4779      }
4780      var env = {
4781        type: o.type,
4782        content: stringify(o.content, language),
4783        tag: "span",
4784        classes: ["token", o.type],
4785        attributes: {},
4786        language
4787      };
4788      var aliases = o.alias;
4789      if (aliases) {
4790        if (Array.isArray(aliases)) {
vendor: 4,299 bytes, lines 4791-4896
4791          Array.prototype.push.apply(env.classes, aliases);
4792        } else {
4793          env.classes.push(aliases);
4794        }
4795      }
4796      _.hooks.run("wrap", env);
4797      var attributes = "";
4798      for (var name in env.attributes) {
4799        attributes += " " + name + '="' + (env.attributes[name] || "").replace(/"/g, "&quot;") + '"';
4800      }
4801      return "<" + env.tag + ' class="' + env.classes.join(" ") + '"' + attributes + ">" + env.content + "</" + env.tag + ">";
4802    };
4803    function matchPattern(pattern, pos, text2, lookbehind) {
4804      pattern.lastIndex = pos;
4805      var match = pattern.exec(text2);
4806      if (match && lookbehind && match[1]) {
4807        var lookbehindLength = match[1].length;
4808        match.index += lookbehindLength;
4809        match[0] = match[0].slice(lookbehindLength);
4810      }
4811      return match;
4812    }
4813    function matchGrammar(text2, tokenList, grammar, startNode, startPos, rematch) {
4814      for (var token in grammar) {
4815        if (!grammar.hasOwnProperty(token) || !grammar[token]) {
4816          continue;
4817        }
4818        var patterns = grammar[token];
4819        patterns = Array.isArray(patterns) ? patterns : [patterns];
4820        for (var j = 0; j < patterns.length; ++j) {
4821          if (rematch && rematch.cause == token + "," + j) {
4822            return;
4823          }
4824          var patternObj = patterns[j];
4825          var inside = patternObj.inside;
4826          var lookbehind = !!patternObj.lookbehind;
4827          var greedy = !!patternObj.greedy;
4828          var alias = patternObj.alias;
4829          if (greedy && !patternObj.pattern.global) {
4830            var flags = patternObj.pattern.toString().match(/[imsuy]*$/)[0];
4831            patternObj.pattern = RegExp(patternObj.pattern.source, flags + "g");
4832          }
4833          var pattern = patternObj.pattern || patternObj;
4834          for (var currentNode = startNode.next, pos = startPos; currentNode !== tokenList.tail; pos += currentNode.value.length, currentNode = currentNode.next) {
4835            if (rematch && pos >= rematch.reach) {
4836              break;
4837            }
4838            var str = currentNode.value;
4839            if (tokenList.length > text2.length) {
4840              return;
4841            }
4842            if (str instanceof Token) {
4843              continue;
4844            }
4845            var removeCount = 1;
4846            var match;
4847            if (greedy) {
4848              match = matchPattern(pattern, pos, text2, lookbehind);
4849              if (!match || match.index >= text2.length) {
4850                break;
4851              }
4852              var from = match.index;
4853              var to = match.index + match[0].length;
4854              var p = pos;
4855              p += currentNode.value.length;
4856              while (from >= p) {
4857                currentNode = currentNode.next;
4858                p += currentNode.value.length;
4859              }
4860              p -= currentNode.value.length;
4861              pos = p;
4862              if (currentNode.value instanceof Token) {
4863                continue;
4864              }
4865              for (var k = currentNode; k !== tokenList.tail && (p < to || typeof k.value === "string"); k = k.next) {
4866                removeCount++;
4867                p += k.value.length;
4868              }
4869              removeCount--;
4870              str = text2.slice(pos, p);
4871              match.index -= pos;
4872            } else {
4873              match = matchPattern(pattern, 0, str, lookbehind);
4874              if (!match) {
4875                continue;
4876              }
4877            }
4878            var from = match.index;
4879            var matchStr = match[0];
4880            var before = str.slice(0, from);
4881            var after = str.slice(from + matchStr.length);
4882            var reach = pos + str.length;
4883            if (rematch && reach > rematch.reach) {
4884              rematch.reach = reach;
4885            }
4886            var removeFrom = currentNode.prev;
4887            if (before) {
4888              removeFrom = addAfter(tokenList, removeFrom, before);
4889              pos += before.length;
4890            }
4891            removeRange(tokenList, removeFrom, removeCount);
4892            var wrapped = new Token(token, inside ? _.tokenize(matchStr, inside) : matchStr, alias, matchStr);
4893            currentNode = addAfter(tokenList, removeFrom, wrapped);
4894            if (after) {
4895              addAfter(tokenList, currentNode, after);
4896            }
vendor: 4,200 bytes, lines 4897-5041
4897            if (removeCount > 1) {
4898              var nestedRematch = {
4899                cause: token + "," + j,
4900                reach
4901              };
4902              matchGrammar(text2, tokenList, grammar, currentNode.prev, pos, nestedRematch);
4903              if (rematch && nestedRematch.reach > rematch.reach) {
4904                rematch.reach = nestedRematch.reach;
4905              }
4906            }
4907          }
4908        }
4909      }
4910    }
4911    function LinkedList() {
4912      var head = { value: null, prev: null, next: null };
4913      var tail = { value: null, prev: head, next: null };
4914      head.next = tail;
4915      this.head = head;
4916      this.tail = tail;
4917      this.length = 0;
4918    }
4919    function addAfter(list2, node, value) {
4920      var next = node.next;
4921      var newNode = { value, prev: node, next };
4922      node.next = newNode;
4923      next.prev = newNode;
4924      list2.length++;
4925      return newNode;
4926    }
4927    function removeRange(list2, node, count) {
4928      var next = node.next;
4929      for (var i = 0; i < count && next !== list2.tail; i++) {
4930        next = next.next;
4931      }
4932      node.next = next;
4933      next.prev = node;
4934      list2.length -= i;
4935    }
4936    function toArray(list2) {
4937      var array = [];
4938      var node = list2.head.next;
4939      while (node !== list2.tail) {
4940        array.push(node.value);
4941        node = node.next;
4942      }
4943      return array;
4944    }
4945    if (!_self2.document) {
4946      if (!_self2.addEventListener) {
4947        return _;
4948      }
4949      if (!_.disableWorkerMessageHandler) {
4950        _self2.addEventListener("message", function(evt) {
4951          var message = JSON.parse(evt.data);
4952          var lang2 = message.language;
4953          var code = message.code;
4954          var immediateClose = message.immediateClose;
4955          _self2.postMessage(_.highlight(code, _.languages[lang2], lang2));
4956          if (immediateClose) {
4957            _self2.close();
4958          }
4959        }, false);
4960      }
4961      return _;
4962    }
4963    var script = _.util.currentScript();
4964    if (script) {
4965      _.filename = script.src;
4966      if (script.hasAttribute("data-manual")) {
4967        _.manual = true;
4968      }
4969    }
4970    function highlightAutomaticallyCallback() {
4971      if (!_.manual) {
4972        _.highlightAll();
4973      }
4974    }
4975    if (!_.manual) {
4976      var readyState = document.readyState;
4977      if (readyState === "loading" || readyState === "interactive" && script && script.defer) {
4978        document.addEventListener("DOMContentLoaded", highlightAutomaticallyCallback);
4979      } else {
4980        if (window.requestAnimationFrame) {
4981          window.requestAnimationFrame(highlightAutomaticallyCallback);
4982        } else {
4983          window.setTimeout(highlightAutomaticallyCallback, 16);
4984        }
4985      }
4986    }
4987    return _;
4988  }(_self);
4989  if (module.exports) {
4990    module.exports = Prism2;
4991  }
4992  if (typeof commonjsGlobal !== "undefined") {
4993    commonjsGlobal.Prism = Prism2;
4994  }
4995  Prism2.languages.markup = {
4996    "comment": {
4997      pattern: /<!--(?:(?!<!--)[\s\S])*?-->/,
4998      greedy: true
4999    },
5000    "prolog": {
5001      pattern: /<\?[\s\S]+?\?>/,
5002      greedy: true
5003    },
5004    "doctype": {
5005      // https://www.w3.org/TR/xml/#NT-doctypedecl
5006      pattern: /<!DOCTYPE(?:[^>"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|<!--(?:[^-]|-(?!->))*-->)*\]\s*)?>/i,
5007      greedy: true,
5008      inside: {
5009        "internal-subset": {
5010          pattern: /(^[^\[]*\[)[\s\S]+(?=\]>$)/,
5011          lookbehind: true,
5012          greedy: true,
5013          inside: null
5014          // see below
5015        },
5016        "string": {
5017          pattern: /"[^"]*"|'[^']*'/,
5018          greedy: true
5019        },
5020        "punctuation": /^<!|>$|[[\]]/,
5021        "doctype-tag": /^DOCTYPE/i,
5022        "name": /[^\s<>'"]+/
5023      }
5024    },
5025    "cdata": {
5026      pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
5027      greedy: true
5028    },
5029    "tag": {
5030      pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,
5031      greedy: true,
5032      inside: {
5033        "tag": {
5034          pattern: /^<\/?[^\s>\/]+/,
5035          inside: {
5036            "punctuation": /^<\/?/,
5037            "namespace": /^[^\s>\/:]+:/
5038          }
5039        },
5040        "special-attr": [],
5041        "attr-value": {
5042          pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,
5043          inside: {
5044            "punctuation": [
5045              {
5046                pattern: /^=/,
5047                alias: "attr-equals"
5048              },
5049              {
5050                pattern: /^(\s*)["']|["']$/,
5051                lookbehind: true
5052              }
5053            ]
5054          }
5055        },
5056        "punctuation": /\/?>/,
5057        "attr-name": {
5058          pattern: /[^\s>\/]+/,
5059          inside: {
5060            "namespace": /^[^\s>\/:]+:/
5061          }
5062        }
5063      }
5064    },
5065    "entity": [
5066      {
5067        pattern: /&[\da-z]{1,8};/i,
5068        alias: "named-entity"
5069      },
5070      /&#x?[\da-f]{1,8};/i
5071    ]
5072  };
5073  Prism2.languages.markup["tag"].inside["attr-value"].inside["entity"] = Prism2.languages.markup["entity"];
5074  Prism2.languages.markup["doctype"].inside["internal-subset"].inside = Prism2.languages.markup;
5075  Prism2.hooks.add("wrap", function(env) {
5076    if (env.type === "entity") {
5077      env.attributes["title"] = env.content.replace(/&amp;/, "&");
5078    }
5079  });
5080  Object.defineProperty(Prism2.languages.markup.tag, "addInlined", {
5081    /**
5082     * Adds an inlined language to markup.
5083     *
5084     * An example of an inlined language is CSS with `<style>` tags.
5085     *
5086     * @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as
5087     * case insensitive.
5088     * @param {string} lang The language key.
5089     * @example
5090     * addInlined('style', 'css');
5091     */
5092    value: function addInlined(tagName, lang) {
5093      var includedCdataInside = {};
5094      includedCdataInside["language-" + lang] = {
5095        pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i,
5096        lookbehind: true,
5097        inside: Prism2.languages[lang]
5098      };
5099      includedCdataInside["cdata"] = /^<!\[CDATA\[|\]\]>$/i;
5100      var inside = {
5101        "included-cdata": {
5102          pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i,
5103          inside: includedCdataInside
5104        }
5105      };
5106      inside["language-" + lang] = {
5107        pattern: /[\s\S]+/,
5108        inside: Prism2.languages[lang]
5109      };
5110      var def2 = {};
5111      def2[tagName] = {
5112        pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function() {
5113          return tagName;
5114        }), "i"),
5115        lookbehind: true,
5116        greedy: true,
5117        inside
5118      };
5119      Prism2.languages.insertBefore("markup", "cdata", def2);
5120    }
5121  });
5122  Object.defineProperty(Prism2.languages.markup.tag, "addAttribute", {
5123    /**
5124     * Adds an pattern to highlight languages embedded in HTML attributes.
5125     *
5126     * An example of an inlined language is CSS with `style` attributes.
5127     *
5128     * @param {string} attrName The name of the tag that contains the inlined language. This name will be treated as
5129     * case insensitive.
5130     * @param {string} lang The language key.
5131     * @example
5132     * addAttribute('style', 'css');
5133     */
5134    value: function(attrName, lang) {
5135      Prism2.languages.markup.tag.inside["special-attr"].push({
5136        pattern: RegExp(
5137          /(^|["'\s])/.source + "(?:" + attrName + ")" + /\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,
5138          "i"
5139        ),
5140        lookbehind: true,
5141        inside: {
5142          "attr-name": /^[^\s=]+/,
5143          "attr-value": {
5144            pattern: /=[\s\S]+/,
5145            inside: {
5146              "value": {
5147                pattern: /(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,
5148                lookbehind: true,
5149                alias: [lang, "language-" + lang],
5150                inside: Prism2.languages[lang]
5151              },
5152              "punctuation": [
5153                {
5154                  pattern: /^=/,
5155                  alias: "attr-equals"
5156                },
5157                /"|'/
5158              ]
5159            }
5160          }
5161        }
5162      });
5163    }
5164  });
5165  Prism2.languages.html = Prism2.languages.markup;
5166  Prism2.languages.mathml = Prism2.languages.markup;
5167  Prism2.languages.svg = Prism2.languages.markup;
5168  Prism2.languages.xml = Prism2.languages.extend("markup", {});
5169  Prism2.languages.ssml = Prism2.languages.xml;
5170  Prism2.languages.atom = Prism2.languages.xml;
5171  Prism2.languages.rss = Prism2.languages.xml;
5172  (function(Prism3) {
5173    var string = /(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;
5174    Prism3.languages.css = {
5175      "comment": /\/\*[\s\S]*?\*\//,
5176      "atrule": {
5177        pattern: RegExp("@[\\w-](?:" + /[^;{\s"']|\s+(?!\s)/.source + "|" + string.source + ")*?" + /(?:;|(?=\s*\{))/.source),
5178        inside: {
5179          "rule": /^@[\w-]+/,
5180          "selector-function-argument": {
5181            pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]
5181*\))*\))+(?=\s*\))/,
5182            lookbehind: true,
5183            alias: "selector"
5184          },
5185          "keyword": {
5186            pattern: /(^|[^\w-])(?:and|not|only|or)(?![\w-])/,
5187            lookbehind: true
5188          }
5189          // See rest below
5190        }
5191      },
5192      "url": {
5193        // https://drafts.csswg.org/css-values-3/#urls
5194        pattern: RegExp("\\burl\\((?:" + string.source + "|" + /(?:[^\\\r\n()"']|\\[\s\S])*/.source + ")\\)", "i"),
5195        greedy: true,
5196        inside: {
5197          "function": /^url/i,
5198          "punctuation": /^\(|\)$/,
5199          "string": {
5200            pattern: RegExp("^" + string.source + "$"),
5201            alias: "url"
5202          }
5203        }
5204      },
5205      "selector": {
5206        pattern: RegExp(`(^|[{}\\s])[^{}\\s](?:[^{};"'\\s]|\\s+(?![\\s{])|` + string.source + ")*(?=\\s*\\{)"),
5207        lookbehind: true
5208      },
5209      "string": {
5210        pattern: string,
5211        greedy: true
5212      },
5213      "property": {
5214        pattern: /(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,
5215        lookbehind: true
5216      },
5217      "important": /!important\b/i,
5218      "function": {
5219        pattern: /(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,
5220        lookbehind: true
5221      },
5222      "punctuation": /[(){};:,]/
5223    };
5224    Prism3.languages.css["atrule"].inside.rest = Prism3.languages.css;
5225    var markup = Prism3.languages.markup;
5226    if (markup) {
5227      markup.tag.addInlined("style", "css");
5228      markup.tag.addAttribute("style", "css");
5229    }
5230  })(Prism2);
5231  Prism2.languages.clike = {
5232    "comment": [
5233      {
5234        pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,
5235        lookbehind: true,
5236        greedy: true
5237      },
5238      {
5239        pattern: /(^|[^\\:])\/\/.*/,
5240        lookbehind: true,
5241        greedy: true
5242      }
5243    ],
5244    "string": {
5245      pattern: /(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
5246      greedy: true
5247    },
5248    "class-name": {
5249      pattern: /(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,
5250      lookbehind: true,
5251      inside: {
5252        "punctuation": /[.\\]/
5253      }
5254    },
5255    "keyword": /\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,
5256    "boolean": /\b(?:false|true)\b/,
5257    "function": /\b\w+(?=\()/,
5258    "number": /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,
5259    "operator": /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,
5260    "punctuation": /[{}[\];(),.:]/
5261  };
5262  Prism2.languages.javascript = Prism2.languages.extend("clike", {
5263    "class-name": [
5264      Prism2.languages.clike["class-name"],
5265      {
5266        pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,
5267        lookbehind: true
5268      }
5269    ],
5270    "keyword": [
5271      {
5272        pattern: /((?:^|\})\s*)catch\b/,
5273        lookbehind: true
5274      },
5275      {
5276        pattern: /(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,
5277        lookbehind: true
5278      }
5279    ],
5280    // Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444)
5281    "function": /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,
5282    "number": {
5283      pattern: RegExp(
5284        /(^|[^\w$])/.source + "(?:" + // constant
5285        (/NaN|Infinity/.source + "|" + // binary integer
5286        /0[bB][01]+(?:_[01]+)*n?/.source + "|" + // octal integer
5287        /0[oO][0-7]+(?:_[0-7]+)*n?/.source + "|" + // hexadecimal integer
5288        /0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source + "|" + // decimal bigint
5289        /\d+(?:_\d+)*n/.source + "|" + // decimal number (integer or float) but no bigint
5290        /(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source) + ")" + /(?![\w$])/.source
5291      ),
5292      lookbehind: true
5293    },
5294    "operator": /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/
5295  });
5296  Prism2.languages.javascript["class-name"][0].pattern = /(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/;
5297  Prism2.languages.insertBefore("javascript", "keyword", {
5298    "regex": {
5299      pattern: RegExp(
5300        // lookbehind
5301        // eslint-disable-next-line regexp/no-dupe-characters-character-class
5302        /((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source + // Regex pattern:
5303        // There are 2 regex patterns here. The RegExp set notation proposal added support for nested character
5304        // classes if the `v` flag is present. Unfortunately, nested CCs are both context-free and incompatible
5305        // with the only syntax, so we have to define 2 different regex patterns.
5306        /\//.source + "(?:" + /(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source + "|" + // `v` flag syntax. This supports 3 levels of nested character classes.
5307        /(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source + ")" + // lookahead
5308        /(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source
5309      ),
5310      lookbehind: true,
5311      greedy: true,
5312      inside: {
5313        "regex-source": {
5314          pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/,
5315          lookbehind: true,
5316          alias: "language-regex",
5317          inside: Prism2.languages.regex
5318        },
5319        "regex-delimiter": /^\/|\/$/,
5320        "regex-flags": /^[a-z]+$/
5321      }
5322    },
5323    // This must be declared before keyword because we use "function" inside the look-forward
5324    "function-variable": {
5325      pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,
5326      alias: "function"
5327    },
5328    "parameter": [
5329      {
5330        pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]
vendor: 7,524 bytes, lines 5330-5536
5330*\))+(?=\s*\))/,
5331        lookbehind: true,
5332        inside: Prism2.languages.javascript
5333      },
5334      {
5335        pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,
5336        lookbehind: true,
5337        inside: Prism2.languages.javascript
5338      },
5339      {
5340        pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,
5341        lookbehind: true,
5342        inside: Prism2.languages.javascript
5343      },
5344      {
5345        pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,
5346        lookbehind: true,
5347        inside: Prism2.languages.javascript
5348      }
5349    ],
5350    "constant": /\b[A-Z](?:[A-Z_]|\dx?)*\b/
5351  });
5352  Prism2.languages.insertBefore("javascript", "string", {
5353    "hashbang": {
5354      pattern: /^#!.*/,
5355      greedy: true,
5356      alias: "comment"
5357    },
5358    "template-string": {
5359      pattern: /`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,
5360      greedy: true,
5361      inside: {
5362        "template-punctuation": {
5363          pattern: /^`|`$/,
5364          alias: "string"
5365        },
5366        "interpolation": {
5367          pattern: /((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,
5368          lookbehind: true,
5369          inside: {
5370            "interpolation-punctuation": {
5371              pattern: /^\$\{|\}$/,
5372              alias: "punctuation"
5373            },
5374            rest: Prism2.languages.javascript
5375          }
5376        },
5377        "string": /[\s\S]+/
5378      }
5379    },
5380    "string-property": {
5381      pattern: /((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,
5382      lookbehind: true,
5383      greedy: true,
5384      alias: "property"
5385    }
5386  });
5387  Prism2.languages.insertBefore("javascript", "operator", {
5388    "literal-property": {
5389      pattern: /((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,
5390      lookbehind: true,
5391      alias: "property"
5392    }
5393  });
5394  if (Prism2.languages.markup) {
5395    Prism2.languages.markup.tag.addInlined("script", "javascript");
5396    Prism2.languages.markup.tag.addAttribute(
5397      /on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,
5398      "javascript"
5399    );
5400  }
5401  Prism2.languages.js = Prism2.languages.javascript;
5402  (function() {
5403    if (typeof Prism2 === "undefined" || typeof document === "undefined") {
5404      return;
5405    }
5406    if (!Element.prototype.matches) {
5407      Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector;
5408    }
5409    var LOADING_MESSAGE = "Loading…";
5410    var FAILURE_MESSAGE = function(status, message) {
5411      return "✖ Error " + status + " while fetching file: " + message;
5412    };
5413    var FAILURE_EMPTY_MESSAGE = "✖ Error: File does not exist or is empty";
5414    var EXTENSIONS = {
5415      "js": "javascript",
5416      "py": "python",
5417      "rb": "ruby",
5418      "ps1": "powershell",
5419      "psm1": "powershell",
5420      "sh": "bash",
5421      "bat": "batch",
5422      "h": "c",
5423      "tex": "latex"
5424    };
5425    var STATUS_ATTR = "data-src-status";
5426    var STATUS_LOADING = "loading";
5427    var STATUS_LOADED = "loaded";
5428    var STATUS_FAILED = "failed";
5429    var SELECTOR = "pre[data-src]:not([" + STATUS_ATTR + '="' + STATUS_LOADED + '"]):not([' + STATUS_ATTR + '="' + STATUS_LOADING + '"])';
5430    function loadFile(src, success, error) {
5431      var xhr = new XMLHttpRequest();
5432      xhr.open("GET", src, true);
5433      xhr.onreadystatechange = function() {
5434        if (xhr.readyState == 4) {
5435          if (xhr.status < 400 && xhr.responseText) {
5436            success(xhr.responseText);
5437          } else {
5438            if (xhr.status >= 400) {
5439              error(FAILURE_MESSAGE(xhr.status, xhr.statusText));
5440            } else {
5441              error(FAILURE_EMPTY_MESSAGE);
5442            }
5443          }
5444        }
5445      };
5446      xhr.send(null);
5447    }
5448    function parseRange(range) {
5449      var m = /^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(range || "");
5450      if (m) {
5451        var start = Number(m[1]);
5452        var comma = m[2];
5453        var end = m[3];
5454        if (!comma) {
5455          return [start, start];
5456        }
5457        if (!end) {
5458          return [start, void 0];
5459        }
5460        return [start, Number(end)];
5461      }
5462      return void 0;
5463    }
5464    Prism2.hooks.add("before-highlightall", function(env) {
5465      env.selector += ", " + SELECTOR;
5466    });
5467    Prism2.hooks.add("before-sanity-check", function(env) {
5468      var pre = (
5469        /** @type {HTMLPreElement} */
5470        env.element
5471      );
5472      if (pre.matches(SELECTOR)) {
5473        env.code = "";
5474        pre.setAttribute(STATUS_ATTR, STATUS_LOADING);
5475        var code = pre.appendChild(document.createElement("CODE"));
5476        code.textContent = LOADING_MESSAGE;
5477        var src = pre.getAttribute("data-src");
5478        var language = env.language;
5479        if (language === "none") {
5480          var extension = (/\.(\w+)$/.exec(src) || [, "none"])[1];
5481          language = EXTENSIONS[extension] || extension;
5482        }
5483        Prism2.util.setLanguage(code, language);
5484        Prism2.util.setLanguage(pre, language);
5485        var autoloader = Prism2.plugins.autoloader;
5486        if (autoloader) {
5487          autoloader.loadLanguages(language);
5488        }
5489        loadFile(
5490          src,
5491          function(text2) {
5492            pre.setAttribute(STATUS_ATTR, STATUS_LOADED);
5493            var range = parseRange(pre.getAttribute("data-range"));
5494            if (range) {
5495              var lines = text2.split(/\r\n?|\n/g);
5496              var start = range[0];
5497              var end = range[1] == null ? lines.length : range[1];
5498              if (start < 0) {
5499                start += lines.length;
5500              }
5501              start = Math.max(0, Math.min(start - 1, lines.length));
5502              if (end < 0) {
5503                end += lines.length;
5504              }
5505              end = Math.max(0, Math.min(end, lines.length));
5506              text2 = lines.slice(start, end).join("\n");
5507              if (!pre.hasAttribute("data-start")) {
5508                pre.setAttribute("data-start", String(start + 1));
5509              }
5510            }
5511            code.textContent = text2;
5512            Prism2.highlightElement(code);
5513          },
5514          function(error) {
5515            pre.setAttribute(STATUS_ATTR, STATUS_FAILED);
5516            code.textContent = error;
5517          }
5518        );
5519      }
5520    });
5521    Prism2.plugins.fileHighlight = {
5522      /**
5523       * Executes the File Highlight plugin for all matching `pre` elements under the given container.
5524       *
5525       * Note: Elements which are already loaded or currently loading will not be touched by this method.
5526       *
5527       * @param {ParentNode} [container=document]
5528       */
5529      highlight: function highlight(container) {
5530        var elements = (container || document).querySelectorAll(SELECTOR);
5531        for (var i = 0, element2; element2 = elements[i++]; ) {
5532          Prism2.highlightElement(element2);
5533        }
5534      }
5535    };
5536    var logged = false;
5537    Prism2.fileHighlight = function() {
5538      if (!logged) {
5539        console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead.");
5540        logged = true;
5541      }
5542      Prism2.plugins.fileHighlight.highlight.apply(this, arguments);
5543    };
5544  })();
5545})(prism);
5546var prismExports = prism.exports;
5547Prism.languages.python = {
5548  "comment": {
5549    pattern: /(^|[^\\])#.*/,
5550    lookbehind: true,
5551    greedy: true
5552  },
5553  "string-interpolation": {
5554    pattern: /(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,
5555    greedy: true,
5556    inside: {
5557      "interpolation": {
5558        // "{" <expression> <optional "!s", "!r", or "!a"> <optional ":" format specifier> "}"
5559        pattern: /((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,
5560        lookbehind: true,
5561        inside: {
5562          "format-spec": {
5563            pattern: /(:)[^:(){}]+(?=\}$)/,
5564            lookbehind: true
5565          },
5566          "conversion-option": {
5567            pattern: /![sra](?=[:}]$)/,
5568            alias: "punctuation"
5569          },
5570          rest: null
5571        }
5572      },
5573      "string": /[\s\S]+/
5574    }
5575  },
5576  "triple-quoted-string": {
5577    pattern: /(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,
5578    greedy: true,
5579    alias: "string"
5580  },
5581  "string": {
5582    pattern: /(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,
5583    greedy: true
5584  },
5585  "function": {
5586    pattern: /((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,
5587    lookbehind: true
5588  },
5589  "class-name": {
5590    pattern: /(\bclass\s+)\w+/i,
5591    lookbehind: true
5592  },
5593  "decorator": {
5594    pattern: /(^[\t ]*)@\w+(?:\.\w+)*/m,
5595    lookbehind: true,
5596    alias: ["annotation", "punctuation"],
5597    inside: {
5598      "punctuation": /\./
5599    }
5600  },
5601  "keyword": /\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,
5602  "builtin": /\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,
5603  "boolean": /\b(?:False|None|True)\b/,
5604  "number": /\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,
5605  "operator": /[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,
5606  "punctuation": /[{}[\];(),.:]/
5607};
5608Prism.languages.python["string-interpolation"].inside["interpolation"].inside.rest = Prism.languages.python;
5609Prism.languages.py = Prism.languages.python;
5610(function(Prism2) {
5611  var funcPattern = /\\(?:[^a-z()[\]]|[a-z*]+)/i;
5612  var insideEqu = {
5613    "equation-command": {
5614      pattern: funcPattern,
5615      alias: "regex"
5616    }
5617  };
5618  Prism2.languages.latex = {
5619    "comment": /%.*/,
5620    // the verbatim environment prints whitespace to the document
5621    "cdata": {
5622      pattern: /(\\begin\{((?:lstlisting|verbatim)\*?)\})[\s\S]*?(?=\\end\{\2\})/,
5623      lookbehind: true
5624    },
5625    /*
5626     * equations can be between $$ $$ or $ $ or \( \) or \[ \]
5627     * (all are multiline)
5628     */
5629    "equation": [
5630      {
5631        pattern: /\$\$(?:\\[\s\S]|[^\\$])+\$\$|\$(?:\\[\s\S]|[^\\$])+\$|\\\([\s\S]*?\\\)|\\\[[\s\S]*?\\\]/,
5632        inside: insideEqu,
5633        alias: "string"
5634      },
5635      {
5636        pattern: /(\\begin\{((?:align|eqnarray|equation|gather|math|multline)\*?)\})[\s\S]*?(?=\\end\{\2\})/,
5637        lookbehind: true,
5638        inside: insideEqu,
5639        alias: "string"
5640      }
5641    ],
5642    /*
5643     * arguments which are keywords or references are highlighted
5644     * as keywords
5645     */
5646    "keyword": {
5647      pattern: /(\\(?:begin|cite|documentclass|end|label|ref|usepackage)(?:\[[^\]]+\])?\{)[^}]+(?=\})/,
5648      lookbehind: true
5649    },
5650    "url": {
5651      pattern: /(\\url\{)[^}]+(?=\})/,
5652      lookbehind: true
5653    },
5654    /*
5655     * section or chapter headlines are highlighted as bold so that
5656     * they stand out more
5657     */
5658    "headline": {
5659      pattern: /(\\(?:chapter|frametitle|paragraph|part|section|subparagraph|subsection|subsubparagraph|subsubsection|subsubsubparagraph)\*?(?:\[[^\]]+\])?\{)[^}]+(?=\})/,
5660      lookbehind: true,
5661      alias: "class-name"
5662    },
5663    "function": {
5664      pattern: funcPattern,
5665      alias: "selector"
5666    },
5667    "punctuation": /[[\]{}&]/
5668  };
5669  Prism2.languages.tex = Prism2.languages.latex;
5670  Prism2.languages.context = Prism2.languages.latex;
5671})(Prism);
5672(function(Prism2) {
5673  var envVars = "\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_
5673CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b";
5674  var commandAfterHeredoc = {
5675    pattern: /(^(["']?)\w+\2)[ \t]+\S.*/,
5676    lookbehind: true,
5677    alias: "punctuation",
5678    // this looks reasonably well in all themes
5679    inside: null
5680    // see below
5681  };
5682  var insideString = {
5683    "bash": commandAfterHeredoc,
5684    "environment": {
5685      pattern: RegExp("\\$" + envVars),
5686      alias: "constant"
5687    },
5688    "variable": [
5689      // [0]: Arithmetic Environment
5690      {
5691        pattern: /\$?\(\([\s\S]+?\)\)/,
5692        greedy: true,
5693        inside: {
5694          // If there is a $ sign at the beginning highlight $(( and )) as variable
5695          "variable": [
5696            {
5697              pattern: /(^\$\(\([\s\S]+)\)\)/,
5698              lookbehind: true
5699            },
5700            /^\$\(\(/
5701          ],
5702          "number": /\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,
5703          // Operators according to https://www.gnu.org/software/bash/manual/bashref.html#Shell-Arithmetic
5704          "operator": /--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,
5705          // If there is no $ sign at the beginning highlight (( and )) as punctuation
5706          "punctuation": /\(\(?|\)\)?|,|;/
5707        }
5708      },
5709      // [1]: Command Substitution
5710      {
5711        pattern: /\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,
5712        greedy: true,
5713        inside: {
5714          "variable": /^\$\(|^`|\)$|`$/
5715        }
5716      },
5717      // [2]: Brace expansion
5718      {
5719        pattern: /\$\{[^}]+\}/,
5720        greedy: true,
5721        inside: {
5722          "operator": /:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,
5723          "punctuation": /[\[\]]/,
5724          "environment": {
5725            pattern: RegExp("(\\{)" + envVars),
5726            lookbehind: true,
5727            alias: "constant"
5728          }
5729        }
5730      },
5731      /\$(?:\w+|[#?*!@$])/
5732    ],
5733    // Escape sequences from echo and printf's manuals, and escaped quotes.
5734    "entity": /\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/
5735  };
5736  Prism2.languages.bash = {
5737    "shebang": {
5738      pattern: /^#!\s*\/.*/,
5739      alias: "important"
5740    },
5741    "comment": {
5742      pattern: /(^|[^"{\\$])#.*/,
5743      lookbehind: true
5744    },
5745    "function-name": [
5746      // a) function foo {
5747      // b) foo() {
5748      // c) function foo() {
5749      // but not “foo {”
5750      {
5751        // a) and c)
5752        pattern: /(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,
5753        lookbehind: true,
5754        alias: "function"
5755      },
5756      {
5757        // b)
5758        pattern: /\b[\w-]+(?=\s*\(\s*\)\s*\{)/,
5759        alias: "function"
5760      }
5761    ],
5762    // Highlight variable names as variables in for and select beginnings.
5763    "for-or-select": {
5764      pattern: /(\b(?:for|select)\s+)\w+(?=\s+in\s)/,
5765      alias: "variable",
5766      lookbehind: true
5767    },
5768    // Highlight variable names as variables in the left-hand part
5769    // of assignments (“=” and “+=”).
5770    "assign-left": {
5771      pattern: /(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,
5772      inside: {
5773        "environment": {
5774          pattern: RegExp("(^|[\\s;|&]|[<>]\\()" + envVars),
5775          lookbehind: true,
5776          alias: "constant"
5777        }
5778      },
5779      alias: "variable",
5780      lookbehind: true
5781    },
5782    // Highlight parameter names as variables
5783    "parameter": {
5784      pattern: /(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,
5785      alias: "variable",
5786      lookbehind: true
5787    },
5788    "string": [
5789      // Support for Here-documents https://en.wikipedia.org/wiki/Here_document
5790      {
5791        pattern: /((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,
5792        lookbehind: true,
5793        greedy: true,
5794        inside: insideString
5795      },
5796      // Here-document with quotes around the tag
5797      // → No expansion (so no “inside”).
5798      {
5799        pattern: /((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,
5800        lookbehind: true,
5801        greedy: true,
5802        inside: {
5803          "bash": commandAfterHeredoc
5804        }
5805      },
5806      // “Normal” string
5807      {
5808        // https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html
5809        pattern: /(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,
5810        lookbehind: true,
5811        greedy: true,
5812        inside: insideString
5813      },
5814      {
5815        // https://www.gnu.org/software/bash/manual/html_node/Single-Quotes.html
5816        pattern: /(^|[^$\\])'[^']*'/,
5817        lookbehind: true,
5818        greedy: true
5819      },
5820      {
5821        // https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html
5822        pattern: /\$'(?:[^'\\]|\\[\s\S])*'/,
5823        greedy: true,
5824        inside: {
5825          "entity": insideString.entity
5826        }
5827      }
5828    ],
5829    "environment": {
5830      pattern: RegExp("\\$?" + envVars),
5831      alias: "constant"
5832    },
5833    "variable": insideString.variable,
5834    "function": {
5835      pattern: /(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|
5835ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,
5836      lookbehind: true
5837    },
5838    "keyword": {
5839      pattern: /(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,
5840      lookbehind: true
5841    },
5842    // https://www.gnu.org/software/bash/manual/html_node/Shell-Builtin-Commands.html
5843    "builtin": {
5844      pattern: /(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,
5845      lookbehind: true,
5846      // Alias added to make those easier to distinguish from strings.
5847      alias: "class-name"
5848    },
5849    "boolean": {
5850      pattern: /(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,
5851      lookbehind: true
5852    },
5853    "file-descriptor": {
5854      pattern: /\B&\d\b/,
5855      alias: "important"
5856    },
5857    "operator": {
5858      // Lots of redirections here, but not just that.
5859      pattern: /\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,
5860      inside: {
5861        "file-descriptor": {
5862          pattern: /^\d/,
5863          alias: "important"
5864        }
5865      }
5866    },
5867    "punctuation": /\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,
5868    "number": {
5869      pattern: /(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,
5870      lookbehind: true
5871    }
5872  };
5873  commandAfterHeredoc.inside = Prism2.languages.bash;
5874  var toBeCopied = [
5875    "comment",
5876    "function-name",
5877    "for-or-select",
5878    "assign-left",
5879    "parameter",
5880    "string",
5881    "environment",
5882    "function",
5883    "keyword",
5884    "builtin",
5885    "boolean",
5886    "file-descriptor",
5887    "operator",
5888    "punctuation",
5889    "number"
5890  ];
5891  var inside = insideString.variable[1].inside;
5892  for (var i = 0; i < toBeCopied.length; i++) {
5893    inside[toBeCopied[i]] = Prism2.languages.bash[toBeCopied[i]];
5894  }
5895  Prism2.languages.sh = Prism2.languages.bash;
5896  Prism2.languages.shell = Prism2.languages.bash;
5897})(Prism);
5898Prism.languages.c = Prism.languages.extend("clike", {
5899  "comment": {
5900    pattern: /\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,
5901    greedy: true
5902  },
5903  "string": {
5904    // https://en.cppreference.com/w/c/language/string_literal
5905    pattern: /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,
5906    greedy: true
5907  },
5908  "class-name": {
5909    pattern: /(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,
5910    lookbehind: true
5911  },
5912  "keyword": /\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,
5913  "function": /\b[a-z_]\w*(?=\s*\()/i,
5914  "number": /(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,
5915  "operator": />>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/
5916});
vendor: 4,936 bytes, lines 5917-6032
5917Prism.languages.insertBefore("c", "string", {
5918  "char": {
5919    // https://en.cppreference.com/w/c/language/character_constant
5920    pattern: /'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,
5921    greedy: true
5922  }
5923});
5924Prism.languages.insertBefore("c", "string", {
5925  "macro": {
5926    // allow for multiline macro definitions
5927    // spaces after the # character compile fine with gcc
5928    pattern: /(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,
5929    lookbehind: true,
5930    greedy: true,
5931    alias: "property",
5932    inside: {
5933      "string": [
5934        {
5935          // highlight the path of the include statement as a string
5936          pattern: /^(#\s*include\s*)<[^>]+>/,
5937          lookbehind: true
5938        },
5939        Prism.languages.c["string"]
5940      ],
5941      "char": Prism.languages.c["char"],
5942      "comment": Prism.languages.c["comment"],
5943      "macro-name": [
5944        {
5945          pattern: /(^#\s*define\s+)\w+\b(?!\()/i,
5946          lookbehind: true
5947        },
5948        {
5949          pattern: /(^#\s*define\s+)\w+\b(?=\()/i,
5950          lookbehind: true,
5951          alias: "function"
5952        }
5953      ],
5954      // highlight macro directives as keywords
5955      "directive": {
5956        pattern: /^(#\s*)[a-z]+/,
5957        lookbehind: true,
5958        alias: "keyword"
5959      },
5960      "directive-hash": /^#/,
5961      "punctuation": /##|\\(?=[\r\n])/,
5962      "expression": {
5963        pattern: /\S[\s\S]*/,
5964        inside: Prism.languages.c
5965      }
5966    }
5967  }
5968});
5969Prism.languages.insertBefore("c", "function", {
5970  // highlight predefined macros as constants
5971  "constant": /\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/
5972});
5973delete Prism.languages.c["boolean"];
5974(function(Prism2) {
5975  var keyword = /\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/;
5976  var modName = /\b(?!<keyword>)\w+(?:\s*\.\s*\w+)*\b/.source.replace(/<keyword>/g, function() {
5977    return keyword.source;
5978  });
5979  Prism2.languages.cpp = Prism2.languages.extend("c", {
5980    "class-name": [
5981      {
5982        pattern: RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!<keyword>)\w+/.source.replace(/<keyword>/g, function() {
5983          return keyword.source;
5984        })),
5985        lookbehind: true
5986      },
5987      // This is intended to capture the class name of method implementations like:
5988      //   void foo::bar() const {}
5989      // However! The `foo` in the above example could also be a namespace, so we only capture the class name if
5990      // it starts with an uppercase letter. This approximation should give decent results.
5991      /\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,
5992      // This will capture the class name before destructors like:
5993      //   Foo::~Foo() {}
5994      /\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,
5995      // This also intends to capture the class name of method implementations but here the class has template
5996      // parameters, so it can't be a namespace (until C++ adds generic namespaces).
5997      /\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/
5998    ],
5999    "keyword": keyword,
6000    "number": {
6001      pattern: /(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,
6002      greedy: true
6003    },
6004    "operator": />>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,
6005    "boolean": /\b(?:false|true)\b/
6006  });
6007  Prism2.languages.insertBefore("cpp", "string", {
6008    "module": {
6009      // https://en.cppreference.com/w/cpp/language/modules
6010      pattern: RegExp(
6011        /(\b(?:import|module)\s+)/.source + "(?:" + // header-name
6012        /"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source + "|" + // module name or partition or both
6013        /<mod-name>(?:\s*:\s*<mod-name>)?|:\s*<mod-name>/.source.replace(/<mod-name>/g, function() {
6014          return modName;
6015        }) + ")"
6016      ),
6017      lookbehind: true,
6018      greedy: true,
6019      inside: {
6020        "string": /^[<"][\s\S]+/,
6021        "operator": /:/,
6022        "punctuation": /\./
6023      }
6024    },
6025    "raw-string": {
6026      pattern: /R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,
6027      alias: "string",
6028      greedy: true
6029    }
6030  });
6031  Prism2.languages.insertBefore("cpp", "keyword", {
6032    "generic-function": {
6033      pattern: /\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,
6034      inside: {
6035        "function": /^\w+/,
6036        "generic": {
6037          pattern: /<[\s\S]+/,
6038          alias: "class-name",
6039          inside: Prism2.languages.cpp
6040        }
6041      }
6042    }
6043  });
6044  Prism2.languages.insertBefore("cpp", "operator", {
6045    "double-colon": {
6046      pattern: /::/,
6047      alias: "punctuation"
6048    }
6049  });
6050  Prism2.languages.insertBefore("cpp", "class-name", {
6051    // the base clause is an optional list of parent classes
6052    // https://en.cppreference.com/w/cpp/language/class
6053    "base-clause": {
6054      pattern: /(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,
6055      lookbehind: true,
6056      greedy: true,
6057      inside: Prism2.languages.extend("cpp", {})
6058    }
6059  });
6060  Prism2.languages.insertBefore("inside", "double-colon", {
6061    // All untokenized words that are not namespaces should be class names
6062    "class-name": /\b[a-z_]\w*\b(?!\s*::)/i
6063  }, Prism2.languages.cpp["base-clause"]);
6064})(Prism);
6065Prism.languages.json = {
6066  "property": {
6067    pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
6068    lookbehind: true,
6069    greedy: true
6070  },
6071  "string": {
6072    pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
6073    lookbehind: true,
6074    greedy: true
6075  },
6076  "comment": {
6077    pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
6078    greedy: true
6079  },
6080  "number": /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
6081  "punctuation": /[{}[\],]/,
6082  "operator": /:/,
6083  "boolean": /\b(?:false|true)\b/,
6084  "null": {
6085    pattern: /\bnull\b/,
6086    alias: "keyword"
6087  }
6088};
6089Prism.languages.webmanifest = Prism.languages.json;
6090Prism.languages.sql = {
6091  "comment": {
6092    pattern: /(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,
6093    lookbehind: true
6094  },
6095  "variable": [
6096    {
6097      pattern: /@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,
6098      greedy: true
6099    },
6100    /@[\w.$]+/
6101  ],
6102  "string": {
6103    pattern: /(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,
6104    greedy: true,
6105    lookbehind: true
6106  },
6107  "identifier": {
6108    pattern: /(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,
6109    greedy: true,
6110    lookbehind: true,
6111    inside: {
6112      "punctuation": /^`|`$/
6113    }
6114  },
6115  "function": /\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,
6116  // Should we highlight user defined functions too?
6117  "keyword": /\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,
6118  "boolean": /\b(?:FALSE|NULL|TRUE)\b/i,
6119  "number": /\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,
6120  "operator": /[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,
6121  "punctuation": /[;[\]()`,.]/
6122};
6123(function(Prism2) {
6124  var keywords = /\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;
vendor: 5,049 bytes, lines 6124-6259
6124?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/;
6125  var classNamePrefix = /(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source;
6126  var className = {
6127    pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),
6128    lookbehind: true,
6129    inside: {
6130      "namespace": {
6131        pattern: /^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,
6132        inside: {
6133          "punctuation": /\./
6134        }
6135      },
6136      "punctuation": /\./
6137    }
6138  };
6139  Prism2.languages.java = Prism2.languages.extend("clike", {
6140    "string": {
6141      pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,
6142      lookbehind: true,
6143      greedy: true
6144    },
6145    "class-name": [
6146      className,
6147      {
6148        // variables, parameters, and constructor references
6149        // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
6150        pattern: RegExp(/(^|[^\w.])/.source + classNamePrefix + /[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),
6151        lookbehind: true,
6152        inside: className.inside
6153      },
6154      {
6155        // class names based on keyword
6156        // this to support class names (or generic parameters) which do not contain a lower case letter (also works for methods)
6157        pattern: RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source + classNamePrefix + /[A-Z]\w*\b/.source),
6158        lookbehind: true,
6159        inside: className.inside
6160      }
6161    ],
6162    "keyword": keywords,
6163    "function": [
6164      Prism2.languages.clike.function,
6165      {
6166        pattern: /(::\s*)[a-z_]\w*/,
6167        lookbehind: true
6168      }
6169    ],
6170    "number": /\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,
6171    "operator": {
6172      pattern: /(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,
6173      lookbehind: true
6174    },
6175    "constant": /\b[A-Z][A-Z_\d]+\b/
6176  });
6177  Prism2.languages.insertBefore("java", "string", {
6178    "triple-quoted-string": {
6179      // http://openjdk.java.net/jeps/355#Description
6180      pattern: /"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,
6181      greedy: true,
6182      alias: "string"
6183    },
6184    "char": {
6185      pattern: /'(?:\\.|[^'\\\r\n]){1,6}'/,
6186      greedy: true
6187    }
6188  });
6189  Prism2.languages.insertBefore("java", "class-name", {
6190    "annotation": {
6191      pattern: /(^|[^.])@\w+(?:\s*\.\s*\w+)*/,
6192      lookbehind: true,
6193      alias: "punctuation"
6194    },
6195    "generics": {
6196      pattern: /<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,
6197      inside: {
6198        "class-name": className,
6199        "keyword": keywords,
6200        "punctuation": /[<>(),.:]/,
6201        "operator": /[?&|]/
6202      }
6203    },
6204    "import": [
6205      {
6206        pattern: RegExp(/(\bimport\s+)/.source + classNamePrefix + /(?:[A-Z]\w*|\*)(?=\s*;)/.source),
6207        lookbehind: true,
6208        inside: {
6209          "namespace": className.inside.namespace,
6210          "punctuation": /\./,
6211          "operator": /\*/,
6212          "class-name": /\w+/
6213        }
6214      },
6215      {
6216        pattern: RegExp(/(\bimport\s+static\s+)/.source + classNamePrefix + /(?:\w+|\*)(?=\s*;)/.source),
6217        lookbehind: true,
6218        alias: "static",
6219        inside: {
6220          "namespace": className.inside.namespace,
6221          "static": /\b\w+$/,
6222          "punctuation": /\./,
6223          "operator": /\*/,
6224          "class-name": /\w+/
6225        }
6226      }
6227    ],
6228    "namespace": {
6229      pattern: RegExp(
6230        /(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!<keyword>)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(/<keyword>/g, function() {
6231          return keywords.source;
6232        })
6233      ),
6234      lookbehind: true,
6235      inside: {
6236        "punctuation": /\./
6237      }
6238    }
6239  });
6240})(Prism);
6241Prism.languages.go = Prism.languages.extend("clike", {
6242  "string": {
6243    pattern: /(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,
6244    lookbehind: true,
6245    greedy: true
6246  },
6247  "keyword": /\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,
6248  "boolean": /\b(?:_|false|iota|nil|true)\b/,
6249  "number": [
6250    // binary and octal integers
6251    /\b0(?:b[01_]+|o[0-7_]+)i?\b/i,
6252    // hexadecimal integers and floats
6253    /\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,
6254    // decimal integers and floats
6255    /(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i
6256  ],
6257  "operator": /[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,
6258  "builtin": /\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/
6259});
6260Prism.languages.insertBefore("go", "string", {
6261  "char": {
6262    pattern: /'(?:\\.|[^'\\\r\n]){0,10}'/,
6263    greedy: true
6264  }
6265});
6266delete Prism.languages.go["class-name"];
6267(function(Prism2) {
6268  var multilineComment = /\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|<self>)*\*\//.source;
6269  for (var i = 0; i < 2; i++) {
6270    multilineComment = multilineComment.replace(/<self>/g, function() {
6271      return multilineComment;
6272    });
6273  }
6274  multilineComment = multilineComment.replace(/<self>/g, function() {
6275    return /[^\s\S]/.source;
6276  });
6277  Prism2.languages.rust = {
6278    "comment": [
6279      {
6280        pattern: RegExp(/(^|[^\\])/.source + multilineComment),
6281        lookbehind: true,
6282        greedy: true
6283      },
6284      {
6285        pattern: /(^|[^\\:])\/\/.*/,
6286        lookbehind: true,
6287        greedy: true
6288      }
6289    ],
6290    "string": {
6291      pattern: /b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,
6292      greedy: true
6293    },
6294    "char": {
6295      pattern: /b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,
6296      greedy: true
6297    },
6298    "attribute": {
6299      pattern: /#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,
6300      greedy: true,
6301      alias: "attr-name",
6302      inside: {
6303        "string": null
6304        // see below
6305      }
6306    },
6307    // Closure params should not be confused with bitwise OR |
6308    "closure-params": {
6309      pattern: /([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,
6310      lookbehind: true,
6311      greedy: true,
6312      inside: {
6313        "closure-punctuation": {
6314          pattern: /^\||\|$/,
6315          alias: "punctuation"
6316        },
6317        rest: null
6318        // see below
6319      }
6320    },
6321    "lifetime-annotation": {
6322      pattern: /'\w+/,
6323      alias: "symbol"
6324    },
6325    "fragment-specifier": {
6326      pattern: /(\$\w+:)[a-z]+/,
6327      lookbehind: true,
6328      alias: "punctuation"
6329    },
6330    "variable": /\$\w+/,
6331    "function-definition": {
6332      pattern: /(\bfn\s+)\w+/,
6333      lookbehind: true,
6334      alias: "function"
6335    },
6336    "type-definition": {
6337      pattern: /(\b(?:enum|struct|trait|type|union)\s+)\w+/,
6338      lookbehind: true,
6339      alias: "class-name"
6340    },
6341    "module-declaration": [
6342      {
6343        pattern: /(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,
6344        lookbehind: true,
6345        alias: "namespace"
6346      },
6347      {
6348        pattern: /(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,
6349        lookbehind: true,
6350        alias: "namespace",
6351        inside: {
6352          "punctuation": /::/
6353        }
6354      }
6355    ],
6356    "keyword": [
6357      // https://github.com/rust-lang/reference/blob/master/src/keywords.md
6358      /\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,
6359      // primitives and str
6360      // https://doc.rust-lang.org/stable/rust-by-example/primitives.html
6361      /\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/
6362    ],
6363    // functions can technically start with an upper-case letter, but this will introduce a lot of false positives
6364    // and Rust's naming conventions recommend snake_case anyway.
6365    // https://doc.rust-lang.org/1.0.0/style/style/naming/README.html
6366    "function": /\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,
6367    "macro": {
6368      pattern: /\b\w+!/,
6369      alias: "property"
6370    },
6371    "constant": /\b[A-Z_][A-Z_\d]+\b/,
6372    "class-name": /\b[A-Z]\w*\b/,
6373    "namespace": {
6374      pattern: /(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,
6375      inside: {
6376        "punctuation": /::/
6377      }
6378    },
6379    // Hex, oct, bin, dec numbers with visual separators and type suffix
6380    "number": /\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,
6381    "boolean": /\b(?:false|true)\b/,
6382    "punctuation": /->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,
6383    "operator": /[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<<?=?|>>?=?|[@?]/
6384  };
6385  Prism2.languages.rust["closure-params"].inside.rest = Prism2.languages.rust;
6386  Prism2.languages.rust["attribute"].inside["string"] = Prism2.languages.rust["string"];
6387})(Prism);
6388(function(Prism2) {
6389  var comment = /\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/;
6390  var constant = [
6391    {
6392      pattern: /\b(?:false|true)\b/i,
6393      alias: "boolean"
6394    },
6395    {
6396      pattern: /(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,
6397      greedy: true,
6398      lookbehind: true
6399    },
6400    {
6401      pattern: /(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,
6402      greedy: true,
6403      lookbehind: true
6404    },
6405    /\b(?:null)\b/i,
6406    /\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/
6407  ];
6408  var number = /\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i;
6409  var operator = /<?=>|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/;
6410  var punctuation2 = /[{}\[\](),:;]/;
6411  Prism2.languages.php = {
6412    "delimiter": {
6413      pattern: /\?>$|^<\?(?:php(?=\s)|=)?/i,
6414      alias: "important"
6415    },
6416    "comment": comment,
6417    "variable": /\$+(?:\w+\b|(?=\{))/,
6418    "package": {
6419      pattern: /(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
6420      lookbehind: true,
6421      inside: {
6422        "punctuation": /\\/
6423      }
6424    },
6425    "class-name-definition": {
6426      pattern: /(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,
6427      lookbehind: true,
6428      alias: "class-name"
6429    },
6430    "function-definition": {
vendor: 4,150 bytes, lines 6431-6557
6431      pattern: /(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,
6432      lookbehind: true,
6433      alias: "function"
6434    },
6435    "keyword": [
6436      {
6437        pattern: /(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,
6438        alias: "type-casting",
6439        greedy: true,
6440        lookbehind: true
6441      },
6442      {
6443        pattern: /([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,
6444        alias: "type-hint",
6445        greedy: true,
6446        lookbehind: true
6447      },
6448      {
6449        pattern: /(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,
6450        alias: "return-type",
6451        greedy: true,
6452        lookbehind: true
6453      },
6454      {
6455        pattern: /\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,
6456        alias: "type-declaration",
6457        greedy: true
6458      },
6459      {
6460        pattern: /(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,
6461        alias: "type-declaration",
6462        greedy: true,
6463        lookbehind: true
6464      },
6465      {
6466        pattern: /\b(?:parent|self|static)(?=\s*::)/i,
6467        alias: "static-context",
6468        greedy: true
6469      },
6470      {
6471        // yield from
6472        pattern: /(\byield\s+)from\b/i,
6473        lookbehind: true
6474      },
6475      // `class` is always a keyword unlike other keywords
6476      /\bclass\b/i,
6477      {
6478        // https://www.php.net/manual/en/reserved.keywords.php
6479        //
6480        // keywords cannot be preceded by "->"
6481        // the complex lookbehind means `(?<!(?:->|::)\s*)`
6482        pattern: /((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,
6483        lookbehind: true
6484      }
6485    ],
6486    "argument-name": {
6487      pattern: /([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,
6488      lookbehind: true
6489    },
6490    "class-name": [
6491      {
6492        pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,
6493        greedy: true,
6494        lookbehind: true
6495      },
6496      {
6497        pattern: /(\|\s*)\b[a-z_]\w*(?!\\)\b/i,
6498        greedy: true,
6499        lookbehind: true
6500      },
6501      {
6502        pattern: /\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,
6503        greedy: true
6504      },
6505      {
6506        pattern: /(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,
6507        alias: "class-name-fully-qualified",
6508        greedy: true,
6509        lookbehind: true,
6510        inside: {
6511          "punctuation": /\\/
6512        }
6513      },
6514      {
6515        pattern: /(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,
6516        alias: "class-name-fully-qualified",
6517        greedy: true,
6518        inside: {
6519          "punctuation": /\\/
6520        }
6521      },
6522      {
6523        pattern: /(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
6524        alias: "class-name-fully-qualified",
6525        greedy: true,
6526        lookbehind: true,
6527        inside: {
6528          "punctuation": /\\/
6529        }
6530      },
6531      {
6532        pattern: /\b[a-z_]\w*(?=\s*\$)/i,
6533        alias: "type-declaration",
6534        greedy: true
6535      },
6536      {
6537        pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
6538        alias: ["class-name-fully-qualified", "type-declaration"],
6539        greedy: true,
6540        inside: {
6541          "punctuation": /\\/
6542        }
6543      },
6544      {
6545        pattern: /\b[a-z_]\w*(?=\s*::)/i,
6546        alias: "static-context",
6547        greedy: true
6548      },
6549      {
6550        pattern: /(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,
6551        alias: ["class-name-fully-qualified", "static-context"],
6552        greedy: true,
6553        inside: {
6554          "punctuation": /\\/
6555        }
6556      },
6557      {
6558        pattern: /([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,
6559        alias: "type-hint",
6560        greedy: true,
6561        lookbehind: true
6562      },
6563      {
6564        pattern: /([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,
6565        alias: ["class-name-fully-qualified", "type-hint"],
6566        greedy: true,
6567        lookbehind: true,
6568        inside: {
6569          "punctuation": /\\/
6570        }
6571      },
6572      {
6573        pattern: /(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,
6574        alias: "return-type",
6575        greedy: true,
6576        lookbehind: true
6577      },
6578      {
6579        pattern: /(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,
6580        alias: ["class-name-fully-qualified", "return-type"],
6581        greedy: true,
6582        lookbehind: true,
6583        inside: {
6584          "punctuation": /\\/
6585        }
6586      }
6587    ],
6588    "constant": constant,
6589    "function": {
6590      pattern: /(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,
6591      lookbehind: true,
6592      inside: {
6593        "punctuation": /\\/
6594      }
6595    },
6596    "property": {
6597      pattern: /(->\s*)\w+/,
6598      lookbehind: true
6599    },
6600    "number": number,
6601    "operator": operator,
6602    "punctuation": punctuation2
6603  };
6604  var string_interpolation = {
6605    pattern: /\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,
6606    lookbehind: true,
6607    inside: Prism2.languages.php
6608  };
6609  var string = [
6610    {
6611      pattern: /<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,
6612      alias: "nowdoc-string",
6613      greedy: true,
6614      inside: {
6615        "delimiter": {
6616          pattern: /^<<<'[^']+'|[a-z_]\w*;$/i,
6617          alias: "symbol",
6618          inside: {
6619            "punctuation": /^<<<'?|[';]$/
6620          }
6621        }
6622      }
6623    },
6624    {
6625      pattern: /<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,
6626      alias: "heredoc-string",
6627      greedy: true,
6628      inside: {
6629        "delimiter": {
6630          pattern: /^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,
6631          alias: "symbol",
6632          inside: {
6633            "punctuation": /^<<<"?|[";]$/
6634          }
6635        },
6636        "interpolation": string_interpolation
6637      }
6638    },
6639    {
6640      pattern: /`(?:\\[\s\S]|[^\\`])*`/,
6641      alias: "backtick-quoted-string",
6642      greedy: true
6643    },
6644    {
6645      pattern: /'(?:\\[\s\S]|[^\\'])*'/,
6646      alias: "single-quoted-string",
6647      greedy: true
6648    },
6649    {
6650      pattern: /"(?:\\[\s\S]|[^\\"])*"/,
6651      alias: "double-quoted-string",
6652      greedy: true,
6653      inside: {
6654        "interpolation": string_interpolation
6655      }
6656    }
6657  ];
6658  Prism2.languages.insertBefore("php", "variable", {
6659    "string": string,
6660    "attribute": {
6661      pattern: /#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,
6662      greedy: true,
6663      inside: {
6664        "attribute-content": {
6665          pattern: /^(#\[)[\s\S]+(?=\]$)/,
6666          lookbehind: true,
6667          // inside can appear subset of php
6668          inside: {
6669            "comment": comment,
6670            "string": string,
6671            "attribute-class-name": [
6672              {
6673                pattern: /([^:]|^)\b[a-z_]\w*(?!\\)\b/i,
6674                alias: "class-name",
6675                greedy: true,
6676                lookbehind: true
6677              },
6678              {
6679                pattern: /([^:]|^)(?:\\?\b[a-z_]\w*)+/i,
6680                alias: [
6681                  "class-name",
6682                  "class-name-fully-qualified"
6683                ],
6684                greedy: true,
6685                lookbehind: true,
6686                inside: {
6687                  "punctuation": /\\/
6688                }
6689              }
6690            ],
6691            "constant": constant,
6692            "number": number,
6693            "operator": operator,
6694            "punctuation": punctuation2
6695          }
6696        },
6697        "delimiter": {
6698          pattern: /^#\[|\]$/,
6699          alias: "punctuation"
6700        }
6701      }
6702    }
6703  });
6704  Prism2.hooks.add("before-tokenize", function(env) {
6705    if (!/<\?/.test(env.code)) {
6706      return;
6707    }
6708    var phpPattern = /<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g;
6709    Prism2.languages["markup-templating"].buildPlaceholders(env, "php", phpPattern);
6710  });
6711  Prism2.hooks.add("after-tokenize", function(env) {
6712    Prism2.languages["markup-templating"].tokenizePlaceholders(env, "php");
6713  });
6714})(Prism);
6715(function(Prism2) {
6716  var anchorOrAlias = /[*&][^\s[\]{},]+/;
6717  var tag2 = /!(?:<[\w\-%#;/?:@&=+$,.!~*'()[\]]+>|(?:[a-zA-Z\d-]*!)?[\w\-%#;/?:@&=+$.~*'()]+)?/;
6718  var properties = "(?:" + tag2.source + "(?:[ 	]+" + anchorOrAlias.source + ")?|" + anchorOrAlias.source + "(?:[ 	]+" + tag2.source + ")?)";
6719  var plainKey = /(?:[^\s\x00-\x08\x0e-\x1f!"#%&'*,\-:>?@[\]`{|}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]|[?:-]<PLAIN>)(?:[ \t]*(?:(?![#:])<PLAIN>|:<PLAIN>))*/.source.replace(/<PLAIN>/g, function() {
6720    return /[^\s\x00-\x08\x0e-\x1f,[\]{}\x7f-\x84\x86-\x9f\ud800-\udfff\ufffe\uffff]/.source;
6721  });
6722  var string = /"(?:[^"\\\r\n]|\\.)*"|'(?:[^'\\\r\n]|\\.)*'/.source;
6723  function createValuePattern(value, flags) {
6724    flags = (flags || "").replace(/m/g, "") + "m";
6725    var pattern = /([:\-,[{]\s*(?:\s<<prop>>[ \t]+)?)(?:<<value>>
6725)(?=[ \t]*(?:$|,|\]|\}|(?:[\r\n]\s*)?#))/.source.replace(/<<prop>>/g, function() {
6726      return properties;
6727    }).replace(/<<value>>/g, function() {
6728      return value;
6729    });
6730    return RegExp(pattern, flags);
6731  }
6732  Prism2.languages.yaml = {
6733    "scalar": {
6734      pattern: RegExp(/([\-:]\s*(?:\s<<prop>>[ \t]+)?[|>])[ \t]*(?:((?:\r?\n|\r)[ \t]+)\S[^\r\n]*(?:\2[^\r\n]+)*)/.source.replace(/<<prop>>/g, function() {
6735        return properties;
6736      })),
6737      lookbehind: true,
6738      alias: "string"
6739    },
6740    "comment": /#.*/,
6741    "key": {
6742      pattern: RegExp(/((?:^|[:\-,[{\r\n?])[ \t]*(?:<<prop>>[ \t]+)?)<<key>>(?=\s*:\s)/.source.replace(/<<prop>>/g, function() {
6743        return properties;
6744      }).replace(/<<key>>/g, function() {
6745        return "(?:" + plainKey + "|" + string + ")";
6746      })),
6747      lookbehind: true,
6748      greedy: true,
6749      alias: "atrule"
6750    },
6751    "directive": {
6752      pattern: /(^[ \t]*)%.+/m,
6753      lookbehind: true,
6754      alias: "important"
6755    },
6756    "datetime": {
6757      pattern: createValuePattern(/\d{4}-\d\d?-\d\d?(?:[tT]|[ \t]+)\d\d?:\d{2}:\d{2}(?:\.\d*)?(?:[ \t]*(?:Z|[-+]\d\d?(?::\d{2})?))?|\d{4}-\d{2}-\d{2}|\d\d?:\d{2}(?::\d{2}(?:\.\d*)?)?/.source),
6758      lookbehind: true,
6759      alias: "number"
6760    },
6761    "boolean": {
6762      pattern: createValuePattern(/false|true/.source, "i"),
6763      lookbehind: true,
6764      alias: "important"
6765    },
6766    "null": {
6767      pattern: createValuePattern(/null|~/.source, "i"),
6768      lookbehind: true,
6769      alias: "important"
6770    },
6771    "string": {
6772      pattern: createValuePattern(string),
6773      lookbehind: true,
6774      greedy: true
6775    },
6776    "number": {
6777      pattern: createValuePattern(/[+-]?(?:0x[\da-f]+|0o[0-7]+|(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?|\.inf|\.nan)/.source, "i"),
6778      lookbehind: true
6779    },
6780    "tag": tag2,
6781    "important": anchorOrAlias,
6782    "punctuation": /---|[:[\]{}\-,|>?]|\.\.\./
6783  };
6784  Prism2.languages.yml = Prism2.languages.yaml;
6785})(Prism);
6786(function(Prism2) {
6787  function getPlaceholder(language, index) {
6788    return "___" + language.toUpperCase() + index + "___";
6789  }
6790  Object.defineProperties(Prism2.languages["markup-templating"] = {}, {
6791    buildPlaceholders: {
6792      /**
6793       * Tokenize all inline templating expressions matching `placeholderPattern`.
6794       *
6795       * If `replaceFilter` is provided, only matches of `placeholderPattern` for which `replaceFilter` returns
6796       * `true` will be replaced.
6797       *
6798       * @param {object} env The environment of the `before-tokenize` hook.
6799       * @param {string} language The language id.
6800       * @param {RegExp} placeholderPattern The matches of this pattern will be replaced by placeholders.
6801       * @param {(match: string) => boolean} [replaceFilter]
6802       */
6803      value: function(env, language, placeholderPattern, replaceFilter) {
6804        if (env.language !== language) {
6805          return;
6806        }
6807        var tokenStack = env.tokenStack = [];
6808        env.code = env.code.replace(placeholderPattern, function(match) {
6809          if (typeof replaceFilter === "function" && !replaceFilter(match)) {
6810            return match;
6811          }
6812          var i = tokenStack.length;
6813          var placeholder;
6814          while (env.code.indexOf(placeholder = getPlaceholder(language, i)) !== -1) {
6815            ++i;
6816          }
6817          tokenStack[i] = match;
6818          return placeholder;
6819        });
6820        env.grammar = Prism2.languages.markup;
6821      }
6822    },
6823    tokenizePlaceholders: {
6824      /**
6825       * Replace placeholders with proper tokens after tokenizing.
6826       *
6827       * @param {object} env The environment of the `after-tokenize` hook.
6828       * @param {string} language The language id.
6829       */
6830      value: function(env, language) {
6831        if (env.language !== language || !env.tokenStack) {
6832          return;
6833        }
6834        env.grammar = Prism2.languages[language];
6835        var j = 0;
6836        var keys = Object.keys(env.tokenStack);
6837        function walkTokens(tokens) {
6838          for (var i = 0; i < tokens.length; i++) {
6839            if (j >= keys.length) {
6840              break;
6841            }
6842            var token = tokens[i];
6843            if (typeof token === "string" || token.content && typeof token.content === "string") {
6844              var k = keys[j];
6845              var t = env.tokenStack[k];
6846              var s = typeof token === "string" ? token : token.content;
6847              var placeholder = getPlaceholder(language, k);
6848              var index = s.indexOf(placeholder);
6849              if (index > -1) {
6850                ++j;
6851                var before = s.substring(0, index);
6852                var middle = new Prism2.Token(language, Prism2.tokenize(t, env.grammar), "language-" + language, t);
6853                var after = s.substring(index + placeholder.length);
6854                var replacement = [];
6855                if (before) {
6856                  replacement.push.apply(replacement, walkTokens([before]));
6857                }
6858                replacement.push(middle);
6859                if (after) {
6860                  replacement.push.apply(replacement, walkTokens([after]));
6861                }
6862                if (typeof token === "string") {
6863                  tokens.splice.apply(tokens, [i, 1].concat(replacement));
6864                } else {
6865                  token.content = replacement;
6866                }
6867              }
6868            } else if (token.content) {
6869              walkTokens(token.content);
6870            }
6871          }
6872          return tokens;
6873        }
6874        walkTokens(env.tokens);
6875      }
6876    }
6877  });
6878})(Prism);
6879const LINK_ICON_CODE = `<svg class="md-link-icon" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true" fill="currentColor"><path d="m7.775 3.275 1.25-1.25a3.5 3.5 0 1 1 4.95 4.95l-2.5 2.5a3.5 3.5 0 0 1-4.95 0 .751.751 0 0 1 .018-1.042.751.751 0 0 1 1.042-.018 1.998 1.998 0 0 0 2.83 0l2.5-2.5a2.002 2.002 0 0 0-2.83-2.83l-1.25 1.25a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042Zm-4.69 9.64a1.998 1.998 0 0 0 2.83 0l1.25-1.25a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042l-1.25 1.25a3.5 3.5 0 1 1-4.95-4.95l2.5-2.5a3.5 3.5 0 0 1 4.95 0 .751.751 0 0 1-.018 1.042.751.751 0 0 1-1.042.018 1.998 1.998 0 0 0-2.83 0l-2.5 2.5a1.998 1.998 0 0 0 0 2.83Z"></path></svg>`;
6880const COPY_ICON_CODE = `
6881<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 15 15" color="currentColor" aria-hidden="true" aria-label="Copy" stroke-width="1.3" width="15" height="15">
6882  <path fill="currentColor" d="M12.728 4.545v8.182H4.545V4.545zm0 -0.909H4.545a0.909 0.909 0 0 0 -0.909 0.909v8.182a0.909 0.909 0 0 0 0.909 0.909h8.182a0.909 0.909 0 0 0 0.909 -0.909V4.545a0.909 0.909 0 0 0 -0.909 -0.909"/>
6883  <path fill="currentColor" d="M1.818 8.182H0.909V1.818a0.909 0.909 0 0 1 0.909 -0.909h6.364v0.909H1.818Z"/>
6884</svg>
6885
6886`;
6887const CHECK_ICON_CODE = `<svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 17 17" aria-hidden="true" aria-label="Copied" fill="none" stroke="currentColor" stroke-width="1.3">
6888  <path d="m13.813 4.781 -7.438 7.438 -3.188 -3.188"/>
6889</svg>
6890`;
6891const COPY_BUTTON_CODE = `<button title="copy" class="copy_code_button">
6892  <span class="copy-text">${COPY_ICON_CODE}</span>
6893  <span class="check">${CHECK_ICON_CODE}</span>
6894</button>`;
6895const escape_test = /[&<>"']/;
6896const escape_replace = new RegExp(escape_test.source, "g");
6897const escape_test_no_encode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
6898const escape_replace_no_encode = new RegExp(escape_test_no_encode.source, "g");
6899const escape_replacements = {
6900  "&": "&amp;",
6901  "<": "&lt;",
6902  ">": "&gt;",
6903  '"': "&quot;",
6904  "'": "&#39;"
6905};
6906const get_escape_replacement = (ch) => escape_replacements[ch] || "";
6907function escape(html2, encode) {
6908  if (encode) {
6909    if (escape_test.test(html2)) {
6910      return html2.replace(escape_replace, get_escape_replacement);
6911    }
6912  } else {
6913    if (escape_test_no_encode.test(html2)) {
6914      return html2.replace(escape_replace_no_encode, get_escape_replacement);
6915    }
6916  }
6917  return html2;
6918}
6919function createLatexTokenizer(delimiters) {
6920  const delimiterPatterns = delimiters.map((delimiter) => ({
6921    start: new RegExp(delimiter.left.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&")),
6922    end: new RegExp(delimiter.right.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&"))
6923  }));
6924  return {
6925    name: "latex",
6926    level: "block",
6927    start(src) {
6928      for (const pattern of delimiterPatterns) {
6929        const match = src.match(pattern.start);
6930        if (match) {
6931          return match.index;
6932        }
6933      }
6934      return -1;
6935    },
6936    tokenizer(src, tokens) {
6937      for (const pattern of delimiterPatterns) {
6938        const match = new RegExp(
6939          `${pattern.start.source}([\\s\\S]+?)${pattern.end.source}`
6940        ).exec(src);
6941        if (match) {
6942          return {
6943            type: "latex",
6944            raw: match[0],
6945            text: match[1].trim()
6946          };
6947        }
6948      }
6949    },
6950    renderer(token) {
6951      return `<div class="latex-block">${token.text}</div>`;
6952    }
6953  };
6954}
6955function createMermaidTokenizer() {
6956  return {
6957    name: "mermaid",
6958    level: "block",
6959    start(src) {
6960      var _a;
6961      return (_a = src.match(/^```mermaid\s*\n/)) == null ? void 0 : _a.index;
6962    },
6963    tokenizer(src) {
6964      const match = /^```mermaid\s*\n([\s\S]*?)```\s*(?:\n|$)/.exec(src);
6965      if (match) {
6966        return {
6967          type: "mermaid",
6968          raw: match[0],
6969          text: match[1].trim()
6970        };
6971      }
6972      return void 0;
6973    },
6974    renderer(token) {
6975      return `<div class="mermaid">${token.text}</div>
6976`;
6977    }
6978  };
6979}
6980const renderer = {
6981  code(code, infostring, escaped) {
6982    var _a;
6983    const lang = ((_a = (infostring ?? "").match(/\S*/)) == null ? void 0 : _a[0]) ?? "";
6984    code = code.replace(/\n$/, "") + "\n";
6985    if (!lang || lang === "mermaid") {
6986      return '<div class="code_wrap">' + COPY_BUTTON_CODE + "<pre><code>" + (escaped ? code : escape(code, true)) + "</code></pre></div>\n";
6987    }
6988    return '<div class="code_wrap">' + COPY_BUTTON_CODE + '<pre><code class="language-' + escape(lang) + '">' + (escaped ? code : escape(code, true)) + "</code></pre></div>\n";
6989  }
6990};
6991const slugger = new BananaSlug();
6992function create_marked({
6993  header_links,
6994  line_breaks,
6995  latex_delimiters
6996}) {
6997  const marked2 = new Marked();
6998  marked2.use(
6999    {
7000      gfm: true,
7001      pedantic: false,
7002      breaks: line_breaks
7003    },
7004    markedHighlight({
7005      highlight: (code, lang) => {
7006        var _a;
7007        if ((_a = prismExports.languages) == null ? void 0 : _a[lang]) {
7008          return prismExports.highlight(code, prismExports.languages[lang], lang);
7009        }
7010        return code;
7011      }
7012    }),
7013    { renderer }
7014  );
7015  if (header_links) {
7016    marked2.use(gfmHeadingId());
7017    marked2.use({
7018      extensions: [
7019        {
7020          name: "heading",
7021          level: "block",
7022          renderer(token) {
7023            const raw = token.raw.toLowerCase().trim().replace(/<[!\/a-z].*?>/gi, "");
7024            const id = "h" + slugger.slug(raw);
7025            const level = token.depth;
7026            const text2 = this.parser.parseInline(token.tokens);
7027            return `<h${level} id="${id}"><a class="md-header-anchor" href="#${id}">${LINK_ICON_CODE}</a>${text2}</h${level}>
7028`;
7029          }
7030        }
7031      ]
7032    });
7033  }
7034  const mermaidTokenizer = createMermaidTokenizer();
7035  const latexTokenizer = createLatexTokenizer(latex_delimiters);
7036  marked2.use({
7037    extensions: [mermaidTokenizer, latexTokenizer]
7038  });
7039  return marked2;
7040}
7041const cloneDeep = (value) => {
7042  return JSON.parse(JSON.stringify(value));
7043};
7044const isElement = (value) => {
7045  return value.nodeType === 1;
7046};
7047const isElementFunky = (value) => {
7048  return FUNKY_TAG_NAMES.has(value.tagName);
7049};
7050const isElementAction = (value) => {
7051  return "action" in value;
7052};
7053const isElementIframe = (value) => {
7054  return value.tagName === "IFRAME";
7055};
7056const isElementFormAction = (value) => {
7057  return "formAction" in value;
7058};
7059const isElementHyperlink = (value) => {
7060  return "protocol" in value;
7061};
7062const isScriptOrDataUrl = /* @__PURE__ */ (() => {
7063  const re = /^(?:\w+script|data):/i;
7064  return (url) => {
7065    return re.test(url);
7066  };
7067})();
7068const isScriptOrDataUrlLoose = /* @__PURE__ */ (() => {
7069  const re = /(?:script|data):/i;
7070  return (url) => {
7071    return re.test(url);
7072  };
7073})();
7074const mergeMaps = (maps) => {
7075  const merged = {};
7076  for (let i = 0, l = maps.length; i < l; i++) {
7077    const map = maps[i];
7078    for (const key in map) {
7079      if (!merged[key]) {
7080        merged[key] = map[key];
7081      } else {
7082        merged[key] = merged[key].concat(map[key]);
7083      }
7084    }
7085  }
7086  return merged;
7087};
7088const traverseElementsBasic = (parent, callback) => {
7089  let current = parent.firstChild;
7090  while (current) {
7091    const next = current.nextSibling;
7092    if (isElement(current)) {
7093      callback(current, parent);
7094      if (current.parentNode) {
7095        traverseElementsBasic(current, callback);
7096      }
7097    }
7098    current = next;
7099  }
7100};
7101const traverseElementsIterator = (parent, callback) => {
7102  const iterator = document.createNodeIterator(parent, NodeFilter.SHOW_ELEMENT);
7103  let current;
7104  while (current = iterator.nextNode()) {
7105    const parent2 = current.parentNode;
7106    if (!parent2)
7107      continue;
7108    callback(current, parent2);
7109  }
7110};
7111const traverseElements = (parent, callback) => {
7112  const hasIterator = !!globalThis.document && !!globalThis.document.createNodeIterator;
7113  if (hasIterator) {
7114    return traverseElementsIterator(parent, callback);
7115  } else {
7116    return traverseElementsBasic(parent, callback);
7117  }
7118};
7119const HTML_ELEMENTS_ALLOW = [
7120  "a",
7121  "abbr",
7122  "acronym",
7123  "address",
7124  "area",
7125  "article",
7126  "aside",
7127  "audio",
7128  "b",
7129  "bdi",
7130  "bdo",
7131  "bgsound",
7132  "big",
7133  "blockquote",
7134  "body",
7135  "br",
7136  "button",
7137  "canvas",
7138  "caption",
7139  "center",
7140  "cite",
7141  "code",
7142  "col",
7143  "colgroup",
7144  "datalist",
7145  "dd",
7146  "del",
7147  "details",
7148  "dfn",
7149  "dialog",
7150  "dir",
7151  "div",
7152  "dl",
7153  "dt",
7154  "em",
7155  "fieldset",
7156  "figcaption",
7157  "figure",
7158  "font",
7159  "footer",
7160  "form",
7161  "h1",
7162  "h2",
7163  "h3",
7164  "h4",
7165  "h5",
7166  "h6",
7167  "head",
7168  "header",
7169  "hgroup",
7170  "hr",
7171  "html",
7172  "i",
7173  "img",
7174  "input",
7175  "ins",
7176  "kbd",
7177  "keygen",
7178  "label",
7179  "layer",
7180  "legend",
7181  "li",
7182  "link",
7183  "listing",
7184  "main",
7185  "map",
7186  "mark",
7187  "marquee",
7188  "menu",
7189  "meta",
7190  "meter",
7191  "nav",
7192  "nobr",
7193  "ol",
7194  "optgroup",
7195  "option",
7196  "output",
7197  "p",
7198  "picture",
7199  "popup",
7200  "pre",
7201  "progress",
7202  "q",
7203  "rb",
7204  "rp",
7205  "rt",
7206  "rtc",
7207  "ruby",
7208  "s",
7209  "samp",
7210  "section",
7211  "select",
7212  "selectmenu",
7213  "small",
7214  "source",
7215  "span",
7216  "strike",
7217  "strong",
7218  "style",
7219  "sub",
7220  "summary",
7221  "sup",
7222  "table",
7223  "tbody",
7224  "td",
7225  "tfoot",
7226  "th",
7227  "thead",
7228  "time",
7229  "tr",
7230  "track",
7231  "tt",
7232  "u",
7233  "ul",
7234  "var",
7235  "video",
7236  "wbr"
7237];
7238const HTML_ELEMENTS_DISALLOW = [
7239  "basefont",
7240  "command",
7241  "data",
7242  "iframe",
7243  "image",
7244  "plaintext",
7245  "portal",
7246  "slot",
7247  // 'template', //TODO: Not exactly correct to never allow this, too strict
7248  "textarea",
7249  "title",
7250  "xmp"
7251];
7252const HTML_ELEMENTS = /* @__PURE__ */ new Set([
7253  ...HTML_ELEMENTS_ALLOW,
7254  ...HTML_ELEMENTS_DISALLOW
7255]);
7256const SVG_ELEMENTS_ALLOW = [
7257  "svg",
7258  "a",
7259  "altglyph",
7260  "altglyphdef",
7261  "altglyphitem",
7262  "animatecolor",
7263  "animatemotion",
7264  "animatetransform",
7265  "circle",
7266  "clippath",
7267  "defs",
7268  "desc",
7269  "ellipse",
7270  "filter",
7271  "font",
7272  "g",
7273  "glyph",
7274  "glyphref",
7275  "hkern",
7276  "image",
7277  "line",
7278  "lineargradient",
7279  "marker",
7280  "mask",
7281  "metadata",
7282  "mpath",
7283  "path",
7284  "pattern",
7285  "polygon",
7286  "polyline",
7287  "radialgradient",
7288  "rect",
7289  "stop",
7290  "style",
7291  "switch",
7292  "symbol",
7293  "text",
7294  "textpath",
7295  "title",
7296  "tref",
7297  "tspan",
7298  "view",
7299  "vkern",
7300  /* FILTERS */
7301  "feBlend",
7302  "feColorMatrix",
7303  "feComponentTransfer",
7304  "feComposite",
7305  "feConvolveMatrix",
7306  "feDiffuseLighting",
7307  "feDisplacementMap",
7308  "feDistantLight",
7309  "feFlood",
7310  "feFuncA",
7311  "feFuncB",
7312  "feFuncG",
7313  "feFuncR",
7314  "feGaussianBlur",
7315  "feImage",
7316  "feMerge",
7317  "feMergeNode",
7318  "feMorphology",
7319  "feOffset",
7320  "fePointLight",
7321  "feSpecularLighting",
7322  "feSpotLight",
7323  "feTile",
7324  "feTurbulence"
7325];
7326const SVG_ELEMENTS_DISALLOW = [
7327  "animate",
7328  "color-profile",
7329  "cursor",
7330  "discard",
7331  "fedropshadow",
7332  "font-face",
7333  "font-face-format",
7334  "font-face-name",
7335  "font-face-src",
7336  "font-face-uri",
7337  "foreignobject",
7338  "hatch",
7339  "hatchpath",
7340  "mesh",
7341  "meshgradient",
7342  "meshpatch",
7343  "meshrow",
7344  "missing-glyph",
7345  "script",
7346  "set",
7347  "solidcolor",
7348  "unknown",
7349  "use"
7350];
7351const SVG_ELEMENTS = /* @__PURE__ */ new Set([
7352  ...SVG_ELEMENTS_ALLOW,
7353  ...SVG_ELEMENTS_DISALLOW
7354]);
7355const MATH_ELEMENTS_ALLOW = [
7356  "math",
7357  "menclose",
7358  "merror",
7359  "mfenced",
7360  "mfrac",
7361  "mglyph",
7362  "mi",
7363  "mlabeledtr",
7364  "mmultiscripts",
7365  "mn",
7366  "mo",
7367  "mover",
7368  "mpadded",
7369  "mphantom",
7370  "mroot",
7371  "mrow",
7372  "ms",
7373  "mspace",
7374  "msqrt",
7375  "mstyle",
7376  "msub",
7377  "msup",
7378  "msubsup",
7379  "mtable",
7380  "mtd",
7381  "mtext",
7382  "mtr",
7383  "munder",
7384  "munderover"
7385];
7386const MATH_ELEMENTS_DISALLOW = [
7387  "maction",
7388  "maligngroup",
7389  "malignmark",
7390  "mlongdiv",
7391  "mscarries",
7392  "mscarry",
7393  "msgroup",
7394  "mstack",
7395  "msline",
7396  "msrow",
7397  "semantics",
7398  "annotation",
7399  "annotation-xml",
7400  "mprescripts",
7401  "none"
7402];
7403const MATH_ELEMENTS = /* @__PURE__ */ new Set([
7404  ...MATH_ELEMENTS_ALLOW,
7405  ...MATH_ELEMENTS_DISALLOW
7406]);
7407const HTML_ATTRIBUTES_ALLOW = [
7408  "abbr",
7409  "accept",
7410  "accept-charset",
7411  "accesskey",
7412  "action",
7413  "align",
7414  "alink",
7415  "allow",
7416  "allowfullscreen",
7417  "alt",
7418  "anchor",
7419  "archive",
7420  "as",
7421  "async",
7422  "autocapitalize",
7423  "autocomplete",
7424  "autocorrect",
7425  "autofocus",
7426  "autopictureinpicture",
7427  "autoplay",
7428  "axis",
7429  "background",
7430  "behavior",
7431  "bgcolor",
7432  "border",
7433  "bordercolor",
7434  "capture",
7435  "cellpadding",
7436  "cellspacing",
7437  "challenge",
7438  "char",
7439  "charoff",
7440  "charset",
7441  "checked",
7442  "cite",
7443  "class",
7444  "classid",
7445  "clear",
7446  "code",
7447  "codebase",
7448  "codetype",
7449  "color",
7450  "cols",
7451  "colspan",
7452  "compact",
7453  "content",
7454  "contenteditable",
7455  "controls",
7456  "controlslist",
7457  "conversiondestination",
7458  "coords",
7459  "crossorigin",
7460  "csp",
7461  "data",
7462  "datetime",
7463  "declare",
7464  "decoding",
7465  "default",
7466  "defer",
7467  "dir",
7468  "direction",
7469  "dirname",
7470  "disabled",
7471  "disablepictureinpicture",
7472  "disableremoteplayback",
7473  "disallowdocumentaccess",
7474  "download",
7475  "draggable",
7476  "elementtiming",
7477  "enctype",
7478  "end",
7479  "enterkeyhint",
7480  "event",
7481  "exportparts",
7482  "face",
7483  "for",
7484  "form",
7485  "formaction",
7486  "formenctype",
7487  "formmethod",
7488  "formnovalidate",
7489  "formtarget",
7490  "frame",
7491  "frameborder",
7492  "headers",
7493  "height",
7494  "hidden",
7495  "high",
7496  "href",
7497  "hreflang",
7498  "hreftranslate",
7499  "hspace",
7500  "http-equiv",
7501  "id",
7502  "imagesizes",
7503  "imagesrcset",
7504  "importance",
7505  "impressiondata",
7506  "impressionexpiry",
7507  "incremental",
7508  "inert",
7509  "inputmode",
7510  "integrity",
7511  "invisible",
7512  "ismap",
7513  "keytype",
7514  "kind",
7515  "label",
7516  "lang",
7517  "language",
7518  "latencyhint",
7519  "leftmargin",
7520  "link",
7521  "list",
7522  "loading",
7523  "longdesc",
7524  "loop",
7525  "low",
7526  "lowsrc",
7527  "manifest",
7528  "marginheight",
7529  "marginwidth",
7530  "max",
7531  "maxlength",
7532  "mayscript",
7533  "media",
7534  "method",
7535  "min",
7536  "minlength",
7537  "multiple",
7538  "muted",
7539  "name",
7540  "nohref",
7541  "nomodule",
7542  "nonce",
7543  "noresize",
7544  "noshade",
7545  "novalidate",
7546  "nowrap",
7547  "object",
7548  "open",
7549  "optimum",
7550  "part",
7551  "pattern",
7552  "ping",
7553  "placeholder",
7554  "playsinline",
7555  "policy",
7556  "poster",
7557  "preload",
7558  "pseudo",
7559  "readonly",
7560  "referrerpolicy",
7561  "rel",
7562  "reportingorigin",
7563  "required",
7564  "resources",
7565  "rev",
7566  "reversed",
7567  "role",
7568  "rows",
7569  "rowspan",
7570  "rules",
7571  "sandbox",
7572  "scheme",
7573  "scope",
7574  "scopes",
7575  "scrollamount",
7576  "scrolldelay",
7577  "scrolling",
7578  "select",
7579  "selected",
7580  "shadowroot",
7581  "shadowrootdelegatesfocus",
7582  "shape",
7583  "size",
7584  "sizes",
7585  "slot",
7586  "span",
7587  "spellcheck",
7588  "src",
7589  "srclang",
7590  "srcset",
7591  "standby",
7592  "start",
7593  "step",
7594  "style",
7595  "summary",
7596  "tabindex",
7597  "target",
7598  "text",
7599  "title",
7600  "topmargin",
7601  "translate",
7602  "truespeed",
7603  "trusttoken",
7604  "type",
7605  "usemap",
7606  "valign",
7607  "value",
7608  "valuetype",
7609  "version",
7610  "virtualkeyboardpolicy",
7611  "vlink",
7612  "vspace",
7613  "webkitdirectory",
7614  "width",
7615  "wrap"
7616];
7617const SVG_ATTRIBUTES_ALLOW = [
7618  "accent-height",
7619  "accumulate",
7620  "additive",
7621  "alignment-baseline",
7622  "ascent",
7623  "attributename",
7624  "attributetype",
7625  "azimuth",
7626  "basefrequency",
7627  "baseline-shift",
7628  "begin",
7629  "bias",
7630  "by",
7631  "class",
7632  "clip",
7633  "clippathunits",
7634  "clip-path",
7635  "clip-rule",
7636  "color",
7637  "color-interpolation",
7638  "color-interpolation-filters",
7639  "color-profile",
7640  "color-rendering",
7641  "cx",
7642  "cy",
7643  "d",
7644  "dx",
7645  "dy",
7646  "diffuseconstant",
7647  "direction",
7648  "display",
7649  "divisor",
7650  "dominant-baseline",
7651  "dur",
7652  "edgemode",
7653  "elevation",
7654  "end",
7655  "fill",
7656  "fill-opacity",
7657  "fill-rule",
7658  "filter",
7659  "filterunits",
7660  "flood-color",
7661  "flood-opacity",
7662  "font-family",
7663  "font-size",
7664  "font-size-adjust",
7665  "font-stretch",
7666  "font-style",
7667  "font-variant",
7668  "font-weight",
7669  "fx",
7670  "fy",
7671  "g1",
7672  "g2",
7673  "glyph-name",
7674  "glyphref",
7675  "gradientunits",
7676  "gradienttransform",
7677  "height",
7678  "href",
7679  "id",
7680  "image-rendering",
7681  "in",
7682  "in2",
7683  "k",
7684  "k1",
7685  "k2",
7686  "k3",
7687  "k4",
7688  "kerning",
7689  "keypoints",
7690  "keysplines",
7691  "keytimes",
7692  "lang",
7693  "lengthadjust",
7694  "letter-spacing",
7695  "kernelmatrix",
7696  "kernelunitlength",
7697  "lighting-color",
7698  "local",
7699  "marker-end",
7700  "marker-mid",
7701  "marker-start",
7702  "markerheight",
7703  "markerunits",
7704  "markerwidth",
7705  "maskcontentunits",
7706  "maskunits",
7707  "max",
7708  "mask",
7709  "media",
7710  "method",
7711  "mode",
7712  "min",
7713  "name",
7714  "numoctaves",
7715  "offset",
7716  "operator",
7717  "opacity",
7718  "order",
7719  "orient",
7720  "orientation",
7721  "origin",
7722  "overflow",
7723  "paint-order",
7724  "path",
7725  "pathlength",
7726  "patterncontentunits",
7727  "patterntransform",
7728  "patternunits",
7729  "points",
7730  "preservealpha",
7731  "preserveaspectratio",
7732  "primitiveunits",
7733  "r",
7734  "rx",
7735  "ry",
7736  "radius",
7737  "refx",
7738  "refy",
7739  "repeatcount",
7740  "repeatdur",
7741  "restart",
7742  "result",
7743  "rotate",
7744  "scale",
7745  "seed",
7746  "shape-rendering",
7747  "specularconstant",
7748  "specularexponent",
7749  "spreadmethod",
7750  "startoffset",
7751  "stddeviation",
7752  "stitchtiles",
7753  "stop-color",
7754  "stop-opacity",
7755  "stroke-dasharray",
7756  "stroke-dashoffset",
7757  "stroke-linecap",
7758  "stroke-linejoin",
7759  "stroke-miterlimit",
7760  "stroke-opacity",
7761  "stroke",
7762  "stroke-width",
7763  "style",
7764  "surfacescale",
7765  "systemlanguage",
7766  "tabindex",
7767  "targetx",
7768  "targety",
7769  "transform",
7770  "transform-origin",
7771  "text-anchor",
7772  "text-decoration",
7773  "text-rendering",
7774  "textlength",
7775  "type",
7776  "u1",
7777  "u2",
7778  "unicode",
7779  "values",
7780  "viewbox",
7781  "visibility",
7782  "version",
7783  "vert-adv-y",
7784  "vert-origin-x",
7785  "vert-origin-y",
7786  "width",
7787  "word-spacing",
7788  "wrap",
7789  "writing-mode",
7790  "xchannelselector",
7791  "ychannelselector",
7792  "x",
7793  "x1",
7794  "x2",
7795  "xmlns",
7796  "y",
7797  "y1",
7798  "y2",
7799  "z",
7800  "zoomandpan"
7801];
7802const MATH_ATTRIBUTES_ALLOW = [
7803  "accent",
7804  "accentunder",
7805  "align",
7806  "bevelled",
7807  "close",
7808  "columnsalign",
7809  "columnlines",
7810  "columnspan",
7811  "denomalign",
7812  "depth",
7813  "dir",
7814  "display",
7815  "displaystyle",
7816  "encoding",
7817  "fence",
7818  "frame",
7819  "height",
7820  "href",
7821  "id",
7822  "largeop",
7823  "length",
7824  "linethickness",
7825  "lspace",
7826  "lquote",
7827  "mathbackground",
7828  "mathcolor",
7829  "mathsize",
7830  "mathvariant",
7831  "maxsize",
7832  "minsize",
7833  "movablelimits",
7834  "notation",
7835  "numalign",
7836  "open",
7837  "rowalign",
7838  "rowlines",
7839  "rowspacing",
7840  "rowspan",
7841  "rspace",
7842  "rquote",
7843  "scriptlevel",
7844  "scriptminsize",
7845  "scriptsizemultiplier",
7846  "selection",
7847  "separator",
7848  "separators",
7849  "stretchy",
7850  "subscriptshift",
7851  "supscriptshift",
7852  "symmetric",
7853  "voffset",
7854  "width",
7855  "xmlns"
7856];
7857const NAMESPACES = {
7858  HTML: "http://www.w3.org/1999/xhtml",
7859  SVG: "http://www.w3.org/2000/svg",
7860  MATH: "http://www.w3.org/1998/Math/MathML"
7861};
7862const NAMESPACES_ELEMENTS = {
7863  [NAMESPACES.HTML]: HTML_ELEMENTS,
7864  [NAMESPACES.SVG]: SVG_ELEMENTS,
7865  [NAMESPACES.MATH]: MATH_ELEMENTS
7866};
7867const NAMESPACES_ROOTS = {
7868  [NAMESPACES.HTML]: "html",
7869  [NAMESPACES.SVG]: "svg",
7870  [NAMESPACES.MATH]: "math"
7871};
7872const NAMESPACES_PREFIXES = {
7873  [NAMESPACES.HTML]: "",
7874  [NAMESPACES.SVG]: "svg:",
7875  [NAMESPACES.MATH]: "math:"
7876};
7877const FUNKY_TAG_NAMES = /* @__PURE__ */ new Set([
7878  "A",
7879  "AREA",
7880  "BUTTON",
7881  "FORM",
7882  "IFRAME",
7883  "INPUT"
7884]);
7885const DEFAULTS = {
7886  allowComments: true,
7887  allowCustomElements: false,
7888  allowUnknownMarkup: false,
7889  allowElements: [
7890    ...HTML_ELEMENTS_ALLOW,
7891    ...SVG_ELEMENTS_ALLOW.map((name) => `svg:${name}`),
7892    ...MATH_ELEMENTS_ALLOW.map((name) => `math:${name}`)
7893  ],
7894  allowAttributes: mergeMaps([
7895    Object.fromEntries(HTML_ATTRIBUTES_ALLOW.map((name) => [name, ["*"]])),
7896    Object.fromEntries(SVG_ATTRIBUTES_ALLOW.map((name) => [name, ["svg:*"]])),
7897    Object.fromEntries(MATH_ATTRIBUTES_ALLOW.map((name) => [name, ["math:*"]]))
7898  ])
7899};
7900var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
7901  if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
7902  return state.set(receiver, value), value;
7903};
7904var __classPrivateFieldGet = function(receiver, state, kind, f) {
7905  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
7906  return kind === "m" ? f : state.get(receiver);
7907};
7908var _Amuchina_configuration, _Amuchina_allowElements, _Amuchina_allowAttributes;
7909class Amuchina {
7910  /* CONSTRUCTOR */
7911  constructor(configuration = {}) {
7912    _Amuchina_configuration.set(this, void 0);
7913    _Amuchina_allowElements.set(this, void 0);
7914    _Amuchina_allowAttributes.set(this, void 0);
7915    this.getConfiguration = () => {
7916      return cloneDeep(__classPrivateFieldGet(this, _Amuchina_configuration, "f"));
7917    };
7918    this.sanitize = (input) => {
7919      const allowElements2 = __classPrivateFieldGet(this, _Amuchina_allowElements, "f");
7920      const allowAttributes2 = __classPrivateFieldGet(this, _Amuchina_allowAttributes, "f");
7921      traverseElements(input, (node, parent) => {
7922        const namespace = node.namespaceURI || NAMESPACES.HTML;
7923        const namespaceParent = parent["namespaceURI"] || NAMESPACES.HTML;
7924        const elements = NAMESPACES_ELEMENTS[namespace];
7925        const root = NAMESPACES_ROOTS[namespace];
7926        const prefix = NAMESPACES_PREFIXES[namespace];
7927        const tag2 = node.tagName.toLowerCase();
7928        const tagPrefixed = `${prefix}${tag2}`;
7929        const all = "*";
7930        const allPrefixed = `${prefix}${all}`;
7931        if (!elements.has(tag2) || !allowElements2.has(tagPrefixed) || namespace !== namespaceParent && tag2 !== root) {
7932          parent.removeChild(node);
7933        } else {
7934          const attributes = node.getAttributeNames();
7935          const attributesLength = attributes.length;
7936          if (attributesLength) {
7937            for (let i = 0; i < attributesLength; i++) {
7938              const attribute = attributes[i];
7939              const allowedValues = allowAttributes2[attribute];
7940              if (!allowedValues || !allowedValues.has(allPrefixed) && !allowedValues.has(tagPrefixed)) {
7941                node.removeAttribute(attribute);
7942              }
7943            }
7944            if (isElementFunky(node)) {
7945              if (isElementHyperlink(node)) {
7946                const href = node.getAttribute("href");
7947                if (href && isScriptOrDataUrlLoose(href) && isScriptOrDataUrl(node.protocol)) {
7948                  node.removeAttribute("href");
7949                }
7950              } else if (isElementAction(node)) {
7951                if (isScriptOrDataUrl(node.action)) {
7952                  node.removeAttribute("action");
7953                }
7954              } else if (isElementFormAction(node)) {
7955                if (isScriptOrDataUrl(node.formAction)) {
7956                  node.removeAttribute("formaction");
7957                }
7958              } else if (isElementIframe(node)) {
7959                if (isScriptOrDataUrl(node.src)) {
7960                  node.removeAttribute("formaction");
7961                }
7962                node.setAttribute("sandbox", "allow-scripts");
7963              }
7964            }
7965          }
7966        }
7967      });
7968      return input;
7969    };
7970    this.sanitizeFor = (element2, input) => {
7971      throw new Error('"sanitizeFor" is not implemented yet');
7972    };
7973    const { allowComments, allowCustomElements, allowUnknownMarkup, blockElements, dropElements, dropAttributes } = configuration;
7974    if (allowComments === false)
7975      throw new Error('A false "allowComments" is not supported yet');
7976    if (allowCustomElements)
7977      throw new Error('A true "allowCustomElements" is not supported yet');
7978    if (allowUnknownMarkup)
7979      throw new Error('A true "allowUnknownMarkup" is not supported yet');
7980    if (blockElements)
7981      throw new Error('"blockElements" is not supported yet, use "allowElements" instead');
7982    if (dropElements)
7983      throw new Error('"dropElements" is not supported yet, use "allowElements" instead');
7984    if (dropAttributes)
7985      throw new Error('"dropAttributes" is not supported yet, use "allowAttributes" instead');
7986    __classPrivateFieldSet(this, _Amuchina_configuration, cloneDeep(DEFAULTS));
7987    const { allowElements, allowAttributes } = configuration;
7988    if (allowElements)
7989      __classPrivateFieldGet(this, _Amuchina_configuration, "f").allowElements = configuration.allowElements;
7990    if (allowAttributes)
7991      __classPrivateFieldGet(this, _Amuchina_configuration, "f").allowAttributes = configuration.allowAttributes;
7992    __classPrivateFieldSet(this, _Amuchina_allowElements, new Set(__classPrivateFieldGet(this, _Amuchina_configuration, "f").allowElements));
7993    __classPrivateFieldSet(this, _Amuchina_allowAttributes, Object.fromEntries(Object.entries(__classPrivateFieldGet(this, _Amuchina_configuration, "f").allowAttributes || {}).map(([element2, attributes]) => [element2, new Set(attributes)])));
7994  }
7995}
7996_Amuchina_configuration = /* @__PURE__ */ new WeakMap(), _Amuchina_allowElements = /* @__PURE__ */ new WeakMap(), _Amuchina_allowAttributes = /* @__PURE__ */ new WeakMap();
7997Amuchina.getDefaultConfiguration = () => {
7998  return cloneDeep(DEFAULTS);
7999};
8000const is_external_url = (link2, root = location.href) => {
8001  try {
8002    return !!link2 && new URL(link2).origin !== new URL(root).origin;
8003  } catch (e) {
8004    return false;
8005  }
8006};
8007function sanitize(source) {
8008  const amuchina = new Amuchina();
8009  const node = new DOMParser().parseFromString(source, "text/html");
8010  walk_nodes(node.body, "A", (node2) => {
8011    if (node2 instanceof HTMLElement && "target" in node2) {
8012      if (is_external_url(node2.getAttribute("href"), location.href)) {
8013        node2.setAttribute("target", "_blank");
8014        node2.setAttribute("rel", "noopener noreferrer");
8015      }
8016    }
8017  });
8018  return amuchina.sanitize(node).body.innerHTML;
8019}
8020function walk_nodes(node, test, callback) {
8021  if (node && (node.nodeName === test || typeof test === "function")) {
8022    callback(node);
8023  }
8024  const children2 = (node == null ? void 0 : node.childNodes) || [];
8025  for (let i = 0; i < children2.length; i++) {
8026    walk_nodes(children2[i], test, callback);
8027  }
8028}
8029const standardHtmlTags = [
8030  "!--",
8031  "!doctype",
8032  "a",
8033  "abbr",
8034  "acronym",
8035  "address",
8036  "applet",
8037  "area",
8038  "article",
8039  "aside",
8040  "audio",
8041  "b",
8042  "base",
8043  "basefont",
8044  "bdi",
8045  "bdo",
8046  "big",
8047  "blockquote",
8048  "body",
8049  "br",
8050  "button",
8051  "canvas",
8052  "caption",
8053  "center",
8054  "cite",
8055  "code",
8056  "col",
8057  "colgroup",
8058  "data",
8059  "datalist",
8060  "dd",
8061  "del",
8062  "details",
8063  "dfn",
8064  "dialog",
8065  "dir",
8066  "div",
8067  "dl",
8068  "dt",
8069  "em",
8070  "embed",
8071  "fieldset",
8072  "figcaption",
8073  "figure",
8074  "font",
8075  "footer",
8076  "form",
8077  "frame",
8078  "frameset",
8079  "h1",
8080  "h2",
8081  "h3",
8082  "h4",
8083  "h5",
8084  "h6",
8085  "head",
8086  "header",
8087  "hgroup",
8088  "hr",
8089  "html",
8090  "i",
8091  "iframe",
8092  "img",
8093  "input",
8094  "ins",
8095  "kbd",
8096  "label",
8097  "legend",
8098  "li",
8099  "link",
8100  "main",
8101  "map",
8102  "mark",
8103  "menu",
8104  "meta",
8105  "meter",
8106  "nav",
8107  "noframes",
8108  "noscript",
8109  "object",
8110  "ol",
8111  "optgroup",
8112  "option",
8113  "output",
8114  "p",
8115  "param",
8116  "picture",
8117  "pre",
8118  "progress",
8119  "q",
8120  "rp",
8121  "rt",
8122  "ruby",
8123  "s",
8124  "samp",
8125  "script",
8126  "search",
8127  "section",
8128  "select",
8129  "small",
8130  "source",
8131  "span",
8132  "strike",
8133  "strong",
8134  "style",
8135  "sub",
8136  "summary",
8137  "sup",
8138  "svg",
8139  "table",
8140  "tbody",
8141  "td",
8142  "template",
8143  "textarea",
8144  "tfoot",
8145  "th",
8146  "thead",
8147  "time",
8148  "title",
8149  "tr",
8150  "track",
8151  "tt",
8152  "u",
8153  "ul",
8154  "var",
8155  "video",
8156  "wbr"
8157];
8158const svgTags = [
8159  // Base structural elements
8160  "g",
8161  "defs",
8162  "use",
8163  "symbol",
8164  // Shape elements
8165  "rect",
8166  "circle",
8167  "ellipse",
8168  "line",
8169  "polyline",
8170  "polygon",
8171  "path",
8172  "image",
8173  // Text elements
8174  "text",
8175  "tspan",
8176  "textPath",
8177  // Gradient and effects
8178  "linearGradient",
8179  "radialGradient",
8180  "stop",
8181  "pattern",
8182  "clipPath",
8183  "mask",
8184  "filter",
8185  // Filter effects
8186  "feBlend",
8187  "feColorMatrix",
8188  "feComponentTransfer",
8189  "feComposite",
8190  "feConvolveMatrix",
8191  "feDiffuseLighting",
8192  "feDisplacementMap",
8193  "feGaussianBlur",
8194  "feMerge",
8195  "feMorphology",
8196  "feOffset",
8197  "feSpecularLighting",
8198  "feTurbulence",
8199  "feMergeNode",
8200  "feFuncR",
8201  "feFuncG",
8202  "feFuncB",
8203  "feFuncA",
8204  "feDistantLight",
8205  "fePointLight",
8206  "feSpotLight",
8207  "feFlood",
8208  "feTile",
8209  // Animation elements
8210  "animate",
8211  "animateTransform",
8212  "animateMotion",
8213  "mpath",
8214  "set",
8215  // Interactive and other elements
8216  "view",
8217  "cursor",
8218  "foreignObject",
8219  "desc",
8220  "title",
8221  "metadata",
8222  "switch"
8223];
8224const standardHtmlAndSvgTags = [
8225  ...standardHtmlTags,
8226  ...svgTags.filter((tag2) => !standardHtmlTags.includes(tag2))
8227];
8228function create_fragment$V(ctx) {
8229  let span;
8230  return {
8231    c() {
8232      span = element("span");
8233      attr(span, "class", "md svelte-1m32c2s");
8234      toggle_class(
8235        span,
8236        "chatbot",
8237        /*chatbot*/
8238        ctx[0]
8239      );
8240      toggle_class(
8241        span,
8242        "prose",
8243        /*render_markdown*/
8244        ctx[1]
8245      );
8246    },
8247    m(target, anchor) {
8248      insert(target, span, anchor);
8249      span.innerHTML = /*html*/
8250      ctx[3];
8251      ctx[11](span);
8252    },
8253    p(ctx2, [dirty]) {
8254      if (dirty & /*html*/
8255      8) span.innerHTML = /*html*/
8256      ctx2[3];
8257      if (dirty & /*chatbot*/
8258      1) {
8259        toggle_class(
8260          span,
8261          "chatbot",
8262          /*chatbot*/
8263          ctx2[0]
8264        );
8265      }
8266      if (dirty & /*render_markdown*/
8267      2) {
8268        toggle_class(
8269          span,
8270          "prose",
8271          /*render_markdown*/
8272          ctx2[1]
8273        );
8274      }
8275    },
8276    i: noop,
8277    o: noop,
8278    d(detaching) {
8279      if (detaching) {
8280        detach(span);
8281      }
8282      ctx[11](null);
8283    }
8284  };
8285}
8286function escapeRegExp(string) {
8287  return string.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
8288}
8289function instance$E($$self, $$props, $$invalidate) {
8290  let { chatbot = true } = $$props;
8291  let { message } = $$props;
8292  let { sanitize_html = true } = $$props;
8293  let { latex_delimiters = [] } = $$props;
8294  let { render_markdown = true } = $$props;
8295  let { line_breaks = true } = $$props;
8296  let { header_links = false } = $$props;
8297  let { allow_tags = false } = $$props;
8298  let { theme_mode = "system" } = $$props;
8299  let el;
8300  let html2;
8301  let katex_loaded = false;
8302  const marked2 = create_marked({
8303    header_links,
8304    line_breaks,
8305    latex_delimiters: latex_delimiters || []
8306  });
8307  function has_math_syntax(text2) {
8308    if (!latex_delimiters || latex_delimiters.length === 0) {
8309      return false;
8310    }
8311    return latex_delimiters.some((delimiter) => text2.includes(delimiter.left) && text2.includes(delimiter.right));
8312  }
8313  function escapeTags(content, tagsToEscape) {
8314    if (tagsToEscape === true) {
8315      const tagRegex = /<\/?([a-zA-Z][a-zA-Z0-9-]*)([\s>])/g;
8316      return content.replace(tagRegex, (match, tagName, endChar) => {
8317        if (!standardHtmlAndSvgTags.includes(tagName.toLowerCase())) {
8318          return match.replace(/</g, "&lt;").replace(/>/g, "&gt;");
8319        }
8320        return match;
8321      });
8322    }
8323    if (Array.isArray(tagsToEscape)) {
8324      const tagPattern = tagsToEscape.map((tag2) => ({
8325        open: new RegExp(`<(${tag2})(\\s+[^>]*)?>`, "gi"),
8326        close: new RegExp(`</(${tag2})>`, "gi")
8327      }));
8328      let result = content;
8329      tagPattern.forEach((pattern) => {
8330        result = result.replace(pattern.open, (match) => match.replace(/</g, "&lt;").replace(/>/g, "&gt;"));
8331        result = result.replace(pattern.close, (match) => match.replace(/</g, "&lt;").replace(/>/g, "&gt;"));
8332      });
8333      return result;
8334    }
8335    return content;
8336  }
8337  function process_message(value) {
8338    let parsedValue = value;
8339    if (render_markdown) {
8340      const latexBlocks = [];
8341      latex_delimiters.forEach((delimiter, index) => {
8342        const leftDelimiter = escapeRegExp(delimiter.left);
8343        const rightDelimiter = escapeRegExp(delimiter.right);
8344        const regex2 = new RegExp(`${leftDelimiter}([\\s\\S]+?)${rightDelimiter}`, "g");
8345        parsedValue = parsedValue.replace(regex2, (match, p1) => {
8346          latexBlocks.push(match);
8347          return `%%%LATEX_BLOCK_${latexBlocks.length - 1}%%%`;
8348        });
8349      });
8350      parsedValue = marked2.parse(parsedValue);
8351      parsedValue = parsedValue.replace(/%%%LATEX_BLOCK_(\d+)%%%/g, (match, p1) => latexBlocks[parseInt(p1, 10)]);
8352    }
8353    if (allow_tags) {
8354      parsedValue = escapeTags(parsedValue, allow_tags);
8355    }
8356    if (sanitize_html && sanitize) {
8357      parsedValue = sanitize(parsedValue);
8358    }
8359    return parsedValue;
8360  }
8361  async function render_html(value) {
8362    if (latex_delimiters.length > 0 && value && has_math_syntax(value)) {
8363      if (!katex_loaded) {
8364        await Promise.all([Promise.resolve({              }), __vitePreload(() => import('./auto-render-DTMSUk0Z-BeunX3LV.js'),true              ?__vite__mapDeps([0,1]):void 0,import.meta.url)]).then(([, { default: render_math_in_element }]) => {
8365          katex_loaded = true;
8366          render_math_in_element(el, {
8367            delimiters: latex_delimiters,
8368            throwOnError: false
8369          });
8370        });
8371      } else {
8372        const { default: render_math_in_element } = await __vitePreload(async () => { const { default: render_math_in_element } = await import('./auto-render-DTMSUk0Z-BeunX3LV.js');return { default: render_math_in_element }},true              ?__vite__mapDeps([0,1]):void 0,import.meta.url);
8373        render_math_in_element(el, {
8374          delimiters: latex_delimiters,
8375          throwOnError: false
8376        });
8377      }
8378    }
8379    if (el) {
8380      const mermaidDivs = el.querySelectorAll(".mermaid");
8381      if (mermaidDivs.length > 0) {
8382        await tick();
8383        const { default: mermaid } = await __vitePreload(() => import('./mermaid.core-vMMZVCDT-alxhRXoZ.js'),true              ?__vite__mapDeps([2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]):void 0,import.meta.url).then((n) => n.bA);
8384        mermaid.initialize({
8385          startOnLoad: false,
8386          theme: theme_mode === "dark" ? "dark" : "default",
8387          securityLevel: "antiscript"
8388        });
8389        await mermaid.run({
8390          nodes: Array.from(mermaidDivs).map((node) => node)
8391        });
8392      }
8393    }
8394  }
8395  afterUpdate(async () => {
8396    if (el && document.body.contains(el)) {
8397      await render_html(message);
8398    } else {
8399      console.error("Element is not in the DOM");
8400    }
8401  });
8402  function span_binding($$value) {
8403    binding_callbacks[$$value ? "unshift" : "push"](() => {
8404      el = $$value;
8405      $$invalidate(2, el);
8406    });
8407  }
8408  $$self.$$set = ($$props2) => {
8409    if ("chatbot" in $$props2) $$invalidate(0, chatbot = $$props2.chatbot);
8410    if ("message" in $$props2) $$invalidate(4, message = $$props2.message);
8411    if ("sanitize_html" in $$props2) $$invalidate(5, sanitize_html = $$props2.sanitize_html);
8412    if ("latex_delimiters" in $$props2) $$invalidate(6, latex_delimiters = $$props2.latex_delimiters);
8413    if ("render_markdown" in $$props2) $$invalidate(1, render_markdown = $$props2.render_markdown);
8414    if ("line_breaks" in $$props2) $$invalidate(7, line_breaks = $$props2.line_breaks);
8415    if ("header_links" in $$props2) $$invalidate(8, header_links = $$props2.header_links);
8416    if ("allow_tags" in $$props2) $$invalidate(9, allow_tags = $$props2.allow_tags);
8417    if ("theme_mode" in $$props2) $$invalidate(10, theme_mode = $$props2.theme_mode);
8418  };
8419  $$self.$$.update = () => {
8420    if ($$self.$$.dirty & /*message*/
8421    16) {
8422      if (message && message.trim()) {
8423        $$invalidate(3, html2 = process_message(message));
8424      } else {
8425        $$invalidate(3, html2 = "");
8426      }
8427    }
8428  };
8429  return [
8430    chatbot,
8431    render_markdown,
8432    el,
8433    html2,
8434    message,
8435    sanitize_html,
8436    latex_delimiters,
8437    line_breaks,
8438    header_links,
8439    allow_tags,
8440    theme_mode,
8441    span_binding
8442  ];
8443}
8444class MarkdownCode extends SvelteComponent {
8445  constructor(options) {
8446    super();
8447    init(this, options, instance$E, create_fragment$V, safe_not_equal, {
8448      chatbot: 0,
8449      message: 4,
8450      sanitize_html: 5,
8451      latex_delimiters: 6,
8452      render_markdown: 1,
8453      line_breaks: 7,
8454      header_links: 8,
8455      allow_tags: 9,
8456      theme_mode: 10
8457    });
8458  }
8459}
8460function create_fragment$U(ctx) {
8461  let label_1;
8462  let span;
8463  let icon;
8464  let t0;
8465  let t1;
8466  let label_1_dir_value;
8467  let current;
8468  icon = new /*Icon*/
8469  ctx[1]({});
8470  return {
8471    c() {
8472      label_1 = element("label");
8473      span = element("span");
8474      create_component(icon.$$.fragment);
8475      t0 = space();
8476      t1 = text(
8477        /*label*/
8478        ctx[0]
8479      );
8480      attr(span, "class", "svelte-igqdol");
8481      attr(label_1, "for", "");
8482      attr(label_1, "data-testid", "block-label");
8483      attr(label_1, "dir", label_1_dir_value = /*rtl*/
8484      ctx[5] ? "rtl" : "ltr");
8485      attr(label_1, "class", "svelte-igqdol");
8486      toggle_class(label_1, "hide", !/*show_label*/
8487      ctx[2]);
8488      toggle_class(label_1, "sr-only", !/*show_label*/
8489      ctx[2]);
8490      toggle_class(
8491        label_1,
8492        "float",
8493        /*float*/
8494        ctx[4]
8495      );
8496      toggle_class(
8497        label_1,
8498        "hide-label",
8499        /*disable*/
8500        ctx[3]
8501      );
8502    },
8503    m(target, anchor) {
8504      insert(target, label_1, anchor);
8505      append(label_1, span);
8506      mount_component(icon, span, null);
8507      append(label_1, t0);
8508      append(label_1, t1);
8509      current = true;
8510    },
8511    p(ctx2, [dirty]) {
8512      if (!current || dirty & /*label*/
8513      1) set_data(
8514        t1,
8515        /*label*/
8516        ctx2[0]
8517      );
8518      if (!current || dirty & /*rtl*/
8519      32 && label_1_dir_value !== (label_1_dir_value = /*rtl*/
8520      ctx2[5] ? "rtl" : "ltr")) {
8521        attr(label_1, "dir", label_1_dir_value);
8522      }
8523      if (!current || dirty & /*show_label*/
8524      4) {
8525        toggle_class(label_1, "hide", !/*show_label*/
8526        ctx2[2]);
8527      }
8528      if (!current || dirty & /*show_label*/
8529      4) {
8530        toggle_class(label_1, "sr-only", !/*show_label*/
8531        ctx2[2]);
8532      }
8533      if (!current || dirty & /*float*/
8534      16) {
8535        toggle_class(
8536          label_1,
8537          "float",
8538          /*float*/
8539          ctx2[4]
8540        );
8541      }
8542      if (!current || dirty & /*disable*/
8543      8) {
8544        toggle_class(
8545          label_1,
8546          "hide-label",
8547          /*disable*/
8548          ctx2[3]
8549        );
8550      }
8551    },
8552    i(local) {
8553      if (current) return;
8554      transition_in(icon.$$.fragment, local);
8555      current = true;
8556    },
8557    o(local) {
8558      transition_out(icon.$$.fragment, local);
8559      current = false;
8560    },
8561    d(detaching) {
8562      if (detaching) {
8563        detach(label_1);
8564      }
8565      destroy_component(icon);
8566    }
8567  };
8568}
8569function instance$D($$self, $$props, $$invalidate) {
8570  let { label = null } = $$props;
8571  let { Icon } = $$props;
8572  let { show_label = true } = $$props;
8573  let { disable = false } = $$props;
8574  let { float = true } = $$props;
8575  let { rtl = false } = $$props;
8576  $$self.$$set = ($$props2) => {
8577    if ("label" in $$props2) $$invalidate(0, label = $$props2.label);
8578    if ("Icon" in $$props2) $$invalidate(1, Icon = $$props2.Icon);
8579    if ("show_label" in $$props2) $$invalidate(2, show_label = $$props2.show_label);
8580    if ("disable" in $$props2) $$invalidate(3, disable = $$props2.disable);
8581    if ("float" in $$props2) $$invalidate(4, float = $$props2.float);
8582    if ("rtl" in $$props2) $$invalidate(5, rtl = $$props2.rtl);
8583  };
8584  return [label, Icon, show_label, disable, float, rtl];
8585}
8586class BlockLabel extends SvelteComponent {
8587  constructor(options) {
8588    super();
8589    init(this, options, instance$D, create_fragment$U, safe_not_equal, {
8590      label: 0,
8591      Icon: 1,
8592      show_label: 2,
8593      disable: 3,
8594      float: 4,
8595      rtl: 5
8596    });
8597  }
8598}
8599function create_fragment$T(ctx) {
8600  let a;
8601  let a_target_value;
8602  let current;
8603  let mounted;
8604  let dispose;
8605  const default_slot_template = (
8606    /*#slots*/
8607    ctx[5].default
8608  );
8609  const default_slot = create_slot(
8610    default_slot_template,
8611    ctx,
8612    /*$$scope*/
8613    ctx[4],
8614    null
8615  );
8616  let a_levels = [
8617    { class: "download-link" },
8618    { href: (
8619      /*href*/
8620      ctx[0]
8621    ) },
8622    {
8623      target: a_target_value = typeof window !== "undefined" && window.__is_colab__ ? "_blank" : null
8624    },
8625    { rel: "noopener noreferrer" },
8626    { download: (
8627      /*download*/
8628      ctx[1]
8629    ) },
8630    /*$$restProps*/
8631    ctx[3]
8632  ];
8633  let a_data = {};
8634  for (let i = 0; i < a_levels.length; i += 1) {
8635    a_data = assign(a_data, a_levels[i]);
8636  }
8637  return {
8638    c() {
8639      a = element("a");
8640      if (default_slot) default_slot.c();
8641      set_attributes(a, a_data);
8642      set_style(a, "position", `relative`);
8643      toggle_class(a, "svelte-151nsdd", true);
8644    },
8645    m(target, anchor) {
8646      insert(target, a, anchor);
8647      if (default_slot) {
8648        default_slot.m(a, null);
8649      }
8650      current = true;
8651      if (!mounted) {
8652        dispose = listen(
8653          a,
8654          "click",
8655          /*dispatch*/
8656          ctx[2].bind(null, "click")
8657        );
8658        mounted = true;
8659      }
8660    },
8661    p(ctx2, [dirty]) {
8662      if (default_slot) {
8663        if (default_slot.p && (!current || dirty & /*$$scope*/
8664        16)) {
8665          update_slot_base(
8666            default_slot,
8667            default_slot_template,
8668            ctx2,
8669            /*$$scope*/
8670            ctx2[4],
8671            !current ? get_all_dirty_from_scope(
8672              /*$$scope*/
8673              ctx2[4]
8674            ) : get_slot_changes(
8675              default_slot_template,
8676              /*$$scope*/
8677              ctx2[4],
8678              dirty,
8679              null
8680            ),
8681            null
8682          );
8683        }
8684      }
8685      set_attributes(a, a_data = get_spread_update(a_levels, [
8686        { class: "download-link" },
8687        (!current || dirty & /*href*/
8688        1) && { href: (
8689          /*href*/
8690          ctx2[0]
8691        ) },
8692        { target: a_target_value },
8693        { rel: "noopener noreferrer" },
8694        (!current || dirty & /*download*/
8695        2) && { download: (
8696          /*download*/
8697          ctx2[1]
8698        ) },
8699        dirty & /*$$restProps*/
8700        8 && /*$$restProps*/
8701        ctx2[3]
8702      ]));
8703      set_style(a, "position", `relative`);
8704      toggle_class(a, "svelte-151nsdd", true);
8705    },
8706    i(local) {
8707      if (current) return;
8708      transition_in(default_slot, local);
8709      current = true;
8710    },
8711    o(local) {
8712      transition_out(default_slot, local);
8713      current = false;
8714    },
8715    d(detaching) {
8716      if (detaching) {
8717        detach(a);
8718      }
8719      if (default_slot) default_slot.d(detaching);
8720      mounted = false;
8721      dispose();
8722    }
8723  };
8724}
8725function instance$C($$self, $$props, $$invalidate) {
8726  const omit_props_names = ["href", "download"];
8727  let $$restProps = compute_rest_props($$props, omit_props_names);
8728  let { $$slots: slots = {}, $$scope } = $$props;
8729  let { href = void 0 } = $$props;
8730  let { download } = $$props;
8731  const dispatch2 = createEventDispatcher();
8732  $$self.$$set = ($$new_props) => {
8733    $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
8734    $$invalidate(3, $$restProps = compute_rest_props($$props, omit_props_names));
8735    if ("href" in $$new_props) $$invalidate(0, href = $$new_props.href);
8736    if ("download" in $$new_props) $$invalidate(1, download = $$new_props.download);
8737    if ("$$scope" in $$new_props) $$invalidate(4, $$scope = $$new_props.$$scope);
8738  };
8739  return [href, download, dispatch2, $$restProps, $$scope, slots];
8740}
8741class DownloadLink extends SvelteComponent {
8742  constructor(options) {
8743    super();
8744    init(this, options, instance$C, create_fragment$T, safe_not_equal, { href: 0, download: 1 });
8745  }
8746}
8747function create_if_block$l(ctx) {
8748  let span;
8749  let t;
8750  return {
8751    c() {
8752      span = element("span");
8753      t = text(
8754        /*label*/
8755        ctx[1]
8756      );
8757      attr(span, "class", "svelte-y0enk4");
8758    },
8759    m(target, anchor) {
8760      insert(target, span, anchor);
8761      append(span, t);
8762    },
8763    p(ctx2, dirty) {
8764      if (dirty & /*label*/
8765      2) set_data(
8766        t,
8767        /*label*/
8768        ctx2[1]
8769      );
8770    },
8771    d(detaching) {
8772      if (detaching) {
8773        detach(span);
8774      }
8775    }
8776  };
8777}
8778function create_fragment$S(ctx) {
8779  let button;
8780  let t0;
8781  let div;
8782  let switch_instance;
8783  let t1;
8784  let current;
8785  let mounted;
8786  let dispose;
8787  let if_block = (
8788    /*show_label*/
8789    ctx[2] && create_if_block$l(ctx)
8790  );
8791  var switch_value = (
8792    /*Icon*/
8793    ctx[0]
8794  );
8795  function switch_props(ctx2, dirty) {
8796    return {};
8797  }
8798  if (switch_value) {
8799    switch_instance = construct_svelte_component(switch_value, switch_props());
8800  }
8801  const default_slot_template = (
8802    /*#slots*/
8803    ctx[15].default
8804  );
8805  const default_slot = create_slot(
8806    default_slot_template,
8807    ctx,
8808    /*$$scope*/
8809    ctx[14],
8810    null
8811  );
8812  return {
8813    c() {
8814      button = element("button");
8815      if (if_block) if_block.c();
8816      t0 = space();
8817      div = element("div");
8818      if (switch_instance) create_component(switch_instance.$$.fragment);
8819      t1 = space();
8820      if (default_slot) default_slot.c();
8821      attr(div, "class", "svelte-y0enk4");
8822      toggle_class(
8823        div,
8824        "x-small",
8825        /*size*/
8826        ctx[4] === "x-small"
8827      );
8828      toggle_class(
8829        div,
8830        "small",
8831        /*size*/
8832        ctx[4] === "small"
8833      );
8834      toggle_class(
8835        div,
8836        "large",
8837        /*size*/
8838        ctx[4] === "large"
8839      );
8840      toggle_class(
8841        div,
8842        "medium",
8843        /*size*/
8844        ctx[4] === "medium"
8845      );
8846      attr(button, "class", "icon-button svelte-y0enk4");
8847      button.disabled = /*disabled*/
8848      ctx[7];
8849      attr(
8850        button,
8851        "aria-label",
8852        /*label*/
8853        ctx[1]
8854      );
8855      attr(
8856        button,
8857        "aria-haspopup",
8858        /*hasPopup*/
8859        ctx[8]
8860      );
8861      attr(
8862        button,
8863        "title",
8864        /*label*/
8865        ctx[1]
8866      );
8867      toggle_class(
8868        button,
8869        "pending",
8870        /*pending*/
8871        ctx[3]
8872      );
8873      toggle_class(
8874        button,
8875        "padded",
8876        /*padded*/
8877        ctx[5]
8878      );
8879      toggle_class(
8880        button,
8881        "highlight",
8882        /*highlight*/
8883        ctx[6]
8884      );
8885      toggle_class(
8886        button,
8887        "transparent",
8888        /*transparent*/
8889        ctx[9]
8890      );
8891      set_style(
8892        button,
8893        "--border-color",
8894        /*border*/
8895        ctx[11]
8896      );
8897      set_style(button, "color", !/*disabled*/
8898      ctx[7] && /*_color*/
8899      ctx[12] ? (
8900        /*_color*/
8901        ctx[12]
8902      ) : "var(--block-label-text-color)");
8903      set_style(button, "--bg-color", !/*disabled*/
8904      ctx[7] ? (
8905        /*background*/
8906        ctx[10]
8907      ) : "auto");
8908    },
8909    m(target, anchor) {
8910      insert(target, button, anchor);
8911      if (if_block) if_block.m(button, null);
8912      append(button, t0);
8913      append(button, div);
8914      if (switch_instance) mount_component(switch_instance, div, null);
8915      append(div, t1);
8916      if (default_slot) {
8917        default_slot.m(div, null);
8918      }
8919      current = true;
8920      if (!mounted) {
8921        dispose = listen(
8922          button,
8923          "click",
8924          /*click_handler*/
8925          ctx[16]
8926        );
8927        mounted = true;
8928      }
8929    },
8930    p(ctx2, [dirty]) {
8931      if (
8932        /*show_label*/
8933        ctx2[2]
8934      ) {
8935        if (if_block) {
8936          if_block.p(ctx2, dirty);
8937        } else {
8938          if_block = create_if_block$l(ctx2);
8939          if_block.c();
8940          if_block.m(button, t0);
8941        }
8942      } else if (if_block) {
8943        if_block.d(1);
8944        if_block = null;
8945      }
8946      if (dirty & /*Icon*/
8947      1 && switch_value !== (switch_value = /*Icon*/
8948      ctx2[0])) {
8949        if (switch_instance) {
8950          group_outros();
8951          const old_component = switch_instance;
8952          transition_out(old_component.$$.fragment, 1, 0, () => {
8953            destroy_component(old_component, 1);
8954          });
8955          check_outros();
8956        }
8957        if (switch_value) {
8958          switch_instance = construct_svelte_component(switch_value, switch_props());
8959          create_component(switch_instance.$$.fragment);
8960          transition_in(switch_instance.$$.fragment, 1);
8961          mount_component(switch_instance, div, t1);
8962        } else {
8963          switch_instance = null;
8964        }
8965      }
8966      if (default_slot) {
8967        if (default_slot.p && (!current || dirty & /*$$scope*/
8968        16384)) {
8969          update_slot_base(
8970            default_slot,
8971            default_slot_template,
8972            ctx2,
8973            /*$$scope*/
8974            ctx2[14],
8975            !current ? get_all_dirty_from_scope(
8976              /*$$scope*/
8977              ctx2[14]
8978            ) : get_slot_changes(
8979              default_slot_template,
8980              /*$$scope*/
8981              ctx2[14],
8982              dirty,
8983              null
8984            ),
8985            null
8986          );
8987        }
8988      }
8989      if (!current || dirty & /*size*/
8990      16) {
8991        toggle_class(
8992          div,
8993          "x-small",
8994          /*size*/
8995          ctx2[4] === "x-small"
8996        );
8997      }
8998      if (!current || dirty & /*size*/
8999      16) {
9000        toggle_class(
9001          div,
9002          "small",
9003          /*size*/
9004          ctx2[4] === "small"
9005        );
9006      }
9007      if (!current || dirty & /*size*/
9008      16) {
9009        toggle_class(
9010          div,
9011          "large",
9012          /*size*/
9013          ctx2[4] === "large"
9014        );
9015      }
9016      if (!current || dirty & /*size*/
9017      16) {
9018        toggle_class(
9019          div,
9020          "medium",
9021          /*size*/
9022          ctx2[4] === "medium"
9023        );
9024      }
9025      if (!current || dirty & /*disabled*/
9026      128) {
9027        button.disabled = /*disabled*/
9028        ctx2[7];
9029      }
9030      if (!current || dirty & /*label*/
9031      2) {
9032        attr(
9033          button,
9034          "aria-label",
9035          /*label*/
9036          ctx2[1]
9037        );
9038      }
9039      if (!current || dirty & /*hasPopup*/
9040      256) {
9041        attr(
9042          button,
9043          "aria-haspopup",
9044          /*hasPopup*/
9045          ctx2[8]
9046        );
9047      }
9048      if (!current || dirty & /*label*/
9049      2) {
9050        attr(
9051          button,
9052          "title",
9053          /*label*/
9054          ctx2[1]
9055        );
9056      }
9057      if (!current || dirty & /*pending*/
9058      8) {
9059        toggle_class(
9060          button,
9061          "pending",
9062          /*pending*/
9063          ctx2[3]
9064        );
9065      }
9066      if (!current || dirty & /*padded*/
9067      32) {
9068        toggle_class(
9069          button,
9070          "padded",
9071          /*padded*/
9072          ctx2[5]
9073        );
9074      }
9075      if (!current || dirty & /*highlight*/
9076      64) {
9077        toggle_class(
9078          button,
9079          "highlight",
9080          /*highlight*/
9081          ctx2[6]
9082        );
9083      }
9084      if (!current || dirty & /*transparent*/
9085      512) {
9086        toggle_class(
9087          button,
9088          "transparent",
9089          /*transparent*/
9090          ctx2[9]
9091        );
9092      }
9093      if (dirty & /*border*/
9094      2048) {
9095        set_style(
9096          button,
9097          "--border-color",
9098          /*border*/
9099          ctx2[11]
9100        );
9101      }
9102      if (dirty & /*disabled, _color*/
9103      4224) {
9104        set_style(button, "color", !/*disabled*/
9105        ctx2[7] && /*_color*/
9106        ctx2[12] ? (
9107          /*_color*/
9108          ctx2[12]
9109        ) : "var(--block-label-text-color)");
9110      }
9111      if (dirty & /*disabled, background*/
9112      1152) {
9113        set_style(button, "--bg-color", !/*disabled*/
9114        ctx2[7] ? (
9115          /*background*/
9116          ctx2[10]
9117        ) : "auto");
9118      }
9119    },
9120    i(local) {
9121      if (current) return;
9122      if (switch_instance) transition_in(switch_instance.$$.fragment, local);
9123      transition_in(default_slot, local);
9124      current = true;
9125    },
9126    o(local) {
9127      if (switch_instance) transition_out(switch_instance.$$.fragment, local);
9128      transition_out(default_slot, local);
9129      current = false;
9130    },
9131    d(detaching) {
9132      if (detaching) {
9133        detach(button);
9134      }
9135      if (if_block) if_block.d();
9136      if (switch_instance) destroy_component(switch_instance);
9137      if (default_slot) default_slot.d(detaching);
9138      mounted = false;
9139      dispose();
9140    }
9141  };
9142}
9143function instance$B($$self, $$props, $$invalidate) {
9144  let _color;
9145  let { $$slots: slots = {}, $$scope } = $$props;
9146  let { Icon } = $$props;
9147  let { label = "" } = $$props;
9148  let { show_label = false } = $$props;
9149  let { pending = false } = $$props;
9150  let { size = "small" } = $$props;
9151  let { padded = true } = $$props;
9152  let { highlight = false } = $$props;
9153  let { disabled = false } = $$props;
9154  let { hasPopup = false } = $$props;
9155  let { color = "var(--block-label-text-color)" } = $$props;
9156  let { transparent = false } = $$props;
9157  let { background = "var(--block-background-fill)" } = $$props;
9158  let { border = "transparent" } = $$props;
9159  function click_handler(event) {
9160    bubble.call(this, $$self, event);
9161  }
9162  $$self.$$set = ($$props2) => {
9163    if ("Icon" in $$props2) $$invalidate(0, Icon = $$props2.Icon);
9164    if ("label" in $$props2) $$invalidate(1, label = $$props2.label);
9165    if ("show_label" in $$props2) $$invalidate(2, show_label = $$props2.show_label);
9166    if ("pending" in $$props2) $$invalidate(3, pending = $$props2.pending);
9167    if ("size" in $$props2) $$invalidate(4, size = $$props2.size);
9168    if ("padded" in $$props2) $$invalidate(5, padded = $$props2.padded);
9169    if ("highlight" in $$props2) $$invalidate(6, highlight = $$props2.highlight);
9170    if ("disabled" in $$props2) $$invalidate(7, disabled = $$props2.disabled);
9171    if ("hasPopup" in $$props2) $$invalidate(8, hasPopup = $$props2.hasPopup);
9172    if ("color" in $$props2) $$invalidate(13, color = $$props2.color);
9173    if ("transparent" in $$props2) $$invalidate(9, transparent = $$props2.transparent);
9174    if ("background" in $$props2) $$invalidate(10, background = $$props2.background);
9175    if ("border" in $$props2) $$invalidate(11, border = $$props2.border);
9176    if ("$$scope" in $$props2) $$invalidate(14, $$scope = $$props2.$$scope);
9177  };
9178  $$self.$$.update = () => {
9179    if ($$self.$$.dirty & /*highlight, color*/
9180    8256) {
9181      $$invalidate(12, _color = highlight ? "var(--color-accent)" : color);
9182    }
9183  };
9184  return [
9185    Icon,
9186    label,
9187    show_label,
9188    pending,
9189    size,
9190    padded,
9191    highlight,
9192    disabled,
9193    hasPopup,
9194    transparent,
9195    background,
9196    border,
9197    _color,
9198    color,
9199    $$scope,
9200    slots,
9201    click_handler
9202  ];
9203}
9204class IconButton extends SvelteComponent {
9205  constructor(options) {
9206    super();
9207    init(this, options, instance$B, create_fragment$S, safe_not_equal, {
9208      Icon: 0,
9209      label: 1,
9210      show_label: 2,
9211      pending: 3,
9212      size: 4,
9213      padded: 5,
9214      highlight: 6,
9215      disabled: 7,
9216      hasPopup: 8,
9217      color: 13,
9218      transparent: 9,
9219      background: 10,
9220      border: 11
9221    });
9222  }
9223}
9224function create_fragment$R(ctx) {
9225  let div1;
9226  let div0;
9227  let current;
9228  const default_slot_template = (
9229    /*#slots*/
9230    ctx[5].default
9231  );
9232  const default_slot = create_slot(
9233    default_slot_template,
9234    ctx,
9235    /*$$scope*/
9236    ctx[4],
9237    null
9238  );
9239  return {
9240    c() {
9241      div1 = element("div");
9242      div0 = element("div");
9243      if (default_slot) default_slot.c();
9244      attr(div0, "class", "icon svelte-3w3rth");
9245      attr(div1, "class", "empty svelte-3w3rth");
9246      attr(div1, "aria-label", "Empty value");
9247      toggle_class(
9248        div1,
9249        "small",
9250        /*size*/
9251        ctx[0] === "small"
9252      );
9253      toggle_class(
9254        div1,
9255        "large",
9256        /*size*/
9257        ctx[0] === "large"
9258      );
9259      toggle_class(
9260        div1,
9261        "unpadded_box",
9262        /*unpadded_box*/
9263        ctx[1]
9264      );
9265      toggle_class(
9266        div1,
9267        "small_parent",
9268        /*parent_height*/
9269        ctx[3]
9270      );
9271    },
9272    m(target, anchor) {
9273      insert(target, div1, anchor);
9274      append(div1, div0);
9275      if (default_slot) {
9276        default_slot.m(div0, null);
9277      }
9278      ctx[6](div1);
9279      current = true;
9280    },
9281    p(ctx2, [dirty]) {
9282      if (default_slot) {
9283        if (default_slot.p && (!current || dirty & /*$$scope*/
9284        16)) {
9285          update_slot_base(
9286            default_slot,
9287            default_slot_template,
9288            ctx2,
9289            /*$$scope*/
9290            ctx2[4],
9291            !current ? get_all_dirty_from_scope(
9292              /*$$scope*/
9293              ctx2[4]
9294            ) : get_slot_changes(
9295              default_slot_template,
9296              /*$$scope*/
9297              ctx2[4],
9298              dirty,
9299              null
9300            ),
9301            null
9302          );
9303        }
9304      }
9305      if (!current || dirty & /*size*/
9306      1) {
9307        toggle_class(
9308          div1,
9309          "small",
9310          /*size*/
9311          ctx2[0] === "small"
9312        );
9313      }
9314      if (!current || dirty & /*size*/
9315      1) {
9316        toggle_class(
9317          div1,
9318          "large",
9319          /*size*/
9320          ctx2[0] === "large"
9321        );
9322      }
9323      if (!current || dirty & /*unpadded_box*/
9324      2) {
9325        toggle_class(
9326          div1,
9327          "unpadded_box",
9328          /*unpadded_box*/
9329          ctx2[1]
9330        );
9331      }
9332      if (!current || dirty & /*parent_height*/
9333      8) {
9334        toggle_class(
9335          div1,
9336          "small_parent",
9337          /*parent_height*/
9338          ctx2[3]
9339        );
9340      }
9341    },
9342    i(local) {
9343      if (current) return;
9344      transition_in(default_slot, local);
9345      current = true;
9346    },
9347    o(local) {
9348      transition_out(default_slot, local);
9349      current = false;
9350    },
9351    d(detaching) {
9352      if (detaching) {
9353        detach(div1);
9354      }
9355      if (default_slot) default_slot.d(detaching);
9356      ctx[6](null);
9357    }
9358  };
9359}
9360function compare_el_to_parent(el2) {
9361  var _a;
9362  if (!el2) return false;
9363  const { height: el_height } = el2.getBoundingClientRect();
9364  const { height: parent_height2 } = ((_a = el2.parentElement) == null ? void 0 : _a.getBoundingClientRect()) || { height: el_height };
9365  return el_height > parent_height2 + 2;
9366}
9367function instance$A($$self, $$props, $$invalidate) {
9368  let parent_height;
9369  let { $$slots: slots = {}, $$scope } = $$props;
9370  let { size = "small" } = $$props;
9371  let { unpadded_box = false } = $$props;
9372  let el;
9373  function div1_binding($$value) {
9374    binding_callbacks[$$value ? "unshift" : "push"](() => {
9375      el = $$value;
9376      $$invalidate(2, el);
9377    });
9378  }
9379  $$self.$$set = ($$props2) => {
9380    if ("size" in $$props2) $$invalidate(0, size = $$props2.size);
9381    if ("unpadded_box" in $$props2) $$invalidate(1, unpadded_box = $$props2.unpadded_box);
9382    if ("$$scope" in $$props2) $$invalidate(4, $$scope = $$props2.$$scope);
9383  };
9384  $$self.$$.update = () => {
9385    if ($$self.$$.dirty & /*el*/
9386    4) {
9387      $$invalidate(3, parent_height = compare_el_to_parent(el));
9388    }
9389  };
9390  return [size, unpadded_box, el, parent_height, $$scope, slots, div1_binding];
9391}
9392class Empty extends SvelteComponent {
9393  constructor(options) {
9394    super();
9395    init(this, options, instance$A, create_fragment$R, safe_not_equal, { size: 0, unpadded_box: 1 });
9396  }
9397}
9398function create_fragment$Q(ctx) {
9399  let svg;
9400  let path;
9401  let circle;
9402  return {
9403    c() {
9404      svg = svg_element("svg");
9405      path = svg_element("path");
9406      circle = svg_element("circle");
9407      attr(path, "d", "M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z");
9408      attr(circle, "cx", "12");
9409      attr(circle, "cy", "13");
9410      attr(circle, "r", "4");
9411      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9412      attr(svg, "width", "100%");
9413      attr(svg, "height", "100%");
9414      attr(svg, "viewBox", "0 0 24 24");
9415      attr(svg, "fill", "none");
9416      attr(svg, "stroke", "currentColor");
9417      attr(svg, "stroke-width", "1.5");
9418      attr(svg, "stroke-linecap", "round");
9419      attr(svg, "stroke-linejoin", "round");
9420      attr(svg, "class", "feather feather-camera");
9421    },
9422    m(target, anchor) {
9423      insert(target, svg, anchor);
9424      append(svg, path);
9425      append(svg, circle);
9426    },
9427    p: noop,
9428    i: noop,
9429    o: noop,
9430    d(detaching) {
9431      if (detaching) {
9432        detach(svg);
9433      }
9434    }
9435  };
9436}
9437class Camera extends SvelteComponent {
9438  constructor(options) {
9439    super();
9440    init(this, options, null, create_fragment$Q, safe_not_equal, {});
9441  }
9442}
9443function create_fragment$P(ctx) {
9444  let svg;
9445  let path;
9446  return {
9447    c() {
9448      svg = svg_element("svg");
9449      path = svg_element("path");
9450      attr(path, "d", "M5 13L9 17L19 7");
9451      attr(path, "stroke", "currentColor");
9452      attr(path, "stroke-width", "1.5");
9453      attr(path, "stroke-linecap", "round");
9454      attr(path, "stroke-linejoin", "round");
9455      attr(svg, "width", "100%");
9456      attr(svg, "height", "100%");
9457      attr(svg, "stroke-width", "1.5");
9458      attr(svg, "viewBox", "0 0 24 24");
9459      attr(svg, "fill", "none");
9460      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9461      attr(svg, "color", "currentColor");
9462    },
9463    m(target, anchor) {
9464      insert(target, svg, anchor);
9465      append(svg, path);
9466    },
9467    p: noop,
9468    i: noop,
9469    o: noop,
9470    d(detaching) {
9471      if (detaching) {
9472        detach(svg);
9473      }
9474    }
9475  };
9476}
9477class Check extends SvelteComponent {
9478  constructor(options) {
9479    super();
9480    init(this, options, null, create_fragment$P, safe_not_equal, {});
9481  }
9482}
9483function create_fragment$O(ctx) {
9484  let svg;
9485  let circle;
9486  return {
9487    c() {
9488      svg = svg_element("svg");
9489      circle = svg_element("circle");
9490      attr(circle, "cx", "12");
9491      attr(circle, "cy", "12");
9492      attr(circle, "r", "10");
9493      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9494      attr(svg, "width", "100%");
9495      attr(svg, "height", "100%");
9496      attr(svg, "viewBox", "0 0 24 24");
9497      attr(svg, "stroke-width", "1.5");
9498      attr(svg, "stroke-linecap", "round");
9499      attr(svg, "stroke-linejoin", "round");
9500      attr(svg, "class", "feather feather-circle");
9501    },
9502    m(target, anchor) {
9503      insert(target, svg, anchor);
9504      append(svg, circle);
9505    },
9506    p: noop,
9507    i: noop,
9508    o: noop,
9509    d(detaching) {
9510      if (detaching) {
9511        detach(svg);
9512      }
9513    }
9514  };
9515}
9516class Circle extends SvelteComponent {
9517  constructor(options) {
9518    super();
9519    init(this, options, null, create_fragment$O, safe_not_equal, {});
9520  }
9521}
9522function create_fragment$N(ctx) {
9523  let svg;
9524  let g;
9525  let path0;
9526  let path1;
9527  return {
9528    c() {
9529      svg = svg_element("svg");
9530      g = svg_element("g");
9531      path0 = svg_element("path");
9532      path1 = svg_element("path");
9533      attr(path0, "d", "M18,6L6.087,17.913");
9534      set_style(path0, "fill", "none");
9535      set_style(path0, "fill-rule", "nonzero");
9536      set_style(path0, "stroke-width", "2px");
9537      attr(g, "transform", "matrix(1.14096,-0.140958,-0.140958,1.14096,-0.0559523,0.0559523)");
9538      attr(path1, "d", "M4.364,4.364L19.636,19.636");
9539      set_style(path1, "fill", "none");
9540      set_style(path1, "fill-rule", "nonzero");
9541      set_style(path1, "stroke-width", "2px");
9542      attr(svg, "width", "100%");
9543      attr(svg, "height", "100%");
9544      attr(svg, "viewBox", "0 0 24 24");
9545      attr(svg, "version", "1.1");
9546      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9547      attr(svg, "xmlns:xlink", "http://www.w3.org/1999/xlink");
9548      attr(svg, "xml:space", "preserve");
9549      attr(svg, "stroke", "currentColor");
9550      set_style(svg, "fill-rule", "evenodd");
9551      set_style(svg, "clip-rule", "evenodd");
9552      set_style(svg, "stroke-linecap", "round");
9553      set_style(svg, "stroke-linejoin", "round");
9554    },
9555    m(target, anchor) {
9556      insert(target, svg, anchor);
9557      append(svg, g);
9558      append(g, path0);
9559      append(svg, path1);
9560    },
9561    p: noop,
9562    i: noop,
9563    o: noop,
9564    d(detaching) {
9565      if (detaching) {
9566        detach(svg);
9567      }
9568    }
9569  };
9570}
9571class Clear extends SvelteComponent {
9572  constructor(options) {
9573    super();
9574    init(this, options, null, create_fragment$N, safe_not_equal, {});
9575  }
9576}
9577function create_fragment$M(ctx) {
9578  let svg;
9579  let path;
9580  return {
9581    c() {
9582      svg = svg_element("svg");
9583      path = svg_element("path");
9584      attr(path, "d", "M23,20a5,5,0,0,0-3.89,1.89L11.8,17.32a4.46,4.46,0,0,0,0-2.64l7.31-4.57A5,5,0,1,0,18,7a4.79,4.79,0,0,0,.2,1.32l-7.31,4.57a5,5,0,1,0,0,6.22l7.31,4.57A4.79,4.79,0,0,0,18,25a5,5,0,1,0,5-5ZM23,4a3,3,0,1,1-3,3A3,3,0,0,1,23,4ZM7,19a3,3,0,1,1,3-3A3,3,0,0,1,7,19Zm16,9a3,3,0,1,1,3-3A3,3,0,0,1,23,28Z");
9585      attr(path, "fill", "currentColor");
9586      attr(svg, "id", "icon");
9587      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9588      attr(svg, "viewBox", "0 0 32 32");
9589      attr(svg, "width", "100%");
9590      attr(svg, "height", "100%");
9591    },
9592    m(target, anchor) {
9593      insert(target, svg, anchor);
9594      append(svg, path);
9595    },
9596    p: noop,
9597    i: noop,
9598    o: noop,
9599    d(detaching) {
9600      if (detaching) {
9601        detach(svg);
9602      }
9603    }
9604  };
9605}
9606class Community extends SvelteComponent {
9607  constructor(options) {
9608    super();
9609    init(this, options, null, create_fragment$M, safe_not_equal, {});
9610  }
9611}
9612function create_fragment$L(ctx) {
9613  let svg;
9614  let path0;
9615  let path1;
9616  return {
9617    c() {
9618      svg = svg_element("svg");
9619      path0 = svg_element("path");
9620      path1 = svg_element("path");
9621      attr(path0, "fill", "currentColor");
9622      attr(path0, "d", "M28 10v18H10V10h18m0-2H10a2 2 0 0 0-2 2v18a2 2 0 0 0 2 2h18a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2Z");
9623      attr(path1, "fill", "currentColor");
9624      attr(path1, "d", "M4 18H2V4a2 2 0 0 1 2-2h14v2H4Z");
9625      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9626      attr(svg, "viewBox", "0 0 33 33");
9627      attr(svg, "color", "currentColor");
9628      attr(svg, "aria-hidden", "true");
9629      attr(svg, "width", "100%");
9630      attr(svg, "height", "100%");
9631    },
9632    m(target, anchor) {
9633      insert(target, svg, anchor);
9634      append(svg, path0);
9635      append(svg, path1);
9636    },
9637    p: noop,
9638    i: noop,
9639    o: noop,
9640    d(detaching) {
9641      if (detaching) {
9642        detach(svg);
9643      }
9644    }
9645  };
9646}
9647class Copy extends SvelteComponent {
9648  constructor(options) {
9649    super();
9650    init(this, options, null, create_fragment$L, safe_not_equal, {});
9651  }
9652}
9653function create_fragment$K(ctx) {
9654  let svg;
9655  let path;
9656  return {
9657    c() {
9658      svg = svg_element("svg");
9659      path = svg_element("path");
9660      attr(path, "fill", "currentColor");
9661      attr(path, "d", "M26 24v4H6v-4H4v4a2 2 0 0 0 2 2h20a2 2 0 0 0 2-2v-4zm0-10l-1.41-1.41L17 20.17V2h-2v18.17l-7.59-7.58L6 14l10 10l10-10z");
9662      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9663      attr(svg, "width", "100%");
9664      attr(svg, "height", "100%");
9665      attr(svg, "viewBox", "0 0 32 32");
9666    },
9667    m(target, anchor) {
9668      insert(target, svg, anchor);
9669      append(svg, path);
9670    },
9671    p: noop,
9672    i: noop,
9673    o: noop,
9674    d(detaching) {
9675      if (detaching) {
9676        detach(svg);
9677      }
9678    }
9679  };
9680}
9681class Download extends SvelteComponent {
9682  constructor(options) {
9683    super();
9684    init(this, options, null, create_fragment$K, safe_not_equal, {});
9685  }
9686}
9687function create_fragment$J(ctx) {
9688  let svg;
9689  let path;
9690  return {
9691    c() {
9692      svg = svg_element("svg");
9693      path = svg_element("path");
9694      attr(path, "d", "M5 8l4 4 4-4z");
9695      attr(svg, "class", "dropdown-arrow svelte-145leq6");
9696      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9697      attr(svg, "width", "100%");
9698      attr(svg, "height", "100%");
9699      attr(svg, "viewBox", "0 0 18 18");
9700    },
9701    m(target, anchor) {
9702      insert(target, svg, anchor);
9703      append(svg, path);
9704    },
9705    p: noop,
9706    i: noop,
9707    o: noop,
9708    d(detaching) {
9709      if (detaching) {
9710        detach(svg);
9711      }
9712    }
9713  };
9714}
9715class DropdownArrow extends SvelteComponent {
9716  constructor(options) {
9717    super();
9718    init(this, options, null, create_fragment$J, safe_not_equal, {});
9719  }
9720}
9721function create_fragment$I(ctx) {
9722  let svg;
9723  let rect;
9724  let circle;
9725  let polyline;
9726  return {
9727    c() {
9728      svg = svg_element("svg");
9729      rect = svg_element("rect");
9730      circle = svg_element("circle");
9731      polyline = svg_element("polyline");
9732      attr(rect, "x", "3");
9733      attr(rect, "y", "3");
9734      attr(rect, "width", "18");
9735      attr(rect, "height", "18");
9736      attr(rect, "rx", "2");
9737      attr(rect, "ry", "2");
9738      attr(circle, "cx", "8.5");
9739      attr(circle, "cy", "8.5");
9740      attr(circle, "r", "1.5");
9741      attr(polyline, "points", "21 15 16 10 5 21");
9742      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9743      attr(svg, "width", "100%");
9744      attr(svg, "height", "100%");
9745      attr(svg, "viewBox", "0 0 24 24");
9746      attr(svg, "fill", "none");
9747      attr(svg, "stroke", "currentColor");
9748      attr(svg, "stroke-width", "1.5");
9749      attr(svg, "stroke-linecap", "round");
9750      attr(svg, "stroke-linejoin", "round");
9751      attr(svg, "class", "feather feather-image");
9752    },
9753    m(target, anchor) {
9754      insert(target, svg, anchor);
9755      append(svg, rect);
9756      append(svg, circle);
9757      append(svg, polyline);
9758    },
9759    p: noop,
9760    i: noop,
9761    o: noop,
9762    d(detaching) {
9763      if (detaching) {
9764        detach(svg);
9765      }
9766    }
9767  };
9768}
9769let Image$1 = class Image extends SvelteComponent {
9770  constructor(options) {
9771    super();
9772    init(this, options, null, create_fragment$I, safe_not_equal, {});
9773  }
9774};
9775function create_fragment$H(ctx) {
9776  let svg;
9777  let path;
9778  return {
9779    c() {
9780      svg = svg_element("svg");
9781      path = svg_element("path");
9782      attr(path, "fill", "currentColor");
9783      attr(path, "d", "M200 32h-36.26a47.92 47.92 0 0 0-71.48 0H56a16 16 0 0 0-16 16v168a16 16 0 0 0 16 16h144a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16m-72 0a32 32 0 0 1 32 32H96a32 32 0 0 1 32-32m72 184H56V48h26.75A47.9 47.9 0 0 0 80 64v8a8 8 0 0 0 8 8h80a8 8 0 0 0 8-8v-8a47.9 47.9 0 0 0-2.75-16H200Z");
9784      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9785      attr(svg, "width", "100%");
9786      attr(svg, "height", "100%");
9787      attr(svg, "viewBox", "0 0 256 256");
9788    },
9789    m(target, anchor) {
9790      insert(target, svg, anchor);
9791      append(svg, path);
9792    },
9793    p: noop,
9794    i: noop,
9795    o: noop,
9796    d(detaching) {
9797      if (detaching) {
9798        detach(svg);
9799      }
9800    }
9801  };
9802}
9803class ImagePaste extends SvelteComponent {
9804  constructor(options) {
9805    super();
9806    init(this, options, null, create_fragment$H, safe_not_equal, {});
9807  }
9808}
9809function create_fragment$G(ctx) {
9810  let svg;
9811  let path;
9812  return {
9813    c() {
9814      svg = svg_element("svg");
9815      path = svg_element("path");
9816      attr(path, "d", "M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3");
9817      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9818      attr(svg, "viewBox", "0 0 24 24");
9819      attr(svg, "fill", "none");
9820      attr(svg, "stroke", "currentColor");
9821      attr(svg, "stroke-width", "2");
9822      attr(svg, "stroke-linecap", "round");
9823      attr(svg, "stroke-linejoin", "round");
9824      attr(svg, "class", "feather feather-maximize");
9825      attr(svg, "width", "100%");
9826      attr(svg, "height", "100%");
9827    },
9828    m(target, anchor) {
9829      insert(target, svg, anchor);
9830      append(svg, path);
9831    },
9832    p: noop,
9833    i: noop,
9834    o: noop,
9835    d(detaching) {
9836      if (detaching) {
9837        detach(svg);
9838      }
9839    }
9840  };
9841}
9842class Maximize extends SvelteComponent {
9843  constructor(options) {
9844    super();
9845    init(this, options, null, create_fragment$G, safe_not_equal, {});
9846  }
9847}
9848function create_fragment$F(ctx) {
9849  let svg;
9850  let path0;
9851  let path1;
9852  let line0;
9853  let line1;
9854  return {
9855    c() {
9856      svg = svg_element("svg");
9857      path0 = svg_element("path");
9858      path1 = svg_element("path");
9859      line0 = svg_element("line");
9860      line1 = svg_element("line");
9861      attr(path0, "d", "M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z");
9862      attr(path1, "d", "M19 10v2a7 7 0 0 1-14 0v-2");
9863      attr(line0, "x1", "12");
9864      attr(line0, "y1", "19");
9865      attr(line0, "x2", "12");
9866      attr(line0, "y2", "23");
9867      attr(line1, "x1", "8");
9868      attr(line1, "y1", "23");
9869      attr(line1, "x2", "16");
9870      attr(line1, "y2", "23");
9871      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9872      attr(svg, "width", "100%");
9873      attr(svg, "height", "100%");
9874      attr(svg, "viewBox", "0 0 24 24");
9875      attr(svg, "fill", "none");
9876      attr(svg, "stroke", "currentColor");
9877      attr(svg, "stroke-width", "2");
9878      attr(svg, "stroke-linecap", "round");
9879      attr(svg, "stroke-linejoin", "round");
9880      attr(svg, "class", "feather feather-mic");
9881    },
9882    m(target, anchor) {
9883      insert(target, svg, anchor);
9884      append(svg, path0);
9885      append(svg, path1);
9886      append(svg, line0);
9887      append(svg, line1);
9888    },
9889    p: noop,
9890    i: noop,
9891    o: noop,
9892    d(detaching) {
9893      if (detaching) {
9894        detach(svg);
9895      }
9896    }
9897  };
9898}
9899class Microphone extends SvelteComponent {
9900  constructor(options) {
9901    super();
9902    init(this, options, null, create_fragment$F, safe_not_equal, {});
9903  }
9904}
9905function create_fragment$E(ctx) {
9906  let svg;
9907  let path;
9908  return {
9909    c() {
9910      svg = svg_element("svg");
9911      path = svg_element("path");
9912      attr(path, "d", "M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3");
9913      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9914      attr(svg, "viewBox", "0 0 24 24");
9915      attr(svg, "fill", "none");
9916      attr(svg, "stroke", "currentColor");
9917      attr(svg, "stroke-width", "2");
9918      attr(svg, "stroke-linecap", "round");
9919      attr(svg, "stroke-linejoin", "round");
9920      attr(svg, "class", "feather feather-minimize");
9921      attr(svg, "width", "100%");
9922      attr(svg, "height", "100%");
9923    },
9924    m(target, anchor) {
9925      insert(target, svg, anchor);
9926      append(svg, path);
9927    },
9928    p: noop,
9929    i: noop,
9930    o: noop,
9931    d(detaching) {
9932      if (detaching) {
9933        detach(svg);
9934      }
9935    }
9936  };
9937}
9938class Minimize extends SvelteComponent {
9939  constructor(options) {
9940    super();
9941    init(this, options, null, create_fragment$E, safe_not_equal, {});
9942  }
9943}
9944function create_fragment$D(ctx) {
9945  let svg;
9946  let rect;
9947  let svg_stroke_width_value;
9948  return {
9949    c() {
9950      svg = svg_element("svg");
9951      rect = svg_element("rect");
9952      attr(rect, "x", "3");
9953      attr(rect, "y", "3");
9954      attr(rect, "width", "18");
9955      attr(rect, "height", "18");
9956      attr(rect, "rx", "2");
9957      attr(rect, "ry", "2");
9958      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
9959      attr(svg, "width", "100%");
9960      attr(svg, "height", "100%");
9961      attr(svg, "viewBox", "0 0 24 24");
9962      attr(
9963        svg,
9964        "fill",
9965        /*fill*/
9966        ctx[0]
9967      );
9968      attr(svg, "stroke", "currentColor");
9969      attr(svg, "stroke-width", svg_stroke_width_value = `${/*stroke_width*/
9970      ctx[1]}`);
9971      attr(svg, "stroke-linecap", "round");
9972      attr(svg, "stroke-linejoin", "round");
9973      attr(svg, "class", "feather feather-square");
9974    },
9975    m(target, anchor) {
9976      insert(target, svg, anchor);
9977      append(svg, rect);
9978    },
9979    p(ctx2, [dirty]) {
9980      if (dirty & /*fill*/
9981      1) {
9982        attr(
9983          svg,
9984          "fill",
9985          /*fill*/
9986          ctx2[0]
9987        );
9988      }
9989      if (dirty & /*stroke_width*/
9990      2 && svg_stroke_width_value !== (svg_stroke_width_value = `${/*stroke_width*/
9991      ctx2[1]}`)) {
9992        attr(svg, "stroke-width", svg_stroke_width_value);
9993      }
9994    },
9995    i: noop,
9996    o: noop,
9997    d(detaching) {
9998      if (detaching) {
9999        detach(svg);
10000      }
10001    }
10002  };
10003}
10004function instance$z($$self, $$props, $$invalidate) {
10005  let { fill = "currentColor" } = $$props;
10006  let { stroke_width = 1.5 } = $$props;
10007  $$self.$$set = ($$props2) => {
10008    if ("fill" in $$props2) $$invalidate(0, fill = $$props2.fill);
10009    if ("stroke_width" in $$props2) $$invalidate(1, stroke_width = $$props2.stroke_width);
10010  };
10011  return [fill, stroke_width];
10012}
10013class Square extends SvelteComponent {
10014  constructor(options) {
10015    super();
10016    init(this, options, instance$z, create_fragment$D, safe_not_equal, { fill: 0, stroke_width: 1 });
10017  }
10018}
10019function create_fragment$C(ctx) {
10020  let svg;
10021  let path;
10022  let polyline;
10023  let line;
10024  return {
10025    c() {
10026      svg = svg_element("svg");
10027      path = svg_element("path");
10028      polyline = svg_element("polyline");
10029      line = svg_element("line");
10030      attr(path, "d", "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4");
10031      attr(polyline, "points", "17 8 12 3 7 8");
10032      attr(line, "x1", "12");
10033      attr(line, "y1", "3");
10034      attr(line, "x2", "12");
10035      attr(line, "y2", "15");
10036      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
10037      attr(svg, "width", "90%");
10038      attr(svg, "height", "90%");
10039      attr(svg, "viewBox", "0 0 24 24");
10040      attr(svg, "fill", "none");
10041      attr(svg, "stroke", "currentColor");
10042      attr(svg, "stroke-width", "2");
10043      attr(svg, "stroke-linecap", "round");
10044      attr(svg, "stroke-linejoin", "round");
10045      attr(svg, "class", "feather feather-upload");
10046    },
10047    m(target, anchor) {
10048      insert(target, svg, anchor);
10049      append(svg, path);
10050      append(svg, polyline);
10051      append(svg, line);
10052    },
10053    p: noop,
10054    i: noop,
10055    o: noop,
10056    d(detaching) {
10057      if (detaching) {
10058        detach(svg);
10059      }
10060    }
10061  };
10062}
10063let Upload$1 = class Upload extends SvelteComponent {
10064  constructor(options) {
10065    super();
10066    init(this, options, null, create_fragment$C, safe_not_equal, {});
10067  }
10068};
10069function create_fragment$B(ctx) {
10070  let svg;
10071  let path0;
10072  let path1;
10073  return {
10074    c() {
10075      svg = svg_element("svg");
10076      path0 = svg_element("path");
10077      path1 = svg_element("path");
10078      attr(path0, "fill", "currentColor");
10079      attr(path0, "d", "M12 2c-4.963 0-9 4.038-9 9c0 3.328 1.82 6.232 4.513 7.79l-2.067 1.378A1 1 0 0 0 6 22h12a1 1 0 0 0 .555-1.832l-2.067-1.378C19.18 17.232 21 14.328 21 11c0-4.962-4.037-9-9-9zm0 16c-3.859 0-7-3.141-7-7c0-3.86 3.141-7 7-7s7 3.14 7 7c0 3.859-3.141 7-7 7z");
10080      attr(path1, "fill", "currentColor");
10081      attr(path1, "d", "M12 6c-2.757 0-5 2.243-5 5s2.243 5 5 5s5-2.243 5-5s-2.243-5-5-5zm0 8c-1.654 0-3-1.346-3-3s1.346-3 3-3s3 1.346 3 3s-1.346 3-3 3z");
10082      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
10083      attr(svg, "width", "100%");
10084      attr(svg, "height", "100%");
10085      attr(svg, "viewBox", "0 0 24 24");
10086    },
10087    m(target, anchor) {
10088      insert(target, svg, anchor);
10089      append(svg, path0);
10090      append(svg, path1);
10091    },
10092    p: noop,
10093    i: noop,
10094    o: noop,
10095    d(detaching) {
10096      if (detaching) {
10097        detach(svg);
10098      }
10099    }
10100  };
10101}
10102let Webcam$1 = class Webcam extends SvelteComponent {
10103  constructor(options) {
10104    super();
10105    init(this, options, null, create_fragment$B, safe_not_equal, {});
10106  }
10107};
10108function create_fragment$A(ctx) {
10109  let svg;
10110  let circle;
10111  let animateTransform;
10112  return {
10113    c() {
10114      svg = svg_element("svg");
10115      circle = svg_element("circle");
10116      animateTransform = svg_element("animateTransform");
10117      attr(animateTransform, "attributeName", "transform");
10118      attr(animateTransform, "type", "rotate");
10119      attr(animateTransform, "from", "0 25 25");
10120      attr(animateTransform, "to", "360 25 25");
10121      attr(animateTransform, "repeatCount", "indefinite");
10122      attr(circle, "cx", "25");
10123      attr(circle, "cy", "25");
10124      attr(circle, "r", "20");
10125      attr(circle, "fill", "none");
10126      attr(circle, "stroke-width", "3.0");
10127      attr(circle, "stroke-linecap", "round");
10128      attr(circle, "stroke-dasharray", "94.2477796076938 94.2477796076938");
10129      attr(circle, "stroke-dashoffset", "0");
10130      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
10131      attr(svg, "width", "100%");
10132      attr(svg, "height", "100%");
10133      attr(svg, "viewBox", "0 0 50 50");
10134      attr(svg, "class", "svelte-pb9pol");
10135    },
10136    m(target, anchor) {
10137      insert(target, svg, anchor);
10138      append(svg, circle);
10139      append(circle, animateTransform);
10140    },
10141    p: noop,
10142    i: noop,
10143    o: noop,
10144    d(detaching) {
10145      if (detaching) {
10146        detach(svg);
10147      }
10148    }
10149  };
10150}
10151class Spinner extends SvelteComponent {
10152  constructor(options) {
10153    super();
10154    init(this, options, null, create_fragment$A, safe_not_equal, {});
10155  }
10156}
10157const color_values = [
10158  { color: "red", primary: 600, secondary: 100 },
10159  { color: "green", primary: 600, secondary: 100 },
10160  { color: "blue", primary: 600, secondary: 100 },
10161  { color: "yellow", primary: 500, secondary: 100 },
10162  { color: "purple", primary: 600, secondary: 100 },
10163  { color: "teal", primary: 600, secondary: 100 },
10164  { color: "orange", primary: 600, secondary: 100 },
10165  { color: "cyan", primary: 600, secondary: 100 },
10166  { color: "lime", primary: 500, secondary: 100 },
10167  { color: "pink", primary: 600, secondary: 100 }
10168];
10169const tw_colors = {
10170  inherit: "inherit",
10171  current: "currentColor",
10172  transparent: "transparent",
10173  black: "#000",
10174  white: "#fff",
10175  slate: {
10176    50: "#f8fafc",
10177    100: "#f1f5f9",
10178    200: "#e2e8f0",
10179    300: "#cbd5e1",
10180    400: "#94a3b8",
10181    500: "#64748b",
10182    600: "#475569",
10183    700: "#334155",
10184    800: "#1e293b",
10185    900: "#0f172a",
10186    950: "#020617"
10187  },
10188  gray: {
10189    50: "#f9fafb",
10190    100: "#f3f4f6",
10191    200: "#e5e7eb",
10192    300: "#d1d5db",
10193    400: "#9ca3af",
10194    500: "#6b7280",
10195    600: "#4b5563",
10196    700: "#374151",
10197    800: "#1f2937",
10198    900: "#111827",
10199    950: "#030712"
10200  },
10201  zinc: {
10202    50: "#fafafa",
10203    100: "#f4f4f5",
10204    200: "#e4e4e7",
10205    300: "#d4d4d8",
10206    400: "#a1a1aa",
10207    500: "#71717a",
10208    600: "#52525b",
10209    700: "#3f3f46",
10210    800: "#27272a",
10211    900: "#18181b",
10212    950: "#09090b"
10213  },
10214  neutral: {
10215    50: "#fafafa",
10216    100: "#f5f5f5",
10217    200: "#e5e5e5",
10218    300: "#d4d4d4",
10219    400: "#a3a3a3",
10220    500: "#737373",
10221    600: "#525252",
10222    700: "#404040",
10223    800: "#262626",
10224    900: "#171717",
10225    950: "#0a0a0a"
10226  },
10227  stone: {
10228    50: "#fafaf9",
10229    100: "#f5f5f4",
10230    200: "#e7e5e4",
10231    300: "#d6d3d1",
10232    400: "#a8a29e",
10233    500: "#78716c",
10234    600: "#57534e",
10235    700: "#44403c",
10236    800: "#292524",
10237    900: "#1c1917",
10238    950: "#0c0a09"
10239  },
10240  red: {
10241    50: "#fef2f2",
10242    100: "#fee2e2",
10243    200: "#fecaca",
10244    300: "#fca5a5",
10245    400: "#f87171",
10246    500: "#ef4444",
10247    600: "#dc2626",
10248    700: "#b91c1c",
10249    800: "#991b1b",
10250    900: "#7f1d1d",
10251    950: "#450a0a"
10252  },
10253  orange: {
10254    50: "#fff7ed",
10255    100: "#ffedd5",
10256    200: "#fed7aa",
10257    300: "#fdba74",
10258    400: "#fb923c",
10259    500: "#f97316",
10260    600: "#ea580c",
10261    700: "#c2410c",
10262    800: "#9a3412",
10263    900: "#7c2d12",
10264    950: "#431407"
10265  },
10266  amber: {
10267    50: "#fffbeb",
10268    100: "#fef3c7",
10269    200: "#fde68a",
10270    300: "#fcd34d",
10271    400: "#fbbf24",
10272    500: "#f59e0b",
10273    600: "#d97706",
10274    700: "#b45309",
10275    800: "#92400e",
10276    900: "#78350f",
10277    950: "#451a03"
10278  },
10279  yellow: {
10280    50: "#fefce8",
10281    100: "#fef9c3",
10282    200: "#fef08a",
10283    300: "#fde047",
10284    400: "#facc15",
10285    500: "#eab308",
10286    600: "#ca8a04",
10287    700: "#a16207",
10288    800: "#854d0e",
10289    900: "#713f12",
10290    950: "#422006"
10291  },
10292  lime: {
10293    50: "#f7fee7",
10294    100: "#ecfccb",
10295    200: "#d9f99d",
10296    300: "#bef264",
10297    400: "#a3e635",
10298    500: "#84cc16",
10299    600: "#65a30d",
10300    700: "#4d7c0f",
10301    800: "#3f6212",
10302    900: "#365314",
10303    950: "#1a2e05"
10304  },
10305  green: {
10306    50: "#f0fdf4",
10307    100: "#dcfce7",
10308    200: "#bbf7d0",
10309    300: "#86efac",
10310    400: "#4ade80",
10311    500: "#22c55e",
10312    600: "#16a34a",
10313    700: "#15803d",
10314    800: "#166534",
10315    900: "#14532d",
10316    950: "#052e16"
10317  },
10318  emerald: {
10319    50: "#ecfdf5",
10320    100: "#d1fae5",
10321    200: "#a7f3d0",
10322    300: "#6ee7b7",
10323    400: "#34d399",
10324    500: "#10b981",
10325    600: "#059669",
10326    700: "#047857",
10327    800: "#065f46",
10328    900: "#064e3b",
10329    950: "#022c22"
10330  },
10331  teal: {
10332    50: "#f0fdfa",
10333    100: "#ccfbf1",
10334    200: "#99f6e4",
10335    300: "#5eead4",
10336    400: "#2dd4bf",
10337    500: "#14b8a6",
10338    600: "#0d9488",
10339    700: "#0f766e",
10340    800: "#115e59",
10341    900: "#134e4a",
10342    950: "#042f2e"
10343  },
10344  cyan: {
10345    50: "#ecfeff",
10346    100: "#cffafe",
10347    200: "#a5f3fc",
10348    300: "#67e8f9",
10349    400: "#22d3ee",
10350    500: "#06b6d4",
10351    600: "#0891b2",
10352    700: "#0e7490",
10353    800: "#155e75",
10354    900: "#164e63",
10355    950: "#083344"
10356  },
10357  sky: {
10358    50: "#f0f9ff",
10359    100: "#e0f2fe",
10360    200: "#bae6fd",
10361    300: "#7dd3fc",
10362    400: "#38bdf8",
10363    500: "#0ea5e9",
10364    600: "#0284c7",
10365    700: "#0369a1",
10366    800: "#075985",
10367    900: "#0c4a6e",
10368    950: "#082f49"
10369  },
10370  blue: {
10371    50: "#eff6ff",
10372    100: "#dbeafe",
10373    200: "#bfdbfe",
10374    300: "#93c5fd",
10375    400: "#60a5fa",
10376    500: "#3b82f6",
10377    600: "#2563eb",
10378    700: "#1d4ed8",
10379    800: "#1e40af",
10380    900: "#1e3a8a",
10381    950: "#172554"
10382  },
10383  indigo: {
10384    50: "#eef2ff",
10385    100: "#e0e7ff",
10386    200: "#c7d2fe",
10387    300: "#a5b4fc",
10388    400: "#818cf8",
10389    500: "#6366f1",
10390    600: "#4f46e5",
10391    700: "#4338ca",
10392    800: "#3730a3",
10393    900: "#312e81",
10394    950: "#1e1b4b"
10395  },
10396  violet: {
10397    50: "#f5f3ff",
10398    100: "#ede9fe",
10399    200: "#ddd6fe",
10400    300: "#c4b5fd",
10401    400: "#a78bfa",
10402    500: "#8b5cf6",
10403    600: "#7c3aed",
10404    700: "#6d28d9",
10405    800: "#5b21b6",
10406    900: "#4c1d95",
10407    950: "#2e1065"
10408  },
10409  purple: {
10410    50: "#faf5ff",
10411    100: "#f3e8ff",
10412    200: "#e9d5ff",
10413    300: "#d8b4fe",
10414    400: "#c084fc",
10415    500: "#a855f7",
10416    600: "#9333ea",
10417    700: "#7e22ce",
10418    800: "#6b21a8",
10419    900: "#581c87",
10420    950: "#3b0764"
10421  },
10422  fuchsia: {
10423    50: "#fdf4ff",
10424    100: "#fae8ff",
10425    200: "#f5d0fe",
10426    300: "#f0abfc",
10427    400: "#e879f9",
10428    500: "#d946ef",
10429    600: "#c026d3",
10430    700: "#a21caf",
10431    800: "#86198f",
10432    900: "#701a75",
10433    950: "#4a044e"
10434  },
10435  pink: {
10436    50: "#fdf2f8",
10437    100: "#fce7f3",
10438    200: "#fbcfe8",
10439    300: "#f9a8d4",
10440    400: "#f472b6",
10441    500: "#ec4899",
10442    600: "#db2777",
10443    700: "#be185d",
10444    800: "#9d174d",
10445    900: "#831843",
10446    950: "#500724"
10447  },
10448  rose: {
10449    50: "#fff1f2",
10450    100: "#ffe4e6",
10451    200: "#fecdd3",
10452    300: "#fda4af",
10453    400: "#fb7185",
10454    500: "#f43f5e",
10455    600: "#e11d48",
10456    700: "#be123c",
10457    800: "#9f1239",
10458    900: "#881337",
10459    950: "#4c0519"
10460  }
10461};
10462color_values.reduce(
10463  (acc, { color, primary, secondary }) => ({
10464    ...acc,
10465    [color]: {
10466      primary: tw_colors[color][primary],
10467      secondary: tw_colors[color][secondary]
10468    }
10469  }),
10470  {}
10471);
10472class ShareError extends Error {
10473  constructor(message) {
10474    super(message);
10475    this.name = "ShareError";
10476  }
10477}
10478async function uploadToHuggingFace(data, type) {
10479  var _a;
10480  if (window.__gradio_space__ == null) {
10481    throw new ShareError("Must be on Spaces to share.");
10482  }
10483  let blob;
10484  let contentType;
10485  let filename;
10486  {
10487    let url;
10488    if (typeof data === "object" && data.url) {
10489      url = data.url;
10490    } else if (typeof data === "string") {
10491      url = data;
10492    } else {
10493      throw new Error("Invalid data format for URL type");
10494    }
10495    const response = await fetch(url);
10496    blob = await response.blob();
10497    contentType = response.headers.get("content-type") || "";
10498    filename = response.headers.get("content-disposition") || "";
10499  }
10500  const file = new File([blob], filename, { type: contentType });
10501  const uploadResponse = await fetch("https://huggingface.co/uploads", {
10502    method: "POST",
10503    body: file,
10504    headers: {
10505      "Content-Type": file.type,
10506      "X-Requested-With": "XMLHttpRequest"
10507    }
10508  });
10509  if (!uploadResponse.ok) {
10510    if ((_a = uploadResponse.headers.get("content-type")) == null ? void 0 : _a.includes("application/json")) {
10511      const error = await uploadResponse.json();
10512      throw new ShareError(`Upload failed: ${error.error}`);
10513    }
10514    throw new ShareError(`Upload failed.`);
10515  }
10516  const result = await uploadResponse.text();
10517  return result;
10518}
10519function create_fragment$z(ctx) {
10520  let iconbutton;
10521  let current;
10522  iconbutton = new IconButton({
10523    props: {
10524      Icon: Community,
10525      label: (
10526        /*i18n*/
10527        ctx[2]("common.share")
10528      ),
10529      pending: (
10530        /*pending*/
10531        ctx[3]
10532      )
10533    }
10534  });
10535  iconbutton.$on(
10536    "click",
10537    /*click_handler*/
10538    ctx[5]
10539  );
10540  return {
10541    c() {
10542      create_component(iconbutton.$$.fragment);
10543    },
10544    m(target, anchor) {
10545      mount_component(iconbutton, target, anchor);
10546      current = true;
10547    },
10548    p(ctx2, [dirty]) {
10549      const iconbutton_changes = {};
10550      if (dirty & /*i18n*/
10551      4) iconbutton_changes.label = /*i18n*/
10552      ctx2[2]("common.share");
10553      if (dirty & /*pending*/
10554      8) iconbutton_changes.pending = /*pending*/
10555      ctx2[3];
10556      iconbutton.$set(iconbutton_changes);
10557    },
10558    i(local) {
10559      if (current) return;
10560      transition_in(iconbutton.$$.fragment, local);
10561      current = true;
10562    },
10563    o(local) {
10564      transition_out(iconbutton.$$.fragment, local);
10565      current = false;
10566    },
10567    d(detaching) {
10568      destroy_component(iconbutton, detaching);
10569    }
10570  };
10571}
10572function instance$y($$self, $$props, $$invalidate) {
10573  const dispatch2 = createEventDispatcher();
10574  let { formatter } = $$props;
10575  let { value } = $$props;
10576  let { i18n } = $$props;
10577  let pending = false;
10578  const click_handler = async () => {
10579    try {
10580      $$invalidate(3, pending = true);
10581      const formatted = await formatter(value);
10582      dispatch2("share", { description: formatted });
10583    } catch (e) {
10584      console.error(e);
10585      let message = e instanceof ShareError ? e.message : "Share failed.";
10586      dispatch2("error", message);
10587    } finally {
10588      $$invalidate(3, pending = false);
10589    }
10590  };
10591  $$self.$$set = ($$props2) => {
10592    if ("formatter" in $$props2) $$invalidate(0, formatter = $$props2.formatter);
10593    if ("value" in $$props2) $$invalidate(1, value = $$props2.value);
10594    if ("i18n" in $$props2) $$invalidate(2, i18n = $$props2.i18n);
10595  };
10596  return [formatter, value, i18n, pending, dispatch2, click_handler];
10597}
10598class ShareButton extends SvelteComponent {
10599  constructor(options) {
10600    super();
10601    init(this, options, instance$y, create_fragment$z, safe_not_equal, { formatter: 0, value: 1, i18n: 2 });
10602  }
10603}
10604const RE_HEADING = /^(#\s*)(.+)$/m;
10605function inject(text2) {
10606  const trimmed_text = text2.trim();
10607  const heading_match = trimmed_text.match(RE_HEADING);
10608  if (!heading_match) {
10609    return [false, trimmed_text || false];
10610  }
10611  const [full_match, , heading_content] = heading_match;
10612  const _heading = heading_content.trim();
10613  if (trimmed_text === full_match) {
10614    return [_heading, false];
10615  }
10616  const heading_end_index = heading_match.index !== void 0 ? heading_match.index + full_match.length : 0;
10617  const remaining_text = trimmed_text.substring(heading_end_index).trim();
10618  const _paragraph2 = remaining_text || false;
10619  return [_heading, _paragraph2];
10620}
10621function create_else_block_1$3(ctx) {
10622  let uploadicon;
10623  let current;
10624  uploadicon = new Upload$1({});
10625  return {
10626    c() {
10627      create_component(uploadicon.$$.fragment);
10628    },
10629    m(target, anchor) {
10630      mount_component(uploadicon, target, anchor);
10631      current = true;
10632    },
10633    i(local) {
10634      if (current) return;
10635      transition_in(uploadicon.$$.fragment, local);
10636      current = true;
10637    },
10638    o(local) {
10639      transition_out(uploadicon.$$.fragment, local);
10640      current = false;
10641    },
10642    d(detaching) {
10643      destroy_component(uploadicon, detaching);
10644    }
10645  };
10646}
10647function create_if_block_4$9(ctx) {
10648  let imagepaste;
10649  let current;
10650  imagepaste = new ImagePaste({});
10651  return {
10652    c() {
10653      create_component(imagepaste.$$.fragment);
10654    },
10655    m(target, anchor) {
10656      mount_component(imagepaste, target, anchor);
10657      current = true;
10658    },
10659    i(local) {
10660      if (current) return;
10661      transition_in(imagepaste.$$.fragment, local);
10662      current = true;
10663    },
10664    o(local) {
10665      transition_out(imagepaste.$$.fragment, local);
10666      current = false;
10667    },
10668    d(detaching) {
10669      destroy_component(imagepaste, detaching);
10670    }
10671  };
10672}
10673function create_else_block$9(ctx) {
10674  let t0_value = (
10675    /*i18n*/
10676    ctx[1](
10677      /*defs*/
10678      ctx[7][
10679        /*type*/
10680        ctx[0]
10681      ] || /*defs*/
10682      ctx[7].file
10683    ) + ""
10684  );
10685  let t0;
10686  let t1;
10687  let if_block_anchor;
10688  let if_block = (
10689    /*mode*/
10690    ctx[3] !== "short" && create_if_block_3$b(ctx)
10691  );
10692  return {
10693    c() {
10694      t0 = text(t0_value);
10695      t1 = space();
10696      if (if_block) if_block.c();
10697      if_block_anchor = empty();
10698    },
10699    m(target, anchor) {
10700      insert(target, t0, anchor);
10701      insert(target, t1, anchor);
10702      if (if_block) if_block.m(target, anchor);
10703      insert(target, if_block_anchor, anchor);
10704    },
10705    p(ctx2, dirty) {
10706      if (dirty & /*i18n, type*/
10707      3 && t0_value !== (t0_value = /*i18n*/
10708      ctx2[1](
10709        /*defs*/
10710        ctx2[7][
10711          /*type*/
10712          ctx2[0]
10713        ] || /*defs*/
10714        ctx2[7].file
10715      ) + "")) set_data(t0, t0_value);
10716      if (
10717        /*mode*/
10718        ctx2[3] !== "short"
10719      ) {
10720        if (if_block) {
10721          if_block.p(ctx2, dirty);
10722        } else {
10723          if_block = create_if_block_3$b(ctx2);
10724          if_block.c();
10725          if_block.m(if_block_anchor.parentNode, if_block_anchor);
10726        }
10727      } else if (if_block) {
10728        if_block.d(1);
10729        if_block = null;
10730      }
10731    },
10732    d(detaching) {
10733      if (detaching) {
10734        detach(t0);
10735        detach(t1);
10736        detach(if_block_anchor);
10737      }
10738      if (if_block) if_block.d(detaching);
10739    }
10740  };
10741}
10742function create_if_block$k(ctx) {
10743  let t;
10744  let if_block1_anchor;
10745  let if_block0 = (
10746    /*heading*/
10747    ctx[6] && create_if_block_2$d(ctx)
10748  );
10749  let if_block1 = (
10750    /*paragraph*/
10751    ctx[5] && create_if_block_1$e(ctx)
10752  );
10753  return {
10754    c() {
10755      if (if_block0) if_block0.c();
10756      t = space();
10757      if (if_block1) if_block1.c();
10758      if_block1_anchor = empty();
10759    },
10760    m(target, anchor) {
10761      if (if_block0) if_block0.m(target, anchor);
10762      insert(target, t, anchor);
10763      if (if_block1) if_block1.m(target, anchor);
10764      insert(target, if_block1_anchor, anchor);
10765    },
10766    p(ctx2, dirty) {
10767      if (
10768        /*heading*/
10769        ctx2[6]
10770      ) {
10771        if (if_block0) {
10772          if_block0.p(ctx2, dirty);
10773        } else {
10774          if_block0 = create_if_block_2$d(ctx2);
10775          if_block0.c();
10776          if_block0.m(t.parentNode, t);
10777        }
10778      } else if (if_block0) {
10779        if_block0.d(1);
10780        if_block0 = null;
10781      }
10782      if (
10783        /*paragraph*/
10784        ctx2[5]
10785      ) {
10786        if (if_block1) {
10787          if_block1.p(ctx2, dirty);
10788        } else {
10789          if_block1 = create_if_block_1$e(ctx2);
10790          if_block1.c();
10791          if_block1.m(if_block1_anchor.parentNode, if_block1_anchor);
10792        }
10793      } else if (if_block1) {
10794        if_block1.d(1);
10795        if_block1 = null;
10796      }
10797    },
10798    d(detaching) {
10799      if (detaching) {
10800        detach(t);
10801        detach(if_block1_anchor);
10802      }
10803      if (if_block0) if_block0.d(detaching);
10804      if (if_block1) if_block1.d(detaching);
10805    }
10806  };
10807}
10808function create_if_block_3$b(ctx) {
10809  let span;
10810  let t0;
10811  let t1_value = (
10812    /*i18n*/
10813    ctx[1]("common.or") + ""
10814  );
10815  let t1;
10816  let t2;
10817  let t3;
10818  let t4_value = (
10819    /*message*/
10820    (ctx[2] || /*i18n*/
10821    ctx[1]("upload_text.click_to_upload")) + ""
10822  );
10823  let t4;
10824  return {
10825    c() {
10826      span = element("span");
10827      t0 = text("- ");
10828      t1 = text(t1_value);
10829      t2 = text(" -");
10830      t3 = space();
10831      t4 = text(t4_value);
10832      attr(span, "class", "or svelte-1xg7h5n");
10833    },
10834    m(target, anchor) {
10835      insert(target, span, anchor);
10836      append(span, t0);
10837      append(span, t1);
10838      append(span, t2);
10839      insert(target, t3, anchor);
10840      insert(target, t4, anchor);
10841    },
10842    p(ctx2, dirty) {
10843      if (dirty & /*i18n*/
10844      2 && t1_value !== (t1_value = /*i18n*/
10845      ctx2[1]("common.or") + "")) set_data(t1, t1_value);
10846      if (dirty & /*message, i18n*/
10847      6 && t4_value !== (t4_value = /*message*/
10848      (ctx2[2] || /*i18n*/
10849      ctx2[1]("upload_text.click_to_upload")) + "")) set_data(t4, t4_value);
10850    },
10851    d(detaching) {
10852      if (detaching) {
10853        detach(span);
10854        detach(t3);
10855        detach(t4);
10856      }
10857    }
10858  };
10859}
10860function create_if_block_2$d(ctx) {
10861  let h2;
10862  let t;
10863  return {
10864    c() {
10865      h2 = element("h2");
10866      t = text(
10867        /*heading*/
10868        ctx[6]
10869      );
10870      attr(h2, "class", "svelte-1xg7h5n");
10871    },
10872    m(target, anchor) {
10873      insert(target, h2, anchor);
10874      append(h2, t);
10875    },
10876    p(ctx2, dirty) {
10877      if (dirty & /*heading*/
10878      64) set_data(
10879        t,
10880        /*heading*/
10881        ctx2[6]
10882      );
10883    },
10884    d(detaching) {
10885      if (detaching) {
10886        detach(h2);
10887      }
10888    }
10889  };
10890}
10891function create_if_block_1$e(ctx) {
10892  let p;
10893  let t;
10894  return {
10895    c() {
10896      p = element("p");
10897      t = text(
10898        /*paragraph*/
10899        ctx[5]
10900      );
10901      attr(p, "class", "svelte-1xg7h5n");
10902    },
10903    m(target, anchor) {
10904      insert(target, p, anchor);
10905      append(p, t);
10906    },
10907    p(ctx2, dirty) {
10908      if (dirty & /*paragraph*/
10909      32) set_data(
10910        t,
10911        /*paragraph*/
10912        ctx2[5]
10913      );
10914    },
10915    d(detaching) {
10916      if (detaching) {
10917        detach(p);
10918      }
10919    }
10920  };
10921}
10922function create_fragment$y(ctx) {
10923  let div;
10924  let span;
10925  let current_block_type_index;
10926  let if_block0;
10927  let t;
10928  let current;
10929  const if_block_creators = [create_if_block_4$9, create_else_block_1$3];
10930  const if_blocks = [];
10931  function select_block_type(ctx2, dirty) {
10932    if (
10933      /*type*/
10934      ctx2[0] === "clipboard"
10935    ) return 0;
10936    return 1;
10937  }
10938  current_block_type_index = select_block_type(ctx);
10939  if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
10940  function select_block_type_1(ctx2, dirty) {
10941    if (
10942      /*heading*/
10943      ctx2[6] || /*paragraph*/
10944      ctx2[5]
10945    ) return create_if_block$k;
10946    return create_else_block$9;
10947  }
10948  let current_block_type = select_block_type_1(ctx);
10949  let if_block1 = current_block_type(ctx);
10950  return {
10951    c() {
10952      div = element("div");
10953      span = element("span");
10954      if_block0.c();
10955      t = space();
10956      if_block1.c();
10957      attr(span, "class", "icon-wrap svelte-1xg7h5n");
10958      toggle_class(
10959        span,
10960        "hovered",
10961        /*hovered*/
10962        ctx[4]
10963      );
10964      attr(div, "class", "wrap svelte-1xg7h5n");
10965    },
10966    m(target, anchor) {
10967      insert(target, div, anchor);
10968      append(div, span);
10969      if_blocks[current_block_type_index].m(span, null);
10970      append(div, t);
10971      if_block1.m(div, null);
10972      current = true;
10973    },
10974    p(ctx2, [dirty]) {
10975      let previous_block_index = current_block_type_index;
10976      current_block_type_index = select_block_type(ctx2);
10977      if (current_block_type_index !== previous_block_index) {
10978        group_outros();
10979        transition_out(if_blocks[previous_block_index], 1, 1, () => {
10980          if_blocks[previous_block_index] = null;
10981        });
10982        check_outros();
10983        if_block0 = if_blocks[current_block_type_index];
10984        if (!if_block0) {
10985          if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
10986          if_block0.c();
10987        }
10988        transition_in(if_block0, 1);
10989        if_block0.m(span, null);
10990      }
10991      if (!current || dirty & /*hovered*/
10992      16) {
10993        toggle_class(
10994          span,
10995          "hovered",
10996          /*hovered*/
10997          ctx2[4]
10998        );
10999      }
11000      if (current_block_type === (current_block_type = select_block_type_1(ctx2)) && if_block1) {
11001        if_block1.p(ctx2, dirty);
11002      } else {
11003        if_block1.d(1);
11004        if_block1 = current_block_type(ctx2);
11005        if (if_block1) {
11006          if_block1.c();
11007          if_block1.m(div, null);
11008        }
11009      }
11010    },
11011    i(local) {
11012      if (current) return;
11013      transition_in(if_block0);
11014      current = true;
11015    },
11016    o(local) {
11017      transition_out(if_block0);
11018      current = false;
11019    },
11020    d(detaching) {
11021      if (detaching) {
11022        detach(div);
11023      }
11024      if_blocks[current_block_type_index].d();
11025      if_block1.d();
11026    }
11027  };
11028}
11029function instance$x($$self, $$props, $$invalidate) {
11030  let heading2;
11031  let paragraph2;
11032  let { type = "file" } = $$props;
11033  let { i18n } = $$props;
11034  let { message = void 0 } = $$props;
11035  let { mode = "full" } = $$props;
11036  let { hovered = false } = $$props;
11037  let { placeholder = void 0 } = $$props;
11038  const defs = {
11039    image: "upload_text.drop_image",
11040    video: "upload_text.drop_video",
11041    audio: "upload_text.drop_audio",
11042    file: "upload_text.drop_file",
11043    csv: "upload_text.drop_csv",
11044    gallery: "upload_text.drop_gallery",
11045    clipboard: "upload_text.paste_clipboard"
11046  };
11047  $$self.$$set = ($$props2) => {
11048    if ("type" in $$props2) $$invalidate(0, type = $$props2.type);
11049    if ("i18n" in $$props2) $$invalidate(1, i18n = $$props2.i18n);
11050    if ("message" in $$props2) $$invalidate(2, message = $$props2.message);
11051    if ("mode" in $$props2) $$invalidate(3, mode = $$props2.mode);
11052    if ("hovered" in $$props2) $$invalidate(4, hovered = $$props2.hovered);
11053    if ("placeholder" in $$props2) $$invalidate(8, placeholder = $$props2.placeholder);
11054  };
11055  $$self.$$.update = () => {
11056    if ($$self.$$.dirty & /*placeholder*/
11057    256) {
11058      $$invalidate(6, [heading2, paragraph2] = placeholder ? inject(placeholder) : [false, false], heading2, ($$invalidate(5, paragraph2), $$invalidate(8, placeholder)));
11059    }
11060  };
11061  return [type, i18n, message, mode, hovered, paragraph2, heading2, defs, placeholder];
11062}
11063class UploadText extends SvelteComponent {
11064  constructor(options) {
11065    super();
11066    init(this, options, instance$x, create_fragment$y, safe_not_equal, {
11067      type: 0,
11068      i18n: 1,
11069      message: 2,
11070      mode: 3,
11071      hovered: 4,
11072      placeholder: 8
11073    });
11074  }
11075}
11076function create_if_block$j(ctx) {
11077  let span;
11078  let show_if_3 = (
11079    /*sources*/
11080    ctx[1].includes("upload")
11081  );
11082  let t0;
11083  let show_if_2 = (
11084    /*sources*/
11085    ctx[1].includes("microphone")
11086  );
11087  let t1;
11088  let show_if_1 = (
11089    /*sources*/
11090    ctx[1].includes("webcam")
11091  );
11092  let t2;
11093  let show_if = (
11094    /*sources*/
11095    ctx[1].includes("clipboard")
11096  );
11097  let current;
11098  let if_block0 = show_if_3 && create_if_block_4$8(ctx);
11099  let if_block1 = show_if_2 && create_if_block_3$a(ctx);
11100  let if_block2 = show_if_1 && create_if_block_2$c(ctx);
11101  let if_block3 = show_if && create_if_block_1$d(ctx);
11102  return {
11103    c() {
11104      span = element("span");
11105      if (if_block0) if_block0.c();
11106      t0 = space();
11107      if (if_block1) if_block1.c();
11108      t1 = space();
11109      if (if_block2) if_block2.c();
11110      t2 = space();
11111      if (if_block3) if_block3.c();
11112      attr(span, "class", "source-selection svelte-15ls1gu");
11113      attr(span, "data-testid", "source-select");
11114    },
11115    m(target, anchor) {
11116      insert(target, span, anchor);
11117      if (if_block0) if_block0.m(span, null);
11118      append(span, t0);
11119      if (if_block1) if_block1.m(span, null);
11120      append(span, t1);
11121      if (if_block2) if_block2.m(span, null);
11122      append(span, t2);
11123      if (if_block3) if_block3.m(span, null);
11124      current = true;
11125    },
11126    p(ctx2, dirty) {
11127      if (dirty & /*sources*/
11128      2) show_if_3 = /*sources*/
11129      ctx2[1].includes("upload");
11130      if (show_if_3) {
11131        if (if_block0) {
11132          if_block0.p(ctx2, dirty);
11133          if (dirty & /*sources*/
11134          2) {
11135            transition_in(if_block0, 1);
11136          }
11137        } else {
11138          if_block0 = create_if_block_4$8(ctx2);
11139          if_block0.c();
11140          transition_in(if_block0, 1);
11141          if_block0.m(span, t0);
11142        }
11143      } else if (if_block0) {
11144        group_outros();
11145        transition_out(if_block0, 1, 1, () => {
11146          if_block0 = null;
11147        });
11148        check_outros();
11149      }
11150      if (dirty & /*sources*/
11151      2) show_if_2 = /*sources*/
11152      ctx2[1].includes("microphone");
11153      if (show_if_2) {
11154        if (if_block1) {
11155          if_block1.p(ctx2, dirty);
11156          if (dirty & /*sources*/
11157          2) {
11158            transition_in(if_block1, 1);
11159          }
11160        } else {
11161          if_block1 = create_if_block_3$a(ctx2);
11162          if_block1.c();
11163          transition_in(if_block1, 1);
11164          if_block1.m(span, t1);
11165        }
11166      } else if (if_block1) {
11167        group_outros();
11168        transition_out(if_block1, 1, 1, () => {
11169          if_block1 = null;
11170        });
11171        check_outros();
11172      }
11173      if (dirty & /*sources*/
11174      2) show_if_1 = /*sources*/
11175      ctx2[1].includes("webcam");
11176      if (show_if_1) {
11177        if (if_block2) {
11178          if_block2.p(ctx2, dirty);
11179          if (dirty & /*sources*/
11180          2) {
11181            transition_in(if_block2, 1);
11182          }
11183        } else {
11184          if_block2 = create_if_block_2$c(ctx2);
11185          if_block2.c();
11186          transition_in(if_block2, 1);
11187          if_block2.m(span, t2);
11188        }
11189      } else if (if_block2) {
11190        group_outros();
11191        transition_out(if_block2, 1, 1, () => {
11192          if_block2 = null;
11193        });
11194        check_outros();
11195      }
11196      if (dirty & /*sources*/
11197      2) show_if = /*sources*/
11198      ctx2[1].includes("clipboard");
11199      if (show_if) {
11200        if (if_block3) {
11201          if_block3.p(ctx2, dirty);
11202          if (dirty & /*sources*/
11203          2) {
11204            transition_in(if_block3, 1);
11205          }
11206        } else {
11207          if_block3 = create_if_block_1$d(ctx2);
11208          if_block3.c();
11209          transition_in(if_block3, 1);
11210          if_block3.m(span, null);
11211        }
11212      } else if (if_block3) {
11213        group_outros();
11214        transition_out(if_block3, 1, 1, () => {
11215          if_block3 = null;
11216        });
11217        check_outros();
11218      }
11219    },
11220    i(local) {
11221      if (current) return;
11222      transition_in(if_block0);
11223      transition_in(if_block1);
11224      transition_in(if_block2);
11225      transition_in(if_block3);
11226      current = true;
11227    },
11228    o(local) {
11229      transition_out(if_block0);
11230      transition_out(if_block1);
11231      transition_out(if_block2);
11232      transition_out(if_block3);
11233      current = false;
11234    },
11235    d(detaching) {
11236      if (detaching) {
11237        detach(span);
11238      }
11239      if (if_block0) if_block0.d();
11240      if (if_block1) if_block1.d();
11241      if (if_block2) if_block2.d();
11242      if (if_block3) if_block3.d();
11243    }
11244  };
11245}
11246function create_if_block_4$8(ctx) {
11247  let button;
11248  let upload;
11249  let current;
11250  let mounted;
11251  let dispose;
11252  upload = new Upload$1({});
11253  return {
11254    c() {
11255      button = element("button");
11256      create_component(upload.$$.fragment);
11257      attr(button, "class", "icon svelte-15ls1gu");
11258      attr(button, "aria-label", "Upload file");
11259      toggle_class(
11260        button,
11261        "selected",
11262        /*active_source*/
11263        ctx[0] === "upload" || !/*active_source*/
11264        ctx[0]
11265      );
11266    },
11267    m(target, anchor) {
11268      insert(target, button, anchor);
11269      mount_component(upload, button, null);
11270      current = true;
11271      if (!mounted) {
11272        dispose = listen(
11273          button,
11274          "click",
11275          /*click_handler*/
11276          ctx[6]
11277        );
11278        mounted = true;
11279      }
11280    },
11281    p(ctx2, dirty) {
11282      if (!current || dirty & /*active_source*/
11283      1) {
11284        toggle_class(
11285          button,
11286          "selected",
11287          /*active_source*/
11288          ctx2[0] === "upload" || !/*active_source*/
11289          ctx2[0]
11290        );
11291      }
11292    },
11293    i(local) {
11294      if (current) return;
11295      transition_in(upload.$$.fragment, local);
11296      current = true;
11297    },
11298    o(local) {
11299      transition_out(upload.$$.fragment, local);
11300      current = false;
11301    },
11302    d(detaching) {
11303      if (detaching) {
11304        detach(button);
11305      }
11306      destroy_component(upload);
11307      mounted = false;
11308      dispose();
11309    }
11310  };
11311}
11312function create_if_block_3$a(ctx) {
11313  let button;
11314  let microphone;
11315  let current;
11316  let mounted;
11317  let dispose;
11318  microphone = new Microphone({});
11319  return {
11320    c() {
11321      button = element("button");
11322      create_component(microphone.$$.fragment);
11323      attr(button, "class", "icon svelte-15ls1gu");
11324      attr(button, "aria-label", "Record audio");
11325      toggle_class(
11326        button,
11327        "selected",
11328        /*active_source*/
11329        ctx[0] === "microphone"
11330      );
11331    },
11332    m(target, anchor) {
11333      insert(target, button, anchor);
11334      mount_component(microphone, button, null);
11335      current = true;
11336      if (!mounted) {
11337        dispose = listen(
11338          button,
11339          "click",
11340          /*click_handler_1*/
11341          ctx[7]
11342        );
11343        mounted = true;
11344      }
11345    },
11346    p(ctx2, dirty) {
11347      if (!current || dirty & /*active_source*/
11348      1) {
11349        toggle_class(
11350          button,
11351          "selected",
11352          /*active_source*/
11353          ctx2[0] === "microphone"
11354        );
11355      }
11356    },
11357    i(local) {
11358      if (current) return;
11359      transition_in(microphone.$$.fragment, local);
11360      current = true;
11361    },
11362    o(local) {
11363      transition_out(microphone.$$.fragment, local);
11364      current = false;
11365    },
11366    d(detaching) {
11367      if (detaching) {
11368        detach(button);
11369      }
11370      destroy_component(microphone);
11371      mounted = false;
11372      dispose();
11373    }
11374  };
11375}
11376function create_if_block_2$c(ctx) {
11377  let button;
11378  let webcam;
11379  let current;
11380  let mounted;
11381  let dispose;
11382  webcam = new Webcam$1({});
11383  return {
11384    c() {
11385      button = element("button");
11386      create_component(webcam.$$.fragment);
11387      attr(button, "class", "icon svelte-15ls1gu");
11388      attr(button, "aria-label", "Capture from camera");
11389      toggle_class(
11390        button,
11391        "selected",
11392        /*active_source*/
11393        ctx[0] === "webcam"
11394      );
11395    },
11396    m(target, anchor) {
11397      insert(target, button, anchor);
11398      mount_component(webcam, button, null);
11399      current = true;
11400      if (!mounted) {
11401        dispose = listen(
11402          button,
11403          "click",
11404          /*click_handler_2*/
11405          ctx[8]
11406        );
11407        mounted = true;
11408      }
11409    },
11410    p(ctx2, dirty) {
11411      if (!current || dirty & /*active_source*/
11412      1) {
11413        toggle_class(
11414          button,
11415          "selected",
11416          /*active_source*/
11417          ctx2[0] === "webcam"
11418        );
11419      }
11420    },
11421    i(local) {
11422      if (current) return;
11423      transition_in(webcam.$$.fragment, local);
11424      current = true;
11425    },
11426    o(local) {
11427      transition_out(webcam.$$.fragment, local);
11428      current = false;
11429    },
11430    d(detaching) {
11431      if (detaching) {
11432        detach(button);
11433      }
11434      destroy_component(webcam);
11435      mounted = false;
11436      dispose();
11437    }
11438  };
11439}
11440function create_if_block_1$d(ctx) {
11441  let button;
11442  let imagepaste;
11443  let current;
11444  let mounted;
11445  let dispose;
11446  imagepaste = new ImagePaste({});
11447  return {
11448    c() {
11449      button = element("button");
11450      create_component(imagepaste.$$.fragment);
11451      attr(button, "class", "icon svelte-15ls1gu");
11452      attr(button, "aria-label", "Paste from clipboard");
11453      toggle_class(
11454        button,
11455        "selected",
11456        /*active_source*/
11457        ctx[0] === "clipboard"
11458      );
11459    },
11460    m(target, anchor) {
11461      insert(target, button, anchor);
11462      mount_component(imagepaste, button, null);
11463      current = true;
11464      if (!mounted) {
11465        dispose = listen(
11466          button,
11467          "click",
11468          /*click_handler_3*/
11469          ctx[9]
11470        );
11471        mounted = true;
11472      }
11473    },
11474    p(ctx2, dirty) {
11475      if (!current || dirty & /*active_source*/
11476      1) {
11477        toggle_class(
11478          button,
11479          "selected",
11480          /*active_source*/
11481          ctx2[0] === "clipboard"
11482        );
11483      }
11484    },
11485    i(local) {
11486      if (current) return;
11487      transition_in(imagepaste.$$.fragment, local);
11488      current = true;
11489    },
11490    o(local) {
11491      transition_out(imagepaste.$$.fragment, local);
11492      current = false;
11493    },
11494    d(detaching) {
11495      if (detaching) {
11496        detach(button);
11497      }
11498      destroy_component(imagepaste);
11499      mounted = false;
11500      dispose();
11501    }
11502  };
11503}
11504function create_fragment$x(ctx) {
11505  let if_block_anchor;
11506  let current;
11507  let if_block = (
11508    /*unique_sources*/
11509    ctx[2].length > 1 && create_if_block$j(ctx)
11510  );
11511  return {
11512    c() {
11513      if (if_block) if_block.c();
11514      if_block_anchor = empty();
11515    },
11516    m(target, anchor) {
11517      if (if_block) if_block.m(target, anchor);
11518      insert(target, if_block_anchor, anchor);
11519      current = true;
11520    },
11521    p(ctx2, [dirty]) {
11522      if (
11523        /*unique_sources*/
11524        ctx2[2].length > 1
11525      ) {
11526        if (if_block) {
11527          if_block.p(ctx2, dirty);
11528          if (dirty & /*unique_sources*/
11529          4) {
11530            transition_in(if_block, 1);
11531          }
11532        } else {
11533          if_block = create_if_block$j(ctx2);
11534          if_block.c();
11535          transition_in(if_block, 1);
11536          if_block.m(if_block_anchor.parentNode, if_block_anchor);
11537        }
11538      } else if (if_block) {
11539        group_outros();
11540        transition_out(if_block, 1, 1, () => {
11541          if_block = null;
11542        });
11543        check_outros();
11544      }
11545    },
11546    i(local) {
11547      if (current) return;
11548      transition_in(if_block);
11549      current = true;
11550    },
11551    o(local) {
11552      transition_out(if_block);
11553      current = false;
11554    },
11555    d(detaching) {
11556      if (detaching) {
11557        detach(if_block_anchor);
11558      }
11559      if (if_block) if_block.d(detaching);
11560    }
11561  };
11562}
11563function instance$w($$self, $$props, $$invalidate) {
11564  let unique_sources;
11565  let { sources } = $$props;
11566  let { active_source } = $$props;
11567  let { handle_clear = () => {
11568  } } = $$props;
11569  let { handle_select = () => {
11570  } } = $$props;
11571  async function handle_select_source(source) {
11572    handle_clear();
11573    $$invalidate(0, active_source = source);
11574    handle_select(source);
11575  }
11576  const click_handler = () => handle_select_source("upload");
11577  const click_handler_1 = () => handle_select_source("microphone");
11578  const click_handler_2 = () => handle_select_source("webcam");
11579  const click_handler_3 = () => handle_select_source("clipboard");
11580  $$self.$$set = ($$props2) => {
11581    if ("sources" in $$props2) $$invalidate(1, sources = $$props2.sources);
11582    if ("active_source" in $$props2) $$invalidate(0, active_source = $$props2.active_source);
11583    if ("handle_clear" in $$props2) $$invalidate(4, handle_clear = $$props2.handle_clear);
11584    if ("handle_select" in $$props2) $$invalidate(5, handle_select = $$props2.handle_select);
11585  };
11586  $$self.$$.update = () => {
11587    if ($$self.$$.dirty & /*sources*/
11588    2) {
11589      $$invalidate(2, unique_sources = [...new Set(sources)]);
11590    }
11591  };
11592  return [
11593    active_source,
11594    sources,
11595    unique_sources,
11596    handle_select_source,
11597    handle_clear,
11598    handle_select,
11599    click_handler,
11600    click_handler_1,
11601    click_handler_2,
11602    click_handler_3
11603  ];
11604}
11605class SelectSource extends SvelteComponent {
11606  constructor(options) {
11607    super();
11608    init(this, options, instance$w, create_fragment$x, safe_not_equal, {
11609      sources: 1,
11610      active_source: 0,
11611      handle_clear: 4,
11612      handle_select: 5
11613    });
11614  }
11615}
11616function create_fragment$w(ctx) {
11617  let div;
11618  let div_class_value;
11619  let current;
11620  const default_slot_template = (
11621    /*#slots*/
11622    ctx[3].default
11623  );
11624  const default_slot = create_slot(
11625    default_slot_template,
11626    ctx,
11627    /*$$scope*/
11628    ctx[2],
11629    null
11630  );
11631  return {
11632    c() {
11633      div = element("div");
11634      if (default_slot) default_slot.c();
11635      attr(div, "class", div_class_value = null_to_empty(`icon-button-wrapper ${/*top_panel*/
11636      ctx[0] ? "top-panel" : ""} ${/*display_top_corner*/
11637      ctx[1] ? "display-top-corner" : "hide-top-corner"}`) + " svelte-1h0hs6p");
11638    },
11639    m(target, anchor) {
11640      insert(target, div, anchor);
11641      if (default_slot) {
11642        default_slot.m(div, null);
11643      }
11644      current = true;
11645    },
11646    p(ctx2, [dirty]) {
11647      if (default_slot) {
11648        if (default_slot.p && (!current || dirty & /*$$scope*/
11649        4)) {
11650          update_slot_base(
11651            default_slot,
11652            default_slot_template,
11653            ctx2,
11654            /*$$scope*/
11655            ctx2[2],
11656            !current ? get_all_dirty_from_scope(
11657              /*$$scope*/
11658              ctx2[2]
11659            ) : get_slot_changes(
11660              default_slot_template,
11661              /*$$scope*/
11662              ctx2[2],
11663              dirty,
11664              null
11665            ),
11666            null
11667          );
11668        }
11669      }
11670      if (!current || dirty & /*top_panel, display_top_corner*/
11671      3 && div_class_value !== (div_class_value = null_to_empty(`icon-button-wrapper ${/*top_panel*/
11672      ctx2[0] ? "top-panel" : ""} ${/*display_top_corner*/
11673      ctx2[1] ? "display-top-corner" : "hide-top-corner"}`) + " svelte-1h0hs6p")) {
11674        attr(div, "class", div_class_value);
11675      }
11676    },
11677    i(local) {
11678      if (current) return;
11679      transition_in(default_slot, local);
11680      current = true;
11681    },
11682    o(local) {
11683      transition_out(default_slot, local);
11684      current = false;
11685    },
11686    d(detaching) {
11687      if (detaching) {
11688        detach(div);
11689      }
11690      if (default_slot) default_slot.d(detaching);
11691    }
11692  };
11693}
11694function instance$v($$self, $$props, $$invalidate) {
11695  let { $$slots: slots = {}, $$scope } = $$props;
11696  let { top_panel = true } = $$props;
11697  let { display_top_corner = false } = $$props;
11698  $$self.$$set = ($$props2) => {
11699    if ("top_panel" in $$props2) $$invalidate(0, top_panel = $$props2.top_panel);
11700    if ("display_top_corner" in $$props2) $$invalidate(1, display_top_corner = $$props2.display_top_corner);
11701    if ("$$scope" in $$props2) $$invalidate(2, $$scope = $$props2.$$scope);
11702  };
11703  return [top_panel, display_top_corner, $$scope, slots];
11704}
11705class IconButtonWrapper extends SvelteComponent {
11706  constructor(options) {
11707    super();
11708    init(this, options, instance$v, create_fragment$w, safe_not_equal, { top_panel: 0, display_top_corner: 1 });
11709  }
11710}
11711function create_else_block$8(ctx) {
11712  let iconbutton;
11713  let current;
11714  iconbutton = new IconButton({
11715    props: { Icon: Maximize, label: "Fullscreen" }
11716  });
11717  iconbutton.$on(
11718    "click",
11719    /*click_handler_1*/
11720    ctx[3]
11721  );
11722  return {
11723    c() {
11724      create_component(iconbutton.$$.fragment);
11725    },
11726    m(target, anchor) {
11727      mount_component(iconbutton, target, anchor);
11728      current = true;
11729    },
11730    p: noop,
11731    i(local) {
11732      if (current) return;
11733      transition_in(iconbutton.$$.fragment, local);
11734      current = true;
11735    },
11736    o(local) {
11737      transition_out(iconbutton.$$.fragment, local);
11738      current = false;
11739    },
11740    d(detaching) {
11741      destroy_component(iconbutton, detaching);
11742    }
11743  };
11744}
11745function create_if_block$i(ctx) {
11746  let iconbutton;
11747  let current;
11748  iconbutton = new IconButton({
11749    props: {
11750      Icon: Minimize,
11751      label: "Exit fullscreen mode"
11752    }
11753  });
11754  iconbutton.$on(
11755    "click",
11756    /*click_handler*/
11757    ctx[2]
11758  );
11759  return {
11760    c() {
11761      create_component(iconbutton.$$.fragment);
11762    },
11763    m(target, anchor) {
11764      mount_component(iconbutton, target, anchor);
11765      current = true;
11766    },
11767    p: noop,
11768    i(local) {
11769      if (current) return;
11770      transition_in(iconbutton.$$.fragment, local);
11771      current = true;
11772    },
11773    o(local) {
11774      transition_out(iconbutton.$$.fragment, local);
11775      current = false;
11776    },
11777    d(detaching) {
11778      destroy_component(iconbutton, detaching);
11779    }
11780  };
11781}
11782function create_fragment$v(ctx) {
11783  let current_block_type_index;
11784  let if_block;
11785  let if_block_anchor;
11786  let current;
11787  const if_block_creators = [create_if_block$i, create_else_block$8];
11788  const if_blocks = [];
11789  function select_block_type(ctx2, dirty) {
11790    if (
11791      /*fullscreen*/
11792      ctx2[0]
11793    ) return 0;
11794    return 1;
11795  }
11796  current_block_type_index = select_block_type(ctx);
11797  if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
11798  return {
11799    c() {
11800      if_block.c();
11801      if_block_anchor = empty();
11802    },
11803    m(target, anchor) {
11804      if_blocks[current_block_type_index].m(target, anchor);
11805      insert(target, if_block_anchor, anchor);
11806      current = true;
11807    },
11808    p(ctx2, [dirty]) {
11809      let previous_block_index = current_block_type_index;
11810      current_block_type_index = select_block_type(ctx2);
11811      if (current_block_type_index === previous_block_index) {
11812        if_blocks[current_block_type_index].p(ctx2, dirty);
11813      } else {
11814        group_outros();
11815        transition_out(if_blocks[previous_block_index], 1, 1, () => {
11816          if_blocks[previous_block_index] = null;
11817        });
11818        check_outros();
11819        if_block = if_blocks[current_block_type_index];
11820        if (!if_block) {
11821          if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
11822          if_block.c();
11823        } else {
11824          if_block.p(ctx2, dirty);
11825        }
11826        transition_in(if_block, 1);
11827        if_block.m(if_block_anchor.parentNode, if_block_anchor);
11828      }
11829    },
11830    i(local) {
11831      if (current) return;
11832      transition_in(if_block);
11833      current = true;
11834    },
11835    o(local) {
11836      transition_out(if_block);
11837      current = false;
11838    },
11839    d(detaching) {
11840      if (detaching) {
11841        detach(if_block_anchor);
11842      }
11843      if_blocks[current_block_type_index].d(detaching);
11844    }
11845  };
11846}
11847function instance$u($$self, $$props, $$invalidate) {
11848  const dispatch2 = createEventDispatcher();
11849  let { fullscreen } = $$props;
11850  const click_handler = () => dispatch2("fullscreen", false);
11851  const click_handler_1 = () => dispatch2("fullscreen", true);
11852  $$self.$$set = ($$props2) => {
11853    if ("fullscreen" in $$props2) $$invalidate(0, fullscreen = $$props2.fullscreen);
11854  };
11855  return [fullscreen, dispatch2, click_handler, click_handler_1];
11856}
11857class FullscreenButton extends SvelteComponent {
11858  constructor(options) {
11859    super();
11860    init(this, options, instance$u, create_fragment$v, safe_not_equal, { fullscreen: 0 });
11861  }
11862}
11863var has$1 = Object.prototype.hasOwnProperty;
11864function find(iter, tar, key) {
11865  for (key of iter.keys()) {
11866    if (dequal$1(key, tar)) return key;
11867  }
11868}
11869function dequal$1(foo, bar) {
11870  var ctor, len, tmp;
11871  if (foo === bar) return true;
11872  if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
11873    if (ctor === Date) return foo.getTime() === bar.getTime();
11874    if (ctor === RegExp) return foo.toString() === bar.toString();
11875    if (ctor === Array) {
11876      if ((len = foo.length) === bar.length) {
11877        while (len-- && dequal$1(foo[len], bar[len])) ;
11878      }
11879      return len === -1;
11880    }
11881    if (ctor === Set) {
11882      if (foo.size !== bar.size) {
11883        return false;
11884      }
11885      for (len of foo) {
11886        tmp = len;
11887        if (tmp && typeof tmp === "object") {
11888          tmp = find(bar, tmp);
11889          if (!tmp) return false;
11890        }
11891        if (!bar.has(tmp)) return false;
11892      }
11893      return true;
11894    }
11895    if (ctor === Map) {
11896      if (foo.size !== bar.size) {
11897        return false;
11898      }
11899      for (len of foo) {
11900        tmp = len[0];
11901        if (tmp && typeof tmp === "object") {
11902          tmp = find(bar, tmp);
11903          if (!tmp) return false;
11904        }
11905        if (!dequal$1(len[1], bar.get(tmp))) {
11906          return false;
11907        }
11908      }
11909      return true;
11910    }
11911    if (ctor === ArrayBuffer) {
11912      foo = new Uint8Array(foo);
11913      bar = new Uint8Array(bar);
11914    } else if (ctor === DataView) {
11915      if ((len = foo.byteLength) === bar.byteLength) {
11916        while (len-- && foo.getInt8(len) === bar.getInt8(len)) ;
11917      }
11918      return len === -1;
11919    }
11920    if (ArrayBuffer.isView(foo)) {
11921      if ((len = foo.byteLength) === bar.byteLength) {
11922        while (len-- && foo[len] === bar[len]) ;
11923      }
11924      return len === -1;
11925    }
11926    if (!ctor || typeof foo === "object") {
11927      len = 0;
11928      for (ctor in foo) {
11929        if (has$1.call(foo, ctor) && ++len && !has$1.call(bar, ctor)) return false;
11930        if (!(ctor in bar) || !dequal$1(foo[ctor], bar[ctor])) return false;
11931      }
11932      return Object.keys(bar).length === len;
11933    }
11934  }
11935  return foo !== foo && bar !== bar;
11936}
11937const subscriber_queue = [];
11938function writable(value, start = noop) {
11939  let stop;
11940  const subscribers = /* @__PURE__ */ new Set();
11941  function set(new_value) {
11942    if (safe_not_equal(value, new_value)) {
11943      value = new_value;
11944      if (stop) {
11945        const run_queue = !subscriber_queue.length;
11946        for (const subscriber of subscribers) {
11947          subscriber[1]();
11948          subscriber_queue.push(subscriber, value);
11949        }
11950        if (run_queue) {
11951          for (let i = 0; i < subscriber_queue.length; i += 2) {
11952            subscriber_queue[i][0](subscriber_queue[i + 1]);
11953          }
11954          subscriber_queue.length = 0;
11955        }
11956      }
11957    }
11958  }
11959  function update2(fn) {
11960    set(fn(value));
11961  }
11962  function subscribe2(run2, invalidate = noop) {
11963    const subscriber = [run2, invalidate];
11964    subscribers.add(subscriber);
11965    if (subscribers.size === 1) {
11966      stop = start(set, update2) || noop;
11967    }
11968    run2(value);
11969    return () => {
11970      subscribers.delete(subscriber);
11971      if (subscribers.size === 0 && stop) {
11972        stop();
11973        stop = null;
11974      }
11975    };
11976  }
11977  return { set, update: update2, subscribe: subscribe2 };
11978}
11979function get_sort_status$1(name, sort_columns, headers) {
11980  if (!sort_columns.length) return "none";
11981  const sort_item = sort_columns.find((item) => {
11982    const col = item.col;
11983    if (col < 0 || col >= headers.length) return false;
11984    return headers[col] === name;
11985  });
11986  if (!sort_item) return "none";
11987  return sort_item.direction;
11988}
11989function sort_data$1(data, sort_columns) {
11990  if (!data || !data.length || !data[0]) {
11991    return [];
11992  }
11993  if (sort_columns.length > 0) {
11994    const row_indices = [...Array(data.length)].map((_, i) => i);
11995    row_indices.sort((row_a_idx, row_b_idx) => {
11996      const row_a = data[row_a_idx];
11997      const row_b = data[row_b_idx];
11998      for (const { col: sort_by, direction } of sort_columns) {
11999        if (!row_a || !row_b || sort_by < 0 || sort_by >= row_a.length || sort_by >= row_b.length || !row_a[sort_by] || !row_b[sort_by]) {
12000          continue;
12001        }
12002        const val_a = row_a[sort_by].value;
12003        const val_b = row_b[sort_by].value;
12004        const comparison = val_a < val_b ? -1 : val_a > val_b ? 1 : 0;
12005        if (comparison !== 0) {
12006          return direction === "asc" ? comparison : -comparison;
12007        }
12008      }
12009      return 0;
12010    });
12011    return row_indices;
12012  }
12013  return [...Array(data.length)].map((_, i) => i);
12014}
12015function sort_data_and_preserve_selection$1(data, display_value, styling, sort_columns, selected, get_current_indices2) {
12016  let id = null;
12017  if (selected && selected[0] in data && selected[1] in data[selected[0]]) {
12018    id = data[selected[0]][selected[1]].id;
12019  }
12020  sort_table_data$1(data, display_value, styling, sort_columns);
12021  let new_selected = selected;
12022  if (id) {
12023    const [i, j] = get_current_indices2(id, data);
12024    new_selected = [i, j];
12025  }
12026  return { data, selected: new_selected };
12027}
12028function filter_data$1(data, filter_columns) {
12029  if (!data || !data.length || !data[0]) {
12030    return [];
12031  }
12032  let row_indices = [...Array(data.length)].map((_, i) => i);
12033  if (filter_columns.length > 0) {
12034    filter_columns.forEach((column) => {
12035      if (column.datatype === "string") {
12036        switch (column.filter) {
12037          case "Contains":
12038            row_indices = row_indices.filter(
12039              (i) => {
12040                var _a;
12041                return (_a = data[i][column.col]) == null ? void 0 : _a.value.toString().includes(column.value);
12042              }
12043            );
12044            break;
12045          case "Does not contain":
12046            row_indices = row_indices.filter(
12047              (i) => {
12048                var _a;
12049                return !((_a = data[i][column.col]) == null ? void 0 : _a.value.toString().includes(column.value));
12050              }
12051            );
12052            break;
12053          case "Starts with":
12054            row_indices = row_indices.filter(
12055              (i) => {
12056                var _a;
12057                return (_a = data[i][column.col]) == null ? void 0 : _a.value.toString().startsWith(column.value);
12058              }
12059            );
12060            break;
12061          case "Ends with":
12062            row_indices = row_indices.filter(
12063              (i) => {
12064                var _a;
12065                return (_a = data[i][column.col]) == null ? void 0 : _a.value.toString().endsWith(column.value);
12066              }
12067            );
12068            break;
12069          case "Is":
12070            row_indices = row_indices.filter(
12071              (i) => {
12072                var _a;
12073                return ((_a = data[i][column.col]) == null ? void 0 : _a.value.toString()) === column.value;
12074              }
12075            );
12076            break;
12077          case "Is not":
12078            row_indices = row_indices.filter(
12079              (i) => {
12080                var _a;
12081                return !(((_a = data[i][column.col]) == null ? void 0 : _a.value.toString()) === column.value);
12082              }
12083            );
12084            break;
12085          case "Is empty":
12086            row_indices = row_indices.filter(
12087              (i) => {
12088                var _a;
12089                return ((_a = data[i][column.col]) == null ? void 0 : _a.value.toString()) === "";
12090              }
12091            );
12092            break;
12093          case "Is not empty":
12094            row_indices = row_indices.filter(
12095              (i) => {
12096                var _a;
12097                return !(((_a = data[i][column.col]) == null ? void 0 : _a.value.toString()) === "");
12098              }
12099            );
12100            break;
12101        }
12102      } else if (column.datatype === "number") {
12103        switch (column.filter) {
12104          case "=":
12105            row_indices = row_indices.filter((i) => {
12106              var _a, _b;
12107              if (!isNaN(Number((_a = data[i][column.col]) == null ? void 0 : _a.value)) && !isNaN(Number(column.value))) {
12108                return Number((_b = data[i][column.col]) == null ? void 0 : _b.value) === Number(column.value);
12109              }
12110              return false;
12111            });
12112            break;
12113          case "≠":
12114            row_indices = row_indices.filter((i) => {
12115              var _a, _b;
12116              if (!isNaN(Number((_a = data[i][column.col]) == null ? void 0 : _a.value)) && !isNaN(Number(column.value))) {
12117                return !(Number((_b = data[i][column.col]) == null ? void 0 : _b.value) === Number(column.value));
12118              }
12119              return false;
12120            });
12121            break;
12122          case ">":
12123            row_indices = row_indices.filter((i) => {
12124              var _a, _b;
12125              if (!isNaN(Number((_a = data[i][column.col]) == null ? void 0 : _a.value)) && !isNaN(Number(column.value))) {
12126                return Number((_b = data[i][column.col]) == null ? void 0 : _b.value) > Number(column.value);
12127              }
12128              return false;
12129            });
12130            break;
12131          case "<":
12132            row_indices = row_indices.filter((i) => {
12133              var _a, _b;
12134              if (!isNaN(Number((_a = data[i][column.col]) == null ? void 0 : _a.value)) && !isNaN(Number(column.value))) {
12135                return Number((_b = data[i][column.col]) == null ? void 0 : _b.value) < Number(column.value);
12136              }
12137              return false;
12138            });
12139            break;
12140          case "≥":
12141            row_indices = row_indices.filter((i) => {
12142              var _a, _b;
12143              if (!isNaN(Number((_a = data[i][column.col]) == null ? void 0 : _a.value)) && !isNaN(Number(column.value))) {
12144                return Number((_b = data[i][column.col]) == null ? void 0 : _b.value) >= Number(column.value);
12145              }
12146              return false;
12147            });
12148            break;
12149          case "≤":
12150            row_indices = row_indices.filter((i) => {
12151              var _a, _b;
12152              if (!isNaN(Number((_a = data[i][column.col]) == null ? void 0 : _a.value)) && !isNaN(Number(column.value))) {
12153                return Number((_b = data[i][column.col]) == null ? void 0 : _b.value) <= Number(column.value);
12154              }
12155              return false;
12156            });
12157            break;
12158          case "Is empty":
12159            row_indices = row_indices.filter(
12160              (i) => {
12161                var _a;
12162                return ((_a = data[i][column.col]) == null ? void 0 : _a.value.toString()) === "";
12163              }
12164            );
12165            break;
12166          case "Is not empty":
12167            row_indices = row_indices.filter((i) => {
12168              var _a, _b;
12169              if (!isNaN(Number((_a = data[i][column.col]) == null ? void 0 : _a.value))) {
12170                return !(((_b = data[i][column.col]) == null ? void 0 : _b.value.toString()) === "");
12171              }
12172              return false;
12173            });
12174            break;
12175        }
12176      }
12177    });
12178    return row_indices;
12179  }
12180  return [...Array(data.length)].map((_, i) => i);
12181}
12182function filter_data_and_preserve_selection$1(data, display_value, styling, filter_columns, selected, get_current_indices2, original_data, original_display_value, original_styling) {
12183  let id = null;
12184  if (selected && selected[0] in data && selected[1] in data[selected[0]]) {
12185    id = data[selected[0]][selected[1]].id;
12186  }
12187  filter_table_data$1(
12188    data,
12189    display_value,
12190    styling,
12191    filter_columns,
12192    original_data,
12193    original_display_value,
12194    original_styling
12195  );
12196  let new_selected = selected;
12197  if (id) {
12198    const [i, j] = get_current_indices2(id, data);
12199    new_selected = [i, j];
12200  }
12201  return { data, selected: new_selected };
12202}
12203var EOL = {}, EOF = {}, QUOTE = 34, NEWLINE = 10, RETURN = 13;
12204function objectConverter(columns) {
12205  return new Function("d", "return {" + columns.map(function(name, i) {
12206    return JSON.stringify(name) + ": d[" + i + '] || ""';
12207  }).join(",") + "}");
12208}
12209function customConverter(columns, f) {
12210  var object = objectConverter(columns);
12211  return function(row, i) {
12212    return f(object(row), i, columns);
12213  };
12214}
12215function inferColumns(rows) {
12216  var columnSet = /* @__PURE__ */ Object.create(null), columns = [];
12217  rows.forEach(function(row) {
12218    for (var column in row) {
12219      if (!(column in columnSet)) {
12220        columns.push(columnSet[column] = column);
12221      }
12222    }
12223  });
12224  return columns;
12225}
12226function pad(value, width) {
12227  var s = value + "", length = s.length;
12228  return length < width ? new Array(width - length + 1).join(0) + s : s;
12229}
12230function formatYear(year) {
12231  return year < 0 ? "-" + pad(-year, 6) : year > 9999 ? "+" + pad(year, 6) : pad(year, 4);
12232}
12233function formatDate(date) {
12234  var hours = date.getUTCHours(), minutes = date.getUTCMinutes(), seconds = date.getUTCSeconds(), milliseconds = date.getUTCMilliseconds();
12235  return isNaN(date) ? "Invalid Date" : formatYear(date.getUTCFullYear()) + "-" + pad(date.getUTCMonth() + 1, 2) + "-" + pad(date.getUTCDate(), 2) + (milliseconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "." + pad(milliseconds, 3) + "Z" : seconds ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + ":" + pad(seconds, 2) + "Z" : minutes || hours ? "T" + pad(hours, 2) + ":" + pad(minutes, 2) + "Z" : "");
12236}
12237function dsvFormat(delimiter) {
12238  var reFormat = new RegExp('["' + delimiter + "\n\r]"), DELIMITER = delimiter.charCodeAt(0);
12239  function parse(text2, f) {
12240    var convert, columns, rows = parseRows(text2, function(row, i) {
12241      if (convert) return convert(row, i - 1);
12242      columns = row, convert = f ? customConverter(row, f) : objectConverter(row);
12243    });
12244    rows.columns = columns || [];
12245    return rows;
12246  }
12247  function parseRows(text2, f) {
12248    var rows = [], N = text2.length, I = 0, n = 0, t, eof = N <= 0, eol = false;
12249    if (text2.charCodeAt(N - 1) === NEWLINE) --N;
12250    if (text2.charCodeAt(N - 1) === RETURN) --N;
12251    function token() {
12252      if (eof) return EOF;
12253      if (eol) return eol = false, EOL;
12254      var i, j = I, c;
12255      if (text2.charCodeAt(j) === QUOTE) {
12256        while (I++ < N && text2.charCodeAt(I) !== QUOTE || text2.charCodeAt(++I) === QUOTE) ;
12257        if ((i = I) >= N) eof = true;
12258        else if ((c = text2.charCodeAt(I++)) === NEWLINE) eol = true;
12259        else if (c === RETURN) {
12260          eol = true;
12261          if (text2.charCodeAt(I) === NEWLINE) ++I;
12262        }
12263        return text2.slice(j + 1, i - 1).replace(/""/g, '"');
12264      }
12265      while (I < N) {
12266        if ((c = text2.charCodeAt(i = I++)) === NEWLINE) eol = true;
12267        else if (c === RETURN) {
12268          eol = true;
12269          if (text2.charCodeAt(I) === NEWLINE) ++I;
12270        } else if (c !== DELIMITER) continue;
12271        return text2.slice(j, i);
12272      }
12273      return eof = true, text2.slice(j, N);
12274    }
12275    while ((t = token()) !== EOF) {
12276      var row = [];
12277      while (t !== EOL && t !== EOF) row.push(t), t = token();
12278      if (f && (row = f(row, n++)) == null) continue;
12279      rows.push(row);
12280    }
12281    return rows;
12282  }
12283  function preformatBody(rows, columns) {
12284    return rows.map(function(row) {
12285      return columns.map(function(column) {
12286        return formatValue(row[column]);
12287      }).join(delimiter);
12288    });
12289  }
12290  function format(rows, columns) {
12291    if (columns == null) columns = inferColumns(rows);
12292    return [columns.map(formatValue).join(delimiter)].concat(preformatBody(rows, columns)).join("\n");
12293  }
12294  function formatBody(rows, columns) {
12295    if (columns == null) columns = inferColumns(rows);
12296    return preformatBody(rows, columns).join("\n");
12297  }
12298  function formatRows(rows) {
12299    return rows.map(formatRow).join("\n");
12300  }
12301  function formatRow(row) {
12302    return row.map(formatValue).join(delimiter);
12303  }
12304  function formatValue(value) {
12305    return value == null ? "" : value instanceof Date ? formatDate(value) : reFormat.test(value += "") ? '"' + value.replace(/"/g, '""') + '"' : value;
12306  }
12307  return {
12308    parse,
12309    parseRows,
12310    format,
12311    formatBody,
12312    formatRows,
12313    formatRow,
12314    formatValue
12315  };
12316}
12317function get_max$1(data) {
12318  if (!data || !data.length) return [];
12319  let max = data[0].slice();
12320  for (let i = 0; i < data.length; i++) {
12321    for (let j = 0; j < data[i].length; j++) {
12322      if (`${max[j].value}`.length < `${data[i][j].value}`.length) {
12323        max[j] = data[i][j];
12324      }
12325    }
12326  }
12327  return max;
12328}
12329function sort_table_data$1(data, display_value, styling, sort_columns) {
12330  if (!sort_columns.length) return;
12331  if (!data || !data.length) return;
12332  const indices = sort_data$1(data, sort_columns);
12333  const new_data = indices.map((i) => data[i]);
12334  data.splice(0, data.length, ...new_data);
12335  if (display_value) {
12336    const new_display = indices.map((i) => display_value[i]);
12337    display_value.splice(0, display_value.length, ...new_display);
12338  }
12339  if (styling) {
12340    const new_styling = indices.map((i) => styling[i]);
12341    styling.splice(0, styling.length, ...new_styling);
12342  }
12343}
12344function filter_table_data$1(data, display_value, styling, filter_columns, original_data, original_display_value, original_styling) {
12345  const base_data = original_data ?? data;
12346  const base_display_value = original_display_value ?? display_value;
12347  const base_styling = original_styling ?? styling;
12348  if (!filter_columns.length) {
12349    data.splice(0, data.length, ...base_data.map((row) => [...row]));
12350    if (display_value && base_display_value) {
12351      display_value.splice(
12352        0,
12353        display_value.length,
12354        ...base_display_value.map((row) => [...row])
12355      );
12356    }
12357    if (styling && base_styling) {
12358      styling.splice(0, styling.length, ...base_styling.map((row) => [...row]));
12359    }
12360    return;
12361  }
12362  if (!data || !data.length) return;
12363  const indices = filter_data$1(base_data, filter_columns);
12364  const new_data = indices.map((i) => base_data[i]);
12365  data.splice(0, data.length, ...new_data);
12366  if (display_value && base_display_value) {
12367    const new_display = indices.map((i) => base_display_value[i]);
12368    display_value.splice(0, display_value.length, ...new_display);
12369  }
12370  if (styling && base_styling) {
12371    const new_styling = indices.map((i) => base_styling[i]);
12372    styling.splice(0, styling.length, ...new_styling);
12373  }
12374}
12375async function copy_table_data$1(data, selected_cells) {
12376  if (!data || !data.length) return;
12377  const cells_to_copy = selected_cells || data.flatMap((row, r) 
12377=> row.map((_, c) => [r, c]));
12378  const csv = cells_to_copy.reduce(
12379    (acc, [row, col]) => {
12380      acc[row] = acc[row] || {};
12381      const value = String(data[row][col].value);
12382      acc[row][col] = value.includes(",") || value.includes('"') || value.includes("\n") ? `"${value.replace(/"/g, '""')}"` : value;
12383      return acc;
12384    },
12385    {}
12386  );
12387  const rows = Object.keys(csv).sort((a, b) => +a - +b);
12388  if (!rows.length) return;
12389  const cols = Object.keys(csv[rows[0]]).sort((a, b) => +a - +b);
12390  const text2 = rows.map((r) => cols.map((c) => csv[r][c] || "").join(",")).join("\n");
12391  try {
12392    await navigator.clipboard.writeText(text2);
12393  } catch (err) {
12394    throw new Error("Failed to copy to clipboard: " + err.message);
12395  }
12396}
12397function guess_delimiter$1(text2, possibleDelimiters) {
12398  return possibleDelimiters.filter(weedOut);
12399  function weedOut(delimiter) {
12400    var cache = -1;
12401    return text2.split("\n").every(checkLength);
12402    function checkLength(line) {
12403      if (!line) return true;
12404      var length = line.split(delimiter).length;
12405      if (cache < 0) cache = length;
12406      return cache === length && length > 1;
12407    }
12408  }
12409}
12410function data_uri_to_blob$1(data_uri) {
12411  const byte_str = atob(data_uri.split(",")[1]);
12412  const mime_str = data_uri.split(",")[0].split(":")[1].split(";")[0];
12413  const ab = new ArrayBuffer(byte_str.length);
12414  const ia = new Uint8Array(ab);
12415  for (let i = 0; i < byte_str.length; i++) {
12416    ia[i] = byte_str.charCodeAt(i);
12417  }
12418  return new Blob([ab], { type: mime_str });
12419}
12420function handle_file_upload$1(data_uri, update_headers, update_values) {
12421  const blob = data_uri_to_blob$1(data_uri);
12422  const reader = new FileReader();
12423  reader.addEventListener("loadend", (e) => {
12424    var _a;
12425    if (!((_a = e == null ? void 0 : e.target) == null ? void 0 : _a.result) || typeof e.target.result !== "string") return;
12426    const [delimiter] = guess_delimiter$1(e.target.result, [",", "	"]);
12427    const [head, ...rest] = dsvFormat(delimiter).parseRows(e.target.result);
12428    update_headers(head);
12429    update_values(rest);
12430  });
12431  reader.readAsText(blob);
12432}
12433function is_cell_in_selection$1(coords, selected_cells) {
12434  const [row, col] = coords;
12435  return selected_cells.some(([r, c]) => r === row && c === col);
12436}
12437function is_cell_selected$1(cell, selected_cells) {
12438  const [row, col] = cell;
12439  if (!selected_cells.some(([r, c]) => r === row && c === col)) return "";
12440  const up = selected_cells.some(([r, c]) => r === row - 1 && c === col);
12441  const down = selected_cells.some(([r, c]) => r === row + 1 && c === col);
12442  const left = selected_cells.some(([r, c]) => r === row && c === col - 1);
12443  const right = selected_cells.some(([r, c]) => r === row && c === col + 1);
12444  return `cell-selected${up ? " no-top" : ""}${down ? " no-bottom" : ""}${left ? " no-left" : ""}${right ? " no-right" : ""}`;
12445}
12446function get_range_selection$1(start, end) {
12447  const [start_row, start_col] = start;
12448  const [end_row, end_col] = end;
12449  const min_row = Math.min(start_row, end_row);
12450  const max_row = Math.max(start_row, end_row);
12451  const min_col = Math.min(start_col, end_col);
12452  const max_col = Math.max(start_col, end_col);
12453  const cells = [];
12454  cells.push(start);
12455  for (let i = min_row; i <= max_row; i++) {
12456    for (let j = min_col; j <= max_col; j++) {
12457      if (i === start_row && j === start_col) continue;
12458      cells.push([i, j]);
12459    }
12460  }
12461  return cells;
12462}
12463function handle_selection$1(current, selected_cells, event) {
12464  if (event.shiftKey && selected_cells.length > 0) {
12465    return get_range_selection$1(
12466      selected_cells[selected_cells.length - 1],
12467      current
12468    );
12469  }
12470  if (event.metaKey || event.ctrlKey) {
12471    const is_cell_match = ([r, c]) => r === current[0] && c === current[1];
12472    const index = selected_cells.findIndex(is_cell_match);
12473    return index === -1 ? [...selected_cells, current] : selected_cells.filter((_, i) => i !== index);
12474  }
12475  return [current];
12476}
12477function handle_delete_key$1(data, selected_cells) {
12478  const new_data = data.map((row) => [...row]);
12479  selected_cells.forEach(([row, col]) => {
12480    if (new_data[row] && new_data[row][col]) {
12481      new_data[row][col] = { ...new_data[row][col], value: "" };
12482    }
12483  });
12484  return new_data;
12485}
12486function should_show_cell_menu$1(cell, selected_cells, editable) {
12487  const [row, col] = cell;
12488  return editable && selected_cells.length === 1 && selected_cells[0][0] === row && selected_cells[0][1] === col;
12489}
12490function get_next_cell_coordinates$1(current, data, shift_key) {
12491  var _a, _b, _c;
12492  const [row, col] = current;
12493  const direction = shift_key ? -1 : 1;
12494  if ((_a = data[row]) == null ? void 0 : _a[col + direction]) {
12495    return [row, col + direction];
12496  }
12497  const next_row = row + (direction > 0 ? 1 : 0);
12498  const prev_row = row + (direction < 0 ? -1 : 0);
12499  if (direction > 0 && ((_b = data[next_row]) == null ? void 0 : _b[0])) {
12500    return [next_row, 0];
12501  }
12502  if (direction < 0 && ((_c = data[prev_row]) == null ? void 0 : _c[data[0].length - 1])) {
12503    return [prev_row, data[0].length - 1];
12504  }
12505  return false;
12506}
12507function move_cursor$1(event, current_coords, data) {
12508  var _a;
12509  const key = event.key;
12510  const dir = {
12511    ArrowRight: [0, 1],
12512    ArrowLeft: [0, -1],
12513    ArrowDown: [1, 0],
12514    ArrowUp: [-1, 0]
12515  }[key];
12516  let i, j;
12517  if (event.metaKey || event.ctrlKey) {
12518    if (key === "ArrowRight") {
12519      i = current_coords[0];
12520      j = data[0].length - 1;
12521    } else if (key === "ArrowLeft") {
12522      i = current_coords[0];
12523      j = 0;
12524    } else if (key === "ArrowDown") {
12525      i = data.length - 1;
12526      j = current_coords[1];
12527    } else if (key === "ArrowUp") {
12528      i = 0;
12529      j = current_coords[1];
12530    } else {
12531      return false;
12532    }
12533  } else {
12534    i = current_coords[0] + dir[0];
12535    j = current_coords[1] + dir[1];
12536  }
12537  if (i < 0 && j <= 0) {
12538    return false;
12539  }
12540  const is_data = (_a = data[i]) == null ? void 0 : _a[j];
12541  if (is_data) {
12542    return [i, j];
12543  }
12544  return false;
12545}
12546function get_current_indices$1(id, data) {
12547  return data.reduce(
12548    (acc, arr, i) => {
12549      const j = arr.reduce(
12550        (_acc, _data, k) => id === _data.id ? k : _acc,
12551        -1
12552      );
12553      return j === -1 ? acc : [i, j];
12554    },
12555    [-1, -1]
12556  );
12557}
12558function handle_click_outside$1(event, parent) {
12559  const [trigger] = event.composedPath();
12560  return !parent.contains(trigger);
12561}
12562function calculate_selection_positions$1(selected, data, els, parent, table) {
12563  var _a, _b;
12564  const [row, col] = selected;
12565  if (!((_a = data[row]) == null ? void 0 : _a[col])) {
12566    return { col_pos: "0px", row_pos: void 0 };
12567  }
12568  const cell_id = data[row][col].id;
12569  const cell_el = (_b = els[cell_id]) == null ? void 0 : _b.cell;
12570  if (!cell_el) {
12571    return { col_pos: "0px", row_pos: void 0 };
12572  }
12573  const cell_rect = cell_el.getBoundingClientRect();
12574  const table_rect = table.getBoundingClientRect();
12575  const col_pos = `${cell_rect.left - table_rect.left + cell_rect.width / 2}px`;
12576  const row_pos = `${cell_rect.top - table_rect.top + cell_rect.height / 2}px`;
12577  return { col_pos, row_pos };
12578}
12579const DATAFRAME_KEY$1 = Symbol("dataframe");
12580function create_actions$1(state, context) {
12581  const update_state = (updater) => state.update((s) => ({ ...s, ...updater(s) }));
12582  const add_row = (data, make_id2, index) => {
12583    var _a;
12584    const new_row = ((_a = data[0]) == null ? void 0 : _a.length) ? Array(data[0].length).fill(null).map(() => ({ value: "", id: make_id2() })) : [{ value: "", id: make_id2() }];
12585    const new_data = [...data];
12586    index !== void 0 ? new_data.splice(index, 0, new_row) : new_data.push(new_row);
12587    return new_data;
12588  };
12589  const add_col = (data, headers, make_id2, index) => {
12590    const new_headers = [...headers, `Header ${headers.length + 1}`];
12591    const new_data = data.map((row) => [...row, { value: "", id: make_id2() }]);
12592    if (index !== void 0) {
12593      new_headers.splice(index, 0, new_headers.pop());
12594      new_data.forEach((row) => row.splice(index, 0, row.pop()));
12595    }
12596    return { data: new_data, headers: new_headers };
12597  };
12598  const update_array = (source, target) => {
12599    if (source && target) {
12600      target.splice(0, target.length, ...JSON.parse(JSON.stringify(source)));
12601    }
12602  };
12603  return {
12604    handle_search: (query) => update_state((s) => ({ current_search_query: query })),
12605    handle_sort: (col, direction) => update_state((s) => {
12606      const sort_cols = s.sort_state.sort_columns.filter(
12607        (c) => c.col !== col
12608      );
12609      if (!s.sort_state.sort_columns.some(
12610        (c) => c.col === col && c.direction === direction
12611      )) {
12612        sort_cols.push({ col, direction });
12613      }
12614      const initial_data = s.sort_state.initial_data || (context.data && sort_cols.length > 0 ? {
12615        data: JSON.parse(JSON.stringify(context.data)),
12616        display_value: context.display_value ? JSON.parse(JSON.stringify(context.display_value)) : null,
12617        styling: context.styling ? JSON.parse(JSON.stringify(context.styling)) : null
12618      } : null);
12619      return {
12620        sort_state: {
12621          ...s.sort_state,
12622          sort_columns: sort_cols.slice(-3),
12623          initial_data
12624        }
12625      };
12626    }),
12627    handle_filter: (col, datatype, filter, value) => update_state((s) => {
12628      const filter_cols = s.filter_state.filter_columns.some(
12629        (c) => c.col === col
12630      ) ? s.filter_state.filter_columns.filter((c) => c.col !== col) : [
12631        ...s.filter_state.filter_columns,
12632        { col, datatype, filter, value }
12633      ];
12634      const initial_data = s.filter_state.initial_data || (context.data && filter_cols.length > 0 ? {
12635        data: JSON.parse(JSON.stringify(context.data)),
12636        display_value: context.display_value ? JSON.parse(JSON.stringify(context.display_value)) : null,
12637        styling: context.styling ? JSON.parse(JSON.stringify(context.styling)) : null
12638      } : null);
12639      return {
12640        filter_state: {
12641          ...s.filter_state,
12642          filter_columns: filter_cols,
12643          initial_data
12644        }
12645      };
12646    }),
12647    get_sort_status: (name, headers) => {
12648      const s = get_store_value(state);
12649      const sort_item = s.sort_state.sort_columns.find(
12650        (item) => headers[item.col] === name
12651      );
12652      return sort_item ? sort_item.direction : "none";
12653    },
12654    sort_data: (data, display_value, styling) => {
12655      const {
12656        sort_state: { sort_columns }
12657      } = get_store_value(state);
12658      if (sort_columns.length)
12659        sort_table_data$1(data, display_value, styling, sort_columns);
12660    },
12661    update_row_order: (data) => update_state((s) => ({
12662      sort_state: {
12663        ...s.sort_state,
12664        row_order: s.sort_state.sort_columns.length && data[0] ? [...Array(data.length)].map((_, i) => i).sort((a, b) => {
12665          var _a, _b, _c, _d;
12666          for (const { col, direction } of s.sort_state.sort_columns) {
12667            const comp = (((_b = (_a = data[a]) == null ? void 0 : _a[col]) == null ? void 0 : _b.value) ?? "") < (((_d = (_c = data[b]) == null ? void 0 : _c[col]) == null ? void 0 : _d.value) ?? "") ? -1 : 1;
12668            return direction === "asc" ? comp : -comp;
12669          }
12670          return 0;
12671        }) : [...Array(data.length)].map((_, i) => i)
12672      }
12673    })),
12674    filter_data: (data) => {
12675      var _a;
12676      const query = (_a = get_store_value(state).current_search_query) == null ? void 0 : _a.toLowerCase();
12677      return query ? data.filter(
12678        (row) => row.some(
12679          (cell) => String(cell == null ? void 0 : cell.value).toLowerCase().includes(query)
12680        )
12681      ) : data;
12682    },
12683    add_row,
12684    add_col,
12685    add_row_at: (data, index, position, make_id2) => add_row(data, make_id2, position === "above" ? index : index + 1),
12686    add_col_at: (data, headers, index, position, make_id2) => add_col(data, headers, make_id2, position === "left" ? index : index + 1),
12687    delete_row: (data, index) => data.length > 1 ? data.filter((_, i) => i !== index) : data,
12688    delete_col: (data, headers, index) => headers.length > 1 ? {
12689      data: data.map((row) => row.filter((_, i) => i !== index)),
12690      headers: headers.filter((_, i) => i !== index)
12691    } : { data, headers },
12692    delete_row_at: (data, index) => data.length > 1 ? [...data.slice(0, index), ...data.slice(index + 1)] : data,
12693    delete_col_at: (data, headers, index) => headers.length > 1 ? {
12694      data: data.map((row) => [
12695        ...row.slice(0, index),
12696        ...row.slice(index + 1)
12697      ]),
12698      headers: [...headers.slice(0, index), ...headers.slice(index + 1)]
12699    } : { data, headers },
12700    trigger_change: async (data, headers, previous_data, previous_headers, value_is_output, dispatch2) => {
12701      const s = get_store_value(state);
12702      if (s.current_search_query) return;
12703      const current_headers = headers.map((h) => h.value);
12704      const current_data = data.map((row) => row.map((cell) => cell.value));
12705      if (!dequal$1(current_data, previous_data) || !dequal$1(current_headers, previous_headers)) {
12706        if (!dequal$1(current_headers, previous_headers)) {
12707          update_state((s2) => ({
12708            sort_state: { sort_columns: [], row_order: [], initial_data: null },
12709            filter_state: { filter_columns: [], initial_data: null }
12710          }));
12711        }
12712        dispatch2("change", {
12713          data: data.map((row) => row.map((cell) => cell.value)),
12714          headers: current_headers,
12715          metadata: null
12716        });
12717        const index = s.ui_state.selected;
12718        if (index) {
12719          dispatch2("edit", {
12720            index,
12721            value: data[index[0]][index[1]].value,
12722            previous_value: previous_data[index[0]][index[1]]
12723          });
12724        }
12725        if (!value_is_output) dispatch2("input");
12726      }
12727    },
12728    reset_sort_state: () => update_state((s) => {
12729      if (s.sort_state.initial_data && context.data) {
12730        const original = s.sort_state.initial_data;
12731        update_array(original.data, context.data);
12732        update_array(original.display_value, context.display_value);
12733        update_array(original.styling, context.styling);
12734      }
12735      return {
12736        sort_state: { sort_columns: [], row_order: [], initial_data: null }
12737      };
12738    }),
12739    reset_filter_state: () => update_state((s) => {
12740      if (s.filter_state.initial_data && context.data) {
12741        const original = s.filter_state.initial_data;
12742        update_array(original.data, context.data);
12743        update_array(original.display_value, context.display_value);
12744        update_array(original.styling, context.styling);
12745      }
12746      return {
12747        filter_state: { filter_columns: [], initial_data: null }
12748      };
12749    }),
12750    set_active_cell_menu: (menu) => update_state((s) => ({
12751      ui_state: { ...s.ui_state, active_cell_menu: menu }
12752    })),
12753    set_active_header_menu: (menu) => update_state((s) => ({
12754      ui_state: { ...s.ui_state, active_header_menu: menu }
12755    })),
12756    set_selected_cells: (cells) => update_state((s) => ({
12757      ui_state: { ...s.ui_state, selected_cells: cells }
12758    })),
12759    set_selected: (selected) => update_state((s) => ({ ui_state: { ...s.ui_state, selected } })),
12760    set_editing: (editing) => update_state((s) => ({ ui_state: { ...s.ui_state, editing } })),
12761    clear_ui_state: () => update_state((s) => ({
12762      ui_state: {
12763        active_cell_menu: null,
12764        active_header_menu: null,
12765        selected_cells: [],
12766        selected: false,
12767        editing: false,
12768        header_edit: false,
12769        selected_header: false,
12770        active_button: null,
12771        copy_flash: false
12772      }
12773    })),
12774    set_header_edit: (header_index) => update_state((s) => ({
12775      ui_state: {
12776        ...s.ui_state,
12777        selected_cells: [],
12778        selected_header: header_index,
12779        header_edit: header_index
12780      }
12781    })),
12782    set_selected_header: (header_index) => update_state((s) => ({
12783      ui_state: {
12784        ...s.ui_state,
12785        selected_header: header_index,
12786        selected: false,
12787        selected_cells: []
12788      }
12789    })),
12790    handle_header_click: (col, editable) => update_state((s) => ({
12791      ui_state: {
12792        ...s.ui_state,
12793        active_cell_menu: null,
12794        active_header_menu: null,
12795        selected: false,
12796        selected_cells: [],
12797        selected_header: col,
12798        header_edit: editable ? col : false
12799      }
12800    })),
12801    end_header_edit: (key) => {
12802      if (["Escape", "Enter", "Tab"].includes(key)) {
12803        update_state((s) => ({
12804          ui_state: { ...s.ui_state, selected: false, header_edit: false }
12805        }));
12806      }
12807    },
12808    get_selected_cells: () => get_store_value(state).ui_state.selected_cells,
12809    get_active_cell_menu: () => get_store_value(state).ui_state.active_cell_menu,
12810    get_active_button: () => get_store_value(state).ui_state.active_button,
12811    set_active_button: (button) => update_state((s) => ({
12812      ui_state: { ...s.ui_state, active_button: button }
12813    })),
12814    set_copy_flash: (value) => update_state((s) => ({ ui_state: { ...s.ui_state, copy_flash: value } })),
12815    handle_cell_click: (event, row, col) => {
12816      var _a;
12817      event.preventDefault();
12818      event.stopPropagation();
12819      const s = get_store_value(state);
12820      if (s.config.show_row_numbers && col === -1) return;
12821      let actual_row = row;
12822      if (s.current_search_query && context.data) {
12823        const filtered_indices = [];
12824        context.data.forEach((dataRow, idx) => {
12825          if (dataRow.some(
12826            (cell) => {
12827              var _a2;
12828              return String(cell == null ? void 0 : cell.value).toLowerCase().includes(((_a2 = s.current_search_query) == null ? void 0 : _a2.toLowerCase()) || "");
12829            }
12830          )) {
12831            filtered_indices.push(idx);
12832          }
12833        });
12834        actual_row = filtered_indices[row] ?? row;
12835      }
12836      const cells = handle_selection$1(
12837        [actual_row, col],
12838        s.ui_state.selected_cells,
12839        event
12840      );
12841      update_state((s2) => ({
12842        ui_state: {
12843          ...s2.ui_state,
12844          active_cell_menu: null,
12845          active_header_menu: null,
12846          selected_header: false,
12847          header_edit: false,
12848          selected_cells: cells,
12849          selected: cells[0]
12850        }
12851      }));
12852      if (s.config.editable && cells.length === 1) {
12853        update_state((s2) => ({
12854          ui_state: { ...s2.ui_state, editing: [actual_row, col] }
12855        }));
12856        tick().then(
12857          () => {
12858            var _a2, _b;
12859            return (_b = (_a2 = context.els[context.data[actual_row][col].id]) == null ? void 0 : _a2.input) == null ? void 0 : _b.focus();
12860          }
12861        );
12862      } else {
12863        tick().then(() => {
12864          if (context.parent_element) {
12865            context.parent_element.focus();
12866          }
12867        });
12868      }
12869      (_a = context.dispatch) == null ? void 0 : _a.call(context, "select", {
12870        index: [actual_row, col],
12871        col_value: context.get_column(col),
12872        row_value: context.get_row(actual_row),
12873        value: context.get_data_at(actual_row, col)
12874      });
12875    },
12876    toggle_cell_menu: (event, row, col) => {
12877      event.stopPropagation();
12878      const current_menu = get_store_value(state).ui_state.active_cell_menu;
12879      if ((current_menu == null ? void 0 : current_menu.row) === row && current_menu.col === col) {
12880        update_state((s) => ({
12881          ui_state: { ...s.ui_state, active_cell_menu: null }
12882        }));
12883      } else {
12884        const cell = event.target.closest("td");
12885        if (cell) {
12886          const rect = cell.getBoundingClientRect();
12887          update_state((s) => ({
12888            ui_state: {
12889              ...s.ui_state,
12890              active_cell_menu: { row, col, x: rect.right, y: rect.bottom }
12891            }
12892          }));
12893        }
12894      }
12895    },
12896    toggle_cell_button: (row, col) => {
12897      const current_button = get_store_value(state).ui_state.active_button;
12898      const new_button = (current_button == null ? void 0 : current_button.type) === "cell" && current_button.row === row && current_button.col === col ? null : { type: "cell", row, col };
12899      update_state((s) => ({
12900        ui_state: { ...s.ui_state, active_button: new_button }
12901      }));
12902    },
12903    handle_select_column: (col) => {
12904      if (!context.data) return;
12905      const cells = context.data.map((_, row) => [row, col]);
12906      update_state((s) => ({
12907        ui_state: {
12908          ...s.ui_state,
12909          selected_cells: cells,
12910          selected: cells[0],
12911          editing: false
12912        }
12913      }));
12914      setTimeout(() => {
12915        var _a;
12916        return (_a = context.parent_element) == null ? void 0 : _a.focus();
12917      }, 0);
12918    },
12919    handle_select_row: (row) => {
12920      if (!context.data || !context.data[0]) return;
12921      const cells = context.data[0].map(
12922        (_, col) => [row, col]
12923      );
12924      update_state((s) => ({
12925        ui_state: {
12926          ...s.ui_state,
12927          selected_cells: cells,
12928          selected: cells[0],
12929          editing: false
12930        }
12931      }));
12932      setTimeout(() => {
12933        var _a;
12934        return (_a = context.parent_element) == null ? void 0 : _a.focus();
12935      }, 0);
12936    },
12937    get_next_cell_coordinates: get_next_cell_coordinates$1,
12938    get_range_selection: get_range_selection$1,
12939    move_cursor: move_cursor$1
12940  };
12941}
12942function create_dataframe_context$1(config) {
12943  const state = writable({
12944    config,
12945    current_search_query: null,
12946    sort_state: { sort_columns: [], row_order: [], initial_data: null },
12947    filter_state: { filter_columns: [], initial_data: null },
12948    ui_state: {
12949      active_cell_menu: null,
12950      active_header_menu: null,
12951      selected_cells: [],
12952      selected: false,
12953      editing: false,
12954      header_edit: false,
12955      selected_header: false,
12956      active_button: null,
12957      copy_flash: false
12958    }
12959  });
12960  const context = { state, actions: null };
12961  context.actions = create_actions$1(state, context);
12962  const instance_id = Symbol(
12963    `dataframe_${Math.random().toString(36).substring(2)}`
12964  );
12965  setContext(instance_id, context);
12966  setContext(DATAFRAME_KEY$1, { instance_id, context });
12967  return context;
12968}
12969var has = Object.prototype.hasOwnProperty;
12970function dequal(foo, bar) {
12971  var ctor, len;
12972  if (foo === bar) return true;
12973  if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
12974    if (ctor === Date) return foo.getTime() === bar.getTime();
12975    if (ctor === RegExp) return foo.toString() === bar.toString();
12976    if (ctor === Array) {
12977      if ((len = foo.length) === bar.length) {
12978        while (len-- && dequal(foo[len], bar[len])) ;
12979      }
12980      return len === -1;
12981    }
12982    if (!ctor || typeof foo === "object") {
12983      len = 0;
12984      for (ctor in foo) {
12985        if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
12986        if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
12987      }
12988      return Object.keys(bar).length === len;
12989    }
12990  }
12991  return foo !== foo && bar !== bar;
12992}
12993new Intl.Collator(0, { numeric: 1 }).compare;
12994async function prepare_files(files, is_stream) {
12995  return files.map(
12996    (f) => new FileData({
12997      path: f.name,
12998      orig_name: f.name,
12999      blob: f,
13000      size: f.size,
13001      mime_type: f.type,
13002      is_stream
13003    })
13004  );
13005}
13006class FileData {
13007  constructor({
13008    path,
13009    url,
13010    orig_name,
13011    size,
13012    blob,
13013    is_stream,
13014    mime_type,
13015    alt_text,
13016    b64
13017  }) {
13018    this.meta = { _type: "gradio.FileData" };
13019    this.path = path;
13020    this.url = url;
13021    this.orig_name = orig_name;
13022    this.size = size;
13023    this.blob = url ? void 0 : blob;
13024    this.is_stream = is_stream;
13025    this.mime_type = mime_type;
13026    this.alt_text = alt_text;
13027    this.b64 = b64;
13028  }
13029}
13030typeof process !== "undefined" && process.versions && process.versions.node;
13031class TextLineStream extends TransformStream {
13032  /** Constructs a new instance. */
13033  constructor(options = { allowCR: false }) {
13034    super({
13035      transform: (chars, controller) => {
13036        chars = __privateGet(this, _currentLine) + chars;
13037        while (true) {
13038          const lfIndex = chars.indexOf("\n");
13039          const crIndex = options.allowCR ? chars.indexOf("\r") : -1;
13040          if (crIndex !== -1 && crIndex !== chars.length - 1 && (lfIndex === -1 || lfIndex - 1 > crIndex)) {
13041            controller.enqueue(chars.slice(0, crIndex));
13042            chars = chars.slice(crIndex + 1);
13043            continue;
13044          }
13045          if (lfIndex === -1)
13046            break;
13047          const endIndex = chars[lfIndex - 1] === "\r" ? lfIndex - 1 : lfIndex;
13048          controller.enqueue(chars.slice(0, endIndex));
13049          chars = chars.slice(lfIndex + 1);
13050        }
13051        __privateSet(this, _currentLine, chars);
13052      },
13053      flush: (controller) => {
13054        if (__privateGet(this, _currentLine) === "")
13055          return;
13056        const currentLine = options.allowCR && __privateGet(this, _currentLine).endsWith("\r") ? __privateGet(this, _currentLine).slice(0, -1) : __privateGet(this, _currentLine);
13057        controller.enqueue(currentLine);
13058      }
13059    });
13060    __privateAdd(this, _currentLine, "");
13061  }
13062}
13063_currentLine = new WeakMap();
13064function create_if_block$h(ctx) {
13065  let div1;
13066  let span0;
13067  let div0;
13068  let progress_1;
13069  let t0_value = getProgress(
13070    /*file_to_display*/
13071    ctx[2]
13072  ) + "";
13073  let t0;
13074  let progress_1_value_value;
13075  let t1;
13076  let span1;
13077  let t2_value = (
13078    /*file_to_display*/
13079    ctx[2].orig_name + ""
13080  );
13081  let t2;
13082  return {
13083    c() {
13084      div1 = element("div");
13085      span0 = element("span");
13086      div0 = element("div");
13087      progress_1 = element("progress");
13088      t0 = text(t0_value);
13089      t1 = space();
13090      span1 = element("span");
13091      t2 = text(t2_value);
13092      set_style(progress_1, "visibility", "hidden");
13093      set_style(progress_1, "height", "0");
13094      set_style(progress_1, "width", "0");
13095      progress_1.value = progress_1_value_value = getProgress(
13096        /*file_to_display*/
13097        ctx[2]
13098      );
13099      attr(progress_1, "max", "100");
13100      attr(progress_1, "class", "svelte-cr2edf");
13101      attr(div0, "class", "progress-bar svelte-cr2edf");
13102      attr(span1, "class", "file-name svelte-cr2edf");
13103      attr(div1, "class", "file svelte-cr2edf");
13104    },
13105    m(target, anchor) {
13106      insert(target, div1, anchor);
13107      append(div1, span0);
13108      append(span0, div0);
13109      append(div0, progress_1);
13110      append(progress_1, t0);
13111      append(div1, t1);
13112      append(div1, span1);
13113      append(span1, t2);
13114    },
13115    p(ctx2, dirty) {
13116      if (dirty & /*file_to_display*/
13117      4 && t0_value !== (t0_value = getProgress(
13118        /*file_to_display*/
13119        ctx2[2]
13120      ) + "")) set_data(t0, t0_value);
13121      if (dirty & /*file_to_display*/
13122      4 && progress_1_value_value !== (progress_1_value_value = getProgress(
13123        /*file_to_display*/
13124        ctx2[2]
13125      ))) {
13126        progress_1.value = progress_1_value_value;
13127      }
13128      if (dirty & /*file_to_display*/
13129      4 && t2_value !== (t2_value = /*file_to_display*/
13130      ctx2[2].orig_name + "")) set_data(t2, t2_value);
13131    },
13132    d(detaching) {
13133      if (detaching) {
13134        detach(div1);
13135      }
13136    }
13137  };
13138}
13139function create_fragment$u(ctx) {
13140  let div;
13141  let span;
13142  let t0;
13143  let t1_value = (
13144    /*files_with_progress*/
13145    ctx[0].length + ""
13146  );
13147  let t1;
13148  let t2;
13149  let t3_value = (
13150    /*files_with_progress*/
13151    ctx[0].length > 1 ? "files" : "file"
13152  );
13153  let t3;
13154  let t4;
13155  let t5;
13156  let if_block = (
13157    /*file_to_display*/
13158    ctx[2] && create_if_block$h(ctx)
13159  );
13160  return {
13161    c() {
13162      div = element("div");
13163      span = element("span");
13164      t0 = text("Uploading ");
13165      t1 = text(t1_value);
13166      t2 = space();
13167      t3 = text(t3_value);
13168      t4 = text("...");
13169      t5 = space();
13170      if (if_block) if_block.c();
13171      attr(span, "class", "uploading svelte-cr2edf");
13172      attr(div, "class", "wrap svelte-cr2edf");
13173      toggle_class(
13174        div,
13175        "progress",
13176        /*progress*/
13177        ctx[1]
13178      );
13179    },
13180    m(target, anchor) {
13181      insert(target, div, anchor);
13182      append(div, span);
13183      append(span, t0);
13184      append(span, t1);
13185      append(span, t2);
13186      append(span, t3);
13187      append(span, t4);
13188      append(div, t5);
13189      if (if_block) if_block.m(div, null);
13190    },
13191    p(ctx2, [dirty]) {
13192      if (dirty & /*files_with_progress*/
13193      1 && t1_value !== (t1_value = /*files_with_progress*/
13194      ctx2[0].length + "")) set_data(t1, t1_value);
13195      if (dirty & /*files_with_progress*/
13196      1 && t3_value !== (t3_value = /*files_with_progress*/
13197      ctx2[0].length > 1 ? "files" : "file")) set_data(t3, t3_value);
13198      if (
13199        /*file_to_display*/
13200        ctx2[2]
13201      ) {
13202        if (if_block) {
13203          if_block.p(ctx2, dirty);
13204        } else {
13205          if_block = create_if_block$h(ctx2);
13206          if_block.c();
13207          if_block.m(div, null);
13208        }
13209      } else if (if_block) {
13210        if_block.d(1);
13211        if_block = null;
13212      }
13213      if (dirty & /*progress*/
13214      2) {
13215        toggle_class(
13216          div,
13217          "progress",
13218          /*progress*/
13219          ctx2[1]
13220        );
13221      }
13222    },
13223    i: noop,
13224    o: noop,
13225    d(detaching) {
13226      if (detaching) {
13227        detach(div);
13228      }
13229      if (if_block) if_block.d();
13230    }
13231  };
13232}
13233function getProgress(file) {
13234  return file.progress * 100 / (file.size || 0) || 0;
13235}
13236function calculateTotalProgress(files2) {
13237  let totalProgress = 0;
13238  files2.forEach((file) => {
13239    totalProgress += getProgress(file);
13240  });
13241  document.documentElement.style.setProperty("--upload-progress-width", (totalProgress / files2.length).toFixed(2) + "%");
13242  return totalProgress / files2.length;
13243}
13244function instance$t($$self, $$props, $$invalidate) {
13245  let { upload_id } = $$props;
13246  let { root } = $$props;
13247  let { files } = $$props;
13248  let { stream_handler } = $$props;
13249  let stream;
13250  let progress = false;
13251  let current_file_upload;
13252  let file_to_display;
13253  let files_with_progress = files.map((file) => {
13254    return { ...file, progress: 0 };
13255  });
13256  const dispatch2 = createEventDispatcher();
13257  function handleProgress(filename, chunk_size) {
13258    $$invalidate(0, files_with_progress = files_with_progress.map((file) => {
13259      if (file.orig_name === filename) {
13260        file.progress += chunk_size;
13261      }
13262      return file;
13263    }));
13264  }
13265  onMount(async () => {
13266    stream = await stream_handler(new URL(`${root}/gradio_api/upload_progress?upload_id=${upload_id}`));
13267    if (stream == null) {
13268      throw new Error("Event source is not defined");
13269    }
13270    stream.onmessage = async function(event) {
13271      const _data = JSON.parse(event.data);
13272      if (!progress) $$invalidate(1, progress = true);
13273      if (_data.msg === "done") {
13274        stream == null ? void 0 : stream.close();
13275        dispatch2("done");
13276      } else {
13277        $$invalidate(7, current_file_upload = _data);
13278        handleProgress(_data.orig_name, _data.chunk_size);
13279      }
13280    };
13281  });
13282  onDestroy(() => {
13283    if (stream != null || stream != void 0) stream.close();
13284  });
13285  $$self.$$set = ($$props2) => {
13286    if ("upload_id" in $$props2) $$invalidate(3, upload_id = $$props2.upload_id);
13287    if ("root" in $$props2) $$invalidate(4, root = $$props2.root);
13288    if ("files" in $$props2) $$invalidate(5, files = $$props2.files);
13289    if ("stream_handler" in $$props2) $$invalidate(6, stream_handler = $$props2.stream_handler);
13290  };
13291  $$self.$$.update = () => {
13292    if ($$self.$$.dirty & /*files_with_progress*/
13293    1) {
13294      calculateTotalProgress(files_with_progress);
13295    }
13296    if ($$self.$$.dirty & /*current_file_upload, files_with_progress*/
13297    129) {
13298      $$invalidate(2, file_to_display = current_file_upload || files_with_progress[0]);
13299    }
13300  };
13301  return [
13302    files_with_progress,
13303    progress,
13304    file_to_display,
13305    upload_id,
13306    root,
13307    files,
13308    stream_handler,
13309    current_file_upload
13310  ];
13311}
13312class UploadProgress extends SvelteComponent {
13313  constructor(options) {
13314    super();
13315    init(this, options, instance$t, create_fragment$u, safe_not_equal, {
13316      upload_id: 3,
13317      root: 4,
13318      files: 5,
13319      stream_handler: 6
13320    });
13321  }
13322}
13323function create_drag() {
13324  let hidden_input;
13325  let _options;
13326  return {
13327    drag(node, options = {}) {
13328      _options = options;
13329      function setup_hidden_input() {
13330        hidden_input = document.createElement("input");
13331        hidden_input.type = "file";
13332        hidden_input.style.display = "none";
13333        hidden_input.setAttribute("aria-label", "File upload");
13334        hidden_input.setAttribute("data-testid", "file-upload");
13335        const accept_options = Array.isArray(_options.accepted_types) ? _options.accepted_types.join(",") : _options.accepted_types || void 0;
13336        if (accept_options) {
13337          hidden_input.accept = accept_options;
13338        }
13339        hidden_input.multiple = _options.mode === "multiple" || false;
13340        if (_options.mode === "directory") {
13341          hidden_input.webkitdirectory = true;
13342          hidden_input.setAttribute("directory", "");
13343          hidden_input.setAttribute("mozdirectory", "");
13344        }
13345        node.appendChild(hidden_input);
13346      }
13347      setup_hidden_input();
13348      function handle_drag(e) {
13349        e.preventDefault();
13350        e.stopPropagation();
13351      }
13352      function handle_drag_enter(e) {
13353        var _a;
13354        e.preventDefault();
13355        e.stopPropagation();
13356        (_a = _options.on_drag_change) == null ? void 0 : _a.call(_options, true);
13357      }
13358      function handle_drag_leave(e) {
13359        var _a;
13360        e.preventDefault();
13361        e.stopPropagation();
13362        (_a = _options.on_drag_change) == null ? void 0 : _a.call(_options, false);
13363      }
13364      function handle_drop(e) {
13365        var _a, _b, _c;
13366        e.preventDefault();
13367        e.stopPropagation();
13368        (_a = _options.on_drag_change) == null ? void 0 : _a.call(_options, false);
13369        if (!((_b = e.dataTransfer) == null ? void 0 : _b.files)) return;
13370        const files = Array.from(e.dataTransfer.files);
13371        if (files.length > 0) {
13372          (_c = _options.on_files) == null ? void 0 : _c.call(_options, files);
13373        }
13374      }
13375      function handle_click() {
13376        if (!_options.disable_click) {
13377          hidden_input.value = "";
13378          hidden_input.click();
13379        }
13380      }
13381      function handle_file_input_change() {
13382        var _a;
13383        if (hidden_input.files) {
13384          const files = Array.from(hidden_input.files);
13385          if (files.length > 0) {
13386            (_a = _options.on_files) == null ? void 0 : _a.call(_options, files);
13387          }
13388        }
13389      }
13390      node.addEventListener("drag", handle_drag);
13391      node.addEventListener("dragstart", handle_drag);
13392      node.addEventListener("dragend", handle_drag);
13393      node.addEventListener("dragover", handle_drag);
13394      node.addEventListener("dragenter", handle_drag_enter);
13395      node.addEventListener("dragleave", handle_drag_leave);
13396      node.addEventListener("drop", handle_drop);
13397      node.addEventListener("click", handle_click);
13398      hidden_input.addEventListener("change", handle_file_input_change);
13399      return {
13400        update(new_options) {
13401          _options = new_options;
13402          hidden_input.remove();
13403          setup_hidden_input();
13404          hidden_input.addEventListener("change", handle_file_input_change);
13405        },
13406        destroy() {
13407          node.removeEventListener("drag", handle_drag);
13408          node.removeEventListener("dragstart", handle_drag);
13409          node.removeEventListener("dragend", handle_drag);
13410          node.removeEventListener("dragover", handle_drag);
13411          node.removeEventListener("dragenter", handle_drag_enter);
13412          node.removeEventListener("dragleave", handle_drag_leave);
13413          node.removeEventListener("drop", handle_drop);
13414          node.removeEventListener("click", handle_click);
13415          hidden_input.removeEventListener("change", handle_file_input_change);
13416          hidden_input.remove();
13417        }
13418      };
13419    },
13420    open_file_upload() {
13421      if (hidden_input) {
13422        hidden_input.value = "";
13423        hidden_input.click();
13424      }
13425    }
13426  };
13427}
13428function create_else_block$7(ctx) {
13429  let button;
13430  let button_tabindex_value;
13431  let button_aria_label_value;
13432  let drag_action;
13433  let current;
13434  let mounted;
13435  let dispose;
13436  const default_slot_template = (
13437    /*#slots*/
13438    ctx[30].default
13439  );
13440  const default_slot = create_slot(
13441    default_slot_template,
13442    ctx,
13443    /*$$scope*/
13444    ctx[29],
13445    null
13446  );
13447  return {
13448    c() {
13449      button = element("button");
13450      if (default_slot) default_slot.c();
13451      attr(button, "tabindex", button_tabindex_value = /*hidden*/
13452      ctx[9] ? -1 : 0);
13453      attr(button, "aria-label", button_aria_label_value = /*aria_label*/
13454      ctx[14] || "Click to upload or drop files");
13455      attr(button, "aria-dropeffect", "copy");
13456      attr(button, "class", "svelte-1o7nwih");
13457      toggle_class(
13458        button,
13459        "hidden",
13460        /*hidden*/
13461        ctx[9]
13462      );
13463      toggle_class(
13464        button,
13465        "center",
13466        /*center*/
13467        ctx[4]
13468      );
13469      toggle_class(
13470        button,
13471        "boundedheight",
13472        /*boundedheight*/
13473        ctx[3]
13474      );
13475      toggle_class(
13476        button,
13477        "flex",
13478        /*flex*/
13479        ctx[5]
13480      );
13481      toggle_class(
13482        button,
13483        "disable_click",
13484        /*disable_click*/
13485        ctx[7]
13486      );
13487      toggle_class(
13488        button,
13489        "icon-mode",
13490        /*icon_upload*/
13491        ctx[12]
13492      );
13493      set_style(
13494        button,
13495        "height",
13496        /*icon_upload*/
13497        ctx[12] ? "" : (
13498          /*height*/
13499          ctx[13] ? typeof /*height*/
13500          ctx[13] === "number" ? (
13501            /*height*/
13502            ctx[13] + "px"
13503          ) : (
13504            /*height*/
13505            ctx[13]
13506          ) : "100%"
13507        )
13508      );
13509    },
13510    m(target, anchor) {
13511      insert(target, button, anchor);
13512      if (default_slot) {
13513        default_slot.m(button, null);
13514      }
13515      current = true;
13516      if (!mounted) {
13517        dispose = action_destroyer(drag_action = /*drag*/
13518        ctx[18].call(null, button, {
13519          on_drag_change: drag_function,
13520          on_files: (
13521            /*drag_function_1*/
13522            ctx[31]
13523          ),
13524          accepted_types: (
13525            /*accept_file_types*/
13526            ctx[17]
13527          ),
13528          mode: (
13529            /*file_count*/
13530            ctx[6]
13531          ),
13532          disable_click: (
13533            /*disable_click*/
13534            ctx[7]
13535          )
13536        }));
13537        mounted = true;
13538      }
13539    },
13540    p(ctx2, dirty) {
13541      if (default_slot) {
13542        if (default_slot.p && (!current || dirty[0] & /*$$scope*/
13543        536870912)) {
13544          update_slot_base(
13545            default_slot,
13546            default_slot_template,
13547            ctx2,
13548            /*$$scope*/
13549            ctx2[29],
13550            !current ? get_all_dirty_from_scope(
13551              /*$$scope*/
13552              ctx2[29]
13553            ) : get_slot_changes(
13554              default_slot_template,
13555              /*$$scope*/
13556              ctx2[29],
13557              dirty,
13558              null
13559            ),
13560            null
13561          );
13562        }
13563      }
13564      if (!current || dirty[0] & /*hidden*/
13565      512 && button_tabindex_value !== (button_tabindex_value = /*hidden*/
13566      ctx2[9] ? -1 : 0)) {
13567        attr(button, "tabindex", button_tabindex_value);
13568      }
13569      if (!current || dirty[0] & /*aria_label*/
13570      16384 && button_aria_label_value !== (button_aria_label_value = /*aria_label*/
13571      ctx2[14] || "Click to upload or drop files")) {
13572        attr(button, "aria-label", button_aria_label_value);
13573      }
13574      if (drag_action && is_function(drag_action.update) && dirty[0] & /*accept_file_types, file_count, disable_click*/
13575      131264) drag_action.update.call(null, {
13576        on_drag_change: drag_function,
13577        on_files: (
13578          /*drag_function_1*/
13579          ctx2[31]
13580        ),
13581        accepted_types: (
13582          /*accept_file_types*/
13583          ctx2[17]
13584        ),
13585        mode: (
13586          /*file_count*/
13587          ctx2[6]
13588        ),
13589        disable_click: (
13590          /*disable_click*/
13591          ctx2[7]
13592        )
13593      });
13594      if (!current || dirty[0] & /*hidden*/
13595      512) {
13596        toggle_class(
13597          button,
13598          "hidden",
13599          /*hidden*/
13600          ctx2[9]
13601        );
13602      }
13603      if (!current || dirty[0] & /*center*/
13604      16) {
13605        toggle_class(
13606          button,
13607          "center",
13608          /*center*/
13609          ctx2[4]
13610        );
13611      }
13612      if (!current || dirty[0] & /*boundedheight*/
13613      8) {
13614        toggle_class(
13615          button,
13616          "boundedheight",
13617          /*boundedheight*/
13618          ctx2[3]
13619        );
13620      }
13621      if (!current || dirty[0] & /*flex*/
13622      32) {
13623        toggle_class(
13624          button,
13625          "flex",
13626          /*flex*/
13627          ctx2[5]
13628        );
13629      }
13630      if (!current || dirty[0] & /*disable_click*/
13631      128) {
13632        toggle_class(
13633          button,
13634          "disable_click",
13635          /*disable_click*/
13636          ctx2[7]
13637        );
13638      }
13639      if (!current || dirty[0] & /*icon_upload*/
13640      4096) {
13641        toggle_class(
13642          button,
13643          "icon-mode",
13644          /*icon_upload*/
13645          ctx2[12]
13646        );
13647      }
13648      if (dirty[0] & /*icon_upload, height*/
13649      12288) {
13650        set_style(
13651          button,
13652          "height",
13653          /*icon_upload*/
13654          ctx2[12] ? "" : (
13655            /*height*/
13656            ctx2[13] ? typeof /*height*/
13657            ctx2[13] === "number" ? (
13658              /*height*/
13659              ctx2[13] + "px"
13660            ) : (
13661              /*height*/
13662              ctx2[13]
13663            ) : "100%"
13664          )
13665        );
13666      }
13667    },
13668    i(local) {
13669      if (current) return;
13670      transition_in(default_slot, local);
13671      current = true;
13672    },
13673    o(local) {
13674      transition_out(default_slot, local);
13675      current = false;
13676    },
13677    d(detaching) {
13678      if (detaching) {
13679        detach(button);
13680      }
13681      if (default_slot) default_slot.d(detaching);
13682      mounted = false;
13683      dispose();
13684    }
13685  };
13686}
13687function create_if_block_1$c(ctx) {
13688  let if_block_anchor;
13689  let current;
13690  let if_block = !/*hidden*/
13691  ctx[9] && create_if_block_2$b(ctx);
13692  return {
13693    c() {
13694      if (if_block) if_block.c();
13695      if_block_anchor = empty();
13696    },
13697    m(target, anchor) {
13698      if (if_block) if_block.m(target, anchor);
13699      insert(target, if_block_anchor, anchor);
13700      current = true;
13701    },
13702    p(ctx2, dirty) {
13703      if (!/*hidden*/
13704      ctx2[9]) {
13705        if (if_block) {
13706          if_block.p(ctx2, dirty);
13707          if (dirty[0] & /*hidden*/
13708          512) {
13709            transition_in(if_block, 1);
13710          }
13711        } else {
13712          if_block = create_if_block_2$b(ctx2);
13713          if_block.c();
13714          transition_in(if_block, 1);
13715          if_block.m(if_block_anchor.parentNode, if_block_anchor);
13716        }
13717      } else if (if_block) {
13718        group_outros();
13719        transition_out(if_block, 1, 1, () => {
13720          if_block = null;
13721        });
13722        check_outros();
13723      }
13724    },
13725    i(local) {
13726      if (current) return;
13727      transition_in(if_block);
13728      current = true;
13729    },
13730    o(local) {
13731      transition_out(if_block);
13732      current = false;
13733    },
13734    d(detaching) {
13735      if (detaching) {
13736        detach(if_block_anchor);
13737      }
13738      if (if_block) if_block.d(detaching);
13739    }
13740  };
13741}
13742function create_if_block$g(ctx) {
13743  let button;
13744  let button_tabindex_value;
13745  let button_aria_label_value;
13746  let current;
13747  let mounted;
13748  let dispose;
13749  const default_slot_template = (
13750    /*#slots*/
13751    ctx[30].default
13752  );
13753  const default_slot = create_slot(
13754    default_slot_template,
13755    ctx,
13756    /*$$scope*/
13757    ctx[29],
13758    null
13759  );
13760  return {
13761    c() {
13762      button = element("button");
13763      if (default_slot) default_slot.c();
13764      attr(button, "tabindex", button_tabindex_value = /*hidden*/
13765      ctx[9] ? -1 : 0);
13766      attr(button, "aria-label", button_aria_label_value = /*aria_label*/
13767      ctx[14] || "Paste from clipboard");
13768      attr(button, "class", "svelte-1o7nwih");
13769      toggle_class(
13770        button,
13771        "hidden",
13772        /*hidden*/
13773        ctx[9]
13774      );
13775      toggle_class(
13776        button,
13777        "center",
13778        /*center*/
13779        ctx[4]
13780      );
13781      toggle_class(
13782        button,
13783        "boundedheight",
13784        /*boundedheight*/
13785        ctx[3]
13786      );
13787      toggle_class(
13788        button,
13789        "flex",
13790        /*flex*/
13791        ctx[5]
13792      );
13793      toggle_class(
13794        button,
13795        "icon-mode",
13796        /*icon_upload*/
13797        ctx[12]
13798      );
13799      set_style(
13800        button,
13801        "height",
13802        /*icon_upload*/
13803        ctx[12] ? "" : (
13804          /*height*/
13805          ctx[13] ? typeof /*height*/
13806          ctx[13] === "number" ? (
13807            /*height*/
13808            ctx[13] + "px"
13809          ) : (
13810            /*height*/
13811            ctx[13]
13812          ) : "100%"
13813        )
13814      );
13815    },
13816    m(target, anchor) {
13817      insert(target, button, anchor);
13818      if (default_slot) {
13819        default_slot.m(button, null);
13820      }
13821      current = true;
13822      if (!mounted) {
13823        dispose = listen(
13824          button,
13825          "click",
13826          /*paste_clipboard*/
13827          ctx[15]
13828        );
13829        mounted = true;
13830      }
13831    },
13832    p(ctx2, dirty) {
13833      if (default_slot) {
13834        if (default_slot.p && (!current || dirty[0] & /*$$scope*/
13835        536870912)) {
13836          update_slot_base(
13837            default_slot,
13838            default_slot_template,
13839            ctx2,
13840            /*$$scope*/
13841            ctx2[29],
13842            !current ? get_all_dirty_from_scope(
13843              /*$$scope*/
13844              ctx2[29]
13845            ) : get_slot_changes(
13846              default_slot_template,
13847              /*$$scope*/
13848              ctx2[29],
13849              dirty,
13850              null
13851            ),
13852            null
13853          );
13854        }
13855      }
13856      if (!current || dirty[0] & /*hidden*/
13857      512 && button_tabindex_value !== (button_tabindex_value = /*hidden*/
13858      ctx2[9] ? -1 : 0)) {
13859        attr(button, "tabindex", button_tabindex_value);
13860      }
13861      if (!current || dirty[0] & /*aria_label*/
13862      16384 && button_aria_label_value !== (button_aria_label_value = /*aria_label*/
13863      ctx2[14] || "Paste from clipboard")) {
13864        attr(button, "aria-label", button_aria_label_value);
13865      }
13866      if (!current || dirty[0] & /*hidden*/
13867      512) {
13868        toggle_class(
13869          button,
13870          "hidden",
13871          /*hidden*/
13872          ctx2[9]
13873        );
13874      }
13875      if (!current || dirty[0] & /*center*/
13876      16) {
13877        toggle_class(
13878          button,
13879          "center",
13880          /*center*/
13881          ctx2[4]
13882        );
13883      }
13884      if (!current || dirty[0] & /*boundedheight*/
13885      8) {
13886        toggle_class(
13887          button,
13888          "boundedheight",
13889          /*boundedheight*/
13890          ctx2[3]
13891        );
13892      }
13893      if (!current || dirty[0] & /*flex*/
13894      32) {
13895        toggle_class(
13896          button,
13897          "flex",
13898          /*flex*/
13899          ctx2[5]
13900        );
13901      }
13902      if (!current || dirty[0] & /*icon_upload*/
13903      4096) {
13904        toggle_class(
13905          button,
13906          "icon-mode",
13907          /*icon_upload*/
13908          ctx2[12]
13909        );
13910      }
13911      if (dirty[0] & /*icon_upload, height*/
13912      12288) {
13913        set_style(
13914          button,
13915          "height",
13916          /*icon_upload*/
13917          ctx2[12] ? "" : (
13918            /*height*/
13919            ctx2[13] ? typeof /*height*/
13920            ctx2[13] === "number" ? (
13921              /*height*/
13922              ctx2[13] + "px"
13923            ) : (
13924              /*height*/
13925              ctx2[13]
13926            ) : "100%"
13927          )
13928        );
13929      }
13930    },
13931    i(local) {
13932      if (current) return;
13933      transition_in(default_slot, local);
13934      current = true;
13935    },
13936    o(local) {
13937      transition_out(default_slot, local);
13938      current = false;
13939    },
13940    d(detaching) {
13941      if (detaching) {
13942        detach(button);
13943      }
13944      if (default_slot) default_slot.d(detaching);
13945      mounted = false;
13946      dispose();
13947    }
13948  };
13949}
13950function create_if_block_2$b(ctx) {
13951  let uploadprogress;
13952  let current;
13953  uploadprogress = new UploadProgress({
13954    props: {
13955      root: (
13956        /*root*/
13957        ctx[8]
13958      ),
13959      upload_id: (
13960        /*upload_id*/
13961        ctx[19]
13962      ),
13963      files: (
13964        /*file_data*/
13965        ctx[16]
13966      ),
13967      stream_handler: (
13968        /*stream_handler*/
13969        ctx[11]
13970      )
13971    }
13972  });
13973  return {
13974    c() {
13975      create_component(uploadprogress.$$.fragment);
13976    },
13977    m(target, anchor) {
13978      mount_component(uploadprogress, target, anchor);
13979      current = true;
13980    },
13981    p(ctx2, dirty) {
13982      const uploadprogress_changes = {};
13983      if (dirty[0] & /*root*/
13984      256) uploadprogress_changes.root = /*root*/
13985      ctx2[8];
13986      if (dirty[0] & /*file_data*/
13987      65536) uploadprogress_changes.files = /*file_data*/
13988      ctx2[16];
13989      if (dirty[0] & /*stream_handler*/
13990      2048) uploadprogress_changes.stream_handler = /*stream_handler*/
13991      ctx2[11];
13992      uploadprogress.$set(uploadprogress_changes);
13993    },
13994    i(local) {
13995      if (current) return;
13996      transition_in(uploadprogress.$$.fragment, local);
13997      current = true;
13998    },
13999    o(local) {
14000      transition_out(uploadprogress.$$.fragment, local);
14001      current = false;
14002    },
14003    d(detaching) {
14004      destroy_component(uploadprogress, detaching);
14005    }
14006  };
14007}
14008function create_fragment$t(ctx) {
14009  let current_block_type_index;
14010  let if_block;
14011  let if_block_anchor;
14012  let current;
14013  const if_block_creators = [create_if_block$g, create_if_block_1$c, create_else_block$7];
14014  const if_blocks = [];
14015  function select_block_type(ctx2, dirty) {
14016    if (
14017      /*filetype*/
14018      ctx2[0] === "clipboard"
14019    ) return 0;
14020    if (
14021      /*uploading*/
14022      ctx2[2] && /*show_progress*/
14023      ctx2[10]
14024    ) return 1;
14025    return 2;
14026  }
14027  current_block_type_index = select_block_type(ctx);
14028  if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
14029  return {
14030    c() {
14031      if_block.c();
14032      if_block_anchor = empty();
14033    },
14034    m(target, anchor) {
14035      if_blocks[current_block_type_index].m(target, anchor);
14036      insert(target, if_block_anchor, anchor);
14037      current = true;
14038    },
14039    p(ctx2, dirty) {
14040      let previous_block_index = current_block_type_index;
14041      current_block_type_index = select_block_type(ctx2);
14042      if (current_block_type_index === previous_block_index) {
14043        if_blocks[current_block_type_index].p(ctx2, dirty);
14044      } else {
14045        group_outros();
14046        transition_out(if_blocks[previous_block_index], 1, 1, () => {
14047          if_blocks[previous_block_index] = null;
14048        });
14049        check_outros();
14050        if_block = if_blocks[current_block_type_index];
14051        if (!if_block) {
14052          if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
14053          if_block.c();
14054        } else {
14055          if_block.p(ctx2, dirty);
14056        }
14057        transition_in(if_block, 1);
14058        if_block.m(if_block_anchor.parentNode, if_block_anchor);
14059      }
14060    },
14061    i(local) {
14062      if (current) return;
14063      transition_in(if_block);
14064      current = true;
14065    },
14066    o(local) {
14067      transition_out(if_block);
14068      current = false;
14069    },
14070    d(detaching) {
14071      if (detaching) {
14072        detach(if_block_anchor);
14073      }
14074      if_blocks[current_block_type_index].d(detaching);
14075    }
14076  };
14077}
14078function is_valid_mimetype(file_accept, uploaded_file_extension, uploaded_file_type) {
14079  if (!file_accept || file_accept === "*" || file_accept === "file/*" || Array.isArray(file_accept) && file_accept.some((accept) => accept === "*" || accept === "file/*")) {
14080    return true;
14081  }
14082  let acceptArray;
14083  if (typeof file_accept === "string") {
14084    acceptArray = file_accept.split(",").map((s) => s.trim());
14085  } else if (Array.isArray(file_accept)) {
14086    acceptArray = file_accept;
14087  } else {
14088    return false;
14089  }
14090  return acceptArray.includes(uploaded_file_extension) || acceptArray.some((type) => {
14091    const [category] = type.split("/").map((s) => s.trim());
14092    return type.endsWith("/*") && uploaded_file_type.startsWith(category + "/");
14093  });
14094}
14095const drag_function = (dragging) => dragging = dragging;
14096function instance$s($$self, $$props, $$invalidate) {
14097  let ios;
14098  let { $$slots: slots = {}, $$scope } = $$props;
14099  const { drag, open_file_upload: _open_file_upload } = create_drag();
14100  let { filetype = null } = $$props;
14101  let { dragging = false } = $$props;
14102  let { boundedheight = true } = $$props;
14103  let { center = true } = $$props;
14104  let { flex = true } = $$props;
14105  let { file_count = "single" } = $$props;
14106  let { disable_click = false } = $$props;
14107  let { root } = $$props;
14108  let { hidden = false } = $$props;
14109  let { format = "file" } = $$props;
14110  let { uploading = false } = $$props;
14111  let { show_progress = true } = $$props;
14112  let { max_file_size = null } = $$props;
14113  let { upload } = $$props;
14114  let { stream_handler } = $$props;
14115  let { icon_upload = false } = $$props;
14116  let { height: height2 = void 0 } = $$props;
14117  let { aria_label = void 0 } = $$props;
14118  function open_upload() {
14119    _open_file_upload();
14120  }
14121  let upload_id;
14122  let file_data;
14123  let accept_file_types;
14124  let use_post_upload_validation = null;
14125  const get_ios = () => {
14126    if (typeof navigator !== "undefined") {
14127      const userAgent = navigator.userAgent.toLowerCase();
14128      return userAgent.indexOf("iphone") > -1 || userAgent.indexOf("ipad") > -1;
14129    }
14130    return false;
14131  };
14132  const dispatch2 = createEventDispatcher();
14133  const validFileTypes = ["image", "video", "audio", "text", "file"];
14134  const process_file_type = (type) => {
14135    if (ios && type.startsWith(".")) {
14136      use_post_upload_validation = true;
14137      return type;
14138    }
14139    if (ios && type.includes("file/*")) {
14140      return "*";
14141    }
14142    if (type.startsWith(".") || type.endsWith("/*")) {
14143      return type;
14144    }
14145    if (validFileTypes.includes(type)) {
14146      return type + "/*";
14147    }
14148    return "." + type;
14149  };
14150  function paste_clipboard() {
14151    navigator.clipboard.read().then(async (items2) => {
14152      for (let i = 0; i < items2.length; i++) {
14153        const type = items2[i].types.find((t) => t.startsWith("image/"));
14154        if (type) {
14155          items2[i].getType(type).then(async (blob) => {
14156            const file = new File([blob], `clipboard.${type.replace("image/", "")}`);
14157            await load_files([file]);
14158          });
14159          break;
14160        }
14161      }
14162    });
14163  }
14164  function open_file_upload() {
14165    _open_file_upload();
14166  }
14167  async function handle_upload(file_data2, upload_id2) {
14168    await tick();
14169    if (!upload_id2) {
14170      upload_id2 = Math.random().toString(36).substring(2, 15);
14171    }
14172    $$invalidate(2, uploading = true);
14173    try {
14174      const _file_data = await upload(file_data2, root, upload_id2, max_file_size ?? Infinity);
14175      dispatch2("load", file_count === "single" ? _file_data == null ? void 0 : _file_data[0] : _file_data);
14176      $$invalidate(2, uploading = false);
14177      return _file_data || [];
14178    } catch (e) {
14179      dispatch2("error", e.message);
14180      $$invalidate(2, uploading = false);
14181      return [];
14182    }
14183  }
14184  async function load_files(files, upload_id2) {
14185    if (!files.length) {
14186      return;
14187    }
14188    let _files = files.map((f) => new File([f], f instanceof File ? f.name : "file", { type: f.type }));
14189    if (ios && use_post_upload_validation) {
14190      _files = _files.filter((file) => {
14191        if (is_valid_file(file)) {
14192          return true;
14193        }
14194        dispatch2("error", `Invalid file type: ${file.name}. Only ${filetype} allowed.`);
14195        return false;
14196      });
14197      if (_files.length === 0) {
14198        return [];
14199      }
14200    }
14201    $$invalidate(16, file_data = await prepare_files(_files));
14202    return await handle_upload(file_data, upload_id2);
14203  }
14204  function is_valid_file(file) {
14205    if (!filetype) return true;
14206    const allowed_types = Array.isArray(filetype) ? filetype : [filetype];
14207    return allowed_types.some((type) => {
14208      const processed_type = process_file_type(type);
14209      if (processed_type.startsWith(".")) {
14210        return file.name.toLowerCase().endsWith(processed_type.toLowerCase());
14211      }
14212      if (processed_type === "*") {
14213        return true;
14214      }
14215      if (processed_type.endsWith("/*")) {
14216        const [category] = processed_type.split("/");
14217        return file.type.startsWith(category + "/");
14218      }
14219      return file.type === processed_type;
14220    });
14221  }
14222  async function load_files_from_upload(files) {
14223    const files_to_load = files.filter((file) => {
14224      const file_extension = "." + file.name.toLowerCase().split(".").pop();
14225      if (file_extension && is_valid_mimetype(accept_file_types, file_extension, file.type)) {
14226        return true;
14227      }
14228      if (file_extension && Array.isArray(filetype) ? filetype.includes(file_extension) : file_extension === filetype) {
14229        return true;
14230      }
14231      dispatch2("error", `Invalid file type only ${filetype} allowed.`);
14232      return false;
14233    });
14234    if (format != "blob") {
14235      await load_files(files_to_load);
14236    } else {
14237      if (file_count === "single") {
14238        dispatch2("load", files_to_load[0]);
14239        return;
14240      }
14241      dispatch2("load", files_to_load);
14242    }
14243  }
14244  async function load_files_from_drop(e) {
14245    var _a;
14246    $$invalidate(1, dragging = false);
14247    if (!((_a = e.dataTransfer) == null ? void 0 : _a.files)) return;
14248    const files_to_load = Array.from(e.dataTransfer.files).filter(is_valid_file);
14249    if (format != "blob") {
14250      await load_files(files_to_load);
14251    } else {
14252      if (file_count === "single") {
14253        dispatch2("load", files_to_load[0]);
14254        return;
14255      }
14256      dispatch2("load", files_to_load);
14257    }
14258  }
14259  const drag_function_1 = (files) => load_files_from_upload(files);
14260  $$self.$$set = ($$props2) => {
14261    if ("filetype" in $$props2) $$invalidate(0, filetype = $$props2.filetype);
14262    if ("dragging" in $$props2) $$invalidate(1, dragging = $$props2.dragging);
14263    if ("boundedheight" in $$props2) $$invalidate(3, boundedheight = $$props2.boundedheight);
14264    if ("center" in $$props2) $$invalidate(4, center = $$props2.center);
14265    if ("flex" in $$props2) $$invalidate(5, flex = $$props2.flex);
14266    if ("file_count" in $$props2) $$invalidate(6, file_count = $$props2.file_count);
14267    if ("disable_click" in $$props2) $$invalidate(7, disable_click = $$props2.disable_click);
14268    if ("root" in $$props2) $$invalidate(8, root = $$props2.root);
14269    if ("hidden" in $$props2) $$invalidate(9, hidden = $$props2.hidden);
14270    if ("format" in $$props2) $$invalidate(21, format = $$props2.format);
14271    if ("uploading" in $$props2) $$invalidate(2, uploading = $$props2.uploading);
14272    if ("show_progress" in $$props2) $$invalidate(10, show_progress = $$props2.show_progress);
14273    if ("max_file_size" in $$props2) $$invalidate(22, max_file_size = $$props2.max_file_size);
14274    if ("upload" in $$props2) $$invalidate(23, upload = $$props2.upload);
14275    if ("stream_handler" in $$props2) $$invalidate(11, stream_handler = $$props2.stream_handler);
14276    if ("icon_upload" in $$props2) $$invalidate(12, icon_upload = $$props2.icon_upload);
14277    if ("height" in $$props2) $$invalidate(13, height2 = $$props2.height);
14278    if ("aria_label" in $$props2) $$invalidate(14, aria_label = $$props2.aria_label);
14279    if ("$$scope" in $$props2) $$invalidate(29, $$scope = $$props2.$$scope);
14280  };
14281  $$self.$$.update = () => {
14282    if ($$self.$$.dirty[0] & /*filetype, ios*/
14283    268435457) {
14284      if (filetype == null) {
14285        $$invalidate(17, accept_file_types = null);
14286      } else if (typeof filetype === "string") {
14287        $$invalidate(17, accept_file_types = process_file_type(filetype));
14288      } else if (ios && filetype.includes("file/*")) {
14289        $$invalidate(17, accept_file_types = "*");
14290      } else {
14291        $$invalidate(0, filetype = filetype.map(process_file_type));
14292        $$invalidate(17, accept_file_types = filetype.join(", "));
14293      }
14294    }
14295  };
14296  $$invalidate(28, ios = get_ios());
14297  return [
14298    filetype,
14299    dragging,
14300    uploading,
14301    boundedheight,
14302    center,
14303    flex,
14304    file_count,
14305    disable_click,
14306    root,
14307    hidden,
14308    show_progress,
14309    stream_handler,
14310    icon_upload,
14311    height2,
14312    aria_label,
14313    paste_clipboard,
14314    file_data,
14315    accept_file_types,
14316    drag,
14317    upload_id,
14318    load_files_from_upload,
14319    format,
14320    max_file_size,
14321    upload,
14322    open_upload,
14323    open_file_upload,
14324    load_files,
14325    load_files_from_drop,
14326    ios,
14327    $$scope,
14328    slots,
14329    drag_function_1
14330  ];
14331}
14332class Upload2 extends SvelteComponent {
14333  constructor(options) {
14334    super();
14335    init(
14336      this,
14337      options,
14338      instance$s,
14339      create_fragment$t,
14340      safe_not_equal,
14341      {
14342        filetype: 0,
14343        dragging: 1,
14344        boundedheight: 3,
14345        center: 4,
14346        flex: 5,
14347        file_count: 6,
14348        disable_click: 7,
14349        root: 8,
14350        hidden: 9,
14351        format: 21,
14352        uploading: 2,
14353        show_progress: 10,
14354        max_file_size: 22,
14355        upload: 23,
14356        stream_handler: 11,
14357        icon_upload: 12,
14358        height: 13,
14359        aria_label: 14,
14360        open_upload: 24,
14361        paste_clipboard: 15,
14362        open_file_upload: 25,
14363        load_files: 26,
14364        load_files_from_drop: 27
14365      },
14366      null,
14367      [-1, -1]
14368    );
14369  }
14370  get open_upload() {
14371    return this.$$.ctx[24];
14372  }
14373  get paste_clipboard() {
14374    return this.$$.ctx[15];
14375  }
14376  get open_file_upload() {
14377    return this.$$.ctx[25];
14378  }
14379  get load_files() {
14380    return this.$$.ctx[26];
14381  }
14382  get load_files_from_drop() {
14383    return this.$$.ctx[27];
14384  }
14385}
14386function create_fragment$s(ctx) {
14387  let button;
14388  let span;
14389  let svg;
14390  let path;
14391  let span_class_value;
14392  let button_class_value;
14393  let button_aria_label_value;
14394  let mounted;
14395  let dispose;
14396  return {
14397    c() {
14398      button = element("button");
14399      span = element("span");
14400      svg = svg_element("svg");
14401      path = svg_element("path");
14402      attr(path, "d", "m16.707 13.293-4-4a1 1 0 0 0-1.414 0l-4 4A1 1 0 0 0 8 15h8a1 1 0 0 0 .707-1.707z");
14403      attr(
14404        path,
14405        "data-name",
14406        /*direction*/
14407        ctx[3]
14408      );
14409      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
14410      attr(svg, "viewBox", "0 0 24 24");
14411      attr(svg, "class", "svelte-liwrp1");
14412      attr(span, "class", span_class_value = null_to_empty(
14413        /*direction*/
14414        ctx[3]
14415      ) + " svelte-liwrp1");
14416      attr(button, "class", button_class_value = "selection-button selection-button-" + /*position*/
14417      ctx[0] + " " + /*is_first_position*/
14418      (ctx[2] ? `move-${/*direction*/
14419      ctx[3]}` : "") + " svelte-liwrp1");
14420      attr(button, "aria-label", button_aria_label_value = `Select ${/*position*/
14421      ctx[0]}`);
14422    },
14423    m(target, anchor) {
14424      insert(target, button, anchor);
14425      append(button, span);
14426      append(span, svg);
14427      append(svg, path);
14428      if (!mounted) {
14429        dispose = listen(button, "click", stop_propagation(
14430          /*click_handler*/
14431          ctx[5]
14432        ));
14433        mounted = true;
14434      }
14435    },
14436    p(ctx2, [dirty]) {
14437      if (dirty & /*direction*/
14438      8) {
14439        attr(
14440          path,
14441          "data-name",
14442          /*direction*/
14443          ctx2[3]
14444        );
14445      }
14446      if (dirty & /*direction*/
14447      8 && span_class_value !== (span_class_value = null_to_empty(
14448        /*direction*/
14449        ctx2[3]
14450      ) + " svelte-liwrp1")) {
14451        attr(span, "class", span_class_value);
14452      }
14453      if (dirty & /*position, is_first_position, direction*/
14454      13 && button_class_value !== (button_class_value = "selection-button selection-button-" + /*position*/
14455      ctx2[0] + " " + /*is_first_position*/
14456      (ctx2[2] ? `move-${/*direction*/
14457      ctx2[3]}` : "") + " svelte-liwrp1")) {
14458        attr(button, "class", button_class_value);
14459      }
14460      if (dirty & /*position*/
14461      1 && button_aria_label_value !== (button_aria_label_value = `Select ${/*position*/
14462      ctx2[0]}`)) {
14463        attr(button, "aria-label", button_aria_label_value);
14464      }
14465    },
14466    i: noop,
14467    o: noop,
14468    d(detaching) {
14469      if (detaching) {
14470        detach(button);
14471      }
14472      mounted = false;
14473      dispose();
14474    }
14475  };
14476}
14477function instance$r($$self, $$props, $$invalidate) {
14478  let is_first_position;
14479  let direction;
14480  let { position } = $$props;
14481  let { coords } = $$props;
14482  let { on_click = null } = $$props;
14483  const click_handler = () => on_click && on_click();
14484  $$self.$$set = ($$props2) => {
14485    if ("position" in $$props2) $$invalidate(0, position = $$props2.position);
14486    if ("coords" in $$props2) $$invalidate(4, coords = $$props2.coords);
14487    if ("on_click" in $$props2) $$invalidate(1, on_click = $$props2.on_click);
14488  };
14489  $$self.$$.update = () => {
14490    if ($$self.$$.dirty & /*position, coords*/
14491    17) {
14492      $$invalidate(2, is_first_position = position === "column" ? coords[0] === 0 : coords[1] === 0);
14493    }
14494    if ($$self.$$.dirty & /*position, is_first_position*/
14495    5) {
14496      $$invalidate(3, direction = position === "column" ? is_first_position ? "down" : "up" : is_first_position ? "right" : "left");
14497    }
14498  };
14499  return [position, on_click, is_first_position, direction, coords, click_handler];
14500}
14501let SelectionButtons$1 = class SelectionButtons extends SvelteComponent {
14502  constructor(options) {
14503    super();
14504    init(this, options, instance$r, create_fragment$s, safe_not_equal, { position: 0, coords: 4, on_click: 1 });
14505  }
14506};
14507function pretty_si(num) {
14508  let units = ["", "k", "M", "G", "T", "P", "E", "Z"];
14509  let i = 0;
14510  while (num > 1e3 && i < units.length - 1) {
14511    num /= 1e3;
14512    i++;
14513  }
14514  let unit = units[i];
14515  return (Number.isInteger(num) ? num : num.toFixed(1)) + unit;
14516}
14517function is_date(obj) {
14518  return Object.prototype.toString.call(obj) === "[object Date]";
14519}
14520function tick_spring(ctx, last_value, current_value, target_value) {
14521  if (typeof current_value === "number" || is_date(current_value)) {
14522    const delta = target_value - current_value;
14523    const velocity = (current_value - last_value) / (ctx.dt || 1 / 60);
14524    const spring2 = ctx.opts.stiffness * delta;
14525    const damper = ctx.opts.damping * velocity;
14526    const acceleration = (spring2 - damper) * ctx.inv_mass;
14527    const d = (velocity + acceleration) * ctx.dt;
14528    if (Math.abs(d) < ctx.opts.precision && Math.abs(delta) < ctx.opts.precision) {
14529      return target_value;
14530    } else {
14531      ctx.settled = false;
14532      return is_date(current_value) ? new Date(current_value.getTime() + d) : current_value + d;
14533    }
14534  } else if (Array.isArray(current_value)) {
14535    return current_value.map(
14536      (_, i) => tick_spring(ctx, last_value[i], current_value[i], target_value[i])
14537    );
14538  } else if (typeof current_value === "object") {
14539    const next_value = {};
14540    for (const k in current_value) {
14541      next_value[k] = tick_spring(ctx, last_value[k], current_value[k], target_value[k]);
14542    }
14543    return next_value;
14544  } else {
14545    throw new Error(`Cannot spring ${typeof current_value} values`);
14546  }
14547}
14548function spring(value, opts = {}) {
14549  const store = writable(value);
14550  const { stiffness = 0.15, damping = 0.8, precision = 0.01 } = opts;
14551  let last_time;
14552  let task;
14553  let current_token;
14554  let last_value = value;
14555  let target_value = value;
14556  let inv_mass = 1;
14557  let inv_mass_recovery_rate = 0;
14558  let cancel_task = false;
14559  function set(new_value, opts2 = {}) {
14560    target_value = new_value;
14561    const token = current_token = {};
14562    if (value == null || opts2.hard || spring2.stiffness >= 1 && spring2.damping >= 1) {
14563      cancel_task = true;
14564      last_time = now();
14565      last_value = new_value;
14566      store.set(value = target_value);
14567      return Promise.resolve();
14568    } else if (opts2.soft) {
14569      const rate = opts2.soft === true ? 0.5 : +opts2.soft;
14570      inv_mass_recovery_rate = 1 / (rate * 60);
14571      inv_mass = 0;
14572    }
14573    if (!task) {
14574      last_time = now();
14575      cancel_task = false;
14576      task = loop((now2) => {
14577        if (cancel_task) {
14578          cancel_task = false;
14579          task = null;
14580          return false;
14581        }
14582        inv_mass = Math.min(inv_mass + inv_mass_recovery_rate, 1);
14583        const ctx = {
14584          inv_mass,
14585          opts: spring2,
14586          settled: true,
14587          dt: (now2 - last_time) * 60 / 1e3
14588        };
14589        const next_value = tick_spring(ctx, last_value, value, target_value);
14590        last_time = now2;
14591        last_value = value;
14592        store.set(value = next_value);
14593        if (ctx.settled) {
14594          task = null;
14595        }
14596        return !ctx.settled;
14597      });
14598    }
14599    return new Promise((fulfil) => {
14600      task.promise.then(() => {
14601        if (token === current_token) fulfil();
14602      });
14603    });
14604  }
14605  const spring2 = {
14606    set,
14607    update: (fn, opts2) => set(fn(target_value, value), opts2),
14608    subscribe: store.subscribe,
14609    stiffness,
14610    damping,
14611    precision
14612  };
14613  return spring2;
14614}
14615function create_fragment$r(ctx) {
14616  let div;
14617  let svg;
14618  let g0;
14619  let path0;
14620  let path1;
14621  let path2;
14622  let path3;
14623  let g1;
14624  let path4;
14625  let path5;
14626  let path6;
14627  let path7;
14628  return {
14629    c() {
14630      div = element("div");
14631      svg = svg_element("svg");
14632      g0 = svg_element("g");
14633      path0 = svg_element("path");
14634      path1 = svg_element("path");
14635      path2 = svg_element("path");
14636      path3 = svg_element("path");
14637      g1 = svg_element("g");
14638      path4 = svg_element("path");
14639      path5 = svg_element("path");
14640      path6 = svg_element("path");
14641      path7 = svg_element("path");
14642      attr(path0, "d", "M255.926 0.754768L509.702 139.936V221.027L255.926 81.8465V0.754768Z");
14643      attr(path0, "fill", "#FF7C00");
14644      attr(path0, "fill-opacity", "0.4");
14645      attr(path0, "class", "svelte-43sxxs");
14646      attr(path1, "d", "M509.69 139.936L254.981 279.641V361.255L509.69 221.55V139.936Z");
14647      attr(path1, "fill", "#FF7C00");
14648      attr(path1, "class", "svelte-43sxxs");
14649      attr(path2, "d", "M0.250138 139.937L254.981 279.641V361.255L0.250138 221.55V139.937Z");
14650      attr(path2, "fill", "#FF7C00");
14651      attr(path2, "fill-opacity", "0.4");
14652      attr(path2, "class", "svelte-43sxxs");
14653      attr(path3, "d", "M255.923 0.232622L0.236328 139.936V221.55L255.923 81.8469V0.232622Z");
14654      attr(path3, "fill", "#FF7C00");
14655      attr(path3, "class", "svelte-43sxxs");
14656      set_style(g0, "transform", "translate(" + /*$top*/
14657      ctx[1][0] + "px, " + /*$top*/
14658      ctx[1][1] + "px)");
14659      attr(path4, "d", "M255.926 141.5L509.702 280.681V361.773L255.926 222.592V141.5Z");
14660      attr(path4, "fill", "#FF7C00");
14661      attr(path4, "fill-opacity", "0.4");
14662      attr(path4, "class", "svelte-43sxxs");
14663      attr(path5, "d", "M509.69 280.679L254.981 420.384V501.998L509.69 362.293V280.679Z");
14664      attr(path5, "fill", "#FF7C00");
14665      attr(path5, "class", "svelte-43sxxs");
14666      attr(path6, "d", "M0.250138 280.681L254.981 420.386V502L0.250138 362.295V280.681Z");
14667      attr(path6, "fill", "#FF7C00");
14668      attr(path6, "fill-opacity", "0.4");
14669      attr(path6, "class", "svelte-43sxxs");
14670      attr(path7, "d", "M255.923 140.977L0.236328 280.68V362.294L255.923 222.591V140.977Z");
14671      attr(path7, "fill", "#FF7C00");
14672      attr(path7, "class", "svelte-43sxxs");
14673      set_style(g1, "transform", "translate(" + /*$bottom*/
14674      ctx[2][0] + "px, " + /*$bottom*/
14675      ctx[2][1] + "px)");
14676      attr(svg, "viewBox", "-1200 -1200 3000 3000");
14677      attr(svg, "fill", "none");
14678      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
14679      attr(svg, "class", "svelte-43sxxs");
14680      attr(div, "class", "svelte-43sxxs");
14681      toggle_class(
14682        div,
14683        "margin",
14684        /*margin*/
14685        ctx[0]
14686      );
14687    },
14688    m(target, anchor) {
14689      insert(target, div, anchor);
14690      append(div, svg);
14691      append(svg, g0);
14692      append(g0, path0);
14693      append(g0, path1);
14694      append(g0, path2);
14695      append(g0, path3);
14696      append(svg, g1);
14697      append(g1, path4);
14698      append(g1, path5);
14699      append(g1, path6);
14700      append(g1, path7);
14701    },
14702    p(ctx2, [dirty]) {
14703      if (dirty & /*$top*/
14704      2) {
14705        set_style(g0, "transform", "translate(" + /*$top*/
14706        ctx2[1][0] + "px, " + /*$top*/
14707        ctx2[1][1] + "px)");
14708      }
14709      if (dirty & /*$bottom*/
14710      4) {
14711        set_style(g1, "transform", "translate(" + /*$bottom*/
14712        ctx2[2][0] + "px, " + /*$bottom*/
14713        ctx2[2][1] + "px)");
14714      }
14715      if (dirty & /*margin*/
14716      1) {
14717        toggle_class(
14718          div,
14719          "margin",
14720          /*margin*/
14721          ctx2[0]
14722        );
14723      }
14724    },
14725    i: noop,
14726    o: noop,
14727    d(detaching) {
14728      if (detaching) {
14729        detach(div);
14730      }
14731    }
14732  };
14733}
14734function instance$q($$self, $$props, $$invalidate) {
14735  let $top;
14736  let $bottom;
14737  let { margin = true } = $$props;
14738  const top = spring([0, 0]);
14739  component_subscribe($$self, top, (value) => $$invalidate(1, $top = value));
14740  const bottom = spring([0, 0]);
14741  component_subscribe($$self, bottom, (value) => $$invalidate(2, $bottom = value));
14742  let dismounted;
14743  async function animate() {
14744    await Promise.all([top.set([125, 140]), bottom.set([-125, -140])]);
14745    await Promise.all([top.set([-125, 140]), bottom.set([125, -140])]);
14746    await Promise.all([top.set([-125, 0]), bottom.set([125, -0])]);
14747    await Promise.all([top.set([125, 0]), bottom.set([-125, 0])]);
14748  }
14749  async function run2() {
14750    await animate();
14751    if (!dismounted) run2();
14752  }
14753  async function loading() {
14754    await Promise.all([top.set([125, 0]), bottom.set([-125, 0])]);
14755    run2();
14756  }
14757  onMount(() => {
14758    loading();
14759    return () => dismounted = true;
14760  });
14761  $$self.$$set = ($$props2) => {
14762    if ("margin" in $$props2) $$invalidate(0, margin = $$props2.margin);
14763  };
14764  return [margin, $top, $bottom, top, bottom];
14765}
14766class Loader extends SvelteComponent {
14767  constructor(options) {
14768    super();
14769    init(this, options, instance$q, create_fragment$r, safe_not_equal, { margin: 0 });
14770  }
14771}
14772const get_error_slot_changes = (dirty) => ({});
14773const get_error_slot_context = (ctx) => ({});
14774const get_additional_loading_text_slot_changes = (dirty) => ({});
14775const get_additional_loading_text_slot_context = (ctx) => ({});
14776function get_each_context$4(ctx, list2, i) {
14777  const child_ctx = ctx.slice();
14778  child_ctx[43] = list2[i];
14779  child_ctx[45] = i;
14780  return child_ctx;
14781}
14782function get_each_context_1$1(ctx, list2, i) {
14783  const child_ctx = ctx.slice();
14784  child_ctx[43] = list2[i];
14785  return child_ctx;
14786}
14787function create_if_block_18(ctx) {
14788  let div;
14789  let t0;
14790  let t1;
14791  let button;
14792  let iconbutton;
14793  let current;
14794  iconbutton = new IconButton({
14795    props: {
14796      Icon: Clear,
14797      label: (
14798        /*i18n*/
14799        ctx[2]("common.clear")
14800      ),
14801      disabled: false,
14802      size: "x-small",
14803      background: "var(--background-fill-primary)",
14804      color: "var(--error-background-text)",
14805      border: "var(--border-color-primary)"
14806    }
14807  });
14808  iconbutton.$on(
14809    "click",
14810    /*click_handler*/
14811    ctx[33]
14812  );
14813  return {
14814    c() {
14815      div = element("div");
14816      t0 = text(
14817        /*validation_error*/
14818        ctx[1]
14819      );
14820      t1 = space();
14821      button = element("button");
14822      create_component(iconbutton.$$.fragment);
14823      attr(div, "class", "validation-error svelte-vusapu");
14824    },
14825    m(target, anchor) {
14826      insert(target, div, anchor);
14827      append(div, t0);
14828      append(div, t1);
14829      append(div, button);
14830      mount_component(iconbutton, button, null);
14831      current = true;
14832    },
14833    p(ctx2, dirty) {
14834      if (!current || dirty[0] & /*validation_error*/
14835      2) set_data(
14836        t0,
14837        /*validation_error*/
14838        ctx2[1]
14839      );
14840      const iconbutton_changes = {};
14841      if (dirty[0] & /*i18n*/
14842      4) iconbutton_changes.label = /*i18n*/
14843      ctx2[2]("common.clear");
14844      iconbutton.$set(iconbutton_changes);
14845    },
14846    i(local) {
14847      if (current) return;
14848      transition_in(iconbutton.$$.fragment, local);
14849      current = true;
14850    },
14851    o(local) {
14852      transition_out(iconbutton.$$.fragment, local);
14853      current = false;
14854    },
14855    d(detaching) {
14856      if (detaching) {
14857        detach(div);
14858      }
14859      destroy_component(iconbutton);
14860    }
14861  };
14862}
14863function create_if_block_17(ctx) {
14864  let div;
14865  let iconbutton;
14866  let t0;
14867  let span;
14868  let t1_value = (
14869    /*i18n*/
14870    ctx[2]("common.error") + ""
14871  );
14872  let t1;
14873  let t2;
14874  let current;
14875  iconbutton = new IconButton({
14876    props: {
14877      Icon: Clear,
14878      label: (
14879        /*i18n*/
14880        ctx[2]("common.clear")
14881      ),
14882      disabled: false
14883    }
14884  });
14885  iconbutton.$on(
14886    "click",
14887    /*click_handler_1*/
14888    ctx[35]
14889  );
14890  const error_slot_template = (
14891    /*#slots*/
14892    ctx[32].error
14893  );
14894  const error_slot = create_slot(
14895    error_slot_template,
14896    ctx,
14897    /*$$scope*/
14898    ctx[31],
14899    get_error_slot_context
14900  );
14901  return {
14902    c() {
14903      div = element("div");
14904      create_component(iconbutton.$$.fragment);
14905      t0 = space();
14906      span = element("span");
14907      t1 = text(t1_value);
14908      t2 = space();
14909      if (error_slot) error_slot.c();
14910      attr(div, "class", "clear-status svelte-vusapu");
14911      attr(span, "class", "error svelte-vusapu");
14912    },
14913    m(target, anchor) {
14914      insert(target, div, anchor);
14915      mount_component(iconbutton, div, null);
14916      insert(target, t0, anchor);
14917      insert(target, span, anchor);
14918      append(span, t1);
14919      insert(target, t2, anchor);
14920      if (error_slot) {
14921        error_slot.m(target, anchor);
14922      }
14923      current = true;
14924    },
14925    p(ctx2, dirty) {
14926      const iconbutton_changes = {};
14927      if (dirty[0] & /*i18n*/
14928      4) iconbutton_changes.label = /*i18n*/
14929      ctx2[2]("common.clear");
14930      iconbutton.$set(iconbutton_changes);
14931      if ((!current || dirty[0] & /*i18n*/
14932      4) && t1_value !== (t1_value = /*i18n*/
14933      ctx2[2]("common.error") + "")) set_data(t1, t1_value);
14934      if (error_slot) {
14935        if (error_slot.p && (!current || dirty[1] & /*$$scope*/
14936        1)) {
14937          update_slot_base(
14938            error_slot,
14939            error_slot_template,
14940            ctx2,
14941            /*$$scope*/
14942            ctx2[31],
14943            !current ? get_all_dirty_from_scope(
14944              /*$$scope*/
14945              ctx2[31]
14946            ) : get_slot_changes(
14947              error_slot_template,
14948              /*$$scope*/
14949              ctx2[31],
14950              dirty,
14951              get_error_slot_changes
14952            ),
14953            get_error_slot_context
14954          );
14955        }
14956      }
14957    },
14958    i(local) {
14959      if (current) return;
14960      transition_in(iconbutton.$$.fragment, local);
14961      transition_in(error_slot, local);
14962      current = true;
14963    },
14964    o(local) {
14965      transition_out(iconbutton.$$.fragment, local);
14966      transition_out(error_slot, local);
14967      current = false;
14968    },
14969    d(detaching) {
14970      if (detaching) {
14971        detach(div);
14972        detach(t0);
14973        detach(span);
14974        detach(t2);
14975      }
14976      destroy_component(iconbutton);
14977      if (error_slot) error_slot.d(detaching);
14978    }
14979  };
14980}
14981function create_if_block$f(ctx) {
14982  let t0;
14983  let div;
14984  let t1;
14985  let t2;
14986  let current_block_type_index;
14987  let if_block3;
14988  let t3;
14989  let if_block4_anchor;
14990  let current;
14991  let if_block0 = (
14992    /*variant*/
14993    ctx[9] === "default" && /*show_eta_bar*/
14994    ctx[20] && /*show_progress*/
14995    ctx[7] === "full" && create_if_block_16(ctx)
14996  );
14997  function select_block_type_1(ctx2, dirty) {
14998    if (
14999      /*progress*/
15000      ctx2[8]
15001    ) return create_if_block_11;
15002    if (
15003      /*queue_position*/
15004      ctx2[3] !== null && /*queue_size*/
15005      ctx2[4] !== void 0 && /*queue_position*/
15006      ctx2[3] >= 0
15007    ) return create_if_block_14;
15008    if (
15009      /*queue_position*/
15010      ctx2[3] === 0
15011    ) return create_if_block_15;
15012  }
15013  let current_block_type = select_block_type_1(ctx);
15014  let if_block1 = current_block_type && current_block_type(ctx);
15015  let if_block2 = (
15016    /*timer*/
15017    ctx[6] && create_if_block_10$1(ctx)
15018  );
15019  const if_block_creators = [create_if_block_2$a, create_if_block_9$2];
15020  const if_blocks = [];
15021  function select_block_type_3(ctx2, dirty) {
15022    if (
15023      /*last_progress_level*/
15024      ctx2[17] != null
15025    ) return 0;
15026    if (
15027      /*show_progress*/
15028      ctx2[7] === "full"
15029    ) return 1;
15030    return -1;
15031  }
15032  if (~(current_block_type_index = select_block_type_3(ctx))) {
15033    if_block3 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
15034  }
15035  let if_block4 = !/*timer*/
15036  ctx[6] && create_if_block_1$b(ctx);
15037  return {
15038    c() {
15039      if (if_block0) if_block0.c();
15040      t0 = space();
15041      div = element("div");
15042      if (if_block1) if_block1.c();
15043      t1 = space();
15044      if (if_block2) if_block2.c();
15045      t2 = space();
15046      if (if_block3) if_block3.c();
15047      t3 = space();
15048      if (if_block4) if_block4.c();
15049      if_block4_anchor = empty();
15050      attr(div, "class", "progress-text svelte-vusapu");
15051      toggle_class(
15052        div,
15053        "meta-text-center",
15054        /*variant*/
15055        ctx[9] === "center"
15056      );
15057      toggle_class(
15058        div,
15059        "meta-text",
15060        /*variant*/
15061        ctx[9] === "default"
15062      );
15063    },
15064    m(target, anchor) {
15065      if (if_block0) if_block0.m(target, anchor);
15066      insert(target, t0, anchor);
15067      insert(target, div, anchor);
15068      if (if_block1) if_block1.m(div, null);
15069      append(div, t1);
15070      if (if_block2) if_block2.m(div, null);
15071      insert(target, t2, anchor);
15072      if (~current_block_type_index) {
15073        if_blocks[current_block_type_index].m(target, anchor);
15074      }
15075      insert(target, t3, anchor);
15076      if (if_block4) if_block4.m(target, anchor);
15077      insert(target, if_block4_anchor, anchor);
15078      current = true;
15079    },
15080    p(ctx2, dirty) {
15081      if (
15082        /*variant*/
15083        ctx2[9] === "default" && /*show_eta_bar*/
15084        ctx2[20] && /*show_progress*/
15085        ctx2[7] === "full"
15086      ) {
15087        if (if_block0) {
15088          if_block0.p(ctx2, dirty);
15089        } else {
15090          if_block0 = create_if_block_16(ctx2);
15091          if_block0.c();
15092          if_block0.m(t0.parentNode, t0);
15093        }
15094      } else if (if_block0) {
15095        if_block0.d(1);
15096        if_block0 = null;
15097      }
15098      if (current_block_type === (current_block_type = select_block_type_1(ctx2)) && if_block1) {
15099        if_block1.p(ctx2, dirty);
15100      } else {
15101        if (if_block1) if_block1.d(1);
15102        if_block1 = current_block_type && current_block_type(ctx2);
15103        if (if_block1) {
15104          if_block1.c();
15105          if_block1.m(div, t1);
15106        }
15107      }
15108      if (
15109        /*timer*/
15110        ctx2[6]
15111      ) {
15112        if (if_block2) {
15113          if_block2.p(ctx2, dirty);
15114        } else {
15115          if_block2 = create_if_block_10$1(ctx2);
15116          if_block2.c();
15117          if_block2.m(div, null);
15118        }
15119      } else if (if_block2) {
15120        if_block2.d(1);
15121        if_block2 = null;
15122      }
15123      if (!current || dirty[0] & /*variant*/
15124      512) {
15125        toggle_class(
15126          div,
15127          "meta-text-center",
15128          /*variant*/
15129          ctx2[9] === "center"
15130        );
15131      }
15132      if (!current || dirty[0] & /*variant*/
15133      512) {
15134        toggle_class(
15135          div,
15136          "meta-text",
15137          /*variant*/
15138          ctx2[9] === "default"
15139        );
15140      }
15141      let previous_block_index = current_block_type_index;
15142      current_block_type_index = select_block_type_3(ctx2);
15143      if (current_block_type_index === previous_block_index) {
15144        if (~current_block_type_index) {
15145          if_blocks[current_block_type_index].p(ctx2, dirty);
15146        }
15147      } else {
15148        if (if_block3) {
15149          group_outros();
15150          transition_out(if_blocks[previous_block_index], 1, 1, () => {
15151            if_blocks[previous_block_index] = null;
15152          });
15153          check_outros();
15154        }
15155        if (~current_block_type_index) {
15156          if_block3 = if_blocks[current_block_type_index];
15157          if (!if_block3) {
15158            if_block3 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
15159            if_block3.c();
15160          } else {
15161            if_block3.p(ctx2, dirty);
15162          }
15163          transition_in(if_block3, 1);
15164          if_block3.m(t3.parentNode, t3);
15165        } else {
15166          if_block3 = null;
15167        }
15168      }
15169      if (!/*timer*/
15170      ctx2[6]) {
15171        if (if_block4) {
15172          if_block4.p(ctx2, dirty);
15173          if (dirty[0] & /*timer*/
15174          64) {
15175            transition_in(if_block4, 1);
15176          }
15177        } else {
15178          if_block4 = create_if_block_1$b(ctx2);
15179          if_block4.c();
15180          transition_in(if_block4, 1);
15181          if_block4.m(if_block4_anchor.parentNode, if_block4_anchor);
15182        }
15183      } else if (if_block4) {
15184        group_outros();
15185        transition_out(if_block4, 1, 1, () => {
15186          if_block4 = null;
15187        });
15188        check_outros();
15189      }
15190    },
15191    i(local) {
15192      if (current) return;
15193      transition_in(if_block3);
15194      transition_in(if_block4);
15195      current = true;
15196    },
15197    o(local) {
15198      transition_out(if_block3);
15199      transition_out(if_block4);
15200      current = false;
15201    },
15202    d(detaching) {
15203      if (detaching) {
15204        detach(t0);
15205        detach(div);
15206        detach(t2);
15207        detach(t3);
15208        detach(if_block4_anchor);
15209      }
15210      if (if_block0) if_block0.d(detaching);
15211      if (if_block1) {
15212        if_block1.d();
15213      }
15214      if (if_block2) if_block2.d();
15215      if (~current_block_type_index) {
15216        if_blocks[current_block_type_index].d(detaching);
15217      }
15218      if (if_block4) if_block4.d(detaching);
15219    }
15220  };
15221}
15222function create_if_block_16(ctx) {
15223  let div;
15224  let style_transform = `translateX(${/*eta_level*/
15225  (ctx[19] || 0) * 100 - 100}%)`;
15226  return {
15227    c() {
15228      div = element("div");
15229      attr(div, "class", "eta-bar svelte-vusapu");
15230      set_style(div, "transform", style_transform);
15231    },
15232    m(target, anchor) {
15233      insert(target, div, anchor);
15234    },
15235    p(ctx2, dirty) {
15236      if (dirty[0] & /*eta_level*/
15237      524288 && style_transform !== (style_transform = `translateX(${/*eta_level*/
15238      (ctx2[19] || 0) * 100 - 100}%)`)) {
15239        set_style(div, "transform", style_transform);
15240      }
15241    },
15242    d(detaching) {
15243      if (detaching) {
15244        detach(div);
15245      }
15246    }
15247  };
15248}
15249function create_if_block_15(ctx) {
15250  let t;
15251  return {
15252    c() {
15253      t = text("processing |");
15254    },
15255    m(target, anchor) {
15256      insert(target, t, anchor);
15257    },
15258    p: noop,
15259    d(detaching) {
15260      if (detaching) {
15261        detach(t);
15262      }
15263    }
15264  };
15265}
15266function create_if_block_14(ctx) {
15267  let t0;
15268  let t1_value = (
15269    /*queue_position*/
15270    ctx[3] + 1 + ""
15271  );
15272  let t1;
15273  let t2;
15274  let t3;
15275  let t4;
15276  return {
15277    c() {
15278      t0 = text("queue: ");
15279      t1 = text(t1_value);
15280      t2 = text("/");
15281      t3 = text(
15282        /*queue_size*/
15283        ctx[4]
15284      );
15285      t4 = text(" |");
15286    },
15287    m(target, anchor) {
15288      insert(target, t0, anchor);
15289      insert(target, t1, anchor);
15290      insert(target, t2, anchor);
15291      insert(target, t3, anchor);
15292      insert(target, t4, anchor);
15293    },
15294    p(ctx2, dirty) {
15295      if (dirty[0] & /*queue_position*/
15296      8 && t1_value !== (t1_value = /*queue_position*/
15297      ctx2[3] + 1 + "")) set_data(t1, t1_value);
15298      if (dirty[0] & /*queue_size*/
15299      16) set_data(
15300        t3,
15301        /*queue_size*/
15302        ctx2[4]
15303      );
15304    },
15305    d(detaching) {
15306      if (detaching) {
15307        detach(t0);
15308        detach(t1);
15309        detach(t2);
15310        detach(t3);
15311        detach(t4);
15312      }
15313    }
15314  };
15315}
15316function create_if_block_11(ctx) {
15317  let each_1_anchor;
15318  let each_value_1 = ensure_array_like(
15319    /*progress*/
15320    ctx[8]
15321  );
15322  let each_blocks = [];
15323  for (let i = 0; i < each_value_1.length; i += 1) {
15324    each_blocks[i] = create_each_block_1$1(get_each_context_1$1(ctx, each_value_1, i));
15325  }
15326  return {
15327    c() {
15328      for (let i = 0; i < each_blocks.length; i += 1) {
15329        each_blocks[i].c();
15330      }
15331      each_1_anchor = empty();
15332    },
15333    m(target, anchor) {
15334      for (let i = 0; i < each_blocks.length; i += 1) {
15335        if (each_blocks[i]) {
15336          each_blocks[i].m(target, anchor);
15337        }
15338      }
15339      insert(target, each_1_anchor, anchor);
15340    },
15341    p(ctx2, dirty) {
15342      if (dirty[0] & /*progress*/
15343      256) {
15344        each_value_1 = ensure_array_like(
15345          /*progress*/
15346          ctx2[8]
15347        );
15348        let i;
15349        for (i = 0; i < each_value_1.length; i += 1) {
15350          const child_ctx = get_each_context_1$1(ctx2, each_value_1, i);
15351          if (each_blocks[i]) {
15352            each_blocks[i].p(child_ctx, dirty);
15353          } else {
15354            each_blocks[i] = create_each_block_1$1(child_ctx);
15355            each_blocks[i].c();
15356            each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
15357          }
15358        }
15359        for (; i < each_blocks.length; i += 1) {
15360          each_blocks[i].d(1);
15361        }
15362        each_blocks.length = each_value_1.length;
15363      }
15364    },
15365    d(detaching) {
15366      if (detaching) {
15367        detach(each_1_anchor);
15368      }
15369      destroy_each(each_blocks, detaching);
15370    }
15371  };
15372}
15373function create_if_block_12(ctx) {
15374  let t0;
15375  let t1_value = (
15376    /*p*/
15377    ctx[43].unit + ""
15378  );
15379  let t1;
15380  let t2;
15381  let t3_value = " ";
15382  let t3;
15383  function select_block_type_2(ctx2, dirty) {
15384    if (
15385      /*p*/
15386      ctx2[43].length != null
15387    ) return create_if_block_13;
15388    return create_else_block$6;
15389  }
15390  let current_block_type = select_block_type_2(ctx);
15391  let if_block = current_block_type(ctx);
15392  return {
15393    c() {
15394      if_block.c();
15395      t0 = space();
15396      t1 = text(t1_value);
15397      t2 = text(" | ");
15398      t3 = text(t3_value);
15399    },
15400    m(target, anchor) {
15401      if_block.m(target, anchor);
15402      insert(target, t0, anchor);
15403      insert(target, t1, anchor);
15404      insert(target, t2, anchor);
15405      insert(target, t3, anchor);
15406    },
15407    p(ctx2, dirty) {
15408      if (current_block_type === (current_block_type = select_block_type_2(ctx2)) && if_block) {
15409        if_block.p(ctx2, dirty);
15410      } else {
15411        if_block.d(1);
15412        if_block = current_block_type(ctx2);
15413        if (if_block) {
15414          if_block.c();
15415          if_block.m(t0.parentNode, t0);
15416        }
15417      }
15418      if (dirty[0] & /*progress*/
15419      256 && t1_value !== (t1_value = /*p*/
15420      ctx2[43].unit + "")) set_data(t1, t1_value);
15421    },
15422    d(detaching) {
15423      if (detaching) {
15424        detach(t0);
15425        detach(t1);
15426        detach(t2);
15427        detach(t3);
15428      }
15429      if_block.d(detaching);
15430    }
15431  };
15432}
15433function create_else_block$6(ctx) {
15434  let t_value = pretty_si(
15435    /*p*/
15436    ctx[43].index || 0
15437  ) + "";
15438  let t;
15439  return {
15440    c() {
15441      t = text(t_value);
15442    },
15443    m(target, anchor) {
15444      insert(target, t, anchor);
15445    },
15446    p(ctx2, dirty) {
15447      if (dirty[0] & /*progress*/
15448      256 && t_value !== (t_value = pretty_si(
15449        /*p*/
15450        ctx2[43].index || 0
15451      ) + "")) set_data(t, t_value);
15452    },
15453    d(detaching) {
15454      if (detaching) {
15455        detach(t);
15456      }
15457    }
15458  };
15459}
15460function create_if_block_13(ctx) {
15461  let t0_value = pretty_si(
15462    /*p*/
15463    ctx[43].index || 0
15464  ) + "";
15465  let t0;
15466  let t1;
15467  let t2_value = pretty_si(
15468    /*p*/
15469    ctx[43].length
15470  ) + "";
15471  let t2;
15472  return {
15473    c() {
15474      t0 = text(t0_value);
15475      t1 = text("/");
15476      t2 = text(t2_value);
15477    },
15478    m(target, anchor) {
15479      insert(target, t0, anchor);
15480      insert(target, t1, anchor);
15481      insert(target, t2, anchor);
15482    },
15483    p(ctx2, dirty) {
15484      if (dirty[0] & /*progress*/
15485      256 && t0_value !== (t0_value = pretty_si(
15486        /*p*/
15487        ctx2[43].index || 0
15488      ) + "")) set_data(t0, t0_value);
15489      if (dirty[0] & /*progress*/
15490      256 && t2_value !== (t2_value = pretty_si(
15491        /*p*/
15492        ctx2[43].length
15493      ) + "")) set_data(t2, t2_value);
15494    },
15495    d(detaching) {
15496      if (detaching) {
15497        detach(t0);
15498        detach(t1);
15499        detach(t2);
15500      }
15501    }
15502  };
15503}
15504function create_each_block_1$1(ctx) {
15505  let if_block_anchor;
15506  let if_block = (
15507    /*p*/
15508    ctx[43].index != null && create_if_block_12(ctx)
15509  );
15510  return {
15511    c() {
15512      if (if_block) if_block.c();
15513      if_block_anchor = empty();
15514    },
15515    m(target, anchor) {
15516      if (if_block) if_block.m(target, anchor);
15517      insert(target, if_block_anchor, anchor);
15518    },
15519    p(ctx2, dirty) {
15520      if (
15521        /*p*/
15522        ctx2[43].index != null
15523      ) {
15524        if (if_block) {
15525          if_block.p(ctx2, dirty);
15526        } else {
15527          if_block = create_if_block_12(ctx2);
15528          if_block.c();
15529          if_block.m(if_block_anchor.parentNode, if_block_anchor);
15530        }
15531      } else if (if_block) {
15532        if_block.d(1);
15533        if_block = null;
15534      }
15535    },
15536    d(detaching) {
15537      if (detaching) {
15538        detach(if_block_anchor);
15539      }
15540      if (if_block) if_block.d(detaching);
15541    }
15542  };
15543}
15544function create_if_block_10$1(ctx) {
15545  let t0;
15546  let t1_value = (
15547    /*eta*/
15548    ctx[0] ? `/${/*formatted_eta*/
15549    ctx[21]}` : ""
15550  );
15551  let t1;
15552  let t2;
15553  return {
15554    c() {
15555      t0 = text(
15556        /*formatted_timer*/
15557        ctx[22]
15558      );
15559      t1 = text(t1_value);
15560      t2 = text("s");
15561    },
15562    m(target, anchor) {
15563      insert(target, t0, anchor);
15564      insert(target, t1, anchor);
15565      insert(target, t2, anchor);
15566    },
15567    p(ctx2, dirty) {
15568      if (dirty[0] & /*formatted_timer*/
15569      4194304) set_data(
15570        t0,
15571        /*formatted_timer*/
15572        ctx2[22]
15573      );
15574      if (dirty[0] & /*eta, formatted_eta*/
15575      2097153 && t1_value !== (t1_value = /*eta*/
15576      ctx2[0] ? `/${/*formatted_eta*/
15577      ctx2[21]}` : "")) set_data(t1, t1_value);
15578    },
15579    d(detaching) {
15580      if (detaching) {
15581        detach(t0);
15582        detach(t1);
15583        detach(t2);
15584      }
15585    }
15586  };
15587}
15588function create_if_block_9$2(ctx) {
15589  let loader;
15590  let current;
15591  loader = new Loader({
15592    props: { margin: (
15593      /*variant*/
15594      ctx[9] === "default"
15595    ) }
15596  });
15597  return {
15598    c() {
15599      create_component(loader.$$.fragment);
15600    },
15601    m(target, anchor) {
15602      mount_component(loader, target, anchor);
15603      current = true;
15604    },
15605    p(ctx2, dirty) {
15606      const loader_changes = {};
15607      if (dirty[0] & /*variant*/
15608      512) loader_changes.margin = /*variant*/
15609      ctx2[9] === "default";
15610      loader.$set(loader_changes);
15611    },
15612    i(local) {
15613      if (current) return;
15614      transition_in(loader.$$.fragment, local);
15615      current = true;
15616    },
15617    o(local) {
15618      transition_out(loader.$$.fragment, local);
15619      current = false;
15620    },
15621    d(detaching) {
15622      destroy_component(loader, detaching);
15623    }
15624  };
15625}
15626function create_if_block_2$a(ctx) {
15627  let div3;
15628  let div0;
15629  let t;
15630  let div2;
15631  let div1;
15632  let style_width = `${/*last_progress_level*/
15633  ctx[17] * 100}%`;
15634  let if_block = (
15635    /*progress*/
15636    ctx[8] != null && create_if_block_3$9(ctx)
15637  );
15638  return {
15639    c() {
15640      div3 = element("div");
15641      div0 = element("div");
15642      if (if_block) if_block.c();
15643      t = space();
15644      div2 = element("div");
15645      div1 = element("div");
15646      attr(div0, "class", "progress-level-inner svelte-vusapu");
15647      attr(div1, "class", "progress-bar svelte-vusapu");
15648      set_style(div1, "width", style_width);
15649      attr(div2, "class", "progress-bar-wrap svelte-vusapu");
15650      attr(div3, "class", "progress-level svelte-vusapu");
15651    },
15652    m(target, anchor) {
15653      insert(target, div3, anchor);
15654      append(div3, div0);
15655      if (if_block) if_block.m(div0, null);
15656      append(div3, t);
15657      append(div3, div2);
15658      append(div2, div1);
15659      ctx[34](div1);
15660    },
15661    p(ctx2, dirty) {
15662      if (
15663        /*progress*/
15664        ctx2[8] != null
15665      ) {
15666        if (if_block) {
15667          if_block.p(ctx2, dirty);
15668        } else {
15669          if_block = create_if_block_3$9(ctx2);
15670          if_block.c();
15671          if_block.m(div0, null);
15672        }
15673      } else if (if_block) {
15674        if_block.d(1);
15675        if_block = null;
15676      }
15677      if (dirty[0] & /*last_progress_level*/
15678      131072 && style_width !== (style_width = `${/*last_progress_level*/
15679      ctx2[17] * 100}%`)) {
15680        set_style(div1, "width", style_width);
15681      }
15682    },
15683    i: noop,
15684    o: noop,
15685    d(detaching) {
15686      if (detaching) {
15687        detach(div3);
15688      }
15689      if (if_block) if_block.d();
15690      ctx[34](null);
15691    }
15692  };
15693}
15694function create_if_block_3$9(ctx) {
15695  let each_1_anchor;
15696  let each_value = ensure_array_like(
15697    /*progress*/
15698    ctx[8]
15699  );
15700  let each_blocks = [];
15701  for (let i = 0; i < each_value.length; i += 1) {
15702    each_blocks[i] = create_each_block$4(get_each_context$4(ctx, each_value, i));
15703  }
15704  return {
15705    c() {
15706      for (let i = 0; i < each_blocks.length; i += 1) {
15707        each_blocks[i].c();
15708      }
15709      each_1_anchor = empty();
15710    },
15711    m(target, anchor) {
15712      for (let i = 0; i < each_blocks.length; i += 1) {
15713        if (each_blocks[i]) {
15714          each_blocks[i].m(target, anchor);
15715        }
15716      }
15717      insert(target, each_1_anchor, anchor);
15718    },
15719    p(ctx2, dirty) {
15720      if (dirty[0] & /*progress_level, progress*/
15721      65792) {
15722        each_value = ensure_array_like(
15723          /*progress*/
15724          ctx2[8]
15725        );
15726        let i;
15727        for (i = 0; i < each_value.length; i += 1) {
15728          const child_ctx = get_each_context$4(ctx2, each_value, i);
15729          if (each_blocks[i]) {
15730            each_blocks[i].p(child_ctx, dirty);
15731          } else {
15732            each_blocks[i] = create_each_block$4(child_ctx);
15733            each_blocks[i].c();
15734            each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
15735          }
15736        }
15737        for (; i < each_blocks.length; i += 1) {
15738          each_blocks[i].d(1);
15739        }
15740        each_blocks.length = each_value.length;
15741      }
15742    },
15743    d(detaching) {
15744      if (detaching) {
15745        detach(each_1_anchor);
15746      }
15747      destroy_each(each_blocks, detaching);
15748    }
15749  };
15750}
15751function create_if_block_4$7(ctx) {
15752  let t0;
15753  let t1;
15754  let t2;
15755  let if_block3_anchor;
15756  let if_block0 = (
15757    /*i*/
15758    ctx[45] !== 0 && create_if_block_8$3()
15759  );
15760  let if_block1 = (
15761    /*p*/
15762    ctx[43].desc != null && create_if_block_7$3(ctx)
15763  );
15764  let if_block2 = (
15765    /*p*/
15766    ctx[43].desc != null && /*progress_level*/
15767    ctx[16] && /*progress_level*/
15768    ctx[16][
15769      /*i*/
15770      ctx[45]
15771    ] != null && create_if_block_6$6()
15772  );
15773  let if_block3 = (
15774    /*progress_level*/
15775    ctx[16] != null && create_if_block_5$7(ctx)
15776  );
15777  return {
15778    c() {
15779      if (if_block0) if_block0.c();
15780      t0 = space();
15781      if (if_block1) if_block1.c();
15782      t1 = space();
15783      if (if_block2) if_block2.c();
15784      t2 = space();
15785      if (if_block3) if_block3.c();
15786      if_block3_anchor = empty();
15787    },
15788    m(target, anchor) {
15789      if (if_block0) if_block0.m(target, anchor);
15790      insert(target, t0, anchor);
15791      if (if_block1) if_block1.m(target, anchor);
15792      insert(target, t1, anchor);
15793      if (if_block2) if_block2.m(target, anchor);
15794      insert(target, t2, anchor);
15795      if (if_block3) if_block3.m(target, anchor);
15796      insert(target, if_block3_anchor, anchor);
15797    },
15798    p(ctx2, dirty) {
15799      if (
15800        /*p*/
15801        ctx2[43].desc != null
15802      ) {
15803        if (if_block1) {
15804          if_block1.p(ctx2, dirty);
15805        } else {
15806          if_block1 = create_if_block_7$3(ctx2);
15807          if_block1.c();
15808          if_block1.m(t1.parentNode, t1);
15809        }
15810      } else if (if_block1) {
15811        if_block1.d(1);
15812        if_block1 = null;
15813      }
15814      if (
15815        /*p*/
15816        ctx2[43].desc != null && /*progress_level*/
15817        ctx2[16] && /*progress_level*/
15818        ctx2[16][
15819          /*i*/
15820          ctx2[45]
15821        ] != null
15822      ) {
15823        if (if_block2) ;
15824        else {
15825          if_block2 = create_if_block_6$6();
15826          if_block2.c();
15827          if_block2.m(t2.parentNode, t2);
15828        }
15829      } else if (if_block2) {
15830        if_block2.d(1);
15831        if_block2 = null;
15832      }
15833      if (
15834        /*progress_level*/
15835        ctx2[16] != null
15836      ) {
15837        if (if_block3) {
15838          if_block3.p(ctx2, dirty);
15839        } else {
15840          if_block3 = create_if_block_5$7(ctx2);
15841          if_block3.c();
15842          if_block3.m(if_block3_anchor.parentNode, if_block3_anchor);
15843        }
15844      } else if (if_block3) {
15845        if_block3.d(1);
15846        if_block3 = null;
15847      }
15848    },
15849    d(detaching) {
15850      if (detaching) {
15851        detach(t0);
15852        detach(t1);
15853        detach(t2);
15854        detach(if_block3_anchor);
15855      }
15856      if (if_block0) if_block0.d(detaching);
15857      if (if_block1) if_block1.d(detaching);
15858      if (if_block2) if_block2.d(detaching);
15859      if (if_block3) if_block3.d(detaching);
15860    }
15861  };
15862}
15863function create_if_block_8$3(ctx) {
15864  let t;
15865  return {
15866    c() {
15867      t = text(" /");
15868    },
15869    m(target, anchor) {
15870      insert(target, t, anchor);
15871    },
15872    d(detaching) {
15873      if (detaching) {
15874        detach(t);
15875      }
15876    }
15877  };
15878}
15879function create_if_block_7$3(ctx) {
15880  let t_value = (
15881    /*p*/
15882    ctx[43].desc + ""
15883  );
15884  let t;
15885  return {
15886    c() {
15887      t = text(t_value);
15888    },
15889    m(target, anchor) {
15890      insert(target, t, anchor);
15891    },
15892    p(ctx2, dirty) {
15893      if (dirty[0] & /*progress*/
15894      256 && t_value !== (t_value = /*p*/
15895      ctx2[43].desc + "")) set_data(t, t_value);
15896    },
15897    d(detaching) {
15898      if (detaching) {
15899        detach(t);
15900      }
15901    }
15902  };
15903}
15904function create_if_block_6$6(ctx) {
15905  let t;
15906  return {
15907    c() {
15908      t = text("-");
15909    },
15910    m(target, anchor) {
15911      insert(target, t, anchor);
15912    },
15913    d(detaching) {
15914      if (detaching) {
15915        detach(t);
15916      }
15917    }
15918  };
15919}
15920function create_if_block_5$7(ctx) {
15921  let t0_value = (100 * /*progress_level*/
15922  (ctx[16][
15923    /*i*/
15924    ctx[45]
15925  ] || 0)).toFixed(1) + "";
15926  let t0;
15927  let t1;
15928  return {
15929    c() {
15930      t0 = text(t0_value);
15931      t1 = text("%");
15932    },
15933    m(target, anchor) {
15934      insert(target, t0, anchor);
15935      insert(target, t1, anchor);
15936    },
15937    p(ctx2, dirty) {
15938      if (dirty[0] & /*progress_level*/
15939      65536 && t0_value !== (t0_value = (100 * /*progress_level*/
15940      (ctx2[16][
15941        /*i*/
15942        ctx2[45]
15943      ] || 0)).toFixed(1) + "")) set_data(t0, t0_value);
15944    },
15945    d(detaching) {
15946      if (detaching) {
15947        detach(t0);
15948        detach(t1);
15949      }
15950    }
15951  };
15952}
15953function create_each_block$4(ctx) {
15954  let if_block_anchor;
15955  let if_block = (
15956    /*p*/
15957    (ctx[43].desc != null || /*progress_level*/
15958    ctx[16] && /*progress_level*/
15959    ctx[16][
15960      /*i*/
15961      ctx[45]
15962    ] != null) && create_if_block_4$7(ctx)
15963  );
15964  return {
15965    c() {
15966      if (if_block) if_block.c();
15967      if_block_anchor = empty();
15968    },
15969    m(target, anchor) {
15970      if (if_block) if_block.m(target, anchor);
15971      insert(target, if_block_anchor, anchor);
15972    },
15973    p(ctx2, dirty) {
15974      if (
15975        /*p*/
15976        ctx2[43].desc != null || /*progress_level*/
15977        ctx2[16] && /*progress_level*/
15978        ctx2[16][
15979          /*i*/
15980          ctx2[45]
15981        ] != null
15982      ) {
15983        if (if_block) {
15984          if_block.p(ctx2, dirty);
15985        } else {
15986          if_block = create_if_block_4$7(ctx2);
15987          if_block.c();
15988          if_block.m(if_block_anchor.parentNode, if_block_anchor);
15989        }
15990      } else if (if_block) {
15991        if_block.d(1);
15992        if_block = null;
15993      }
15994    },
15995    d(detaching) {
15996      if (detaching) {
15997        detach(if_block_anchor);
15998      }
15999      if (if_block) if_block.d(detaching);
16000    }
16001  };
16002}
16003function create_if_block_1$b(ctx) {
16004  let p_1;
16005  let t0;
16006  let t1;
16007  let current;
16008  const additional_loading_text_slot_template = (
16009    /*#slots*/
16010    ctx[32]["additional-loading-text"]
16011  );
16012  const additional_loading_text_slot = create_slot(
16013    additional_loading_text_slot_template,
16014    ctx,
16015    /*$$scope*/
16016    ctx[31],
16017    get_additional_loading_text_slot_context
16018  );
16019  return {
16020    c() {
16021      p_1 = element("p");
16022      t0 = text(
16023        /*loading_text*/
16024        ctx[10]
16025      );
16026      t1 = space();
16027      if (additional_loading_text_slot) additional_loading_text_slot.c();
16028      attr(p_1, "class", "loading svelte-vusapu");
16029    },
16030    m(target, anchor) {
16031      insert(target, p_1, anchor);
16032      append(p_1, t0);
16033      insert(target, t1, anchor);
16034      if (additional_loading_text_slot) {
16035        additional_loading_text_slot.m(target, anchor);
16036      }
16037      current = true;
16038    },
16039    p(ctx2, dirty) {
16040      if (!current || dirty[0] & /*loading_text*/
16041      1024) set_data(
16042        t0,
16043        /*loading_text*/
16044        ctx2[10]
16045      );
16046      if (additional_loading_text_slot) {
16047        if (additional_loading_text_slot.p && (!current || dirty[1] & /*$$scope*/
16048        1)) {
16049          update_slot_base(
16050            additional_loading_text_slot,
16051            additional_loading_text_slot_template,
16052            ctx2,
16053            /*$$scope*/
16054            ctx2[31],
16055            !current ? get_all_dirty_from_scope(
16056              /*$$scope*/
16057              ctx2[31]
16058            ) : get_slot_changes(
16059              additional_loading_text_slot_template,
16060              /*$$scope*/
16061              ctx2[31],
16062              dirty,
16063              get_additional_loading_text_slot_changes
16064            ),
16065            get_additional_loading_text_slot_context
16066          );
16067        }
16068      }
16069    },
16070    i(local) {
16071      if (current) return;
16072      transition_in(additional_loading_text_slot, local);
16073      current = true;
16074    },
16075    o(local) {
16076      transition_out(additional_loading_text_slot, local);
16077      current = false;
16078    },
16079    d(detaching) {
16080      if (detaching) {
16081        detach(p_1);
16082        detach(t1);
16083      }
16084      if (additional_loading_text_slot) additional_loading_text_slot.d(detaching);
16085    }
16086  };
16087}
16088function create_fragment$q(ctx) {
16089  let div;
16090  let t;
16091  let current_block_type_index;
16092  let if_block1;
16093  let div_class_value;
16094  let current;
16095  let if_block0 = (
16096    /*validation_error*/
16097    ctx[1] && /*show_validation_error*/
16098    ctx[14] && create_if_block_18(ctx)
16099  );
16100  const if_block_creators = [create_if_block$f, create_if_block_17];
16101  const if_blocks = [];
16102  function select_block_type(ctx2, dirty) {
16103    if (
16104      /*status*/
16105      ctx2[5] === "pending"
16106    ) return 0;
16107    if (
16108      /*status*/
16109      ctx2[5] === "error"
16110    ) return 1;
16111    return -1;
16112  }
16113  if (~(current_block_type_index = select_block_type(ctx))) {
16114    if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
16115  }
16116  return {
16117    c() {
16118      div = element("div");
16119      if (if_block0) if_block0.c();
16120      t = space();
16121      if (if_block1) if_block1.c();
16122      attr(div, "class", div_class_value = "wrap " + /*variant*/
16123      ctx[9] + " " + /*show_progress*/
16124      ctx[7] + " svelte-vusapu");
16125      toggle_class(div, "hide", (!/*status*/
16126      ctx[5] || /*status*/
16127      ctx[5] === "complete" || /*show_progress*/
16128      ctx[7] === "hidden" || /*status*/
16129      ctx[5] == "streaming") && !/*validation_error*/
16130      ctx[1]);
16131      toggle_class(
16132        div,
16133        "translucent",
16134        /*variant*/
16135        ctx[9] === "center" && /*status*/
16136        (ctx[5] === "pending" || /*status*/
16137        ctx[5] === "error") || /*translucent*/
16138        ctx[12] || /*show_progress*/
16139        ctx[7] === "minimal" || /*validation_error*/
16140        ctx[1]
16141      );
16142      toggle_class(
16143        div,
16144        "generating",
16145        /*status*/
16146        ctx[5] === "generating" && /*show_progress*/
16147        ctx[7] === "full"
16148      );
16149      toggle_class(
16150        div,
16151        "border",
16152        /*border*/
16153        ctx[13]
16154      );
16155      set_style(
16156        div,
16157        "position",
16158        /*absolute*/
16159        ctx[11] ? "absolute" : "static"
16160      );
16161      set_style(
16162        div,
16163        "padding",
16164        /*absolute*/
16165        ctx[11] ? "0" : "var(--size-8) 0"
16166      );
16167    },
16168    m(target, anchor) {
16169      insert(target, div, anchor);
16170      if (if_block0) if_block0.m(div, null);
16171      append(div, t);
16172      if (~current_block_type_index) {
16173        if_blocks[current_block_type_index].m(div, null);
16174      }
16175      ctx[36](div);
16176      current = true;
16177    },
16178    p(ctx2, dirty) {
16179      if (
16180        /*validation_error*/
16181        ctx2[1] && /*show_validation_error*/
16182        ctx2[14]
16183      ) {
16184        if (if_block0) {
16185          if_block0.p(ctx2, dirty);
16186          if (dirty[0] & /*validation_error, show_validation_error*/
16187          16386) {
16188            transition_in(if_block0, 1);
16189          }
16190        } else {
16191          if_block0 = create_if_block_18(ctx2);
16192          if_block0.c();
16193          transition_in(if_block0, 1);
16194          if_block0.m(div, t);
16195        }
16196      } else if (if_block0) {
16197        group_outros();
16198        transition_out(if_block0, 1, 1, () => {
16199          if_block0 = null;
16200        });
16201        check_outros();
16202      }
16203      let previous_block_index = current_block_type_index;
16204      current_block_type_index = select_block_type(ctx2);
16205      if (current_block_type_index === previous_block_index) {
16206        if (~current_block_type_index) {
16207          if_blocks[current_block_type_index].p(ctx2, dirty);
16208        }
16209      } else {
16210        if (if_block1) {
16211          group_outros();
16212          transition_out(if_blocks[previous_block_index], 1, 1, () => {
16213            if_blocks[previous_block_index] = null;
16214          });
16215          check_outros();
16216        }
16217        if (~current_block_type_index) {
16218          if_block1 = if_blocks[current_block_type_index];
16219          if (!if_block1) {
16220            if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
16221            if_block1.c();
16222          } else {
16223            if_block1.p(ctx2, dirty);
16224          }
16225          transition_in(if_block1, 1);
16226          if_block1.m(div, null);
16227        } else {
16228          if_block1 = null;
16229        }
16230      }
16231      if (!current || dirty[0] & /*variant, show_progress*/
16232      640 && div_class_value !== (div_class_value = "wrap " + /*variant*/
16233      ctx2[9] + " " + /*show_progress*/
16234      ctx2[7] + " svelte-vusapu")) {
16235        attr(div, "class", div_class_value);
16236      }
16237      if (!current || dirty[0] & /*variant, show_progress, status, show_progress, val
16237idation_error*/
16238      674) {
16239        toggle_class(div, "hide", (!/*status*/
16240        ctx2[5] || /*status*/
16241        ctx2[5] === "complete" || /*show_progress*/
16242        ctx2[7] === "hidden" || /*status*/
16243        ctx2[5] == "streaming") && !/*validation_error*/
16244        ctx2[1]);
16245      }
16246      if (!current || dirty[0] & /*variant, show_progress, variant, status, translucent, show_progress, validation_error*/
16247      4770) {
16248        toggle_class(
16249          div,
16250          "translucent",
16251          /*variant*/
16252          ctx2[9] === "center" && /*status*/
16253          (ctx2[5] === "pending" || /*status*/
16254          ctx2[5] === "error") || /*translucent*/
16255          ctx2[12] || /*show_progress*/
16256          ctx2[7] === "minimal" || /*validation_error*/
16257          ctx2[1]
16258        );
16259      }
16260      if (!current || dirty[0] & /*variant, show_progress, status, show_progress*/
16261      672) {
16262        toggle_class(
16263          div,
16264          "generating",
16265          /*status*/
16266          ctx2[5] === "generating" && /*show_progress*/
16267          ctx2[7] === "full"
16268        );
16269      }
16270      if (!current || dirty[0] & /*variant, show_progress, border*/
16271      8832) {
16272        toggle_class(
16273          div,
16274          "border",
16275          /*border*/
16276          ctx2[13]
16277        );
16278      }
16279      if (dirty[0] & /*absolute*/
16280      2048) {
16281        set_style(
16282          div,
16283          "position",
16284          /*absolute*/
16285          ctx2[11] ? "absolute" : "static"
16286        );
16287      }
16288      if (dirty[0] & /*absolute*/
16289      2048) {
16290        set_style(
16291          div,
16292          "padding",
16293          /*absolute*/
16294          ctx2[11] ? "0" : "var(--size-8) 0"
16295        );
16296      }
16297    },
16298    i(local) {
16299      if (current) return;
16300      transition_in(if_block0);
16301      transition_in(if_block1);
16302      current = true;
16303    },
16304    o(local) {
16305      transition_out(if_block0);
16306      transition_out(if_block1);
16307      current = false;
16308    },
16309    d(detaching) {
16310      if (detaching) {
16311        detach(div);
16312      }
16313      if (if_block0) if_block0.d();
16314      if (~current_block_type_index) {
16315        if_blocks[current_block_type_index].d();
16316      }
16317      ctx[36](null);
16318    }
16319  };
16320}
16321let items = [];
16322let called = false;
16323const is_browser = typeof window !== "undefined";
16324const raf = is_browser ? window.requestAnimationFrame : (cb) => {
16325};
16326async function scroll_into_view(el, enable = true) {
16327  if (window.__gradio_mode__ === "website" || window.__gradio_mode__ !== "app" && enable !== true) {
16328    return;
16329  }
16330  items.push(el);
16331  if (!called) called = true;
16332  else return;
16333  await tick();
16334  raf(() => {
16335    let min = [0, 0];
16336    for (let i = 0; i < items.length; i++) {
16337      const element2 = items[i];
16338      const box = element2.getBoundingClientRect();
16339      if (i === 0 || box.top + window.scrollY <= min[0]) {
16340        min[0] = box.top + window.scrollY;
16341        min[1] = i;
16342      }
16343    }
16344    window.scrollTo({ top: min[0] - 20, behavior: "smooth" });
16345    called = false;
16346    items = [];
16347  });
16348}
16349function instance$p($$self, $$props, $$invalidate) {
16350  let formatted_timer;
16351  let { $$slots: slots = {}, $$scope } = $$props;
16352  const dispatch2 = createEventDispatcher();
16353  let { i18n } = $$props;
16354  let { eta = null } = $$props;
16355  let { queue_position } = $$props;
16356  let { queue_size } = $$props;
16357  let { status } = $$props;
16358  let { scroll_to_output = false } = $$props;
16359  let { timer = true } = $$props;
16360  let { show_progress = "full" } = $$props;
16361  let { message = null } = $$props;
16362  let { progress = null } = $$props;
16363  let { variant = "default" } = $$props;
16364  let { loading_text = "Loading..." } = $$props;
16365  let { absolute = true } = $$props;
16366  let { translucent = false } = $$props;
16367  let { border = false } = $$props;
16368  let { autoscroll } = $$props;
16369  let { validation_error = null } = $$props;
16370  let { show_validation_error = true } = $$props;
16371  let el;
16372  let _timer = false;
16373  let timer_start = 0;
16374  let timer_diff = 0;
16375  let old_eta = null;
16376  let eta_from_start = null;
16377  let eta_level = 0;
16378  let progress_level = null;
16379  let last_progress_level = void 0;
16380  let progress_bar = null;
16381  let show_eta_bar = true;
16382  const start_timer = () => {
16383    $$invalidate(0, eta = $$invalidate(29, old_eta = $$invalidate(21, formatted_eta = null)));
16384    $$invalidate(27, timer_start = performance.now());
16385    $$invalidate(28, timer_diff = 0);
16386    _timer = true;
16387    run2();
16388  };
16389  function run2() {
16390    raf(() => {
16391      $$invalidate(28, timer_diff = (performance.now() - timer_start) / 1e3);
16392      if (_timer) run2();
16393    });
16394  }
16395  function stop_timer() {
16396    $$invalidate(28, timer_diff = 0);
16397    $$invalidate(0, eta = $$invalidate(29, old_eta = $$invalidate(21, formatted_eta = null)));
16398    if (!_timer) return;
16399    _timer = false;
16400  }
16401  onDestroy(() => {
16402    if (_timer) stop_timer();
16403  });
16404  let formatted_eta = null;
16405  const click_handler = () => $$invalidate(1, validation_error = null);
16406  function div1_binding($$value) {
16407    binding_callbacks[$$value ? "unshift" : "push"](() => {
16408      progress_bar = $$value;
16409      $$invalidate(18, progress_bar), $$invalidate(8, progress), $$invalidate(16, progress_level), $$invalidate(17, last_progress_level);
16410    });
16411  }
16412  const click_handler_1 = () => {
16413    dispatch2("clear_status");
16414  };
16415  function div_binding($$value) {
16416    binding_callbacks[$$value ? "unshift" : "push"](() => {
16417      el = $$value;
16418      $$invalidate(15, el);
16419    });
16420  }
16421  $$self.$$set = ($$props2) => {
16422    if ("i18n" in $$props2) $$invalidate(2, i18n = $$props2.i18n);
16423    if ("eta" in $$props2) $$invalidate(0, eta = $$props2.eta);
16424    if ("queue_position" in $$props2) $$invalidate(3, queue_position = $$props2.queue_position);
16425    if ("queue_size" in $$props2) $$invalidate(4, queue_size = $$props2.queue_size);
16426    if ("status" in $$props2) $$invalidate(5, status = $$props2.status);
16427    if ("scroll_to_output" in $$props2) $$invalidate(24, scroll_to_output = $$props2.scroll_to_output);
16428    if ("timer" in $$props2) $$invalidate(6, timer = $$props2.timer);
16429    if ("show_progress" in $$props2) $$invalidate(7, show_progress = $$props2.show_progress);
16430    if ("message" in $$props2) $$invalidate(25, message = $$props2.message);
16431    if ("progress" in $$props2) $$invalidate(8, progress = $$props2.progress);
16432    if ("variant" in $$props2) $$invalidate(9, variant = $$props2.variant);
16433    if ("loading_text" in $$props2) $$invalidate(10, loading_text = $$props2.loading_text);
16434    if ("absolute" in $$props2) $$invalidate(11, absolute = $$props2.absolute);
16435    if ("translucent" in $$props2) $$invalidate(12, translucent = $$props2.translucent);
16436    if ("border" in $$props2) $$invalidate(13, border = $$props2.border);
16437    if ("autoscroll" in $$props2) $$invalidate(26, autoscroll = $$props2.autoscroll);
16438    if ("validation_error" in $$props2) $$invalidate(1, validation_error = $$props2.validation_error);
16439    if ("show_validation_error" in $$props2) $$invalidate(14, show_validation_error = $$props2.show_validation_error);
16440    if ("$$scope" in $$props2) $$invalidate(31, $$scope = $$props2.$$scope);
16441  };
16442  $$self.$$.update = () => {
16443    if ($$self.$$.dirty[0] & /*eta, old_eta, timer_start, eta_from_start*/
16444    1744830465) {
16445      {
16446        if (eta === null) {
16447          $$invalidate(0, eta = old_eta);
16448        }
16449        if (eta != null && old_eta !== eta) {
16450          $$invalidate(30, eta_from_start = (performance.now() - timer_start) / 1e3 + eta);
16451          $$invalidate(21, formatted_eta = eta_from_start.toFixed(1));
16452          $$invalidate(29, old_eta = eta);
16453        }
16454      }
16455    }
16456    if ($$self.$$.dirty[0] & /*eta_from_start, timer_diff*/
16457    1342177280) {
16458      $$invalidate(19, eta_level = eta_from_start === null || eta_from_start <= 0 || !timer_diff ? null : Math.min(timer_diff / eta_from_start, 1));
16459    }
16460    if ($$self.$$.dirty[0] & /*progress*/
16461    256) {
16462      if (progress != null) {
16463        $$invalidate(20, show_eta_bar = false);
16464      }
16465    }
16466    if ($$self.$$.dirty[0] & /*progress, progress_level, progress_bar, last_progress_level*/
16467    459008) {
16468      {
16469        if (progress != null) {
16470          $$invalidate(16, progress_level = progress.map((p) => {
16471            if (p.index != null && p.length != null) {
16472              return p.index / p.length;
16473            } else if (p.progress != null) {
16474              return p.progress;
16475            }
16476            return void 0;
16477          }));
16478        } else {
16479          $$invalidate(16, progress_level = null);
16480        }
16481        if (progress_level) {
16482          $$invalidate(17, last_progress_level = progress_level[progress_level.length - 1]);
16483          if (progress_bar) {
16484            if (last_progress_level === 0) {
16485              $$invalidate(18, progress_bar.style.transition = "0", progress_bar);
16486            } else {
16487              $$invalidate(18, progress_bar.style.transition = "150ms", progress_bar);
16488            }
16489          }
16490        } else {
16491          $$invalidate(17, last_progress_level = void 0);
16492        }
16493      }
16494    }
16495    if ($$self.$$.dirty[0] & /*status*/
16496    32) {
16497      {
16498        if (status === "pending") {
16499          start_timer();
16500        } else {
16501          stop_timer();
16502        }
16503      }
16504    }
16505    if ($$self.$$.dirty[0] & /*el, scroll_to_output, status, autoscroll*/
16506    83918880) {
16507      el && scroll_to_output && (status === "pending" || status === "complete") && scroll_into_view(el, autoscroll);
16508    }
16509    if ($$self.$$.dirty[0] & /*status, message*/
16510    33554464) ;
16511    if ($$self.$$.dirty[0] & /*timer_diff*/
16512    268435456) {
16513      $$invalidate(22, formatted_timer = timer_diff.toFixed(1));
16514    }
16515  };
16516  return [
16517    eta,
16518    validation_error,
16519    i18n,
16520    queue_position,
16521    queue_size,
16522    status,
16523    timer,
16524    show_progress,
16525    progress,
16526    variant,
16527    loading_text,
16528    absolute,
16529    translucent,
16530    border,
16531    show_validation_error,
16532    el,
16533    progress_level,
16534    last_progress_level,
16535    progress_bar,
16536    eta_level,
16537    show_eta_bar,
16538    formatted_eta,
16539    formatted_timer,
16540    dispatch2,
16541    scroll_to_output,
16542    message,
16543    autoscroll,
16544    timer_start,
16545    timer_diff,
16546    old_eta,
16547    eta_from_start,
16548    $$scope,
16549    slots,
16550    click_handler,
16551    div1_binding,
16552    click_handler_1,
16553    div_binding
16554  ];
16555}
16556class Static extends SvelteComponent {
16557  constructor(options) {
16558    super();
16559    init(
16560      this,
16561      options,
16562      instance$p,
16563      create_fragment$q,
16564      safe_not_equal,
16565      {
16566        i18n: 2,
16567        eta: 0,
16568        queue_position: 3,
16569        queue_size: 4,
16570        status: 5,
16571        scroll_to_output: 24,
16572        timer: 6,
16573        show_progress: 7,
16574        message: 25,
16575        progress: 8,
16576        variant: 9,
16577        loading_text: 10,
16578        absolute: 11,
16579        translucent: 12,
16580        border: 13,
16581        autoscroll: 26,
16582        validation_error: 1,
16583        show_validation_error: 14
16584      },
16585      null,
16586      [-1, -1]
16587    );
16588  }
16589}
16590function fade(node, { delay = 0, duration = 400, easing = identity } = {}) {
16591  const o = +getComputedStyle(node).opacity;
16592  return {
16593    delay,
16594    duration,
16595    easing,
16596    css: (t) => `opacity: ${t * o}`
16597  };
16598}
16599function create_if_block$e(ctx) {
16600  let div;
16601  let style_animation_duration = `${/*time_limit*/
16602  ctx[0]}s`;
16603  return {
16604    c() {
16605      div = element("div");
16606      attr(div, "class", "streaming-bar svelte-ga0jj6");
16607      set_style(div, "animation-duration", style_animation_duration);
16608    },
16609    m(target, anchor) {
16610      insert(target, div, anchor);
16611    },
16612    p(ctx2, dirty) {
16613      if (dirty & /*time_limit*/
16614      1 && style_animation_duration !== (style_animation_duration = `${/*time_limit*/
16615      ctx2[0]}s`)) {
16616        set_style(div, "animation-duration", style_animation_duration);
16617      }
16618    },
16619    d(detaching) {
16620      if (detaching) {
16621        detach(div);
16622      }
16623    }
16624  };
16625}
16626function create_fragment$p(ctx) {
16627  let if_block_anchor;
16628  let if_block = (
16629    /*time_limit*/
16630    ctx[0] && create_if_block$e(ctx)
16631  );
16632  return {
16633    c() {
16634      if (if_block) if_block.c();
16635      if_block_anchor = empty();
16636    },
16637    m(target, anchor) {
16638      if (if_block) if_block.m(target, anchor);
16639      insert(target, if_block_anchor, anchor);
16640    },
16641    p(ctx2, [dirty]) {
16642      if (
16643        /*time_limit*/
16644        ctx2[0]
16645      ) {
16646        if (if_block) {
16647          if_block.p(ctx2, dirty);
16648        } else {
16649          if_block = create_if_block$e(ctx2);
16650          if_block.c();
16651          if_block.m(if_block_anchor.parentNode, if_block_anchor);
16652        }
16653      } else if (if_block) {
16654        if_block.d(1);
16655        if_block = null;
16656      }
16657    },
16658    i: noop,
16659    o: noop,
16660    d(detaching) {
16661      if (detaching) {
16662        detach(if_block_anchor);
16663      }
16664      if (if_block) if_block.d(detaching);
16665    }
16666  };
16667}
16668function instance$o($$self, $$props, $$invalidate) {
16669  let { time_limit } = $$props;
16670  $$self.$$set = ($$props2) => {
16671    if ("time_limit" in $$props2) $$invalidate(0, time_limit = $$props2.time_limit);
16672  };
16673  return [time_limit];
16674}
16675class StreamingBar extends SvelteComponent {
16676  constructor(options) {
16677    super();
16678    init(this, options, instance$o, create_fragment$p, safe_not_equal, { time_limit: 0 });
16679  }
16680}
16681function create_fragment$o(ctx) {
16682  let label_1;
16683  let input;
16684  let t0;
16685  let span;
16686  let t1;
16687  let mounted;
16688  let dispose;
16689  return {
16690    c() {
16691      label_1 = element("label");
16692      input = element("input");
16693      t0 = space();
16694      span = element("span");
16695      t1 = text(
16696        /*label*/
16697        ctx[2]
16698      );
16699      input.disabled = /*disabled*/
16700      ctx[3];
16701      attr(input, "type", "checkbox");
16702      attr(input, "name", "test");
16703      attr(input, "data-testid", "checkbox");
16704      attr(input, "class", "svelte-1q14yvm");
16705      if (
16706        /*value*/
16707        ctx[0] === void 0 || /*indeterminate*/
16708        ctx[1] === void 0
16709      ) add_render_callback(() => (
16710        /*input_change_handler*/
16711        ctx[7].call(input)
16712      ));
16713      attr(span, "class", "svelte-1q14yvm");
16714      attr(label_1, "class", "svelte-1q14yvm");
16715      toggle_class(
16716        label_1,
16717        "disabled",
16718        /*disabled*/
16719        ctx[3]
16720      );
16721    },
16722    m(target, anchor) {
16723      insert(target, label_1, anchor);
16724      append(label_1, input);
16725      input.checked = /*value*/
16726      ctx[0];
16727      input.indeterminate = /*indeterminate*/
16728      ctx[1];
16729      append(label_1, t0);
16730      append(label_1, span);
16731      append(span, t1);
16732      if (!mounted) {
16733        dispose = [
16734          listen(
16735            input,
16736            "change",
16737            /*input_change_handler*/
16738            ctx[7]
16739          ),
16740          listen(
16741            input,
16742            "keydown",
16743            /*handle_enter*/
16744            ctx[4]
16745          ),
16746          listen(
16747            input,
16748            "input",
16749            /*handle_input*/
16750            ctx[5]
16751          )
16752        ];
16753        mounted = true;
16754      }
16755    },
16756    p(ctx2, [dirty]) {
16757      if (dirty & /*disabled*/
16758      8) {
16759        input.disabled = /*disabled*/
16760        ctx2[3];
16761      }
16762      if (dirty & /*value*/
16763      1) {
16764        input.checked = /*value*/
16765        ctx2[0];
16766      }
16767      if (dirty & /*indeterminate*/
16768      2) {
16769        input.indeterminate = /*indeterminate*/
16770        ctx2[1];
16771      }
16772      if (dirty & /*label*/
16773      4) set_data(
16774        t1,
16775        /*label*/
16776        ctx2[2]
16777      );
16778      if (dirty & /*disabled*/
16779      8) {
16780        toggle_class(
16781          label_1,
16782          "disabled",
16783          /*disabled*/
16784          ctx2[3]
16785        );
16786      }
16787    },
16788    i: noop,
16789    o: noop,
16790    d(detaching) {
16791      if (detaching) {
16792        detach(label_1);
16793      }
16794      mounted = false;
16795      run_all(dispose);
16796    }
16797  };
16798}
16799function instance$n($$self, $$props, $$invalidate) {
16800  let disabled;
16801  let { value = false } = $$props;
16802  let { label = "Checkbox" } = $$props;
16803  let { interactive } = $$props;
16804  let { indeterminate = false } = $$props;
16805  const dispatch2 = createEventDispatcher();
16806  async function handle_enter(event) {
16807    if (event.key === "Enter") {
16808      $$invalidate(0, value = !value);
16809      dispatch2("select", {
16810        index: 0,
16811        value: event.currentTarget.checked,
16812        selected: event.currentTarget.checked
16813      });
16814    }
16815  }
16816  async function handle_input(event) {
16817    $$invalidate(0, value = event.currentTarget.checked);
16818    dispatch2("select", {
16819      index: 0,
16820      value: event.currentTarget.checked,
16821      selected: event.currentTarget.checked
16822    });
16823  }
16824  function input_change_handler() {
16825    value = this.checked;
16826    indeterminate = this.indeterminate;
16827    $$invalidate(0, value);
16828    $$invalidate(1, indeterminate);
16829  }
16830  $$self.$$set = ($$props2) => {
16831    if ("value" in $$props2) $$invalidate(0, value = $$props2.value);
16832    if ("label" in $$props2) $$invalidate(2, label = $$props2.label);
16833    if ("interactive" in $$props2) $$invalidate(6, interactive = $$props2.interactive);
16834    if ("indeterminate" in $$props2) $$invalidate(1, indeterminate = $$props2.indeterminate);
16835  };
16836  $$self.$$.update = () => {
16837    if ($$self.$$.dirty & /*value*/
16838    1) {
16839      dispatch2("change", value);
16840    }
16841    if ($$self.$$.dirty & /*interactive*/
16842    64) {
16843      $$invalidate(3, disabled = !interactive);
16844    }
16845  };
16846  return [
16847    value,
16848    indeterminate,
16849    label,
16850    disabled,
16851    handle_enter,
16852    handle_input,
16853    interactive,
16854    input_change_handler
16855  ];
16856}
16857class Checkbox extends SvelteComponent {
16858  constructor(options) {
16859    super();
16860    init(this, options, instance$n, create_fragment$o, safe_not_equal, {
16861      value: 0,
16862      label: 2,
16863      interactive: 6,
16864      indeterminate: 1
16865    });
16866  }
16867}
16868function create_fragment$n(ctx) {
16869  let div;
16870  let basecheckbox;
16871  let updating_value;
16872  let current;
16873  function basecheckbox_value_binding(value) {
16874    ctx[4](value);
16875  }
16876  let basecheckbox_props = {
16877    label: "",
16878    interactive: (
16879      /*editable*/
16880      ctx[1]
16881    )
16882  };
16883  if (
16884    /*value*/
16885    ctx[0] !== void 0
16886  ) {
16887    basecheckbox_props.value = /*value*/
16888    ctx[0];
16889  }
16890  basecheckbox = new Checkbox({ props: basecheckbox_props });
16891  binding_callbacks.push(() => bind(basecheckbox, "value", basecheckbox_value_binding));
16892  basecheckbox.$on(
16893    "change",
16894    /*handle_change*/
16895    ctx[2]
16896  );
16897  return {
16898    c() {
16899      div = element("div");
16900      create_component(basecheckbox.$$.fragment);
16901      attr(div, "class", "bool-cell svelte-1fodq17");
16902      attr(div, "role", "button");
16903      attr(div, "tabindex", "-1");
16904    },
16905    m(target, anchor) {
16906      insert(target, div, anchor);
16907      mount_component(basecheckbox, div, null);
16908      current = true;
16909    },
16910    p(ctx2, [dirty]) {
16911      const basecheckbox_changes = {};
16912      if (dirty & /*editable*/
16913      2) basecheckbox_changes.interactive = /*editable*/
16914      ctx2[1];
16915      if (!updating_value && dirty & /*value*/
16916      1) {
16917        updating_value = true;
16918        basecheckbox_changes.value = /*value*/
16919        ctx2[0];
16920        add_flush_callback(() => updating_value = false);
16921      }
16922      basecheckbox.$set(basecheckbox_changes);
16923    },
16924    i(local) {
16925      if (current) return;
16926      transition_in(basecheckbox.$$.fragment, local);
16927      current = true;
16928    },
16929    o(local) {
16930      transition_out(basecheckbox.$$.fragment, local);
16931      current = false;
16932    },
16933    d(detaching) {
16934      if (detaching) {
16935        detach(div);
16936      }
16937      destroy_component(basecheckbox);
16938    }
16939  };
16940}
16941function instance$m($$self, $$props, $$invalidate) {
16942  let { value = false } = $$props;
16943  let { editable = true } = $$props;
16944  let { on_change } = $$props;
16945  function handle_change(event) {
16946    if (editable) {
16947      on_change(event.detail);
16948    }
16949  }
16950  function basecheckbox_value_binding(value$1) {
16951    value = value$1;
16952    $$invalidate(0, value);
16953  }
16954  $$self.$$set = ($$props2) => {
16955    if ("value" in $$props2) $$invalidate(0, value = $$props2.value);
16956    if ("editable" in $$props2) $$invalidate(1, editable = $$props2.editable);
16957    if ("on_change" in $$props2) $$invalidate(3, on_change = $$props2.on_change);
16958  };
16959  return [value, editable, handle_change, on_change, basecheckbox_value_binding];
16960}
16961let BooleanCell$1 = class BooleanCell extends SvelteComponent {
16962  constructor(options) {
16963    super();
16964    init(this, options, instance$m, create_fragment$n, safe_not_equal, { value: 0, editable: 1, on_change: 3 });
16965  }
16966};
16967function create_if_block_5$6(ctx) {
16968  let textarea;
16969  let textarea_aria_label_value;
16970  let mounted;
16971  let dispose;
16972  return {
16973    c() {
16974      textarea = element("textarea");
16975      textarea.readOnly = /*is_static*/
16976      ctx[9];
16977      attr(
16978        textarea,
16979        "aria-readonly",
16980        /*is_static*/
16981        ctx[9]
16982      );
16983      attr(textarea, "aria-label", textarea_aria_label_value = /*is_static*/
16984      ctx[9] ? "Cell is read-only" : "Edit cell");
16985      attr(textarea, "tabindex", "-1");
16986      attr(textarea, "class", "svelte-8fgf56");
16987      toggle_class(
16988        textarea,
16989        "header",
16990        /*header*/
16991        ctx[4]
16992      );
16993    },
16994    m(target, anchor) {
16995      insert(target, textarea, anchor);
16996      ctx[29](textarea);
16997      set_input_value(
16998        textarea,
16999        /*value*/
17000        ctx[0]
17001      );
17002      if (!mounted) {
17003        dispose = [
17004          listen(
17005            textarea,
17006            "input",
17007            /*textarea_input_handler*/
17008            ctx[30]
17009          ),
17010          listen(
17011            textarea,
17012            "blur",
17013            /*handle_blur*/
17014            ctx[20]
17015          ),
17016          listen(textarea, "mousedown", stop_propagation(
17017            /*mousedown_handler*/
17018            ctx[27]
17019          )),
17020          listen(textarea, "click", stop_propagation(
17021            /*click_handler*/
17022            ctx[28]
17023          )),
17024          action_destroyer(use_focus.call(null, textarea)),
17025          listen(
17026            textarea,
17027            "keydown",
17028            /*handle_keydown*/
17029            ctx[21]
17030          )
17031        ];
17032        mounted = true;
17033      }
17034    },
17035    p(ctx2, dirty) {
17036      if (dirty[0] & /*is_static*/
17037      512) {
17038        textarea.readOnly = /*is_static*/
17039        ctx2[9];
17040      }
17041      if (dirty[0] & /*is_static*/
17042      512) {
17043        attr(
17044          textarea,
17045          "aria-readonly",
17046          /*is_static*/
17047          ctx2[9]
17048        );
17049      }
17050      if (dirty[0] & /*is_static*/
17051      512 && textarea_aria_label_value !== (textarea_aria_label_value = /*is_static*/
17052      ctx2[9] ? "Cell is read-only" : "Edit cell")) {
17053        attr(textarea, "aria-label", textarea_aria_label_value);
17054      }
17055      if (dirty[0] & /*value*/
17056      1) {
17057        set_input_value(
17058          textarea,
17059          /*value*/
17060          ctx2[0]
17061        );
17062      }
17063      if (dirty[0] & /*header*/
17064      16) {
17065        toggle_class(
17066          textarea,
17067          "header",
17068          /*header*/
17069          ctx2[4]
17070        );
17071      }
17072    },
17073    d(detaching) {
17074      if (detaching) {
17075        detach(textarea);
17076      }
17077      ctx[29](null);
17078      mounted = false;
17079      run_all(dispose);
17080    }
17081  };
17082}
17083function create_else_block$5(ctx) {
17084  let span;
17085  let current_block_type_index;
17086  let if_block;
17087  let current;
17088  let mounted;
17089  let dispose;
17090  const if_block_creators = [create_if_block_2$9, create_if_block_3$8, create_if_block_4$6, create_else_block_1$2];
17091  const if_blocks = [];
17092  function select_block_type_1(ctx2, dirty) {
17093    if (
17094      /*datatype*/
17095      ctx2[5] === "image" && /*components*/
17096      ctx2[11].image
17097    ) return 0;
17098    if (
17099      /*datatype*/
17100      ctx2[5] === "html"
17101    ) return 1;
17102    if (
17103      /*datatype*/
17104      ctx2[5] === "markdown"
17105    ) return 2;
17106    return 3;
17107  }
17108  current_block_type_index = select_block_type_1(ctx);
17109  if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
17110  return {
17111    c() {
17112      span = element("span");
17113      if_block.c();
17114      attr(span, "tabindex", "0");
17115      attr(span, "role", "button");
17116      attr(
17117        span,
17118        "style",
17119        /*styling*/
17120        ctx[3]
17121      );
17122      attr(
17123        span,
17124        "data-editable",
17125        /*editable*/
17126        ctx[8]
17127      );
17128      attr(
17129        span,
17130        "data-max-chars",
17131        /*max_chars*/
17132        ctx[10]
17133      );
17134      attr(
17135        span,
17136        "data-expanded",
17137        /*edit*/
17138        ctx[2]
17139      );
17140      attr(span, "placeholder", " ");
17141      attr(span, "class", "svelte-8fgf56");
17142      toggle_class(
17143        span,
17144        "dragging",
17145        /*is_dragging*/
17146        ctx[13]
17147      );
17148      toggle_class(
17149        span,
17150        "edit",
17151        /*edit*/
17152        ctx[2]
17153      );
17154      toggle_class(
17155        span,
17156        "expanded",
17157        /*edit*/
17158        ctx[2]
17159      );
17160      toggle_class(
17161        span,
17162        "multiline",
17163        /*header*/
17164        ctx[4]
17165      );
17166      toggle_class(
17167        span,
17168        "text",
17169        /*datatype*/
17170        ctx[5] === "str"
17171      );
17172      toggle_class(
17173        span,
17174        "wrap",
17175        /*wrap_text*/
17176        ctx[14]
17177      );
17178    },
17179    m(target, anchor) {
17180      insert(target, span, anchor);
17181      if_blocks[current_block_type_index].m(span, null);
17182      current = true;
17183      if (!mounted) {
17184        dispose = [
17185          listen(
17186            span,
17187            "keydown",
17188            /*handle_keydown*/
17189            ctx[21]
17190          ),
17191          listen(span, "focus", prevent_default(
17192            /*focus_handler*/
17193            ctx[26]
17194          ))
17195        ];
17196        mounted = true;
17197      }
17198    },
17199    p(ctx2, dirty) {
17200      let previous_block_index = current_block_type_index;
17201      current_block_type_index = select_block_type_1(ctx2);
17202      if (current_block_type_index === previous_block_index) {
17203        if_blocks[current_block_type_index].p(ctx2, dirty);
17204      } else {
17205        group_outros();
17206        transition_out(if_blocks[previous_block_index], 1, 1, () => {
17207          if_blocks[previous_block_index] = null;
17208        });
17209        check_outros();
17210        if_block = if_blocks[current_block_type_index];
17211        if (!if_block) {
17212          if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
17213          if_block.c();
17214        } else {
17215          if_block.p(ctx2, dirty);
17216        }
17217        transition_in(if_block, 1);
17218        if_block.m(span, null);
17219      }
17220      if (!current || dirty[0] & /*styling*/
17221      8) {
17222        attr(
17223          span,
17224          "style",
17225          /*styling*/
17226          ctx2[3]
17227        );
17228      }
17229      if (!current || dirty[0] & /*editable*/
17230      256) {
17231        attr(
17232          span,
17233          "data-editable",
17234          /*editable*/
17235          ctx2[8]
17236        );
17237      }
17238      if (!current || dirty[0] & /*max_chars*/
17239      1024) {
17240        attr(
17241          span,
17242          "data-max-chars",
17243          /*max_chars*/
17244          ctx2[10]
17245        );
17246      }
17247      if (!current || dirty[0] & /*edit*/
17248      4) {
17249        attr(
17250          span,
17251          "data-expanded",
17252          /*edit*/
17253          ctx2[2]
17254        );
17255      }
17256      if (!current || dirty[0] & /*is_dragging*/
17257      8192) {
17258        toggle_class(
17259          span,
17260          "dragging",
17261          /*is_dragging*/
17262          ctx2[13]
17263        );
17264      }
17265      if (!current || dirty[0] & /*edit*/
17266      4) {
17267        toggle_class(
17268          span,
17269          "edit",
17270          /*edit*/
17271          ctx2[2]
17272        );
17273      }
17274      if (!current || dirty[0] & /*edit*/
17275      4) {
17276        toggle_class(
17277          span,
17278          "expanded",
17279          /*edit*/
17280          ctx2[2]
17281        );
17282      }
17283      if (!current || dirty[0] & /*header*/
17284      16) {
17285        toggle_class(
17286          span,
17287          "multiline",
17288          /*header*/
17289          ctx2[4]
17290        );
17291      }
17292      if (!current || dirty[0] & /*datatype*/
17293      32) {
17294        toggle_class(
17295          span,
17296          "text",
17297          /*datatype*/
17298          ctx2[5] === "str"
17299        );
17300      }
17301      if (!current || dirty[0] & /*wrap_text*/
17302      16384) {
17303        toggle_class(
17304          span,
17305          "wrap",
17306          /*wrap_text*/
17307          ctx2[14]
17308        );
17309      }
17310    },
17311    i(local) {
17312      if (current) return;
17313      transition_in(if_block);
17314      current = true;
17315    },
17316    o(local) {
17317      transition_out(if_block);
17318      current = false;
17319    },
17320    d(detaching) {
17321      if (detaching) {
17322        detach(span);
17323      }
17324      if_blocks[current_block_type_index].d();
17325      mounted = false;
17326      run_all(dispose);
17327    }
17328  };
17329}
17330function create_if_block_1$a(ctx) {
17331  let booleancell;
17332  let updating_value;
17333  let current;
17334  function booleancell_value_binding(value) {
17335    ctx[31](value);
17336  }
17337  let booleancell_props = {
17338    editable: (
17339      /*editable*/
17340      ctx[8]
17341    ),
17342    on_change: (
17343      /*commit_change*/
17344      ctx[22]
17345    )
17346  };
17347  if (
17348    /*value*/
17349    ctx[0] !== void 0
17350  ) {
17351    booleancell_props.value = /*value*/
17352    ctx[0];
17353  }
17354  booleancell = new BooleanCell$1({ props: booleancell_props });
17355  binding_callbacks.push(() => bind(booleancell, "value", booleancell_value_binding));
17356  return {
17357    c() {
17358      create_component(booleancell.$$.fragment);
17359    },
17360    m(target, anchor) {
17361      mount_component(booleancell, target, anchor);
17362      current = true;
17363    },
17364    p(ctx2, dirty) {
17365      const booleancell_changes = {};
17366      if (dirty[0] & /*editable*/
17367      256) booleancell_changes.editable = /*editable*/
17368      ctx2[8];
17369      if (!updating_value && dirty[0] & /*value*/
17370      1) {
17371        updating_value = true;
17372        booleancell_changes.value = /*value*/
17373        ctx2[0];
17374        add_flush_callback(() => updating_value = false);
17375      }
17376      booleancell.$set(booleancell_changes);
17377    },
17378    i(local) {
17379      if (current) return;
17380      transition_in(booleancell.$$.fragment, local);
17381      current = true;
17382    },
17383    o(local) {
17384      transition_out(booleancell.$$.fragment, local);
17385      current = false;
17386    },
17387    d(detaching) {
17388      destroy_component(booleancell, detaching);
17389    }
17390  };
17391}
17392function create_else_block_1$2(ctx) {
17393  let t;
17394  return {
17395    c() {
17396      t = text(
17397        /*display_text*/
17398        ctx[19]
17399      );
17400    },
17401    m(target, anchor) {
17402      insert(target, t, anchor);
17403    },
17404    p(ctx2, dirty) {
17405      if (dirty[0] & /*display_text*/
17406      524288) set_data(
17407        t,
17408        /*display_text*/
17409        ctx2[19]
17410      );
17411    },
17412    i: noop,
17413    o: noop,
17414    d(detaching) {
17415      if (detaching) {
17416        detach(t);
17417      }
17418    }
17419  };
17420}
17421function create_if_block_4$6(ctx) {
17422  let markdowncode;
17423  let current;
17424  markdowncode = new MarkdownCode({
17425    props: {
17426      message: (
17427        /*display_text*/
17428        ctx[19].toLocaleString()
17429      ),
17430      latex_delimiters: (
17431        /*latex_delimiters*/
17432        ctx[6]
17433      ),
17434      line_breaks: (
17435        /*line_breaks*/
17436        ctx[7]
17437      ),
17438      chatbot: false
17439    }
17440  });
17441  return {
17442    c() {
17443      create_component(markdowncode.$$.fragment);
17444    },
17445    m(target, anchor) {
17446      mount_component(markdowncode, target, anchor);
17447      current = true;
17448    },
17449    p(ctx2, dirty) {
17450      const markdowncode_changes = {};
17451      if (dirty[0] & /*display_text*/
17452      524288) markdowncode_changes.message = /*display_text*/
17453      ctx2[19].toLocaleString();
17454      if (dirty[0] & /*latex_delimiters*/
17455      64) markdowncode_changes.latex_delimiters = /*latex_delimiters*/
17456      ctx2[6];
17457      if (dirty[0] & /*line_breaks*/
17458      128) markdowncode_changes.line_breaks = /*line_breaks*/
17459      ctx2[7];
17460      markdowncode.$set(markdowncode_changes);
17461    },
17462    i(local) {
17463      if (current) return;
17464      transition_in(markdowncode.$$.fragment, local);
17465      current = true;
17466    },
17467    o(local) {
17468      transition_out(markdowncode.$$.fragment, local);
17469      current = false;
17470    },
17471    d(detaching) {
17472      destroy_component(markdowncode, detaching);
17473    }
17474  };
17475}
17476function create_if_block_3$8(ctx) {
17477  let html_tag;
17478  let html_anchor;
17479  return {
17480    c() {
17481      html_tag = new HtmlTag(false);
17482      html_anchor = empty();
17483      html_tag.a = html_anchor;
17484    },
17485    m(target, anchor) {
17486      html_tag.m(
17487        /*display_text*/
17488        ctx[19],
17489        target,
17490        anchor
17491      );
17492      insert(target, html_anchor, anchor);
17493    },
17494    p(ctx2, dirty) {
17495      if (dirty[0] & /*display_text*/
17496      524288) html_tag.p(
17497        /*display_text*/
17498        ctx2[19]
17499      );
17500    },
17501    i: noop,
17502    o: noop,
17503    d(detaching) {
17504      if (detaching) {
17505        detach(html_anchor);
17506        html_tag.d();
17507      }
17508    }
17509  };
17510}
17511function create_if_block_2$9(ctx) {
17512  let switch_instance;
17513  let switch_instance_anchor;
17514  let current;
17515  var switch_value = (
17516    /*components*/
17517    ctx[11].image
17518  );
17519  function switch_props(ctx2, dirty) {
17520    return {
17521      props: {
17522        value: { url: (
17523          /*display_text*/
17524          ctx2[19]
17525        ) },
17526        show_label: false,
17527        label: "cell-image",
17528        show_download_button: false,
17529        i18n: (
17530          /*i18n*/
17531          ctx2[12]
17532        ),
17533        gradio: { dispatch: func }
17534      }
17535    };
17536  }
17537  if (switch_value) {
17538    switch_instance = construct_svelte_component(switch_value, switch_props(ctx));
17539  }
17540  return {
17541    c() {
17542      if (switch_instance) create_component(switch_instance.$$.fragment);
17543      switch_instance_anchor = empty();
17544    },
17545    m(target, anchor) {
17546      if (switch_instance) mount_component(switch_instance, target, anchor);
17547      insert(target, switch_instance_anchor, anchor);
17548      current = true;
17549    },
17550    p(ctx2, dirty) {
17551      if (dirty[0] & /*components*/
17552      2048 && switch_value !== (switch_value = /*components*/
17553      ctx2[11].image)) {
17554        if (switch_instance) {
17555          group_outros();
17556          const old_component = switch_instance;
17557          transition_out(old_component.$$.fragment, 1, 0, () => {
17558            destroy_component(old_component, 1);
17559          });
17560          check_outros();
17561        }
17562        if (switch_value) {
17563          switch_instance = construct_svelte_component(switch_value, switch_props(ctx2));
17564          create_component(switch_instance.$$.fragment);
17565          transition_in(switch_instance.$$.fragment, 1);
17566          mount_component(switch_instance, switch_instance_anchor.parentNode, switch_instance_anchor);
17567        } else {
17568          switch_instance = null;
17569        }
17570      } else if (switch_value) {
17571        const switch_instance_changes = {};
17572        if (dirty[0] & /*display_text*/
17573        524288) switch_instance_changes.value = { url: (
17574          /*display_text*/
17575          ctx2[19]
17576        ) };
17577        if (dirty[0] & /*i18n*/
17578        4096) switch_instance_changes.i18n = /*i18n*/
17579        ctx2[12];
17580        switch_instance.$set(switch_instance_changes);
17581      }
17582    },
17583    i(local) {
17584      if (current) return;
17585      if (switch_instance) transition_in(switch_instance.$$.fragment, local);
17586      current = true;
17587    },
17588    o(local) {
17589      if (switch_instance) transition_out(switch_instance.$$.fragment, local);
17590      current = false;
17591    },
17592    d(detaching) {
17593      if (detaching) {
17594        detach(switch_instance_anchor);
17595      }
17596      if (switch_instance) destroy_component(switch_instance, detaching);
17597    }
17598  };
17599}
17600function create_if_block$d(ctx) {
17601  let selectionbuttons0;
17602  let t;
17603  let selectionbuttons1;
17604  let current;
17605  selectionbuttons0 = new SelectionButtons$1({
17606    props: {
17607      position: "column",
17608      coords: (
17609        /*coords*/
17610        ctx[16]
17611      ),
17612      on_click: (
17613        /*func_1*/
17614        ctx[32]
17615      )
17616    }
17617  });
17618  selectionbuttons1 = new SelectionButtons$1({
17619    props: {
17620      position: "row",
17621      coords: (
17622        /*coords*/
17623        ctx[16]
17624      ),
17625      on_click: (
17626        /*func_2*/
17627        ctx[33]
17628      )
17629    }
17630  });
17631  return {
17632    c() {
17633      create_component(selectionbuttons0.$$.fragment);
17634      t = space();
17635      create_component(selectionbuttons1.$$.fragment);
17636    },
17637    m(target, anchor) {
17638      mount_component(selectionbuttons0, target, anchor);
17639      insert(target, t, anchor);
17640      mount_component(selectionbuttons1, target, anchor);
17641      current = true;
17642    },
17643    p(ctx2, dirty) {
17644      const selectionbuttons0_changes = {};
17645      if (dirty[0] & /*coords*/
17646      65536) selectionbuttons0_changes.coords = /*coords*/
17647      ctx2[16];
17648      if (dirty[0] & /*on_select_column, coords*/
17649      196608) selectionbuttons0_changes.on_click = /*func_1*/
17650      ctx2[32];
17651      selectionbuttons0.$set(selectionbuttons0_changes);
17652      const selectionbuttons1_changes = {};
17653      if (dirty[0] & /*coords*/
17654      65536) selectionbuttons1_changes.coords = /*coords*/
17655      ctx2[16];
17656      if (dirty[0] & /*on_select_row, coords*/
17657      327680) selectionbuttons1_changes.on_click = /*func_2*/
17658      ctx2[33];
17659      selectionbuttons1.$set(selectionbuttons1_changes);
17660    },
17661    i(local) {
17662      if (current) return;
17663      transition_in(selectionbuttons0.$$.fragment, local);
17664      transition_in(selectionbuttons1.$$.fragment, local);
17665      current = true;
17666    },
17667    o(local) {
17668      transition_out(selectionbuttons0.$$.fragment, local);
17669      transition_out(selectionbuttons1.$$.fragment, local);
17670      current = false;
17671    },
17672    d(detaching) {
17673      if (detaching) {
17674        detach(t);
17675      }
17676      destroy_component(selectionbuttons0, detaching);
17677      destroy_component(selectionbuttons1, detaching);
17678    }
17679  };
17680}
17681function create_fragment$m(ctx) {
17682  let t0;
17683  let current_block_type_index;
17684  let if_block1;
17685  let t1;
17686  let if_block2_anchor;
17687  let current;
17688  let if_block0 = (
17689    /*edit*/
17690    ctx[2] && /*datatype*/
17691    ctx[5] !== "bool" && create_if_block_5$6(ctx)
17692  );
17693  const if_block_creators = [create_if_block_1$a, create_else_block$5];
17694  const if_blocks = [];
17695  function select_block_type(ctx2, dirty) {
17696    if (
17697      /*datatype*/
17698      ctx2[5] === "bool" && typeof /*value*/
17699      ctx2[0] === "boolean"
17700    ) return 0;
17701    return 1;
17702  }
17703  current_block_type_index = select_block_type(ctx);
17704  if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
17705  let if_block2 = (
17706    /*show_selection_buttons*/
17707    ctx[15] && /*coords*/
17708    ctx[16] && /*on_select_column*/
17709    ctx[17] && /*on_select_row*/
17710    ctx[18] && create_if_block$d(ctx)
17711  );
17712  return {
17713    c() {
17714      if (if_block0) if_block0.c();
17715      t0 = space();
17716      if_block1.c();
17717      t1 = space();
17718      if (if_block2) if_block2.c();
17719      if_block2_anchor = empty();
17720    },
17721    m(target, anchor) {
17722      if (if_block0) if_block0.m(target, anchor);
17723      insert(target, t0, anchor);
17724      if_blocks[current_block_type_index].m(target, anchor);
17725      insert(target, t1, anchor);
17726      if (if_block2) if_block2.m(target, anchor);
17727      insert(target, if_block2_anchor, anchor);
17728      current = true;
17729    },
17730    p(ctx2, dirty) {
17731      if (
17732        /*edit*/
17733        ctx2[2] && /*datatype*/
17734        ctx2[5] !== "bool"
17735      ) {
17736        if (if_block0) {
17737          if_block0.p(ctx2, dirty);
17738        } else {
17739          if_block0 = create_if_block_5$6(ctx2);
17740          if_block0.c();
17741          if_block0.m(t0.parentNode, t0);
17742        }
17743      } else if (if_block0) {
17744        if_block0.d(1);
17745        if_block0 = null;
17746      }
17747      let previous_block_index = current_block_type_index;
17748      current_block_type_index = select_block_type(ctx2);
17749      if (current_block_type_index === previous_block_index) {
17750        if_blocks[current_block_type_index].p(ctx2, dirty);
17751      } else {
17752        group_outros();
17753        transition_out(if_blocks[previous_block_index], 1, 1, () => {
17754          if_blocks[previous_block_index] = null;
17755        });
17756        check_outros();
17757        if_block1 = if_blocks[current_block_type_index];
17758        if (!if_block1) {
17759          if_block1 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
17760          if_block1.c();
17761        } else {
17762          if_block1.p(ctx2, dirty);
17763        }
17764        transition_in(if_block1, 1);
17765        if_block1.m(t1.parentNode, t1);
17766      }
17767      if (
17768        /*show_selection_buttons*/
17769        ctx2[15] && /*coords*/
17770        ctx2[16] && /*on_select_column*/
17771        ctx2[17] && /*on_select_row*/
17772        ctx2[18]
17773      ) {
17774        if (if_block2) {
17775          if_block2.p(ctx2, dirty);
17776          if (dirty[0] & /*show_selection_buttons, coords, on_select_column, on_select_row*/
17777          491520) {
17778            transition_in(if_block2, 1);
17779          }
17780        } else {
17781          if_block2 = create_if_block$d(ctx2);
17782          if_block2.c();
17783          transition_in(if_block2, 1);
17784          if_block2.m(if_block2_anchor.parentNode, if_block2_anchor);
17785        }
17786      } else if (if_block2) {
17787        group_outros();
17788        transition_out(if_block2, 1, 1, () => {
17789          if_block2 = null;
17790        });
17791        check_outros();
17792      }
17793    },
17794    i(local) {
17795      if (current) return;
17796      transition_in(if_block1);
17797      transition_in(if_block2);
17798      current = true;
17799    },
17800    o(local) {
17801      transition_out(if_block1);
17802      transition_out(if_block2);
17803      current = false;
17804    },
17805    d(detaching) {
17806      if (detaching) {
17807        detach(t0);
17808        detach(t1);
17809        detach(if_block2_anchor);
17810      }
17811      if (if_block0) if_block0.d(detaching);
17812      if_blocks[current_block_type_index].d(detaching);
17813      if (if_block2) if_block2.d(detaching);
17814    }
17815  };
17816}
17817function truncate_text(text2, max_length = null, is_image = false) {
17818  if (is_image) return String(text2);
17819  const str = String(text2);
17820  if (!max_length || max_length <= 0) return str;
17821  if (str.length <= max_length) return str;
17822  return str.slice(0, max_length) + "...";
17823}
17824function use_focus(node) {
17825  requestAnimationFrame(() => {
17826    node.focus();
17827  });
17828  return {};
17829}
17830const func = () => {
17831};
17832function instance$l($$self, $$props, $$invalidate) {
17833  let should_truncate;
17834  let display_content;
17835  let display_text;
17836  let { edit: edit2 } = $$props;
17837  let { value = "" } = $$props;
17838  let { display_value = null } = $$props;
17839  let { styling = "" } = $$props;
17840  let { header = false } = $$props;
17841  let { datatype = "str" } = $$props;
17842  let { latex_delimiters } = $$props;
17843  let { line_breaks = true } = $$props;
17844  let { editable = true } = $$props;
17845  let { is_static = false } = $$props;
17846  let { max_chars = null } = $$props;
17847  let { components = {} } = $$props;
17848  let { i18n } = $$props;
17849  let { is_dragging = false } = $$props;
17850  let { wrap_text = false } = $$props;
17851  let { show_selection_buttons = false } = $$props;
17852  let { coords } = $$props;
17853  let { on_select_column = null } = $$props;
17854  let { on_select_row = null } = $$props;
17855  let { el } = $$props;
17856  const dispatch2 = createEventDispatcher();
17857  function handle_blur(event) {
17858    dispatch2("blur", { blur_event: event, coords });
17859  }
17860  function handle_keydown2(event) {
17861    dispatch2("keydown", event);
17862  }
17863  function commit_change(checked) {
17864    handle_blur({ target: { value } });
17865  }
17866  function focus_handler(event) {
17867    bubble.call(this, $$self, event);
17868  }
17869  function mousedown_handler(event) {
17870    bubble.call(this, $$self, event);
17871  }
17872  function click_handler(event) {
17873    bubble.call(this, $$self, event);
17874  }
17875  function textarea_binding($$value) {
17876    binding_callbacks[$$value ? "unshift" : "push"](() => {
17877      el = $$value;
17878      $$invalidate(1, el);
17879    });
17880  }
17881  function textarea_input_handler() {
17882    value = this.value;
17883    $$invalidate(0, value);
17884  }
17885  function booleancell_value_binding(value$1) {
17886    value = value$1;
17887    $$invalidate(0, value);
17888  }
17889  const func_1 = () => on_select_column(coords[1]);
17890  const func_2 = () => on_select_row(coords[0]);
17891  $$self.$$set = ($$props2) => {
17892    if ("edit" in $$props2) $$invalidate(2, edit2 = $$props2.edit);
17893    if ("value" in $$props2) $$invalidate(0, value = $$props2.value);
17894    if ("display_value" in $$props2) $$invalidate(23, display_value = $$props2.display_value);
17895    if ("styling" in $$props2) $$invalidate(3, styling = $$props2.styling);
17896    if ("header" in $$props2) $$invalidate(4, header = $$props2.header);
17897    if ("datatype" in $$props2) $$invalidate(5, datatype = $$props2.datatype);
17898    if ("latex_delimiters" in $$props2) $$invalidate(6, latex_delimiters = $$props2.latex_delimiters);
17899    if ("line_breaks" in $$props2) $$invalidate(7, line_breaks = $$props2.line_breaks);
17900    if ("editable" in $$props2) $$invalidate(8, editable = $$props2.editable);
17901    if ("is_static" in $$props2) $$invalidate(9, is_static = $$props2.is_static);
17902    if ("max_chars" in $$props2) $$invalidate(10, max_chars = $$props2.max_chars);
17903    if ("components" in $$props2) $$invalidate(11, components = $$props2.components);
17904    if ("i18n" in $$props2) $$invalidate(12, i18n = $$props2.i18n);
17905    if ("is_dragging" in $$props2) $$invalidate(13, is_dragging = $$props2.is_dragging);
17906    if ("wrap_text" in $$props2) $$invalidate(14, wrap_text = $$props2.wrap_text);
17907    if ("show_selection_buttons" in $$props2) $$invalidate(15, show_selection_buttons = $$props2.show_selection_buttons);
17908    if ("coords" in $$props2) $$invalidate(16, coords = $$props2.coords);
17909    if ("on_select_column" in $$props2) $$invalidate(17, on_select_column = $$props2.on_select_column);
17910    if ("on_select_row" in $$props2) $$invalidate(18, on_select_row = $$props2.on_select_row);
17911    if ("el" in $$props2) $$invalidate(1, el = $$props2.el);
17912  };
17913  $$self.$$.update = () => {
17914    if ($$self.$$.dirty[0] & /*edit, max_chars*/
17915    1028) {
17916      $$invalidate(25, should_truncate = !edit2 && max_chars !== null && max_chars > 0);
17917    }
17918    if ($$self.$$.dirty[0] & /*editable, value, display_value*/
17919    8388865) {
17920      $$invalidate(24, display_content = editable ? value : display_value !== null ? display_value : value);
17921    }
17922    if ($$self.$$.dirty[0] & /*should_truncate, display_content, max_chars, datatype*/
17923    50332704) {
17924      $$invalidate(19, display_text = should_truncate ? truncate_text(display_content, max_chars, datatype === "image") : display_content);
17925    }
17926    if ($$self.$$.dirty[0] & /*edit, value*/
17927    5) {
17928      if (!edit2) {
17929        handle_blur({ target: { value } });
17930      }
17931    }
17932  };
17933  return [
17934    value,
17935    el,
17936    edit2,
17937    styling,
17938    header,
17939    datatype,
17940    latex_delimiters,
17941    line_breaks,
17942    editable,
17943    is_static,
17944    max_chars,
17945    components,
17946    i18n,
17947    is_dragging,
17948    wrap_text,
17949    show_selection_buttons,
17950    coords,
17951    on_select_column,
17952    on_select_row,
17953    display_text,
17954    handle_blur,
17955    handle_keydown2,
17956    commit_change,
17957    display_value,
17958    display_content,
17959    should_truncate,
17960    focus_handler,
17961    mousedown_handler,
17962    click_handler,
17963    textarea_binding,
17964    textarea_input_handler,
17965    booleancell_value_binding,
17966    func_1,
17967    func_2
17968  ];
17969}
17970let EditableCell$1 = class EditableCell extends SvelteComponent {
17971  constructor(options) {
17972    super();
17973    init(
17974      this,
17975      options,
17976      instance$l,
17977      create_fragment$m,
17978      safe_not_equal,
17979      {
17980        edit: 2,
17981        value: 0,
17982        display_value: 23,
17983        styling: 3,
17984        header: 4,
17985        datatype: 5,
17986        latex_delimiters: 6,
17987        line_breaks: 7,
17988        editable: 8,
17989        is_static: 9,
17990        max_chars: 10,
17991        components: 11,
17992        i18n: 12,
17993        is_dragging: 13,
17994        wrap_text: 14,
17995        show_selection_buttons: 15,
17996        coords: 16,
17997        on_select_column: 17,
17998        on_select_row: 18,
17999        el: 1
18000      },
18001      null,
18002      [-1, -1]
18003    );
18004  }
18005};
18006function create_else_block$4(ctx) {
18007  let td;
18008  let t_value = (
18009    /*index*/
18010    (ctx[0] !== null ? (
18011      /*index*/
18012      ctx[0] + 1
18013    ) : "") + ""
18014  );
18015  let t;
18016  return {
18017    c() {
18018      td = element("td");
18019      t = text(t_value);
18020      attr(td, "class", "row-number svelte-1u9ak0p");
18021      attr(td, "tabindex", "-1");
18022      attr(
18023        td,
18024        "data-row",
18025        /*index*/
18026        ctx[0]
18027      );
18028      attr(td, "data-col", "row-number");
18029    },
18030    m(target, anchor) {
18031      insert(target, td, anchor);
18032      append(td, t);
18033    },
18034    p(ctx2, dirty) {
18035      if (dirty & /*index*/
18036      1 && t_value !== (t_value = /*index*/
18037      (ctx2[0] !== null ? (
18038        /*index*/
18039        ctx2[0] + 1
18040      ) : "") + "")) set_data(t, t_value);
18041      if (dirty & /*index*/
18042      1) {
18043        attr(
18044          td,
18045          "data-row",
18046          /*index*/
18047          ctx2[0]
18048        );
18049      }
18050    },
18051    d(detaching) {
18052      if (detaching) {
18053        detach(td);
18054      }
18055    }
18056  };
18057}
18058function create_if_block$c(ctx) {
18059  let th;
18060  return {
18061    c() {
18062      th = element("th");
18063      th.innerHTML = `<div class="cell-wrap"><div class="header-content"><div class="header-text"></div></div></div>`;
18064      attr(th, "tabindex", "-1");
18065      attr(th, "class", "row-number svelte-1u9ak0p");
18066    },
18067    m(target, anchor) {
18068      insert(target, th, anchor);
18069    },
18070    p: noop,
18071    d(detaching) {
18072      if (detaching) {
18073        detach(th);
18074      }
18075    }
18076  };
18077}
18078function create_fragment$l(ctx) {
18079  let if_block_anchor;
18080  function select_block_type(ctx2, dirty) {
18081    if (
18082      /*is_header*/
18083      ctx2[1]
18084    ) return create_if_block$c;
18085    return create_else_block$4;
18086  }
18087  let current_block_type = select_block_type(ctx);
18088  let if_block = current_block_type(ctx);
18089  return {
18090    c() {
18091      if_block.c();
18092      if_block_anchor = empty();
18093    },
18094    m(target, anchor) {
18095      if_block.m(target, anchor);
18096      insert(target, if_block_anchor, anchor);
18097    },
18098    p(ctx2, [dirty]) {
18099      if (current_block_type === (current_block_type = select_block_type(ctx2)) && if_block) {
18100        if_block.p(ctx2, dirty);
18101      } else {
18102        if_block.d(1);
18103        if_block = current_block_type(ctx2);
18104        if (if_block) {
18105          if_block.c();
18106          if_block.m(if_block_anchor.parentNode, if_block_anchor);
18107        }
18108      }
18109    },
18110    i: noop,
18111    o: noop,
18112    d(detaching) {
18113      if (detaching) {
18114        detach(if_block_anchor);
18115      }
18116      if_block.d(detaching);
18117    }
18118  };
18119}
18120function instance$k($$self, $$props, $$invalidate) {
18121  let { index = null } = $$props;
18122  let { is_header = false } = $$props;
18123  $$self.$$set = ($$props2) => {
18124    if ("index" in $$props2) $$invalidate(0, index = $$props2.index);
18125    if ("is_header" in $$props2) $$invalidate(1, is_header = $$props2.is_header);
18126  };
18127  return [index, is_header];
18128}
18129let RowNumber$1 = class RowNumber extends SvelteComponent {
18130  constructor(options) {
18131    super();
18132    init(this, options, instance$k, create_fragment$l, safe_not_equal, { index: 0, is_header: 1 });
18133  }
18134};
18135function create_fragment$k(ctx) {
18136  let button;
18137  let mounted;
18138  let dispose;
18139  return {
18140    c() {
18141      button = element("button");
18142      button.textContent = "⋮";
18143      attr(button, "aria-label", "Open cell menu");
18144      attr(button, "class", "cell-menu-button svelte-pgxclp");
18145      attr(button, "aria-haspopup", "menu");
18146    },
18147    m(target, anchor) {
18148      insert(target, button, anchor);
18149      if (!mounted) {
18150        dispose = [
18151          listen(button, "click", function() {
18152            if (is_function(
18153              /*on_click*/
18154              ctx[0]
18155            )) ctx[0].apply(this, arguments);
18156          }),
18157          listen(
18158            button,
18159            "touchstart",
18160            /*touchstart_handler*/
18161            ctx[1]
18162          )
18163        ];
18164        mounted = true;
18165      }
18166    },
18167    p(new_ctx, [dirty]) {
18168      ctx = new_ctx;
18169    },
18170    i: noop,
18171    o: noop,
18172    d(detaching) {
18173      if (detaching) {
18174        detach(button);
18175      }
18176      mounted = false;
18177      run_all(dispose);
18178    }
18179  };
18180}
18181function instance$j($$self, $$props, $$invalidate) {
18182  let { on_click } = $$props;
18183  const touchstart_handler = (event) => {
18184    event.preventDefault();
18185    const touch = event.touches[0];
18186    const mouseEvent = new MouseEvent(
18187      "click",
18188      {
18189        clientX: touch.clientX,
18190        clientY: touch.clientY,
18191        bubbles: true,
18192        cancelable: true,
18193        view: window
18194      }
18195    );
18196    on_click(mouseEvent);
18197  };
18198  $$self.$$set = ($$props2) => {
18199    if ("on_click" in $$props2) $$invalidate(0, on_click = $$props2.on_click);
18200  };
18201  return [on_click, touchstart_handler];
18202}
18203let CellMenuButton$1 = class CellMenuButton extends SvelteComponent {
18204  constructor(options) {
18205    super();
18206    init(this, options, instance$j, create_fragment$k, safe_not_equal, { on_click: 0 });
18207  }
18208};
18209function create_fragment$j(ctx) {
18210  let div;
18211  return {
18212    c() {
18213      div = element("div");
18214      div.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg>`;
18215      attr(div, "class", "wrapper svelte-uijjh0");
18216      attr(div, "aria-label", "Static column");
18217    },
18218    m(target, anchor) {
18219      insert(target, div, anchor);
18220    },
18221    p: noop,
18222    i: noop,
18223    o: noop,
18224    d(detaching) {
18225      if (detaching) {
18226        detach(div);
18227      }
18228    }
18229  };
18230}
18231let Padlock$1 = class Padlock extends SvelteComponent {
18232  constructor(options) {
18233    super();
18234    init(this, options, null, create_fragment$j, safe_not_equal, {});
18235  }
18236};
18237function create_fragment$i(ctx) {
18238  let svg;
18239  let path0;
18240  let path1;
18241  return {
18242    c() {
18243      svg = svg_element("svg");
18244      path0 = svg_element("path");
18245      path1 = svg_element("path");
18246      attr(path0, "d", "M4 8L8 4L12 8");
18247      attr(path0, "stroke", "currentColor");
18248      attr(path0, "stroke-width", "1.5");
18249      attr(path0, "stroke-linecap", "round");
18250      attr(path0, "stroke-linejoin", "round");
18251      attr(path1, "d", "M8 4V12");
18252      attr(path1, "stroke", "currentColor");
18253      attr(path1, "stroke-width", "1.5");
18254      attr(path1, "stroke-linecap", "round");
18255      attr(
18256        svg,
18257        "width",
18258        /*size*/
18259        ctx[0]
18260      );
18261      attr(
18262        svg,
18263        "height",
18264        /*size*/
18265        ctx[0]
18266      );
18267      attr(svg, "viewBox", "0 0 16 16");
18268      attr(svg, "fill", "none");
18269      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
18270    },
18271    m(target, anchor) {
18272      insert(target, svg, anchor);
18273      append(svg, path0);
18274      append(svg, path1);
18275    },
18276    p(ctx2, [dirty]) {
18277      if (dirty & /*size*/
18278      1) {
18279        attr(
18280          svg,
18281          "width",
18282          /*size*/
18283          ctx2[0]
18284        );
18285      }
18286      if (dirty & /*size*/
18287      1) {
18288        attr(
18289          svg,
18290          "height",
18291          /*size*/
18292          ctx2[0]
18293        );
18294      }
18295    },
18296    i: noop,
18297    o: noop,
18298    d(detaching) {
18299      if (detaching) {
18300        detach(svg);
18301      }
18302    }
18303  };
18304}
18305function instance$i($$self, $$props, $$invalidate) {
18306  let { size = 16 } = $$props;
18307  $$self.$$set = ($$props2) => {
18308    if ("size" in $$props2) $$invalidate(0, size = $$props2.size);
18309  };
18310  return [size];
18311}
18312let SortArrowUp$1 = class SortArrowUp extends SvelteComponent {
18313  constructor(options) {
18314    super();
18315    init(this, options, instance$i, create_fragment$i, safe_not_equal, { size: 0 });
18316  }
18317};
18318function create_fragment$h(ctx) {
18319  let svg;
18320  let path0;
18321  let path1;
18322  return {
18323    c() {
18324      svg = svg_element("svg");
18325      path0 = svg_element("path");
18326      path1 = svg_element("path");
18327      attr(path0, "d", "M4 8L8 12L12 8");
18328      attr(path0, "stroke", "currentColor");
18329      attr(path0, "stroke-width", "1.5");
18330      attr(path0, "stroke-linecap", "round");
18331      attr(path0, "stroke-linejoin", "round");
18332      attr(path1, "d", "M8 12V4");
18333      attr(path1, "stroke", "currentColor");
18334      attr(path1, "stroke-width", "1.5");
18335      attr(path1, "stroke-linecap", "round");
18336      attr(
18337        svg,
18338        "width",
18339        /*size*/
18340        ctx[0]
18341      );
18342      attr(
18343        svg,
18344        "height",
18345        /*size*/
18346        ctx[0]
18347      );
18348      attr(svg, "viewBox", "0 0 16 16");
18349      attr(svg, "fill", "none");
18350      attr(svg, "xmlns", "http://www.w3.org/2000/svg");
18351    },
18352    m(target, anchor) {
18353      insert(target, svg, anchor);
18354      append(svg, path0);
18355      append(svg, path1);
18356    },
18357    p(ctx2, [dirty]) {
18358      if (dirty & /*size*/
18359      1) {
18360        attr(
18361          svg,
18362          "width",
18363          /*size*/
18364          ctx2[0]
18365        );
18366      }
18367      if (dirty & /*size*/
18368      1) {
18369        attr(
18370          svg,
18371          "height",
18372          /*size*/
18373          ctx2[0]
18374        );
18375      }
18376    },
18377    i: noop,
18378    o: noop,
18379    d(detaching) {
18380      if (detaching) {
18381        detach(svg);
18382      }
18383    }
18384  };
18385}
18386function instance$h($$self, $$props, $$invalidate) {
18387  let { size = 16 } = $$props;
18388  $$self.$$set = ($$props2) => {
18389    if ("size" in $$props2) $$invalidate(0, size = $$props2.size);
18390  };
18391  return [size];
18392}
18393let SortArrowDown$1 = class SortArrowDown extends SvelteComponent {
18394  constructor(options) {
18395    super();
18396    init(this, options, instance$h, create_fragment$h, safe_not_equal, { size: 0 });
18397  }
18398};
18399function create_if_block_10(ctx) {
18400  let svg;
18401  let path0;
18402  let path1;
18403  let path2;
18404  let path3;
18405  return {
18406    c() {
18407      svg = svg_element("svg");
18408      path0 = svg_element("path");
18409      path1 = svg_element("path");
18410      path2 = svg_element("path");
18411      path3 = svg_element("path");
18412      attr(path0, "d", "M5 5H19");
18413      attr(path0, "stroke", "currentColor");
18414      attr(path0, "stroke-width", "2");
18415      attr(path0, "stroke-linecap", "round");
18416      attr(path1, "d", "M8 9H16");
18417      attr(path1, "stroke", "currentColor");
18418      attr(path1, "stroke-width", "2");
18419      attr(path1, "stroke-linecap", "round");
18420      attr(path2, "d", "M11 13H13");
18421      attr(path2, "stroke", "currentColor");
18422      attr(path2, "stroke-width", "2");
18423      attr(path2, "stroke-linecap", "round");
18424      attr(path3, "d", "M17 17L21 21M21 17L17 21");
18425      attr(path3, "stroke", "currentColor");
18426      attr(path3, "stroke-width", "2");
18427      attr(path3, "stroke-linecap", "round");
18428      attr(svg, "viewBox", "0 0 24 24");
18429      attr(svg, "width", "16");
18430      attr(svg, "height", "16");
18431    },
18432    m(target, anchor) {
18433      insert(target, svg, anchor);
18434      append(svg, path0);
18435      append(svg, path1);
18436      append(svg, path2);
18437      append(svg, path3);
18438    },
18439    d(detaching) {
18440      if (detaching) {
18441        detach(svg);
18442      }
18443    }
18444  };
18445}
18446function create_if_block_9$1(ctx) {
18447  let svg;
18448  let path0;
18449  let path1;
18450  let path2;
18451  return {
18452    c() {
18453      svg = svg_element("svg");
18454      path0 = svg_element("path");
18455      path1 = svg_element("path");
18456      path2 = svg_element("path");
18457      attr(path0, "d", "M5 5H19");
18458      attr(path0, "stroke", "currentColor");
18459      attr(path0, "stroke-width", "2");
18460      attr(path0, "stroke-linecap", "round");
18461      attr(path1, "d", "M8 9H16");
18462      attr(path1, "stroke", "currentColor");
18463      attr(path1, "stroke-width", "2");
18464      attr(path1, "stroke-linecap", "round");
18465      attr(path2, "d", "M11 13H13");
18466      attr(path2, "stroke", "currentColor");
18467      attr(path2, "stroke-width", "2");
18468      attr(path2, "stroke-linecap", "round");
18469      attr(svg, "viewBox", "0 0 24 24");
18470      attr(svg, "width", "16");
18471      attr(svg, "height", "16");
18472    },
18473    m(target, anchor) {
18474      insert(target, svg, anchor);
18475      append(svg, path0);
18476      append(svg, path1);
18477      append(svg, path2);
18478    },
18479    d(detaching) {
18480      if (detaching) {
18481        detach(svg);
18482      }
18483    }
18484  };
18485}
18486function create_if_block_8$2(ctx) {
18487  let svg;
18488  let path0;
18489  let path1;
18490  let path2;
18491  let path3;
18492  let path4;
18493  return {
18494    c() {
18495      svg = svg_element("svg");
18496      path0 = svg_element("path");
18497      path1 = svg_element("path");
18498      path2 = svg_element("path");
18499      path3 = svg_element("path");
18500      path4 = svg_element("path");
18501      attr(path0, "d", "M5 5H19");
18502      attr(path0, "stroke", "currentColor");
18503      attr(path0, "stroke-width", "2");
18504      attr(path0, "stroke-linecap", "round");
18505      attr(path1, "d", "M5 9H15");
18506      attr(path1, "stroke", "currentColor");
18507      attr(path1, "stroke-width", "2");
18508      attr(path1, "stroke-linecap", "round");
18509      attr(path2, "d", "M5 13H11");
18510      attr(path2, "stroke", "currentColor");
18511      attr(path2, "stroke-width", "2");
18512      attr(path2, "stroke-linecap", "round");
18513      attr(path3, "d", "M5 17H7");
18514      attr(path3, "stroke", "currentColor");
18515      attr(path3, "stroke-width", "2");
18516      attr(path3, "stroke-linecap", "round");
18517      attr(path4, "d", "M17 17L21 21M21 17L17 21");
18518      attr(path4, "stroke", "currentColor");
18519      attr(path4, "stroke-width", "2");
18520      attr(path4, "stroke-linecap", "round");
18521      attr(svg, "viewBox", "0 0 24 24");
18522      attr(svg, "width", "16");
18523      attr(svg, "height", "16");
18524    },
18525    m(target, anchor) {
18526      insert(target, svg, anchor);
18527      append(svg, path0);
18528      append(svg, path1);
18529      append(svg, path2);
18530      append(svg, path3);
18531      append(svg, path4);
18532    },
18533    d(detaching) {
18534      if (detaching) {
18535        detach(svg);
18536      }
18537    }
18538  };
18539}
18540function create_if_block_7$2(ctx) {
18541  let svg;
18542  let path0;
18543  let path1;
18544  let path2;
18545  return {
18546    c() {
vendor: 4,110 bytes, lines 18547-18699
18547      svg = svg_element("svg");
18548      path0 = svg_element("path");
18549      path1 = svg_element("path");
18550      path2 = svg_element("path");
18551      attr(path0, "d", "M8 12L12 16L16 12");
18552      attr(path0, "stroke", "currentColor");
18553      attr(path0, "stroke-width", "2");
18554      attr(path0, "fill", "none");
18555      attr(path0, "stroke-linecap", "round");
18556      attr(path0, "stroke-linejoin", "round");
18557      attr(path1, "d", "M12 16V9");
18558      attr(path1, "stroke", "currentColor");
18559      attr(path1, "stroke-width", "2");
18560      attr(path1, "stroke-linecap", "round");
18561      attr(path2, "d", "M5 5H19");
18562      attr(path2, "stroke", "currentColor");
18563      attr(path2, "stroke-width", "2");
18564      attr(path2, "stroke-linecap", "round");
18565      attr(svg, "viewBox", "0 0 24 24");
18566      attr(svg, "width", "16");
18567      attr(svg, "height", "16");
18568    },
18569    m(target, anchor) {
18570      insert(target, svg, anchor);
18571      append(svg, path0);
18572      append(svg, path1);
18573      append(svg, path2);
18574    },
18575    d(detaching) {
18576      if (detaching) {
18577        detach(svg);
18578      }
18579    }
18580  };
18581}
18582function create_if_block_6$5(ctx) {
18583  let svg;
18584  let path0;
18585  let path1;
18586  let path2;
18587  return {
18588    c() {
18589      svg = svg_element("svg");
18590      path0 = svg_element("path");
18591      path1 = svg_element("path");
18592      path2 = svg_element("path");
18593      attr(path0, "d", "M8 16L12 12L16 16");
18594      attr(path0, "stroke", "currentColor");
18595      attr(path0, "stroke-width", "2");
18596      attr(path0, "fill", "none");
18597      attr(path0, "stroke-linecap", "round");
18598      attr(path0, "stroke-linejoin", "round");
18599      attr(path1, "d", "M12 12V19");
18600      attr(path1, "stroke", "currentColor");
18601      attr(path1, "stroke-width", "2");
18602      attr(path1, "stroke-linecap", "round");
18603      attr(path2, "d", "M5 7H19");
18604      attr(path2, "stroke", "currentColor");
18605      attr(path2, "stroke-width", "2");
18606      attr(path2, "stroke-linecap", "round");
18607      attr(svg, "viewBox", "0 0 24 24");
18608      attr(svg, "width", "16");
18609      attr(svg, "height", "16");
18610    },
18611    m(target, anchor) {
18612      insert(target, svg, anchor);
18613      append(svg, path0);
18614      append(svg, path1);
18615      append(svg, path2);
18616    },
18617    d(detaching) {
18618      if (detaching) {
18619        detach(svg);
18620      }
18621    }
18622  };
18623}
18624function create_if_block_5$5(ctx) {
18625  let svg;
18626  let rect;
18627  let path;
18628  return {
18629    c() {
18630      svg = svg_element("svg");
18631      rect = svg_element("rect");
18632      path = svg_element("path");
18633      attr(rect, "x", "10");
18634      attr(rect, "y", "5");
18635      attr(rect, "width", "4");
18636      attr(rect, "height", "14");
18637      attr(rect, "stroke", "currentColor");
18638      attr(rect, "stroke-width", "2");
18639      attr(path, "d", "M7 8L17 16M17 8L7 16");
18640      attr(path, "stroke", "currentColor");
18641      attr(path, "stroke-width", "2");
18642      attr(path, "stroke-linecap", "round");
18643      attr(svg, "viewBox", "0 0 24 24");
18644      attr(svg, "width", "16");
18645      attr(svg, "height", "16");
18646    },
18647    m(target, anchor) {
18648      insert(target, svg, anchor);
18649      append(svg, rect);
18650      append(svg, path);
18651    },
18652    d(detaching) {
18653      if (detaching) {
18654        detach(svg);
18655      }
18656    }
18657  };
18658}
18659function create_if_block_4$5(ctx) {
18660  let svg;
18661  let rect;
18662  let path;
18663  return {
18664    c() {
18665      svg = svg_element("svg");
18666      rect = svg_element("rect");
18667      path = svg_element("path");
18668      attr(rect, "x", "5");
18669      attr(rect, "y", "10");
18670      attr(rect, "width", "14");
18671      attr(rect, "height", "4");
18672      attr(rect, "stroke", "currentColor");
18673      attr(rect, "stroke-width", "2");
18674      attr(path, "d", "M8 7L16 17M16 7L8 17");
18675      attr(path, "stroke", "currentColor");
18676      attr(path, "stroke-width", "2");
18677      attr(path, "stroke-linecap", "round");
18678      attr(svg, "viewBox", "0 0 24 24");
18679      attr(svg, "width", "16");
18680      attr(svg, "height", "16");
18681    },
18682    m(target, anchor) {
18683      insert(target, svg, anchor);
18684      append(svg, rect);
18685      append(svg, path);
18686    },
18687    d(detaching) {
18688      if (detaching) {
18689        detach(svg);
18690      }
18691    }
18692  };
18693}
18694function create_if_block_3$7(ctx) {
18695  let svg;
18696  let rect;
18697  let path;
18698  return {
18699    c() {
18700      svg = svg_element("svg");
18701      rect = svg_element("rect");
18702      path = svg_element("path");
18703      attr(rect, "x", "6");
18704      attr(rect, "y", "4");
18705      attr(rect, "width", "12");
18706      attr(rect, "height", "4");
18707      attr(rect, "stroke", "currentColor");
18708      attr(rect, "stroke-width", "2");
18709      attr(path, "d", "M12 12V19M8 16L12 19L16 16");
18710      attr(path, "stroke", "currentColor");
18711      attr(path, "stroke-width", "2");
18712      attr(path, "fill", "none");
18713      attr(path, "stroke-linecap", "round");
18714      attr(svg, "viewBox", "0 0 24 24");
18715      attr(svg, "width", "16");
18716      attr(svg, "height", "16");
18717    },
18718    m(target, anchor) {
18719      insert(target, svg, anchor);
18720      append(svg, rect);
18721      append(svg, path);
18722    },
18723    d(detaching) {
18724      if (detaching) {
18725        detach(svg);
18726      }
18727    }
18728  };
18729}
18730function create_if_block_2$8(ctx) {
18731  let svg;
18732  let rect;
18733  let path;
18734  return {
18735    c() {
18736      svg = svg_element("svg");
18737      rect = svg_element("rect");
18738      path = svg_element("path");
18739      attr(rect, "x", "6");
18740      attr(rect, "y", "16");
18741      attr(rect, "width", "12");
18742      attr(rect, "height", "4");
18743      attr(rect, "stroke", "currentColor");
18744      attr(rect, "stroke-width", "2");
18745      attr(path, "d", "M12 12V5M8 8L12 5L16 8");
18746      attr(path, "stroke", "currentColor");
18747      attr(path, "stroke-width", "2");
18748      attr(path, "fill", "none");
18749      attr(path, "stroke-linecap", "round");
18750      attr(svg, "viewBox", "0 0 24 24");
18751      attr(svg, "width", "16");
18752      attr(svg, "height", "16");
18753    },
18754    m(target, anchor) {
18755      insert(target, svg, anchor);
18756      append(svg, rect);
18757      append(svg, path);
18758    },
18759    d(detaching) {
18760      if (detaching) {
18761        detach(svg);
18762      }
18763    }
18764  };
18765}
18766function create_if_block_1$9(ctx) {
18767  let svg;
18768  let rect;
18769  let path;
18770  return {
18771    c() {
18772      svg = svg_element("svg");
18773      rect = svg_element("rect");
18774      path = svg_element("path");
18775      attr(rect, "x", "16");
18776      attr(rect, "y", "6");
18777      attr(rect, "width", "4");
18778      attr(rect, "height", "12");
18779      attr(rect, "stroke", "currentColor");
18780      attr(rect, "stroke-width", "2");
18781      attr(rect, "fill", "none");
18782      attr(path, "d", "M12 12H5M8 8L5 12L8 16");
18783      attr(path, "stroke", "currentColor");
18784      attr(path, "stroke-width", "2");
18785      attr(path, "fill", "none");
18786      attr(path, "stroke-linecap", "round");
18787      attr(svg, "viewBox", "0 0 24 24");
18788      attr(svg, "width", "16");
18789      attr(svg, "height", "16");
18790    },
18791    m(target, anchor) {
18792      insert(target, svg, anchor);
18793      append(svg, rect);
18794      append(svg, path);
18795    },
18796    d(detaching) {
18797      if (detaching) {
18798        detach(svg);
18799      }
18800    }
18801  };
18802}
18803function create_if_block$b(ctx) {
18804  let svg;
18805  let rect;
18806  let path;
18807  return {
18808    c() {
18809      svg = svg_element("svg");
18810      rect = svg_element("rect");
18811      path = svg_element("path");
18812      attr(rect, "x", "4");
18813      attr(rect, "y", "6");
18814      attr(rect, "width", "4");
18815      attr(rect, "height", "12");
18816      attr(rect, "stroke", "currentColor");
18817      attr(rect, "stroke-width", "2");
18818      attr(rect, "fill", "none");
18819      attr(path, "d", "M12 12H19M16 8L19 12L16 16");
18820      attr(path, "stroke", "currentColor");
18821      attr(path, "stroke-width", "2");
18822      attr(path, "fill", "none");
18823      attr(path, "stroke-linecap", "round");
18824      attr(svg, "viewBox", "0 0 24 24");
18825      attr(svg, "width", "16");
18826      attr(svg, "height", "16");
18827    },
18828    m(target, anchor) {
18829      insert(target, svg, anchor);
18830      append(svg, rect);
18831      append(svg, path);
18832    },
18833    d(detaching) {
18834      if (detaching) {
18835        detach(svg);
18836      }
18837    }
18838  };
18839}
18840function create_fragment$g(ctx) {
18841  let if_block_anchor;
18842  function select_block_type(ctx2, dirty) {
18843    if (
18844      /*icon*/
18845      ctx2[0] == "add-column-right"
18846    ) return create_if_block$b;
18847    if (
18848      /*icon*/
18849      ctx2[0] == "add-column-left"
18850    ) return create_if_block_1$9;
18851    if (
18852      /*icon*/
18853      ctx2[0] == "add-row-above"
18854    ) return create_if_block_2$8;
18855    if (
18856      /*icon*/
18857      ctx2[0] == "add-row-below"
18858    ) return create_if_block_3$7;
18859    if (
18860      /*icon*/
18861      ctx2[0] == "delete-row"
18862    ) return create_if_block_4$5;
18863    if (
18864      /*icon*/
18865      ctx2[0] == "delete-column"
18866    ) return create_if_block_5$5;
18867    if (
18868      /*icon*/
18869      ctx2[0] == "sort-asc"
18870    ) return create_if_block_6$5;
18871    if (
18872      /*icon*/
18873      ctx2[0] == "sort-desc"
18874    ) return create_if_block_7$2;
18875    if (
18876      /*icon*/
18877      ctx2[0] == "clear-sort"
18878    ) return create_if_block_8$2;
18879    if (
18880      /*icon*/
18881      ctx2[0] == "filter"
18882    ) return create_if_block_9$1;
18883    if (
18884      /*icon*/
18885      ctx2[0] == "clear-filter"
18886    ) return create_if_block_10;
18887  }
18888  let current_block_type = select_block_type(ctx);
18889  let if_block = current_block_type && current_block_type(ctx);
18890  return {
18891    c() {
18892      if (if_block) if_block.c();
18893      if_block_anchor = empty();
18894    },
18895    m(target, anchor) {
18896      if (if_block) if_block.m(target, anchor);
18897      insert(target, if_block_anchor, anchor);
18898    },
18899    p(ctx2, [dirty]) {
18900      if (current_block_type !== (current_block_type = select_block_type(ctx2))) {
18901        if (if_block) if_block.d(1);
18902        if_block = current_block_type && current_block_type(ctx2);
18903        if (if_block) {
18904          if_block.c();
18905          if_block.m(if_block_anchor.parentNode, if_block_anchor);
18906        }
18907      }
18908    },
18909    i: noop,
18910    o: noop,
18911    d(detaching) {
18912      if (detaching) {
18913        detach(if_block_anchor);
18914      }
18915      if (if_block) {
18916        if_block.d(detaching);
18917      }
18918    }
18919  };
18920}
18921function instance$g($$self, $$props, $$invalidate) {
18922  let { icon } = $$props;
18923  $$self.$$set = ($$props2) => {
18924    if ("icon" in $$props2) $$invalidate(0, icon = $$props2.icon);
18925  };
18926  return [icon];
18927}
18928let CellMenuIcons$1 = class CellMenuIcons extends SvelteComponent {
18929  constructor(options) {
18930    super();
18931    init(this, options, instance$g, create_fragment$g, safe_not_equal, { icon: 0 });
18932  }
18933};
18934function create_if_block_6$4(ctx) {
18935  let div;
18936  let basecheckbox;
18937  let current;
18938  let mounted;
18939  let dispose;
18940  basecheckbox = new Checkbox({
18941    props: {
18942      value: (
18943        /*select_all_state*/
18944        ctx[24] === "checked"
18945      ),
18946      indeterminate: (
18947        /*select_all_state*/
18948        ctx[24] === "indeterminate"
18949      ),
18950      label: "",
18951      interactive: true
18952    }
18953  });
18954  basecheckbox.$on(
18955    "select",
18956    /*select_handler*/
18957    ctx[33]
18958  );
18959  return {
18960    c() {
18961      div = element("div");
18962      create_component(basecheckbox.$$.fragment);
18963      attr(div, "class", "select-all-checkbox svelte-1fq485w");
18964      attr(div, "role", "button");
18965      attr(div, "tabindex", "0");
18966    },
18967    m(target, anchor) {
18968      insert(target, div, anchor);
18969      mount_component(basecheckbox, div, null);
18970      current = true;
18971      if (!mounted) {
18972        dispose = [
18973          listen(div, "click", stop_propagation(
18974            /*click_handler*/
18975            ctx[31]
18976          )),
18977          listen(div, "keydown", stop_propagation(keydown_handler)),
18978          listen(div, "mousedown", stop_propagation(
18979            /*mousedown_handler*/
18980            ctx[32]
18981          ))
18982        ];
18983        mounted = true;
18984      }
18985    },
18986    p(ctx2, dirty) {
18987      const basecheckbox_changes = {};
18988      if (dirty[0] & /*select_all_state*/
18989      16777216) basecheckbox_changes.value = /*select_all_state*/
18990      ctx2[24] === "checked";
18991      if (dirty[0] & /*select_all_state*/
18992      16777216) basecheckbox_changes.indeterminate = /*select_all_state*/
18993      ctx2[24] === "indeterminate";
18994      basecheckbox.$set(basecheckbox_changes);
18995    },
18996    i(local) {
18997      if (current) return;
18998      transition_in(basecheckbox.$$.fragment, local);
18999      current = true;
19000    },
19001    o(local) {
19002      transition_out(basecheckbox.$$.fragment, local);
19003      current = false;
19004    },
19005    d(detaching) {
19006      if (detaching) {
19007        detach(div);
19008      }
19009      destroy_component(basecheckbox);
19010      mounted = false;
19011      run_all(dispose);
19012    }
19013  };
19014}
19015function create_if_block_3$6(ctx) {
19016  let div;
19017  let span;
19018  let current_block_type_index;
19019  let if_block0;
19020  let t;
19021  let current;
19022  const if_block_creators = [create_if_block_5$4, create_else_block$3];
19023  const if_blocks = [];
19024  function select_block_type(ctx2, dirty) {
19025    if (
19026      /*current_direction*/
19027      ctx2[21] === "asc"
19028    ) return 0;
19029    return 1;
19030  }
19031  current_block_type_index = select_block_type(ctx);
19032  if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
19033  let if_block1 = (
19034    /*sort_columns*/
19035    ctx[11].length > 1 && create_if_block_4$4(ctx)
19036  );
19037  return {
19038    c() {
19039      div = element("div");
19040      span = element("span");
19041      if_block0.c();
19042      t = space();
19043      if (if_block1) if_block1.c();
19044      attr(span, "class", "sort-arrow svelte-1fq485w");
19045      attr(div, "class", "sort-indicators svelte-1fq485w");
19046    },
19047    m(target, anchor) {
19048      insert(target, div, anchor);
19049      append(div, span);
19050      if_blocks[current_block_type_index].m(span, null);
19051      append(div, t);
19052      if (if_block1) if_block1.m(div, null);
19053      current = true;
19054    },
19055    p(ctx2, dirty) {
19056      let previous_block_index = current_block_type_index;
19057      current_block_type_index = select_block_type(ctx2);
19058      if (current_block_type_index !== previous_block_index) {
19059        group_outros();
19060        transition_out(if_blocks[previous_block_index], 1, 1, () => {
19061          if_blocks[previous_block_index] = null;
19062        });
19063        check_outros();
19064        if_block0 = if_blocks[current_block_type_index];
19065        if (!if_block0) {
19066          if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
19067          if_block0.c();
19068        }
19069        transition_in(if_block0, 1);
19070        if_block0.m(span, null);
19071      }
19072      if (
19073        /*sort_columns*/
19074        ctx2[11].length > 1
19075      ) {
19076        if (if_block1) {
19077          if_block1.p(ctx2, dirty);
19078        } else {
19079          if_block1 = create_if_block_4$4(ctx2);
19080          if_block1.c();
19081          if_block1.m(div, null);
19082        }
19083      } else if (if_block1) {
19084        if_block1.d(1);
19085        if_block1 = null;
19086      }
19087    },
19088    i(local) {
19089      if (current) return;
19090      transition_in(if_block0);
19091      current = true;
19092    },
19093    o(local) {
19094      transition_out(if_block0);
19095      current = false;
19096    },
19097    d(detaching) {
19098      if (detaching) {
19099        detach(div);
19100      }
19101      if_blocks[current_block_type_index].d();
19102      if (if_block1) if_block1.d();
19103    }
19104  };
19105}
19106function create_else_block$3(ctx) {
19107  let sortarrowdown;
19108  let current;
19109  sortarrowdown = new SortArrowDown$1({ props: { size: 12 } });
19110  return {
19111    c() {
19112      create_component(sortarrowdown.$$.fragment);
19113    },
19114    m(target, anchor) {
19115      mount_component(sortarrowdown, target, anchor);
19116      current = true;
19117    },
19118    i(local) {
19119      if (current) return;
19120      transition_in(sortarrowdown.$$.fragment, local);
19121      current = true;
19122    },
19123    o(local) {
19124      transition_out(sortarrowdown.$$.fragment, local);
19125      current = false;
19126    },
19127    d(detaching) {
19128      destroy_component(sortarrowdown, detaching);
19129    }
19130  };
19131}
19132function create_if_block_5$4(ctx) {
19133  let sortarrowup;
19134  let current;
19135  sortarrowup = new SortArrowUp$1({ props: { size: 12 } });
19136  return {
19137    c() {
19138      create_component(sortarrowup.$$.fragment);
19139    },
19140    m(target, anchor) {
19141      mount_component(sortarrowup, target, anchor);
19142      current = true;
19143    },
19144    i(local) {
19145      if (current) return;
19146      transition_in(sortarrowup.$$.fragment, local);
19147      current = true;
19148    },
19149    o(local) {
19150      transition_out(sortarrowup.$$.fragment, local);
19151      current = false;
19152    },
19153    d(detaching) {
19154      destroy_component(sortarrowup, detaching);
19155    }
19156  };
19157}
19158function create_if_block_4$4(ctx) {
19159  let span;
19160  let t;
19161  return {
19162    c() {
19163      span = element("span");
19164      t = text(
19165        /*sort_priority*/
19166        ctx[22]
19167      );
19168      attr(span, "class", "sort-priority svelte-1fq485w");
19169    },
19170    m(target, anchor) {
19171      insert(target, span, anchor);
19172      append(span, t);
19173    },
19174    p(ctx2, dirty) {
19175      if (dirty[0] & /*sort_priority*/
19176      4194304) set_data(
19177        t,
19178        /*sort_priority*/
19179        ctx2[22]
19180      );
19181    },
19182    d(detaching) {
19183      if (detaching) {
19184        detach(span);
19185      }
19186    }
19187  };
19188}
19189function create_if_block_2$7(ctx) {
19190  let div;
19191  let span;
19192  let cellmenuicons;
19193  let current;
19194  cellmenuicons = new CellMenuIcons$1({ props: { icon: "filter" } });
19195  return {
19196    c() {
19197      div = element("div");
19198      span = element("span");
19199      create_component(cellmenuicons.$$.fragment);
19200      attr(span, "class", "filter-icon svelte-1fq485w");
19201      attr(div, "class", "filter-indicators svelte-1fq485w");
19202    },
19203    m(target, anchor) {
19204      insert(target, div, anchor);
19205      append(div, span);
19206      mount_component(cellmenuicons, span, null);
19207      current = true;
19208    },
19209    i(local) {
19210      if (current) return;
19211      transition_in(cellmenuicons.$$.fragment, local);
19212      current = true;
19213    },
19214    o(local) {
19215      transition_out(cellmenuicons.$$.fragment, local);
19216      current = false;
19217    },
19218    d(detaching) {
19219      if (detaching) {
19220        detach(div);
19221      }
19222      destroy_component(cellmenuicons);
19223    }
19224  };
19225}
19226function create_if_block_1$8(ctx) {
19227  let padlock;
19228  let current;
19229  padlock = new Padlock$1({});
19230  return {
19231    c() {
19232      create_component(padlock.$$.fragment);
19233    },
19234    m(target, anchor) {
19235      mount_component(padlock, target, anchor);
19236      current = true;
19237    },
19238    i(local) {
19239      if (current) return;
19240      transition_in(padlock.$$.fragment, local);
19241      current = true;
19242    },
19243    o(local) {
19244      transition_out(padlock.$$.fragment, local);
19245      current = false;
19246    },
19247    d(detaching) {
19248      destroy_component(padlock, detaching);
19249    }
19250  };
19251}
19252function create_if_block$a(ctx) {
19253  let cellmenubutton;
19254  let current;
19255  cellmenubutton = new CellMenuButton$1({ props: { on_click: (
19256    /*func*/
19257    ctx[38]
19258  ) } });
19259  return {
19260    c() {
19261      create_component(cellmenubutton.$$.fragment);
19262    },
19263    m(target, anchor) {
19264      mount_component(cellmenubutton, target, anchor);
19265      current = true;
19266    },
19267    p(ctx2, dirty) {
19268      const cellmenubutton_changes = {};
19269      if (dirty[0] & /*toggle_header_menu, i*/
19270      516) cellmenubutton_changes.on_click = /*func*/
19271      ctx2[38];
19272      cellmenubutton.$set(cellmenubutton_changes);
19273    },
19274    i(local) {
19275      if (current) return;
19276      transition_in(cellmenubutton.$$.fragment, local);
19277      current = true;
19278    },
19279    o(local) {
19280      transition_out(cellmenubutton.$$.fragment, local);
19281      current = false;
19282    },
19283    d(detaching) {
19284      destroy_component(cellmenubutton, detaching);
19285    }
19286  };
19287}
19288function create_fragment$f(ctx) {
19289  let th;
19290  let div1;
19291  let div0;
19292  let t0;
19293  let button;
19294  let editablecell;
19295  let updating_value;
19296  let updating_el;
19297  let t1;
19298  let t2;
19299  let t3;
19300  let t4;
19301  let th_aria_sort_value;
19302  let current;
19303  let mounted;
19304  let dispose;
19305  let if_block0 = (
19306    /*is_bool_column*/
19307    ctx[20] && /*editable*/
19308    ctx[15] && /*on_select_all*/
19309    ctx[18] && create_if_block_6$4(ctx)
19310  );
19311  function editablecell_value_binding(value) {
19312    ctx[34](value);
19313  }
19314  function editablecell_el_binding(value) {
19315    ctx[35](value);
19316  }
19317  let editablecell_props = {
19318    max_chars: (
19319      /*max_chars*/
19320      ctx[14]
19321    ),
19322    latex_delimiters: (
19323      /*latex_delimiters*/
19324      ctx[12]
19325    ),
19326    line_breaks: (
19327      /*line_breaks*/
19328      ctx[13]
19329    ),
19330    edit: (
19331      /*header_edit*/
19332      ctx[4] === /*i*/
19333      ctx[2]
19334    ),
19335    header: true,
19336    editable: (
19337      /*editable*/
19338      ctx[15]
19339    ),
19340    is_static: (
19341      /*is_static*/
19342      ctx[17]
19343    ),
19344    i18n: (
19345      /*i18n*/
19346      ctx[16]
19347    ),
19348    coords: [
19349      /*i*/
19350      ctx[2],
19351      0
19352    ]
19353  };
19354  if (
19355    /*value*/
19356    ctx[0] !== void 0
19357  ) {
19358    editablecell_props.value = /*value*/
19359    ctx[0];
19360  }
19361  if (
19362    /*el*/
19363    ctx[1] !== void 0
19364  ) {
19365    editablecell_props.el = /*el*/
19366    ctx[1];
19367  }
19368  editablecell = new EditableCell$1({ props: editablecell_props });
19369  binding_callbacks.push(() => bind(editablecell, "value", editablecell_value_binding));
19370  binding_callbacks.push(() => bind(editablecell, "el", editablecell_el_binding));
19371  editablecell.$on(
19372    "keydown",
19373    /*keydown_handler_1*/
19374    ctx[36]
19375  );
19376  let if_block1 = (
19377    /*sort_index*/
19378    ctx[19] !== -1 && create_if_block_3$6(ctx)
19379  );
19380  let if_block2 = (
19381    /*filter_index*/
19382    ctx[23] !== -1 && create_if_block_2$7()
19383  );
19384  let if_block3 = (
19385    /*is_static*/
19386    ctx[17] && create_if_block_1$8()
19387  );
19388  let if_block4 = (
19389    /*can_add_columns*/
19390    ctx[25] && create_if_block$a(ctx)
19391  );
19392  return {
19393    c() {
19394      th = element("th");
19395      div1 = element("div");
19396      div0 = element("div");
19397      if (if_block0) if_block0.c();
19398      t0 = space();
19399      button = element("button");
19400      create_component(editablecell.$$.fragment);
19401      t1 = space();
19402      if (if_block1) if_block1.c();
19403      t2 = space();
19404      if (if_block2) if_block2.c();
19405      t3 = space();
19406      if (if_block3) if_block3.c();
19407      t4 = space();
19408      if (if_block4) if_block4.c();
19409      attr(button, "class", "header-button svelte-1fq485w");
19410      attr(
19411        button,
19412        "title",
19413        /*value*/
19414        ctx[0]
19415      );
19416      attr(div0, "class", "header-content svelte-1fq485w");
19417      attr(div1, "class", "cell-wrap svelte-1fq485w");
19418      attr(th, "aria-sort", th_aria_sort_value = get_sort_status$1(
19419        /*value*/
19420        ctx[0],
19421        /*sort_columns*/
19422        ctx[11],
19423        /*headers*/
19424        ctx[6]
19425      ) === "none" ? "none" : get_sort_status$1(
19426        /*value*/
19427        ctx[0],
19428        /*sort_columns*/
19429        ctx[11],
19430        /*headers*/
19431        ctx[6]
19432      ) === "asc" ? "ascending" : "descending");
19433      set_style(
19434        th,
19435        "width",
19436        /*get_cell_width*/
19437        ctx[7](
19438          /*i*/
19439          ctx[2]
19440        )
19441      );
19442      set_style(
19443        th,
19444        "left",
19445        /*get_header_position*/
19446        ctx[26](
19447          /*i*/
19448          ctx[2]
19449        )
19450      );
19451      attr(
19452        th,
19453        "title",
19454        /*value*/
19455        ctx[0]
19456      );
19457      attr(th, "class", "svelte-1fq485w");
19458      toggle_class(
19459        th,
19460        "pinned-column",
19461        /*i*/
19462        ctx[2] < /*actual_pinned_columns*/
19463        ctx[3]
19464      );
19465      toggle_class(
19466        th,
19467        "last-pinned",
19468        /*i*/
19469        ctx[2] === /*actual_pinned_columns*/
19470        ctx[3] - 1
19471      );
19472      toggle_class(
19473        th,
19474        "focus",
19475        /*header_edit*/
19476        ctx[4] === /*i*/
19477        ctx[2] || /*selected_header*/
19478        ctx[5] === /*i*/
19479        ctx[2]
19480      );
19481      toggle_class(
19482        th,
19483        "sorted",
19484        /*sort_index*/
19485        ctx[19] !== -1
19486      );
19487      toggle_class(
19488        th,
19489        "filtered",
19490        /*filter_index*/
19491        ctx[23] !== -1
19492      );
19493    },
19494    m(target, anchor) {
19495      insert(target, th, anchor);
19496      append(th, div1);
19497      append(div1, div0);
19498      if (if_block0) if_block0.m(div0, null);
19499      append(div0, t0);
19500      append(div0, button);
19501      mount_component(editablecell, button, null);
19502      append(button, t1);
19503      if (if_block1) if_block1.m(button, null);
19504      append(button, t2);
19505      if (if_block2) if_block2.m(button, null);
19506      append(div0, t3);
19507      if (if_block3) if_block3.m(div0, null);
19508      append(div1, t4);
19509      if (if_block4) if_block4.m(div1, null);
19510      current = true;
19511      if (!mounted) {
19512        dispose = [
19513          listen(
19514            button,
19515            "click",
19516            /*click_handler_1*/
19517            ctx[37]
19518          ),
19519          listen(button, "mousedown", mousedown_handler_1),
19520          listen(
19521            th,
19522            "click",
19523            /*click_handler_2*/
19524            ctx[39]
19525          ),
19526          listen(th, "mousedown", mousedown_handler_2)
19527        ];
19528        mounted = true;
19529      }
19530    },
19531    p(ctx2, dirty) {
19532      if (
19533        /*is_bool_column*/
19534        ctx2[20] && /*editable*/
19535        ctx2[15] && /*on_select_all*/
19536        ctx2[18]
19537      ) {
19538        if (if_block0) {
19539          if_block0.p(ctx2, dirty);
19540          if (dirty[0] & /*is_bool_column, editable, on_select_all*/
19541          1343488) {
19542            transition_in(if_block0, 1);
19543          }
19544        } else {
19545          if_block0 = create_if_block_6$4(ctx2);
19546          if_block0.c();
19547          transition_in(if_block0, 1);
19548          if_block0.m(div0, t0);
19549        }
19550      } else if (if_block0) {
19551        group_outros();
19552        transition_out(if_block0, 1, 1, () => {
19553          if_block0 = null;
19554        });
19555        check_outros();
19556      }
19557      const editablecell_changes = {};
19558      if (dirty[0] & /*max_chars*/
19559      16384) editablecell_changes.max_chars = /*max_chars*/
19560      ctx2[14];
19561      if (dirty[0] & /*latex_delimiters*/
19562      4096) editablecell_changes.latex_delimiters = /*latex_delimiters*/
19563      ctx2[12];
19564      if (dirty[0] & /*line_breaks*/
19565      8192) editablecell_changes.line_breaks = /*line_breaks*/
19566      ctx2[13];
19567      if (dirty[0] & /*header_edit, i*/
19568      20) editablecell_changes.edit = /*header_edit*/
19569      ctx2[4] === /*i*/
19570      ctx2[2];
19571      if (dirty[0] & /*editable*/
19572      32768) editablecell_changes.editable = /*editable*/
19573      ctx2[15];
19574      if (dirty[0] & /*is_static*/
19575      131072) editablecell_changes.is_static = /*is_static*/
19576      ctx2[17];
19577      if (dirty[0] & /*i18n*/
19578      65536) editablecell_changes.i18n = /*i18n*/
19579      ctx2[16];
19580      if (dirty[0] & /*i*/
19581      4) editablecell_changes.coords = [
19582        /*i*/
19583        ctx2[2],
19584        0
19585      ];
19586      if (!updating_value && dirty[0] & /*value*/
19587      1) {
19588        updating_value = true;
19589        editablecell_changes.value = /*value*/
19590        ctx2[0];
19591        add_flush_callback(() => updating_value = false);
19592      }
19593      if (!updating_el && dirty[0] & /*el*/
19594      2) {
19595        updating_el = true;
19596        editablecell_changes.el = /*el*/
19597        ctx2[1];
19598        add_flush_callback(() => updating_el = false);
19599      }
19600      editablecell.$set(editablecell_changes);
19601      if (
19602        /*sort_index*/
19603        ctx2[19] !== -1
19604      ) {
19605        if (if_block1) {
19606          if_block1.p(ctx2, dirty);
19607          if (dirty[0] & /*sort_index*/
19608          524288) {
19609            transition_in(if_block1, 1);
19610          }
19611        } else {
19612          if_block1 = create_if_block_3$6(ctx2);
19613          if_block1.c();
19614          transition_in(if_block1, 1);
19615          if_block1.m(button, t2);
19616        }
19617      } else if (if_block1) {
19618        group_outros();
19619        transition_out(if_block1, 1, 1, () => {
19620          if_block1 = null;
19621        });
19622        check_outros();
19623      }
19624      if (
19625        /*filter_index*/
19626        ctx2[23] !== -1
19627      ) {
19628        if (if_block2) {
19629          if (dirty[0] & /*filter_index*/
19630          8388608) {
19631            transition_in(if_block2, 1);
19632          }
19633        } else {
19634          if_block2 = create_if_block_2$7();
19635          if_block2.c();
19636          transition_in(if_block2, 1);
19637          if_block2.m(button, null);
19638        }
19639      } else if (if_block2) {
19640        group_outros();
19641        transition_out(if_block2, 1, 1, () => {
19642          if_block2 = null;
19643        });
19644        check_outros();
19645      }
19646      if (!current || dirty[0] & /*value*/
19647      1) {
19648        attr(
19649          button,
19650          "title",
19651          /*value*/
19652          ctx2[0]
19653        );
19654      }
19655      if (
19656        /*is_static*/
19657        ctx2[17]
19658      ) {
19659        if (if_block3) {
19660          if (dirty[0] & /*is_static*/
19661          131072) {
19662            transition_in(if_block3, 1);
19663          }
19664        } else {
19665          if_block3 = create_if_block_1$8();
19666          if_block3.c();
19667          transition_in(if_block3, 1);
19668          if_block3.m(div0, null);
19669        }
19670      } else if (if_block3) {
19671        group_outros();
19672        transition_out(if_block3, 1, 1, () => {
19673          if_block3 = null;
19674        });
19675        check_outros();
19676      }
19677      if (
19678        /*can_add_columns*/
19679        ctx2[25]
19680      ) {
19681        if (if_block4) {
19682          if_block4.p(ctx2, dirty);
19683          if (dirty[0] & /*can_add_columns*/
19684          33554432) {
19685            transition_in(if_block4, 1);
19686          }
19687        } else {
19688          if_block4 = create_if_block$a(ctx2);
19689          if_block4.c();
19690          transition_in(if_block4, 1);
19691          if_block4.m(div1, null);
19692        }
19693      } else if (if_block4) {
19694        group_outros();
19695        transition_out(if_block4, 1, 1, () => {
19696          if_block4 = null;
19697        });
19698        check_outros();
19699      }
19700      if (!current || dirty[0] & /*value, sort_columns, headers*/
19701      2113 && th_aria_sort_value !== (th_aria_sort_value = get_sort_status$1(
19702        /*value*/
19703        ctx2[0],
19704        /*sort_columns*/
19705        ctx2[11],
19706        /*headers*/
19707        ctx2[6]
19708      ) === "none" ? "none" : get_sort_status$1(
19709        /*value*/
19710        ctx2[0],
19711        /*sort_columns*/
19712        ctx2[11],
19713        /*headers*/
19714        ctx2[6]
19715      ) === "asc" ? "ascending" : "descending")) {
19716        attr(th, "aria-sort", th_aria_sort_value);
19717      }
19718      if (!current || dirty[0] & /*get_cell_width, i*/
19719      132) {
19720        set_style(
19721          th,
19722          "width",
19723          /*get_cell_width*/
19724          ctx2[7](
19725            /*i*/
19726            ctx2[2]
19727          )
19728        );
19729      }
19730      if (!current || dirty[0] & /*i*/
19731      4) {
19732        set_style(
19733          th,
19734          "left",
19735          /*get_header_position*/
19736          ctx2[26](
19737            /*i*/
19738            ctx2[2]
19739          )
19740        );
19741      }
19742      if (!current || dirty[0] & /*value*/
19743      1) {
19744        attr(
19745          th,
19746          "title",
19747          /*value*/
19748          ctx2[0]
19749        );
19750      }
19751      if (!current || dirty[0] & /*i, actual_pinned_columns*/
19752      12) {
19753        toggle_class(
19754          th,
19755          "pinned-column",
19756          /*i*/
19757          ctx2[2] < /*actual_pinned_columns*/
19758          ctx2[3]
19759        );
19760      }
19761      if (!current || dirty[0] & /*i, actual_pinned_columns*/
19762      12) {
19763        toggle_class(
19764          th,
19765          "last-pinned",
19766          /*i*/
19767          ctx2[2] === /*actual_pinned_columns*/
19768          ctx2[3] - 1
19769        );
19770      }
19771      if (!current || dirty[0] & /*header_edit, i, selected_header*/
19772      52) {
19773        toggle_class(
19774          th,
19775          "focus",
19776          /*header_edit*/
19777          ctx2[4] === /*i*/
19778          ctx2[2] || /*selected_header*/
19779          ctx2[5] === /*i*/
19780          ctx2[2]
19781        );
19782      }
19783      if (!current || dirty[0] & /*sort_index*/
19784      524288) {
19785        toggle_class(
19786          th,
19787          "sorted",
19788          /*sort_index*/
19789          ctx2[19] !== -1
19790        );
19791      }
19792      if (!current || dirty[0] & /*filter_index*/
19793      8388608) {
19794        toggle_class(
19795          th,
19796          "filtered",
19797          /*filter_index*/
19798          ctx2[23] !== -1
19799        );
19800      }
19801    },
19802    i(local) {
19803      if (current) return;
19804      transition_in(if_block0);
19805      transition_in(editablecell.$$.fragment, local);
19806      transition_in(if_block1);
19807      transition_in(if_block2);
19808      transition_in(if_block3);
19809      transition_in(if_block4);
19810      current = true;
19811    },
19812    o(local) {
19813      transition_out(if_block0);
19814      transition_out(editablecell.$$.fragment, local);
19815      transition_out(if_block1);
19816      transition_out(if_block2);
19817      transition_out(if_block3);
19818      transition_out(if_block4);
19819      current = false;
19820    },
19821    d(detaching) {
19822      if (detaching) {
19823        detach(th);
19824      }
19825      if (if_block0) if_block0.d();
19826      destroy_component(editablecell);
19827      if (if_block1) if_block1.d();
19828      if (if_block2) if_block2.d();
19829      if (if_block3) if_block3.d();
19830      if (if_block4) if_block4.d();
19831      mounted = false;
19832      run_all(dispose);
19833    }
19834  };
19835}
19836const keydown_handler = (e) => {
19837  if (e.key === "Enter" || e.key === " ") {
19838    e.preventDefault();
19839  }
19840};
19841const mousedown_handler_1 = (event) => {
19842  event.preventDefault();
19843  event.stopPropagation();
19844};
19845const mousedown_handler_2 = (event) => {
19846  event.preventDefault();
19847  event.stopPropagation();
19848};
19849function instance$f($$self, $$props, $$invalidate) {
19850  let can_add_columns;
19851  let is_bool_column;
19852  let select_all_state;
19853  let sort_index;
19854  let filter_index;
19855  let sort_priority;
19856  let current_direction;
19857  let { value } = $$props;
19858  let { i } = $$props;
19859  let { datatype = "str" } = $$props;
19860  let { actual_pinned_columns } = $$props;
19861  let { header_edit } = $$props;
19862  let { selected_header } = $$props;
19863  let { headers } = $$props;
19864  let { get_cell_width: get_cell_width2 } = $$props;
19865  let { handle_header_click } = $$props;
19866  let { toggle_header_menu } = $$props;
19867  let { end_header_edit } = $$props;
19868  let { sort_columns = [] } = $$props;
19869  let { filter_columns = [] } = $$props;
19870  let { latex_delimiters } = $$props;
19871  let { line_breaks } = $$props;
19872  let { max_chars } = $$props;
19873  let { editable } = $$props;
19874  let { i18n } = $$props;
19875  let { el } = $$props;
19876  let { is_static } = $$props;
19877  let { col_count } = $$props;
19878  let { data = [] } = $$props;
19879  let { on_select_all = void 0 } = $$props;
19880  function get_header_position(col_index) {
19881    if (col_index >= actual_pinned_columns) {
19882      return "auto";
19883    }
19884    if (col_index === 0) {
19885      return "0";
19886    }
19887    const previous_widths = Array(col_index).fill(0).map((_, idx) => {
19888      return get_cell_width2(idx);
19889    }).join(" + ");
19890    return `calc(${previous_widths})`;
19891  }
19892  function click_handler(event) {
19893    bubble.call(this, $$self, event);
19894  }
19895  function mousedown_handler(event) {
19896    bubble.call(this, $$self, event);
19897  }
19898  const select_handler = () => {
19899    if (on_select_all) {
19900      const new_value = select_all_state !== "checked";
19901      on_select_all(i, new_value);
19902    }
19903  };
19904  function editablecell_value_binding(value$1) {
19905    value = value$1;
19906    $$invalidate(0, value);
19907  }
19908  function editablecell_el_binding(value2) {
19909    el = value2;
19910    $$invalidate(1, el);
19911  }
19912  const keydown_handler_1 = (event) => {
19913    if (event.detail.key === "Enter" || event.detail.key === "Escape" || event.detail.key === "Tab") {
19914      end_header_edit(event);
19915    }
19916  };
19917  const click_handler_1 = (event) => handle_header_click(event, i);
19918  const func2 = (event) => toggle_header_menu(event, i);
19919  const click_handler_2 = (event) => handle_header_click(event, i);
19920  $$self.$$set = ($$props2) => {
19921    if ("value" in $$props2) $$invalidate(0, value = $$props2.value);
19922    if ("i" in $$props2) $$invalidate(2, i = $$props2.i);
19923    if ("datatype" in $$props2) $$invalidate(27, datatype = $$props2.datatype);
19924    if ("actual_pinned_columns" in $$props2) $$invalidate(3, actual_pinned_columns = $$props2.actual_pinned_columns);
19925    if ("header_edit" in $$props2) $$invalidate(4, header_edit = $$props2.header_edit);
19926    if ("selected_header" in $$props2) $$invalidate(5, selected_header = $$props2.selected_header);
19927    if ("headers" in $$props2) $$invalidate(6, headers = $$props2.headers);
19928    if ("get_cell_width" in $$props2) $$invalidate(7, get_cell_width2 = $$props2.get_cell_width);
19929    if ("handle_header_click" in $$props2) $$invalidate(8, handle_header_click = $$props2.handle_header_click);
19930    if ("toggle_header_menu" in $$props2) $$invalidate(9, toggle_header_menu = $$props2.toggle_header_menu);
19931    if ("end_header_edit" in $$props2) $$invalidate(10, end_header_edit = $$props2.end_header_edit);
19932    if ("sort_columns" in $$props2) $$invalidate(11, sort_columns = $$props2.sort_columns);
19933    if ("filter_columns" in $$props2) $$invalidate(28, filter_columns = $$props2.filter_columns);
19934    if ("latex_delimiters" in $$props2) $$invalidate(12, latex_delimiters = $$props2.latex_delimiters);
19935    if ("line_breaks" in $$props2) $$invalidate(13, line_breaks = $$props2.line_breaks);
19936    if ("max_chars" in $$props2) $$invalidate(14, max_chars = $$props2.max_chars);
19937    if ("editable" in $$props2) $$invalidate(15, editable = $$props2.editable);
19938    if ("i18n" in $$props2) $$invalidate(16, i18n = $$props2.i18n);
19939    if ("el" in $$props2) $$invalidate(1, el = $$props2.el);
19940    if ("is_static" in $$props2) $$invalidate(17, is_static = $$props2.is_static);
19941    if ("col_count" in $$props2) $$invalidate(29, col_count = $$props2.col_count);
19942    if ("data" in $$props2) $$invalidate(30, data = $$props2.data);
19943    if ("on_select_all" in $$props2) $$invalidate(18, on_select_all = $$props2.on_select_all);
19944  };
19945  $$self.$$.update = () => {
19946    if ($$self.$$.dirty[0] & /*col_count*/
19947    536870912) {
19948      $$invalidate(25, can_add_columns = col_count && col_count[1] === "dynamic");
19949    }
19950    if ($$self.$$.dirty[0] & /*datatype*/
19951    134217728) {
19952      $$invalidate(20, is_bool_column = datatype === "bool");
19953    }
19954    if ($$self.$$.dirty[0] & /*is_bool_column, data, i*/
19955    1074790404) {
19956      $$invalidate(24, select_all_state = (() => {
19957        if (!is_bool_column || data.length === 0) return "unchecked";
19958        const true_count = data.filter((row) => {
19959          var _a, _b;
19960          return ((_a = row[i]) == null ? void 0 : _a.value) === true || ((_b = row[i]) == null ? void 0 : _b.value) === "true";
19961        }).length;
19962        if (true_count === 0) return "unchecked";
19963        if (true_count === data.length) return "checked";
19964        return "indeterminate";
19965      })());
19966    }
19967    if ($$self.$$.dirty[0] & /*sort_columns, i*/
19968    2052) {
19969      $$invalidate(19, sort_index = sort_columns.findIndex((item) => item.col === i));
19970    }
19971    if ($$self.$$.dirty[0] & /*filter_columns, i*/
19972    268435460) {
19973      $$invalidate(23, filter_index = filter_columns.findIndex((item) => item.col === i));
19974    }
19975    if ($$self.$$.dirty[0] & /*sort_index*/
19976    524288) {
19977      $$invalidate(22, sort_priority = sort_index !== -1 ? sort_index + 1 : null);
19978    }
19979    if ($$self.$$.dirty[0] & /*sort_index, sort_columns*/
19980    526336) {
19981      $$invalidate(21, current_direction = sort_index !== -1 ? sort_columns[sort_index].direction : null);
19982    }
19983  };
19984  return [
19985    value,
19986    el,
19987    i,
19988    actual_pinned_columns,
19989    header_edit,
19990    selected_header,
19991    headers,
19992    get_cell_width2,
19993    handle_header_click,
19994    toggle_header_menu,
19995    end_header_edit,
19996    sort_columns,
19997    latex_delimiters,
19998    line_breaks,
19999    max_chars,
20000    editable,
20001    i18n,
20002    is_static,
20003    on_select_all,
20004    sort_index,
20005    is_bool_column,
20006    current_direction,
20007    sort_priority,
20008    filter_index,
20009    select_all_state,
20010    can_add_columns,
20011    get_header_position,
20012    datatype,
20013    filter_columns,
20014    col_count,
20015    data,
20016    click_handler,
20017    mousedown_handler,
20018    select_handler,
20019    editablecell_value_binding,
20020    editablecell_el_binding,
20021    keydown_handler_1,
20022    click_handler_1,
20023    func2,
20024    click_handler_2
20025  ];
20026}
20027let TableHeader$1 = class TableHeader extends SvelteComponent {
20028  constructor(options) {
20029    super();
20030    init(
20031      this,
20032      options,
20033      instance$f,
20034      create_fragment$f,
20035      safe_not_equal,
20036      {
20037        value: 0,
20038        i: 2,
20039        datatype: 27,
20040        actual_pinned_columns: 3,
20041        header_edit: 4,
20042        selected_header: 5,
20043        headers: 6,
20044        get_cell_width: 7,
20045        handle_header_click: 8,
20046        toggle_header_menu: 9,
20047        end_header_edit: 10,
20048        sort_columns: 11,
20049        filter_columns: 28,
20050        latex_delimiters: 12,
20051        line_breaks: 13,
20052        max_chars: 14,
20053        editable: 15,
20054        i18n: 16,
20055        el: 1,
20056        is_static: 17,
20057        col_count: 29,
20058        data: 30,
20059        on_select_all: 18
20060      },
20061      null,
20062      [-1, -1]
20063    );
20064  }
20065};
20066function create_if_block$9(ctx) {
20067  let cellmenubutton;
20068  let current;
20069  cellmenubutton = new CellMenuButton$1({ props: { on_click: (
20070    /*func*/
20071    ctx[39]
20072  ) } });
20073  return {
20074    c() {
20075      create_component(cellmenubutton.$$.fragment);
20076    },
20077    m(target, anchor) {
20078      mount_component(cellmenubutton, target, anchor);
20079      current = true;
20080    },
20081    p(ctx2, dirty) {
20082      const cellmenubutton_changes = {};
20083      if (dirty[0] & /*toggle_cell_menu, index, j*/
20084      536) cellmenubutton_changes.on_click = /*func*/
20085      ctx2[39];
20086      cellmenubutton.$set(cellmenubutton_changes);
20087    },
20088    i(local) {
20089      if (current) return;
20090      transition_in(cellmenubutton.$$.fragment, local);
20091      current = true;
20092    },
20093    o(local) {
20094      transition_out(cellmenubutton.$$.fragment, local);
20095      current = false;
20096    },
20097    d(detaching) {
20098      destroy_component(cellmenubutton, detaching);
20099    }
20100  };
20101}
20102function create_fragment$e(ctx) {
20103  let td;
20104  let div;
20105  let editablecell;
20106  let updating_value;
20107  let updating_el;
20108  let t;
20109  let show_if = (
20110    /*editable*/
20111    ctx[19] && /*should_show_cell_menu*/
20112    ctx[10](
20113      [
20114        /*index*/
20115        ctx[3],
20116        /*j*/
20117        ctx[4]
20118      ],
20119      /*selected_cells*/
20120      ctx[0],
20121      /*editable*/
20122      ctx[19]
20123    )
20124  );
20125  let td_tabindex_value;
20126  let td_data_testid_value;
20127  let td_style_value;
20128  let current;
20129  let mounted;
20130  let dispose;
20131  function editablecell_value_binding(value) {
20132    ctx[36](value);
20133  }
20134  function editablecell_el_binding(value) {
20135    ctx[37](value);
20136  }
20137  let editablecell_props = {
20138    display_value: (
20139      /*display_value*/
20140      ctx[26] !== void 0 ? (
20141        /*display_value*/
20142        ctx[26]
20143      ) : String(
20144        /*value*/
20145        ctx[1]
20146      )
20147    ),
20148    latex_delimiters: (
20149      /*latex_delimiters*/
20150      ctx[14]
20151    ),
20152    line_breaks: (
20153      /*line_breaks*/
20154      ctx[15]
20155    ),
20156    editable: (
20157      /*editable*/
20158      ctx[19]
20159    ),
20160    is_static: (
20161      /*is_static*/
20162      ctx[20]
20163    ),
20164    edit: (
20165      /*editing*/
20166      ctx[17] && /*editing*/
20167      ctx[17][0] === /*index*/
20168      ctx[3] && /*editing*/
20169      ctx[17][1] === /*j*/
20170      ctx[4]
20171    ),
20172    datatype: (
20173      /*datatype*/
20174      ctx[16]
20175    ),
20176    max_chars: (
20177      /*max_chars*/
20178      ctx[18]
20179    ),
20180    i18n: (
20181      /*i18n*/
20182      ctx[21]
20183    ),
20184    components: (
20185      /*components*/
20186      ctx[22]
20187    ),
20188    show_selection_buttons: (
20189      /*selected_cells*/
20190      ctx[0].length === 1 && /*selected_cells*/
20191      ctx[0][0][0] === /*index*/
20192      ctx[3] && /*selected_cells*/
20193      ctx[0][0][1] === /*j*/
20194      ctx[4]
20195    ),
20196    coords: [
20197      /*index*/
20198      ctx[3],
20199      /*j*/
20200      ctx[4]
20201    ],
20202    on_select_column: (
20203      /*handle_select_column*/
20204      ctx[23]
20205    ),
20206    on_select_row: (
20207      /*handle_select_row*/
20208      ctx[24]
20209    ),
20210    is_dragging: (
20211      /*is_dragging*/
20212      ctx[25]
20213    ),
20214    wrap_text: (
20215      /*wrap*/
20216      ctx[27]
20217    )
20218  };
20219  if (
20220    /*value*/
20221    ctx[1] !== void 0
20222  ) {
20223    editablecell_props.value = /*value*/
20224    ctx[1];
20225  }
20226  if (
20227    /*el*/
20228    ctx[2].input !== void 0
20229  ) {
20230    editablecell_props.el = /*el*/
20231    ctx[2].input;
20232  }
20233  editablecell = new EditableCell$1({ props: editablecell_props });
20234  binding_callbacks.push(() => bind(editablecell, "value", editablecell_value_binding));
20235  binding_callbacks.push(() => bind(editablecell, "el", editablecell_el_binding));
20236  editablecell.$on(
20237    "focus",
20238    /*focus_handler*/
20239    ctx[38]
20240  );
20241  editablecell.$on("blur", function() {
20242    if (is_function(
20243      /*handle_blur*/
20244      ctx[8]
20245    )) ctx[8].apply(this, arguments);
20246  });
20247  let if_block = show_if && create_if_block$9(ctx);
20248  return {
20249    c() {
20250      td = element("td");
20251      div = element("div");
20252      create_component(editablecell.$$.fragment);
20253      t = space();
20254      if (if_block) if_block.c();
20255      attr(div, "class", "cell-wrap svelte-lcqe7p");
20256      attr(td, "tabindex", td_tabindex_value = /*j*/
20257      ctx[4] < /*actual_pinned_columns*/
20258      ctx[5] ? -1 : 0);
20259      attr(
20260        td,
20261        "data-row",
20262        /*index*/
20263        ctx[3]
20264      );
20265      attr(
20266        td,
20267        "data-col",
20268        /*j*/
20269        ctx[4]
20270      );
20271      attr(td, "data-testid", td_data_testid_value = `cell-${/*index*/
20272      ctx[3]}-${/*j*/
20273      ctx[4]}`);
20274      attr(td, "style", td_style_value = "width: " + /*get_cell_width*/
20275      ctx[6](
20276        /*j*/
20277        ctx[4]
20278      ) + "; left: " + /*get_cell_position*/
20279      ctx[33](
20280        /*j*/
20281        ctx[4]
20282      ) + "; " + /*styling*/
20283      (ctx[13] || ""));
20284      attr(td, "class", "svelte-lcqe7p");
20285      toggle_class(
20286        td,
20287        "pinned-column",
20288        /*j*/
20289        ctx[4] < /*actual_pinned_columns*/
20290        ctx[5]
20291      );
20292      toggle_class(
20293        td,
20294        "last-pinned",
20295        /*j*/
20296        ctx[4] === /*actual_pinned_columns*/
20297        ctx[5] - 1
20298      );
20299      toggle_class(
20300        td,
20301        "flash",
20302        /*copy_flash*/
20303        ctx[11] && /*is_in_selection*/
20304        ctx[32]
20305      );
20306      toggle_class(
20307        td,
20308        "cell-selected",
20309        /*is_in_selection*/
20310        ctx[32]
20311      );
20312      toggle_class(
20313        td,
20314        "no-top",
20315        /*has_no_top*/
20316        ctx[31]
20317      );
20318      toggle_class(
20319        td,
20320        "no-bottom",
20321        /*has_no_bottom*/
20322        ctx[30]
20323      );
20324      toggle_class(
20325        td,
20326        "no-left",
20327        /*has_no_left*/
20328        ctx[29]
20329      );
20330      toggle_class(
20331        td,
20332        "no-right",
20333        /*has_no_right*/
20334        ctx[28]
20335      );
20336      toggle_class(
20337        td,
20338        "menu-active",
20339        /*active_cell_menu*/
20340        ctx[12] && /*active_cell_menu*/
20341        ctx[12].row === /*index*/
20342        ctx[3] && /*active_cell_menu*/
20343        ctx[12].col === /*j*/
20344        ctx[4]
20345      );
20346      toggle_class(
20347        td,
20348        "dragging",
20349        /*is_dragging*/
20350        ctx[25]
20351      );
20352    },
20353    m(target, anchor) {
20354      insert(target, td, anchor);
20355      append(td, div);
20356      mount_component(editablecell, div, null);
20357      append(div, t);
20358      if (if_block) if_block.m(div, null);
20359      ctx[40](td);
20360      current = true;
20361      if (!mounted) {
20362        dispose = [
20363          listen(
20364            td,
20365            "mousedown",
20366            /*mousedown_handler*/
20367            ctx[41]
20368          ),
20369          listen(td, "contextmenu", prevent_default(
20370            /*contextmenu_handler*/
20371            ctx[42]
20372          ))
20373        ];
20374        mounted = true;
20375      }
20376    },
20377    p(new_ctx, dirty) {
20378      ctx = new_ctx;
20379      const editablecell_changes = {};
20380      if (dirty[0] & /*display_value, value*/
20381      67108866) editablecell_changes.display_value = /*display_value*/
20382      ctx[26] !== void 0 ? (
20383        /*display_value*/
20384        ctx[26]
20385      ) : String(
20386        /*value*/
20387        ctx[1]
20388      );
20389      if (dirty[0] & /*latex_delimiters*/
20390      16384) editablecell_changes.latex_delimiters = /*latex_delimiters*/
20391      ctx[14];
20392      if (dirty[0] & /*line_breaks*/
20393      32768) editablecell_changes.line_breaks = /*line_breaks*/
20394      ctx[15];
20395      if (dirty[0] & /*editable*/
20396      524288) editablecell_changes.editable = /*editable*/
20397      ctx[19];
20398      if (dirty[0] & /*is_static*/
20399      1048576) editablecell_changes.is_static = /*is_static*/
20400      ctx[20];
20401      if (dirty[0] & /*editing, index, j*/
20402      131096) editablecell_changes.edit = /*editing*/
20403      ctx[17] && /*editing*/
20404      ctx[17][0] === /*index*/
20405      ctx[3] && /*editing*/
20406      ctx[17][1] === /*j*/
20407      ctx[4];
20408      if (dirty[0] & /*datatype*/
20409      65536) editablecell_changes.datatype = /*datatype*/
20410      ctx[16];
20411      if (dirty[0] & /*max_chars*/
20412      262144) editablecell_changes.max_chars = /*max_chars*/
20413      ctx[18];
20414      if (dirty[0] & /*i18n*/
20415      2097152) editablecell_changes.i18n = /*i18n*/
20416      ctx[21];
20417      if (dirty[0] & /*components*/
20418      4194304) editablecell_changes.components = /*components*/
20419      ctx[22];
20420      if (dirty[0] & /*selected_cells, index, j*/
20421      25) editablecell_changes.show_selection_buttons = /*selected_cells*/
20422      ctx[0].length === 1 && /*selected_cells*/
20423      ctx[0][0][0] === /*index*/
20424      ctx[3] && /*selected_cells*/
20425      ctx[0][0][1] === /*j*/
20426      ctx[4];
20427      if (dirty[0] & /*index, j*/
20428      24) editablecell_changes.coords = [
20429        /*index*/
20430        ctx[3],
20431        /*j*/
20432        ctx[4]
20433      ];
20434      if (dirty[0] & /*handle_select_column*/
20435      8388608) editablecell_changes.on_select_column = /*handle_select_column*/
20436      ctx[23];
20437      if (dirty[0] & /*handle_select_row*/
20438      16777216) editablecell_changes.on_select_row = /*handle_select_row*/
20439      ctx[24];
20440      if (dirty[0] & /*is_dragging*/
20441      33554432) editablecell_changes.is_dragging = /*is_dragging*/
20442      ctx[25];
20443      if (dirty[0] & /*wrap*/
20444      134217728) editablecell_changes.wrap_text = /*wrap*/
20445      ctx[27];
20446      if (!updating_value && dirty[0] & /*value*/
20447      2) {
20448        updating_value = true;
20449        editablecell_changes.value = /*value*/
20450        ctx[1];
20451        add_flush_callback(() => updating_value = false);
20452      }
20453      if (!updating_el && dirty[0] & /*el*/
20454      4) {
20455        updating_el = true;
20456        editablecell_changes.el = /*el*/
20457        ctx[2].input;
20458        add_flush_callback(() => updating_el = false);
20459      }
20460      editablecell.$set(editablecell_changes);
20461      if (dirty[0] & /*editable, should_show_cell_menu, index, j, selected_cells*/
20462      525337) show_if = /*editable*/
20463      ctx[19] && /*should_show_cell_menu*/
20464      ctx[10](
20465        [
20466          /*index*/
20467          ctx[3],
20468          /*j*/
20469          ctx[4]
20470        ],
20471        /*selected_cells*/
20472        ctx[0],
20473        /*editable*/
20474        ctx[19]
20475      );
20476      if (show_if) {
20477        if (if_block) {
20478          if_block.p(ctx, dirty);
20479          if (dirty[0] & /*editable, should_show_cell_menu, index, j, selected_cells*/
20480          525337) {
20481            transition_in(if_block, 1);
20482          }
20483        } else {
20484          if_block = create_if_block$9(ctx);
20485          if_block.c();
20486          transition_in(if_block, 1);
20487          if_block.m(div, null);
20488        }
20489      } else if (if_block) {
20490        group_outros();
20491        transition_out(if_block, 1, 1, () => {
20492          if_block = null;
20493        });
20494        check_outros();
20495      }
20496      if (!current || dirty[0] & /*j, actual_pinned_columns*/
20497      48 && td_tabindex_value !== (td_tabindex_value = /*j*/
20498      ctx[4] < /*actual_pinned_columns*/
20499      ctx[5] ? -1 : 0)) {
20500        attr(td, "tabindex", td_tabindex_value);
20501      }
20502      if (!current || dirty[0] & /*index*/
20503      8) {
20504        attr(
20505          td,
20506          "data-row",
20507          /*index*/
20508          ctx[3]
20509        );
20510      }
20511      if (!current || dirty[0] & /*j*/
20512      16) {
20513        attr(
20514          td,
20515          "data-col",
20516          /*j*/
20517          ctx[4]
20518        );
20519      }
20520      if (!current || dirty[0] & /*index, j*/
20521      24 && td_data_testid_value !== (td_data_testid_value = `cell-${/*index*/
20522      ctx[3]}-${/*j*/
20523      ctx[4]}`)) {
20524        attr(td, "data-testid", td_data_testid_value);
20525      }
20526      if (!current || dirty[0] & /*get_cell_width, j, styling*/
20527      8272 && td_style_value !== (td_style_value = "width: " + /*get_cell_width*/
20528      ctx[6](
20529        /*j*/
20530        ctx[4]
20531      ) + "; left: " + /*get_cell_position*/
20532      ctx[33](
20533        /*j*/
20534        ctx[4]
20535      ) + "; " + /*styling*/
20536      (ctx[13] || ""))) {
20537        attr(td, "style", td_style_value);
20538      }
20539      if (!current || dirty[0] & /*j, actual_pinned_columns*/
20540      48) {
20541        toggle_class(
20542          td,
20543          "pinned-column",
20544          /*j*/
20545          ctx[4] < /*actual_pinned_columns*/
20546          ctx[5]
20547        );
20548      }
20549      if (!current || dirty[0] & /*j, actual_pinned_columns*/
20550      48) {
20551        toggle_class(
20552          td,
20553          "last-pinned",
20554          /*j*/
20555          ctx[4] === /*actual_pinned_columns*/
20556          ctx[5] - 1
20557        );
20558      }
20559      if (!current || dirty[0] & /*copy_flash*/
20560      2048 | dirty[1] & /*is_in_selection*/
20561      2) {
20562        toggle_class(
20563          td,
20564          "flash",
20565          /*copy_flash*/
20566          ctx[11] && /*is_in_selection*/
20567          ctx[32]
20568        );
20569      }
20570      if (!current || dirty[1] & /*is_in_selection*/
20571      2) {
20572        toggle_class(
20573          td,
20574          "cell-selected",
20575          /*is_in_selection*/
20576          ctx[32]
20577        );
20578      }
20579      if (!current || dirty[1] & /*has_no_top*/
20580      1) {
20581        toggle_class(
20582          td,
20583          "no-top",
20584          /*has_no_top*/
20585          ctx[31]
20586        );
20587      }
20588      if (!current || dirty[0] & /*has_no_bottom*/
20589      1073741824) {
20590        toggle_class(
20591          td,
20592          "no-bottom",
20593          /*has_no_bottom*/
20594          ctx[30]
20595        );
20596      }
20597      if (!current || dirty[0] & /*has_no_left*/
20598      536870912) {
20599        toggle_class(
20600          td,
20601          "no-left",
20602          /*has_no_left*/
20603          ctx[29]
20604        );
20605      }
20606      if (!current || dirty[0] & /*has_no_right*/
20607      268435456) {
20608        toggle_class(
20609          td,
20610          "no-right",
20611          /*has_no_right*/
20612          ctx[28]
20613        );
20614      }
20615      if (!current || dirty[0] & /*active_cell_menu, index, j*/
20616      4120) {
20617        toggle_class(
20618          td,
20619          "menu-active",
20620          /*active_cell_menu*/
20621          ctx[12] && /*active_cell_menu*/
20622          ctx[12].row === /*index*/
20623          ctx[3] && /*active_cell_menu*/
20624          ctx[12].col === /*j*/
20625          ctx[4]
20626        );
20627      }
20628      if (!current || dirty[0] & /*is_dragging*/
20629      33554432) {
20630        toggle_class(
20631          td,
20632          "dragging",
20633          /*is_dragging*/
20634          ctx[25]
20635        );
20636      }
20637    },
20638    i(local) {
20639      if (current) return;
20640      transition_in(editablecell.$$.fragment, local);
20641      transition_in(if_block);
20642      current = true;
20643    },
20644    o(local) {
20645      transition_out(editablecell.$$.fragment, local);
20646      transition_out(if_block);
20647      current = false;
20648    },
20649    d(detaching) {
20650      if (detaching) {
20651        detach(td);
20652      }
20653      destroy_component(editablecell);
20654      if (if_block) if_block.d();
20655      ctx[40](null);
20656      mounted = false;
20657      run_all(dispose);
20658    }
20659  };
20660}
20661function instance$e($$self, $$props, $$invalidate) {
20662  let cell_classes;
20663  let is_in_selection;
20664  let has_no_top;
20665  let has_no_bottom;
20666  let has_no_left;
20667  let has_no_right;
20668  let { value } = $$props;
20669  let { index } = $$props;
20670  let { j } = $$props;
20671  let { actual_pinned_columns } = $$props;
20672  let { get_cell_width: get_cell_width2 } = $$props;
20673  let { handle_cell_click } = $$props;
20674  let { handle_blur } = $$props;
20675  let { toggle_cell_menu } = $$props;
20676  let { is_cell_selected: is_cell_selected2 } = $$props;
20677  let { should_show_cell_menu: should_show_cell_menu2 } = $$props;
20678  let { selected_cells } = $$props;
20679  let { copy_flash } = $$props;
20680  let { active_cell_menu } = $$props;
20681  let { styling } = $$props;
20682  let { latex_delimiters } = $$props;
20683  let { line_breaks } = $$props;
20684  let { datatype } = $$props;
20685  let { editing } = $$props;
20686  let { max_chars } = $$props;
20687  let { editable } = $$props;
20688  let { is_static = false } = $$props;
20689  let { i18n } = $$props;
20690  let { components = {} } = $$props;
20691  let { el } = $$props;
20692  let { handle_select_column } = $$props;
20693  let { handle_select_row } = $$props;
20694  let { is_dragging } = $$props;
20695  let { display_value } = $$props;
20696  let { wrap = false } = $$props;
20697  function get_cell_position(col_index) {
20698    if (col_index >= actual_pinned_columns) {
20699      return "auto";
20700    }
20701    if (col_index === 0) {
20702      return "0";
20703    }
20704    const previous_widths = Array(col_index).fill(0).map((_, idx) => {
20705      return get_cell_width2(idx);
20706    }).join(" + ");
20707    return `calc(${previous_widths})`;
20708  }
20709  function editablecell_value_binding(value$1) {
20710    value = value$1;
20711    $$invalidate(1, value);
20712  }
20713  function editablecell_el_binding(value2) {
20714    if ($$self.$$.not_equal(el.input, value2)) {
20715      el.input = value2;
20716      $$invalidate(2, el);
20717    }
20718  }
20719  const focus_handler = () => {
20720    const row = index;
20721    const col = j;
20722    if (!selected_cells.some(([r, c]) => r === row && c === col)) {
20723      $$invalidate(0, selected_cells = [[row, col]]);
20724    }
20725  };
20726  const func2 = (event) => toggle_cell_menu(event, index, j);
20727  function td_binding($$value) {
20728    binding_callbacks[$$value ? "unshift" : "push"](() => {
20729      el.cell = $$value;
20730      $$invalidate(2, el);
20731    });
20732  }
20733  const mousedown_handler = (e) => handle_cell_click(e, index, j);
20734  const contextmenu_handler = (e) => toggle_cell_menu(e, index, j);
20735  $$self.$$set = ($$props2) => {
20736    if ("value" in $$props2) $$invalidate(1, value = $$props2.value);
20737    if ("index" in $$props2) $$invalidate(3, index = $$props2.index);
20738    if ("j" in $$props2) $$invalidate(4, j = $$props2.j);
20739    if ("actual_pinned_columns" in $$props2) $$invalidate(5, actual_pinned_columns = $$props2.actual_pinned_columns);
20740    if ("get_cell_width" in $$props2) $$invalidate(6, get_cell_width2 = $$props2.get_cell_width);
20741    if ("handle_cell_click" in $$props2) $$invalidate(7, handle_cell_click = $$props2.handle_cell_click);
20742    if ("handle_blur" in $$props2) $$invalidate(8, handle_blur = $$props2.handle_blur);
20743    if ("toggle_cell_menu" in $$props2) $$invalidate(9, toggle_cell_menu = $$props2.toggle_cell_menu);
20744    if ("is_cell_selected" in $$props2) $$invalidate(34, is_cell_selected2 = $$props2.is_cell_selected);
20745    if ("should_show_cell_menu" in $$props2) $$invalidate(10, should_show_cell_menu2 = $$props2.should_show_cell_menu);
20746    if ("selected_cells" in $$props2) $$invalidate(0, selected_cells = $$props2.selected_cells);
20747    if ("copy_flash" in $$props2) $$invalidate(11, copy_flash = $$props2.copy_flash);
20748    if ("active_cell_menu" in $$props2) $$invalidate(12, active_cell_menu = $$props2.active_cell_menu);
20749    if ("styling" in $$props2) $$invalidate(13, styling = $$props2.styling);
20750    if ("latex_delimiters" in $$props2) $$invalidate(14, latex_delimiters = $$props2.latex_delimiters);
20751    if ("line_breaks" in $$props2) $$invalidate(15, line_breaks = $$props2.line_breaks);
20752    if ("datatype" in $$props2) $$invalidate(16, datatype = $$props2.datatype);
20753    if ("editing" in $$props2) $$invalidate(17, editing = $$props2.editing);
20754    if ("max_chars" in $$props2) $$invalidate(18, max_chars = $$props2.max_chars);
20755    if ("editable" in $$props2) $$invalidate(19, editable = $$props2.editable);
20756    if ("is_static" in $$props2) $$invalidate(20, is_static = $$props2.is_static);
20757    if ("i18n" in $$props2) $$invalidate(21, i18n = $$props2.i18n);
20758    if ("components" in $$props2) $$invalidate(22, components = $$props2.components);
20759    if ("el" in $$props2) $$invalidate(2, el = $$props2.el);
20760    if ("handle_select_column" in $$props2) $$invalidate(23, handle_select_column = $$props2.handle_select_column);
20761    if ("handle_select_row" in $$props2) $$invalidate(24, handle_select_row = $$props2.handle_select_row);
20762    if ("is_dragging" in $$props2) $$invalidate(25, is_dragging = $$props2.is_dragging);
20763    if ("display_value" in $$props2) $$invalidate(26, display_value = $$props2.display_value);
20764    if ("wrap" in $$props2) $$invalidate(27, wrap = $$props2.wrap);
20765  };
20766  $$self.$$.update = () => {
20767    if ($$self.$$.dirty[0] & /*index, j, selected_cells*/
20768    25 | $$self.$$.dirty[1] & /*is_cell_selected*/
20769    8) {
20770      $$invalidate(35, cell_classes = is_cell_selected2([index, j], selected_cells || []));
20771    }
20772    if ($$self.$$.dirty[0] & /*index, j, selected_cells*/
20773    25) {
20774      $$invalidate(32, is_in_selection = is_cell_in_selection$1([index, j], selected_cells));
20775    }
20776    if ($$self.$$.dirty[1] & /*cell_classes*/
20777    16) {
20778      $$invalidate(31, has_no_top = cell_classes.includes("no-top"));
20779    }
20780    if ($$self.$$.dirty[1] & /*cell_classes*/
20781    16) {
20782      $$invalidate(30, has_no_bottom = cell_classes.includes("no-bottom"));
20783    }
20784    if ($$self.$$.dirty[1] & /*cell_classes*/
20785    16) {
20786      $$invalidate(29, has_no_left = cell_classes.includes("no-left"));
20787    }
20788    if ($$self.$$.dirty[1] & /*cell_classes*/
20789    16) {
20790      $$invalidate(28, has_no_right = cell_classes.includes("no-right"));
20791    }
20792  };
20793  return [
20794    selected_cells,
20795    value,
20796    el,
20797    index,
20798    j,
20799    actual_pinned_columns,
20800    get_cell_width2,
20801    handle_cell_click,
20802    handle_blur,
20803    toggle_cell_menu,
20804    should_show_cell_menu2,
20805    copy_flash,
20806    active_cell_menu,
20807    styling,
20808    latex_delimiters,
20809    line_breaks,
20810    datatype,
20811    editing,
20812    max_chars,
20813    editable,
20814    is_static,
20815    i18n,
20816    components,
20817    handle_select_column,
20818    handle_select_row,
20819    is_dragging,
20820    display_value,
20821    wrap,
20822    has_no_right,
20823    has_no_left,
20824    has_no_bottom,
20825    has_no_top,
20826    is_in_selection,
20827    get_cell_position,
20828    is_cell_selected2,
20829    cell_classes,
20830    editablecell_value_binding,
20831    editablecell_el_binding,
20832    focus_handler,
20833    func2,
20834    td_binding,
20835    mousedown_handler,
20836    contextmenu_handler
20837  ];
20838}
20839let TableCell$1 = class TableCell extends SvelteComponent {
20840  constructor(options) {
20841    super();
20842    init(
20843      this,
20844      options,
20845      instance$e,
20846      create_fragment$e,
20847      safe_not_equal,
20848      {
20849        value: 1,
20850        index: 3,
20851        j: 4,
20852        actual_pinned_columns: 5,
20853        get_cell_width: 6,
20854        handle_cell_click: 7,
20855        handle_blur: 8,
20856        toggle_cell_menu: 9,
20857        is_cell_selected: 34,
20858        should_show_cell_menu: 10,
20859        selected_cells: 0,
20860        copy_flash: 11,
20861        active_cell_menu: 12,
20862        styling: 13,
20863        latex_delimiters: 14,
20864        line_breaks: 15,
20865        datatype: 16,
20866        editing: 17,
20867        max_chars: 18,
20868        editable: 19,
20869        is_static: 20,
20870        i18n: 21,
20871        components: 22,
20872        el: 2,
20873        handle_select_column: 23,
20874        handle_select_row: 24,
20875        is_dragging: 25,
20876        display_value: 26,
20877        wrap: 27
20878      },
20879      null,
20880      [-1, -1]
20881    );
20882  }
20883};
20884function create_fragment$d(ctx) {
20885  let button;
20886  let mounted;
20887  let dispose;
20888  return {
20889    c() {
20890      button = element("button");
20891      button.textContent = "+";
20892      attr(button, "class", "add-row-button svelte-jmcozb");
20893      attr(button, "aria-label", "Add row");
20894    },
20895    m(target, anchor) {
20896      insert(target, button, anchor);
20897      if (!mounted) {
20898        dispose = listen(button, "click", function() {
20899          if (is_function(
20900            /*on_click*/
20901            ctx[0]
20902          )) ctx[0].apply(this, arguments);
20903        });
20904        mounted = true;
20905      }
20906    },
20907    p(new_ctx, [dirty]) {
20908      ctx = new_ctx;
20909    },
20910    i: noop,
20911    o: noop,
20912    d(detaching) {
20913      if (detaching) {
20914        detach(button);
20915      }
20916      mounted = false;
20917      dispose();
20918    }
20919  };
20920}
20921function instance$d($$self, $$props, $$invalidate) {
20922  let { on_click } = $$props;
20923  $$self.$$set = ($$props2) => {
20924    if ("on_click" in $$props2) $$invalidate(0, on_click = $$props2.on_click);
20925  };
20926  return [on_click];
20927}
20928let EmptyRowButton$1 = class EmptyRowButton extends SvelteComponent {
20929  constructor(options) {
20930    super();
20931    init(this, options, instance$d, create_fragment$d, safe_not_equal, { on_click: 0 });
20932  }
20933};
20934const get_tfoot_slot_changes = (dirty) => ({});
20935const get_tfoot_slot_context = (ctx) => ({});
20936function get_each_context$3(ctx, list2, i) {
20937  const child_ctx = ctx.slice();
20938  child_ctx[38] = list2[i];
20939  return child_ctx;
20940}
20941const get_tbody_slot_changes = (dirty) => ({
20942  item: dirty[0] & /*visible*/
20943  2048,
20944  index: dirty[0] & /*visible*/
20945  2048
20946});
20947const get_tbody_slot_context = (ctx) => ({
20948  item: (
20949    /*item*/
20950    ctx[38].data
20951  ),
20952  index: (
20953    /*item*/
20954    ctx[38].index
20955  )
20956});
20957const get_thead_slot_changes = (dirty) => ({});
20958const get_thead_slot_context = (ctx) => ({});
20959function create_if_block_1$7(ctx) {
20960  let caption;
20961  let t;
20962  return {
20963    c() {
20964      caption = element("caption");
20965      t = text(
20966        /*label*/
20967        ctx[3]
20968      );
20969      attr(caption, "class", "sr-only svelte-u825rv");
20970    },
20971    m(target, anchor) {
20972      insert(target, caption, anchor);
20973      append(caption, t);
20974    },
20975    p(ctx2, dirty) {
20976      if (dirty[0] & /*label*/
20977      8) set_data(
20978        t,
20979        /*label*/
20980        ctx2[3]
20981      );
20982    },
20983    d(detaching) {
20984      if (detaching) {
20985        detach(caption);
20986      }
20987    }
20988  };
20989}
20990function create_if_block$8(ctx) {
20991  let each_blocks = [];
20992  let each_1_lookup = /* @__PURE__ */ new Map();
20993  let each_1_anchor;
20994  let current;
20995  let each_value = ensure_array_like(
20996    /*visible*/
20997    ctx[11]
20998  );
20999  const get_key = (ctx2) => (
21000    /*item*/
21001    ctx2[38].data[0].id
21002  );
21003  for (let i = 0; i < each_value.length; i += 1) {
21004    let child_ctx = get_each_context$3(ctx, each_value, i);
21005    let key = get_key(child_ctx);
21006    each_1_lookup.set(key, each_blocks[i] = create_each_block$3(key, child_ctx));
21007  }
21008  return {
21009    c() {
21010      for (let i = 0; i < each_blocks.length; i += 1) {
21011        each_blocks[i].c();
21012      }
21013      each_1_anchor = empty();
21014    },
21015    m(target, anchor) {
21016      for (let i = 0; i < each_blocks.length; i += 1) {
21017        if (each_blocks[i]) {
21018          each_blocks[i].m(target, anchor);
21019        }
21020      }
21021      insert(target, each_1_anchor, anchor);
21022      current = true;
21023    },
21024    p(ctx2, dirty) {
21025      if (dirty[0] & /*$$scope, visible*/
21026      16779264) {
21027        each_value = ensure_array_like(
21028          /*visible*/
21029          ctx2[11]
21030        );
21031        group_outros();
21032        each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx2, each_value, each_1_lookup, each_1_anchor.parentNode, outro_and_destroy_block, create_each_block$3, each_1_anchor, get_each_context$3);
21033        check_outros();
21034      }
21035    },
21036    i(local) {
21037      if (current) return;
21038      for (let i = 0; i < each_value.length; i += 1) {
21039        transition_in(each_blocks[i]);
21040      }
21041      current = true;
21042    },
21043    o(local) {
21044      for (let i = 0; i < each_blocks.length; i += 1) {
21045        transition_out(each_blocks[i]);
21046      }
21047      current = false;
21048    },
21049    d(detaching) {
21050      if (detaching) {
21051        detach(each_1_anchor);
21052      }
21053      for (let i = 0; i < each_blocks.length; i += 1) {
21054        each_blocks[i].d(detaching);
21055      }
21056    }
21057  };
21058}
21059function fallback_block(ctx) {
21060  let tr;
21061  let t1;
21062  return {
21063    c() {
21064      tr = element("tr");
21065      tr.innerHTML = `<td class="svelte-u825rv">Missing Table Row</td>`;
21066      t1 = space();
21067      attr(tr, "class", "svelte-u825rv");
21068    },
21069    m(target, anchor) {
21070      insert(target, tr, anchor);
21071      insert(target, t1, anchor);
21072    },
21073    p: noop,
21074    d(detaching) {
21075      if (detaching) {
21076        detach(tr);
21077        detach(t1);
21078      }
21079    }
21080  };
21081}
21082function create_each_block$3(key_1, ctx) {
21083  let first;
21084  let current;
21085  const tbody_slot_template = (
21086    /*#slots*/
21087    ctx[25].tbody
21088  );
21089  const tbody_slot = create_slot(
21090    tbody_slot_template,
21091    ctx,
21092    /*$$scope*/
21093    ctx[24],
21094    get_tbody_slot_context
21095  );
21096  const tbody_slot_or_fallback = tbody_slot || fallback_block();
21097  return {
21098    key: key_1,
21099    first: null,
21100    c() {
21101      first = empty();
21102      if (tbody_slot_or_fallback) tbody_slot_or_fallback.c();
21103      this.first = first;
21104    },
21105    m(target, anchor) {
21106      insert(target, first, anchor);
21107      if (tbody_slot_or_fallback) {
21108        tbody_slot_or_fallback.m(target, anchor);
21109      }
21110      current = true;
21111    },
21112    p(new_ctx, dirty) {
21113      ctx = new_ctx;
21114      if (tbody_slot) {
21115        if (tbody_slot.p && (!current || dirty[0] & /*$$scope, visible*/
21116        16779264)) {
21117          update_slot_base(
21118            tbody_slot,
21119            tbody_slot_template,
21120            ctx,
21121            /*$$scope*/
21122            ctx[24],
21123            !current ? get_all_dirty_from_scope(
21124              /*$$scope*/
21125              ctx[24]
21126            ) : get_slot_changes(
21127              tbody_slot_template,
21128              /*$$scope*/
21129              ctx[24],
21130              dirty,
21131              get_tbody_slot_changes
21132            ),
21133            get_tbody_slot_context
21134          );
21135        }
21136      }
21137    },
21138    i(local) {
21139      if (current) return;
21140      transition_in(tbody_slot_or_fallback, local);
21141      current = true;
21142    },
21143    o(local) {
21144      transition_out(tbody_slot_or_fallback, local);
21145      current = false;
21146    },
21147    d(detaching) {
21148      if (detaching) {
21149        detach(first);
21150      }
21151      if (tbody_slot_or_fallback) tbody_slot_or_fallback.d(detaching);
21152    }
21153  };
21154}
21155function create_fragment$c(ctx) {
21156  let svelte_virtual_table_viewport;
21157  let div;
21158  let table;
21159  let t0;
21160  let thead;
21161  let thead_resize_listener;
21162  let t1;
21163  let tbody;
21164  let t2;
21165  let tfoot;
21166  let tfoot_resize_listener;
21167  let table_resize_listener;
21168  let current;
21169  let mounted;
21170  let dispose;
21171  let if_block0 = (
21172    /*label*/
21173    ctx[3] && /*label*/
21174    ctx[3].length !== 0 && create_if_block_1$7(ctx)
21175  );
21176  const thead_slot_template = (
21177    /*#slots*/
21178    ctx[25].thead
21179  );
21180  const thead_slot = create_slot(
21181    thead_slot_template,
21182    ctx,
21183    /*$$scope*/
21184    ctx[24],
21185    get_thead_slot_context
21186  );
21187  let if_block1 = (
21188    /*visible*/
21189    ctx[11].length && /*visible*/
21190    ctx[11][0].data.length && create_if_block$8(ctx)
21191  );
21192  const tfoot_slot_template = (
21193    /*#slots*/
21194    ctx[25].tfoot
21195  );
21196  const tfoot_slot = create_slot(
21197    tfoot_slot_template,
21198    ctx,
21199    /*$$scope*/
21200    ctx[24],
21201    get_tfoot_slot_context
21202  );
21203  return {
21204    c() {
21205      svelte_virtual_table_viewport = element("svelte-virtual-table-viewport");
21206      div = element("div");
21207      table = element("table");
21208      if (if_block0) if_block0.c();
21209      t0 = space();
21210      thead = element("thead");
21211      if (thead_slot) thead_slot.c();
21212      t1 = space();
21213      tbody = element("tbody");
21214      if (if_block1) if_block1.c();
21215      t2 = space();
21216      tfoot = element("tfoot");
21217      if (tfoot_slot) tfoot_slot.c();
21218      attr(thead, "class", "thead svelte-u825rv");
21219      add_render_callback(() => (
21220        /*thead_elementresize_handler*/
21221        ctx[26].call(thead)
21222      ));
21223      attr(tbody, "class", "tbody svelte-u825rv");
21224      attr(tfoot, "class", "tfoot svelte-u825rv");
21225      add_render_callback(() => (
21226        /*tfoot_elementresize_handler*/
21227        ctx[28].call(tfoot)
21228      ));
21229      attr(table, "class", "table svelte-u825rv");
21230      set_style(table, "height", height);
21231      set_style(
21232        table,
21233        "--bw-svt-p-top",
21234        /*top*/
21235        ctx[10] + "px"
21236      );
21237      set_style(
21238        table,
21239        "--bw-svt-p-bottom",
21240        /*bottom*/
21241        ctx[6] + "px"
21242      );
21243      set_style(
21244        table,
21245        "--bw-svt-head-height",
21246        /*head_height*/
21247        ctx[8] + "px"
21248      );
21249      set_style(
21250        table,
21251        "--bw-svt-foot-height",
21252        /*foot_height*/
21253        ctx[9] + "px"
21254      );
21255      set_style(
21256        table,
21257        "--bw-svt-avg-row-height",
21258        /*average_height*/
21259        ctx[4] + "px"
21260      );
21261      set_style(
21262        table,
21263        "--max-height",
21264        /*max_height*/
21265        ctx[1] + "px"
21266      );
21267      toggle_class(
21268        table,
21269        "disable-scroll",
21270        /*disable_scroll*/
21271        ctx[2]
21272      );
21273    },
21274    m(target, anchor) {
21275      insert(target, svelte_virtual_table_viewport, anchor);
21276      append(svelte_virtual_table_viewport, div);
21277      append(div, table);
21278      if (if_block0) if_block0.m(table, null);
21279      append(table, t0);
21280      append(table, thead);
21281      if (thead_slot) {
21282        thead_slot.m(thead, null);
21283      }
21284      thead_resize_listener = add_iframe_resize_listener(
21285        thead,
21286        /*thead_elementresize_handler*/
21287        ctx[26].bind(thead)
21288      );
21289      append(table, t1);
21290      append(table, tbody);
21291      if (if_block1) if_block1.m(tbody, null);
21292      ctx[27](tbody);
21293      append(table, t2);
21294      append(table, tfoot);
21295      if (tfoot_slot) {
21296        tfoot_slot.m(tfoot, null);
21297      }
21298      tfoot_resize_listener = add_iframe_resize_listener(
21299        tfoot,
21300        /*tfoot_elementresize_handler*/
21301        ctx[28].bind(tfoot)
21302      );
21303      ctx[29](table);
21304      table_resize_listener = resize_observer_content_box.observe(
21305        table,
21306        /*table_elementresizecontentbox_handler*/
21307        ctx[30].bind(table)
21308      );
21309      current = true;
21310      if (!mounted) {
21311        dispose = listen(
21312          table,
21313          "scroll",
21314          /*refresh_height_map*/
21315          ctx[12]
21316        );
21317        mounted = true;
21318      }
21319    },
21320    p(ctx2, dirty) {
21321      if (
21322        /*label*/
21323        ctx2[3] && /*label*/
21324        ctx2[3].length !== 0
21325      ) {
21326        if (if_block0) {
21327          if_block0.p(ctx2, dirty);
21328        } else {
21329          if_block0 = create_if_block_1$7(ctx2);
21330          if_block0.c();
21331          if_block0.m(table, t0);
21332        }
21333      } else if (if_block0) {
21334        if_block0.d(1);
21335        if_block0 = null;
21336      }
21337      if (thead_slot) {
21338        if (thead_slot.p && (!current || dirty[0] & /*$$scope*/
21339        16777216)) {
21340          update_slot_base(
21341            thead_slot,
21342            thead_slot_template,
21343            ctx2,
21344            /*$$scope*/
21345            ctx2[24],
21346            !current ? get_all_dirty_from_scope(
21347              /*$$scope*/
21348              ctx2[24]
21349            ) : get_slot_changes(
21350              thead_slot_template,
21351              /*$$scope*/
21352              ctx2[24],
21353              dirty,
21354              get_thead_slot_changes
21355            ),
21356            get_thead_slot_context
21357          );
21358        }
21359      }
21360      if (
21361        /*visible*/
21362        ctx2[11].length && /*visible*/
21363        ctx2[11][0].data.length
21364      ) {
21365        if (if_block1) {
21366          if_block1.p(ctx2, dirty);
21367          if (dirty[0] & /*visible*/
21368          2048) {
21369            transition_in(if_block1, 1);
21370          }
21371        } else {
21372          if_block1 = create_if_block$8(ctx2);
21373          if_block1.c();
21374          transition_in(if_block1, 1);
21375          if_block1.m(tbody, null);
21376        }
21377      } else if (if_block1) {
21378        group_outros();
21379        transition_out(if_block1, 1, 1, () => {
21380          if_block1 = null;
21381        });
21382        check_outros();
21383      }
21384      if (tfoot_slot) {
21385        if (tfoot_slot.p && (!current || dirty[0] & /*$$scope*/
21386        16777216)) {
21387          update_slot_base(
21388            tfoot_slot,
21389            tfoot_slot_template,
21390            ctx2,
21391            /*$$scope*/
21392            ctx2[24],
21393            !current ? get_all_dirty_from_scope(
21394              /*$$scope*/
21395              ctx2[24]
21396            ) : get_slot_changes(
21397              tfoot_slot_template,
21398              /*$$scope*/
21399              ctx2[24],
21400              dirty,
21401              get_tfoot_slot_changes
21402            ),
21403            get_tfoot_slot_context
21404          );
21405        }
21406      }
21407      if (!current || dirty[0] & /*top*/
21408      1024) {
21409        set_style(
21410          table,
21411          "--bw-svt-p-top",
21412          /*top*/
21413          ctx2[10] + "px"
21414        );
21415      }
21416      if (!current || dirty[0] & /*bottom*/
21417      64) {
21418        set_style(
21419          table,
21420          "--bw-svt-p-bottom",
21421          /*bottom*/
21422          ctx2[6] + "px"
21423        );
21424      }
21425      if (!current || dirty[0] & /*head_height*/
21426      256) {
21427        set_style(
21428          table,
21429          "--bw-svt-head-height",
21430          /*head_height*/
21431          ctx2[8] + "px"
21432        );
21433      }
21434      if (!current || dirty[0] & /*foot_height*/
21435      512) {
21436        set_style(
21437          table,
21438          "--bw-svt-foot-height",
21439          /*foot_height*/
21440          ctx2[9] + "px"
21441        );
21442      }
21443      if (!current || dirty[0] & /*average_height*/
21444      16) {
21445        set_style(
21446          table,
21447          "--bw-svt-avg-row-height",
21448          /*average_height*/
21449          ctx2[4] + "px"
21450        );
21451      }
21452      if (!current || dirty[0] & /*max_height*/
21453      2) {
21454        set_style(
21455          table,
21456          "--max-height",
21457          /*max_height*/
21458          ctx2[1] + "px"
21459        );
21460      }
21461      if (!current || dirty[0] & /*disable_scroll*/
21462      4) {
21463        toggle_class(
21464          table,
21465          "disable-scroll",
21466          /*disable_scroll*/
21467          ctx2[2]
21468        );
21469      }
21470    },
21471    i(local) {
21472      if (current) return;
21473      transition_in(thead_slot, local);
21474      transition_in(if_block1);
21475      transition_in(tfoot_slot, local);
21476      current = true;
21477    },
21478    o(local) {
21479      transition_out(thead_slot, local);
21480      transition_out(if_block1);
21481      transition_out(tfoot_slot, local);
21482      current = false;
21483    },
21484    d(detaching) {
21485      if (detaching) {
21486        detach(svelte_virtual_table_viewport);
21487      }
21488      if (if_block0) if_block0.d();
21489      if (thead_slot) thead_slot.d(detaching);
21490      thead_resize_listener();
21491      if (if_block1) if_block1.d();
21492      ctx[27](null);
21493      if (tfoot_slot) tfoot_slot.d(detaching);
21494      tfoot_resize_listener();
21495      ctx[29](null);
21496      table_resize_listener();
21497      mounted = false;
21498      dispose();
21499    }
21500  };
21501}
21502let height = "100%";
21503function instance$c($$self, $$props, $$invalidate) {
21504  let sortedItems;
21505  let { $$slots: slots = {}, $$scope } = $$props;
21506  let { items: items2 = [] } = $$props;
21507  let { max_height } = $$props;
21508  let { actual_height } = $$props;
21509  let { table_scrollbar_width } = $$props;
21510  let { start = 0 } = $$props;
21511  let { end = 20 } = $$props;
21512  let { selected } = $$props;
21513  let { disable_scroll = false } = $$props;
21514  let { show_scroll_button = false } = $$props;
21515  let { viewport } = $$props;
21516  let { label = null } = $$props;
21517  createEventDispatcher();
21518  let average_height = 30;
21519  let bottom = 0;
21520  let contents;
21521  let head_height = 0;
21522  let foot_height = 0;
21523  let height_map = [];
21524  let mounted;
21525  let rows;
21526  let top = 0;
21527  let viewport_height = 200;
21528  let visible = [];
21529  let viewport_box;
21530  const is_browser2 = typeof window !== "undefined";
21531  const raf2 = is_browser2 ? window.requestAnimationFrame : (cb) => cb();
21532  async function refresh_height_map() {
21533    if (!viewport) {
21534      return;
21535    }
21536    if (sortedItems.length < start) {
21537      await scroll_to_index(sortedItems.length - 1, { behavior: "auto" });
21538    }
21539    const scrollTop = Math.max(0, viewport.scrollTop);
21540    $$invalidate(17, show_scroll_button = scrollTop > 100);
21541    $$invalidate(16, table_scrollbar_width = viewport.offsetWidth - viewport.clientWidth);
21542    for (let v = 0; v < rows.length; v += 1) {
21543      height_map[start + v] = rows[v].getBoundingClientRect().height;
21544    }
21545    let i = 0;
21546    let y = head_height;
21547    while (i < sortedItems.length) {
21548      const row_height = height_map[i] || average_height;
21549      if (y + row_height > scrollTop - max_height) {
21550        $$invalidate(13, start = i);
21551        $$invalidate(10, top = y - head_height);
21552        break;
21553      }
21554      y += row_height;
21555      i += 1;
21556    }
21557    let content_height = head_height;
21558    while (i < sortedItems.length) {
21559      const row_height = height_map[i] || average_height;
21560      content_height += row_height;
21561      i += 1;
21562      if (content_height - head_height > 3 * max_height) {
21563        break;
21564      }
21565    }
21566    $$invalidate(14, end = i);
21567    const remaining = sortedItems.length - end;
21568    const scrollbar_height = viewport.offsetHeight - viewport.clientHeight;
21569    if (scrollbar_height > 0) {
21570      content_height += scrollbar_height;
21571    }
21572    let filtered_height_map = height_map.filter((v) => typeof v === "number");
21573    $$invalidate(4, average_height = filtered_height_map.reduce((a, b) => a + b, 0) / filtered_height_map.length || 30);
21574    $$invalidate(6, bottom = remaining * average_height);
21575    if (!isFinite(bottom)) {
21576      $$invalidate(6, bottom = 2e5);
21577    }
21578    height_map.length = sortedItems.length;
21579    while (i < sortedItems.length) {
21580      i += 1;
21581      height_map[i] = average_height;
21582    }
21583    if (max_height && content_height > max_height) {
21584      $$invalidate(15, actual_height = max_height);
21585    } else {
21586      $$invalidate(15, actual_height = content_height);
21587    }
21588  }
21589  async function scroll_and_render(n) {
21590    raf2(async () => {
21591      if (typeof n !== "number") return;
21592      const direction = typeof n !== "number" ? false : is_in_view(n);
21593      if (direction === true) {
21594        return;
21595      }
21596      if (direction === "back") {
21597        await scroll_to_index(n, { behavior: "instant" });
21598      }
21599      if (direction === "forwards") {
21600        await scroll_to_index(n, { behavior: "instant" }, true);
21601      }
21602    });
21603  }
21604  function is_in_view(n) {
21605    const current = rows && rows[n - start];
21606    if (!current && n < start) {
21607      return "back";
21608    }
21609    if (!current && n >= end - 1) {
21610      return "forwards";
21611    }
21612    const { top: viewport_top } = viewport.getBoundingClientRect();
21613    const { top: top2, bottom: bottom2 } = current.getBoundingClientRect();
21614    if (top2 - viewport_top < 37) {
21615      return "back";
21616    }
21617    if (bottom2 - viewport_top > viewport_height) {
21618      return "forwards";
21619    }
21620    return true;
21621  }
21622  async function scroll_to_index(index, opts, align_end = false) {
21623    await tick();
21624    const _itemHeight = average_height;
21625    let distance = index * _itemHeight;
21626    if (align_end) {
21627      distance = distance - viewport_height + _itemHeight + head_height;
21628    }
21629    const scrollbar_height = viewport.offsetHeight - viewport.clientHeight;
21630    if (scrollbar_height > 0) {
21631      distance += scrollbar_height;
21632    }
21633    const _opts = {
21634      top: distance,
21635      behavior: "smooth",
21636      ...opts
21637    };
21638    viewport.scrollTo(_opts);
21639  }
21640  onMount(() => {
21641    rows = contents.children;
21642    $$invalidate(21, mounted = true);
21643  });
21644  function thead_elementresize_handler() {
21645    head_height = this.offsetHeight;
21646    $$invalidate(8, head_height);
21647  }
21648  function tbody_binding($$value) {
21649    binding_callbacks[$$value ? "unshift" : "push"](() => {
21650      contents = $$value;
21651      $$invalidate(7, contents);
21652    });
21653  }
21654  function tfoot_elementresize_handler() {
21655    foot_height = this.offsetHeight;
21656    $$invalidate(9, foot_height);
21657  }
21658  function table_binding($$value) {
21659    binding_callbacks[$$value ? "unshift" : "push"](() => {
21660      viewport = $$value;
21661      $$invalidate(0, viewport);
21662    });
21663  }
21664  function table_elementresizecontentbox_handler() {
21665    var _a;
21666    viewport_box = (_a = ResizeObserverSingleton.entries.get(this)) == null ? void 0 : _a.contentRect;
21667    $$invalidate(5, viewport_box);
21668  }
21669  $$self.$$set = ($$props2) => {
21670    if ("items" in $$props2) $$invalidate(18, items2 = $$props2.items);
21671    if ("max_height" in $$props2) $$invalidate(1, max_height = $$props2.max_height);
21672    if ("actual_height" in $$props2) $$invalidate(15, actual_height = $$props2.actual_height);
21673    if ("table_scrollbar_width" in $$props2) $$invalidate(16, table_scrollbar_width = $$props2.table_scrollbar_width);
21674    if ("start" in $$props2) $$invalidate(13, start = $$props2.start);
21675    if ("end" in $$props2) $$invalidate(14, end = $$props2.end);
21676    if ("selected" in $$props2) $$invalidate(19, selected = $$props2.selected);
21677    if ("disable_scroll" in $$props2) $$invalidate(2, disable_scroll = $$props2.disable_scroll);
21678    if ("show_scroll_button" in $$props2) $$invalidate(17, show_scroll_button = $$props2.show_scroll_button);
21679    if ("viewport" in $$props2) $$invalidate(0, viewport = $$props2.viewport);
21680    if ("label" in $$props2) $$invalidate(3, label = $$props2.label);
21681    if ("$$scope" in $$props2) $$invalidate(24, $$scope = $$props2.$$scope);
21682  };
21683  $$self.$$.update = () => {
21684    if ($$self.$$.dirty[0] & /*viewport_box*/
21685    32) {
21686      $$invalidate(22, viewport_height = (viewport_box == null ? void 0 : viewport_box.height) || 200);
21687    }
21688    if ($$self.$$.dirty[0] & /*items*/
21689    262144) {
21690      $$invalidate(23, sortedItems = items2);
21691    }
21692    if ($$self.$$.dirty[0] & /*mounted, viewport_height, viewport, sortedItems*/
21693    14680065) {
21694      {
21695        if (mounted && viewport_height && viewport.offsetParent) {
21696          raf2(refresh_height_map);
21697        }
21698      }
21699    }
21700    if ($$self.$$.dirty[0] & /*selected*/
21701    524288) {
21702      scroll_and_render(selected);
21703    }
21704    if ($$self.$$.dirty[0] & /*sortedItems, start, end, max_height, average_height*/
21705    8413202) {
21706      $$invalidate(11, visible = is_browser2 ? sortedItems.slice(start, end).map((data, i) => {
21707        return { index: i + start, data };
21708      }) : sortedItems.slice(0, max_height / sortedItems.length * average_height + 1).map((data, i) => {
21709        return { index: i + start, data };
21710      }));
21711    }
21712  };
21713  return [
21714    viewport,
21715    max_height,
21716    disable_scroll,
21717    label,
21718    average_height,
21719    viewport_box,
21720    bottom,
21721    contents,
21722    head_height,
21723    foot_height,
21724    top,
21725    visible,
21726    refresh_height_map,
21727    start,
21728    end,
21729    actual_height,
21730    table_scrollbar_width,
21731    show_scroll_button,
21732    items2,
21733    selected,
21734    scroll_to_index,
21735    mounted,
21736    viewport_height,
21737    sortedItems,
21738    $$scope,
21739    slots,
21740    thead_elementresize_handler,
21741    tbody_binding,
21742    tfoot_elementresize_handler,
21743    table_binding,
21744    table_elementresizecontentbox_handler
21745  ];
21746}
21747let VirtualTable$1 = class VirtualTable extends SvelteComponent {
21748  constructor(options) {
21749    super();
21750    init(
21751      this,
21752      options,
21753      instance$c,
21754      create_fragment$c,
21755      safe_not_equal,
21756      {
21757        items: 18,
21758        max_height: 1,
21759        actual_height: 15,
21760        table_scrollbar_width: 16,
21761        start: 13,
21762        end: 14,
21763        selected: 19,
21764        disable_scroll: 2,
21765        show_scroll_button: 17,
21766        viewport: 0,
21767        label: 3,
21768        scroll_to_index: 20
21769      },
21770      null,
21771      [-1, -1]
21772    );
21773  }
21774  get scroll_to_index() {
21775    return this.$$.ctx[20];
21776  }
21777};
21778function get_each_context$2(ctx, list2, i) {
21779  const child_ctx = ctx.slice();
21780  child_ctx[15] = list2[i];
21781  return child_ctx;
21782}
21783function create_if_block$7(ctx) {
21784  let div;
21785  let each_value = ensure_array_like(
21786    /*filter_options*/
21787    ctx[6][
21788      /*datatype*/
21789      ctx[2]
21790    ]
21791  );
21792  let each_blocks = [];
21793  for (let i = 0; i < each_value.length; i += 1) {
21794    each_blocks[i] = create_each_block$2(get_each_context$2(ctx, each_value, i));
21795  }
21796  return {
21797    c() {
21798      div = element("div");
21799      for (let i = 0; i < each_blocks.length; i += 1) {
21800        each_blocks[i].c();
21801      }
21802      attr(div, "class", "dropdown-filter-options svelte-1p5crt7");
21803    },
21804    m(target, anchor) {
21805      insert(target, div, anchor);
21806      for (let i = 0; i < each_blocks.length; i += 1) {
21807        if (each_blocks[i]) {
21808          each_blocks[i].m(div, null);
21809        }
21810      }
21811    },
21812    p(ctx2, dirty) {
21813      if (dirty & /*current_filter, filter_options, datatype, filter_dropdown_open*/
21814      92) {
21815        each_value = ensure_array_like(
21816          /*filter_options*/
21817          ctx2[6][
21818            /*datatype*/
21819            ctx2[2]
21820          ]
21821        );
21822        let i;
21823        for (i = 0; i < each_value.length; i += 1) {
21824          const child_ctx = get_each_context$2(ctx2, each_value, i);
21825          if (each_blocks[i]) {
21826            each_blocks[i].p(child_ctx, dirty);
21827          } else {
21828            each_blocks[i] = create_each_block$2(child_ctx);
21829            each_blocks[i].c();
21830            each_blocks[i].m(div, null);
21831          }
21832        }
21833        for (; i < each_blocks.length; i += 1) {
21834          each_blocks[i].d(1);
21835        }
21836        each_blocks.length = each_value.length;
21837      }
21838    },
21839    d(detaching) {
21840      if (detaching) {
21841        detach(div);
21842      }
21843      destroy_each(each_blocks, detaching);
21844    }
21845  };
21846}
21847function create_each_block$2(ctx) {
21848  let button;
21849  let t0_value = (
21850    /*opt*/
21851    ctx[15] + ""
21852  );
21853  let t0;
21854  let t1;
21855  let mounted;
21856  let dispose;
21857  function click_handler_3() {
21858    return (
21859      /*click_handler_3*/
21860      ctx[11](
21861        /*opt*/
21862        ctx[15]
21863      )
21864    );
21865  }
21866  return {
21867    c() {
21868      button = element("button");
21869      t0 = text(t0_value);
21870      t1 = space();
21871      attr(button, "class", "filter-option svelte-1p5crt7");
21872    },
21873    m(target, anchor) {
21874      insert(target, button, anchor);
21875      append(button, t0);
21876      append(button, t1);
21877      if (!mounted) {
21878        dispose = listen(button, "click", stop_propagation(click_handler_3));
21879        mounted = true;
21880      }
21881    },
21882    p(new_ctx, dirty) {
21883      ctx = new_ctx;
21884      if (dirty & /*datatype*/
21885      4 && t0_value !== (t0_value = /*opt*/
21886      ctx[15] + "")) set_data(t0, t0_value);
21887    },
21888    d(detaching) {
21889      if (detaching) {
21890        detach(button);
21891      }
21892      mounted = false;
21893      dispose();
21894    }
21895  };
21896}
21897function create_fragment$b(ctx) {
21898  let div5;
21899  let div0;
21900  let t0;
21901  let div4;
21902  let div1;
21903  let span;
21904  let t2;
21905  let button0;
21906  let t3;
21907  let button0_aria_label_value;
21908  let t4;
21909  let div3;
21910  let div2;
21911  let button1;
21912  let t5;
21913  let t6;
21914  let dropdownarrow;
21915  let button1_aria_label_value;
21916  let t7;
21917  let t8;
21918  let input;
21919  let t9;
21920  let button2;
21921  let check;
21922  let current;
21923  let mounted;
21924  let dispose;
21925  dropdownarrow = new DropdownArrow({});
21926  let if_block = (
21927    /*filter_dropdown_open*/
21928    ctx[4] && create_if_block$7(ctx)
21929  );
21930  check = new Check({});
21931  return {
21932    c() {
21933      div5 = element("div");
21934      div0 = element("div");
21935      t0 = space();
21936      div4 = element("div");
21937      div1 = element("div");
21938      span = element("span");
21939      span.textContent = "Filter as";
21940      t2 = space();
21941      button0 = element("button");
21942      t3 = text(
21943        /*datatype*/
21944        ctx[2]
21945      );
21946      t4 = space();
21947      div3 = element("div");
21948      div2 = element("div");
21949      button1 = element("button");
21950      t5 = text(
21951        /*current_filter*/
21952        ctx[3]
21953      );
21954      t6 = space();
21955      create_component(dropdownarrow.$$.fragment);
21956      t7 = space();
21957      if (if_block) if_block.c();
21958      t8 = space();
21959      input = element("input");
21960      t9 = space();
21961      button2 = element("button");
21962      create_component(check.$$.fragment);
21963      attr(div0, "class", "background svelte-1p5crt7");
21964      attr(span, "class", "svelte-1p5crt7");
21965      attr(button0, "aria-label", button0_aria_label_value = `Change filter type. Filtering ${/*datatype*/
21966      ctx[2]}s`);
21967      attr(button0, "class", "svelte-1p5crt7");
21968      attr(div1, "class", "filter-datatype-container svelte-1p5crt7");
21969      attr(button1, "aria-label", button1_aria_label_value = `Change filter. Using '${/*current_filter*/
21970      ctx[3]}'`);
21971      attr(button1, "class", "svelte-1p5crt7");
21972      attr(div2, "class", "filter-dropdown");
21973      attr(input, "type", "text");
21974      input.value = /*filter_input_value*/
21975      ctx[5];
21976      attr(input, "placeholder", "Type a value");
21977      attr(input, "class", "filter-input svelte-1p5crt7");
21978      attr(div3, "class", "input-container svelte-1p5crt7");
21979      attr(button2, "class", "check-button svelte-1p5crt7");
21980      attr(div4, "class", "filter-menu svelte-1p5crt7");
21981    },
21982    m(target, anchor) {
21983      insert(target, div5, anchor);
21984      append(div5, div0);
21985      append(div5, t0);
21986      append(div5, div4);
21987      append(div4, div1);
21988      append(div1, span);
21989      append(div1, t2);
21990      append(div1, button0);
21991      append(button0, t3);
21992      append(div4, t4);
21993      append(div4, div3);
21994      append(div3, div2);
21995      append(div2, button1);
21996      append(button1, t5);
21997      append(button1, t6);
21998      mount_component(dropdownarrow, button1, null);
21999      append(div2, t7);
22000      if (if_block) if_block.m(div2, null);
22001      append(div3, t8);
22002      append(div3, input);
22003      append(div4, t9);
22004      append(div4, button2);
22005      mount_component(check, button2, null);
22006      ctx[13](div4);
22007      current = true;
22008      if (!mounted) {
22009        dispose = [
22010          listen(button0, "click", stop_propagation(
22011            /*click_handler_1*/
22012            ctx[9]
22013          )),
22014          listen(button1, "click", stop_propagation(
22015            /*click_handler_2*/
22016            ctx[10]
22017          )),
22018          listen(input, "click", stop_propagation(
22019            /*click_handler*/
22020            ctx[8]
22021          )),
22022          listen(
22023            input,
22024            "input",
22025            /*handle_filter_input*/
22026            ctx[7]
22027          ),
22028          listen(
22029            button2,
22030            "click",
22031            /*click_handler_4*/
22032            ctx[12]
22033          )
22034        ];
22035        mounted = true;
22036      }
22037    },
22038    p(ctx2, [dirty]) {
22039      if (!current || dirty & /*datatype*/
22040      4) set_data(
22041        t3,
22042        /*datatype*/
22043        ctx2[2]
22044      );
22045      if (!current || dirty & /*datatype*/
22046      4 && button0_aria_label_value !== (button0_aria_label_value = `Change filter type. Filtering ${/*datatype*/
22047      ctx2[2]}s`)) {
22048        attr(button0, "aria-label", button0_aria_label_value);
22049      }
22050      if (!current || dirty & /*current_filter*/
22051      8) set_data(
22052        t5,
22053        /*current_filter*/
22054        ctx2[3]
22055      );
22056      if (!current || dirty & /*current_filter*/
22057      8 && button1_aria_label_value !== (button1_aria_label_value = `Change filter. Using '${/*current_filter*/
22058      ctx2[3]}'`)) {
22059        attr(button1, "aria-label", button1_aria_label_value);
22060      }
22061      if (
22062        /*filter_dropdown_open*/
22063        ctx2[4]
22064      ) {
22065        if (if_block) {
22066          if_block.p(ctx2, dirty);
22067        } else {
22068          if_block = create_if_block$7(ctx2);
22069          if_block.c();
22070          if_block.m(div2, null);
22071        }
22072      } else if (if_block) {
22073        if_block.d(1);
22074        if_block = null;
22075      }
22076      if (!current || dirty & /*filter_input_value*/
22077      32 && input.value !== /*filter_input_value*/
22078      ctx2[5]) {
22079        input.value = /*filter_input_value*/
22080        ctx2[5];
22081      }
22082    },
22083    i(local) {
22084      if (current) return;
22085      transition_in(dropdownarrow.$$.fragment, local);
22086      transition_in(check.$$.fragment, local);
22087      current = true;
22088    },
22089    o(local) {
22090      transition_out(dropdownarrow.$$.fragment, local);
22091      transition_out(check.$$.fragment, local);
22092      current = false;
22093    },
22094    d(detaching) {
22095      if (detaching) {
22096        detach(div5);
22097      }
22098      destroy_component(dropdownarrow);
22099      if (if_block) if_block.d();
22100      destroy_component(check);
22101      ctx[13](null);
22102      mounted = false;
22103      run_all(dispose);
22104    }
22105  };
22106}
22107function instance$b($$self, $$props, $$invalidate) {
22108  let { on_filter = () => {
22109  } } = $$props;
22110  let menu_element;
22111  let datatype = "string";
22112  let current_filter = "Contains";
22113  let filter_dropdown_open = false;
22114  let filter_input_value = "";
22115  const filter_options = {
22116    string: [
22117      "Contains",
22118      "Does not contain",
22119      "Starts with",
22120      "Ends with",
22121      "Is",
22122      "Is not",
22123      "Is empty",
22124      "Is not empty"
22125    ],
22126    number: ["=", "≠", ">", "<", "≥", "≤", "Is empty", "Is not empty"]
22127  };
22128  onMount(() => {
22129    position_menu();
22130  });
22131  function position_menu() {
22132    if (!menu_element) return;
22133    const viewport_width = window.innerWidth;
22134    const viewport_height = window.innerHeight;
22135    const menu_rect = menu_element.getBoundingClientRect();
22136    const x = (viewport_width - menu_rect.width) / 2;
22137    const y = (viewport_height - menu_rect.height) / 2;
22138    $$invalidate(1, menu_element.style.left = `${x}px`, menu_element);
22139    $$invalidate(1, menu_element.style.top = `${y}px`, menu_element);
22140  }
22141  function handle_filter_input(e) {
22142    const target = e.target;
22143    $$invalidate(5, filter_input_value = target.value);
22144  }
22145  function click_handler(event) {
22146    bubble.call(this, $$self, event);
22147  }
22148  const click_handler_1 = () => {
22149    $$invalidate(2, datatype = datatype === "string" ? "number" : "string");
22150    $$invalidate(3, current_filter = filter_options[datatype][0]);
22151  };
22152  const click_handler_2 = () =>
22152 $$invalidate(4, filter_dropdown_open = !filter_dropdown_open);
22153  const click_handler_3 = (opt) => {
22154    $$invalidate(3, current_filter = opt);
22155    $$invalidate(4, filter_dropdown_open = !filter_dropdown_open);
22156  };
22157  const click_handler_4 = () => on_filter(datatype, current_filter, filter_input_value);
22158  function div4_binding($$value) {
22159    binding_callbacks[$$value ? "unshift" : "push"](() => {
22160      menu_element = $$value;
22161      $$invalidate(1, menu_element);
22162    });
22163  }
22164  $$self.$$set = ($$props2) => {
22165    if ("on_filter" in $$props2) $$invalidate(0, on_filter = $$props2.on_filter);
22166  };
22167  return [
22168    on_filter,
22169    menu_element,
22170    datatype,
22171    current_filter,
22172    filter_dropdown_open,
22173    filter_input_value,
22174    filter_options,
22175    handle_filter_input,
22176    click_handler,
22177    click_handler_1,
22178    click_handler_2,
22179    click_handler_3,
22180    click_handler_4,
22181    div4_binding
22182  ];
22183}
22184let FilterMenu$1 = class FilterMenu extends SvelteComponent {
22185  constructor(options) {
22186    super();
22187    init(this, options, instance$b, create_fragment$b, safe_not_equal, { on_filter: 0 });
22188  }
22189};
22190function create_if_block_5$3(ctx) {
22191  let button0;
22192  let cellmenuicons0;
22193  let t0;
22194  let t1_value = (
22195    /*i18n*/
22196    ctx[15]("dataframe.sort_ascending") + ""
22197  );
22198  let t1;
22199  let t2;
22200  let t3;
22201  let button1;
22202  let cellmenuicons1;
22203  let t4;
22204  let t5_value = (
22205    /*i18n*/
22206    ctx[15]("dataframe.sort_descending") + ""
22207  );
22208  let t5;
22209  let t6;
22210  let t7;
22211  let button2;
22212  let cellmenuicons2;
22213  let t8;
22214  let t9_value = (
22215    /*i18n*/
22216    ctx[15]("dataframe.clear_sort") + ""
22217  );
22218  let t9;
22219  let t10;
22220  let button3;
22221  let cellmenuicons3;
22222  let t11;
22223  let t12_value = (
22224    /*i18n*/
22225    ctx[15]("dataframe.filter") + ""
22226  );
22227  let t12;
22228  let t13;
22229  let t14;
22230  let button4;
22231  let cellmenuicons4;
22232  let t15;
22233  let t16_value = (
22234    /*i18n*/
22235    ctx[15]("dataframe.clear_filter") + ""
22236  );
22237  let t16;
22238  let current;
22239  let mounted;
22240  let dispose;
22241  cellmenuicons0 = new CellMenuIcons$1({ props: { icon: "sort-asc" } });
22242  let if_block0 = (
22243    /*sort_direction*/
22244    ctx[10] === "asc" && /*sort_priority*/
22245    ctx[11] !== null && create_if_block_8$1(ctx)
22246  );
22247  cellmenuicons1 = new CellMenuIcons$1({ props: { icon: "sort-desc" } });
22248  let if_block1 = (
22249    /*sort_direction*/
22250    ctx[10] === "desc" && /*sort_priority*/
22251    ctx[11] !== null && create_if_block_7$1(ctx)
22252  );
22253  cellmenuicons2 = new CellMenuIcons$1({ props: { icon: "clear-sort" } });
22254  cellmenuicons3 = new CellMenuIcons$1({ props: { icon: "filter" } });
22255  let if_block2 = (
22256    /*filter_active*/
22257    ctx[14] && create_if_block_6$3()
22258  );
22259  cellmenuicons4 = new CellMenuIcons$1({ props: { icon: "clear-filter" } });
22260  return {
22261    c() {
22262      button0 = element("button");
22263      create_component(cellmenuicons0.$$.fragment);
22264      t0 = space();
22265      t1 = text(t1_value);
22266      t2 = space();
22267      if (if_block0) if_block0.c();
22268      t3 = space();
22269      button1 = element("button");
22270      create_component(cellmenuicons1.$$.fragment);
22271      t4 = space();
22272      t5 = text(t5_value);
22273      t6 = space();
22274      if (if_block1) if_block1.c();
22275      t7 = space();
22276      button2 = element("button");
22277      create_component(cellmenuicons2.$$.fragment);
22278      t8 = space();
22279      t9 = text(t9_value);
22280      t10 = space();
22281      button3 = element("button");
22282      create_component(cellmenuicons3.$$.fragment);
22283      t11 = space();
22284      t12 = text(t12_value);
22285      t13 = space();
22286      if (if_block2) if_block2.c();
22287      t14 = space();
22288      button4 = element("button");
22289      create_component(cellmenuicons4.$$.fragment);
22290      t15 = space();
22291      t16 = text(t16_value);
22292      attr(button0, "role", "menuitem");
22293      attr(button0, "class", "svelte-1w7httw");
22294      toggle_class(
22295        button0,
22296        "active",
22297        /*sort_direction*/
22298        ctx[10] === "asc"
22299      );
22300      attr(button1, "role", "menuitem");
22301      attr(button1, "class", "svelte-1w7httw");
22302      toggle_class(
22303        button1,
22304        "active",
22305        /*sort_direction*/
22306        ctx[10] === "desc"
22307      );
22308      attr(button2, "role", "menuitem");
22309      attr(button2, "class", "svelte-1w7httw");
22310      attr(button3, "role", "menuitem");
22311      attr(button3, "class", "svelte-1w7httw");
22312      toggle_class(
22313        button3,
22314        "active",
22315        /*filter_active*/
22316        ctx[14] || /*active_filter_menu*/
22317        ctx[17]
22318      );
22319      attr(button4, "role", "menuitem");
22320      attr(button4, "class", "svelte-1w7httw");
22321    },
22322    m(target, anchor) {
22323      insert(target, button0, anchor);
22324      mount_component(cellmenuicons0, button0, null);
22325      append(button0, t0);
22326      append(button0, t1);
22327      append(button0, t2);
22328      if (if_block0) if_block0.m(button0, null);
22329      insert(target, t3, anchor);
22330      insert(target, button1, anchor);
22331      mount_component(cellmenuicons1, button1, null);
22332      append(button1, t4);
22333      append(button1, t5);
22334      append(button1, t6);
22335      if (if_block1) if_block1.m(button1, null);
22336      insert(target, t7, anchor);
22337      insert(target, button2, anchor);
22338      mount_component(cellmenuicons2, button2, null);
22339      append(button2, t8);
22340      append(button2, t9);
22341      insert(target, t10, anchor);
22342      insert(target, button3, anchor);
22343      mount_component(cellmenuicons3, button3, null);
22344      append(button3, t11);
22345      append(button3, t12);
22346      append(button3, t13);
22347      if (if_block2) if_block2.m(button3, null);
22348      insert(target, t14, anchor);
22349      insert(target, button4, anchor);
22350      mount_component(cellmenuicons4, button4, null);
22351      append(button4, t15);
22352      append(button4, t16);
22353      current = true;
22354      if (!mounted) {
22355        dispose = [
22356          listen(
22357            button0,
22358            "click",
22359            /*click_handler*/
22360            ctx[28]
22361          ),
22362          listen(
22363            button1,
22364            "click",
22365            /*click_handler_1*/
22366            ctx[29]
22367          ),
22368          listen(button2, "click", function() {
22369            if (is_function(
22370              /*on_clear_sort*/
22371              ctx[9]
22372            )) ctx[9].apply(this, arguments);
22373          }),
22374          listen(button3, "click", stop_propagation(
22375            /*toggle_filter_menu*/
22376            ctx[21]
22377          )),
22378          listen(button4, "click", function() {
22379            if (is_function(
22380              /*on_clear_filter*/
22381              ctx[13]
22382            )) ctx[13].apply(this, arguments);
22383          })
22384        ];
22385        mounted = true;
22386      }
22387    },
22388    p(new_ctx, dirty) {
22389      ctx = new_ctx;
22390      if ((!current || dirty[0] & /*i18n*/
22391      32768) && t1_value !== (t1_value = /*i18n*/
22392      ctx[15]("dataframe.sort_ascending") + "")) set_data(t1, t1_value);
22393      if (
22394        /*sort_direction*/
22395        ctx[10] === "asc" && /*sort_priority*/
22396        ctx[11] !== null
22397      ) {
22398        if (if_block0) {
22399          if_block0.p(ctx, dirty);
22400        } else {
22401          if_block0 = create_if_block_8$1(ctx);
22402          if_block0.c();
22403          if_block0.m(button0, null);
22404        }
22405      } else if (if_block0) {
22406        if_block0.d(1);
22407        if_block0 = null;
22408      }
22409      if (!current || dirty[0] & /*sort_direction*/
22410      1024) {
22411        toggle_class(
22412          button0,
22413          "active",
22414          /*sort_direction*/
22415          ctx[10] === "asc"
22416        );
22417      }
22418      if ((!current || dirty[0] & /*i18n*/
22419      32768) && t5_value !== (t5_value = /*i18n*/
22420      ctx[15]("dataframe.sort_descending") + "")) set_data(t5, t5_value);
22421      if (
22422        /*sort_direction*/
22423        ctx[10] === "desc" && /*sort_priority*/
22424        ctx[11] !== null
22425      ) {
22426        if (if_block1) {
22427          if_block1.p(ctx, dirty);
22428        } else {
22429          if_block1 = create_if_block_7$1(ctx);
22430          if_block1.c();
22431          if_block1.m(button1, null);
22432        }
22433      } else if (if_block1) {
22434        if_block1.d(1);
22435        if_block1 = null;
22436      }
22437      if (!current || dirty[0] & /*sort_direction*/
22438      1024) {
22439        toggle_class(
22440          button1,
22441          "active",
22442          /*sort_direction*/
22443          ctx[10] === "desc"
22444        );
22445      }
22446      if ((!current || dirty[0] & /*i18n*/
22447      32768) && t9_value !== (t9_value = /*i18n*/
22448      ctx[15]("dataframe.clear_sort") + "")) set_data(t9, t9_value);
22449      if ((!current || dirty[0] & /*i18n*/
22450      32768) && t12_value !== (t12_value = /*i18n*/
22451      ctx[15]("dataframe.filter") + "")) set_data(t12, t12_value);
22452      if (
22453        /*filter_active*/
22454        ctx[14]
22455      ) {
22456        if (if_block2) ;
22457        else {
22458          if_block2 = create_if_block_6$3();
22459          if_block2.c();
22460          if_block2.m(button3, null);
22461        }
22462      } else if (if_block2) {
22463        if_block2.d(1);
22464        if_block2 = null;
22465      }
22466      if (!current || dirty[0] & /*filter_active, active_filter_menu*/
22467      147456) {
22468        toggle_class(
22469          button3,
22470          "active",
22471          /*filter_active*/
22472          ctx[14] || /*active_filter_menu*/
22473          ctx[17]
22474        );
22475      }
22476      if ((!current || dirty[0] & /*i18n*/
22477      32768) && t16_value !== (t16_value = /*i18n*/
22478      ctx[15]("dataframe.clear_filter") + "")) set_data(t16, t16_value);
22479    },
22480    i(local) {
22481      if (current) return;
22482      transition_in(cellmenuicons0.$$.fragment, local);
22483      transition_in(cellmenuicons1.$$.fragment, local);
22484      transition_in(cellmenuicons2.$$.fragment, local);
22485      transition_in(cellmenuicons3.$$.fragment, local);
22486      transition_in(cellmenuicons4.$$.fragment, local);
22487      current = true;
22488    },
22489    o(local) {
22490      transition_out(cellmenuicons0.$$.fragment, local);
22491      transition_out(cellmenuicons1.$$.fragment, local);
22492      transition_out(cellmenuicons2.$$.fragment, local);
22493      transition_out(cellmenuicons3.$$.fragment, local);
22494      transition_out(cellmenuicons4.$$.fragment, local);
22495      current = false;
22496    },
22497    d(detaching) {
22498      if (detaching) {
22499        detach(button0);
22500        detach(t3);
22501        detach(button1);
22502        detach(t7);
22503        detach(button2);
22504        detach(t10);
22505        detach(button3);
22506        detach(t14);
22507        detach(button4);
22508      }
22509      destroy_component(cellmenuicons0);
22510      if (if_block0) if_block0.d();
22511      destroy_component(cellmenuicons1);
22512      if (if_block1) if_block1.d();
22513      destroy_component(cellmenuicons2);
22514      destroy_component(cellmenuicons3);
22515      if (if_block2) if_block2.d();
22516      destroy_component(cellmenuicons4);
22517      mounted = false;
22518      run_all(dispose);
22519    }
22520  };
22521}
22522function create_if_block_8$1(ctx) {
22523  let span;
22524  let t;
22525  return {
22526    c() {
22527      span = element("span");
22528      t = text(
22529        /*sort_priority*/
22530        ctx[11]
22531      );
22532      attr(span, "class", "priority svelte-1w7httw");
22533    },
22534    m(target, anchor) {
22535      insert(target, span, anchor);
22536      append(span, t);
22537    },
22538    p(ctx2, dirty) {
22539      if (dirty[0] & /*sort_priority*/
22540      2048) set_data(
22541        t,
22542        /*sort_priority*/
22543        ctx2[11]
22544      );
22545    },
22546    d(detaching) {
22547      if (detaching) {
22548        detach(span);
22549      }
22550    }
22551  };
22552}
22553function create_if_block_7$1(ctx) {
22554  let span;
22555  let t;
22556  return {
22557    c() {
22558      span = element("span");
22559      t = text(
22560        /*sort_priority*/
22561        ctx[11]
22562      );
22563      attr(span, "class", "priority svelte-1w7httw");
22564    },
22565    m(target, anchor) {
22566      insert(target, span, anchor);
22567      append(span, t);
22568    },
22569    p(ctx2, dirty) {
22570      if (dirty[0] & /*sort_priority*/
22571      2048) set_data(
22572        t,
22573        /*sort_priority*/
22574        ctx2[11]
22575      );
22576    },
22577    d(detaching) {
22578      if (detaching) {
22579        detach(span);
22580      }
22581    }
22582  };
22583}
22584function create_if_block_6$3(ctx) {
22585  let span;
22586  return {
22587    c() {
22588      span = element("span");
22589      span.textContent = "1";
22590      attr(span, "class", "priority svelte-1w7httw");
22591    },
22592    m(target, anchor) {
22593      insert(target, span, anchor);
22594    },
22595    d(detaching) {
22596      if (detaching) {
22597        detach(span);
22598      }
22599    }
22600  };
22601}
22602function create_if_block_3$5(ctx) {
22603  let button0;
22604  let cellmenuicons0;
22605  let t0;
22606  let t1_value = (
22607    /*i18n*/
22608    ctx[15]("dataframe.add_row_above") + ""
22609  );
22610  let t1;
22611  let t2;
22612  let button1;
22613  let cellmenuicons1;
22614  let t3;
22615  let t4_value = (
22616    /*i18n*/
22617    ctx[15]("dataframe.add_row_below") + ""
22618  );
22619  let t4;
22620  let t5;
22621  let if_block_anchor;
22622  let current;
22623  let mounted;
22624  let dispose;
22625  cellmenuicons0 = new CellMenuIcons$1({ props: { icon: "add-row-above" } });
22626  cellmenuicons1 = new CellMenuIcons$1({ props: { icon: "add-row-below" } });
22627  let if_block = (
22628    /*can_delete_rows*/
22629    ctx[6] && create_if_block_4$3(ctx)
22630  );
22631  return {
22632    c() {
22633      button0 = element("button");
22634      create_component(cellmenuicons0.$$.fragment);
22635      t0 = space();
22636      t1 = text(t1_value);
22637      t2 = space();
22638      button1 = element("button");
22639      create_component(cellmenuicons1.$$.fragment);
22640      t3 = space();
22641      t4 = text(t4_value);
22642      t5 = space();
22643      if (if_block) if_block.c();
22644      if_block_anchor = empty();
22645      attr(button0, "role", "menuitem");
22646      attr(button0, "aria-label", "Add row above");
22647      attr(button0, "class", "svelte-1w7httw");
22648      attr(button1, "role", "menuitem");
22649      attr(button1, "aria-label", "Add row below");
22650      attr(button1, "class", "svelte-1w7httw");
22651    },
22652    m(target, anchor) {
22653      insert(target, button0, anchor);
22654      mount_component(cellmenuicons0, button0, null);
22655      append(button0, t0);
22656      append(button0, t1);
22657      insert(target, t2, anchor);
22658      insert(target, button1, anchor);
22659      mount_component(cellmenuicons1, button1, null);
22660      append(button1, t3);
22661      append(button1, t4);
22662      insert(target, t5, anchor);
22663      if (if_block) if_block.m(target, anchor);
22664      insert(target, if_block_anchor, anchor);
22665      current = true;
22666      if (!mounted) {
22667        dispose = [
22668          listen(
22669            button0,
22670            "click",
22671            /*click_handler_2*/
22672            ctx[30]
22673          ),
22674          listen(
22675            button1,
22676            "click",
22677            /*click_handler_3*/
22678            ctx[31]
22679          )
22680        ];
22681        mounted = true;
22682      }
22683    },
22684    p(ctx2, dirty) {
22685      if ((!current || dirty[0] & /*i18n*/
22686      32768) && t1_value !== (t1_value = /*i18n*/
22687      ctx2[15]("dataframe.add_row_above") + "")) set_data(t1, t1_value);
22688      if ((!current || dirty[0] & /*i18n*/
22689      32768) && t4_value !== (t4_value = /*i18n*/
22690      ctx2[15]("dataframe.add_row_below") + "")) set_data(t4, t4_value);
22691      if (
22692        /*can_delete_rows*/
22693        ctx2[6]
22694      ) {
22695        if (if_block) {
22696          if_block.p(ctx2, dirty);
22697          if (dirty[0] & /*can_delete_rows*/
22698          64) {
22699            transition_in(if_block, 1);
22700          }
22701        } else {
22702          if_block = create_if_block_4$3(ctx2);
22703          if_block.c();
22704          transition_in(if_block, 1);
22705          if_block.m(if_block_anchor.parentNode, if_block_anchor);
22706        }
22707      } else if (if_block) {
22708        group_outros();
22709        transition_out(if_block, 1, 1, () => {
22710          if_block = null;
22711        });
22712        check_outros();
22713      }
22714    },
22715    i(local) {
22716      if (current) return;
22717      transition_in(cellmenuicons0.$$.fragment, local);
22718      transition_in(cellmenuicons1.$$.fragment, local);
22719      transition_in(if_block);
22720      current = true;
22721    },
22722    o(local) {
22723      transition_out(cellmenuicons0.$$.fragment, local);
22724      transition_out(cellmenuicons1.$$.fragment, local);
22725      transition_out(if_block);
22726      current = false;
22727    },
22728    d(detaching) {
22729      if (detaching) {
22730        detach(button0);
22731        detach(t2);
22732        detach(button1);
22733        detach(t5);
22734        detach(if_block_anchor);
22735      }
22736      destroy_component(cellmenuicons0);
22737      destroy_component(cellmenuicons1);
22738      if (if_block) if_block.d(detaching);
22739      mounted = false;
22740      run_all(dispose);
22741    }
22742  };
22743}
22744function create_if_block_4$3(ctx) {
22745  let button;
22746  let cellmenuicons;
22747  let t0;
22748  let t1_value = (
22749    /*i18n*/
22750    ctx[15]("dataframe.delete_row") + ""
22751  );
22752  let t1;
22753  let current;
22754  let mounted;
22755  let dispose;
22756  cellmenuicons = new CellMenuIcons$1({ props: { icon: "delete-row" } });
22757  return {
22758    c() {
22759      button = element("button");
22760      create_component(cellmenuicons.$$.fragment);
22761      t0 = space();
22762      t1 = text(t1_value);
22763      attr(button, "role", "menuitem");
22764      attr(button, "class", "delete svelte-1w7httw");
22765      attr(button, "aria-label", "Delete row");
22766    },
22767    m(target, anchor) {
22768      insert(target, button, anchor);
22769      mount_component(cellmenuicons, button, null);
22770      append(button, t0);
22771      append(button, t1);
22772      current = true;
22773      if (!mounted) {
22774        dispose = listen(button, "click", function() {
22775          if (is_function(
22776            /*on_delete_row*/
22777            ctx[4]
22778          )) ctx[4].apply(this, arguments);
22779        });
22780        mounted = true;
22781      }
22782    },
22783    p(new_ctx, dirty) {
22784      ctx = new_ctx;
22785      if ((!current || dirty[0] & /*i18n*/
22786      32768) && t1_value !== (t1_value = /*i18n*/
22787      ctx[15]("dataframe.delete_row") + "")) set_data(t1, t1_value);
22788    },
22789    i(local) {
22790      if (current) return;
22791      transition_in(cellmenuicons.$$.fragment, local);
22792      current = true;
22793    },
22794    o(local) {
22795      transition_out(cellmenuicons.$$.fragment, local);
22796      current = false;
22797    },
22798    d(detaching) {
22799      if (detaching) {
22800        detach(button);
22801      }
22802      destroy_component(cellmenuicons);
22803      mounted = false;
22804      dispose();
22805    }
22806  };
22807}
22808function create_if_block_1$6(ctx) {
22809  let button0;
22810  let cellmenuicons0;
22811  let t0;
22812  let t1_value = (
22813    /*i18n*/
22814    ctx[15]("dataframe.add_column_left") + ""
22815  );
22816  let t1;
22817  let t2;
22818  let button1;
22819  let cellmenuicons1;
22820  let t3;
22821  let t4_value = (
22822    /*i18n*/
22823    ctx[15]("dataframe.add_column_right") + ""
22824  );
22825  let t4;
22826  let t5;
22827  let if_block_anchor;
22828  let current;
22829  let mounted;
22830  let dispose;
22831  cellmenuicons0 = new CellMenuIcons$1({ props: { icon: "add-column-left" } });
22832  cellmenuicons1 = new CellMenuIcons$1({ props: { icon: "add-column-right" } });
22833  let if_block = (
22834    /*can_delete_cols*/
22835    ctx[7] && create_if_block_2$6(ctx)
22836  );
22837  return {
22838    c() {
22839      button0 = element("button");
22840      create_component(cellmenuicons0.$$.fragment);
22841      t0 = space();
22842      t1 = text(t1_value);
22843      t2 = space();
22844      button1 = element("button");
22845      create_component(cellmenuicons1.$$.fragment);
22846      t3 = space();
22847      t4 = text(t4_value);
22848      t5 = space();
22849      if (if_block) if_block.c();
22850      if_block_anchor = empty();
22851      attr(button0, "role", "menuitem");
22852      attr(button0, "aria-label", "Add column to the left");
22853      attr(button0, "class", "svelte-1w7httw");
22854      attr(button1, "role", "menuitem");
22855      attr(button1, "aria-label", "Add column to the right");
22856      attr(button1, "class", "svelte-1w7httw");
22857    },
22858    m(target, anchor) {
22859      insert(target, button0, anchor);
22860      mount_component(cellmenuicons0, button0, null);
22861      append(button0, t0);
22862      append(button0, t1);
22863      insert(target, t2, anchor);
22864      insert(target, button1, anchor);
22865      mount_component(cellmenuicons1, button1, null);
22866      append(button1, t3);
22867      append(button1, t4);
22868      insert(target, t5, anchor);
22869      if (if_block) if_block.m(target, anchor);
22870      insert(target, if_block_anchor, anchor);
22871      current = true;
22872      if (!mounted) {
22873        dispose = [
22874          listen(
22875            button0,
22876            "click",
22877            /*click_handler_4*/
22878            ctx[32]
22879          ),
22880          listen(
22881            button1,
22882            "click",
22883            /*click_handler_5*/
22884            ctx[33]
22885          )
22886        ];
22887        mounted = true;
22888      }
22889    },
22890    p(ctx2, dirty) {
22891      if ((!current || dirty[0] & /*i18n*/
22892      32768) && t1_value !== (t1_value = /*i18n*/
22893      ctx2[15]("dataframe.add_column_left") + "")) set_data(t1, t1_value);
22894      if ((!current || dirty[0] & /*i18n*/
22895      32768) && t4_value !== (t4_value = /*i18n*/
22896      ctx2[15]("dataframe.add_column_right") + "")) set_data(t4, t4_value);
22897      if (
22898        /*can_delete_cols*/
22899        ctx2[7]
22900      ) {
22901        if (if_block) {
22902          if_block.p(ctx2, dirty);
22903          if (dirty[0] & /*can_delete_cols*/
22904          128) {
22905            transition_in(if_block, 1);
22906          }
22907        } else {
22908          if_block = create_if_block_2$6(ctx2);
22909          if_block.c();
22910          transition_in(if_block, 1);
22911          if_block.m(if_block_anchor.parentNode, if_block_anchor);
22912        }
22913      } else if (if_block) {
22914        group_outros();
22915        transition_out(if_block, 1, 1, () => {
22916          if_block = null;
22917        });
22918        check_outros();
22919      }
22920    },
22921    i(local) {
22922      if (current) return;
22923      transition_in(cellmenuicons0.$$.fragment, local);
22924      transition_in(cellmenuicons1.$$.fragment, local);
22925      transition_in(if_block);
22926      current = true;
22927    },
22928    o(local) {
22929      transition_out(cellmenuicons0.$$.fragment, local);
22930      transition_out(cellmenuicons1.$$.fragment, local);
22931      transition_out(if_block);
22932      current = false;
22933    },
22934    d(detaching) {
22935      if (detaching) {
22936        detach(button0);
22937        detach(t2);
22938        detach(button1);
22939        detach(t5);
22940        detach(if_block_anchor);
22941      }
22942      destroy_component(cellmenuicons0);
22943      destroy_component(cellmenuicons1);
22944      if (if_block) if_block.d(detaching);
22945      mounted = false;
22946      run_all(dispose);
22947    }
22948  };
22949}
22950function create_if_block_2$6(ctx) {
22951  let button;
22952  let cellmenuicons;
22953  let t0;
22954  let t1_value = (
22955    /*i18n*/
22956    ctx[15]("dataframe.delete_column") + ""
22957  );
22958  let t1;
22959  let current;
22960  let mounted;
22961  let dispose;
22962  cellmenuicons = new CellMenuIcons$1({ props: { icon: "delete-column" } });
22963  return {
22964    c() {
22965      button = element("button");
22966      create_component(cellmenuicons.$$.fragment);
22967      t0 = space();
22968      t1 = text(t1_value);
22969      attr(button, "role", "menuitem");
22970      attr(button, "class", "delete svelte-1w7httw");
22971      attr(button, "aria-label", "Delete column");
22972    },
22973    m(target, anchor) {
22974      insert(target, button, anchor);
22975      mount_component(cellmenuicons, button, null);
22976      append(button, t0);
22977      append(button, t1);
22978      current = true;
22979      if (!mounted) {
22980        dispose = listen(button, "click", function() {
22981          if (is_function(
22982            /*on_delete_col*/
22983            ctx[5]
22984          )) ctx[5].apply(this, arguments);
22985        });
22986        mounted = true;
22987      }
22988    },
22989    p(new_ctx, dirty) {
22990      ctx = new_ctx;
22991      if ((!current || dirty[0] & /*i18n*/
22992      32768) && t1_value !== (t1_value = /*i18n*/
22993      ctx[15]("dataframe.delete_column") + "")) set_data(t1, t1_value);
22994    },
22995    i(local) {
22996      if (current) return;
22997      transition_in(cellmenuicons.$$.fragment, local);
22998      current = true;
22999    },
23000    o(local) {
23001      transition_out(cellmenuicons.$$.fragment, local);
23002      current = false;
23003    },
23004    d(detaching) {
23005      if (detaching) {
23006        detach(button);
23007      }
23008      destroy_component(cellmenuicons);
23009      mounted = false;
23010      dispose();
23011    }
23012  };
23013}
23014function create_if_block$6(ctx) {
23015  let filtermenu;
23016  let current;
23017  filtermenu = new FilterMenu$1({
23018    props: { on_filter: (
23019      /*on_filter*/
23020      ctx[12]
23021    ) }
23022  });
23023  return {
23024    c() {
23025      create_component(filtermenu.$$.fragment);
23026    },
23027    m(target, anchor) {
23028      mount_component(filtermenu, target, anchor);
23029      current = true;
23030    },
23031    p(ctx2, dirty) {
23032      const filtermenu_changes = {};
23033      if (dirty[0] & /*on_filter*/
23034      4096) filtermenu_changes.on_filter = /*on_filter*/
23035      ctx2[12];
23036      filtermenu.$set(filtermenu_changes);
23037    },
23038    i(local) {
23039      if (current) return;
23040      transition_in(filtermenu.$$.fragment, local);
23041      current = true;
23042    },
23043    o(local) {
23044      transition_out(filtermenu.$$.fragment, local);
23045      current = false;
23046    },
23047    d(detaching) {
23048      destroy_component(filtermenu, detaching);
23049    }
23050  };
23051}
23052function create_fragment$a(ctx) {
23053  let div;
23054  let t0;
23055  let t1;
23056  let t2;
23057  let if_block3_anchor;
23058  let current;
23059  let if_block0 = (
23060    /*is_header*/
23061    ctx[20] && create_if_block_5$3(ctx)
23062  );
23063  let if_block1 = !/*is_header*/
23064  ctx[20] && /*can_add_rows*/
23065  ctx[19] && create_if_block_3$5(ctx);
23066  let if_block2 = (
23067    /*can_add_columns*/
23068    ctx[18] && create_if_block_1$6(ctx)
23069  );
23070  let if_block3 = (
23071    /*active_filter_menu*/
23072    ctx[17] && create_if_block$6(ctx)
23073  );
23074  return {
23075    c() {
23076      div = element("div");
23077      if (if_block0) if_block0.c();
23078      t0 = space();
23079      if (if_block1) if_block1.c();
23080      t1 = space();
23081      if (if_block2) if_block2.c();
23082      t2 = space();
23083      if (if_block3) if_block3.c();
23084      if_block3_anchor = empty();
23085      attr(div, "class", "cell-menu svelte-1w7httw");
23086      attr(div, "role", "menu");
23087    },
23088    m(target, anchor) {
23089      insert(target, div, anchor);
23090      if (if_block0) if_block0.m(div, null);
23091      append(div, t0);
23092      if (if_block1) if_block1.m(div, null);
23093      append(div, t1);
23094      if (if_block2) if_block2.m(div, null);
23095      ctx[34](div);
23096      insert(target, t2, anchor);
23097      if (if_block3) if_block3.m(target, anchor);
23098      insert(target, if_block3_anchor, anchor);
23099      current = true;
23100    },
23101    p(ctx2, dirty) {
23102      if (
23103        /*is_header*/
23104        ctx2[20]
23105      ) {
23106        if (if_block0) {
23107          if_block0.p(ctx2, dirty);
23108          if (dirty[0] & /*is_header*/
23109          1048576) {
23110            transition_in(if_block0, 1);
23111          }
23112        } else {
23113          if_block0 = create_if_block_5$3(ctx2);
23114          if_block0.c();
23115          transition_in(if_block0, 1);
23116          if_block0.m(div, t0);
23117        }
23118      } else if (if_block0) {
23119        group_outros();
23120        transition_out(if_block0, 1, 1, () => {
23121          if_block0 = null;
23122        });
23123        check_outros();
23124      }
23125      if (!/*is_header*/
23126      ctx2[20] && /*can_add_rows*/
23127      ctx2[19]) {
23128        if (if_block1) {
23129          if_block1.p(ctx2, dirty);
23130          if (dirty[0] & /*is_header, can_add_rows*/
23131          1572864) {
23132            transition_in(if_block1, 1);
23133          }
23134        } else {
23135          if_block1 = create_if_block_3$5(ctx2);
23136          if_block1.c();
23137          transition_in(if_block1, 1);
23138          if_block1.m(div, t1);
23139        }
23140      } else if (if_block1) {
23141        group_outros();
23142        transition_out(if_block1, 1, 1, () => {
23143          if_block1 = null;
23144        });
23145        check_outros();
23146      }
23147      if (
23148        /*can_add_columns*/
23149        ctx2[18]
23150      ) {
23151        if (if_block2) {
23152          if_block2.p(ctx2, dirty);
23153          if (dirty[0] & /*can_add_columns*/
23154          262144) {
23155            transition_in(if_block2, 1);
23156          }
23157        } else {
23158          if_block2 = create_if_block_1$6(ctx2);
23159          if_block2.c();
23160          transition_in(if_block2, 1);
23161          if_block2.m(div, null);
23162        }
23163      } else if (if_block2) {
23164        group_outros();
23165        transition_out(if_block2, 1, 1, () => {
23166          if_block2 = null;
23167        });
23168        check_outros();
23169      }
23170      if (
23171        /*active_filter_menu*/
23172        ctx2[17]
23173      ) {
23174        if (if_block3) {
23175          if_block3.p(ctx2, dirty);
23176          if (dirty[0] & /*active_filter_menu*/
23177          131072) {
23178            transition_in(if_block3, 1);
23179          }
23180        } else {
23181          if_block3 = create_if_block$6(ctx2);
23182          if_block3.c();
23183          transition_in(if_block3, 1);
23184          if_block3.m(if_block3_anchor.parentNode, if_block3_anchor);
23185        }
23186      } else if (if_block3) {
23187        group_outros();
23188        transition_out(if_block3, 1, 1, () => {
23189          if_block3 = null;
23190        });
23191        check_outros();
23192      }
23193    },
23194    i(local) {
23195      if (current) return;
23196      transition_in(if_block0);
23197      transition_in(if_block1);
23198      transition_in(if_block2);
23199      transition_in(if_block3);
23200      current = true;
23201    },
23202    o(local) {
23203      transition_out(if_block0);
23204      transition_out(if_block1);
23205      transition_out(if_block2);
23206      transition_out(if_block3);
23207      current = false;
23208    },
23209    d(detaching) {
23210      if (detaching) {
23211        detach(div);
23212        detach(t2);
23213        detach(if_block3_anchor);
23214      }
23215      if (if_block0) if_block0.d();
23216      if (if_block1) if_block1.d();
23217      if (if_block2) if_block2.d();
23218      ctx[34](null);
23219      if (if_block3) if_block3.d(detaching);
23220    }
23221  };
23222}
23223function instance$a($$self, $$props, $$invalidate) {
23224  let is_header;
23225  let can_add_rows;
23226  let can_add_columns;
23227  let { x } = $$props;
23228  let { y } = $$props;
23229  let { on_add_row_above } = $$props;
23230  let { on_add_row_below } = $$props;
23231  let { on_add_column_left } = $$props;
23232  let { on_add_column_right } = $$props;
23233  let { row } = $$props;
23234  let { col_count } = $$props;
23235  let { row_count } = $$props;
23236  let { on_delete_row } = $$props;
23237  let { on_delete_col } = $$props;
23238  let { can_delete_rows } = $$props;
23239  let { can_delete_cols } = $$props;
23240  let { on_sort = () => {
23241  } } = $$props;
23242  let { on_clear_sort = () => {
23243  } } = $$props;
23244  let { sort_direction = null } = $$props;
23245  let { sort_priority = null } = $$props;
23246  let { on_filter = () => {
23247  } } = $$props;
23248  let { on_clear_filter = () => {
23249  } } = $$props;
23250  let { filter_active = null } = $$props;
23251  let { editable = true } = $$props;
23252  let { i18n } = $$props;
23253  let menu_element;
23254  let active_filter_menu = null;
23255  onMount(() => {
23256    position_menu();
23257  });
23258  function position_menu() {
23259    if (!menu_element) return;
23260    const viewport_width = window.innerWidth;
23261    const viewport_height = window.innerHeight;
23262    const menu_rect = menu_element.getBoundingClientRect();
23263    let new_x = x - 30;
23264    let new_y = y - 20;
23265    if (new_x + menu_rect.width > viewport_width) {
23266      new_x = x - menu_rect.width + 10;
23267    }
23268    if (new_y + menu_rect.height > viewport_height) {
23269      new_y = y - menu_rect.height + 10;
23270    }
23271    $$invalidate(16, menu_element.style.left = `${new_x}px`, menu_element);
23272    $$invalidate(16, menu_element.style.top = `${new_y}px`, menu_element);
23273  }
23274  function toggle_filter_menu() {
23275    if (filter_active) {
23276      on_filter("string", "", "");
23277      return;
23278    }
23279    const menu_rect = menu_element.getBoundingClientRect();
23280    $$invalidate(17, active_filter_menu = {
23281      x: menu_rect.right,
23282      y: menu_rect.top + menu_rect.height / 2
23283    });
23284  }
23285  const click_handler = () => on_sort("asc");
23286  const click_handler_1 = () => on_sort("desc");
23287  const click_handler_2 = () => on_add_row_above();
23288  const click_handler_3 = () => on_add_row_below();
23289  const click_handler_4 = () => on_add_column_left();
23290  const click_handler_5 = () => on_add_column_right();
23291  function div_binding($$value) {
23292    binding_callbacks[$$value ? "unshift" : "push"](() => {
23293      menu_element = $$value;
23294      $$invalidate(16, menu_element);
23295    });
23296  }
23297  $$self.$$set = ($$props2) => {
23298    if ("x" in $$props2) $$invalidate(22, x = $$props2.x);
23299    if ("y" in $$props2) $$invalidate(23, y = $$props2.y);
23300    if ("on_add_row_above" in $$props2) $$invalidate(0, on_add_row_above = $$props2.on_add_row_above);
23301    if ("on_add_row_below" in $$props2) $$invalidate(1, on_add_row_below = $$props2.on_add_row_below);
23302    if ("on_add_column_left" in $$props2) $$invalidate(2, on_add_column_left = $$props2.on_add_column_left);
23303    if ("on_add_column_right" in $$props2) $$invalidate(3, on_add_column_right = $$props2.on_add_column_right);
23304    if ("row" in $$props2) $$invalidate(24, row = $$props2.row);
23305    if ("col_count" in $$props2) $$invalidate(25, col_count = $$props2.col_count);
23306    if ("row_count" in $$props2) $$invalidate(26, row_count = $$props2.row_count);
23307    if ("on_delete_row" in $$props2) $$invalidate(4, on_delete_row = $$props2.on_delete_row);
23308    if ("on_delete_col" in $$props2) $$invalidate(5, on_delete_col = $$props2.on_delete_col);
23309    if ("can_delete_rows" in $$props2) $$invalidate(6, can_delete_rows = $$props2.can_delete_rows);
23310    if ("can_delete_cols" in $$props2) $$invalidate(7, can_delete_cols = $$props2.can_delete_cols);
23311    if ("on_sort" in $$props2) $$invalidate(8, on_sort = $$props2.on_sort);
23312    if ("on_clear_sort" in $$props2) $$invalidate(9, on_clear_sort = $$props2.on_clear_sort);
23313    if ("sort_direction" in $$props2) $$invalidate(10, sort_direction = $$props2.sort_direction);
23314    if ("sort_priority" in $$props2) $$invalidate(11, sort_priority = $$props2.sort_priority);
23315    if ("on_filter" in $$props2) $$invalidate(12, on_filter = $$props2.on_filter);
23316    if ("on_clear_filter" in $$props2) $$invalidate(13, on_clear_filter = $$props2.on_clear_filter);
23317    if ("filter_active" in $$props2) $$invalidate(14, filter_active = $$props2.filter_active);
23318    if ("editable" in $$props2) $$invalidate(27, editable = $$props2.editable);
23319    if ("i18n" in $$props2) $$invalidate(15, i18n = $$props2.i18n);
23320  };
23321  $$self.$$.update = () => {
23322    if ($$self.$$.dirty[0] & /*row*/
23323    16777216) {
23324      $$invalidate(20, is_header = row === -1);
23325    }
23326    if ($$self.$$.dirty[0] & /*editable, row_count*/
23327    201326592) {
23328      $$invalidate(19, can_add_rows = editable && row_count[1] === "dynamic");
23329    }
23330    if ($$self.$$.dirty[0] & /*editable, col_count*/
23331    167772160) {
23332      $$invalidate(18, can_add_columns = editable && col_count[1] === "dynamic");
23333    }
23334  };
23335  return [
23336    on_add_row_above,
23337    on_add_row_below,
23338    on_add_column_left,
23339    on_add_column_right,
23340    on_delete_row,
23341    on_delete_col,
23342    can_delete_rows,
23343    can_delete_cols,
23344    on_sort,
23345    on_clear_sort,
23346    sort_direction,
23347    sort_priority,
23348    on_filter,
23349    on_clear_filter,
23350    filter_active,
23351    i18n,
23352    menu_element,
23353    active_filter_menu,
23354    can_add_columns,
23355    can_add_rows,
23356    is_header,
23357    toggle_filter_menu,
23358    x,
23359    y,
23360    row,
23361    col_count,
23362    row_count,
23363    editable,
23364    click_handler,
23365    click_handler_1,
23366    click_handler_2,
23367    click_handler_3,
23368    click_handler_4,
23369    click_handler_5,
23370    div_binding
23371  ];
23372}
23373let CellMenu$1 = class CellMenu extends SvelteComponent {
23374  constructor(options) {
23375    super();
23376    init(
23377      this,
23378      options,
23379      instance$a,
23380      create_fragment$a,
23381      safe_not_equal,
23382      {
23383        x: 22,
23384        y: 23,
23385        on_add_row_above: 0,
23386        on_add_row_below: 1,
23387        on_add_column_left: 2,
23388        on_add_column_right: 3,
23389        row: 24,
23390        col_count: 25,
23391        row_count: 26,
23392        on_delete_row: 4,
23393        on_delete_col: 5,
23394        can_delete_rows: 6,
23395        can_delete_cols: 7,
23396        on_sort: 8,
23397        on_clear_sort: 9,
23398        sort_direction: 10,
23399        sort_priority: 11,
23400        on_filter: 12,
23401        on_clear_filter: 13,
23402        filter_active: 14,
23403        editable: 27,
23404        i18n: 15
23405      },
23406      null,
23407      [-1, -1]
23408    );
23409  }
23410};
23411function create_if_block_2$5(ctx) {
23412  let div;
23413  let input;
23414  let input_value_value;
23415  let input_placeholder_value;
23416  let input_title_value;
23417  let t;
23418  let current;
23419  let mounted;
23420  let dispose;
23421  let if_block = (
23422    /*current_search_query*/
23423    ctx[0] && /*show_search*/
23424    ctx[3] === "filter" && create_if_block_3$4(ctx)
23425  );
23426  return {
23427    c() {
23428      div = element("div");
23429      input = element("input");
23430      t = space();
23431      if (if_block) if_block.c();
23432      attr(input, "type", "text");
23433      input.value = input_value_value = /*current_search_query*/
23434      ctx[0] || "";
23435      attr(input, "placeholder", input_placeholder_value = /*show_search*/
23436      ctx[3] === "filter" ? "Filter..." : "Search...");
23437      attr(input, "class", "search-input svelte-1jaxu11");
23438      attr(input, "title", input_title_value = `Enter text to ${/*show_search*/
23439      ctx[3]} the table`);
23440      toggle_class(
23441        input,
23442        "filter-mode",
23443        /*show_search*/
23444        ctx[3] === "filter"
23445      );
23446      attr(div, "class", "search-container svelte-1jaxu11");
23447    },
23448    m(target, anchor) {
23449      insert(target, div, anchor);
23450      append(div, input);
23451      append(div, t);
23452      if (if_block) if_block.m(div, null);
23453      current = true;
23454      if (!mounted) {
23455        dispose = listen(
23456          input,
23457          "input",
23458          /*handle_search_input*/
23459          ctx[7]
23460        );
23461        mounted = true;
23462      }
23463    },
23464    p(ctx2, dirty) {
23465      if (!current || dirty & /*current_search_query*/
23466      1 && input_value_value !== (input_value_value = /*current_search_query*/
23467      ctx2[0] || "") && input.value !== input_value_value) {
23468        input.value = input_value_value;
23469      }
23470      if (!current || dirty & /*show_search*/
23471      8 && input_placeholder_value !== (input_placeholder_value = /*show_search*/
23472      ctx2[3] === "filter" ? "Filter..." : "Search...")) {
23473        attr(input, "placeholder", input_placeholder_value);
23474      }
23475      if (!current || dirty & /*show_search*/
23476      8 && input_title_value !== (input_title_value = `Enter text to ${/*show_search*/
23477      ctx2[3]} the table`)) {
23478        attr(input, "title", input_title_value);
23479      }
23480      if (!current || dirty & /*show_search*/
23481      8) {
23482        toggle_class(
23483          input,
23484          "filter-mode",
23485          /*show_search*/
23486          ctx2[3] === "filter"
23487        );
23488      }
23489      if (
23490        /*current_search_query*/
23491        ctx2[0] && /*show_search*/
23492        ctx2[3] === "filter"
23493      ) {
23494        if (if_block) {
23495          if_block.p(ctx2, dirty);
23496          if (dirty & /*current_search_query, show_search*/
23497          9) {
23498            transition_in(if_block, 1);
23499          }
23500        } else {
23501          if_block = create_if_block_3$4(ctx2);
23502          if_block.c();
23503          transition_in(if_block, 1);
23504          if_block.m(div, null);
23505        }
23506      } else if (if_block) {
23507        group_outros();
23508        transition_out(if_block, 1, 1, () => {
23509          if_block = null;
23510        });
23511        check_outros();
23512      }
23513    },
23514    i(local) {
23515      if (current) return;
23516      transition_in(if_block);
23517      current = true;
23518    },
23519    o(local) {
23520      transition_out(if_block);
23521      current = false;
23522    },
23523    d(detaching) {
23524      if (detaching) {
23525        detach(div);
23526      }
23527      if (if_block) if_block.d();
23528      mounted = false;
23529      dispose();
23530    }
23531  };
23532}
23533function create_if_block_3$4(ctx) {
23534  let button;
23535  let check;
23536  let current;
23537  let mounted;
23538  let dispose;
23539  check = new Check({});
23540  return {
23541    c() {
23542      button = element("button");
23543      create_component(check.$$.fragment);
23544      attr(button, "class", "toolbar-button check-button svelte-1jaxu11");
23545      attr(button, "aria-label", "Apply filter and update dataframe values");
23546      attr(button, "title", "Apply filter and update dataframe values");
23547    },
23548    m(target, anchor) {
23549      insert(target, button, anchor);
23550      mount_component(check, button, null);
23551      current = true;
23552      if (!mounted) {
23553        dispose = listen(button, "click", function() {
23554          if (is_function(
23555            /*on_commit_filter*/
23556            ctx[5]
23557          )) ctx[5].apply(this, arguments);
23558        });
23559        mounted = true;
23560      }
23561    },
23562    p(new_ctx, dirty) {
23563      ctx = new_ctx;
23564    },
23565    i(local) {
23566      if (current) return;
23567      transition_in(check.$$.fragment, local);
23568      current = true;
23569    },
23570    o(local) {
23571      transition_out(check.$$.fragment, local);
23572      current = false;
23573    },
23574    d(detaching) {
23575      if (detaching) {
23576        detach(button);
23577      }
23578      destroy_component(check);
23579      mounted = false;
23580      dispose();
23581    }
23582  };
23583}
23584function create_if_block_1$5(ctx) {
23585  let iconbutton;
23586  let current;
23587  iconbutton = new IconButton({
23588    props: {
23589      Icon: (
23590        /*copied*/
23591        ctx[6] ? Check : Copy
23592      ),
23593      label: (
23594        /*copied*/
23595        ctx[6] ? "Copied to clipboard" : "Copy table data"
23596      )
23597    }
23598  });
23599  iconbutton.$on(
23600    "click",
23601    /*handle_copy*/
23602    ctx[8]
23603  );
23604  return {
23605    c() {
23606      create_component(iconbutton.$$.fragment);
23607    },
23608    m(target, anchor) {
23609      mount_component(iconbutton, target, anchor);
23610      current = true;
23611    },
23612    p(ctx2, dirty) {
23613      const iconbutton_changes = {};
23614      if (dirty & /*copied*/
23615      64) iconbutton_changes.Icon = /*copied*/
23616      ctx2[6] ? Check : Copy;
23617      if (dirty & /*copied*/
23618      64) iconbutton_changes.label = /*copied*/
23619      ctx2[6] ? "Copied to clipboard" : "Copy table data";
23620      iconbutton.$set(iconbutton_changes);
23621    },
23622    i(local) {
23623      if (current) return;
23624      transition_in(iconbutton.$$.fragment, local);
23625      current = true;
23626    },
23627    o(local) {
23628      transition_out(iconbutton.$$.fragment, local);
23629      current = false;
23630    },
23631    d(detaching) {
23632      destroy_component(iconbutton, detaching);
23633    }
23634  };
23635}
23636function create_if_block$5(ctx) {
23637  let fullscreenbutton;
23638  let current;
23639  fullscreenbutton = new FullscreenButton({
23640    props: { fullscreen: (
23641      /*fullscreen*/
23642      ctx[4]
23643    ) }
23644  });
23645  fullscreenbutton.$on(
23646    "fullscreen",
23647    /*fullscreen_handler*/
23648    ctx[10]
23649  );
23650  return {
23651    c() {
23652      create_component(fullscreenbutton.$$.fragment);
23653    },
23654    m(target, anchor) {
23655      mount_component(fullscreenbutton, target, anchor);
23656      current = true;
23657    },
23658    p(ctx2, dirty) {
23659      const fullscreenbutton_changes = {};
23660      if (dirty & /*fullscreen*/
23661      16) fullscreenbutton_changes.fullscreen = /*fullscreen*/
23662      ctx2[4];
23663      fullscreenbutton.$set(fullscreenbutton_changes);
23664    },
23665    i(local) {
23666      if (current) return;
23667      transition_in(fullscreenbutton.$$.fragment, local);
23668      current = true;
23669    },
23670    o(local) {
23671      transition_out(fullscreenbutton.$$.fragment, local);
23672      current = false;
23673    },
23674    d(detaching) {
23675      destroy_component(fullscreenbutton, detaching);
23676    }
23677  };
23678}
23679function create_fragment$9(ctx) {
23680  let div1;
23681  let div0;
23682  let t0;
23683  let t1;
23684  let current;
23685  let if_block0 = (
23686    /*show_search*/
23687    ctx[3] !== "none" && create_if_block_2$5(ctx)
23688  );
23689  let if_block1 = (
23690    /*show_copy_button*/
23691    ctx[2] && create_if_block_1$5(ctx)
23692  );
23693  let if_block2 = (
23694    /*show_fullscreen_button*/
23695    ctx[1] && create_if_block$5(ctx)
23696  );
23697  return {
23698    c() {
23699      div1 = element("div");
23700      div0 = element("div");
23701      if (if_block0) if_block0.c();
23702      t0 = space();
23703      if (if_block1) if_block1.c();
23704      t1 = space();
23705      if (if_block2) if_block2.c();
23706      attr(div0, "class", "toolbar-buttons svelte-1jaxu11");
23707      attr(div1, "class", "toolbar svelte-1jaxu11");
23708      attr(div1, "role", "toolbar");
23709      attr(div1, "aria-label", "Table actions");
23710    },
23711    m(target, anchor) {
23712      insert(target, div1, anchor);
23713      append(div1, div0);
23714      if (if_block0) if_block0.m(div0, null);
23715      append(div0, t0);
23716      if (if_block1) if_block1.m(div0, null);
23717      append(div0, t1);
23718      if (if_block2) if_block2.m(div0, null);
23719      current = true;
23720    },
23721    p(ctx2, [dirty]) {
23722      if (
23723        /*show_search*/
23724        ctx2[3] !== "none"
23725      ) {
23726        if (if_block0) {
23727          if_block0.p(ctx2, dirty);
23728          if (dirty & /*show_search*/
23729          8) {
23730            transition_in(if_block0, 1);
23731          }
23732        } else {
23733          if_block0 = create_if_block_2$5(ctx2);
23734          if_block0.c();
23735          transition_in(if_block0, 1);
23736          if_block0.m(div0, t0);
23737        }
23738      } else if (if_block0) {
23739        group_outros();
23740        transition_out(if_block0, 1, 1, () => {
23741          if_block0 = null;
23742        });
23743        check_outros();
23744      }
23745      if (
23746        /*show_copy_button*/
23747        ctx2[2]
23748      ) {
23749        if (if_block1) {
23750          if_block1.p(ctx2, dirty);
23751          if (dirty & /*show_copy_button*/
23752          4) {
23753            transition_in(if_block1, 1);
23754          }
23755        } else {
23756          if_block1 = create_if_block_1$5(ctx2);
23757          if_block1.c();
23758          transition_in(if_block1, 1);
23759          if_block1.m(div0, t1);
23760        }
23761      } else if (if_block1) {
23762        group_outros();
23763        transition_out(if_block1, 1, 1, () => {
23764          if_block1 = null;
23765        });
23766        check_outros();
23767      }
23768      if (
23769        /*show_fullscreen_button*/
23770        ctx2[1]
23771      ) {
23772        if (if_block2) {
23773          if_block2.p(ctx2, dirty);
23774          if (dirty & /*show_fullscreen_button*/
23775          2) {
23776            transition_in(if_block2, 1);
23777          }
23778        } else {
23779          if_block2 = create_if_block$5(ctx2);
23780          if_block2.c();
23781          transition_in(if_block2, 1);
23782          if_block2.m(div0, null);
23783        }
23784      } else if (if_block2) {
23785        group_outros();
23786        transition_out(if_block2, 1, 1, () => {
23787          if_block2 = null;
23788        });
23789        check_outros();
23790      }
23791    },
23792    i(local) {
23793      if (current) return;
23794      transition_in(if_block0);
23795      transition_in(if_block1);
23796      transition_in(if_block2);
23797      current = true;
23798    },
23799    o(local) {
23800      transition_out(if_block0);
23801      transition_out(if_block1);
23802      transition_out(if_block2);
23803      current = false;
23804    },
23805    d(detaching) {
23806      if (detaching) {
23807        detach(div1);
23808      }
23809      if (if_block0) if_block0.d();
23810      if (if_block1) if_block1.d();
23811      if (if_block2) if_block2.d();
23812    }
23813  };
23814}
23815function instance$9($$self, $$props, $$invalidate) {
23816  let { show_fullscreen_button = false } = $$props;
23817  let { show_copy_button = false } = $$props;
23818  let { show_search = "none" } = $$props;
23819  let { fullscreen = false } = $$props;
23820  let { on_copy } = $$props;
23821  let { on_commit_filter } = $$props;
23822  const dispatch2 = createEventDispatcher();
23823  let copied = false;
23824  let timer;
23825  let { current_search_query = null } = $$props;
23826  let input_value = "";
23827  function handle_search_input(e) {
23828    const target = e.target;
23829    input_value = target.value;
23830    const new_query = input_value || null;
23831    if (current_search_query !== new_query) {
23832      $$invalidate(0, current_search_query = new_query);
23833      dispatch2("search", current_search_query);
23834    }
23835  }
23836  function copy_feedback() {
23837    $$invalidate(6, copied = true);
23838    if (timer) clearTimeout(timer);
23839    timer = setTimeout(
23840      () => {
23841        $$invalidate(6, copied = false);
23842      },
23843      2e3
23844    );
23845  }
23846  async function handle_copy() {
23847    await on_copy();
23848    copy_feedback();
23849  }
23850  onDestroy(() => {
23851    if (timer) clearTimeout(timer);
23852  });
23853  function fullscreen_handler(event) {
23854    bubble.call(this, $$self, event);
23855  }
23856  $$self.$$set = ($$props2) => {
23857    if ("show_fullscreen_button" in $$props2) $$invalidate(1, show_fullscreen_button = $$props2.show_fullscreen_button);
23858    if ("show_copy_button" in $$props2) $$invalidate(2, show_copy_button = $$props2.show_copy_button);
23859    if ("show_search" in $$props2) $$invalidate(3, show_search = $$props2.show_search);
23860    if ("fullscreen" in $$props2) $$invalidate(4, fullscreen = $$props2.fullscreen);
23861    if ("on_copy" in $$props2) $$invalidate(9, on_copy = $$props2.on_copy);
23862    if ("on_commit_filter" in $$props2) $$invalidate(5, on_commit_filter = $$props2.on_commit_filter);
23863    if ("current_search_query" in $$props2) $$invalidate(0, current_search_query = $$props2.current_search_query);
23864  };
23865  return [
23866    current_search_query,
23867    show_fullscreen_button,
23868    show_copy_button,
23869    show_search,
23870    fullscreen,
23871    on_commit_filter,
23872    copied,
23873    handle_search_input,
23874    handle_copy,
23875    on_copy,
23876    fullscreen_handler
23877  ];
23878}
23879let Toolbar$1 = class Toolbar extends SvelteComponent {
23880  constructor(options) {
23881    super();
23882    init(this, options, instance$9, create_fragment$9, safe_not_equal, {
23883      show_fullscreen_button: 1,
23884      show_copy_button: 2,
23885      show_search: 3,
23886      fullscreen: 4,
23887      on_copy: 9,
23888      on_commit_filter: 5,
23889      current_search_query: 0
23890    });
23891  }
23892};
23893function cast_value_to_type$1(v, t) {
23894  if (t === "number") {
23895    const n = Number(v);
23896    return isNaN(n) ? v : n;
23897  }
23898  if (t === "bool") {
23899    if (typeof v === "boolean") return v;
23900    if (typeof v === "number") return v !== 0;
23901    const s = String(v).toLowerCase();
23902    if (s === "true" || s === "1") return true;
23903    if (s === "false" || s === "0") return false;
23904    return v;
23905  }
23906  if (t === "date") {
23907    const d = new Date(v);
23908    return isNaN(d.getTime()) ? v : d.toISOString();
23909  }
23910  return v;
23911}
23912function make_headers$1(_head, col_count, els, make_id2) {
23913  let _h = _head || [];
23914  if (col_count[1] === "fixed" && _h.length < col_count[0]) {
23915    const fill = Array(col_count[0] - _h.length).fill("").map((_, i) => `${i + _h.length}`);
23916    _h = _h.concat(fill);
23917  }
23918  if (!_h || _h.length === 0) {
23919    return Array(col_count[0]).fill(0).map((_, i) => {
23920      const _id = make_id2();
23921      els[_id] = { cell: null, input: null };
23922      return { id: _id, value: JSON.stringify(i + 1) };
23923    });
23924  }
23925  return _h.map((h, i) => {
23926    const _id = make_id2();
23927    els[_id] = { cell: null, input: null };
23928    return { id: _id, value: h ?? "" };
23929  });
23930}
23931function process_data$1(values, els, data_binding, make_id2, display_value = null, datatype) {
23932  if (!values || values.length === 0) {
23933    return [];
23934  }
23935  const result = values.map((row, i) => {
23936    return row.map((value, j) => {
23937      var _a;
23938      const _id = make_id2();
23939      els[_id] = { cell: null, input: null };
23940      data_binding[_id] = value;
23941      let display = (_a = display_value == null ? void 0 : display_value[i]) == null ? void 0 : _a[j];
23942      if (display === void 0) {
23943        display = String(value);
23944      }
23945      const dtype = Array.isArray(datatype) ? datatype[j] : datatype;
23946      return {
23947        id: _id,
23948        value: cast_value_to_type$1(value, dtype),
23949        display_value: display
23950      };
23951    });
23952  });
23953  return result;
23954}
23955async function save_cell_value$1(input_value, ctx, row, col) {
23956  var _a;
23957  if (!ctx.data || !ctx.data[row] || !ctx.data[row][col]) return;
23958  const old_value = ctx.data[row][col].value;
23959  ctx.data[row][col].value = input_value;
23960  if (ctx.data[row][col].display_value !== void 0) {
23961    ctx.data[row][col].display_value = input_value;
23962  }
23963  if (old_value !== input_value && ctx.dispatch) {
23964    ctx.dispatch("change", {
23965      data: ctx.data.map((row2) => row2.map((cell) => cell.value)),
23966      headers: ((_a = ctx.headers) == null ? void 0 : _a.map((h) => h.value)) || [],
23967      metadata: null
23968    });
23969  }
23970  ctx.actions.set_selected([row, col]);
23971}
23972async function handle_cell_blur$1(event, ctx, coords) {
23973  if (!ctx.data || !ctx.headers || !ctx.els) return;
23974  const input_el = event.target;
23975  if (!input_el || input_el.value === void 0) return;
23976  await save_cell_value$1(input_el.value, ctx, coords[0], coords[1]);
23977}
23978function handle_header_navigation$1(event, ctx) {
23979  const state = get_store_value(ctx.state);
23980  const selected_header = state.ui_state.selected_header;
23981  const header_edit = state.ui_state.header_edit;
23982  const headers = ctx.headers || [];
23983  if (selected_header === false || header_edit !== false) return false;
23984  switch (event.key) {
23985    case "ArrowDown":
23986      ctx.actions.set_selected_header(false);
23987      ctx.actions.set_selected([0, selected_header]);
23988      ctx.actions.set_selected_cells([[0, selected_header]]);
23989      return true;
23990    case "ArrowLeft":
23991      ctx.actions.set_selected_header(
23992        selected_header > 0 ? selected_header - 1 : selected_header
23993      );
23994      return true;
23995    case "ArrowRight":
23996      ctx.actions.set_selected_header(
23997        selected_header < headers.length - 1 ? selected_header + 1 : selected_header
23998      );
23999      return true;
24000    case "Escape":
24001      event.preventDefault();
24002      ctx.actions.set_selected_header(false);
24003      return true;
24004    case "Enter":
24005      event.preventDefault();
24006      if (state.config.editable) {
24007        ctx.actions.set_header_edit(selected_header);
24008      }
24009      return true;
24010  }
24011  return false;
24012}
24013function handle_delete_operation$1(event, ctx) {
24014  var _a;
24015  if (!ctx.data || !ctx.headers || !ctx.els || !ctx.dispatch) return false;
24016  const state = get_store_value(ctx.state);
24017  if (!state.config.editable) return false;
24018  if (event.key !== "Delete" && event.key !== "Backspace") return false;
24019  const editing = state.ui_state.editing;
24020  const selected_cells = state.ui_state.selected_cells;
24021  const static_columns = state.config.static_columns || [];
24022  if (selected_cells.some(([_, col]) => static_columns.includes(col))) {
24023    return false;
24024  }
24025  if (editing) {
24026    const [row, col] = editing;
24027    const input_el = (_a = ctx.els[ctx.data[row][col].id]) == null ? void 0 : _a.input;
24028    if (input_el && input_el.selectionStart !== input_el.selectionEnd) {
24029      return false;
24030    }
24031    if (event.key === "Delete" && (input_el == null ? void 0 : input_el.selectionStart) !== (input_el == null ? void 0 : input_el.value.length)) {
24032      return false;
24033    }
24034    if (event.key === "Backspace" && (input_el == null ? void 0 : input_el.selectionStart) !== 0) {
24035      return false;
24036    }
24037  }
24038  event.preventDefault();
24039  if (selected_cells.length > 0) {
24040    const new_data = handle_delete_key$1(ctx.data, selected_cells);
24041    ctx.dispatch("change", {
24042      data: new_data.map((row) => row.map((cell) => cell.value)),
24043      headers: ctx.headers.map((h) => h.value),
24044      metadata: null
24045    });
24046  }
24047  return true;
24048}
24049function handle_arrow_keys$1(event, ctx, i, j) {
24050  const state = get_store_value(ctx.state);
24051  const editing = state.ui_state.editing;
24052  const selected_cells = state.ui_state.selected_cells;
24053  if (editing) return false;
24054  if (!ctx.data) return false;
24055  event.preventDefault();
24056  const next_coords = ctx.actions.move_cursor(event, [i, j], ctx.data);
24057  if (next_coords) {
24058    if (event.shiftKey) {
24059      ctx.actions.set_selected_cells(
24060        ctx.actions.get_range_selection(
24061          selected_cells.length > 0 ? selected_cells[0] : [i, j],
24062          next_coords
24063        )
24064      );
24065      ctx.actions.set_editing(false);
24066    } else {
24067      ctx.actions.set_selected_cells([next_coords]);
24068      ctx.actions.set_editing(false);
24069    }
24070    ctx.actions.set_selected(next_coords);
24071  } else if (next_coords === false && event.key === "ArrowUp" && i === 0) {
24072    ctx.actions.set_selected_header(j);
24073    ctx.actions.set_selected(false);
24074    ctx.actions.set_selected_cells([]);
24075    ctx.actions.set_editing(false);
24076  }
24077  return true;
24078}
24079async function handle_enter_key$1(event, ctx, i, j) {
24080  var _a, _b;
24081  if (!ctx.data || !ctx.els) return false;
24082  const state = get_store_value(ctx.state);
24083  if (!state.config.editable) return false;
24084  const editing = state.ui_state.editing;
24085  if (editing && event.shiftKey) return false;
24086  event.preventDefault();
24087  if (editing && dequal(editing, [i, j])) {
24088    const cell_id = ctx.data[i][j].id;
24089    const input_el = (_a = ctx.els[cell_id]) == null ? void 0 : _a.input;
24090    if (input_el) {
24091      await save_cell_value$1(input_el.value, ctx, i, j);
24092    }
24093    ctx.actions.set_editing(false);
24094    await tick();
24095    (_b = ctx.parent_element) == null ? void 0 : _b.focus();
24096  } else {
24097    ctx.actions.set_editing([i, j]);
24098  }
24099  return true;
24100}
24101function handle_tab_key$1(event, ctx, i, j) {
24102  if (!ctx.data) return false;
24103  event.preventDefault();
24104  ctx.actions.set_editing(false);
24105  const next_cell = ctx.actions.get_next_cell_coordinates(
24106    [i, j],
24107    ctx.data,
24108    event.shiftKey
24109  );
24110  if (next_cell) {
24111    ctx.actions.set_selected_cells([next_cell]);
24112    ctx.actions.set_selected(next_cell);
24113    if (get_store_value(ctx.state).config.editable) {
24114      ctx.actions.set_editing(next_cell);
24115    }
24116  }
24117  return true;
24118}
24119function handle_default_key$1(event, ctx, i, j) {
24120  const state = get_store_value(ctx.state);
24121  if (!state.config.editable) return false;
24122  const editing = state.ui_state.editing;
24123  if (event.key.length === 1 && (!editing || !dequal(editing, [i, j]))) {
24124    ctx.actions.set_editing([i, j]);
24125    return true;
24126  }
24127  return false;
24128}
24129async function handle_cell_navigation$1(event, ctx) {
24130  if (!ctx.data) return false;
24131  const state = get_store_value(ctx.state);
24132  const selected = state.ui_state.selected;
24133  const selected_cells = state.ui_state.selected_cells;
24134  if (!selected) return false;
24135  if (event.key === "c" && (event.metaKey || event.ctrlKey)) {
24136    event.preventDefault();
24137    if (selected_cells.length > 0) {
24138      await copy_table_data$1(ctx.data, selected_cells);
24139    }
24140    ctx.actions.set_copy_flash(true);
24141    return true;
24142  }
24143  const [i, j] = selected;
24144  switch (event.key) {
24145    case "ArrowRight":
24146    case "ArrowLeft":
24147    case "ArrowDown":
24148    case "ArrowUp":
24149      return handle_arrow_keys$1(event, ctx, i, j);
24150    case "Escape":
24151      if (!state.config.editable) return false;
24152      event.preventDefault();
24153      ctx.actions.set_editing(false);
24154      tick().then(() => {
24155        if (ctx.parent_element) {
24156          ctx.parent_element.focus();
24157        }
24158      });
24159      return true;
24160    case "Enter":
24161      return await handle_enter_key$1(event, ctx, i, j);
24162    case "Tab":
24163      return handle_tab_key$1(event, ctx, i, j);
24164    case "Delete":
24165    case "Backspace":
24166      return handle_delete_operation$1(event, ctx);
24167    default:
24168      return handle_default_key$1(event, ctx, i, j);
24169  }
24170}
24171async function handle_keydown$1(event, context) {
24172  if (handle_header_navigation$1(event, context)) return;
24173  if (handle_delete_operation$1(event, context)) return;
24174  await handle_cell_navigation$1(event, context);
24175}
24176function create_drag_handlers$1(state, set_is_dragging, set_selected_cells, set_selected, handle_cell_click, show_row_numbers, parent_element) {
24177  const start_drag = (event, row, col) => {
24178    const target = event.target;
24179    const is_checkbox_click = target.type === "checkbox" || target.closest('input[type="checkbox"]') || target.closest(".bool-cell");
24180    if (event.target instanceof HTMLAnchorElement || show_row_numbers && col === -1 || is_checkbox_click)
24181      return;
24182    event.preventDefault();
24183    event.stopPropagation();
24184    state.mouse_down_pos = { x: event.clientX, y: event.clientY };
24185    state.drag_start = [row, col];
24186    if (!event.shiftKey && !event.metaKey && !event.ctrlKey) {
24187      set_selected_cells([[row, col]]);
24188      set_selected([row, col]);
24189      handle_cell_click(event, row, col);
24190    }
24191  };
24192  const update_selection = (event) => {
24193    const cell = event.target.closest("td");
24194    if (!cell) return;
24195    const row = parseInt(cell.getAttribute("data-row") || "0");
24196    const col = parseInt(cell.getAttribute("data-col") || "0");
24197    if (isNaN(row) || isNaN(col)) return;
24198    const selection_range = get_range_selection$1(state.drag_start, [row, col]);
24199    set_selected_cells(selection_range);
24200    set_selected([row, col]);
24201  };
24202  const end_drag = (event) => {
24203    if (!state.is_dragging && state.drag_start) {
24204      handle_cell_click(event, state.drag_start[0], state.drag_start[1]);
24205    } else if (state.is_dragging && parent_element) {
24206      parent_element.focus();
24207    }
24208    state.is_dragging = false;
24209    set_is_dragging(false);
24210    state.drag_start = null;
24211    state.mouse_down_pos = null;
24212  };
24213  return {
24214    handle_mouse_down: start_drag,
24215    handle_mouse_move(event) {
24216      if (!state.drag_start || !state.mouse_down_pos) return;
24217      if (!(event.buttons & 1)) {
24218        end_drag(event);
24219        return;
24220      }
24221      const dx = Math.abs(event.clientX - state.mouse_down_pos.x);
24222      const dy = Math.abs(event.clientY - state.mouse_down_pos.y);
24223      if (!state.is_dragging && (dx > 3 || dy > 3)) {
24224        state.is_dragging = true;
24225        set_is_dragging(true);
24226      }
24227      if (state.is_dragging) {
24228        update_selection(event);
24229      }
24230    },
24231    handle_mouse_up: end_drag
24232  };
24233}
24234const { Map: Map_1, window: window_1 } = globals;
24235function get_each_context_1(ctx, list2, i) {
24236  const child_ctx = ctx.slice();
24237  child_ctx[147] = list2[i].value;
24238  child_ctx[148] = list2[i].id;
24239  child_ctx[151] = list2;
24240  child_ctx[152] = i;
24241  return child_ctx;
24242}
24243function get_each_context$1(ctx, list2, i) {
24244  const child_ctx = ctx.slice();
24245  child_ctx[147] = list2[i].value;
24246  child_ctx[148] = list2[i].id;
24247  child_ctx[149] = list2;
24248  child_ctx[150] = i;
24249  return child_ctx;
24250}
24251function get_each_context_2(ctx, list2, i) {
24252  const child_ctx = ctx.slice();
24253  child_ctx[147] = list2[i].value;
24254  child_ctx[148] = list2[i].id;
24255  child_ctx[153] = list2;
24256  child_ctx[150] = i;
24257  return child_ctx;
24258}
24259function get_each_context_3(ctx, list2, i) {
24260  const child_ctx = ctx.slice();
24261  child_ctx[147] = list2[i].value;
24262  child_ctx[148] = list2[i].id;
24263  child_ctx[154] = list2;
24264  child_ctx[152] = i;
24265  return child_ctx;
24266}
24267function create_if_block_8(ctx) {
24268  let div;
24269  let t;
24270  let toolbar;
24271  let current;
24272  let if_block = (
24273    /*label*/
24274    ctx[3] && /*label*/
24275    ctx[3].length !== 0 && /*show_label*/
24276    ctx[4] && create_if_block_9(ctx)
24277  );
24278  toolbar = new Toolbar$1({
24279    props: {
24280      show_fullscreen_button: (
24281        /*show_fullscreen_button*/
24282        ctx[18]
24283      ),
24284      fullscreen: (
24285        /*fullscreen*/
24286        ctx[23]
24287      ),
24288      on_copy: (
24289        /*func*/
24290        ctx[90]
24291      ),
24292      show_copy_button: (
24293        /*show_copy_button*/
24294        ctx[19]
24295      ),
24296      show_search: (
24297        /*show_search*/
24298        ctx[21]
24299      ),
24300      on_commit_filter: (
24301        /*commit_filter*/
24302        ctx[68]
24303      ),
24304      current_search_query: (
24305        /*$df_state*/
24306        ctx[33].current_search_query
24307      )
24308    }
24309  });
24310  toolbar.$on(
24311    "search",
24312    /*search_handler*/
24313    ctx[91]
24314  );
24315  toolbar.$on(
24316    "fullscreen",
24317    /*fullscreen_handler*/
24318    ctx[92]
24319  );
24320  return {
24321    c() {
24322      div = element("div");
24323      if (if_block) if_block.c();
24324      t = space();
24325      create_component(toolbar.$$.fragment);
24326      attr(div, "class", "header-row svelte-4x7jh");
24327    },
24328    m(target, anchor) {
24329      insert(target, div, anchor);
24330      if (if_block) if_block.m(div, null);
24331      append(div, t);
24332      mount_component(toolbar, div, null);
24333      current = true;
24334    },
24335    p(ctx2, dirty) {
24336      if (
24337        /*label*/
24338        ctx2[3] && /*label*/
24339        ctx2[3].length !== 0 && /*show_label*/
24340        ctx2[4]
24341      ) {
24342        if (if_block) {
24343          if_block.p(ctx2, dirty);
24344        } else {
24345          if_block = create_if_block_9(ctx2);
24346          if_block.c();
24347          if_block.m(div, t);
24348        }
24349      } else if (if_block) {
24350        if_block.d(1);
24351        if_block = null;
24352      }
24353      const toolbar_changes = {};
24354      if (dirty[0] & /*show_fullscreen_button*/
24355      262144) toolbar_changes.show_fullscreen_button = /*show_fullscreen_button*/
24356      ctx2[18];
24357      if (dirty[0] & /*fullscreen*/
24358      8388608) toolbar_changes.fullscreen = /*fullscreen*/
24359      ctx2[23];
24360      if (dirty[0] & /*data*/
24361      67108864) toolbar_changes.on_copy = /*func*/
24362      ctx2[90];
24363      if (dirty[0] & /*show_copy_button*/
24364      524288) toolbar_changes.show_copy_button = /*show_copy_button*/
24365      ctx2[19];
24366      if (dirty[0] & /*show_search*/
24367      2097152) toolbar_changes.show_search = /*show_search*/
24368      ctx2[21];
24369      if (dirty[1] & /*$df_state*/
24370      4) toolbar_changes.current_search_query = /*$df_state*/
24371      ctx2[33].current_search_query;
24372      toolbar.$set(toolbar_changes);
24373    },
24374    i(local) {
24375      if (current) return;
24376      transition_in(toolbar.$$.fragment, local);
24377      current = true;
24378    },
24379    o(local) {
24380      transition_out(toolbar.$$.fragment, local);
24381      current = false;
24382    },
24383    d(detaching) {
24384      if (detaching) {
24385        detach(div);
24386      }
24387      if (if_block) if_block.d();
24388      destroy_component(toolbar);
24389    }
24390  };
24391}
24392function create_if_block_9(ctx) {
24393  let div;
24394  let p;
24395  let t;
24396  return {
24397    c() {
24398      div = element("div");
24399      p = element("p");
24400      t = text(
24401        /*label*/
24402        ctx[3]
24403      );
24404      attr(p, "class", "svelte-4x7jh");
24405      attr(div, "class", "label svelte-4x7jh");
24406    },
24407    m(target, anchor) {
24408      insert(target, div, anchor);
24409      append(div, p);
24410      append(p, t);
24411    },
24412    p(ctx2, dirty) {
24413      if (dirty[0] & /*label*/
24414      8) set_data(
24415        t,
24416        /*label*/
24417        ctx2[3]
24418      );
24419    },
24420    d(detaching) {
24421      if (detaching) {
24422        detach(div);
24423      }
24424    }
24425  };
24426}
24427function create_if_block_7(ctx) {
24428  let caption;
24429  let t;
24430  return {
24431    c() {
24432      caption = element("caption");
24433      t = text(
24434        /*label*/
24435        ctx[3]
24436      );
24437      attr(caption, "class", "sr-only svelte-4x7jh");
24438    },
24439    m(target, anchor) {
24440      insert(target, caption, anchor);
24441      append(caption, t);
24442    },
24443    p(ctx2, dirty) {
24444      if (dirty[0] & /*label*/
24445      8) set_data(
24446        t,
24447        /*label*/
24448        ctx2[3]
24449      );
24450    },
24451    d(detaching) {
24452      if (detaching) {
24453        detach(caption);
24454      }
24455    }
24456  };
24457}
24458function create_if_block_6$2(ctx) {
24459  let rownumber;
24460  let current;
24461  rownumber = new RowNumber$1({ props: { is_header: true } });
24462  return {
24463    c() {
24464      create_component(rownumber.$$.fragment);
24465    },
24466    m(target, anchor) {
24467      mount_component(rownumber, target, anchor);
24468      current = true;
24469    },
24470    i(local) {
24471      if (current) return;
24472      transition_in(rownumber.$$.fragment, local);
24473      current = true;
24474    },
24475    o(local) {
24476      transition_out(rownumber.$$.fragment, local);
24477      current = false;
24478    },
24479    d(detaching) {
24480      destroy_component(rownumber, detaching);
24481    }
24482  };
24483}
24484function create_each_block_3(key_1, ctx) {
24485  let first;
24486  let tableheader;
24487  let updating_value;
24488  let updating_el;
24489  let current;
24490  function tableheader_value_binding(value) {
24491    ctx[93](
24492      value,
24493      /*i*/
24494      ctx[152]
24495    );
24496  }
24497  function tableheader_el_binding(value) {
24498    ctx[94](
24499      value,
24500      /*id*/
24501      ctx[148]
24502    );
24503  }
24504  let tableheader_props = {
24505    i: (
24506      /*i*/
24507      ctx[152]
24508    ),
24509    actual_pinned_columns: (
24510      /*actual_pinned_columns*/
24511      ctx[53]
24512    ),
24513    header_edit: (
24514      /*header_edit*/
24515      ctx[52]
24516    ),
24517    selected_header: (
24518      /*selected_header*/
24519      ctx[51]
24520    ),
24521    headers: (
24522      /*headers*/
24523      ctx[0]
24524    ),
24525    get_cell_width,
24526    handle_header_click: (
24527      /*handle_header_click*/
24528      ctx[60]
24529    ),
24530    toggle_header_menu: (
24531      /*toggle_header_menu*/
24532      ctx[65]
24533    ),
24534    end_header_edit: (
24535      /*end_header_edit*/
24536      ctx[61]
24537    ),
24538    sort_columns: (
24539      /*$df_state*/
24540      ctx[33].sort_state.sort_columns
24541    ),
24542    filter_columns: (
24543      /*$df_state*/
24544      ctx[33].filter_state.filter_columns
24545    ),
24546    latex_delimiters: (
24547      /*latex_delimiters*/
24548      ctx[7]
24549    ),
24550    line_breaks: (
24551      /*line_breaks*/
24552      ctx[14]
24553    ),
24554    max_chars: (
24555      /*max_chars*/
24556      ctx[20]
24557    ),
24558    editable: (
24559      /*editable*/
24560      ctx[9]
24561    ),
24562    is_static: (
24563      /*static_columns*/
24564      ctx[22].includes(
24565        /*i*/
24566        ctx[152]
24567      )
24568    ),
24569    i18n: (
24570      /*i18n*/
24571      ctx[12]
24572    ),
24573    col_count: (
24574      /*col_count*/
24575      ctx[5]
24576    ),
24577    datatype: Array.isArray(
24578      /*datatype*/
24579      ctx[2]
24580    ) ? (
24581      /*datatype*/
24582      ctx[2][
24583        /*i*/
24584        ctx[152]
24585      ]
24586    ) : (
24587      /*datatype*/
24588      ctx[2]
24589    ),
24590    data: (
24591      /*data*/
24592      ctx[26]
24593    ),
24594    on_select_all: (
24595      /*handle_select_all*/
24596      ctx[72]
24597    )
24598  };
24599  if (
24600    /*_headers*/
24601    ctx[25][
24602      /*i*/
24603      ctx[152]
24604    ].value !== void 0
24605  ) {
24606    tableheader_props.value = /*_headers*/
24607    ctx[25][
24608      /*i*/
24609      ctx[152]
24610    ].value;
24611  }
24612  if (
24613    /*els*/
24614    ctx[24][
24615      /*id*/
24616      ctx[148]
24617    ].input !== void 0
24618  ) {
24619    tableheader_props.el = /*els*/
24620    ctx[24][
24621      /*id*/
24622      ctx[148]
24623    ].input;
24624  }
24625  tableheader = new TableHeader$1({ props: tableheader_props });
24626  binding_callbacks.push(() => bind(tableheader, "value", tableheader_value_binding));
24627  binding_callbacks.push(() => bind(tableheader, "el", tableheader_el_binding));
24628  return {
24629    key: key_1,
24630    first: null,
24631    c() {
24632      first = empty();
24633      create_component(tableheader.$$.fragment);
24634      this.first = first;
24635    },
24636    m(target, anchor) {
24637      insert(target, first, anchor);
24638      mount_component(tableheader, target, anchor);
24639      current = true;
24640    },
24641    p(new_ctx, dirty) {
24642      ctx = new_ctx;
24643      const tableheader_changes = {};
24644      if (dirty[0] & /*_headers*/
24645      33554432) tableheader_changes.i = /*i*/
24646      ctx[152];
24647      if (dirty[1] & /*actual_pinned_columns*/
24648      4194304) tableheader_changes.actual_pinned_columns = /*actual_pinned_columns*/
24649      ctx[53];
24650      if (dirty[1] & /*header_edit*/
24651      2097152) tableheader_changes.header_edit = /*header_edit*/
24652      ctx[52];
24653      if (dirty[1] & /*selected_header*/
24654      1048576) tableheader_changes.selected_header = /*selected_header*/
24655      ctx[51];
24656      if (dirty[0] & /*headers*/
24657      1) tableheader_changes.headers = /*headers*/
24658      ctx[0];
24659      if (dirty[1] & /*$df_state*/
24660      4) tableheader_changes.sort_columns = /*$df_state*/
24661      ctx[33].sort_state.sort_columns;
24662      if (dirty[1] & /*$df_state*/
24663      4) tableheader_changes.filter_columns = /*$df_state*/
24664      ctx[33].filter_state.filter_columns;
24665      if (dirty[0] & /*latex_delimiters*/
24666      128) tableheader_changes.latex_delimiters = /*latex_delimiters*/
24667      ctx[7];
24668      if (dirty[0] & /*line_breaks*/
24669      16384) tableheader_changes.line_breaks = /*line_breaks*/
24670      ctx[14];
24671      if (dirty[0] & /*max_chars*/
24672      1048576) tableheader_changes.max_chars = /*max_chars*/
24673      ctx[20];
24674      if (dirty[0] & /*editable*/
24675      512) tableheader_changes.editable = /*editable*/
24676      ctx[9];
24677      if (dirty[0] & /*static_columns, _headers*/
24678      37748736) tableheader_changes.is_static = /*static_columns*/
24679      ctx[22].includes(
24680        /*i*/
24681        ctx[152]
24682      );
24683      if (dirty[0] & /*i18n*/
24684      4096) tableheader_changes.i18n = /*i18n*/
24685      ctx[12];
24686      if (dirty[0] & /*col_count*/
24687      32) tableheader_changes.col_count = /*col_count*/
24688      ctx[5];
24689      if (dirty[0] & /*datatype, _headers*/
24690      33554436) tableheader_changes.datatype = Array.isArray(
24691        /*datatype*/
24692        ctx[2]
24693      ) ? (
24694        /*datatype*/
24695        ctx[2][
24696          /*i*/
24697          ctx[152]
24698        ]
24699      ) : (
24700        /*datatype*/
24701        ctx[2]
24702      );
24703      if (dirty[0] & /*data*/
24704      67108864) tableheader_changes.data = /*data*/
24705      ctx[26];
24706      if (!updating_value && dirty[0] & /*_headers*/
24707      33554432) {
24708        updating_value = true;
24709        tableheader_changes.value = /*_headers*/
24710        ctx[25][
24711          /*i*/
24712          ctx[152]
24713        ].value;
24714        add_flush_callback(() => updating_value = false);
24715      }
24716      if (!updating_el && dirty[0] & /*els, _headers*/
24717      50331648) {
24718        updating_el = true;
24719        tableheader_changes.el = /*els*/
24720        ctx[24][
24721          /*id*/
24722          ctx[148]
24723        ].input;
24724        add_flush_callback(() => updating_el = false);
24725      }
24726      tableheader.$set(tableheader_changes);
24727    },
24728    i(local) {
24729      if (current) return;
24730      transition_in(tableheader.$$.fragment, local);
24731      current = true;
24732    },
24733    o(local) {
24734      transition_out(tableheader.$$.fragment, local);
24735      current = false;
24736    },
24737    d(detaching) {
24738      if (detaching) {
24739        detach(first);
24740      }
24741      destroy_component(tableheader, detaching);
24742    }
24743  };
24744}
24745function create_if_block_5$2(ctx) {
24746  let rownumber;
24747  let current;
24748  rownumber = new RowNumber$1({ props: { index: 0 } });
24749  return {
24750    c() {
24751      create_component(rownumber.$$.fragment);
24752    },
24753    m(target, anchor) {
24754      mount_component(rownumber, target, anchor);
24755      current = true;
24756    },
24757    i(local) {
24758      if (current) return;
24759      transition_in(rownumber.$$.fragment, local);
24760      current = true;
24761    },
24762    o(local) {
24763      transition_out(rownumber.$$.fragment, local);
24764      current = false;
24765    },
24766    d(detaching) {
24767      destroy_component(rownumber, detaching);
24768    }
24769  };
24770}
24771function create_each_block_2(key_1, ctx) {
24772  let td;
24773  let div;
24774  let editablecell;
24775  let t;
24776  let j = (
24777    /*j*/
24778    ctx[150]
24779  );
24780  let current;
24781  editablecell = new EditableCell$1({
24782    props: {
24783      value: (
24784        /*value*/
24785        ctx[147]
24786      ),
24787      latex_delimiters: (
24788        /*latex_delimiters*/
24789        ctx[7]
24790      ),
24791      line_breaks: (
24792        /*line_breaks*/
24793        ctx[14]
24794      ),
24795      datatype: Array.isArray(
24796        /*datatype*/
24797        ctx[2]
24798      ) ? (
24799        /*datatype*/
24800        ctx[2][
24801          /*j*/
24802          ctx[150]
24803        ]
24804      ) : (
24805        /*datatype*/
24806        ctx[2]
24807      ),
24808      edit: false,
24809      el: null,
24810      editable: (
24811        /*editable*/
24812        ctx[9]
24813      ),
24814      i18n: (
24815        /*i18n*/
24816        ctx[12]
24817      ),
24818      show_selection_buttons: (
24819        /*selected_cells*/
24820        ctx[31].length === 1 && /*selected_cells*/
24821        ctx[31][0][0] === 0 && /*selected_cells*/
24822        ctx[31][0][1] === /*j*/
24823        ctx[150]
24824      ),
24825      coords: (
24826        /*selected_cell_coords*/
24827        ctx[39]
24828      ),
24829      on_select_column: (
24830        /*df_actions*/
24831        ctx[55].handle_select_column
24832      ),
24833      on_select_row: (
24834        /*df_actions*/
24835        ctx[55].handle_select_row
24836      ),
24837      is_dragging: (
24838        /*is_dragging*/
24839        ctx[42]
24840      )
24841    }
24842  });
24843  editablecell.$on(
24844    "blur",
24845    /*handle_blur*/
24846    ctx[64]
24847  );
24848  const assign_td = () => (
24849    /*td_binding*/
24850    ctx[95](td, j)
24851  );
24852  const unassign_td = () => (
24853    /*td_binding*/
24854    ctx[95](null, j)
24855  );
24856  return {
24857    key: key_1,
24858    first: null,
24859    c() {
24860      td = element("td");
24861      div = element("div");
24862      create_component(editablecell.$$.fragment);
24863      t = space();
24864      attr(div, "class", "cell-wrap svelte-4x7jh");
24865      attr(td, "tabindex", "-1");
24866      attr(td, "class", "svelte-4x7jh");
24867      this.first = td;
24868    },
24869    m(target, anchor) {
24870      insert(target, td, anchor);
24871      append(td, div);
24872      mount_component(editablecell, div, null);
24873      append(td, t);
24874      assign_td();
24875      current = true;
24876    },
24877    p(new_ctx, dirty) {
24878      ctx = new_ctx;
24879      const editablecell_changes = {};
24880      if (dirty[1] & /*max*/
24881      524288) editablecell_changes.value = /*value*/
24882      ctx[147];
24883      if (dirty[0] & /*latex_delimiters*/
24884      128) editablecell_changes.latex_delimiters = /*latex_delimiters*/
24885      ctx[7];
24886      if (dirty[0] & /*line_breaks*/
24887      16384) editablecell_changes.line_breaks = /*line_breaks*/
24888      ctx[14];
24889      if (dirty[0] & /*datatype*/
24890      4 | dirty[1] & /*max*/
24891      524288) editablecell_changes.datatype = Array.isArray(
24892        /*datatype*/
24893        ctx[2]
24894      ) ? (
24895        /*datatype*/
24896        ctx[2][
24897          /*j*/
24898          ctx[150]
24899        ]
24900      ) : (
24901        /*datatype*/
24902        ctx[2]
24903      );
24904      if (dirty[0] & /*editable*/
24905      512) editablecell_changes.editable = /*editable*/
24906      ctx[9];
24907      if (dirty[0] & /*i18n*/
24908      4096) editablecell_changes.i18n = /*i18n*/
24909      ctx[12];
24910      if (dirty[1] & /*selected_cells, max*/
24911      524289) editablecell_changes.show_selection_buttons = /*selected_cells*/
24912      ctx[31].length === 1 && /*selected_cells*/
24913      ctx[31][0][0] === 0 && /*selected_cells*/
24914      ctx[31][0][1] === /*j*/
24915      ctx[150];
24916      if (dirty[1] & /*selected_cell_coords*/
24917      256) editablecell_changes.coords = /*selected_cell_coords*/
24918      ctx[39];
24919      if (dirty[1] & /*is_dragging*/
24920      2048) editablecell_changes.is_dragging = /*is_dragging*/
24921      ctx[42];
24922      editablecell.$set(editablecell_changes);
24923      if (j !== /*j*/
24924      ctx[150]) {
24925        unassign_td();
24926        j = /*j*/
24927        ctx[150];
24928        assign_td();
24929      }
24930    },
24931    i(local) {
24932      if (current) return;
24933      transition_in(editablecell.$$.fragment, local);
24934      current = true;
24935    },
24936    o(local) {
24937      transition_out(editablecell.$$.fragment, local);
24938      current = false;
24939    },
24940    d(detaching) {
24941      if (detaching) {
24942        detach(td);
24943      }
24944      destroy_component(editablecell);
24945      unassign_td();
24946    }
24947  };
24948}
24949function create_if_block_4$2(ctx) {
24950  let rownumber;
24951  let current;
24952  rownumber = new RowNumber$1({ props: { is_header: true } });
24953  return {
24954    c() {
24955      create_component(rownumber.$$.fragment);
24956    },
24957    m(target, anchor) {
24958      mount_component(rownumber, target, anchor);
24959      current = true;
24960    },
24961    i(local) {
24962      if (current) return;
24963      transition_in(rownumber.$$.fragment, local);
24964      current = true;
24965    },
24966    o(local) {
24967      transition_out(rownumber.$$.fragment, local);
24968      current = false;
24969    },
24970    d(detaching) {
24971      destroy_component(rownumber, detaching);
24972    }
24973  };
24974}
24975function create_each_block_1(key_1, ctx) {
24976  let first;
24977  let tableheader;
24978  let updating_value;
24979  let updating_el;
24980  let current;
24981  function tableheader_value_binding_1(value) {
24982    ctx[100](
24983      value,
24984      /*i*/
24985      ctx[152]
24986    );
24987  }
24988  function tableheader_el_binding_1(value) {
24989    ctx[101](
24990      value,
24991      /*id*/
24992      ctx[148]
24993    );
24994  }
24995  let tableheader_props = {
24996    i: (
24997      /*i*/
24998      ctx[152]
24999    ),
25000    actual_pinned_columns: (
25001      /*actual_pinned_columns*/
25002      ctx[53]
25003    ),
25004    header_edit: (
25005      /*header_edit*/
25006      ctx[52]
25007    ),
25008    selected_header: (
25009      /*selected_header*/
25010      ctx[51]
25011    ),
25012    headers: (
25013      /*headers*/
25014      ctx[0]
25015    ),
25016    get_cell_width,
25017    handle_header_click: (
25018      /*handle_header_click*/
25019      ctx[60]
25020    ),
25021    toggle_header_menu: (
25022      /*toggle_header_menu*/
25023      ctx[65]
25024    ),
25025    end_header_edit: (
25026      /*end_header_edit*/
25027      ctx[61]
25028    ),
25029    sort_columns: (
25030      /*$df_state*/
25031      ctx[33].sort_state.sort_columns
25032    ),
25033    filter_columns: (
25034      /*$df_state*/
25035      ctx[33].filter_state.filter_columns
25036    ),
25037    latex_delimiters: (
25038      /*latex_delimiters*/
25039      ctx[7]
25040    ),
25041    line_breaks: (
25042      /*line_breaks*/
25043      ctx[14]
25044    ),
25045    max_chars: (
25046      /*max_chars*/
25047      ctx[20]
25048    ),
25049    editable: (
25050      /*editable*/
25051      ctx[9]
25052    ),
25053    is_static: (
25054      /*static_columns*/
25055      ctx[22].includes(
25056        /*i*/
25057        ctx[152]
25058      )
25059    ),
25060    i18n: (
25061      /*i18n*/
25062      ctx[12]
25063    ),
25064    col_count: (
25065      /*col_count*/
25066      ctx[5]
25067    ),
25068    datatype: Array.isArray(
25069      /*datatype*/
25070      ctx[2]
25071    ) ? (
25072      /*datatype*/
25073      ctx[2][
25074        /*i*/
25075        ctx[152]
25076      ]
25077    ) : (
25078      /*datatype*/
25079      ctx[2]
25080    ),
25081    data: (
25082      /*data*/
25083      ctx[26]
25084    ),
25085    on_select_all: (
25086      /*handle_select_all*/
25087      ctx[72]
25088    )
25089  };
25090  if (
25091    /*_headers*/
25092    ctx[25][
25093      /*i*/
25094      ctx[152]
25095    ].value !== void 0
25096  ) {
25097    tableheader_props.value = /*_headers*/
25098    ctx[25][
25099      /*i*/
25100      ctx[152]
25101    ].value;
25102  }
25103  if (
25104    /*els*/
25105    ctx[24][
25106      /*id*/
25107      ctx[148]
25108    ].input !== void 0
25109  ) {
25110    tableheader_props.el = /*els*/
25111    ctx[24][
25112      /*id*/
25113      ctx[148]
25114    ].input;
25115  }
25116  tableheader = new TableHeader$1({ props: tableheader_props });
25117  binding_callbacks.push(() => bind(tableheader, "value", tableheader_value_binding_1));
25118  binding_callbacks.push(() => bind(tableheader, "el", tableheader_el_binding_1));
25119  return {
25120    key: key_1,
25121    first: null,
25122    c() {
25123      first = empty();
25124      create_component(tableheader.$$.fragment);
25125      this.first = first;
25126    },
25127    m(target, anchor) {
25128      insert(target, first, anchor);
25129      mount_component(tableheader, target, anchor);
25130      current = true;
25131    },
25132    p(new_ctx, dirty) {
25133      ctx = new_ctx;
25134      const tableheader_changes = {};
25135      if (dirty[0] & /*_headers*/
25136      33554432) tableheader_changes.i = /*i*/
25137      ctx[152];
25138      if (dirty[1] & /*actual_pinned_columns*/
25139      4194304) tableheader_changes.actual_pinned_columns = /*actual_pinned_columns*/
25140      ctx[53];
25141      if (dirty[1] & /*header_edit*/
25142      2097152) tableheader_changes.header_edit = /*header_edit*/
25143      ctx[52];
25144      if (dirty[1] & /*selected_header*/
25145      1048576) tableheader_changes.selected_header = /*selected_header*/
25146      ctx[51];
25147      if (dirty[0] & /*headers*/
25148      1) tableheader_changes.headers = /*headers*/
25149      ctx[0];
25150      if (dirty[1] & /*$df_state*/
25151      4) tableheader_changes.sort_columns = /*$df_state*/
25152      ctx[33].sort_state.sort_columns;
25153      if (dirty[1] & /*$df_state*/
25154      4) tableheader_changes.filter_columns = /*$df_state*/
25155      ctx[33].filter_state.filter_columns;
25156      if (dirty[0] & /*latex_delimiters*/
25157      128) tableheader_changes.latex_delimiters = /*latex_delimiters*/
25158      ctx[7];
25159      if (dirty[0] & /*line_breaks*/
25160      16384) tableheader_changes.line_breaks = /*line_breaks*/
25161      ctx[14];
25162      if (dirty[0] & /*max_chars*/
25163      1048576) tableheader_changes.max_chars = /*max_chars*/
25164      ctx[20];
25165      if (dirty[0] & /*editable*/
25166      512) tableheader_changes.editable = /*editable*/
25167      ctx[9];
25168      if (dirty[0] & /*static_columns, _headers*/
25169      37748736) tableheader_changes.is_static = /*static_columns*/
25170      ctx[22].includes(
25171        /*i*/
25172        ctx[152]
25173      );
25174      if (dirty[0] & /*i18n*/
25175      4096) tableheader_changes.i18n = /*i18n*/
25176      ctx[12];
25177      if (dirty[0] & /*col_count*/
25178      32) tableheader_changes.col_count = /*col_count*/
25179      ctx[5];
25180      if (dirty[0] & /*datatype, _headers*/
25181      33554436) tableheader_changes.datatype = Array.isArray(
25182        /*datatype*/
25183        ctx[2]
25184      ) ? (
25185        /*datatype*/
25186        ctx[2][
25187          /*i*/
25188          ctx[152]
25189        ]
25190      ) : (
25191        /*datatype*/
25192        ctx[2]
25193      );
25194      if (dirty[0] & /*data*/
25195      67108864) tableheader_changes.data = /*data*/
25196      ctx[26];
25197      if (!updating_value && dirty[0] & /*_headers*/
25198      33554432) {
25199        updating_value = true;
25200        tableheader_changes.value = /*_headers*/
25201        ctx[25][
25202          /*i*/
25203          ctx[152]
25204        ].value;
25205        add_flush_callback(() => updating_value = false);
25206      }
25207      if (!updating_el && dirty[0] & /*els, _headers*/
25208      50331648) {
25209        updating_el = true;
25210        tableheader_changes.el = /*els*/
25211        ctx[24][
25212          /*id*/
25213          ctx[148]
25214        ].input;
25215        add_flush_callback(() => updating_el = false);
25216      }
25217      tableheader.$set(tableheader_changes);
25218    },
25219    i(local) {
25220      if (current) return;
25221      transition_in(tableheader.$$.fragment, local);
25222      current = true;
25223    },
25224    o(local) {
25225      transition_out(tableheader.$$.fragment, local);
25226      current = false;
25227    },
25228    d(detaching) {
25229      if (detaching) {
25230        detach(first);
25231      }
25232      destroy_component(tableheader, detaching);
25233    }
25234  };
25235}
25236function create_thead_slot(ctx) {
25237  let tr;
25238  let t;
25239  let each_blocks = [];
25240  let each_1_lookup = new Map_1();
25241  let current;
25242  let if_block = (
25243    /*show_row_numbers*/
25244    ctx[15] && create_if_block_4$2()
25245  );
25246  let each_value_1 = ensure_array_like(
25247    /*_headers*/
25248    ctx[25]
25249  );
25250  const get_key = (ctx2) => (
25251    /*id*/
25252    ctx2[148]
25253  );
25254  for (let i = 0; i < each_value_1.length; i += 1) {
25255    let child_ctx = get_each_context_1(ctx, each_value_1, i);
25256    let key = get_key(child_ctx);
25257    each_1_lookup.set(key, each_blocks[i] = create_each_block_1(key, child_ctx));
25258  }
25259  return {
25260    c() {
25261      tr = element("tr");
25262      if (if_block) if_block.c();
25263      t = space();
25264      for (let i = 0; i < each_blocks.length; i += 1) {
25265        each_blocks[i].c();
25266      }
25267      attr(tr, "slot", "thead");
25268      attr(tr, "class", "svelte-4x7jh");
25269    },
25270    m(target, anchor) {
25271      insert(target, tr, anchor);
25272      if (if_block) if_block.m(tr, null);
25273      append(tr, t);
25274      for (let i = 0; i < each_blocks.length; i += 1) {
25275        if (each_blocks[i]) {
25276          each_blocks[i].m(tr, null);
25277        }
25278      }
25279      current = true;
25280    },
25281    p(ctx2, dirty) {
25282      if (
25283        /*show_row_numbers*/
25284        ctx2[15]
25285      ) {
25286        if (if_block) {
25287          if (dirty[0] & /*show_row_numbers*/
25288          32768) {
25289            transition_in(if_block, 1);
25290          }
25291        } else {
25292          if_block = create_if_block_4$2();
25293          if_block.c();
25294          transition_in(if_block, 1);
25295          if_block.m(tr, t);
25296        }
25297      } else if (if_block) {
25298        group_outros();
25299        transition_out(if_block, 1, 1, () => {
25300          if_block = null;
25301        });
25302        check_outros();
25303      }
25304      if (dirty[0] & /*_headers, headers, latex_delimiters, line_breaks, max_chars, editable, static_columns, i18n, col_count, datatype, data, els*/
25305      122704549 | dirty[1] & /*actual_pinned_columns, header_edit, selected_header, handle_header_click, end_header_edit, $df_state*/
25306      1617952772 | dirty[2] & /*toggle_header_menu, handle_select_all*/
25307      1032) {
25308        each_value_1 = ensure_array_like(
25309          /*_headers*/
25310          ctx2[25]
25311        );
25312        group_outros();
25313        each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx2, each_value_1, each_1_lookup, tr, outro_and_destroy_block, create_each_block_1, null, get_each_context_1);
25314        check_outros();
25315      }
25316    },
25317    i(local) {
25318      if (current) return;
25319      transition_in(if_block);
25320      for (let i = 0; i < each_value_1.length; i += 1) {
25321        transition_in(each_blocks[i]);
25322      }
25323      current = true;
25324    },
25325    o(local) {
25326      transition_out(if_block);
25327      for (let i = 0; i < each_blocks.length; i += 1) {
25328        transition_out(each_blocks[i]);
25329      }
25330      current = false;
25331    },
25332    d(detaching) {
25333      if (detaching) {
25334        detach(tr);
25335      }
25336      if (if_block) if_block.d();
25337      for (let i = 0; i < each_blocks.length; i += 1) {
25338        each_blocks[i].d();
25339      }
25340    }
25341  };
25342}
25343function create_if_block_3$3(ctx) {
25344  let rownumber;
25345  let current;
25346  rownumber = new RowNumber$1({ props: { index: (
25347    /*index*/
25348    ctx[145]
25349  ) } });
25350  return {
25351    c() {
25352      create_component(rownumber.$$.fragment);
25353    },
25354    m(target, anchor) {
25355      mount_component(rownumber, target, anchor);
25356      current = true;
25357    },
25358    p(ctx2, dirty) {
25359      const rownumber_changes = {};
25360      if (dirty[4] & /*index*/
25361      2097152) rownumber_changes.index = /*index*/
25362      ctx2[145];
25363      rownumber.$set(rownumber_changes);
25364    },
25365    i(local) {
25366      if (current) return;
25367      transition_in(rownumber.$$.fragment, local);
25368      current = true;
25369    },
25370    o(local) {
25371      transition_out(rownumber.$$.fragment, local);
25372      current = false;
25373    },
25374    d(detaching) {
25375      destroy_component(rownumber, detaching);
25376    }
25377  };
25378}
25379function create_each_block$1(key_1, ctx) {
25380  let first;
25381  let tablecell;
25382  let updating_value;
25383  let updating_el;
25384  let current;
25385  function tablecell_value_binding(value) {
25386    ctx[98](
25387      value,
25388      /*index*/
25389      ctx[145],
25390      /*j*/
25391      ctx[150]
25392    );
25393  }
25394  function tablecell_el_binding(value) {
25395    ctx[99](
25396      value,
25397      /*id*/
25398      ctx[148]
25399    );
25400  }
25401  let tablecell_props = {
25402    display_value: (
25403      /*get_cell_display_value*/
25404      ctx[73](
25405        /*index*/
25406        ctx[145],
25407        /*j*/
25408        ctx[150]
25409      )
25410    ),
25411    index: (
25412      /*$df_state*/
25413      ctx[33].current_search_query !== void 0 && /*filtered_to_original_map*/
25414      ctx[27][
25415        /*index*/
25416        ctx[145]
25417      ] !== void 0 ? (
25418        /*filtered_to_original_map*/
25419        ctx[27][
25420          /*index*/
25421          ctx[145]
25422        ]
25423      ) : (
25424        /*index*/
25425        ctx[145]
25426      )
25427    ),
25428    j: (
25429      /*j*/
25430      ctx[150]
25431    ),
25432    actual_pinned_columns: (
25433      /*actual_pinned_columns*/
25434      ctx[53]
25435    ),
25436    get_cell_width,
25437    handle_cell_click: (
25438      /*func_1*/
25439      ctx[97]
25440    ),
25441    handle_blur: (
25442      /*handle_blur*/
25443      ctx[64]
25444    ),
25445    toggle_cell_menu: (
25446      /*df_actions*/
25447      ctx[55].toggle_cell_menu
25448    ),
25449    is_cell_selected: is_cell_selected$1,
25450    should_show_cell_menu: should_show_cell_menu$1,
25451    selected_cells: (
25452      /*selected_cells*/
25453      ctx[31]
25454    ),
25455    copy_flash: (
25456      /*copy_flash*/
25457      ctx[32]
25458    ),
25459    active_cell_menu: (
25460      /*active_cell_menu*/
25461      ctx[47]
25462    ),
25463    styling: (
25464      /*search_results*/
25465      ctx[35][
25466        /*index*/
25467        ctx[145]
25468      ][
25469        /*j*/
25470        ctx[150]
25471      ].styling
25472    ),
25473    latex_delimiters: (
25474      /*latex_delimiters*/
25475      ctx[7]
25476    ),
25477    line_breaks: (
25478      /*line_breaks*/
25479      ctx[14]
25480    ),
25481    datatype: Array.isArray(
25482      /*datatype*/
25483      ctx[2]
25484    ) ? (
25485      /*datatype*/
25486      ctx[2][
25487        /*j*/
25488        ctx[150]
25489      ]
25490    ) : (
25491      /*datatype*/
25492      ctx[2]
25493    ),
25494    editing: (
25495      /*editing*/
25496      ctx[48]
25497    ),
25498    max_chars: (
25499      /*max_chars*/
25500      ctx[20]
25501    ),
25502    editable: (
25503      /*editable*/
25504      ctx[9]
25505    ),
25506    is_static: (
25507      /*static_columns*/
25508      ctx[22].includes(
25509        /*j*/
25510        ctx[150]
25511      )
25512    ),
25513    i18n: (
25514      /*i18n*/
25515      ctx[12]
25516    ),
25517    components: (
25518      /*components*/
25519      ctx[8]
25520    ),
25521    handle_select_column: (
25522      /*df_actions*/
25523      ctx[55].handle_select_column
25524    ),
25525    handle_select_row: (
25526      /*df_actions*/
25527      ctx[55].handle_select_row
25528    ),
25529    is_dragging: (
25530      /*is_dragging*/
25531      ctx[42]
25532    ),
25533    wrap: (
25534      /*wrap*/
25535      ctx[10]
25536    )
25537  };
25538  if (
25539    /*search_results*/
25540    ctx[35][
25541      /*index*/
25542      ctx[145]
25543    ][
25544      /*j*/
25545      ctx[150]
25546    ].value !== void 0
25547  ) {
25548    tablecell_props.value = /*search_results*/
25549    ctx[35][
25550      /*index*/
25551      ctx[145]
25552    ][
25553      /*j*/
25554      ctx[150]
25555    ].value;
25556  }
25557  if (
25558    /*els*/
25559    ctx[24][
25560      /*id*/
25561      ctx[148]
25562    ] !== void 0
25563  ) {
25564    tablecell_props.el = /*els*/
25565    ctx[24][
25566      /*id*/
25567      ctx[148]
25568    ];
25569  }
25570  tablecell = new TableCell$1({ props: tablecell_props });
25571  binding_callbacks.push(() => bind(tablecell, "value", tablecell_value_binding));
25572  binding_callbacks.push(() => bind(tablecell, "el", tablecell_el_binding));
25573  return {
25574    key: key_1,
25575    first: null,
25576    c() {
25577      first = empty();
25578      create_component(tablecell.$$.fragment);
25579      this.first = first;
25580    },
25581    m(target, anchor) {
25582      insert(target, first, anchor);
25583      mount_component(tablecell, target, anchor);
25584      current = true;
25585    },
25586    p(new_ctx, dirty) {
25587      ctx = new_ctx;
25588      const tablecell_changes = {};
25589      if (dirty[4] & /*index, item*/
25590      6291456) tablecell_changes.display_value = /*get_cell_display_value*/
25591      ctx[73](
25592        /*index*/
25593        ctx[145],
25594        /*j*/
25595        ctx[150]
25596      );
25597      if (dirty[0] & /*filtered_to_original_map*/
25598      134217728 | dirty[1] & /*$df_state*/
25599      4 | dirty[4] & /*index*/
25600      2097152) tablecell_changes.index = /*$df_state*/
25601      ctx[33].current_search_query !== void 0 && /*filtered_to_original_map*/
25602      ctx[27][
25603        /*index*/
25604        ctx[145]
25605      ] !== void 0 ? (
25606        /*filtered_to_original_map*/
25607        ctx[27][
25608          /*index*/
25609          ctx[145]
25610        ]
25611      ) : (
25612        /*index*/
25613        ctx[145]
25614      );
25615      if (dirty[4] & /*item*/
25616      4194304) tablecell_changes.j = /*j*/
25617      ctx[150];
25618      if (dirty[1] & /*actual_pinned_columns*/
25619      4194304) tablecell_changes.actual_pinned_columns = /*actual_pinned_columns*/
25620      ctx[53];
25621      if (dirty[1] & /*handle_mouse_down*/
25622      16384) tablecell_changes.handle_cell_click = /*func_1*/
25623      ctx[97];
25624      if (dirty[1] & /*selected_cells*/
25625      1) tablecell_changes.selected_cells = /*selected_cells*/
25626      ctx[31];
25627      if (dirty[1] & /*copy_flash*/
25628      2) tablecell_changes.copy_flash = /*copy_flash*/
25629      ctx[32];
25630      if (dirty[1] & /*active_cell_menu*/
25631      65536) tablecell_changes.active_cell_menu = /*active_cell_menu*/
25632      ctx[47];
25633      if (dirty[1] & /*search_results*/
25634      16 | dirty[4] & /*index, item*/
25635      6291456) tablecell_changes.styling = /*search_results*/
25636      ctx[35][
25637        /*index*/
25638        ctx[145]
25639      ][
25640        /*j*/
25641        ctx[150]
25642      ].styling;
25643      if (dirty[0] & /*latex_delimiters*/
25644      128) tablecell_changes.latex_delimiters = /*latex_delimiters*/
25645      ctx[7];
25646      if (dirty[0] & /*line_breaks*/
25647      16384) tablecell_changes.line_breaks = /*line_breaks*/
25648      ctx[14];
25649      if (dirty[0] & /*datatype*/
25650      4 | dirty[4] & /*item*/
25651      4194304) tablecell_changes.datatype = Array.isArray(
25652        /*datatype*/
25653        ctx[2]
25654      ) ? (
25655        /*datatype*/
25656        ctx[2][
25657          /*j*/
25658          ctx[150]
25659        ]
25660      ) : (
25661        /*datatype*/
25662        ctx[2]
25663      );
25664      if (dirty[1] & /*editing*/
25665      131072) tablecell_changes.editing = /*editing*/
25666      ctx[48];
25667      if (dirty[0] & /*max_chars*/
25668      1048576) tablecell_changes.max_chars = /*max_chars*/
25669      ctx[20];
25670      if (dirty[0] & /*editable*/
25671      512) tablecell_changes.editable = /*editable*/
25672      ctx[9];
25673      if (dirty[0] & /*static_columns*/
25674      4194304 | dirty[4] & /*item*/
25675      4194304) tablecell_changes.is_static = /*static_columns*/
25676      ctx[22].includes(
25677        /*j*/
25678        ctx[150]
25679      );
25680      if (dirty[0] & /*i18n*/
25681      4096) tablecell_changes.i18n = /*i18n*/
25682      ctx[12];
25683      if (dirty[0] & /*components*/
25684      256) tablecell_changes.components = /*components*/
25685      ctx[8];
25686      if (dirty[1] & /*is_dragging*/
25687      2048) tablecell_changes.is_dragging = /*is_dragging*/
25688      ctx[42];
25689      if (dirty[0] & /*wrap*/
25690      1024) tablecell_changes.wrap = /*wrap*/
25691      ctx[10];
25692      if (!updating_value && dirty[1] & /*search_results*/
25693      16 | dirty[4] & /*index, item*/
25694      6291456) {
25695        updating_value = true;
25696        tablecell_changes.value = /*search_results*/
25697        ctx[35][
25698          /*index*/
25699          ctx[145]
25700        ][
25701          /*j*/
25702          ctx[150]
25703        ].value;
25704        add_flush_callback(() => updating_value = false);
25705      }
25706      if (!updating_el && dirty[0] & /*els*/
25707      16777216 | dirty[4] & /*item*/
25708      4194304) {
25709        updating_el = true;
25710        tablecell_changes.el = /*els*/
25711        ctx[24][
25712          /*id*/
25713          ctx[148]
25714        ];
25715        add_flush_callback(() => updating_el = false);
25716      }
25717      tablecell.$set(tablecell_changes);
25718    },
25719    i(local) {
25720      if (current) return;
25721      transition_in(tablecell.$$.fragment, local);
25722      current = true;
25723    },
25724    o(local) {
25725      transition_out(tablecell.$$.fragment, local);
25726      current = false;
25727    },
25728    d(detaching) {
25729      if (detaching) {
25730        detach(first);
25731      }
25732      destroy_component(tablecell, detaching);
25733    }
25734  };
25735}
25736function create_tbody_slot(ctx) {
25737  let tr;
25738  let t;
25739  let each_blocks = [];
25740  let each_1_lookup = new Map_1();
25741  let current;
25742  let if_block = (
25743    /*show_row_numbers*/
25744    ctx[15] && create_if_block_3$3(ctx)
25745  );
25746  let each_value = ensure_array_like(
25747    /*item*/
25748    ctx[146]
25749  );
25750  const get_key = (ctx2) => (
25751    /*id*/
25752    ctx2[148]
25753  );
25754  for (let i = 0; i < each_value.length; i += 1) {
25755    let child_ctx = get_each_context$1(ctx, each_value, i);
25756    let key = get_key(child_ctx);
25757    each_1_lookup.set(key, each_blocks[i] = create_each_block$1(key, child_ctx));
25758  }
25759  return {
25760    c() {
25761      tr = element("tr");
25762      if (if_block) if_block.c();
25763      t = space();
25764      for (let i = 0; i < each_blocks.length; i += 1) {
25765        each_blocks[i].c();
25766      }
25767      attr(tr, "slot", "tbody");
25768      attr(tr, "class", "svelte-4x7jh");
25769      toggle_class(
25770        tr,
25771        "row-odd",
25772        /*index*/
25773        ctx[145] % 2 === 0
25774      );
25775    },
25776    m(target, anchor) {
25777      insert(target, tr, anchor);
25778      if (if_block) if_block.m(tr, null);
25779      append(tr, t);
25780      for (let i = 0; i < each_blocks.length; i += 1) {
25781        if (each_blocks[i]) {
25782          each_blocks[i].m(tr, null);
25783        }
25784      }
25785      current = true;
25786    },
25787    p(ctx2, dirty) {
25788      if (
25789        /*show_row_numbers*/
25790        ctx2[15]
25791      ) {
25792        if (if_block) {
25793          if_block.p(ctx2, dirty);
25794          if (dirty[0] & /*show_row_numbers*/
25795          32768) {
25796            transition_in(if_block, 1);
25797          }
25798        } else {
25799          if_block = create_if_block_3$3(ctx2);
25800          if_block.c();
25801          transition_in(if_block, 1);
25802          if_block.m(tr, t);
25803        }
25804      } else if (if_block) {
25805        group_outros();
25806        transition_out(if_block, 1, 1, () => {
25807          if_block = null;
25808        });
25809        check_outros();
25810      }
25811      if (dirty[0] & /*filtered_to_original_map, latex_delimiters, line_breaks, datatype, max_chars, editable, static_columns, i18n, components, wrap, els*/
25812      156260228 | dirty[1] & /*$df_state, actual_pinned_columns, handle_mouse_down, df_actions, selected_cells, copy_flash, active_cell_menu, search_results, editing, is_dragging*/
25813      21186583 | dirty[2] & /*get_cell_display_value, handle_blur*/
25814      2052 | dirty[4] & /*index, item*/
25815      6291456) {
25816        each_value = ensure_array_like(
25817          /*item*/
25818          ctx2[146]
25819        );
25820        group_outros();
25821        each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx2, each_value, each_1_lookup, tr, outro_and_destroy_block, create_each_block$1, null, get_each_context$1);
25822        check_outros();
25823      }
25824      if (!current || dirty[4] & /*index*/
25825      2097152) {
25826        toggle_class(
25827          tr,
25828          "row-odd",
25829          /*index*/
25830          ctx2[145] % 2 === 0
25831        );
25832      }
25833    },
25834    i(local) {
25835      if (current) return;
25836      transition_in(if_block);
25837      for (let i = 0; i < each_value.length; i += 1) {
25838        transition_in(each_blocks[i]);
25839      }
25840      current = true;
25841    },
25842    o(local) {
25843      transition_out(if_block);
25844      for (let i = 0; i < each_blocks.length; i += 1) {
25845        transition_out(each_blocks[i]);
25846      }
25847      current = false;
25848    },
25849    d(detaching) {
25850      if (detaching) {
25851        detach(tr);
25852      }
25853      if (if_block) if_block.d();
25854      for (let i = 0; i < each_blocks.length; i += 1) {
25855        each_blocks[i].d();
25856      }
25857    }
25858  };
25859}
25860function create_default_slot$4(ctx) {
25861  let div;
25862  let virtualtable;
25863  let updating_items;
25864  let updating_actual_height;
25865  let updating_table_scrollbar_width;
25866  let updating_viewport;
25867  let updating_show_scroll_button;
25868  let current;
25869  function virtualtable_items_binding(value) {
25870    ctx[102](value);
25871  }
25872  function virtualtable_actual_height_binding(value) {
25873    ctx[103](value);
25874  }
25875  function virtualtable_table_scrollbar_width_binding(value) {
25876    ctx[104](value);
25877  }
25878  function virtualtable_viewport_binding(value) {
25879    ctx[105](value);
25880  }
25881  function virtualtable_show_scroll_button_binding(value) {
25882    ctx[106](value);
25883  }
25884  let virtualtable_props = {
25885    max_height: (
25886      /*max_height*/
25887      ctx[13]
25888    ),
25889    selected: (
25890      /*selected_index*/
25891      ctx[49]
25892    ),
25893    disable_scroll: (
25894      /*active_cell_menu*/
25895      ctx[47] !== null || /*active_header_menu*/
25896      ctx[46] !== null
25897    ),
25898    label: (
25899      /*label*/
25900      ctx[3]
25901    ),
25902    $$slots: {
25903      tbody: [
25904        create_tbody_slot,
25905        ({ index, item }) => ({ 145: index, 146: item }),
25906        ({ index, item }) => [0, 0, 0, 0, (index ? 2097152 : 0) | (item ? 4194304 : 0)]
25907      ],
25908      thead: [create_thead_slot]
25909    },
25910    $$scope: { ctx }
25911  };
25912  if (
25913    /*search_results*/
25914    ctx[35] !== void 0
25915  ) {
25916    virtualtable_props.items = /*search_results*/
25917    ctx[35];
25918  }
25919  if (
25920    /*table_height*/
25921    ctx[37] !== void 0
25922  ) {
25923    virtualtable_props.actual_height = /*table_height*/
25924    ctx[37];
25925  }
25926  if (
25927    /*scrollbar_width*/
25928    ctx[38] !== void 0
25929  ) {
25930    virtualtable_props.table_scrollbar_width = /*scrollbar_width*/
25931    ctx[38];
25932  }
25933  if (
25934    /*viewport*/
25935    ctx[40] !== void 0
25936  ) {
25937    virtualtable_props.viewport = /*viewport*/
25938    ctx[40];
25939  }
25940  if (
25941    /*show_scroll_button*/
25942    ctx[41] !== void 0
25943  ) {
25944    virtualtable_props.show_scroll_button = /*show_scroll_button*/
25945    ctx[41];
25946  }
25947  virtualtable = new VirtualTable$1({ props: virtualtable_props });
25948  binding_callbacks.push(() => bind(virtualtable, "items", virtualtable_items_binding));
25949  binding_callbacks.push(() => bind(virtualtable, "actual_height", virtualtable_actual_height_binding));
25950  binding_callbacks.push(() => bind(virtualtable, "table_scrollbar_width", virtualtable_table_scrollbar_width_binding));
25951  binding_callbacks.push(() => bind(virtualtable, "viewport", virtualtable_viewport_binding));
25952  binding_callbacks.push(() => bind(virtualtable, "show_scroll_button", virtualtable_show_scroll_button_binding));
25953  virtualtable.$on("scroll_top", scroll_top_handler);
25954  return {
25955    c() {
25956      div = element("div");
25957      create_component(virtualtable.$$.fragment);
25958      attr(div, "class", "table-wrap svelte-4x7jh");
25959    },
25960    m(target, anchor) {
25961      insert(target, div, anchor);
25962      mount_component(virtualtable, div, null);
25963      current = true;
25964    },
25965    p(ctx2, dirty) {
25966      const virtualtable_changes = {};
25967      if (dirty[0] & /*max_height*/
25968      8192) virtualtable_changes.max_height = /*max_height*/
25969      ctx2[13];
25970      if (dirty[1] & /*selected_index*/
25971      262144) virtualtable_changes.selected = /*selected_index*/
25972      ctx2[49];
25973      if (dirty[1] & /*active_cell_menu, active_header_menu*/
25974      98304) virtualtable_changes.disable_scroll = /*active_cell_menu*/
25975      ctx2[47] !== null || /*active_header_menu*/
25976      ctx2[46] !== null;
25977      if (dirty[0] & /*label*/
25978      8) virtualtable_changes.label = /*label*/
25979      ctx2[3];
25980      if (dirty[0] & /*filtered_to_original_map, latex_delimiters, line_breaks, datatype, max_chars, editable, static_columns, i18n, components, wrap, els, show_row_numbers, _headers, headers, col_count, data*/
25981      256956325 | dirty[1] & /*$df_state, actual_pinned_columns, handle_mouse_down, selected_cells, copy_flash, active_cell_menu, search_results, editing, is_dragging, header_edit, selected_header*/
25982      7555095 | dirty[4] & /*index, item*/
25983      6291456 | dirty[5] & /*$$scope*/
25984      1) {
25985        virtualtable_changes.$$scope = { dirty, ctx: ctx2 };
25986      }
25987      if (!updating_items && dirty[1] & /*search_results*/
25988      16) {
25989        updating_items = true;
25990        virtualtable_changes.items = /*search_results*/
25991        ctx2[35];
25992        add_flush_callback(() => updating_items = false);
25993      }
25994      if (!updating_actual_height && dirty[1] & /*table_height*/
25995      64) {
25996        updating_actual_height = true;
25997        virtualtable_changes.actual_height = /*table_height*/
25998        ctx2[37];
25999        add_flush_callback(() => updating_actual_height = false);
26000      }
26001      if (!updating_table_scrollbar_width && dirty[1] & /*scrollbar_width*/
26002      128) {
26003        updating_table_scrollbar_width = true;
26004        virtualtable_changes.table_scrollbar_width = /*scrollbar_width*/
26005        ctx2[38];
26006        add_flush_callback(() => updating_table_scrollbar_width = false);
26007      }
26008      if (!updating_viewport && dirty[1] & /*viewport*/
26009      512) {
26010        updating_viewport = true;
26011        virtualtable_changes.viewport = /*viewport*/
26012        ctx2[40];
26013        add_flush_callback(() => updating_viewport = false);
26014      }
26015      if (!updating_show_scroll_button && dirty[1] & /*show_scroll_button*/
26016      1024) {
26017        updating_show_scroll_button = true;
26018        virtualtable_changes.show_scroll_button = /*show_scroll_button*/
26019        ctx2[41];
26020        add_flush_callback(() => updating_show_scroll_button = false);
26021      }
26022      virtualtable.$set(virtualtable_changes);
26023    },
26024    i(local) {
26025      if (current) return;
26026      transition_in(virtualtable.$$.fragment, local);
26027      current = true;
26028    },
26029    o(local) {
26030      transition_out(virtualtable.$$.fragment, local);
26031      current = false;
26032    },
26033    d(detaching) {
26034      if (detaching) {
26035        detach(div);
26036      }
26037      destroy_component(virtualtable);
26038    }
26039  };
26040}
26041function create_if_block_2$4(ctx) {
26042  let button;
26043  let mounted;
26044  let dispose;
26045  return {
26046    c() {
26047      button = element("button");
26048      button.textContent = "↑";
26049      attr(button, "class", "scroll-top-button svelte-4x7jh");
26050    },
26051    m(target, anchor) {
26052      insert(target, button, anchor);
26053      if (!mounted) {
26054        dispose = listen(
26055          button,
26056          "click",
26057          /*scroll_to_top*/
26058          ctx[69]
26059        );
26060        mounted = true;
26061      }
26062    },
26063    p: noop,
26064    d(detaching) {
26065      if (detaching) {
26066        detach(button);
26067      }
26068      mounted = false;
26069      dispose();
26070    }
26071  };
26072}
26073function create_if_block_1$4(ctx) {
26074  let emptyrowbutton;
26075  let current;
26076  emptyrowbutton = new EmptyRowButton$1({ props: { on_click: (
26077    /*func_2*/
26078    ctx[111]
26079  ) } });
26080  return {
26081    c() {
26082      create_component(emptyrowbutton.$$.fragment);
26083    },
26084    m(target, anchor) {
26085      mount_component(emptyrowbutton, target, anchor);
26086      current = true;
26087    },
26088    p: noop,
26089    i(local) {
26090      if (current) return;
26091      transition_in(emptyrowbutton.$$.fragment, local);
26092      current = true;
26093    },
26094    o(local) {
26095      transition_out(emptyrowbutton.$$.fragment, local);
26096      current = false;
26097    },
26098    d(detaching) {
26099      destroy_component(emptyrowbutton, detaching);
26100    }
26101  };
26102}
26103function create_if_block$4(ctx) {
26104  var _a, _b, _c, _d, _e, _f, _g;
26105  let cellmenu;
26106  let current;
26107  cellmenu = new CellMenu$1({
26108    props: {
26109      x: (
26110        /*active_cell_menu*/
26111        ((_a = ctx[47]) == null ? void 0 : _a.x) ?? /*active_header_menu*/
26112        ((_b = ctx[46]) == null ? void 0 : _b.x) ?? 0
26113      ),
26114      y: (
26115        /*active_cell_menu*/
26116        ((_c = ctx[47]) == null ? void 0 : _c.y) ?? /*active_header_menu*/
26117        ((_d = ctx[46]) == null ? void 0 : _d.y) ?? 0
26118      ),
26119      row: (
26120        /*active_header_menu*/
26121        ctx[46] ? -1 : (
26122          /*active_cell_menu*/
26123          ((_e = ctx[47]) == null ? void 0 : _e.row) ?? 0
26124        )
26125      ),
26126      col_count: (
26127        /*col_count*/
26128        ctx[5]
26129      ),
26130      row_count: (
26131        /*row_count*/
26132        ctx[6]
26133      ),
26134      on_add_row_above: (
26135        /*func_3*/
26136        ctx[112]
26137      ),
26138      on_add_row_below: (
26139        /*func_4*/
26140        ctx[113]
26141      ),
26142      on_add_column_left: (
26143        /*func_5*/
26144        ctx[114]
26145      ),
26146      on_add_column_right: (
26147        /*func_6*/
26148        ctx[115]
26149      ),
26150      on_delete_row: (
26151        /*func_7*/
26152        ctx[116]
26153      ),
26154      on_delete_col: (
26155        /*func_8*/
26156        ctx[117]
26157      ),
26158      editable: (
26159        /*editable*/
26160        ctx[9]
26161      ),
26162      can_delete_rows: !/*active_header_menu*/
26163      ctx[46] && /*data*/
26164      ctx[26].length > 1 && /*editable*/
26165      ctx[9],
26166      can_delete_cols: (
26167        /*data*/
26168        ctx[26].length > 0 && /*data*/
26169        ((_f = ctx[26][0]) == null ? void 0 : _f.length) > 1 && /*editable*/
26170        ctx[9]
26171      ),
26172      i18n: (
26173        /*i18n*/
26174        ctx[12]
26175      ),
26176      on_sort: (
26177        /*active_header_menu*/
26178        ctx[46] ? (
26179          /*func_9*/
26180          ctx[118]
26181        ) : void 0
26182      ),
26183      on_clear_sort: (
26184        /*active_header_menu*/
26185        ctx[46] ? (
26186          /*func_10*/
26187          ctx[119]
26188        ) : void 0
26189      ),
26190      sort_direction: (
26191        /*active_header_menu*/
26192        ctx[46] ? (
26193          /*$df_state*/
26194          ((_g = ctx[33].sort_state.sort_columns.find(
26195            /*func_11*/
26196            ctx[120]
26197          )) == null ? void 0 : _g.direction) ?? null
26198        ) : null
26199      ),
26200      sort_priority: (
26201        /*active_header_menu*/
26202        ctx[46] ? (
26203          /*$df_state*/
26204          ctx[33].sort_state.sort_columns.findIndex(
26205            /*func_12*/
26206            ctx[121]
26207          ) + 1 || null
26208        ) : null
26209      ),
26210      on_filter: (
26211        /*active_header_menu*/
26212        ctx[46] ? (
26213          /*func_13*/
26214          ctx[122]
26215        ) : void 0
26216      ),
26217      on_clear_filter: (
26218        /*active_header_menu*/
26219        ctx[46] ? (
26220          /*func_14*/
26221          ctx[123]
26222        ) : void 0
26223      ),
26224      filter_active: (
26225        /*active_header_menu*/
26226        ctx[46] ? (
26227          /*$df_state*/
26228          ctx[33].filter_state.filter_columns.some(
26229            /*func_15*/
26230            ctx[124]
26231          )
26232        ) : null
26233      )
26234    }
26235  });
26236  return {
26237    c() {
26238      create_component(cellmenu.$$.fragment);
26239    },
26240    m(target, anchor) {
26241      mount_component(cellmenu, target, anchor);
26242      current = true;
26243    },
26244    p(ctx2, dirty) {
26245      var _a2, _b2, _c2, _d2, _e2, _f2, _g2;
26246      const cellmenu_changes = {};
26247      if (dirty[1] & /*active_cell_menu, active_header_menu*/
26248      98304) cellmenu_changes.x = /*active_cell_menu*/
26249      ((_a2 = ctx2[47]) == null ? void 0 : _a2.x) ?? /*active_header_menu*/
26250      ((_b2 = ctx2[46]) == null ? void 0 : _b2.x) ?? 0;
26251      if (dirty[1] & /*active_cell_menu, active_header_menu*/
26252      98304) cellmenu_changes.y = /*active_cell_menu*/
26253      ((_c2 = ctx2[47]) == null ? void 0 : _c2.y) ?? /*active_header_menu*/
26254      ((_d2 = ctx2[46]) == null ? void 0 : _d2.y) ?? 0;
26255      if (dirty[1] & /*active_header_menu, active_cell_menu*/
26256      98304) cellmenu_changes.row = /*active_header_menu*/
26257      ctx2[46] ? -1 : (
26258        /*active_cell_menu*/
26259        ((_e2 = ctx2[47]) == null ? void 0 : _e2.row) ?? 0
26260      );
26261      if (dirty[0] & /*col_count*/
26262      32) cellmenu_changes.col_count = /*col_count*/
26263      ctx2[5];
26264      if (dirty[0] & /*row_count*/
26265      64) cellmenu_changes.row_count = /*row_count*/
26266      ctx2[6];
26267      if (dirty[1] & /*active_cell_menu*/
26268      65536) cellmenu_changes.on_add_row_above = /*func_3*/
26269      ctx2[112];
26270      if (dirty[1] & /*active_cell_menu*/
26271      65536) cellmenu_changes.on_add_row_below = /*func_4*/
26272      ctx2[113];
26273      if (dirty[1] & /*active_cell_menu, active_header_menu*/
26274      98304) cellmenu_changes.on_add_column_left = /*func_5*/
26275      ctx2[114];
26276      if (dirty[1] & /*active_cell_menu, active_header_menu*/
26277      98304) cellmenu_changes.on_add_column_right = /*func_6*/
26278      ctx2[115];
26279      if (dirty[1] & /*active_cell_menu*/
26280      65536) cellmenu_changes.on_delete_row = /*func_7*/
26281      ctx2[116];
26282      if (dirty[1] & /*active_cell_menu, active_header_menu*/
26283      98304) cellmenu_changes.on_delete_col = /*func_8*/
26284      ctx2[117];
26285      if (dirty[0] & /*editable*/
26286      512) cellmenu_changes.editable = /*editable*/
26287      ctx2[9];
26288      if (dirty[0] & /*data, editable*/
26289      67109376 | dirty[1] & /*active_header_menu*/
26290      32768) cellmenu_changes.can_delete_rows = !/*active_header_menu*/
26291      ctx2[46] && /*data*/
26292      ctx2[26].length > 1 && /*editable*/
26293      ctx2[9];
26294      if (dirty[0] & /*data, editable*/
26295      67109376) cellmenu_changes.can_delete_cols = /*data*/
26296      ctx2[26].length > 0 && /*data*/
26297      ((_f2 = ctx2[26][0]) == null ? void 0 : _f2.length) > 1 && /*editable*/
26298      ctx2[9];
26299      if (dirty[0] & /*i18n*/
26300      4096) cellmenu_changes.i18n = /*i18n*/
26301      ctx2[12];
26302      if (dirty[1] & /*active_header_menu*/
26303      32768) cellmenu_changes.on_sort = /*active_header_menu*/
26304      ctx2[46] ? (
26305        /*func_9*/
26306        ctx2[118]
26307      ) : void 0;
26308      if (dirty[1] & /*active_header_menu*/
26309      32768) cellmenu_changes.on_clear_sort = /*active_header_menu*/
26310      ctx2[46] ? (
26311        /*func_10*/
26312        ctx2[119]
26313      ) : void 0;
26314      if (dirty[1] & /*active_header_menu, $df_state*/
26315      32772) cellmenu_changes.sort_direction = /*active_header_menu*/
26316      ctx2[46] ? (
26317        /*$df_state*/
26318        ((_g2 = ctx2[33].sort_state.sort_columns.find(
26319          /*func_11*/
26320          ctx2[120]
26321        )) == null ? void 0 : _g2.direction) ?? null
26322      ) : null;
26323      if (dirty[1] & /*active_header_menu, $df_state*/
26324      32772) cellmenu_changes.sort_priority = /*active_header_menu*/
26325      ctx2[46] ? (
26326        /*$df_state*/
26327        ctx2[33].sort_state.sort_columns.findIndex(
26328          /*func_12*/
26329          ctx2[121]
26330        ) + 1 || null
26331      ) : null;
26332      if (dirty[1] & /*active_header_menu*/
26333      32768) cellmenu_changes.on_filter = /*active_header_menu*/
26334      ctx2[46] ? (
26335        /*func_13*/
26336        ctx2[122]
26337      ) : void 0;
26338      if (dirty[1] & /*active_header_menu*/
26339      32768) cellmenu_changes.on_clear_filter = /*active_header_menu*/
26340      ctx2[46] ? (
26341        /*func_14*/
26342        ctx2[123]
26343      ) : void 0;
26344      if (dirty[1] & /*active_header_menu, $df_state*/
26345      32772) cellmenu_changes.filter_active = /*active_header_menu*/
26346      ctx2[46] ? (
26347        /*$df_state*/
26348        ctx2[33].filter_state.filter_columns.some(
26349          /*func_15*/
26350          ctx2[124]
26351        )
26352      ) : null;
26353      cellmenu.$set(cellmenu_changes);
26354    },
26355    i(local) {
26356      if (current) return;
26357      transition_in(cellmenu.$$.fragment, local);
26358      current = true;
26359    },
26360    o(local) {
26361      transition_out(cellmenu.$$.fragment, local);
26362      current = false;
26363    },
26364    d(detaching) {
26365      destroy_component(cellmenu, detaching);
26366    }
26367  };
26368}
26369function create_fragment$8(ctx) {
26370  let div1;
26371  let t0;
26372  let div0;
26373  let table_1;
26374  let t1;
26375  let thead;
26376  let tr0;
26377  let t2;
26378  let each_blocks_1 = [];
26379  let each0_lookup = new Map_1();
26380  let t3;
26381  let tbody;
26382  let tr1;
26383  let t4;
26384  let each_blocks = [];
26385  let each1_lookup = new Map_1();
26386  let t5;
26387  let upload_1;
26388  let updating_dragging;
26389  let t6;
26390  let t7;
26391  let t8;
26392  let if_block6_anchor;
26393  let current;
26394  let mounted;
26395  let dispose;
26396  let if_block0 = (
26397    /*label*/
26398    (ctx[3] && /*label*/
26399    ctx[3].length !== 0 && /*show_label*/
26400    ctx[4] || /*show_fullscreen_button*/
26401    ctx[18] || /*show_copy_button*/
26402    ctx[19] || /*show_search*/
26403    ctx[21] !== "none") && create_if_block_8(ctx)
26404  );
26405  let if_block1 = (
26406    /*label*/
26407    ctx[3] && /*label*/
26408    ctx[3].length !== 0 && create_if_block_7(ctx)
26409  );
26410  let if_block2 = (
26411    /*show_row_numbers*/
26412    ctx[15] && create_if_block_6$2()
26413  );
26414  let each_value_3 = ensure_array_like(
26415    /*_headers*/
26416    ctx[25]
26417  );
26418  const get_key = (ctx2) => (
26419    /*id*/
26420    ctx2[148]
26421  );
26422  for (let i = 0; i < each_value_3.length; i += 1) {
26423    let child_ctx = get_each_context_3(ctx, each_value_3, i);
26424    let key = get_key(child_ctx);
26425    each0_lookup.set(key, each_blocks_1[i] = create_each_block_3(key, child_ctx));
26426  }
26427  let if_block3 = (
26428    /*show_row_numbers*/
26429    ctx[15] && create_if_block_5$2()
26430  );
26431  let each_value_2 = ensure_array_like(
26432    /*max*/
26433    ctx[50]
26434  );
26435  const get_key_1 = (ctx2) => (
26436    /*id*/
26437    ctx2[148]
26438  );
26439  for (let i = 0; i < each_value_2.length; i += 1) {
26440    let child_ctx = get_each_context_2(ctx, each_value_2, i);
26441    let key = get_key_1(child_ctx);
26442    each1_lookup.set(key, each_blocks[i] = create_each_block_2(key, child_ctx));
26443  }
26444  function upload_1_dragging_binding(value) {
26445    ctx[107](value);
26446  }
26447  let upload_1_props = {
26448    upload: (
26449      /*upload*/
26450      ctx[16]
26451    ),
26452    stream_handler: (
26453      /*stream_handler*/
26454      ctx[17]
26455    ),
26456    flex: false,
26457    center: false,
26458    boundedheight: false,
26459    disable_click: true,
26460    root: (
26461      /*root*/
26462      ctx[11]
26463    ),
26464    aria_label: (
26465      /*i18n*/
26466      ctx[12]("dataframe.drop_to_upload")
26467    ),
26468    $$slots: { default: [create_default_slot$4] },
26469    $$scope: { ctx }
26470  };
26471  if (
26472    /*dragging*/
26473    ctx[36] !== void 0
26474  ) {
26475    upload_1_props.dragging = /*dragging*/
26476    ctx[36];
26477  }
26478  upload_1 = new Upload2({ props: upload_1_props });
26479  binding_callbacks.push(() => bind(upload_1, "dragging", upload_1_dragging_binding));
26480  upload_1.$on(
26481    "load",
26482    /*load_handler*/
26483    ctx[108]
26484  );
26485  let if_block4 = (
26486    /*show_scroll_button*/
26487    ctx[41] && create_if_block_2$4(ctx)
26488  );
26489  let if_block5 = (
26490    /*data*/
26491    ctx[26].length === 0 && /*editable*/
26492    ctx[9] && /*row_count*/
26493    ctx[6][1] === "dynamic" && create_if_block_1$4(ctx)
26494  );
26495  let if_block6 = (
26496    /*active_cell_menu*/
26497    (ctx[47] || /*active_header_menu*/
26498    ctx[46]) && create_if_block$4(ctx)
26499  );
26500  return {
26501    c() {
26502      div1 = element("div");
26503      if (if_block0) if_block0.c();
26504      t0 = space();
26505      div0 = element("div");
26506      table_1 = element("table");
26507      if (if_block1) if_block1.c();
26508      t1 = space();
26509      thead = element("thead");
26510      tr0 = element("tr");
26511      if (if_block2) if_block2.c();
26512      t2 = space();
26513      for (let i = 0; i < each_blocks_1.length; i += 1) {
26514        each_blocks_1[i].c();
26515      }
26516      t3 = space();
26517      tbody = element("tbody");
26518      tr1 = element("tr");
26519      if (if_block3) if_block3.c();
26520      t4 = space();
26521      for (let i = 0; i < each_blocks.length; i += 1) {
26522        each_blocks[i].c();
26523      }
26524      t5 = space();
26525      create_component(upload_1.$$.fragment);
26526      t6 = space();
26527      if (if_block4) if_block4.c();
26528      t7 = space();
26529      if (if_block5) if_block5.c();
26530      t8 = space();
26531      if (if_block6) if_block6.c();
26532      if_block6_anchor = empty();
26533      attr(tr0, "class", "svelte-4x7jh");
26534      attr(thead, "class", "svelte-4x7jh");
26535      attr(tr1, "class", "svelte-4x7jh");
26536      attr(tbody, "class", "svelte-4x7jh");
26537      attr(table_1, "aria-hidden", "true");
26538      attr(table_1, "class", "svelte-4x7jh");
26539      attr(div0, "class", "table-wrap svelte-4x7jh");
26540      attr(div0, "role", "grid");
26541      attr(div0, "tabindex", "0");
26542      toggle_class(
26543        div0,
26544        "dragging",
26545        /*is_dragging*/
26546        ctx[42]
26547      );
26548      toggle_class(div0, "no-wrap", !/*wrap*/
26549      ctx[10]);
26550      toggle_class(
26551        div0,
26552        "menu-open",
26553        /*active_cell_menu*/
26554        ctx[47] || /*active_header_menu*/
26555        ctx[46]
26556      );
26557      attr(div1, "class", "table-container svelte-4x7jh");
26558    },
26559    m(target, anchor) {
26560      insert(target, div1, anchor);
26561      if (if_block0) if_block0.m(div1, null);
26562      append(div1, t0);
26563      append(div1, div0);
26564      append(div0, table_1);
26565      if (if_block1) if_block1.m(table_1, null);
26566      append(table_1, t1);
26567      append(table_1, thead);
26568      append(thead, tr0);
26569      if (if_block2) if_block2.m(tr0, null);
26570      append(tr0, t2);
26571      for (let i = 0; i < each_blocks_1.length; i += 1) {
26572        if (each_blocks_1[i]) {
26573          each_blocks_1[i].m(tr0, null);
26574        }
26575      }
26576      append(table_1, t3);
26577      append(table_1, tbody);
26578      append(tbody, tr1);
26579      if (if_block3) if_block3.m(tr1, null);
26580      append(tr1, t4);
26581      for (let i = 0; i < each_blocks.length; i += 1) {
26582        if (each_blocks[i]) {
26583          each_blocks[i].m(tr1, null);
26584        }
26585      }
26586      ctx[96](table_1);
26587      append(div0, t5);
26588      mount_component(upload_1, div0, null);
26589      append(div0, t6);
26590      if (if_block4) if_block4.m(div0, null);
26591      ctx[109](div0);
26592      insert(target, t7, anchor);
26593      if (if_block5) if_block5.m(target, anchor);
26594      insert(target, t8, anchor);
26595      if (if_block6) if_block6.m(target, anchor);
26596      insert(target, if_block6_anchor, anchor);
26597      current = true;
26598      if (!mounted) {
26599        dispose = [
26600          listen(
26601            window_1,
26602            "resize",
26603            /*resize_handler*/
26604            ctx[89]
26605          ),
26606          listen(
26607            div0,
26608            "keydown",
26609            /*keydown_handler*/
26610            ctx[110]
26611          ),
26612          listen(div0, "mousemove", function() {
26613            if (is_function(
26614              /*handle_mouse_move*/
26615              ctx[44]
26616            )) ctx[44].apply(this, arguments);
26617          }),
26618          listen(div0, "mouseup", function() {
26619            if (is_function(
26620              /*handle_mouse_up*/
26621              ctx[43]
26622            )) ctx[43].apply(this, arguments);
26623          }),
26624          listen(div0, "mouseleave", function() {
26625            if (is_function(
26626              /*handle_mouse_up*/
26627              ctx[43]
26628            )) ctx[43].apply(this, arguments);
26629          })
26630        ];
26631        mounted = true;
26632      }
26633    },
26634    p(new_ctx, dirty) {
26635      ctx = new_ctx;
26636      if (
26637        /*label*/
26638        ctx[3] && /*label*/
26639        ctx[3].length !== 0 && /*show_label*/
26640        ctx[4] || /*show_fullscreen_button*/
26641        ctx[18] || /*show_copy_button*/
26642        ctx[19] || /*show_search*/
26643        ctx[21] !== "none"
26644      ) {
26645        if (if_block0) {
26646          if_block0.p(ctx, dirty);
26647          if (dirty[0] & /*label, show_label, show_fullscreen_button, show_copy_button, show_search*/
26648          2883608) {
26649            transition_in(if_block0, 1);
26650          }
26651        } else {
26652          if_block0 = create_if_block_8(ctx);
26653          if_block0.c();
26654          transition_in(if_block0, 1);
26655          if_block0.m(div1, t0);
26656        }
26657      } else if (if_block0) {
26658        group_outros();
26659        transition_out(if_block0, 1, 1, () => {
26660          if_block0 = null;
26661        });
26662        check_outros();
26663      }
26664      if (
26665        /*label*/
26666        ctx[3] && /*label*/
26667        ctx[3].length !== 0
26668      ) {
26669        if (if_block1) {
26670          if_block1.p(ctx, dirty);
26671        } else {
26672          if_block1 = create_if_block_7(ctx);
26673          if_block1.c();
26674          if_block1.m(table_1, t1);
26675        }
26676      } else if (if_block1) {
26677        if_block1.d(1);
26678        if_block1 = null;
26679      }
26680      if (
26681        /*show_row_numbers*/
26682        ctx[15]
26683      ) {
26684        if (if_block2) {
26685          if (dirty[0] & /*show_row_numbers*/
26686          32768) {
26687            transition_in(if_block2, 1);
26688          }
26689        } else {
26690          if_block2 = create_if_block_6$2();
26691          if_block2.c();
26692          transition_in(if_block2, 1);
26693          if_block2.m(tr0, t2);
26694        }
26695      } else if (if_block2) {
26696        group_outros();
26697        transition_out(if_block2, 1, 1, () => {
26698          if_block2 = null;
26699        });
26700        check_outros();
26701      }
26702      if (dirty[0] & /*_headers, headers, latex_delimiters, line_breaks, max_chars, editable, static_columns, i18n, col_count, datatype, data, els*/
26703      122704549 | dirty[1] & /*actual_pinned_columns, header_edit, selected_header, handle_header_click, end_header_edit, $df_state*/
26704      1617952772 | dirty[2] & /*toggle_header_menu, handle_select_all*/
26705      1032) {
26706        each_value_3 = ensure_array_like(
26707          /*_headers*/
26708          ctx[25]
26709        );
26710        group_outros();
26711        each_blocks_1 = update_keyed_each(each_blocks_1, dirty, get_key, 1, ctx, each_value_3, each0_lookup, tr0, outro_and_destroy_block, create_each_block_3, null, get_each_context_3);
26712        check_outros();
26713      }
26714      if (
26715        /*show_row_numbers*/
26716        ctx[15]
26717      ) {
26718        if (if_block3) {
26719          if (dirty[0] & /*show_row_numbers*/
26720          32768) {
26721            transition_in(if_block3, 1);
26722          }
26723        } else {
26724          if_block3 = create_if_block_5$2();
26725          if_block3.c();
26726          transition_in(if_block3, 1);
26727          if_block3.m(tr1, t4);
26728        }
26729      } else if (if_block3) {
26730        group_outros();
26731        transition_out(if_block3, 1, 1, () => {
26732          if_block3 = null;
26733        });
26734        check_outros();
26735      }
26736      if (dirty[0] & /*cells, latex_delimiters, line_breaks, datatype, editable, i18n*/
26737      268456580 | dirty[1] & /*max, selected_cells, selected_cell_coords, df_actions, is_dragging*/
26738      17303809 | dirty[2] & /*handle_blur*/
26739      4) {
26740        each_value_2 = ensure_array_like(
26741          /*max*/
26742          ctx[50]
26743        );
26744        group_outros();
26745        each_blocks = update_keyed_each(each_blocks, dirty, get_key_1, 1, ctx, each_value_2, each1_lookup, tr1, outro_and_destroy_block, create_each_block_2, null, get_each_context_2);
26746        check_outros();
26747      }
26748      const upload_1_changes = {};
26749      if (dirty[0] & /*upload*/
26750      65536) upload_1_changes.upload = /*upload*/
26751      ctx[16];
26752      if (dirty[0] & /*stream_handler*/
26753      131072) upload_1_changes.stream_handler = /*stream_handler*/
26754      ctx[17];
26755      if (dirty[0] & /*root*/
26756      2048) upload_1_changes.root = /*root*/
26757      ctx[11];
26758      if (dirty[0] & /*i18n*/
26759      4096) upload_1_changes.aria_label = /*i18n*/
26760      ctx[12]("dataframe.drop_to_upload");
26761      if (dirty[0] & /*max_height, label, filtered_to_original_map, latex_delimiters, line_breaks, datatype, max_chars, editable, static_columns, i18n, components, wrap, els, show_row_numbers, _headers, headers, col_count, data*/
26762      256964525 | dirty[1] & /*selected_index, active_cell_menu, active_header_menu, search_results, table_height, scrollbar_width, viewport, show_scroll_button, $df_state, actual_pinned_columns, handle_mouse_down, selected_cells, copy_flash, editing, is_dragging, header_edit, selected_header*/
26763      7851735 | dirty[5] & /*$$scope*/
26764      1) {
26765        upload_1_changes.$$scope = { dirty, ctx };
26766      }
26767      if (!updating_dragging && dirty[1] & /*dragging*/
26768      32) {
26769        updating_dragging = true;
26770        upload_1_changes.dragging = /*dragging*/
26771        ctx[36];
26772        add_flush_callback(() => updating_dragging = false);
26773      }
26774      upload_1.$set(upload_1_changes);
26775      if (
26776        /*show_scroll_button*/
26777        ctx[41]
26778      ) {
26779        if (if_block4) {
26780          if_block4.p(ctx, dirty);
26781        } else {
26782          if_block4 = create_if_block_2$4(ctx);
26783          if_block4.c();
26784          if_block4.m(div0, null);
26785        }
26786      } else if (if_block4) {
26787        if_block4.d(1);
26788        if_block4 = null;
26789      }
26790      if (!current || dirty[1] & /*is_dragging*/
26791      2048) {
26792        toggle_class(
26793          div0,
26794          "dragging",
26795          /*is_dragging*/
26796          ctx[42]
26797        );
26798      }
26799      if (!current || dirty[0] & /*wrap*/
26800      1024) {
26801        toggle_class(div0, "no-wrap", !/*wrap*/
26802        ctx[10]);
26803      }
26804      if (!current || dirty[1] & /*active_cell_menu, active_header_menu*/
26805      98304) {
26806        toggle_class(
26807          div0,
26808          "menu-open",
26809          /*active_cell_menu*/
26810          ctx[47] || /*active_header_menu*/
26811          ctx[46]
26812        );
26813      }
26814      if (
26815        /*data*/
26816        ctx[26].length === 0 && /*editable*/
26817        ctx[9] && /*row_count*/
26818        ctx[6][1] === "dynamic"
26819      ) {
26820        if (if_block5) {
26821          if_block5.p(ctx, dirty);
26822          if (dirty[0] & /*data, editable, row_count*/
26823          67109440) {
26824            transition_in(if_block5, 1);
26825          }
26826        } else {
26827          if_block5 = create_if_block_1$4(ctx);
26828          if_block5.c();
26829          transition_in(if_block5, 1);
26830          if_block5.m(t8.parentNode, t8);
26831        }
26832      } else if (if_block5) {
26833        group_outros();
26834        transition_out(if_block5, 1, 1, () => {
26835          if_block5 = null;
26836        });
26837        check_outros();
26838      }
26839      if (
26840        /*active_cell_menu*/
26841        ctx[47] || /*active_header_menu*/
26842        ctx[46]
26843      ) {
26844        if (if_block6) {
26845          if_block6.p(ctx, dirty);
26846          if (dirty[1] & /*active_cell_menu, active_header_menu*/
26847          98304) {
26848            transition_in(if_block6, 1);
26849          }
26850        } else {
26851          if_block6 = create_if_block$4(ctx);
26852          if_block6.c();
26853          transition_in(if_block6, 1);
26854          if_block6.m(if_block6_anchor.parentNode, if_block6_anchor);
26855        }
26856      } else if (if_block6) {
26857        group_outros();
26858        transition_out(if_block6, 1, 1, () => {
26859          if_block6 = null;
26860        });
26861        check_outros();
26862      }
26863    },
26864    i(local) {
26865      if (current) return;
26866      transition_in(if_block0);
26867      transition_in(if_block2);
26868      for (let i = 0; i < each_value_3.length; i += 1) {
26869        transition_in(each_blocks_1[i]);
26870      }
26871      transition_in(if_block3);
26872      for (let i = 0; i < each_value_2.length; i += 1) {
26873        transition_in(each_blocks[i]);
26874      }
26875      transition_in(upload_1.$$.fragment, local);
26876      transition_in(if_block5);
26877      transition_in(if_block6);
26878      current = true;
26879    },
26880    o(local) {
26881      transition_out(if_block0);
26882      transition_out(if_block2);
26883      for (let i = 0; i < each_blocks_1.length; i += 1) {
26884        transition_out(each_blocks_1[i]);
26885      }
26886      transition_out(if_block3);
26887      for (let i = 0; i < each_blocks.length; i += 1) {
26888        transition_out(each_blocks[i]);
26889      }
26890      transition_out(upload_1.$$.fragment, local);
26891      transition_out(if_block5);
26892      transition_out(if_block6);
26893      current = false;
26894    },
26895    d(detaching) {
26896      if (detaching) {
26897        detach(div1);
26898        detach(t7);
26899        detach(t8);
26900        detach(if_block6_anchor);
26901      }
26902      if (if_block0) if_block0.d();
26903      if (if_block1) if_block1.d();
26904      if (if_block2) if_block2.d();
26905      for (let i = 0; i < each_blocks_1.length; i += 1) {
26906        each_blocks_1[i].d();
26907      }
26908      if (if_block3) if_block3.d();
26909      for (let i = 0; i < each_blocks.length; i += 1) {
26910        each_blocks[i].d();
26911      }
26912      ctx[96](null);
26913      destroy_component(upload_1);
26914      if (if_block4) if_block4.d();
26915      ctx[109](null);
26916      if (if_block5) if_block5.d(detaching);
26917      if (if_block6) if_block6.d(detaching);
26918      mounted = false;
26919      run_all(dispose);
26920    }
26921  };
26922}
26923function make_id() {
26924  return Math.random().toString(36).substring(2, 15);
26925}
26926function get_cell_width(index) {
26927  return `var(--cell-width-${index})`;
26928}
26929const scroll_top_handler = (_) => {
26930};
26931function instance$8($$self, $$props, $$invalidate) {
26932  let selected_cells;
26933  let selected;
26934  let editing;
26935  let header_edit;
26936  let selected_header;
26937  let active_cell_menu;
26938  let active_header_menu;
26939  let copy_flash;
26940  let actual_pinned_columns;
26941  let max;
26942  let selected_index;
26943  let handle_mouse_down;
26944  let handle_mouse_move;
26945  let handle_mouse_up;
26946  let $df_state;
26947  let { datatype } = $$props;
26948  let { label = null } = $$props;
26949  let { show_label = true } = $$props;
26950  let { headers = [] } = $$props;
26951  let { values = [] } = $$props;
26952  let { col_count } = $$props;
26953  let { row_count } = $$props;
26954  let { latex_delimiters } = $$props;
26955  let { components = {} } = $$props;
26956  let { editable = true } = $$props;
26957  let { wrap = false } = $$props;
26958  let { root } = $$props;
26959  let { i18n } = $$props;
26960  let { max_height = 500 } = $$props;
26961  let { line_breaks = true } = $$props;
26962  let { column_widths = [] } = $$props;
26963  let { show_row_numbers = false } = $$props;
26964  let { upload } = $$props;
26965  let { stream_handler } = $$props;
26966  let { show_fullscreen_button = false } = $$props;
26967  let { show_copy_button = false } = $$props;
26968  let { value_is_output = false } = $$props;
26969  let { max_chars = void 0 } = $$props;
26970  let { show_search = "none" } = $$props;
26971  let { pinned_columns = 0 } = $$props;
26972  let { static_columns = [] } = $$props;
26973  let { fullscreen = false } = $$props;
26974  const df_ctx = create_dataframe_context$1({
26975    show_fullscreen_button,
26976    show_copy_button,
26977    show_search,
26978    show_row_numbers,
26979    editable,
26980    pinned_columns,
26981    show_label,
26982    line_breaks,
26983    wrap,
26984    max_height,
26985    column_widths,
26986    max_chars,
26987    static_columns
26988  });
26989  const { state: df_state, actions: df_actions } = df_ctx;
26990  component_subscribe($$self, df_state, (value) =>
26990 $$invalidate(33, $df_state = value));
26991  onMount(() => {
26992    $$invalidate(34, df_ctx.parent_element = parent, df_ctx);
26993    $$invalidate(34, df_ctx.get_data_at = get_data_at, df_ctx);
26994    $$invalidate(34, df_ctx.get_column = get_column, df_ctx);
26995    $$invalidate(34, df_ctx.get_row = get_row, df_ctx);
26996    $$invalidate(34, df_ctx.dispatch = dispatch2, df_ctx);
26997    init_drag_handlers();
26998    const observer = new IntersectionObserver((entries) => {
26999      entries.forEach((entry) => {
27000        if (entry.isIntersecting && !is_visible) {
27001          $$invalidate(85, width_calculated = false);
27002        }
27003        is_visible = entry.isIntersecting;
27004      });
27005    });
27006    observer.observe(parent);
27007    document.addEventListener("click", handle_click_outside$1$1);
27008    window.addEventListener("resize", handle_resize);
27009    const global_mouse_up = (event) => {
27010      if (is_dragging || drag_start) {
27011        handle_mouse_up(event);
27012      }
27013    };
27014    document.addEventListener("mouseup", global_mouse_up);
27015    return () => {
27016      observer.disconnect();
27017      document.removeEventListener("click", handle_click_outside$1$1);
27018      window.removeEventListener("resize", handle_resize);
27019      document.removeEventListener("mouseup", global_mouse_up);
27020    };
27021  });
27022  const dispatch2 = createEventDispatcher();
27023  let els = {};
27024  let data_binding = {};
27025  let _headers = make_headers$1(headers, col_count, els, make_id);
27026  let old_headers = headers;
27027  let data = [[]];
27028  let old_val = void 0;
27029  let search_results = [[]];
27030  let dragging = false;
27031  let color_accent_copied;
27032  let filtered_to_original_map = [];
27033  onMount(() => {
27034    const color = getComputedStyle(document.documentElement).getPropertyValue("--color-accent").trim();
27035    color_accent_copied = color + "40";
27036    document.documentElement.style.setProperty("--color-accent-copied", color_accent_copied);
27037  });
27038  const get_data_at = (row, col) => {
27039    var _a, _b;
27040    return (_b = (_a = data == null ? void 0 : data[row]) == null ? void 0 : _a[col]) == null ? void 0 : _b.value;
27041  };
27042  const get_column = (col) => (data == null ? void 0 : data.map((row) => {
27043    var _a;
27044    return (_a = row[col]) == null ? void 0 : _a.value;
27045  })) ?? [];
27046  const get_row = (row) => {
27047    var _a;
27048    return ((_a = data == null ? void 0 : data[row]) == null ? void 0 : _a.map((cell) => cell.value)) ?? [];
27049  };
27050  let { display_value = null } = $$props;
27051  let { styling = null } = $$props;
27052  let previous_headers = _headers.map((h) => h.value);
27053  let previous_data = data.map((row) => row.map((cell) => cell.value));
27054  function handle_sort(col, direction) {
27055    df_actions.handle_sort(col, direction);
27056    sort_data2(data, display_value, styling);
27057  }
27058  function clear_sort() {
27059    df_actions.reset_sort_state();
27060    sort_data2(data, display_value, styling);
27061  }
27062  function handle_filter(col, datatype2, filter, value) {
27063    df_actions.handle_filter(col, datatype2, filter, value);
27064    filter_data2(data, display_value, styling);
27065  }
27066  function clear_filter() {
27067    df_actions.reset_filter_state();
27068    filter_data2(data, display_value, styling);
27069  }
27070  async function edit_header(i, _select = false) {
27071    if (!editable || header_edit === i || col_count[1] !== "dynamic") return;
27072    df_actions.set_header_edit(i);
27073  }
27074  function handle_header_click(event, col) {
27075    if (event.target instanceof HTMLAnchorElement) {
27076      return;
27077    }
27078    event.preventDefault();
27079    event.stopPropagation();
27080    if (!editable) return;
27081    df_actions.set_editing(false);
27082    df_actions.handle_header_click(col, editable);
27083    parent.focus();
27084  }
27085  function end_header_edit(event) {
27086    if (!editable) return;
27087    df_actions.end_header_edit(event.detail.key);
27088    parent.focus();
27089  }
27090  async function add_row(index) {
27091    var _a;
27092    parent.focus();
27093    if (row_count[1] !== "dynamic") return;
27094    const new_row = Array(((_a = data[0]) == null ? void 0 : _a.length) || headers.length).fill(0).map((_, i) => {
27095      const _id = make_id();
27096      $$invalidate(24, els[_id] = { cell: null, input: null }, els);
27097      return { id: _id, value: "" };
27098    });
27099    if (data.length === 0) {
27100      $$invalidate(26, data = [new_row]);
27101    } else if (index !== void 0 && index >= 0 && index <= data.length) {
27102      data.splice(index, 0, new_row);
27103    } else {
27104      data.push(new_row);
27105    }
27106    $$invalidate(88, selected = [index !== void 0 ? index : data.length - 1, 0]);
27107  }
27108  async function add_col(index) {
27109    parent.focus();
27110    if (col_count[1] !== "dynamic") return;
27111    const result = df_actions.add_col(data, headers, make_id, index);
27112    result.data.forEach((row) => {
27113      row.forEach((cell) => {
27114        if (!els[cell.id]) {
27115          $$invalidate(24, els[cell.id] = { cell: null, input: null }, els);
27116        }
27117      });
27118    });
27119    $$invalidate(26, data = result.data);
27120    $$invalidate(0, headers = result.headers);
27121    await tick();
27122    requestAnimationFrame(() => {
27123      edit_header(index !== void 0 ? index : data[0].length - 1, true);
27124      const new_w = parent.querySelectorAll("tbody")[1].offsetWidth;
27125      parent.querySelectorAll("table")[1].scrollTo({ left: new_w });
27126    });
27127  }
27128  function handle_click_outside$1$1(event) {
27129    if (handle_click_outside$1(event, parent)) {
27130      df_actions.clear_ui_state();
27131      $$invalidate(52, header_edit = false);
27132      $$invalidate(51, selected_header = false);
27133    }
27134  }
27135  let width_calc_timeout;
27136  let width_calculated = false;
27137  let cells = [];
27138  let parent;
27139  let table;
27140  let last_width_data_length = 0;
27141  let last_width_column_count = 0;
27142  function set_cell_widths() {
27143    var _a;
27144    const column_count = ((_a = data[0]) == null ? void 0 : _a.length) || 0;
27145    if ($df_state.filter_state.filter_columns.length > 0) {
27146      return;
27147    }
27148    if (last_width_data_length === data.length && last_width_column_count === column_count && $df_state.sort_state.sort_columns.length > 0) {
27149      return;
27150    }
27151    if (!parent) {
27152      return;
27153    }
27154    last_width_data_length = data.length;
27155    last_width_column_count = column_count;
27156    const widths = cells.map((el) => (el == null ? void 0 : el.clientWidth) || 0);
27157    if (widths.length === 0) return;
27158    if (show_row_numbers) {
27159      parent.style.setProperty(`--cell-width-row-number`, `${widths[0]}px`);
27160    }
27161    for (let i = 0; i < 50; i++) {
27162      if (!column_widths[i]) {
27163        parent.style.removeProperty(`--cell-width-${i}`);
27164      } else if (column_widths[i].endsWith("%")) {
27165        const percentage = parseFloat(column_widths[i]);
27166        const pixel_width = Math.floor(percentage / 100 * parent.clientWidth);
27167        parent.style.setProperty(`--cell-width-${i}`, `${pixel_width}px`);
27168      } else {
27169        parent.style.setProperty(`--cell-width-${i}`, column_widths[i]);
27170      }
27171    }
27172    widths.forEach((width, i) => {
27173      if (!column_widths[i]) {
27174        const calculated_width = `${Math.max(width, 45)}px`;
27175        parent.style.setProperty(`--cell-width-${i}`, calculated_width);
27176      }
27177    });
27178  }
27179  let table_height = values.slice(0, max_height / values.length * 37).length * 37 + 37;
27180  let scrollbar_width = 0;
27181  function sort_data2(_data, _display_value, _styling) {
27182    const result = sort_data_and_preserve_selection$1(_data, _display_value, _styling, $df_state.sort_state.sort_columns, selected, get_current_indices$1);
27183    $$invalidate(26, data = result.data);
27184    $$invalidate(88, selected = result.selected);
27185  }
27186  function filter_data2(_data, _display_value, _styling) {
27187    var _a, _b, _c;
27188    const result = filter_data_and_preserve_selection$1(_data, _display_value, _styling, $df_state.filter_state.filter_columns, selected, get_current_indices$1, (_a = $df_state.filter_state.initial_data) == null ? void 0 : _a.data, (_b = $df_state.filter_state.initial_data) == null ? void 0 : _b.display_value, (_c = $df_state.filter_state.initial_data) == null ? void 0 : _c.styling);
27189    $$invalidate(26, data = result.data);
27190    $$invalidate(88, selected = result.selected);
27191  }
27192  let is_visible = false;
27193  const set_copy_flash = (value) => {
27194    df_actions.set_copy_flash(value);
27195  };
27196  let previous_selected_cells = [];
27197  function handle_blur(event) {
27198    const { blur_event, coords } = event.detail;
27199    handle_cell_blur$1(blur_event, df_ctx, coords);
27200  }
27201  function toggle_header_menu(event, col) {
27202    event.stopPropagation();
27203    if (active_header_menu && active_header_menu.col === col) {
27204      df_actions.set_active_header_menu(null);
27205    } else {
27206      const header = event.target.closest("th");
27207      if (header) {
27208        const rect = header.getBoundingClientRect();
27209        df_actions.set_active_header_menu({ col, x: rect.right, y: rect.bottom });
27210      }
27211    }
27212  }
27213  afterUpdate(() => {
27214    $$invalidate(74, value_is_output = false);
27215  });
27216  function delete_col_at(index) {
27217    if (col_count[1] !== "dynamic") return;
27218    if (data[0].length <= 1) return;
27219    const result = df_actions.delete_col_at(data, headers, index);
27220    $$invalidate(26, data = result.data);
27221    $$invalidate(0, headers = result.headers);
27222    $$invalidate(25, _headers = make_headers$1(headers, col_count, els, make_id));
27223    df_actions.set_active_cell_menu(null);
27224    df_actions.set_active_header_menu(null);
27225    df_actions.set_selected(false);
27226    df_actions.set_selected_cells([]);
27227    df_actions.set_editing(false);
27228  }
27229  function delete_row_at(index) {
27230    $$invalidate(26, data = df_actions.delete_row_at(data, index));
27231    df_actions.set_active_cell_menu(null);
27232    df_actions.set_active_header_menu(null);
27233  }
27234  let selected_cell_coords;
27235  function commit_filter() {
27236    if ($df_state.current_search_query && show_search === "filter") {
27237      const filtered_data = [];
27238      const filtered_display_values = [];
27239      const filtered_styling = [];
27240      search_results.forEach((row) => {
27241        const data_row = [];
27242        const display_row = [];
27243        const styling_row = [];
27244        row.forEach((cell) => {
27245          data_row.push(cell.value);
27246          display_row.push(cell.display_value !== void 0 ? cell.display_value : String(cell.value));
27247          styling_row.push(cell.styling || "");
27248        });
27249        filtered_data.push(data_row);
27250        filtered_display_values.push(display_row);
27251        filtered_styling.push(styling_row);
27252      });
27253      const change_payload = {
27254        data: filtered_data,
27255        headers: _headers.map((h) => h.value),
27256        metadata: {
27257          display_value: filtered_display_values,
27258          styling: filtered_styling
27259        }
27260      };
27261      dispatch2("change", change_payload);
27262      if (!value_is_output) {
27263        dispatch2("input");
27264      }
27265      df_actions.handle_search(null);
27266    }
27267  }
27268  let viewport;
27269  let show_scroll_button = false;
27270  function scroll_to_top() {
27271    viewport.scrollTo({ top: 0 });
27272  }
27273  function handle_resize() {
27274    df_actions.set_active_cell_menu(null);
27275    df_actions.set_active_header_menu(null);
27276    $$invalidate(31, selected_cells = []);
27277    $$invalidate(88, selected = false);
27278    $$invalidate(48, editing = false);
27279    $$invalidate(85, width_calculated = false);
27280    set_cell_widths();
27281  }
27282  function add_row_at(index, position) {
27283    const row_index = position === "above" ? index : index + 1;
27284    add_row(row_index);
27285    $$invalidate(47, active_cell_menu = null);
27286    $$invalidate(46, active_header_menu = null);
27287  }
27288  function add_col_at(index, position) {
27289    const col_index = position === "left" ? index : index + 1;
27290    add_col(col_index);
27291    $$invalidate(47, active_cell_menu = null);
27292    $$invalidate(46, active_header_menu = null);
27293  }
27294  function reset_sort_state() {
27295    df_actions.reset_sort_state();
27296  }
27297  function handle_select_all(col, checked) {
27298    $$invalidate(26, data = data.map((row) => {
27299      const new_row = [...row];
27300      if (new_row[col]) {
27301        new_row[col] = {
27302          ...new_row[col],
27303          value: checked.toString()
27304        };
27305      }
27306      return new_row;
27307    }));
27308  }
27309  let is_dragging = false;
27310  let drag_start = null;
27311  let mouse_down_pos = null;
27312  const drag_state = { is_dragging, drag_start, mouse_down_pos };
27313  let drag_handlers;
27314  function init_drag_handlers() {
27315    $$invalidate(87, drag_handlers = create_drag_handlers$1(drag_state, (value) =>
27315 $$invalidate(42, is_dragging = value), (cells2) => df_actions.set_selected_cells(cells2), (cell) => df_actions.set_selected(cell), (event, row, col) => df_actions.handle_cell_click(event, row, col), show_row_numbers, parent));
27316  }
27317  function get_cell_display_value(row, col) {
27318    var _a, _b;
27319    const is_search_active = $df_state.current_search_query !== void 0;
27320    if (is_search_active && ((_a = search_results == null ? void 0 : search_results[row]) == null ? void 0 : _a[col])) {
27321      return search_results[row][col].display_value !== void 0 ? search_results[row][col].display_value : String(search_results[row][col].value);
27322    }
27323    if ((_b = data == null ? void 0 : data[row]) == null ? void 0 : _b[col]) {
27324      return data[row][col].display_value !== void 0 ? data[row][col].display_value : String(data[row][col].value);
27325    }
27326    return "";
27327  }
27328  const resize_handler = () => set_cell_widths();
27329  const func2 = async () => await copy_table_data$1(data, null);
27330  const search_handler = (e) => df_actions.handle_search(e.detail);
27331  function fullscreen_handler(event) {
27332    bubble.call(this, $$self, event);
27333  }
27334  function tableheader_value_binding(value, i) {
27335    if ($$self.$$.not_equal(_headers[i].value, value)) {
27336      _headers[i].value = value;
27337      $$invalidate(25, _headers), $$invalidate(0, headers), $$invalidate(80, old_headers), $$invalidate(5, col_count), $$invalidate(24, els);
27338    }
27339  }
27340  function tableheader_el_binding(value, id) {
27341    if ($$self.$$.not_equal(els[id].input, value)) {
27342      els[id].input = value;
27343      $$invalidate(24, els);
27344    }
27345  }
27346  function td_binding($$value, j) {
27347    binding_callbacks[$$value ? "unshift" : "push"](() => {
27348      cells[j] = $$value;
27349      $$invalidate(28, cells);
27350    });
27351  }
27352  function table_1_binding($$value) {
27353    binding_callbacks[$$value ? "unshift" : "push"](() => {
27354      table = $$value;
27355      $$invalidate(30, table);
27356    });
27357  }
27358  const func_1 = (e, r, c) => handle_mouse_down(e, r, c);
27359  function tablecell_value_binding(value, index, j) {
27360    if ($$self.$$.not_equal(search_results[index][j].value, value)) {
27361      search_results[index][j].value = value;
27362      $$invalidate(35, search_results), $$invalidate(33, $df_state), $$invalidate(26, data), $$invalidate(27, filtered_to_original_map), $$invalidate(78, styling), $$invalidate(1, values), $$invalidate(81, old_val), $$invalidate(29, parent), $$invalidate(24, els), $$invalidate(132, data_binding), $$invalidate(77, display_value), $$invalidate(2, datatype), $$invalidate(28, cells);
27363    }
27364  }
27365  function tablecell_el_binding(value, id) {
27366    if ($$self.$$.not_equal(els[id], value)) {
27367      els[id] = value;
27368      $$invalidate(24, els);
27369    }
27370  }
27371  function tableheader_value_binding_1(value, i) {
27372    if ($$self.$$.not_equal(_headers[i].value, value)) {
27373      _headers[i].value = value;
27374      $$invalidate(25, _headers), $$invalidate(0, headers), $$invalidate(80, old_headers), $$invalidate(5, col_count), $$invalidate(24, els);
27375    }
27376  }
27377  function tableheader_el_binding_1(value, id) {
27378    if ($$self.$$.not_equal(els[id].input, value)) {
27379      els[id].input = value;
27380      $$invalidate(24, els);
27381    }
27382  }
27383  function virtualtable_items_binding(value) {
27384    search_results = value;
27385    $$invalidate(35, search_results), $$invalidate(33, $df_state), $$invalidate(26, data), $$invalidate(27, filtered_to_original_map), $$invalidate(78, styling), $$invalidate(1, values), $$invalidate(81, old_val), $$invalidate(29, parent), $$invalidate(24, els), $$invalidate(132, data_binding), $$invalidate(77, display_value), $$invalidate(2, datatype), $$invalidate(28, cells);
27386  }
27387  function virtualtable_actual_height_binding(value) {
27388    table_height = value;
27389    $$invalidate(37, table_height);
27390  }
27391  function virtualtable_table_scrollbar_width_binding(value) {
27392    scrollbar_width = value;
27393    $$invalidate(38, scrollbar_width);
27394  }
27395  function virtualtable_viewport_binding(value) {
27396    viewport = value;
27397    $$invalidate(40, viewport);
27398  }
27399  function virtualtable_show_scroll_button_binding(value) {
27400    show_scroll_button = value;
27401    $$invalidate(41, show_scroll_button);
27402  }
27403  function upload_1_dragging_binding(value) {
27404    dragging = value;
27405    $$invalidate(36, dragging);
27406  }
27407  const load_handler = ({ detail }) => handle_file_upload$1(
27408    detail.data,
27409    (head) => {
27410      $$invalidate(25, _headers = make_headers$1(head.map((h) => h ?? ""), col_count, els, make_id));
27411      return _headers;
27412    },
27413    (vals) => {
27414      $$invalidate(1, values = vals);
27415    }
27416  );
27417  function div0_binding($$value) {
27418    binding_callbacks[$$value ? "unshift" : "push"](() => {
27419      parent = $$value;
27420      $$invalidate(29, parent);
27421    });
27422  }
27423  const keydown_handler2 = (e) => handle_keydown$1(e, df_ctx);
27424  const func_2 = () => add_row();
27425  const func_3 = () => add_row_at((active_cell_menu == null ? void 0 : active_cell_menu.row) ?? -1, "above");
27426  const func_4 = () => add_row_at((active_cell_menu == null ? void 0 : active_cell_menu.row) ?? -1, "below");
27427  const func_5 = () => add_col_at((active_cell_menu == null ? void 0 : active_cell_menu.col) ?? (active_header_menu == null ? void 0 : active_header_menu.col) ?? -1, "left");
27428  const func_6 = () => add_col_at((active_cell_menu == null ? void 0 : active_cell_menu.col) ?? (active_header_menu == null ? void 0 : active_header_menu.col) ?? -1, "right");
27429  const func_7 = () => delete_row_at((active_cell_menu == null ? void 0 : active_cell_menu.row) ?? -1);
27430  const func_8 = () => delete_col_at((active_cell_menu == null ? void 0 : active_cell_menu.col) ?? (active_header_menu == null ? void 0 : active_header_menu.col) ?? -1);
27431  const func_9 = (direction) => {
27432    if (active_header_menu) {
27433      handle_sort(active_header_menu.col, direction);
27434      df_actions.set_active_header_menu(null);
27435    }
27436  };
27437  const func_10 = () => {
27438    clear_sort();
27439    df_actions.set_active_header_menu(null);
27440  };
27441  const func_11 = (item) => item.col === ((active_header_menu == null ? void 0 : active_header_menu.col) ?? -1);
27442  const func_12 = (item) => item.col === ((active_header_menu == null ? void 0 : active_header_menu.col) ?? -1);
27443  const func_13 = (datatype2, filter, value) => {
27444    if (active_header_menu) {
27445      handle_filter(active_header_menu.col, datatype2, filter, value);
27446      df_actions.set_active_header_menu(null);
27447    }
27448  };
27449  const func_14 = () => {
27450    clear_filter();
27451    df_actions.set_active_header_menu(null);
27452  };
27453  const func_15 = (c) => c.col === ((active_header_menu == null ? void 0 : active_header_menu.col) ?? -1);
27454  $$self.$$set = ($$props2) => {
27455    if ("datatype" in $$props2) $$invalidate(2, datatype = $$props2.datatype);
27456    if ("label" in $$props2) $$invalidate(3, label = $$props2.label);
27457    if ("show_label" in $$props2) $$invalidate(4, show_label = $$props2.show_label);
27458    if ("headers" in $$props2) $$invalidate(0, headers = $$props2.headers);
27459    if ("values" in $$props2) $$invalidate(1, values = $$props2.values);
27460    if ("col_count" in $$props2) $$invalidate(5, col_count = $$props2.col_count);
27461    if ("row_count" in $$props2) $$invalidate(6, row_count = $$props2.row_count);
27462    if ("latex_delimiters" in $$props2) $$invalidate(7, latex_delimiters = $$props2.latex_delimiters);
27463    if ("components" in $$props2) $$invalidate(8, components = $$props2.components);
27464    if ("editable" in $$props2) $$invalidate(9, editable = $$props2.editable);
27465    if ("wrap" in $$props2) $$invalidate(10, wrap = $$props2.wrap);
27466    if ("root" in $$props2) $$invalidate(11, root = $$props2.root);
27467    if ("i18n" in $$props2) $$invalidate(12, i18n = $$props2.i18n);
27468    if ("max_height" in $$props2) $$invalidate(13, max_height = $$props2.max_height);
27469    if ("line_breaks" in $$props2) $$invalidate(14, line_breaks = $$props2.line_breaks);
27470    if ("column_widths" in $$props2) $$invalidate(75, column_widths = $$props2.column_widths);
27471    if ("show_row_numbers" in $$props2) $$invalidate(15, show_row_numbers = $$props2.show_row_numbers);
27472    if ("upload" in $$props2) $$invalidate(16, upload = $$props2.upload);
27473    if ("stream_handler" in $$props2) $$invalidate(17, stream_handler = $$props2.stream_handler);
27474    if ("show_fullscreen_button" in $$props2) $$invalidate(18, show_fullscreen_button = $$props2.show_fullscreen_button);
27475    if ("show_copy_button" in $$props2) $$invalidate(19, show_copy_button = $$props2.show_copy_button);
27476    if ("value_is_output" in $$props2) $$invalidate(74, value_is_output = $$props2.value_is_output);
27477    if ("max_chars" in $$props2) $$invalidate(20, max_chars = $$props2.max_chars);
27478    if ("show_search" in $$props2) $$invalidate(21, show_search = $$props2.show_search);
27479    if ("pinned_columns" in $$props2) $$invalidate(76, pinned_columns = $$props2.pinned_columns);
27480    if ("static_columns" in $$props2) $$invalidate(22, static_columns = $$props2.static_columns);
27481    if ("fullscreen" in $$props2) $$invalidate(23, fullscreen = $$props2.fullscreen);
27482    if ("display_value" in $$props2) $$invalidate(77, display_value = $$props2.display_value);
27483    if ("styling" in $$props2) $$invalidate(78, styling = $$props2.styling);
27484  };
27485  $$self.$$.update = () => {
27486    var _a, _b;
27487    if ($$self.$$.dirty[1] & /*$df_state*/
27488    4) {
27489      $$invalidate(31, selected_cells = $df_state.ui_state.selected_cells);
27490    }
27491    if ($$self.$$.dirty[1] & /*$df_state*/
27492    4) {
27493      $$invalidate(88, selected = $df_state.ui_state.selected);
27494    }
27495    if ($$self.$$.dirty[1] & /*$df_state*/
27496    4) {
27497      $$invalidate(48, editing = $df_state.ui_state.editing);
27498    }
27499    if ($$self.$$.dirty[1] & /*$df_state*/
27500    4) {
27501      $$invalidate(52, header_edit = $df_state.ui_state.header_edit);
27502    }
27503    if ($$self.$$.dirty[1] & /*$df_state*/
27504    4) {
27505      $$invalidate(51, selected_header = $df_state.ui_state.selected_header);
27506    }
27507    if ($$self.$$.dirty[1] & /*$df_state*/
27508    4) {
27509      $$invalidate(47, active_cell_menu = $df_state.ui_state.active_cell_menu);
27510    }
27511    if ($$self.$$.dirty[1] & /*$df_state*/
27512    4) {
27513      $$invalidate(46, active_header_menu = $df_state.ui_state.active_header_menu);
27514    }
27515    if ($$self.$$.dirty[1] & /*$df_state*/
27516    4) {
27517      $$invalidate(32, copy_flash = $df_state.ui_state.copy_flash);
27518    }
27519    if ($$self.$$.dirty[0] & /*values, parent, els, datatype, data, cells*/
27520    889192454 | $$self.$$.dirty[1] & /*$df_state*/
27521    4 | $$self.$$.dirty[2] & /*old_val, display_value, styling*/
27522    622592) {
27523      if (!dequal(values, old_val)) {
27524        if (parent) {
27525          const is_reset2 = values.length === 0 || values.length === 1 && values[0].length === 0;
27526          const is_different_structure2 = old_val !== void 0 && (values.length !== old_val.length || values[0] && old_val[0] && values[0].length !== old_val[0].length);
27527          if (is_reset2 || is_different_structure2) {
27528            for (let i = 0; i < 50; i++) {
27529              parent.style.removeProperty(`--cell-width-${i}`);
27530            }
27531            last_width_data_length = 0;
27532            last_width_column_count = 0;
27533            $$invalidate(85, width_calculated = false);
27534          }
27535        }
27536        const is_reset = values.length === 0 || values.length === 1 && values[0].length === 0;
27537        const is_different_structure = old_val !== void 0 && (values.length !== old_val.length || values[0] && old_val[0] && values[0].length !== old_val[0].length);
27538        $$invalidate(26, data = process_data$1(values, els, data_binding, make_id, display_value, datatype));
27539        $$invalidate(81, old_val = JSON.parse(JSON.stringify(values)));
27540        if (is_reset || is_different_structure) {
27541          df_actions.reset_sort_state();
27542        } else if ($df_state.sort_state.sort_columns.length > 0) {
27543          sort_data2(data, display_value, styling);
27544        } else {
27545          df_actions.handle_sort(-1, "asc");
27546          df_actions.reset_sort_state();
27547        }
27548        if ($df_state.filter_state.filter_columns.length > 0) {
27549          filter_data2(data, display_value, styling);
27550        } else {
27551          df_actions.reset_filter_state();
27552        }
27553        if ($df_state.current_search_query) {
27554          df_actions.handle_search(null);
27555        }
27556        if (parent && cells.length > 0 && (is_reset || is_different_structure)) {
27557          $$invalidate(85, width_calculated = false);
27558        }
27559      }
27560    }
27561    if ($$self.$$.dirty[0] & /*data*/
27562    67108864 | $$self.$$.dirty[2] & /*pinned_columns*/
27563    16384) {
27564      $$invalidate(53, actual_pinned_columns = pinned_columns && ((_a = data == null ? void 0 : data[0]) == null ? void 0 : _a.length) ? Math.min(pinned_columns, data[0].length) : 0);
27565    }
27566    if ($$self.$$.dirty[0] & /*headers, col_count, els*/
27567    16777249 | $$self.$$.dirty[2] & /*old_headers*/
27568    262144) {
27569      {
27570        if (!dequal(headers, old_headers)) {
27571          $$invalidate(25, _headers = make_headers$1(headers, col_count, els, make_id));
27572          $$invalidate(80, old_headers = JSON.parse(JSON.stringify(headers)));
27573        }
27574      }
27575    }
27576    if ($$self.$$.dirty[0] & /*data, _headers, els*/
27577    117440512 | $$self.$$.dirty[2] & /*display_value, styling*/
27578    98304) {
27579      {
27580        if (data || _headers || els) {
27581          $$invalidate(34, df_ctx.data = data, df_ctx);
27582          $$invalidate(34, df_ctx.headers = _headers, df_ctx);
27583          $$invalidate(34, df_ctx.els = els, df_ctx);
27584          $$invalidate(34, df_ctx.display_value = display_value, df_ctx);
27585          $$invalidate(34, df_ctx.styling = styling, df_ctx);
27586        }
27587      }
27588    }
27589    if ($$self.$$.dirty[0] & /*data, filtered_to_original_map*/
27590    201326592 | $$self.$$.dirty[1] & /*$df_state*/
27591    4 | $$self.$$.dirty[2] & /*styling*/
27592    65536) {
27593      if ($df_state.current_search_query !== void 0) {
27594        const cell_map = /* @__PURE__ */ new Map();
27595        $$invalidate(27, filtered_to_original_map = []);
27596        data.forEach((row, row_idx) => {
27597          if (row.some((cell) => {
27598            var _a2;
27599            return String(cell == null ? void 0 : cell.value).toLowerCase().includes(((_a2 = $df_state.current_search_query) == null ? void 0 : _a2.toLowerCase()) || "");
27600          })) {
27601            filtered_to_original_map.push(row_idx);
27602          }
27603          row.forEach((cell, col_idx) => {
27604            var _a2;
27605            cell_map.set(cell.id, {
27606              value: cell.value,
27607              display_value: cell.display_value !== void 0 ? cell.display_value : String(cell.value),
27608              styling: ((_a2 = styling == null ? void 0 : styling[row_idx]) == null ? void 0 : _a2[col_idx]) || ""
27609            });
27610          });
27611        });
27612        const filtered = df_actions.filter_data(data);
27613        $$invalidate(35, search_results = filtered.map((row) => row.map((cell) => {
27614          const original = cell_map.get(cell.id);
27615          return {
27616            ...cell,
27617            display_value: (original == null ? void 0 : original.display_value) !== void 0 ? original.display_value : String(cell.value),
27618            styling: (original == null ? void 0 : original.styling) || ""
27619          };
27620        })));
27621      } else {
27622        $$invalidate(27, filtered_to_original_map = []);
27623      }
27624    }
27625    if ($$self.$$.dirty[0] & /*data, _headers*/
27626    100663296 | $$self.$$.dirty[2] & /*previous_data, previous_headers, value_is_output*/
27627    3149824) {
27628      {
27629        if (data || _headers) {
27630          df_actions.trigger_change(data, _headers, previous_data, previous_headers, value_is_output, dispatch2);
27631          $$invalidate(83, previous_data = data.map((row) => row.map((cell) => cell.value)));
27632          $$invalidate(82, previous_headers = _headers.map((h) => h.value));
27633        }
27634      }
27635    }
27636    if ($$self.$$.dirty[0] & /*data*/
27637    67108864 | $$self.$$.dirty[1] & /*$df_state*/
27638    4 | $$self.$$.dirty[2] & /*display_value, styling*/
27639    98304) {
27640      {
27641        if ($df_state.filter_state.filter_columns.length > 0) {
27642          filter_data2(data, display_value, styling);
27643        }
27644        if ($df_state.sort_state.sort_columns.length > 0) {
27645          sort_data2(data, display_value, styling);
27646          df_actions.update_row_order(data);
27647        }
27648      }
27649    }
27650    if ($$self.$$.dirty[0] & /*data*/
27651    67108864) {
27652      $$invalidate(50, max = get_max$1(data));
27653    }
27654    if ($$self.$$.dirty[0] & /*cells*/
27655    268435456 | $$self.$$.dirty[2] & /*width_calc_timeout*/
27656    4194304) {
27657      if (cells[0] && ((_b = cells[0]) == null ? void 0 : _b.clientWidth)) {
27658        clearTimeout(width_calc_timeout);
27659        $$invalidate(84, width_calc_timeout = setTimeout(() => set_cell_widths(), 100));
27660      }
27661    }
27662    if ($$self.$$.dirty[0] & /*cells*/
27663    268435456 | $$self.$$.dirty[2] & /*width_calculated*/
27664    8388608) {
27665      if (cells[0] && !width_calculated) {
27666        set_cell_widths();
27667        $$invalidate(85, width_calculated = true);
27668      }
27669    }
27670    if ($$self.$$.dirty[2] & /*selected*/
27671    67108864) {
27672      $$invalidate(49, selected_index = !!selected && selected[0]);
27673    }
27674    if ($$self.$$.dirty[1] & /*copy_flash, selected_cells*/
27675    3 | $$self.$$.dirty[2] & /*previous_selected_cells*/
27676    16777216) {
27677      {
27678        if (copy_flash && !dequal(selected_cells, previous_selected_cells)) {
27679          set_copy_flash(false);
27680        }
27681        $$invalidate(86, previous_selected_cells = selected_cells);
27682      }
27683    }
27684    if ($$self.$$.dirty[2] & /*selected*/
27685    67108864) {
27686      if (selected !== false) $$invalidate(39, selected_cell_coords = selected);
27687    }
27688    if ($$self.$$.dirty[0] & /*data, els, parent, table*/
27689    1694498816 | $$self.$$.dirty[2] & /*selected*/
27690    67108864) {
27691      if (selected !== false) {
27692        const positions = calculate_selection_positions$1(selected, data, els, parent, table);
27693        document.documentElement.style.setProperty("--selected-col-pos", positions.col_pos);
27694        document.documentElement.style.setProperty("--selected-row-pos", positions.row_pos || "0px");
27695      }
27696    }
27697    if ($$self.$$.dirty[0] & /*parent*/
27698    536870912) {
27699      if (parent) init_drag_handlers();
27700    }
27701    if ($$self.$$.dirty[2] & /*drag_handlers*/
27702    33554432) {
27703      $$invalidate(45, handle_mouse_down = (drag_handlers == null ? void 0 : drag_handlers.handle_mouse_down) || (() => {
27704      }));
27705    }
27706    if ($$self.$$.dirty[2] & /*drag_handlers*/
27707    33554432) {
27708      $$invalidate(44, handle_mouse_move = (drag_handlers == null ? void 0 : drag_handlers.handle_mouse_move) || (() => {
27709      }));
27710    }
27711    if ($$self.$$.dirty[2] & /*drag_handlers*/
27712    33554432) {
27713      $$invalidate(43, handle_mouse_up = (drag_handlers == null ? void 0 : drag_handlers.handle_mouse_up) || (() => {
27714      }));
27715    }
27716  };
27717  {
27718    $$invalidate(42, is_dragging = drag_state.is_dragging);
27719    drag_start = drag_state.drag_start;
27720    mouse_down_pos = drag_state.mouse_down_pos;
27721  }
27722  return [
27723    headers,
27724    values,
27725    datatype,
27726    label,
27727    show_label,
27728    col_count,
27729    row_count,
27730    latex_delimiters,
27731    components,
27732    editable,
27733    wrap,
27734    root,
27735    i18n,
27736    max_height,
27737    line_breaks,
27738    show_row_numbers,
27739    upload,
27740    stream_handler,
27741    show_fullscreen_button,
27742    show_copy_button,
27743    max_chars,
27744    show_search,
27745    static_columns,
27746    fullscreen,
27747    els,
27748    _headers,
27749    data,
27750    filtered_to_original_map,
27751    cells,
27752    parent,
27753    table,
27754    selected_cells,
27755    copy_flash,
27756    $df_state,
27757    df_ctx,
27758    search_results,
27759    dragging,
27760    table_height,
27761    scrollbar_width,
27762    selected_cell_coords,
27763    viewport,
27764    show_scroll_button,
27765    is_dragging,
27766    handle_mouse_up,
27767    handle_mouse_move,
27768    handle_mouse_down,
27769    active_header_menu,
27770    active_cell_menu,
27771    editing,
27772    selected_index,
27773    max,
27774    selected_header,
27775    header_edit,
27776    actual_pinned_columns,
27777    df_state,
27778    df_actions,
27779    handle_sort,
27780    clear_sort,
27781    handle_filter,
27782    clear_filter,
27783    handle_header_click,
27784    end_header_edit,
27785    add_row,
27786    set_cell_widths,
27787    handle_blur,
27788    toggle_header_menu,
27789    delete_col_at,
27790    delete_row_at,
27791    commit_filter,
27792    scroll_to_top,
27793    add_row_at,
27794    add_col_at,
27795    handle_select_all,
27796    get_cell_display_value,
27797    value_is_output,
27798    column_widths,
27799    pinned_columns,
27800    display_value,
27801    styling,
27802    reset_sort_state,
27803    old_headers,
27804    old_val,
27805    previous_headers,
27806    previous_data,
27807    width_calc_timeout,
27808    width_calculated,
27809    previous_selected_cells,
27810    drag_handlers,
27811    selected,
27812    resize_handler,
27813    func2,
27814    search_handler,
27815    fullscreen_handler,
27816    tableheader_value_binding,
27817    tableheader_el_binding,
27818    td_binding,
27819    table_1_binding,
27820    func_1,
27821    tablecell_value_binding,
27822    tablecell_el_binding,
27823    tableheader_value_binding_1,
27824    tableheader_el_binding_1,
27825    virtualtable_items_binding,
27826    virtualtable_actual_height_binding,
27827    virtualtable_table_scrollbar_width_binding,
27828    virtualtable_viewport_binding,
27829    virtualtable_show_scroll_button_binding,
27830    upload_1_dragging_binding,
27831    load_handler,
27832    div0_binding,
27833    keydown_handler2,
27834    func_2,
27835    func_3,
27836    func_4,
27837    func_5,
27838    func_6,
27839    func_7,
27840    func_8,
27841    func_9,
27842    func_10,
27843    func_11,
27844    func_12,
27845    func_13,
27846    func_14,
27847    func_15
27848  ];
27849}
27850let Table$1 = class Table extends SvelteComponent {
27851  constructor(options) {
27852    super();
27853    init(
27854      this,
27855      options,
27856      instance$8,
27857      create_fragment$8,
27858      safe_not_equal,
27859      {
27860        datatype: 2,
27861        label: 3,
27862        show_label: 4,
27863        headers: 0,
27864        values: 1,
27865        col_count: 5,
27866        row_count: 6,
27867        latex_delimiters: 7,
27868        components: 8,
27869        editable: 9,
27870        wrap: 10,
27871        root: 11,
27872        i18n: 12,
27873        max_height: 13,
27874        line_breaks: 14,
27875        column_widths: 75,
27876        show_row_numbers: 15,
27877        upload: 16,
27878        stream_handler: 17,
27879        show_fullscreen_button: 18,
27880        show_copy_button: 19,
27881        value_is_output: 74,
27882        max_chars: 20,
27883        show_search: 21,
27884        pinned_columns: 76,
27885        static_columns: 22,
27886        fullscreen: 23,
27887        display_value: 77,
27888        styling: 78,
27889        reset_sort_state: 79
27890      },
27891      null,
27892      [-1, -1, -1, -1, -1, -1]
27893    );
27894  }
27895  get reset_sort_state() {
27896    return this.$$.ctx[79];
27897  }
27898};
27899const get_coordinates_of_clicked_image = (evt) => {
27900  let image;
27901  if (evt.currentTarget instanceof Element) {
27902    image = evt.currentTarget.querySelector("img");
27903  } else {
27904    return [NaN, NaN];
27905  }
27906  const imageRect = image.getBoundingClientRect();
27907  const xScale = image.naturalWidth / imageRect.width;
27908  const yScale = image.naturalHeight / imageRect.height;
27909  if (xScale > yScale) {
27910    const displayed_height = image.naturalHeight / xScale;
27911    const y_offset = (imageRect.height - displayed_height) / 2;
27912    var x = Math.round((evt.clientX - imageRect.left) * xScale);
27913    var y = Math.round((evt.clientY - imageRect.top - y_offset) * xScale);
27914  } else {
27915    const displayed_width = image.naturalWidth / yScale;
27916    const x_offset = (imageRect.width - displayed_width) / 2;
27917    var x = Math.round((evt.clientX - imageRect.left - x_offset) * yScale);
27918    var y = Math.round((evt.clientY - imageRect.top) * yScale);
27919  }
27920  if (x < 0 || x >= image.naturalWidth || y < 0 || y >= image.naturalHeight) {
27921    return null;
27922  }
27923  return [x, y];
27924};
27925function create_fragment$7(ctx) {
27926  let img;
27927  let img_src_value;
27928  let mounted;
27929  let dispose;
27930  let img_levels = [
27931    { src: img_src_value = /*src*/
27932    ctx[0] },
27933    /*$$restProps*/
27934    ctx[1]
27935  ];
27936  let img_data = {};
27937  for (let i = 0; i < img_levels.length; i += 1) {
27938    img_data = assign(img_data, img_levels[i]);
27939  }
27940  return {
27941    c() {
27942      img = element("img");
27943      set_attributes(img, img_data);
27944      toggle_class(img, "svelte-kxeri3", true);
27945    },
27946    m(target, anchor) {
27947      insert(target, img, anchor);
27948      if (!mounted) {
27949        dispose = listen(
27950          img,
27951          "load",
27952          /*load_handler*/
27953          ctx[2]
27954        );
27955        mounted = true;
27956      }
27957    },
27958    p(ctx2, [dirty]) {
27959      set_attributes(img, img_data = get_spread_update(img_levels, [
27960        dirty & /*src*/
27961        1 && !src_url_equal(img.src, img_src_value = /*src*/
27962        ctx2[0]) && { src: img_src_value },
27963        dirty & /*$$restProps*/
27964        2 && /*$$restProps*/
27965        ctx2[1]
27966      ]));
27967      toggle_class(img, "svelte-kxeri3", true);
27968    },
27969    i: noop,
27970    o: noop,
27971    d(detaching) {
27972      if (detaching) {
27973        detach(img);
27974      }
27975      mounted = false;
27976      dispose();
27977    }
27978  };
27979}
27980function instance$7($$self, $$props, $$invalidate) {
27981  const omit_props_names = ["src"];
27982  let $$restProps = compute_rest_props($$props, omit_props_names);
27983  let { src = void 0 } = $$props;
27984  function load_handler(event) {
27985    bubble.call(this, $$self, event);
27986  }
27987  $$self.$$set = ($$new_props) => {
27988    $$props = assign(assign({}, $$props), exclude_internal_props($$new_props));
27989    $$invalidate(1, $$restProps = compute_rest_props($$props, omit_props_names));
27990    if ("src" in $$new_props) $$invalidate(0, src = $$new_props.src);
27991  };
27992  return [src, $$restProps, load_handler];
27993}
27994class Image2 extends SvelteComponent {
27995  constructor(options) {
27996    super();
27997    init(this, options, instance$7, create_fragment$7, safe_not_equal, { src: 0 });
27998  }
27999}
28000function create_else_block$2(ctx) {
28001  let div1;
28002  let iconbuttonwrapper;
28003  let t;
28004  let button;
28005  let div0;
28006  let image;
28007  let current;
28008  let mounted;
28009  let dispose;
28010  iconbuttonwrapper = new IconButtonWrapper({
28011    props: {
28012      display_top_corner: (
28013        /*display_icon_button_wrapper_top_corner*/
28014        ctx[8]
28015      ),
28016      $$slots: { default: [create_default_slot_1$2] },
28017      $$scope: { ctx }
28018    }
28019  });
28020  image = new Image2({
28021    props: {
28022      src: (
28023        /*value*/
28024        ctx[0].url
28025      ),
28026      alt: "",
28027      loading: "lazy"
28028    }
28029  });
28030  image.$on(
28031    "load",
28032    /*load_handler*/
28033    ctx[16]
28034  );
28035  return {
28036    c() {
28037      div1 = element("div");
28038      create_component(iconbuttonwrapper.$$.fragment);
28039      t = space();
28040      button = element("button");
28041      div0 = element("div");
28042      create_component(image.$$.fragment);
28043      attr(div0, "class", "image-frame svelte-x2tujq");
28044      toggle_class(
28045        div0,
28046        "selectable",
28047        /*selectable*/
28048        ctx[4]
28049      );
28050      attr(button, "class", "svelte-x2tujq");
28051      attr(div1, "class", "image-container svelte-x2tujq");
28052    },
28053    m(target, anchor) {
28054      insert(target, div1, anchor);
28055      mount_component(iconbuttonwrapper, div1, null);
28056      append(div1, t);
28057      append(div1, button);
28058      append(button, div0);
28059      mount_component(image, div0, null);
28060      ctx[17](div1);
28061      current = true;
28062      if (!mounted) {
28063        dispose = listen(
28064          button,
28065          "click",
28066          /*handle_click*/
28067          ctx[11]
28068        );
28069        mounted = true;
28070      }
28071    },
28072    p(ctx2, dirty) {
28073      const iconbuttonwrapper_changes = {};
28074      if (dirty & /*display_icon_button_wrapper_top_corner*/
28075      256) iconbuttonwrapper_changes.display_top_corner = /*display_icon_button_wrapper_top_corner*/
28076      ctx2[8];
28077      if (dirty & /*$$scope, i18n, value, show_share_button, show_download_button, fullscreen, show_fullscreen_button*/
28078      525033) {
28079        iconbuttonwrapper_changes.$$scope = { dirty, ctx: ctx2 };
28080      }
28081      iconbuttonwrapper.$set(iconbuttonwrapper_changes);
28082      const image_changes = {};
28083      if (dirty & /*value*/
28084      1) image_changes.src = /*value*/
28085      ctx2[0].url;
28086      image.$set(image_changes);
28087      if (!current || dirty & /*selectable*/
28088      16) {
28089        toggle_class(
28090          div0,
28091          "selectable",
28092          /*selectable*/
28093          ctx2[4]
28094        );
28095      }
28096    },
28097    i(local) {
28098      if (current) return;
28099      transition_in(iconbuttonwrapper.$$.fragment, local);
28100      transition_in(image.$$.fragment, local);
28101      current = true;
28102    },
28103    o(local) {
28104      transition_out(iconbuttonwrapper.$$.fragment, local);
28105      transition_out(image.$$.fragment, local);
28106      current = false;
28107    },
28108    d(detaching) {
28109      if (detaching) {
28110        detach(div1);
28111      }
28112      destroy_component(iconbuttonwrapper);
28113      destroy_component(image);
28114      ctx[17](null);
28115      mounted = false;
28116      dispose();
28117    }
28118  };
28119}
28120function create_if_block$3(ctx) {
28121  let empty_1;
28122  let current;
28123  empty_1 = new Empty({
28124    props: {
28125      unpadded_box: true,
28126      size: "large",
28127      $$slots: { default: [create_default_slot$3] },
28128      $$scope: { ctx }
28129    }
28130  });
28131  return {
28132    c() {
28133      create_component(empty_1.$$.fragment);
28134    },
28135    m(target, anchor) {
28136      mount_component(empty_1, target, anchor);
28137      current = true;
28138    },
28139    p(ctx2, dirty) {
28140      const empty_1_changes = {};
28141      if (dirty & /*$$scope*/
28142      524288) {
28143        empty_1_changes.$$scope = { dirty, ctx: ctx2 };
28144      }
28145      empty_1.$set(empty_1_changes);
28146    },
28147    i(local) {
28148      if (current) return;
28149      transition_in(empty_1.$$.fragment, local);
28150      current = true;
28151    },
28152    o(local) {
28153      transition_out(empty_1.$$.fragment, local);
28154      current = false;
28155    },
28156    d(detaching) {
28157      destroy_component(empty_1, detaching);
28158    }
28159  };
28160}
28161function create_if_block_3$2(ctx) {
28162  let fullscreenbutton;
28163  let current;
28164  fullscreenbutton = new FullscreenButton({
28165    props: { fullscreen: (
28166      /*fullscreen*/
28167      ctx[9]
28168    ) }
28169  });
28170  fullscreenbutton.$on(
28171    "fullscreen",
28172    /*fullscreen_handler*/
28173    ctx[12]
28174  );
28175  return {
28176    c() {
28177      create_component(fullscreenbutton.$$.fragment);
28178    },
28179    m(target, anchor) {
28180      mount_component(fullscreenbutton, target, anchor);
28181      current = true;
28182    },
28183    p(ctx2, dirty) {
28184      const fullscreenbutton_changes = {};
28185      if (dirty & /*fullscreen*/
28186      512) fullscreenbutton_changes.fullscreen = /*fullscreen*/
28187      ctx2[9];
28188      fullscreenbutton.$set(fullscreenbutton_changes);
28189    },
28190    i(local) {
28191      if (current) return;
28192      transition_in(fullscreenbutton.$$.fragment, local);
28193      current = true;
28194    },
28195    o(local) {
28196      transition_out(fullscreenbutton.$$.fragment, local);
28197      current = false;
28198    },
28199    d(detaching) {
28200      destroy_component(fullscreenbutton, detaching);
28201    }
28202  };
28203}
28204function create_if_block_2$3(ctx) {
28205  let downloadlink;
28206  let current;
28207  downloadlink = new DownloadLink({
28208    props: {
28209      href: (
28210        /*value*/
28211        ctx[0].url
28212      ),
28213      download: (
28214        /*value*/
28215        ctx[0].orig_name || "image"
28216      ),
28217      $$slots: { default: [create_default_slot_2$1] },
28218      $$scope: { ctx }
28219    }
28220  });
28221  return {
28222    c() {
28223      create_component(downloadlink.$$.fragment);
28224    },
28225    m(target, anchor) {
28226      mount_component(downloadlink, target, anchor);
28227      current = true;
28228    },
28229    p(ctx2, dirty) {
28230      const downloadlink_changes = {};
28231      if (dirty & /*value*/
28232      1) downloadlink_changes.href = /*value*/
28233      ctx2[0].url;
28234      if (dirty & /*value*/
28235      1) downloadlink_changes.download = /*value*/
28236      ctx2[0].orig_name || "image";
28237      if (dirty & /*$$scope, i18n*/
28238      524352) {
28239        downloadlink_changes.$$scope = { dirty, ctx: ctx2 };
28240      }
28241      downloadlink.$set(downloadlink_changes);
28242    },
28243    i(local) {
28244      if (current) return;
28245      transition_in(downloadlink.$$.fragment, local);
28246      current = true;
28247    },
28248    o(local) {
28249      transition_out(downloadlink.$$.fragment, local);
28250      current = false;
28251    },
28252    d(detaching) {
28253      destroy_component(downloadlink, detaching);
28254    }
28255  };
28256}
28257function create_default_slot_2$1(ctx) {
28258  let iconbutton;
28259  let current;
28260  iconbutton = new IconButton({
28261    props: {
28262      Icon: Download,
28263      label: (
28264        /*i18n*/
28265        ctx[6]("common.download")
28266      )
28267    }
28268  });
28269  return {
28270    c() {
28271      create_component(iconbutton.$$.fragment);
28272    },
28273    m(target, anchor) {
28274      mount_component(iconbutton, target, anchor);
28275      current = true;
28276    },
28277    p(ctx2, dirty) {
28278      const iconbutton_changes = {};
28279      if (dirty & /*i18n*/
28280      64) iconbutton_changes.label = /*i18n*/
28281      ctx2[6]("common.download");
28282      iconbutton.$set(iconbutton_changes);
28283    },
28284    i(local) {
28285      if (current) return;
28286      transition_in(iconbutton.$$.fragment, local);
28287      current = true;
28288    },
28289    o(local) {
28290      transition_out(iconbutton.$$.fragment, local);
28291      current = false;
28292    },
28293    d(detaching) {
28294      destroy_component(iconbutton, detaching);
28295    }
28296  };
28297}
28298function create_if_block_1$3(ctx) {
28299  let sharebutton;
28300  let current;
28301  sharebutton = new ShareButton({
28302    props: {
28303      i18n: (
28304        /*i18n*/
28305        ctx[6]
28306      ),
28307      formatter: (
28308        /*func*/
28309        ctx[13]
28310      ),
28311      value: (
28312        /*value*/
28313        ctx[0]
28314      )
28315    }
28316  });
28317  sharebutton.$on(
28318    "share",
28319    /*share_handler*/
28320    ctx[14]
28321  );
28322  sharebutton.$on(
28323    "error",
28324    /*error_handler*/
28325    ctx[15]
28326  );
28327  return {
28328    c() {
28329      create_component(sharebutton.$$.fragment);
28330    },
28331    m(target, anchor) {
28332      mount_component(sharebutton, target, anchor);
28333      current = true;
28334    },
28335    p(ctx2, dirty) {
28336      const sharebutton_changes = {};
28337      if (dirty & /*i18n*/
28338      64) sharebutton_changes.i18n = /*i18n*/
28339      ctx2[6];
28340      if (dirty & /*value*/
28341      1) sharebutton_changes.value = /*value*/
28342      ctx2[0];
28343      sharebutton.$set(sharebutton_changes);
28344    },
28345    i(local) {
28346      if (current) return;
28347      transition_in(sharebutton.$$.fragment, local);
28348      current = true;
28349    },
28350    o(local) {
28351      transition_out(sharebutton.$$.fragment, local);
28352      current = false;
28353    },
28354    d(detaching) {
28355      destroy_component(sharebutton, detaching);
28356    }
28357  };
28358}
28359function create_default_slot_1$2(ctx) {
28360  let t0;
28361  let t1;
28362  let if_block2_anchor;
28363  let current;
28364  let if_block0 = (
28365    /*show_fullscreen_button*/
28366    ctx[7] && create_if_block_3$2(ctx)
28367  );
28368  let if_block1 = (
28369    /*show_download_button*/
28370    ctx[3] && create_if_block_2$3(ctx)
28371  );
28372  let if_block2 = (
28373    /*show_share_button*/
28374    ctx[5] && create_if_block_1$3(ctx)
28375  );
28376  return {
28377    c() {
28378      if (if_block0) if_block0.c();
28379      t0 = space();
28380      if (if_block1) if_block1.c();
28381      t1 = space();
28382      if (if_block2) if_block2.c();
28383      if_block2_anchor = empty();
28384    },
28385    m(target, anchor) {
28386      if (if_block0) if_block0.m(target, anchor);
28387      insert(target, t0, anchor);
28388      if (if_block1) if_block1.m(target, anchor);
28389      insert(target, t1, anchor);
28390      if (if_block2) if_block2.m(target, anchor);
28391      insert(target, if_block2_anchor, anchor);
28392      current = true;
28393    },
28394    p(ctx2, dirty) {
28395      if (
28396        /*show_fullscreen_button*/
28397        ctx2[7]
28398      ) {
28399        if (if_block0) {
28400          if_block0.p(ctx2, dirty);
28401          if (dirty & /*show_fullscreen_button*/
28402          128) {
28403            transition_in(if_block0, 1);
28404          }
28405        } else {
28406          if_block0 = create_if_block_3$2(ctx2);
28407          if_block0.c();
28408          transition_in(if_block0, 1);
28409          if_block0.m(t0.parentNode, t0);
28410        }
28411      } else if (if_block0) {
28412        group_outros();
28413        transition_out(if_block0, 1, 1, () => {
28414          if_block0 = null;
28415        });
28416        check_outros();
28417      }
28418      if (
28419        /*show_download_button*/
28420        ctx2[3]
28421      ) {
28422        if (if_block1) {
28423          if_block1.p(ctx2, dirty);
28424          if (dirty & /*show_download_button*/
28425          8) {
28426            transition_in(if_block1, 1);
28427          }
28428        } else {
28429          if_block1 = create_if_block_2$3(ctx2);
28430          if_block1.c();
28431          transition_in(if_block1, 1);
28432          if_block1.m(t1.parentNode, t1);
28433        }
28434      } else if (if_block1) {
28435        group_outros();
28436        transition_out(if_block1, 1, 1, () => {
28437          if_block1 = null;
28438        });
28439        check_outros();
28440      }
28441      if (
28442        /*show_share_button*/
28443        ctx2[5]
28444      ) {
28445        if (if_block2) {
28446          if_block2.p(ctx2, dirty);
28447          if (dirty & /*show_share_button*/
28448          32) {
28449            transition_in(if_block2, 1);
28450          }
28451        } else {
28452          if_block2 = create_if_block_1$3(ctx2);
28453          if_block2.c();
28454          transition_in(if_block2, 1);
28455          if_block2.m(if_block2_anchor.parentNode, if_block2_anchor);
28456        }
28457      } else if (if_block2) {
28458        group_outros();
28459        transition_out(if_block2, 1, 1, () => {
28460          if_block2 = null;
28461        });
28462        check_outros();
28463      }
28464    },
28465    i(local) {
28466      if (current) return;
28467      transition_in(if_block0);
28468      transition_in(if_block1);
28469      transition_in(if_block2);
28470      current = true;
28471    },
28472    o(local) {
28473      transition_out(if_block0);
28474      transition_out(if_block1);
28475      transition_out(if_block2);
28476      current = false;
28477    },
28478    d(detaching) {
28479      if (detaching) {
28480        detach(t0);
28481        detach(t1);
28482        detach(if_block2_anchor);
28483      }
28484      if (if_block0) if_block0.d(detaching);
28485      if (if_block1) if_block1.d(detaching);
28486      if (if_block2) if_block2.d(detaching);
28487    }
28488  };
28489}
28490function create_default_slot$3(ctx) {
28491  let imageicon;
28492  let current;
28493  imageicon = new Image$1({});
28494  return {
28495    c() {
28496      create_component(imageicon.$$.fragment);
28497    },
28498    m(target, anchor) {
28499      mount_component(imageicon, target, anchor);
28500      current = true;
28501    },
28502    i(local) {
28503      if (current) return;
28504      transition_in(imageicon.$$.fragment, local);
28505      current = true;
28506    },
28507    o(local) {
28508      transition_out(imageicon.$$.fragment, local);
28509      current = false;
28510    },
28511    d(detaching) {
28512      destroy_component(imageicon, detaching);
28513    }
28514  };
28515}
28516function create_fragment$6(ctx) {
28517  let blocklabel;
28518  let t;
28519  let current_block_type_index;
28520  let if_block;
28521  let if_block_anchor;
28522  let current;
28523  blocklabel = new BlockLabel({
28524    props: {
28525      show_label: (
28526        /*show_label*/
28527        ctx[2]
28528      ),
28529      Icon: Image$1,
28530      label: !/*show_label*/
28531      ctx[2] ? "" : (
28532        /*label*/
28533        ctx[1] || /*i18n*/
28534        ctx[6]("image.image")
28535      )
28536    }
28537  });
28538  const if_block_creators = [create_if_block$3, create_else_block$2];
28539  const if_blocks = [];
28540  function select_block_type(ctx2, dirty) {
28541    if (
28542      /*value*/
28543      ctx2[0] === null || !/*value*/
28544      ctx2[0].url
28545    ) return 0;
28546    return 1;
28547  }
28548  current_block_type_index = select_block_type(ctx);
28549  if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
28550  return {
28551    c() {
28552      create_component(blocklabel.$$.fragment);
28553      t = space();
28554      if_block.c();
28555      if_block_anchor = empty();
28556    },
28557    m(target, anchor) {
28558      mount_component(blocklabel, target, anchor);
28559      insert(target, t, anchor);
28560      if_blocks[current_block_type_index].m(target, anchor);
28561      insert(target, if_block_anchor, anchor);
28562      current = true;
28563    },
28564    p(ctx2, [dirty]) {
28565      const blocklabel_changes = {};
28566      if (dirty & /*show_label*/
28567      4) blocklabel_changes.show_label = /*show_label*/
28568      ctx2[2];
28569      if (dirty & /*show_label, label, i18n*/
28570      70) blocklabel_changes.label = !/*show_label*/
28571      ctx2[2] ? "" : (
28572        /*label*/
28573        ctx2[1] || /*i18n*/
28574        ctx2[6]("image.image")
28575      );
28576      blocklabel.$set(blocklabel_changes);
28577      let previous_block_index = current_block_type_index;
28578      current_block_type_index = select_block_type(ctx2);
28579      if (current_block_type_index === previous_block_index) {
28580        if_blocks[current_block_type_index].p(ctx2, dirty);
28581      } else {
28582        group_outros();
28583        transition_out(if_blocks[previous_block_index], 1, 1, () => {
28584          if_blocks[previous_block_index] = null;
28585        });
28586        check_outros();
28587        if_block = if_blocks[current_block_type_index];
28588        if (!if_block) {
28589          if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
28590          if_block.c();
28591        } else {
28592          if_block.p(ctx2, dirty);
28593        }
28594        transition_in(if_block, 1);
28595        if_block.m(if_block_anchor.parentNode, if_block_anchor);
28596      }
28597    },
28598    i(local) {
28599      if (current) return;
28600      transition_in(blocklabel.$$.fragment, local);
28601      transition_in(if_block);
28602      current = true;
28603    },
28604    o(local) {
28605      transition_out(blocklabel.$$.fragment, local);
28606      transition_out(if_block);
28607      current = false;
28608    },
28609    d(detaching) {
28610      if (detaching) {
28611        detach(t);
28612        detach(if_block_anchor);
28613      }
28614      destroy_component(blocklabel, detaching);
28615      if_blocks[current_block_type_index].d(detaching);
28616    }
28617  };
28618}
28619function instance$6($$self, $$props, $$invalidate) {
28620  let { value } = $$props;
28621  let { label = void 0 } = $$props;
28622  let { show_label } = $$props;
28623  let { show_download_button = true } = $$props;
28624  let { selectable = false } = $$props;
28625  let { show_share_button = false } = $$props;
28626  let { i18n } = $$props;
28627  let { show_fullscreen_button = true } = $$props;
28628  let { display_icon_button_wrapper_top_corner = false } = $$props;
28629  let { fullscreen = false } = $$props;
28630  const dispatch2 = createEventDispatcher();
28631  const handle_click = (evt) => {
28632    let coordinates = get_coordinates_of_clicked_image(evt);
28633    if (coordinates) {
28634      dispatch2("select", { index: coordinates, value: null });
28635    }
28636  };
28637  let image_container;
28638  function fullscreen_handler(event) {
28639    bubble.call(this, $$self, event);
28640  }
28641  const func2 = async (value2) => {
28642    if (!value2) return "";
28643    let url = await uploadToHuggingFace(value2);
28644    return `<img src="${url}" />`;
28645  };
28646  function share_handler(event) {
28647    bubble.call(this, $$self, event);
28648  }
28649  function error_handler(event) {
28650    bubble.call(this, $$self, event);
28651  }
28652  function load_handler(event) {
28653    bubble.call(this, $$self, event);
28654  }
28655  function div1_binding($$value) {
28656    binding_callbacks[$$value ? "unshift" : "push"](() => {
28657      image_container = $$value;
28658      $$invalidate(10, image_container);
28659    });
28660  }
28661  $$self.$$set = ($$props2) => {
28662    if ("value" in $$props2) $$invalidate(0, value = $$props2.value);
28663    if ("label" in $$props2) $$invalidate(1, label = $$props2.label);
28664    if ("show_label" in $$props2) $$invalidate(2, show_label = $$props2.show_label);
28665    if ("show_download_button" in $$props2) $$invalidate(3, show_download_button = $$props2.show_download_button);
28666    if ("selectable" in $$props2) $$invalidate(4, selectable = $$props2.selectable);
28667    if ("show_share_button" in $$props2) $$invalidate(5, show_share_button = $$props2.show_share_button);
28668    if ("i18n" in $$props2) $$invalidate(6, i18n = $$props2.i18n);
28669    if ("show_fullscreen_button" in $$props2) $$invalidate(7, show_fullscreen_button = $$props2.show_fullscreen_button);
28670    if ("display_icon_button_wrapper_top_corner" in $$props2) $$invalidate(8, display_icon_button_wrapper_top_corner = $$props2.display_icon_button_wrapper_top_corner);
28671    if ("fullscreen" in $$props2) $$invalidate(9, fullscreen = $$props2.fullscreen);
28672  };
28673  return [
28674    value,
28675    label,
28676    show_label,
28677    show_download_button,
28678    selectable,
28679    show_share_button,
28680    i18n,
28681    show_fullscreen_button,
28682    display_icon_button_wrapper_top_corner,
28683    fullscreen,
28684    image_container,
28685    handle_click,
28686    fullscreen_handler,
28687    func2,
28688    share_handler,
28689    error_handler,
28690    load_handler,
28691    div1_binding
28692  ];
28693}
28694class ImagePreview extends SvelteComponent {
28695  constructor(options) {
28696    super();
28697    init(this, options, instance$6, create_fragment$6, safe_not_equal, {
28698      value: 0,
28699      label: 1,
28700      show_label: 2,
28701      show_download_button: 3,
28702      selectable: 4,
28703      show_share_button: 5,
28704      i18n: 6,
28705      show_fullscreen_button: 7,
28706      display_icon_button_wrapper_top_corner: 8,
28707      fullscreen: 9
28708    });
28709  }
28710}
28711function create_fragment$5(ctx) {
28712  let button;
28713  let div;
28714  let span;
28715  let webcam;
28716  let t0;
28717  let t1_value = "Click to Access Webcam";
28718  let t1;
28719  let current;
28720  let mounted;
28721  let dispose;
28722  webcam = new Webcam$1({});
28723  return {
28724    c() {
28725      button = element("button");
28726      div = element("div");
28727      span = element("span");
28728      create_component(webcam.$$.fragment);
28729      t0 = space();
28730      t1 = text(t1_value);
28731      attr(span, "class", "icon-wrap svelte-fjcd9c");
28732      attr(div, "class", "wrap svelte-fjcd9c");
28733      attr(button, "class", "svelte-fjcd9c");
28734      set_style(button, "height", `100%`);
28735    },
28736    m(target, anchor) {
28737      insert(target, button, anchor);
28738      append(button, div);
28739      append(div, span);
28740      mount_component(webcam, span, null);
28741      append(div, t0);
28742      append(div, t1);
28743      current = true;
28744      if (!mounted) {
28745        dispose = listen(
28746          button,
28747          "click",
28748          /*click_handler*/
28749          ctx[1]
28750        );
28751        mounted = true;
28752      }
28753    },
28754    p: noop,
28755    i(local) {
28756      if (current) return;
28757      transition_in(webcam.$$.fragment, local);
28758      current = true;
28759    },
28760    o(local) {
28761      transition_out(webcam.$$.fragment, local);
28762      current = false;
28763    },
28764    d(detaching) {
28765      if (detaching) {
28766        detach(button);
28767      }
28768      destroy_component(webcam);
28769      mounted = false;
28770      dispose();
28771    }
28772  };
28773}
28774function instance$5($$self) {
28775  const dispatch2 = createEventDispatcher();
28776  const click_handler = () => dispatch2("click");
28777  return [dispatch2, click_handler];
28778}
28779class WebcamPermissions extends SvelteComponent {
28780  constructor(options) {
28781    super();
28782    init(this, options, instance$5, create_fragment$5, safe_not_equal, {});
28783  }
28784}
28785function get_devices() {
28786  return navigator.mediaDevices.enumerateDevices();
28787}
28788function set_local_stream(local_stream, video_source) {
28789  video_source.srcObject = local_stream;
28790  video_source.muted = true;
28791  video_source.play();
28792}
28793async function get_video_stream(include_audio, video_source, webcam_constraints, device_id) {
28794  const constraints = {
28795    video: device_id ? { deviceId: { exact: device_id }, ...webcam_constraints == null ? void 0 : webcam_constraints.video } : (webcam_constraints == null ? void 0 : webcam_constraints.video) || {
28796      width: { ideal: 1920 },
28797      height: { ideal: 1440 }
28798    },
28799    audio: include_audio && ((webcam_constraints == null ? void 0 : webcam_constraints.audio) ?? true)
28800    // Defaults to true if not specified
28801  };
28802  return navigator.mediaDevices.getUserMedia(constraints).then((local_stream) => {
28803    set_local_stream(local_stream, video_source);
28804    return local_stream;
28805  });
28806}
28807function set_available_devices(devices) {
28808  const cameras = devices.filter(
28809    (device) => device.kind === "videoinput"
28810  );
28811  return cameras;
28812}
28813function get_each_context(ctx, list2, i) {
28814  const child_ctx = ctx.slice();
28815  child_ctx[39] = list2[i];
28816  return child_ctx;
28817}
28818function create_else_block$1(ctx) {
28819  let div;
28820  let button;
28821  let current_block_type_index;
28822  let if_block0;
28823  let button_aria_label_value;
28824  let t0;
28825  let t1;
28826  let if_block2_anchor;
28827  let current;
28828  let mounted;
28829  let dispose;
28830  const if_block_creators = [create_if_block_4$1, create_else_block_3];
28831  const if_blocks = [];
28832  function select_block_type_1(ctx2, dirty) {
28833    if (
28834      /*mode*/
28835      ctx2[2] === "video" || /*streaming*/
28836      ctx2[1]
28837    ) return 0;
28838    return 1;
28839  }
28840  current_block_type_index = select_block_type_1(ctx);
28841  if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
28842  let if_block1 = !/*recording*/
28843  ctx[11] && create_if_block_3$1(ctx);
28844  let if_block2 = (
28845    /*options_open*/
28846    ctx[13] && /*selected_device*/
28847    ctx[8] && create_if_block_1$2(ctx)
28848  );
28849  return {
28850    c() {
28851      div = element("div");
28852      button = element("button");
28853      if_block0.c();
28854      t0 = space();
28855      if (if_block1) if_block1.c();
28856      t1 = space();
28857      if (if_block2) if_block2.c();
28858      if_block2_anchor = empty();
28859      attr(button, "aria-label", button_aria_label_value = /*mode*/
28860      ctx[2] === "image" ? "capture photo" : "start recording");
28861      attr(button, "class", "svelte-1tdan5a");
28862      attr(div, "class", "button-wrap svelte-1tdan5a");
28863    },
28864    m(target, anchor) {
28865      insert(target, div, anchor);
28866      append(div, button);
28867      if_blocks[current_block_type_index].m(button, null);
28868      append(div, t0);
28869      if (if_block1) if_block1.m(div, null);
28870      insert(target, t1, anchor);
28871      if (if_block2) if_block2.m(target, anchor);
28872      insert(target, if_block2_anchor, anchor);
28873      current = true;
28874      if (!mounted) {
28875        dispose = listen(
28876          button,
28877          "click",
28878          /*click_handler_1*/
28879          ctx[28]
28880        );
28881        mounted = true;
28882      }
28883    },
28884    p(ctx2, dirty) {
28885      let previous_block_index = current_block_type_index;
28886      current_block_type_index = select_block_type_1(ctx2);
28887      if (current_block_type_index === previous_block_index) {
28888        if_blocks[current_block_type_index].p(ctx2, dirty);
28889      } else {
28890        group_outros();
28891        transition_out(if_blocks[previous_block_index], 1, 1, () => {
28892          if_blocks[previous_block_index] = null;
28893        });
28894        check_outros();
28895        if_block0 = if_blocks[current_block_type_index];
28896        if (!if_block0) {
28897          if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
28898          if_block0.c();
28899        } else {
28900          if_block0.p(ctx2, dirty);
28901        }
28902        transition_in(if_block0, 1);
28903        if_block0.m(button, null);
28904      }
28905      if (!current || dirty[0] & /*mode*/
28906      4 && button_aria_label_value !== (button_aria_label_value = /*mode*/
28907      ctx2[2] === "image" ? "capture photo" : "start recording")) {
28908        attr(button, "aria-label", button_aria_label_value);
28909      }
28910      if (!/*recording*/
28911      ctx2[11]) {
28912        if (if_block1) {
28913          if_block1.p(ctx2, dirty);
28914          if (dirty[0] & /*recording*/
28915          2048) {
28916            transition_in(if_block1, 1);
28917          }
28918        } else {
28919          if_block1 = create_if_block_3$1(ctx2);
28920          if_block1.c();
28921          transition_in(if_block1, 1);
28922          if_block1.m(div, null);
28923        }
28924      } else if (if_block1) {
28925        group_outros();
28926        transition_out(if_block1, 1, 1, () => {
28927          if_block1 = null;
28928        });
28929        check_outros();
28930      }
28931      if (
28932        /*options_open*/
28933        ctx2[13] && /*selected_device*/
28934        ctx2[8]
28935      ) {
28936        if (if_block2) {
28937          if_block2.p(ctx2, dirty);
28938          if (dirty[0] & /*options_open, selected_device*/
28939          8448) {
28940            transition_in(if_block2, 1);
28941          }
28942        } else {
28943          if_block2 = create_if_block_1$2(ctx2);
28944          if_block2.c();
28945          transition_in(if_block2, 1);
28946          if_block2.m(if_block2_anchor.parentNode, if_block2_anchor);
28947        }
28948      } else if (if_block2) {
28949        group_outros();
28950        transition_out(if_block2, 1, 1, () => {
28951          if_block2 = null;
28952        });
28953        check_outros();
28954      }
28955    },
28956    i(local) {
28957      if (current) return;
28958      transition_in(if_block0);
28959      transition_in(if_block1);
28960      transition_in(if_block2);
28961      current = true;
28962    },
28963    o(local) {
28964      transition_out(if_block0);
28965      transition_out(if_block1);
28966      transition_out(if_block2);
28967      current = false;
28968    },
28969    d(detaching) {
28970      if (detaching) {
28971        detach(div);
28972        detach(t1);
28973        detach(if_block2_anchor);
28974      }
28975      if_blocks[current_block_type_index].d();
28976      if (if_block1) if_block1.d();
28977      if (if_block2) if_block2.d(detaching);
28978      mounted = false;
28979      dispose();
28980    }
28981  };
28982}
28983function create_if_block$2(ctx) {
28984  let div;
28985  let webcampermissions;
28986  let div_intro;
28987  let current;
28988  webcampermissions = new WebcamPermissions({});
28989  webcampermissions.$on(
28990    "click",
28991    /*click_handler*/
28992    ctx[27]
28993  );
28994  return {
28995    c() {
28996      div = element("div");
28997      create_component(webcampermissions.$$.fragment);
28998      attr(div, "title", "grant webcam access");
28999      set_style(div, "height", "100%");
29000    },
29001    m(target, anchor) {
29002      insert(target, div, anchor);
29003      mount_component(webcampermissions, div, null);
29004      current = true;
29005    },
29006    p: noop,
29007    i(local) {
29008      if (current) return;
29009      transition_in(webcampermissions.$$.fragment, local);
29010      if (local) {
29011        if (!div_intro) {
29012          add_render_callback(() => {
29013            div_intro = create_in_transition(div, fade, { delay: 100, duration: 200 });
29014            div_intro.start();
29015          });
29016        }
29017      }
29018      current = true;
29019    },
29020    o(local) {
29021      transition_out(webcampermissions.$$.fragment, local);
29022      current = false;
29023    },
29024    d(detaching) {
29025      if (detaching) {
29026        detach(div);
29027      }
29028      destroy_component(webcampermissions);
29029    }
29030  };
29031}
29032function create_else_block_3(ctx) {
29033  let div;
29034  let camera;
29035  let current;
29036  camera = new Camera({});
29037  return {
29038    c() {
29039      div = element("div");
29040      create_component(camera.$$.fragment);
29041      attr(div, "class", "icon svelte-1tdan5a");
29042      attr(div, "title", "capture photo");
29043    },
29044    m(target, anchor) {
29045      insert(target, div, anchor);
29046      mount_component(camera, div, null);
29047      current = true;
29048    },
29049    p: noop,
29050    i(local) {
29051      if (current) return;
29052      transition_in(camera.$$.fragment, local);
29053      current = true;
29054    },
29055    o(local) {
29056      transition_out(camera.$$.fragment, local);
29057      current = false;
29058    },
29059    d(detaching) {
29060      if (detaching) {
29061        detach(div);
29062      }
29063      destroy_component(camera);
29064    }
29065  };
29066}
29067function create_if_block_4$1(ctx) {
29068  let current_block_type_index;
29069  let if_block;
29070  let if_block_anchor;
29071  let current;
29072  const if_block_creators = [create_if_block_5$1, create_if_block_6$1, create_else_block_2];
29073  const if_blocks = [];
29074  function select_block_type_2(ctx2, dirty) {
29075    if (
29076      /*streaming*/
29077      ctx2[1] && /*stream_state*/
29078      ctx2[10] === "waiting"
29079    ) return 0;
29080    if (
29081      /*streaming*/
29082      ctx2[1] && /*stream_state*/
29083      ctx2[10] === "open" || !/*streaming*/
29084      ctx2[1] && /*recording*/
29085      ctx2[11]
29086    ) return 1;
29087    return 2;
29088  }
29089  current_block_type_index = select_block_type_2(ctx);
29090  if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
29091  return {
29092    c() {
29093      if_block.c();
29094      if_block_anchor = empty();
29095    },
29096    m(target, anchor) {
29097      if_blocks[current_block_type_index].m(target, anchor);
29098      insert(target, if_block_anchor, anchor);
29099      current = true;
29100    },
29101    p(ctx2, dirty) {
29102      let previous_block_index = current_block_type_index;
29103      current_block_type_index = select_block_type_2(ctx2);
29104      if (current_block_type_index === previous_block_index) {
29105        if_blocks[current_block_type_index].p(ctx2, dirty);
29106      } else {
29107        group_outros();
29108        transition_out(if_blocks[previous_block_index], 1, 1, () => {
29109          if_blocks[previous_block_index] = null;
29110        });
29111        check_outros();
29112        if_block = if_blocks[current_block_type_index];
29113        if (!if_block) {
29114          if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
29115          if_block.c();
29116        } else {
29117          if_block.p(ctx2, dirty);
29118        }
29119        transition_in(if_block, 1);
29120        if_block.m(if_block_anchor.parentNode, if_block_anchor);
29121      }
29122    },
29123    i(local) {
29124      if (current) return;
29125      transition_in(if_block);
29126      current = true;
29127    },
29128    o(local) {
29129      transition_out(if_block);
29130      current = false;
29131    },
29132    d(detaching) {
29133      if (detaching) {
29134        detach(if_block_anchor);
29135      }
29136      if_blocks[current_block_type_index].d(detaching);
29137    }
29138  };
29139}
29140function create_else_block_2(ctx) {
29141  let div1;
29142  let div0;
29143  let circle;
29144  let t0;
29145  let t1_value = (
29146    /*i18n*/
29147    ctx[4]("audio.record") + ""
29148  );
29149  let t1;
29150  let current;
29151  circle = new Circle({});
29152  return {
29153    c() {
29154      div1 = element("div");
29155      div0 = element("div");
29156      create_component(circle.$$.fragment);
29157      t0 = space();
29158      t1 = text(t1_value);
29159      attr(div0, "class", "icon color-primary svelte-1tdan5a");
29160      attr(div0, "title", "start recording");
29161      attr(div1, "class", "icon-with-text svelte-1tdan5a");
29162    },
29163    m(target, anchor) {
29164      insert(target, div1, anchor);
29165      append(div1, div0);
29166      mount_component(circle, div0, null);
29167      append(div1, t0);
29168      append(div1, t1);
29169      current = true;
29170    },
29171    p(ctx2, dirty) {
29172      if ((!current || dirty[0] & /*i18n*/
29173      16) && t1_value !== (t1_value = /*i18n*/
29174      ctx2[4]("audio.record") + "")) set_data(t1, t1_value);
29175    },
29176    i(local) {
29177      if (current) return;
29178      transition_in(circle.$$.fragment, local);
29179      current = true;
29180    },
29181    o(local) {
29182      transition_out(circle.$$.fragment, local);
29183      current = false;
29184    },
29185    d(detaching) {
29186      if (detaching) {
29187        detach(div1);
29188      }
29189      destroy_component(circle);
29190    }
29191  };
29192}
29193function create_if_block_6$1(ctx) {
29194  let div1;
29195  let div0;
29196  let square;
29197  let t0;
29198  let t1_value = (
29199    /*i18n*/
29200    ctx[4]("audio.stop") + ""
29201  );
29202  let t1;
29203  let current;
29204  square = new Square({});
29205  return {
29206    c() {
29207      div1 = element("div");
29208      div0 = element("div");
29209      create_component(square.$$.fragment);
29210      t0 = space();
29211      t1 = text(t1_value);
29212      attr(div0, "class", "icon color-primary svelte-1tdan5a");
29213      attr(div0, "title", "stop recording");
29214      attr(div1, "class", "icon-with-text svelte-1tdan5a");
29215    },
29216    m(target, anchor) {
29217      insert(target, div1, anchor);
29218      append(div1, div0);
29219      mount_component(square, div0, null);
29220      append(div1, t0);
29221      append(div1, t1);
29222      current = true;
29223    },
29224    p(ctx2, dirty) {
29225      if ((!current || dirty[0] & /*i18n*/
29226      16) && t1_value !== (t1_value = /*i18n*/
29227      ctx2[4]("audio.stop") + "")) set_data(t1, t1_value);
29228    },
29229    i(local) {
29230      if (current) return;
29231      transition_in(square.$$.fragment, local);
29232      current = true;
29233    },
29234    o(local) {
29235      transition_out(square.$$.fragment, local);
29236      current = false;
29237    },
29238    d(detaching) {
29239      if (detaching) {
29240        detach(div1);
29241      }
29242      destroy_component(square);
29243    }
29244  };
29245}
29246function create_if_block_5$1(ctx) {
29247  let div1;
29248  let div0;
29249  let spinner;
29250  let t0;
29251  let t1_value = (
29252    /*i18n*/
29253    ctx[4]("audio.waiting") + ""
29254  );
29255  let t1;
29256  let current;
29257  spinner = new Spinner({});
29258  return {
29259    c() {
29260      div1 = element("div");
29261      div0 = element("div");
29262      create_component(spinner.$$.fragment);
29263      t0 = space();
29264      t1 = text(t1_value);
29265      attr(div0, "class", "icon color-primary svelte-1tdan5a");
29266      attr(div0, "title", "spinner");
29267      attr(div1, "class", "icon-with-text svelte-1tdan5a");
29268      set_style(div1, "width", "var(--size-24)");
29269    },
29270    m(target, anchor) {
29271      insert(target, div1, anchor);
29272      append(div1, div0);
29273      mount_component(spinner, div0, null);
29274      append(div1, t0);
29275      append(div1, t1);
29276      current = true;
29277    },
29278    p(ctx2, dirty) {
29279      if ((!current || dirty[0] & /*i18n*/
29280      16) && t1_value !== (t1_value = /*i18n*/
29281      ctx2[4]("audio.waiting") + "")) set_data(t1, t1_value);
29282    },
29283    i(local) {
29284      if (current) return;
29285      transition_in(spinner.$$.fragment, local);
29286      current = true;
29287    },
29288    o(local) {
29289      transition_out(spinner.$$.fragment, local);
29290      current = false;
29291    },
29292    d(detaching) {
29293      if (detaching) {
29294        detach(div1);
29295      }
29296      destroy_component(spinner);
29297    }
29298  };
29299}
29300function create_if_block_3$1(ctx) {
29301  let button;
29302  let dropdownarrow;
29303  let current;
29304  let mounted;
29305  let dispose;
29306  dropdownarrow = new DropdownArrow({});
29307  return {
29308    c() {
29309      button = element("button");
29310      create_component(dropdownarrow.$$.fragment);
29311      attr(button, "class", "icon svelte-1tdan5a");
29312      attr(button, "aria-label", "select input source");
29313    },
29314    m(target, anchor) {
29315      insert(target, button, anchor);
29316      mount_component(dropdownarrow, button, null);
29317      current = true;
29318      if (!mounted) {
29319        dispose = listen(
29320          button,
29321          "click",
29322          /*click_handler_2*/
29323          ctx[29]
29324        );
29325        mounted = true;
29326      }
29327    },
29328    p: noop,
29329    i(local) {
29330      if (current) return;
29331      transition_in(dropdownarrow.$$.fragment, local);
29332      current = true;
29333    },
29334    o(local) {
29335      transition_out(dropdownarrow.$$.fragment, local);
29336      current = false;
29337    },
29338    d(detaching) {
29339      if (detaching) {
29340        detach(button);
29341      }
29342      destroy_component(dropdownarrow);
29343      mounted = false;
29344      dispose();
29345    }
29346  };
29347}
29348function create_if_block_1$2(ctx) {
29349  let select;
29350  let button;
29351  let dropdownarrow;
29352  let t;
29353  let current;
29354  let mounted;
29355  let dispose;
29356  dropdownarrow = new DropdownArrow({});
29357  function select_block_type_3(ctx2, dirty) {
29358    if (
29359      /*available_video_devices*/
29360      ctx2[7].length === 0
29361    ) return create_if_block_2$2;
29362    return create_else_block_1$1;
29363  }
29364  let current_block_type = select_block_type_3(ctx);
29365  let if_block = current_block_type(ctx);
29366  return {
29367    c() {
29368      select = element("select");
29369      button = element("button");
29370      create_component(dropdownarrow.$$.fragment);
29371      t = space();
29372      if_block.c();
29373      attr(button, "class", "inset-icon svelte-1tdan5a");
29374      attr(select, "class", "select-wrap svelte-1tdan5a");
29375      attr(select, "aria-label", "select source");
29376    },
29377    m(target, anchor) {
29378      insert(target, select, anchor);
29379      append(select, button);
29380      mount_component(dropdownarrow, button, null);
29381      append(button, t);
29382      if_block.m(select, null);
29383      current = true;
29384      if (!mounted) {
29385        dispose = [
29386          listen(button, "click", stop_propagation(
29387            /*click_handler_3*/
29388            ctx[30]
29389          )),
29390          action_destroyer(click_outside.call(
29391            null,
29392            select,
29393            /*handle_click_outside*/
29394            ctx[17]
29395          )),
29396          listen(
29397            select,
29398            "change",
29399            /*handle_device_change*/
29400            ctx[14]
29401          )
29402        ];
29403        mounted = true;
29404      }
29405    },
29406    p(ctx2, dirty) {
29407      if (current_block_type === (current_block_type = select_block_type_3(ctx2)) && if_block) {
29408        if_block.p(ctx2, dirty);
29409      } else {
29410        if_block.d(1);
29411        if_block = current_block_type(ctx2);
29412        if (if_block) {
29413          if_block.c();
29414          if_block.m(select, null);
29415        }
29416      }
29417    },
29418    i(local) {
29419      if (current) return;
29420      transition_in(dropdownarrow.$$.fragment, local);
29421      current = true;
29422    },
29423    o(local) {
29424      transition_out(dropdownarrow.$$.fragment, local);
29425      current = false;
29426    },
29427    d(detaching) {
29428      if (detaching) {
29429        detach(select);
29430      }
29431      destroy_component(dropdownarrow);
29432      if_block.d();
29433      mounted = false;
29434      run_all(dispose);
29435    }
29436  };
29437}
29438function create_else_block_1$1(ctx) {
29439  let each_1_anchor;
29440  let each_value = ensure_array_like(
29441    /*available_video_devices*/
29442    ctx[7]
29443  );
29444  let each_blocks = [];
29445  for (let i = 0; i < each_value.length; i += 1) {
29446    each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
29447  }
29448  return {
29449    c() {
29450      for (let i = 0; i < each_blocks.length; i += 1) {
29451        each_blocks[i].c();
29452      }
29453      each_1_anchor = empty();
29454    },
29455    m(target, anchor) {
29456      for (let i = 0; i < each_blocks.length; i += 1) {
29457        if (each_blocks[i]) {
29458          each_blocks[i].m(target, anchor);
29459        }
29460      }
29461      insert(target, each_1_anchor, anchor);
29462    },
29463    p(ctx2, dirty) {
29464      if (dirty[0] & /*available_video_devices, selected_device*/
29465      384) {
29466        each_value = ensure_array_like(
29467          /*available_video_devices*/
29468          ctx2[7]
29469        );
29470        let i;
29471        for (i = 0; i < each_value.length; i += 1) {
29472          const child_ctx = get_each_context(ctx2, each_value, i);
29473          if (each_blocks[i]) {
29474            each_blocks[i].p(child_ctx, dirty);
29475          } else {
29476            each_blocks[i] = create_each_block(child_ctx);
29477            each_blocks[i].c();
29478            each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
29479          }
29480        }
29481        for (; i < each_blocks.length; i += 1) {
29482          each_blocks[i].d(1);
29483        }
29484        each_blocks.length = each_value.length;
29485      }
29486    },
29487    d(detaching) {
29488      if (detaching) {
29489        detach(each_1_anchor);
29490      }
29491      destroy_each(each_blocks, detaching);
29492    }
29493  };
29494}
29495function create_if_block_2$2(ctx) {
29496  let option;
29497  let t_value = (
29498    /*i18n*/
29499    ctx[4]("common.no_devices") + ""
29500  );
29501  let t;
29502  return {
29503    c() {
29504      option = element("option");
29505      t = text(t_value);
29506      option.__value = "";
29507      set_input_value(option, option.__value);
29508      attr(option, "class", "svelte-1tdan5a");
29509    },
29510    m(target, anchor) {
29511      insert(target, option, anchor);
29512      append(option, t);
29513    },
29514    p(ctx2, dirty) {
29515      if (dirty[0] & /*i18n*/
29516      16 && t_value !== (t_value = /*i18n*/
29517      ctx2[4]("common.no_devices") + "")) set_data(t, t_value);
29518    },
29519    d(detaching) {
29520      if (detaching) {
29521        detach(option);
29522      }
29523    }
29524  };
29525}
29526function create_each_block(ctx) {
29527  let option;
29528  let t0_value = (
29529    /*device*/
29530    ctx[39].label + ""
29531  );
29532  let t0;
29533  let t1;
29534  let option_value_value;
29535  let option_selected_value;
29536  return {
29537    c() {
29538      option = element("option");
29539      t0 = text(t0_value);
29540      t1 = space();
29541      option.__value = option_value_value = /*device*/
29542      ctx[39].deviceId;
29543      set_input_value(option, option.__value);
29544      option.selected = option_selected_value = /*selected_device*/
29545      ctx[8].deviceId === /*device*/
29546      ctx[39].deviceId;
29547      attr(option, "class", "svelte-1tdan5a");
29548    },
29549    m(target, anchor) {
29550      insert(target, option, anchor);
29551      append(option, t0);
29552      append(option, t1);
29553    },
29554    p(ctx2, dirty) {
29555      if (dirty[0] & /*available_video_devices*/
29556      128 && t0_value !== (t0_value = /*device*/
29557      ctx2[39].label + "")) set_data(t0, t0_value);
29558      if (dirty[0] & /*available_video_devices*/
29559      128 && option_value_value !== (option_value_value = /*device*/
29560      ctx2[39].deviceId)) {
29561        option.__value = option_value_value;
29562        set_input_value(option, option.__value);
29563      }
29564      if (dirty[0] & /*selected_device, available_video_devices*/
29565      384 && option_selected_value !== (option_selected_value = /*selected_device*/
29566      ctx2[8].deviceId === /*device*/
29567      ctx2[39].deviceId)) {
29568        option.selected = option_selected_value;
29569      }
29570    },
29571    d(detaching) {
29572      if (detaching) {
29573        detach(option);
29574      }
29575    }
29576  };
29577}
29578function create_fragment$4(ctx) {
29579  let div;
29580  let streamingbar;
29581  let t0;
29582  let video;
29583  let t1;
29584  let img;
29585  let img_src_value;
29586  let t2;
29587  let current_block_type_index;
29588  let if_block;
29589  let current;
29590  streamingbar = new StreamingBar({
29591    props: { time_limit: (
29592      /*time_limit*/
29593      ctx[9]
29594    ) }
29595  });
29596  const if_block_creators = [create_if_block$2, create_else_block$1];
29597  const if_blocks = [];
29598  function select_block_type(ctx2, dirty) {
29599    if (!/*webcam_accessed*/
29600    ctx2[12]) return 0;
29601    return 1;
29602  }
29603  current_block_type_index = select_block_type(ctx);
29604  if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
29605  return {
29606    c() {
29607      var _a;
29608      div = element("div");
29609      create_component(streamingbar.$$.fragment);
29610      t0 = space();
29611      video = element("video");
29612      t1 = space();
29613      img = element("img");
29614      t2 = space();
29615      if_block.c();
29616      attr(video, "class", "svelte-1tdan5a");
29617      toggle_class(
29618        video,
29619        "flip",
29620        /*mirror_webcam*/
29621        ctx[3]
29622      );
29623      toggle_class(video, "hide", !/*webcam_accessed*/
29624      ctx[12] || /*webcam_accessed*/
29625      ctx[12] && !!/*value*/
29626      ctx[0]);
29627      if (!src_url_equal(img.src, img_src_value = /*value*/
29628      (_a = ctx[0]) == null ? void 0 : _a.url)) attr(img, "src", img_src_value);
29629      attr(img, "class", "svelte-1tdan5a");
29630      toggle_class(img, "hide", !/*webcam_accessed*/
29631      ctx[12] || /*webcam_accessed*/
29632      ctx[12] && !/*value*/
29633      ctx[0]);
29634      attr(div, "class", "wrap svelte-1tdan5a");
29635    },
29636    m(target, anchor) {
29637      insert(target, div, anchor);
29638      mount_component(streamingbar, div, null);
29639      append(div, t0);
29640      append(div, video);
29641      ctx[26](video);
29642      append(div, t1);
29643      append(div, img);
29644      append(div, t2);
29645      if_blocks[current_block_type_index].m(div, null);
29646      current = true;
29647    },
29648    p(ctx2, dirty) {
29649      var _a;
29650      const streamingbar_changes = {};
29651      if (dirty[0] & /*time_limit*/
29652      512) streamingbar_changes.time_limit = /*time_limit*/
29653      ctx2[9];
29654      streamingbar.$set(streamingbar_changes);
29655      if (!current || dirty[0] & /*mirror_webcam*/
29656      8) {
29657        toggle_class(
29658          video,
29659          "flip",
29660          /*mirror_webcam*/
29661          ctx2[3]
29662        );
29663      }
29664      if (!current || dirty[0] & /*webcam_accessed, value*/
29665      4097) {
29666        toggle_class(video, "hide", !/*webcam_accessed*/
29667        ctx2[12] || /*webcam_accessed*/
29668        ctx2[12] && !!/*value*/
29669        ctx2[0]);
29670      }
29671      if (!current || dirty[0] & /*value*/
29672      1 && !src_url_equal(img.src, img_src_value = /*value*/
29673      (_a = ctx2[0]) == null ? void 0 : _a.url)) {
29674        attr(img, "src", img_src_value);
29675      }
29676      if (!current || dirty[0] & /*webcam_accessed, value*/
29677      4097) {
29678        toggle_class(img, "hide", !/*webcam_accessed*/
29679        ctx2[12] || /*webcam_accessed*/
29680        ctx2[12] && !/*value*/
29681        ctx2[0]);
29682      }
29683      let previous_block_index = current_block_type_index;
29684      current_block_type_index = select_block_type(ctx2);
29685      if (current_block_type_index === previous_block_index) {
29686        if_blocks[current_block_type_index].p(ctx2, dirty);
29687      } else {
29688        group_outros();
29689        transition_out(if_blocks[previous_block_index], 1, 1, () => {
29690          if_blocks[previous_block_index] = null;
29691        });
29692        check_outros();
29693        if_block = if_blocks[current_block_type_index];
29694        if (!if_block) {
29695          if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
29696          if_block.c();
29697        } else {
29698          if_block.p(ctx2, dirty);
29699        }
29700        transition_in(if_block, 1);
29701        if_block.m(div, null);
29702      }
29703    },
29704    i(local) {
29705      if (current) return;
29706      transition_in(streamingbar.$$.fragment, local);
29707      transition_in(if_block);
29708      current = true;
29709    },
29710    o(local) {
29711      transition_out(streamingbar.$$.fragment, local);
29712      transition_out(if_block);
29713      current = false;
29714    },
29715    d(detaching) {
29716      if (detaching) {
29717        detach(div);
29718      }
29719      destroy_component(streamingbar);
29720      ctx[26](null);
29721      if_blocks[current_block_type_index].d();
29722    }
29723  };
29724}
29725function click_outside(node, cb) {
29726  const handle_click = (event) => {
29727    if (node && !node.contains(event.target) && !event.defaultPrevented) {
29728      cb(event);
29729    }
29730  };
29731  document.addEventListener("click", handle_click, true);
29732  return {
29733    destroy() {
29734      document.removeEventListener("click", handle_click, true);
29735    }
29736  };
29737}
29738function instance$4($$self, $$props, $$invalidate) {
29739  let video_source;
29740  let available_video_devices = [];
29741  let selected_device = null;
29742  let time_limit = null;
29743  let stream_state = "closed";
29744  const modify_stream = (state) => {
29745    if (state === "closed") {
29746      $$invalidate(9, time_limit = null);
29747      $$invalidate(10, stream_state = "closed");
29748      $$invalidate(0, value = null);
29749    } else if (state === "waiting") {
29750      $$invalidate(10, stream_state = "waiting");
29751    } else {
29752      $$invalidate(10, stream_state = "open");
29753    }
29754  };
29755  const set_time_limit = (time) => {
29756    if (recording) $$invalidate(9, time_limit = time);
29757  };
29758  let canvas;
29759  let { streaming = false } = $$props;
29760  let { pending = false } = $$props;
29761  let { root = "" } = $$props;
29762  let { stream_every = 1 } = $$props;
29763  let { mode = "image" } = $$props;
29764  let { mirror_webcam } = $$props;
29765  let { include_audio } = $$props;
29766  let { webcam_constraints = null } = $$props;
29767  let { i18n } = $$props;
29768  let { upload } = $$props;
29769  let { value = null } = $$props;
29770  const dispatch2 = createEventDispatcher();
29771  onMount(() => {
29772    canvas = document.createElement("canvas");
29773    if (streaming && mode === "image") {
29774      window.setInterval(
29775        () => {
29776          if (video_source && !pending) {
29777            take_picture();
29778          }
29779        },
29780        stream_every * 1e3
29781      );
29782    }
29783  });
29784  const handle_device_change = async (event) => {
29785    const target = event.target;
29786    const device_id = target.value;
29787    await get_video_stream(include_audio, video_source, webcam_constraints, device_id).then(async (local_stream) => {
29788      stream = local_stream;
29789      $$invalidate(8, selected_device = available_video_devices.find((device) => device.deviceId === device_id) || null);
29790      $$invalidate(13, options_open = false);
29791    });
29792  };
29793  async function access_webcam() {
29794    try {
29795      get_video_stream(include_audio, video_source, webcam_constraints).then(async (local_stream) => {
29796        $$invalidate(12, webcam_accessed = true);
29797        $$invalidate(7, available_video_devices = await get_devices());
29798        stream = local_stream;
29799      }).then(() => set_available_devices(available_video_devices)).then((devices) => {
29800        $$invalidate(7, available_video_devices = devices);
29801        const used_devices = stream.getTracks().map((track) => {
29802          var _a;
29803          return (_a = track.getSettings()) == null ? void 0 : _a.deviceId;
29804        })[0];
29805        $$invalidate(8, selected_device = used_devices ? devices.find((device) => device.deviceId === used_devices) || available_video_devices[0] : available_video_devices[0]);
29806      });
29807      if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) {
29808        dispatch2("error", i18n("image.no_webcam_support"));
29809      }
29810    } catch (err) {
29811      if (err instanceof DOMException && err.name == "NotAllowedError") {
29812        dispatch2("error", i18n("image.allow_webcam_access"));
29813      } else {
29814        throw err;
29815      }
29816    }
29817  }
29818  function take_picture() {
29819    var context = canvas.getContext("2d");
29820    if ((!streaming || streaming && recording) && video_source.videoWidth && video_source.videoHeight) {
29821      canvas.width = video_source.videoWidth;
29822      canvas.height = video_source.videoHeight;
29823      context.drawImage(video_source, 0, 0, video_source.videoWidth, video_source.videoHeight);
29824      if (mirror_webcam) {
29825        context.scale(-1, 1);
29826        context.drawImage(video_source, -video_source.videoWidth, 0);
29827      }
29828      if (streaming && (!recording || stream_state === "waiting")) {
29829        return;
29830      }
29831      if (streaming) {
29832        const image_data = canvas.toDataURL("image/jpeg");
29833        dispatch2("stream", image_data);
29834        return;
29835      }
29836      canvas.toBlob(
29837        (blob) => {
29838          dispatch2(streaming ? "stream" : "capture", blob);
29839        },
29840        `image/${streaming ? "jpeg" : "png"}`,
29841        0.8
29842      );
29843    }
29844  }
29845  let recording = false;
29846  let recorded_blobs = [];
29847  let stream;
29848  let mimeType;
29849  let media_recorder;
29850  function take_recording() {
29851    if (recording) {
29852      media_recorder.stop();
29853      let video_blob = new Blob(recorded_blobs, { type: mimeType });
29854      let ReaderObj = new FileReader();
29855      ReaderObj.onload = async function(e) {
29856        var _a;
29857        if (e.target) {
29858          let _video_blob = new File([video_blob], "sample." + mimeType.substring(6));
29859          const val = await prepare_files([_video_blob]);
29860          let val_ = (_a = await upload(val, root)) == null ? void 0 : _a.filter(Boolean)[0];
29861          dispatch2("capture", val_);
29862          dispatch2("stop_recording");
29863        }
29864      };
29865      ReaderObj.readAsDataURL(video_blob);
29866    } else if (typeof MediaRecorder !== "undefined") {
29867      dispatch2("start_recording");
29868      recorded_blobs = [];
29869      let validMimeTypes = ["video/webm", "video/mp4"];
29870      for (let validMimeType of validMimeTypes) {
29871        if (MediaRecorder.isTypeSupported(validMimeType)) {
29872          mimeType = validMimeType;
29873          break;
29874        }
29875      }
29876      if (mimeType === null) {
29877        console.error("No supported MediaRecorder mimeType");
29878        return;
29879      }
29880      media_recorder = new MediaRecorder(stream, { mimeType });
29881      media_recorder.addEventListener("dataavailable", function(e) {
29882        recorded_blobs.push(e.data);
29883      });
29884      media_recorder.start(200);
29885    }
29886    $$invalidate(11, recording = !recording);
29887  }
29888  let webcam_accessed = false;
29889  function record_video_or_photo({ destroy } = {}) {
29890    if (mode === "image" && streaming) {
29891      $$invalidate(11, recording = !recording);
29892    }
29893    if (!destroy) {
29894      if (mode === "image") {
29895        take_picture();
29896      } else {
29897        take_recording();
29898      }
29899    }
29900    if (!recording && stream) {
29901      dispatch2("close_stream");
29902      stream.getTracks().forEach((track) => track.stop());
29903      $$invalidate(6, video_source.srcObject = null, video_source);
29904      $$invalidate(12, webcam_accessed = false);
29905      window.setTimeout(
29906        () => {
29907          $$invalidate(0, value = null);
29908        },
29909        500
29910      );
29911      $$invalidate(0, value = null);
29912    }
29913  }
29914  let options_open = false;
29915  function handle_click_outside2(event) {
29916    event.preventDefault();
29917    event.stopPropagation();
29918    $$invalidate(13, options_open = false);
29919  }
29920  onDestroy(() => {
29921    if (typeof window === "undefined") return;
29922    record_video_or_photo({ destroy: true });
29923    stream == null ? void 0 : stream.getTracks().forEach((track) => track.stop());
29924  });
29925  function video_binding($$value) {
29926    binding_callbacks[$$value ? "unshift" : "push"](() => {
29927      video_source = $$value;
29928      $$invalidate(6, video_source);
29929    });
29930  }
29931  const click_handler = async () => access_webcam();
29932  const click_handler_1 = () => record_video_or_photo();
29933  const click_handler_2 = () =>
29933 $$invalidate(13, options_open = true);
29934  const click_handler_3 = () => $$invalidate(13, options_open = false);
29935  $$self.$$set = ($$props2) => {
29936    if ("streaming" in $$props2) $$invalidate(1, streaming = $$props2.streaming);
29937    if ("pending" in $$props2) $$invalidate(20, pending = $$props2.pending);
29938    if ("root" in $$props2) $$invalidate(21, root = $$props2.root);
29939    if ("stream_every" in $$props2) $$invalidate(22, stream_every = $$props2.stream_every);
29940    if ("mode" in $$props2) $$invalidate(2, mode = $$props2.mode);
29941    if ("mirror_webcam" in $$props2) $$invalidate(3, mirror_webcam = $$props2.mirror_webcam);
29942    if ("include_audio" in $$props2) $$invalidate(23, include_audio = $$props2.include_audio);
29943    if ("webcam_constraints" in $$props2) $$invalidate(24, webcam_constraints = $$props2.webcam_constraints);
29944    if ("i18n" in $$props2) $$invalidate(4, i18n = $$props2.i18n);
29945    if ("upload" in $$props2) $$invalidate(25, upload = $$props2.upload);
29946    if ("value" in $$props2) $$invalidate(0, value = $$props2.value);
29947  };
29948  return [
29949    value,
29950    streaming,
29951    mode,
29952    mirror_webcam,
29953    i18n,
29954    click_outside,
29955    video_source,
29956    available_video_devices,
29957    selected_device,
29958    time_limit,
29959    stream_state,
29960    recording,
29961    webcam_accessed,
29962    options_open,
29963    handle_device_change,
29964    access_webcam,
29965    record_video_or_photo,
29966    handle_click_outside2,
29967    modify_stream,
29968    set_time_limit,
29969    pending,
29970    root,
29971    stream_every,
29972    include_audio,
29973    webcam_constraints,
29974    upload,
29975    video_binding,
29976    click_handler,
29977    click_handler_1,
29978    click_handler_2,
29979    click_handler_3
29980  ];
29981}
29982class Webcam2 extends SvelteComponent {
29983  constructor(options) {
29984    super();
29985    init(
29986      this,
29987      options,
29988      instance$4,
29989      create_fragment$4,
29990      safe_not_equal,
29991      {
29992        modify_stream: 18,
29993        set_time_limit: 19,
29994        streaming: 1,
29995        pending: 20,
29996        root: 21,
29997        stream_every: 22,
29998        mode: 2,
29999        mirror_webcam: 3,
30000        include_audio: 23,
30001        webcam_constraints: 24,
30002        i18n: 4,
30003        upload: 25,
30004        value: 0,
30005        click_outside: 5
30006      },
30007      null,
30008      [-1, -1]
30009    );
30010  }
30011  get modify_stream() {
30012    return this.$$.ctx[18];
30013  }
30014  get set_time_limit() {
30015    return this.$$.ctx[19];
30016  }
30017  get click_outside() {
30018    return click_outside;
30019  }
30020}
30021function create_if_block_5(ctx) {
30022  let t;
30023  let iconbutton;
30024  let current;
30025  let if_block = (
30026    /*show_fullscreen_button*/
30027    ctx[19] && create_if_block_6(ctx)
30028  );
30029  iconbutton = new IconButton({
30030    props: { Icon: Clear, label: "Remove Image" }
30031  });
30032  iconbutton.$on(
30033    "click",
30034    /*handle_remove_image_click*/
30035    ctx[28]
30036  );
30037  return {
30038    c() {
30039      if (if_block) if_block.c();
30040      t = space();
30041      create_component(iconbutton.$$.fragment);
30042    },
30043    m(target, anchor) {
30044      if (if_block) if_block.m(target, anchor);
30045      insert(target, t, anchor);
30046      mount_component(iconbutton, target, anchor);
30047      current = true;
30048    },
30049    p(ctx2, dirty) {
30050      if (
30051        /*show_fullscreen_button*/
30052        ctx2[19]
30053      ) {
30054        if (if_block) {
30055          if_block.p(ctx2, dirty);
30056          if (dirty[0] & /*show_fullscreen_button*/
30057          524288) {
30058            transition_in(if_block, 1);
30059          }
30060        } else {
30061          if_block = create_if_block_6(ctx2);
30062          if_block.c();
30063          transition_in(if_block, 1);
30064          if_block.m(t.parentNode, t);
30065        }
30066      } else if (if_block) {
30067        group_outros();
30068        transition_out(if_block, 1, 1, () => {
30069          if_block = null;
30070        });
30071        check_outros();
30072      }
30073    },
30074    i(local) {
30075      if (current) return;
30076      transition_in(if_block);
30077      transition_in(iconbutton.$$.fragment, local);
30078      current = true;
30079    },
30080    o(local) {
30081      transition_out(if_block);
30082      transition_out(iconbutton.$$.fragment, local);
30083      current = false;
30084    },
30085    d(detaching) {
30086      if (detaching) {
30087        detach(t);
30088      }
30089      if (if_block) if_block.d(detaching);
30090      destroy_component(iconbutton, detaching);
30091    }
30092  };
30093}
30094function create_if_block_6(ctx) {
30095  let fullscreenbutton;
30096  let current;
30097  fullscreenbutton = new FullscreenButton({
30098    props: { fullscreen: (
30099      /*fullscreen*/
30100      ctx[20]
30101    ) }
30102  });
30103  fullscreenbutton.$on(
30104    "fullscreen",
30105    /*fullscreen_handler*/
30106    ctx[35]
30107  );
30108  return {
30109    c() {
30110      create_component(fullscreenbutton.$$.fragment);
30111    },
30112    m(target, anchor) {
30113      mount_component(fullscreenbutton, target, anchor);
30114      current = true;
30115    },
30116    p(ctx2, dirty) {
30117      const fullscreenbutton_changes = {};
30118      if (dirty[0] & /*fullscreen*/
30119      1048576) fullscreenbutton_changes.fullscreen = /*fullscreen*/
30120      ctx2[20];
30121      fullscreenbutton.$set(fullscreenbutton_changes);
30122    },
30123    i(local) {
30124      if (current) return;
30125      transition_in(fullscreenbutton.$$.fragment, local);
30126      current = true;
30127    },
30128    o(local) {
30129      transition_out(fullscreenbutton.$$.fragment, local);
30130      current = false;
30131    },
30132    d(detaching) {
30133      destroy_component(fullscreenbutton, detaching);
30134    }
30135  };
30136}
30137function create_default_slot_1$1(ctx) {
30138  var _a;
30139  let if_block_anchor;
30140  let current;
30141  let if_block = (
30142    /*value*/
30143    ((_a = ctx[3]) == null ? void 0 : _a.url) && !/*active_streaming*/
30144    ctx[21] && create_if_block_5(ctx)
30145  );
30146  return {
30147    c() {
30148      if (if_block) if_block.c();
30149      if_block_anchor = empty();
30150    },
30151    m(target, anchor) {
30152      if (if_block) if_block.m(target, anchor);
30153      insert(target, if_block_anchor, anchor);
30154      current = true;
30155    },
30156    p(ctx2, dirty) {
30157      var _a2;
30158      if (
30159        /*value*/
30160        ((_a2 = ctx2[3]) == null ? void 0 : _a2.url) && !/*active_streaming*/
30161        ctx2[21]
30162      ) {
30163        if (if_block) {
30164          if_block.p(ctx2, dirty);
30165          if (dirty[0] & /*value, active_streaming*/
30166          2097160) {
30167            transition_in(if_block, 1);
30168          }
30169        } else {
30170          if_block = create_if_block_5(ctx2);
30171          if_block.c();
30172          transition_in(if_block, 1);
30173          if_block.m(if_block_anchor.parentNode, if_block_anchor);
30174        }
30175      } else if (if_block) {
30176        group_outros();
30177        transition_out(if_block, 1, 1, () => {
30178          if_block = null;
30179        });
30180        check_outros();
30181      }
30182    },
30183    i(local) {
30184      if (current) return;
30185      transition_in(if_block);
30186      current = true;
30187    },
30188    o(local) {
30189      transition_out(if_block);
30190      current = false;
30191    },
30192    d(detaching) {
30193      if (detaching) {
30194        detach(if_block_anchor);
30195      }
30196      if (if_block) if_block.d(detaching);
30197    }
30198  };
30199}
30200function create_if_block_4(ctx) {
30201  let current;
30202  const default_slot_template = (
30203    /*#slots*/
30204    ctx[34].default
30205  );
30206  const default_slot = create_slot(
30207    default_slot_template,
30208    ctx,
30209    /*$$scope*/
30210    ctx[50],
30211    null
30212  );
30213  return {
30214    c() {
30215      if (default_slot) default_slot.c();
30216    },
30217    m(target, anchor) {
30218      if (default_slot) {
30219        default_slot.m(target, anchor);
30220      }
30221      current = true;
30222    },
30223    p(ctx2, dirty) {
30224      if (default_slot) {
30225        if (default_slot.p && (!current || dirty[1] & /*$$scope*/
30226        524288)) {
30227          update_slot_base(
30228            default_slot,
30229            default_slot_template,
30230            ctx2,
30231            /*$$scope*/
30232            ctx2[50],
30233            !current ? get_all_dirty_from_scope(
30234              /*$$scope*/
30235              ctx2[50]
30236            ) : get_slot_changes(
30237              default_slot_template,
30238              /*$$scope*/
30239              ctx2[50],
30240              dirty,
30241              null
30242            ),
30243            null
30244          );
30245        }
30246      }
30247    },
30248    i(local) {
30249      if (current) return;
30250      transition_in(default_slot, local);
30251      current = true;
30252    },
30253    o(local) {
30254      transition_out(default_slot, local);
30255      current = false;
30256    },
30257    d(detaching) {
30258      if (default_slot) default_slot.d(detaching);
30259    }
30260  };
30261}
30262function create_default_slot$2(ctx) {
30263  let if_block_anchor;
30264  let current;
30265  let if_block = (
30266    /*value*/
30267    ctx[3] === null && create_if_block_4(ctx)
30268  );
30269  return {
30270    c() {
30271      if (if_block) if_block.c();
30272      if_block_anchor = empty();
30273    },
30274    m(target, anchor) {
30275      if (if_block) if_block.m(target, anchor);
30276      insert(target, if_block_anchor, anchor);
30277      current = true;
30278    },
30279    p(ctx2, dirty) {
30280      if (
30281        /*value*/
30282        ctx2[3] === null
30283      ) {
30284        if (if_block) {
30285          if_block.p(ctx2, dirty);
30286          if (dirty[0] & /*value*/
30287          8) {
30288            transition_in(if_block, 1);
30289          }
30290        } else {
30291          if_block = create_if_block_4(ctx2);
30292          if_block.c();
30293          transition_in(if_block, 1);
30294          if_block.m(if_block_anchor.parentNode, if_block_anchor);
30295        }
30296      } else if (if_block) {
30297        group_outros();
30298        transition_out(if_block, 1, 1, () => {
30299          if_block = null;
30300        });
30301        check_outros();
30302      }
30303    },
30304    i(local) {
30305      if (current) return;
30306      transition_in(if_block);
30307      current = true;
30308    },
30309    o(local) {
30310      transition_out(if_block);
30311      current = false;
30312    },
30313    d(detaching) {
30314      if (detaching) {
30315        detach(if_block_anchor);
30316      }
30317      if (if_block) if_block.d(detaching);
30318    }
30319  };
30320}
30321function create_if_block_3(ctx) {
30322  let div;
30323  let image;
30324  let current;
30325  let mounted;
30326  let dispose;
30327  image = new Image2({
30328    props: {
30329      src: (
30330        /*value*/
30331        ctx[3].url
30332      ),
30333      alt: (
30334        /*value*/
30335        ctx[3].alt_text
30336      )
30337    }
30338  });
30339  return {
30340    c() {
30341      div = element("div");
30342      create_component(image.$$.fragment);
30343      attr(div, "class", "image-frame svelte-1562gr6");
30344      toggle_class(
30345        div,
30346        "selectable",
30347        /*selectable*/
30348        ctx[12]
30349      );
30350    },
30351    m(target, anchor) {
30352      insert(target, div, anchor);
30353      mount_component(image, div, null);
30354      current = true;
30355      if (!mounted) {
30356        dispose = listen(
30357          div,
30358          "click",
30359          /*handle_click*/
30360          ctx[30]
30361        );
30362        mounted = true;
30363      }
30364    },
30365    p(ctx2, dirty) {
30366      const image_changes = {};
30367      if (dirty[0] & /*value*/
30368      8) image_changes.src = /*value*/
30369      ctx2[3].url;
30370      if (dirty[0] & /*value*/
30371      8) image_changes.alt = /*value*/
30372      ctx2[3].alt_text;
30373      image.$set(image_changes);
30374      if (!current || dirty[0] & /*selectable*/
30375      4096) {
30376        toggle_class(
30377          div,
30378          "selectable",
30379          /*selectable*/
30380          ctx2[12]
30381        );
30382      }
30383    },
30384    i(local) {
30385      if (current) return;
30386      transition_in(image.$$.fragment, local);
30387      current = true;
30388    },
30389    o(local) {
30390      transition_out(image.$$.fragment, local);
30391      current = false;
30392    },
30393    d(detaching) {
30394      if (detaching) {
30395        detach(div);
30396      }
30397      destroy_component(image);
30398      mounted = false;
30399      dispose();
30400    }
30401  };
30402}
30403function create_if_block_2$1(ctx) {
30404  let webcam;
30405  let updating_modify_stream;
30406  let updating_set_time_limit;
30407  let current;
30408  function webcam_modify_stream_binding(value) {
30409    ctx[40](value);
30410  }
30411  function webcam_set_time_limit_binding(value) {
30412    ctx[41](value);
30413  }
30414  let webcam_props = {
30415    root: (
30416      /*root*/
30417      ctx[13]
30418    ),
30419    value: (
30420      /*value*/
30421      ctx[3]
30422    ),
30423    mirror_webcam: (
30424      /*webcam_options*/
30425      ctx[11].mirror
30426    ),
30427    stream_every: (
30428      /*stream_every*/
30429      ctx[18]
30430    ),
30431    streaming: (
30432      /*streaming*/
30433      ctx[10]
30434    ),
30435    mode: "image",
30436    include_audio: false,
30437    i18n: (
30438      /*i18n*/
30439      ctx[14]
30440    ),
30441    upload: (
30442      /*upload*/
30443      ctx[16]
30444    ),
30445    webcam_constraints: (
30446      /*webcam_options*/
30447      ctx[11].constraints
30448    )
30449  };
30450  if (
30451    /*modify_stream*/
30452    ctx[5] !== void 0
30453  ) {
30454    webcam_props.modify_stream = /*modify_stream*/
30455    ctx[5];
30456  }
30457  if (
30458    /*set_time_limit*/
30459    ctx[6] !== void 0
30460  ) {
30461    webcam_props.set_time_limit = /*set_time_limit*/
30462    ctx[6];
30463  }
30464  webcam = new Webcam2({ props: webcam_props });
30465  binding_callbacks.push(() => bind(webcam, "modify_stream", webcam_modify_stream_binding));
30466  binding_callbacks.push(() => bind(webcam, "set_time_limit", webcam_set_time_limit_binding));
30467  webcam.$on(
30468    "capture",
30469    /*capture_handler*/
30470    ctx[42]
30471  );
30472  webcam.$on(
30473    "stream",
30474    /*stream_handler_1*/
30475    ctx[43]
30476  );
30477  webcam.$on(
30478    "error",
30479    /*error_handler_1*/
30480    ctx[44]
30481  );
30482  webcam.$on(
30483    "drag",
30484    /*drag_handler*/
30485    ctx[45]
30486  );
30487  webcam.$on(
30488    "upload",
30489    /*upload_handler*/
30490    ctx[46]
30491  );
30492  webcam.$on(
30493    "close_stream",
30494    /*close_stream_handler*/
30495    ctx[47]
30496  );
30497  return {
30498    c() {
30499      create_component(webcam.$$.fragment);
30500    },
30501    m(target, anchor) {
30502      mount_component(webcam, target, anchor);
30503      current = true;
30504    },
30505    p(ctx2, dirty) {
30506      const webcam_changes = {};
30507      if (dirty[0] & /*root*/
30508      8192) webcam_changes.root = /*root*/
30509      ctx2[13];
30510      if (dirty[0] & /*value*/
30511      8) webcam_changes.value = /*value*/
30512      ctx2[3];
30513      if (dirty[0] & /*webcam_options*/
30514      2048) webcam_changes.mirror_webcam = /*webcam_options*/
30515      ctx2[11].mirror;
30516      if (dirty[0] & /*stream_every*/
30517      262144) webcam_changes.stream_every = /*stream_every*/
30518      ctx2[18];
30519      if (dirty[0] & /*streaming*/
30520      1024) webcam_changes.streaming = /*streaming*/
30521      ctx2[10];
30522      if (dirty[0] & /*i18n*/
30523      16384) webcam_changes.i18n = /*i18n*/
30524      ctx2[14];
30525      if (dirty[0] & /*upload*/
30526      65536) webcam_changes.upload = /*upload*/
30527      ctx2[16];
30528      if (dirty[0] & /*webcam_options*/
30529      2048) webcam_changes.webcam_constraints = /*webcam_options*/
30530      ctx2[11].constraints;
30531      if (!updating_modify_stream && dirty[0] & /*modify_stream*/
30532      32) {
30533        updating_modify_stream = true;
30534        webcam_changes.modify_stream = /*modify_stream*/
30535        ctx2[5];
30536        add_flush_callback(() => updating_modify_stream = false);
30537      }
30538      if (!updating_set_time_limit && dirty[0] & /*set_time_limit*/
30539      64) {
30540        updating_set_time_limit = true;
30541        webcam_changes.set_time_limit = /*set_time_limit*/
30542        ctx2[6];
30543        add_flush_callback(() => updating_set_time_limit = false);
30544      }
30545      webcam.$set(webcam_changes);
30546    },
30547    i(local) {
30548      if (current) return;
30549      transition_in(webcam.$$.fragment, local);
30550      current = true;
30551    },
30552    o(local) {
30553      transition_out(webcam.$$.fragment, local);
30554      current = false;
30555    },
30556    d(detaching) {
30557      destroy_component(webcam, detaching);
30558    }
30559  };
30560}
30561function create_if_block_1$1(ctx) {
30562  let uploadprogress;
30563  let current;
30564  uploadprogress = new UploadProgress({
30565    props: {
30566      root: (
30567        /*root*/
30568        ctx[13]
30569      ),
30570      upload_id: (
30571        /*upload_id*/
30572        ctx[24]
30573      ),
30574      stream_handler: (
30575        /*stream_handler*/
30576        ctx[17]
30577      ),
30578      files: (
30579        /*files*/
30580        ctx[23]
30581      )
30582    }
30583  });
30584  return {
30585    c() {
30586      create_component(uploadprogress.$$.fragment);
30587    },
30588    m(target, anchor) {
30589      mount_component(uploadprogress, target, anchor);
30590      current = true;
30591    },
30592    p(ctx2, dirty) {
30593      const uploadprogress_changes = {};
30594      if (dirty[0] & /*root*/
30595      8192) uploadprogress_changes.root = /*root*/
30596      ctx2[13];
30597      if (dirty[0] & /*upload_id*/
30598      16777216) uploadprogress_changes.upload_id = /*upload_id*/
30599      ctx2[24];
30600      if (dirty[0] & /*stream_handler*/
30601      131072) uploadprogress_changes.stream_handler = /*stream_handler*/
30602      ctx2[17];
30603      if (dirty[0] & /*files*/
30604      8388608) uploadprogress_changes.files = /*files*/
30605      ctx2[23];
30606      uploadprogress.$set(uploadprogress_changes);
30607    },
30608    i(local) {
30609      if (current) return;
30610      transition_in(uploadprogress.$$.fragment, local);
30611      current = true;
30612    },
30613    o(local) {
30614      transition_out(uploadprogress.$$.fragment, local);
30615      current = false;
30616    },
30617    d(detaching) {
30618      destroy_component(uploadprogress, detaching);
30619    }
30620  };
30621}
30622function create_if_block$1(ctx) {
30623  let selectsource;
30624  let updating_active_source;
30625  let current;
30626  function selectsource_active_source_binding(value) {
30627    ctx[48](value);
30628  }
30629  let selectsource_props = {
30630    sources: (
30631      /*sources*/
30632      ctx[9]
30633    ),
30634    handle_clear: (
30635      /*handle_clear*/
30636      ctx[27]
30637    ),
30638    handle_select: (
30639      /*handle_select_source*/
30640      ctx[31]
30641    )
30642  };
30643  if (
30644    /*active_source*/
30645    ctx[1] !== void 0
30646  ) {
30647    selectsource_props.active_source = /*active_source*/
30648    ctx[1];
30649  }
30650  selectsource = new SelectSource({ props: selectsource_props });
30651  binding_callbacks.push(() => bind(selectsource, "active_source", selectsource_active_source_binding));
30652  return {
30653    c() {
30654      create_component(selectsource.$$.fragment);
30655    },
30656    m(target, anchor) {
30657      mount_component(selectsource, target, anchor);
30658      current = true;
30659    },
30660    p(ctx2, dirty) {
30661      const selectsource_changes = {};
30662      if (dirty[0] & /*sources*/
30663      512) selectsource_changes.sources = /*sources*/
30664      ctx2[9];
30665      if (!updating_active_source && dirty[0] & /*active_source*/
30666      2) {
30667        updating_active_source = true;
30668        selectsource_changes.active_source = /*active_source*/
30669        ctx2[1];
30670        add_flush_callback(() => updating_active_source = false);
30671      }
30672      selectsource.$set(selectsource_changes);
30673    },
30674    i(local) {
30675      if (current) return;
30676      transition_in(selectsource.$$.fragment, local);
30677      current = true;
30678    },
30679    o(local) {
30680      transition_out(selectsource.$$.fragment, local);
30681      current = false;
30682    },
30683    d(detaching) {
30684      destroy_component(selectsource, detaching);
30685    }
30686  };
30687}
30688function create_fragment$3(ctx) {
30689  let blocklabel;
30690  let t0;
30691  let div1;
30692  let iconbuttonwrapper;
30693  let t1;
30694  let div0;
30695  let upload_1;
30696  let updating_uploading;
30697  let updating_dragging;
30698  let t2;
30699  let current_block_type_index;
30700  let if_block0;
30701  let t3;
30702  let show_if = (
30703    /*sources*/
30704    ctx[9].length > 1 || /*sources*/
30705    ctx[9].includes("clipboard")
30706  );
30707  let current;
30708  let mounted;
30709  let dispose;
30710  blocklabel = new BlockLabel({
30711    props: {
30712      show_label: (
30713        /*show_label*/
30714        ctx[8]
30715      ),
30716      Icon: Image$1,
30717      label: (
30718        /*label*/
30719        ctx[7] || "Image"
30720      )
30721    }
30722  });
30723  iconbuttonwrapper = new IconButtonWrapper({
30724    props: {
30725      $$slots: { default: [create_default_slot_1$1] },
30726      $$scope: { ctx }
30727    }
30728  });
30729  function upload_1_uploading_binding(value) {
30730    ctx[37](value);
30731  }
30732  function upload_1_dragging_binding(value) {
30733    ctx[38](value);
30734  }
30735  let upload_1_props = {
30736    hidden: (
30737      /*value*/
30738      ctx[3] !== null || /*active_source*/
30739      ctx[1] === "webcam"
30740    ),
30741    filetype: (
30742      /*active_source*/
30743      ctx[1] === "clipboard" ? "clipboard" : "image/*"
30744    ),
30745    root: (
30746      /*root*/
30747      ctx[13]
30748    ),
30749    max_file_size: (
30750      /*max_file_size*/
30751      ctx[15]
30752    ),
30753    disable_click: !/*sources*/
30754    ctx[9].includes("upload") || /*value*/
30755    ctx[3] !== null,
30756    upload: (
30757      /*upload*/
30758      ctx[16]
30759    ),
30760    stream_handler: (
30761      /*stream_handler*/
30762      ctx[17]
30763    ),
30764    aria_label: (
30765      /*i18n*/
30766      ctx[14]("image.drop_to_upload")
30767    ),
30768    $$slots: { default: [create_default_slot$2] },
30769    $$scope: { ctx }
30770  };
30771  if (
30772    /*uploading*/
30773    ctx[0] !== void 0
30774  ) {
30775    upload_1_props.uploading = /*uploading*/
30776    ctx[0];
30777  }
30778  if (
30779    /*dragging*/
30780    ctx[2] !== void 0
30781  ) {
30782    upload_1_props.dragging = /*dragging*/
30783    ctx[2];
30784  }
30785  upload_1 = new Upload2({ props: upload_1_props });
30786  ctx[36](upload_1);
30787  binding_callbacks.push(() => bind(upload_1, "uploading", upload_1_uploading_binding));
30788  binding_callbacks.push(() => bind(upload_1, "dragging", upload_1_dragging_binding));
30789  upload_1.$on(
30790    "load",
30791    /*handle_upload*/
30792    ctx[26]
30793  );
30794  upload_1.$on(
30795    "error",
30796    /*error_handler*/
30797    ctx[39]
30798  );
30799  const if_block_creators = [create_if_block_1$1, create_if_block_2$1, create_if_block_3];
30800  const if_blocks = [];
30801  function select_block_type(ctx2, dirty) {
30802    if (
30803      /*active_source*/
30804      ctx2[1] === "webcam" && !/*streaming*/
30805      ctx2[10] && /*pending*/
30806      ctx2[4]
30807    ) return 0;
30808    if (
30809      /*active_source*/
30810      ctx2[1] === "webcam" && /*streaming*/
30811      (ctx2[10] || !/*streaming*/
30812      ctx2[10] && !/*value*/
30813      ctx2[3])
30814    ) return 1;
30815    if (
30816      /*value*/
30817      ctx2[3] !== null && !/*streaming*/
30818      ctx2[10]
30819    ) return 2;
30820    return -1;
30821  }
30822  if (~(current_block_type_index = select_block_type(ctx))) {
30823    if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
30824  }
30825  let if_block1 = show_if && create_if_block$1(ctx);
30826  return {
30827    c() {
30828      create_component(blocklabel.$$.fragment);
30829      t0 = space();
30830      div1 = element("div");
30831      create_component(iconbuttonwrapper.$$.fragment);
30832      t1 = space();
30833      div0 = element("div");
30834      create_component(upload_1.$$.fragment);
30835      t2 = space();
30836      if (if_block0) if_block0.c();
30837      t3 = space();
30838      if (if_block1) if_block1.c();
30839      attr(div0, "class", "upload-container svelte-1562gr6");
30840      toggle_class(
30841        div0,
30842        "reduced-height",
30843        /*sources*/
30844        ctx[9].length > 1
30845      );
30846      set_style(
30847        div0,
30848        "width",
30849        /*value*/
30850        ctx[3] ? "auto" : "100%"
30851      );
30852      attr(div1, "data-testid", "image");
30853      attr(div1, "class", "image-container svelte-1562gr6");
30854    },
30855    m(target, anchor) {
30856      mount_component(blocklabel, target, anchor);
30857      insert(target, t0, anchor);
30858      insert(target, div1, anchor);
30859      mount_component(iconbuttonwrapper, div1, null);
30860      append(div1, t1);
30861      append(div1, div0);
30862      mount_component(upload_1, div0, null);
30863      append(div0, t2);
30864      if (~current_block_type_index) {
30865        if_blocks[current_block_type_index].m(div0, null);
30866      }
30867      append(div1, t3);
30868      if (if_block1) if_block1.m(div1, null);
30869      ctx[49](div1);
30870      current = true;
30871      if (!mounted) {
30872        dispose = [
30873          listen(
30874            div0,
30875            "dragover",
30876            /*on_drag_over*/
30877            ctx[32]
30878          ),
30879          listen(
30880            div0,
30881            "drop",
30882            /*on_drop*/
30883            ctx[33]
30884          )
30885        ];
30886        mounted = true;
30887      }
30888    },
30889    p(ctx2, dirty) {
30890      const blocklabel_changes = {};
30891      if (dirty[0] & /*show_label*/
30892      256) blocklabel_changes.show_label = /*show_label*/
30893      ctx2[8];
30894      if (dirty[0] & /*label*/
30895      128) blocklabel_changes.label = /*label*/
30896      ctx2[7] || "Image";
30897      blocklabel.$set(blocklabel_changes);
30898      const iconbuttonwrapper_changes = {};
30899      if (dirty[0] & /*fullscreen, show_fullscreen_button, value, active_streaming*/
30900      3670024 | dirty[1] & /*$$scope*/
30901      524288) {
30902        iconbuttonwrapper_changes.$$scope = { dirty, ctx: ctx2 };
30903      }
30904      iconbuttonwrapper.$set(iconbuttonwrapper_changes);
30905      const upload_1_changes = {};
30906      if (dirty[0] & /*value, active_source*/
30907      10) upload_1_changes.hidden = /*value*/
30908      ctx2[3] !== null || /*active_source*/
30909      ctx2[1] === "webcam";
30910      if (dirty[0] & /*active_source*/
30911      2) upload_1_changes.filetype = /*active_source*/
30912      ctx2[1] === "clipboard" ? "clipboard" : "image/*";
30913      if (dirty[0] & /*root*/
30914      8192) upload_1_changes.root = /*root*/
30915      ctx2[13];
30916      if (dirty[0] & /*max_file_size*/
30917      32768) upload_1_changes.max_file_size = /*max_file_size*/
30918      ctx2[15];
30919      if (dirty[0] & /*sources, value*/
30920      520) upload_1_changes.disable_click = !/*sources*/
30921      ctx2[9].includes("upload") || /*value*/
30922      ctx2[3] !== null;
30923      if (dirty[0] & /*upload*/
30924      65536) upload_1_changes.upload = /*upload*/
30925      ctx2[16];
30926      if (dirty[0] & /*stream_handler*/
30927      131072) upload_1_changes.stream_handler = /*stream_handler*/
30928      ctx2[17];
30929      if (dirty[0] & /*i18n*/
30930      16384) upload_1_changes.aria_label = /*i18n*/
30931      ctx2[14]("image.drop_to_upload");
30932      if (dirty[0] & /*value*/
30933      8 | dirty[1] & /*$$scope*/
30934      524288) {
30935        upload_1_changes.$$scope = { dirty, ctx: ctx2 };
30936      }
30937      if (!updating_uploading && dirty[0] & /*uploading*/
30938      1) {
30939        updating_uploading = true;
30940        upload_1_changes.uploading = /*uploading*/
30941        ctx2[0];
30942        add_flush_callback(() => updating_uploading = false);
30943      }
30944      if (!updating_dragging && dirty[0] & /*dragging*/
30945      4) {
30946        updating_dragging = true;
30947        upload_1_changes.dragging = /*dragging*/
30948        ctx2[2];
30949        add_flush_callback(() => updating_dragging = false);
30950      }
30951      upload_1.$set(upload_1_changes);
30952      let previous_block_index = current_block_type_index;
30953      current_block_type_index = select_block_type(ctx2);
30954      if (current_block_type_index === previous_block_index) {
30955        if (~current_block_type_index) {
30956          if_blocks[current_block_type_index].p(ctx2, dirty);
30957        }
30958      } else {
30959        if (if_block0) {
30960          group_outros();
30961          transition_out(if_blocks[previous_block_index], 1, 1, () => {
30962            if_blocks[previous_block_index] = null;
30963          });
30964          check_outros();
30965        }
30966        if (~current_block_type_index) {
30967          if_block0 = if_blocks[current_block_type_index];
30968          if (!if_block0) {
30969            if_block0 = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
30970            if_block0.c();
30971          } else {
30972            if_block0.p(ctx2, dirty);
30973          }
30974          transition_in(if_block0, 1);
30975          if_block0.m(div0, null);
30976        } else {
30977          if_block0 = null;
30978        }
30979      }
30980      if (!current || dirty[0] & /*sources*/
30981      512) {
30982        toggle_class(
30983          div0,
30984          "reduced-height",
30985          /*sources*/
30986          ctx2[9].length > 1
30987        );
30988      }
30989      if (dirty[0] & /*value*/
30990      8) {
30991        set_style(
30992          div0,
30993          "width",
30994          /*value*/
30995          ctx2[3] ? "auto" : "100%"
30996        );
30997      }
30998      if (dirty[0] & /*sources*/
30999      512) show_if = /*sources*/
31000      ctx2[9].length > 1 || /*sources*/
31001      ctx2[9].includes("clipboard");
31002      if (show_if) {
31003        if (if_block1) {
31004          if_block1.p(ctx2, dirty);
31005          if (dirty[0] & /*sources*/
31006          512) {
31007            transition_in(if_block1, 1);
31008          }
31009        } else {
31010          if_block1 = create_if_block$1(ctx2);
31011          if_block1.c();
31012          transition_in(if_block1, 1);
31013          if_block1.m(div1, null);
31014        }
31015      } else if (if_block1) {
31016        group_outros();
31017        transition_out(if_block1, 1, 1, () => {
31018          if_block1 = null;
31019        });
31020        check_outros();
31021      }
31022    },
31023    i(local) {
31024      if (current) return;
31025      transition_in(blocklabel.$$.fragment, local);
31026      transition_in(iconbuttonwrapper.$$.fragment, local);
31027      transition_in(upload_1.$$.fragment, local);
31028      transition_in(if_block0);
31029      transition_in(if_block1);
31030      current = true;
31031    },
31032    o(local) {
31033      transition_out(blocklabel.$$.fragment, local);
31034      transition_out(iconbuttonwrapper.$$.fragment, local);
31035      transition_out(upload_1.$$.fragment, local);
31036      transition_out(if_block0);
31037      transition_out(if_block1);
31038      current = false;
31039    },
31040    d(detaching) {
31041      if (detaching) {
31042        detach(t0);
31043        detach(div1);
31044      }
31045      destroy_component(blocklabel, detaching);
31046      destroy_component(iconbuttonwrapper);
31047      ctx[36](null);
31048      destroy_component(upload_1);
31049      if (~current_block_type_index) {
31050        if_blocks[current_block_type_index].d();
31051      }
31052      if (if_block1) if_block1.d();
31053      ctx[49](null);
31054      mounted = false;
31055      run_all(dispose);
31056    }
31057  };
31058}
31059function instance$3($$self, $$props, $$invalidate) {
31060  let active_streaming;
31061  let { $$slots: slots = {}, $$scope } = $$props;
31062  let { value = null } = $$props;
31063  let { label = void 0 } = $$props;
31064  let { show_label } = $$props;
31065  let { sources = ["upload", "clipboard", "webcam"] } = $$props;
31066  let { streaming = false } = $$props;
31067  let { pending = false } = $$props;
31068  let { webcam_options } = $$props;
31069  let { selectable = false } = $$props;
31070  let { root } = $$props;
31071  let { i18n } = $$props;
31072  let { max_file_size = null } = $$props;
31073  let { upload } = $$props;
31074  let { stream_handler } = $$props;
31075  let { stream_every } = $$props;
31076  let { modify_stream } = $$props;
31077  let { set_time_limit } = $$props;
31078  let { show_fullscreen_button = true } = $$props;
31079  let upload_input;
31080  let { uploading = false } = $$props;
31081  let { active_source = null } = $$props;
31082  let { fullscreen = false } = $$props;
31083  let files = [];
31084  let upload_id;
31085  async function handle_upload({ detail }) {
31086    var _a;
31087    if (!streaming) {
31088      if (((_a = detail.path) == null ? void 0 : _a.toLowerCase().endsWith(".svg")) && detail.url) {
31089        const response = await fetch(detail.url);
31090        const svgContent = await response.text();
31091        $$invalidate(3, value = {
31092          ...detail,
31093          url: `data:image/svg+xml,${encodeURIComponent(svgContent)}`
31094        });
31095      } else {
31096        $$invalidate(3, value = detail);
31097      }
31098      await tick();
31099      dispatch2("upload");
31100    }
31101  }
31102  function handle_clear() {
31103    $$invalidate(3, value = null);
31104    dispatch2("clear");
31105    dispatch2("change", null);
31106  }
31107  function handle_remove_image_click(event) {
31108    handle_clear();
31109    event.stopPropagation();
31110  }
31111  async function handle_save(img_blob, event) {
31112    if (event === "stream") {
31113      dispatch2("stream", {
31114        value: { url: img_blob },
31115        is_value_data: true
31116      });
31117      return;
31118    }
31119    $$invalidate(24, upload_id = Math.random().toString(36).substring(2, 15));
31120    const f_ = new File([img_blob], `image.${streaming ? "jpeg" : "png"}`);
31121    $$invalidate(23, files = [
31122      new FileData({
31123        path: f_.name,
31124        orig_name: f_.name,
31125        blob: f_,
31126        size: f_.size,
31127        mime_type: f_.type,
31128        is_stream: false
31129      })
31130    ]);
31131    $$invalidate(4, pending = true);
31132    const f = await upload_input.load_files([f_], upload_id);
31133    if (event === "change" || event === "upload") {
31134      $$invalidate(3, value = (f == null ? void 0 : f[0]) || null);
31135      await tick();
31136      dispatch2("change");
31137    }
31138    $$invalidate(4, pending = false);
31139  }
31140  const dispatch2 = createEventDispatcher();
31141  let { dragging = false } = $$props;
31142  function handle_click(evt) {
31143    let coordinates = get_coordinates_of_clicked_image(evt);
31144    if (coordinates) {
31145      dispatch2("select", { index: coordinates, value: null });
31146    }
31147  }
31148  async function handle_select_source(source) {
31149    switch (source) {
31150      case "clipboard":
31151        upload_input.paste_clipboard();
31152        break;
31153    }
31154  }
31155  let image_container;
31156  function on_drag_over(evt) {
31157    evt.preventDefault();
31158    evt.stopPropagation();
31159    if (evt.dataTransfer) {
31160      evt.dataTransfer.dropEffect = "copy";
31161    }
31162    $$invalidate(2, dragging = true);
31163  }
31164  async function on_drop(evt) {
31165    evt.preventDefault();
31166    evt.stopPropagation();
31167    $$invalidate(2, dragging = false);
31168    if (value) {
31169      handle_clear();
31170      await tick();
31171    }
31172    $$invalidate(1, active_source = "upload");
31173    await tick();
31174    upload_input.load_files_from_drop(evt);
31175  }
31176  function fullscreen_handler(event) {
31177    bubble.call(this, $$self, event);
31178  }
31179  function upload_1_binding($$value) {
31180    binding_callbacks[$$value ? "unshift" : "push"](() => {
31181      upload_input = $$value;
31182      $$invalidate(22, upload_input);
31183    });
31184  }
31185  function upload_1_uploading_binding(value2) {
31186    uploading = value2;
31187    $$invalidate(0, uploading);
31188  }
31189  function upload_1_dragging_binding(value2) {
31190    dragging = value2;
31191    $$invalidate(2, dragging);
31192  }
31193  function error_handler(event) {
31194    bubble.call(this, $$self, event);
31195  }
31196  function webcam_modify_stream_binding(value2) {
31197    modify_stream = value2;
31198    $$invalidate(5, modify_stream);
31199  }
31200  function webcam_set_time_limit_binding(value2) {
31201    set_time_limit = value2;
31202    $$invalidate(6, set_time_limit);
31203  }
31204  const capture_handler = (e) => handle_save(e.detail, "change");
31205  const stream_handler_1 = (e) => handle_save(e.detail, "stream");
31206  function error_handler_1(event) {
31207    bubble.call(this, $$self, event);
31208  }
31209  function drag_handler(event) {
31210    bubble.call(this, $$self, event);
31211  }
31212  const upload_handler = (e) => handle_save(e.detail, "upload");
31213  function close_stream_handler(event) {
31214    bubble.call(this, $$self, event);
31215  }
31216  function selectsource_active_source_binding(value2) {
31217    active_source = value2;
31218    $$invalidate(1, active_source), $$invalidate(9, sources);
31219  }
31220  function div1_binding($$value) {
31221    binding_callbacks[$$value ? "unshift" : "push"](() => {
31222      image_container = $$value;
31223      $$invalidate(25, image_container);
31224    });
31225  }
31226  $$self.$$set = ($$props2) => {
31227    if ("value" in $$props2) $$invalidate(3, value = $$props2.value);
31228    if ("label" in $$props2) $$invalidate(7, label = $$props2.label);
31229    if ("show_label" in $$props2) $$invalidate(8, show_label = $$props2.show_label);
31230    if ("sources" in $$props2) $$invalidate(9, sources = $$props2.sources);
31231    if ("streaming" in $$props2) $$invalidate(10, streaming = $$props2.streaming);
31232    if ("pending" in $$props2) $$invalidate(4, pending = $$props2.pending);
31233    if ("webcam_options" in $$props2) $$invalidate(11, webcam_options = $$props2.webcam_options);
31234    if ("selectable" in $$props2) $$invalidate(12, selectable = $$props2.selectable);
31235    if ("root" in $$props2) $$invalidate(13, root = $$props2.root);
31236    if ("i18n" in $$props2) $$invalidate(14, i18n = $$props2.i18n);
31237    if ("max_file_size" in $$props2) $$invalidate(15, max_file_size = $$props2.max_file_size);
31238    if ("upload" in $$props2) $$invalidate(16, upload = $$props2.upload);
31239    if ("stream_handler" in $$props2) $$invalidate(17, stream_handler = $$props2.stream_handler);
31240    if ("stream_every" in $$props2) $$invalidate(18, stream_every = $$props2.stream_every);
31241    if ("modify_stream" in $$props2) $$invalidate(5, modify_stream = $$props2.modify_stream);
31242    if ("set_time_limit" in $$props2) $$invalidate(6, set_time_limit = $$props2.set_time_limit);
31243    if ("show_fullscreen_button" in $$props2) $$invalidate(19, show_fullscreen_button = $$props2.show_fullscreen_button);
31244    if ("uploading" in $$props2) $$invalidate(0, uploading = $$props2.uploading);
31245    if ("active_source" in $$props2) $$invalidate(1, active_source = $$props2.active_source);
31246    if ("fullscreen" in $$props2) $$invalidate(20, fullscreen = $$props2.fullscreen);
31247    if ("dragging" in $$props2) $$invalidate(2, dragging = $$props2.dragging);
31248    if ("$$scope" in $$props2) $$invalidate(50, $$scope = $$props2.$$scope);
31249  };
31250  $$self.$$.update = () => {
31251    if ($$self.$$.dirty[0] & /*active_source, sources*/
31252    514) {
31253      if (!active_source && sources) {
31254        $$invalidate(1, active_source = sources[0]);
31255      }
31256    }
31257    if ($$self.$$.dirty[0] & /*streaming, active_source*/
31258    1026) {
31259      $$invalidate(21, active_streaming = streaming && active_source === "webcam");
31260    }
31261    if ($$self.$$.dirty[0] & /*uploading, active_streaming*/
31262    2097153) {
31263      if (uploading && !active_streaming) $$invalidate(3, value = null);
31264    }
31265    if ($$self.$$.dirty[0] & /*dragging*/
31266    4) {
31267      dispatch2("drag", dragging);
31268    }
31269  };
31270  return [
31271    uploading,
31272    active_source,
31273    dragging,
31274    value,
31275    pending,
31276    modify_stream,
31277    set_time_limit,
31278    label,
31279    show_label,
31280    sources,
31281    streaming,
31282    webcam_options,
31283    selectable,
31284    root,
31285    i18n,
31286    max_file_size,
31287    upload,
31288    stream_handler,
31289    stream_every,
31290    show_fullscreen_button,
31291    fullscreen,
31292    active_streaming,
31293    upload_input,
31294    files,
31295    upload_id,
31296    image_container,
31297    handle_upload,
31298    handle_clear,
31299    handle_remove_image_click,
31300    handle_save,
31301    handle_click,
31302    handle_select_source,
31303    on_drag_over,
31304    on_drop,
31305    slots,
31306    fullscreen_handler,
31307    upload_1_binding,
31308    upload_1_uploading_binding,
31309    upload_1_dragging_binding,
31310    error_handler,
31311    webcam_modify_stream_binding,
31312    webcam_set_time_limit_binding,
31313    capture_handler,
31314    stream_handler_1,
31315    error_handler_1,
31316    drag_handler,
31317    upload_handler,
31318    close_stream_handler,
31319    selectsource_active_source_binding,
31320    div1_binding,
31321    $$scope
31322  ];
31323}
31324class ImageUploader extends SvelteComponent {
31325  constructor(options) {
31326    super();
31327    init(
31328      this,
31329      options,
31330      instance$3,
31331      create_fragment$3,
31332      safe_not_equal,
31333      {
31334        value: 3,
31335        label: 7,
31336        show_label: 8,
31337        sources: 9,
31338        streaming: 10,
31339        pending: 4,
31340        webcam_options: 11,
31341        selectable: 12,
31342        root: 13,
31343        i18n: 14,
31344        max_file_size: 15,
31345        upload: 16,
31346        stream_handler: 17,
31347        stream_every: 18,
31348        modify_stream: 5,
31349        set_time_limit: 6,
31350        show_fullscreen_button: 19,
31351        uploading: 0,
31352        active_source: 1,
31353        fullscreen: 20,
31354        dragging: 2
31355      },
31356      null,
31357      [-1, -1]
31358    );
31359  }
31360}
31361function create_else_block(ctx) {
31362  let block2;
31363  let updating_fullscreen;
31364  let current;
31365  function block_fullscreen_binding_1(value) {
31366    ctx[63](value);
31367  }
31368  let block_props = {
31369    visible: (
31370      /*visible*/
31371      ctx[5]
31372    ),
31373    variant: (
31374      /*value*/
31375      ctx[0] === null ? "dashed" : "solid"
31376    ),
31377    border_mode: (
31378      /*dragging*/
31379      ctx[29] ? "focus" : "base"
31380    ),
31381    padding: false,
31382    elem_id: (
31383      /*elem_id*/
31384      ctx[3]
31385    ),
31386    elem_classes: (
31387      /*elem_classes*/
31388      ctx[4]
31389    ),
31390    height: (
31391      /*height*/
31392      ctx[10] || void 0
31393    ),
31394    width: (
31395      /*width*/
31396      ctx[11]
31397    ),
31398    allow_overflow: false,
31399    container: (
31400      /*container*/
31401      ctx[14]
31402    ),
31403    scale: (
31404      /*scale*/
31405      ctx[15]
31406    ),
31407    min_width: (
31408      /*min_width*/
31409      ctx[16]
31410    ),
31411    $$slots: { default: [create_default_slot_1] },
31412    $$scope: { ctx }
31413  };
31414  if (
31415    /*fullscreen*/
31416    ctx[28] !== void 0
31417  ) {
31418    block_props.fullscreen = /*fullscreen*/
31419    ctx[28];
31420  }
31421  block2 = new Block({ props: block_props });
31422  binding_callbacks.push(() => bind(block2, "fullscreen", block_fullscreen_binding_1));
31423  block2.$on(
31424    "dragenter",
31425    /*handle_drag_event*/
31426    ctx[32]
31427  );
31428  block2.$on(
31429    "dragleave",
31430    /*handle_drag_event*/
31431    ctx[32]
31432  );
31433  block2.$on(
31434    "dragover",
31435    /*handle_drag_event*/
31436    ctx[32]
31437  );
31438  block2.$on(
31439    "drop",
31440    /*handle_drop*/
31441    ctx[33]
31442  );
31443  return {
31444    c() {
31445      create_component(block2.$$.fragment);
31446    },
31447    m(target, anchor) {
31448      mount_component(block2, target, anchor);
31449      current = true;
31450    },
31451    p(ctx2, dirty) {
31452      const block_changes = {};
31453      if (dirty[0] & /*visible*/
31454      32) block_changes.visible = /*visible*/
31455      ctx2[5];
31456      if (dirty[0] & /*value*/
31457      1) block_changes.variant = /*value*/
31458      ctx2[0] === null ? "dashed" : "solid";
31459      if (dirty[0] & /*dragging*/
31460      536870912) block_changes.border_mode = /*dragging*/
31461      ctx2[29] ? "focus" : "base";
31462      if (dirty[0] & /*elem_id*/
31463      8) block_changes.elem_id = /*elem_id*/
31464      ctx2[3];
31465      if (dirty[0] & /*elem_classes*/
31466      16) block_changes.elem_classes = /*elem_classes*/
31467      ctx2[4];
31468      if (dirty[0] & /*height*/
31469      1024) block_changes.height = /*height*/
31470      ctx2[10] || void 0;
31471      if (dirty[0] & /*width*/
31472      2048) block_changes.width = /*width*/
31473      ctx2[11];
31474      if (dirty[0] & /*container*/
31475      16384) block_changes.container = /*container*/
31476      ctx2[14];
31477      if (dirty[0] & /*scale*/
31478      32768) block_changes.scale = /*scale*/
31479      ctx2[15];
31480      if (dirty[0] & /*min_width*/
31481      65536) block_changes.min_width = /*min_width*/
31482      ctx2[16];
31483      if (dirty[0] & /*_selectable, root, sources, fullscreen, label, show_label, pending, streaming, webcam_options, stream_every, gradio, uploading, active_source, value, dragging, _modify_stream, set_time_limit, loading_status, placeholder*/
31484      2138321607 | dirty[1] & /*upload_component*/
31485      1 | dirty[2] & /*$$scope*/
31486      8) {
31487        block_changes.$$scope = { dirty, ctx: ctx2 };
31488      }
31489      if (!updating_fullscreen && dirty[0] & /*fullscreen*/
31490      268435456) {
31491        updating_fullscreen = true;
31492        block_changes.fullscreen = /*fullscreen*/
31493        ctx2[28];
31494        add_flush_callback(() => updating_fullscreen = false);
31495      }
31496      block2.$set(block_changes);
31497    },
31498    i(local) {
31499      if (current) return;
31500      transition_in(block2.$$.fragment, local);
31501      current = true;
31502    },
31503    o(local) {
31504      transition_out(block2.$$.fragment, local);
31505      current = false;
31506    },
31507    d(detaching) {
31508      destroy_component(block2, detaching);
31509    }
31510  };
31511}
31512function create_if_block(ctx) {
31513  let block2;
31514  let updating_fullscreen;
31515  let current;
31516  function block_fullscreen_binding(value) {
31517    ctx[43](value);
31518  }
31519  let block_props = {
31520    visible: (
31521      /*visible*/
31522      ctx[5]
31523    ),
31524    variant: "solid",
31525    border_mode: (
31526      /*dragging*/
31527      ctx[29] ? "focus" : "base"
31528    ),
31529    padding: false,
31530    elem_id: (
31531      /*elem_id*/
31532      ctx[3]
31533    ),
31534    elem_classes: (
31535      /*elem_classes*/
31536      ctx[4]
31537    ),
31538    height: (
31539      /*height*/
31540      ctx[10] || void 0
31541    ),
31542    width: (
31543      /*width*/
31544      ctx[11]
31545    ),
31546    allow_overflow: false,
31547    container: (
31548      /*container*/
31549      ctx[14]
31550    ),
31551    scale: (
31552      /*scale*/
31553      ctx[15]
31554    ),
31555    min_width: (
31556      /*min_width*/
31557      ctx[16]
31558    ),
31559    $$slots: { default: [create_default_slot$1] },
31560    $$scope: { ctx }
31561  };
31562  if (
31563    /*fullscreen*/
31564    ctx[28] !== void 0
31565  ) {
31566    block_props.fullscreen = /*fullscreen*/
31567    ctx[28];
31568  }
31569  block2 = new Block({ props: block_props });
31570  binding_callbacks.push(() => bind(block2, "fullscreen", block_fullscreen_binding));
31571  return {
31572    c() {
31573      create_component(block2.$$.fragment);
31574    },
31575    m(target, anchor) {
31576      mount_component(block2, target, anchor);
31577      current = true;
31578    },
31579    p(ctx2, dirty) {
31580      const block_changes = {};
31581      if (dirty[0] & /*visible*/
31582      32) block_changes.visible = /*visible*/
31583      ctx2[5];
31584      if (dirty[0] & /*dragging*/
31585      536870912) block_changes.border_mode = /*dragging*/
31586      ctx2[29] ? "focus" : "base";
31587      if (dirty[0] & /*elem_id*/
31588      8) block_changes.elem_id = /*elem_id*/
31589      ctx2[3];
31590      if (dirty[0] & /*elem_classes*/
31591      16) block_changes.elem_classes = /*elem_classes*/
31592      ctx2[4];
31593      if (dirty[0] & /*height*/
31594      1024) block_changes.height = /*height*/
31595      ctx2[10] || void 0;
31596      if (dirty[0] & /*width*/
31597      2048) block_changes.width = /*width*/
31598      ctx2[11];
31599      if (dirty[0] & /*container*/
31600      16384) block_changes.container = /*container*/
31601      ctx2[14];
31602      if (dirty[0] & /*scale*/
31603      32768) block_changes.scale = /*scale*/
31604      ctx2[15];
31605      if (dirty[0] & /*min_width*/
31606      65536) block_changes.min_width = /*min_width*/
31607      ctx2[16];
31608      if (dirty[0] & /*fullscreen, value, label, show_label, show_download_button, _selectable, show_share_button, gradio, show_fullscreen_button, loading_status*/
31609      310518213 | dirty[2] & /*$$scope*/
31610      8) {
31611        block_changes.$$scope = { dirty, ctx: ctx2 };
31612      }
31613      if (!updating_fullscreen && dirty[0] & /*fullscreen*/
31614      268435456) {
31615        updating_fullscreen = true;
31616        block_changes.fullscreen = /*fullscreen*/
31617        ctx2[28];
31618        add_flush_callback(() => updating_fullscreen = false);
31619      }
31620      block2.$set(block_changes);
31621    },
31622    i(local) {
31623      if (current) return;
31624      transition_in(block2.$$.fragment, local);
31625      current = true;
31626    },
31627    o(local) {
31628      transition_out(block2.$$.fragment, local);
31629      current = false;
31630    },
31631    d(detaching) {
31632      destroy_component(block2, detaching);
31633    }
31634  };
31635}
31636function create_else_block_1(ctx) {
31637  let empty_1;
31638  let current;
31639  empty_1 = new Empty({
31640    props: {
31641      unpadded_box: true,
31642      size: "large",
31643      $$slots: { default: [create_default_slot_3] },
31644      $$scope: { ctx }
31645    }
31646  });
31647  return {
31648    c() {
31649      create_component(empty_1.$$.fragment);
31650    },
31651    m(target, anchor) {
31652      mount_component(empty_1, target, anchor);
31653      current = true;
31654    },
31655    p(ctx2, dirty) {
31656      const empty_1_changes = {};
31657      if (dirty[2] & /*$$scope*/
31658      8) {
31659        empty_1_changes.$$scope = { dirty, ctx: ctx2 };
31660      }
31661      empty_1.$set(empty_1_changes);
31662    },
31663    i(local) {
31664      if (current) return;
31665      transition_in(empty_1.$$.fragment, local);
31666      current = true;
31667    },
31668    o(local) {
31669      transition_out(empty_1.$$.fragment, local);
31670      current = false;
31671    },
31672    d(detaching) {
31673      destroy_component(empty_1, detaching);
31674    }
31675  };
31676}
31677function create_if_block_2(ctx) {
31678  let uploadtext;
31679  let current;
31680  uploadtext = new UploadText({
31681    props: {
31682      i18n: (
31683        /*gradio*/
31684        ctx[25].i18n
31685      ),
31686      type: "clipboard",
31687      mode: "short"
31688    }
31689  });
31690  return {
31691    c() {
31692      create_component(uploadtext.$$.fragment);
31693    },
31694    m(target, anchor) {
31695      mount_component(uploadtext, target, anchor);
31696      current = true;
31697    },
31698    p(ctx2, dirty) {
31699      const uploadtext_changes = {};
31700      if (dirty[0] & /*gradio*/
31701      33554432) uploadtext_changes.i18n = /*gradio*/
31702      ctx2[25].i18n;
31703      uploadtext.$set(uploadtext_changes);
31704    },
31705    i(local) {
31706      if (current) return;
31707      transition_in(uploadtext.$$.fragment, local);
31708      current = true;
31709    },
31710    o(local) {
31711      transition_out(uploadtext.$$.fragment, local);
31712      current = false;
31713    },
31714    d(detaching) {
31715      destroy_component(uploadtext, detaching);
31716    }
31717  };
31718}
31719function create_if_block_1(ctx) {
31720  let uploadtext;
31721  let current;
31722  uploadtext = new UploadText({
31723    props: {
31724      i18n: (
31725        /*gradio*/
31726        ctx[25].i18n
31727      ),
31728      type: "image",
31729      placeholder: (
31730        /*placeholder*/
31731        ctx[22]
31732      )
31733    }
31734  });
31735  return {
31736    c() {
31737      create_component(uploadtext.$$.fragment);
31738    },
31739    m(target, anchor) {
31740      mount_component(uploadtext, target, anchor);
31741      current = true;
31742    },
31743    p(ctx2, dirty) {
31744      const uploadtext_changes = {};
31745      if (dirty[0] & /*gradio*/
31746      33554432) uploadtext_changes.i18n = /*gradio*/
31747      ctx2[25].i18n;
31748      if (dirty[0] & /*placeholder*/
31749      4194304) uploadtext_changes.placeholder = /*placeholder*/
31750      ctx2[22];
31751      uploadtext.$set(uploadtext_changes);
31752    },
31753    i(local) {
31754      if (current) return;
31755      transition_in(uploadtext.$$.fragment, local);
31756      current = true;
31757    },
31758    o(local) {
31759      transition_out(uploadtext.$$.fragment, local);
31760      current = false;
31761    },
31762    d(detaching) {
31763      destroy_component(uploadtext, detaching);
31764    }
31765  };
31766}
31767function create_default_slot_3(ctx) {
31768  let image;
31769  let current;
31770  image = new Image$1({});
31771  return {
31772    c() {
31773      create_component(image.$$.fragment);
31774    },
31775    m(target, anchor) {
31776      mount_component(image, target, anchor);
31777      current = true;
31778    },
31779    i(local) {
31780      if (current) return;
31781      transition_in(image.$$.fragment, local);
31782      current = true;
31783    },
31784    o(local) {
31785      transition_out(image.$$.fragment, local);
31786      current = false;
31787    },
31788    d(detaching) {
31789      destroy_component(image, detaching);
31790    }
31791  };
31792}
31793function create_default_slot_2(ctx) {
31794  let current_block_type_index;
31795  let if_block;
31796  let if_block_anchor;
31797  let current;
31798  const if_block_creators = [create_if_block_1, create_if_block_2, create_else_block_1];
31799  const if_blocks = [];
31800  function select_block_type_1(ctx2, dirty) {
31801    if (
31802      /*active_source*/
31803      ctx2[30] === "upload" || !/*active_source*/
31804      ctx2[30]
31805    ) return 0;
31806    if (
31807      /*active_source*/
31808      ctx2[30] === "clipboard"
31809    ) return 1;
31810    return 2;
31811  }
31812  current_block_type_index = select_block_type_1(ctx);
31813  if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
31814  return {
31815    c() {
31816      if_block.c();
31817      if_block_anchor = empty();
31818    },
31819    m(target, anchor) {
31820      if_blocks[current_block_type_index].m(target, anchor);
31821      insert(target, if_block_anchor, anchor);
31822      current = true;
31823    },
31824    p(ctx2, dirty) {
31825      let previous_block_index = current_block_type_index;
31826      current_block_type_index = select_block_type_1(ctx2);
31827      if (current_block_type_index === previous_block_index) {
31828        if_blocks[current_block_type_index].p(ctx2, dirty);
31829      } else {
31830        group_outros();
31831        transition_out(if_blocks[previous_block_index], 1, 1, () => {
31832          if_blocks[previous_block_index] = null;
31833        });
31834        check_outros();
31835        if_block = if_blocks[current_block_type_index];
31836        if (!if_block) {
31837          if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
31838          if_block.c();
31839        } else {
31840          if_block.p(ctx2, dirty);
31841        }
31842        transition_in(if_block, 1);
31843        if_block.m(if_block_anchor.parentNode, if_block_anchor);
31844      }
31845    },
31846    i(local) {
31847      if (current) return;
31848      transition_in(if_block);
31849      current = true;
31850    },
31851    o(local) {
31852      transition_out(if_block);
31853      current = false;
31854    },
31855    d(detaching) {
31856      if (detaching) {
31857        detach(if_block_anchor);
31858      }
31859      if_blocks[current_block_type_index].d(detaching);
31860    }
31861  };
31862}
31863function create_default_slot_1(ctx) {
31864  var _a;
31865  let statustracker;
31866  let t;
31867  let imageuploader;
31868  let updating_uploading;
31869  let updating_active_source;
31870  let updating_value;
31871  let updating_dragging;
31872  let updating_modify_stream;
31873  let updating_set_time_limit;
31874  let current;
31875  const statustracker_spread_levels = [
31876    {
31877      autoscroll: (
31878        /*gradio*/
31879        ctx[25].autoscroll
31880      )
31881    },
31882    { i18n: (
31883      /*gradio*/
31884      ctx[25].i18n
31885    ) },
31886    /*loading_status*/
31887    ctx[2]
31888  ];
31889  let statustracker_props = {};
31890  for (let i = 0; i < statustracker_spread_levels.length; i += 1) {
31891    statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]);
31892  }
31893  statustracker = new Static({ props: statustracker_props });
31894  statustracker.$on(
31895    "clear_status",
31896    /*clear_status_handler*/
31897    ctx[44]
31898  );
31899  function imageuploader_uploading_binding(value) {
31900    ctx[47](value);
31901  }
31902  function imageuploader_active_source_binding(value) {
31903    ctx[48](value);
31904  }
31905  function imageuploader_value_binding(value) {
31906    ctx[49](value);
31907  }
31908  function imageuploader_dragging_binding(value) {
31909    ctx[50](value);
31910  }
31911  function imageuploader_modify_stream_binding(value) {
31912    ctx[51](value);
31913  }
31914  function imageuploader_set_time_limit_binding(value) {
31915    ctx[52](value);
31916  }
31917  let imageuploader_props = {
31918    selectable: (
31919      /*_selectable*/
31920      ctx[13]
31921    ),
31922    root: (
31923      /*root*/
31924      ctx[9]
31925    ),
31926    sources: (
31927      /*sources*/
31928      ctx[18]
31929    ),
31930    fullscreen: (
31931      /*fullscreen*/
31932      ctx[28]
31933    ),
31934    label: (
31935      /*label*/
31936      ctx[6]
31937    ),
31938    show_label: (
31939      /*show_label*/
31940      ctx[7]
31941    ),
31942    pending: (
31943      /*pending*/
31944      ctx[21]
31945    ),
31946    streaming: (
31947      /*streaming*/
31948      ctx[20]
31949    ),
31950    webcam_options: (
31951      /*webcam_options*/
31952      ctx[24]
31953    ),
31954    stream_every: (
31955      /*stream_every*/
31956      ctx[12]
31957    ),
31958    max_file_size: (
31959      /*gradio*/
31960      ctx[25].max_file_size
31961    ),
31962    i18n: (
31963      /*gradio*/
31964      ctx[25].i18n
31965    ),
31966    upload: (
31967      /*func*/
31968      ctx[45]
31969    ),
31970    stream_handler: (
31971      /*gradio*/
31972      (_a = ctx[25].client) == null ? void 0 : _a.stream
31973    ),
31974    $$slots: { default: [create_default_slot_2] },
31975    $$scope: { ctx }
31976  };
31977  if (
31978    /*uploading*/
31979    ctx[26] !== void 0
31980  ) {
31981    imageuploader_props.uploading = /*uploading*/
31982    ctx[26];
31983  }
31984  if (
31985    /*active_source*/
31986    ctx[30] !== void 0
31987  ) {
31988    imageuploader_props.active_source = /*active_source*/
31989    ctx[30];
31990  }
31991  if (
31992    /*value*/
31993    ctx[0] !== void 0
31994  ) {
31995    imageuploader_props.value = /*value*/
31996    ctx[0];
31997  }
31998  if (
31999    /*dragging*/
32000    ctx[29] !== void 0
32001  ) {
32002    imageuploader_props.dragging = /*dragging*/
32003    ctx[29];
32004  }
32005  if (
32006    /*_modify_stream*/
32007    ctx[27] !== void 0
32008  ) {
32009    imageuploader_props.modify_stream = /*_modify_stream*/
32010    ctx[27];
32011  }
32012  if (
32013    /*set_time_limit*/
32014    ctx[1] !== void 0
32015  ) {
32016    imageuploader_props.set_time_limit = /*set_time_limit*/
32017    ctx[1];
32018  }
32019  imageuploader = new ImageUploader({ props: imageuploader_props });
32020  ctx[46](imageuploader);
32021  binding_callbacks.push(() => bind(imageuploader, "uploading", imageuploader_uploading_binding));
32022  binding_callbacks.push(() => bind(imageuploader, "active_source", imageuploader_active_source_binding));
32023  binding_callbacks.push(() => bind(imageuploader, "value", imageuploader_value_binding));
32024  binding_callbacks.push(() => bind(imageuploader, "dragging", imageuploader_dragging_binding));
32025  binding_callbacks.push(() => bind(imageuploader, "modify_stream", imageuploader_modify_stream_binding));
32026  binding_callbacks.push(() => bind(imageuploader, "set_time_limit", imageuploader_set_time_limit_binding));
32027  imageuploader.$on(
32028    "edit",
32029    /*edit_handler*/
32030    ctx[53]
32031  );
32032  imageuploader.$on(
32033    "clear",
32034    /*clear_handler*/
32035    ctx[54]
32036  );
32037  imageuploader.$on(
32038    "stream",
32039    /*stream_handler*/
32040    ctx[55]
32041  );
32042  imageuploader.$on(
32043    "drag",
32044    /*drag_handler*/
32045    ctx[56]
32046  );
32047  imageuploader.$on(
32048    "upload",
32049    /*upload_handler*/
32050    ctx[57]
32051  );
32052  imageuploader.$on(
32053    "select",
32054    /*select_handler_1*/
32055    ctx[58]
32056  );
32057  imageuploader.$on(
32058    "share",
32059    /*share_handler_1*/
32060    ctx[59]
32061  );
32062  imageuploader.$on(
32063    "error",
32064    /*error_handler_1*/
32065    ctx[60]
32066  );
32067  imageuploader.$on(
32068    "close_stream",
32069    /*close_stream_handler*/
32070    ctx[61]
32071  );
32072  imageuploader.$on(
32073    "fullscreen",
32074    /*fullscreen_handler_1*/
32075    ctx[62]
32076  );
32077  return {
32078    c() {
32079      create_component(statustracker.$$.fragment);
32080      t = space();
32081      create_component(imageuploader.$$.fragment);
32082    },
32083    m(target, anchor) {
32084      mount_component(statustracker, target, anchor);
32085      insert(target, t, anchor);
32086      mount_component(imageuploader, target, anchor);
32087      current = true;
32088    },
32089    p(ctx2, dirty) {
32090      var _a2;
32091      const statustracker_changes = dirty[0] & /*gradio, loading_status*/
32092      33554436 ? get_spread_update(statustracker_spread_levels, [
32093        dirty[0] & /*gradio*/
32094        33554432 && {
32095          autoscroll: (
32096            /*gradio*/
32097            ctx2[25].autoscroll
32098          )
32099        },
32100        dirty[0] & /*gradio*/
32101        33554432 && { i18n: (
32102          /*gradio*/
32103          ctx2[25].i18n
32104        ) },
32105        dirty[0] & /*loading_status*/
32106        4 && get_spread_object(
32107          /*loading_status*/
32108          ctx2[2]
32109        )
32110      ]) : {};
32111      statustracker.$set(statustracker_changes);
32112      const imageuploader_changes = {};
32113      if (dirty[0] & /*_selectable*/
32114      8192) imageuploader_changes.selectable = /*_selectable*/
32115      ctx2[13];
32116      if (dirty[0] & /*root*/
32117      512) imageuploader_changes.root = /*root*/
32118      ctx2[9];
32119      if (dirty[0] & /*sources*/
32120      262144) imageuploader_changes.sources = /*sources*/
32121      ctx2[18];
32122      if (dirty[0] & /*fullscreen*/
32123      268435456) imageuploader_changes.fullscreen = /*fullscreen*/
32124      ctx2[28];
32125      if (dirty[0] & /*label*/
32126      64) imageuploader_changes.label = /*label*/
32127      ctx2[6];
32128      if (dirty[0] & /*show_label*/
32129      128) imageuploader_changes.show_label = /*show_label*/
32130      ctx2[7];
32131      if (dirty[0] & /*pending*/
32132      2097152) imageuploader_changes.pending = /*pending*/
32133      ctx2[21];
32134      if (dirty[0] & /*streaming*/
32135      1048576) imageuploader_changes.streaming = /*streaming*/
32136      ctx2[20];
32137      if (dirty[0] & /*webcam_options*/
32138      16777216) imageuploader_changes.webcam_options = /*webcam_options*/
32139      ctx2[24];
32140      if (dirty[0] & /*stream_every*/
32141      4096) imageuploader_changes.stream_every = /*stream_every*/
32142      ctx2[12];
32143      if (dirty[0] & /*gradio*/
32144      33554432) imageuploader_changes.max_file_size = /*gradio*/
32145      ctx2[25].max_file_size;
32146      if (dirty[0] & /*gradio*/
32147      33554432) imageuploader_changes.i18n = /*gradio*/
32148      ctx2[25].i18n;
32149      if (dirty[0] & /*gradio*/
32150      33554432) imageuploader_changes.upload = /*func*/
32151      ctx2[45];
32152      if (dirty[0] & /*gradio*/
32153      33554432) imageuploader_changes.stream_handler = /*gradio*/
32154      (_a2 = ctx2[25].client) == null ? void 0 : _a2.stream;
32155      if (dirty[0] & /*gradio, placeholder, active_source*/
32156      1111490560 | dirty[2] & /*$$scope*/
32157      8) {
32158        imageuploader_changes.$$scope = { dirty, ctx: ctx2 };
32159      }
32160      if (!updating_uploading && dirty[0] & /*uploading*/
32161      67108864) {
32162        updating_uploading = true;
32163        imageuploader_changes.uploading = /*uploading*/
32164        ctx2[26];
32165        add_flush_callback(() => updating_uploading = false);
32166      }
32167      if (!updating_active_source && dirty[0] & /*active_source*/
32168      1073741824) {
32169        updating_active_source = true;
32170        imageuploader_changes.active_source = /*active_source*/
32171        ctx2[30];
32172        add_flush_callback(() => updating_active_source = false);
32173      }
32174      if (!updating_value && dirty[0] & /*value*/
32175      1) {
32176        updating_value = true;
32177        imageuploader_changes.value = /*value*/
32178        ctx2[0];
32179        add_flush_callback(() => updating_value = false);
32180      }
32181      if (!updating_dragging && dirty[0] & /*dragging*/
32182      536870912) {
32183        updating_dragging = true;
32184        imageuploader_changes.dragging = /*dragging*/
32185        ctx2[29];
32186        add_flush_callback(() => updating_dragging = false);
32187      }
32188      if (!updating_modify_stream && dirty[0] & /*_modify_stream*/
32189      134217728) {
32190        updating_modify_stream = true;
32191        imageuploader_changes.modify_stream = /*_modify_stream*/
32192        ctx2[27];
32193        add_flush_callback(() => updating_modify_stream = false);
32194      }
32195      if (!updating_set_time_limit && dirty[0] & /*set_time_limit*/
32196      2) {
32197        updating_set_time_limit = true;
32198        imageuploader_changes.set_time_limit = /*set_time_limit*/
32199        ctx2[1];
32200        add_flush_callback(() => updating_set_time_limit = false);
32201      }
32202      imageuploader.$set(imageuploader_changes);
32203    },
32204    i(local) {
32205      if (current) return;
32206      transition_in(statustracker.$$.fragment, local);
32207      transition_in(imageuploader.$$.fragment, local);
32208      current = true;
32209    },
32210    o(local) {
32211      transition_out(statustracker.$$.fragment, local);
32212      transition_out(imageuploader.$$.fragment, local);
32213      current = false;
32214    },
32215    d(detaching) {
32216      if (detaching) {
32217        detach(t);
32218      }
32219      destroy_component(statustracker, detaching);
32220      ctx[46](null);
32221      destroy_component(imageuploader, detaching);
32222    }
32223  };
32224}
32225function create_default_slot$1(ctx) {
32226  let statustracker;
32227  let t;
32228  let staticimage;
32229  let current;
32230  const statustracker_spread_levels = [
32231    {
32232      autoscroll: (
32233        /*gradio*/
32234        ctx[25].autoscroll
32235      )
32236    },
32237    { i18n: (
32238      /*gradio*/
32239      ctx[25].i18n
32240    ) },
32241    /*loading_status*/
32242    ctx[2]
32243  ];
32244  let statustracker_props = {};
32245  for (let i = 0; i < statustracker_spread_levels.length; i += 1) {
32246    statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]);
32247  }
32248  statustracker = new Static({ props: statustracker_props });
32249  staticimage = new ImagePreview({
32250    props: {
32251      fullscreen: (
32252        /*fullscreen*/
32253        ctx[28]
32254      ),
32255      value: (
32256        /*value*/
32257        ctx[0]
32258      ),
32259      label: (
32260        /*label*/
32261        ctx[6]
32262      ),
32263      show_label: (
32264        /*show_label*/
32265        ctx[7]
32266      ),
32267      show_download_button: (
32268        /*show_download_button*/
32269        ctx[8]
32270      ),
32271      selectable: (
32272        /*_selectable*/
32273        ctx[13]
32274      ),
32275      show_share_button: (
32276        /*show_share_button*/
32277        ctx[17]
32278      ),
32279      i18n: (
32280        /*gradio*/
32281        ctx[25].i18n
32282      ),
32283      show_fullscreen_button: (
32284        /*show_fullscreen_button*/
32285        ctx[23]
32286      )
32287    }
32288  });
32289  staticimage.$on(
32290    "select",
32291    /*select_handler*/
32292    ctx[39]
32293  );
32294  staticimage.$on(
32295    "share",
32296    /*share_handler*/
32297    ctx[40]
32298  );
32299  staticimage.$on(
32300    "error",
32301    /*error_handler*/
32302    ctx[41]
32303  );
32304  staticimage.$on(
32305    "fullscreen",
32306    /*fullscreen_handler*/
32307    ctx[42]
32308  );
32309  return {
32310    c() {
32311      create_component(statustracker.$$.fragment);
32312      t = space();
32313      create_component(staticimage.$$.fragment);
32314    },
32315    m(target, anchor) {
32316      mount_component(statustracker, target, anchor);
32317      insert(target, t, anchor);
32318      mount_component(staticimage, target, anchor);
32319      current = true;
32320    },
32321    p(ctx2, dirty) {
32322      const statustracker_changes = dirty[0] & /*gradio, loading_status*/
32323      33554436 ? get_spread_update(statustracker_spread_levels, [
32324        dirty[0] & /*gradio*/
32325        33554432 && {
32326          autoscroll: (
32327            /*gradio*/
32328            ctx2[25].autoscroll
32329          )
32330        },
32331        dirty[0] & /*gradio*/
32332        33554432 && { i18n: (
32333          /*gradio*/
32334          ctx2[25].i18n
32335        ) },
32336        dirty[0] & /*loading_status*/
32337        4 && get_spread_object(
32338          /*loading_status*/
32339          ctx2[2]
32340        )
32341      ]) : {};
32342      statustracker.$set(statustracker_changes);
32343      const staticimage_changes = {};
32344      if (dirty[0] & /*fullscreen*/
32345      268435456) staticimage_changes.fullscreen = /*fullscreen*/
32346      ctx2[28];
32347      if (dirty[0] & /*value*/
32348      1) staticimage_changes.value = /*value*/
32349      ctx2[0];
32350      if (dirty[0] & /*label*/
32351      64) staticimage_changes.label = /*label*/
32352      ctx2[6];
32353      if (dirty[0] & /*show_label*/
32354      128) staticimage_changes.show_label = /*show_label*/
32355      ctx2[7];
32356      if (dirty[0] & /*show_download_button*/
32357      256) staticimage_changes.show_download_button = /*show_download_button*/
32358      ctx2[8];
32359      if (dirty[0] & /*_selectable*/
32360      8192) staticimage_changes.selectable = /*_selectable*/
32361      ctx2[13];
32362      if (dirty[0] & /*show_share_button*/
32363      131072) staticimage_changes.show_share_button = /*show_share_button*/
32364      ctx2[17];
32365      if (dirty[0] & /*gradio*/
32366      33554432) staticimage_changes.i18n = /*gradio*/
32367      ctx2[25].i18n;
32368      if (dirty[0] & /*show_fullscreen_button*/
32369      8388608) staticimage_changes.show_fullscreen_button = /*show_fullscreen_button*/
32370      ctx2[23];
32371      staticimage.$set(staticimage_changes);
32372    },
32373    i(local) {
32374      if (current) return;
32375      transition_in(statustracker.$$.fragment, local);
32376      transition_in(staticimage.$$.fragment, local);
32377      current = true;
32378    },
32379    o(local) {
32380      transition_out(statustracker.$$.fragment, local);
32381      transition_out(staticimage.$$.fragment, local);
32382      current = false;
32383    },
32384    d(detaching) {
32385      if (detaching) {
32386        detach(t);
32387      }
32388      destroy_component(statustracker, detaching);
32389      destroy_component(staticimage, detaching);
32390    }
32391  };
32392}
32393function create_fragment$2(ctx) {
32394  let current_block_type_index;
32395  let if_block;
32396  let if_block_anchor;
32397  let current;
32398  const if_block_creators = [create_if_block, create_else_block];
32399  const if_blocks = [];
32400  function select_block_type(ctx2, dirty) {
32401    if (!/*interactive*/
32402    ctx2[19]) return 0;
32403    return 1;
32404  }
32405  current_block_type_index = select_block_type(ctx);
32406  if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
32407  return {
32408    c() {
32409      if_block.c();
32410      if_block_anchor = empty();
32411    },
32412    m(target, anchor) {
32413      if_blocks[current_block_type_index].m(target, anchor);
32414      insert(target, if_block_anchor, anchor);
32415      current = true;
32416    },
32417    p(ctx2, dirty) {
32418      let previous_block_index = current_block_type_index;
32419      current_block_type_index = select_block_type(ctx2);
32420      if (current_block_type_index === previous_block_index) {
32421        if_blocks[current_block_type_index].p(ctx2, dirty);
32422      } else {
32423        group_outros();
32424        transition_out(if_blocks[previous_block_index], 1, 1, () => {
32425          if_blocks[previous_block_index] = null;
32426        });
32427        check_outros();
32428        if_block = if_blocks[current_block_type_index];
32429        if (!if_block) {
32430          if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
32431          if_block.c();
32432        } else {
32433          if_block.p(ctx2, dirty);
32434        }
32435        transition_in(if_block, 1);
32436        if_block.m(if_block_anchor.parentNode, if_block_anchor);
32437      }
32438    },
32439    i(local) {
32440      if (current) return;
32441      transition_in(if_block);
32442      current = true;
32443    },
32444    o(local) {
32445      transition_out(if_block);
32446      current = false;
32447    },
32448    d(detaching) {
32449      if (detaching) {
32450        detach(if_block_anchor);
32451      }
32452      if_blocks[current_block_type_index].d(detaching);
32453    }
32454  };
32455}
32456function instance$2($$self, $$props, $$invalidate) {
32457  let stream_state = "closed";
32458  let _modify_stream = () => {
32459  };
32460  function modify_stream_state(state) {
32461    stream_state = state;
32462    _modify_stream(state);
32463  }
32464  const get_stream_state = () => stream_state;
32465  let { set_time_limit } = $$props;
32466  let { value_is_output = false } = $$props;
32467  let { elem_id = "" } = $$props;
32468  let { elem_classes = [] } = $$props;
32469  let { visible = true } = $$props;
32470  let { value = null } = $$props;
32471  let old_value = null;
32472  let { label } = $$props;
32473  let { show_label } = $$props;
32474  let { show_download_button } = $$props;
32475  let { root } = $$props;
32476  let { height: height2 } = $$props;
32477  let { width } = $$props;
32478  let { stream_every } = $$props;
32479  let { _selectable = false } = $$props;
32480  let { container = true } = $$props;
32481  let { scale = null } = $$props;
32482  let { min_width = void 0 } = $$props;
32483  let { loading_status } = $$props;
32484  let { show_share_button = false } = $$props;
32485  let { sources = ["upload", "clipboard", "webcam"] } = $$props;
32486  let { interactive } = $$props;
32487  let { streaming } = $$props;
32488  let { pending } = $$props;
32489  let { placeholder = void 0 } = $$props;
32490  let { show_fullscreen_button } = $$props;
32491  let { input_ready } = $$props;
32492  let { webcam_options } = $$props;
32493  let fullscreen = false;
32494  let uploading = false;
32495  let { gradio } = $$props;
32496  afterUpdate(() => {
32497    $$invalidate(34, value_is_output = false);
32498  });
32499  let dragging;
32500  let active_source = null;
32501  let upload_component;
32502  const handle_drag_event = (event) => {
32503    const drag_event = event;
32504    drag_event.preventDefault();
32505    drag_event.stopPropagation();
32506    if (drag_event.type === "dragenter" || drag_event.type === "dragover") {
32507      $$invalidate(29, dragging = true);
32508    } else if (drag_event.type === "dragleave") {
32509      $$invalidate(29, dragging = false);
32510    }
32511  };
32512  const handle_drop = (event) => {
32513    if (interactive) {
32514      const drop_event = event;
32515      drop_event.preventDefault();
32516      drop_event.stopPropagation();
32517      $$invalidate(29, dragging = false);
32518      if (upload_component) {
32519        upload_component.loadFilesFromDrop(drop_event);
32520      }
32521    }
32522  };
32523  const select_handler = ({ detail }) => gradio.dispatch("select", detail);
32524  const share_handler = ({ detail }) => gradio.dispatch("share", detail);
32525  const error_handler = ({ detail }) => gradio.dispatch("error", detail);
32526  const fullscreen_handler = ({ detail }) => {
32527    $$invalidate(28, fullscreen = detail);
32528  };
32529  function block_fullscreen_binding(value2) {
32530    fullscreen = value2;
32531    $$invalidate(28, fullscreen);
32532  }
32533  const clear_status_handler = () => gradio.dispatch("clear_status", loading_status);
32534  const func2 = (...args) => gradio.client.upload(...args);
32535  function imageuploader_binding($$value) {
32536    binding_callbacks[$$value ? "unshift" : "push"](() => {
32537      upload_component = $$value;
32538      $$invalidate(31, upload_component);
32539    });
32540  }
32541  function imageuploader_uploading_binding(value2) {
32542    uploading = value2;
32543    $$invalidate(26, uploading);
32544  }
32545  function imageuploader_active_source_binding(value2) {
32546    active_source = value2;
32547    $$invalidate(30, active_source);
32548  }
32549  function imageuploader_value_binding(value$1) {
32550    value = value$1;
32551    $$invalidate(0, value);
32552  }
32553  function imageuploader_dragging_binding(value2) {
32554    dragging = value2;
32555    $$invalidate(29, dragging);
32556  }
32557  function imageuploader_modify_stream_binding(value2) {
32558    _modify_stream = value2;
32559    $$invalidate(27, _modify_stream);
32560  }
32561  function imageuploader_set_time_limit_binding(value2) {
32562    set_time_limit = value2;
32563    $$invalidate(1, set_time_limit);
32564  }
32565  const edit_handler = () => gradio.dispatch("edit");
32566  const clear_handler = () => {
32567    $$invalidate(28, fullscreen = false);
32568    gradio.dispatch("clear");
32569  };
32570  const stream_handler = ({ detail }) => gradio.dispatch("stream", detail);
32571  const drag_handler = ({ detail }) =>
32571 $$invalidate(29, dragging = detail);
32572  const upload_handler = () => gradio.dispatch("upload");
32573  const select_handler_1 = ({ detail }) => gradio.dispatch("select", detail);
32574  const share_handler_1 = ({ detail }) => gradio.dispatch("share", detail);
32575  const error_handler_1 = ({ detail }) => {
32576    $$invalidate(2, loading_status = loading_status || {});
32577    $$invalidate(2, loading_status.status = "error", loading_status);
32578    gradio.dispatch("error", detail);
32579  };
32580  const close_stream_handler = () => {
32581    gradio.dispatch("close_stream", "stream");
32582  };
32583  const fullscreen_handler_1 = ({ detail }) => {
32584    $$invalidate(28, fullscreen = detail);
32585  };
32586  function block_fullscreen_binding_1(value2) {
32587    fullscreen = value2;
32588    $$invalidate(28, fullscreen);
32589  }
32590  $$self.$$set = ($$props2) => {
32591    if ("set_time_limit" in $$props2) $$invalidate(1, set_time_limit = $$props2.set_time_limit);
32592    if ("value_is_output" in $$props2) $$invalidate(34, value_is_output = $$props2.value_is_output);
32593    if ("elem_id" in $$props2) $$invalidate(3, elem_id = $$props2.elem_id);
32594    if ("elem_classes" in $$props2) $$invalidate(4, elem_classes = $$props2.elem_classes);
32595    if ("visible" in $$props2) $$invalidate(5, visible = $$props2.visible);
32596    if ("value" in $$props2) $$invalidate(0, value = $$props2.value);
32597    if ("label" in $$props2) $$invalidate(6, label = $$props2.label);
32598    if ("show_label" in $$props2) $$invalidate(7, show_label = $$props2.show_label);
32599    if ("show_download_button" in $$props2) $$invalidate(8, show_download_button = $$props2.show_download_button);
32600    if ("root" in $$props2) $$invalidate(9, root = $$props2.root);
32601    if ("height" in $$props2) $$invalidate(10, height2 = $$props2.height);
32602    if ("width" in $$props2) $$invalidate(11, width = $$props2.width);
32603    if ("stream_every" in $$props2) $$invalidate(12, stream_every = $$props2.stream_every);
32604    if ("_selectable" in $$props2) $$invalidate(13, _selectable = $$props2._selectable);
32605    if ("container" in $$props2) $$invalidate(14, container = $$props2.container);
32606    if ("scale" in $$props2) $$invalidate(15, scale = $$props2.scale);
32607    if ("min_width" in $$props2) $$invalidate(16, min_width = $$props2.min_width);
32608    if ("loading_status" in $$props2) $$invalidate(2, loading_status = $$props2.loading_status);
32609    if ("show_share_button" in $$props2) $$invalidate(17, show_share_button = $$props2.show_share_button);
32610    if ("sources" in $$props2) $$invalidate(18, sources = $$props2.sources);
32611    if ("interactive" in $$props2) $$invalidate(19, interactive = $$props2.interactive);
32612    if ("streaming" in $$props2) $$invalidate(20, streaming = $$props2.streaming);
32613    if ("pending" in $$props2) $$invalidate(21, pending = $$props2.pending);
32614    if ("placeholder" in $$props2) $$invalidate(22, placeholder = $$props2.placeholder);
32615    if ("show_fullscreen_button" in $$props2) $$invalidate(23, show_fullscreen_button = $$props2.show_fullscreen_button);
32616    if ("input_ready" in $$props2) $$invalidate(35, input_ready = $$props2.input_ready);
32617    if ("webcam_options" in $$props2) $$invalidate(24, webcam_options = $$props2.webcam_options);
32618    if ("gradio" in $$props2) $$invalidate(25, gradio = $$props2.gradio);
32619  };
32620  $$self.$$.update = () => {
32621    if ($$self.$$.dirty[0] & /*uploading*/
32622    67108864) {
32623      $$invalidate(35, input_ready = !uploading);
32624    }
32625    if ($$self.$$.dirty[0] & /*value, gradio*/
32626    33554433 | $$self.$$.dirty[1] & /*old_value, value_is_output*/
32627    136) {
32628      {
32629        if (JSON.stringify(value) !== JSON.stringify(old_value)) {
32630          $$invalidate(38, old_value = value);
32631          gradio.dispatch("change");
32632          if (!value_is_output) {
32633            gradio.dispatch("input");
32634          }
32635        }
32636      }
32637    }
32638  };
32639  return [
32640    value,
32641    set_time_limit,
32642    loading_status,
32643    elem_id,
32644    elem_classes,
32645    visible,
32646    label,
32647    show_label,
32648    show_download_button,
32649    root,
32650    height2,
32651    width,
32652    stream_every,
32653    _selectable,
32654    container,
32655    scale,
32656    min_width,
32657    show_share_button,
32658    sources,
32659    interactive,
32660    streaming,
32661    pending,
32662    placeholder,
32663    show_fullscreen_button,
32664    webcam_options,
32665    gradio,
32666    uploading,
32667    _modify_stream,
32668    fullscreen,
32669    dragging,
32670    active_source,
32671    upload_component,
32672    handle_drag_event,
32673    handle_drop,
32674    value_is_output,
32675    input_ready,
32676    modify_stream_state,
32677    get_stream_state,
32678    old_value,
32679    select_handler,
32680    share_handler,
32681    error_handler,
32682    fullscreen_handler,
32683    block_fullscreen_binding,
32684    clear_status_handler,
32685    func2,
32686    imageuploader_binding,
32687    imageuploader_uploading_binding,
32688    imageuploader_active_source_binding,
32689    imageuploader_value_binding,
32690    imageuploader_dragging_binding,
32691    imageuploader_modify_stream_binding,
32692    imageuploader_set_time_limit_binding,
32693    edit_handler,
32694    clear_handler,
32695    stream_handler,
32696    drag_handler,
32697    upload_handler,
32698    select_handler_1,
32699    share_handler_1,
32700    error_handler_1,
32701    close_stream_handler,
32702    fullscreen_handler_1,
32703    block_fullscreen_binding_1
32704  ];
32705}
32706let Index$2 = class Index extends SvelteComponent {
32707  constructor(options) {
32708    super();
32709    init(
32710      this,
32711      options,
32712      instance$2,
32713      create_fragment$2,
32714      safe_not_equal,
32715      {
32716        modify_stream_state: 36,
32717        get_stream_state: 37,
32718        set_time_limit: 1,
32719        value_is_output: 34,
32720        elem_id: 3,
32721        elem_classes: 4,
32722        visible: 5,
32723        value: 0,
32724        label: 6,
32725        show_label: 7,
32726        show_download_button: 8,
32727        root: 9,
32728        height: 10,
32729        width: 11,
32730        stream_every: 12,
32731        _selectable: 13,
32732        container: 14,
32733        scale: 15,
32734        min_width: 16,
32735        loading_status: 2,
32736        show_share_button: 17,
32737        sources: 18,
32738        interactive: 19,
32739        streaming: 20,
32740        pending: 21,
32741        placeholder: 22,
32742        show_fullscreen_button: 23,
32743        input_ready: 35,
32744        webcam_options: 24,
32745        gradio: 25
32746      },
32747      null,
32748      [-1, -1, -1]
32749    );
32750  }
32751  get modify_stream_state() {
32752    return this.$$.ctx[36];
32753  }
32754  get get_stream_state() {
32755    return this.$$.ctx[37];
32756  }
32757  get set_time_limit() {
32758    return this.$$.ctx[1];
32759  }
32760  set set_time_limit(set_time_limit) {
32761    this.$$set({ set_time_limit });
32762    flush();
32763  }
32764  get value_is_output() {
32765    return this.$$.ctx[34];
32766  }
32767  set value_is_output(value_is_output) {
32768    this.$$set({ value_is_output });
32769    flush();
32770  }
32771  get elem_id() {
32772    return this.$$.ctx[3];
32773  }
32774  set elem_id(elem_id) {
32775    this.$$set({ elem_id });
32776    flush();
32777  }
32778  get elem_classes() {
32779    return this.$$.ctx[4];
32780  }
32781  set elem_classes(elem_classes) {
32782    this.$$set({ elem_classes });
32783    flush();
32784  }
32785  get visible() {
32786    return this.$$.ctx[5];
32787  }
32788  set visible(visible) {
32789    this.$$set({ visible });
32790    flush();
32791  }
32792  get value() {
32793    return this.$$.ctx[0];
32794  }
32795  set value(value) {
32796    this.$$set({ value });
32797    flush();
32798  }
32799  get label() {
32800    return this.$$.ctx[6];
32801  }
32802  set label(label) {
32803    this.$$set({ label });
32804    flush();
32805  }
32806  get show_label() {
32807    return this.$$.ctx[7];
32808  }
32809  set show_label(show_label) {
32810    this.$$set({ show_label });
32811    flush();
32812  }
32813  get show_download_button() {
32814    return this.$$.ctx[8];
32815  }
32816  set show_download_button(show_download_button) {
32817    this.$$set({ show_download_button });
32818    flush();
32819  }
32820  get root() {
32821    return this.$$.ctx[9];
32822  }
32823  set root(root) {
32824    this.$$set({ root });
32825    flush();
32826  }
32827  get height() {
32828    return this.$$.ctx[10];
32829  }
32830  set height(height2) {
32831    this.$$set({ height: height2 });
32832    flush();
32833  }
32834  get width() {
32835    return this.$$.ctx[11];
32836  }
32837  set width(width) {
32838    this.$$set({ width });
32839    flush();
32840  }
32841  get stream_every() {
32842    return this.$$.ctx[12];
32843  }
32844  set stream_every(stream_every) {
32845    this.$$set({ stream_every });
32846    flush();
32847  }
32848  get _selectable() {
32849    return this.$$.ctx[13];
32850  }
32851  set _selectable(_selectable) {
32852    this.$$set({ _selectable });
32853    flush();
32854  }
32855  get container() {
32856    return this.$$.ctx[14];
32857  }
32858  set container(container) {
32859    this.$$set({ container });
32860    flush();
32861  }
32862  get scale() {
32863    return this.$$.ctx[15];
32864  }
32865  set scale(scale) {
32866    this.$$set({ scale });
32867    flush();
32868  }
32869  get min_width() {
32870    return this.$$.ctx[16];
32871  }
32872  set min_width(min_width) {
32873    this.$$set({ min_width });
32874    flush();
32875  }
32876  get loading_status() {
32877    return this.$$.ctx[2];
32878  }
32879  set loading_status(loading_status) {
32880    this.$$set({ loading_status });
32881    flush();
32882  }
32883  get show_share_button() {
32884    return this.$$.ctx[17];
32885  }
32886  set show_share_button(show_share_button) {
32887    this.$$set({ show_share_button });
32888    flush();
32889  }
32890  get sources() {
32891    return this.$$.ctx[18];
32892  }
32893  set sources(sources) {
32894    this.$$set({ sources });
32895    flush();
32896  }
32897  get interactive() {
32898    return this.$$.ctx[19];
32899  }
32900  set interactive(interactive) {
32901    this.$$set({ interactive });
32902    flush();
32903  }
32904  get streaming() {
32905    return this.$$.ctx[20];
32906  }
32907  set streaming(streaming) {
32908    this.$$set({ streaming });
32909    flush();
32910  }
32911  get pending() {
32912    return this.$$.ctx[21];
32913  }
32914  set pending(pending) {
32915    this.$$set({ pending });
32916    flush();
32917  }
32918  get placeholder() {
32919    return this.$$.ctx[22];
32920  }
32921  set placeholder(placeholder) {
32922    this.$$set({ placeholder });
32923    flush();
32924  }
32925  get show_fullscreen_button() {
32926    return this.$$.ctx[23];
32927  }
32928  set show_fullscreen_button(show_fullscreen_button) {
32929    this.$$set({ show_fullscreen_button });
32930    flush();
32931  }
32932  get input_ready() {
32933    return this.$$.ctx[35];
32934  }
32935  set input_ready(input_ready) {
32936    this.$$set({ input_ready });
32937    flush();
32938  }
32939  get webcam_options() {
32940    return this.$$.ctx[24];
32941  }
32942  set webcam_options(webcam_options) {
32943    this.$$set({ webcam_options });
32944    flush();
32945  }
32946  get gradio() {
32947    return this.$$.ctx[25];
32948  }
32949  set gradio(gradio) {
32950    this.$$set({ gradio });
32951    flush();
32952  }
32953};
32954function create_default_slot(ctx) {
32955  var _a, _b;
32956  let statustracker;
32957  let t;
32958  let table;
32959  let updating_value_is_output;
32960  let current;
32961  const statustracker_spread_levels = [
32962    {
32963      autoscroll: (
32964        /*gradio*/
32965        ctx[17].autoscroll
32966      )
32967    },
32968    { i18n: (
32969      /*gradio*/
32970      ctx[17].i18n
32971    ) },
32972    /*loading_status*/
32973    ctx[20]
32974  ];
32975  let statustracker_props = {};
32976  for (let i = 0; i < statustracker_spread_levels.length; i += 1) {
32977    statustracker_props = assign(statustracker_props, statustracker_spread_levels[i]);
32978  }
32979  statustracker = new Static({ props: statustracker_props });
32980  statustracker.$on(
32981    "clear_status",
32982    /*clear_status_handler*/
32983    ctx[29]
32984  );
32985  function table_value_is_output_binding(value) {
32986    ctx[32](value);
32987  }
32988  let table_props = {
32989    root: (
32990      /*root*/
32991      ctx[14]
32992    ),
32993    label: (
32994      /*label*/
32995      ctx[8]
32996    ),
32997    show_label: (
32998      /*show_label*/
32999      ctx[9]
33000    ),
33001    row_count: (
33002      /*row_count*/
33003      ctx[7]
33004    ),
33005    col_count: (
33006      /*col_count*/
33007      ctx[6]
33008    ),
33009    values: (
33010      /*value*/
33011      ctx[0].data
33012    ),
33013    display_value: (
33014      /*value*/
33015      (_a = ctx[0].metadata) == null ? void 0 : _a.display_value
33016    ),
33017    styling: (
33018      /*value*/
33019      (_b = ctx[0].metadata) == null ? void 0 : _b.styling
33020    ),
33021    headers: (
33022      /*value*/
33023      ctx[0].headers
33024    ),
33025    fullscreen: (
33026      /*fullscreen*/
33027      ctx[2]
33028    ),
33029    wrap: (
33030      /*wrap*/
33031      ctx[10]
33032    ),
33033    datatype: (
33034      /*datatype*/
33035      ctx[11]
33036    ),
33037    latex_delimiters: (
33038      /*latex_delimiters*/
33039      ctx[18]
33040    ),
33041    editable: (
33042      /*interactive*/
33043      ctx[21]
33044    ),
33045    max_height: (
33046      /*max_height*/
33047      ctx[19]
33048    ),
33049    i18n: (
33050      /*gradio*/
33051      ctx[17].i18n
33052    ),
33053    line_breaks: (
33054      /*line_breaks*/
33055      ctx[15]
33056    ),
33057    column_widths: (
33058      /*column_widths*/
33059      ctx[16]
33060    ),
33061    upload: (
33062      /*func*/
33063      ctx[30]
33064    ),
33065    stream_handler: (
33066      /*func_1*/
33067      ctx[31]
33068    ),
33069    show_fullscreen_button: (
33070      /*show_fullscreen_button*/
33071      ctx[22]
33072    ),
33073    max_chars: (
33074      /*max_chars*/
33075      ctx[23]
33076    ),
33077    show_copy_button: (
33078      /*show_copy_button*/
33079      ctx[24]
33080    ),
33081    show_row_numbers: (
33082      /*show_row_numbers*/
33083      ctx[25]
33084    ),
33085    show_search: (
33086      /*show_search*/
33087      ctx[26]
33088    ),
33089    pinned_columns: (
33090      /*pinned_columns*/
33091      ctx[27]
33092    ),
33093    components: { image: Index$2 },
33094    static_columns: (
33095      /*static_columns*/
33096      ctx[28]
33097    )
33098  };
33099  if (
33100    /*value_is_output*/
33101    ctx[1] !== void 0
33102  ) {
33103    table_props.value_is_output = /*value_is_output*/
33104    ctx[1];
33105  }
33106  table = new Table$1({ props: table_props });
33107  binding_callbacks.push(() => bind(table, "value_is_output", table_value_is_output_binding));
33108  table.$on(
33109    "change",
33110    /*change_handler*/
33111    ctx[33]
33112  );
33113  table.$on(
33114    "input",
33115    /*input_handler*/
33116    ctx[34]
33117  );
33118  table.$on(
33119    "select",
33120    /*select_handler*/
33121    ctx[35]
33122  );
33123  table.$on(
33124    "edit",
33125    /*edit_handler*/
33126    ctx[36]
33127  );
33128  table.$on(
33129    "fullscreen",
33130    /*fullscreen_handler*/
33131    ctx[37]
33132  );
33133  return {
33134    c() {
33135      create_component(statustracker.$$.fragment);
33136      t = space();
33137      create_component(table.$$.fragment);
33138    },
33139    m(target, anchor) {
33140      mount_component(statustracker, target, anchor);
33141      insert(target, t, anchor);
33142      mount_component(table, target, anchor);
33143      current = true;
33144    },
33145    p(ctx2, dirty) {
33146      var _a2, _b2;
33147      const statustracker_changes = dirty[0] & /*gradio, loading_status*/
33148      1179648 ? get_spread_update(statustracker_spread_levels, [
33149        dirty[0] & /*gradio*/
33150        131072 && {
33151          autoscroll: (
33152            /*gradio*/
33153            ctx2[17].autoscroll
33154          )
33155        },
33156        dirty[0] & /*gradio*/
33157        131072 && { i18n: (
33158          /*gradio*/
33159          ctx2[17].i18n
33160        ) },
33161        dirty[0] & /*loading_status*/
33162        1048576 && get_spread_object(
33163          /*loading_status*/
33164          ctx2[20]
33165        )
33166      ]) : {};
33167      statustracker.$set(statustracker_changes);
33168      const table_changes = {};
33169      if (dirty[0] & /*root*/
33170      16384) table_changes.root = /*root*/
33171      ctx2[14];
33172      if (dirty[0] & /*label*/
33173      256) table_changes.label = /*label*/
33174      ctx2[8];
33175      if (dirty[0] & /*show_label*/
33176      512) table_changes.show_label = /*show_label*/
33177      ctx2[9];
33178      if (dirty[0] & /*row_count*/
33179      128) table_changes.row_count = /*row_count*/
33180      ctx2[7];
33181      if (dirty[0] & /*col_count*/
33182      64) table_changes.col_count = /*col_count*/
33183      ctx2[6];
33184      if (dirty[0] & /*value*/
33185      1) table_changes.values = /*value*/
33186      ctx2[0].data;
33187      if (dirty[0] & /*value*/
33188      1) table_changes.display_value = /*value*/
33189      (_a2 = ctx2[0].metadata) == null ? void 0 : _a2.display_value;
33190      if (dirty[0] & /*value*/
33191      1) table_changes.styling = /*value*/
33192      (_b2 = ctx2[0].metadata) == null ? void 0 : _b2.styling;
33193      if (dirty[0] & /*value*/
33194      1) table_changes.headers = /*value*/
33195      ctx2[0].headers;
33196      if (dirty[0] & /*fullscreen*/
33197      4) table_changes.fullscreen = /*fullscreen*/
33198      ctx2[2];
33199      if (dirty[0] & /*wrap*/
33200      1024) table_changes.wrap = /*wrap*/
33201      ctx2[10];
33202      if (dirty[0] & /*datatype*/
33203      2048) table_changes.datatype = /*datatype*/
33204      ctx2[11];
33205      if (dirty[0] & /*latex_delimiters*/
33206      262144) table_changes.latex_delimiters = /*latex_delimiters*/
33207      ctx2[18];
33208      if (dirty[0] & /*interactive*/
33209      2097152) table_changes.editable = /*interactive*/
33210      ctx2[21];
33211      if (dirty[0] & /*max_height*/
33212      524288) table_changes.max_height = /*max_height*/
33213      ctx2[19];
33214      if (dirty[0] & /*gradio*/
33215      131072) table_changes.i18n = /*gradio*/
33216      ctx2[17].i18n;
33217      if (dirty[0] & /*line_breaks*/
33218      32768) table_changes.line_breaks = /*line_breaks*/
33219      ctx2[15];
33220      if (dirty[0] & /*column_widths*/
33221      65536) table_changes.column_widths = /*column_widths*/
33222      ctx2[16];
33223      if (dirty[0] & /*gradio*/
33224      131072) table_changes.upload = /*func*/
33225      ctx2[30];
33226      if (dirty[0] & /*gradio*/
33227      131072) table_changes.stream_handler = /*func_1*/
33228      ctx2[31];
33229      if (dirty[0] & /*show_fullscreen_button*/
33230      4194304) table_changes.show_fullscreen_button = /*show_fullscreen_button*/
33231      ctx2[22];
33232      if (dirty[0] & /*max_chars*/
33233      8388608) table_changes.max_chars = /*max_chars*/
33234      ctx2[23];
33235      if (dirty[0] & /*show_copy_button*/
33236      16777216) table_changes.show_copy_button = /*show_copy_button*/
33237      ctx2[24];
33238      if (dirty[0] & /*show_row_numbers*/
33239      33554432) table_changes.show_row_numbers = /*show_row_numbers*/
33240      ctx2[25];
33241      if (dirty[0] & /*show_search*/
33242      67108864) table_changes.show_search = /*show_search*/
33243      ctx2[26];
33244      if (dirty[0] & /*pinned_columns*/
33245      134217728) table_changes.pinned_columns = /*pinned_columns*/
33246      ctx2[27];
33247      if (dirty[0] & /*static_columns*/
33248      268435456) table_changes.static_columns = /*static_columns*/
33249      ctx2[28];
33250      if (!updating_value_is_output && dirty[0] & /*value_is_output*/
33251      2) {
33252        updating_value_is_output = true;
33253        table_changes.value_is_output = /*value_is_output*/
33254        ctx2[1];
33255        add_flush_callback(() => updating_value_is_output = false);
33256      }
33257      table.$set(table_changes);
33258    },
33259    i(local) {
33260      if (current) return;
33261      transition_in(statustracker.$$.fragment, local);
33262      transition_in(table.$$.fragment, local);
33263      current = true;
33264    },
33265    o(local) {
33266      transition_out(statustracker.$$.fragment, local);
33267      transition_out(table.$$.fragment, local);
33268      current = false;
33269    },
33270    d(detaching) {
33271      if (detaching) {
33272        detach(t);
33273      }
33274      destroy_component(statustracker, detaching);
33275      destroy_component(table, detaching);
33276    }
33277  };
33278}
33279function create_fragment$1(ctx) {
33280  let block2;
33281  let updating_fullscreen;
33282  let current;
33283  function block_fullscreen_binding(value) {
33284    ctx[38](value);
33285  }
33286  let block_props = {
33287    visible: (
33288      /*visible*/
33289      ctx[5]
33290    ),
33291    padding: false,
33292    elem_id: (
33293      /*elem_id*/
33294      ctx[3]
33295    ),
33296    elem_classes: (
33297      /*elem_classes*/
33298      ctx[4]
33299    ),
33300    container: false,
33301    scale: (
33302      /*scale*/
33303      ctx[12]
33304    ),
33305    min_width: (
33306      /*min_width*/
33307      ctx[13]
33308    ),
33309    overflow_behavior: "visible",
33310    $$slots: { default: [create_default_slot] },
33311    $$scope: { ctx }
33312  };
33313  if (
33314    /*fullscreen*/
33315    ctx[2] !== void 0
33316  ) {
33317    block_props.fullscreen = /*fullscreen*/
33318    ctx[2];
33319  }
33320  block2 = new Block({ props: block_props });
33321  binding_callbacks.push(() => bind(block2, "fullscreen", block_fullscreen_binding));
33322  return {
33323    c() {
33324      create_component(block2.$$.fragment);
33325    },
33326    m(target, anchor) {
33327      mount_component(block2, target, anchor);
33328      current = true;
33329    },
33330    p(ctx2, dirty) {
33331      const block_changes = {};
33332      if (dirty[0] & /*visible*/
33333      32) block_changes.visible = /*visible*/
33334      ctx2[5];
33335      if (dirty[0] & /*elem_id*/
33336      8) block_changes.elem_id = /*elem_id*/
33337      ctx2[3];
33338      if (dirty[0] & /*elem_classes*/
33339      16) block_changes.elem_classes = /*elem_classes*/
33340      ctx2[4];
33341      if (dirty[0] & /*scale*/
33342      4096) block_changes.scale = /*scale*/
33343      ctx2[12];
33344      if (dirty[0] & /*min_width*/
33345      8192) block_changes.min_width = /*min_width*/
33346      ctx2[13];
33347      if (dirty[0] & /*root, label, show_label, row_count, col_count, value, fullscreen, wrap, datatype, latex_delimiters, interactive, max_height, gradio, line_breaks, column_widths, show_fullscreen_button, max_chars, show_copy_button, show_row_numbers, show_search, pinned_columns, static_columns, value_is_output, loading_status*/
33348      536858567 | dirty[1] & /*$$scope*/
33349      256) {
33350        block_changes.$$scope = { dirty, ctx: ctx2 };
33351      }
33352      if (!updating_fullscreen && dirty[0] & /*fullscreen*/
33353      4) {
33354        updating_fullscreen = true;
33355        block_changes.fullscreen = /*fullscreen*/
33356        ctx2[2];
33357        add_flush_callback(() => updating_fullscreen = false);
33358      }
33359      block2.$set(block_changes);
33360    },
33361    i(local) {
33362      if (current) return;
33363      transition_in(block2.$$.fragment, local);
33364      current = true;
33365    },
33366    o(local) {
33367      transition_out(block2.$$.fragment, local);
33368      current = false;
33369    },
33370    d(detaching) {
33371      destroy_component(block2, detaching);
33372    }
33373  };
33374}
33375function instance$1($$self, $$props, $$invalidate) {
33376  let { elem_id = "" } = $$props;
33377  let { elem_classes = [] } = $$props;
33378  let { visible = true } = $$props;
33379  let { value = {
33380    data: [["", "", ""]],
33381    headers: ["1", "2", "3"],
33382    metadata: null
33383  } } = $$props;
33384  let { value_is_output = false } = $$props;
33385  let { col_count } = $$props;
33386  let { row_count } = $$props;
33387  let { label = null } = $$props;
33388  let { show_label = true } = $$props;
33389  let { wrap } = $$props;
33390  let { datatype } = $$props;
33391  let { scale = null } = $$props;
33392  let { min_width = void 0 } = $$props;
33393  let { root } = $$props;
33394  let { line_breaks = true } = $$props;
33395  let { column_widths = [] } = $$props;
33396  let { gradio } = $$props;
33397  let { latex_delimiters } = $$props;
33398  let { max_height = void 0 } = $$props;
33399  let { loading_status } = $$props;
33400  let { interactive } = $$props;
33401  let { show_fullscreen_button = false } = $$props;
33402  let { max_chars = void 0 } = $$props;
33403  let { show_copy_button = false } = $$props;
33404  let { show_row_numbers = false } = $$props;
33405  let { show_search = "none" } = $$props;
33406  let { pinned_columns = 0 } = $$props;
33407  let { static_columns = [] } = $$props;
33408  let { fullscreen = false } = $$props;
33409  const clear_status_handler = () => gradio.dispatch("clear_status", loading_status);
33410  const func2 = (...args) => gradio.client.upload(...args);
33411  const func_1 = (...args) => gradio.client.stream(...args);
33412  function table_value_is_output_binding(value2) {
33413    value_is_output = value2;
33414    $$invalidate(1, value_is_output);
33415  }
33416  const change_handler = (e) => {
33417    $$invalidate(0, value.data = e.detail.data, value);
33418    $$invalidate(0, value.headers = e.detail.headers, value);
33419    gradio.dispatch("change");
33420  };
33421  const input_handler = (e) => gradio.dispatch("input");
33422  const select_handler = (e) => gradio.dispatch("select", e.detail);
33423  const edit_handler = (e) => gradio.dispatch("edit", e.detail);
33424  const fullscreen_handler = ({ detail }) => {
33425    $$invalidate(2, fullscreen = detail);
33426  };
33427  function block_fullscreen_binding(value2) {
33428    fullscreen = value2;
33429    $$invalidate(2, fullscreen);
33430  }
33431  $$self.$$set = ($$props2) => {
33432    if ("elem_id" in $$props2) $$invalidate(3, elem_id = $$props2.elem_id);
33433    if ("elem_classes" in $$props2) $$invalidate(4, elem_classes = $$props2.elem_classes);
33434    if ("visible" in $$props2) $$invalidate(5, visible = $$props2.visible);
33435    if ("value" in $$props2) $$invalidate(0, value = $$props2.value);
33436    if ("value_is_output" in $$props2) $$invalidate(1, value_is_output = $$props2.value_is_output);
33437    if ("col_count" in $$props2) $$invalidate(6, col_count = $$props2.col_count);
33438    if ("row_count" in $$props2) $$invalidate(7, row_count = $$props2.row_count);
33439    if ("label" in $$props2) $$invalidate(8, label = $$props2.label);
33440    if ("show_label" in $$props2) $$invalidate(9, show_label = $$props2.show_label);
33441    if ("wrap" in $$props2) $$invalidate(10, wrap = $$props2.wrap);
33442    if ("datatype" in $$props2) $$invalidate(11, datatype = $$props2.datatype);
33443    if ("scale" in $$props2) $$invalidate(12, scale = $$props2.scale);
33444    if ("min_width" in $$props2) $$invalidate(13, min_width = $$props2.min_width);
33445    if ("root" in $$props2) $$invalidate(14, root = $$props2.root);
33446    if ("line_breaks" in $$props2) $$invalidate(15, line_breaks = $$props2.line_breaks);
33447    if ("column_widths" in $$props2) $$invalidate(16, column_widths = $$props2.column_widths);
33448    if ("gradio" in $$props2) $$invalidate(17, gradio = $$props2.gradio);
33449    if ("latex_delimiters" in $$props2) $$invalidate(18, latex_delimiters = $$props2.latex_delimiters);
33450    if ("max_height" in $$props2) $$invalidate(19, max_height = $$props2.max_height);
33451    if ("loading_status" in $$props2) $$invalidate(20, loading_status = $$props2.loading_status);
33452    if ("interactive" in $$props2) $$invalidate(21, interactive = $$props2.interactive);
33453    if ("show_fullscreen_button" in $$props2) $$invalidate(22, show_fullscreen_button = $$props2.show_fullscreen_button);
33454    if ("max_chars" in $$props2) $$invalidate(23, max_chars = $$props2.max_chars);
33455    if ("show_copy_button" in $$props2) $$invalidate(24, show_copy_button = $$props2.show_copy_button);
33456    if ("show_row_numbers" in $$props2) $$invalidate(25, show_row_numbers = $$props2.show_row_numbers);
33457    if ("show_search" in $$props2) $$invalidate(26, show_search = $$props2.show_search);
33458    if ("pinned_columns" in $$props2) $$invalidate(27, pinned_columns = $$props2.pinned_columns);
33459    if ("static_columns" in $$props2) $$invalidate(28, static_columns = $$props2.static_columns);
33460    if ("fullscreen" in $$props2) $$invalidate(2, fullscreen = $$props2.fullscreen);
33461  };
33462  return [
33463    value,
33464    value_is_output,
33465    fullscreen,
33466    elem_id,
33467    elem_classes,
33468    visible,
33469    col_count,
33470    row_count,
33471    label,
33472    show_label,
33473    wrap,
33474    datatype,
33475    scale,
33476    min_width,
33477    root,
33478    line_breaks,
33479    column_widths,
33480    gradio,
33481    latex_delimiters,
33482    max_height,
33483    loading_status,
33484    interactive,
33485    show_fullscreen_button,
33486    max_chars,
33487    show_copy_button,
33488    show_row_numbers,
33489    show_search,
33490    pinned_columns,
33491    static_columns,
33492    clear_status_handler,
33493    func2,
33494    func_1,
33495    table_value_is_output_binding,
33496    change_handler,
33497    input_handler,
33498    select_handler,
33499    edit_handler,
33500    fullscreen_handler,
33501    block_fullscreen_binding
33502  ];
33503}
33504let Index$1$1 = class Index2 extends SvelteComponent {
33505  constructor(options) {
33506    super();
33507    init(
33508      this,
33509      options,
33510      instance$1,
33511      create_fragment$1,
33512      safe_not_equal,
33513      {
33514        elem_id: 3,
33515        elem_classes: 4,
33516        visible: 5,
33517        value: 0,
33518        value_is_output: 1,
33519        col_count: 6,
33520        row_count: 7,
33521        label: 8,
33522        show_label: 9,
33523        wrap: 10,
33524        datatype: 11,
33525        scale: 12,
33526        min_width: 13,
33527        root: 14,
33528        line_breaks: 15,
33529        column_widths: 16,
33530        gradio: 17,
33531        latex_delimiters: 18,
33532        max_height: 19,
33533        loading_status: 20,
33534        interactive: 21,
33535        show_fullscreen_button: 22,
33536        max_chars: 23,
33537        show_copy_button: 24,
33538        show_row_numbers: 25,
33539        show_search: 26,
33540        pinned_columns: 27,
33541        static_columns: 28,
33542        fullscreen: 2
33543      },
33544      null,
33545      [-1, -1]
33546    );
33547  }
33548  get elem_id() {
33549    return this.$$.ctx[3];
33550  }
33551  set elem_id(elem_id) {
33552    this.$$set({ elem_id });
33553    flush();
33554  }
33555  get elem_classes() {
33556    return this.$$.ctx[4];
33557  }
33558  set elem_classes(elem_classes) {
33559    this.$$set({ elem_classes });
33560    flush();
33561  }
33562  get visible() {
33563    return this.$$.ctx[5];
33564  }
33565  set visible(visible) {
33566    this.$$set({ visible });
33567    flush();
33568  }
33569  get value() {
33570    return this.$$.ctx[0];
33571  }
33572  set value(value) {
33573    this.$$set({ value });
33574    flush();
33575  }
33576  get value_is_output() {
33577    return this.$$.ctx[1];
33578  }
33579  set value_is_output(value_is_output) {
33580    this.$$set({ value_is_output });
33581    flush();
33582  }
33583  get col_count() {
33584    return this.$$.ctx[6];
33585  }
33586  set col_count(col_count) {
33587    this.$$set({ col_count });
33588    flush();
33589  }
33590  get row_count() {
33591    return this.$$.ctx[7];
33592  }
33593  set row_count(row_count) {
33594    this.$$set({ row_count });
33595    flush();
33596  }
33597  get label() {
33598    return this.$$.ctx[8];
33599  }
33600  set label(label) {
33601    this.$$set({ label });
33602    flush();
33603  }
33604  get show_label() {
33605    return this.$$.ctx[9];
33606  }
33607  set show_label(show_label) {
33608    this.$$set({ show_label });
33609    flush();
33610  }
33611  get wrap() {
33612    return this.$$.ctx[10];
33613  }
33614  set wrap(wrap) {
33615    this.$$set({ wrap });
33616    flush();
33617  }
33618  get datatype() {
33619    return this.$$.ctx[11];
33620  }
33621  set datatype(datatype) {
33622    this.$$set({ datatype });
33623    flush();
33624  }
33625  get scale() {
33626    return this.$$.ctx[12];
33627  }
33628  set scale(scale) {
33629    this.$$set({ scale });
33630    flush();
33631  }
33632  get min_width() {
33633    return this.$$.ctx[13];
33634  }
33635  set min_width(min_width) {
33636    this.$$set({ min_width });
33637    flush();
33638  }
33639  get root() {
33640    return this.$$.ctx[14];
33641  }
33642  set root(root) {
33643    this.$$set({ root });
33644    flush();
33645  }
33646  get line_breaks() {
33647    return this.$$.ctx[15];
33648  }
33649  set line_breaks(line_breaks) {
33650    this.$$set({ line_breaks });
33651    flush();
33652  }
33653  get column_widths() {
33654    return this.$$.ctx[16];
33655  }
33656  set column_widths(column_widths) {
33657    this.$$set({ column_widths });
33658    flush();
33659  }
33660  get gradio() {
33661    return this.$$.ctx[17];
33662  }
33663  set gradio(gradio) {
33664    this.$$set({ gradio });
33665    flush();
33666  }
33667  get latex_delimiters() {
33668    return this.$$.ctx[18];
33669  }
33670  set latex_delimiters(latex_delimiters) {
33671    this.$$set({ latex_delimiters });
33672    flush();
33673  }
33674  get max_height() {
33675    return this.$$.ctx[19];
33676  }
33677  set max_height(max_height) {
33678    this.$$set({ max_height });
33679    flush();
33680  }
33681  get loading_status() {
33682    return this.$$.ctx[20];
33683  }
33684  set loading_status(loading_status) {
33685    this.$$set({ loading_status });
33686    flush();
33687  }
33688  get interactive() {
33689    return this.$$.ctx[21];
33690  }
33691  set interactive(interactive) {
33692    this.$$set({ interactive });
33693    flush();
33694  }
33695  get show_fullscreen_button() {
33696    return this.$$.ctx[22];
33697  }
33698  set show_fullscreen_button(show_fullscreen_button) {
33699    this.$$set({ show_fullscreen_button });
33700    flush();
33701  }
33702  get max_chars() {
33703    return this.$$.ctx[23];
33704  }
33705  set max_chars(max_chars) {
33706    this.$$set({ max_chars });
33707    flush();
33708  }
33709  get show_copy_button() {
33710    return this.$$.ctx[24];
33711  }
33712  set show_copy_button(show_copy_button) {
33713    this.$$set({ show_copy_button });
33714    flush();
33715  }
33716  get show_row_numbers() {
33717    return this.$$.ctx[25];
33718  }
33719  set show_row_numbers(show_row_numbers) {
33720    this.$$set({ show_row_numbers });
33721    flush();
33722  }
33723  get show_search() {
33724    return this.$$.ctx[26];
33725  }
33726  set show_search(show_search) {
33727    this.$$set({ show_search });
33728    flush();
33729  }
33730  get pinned_columns() {
33731    return this.$$.ctx[27];
33732  }
33733  set pinned_columns(pinned_columns) {
33734    this.$$set({ pinned_columns });
33735    flush();
33736  }
33737  get static_columns() {
33738    return this.$$.ctx[28];
33739  }
33740  set static_columns(static_columns) {
33741    this.$$set({ static_columns });
33742    flush();
33743  }
33744  get fullscreen() {
33745    return this.$$.ctx[2];
33746  }
33747  set fullscreen(fullscreen) {
33748    this.$$set({ fullscreen });
33749    flush();
33750  }
33751};
33752function create_fragment(ctx) {
33753  let df;
33754  let current;
33755  const df_spread_levels = [
33756    /*$$props*/
33757    ctx[0]
33758  ];
33759  let df_props = {};
33760  for (let i = 0; i < df_spread_levels.length; i += 1) {
33761    df_props = assign(df_props, df_spread_levels[i]);
33762  }
33763  df = new Index$1$1({ props: df_props });
33764  return {
33765    c() {
33766      create_component(df.$$.fragment);
33767    },
33768    m(target, anchor) {
33769      mount_component(df, target, anchor);
33770      current = true;
33771    },
33772    p(ctx2, [dirty]) {
33773      const df_changes = dirty & /*$$props*/
33774      1 ? get_spread_update(df_spread_levels, [get_spread_object(
33775        /*$$props*/
33776        ctx2[0]
33777      )]) : {};
33778      df.$set(df_changes);
33779    },
33780    i(local) {
33781      if (current) return;
33782      transition_in(df.$$.fragment, local);
33783      current = true;
33784    },
33785    o(local) {
33786      transition_out(df.$$.fragment, local);
33787      current = false;
33788    },
33789    d(detaching) {
33790      destroy_component(df, detaching);
33791    }
33792  };
33793}
33794function instance($$self, $$props, $$invalidate) {
33795  $$self.$$set = ($$new_props) => {
33796    $$invalidate(0, $$props = assign(assign({}, $$props), exclude_internal_props($$new_props)));
33797  };
33798  $$props = exclude_internal_props($$props);
33799  return [$$props];
33800}
33801class Index3 extends SvelteComponent {
33802  constructor(options) {
33803    super();
33804    init(this, options, instance, create_fragment, safe_not_equal, {});
33805  }
33806}
33807
33808function get_sort_status(name, sort_columns, headers) {
33809  if (!sort_columns.length) return "none";
33810  const sort_item = sort_columns.find((item) => {
33811    const col = item.col;
33812    if (col < 0 || col >= headers.length) return false;
33813    return headers[col] === name;
33814  });
33815  if (!sort_item) return "none";
33816  return sort_item.direction;
33817}
33818function sort_data(data, sort_columns) {
33819  if (!data || !data.length || !data[0]) {
33820    return [];
33821  }
33822  if (sort_columns.length > 0) {
33823    const row_indices = [...Array(data.length)].map((_, i) => i);
33824    row_indices.sort((row_a_idx, row_b_idx) => {
33825      const row_a = data[row_a_idx];
33826      const row_b = data[row_b_idx];
33827      for (const { col: sort_by, direction } of sort_columns) {
33828        if (!row_a || !row_b || sort_by < 0 || sort_by >= row_a.length || sort_by >= row_b.length || !row_a[sort_by] || !row_b[sort_by]) {
33829          continue;
33830        }
33831        const val_a = row_a[sort_by].value;
33832        const val_b = row_b[sort_by].value;
33833        const comparison = val_a < val_b ? -1 : val_a > val_b ? 1 : 0;
33834        if (comparison !== 0) {
33835          return direction === "asc" ? comparison : -comparison;
33836        }
33837      }
33838      return 0;
33839    });
33840    return row_indices;
33841  }
33842  return [...Array(data.length)].map((_, i) => i);
33843}
33844function sort_data_and_preserve_selection(data, display_value, styling, sort_columns, selected, get_current_indices) {
33845  let id = null;
33846  if (selected && selected[0] in data && selected[1] in data[selected[0]]) {
33847    id = data[selected[0]][selected[1]].id;
33848  }
33849  sort_table_data(data, display_value, styling, sort_columns);
33850  let new_selected = selected;
33851  if (id) {
33852    const [i, j] = get_current_indices(id, data);
33853    new_selected = [i, j];
33854  }
33855  return { data, selected: new_selected };
33856}
33857
33858function filter_data(data, filter_columns) {
33859  if (!data || !data.length || !data[0]) {
33860    return [];
33861  }
33862  let row_indices = [...Array(data.length)].map((_, i) => i);
33863  if (filter_columns.length > 0) {
33864    filter_columns.forEach((column) => {
33865      if (column.datatype === "string") {
33866        switch (column.filter) {
33867          case "Contains":
33868            row_indices = row_indices.filter(
33869              (i) => data[i][column.col]?.value.toString().includes(column.value)
33870            );
33871            break;
33872          case "Does not contain":
33873            row_indices = row_indices.filter(
33874              (i) => !data[i][column.col]?.value.toString().includes(column.value)
33875            );
33876            break;
33877          case "Starts with":
33878            row_indices = row_indices.filter(
33879              (i) => data[i][column.col]?.value.toString().startsWith(column.value)
33880            );
33881            break;
33882          case "Ends with":
33883            row_indices = row_indices.filter(
33884              (i) => data[i][column.col]?.value.toString().endsWith(column.value)
33885            );
33886            break;
33887          case "Is":
33888            row_indices = row_indices.filter(
33889              (i) => data[i][column.col]?.value.toString() === column.value
33890            );
33891            break;
33892          case "Is not":
33893            row_indices = row_indices.filter(
33894              (i) => !(data[i][column.col]?.value.toString() === column.value)
33895            );
33896            break;
33897          case "Is empty":
33898            row_indices = row_indices.filter(
33899              (i) => data[i][column.col]?.value.toString() === ""
33900            );
33901            break;
33902          case "Is not empty":
33903            row_indices = row_indices.filter(
33904              (i) => !(data[i][column.col]?.value.toString() === "")
33905            );
33906            break;
33907        }
33908      } else if (column.datatype === "number") {
33909        switch (column.filter) {
33910          case "=":
33911            row_indices = row_indices.filter((i) => {
33912              if (!isNaN(Number(data[i][column.col]?.value)) && !isNaN(Number(column.value))) {
33913                return Number(data[i][column.col]?.value) === Number(column.value);
33914              }
33915              return false;
33916            });
33917            break;
33918          case "≠":
33919            row_indices = row_indices.filter((i) => {
33920              if (!isNaN(Number(data[i][column.col]?.value)) && !isNaN(Number(column.value))) {
33921                return !(Number(data[i][column.col]?.value) === Number(column.value));
33922              }
33923              return false;
33924            });
33925            break;
33926          case ">":
33927            row_indices = row_indices.filter((i) => {
33928              if (!isNaN(Number(data[i][column.col]?.value)) && !isNaN(Number(column.value))) {
33929                return Number(data[i][column.col]?.value) > Number(column.value);
33930              }
33931              return false;
33932            });
33933            break;
33934          case "<":
33935            row_indices = row_indices.filter((i) => {
33936              if (!isNaN(Number(data[i][column.col]?.value)) && !isNaN(Number(column.value))) {
33937                return Number(data[i][column.col]?.value) < Number(column.value);
33938              }
33939              return false;
33940            });
33941            break;
33942          case "≥":
33943            row_indices = row_indices.filter((i) => {
33944              if (!isNaN(Number(data[i][column.col]?.value)) && !isNaN(Number(column.value))) {
33945                return Number(data[i][column.col]?.value) >= Number(column.value);
33946              }
33947              return false;
33948            });
33949            break;
33950          case "≤":
33951            row_indices = row_indices.filter((i) => {
33952              if (!isNaN(Number(data[i][column.col]?.value)) && !isNaN(Number(column.value))) {
33953                return Number(data[i][column.col]?.value) <= Number(column.value);
33954              }
33955              return false;
33956            });
33957            break;
33958          case "Is empty":
33959            row_indices = row_indices.filter(
33960              (i) => data[i][column.col]?.value.toString() === ""
33961            );
33962            break;
33963          case "Is not empty":
33964            row_indices = row_indices.filter((i) => {
33965              if (!isNaN(Number(data[i][column.col]?.value))) {
33966                return !(data[i][column.col]?.value.toString() === "");
33967              }
33968              return false;
33969            });
33970            break;
33971        }
33972      }
33973    });
33974    return row_indices;
33975  }
33976  return [...Array(data.length)].map((_, i) => i);
33977}
33978function filter_data_and_preserve_selection(data, display_value, styling, filter_columns, selected, get_current_indices, original_data, original_display_value, original_styling) {
33979  let id = null;
33980  if (selected && selected[0] in data && selected[1] in data[selected[0]]) {
33981    id = data[selected[0]][selected[1]].id;
33982  }
33983  filter_table_data(
33984    data,
33985    display_value,
33986    styling,
33987    filter_columns,
33988    original_data,
33989    original_display_value,
33990    original_styling
33991  );
33992  let new_selected = selected;
33993  if (id) {
33994    const [i, j] = get_current_indices(id, data);
33995    new_selected = [i, j];
33996  }
33997  return { data, selected: new_selected };
33998}
33999
34000function get_max(data) {
34001  if (!data || !data.length) return [];
34002  let max = data[0].slice();
34003  for (let i = 0; i < data.length; i++) {
34004    for (let j = 0; j < data[i].length; j++) {
34005      if (`${max[j].value}`.length < `${data[i][j].value}`.length) {
34006        max[j] = data[i][j];
34007      }
34008    }
34009  }
34010  return max;
34011}
34012function sort_table_data(data, display_value, styling, sort_columns) {
34013  if (!sort_columns.length) return;
34014  if (!data || !data.length) return;
34015  const indices = sort_data(data, sort_columns);
34016  const new_data = indices.map((i) => data[i]);
34017  data.splice(0, data.length, ...new_data);
34018  if (display_value) {
34019    const new_display = indices.map((i) => display_value[i]);
34020    display_value.splice(0, display_value.length, ...new_display);
34021  }
34022  if (styling) {
34023    const new_styling = indices.map((i) => styling[i]);
34024    styling.splice(0, styling.length, ...new_styling);
34025  }
34026}
34027function filter_table_data(data, display_value, styling, filter_columns, original_data, original_display_value, original_styling) {
34028  const base_data = original_data ?? data;
34029  const base_display_value = original_display_value ?? display_value;
34030  const base_styling = original_styling ?? styling;
34031  if (!filter_columns.length) {
34032    data.splice(0, data.length, ...base_data.map((row) => [...row]));
34033    if (display_value && base_display_value) {
34034      display_value.splice(
34035        0,
34036        display_value.length,
34037        ...base_display_value.map((row) => [...row])
34038      );
34039    }
34040    if (styling && base_styling) {
34041      styling.splice(0, styling.length, ...base_styling.map((row) => [...row]));
34042    }
34043    return;
34044  }
34045  if (!data || !data.length) return;
34046  const indices = filter_data(base_data, filter_columns);
34047  const new_data = indices.map((i) => base_data[i]);
34048  data.splice(0, data.length, ...new_data);
34049  if (display_value && base_display_value) {
34050    const new_display = indices.map((i) => base_display_value[i]);
34051    display_value.splice(0, display_value.length, ...new_display);
34052  }
34053  if (styling && base_styling) {
34054    const new_styling = indices.map((i) => base_styling[i]);
34055    styling.splice(0, styling.length, ...new_styling);
34056  }
34057}
34058async function copy_table_data(data, selected_cells) {
34059  if (!data || !data.length) return;
34060  const cells_to_copy = selected_cells || data.flatMap((row, r) 
34060=> row.map((_, c) => [r, c]));
34061  const csv = cells_to_copy.reduce(
34062    (acc, [row, col]) => {
34063      acc[row] = acc[row] || {};
34064      const value = String(data[row][col].value);
34065      acc[row][col] = value.includes(",") || value.includes('"') || value.includes("\n") ? `"${value.replace(/"/g, '""')}"` : value;
34066      return acc;
34067    },
34068    {}
34069  );
34070  const rows = Object.keys(csv).sort((a, b) => +a - +b);
34071  if (!rows.length) return;
34072  const cols = Object.keys(csv[rows[0]]).sort((a, b) => +a - +b);
34073  const text = rows.map((r) => cols.map((c) => csv[r][c] || "").join(",")).join("\n");
34074  try {
34075    await navigator.clipboard.writeText(text);
34076  } catch (err) {
34077    throw new Error("Failed to copy to clipboard: " + err.message);
34078  }
34079}
34080function guess_delimiter(text, possibleDelimiters) {
34081  return possibleDelimiters.filter(weedOut);
34082  function weedOut(delimiter) {
34083    var cache = -1;
34084    return text.split("\n").every(checkLength);
34085    function checkLength(line) {
34086      if (!line) return true;
34087      var length = line.split(delimiter).length;
34088      if (cache < 0) cache = length;
34089      return cache === length && length > 1;
34090    }
34091  }
34092}
34093function data_uri_to_blob(data_uri) {
34094  const byte_str = atob(data_uri.split(",")[1]);
34095  const mime_str = data_uri.split(",")[0].split(":")[1].split(";")[0];
34096  const ab = new ArrayBuffer(byte_str.length);
34097  const ia = new Uint8Array(ab);
34098  for (let i = 0; i < byte_str.length; i++) {
34099    ia[i] = byte_str.charCodeAt(i);
34100  }
34101  return new Blob([ab], { type: mime_str });
34102}
34103function handle_file_upload(data_uri, update_headers, update_values) {
34104  const blob = data_uri_to_blob(data_uri);
34105  const reader = new FileReader();
34106  reader.addEventListener("loadend", (e) => {
34107    if (!e?.target?.result || typeof e.target.result !== "string") return;
34108    const [delimiter] = guess_delimiter(e.target.result, [",", "	"]);
34109    const [head, ...rest] = dsvFormat$1(delimiter).parseRows(e.target.result);
34110    update_headers(head);
34111    update_values(rest);
34112  });
34113  reader.readAsText(blob);
34114}
34115
34116function is_cell_in_selection(coords, selected_cells) {
34117  const [row, col] = coords;
34118  return selected_cells.some(([r, c]) => r === row && c === col);
34119}
34120function is_cell_selected(cell, selected_cells) {
34121  const [row, col] = cell;
34122  if (!selected_cells.some(([r, c]) => r === row && c === col)) return "";
34123  const up = selected_cells.some(([r, c]) => r === row - 1 && c === col);
34124  const down = selected_cells.some(([r, c]) => r === row + 1 && c === col);
34125  const left = selected_cells.some(([r, c]) => r === row && c === col - 1);
34126  const right = selected_cells.some(([r, c]) => r === row && c === col + 1);
34127  return `cell-selected${up ? " no-top" : ""}${down ? " no-bottom" : ""}${left ? " no-left" : ""}${right ? " no-right" : ""}`;
34128}
34129function get_range_selection(start, end) {
34130  const [start_row, start_col] = start;
34131  const [end_row, end_col] = end;
34132  const min_row = Math.min(start_row, end_row);
34133  const max_row = Math.max(start_row, end_row);
34134  const min_col = Math.min(start_col, end_col);
34135  const max_col = Math.max(start_col, end_col);
34136  const cells = [];
34137  cells.push(start);
34138  for (let i = min_row; i <= max_row; i++) {
34139    for (let j = min_col; j <= max_col; j++) {
34140      if (i === start_row && j === start_col) continue;
34141      cells.push([i, j]);
34142    }
34143  }
34144  return cells;
34145}
34146function handle_selection(current, selected_cells, event) {
34147  if (event.shiftKey && selected_cells.length > 0) {
34148    return get_range_selection(
34149      selected_cells[selected_cells.length - 1],
34150      current
34151    );
34152  }
34153  if (event.metaKey || event.ctrlKey) {
34154    const is_cell_match = ([r, c]) => r === current[0] && c === current[1];
34155    const index = selected_cells.findIndex(is_cell_match);
34156    return index === -1 ? [...selected_cells, current] : selected_cells.filter((_, i) => i !== index);
34157  }
34158  return [current];
34159}
34160function handle_delete_key(data, selected_cells) {
34161  const new_data = data.map((row) => [...row]);
34162  selected_cells.forEach(([row, col]) => {
34163    if (new_data[row] && new_data[row][col]) {
34164      new_data[row][col] = { ...new_data[row][col], value: "" };
34165    }
34166  });
34167  return new_data;
34168}
34169function should_show_cell_menu(cell, selected_cells, editable) {
34170  const [row, col] = cell;
34171  return editable && selected_cells.length === 1 && selected_cells[0][0] === row && selected_cells[0][1] === col;
34172}
34173function get_next_cell_coordinates(current, data, shift_key) {
34174  const [row, col] = current;
34175  const direction = shift_key ? -1 : 1;
34176  if (data[row]?.[col + direction]) {
34177    return [row, col + direction];
34178  }
34179  const next_row = row + (direction > 0 ? 1 : 0);
34180  const prev_row = row + (direction < 0 ? -1 : 0);
34181  if (direction > 0 && data[next_row]?.[0]) {
34182    return [next_row, 0];
34183  }
34184  if (direction < 0 && data[prev_row]?.[data[0].length - 1]) {
34185    return [prev_row, data[0].length - 1];
34186  }
34187  return false;
34188}
34189function move_cursor(event, current_coords, data) {
34190  const key = event.key;
34191  const dir = {
34192    ArrowRight: [0, 1],
34193    ArrowLeft: [0, -1],
34194    ArrowDown: [1, 0],
34195    ArrowUp: [-1, 0]
34196  }[key];
34197  let i, j;
34198  if (event.metaKey || event.ctrlKey) {
34199    if (key === "ArrowRight") {
34200      i = current_coords[0];
34201      j = data[0].length - 1;
34202    } else if (key === "ArrowLeft") {
34203      i = current_coords[0];
34204      j = 0;
34205    } else if (key === "ArrowDown") {
34206      i = data.length - 1;
34207      j = current_coords[1];
34208    } else if (key === "ArrowUp") {
34209      i = 0;
34210      j = current_coords[1];
34211    } else {
34212      return false;
34213    }
34214  } else {
34215    i = current_coords[0] + dir[0];
34216    j = current_coords[1] + dir[1];
34217  }
34218  if (i < 0 && j <= 0) {
34219    return false;
34220  }
34221  const is_data = data[i]?.[j];
34222  if (is_data) {
34223    return [i, j];
34224  }
34225  return false;
34226}
34227function get_current_indices(id, data) {
34228  return data.reduce(
34229    (acc, arr, i) => {
34230      const j = arr.reduce(
34231        (_acc, _data, k) => id === _data.id ? k : _acc,
34232        -1
34233      );
34234      return j === -1 ? acc : [i, j];
34235    },
34236    [-1, -1]
34237  );
34238}
34239function handle_click_outside(event, parent) {
34240  const [trigger] = event.composedPath();
34241  return !parent.contains(trigger);
34242}
34243function calculate_selection_positions(selected, data, els, parent, table) {
34244  const [row, col] = selected;
34245  if (!data[row]?.[col]) {
34246    return { col_pos: "0px", row_pos: void 0 };
34247  }
34248  const cell_id = data[row][col].id;
34249  const cell_el = els[cell_id]?.cell;
34250  if (!cell_el) {
34251    return { col_pos: "0px", row_pos: void 0 };
34252  }
34253  const cell_rect = cell_el.getBoundingClientRect();
34254  const table_rect = table.getBoundingClientRect();
34255  const col_pos = `${cell_rect.left - table_rect.left + cell_rect.width / 2}px`;
34256  const row_pos = `${cell_rect.top - table_rect.top + cell_rect.height / 2}px`;
34257  return { col_pos, row_pos };
34258}
34259
34260const DATAFRAME_KEY = /* @__PURE__ */ Symbol("dataframe");
34261function create_actions(state, context) {
34262  const update_state = (updater) => state.update((s) => ({ ...s, ...updater(s) }));
34263  const add_row = (data, make_id, index) => {
34264    const new_row = data[0]?.length ? Array(data[0].length).fill(null).map(() => ({ value: "", id: make_id() })) : [{ value: "", id: make_id() }];
34265    const new_data = [...data];
34266    index !== void 0 ? new_data.splice(index, 0, new_row) : new_data.push(new_row);
34267    return new_data;
34268  };
34269  const add_col = (data, headers, make_id, index) => {
34270    const new_headers = [...headers, `Header ${headers.length + 1}`];
34271    const new_data = data.map((row) => [...row, { value: "", id: make_id() }]);
34272    if (index !== void 0) {
34273      new_headers.splice(index, 0, new_headers.pop());
34274      new_data.forEach((row) => row.splice(index, 0, row.pop()));
34275    }
34276    return { data: new_data, headers: new_headers };
34277  };
34278  const update_array = (source, target) => {
34279    if (source && target) {
34280      target.splice(0, target.length, ...JSON.parse(JSON.stringify(source)));
34281    }
34282  };
34283  return {
34284    handle_search: (query) => update_state((s) => ({ current_search_query: query })),
34285    handle_sort: (col, direction) => update_state((s) => {
34286      const sort_cols = s.sort_state.sort_columns.filter(
34287        (c) => c.col !== col
34288      );
34289      if (!s.sort_state.sort_columns.some(
34290        (c) => c.col === col && c.direction === direction
34291      )) {
34292        sort_cols.push({ col, direction });
34293      }
34294      const initial_data = s.sort_state.initial_data || (context.data && sort_cols.length > 0 ? {
34295        data: JSON.parse(JSON.stringify(context.data)),
34296        display_value: context.display_value ? JSON.parse(JSON.stringify(context.display_value)) : null,
34297        styling: context.styling ? JSON.parse(JSON.stringify(context.styling)) : null
34298      } : null);
34299      return {
34300        sort_state: {
34301          ...s.sort_state,
34302          sort_columns: sort_cols.slice(-3),
34303          initial_data
34304        }
34305      };
34306    }),
34307    handle_filter: (col, datatype, filter, value) => update_state((s) => {
34308      const filter_cols = s.filter_state.filter_columns.some(
34309        (c) => c.col === col
34310      ) ? s.filter_state.filter_columns.filter((c) => c.col !== col) : [
34311        ...s.filter_state.filter_columns,
34312        { col, datatype, filter, value }
34313      ];
34314      const initial_data = s.filter_state.initial_data || (context.data && filter_cols.length > 0 ? {
34315        data: JSON.parse(JSON.stringify(context.data)),
34316        display_value: context.display_value ? JSON.parse(JSON.stringify(context.display_value)) : null,
34317        styling: context.styling ? JSON.parse(JSON.stringify(context.styling)) : null
34318      } : null);
34319      return {
34320        filter_state: {
34321          ...s.filter_state,
34322          filter_columns: filter_cols,
34323          initial_data
34324        }
34325      };
34326    }),
34327    get_sort_status: (name, headers) => {
34328      const s = get(state);
34329      const sort_item = s.sort_state.sort_columns.find(
34330        (item) => headers[item.col] === name
34331      );
34332      return sort_item ? sort_item.direction : "none";
34333    },
34334    sort_data: (data, display_value, styling) => {
34335      const {
34336        sort_state: { sort_columns }
34337      } = get(state);
34338      if (sort_columns.length)
34339        sort_table_data(data, display_value, styling, sort_columns);
34340    },
34341    update_row_order: (data) => update_state((s) => ({
34342      sort_state: {
34343        ...s.sort_state,
34344        row_order: s.sort_state.sort_columns.length && data[0] ? [...Array(data.length)].map((_, i) => i).sort((a, b) => {
34345          for (const { col, direction } of s.sort_state.sort_columns) {
34346            const comp = (data[a]?.[col]?.value ?? "") < (data[b]?.[col]?.value ?? "") ? -1 : 1;
34347            return direction === "asc" ? comp : -comp;
34348          }
34349          return 0;
34350        }) : [...Array(data.length)].map((_, i) => i)
34351      }
34352    })),
34353    filter_data: (data) => {
34354      const query = get(state).current_search_query?.toLowerCase();
34355      return query ? data.filter(
34356        (row) => row.some(
34357          (cell) => String(cell?.value).toLowerCase().includes(query)
34358        )
34359      ) : data;
34360    },
34361    add_row,
34362    add_col,
34363    add_row_at: (data, index, position, make_id) => add_row(data, make_id, position === "above" ? index : index + 1),
34364    add_col_at: (data, headers, index, position, make_id) => add_col(data, headers, make_id, position === "left" ? index : index + 1),
34365    delete_row: (data, index) => data.length > 1 ? data.filter((_, i) => i !== index) : data,
34366    delete_col: (data, headers, index) => headers.length > 1 ? {
34367      data: data.map((row) => row.filter((_, i) => i !== index)),
34368      headers: headers.filter((_, i) => i !== index)
34369    } : { data, headers },
34370    delete_row_at: (data, index) => data.length > 1 ? [...data.slice(0, index), ...data.slice(index + 1)] : data,
34371    delete_col_at: (data, headers, index) => headers.length > 1 ? {
34372      data: data.map((row) => [
34373        ...row.slice(0, index),
34374        ...row.slice(index + 1)
34375      ]),
34376      headers: [...headers.slice(0, index), ...headers.slice(index + 1)]
34377    } : { data, headers },
34378    trigger_change: async (data, headers, previous_data, previous_headers, value_is_output, dispatch) => {
34379      const s = get(state);
34380      if (s.current_search_query) return;
34381      const current_headers = headers.map((h) => h.value);
34382      const current_data = data.map((row) => row.map((cell) => cell.value));
34383      if (!dequal$2(current_data, previous_data) || !dequal$2(current_headers, previous_headers)) {
34384        if (!dequal$2(current_headers, previous_headers)) {
34385          update_state((s2) => ({
34386            sort_state: { sort_columns: [], row_order: [], initial_data: null },
34387            filter_state: { filter_columns: [], initial_data: null }
34388          }));
34389        }
34390        dispatch("change", {
34391          data: data.map((row) => row.map((cell) => cell.value)),
34392          headers: current_headers,
34393          metadata: null
34394        });
34395        const index = s.ui_state.selected;
34396        if (index) {
34397          dispatch("edit", {
34398            index,
34399            value: data[index[0]][index[1]].value,
34400            previous_value: previous_data[index[0]][index[1]]
34401          });
34402        }
34403        if (!value_is_output) dispatch("input");
34404      }
34405    },
34406    reset_sort_state: () => update_state((s) => {
34407      if (s.sort_state.initial_data && context.data) {
34408        const original = s.sort_state.initial_data;
34409        update_array(original.data, context.data);
34410        update_array(original.display_value, context.display_value);
34411        update_array(original.styling, context.styling);
34412      }
34413      return {
34414        sort_state: { sort_columns: [], row_order: [], initial_data: null }
34415      };
34416    }),
34417    reset_filter_state: () => update_state((s) => {
34418      if (s.filter_state.initial_data && context.data) {
34419        const original = s.filter_state.initial_data;
34420        update_array(original.data, context.data);
34421        update_array(original.display_value, context.display_value);
34422        update_array(original.styling, context.styling);
34423      }
34424      return {
34425        filter_state: { filter_columns: [], initial_data: null }
34426      };
34427    }),
34428    set_active_cell_menu: (menu) => update_state((s) => ({
34429      ui_state: { ...s.ui_state, active_cell_menu: menu }
34430    })),
34431    set_active_header_menu: (menu) => update_state((s) => ({
34432      ui_state: { ...s.ui_state, active_header_menu: menu }
34433    })),
34434    set_selected_cells: (cells) => update_state((s) => ({
34435      ui_state: { ...s.ui_state, selected_cells: cells }
34436    })),
34437    set_selected: (selected) => update_state((s) => ({ ui_state: { ...s.ui_state, selected } })),
34438    set_editing: (editing) => update_state((s) => ({ ui_state: { ...s.ui_state, editing } })),
34439    clear_ui_state: () => update_state((s) => ({
34440      ui_state: {
34441        active_cell_menu: null,
34442        active_header_menu: null,
34443        selected_cells: [],
34444        selected: false,
34445        editing: false,
34446        header_edit: false,
34447        selected_header: false,
34448        active_button: null,
34449        copy_flash: false
34450      }
34451    })),
34452    set_header_edit: (header_index) => update_state((s) => ({
34453      ui_state: {
34454        ...s.ui_state,
34455        selected_cells: [],
34456        selected_header: header_index,
34457        header_edit: header_index
34458      }
34459    })),
34460    set_selected_header: (header_index) => update_state((s) => ({
34461      ui_state: {
34462        ...s.ui_state,
34463        selected_header: header_index,
34464        selected: false,
34465        selected_cells: []
34466      }
34467    })),
34468    handle_header_click: (col, editable) => update_state((s) => ({
34469      ui_state: {
34470        ...s.ui_state,
34471        active_cell_menu: null,
34472        active_header_menu: null,
34473        selected: false,
34474        selected_cells: [],
34475        selected_header: col,
34476        header_edit: editable ? col : false
34477      }
34478    })),
34479    end_header_edit: (key) => {
34480      if (["Escape", "Enter", "Tab"].includes(key)) {
34481        update_state((s) => ({
34482          ui_state: { ...s.ui_state, selected: false, header_edit: false }
34483        }));
34484      }
34485    },
34486    get_selected_cells: () => get(state).ui_state.selected_cells,
34487    get_active_cell_menu: () => get(state).ui_state.active_cell_menu,
34488    get_active_button: () => get(state).ui_state.active_button,
34489    set_active_button: (button) => update_state((s) => ({
34490      ui_state: { ...s.ui_state, active_button: button }
34491    })),
34492    set_copy_flash: (value) => update_state((s) => ({ ui_state: { ...s.ui_state, copy_flash: value } })),
34493    handle_cell_click: (event, row, col) => {
34494      event.preventDefault();
34495      event.stopPropagation();
34496      const s = get(state);
34497      if (s.config.show_row_numbers && col === -1) return;
34498      let actual_row = row;
34499      if (s.current_search_query && context.data) {
34500        const filtered_indices = [];
34501        context.data.forEach((dataRow, idx) => {
34502          if (dataRow.some(
34503            (cell) => String(cell?.value).toLowerCase().includes(s.current_search_query?.toLowerCase() || "")
34504          )) {
34505            filtered_indices.push(idx);
34506          }
34507        });
34508        actual_row = filtered_indices[row] ?? row;
34509      }
34510      const cells = handle_selection(
34511        [actual_row, col],
34512        s.ui_state.selected_cells,
34513        event
34514      );
34515      update_state((s2) => ({
34516        ui_state: {
34517          ...s2.ui_state,
34518          active_cell_menu: null,
34519          active_header_menu: null,
34520          selected_header: false,
34521          header_edit: false,
34522          selected_cells: cells,
34523          selected: cells[0]
34524        }
34525      }));
34526      if (s.config.editable && cells.length === 1) {
34527        update_state((s2) => ({
34528          ui_state: { ...s2.ui_state, editing: [actual_row, col] }
34529        }));
34530        tick$1().then(
34531          () => context.els[context.data[actual_row][col].id]?.input?.focus()
34532        );
34533      } else {
34534        tick$1().then(() => {
34535          if (context.parent_element) {
34536            context.parent_element.focus();
34537          }
34538        });
34539      }
34540      context.dispatch?.("select", {
34541        index: [actual_row, col],
34542        col_value: context.get_column(col),
34543        row_value: context.get_row(actual_row),
34544        value: context.get_data_at(actual_row, col)
34545      });
34546    },
34547    toggle_cell_menu: (event, row, col) => {
34548      event.stopPropagation();
34549      const current_menu = get(state).ui_state.active_cell_menu;
34550      if (current_menu?.row === row && current_menu.col === col) {
34551        update_state((s) => ({
34552          ui_state: { ...s.ui_state, active_cell_menu: null }
34553        }));
34554      } else {
34555        const cell = event.target.closest("td");
34556        if (cell) {
34557          const rect = cell.getBoundingClientRect();
34558          update_state((s) => ({
34559            ui_state: {
34560              ...s.ui_state,
34561              active_cell_menu: { row, col, x: rect.right, y: rect.bottom }
34562            }
34563          }));
34564        }
34565      }
34566    },
34567    toggle_cell_button: (row, col) => {
34568      const current_button = get(state).ui_state.active_button;
34569      const new_button = current_button?.type === "cell" && current_button.row === row && current_button.col === col ? null : { type: "cell", row, col };
34570      update_state((s) => ({
34571        ui_state: { ...s.ui_state, active_button: new_button }
34572      }));
34573    },
34574    handle_select_column: (col) => {
34575      if (!context.data) return;
34576      const cells = context.data.map((_, row) => [row, col]);
34577      update_state((s) => ({
34578        ui_state: {
34579          ...s.ui_state,
34580          selected_cells: cells,
34581          selected: cells[0],
34582          editing: false
34583        }
34584      }));
34585      setTimeout(() => context.parent_element?.focus(), 0);
34586    },
34587    handle_select_row: (row) => {
34588      if (!context.data || !context.data[0]) return;
34589      const cells = context.data[0].map(
34590        (_, col) => [row, col]
34591      );
34592      update_state((s) => ({
34593        ui_state: {
34594          ...s.ui_state,
34595          selected_cells: cells,
34596          selected: cells[0],
34597          editing: false
34598        }
34599      }));
34600      setTimeout(() => context.parent_element?.focus(), 0);
34601    },
34602    get_next_cell_coordinates,
34603    get_range_selection,
34604    move_cursor
34605  };
34606}
34607function create_dataframe_context(config) {
34608  const state = writable$1({
34609    config,
34610    current_search_query: null,
34611    sort_state: { sort_columns: [], row_order: [], initial_data: null },
34612    filter_state: { filter_columns: [], initial_data: null },
34613    ui_state: {
34614      active_cell_menu: null,
34615      active_header_menu: null,
34616      selected_cells: [],
34617      selected: false,
34618      editing: false,
34619      header_edit: false,
34620      selected_header: false,
34621      active_button: null,
34622      copy_flash: false
34623    }
34624  });
34625  const context = { state, actions: null };
34626  context.actions = create_actions(state, context);
34627  const instance_id = /* @__PURE__ */ Symbol(
34628    `dataframe_${Math.random().toString(36).substring(2)}`
34629  );
34630  setContext$1(instance_id, context);
34631  setContext$1(DATAFRAME_KEY, { instance_id, context });
34632  return context;
34633}
34634
34635var root$e = from_html(`<button><span><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" class="svelte-fit6p6"><path d="m16.707 13.293-4-4a1 1 0 0 0-1.414 0l-4 4A1 1 0 0 0 8 15h8a1 1 0 0 0 .707-1.707z"></path></svg></span></button>`);
34636
34637function SelectionButtons($$anchor, $$props) {
34638	push($$props, false);
34639
34640	const is_first_position = mutable_source();
34641	const direction = mutable_source();
34642	let position = prop($$props, 'position', 12);
34643	let coords = prop($$props, 'coords', 12);
34644	let on_click = prop($$props, 'on_click', 12, null);
34645
34646	legacy_pre_effect(() => (deep_read_state(position()), deep_read_state(coords())), () => {
34647		set(is_first_position, position() === "column" ? coords()[0] === 0 : co
34647ords()[1] === 0);
34648	});
34649
34650	legacy_pre_effect(() => (deep_read_state(position()), get$1(is_first_position)), () => {
34651		set(direction, position() === "column"
34652			? get$1(is_first_position) ? "down" : "up"
34653			: get$1(is_first_position) ? "right" : "left");
34654	});
34655
34656	legacy_pre_effect_reset();
34657
34658	var $$exports = {
34659		get position() {
34660			return position();
34661		},
34662
34663		set position($$value) {
34664			position($$value);
34665			flushSync();
34666		},
34667
34668		get coords() {
34669			return coords();
34670		},
34671
34672		set coords($$value) {
34673			coords($$value);
34674			flushSync();
34675		},
34676
34677		get on_click() {
34678			return on_click();
34679		},
34680
34681		set on_click($$value) {
34682			on_click($$value);
34683			flushSync();
34684		}
34685	};
34686
34687	init$1();
34688
34689	var button = root$e();
34690	var span = child(button);
34691	var svg = child(span);
34692	var path = child(svg);
34693
34694	reset(svg);
34695	reset(span);
34696	reset(button);
34697
34698	template_effect(() => {
34699		set_class(button, 1, `selection-button selection-button-${position() ?? ''} ${get$1(is_first_position) ? `move-${get$1(direction)}` : ''}`, 'svelte-fit6p6');
34700		set_attribute(button, 'aria-label', `Select ${position()}`);
34701		set_class(span, 1, clsx(get$1(direction)), 'svelte-fit6p6');
34702		set_attribute(path, 'data-name', get$1(direction));
34703	});
34704
34705	event('click', button, stopPropagation(() => on_click() && on_click()()));
34706	append$1($$anchor, button);
34707
34708	return pop($$exports);
34709}
34710
34711var root$d = from_html(`<div class="bool-cell svelte-1d51ufy" role="button" tabindex="-1"><!></div>`);
34712
34713function BooleanCell($$anchor, $$props) {
34714	push($$props, false);
34715
34716	let value = prop($$props, 'value', 12, false);
34717	let editable = prop($$props, 'editable', 12, true);
34718	let on_change = prop($$props, 'on_change', 12);
34719
34720	function handle_change(event) {
34721		if (editable()) {
34722			on_change()(event.detail);
34723		}
34724	}
34725
34726	var $$exports = {
34727		get value() {
34728			return value();
34729		},
34730
34731		set value($$value) {
34732			value($$value);
34733			flushSync();
34734		},
34735
34736		get editable() {
34737			return editable();
34738		},
34739
34740		set editable($$value) {
34741			editable($$value);
34742			flushSync();
34743		},
34744
34745		get on_change() {
34746			return on_change();
34747		},
34748
34749		set on_change($$value) {
34750			on_change($$value);
34751			flushSync();
34752		}
34753	};
34754
34755	init$1();
34756
34757	var div = root$d();
34758	var node = child(div);
34759
34760	Checkbox$1(node, {
34761		label: '',
34762		get interactive() {
34763			return editable();
34764		},
34765
34766		get value() {
34767			return value();
34768		},
34769
34770		set value($$value) {
34771			value($$value);
34772		},
34773		$$events: { change: handle_change },
34774		$$legacy: true
34775	});
34776
34777	reset(div);
34778	append$1($$anchor, div);
34779
34780	return pop($$exports);
34781}
34782
34783var root_1$8 = from_html(`<textarea tabindex="-1"></textarea>`);
34784var root_3$3 = from_html(`<span tabindex="0" role="button" placeholder=" "><!></span>`);
34785var root_10$1 = from_html(`<!> <!>`, 1);
34786var root$c = from_html(`<!> <!> <!>`, 1);
34787
34788function EditableCell($$anchor, $$props) {
34789	push($$props, false);
34790
34791	const should_truncate = mutable_source();
34792	const display_content = mutable_source();
34793	const display_text = mutable_source();
34794	let edit = prop($$props, 'edit', 12);
34795	let value = prop($$props, 'value', 12, "");
34796	let display_value = prop($$props, 'display_value', 12, null);
34797	let styling = prop($$props, 'styling', 12, "");
34798	let header = prop($$props, 'header', 12, false);
34799	let datatype = prop($$props, 'datatype', 12, "str");
34800	let latex_delimiters = prop($$props, 'latex_delimiters', 12);
34801	let line_breaks = prop($$props, 'line_breaks', 12, true);
34802	let editable = prop($$props, 'editable', 12, true);
34803	let is_static = prop($$props, 'is_static', 12, false);
34804	let max_chars = prop($$props, 'max_chars', 12, null);
34805	let components = prop($$props, 'components', 28, () => ({}));
34806	let i18n = prop($$props, 'i18n', 12);
34807	let is_dragging = prop($$props, 'is_dragging', 12, false);
34808	let wrap_text = prop($$props, 'wrap_text', 12, false);
34809	let show_selection_buttons = prop($$props, 'show_selection_buttons', 12, false);
34810	let coords = prop($$props, 'coords', 12);
34811	let on_select_column = prop($$props, 'on_select_column', 12, null);
34812	let on_select_row = prop($$props, 'on_select_row', 12, null);
34813	let el = prop($$props, 'el', 12);
34814	const dispatch = createEventDispatcher$1();
34815
34816	function truncate_text(text, max_length = null, is_image = false) {
34817		if (is_image) return String(text);
34818
34819		const str = String(text);
34820
34821		if (!max_length || max_length <= 0) return str;
34822		if (str.length <= max_length) return str;
34823
34824		return str.slice(0, max_length) + "...";
34825	}
34826
34827	function use_focus(node) {
34828		requestAnimationFrame(() => {
34829			node.focus();
34830		});
34831
34832		return {};
34833	}
34834
34835	function handle_blur(event) {
34836		dispatch("blur", { blur_event: event, coords: coords() });
34837	}
34838
34839	function handle_keydown(event) {
34840		dispatch("keydown", event);
34841	}
34842
34843	function commit_change(checked) {
34844		handle_blur({ target: { value: value() } });
34845	}
34846
34847	legacy_pre_effect(() => (deep_read_state(edit()), deep_read_state(max_chars())), () => {
34848		set(should_truncate, !edit() && max_chars() !== null && max_chars() > 0);
34849	});
34850
34851	legacy_pre_effect(
34852		() => (
34853			deep_read_state(editable()),
34854			deep_read_state(value()),
34855			deep_read_state(display_value())
34856		),
34857		() => {
34858			set(display_content, editable()
34859				? value()
34860				: display_value() !== null ? display_value() : value());
34861		}
34862	);
34863
34864	legacy_pre_effect(
34865		() => (
34866			get$1(should_truncate),
34867			get$1(display_content),
34868			deep_read_state(max_chars()),
34869			deep_read_state(datatype())
34870		),
34871		() => {
34872			set(display_text, get$1(should_truncate)
34873				? truncate_text(get$1(display_content), max_chars(), datatype() === "image")
34874				: get$1(display_content));
34875		}
34876	);
34877
34878	legacy_pre_effect(() => (deep_read_state(edit()), deep_read_state(value())), () => {
34879		if (!edit()) {
34880			// Shim blur on removal for Safari and Firefox
34881			handle_blur({ target: { value: value() } });
34882		}
34883	});
34884
34885	legacy_pre_effect_reset();
34886
34887	var $$exports = {
34888		get edit() {
34889			return edit();
34890		},
34891
34892		set edit($$value) {
34893			edit($$value);
34894			flushSync();
34895		},
34896
34897		get value() {
34898			return value();
34899		},
34900
34901		set value($$value) {
34902			value($$value);
34903			flushSync();
34904		},
34905
34906		get display_value() {
34907			return display_value();
34908		},
34909
34910		set display_value($$value) {
34911			display_value($$value);
34912			flushSync();
34913		},
34914
34915		get styling() {
34916			return styling();
34917		},
34918
34919		set styling($$value) {
34920			styling($$value);
34921			flushSync();
34922		},
34923
34924		get header() {
34925			return header();
34926		},
34927
34928		set header($$value) {
34929			header($$value);
34930			flushSync();
34931		},
34932
34933		get datatype() {
34934			return datatype();
34935		},
34936
34937		set datatype($$value) {
34938			datatype($$value);
34939			flushSync();
34940		},
34941
34942		get latex_delimiters() {
34943			return latex_delimiters();
34944		},
34945
34946		set latex_delimiters($$value) {
34947			latex_delimiters($$value);
34948			flushSync();
34949		},
34950
34951		get line_breaks() {
34952			return line_breaks();
34953		},
34954
34955		set line_breaks($$value) {
34956			line_breaks($$value);
34957			flushSync();
34958		},
34959
34960		get editable() {
34961			return editable();
34962		},
34963
34964		set editable($$value) {
34965			editable($$value);
34966			flushSync();
34967		},
34968
34969		get is_static() {
34970			return is_static();
34971		},
34972
34973		set is_static($$value) {
34974			is_static($$value);
34975			flushSync();
34976		},
34977
34978		get max_chars() {
34979			return max_chars();
34980		},
34981
34982		set max_chars($$value) {
34983			max_chars($$value);
34984			flushSync();
34985		},
34986
34987		get components() {
34988			return components();
34989		},
34990
34991		set components($$value) {
34992			components($$value);
34993			flushSync();
34994		},
34995
34996		get i18n() {
34997			return i18n();
34998		},
34999
35000		set i18n($$value) {
35001			i18n($$value);
35002			flushSync();
35003		},
35004
35005		get is_dragging() {
35006			return is_dragging();
35007		},
35008
35009		set is_dragging($$value) {
35010			is_dragging($$value);
35011			flushSync();
35012		},
35013
35014		get wrap_text() {
35015			return wrap_text();
35016		},
35017
35018		set wrap_text($$value) {
35019			wrap_text($$value);
35020			flushSync();
35021		},
35022
35023		get show_selection_buttons() {
35024			return show_selection_buttons();
35025		},
35026
35027		set show_selection_buttons($$value) {
35028			show_selection_buttons($$value);
35029			flushSync();
35030		},
35031
35032		get coords() {
35033			return coords();
35034		},
35035
35036		set coords($$value) {
35037			coords($$value);
35038			flushSync();
35039		},
35040
35041		get on_select_column() {
35042			return on_select_column();
35043		},
35044
35045		set on_select_column($$value) {
35046			on_select_column($$value);
35047			flushSync();
35048		},
35049
35050		get on_select_row() {
35051			return on_select_row();
35052		},
35053
35054		set on_select_row($$value) {
35055			on_select_row($$value);
35056			flushSync();
35057		},
35058
35059		get el() {
35060			return el();
35061		},
35062
35063		set el($$value) {
35064			el($$value);
35065			flushSync();
35066		}
35067	};
35068
35069	init$1();
35070
35071	var fragment = root$c();
35072	var node_1 = first_child(fragment);
35073
35074	{
35075		var consequent = ($$anchor) => {
35076			var textarea = root_1$8();
35077
35078			remove_textarea_child(textarea);
35079
35080			let classes;
35081
35082			bind_this(textarea, ($$value) => el($$value), () => el());
35083			effect(() => bind_value(textarea, value));
35084			effect(() => event('blur', textarea, handle_blur));
35085
35086			effect(() => event('mousedown', textarea, stopPropagation(function ($$arg) {
35087				bubble_event.call(this, $$props, $$arg);
35088			})));
35089
35090			effect(() =>
35090 event('click', textarea, stopPropagation(function ($$arg) {
35091				bubble_event.call(this, $$props, $$arg);
35092			})));
35093
35094			action(textarea, ($$node) => use_focus?.($$node));
35095			effect(() => event('keydown', textarea, handle_keydown));
35096
35097			template_effect(() => {
35098				textarea.readOnly = is_static();
35099				set_attribute(textarea, 'aria-readonly', is_static());
35100				set_attribute(textarea, 'aria-label', is_static() ? "Cell is read-only" : "Edit cell");
35101				classes = set_class(textarea, 1, 'svelte-odwpey', null, classes, { header: header() });
35102			});
35103
35104			append$1($$anchor, textarea);
35105		};
35106
35107		if_block(node_1, ($$render) => {
35108			if (edit() && datatype() !== "bool") $$render(consequent);
35109		});
35110	}
35111
35112	var node_2 = sibling(node_1, 2);
35113
35114	{
35115		var consequent_1 = ($$anchor) => {
35116			BooleanCell($$anchor, {
35117				get editable() {
35118					return editable();
35119				},
35120				on_change: commit_change,
35121				get value() {
35122					return value();
35123				},
35124
35125				set value($$value) {
35126					value($$value);
35127				},
35128				$$legacy: true
35129			});
35130		};
35131
35132		var alternate_3 = ($$anchor) => {
35133			var span = root_3$3();
35134			let classes_1;
35135			var node_3 = child(span);
35136
35137			{
35138				var consequent_2 = ($$anchor) => {
35139					var fragment_2 = comment();
35140					var node_4 = first_child(fragment_2);
35141
35142					{
35143						let $0 = derived_safe_equal(() => ({ url: get$1(display_text) }));
35144
35145						component(node_4, () => components().image, ($$anchor, $$component) => {
35146							$$component($$anchor, {
35147								get value() {
35148									return get$1($0);
35149								},
35150								show_label: false,
35151								label: 'cell-image',
35152								show_download_button: false,
35153								get i18n() {
35154									return i18n();
35155								},
35156								gradio: { dispatch: () => {} }
35157							});
35158						});
35159					}
35160
35161					append$1($$anchor, fragment_2);
35162				};
35163
35164				var alternate_2 = ($$anchor) => {
35165					var fragment_3 = comment();
35166					var node_5 = first_child(fragment_3);
35167
35168					{
35169						var consequent_3 = ($$anchor) => {
35170							var fragment_4 = comment();
35171							var node_6 = first_child(fragment_4);
35172
35173							html$1(node_6, () => get$1(display_text));
35174							append$1($$anchor, fragment_4);
35175						};
35176
35177						var alternate_1 = ($$anchor) => {
35178							var fragment_5 = comment();
35179							var node_7 = first_child(fragment_5);
35180
35181							{
35182								var consequent_4 = ($$anchor) => {
35183									{
35184										let $0 = derived_safe_equal(() => (
35185											get$1(display_text),
35186											untrack(() => get$1(display_text).toLocaleString())
35187										));
35188
35189										MarkdownCode$1($$anchor, {
35190											get message() {
35191												return get$1($0);
35192											},
35193
35194											get latex_delimiters() {
35195												return latex_delimiters();
35196											},
35197
35198											get line_breaks() {
35199												return line_breaks();
35200											},
35201											chatbot: false
35202										});
35203									}
35204								};
35205
35206								var alternate = ($$anchor) => {
35207									var text_1 = text$1();
35208
35209									template_effect(() => set_text(text_1, get$1(display_text)));
35210									append$1($$anchor, text_1);
35211								};
35212
35213								if_block(
35214									node_7,
35215									($$render) => {
35216										if (datatype() === "markdown") $$render(consequent_4); else $$render(alternate, false);
35217									},
35218									true
35219								);
35220							}
35221
35222							append$1($$anchor, fragment_5);
35223						};
35224
35225						if_block(
35226							node_5,
35227							($$render) => {
35228								if (datatype() === "html") $$render(consequent_3); else $$render(alternate_1, false);
35229							},
35230							true
35231						);
35232					}
35233
35234					append$1($$anchor, fragment_3);
35235				};
35236
35237				if_block(node_3, ($$render) => {
35238					if ((
35239						deep_read_state(datatype()),
35240						deep_read_state(components()),
35241						untrack(() => datatype() === "image" && components().image)
35242					)) $$render(consequent_2); else $$render(alternate_2, false);
35243				});
35244			}
35245
35246			reset(span);
35247
35248			template_effect(() => {
35249				set_style$1(span, styling());
35250				set_attribute(span, 'data-editable', editable());
35251				set_attribute(span, 'data-max-chars', max_chars());
35252				set_attribute(span, 'data-expanded', edit());
35253
35254				classes_1 = set_class(span, 1, 'svelte-odwpey', null, classes_1, {
35255					dragging: is_dragging(),
35256					edit: edit(),
35257					expanded: edit(),
35258					multiline: header(),
35259					text: datatype() === "str",
35260					wrap: wrap_text()
35261				});
35262			});
35263
35264			event('keydown', span, handle_keydown);
35265
35266			event('focus', span, preventDefault(function ($$arg) {
35267				bubble_event.call(this, $$props, $$arg);
35268			}));
35269
35270			append$1($$anchor, span);
35271		};
35272
35273		if_block(node_2, ($$render) => {
35274			if (datatype() === "bool" && typeof value() === "boolean") $$render(consequent_1); else $$render(alternate_3, false);
35275		});
35276	}
35277
35278	var node_8 = sibling(node_2, 2);
35279
35280	{
35281		var consequent_5 = ($$anchor) => {
35282			var fragment_8 = root_10$1();
35283			var node_9 = first_child(fragment_8);
35284
35285			SelectionButtons(node_9, {
35286				position: 'column',
35287				get coords() {
35288					return coords();
35289				},
35290				on_click: () => on_select_column()(coords()[1])
35291			});
35292
35293			var node_10 = sibling(node_9, 2);
35294
35295			SelectionButtons(node_10, {
35296				position: 'row',
35297				get coords() {
35298					return coords();
35299				},
35300				on_click: () => on_select_row()(coords()[0])
35301			});
35302
35303			append$1($$anchor, fragment_8);
35304		};
35305
35306		if_block(node_8, ($$render) => {
35307			if (show_selection_buttons() && coords() && on_select_column() && on_select_row()) $$render(consequent_5);
35308		});
35309	}
35310
35311	append$1($$anchor, fragment);
35312
35313	return pop($$exports);
35314}
35315
35316var root_1$7 = from_html(`<th tabindex="-1" class="row-number svelte-11p754p"><div class="cell-wrap"><div class="header-content"><div class="header-text"></div></div></div></th>`);
35317var root_2$5 = from_html(`<td class="row-number svelte-11p754p" tabindex="-1" data-col="row-number"> </td>`);
35318
35319function RowNumber($$anchor, $$props) {
35320	push($$props, false);
35321
35322	let index = prop($$props, 'index', 12, null);
35323	let is_header = prop($$props, 'is_header', 12, false);
35324
35325	var $$exports = {
35326		get index() {
35327			return index();
35328		},
35329
35330		set index($$value) {
35331			index($$value);
35332			flushSync();
35333		},
35334
35335		get is_header() {
35336			return is_header();
35337		},
35338
35339		set is_header($$value) {
35340			is_header($$value);
35341			flushSync();
35342		}
35343	};
35344
35345	var fragment = comment();
35346	var node = first_child(fragment);
35347
35348	{
35349		var consequent = ($$anchor) => {
35350			var th = root_1$7();
35351
35352			append$1($$anchor, th);
35353		};
35354
35355		var alternate = ($$anchor) => {
35356			var td = root_2$5();
35357			var text = child(td, true);
35358
35359			reset(td);
35360
35361			template_effect(() => {
35362				set_attribute(td, 'data-row', index());
35363				set_text(text, index() !== null ? index() + 1 : "");
35364			});
35365
35366			append$1($$anchor, td);
35367		};
35368
35369		if_block(node, ($$render) => {
35370			if (is_header()) $$render(consequent); else $$render(alternate, false);
35371		});
35372	}
35373
35374	append$1($$anchor, fragment);
35375
35376	return pop($$exports);
35377}
35378
35379var root$b = from_html(`<button aria-label="Open cell menu" class="cell-menu-button svelte-j6wkfp" aria-haspopup="menu">&#8942;</button>`);
35380
35381function CellMenuButton($$anchor, $$props) {
35382	push($$props, false);
35383
35384	let on_click = prop($$props, 'on_click', 12);
35385
35386	var $$exports = {
35387		get on_click() {
35388			return on_click();
35389		},
35390
35391		set on_click($$value) {
35392			on_click($$value);
35393			flushSync();
35394		}
35395	};
35396
35397	init$1();
35398
35399	var button = root$b();
35400
35401	event('click', button, function (...$$args) {
35402		on_click()?.apply(this, $$args);
35403	});
35404
35405	event('touchstart', button, (event) => {
35406		event.preventDefault();
35407
35408		const touch = event.touches[0];
35409
35410		const mouseEvent = new MouseEvent("click", {
35411			clientX: touch.clientX,
35412			clientY: touch.clientY,
35413			bubbles: true,
35414			cancelable: true,
35415			view: window
35416		});
35417
35418		on_click()(mouseEvent);
35419	});
35420
35421	append$1($$anchor, button);
35422
35423	return pop($$exports);
35424}
35425
35426var root$a = from_html(`<div class="wrapper svelte-4dxgzr" aria-label="Static column"><svg xmlns="http://www.w3.org/2000/svg" width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"></rect><path d="M7 11V7a5 5 0 0 1 10 0v4"></path></svg></div>`);
35427
35428function Padlock($$anchor) {
35429	var div = root$a();
35430
35431	append$1($$anchor, div);
35432}
35433
35434var root$9 = from_svg(`<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 8L8 4L12 8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M8 4V12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>`);
35435
35436function SortArrowUp($$anchor, $$props) {
35437	push($$props, false);
35438
35439	let size = prop($$props, 'size', 12, 16);
35440
35441	var $$exports = {
35442		get size() {
35443			return size();
35444		},
35445
35446		set size($$value) {
35447			size($$value);
35448			flushSync();
35449		}
35450	};
35451
35452	var svg = root$9();
35453
35454	template_effect(() => {
35455		set_attribute(svg, 'width', size());
35456		set_attribute(svg, 'height', size());
35457	});
35458
35459	append$1($$anchor, svg);
35460
35461	return pop($$exports);
35462}
35463
35464var root$8 = from_svg(`<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 8L8 12L12 8" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"></path><path d="M8 12V4" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"></path></svg>`);
35465
35466function SortArrowDown($$anchor, $$props) {
35467	push($$props, false);
35468
35469	let size = prop($$props, 'size', 12, 16);
35470
35471	var $$exports = {
35472		get size() {
35473			return size();
35474		},
35475
35476		set size($$value) {
35477			size($$value);
35478			flushSync();
35479		}
35480	};
35481
35482	var svg = root$8();
35483
35484	template_effect(() => {
35485		set_attribute(svg, 'width', size());
35486		set_attribute(svg, 'height', size());
35487	});
35488
35489	append$1($$anchor, svg);
35490
35491	return pop($$exports);
35492}
35493
35494var root_1$6 = from_svg(`<svg viewBox="0 0 24 24" width="16" height="16"><rect x="4" y="6" width="4" height="12" stroke="currentColor" stroke-width="2" fill="none"></rect>
35494<path d="M12 12H19M16 8L19 12L16 16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"></path></svg>`);
35495var root_3$2 = from_svg(`<svg viewBox="0 0 24 24" width="16" height="16"><rect x="16" y="6" width="4" height="12" stroke="currentColor" stroke-width="2" fill="none"></rect><path d="M12 12H5M8 8L5 12L8 16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"></path></svg>`);
35496var root_5$2 = from_svg(`<svg viewBox="0 0 24 24" width="16" height="16"><rect x="6" y="16" width="12" height="4" stroke="currentColor" stroke-width="2"></rect><path d="M12 12V5M8 8L12 5L16 8" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"></path></svg>`);
35497var root_7$1 = from_svg(`<svg viewBox="0 0 24 24" width="16" height="16"><rect x="6" y="4" width="12" height="4" stroke="currentColor" stroke-width="2"></rect><path d="M12 12V19M8 16L12 19L16 16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"></path></svg>`);
35498var root_9$1 = from_svg(`<svg viewBox="0 0 24 24" width="16" height="16"><rect x="5" y="10" width="14" height="4" stroke="currentColor" stroke-width="2"></rect><path d="M8 7L16 17M16 7L8 17" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>`);
35499var root_11 = from_svg(`<svg viewBox="0 0 24 24" width="16" height="16"><rect x="10" y="5" width="4" height="14" stroke="currentColor" stroke-width="2"></rect><path d="M7 8L17 16M17 8L7 16" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>`);
35500var root_13$1 = from_svg(`<svg viewBox="0 0 24 24" width="16" height="16"><path d="M8 16L12 12L16 16" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"></path><path d="M12 12V19" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M5 7H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>`);
35501var root_15 = from_svg(`<svg viewBox="0 0 24 24" width="16" height="16"><path d="M8 12L12 16L16 12" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round" stroke-linejoin="round"></path><path d="M12 16V9" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M5 5H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>`);
35502var root_17 = from_svg(`<svg viewBox="0 0 24 24" width="16" height="16"><path d="M5 5H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M5 9H15" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M5 13H11" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M5 17H7" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M17 17L21 21M21 17L17 21" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>`);
35503var root_19 = from_svg(`<svg viewBox="0 0 24 24" width="16" height="16"><path d="M5 5H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M8 9H16" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M11 13H13" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>`);
35504var root_21 = from_svg(`<svg viewBox="0 0 24 24" width="16" height="16"><path d="M5 5H19" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M8 9H16" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M11 13H13" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path><path d="M17 17L21 21M21 17L17 21" stroke="currentColor" stroke-width="2" stroke-linecap="round"></path></svg>`);
35505
35506function CellMenuIcons($$anchor, $$props) {
35507	push($$props, false);
35508
35509	let icon = prop($$props, 'icon', 12);
35510
35511	var $$exports = {
35512		get icon() {
35513			return icon();
35514		},
35515
35516		set icon($$value) {
35517			icon($$value);
35518			flushSync();
35519		}
35520	};
35521
35522	var fragment = comment();
35523	var node = first_child(fragment);
35524
35525	{
35526		var consequent = ($$anchor) => {
35527			var svg = root_1$6();
35528
35529			append$1($$anchor, svg);
35530		};
35531
35532		var alternate_9 = ($$anchor) => {
35533			var fragment_1 = comment();
35534			var node_1 = first_child(fragment_1);
35535
35536			{
35537				var consequent_1 = ($$anchor) => {
35538					var svg_1 = root_3$2();
35539
35540					append$1($$anchor, svg_1);
35541				};
35542
35543				var alternate_8 = ($$anchor) => {
35544					var fragment_2 = comment();
35545					var node_2 = first_child(fragment_2);
35546
35547					{
35548						var consequent_2 = ($$anchor) => {
35549							var svg_2 = root_5$2();
35550
35551							append$1($$anchor, svg_2);
35552						};
35553
35554						var alternate_7 = ($$anchor) => {
35555							var fragment_3 = comment();
35556							var node_3 = first_child(fragment_3);
35557
35558							{
35559								var consequent_3 = ($$anchor) => {
35560									var svg_3 = root_7$1();
35561
35562									append$1($$anchor, svg_3);
35563								};
35564
35565								var alternate_6 = ($$anchor) => {
35566									var fragment_4 = comment();
35567									var node_4 = first_child(fragment_4);
35568
35569									{
35570										var consequent_4 = ($$anchor) => {
35571											var svg_4 = root_9$1();
35572
35573											append$1($$anchor, svg_4);
35574										};
35575
35576										var alternate_5 = ($$anchor) => {
35577											var fragment_5 = comment();
35578											var node_5 = first_child(fragment_5);
35579
35580											{
35581												var consequent_5 = ($$anchor) => {
35582													var svg_5 = root_11();
35583
35584													append$1($$anchor, svg_5);
35585												};
35586
35587												var alternate_4 = ($$anchor) => {
35588													var fragment_6 = comment();
35589													var node_6 = first_child(fragment_6);
35590
35591													{
35592														var consequent_6 = ($$anchor) => {
35593															var svg_6 = root_13$1();
35594
35595															append$1($$anchor, svg_6);
35596														};
35597
35598														var alternate_3 = ($$anchor) => {
35599															var fragment_7 = comment();
35600															var node_7 = first_child(fragment_7);
35601
35602															{
35603																var consequent_7 = ($$anchor) => {
35604																	var svg_7 = root_15();
35605
35606																	append$1($$anchor, svg_7);
35607																};
35608
35609																var alternate_2 = ($$anchor) => {
35610																	var fragment_8 = comment();
35611																	var node_8 = first_child(fragment_8);
35612
35613																	{
35614																		var consequent_8 = ($$anchor) => {
35615																			var svg_8 = root_17();
35616
35617																			append$1($$anchor, svg_8);
35618																		};
35619
35620																		var alternate_1 = ($$anchor) => {
35621																			var fragment_9 = comment();
35622																			var node_9 = first_child(fragment_9);
35623
35624																			{
35625																				var consequent_9 = ($$anchor) => {
35626																					var svg_9 = root_19();
35627
35628																					append$1($$anchor, svg_9);
35629																				};
35630
35631																				var alternate = ($$anchor) => {
35632																					var fragment_10 = comment();
35633																					var node_10 = first_child(fragment_10);
35634
35635																					{
35636																						var consequent_10 = ($$anchor) => {
35637																							var svg_10 = root_21();
35638
35639																							append$1($$anchor, svg_10);
35640																						};
35641
35642																						if_block(
35643																							node_10,
35644																							($$render) => {
35645																								if (icon() == "clear-filter") $$render(consequent_10);
35646																							},
35647																							true
35648																						);
35649																					}
35650
35651																					append$1($$anchor, fragment_10);
35652																				};
35653
35654																				if_block(
35655																					node_9,
35656																					($$render) => {
35657																						if (icon() == "filter") $$render(consequent_9); else $$render(alternate, false);
35658																					},
35659																					true
35660																				);
35661																			}
35662
35663																			append$1($$anchor, fragment_9);
35664																		};
35665
35666																		if_block(
35667																			node_8,
35668																			($$render) => {
35669																				if (icon() == "clear-sort") $$render(consequent_8); else $$render(alternate_1, false);
35670																			},
35671																			true
35672																		);
35673																	}
35674
35675																	append$1($$anchor, fragment_8);
35676																};
35677
35678																if_block(
35679																	node_7,
35680																	($$render) => {
35681																		if (icon() == "sort-desc") $$render(consequent_7); else $$render(alternate_2, false);
35682																	},
35683																	true
35684																);
35685															}
35686
35687															append$1($$anchor, fragment_7);
35688														};
35689
35690														if_block(
35691															node_6,
35692															($$render) => {
35693																if (icon() == "sort-asc") $$render(consequent_6); else $$render(alternate_3, false);
35694															},
35695															true
35696														);
35697													}
35698
35699													append$1($$anchor, fragment_6);
35700												};
35701
35702												if_block(
35703													node_5,
35704													($$render) => {
35705														if (icon() == "delete-column") $$render(consequent_5); else $$render(alternate_4, false);
35706													},
35707													true
35708												);
35709											}
35710
35711											append$1($$anchor, fragment_5);
35712										};
35713
35714										if_block(
35715											node_4,
35716											($$render) => {
35717												if (icon() == "delete-row") $$render(consequent_4); else $$render(alternate_5, false);
35718											},
35719											true
35720										);
35721									}
35722
35723									append$1($$anchor, fragment_4);
35724								};
35725
35726								if_block(
35727									node_3,
35728									($$render) => {
35729										if (icon() == "add-row-below") $$render(consequent_3); else $$render(alternate_6, false);
35730									},
35731									true
35732								);
35733							}
35734
35735							append$1($$anchor, fragment_3);
35736						};
35737
35738						if_block(
35739							node_2,
35740							($$render) => {
35741								if (icon() == "add-row-above") $$render(consequent_2); else $$render(alternate_7, false);
35742							},
35743							true
35744						);
35745					}
35746
35747					append$1($$anchor, fragment_2);
35748				};
35749
35750				if_block(
35751					node_1,
35752					($$render) => {
35753						if (icon() == "add-column-left") $$render(consequent_1); else $$render(alternate_8, false);
35754					},
35755					true
35756				);
35757			}
35758
35759			append$1($$anchor, fragment_1);
35760		};
35761
35762		if_block(node, ($$render) => {
35763			if (icon() == "add-column-right") $$render(consequent); else $$render(alternate_9, false);
35764		});
35765	}
35766
35767	append$1($$anchor, fragment);
35768
35769	return pop($$exports);
35770}
35771
35772var root_1$5 = from_html(`<div class="select-all-checkbox svelte-1yuystx" role="button" tabindex="0"><!></div>`);
35773var root_5$1 = from_html(`<span class="sort-priority svelte-1yuystx"> </span>`);
35774var root_2$4 = from_html(`<div class="sort-indicators svelte-1yuystx"><span class="sort-arrow svelte-1yuystx"><!></span> <!></div>`);
35775var root_6$1 = from_html(`<div class="filter-indicators svelte-1yuystx"><span class="filter-icon svelte-1yuystx"><!></span></div>`);
35776var root$7 = from_html(`<th><div class="cell-wrap svelte-1yuystx"><div class="header-content svelte-1yuystx"><!> <button class="header-button svelte-1yuystx"><!> <!> <!></button> <!></div> <!></div></th>`);
35777
35778function TableHeader($$anchor, $$props) {
35779	push($$props, false);
35780
35781	const can_add_columns = mutable_source();
35782	const is_bool_column = mutable_source();
35783	const select_all_state = mutable_source();
35784	const sort_index = mutable_source();
35785	const filter_index = mutable_source();
35786	const sort_priority = mutable_source();
35787	const current_direction = mutable_source();
35788	let value = prop($$props, 'value', 12);
35789	let i = prop($$props, 'i', 12);
35790	let datatype = prop($$props, 'datatype', 12, "str");
35791	let actual_pinned_columns = prop($$props, 'actual_pinned_columns', 12);
35792	let header_edit = prop($$props, 'header_edit', 12);
35793	let selected_header = prop($$props, 'selected_header', 12);
35794	let headers = prop($$props, 'headers', 12);
35795	let get_cell_width = prop($$props, 'get_cell_width', 12);
35796	let handle_header_click = prop($$props, 'handle_header_click', 12);
35797	let toggle_header_menu = prop($$props, 'toggle_header_menu', 12);
35798	let end_header_edit = prop($$props, 'end_header_edit', 12);
35799	let sort_columns = prop($$props, 'sort_columns', 28, () => []);
35800	let filter_columns = prop($$props, 'filter_columns', 28, () => []);
35801	let latex_delimiters = prop($$props, 'latex_delimiters', 12);
35802	let line_breaks = prop($$props, 'line_breaks', 12);
35803	let max_chars = prop($$props, 'max_chars', 12);
35804	let editable = prop($$props, 'editable', 12);
35805	let i18n = prop($$props, 'i18n', 12);
35806	let el = prop($$props, 'el', 12);
35807	let is_static = prop($$props, 'is_static', 12);
35808	let col_count = prop($$props, 'col_count', 12);
35809	let data = prop($$props, 'data', 28, () => []);
35810	let on_select_all = prop($$props, 'on_select_all', 12, undefined);
35811
35812	function get_header_position(col_index) {
35813		if (col_index >= actual_pinned_columns()) {
35814			return "auto";
35815		}
35816
35817		if (col_index === 0) {
35818			return "0";
35819		}
35820
35821		const previous_widths = Array(col_index).fill(0).map((_, idx) => {
35822			return get_cell_width()(idx);
35823		}).join(" + ");
35824
35825		return `calc(${previous_widths})`;
35826	}
35827
35828	legacy_pre_effect(() => (deep_read_state(col_count())), () => {
35829		set(can_add_columns, col_count() && col_count()[1] === "dynamic");
35830	});
35831
35832	legacy_pre_effect(() => (deep_read_state(datatype())), () => {
35833		set(is_bool_column, datatype() === "bool");
35834	});
35835
35836	legacy_pre_effect(
35837		() => (
35838			get$1(is_bool_column),
35839			deep_read_state(data()),
35840			deep_read_state(i())
35841		),
35842		() => {
35843			set(select_all_state, (() => {
35844				if (!get$1(is_bool_column) || data().length === 0) return "unchecked";
35845
35846				const true_count = data().filter((row) => row[i()]?.value === true || row[i()]?.value === "true").length;
35847
35848				if (true_count === 0) return "unchecked";
35849				if (true_count === data().length) return "checked";
35850
35851				return "indeterminate";
35852			})());
35853		}
35854	);
35855
35856	legacy_pre_effect(() => (deep_read_state(sort_columns()), deep_read_state(i())), () => {
35857		set(sort_index, sort_columns().findIndex((item) => item.col === i()));
35858	});
35859
35860	legacy_pre_effect(() => (deep_read_state(filter_columns()), deep_read_state(i())), () => {
35861		set(filter_index, filter_columns().findIndex((item) => item.col === i()));
35862	});
35863
35864	legacy_pre_effect(() => (get$1(sort_index)), () => {
35865		set(sort_priority, get$1(sort_index) !== -1 ? get$1(sort_index) + 1 : null);
35866	});
35867
35868	legacy_pre_effect(() => (get$1(sort_index), deep_read_state(sort_columns())), () => {
35869		set(current_direction, get$1(sort_index) !== -1 ? sort_columns()[get$1(sort_index)].direction : null);
35870	});
35871
35872	legacy_pre_effect_reset();
35873
35874	var $$exports = {
35875		get value() {
35876			return value();
35877		},
35878
35879		set value($$value) {
35880			value($$value);
35881			flushSync();
35882		},
35883
35884		get i() {
35885			return i();
35886		},
35887
35888		set i($$value) {
35889			i($$value);
35890			flushSync();
35891		},
35892
35893		get datatype() {
35894			return datatype();
35895		},
35896
35897		set datatype($$value) {
35898			datatype($$value);
35899			flushSync();
35900		},
35901
35902		get actual_pinned_columns() {
35903			return actual_pinned_columns();
35904		},
35905
35906		set actual_pinned_columns($$value) {
35907			actual_pinned_columns($$value);
35908			flushSync();
35909		},
35910
35911		get header_edit() {
35912			return header_edit();
35913		},
35914
35915		set header_edit($$value) {
35916			header_edit($$value);
35917			flushSync();
35918		},
35919
35920		get selected_header() {
35921			return selected_header();
35922		},
35923
35924		set selected_header($$value) {
35925			selected_header($$value);
35926			flushSync();
35927		},
35928
35929		get headers() {
35930			return headers();
35931		},
35932
35933		set headers($$value) {
35934			headers($$value);
35935			flushSync();
35936		},
35937
35938		get get_cell_width() {
35939			return get_cell_width();
35940		},
35941
35942		set get_cell_width($$value) {
35943			get_cell_width($$value);
35944			flushSync();
35945		},
35946
35947		get handle_header_click() {
35948			return handle_header_click();
35949		},
35950
35951		set handle_header_click($$value) {
35952			handle_header_click($$value);
35953			flushSync();
35954		},
35955
35956		get toggle_header_menu() {
35957			return toggle_header_menu();
35958		},
35959
35960		set toggle_header_menu($$value) {
35961			toggle_header_menu($$value);
35962			flushSync();
35963		},
35964
35965		get end_header_edit() {
35966			return end_header_edit();
35967		},
35968
35969		set end_header_edit($$value) {
35970			end_header_edit($$value);
35971			flushSync();
35972		},
35973
35974		get sort_columns() {
35975			return sort_columns();
35976		},
35977
35978		set sort_columns($$value) {
35979			sort_columns($$value);
35980			flushSync();
35981		},
35982
35983		get filter_columns() {
35984			return filter_columns();
35985		},
35986
35987		set filter_columns($$value) {
35988			filter_columns($$value);
35989			flushSync();
35990		},
35991
35992		get latex_delimiters() {
35993			return latex_delimiters();
35994		},
35995
35996		set latex_delimiters($$value) {
35997			latex_delimiters($$value);
35998			flushSync();
35999		},
36000
36001		get line_breaks() {
36002			return line_breaks();
36003		},
36004
36005		set line_breaks($$value) {
36006			line_breaks($$value);
36007			flushSync();
36008		},
36009
36010		get max_chars() {
36011			return max_chars();
36012		},
36013
36014		set max_chars($$value) {
36015			max_chars($$value);
36016			flushSync();
36017		},
36018
36019		get editable() {
36020			return editable();
36021		},
36022
36023		set editable($$value) {
36024			editable($$value);
36025			flushSync();
36026		},
36027
36028		get i18n() {
36029			return i18n();
36030		},
36031
36032		set i18n($$value) {
36033			i18n($$value);
36034			flushSync();
36035		},
36036
36037		get el() {
36038			return el();
36039		},
36040
36041		set el($$value) {
36042			el($$value);
36043			flushSync();
36044		},
36045
36046		get is_static() {
36047			return is_static();
36048		},
36049
36050		set is_static($$value) {
36051			is_static($$value);
36052			flushSync();
36053		},
36054
36055		get col_count() {
36056			return col_count();
36057		},
36058
36059		set col_count($$value) {
36060			col_count($$value);
36061			flushSync();
36062		},
36063
36064		get data() {
36065			return data();
36066		},
36067
36068		set data($$value) {
36069			data($$value);
36070			flushSync();
36071		},
36072
36073		get on_select_all() {
36074			return on_select_all();
36075		},
36076
36077		set on_select_all($$value) {
36078			on_select_all($$value);
36079			flushSync();
36080		}
36081	};
36082
36083	init$1();
36084
36085	var th = root$7();
36086	let classes;
36087	var div = child(th);
36088	var div_1 = child(div);
36089	var node = child(div_1);
36090
36091	{
36092		var consequent = ($$anchor) => {
36093			var div_2 = root_1$5();
36094			var node_1 = child(div_2);
36095
36096			{
36097				let $0 = derived_safe_equal(() => get$1(select_all_state) === "checked");
36098				let $1 = derived_safe_equal(() => get$1(select_all_state) === "indeterminate");
36099
36100				Checkbox$1(node_1, {
36101					get value() {
36102						return get$1($0);
36103					},
36104
36105					get indeterminate() {
36106						return get$1($1);
36107					},
36108					label: '',
36109					interactive: true,
36110					$$events: {
36111						select: () => {
36112							if (on_select_all()) {
36113								const new_value = get$1(select_all_state) !== "checked";
36114
36115								on_select_all()(i(), new_value);
36116							}
36117						}
36118					}
36119				});
36120			}
36121
36122			reset(div_2);
36123
36124			event('click', div_2, stopPropagation(function ($$arg) {
36125				bubble_event.call(this, $$props, $$arg);
36126			}));
36127
36128			event('keydown', div_2, stopPropagation((e) => {
36129				if (e.key === "Enter" || e.key === " ") {
36130					e.preventDefault();
36131				}
36132			}));
36133
36134			event('mousedown', div_2, stopPropagation(function ($$arg) {
36135				bubble_event.call(this, $$props, $$arg);
36136			}));
36137
36138			append$1($$anchor, div_2);
36139		};
36140
36141		if_block(node, ($$render) => {
36142			if (get$1(is_bool_column) && editable() && on_select_all()) $$render(consequent);
36143		});
36144	}
36145
36146	var button = sibling(node, 2);
36147	var node_2 = child(button);
36148
36149	{
36150		let $0 = derived_safe_equal(() => header_edit() === i());
36151		let $1 = derived_safe_equal(() => [i(), 0]);
36152
36153		EditableCell(node_2, {
36154			get max_chars() {
36155				return max_chars();
36156			},
36157
36158			get latex_delimiters() {
36159				return latex_delimiters();
36160			},
36161
36162			get line_breaks() {
36163				return line_breaks();
36164			},
36165
36166			get edit() {
36167				return get$1($0);
36168			},
36169			header: true,
36170			get editable() {
36171				return editable();
36172			},
36173
36174			get is_static() {
36175				return is_static();
36176			},
36177
36178			get i18n() {
36179				return i18n();
36180			},
36181
36182			get coords() {
36183				return get$1($1);
36184			},
36185
36186			get value() {
36187				return value();
36188			},
36189
36190			set value($$value) {
36191				value($$value);
36192			},
36193
36194			get el() {
36195				return el();
36196			},
36197
36198			set el($$value) {
36199				el($$value);
36200			},
36201
36202			$$events: {
36203				keydown: (event) => {
36204					if (event.detail.key === "Enter" || event.detail.key === "Escape" || event.detail.key === "Tab") {
36205						end_header_edit()(event);
36206					}
36207				}
36208			},
36209			$$legacy: true
36210		});
36211	}
36212
36213	var node_3 = sibling(node_2, 2);
36214
36215	{
36216		var consequent_3 = ($$anchor) => {
36217			var div_3 = root_2$4();
36218			var span = child(div_3);
36219			var node_4 = child(span);
36220
36221			{
36222				var consequent_1 = ($$anchor) => {
36223					SortArrowUp($$anchor, { size: 12 });
36224				};
36225
36226				var alternate = ($$anchor) => {
36227					SortArrowDown($$anchor, { size: 12 });
36228				};
36229
36230				if_block(node_4, ($$render) => {
36231					if (get$1(current_direction) === "asc") $$render(consequent_1); else $$render(alternate, false);
36232				});
36233			}
36234
36235			reset(span);
36236
36237			var node_5 = sibling(span, 2);
36238
36239			{
36240				var consequent_2 = ($$anchor) => {
36241					var span_1 = root_5$1();
36242					var text = child(span_1, true);
36243
36244					reset(span_1);
36245					template_effect(() => set_text(text, get$1(sort_priority)));
36246					append$1($$anchor, span_1);
36247				};
36248
36249				if_block(node_5, ($$render) => {
36250					if ((
36251						deep_read_state(sort_columns()),
36252						untrack(() => sort_columns().length > 1)
36253					)) $$render(consequent_2);
36254				});
36255			}
36256
36257			reset(div_3);
36258			append$1($$anchor, div_3);
36259		};
36260
36261		if_block(node_3, ($$render) => {
36262			if (get$1(sort_index) !== -1) $$render(consequent_3);
36263		});
36264	}
36265
36266	var node_6 = sibling(node_3, 2);
36267
36268	{
36269		var consequent_4 = ($$anchor) => {
36270			var div_4 = root_6$1();
36271			var span_2 = child(div_4);
36272			var node_7 = child(span_2);
36273
36274			CellMenuIcons(node_7, { icon: 'filter' });
36275			reset(span_2);
36276			reset(div_4);
36277			append$1($$anchor, div_4);
36278		};
36279
36280		if_block(node_6, ($$render) => {
36281			if (get$1(filter_index) !== -1) $$render(consequent_4);
36282		});
36283	}
36284
36285	reset(button);
36286
36287	var node_8 = sibling(button, 2);
36288
36289	{
36290		var consequent_5 = ($$anchor) => {
36291			Padlock($$anchor);
36292		};
36293
36294		if_block(node_8, ($$render) => {
36295			if (is_static()) $$render(consequent_5);
36296		});
36297	}
36298
36299	reset(div_1);
36300
36301	var node_9 = sibling(div_1, 2);
36302
36303	{
36304		var consequent_6 = ($$anchor) => {
36305			CellMenuButton($$anchor, { on_click: (event) => toggle_header_menu()(event, i()) });
36306		};
36307
36308		if_block(node_9, ($$render) => {
36309			if (get$1(can_add_columns)) $$render(consequent_6);
36310		});
36311	}
36312
36313	reset(div);
36314	reset(th);
36315
36316	template_effect(
36317		($0, $1, $2) => {
36318			set_attribute(th, 'aria-sort', $0);
36319			set_style$1(th, `width: ${$1 ?? ''}; left: ${$2 ?? ''};`);
36320			set_attribute(th, 'title', value());
36321
36322			classes = set_class(th, 1, 'svelte-1yuystx', null, classes, {
36323				'pinned-column': i() < actual_pinned_columns(),
36324				'last-pinned': i() === actual_pinned_columns() - 1,
36325				focus: header_edit() === i() || selected_header() === i(),
36326				sorted: get$1(sort_index) !== -1,
36327				filtered: get$1(filter_index) !== -1
36328			});
36329
36330			set_attribute(button, 'title', value());
36331		},
36332		[
36333			() => (
36334				deep_read_state(get_sort_status),
36335				deep_read_state(value()),
36336				deep_read_state(sort_columns()),
36337				deep_read_state(headers()),
36338				untrack(() => get_sort_status(value(), sort_columns(), headers()) === "none"
36339					? "none"
36340					: get_sort_status(value(), sort_columns(), headers()) === "asc" ? "ascending" : "descending")
36341			),
36342
36343			() => (
36344				deep_read_state(get_cell_width()),
36345				deep_read_state(i()),
36346				untrack(() => get_cell_width()(i()))
36347			),
36348
36349			() => (
36350				deep_read_state(i()),
36351				untrack(() => get_header_position(i()))
36352			)
36353		]
36354	);
36355
36356	event('click', button, (event) => handle_header_click()(event, i()));
36357
36358	event('mousedown', button, (event) => {
36359		event.preventDefault();
36360		event.stopPropagation();
36361	});
36362
36363	event('click', th, (event) => handle_header_click()(event, i()));
36364
36365	event('mousedown', th, (event) => {
36366		event.preventDefault();
36367		event.stopPropagation();
36368	});
36369
36370	append$1($$anchor, th);
36371
36372	return pop($$exports);
36373}
36374
36375var root$6 = from_html(`<td><div class="cell-wrap svelte-18bs22a"><!> <!></div></td>`);
36376
36377function TableCell($$anchor, $$props) {
36378	push($$props, false);
36379
36380	const cell_classes = mutable_source();
36381	const is_in_selection = mutable_source();
36382	const has_no_top = mutable_source();
36383	const has_no_bottom = mutable_source();
36384	const has_no_left = mutable_source();
36385	const has_no_right = mutable_source();
36386	let value = prop($$props, 'value', 12);
36387	let index = prop($$props, 'index', 12);
36388	let j = prop($$props, 'j', 12);
36389	let actual_pinned_columns = prop($$props, 'actual_pinned_columns', 12);
36390	let get_cell_width = prop($$props, 'get_cell_width', 12);
36391	let handle_cell_click = prop($$props, 'handle_cell_click', 12);
36392	let handle_blur = prop($$props, 'handle_blur', 12);
36393	let toggle_cell_menu = prop($$props, 'toggle_cell_menu', 12);
36394	let is_cell_selected = prop($$props, 'is_cell_selected', 12);
36395	let should_show_cell_menu = prop($$props, 'should_show_cell_menu', 12);
36396	let selected_cells = prop($$props, 'selected_cells', 12);
36397	let copy_flash = prop($$props, 'copy_flash', 12);
36398	let active_cell_menu = prop($$props, 'active_cell_menu', 12);
36399	let styling = prop($$props, 'styling', 12);
36400	let latex_delimiters = prop($$props, 'latex_delimiters', 12);
36401	let line_breaks = prop($$props, 'line_breaks', 12);
36402	let datatype = prop($$props, 'datatype', 12);
36403	let editing = prop($$props, 'editing', 12);
36404	let max_chars = prop($$props, 'max_chars', 12);
36405	let editable = prop($$props, 'editable', 12);
36406	let is_static = prop($$props, 'is_static', 12, false);
36407	let i18n = prop($$props, 'i18n', 12);
36408	let components = prop($$props, 'components', 28, () => ({}));
36409	let el = prop($$props, 'el', 12);
36410	let handle_select_column = prop($$props, 'handle_select_column', 12);
36411	let handle_select_row = prop($$props, 'handle_select_row', 12);
36412	let is_dragging = prop($$props, 'is_dragging', 12);
36413	let display_value = prop($$props, 'display_value', 12);
36414	let wrap = prop($$props, 'wrap', 12, false);
36415
36416	function get_cell_position(col_index) {
36417		if (col_index >= actual_pinned_columns()) {
36418			return "auto";
36419		}
36420
36421		if (col_index === 0) {
36422			return "0";
36423		}
36424
36425		const previous_widths = Array(col_index).fill(0).map((_, idx) => {
36426			return get_cell_width()(idx);
36427		}).join(" + ");
36428
36429		return `calc(${previous_widths})`;
36430	}
36431
36432	legacy_pre_effect(
36433		() => (
36434			deep_read_state(is_cell_selected()),
36435			deep_read_state(index()),
36436			deep_read_state(j()),
36437			deep_read_state(selected_cells())
36438		),
36439		() => {
36440			set(cell_classes, is_cell_selected()([index(), j()], selected_cells() || []));
36441		}
36442	);
36443
36444	legacy_pre_effect(
36445		() => (
36446			deep_read_state(index()),
36447			deep_read_state(j()),
36448			deep_read_state(selected_cells())
36449		),
36450		() => {
36451			set(is_in_selection, is_cell_in_selection([index(), j()], selected_cells()));
36452		}
36453	);
36454
36455	legacy_pre_effect(() => (get$1(cell_classes)), () => {
36456		set(has_no_top, get$1(cell_classes).includes("no-top"));
36457	});
36458
36459	legacy_pre_effect(() => (get$1(cell_classes)), () => {
36460		set(has_no_bottom, get$1(cell_classes).includes("no-bottom"));
36461	});
36462
36463	legacy_pre_effect(() => (get$1(cell_classes)), () => {
36464		set(has_no_left, get$1(cell_classes).includes("no-left"));
36465	});
36466
36467	legacy_pre_effect(() => (get$1(cell_classes)), () => {
36468		set(has_no_right, get$1(cell_classes).includes("no-right"));
36469	});
36470
36471	legacy_pre_effect_reset();
36472
36473	var $$exports = {
36474		get value() {
36475			return value();
36476		},
36477
36478		set value($$value) {
36479			value($$value);
36480			flushSync();
36481		},
36482
36483		get index() {
36484			return index();
36485		},
36486
36487		set index($$value) {
36488			index($$value);
36489			flushSync();
36490		},
36491
36492		get j() {
36493			return j();
36494		},
36495
36496		set j($$value) {
36497			j($$value);
36498			flushSync();
36499		},
36500
36501		get actual_pinned_columns() {
36502			return actual_pinned_columns();
36503		},
36504
36505		set actual_pinned_columns($$value) {
36506			actual_pinned_columns($$value);
36507			flushSync();
36508		},
36509
36510		get get_cell_width() {
36511			return get_cell_width();
36512		},
36513
36514		set get_cell_width($$value) {
36515			get_cell_width($$value);
36516			flushSync();
36517		},
36518
36519		get handle_cell_click() {
36520			return handle_cell_click();
36521		},
36522
36523		set handle_cell_click($$value) {
36524			handle_cell_click($$value);
36525			flushSync();
36526		},
36527
36528		get handle_blur() {
36529			return handle_blur();
36530		},
36531
36532		set handle_blur($$value) {
36533			handle_blur($$value);
36534			flushSync();
36535		},
36536
36537		get toggle_cell_menu() {
36538			return toggle_cell_menu();
36539		},
36540
36541		set toggle_cell_menu($$value) {
36542			toggle_cell_menu($$value);
36543			flushSync();
36544		},
36545
36546		get is_cell_selected() {
36547			return is_cell_selected();
36548		},
36549
36550		set is_cell_selected($$value) {
36551			is_cell_selected($$value);
36552			flushSync();
36553		},
36554
36555		get should_show_cell_menu() {
36556			return should_show_cell_menu();
36557		},
36558
36559		set should_show_cell_menu($$value) {
36560			should_show_cell_menu($$value);
36561			flushSync();
36562		},
36563
36564		get selected_cells() {
36565			return selected_cells();
36566		},
36567
36568		set selected_cells($$value) {
36569			selected_cells($$value);
36570			flushSync();
36571		},
36572
36573		get copy_flash() {
36574			return copy_flash();
36575		},
36576
36577		set copy_flash($$value) {
36578			copy_flash($$value);
36579			flushSync();
36580		},
36581
36582		get active_cell_menu() {
36583			return active_cell_menu();
36584		},
36585
36586		set active_cell_menu($$value) {
36587			active_cell_menu($$value);
36588			flushSync();
36589		},
36590
36591		get styling() {
36592			return styling();
36593		},
36594
36595		set styling($$value) {
36596			styling($$value);
36597			flushSync();
36598		},
36599
36600		get latex_delimiters() {
36601			return latex_delimiters();
36602		},
36603
36604		set latex_delimiters($$value) {
36605			latex_delimiters($$value);
36606			flushSync();
36607		},
36608
36609		get line_breaks() {
36610			return line_breaks();
36611		},
36612
36613		set line_breaks($$value) {
36614			line_breaks($$value);
36615			flushSync();
36616		},
36617
36618		get datatype() {
36619			return datatype();
36620		},
36621
36622		set datatype($$value) {
36623			datatype($$value);
36624			flushSync();
36625		},
36626
36627		get editing() {
36628			return editing();
36629		},
36630
36631		set editing($$value) {
36632			editing($$value);
36633			flushSync();
36634		},
36635
36636		get max_chars() {
36637			return max_chars();
36638		},
36639
36640		set max_chars($$value) {
36641			max_chars($$value);
36642			flushSync();
36643		},
36644
36645		get editable() {
36646			return editable();
36647		},
36648
36649		set editable($$value) {
36650			editable($$value);
36651			flushSync();
36652		},
36653
36654		get is_static() {
36655			return is_static();
36656		},
36657
36658		set is_static($$value) {
36659			is_static($$value);
36660			flushSync();
36661		},
36662
36663		get i18n() {
36664			return i18n();
36665		},
36666
36667		set i18n($$value) {
36668			i18n($$value);
36669			flushSync();
36670		},
36671
36672		get components() {
36673			return components();
36674		},
36675
36676		set components($$value) {
36677			components($$value);
36678			flushSync();
36679		},
36680
36681		get el() {
36682			return el();
36683		},
36684
36685		set el($$value) {
36686			el($$value);
36687			flushSync();
36688		},
36689
36690		get handle_select_column() {
36691			return handle_select_column();
36692		},
36693
36694		set handle_select_column($$value) {
36695			handle_select_column($$value);
36696			flushSync();
36697		},
36698
36699		get handle_select_row() {
36700			return handle_select_row();
36701		},
36702
36703		set handle_select_row($$value) {
36704			handle_select_row($$value);
36705			flushSync();
36706		},
36707
36708		get is_dragging() {
36709			return is_dragging();
36710		},
36711
36712		set is_dragging($$value) {
36713			is_dragging($$value);
36714			flushSync();
36715		},
36716
36717		get display_value() {
36718			return display_value();
36719		},
36720
36721		set display_value($$value) {
36722			display_value($$value);
36723			flushSync();
36724		},
36725
36726		get wrap() {
36727			return wrap();
36728		},
36729
36730		set wrap($$value) {
36731			wrap($$value);
36732			flushSync();
36733		}
36734	};
36735
36736	init$1();
36737
36738	var td = root$6();
36739	let classes;
36740	var div = child(td);
36741	var node = child(div);
36742
36743	{
36744		let $0 = derived_safe_equal(() => (
36745			deep_read_state(display_value()),
36746			deep_read_state(value()),
36747			untrack(() => display_value() !== undefined ? display_value() : String(value()))
36748		));
36749
36750		let $1 = derived_safe_equal(() => (
36751			deep_read_state(editing()),
36752			deep_read_state(index()),
36753			deep_read_state(j()),
36754			untrack(() => editing() && editing()[0] === index() && editing()[1] === j())
36755		));
36756
36757		let $2 = derived_safe_equal(() => (
36758			deep_read_state(selected_cells()),
36759			deep_read_state(index()),
36760			deep_read_state(j()),
36761			untrack(() => selected_cells().length === 1 && selected_cells()[0][0] === index() && selected_cells()[0][1] === j())
36762		));
36763
36764		let $3 = derived_safe_equal(() => [index(), j()]);
36765
36766		EditableCell(node, {
36767			get display_value() {
36768				return get$1($0);
36769			},
36770
36771			get latex_delimiters() {
36772				return latex_delimiters();
36773			},
36774
36775			get line_breaks() {
36776				return line_breaks();
36777			},
36778
36779			get editable() {
36780				return editable();
36781			},
36782
36783			get is_static() {
36784				return is_static();
36785			},
36786
36787			get edit() {
36788				return get$1($1);
36789			},
36790
36791			get datatype() {
36792				return datatype();
36793			},
36794
36795			get max_chars() {
36796				return max_chars();
36797			},
36798
36799			get i18n() {
36800				return i18n();
36801			},
36802
36803			get components() {
36804				return components();
36805			},
36806
36807			get show_selection_buttons() {
36808				return get$1($2);
36809			},
36810
36811			get coords() {
36812				return get$1($3);
36813			},
36814
36815			get on_select_column() {
36816				return handle_select_column();
36817			},
36818
36819			get on_select_row() {
36820				return handle_select_row();
36821			},
36822
36823			get is_dragging() {
36824				return is_dragging();
36825			},
36826
36827			get wrap_text() {
36828				return wrap();
36829			},
36830
36831			get value() {
36832				return value();
36833			},
36834
36835			set value($$value) {
36836				value($$value);
36837			},
36838
36839			get el() {
36840				return el().input;
36841			},
36842
36843			set el($$value) {
36844				el(el().input = $$value, true);
36845			},
36846
36847			$$events: {
36848				focus: () => {
36849					const row = index();
36850					const col = j();
36851
36852					if (!selected_cells().some(([r, c]) => r === row && c === col)) {
36853						selected_cells([[row, col]]);
36854					}
36855				},
36856
36857				blur(...$$args) {
36858					handle_blur()?.apply(this, $$args);
36859				}
36860			},
36861			$$legacy: true
36862		});
36863	}
36864
36865	var node_1 = sibling(node, 2);
36866
36867	{
36868		var consequent = ($$anchor) => {
36869			CellMenuButton($$anchor, { on_click: (event) => toggle_cell_menu()(event, index(), j()) });
36870		};
36871
36872		if_block(node_1, ($$render) => {
36873			if ((
36874				deep_read_state(editable()),
36875				deep_read_state(should_show_cell_menu()),
36876				deep_read_state(index()),
36877				deep_read_state(j()),
36878				deep_read_state(selected_cells()),
36879				untrack(() => editable() && should_show_cell_menu()([index(), j()], selected_cells(), editable()))
36880			)) $$render(consequent);
36881		});
36882	}
36883
36884	reset(div);
36885	reset(td);
36886	bind_this(td, ($$value) => el(el().cell = $$value, true), () => el()?.cell);
36887
36888	template_effect(
36889		($0, $1) => {
36890			set_attribute(td, 'tabindex', j() < actual_pinned_columns() ? -1 : 0);
36891			set_attribute(td, 'data-row', index());
36892			set_attribute(td, 'data-col', j());
36893			set_attribute(td, 'data-testid', `cell-${index()}-${j()}`);
36894			set_style$1(td, `width: ${$0 ?? ''}; left: ${$1 ?? ''}; ${(styling() || '') ?? ''}`);
36895
36896			classes = set_class(td, 1, 'svelte-18bs22a', null, classes, {
36897				'pinned-column': j() < actual_pinned_columns(),
36898				'last-pinned': j() === actual_pinned_columns() - 1,
36899				flash: copy_flash() && get$1(is_in_selection),
36900				'cell-selected': get$1(is_in_selection),
36901				'no-top': get$1(has_no_top),
36902				'no-bottom': get$1(has_no_bottom),
36903				'no-left': get$1(has_no_left),
36904				'no-right': get$1(has_no_right),
36905				'menu-active': active_cell_menu() && active_cell_menu().row === index() && active_cell_menu().col === j(),
36906				dragging: is_dragging()
36907			});
36908		},
36909		[
36910			() => (
36911				deep_read_state(get_cell_width()),
36912				deep_read_state(j()),
36913				untrack(() => get_cell_width()(j()))
36914			),
36915
36916			() => (
36917				deep_read_state(j()),
36918				untrack(() => get_cell_position(j()))
36919			)
36920		]
36921	);
36922
36923	event('mousedown', td, (e) => handle_cell_click()(e, index(), j()));
36924	event('contextmenu', td, preventDefault((e) => toggle_cell_menu()(e, index(), j())));
36925	append$1($$anchor, td);
36926
36927	return pop($$exports);
36928}
36929
36930var root$5 = from_html(`<button class="add-row-button svelte-1at77md" aria-label="Add row">+</button>`);
36931
36932function EmptyRowButton($$anchor, $$props) {
36933	push($$props, false);
36934
36935	let on_click = prop($$props, 'on_click', 12);
36936
36937	var $$exports = {
36938		get on_click() {
36939			return on_click();
36940		},
36941
36942		set on_click($$value) {
36943			on_click($$value);
36944			flushSync();
36945		}
36946	};
36947
36948	var button = root$5();
36949
36950	event('click', button, function (...$$args) {
36951		on_click()?.apply(this, $$args);
36952	});
36953
36954	append$1($$anchor, button);
36955
36956	return pop($$exports);
36957}
36958
36959var root_1$4 = from_html(`<caption class="sr-only"> </caption>`);
36960var root_4$2 = from_html(`<tr><td>Missing Table Row</td></tr>`);
36961var root$4 = from_html(`<svelte-virtual-table-viewport><div><table><!><thead class="thead svelte-fhd0lr"><!></thead><tbody class="tbody svelte-fhd0lr"><!></tbody><tfoot class="tfoot svelte-fhd0lr"><!></tfoot></table></div></svelte-virtual-table-viewport>`, 2);
36962
36963function VirtualTable($$anchor, $$props) {
36964	push($$props, false);
36965
36966	const sortedItems = mutable_source();
36967	let items = prop($$props, 'items', 28, () => []);
36968	let max_height = prop($$props, 'max_height', 12);
36969	let actual_height = prop($$props, 'actual_height', 12);
36970	let table_scrollbar_width = prop($$props, 'table_scrollbar_width', 12);
36971	let start = prop($$props, 'start', 12, 0);
36972	let end = prop($$props, 'end', 12, 20);
36973	let selected = prop($$props, 'selected', 12);
36974	let disable_scroll = prop($$props, 'disable_scroll', 12, false);
36975	let show_scroll_button = prop($$props, 'show_scroll_button', 12, false);
36976	let viewport = prop($$props, 'viewport', 12);
36977	let label = prop($$props, 'label', 12, null);
36978	createEventDispatcher$1();
36979	let average_height = mutable_source(30);
36980	let bottom = mutable_source(0);
36981	let contents = mutable_source();
36982	let head_height = mutable_source(0);
36983	let foot_height = mutable_source(0);
36984	let height_map = [];
36985	let mounted = mutable_source();
36986	let rows;
36987	let top = mutable_source(0);
36988	let viewport_height = mutable_source(200);
36989	let visible = mutable_source([]);
36990	let viewport_box = mutable_source();
36991	const is_browser = typeof window !== "undefined";
36992	const raf = is_browser ? window.requestAnimationFrame : (cb) => cb();
36993
36994	async function refresh_height_map() {
36995		if (!viewport()) {
36996			return;
36997		}
36998
36999		if (get$1(sortedItems).length < start()) {
37000			await scroll_to_index(get$1(sortedItems).length - 1, { behavior: "auto" });
37001		}
37002
37003		const scrollTop = Math.max(0, viewport().scrollTop);
37004
37005		show_scroll_button(scrollTop > 100);
37006		table_scrollbar_width(viewport().offsetWidth - viewport().clientWidth);
37007
37008		// acquire height map for currently visible rows
37009		for (let v = 0; v < rows.length; v += 1) {
37010			height_map[start() + v] = rows[v].getBoundingClientRect().height;
37011		}
37012
37013		let i = 0;
37014		let y = get$1(head_height);
37015
37016		// loop items to find new start
37017		while (i < get$1(sortedItems).length) {
37018			const row_height = height_map[i] || get$1(average_height);
37019
37020			// keep a page of rows buffered above
37021			if (y + row_height > scrollTop - max_height()) {
37022				start(i);
37023				set(top, y - get$1(head_height));
37024
37025				break;
37026			}
37027
37028			y += row_height;
37029			i += 1;
37030		}
37031
37032		let content_height = get$1(head_height);
37033
37034		while (i < get$1(sortedItems).length) {
37035			const row_height = height_map[i] || get$1(average_height);
37036
37037			content_height += row_height;
37038			i += 1;
37039
37040			// keep a page of rows buffered below
37041			if (content_height - get$1(head_height) > 3 * max_height()) {
37042				break;
37043			}
37044		}
37045
37046		end(i);
37047
37048		const remaining = get$1(sortedItems).length - end();
37049		const scrollbar_height = viewport().offsetHeight - viewport().clientHeight;
37050
37051		if (scrollbar_height > 0) {
37052			content_height += scrollbar_height;
37053		}
37054
37055		let filtered_height_map = height_map.filter((v) => typeof v === "number");
37056
37057		set(average_height, filtered_height_map.reduce((a, b) => a + b, 0) / filtered_height_map.length || 30);
37058		set(bottom, remaining * get$1(average_height));
37059
37060		if (!isFinite(get$1(bottom))) {
37061			set(bottom, 200000);
37062		}
37063
37064		height_map.length = get$1(sortedItems).length;
37065
37066		while (i < get$1(sortedItems).length) {
37067			i += 1;
37068			height_map[i] = get$1(average_height);
37069		}
37070
37071		if (max_height() && content_height > max_height()) {
37072			actual_height(max_height());
37073		} else {
37074			actual_height(content_height);
37075		}
37076	}
37077
37078	async function scroll_and_render(n) {
37079		raf(async () => {
37080			if (typeof n !== "number") return;
37081
37082			const direction = typeof n !== "number" ? false : is_in_view(n);
37083
37084			if (direction === true) {
37085				return;
37086			}
37087
37088			if (direction === "back") {
37089				await scroll_to_index(n, { behavior: "instant" });
37090			}
37091
37092			if (direction === "forwards") {
37093				await scroll_to_index(n, { behavior: "instant" }, true);
37094			}
37095		});
37096	}
37097
37098	function is_in_view(n) {
37099		const current = rows && rows[n - start()];
37100
37101		if (!current && n < start()) {
37102			return "back";
37103		}
37104
37105		if (!current && n >= end() - 1) {
37106			return "forwards";
37107		}
37108
37109		const { top: viewport_top } = viewport().getBoundingClientRect();
37110		const { top, bottom } = current.getBoundingClientRect();
37111
37112		if (top - viewport_top < 37) {
37113			return "back";
37114		}
37115
37116		if (bottom - viewport_top > get$1(viewport_height)) {
37117			return "forwards";
37118		}
37119
37120		return true;
37121	}
37122
37123	async function scroll_to_index(index, opts, align_end = false) {
37124		await tick$1();
37125
37126		const _itemHeight = get$1(average_height);
37127		let distance = index * _itemHeight;
37128
37129		if (align_end) {
37130			distance = distance - get$1(viewport_height) + _itemHeight + get$1(head_height);
37131		}
37132
37133		const scrollbar_height = viewport().offsetHeight - viewport().clientHeight;
37134
37135		if (scrollbar_height > 0) {
37136			distance += scrollbar_height;
37137		}
37138
37139		const _opts = { top: distance, behavior: "smooth", ...opts };
37140
37141		viewport().scrollTo(_opts);
37142	}
37143
37144	onMount$1(() => {
37145		rows = get$1(contents).children;
37146		set(mounted, true);
37147	});
37148
37149	legacy_pre_effect(() => (get$1(viewport_box)), () => {
37150		set(viewport_height, get$1(viewport_box)?.height || 200);
37151	});
37152
37153	legacy_pre_effect(() =>
37153 (deep_read_state(items())), () => {
37154		set(sortedItems, items());
37155	});
37156
37157	legacy_pre_effect(
37158		() => (
37159			get$1(mounted),
37160			get$1(viewport_height),
37161			deep_read_state(viewport()),
37162			get$1(sortedItems)
37163		),
37164		() => {
37165			if (get$1(mounted) && get$1(viewport_height) && viewport().offsetParent) {
37166				(get$1(sortedItems), raf(refresh_height_map));
37167			}
37168		}
37169	);
37170
37171	legacy_pre_effect(() => (deep_read_state(selected())), () => {
37172		scroll_and_render(selected());
37173	});
37174
37175	legacy_pre_effect(
37176		() => (
37177			get$1(sortedItems),
37178			deep_read_state(start()),
37179			deep_read_state(end()),
37180			deep_read_state(max_height()),
37181			get$1(average_height)
37182		),
37183		() => {
37184			set(visible, is_browser
37185				? get$1(sortedItems).slice(start(), end()).map((data, i) => {
37186					return { index: i + start(), data };
37187				})
37188				: get$1(sortedItems).slice(0, max_height() / get$1(sortedItems).length * get$1(average_height) + 1).map((data, i) => {
37189					return { index: i + start(), data };
37190				}));
37191		}
37192	);
37193
37194	legacy_pre_effect_reset();
37195
37196	var $$exports = {
37197		scroll_to_index,
37198		get items() {
37199			return items();
37200		},
37201
37202		set items($$value) {
37203			items($$value);
37204			flushSync();
37205		},
37206
37207		get max_height() {
37208			return max_height();
37209		},
37210
37211		set max_height($$value) {
37212			max_height($$value);
37213			flushSync();
37214		},
37215
37216		get actual_height() {
37217			return actual_height();
37218		},
37219
37220		set actual_height($$value) {
37221			actual_height($$value);
37222			flushSync();
37223		},
37224
37225		get table_scrollbar_width() {
37226			return table_scrollbar_width();
37227		},
37228
37229		set table_scrollbar_width($$value) {
37230			table_scrollbar_width($$value);
37231			flushSync();
37232		},
37233
37234		get start() {
37235			return start();
37236		},
37237
37238		set start($$value) {
37239			start($$value);
37240			flushSync();
37241		},
37242
37243		get end() {
37244			return end();
37245		},
37246
37247		set end($$value) {
37248			end($$value);
37249			flushSync();
37250		},
37251
37252		get selected() {
37253			return selected();
37254		},
37255
37256		set selected($$value) {
37257			selected($$value);
37258			flushSync();
37259		},
37260
37261		get disable_scroll() {
37262			return disable_scroll();
37263		},
37264
37265		set disable_scroll($$value) {
37266			disable_scroll($$value);
37267			flushSync();
37268		},
37269
37270		get show_scroll_button() {
37271			return show_scroll_button();
37272		},
37273
37274		set show_scroll_button($$value) {
37275			show_scroll_button($$value);
37276			flushSync();
37277		},
37278
37279		get viewport() {
37280			return viewport();
37281		},
37282
37283		set viewport($$value) {
37284			viewport($$value);
37285			flushSync();
37286		},
37287
37288		get label() {
37289			return label();
37290		},
37291
37292		set label($$value) {
37293			label($$value);
37294			flushSync();
37295		}
37296	};
37297
37298	init$1();
37299
37300	var svelte_virtual_table_viewport = root$4();
37301	var div = child(svelte_virtual_table_viewport);
37302	var table = child(div);
37303	let classes;
37304	var node = child(table);
37305
37306	{
37307		var consequent = ($$anchor) => {
37308			var caption = root_1$4();
37309			var text = child(caption, true);
37310
37311			reset(caption);
37312			template_effect(() => set_text(text, label()));
37313			append$1($$anchor, caption);
37314		};
37315
37316		if_block(node, ($$render) => {
37317			if ((
37318				deep_read_state(label()),
37319				untrack(() => label() && label().length !== 0)
37320			)) $$render(consequent);
37321		});
37322	}
37323
37324	var thead = sibling(node);
37325	var node_1 = child(thead);
37326
37327	slot(node_1, $$props, 'thead', {}, null);
37328	reset(thead);
37329
37330	var tbody = sibling(thead);
37331	var node_2 = child(tbody);
37332
37333	{
37334		var consequent_1 = ($$anchor) => {
37335			var fragment = comment();
37336			var node_3 = first_child(fragment);
37337
37338			each(node_3, 1, () => get$1(visible), (item) => item.data[0].id, ($$anchor, item) => {
37339				var fragment_1 = comment();
37340				var node_4 = first_child(fragment_1);
37341
37342				slot(
37343					node_4,
37344					$$props,
37345					'tbody',
37346					{
37347						get item() {
37348							return (get$1(item), untrack(() => get$1(item).data));
37349						},
37350
37351						get index() {
37352							return (get$1(item), untrack(() => get$1(item).index));
37353						}
37354					},
37355					($$anchor) => {
37356						var tr = root_4$2();
37357
37358						append$1($$anchor, tr);
37359					}
37360				);
37361
37362				append$1($$anchor, fragment_1);
37363			});
37364
37365			append$1($$anchor, fragment);
37366		};
37367
37368		if_block(node_2, ($$render) => {
37369			if ((
37370				get$1(visible),
37371				untrack(() => get$1(visible).length && get$1(visible)[0].data.length)
37372			)) $$render(consequent_1);
37373		});
37374	}
37375
37376	reset(tbody);
37377	bind_this(tbody, ($$value) => set(contents, $$value), () => get$1(contents));
37378
37379	var tfoot = sibling(tbody);
37380	var node_5 = child(tfoot);
37381
37382	slot(node_5, $$props, 'tfoot', {}, null);
37383	reset(tfoot);
37384	reset(table);
37385	bind_this(table, ($$value) => viewport($$value), () => viewport());
37386	reset(div);
37387	reset(svelte_virtual_table_viewport);
37388
37389	template_effect(() => {
37390		classes = set_class(table, 1, 'table svelte-fhd0lr', null, classes, { 'disable-scroll': disable_scroll() });
37391		set_style$1(table, `height: 100%; --bw-svt-p-top: ${get$1(top) ?? ''}px; --bw-svt-p-bottom: ${get$1(bottom) ?? ''}px; --bw-svt-head-height: ${get$1(head_height) ?? ''}px; --bw-svt-foot-height: ${get$1(foot_height) ?? ''}px; --bw-svt-avg-row-height: ${get$1(average_height) ?? ''}px; --max-height: ${max_height() ?? ''}px`);
37392	});
37393
37394	bind_element_size(thead, 'offsetHeight', ($$value) => set(head_height, $$value));
37395	bind_element_size(tfoot, 'offsetHeight', ($$value) => set(foot_height, $$value));
37396	bind_resize_observer(table, 'contentRect', ($$value) => set(viewport_box, $$value));
37397	event('scroll', table, refresh_height_map);
37398	append$1($$anchor, svelte_virtual_table_viewport);
37399	bind_prop($$props, 'scroll_to_index', scroll_to_index);
37400
37401	return pop($$exports);
37402}
37403
37404var root_2$3 = from_html(`<button class="filter-option svelte-1y6dxc7"> </button>`);
37405var root_1$3 = from_html(`<div class="dropdown-filter-options svelte-1y6dxc7"></div>`);
37406var root$3 = from_html(`<div><div class="background svelte-1y6dxc7"></div> <div class="filter-menu svelte-1y6dxc7"><div class="filter-datatype-container svelte-1y6dxc7"><span class="svelte-1y6dxc7">Filter as</span> <button class="svelte-1y6dxc7"> </button></div> <div class="input-container svelte-1y6dxc7"><div class="filter-dropdown"><button class="svelte-1y6dxc7"> <!></button> <!></div> <input type="text" placeholder="Type a value" class="filter-input svelte-1y6dxc7"/></div> <button class="check-button svelte-1y6dxc7"><!></button></div></div>`);
37407
37408function FilterMenu($$anchor, $$props) {
37409	push($$props, false);
37410
37411	let on_filter = prop($$props, 'on_filter', 12, () => {});
37412	let menu_element = mutable_source();
37413	let datatype = mutable_source("string");
37414	let current_filter = mutable_source("Contains");
37415	let filter_dropdown_open = mutable_source(false);
37416	let filter_input_value = mutable_source("");
37417
37418	const filter_options = {
37419		string: [
37420			"Contains",
37421			"Does not contain",
37422			"Starts with",
37423			"Ends with",
37424			"Is",
37425			"Is not",
37426			"Is empty",
37427			"Is not empty"
37428		],
37429		number: ["=", "≠", ">", "<", "≥", "≤", "Is empty", "Is not empty"]
37430	};
37431
37432	onMount$1(() => {
37433		position_menu();
37434	});
37435
37436	function position_menu() {
37437		if (!get$1(menu_element)) return;
37438
37439		const viewport_width = window.innerWidth;
37440		const viewport_height = window.innerHeight;
37441		const menu_rect = get$1(menu_element).getBoundingClientRect();
37442		const x = (viewport_width - menu_rect.width) / 2;
37443		const y = (viewport_height - menu_rect.height) / 2;
37444
37445		mutate(menu_element, get$1(menu_element).style.left = `${x}px`);
37446		mutate(menu_element, get$1(menu_element).style.top = `${y}px`);
37447	}
37448
37449	function handle_filter_input(e) {
37450		const target = e.target;
37451
37452		set(filter_input_value, target.value);
37453	}
37454
37455	var $$exports = {
37456		get on_filter() {
37457			return on_filter();
37458		},
37459
37460		set on_filter($$value) {
37461			on_filter($$value);
37462			flushSync();
37463		}
37464	};
37465
37466	init$1();
37467
37468	var div = root$3();
37469	var div_1 = sibling(child(div), 2);
37470	var div_2 = child(div_1);
37471	var button = sibling(child(div_2), 2);
37472	var text = child(button, true);
37473
37474	reset(button);
37475	reset(div_2);
37476
37477	var div_3 = sibling(div_2, 2);
37478	var div_4 = child(div_3);
37479	var button_1 = child(div_4);
37480	var text_1 = child(button_1);
37481	var node = sibling(text_1);
37482
37483	DropdownArrow$1(node);
37484	reset(button_1);
37485
37486	var node_1 = sibling(button_1, 2);
37487
37488	{
37489		var consequent = ($$anchor) => {
37490			var div_5 = root_1$3();
37491
37492			each(
37493				div_5,
37494				5,
37495				() => (
37496					get$1(datatype),
37497					untrack(() => filter_options[get$1(datatype)])
37498				),
37499				index,
37500				($$anchor, opt) => {
37501					var button_2 = root_2$3();
37502					var text_2 = child(button_2, true);
37503
37504					reset(button_2);
37505					template_effect(() => set_text(text_2, get$1(opt)));
37506
37507					event('click', button_2, stopPropagation(() => {
37508						set(current_filter, get$1(opt));
37509						set(filter_dropdown_open, !get$1(filter_dropdown_open));
37510					}));
37511
37512					append$1($$anchor, button_2);
37513				}
37514			);
37515
37516			reset(div_5);
37517			append$1($$anchor, div_5);
37518		};
37519
37520		if_block(node_1, ($$render) => {
37521			if (get$1(filter_dropdown_open)) $$render(consequent);
37522		});
37523	}
37524
37525	reset(div_4);
37526
37527	var input = sibling(div_4, 2);
37528
37529	remove_input_defaults(input);
37530	reset(div_3);
37531
37532	var button_3 = sibling(div_3, 2);
37533	var node_2 = child(button_3);
37534
37535	Check$1(node_2);
37536	reset(button_3);
37537	reset(div_1);
37538	bind_this(div_1, ($$value) => set(menu_element, $$value), () => get$1(menu_element));
37539	reset(div);
37540
37541	template_effect(() => {
37542		set_attribute(button, 'aria-label', `Change filter type. Filtering ${get$1(datatype)}s`);
37543		set_text(text, get$1(datatype));
37544		set_attribute(button_1, 'aria-label', `Change filter. Using '${get$1(current_filter)}'`);
37545		set_text(text_1, `${get$1(current_filter) ?? ''} `);
37546		set_value(input, get$1(filter_input_value));
37547	});
37548
37549	event('click', button, stopPropagation(() => {
37550		set(datatype, get$1(datatype) === "string" ? "number" : "string");
37551		set(current_filter, filter_options[get$1(datatype)][0]);
37552	}));
37553
37554	event('click', button_1, stopPropagation(() => set(filter_dropdown_open, !get$1(filter_dropdown_open))));
37555
37556	event('click', input, stopPropagation(function ($$arg) {
37557		bubble_event.call(this, $$props, $$arg);
37558	}));
37559
37560	event('input', input, handle_filter_input);
37561	event('click', button_3, () => on_filter()(get$1(datatype), get$1(current_filter), get$1(filter_input_value)));
37562	append$1($$anchor, div);
37563
37564	return pop($$exports);
37565}
37566
37567var root_2$2 = from_html(`<span class="priority svelte-1v4jjjx"> </span>`);
37568var root_3$1 = from_html(`<span class="priority svelte-1v4jjjx"> </span>`);
37569var root_4$1 = from_html(`<span class="priority svelte-1v4jjjx">1</span>`);
37570var root_1$2 = from_html(`<button role="menuitem"><!> <!></button> <button role="menuitem"><!> <!></button> <button role="menuitem" class="svelte-1v4jjjx"><!> </button> <button role="menuitem"><!> <!></button> <button role="menuitem" class="svelte-1v4jjjx"><!> </button>`, 1);
37571var root_6 = from_html(`<button role="menuitem" class="delete svelte-1v4jjjx" aria-label="Delete row"><!> </button>`);
37572var root_5 = from_html(`<button role="menuitem" aria-label="Add row above" class="svelte-1v4jjjx"><!> </button> <button role="menuitem" aria-label="Add row below" class="svelte-1v4jjjx"><!> </button> <!>`, 1);
37573var root_8$1 = from_html(`<button role="menuitem" class="delete svelte-1v4jjjx" aria-label="Delete column"><!> </button>`);
37574var root_7 = from_html(`<button role="menuitem" aria-label="Add column to the left" class="svelte-1v4jjjx"><!> </button> <button role="menuitem" aria-label="Add column to the right" class="svelte-1v4jjjx"><!> </button> <!>`, 1);
37575var root$2 = from_html(`<div class="cell-menu svelte-1v4jjjx" role="menu"><!> <!> <!></div> <!>`, 1);
37576
37577function CellMenu($$anchor, $$props) {
37578	push($$props, false);
37579
37580	const is_header = mutable_source();
37581	const can_add_rows = mutable_source();
37582	const can_add_columns = mutable_source();
37583	let x = prop($$props, 'x', 12);
37584	let y = prop($$props, 'y', 12);
37585	let on_add_row_above = prop($$props, 'on_add_row_above', 12);
37586	let on_add_row_below = prop($$props, 'on_add_row_below', 12);
37587	let on_add_column_left = prop($$props, 'on_add_column_left', 12);
37588	let on_add_column_right = prop($$props, 'on_add_column_right', 12);
37589	let row = prop($$props, 'row', 12);
37590	let col_count = prop($$props, 'col_count', 12);
37591	let row_count = prop($$props, 'row_count', 12);
37592	let on_delete_row = prop($$props, 'on_delete_row', 12);
37593	let on_delete_col = prop($$props, 'on_delete_col', 12);
37594	let can_delete_rows = prop($$props, 'can_delete_rows', 12);
37595	let can_delete_cols = prop($$props, 'can_delete_cols', 12);
37596	let on_sort = prop($$props, 'on_sort', 12, () => {});
37597	let on_clear_sort = prop($$props, 'on_clear_sort', 12, () => {});
37598	let sort_direction = prop($$props, 'sort_direction', 12, null);
37599	let sort_priority = prop($$props, 'sort_priority', 12, null);
37600	let on_filter = prop($$props, 'on_filter', 12, () => {});
37601	let on_clear_filter = prop($$props, 'on_clear_filter', 12, () => {});
37602	let filter_active = prop($$props, 'filter_active', 12, null);
37603	let editable = prop($$props, 'editable', 12, true);
37604	let i18n = prop($$props, 'i18n', 12);
37605	let menu_element = mutable_source();
37606	let active_filter_menu = mutable_source(null);
37607
37608	onMount$1(() => {
37609		position_menu();
37610	});
37611
37612	function position_menu() {
37613		if (!get$1(menu_element)) return;
37614
37615		const viewport_width = window.innerWidth;
37616		const viewport_height = window.innerHeight;
37617		const menu_rect = get$1(menu_element).getBoundingClientRect();
37618		let new_x = x() - 30;
37619		let new_y = y() - 20;
37620
37621		if (new_x + menu_rect.width > viewport_width) {
37622			new_x = x() - menu_rect.width + 10;
37623		}
37624
37625		if (new_y + menu_rect.height > viewport_height) {
37626			new_y = y() - menu_rect.height + 10;
37627		}
37628
37629		mutate(menu_element, get$1(menu_element).style.left = `${new_x}px`);
37630		mutate(menu_element, get$1(menu_element).style.top = `${new_y}px`);
37631	}
37632
37633	function toggle_filter_menu() {
37634		if (filter_active()) {
37635			on_filter()("string", "", "");
37636
37637			return;
37638		}
37639
37640		const menu_rect = get$1(menu_element).getBoundingClientRect();
37641
37642		set(active_filter_menu, { x: menu_rect.right, y: menu_rect.top + menu_rect.height / 2 });
37643	}
37644
37645	legacy_pre_effect(() => (deep_read_state(row())), () => {
37646		set(is_header, row() === -1);
37647	});
37648
37649	legacy_pre_effect(
37650		() => (
37651			deep_read_state(editable()),
37652			deep_read_state(row_count())
37653		),
37654		() => {
37655			set(can_add_rows, editable() && row_count()[1] === "dynamic");
37656		}
37657	);
37658
37659	legacy_pre_effect(
37660		() => (
37661			deep_read_state(editable()),
37662			deep_read_state(col_count())
37663		),
37664		() => {
37665			set(can_add_columns, editable() && col_count()[1] === "dynamic");
37666		}
37667	);
37668
37669	legacy_pre_effect_reset();
37670
37671	var $$exports = {
37672		get x() {
37673			return x();
37674		},
37675
37676		set x($$value) {
37677			x($$value);
37678			flushSync();
37679		},
37680
37681		get y() {
37682			return y();
37683		},
37684
37685		set y($$value) {
37686			y($$value);
37687			flushSync();
37688		},
37689
37690		get on_add_row_above() {
37691			return on_add_row_above();
37692		},
37693
37694		set on_add_row_above($$value) {
37695			on_add_row_above($$value);
37696			flushSync();
37697		},
37698
37699		get on_add_row_below() {
37700			return on_add_row_below();
37701		},
37702
37703		set on_add_row_below($$value) {
37704			on_add_row_below($$value);
37705			flushSync();
37706		},
37707
37708		get on_add_column_left() {
37709			return on_add_column_left();
37710		},
37711
37712		set on_add_column_left($$value) {
37713			on_add_column_left($$value);
37714			flushSync();
37715		},
37716
37717		get on_add_column_right() {
37718			return on_add_column_right();
37719		},
37720
37721		set on_add_column_right($$value) {
37722			on_add_column_right($$value);
37723			flushSync();
37724		},
37725
37726		get row() {
37727			return row();
37728		},
37729
37730		set row($$value) {
37731			row($$value);
37732			flushSync();
37733		},
37734
37735		get col_count() {
37736			return col_count();
37737		},
37738
37739		set col_count($$value) {
37740			col_count($$value);
37741			flushSync();
37742		},
37743
37744		get row_count() {
37745			return row_count();
37746		},
37747
37748		set row_count($$value) {
37749			row_count($$value);
37750			flushSync();
37751		},
37752
37753		get on_delete_row() {
37754			return on_delete_row();
37755		},
37756
37757		set on_delete_row($$value) {
37758			on_delete_row($$value);
37759			flushSync();
37760		},
37761
37762		get on_delete_col() {
37763			return on_delete_col();
37764		},
37765
37766		set on_delete_col($$value) {
37767			on_delete_col($$value);
37768			flushSync();
37769		},
37770
37771		get can_delete_rows() {
37772			return can_delete_rows();
37773		},
37774
37775		set can_delete_rows($$value) {
37776			can_delete_rows($$value);
37777			flushSync();
37778		},
37779
37780		get can_delete_cols() {
37781			return can_delete_cols();
37782		},
37783
37784		set can_delete_cols($$value) {
37785			can_delete_cols($$value);
37786			flushSync();
37787		},
37788
37789		get on_sort() {
37790			return on_sort();
37791		},
37792
37793		set on_sort($$value) {
37794			on_sort($$value);
37795			flushSync();
37796		},
37797
37798		get on_clear_sort() {
37799			return on_clear_sort();
37800		},
37801
37802		set on_clear_sort($$value) {
37803			on_clear_sort($$value);
37804			flushSync();
37805		},
37806
37807		get sort_direction() {
37808			return sort_direction();
37809		},
37810
37811		set sort_direction($$value) {
37812			sort_direction($$value);
37813			flushSync();
37814		},
37815
37816		get sort_priority() {
37817			return sort_priority();
37818		},
37819
37820		set sort_priority($$value) {
37821			sort_priority($$value);
37822			flushSync();
37823		},
37824
37825		get on_filter() {
37826			return on_filter();
37827		},
37828
37829		set on_filter($$value) {
37830			on_filter($$value);
37831			flushSync();
37832		},
37833
37834		get on_clear_filter() {
37835			return on_clear_filter();
37836		},
37837
37838		set on_clear_filter($$value) {
37839			on_clear_filter($$value);
37840			flushSync();
37841		},
37842
37843		get filter_active() {
37844			return filter_active();
37845		},
37846
37847		set filter_active($$value) {
37848			filter_active($$value);
37849			flushSync();
37850		},
37851
37852		get editable() {
37853			return editable();
37854		},
37855
37856		set editable($$value) {
37857			editable($$value);
37858			flushSync();
37859		},
37860
37861		get i18n() {
37862			return i18n();
37863		},
37864
37865		set i18n($$value) {
37866			i18n($$value);
37867			flushSync();
37868		}
37869	};
37870
37871	init$1();
37872
37873	var fragment = root$2();
37874	var div = first_child(fragment);
37875	var node = child(div);
37876
37877	{
37878		var consequent_3 = ($$anchor) => {
37879			var fragment_1 = root_1$2();
37880			var button = first_child(fragment_1);
37881			let classes;
37882			var node_1 = child(button);
37883
37884			CellMenuIcons(node_1, { icon: 'sort-asc' });
37885
37886			var text = sibling(node_1);
37887			var node_2 = sibling(text);
37888
37889			{
37890				var consequent = ($$anchor) => {
37891					var span = root_2$2();
37892					var text_1 = child(span, true);
37893
37894					reset(span);
37895					template_effect(() => set_text(text_1, sort_priority()));
37896					append$1($$anchor, span);
37897				};
37898
37899				if_block(node_2, ($$render) => {
37900					if (sort_direction() === "asc" && sort_priority() !== null) $$render(consequent);
37901				});
37902			}
37903
37904			reset(button);
37905
37906			var button_1 = sibling(button, 2);
37907			let classes_1;
37908			var node_3 = child(button_1);
37909
37910			CellMenuIcons(node_3, { icon: 'sort-desc' });
37911
37912			var text_2 = sibling(node_3);
37913			var node_4 = sibling(text_2);
37914
37915			{
37916				var consequent_1 = ($$anchor) => {
37917					var span_1 = root_3$1();
37918					var text_3 = child(span_1, true);
37919
37920					reset(span_1);
37921					template_effect(() => set_text(text_3, sort_priority()));
37922					append$1($$anchor, span_1);
37923				};
37924
37925				if_block(node_4, ($$render) => {
37926					if (sort_direction() === "desc" && sort_priority() !== null) $$render(consequent_1);
37927				});
37928			}
37929
37930			reset(button_1);
37931
37932			var button_2 = sibling(button_1, 2);
37933			var node_5 = child(button_2);
37934
37935			CellMenuIcons(node_5, { icon: 'clear-sort' });
37936
37937			var text_4 = sibling(node_5);
37938
37939			reset(button_2);
37940
37941			var button_3 = sibling(button_2, 2);
37942			let classes_2;
37943			var node_6 = child(button_3);
37944
37945			CellMenuIcons(node_6, { icon: 'filter' });
37946
37947			var text_5 = sibling(node_6);
37948			var node_7 = sibling(text_5);
37949
37950			{
37951				var consequent_2 = ($$anchor) => {
37952					var span_2 = root_4$1();
37953
37954					append$1($$anchor, span_2);
37955				};
37956
37957				if_block(node_7, ($$render) => {
37958					if (filter_active()) $$render(consequent_2);
37959				});
37960			}
37961
37962			reset(button_3);
37963
37964			var button_4 = sibling(button_3, 2);
37965			var node_8 = child(button_4);
37966
37967			CellMenuIcons(node_8, { icon: 'clear-filter' });
37968
37969			var text_6 = sibling(node_8);
37970
37971			reset(button_4);
37972
37973			template_effect(
37974				($0, $1, $2, $3, $4) => {
37975					classes = set_class(button, 1, 'svelte-1v4jjjx', null, classes, { active: sort_direction() === "asc" });
37976					set_text(text, ` ${$0 ?? ''} `);
37977					classes_1 = set_class(button_1, 1, 'svelte-1v4jjjx', null, classes_1, { active: sort_direction() === "desc" });
37978					set_text(text_2, ` ${$1 ?? ''} `);
37979					set_text(text_4, ` ${$2 ?? ''}`);
37980					classes_2 = set_class(button_3, 1, 'svelte-1v4jjjx', null, classes_2, { active: filter_active() || get$1(active_filter_menu) });
37981					set_text(text_5, ` ${$3 ?? ''} `);
37982					set_text(text_6, ` ${$4 ?? ''}`);
37983				},
37984				[
37985					() => (
37986						deep_read_state(i18n()),
37987						untrack(() => i18n()("dataframe.sort_ascending"))
37988					),
37989
37990					() => (
37991						deep_read_state(i18n()),
37992						untrack(() => i18n()("dataframe.sort_descending"))
37993					),
37994
37995					() => (
37996						deep_read_state(i18n()),
37997						untrack(() => i18n()("dataframe.clear_sort"))
37998					),
37999
38000					() => (
38001						deep_read_state(i18n()),
38002						untrack(() => i18n()("dataframe.filter"))
38003					),
38004
38005					() => (
38006						deep_read_state(i18n()),
38007						untrack(() => i18n()("dataframe.clear_filter"))
38008					)
38009				]
38010			);
38011
38012			event('click', button, () => on_sort()("asc"));
38013			event('click', button_1, () => on_sort()("desc"));
38014
38015			event('click', button_2, function (...$$args) {
38016				on_clear_sort()?.apply(this, $$args);
38017			});
38018
38019			event('click', button_3, stopPropagation(toggle_filter_menu));
38020
38021			event('click', button_4, function (...$$args) {
38022				on_clear_filter()?.apply(this, $$args);
38023			});
38024
38025			append$1($$anchor, fragment_1);
38026		};
38027
38028		if_block(node, ($$render) => {
38029			if (get$1(is_header)) $$render(consequent_3);
38030		});
38031	}
38032
38033	var node_9 = sibling(node, 2);
38034
38035	{
38036		var consequent_5 = ($$anchor) => {
38037			var fragment_2 = root_5();
38038			var button_5 = first_child(fragment_2);
38039			var node_10 = child(button_5);
38040
38041			CellMenuIcons(node_10, { icon: 'add-row-above' });
38042
38043			var text_7 = sibling(node_10);
38044
38045			reset(button_5);
38046
38047			var button_6 = sibling(button_5, 2);
38048			var node_11 = child(button_6);
38049
38050			CellMenuIcons(node_11, { icon: 'add-row-below' });
38051
38052			var text_8 = sibling(node_11);
38053
38054			reset(button_6);
38055
38056			var node_12 = sibling(button_6, 2);
38057
38058			{
38059				var consequent_4 = ($$anchor) => {
38060					var button_7 = root_6();
38061					var node_13 = child(button_7);
38062
38063					CellMenuIcons(node_13, { icon: 'delete-row' });
38064
38065					var text_9 = sibling(node_13);
38066
38067					reset(button_7);
38068
38069					template_effect(($0) => set_text(text_9, ` ${$0 ?? ''}`), [
38070						() => (
38071							deep_read_state(i18n()),
38072							untrack(() => i18n()("dataframe.delete_row"))
38073						)
38074					]);
38075
38076					event('click', button_7, function (...$$args) {
38077						on_delete_row()?.apply(this, $$args);
38078					});
38079
38080					append$1($$anchor, button_7);
38081				};
38082
38083				if_block(node_12, ($$render) => {
38084					if (can_delete_rows()) $$render(consequent_4);
38085				});
38086			}
38087
38088			template_effect(
38089				($0, $1) => {
38090					set_text(text_7, ` ${$0 ?? ''}`);
38091					set_text(text_8, ` ${$1 ?? ''}`);
38092				},
38093				[
38094					() => (
38095						deep_read_state(i18n()),
38096						untrack(() => i18n()("dataframe.add_row_above"))
38097					),
38098
38099					() => (
38100						deep_read_state(i18n()),
38101						untrack(() => i18n()("dataframe.add_row_below"))
38102					)
38103				]
38104			);
38105
38106			event('click', button_5, () => on_add_row_above()());
38107			event('click', button_6, () => on_add_row_below()());
38108			append$1($$anchor, fragment_2);
38109		};
38110
38111		if_block(node_9, ($$render) => {
38112			if (!get$1(is_header) && get$1(can_add_rows)) $$render(consequent_5);
38113		});
38114	}
38115
38116	var node_14 = sibling(node_9, 2);
38117
38118	{
38119		var consequent_7 = ($$anchor) => {
38120			var fragment_3 = root_7();
38121			var button_8 = first_child(fragment_3);
38122			var node_15 = child(button_8);
38123
38124			CellMenuIcons(node_15, { icon: 'add-column-left' });
38125
38126			var text_10 = sibling(node_15);
38127
38128			reset(button_8);
38129
38130			var button_9 = sibling(button_8, 2);
38131			var node_16 = child(button_9);
38132
38133			CellMenuIcons(node_16, { icon: 'add-column-right' });
38134
38135			var text_11 = sibling(node_16);
38136
38137			reset(button_9);
38138
38139			var node_17 = sibling(button_9, 2);
38140
38141			{
38142				var consequent_6 = ($$anchor) => {
38143					var button_10 = root_8$1();
38144					var node_18 = child(button_10);
38145
38146					CellMenuIcons(node_18, { icon: 'delete-column' });
38147
38148					var text_12 = sibling(node_18);
38149
38150					reset(button_10);
38151
38152					template_effect(($0) => set_text(text_12, ` ${$0 ?? ''}`), [
38153						() => (
38154							deep_read_state(i18n()),
38155							untrack(() => i18n()("dataframe.delete_column"))
38156						)
38157					]);
38158
38159					event('click', button_10, function (...$$args) {
38160						on_delete_col()?.apply(this, $$args);
38161					});
38162
38163					append$1($$anchor, button_10);
38164				};
38165
38166				if_block(node_17, ($$render) => {
38167					if (can_delete_cols()) $$render(consequent_6);
38168				});
38169			}
38170
38171			template_effect(
38172				($0, $1) => {
38173					set_text(text_10, ` ${$0 ?? ''}`);
38174					set_text(text_11, ` ${$1 ?? ''}`);
38175				},
38176				[
38177					() => (
38178						deep_read_state(i18n()),
38179						untrack(() => i18n()("dataframe.add_column_left"))
38180					),
38181
38182					() => (
38183						deep_read_state(i18n()),
38184						untrack(() => i18n()("dataframe.add_column_right"))
38185					)
38186				]
38187			);
38188
38189			event('click', button_8, () => on_add_column_left()());
38190			event('click', button_9, () => on_add_column_right()());
38191			append$1($$anchor, fragment_3);
38192		};
38193
38194		if_block(node_14, ($$render) => {
38195			if (get$1(can_add_columns)) $$render(consequent_7);
38196		});
38197	}
38198
38199	reset(div);
38200	bind_this(div, ($$value) => set(menu_element, $$value), () => get$1(menu_element));
38201
38202	var node_19 = sibling(div, 2);
38203
38204	{
38205		var consequent_8 = ($$anchor) => {
38206			FilterMenu($$anchor, {
38207				get on_filter() {
38208					return on_filter();
38209				}
38210			});
38211		};
38212
38213		if_block(node_19, ($$render) => {
38214			if (get$1(active_filter_menu)) $$render(consequent_8);
38215		});
38216	}
38217
38218	append$1($$anchor, fragment);
38219
38220	return pop($$exports);
38221}
38222
38223var root_2$1 = from_html(`<button class="toolbar-button check-button svelte-1rajnm3" aria-label="Apply filter and update dataframe values" title="Apply filter and update dataframe values"><!></button>`);
38224var root_1$1 = from_html(`<div class="search-container svelte-1rajnm3"><input type="text"/> <!></div>`);
38225var root$1 = from_html(`<div class="toolbar svelte-1rajnm3" role="toolbar" aria-label="Table actions"><div class="toolbar-buttons svelte-1rajnm3"><!> <!> <!></div></div>`);
38226
38227function Toolbar($$anchor, $$props) {
38228	push($$props, false);
38229
38230	let show_fullscreen_button = prop($$props, 'show_fullscreen_button', 12, false);
38231	let show_copy_button = prop($$props, 'show_copy_button', 12, false);
38232	let show_search = prop($$props, 'show_search', 12, "none");
38233	let fullscreen = prop($$props, 'fullscreen', 12, false);
38234	let on_copy = prop($$props, 'on_copy', 12);
38235	let on_commit_filter = prop($$props, 'on_commit_filter', 12);
38236	const dispatch = createEventDispatcher$1();
38237	let copied = mutable_source(false);
38238	let timer;
38239	let current_search_query = prop($$props, 'current_search_query', 12, null);
38240	let input_value = "";
38241
38242	function handle_search_input(e) {
38243		const target = e.target;
38244
38245		input_value = target.value;
38246
38247		const new_query = input_value || null;
38248
38249		if (current_search_query() !== new_query) {
38250			current_search_query(new_query);
38251			dispatch("search", current_search_query());
38252		}
38253	}
38254
38255	function copy_feedback() {
38256		set(copied, true);
38257
38258		if (timer) clearTimeout(timer);
38259
38260		timer = setTimeout(
38261			() => {
38262				set(copied, false);
38263			},
38264			2000
38265		);
38266	}
38267
38268	async function handle_copy() {
38269		await on_copy()();
38270		copy_feedback();
38271	}
38272
38273	onDestroy$1(() => {
38274		if (timer) clearTimeout(timer);
38275	});
38276
38277	var $$exports = {
38278		get show_fullscreen_button() {
38279			return show_fullscreen_button();
38280		},
38281
38282		set show_fullscreen_button($$value) {
38283			show_fullscreen_button($$value);
38284			flushSync();
38285		},
38286
38287		get show_copy_button() {
38288			return show_copy_button();
38289		},
38290
38291		set show_copy_button($$value) {
38292			show_copy_button($$value);
38293			flushSync();
38294		},
38295
38296		get show_search() {
38297			return show_search();
38298		},
38299
38300		set show_search($$value) {
38301			show_search($$value);
38302			flushSync();
38303		},
38304
38305		get fullscreen() {
38306			return fullscreen();
38307		},
38308
38309		set fullscreen($$value) {
38310			fullscreen($$value);
38311			flushSync();
38312		},
38313
38314		get on_copy() {
38315			return on_copy();
38316		},
38317
38318		set on_copy($$value) {
38319			on_copy($$value);
38320			flushSync();
38321		},
38322
38323		get on_commit_filter() {
38324			return on_commit_filter();
38325		},
38326
38327		set on_commit_filter($$value) {
38328			on_commit_filter($$value);
38329			flushSync();
38330		},
38331
38332		get current_search_query() {
38333			return current_search_query();
38334		},
38335
38336		set current_search_query($$value) {
38337			current_search_query($$value);
38338			flushSync();
38339		}
38340	};
38341
38342	init$1();
38343
38344	var div = root$1();
38345	var div_1 = child(div);
38346	var node = child(div_1);
38347
38348	{
38349		var consequent_1 = ($$anchor) => {
38350			var div_2 = root_1$1();
38351			var input = child(div_2);
38352
38353			remove_input_defaults(input);
38354
38355			let classes;
38356			var node_1 = sibling(input, 2);
38357
38358			{
38359				var consequent = ($$anchor) => {
38360					var button = root_2$1();
38361					var node_2 = child(button);
38362
38363					Check$1(node_2);
38364					reset(button);
38365
38366					event('click', button, function (...$$args) {
38367						on_commit_filter()?.apply(this, $$args);
38368					});
38369
38370					append$1($$anchor, button);
38371				};
38372
38373				if_block(node_1, ($$render) => {
38374					if (current_search_query() && show_search() === "filter") $$render(consequent);
38375				});
38376			}
38377
38378			reset(div_2);
38379
38380			template_effect(() => {
38381				set_value(input, current_search_query() || "");
38382				set_attribute(input, 'placeholder', show_search() === "filter" ? "Filter..." : "Search...");
38383				classes = set_class(input, 1, 'search-input svelte-1rajnm3', null, classes, { 'filter-mode': show_search() === "filter" });
38384				set_attribute(input, 'title', `Enter text to ${show_search()} the table`);
38385			});
38386
38387			event('input', input, handle_search_input);
38388			append$1($$anchor, div_2);
38389		};
38390
38391		if_block(node, ($$render) => {
38392			if (show_search() !== "none") $$render(consequent_1);
38393		});
38394	}
38395
38396	var node_3 = sibling(node, 2);
38397
38398	{
38399		var consequent_2 = ($$anchor) => {
38400			{
38401				let $0 = derived_safe_equal(() => get$1(copied) ? Check$1 : Copy$1);
38402				let $1 = derived_safe_equal(() => get$1(copied) ? "Copied to clipboard" : "Copy table data");
38403
38404				IconButton$1($$anchor, {
38405					get Icon() {
38406						return get$1($0);
38407					},
38408
38409					get label() {
38410						return get$1($1);
38411					},
38412					onclick: handle_copy
38413				});
38414			}
38415		};
38416
38417		if_block(node_3, ($$render) => {
38418			if (show_copy_button()) $$render(consequent_2);
38419		});
38420	}
38421
38422	var node_4 = sibling(node_3, 2);
38423
38424	{
38425		var consequent_3 = ($$anchor) => {
38426			FullscreenButton$1($$anchor, {
38427				get fullscreen() {
38428					return fullscreen();
38429				},
38430
38431				$$events: {
38432					fullscreen($$arg) {
38433						bubble_event.call(this, $$props, $$arg);
38434					}
38435				}
38436			});
38437		};
38438
38439		if_block(node_4, ($$render) => {
38440			if (show_fullscreen_button()) $$render(consequent_3);
38441		});
38442	}
38443
38444	reset(div_1);
38445	reset(div);
38446	append$1($$anchor, div);
38447
38448	return pop($$exports);
38449}
38450
38451function cast_value_to_type(v, t) {
38452  if (v === null || v === void 0) {
38453    return v;
38454  }
38455  if (t === "number") {
38456    const n = Number(v);
38457    return isNaN(n) ? v : n;
38458  }
38459  if (t === "bool") {
38460    if (typeof v === "boolean") return v;
38461    if (typeof v === "number") return v !== 0;
38462    const s = String(v).toLowerCase();
38463    if (s === "true" || s === "1") return true;
38464    if (s === "false" || s === "0") return false;
38465    return v;
38466  }
38467  if (t === "date") {
38468    const d = new Date(v);
38469    return isNaN(d.getTime()) ? v : d.toISOString();
38470  }
38471  return v;
38472}
38473
38474function make_headers(_head, col_count, els, make_id) {
38475  let _h = _head || [];
38476  if (col_count[1] === "fixed" && _h.length < col_count[0]) {
38477    const fill = Array(col_count[0] - _h.length).fill("").map((_, i) => `${i + _h.length}`);
38478    _h = _h.concat(fill);
38479  }
38480  if (!_h || _h.length === 0) {
38481    return Array(col_count[0]).fill(0).map((_, i) => {
38482      const _id = make_id();
38483      els[_id] = { cell: null, input: null };
38484      return { id: _id, value: JSON.stringify(i + 1) };
38485    });
38486  }
38487  return _h.map((h, i) => {
38488    const _id = make_id();
38489    els[_id] = { cell: null, input: null };
38490    return { id: _id, value: h ?? "" };
38491  });
38492}
38493function process_data(values, els, data_binding, make_id, display_value = null, datatype) {
38494  if (!values || values.length === 0) {
38495    return [];
38496  }
38497  const result = values.map((row, i) => {
38498    return row.map((value, j) => {
38499      const _id = make_id();
38500      els[_id] = { cell: null, input: null };
38501      data_binding[_id] = value;
38502      let display = display_value?.[i]?.[j];
38503      if (display === void 0) {
38504        display = String(value);
38505      }
38506      const dtype = Array.isArray(datatype) ? datatype[j] : datatype;
38507      return {
38508        id: _id,
38509        value: cast_value_to_type(value, dtype),
38510        display_value: display
38511      };
38512    });
38513  });
38514  return result;
38515}
38516
38517async function save_cell_value(input_value, ctx, row, col) {
38518  if (!ctx.data || !ctx.data[row] || !ctx.data[row][col]) return;
38519  const old_value = ctx.data[row][col].value;
38520  ctx.data[row][col].value = input_value;
38521  if (ctx.data[row][col].display_value !== void 0) {
38522    ctx.data[row][col].display_value = input_value;
38523  }
38524  if (old_value !== input_value && ctx.dispatch) {
38525    ctx.dispatch("change", {
38526      data: ctx.data.map((row2) => row2.map((cell) => cell.value)),
38527      headers: ctx.headers?.map((h) => h.value) || [],
38528      metadata: null
38529    });
38530  }
38531  ctx.actions.set_selected([row, col]);
38532}
38533async function handle_cell_blur(event, ctx, coords) {
38534  if (!ctx.data || !ctx.headers || !ctx.els) return;
38535  const input_el = event.target;
38536  if (!input_el || input_el.value === void 0) return;
38537  await save_cell_value(input_el.value, ctx, coords[0], coords[1]);
38538}
38539function handle_header_navigation(event, ctx) {
38540  const state = get(ctx.state);
38541  const selected_header = state.ui_state.selected_header;
38542  const header_edit = state.ui_state.header_edit;
38543  const headers = ctx.headers || [];
38544  if (selected_header === false || header_edit !== false) return false;
38545  switch (event.key) {
38546    case "ArrowDown":
38547      ctx.actions.set_selected_header(false);
38548      ctx.actions.set_selected([0, selected_header]);
38549      ctx.actions.set_selected_cells([[0, selected_header]]);
38550      return true;
38551    case "ArrowLeft":
38552      ctx.actions.set_selected_header(
38553        selected_header > 0 ? selected_header - 1 : selected_header
38554      );
38555      return true;
38556    case "ArrowRight":
38557      ctx.actions.set_selected_header(
38558        selected_header < headers.length - 1 ? selected_header + 1 : selected_header
38559      );
38560      return true;
38561    case "Escape":
38562      event.preventDefault();
38563      ctx.actions.set_selected_header(false);
38564      return true;
38565    case "Enter":
38566      event.preventDefault();
38567      if (state.config.editable) {
38568        ctx.actions.set_header_edit(selected_header);
38569      }
38570      return true;
38571  }
38572  return false;
38573}
38574function handle_delete_operation(event, ctx) {
38575  if (!ctx.data || !ctx.headers || !ctx.els || !ctx.dispatch) return false;
38576  const state = get(ctx.state);
38577  if (!state.config.editable) return false;
38578  if (event.key !== "Delete" && event.key !== "Backspace") return false;
38579  const editing = state.ui_state.editing;
38580  const selected_cells = state.ui_state.selected_cells;
38581  const static_columns = state.config.static_columns || [];
38582  if (selected_cells.some(([_, col]) => static_columns.includes(col))) {
38583    return false;
38584  }
38585  if (editing) {
38586    const [row, col] = editing;
38587    const input_el = ctx.els[ctx.data[row][col].id]?.input;
38588    if (input_el && input_el.selectionStart !== input_el.selectionEnd) {
38589      return false;
38590    }
38591    if (event.key === "Delete" && input_el?.selectionStart !== input_el?.value.length) {
38592      return false;
38593    }
38594    if (event.key === "Backspace" && input_el?.selectionStart !== 0) {
38595      return false;
38596    }
38597  }
38598  event.preventDefault();
38599  if (selected_cells.length > 0) {
38600    const new_data = handle_delete_key(ctx.data, selected_cells);
38601    ctx.dispatch("change", {
38602      data: new_data.map((row) => row.map((cell) => cell.value)),
38603      headers: ctx.headers.map((h) => h.value),
38604      metadata: null
38605    });
38606  }
38607  return true;
38608}
38609function handle_arrow_keys(event, ctx, i, j) {
38610  const state = get(ctx.state);
38611  const editing = state.ui_state.editing;
38612  const selected_cells = state.ui_state.selected_cells;
38613  if (editing) return false;
38614  if (!ctx.data) return false;
38615  event.preventDefault();
38616  const next_coords = ctx.actions.move_cursor(event, [i, j], ctx.data);
38617  if (next_coords) {
38618    if (event.shiftKey) {
38619      ctx.actions.set_selected_cells(
38620        ctx.actions.get_range_selection(
38621          selected_cells.length > 0 ? selected_cells[0] : [i, j],
38622          next_coords
38623        )
38624      );
38625      ctx.actions.set_editing(false);
38626    } else {
38627      ctx.actions.set_selected_cells([next_coords]);
38628      ctx.actions.set_editing(false);
38629    }
38630    ctx.actions.set_selected(next_coords);
38631  } else if (next_coords === false && event.key === "ArrowUp" && i === 0) {
38632    ctx.actions.set_selected_header(j);
38633    ctx.actions.set_selected(false);
38634    ctx.actions.set_selected_cells([]);
38635    ctx.actions.set_editing(false);
38636  }
38637  return true;
38638}
38639async function handle_enter_key(event, ctx, i, j) {
38640  if (!ctx.data || !ctx.els) return false;
38641  const state = get(ctx.state);
38642  if (!state.config.editable) return false;
38643  const editing = state.ui_state.editing;
38644  if (editing && event.shiftKey) return false;
38645  event.preventDefault();
38646  if (editing && dequal$3(editing, [i, j])) {
38647    const cell_id = ctx.data[i][j].id;
38648    const input_el = ctx.els[cell_id]?.input;
38649    if (input_el) {
38650      await save_cell_value(input_el.value, ctx, i, j);
38651    }
38652    ctx.actions.set_editing(false);
38653    await tick$1();
38654    ctx.parent_element?.focus();
38655  } else {
38656    ctx.actions.set_editing([i, j]);
38657  }
38658  return true;
38659}
38660function handle_tab_key(event, ctx, i, j) {
38661  if (!ctx.data) return false;
38662  event.preventDefault();
38663  ctx.actions.set_editing(false);
38664  const next_cell = ctx.actions.get_next_cell_coordinates(
38665    [i, j],
38666    ctx.data,
38667    event.shiftKey
38668  );
38669  if (next_cell) {
38670    ctx.actions.set_selected_cells([next_cell]);
38671    ctx.actions.set_selected(next_cell);
38672    if (get(ctx.state).config.editable) {
38673      ctx.actions.set_editing(next_cell);
38674    }
38675  }
38676  return true;
38677}
38678function handle_default_key(event, ctx, i, j) {
38679  const state = get(ctx.state);
38680  if (!state.config.editable) return false;
38681  const editing = state.ui_state.editing;
38682  if (event.key.length === 1 && (!editing || !dequal$3(editing, [i, j]))) {
38683    ctx.actions.set_editing([i, j]);
38684    return true;
38685  }
38686  return false;
38687}
38688async function handle_cell_navigation(event, ctx) {
38689  if (!ctx.data) return false;
38690  const state = get(ctx.state);
38691  const selected = state.ui_state.selected;
38692  const selected_cells = state.ui_state.selected_cells;
38693  if (!selected) return false;
38694  if (event.key === "c" && (event.metaKey || event.ctrlKey)) {
38695    event.preventDefault();
38696    if (selected_cells.length > 0) {
38697      await copy_table_data(ctx.data, selected_cells);
38698    }
38699    ctx.actions.set_copy_flash(true);
38700    return true;
38701  }
38702  const [i, j] = selected;
38703  switch (event.key) {
38704    case "ArrowRight":
38705    case "ArrowLeft":
38706    case "ArrowDown":
38707    case "ArrowUp":
38708      return handle_arrow_keys(event, ctx, i, j);
38709    case "Escape":
38710      if (!state.config.editable) return false;
38711      event.preventDefault();
38712      ctx.actions.set_editing(false);
38713      tick$1().then(() => {
38714        if (ctx.parent_element) {
38715          ctx.parent_element.focus();
38716        }
38717      });
38718      return true;
38719    case "Enter":
38720      return await handle_enter_key(event, ctx, i, j);
38721    case "Tab":
38722      return handle_tab_key(event, ctx, i, j);
38723    case "Delete":
38724    case "Backspace":
38725      return handle_delete_operation(event, ctx);
38726    default:
38727      return handle_default_key(event, ctx, i, j);
38728  }
38729}
38730async function handle_keydown(event, context) {
38731  if (handle_header_navigation(event, context)) return;
38732  if (handle_delete_operation(event, context)) return;
38733  await handle_cell_navigation(event, context);
38734}
38735
38736function create_drag_handlers(state, set_is_dragging, set_selected_cells, set_selected, handle_cell_click, show_row_numbers, parent_element) {
38737  const start_drag = (event, row, col) => {
38738    const target = event.target;
38739    const is_checkbox_click = target.type === "checkbox" || target.closest('input[type="checkbox"]') || target.closest(".bool-cell");
38740    if (event.target instanceof HTMLAnchorElement || show_row_numbers && col === -1 || is_checkbox_click)
38741      return;
38742    event.preventDefault();
38743    event.stopPropagation();
38744    state.mouse_down_pos = { x: event.clientX, y: event.clientY };
38745    state.drag_start = [row, col];
38746    if (!event.shiftKey && !event.metaKey && !event.ctrlKey) {
38747      set_selected_cells([[row, col]]);
38748      set_selected([row, col]);
38749      handle_cell_click(event, row, col);
38750    }
38751  };
38752  const update_selection = (event) => {
38753    const cell = event.target.closest("td");
38754    if (!cell) return;
38755    const row = parseInt(cell.getAttribute("data-row") || "0");
38756    const col = parseInt(cell.getAttribute("data-col") || "0");
38757    if (isNaN(row) || isNaN(col)) return;
38758    const selection_range = get_range_selection(state.drag_start, [row, col]);
38759    set_selected_cells(selection_range);
38760    set_selected([row, col]);
38761  };
38762  const end_drag = (event) => {
38763    if (!state.is_dragging && state.drag_start) {
38764      handle_cell_click(event, state.drag_start[0], state.drag_start[1]);
38765    } else if (state.is_dragging && parent_element) {
38766      parent_element.focus();
38767    }
38768    state.is_dragging = false;
38769    set_is_dragging(false);
38770    state.drag_start = null;
38771    state.mouse_down_pos = null;
38772  };
38773  return {
38774    handle_mouse_down: start_drag,
38775    handle_mouse_move(event) {
38776      if (!state.drag_start || !state.mouse_down_pos) return;
38777      if (!(event.buttons & 1)) {
38778        end_drag(event);
38779        return;
38780      }
38781      const dx = Math.abs(event.clientX - state.mouse_down_pos.x);
38782      const dy = Math.abs(event.clientY - state.mouse_down_pos.y);
38783      if (!state.is_dragging && (dx > 3 || dy > 3)) {
38784        state.is_dragging = true;
38785        set_is_dragging(true);
38786      }
38787      if (state.is_dragging) {
38788        update_selection(event);
38789      }
38790    },
38791    handle_mouse_up: end_drag
38792  };
38793}
38794
38795var root_3 = from_html(`<div class="label svelte-2balj6"><p class="svelte-2balj6"> </p></div>`);
38796var root_2 = from_html(`<div class="header-row svelte-2balj6"><!> <!></div>`);
38797var root_4 = from_html(`<caption class="sr-only svelte-2balj6"> </caption>`);
38798var root_8 = from_html(`<td tabindex="-1" class="svelte-2balj6"><div class="cell-wrap svelte-2balj6"><!></div></td>`);
38799var root_10 = from_html(`<tr slot="thead" class="svelte-2balj6"><!><!></tr>`);
38800var root_13 = from_html(`<tr slot="tbody"><!><!></tr>`);
38801var root_9 = from_html(`<div class="table-wrap svelte-2balj6"><!></div>`);
38802var root_16 = from_html(`<button class="scroll-top-button svelte-2balj6">&uarr;</button>`);
38803var root_1 = from_html(`<div class="table-container svelte-2balj6"><!> <div role="grid" tabindex="0"><table aria-hidden="true" class="svelte-2balj6"><!><thead class="svelte-2balj6"><tr class="svelte-2balj6"><!><!></tr></thead><tbody class="svelte-2balj6"><tr class="svelte-2balj6"><!><!></tr></tbody></table> <!> <!></div></div> <!> <!>`, 1);
38804
38805function Table($$anchor, $$props) {
38806	push($$props, false);
38807
38808	const $df_state = () => store_get(df_state, '$df_state', $$stores);
38809	const [$$stores, $$cleanup] = setup_stores();
38810	const selected_cells = mutable_source();
38811	const selected = mutable_source();
38812	const editing = mutable_source();
38813	const header_edit = mutable_source();
38814	const selected_header = mutable_source();
38815	const active_cell_menu = mutable_source();
38816	const active_header_menu = mutable_source();
38817	const copy_flash = mutable_source();
38818	const actual_pinned_columns = mutable_source();
38819	const max = mutable_source();
38820	const selected_index = mutable_source();
38821	const handle_mouse_down = mutable_source();
38822	const handle_mouse_move = mutable_source();
38823	const handle_mouse_up = mutable_source();
38824	let datatype = prop($$props, 'datatype', 12);
38825	let label = prop($$props, 'label', 12, null);
38826	let show_label = prop($$props, 'show_label', 12, true);
38827	let headers = prop($$props, 'headers', 28, () => []);
38828	let values = prop($$props, 'values', 28, () => []);
38829	let col_count = prop($$props, 'col_count', 12);
38830	let row_count = prop($$props, 'row_count', 12);
38831	let latex_delimiters = prop($$props, 'latex_delimiters', 12);
38832	let components = prop($$props, 'components', 28, () => ({}));
38833	let editable = prop($$props, 'editable', 12, true);
38834	let wrap = prop($$props, 'wrap', 12, false);
38835	let root = prop($$props, 'root', 12);
38836	let i18n = prop($$props, 'i18n', 12);
38837	let max_height = prop($$props, 'max_height', 12, 500);
38838	let line_breaks = prop($$props, 'line_breaks', 12, true);
38839	let column_widths = prop($$props, 'column_widths', 28, () => []);
38840	let show_row_numbers = prop($$props, 'show_row_numbers', 12, false);
38841	let upload = prop($$props, 'upload', 12);
38842	let stream_handler = prop($$props, 'stream_handler', 12);
38843	let buttons = prop($$props, 'buttons', 12, null);
38844	let value_is_output = prop($$props, 'value_is_output', 12, false);
38845	let max_chars = prop($$props, 'max_chars', 12, undefined);
38846	let show_search = prop($$props, 'show_search', 12, "none");
38847	let pinned_columns = prop($$props, 'pinned_columns', 12, 0);
38848	let static_columns = prop($$props, 'static_columns', 28, () => []);
38849	let fullscreen = prop($$props, 'fullscreen', 12, false);
38850
38851	const df_ctx = mutable_source(create_dataframe_context({
38852		show_fullscreen_button: buttons() === null ? true : buttons().includes("fullscreen"),
38853		show_copy_button: buttons() === null ? true : buttons().includes("copy"),
38854		show_search: show_search(),
38855		show_row_numbers: show_row_numbers(),
38856		editable: editable(),
38857		pinned_columns: pinned_columns(),
38858		show_label: show_label(),
38859		line_breaks: line_breaks(),
38860		wrap: wrap(),
38861		max_height: max_height(),
38862		column_widths: column_widths(),
38863		max_chars: max_chars(),
38864		static_columns: static_columns()
38865	}));
38866
38867	const { state: df_state, actions: df_actions } = get$1(df_ctx);
38868
38869	onMount$1(() => {
38870		mutate(df_ctx, get$1(df_ctx).parent_element = get$1(parent));
38871		mutate(df_ctx, get$1(df_ctx).get_data_at = get_data_at);
38872		mutate(df_ctx, get$1(df_ctx).get_column = get_column);
38873		mutate(df_ctx, get$1(df_ctx).get_row = get_row);
38874		mutate(df_ctx, get$1(df_ctx).dispatch = dispatch);
38875		init_drag_handlers();
38876
38877		const observer = new IntersectionObserver((entries) => {
38878			entries.forEach((entry) => {
38879				if (entry.isIntersecting && !is_visible) {
38880					set(width_calculated, false);
38881				}
38882
38883				is_visible = entry.isIntersecting;
38884			});
38885		});
38886
38887		observer.observe(get$1(parent));
38888		document.addEventListener("click", handle_click_outside$1);
38889		window.addEventListener("resize", handle_resize);
38890
38891		const global_mouse_up = (event) => {
38892			if (get$1(is_dragging) || get$1(drag_start)) {
38893				get$1(handle_mouse_up)(event);
38894			}
38895		};
38896
38897		document.addEventListener("mouseup", global_mouse_up);
38898
38899		return () => {
38900			observer.disconnect();
38901			document.removeEventListener("click", handle_click_outside$1);
38902			window.removeEventListener("resize", handle_resize);
38903			document.removeEventListener("mouseup", global_mouse_up);
38904		};
38905	});
38906
38907	const dispatch = createEventDispatcher$1();
38908	let els = mutable_source({});
38909	let data_binding = {};
38910	let _headers = mutable_source(make_headers(headers(), col_count(), get$1(els), make_id));
38911	let old_headers = mutable_source(headers());
38912	let data = mutable_source([[]]);
38913	let old_val = mutable_source(undefined);
38914	let search_results = mutable_source([[]]);
38915	let dragging = mutable_source(false);
38916	let color_accent_copied;
38917	let filtered_to_original_map = mutable_source([]);
38918
38919	onMount$1(() => {
38920		const color = getComputedStyle(document.documentElement).getPropertyValue("--color-accent").trim();
38921
38922		color_accent_copied = color + "40"; // 80 is 50% opacity in hex
38923		document.documentElement.style.setProperty("--color-accent-copied", color_accent_copied);
38924	});
38925
38926	const get_data_at = (row, col) => get$1(data)?.[row]?.[col]?.value;
38927	const get_column = (col) => get$1(data)?.map((row) => row[col]?.value) ?? [];
38928	const get_row = (row) => get$1(data)?.[row]?.map((cell) => cell.value) ?? [];
38929
38930	function make_id() {
38931		return Math.random().toString(36).substring(2, 15);
38932	}
38933
38934	let display_value = prop($$props, 'display_value', 12, null);
38935	let styling = prop($$props, 'styling', 12, null);
38936
38937	// only clear column widths when the data structure changes
38938	// only reset sort state when values are changed
38939	let previous_headers = mutable_source(get$1(_headers).map((h) => h.value));
38940
38941	let previous_data = mutable_source(get$1(data).map((row) => row.map((cell) => cell.value)));
38942
38943	function handle_sort(col, direction) {
38944		df_actions.handle_sort(col, direction);
38945		sort_data(get$1(data), display_value(), styling());
38946	}
38947
38948	function clear_sort() {
38949		df_actions.reset_sort_state();
38950		sort_data(get$1(data), display_value(), styling());
38951	}
38952
38953	function handle_filter(col, datatype, filter, value) {
38954		df_actions.handle_filter(col, datatype, filter, value);
38955		filter_data(get$1(data), display_value(), styling());
38956	}
38957
38958	function clear_filter() {
38959		df_actions.reset_filter_state();
38960		filter_data(get$1(data), display_value(), styling());
38961	}
38962
38963	async function edit_header(i, _select = false) {
38964		if (!editable() || get$1(header_edit) === i || col_count()[1] !== "dynamic") return;
38965
38966		df_actions.set_header_edit(i);
38967	}
38968
38969	function handle_header_click(event, col) {
38970		if (event.target instanceof HTMLAnchorElement) {
38971			return;
38972		}
38973
38974		event.preventDefault();
38975		event.stopPropagation();
38976
38977		if (!editable()) return;
38978
38979		df_actions.set_editing(false);
38980		df_actions.handle_header_click(col, editable());
38981		get$1(parent).focus();
38982	}
38983
38984	function end_header_edit(event) {
38985		if (!editable()) return;
38986
38987		df_actions.end_header_edit(event.detail.key);
38988		get$1(parent).focus();
38989	}
38990
38991	async function add_row(index) {
38992		get$1(parent).focus();
38993
38994		if (row_count()[1] !== "dynamic") return;
38995
38996		const new_row = Array(get$1(data)[0]?.length || headers().length).fill(0).map((_, i) => {
38997			const _id = make_id();
38998
38999			mutate(els, get$1(els)[_id] = { cell: null, input: null });
39000
39001			return { id: _id, value: "" };
39002		});
39003
39004		if (get$1(data).length === 0) {
39005			set(data, [new_row]);
39006		} else if (index !== undefined && index >= 0 && index <= get$1(data).length) {
39007			get$1(data).splice(index, 0, new_row);
39008		} else {
39009			get$1(data).push(new_row);
39010		}
39011
39012		set(selected, [index !== undefined ? index : get$1(data).length - 1, 0]);
39013	}
39014
39015	async function add_col(index) {
39016		get$1(parent).focus();
39017
39018		if (col_count()[1] !== "dynamic") return;
39019
39020		const result = df_actions.add_col(get$1(data), headers(), make_id, index);
39021
39022		result.data.forEach((row) => {
39023			row.forEach((cell) => {
39024				if (!get$1(els)[cell.id]) {
39025					mutate(els, get$1(els)[cell.id] = { cell: null, input: null });
39026				}
39027			});
39028		});
39029
39030		set(data, result.data);
39031		headers(result.headers);
39032		await tick$1();
39033
39034		requestAnimationFrame(() => {
39035			edit_header(index !== undefined ? index : get$1(data)[0].length - 1, true);
39036
39037			const new_w = get$1(parent).querySelectorAll("tbody")[1].offsetWidth;
39038
39039			get$1(parent).querySelectorAll("table")[1].scrollTo({ left: new_w });
39040		});
39041	}
39042
39043	function handle_click_outside$1(event) {
39044		if (handle_click_outside(event, get$1(parent))) {
39045			df_actions.clear_ui_state();
39046			set(header_edit, false);
39047			set(selected_header, false);
39048		}
39049	}
39050
39051	let width_calc_timeout = mutable_source();
39052	let width_calculated = mutable_source(false);
39053	let cells = mutable_source([]);
39054	let parent = mutable_source();
39055	let table = mutable_source();
39056	let last_width_data_length = mutable_source(0);
39057	let last_width_column_count = mutable_source(0);
39058
39059	function set_cell_widths() {
39060		const column_count = get$1(data)[0]?.length || 0;
39061
39062		if ($df_state().filter_state.filter_columns.length > 0) {
39063			return;
39064		}
39065
39066		if (get$1(last_width_data_length) === get$1(data).length && get$1(last_width_column_count) === column_count && $df_state().sort_state.sort_columns.length > 0) {
39067			return;
39068		}
39069
39070		if (!get$1(parent)) {
39071			return;
39072		}
39073
39074		set(last_width_data_length, get$1(data).length);
39075		set(last_width_column_count, column_count);
39076
39077		const widths = get$1(cells).map((el) => el?.clientWidth || 0);
39078
39079		if (widths.length === 0) return;
39080
39081		if (show_row_numbers()) {
39082			get$1(parent).style.setProperty(`--cell-width-row-number`, `${widths[0]}px`);
39083		}
39084
39085		for (let i = 0; i < 50; i++) {
39086			if (!column_widths()[i]) {
39087				get$1(parent).style.removeProperty(`--cell-width-${i}`);
39088			} else if (column_widths()[i].endsWith("%")) {
39089				const percentage = parseFloat(column_widths()[i]);
39090				const pixel_width = Math.floor(percentage / 100 * get$1(parent).clientWidth);
39091
39092				get$1(parent).style.setProperty(`--cell-width-${i}`, `${pixel_width}px`);
39093			} else {
39094				get$1(parent).style.setProperty(`--cell-width-${i}`, column_widths()[i]);
39095			}
39096		}
39097
39098		widths.forEach((width, i) => {
39099			if (!column_widths()[i]) {
39100				const calculated_width = `${Math.max(width, 45)}px`;
39101
39102				get$1(parent).style.setProperty(`--cell-width-${i}`, calculated_width);
39103			}
39104		});
39105	}
39106
39107	function get_cell_width(index) {
39108		return `var(--cell-width-${index})`;
39109	}
39110
39111	let table_height = mutable_source(values().slice(0, max_height() / values().length * 37).length * 37 + 37);
39112	let scrollbar_width = mutable_source(0);
39113
39114	function sort_data(_data, _display_value, _styling) {
39115		const result = sort_data_and_preserve_selection(_data, _display_value, _styling, $df_state().sort_state.sort_columns, get$1(selected), get_current_indices);
39116
39117		set(data, result.data);
39118		set(selected, result.selected);
39119	}
39120
39121	function filter_data(_data, _display_value, _styling) {
39122		const result = filter_data_and_preserve_selection(_data, _display_value, _styling, $df_state().filter_state.filter_columns, get$1(selected), get_current_indices, $df_state().filter_state.initial_data?.data, $df_state().filter_state.initial_data?.display_value, $df_state().filter_state.initial_data?.styling);
39123
39124		set(data, result.data);
39125		set(selected, result.selected);
39126	}
39127
39128	let is_visible = false;
39129
39130	const set_copy_flash = (value) => {
39131		df_actions.set_copy_flash(value);
39132	};
39133
39134	let previous_selected_cells = mutable_source([]);
39135
39136	function handle_blur(event) {
39137		const { blur_event, coords } = event.detail;
39138
39139		handle_cell_blur(blur_event, get$1(df_ctx), coords);
39140	}
39141
39142	function toggle_header_menu(event, col) {
39143		event.stopPropagation();
39144
39145		if (get$1(active_header_menu) && get$1(active_header_menu).col === col) {
39146			df_actions.set_active_header_menu(null);
39147		} else {
39148			const header = event.target.closest("th");
39149
39150			if (header) {
39151				const rect = header.getBoundingClientRect();
39152
39153				df_actions.set_active_header_menu({ col, x: rect.right, y: rect.bottom });
39154			}
39155		}
39156	}
39157
39158	afterUpdate$1(() => {
39159		value_is_output(false);
39160	});
39161
39162	function delete_col_at(index) {
39163		if (col_count()[1] !== "dynamic") return;
39164		if (get$1(data)[0].length <= 1) return;
39165
39166		const result = df_actions.delete_col_at(get$1(data), headers(), index);
39167
39168		set(data, result.data);
39169		headers(result.headers);
39170		set(_headers, make_headers(headers(), col_count(), get$1(els), make_id));
39171		df_actions.set_active_cell_menu(null);
39172		df_actions.set_active_header_menu(null);
39173		df_actions.set_selected(false);
39174		df_actions.set_selected_cells([]);
39175		df_actions.set_editing(false);
39176	}
39177
39178	function delete_row_at(index) {
39179		set(data, df_actions.delete_row_at(get$1(data), index));
39180		df_actions.set_active_cell_menu(null);
39181		df_actions.set_active_header_menu(null);
39182	}
39183
39184	let selected_cell_coords = mutable_source();
39185
39186	function commit_filter() {
39187		if ($df_state().current_search_query && show_search() === "filter") {
39188			const filtered_data = [];
39189			const filtered_display_values = [];
39190			const filtered_styling = [];
39191
39192			get$1(search_results).forEach((row) => {
39193				const data_row = [];
39194				const display_row = [];
39195				const styling_row = [];
39196
39197				row.forEach((cell) => {
39198					data_row.push(cell.value);
39199					display_row.push(cell.display_value !== undefined ? cell.display_value : String(cell.value));
39200					styling_row.push(cell.styling || "");
39201				});
39202
39203				filtered_data.push(data_row);
39204				filtered_display_values.push(display_row);
39205				filtered_styling.push(styling_row);
39206			});
39207
39208			const change_payload = {
39209				data: filtered_data,
39210				headers: get$1(_headers).map((h) => h.value),
39211				metadata: {
39212					display_value: filtered_display_values,
39213					styling: filtered_styling
39214				}
39215			};
39216
39217			dispatch("change", change_payload);
39218
39219			if (!value_is_output()) {
39220				dispatch("input");
39221			}
39222
39223			df_actions.handle_search(null);
39224		}
39225	}
39226
39227	let viewport = mutable_source();
39228	let show_scroll_button = mutable_source(false);
39229
39230	function scroll_to_top() {
39231		get$1(viewport).scrollTo({ top: 0 });
39232	}
39233
39234	function handle_resize() {
39235		df_actions.set_active_cell_menu(null);
39236		df_actions.set_active_header_menu(null);
39237		set(selected_cells, []);
39238		set(selected, false);
39239		set(editing, false);
39240		set(width_calculated, false);
39241		set_cell_widths();
39242	}
39243
39244	function add_row_at(index, position) {
39245		const row_index = position === "above" ? index : index + 1;
39246
39247		add_row(row_index);
39248		set(active_cell_menu, null);
39249		set(active_header_menu, null);
39250	}
39251
39252	function add_col_at(index, position) {
39253		const col_index = position === "left" ? index : index + 1;
39254
39255		add_col(col_index);
39256		set(active_cell_menu, null);
39257		set(active_header_menu, null);
39258	}
39259
39260	function reset_sort_state() {
39261		df_actions.reset_sort_state();
39262	}
39263
39264	function handle_select_all(col, checked) {
39265		set(data, get$1(data).map((row) => {
39266			const new_row = [...row];
39267
39268			if (new_row[col]) {
39269				new_row[col] = { ...new_row[col], value: checked };
39270			}
39271
39272			return new_row;
39273		}));
39274	}
39275
39276	let is_dragging = mutable_source(false);
39277	let drag_start = mutable_source(null);
39278	let mouse_down_pos = mutable_source(null);
39279
39280	const drag_state = {
39281		is_dragging: get$1(is_dragging),
39282		drag_start: get$1(drag_start),
39283		mouse_down_pos: get$1(mouse_down_pos)
39284	};
39285
39286	let drag_handlers = mutable_source();
39287
39288	function init_drag_handlers() {
39289		set(drag_handlers, create_drag_handlers(drag_state, (value) => set(is_dragging, value), (cells) => df_actions.set_selected_cells(cells), (cell) => df_actions.set_selected(cell), (event, row, col) => df_actions.handle_cell_click(event, row, col), show_row_numbers(), get$1(parent)));
39290	}
39291
39292	function get_cell_display_value(row, col) {
39293		const is_search_active = $df_state().current_search_query !== undefined;
39294
39295		if (is_search_active && get$1(search_results)?.[row]?.[col]) {
39296			return get$1(search_results)[row][col].display_value !== undefined
39297				? get$1(search_results)[row][col].display_value
39298				: String(get$1(search_results)[row][col].value);
39299		}
39300
39301		if (get$1(data)?.[row]?.[col]) {
39302			return get$1(data)[row][col].display_value !== undefined
39303				? get$1(data)[row][col].display_value
39304				: String(get$1(data)[row][col].value);
39305		}
39306
39307		return "";
39308	}
39309
39310	legacy_pre_effect(() => ($df_state()), () => {
39311		set(selected_cells, $df_state().ui_state.selected_cells);
39312	});
39313
39314	legacy_pre_effect(() => ($df_state()), () => {
39315		set(selected, $df_state().ui_state.selected);
39316	});
39317
39318	legacy_pre_effect(() => ($df_state()), () => {
39319		set(editing, $df_state().ui_state.editing);
39320	});
39321
39322	legacy_pre_effect(() => ($df_state()), () => {
39323		set(header_edit, $df_state().ui_state.header_edit);
39324	});
39325
39326	legacy_pre_effect(() => ($df_state()), () => {
39327		set(selected_header, $df_state().ui_state.selected_header);
39328	});
39329
39330	legacy_pre_effect(() => ($df_state()), () => {
39331		set(active_cell_menu, $df_state().ui_state.active_cell_menu);
39332	});
39333
39334	legacy_pre_effect(() => ($df_state()), () => {
39335		set(active_header_menu, $df_state().ui_state.active_header_menu);
39336	});
39337
39338	legacy_pre_effect(() => ($df_state()), () => {
39339		set(copy_flash, $df_state().ui_state.copy_flash);
39340	});
39341
39342	legacy_pre_effect(
39343		() => (
39344			deep_read_state(values()),
39345			get$1(old_val),
39346			get$1(parent),
39347			get$1(data),
39348			get$1(els),
39349			deep_read_state(display_value()),
39350			deep_read_state(datatype()),
39351			$df_state(),
39352			deep_read_state(styling()),
39353			get$1(cells)
39354		),
39355		() => {
39356			if (!dequal$3(values(), get$1(old_val))) {
39357				if (get$1(parent)) {
39358					// only clear column widths when the data structure changes
39359					const is_reset = values().length === 0 || values().length === 1 && values()[0].length === 0;
39360
39361					const is_different_structure = get$1(old_val) !== undefined && (values().length !== get$1(old_val).length || values()[0] && get$1(old_val)[0] && values()[0].length !== get$1(old_val)[0].length);
39362
39363					if (is_reset || is_different_structure) {
39364						for (let i = 0; i < 50; i++) {
39365							get$1(parent).style.removeProperty(`--cell-width-${i}`);
39366						}
39367
39368						set(last_width_data_length, 0);
39369						set(last_width_column_count, 0);
39370						set(width_calculated, false);
39371					}
39372				}
39373
39374				// only reset sort state when values are changed
39375				const is_reset = values().length === 0 || values().length === 1 && values()[0].length === 0;
39376
39377				const is_different_structure = get$1(old_val) !== undefined && (values().length !== get$1(old_val).length || values()[0] && get$1(old_val)[0] && values()[0].length !== get$1(old_val)[0].length);
39378
39379				set(data, process_data(values(), get$1(els), data_binding, make_id, display_value(), datatype()));
39380				set(old_val, JSON.parse(JSON.stringify(values())));
39381
39382				if (is_reset || is_different_structure) {
39383					df_actions.reset_sort_state();
39384				} else if ($df_state().sort_state.sort_columns.length > 0) {
39385					sort_data(get$1(data), display_value(), styling());
39386				} else {
39387					df_actions.handle_sort(-1, "asc");
39388					df_actions.reset_sort_state();
39389				}
39390
39391				if ($df_state().filter_state.filter_columns.length > 0) {
39392					filter_data(get$1(data), display_value(), styling());
39393				} else {
39394					df_actions.reset_filter_state();
39395				}
39396
39397				if ($df_state().current_search_query) {
39398					df_actions.handle_search(null);
39399				}
39400
39401				if (get$1(parent) && get$1(cells).length > 0 && (is_reset || is_different_structure)) {
39402					set(width_calculated, false);
39403				}
39404			}
39405		}
39406	);
39407
39408	legacy_pre_effect(() => (deep_read_state(pinned_columns()), get$1(data)), () => {
39409		set(actual_pinned_columns, pinned_columns() && get$1(data)?.[0]?.length ? Math.min(pinned_columns(), get$1(data)[0].length) : 0);
39410	});
39411
39412	legacy_pre_effect(
39413		() => (
39414			deep_read_state(headers()),
39415			get$1(old_headers),
39416			deep_read_state(col_count()),
39417			get$1(els)
39418		),
39419		() => {
39420			if (!dequal$3(headers(), get$1(old_headers))) {
39421				set(_headers, make_headers(headers(), col_count(), get$1(els), make_id));
39422				set(old_headers, JSON.parse(JSON.stringify(headers())));
39423			}
39424		}
39425	);
39426
39427	legacy_pre_effect(
39428		() => (
39429			get$1(data),
39430			get$1(_headers),
39431			get$1(els),
39432			deep_read_state(display_value()),
39433			deep_read_state(styling())
39434		),
39435		() => {
39436			if (get$1(data) || get$1(_headers) || get$1(els)) {
39437				mutate(df_ctx, get$1(df_ctx).data = get$1(data));
39438				mutate(df_ctx, get$1(df_ctx).headers = get$1(_headers));
39439				mutate(df_ctx, get$1(df_ctx).els = get$1(els));
39440				mutate(df_ctx, get$1(df_ctx).display_value = display_value());
39441				mutate(df_ctx, get$1(df_ctx).styling = styling());
39442			}
39443		}
39444	);
39445
39446	legacy_pre_effect(
39447		() => (
39448			$df_state(),
39449			get$1(filtered_to_original_map),
39450			get$1(data),
39451			deep_read_state(styling())
39452		),
39453		() => {
39454			if ($df_state().current_search_query !== undefined) {
39455				const cell_map = new Map();
39456
39457				set(filtered_to_original_map, []);
39458
39459				get$1(data).forEach((row, row_idx) => {
39460					if (row.some((cell) => String(cell?.value).toLowerCase().includes($df_state().current_search_query?.toLowerCase() || ""))) {
39461						get$1(filtered_to_original_map).push(row_idx);
39462					}
39463
39464					row.forEach((cell, col_idx) => {
39465						cell_map.set(cell.id, {
39466							value: cell.value,
39467							display_value: cell.display_value !== undefined ? cell.display_value : String(cell.value),
39468							styling: styling()?.[row_idx]?.[col_idx] || ""
39469						});
39470					});
39471				});
39472
39473				const filtered = df_actions.filter_data(get$1(data));
39474
39475				set(search_results, filtered.map((row) => row.map((cell) => {
39476					const original = cell_map.get(cell.id);
39477
39478					return {
39479						...cell,
39480						display_value: original?.display_value !== undefined ? original.display_value : String(cell.value),
39481						styling: original?.styling || ""
39482					};
39483				})));
39484			} else {
39485				set(filtered_to_original_map, []);
39486			}
39487		}
39488	);
39489
39490	legacy_pre_effect(
39491		() => (
39492			get$1(data),
39493			get$1(_headers),
39494			get$1(previous_data),
39495			get$1(previous_headers),
39496			deep_read_state(value_is_output())
39497		),
39498		() => {
39499			if (get$1(data) || get$1(_headers)) {
39500				df_actions.trigger_change(get$1(data), get$1(_headers), get$1(previous_data), get$1(previous_headers), value_is_output(), dispatch);
39501				set(previous_data, get$1(data).map((row) => row.map((cell) => cell.value)));
39502				set(previous_headers, get$1(_headers).map((h) => h.value));
39503			}
39504		}
39505	);
39506
39507	legacy_pre_effect(
39508		() => (
39509			$df_state(),
39510			get$1(data),
39511			deep_read_state(display_value()),
39512			deep_read_state(styling())
39513		),
39514		() => {
39515			if ($df_state().filter_state.filter_columns.length > 0) {
39516				filter_data(get$1(data), display_value(), styling());
39517			}
39518
39519			if ($df_state().sort_state.sort_columns.length > 0) {
39520				sort_data(get$1(data), display_value(), styling());
39521				df_actions.update_row_order(get$1(data));
39522			}
39523		}
39524	);
39525
39526	legacy_pre_effect(() => (get$1(data)), () => {
39527		set(max, get_max(get$1(data)));
39528	});
39529
39530	legacy_pre_effect(() => (get$1(cells), get$1(width_calc_timeout)), () => {
39531		if (get$1(cells)[0] && get$1(cells)[0]?.clientWidth) {
39532			clearTimeout(get$1(width_calc_timeout));
39533			set(width_calc_timeout, setTimeout(() => set_cell_widths(), 100));
39534		}
39535	});
39536
39537	legacy_pre_effect(() => (get$1(cells), get$1(width_calculated)), () => {
39538		if (get$1(cells)[0] && !get$1(width_calculated)) {
39539			set_cell_widths();
39540			set(width_calculated, true);
39541		}
39542	});
39543
39544	legacy_pre_effect(() => (get$1(selected)), () => {
39545		set(selected_index, !!get$1(selected) && get$1(selected)[0]);
39546	});
39547
39548	legacy_pre_effect(
39549		() => (
39550			get$1(copy_flash),
39551			get$1(selected_cells),
39552			get$1(previous_selected_cells)
39553		),
39554		() => {
39555			if (get$1(copy_flash) && !dequal$3(get$1(selected_cells), get$1(previous_selected_cells))) {
39556				set_copy_flash(false);
39557			}
39558
39559			set(previous_selected_cells, get$1(selected_cells));
39560		}
39561	);
39562
39563	legacy_pre_effect(() => (get$1(selected)), () => {
39564		if (get$1(selected) !== false) set(selected_cell_coords, get$1(selected));
39565	});
39566
39567	legacy_pre_effect(
39568		() => (
39569			get$1(selected),
39570			get$1(data),
39571			get$1(els),
39572			get$1(parent),
39573			get$1(table)
39574		),
39575		() => {
39576			if (get$1(selected) !== false) {
39577				const positions = calculate_selection_positions(get$1(selected), get$1(data), get$1(els), get$1(parent), get$1(table));
39578
39579				document.documentElement.style.setProperty("--selected-col-pos", positions.col_pos);
39580				document.documentElement.style.setProperty("--selected-row-pos", positions.row_pos || "0px");
39581			}
39582		}
39583	);
39584
39585	legacy_pre_effect(() => {}, () => {
39586		set(is_dragging, drag_state.is_dragging);
39587		set(drag_start, drag_state.drag_start);
39588		set(mouse_down_pos, drag_state.mouse_down_pos);
39589	});
39590
39591	legacy_pre_effect(() => (get$1(parent)), () => {
39592		if (get$1(parent)) init_drag_handlers();
39593	});
39594
39595	legacy_pre_effect(() => (get$1(drag_handlers)), () => {
39596		set(handle_mouse_down, get$1(drag_handlers)?.handle_mouse_down || (() => {}));
39597	});
39598
39599	legacy_pre_effect(() => (get$1(drag_handlers)), () => {
39600		set(handle_mouse_move, get$1(drag_handlers)?.handle_mouse_move || (() => {}));
39601	});
39602
39603	legacy_pre_effect(() => (get$1(drag_handlers)), () => {
39604		set(handle_mouse_up, get$1(drag_handlers)?.handle_mouse_up || (() => {}));
39605	});
39606
39607	legacy_pre_effect_reset();
39608
39609	var $$exports = {
39610		reset_sort_state,
39611		get datatype() {
39612			return datatype();
39613		},
39614
39615		set datatype($$value) {
39616			datatype($$value);
39617			flushSync();
39618		},
39619
39620		get label() {
39621			return label();
39622		},
39623
39624		set label($$value) {
39625			label($$value);
39626			flushSync();
39627		},
39628
39629		get show_label() {
39630			return show_label();
39631		},
39632
39633		set show_label($$value) {
39634			show_label($$value);
39635			flushSync();
39636		},
39637
39638		get headers() {
39639			return headers();
39640		},
39641
39642		set headers($$value) {
39643			headers($$value);
39644			flushSync();
39645		},
39646
39647		get values() {
39648			return values();
39649		},
39650
39651		set values($$value) {
39652			values($$value);
39653			flushSync();
39654		},
39655
39656		get col_count() {
39657			return col_count();
39658		},
39659
39660		set col_count($$value) {
39661			col_count($$value);
39662			flushSync();
39663		},
39664
39665		get row_count() {
39666			return row_count();
39667		},
39668
39669		set row_count($$value) {
39670			row_count($$value);
39671			flushSync();
39672		},
39673
39674		get latex_delimiters() {
39675			return latex_delimiters();
39676		},
39677
39678		set latex_delimiters($$value) {
39679			latex_delimiters($$value);
39680			flushSync();
39681		},
39682
39683		get components() {
39684			return components();
39685		},
39686
39687		set components($$value) {
39688			components($$value);
39689			flushSync();
39690		},
39691
39692		get editable() {
39693			return editable();
39694		},
39695
39696		set editable($$value) {
39697			editable($$value);
39698			flushSync();
39699		},
39700
39701		get wrap() {
39702			return wrap();
39703		},
39704
39705		set wrap($$value) {
39706			wrap($$value);
39707			flushSync();
39708		},
39709
39710		get root() {
39711			return root();
39712		},
39713
39714		set root($$value) {
39715			root($$value);
39716			flushSync();
39717		},
39718
39719		get i18n() {
39720			return i18n();
39721		},
39722
39723		set i18n($$value) {
39724			i18n($$value);
39725			flushSync();
39726		},
39727
39728		get max_height() {
39729			return max_height();
39730		},
39731
39732		set max_height($$value) {
39733			max_height($$value);
39734			flushSync();
39735		},
39736
39737		get line_breaks() {
39738			return line_breaks();
39739		},
39740
39741		set line_breaks($$value) {
39742			line_breaks($$value);
39743			flushSync();
39744		},
39745
39746		get column_widths() {
39747			return column_widths();
39748		},
39749
39750		set column_widths($$value) {
39751			column_widths($$value);
39752			flushSync();
39753		},
39754
39755		get show_row_numbers() {
39756			return show_row_numbers();
39757		},
39758
39759		set show_row_numbers($$value) {
39760			show_row_numbers($$value);
39761			flushSync();
39762		},
39763
39764		get upload() {
39765			return upload();
39766		},
39767
39768		set upload($$value) {
39769			upload($$value);
39770			flushSync();
39771		},
39772
39773		get stream_handler() {
39774			return stream_handler();
39775		},
39776
39777		set stream_handler($$value) {
39778			stream_handler($$value);
39779			flushSync();
39780		},
39781
39782		get buttons() {
39783			return buttons();
39784		},
39785
39786		set buttons($$value) {
39787			buttons($$value);
39788			flushSync();
39789		},
39790
39791		get value_is_output() {
39792			return value_is_output();
39793		},
39794
39795		set value_is_output($$value) {
39796			value_is_output($$value);
39797			flushSync();
39798		},
39799
39800		get max_chars() {
39801			return max_chars();
39802		},
39803
39804		set max_chars($$value) {
39805			max_chars($$value);
39806			flushSync();
39807		},
39808
39809		get show_search() {
39810			return show_search();
39811		},
39812
39813		set show_search($$value) {
39814			show_search($$value);
39815			flushSync();
39816		},
39817
39818		get pinned_columns() {
39819			return pinned_columns();
39820		},
39821
39822		set pinned_columns($$value) {
39823			pinned_columns($$value);
39824			flushSync();
39825		},
39826
39827		get static_columns() {
39828			return static_columns();
39829		},
39830
39831		set static_columns($$value) {
39832			static_columns($$value);
39833			flushSync();
39834		},
39835
39836		get fullscreen() {
39837			return fullscreen();
39838		},
39839
39840		set fullscreen($$value) {
39841			fullscreen($$value);
39842			flushSync();
39843		},
39844
39845		get display_value() {
39846			return display_value();
39847		},
39848
39849		set display_value($$value) {
39850			display_value($$value);
39851			flushSync();
39852		},
39853
39854		get styling() {
39855			return styling();
39856		},
39857
39858		set styling($$value) {
39859			styling($$value);
39860			flushSync();
39861		}
39862	};
39863
39864	init$1();
39865
39866	var fragment = root_1();
39867
39868	event('resize', $window, () => set_cell_widths());
39869
39870	var div = first_child(fragment);
39871	var node = child(div);
39872
39873	{
39874		var consequent_1 = ($$anchor) => {
39875			var div_1 = root_2();
39876			var node_1 = child(div_1);
39877
39878			{
39879				var consequent = ($$anchor) => {
39880					var div_2 = root_3();
39881					var p = child(div_2);
39882					var text = child(p, true);
39883
39884					reset(p);
39885					reset(div_2);
39886					template_effect(() => set_text(text, label()));
39887					append$1($$anchor, div_2);
39888				};
39889
39890				if_block(node_1, ($$render) => {
39891					if ((
39892						deep_read_state(label()),
39893						deep_read_state(show_label()),
39894						untrack(() => label() && label().length !== 0 && show_label())
39895					)) $$render(consequent);
39896				});
39897			}
39898
39899			var node_2 = sibling(node_1, 2);
39900
39901			{
39902				let $0 = derived_safe_equal(() => (
39903					deep_read_state(buttons()),
39904					untrack(() => buttons() === null ? true : buttons().includes("fullscreen"))
39905				));
39906
39907				let $1 = derived_safe_equal(() => (
39908					deep_read_state(buttons()),
39909					untrack(() => buttons() === null ? true : buttons().includes("copy"))
39910				));
39911
39912				Toolbar(node_2, {
39913					get show_fullscreen_button() {
39914						return get$1($0);
39915					},
39916
39917					get fullscreen() {
39918						return fullscreen();
39919					},
39920					on_copy: async () => await copy_table_data(get$1(data), null),
39921					get show_copy_button() {
39922						return get$1($1);
39923					},
39924
39925					get show_search() {
39926						return show_search();
39927					},
39928					on_commit_filter: commit_filter,
39929					get current_search_query() {
39930						return (
39931							$df_state(),
39932							untrack(() => $df_state().current_search_query)
39933						);
39934					},
39935
39936					$$events: {
39937						search: (e) => df_actions.handle_search(e.detail),
39938						fullscreen($$arg) {
39939							bubble_event.call(this, $$props, $$arg);
39940						}
39941					}
39942				});
39943			}
39944
39945			reset(div_1);
39946			append$1($$anchor, div_1);
39947		};
39948
39949		if_block(node, ($$render) => {
39950			if ((
39951				deep_read_state(label()),
39952				deep_read_state(show_label()),
39953				deep_read_state(buttons()),
39954				deep_read_state(show_search()),
39955				untrack(() => label() && label().length !== 0 && show_label() || (buttons() === null ? true : buttons().includes("fullscreen")) || (buttons() === null ? true : buttons().includes("copy")) || show_search() !== "none")
39956			)) $$render(consequent_1);
39957		});
39958	}
39959
39960	var div_3 = sibling(node, 2);
39961	let classes;
39962	var table_1 = child(div_3);
39963	var node_3 = child(table_1);
39964
39965	{
39966		var consequent_2 = ($$anchor) => {
39967			var caption = root_4();
39968			var text_1 = child(caption, true);
39969
39970			reset(caption);
39971			template_effect(() => set_text(text_1, label()));
39972			append$1($$anchor, caption);
39973		};
39974
39975		if_block(node_3, ($$render) => {
39976			if ((
39977				deep_read_state(label()),
39978				untrack(() => label() && label().length !== 0)
39979			)) $$render(consequent_2);
39980		});
39981	}
39982
39983	var thead = sibling(node_3);
39984	var tr = child(thead);
39985	var node_4 = child(tr);
39986
39987	{
39988		var consequent_3 = ($$anchor) => {
39989			RowNumber($$anchor, { is_header: true });
39990		};
39991
39992		if_block(node_4, ($$render) => {
39993			if (show_row_numbers()) $$render(consequent_3);
39994		});
39995	}
39996
39997	var node_5 = sibling(node_4);
39998
39999	each(node_5, 3, () => get$1(_headers), ({ value, id }) => id, ($$anchor, $$item, i) => {
40000		let id = () => get$1($$item).id;
40001
40002		{
40003			let $0 = derived_safe_equal(() => (
40004				deep_read_state(static_columns()),
40005				deep_read_state(get$1(i)),
40006				untrack(() => static_columns().includes(get$1(i)))
40007			));
40008
40009			let $1 = derived_safe_equal(() => (
40010				deep_read_state(datatype()),
40011				deep_read_state(get$1(i)),
40012				untrack(() => Array.isArray(datatype()) ? datatype()[get$1(i)] : datatype())
40013			));
40014
40015			TableHeader($$anchor, {
40016				get i() {
40017					return get$1(i);
40018				},
40019
40020				get actual_pinned_columns() {
40021					return get$1(actual_pinned_columns);
40022				},
40023
40024				get header_edit() {
40025					return get$1(header_edit);
40026				},
40027
40028				get selected_header() {
40029					return get$1(selected_header);
40030				},
40031
40032				get headers() {
40033					return headers();
40034				},
40035				get_cell_width,
40036				handle_header_click,
40037				toggle_header_menu,
40038				end_header_edit,
40039				get sort_columns() {
40040					return (
40041						$df_state(),
40042						untrack(() => $df_state().sort_state.sort_columns)
40043					);
40044				},
40045
40046				get filter_columns() {
40047					return (
40048						$df_state(),
40049						untrack(() => $df_state().filter_state.filter_columns)
40050					);
40051				},
40052
40053				get latex_delimiters() {
40054					return latex_delimiters();
40055				},
40056
40057				get line_breaks() {
40058					return line_breaks();
40059				},
40060
40061				get max_chars() {
40062					return max_chars();
40063				},
40064
40065				get editable() {
40066					return editable();
40067				},
40068
40069				get is_static() {
40070					return get$1($0);
40071				},
40072
40073				get i18n() {
40074					return i18n();
40075				},
40076
40077				get col_count() {
40078					return col_count();
40079				},
40080
40081				get datatype() {
40082					return get$1($1);
40083				},
40084
40085				get data() {
40086					return get$1(data);
40087				},
40088				on_select_all: handle_select_all,
40089				get value() {
40090					return get$1(_headers)[get$1(i)].value;
40091				},
40092
40093				set value($$value) {
40094					mutate(_headers, get$1(_headers)[get$1(i)].value = $$value);
40095				},
40096
40097				get el() {
40098					return get$1(els)[id()].input;
40099				},
40100
40101				set el($$value) {
40102					mutate(els, get$1(els)[id()].input = $$value);
40103				},
40104				$$legacy: true
40105			});
40106		}
40107	});
40108
40109	reset(tr);
40110	reset(thead);
40111
40112	var tbody = sibling(thead);
40113	var tr_1 = child(tbody);
40114	var node_6 = child(tr_1);
40115
40116	{
40117		var consequent_4 = ($$anchor) => {
40118			RowNumber($$anchor, { index: 0 });
40119		};
40120
40121		if_block(node_6, ($$render) => {
40122			if (show_row_numbers()) $$render(consequent_4);
40123		});
40124	}
40125
40126	var node_7 = sibling(node_6);
40127
40128	each(node_7, 3, () => get$1(max), ({ value, id }) => id, ($$anchor, $$item, j) => {
40129		let value = () => get$1($$item).value;
40130		var td = root_8();
40131		var div_4 = child(td);
40132		var node_8 = child(div_4);
40133
40134		{
40135			let $0 = derived_safe_equal(() => (
40136				deep_read_state(datatype()),
40137				deep_read_state(get$1(j)),
40138				untrack(() => Array.isArray(datatype()) ? datatype()[get$1(j)] : datatype())
40139			));
40140
40141			let $1 = derived_safe_equal(() => (
40142				get$1(selected_cells),
40143				deep_read_state(get$1(j)),
40144				untrack(() => get$1(selected_cells).length === 1 && get$1(selected_cells)[0][0] === 0 && get$1(selected_cells)[0][1] === get$1(j))
40145			));
40146
40147			EditableCell(node_8, {
40148				get value() {
40149					return value();
40150				},
40151
40152				get latex_delimiters() {
40153					return latex_delimiters();
40154				},
40155
40156				get line_breaks() {
40157					return line_breaks();
40158				},
40159
40160				get datatype() {
40161					return get$1($0);
40162				},
40163				edit: false,
40164				el: null,
40165				get editable() {
40166					return editable();
40167				},
40168
40169				get i18n() {
40170					return i18n();
40171				},
40172
40173				get show_selection_buttons() {
40174					return get$1($1);
40175				},
40176
40177				get coords() {
40178					return get$1(selected_cell_coords);
40179				},
40180
40181				get on_select_column() {
40182					return (untrack(() => df_actions.handle_select_column));
40183				},
40184
40185				get on_select_row() {
40186					return (untrack(() => df_actions.handle_select_row));
40187				},
40188
40189				get is_dragging() {
40190					return get$1(is_dragging);
40191				},
40192				$$events: { blur: handle_blur }
40193			});
40194		}
40195
40196		reset(div_4);
40197		reset(td);
40198		bind_this(td, ($$value, j) => mutate(cells, get$1(cells)[j] = $$value), (j) => get$1(cells)?.[j], () => [get$1(j)]);
40199		append$1($$anchor, td);
40200	});
40201
40202	reset(tr_1);
40203	reset(tbody);
40204	reset(table_1);
40205	bind_this(table_1, ($$value) => set(table, $$value), () => get$1(table));
40206
40207	var node_9 = sibling(table_1, 2);
40208
40209	{
40210		let $0 = derived_safe_equal(() => (
40211			deep_read_state(i18n()),
40212			untrack(() => i18n()("dataframe.drop_to_upload"))
40213		));
40214
40215		Upload(node_9, {
40216			get upload() {
40217				return upload();
40218			},
40219
40220			get stream_handler() {
40221				return stream_handler();
40222			},
40223			flex: false,
40224			center: false,
40225			boundedheight: false,
40226			disable_click: true,
40227			get root() {
40228				return root();
40229			},
40230
40231			get aria_label() {
40232				return get$1($0);
40233			},
40234
40235			get dragging() {
40236				return get$1(dragging);
40237			},
40238
40239			set dragging($$value) {
40240				set(dragging, $$value);
40241			},
40242
40243			$$events: {
40244				load: ({ detail }) => handle_file_upload(
40245					detail.data,
40246					(head) => {
40247						set(_headers, make_headers(head.map((h) => h ?? ""), col_count(), get$1(els), make_id));
40248
40249						return get$1(_headers);
40250					},
40251					(vals) => {
40252						values(vals);
40253					}
40254				)
40255			},
40256
40257			children: ($$anchor, $$slotProps) => {
40258				var div_5 = root_9();
40259				var node_10 = child(div_5);
40260
40261				{
40262					let $0 = derived_safe_equal(() => get$1(active_cell_menu) !== null || get$1(active_header_menu) !== null);
40263
40264					VirtualTable(node_10, {
40265						get max_height() {
40266							return max_height();
40267						},
40268
40269						get selected() {
40270							return get$1(selected_index);
40271						},
40272
40273						get disable_scroll() {
40274							return get$1($0);
40275						},
40276
40277						get label() {
40278							return label();
40279						},
40280
40281						get items() {
40282							return get$1(search_results);
40283						},
40284
40285						set items($$value) {
40286							set(search_results, $$value);
40287						},
40288
40289						get actual_height() {
40290							return get$1(table_height);
40291						},
40292
40293						set actual_height($$value) {
40294							set(table_height, $$value);
40295						},
40296
40297						get table_scrollbar_width() {
40298							return get$1(scrollbar_width);
40299						},
40300
40301						set table_scrollbar_width($$value) {
40302							set(scrollbar_width, $$value);
40303						},
40304
40305						get viewport() {
40306							return get$1(viewport);
40307						},
40308
40309						set viewport($$value) {
40310							set(viewport, $$value);
40311						},
40312
40313						get show_scroll_button() {
40314							return get$1(show_scroll_button);
40315						},
40316
40317						set show_scroll_button($$value) {
40318							set(show_scroll_button, $$value);
40319						},
40320						$$events: { scroll_top: (_) => {} },
40321						$$slots: {
40322							thead: ($$anchor, $$slotProps) => {
40323								var tr_2 = root_10();
40324								var node_11 = child(tr_2);
40325
40326								{
40327									var consequent_5 = ($$anchor) => {
40328										RowNumber($$anchor, { is_header: true });
40329									};
40330
40331									if_block(node_11, ($$render) => {
40332										if (show_row_numbers()) $$render(consequent_5);
40333									});
40334								}
40335
40336								var node_12 = sibling(node_11);
40337
40338								each(node_12, 3, () => get$1(_headers), ({ value, id }) => id, ($$anchor, $$item, i) => {
40339									let id = () => get$1($$item).id;
40340
40341									{
40342										let $0 = derived_safe_equal(() => (
40343											deep_read_state(static_columns()),
40344											deep_read_state(get$1(i)),
40345											untrack(() => static_columns().includes(get$1(i)))
40346										));
40347
40348										let $1 = derived_safe_equal(() => (
40349											deep_read_state(datatype()),
40350											deep_read_state(get$1(i)),
40351											untrack(() => Array.isArray(datatype()) ? datatype()[get$1(i)] : datatype())
40352										));
40353
40354										TableHeader($$anchor, {
40355											get i() {
40356												return get$1(i);
40357											},
40358
40359											get actual_pinned_columns() {
40360												return get$1(actual_pinned_columns);
40361											},
40362
40363											get header_edit() {
40364												return get$1(header_edit);
40365											},
40366
40367											get selected_header() {
40368												return get$1(selected_header);
40369											},
40370
40371											get headers() {
40372												return headers();
40373											},
40374											get_cell_width,
40375											handle_header_click,
40376											toggle_header_menu,
40377											end_header_edit,
40378											get sort_columns() {
40379												return (
40380													$df_state(),
40381													untrack(() => $df_state().sort_state.sort_columns)
40382												);
40383											},
40384
40385											get filter_columns() {
40386												return (
40387													$df_state(),
40388													untrack(() => $df_state().filter_state.filter_columns)
40389												);
40390											},
40391
40392											get latex_delimiters() {
40393												return latex_delimiters();
40394											},
40395
40396											get line_breaks() {
40397												return line_breaks();
40398											},
40399
40400											get max_chars() {
40401												return max_chars();
40402											},
40403
40404											get editable() {
40405												return editable();
40406											},
40407
40408											get is_static() {
40409												return get$1($0);
40410											},
40411
40412											get i18n() {
40413												return i18n();
40414											},
40415
40416											get col_count() {
40417												return col_count();
40418											},
40419
40420											get datatype() {
40421												return get$1($1);
40422											},
40423
40424											get data() {
40425												return get$1(data);
40426											},
40427											on_select_all: handle_select_all,
40428											get value() {
40429												return get$1(_headers)[get$1(i)].value;
40430											},
40431
40432											set value($$value) {
40433												mutate(_headers, get$1(_headers)[get$1(i)].value = $$value);
40434											},
40435
40436											get el() {
40437												return get$1(els)[id()].input;
40438											},
40439
40440											set el($$value) {
40441												mutate(els, get$1(els)[id()].input = $$value);
40442											},
40443											$$legacy: true
40444										});
40445									}
40446								});
40447
40448								reset(tr_2);
40449								append$1($$anchor, tr_2);
40450							},
40451
40452							tbody: ($$anchor, $$slotProps) => {
40453								var tr_3 = root_13();
40454								const item = derived_safe_equal(() => $$slotProps.item);
40455								const index = derived_safe_equal(() => $$slotProps.index);
40456								let classes_1;
40457								var node_13 = child(tr_3);
40458
40459								{
40460									var consequent_6 = ($$anchor) => {
40461										RowNumber($$anchor, {
40462											get index() {
40463												return get$1(index);
40464											}
40465										});
40466									};
40467
40468									if_block(node_13, ($$render) => {
40469										if (show_row_numbers()) $$render(consequent_6);
40470									});
40471								}
40472
40473								var node_14 = sibling(node_13);
40474
40475								each(node_14, 3, () => get$1(item), ({ value, id }) => id, ($$anchor, $$item, j) => {
40476									let id = () => get$1($$item).id;
40477
40478									{
40479										let $0 = derived_safe_equal(() => (
40480											deep_read_state(get$1(index)),
40481											deep_read_state(get$1(j)),
40482											untrack(() => get_cell_display_value(get$1(index), get$1(j)))
40483										));
40484
40485										let $1 = derived_safe_equal(() => (
40486											$df_state(),
40487											get$1(filtered_to_original_map),
40488											deep_read_state(get$1(index)),
40489											untrack(() => $df_state().current_search_query !== undefined && get$1(filtered_to_original_map)[get$1(index)] !== undefined
40490												? get$1(filtered_to_original_map)[get$1(index)]
40491												: get$1(index))
40492										));
40493
40494										let $2 = derived_safe_equal(() => (
40495											deep_read_state(datatype()),
40496											deep_read_state(get$1(j)),
40497											untrack(() => Array.isArray(datatype()) ? datatype()[get$1(j)] : datatype())
40498										));
40499
40500										let $3 = derived_safe_equal(() => (
40501											deep_read_state(static_columns()),
40502											deep_read_state(get$1(j)),
40503											untrack(() => static_columns().includes(get$1(j)))
40504										));
40505
40506										TableCell($$anchor, {
40507											get display_value() {
40508												return get$1($0);
40509											},
40510
40511											get index() {
40512												return get$1($1);
40513											},
40514
40515											get j() {
40516												return get$1(j);
40517											},
40518
40519											get actual_pinned_columns() {
40520												return get$1(actual_pinned_columns);
40521											},
40522											get_cell_width,
40523											handle_cell_click: (e, r, c) => get$1(handle_mouse_down)(e, r, c),
40524											handle_blur,
40525											get toggle_cell_menu() {
40526												return (untrack(() => df_actions.toggle_cell_menu));
40527											},
40528
40529											get is_cell_selected() {
40530												return is_cell_selected;
40531											},
40532
40533											get should_show_cell_menu() {
40534												return should_show_cell_menu;
40535											},
40536
40537											get selected_cells() {
40538												return get$1(selected_cells);
40539											},
40540
40541											get copy_flash() {
40542												return get$1(copy_flash);
40543											},
40544
40545											get active_cell_menu() {
40546												return get$1(active_cell_menu);
40547											},
40548
40549											get styling() {
40550												return (
40551													get$1(search_results),
40552													deep_read_state(get$1(index)),
40553													deep_read_state(get$1(j)),
40554													untrack(() => get$1(search_results)[get$1(index)][get$1(j)].styling)
40555												);
40556											},
40557
40558											get latex_delimiters() {
40559												return latex_delimiters();
40560											},
40561
40562											get line_breaks() {
40563												return line_breaks();
40564											},
40565
40566											get datatype() {
40567												return get$1($2);
40568											},
40569
40570											get editing() {
40571												return get$1(editing);
40572											},
40573
40574											get max_chars() {
40575												return max_chars();
40576											},
40577
40578											get editable() {
40579												return editable();
40580											},
40581
40582											get is_static() {
40583												return get$1($3);
40584											},
40585
40586											get i18n() {
40587												return i18n();
40588											},
40589
40590											get components() {
40591												return components();
40592											},
40593
40594											get handle_select_column() {
40595												return (untrack(() => df_actions.handle_select_column));
40596											},
40597
40598											get handle_select_row() {
40599												return (untrack(() => df_actions.handle_select_row));
40600											},
40601
40602											get is_dragging() {
40603												return get$1(is_dragging);
40604											},
40605
40606											get wrap() {
40607												return wrap();
40608											},
40609
40610											get value() {
40611												return get$1(search_results)[get$1(index)][get$1(j)].value;
40612											},
40613
40614											set value($$value) {
40615												mutate(search_results, get$1(search_results)[get$1(index)][get$1(j)].value = $$value);
40616											},
40617
40618											get el() {
40619												return get$1(els)[id()];
40620											},
40621
40622											set el($$value) {
40623												mutate(els, get$1(els)[id()] = $$value);
40624											},
40625											$$legacy: true
40626										});
40627									}
40628								});
40629
40630								reset(tr_3);
40631								template_effect(() => classes_1 = set_class(tr_3, 1, 'svelte-2balj6', null, classes_1, { 'row-odd': get$1(index) % 2 === 0 }));
40632								append$1($$anchor, tr_3);
40633							}
40634						},
40635						$$legacy: true
40636					});
40637				}
40638
40639				reset(div_5);
40640				append$1($$anchor, div_5);
40641			},
40642			$$slots: { default: true },
40643			$$legacy: true
40644		});
40645	}
40646
40647	var node_15 = sibling(node_9, 2);
40648
40649	{
40650		var consequent_7 = ($$anchor) => {
40651			var button = root_16();
40652
40653			event('click', button, scroll_to_top);
40654			append$1($$anchor, button);
40655		};
40656
40657		if_block(node_15, ($$render) => {
40658			if (get$1(show_scroll_button)) $$render(consequent_7);
40659		});
40660	}
40661
40662	reset(div_3);
40663	bind_this(div_3, ($$value) => set(parent, $$value), () => get$1(parent));
40664	reset(div);
40665
40666	var node_16 = sibling(div, 2);
40667
40668	{
40669		var consequent_8 = ($$anchor) => {
40670			EmptyRowButton($$anchor, { on_click: () => add_row() });
40671		};
40672
40673		if_block(node_16, ($$render) => {
40674			if ((
40675				get$1(data),
40676				deep_read_state(editable()),
40677				deep_read_state(row_count()),
40678				untrack(() => get$1(data).length === 0 && editable() && row_count()[1] === "dynamic")
40679			)) $$render(consequent_8);
40680		});
40681	}
40682
40683	var node_17 = sibling(node_16, 2);
40684
40685	{
40686		var consequent_9 = ($$anchor) => {
40687			{
40688				let $0 = derived_safe_equal(() => (
40689					get$1(active_cell_menu),
40690					get$1(active_header_menu),
40691					untrack(() => get$1(active_cell_menu)?.x ?? get$1(active_header_menu)?.x ?? 0)
40692				));
40693
40694				let $1 = derived_safe_equal(() => (
40695					get$1(active_cell_menu),
40696					get$1(active_header_menu),
40697					untrack(() => get$1(active_cell_menu)?.y ?? get$1(active_header_menu)?.y ?? 0)
40698				));
40699
40700				let $2 = derived_safe_equal(() => (
40701					get$1(active_header_menu),
40702					get$1(active_cell_menu),
40703					untrack(() => get$1(active_header_menu) ? -1 : get$1(active_cell_menu)?.row ?? 0)
40704				));
40705
40706				let $3 = derived_safe_equal(() => (
40707					get$1(active_header_menu),
40708					get$1(data),
40709					deep_read_state(editable()),
40710					untrack(() => !get$1(active_header_menu) && get$1(data).length > 1 && editable())
40711				));
40712
40713				let $4 = derived_safe_equal(() => (
40714					get$1(data),
40715					deep_read_state(editable()),
40716					untrack(() => get$1(data).length > 0 && get$1(data)[0]?.length > 1 && editable())
40717				));
40718
40719				let $5 = derived_safe_equal(() => get$1(active_header_menu)
40720					? (direction) => {
40721						if (get$1(active_header_menu)) {
40722							handle_sort(get$1(active_header_menu).col, direction);
40723							df_actions.set_active_header_menu(null);
40724						}
40725					}
40726					: undefined);
40727
40728				let $6 = derived_safe_equal(() => get$1(active_header_menu)
40729					? () => {
40730						clear_sort();
40731						df_actions.set_active_header_menu(null);
40732					}
40733					: undefined);
40734
40735				let $7 = derived_safe_equal(() => (
40736					get$1(active_header_menu),
40737					$df_state(),
40738					untrack(() => get$1(active_header_menu)
40739						? $df_state().sort_state.sort_columns.find((item) => item.col === (get$1(active_header_menu)?.col ?? -1))?.direction ?? null
40740						: null)
40741				));
40742
40743				let $8 = derived_safe_equal(() => (
40744					get$1(active_header_menu),
40745					$df_state(),
40746					untrack(() => get$1(active_header_menu)
40747						? $df_state().sort_state.sort_columns.findIndex((item) => item.col === (get$1(active_header_menu)?.col ?? -1)) + 1 || null
40748						: null)
40749				));
40750
40751				let $9 = derived_safe_equal(() => get$1(active_header_menu)
40752					? (datatype, filter, value) => {
40753						if (get$1(active_header_menu)) {
40754							handle_filter(get$1(active_header_menu).col, datatype, filter, value);
40755							df_actions.set_active_header_menu(null);
40756						}
40757					}
40758					: undefined);
40759
40760				let $10 = derived_safe_equal(() => get$1(active_header_menu)
40761					? () => {
40762						clear_filter();
40763						df_actions.set_active_header_menu(null);
40764					}
40765					: undefined);
40766
40767				let $11 = derived_safe_equal(() => (
40768					get$1(active_header_menu),
40769					$df_state(),
40770					untrack(() => get$1(active_header_menu)
40771						? $df_state().filter_state.filter_columns.some((c) => c.col === (get$1(active_header_menu)?.col ?? -1))
40772						: null)
40773				));
40774
40775				CellMenu($$anchor, {
40776					get x() {
40777						return get$1($0);
40778					},
40779
40780					get y() {
40781						return get$1($1);
40782					},
40783
40784					get row() {
40785						return get$1($2);
40786					},
40787
40788					get col_count() {
40789						return col_count();
40790					},
40791
40792					get row_count() {
40793						return row_count();
40794					},
40795					on_add_row_above: () => add_row_at(get$1(active_cell_menu)?.row ?? -1, "above"),
40796					on_add_row_below: () => add_row_at(get$1(active_cell_menu)?.row ?? -1, "below"),
40797					on_add_column_left: () => add_col_at(get$1(active_cell_menu)?.col ?? get$1(active_header_menu)?.col ?? -1, "left"),
40798					on_add_column_right: () => add_col_at(get$1(active_cell_menu)?.col ?? get$1(active_header_menu)?.col ?? -1, "right"),
40799					on_delete_row: () => delete_row_at(get$1(active_cell_menu)?.row ?? -1),
40800					on_delete_col: () => delete_col_at(get$1(active_cell_menu)?.col ?? get$1(active_header_menu)?.col ?? -1),
40801					get editable() {
40802						return editable();
40803					},
40804
40805					get can_delete_rows() {
40806						return get$1($3);
40807					},
40808
40809					get can_delete_cols() {
40810						return get$1($4);
40811					},
40812
40813					get i18n() {
40814						return i18n();
40815					},
40816
40817					get on_sort() {
40818						return get$1($5);
40819					},
40820
40821					get on_clear_sort() {
40822						return get$1($6);
40823					},
40824
40825					get sort_direction() {
40826						return get$1($7);
40827					},
40828
40829					get sort_priority() {
40830						return get$1($8);
40831					},
40832
40833					get on_filter() {
40834						return get$1($9);
40835					},
40836
40837					get on_clear_filter() {
40838						return get$1($10);
40839					},
40840
40841					get filter_active() {
40842						return get$1($11);
40843					}
40844				});
40845			}
40846		};
40847
40848		if_block(node_17, ($$render) => {
40849			if (get$1(active_cell_menu) || get$1(active_header_menu)) $$render(consequent_9);
40850		});
40851	}
40852
40853	template_effect(() => classes = set_class(div_3, 1, 'table-wrap svelte-2balj6', null, classes, {
40854		dragging: get$1(is_dragging),
40855		'no-wrap': !wrap(),
40856		'menu-open': get$1(active_cell_menu) || get$1(active_header_menu)
40857	}));
40858
40859	event('keydown', div_3, (e) =>
40859 handle_keydown(e, get$1(df_ctx)));
40860
40861	event('mousemove', div_3, function (...$$args) {
40862		get$1(handle_mouse_move)?.apply(this, $$args);
40863	});
40864
40865	event('mouseup', div_3, function (...$$args) {
40866		get$1(handle_mouse_up)?.apply(this, $$args);
40867	});
40868
40869	event('mouseleave', div_3, function (...$$args) {
40870		get$1(handle_mouse_up)?.apply(this, $$args);
40871	});
40872
40873	append$1($$anchor, fragment);
40874	bind_prop($$props, 'reset_sort_state', reset_sort_state);
40875
40876	var $$pop = pop($$exports);
40877
40878	$$cleanup();
40879
40880	return $$pop;
40881}
40882
40883var root = from_html(`<div></div>`);
40884
40885function Index($$anchor, $$props) {
40886	push($$props, true);
40887
40888	let prev_data = null;
40889	let changed = false;
40890
40891	class DataframeGradio extends Gradio {
40892		async set_data(data) {
40893			if (data.value) {
40894				changed = true;
40895			}
40896
40897			super.set_data(data);
40898
40899			if (data.value && dequal$2(data.value, JSON.parse(prev_data)) === false) {
40900				// this.dispatch("change");
40901				prev_data = JSON.stringify(data.value);
40902			}
40903		}
40904	}
40905
40906	let props = rest_props($$props, ['$$slots', '$$events', '$$legacy']);
40907	let gradio = new DataframeGradio(props);
40908	let el;
40909	let Component = null;
40910
40911	onMount$1(() => {
40912		Component = new Index3({
40913			target: el,
40914			props: {
40915				elem_id: gradio.shared.elem_id,
40916				elem_classes: gradio.shared.elem_classes,
40917				visible: gradio.shared.visible,
40918				value: gradio.props.value,
40919				col_count: gradio.props.col_count,
40920				row_count: gradio.props.row_count,
40921				label: gradio.shared.label,
40922				show_label: gradio.shared.show_label,
40923				wrap: gradio.props.wrap,
40924				datatype: gradio.props.datatype,
40925				scale: gradio.shared.scale,
40926				min_width: gradio.shared.min_width,
40927				root: gradio.shared.root,
40928				line_breaks: gradio.props.line_breaks,
40929				column_widths: gradio.props.column_widths,
40930				gradio: compat_gradio,
40931				latex_delimiters: gradio.props.latex_delimiters,
40932				max_height: gradio.props.max_height,
40933				loading_status: gradio.shared.loading_status,
40934				interactive: gradio.shared.interactive,
40935				buttons: gradio.props.buttons,
40936				max_chars: gradio.props.max_chars,
40937				show_row_numbers: gradio.props.show_row_numbers,
40938				show_search: gradio.props.show_search,
40939				pinned_columns: gradio.props.pinned_columns,
40940				static_columns: gradio.props.static_columns,
40941				fullscreen: gradio.props.fullscreen,
40942				show_copy_button: gradio.props.buttons && gradio.props.buttons.includes("copy"),
40943				show_fullscreen_button: gradio.props.buttons && gradio.props.buttons.includes("fullscreen")
40944			}
40945		});
40946	});
40947
40948	const compat_gradio = {
40949		i18n: gradio.i18n,
40950		client: gradio.shared.client,
40951		dispatch(name, detail) {
40952			if (name === "input" && changed) {
40953				changed = false;
40954
40955				return;
40956			}
40957
40958			gradio.dispatch(name, detail);
40959		},
40960		autoscroll: gradio.shared.autoscroll
40961	};
40962
40963	user_effect(() => {
40964		if (Component) {
40965			Component.$set({
40966				elem_id: gradio.shared.elem_id,
40967				elem_classes: gradio.shared.elem_classes,
40968				visible: gradio.shared.visible,
40969				value: gradio.props.value,
40970				col_count: gradio.props.col_count,
40971				row_count: gradio.props.row_count,
40972				label: gradio.shared.label,
40973				show_label: gradio.shared.show_label,
40974				wrap: gradio.props.wrap,
40975				datatype: gradio.props.datatype,
40976				scale: gradio.shared.scale,
40977				min_width: gradio.shared.min_width,
40978				root: gradio.shared.root,
40979				line_breaks: gradio.props.line_breaks,
40980				column_widths: gradio.props.column_widths,
40981				gradio: compat_gradio,
40982				latex_delimiters: gradio.props.latex_delimiters,
40983				max_height: gradio.props.max_height,
40984				loading_status: gradio.shared.loading_status,
40985				interactive: gradio.shared.interactive,
40986				buttons: gradio.props.buttons,
40987				max_chars: gradio.props.max_chars,
40988				show_row_numbers: gradio.props.show_row_numbers,
40989				show_search: gradio.props.show_search,
40990				pinned_columns: gradio.props.pinned_columns,
40991				static_columns: gradio.props.static_columns,
40992				fullscreen: gradio.props.fullscreen
40993			});
40994		}
40995	});
40996
40997	var div = root();
40998
40999	bind_this(div, ($$value) => el = $$value, () => el);
41000	append$1($$anchor, div);
41001	pop();
41002}
41003
41004const Index$1 = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
41005  __proto__: null,
41006  BaseDataFrame: Table,
41007  BaseExample: Example,
41008  default: Index
41009}, Symbol.toStringTag, { value: 'Module' }));
41010
41011export { Index$1 as I, commonjsGlobal as c, getDefaultExportFromCjs as g };
41012//# sourceMappingURL=Index-BOG-LPoW.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.