Greasy Fork is available in English.

LeetCode Toolkit

Copy problem as Markdown, Download as Jupyter Notebook, Format on Save, Unlock IntelliSense, Find & Save Editorial

Verze ze dne 22. 04. 2025. Zobrazit nejnovější verzi.

  1. // ==UserScript==
  2. // @name LeetCode Toolkit
  3. // @name:zh-CN LeetCode工具箱
  4. // @namespace https://github.com/eclipher/leetcode-toolkit
  5. // @version 2.2.1
  6. // @author eclipher
  7. // @description Copy problem as Markdown, Download as Jupyter Notebook, Format on Save, Unlock IntelliSense, Find & Save Editorial
  8. // @description:zh-CN 复制题目为 Markdown | 下载为 Jupyter Notebook | 保存时自动格式化 | 免费自动补全
  9. // @license MIT
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=leetcode.com
  11. // @homepage https://github.com/eclipher/leetcode-toolkit
  12. // @match *://leetcode.com/problems/*
  13. // @match *://leetcode.cn/problems/*
  14. // @exclude *://leetcode.com/problems/*/post-solution/*
  15. // @exclude *://leetcode.cn/problems/*/post-solution/*
  16. // @resource editorials https://raw.githubusercontent.com/akhilkammila/leetcode-screenshotter/refs/heads/main/ReadMe.md
  17. // @grant GM_addStyle
  18. // @grant GM_getResourceText
  19. // @grant GM_registerMenuCommand
  20. // @grant unsafeWindow
  21. // ==/UserScript==
  22.  
  23. (t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const a=document.createElement("style");a.textContent=t,document.head.append(a)})(' :where(html[dir=ltr]),:where([data-sonner-toaster][dir=ltr]){--toast-icon-margin-start: -3px;--toast-icon-margin-end: 4px;--toast-svg-margin-start: -1px;--toast-svg-margin-end: 0px;--toast-button-margin-start: auto;--toast-button-margin-end: 0;--toast-close-button-start: 0;--toast-close-button-end: unset;--toast-close-button-transform: translate(-35%, -35%)}:where(html[dir=rtl]),:where([data-sonner-toaster][dir=rtl]){--toast-icon-margin-start: 4px;--toast-icon-margin-end: -3px;--toast-svg-margin-start: 0px;--toast-svg-margin-end: -1px;--toast-button-margin-start: 0;--toast-button-margin-end: auto;--toast-close-button-start: unset;--toast-close-button-end: 0;--toast-close-button-transform: translate(35%, -35%)}:where([data-sonner-toaster]){position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1: hsl(0, 0%, 99%);--gray2: hsl(0, 0%, 97.3%);--gray3: hsl(0, 0%, 95.1%);--gray4: hsl(0, 0%, 93%);--gray5: hsl(0, 0%, 90.9%);--gray6: hsl(0, 0%, 88.7%);--gray7: hsl(0, 0%, 85.8%);--gray8: hsl(0, 0%, 78%);--gray9: hsl(0, 0%, 56.1%);--gray10: hsl(0, 0%, 52.3%);--gray11: hsl(0, 0%, 43.5%);--gray12: hsl(0, 0%, 9%);--border-radius: 8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:none;z-index:999999999}:where([data-sonner-toaster][data-x-position=right]){right:max(var(--offset),env(safe-area-inset-right))}:where([data-sonner-toaster][data-x-position=left]){left:max(var(--offset),env(safe-area-inset-left))}:where([data-sonner-toaster][data-x-position=center]){left:50%;transform:translate(-50%)}:where([data-sonner-toaster][data-y-position=top]){top:max(var(--offset),env(safe-area-inset-top))}:where([data-sonner-toaster][data-y-position=bottom]){bottom:max(var(--offset),env(safe-area-inset-bottom))}:where([data-sonner-toast]){--y: translateY(100%);--lift-amount: calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);filter:blur(0);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:none;overflow-wrap:anywhere}:where([data-sonner-toast][data-styled=true]){padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px #0000001a;width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}:where([data-sonner-toast]:focus-visible){box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast][data-y-position=top]){top:0;--y: translateY(-100%);--lift: 1;--lift-amount: calc(1 * var(--gap))}:where([data-sonner-toast][data-y-position=bottom]){bottom:0;--y: translateY(100%);--lift: -1;--lift-amount: calc(var(--lift) * var(--gap))}:where([data-sonner-toast]) :where([data-description]){font-weight:400;line-height:1.4;color:inherit}:where([data-sonner-toast]) :where([data-title]){font-weight:500;line-height:1.5;color:inherit}:where([data-sonner-toast]) :where([data-icon]){display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}:where([data-sonner-toast][data-promise=true]) :where([data-icon])>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}:where([data-sonner-toast]) :where([data-icon])>*{flex-shrink:0}:where([data-sonner-toast]) :where([data-icon]) svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}:where([data-sonner-toast]) :where([data-content]){display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;cursor:pointer;outline:none;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}:where([data-sonner-toast]) :where([data-button]):focus-visible{box-shadow:0 0 0 2px #0006}:where([data-sonner-toast]) :where([data-button]):first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}:where([data-sonner-toast]) :where([data-cancel]){color:var(--normal-text);background:#00000014}:where([data-sonner-toast][data-theme=dark]) :where([data-cancel]){background:#ffffff4d}:where([data-sonner-toast]) :where([data-close-button]){position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;background:var(--gray1);color:var(--gray12);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}:where([data-sonner-toast]) :where([data-close-button]):focus-visible{box-shadow:0 4px 12px #0000001a,0 0 0 2px #0003}:where([data-sonner-toast]) :where([data-disabled=true]){cursor:not-allowed}:where([data-sonner-toast]):hover :where([data-close-button]):hover{background:var(--gray2);border-color:var(--gray5)}:where([data-sonner-toast][data-swiping=true]):before{content:"";position:absolute;left:0;right:0;height:100%;z-index:-1}:where([data-sonner-toast][data-y-position=top][data-swiping=true]):before{bottom:50%;transform:scaleY(3) translateY(50%)}:where([data-sonner-toast][data-y-position=bottom][data-swiping=true]):before{top:50%;transform:scaleY(3) translateY(-50%)}:where([data-sonner-toast][data-swiping=false][data-removed=true]):before{content:"";position:absolute;top:0;right:0;bottom:0;left:0;transform:scaleY(2)}:where([data-sonner-toast]):after{content:"";position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}:where([data-sonner-toast][data-mounted=true]){--y: translateY(0);opacity:1}:where([data-sonner-toast][data-expanded=false][data-front=false]){--scale: var(--toasts-before) * .05 + 1;--y: translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}:where([data-sonner-toast])>*{transition:opacity .4s}:where([data-sonner-toast][data-expanded=false][data-front=false][data-styled=true])>*{opacity:0}:where([data-sonner-toast][data-visible=false]){opacity:0;pointer-events:none}:where([data-sonner-toast][data-mounted=true][data-expanded=true]){--y: translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}:where([data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]){--y: translateY(calc(var(--lift) * -100%));opacity:0}:where([data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]){--y: translateY( calc(var(--lift) * var(--offset) + var(--lift) * -100%) );opacity:0}:where([data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]){--y: translateY(40%);opacity:0;transition:transform .5s,opacity .2s}:where([data-sonner-toast][data-removed=true][data-front=false]):before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount, 0px));transition:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation:swipe-out .2s ease-out forwards}@keyframes swipe-out{0%{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount)));opacity:1}to{transform:translateY(calc(var(--lift) * var(--offset) + var(--swipe-amount) + var(--lift) * -100%));opacity:0}}@media (max-width: 600px){[data-sonner-toaster]{position:fixed;--mobile-offset: 16px;right:var(--mobile-offset);left:var(--mobile-offset);width:100%}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset)}[data-sonner-toaster][data-y-position=bottom]{bottom:20px}[data-sonner-toaster][data-y-position=top]{top:20px}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset);right:var(--mobile-offset);transform:none}}[data-sonner-toaster][data-theme=light]{--normal-bg: #fff;--normal-border: var(--gray4);--normal-text: var(--gray12);--success-bg: hsl(143, 85%, 96%);--success-border: hsl(145, 92%, 91%);--success-text: hsl(140, 100%, 27%);--info-bg: hsl(208, 100%, 97%);--info-border: hsl(221, 91%, 91%);--info-text: hsl(210, 92%, 45%);--warning-bg: hsl(49, 100%, 97%);--warning-border: hsl(49, 91%, 91%);--warning-text: hsl(31, 92%, 45%);--error-bg: hsl(359, 100%, 97%);--error-border: hsl(359, 100%, 94%);--error-text: hsl(360, 100%, 45%)}[data-sonner-toaster][data-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1)}[data-sonner-toaster][data-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg: #fff;--normal-border: var(--gray3);--normal-text: var(--gray12)}[data-sonner-toaster][data-theme=dark]{--normal-bg: #000;--normal-border: hsl(0, 0%, 20%);--normal-text: var(--gray1);--success-bg: hsl(150, 100%, 6%);--success-border: hsl(147, 100%, 12%);--success-text: hsl(150, 86%, 65%);--info-bg: hsl(215, 100%, 6%);--info-border: hsl(223, 100%, 12%);--info-text: hsl(216, 87%, 65%);--warning-bg: hsl(64, 100%, 6%);--warning-border: hsl(60, 100%, 12%);--warning-text: hsl(46, 87%, 65%);--error-bg: hsl(358, 76%, 10%);--error-border: hsl(357, 89%, 16%);--error-text: hsl(358, 100%, 81%)}[data-rich-colors=true] [data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-theme=dark] [data-sonner-toast][data-type=default] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-rich-colors=true] [data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true] [data-sonner-toast][data-type=info],[data-rich-colors=true] [data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true] [data-sonner-toast][data-type=warning],[data-rich-colors=true] [data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true] [data-sonner-toast][data-type=error],[data-rich-colors=true] [data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size: 16px;height:var(--size);width:var(--size);position:absolute;top:0;right:0;bottom:0;left:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:nth-child(1){animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}to{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}to{opacity:.15}}@media (prefers-reduced-motion){[data-sonner-toast],[data-sonner-toast]>*,.sonner-loading-bar{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)} ');
  24.  
  25. (async function () {
  26. 'use strict';
  27.  
  28. var __defProp = Object.defineProperty;
  29. var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
  30. var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
  31. var _a, _b;
  32. const DEV = false;
  33. var is_array = Array.isArray;
  34. var index_of = Array.prototype.indexOf;
  35. var array_from = Array.from;
  36. var define_property = Object.defineProperty;
  37. var get_descriptor = Object.getOwnPropertyDescriptor;
  38. var get_descriptors = Object.getOwnPropertyDescriptors;
  39. var object_prototype = Object.prototype;
  40. var array_prototype = Array.prototype;
  41. var get_prototype_of = Object.getPrototypeOf;
  42. var is_extensible = Object.isExtensible;
  43. function is_function(thing) {
  44. return typeof thing === "function";
  45. }
  46. const noop = () => {
  47. };
  48. function run(fn) {
  49. return fn();
  50. }
  51. function run_all(arr) {
  52. for (var i2 = 0; i2 < arr.length; i2++) {
  53. arr[i2]();
  54. }
  55. }
  56. const DERIVED = 1 << 1;
  57. const EFFECT = 1 << 2;
  58. const RENDER_EFFECT = 1 << 3;
  59. const BLOCK_EFFECT = 1 << 4;
  60. const BRANCH_EFFECT = 1 << 5;
  61. const ROOT_EFFECT = 1 << 6;
  62. const BOUNDARY_EFFECT = 1 << 7;
  63. const UNOWNED = 1 << 8;
  64. const DISCONNECTED = 1 << 9;
  65. const CLEAN = 1 << 10;
  66. const DIRTY = 1 << 11;
  67. const MAYBE_DIRTY = 1 << 12;
  68. const INERT = 1 << 13;
  69. const DESTROYED = 1 << 14;
  70. const EFFECT_RAN = 1 << 15;
  71. const EFFECT_TRANSPARENT = 1 << 16;
  72. const LEGACY_DERIVED_PROP = 1 << 17;
  73. const HEAD_EFFECT = 1 << 19;
  74. const EFFECT_HAS_DERIVED = 1 << 20;
  75. const EFFECT_IS_UPDATING = 1 << 21;
  76. const STATE_SYMBOL = Symbol("$state");
  77. const LEGACY_PROPS = Symbol("legacy props");
  78. const LOADING_ATTR_SYMBOL = Symbol("");
  79. function equals(value) {
  80. return value === this.v;
  81. }
  82. function safe_not_equal(a2, b) {
  83. return a2 != a2 ? b == b : a2 !== b || a2 !== null && typeof a2 === "object" || typeof a2 === "function";
  84. }
  85. function safe_equals(value) {
  86. return !safe_not_equal(value, this.v);
  87. }
  88. function effect_in_teardown(rune) {
  89. {
  90. throw new Error(`https://svelte.dev/e/effect_in_teardown`);
  91. }
  92. }
  93. function effect_in_unowned_derived() {
  94. {
  95. throw new Error(`https://svelte.dev/e/effect_in_unowned_derived`);
  96. }
  97. }
  98. function effect_orphan(rune) {
  99. {
  100. throw new Error(`https://svelte.dev/e/effect_orphan`);
  101. }
  102. }
  103. function effect_update_depth_exceeded() {
  104. {
  105. throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
  106. }
  107. }
  108. function props_invalid_value(key) {
  109. {
  110. throw new Error(`https://svelte.dev/e/props_invalid_value`);
  111. }
  112. }
  113. function state_descriptors_fixed() {
  114. {
  115. throw new Error(`https://svelte.dev/e/state_descriptors_fixed`);
  116. }
  117. }
  118. function state_prototype_fixed() {
  119. {
  120. throw new Error(`https://svelte.dev/e/state_prototype_fixed`);
  121. }
  122. }
  123. function state_unsafe_mutation() {
  124. {
  125. throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
  126. }
  127. }
  128. let legacy_mode_flag = false;
  129. let tracing_mode_flag = false;
  130. function enable_legacy_mode_flag() {
  131. legacy_mode_flag = true;
  132. }
  133. const EACH_ITEM_REACTIVE = 1;
  134. const EACH_INDEX_REACTIVE = 1 << 1;
  135. const EACH_IS_CONTROLLED = 1 << 2;
  136. const EACH_IS_ANIMATED = 1 << 3;
  137. const EACH_ITEM_IMMUTABLE = 1 << 4;
  138. const PROPS_IS_IMMUTABLE = 1;
  139. const PROPS_IS_RUNES = 1 << 1;
  140. const PROPS_IS_UPDATED = 1 << 2;
  141. const PROPS_IS_BINDABLE = 1 << 3;
  142. const PROPS_IS_LAZY_INITIAL = 1 << 4;
  143. const TEMPLATE_FRAGMENT = 1;
  144. const TEMPLATE_USE_IMPORT_NODE = 1 << 1;
  145. const UNINITIALIZED = Symbol();
  146. const NAMESPACE_HTML = "http://www.w3.org/1999/xhtml";
  147. function lifecycle_outside_component(name) {
  148. {
  149. throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
  150. }
  151. }
  152. let component_context = null;
  153. function set_component_context(context) {
  154. component_context = context;
  155. }
  156. function push(props, runes = false, fn) {
  157. var ctx = component_context = {
  158. p: component_context,
  159. c: null,
  160. d: false,
  161. e: null,
  162. m: false,
  163. s: props,
  164. x: null,
  165. l: null
  166. };
  167. if (legacy_mode_flag && !runes) {
  168. component_context.l = {
  169. s: null,
  170. u: null,
  171. r1: [],
  172. r2: source(false)
  173. };
  174. }
  175. teardown(() => {
  176. ctx.d = true;
  177. });
  178. }
  179. function pop(component2) {
  180. const context_stack_item = component_context;
  181. if (context_stack_item !== null) {
  182. const component_effects = context_stack_item.e;
  183. if (component_effects !== null) {
  184. var previous_effect = active_effect;
  185. var previous_reaction = active_reaction;
  186. context_stack_item.e = null;
  187. try {
  188. for (var i2 = 0; i2 < component_effects.length; i2++) {
  189. var component_effect = component_effects[i2];
  190. set_active_effect(component_effect.effect);
  191. set_active_reaction(component_effect.reaction);
  192. effect(component_effect.fn);
  193. }
  194. } finally {
  195. set_active_effect(previous_effect);
  196. set_active_reaction(previous_reaction);
  197. }
  198. }
  199. component_context = context_stack_item.p;
  200. context_stack_item.m = true;
  201. }
  202. return (
  203. /** @type {T} */
  204. {}
  205. );
  206. }
  207. function is_runes() {
  208. return !legacy_mode_flag || component_context !== null && component_context.l === null;
  209. }
  210. function proxy(value, prev) {
  211. if (typeof value !== "object" || value === null || STATE_SYMBOL in value) {
  212. return value;
  213. }
  214. const prototype = get_prototype_of(value);
  215. if (prototype !== object_prototype && prototype !== array_prototype) {
  216. return value;
  217. }
  218. var sources = /* @__PURE__ */ new Map();
  219. var is_proxied_array = is_array(value);
  220. var version = state$1(0);
  221. var reaction = active_reaction;
  222. var with_parent = (fn) => {
  223. var previous_reaction = active_reaction;
  224. set_active_reaction(reaction);
  225. var result;
  226. {
  227. result = fn();
  228. }
  229. set_active_reaction(previous_reaction);
  230. return result;
  231. };
  232. if (is_proxied_array) {
  233. sources.set("length", state$1(
  234. /** @type {any[]} */
  235. value.length
  236. ));
  237. }
  238. return new Proxy(
  239. /** @type {any} */
  240. value,
  241. {
  242. defineProperty(_, prop2, descriptor) {
  243. if (!("value" in descriptor) || descriptor.configurable === false || descriptor.enumerable === false || descriptor.writable === false) {
  244. state_descriptors_fixed();
  245. }
  246. var s = sources.get(prop2);
  247. if (s === void 0) {
  248. s = with_parent(() => state$1(descriptor.value));
  249. sources.set(prop2, s);
  250. } else {
  251. set(
  252. s,
  253. with_parent(() => proxy(descriptor.value))
  254. );
  255. }
  256. return true;
  257. },
  258. deleteProperty(target, prop2) {
  259. var s = sources.get(prop2);
  260. if (s === void 0) {
  261. if (prop2 in target) {
  262. sources.set(
  263. prop2,
  264. with_parent(() => state$1(UNINITIALIZED))
  265. );
  266. }
  267. } else {
  268. if (is_proxied_array && typeof prop2 === "string") {
  269. var ls = (
  270. /** @type {Source<number>} */
  271. sources.get("length")
  272. );
  273. var n = Number(prop2);
  274. if (Number.isInteger(n) && n < ls.v) {
  275. set(ls, n);
  276. }
  277. }
  278. set(s, UNINITIALIZED);
  279. update_version(version);
  280. }
  281. return true;
  282. },
  283. get(target, prop2, receiver) {
  284. var _a2;
  285. if (prop2 === STATE_SYMBOL) {
  286. return value;
  287. }
  288. var s = sources.get(prop2);
  289. var exists = prop2 in target;
  290. if (s === void 0 && (!exists || ((_a2 = get_descriptor(target, prop2)) == null ? void 0 : _a2.writable))) {
  291. s = with_parent(() => state$1(proxy(exists ? target[prop2] : UNINITIALIZED)));
  292. sources.set(prop2, s);
  293. }
  294. if (s !== void 0) {
  295. var v = get$1(s);
  296. return v === UNINITIALIZED ? void 0 : v;
  297. }
  298. return Reflect.get(target, prop2, receiver);
  299. },
  300. getOwnPropertyDescriptor(target, prop2) {
  301. var descriptor = Reflect.getOwnPropertyDescriptor(target, prop2);
  302. if (descriptor && "value" in descriptor) {
  303. var s = sources.get(prop2);
  304. if (s) descriptor.value = get$1(s);
  305. } else if (descriptor === void 0) {
  306. var source2 = sources.get(prop2);
  307. var value2 = source2 == null ? void 0 : source2.v;
  308. if (source2 !== void 0 && value2 !== UNINITIALIZED) {
  309. return {
  310. enumerable: true,
  311. configurable: true,
  312. value: value2,
  313. writable: true
  314. };
  315. }
  316. }
  317. return descriptor;
  318. },
  319. has(target, prop2) {
  320. var _a2;
  321. if (prop2 === STATE_SYMBOL) {
  322. return true;
  323. }
  324. var s = sources.get(prop2);
  325. var has2 = s !== void 0 && s.v !== UNINITIALIZED || Reflect.has(target, prop2);
  326. if (s !== void 0 || active_effect !== null && (!has2 || ((_a2 = get_descriptor(target, prop2)) == null ? void 0 : _a2.writable))) {
  327. if (s === void 0) {
  328. s = with_parent(() => state$1(has2 ? proxy(target[prop2]) : UNINITIALIZED));
  329. sources.set(prop2, s);
  330. }
  331. var value2 = get$1(s);
  332. if (value2 === UNINITIALIZED) {
  333. return false;
  334. }
  335. }
  336. return has2;
  337. },
  338. set(target, prop2, value2, receiver) {
  339. var _a2;
  340. var s = sources.get(prop2);
  341. var has2 = prop2 in target;
  342. if (is_proxied_array && prop2 === "length") {
  343. for (var i2 = value2; i2 < /** @type {Source<number>} */
  344. s.v; i2 += 1) {
  345. var other_s = sources.get(i2 + "");
  346. if (other_s !== void 0) {
  347. set(other_s, UNINITIALIZED);
  348. } else if (i2 in target) {
  349. other_s = with_parent(() => state$1(UNINITIALIZED));
  350. sources.set(i2 + "", other_s);
  351. }
  352. }
  353. }
  354. if (s === void 0) {
  355. if (!has2 || ((_a2 = get_descriptor(target, prop2)) == null ? void 0 : _a2.writable)) {
  356. s = with_parent(() => state$1(void 0));
  357. set(
  358. s,
  359. with_parent(() => proxy(value2))
  360. );
  361. sources.set(prop2, s);
  362. }
  363. } else {
  364. has2 = s.v !== UNINITIALIZED;
  365. set(
  366. s,
  367. with_parent(() => proxy(value2))
  368. );
  369. }
  370. var descriptor = Reflect.getOwnPropertyDescriptor(target, prop2);
  371. if (descriptor == null ? void 0 : descriptor.set) {
  372. descriptor.set.call(receiver, value2);
  373. }
  374. if (!has2) {
  375. if (is_proxied_array && typeof prop2 === "string") {
  376. var ls = (
  377. /** @type {Source<number>} */
  378. sources.get("length")
  379. );
  380. var n = Number(prop2);
  381. if (Number.isInteger(n) && n >= ls.v) {
  382. set(ls, n + 1);
  383. }
  384. }
  385. update_version(version);
  386. }
  387. return true;
  388. },
  389. ownKeys(target) {
  390. get$1(version);
  391. var own_keys = Reflect.ownKeys(target).filter((key2) => {
  392. var source3 = sources.get(key2);
  393. return source3 === void 0 || source3.v !== UNINITIALIZED;
  394. });
  395. for (var [key, source2] of sources) {
  396. if (source2.v !== UNINITIALIZED && !(key in target)) {
  397. own_keys.push(key);
  398. }
  399. }
  400. return own_keys;
  401. },
  402. setPrototypeOf() {
  403. state_prototype_fixed();
  404. }
  405. }
  406. );
  407. }
  408. function update_version(signal, d = 1) {
  409. set(signal, signal.v + d);
  410. }
  411. const old_values = /* @__PURE__ */ new Map();
  412. function source(v, stack) {
  413. var signal = {
  414. f: 0,
  415. // TODO ideally we could skip this altogether, but it causes type errors
  416. v,
  417. reactions: null,
  418. equals,
  419. rv: 0,
  420. wv: 0
  421. };
  422. return signal;
  423. }
  424. function state$1(v, stack) {
  425. const s = source(v);
  426. push_reaction_value(s);
  427. return s;
  428. }
  429. // @__NO_SIDE_EFFECTS__
  430. function mutable_source(initial_value, immutable = false) {
  431. var _a2;
  432. const s = source(initial_value);
  433. if (!immutable) {
  434. s.equals = safe_equals;
  435. }
  436. if (legacy_mode_flag && component_context !== null && component_context.l !== null) {
  437. ((_a2 = component_context.l).s ?? (_a2.s = [])).push(s);
  438. }
  439. return s;
  440. }
  441. function set(source2, value, should_proxy = false) {
  442. if (active_reaction !== null && !untracking && is_runes() && (active_reaction.f & (DERIVED | BLOCK_EFFECT)) !== 0 && !(reaction_sources == null ? void 0 : reaction_sources.includes(source2))) {
  443. state_unsafe_mutation();
  444. }
  445. let new_value = should_proxy ? proxy(value) : value;
  446. return internal_set(source2, new_value);
  447. }
  448. function internal_set(source2, value) {
  449. if (!source2.equals(value)) {
  450. var old_value = source2.v;
  451. if (is_destroying_effect) {
  452. old_values.set(source2, value);
  453. } else {
  454. old_values.set(source2, old_value);
  455. }
  456. source2.v = value;
  457. source2.wv = increment_write_version();
  458. mark_reactions(source2, DIRTY);
  459. if (is_runes() && active_effect !== null && (active_effect.f & CLEAN) !== 0 && (active_effect.f & (BRANCH_EFFECT | ROOT_EFFECT)) === 0) {
  460. if (untracked_writes === null) {
  461. set_untracked_writes([source2]);
  462. } else {
  463. untracked_writes.push(source2);
  464. }
  465. }
  466. }
  467. return value;
  468. }
  469. function update(source2, d = 1) {
  470. var value = get$1(source2);
  471. var result = d === 1 ? value++ : value--;
  472. set(source2, value);
  473. return result;
  474. }
  475. function mark_reactions(signal, status) {
  476. var reactions = signal.reactions;
  477. if (reactions === null) return;
  478. var runes = is_runes();
  479. var length = reactions.length;
  480. for (var i2 = 0; i2 < length; i2++) {
  481. var reaction = reactions[i2];
  482. var flags = reaction.f;
  483. if ((flags & DIRTY) !== 0) continue;
  484. if (!runes && reaction === active_effect) continue;
  485. set_signal_status(reaction, status);
  486. if ((flags & (CLEAN | UNOWNED)) !== 0) {
  487. if ((flags & DERIVED) !== 0) {
  488. mark_reactions(
  489. /** @type {Derived} */
  490. reaction,
  491. MAYBE_DIRTY
  492. );
  493. } else {
  494. schedule_effect(
  495. /** @type {Effect} */
  496. reaction
  497. );
  498. }
  499. }
  500. }
  501. }
  502. let hydrating = false;
  503. var $window;
  504. var is_firefox;
  505. var first_child_getter;
  506. var next_sibling_getter;
  507. function init_operations() {
  508. if ($window !== void 0) {
  509. return;
  510. }
  511. $window = window;
  512. is_firefox = /Firefox/.test(navigator.userAgent);
  513. var element_prototype = Element.prototype;
  514. var node_prototype = Node.prototype;
  515. var text_prototype = Text.prototype;
  516. first_child_getter = get_descriptor(node_prototype, "firstChild").get;
  517. next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
  518. if (is_extensible(element_prototype)) {
  519. element_prototype.__click = void 0;
  520. element_prototype.__className = void 0;
  521. element_prototype.__attributes = null;
  522. element_prototype.__style = void 0;
  523. element_prototype.__e = void 0;
  524. }
  525. if (is_extensible(text_prototype)) {
  526. text_prototype.__t = void 0;
  527. }
  528. }
  529. function create_text(value = "") {
  530. return document.createTextNode(value);
  531. }
  532. // @__NO_SIDE_EFFECTS__
  533. function get_first_child(node) {
  534. return first_child_getter.call(node);
  535. }
  536. // @__NO_SIDE_EFFECTS__
  537. function get_next_sibling(node) {
  538. return next_sibling_getter.call(node);
  539. }
  540. function child(node, is_text) {
  541. {
  542. return /* @__PURE__ */ get_first_child(node);
  543. }
  544. }
  545. function first_child(fragment, is_text) {
  546. {
  547. var first = (
  548. /** @type {DocumentFragment} */
  549. /* @__PURE__ */ get_first_child(
  550. /** @type {Node} */
  551. fragment
  552. )
  553. );
  554. if (first instanceof Comment && first.data === "") return /* @__PURE__ */ get_next_sibling(first);
  555. return first;
  556. }
  557. }
  558. function sibling(node, count = 1, is_text = false) {
  559. let next_sibling = node;
  560. while (count--) {
  561. next_sibling = /** @type {TemplateNode} */
  562. /* @__PURE__ */ get_next_sibling(next_sibling);
  563. }
  564. {
  565. return next_sibling;
  566. }
  567. }
  568. function clear_text_content(node) {
  569. node.textContent = "";
  570. }
  571. // @__NO_SIDE_EFFECTS__
  572. function derived(fn) {
  573. var flags = DERIVED | DIRTY;
  574. var parent_derived = active_reaction !== null && (active_reaction.f & DERIVED) !== 0 ? (
  575. /** @type {Derived} */
  576. active_reaction
  577. ) : null;
  578. if (active_effect === null || parent_derived !== null && (parent_derived.f & UNOWNED) !== 0) {
  579. flags |= UNOWNED;
  580. } else {
  581. active_effect.f |= EFFECT_HAS_DERIVED;
  582. }
  583. const signal = {
  584. ctx: component_context,
  585. deps: null,
  586. effects: null,
  587. equals,
  588. f: flags,
  589. fn,
  590. reactions: null,
  591. rv: 0,
  592. v: (
  593. /** @type {V} */
  594. null
  595. ),
  596. wv: 0,
  597. parent: parent_derived ?? active_effect
  598. };
  599. return signal;
  600. }
  601. // @__NO_SIDE_EFFECTS__
  602. function derived_safe_equal(fn) {
  603. const signal = /* @__PURE__ */ derived(fn);
  604. signal.equals = safe_equals;
  605. return signal;
  606. }
  607. function destroy_derived_effects(derived2) {
  608. var effects = derived2.effects;
  609. if (effects !== null) {
  610. derived2.effects = null;
  611. for (var i2 = 0; i2 < effects.length; i2 += 1) {
  612. destroy_effect(
  613. /** @type {Effect} */
  614. effects[i2]
  615. );
  616. }
  617. }
  618. }
  619. function get_derived_parent_effect(derived2) {
  620. var parent = derived2.parent;
  621. while (parent !== null) {
  622. if ((parent.f & DERIVED) === 0) {
  623. return (
  624. /** @type {Effect} */
  625. parent
  626. );
  627. }
  628. parent = parent.parent;
  629. }
  630. return null;
  631. }
  632. function execute_derived(derived2) {
  633. var value;
  634. var prev_active_effect = active_effect;
  635. set_active_effect(get_derived_parent_effect(derived2));
  636. {
  637. try {
  638. destroy_derived_effects(derived2);
  639. value = update_reaction(derived2);
  640. } finally {
  641. set_active_effect(prev_active_effect);
  642. }
  643. }
  644. return value;
  645. }
  646. function update_derived(derived2) {
  647. var value = execute_derived(derived2);
  648. var status = (skip_reaction || (derived2.f & UNOWNED) !== 0) && derived2.deps !== null ? MAYBE_DIRTY : CLEAN;
  649. set_signal_status(derived2, status);
  650. if (!derived2.equals(value)) {
  651. derived2.v = value;
  652. derived2.wv = increment_write_version();
  653. }
  654. }
  655. function validate_effect(rune) {
  656. if (active_effect === null && active_reaction === null) {
  657. effect_orphan();
  658. }
  659. if (active_reaction !== null && (active_reaction.f & UNOWNED) !== 0 && active_effect === null) {
  660. effect_in_unowned_derived();
  661. }
  662. if (is_destroying_effect) {
  663. effect_in_teardown();
  664. }
  665. }
  666. function push_effect(effect2, parent_effect) {
  667. var parent_last = parent_effect.last;
  668. if (parent_last === null) {
  669. parent_effect.last = parent_effect.first = effect2;
  670. } else {
  671. parent_last.next = effect2;
  672. effect2.prev = parent_last;
  673. parent_effect.last = effect2;
  674. }
  675. }
  676. function create_effect(type, fn, sync, push2 = true) {
  677. var parent = active_effect;
  678. var effect2 = {
  679. ctx: component_context,
  680. deps: null,
  681. nodes_start: null,
  682. nodes_end: null,
  683. f: type | DIRTY,
  684. first: null,
  685. fn,
  686. last: null,
  687. next: null,
  688. parent,
  689. prev: null,
  690. teardown: null,
  691. transitions: null,
  692. wv: 0
  693. };
  694. if (sync) {
  695. try {
  696. update_effect(effect2);
  697. effect2.f |= EFFECT_RAN;
  698. } catch (e) {
  699. destroy_effect(effect2);
  700. throw e;
  701. }
  702. } else if (fn !== null) {
  703. schedule_effect(effect2);
  704. }
  705. var inert = sync && effect2.deps === null && effect2.first === null && effect2.nodes_start === null && effect2.teardown === null && (effect2.f & (EFFECT_HAS_DERIVED | BOUNDARY_EFFECT)) === 0;
  706. if (!inert && push2) {
  707. if (parent !== null) {
  708. push_effect(effect2, parent);
  709. }
  710. if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0) {
  711. var derived2 = (
  712. /** @type {Derived} */
  713. active_reaction
  714. );
  715. (derived2.effects ?? (derived2.effects = [])).push(effect2);
  716. }
  717. }
  718. return effect2;
  719. }
  720. function teardown(fn) {
  721. const effect2 = create_effect(RENDER_EFFECT, null, false);
  722. set_signal_status(effect2, CLEAN);
  723. effect2.teardown = fn;
  724. return effect2;
  725. }
  726. function user_effect(fn) {
  727. validate_effect();
  728. var defer = active_effect !== null && (active_effect.f & BRANCH_EFFECT) !== 0 && component_context !== null && !component_context.m;
  729. if (defer) {
  730. var context = (
  731. /** @type {ComponentContext} */
  732. component_context
  733. );
  734. (context.e ?? (context.e = [])).push({
  735. fn,
  736. effect: active_effect,
  737. reaction: active_reaction
  738. });
  739. } else {
  740. var signal = effect(fn);
  741. return signal;
  742. }
  743. }
  744. function user_pre_effect(fn) {
  745. validate_effect();
  746. return render_effect(fn);
  747. }
  748. function component_root(fn) {
  749. const effect2 = create_effect(ROOT_EFFECT, fn, true);
  750. return (options = {}) => {
  751. return new Promise((fulfil) => {
  752. if (options.outro) {
  753. pause_effect(effect2, () => {
  754. destroy_effect(effect2);
  755. fulfil(void 0);
  756. });
  757. } else {
  758. destroy_effect(effect2);
  759. fulfil(void 0);
  760. }
  761. });
  762. };
  763. }
  764. function effect(fn) {
  765. return create_effect(EFFECT, fn, false);
  766. }
  767. function legacy_pre_effect(deps, fn) {
  768. var context = (
  769. /** @type {ComponentContextLegacy} */
  770. component_context
  771. );
  772. var token = { effect: null, ran: false };
  773. context.l.r1.push(token);
  774. token.effect = render_effect(() => {
  775. deps();
  776. if (token.ran) return;
  777. token.ran = true;
  778. set(context.l.r2, true);
  779. untrack(fn);
  780. });
  781. }
  782. function legacy_pre_effect_reset() {
  783. var context = (
  784. /** @type {ComponentContextLegacy} */
  785. component_context
  786. );
  787. render_effect(() => {
  788. if (!get$1(context.l.r2)) return;
  789. for (var token of context.l.r1) {
  790. var effect2 = token.effect;
  791. if ((effect2.f & CLEAN) !== 0) {
  792. set_signal_status(effect2, MAYBE_DIRTY);
  793. }
  794. if (check_dirtiness(effect2)) {
  795. update_effect(effect2);
  796. }
  797. token.ran = false;
  798. }
  799. context.l.r2.v = false;
  800. });
  801. }
  802. function render_effect(fn) {
  803. return create_effect(RENDER_EFFECT, fn, true);
  804. }
  805. function template_effect(fn, thunks = [], d = derived) {
  806. const deriveds = thunks.map(d);
  807. const effect2 = () => fn(...deriveds.map(get$1));
  808. return block(effect2);
  809. }
  810. function block(fn, flags = 0) {
  811. return create_effect(RENDER_EFFECT | BLOCK_EFFECT | flags, fn, true);
  812. }
  813. function branch(fn, push2 = true) {
  814. return create_effect(RENDER_EFFECT | BRANCH_EFFECT, fn, true, push2);
  815. }
  816. function execute_effect_teardown(effect2) {
  817. var teardown2 = effect2.teardown;
  818. if (teardown2 !== null) {
  819. const previously_destroying_effect = is_destroying_effect;
  820. const previous_reaction = active_reaction;
  821. set_is_destroying_effect(true);
  822. set_active_reaction(null);
  823. try {
  824. teardown2.call(null);
  825. } finally {
  826. set_is_destroying_effect(previously_destroying_effect);
  827. set_active_reaction(previous_reaction);
  828. }
  829. }
  830. }
  831. function destroy_effect_children(signal, remove_dom = false) {
  832. var effect2 = signal.first;
  833. signal.first = signal.last = null;
  834. while (effect2 !== null) {
  835. var next2 = effect2.next;
  836. if ((effect2.f & ROOT_EFFECT) !== 0) {
  837. effect2.parent = null;
  838. } else {
  839. destroy_effect(effect2, remove_dom);
  840. }
  841. effect2 = next2;
  842. }
  843. }
  844. function destroy_block_effect_children(signal) {
  845. var effect2 = signal.first;
  846. while (effect2 !== null) {
  847. var next2 = effect2.next;
  848. if ((effect2.f & BRANCH_EFFECT) === 0) {
  849. destroy_effect(effect2);
  850. }
  851. effect2 = next2;
  852. }
  853. }
  854. function destroy_effect(effect2, remove_dom = true) {
  855. var removed = false;
  856. if ((remove_dom || (effect2.f & HEAD_EFFECT) !== 0) && effect2.nodes_start !== null) {
  857. var node = effect2.nodes_start;
  858. var end = effect2.nodes_end;
  859. while (node !== null) {
  860. var next2 = node === end ? null : (
  861. /** @type {TemplateNode} */
  862. /* @__PURE__ */ get_next_sibling(node)
  863. );
  864. node.remove();
  865. node = next2;
  866. }
  867. removed = true;
  868. }
  869. destroy_effect_children(effect2, remove_dom && !removed);
  870. remove_reactions(effect2, 0);
  871. set_signal_status(effect2, DESTROYED);
  872. var transitions = effect2.transitions;
  873. if (transitions !== null) {
  874. for (const transition of transitions) {
  875. transition.stop();
  876. }
  877. }
  878. execute_effect_teardown(effect2);
  879. var parent = effect2.parent;
  880. if (parent !== null && parent.first !== null) {
  881. unlink_effect(effect2);
  882. }
  883. effect2.next = effect2.prev = effect2.teardown = effect2.ctx = effect2.deps = effect2.fn = effect2.nodes_start = effect2.nodes_end = null;
  884. }
  885. function unlink_effect(effect2) {
  886. var parent = effect2.parent;
  887. var prev = effect2.prev;
  888. var next2 = effect2.next;
  889. if (prev !== null) prev.next = next2;
  890. if (next2 !== null) next2.prev = prev;
  891. if (parent !== null) {
  892. if (parent.first === effect2) parent.first = next2;
  893. if (parent.last === effect2) parent.last = prev;
  894. }
  895. }
  896. function pause_effect(effect2, callback) {
  897. var transitions = [];
  898. pause_children(effect2, transitions, true);
  899. run_out_transitions(transitions, () => {
  900. destroy_effect(effect2);
  901. if (callback) callback();
  902. });
  903. }
  904. function run_out_transitions(transitions, fn) {
  905. var remaining = transitions.length;
  906. if (remaining > 0) {
  907. var check = () => --remaining || fn();
  908. for (var transition of transitions) {
  909. transition.out(check);
  910. }
  911. } else {
  912. fn();
  913. }
  914. }
  915. function pause_children(effect2, transitions, local) {
  916. if ((effect2.f & INERT) !== 0) return;
  917. effect2.f ^= INERT;
  918. if (effect2.transitions !== null) {
  919. for (const transition of effect2.transitions) {
  920. if (transition.is_global || local) {
  921. transitions.push(transition);
  922. }
  923. }
  924. }
  925. var child2 = effect2.first;
  926. while (child2 !== null) {
  927. var sibling2 = child2.next;
  928. var transparent = (child2.f & EFFECT_TRANSPARENT) !== 0 || (child2.f & BRANCH_EFFECT) !== 0;
  929. pause_children(child2, transitions, transparent ? local : false);
  930. child2 = sibling2;
  931. }
  932. }
  933. function resume_effect(effect2) {
  934. resume_children(effect2, true);
  935. }
  936. function resume_children(effect2, local) {
  937. if ((effect2.f & INERT) === 0) return;
  938. effect2.f ^= INERT;
  939. if ((effect2.f & CLEAN) === 0) {
  940. effect2.f ^= CLEAN;
  941. }
  942. if (check_dirtiness(effect2)) {
  943. set_signal_status(effect2, DIRTY);
  944. schedule_effect(effect2);
  945. }
  946. var child2 = effect2.first;
  947. while (child2 !== null) {
  948. var sibling2 = child2.next;
  949. var transparent = (child2.f & EFFECT_TRANSPARENT) !== 0 || (child2.f & BRANCH_EFFECT) !== 0;
  950. resume_children(child2, transparent ? local : false);
  951. child2 = sibling2;
  952. }
  953. if (effect2.transitions !== null) {
  954. for (const transition of effect2.transitions) {
  955. if (transition.is_global || local) {
  956. transition.in();
  957. }
  958. }
  959. }
  960. }
  961. let micro_tasks = [];
  962. let idle_tasks = [];
  963. function run_micro_tasks() {
  964. var tasks = micro_tasks;
  965. micro_tasks = [];
  966. run_all(tasks);
  967. }
  968. function run_idle_tasks() {
  969. var tasks = idle_tasks;
  970. idle_tasks = [];
  971. run_all(tasks);
  972. }
  973. function queue_micro_task(fn) {
  974. if (micro_tasks.length === 0) {
  975. queueMicrotask(run_micro_tasks);
  976. }
  977. micro_tasks.push(fn);
  978. }
  979. function flush_tasks() {
  980. if (micro_tasks.length > 0) {
  981. run_micro_tasks();
  982. }
  983. if (idle_tasks.length > 0) {
  984. run_idle_tasks();
  985. }
  986. }
  987. let is_throwing_error = false;
  988. let is_flushing = false;
  989. let last_scheduled_effect = null;
  990. let is_updating_effect = false;
  991. let is_destroying_effect = false;
  992. function set_is_destroying_effect(value) {
  993. is_destroying_effect = value;
  994. }
  995. let queued_root_effects = [];
  996. let active_reaction = null;
  997. let untracking = false;
  998. function set_active_reaction(reaction) {
  999. active_reaction = reaction;
  1000. }
  1001. let active_effect = null;
  1002. function set_active_effect(effect2) {
  1003. active_effect = effect2;
  1004. }
  1005. let reaction_sources = null;
  1006. function set_reaction_sources(sources) {
  1007. reaction_sources = sources;
  1008. }
  1009. function push_reaction_value(value) {
  1010. if (active_reaction !== null && active_reaction.f & EFFECT_IS_UPDATING) {
  1011. if (reaction_sources === null) {
  1012. set_reaction_sources([value]);
  1013. } else {
  1014. reaction_sources.push(value);
  1015. }
  1016. }
  1017. }
  1018. let new_deps = null;
  1019. let skipped_deps = 0;
  1020. let untracked_writes = null;
  1021. function set_untracked_writes(value) {
  1022. untracked_writes = value;
  1023. }
  1024. let write_version = 1;
  1025. let read_version = 0;
  1026. let skip_reaction = false;
  1027. function increment_write_version() {
  1028. return ++write_version;
  1029. }
  1030. function check_dirtiness(reaction) {
  1031. var _a2;
  1032. var flags = reaction.f;
  1033. if ((flags & DIRTY) !== 0) {
  1034. return true;
  1035. }
  1036. if ((flags & MAYBE_DIRTY) !== 0) {
  1037. var dependencies = reaction.deps;
  1038. var is_unowned = (flags & UNOWNED) !== 0;
  1039. if (dependencies !== null) {
  1040. var i2;
  1041. var dependency;
  1042. var is_disconnected = (flags & DISCONNECTED) !== 0;
  1043. var is_unowned_connected = is_unowned && active_effect !== null && !skip_reaction;
  1044. var length = dependencies.length;
  1045. if (is_disconnected || is_unowned_connected) {
  1046. var derived2 = (
  1047. /** @type {Derived} */
  1048. reaction
  1049. );
  1050. var parent = derived2.parent;
  1051. for (i2 = 0; i2 < length; i2++) {
  1052. dependency = dependencies[i2];
  1053. if (is_disconnected || !((_a2 = dependency == null ? void 0 : dependency.reactions) == null ? void 0 : _a2.includes(derived2))) {
  1054. (dependency.reactions ?? (dependency.reactions = [])).push(derived2);
  1055. }
  1056. }
  1057. if (is_disconnected) {
  1058. derived2.f ^= DISCONNECTED;
  1059. }
  1060. if (is_unowned_connected && parent !== null && (parent.f & UNOWNED) === 0) {
  1061. derived2.f ^= UNOWNED;
  1062. }
  1063. }
  1064. for (i2 = 0; i2 < length; i2++) {
  1065. dependency = dependencies[i2];
  1066. if (check_dirtiness(
  1067. /** @type {Derived} */
  1068. dependency
  1069. )) {
  1070. update_derived(
  1071. /** @type {Derived} */
  1072. dependency
  1073. );
  1074. }
  1075. if (dependency.wv > reaction.wv) {
  1076. return true;
  1077. }
  1078. }
  1079. }
  1080. if (!is_unowned || active_effect !== null && !skip_reaction) {
  1081. set_signal_status(reaction, CLEAN);
  1082. }
  1083. }
  1084. return false;
  1085. }
  1086. function propagate_error(error, effect2) {
  1087. var current = effect2;
  1088. while (current !== null) {
  1089. if ((current.f & BOUNDARY_EFFECT) !== 0) {
  1090. try {
  1091. current.fn(error);
  1092. return;
  1093. } catch {
  1094. current.f ^= BOUNDARY_EFFECT;
  1095. }
  1096. }
  1097. current = current.parent;
  1098. }
  1099. is_throwing_error = false;
  1100. throw error;
  1101. }
  1102. function should_rethrow_error(effect2) {
  1103. return (effect2.f & DESTROYED) === 0 && (effect2.parent === null || (effect2.parent.f & BOUNDARY_EFFECT) === 0);
  1104. }
  1105. function handle_error(error, effect2, previous_effect, component_context2) {
  1106. if (is_throwing_error) {
  1107. if (previous_effect === null) {
  1108. is_throwing_error = false;
  1109. }
  1110. if (should_rethrow_error(effect2)) {
  1111. throw error;
  1112. }
  1113. return;
  1114. }
  1115. if (previous_effect !== null) {
  1116. is_throwing_error = true;
  1117. }
  1118. {
  1119. propagate_error(error, effect2);
  1120. return;
  1121. }
  1122. }
  1123. function schedule_possible_effect_self_invalidation(signal, effect2, root2 = true) {
  1124. var reactions = signal.reactions;
  1125. if (reactions === null) return;
  1126. for (var i2 = 0; i2 < reactions.length; i2++) {
  1127. var reaction = reactions[i2];
  1128. if (reaction_sources == null ? void 0 : reaction_sources.includes(signal)) continue;
  1129. if ((reaction.f & DERIVED) !== 0) {
  1130. schedule_possible_effect_self_invalidation(
  1131. /** @type {Derived} */
  1132. reaction,
  1133. effect2,
  1134. false
  1135. );
  1136. } else if (effect2 === reaction) {
  1137. if (root2) {
  1138. set_signal_status(reaction, DIRTY);
  1139. } else if ((reaction.f & CLEAN) !== 0) {
  1140. set_signal_status(reaction, MAYBE_DIRTY);
  1141. }
  1142. schedule_effect(
  1143. /** @type {Effect} */
  1144. reaction
  1145. );
  1146. }
  1147. }
  1148. }
  1149. function update_reaction(reaction) {
  1150. var _a2;
  1151. var previous_deps = new_deps;
  1152. var previous_skipped_deps = skipped_deps;
  1153. var previous_untracked_writes = untracked_writes;
  1154. var previous_reaction = active_reaction;
  1155. var previous_skip_reaction = skip_reaction;
  1156. var previous_reaction_sources = reaction_sources;
  1157. var previous_component_context = component_context;
  1158. var previous_untracking = untracking;
  1159. var flags = reaction.f;
  1160. new_deps = /** @type {null | Value[]} */
  1161. null;
  1162. skipped_deps = 0;
  1163. untracked_writes = null;
  1164. skip_reaction = (flags & UNOWNED) !== 0 && (untracking || !is_updating_effect || active_reaction === null);
  1165. active_reaction = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
  1166. reaction_sources = null;
  1167. set_component_context(reaction.ctx);
  1168. untracking = false;
  1169. read_version++;
  1170. reaction.f |= EFFECT_IS_UPDATING;
  1171. try {
  1172. var result = (
  1173. /** @type {Function} */
  1174. (0, reaction.fn)()
  1175. );
  1176. var deps = reaction.deps;
  1177. if (new_deps !== null) {
  1178. var i2;
  1179. remove_reactions(reaction, skipped_deps);
  1180. if (deps !== null && skipped_deps > 0) {
  1181. deps.length = skipped_deps + new_deps.length;
  1182. for (i2 = 0; i2 < new_deps.length; i2++) {
  1183. deps[skipped_deps + i2] = new_deps[i2];
  1184. }
  1185. } else {
  1186. reaction.deps = deps = new_deps;
  1187. }
  1188. if (!skip_reaction) {
  1189. for (i2 = skipped_deps; i2 < deps.length; i2++) {
  1190. ((_a2 = deps[i2]).reactions ?? (_a2.reactions = [])).push(reaction);
  1191. }
  1192. }
  1193. } else if (deps !== null && skipped_deps < deps.length) {
  1194. remove_reactions(reaction, skipped_deps);
  1195. deps.length = skipped_deps;
  1196. }
  1197. if (is_runes() && untracked_writes !== null && !untracking && deps !== null && (reaction.f & (DERIVED | MAYBE_DIRTY | DIRTY)) === 0) {
  1198. for (i2 = 0; i2 < /** @type {Source[]} */
  1199. untracked_writes.length; i2++) {
  1200. schedule_possible_effect_self_invalidation(
  1201. untracked_writes[i2],
  1202. /** @type {Effect} */
  1203. reaction
  1204. );
  1205. }
  1206. }
  1207. if (previous_reaction !== reaction) {
  1208. read_version++;
  1209. if (untracked_writes !== null) {
  1210. if (previous_untracked_writes === null) {
  1211. previous_untracked_writes = untracked_writes;
  1212. } else {
  1213. previous_untracked_writes.push(.../** @type {Source[]} */
  1214. untracked_writes);
  1215. }
  1216. }
  1217. }
  1218. return result;
  1219. } finally {
  1220. new_deps = previous_deps;
  1221. skipped_deps = previous_skipped_deps;
  1222. untracked_writes = previous_untracked_writes;
  1223. active_reaction = previous_reaction;
  1224. skip_reaction = previous_skip_reaction;
  1225. reaction_sources = previous_reaction_sources;
  1226. set_component_context(previous_component_context);
  1227. untracking = previous_untracking;
  1228. reaction.f ^= EFFECT_IS_UPDATING;
  1229. }
  1230. }
  1231. function remove_reaction(signal, dependency) {
  1232. let reactions = dependency.reactions;
  1233. if (reactions !== null) {
  1234. var index2 = index_of.call(reactions, signal);
  1235. if (index2 !== -1) {
  1236. var new_length = reactions.length - 1;
  1237. if (new_length === 0) {
  1238. reactions = dependency.reactions = null;
  1239. } else {
  1240. reactions[index2] = reactions[new_length];
  1241. reactions.pop();
  1242. }
  1243. }
  1244. }
  1245. if (reactions === null && (dependency.f & DERIVED) !== 0 && // Destroying a child effect while updating a parent effect can cause a dependency to appear
  1246. // to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
  1247. // allows us to skip the expensive work of disconnecting and immediately reconnecting it
  1248. (new_deps === null || !new_deps.includes(dependency))) {
  1249. set_signal_status(dependency, MAYBE_DIRTY);
  1250. if ((dependency.f & (UNOWNED | DISCONNECTED)) === 0) {
  1251. dependency.f ^= DISCONNECTED;
  1252. }
  1253. destroy_derived_effects(
  1254. /** @type {Derived} **/
  1255. dependency
  1256. );
  1257. remove_reactions(
  1258. /** @type {Derived} **/
  1259. dependency,
  1260. 0
  1261. );
  1262. }
  1263. }
  1264. function remove_reactions(signal, start_index) {
  1265. var dependencies = signal.deps;
  1266. if (dependencies === null) return;
  1267. for (var i2 = start_index; i2 < dependencies.length; i2++) {
  1268. remove_reaction(signal, dependencies[i2]);
  1269. }
  1270. }
  1271. function update_effect(effect2) {
  1272. var flags = effect2.f;
  1273. if ((flags & DESTROYED) !== 0) {
  1274. return;
  1275. }
  1276. set_signal_status(effect2, CLEAN);
  1277. var previous_effect = active_effect;
  1278. var previous_component_context = component_context;
  1279. var was_updating_effect = is_updating_effect;
  1280. active_effect = effect2;
  1281. is_updating_effect = true;
  1282. try {
  1283. if ((flags & BLOCK_EFFECT) !== 0) {
  1284. destroy_block_effect_children(effect2);
  1285. } else {
  1286. destroy_effect_children(effect2);
  1287. }
  1288. execute_effect_teardown(effect2);
  1289. var teardown2 = update_reaction(effect2);
  1290. effect2.teardown = typeof teardown2 === "function" ? teardown2 : null;
  1291. effect2.wv = write_version;
  1292. var deps = effect2.deps;
  1293. var dep;
  1294. if (DEV && tracing_mode_flag && (effect2.f & DIRTY) !== 0 && deps !== null) ;
  1295. if (DEV) ;
  1296. } catch (error) {
  1297. handle_error(error, effect2, previous_effect, previous_component_context || effect2.ctx);
  1298. } finally {
  1299. is_updating_effect = was_updating_effect;
  1300. active_effect = previous_effect;
  1301. }
  1302. }
  1303. function infinite_loop_guard() {
  1304. try {
  1305. effect_update_depth_exceeded();
  1306. } catch (error) {
  1307. if (last_scheduled_effect !== null) {
  1308. {
  1309. handle_error(error, last_scheduled_effect, null);
  1310. }
  1311. } else {
  1312. throw error;
  1313. }
  1314. }
  1315. }
  1316. function flush_queued_root_effects() {
  1317. var was_updating_effect = is_updating_effect;
  1318. try {
  1319. var flush_count = 0;
  1320. is_updating_effect = true;
  1321. while (queued_root_effects.length > 0) {
  1322. if (flush_count++ > 1e3) {
  1323. infinite_loop_guard();
  1324. }
  1325. var root_effects = queued_root_effects;
  1326. var length = root_effects.length;
  1327. queued_root_effects = [];
  1328. for (var i2 = 0; i2 < length; i2++) {
  1329. var collected_effects = process_effects(root_effects[i2]);
  1330. flush_queued_effects(collected_effects);
  1331. }
  1332. old_values.clear();
  1333. }
  1334. } finally {
  1335. is_flushing = false;
  1336. is_updating_effect = was_updating_effect;
  1337. last_scheduled_effect = null;
  1338. }
  1339. }
  1340. function flush_queued_effects(effects) {
  1341. var length = effects.length;
  1342. if (length === 0) return;
  1343. for (var i2 = 0; i2 < length; i2++) {
  1344. var effect2 = effects[i2];
  1345. if ((effect2.f & (DESTROYED | INERT)) === 0) {
  1346. try {
  1347. if (check_dirtiness(effect2)) {
  1348. update_effect(effect2);
  1349. if (effect2.deps === null && effect2.first === null && effect2.nodes_start === null) {
  1350. if (effect2.teardown === null) {
  1351. unlink_effect(effect2);
  1352. } else {
  1353. effect2.fn = null;
  1354. }
  1355. }
  1356. }
  1357. } catch (error) {
  1358. handle_error(error, effect2, null, effect2.ctx);
  1359. }
  1360. }
  1361. }
  1362. }
  1363. function schedule_effect(signal) {
  1364. if (!is_flushing) {
  1365. is_flushing = true;
  1366. queueMicrotask(flush_queued_root_effects);
  1367. }
  1368. var effect2 = last_scheduled_effect = signal;
  1369. while (effect2.parent !== null) {
  1370. effect2 = effect2.parent;
  1371. var flags = effect2.f;
  1372. if ((flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
  1373. if ((flags & CLEAN) === 0) return;
  1374. effect2.f ^= CLEAN;
  1375. }
  1376. }
  1377. queued_root_effects.push(effect2);
  1378. }
  1379. function process_effects(root2) {
  1380. var effects = [];
  1381. var effect2 = root2;
  1382. while (effect2 !== null) {
  1383. var flags = effect2.f;
  1384. var is_branch = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) !== 0;
  1385. var is_skippable_branch = is_branch && (flags & CLEAN) !== 0;
  1386. if (!is_skippable_branch && (flags & INERT) === 0) {
  1387. if ((flags & EFFECT) !== 0) {
  1388. effects.push(effect2);
  1389. } else if (is_branch) {
  1390. effect2.f ^= CLEAN;
  1391. } else {
  1392. var previous_active_reaction = active_reaction;
  1393. try {
  1394. active_reaction = effect2;
  1395. if (check_dirtiness(effect2)) {
  1396. update_effect(effect2);
  1397. }
  1398. } catch (error) {
  1399. handle_error(error, effect2, null, effect2.ctx);
  1400. } finally {
  1401. active_reaction = previous_active_reaction;
  1402. }
  1403. }
  1404. var child2 = effect2.first;
  1405. if (child2 !== null) {
  1406. effect2 = child2;
  1407. continue;
  1408. }
  1409. }
  1410. var parent = effect2.parent;
  1411. effect2 = effect2.next;
  1412. while (effect2 === null && parent !== null) {
  1413. effect2 = parent.next;
  1414. parent = parent.parent;
  1415. }
  1416. }
  1417. return effects;
  1418. }
  1419. function flushSync(fn) {
  1420. var result;
  1421. flush_tasks();
  1422. while (queued_root_effects.length > 0) {
  1423. is_flushing = true;
  1424. flush_queued_root_effects();
  1425. flush_tasks();
  1426. }
  1427. return (
  1428. /** @type {T} */
  1429. result
  1430. );
  1431. }
  1432. async function tick() {
  1433. await Promise.resolve();
  1434. flushSync();
  1435. }
  1436. function get$1(signal) {
  1437. var flags = signal.f;
  1438. var is_derived = (flags & DERIVED) !== 0;
  1439. if (active_reaction !== null && !untracking) {
  1440. if (!(reaction_sources == null ? void 0 : reaction_sources.includes(signal))) {
  1441. var deps = active_reaction.deps;
  1442. if (signal.rv < read_version) {
  1443. signal.rv = read_version;
  1444. if (new_deps === null && deps !== null && deps[skipped_deps] === signal) {
  1445. skipped_deps++;
  1446. } else if (new_deps === null) {
  1447. new_deps = [signal];
  1448. } else if (!skip_reaction || !new_deps.includes(signal)) {
  1449. new_deps.push(signal);
  1450. }
  1451. }
  1452. }
  1453. } else if (is_derived && /** @type {Derived} */
  1454. signal.deps === null && /** @type {Derived} */
  1455. signal.effects === null) {
  1456. var derived2 = (
  1457. /** @type {Derived} */
  1458. signal
  1459. );
  1460. var parent = derived2.parent;
  1461. if (parent !== null && (parent.f & UNOWNED) === 0) {
  1462. derived2.f ^= UNOWNED;
  1463. }
  1464. }
  1465. if (is_derived) {
  1466. derived2 = /** @type {Derived} */
  1467. signal;
  1468. if (check_dirtiness(derived2)) {
  1469. update_derived(derived2);
  1470. }
  1471. }
  1472. if (is_destroying_effect && old_values.has(signal)) {
  1473. return old_values.get(signal);
  1474. }
  1475. return signal.v;
  1476. }
  1477. function untrack(fn) {
  1478. var previous_untracking = untracking;
  1479. try {
  1480. untracking = true;
  1481. return fn();
  1482. } finally {
  1483. untracking = previous_untracking;
  1484. }
  1485. }
  1486. const STATUS_MASK = -7169;
  1487. function set_signal_status(signal, status) {
  1488. signal.f = signal.f & STATUS_MASK | status;
  1489. }
  1490. function deep_read_state(value) {
  1491. if (typeof value !== "object" || !value || value instanceof EventTarget) {
  1492. return;
  1493. }
  1494. if (STATE_SYMBOL in value) {
  1495. deep_read(value);
  1496. } else if (!Array.isArray(value)) {
  1497. for (let key in value) {
  1498. const prop2 = value[key];
  1499. if (typeof prop2 === "object" && prop2 && STATE_SYMBOL in prop2) {
  1500. deep_read(prop2);
  1501. }
  1502. }
  1503. }
  1504. }
  1505. function deep_read(value, visited = /* @__PURE__ */ new Set()) {
  1506. if (typeof value === "object" && value !== null && // We don't want to traverse DOM elements
  1507. !(value instanceof EventTarget) && !visited.has(value)) {
  1508. visited.add(value);
  1509. if (value instanceof Date) {
  1510. value.getTime();
  1511. }
  1512. for (let key in value) {
  1513. try {
  1514. deep_read(value[key], visited);
  1515. } catch (e) {
  1516. }
  1517. }
  1518. const proto = get_prototype_of(value);
  1519. if (proto !== Object.prototype && proto !== Array.prototype && proto !== Map.prototype && proto !== Set.prototype && proto !== Date.prototype) {
  1520. const descriptors = get_descriptors(proto);
  1521. for (let key in descriptors) {
  1522. const get2 = descriptors[key].get;
  1523. if (get2) {
  1524. try {
  1525. get2.call(value);
  1526. } catch (e) {
  1527. }
  1528. }
  1529. }
  1530. }
  1531. }
  1532. }
  1533. function is_capture_event(name) {
  1534. return name.endsWith("capture") && name !== "gotpointercapture" && name !== "lostpointercapture";
  1535. }
  1536. const DELEGATED_EVENTS = [
  1537. "beforeinput",
  1538. "click",
  1539. "change",
  1540. "dblclick",
  1541. "contextmenu",
  1542. "focusin",
  1543. "focusout",
  1544. "input",
  1545. "keydown",
  1546. "keyup",
  1547. "mousedown",
  1548. "mousemove",
  1549. "mouseout",
  1550. "mouseover",
  1551. "mouseup",
  1552. "pointerdown",
  1553. "pointermove",
  1554. "pointerout",
  1555. "pointerover",
  1556. "pointerup",
  1557. "touchend",
  1558. "touchmove",
  1559. "touchstart"
  1560. ];
  1561. function is_delegated(event_name) {
  1562. return DELEGATED_EVENTS.includes(event_name);
  1563. }
  1564. const ATTRIBUTE_ALIASES = {
  1565. // no `class: 'className'` because we handle that separately
  1566. formnovalidate: "formNoValidate",
  1567. ismap: "isMap",
  1568. nomodule: "noModule",
  1569. playsinline: "playsInline",
  1570. readonly: "readOnly",
  1571. defaultvalue: "defaultValue",
  1572. defaultchecked: "defaultChecked",
  1573. srcobject: "srcObject",
  1574. novalidate: "noValidate",
  1575. allowfullscreen: "allowFullscreen",
  1576. disablepictureinpicture: "disablePictureInPicture",
  1577. disableremoteplayback: "disableRemotePlayback"
  1578. };
  1579. function normalize_attribute(name) {
  1580. name = name.toLowerCase();
  1581. return ATTRIBUTE_ALIASES[name] ?? name;
  1582. }
  1583. const PASSIVE_EVENTS = ["touchstart", "touchmove"];
  1584. function is_passive_event(name) {
  1585. return PASSIVE_EVENTS.includes(name);
  1586. }
  1587. function autofocus(dom, value) {
  1588. if (value) {
  1589. const body = document.body;
  1590. dom.autofocus = true;
  1591. queue_micro_task(() => {
  1592. if (document.activeElement === body) {
  1593. dom.focus();
  1594. }
  1595. });
  1596. }
  1597. }
  1598. function without_reactive_context(fn) {
  1599. var previous_reaction = active_reaction;
  1600. var previous_effect = active_effect;
  1601. set_active_reaction(null);
  1602. set_active_effect(null);
  1603. try {
  1604. return fn();
  1605. } finally {
  1606. set_active_reaction(previous_reaction);
  1607. set_active_effect(previous_effect);
  1608. }
  1609. }
  1610. const all_registered_events = /* @__PURE__ */ new Set();
  1611. const root_event_handles = /* @__PURE__ */ new Set();
  1612. function create_event(event_name, dom, handler, options = {}) {
  1613. function target_handler(event2) {
  1614. if (!options.capture) {
  1615. handle_event_propagation.call(dom, event2);
  1616. }
  1617. if (!event2.cancelBubble) {
  1618. return without_reactive_context(() => {
  1619. return handler == null ? void 0 : handler.call(this, event2);
  1620. });
  1621. }
  1622. }
  1623. if (event_name.startsWith("pointer") || event_name.startsWith("touch") || event_name === "wheel") {
  1624. queue_micro_task(() => {
  1625. dom.addEventListener(event_name, target_handler, options);
  1626. });
  1627. } else {
  1628. dom.addEventListener(event_name, target_handler, options);
  1629. }
  1630. return target_handler;
  1631. }
  1632. function event(event_name, dom, handler, capture, passive) {
  1633. var options = { capture, passive };
  1634. var target_handler = create_event(event_name, dom, handler, options);
  1635. if (dom === document.body || dom === window || dom === document) {
  1636. teardown(() => {
  1637. dom.removeEventListener(event_name, target_handler, options);
  1638. });
  1639. }
  1640. }
  1641. function delegate(events) {
  1642. for (var i2 = 0; i2 < events.length; i2++) {
  1643. all_registered_events.add(events[i2]);
  1644. }
  1645. for (var fn of root_event_handles) {
  1646. fn(events);
  1647. }
  1648. }
  1649. function handle_event_propagation(event2) {
  1650. var _a2;
  1651. var handler_element = this;
  1652. var owner_document = (
  1653. /** @type {Node} */
  1654. handler_element.ownerDocument
  1655. );
  1656. var event_name = event2.type;
  1657. var path = ((_a2 = event2.composedPath) == null ? void 0 : _a2.call(event2)) || [];
  1658. var current_target = (
  1659. /** @type {null | Element} */
  1660. path[0] || event2.target
  1661. );
  1662. var path_idx = 0;
  1663. var handled_at = event2.__root;
  1664. if (handled_at) {
  1665. var at_idx = path.indexOf(handled_at);
  1666. if (at_idx !== -1 && (handler_element === document || handler_element === /** @type {any} */
  1667. window)) {
  1668. event2.__root = handler_element;
  1669. return;
  1670. }
  1671. var handler_idx = path.indexOf(handler_element);
  1672. if (handler_idx === -1) {
  1673. return;
  1674. }
  1675. if (at_idx <= handler_idx) {
  1676. path_idx = at_idx;
  1677. }
  1678. }
  1679. current_target = /** @type {Element} */
  1680. path[path_idx] || event2.target;
  1681. if (current_target === handler_element) return;
  1682. define_property(event2, "currentTarget", {
  1683. configurable: true,
  1684. get() {
  1685. return current_target || owner_document;
  1686. }
  1687. });
  1688. var previous_reaction = active_reaction;
  1689. var previous_effect = active_effect;
  1690. set_active_reaction(null);
  1691. set_active_effect(null);
  1692. try {
  1693. var throw_error;
  1694. var other_errors = [];
  1695. while (current_target !== null) {
  1696. var parent_element = current_target.assignedSlot || current_target.parentNode || /** @type {any} */
  1697. current_target.host || null;
  1698. try {
  1699. var delegated = current_target["__" + event_name];
  1700. if (delegated != null && (!/** @type {any} */
  1701. current_target.disabled || // DOM could've been updated already by the time this is reached, so we check this as well
  1702. // -> the target could not have been disabled because it emits the event in the first place
  1703. event2.target === current_target)) {
  1704. if (is_array(delegated)) {
  1705. var [fn, ...data] = delegated;
  1706. fn.apply(current_target, [event2, ...data]);
  1707. } else {
  1708. delegated.call(current_target, event2);
  1709. }
  1710. }
  1711. } catch (error) {
  1712. if (throw_error) {
  1713. other_errors.push(error);
  1714. } else {
  1715. throw_error = error;
  1716. }
  1717. }
  1718. if (event2.cancelBubble || parent_element === handler_element || parent_element === null) {
  1719. break;
  1720. }
  1721. current_target = parent_element;
  1722. }
  1723. if (throw_error) {
  1724. for (let error of other_errors) {
  1725. queueMicrotask(() => {
  1726. throw error;
  1727. });
  1728. }
  1729. throw throw_error;
  1730. }
  1731. } finally {
  1732. event2.__root = handler_element;
  1733. delete event2.currentTarget;
  1734. set_active_reaction(previous_reaction);
  1735. set_active_effect(previous_effect);
  1736. }
  1737. }
  1738. function create_fragment_from_html(html) {
  1739. var elem = document.createElement("template");
  1740. elem.innerHTML = html;
  1741. return elem.content;
  1742. }
  1743. function assign_nodes(start, end) {
  1744. var effect2 = (
  1745. /** @type {Effect} */
  1746. active_effect
  1747. );
  1748. if (effect2.nodes_start === null) {
  1749. effect2.nodes_start = start;
  1750. effect2.nodes_end = end;
  1751. }
  1752. }
  1753. // @__NO_SIDE_EFFECTS__
  1754. function template(content, flags) {
  1755. var is_fragment = (flags & TEMPLATE_FRAGMENT) !== 0;
  1756. var use_import_node = (flags & TEMPLATE_USE_IMPORT_NODE) !== 0;
  1757. var node;
  1758. var has_start = !content.startsWith("<!>");
  1759. return () => {
  1760. if (node === void 0) {
  1761. node = create_fragment_from_html(has_start ? content : "<!>" + content);
  1762. if (!is_fragment) node = /** @type {Node} */
  1763. /* @__PURE__ */ get_first_child(node);
  1764. }
  1765. var clone = (
  1766. /** @type {TemplateNode} */
  1767. use_import_node || is_firefox ? document.importNode(node, true) : node.cloneNode(true)
  1768. );
  1769. if (is_fragment) {
  1770. var start = (
  1771. /** @type {TemplateNode} */
  1772. /* @__PURE__ */ get_first_child(clone)
  1773. );
  1774. var end = (
  1775. /** @type {TemplateNode} */
  1776. clone.lastChild
  1777. );
  1778. assign_nodes(start, end);
  1779. } else {
  1780. assign_nodes(clone, clone);
  1781. }
  1782. return clone;
  1783. };
  1784. }
  1785. // @__NO_SIDE_EFFECTS__
  1786. function ns_template(content, flags, ns = "svg") {
  1787. var has_start = !content.startsWith("<!>");
  1788. var wrapped = `<${ns}>${has_start ? content : "<!>" + content}</${ns}>`;
  1789. var node;
  1790. return () => {
  1791. if (!node) {
  1792. var fragment = (
  1793. /** @type {DocumentFragment} */
  1794. create_fragment_from_html(wrapped)
  1795. );
  1796. var root2 = (
  1797. /** @type {Element} */
  1798. /* @__PURE__ */ get_first_child(fragment)
  1799. );
  1800. {
  1801. node = /** @type {Element} */
  1802. /* @__PURE__ */ get_first_child(root2);
  1803. }
  1804. }
  1805. var clone = (
  1806. /** @type {TemplateNode} */
  1807. node.cloneNode(true)
  1808. );
  1809. {
  1810. assign_nodes(clone, clone);
  1811. }
  1812. return clone;
  1813. };
  1814. }
  1815. function text(value = "") {
  1816. {
  1817. var t = create_text(value + "");
  1818. assign_nodes(t, t);
  1819. return t;
  1820. }
  1821. }
  1822. function comment() {
  1823. var frag = document.createDocumentFragment();
  1824. var start = document.createComment("");
  1825. var anchor = create_text();
  1826. frag.append(start, anchor);
  1827. assign_nodes(start, anchor);
  1828. return frag;
  1829. }
  1830. function append(anchor, dom) {
  1831. if (anchor === null) {
  1832. return;
  1833. }
  1834. anchor.before(
  1835. /** @type {Node} */
  1836. dom
  1837. );
  1838. }
  1839. function set_text(text2, value) {
  1840. var str = value == null ? "" : typeof value === "object" ? value + "" : value;
  1841. if (str !== (text2.__t ?? (text2.__t = text2.nodeValue))) {
  1842. text2.__t = str;
  1843. text2.nodeValue = str + "";
  1844. }
  1845. }
  1846. function mount(component2, options) {
  1847. return _mount(component2, options);
  1848. }
  1849. const document_listeners = /* @__PURE__ */ new Map();
  1850. function _mount(Component, { target, anchor, props = {}, events, context, intro = true }) {
  1851. init_operations();
  1852. var registered_events = /* @__PURE__ */ new Set();
  1853. var event_handle = (events2) => {
  1854. for (var i2 = 0; i2 < events2.length; i2++) {
  1855. var event_name = events2[i2];
  1856. if (registered_events.has(event_name)) continue;
  1857. registered_events.add(event_name);
  1858. var passive = is_passive_event(event_name);
  1859. target.addEventListener(event_name, handle_event_propagation, { passive });
  1860. var n = document_listeners.get(event_name);
  1861. if (n === void 0) {
  1862. document.addEventListener(event_name, handle_event_propagation, { passive });
  1863. document_listeners.set(event_name, 1);
  1864. } else {
  1865. document_listeners.set(event_name, n + 1);
  1866. }
  1867. }
  1868. };
  1869. event_handle(array_from(all_registered_events));
  1870. root_event_handles.add(event_handle);
  1871. var component2 = void 0;
  1872. var unmount = component_root(() => {
  1873. var anchor_node = anchor ?? target.appendChild(create_text());
  1874. branch(() => {
  1875. if (context) {
  1876. push({});
  1877. var ctx = (
  1878. /** @type {ComponentContext} */
  1879. component_context
  1880. );
  1881. ctx.c = context;
  1882. }
  1883. if (events) {
  1884. props.$$events = events;
  1885. }
  1886. component2 = Component(anchor_node, props) || {};
  1887. if (context) {
  1888. pop();
  1889. }
  1890. });
  1891. return () => {
  1892. var _a2;
  1893. for (var event_name of registered_events) {
  1894. target.removeEventListener(event_name, handle_event_propagation);
  1895. var n = (
  1896. /** @type {number} */
  1897. document_listeners.get(event_name)
  1898. );
  1899. if (--n === 0) {
  1900. document.removeEventListener(event_name, handle_event_propagation);
  1901. document_listeners.delete(event_name);
  1902. } else {
  1903. document_listeners.set(event_name, n);
  1904. }
  1905. }
  1906. root_event_handles.delete(event_handle);
  1907. if (anchor_node !== anchor) {
  1908. (_a2 = anchor_node.parentNode) == null ? void 0 : _a2.removeChild(anchor_node);
  1909. }
  1910. };
  1911. });
  1912. mounted_components.set(component2, unmount);
  1913. return component2;
  1914. }
  1915. let mounted_components = /* @__PURE__ */ new WeakMap();
  1916. function if_block(node, fn, [root_index, hydrate_index] = [0, 0]) {
  1917. var anchor = node;
  1918. var consequent_effect = null;
  1919. var alternate_effect = null;
  1920. var condition = UNINITIALIZED;
  1921. var flags = root_index > 0 ? EFFECT_TRANSPARENT : 0;
  1922. var has_branch = false;
  1923. const set_branch = (fn2, flag = true) => {
  1924. has_branch = true;
  1925. update_branch(flag, fn2);
  1926. };
  1927. const update_branch = (new_condition, fn2) => {
  1928. if (condition === (condition = new_condition)) return;
  1929. if (condition) {
  1930. if (consequent_effect) {
  1931. resume_effect(consequent_effect);
  1932. } else if (fn2) {
  1933. consequent_effect = branch(() => fn2(anchor));
  1934. }
  1935. if (alternate_effect) {
  1936. pause_effect(alternate_effect, () => {
  1937. alternate_effect = null;
  1938. });
  1939. }
  1940. } else {
  1941. if (alternate_effect) {
  1942. resume_effect(alternate_effect);
  1943. } else if (fn2) {
  1944. alternate_effect = branch(() => fn2(anchor, [root_index + 1, hydrate_index]));
  1945. }
  1946. if (consequent_effect) {
  1947. pause_effect(consequent_effect, () => {
  1948. consequent_effect = null;
  1949. });
  1950. }
  1951. }
  1952. };
  1953. block(() => {
  1954. has_branch = false;
  1955. fn(set_branch);
  1956. if (!has_branch) {
  1957. update_branch(null, null);
  1958. }
  1959. }, flags);
  1960. }
  1961. function index(_, i2) {
  1962. return i2;
  1963. }
  1964. function pause_effects(state2, items, controlled_anchor, items_map) {
  1965. var transitions = [];
  1966. var length = items.length;
  1967. for (var i2 = 0; i2 < length; i2++) {
  1968. pause_children(items[i2].e, transitions, true);
  1969. }
  1970. var is_controlled = length > 0 && transitions.length === 0 && controlled_anchor !== null;
  1971. if (is_controlled) {
  1972. var parent_node = (
  1973. /** @type {Element} */
  1974. /** @type {Element} */
  1975. controlled_anchor.parentNode
  1976. );
  1977. clear_text_content(parent_node);
  1978. parent_node.append(
  1979. /** @type {Element} */
  1980. controlled_anchor
  1981. );
  1982. items_map.clear();
  1983. link(state2, items[0].prev, items[length - 1].next);
  1984. }
  1985. run_out_transitions(transitions, () => {
  1986. for (var i3 = 0; i3 < length; i3++) {
  1987. var item = items[i3];
  1988. if (!is_controlled) {
  1989. items_map.delete(item.k);
  1990. link(state2, item.prev, item.next);
  1991. }
  1992. destroy_effect(item.e, !is_controlled);
  1993. }
  1994. });
  1995. }
  1996. function each(node, flags, get_collection, get_key, render_fn, fallback_fn = null) {
  1997. var anchor = node;
  1998. var state2 = { flags, items: /* @__PURE__ */ new Map(), first: null };
  1999. var is_controlled = (flags & EACH_IS_CONTROLLED) !== 0;
  2000. if (is_controlled) {
  2001. var parent_node = (
  2002. /** @type {Element} */
  2003. node
  2004. );
  2005. anchor = parent_node.appendChild(create_text());
  2006. }
  2007. var fallback = null;
  2008. var was_empty = false;
  2009. var each_array = /* @__PURE__ */ derived_safe_equal(() => {
  2010. var collection = get_collection();
  2011. return is_array(collection) ? collection : collection == null ? [] : array_from(collection);
  2012. });
  2013. block(() => {
  2014. var array = get$1(each_array);
  2015. var length = array.length;
  2016. if (was_empty && length === 0) {
  2017. return;
  2018. }
  2019. was_empty = length === 0;
  2020. {
  2021. reconcile(array, state2, anchor, render_fn, flags, get_key, get_collection);
  2022. }
  2023. if (fallback_fn !== null) {
  2024. if (length === 0) {
  2025. if (fallback) {
  2026. resume_effect(fallback);
  2027. } else {
  2028. fallback = branch(() => fallback_fn(anchor));
  2029. }
  2030. } else if (fallback !== null) {
  2031. pause_effect(fallback, () => {
  2032. fallback = null;
  2033. });
  2034. }
  2035. }
  2036. get$1(each_array);
  2037. });
  2038. }
  2039. function reconcile(array, state2, anchor, render_fn, flags, get_key, get_collection) {
  2040. var _a2, _b2, _c, _d;
  2041. var is_animated = (flags & EACH_IS_ANIMATED) !== 0;
  2042. var should_update = (flags & (EACH_ITEM_REACTIVE | EACH_INDEX_REACTIVE)) !== 0;
  2043. var length = array.length;
  2044. var items = state2.items;
  2045. var first = state2.first;
  2046. var current = first;
  2047. var seen;
  2048. var prev = null;
  2049. var to_animate;
  2050. var matched = [];
  2051. var stashed = [];
  2052. var value;
  2053. var key;
  2054. var item;
  2055. var i2;
  2056. if (is_animated) {
  2057. for (i2 = 0; i2 < length; i2 += 1) {
  2058. value = array[i2];
  2059. key = get_key(value, i2);
  2060. item = items.get(key);
  2061. if (item !== void 0) {
  2062. (_a2 = item.a) == null ? void 0 : _a2.measure();
  2063. (to_animate ?? (to_animate = /* @__PURE__ */ new Set())).add(item);
  2064. }
  2065. }
  2066. }
  2067. for (i2 = 0; i2 < length; i2 += 1) {
  2068. value = array[i2];
  2069. key = get_key(value, i2);
  2070. item = items.get(key);
  2071. if (item === void 0) {
  2072. var child_anchor = current ? (
  2073. /** @type {TemplateNode} */
  2074. current.e.nodes_start
  2075. ) : anchor;
  2076. prev = create_item(
  2077. child_anchor,
  2078. state2,
  2079. prev,
  2080. prev === null ? state2.first : prev.next,
  2081. value,
  2082. key,
  2083. i2,
  2084. render_fn,
  2085. flags,
  2086. get_collection
  2087. );
  2088. items.set(key, prev);
  2089. matched = [];
  2090. stashed = [];
  2091. current = prev.next;
  2092. continue;
  2093. }
  2094. if (should_update) {
  2095. update_item(item, value, i2, flags);
  2096. }
  2097. if ((item.e.f & INERT) !== 0) {
  2098. resume_effect(item.e);
  2099. if (is_animated) {
  2100. (_b2 = item.a) == null ? void 0 : _b2.unfix();
  2101. (to_animate ?? (to_animate = /* @__PURE__ */ new Set())).delete(item);
  2102. }
  2103. }
  2104. if (item !== current) {
  2105. if (seen !== void 0 && seen.has(item)) {
  2106. if (matched.length < stashed.length) {
  2107. var start = stashed[0];
  2108. var j;
  2109. prev = start.prev;
  2110. var a2 = matched[0];
  2111. var b = matched[matched.length - 1];
  2112. for (j = 0; j < matched.length; j += 1) {
  2113. move(matched[j], start, anchor);
  2114. }
  2115. for (j = 0; j < stashed.length; j += 1) {
  2116. seen.delete(stashed[j]);
  2117. }
  2118. link(state2, a2.prev, b.next);
  2119. link(state2, prev, a2);
  2120. link(state2, b, start);
  2121. current = start;
  2122. prev = b;
  2123. i2 -= 1;
  2124. matched = [];
  2125. stashed = [];
  2126. } else {
  2127. seen.delete(item);
  2128. move(item, current, anchor);
  2129. link(state2, item.prev, item.next);
  2130. link(state2, item, prev === null ? state2.first : prev.next);
  2131. link(state2, prev, item);
  2132. prev = item;
  2133. }
  2134. continue;
  2135. }
  2136. matched = [];
  2137. stashed = [];
  2138. while (current !== null && current.k !== key) {
  2139. if ((current.e.f & INERT) === 0) {
  2140. (seen ?? (seen = /* @__PURE__ */ new Set())).add(current);
  2141. }
  2142. stashed.push(current);
  2143. current = current.next;
  2144. }
  2145. if (current === null) {
  2146. continue;
  2147. }
  2148. item = current;
  2149. }
  2150. matched.push(item);
  2151. prev = item;
  2152. current = item.next;
  2153. }
  2154. if (current !== null || seen !== void 0) {
  2155. var to_destroy = seen === void 0 ? [] : array_from(seen);
  2156. while (current !== null) {
  2157. if ((current.e.f & INERT) === 0) {
  2158. to_destroy.push(current);
  2159. }
  2160. current = current.next;
  2161. }
  2162. var destroy_length = to_destroy.length;
  2163. if (destroy_length > 0) {
  2164. var controlled_anchor = (flags & EACH_IS_CONTROLLED) !== 0 && length === 0 ? anchor : null;
  2165. if (is_animated) {
  2166. for (i2 = 0; i2 < destroy_length; i2 += 1) {
  2167. (_c = to_destroy[i2].a) == null ? void 0 : _c.measure();
  2168. }
  2169. for (i2 = 0; i2 < destroy_length; i2 += 1) {
  2170. (_d = to_destroy[i2].a) == null ? void 0 : _d.fix();
  2171. }
  2172. }
  2173. pause_effects(state2, to_destroy, controlled_anchor, items);
  2174. }
  2175. }
  2176. if (is_animated) {
  2177. queue_micro_task(() => {
  2178. var _a3;
  2179. if (to_animate === void 0) return;
  2180. for (item of to_animate) {
  2181. (_a3 = item.a) == null ? void 0 : _a3.apply();
  2182. }
  2183. });
  2184. }
  2185. active_effect.first = state2.first && state2.first.e;
  2186. active_effect.last = prev && prev.e;
  2187. }
  2188. function update_item(item, value, index2, type) {
  2189. if ((type & EACH_ITEM_REACTIVE) !== 0) {
  2190. internal_set(item.v, value);
  2191. }
  2192. if ((type & EACH_INDEX_REACTIVE) !== 0) {
  2193. internal_set(
  2194. /** @type {Value<number>} */
  2195. item.i,
  2196. index2
  2197. );
  2198. } else {
  2199. item.i = index2;
  2200. }
  2201. }
  2202. function create_item(anchor, state2, prev, next2, value, key, index2, render_fn, flags, get_collection) {
  2203. var reactive = (flags & EACH_ITEM_REACTIVE) !== 0;
  2204. var mutable = (flags & EACH_ITEM_IMMUTABLE) === 0;
  2205. var v = reactive ? mutable ? /* @__PURE__ */ mutable_source(value) : source(value) : value;
  2206. var i2 = (flags & EACH_INDEX_REACTIVE) === 0 ? index2 : source(index2);
  2207. var item = {
  2208. i: i2,
  2209. v,
  2210. k: key,
  2211. a: null,
  2212. // @ts-expect-error
  2213. e: null,
  2214. prev,
  2215. next: next2
  2216. };
  2217. try {
  2218. item.e = branch(() => render_fn(anchor, v, i2, get_collection), hydrating);
  2219. item.e.prev = prev && prev.e;
  2220. item.e.next = next2 && next2.e;
  2221. if (prev === null) {
  2222. state2.first = item;
  2223. } else {
  2224. prev.next = item;
  2225. prev.e.next = item.e;
  2226. }
  2227. if (next2 !== null) {
  2228. next2.prev = item;
  2229. next2.e.prev = item.e;
  2230. }
  2231. return item;
  2232. } finally {
  2233. }
  2234. }
  2235. function move(item, next2, anchor) {
  2236. var end = item.next ? (
  2237. /** @type {TemplateNode} */
  2238. item.next.e.nodes_start
  2239. ) : anchor;
  2240. var dest = next2 ? (
  2241. /** @type {TemplateNode} */
  2242. next2.e.nodes_start
  2243. ) : anchor;
  2244. var node = (
  2245. /** @type {TemplateNode} */
  2246. item.e.nodes_start
  2247. );
  2248. while (node !== end) {
  2249. var next_node = (
  2250. /** @type {TemplateNode} */
  2251. /* @__PURE__ */ get_next_sibling(node)
  2252. );
  2253. dest.before(node);
  2254. node = next_node;
  2255. }
  2256. }
  2257. function link(state2, prev, next2) {
  2258. if (prev === null) {
  2259. state2.first = next2;
  2260. } else {
  2261. prev.next = next2;
  2262. prev.e.next = next2 && next2.e;
  2263. }
  2264. if (next2 !== null) {
  2265. next2.prev = prev;
  2266. next2.e.prev = prev && prev.e;
  2267. }
  2268. }
  2269. function slot(anchor, $$props, name, slot_props, fallback_fn) {
  2270. var _a2;
  2271. var slot_fn = (_a2 = $$props.$$slots) == null ? void 0 : _a2[name];
  2272. var is_interop = false;
  2273. if (slot_fn === true) {
  2274. slot_fn = $$props[name === "default" ? "children" : name];
  2275. is_interop = true;
  2276. }
  2277. if (slot_fn === void 0) {
  2278. if (fallback_fn !== null) {
  2279. fallback_fn(anchor);
  2280. }
  2281. } else {
  2282. slot_fn(anchor, is_interop ? () => slot_props : slot_props);
  2283. }
  2284. }
  2285. function snippet(node, get_snippet, ...args) {
  2286. var anchor = node;
  2287. var snippet2 = noop;
  2288. var snippet_effect;
  2289. block(() => {
  2290. if (snippet2 === (snippet2 = get_snippet())) return;
  2291. if (snippet_effect) {
  2292. destroy_effect(snippet_effect);
  2293. snippet_effect = null;
  2294. }
  2295. snippet_effect = branch(() => (
  2296. /** @type {SnippetFn} */
  2297. snippet2(anchor, ...args)
  2298. ));
  2299. }, EFFECT_TRANSPARENT);
  2300. }
  2301. function component(node, get_component, render_fn) {
  2302. var anchor = node;
  2303. var component2;
  2304. var effect2;
  2305. block(() => {
  2306. if (component2 === (component2 = get_component())) return;
  2307. if (effect2) {
  2308. pause_effect(effect2);
  2309. effect2 = null;
  2310. }
  2311. if (component2) {
  2312. effect2 = branch(() => render_fn(anchor, component2));
  2313. }
  2314. }, EFFECT_TRANSPARENT);
  2315. }
  2316. function r(e) {
  2317. var t, f, n = "";
  2318. if ("string" == typeof e || "number" == typeof e) n += e;
  2319. else if ("object" == typeof e) if (Array.isArray(e)) {
  2320. var o2 = e.length;
  2321. for (t = 0; t < o2; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
  2322. } else for (f in e) e[f] && (n && (n += " "), n += f);
  2323. return n;
  2324. }
  2325. function clsx$1() {
  2326. for (var e, t, f = 0, n = "", o2 = arguments.length; f < o2; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
  2327. return n;
  2328. }
  2329. function clsx(value) {
  2330. if (typeof value === "object") {
  2331. return clsx$1(value);
  2332. } else {
  2333. return value ?? "";
  2334. }
  2335. }
  2336. const whitespace = [..." \n\r\f \v\uFEFF"];
  2337. function to_class(value, hash, directives) {
  2338. var classname = value == null ? "" : "" + value;
  2339. if (hash) {
  2340. classname = classname ? classname + " " + hash : hash;
  2341. }
  2342. if (directives) {
  2343. for (var key in directives) {
  2344. if (directives[key]) {
  2345. classname = classname ? classname + " " + key : key;
  2346. } else if (classname.length) {
  2347. var len = key.length;
  2348. var a2 = 0;
  2349. while ((a2 = classname.indexOf(key, a2)) >= 0) {
  2350. var b = a2 + len;
  2351. if ((a2 === 0 || whitespace.includes(classname[a2 - 1])) && (b === classname.length || whitespace.includes(classname[b]))) {
  2352. classname = (a2 === 0 ? "" : classname.substring(0, a2)) + classname.substring(b + 1);
  2353. } else {
  2354. a2 = b;
  2355. }
  2356. }
  2357. }
  2358. }
  2359. }
  2360. return classname === "" ? null : classname;
  2361. }
  2362. function append_styles(styles, important = false) {
  2363. var separator = important ? " !important;" : ";";
  2364. var css = "";
  2365. for (var key in styles) {
  2366. var value = styles[key];
  2367. if (value != null && value !== "") {
  2368. css += " " + key + ": " + value + separator;
  2369. }
  2370. }
  2371. return css;
  2372. }
  2373. function to_css_name(name) {
  2374. if (name[0] !== "-" || name[1] !== "-") {
  2375. return name.toLowerCase();
  2376. }
  2377. return name;
  2378. }
  2379. function to_style(value, styles) {
  2380. if (styles) {
  2381. var new_style = "";
  2382. var normal_styles;
  2383. var important_styles;
  2384. if (Array.isArray(styles)) {
  2385. normal_styles = styles[0];
  2386. important_styles = styles[1];
  2387. } else {
  2388. normal_styles = styles;
  2389. }
  2390. if (value) {
  2391. value = String(value).replaceAll(/\s*\/\*.*?\*\/\s*/g, "").trim();
  2392. var in_str = false;
  2393. var in_apo = 0;
  2394. var in_comment = false;
  2395. var reserved_names = [];
  2396. if (normal_styles) {
  2397. reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
  2398. }
  2399. if (important_styles) {
  2400. reserved_names.push(...Object.keys(important_styles).map(to_css_name));
  2401. }
  2402. var start_index = 0;
  2403. var name_index = -1;
  2404. const len = value.length;
  2405. for (var i2 = 0; i2 < len; i2++) {
  2406. var c2 = value[i2];
  2407. if (in_comment) {
  2408. if (c2 === "/" && value[i2 - 1] === "*") {
  2409. in_comment = false;
  2410. }
  2411. } else if (in_str) {
  2412. if (in_str === c2) {
  2413. in_str = false;
  2414. }
  2415. } else if (c2 === "/" && value[i2 + 1] === "*") {
  2416. in_comment = true;
  2417. } else if (c2 === '"' || c2 === "'") {
  2418. in_str = c2;
  2419. } else if (c2 === "(") {
  2420. in_apo++;
  2421. } else if (c2 === ")") {
  2422. in_apo--;
  2423. }
  2424. if (!in_comment && in_str === false && in_apo === 0) {
  2425. if (c2 === ":" && name_index === -1) {
  2426. name_index = i2;
  2427. } else if (c2 === ";" || i2 === len - 1) {
  2428. if (name_index !== -1) {
  2429. var name = to_css_name(value.substring(start_index, name_index).trim());
  2430. if (!reserved_names.includes(name)) {
  2431. if (c2 !== ";") {
  2432. i2++;
  2433. }
  2434. var property = value.substring(start_index, i2).trim();
  2435. new_style += " " + property + ";";
  2436. }
  2437. }
  2438. start_index = i2 + 1;
  2439. name_index = -1;
  2440. }
  2441. }
  2442. }
  2443. }
  2444. if (normal_styles) {
  2445. new_style += append_styles(normal_styles);
  2446. }
  2447. if (important_styles) {
  2448. new_style += append_styles(important_styles, true);
  2449. }
  2450. new_style = new_style.trim();
  2451. return new_style === "" ? null : new_style;
  2452. }
  2453. return value == null ? null : String(value);
  2454. }
  2455. function set_class(dom, is_html, value, hash, prev_classes, next_classes) {
  2456. var prev = dom.__className;
  2457. if (prev !== value || prev === void 0) {
  2458. var next_class_name = to_class(value, hash, next_classes);
  2459. {
  2460. if (next_class_name == null) {
  2461. dom.removeAttribute("class");
  2462. } else if (is_html) {
  2463. dom.className = next_class_name;
  2464. } else {
  2465. dom.setAttribute("class", next_class_name);
  2466. }
  2467. }
  2468. dom.__className = value;
  2469. } else if (next_classes && prev_classes !== next_classes) {
  2470. for (var key in next_classes) {
  2471. var is_present = !!next_classes[key];
  2472. if (prev_classes == null || is_present !== !!prev_classes[key]) {
  2473. dom.classList.toggle(key, is_present);
  2474. }
  2475. }
  2476. }
  2477. return next_classes;
  2478. }
  2479. function update_styles(dom, prev = {}, next2, priority) {
  2480. for (var key in next2) {
  2481. var value = next2[key];
  2482. if (prev[key] !== value) {
  2483. if (next2[key] == null) {
  2484. dom.style.removeProperty(key);
  2485. } else {
  2486. dom.style.setProperty(key, value, priority);
  2487. }
  2488. }
  2489. }
  2490. }
  2491. function set_style(dom, value, prev_styles, next_styles) {
  2492. var prev = dom.__style;
  2493. if (prev !== value) {
  2494. var next_style_attr = to_style(value, next_styles);
  2495. {
  2496. if (next_style_attr == null) {
  2497. dom.removeAttribute("style");
  2498. } else {
  2499. dom.style.cssText = next_style_attr;
  2500. }
  2501. }
  2502. dom.__style = value;
  2503. } else if (next_styles) {
  2504. if (Array.isArray(next_styles)) {
  2505. update_styles(dom, prev_styles == null ? void 0 : prev_styles[0], next_styles[0]);
  2506. update_styles(dom, prev_styles == null ? void 0 : prev_styles[1], next_styles[1], "important");
  2507. } else {
  2508. update_styles(dom, prev_styles, next_styles);
  2509. }
  2510. }
  2511. return next_styles;
  2512. }
  2513. const CLASS = Symbol("class");
  2514. const STYLE = Symbol("style");
  2515. const IS_CUSTOM_ELEMENT = Symbol("is custom element");
  2516. const IS_HTML = Symbol("is html");
  2517. function set_selected(element, selected) {
  2518. if (selected) {
  2519. if (!element.hasAttribute("selected")) {
  2520. element.setAttribute("selected", "");
  2521. }
  2522. } else {
  2523. element.removeAttribute("selected");
  2524. }
  2525. }
  2526. function set_attribute(element, attribute, value, skip_warning) {
  2527. var attributes = get_attributes(element);
  2528. if (attributes[attribute] === (attributes[attribute] = value)) return;
  2529. if (attribute === "loading") {
  2530. element[LOADING_ATTR_SYMBOL] = value;
  2531. }
  2532. if (value == null) {
  2533. element.removeAttribute(attribute);
  2534. } else if (typeof value !== "string" && get_setters(element).includes(attribute)) {
  2535. element[attribute] = value;
  2536. } else {
  2537. element.setAttribute(attribute, value);
  2538. }
  2539. }
  2540. function set_attributes(element, prev, next2, css_hash, skip_warning = false) {
  2541. var attributes = get_attributes(element);
  2542. var is_custom_element = attributes[IS_CUSTOM_ELEMENT];
  2543. var preserve_attribute_case = !attributes[IS_HTML];
  2544. var current = prev || {};
  2545. var is_option_element = element.tagName === "OPTION";
  2546. for (var key in prev) {
  2547. if (!(key in next2)) {
  2548. next2[key] = null;
  2549. }
  2550. }
  2551. if (next2.class) {
  2552. next2.class = clsx(next2.class);
  2553. } else if (css_hash || next2[CLASS]) {
  2554. next2.class = null;
  2555. }
  2556. if (next2[STYLE]) {
  2557. next2.style ?? (next2.style = null);
  2558. }
  2559. var setters = get_setters(element);
  2560. for (const key2 in next2) {
  2561. let value = next2[key2];
  2562. if (is_option_element && key2 === "value" && value == null) {
  2563. element.value = element.__value = "";
  2564. current[key2] = value;
  2565. continue;
  2566. }
  2567. if (key2 === "class") {
  2568. var is_html = element.namespaceURI === "http://www.w3.org/1999/xhtml";
  2569. set_class(element, is_html, value, css_hash, prev == null ? void 0 : prev[CLASS], next2[CLASS]);
  2570. current[key2] = value;
  2571. current[CLASS] = next2[CLASS];
  2572. continue;
  2573. }
  2574. if (key2 === "style") {
  2575. set_style(element, value, prev == null ? void 0 : prev[STYLE], next2[STYLE]);
  2576. current[key2] = value;
  2577. current[STYLE] = next2[STYLE];
  2578. continue;
  2579. }
  2580. var prev_value = current[key2];
  2581. if (value === prev_value) continue;
  2582. current[key2] = value;
  2583. var prefix = key2[0] + key2[1];
  2584. if (prefix === "$$") continue;
  2585. if (prefix === "on") {
  2586. const opts = {};
  2587. const event_handle_key = "$$" + key2;
  2588. let event_name = key2.slice(2);
  2589. var delegated = is_delegated(event_name);
  2590. if (is_capture_event(event_name)) {
  2591. event_name = event_name.slice(0, -7);
  2592. opts.capture = true;
  2593. }
  2594. if (!delegated && prev_value) {
  2595. if (value != null) continue;
  2596. element.removeEventListener(event_name, current[event_handle_key], opts);
  2597. current[event_handle_key] = null;
  2598. }
  2599. if (value != null) {
  2600. if (!delegated) {
  2601. let handle = function(evt) {
  2602. current[key2].call(this, evt);
  2603. };
  2604. current[event_handle_key] = create_event(event_name, element, handle, opts);
  2605. } else {
  2606. element[`__${event_name}`] = value;
  2607. delegate([event_name]);
  2608. }
  2609. } else if (delegated) {
  2610. element[`__${event_name}`] = void 0;
  2611. }
  2612. } else if (key2 === "style") {
  2613. set_attribute(element, key2, value);
  2614. } else if (key2 === "autofocus") {
  2615. autofocus(
  2616. /** @type {HTMLElement} */
  2617. element,
  2618. Boolean(value)
  2619. );
  2620. } else if (!is_custom_element && (key2 === "__value" || key2 === "value" && value != null)) {
  2621. element.value = element.__value = value;
  2622. } else if (key2 === "selected" && is_option_element) {
  2623. set_selected(
  2624. /** @type {HTMLOptionElement} */
  2625. element,
  2626. value
  2627. );
  2628. } else {
  2629. var name = key2;
  2630. if (!preserve_attribute_case) {
  2631. name = normalize_attribute(name);
  2632. }
  2633. var is_default = name === "defaultValue" || name === "defaultChecked";
  2634. if (value == null && !is_custom_element && !is_default) {
  2635. attributes[key2] = null;
  2636. if (name === "value" || name === "checked") {
  2637. let input = (
  2638. /** @type {HTMLInputElement} */
  2639. element
  2640. );
  2641. const use_default = prev === void 0;
  2642. if (name === "value") {
  2643. let previous = input.defaultValue;
  2644. input.removeAttribute(name);
  2645. input.defaultValue = previous;
  2646. input.value = input.__value = use_default ? previous : null;
  2647. } else {
  2648. let previous = input.defaultChecked;
  2649. input.removeAttribute(name);
  2650. input.defaultChecked = previous;
  2651. input.checked = use_default ? previous : false;
  2652. }
  2653. } else {
  2654. element.removeAttribute(key2);
  2655. }
  2656. } else if (is_default || setters.includes(name) && (is_custom_element || typeof value !== "string")) {
  2657. element[name] = value;
  2658. } else if (typeof value !== "function") {
  2659. set_attribute(element, name, value);
  2660. }
  2661. }
  2662. }
  2663. return current;
  2664. }
  2665. function get_attributes(element) {
  2666. return (
  2667. /** @type {Record<string | symbol, unknown>} **/
  2668. // @ts-expect-error
  2669. element.__attributes ?? (element.__attributes = {
  2670. [IS_CUSTOM_ELEMENT]: element.nodeName.includes("-"),
  2671. [IS_HTML]: element.namespaceURI === NAMESPACE_HTML
  2672. })
  2673. );
  2674. }
  2675. var setters_cache = /* @__PURE__ */ new Map();
  2676. function get_setters(element) {
  2677. var setters = setters_cache.get(element.nodeName);
  2678. if (setters) return setters;
  2679. setters_cache.set(element.nodeName, setters = []);
  2680. var descriptors;
  2681. var proto = element;
  2682. var element_proto = Element.prototype;
  2683. while (element_proto !== proto) {
  2684. descriptors = get_descriptors(proto);
  2685. for (var key in descriptors) {
  2686. if (descriptors[key].set) {
  2687. setters.push(key);
  2688. }
  2689. }
  2690. proto = get_prototype_of(proto);
  2691. }
  2692. return setters;
  2693. }
  2694. function is_bound_this(bound_value, element_or_component) {
  2695. return bound_value === element_or_component || (bound_value == null ? void 0 : bound_value[STATE_SYMBOL]) === element_or_component;
  2696. }
  2697. function bind_this(element_or_component = {}, update2, get_value, get_parts) {
  2698. effect(() => {
  2699. var old_parts;
  2700. var parts;
  2701. render_effect(() => {
  2702. old_parts = parts;
  2703. parts = [];
  2704. untrack(() => {
  2705. if (element_or_component !== get_value(...parts)) {
  2706. update2(element_or_component, ...parts);
  2707. if (old_parts && is_bound_this(get_value(...old_parts), element_or_component)) {
  2708. update2(null, ...old_parts);
  2709. }
  2710. }
  2711. });
  2712. });
  2713. return () => {
  2714. queue_micro_task(() => {
  2715. if (parts && is_bound_this(get_value(...parts), element_or_component)) {
  2716. update2(null, ...parts);
  2717. }
  2718. });
  2719. };
  2720. });
  2721. return element_or_component;
  2722. }
  2723. function init(immutable = false) {
  2724. const context = (
  2725. /** @type {ComponentContextLegacy} */
  2726. component_context
  2727. );
  2728. const callbacks = context.l.u;
  2729. if (!callbacks) return;
  2730. let props = () => deep_read_state(context.s);
  2731. if (immutable) {
  2732. let version = 0;
  2733. let prev = (
  2734. /** @type {Record<string, any>} */
  2735. {}
  2736. );
  2737. const d = /* @__PURE__ */ derived(() => {
  2738. let changed = false;
  2739. const props2 = context.s;
  2740. for (const key in props2) {
  2741. if (props2[key] !== prev[key]) {
  2742. prev[key] = props2[key];
  2743. changed = true;
  2744. }
  2745. }
  2746. if (changed) version++;
  2747. return version;
  2748. });
  2749. props = () => get$1(d);
  2750. }
  2751. if (callbacks.b.length) {
  2752. user_pre_effect(() => {
  2753. observe_all(context, props);
  2754. run_all(callbacks.b);
  2755. });
  2756. }
  2757. user_effect(() => {
  2758. const fns = untrack(() => callbacks.m.map(run));
  2759. return () => {
  2760. for (const fn of fns) {
  2761. if (typeof fn === "function") {
  2762. fn();
  2763. }
  2764. }
  2765. };
  2766. });
  2767. if (callbacks.a.length) {
  2768. user_effect(() => {
  2769. observe_all(context, props);
  2770. run_all(callbacks.a);
  2771. });
  2772. }
  2773. }
  2774. function observe_all(context, props) {
  2775. if (context.l.s) {
  2776. for (const signal of context.l.s) get$1(signal);
  2777. }
  2778. props();
  2779. }
  2780. function subscribe_to_store(store, run2, invalidate) {
  2781. if (store == null) {
  2782. run2(void 0);
  2783. return noop;
  2784. }
  2785. const unsub = untrack(
  2786. () => store.subscribe(
  2787. run2,
  2788. // @ts-expect-error
  2789. invalidate
  2790. )
  2791. );
  2792. return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
  2793. }
  2794. const subscriber_queue = [];
  2795. function writable(value, start = noop) {
  2796. let stop = null;
  2797. const subscribers = /* @__PURE__ */ new Set();
  2798. function set2(new_value) {
  2799. if (safe_not_equal(value, new_value)) {
  2800. value = new_value;
  2801. if (stop) {
  2802. const run_queue = !subscriber_queue.length;
  2803. for (const subscriber of subscribers) {
  2804. subscriber[1]();
  2805. subscriber_queue.push(subscriber, value);
  2806. }
  2807. if (run_queue) {
  2808. for (let i2 = 0; i2 < subscriber_queue.length; i2 += 2) {
  2809. subscriber_queue[i2][0](subscriber_queue[i2 + 1]);
  2810. }
  2811. subscriber_queue.length = 0;
  2812. }
  2813. }
  2814. }
  2815. }
  2816. function update2(fn) {
  2817. set2(fn(
  2818. /** @type {T} */
  2819. value
  2820. ));
  2821. }
  2822. function subscribe(run2, invalidate = noop) {
  2823. const subscriber = [run2, invalidate];
  2824. subscribers.add(subscriber);
  2825. if (subscribers.size === 1) {
  2826. stop = start(set2, update2) || noop;
  2827. }
  2828. run2(
  2829. /** @type {T} */
  2830. value
  2831. );
  2832. return () => {
  2833. subscribers.delete(subscriber);
  2834. if (subscribers.size === 0 && stop) {
  2835. stop();
  2836. stop = null;
  2837. }
  2838. };
  2839. }
  2840. return { set: set2, update: update2, subscribe };
  2841. }
  2842. function get(store) {
  2843. let value;
  2844. subscribe_to_store(store, (_) => value = _)();
  2845. return value;
  2846. }
  2847. let is_store_binding = false;
  2848. let IS_UNMOUNTED = Symbol();
  2849. function store_get(store, store_name, stores) {
  2850. const entry = stores[store_name] ?? (stores[store_name] = {
  2851. store: null,
  2852. source: /* @__PURE__ */ mutable_source(void 0),
  2853. unsubscribe: noop
  2854. });
  2855. if (entry.store !== store && !(IS_UNMOUNTED in stores)) {
  2856. entry.unsubscribe();
  2857. entry.store = store ?? null;
  2858. if (store == null) {
  2859. entry.source.v = void 0;
  2860. entry.unsubscribe = noop;
  2861. } else {
  2862. var is_synchronous_callback = true;
  2863. entry.unsubscribe = subscribe_to_store(store, (v) => {
  2864. if (is_synchronous_callback) {
  2865. entry.source.v = v;
  2866. } else {
  2867. set(entry.source, v);
  2868. }
  2869. });
  2870. is_synchronous_callback = false;
  2871. }
  2872. }
  2873. if (store && IS_UNMOUNTED in stores) {
  2874. return get(store);
  2875. }
  2876. return get$1(entry.source);
  2877. }
  2878. function store_unsub(store, store_name, stores) {
  2879. let entry = stores[store_name];
  2880. if (entry && entry.store !== store) {
  2881. entry.unsubscribe();
  2882. entry.unsubscribe = noop;
  2883. }
  2884. return store;
  2885. }
  2886. function setup_stores() {
  2887. const stores = {};
  2888. function cleanup() {
  2889. teardown(() => {
  2890. for (var store_name in stores) {
  2891. const ref = stores[store_name];
  2892. ref.unsubscribe();
  2893. }
  2894. define_property(stores, IS_UNMOUNTED, {
  2895. enumerable: false,
  2896. value: true
  2897. });
  2898. });
  2899. }
  2900. return [stores, cleanup];
  2901. }
  2902. function capture_store_binding(fn) {
  2903. var previous_is_store_binding = is_store_binding;
  2904. try {
  2905. is_store_binding = false;
  2906. return [fn(), is_store_binding];
  2907. } finally {
  2908. is_store_binding = previous_is_store_binding;
  2909. }
  2910. }
  2911. const rest_props_handler = {
  2912. get(target, key) {
  2913. if (target.exclude.includes(key)) return;
  2914. return target.props[key];
  2915. },
  2916. set(target, key) {
  2917. return false;
  2918. },
  2919. getOwnPropertyDescriptor(target, key) {
  2920. if (target.exclude.includes(key)) return;
  2921. if (key in target.props) {
  2922. return {
  2923. enumerable: true,
  2924. configurable: true,
  2925. value: target.props[key]
  2926. };
  2927. }
  2928. },
  2929. has(target, key) {
  2930. if (target.exclude.includes(key)) return false;
  2931. return key in target.props;
  2932. },
  2933. ownKeys(target) {
  2934. return Reflect.ownKeys(target.props).filter((key) => !target.exclude.includes(key));
  2935. }
  2936. };
  2937. // @__NO_SIDE_EFFECTS__
  2938. function rest_props(props, exclude, name) {
  2939. return new Proxy(
  2940. { props, exclude },
  2941. rest_props_handler
  2942. );
  2943. }
  2944. const legacy_rest_props_handler = {
  2945. get(target, key) {
  2946. if (target.exclude.includes(key)) return;
  2947. get$1(target.version);
  2948. return key in target.special ? target.special[key]() : target.props[key];
  2949. },
  2950. set(target, key, value) {
  2951. if (!(key in target.special)) {
  2952. target.special[key] = prop(
  2953. {
  2954. get [key]() {
  2955. return target.props[key];
  2956. }
  2957. },
  2958. /** @type {string} */
  2959. key,
  2960. PROPS_IS_UPDATED
  2961. );
  2962. }
  2963. target.special[key](value);
  2964. update(target.version);
  2965. return true;
  2966. },
  2967. getOwnPropertyDescriptor(target, key) {
  2968. if (target.exclude.includes(key)) return;
  2969. if (key in target.props) {
  2970. return {
  2971. enumerable: true,
  2972. configurable: true,
  2973. value: target.props[key]
  2974. };
  2975. }
  2976. },
  2977. deleteProperty(target, key) {
  2978. if (target.exclude.includes(key)) return true;
  2979. target.exclude.push(key);
  2980. update(target.version);
  2981. return true;
  2982. },
  2983. has(target, key) {
  2984. if (target.exclude.includes(key)) return false;
  2985. return key in target.props;
  2986. },
  2987. ownKeys(target) {
  2988. return Reflect.ownKeys(target.props).filter((key) => !target.exclude.includes(key));
  2989. }
  2990. };
  2991. function legacy_rest_props(props, exclude) {
  2992. return new Proxy({ props, exclude, special: {}, version: source(0) }, legacy_rest_props_handler);
  2993. }
  2994. const spread_props_handler = {
  2995. get(target, key) {
  2996. let i2 = target.props.length;
  2997. while (i2--) {
  2998. let p = target.props[i2];
  2999. if (is_function(p)) p = p();
  3000. if (typeof p === "object" && p !== null && key in p) return p[key];
  3001. }
  3002. },
  3003. set(target, key, value) {
  3004. let i2 = target.props.length;
  3005. while (i2--) {
  3006. let p = target.props[i2];
  3007. if (is_function(p)) p = p();
  3008. const desc = get_descriptor(p, key);
  3009. if (desc && desc.set) {
  3010. desc.set(value);
  3011. return true;
  3012. }
  3013. }
  3014. return false;
  3015. },
  3016. getOwnPropertyDescriptor(target, key) {
  3017. let i2 = target.props.length;
  3018. while (i2--) {
  3019. let p = target.props[i2];
  3020. if (is_function(p)) p = p();
  3021. if (typeof p === "object" && p !== null && key in p) {
  3022. const descriptor = get_descriptor(p, key);
  3023. if (descriptor && !descriptor.configurable) {
  3024. descriptor.configurable = true;
  3025. }
  3026. return descriptor;
  3027. }
  3028. }
  3029. },
  3030. has(target, key) {
  3031. if (key === STATE_SYMBOL || key === LEGACY_PROPS) return false;
  3032. for (let p of target.props) {
  3033. if (is_function(p)) p = p();
  3034. if (p != null && key in p) return true;
  3035. }
  3036. return false;
  3037. },
  3038. ownKeys(target) {
  3039. const keys = [];
  3040. for (let p of target.props) {
  3041. if (is_function(p)) p = p();
  3042. for (const key in p) {
  3043. if (!keys.includes(key)) keys.push(key);
  3044. }
  3045. }
  3046. return keys;
  3047. }
  3048. };
  3049. function spread_props(...props) {
  3050. return new Proxy({ props }, spread_props_handler);
  3051. }
  3052. function has_destroyed_component_ctx(current_value) {
  3053. var _a2;
  3054. return ((_a2 = current_value.ctx) == null ? void 0 : _a2.d) ?? false;
  3055. }
  3056. function prop(props, key, flags, fallback) {
  3057. var _a2;
  3058. var immutable = (flags & PROPS_IS_IMMUTABLE) !== 0;
  3059. var runes = !legacy_mode_flag || (flags & PROPS_IS_RUNES) !== 0;
  3060. var bindable = (flags & PROPS_IS_BINDABLE) !== 0;
  3061. var lazy = (flags & PROPS_IS_LAZY_INITIAL) !== 0;
  3062. var is_store_sub = false;
  3063. var prop_value;
  3064. if (bindable) {
  3065. [prop_value, is_store_sub] = capture_store_binding(() => (
  3066. /** @type {V} */
  3067. props[key]
  3068. ));
  3069. } else {
  3070. prop_value = /** @type {V} */
  3071. props[key];
  3072. }
  3073. var is_entry_props = STATE_SYMBOL in props || LEGACY_PROPS in props;
  3074. var setter = bindable && (((_a2 = get_descriptor(props, key)) == null ? void 0 : _a2.set) ?? (is_entry_props && key in props && ((v) => props[key] = v))) || void 0;
  3075. var fallback_value = (
  3076. /** @type {V} */
  3077. fallback
  3078. );
  3079. var fallback_dirty = true;
  3080. var fallback_used = false;
  3081. var get_fallback = () => {
  3082. fallback_used = true;
  3083. if (fallback_dirty) {
  3084. fallback_dirty = false;
  3085. if (lazy) {
  3086. fallback_value = untrack(
  3087. /** @type {() => V} */
  3088. fallback
  3089. );
  3090. } else {
  3091. fallback_value = /** @type {V} */
  3092. fallback;
  3093. }
  3094. }
  3095. return fallback_value;
  3096. };
  3097. if (prop_value === void 0 && fallback !== void 0) {
  3098. if (setter && runes) {
  3099. props_invalid_value();
  3100. }
  3101. prop_value = get_fallback();
  3102. if (setter) setter(prop_value);
  3103. }
  3104. var getter;
  3105. if (runes) {
  3106. getter = () => {
  3107. var value = (
  3108. /** @type {V} */
  3109. props[key]
  3110. );
  3111. if (value === void 0) return get_fallback();
  3112. fallback_dirty = true;
  3113. fallback_used = false;
  3114. return value;
  3115. };
  3116. } else {
  3117. var derived_getter = (immutable ? derived : derived_safe_equal)(
  3118. () => (
  3119. /** @type {V} */
  3120. props[key]
  3121. )
  3122. );
  3123. derived_getter.f |= LEGACY_DERIVED_PROP;
  3124. getter = () => {
  3125. var value = get$1(derived_getter);
  3126. if (value !== void 0) fallback_value = /** @type {V} */
  3127. void 0;
  3128. return value === void 0 ? fallback_value : value;
  3129. };
  3130. }
  3131. if ((flags & PROPS_IS_UPDATED) === 0) {
  3132. return getter;
  3133. }
  3134. if (setter) {
  3135. var legacy_parent = props.$$legacy;
  3136. return function(value, mutation) {
  3137. if (arguments.length > 0) {
  3138. if (!runes || !mutation || legacy_parent || is_store_sub) {
  3139. setter(mutation ? getter() : value);
  3140. }
  3141. return value;
  3142. } else {
  3143. return getter();
  3144. }
  3145. };
  3146. }
  3147. var from_child = false;
  3148. var inner_current_value = /* @__PURE__ */ mutable_source(prop_value);
  3149. var current_value = /* @__PURE__ */ derived(() => {
  3150. var parent_value = getter();
  3151. var child_value = get$1(inner_current_value);
  3152. if (from_child) {
  3153. from_child = false;
  3154. return child_value;
  3155. }
  3156. return inner_current_value.v = parent_value;
  3157. });
  3158. if (bindable) {
  3159. get$1(current_value);
  3160. }
  3161. if (!immutable) current_value.equals = safe_equals;
  3162. return function(value, mutation) {
  3163. if (arguments.length > 0) {
  3164. const new_value = mutation ? get$1(current_value) : runes && bindable ? proxy(value) : value;
  3165. if (!current_value.equals(new_value)) {
  3166. from_child = true;
  3167. set(inner_current_value, new_value);
  3168. if (fallback_used && fallback_value !== void 0) {
  3169. fallback_value = new_value;
  3170. }
  3171. if (has_destroyed_component_ctx(current_value)) {
  3172. return value;
  3173. }
  3174. untrack(() => get$1(current_value));
  3175. }
  3176. return value;
  3177. }
  3178. if (has_destroyed_component_ctx(current_value)) {
  3179. return current_value.v;
  3180. }
  3181. return get$1(current_value);
  3182. };
  3183. }
  3184. function onMount(fn) {
  3185. if (component_context === null) {
  3186. lifecycle_outside_component();
  3187. }
  3188. if (legacy_mode_flag && component_context.l !== null) {
  3189. init_update_callbacks(component_context).m.push(fn);
  3190. } else {
  3191. user_effect(() => {
  3192. const cleanup = untrack(fn);
  3193. if (typeof cleanup === "function") return (
  3194. /** @type {() => void} */
  3195. cleanup
  3196. );
  3197. });
  3198. }
  3199. }
  3200. function onDestroy(fn) {
  3201. if (component_context === null) {
  3202. lifecycle_outside_component();
  3203. }
  3204. onMount(() => () => untrack(fn));
  3205. }
  3206. function init_update_callbacks(context) {
  3207. var l = (
  3208. /** @type {ComponentContextLegacy} */
  3209. context.l
  3210. );
  3211. return l.u ?? (l.u = { a: [], b: [], m: [] });
  3212. }
  3213. const PUBLIC_VERSION = "5";
  3214. if (typeof window !== "undefined") {
  3215. ((_a = window.__svelte ?? (window.__svelte = {})).v ?? (_a.v = /* @__PURE__ */ new Set())).add(PUBLIC_VERSION);
  3216. }
  3217. enable_legacy_mode_flag();
  3218. var root$4 = /* @__PURE__ */ template(`<button><!></button>`);
  3219. function Button($$anchor, $$props) {
  3220. let restProps = /* @__PURE__ */ rest_props($$props, [
  3221. "$$slots",
  3222. "$$events",
  3223. "$$legacy",
  3224. "children"
  3225. ]);
  3226. var button = root$4();
  3227. let attributes;
  3228. var node = child(button);
  3229. snippet(node, () => $$props.children ?? noop);
  3230. template_effect(() => attributes = set_attributes(button, attributes, {
  3231. class: "relative inline-flex items-center justify-center text-caption px-2 py-1 gap-1 rounded-full bg-fill-secondary cursor-pointer transition-colors hover:bg-fill-primary hover:text-text-primary text-sd-secondary-foreground hover:opacity-80",
  3232. ...restProps
  3233. }));
  3234. append($$anchor, button);
  3235. }
  3236. var root_1$3 = /* @__PURE__ */ ns_template(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z" clip-rule="evenodd"></path></svg>`);
  3237. var root_3$1 = /* @__PURE__ */ ns_template(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z" clip-rule="evenodd"></path></svg>`);
  3238. var root_5 = /* @__PURE__ */ ns_template(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" height="20" width="20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z" clip-rule="evenodd"></path></svg>`);
  3239. var root_7 = /* @__PURE__ */ ns_template(`<svg viewBox="0 0 64 64" fill="currentColor" height="20" width="20" xmlns="http://www.w3.org/2000/svg"><path d="M32.427,7.987c2.183,0.124 4,1.165 5.096,3.281l17.936,36.208c1.739,3.66 -0.954,8.585 -5.373,8.656l-36.119,0c-4.022,-0.064 -7.322,-4.631 -5.352,-8.696l18.271,-36.207c0.342,-0.65 0.498,-0.838 0.793,-1.179c1.186,-1.375 2.483,-2.111 4.748,-2.063Zm-0.295,3.997c-0.687,0.034 -1.316,0.419 -1.659,1.017c-6.312,11.979 -12.397,24.081 -18.301,36.267c-0.546,1.225 0.391,2.797 1.762,2.863c12.06,0.195 24.125,0.195 36.185,0c1.325,-0.064 2.321,-1.584 1.769,-2.85c-5.793,-12.184 -11.765,-24.286 -17.966,-36.267c-0.366,-0.651 -0.903,-1.042 -1.79,-1.03Z"></path><path d="M33.631,40.581l-3.348,0l-0.368,-16.449l4.1,0l-0.384,16.449Zm-3.828,5.03c0,-0.609 0.197,-1.113 0.592,-1.514c0.396,-0.4 0.935,-0.601 1.618,-0.601c0.684,0 1.223,0.201 1.618,0.601c0.395,0.401 0.593,0.905 0.593,1.514c0,0.587 -0.193,1.078 -0.577,1.473c-0.385,0.395 -0.929,0.593 -1.634,0.593c-0.705,0 -1.249,-0.198 -1.634,-0.593c-0.384,-0.395 -0.576,-0.886 -0.576,-1.473Z"></path></svg>`);
  3240. function Icon($$anchor, $$props) {
  3241. let type = prop($$props, "type", 8, "success");
  3242. var fragment = comment();
  3243. var node = first_child(fragment);
  3244. {
  3245. var consequent = ($$anchor2) => {
  3246. var svg = root_1$3();
  3247. append($$anchor2, svg);
  3248. };
  3249. var alternate = ($$anchor2, $$elseif) => {
  3250. {
  3251. var consequent_1 = ($$anchor3) => {
  3252. var svg_1 = root_3$1();
  3253. append($$anchor3, svg_1);
  3254. };
  3255. var alternate_1 = ($$anchor3, $$elseif2) => {
  3256. {
  3257. var consequent_2 = ($$anchor4) => {
  3258. var svg_2 = root_5();
  3259. append($$anchor4, svg_2);
  3260. };
  3261. var alternate_2 = ($$anchor4, $$elseif3) => {
  3262. {
  3263. var consequent_3 = ($$anchor5) => {
  3264. var svg_3 = root_7();
  3265. append($$anchor5, svg_3);
  3266. };
  3267. var alternate_3 = ($$anchor5) => {
  3268. };
  3269. if_block(
  3270. $$anchor4,
  3271. ($$render) => {
  3272. if (type() === "warning") $$render(consequent_3);
  3273. else $$render(alternate_3, false);
  3274. },
  3275. $$elseif3
  3276. );
  3277. }
  3278. };
  3279. if_block(
  3280. $$anchor3,
  3281. ($$render) => {
  3282. if (type() === "info") $$render(consequent_2);
  3283. else $$render(alternate_2, false);
  3284. },
  3285. $$elseif2
  3286. );
  3287. }
  3288. };
  3289. if_block(
  3290. $$anchor2,
  3291. ($$render) => {
  3292. if (type() === "error") $$render(consequent_1);
  3293. else $$render(alternate_1, false);
  3294. },
  3295. $$elseif
  3296. );
  3297. }
  3298. };
  3299. if_block(node, ($$render) => {
  3300. if (type() === "success") $$render(consequent);
  3301. else $$render(alternate, false);
  3302. });
  3303. }
  3304. append($$anchor, fragment);
  3305. }
  3306. var root_1$2 = /* @__PURE__ */ template(`<div class="sonner-loading-bar"></div>`);
  3307. var root$3 = /* @__PURE__ */ template(`<div class="sonner-loading-wrapper"><div class="sonner-spinner"></div></div>`);
  3308. function Loader($$anchor, $$props) {
  3309. push($$props, false);
  3310. let visible = prop($$props, "visible", 8);
  3311. const bars = Array(12).fill(0);
  3312. init();
  3313. var div = root$3();
  3314. var div_1 = child(div);
  3315. each(div_1, 5, () => bars, index, ($$anchor2, _) => {
  3316. var div_2 = root_1$2();
  3317. append($$anchor2, div_2);
  3318. });
  3319. template_effect(() => set_attribute(div, "data-visible", visible()));
  3320. append($$anchor, div);
  3321. pop();
  3322. }
  3323. function cn(...classes) {
  3324. return classes.filter(Boolean).join(" ");
  3325. }
  3326. const isBrowser = typeof document !== "undefined";
  3327. function clientWritable(initialValue) {
  3328. const store = writable(initialValue);
  3329. function set2(value) {
  3330. if (isBrowser) {
  3331. store.set(value);
  3332. }
  3333. }
  3334. function update2(updater) {
  3335. if (isBrowser) {
  3336. store.update(updater);
  3337. }
  3338. }
  3339. return {
  3340. subscribe: store.subscribe,
  3341. set: set2,
  3342. update: update2
  3343. };
  3344. }
  3345. let toastsCounter = 0;
  3346. function createToastState() {
  3347. const toasts = clientWritable([]);
  3348. const heights = clientWritable([]);
  3349. function addToast(data) {
  3350. toasts.update((prev) => [data, ...prev]);
  3351. }
  3352. function create(data) {
  3353. var _a2;
  3354. const { message: message2, ...rest } = data;
  3355. const id = typeof (data == null ? void 0 : data.id) === "number" || data.id && ((_a2 = data.id) == null ? void 0 : _a2.length) > 0 ? data.id : toastsCounter++;
  3356. const dismissable = data.dismissable === void 0 ? true : data.dismissable;
  3357. const type = data.type === void 0 ? "default" : data.type;
  3358. const $toasts = get(toasts);
  3359. const alreadyExists = $toasts.find((toast2) => {
  3360. return toast2.id === id;
  3361. });
  3362. if (alreadyExists) {
  3363. toasts.update((prev) => prev.map((toast2) => {
  3364. if (toast2.id === id) {
  3365. return {
  3366. ...toast2,
  3367. ...data,
  3368. id,
  3369. title: message2,
  3370. dismissable,
  3371. type,
  3372. updated: true
  3373. };
  3374. }
  3375. return {
  3376. ...toast2,
  3377. updated: false
  3378. };
  3379. }));
  3380. } else {
  3381. addToast({ ...rest, id, title: message2, dismissable, type });
  3382. }
  3383. return id;
  3384. }
  3385. function dismiss(id) {
  3386. if (id === void 0) {
  3387. toasts.update((prev) => prev.map((toast2) => ({ ...toast2, dismiss: true })));
  3388. return;
  3389. }
  3390. toasts.update((prev) => prev.map((toast2) => toast2.id === id ? { ...toast2, dismiss: true } : toast2));
  3391. return id;
  3392. }
  3393. function remove2(id) {
  3394. if (id === void 0) {
  3395. toasts.set([]);
  3396. return;
  3397. }
  3398. toasts.update((prev) => prev.filter((toast2) => toast2.id !== id));
  3399. return id;
  3400. }
  3401. function message(message2, data) {
  3402. return create({ ...data, type: "default", message: message2 });
  3403. }
  3404. function error(message2, data) {
  3405. return create({ ...data, type: "error", message: message2 });
  3406. }
  3407. function success(message2, data) {
  3408. return create({ ...data, type: "success", message: message2 });
  3409. }
  3410. function info(message2, data) {
  3411. return create({ ...data, type: "info", message: message2 });
  3412. }
  3413. function warning(message2, data) {
  3414. return create({ ...data, type: "warning", message: message2 });
  3415. }
  3416. function loading(message2, data) {
  3417. return create({ ...data, type: "loading", message: message2 });
  3418. }
  3419. function promise(promise2, data) {
  3420. if (!data) {
  3421. return;
  3422. }
  3423. let id = void 0;
  3424. if (data.loading !== void 0) {
  3425. id = create({
  3426. ...data,
  3427. promise: promise2,
  3428. type: "loading",
  3429. message: data.loading
  3430. });
  3431. }
  3432. const p = promise2 instanceof Promise ? promise2 : promise2();
  3433. let shouldDismiss = id !== void 0;
  3434. p.then((response) => {
  3435. if (response && typeof response.ok === "boolean" && !response.ok) {
  3436. shouldDismiss = false;
  3437. const message2 = typeof data.error === "function" ? (
  3438. // @ts-expect-error: Incorrect response type
  3439. data.error(`HTTP error! status: ${response.status}`)
  3440. ) : data.error;
  3441. create({ id, type: "error", message: message2 });
  3442. } else if (data.success !== void 0) {
  3443. shouldDismiss = false;
  3444. const message2 = (
  3445. // @ts-expect-error: TODO: Better function checking
  3446. typeof data.success === "function" ? data.success(response) : data.success
  3447. );
  3448. create({ id, type: "success", message: message2 });
  3449. }
  3450. }).catch((error2) => {
  3451. if (data.error !== void 0) {
  3452. shouldDismiss = false;
  3453. const message2 = (
  3454. // @ts-expect-error: TODO: Better function checking
  3455. typeof data.error === "function" ? data.error(error2) : data.error
  3456. );
  3457. create({ id, type: "error", message: message2 });
  3458. }
  3459. }).finally(() => {
  3460. var _a2;
  3461. if (shouldDismiss) {
  3462. dismiss(id);
  3463. id = void 0;
  3464. }
  3465. (_a2 = data.finally) == null ? void 0 : _a2.call(data);
  3466. });
  3467. return id;
  3468. }
  3469. function custom(component2, data) {
  3470. const id = (data == null ? void 0 : data.id) || toastsCounter++;
  3471. create({ component: component2, id, ...data });
  3472. return id;
  3473. }
  3474. function removeHeight(id) {
  3475. heights.update((prev) => prev.filter((height) => height.toastId !== id));
  3476. }
  3477. function setHeight(data) {
  3478. const exists = get(heights).find((el) => el.toastId === data.toastId);
  3479. if (exists === void 0) {
  3480. heights.update((prev) => [data, ...prev]);
  3481. return;
  3482. }
  3483. heights.update((prev) => prev.map((el) => {
  3484. if (el.toastId === data.toastId) {
  3485. return data;
  3486. } else {
  3487. return el;
  3488. }
  3489. }));
  3490. }
  3491. function reset() {
  3492. toasts.set([]);
  3493. heights.set([]);
  3494. }
  3495. return {
  3496. // methods
  3497. create,
  3498. addToast,
  3499. dismiss,
  3500. remove: remove2,
  3501. message,
  3502. error,
  3503. success,
  3504. info,
  3505. warning,
  3506. loading,
  3507. promise,
  3508. custom,
  3509. removeHeight,
  3510. setHeight,
  3511. reset,
  3512. // stores
  3513. toasts,
  3514. heights
  3515. };
  3516. }
  3517. const toastState = createToastState();
  3518. function toastFunction(message, data) {
  3519. return toastState.create({
  3520. message,
  3521. ...data
  3522. });
  3523. }
  3524. const basicToast = toastFunction;
  3525. const toast = Object.assign(basicToast, {
  3526. success: toastState.success,
  3527. info: toastState.info,
  3528. warning: toastState.warning,
  3529. error: toastState.error,
  3530. custom: toastState.custom,
  3531. message: toastState.message,
  3532. promise: toastState.promise,
  3533. dismiss: toastState.dismiss,
  3534. loading: toastState.loading
  3535. });
  3536. const useEffect = (subscribe) => ({ subscribe });
  3537. var root_1$1 = /* @__PURE__ */ template(`<button aria-label="Close toast" data-close-button=""><svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg></button>`);
  3538. var root_4 = /* @__PURE__ */ template(`<div data-icon=""><!> <!></div>`);
  3539. var root_15 = /* @__PURE__ */ template(`<div data-title=""><!></div>`);
  3540. var root_18 = /* @__PURE__ */ template(`<div data-description=""><!></div>`);
  3541. var root_21 = /* @__PURE__ */ template(`<button data-button="" data-cancel=""> </button>`);
  3542. var root_22 = /* @__PURE__ */ template(`<button data-button=""> </button>`);
  3543. var root_3 = /* @__PURE__ */ template(`<!> <div data-content=""><!> <!></div> <!> <!>`, 1);
  3544. var root$2 = /* @__PURE__ */ template(`<li aria-atomic="true" role="status" data-sonner-toast=""><!> <!></li>`);
  3545. function Toast($$anchor, $$props) {
  3546. const $$sanitized_props = legacy_rest_props($$props, [
  3547. "children",
  3548. "$$slots",
  3549. "$$events",
  3550. "$$legacy"
  3551. ]);
  3552. push($$props, false);
  3553. const [$$stores, $$cleanup] = setup_stores();
  3554. const $heights = () => store_get(heights, "$heights", $$stores);
  3555. const $effect = () => store_get(get$1(effect2), "$effect", $$stores);
  3556. const $toasts = () => store_get(toasts, "$toasts", $$stores);
  3557. const isFront = /* @__PURE__ */ mutable_source(void 0, true);
  3558. const isVisible = /* @__PURE__ */ mutable_source(void 0, true);
  3559. const toastTitle = /* @__PURE__ */ mutable_source(void 0, true);
  3560. const toastDescription = /* @__PURE__ */ mutable_source(void 0, true);
  3561. const toastType = /* @__PURE__ */ mutable_source(void 0, true);
  3562. const toastClass = /* @__PURE__ */ mutable_source(void 0, true);
  3563. const toastDescriptionClass = /* @__PURE__ */ mutable_source(void 0, true);
  3564. const heightIndex = /* @__PURE__ */ mutable_source(void 0, true);
  3565. const coords = /* @__PURE__ */ mutable_source(void 0, true);
  3566. const toastsHeightBefore = /* @__PURE__ */ mutable_source(void 0, true);
  3567. const disabled = /* @__PURE__ */ mutable_source(void 0, true);
  3568. const isPromiseLoadingOrInfiniteDuration = /* @__PURE__ */ mutable_source(void 0, true);
  3569. const TOAST_LIFETIME = 4e3;
  3570. const GAP = 14;
  3571. const SWIPE_TRESHOLD = 20;
  3572. const TIME_BEFORE_UNMOUNT = 200;
  3573. const SCALE_MULTIPLIER = 0.05;
  3574. const defaultClasses = {
  3575. toast: "",
  3576. title: "",
  3577. description: "",
  3578. loader: "",
  3579. closeButton: "",
  3580. cancelButton: "",
  3581. actionButton: "",
  3582. action: "",
  3583. warning: "",
  3584. error: "",
  3585. success: "",
  3586. default: "",
  3587. info: "",
  3588. loading: ""
  3589. };
  3590. const {
  3591. toasts,
  3592. heights,
  3593. removeHeight,
  3594. setHeight,
  3595. remove: remove2
  3596. } = toastState;
  3597. let toast2 = prop($$props, "toast", 9);
  3598. let index2 = prop($$props, "index", 9);
  3599. let expanded = prop($$props, "expanded", 9);
  3600. let invert = prop($$props, "invert", 13);
  3601. let position = prop($$props, "position", 9);
  3602. let visibleToasts = prop($$props, "visibleToasts", 9);
  3603. let expandByDefault = prop($$props, "expandByDefault", 9);
  3604. let closeButton = prop($$props, "closeButton", 9);
  3605. let interacting = prop($$props, "interacting", 9);
  3606. let cancelButtonStyle = prop($$props, "cancelButtonStyle", 9, "");
  3607. let actionButtonStyle = prop($$props, "actionButtonStyle", 9, "");
  3608. let duration = prop($$props, "duration", 9, 4e3);
  3609. let descriptionClass = prop($$props, "descriptionClass", 9, "");
  3610. let classes = prop($$props, "classes", 29, () => ({}));
  3611. let unstyled = prop($$props, "unstyled", 9, false);
  3612. let mounted = /* @__PURE__ */ mutable_source(false, true);
  3613. let removed = /* @__PURE__ */ mutable_source(false, true);
  3614. let swiping = /* @__PURE__ */ mutable_source(false, true);
  3615. let swipeOut = /* @__PURE__ */ mutable_source(false, true);
  3616. let offsetBeforeRemove = /* @__PURE__ */ mutable_source(0, true);
  3617. let initialHeight = /* @__PURE__ */ mutable_source(0, true);
  3618. let toastRef = /* @__PURE__ */ mutable_source(void 0, true);
  3619. let offset = /* @__PURE__ */ mutable_source(0, true);
  3620. let closeTimerStartTimeRef = 0;
  3621. let lastCloseTimerStartTimeRef = 0;
  3622. let pointerStartRef = null;
  3623. async function updateHeights() {
  3624. if (!get$1(mounted)) {
  3625. return;
  3626. }
  3627. await tick();
  3628. let scale;
  3629. if (expanded() || expandByDefault()) {
  3630. scale = 1;
  3631. } else {
  3632. scale = 1 - index2() * SCALE_MULTIPLIER;
  3633. }
  3634. get$1(toastRef).style.setProperty("height", "auto");
  3635. const offsetHeight = get$1(toastRef).offsetHeight;
  3636. const rectHeight = get$1(toastRef).getBoundingClientRect().height;
  3637. const scaledRectHeight = Math.round((rectHeight / scale + Number.EPSILON) * 100) / 100;
  3638. get$1(toastRef).style.removeProperty("height");
  3639. let finalHeight;
  3640. if (Math.abs(scaledRectHeight - offsetHeight) < 1) {
  3641. finalHeight = scaledRectHeight;
  3642. } else {
  3643. finalHeight = offsetHeight;
  3644. }
  3645. set(initialHeight, finalHeight);
  3646. setHeight({ toastId: toast2().id, height: finalHeight });
  3647. }
  3648. function deleteToast() {
  3649. set(removed, true);
  3650. set(offsetBeforeRemove, get$1(offset));
  3651. removeHeight(toast2().id);
  3652. setTimeout(
  3653. () => {
  3654. remove2(toast2().id);
  3655. },
  3656. TIME_BEFORE_UNMOUNT
  3657. );
  3658. }
  3659. let timeoutId = /* @__PURE__ */ mutable_source(void 0, true);
  3660. let remainingTime = /* @__PURE__ */ mutable_source(toast2().duration || duration() || TOAST_LIFETIME, true);
  3661. function pauseTimer() {
  3662. if (lastCloseTimerStartTimeRef < closeTimerStartTimeRef) {
  3663. const elapsedTime = (/* @__PURE__ */ new Date()).getTime() - closeTimerStartTimeRef;
  3664. set(remainingTime, get$1(remainingTime) - elapsedTime);
  3665. }
  3666. lastCloseTimerStartTimeRef = (/* @__PURE__ */ new Date()).getTime();
  3667. }
  3668. function startTimer() {
  3669. closeTimerStartTimeRef = (/* @__PURE__ */ new Date()).getTime();
  3670. set(timeoutId, setTimeout(
  3671. () => {
  3672. var _a2, _b2;
  3673. (_b2 = (_a2 = toast2()).onAutoClose) == null ? void 0 : _b2.call(_a2, toast2());
  3674. deleteToast();
  3675. },
  3676. get$1(remainingTime)
  3677. ));
  3678. }
  3679. let effect2 = /* @__PURE__ */ mutable_source(void 0, true);
  3680. onMount(() => {
  3681. set(mounted, true);
  3682. const height = get$1(toastRef).getBoundingClientRect().height;
  3683. set(initialHeight, height);
  3684. setHeight({ toastId: toast2().id, height });
  3685. return () => removeHeight(toast2().id);
  3686. });
  3687. function onPointerDown(event2) {
  3688. if (get$1(disabled)) {
  3689. return;
  3690. }
  3691. set(offsetBeforeRemove, get$1(offset));
  3692. const target = event2.target;
  3693. target.setPointerCapture(event2.pointerId);
  3694. if (target.tagName === "BUTTON") {
  3695. return;
  3696. }
  3697. set(swiping, true);
  3698. pointerStartRef = { x: event2.clientX, y: event2.clientY };
  3699. }
  3700. function onPointerUp() {
  3701. var _a2, _b2, _c;
  3702. if (get$1(swipeOut)) {
  3703. return;
  3704. }
  3705. pointerStartRef = null;
  3706. const swipeAmount = Number(((_a2 = get$1(toastRef)) == null ? void 0 : _a2.style.getPropertyValue("--swipe-amount").replace("px", "")) || 0);
  3707. if (Math.abs(swipeAmount) >= SWIPE_TRESHOLD) {
  3708. set(offsetBeforeRemove, get$1(offset));
  3709. (_c = (_b2 = toast2()).onDismiss) == null ? void 0 : _c.call(_b2, toast2());
  3710. deleteToast();
  3711. set(swipeOut, true);
  3712. return;
  3713. }
  3714. get$1(toastRef).style.setProperty("--swipe-amount", "0px");
  3715. set(swiping, false);
  3716. }
  3717. function onPointerMove(event2) {
  3718. if (!pointerStartRef) {
  3719. return;
  3720. }
  3721. const yPosition = event2.clientY - pointerStartRef.y;
  3722. const xPosition = event2.clientX - pointerStartRef.x;
  3723. const clamp = get$1(coords)[0] === "top" ? Math.min : Math.max;
  3724. const clampedY = clamp(0, yPosition);
  3725. const swipeStartThreshold = event2.pointerType === "touch" ? 10 : 2;
  3726. const isAllowedToSwipe = Math.abs(clampedY) > swipeStartThreshold;
  3727. if (isAllowedToSwipe) {
  3728. get$1(toastRef).style.setProperty("--swipe-amount", `${yPosition}px`);
  3729. } else if (Math.abs(xPosition) > swipeStartThreshold) {
  3730. pointerStartRef = null;
  3731. }
  3732. }
  3733. legacy_pre_effect(() => deep_read_state(classes()), () => {
  3734. classes({ ...defaultClasses, ...classes() });
  3735. });
  3736. legacy_pre_effect(() => deep_read_state(index2()), () => {
  3737. set(isFront, index2() === 0);
  3738. });
  3739. legacy_pre_effect(
  3740. () => (deep_read_state(index2()), deep_read_state(visibleToasts())),
  3741. () => {
  3742. set(isVisible, index2() + 1 <= visibleToasts());
  3743. }
  3744. );
  3745. legacy_pre_effect(() => deep_read_state(toast2()), () => {
  3746. set(toastTitle, toast2().title);
  3747. });
  3748. legacy_pre_effect(() => deep_read_state(toast2()), () => {
  3749. set(toastDescription, toast2().description);
  3750. });
  3751. legacy_pre_effect(() => deep_read_state(toast2()), () => {
  3752. set(toastType, toast2().type);
  3753. });
  3754. legacy_pre_effect(() => deep_read_state(toast2()), () => {
  3755. set(toastClass, toast2().class || "");
  3756. });
  3757. legacy_pre_effect(() => deep_read_state(toast2()), () => {
  3758. set(toastDescriptionClass, toast2().descriptionClass || "");
  3759. });
  3760. legacy_pre_effect(
  3761. () => ($heights(), deep_read_state(toast2())),
  3762. () => {
  3763. set(heightIndex, $heights().findIndex((height) => height.toastId === toast2().id) || 0);
  3764. }
  3765. );
  3766. legacy_pre_effect(() => deep_read_state(position()), () => {
  3767. set(coords, position().split("-"));
  3768. });
  3769. legacy_pre_effect(() => ($heights(), get$1(heightIndex)), () => {
  3770. set(toastsHeightBefore, $heights().reduce(
  3771. (prev, curr, reducerIndex) => {
  3772. if (reducerIndex >= get$1(heightIndex)) return prev;
  3773. return prev + curr.height;
  3774. },
  3775. 0
  3776. ));
  3777. });
  3778. legacy_pre_effect(
  3779. () => (deep_read_state(invert()), deep_read_state(toast2())),
  3780. () => {
  3781. invert(toast2().invert || invert());
  3782. }
  3783. );
  3784. legacy_pre_effect(() => get$1(toastType), () => {
  3785. set(disabled, get$1(toastType) === "loading");
  3786. });
  3787. legacy_pre_effect(
  3788. () => (get$1(heightIndex), get$1(toastsHeightBefore)),
  3789. () => {
  3790. set(offset, Math.round(get$1(heightIndex) * GAP + get$1(toastsHeightBefore)));
  3791. }
  3792. );
  3793. legacy_pre_effect(
  3794. () => (get$1(toastTitle), get$1(toastDescription)),
  3795. () => {
  3796. get$1(toastTitle), get$1(toastDescription), updateHeights();
  3797. }
  3798. );
  3799. legacy_pre_effect(
  3800. () => (deep_read_state(toast2()), get$1(timeoutId), deep_read_state(duration())),
  3801. () => {
  3802. if (toast2().updated) {
  3803. clearTimeout(get$1(timeoutId));
  3804. set(remainingTime, toast2().duration || duration() || TOAST_LIFETIME);
  3805. startTimer();
  3806. }
  3807. }
  3808. );
  3809. legacy_pre_effect(
  3810. () => (deep_read_state(toast2()), get$1(toastType)),
  3811. () => {
  3812. set(isPromiseLoadingOrInfiniteDuration, toast2().promise && get$1(toastType) === "loading" || toast2().duration === Number.POSITIVE_INFINITY);
  3813. }
  3814. );
  3815. legacy_pre_effect(
  3816. () => (get$1(isPromiseLoadingOrInfiniteDuration), deep_read_state(expanded()), deep_read_state(interacting()), get$1(timeoutId)),
  3817. () => {
  3818. store_unsub(
  3819. set(effect2, useEffect(() => {
  3820. if (!get$1(isPromiseLoadingOrInfiniteDuration)) {
  3821. if (expanded() || interacting()) {
  3822. pauseTimer();
  3823. } else {
  3824. startTimer();
  3825. }
  3826. }
  3827. return () => clearTimeout(get$1(timeoutId));
  3828. })),
  3829. "$effect",
  3830. $$stores
  3831. );
  3832. }
  3833. );
  3834. legacy_pre_effect(() => $effect(), () => {
  3835. $effect();
  3836. });
  3837. legacy_pre_effect(() => deep_read_state(toast2()), () => {
  3838. if (toast2().delete) {
  3839. deleteToast();
  3840. }
  3841. });
  3842. legacy_pre_effect_reset();
  3843. init(true);
  3844. var li = root$2();
  3845. set_attribute(li, "tabindex", 0);
  3846. let styles;
  3847. var node = child(li);
  3848. {
  3849. var consequent = ($$anchor2) => {
  3850. var button = root_1$1();
  3851. template_effect(
  3852. ($0) => {
  3853. set_attribute(button, "data-disabled", get$1(disabled));
  3854. set_class(button, 1, $0);
  3855. },
  3856. [
  3857. () => {
  3858. var _a2, _b2, _c;
  3859. return clsx(cn((_a2 = classes()) == null ? void 0 : _a2.closeButton, (_c = (_b2 = toast2()) == null ? void 0 : _b2.classes) == null ? void 0 : _c.closeButton));
  3860. }
  3861. ],
  3862. derived_safe_equal
  3863. );
  3864. event("click", button, function(...$$args) {
  3865. var _a2;
  3866. (_a2 = get$1(disabled) ? void 0 : () => {
  3867. var _a3, _b2;
  3868. deleteToast();
  3869. (_b2 = (_a3 = toast2()).onDismiss) == null ? void 0 : _b2.call(_a3, toast2());
  3870. }) == null ? void 0 : _a2.apply(this, $$args);
  3871. });
  3872. append($$anchor2, button);
  3873. };
  3874. if_block(node, ($$render) => {
  3875. if (closeButton() && !toast2().component) $$render(consequent);
  3876. });
  3877. }
  3878. var node_1 = sibling(node, 2);
  3879. {
  3880. var consequent_1 = ($$anchor2) => {
  3881. var fragment = comment();
  3882. var node_2 = first_child(fragment);
  3883. component(node_2, () => toast2().component, ($$anchor3, $$component) => {
  3884. $$component($$anchor3, spread_props(() => toast2().componentProps, { $$events: { closeToast: deleteToast } }));
  3885. });
  3886. append($$anchor2, fragment);
  3887. };
  3888. var alternate = ($$anchor2) => {
  3889. var fragment_1 = root_3();
  3890. var node_3 = first_child(fragment_1);
  3891. {
  3892. var consequent_8 = ($$anchor3) => {
  3893. var div = root_4();
  3894. var node_4 = child(div);
  3895. {
  3896. var consequent_2 = ($$anchor4) => {
  3897. var fragment_2 = comment();
  3898. var node_5 = first_child(fragment_2);
  3899. slot(node_5, $$props, "loading-icon", {}, null);
  3900. append($$anchor4, fragment_2);
  3901. };
  3902. if_block(node_4, ($$render) => {
  3903. if ((toast2().promise || get$1(toastType) === "loading") && !toast2().icon) $$render(consequent_2);
  3904. });
  3905. }
  3906. var node_6 = sibling(node_4, 2);
  3907. {
  3908. var consequent_3 = ($$anchor4) => {
  3909. var fragment_3 = comment();
  3910. var node_7 = first_child(fragment_3);
  3911. component(node_7, () => toast2().icon, ($$anchor5, $$component) => {
  3912. $$component($$anchor5, {});
  3913. });
  3914. append($$anchor4, fragment_3);
  3915. };
  3916. var alternate_1 = ($$anchor4, $$elseif) => {
  3917. {
  3918. var consequent_4 = ($$anchor5) => {
  3919. var fragment_4 = comment();
  3920. var node_8 = first_child(fragment_4);
  3921. slot(node_8, $$props, "success-icon", {}, null);
  3922. append($$anchor5, fragment_4);
  3923. };
  3924. var alternate_2 = ($$anchor5, $$elseif2) => {
  3925. {
  3926. var consequent_5 = ($$anchor6) => {
  3927. var fragment_5 = comment();
  3928. var node_9 = first_child(fragment_5);
  3929. slot(node_9, $$props, "error-icon", {}, null);
  3930. append($$anchor6, fragment_5);
  3931. };
  3932. var alternate_3 = ($$anchor6, $$elseif3) => {
  3933. {
  3934. var consequent_6 = ($$anchor7) => {
  3935. var fragment_6 = comment();
  3936. var node_10 = first_child(fragment_6);
  3937. slot(node_10, $$props, "warning-icon", {}, null);
  3938. append($$anchor7, fragment_6);
  3939. };
  3940. var alternate_4 = ($$anchor7, $$elseif4) => {
  3941. {
  3942. var consequent_7 = ($$anchor8) => {
  3943. var fragment_7 = comment();
  3944. var node_11 = first_child(fragment_7);
  3945. slot(node_11, $$props, "info-icon", {}, null);
  3946. append($$anchor8, fragment_7);
  3947. };
  3948. if_block(
  3949. $$anchor7,
  3950. ($$render) => {
  3951. if (get$1(toastType) === "info") $$render(consequent_7);
  3952. },
  3953. $$elseif4
  3954. );
  3955. }
  3956. };
  3957. if_block(
  3958. $$anchor6,
  3959. ($$render) => {
  3960. if (get$1(toastType) === "warning") $$render(consequent_6);
  3961. else $$render(alternate_4, false);
  3962. },
  3963. $$elseif3
  3964. );
  3965. }
  3966. };
  3967. if_block(
  3968. $$anchor5,
  3969. ($$render) => {
  3970. if (get$1(toastType) === "error") $$render(consequent_5);
  3971. else $$render(alternate_3, false);
  3972. },
  3973. $$elseif2
  3974. );
  3975. }
  3976. };
  3977. if_block(
  3978. $$anchor4,
  3979. ($$render) => {
  3980. if (get$1(toastType) === "success") $$render(consequent_4);
  3981. else $$render(alternate_2, false);
  3982. },
  3983. $$elseif
  3984. );
  3985. }
  3986. };
  3987. if_block(node_6, ($$render) => {
  3988. if (toast2().icon) $$render(consequent_3);
  3989. else $$render(alternate_1, false);
  3990. });
  3991. }
  3992. append($$anchor3, div);
  3993. };
  3994. if_block(node_3, ($$render) => {
  3995. if (get$1(toastType) !== "default" || toast2().icon || toast2().promise) $$render(consequent_8);
  3996. });
  3997. }
  3998. var div_1 = sibling(node_3, 2);
  3999. var node_12 = child(div_1);
  4000. {
  4001. var consequent_10 = ($$anchor3) => {
  4002. var div_2 = root_15();
  4003. var node_13 = child(div_2);
  4004. {
  4005. var consequent_9 = ($$anchor4) => {
  4006. var fragment_8 = comment();
  4007. var node_14 = first_child(fragment_8);
  4008. component(node_14, () => toast2().title, ($$anchor5, $$component) => {
  4009. $$component($$anchor5, spread_props(() => toast2().componentProps));
  4010. });
  4011. append($$anchor4, fragment_8);
  4012. };
  4013. var alternate_5 = ($$anchor4) => {
  4014. var text$1 = text();
  4015. template_effect(() => set_text(text$1, toast2().title));
  4016. append($$anchor4, text$1);
  4017. };
  4018. if_block(node_13, ($$render) => {
  4019. if (typeof toast2().title !== "string") $$render(consequent_9);
  4020. else $$render(alternate_5, false);
  4021. });
  4022. }
  4023. template_effect(
  4024. ($0) => set_class(div_2, 1, $0),
  4025. [
  4026. () => {
  4027. var _a2, _b2, _c;
  4028. return clsx(cn((_a2 = classes()) == null ? void 0 : _a2.title, (_c = (_b2 = toast2()) == null ? void 0 : _b2.classes) == null ? void 0 : _c.title));
  4029. }
  4030. ],
  4031. derived_safe_equal
  4032. );
  4033. append($$anchor3, div_2);
  4034. };
  4035. if_block(node_12, ($$render) => {
  4036. if (toast2().title) $$render(consequent_10);
  4037. });
  4038. }
  4039. var node_15 = sibling(node_12, 2);
  4040. {
  4041. var consequent_12 = ($$anchor3) => {
  4042. var div_3 = root_18();
  4043. var node_16 = child(div_3);
  4044. {
  4045. var consequent_11 = ($$anchor4) => {
  4046. var fragment_10 = comment();
  4047. var node_17 = first_child(fragment_10);
  4048. component(node_17, () => toast2().description, ($$anchor5, $$component) => {
  4049. $$component($$anchor5, spread_props(() => toast2().componentProps));
  4050. });
  4051. append($$anchor4, fragment_10);
  4052. };
  4053. var alternate_6 = ($$anchor4) => {
  4054. var text_1 = text();
  4055. template_effect(() => set_text(text_1, toast2().description));
  4056. append($$anchor4, text_1);
  4057. };
  4058. if_block(node_16, ($$render) => {
  4059. if (typeof toast2().description !== "string") $$render(consequent_11);
  4060. else $$render(alternate_6, false);
  4061. });
  4062. }
  4063. template_effect(
  4064. ($0) => set_class(div_3, 1, $0),
  4065. [
  4066. () => {
  4067. var _a2, _b2;
  4068. return clsx(cn(descriptionClass(), get$1(toastDescriptionClass), (_a2 = classes()) == null ? void 0 : _a2.description, (_b2 = toast2().classes) == null ? void 0 : _b2.description));
  4069. }
  4070. ],
  4071. derived_safe_equal
  4072. );
  4073. append($$anchor3, div_3);
  4074. };
  4075. if_block(node_15, ($$render) => {
  4076. if (toast2().description) $$render(consequent_12);
  4077. });
  4078. }
  4079. var node_18 = sibling(div_1, 2);
  4080. {
  4081. var consequent_13 = ($$anchor3) => {
  4082. var button_1 = root_21();
  4083. var text_2 = child(button_1);
  4084. template_effect(
  4085. ($0) => {
  4086. set_style(button_1, cancelButtonStyle());
  4087. set_class(button_1, 1, $0);
  4088. set_text(text_2, toast2().cancel.label);
  4089. },
  4090. [
  4091. () => {
  4092. var _a2, _b2, _c;
  4093. return clsx(cn((_a2 = classes()) == null ? void 0 : _a2.cancelButton, (_c = (_b2 = toast2()) == null ? void 0 : _b2.classes) == null ? void 0 : _c.cancelButton));
  4094. }
  4095. ],
  4096. derived_safe_equal
  4097. );
  4098. event("click", button_1, () => {
  4099. var _a2;
  4100. deleteToast();
  4101. if ((_a2 = toast2().cancel) == null ? void 0 : _a2.onClick) {
  4102. toast2().cancel.onClick();
  4103. }
  4104. });
  4105. append($$anchor3, button_1);
  4106. };
  4107. if_block(node_18, ($$render) => {
  4108. if (toast2().cancel) $$render(consequent_13);
  4109. });
  4110. }
  4111. var node_19 = sibling(node_18, 2);
  4112. {
  4113. var consequent_14 = ($$anchor3) => {
  4114. var button_2 = root_22();
  4115. var text_3 = child(button_2);
  4116. template_effect(
  4117. ($0) => {
  4118. set_style(button_2, actionButtonStyle());
  4119. set_class(button_2, 1, $0);
  4120. set_text(text_3, toast2().action.label);
  4121. },
  4122. [
  4123. () => {
  4124. var _a2, _b2, _c;
  4125. return clsx(cn((_a2 = classes()) == null ? void 0 : _a2.actionButton, (_c = (_b2 = toast2()) == null ? void 0 : _b2.classes) == null ? void 0 : _c.actionButton));
  4126. }
  4127. ],
  4128. derived_safe_equal
  4129. );
  4130. event("click", button_2, (event2) => {
  4131. var _a2;
  4132. (_a2 = toast2().action) == null ? void 0 : _a2.onClick(event2);
  4133. if (event2.defaultPrevented) return;
  4134. deleteToast();
  4135. });
  4136. append($$anchor3, button_2);
  4137. };
  4138. if_block(node_19, ($$render) => {
  4139. if (toast2().action) $$render(consequent_14);
  4140. });
  4141. }
  4142. append($$anchor2, fragment_1);
  4143. };
  4144. if_block(node_1, ($$render) => {
  4145. if (toast2().component) $$render(consequent_1);
  4146. else $$render(alternate, false);
  4147. });
  4148. }
  4149. bind_this(li, ($$value) => set(toastRef, $$value), () => get$1(toastRef));
  4150. template_effect(
  4151. ($0, $1, $2) => {
  4152. var _a2;
  4153. set_attribute(li, "aria-live", toast2().important ? "assertive" : "polite");
  4154. set_class(li, 1, $0);
  4155. set_attribute(li, "data-styled", !(toast2().component || ((_a2 = toast2()) == null ? void 0 : _a2.unstyled) || unstyled()));
  4156. set_attribute(li, "data-mounted", get$1(mounted));
  4157. set_attribute(li, "data-promise", $1);
  4158. set_attribute(li, "data-removed", get$1(removed));
  4159. set_attribute(li, "data-visible", get$1(isVisible));
  4160. set_attribute(li, "data-y-position", get$1(coords)[0]);
  4161. set_attribute(li, "data-x-position", get$1(coords)[1]);
  4162. set_attribute(li, "data-index", index2());
  4163. set_attribute(li, "data-front", get$1(isFront));
  4164. set_attribute(li, "data-swiping", get$1(swiping));
  4165. set_attribute(li, "data-type", get$1(toastType));
  4166. set_attribute(li, "data-invert", invert());
  4167. set_attribute(li, "data-swipe-out", get$1(swipeOut));
  4168. set_attribute(li, "data-expanded", $2);
  4169. styles = set_style(li, `${$$sanitized_props.style} ${toast2().style}`, styles, {
  4170. "--index": index2(),
  4171. "--toasts-before": index2(),
  4172. "--z-index": $toasts().length - index2(),
  4173. "--offset": `${get$1(removed) ? get$1(offsetBeforeRemove) : get$1(offset)}px`,
  4174. "--initial-height": `${get$1(initialHeight)}px`
  4175. });
  4176. },
  4177. [
  4178. () => {
  4179. var _a2, _b2, _c, _d, _e, _f;
  4180. return clsx(cn($$sanitized_props.class, get$1(toastClass), (_a2 = classes()) == null ? void 0 : _a2.toast, (_c = (_b2 = toast2()) == null ? void 0 : _b2.classes) == null ? void 0 : _c.toast, (_d = classes()) == null ? void 0 : _d[get$1(toastType)], (_f = (_e = toast2()) == null ? void 0 : _e.classes) == null ? void 0 : _f[get$1(toastType)]));
  4181. },
  4182. () => Boolean(toast2().promise),
  4183. () => Boolean(expanded() || expandByDefault() && get$1(mounted))
  4184. ],
  4185. derived_safe_equal
  4186. );
  4187. event("pointerdown", li, onPointerDown);
  4188. event("pointerup", li, onPointerUp);
  4189. event("pointermove", li, onPointerMove);
  4190. append($$anchor, li);
  4191. pop();
  4192. $$cleanup();
  4193. }
  4194. var root_2 = /* @__PURE__ */ template(`<ol></ol>`);
  4195. var root_1 = /* @__PURE__ */ template(`<section class="svelte-1fo5d1m"></section>`);
  4196. function Toaster($$anchor, $$props) {
  4197. const $$sanitized_props = legacy_rest_props($$props, [
  4198. "children",
  4199. "$$slots",
  4200. "$$events",
  4201. "$$legacy"
  4202. ]);
  4203. const $$restProps = legacy_rest_props($$sanitized_props, [
  4204. "invert",
  4205. "theme",
  4206. "position",
  4207. "hotkey",
  4208. "containerAriaLabel",
  4209. "richColors",
  4210. "expand",
  4211. "duration",
  4212. "visibleToasts",
  4213. "closeButton",
  4214. "toastOptions",
  4215. "offset",
  4216. "dir"
  4217. ]);
  4218. push($$props, false);
  4219. const [$$stores, $$cleanup] = setup_stores();
  4220. const $toasts = () => store_get(toasts, "$toasts", $$stores);
  4221. const $heights = () => store_get(heights, "$heights", $$stores);
  4222. const possiblePositions = /* @__PURE__ */ mutable_source();
  4223. const hotkeyLabel = /* @__PURE__ */ mutable_source();
  4224. const VISIBLE_TOASTS_AMOUNT = 3;
  4225. const VIEWPORT_OFFSET = "32px";
  4226. const TOAST_WIDTH = 356;
  4227. const GAP = 14;
  4228. const DARK = "dark";
  4229. const LIGHT = "light";
  4230. function getInitialTheme(t) {
  4231. if (t !== "system") {
  4232. return t;
  4233. }
  4234. if (typeof window !== "undefined") {
  4235. if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
  4236. return DARK;
  4237. }
  4238. return LIGHT;
  4239. }
  4240. return LIGHT;
  4241. }
  4242. function getDocumentDirection() {
  4243. if (typeof window === "undefined") return "ltr";
  4244. if (typeof document === "undefined") return "ltr";
  4245. const dirAttribute = document.documentElement.getAttribute("dir");
  4246. if (dirAttribute === "auto" || !dirAttribute) {
  4247. return window.getComputedStyle(document.documentElement).direction;
  4248. }
  4249. return dirAttribute;
  4250. }
  4251. let invert = prop($$props, "invert", 8, false);
  4252. let theme = prop($$props, "theme", 8, "light");
  4253. let position = prop($$props, "position", 8, "bottom-right");
  4254. let hotkey = prop($$props, "hotkey", 24, () => ["altKey", "KeyT"]);
  4255. let containerAriaLabel = prop($$props, "containerAriaLabel", 8, "Notifications");
  4256. let richColors = prop($$props, "richColors", 8, false);
  4257. let expand = prop($$props, "expand", 8, false);
  4258. let duration = prop($$props, "duration", 8, 4e3);
  4259. let visibleToasts = prop($$props, "visibleToasts", 8, VISIBLE_TOASTS_AMOUNT);
  4260. let closeButton = prop($$props, "closeButton", 8, false);
  4261. let toastOptions = prop($$props, "toastOptions", 24, () => ({}));
  4262. let offset = prop($$props, "offset", 8, null);
  4263. let dir = prop($$props, "dir", 24, getDocumentDirection);
  4264. const { toasts, heights, reset } = toastState;
  4265. let expanded = /* @__PURE__ */ mutable_source(false);
  4266. let interacting = /* @__PURE__ */ mutable_source(false);
  4267. let actualTheme = /* @__PURE__ */ mutable_source(getInitialTheme(theme()));
  4268. let listRef = /* @__PURE__ */ mutable_source();
  4269. let lastFocusedElementRef = null;
  4270. let isFocusWithinRef = false;
  4271. onDestroy(() => {
  4272. if (get$1(listRef) && lastFocusedElementRef) {
  4273. lastFocusedElementRef.focus({ preventScroll: true });
  4274. lastFocusedElementRef = null;
  4275. isFocusWithinRef = false;
  4276. }
  4277. });
  4278. onMount(() => {
  4279. reset();
  4280. const handleKeydown = (event2) => {
  4281. var _a2, _b2;
  4282. const isHotkeyPressed = hotkey().every((key) => (
  4283. // eslint-disable-next-line @typescript-eslint/no-explicit-any
  4284. event2[key] || event2.code === key
  4285. ));
  4286. if (isHotkeyPressed) {
  4287. set(expanded, true);
  4288. (_a2 = get$1(listRef)) == null ? void 0 : _a2.focus();
  4289. }
  4290. if (event2.code === "Escape" && (document.activeElement === get$1(listRef) || ((_b2 = get$1(listRef)) == null ? void 0 : _b2.contains(document.activeElement)))) {
  4291. set(expanded, false);
  4292. }
  4293. };
  4294. document.addEventListener("keydown", handleKeydown);
  4295. return () => {
  4296. document.removeEventListener("keydown", handleKeydown);
  4297. };
  4298. });
  4299. function handleBlur(event2) {
  4300. if (isFocusWithinRef && !event2.currentTarget.contains(event2.relatedTarget)) {
  4301. isFocusWithinRef = false;
  4302. if (lastFocusedElementRef) {
  4303. lastFocusedElementRef.focus({ preventScroll: true });
  4304. lastFocusedElementRef = null;
  4305. }
  4306. }
  4307. }
  4308. function handleFocus(event2) {
  4309. if (!isFocusWithinRef) {
  4310. isFocusWithinRef = true;
  4311. lastFocusedElementRef = event2.relatedTarget;
  4312. }
  4313. }
  4314. legacy_pre_effect(
  4315. () => (deep_read_state(position()), $toasts()),
  4316. () => {
  4317. set(possiblePositions, Array.from(new Set([
  4318. position(),
  4319. ...$toasts().filter((toast2) => toast2.position).map((toast2) => toast2.position)
  4320. ].filter(Boolean))));
  4321. }
  4322. );
  4323. legacy_pre_effect(() => deep_read_state(hotkey()), () => {
  4324. set(hotkeyLabel, hotkey().join("+").replace(/Key/g, "").replace(/Digit/g, ""));
  4325. });
  4326. legacy_pre_effect(() => $toasts(), () => {
  4327. if ($toasts().length <= 1) {
  4328. set(expanded, false);
  4329. }
  4330. });
  4331. legacy_pre_effect(() => $toasts(), () => {
  4332. const toastsToDismiss = $toasts().filter((toast2) => toast2.dismiss && !toast2.delete);
  4333. if (toastsToDismiss.length > 0) {
  4334. const updatedToasts = $toasts().map((toast2) => {
  4335. const matchingToast = toastsToDismiss.find((dismissToast) => dismissToast.id === toast2.id);
  4336. if (matchingToast) {
  4337. return { ...toast2, delete: true };
  4338. }
  4339. return toast2;
  4340. });
  4341. toasts.set(updatedToasts);
  4342. }
  4343. });
  4344. legacy_pre_effect(() => deep_read_state(theme()), () => {
  4345. if (theme() !== "system") {
  4346. set(actualTheme, theme());
  4347. }
  4348. if (typeof window !== "undefined") {
  4349. if (theme() === "system") {
  4350. if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
  4351. set(actualTheme, DARK);
  4352. } else {
  4353. set(actualTheme, LIGHT);
  4354. }
  4355. }
  4356. const mediaQueryList = window.matchMedia("(prefers-color-scheme: dark)");
  4357. const changeHandler = ({ matches }) => {
  4358. set(actualTheme, matches ? DARK : LIGHT);
  4359. };
  4360. if ("addEventListener" in mediaQueryList) {
  4361. mediaQueryList.addEventListener("change", changeHandler);
  4362. } else {
  4363. mediaQueryList.addListener(changeHandler);
  4364. }
  4365. }
  4366. });
  4367. legacy_pre_effect_reset();
  4368. init();
  4369. var fragment = comment();
  4370. var node = first_child(fragment);
  4371. {
  4372. var consequent = ($$anchor2) => {
  4373. var section = root_1();
  4374. set_attribute(section, "tabindex", -1);
  4375. each(section, 5, () => get$1(possiblePositions), index, ($$anchor3, position2, index2, $$array) => {
  4376. var ol = root_2();
  4377. let attributes;
  4378. each(ol, 7, () => $toasts().filter((toast2) => !toast2.position && index2 === 0 || toast2.position === get$1(position2)), (toast2) => toast2.id, ($$anchor4, toast2, index3, $$array_1) => {
  4379. const expression = /* @__PURE__ */ derived_safe_equal(() => {
  4380. var _a2;
  4381. return ((_a2 = toastOptions()) == null ? void 0 : _a2.actionButtonStyle) || "";
  4382. });
  4383. const expression_1 = /* @__PURE__ */ derived_safe_equal(() => {
  4384. var _a2;
  4385. return ((_a2 = toastOptions()) == null ? void 0 : _a2.cancelButtonStyle) || "";
  4386. });
  4387. const expression_2 = /* @__PURE__ */ derived_safe_equal(() => {
  4388. var _a2;
  4389. return ((_a2 = toastOptions()) == null ? void 0 : _a2.class) || "";
  4390. });
  4391. const expression_3 = /* @__PURE__ */ derived_safe_equal(() => {
  4392. var _a2;
  4393. return ((_a2 = toastOptions()) == null ? void 0 : _a2.descriptionClass) || "";
  4394. });
  4395. const expression_4 = /* @__PURE__ */ derived_safe_equal(() => toastOptions().classes || {});
  4396. const expression_5 = /* @__PURE__ */ derived_safe_equal(() => {
  4397. var _a2;
  4398. return ((_a2 = toastOptions()) == null ? void 0 : _a2.duration) ?? duration();
  4399. });
  4400. const expression_6 = /* @__PURE__ */ derived_safe_equal(() => toastOptions().unstyled || false);
  4401. Toast($$anchor4, {
  4402. get index() {
  4403. return get$1(index3);
  4404. },
  4405. get toast() {
  4406. return get$1(toast2);
  4407. },
  4408. get invert() {
  4409. return invert();
  4410. },
  4411. get visibleToasts() {
  4412. return visibleToasts();
  4413. },
  4414. get closeButton() {
  4415. return closeButton();
  4416. },
  4417. get interacting() {
  4418. return get$1(interacting);
  4419. },
  4420. get position() {
  4421. return get$1(position2);
  4422. },
  4423. get expandByDefault() {
  4424. return expand();
  4425. },
  4426. get expanded() {
  4427. return get$1(expanded);
  4428. },
  4429. get actionButtonStyle() {
  4430. return get$1(expression);
  4431. },
  4432. get cancelButtonStyle() {
  4433. return get$1(expression_1);
  4434. },
  4435. get class() {
  4436. return get$1(expression_2);
  4437. },
  4438. get descriptionClass() {
  4439. return get$1(expression_3);
  4440. },
  4441. get classes() {
  4442. return get$1(expression_4);
  4443. },
  4444. get duration() {
  4445. return get$1(expression_5);
  4446. },
  4447. get unstyled() {
  4448. return get$1(expression_6);
  4449. },
  4450. $$slots: {
  4451. "loading-icon": ($$anchor5, $$slotProps) => {
  4452. var fragment_2 = comment();
  4453. var node_1 = first_child(fragment_2);
  4454. slot(node_1, $$props, "loading-icon", {}, ($$anchor6) => {
  4455. const expression_7 = /* @__PURE__ */ derived_safe_equal(() => get$1(toast2).type === "loading");
  4456. Loader($$anchor6, {
  4457. get visible() {
  4458. return get$1(expression_7);
  4459. }
  4460. });
  4461. });
  4462. append($$anchor5, fragment_2);
  4463. },
  4464. "success-icon": ($$anchor5, $$slotProps) => {
  4465. var fragment_4 = comment();
  4466. var node_2 = first_child(fragment_4);
  4467. slot(node_2, $$props, "success-icon", {}, ($$anchor6) => {
  4468. Icon($$anchor6, { type: "success" });
  4469. });
  4470. append($$anchor5, fragment_4);
  4471. },
  4472. "error-icon": ($$anchor5, $$slotProps) => {
  4473. var fragment_6 = comment();
  4474. var node_3 = first_child(fragment_6);
  4475. slot(node_3, $$props, "error-icon", {}, ($$anchor6) => {
  4476. Icon($$anchor6, { type: "error" });
  4477. });
  4478. append($$anchor5, fragment_6);
  4479. },
  4480. "warning-icon": ($$anchor5, $$slotProps) => {
  4481. var fragment_8 = comment();
  4482. var node_4 = first_child(fragment_8);
  4483. slot(node_4, $$props, "warning-icon", {}, ($$anchor6) => {
  4484. Icon($$anchor6, { type: "warning" });
  4485. });
  4486. append($$anchor5, fragment_8);
  4487. },
  4488. "info-icon": ($$anchor5, $$slotProps) => {
  4489. var fragment_10 = comment();
  4490. var node_5 = first_child(fragment_10);
  4491. slot(node_5, $$props, "info-icon", {}, ($$anchor6) => {
  4492. Icon($$anchor6, { type: "info" });
  4493. });
  4494. append($$anchor5, fragment_10);
  4495. }
  4496. }
  4497. });
  4498. });
  4499. bind_this(ol, ($$value) => set(listRef, $$value), () => get$1(listRef));
  4500. template_effect(
  4501. ($0, $1, $2) => {
  4502. var _a2;
  4503. attributes = set_attributes(
  4504. ol,
  4505. attributes,
  4506. {
  4507. tabIndex: -1,
  4508. class: $$sanitized_props.class,
  4509. "data-sonner-toaster": true,
  4510. "data-theme": get$1(actualTheme),
  4511. "data-rich-colors": richColors(),
  4512. dir: $0,
  4513. "data-y-position": $1,
  4514. "data-x-position": $2,
  4515. style: $$sanitized_props.style,
  4516. ...$$restProps,
  4517. [STYLE]: {
  4518. "--front-toast-height": `${(_a2 = $heights()[0]) == null ? void 0 : _a2.height}px`,
  4519. "--offset": typeof offset() === "number" ? `${offset()}px` : offset() || VIEWPORT_OFFSET,
  4520. "--width": `${TOAST_WIDTH}px`,
  4521. "--gap": `${GAP}px`
  4522. }
  4523. },
  4524. "svelte-1fo5d1m"
  4525. );
  4526. ol.dir = ol.dir;
  4527. },
  4528. [
  4529. () => dir() === "auto" ? getDocumentDirection() : dir(),
  4530. () => get$1(position2).split("-")[0],
  4531. () => get$1(position2).split("-")[1]
  4532. ],
  4533. derived_safe_equal
  4534. );
  4535. event("blur", ol, handleBlur);
  4536. event("focus", ol, handleFocus);
  4537. event("mouseenter", ol, () => set(expanded, true));
  4538. event("mousemove", ol, () => set(expanded, true));
  4539. event("mouseleave", ol, () => {
  4540. if (!get$1(interacting)) {
  4541. set(expanded, false);
  4542. }
  4543. });
  4544. event("pointerdown", ol, () => set(interacting, true));
  4545. event("pointerup", ol, () => set(interacting, false));
  4546. append($$anchor3, ol);
  4547. });
  4548. template_effect(() => set_attribute(section, "aria-label", `${containerAriaLabel()} ${get$1(hotkeyLabel)}`));
  4549. append($$anchor2, section);
  4550. };
  4551. if_block(node, ($$render) => {
  4552. if ($toasts().length > 0) $$render(consequent);
  4553. });
  4554. }
  4555. append($$anchor, fragment);
  4556. pop();
  4557. $$cleanup();
  4558. }
  4559. const CONFIG = {
  4560. APP_NAME: "LeetCode Toolbox"
  4561. };
  4562. const messageToastTypes = [
  4563. "success",
  4564. "info",
  4565. "warning",
  4566. "error",
  4567. "message",
  4568. "loading"
  4569. ];
  4570. function addPrefix(message) {
  4571. if (typeof message === "string") {
  4572. return `${CONFIG.APP_NAME}: ${message}`;
  4573. }
  4574. return message;
  4575. }
  4576. const prefixToast = new Proxy(toast, {
  4577. // Handle direct function calls: toast('message')
  4578. apply(target, thisArg, args) {
  4579. if (args.length > 0) {
  4580. args[0] = addPrefix(args[0]);
  4581. }
  4582. return Reflect.apply(target, thisArg, args);
  4583. },
  4584. get(target, prop2, receiver) {
  4585. const originalProp = Reflect.get(target, prop2, receiver);
  4586. if (typeof originalProp === "function" && messageToastTypes.includes(prop2.toString())) {
  4587. return function(...args) {
  4588. if (args.length > 0) {
  4589. args[0] = addPrefix(args[0]);
  4590. }
  4591. return originalProp.apply(this, args);
  4592. };
  4593. }
  4594. return originalProp;
  4595. }
  4596. });
  4597. class TimeoutError extends Error {
  4598. constructor(item, timeout) {
  4599. super();
  4600. __publicField(this, "name", this.constructor.name);
  4601. this.message = `"${item}" not found within timeout (${timeout}ms)`;
  4602. }
  4603. }
  4604. function find(finderFn, {
  4605. subject = document,
  4606. observerOption = {
  4607. childList: true,
  4608. subtree: true
  4609. },
  4610. timeout = 5e3,
  4611. itemName = "Item"
  4612. }) {
  4613. return new Promise((resolve, reject) => {
  4614. const item = finderFn();
  4615. if (item) return resolve(item);
  4616. let timeoutId;
  4617. const observer = new MutationObserver(() => {
  4618. const item2 = finderFn();
  4619. if (item2) {
  4620. observer.disconnect();
  4621. clearTimeout(timeoutId);
  4622. return resolve(item2);
  4623. }
  4624. });
  4625. observer.observe(subject, observerOption);
  4626. if (timeout > 0) {
  4627. timeoutId = setTimeout(() => {
  4628. observer.disconnect();
  4629. prefixToast.error(
  4630. `${itemName} not found within timeout. Please refresh the page or disable the script.`
  4631. );
  4632. const error = new TimeoutError(itemName, timeout);
  4633. console.error(error);
  4634. return reject(error);
  4635. }, timeout);
  4636. }
  4637. });
  4638. }
  4639. async function findElement(selector, {
  4640. parent = document,
  4641. timeout = 500,
  4642. additionalRule
  4643. } = {}) {
  4644. const element = await find(
  4645. () => {
  4646. const el = parent.querySelector(selector);
  4647. if (additionalRule && el) {
  4648. return additionalRule(el) ? el : null;
  4649. } else {
  4650. return el;
  4651. }
  4652. },
  4653. {
  4654. subject: parent,
  4655. timeout,
  4656. itemName: `Element ${selector}`
  4657. }
  4658. );
  4659. return element;
  4660. }
  4661. var _GM_getResourceText = /* @__PURE__ */ (() => typeof GM_getResourceText != "undefined" ? GM_getResourceText : void 0)();
  4662. var _GM_registerMenuCommand = /* @__PURE__ */ (() => typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)();
  4663. var _unsafeWindow = /* @__PURE__ */ (() => typeof unsafeWindow != "undefined" ? unsafeWindow : void 0)();
  4664. const overrideOptions = {
  4665. selectionHighlight: true,
  4666. parameterHints: { enabled: true },
  4667. hover: { enabled: true },
  4668. quickSuggestions: true,
  4669. suggestOnTriggerCharacters: true,
  4670. "bracketPairColorization.enabled": true
  4671. };
  4672. function patchMonaco(editor) {
  4673. const originalUpdateOptions = editor.updateOptions.bind(editor);
  4674. editor.updateOptions = (options) => {
  4675. originalUpdateOptions({
  4676. ...options,
  4677. ...overrideOptions
  4678. });
  4679. };
  4680. }
  4681. async function findMonacoEditor() {
  4682. function getEditor() {
  4683. var _a2;
  4684. return ((_a2 = _unsafeWindow.monaco) == null ? void 0 : _a2.editor.getEditors()[0]) ?? null;
  4685. }
  4686. const editor = find(getEditor, {
  4687. subject: document.head,
  4688. observerOption: { childList: true },
  4689. itemName: "Monaco Editor"
  4690. });
  4691. return editor;
  4692. }
  4693. class State {
  4694. constructor() {
  4695. __publicField(this, "site", "global");
  4696. __publicField(this, "editor", null);
  4697. }
  4698. async init() {
  4699. const hostname = window.location.hostname;
  4700. this.site = hostname === "leetcode.cn" ? "cn" : "global";
  4701. this.editor = await findMonacoEditor();
  4702. patchMonaco(this.editor);
  4703. }
  4704. }
  4705. const state = new State();
  4706. async function copy(text2) {
  4707. try {
  4708. await navigator.clipboard.writeText(text2);
  4709. prefixToast.success(state.site === "cn" ? "复制到剪贴板!" : "Copied to clipboard!");
  4710. } catch (err) {
  4711. if (err instanceof Error) {
  4712. const errorMessage = state.site === "cn" ? "复制失败" : "Failed to copy";
  4713. prefixToast.error(errorMessage + ": " + err.message);
  4714. console.error(errorMessage + err);
  4715. } else throw err;
  4716. }
  4717. }
  4718. const getTitle = async () => (await findElement(".text-title-large")).textContent ?? "";
  4719. function Copy_title($$anchor, $$props) {
  4720. push($$props, false);
  4721. async function copyTitle() {
  4722. copy(await getTitle());
  4723. }
  4724. init();
  4725. Button($$anchor, {
  4726. onclick: copyTitle,
  4727. children: ($$anchor2, $$slotProps) => {
  4728. var text$1 = text();
  4729. template_effect(() => set_text(text$1, state.site === "cn" ? "复制标题" : "Copy Title"));
  4730. append($$anchor2, text$1);
  4731. },
  4732. $$slots: { default: true }
  4733. });
  4734. pop();
  4735. }
  4736. function extend(destination) {
  4737. for (var i2 = 1; i2 < arguments.length; i2++) {
  4738. var source2 = arguments[i2];
  4739. for (var key in source2) {
  4740. if (source2.hasOwnProperty(key)) destination[key] = source2[key];
  4741. }
  4742. }
  4743. return destination;
  4744. }
  4745. function repeat(character, count) {
  4746. return Array(count + 1).join(character);
  4747. }
  4748. function trimLeadingNewlines(string) {
  4749. return string.replace(/^\n*/, "");
  4750. }
  4751. function trimTrailingNewlines(string) {
  4752. var indexEnd = string.length;
  4753. while (indexEnd > 0 && string[indexEnd - 1] === "\n") indexEnd--;
  4754. return string.substring(0, indexEnd);
  4755. }
  4756. var blockElements = [
  4757. "ADDRESS",
  4758. "ARTICLE",
  4759. "ASIDE",
  4760. "AUDIO",
  4761. "BLOCKQUOTE",
  4762. "BODY",
  4763. "CANVAS",
  4764. "CENTER",
  4765. "DD",
  4766. "DIR",
  4767. "DIV",
  4768. "DL",
  4769. "DT",
  4770. "FIELDSET",
  4771. "FIGCAPTION",
  4772. "FIGURE",
  4773. "FOOTER",
  4774. "FORM",
  4775. "FRAMESET",
  4776. "H1",
  4777. "H2",
  4778. "H3",
  4779. "H4",
  4780. "H5",
  4781. "H6",
  4782. "HEADER",
  4783. "HGROUP",
  4784. "HR",
  4785. "HTML",
  4786. "ISINDEX",
  4787. "LI",
  4788. "MAIN",
  4789. "MENU",
  4790. "NAV",
  4791. "NOFRAMES",
  4792. "NOSCRIPT",
  4793. "OL",
  4794. "OUTPUT",
  4795. "P",
  4796. "PRE",
  4797. "SECTION",
  4798. "TABLE",
  4799. "TBODY",
  4800. "TD",
  4801. "TFOOT",
  4802. "TH",
  4803. "THEAD",
  4804. "TR",
  4805. "UL"
  4806. ];
  4807. function isBlock(node) {
  4808. return is(node, blockElements);
  4809. }
  4810. var voidElements = [
  4811. "AREA",
  4812. "BASE",
  4813. "BR",
  4814. "COL",
  4815. "COMMAND",
  4816. "EMBED",
  4817. "HR",
  4818. "IMG",
  4819. "INPUT",
  4820. "KEYGEN",
  4821. "LINK",
  4822. "META",
  4823. "PARAM",
  4824. "SOURCE",
  4825. "TRACK",
  4826. "WBR"
  4827. ];
  4828. function isVoid(node) {
  4829. return is(node, voidElements);
  4830. }
  4831. function hasVoid(node) {
  4832. return has(node, voidElements);
  4833. }
  4834. var meaningfulWhenBlankElements = [
  4835. "A",
  4836. "TABLE",
  4837. "THEAD",
  4838. "TBODY",
  4839. "TFOOT",
  4840. "TH",
  4841. "TD",
  4842. "IFRAME",
  4843. "SCRIPT",
  4844. "AUDIO",
  4845. "VIDEO"
  4846. ];
  4847. function isMeaningfulWhenBlank(node) {
  4848. return is(node, meaningfulWhenBlankElements);
  4849. }
  4850. function hasMeaningfulWhenBlank(node) {
  4851. return has(node, meaningfulWhenBlankElements);
  4852. }
  4853. function is(node, tagNames) {
  4854. return tagNames.indexOf(node.nodeName) >= 0;
  4855. }
  4856. function has(node, tagNames) {
  4857. return node.getElementsByTagName && tagNames.some(function(tagName) {
  4858. return node.getElementsByTagName(tagName).length;
  4859. });
  4860. }
  4861. var rules = {};
  4862. rules.paragraph = {
  4863. filter: "p",
  4864. replacement: function(content) {
  4865. return "\n\n" + content + "\n\n";
  4866. }
  4867. };
  4868. rules.lineBreak = {
  4869. filter: "br",
  4870. replacement: function(content, node, options) {
  4871. return options.br + "\n";
  4872. }
  4873. };
  4874. rules.heading = {
  4875. filter: ["h1", "h2", "h3", "h4", "h5", "h6"],
  4876. replacement: function(content, node, options) {
  4877. var hLevel = Number(node.nodeName.charAt(1));
  4878. if (options.headingStyle === "setext" && hLevel < 3) {
  4879. var underline = repeat(hLevel === 1 ? "=" : "-", content.length);
  4880. return "\n\n" + content + "\n" + underline + "\n\n";
  4881. } else {
  4882. return "\n\n" + repeat("#", hLevel) + " " + content + "\n\n";
  4883. }
  4884. }
  4885. };
  4886. rules.blockquote = {
  4887. filter: "blockquote",
  4888. replacement: function(content) {
  4889. content = content.replace(/^\n+|\n+$/g, "");
  4890. content = content.replace(/^/gm, "> ");
  4891. return "\n\n" + content + "\n\n";
  4892. }
  4893. };
  4894. rules.list = {
  4895. filter: ["ul", "ol"],
  4896. replacement: function(content, node) {
  4897. var parent = node.parentNode;
  4898. if (parent.nodeName === "LI" && parent.lastElementChild === node) {
  4899. return "\n" + content;
  4900. } else {
  4901. return "\n\n" + content + "\n\n";
  4902. }
  4903. }
  4904. };
  4905. rules.listItem = {
  4906. filter: "li",
  4907. replacement: function(content, node, options) {
  4908. content = content.replace(/^\n+/, "").replace(/\n+$/, "\n").replace(/\n/gm, "\n ");
  4909. var prefix = options.bulletListMarker + " ";
  4910. var parent = node.parentNode;
  4911. if (parent.nodeName === "OL") {
  4912. var start = parent.getAttribute("start");
  4913. var index2 = Array.prototype.indexOf.call(parent.children, node);
  4914. prefix = (start ? Number(start) + index2 : index2 + 1) + ". ";
  4915. }
  4916. return prefix + content + (node.nextSibling && !/\n$/.test(content) ? "\n" : "");
  4917. }
  4918. };
  4919. rules.indentedCodeBlock = {
  4920. filter: function(node, options) {
  4921. return options.codeBlockStyle === "indented" && node.nodeName === "PRE" && node.firstChild && node.firstChild.nodeName === "CODE";
  4922. },
  4923. replacement: function(content, node, options) {
  4924. return "\n\n " + node.firstChild.textContent.replace(/\n/g, "\n ") + "\n\n";
  4925. }
  4926. };
  4927. rules.fencedCodeBlock = {
  4928. filter: function(node, options) {
  4929. return options.codeBlockStyle === "fenced" && node.nodeName === "PRE" && node.firstChild && node.firstChild.nodeName === "CODE";
  4930. },
  4931. replacement: function(content, node, options) {
  4932. var className = node.firstChild.getAttribute("class") || "";
  4933. var language = (className.match(/language-(\S+)/) || [null, ""])[1];
  4934. var code = node.firstChild.textContent;
  4935. var fenceChar = options.fence.charAt(0);
  4936. var fenceSize = 3;
  4937. var fenceInCodeRegex = new RegExp("^" + fenceChar + "{3,}", "gm");
  4938. var match;
  4939. while (match = fenceInCodeRegex.exec(code)) {
  4940. if (match[0].length >= fenceSize) {
  4941. fenceSize = match[0].length + 1;
  4942. }
  4943. }
  4944. var fence = repeat(fenceChar, fenceSize);
  4945. return "\n\n" + fence + language + "\n" + code.replace(/\n$/, "") + "\n" + fence + "\n\n";
  4946. }
  4947. };
  4948. rules.horizontalRule = {
  4949. filter: "hr",
  4950. replacement: function(content, node, options) {
  4951. return "\n\n" + options.hr + "\n\n";
  4952. }
  4953. };
  4954. rules.inlineLink = {
  4955. filter: function(node, options) {
  4956. return options.linkStyle === "inlined" && node.nodeName === "A" && node.getAttribute("href");
  4957. },
  4958. replacement: function(content, node) {
  4959. var href = node.getAttribute("href");
  4960. if (href) href = href.replace(/([()])/g, "\\$1");
  4961. var title = cleanAttribute(node.getAttribute("title"));
  4962. if (title) title = ' "' + title.replace(/"/g, '\\"') + '"';
  4963. return "[" + content + "](" + href + title + ")";
  4964. }
  4965. };
  4966. rules.referenceLink = {
  4967. filter: function(node, options) {
  4968. return options.linkStyle === "referenced" && node.nodeName === "A" && node.getAttribute("href");
  4969. },
  4970. replacement: function(content, node, options) {
  4971. var href = node.getAttribute("href");
  4972. var title = cleanAttribute(node.getAttribute("title"));
  4973. if (title) title = ' "' + title + '"';
  4974. var replacement;
  4975. var reference;
  4976. switch (options.linkReferenceStyle) {
  4977. case "collapsed":
  4978. replacement = "[" + content + "][]";
  4979. reference = "[" + content + "]: " + href + title;
  4980. break;
  4981. case "shortcut":
  4982. replacement = "[" + content + "]";
  4983. reference = "[" + content + "]: " + href + title;
  4984. break;
  4985. default:
  4986. var id = this.references.length + 1;
  4987. replacement = "[" + content + "][" + id + "]";
  4988. reference = "[" + id + "]: " + href + title;
  4989. }
  4990. this.references.push(reference);
  4991. return replacement;
  4992. },
  4993. references: [],
  4994. append: function(options) {
  4995. var references = "";
  4996. if (this.references.length) {
  4997. references = "\n\n" + this.references.join("\n") + "\n\n";
  4998. this.references = [];
  4999. }
  5000. return references;
  5001. }
  5002. };
  5003. rules.emphasis = {
  5004. filter: ["em", "i"],
  5005. replacement: function(content, node, options) {
  5006. if (!content.trim()) return "";
  5007. return options.emDelimiter + content + options.emDelimiter;
  5008. }
  5009. };
  5010. rules.strong = {
  5011. filter: ["strong", "b"],
  5012. replacement: function(content, node, options) {
  5013. if (!content.trim()) return "";
  5014. return options.strongDelimiter + content + options.strongDelimiter;
  5015. }
  5016. };
  5017. rules.code = {
  5018. filter: function(node) {
  5019. var hasSiblings = node.previousSibling || node.nextSibling;
  5020. var isCodeBlock = node.parentNode.nodeName === "PRE" && !hasSiblings;
  5021. return node.nodeName === "CODE" && !isCodeBlock;
  5022. },
  5023. replacement: function(content) {
  5024. if (!content) return "";
  5025. content = content.replace(/\r?\n|\r/g, " ");
  5026. var extraSpace = /^`|^ .*?[^ ].* $|`$/.test(content) ? " " : "";
  5027. var delimiter = "`";
  5028. var matches = content.match(/`+/gm) || [];
  5029. while (matches.indexOf(delimiter) !== -1) delimiter = delimiter + "`";
  5030. return delimiter + extraSpace + content + extraSpace + delimiter;
  5031. }
  5032. };
  5033. rules.image = {
  5034. filter: "img",
  5035. replacement: function(content, node) {
  5036. var alt = cleanAttribute(node.getAttribute("alt"));
  5037. var src = node.getAttribute("src") || "";
  5038. var title = cleanAttribute(node.getAttribute("title"));
  5039. var titlePart = title ? ' "' + title + '"' : "";
  5040. return src ? "![" + alt + "](" + src + titlePart + ")" : "";
  5041. }
  5042. };
  5043. function cleanAttribute(attribute) {
  5044. return attribute ? attribute.replace(/(\n+\s*)+/g, "\n") : "";
  5045. }
  5046. function Rules(options) {
  5047. this.options = options;
  5048. this._keep = [];
  5049. this._remove = [];
  5050. this.blankRule = {
  5051. replacement: options.blankReplacement
  5052. };
  5053. this.keepReplacement = options.keepReplacement;
  5054. this.defaultRule = {
  5055. replacement: options.defaultReplacement
  5056. };
  5057. this.array = [];
  5058. for (var key in options.rules) this.array.push(options.rules[key]);
  5059. }
  5060. Rules.prototype = {
  5061. add: function(key, rule) {
  5062. this.array.unshift(rule);
  5063. },
  5064. keep: function(filter) {
  5065. this._keep.unshift({
  5066. filter,
  5067. replacement: this.keepReplacement
  5068. });
  5069. },
  5070. remove: function(filter) {
  5071. this._remove.unshift({
  5072. filter,
  5073. replacement: function() {
  5074. return "";
  5075. }
  5076. });
  5077. },
  5078. forNode: function(node) {
  5079. if (node.isBlank) return this.blankRule;
  5080. var rule;
  5081. if (rule = findRule(this.array, node, this.options)) return rule;
  5082. if (rule = findRule(this._keep, node, this.options)) return rule;
  5083. if (rule = findRule(this._remove, node, this.options)) return rule;
  5084. return this.defaultRule;
  5085. },
  5086. forEach: function(fn) {
  5087. for (var i2 = 0; i2 < this.array.length; i2++) fn(this.array[i2], i2);
  5088. }
  5089. };
  5090. function findRule(rules2, node, options) {
  5091. for (var i2 = 0; i2 < rules2.length; i2++) {
  5092. var rule = rules2[i2];
  5093. if (filterValue(rule, node, options)) return rule;
  5094. }
  5095. return void 0;
  5096. }
  5097. function filterValue(rule, node, options) {
  5098. var filter = rule.filter;
  5099. if (typeof filter === "string") {
  5100. if (filter === node.nodeName.toLowerCase()) return true;
  5101. } else if (Array.isArray(filter)) {
  5102. if (filter.indexOf(node.nodeName.toLowerCase()) > -1) return true;
  5103. } else if (typeof filter === "function") {
  5104. if (filter.call(rule, node, options)) return true;
  5105. } else {
  5106. throw new TypeError("`filter` needs to be a string, array, or function");
  5107. }
  5108. }
  5109. function collapseWhitespace(options) {
  5110. var element = options.element;
  5111. var isBlock2 = options.isBlock;
  5112. var isVoid2 = options.isVoid;
  5113. var isPre = options.isPre || function(node2) {
  5114. return node2.nodeName === "PRE";
  5115. };
  5116. if (!element.firstChild || isPre(element)) return;
  5117. var prevText = null;
  5118. var keepLeadingWs = false;
  5119. var prev = null;
  5120. var node = next(prev, element, isPre);
  5121. while (node !== element) {
  5122. if (node.nodeType === 3 || node.nodeType === 4) {
  5123. var text2 = node.data.replace(/[ \r\n\t]+/g, " ");
  5124. if ((!prevText || / $/.test(prevText.data)) && !keepLeadingWs && text2[0] === " ") {
  5125. text2 = text2.substr(1);
  5126. }
  5127. if (!text2) {
  5128. node = remove(node);
  5129. continue;
  5130. }
  5131. node.data = text2;
  5132. prevText = node;
  5133. } else if (node.nodeType === 1) {
  5134. if (isBlock2(node) || node.nodeName === "BR") {
  5135. if (prevText) {
  5136. prevText.data = prevText.data.replace(/ $/, "");
  5137. }
  5138. prevText = null;
  5139. keepLeadingWs = false;
  5140. } else if (isVoid2(node) || isPre(node)) {
  5141. prevText = null;
  5142. keepLeadingWs = true;
  5143. } else if (prevText) {
  5144. keepLeadingWs = false;
  5145. }
  5146. } else {
  5147. node = remove(node);
  5148. continue;
  5149. }
  5150. var nextNode = next(prev, node, isPre);
  5151. prev = node;
  5152. node = nextNode;
  5153. }
  5154. if (prevText) {
  5155. prevText.data = prevText.data.replace(/ $/, "");
  5156. if (!prevText.data) {
  5157. remove(prevText);
  5158. }
  5159. }
  5160. }
  5161. function remove(node) {
  5162. var next2 = node.nextSibling || node.parentNode;
  5163. node.parentNode.removeChild(node);
  5164. return next2;
  5165. }
  5166. function next(prev, current, isPre) {
  5167. if (prev && prev.parentNode === current || isPre(current)) {
  5168. return current.nextSibling || current.parentNode;
  5169. }
  5170. return current.firstChild || current.nextSibling || current.parentNode;
  5171. }
  5172. var root$1 = typeof window !== "undefined" ? window : {};
  5173. function canParseHTMLNatively() {
  5174. var Parser = root$1.DOMParser;
  5175. var canParse = false;
  5176. try {
  5177. if (new Parser().parseFromString("", "text/html")) {
  5178. canParse = true;
  5179. }
  5180. } catch (e) {
  5181. }
  5182. return canParse;
  5183. }
  5184. function createHTMLParser() {
  5185. var Parser = function() {
  5186. };
  5187. {
  5188. if (shouldUseActiveX()) {
  5189. Parser.prototype.parseFromString = function(string) {
  5190. var doc = new window.ActiveXObject("htmlfile");
  5191. doc.designMode = "on";
  5192. doc.open();
  5193. doc.write(string);
  5194. doc.close();
  5195. return doc;
  5196. };
  5197. } else {
  5198. Parser.prototype.parseFromString = function(string) {
  5199. var doc = document.implementation.createHTMLDocument("");
  5200. doc.open();
  5201. doc.write(string);
  5202. doc.close();
  5203. return doc;
  5204. };
  5205. }
  5206. }
  5207. return Parser;
  5208. }
  5209. function shouldUseActiveX() {
  5210. var useActiveX = false;
  5211. try {
  5212. document.implementation.createHTMLDocument("").open();
  5213. } catch (e) {
  5214. if (root$1.ActiveXObject) useActiveX = true;
  5215. }
  5216. return useActiveX;
  5217. }
  5218. var HTMLParser = canParseHTMLNatively() ? root$1.DOMParser : createHTMLParser();
  5219. function RootNode(input, options) {
  5220. var root2;
  5221. if (typeof input === "string") {
  5222. var doc = htmlParser().parseFromString(
  5223. // DOM parsers arrange elements in the <head> and <body>.
  5224. // Wrapping in a custom element ensures elements are reliably arranged in
  5225. // a single element.
  5226. '<x-turndown id="turndown-root">' + input + "</x-turndown>",
  5227. "text/html"
  5228. );
  5229. root2 = doc.getElementById("turndown-root");
  5230. } else {
  5231. root2 = input.cloneNode(true);
  5232. }
  5233. collapseWhitespace({
  5234. element: root2,
  5235. isBlock,
  5236. isVoid,
  5237. isPre: options.preformattedCode ? isPreOrCode : null
  5238. });
  5239. return root2;
  5240. }
  5241. var _htmlParser;
  5242. function htmlParser() {
  5243. _htmlParser = _htmlParser || new HTMLParser();
  5244. return _htmlParser;
  5245. }
  5246. function isPreOrCode(node) {
  5247. return node.nodeName === "PRE" || node.nodeName === "CODE";
  5248. }
  5249. function Node$1(node, options) {
  5250. node.isBlock = isBlock(node);
  5251. node.isCode = node.nodeName === "CODE" || node.parentNode.isCode;
  5252. node.isBlank = isBlank(node);
  5253. node.flankingWhitespace = flankingWhitespace(node, options);
  5254. return node;
  5255. }
  5256. function isBlank(node) {
  5257. return !isVoid(node) && !isMeaningfulWhenBlank(node) && /^\s*$/i.test(node.textContent) && !hasVoid(node) && !hasMeaningfulWhenBlank(node);
  5258. }
  5259. function flankingWhitespace(node, options) {
  5260. if (node.isBlock || options.preformattedCode && node.isCode) {
  5261. return { leading: "", trailing: "" };
  5262. }
  5263. var edges = edgeWhitespace(node.textContent);
  5264. if (edges.leadingAscii && isFlankedByWhitespace("left", node, options)) {
  5265. edges.leading = edges.leadingNonAscii;
  5266. }
  5267. if (edges.trailingAscii && isFlankedByWhitespace("right", node, options)) {
  5268. edges.trailing = edges.trailingNonAscii;
  5269. }
  5270. return { leading: edges.leading, trailing: edges.trailing };
  5271. }
  5272. function edgeWhitespace(string) {
  5273. var m = string.match(/^(([ \t\r\n]*)(\s*))(?:(?=\S)[\s\S]*\S)?((\s*?)([ \t\r\n]*))$/);
  5274. return {
  5275. leading: m[1],
  5276. // whole string for whitespace-only strings
  5277. leadingAscii: m[2],
  5278. leadingNonAscii: m[3],
  5279. trailing: m[4],
  5280. // empty for whitespace-only strings
  5281. trailingNonAscii: m[5],
  5282. trailingAscii: m[6]
  5283. };
  5284. }
  5285. function isFlankedByWhitespace(side, node, options) {
  5286. var sibling2;
  5287. var regExp;
  5288. var isFlanked;
  5289. if (side === "left") {
  5290. sibling2 = node.previousSibling;
  5291. regExp = / $/;
  5292. } else {
  5293. sibling2 = node.nextSibling;
  5294. regExp = /^ /;
  5295. }
  5296. if (sibling2) {
  5297. if (sibling2.nodeType === 3) {
  5298. isFlanked = regExp.test(sibling2.nodeValue);
  5299. } else if (options.preformattedCode && sibling2.nodeName === "CODE") {
  5300. isFlanked = false;
  5301. } else if (sibling2.nodeType === 1 && !isBlock(sibling2)) {
  5302. isFlanked = regExp.test(sibling2.textContent);
  5303. }
  5304. }
  5305. return isFlanked;
  5306. }
  5307. var reduce = Array.prototype.reduce;
  5308. var escapes = [
  5309. [/\\/g, "\\\\"],
  5310. [/\*/g, "\\*"],
  5311. [/^-/g, "\\-"],
  5312. [/^\+ /g, "\\+ "],
  5313. [/^(=+)/g, "\\$1"],
  5314. [/^(#{1,6}) /g, "\\$1 "],
  5315. [/`/g, "\\`"],
  5316. [/^~~~/g, "\\~~~"],
  5317. [/\[/g, "\\["],
  5318. [/\]/g, "\\]"],
  5319. [/^>/g, "\\>"],
  5320. [/_/g, "\\_"],
  5321. [/^(\d+)\. /g, "$1\\. "]
  5322. ];
  5323. function TurndownService(options) {
  5324. if (!(this instanceof TurndownService)) return new TurndownService(options);
  5325. var defaults = {
  5326. rules,
  5327. headingStyle: "setext",
  5328. hr: "* * *",
  5329. bulletListMarker: "*",
  5330. codeBlockStyle: "indented",
  5331. fence: "```",
  5332. emDelimiter: "_",
  5333. strongDelimiter: "**",
  5334. linkStyle: "inlined",
  5335. linkReferenceStyle: "full",
  5336. br: " ",
  5337. preformattedCode: false,
  5338. blankReplacement: function(content, node) {
  5339. return node.isBlock ? "\n\n" : "";
  5340. },
  5341. keepReplacement: function(content, node) {
  5342. return node.isBlock ? "\n\n" + node.outerHTML + "\n\n" : node.outerHTML;
  5343. },
  5344. defaultReplacement: function(content, node) {
  5345. return node.isBlock ? "\n\n" + content + "\n\n" : content;
  5346. }
  5347. };
  5348. this.options = extend({}, defaults, options);
  5349. this.rules = new Rules(this.options);
  5350. }
  5351. TurndownService.prototype = {
  5352. /**
  5353. * The entry point for converting a string or DOM node to Markdown
  5354. * @public
  5355. * @param {String|HTMLElement} input The string or DOM node to convert
  5356. * @returns A Markdown representation of the input
  5357. * @type String
  5358. */
  5359. turndown: function(input) {
  5360. if (!canConvert(input)) {
  5361. throw new TypeError(
  5362. input + " is not a string, or an element/document/fragment node."
  5363. );
  5364. }
  5365. if (input === "") return "";
  5366. var output = process.call(this, new RootNode(input, this.options));
  5367. return postProcess.call(this, output);
  5368. },
  5369. /**
  5370. * Add one or more plugins
  5371. * @public
  5372. * @param {Function|Array} plugin The plugin or array of plugins to add
  5373. * @returns The Turndown instance for chaining
  5374. * @type Object
  5375. */
  5376. use: function(plugin) {
  5377. if (Array.isArray(plugin)) {
  5378. for (var i2 = 0; i2 < plugin.length; i2++) this.use(plugin[i2]);
  5379. } else if (typeof plugin === "function") {
  5380. plugin(this);
  5381. } else {
  5382. throw new TypeError("plugin must be a Function or an Array of Functions");
  5383. }
  5384. return this;
  5385. },
  5386. /**
  5387. * Adds a rule
  5388. * @public
  5389. * @param {String} key The unique key of the rule
  5390. * @param {Object} rule The rule
  5391. * @returns The Turndown instance for chaining
  5392. * @type Object
  5393. */
  5394. addRule: function(key, rule) {
  5395. this.rules.add(key, rule);
  5396. return this;
  5397. },
  5398. /**
  5399. * Keep a node (as HTML) that matches the filter
  5400. * @public
  5401. * @param {String|Array|Function} filter The unique key of the rule
  5402. * @returns The Turndown instance for chaining
  5403. * @type Object
  5404. */
  5405. keep: function(filter) {
  5406. this.rules.keep(filter);
  5407. return this;
  5408. },
  5409. /**
  5410. * Remove a node that matches the filter
  5411. * @public
  5412. * @param {String|Array|Function} filter The unique key of the rule
  5413. * @returns The Turndown instance for chaining
  5414. * @type Object
  5415. */
  5416. remove: function(filter) {
  5417. this.rules.remove(filter);
  5418. return this;
  5419. },
  5420. /**
  5421. * Escapes Markdown syntax
  5422. * @public
  5423. * @param {String} string The string to escape
  5424. * @returns A string with Markdown syntax escaped
  5425. * @type String
  5426. */
  5427. escape: function(string) {
  5428. return escapes.reduce(function(accumulator, escape) {
  5429. return accumulator.replace(escape[0], escape[1]);
  5430. }, string);
  5431. }
  5432. };
  5433. function process(parentNode) {
  5434. var self = this;
  5435. return reduce.call(parentNode.childNodes, function(output, node) {
  5436. node = new Node$1(node, self.options);
  5437. var replacement = "";
  5438. if (node.nodeType === 3) {
  5439. replacement = node.isCode ? node.nodeValue : self.escape(node.nodeValue);
  5440. } else if (node.nodeType === 1) {
  5441. replacement = replacementForNode.call(self, node);
  5442. }
  5443. return join(output, replacement);
  5444. }, "");
  5445. }
  5446. function postProcess(output) {
  5447. var self = this;
  5448. this.rules.forEach(function(rule) {
  5449. if (typeof rule.append === "function") {
  5450. output = join(output, rule.append(self.options));
  5451. }
  5452. });
  5453. return output.replace(/^[\t\r\n]+/, "").replace(/[\t\r\n\s]+$/, "");
  5454. }
  5455. function replacementForNode(node) {
  5456. var rule = this.rules.forNode(node);
  5457. var content = process.call(this, node);
  5458. var whitespace2 = node.flankingWhitespace;
  5459. if (whitespace2.leading || whitespace2.trailing) content = content.trim();
  5460. return whitespace2.leading + rule.replacement(content, node, this.options) + whitespace2.trailing;
  5461. }
  5462. function join(output, replacement) {
  5463. var s1 = trimTrailingNewlines(output);
  5464. var s2 = trimLeadingNewlines(replacement);
  5465. var nls = Math.max(output.length - s1.length, replacement.length - s2.length);
  5466. var separator = "\n\n".substring(0, nls);
  5467. return s1 + separator + s2;
  5468. }
  5469. function canConvert(input) {
  5470. return input != null && (typeof input === "string" || input.nodeType && (input.nodeType === 1 || input.nodeType === 9 || input.nodeType === 11));
  5471. }
  5472. var turndownPluginGfm_cjs = {};
  5473. var hasRequiredTurndownPluginGfm_cjs;
  5474. function requireTurndownPluginGfm_cjs() {
  5475. if (hasRequiredTurndownPluginGfm_cjs) return turndownPluginGfm_cjs;
  5476. hasRequiredTurndownPluginGfm_cjs = 1;
  5477. Object.defineProperty(turndownPluginGfm_cjs, "__esModule", { value: true });
  5478. var highlightRegExp = /highlight-(?:text|source)-([a-z0-9]+)/;
  5479. function highlightedCodeBlock(turndownService) {
  5480. turndownService.addRule("highlightedCodeBlock", {
  5481. filter: function(node) {
  5482. var firstChild = node.firstChild;
  5483. return node.nodeName === "DIV" && highlightRegExp.test(node.className) && firstChild && firstChild.nodeName === "PRE";
  5484. },
  5485. replacement: function(content, node, options) {
  5486. var className = node.className || "";
  5487. var language = (className.match(highlightRegExp) || [null, ""])[1];
  5488. return "\n\n" + options.fence + language + "\n" + node.firstChild.textContent + "\n" + options.fence + "\n\n";
  5489. }
  5490. });
  5491. }
  5492. function strikethrough(turndownService) {
  5493. turndownService.addRule("strikethrough", {
  5494. filter: ["del", "s", "strike"],
  5495. replacement: function(content) {
  5496. return "~~" + content + "~~";
  5497. }
  5498. });
  5499. }
  5500. var indexOf = Array.prototype.indexOf;
  5501. var every = Array.prototype.every;
  5502. var rules2 = {};
  5503. var alignMap = { left: ":---", right: "---:", center: ":---:" };
  5504. let isCodeBlock_ = null;
  5505. let options_ = null;
  5506. const tableShouldBeSkippedCache_ = /* @__PURE__ */ new WeakMap();
  5507. function getAlignment(node) {
  5508. return node ? (node.getAttribute("align") || node.style.textAlign || "").toLowerCase() : "";
  5509. }
  5510. function getBorder(alignment) {
  5511. return alignment ? alignMap[alignment] : "---";
  5512. }
  5513. function getColumnAlignment(table, columnIndex) {
  5514. var votes = {
  5515. left: 0,
  5516. right: 0,
  5517. center: 0,
  5518. "": 0
  5519. };
  5520. var align = "";
  5521. for (var i2 = 0; i2 < table.rows.length; ++i2) {
  5522. var row = table.rows[i2];
  5523. if (columnIndex < row.childNodes.length) {
  5524. var cellAlignment = getAlignment(row.childNodes[columnIndex]);
  5525. ++votes[cellAlignment];
  5526. if (votes[cellAlignment] > votes[align]) {
  5527. align = cellAlignment;
  5528. }
  5529. }
  5530. }
  5531. return align;
  5532. }
  5533. rules2.tableCell = {
  5534. filter: ["th", "td"],
  5535. replacement: function(content, node) {
  5536. if (tableShouldBeSkipped(nodeParentTable(node))) return content;
  5537. return cell(content, node);
  5538. }
  5539. };
  5540. rules2.tableRow = {
  5541. filter: "tr",
  5542. replacement: function(content, node) {
  5543. const parentTable = nodeParentTable(node);
  5544. if (tableShouldBeSkipped(parentTable)) return content;
  5545. var borderCells = "";
  5546. if (isHeadingRow(node)) {
  5547. const colCount = tableColCount(parentTable);
  5548. for (var i2 = 0; i2 < colCount; i2++) {
  5549. const childNode = i2 < node.childNodes.length ? node.childNodes[i2] : null;
  5550. var border = getBorder(getColumnAlignment(parentTable, i2));
  5551. borderCells += cell(border, childNode, i2);
  5552. }
  5553. }
  5554. return "\n" + content + (borderCells ? "\n" + borderCells : "");
  5555. }
  5556. };
  5557. rules2.table = {
  5558. filter: function(node, options) {
  5559. return node.nodeName === "TABLE";
  5560. },
  5561. replacement: function(content, node) {
  5562. if (tableShouldBeHtml(node, options_)) {
  5563. let html = node.outerHTML;
  5564. let divParent = nodeParentDiv(node);
  5565. if (divParent === null || !divParent.classList.contains("joplin-table-wrapper")) {
  5566. return `
  5567.  
  5568. <div class="joplin-table-wrapper">${html}</div>
  5569.  
  5570. `;
  5571. } else {
  5572. return html;
  5573. }
  5574. } else {
  5575. if (tableShouldBeSkipped(node)) return content;
  5576. content = content.replace(/\n+/g, "\n");
  5577. var secondLine = content.trim().split("\n");
  5578. if (secondLine.length >= 2) secondLine = secondLine[1];
  5579. var secondLineIsDivider = /\| :?---/.test(secondLine);
  5580. var columnCount = tableColCount(node);
  5581. var emptyHeader = "";
  5582. if (columnCount && !secondLineIsDivider) {
  5583. emptyHeader = "|" + " |".repeat(columnCount) + "\n|";
  5584. for (var columnIndex = 0; columnIndex < columnCount; ++columnIndex) {
  5585. emptyHeader += " " + getBorder(getColumnAlignment(node, columnIndex)) + " |";
  5586. }
  5587. }
  5588. const captionContent = node.caption ? node.caption.textContent || "" : "";
  5589. const caption = captionContent ? `${captionContent}
  5590.  
  5591. ` : "";
  5592. const tableContent = `${emptyHeader}${content}`.trimStart();
  5593. return `
  5594.  
  5595. ${caption}${tableContent}
  5596.  
  5597. `;
  5598. }
  5599. }
  5600. };
  5601. rules2.tableCaption = {
  5602. filter: ["caption"],
  5603. replacement: () => ""
  5604. };
  5605. rules2.tableColgroup = {
  5606. filter: ["colgroup", "col"],
  5607. replacement: () => ""
  5608. };
  5609. rules2.tableSection = {
  5610. filter: ["thead", "tbody", "tfoot"],
  5611. replacement: function(content) {
  5612. return content;
  5613. }
  5614. };
  5615. function isHeadingRow(tr) {
  5616. var parentNode = tr.parentNode;
  5617. return parentNode.nodeName === "THEAD" || parentNode.firstChild === tr && (parentNode.nodeName === "TABLE" || isFirstTbody(parentNode)) && every.call(tr.childNodes, function(n) {
  5618. return n.nodeName === "TH";
  5619. });
  5620. }
  5621. function isFirstTbody(element) {
  5622. var previousSibling = element.previousSibling;
  5623. return element.nodeName === "TBODY" && (!previousSibling || previousSibling.nodeName === "THEAD" && /^\s*$/i.test(previousSibling.textContent));
  5624. }
  5625. function cell(content, node = null, index2 = null) {
  5626. if (index2 === null) index2 = indexOf.call(node.parentNode.childNodes, node);
  5627. var prefix = " ";
  5628. if (index2 === 0) prefix = "| ";
  5629. let filteredContent = content.trim().replace(/\n\r/g, "<br>").replace(/\n/g, "<br>");
  5630. filteredContent = filteredContent.replace(/\|+/g, "\\|");
  5631. while (filteredContent.length < 3) filteredContent += " ";
  5632. if (node) filteredContent = handleColSpan(filteredContent, node, " ");
  5633. return prefix + filteredContent + " |";
  5634. }
  5635. function nodeContainsTable(node) {
  5636. if (!node.childNodes) return false;
  5637. for (let i2 = 0; i2 < node.childNodes.length; i2++) {
  5638. const child2 = node.childNodes[i2];
  5639. if (child2.nodeName === "TABLE") return true;
  5640. if (nodeContainsTable(child2)) return true;
  5641. }
  5642. return false;
  5643. }
  5644. const nodeContains = (node, types) => {
  5645. if (!node.childNodes) return false;
  5646. for (let i2 = 0; i2 < node.childNodes.length; i2++) {
  5647. const child2 = node.childNodes[i2];
  5648. if (types === "code" && isCodeBlock_ && isCodeBlock_(child2)) return true;
  5649. if (types.includes(child2.nodeName)) return true;
  5650. if (nodeContains(child2, types)) return true;
  5651. }
  5652. return false;
  5653. };
  5654. const tableShouldBeHtml = (tableNode, options) => {
  5655. const possibleTags = [
  5656. "UL",
  5657. "OL",
  5658. "H1",
  5659. "H2",
  5660. "H3",
  5661. "H4",
  5662. "H5",
  5663. "H6",
  5664. "HR",
  5665. "BLOCKQUOTE"
  5666. ];
  5667. if (options.preserveNestedTables) possibleTags.push("TABLE");
  5668. return nodeContains(tableNode, "code") || nodeContains(tableNode, possibleTags);
  5669. };
  5670. function tableShouldBeSkipped(tableNode) {
  5671. const cached = tableShouldBeSkippedCache_.get(tableNode);
  5672. if (cached !== void 0) return cached;
  5673. const result = tableShouldBeSkipped_(tableNode);
  5674. tableShouldBeSkippedCache_.set(tableNode, result);
  5675. return result;
  5676. }
  5677. function tableShouldBeSkipped_(tableNode) {
  5678. if (!tableNode) return true;
  5679. if (!tableNode.rows) return true;
  5680. if (tableNode.rows.length === 1 && tableNode.rows[0].childNodes.length <= 1) return true;
  5681. if (nodeContainsTable(tableNode)) return true;
  5682. return false;
  5683. }
  5684. function nodeParentDiv(node) {
  5685. let parent = node.parentNode;
  5686. while (parent.nodeName !== "DIV") {
  5687. parent = parent.parentNode;
  5688. if (!parent) return null;
  5689. }
  5690. return parent;
  5691. }
  5692. function nodeParentTable(node) {
  5693. let parent = node.parentNode;
  5694. while (parent.nodeName !== "TABLE") {
  5695. parent = parent.parentNode;
  5696. if (!parent) return null;
  5697. }
  5698. return parent;
  5699. }
  5700. function handleColSpan(content, node, emptyChar) {
  5701. const colspan = node.getAttribute("colspan") || 1;
  5702. for (let i2 = 1; i2 < colspan; i2++) {
  5703. content += " | " + emptyChar.repeat(3);
  5704. }
  5705. return content;
  5706. }
  5707. function tableColCount(node) {
  5708. let maxColCount = 0;
  5709. for (let i2 = 0; i2 < node.rows.length; i2++) {
  5710. const row = node.rows[i2];
  5711. const colCount = row.childNodes.length;
  5712. if (colCount > maxColCount) maxColCount = colCount;
  5713. }
  5714. return maxColCount;
  5715. }
  5716. function tables(turndownService) {
  5717. isCodeBlock_ = turndownService.isCodeBlock;
  5718. options_ = turndownService.options;
  5719. turndownService.keep(function(node) {
  5720. if (node.nodeName === "TABLE" && tableShouldBeHtml(node, turndownService.options)) return true;
  5721. return false;
  5722. });
  5723. for (var key in rules2) turndownService.addRule(key, rules2[key]);
  5724. }
  5725. function taskListItems(turndownService) {
  5726. turndownService.addRule("taskListItems", {
  5727. filter: function(node) {
  5728. return node.type === "checkbox" && node.parentNode.nodeName === "LI";
  5729. },
  5730. replacement: function(content, node) {
  5731. return (node.checked ? "[x]" : "[ ]") + " ";
  5732. }
  5733. });
  5734. }
  5735. function gfm(turndownService) {
  5736. turndownService.use([
  5737. highlightedCodeBlock,
  5738. strikethrough,
  5739. tables,
  5740. taskListItems
  5741. ]);
  5742. }
  5743. turndownPluginGfm_cjs.gfm = gfm;
  5744. turndownPluginGfm_cjs.highlightedCodeBlock = highlightedCodeBlock;
  5745. turndownPluginGfm_cjs.strikethrough = strikethrough;
  5746. turndownPluginGfm_cjs.tables = tables;
  5747. turndownPluginGfm_cjs.taskListItems = taskListItems;
  5748. return turndownPluginGfm_cjs;
  5749. }
  5750. var turndownPluginGfm_cjsExports = requireTurndownPluginGfm_cjs();
  5751. function createTurndownService() {
  5752. return new TurndownService({
  5753. emDelimiter: "*",
  5754. bulletListMarker: "-"
  5755. }).addRule("pre", {
  5756. filter: ["pre"],
  5757. replacement: (_content, node) => {
  5758. var _a2;
  5759. return "\n```txt\n" + ((_a2 = node.textContent) == null ? void 0 : _a2.trim()) + "\n```\n";
  5760. }
  5761. }).addRule("superscript", {
  5762. filter: ["sup"],
  5763. replacement: (content) => "^" + content
  5764. }).addRule("paragraph", {
  5765. filter: ["p"],
  5766. replacement: (content) => "\n\n" + content + "\n\n"
  5767. }).addRule("convert-path-for-img", {
  5768. filter: ["img"],
  5769. replacement: (_content, node) => {
  5770. const { src, alt } = node;
  5771. return `![${alt}](${src})`;
  5772. }
  5773. }).use(turndownPluginGfm_cjsExports.tables);
  5774. }
  5775. function htmlToMd(htmlStr, service = createTurndownService()) {
  5776. return service.turndown(htmlStr);
  5777. }
  5778. const getDescription = async () => {
  5779. const el = await findElement("[data-track-load='description_content']");
  5780. return htmlToMd(el.innerHTML);
  5781. };
  5782. function Copy_description($$anchor, $$props) {
  5783. push($$props, false);
  5784. async function copyDescription() {
  5785. copy(await getDescription());
  5786. }
  5787. init();
  5788. Button($$anchor, {
  5789. onclick: copyDescription,
  5790. children: ($$anchor2, $$slotProps) => {
  5791. var text$1 = text();
  5792. template_effect(() => set_text(text$1, state.site === "cn" ? "复制描述" : "Copy Description"));
  5793. append($$anchor2, text$1);
  5794. },
  5795. $$slots: { default: true }
  5796. });
  5797. pop();
  5798. }
  5799. function downloadFile(blob, filename, extension) {
  5800. const url = URL.createObjectURL(blob);
  5801. const a2 = document.createElement("a");
  5802. a2.href = url;
  5803. a2.download = filename + "." + extension;
  5804. document.body.appendChild(a2);
  5805. a2.click();
  5806. document.body.removeChild(a2);
  5807. URL.revokeObjectURL(url);
  5808. prefixToast.success(state.site === "cn" ? "开始下载……" : "Start downloading...");
  5809. }
  5810. function createNotebook({
  5811. title,
  5812. description,
  5813. language = "python",
  5814. url
  5815. }) {
  5816. var _a2, _b2;
  5817. const notebook = {
  5818. metadata: { language_info: { name: language } },
  5819. nbformat: 5,
  5820. nbformat_minor: 10,
  5821. cells: []
  5822. };
  5823. const regex = /^(https:\/\/(leetcode\.com|leetcode\.cn)\/problems\/[a-zA-Z0-9_-]+)/;
  5824. const match = url.match(regex);
  5825. const titleCell = createMarkdownCell(`# [${title}](${match ? match[0] : url})`);
  5826. const descriptionPrefix = state.site === "cn" ? "题目描述" : "Description";
  5827. const descriptionCell = createMarkdownCell(`## ${descriptionPrefix}
  5828.  
  5829. ` + description);
  5830. const solutionPrefix = state.site === "cn" ? "解答" : "Solution";
  5831. const partitionCell = createMarkdownCell(["---\n\n", `## ${solutionPrefix}`]);
  5832. const codeCell = createCodeCell(((_b2 = (_a2 = state.editor) == null ? void 0 : _a2.getModel()) == null ? void 0 : _b2.getValue()) ?? "");
  5833. notebook.cells.push(titleCell, descriptionCell, partitionCell, codeCell);
  5834. return notebook;
  5835. }
  5836. function createMarkdownCell(content) {
  5837. return {
  5838. cell_type: "markdown",
  5839. metadata: {},
  5840. source: content
  5841. };
  5842. }
  5843. function createCodeCell(content) {
  5844. return {
  5845. cell_type: "code",
  5846. metadata: {},
  5847. source: content,
  5848. execution_count: null,
  5849. outputs: []
  5850. };
  5851. }
  5852. function downloadNotebook(notebook, filename) {
  5853. const blob = new Blob([JSON.stringify(notebook)], { type: "application/x-ipynb+json" });
  5854. downloadFile(blob, filename, "ipynb");
  5855. }
  5856. function Download_as_jupyter($$anchor, $$props) {
  5857. push($$props, false);
  5858. const getLanguage = () => {
  5859. var _a2, _b2;
  5860. return ((_b2 = (_a2 = state.editor) == null ? void 0 : _a2.getModel()) == null ? void 0 : _b2.getLanguageId()) ?? "python";
  5861. };
  5862. async function downloadAsJupyter() {
  5863. const title = await getTitle();
  5864. const notebook = createNotebook({
  5865. title,
  5866. description: await getDescription(),
  5867. language: getLanguage(),
  5868. url: window.location.href
  5869. });
  5870. downloadNotebook(notebook, title);
  5871. }
  5872. init();
  5873. Button($$anchor, {
  5874. style: "color: oklch(51.1% 0.096 186.391)",
  5875. onclick: downloadAsJupyter,
  5876. children: ($$anchor2, $$slotProps) => {
  5877. var text$1 = text();
  5878. template_effect(() => set_text(text$1, state.site === "cn" ? "下载为 Jupyter Notebook (.ipynb)" : "Download as Jupyter Notebook (.ipynb)"));
  5879. append($$anchor2, text$1);
  5880. },
  5881. $$slots: { default: true }
  5882. });
  5883. pop();
  5884. }
  5885. const editorialsMarkdown = _GM_getResourceText("editorials");
  5886. function extractScreenshotLink(problemTitle) {
  5887. const cleanTitle = problemTitle.trim();
  5888. const headingPattern = new RegExp(
  5889. `####\\s+\\[${cleanTitle.replace(
  5890. /[.*+?^${}()|[\]\\]/g,
  5891. "\\$&"
  5892. )}\\]\\((.*?)\\)`,
  5893. "i"
  5894. );
  5895. const match = editorialsMarkdown.match(headingPattern);
  5896. return match ? match[1] : null;
  5897. }
  5898. function Find_editorial_screenshot($$anchor, $$props) {
  5899. push($$props, false);
  5900. async function goToEditorialScreenshot() {
  5901. const title = await getTitle();
  5902. const link2 = extractScreenshotLink(title);
  5903. if (link2) {
  5904. window.open(link2, "_blank");
  5905. } else {
  5906. toast.warning(`Editorial screenshot not found for problem: ${title}`);
  5907. }
  5908. }
  5909. init();
  5910. Button($$anchor, {
  5911. style: "color: rgb(255, 161, 22)",
  5912. onclick: goToEditorialScreenshot,
  5913. children: ($$anchor2, $$slotProps) => {
  5914. var text$1 = text("Find Editorial");
  5915. append($$anchor2, text$1);
  5916. },
  5917. $$slots: { default: true }
  5918. });
  5919. pop();
  5920. }
  5921. var root = /* @__PURE__ */ template(`<div><!> <!> <!> <!></div>`);
  5922. function App($$anchor, $$props) {
  5923. push($$props, false);
  5924. document.addEventListener("keydown", async () => {
  5925. var _a2, _b2;
  5926. try {
  5927. await ((_b2 = (_a2 = state.editor) == null ? void 0 : _a2.getAction("editor.action.formatDocument")) == null ? void 0 : _b2.run());
  5928. } catch (err) {
  5929. console.error(err);
  5930. if (err instanceof Error) {
  5931. toast.error("Failed to format code:" + err.message);
  5932. }
  5933. }
  5934. });
  5935. init();
  5936. var div = root();
  5937. var node = child(div);
  5938. Copy_title(node, {});
  5939. var node_1 = sibling(node, 2);
  5940. Copy_description(node_1, {});
  5941. var node_2 = sibling(node_1, 2);
  5942. Download_as_jupyter(node_2, {});
  5943. var node_3 = sibling(node_2, 2);
  5944. {
  5945. var consequent = ($$anchor2) => {
  5946. Find_editorial_screenshot($$anchor2, {});
  5947. };
  5948. if_block(node_3, ($$render) => {
  5949. if (state.site === "global") $$render(consequent);
  5950. });
  5951. }
  5952. append($$anchor, div);
  5953. pop();
  5954. }
  5955. function u$1(o2, n, a2) {
  5956. let t = (r2) => o2(r2, ...n);
  5957. return a2 === void 0 ? t : Object.assign(t, { lazy: a2, lazyArgs: n });
  5958. }
  5959. function u(r2, n, o2) {
  5960. let a2 = r2.length - n.length;
  5961. if (a2 === 0) return r2(...n);
  5962. if (a2 === 1) return u$1(r2, n, o2);
  5963. throw new Error("Wrong number of arguments");
  5964. }
  5965. var o$1 = [" ", `
  5966. `, "\v", "\f", "\r", " ", "…", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", " ", "\u2028", "\u2029", " ", " ", " ", "\uFEFF"], c = /* @__PURE__ */ new Set(["-", "_", ...o$1]), i = (r2) => {
  5967. let e = [], t = "", u2 = () => {
  5968. t.length > 0 && (e.push(t), t = "");
  5969. };
  5970. for (let s of r2) {
  5971. if (c.has(s)) {
  5972. u2();
  5973. continue;
  5974. }
  5975. if (/[a-z]$/u.test(t) && /[A-Z]/u.test(s)) u2();
  5976. else if (/[A-Z][A-Z]$/u.test(t) && /[a-z]/u.test(s)) {
  5977. let n = t.slice(-1);
  5978. t = t.slice(0, -1), u2(), t = n;
  5979. } else /\d$/u.test(t) !== /\d/u.test(s) && u2();
  5980. t += s;
  5981. }
  5982. return u2(), e;
  5983. };
  5984. function a(...e) {
  5985. return u(o, e);
  5986. }
  5987. var o = (e) => i(e).join("-").toLowerCase();
  5988. const turndown = createTurndownService();
  5989. turndown.addRule("remove-heading-link", {
  5990. filter: (node) => node.nodeName === "A" && node.getAttribute("aria-hidden") === "true",
  5991. replacement: () => ""
  5992. });
  5993. turndown.addRule("save-playground-link", {
  5994. filter: ["iframe"],
  5995. replacement: (_content, node) => {
  5996. const link2 = node.getAttribute("src");
  5997. return (link2 == null ? void 0 : link2.includes("playground")) ? `[LeetCode Playground](${link2})` : "";
  5998. }
  5999. });
  6000. async function downloadEditorial() {
  6001. const titleEl = await findElement("#editorial-quick-navigation");
  6002. const editorialEl = await findElement(
  6003. ".flexlayout__tab:has(#editorial-quick-navigation) div.WRmCx"
  6004. );
  6005. const editorial = htmlToMd(editorialEl.innerHTML, turndown);
  6006. const blob = new Blob([editorial], {
  6007. type: "text/markdown; charset=UTF-8"
  6008. });
  6009. downloadFile(blob, titleEl.textContent ?? "Untitled", "md");
  6010. }
  6011. mount(Toaster, {
  6012. target: document.body,
  6013. props: { richColors: true, position: "top-center" }
  6014. });
  6015. await( state.init());
  6016. if (state.site === "global") {
  6017. _GM_registerMenuCommand(
  6018. "Download Editorial (Experimental)",
  6019. () => downloadEditorial()
  6020. );
  6021. }
  6022. const descriptionTab = await( findElement(
  6023. ".flexlayout__tab:has([data-track-load='description_content'])",
  6024. {
  6025. timeout: 0,
  6026. additionalRule: (el) => el.style.display !== "none"
  6027. }
  6028. ));
  6029. console.log("description tab is active!");
  6030. const titleContainer = await( findElement("div:has(> .text-title-large)", {
  6031. parent: descriptionTab
  6032. }));
  6033. const app = document.createElement("div");
  6034. app.setAttribute("id", a(CONFIG.APP_NAME));
  6035. app.style.cssText = "display: contents;";
  6036. (_b = titleContainer.parentElement) == null ? void 0 : _b.before(app);
  6037. mount(App, {
  6038. target: app
  6039. });
  6040.  
  6041. })();