vanilla-breeze 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (268) hide show
  1. package/dist/cdn/components/accessibility-specimen.js +11 -0
  2. package/dist/cdn/components/accordion-wc.js +1 -1
  3. package/dist/cdn/components/activity-feed.js +2 -0
  4. package/dist/cdn/components/adr-wc.js +17 -17
  5. package/dist/cdn/components/ai-chat.js +28 -0
  6. package/dist/cdn/components/ai-summary.js +10 -0
  7. package/dist/cdn/components/analytics-panel.js +5 -5
  8. package/dist/cdn/components/audio-player.js +3 -3
  9. package/dist/cdn/components/audio-visualizer.js +2 -2
  10. package/dist/cdn/components/author-index.js +2 -2
  11. package/dist/cdn/components/brand-mark.js +1 -1
  12. package/dist/cdn/components/bread-crumb.js +2 -0
  13. package/dist/cdn/components/breakpoint-specimen.js +26 -0
  14. package/dist/cdn/components/burndown-chart.js +2 -0
  15. package/dist/cdn/components/calendar-wc.js +2 -2
  16. package/dist/cdn/components/capacity-plan.js +25 -0
  17. package/dist/cdn/components/card-list.js +1 -1
  18. package/dist/cdn/components/carousel-wc.js +1 -1
  19. package/dist/cdn/components/change-set.js +2 -2
  20. package/dist/cdn/components/chart-wc.js +58 -36
  21. package/dist/cdn/components/chat-input.js +1 -1
  22. package/dist/cdn/components/chat-window.js +1 -1
  23. package/dist/cdn/components/color-palette.js +9 -9
  24. package/dist/cdn/components/color-picker.js +1 -1
  25. package/dist/cdn/components/combo-box.js +1 -1
  26. package/dist/cdn/components/command-palette.js +1 -1
  27. package/dist/cdn/components/comment-box.js +60 -0
  28. package/dist/cdn/components/comment-thread.js +60 -0
  29. package/dist/cdn/components/comment-wc.js +1 -1
  30. package/dist/cdn/components/compare-surface.js +1 -1
  31. package/dist/cdn/components/component-sampler.js +2 -2
  32. package/dist/cdn/components/consent-banner.js +1 -1
  33. package/dist/cdn/components/content-lens.js +1 -1
  34. package/dist/cdn/components/content-swap.js +1 -1
  35. package/dist/cdn/components/context-menu.js +1 -1
  36. package/dist/cdn/components/data-table.js +1 -1
  37. package/dist/cdn/components/date-picker.js +1 -1
  38. package/dist/cdn/components/day-view.js +1 -1
  39. package/dist/cdn/components/diagram-wc.js +3 -0
  40. package/dist/cdn/components/drag-surface.js +1 -1
  41. package/dist/cdn/components/drop-down.js +1 -1
  42. package/dist/cdn/components/emoji-picker.js +1 -1
  43. package/dist/cdn/components/empathy-map.js +41 -43
  44. package/dist/cdn/components/flow-diagram.js +1 -1
  45. package/dist/cdn/components/font-pairer.js +81 -81
  46. package/dist/cdn/components/foot-notes.js +1 -1
  47. package/dist/cdn/components/form-field.js +1 -1
  48. package/dist/cdn/components/gantt-chart.js +1 -1
  49. package/dist/cdn/components/geo-map.js +25 -23
  50. package/dist/cdn/components/glossary-index.js +1 -1
  51. package/dist/cdn/components/glossary-wc.js +1 -1
  52. package/dist/cdn/components/gradient-builder.js +29 -29
  53. package/dist/cdn/components/heading-links.js +1 -1
  54. package/dist/cdn/components/highlight-wc.js +2 -2
  55. package/dist/cdn/components/image-gallery.js +1 -1
  56. package/dist/cdn/components/image-map.js +1 -1
  57. package/dist/cdn/components/impact-effort.js +1 -1
  58. package/dist/cdn/components/include-file.js +1 -1
  59. package/dist/cdn/components/iron-triangle.js +2 -0
  60. package/dist/cdn/components/kanban-board.js +1 -1
  61. package/dist/cdn/components/layout-specimen.js +35 -0
  62. package/dist/cdn/components/manifest.json +228 -100
  63. package/dist/cdn/components/markdown-editor.js +1 -1
  64. package/dist/cdn/components/markdown-viewer.js +12 -12
  65. package/dist/cdn/components/motion-specimen.js +12 -12
  66. package/dist/cdn/components/nav-bar.js +2 -0
  67. package/dist/cdn/components/note-wc.js +2 -2
  68. package/dist/cdn/components/notification-wc.js +4 -4
  69. package/dist/cdn/components/page-info.js +4 -4
  70. package/dist/cdn/components/page-stats.js +1 -1
  71. package/dist/cdn/components/page-toc.js +1 -1
  72. package/dist/cdn/components/page-tools.js +1 -1
  73. package/dist/cdn/components/page-tour.js +6 -6
  74. package/dist/cdn/components/pager-wc.js +2 -0
  75. package/dist/cdn/components/palette-generator.js +11 -11
  76. package/dist/cdn/components/poll-wc.js +2 -0
  77. package/dist/cdn/components/pop-over.js +2 -0
  78. package/dist/cdn/components/popularity-index.js +2 -2
  79. package/dist/cdn/components/print-page.js +1 -1
  80. package/dist/cdn/components/product-roadmap.js +3 -0
  81. package/dist/cdn/components/progress-tracker.js +2 -0
  82. package/dist/cdn/components/qr-code.js +1 -1
  83. package/dist/cdn/components/quadrant-grid.js +3 -0
  84. package/dist/cdn/components/quality-target.js +12 -0
  85. package/dist/cdn/components/reaction-bar.js +2 -0
  86. package/dist/cdn/components/reader-view.js +3 -3
  87. package/dist/cdn/components/reading-progress.js +2 -0
  88. package/dist/cdn/components/recently-visited.js +10 -10
  89. package/dist/cdn/components/requirement-card.js +122 -0
  90. package/dist/cdn/components/review-surface.js +34 -40
  91. package/dist/cdn/components/risk-register.js +25 -0
  92. package/dist/cdn/components/roadmap.js +3 -0
  93. package/dist/cdn/components/score-card.js +197 -0
  94. package/dist/cdn/components/selection-menu.js +1 -1
  95. package/dist/cdn/components/semantic-palette.js +15 -15
  96. package/dist/cdn/components/settings-panel.js +12 -12
  97. package/dist/cdn/components/share-wc.js +2 -2
  98. package/dist/cdn/components/short-cuts.js +1 -1
  99. package/dist/cdn/components/site-index.js +4 -4
  100. package/dist/cdn/components/site-map-wc.js +1 -1
  101. package/dist/cdn/components/site-map.js +1 -1
  102. package/dist/cdn/components/site-search.js +9 -9
  103. package/dist/cdn/components/slide-accept.js +1 -1
  104. package/dist/cdn/components/social-embed.js +1 -1
  105. package/dist/cdn/components/spacing-specimen.js +5 -5
  106. package/dist/cdn/components/split-surface.js +1 -1
  107. package/dist/cdn/components/star-rating.js +1 -1
  108. package/dist/cdn/components/status-wc.js +2 -0
  109. package/dist/cdn/components/stepper-wc.js +2 -0
  110. package/dist/cdn/components/story-map.js +1 -1
  111. package/dist/cdn/components/tab-set.js +1 -1
  112. package/dist/cdn/components/text-reader.js +2 -2
  113. package/dist/cdn/components/theme-catalog.js +28 -0
  114. package/dist/cdn/components/theme-export.js +20 -12
  115. package/dist/cdn/components/theme-import.js +44 -0
  116. package/dist/cdn/components/theme-picker.js +29 -26
  117. package/dist/cdn/components/time-index.js +2 -2
  118. package/dist/cdn/components/time-picker.js +1 -1
  119. package/dist/cdn/components/toast-msg.js +3 -3
  120. package/dist/cdn/components/token-specimen.js +14 -14
  121. package/dist/cdn/components/tool-tip.js +1 -1
  122. package/dist/cdn/components/topic-map.js +3 -3
  123. package/dist/cdn/components/traceability-matrix.js +3 -0
  124. package/dist/cdn/components/trust-filter.js +3 -3
  125. package/dist/cdn/components/type-specimen.js +15 -15
  126. package/dist/cdn/components/user-journey.js +63 -70
  127. package/dist/cdn/components/user-persona.js +75 -13
  128. package/dist/cdn/components/user-story.js +9 -8
  129. package/dist/cdn/components/version-switcher.js +17 -0
  130. package/dist/cdn/components/video-player.js +3 -3
  131. package/dist/cdn/components/watch-wc.js +2 -2
  132. package/dist/cdn/components/week-view.js +1 -1
  133. package/dist/cdn/components/work-item.js +29 -28
  134. package/dist/cdn/components/youtube-player.js +1 -1
  135. package/dist/cdn/packs/design-system.full.js +59 -51
  136. package/dist/cdn/packs/effects.full.js +1 -1
  137. package/dist/cdn/packs/icons.effects.js +1 -1
  138. package/dist/cdn/packs/icons.full.js +1 -1
  139. package/dist/cdn/packs/kawaii.full.css +1 -1
  140. package/dist/cdn/packs/kawaii.full.js +6 -6
  141. package/dist/cdn/packs/kawaii.theme.css +1 -1
  142. package/dist/cdn/packs/manifest.json +11 -11
  143. package/dist/cdn/packs/ui.full.css +1 -1
  144. package/dist/cdn/packs/ui.full.js +54 -51
  145. package/dist/cdn/packs/ux-planning.full.css +1 -1
  146. package/dist/cdn/packs/ux-planning.full.js +317 -241
  147. package/dist/cdn/themes/8bit.css +1 -1
  148. package/dist/cdn/themes/8bit.tokens.json +662 -0
  149. package/dist/cdn/themes/alpha1999-dark.tokens.json +693 -0
  150. package/dist/cdn/themes/alpha1999.css +1 -1
  151. package/dist/cdn/themes/alpha1999.tokens.json +869 -0
  152. package/dist/cdn/themes/anthropic.css +2 -0
  153. package/dist/cdn/themes/anthropic.tokens.json +564 -0
  154. package/dist/cdn/themes/art-deco-dark.tokens.json +407 -0
  155. package/dist/cdn/themes/art-deco.css +1 -1
  156. package/dist/cdn/themes/art-deco.tokens.json +581 -0
  157. package/dist/cdn/themes/bauhaus-dark.tokens.json +260 -0
  158. package/dist/cdn/themes/bauhaus.css +1 -1
  159. package/dist/cdn/themes/bauhaus.tokens.json +589 -0
  160. package/dist/cdn/themes/brutalist-dark.tokens.json +503 -0
  161. package/dist/cdn/themes/brutalist.tokens.json +677 -0
  162. package/dist/cdn/themes/catalog/atlassian.tokens.json +303 -0
  163. package/dist/cdn/themes/catalog/bootstrap.tokens.json +304 -0
  164. package/dist/cdn/themes/catalog/carbon.tokens.json +301 -0
  165. package/dist/cdn/themes/catalog/catppuccin-mocha.tokens.json +301 -0
  166. package/dist/cdn/themes/catalog/govuk.tokens.json +301 -0
  167. package/dist/cdn/themes/catalog/manifest.json +132 -0
  168. package/dist/cdn/themes/catalog/material.tokens.json +289 -0
  169. package/dist/cdn/themes/catalog/salesforce.tokens.json +301 -0
  170. package/dist/cdn/themes/catalog/tailwind.tokens.json +302 -0
  171. package/dist/cdn/themes/catppuccin-frappe.css +1 -1
  172. package/dist/cdn/themes/catppuccin-frappe.tokens.json +608 -0
  173. package/dist/cdn/themes/catppuccin-latte-dark.tokens.json +472 -0
  174. package/dist/cdn/themes/catppuccin-latte.css +1 -1
  175. package/dist/cdn/themes/catppuccin-latte.tokens.json +608 -0
  176. package/dist/cdn/themes/catppuccin-macchiato.css +1 -1
  177. package/dist/cdn/themes/catppuccin-macchiato.tokens.json +608 -0
  178. package/dist/cdn/themes/catppuccin-mocha.tokens.json +608 -0
  179. package/dist/cdn/themes/classic-dark.tokens.json +503 -0
  180. package/dist/cdn/themes/classic.tokens.json +640 -0
  181. package/dist/cdn/themes/claymorphism-dark.tokens.json +493 -0
  182. package/dist/cdn/themes/claymorphism.css +1 -1
  183. package/dist/cdn/themes/claymorphism.tokens.json +626 -0
  184. package/dist/cdn/themes/clinical-dark.tokens.json +472 -0
  185. package/dist/cdn/themes/clinical.tokens.json +608 -0
  186. package/dist/cdn/themes/cottagecore-dark.tokens.json +412 -0
  187. package/dist/cdn/themes/cottagecore.css +1 -1
  188. package/dist/cdn/themes/cottagecore.tokens.json +544 -0
  189. package/dist/cdn/themes/cyber.tokens.json +668 -0
  190. package/dist/cdn/themes/dawn-dark.tokens.json +472 -0
  191. package/dist/cdn/themes/dawn.css +1 -1
  192. package/dist/cdn/themes/dawn.tokens.json +608 -0
  193. package/dist/cdn/themes/dracula.tokens.json +534 -0
  194. package/dist/cdn/themes/dusk.tokens.json +533 -0
  195. package/dist/cdn/themes/editorial-dark.tokens.json +400 -0
  196. package/dist/cdn/themes/editorial.tokens.json +690 -0
  197. package/dist/cdn/themes/financial-dark.tokens.json +472 -0
  198. package/dist/cdn/themes/financial.css +1 -1
  199. package/dist/cdn/themes/financial.tokens.json +607 -0
  200. package/dist/cdn/themes/genai.tokens.json +534 -0
  201. package/dist/cdn/themes/glassmorphism-dark.tokens.json +489 -0
  202. package/dist/cdn/themes/glassmorphism.css +1 -1
  203. package/dist/cdn/themes/glassmorphism.tokens.json +632 -0
  204. package/dist/cdn/themes/government-dark.tokens.json +472 -0
  205. package/dist/cdn/themes/government.tokens.json +608 -0
  206. package/dist/cdn/themes/gruvbox-dark.tokens.json +472 -0
  207. package/dist/cdn/themes/gruvbox.tokens.json +608 -0
  208. package/dist/cdn/themes/high-noon-dark.tokens.json +397 -0
  209. package/dist/cdn/themes/high-noon.tokens.json +533 -0
  210. package/dist/cdn/themes/ibm.css +2 -0
  211. package/dist/cdn/themes/ibm.tokens.json +568 -0
  212. package/dist/cdn/themes/kawaii-dark.tokens.json +549 -0
  213. package/dist/cdn/themes/kawaii.css +1 -1
  214. package/dist/cdn/themes/kawaii.tokens.json +641 -0
  215. package/dist/cdn/themes/magna-dark.tokens.json +482 -0
  216. package/dist/cdn/themes/magna.css +1 -1
  217. package/dist/cdn/themes/magna.tokens.json +632 -0
  218. package/dist/cdn/themes/manifest.json +162 -62
  219. package/dist/cdn/themes/mcdonalds.css +2 -0
  220. package/dist/cdn/themes/mcdonalds.tokens.json +533 -0
  221. package/dist/cdn/themes/midnight.tokens.json +534 -0
  222. package/dist/cdn/themes/minimal-dark.tokens.json +294 -0
  223. package/dist/cdn/themes/minimal.tokens.json +494 -0
  224. package/dist/cdn/themes/modern-dark.tokens.json +490 -0
  225. package/dist/cdn/themes/modern.tokens.json +573 -0
  226. package/dist/cdn/themes/nes-dark.tokens.json +564 -0
  227. package/dist/cdn/themes/nes.css +1 -1
  228. package/dist/cdn/themes/nes.tokens.json +687 -0
  229. package/dist/cdn/themes/neumorphism-dark.tokens.json +471 -0
  230. package/dist/cdn/themes/neumorphism.css +1 -1
  231. package/dist/cdn/themes/neumorphism.tokens.json +589 -0
  232. package/dist/cdn/themes/nord-dark.tokens.json +484 -0
  233. package/dist/cdn/themes/nord.tokens.json +619 -0
  234. package/dist/cdn/themes/organic-dark.tokens.json +532 -0
  235. package/dist/cdn/themes/organic.tokens.json +685 -0
  236. package/dist/cdn/themes/rose-pine-dark.tokens.json +472 -0
  237. package/dist/cdn/themes/rose-pine.tokens.json +608 -0
  238. package/dist/cdn/themes/rough-dark.tokens.json +515 -0
  239. package/dist/cdn/themes/rough.css +1 -1
  240. package/dist/cdn/themes/rough.tokens.json +650 -0
  241. package/dist/cdn/themes/solarized-dark.tokens.json +397 -0
  242. package/dist/cdn/themes/solarized.tokens.json +532 -0
  243. package/dist/cdn/themes/starbucks.css +2 -0
  244. package/dist/cdn/themes/starbucks.tokens.json +593 -0
  245. package/dist/cdn/themes/startup-dark.tokens.json +522 -0
  246. package/dist/cdn/themes/startup.css +1 -1
  247. package/dist/cdn/themes/startup.tokens.json +607 -0
  248. package/dist/cdn/themes/super2026-dark.tokens.json +667 -0
  249. package/dist/cdn/themes/super2026.tokens.json +863 -0
  250. package/dist/cdn/themes/swiss-dark.tokens.json +390 -0
  251. package/dist/cdn/themes/swiss.tokens.json +750 -0
  252. package/dist/cdn/themes/terminal.css +1 -1
  253. package/dist/cdn/themes/terminal.tokens.json +689 -0
  254. package/dist/cdn/themes/tokyo-night-dark.tokens.json +472 -0
  255. package/dist/cdn/themes/tokyo-night.tokens.json +608 -0
  256. package/dist/cdn/themes/vaporwave-dark.tokens.json +413 -0
  257. package/dist/cdn/themes/vaporwave.tokens.json +549 -0
  258. package/dist/cdn/themes/win9x-dark.tokens.json +563 -0
  259. package/dist/cdn/themes/win9x.tokens.json +700 -0
  260. package/dist/cdn/vanilla-breeze-charts.css +1 -1
  261. package/dist/cdn/vanilla-breeze-charts.js +58 -36
  262. package/dist/cdn/vanilla-breeze-core.css +1 -1
  263. package/dist/cdn/vanilla-breeze-core.js +246 -51
  264. package/dist/cdn/vanilla-breeze-dev.js +1 -1
  265. package/dist/cdn/vanilla-breeze-extras.js +90 -80
  266. package/dist/cdn/vanilla-breeze.css +1 -1
  267. package/dist/cdn/vanilla-breeze.js +1363 -398
  268. package/package.json +10 -3
@@ -1,2 +1,2 @@
1
- function l(r){if(!r||typeof r!="string")return"";let t=document.createElement("template");return t.innerHTML=r,t.content.querySelectorAll("script, iframe, object, embed, form, base, link, meta, noscript").forEach(i=>i.remove()),t.content.querySelectorAll("*").forEach(i=>{for(let s of[...i.attributes]){if(s.name.startsWith("on")){i.removeAttribute(s.name);continue}if(["href","src","action","formaction","xlink:href"].includes(s.name)){let a=s.value.trim().toLowerCase();(a.startsWith("javascript:")||a.startsWith("data:text/html"))&&i.removeAttribute(s.name);continue}(s.name==="srcdoc"||s.name==="data"&&i.tagName==="OBJECT")&&i.removeAttribute(s.name)}}),t.innerHTML}var m=window.matchMedia("(prefers-reduced-motion: reduce)");var u=new Map;function h(r,t,e={}){let n=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:n},s=u.get(r);if(customElements.get(r)){if(!s||s.priority>=n){s&&s.priority===n&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=n){s.priority===n&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}u.set(r,i),customElements.define(r,t)}var c=class extends HTMLElement{#t=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,n,i){t.addEventListener(e,n,i),this.#t.push(()=>t.removeEventListener(e,n,i))}setup(){}teardown(){}};var d=class extends c{#t=null;#i=null;#e=null;#n=new Map;#s=null;setup(){this.#u(),this.#h(),this.#f(),this.#c(),this.#r(),this.#m()}teardown(){}#u(){this.#t=this.querySelector(":scope > chat-thread"),this.#i=this.querySelector(":scope > chat-input"),this.#e=this.querySelector(":scope > header select[data-model-select]")}#h(){let t=this.querySelector(":scope > script[data-participants]");if(t)try{let e=JSON.parse(t.textContent);this.#n=new Map(Object.entries(e))}catch{console.warn("[chat-window] Invalid participant JSON")}}#c(){if(this.#t)for(let t of this.#t.querySelectorAll("chat-message[data-from]"))this.#o(t)}#o(t){let e=t.getAttribute("data-from");if(!e)return;let n=this.#n.get(e);n?.name?t.setAttribute("data-from-label",n.name):t.hasAttribute("data-from-label")||t.setAttribute("data-from-label",e)}#f(){if(!this.#e)return;let t=this.getAttribute("model");t?this.#e.value=t:this.#e.value&&this.setAttribute("model",this.#e.value)}#m(){this.listen(this,"chat-input:send",this.#p),this.#e&&this.listen(this.#e,"change",this.#b)}#p=async t=>{t.stopPropagation();let{message:e}=t.detail;if(!e||!this.#t)return;let n=this.#l("user",e,"user");this.#t.appendChild(n),this.#a(),this.#r();let i=this.#y(),s=this.#g(i);this.#t.appendChild(s),this.#a(),this.#i&&(this.#i.disabled=!0);let a=this.getAttribute("endpoint");if(a)try{let o=await this.#E(a,e);this.#d(s,o)}catch(o){this.#d(s,"<p>Sorry, something went wrong.</p>"),s.setAttribute("data-status","error"),this.dispatchEvent(new CustomEvent("chat-window:error",{bubbles:!0,detail:{error:o.message,status:o.status??0}}))}else this.dispatchEvent(new CustomEvent("chat-window:send",{bubbles:!0,detail:{message:e,typingElement:s}}));this.#i&&(this.#i.disabled=!1,this.#i.focus()),this.#a()};#b=()=>{let t=this.#e.value;this.setAttribute("model",t),this.dispatchEvent(new CustomEvent("chat-window:model-change",{bubbles:!0,detail:{model:t}}))};#l(t,e,n){let i=document.createElement("chat-message");i.setAttribute("data-role",t),n&&(i.setAttribute("data-from",n),this.#o(i));let s=document.createElement("chat-bubble");if(e.includes("<"))s.innerHTML=l(e);else{let a=document.createElement("p");a.textContent=e,s.appendChild(a)}return i.appendChild(s),i}#g(t){let e=document.createElement("chat-message");if(e.setAttribute("data-role","agent"),e.setAttribute("data-status","typing"),t){e.setAttribute("data-from",t),this.#o(e);let a=this.#n.get(t)?.name??t;e.setAttribute("aria-label",`${a} is typing`)}else e.setAttribute("aria-label","Agent is typing");let n=this.getAttribute("model");n&&e.setAttribute("data-model",n);let i=document.createElement("chat-bubble");return e.appendChild(i),e}#d(t,e){let n=t.querySelector("chat-bubble");n&&(n.innerHTML=l(e)),t.removeAttribute("data-status"),t.removeAttribute("aria-label")}#y(){for(let[t,e]of this.#n)if(e.role==="agent")return t;return null}#r(){if(!this.#t)return;this.#t.querySelector("chat-message")!==null?(this.#s&&(this.#s.remove(),this.#s=null),this.#t.hidden=!1):(this.#t.hidden=!0,this.#s||(this.#s=document.createElement("p"),this.#s.setAttribute("data-chat-empty",""),this.#s.textContent=this.getAttribute("empty-message")||"Send a message to start.",this.#t.insertAdjacentElement("afterend",this.#s)))}#a(){this.#t&&requestAnimationFrame(()=>{this.#t.scrollTop=this.#t.scrollHeight})}async#E(t,e){let n={message:e,model:this.getAttribute("model")||void 0},i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok){let a=new Error(`Chat request failed: ${i.status}`);throw a.status=i.status,a}let s=await i.json();return s.html??s.message??s.content??""}get model(){return this.getAttribute("model")??""}set model(t){this.setAttribute("model",t),this.#e&&(this.#e.value=t)}get participants(){return this.#n}set participants(t){this.#n=t instanceof Map?t:new Map(Object.entries(t)),this.#c()}clearThread(){if(this.#t){for(;this.#t.firstChild;)this.#t.removeChild(this.#t.firstChild);this.#r()}}appendMessage(t,e,n){if(!this.#t)return;let i=this.#l(t,e,n);this.#t.appendChild(i),this.#a(),this.#r()}};h("chat-window",d);export{d as ChatWindow};
1
+ function b(o){if(!o||typeof o!="string")return"";let t=document.createElement("template");return t.innerHTML=o,t.content.querySelectorAll("script, iframe, object, embed, form, base, link, meta, noscript").forEach(n=>n.remove()),t.content.querySelectorAll("*").forEach(n=>{for(let i of[...n.attributes]){if(i.name.startsWith("on")){n.removeAttribute(i.name);continue}if(["href","src","action","formaction","xlink:href"].includes(i.name)){let r=i.value.trim().toLowerCase();(r.startsWith("javascript:")||r.startsWith("data:text/html"))&&n.removeAttribute(i.name);continue}(i.name==="srcdoc"||i.name==="data"&&n.tagName==="OBJECT")&&n.removeAttribute(i.name)}}),t.innerHTML}var C=window.matchMedia("(prefers-reduced-motion: reduce)");var E=new Map;function A(o,t,e={}){let s=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:s},i=E.get(o);if(customElements.get(o)){if(!i||i.priority>=s){i&&i.priority===s&&i.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=s){i.priority===s&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${i.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}E.set(o,n),customElements.define(o,t)}var m=class extends HTMLElement{#t=[];#e;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#t)t();this.#t=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,n){t.addEventListener(e,s,n),this.#t.push(()=>t.removeEventListener(e,s,n))}setup(){}teardown(){}setState(t,e){this.#e||(this.#e=this.attachInternals());let s=this.#e.states;try{e?s.add(t):s.delete(t)}catch{let n=`--${t}`;e?s.add(n):s.delete(n)}}_adoptInternals(t){this.#e||(this.#e=t)}};function v({newItems:o,nodes:t,keyOf:e,renderItem:s,containerFor:n}){let i=[],r=[],l=[],y=new Set;for(let a of o)y.add(e(a));for(let[a,d]of[...t])y.has(a)||(d.remove(),t.delete(a),l.push(a));let f=new Map;for(let a of o){let d=e(a),c=t.get(d)||null,h=n(a,c);f.has(h)||f.set(h,[]),f.get(h)?.push({item:a,key:d,existing:c})}for(let[a,d]of f)for(let c=0;c<d.length;c++){let{item:h,key:p,existing:M}=d[c],u=M;u?(u.parentElement!==a||a.children[c]!==u)&&r.push(p):(u=s(h),t.set(p,u),i.push(p));let w=a.children[c];w!==u&&a.insertBefore(u,w||null)}return{added:i,moved:r,removed:l}}var g=class extends m{#t=null;#e=null;#s=null;#n=new Map;#i=null;#u=new Map;setup(){this.#h(),this.#f(),this.#p(),this.#l(),this.#o(),this.#m()}teardown(){}#h(){this.#t=this.querySelector(":scope > chat-thread"),this.#e=this.querySelector(":scope > chat-input"),this.#s=this.querySelector(":scope > header select[data-model-select]")}#f(){let t=this.querySelector(":scope > script[data-participants]");if(t)try{let e=JSON.parse(t.textContent);this.#n=new Map(Object.entries(e))}catch{console.warn("[chat-window] Invalid participant JSON")}}#l(){if(this.#t)for(let t of this.#t.querySelectorAll("chat-message[data-from]"))this.#a(t)}#a(t){let e=t.getAttribute("data-from");if(!e)return;let s=this.#n.get(e);s?.name?t.setAttribute("data-from-label",s.name):t.hasAttribute("data-from-label")||t.setAttribute("data-from-label",e)}#p(){if(!this.#s)return;let t=this.getAttribute("model");t?this.#s.value=t:this.#s.value&&this.setAttribute("model",this.#s.value)}#m(){this.listen(this,"chat-input:send",this.#b),this.#s&&this.listen(this.#s,"change",this.#g)}#b=async t=>{t.stopPropagation();let{message:e}=t.detail;if(!e||!this.#t)return;let s=this.#c("user",e,"user");this.#t.appendChild(s),this.#r(),this.#o();let n=this.#w(),i=this.#y(n);this.#t.appendChild(i),this.#r(),this.#e&&(this.#e.disabled=!0);let r=this.getAttribute("endpoint");if(r)try{let l=await this.#E(r,e);this.#d(i,l)}catch(l){this.#d(i,"<p>Sorry, something went wrong.</p>"),i.setAttribute("data-status","error"),this.dispatchEvent(new CustomEvent("chat-window:error",{bubbles:!0,detail:{error:l.message,status:l.status??0}}))}else this.dispatchEvent(new CustomEvent("chat-window:send",{bubbles:!0,detail:{message:e,typingElement:i}}));this.#e&&(this.#e.disabled=!1,this.#e.focus()),this.#r()};#g=()=>{let t=this.#s.value;this.setAttribute("model",t),this.dispatchEvent(new CustomEvent("chat-window:model-change",{bubbles:!0,detail:{model:t}}))};#c(t,e,s){let n=document.createElement("chat-message");n.setAttribute("data-role",t),s&&(n.setAttribute("data-from",s),this.#a(n));let i=document.createElement("chat-bubble");if(e.includes("<"))i.innerHTML=b(e);else{let r=document.createElement("p");r.textContent=e,i.appendChild(r)}return n.appendChild(i),n}#y(t){let e=document.createElement("chat-message");if(e.setAttribute("data-role","agent"),e.setAttribute("data-status","typing"),t){e.setAttribute("data-from",t),this.#a(e);let r=this.#n.get(t)?.name??t;e.setAttribute("aria-label",`${r} is typing`)}else e.setAttribute("aria-label","Agent is typing");let s=this.getAttribute("model");s&&e.setAttribute("data-model",s);let n=document.createElement("chat-bubble");return e.appendChild(n),e}#d(t,e){let s=t.querySelector("chat-bubble");s&&(s.innerHTML=b(e)),t.removeAttribute("data-status"),t.removeAttribute("aria-label")}#w(){for(let[t,e]of this.#n)if(e.role==="agent")return t;return null}#o(){if(!this.#t)return;this.#t.querySelector("chat-message")!==null?(this.#i&&(this.#i.remove(),this.#i=null),this.#t.hidden=!1):(this.#t.hidden=!0,this.#i||(this.#i=document.createElement("p"),this.#i.setAttribute("data-chat-empty",""),this.#i.textContent=this.getAttribute("empty-message")||"Send a message to start.",this.#t.insertAdjacentElement("afterend",this.#i)))}#r(){this.#t&&requestAnimationFrame(()=>{this.#t.scrollTop=this.#t.scrollHeight})}scrollToBottom(){this.#r()}async#E(t,e){let s={message:e,model:this.getAttribute("model")||void 0},n=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(s)});if(!n.ok){let r=new Error(`Chat request failed: ${n.status}`);throw r.status=n.status,r}let i=await n.json();return i.html??i.message??i.content??""}get model(){return this.getAttribute("model")??""}set model(t){this.setAttribute("model",t),this.#s&&(this.#s.value=t)}get participants(){return this.#n}set participants(t){this.#n=t instanceof Map?t:new Map(Object.entries(t)),this.#l()}clearThread(){if(this.#t){for(;this.#t.firstChild;)this.#t.removeChild(this.#t.firstChild);this.#o()}}appendMessage(t,e,s){if(!this.#t)return;let n=this.#c(t,e,s);this.#t.appendChild(n),this.#r(),this.#o()}get messages(){return this.#t?[...this.#t.querySelectorAll(':scope > chat-message:not([data-status="typing"])')].map(t=>({id:t.id||t.getAttribute("data-id")||void 0,role:t.getAttribute("data-role")||"user",content:t.querySelector("chat-bubble")?.innerHTML||"",from:t.getAttribute("data-from")||void 0})):[]}set messages(t){if(!this.#t)return;let e=Array.isArray(t)?t:[];v({newItems:e,nodes:this.#u,keyOf:s=>s.id??s.role+":"+s.content,renderItem:s=>{let n=this.#c(s.role||"user",s.content||"",s.from);return s.id&&(n.id=s.id),n},containerFor:()=>this.#t}),this.#o(),this.#r(),this.dispatchEvent(new CustomEvent("chat-window:messages-changed",{detail:{messages:e,source:"property"},bubbles:!0}))}};A("chat-window",g);export{g as ChatWindow};
2
2
  //# sourceMappingURL=chat-window.js.map
@@ -1,16 +1,16 @@
1
- var S=window.matchMedia("(prefers-reduced-motion: reduce)");var v=new Map;function g(a,o,i={}){let e=i.priority??10,t={impl:o,bundle:i.bundle,contract:i.contract,priority:e},s=v.get(a);if(customElements.get(a)){if(!s||s.priority>=e){s&&s.priority===e&&s.impl!==o&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${i.bundle}".`);return}console.warn(`[VB Bundle] Tag <${a}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${i.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=e){s.priority===e&&console.warn(`[VB Bundle] Tag <${a}> already registered by "${s.bundle}". Skipping "${i.bundle}" (first wins at equal priority).`);return}v.set(a,t),customElements.define(a,o)}var f=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let o of this.#e)o();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(o,i,e,t){o.addEventListener(i,e,t),this.#e.push(()=>o.removeEventListener(i,e,t))}setup(){}teardown(){}};var b=class extends f{static observedAttributes=["colors","names","layout","show-values","show-names","size","editable"];#e=[];setup(){this.#o()}attributeChangedCallback(){this.isConnected&&this.#o()}#o(){let o=this.getAttribute("colors")||"",i=this.getAttribute("names")||"",e=this.getAttribute("layout")||"inline",t=this.getAttribute("size")||"md",s=this.hasAttribute("show-values"),r=this.hasAttribute("show-names")||i.length>0,n=this.hasAttribute("editable"),u=this.#c(o);this.#e=u.slice();let d=i?i.split(",").map(c=>c.trim()):[],h={sm:48,md:80,lg:120}[t]||80,m="display:flex;flex-wrap:wrap;gap:var(--size-xs,0.5rem)";e==="grid"?m=`display:grid;grid-template-columns:repeat(auto-fill,minmax(${h}px,1fr));gap:var(--size-xs,0.5rem)`:e==="list"&&(m="display:flex;flex-direction:column;gap:var(--size-xs,0.5rem)");let w=u.map((c,p)=>{let l=d[p]||"",E=this.#s(c),y=e==="list"?"display:flex;flex-direction:row;align-items:center;gap:0.75rem":`display:flex;flex-direction:column;align-items:center;gap:0.25rem;max-inline-size:${h}px`,x=e==="list"?36:h,$=`background:${c};color:${E};width:${x}px;height:${x}px;border:1px solid oklch(0% 0 0/0.15);border-radius:var(--radius-s,0.25rem);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;font-family:var(--font-mono,monospace);position:relative;overflow:hidden;flex-shrink:0`;if(n){let C=this.#a(c);return`<div class="swatch-wrap" role="listitem" style="${y}">
2
- <label class="color-box color-box-edit" style="${$};cursor:pointer" data-index="${p}" title="Click to edit${l?": "+l:""}" aria-label="${l||"Color "+(p+1)}: ${c}. Click to edit.">
3
- <input type="color" class="color-input" value="${C}" data-index="${p}" style="position:absolute;inset:0;opacity:0;cursor:pointer;inline-size:100%;block-size:100%" aria-label="${l||"Color "+(p+1)} picker">
4
- <span class="color-value" style="font-size:0.625rem;line-height:1.2;opacity:${s?"1":"0"};text-align:center;padding:2px 4px;word-break:break-all;transition:opacity 0.15s ease;pointer-events:none">${this.#t(c)}</span>
1
+ var U=window.matchMedia("(prefers-reduced-motion: reduce)");var C=new Map;function A(o,t,e={}){let s=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:s},n=C.get(o);if(customElements.get(o)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${n.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(n&&n.priority>=s){n.priority===s&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}C.set(o,i),customElements.define(o,t)}var f=class extends HTMLElement{#e=[];#t;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,i){t.addEventListener(e,s,i),this.#e.push(()=>t.removeEventListener(e,s,i))}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let s=this.#t.states;try{e?s.add(t):s.delete(t)}catch{let i=`--${t}`;e?s.add(i):s.delete(i)}}_adoptInternals(t){this.#t||(this.#t=t)}};var b="[data-copy], [data-copy-target], [data-paste-target]",L="Copied to clipboard",O="Pasted from clipboard",y=new WeakMap;async function v(o,t={}){if(o==null||o==="")return!1;let{button:e,announceMessage:s=L,duration:i=1500}=t;try{await navigator.clipboard.writeText(o)}catch{return!1}return k({button:e,duration:i,announceMessage:s,eventDetail:{text:o}}),!0}function k({button:o,duration:t,announceMessage:e,eventDetail:s,state:i="copied",eventName:n="copy"}){if(o){o.dataset.state=i;let r=y.get(o);r&&clearTimeout(r),y.set(o,setTimeout(()=>{delete o.dataset.state,y.delete(o)},t)),o.dispatchEvent(new CustomEvent(n,{bubbles:!0,detail:s}))}q(e,o??document.body)}async function z(o,t={}){let{button:e,announceMessage:s=O,duration:i=1500}=t,n;try{n=await navigator.clipboard.readText()}catch{return null}return o&&("value"in o&&(o instanceof HTMLInputElement||o instanceof HTMLTextAreaElement||o instanceof HTMLSelectElement)?o.value=n:o.textContent=n,o.dispatchEvent(new Event("input",{bubbles:!0}))),k({button:e,duration:i,announceMessage:s,eventDetail:{text:n},state:"pasted",eventName:"paste"}),n}function T(o=document){o.querySelectorAll(b).forEach(x)}function x(o){o.hasAttribute("data-copy-init")||(o.setAttribute("data-copy-init",""),o.addEventListener("click",()=>{if(o.dataset.pasteTarget){let e=document.querySelector(o.dataset.pasteTarget);if(!e)return;z(e,{button:o});return}let t=D(o);t&&v(t,{button:o})}))}function D(o){if(o.dataset.copy)return o.dataset.copy;if(o.dataset.copyTarget){let t=document.querySelector(o.dataset.copyTarget);if(!t)return"";let e=o.dataset.copyAttr;return e?t.getAttribute(e)??"":t.textContent??""}return""}function q(o,t){let e=document.createElement("div");e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.className="visually-hidden",e.textContent=o,t.appendChild(e),setTimeout(()=>e.remove(),1e3)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>T()):T();var I=new MutationObserver(o=>{for(let t of o)for(let e of t.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;let s=e;s.matches(b)&&x(s),s.querySelectorAll(b).forEach(i=>x(i))}});I.observe(document.documentElement,{childList:!0,subtree:!0});var g=class extends f{static observedAttributes=["colors","names","layout","show-values","show-names","size","editable"];#e=[];setup(){this.#t()}attributeChangedCallback(){this.isConnected&&this.#t()}#t(){let t=this.getAttribute("colors")||"",e=this.getAttribute("names")||"",s=this.getAttribute("layout")||"inline",i=this.getAttribute("size")||"md",n=this.hasAttribute("show-values"),r=this.hasAttribute("show-names")||e.length>0,a=this.hasAttribute("editable"),c=this.#c(t);this.#e=c.slice();let u=e?e.split(",").map(d=>d.trim()):[],h={sm:48,md:80,lg:120}[i]||80,m="display:flex;flex-wrap:wrap;gap:var(--size-xs,0.5rem)";s==="grid"?m=`display:grid;grid-template-columns:repeat(auto-fill,minmax(${h}px,1fr));gap:var(--size-xs,0.5rem)`:s==="list"&&(m="display:flex;flex-direction:column;gap:var(--size-xs,0.5rem)");let N=c.map((d,p)=>{let l=u[p]||"",S=this.#n(d),E=s==="list"?"display:flex;flex-direction:row;align-items:center;gap:0.75rem":`display:flex;flex-direction:column;align-items:center;gap:0.25rem;max-inline-size:${h}px`,$=s==="list"?36:h,w=`background:${d};color:${S};width:${$}px;height:${$}px;border:1px solid oklch(0% 0 0/0.15);border-radius:var(--radius-s,0.25rem);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0;font-family:var(--font-mono,monospace);position:relative;overflow:hidden;flex-shrink:0`;if(a){let M=this.#l(d);return`<div class="swatch-wrap" role="listitem" style="${E}">
2
+ <label class="color-box color-box-edit" style="${w};cursor:pointer" data-index="${p}" title="Click to edit${l?": "+l:""}" aria-label="${l||"Color "+(p+1)}: ${d}. Click to edit.">
3
+ <input type="color" class="color-input" value="${M}" data-index="${p}" style="position:absolute;inset:0;opacity:0;cursor:pointer;inline-size:100%;block-size:100%" aria-label="${l||"Color "+(p+1)} picker">
4
+ <span class="color-value" style="font-size:0.625rem;line-height:1.2;opacity:${n?"1":"0"};text-align:center;padding:2px 4px;word-break:break-all;transition:opacity 0.15s ease;pointer-events:none">${this.#s(d)}</span>
5
5
  </label>
6
6
  ${r&&l?`<span style="font-size:var(--font-size-xs,0.75rem);color:var(--color-text-muted,#666);text-align:center;max-inline-size:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${l}</span>`:""}
7
- </div>`}return`<div class="swatch-wrap" role="listitem" style="${y}">
7
+ </div>`}return`<div class="swatch-wrap" role="listitem" style="${E}">
8
8
  <button type="button" class="color-box" data-index="${p}"
9
- style="${$}"
9
+ style="${w}"
10
10
  title="Click to copy${l?": "+l:""}"
11
- aria-label="${l||"Color "+(p+1)}: ${c}">
12
- <span class="color-value" style="font-size:0.625rem;line-height:1.2;opacity:${s?"1":"0"};text-align:center;padding:2px 4px;word-break:break-all;transition:opacity 0.15s ease">${this.#t(c)}</span>
11
+ aria-label="${l||"Color "+(p+1)}: ${d}">
12
+ <span class="color-value" style="font-size:0.625rem;line-height:1.2;opacity:${n?"1":"0"};text-align:center;padding:2px 4px;word-break:break-all;transition:opacity 0.15s ease">${this.#s(d)}</span>
13
13
  </button>
14
14
  ${r&&l?`<span style="font-size:var(--font-size-xs,0.75rem);color:var(--color-text-muted,#666);text-align:center;max-inline-size:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap">${l}</span>`:""}
15
- </div>`}).join("");this.innerHTML=`<div class="palette ${e}" role="list" aria-label="Color palette" style="${m}">${w}</div>`,n?this.#n(d):(this.#l(u,d),this.#r(u,d,s))}#r(o,i,e){this.querySelectorAll(".color-box").forEach(t=>{e||(t.addEventListener("pointerenter",()=>{let s=t.querySelector(".color-value");s&&(s.style.opacity="1")}),t.addEventListener("pointerleave",()=>{let s=t.querySelector(".color-value");s&&(s.style.opacity="0")})),t.addEventListener("click",()=>{let s=Number(t.dataset.index),r=o[s],n=i[s]||"";navigator.clipboard?.writeText(r),this.dispatchEvent(new CustomEvent("color-palette:select",{bubbles:!0,detail:{color:r,name:n,index:s}})),t.style.outline="3px solid currentColor",t.style.outlineOffset="2px",setTimeout(()=>{t.style.outline="",t.style.outlineOffset=""},600)})})}#n(o){this.querySelectorAll(".color-input").forEach(i=>{i.addEventListener("input",()=>{let e=Number(i.dataset.index),t=i.value;this.#e[e]=t;let s=i.parentElement;if(s){s.style.background=t,s.style.color=this.#s(t);let r=s.querySelector(".color-value");r&&(r.textContent=this.#t(t)),s.title=`Click to edit${o[e]?": "+o[e]:""} (${t})`,s.setAttribute("aria-label",`${o[e]||"Color "+(e+1)}: ${t}. Click to edit.`)}this.setAttribute("colors",this.#e.join(",")),this.dispatchEvent(new CustomEvent("color-palette:change",{bubbles:!0,detail:{color:t,name:o[e]||"",index:e,colors:this.#e.slice()}}))})})}get colors(){return this.#e.slice()}#l(o,i){this.querySelectorAll(".color-box").forEach(e=>{let t=Number(e.dataset.index),s=o[t];if(!s||!s.includes("var("))return;let r=getComputedStyle(e).backgroundColor,n=this.#i(r)||r;o[t]=n,this.#e[t]=n;let u=e.querySelector(".color-value");u&&(u.textContent=n),e.style.color=this.#s(n);let d=i[t]||"";e.title=`Click to copy${d?": "+d:""} (${n})`,e.setAttribute("aria-label",`${d||"Color "+(t+1)}: ${n}`)})}#i(o){let i=o.match(/rgba?\(\s*([\d.]+),?\s*([\d.]+),?\s*([\d.]+)/);if(!i)return null;let[,e,t,s]=i,r=n=>Math.round(Number(n)).toString(16).padStart(2,"0");return`#${r(e)}${r(t)}${r(s)}`}#a(o){if(/^#[0-9a-f]{6}$/i.test(o))return o.toLowerCase();if(/^#[0-9a-f]{3}$/i.test(o))return("#"+o.slice(1).split("").map(t=>t+t).join("")).toLowerCase();if(typeof document>"u")return"#000000";let i=document.createElement("span");i.style.color=o,i.style.display="none",document.body.appendChild(i);let e=getComputedStyle(i).color;return i.remove(),this.#i(e)||"#000000"}#t(o){if(o.startsWith("#"))return o;let i=o.match(/oklch\(\s*([\d.]+)%?\s+([\d.]+)\s+([\d.]+)/);return i?`${i[1]}% .${i[2].replace("0.","")}`:o.length>12?o.slice(0,12)+"\u2026":o}#c(o){if(!o)return[];let i=[],e=0,t="";for(let s of o)s==="("?e++:s===")"&&e--,s===","&&e===0?(i.push(t.trim()),t=""):t+=s;return t.trim()&&i.push(t.trim()),i}#s(o){let i=o.match(/oklch\(\s*([\d.]+)%?\s/);if(i){let e=parseFloat(i[1]);return(e>1?e/100:e)>.6?"#000":"#fff"}if(o.startsWith("#")){let e=o.replace("#",""),t=parseInt(e.substring(0,2),16)/255,s=parseInt(e.substring(2,4),16)/255,r=parseInt(e.substring(4,6),16)/255;return .2126*t+.7152*s+.0722*r>.4?"#000":"#fff"}return"#000"}};g("color-palette",b);export{b as ColorPalette};
15
+ </div>`}).join("");this.innerHTML=`<div class="palette ${s}" role="list" aria-label="Color palette" style="${m}">${N}</div>`,a?this.#r(u):(this.#a(c,u),this.#i(c,u,n))}#i(t,e,s){this.querySelectorAll(".color-box").forEach(i=>{let n=i;s||(n.addEventListener("pointerenter",()=>{let r=n.querySelector(".color-value");r&&(r.style.opacity="1")}),n.addEventListener("pointerleave",()=>{let r=n.querySelector(".color-value");r&&(r.style.opacity="0")})),n.addEventListener("click",()=>{let r=Number(n.dataset.index),a=t[r],c=e[r]||"";v(a,{button:n,announceMessage:"Color copied"}),this.dispatchEvent(new CustomEvent("color-palette:select",{bubbles:!0,detail:{color:a,name:c,index:r}})),n.style.outline="3px solid currentColor",n.style.outlineOffset="2px",setTimeout(()=>{n.style.outline="",n.style.outlineOffset=""},600)})})}#r(t){this.querySelectorAll(".color-input").forEach(e=>{e.addEventListener("input",()=>{let s=Number(e.dataset.index),i=e.value;this.#e[s]=i;let n=e.parentElement;if(n){n.style.background=i,n.style.color=this.#n(i);let r=n.querySelector(".color-value");r&&(r.textContent=this.#s(i)),n.title=`Click to edit${t[s]?": "+t[s]:""} (${i})`,n.setAttribute("aria-label",`${t[s]||"Color "+(s+1)}: ${i}. Click to edit.`)}this.setAttribute("colors",this.#e.join(",")),this.dispatchEvent(new CustomEvent("color-palette:change",{bubbles:!0,detail:{color:i,name:t[s]||"",index:s,colors:this.#e.slice()}}))})})}get colors(){return this.#e.slice()}#a(t,e){this.querySelectorAll(".color-box").forEach(s=>{let i=Number(s.dataset.index),n=t[i];if(!n||!n.includes("var("))return;let r=getComputedStyle(s).backgroundColor,a=this.#o(r)||r;t[i]=a,this.#e[i]=a;let c=s.querySelector(".color-value");c&&(c.textContent=a),s.style.color=this.#n(a);let u=e[i]||"";s.title=`Click to copy${u?": "+u:""} (${a})`,s.setAttribute("aria-label",`${u||"Color "+(i+1)}: ${a}`)})}#o(t){let e=t.match(/rgba?\(\s*([\d.]+),?\s*([\d.]+),?\s*([\d.]+)/);if(!e)return null;let[,s,i,n]=e,r=a=>Math.round(Number(a)).toString(16).padStart(2,"0");return`#${r(s)}${r(i)}${r(n)}`}#l(t){if(/^#[0-9a-f]{6}$/i.test(t))return t.toLowerCase();if(/^#[0-9a-f]{3}$/i.test(t))return("#"+t.slice(1).split("").map(i=>i+i).join("")).toLowerCase();if(typeof document>"u")return"#000000";let e=document.createElement("span");e.style.color=t,e.style.display="none",document.body.appendChild(e);let s=getComputedStyle(e).color;return e.remove(),this.#o(s)||"#000000"}#s(t){if(t.startsWith("#"))return t;let e=t.match(/oklch\(\s*([\d.]+)%?\s+([\d.]+)\s+([\d.]+)/);return e?`${e[1]}% .${e[2].replace("0.","")}`:t.length>12?t.slice(0,12)+"\u2026":t}#c(t){if(!t)return[];let e=[],s=0,i="";for(let n of t)n==="("?s++:n===")"&&s--,n===","&&s===0?(e.push(i.trim()),i=""):i+=n;return i.trim()&&e.push(i.trim()),e}#n(t){let e=t.match(/oklch\(\s*([\d.]+)%?\s/);if(e){let s=parseFloat(e[1]);return(s>1?s/100:s)>.6?"#000":"#fff"}if(t.startsWith("#")){let s=t.replace("#",""),i=parseInt(s.substring(0,2),16)/255,n=parseInt(s.substring(2,4),16)/255,r=parseInt(s.substring(4,6),16)/255;return .2126*i+.7152*n+.0722*r>.4?"#000":"#fff"}return"#000"}};A("color-palette",g);export{g as ColorPalette};
16
16
  //# sourceMappingURL=color-palette.js.map
@@ -1,2 +1,2 @@
1
- var E=window.matchMedia("(prefers-reduced-motion: reduce)");var f=new Map;function v(n,t,e={}){let i=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=f.get(n);if(customElements.get(n)){if(!r||r.priority>=i){r&&r.priority===i&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=i){r.priority===i&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}f.set(n,s),customElements.define(n,t)}var p=class extends HTMLElement{#d=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let t of this.#d)t();this.#d=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,s){t.addEventListener(e,i,s),this.#d.push(()=>t.removeEventListener(e,i,s))}setup(){}teardown(){}};var y="popover"in HTMLElement.prototype;function d(n,t,e){t/=100,e/=100;let i=o=>(o+n/30)%12,s=t*Math.min(e,1-e),r=o=>e-s*Math.max(-1,Math.min(i(o)-3,9-i(o),1));return{r:Math.round(r(0)*255),g:Math.round(r(8)*255),b:Math.round(r(4)*255)}}function m(n,t,e){n/=255,t/=255,e/=255;let i=Math.max(n,t,e),s=Math.min(n,t,e),r=(i+s)/2,o=0,a=0;if(i!==s){let u=i-s;switch(a=r>.5?u/(2-i-s):u/(i+s),i){case n:o=((t-e)/u+(t<e?6:0))/6;break;case t:o=((e-n)/u+2)/6;break;case e:o=((n-t)/u+4)/6;break}}return{h:Math.round(o*360),s:Math.round(a*100),l:Math.round(r*100)}}function w(n){n=n.replace(/^#/,""),n.length===3&&(n=n[0]+n[0]+n[1]+n[1]+n[2]+n[2]);let t=parseInt(n,16);return{r:t>>16&255,g:t>>8&255,b:t&255}}function g(n,t,e){return"#"+[n,t,e].map(i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0")).join("")}function l(n){let{r:t,g:e,b:i}=w(n);return m(t,e,i)}function c(n,t,e){let{r:i,g:s,b:r}=d(n,t,e);return g(i,s,r)}function h(n,t,e){return Math.max(t,Math.min(e,n))}var b=class extends p{static formAssociated=!0;#d;#h;#o;#E;#A;#r;#n;#m;#s;#x;#f;#v;#y;#w;#c;#u;#a;#p=!1;#g=!1;#t=0;#e=100;#i=50;#N;constructor(){super(),this.#d=this.attachInternals()}setup(){if(this.#h=this.querySelector(':scope > input[type="color"]'),!this.#h)return!1;let t=this.#h.value||"#000000";this.#N=t;let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#h.setAttribute("tabindex","-1"),this.#h.setAttribute("aria-hidden","true"),this.#h.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.#P(),this.#D(),this.#C(),this.#k(),this.#g=y,this.#g&&this.#r.setAttribute("popover","manual"),this.listen(document,"click",this.#G),(this.#h.disabled||this.hasAttribute("disabled"))&&this.setAttribute("data-disabled","")}teardown(){window.removeEventListener("scroll",this.#b,{capture:!0}),window.removeEventListener("resize",this.#b)}#P(){this.#o=document.createElement("button"),this.#o.type="button",this.#o.className="color-trigger",this.#o.setAttribute("aria-haspopup","dialog"),this.#o.setAttribute("aria-expanded","false"),this.#E=document.createElement("span"),this.#E.className="color-swatch",this.#A=document.createElement("span"),this.#A.className="color-hex",this.#o.appendChild(this.#E),this.#o.appendChild(this.#A),this.appendChild(this.#o),this.listen(this.#o,"click",()=>{this.#p?this.#L():this.#z()})}#D(){this.#r=document.createElement("div"),this.#r.className="color-panel",this.#r.setAttribute("role","dialog"),this.#r.setAttribute("aria-label","Color picker"),this.#n=document.createElement("div"),this.#n.className="color-area",this.#n.setAttribute("role","slider"),this.#n.setAttribute("aria-label","Saturation and lightness"),this.#n.setAttribute("tabindex","0"),this.#m=document.createElement("div"),this.#m.className="color-area-thumb",this.#n.appendChild(this.#m),this.#r.appendChild(this.#n);let t=document.createElement("div");t.className="color-hue-wrap",this.#s=document.createElement("div"),this.#s.className="color-hue",this.#s.setAttribute("role","slider"),this.#s.setAttribute("aria-label","Hue"),this.#s.setAttribute("aria-valuemin","0"),this.#s.setAttribute("aria-valuemax","360"),this.#s.setAttribute("tabindex","0"),this.#x=document.createElement("div"),this.#x.className="color-hue-thumb",this.#s.appendChild(this.#x),t.appendChild(this.#s),this.#r.appendChild(t);let e=document.createElement("div");e.className="color-inputs",this.#f=this.#B("Hex","hex",7),this.#v=this.#M("R","r",0,255),this.#y=this.#M("G","g",0,255),this.#w=this.#M("B","b",0,255),e.appendChild(this.#f.wrapper),e.appendChild(this.#v.wrapper),e.appendChild(this.#y.wrapper),e.appendChild(this.#w.wrapper),this.#r.appendChild(e);let i=this.querySelector(":scope > datalist");if(i){this.#c=document.createElement("div"),this.#c.className="color-swatches",this.#c.setAttribute("role","listbox"),this.#c.setAttribute("aria-label","Preset colors");for(let r of i.querySelectorAll("option[value]")){let o=document.createElement("button");o.type="button",o.setAttribute("role","option"),o.style.background=r.value,o.setAttribute("aria-label",r.textContent||r.value),o.setAttribute("data-color",r.value),this.#c.appendChild(o)}this.#r.appendChild(this.#c),this.listen(this.#c,"click",this.#V)}let s=document.createElement("div");s.className="color-actions","EyeDropper"in window&&(this.#u=document.createElement("button"),this.#u.type="button",this.#u.className="color-eyedropper",this.#u.setAttribute("aria-label","Pick color from screen"),this.#u.textContent="\u{1F4A7}",s.appendChild(this.#u),this.listen(this.#u,"click",this.#j)),this.#a=document.createElement("button"),this.#a.type="button",this.#a.className="color-copy",this.#a.setAttribute("aria-label","Copy hex value"),this.#a.textContent="Copy",s.appendChild(this.#a),this.listen(this.#a,"click",this.#K),this.#r.appendChild(s),this.appendChild(this.#r),this.listen(this.#n,"pointerdown",this.#F),this.listen(this.#n,"keydown",this.#R),this.listen(this.#s,"pointerdown",this.#I),this.listen(this.#s,"keydown",this.#q),this.listen(this.#f.input,"change",this.#O),this.listen(this.#v.input,"change",this.#S),this.listen(this.#y.input,"change",this.#S),this.listen(this.#w.input,"change",this.#S)}#B(t,e,i){let s=document.createElement("label");s.className="color-input-label";let r=document.createElement("span");r.textContent=t;let o=document.createElement("input");return o.type="text",o.setAttribute("data-channel",e),o.setAttribute("maxlength",String(i)),o.setAttribute("spellcheck","false"),o.setAttribute("autocomplete","off"),s.appendChild(r),s.appendChild(o),{wrapper:s,input:o}}#M(t,e,i,s){let r=document.createElement("label");r.className="color-input-label";let o=document.createElement("span");o.textContent=t;let a=document.createElement("input");return a.type="number",a.setAttribute("data-channel",e),a.min=String(i),a.max=String(s),r.appendChild(o),r.appendChild(a),{wrapper:r,input:a}}#F=t=>{t.preventDefault(),this.#n.setPointerCapture(t.pointerId),this.#T(t);let e=s=>this.#T(s),i=s=>{this.#n.releasePointerCapture(s.pointerId),this.#n.removeEventListener("pointermove",e),this.#n.removeEventListener("pointerup",i)};this.#n.addEventListener("pointermove",e),this.#n.addEventListener("pointerup",i)};#T(t){let e=this.#n.getBoundingClientRect(),i=h((t.clientX-e.left)/e.width,0,1),s=h((t.clientY-e.top)/e.height,0,1);this.#e=Math.round(i*100),this.#i=Math.round((1-s)*100),this.#l()}#R=t=>{let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":t.preventDefault(),this.#e=h(this.#e+e,0,100);break;case"ArrowLeft":t.preventDefault(),this.#e=h(this.#e-e,0,100);break;case"ArrowUp":t.preventDefault(),this.#i=h(this.#i+e,0,100);break;case"ArrowDown":t.preventDefault(),this.#i=h(this.#i-e,0,100);break;default:return}this.#l()};#I=t=>{t.preventDefault(),this.#s.setPointerCapture(t.pointerId),this.#$(t);let e=s=>this.#$(s),i=s=>{this.#s.releasePointerCapture(s.pointerId),this.#s.removeEventListener("pointermove",e),this.#s.removeEventListener("pointerup",i)};this.#s.addEventListener("pointermove",e),this.#s.addEventListener("pointerup",i)};#$(t){let e=this.#s.getBoundingClientRect(),i=h((t.clientX-e.left)/e.width,0,1);this.#t=Math.round(i*360),this.#l()}#q=t=>{let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#t=(this.#t+e)%361;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#t=(this.#t-e+361)%361;break;default:return}this.#l()};#O=()=>{let t=this.#f.input.value.trim();if(t.startsWith("#")||(t="#"+t),/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t)){let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#l()}};#S=()=>{let t=h(Number(this.#v.input.value)||0,0,255),e=h(Number(this.#y.input.value)||0,0,255),i=h(Number(this.#w.input.value)||0,0,255),s=m(t,e,i);this.#t=s.h,this.#e=s.s,this.#i=s.l,this.#l()};#V=t=>{let e=t.target.closest("button[data-color]");if(!e)return;let i=e.getAttribute("data-color"),s=l(i);this.#t=s.h,this.#e=s.s,this.#i=s.l,this.#l()};#j=async()=>{try{let e=await new EyeDropper().open(),i=l(e.sRGBHex);this.#t=i.h,this.#e=i.s,this.#i=i.l,this.#l()}catch{}};#K=async()=>{let t=c(this.#t,this.#e,this.#i);try{await navigator.clipboard.writeText(t),this.#a.textContent="Copied!",setTimeout(()=>{this.#a.textContent="Copy"},1500)}catch{}};#l(){this.#C(),this.#k();let t=c(this.#t,this.#e,this.#i),e=d(this.#t,this.#e,this.#i);this.dispatchEvent(new CustomEvent("color-picker:change",{bubbles:!0,detail:{hex:t,rgb:{r:e.r,g:e.g,b:e.b},hsl:{h:this.#t,s:this.#e,l:this.#i}}}))}#C(){let t=c(this.#t,this.#e,this.#i),e=d(this.#t,this.#e,this.#i),i=c(this.#t,100,50);this.#E.style.background=t,this.#A.textContent=t,this.#n.style.setProperty("--area-hue",i),this.#m.style.insetInlineStart=`${this.#e}%`,this.#m.style.insetBlockStart=`${100-this.#i}%`,this.#m.style.background=t,this.#n.setAttribute("aria-valuetext",`Saturation ${this.#e}%, Lightness ${this.#i}%`),this.#x.style.insetInlineStart=`${this.#t/360*100}%`,this.#s.setAttribute("aria-valuenow",String(this.#t)),this.#s.setAttribute("aria-valuetext",`Hue ${this.#t}\xB0`),this.#f.input.value=t,this.#v.input.value=String(e.r),this.#y.input.value=String(e.g),this.#w.input.value=String(e.b)}#z(){if(!this.#p){if(this.#p=!0,this.setAttribute("open",""),this.#o.setAttribute("aria-expanded","true"),this.#g){this.#H();try{this.#r.showPopover()}catch{}window.addEventListener("scroll",this.#b,{capture:!0,passive:!0}),window.addEventListener("resize",this.#b,{passive:!0})}requestAnimationFrame(()=>this.#n.focus()),this.dispatchEvent(new CustomEvent("color-picker:open",{bubbles:!0}))}}#L(){if(this.#p){if(this.#p=!1,this.removeAttribute("open"),this.#o.setAttribute("aria-expanded","false"),this.#g){try{this.#r.hidePopover()}catch{}window.removeEventListener("scroll",this.#b,{capture:!0}),window.removeEventListener("resize",this.#b)}this.dispatchEvent(new CustomEvent("color-picker:close",{bubbles:!0}))}}#H(){if(!this.#g)return;let t=this.#o.getBoundingClientRect();this.#r.style.setProperty("--panel-top",`${t.bottom+4}px`),this.#r.style.setProperty("--panel-left",`${t.left}px`)}#b=()=>{this.#p&&this.#H()};#G=t=>{this.#p&&!this.contains(t.target)&&this.#L()};#k(){let t=c(this.#t,this.#e,this.#i);this.#d.setFormValue(t),this.#h.value=t,this.#h.dispatchEvent(new Event("input",{bubbles:!0}))}formResetCallback(){let t=l(this.#N);this.#t=t.h,this.#e=t.s,this.#i=t.l,this.#C(),this.#k()}formStateRestoreCallback(t){if(!t)return;let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#C(),this.#k()}get value(){return c(this.#t,this.#e,this.#i)}set value(t){if(!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t))return;let e=l(t);this.#t=e.h,this.#e=e.s,this.#i=e.l,this.#l()}};v("color-picker",b);export{b as ColorPicker};
1
+ var tt=window.matchMedia("(prefers-reduced-motion: reduce)");var $=new Map;function D(i,t,e={}){let s=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:s},o=$.get(i);if(customElements.get(i)){if(!o||o.priority>=s){o&&o.priority===s&&o.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${o.bundle}" (priority ${o.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${o.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(o&&o.priority>=s){o.priority===s&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${o.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}$.set(i,n),customElements.define(i,t)}var y=class extends HTMLElement{#d=[];#r;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#d)t();this.#d=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,n){t.addEventListener(e,s,n),this.#d.push(()=>t.removeEventListener(e,s,n))}setup(){}teardown(){}setState(t,e){this.#r||(this.#r=this.attachInternals());let s=this.#r.states;try{e?s.add(t):s.delete(t)}catch{let n=`--${t}`;e?s.add(n):s.delete(n)}}_adoptInternals(t){this.#r||(this.#r=t)}};var F="popover"in HTMLElement.prototype;var A="[data-copy], [data-copy-target], [data-paste-target]",_="Copied to clipboard",B="Pasted from clipboard",C=new WeakMap;async function T(i,t={}){if(i==null||i==="")return!1;let{button:e,announceMessage:s=_,duration:n=1500}=t;try{await navigator.clipboard.writeText(i)}catch{return!1}return P({button:e,duration:n,announceMessage:s,eventDetail:{text:i}}),!0}function P({button:i,duration:t,announceMessage:e,eventDetail:s,state:n="copied",eventName:o="copy"}){if(i){i.dataset.state=n;let a=C.get(i);a&&clearTimeout(a),C.set(i,setTimeout(()=>{delete i.dataset.state,C.delete(i)},t)),i.dispatchEvent(new CustomEvent(o,{bubbles:!0,detail:s}))}V(e,i??document.body)}async function U(i,t={}){let{button:e,announceMessage:s=B,duration:n=1500}=t,o;try{o=await navigator.clipboard.readText()}catch{return null}return i&&("value"in i&&(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement)?i.value=o:i.textContent=o,i.dispatchEvent(new Event("input",{bubbles:!0}))),P({button:e,duration:n,announceMessage:s,eventDetail:{text:o},state:"pasted",eventName:"paste"}),o}function O(i=document){i.querySelectorAll(A).forEach(k)}function k(i){i.hasAttribute("data-copy-init")||(i.setAttribute("data-copy-init",""),i.addEventListener("click",()=>{if(i.dataset.pasteTarget){let e=document.querySelector(i.dataset.pasteTarget);if(!e)return;U(e,{button:i});return}let t=q(i);t&&T(t,{button:i})}))}function q(i){if(i.dataset.copy)return i.dataset.copy;if(i.dataset.copyTarget){let t=document.querySelector(i.dataset.copyTarget);if(!t)return"";let e=i.dataset.copyAttr;return e?t.getAttribute(e)??"":t.textContent??""}return""}function V(i,t){let e=document.createElement("div");e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.className="visually-hidden",e.textContent=i,t.appendChild(e),setTimeout(()=>e.remove(),1e3)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>O()):O();var j=new MutationObserver(i=>{for(let t of i)for(let e of t.addedNodes){if(e.nodeType!==Node.ELEMENT_NODE)continue;let s=e;s.matches(A)&&k(s),s.querySelectorAll(A).forEach(n=>k(n))}});j.observe(document.documentElement,{childList:!0,subtree:!0});function b(i,t,e){t/=100,e/=100;let s=a=>(a+i/30)%12,n=t*Math.min(e,1-e),o=a=>e-n*Math.max(-1,Math.min(s(a)-3,9-s(a),1));return{r:Math.round(o(0)*255),g:Math.round(o(8)*255),b:Math.round(o(4)*255)}}function E(i,t,e){i/=255,t/=255,e/=255;let s=Math.max(i,t,e),n=Math.min(i,t,e),o=(s+n)/2,a=0,h=0;if(s!==n){let r=s-n;switch(h=o>.5?r/(2-s-n):r/(s+n),s){case i:a=((t-e)/r+(t<e?6:0))/6;break;case t:a=((e-i)/r+2)/6;break;case e:a=((i-t)/r+4)/6;break}}return{h:Math.round(a*360),s:Math.round(h*100),l:Math.round(o*100)}}function G(i){i=i.replace(/^#/,""),i.length===3&&(i=i[0]+i[0]+i[1]+i[1]+i[2]+i[2]);let t=parseInt(i,16);return{r:t>>16&255,g:t>>8&255,b:t&255}}function K(i,t,e){return"#"+[i,t,e].map(s=>Math.max(0,Math.min(255,Math.round(s))).toString(16).padStart(2,"0")).join("")}function u(i){let{r:t,g:e,b:s}=G(i);return E(t,e,s)}function d(i,t,e){let{r:s,g:n,b:o}=b(i,t,e);return K(s,n,o)}function c(i,t,e){return Math.max(t,Math.min(e,i))}function M(i){return i/=255,i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function N(i){let t=i<=.0031308?i*12.92:1.055*Math.pow(i,.4166666666666667)-.055;return Math.round(c(t,0,1)*255)}function z(i,t,e){let s=M(i),n=M(t),o=M(e),a=.4122214708*s+.5363325363*n+.0514459929*o,h=.2119034982*s+.6806995451*n+.1073969566*o,r=.0883024619*s+.2817188376*n+.6299787005*o,l=Math.cbrt(a),p=Math.cbrt(h),m=Math.cbrt(r),w=.2104542553*l+.793617785*p-.0040720468*m,v=1.9779984951*l-2.428592205*p+.4505937099*m,g=.0259040371*l+.7827717662*p-.808675766*m,H=Math.sqrt(v*v+g*g),x=Math.atan2(g,v)*180/Math.PI;return x<0&&(x+=360),H<1e-4&&(x=0),{L:w,C:H,H:x}}function W(i,t,e){let s=e*Math.PI/180,n=t*Math.cos(s),o=t*Math.sin(s),a=i+.3963377774*n+.2158037573*o,h=i-.1055613458*n-.0638541728*o,r=i-.0894841775*n-1.291485548*o,l=a**3,p=h**3,m=r**3,w=4.0767416621*l-3.3077115913*p+.2309699292*m,v=-1.2684380046*l+2.6097574011*p-.3413193965*m,g=-.0041960863*l-.7034186147*p+1.707614701*m;return{r:N(w),g:N(v),b:N(g)}}function L(i,t,e){let s=b(i,t,e);return z(s.r,s.g,s.b)}function I(i,t,e){let{r:s,g:n,b:o}=W(i,t,e);return E(s,n,o)}function X(i,t,e){return d(i,t,e)}function Y(i,t,e){let{r:s,g:n,b:o}=b(i,t,e);return`rgb(${s} ${n} ${o})`}function J(i,t,e){return`hsl(${i}deg ${t}% ${e}%)`}function Q(i,t,e){let{L:s,C:n,H:o}=L(i,t,e);return`oklch(${(s*100).toFixed(1)}% ${n.toFixed(3)} ${o.toFixed(1)}deg)`}function R(i,t,e,s){switch(i){case"rgb":return Y(t,e,s);case"hsl":return J(t,e,s);case"oklch":return Q(t,e,s);default:return X(t,e,s)}}var f=["hex","rgb","hsl","oklch"],Z="hex",S=class extends y{static formAssociated=!0;#d;#r;#a;#w;#C;#o;#n;#v;#i;#A;#p;#u={};#g=Z;#m;#b;#l;#f=!1;#y=!1;#t=0;#e=100;#s=50;#M;constructor(){super(),this.#d=this.attachInternals(),this._adoptInternals(this.#d)}setup(){if(this.#r=this.querySelector(':scope > input[type="color"]'),!this.#r)return!1;let t=this.getAttribute("format");t&&f.includes(t)&&(this.#g=t);let e=this.#r.value||"#000000";this.#M=e;let s=u(e);return this.#t=s.h,this.#e=s.s,this.#s=s.l,this.#r.setAttribute("tabindex","-1"),this.#r.setAttribute("aria-hidden","true"),this.#r.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.#D(),this.#F(),this.#E(),this.#T(),this.#y=F,this.#y&&this.#o.setAttribute("popover","manual"),this.listen(document,"click",this.#W),(this.#r.disabled||this.hasAttribute("disabled"))&&this.setAttribute("data-disabled",""),!0}teardown(){window.removeEventListener("scroll",this.#x,{capture:!0}),window.removeEventListener("resize",this.#x)}#D(){this.#a=document.createElement("button"),this.#a.type="button",this.#a.className="color-trigger",this.#a.setAttribute("aria-haspopup","dialog"),this.#a.setAttribute("aria-expanded","false"),this.#w=document.createElement("span"),this.#w.className="color-swatch",this.#C=document.createElement("span"),this.#C.className="color-hex",this.#a.appendChild(this.#w),this.#a.appendChild(this.#C),this.appendChild(this.#a),this.listen(this.#a,"click",()=>{this.#f?this.#H():this.#z()})}#F(){this.#o=document.createElement("div"),this.#o.className="color-panel",this.#o.setAttribute("role","dialog"),this.#o.setAttribute("aria-label","Color picker"),this.#n=document.createElement("div"),this.#n.className="color-area",this.#n.setAttribute("role","slider"),this.#n.setAttribute("aria-label","Saturation and lightness"),this.#n.setAttribute("tabindex","0"),this.#v=document.createElement("div"),this.#v.className="color-area-thumb",this.#n.appendChild(this.#v),this.#o.appendChild(this.#n);let t=document.createElement("div");t.className="color-hue-wrap",this.#i=document.createElement("div"),this.#i.className="color-hue",this.#i.setAttribute("role","slider"),this.#i.setAttribute("aria-label","Hue"),this.#i.setAttribute("aria-valuemin","0"),this.#i.setAttribute("aria-valuemax","360"),this.#i.setAttribute("tabindex","0"),this.#A=document.createElement("div"),this.#A.className="color-hue-thumb",this.#i.appendChild(this.#A),t.appendChild(this.#i),this.#o.appendChild(t);let e=document.createElement("div");e.className="color-format-row";let s=document.createElement("label");s.className="color-format-label";let n=document.createElement("span");n.textContent="Format",this.#p=document.createElement("select"),this.#p.className="color-format-select";for(let h of f){let r=document.createElement("option");r.value=h,r.textContent=h.toUpperCase(),this.#p.appendChild(r)}this.#p.value=this.#g,s.appendChild(n),s.appendChild(this.#p),e.appendChild(s),this.#o.appendChild(e),this.listen(this.#p,"change",this.#O),this.#u.hex=this.#k("hex",[{label:"Hex",channel:"hex",kind:"text",maxLength:7}]),this.#u.rgb=this.#k("rgb",[{label:"R",channel:"r",kind:"number",min:0,max:255,step:1},{label:"G",channel:"g",kind:"number",min:0,max:255,step:1},{label:"B",channel:"b",kind:"number",min:0,max:255,step:1}]),this.#u.hsl=this.#k("hsl",[{label:"H",channel:"h",kind:"number",min:0,max:360,step:1},{label:"S",channel:"s",kind:"number",min:0,max:100,step:1},{label:"L",channel:"l",kind:"number",min:0,max:100,step:1}]),this.#u.oklch=this.#k("oklch",[{label:"L%",channel:"oL",kind:"number",min:0,max:100,step:.1},{label:"C",channel:"oC",kind:"number",min:0,max:.4,step:.001},{label:"H\xB0",channel:"oH",kind:"number",min:0,max:360,step:.1}]);for(let h of f)this.#o.appendChild(this.#u[h].wrapper);this.#N();let o=this.querySelector(":scope > datalist");if(o){this.#m=document.createElement("div"),this.#m.className="color-swatches",this.#m.setAttribute("role","listbox"),this.#m.setAttribute("aria-label","Preset colors");for(let h of o.querySelectorAll("option[value]")){let r=document.createElement("button");r.type="button",r.setAttribute("role","option"),r.style.background=h.value,r.setAttribute("aria-label",h.textContent||h.value),r.setAttribute("data-color",h.value),this.#m.appendChild(r)}this.#o.appendChild(this.#m),this.listen(this.#m,"click",this.#j)}let a=document.createElement("div");a.className="color-actions","EyeDropper"in window&&(this.#b=document.createElement("button"),this.#b.type="button",this.#b.className="color-eyedropper",this.#b.setAttribute("aria-label","Pick color from screen"),this.#b.textContent="\u{1F4A7}",a.appendChild(this.#b),this.listen(this.#b,"click",this.#G)),this.#l=document.createElement("button"),this.#l.type="button",this.#l.className="color-copy",this.#l.setAttribute("aria-label","Copy hex value"),this.#l.textContent="Copy",a.appendChild(this.#l),this.listen(this.#l,"click",this.#K),this.#o.appendChild(a),this.appendChild(this.#o),this.listen(this.#n,"pointerdown",this.#P),this.listen(this.#n,"keydown",this.#I),this.listen(this.#i,"pointerdown",this.#R),this.listen(this.#i,"keydown",this.#_);for(let h of f){let r=h==="hex"?this.#B:h==="rgb"?this.#U:h==="hsl"?this.#q:this.#V;for(let{el:l}of this.#u[h].inputs)this.listen(l,"change",r)}}#k(t,e){let s=document.createElement("div");s.className=`color-inputs color-inputs-${t}`,s.setAttribute("data-format",t);let n=[];for(let o of e){let a=document.createElement("label");a.className="color-input-label";let h=document.createElement("span");h.textContent=o.label;let r=document.createElement("input");r.type=o.kind,r.setAttribute("data-channel",o.channel),r.setAttribute("autocomplete","off"),r.setAttribute("spellcheck","false"),o.kind==="text"&&o.maxLength&&r.setAttribute("maxlength",String(o.maxLength)),o.kind==="number"&&(r.min=String(o.min),r.max=String(o.max),o.step!=null&&(r.step=String(o.step))),a.appendChild(h),a.appendChild(r),s.appendChild(a),n.push({el:r,channel:o.channel})}return{wrapper:s,inputs:n}}#N(){for(let t of f)this.#u[t].wrapper.hidden=t!==this.#g;this.#l&&this.#l.setAttribute("aria-label",`Copy ${this.#g.toUpperCase()} value`)}#O=()=>{let t=this.#p.value;f.includes(t)&&(this.#g=t,this.#N(),this.#E())};#P=t=>{t.preventDefault(),this.#n.setPointerCapture(t.pointerId),this.#L(t);let e=n=>this.#L(n),s=n=>{this.#n.releasePointerCapture(n.pointerId),this.#n.removeEventListener("pointermove",e),this.#n.removeEventListener("pointerup",s)};this.#n.addEventListener("pointermove",e),this.#n.addEventListener("pointerup",s)};#L(t){let e=this.#n.getBoundingClientRect(),s=c((t.clientX-e.left)/e.width,0,1),n=c((t.clientY-e.top)/e.height,0,1);this.#e=Math.round(s*100),this.#s=Math.round((1-n)*100),this.#c()}#I=t=>{let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":t.preventDefault(),this.#e=c(this.#e+e,0,100);break;case"ArrowLeft":t.preventDefault(),this.#e=c(this.#e-e,0,100);break;case"ArrowUp":t.preventDefault(),this.#s=c(this.#s+e,0,100);break;case"ArrowDown":t.preventDefault(),this.#s=c(this.#s-e,0,100);break;default:return}this.#c()};#R=t=>{t.preventDefault(),this.#i.setPointerCapture(t.pointerId),this.#S(t);let e=n=>this.#S(n),s=n=>{this.#i.releasePointerCapture(n.pointerId),this.#i.removeEventListener("pointermove",e),this.#i.removeEventListener("pointerup",s)};this.#i.addEventListener("pointermove",e),this.#i.addEventListener("pointerup",s)};#S(t){let e=this.#i.getBoundingClientRect(),s=c((t.clientX-e.left)/e.width,0,1);this.#t=Math.round(s*360),this.#c()}#_=t=>{let e=t.shiftKey?10:1;switch(t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#t=(this.#t+e)%361;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#t=(this.#t-e+361)%361;break;default:return}this.#c()};#h(t,e){return this.#u[t].inputs.find(s=>s.channel===e)?.el}#B=()=>{let t=this.#h("hex","hex");if(!t)return;let e=t.value.trim();if(e.startsWith("#")||(e="#"+e),/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(e)){let s=u(e);this.#t=s.h,this.#e=s.s,this.#s=s.l,this.#c()}};#U=()=>{let t=c(Number(this.#h("rgb","r").value)||0,0,255),e=c(Number(this.#h("rgb","g").value)||0,0,255),s=c(Number(this.#h("rgb","b").value)||0,0,255),n=E(t,e,s);this.#t=n.h,this.#e=n.s,this.#s=n.l,this.#c()};#q=()=>{let t=c(Number(this.#h("hsl","h").value)||0,0,360)%361,e=c(Number(this.#h("hsl","s").value)||0,0,100),s=c(Number(this.#h("hsl","l").value)||0,0,100);this.#t=t,this.#e=e,this.#s=s,this.#c()};#V=()=>{let t=c(Number(this.#h("oklch","oL").value)||0,0,100)/100,e=c(Number(this.#h("oklch","oC").value)||0,0,.4),s=c(Number(this.#h("oklch","oH").value)||0,0,360),n=I(t,e,s);this.#t=n.h,this.#e=n.s,this.#s=n.l,this.#c()};#j=t=>{let e=t.target.closest("button[data-color]");if(!e)return;let s=e.getAttribute("data-color"),n=u(s);this.#t=n.h,this.#e=n.s,this.#s=n.l,this.#c()};#G=async()=>{try{let e=await new window.EyeDropper().open(),s=u(e.sRGBHex);this.#t=s.h,this.#e=s.s,this.#s=s.l,this.#c()}catch{}};#K=()=>{let t=R(this.#g,this.#t,this.#e,this.#s);T(t,{button:this.#l,announceMessage:"Color copied"})};#c(t="internal"){this.#E(),this.#T();let e=d(this.#t,this.#e,this.#s),s=b(this.#t,this.#e,this.#s);this.dispatchEvent(new CustomEvent("color-picker:change",{bubbles:!0,detail:{hex:e,rgb:{r:s.r,g:s.g,b:s.b},hsl:{h:this.#t,s:this.#e,l:this.#s},source:t}}))}#E(){let t=d(this.#t,this.#e,this.#s),e=b(this.#t,this.#e,this.#s),s=d(this.#t,100,50);this.#w.style.background=t,this.#C.textContent=t,this.#n.style.setProperty("--area-hue",s),this.#v.style.insetInlineStart=`${this.#e}%`,this.#v.style.insetBlockStart=`${100-this.#s}%`,this.#v.style.background=t,this.#n.setAttribute("aria-valuetext",`Saturation ${this.#e}%, Lightness ${this.#s}%`),this.#A.style.insetInlineStart=`${this.#t/360*100}%`,this.#i.setAttribute("aria-valuenow",String(this.#t)),this.#i.setAttribute("aria-valuetext",`Hue ${this.#t}\xB0`);let n=(a,h,r)=>{let l=this.#h(a,h);l&&(l.value=String(r))};n("hex","hex",t),n("rgb","r",e.r),n("rgb","g",e.g),n("rgb","b",e.b),n("hsl","h",this.#t),n("hsl","s",this.#e),n("hsl","l",this.#s);let o=L(this.#t,this.#e,this.#s);n("oklch","oL",(o.L*100).toFixed(1)),n("oklch","oC",o.C.toFixed(3)),n("oklch","oH",o.H.toFixed(1))}#z(){if(!this.#f){if(this.#f=!0,this.setAttribute("open",""),this.#a.setAttribute("aria-expanded","true"),this.#y){this.#$();try{this.#o.showPopover()}catch{}window.addEventListener("scroll",this.#x,{capture:!0,passive:!0}),window.addEventListener("resize",this.#x,{passive:!0})}requestAnimationFrame(()=>this.#n.focus()),this.dispatchEvent(new CustomEvent("color-picker:open",{bubbles:!0}))}}#H(){if(this.#f){if(this.#f=!1,this.removeAttribute("open"),this.#a.setAttribute("aria-expanded","false"),this.#y){try{this.#o.hidePopover()}catch{}window.removeEventListener("scroll",this.#x,{capture:!0}),window.removeEventListener("resize",this.#x)}this.dispatchEvent(new CustomEvent("color-picker:close",{bubbles:!0}))}}#$(){if(!this.#y)return;let t=this.#a.getBoundingClientRect();this.#o.style.setProperty("--panel-top",`${t.bottom+4}px`),this.#o.style.setProperty("--panel-left",`${t.left}px`)}#x=()=>{this.#f&&this.#$()};#W=t=>{this.#f&&!this.contains(t.target)&&this.#H()};#T(){let t=d(this.#t,this.#e,this.#s);this.#d.setFormValue(t),this.#r.value=t,this.#r.dispatchEvent(new Event("input",{bubbles:!0}))}formResetCallback(){let t=u(this.#M);this.#t=t.h,this.#e=t.s,this.#s=t.l,this.#E(),this.#T()}formStateRestoreCallback(t){if(!t)return;let e=u(t);this.#t=e.h,this.#e=e.s,this.#s=e.l,this.#E(),this.#T()}get value(){return d(this.#t,this.#e,this.#s)}set value(t){if(!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t))return;let e=d(this.#t,this.#e,this.#s).toLowerCase(),s=t.toLowerCase();if(e===s||e===s.toLowerCase())return;let n=u(t);this.#t=n.h,this.#e=n.s,this.#s=n.l,this.#c("api")}};D("color-picker",S);export{S as ColorPicker};
2
2
  //# sourceMappingURL=color-picker.js.map
@@ -1,2 +1,2 @@
1
- var b=window.matchMedia("(prefers-reduced-motion: reduce)");var c=new Map;function d(h,t,e={}){let i=e.priority??10,r={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=c.get(h);if(customElements.get(h)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${h}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${h}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=i){s.priority===i&&console.warn(`[VB Bundle] Tag <${h}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}c.set(h,r),customElements.define(h,t)}var l=class extends HTMLElement{#r=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let t of this.#r)t();this.#r=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,i,r){t.addEventListener(e,i,r),this.#r.push(()=>t.removeEventListener(e,i,r))}setup(){}teardown(){}};function f(h,t,e){"role"in ElementInternals.prototype?t.role=e:h.setAttribute("role",e)}var p="popover"in HTMLElement.prototype;var u=class extends l{static formAssociated=!0;#r;#t;#e;#l=[];#h=[];#o=-1;#a=!1;#m=!1;#n="";#f="";#C="";#u;#p;#i=[];constructor(){super(),this.#r=this.attachInternals()}get#s(){return this.hasAttribute("multiple")}setup(){if(this.#t=this.querySelector(":scope > input")||this.querySelector(":scope > .tags-input-area > input"),!this.#t||(this.#e=this.querySelector(":scope > ul, :scope > ol"),!this.#e))return!1;this.#m=p,this.#m&&this.#e.setAttribute("popover","manual"),this.#s&&(this.#u=document.createElement("div"),this.#u.className="tags-input-area",this.insertBefore(this.#u,this.#e),this.#u.appendChild(this.#t),this.#p=document.createElement("div"),this.#p.setAttribute("aria-live","polite"),this.#p.setAttribute("aria-atomic","true"),this.#p.className="visually-hidden",this.appendChild(this.#p));let t=this.getAttribute("placeholder");t&&!this.#t.getAttribute("placeholder")&&this.#t.setAttribute("placeholder",t);let e=crypto.randomUUID().slice(0,8);if(this.#e.id||(this.#e.id=`combobox-listbox-${e}`),f(this.#t,this.#r,"combobox"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-autocomplete","list"),this.#t.setAttribute("aria-controls",this.#e.id),this.#t.setAttribute("autocomplete","off"),this.#e.setAttribute("role","listbox"),this.#s&&this.#e.setAttribute("aria-multiselectable","true"),this.#P(),!this.#s){let i=this.getAttribute("value");i&&this.#y(i,!1),this.#C=this.#n}this.listen(this.#t,"input",this.#V),this.listen(this.#t,"keydown",this.#T),this.listen(this.#t,"focus",this.#q),this.listen(this.#t,"click",this.#O),this.listen(this.#e,"click",this.#F),this.listen(this.#e,"pointerdown",this.#B),this.listen(document,"click",this.#N),this.#m&&this.listen(this.#e,"toggle",this.#R),this.#c(),this.#d(),this.#b()}teardown(){window.removeEventListener("scroll",this.#A,{capture:!0}),window.removeEventListener("resize",this.#A)}#P(){this.#l=Array.from(this.#e.querySelectorAll(":scope > li[data-value]")),this.#l.forEach((t,e)=>{t.setAttribute("role","option"),t.setAttribute("aria-selected","false"),t.id||(t.id=`${this.#e.id}-option-${e}`)}),this.#h=[...this.#l]}#E(t,e){if(this.#i.some(a=>a.value===t))return;let i=this.#S();if(i&&this.#i.length>=i)return;this.#i.push({value:t,label:e});let r=document.createElement("span");r.className="tag",r.dataset.value=t,r.textContent=e+" ";let s=document.createElement("button");s.type="button",s.setAttribute("aria-label",`Remove ${e}`),s.innerHTML="&times;",s.addEventListener("click",a=>{a.stopPropagation(),this.#$(t)}),r.appendChild(s),this.#u.insertBefore(r,this.#t);let o=this.#l.find(a=>a.getAttribute("data-value")===t);o&&o.setAttribute("aria-selected","true"),this.#L(`${e} added`),this.#t.value="",this.#v(""),this.#c(),this.#d(),this.#D(),i&&this.#i.length>=i&&(this.#t.disabled=!0,this.#b())}#$(t){let e=this.#i.findIndex(a=>a.value===t);if(e===-1)return;let i=this.#i.splice(e,1)[0],r=this.#u.querySelector(`.tag[data-value="${CSS.escape(t)}"]`);r&&r.remove();let s=this.#l.find(a=>a.getAttribute("data-value")===t);s&&s.setAttribute("aria-selected","false"),this.#L(`${i.label} removed`),this.#S()&&this.#t.disabled&&(this.#t.disabled=!1),this.#v(this.#t.value.trim()),this.#c(),this.#d(),this.#D(),this.#t.focus()}#S(){let t=this.getAttribute("max");return t?parseInt(t,10):0}#L(t){this.#p&&(this.#p.textContent="",requestAnimationFrame(()=>{this.#p.textContent=t}))}#V=()=>{let t=this.#t.value.trim();if(!this.#s&&this.#n){let e=this.#e.querySelector('[aria-selected="true"]');e&&e.setAttribute("aria-selected","false"),this.#n="",this.#f="",this.removeAttribute("value"),this.#c(),this.#d()}this.#v(t),this.#g()};#T=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#a||this.#g(),this.#w(this.#o+1);break;case"ArrowUp":t.preventDefault(),this.#a||this.#g(),this.#w(this.#o-1);break;case"Home":this.#a&&(t.preventDefault(),this.#w(0));break;case"End":this.#a&&(t.preventDefault(),this.#w(this.#h.length-1));break;case"Enter":if(t.preventDefault(),this.#a&&this.#o>=0&&this.#h[this.#o]){let e=this.#h[this.#o];this.#s?this.#E(e.getAttribute("data-value"),e.textContent.trim()):this.#k(e)}else if(this.#s&&this.hasAttribute("custom")&&this.#t.value.trim()){let e=this.#t.value.trim();this.#E(e,e)}break;case"Backspace":if(this.#s&&!this.#t.value&&this.#i.length>0){let e=this.#i[this.#i.length-1];this.#$(e.value)}break;case",":if(this.#s&&this.hasAttribute("custom")&&this.#t.value.trim()){t.preventDefault();let e=this.#t.value.trim();this.#E(e,e)}break;case"Escape":this.#a&&(t.preventDefault(),t.stopPropagation(),this.#b(),this.#t.focus());break;case"Tab":this.#a&&this.#b();break}};#q=()=>{this.#s?(this.#v(this.#t.value.trim()),this.#g()):(this.#t.value||!this.#n)&&(this.#v(this.#t.value.trim()),this.#g())};#O=()=>{this.#a||(this.#v(this.#t.value.trim()),this.#g())};#F=t=>{let e=t.target.closest("li[data-value]");e&&this.#h.includes(e)&&(this.#s?this.#E(e.getAttribute("data-value"),e.textContent.trim()):this.#k(e))};#B=t=>{t.preventDefault()};#N=t=>{this.#a&&!this.contains(t.target)&&this.#b()};#v(t){let e=this.getAttribute("filter")||"contains",i=t.toLowerCase(),r=this.#s?new Set(this.#i.map(s=>s.value)):null;this.#h=[],this.#l.forEach(s=>{let o=s.getAttribute("data-value"),a=s.textContent.trim().toLowerCase();if(r&&r.has(o)){s.hidden=!0;return}let n;t?e==="startsWith"?n=a.startsWith(i):n=a.includes(i):n=!0,s.hidden=!n,n&&this.#h.push(s)}),this.#o=-1,this.#x()}#w(t){if(this.#h.length===0)return;t<0&&(t=this.#h.length-1),t>=this.#h.length&&(t=0),this.#o>=0&&this.#h[this.#o]&&this.#h[this.#o].removeAttribute("data-active"),this.#o=t;let e=this.#h[t];e.setAttribute("data-active",""),e.scrollIntoView({block:"nearest"}),this.#t.setAttribute("aria-activedescendant",e.id)}#x(){this.#l.forEach(t=>t.removeAttribute("data-active")),this.#t.removeAttribute("aria-activedescendant")}#k(t){let e=t.getAttribute("data-value"),i=t.textContent.trim();this.#l.forEach(r=>r.setAttribute("aria-selected","false")),t.setAttribute("aria-selected","true"),this.#n=e,this.#f=i,this.#t.value=i,this.setAttribute("value",e),this.#c(),this.#d(),this.#b(),this.#t.focus(),this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{value:e,label:i}}))}#y(t,e=!0){let i=this.#l.find(r=>r.getAttribute("data-value")===t);i&&(e?this.#k(i):(i.setAttribute("aria-selected","true"),this.#n=t,this.#f=i.textContent.trim(),this.#t.value=this.#f,this.setAttribute("value",t)))}#A=()=>this.#M();#g(){if(!this.#a){if(this.#a=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#e.hidden=!1,this.#m){this.#M();try{this.#e.showPopover()}catch{}window.addEventListener("scroll",this.#A,{capture:!0,passive:!0}),window.addEventListener("resize",this.#A,{passive:!0})}this.dispatchEvent(new CustomEvent("combo-box:open",{bubbles:!0}))}}#b(){if(!(!this.#a&&this.#e.hidden)){if(this.#a=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#e.hidden=!0,this.#o=-1,this.#x(),this.#m){try{this.#e.hidePopover()}catch{}window.removeEventListener("scroll",this.#A,{capture:!0}),window.removeEventListener("resize",this.#A)}this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0}))}}get#I(){return this.#s&&this.#u?this.#u:this.#t}#M(){if(!this.#m)return;let t=this.#I;if(!t)return;let e=t.getBoundingClientRect();this.#e.style.setProperty("--combobox-top",`${e.bottom+2}px`),this.#e.style.setProperty("--combobox-left",`${e.left}px`),this.#e.style.setProperty("--combobox-width",`${e.width}px`)}#R=t=>{t.newState==="closed"&&this.#a&&(this.#a=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#e.hidden=!0,this.#o=-1,this.#x(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))};#c(){if(this.#s)if(this.#i.length>0){let t=new FormData,e=this.getAttribute("name")||"";for(let i of this.#i)t.append(e,i.value);this.#r.setFormValue(t)}else this.#r.setFormValue(null);else this.#n?this.#r.setFormValue(this.#n,this.#f):this.#r.setFormValue(null)}#d(){this.hasAttribute("required")?this.#s?this.#i.length===0?this.#r.setValidity({valueMissing:!0},"Please select at least one option",this.#t):this.#r.setValidity({}):this.#n?this.#r.setValidity({}):this.#r.setValidity({valueMissing:!0},"Please select an option",this.#t):this.#r.setValidity({})}#D(){this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{values:this.#i.map(t=>t.value),labels:this.#i.map(t=>t.label)}}))}formResetCallback(){this.#s?(this.#u.querySelectorAll(".tag").forEach(t=>t.remove()),this.#i=[],this.#t.value="",this.#t.disabled=!1):(this.#n="",this.#f="",this.#t.value="",this.removeAttribute("value")),this.#l.forEach(t=>{t.setAttribute("aria-selected","false"),t.hidden=!1}),this.#h=[...this.#l],this.#o=-1,this.#x(),this.#b(),!this.#s&&this.#C&&this.#y(this.#C,!1),this.#c(),this.#d()}formStateRestoreCallback(t){t&&(this.#s||(this.#y(t,!1),this.#c(),this.#d()))}get value(){return this.#n}set value(t){t?this.#y(t):(this.#l.forEach(e=>e.setAttribute("aria-selected","false")),this.#n="",this.#f="",this.#t.value="",this.removeAttribute("value"),this.#c(),this.#d())}get label(){return this.#f}get values(){return this.#i.map(t=>t.value)}get labels(){return this.#i.map(t=>t.label)}static get observedAttributes(){return["value"]}attributeChangedCallback(t,e,i){t==="value"&&this.#t&&i!==this.#n&&i&&(this.#y(i,!1),this.#c(),this.#d())}};d("combo-box",u);export{u as ComboBox};
1
+ var y=window.matchMedia("(prefers-reduced-motion: reduce)");var p=new Map;function c(h,t,e={}){let s=e.priority??10,o={impl:t,bundle:e.bundle,contract:e.contract,priority:s},i=p.get(h);if(customElements.get(h)){if(!i||i.priority>=s){i&&i.priority===s&&i.impl!==t&&console.warn(`[VB Bundle] Tag <${h}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${h}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=s){i.priority===s&&console.warn(`[VB Bundle] Tag <${h}> already registered by "${i.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}p.set(h,o),customElements.define(h,t)}var l=class extends HTMLElement{#e=[];#t;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let t of this.#e)t();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(t,e,s,o){t.addEventListener(e,s,o),this.#e.push(()=>t.removeEventListener(e,s,o))}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let s=this.#t.states;try{e?s.add(t):s.delete(t)}catch{let o=`--${t}`;e?s.add(o):s.delete(o)}}_adoptInternals(t){this.#t||(this.#t=t)}};function b(h,t,e){"role"in ElementInternals.prototype?t.role=e:h.setAttribute("role",e)}var u=CSS.supports("anchor-name","--x"),v=CSS.supports("position-area","bottom"),g=0,d=class extends l{#e=null;#t=null;#i=null;#s=null;setup(){this.id||(this.id=`pop-over-${++g}`);let t=this.dataset.mode||"auto";this.hasAttribute("popover")||this.setAttribute("popover",t),this.#c(),this.#a(),this.#i=e=>{let s=e.newState==="open"?"show":"hide";this.dispatchEvent(new CustomEvent(`pop-over:${s}`,{detail:{state:e.newState},bubbles:!0,composed:!0})),!u&&e.newState==="open"&&this.#e&&this.#o()},this.listen(this,"beforetoggle",this.#i),u||(this.#s=()=>{this.matches(":popover-open")&&this.#e&&this.#o()},this.listen(window,"resize",this.#s),this.listen(window,"scroll",this.#s,{capture:!0,passive:!0}))}show(){this.matches(":popover-open")||this.showPopover()}hide(){this.matches(":popover-open")&&this.hidePopover()}toggle(){this.matches(":popover-open")?this.hide():this.show()}get open(){return this.matches(":popover-open")}#c(){let t=this.dataset.anchor;t?this.#e=document.getElementById(t)||document.querySelector(t):this.#e=document.querySelector(`[popovertarget="${CSS.escape(this.id)}"]`)}#a(){if(!(!this.#e||!u)&&(this.#t=`--pop-over-anchor-${this.id}`,this.#e.style.setProperty("anchor-name",this.#t),this.style.setProperty("position-anchor",this.#t),this.setAttribute("data-anchor-name",this.#t||""),!v)){let t=this.dataset.position||"bottom";this.#l(t)}}#l(t){let e="var(--_pop-over-offset, var(--size-xs))",s={top:{bottom:`calc(anchor(top) + ${e})`,left:"anchor(left)"},bottom:{top:`calc(anchor(bottom) + ${e})`,left:"anchor(left)"},left:{right:`calc(anchor(left) + ${e})`,top:"anchor(top)"},right:{left:`calc(anchor(right) + ${e})`,top:"anchor(top)"}},o=t.split("-")[0],i=s[o]||s.bottom;Object.entries(i).forEach(([n,r])=>this.style.setProperty(n,r))}#o(){if(!this.#e)return;let t=this.#e.getBoundingClientRect(),e=this.dataset.position||"bottom",s=this.#n(),o,i;switch(e.split("-")[0]){case"top":o=t.top-this.offsetHeight-s,i=t.left;break;case"left":o=t.top,i=t.left-this.offsetWidth-s;break;case"right":o=t.top,i=t.right+s;break;default:o=t.bottom+s,i=t.left;break}e.endsWith("-end")&&(e.startsWith("top")||e.startsWith("bottom")?i=t.right-this.offsetWidth:o=t.bottom-this.offsetHeight),this.style.position="fixed",this.style.top=`${Math.round(o)}px`,this.style.left=`${Math.round(i)}px`,this.style.margin="0"}#n(){let t={none:0,xs:4,s:8,m:16,l:24};return t[this.dataset.offset]??t.xs}};c("pop-over",d);var A=0,f=class extends l{static formAssociated=!0;#e;#t;#i;#s;#c=[];#a=[];#l=-1;#o=!1;#n="";#f="";#w="";#p;#A;#r=[];constructor(){super(),this.#e=this.attachInternals(),this._adoptInternals(this.#e)}get#h(){return this.hasAttribute("multiple")}setup(){let t=this.querySelector(":scope > input")||this.querySelector(":scope > .tags-input-area > input");if(!t)return!1;this.#t=t;let e=this.querySelector("ul, ol");if(!e)return!1;if(this.#i=e,this.#h){let r=this.querySelector(":scope > .tags-input-area");if(!r){r=document.createElement("div"),r.className="tags-input-area";let m=this.querySelector(":scope > pop-over[data-combobox-host]")||this.#i;this.insertBefore(r,m)}this.#p=r,this.#t.parentNode!==this.#p&&this.#p.appendChild(this.#t);let a=this.querySelector(":scope > [data-combobox-live]");a||(a=document.createElement("div"),a.setAttribute("aria-live","polite"),a.setAttribute("aria-atomic","true"),a.setAttribute("data-combobox-live",""),a.className="visually-hidden",this.appendChild(a)),this.#A=a}let s=this.getAttribute("placeholder");s&&!this.#t.getAttribute("placeholder")&&this.#t.setAttribute("placeholder",s);let o=`cb${++A}`;this.#i.id||(this.#i.id=`combobox-listbox-${o}`),b(this.#t,this.#e,"combobox"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-autocomplete","list"),this.#t.setAttribute("aria-controls",this.#i.id),this.#t.setAttribute("autocomplete","off"),this.#i.setAttribute("role","listbox"),this.#h&&this.#i.setAttribute("aria-multiselectable","true");let i=this.#h?this.#p:this.#t;i.id||(i.id=`combobox-anchor-${o}`);let n=this.querySelector(":scope > pop-over[data-combobox-host]");if(n?this.#s=n:(this.#s=document.createElement("pop-over"),this.#s.setAttribute("data-combobox-host",""),this.#s.id=`combobox-pop-${o}`,this.#s.dataset.mode="manual",this.#s.dataset.position="bottom-start",this.#s.dataset.anchor=i.id,this.#s.appendChild(this.#i),this.appendChild(this.#s)),this.#s.dataset.anchor=i.id,this.#i.parentElement!==this.#s&&this.#s.appendChild(this.#i),this.#M(),!this.#h){let r=this.getAttribute("value");r&&this.#g(r,!1),this.#w=this.#n}return this.listen(this.#t,"input",this.#V),this.listen(this.#t,"keydown",this.#D),this.listen(this.#t,"focus",this.#P),this.listen(this.#t,"click",this.#B),this.listen(this.#i,"click",this.#T),this.listen(this.#i,"pointerdown",this.#F),this.listen(document,"click",this.#I),this.listen(this.#s,"pop-over:hide",this.#N),this.#u(),this.#d(),this.#b(),!0}teardown(){}#M(){this.#c=Array.from(this.#i.querySelectorAll(":scope > li[data-value]")),this.#c.forEach((t,e)=>{t.setAttribute("role","option"),t.setAttribute("aria-selected","false"),t.id||(t.id=`${this.#i.id}-option-${e}`)}),this.#a=[...this.#c]}#y(t,e){if(this.#r.some(r=>r.value===t))return;let s=this.#$();if(s&&this.#r.length>=s)return;this.#r.push({value:t,label:e});let o=document.createElement("span");o.className="tag",o.dataset.value=t,o.textContent=e+" ";let i=document.createElement("button");i.type="button",i.setAttribute("aria-label",`Remove ${e}`),i.innerHTML="&times;",i.addEventListener("click",r=>{r.stopPropagation(),this.#k(t)}),o.appendChild(i),this.#p.insertBefore(o,this.#t);let n=this.#c.find(r=>r.getAttribute("data-value")===t);n&&n.setAttribute("aria-selected","true"),this.#S(`${e} added`),this.#t.value="",this.#m(""),this.#u(),this.#d(),this.#q(),s&&this.#r.length>=s&&(this.#t.disabled=!0,this.#b())}#k(t){let e=this.#r.findIndex(r=>r.value===t);if(e===-1)return;let s=this.#r.splice(e,1)[0],o=this.#p.querySelector(`.tag[data-value="${CSS.escape(t)}"]`);o&&o.remove();let i=this.#c.find(r=>r.getAttribute("data-value")===t);i&&i.setAttribute("aria-selected","false"),this.#S(`${s.label} removed`),this.#$()&&this.#t.disabled&&(this.#t.disabled=!1),this.#m(this.#t.value.trim()),this.#u(),this.#d(),this.#q(),this.#t.focus()}#$(){let t=this.getAttribute("max");return t?parseInt(t,10):0}#S(t){this.#A&&(this.#A.textContent="",requestAnimationFrame(()=>{this.#A.textContent=t}))}#V=()=>{let t=this.#t.value.trim();if(!this.#h&&this.#n){let e=this.#i.querySelector('[aria-selected="true"]');e&&e.setAttribute("aria-selected","false"),this.#n="",this.#f="",this.removeAttribute("value"),this.#u(),this.#d()}this.#m(t),this.#v()};#D=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#o||this.#v(),this.#E(this.#l+1);break;case"ArrowUp":t.preventDefault(),this.#o||this.#v(),this.#E(this.#l-1);break;case"Home":this.#o&&(t.preventDefault(),this.#E(0));break;case"End":this.#o&&(t.preventDefault(),this.#E(this.#a.length-1));break;case"Enter":if(t.preventDefault(),this.#o&&this.#l>=0&&this.#a[this.#l]){let e=this.#a[this.#l];this.#h?this.#y(e.getAttribute("data-value"),e.textContent.trim()):this.#C(e)}else if(this.#h&&this.hasAttribute("custom")&&this.#t.value.trim()){let e=this.#t.value.trim();this.#y(e,e)}break;case"Backspace":if(this.#h&&!this.#t.value&&this.#r.length>0){let e=this.#r[this.#r.length-1];this.#k(e.value)}break;case",":if(this.#h&&this.hasAttribute("custom")&&this.#t.value.trim()){t.preventDefault();let e=this.#t.value.trim();this.#y(e,e)}break;case"Escape":this.#o&&(t.preventDefault(),t.stopPropagation(),this.#b(),this.#t.focus());break;case"Tab":this.#o&&this.#b();break}};#P=()=>{this.#h?(this.#m(this.#t.value.trim()),this.#v()):(this.#t.value||!this.#n)&&(this.#m(this.#t.value.trim()),this.#v())};#B=()=>{this.#o||(this.#m(this.#t.value.trim()),this.#v())};#T=t=>{let e=t.target.closest("li[data-value]");e&&this.#a.includes(e)&&(this.#h?this.#y(e.getAttribute("data-value"),e.textContent.trim()):this.#C(e))};#F=t=>{t.preventDefault()};#I=t=>{this.#o&&!this.contains(t.target)&&this.#b()};#m(t){let e=this.getAttribute("filter")||"contains",s=t.toLowerCase(),o=this.#h?new Set(this.#r.map(i=>i.value)):null;this.#a=[],this.#c.forEach(i=>{let n=i.getAttribute("data-value"),r=i.textContent.trim().toLowerCase();if(o&&o.has(n)){i.hidden=!0;return}let a;t?e==="startsWith"?a=r.startsWith(s):a=r.includes(s):a=!0,i.hidden=!a,a&&this.#a.push(i)}),this.#l=-1,this.#x(),this.setState("no-matches",this.#a.length===0)}#E(t){if(this.#a.length===0)return;t<0&&(t=this.#a.length-1),t>=this.#a.length&&(t=0),this.#l>=0&&this.#a[this.#l]&&this.#a[this.#l].removeAttribute("data-active"),this.#l=t;let e=this.#a[t];e.setAttribute("data-active",""),e.scrollIntoView({block:"nearest"}),this.#t.setAttribute("aria-activedescendant",e.id)}#x(){this.#c.forEach(t=>t.removeAttribute("data-active")),this.#t.removeAttribute("aria-activedescendant")}#C(t,e="internal"){let s=t.getAttribute("data-value")||"",o=t.textContent.trim();this.#n!==s&&(this.#c.forEach(i=>i.setAttribute("aria-selected","false")),t.setAttribute("aria-selected","true"),this.#n=s,this.#f=o,this.#t.value=o,this.setAttribute("value",s),this.#u(),this.#d(),this.#b(),this.#t.focus(),this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{value:s,label:o,source:e}})))}#g(t,e=!0,s="api"){let o=this.#c.find(i=>i.getAttribute("data-value")===t);o&&(e?this.#C(o,s):(o.setAttribute("aria-selected","true"),this.#n=t,this.#f=o.textContent.trim(),this.#t.value=this.#f,this.setAttribute("value",t)))}#v(){this.#o||(this.#o=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#s?.show(),this.dispatchEvent(new CustomEvent("combo-box:open",{bubbles:!0})))}#b(){this.#o&&(this.#o=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#l=-1,this.#x(),this.#s?.hide(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))}#N=()=>{this.#o&&(this.#o=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#l=-1,this.#x(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))};#u(){if(this.#h)if(this.#r.length>0){let t=new FormData,e=this.getAttribute("name")||"";for(let s of this.#r)t.append(e,s.value);this.#e.setFormValue(t)}else this.#e.setFormValue(null);else this.#n?this.#e.setFormValue(this.#n,this.#f):this.#e.setFormValue(null)}#d(){this.hasAttribute("required")?this.#h?this.#r.length===0?this.#e.setValidity({valueMissing:!0},"Please select at least one option",this.#t):this.#e.setValidity({}):this.#n?this.#e.setValidity({}):this.#e.setValidity({valueMissing:!0},"Please select an option",this.#t):this.#e.setValidity({})}#q(){this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{values:this.#r.map(t=>t.value),labels:this.#r.map(t=>t.label)}}))}formResetCallback(){this.#h?(this.#p.querySelectorAll(".tag").forEach(t=>t.remove()),this.#r=[],this.#t.value="",this.#t.disabled=!1):(this.#n="",this.#f="",this.#t.value="",this.removeAttribute("value")),this.#c.forEach(t=>{t.setAttribute("aria-selected","false"),t.hidden=!1}),this.#a=[...this.#c],this.#l=-1,this.#x(),this.#b(),!this.#h&&this.#w&&this.#g(this.#w,!1),this.#u(),this.#d()}formStateRestoreCallback(t){t&&(this.#h||(this.#g(t,!1),this.#u(),this.#d()))}get value(){return this.#n}set value(t){t?this.#g(t):(this.#c.forEach(e=>e.setAttribute("aria-selected","false")),this.#n="",this.#f="",this.#t.value="",this.removeAttribute("value"),this.#u(),this.#d())}get label(){return this.#f}get values(){return this.#r.map(t=>t.value)}get labels(){return this.#r.map(t=>t.label)}static get observedAttributes(){return["value"]}attributeChangedCallback(t,e,s){t==="value"&&this.#t&&s!==this.#n&&s&&(this.#g(s,!1),this.#u(),this.#d())}};c("combo-box",f);export{f as ComboBox};
2
2
  //# sourceMappingURL=combo-box.js.map
@@ -1,2 +1,2 @@
1
- var f=/Mac|iPhone|iPad|iPod/.test(navigator.platform??""),v={mac:{meta:"\u2318",cmd:"\u2318",alt:"\u2325",shift:"\u21E7",ctrl:"\u2303"},other:{meta:"Ctrl",cmd:"Ctrl",alt:"Alt",shift:"Shift",ctrl:"Ctrl"}};function b(i){let e=f?v.mac:v.other;return i.split("+").map(t=>{let n=t.trim().toLowerCase();return e[n]??n.toUpperCase()}).join(f?"":"+")}function k(i){let e=i.toLowerCase().split("+").map(n=>n.trim());return{key:e.pop()??"",meta:e.includes("meta")||e.includes("cmd"),ctrl:e.includes("ctrl"),shift:e.includes("shift"),alt:e.includes("alt")}}function C(i,e){if(i.key.toLowerCase()!==e.key)return!1;let t,n;return f?(t=e.meta,n=e.ctrl):(t=!1,n=e.meta||e.ctrl),!(t!==i.metaKey||n!==i.ctrlKey||e.shift!==i.shiftKey||e.alt!==i.altKey)}var x=new Set(["INPUT","TEXTAREA","SELECT"]),h=[],w=!1;function L(i){let e=x.has(i.target.tagName)||i.target.isContentEditable;for(let t of h)if(!(e&&!t.global)&&C(i,t.descriptor)){i.preventDefault(),t.callback(i);return}}function S(){w||(document.addEventListener("keydown",L),w=!0)}function A(i,e,t={}){S();let n=k(i),r={combo:i,descriptor:n,callback:e,global:t.global===!0};return h.find(a=>a.combo===i)&&console.warn(`[hotkey-bind] Shortcut "${i}" already bound. Last-connected-wins.`),h.unshift(r),function(){let o=h.indexOf(r);o!==-1&&h.splice(o,1)}}var H=window.matchMedia("(prefers-reduced-motion: reduce)");var N=new Map;function m(i,e,t={}){let n=t.priority??10,r={impl:e,bundle:t.bundle,contract:t.contract,priority:n},s=N.get(i);if(customElements.get(i)){if(!s||s.priority>=n){s&&s.priority===n&&s.impl!==e&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${s.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(s&&s.priority>=n){s.priority===n&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${s.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}N.set(i,r),customElements.define(i,e)}var p=class extends HTMLElement{#e=[];connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0})))}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,n,r){e.addEventListener(t,n,r),this.#e.push(()=>e.removeEventListener(t,n,r))}setup(){}teardown(){}};var y=class extends p{#e;#n;#t;#s=[];#o=-1;#c=[];#l=null;#i=[];setup(){this.#m(),this.#p(),this.hasAttribute("discover")&&this.#y()}teardown(){this.#l?.()}#m(){this.#e=document.createElement("dialog"),this.#e.className="command-dialog",this.#e.addEventListener("click",n=>{n.target===this.#e&&this.close()});let e=document.createElement("div");e.className="command-search",this.#n=document.createElement("input"),this.#n.type="search",this.#n.placeholder=this.getAttribute("placeholder")||"Type a command...",this.#n.setAttribute("aria-label","Search commands"),this.#n.autocomplete="off",this.#n.addEventListener("input",this.#r),this.#n.addEventListener("keydown",this.#f),e.appendChild(this.#n),this.#t=document.createElement("div"),this.#t.className="command-list",this.#t.setAttribute("role","listbox"),this.#c=Array.from(this.querySelectorAll("command-group")),this.#c.forEach(n=>{let r=document.createElement("div");r.className="command-group-header",r.textContent=n.getAttribute("label")||"",r.setAttribute("role","presentation");let s=Array.from(n.querySelectorAll("command-item"));this.#t.appendChild(r),s.forEach(a=>{let o=document.createElement("button");o.className="command-option",o.setAttribute("role","option"),o.dataset.value=a.getAttribute("value")||"",o.dataset.searchText=a.textContent.toLowerCase().trim();let l=a.querySelector('[slot="icon"]');if(l){let d=document.createElement("span");d.className="command-icon",d.appendChild(l.cloneNode(!0)),o.appendChild(d)}let c=document.createElement("span");c.className="command-label",c.textContent=a.textContent.trim(),o.appendChild(c);let u=a.getAttribute("data-hotkey");if(u){let d=document.createElement("kbd");d.className="command-kbd",d.textContent=b(u),o.appendChild(d)}o.addEventListener("click",()=>{this.#b(o.dataset.value)}),this.#t.appendChild(o),this.#s.push({btn:o,header:r,group:n})})});let t=document.createElement("div");t.className="command-empty",t.textContent="No results found.",t.hidden=!0,this.#t.appendChild(t),this.#e.appendChild(e),this.#e.appendChild(this.#t),this.appendChild(this.#e)}#p(){let e=this.getAttribute("hotkey")||"meta+k";this.#l=A(e,()=>{this.#e.open?this.close():this.open()},{global:!0})}#r=()=>{let e=this.#n.value.toLowerCase().trim(),t=0,n=new Set;this.#s.forEach(({btn:s,header:a})=>{let o=!e||s.dataset.searchText.includes(e);s.hidden=!o,o&&(t++,n.add(a))}),this.#t.querySelectorAll(".command-group-header").forEach(s=>{s.hidden=!n.has(s)});let r=this.#t.querySelector(".command-empty");r&&(r.hidden=t>0),this.#o=-1,t>0&&this.#a(0)};#f=e=>{let t=this.#d();switch(e.key){case"ArrowDown":e.preventDefault(),this.#a(this.#o+1);break;case"ArrowUp":e.preventDefault(),this.#a(this.#o-1);break;case"Enter":e.preventDefault(),this.#o>=0&&t[this.#o]&&t[this.#o].btn.click();break;case"Escape":e.preventDefault(),this.close();break}};#d(){return this.#s.filter(({btn:e})=>!e.hidden)}#a(e){let t=this.#d();if(t.length===0)return;t.forEach(({btn:r})=>r.removeAttribute("data-active")),e<0&&(e=t.length-1),e>=t.length&&(e=0),this.#o=e;let{btn:n}=t[e];n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"})}#b(e){this.close(),this.dispatchEvent(new CustomEvent("command-palette:select",{bubbles:!0,detail:{value:e}}))}#y(){this.listen(document,"vb:command-registry-change",this.#E)}#E=()=>{this.#e?.open&&(this.#u(),this.#r())};#u(){if(!this.hasAttribute("discover"))return;let{getRegisteredCommands:e,scanAutoDiscoverable:t}=window.__commandRegistry||{};if(!e)return;this.#s=this.#s.filter(s=>!s.discovered),this.#i.forEach(s=>s.remove()),this.#i=[];let n=this.#t.querySelector(".command-empty"),r=e();for(let[s,a]of r){let o=document.createElement("div");o.className="command-group-header",o.textContent=s,o.setAttribute("role","presentation"),this.#t.insertBefore(o,n),this.#i.push(o);for(let l of a){if(this.contains(l.element))continue;let c=this.#h(l.label,l.icon,l.shortcut);c.dataset.value=`__discovered:${l.label}`,c.addEventListener("click",()=>{this.close(),l.element.click()}),this.#t.insertBefore(c,n),this.#s.push({btn:c,header:o,group:null,discovered:!0})}}if(this.getAttribute("discover")==="auto"&&t){let s=t(),a=new Map;for(let o of s){let l=a.get(o.group)||[];l.push(o),a.set(o.group,l)}for(let[o,l]of a){let c=document.createElement("div");c.className="command-group-header",c.textContent=o,c.setAttribute("role","presentation"),this.#t.insertBefore(c,n),this.#i.push(c);for(let u of l){if(this.contains(u.element))continue;let d=this.#h(u.label,u.icon,u.shortcut);d.dataset.value=`__auto:${u.label}`,d.dataset.auto="",d.addEventListener("click",()=>{this.close(),u.action?u.action():u.element.click()}),this.#t.insertBefore(d,n),this.#s.push({btn:d,header:c,group:null,discovered:!0})}}}}#h(e,t,n){let r=document.createElement("button");if(r.className="command-option",r.setAttribute("role","option"),r.dataset.searchText=e.toLowerCase(),t){let a=document.createElement("span");a.className="command-icon";let o=document.createElement("icon-wc");o.setAttribute("name",t),a.appendChild(o),r.appendChild(a)}let s=document.createElement("span");if(s.className="command-label",s.textContent=e,r.appendChild(s),n){let a=document.createElement("kbd");a.className="command-kbd",a.textContent=b(n),r.appendChild(a)}return r}open(){this.#e.open||(this.#u(),this.#e.showModal(),this.#n.value="",this.#r(),this.#n.focus(),this.dispatchEvent(new CustomEvent("command-palette:open",{bubbles:!0})))}close(){this.#e.open&&(this.#e.close(),this.dispatchEvent(new CustomEvent("command-palette:close",{bubbles:!0})))}get isOpen(){return this.#e?.open??!1}},E=class extends HTMLElement{},g=class extends HTMLElement{};m("command-palette",y);m("command-group",E);m("command-item",g);export{y as CommandPalette};
1
+ var f=/Mac|iPhone|iPad|iPod/.test(navigator.platform??""),v={mac:{meta:"\u2318",cmd:"\u2318",alt:"\u2325",shift:"\u21E7",ctrl:"\u2303"},other:{meta:"Ctrl",cmd:"Ctrl",alt:"Alt",shift:"Shift",ctrl:"Ctrl"}};function b(r){let e=f?v.mac:v.other;return r.split("+").map(t=>{let n=t.trim().toLowerCase();return e[n]??n.toUpperCase()}).join(f?"":"+")}function k(r){let e=r.toLowerCase().split("+").map(n=>n.trim());return{key:e.pop()??"",meta:e.includes("meta")||e.includes("cmd"),ctrl:e.includes("ctrl"),shift:e.includes("shift"),alt:e.includes("alt")}}function C(r,e){if(r.key.toLowerCase()!==e.key)return!1;let t,n;return f?(t=e.meta,n=e.ctrl):(t=!1,n=e.meta||e.ctrl),!(t!==r.metaKey||n!==r.ctrlKey||e.shift!==r.shiftKey||e.alt!==r.altKey)}var x=new Set(["INPUT","TEXTAREA","SELECT"]),h=[],A=!1;function L(r){let e=x.has(r.target.tagName)||r.target.isContentEditable;for(let t of h)if(!(e&&!t.global)&&C(r,t.descriptor)){r.preventDefault(),t.callback(r);return}}function M(){A||(document.addEventListener("keydown",L),A=!0)}function w(r,e,t={}){M();let n=k(r),s={combo:r,descriptor:n,callback:e,global:t.global===!0};return h.find(a=>a.combo===r)&&console.warn(`[hotkey-bind] Shortcut "${r}" already bound. Last-connected-wins.`),h.unshift(s),function(){let o=h.indexOf(s);o!==-1&&h.splice(o,1)}}var H=window.matchMedia("(prefers-reduced-motion: reduce)");var N=new Map;function m(r,e,t={}){let n=t.priority??10,s={impl:e,bundle:t.bundle,contract:t.contract,priority:n},i=N.get(r);if(customElements.get(r)){if(!i||i.priority>=n){i&&i.priority===n&&i.impl!==e&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=n){i.priority===n&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${i.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}N.set(r,s),customElements.define(r,e)}var p=class extends HTMLElement{#e=[];#t;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,n,s){e.addEventListener(t,n,s),this.#e.push(()=>e.removeEventListener(t,n,s))}setup(){}teardown(){}setState(e,t){this.#t||(this.#t=this.attachInternals());let n=this.#t.states;try{t?n.add(e):n.delete(e)}catch{let s=`--${e}`;t?n.add(s):n.delete(s)}}_adoptInternals(e){this.#t||(this.#t=e)}};var y=class extends p{#e;#t;#n;#s=[];#o=-1;#r=[];#l=null;#i=[];setup(){this.#m(),this.#p(),this.hasAttribute("discover")&&this.#y()}teardown(){this.#l?.()}get commands(){let e=[];for(let t of this.#r){let n=t.getAttribute("label")||"";for(let s of t.querySelectorAll("command-item"))e.push({value:s.getAttribute("value")||"",label:s.textContent.trim(),hotkey:s.getAttribute("data-hotkey")||void 0,group:n||void 0})}return e}set commands(e){let t=Array.isArray(e)?e:[],n=new Map;for(let s of t){let i=s.group||"";n.has(i)||n.set(i,[]),n.get(i).push(s)}for(let s of[...this.children])(s.tagName==="COMMAND-GROUP"||s.tagName==="COMMAND-ITEM")&&s.remove();for(let[s,i]of n){let a=document.createElement("command-group");s&&a.setAttribute("label",s);for(let o of i){let c=document.createElement("command-item");if(o.value&&c.setAttribute("value",o.value),o.hotkey&&c.setAttribute("data-hotkey",o.hotkey),o.icon){let l=document.createElement("span");l.setAttribute("slot","icon"),l.innerHTML=o.icon,c.appendChild(l)}c.appendChild(document.createTextNode(o.label||o.value||"")),a.appendChild(c)}this.appendChild(a)}this.teardown(),this.removeAttribute("data-upgraded"),this.setup(),this.dispatchEvent(new CustomEvent("command-palette:commands-changed",{detail:{commands:t,source:"property"},bubbles:!0}))}#m(){this.#e=document.createElement("dialog"),this.#e.className="command-dialog",this.#e.addEventListener("click",n=>{n.target===this.#e&&this.close()});let e=document.createElement("div");e.className="command-search",this.#t=document.createElement("input"),this.#t.type="search",this.#t.placeholder=this.getAttribute("placeholder")||"Type a command...",this.#t.setAttribute("aria-label","Search commands"),this.#t.autocomplete="off",this.#t.addEventListener("input",this.#a),this.#t.addEventListener("keydown",this.#f),e.appendChild(this.#t),this.#n=document.createElement("div"),this.#n.className="command-list",this.#n.setAttribute("role","listbox"),this.#r=Array.from(this.querySelectorAll("command-group")),this.#r.forEach(n=>{let s=document.createElement("div");s.className="command-group-header",s.textContent=n.getAttribute("label")||"",s.setAttribute("role","presentation");let i=Array.from(n.querySelectorAll("command-item"));this.#n.appendChild(s),i.forEach(a=>{let o=document.createElement("button");o.className="command-option",o.setAttribute("role","option"),o.dataset.value=a.getAttribute("value")||"",o.dataset.searchText=a.textContent.toLowerCase().trim();let c=a.querySelector('[slot="icon"]');if(c){let d=document.createElement("span");d.className="command-icon",d.appendChild(c.cloneNode(!0)),o.appendChild(d)}let l=document.createElement("span");l.className="command-label",l.textContent=a.textContent.trim(),o.appendChild(l);let u=a.getAttribute("data-hotkey");if(u){let d=document.createElement("kbd");d.className="command-kbd",d.textContent=b(u),o.appendChild(d)}o.addEventListener("click",()=>{this.#b(o.dataset.value)}),this.#n.appendChild(o),this.#s.push({btn:o,header:s,group:n})})});let t=document.createElement("div");t.className="command-empty",t.textContent="No results found.",t.hidden=!0,this.#n.appendChild(t),this.#e.appendChild(e),this.#e.appendChild(this.#n),this.appendChild(this.#e)}#p(){let e=this.getAttribute("hotkey")||"meta+k";this.#l=w(e,()=>{this.#e.open?this.close():this.open()},{global:!0})}#a=()=>{let e=this.#t.value.toLowerCase().trim(),t=0,n=new Set;this.#s.forEach(({btn:i,header:a})=>{let o=!e||i.dataset.searchText.includes(e);i.hidden=!o,o&&(t++,n.add(a))}),this.#n.querySelectorAll(".command-group-header").forEach(i=>{i.hidden=!n.has(i)});let s=this.#n.querySelector(".command-empty");s&&(s.hidden=t>0),this.#o=-1,t>0&&this.#c(0)};#f=e=>{let t=this.#d();switch(e.key){case"ArrowDown":e.preventDefault(),this.#c(this.#o+1);break;case"ArrowUp":e.preventDefault(),this.#c(this.#o-1);break;case"Enter":e.preventDefault(),this.#o>=0&&t[this.#o]&&t[this.#o].btn.click();break;case"Escape":e.preventDefault(),this.close();break}};#d(){return this.#s.filter(({btn:e})=>!e.hidden)}#c(e){let t=this.#d();if(t.length===0)return;t.forEach(({btn:s})=>s.removeAttribute("data-active")),e<0&&(e=t.length-1),e>=t.length&&(e=0),this.#o=e;let{btn:n}=t[e];n.setAttribute("data-active",""),n.scrollIntoView({block:"nearest"})}#b(e){this.close(),this.dispatchEvent(new CustomEvent("command-palette:select",{bubbles:!0,detail:{value:e}}))}#y(){this.listen(document,"vb:command-registry-change",this.#g)}#g=()=>{this.#e?.open&&(this.#u(),this.#a())};#u(){if(!this.hasAttribute("discover"))return;let{getRegisteredCommands:e,scanAutoDiscoverable:t}=window.__commandRegistry||{};if(!e)return;this.#s=this.#s.filter(i=>!i.discovered),this.#i.forEach(i=>i.remove()),this.#i=[];let n=this.#n.querySelector(".command-empty"),s=e();for(let[i,a]of s){let o=document.createElement("div");o.className="command-group-header",o.textContent=i,o.setAttribute("role","presentation"),this.#n.insertBefore(o,n),this.#i.push(o);for(let c of a){if(this.contains(c.element))continue;let l=this.#h(c.label,c.icon,c.shortcut);l.dataset.value=`__discovered:${c.label}`,l.addEventListener("click",()=>{this.close(),c.element.click()}),this.#n.insertBefore(l,n),this.#s.push({btn:l,header:o,group:null,discovered:!0})}}if(this.getAttribute("discover")==="auto"&&t){let i=t(),a=new Map;for(let o of i){let c=a.get(o.group)||[];c.push(o),a.set(o.group,c)}for(let[o,c]of a){let l=document.createElement("div");l.className="command-group-header",l.textContent=o,l.setAttribute("role","presentation"),this.#n.insertBefore(l,n),this.#i.push(l);for(let u of c){if(this.contains(u.element))continue;let d=this.#h(u.label,u.icon,u.shortcut);d.dataset.value=`__auto:${u.label}`,d.dataset.auto="",d.addEventListener("click",()=>{this.close(),u.action?u.action():u.element.click()}),this.#n.insertBefore(d,n),this.#s.push({btn:d,header:l,group:null,discovered:!0})}}}}#h(e,t,n){let s=document.createElement("button");if(s.className="command-option",s.setAttribute("role","option"),s.dataset.searchText=e.toLowerCase(),t){let a=document.createElement("span");a.className="command-icon";let o=document.createElement("icon-wc");o.setAttribute("name",t),a.appendChild(o),s.appendChild(a)}let i=document.createElement("span");if(i.className="command-label",i.textContent=e,s.appendChild(i),n){let a=document.createElement("kbd");a.className="command-kbd",a.textContent=b(n),s.appendChild(a)}return s}open(){this.#e.open||(this.#u(),this.#e.showModal(),this.#t.value="",this.#a(),this.#t.focus(),this.dispatchEvent(new CustomEvent("command-palette:open",{bubbles:!0})))}close(){this.#e.open&&(this.#e.close(),this.dispatchEvent(new CustomEvent("command-palette:close",{bubbles:!0})))}get isOpen(){return this.#e?.open??!1}},g=class extends HTMLElement{},E=class extends HTMLElement{};m("command-palette",y);m("command-group",g);m("command-item",E);export{y as CommandPalette};
2
2
  //# sourceMappingURL=command-palette.js.map
@@ -0,0 +1,60 @@
1
+ var ct=window.matchMedia("(prefers-reduced-motion: reduce)");var ne=new Map;function R(n,e,t={}){let s=t.priority??10,r={impl:e,bundle:t.bundle,contract:t.contract,priority:s},i=ne.get(n);if(customElements.get(n)){if(!i||i.priority>=s){i&&i.priority===s&&i.impl!==e&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${i.bundle}" (priority ${i.priority}). Skipping "${t.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> defined by "${i.bundle}" cannot be replaced (customElements.define is permanent). "${t.bundle}" has higher priority but arrived late.`);return}if(i&&i.priority>=s){i.priority===s&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${i.bundle}". Skipping "${t.bundle}" (first wins at equal priority).`);return}ne.set(n,r),customElements.define(n,e)}var v=class extends HTMLElement{#e=[];#t;connectedCallback(){this.hasAttribute("data-upgraded")||this.setup()!==!1&&(this.setAttribute("data-upgraded",""),queueMicrotask(()=>{this.dispatchEvent(new CustomEvent(`${this.localName}:upgraded`,{bubbles:!0}))}))}disconnectedCallback(){for(let e of this.#e)e();this.#e=[],this.removeAttribute("data-upgraded"),this.teardown()}listen(e,t,s,r){e.addEventListener(t,s,r),this.#e.push(()=>e.removeEventListener(t,s,r))}setup(){}teardown(){}setState(e,t){this.#t||(this.#t=this.attachInternals());let s=this.#t.states;try{t?s.add(e):s.delete(e)}catch{let r=`--${e}`;t?s.add(r):s.delete(r)}}_adoptInternals(e){this.#t||(this.#t=e)}};function Q(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var A=Q();function ue(n){A=n}var S={exec:()=>null};function u(n,e=""){let t=typeof n=="string"?n:n.source,s={replace:(r,i)=>{let l=typeof i=="string"?i:i.source;return l=l.replace(b.caret,"$1"),t=t.replace(r,l),s},getRegex:()=>new RegExp(t,e)};return s}var Se=(()=>{try{return!!new RegExp("(?<=1)(?<!1)")}catch{return!1}})(),b={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] +\S/,listReplaceTask:/^\[[ xX]\] +/,listTaskCheckbox:/\[[ xX]\]/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:n=>new RegExp(`^( {0,3}${n})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}#`),htmlBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}<(?:[a-z].*>|!--)`,"i"),blockquoteBeginRegex:n=>new RegExp(`^ {0,${Math.min(3,n-1)}}>`)},$e=/^(?:[ \t]*(?:\n|$))+/,Ae=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Re=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,_=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,Te=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,j=/ {0,3}(?:[*+-]|\d{1,9}[.)])/,pe=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,de=u(pe).replace(/bull/g,j).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Ee=u(pe).replace(/bull/g,j).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),V=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Ce=/^[^\n]+/,F=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,ze=u(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",F).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Pe=u(/^(bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,j).getRegex(),M="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",G=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,_e=u("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",G).replace("tag",M).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),ge=u(V).replace("hr",_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",M).getRegex(),qe=u(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",ge).getRegex(),K={blockquote:qe,code:Ae,def:ze,fences:Re,heading:Te,hr:_,html:_e,lheading:de,list:Pe,newline:$e,paragraph:ge,table:S,text:Ce},ie=u("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",M).getRegex(),Le={...K,lheading:Ee,table:ie,paragraph:u(V).replace("hr",_).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",ie).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)])[ \\t]").replace("html","</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag",M).getRegex()},Ie={...K,html:u(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",G).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:S,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:u(V).replace("hr",_).replace("heading",` *#{1,6} *[^
2
+ ]`).replace("lheading",de).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Be=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,Me=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ke=/^( {2,}|\\)\n(?!\s*$)/,Ne=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,T=/[\p{P}\p{S}]/u,N=/[\s\p{P}\p{S}]/u,W=/[^\s\p{P}\p{S}]/u,De=u(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,N).getRegex(),fe=/(?!~)[\p{P}\p{S}]/u,Ze=/(?!~)[\s\p{P}\p{S}]/u,Oe=/(?:[^\s\p{P}\p{S}]|~)/u,He=u(/link|precode-code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?<a>`+)[^`]+\k<a>(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("precode-",Se?"(?<!`)()":"(^^|[^`])").replace("code",/(?<b>`+)[^`]+\k<b>(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),be=/^(?:\*+(?:((?!\*)punct)|([^\s*]))?)|^_+(?:((?!_)punct)|([^\s_]))?/,Qe=u(be,"u").replace(/punct/g,T).getRegex(),je=u(be,"u").replace(/punct/g,fe).getRegex(),me="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Ve=u(me,"gu").replace(/notPunctSpace/g,W).replace(/punctSpace/g,N).replace(/punct/g,T).getRegex(),Fe=u(me,"gu").replace(/notPunctSpace/g,Oe).replace(/punctSpace/g,Ze).replace(/punct/g,fe).getRegex(),Ge=u("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,W).replace(/punctSpace/g,N).replace(/punct/g,T).getRegex(),Ke=u(/^~~?(?:((?!~)punct)|[^\s~])/,"u").replace(/punct/g,T).getRegex(),We="^[^~]+(?=[^~])|(?!~)punct(~~?)(?=[\\s]|$)|notPunctSpace(~~?)(?!~)(?=punctSpace|$)|(?!~)punctSpace(~~?)(?=notPunctSpace)|[\\s](~~?)(?!~)(?=punct)|(?!~)punct(~~?)(?!~)(?=punct)|notPunctSpace(~~?)(?=notPunctSpace)",Xe=u(We,"gu").replace(/notPunctSpace/g,W).replace(/punctSpace/g,N).replace(/punct/g,T).getRegex(),Ue=u(/\\(punct)/,"gu").replace(/punct/g,T).getRegex(),Je=u(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Ye=u(G).replace("(?:-->|$)","-->").getRegex(),et=u("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment",Ye).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),L=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+(?!`)[^`]*?`+(?!`)|``+(?=\])|[^\[\]\\`])*?/,tt=u(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]+(?:\n[ \t]*)?|\n[ \t]*)(title))?\s*\)/).replace("label",L).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),xe=u(/^!?\[(label)\]\[(ref)\]/).replace("label",L).replace("ref",F).getRegex(),we=u(/^!?\[(ref)\](?:\[\])?/).replace("ref",F).getRegex(),rt=u("reflink|nolink(?!\\()","g").replace("reflink",xe).replace("nolink",we).getRegex(),le=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,X={_backpedal:S,anyPunctuation:Ue,autolink:Je,blockSkip:He,br:ke,code:Me,del:S,delLDelim:S,delRDelim:S,emStrongLDelim:Qe,emStrongRDelimAst:Ve,emStrongRDelimUnd:Ge,escape:Be,link:tt,nolink:we,punctuation:De,reflink:xe,reflinkSearch:rt,tag:et,text:Ne,url:S},st={...X,link:u(/^!?\[(label)\]\((.*?)\)/).replace("label",L).getRegex(),reflink:u(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",L).getRegex()},Z={...X,emStrongRDelimAst:Fe,emStrongLDelim:je,delLDelim:Ke,delRDelim:Xe,url:u(/^((?:protocol):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/).replace("protocol",le).replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\[\s\S]|[^\\])*?(?:\\[\s\S]|[^\s~\\]))\1(?=[^~]|$)/,text:u(/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|protocol:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/).replace("protocol",le).getRegex()},nt={...Z,br:u(ke).replace("{2,}","*").getRegex(),text:u(Z.text).replace("\\b_","\\b_| {2,}\\n").replace(/\{2,\}/g,"*").getRegex()},q={normal:K,gfm:Le,pedantic:Ie},C={normal:X,gfm:Z,breaks:nt,pedantic:st},it={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"},ae=n=>it[n];function w(n,e){if(e){if(b.escapeTest.test(n))return n.replace(b.escapeReplace,ae)}else if(b.escapeTestNoEncode.test(n))return n.replace(b.escapeReplaceNoEncode,ae);return n}function oe(n){try{n=encodeURI(n).replace(b.percentDecode,"%")}catch{return null}return n}function he(n,e){let t=n.replace(b.findPipe,(i,l,o)=>{let a=!1,c=l;for(;--c>=0&&o[c]==="\\";)a=!a;return a?"|":" |"}),s=t.split(b.splitPipe),r=0;if(s[0].trim()||s.shift(),s.length>0&&!s.at(-1)?.trim()&&s.pop(),e)if(s.length>e)s.splice(e);else for(;s.length<e;)s.push("");for(;r<s.length;r++)s[r]=s[r].trim().replace(b.slashPipe,"|");return s}function z(n,e,t){let s=n.length;if(s===0)return"";let r=0;for(;r<s;){let i=n.charAt(s-r-1);if(i===e&&!t)r++;else if(i!==e&&t)r++;else break}return n.slice(0,s-r)}function lt(n,e){if(n.indexOf(e[1])===-1)return-1;let t=0;for(let s=0;s<n.length;s++)if(n[s]==="\\")s++;else if(n[s]===e[0])t++;else if(n[s]===e[1]&&(t--,t<0))return s;return t>0?-2:-1}function at(n,e=0){let t=e,s="";for(let r of n)if(r===" "){let i=4-t%4;s+=" ".repeat(i),t+=i}else s+=r,t++;return s}function ce(n,e,t,s,r){let i=e.href,l=e.title||null,o=n[1].replace(r.other.outputLinkReplace,"$1");s.state.inLink=!0;let a={type:n[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:l,text:o,tokens:s.inlineTokens(o)};return s.state.inLink=!1,a}function ot(n,e,t){let s=n.match(t.other.indentCodeCompensation);if(s===null)return e;let r=s[1];return e.split(`
3
+ `).map(i=>{let l=i.match(t.other.beginningSpace);if(l===null)return i;let[o]=l;return o.length>=r.length?i.slice(r.length):i}).join(`
4
+ `)}var I=class{options;rules;lexer;constructor(n){this.options=n||A}space(n){let e=this.rules.block.newline.exec(n);if(e&&e[0].length>0)return{type:"space",raw:e[0]}}code(n){let e=this.rules.block.code.exec(n);if(e){let t=e[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:e[0],codeBlockStyle:"indented",text:this.options.pedantic?t:z(t,`
5
+ `)}}}fences(n){let e=this.rules.block.fences.exec(n);if(e){let t=e[0],s=ot(t,e[3]||"",this.rules);return{type:"code",raw:t,lang:e[2]?e[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):e[2],text:s}}}heading(n){let e=this.rules.block.heading.exec(n);if(e){let t=e[2].trim();if(this.rules.other.endingHash.test(t)){let s=z(t,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(t=s.trim())}return{type:"heading",raw:e[0],depth:e[1].length,text:t,tokens:this.lexer.inline(t)}}}hr(n){let e=this.rules.block.hr.exec(n);if(e)return{type:"hr",raw:z(e[0],`
6
+ `)}}blockquote(n){let e=this.rules.block.blockquote.exec(n);if(e){let t=z(e[0],`
7
+ `).split(`
8
+ `),s="",r="",i=[];for(;t.length>0;){let l=!1,o=[],a;for(a=0;a<t.length;a++)if(this.rules.other.blockquoteStart.test(t[a]))o.push(t[a]),l=!0;else if(!l)o.push(t[a]);else break;t=t.slice(a);let c=o.join(`
9
+ `),h=c.replace(this.rules.other.blockquoteSetextReplace,`
10
+ $1`).replace(this.rules.other.blockquoteSetextReplace2,"");s=s?`${s}
11
+ ${c}`:c,r=r?`${r}
12
+ ${h}`:h;let d=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTokens(h,i,!0),this.lexer.state.top=d,t.length===0)break;let p=i.at(-1);if(p?.type==="code")break;if(p?.type==="blockquote"){let f=p,k=f.raw+`
13
+ `+t.join(`
14
+ `),y=this.blockquote(k);i[i.length-1]=y,s=s.substring(0,s.length-f.raw.length)+y.raw,r=r.substring(0,r.length-f.text.length)+y.text;break}else if(p?.type==="list"){let f=p,k=f.raw+`
15
+ `+t.join(`
16
+ `),y=this.list(k);i[i.length-1]=y,s=s.substring(0,s.length-p.raw.length)+y.raw,r=r.substring(0,r.length-f.raw.length)+y.raw,t=k.substring(i.at(-1).raw.length).split(`
17
+ `);continue}}return{type:"blockquote",raw:s,tokens:i,text:r}}}list(n){let e=this.rules.block.list.exec(n);if(e){let t=e[1].trim(),s=t.length>1,r={type:"list",raw:"",ordered:s,start:s?+t.slice(0,-1):"",loose:!1,items:[]};t=s?`\\d{1,9}\\${t.slice(-1)}`:`\\${t}`,this.options.pedantic&&(t=s?t:"[*+-]");let i=this.rules.other.listItemRegex(t),l=!1;for(;n;){let a=!1,c="",h="";if(!(e=i.exec(n))||this.rules.block.hr.test(n))break;c=e[0],n=n.substring(c.length);let d=at(e[2].split(`
18
+ `,1)[0],e[1].length),p=n.split(`
19
+ `,1)[0],f=!d.trim(),k=0;if(this.options.pedantic?(k=2,h=d.trimStart()):f?k=e[1].length+1:(k=d.search(this.rules.other.nonSpaceChar),k=k>4?1:k,h=d.slice(k),k+=e[1].length),f&&this.rules.other.blankLine.test(p)&&(c+=p+`
20
+ `,n=n.substring(p.length+1),a=!0),!a){let y=this.rules.other.nextBulletRegex(k),te=this.rules.other.hrRegex(k),re=this.rules.other.fencesBeginRegex(k),se=this.rules.other.headingBeginRegex(k),ye=this.rules.other.htmlBeginRegex(k),ve=this.rules.other.blockquoteBeginRegex(k);for(;n;){let D=n.split(`
21
+ `,1)[0],E;if(p=D,this.options.pedantic?(p=p.replace(this.rules.other.listReplaceNesting," "),E=p):E=p.replace(this.rules.other.tabCharGlobal," "),re.test(p)||se.test(p)||ye.test(p)||ve.test(p)||y.test(p)||te.test(p))break;if(E.search(this.rules.other.nonSpaceChar)>=k||!p.trim())h+=`
22
+ `+E.slice(k);else{if(f||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||re.test(d)||se.test(d)||te.test(d))break;h+=`
23
+ `+p}f=!p.trim(),c+=D+`
24
+ `,n=n.substring(D.length+1),d=E.slice(k)}}r.loose||(l?r.loose=!0:this.rules.other.doubleBlankLine.test(c)&&(l=!0)),r.items.push({type:"list_item",raw:c,task:!!this.options.gfm&&this.rules.other.listIsTask.test(h),loose:!1,text:h,tokens:[]}),r.raw+=c}let o=r.items.at(-1);if(o)o.raw=o.raw.trimEnd(),o.text=o.text.trimEnd();else return;r.raw=r.raw.trimEnd();for(let a of r.items){if(this.lexer.state.top=!1,a.tokens=this.lexer.blockTokens(a.text,[]),a.task){if(a.text=a.text.replace(this.rules.other.listReplaceTask,""),a.tokens[0]?.type==="text"||a.tokens[0]?.type==="paragraph"){a.tokens[0].raw=a.tokens[0].raw.replace(this.rules.other.listReplaceTask,""),a.tokens[0].text=a.tokens[0].text.replace(this.rules.other.listReplaceTask,"");for(let h=this.lexer.inlineQueue.length-1;h>=0;h--)if(this.rules.other.listIsTask.test(this.lexer.inlineQueue[h].src)){this.lexer.inlineQueue[h].src=this.lexer.inlineQueue[h].src.replace(this.rules.other.listReplaceTask,"");break}}let c=this.rules.other.listTaskCheckbox.exec(a.raw);if(c){let h={type:"checkbox",raw:c[0]+" ",checked:c[0]!=="[ ]"};a.checked=h.checked,r.loose?a.tokens[0]&&["paragraph","text"].includes(a.tokens[0].type)&&"tokens"in a.tokens[0]&&a.tokens[0].tokens?(a.tokens[0].raw=h.raw+a.tokens[0].raw,a.tokens[0].text=h.raw+a.tokens[0].text,a.tokens[0].tokens.unshift(h)):a.tokens.unshift({type:"paragraph",raw:h.raw,text:h.raw,tokens:[h]}):a.tokens.unshift(h)}}if(!r.loose){let c=a.tokens.filter(d=>d.type==="space"),h=c.length>0&&c.some(d=>this.rules.other.anyLine.test(d.raw));r.loose=h}}if(r.loose)for(let a of r.items){a.loose=!0;for(let c of a.tokens)c.type==="text"&&(c.type="paragraph")}return r}}html(n){let e=this.rules.block.html.exec(n);if(e)return{type:"html",block:!0,raw:e[0],pre:e[1]==="pre"||e[1]==="script"||e[1]==="style",text:e[0]}}def(n){let e=this.rules.block.def.exec(n);if(e){let t=e[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal," "),s=e[2]?e[2].replace(this.rules.other.hrefBrackets,"$1").replace(this.rules.inline.anyPunctuation,"$1"):"",r=e[3]?e[3].substring(1,e[3].length-1).replace(this.rules.inline.anyPunctuation,"$1"):e[3];return{type:"def",tag:t,raw:e[0],href:s,title:r}}}table(n){let e=this.rules.block.table.exec(n);if(!e||!this.rules.other.tableDelimiter.test(e[2]))return;let t=he(e[1]),s=e[2].replace(this.rules.other.tableAlignChars,"").split("|"),r=e[3]?.trim()?e[3].replace(this.rules.other.tableRowBlankLine,"").split(`
25
+ `):[],i={type:"table",raw:e[0],header:[],align:[],rows:[]};if(t.length===s.length){for(let l of s)this.rules.other.tableAlignRight.test(l)?i.align.push("right"):this.rules.other.tableAlignCenter.test(l)?i.align.push("center"):this.rules.other.tableAlignLeft.test(l)?i.align.push("left"):i.align.push(null);for(let l=0;l<t.length;l++)i.header.push({text:t[l],tokens:this.lexer.inline(t[l]),header:!0,align:i.align[l]});for(let l of r)i.rows.push(he(l,i.header.length).map((o,a)=>({text:o,tokens:this.lexer.inline(o),header:!1,align:i.align[a]})));return i}}lheading(n){let e=this.rules.block.lheading.exec(n);if(e){let t=e[1].trim();return{type:"heading",raw:e[0],depth:e[2].charAt(0)==="="?1:2,text:t,tokens:this.lexer.inline(t)}}}paragraph(n){let e=this.rules.block.paragraph.exec(n);if(e){let t=e[1].charAt(e[1].length-1)===`
26
+ `?e[1].slice(0,-1):e[1];return{type:"paragraph",raw:e[0],text:t,tokens:this.lexer.inline(t)}}}text(n){let e=this.rules.block.text.exec(n);if(e)return{type:"text",raw:e[0],text:e[0],tokens:this.lexer.inline(e[0])}}escape(n){let e=this.rules.inline.escape.exec(n);if(e)return{type:"escape",raw:e[0],text:e[1]}}tag(n){let e=this.rules.inline.tag.exec(n);if(e)return!this.lexer.state.inLink&&this.rules.other.startATag.test(e[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(e[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(e[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(e[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:e[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:e[0]}}link(n){let e=this.rules.inline.link.exec(n);if(e){let t=e[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(t)){if(!this.rules.other.endAngleBracket.test(t))return;let i=z(t.slice(0,-1),"\\");if((t.length-i.length)%2===0)return}else{let i=lt(e[2],"()");if(i===-2)return;if(i>-1){let l=(e[0].indexOf("!")===0?5:4)+e[1].length+i;e[2]=e[2].substring(0,i),e[0]=e[0].substring(0,l).trim(),e[3]=""}}let s=e[2],r="";if(this.options.pedantic){let i=this.rules.other.pedanticHrefTitle.exec(s);i&&(s=i[1],r=i[3])}else r=e[3]?e[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(t)?s=s.slice(1):s=s.slice(1,-1)),ce(e,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},e[0],this.lexer,this.rules)}}reflink(n,e){let t;if((t=this.rules.inline.reflink.exec(n))||(t=this.rules.inline.nolink.exec(n))){let s=(t[2]||t[1]).replace(this.rules.other.multipleSpaceGlobal," "),r=e[s.toLowerCase()];if(!r){let i=t[0].charAt(0);return{type:"text",raw:i,text:i}}return ce(t,r,t[0],this.lexer,this.rules)}}emStrong(n,e,t=""){let s=this.rules.inline.emStrongLDelim.exec(n);if(!(!s||!s[1]&&!s[2]&&!s[3]&&!s[4]||s[4]&&t.match(this.rules.other.unicodeAlphaNumeric))&&(!(s[1]||s[3])||!t||this.rules.inline.punctuation.exec(t))){let r=[...s[0]].length-1,i,l,o=r,a=0,c=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,e=e.slice(-1*n.length+r);(s=c.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i)continue;if(l=[...i].length,s[3]||s[4]){o+=l;continue}else if((s[5]||s[6])&&r%3&&!((r+l)%3)){a+=l;continue}if(o-=l,o>0)continue;l=Math.min(l,l+o+a);let h=[...s[0]][0].length,d=n.slice(0,r+s.index+h+l);if(Math.min(r,l)%2){let f=d.slice(1,-1);return{type:"em",raw:d,text:f,tokens:this.lexer.inlineTokens(f)}}let p=d.slice(2,-2);return{type:"strong",raw:d,text:p,tokens:this.lexer.inlineTokens(p)}}}}codespan(n){let e=this.rules.inline.code.exec(n);if(e){let t=e[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(t),r=this.rules.other.startingSpaceChar.test(t)&&this.rules.other.endingSpaceChar.test(t);return s&&r&&(t=t.substring(1,t.length-1)),{type:"codespan",raw:e[0],text:t}}}br(n){let e=this.rules.inline.br.exec(n);if(e)return{type:"br",raw:e[0]}}del(n,e,t=""){let s=this.rules.inline.delLDelim.exec(n);if(s&&(!s[1]||!t||this.rules.inline.punctuation.exec(t))){let r=[...s[0]].length-1,i,l,o=r,a=this.rules.inline.delRDelim;for(a.lastIndex=0,e=e.slice(-1*n.length+r);(s=a.exec(e))!==null;){if(i=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!i||(l=[...i].length,l!==r))continue;if(s[3]||s[4]){o+=l;continue}if(o-=l,o>0)continue;l=Math.min(l,l+o);let c=[...s[0]][0].length,h=n.slice(0,r+s.index+c+l),d=h.slice(r,-r);return{type:"del",raw:h,text:d,tokens:this.lexer.inlineTokens(d)}}}}autolink(n){let e=this.rules.inline.autolink.exec(n);if(e){let t,s;return e[2]==="@"?(t=e[1],s="mailto:"+t):(t=e[1],s=t),{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}url(n){let e;if(e=this.rules.inline.url.exec(n)){let t,s;if(e[2]==="@")t=e[0],s="mailto:"+t;else{let r;do r=e[0],e[0]=this.rules.inline._backpedal.exec(e[0])?.[0]??"";while(r!==e[0]);t=e[0],e[1]==="www."?s="http://"+e[0]:s=e[0]}return{type:"link",raw:e[0],text:t,href:s,tokens:[{type:"text",raw:t,text:t}]}}}inlineText(n){let e=this.rules.inline.text.exec(n);if(e){let t=this.lexer.state.inRawBlock;return{type:"text",raw:e[0],text:e[0],escaped:t}}}},m=class O{tokens;options;state;inlineQueue;tokenizer;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||A,this.options.tokenizer=this.options.tokenizer||new I,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:b,block:q.normal,inline:C.normal};this.options.pedantic?(t.block=q.pedantic,t.inline=C.pedantic):this.options.gfm&&(t.block=q.gfm,this.options.breaks?t.inline=C.breaks:t.inline=C.gfm),this.tokenizer.rules=t}static get rules(){return{block:q,inline:C}}static lex(e,t){return new O(t).lex(e)}static lexInline(e,t){return new O(t).inlineTokens(e)}lex(e){e=e.replace(b.carriageReturn,`
27
+ `),this.blockTokens(e,this.tokens);for(let t=0;t<this.inlineQueue.length;t++){let s=this.inlineQueue[t];this.inlineTokens(s.src,s.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],s=!1){for(this.tokenizer.lexer=this,this.options.pedantic&&(e=e.replace(b.tabCharGlobal," ").replace(b.spaceLine,""));e;){let r;if(this.options.extensions?.block?.some(l=>(r=l.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let l=t.at(-1);r.raw.length===1&&l!==void 0?l.raw+=`
28
+ `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let l=t.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
29
+ `)?"":`
30
+ `)+r.raw,l.text+=`
31
+ `+r.text,this.inlineQueue.at(-1).src=l.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let l=t.at(-1);l?.type==="paragraph"||l?.type==="text"?(l.raw+=(l.raw.endsWith(`
32
+ `)?"":`
33
+ `)+r.raw,l.text+=`
34
+ `+r.raw,this.inlineQueue.at(-1).src=l.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let l=1/0,o=e.slice(1),a;this.options.extensions.startBlock.forEach(c=>{a=c.call({lexer:this},o),typeof a=="number"&&a>=0&&(l=Math.min(l,a))}),l<1/0&&l>=0&&(i=e.substring(0,l+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let l=t.at(-1);s&&l?.type==="paragraph"?(l.raw+=(l.raw.endsWith(`
35
+ `)?"":`
36
+ `)+r.raw,l.text+=`
37
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):t.push(r),s=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let l=t.at(-1);l?.type==="text"?(l.raw+=(l.raw.endsWith(`
38
+ `)?"":`
39
+ `)+r.raw,l.text+=`
40
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=l.text):t.push(r);continue}if(e){let l="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(l);break}else throw new Error(l)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){this.tokenizer.lexer=this;let s=e,r=null;if(this.tokens.links){let a=Object.keys(this.tokens.links);if(a.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(s))!==null;)a.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(s=s.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+s.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(s))!==null;)s=s.slice(0,r.index)+"++"+s.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);let i;for(;(r=this.tokenizer.rules.inline.blockSkip.exec(s))!==null;)i=r[2]?r[2].length:0,s=s.slice(0,r.index+i)+"["+"a".repeat(r[0].length-i-2)+"]"+s.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);s=this.options.hooks?.emStrongMask?.call({lexer:this},s)??s;let l=!1,o="";for(;e;){l||(o=""),l=!1;let a;if(this.options.extensions?.inline?.some(h=>(a=h.call({lexer:this},e,t))?(e=e.substring(a.raw.length),t.push(a),!0):!1))continue;if(a=this.tokenizer.escape(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.tag(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.link(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(a.raw.length);let h=t.at(-1);a.type==="text"&&h?.type==="text"?(h.raw+=a.raw,h.text+=a.text):t.push(a);continue}if(a=this.tokenizer.emStrong(e,s,o)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.codespan(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.br(e)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.del(e,s,o)){e=e.substring(a.raw.length),t.push(a);continue}if(a=this.tokenizer.autolink(e)){e=e.substring(a.raw.length),t.push(a);continue}if(!this.state.inLink&&(a=this.tokenizer.url(e))){e=e.substring(a.raw.length),t.push(a);continue}let c=e;if(this.options.extensions?.startInline){let h=1/0,d=e.slice(1),p;this.options.extensions.startInline.forEach(f=>{p=f.call({lexer:this},d),typeof p=="number"&&p>=0&&(h=Math.min(h,p))}),h<1/0&&h>=0&&(c=e.substring(0,h+1))}if(a=this.tokenizer.inlineText(c)){e=e.substring(a.raw.length),a.raw.slice(-1)!=="_"&&(o=a.raw.slice(-1)),l=!0;let h=t.at(-1);h?.type==="text"?(h.raw+=a.raw,h.text+=a.text):t.push(a);continue}if(e){let h="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(h);break}else throw new Error(h)}}return t}},B=class{options;parser;constructor(n){this.options=n||A}space(n){return""}code({text:n,lang:e,escaped:t}){let s=(e||"").match(b.notSpaceStart)?.[0],r=n.replace(b.endingNewline,"")+`
41
+ `;return s?'<pre><code class="language-'+w(s)+'">'+(t?r:w(r,!0))+`</code></pre>
42
+ `:"<pre><code>"+(t?r:w(r,!0))+`</code></pre>
43
+ `}blockquote({tokens:n}){return`<blockquote>
44
+ ${this.parser.parse(n)}</blockquote>
45
+ `}html({text:n}){return n}def(n){return""}heading({tokens:n,depth:e}){return`<h${e}>${this.parser.parseInline(n)}</h${e}>
46
+ `}hr(n){return`<hr>
47
+ `}list(n){let e=n.ordered,t=n.start,s="";for(let l=0;l<n.items.length;l++){let o=n.items[l];s+=this.listitem(o)}let r=e?"ol":"ul",i=e&&t!==1?' start="'+t+'"':"";return"<"+r+i+`>
48
+ `+s+"</"+r+`>
49
+ `}listitem(n){return`<li>${this.parser.parse(n.tokens)}</li>
50
+ `}checkbox({checked:n}){return"<input "+(n?'checked="" ':"")+'disabled="" type="checkbox"> '}paragraph({tokens:n}){return`<p>${this.parser.parseInline(n)}</p>
51
+ `}table(n){let e="",t="";for(let r=0;r<n.header.length;r++)t+=this.tablecell(n.header[r]);e+=this.tablerow({text:t});let s="";for(let r=0;r<n.rows.length;r++){let i=n.rows[r];t="";for(let l=0;l<i.length;l++)t+=this.tablecell(i[l]);s+=this.tablerow({text:t})}return s&&(s=`<tbody>${s}</tbody>`),`<table>
52
+ <thead>
53
+ `+e+`</thead>
54
+ `+s+`</table>
55
+ `}tablerow({text:n}){return`<tr>
56
+ ${n}</tr>
57
+ `}tablecell(n){let e=this.parser.parseInline(n.tokens),t=n.header?"th":"td";return(n.align?`<${t} align="${n.align}">`:`<${t}>`)+e+`</${t}>
58
+ `}strong({tokens:n}){return`<strong>${this.parser.parseInline(n)}</strong>`}em({tokens:n}){return`<em>${this.parser.parseInline(n)}</em>`}codespan({text:n}){return`<code>${w(n,!0)}</code>`}br(n){return"<br>"}del({tokens:n}){return`<del>${this.parser.parseInline(n)}</del>`}link({href:n,title:e,tokens:t}){let s=this.parser.parseInline(t),r=oe(n);if(r===null)return s;n=r;let i='<a href="'+n+'"';return e&&(i+=' title="'+w(e)+'"'),i+=">"+s+"</a>",i}image({href:n,title:e,text:t,tokens:s}){s&&(t=this.parser.parseInline(s,this.parser.textRenderer));let r=oe(n);if(r===null)return w(t);n=r;let i=`<img src="${n}" alt="${w(t)}"`;return e&&(i+=` title="${w(e)}"`),i+=">",i}text(n){return"tokens"in n&&n.tokens?this.parser.parseInline(n.tokens):"escaped"in n&&n.escaped?n.text:w(n.text)}},U=class{strong({text:n}){return n}em({text:n}){return n}codespan({text:n}){return n}del({text:n}){return n}html({text:n}){return n}text({text:n}){return n}link({text:n}){return""+n}image({text:n}){return""+n}br(){return""}checkbox({raw:n}){return n}},x=class H{options;renderer;textRenderer;constructor(e){this.options=e||A,this.options.renderer=this.options.renderer||new B,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new U}static parse(e,t){return new H(t).parse(e)}static parseInline(e,t){return new H(t).parseInline(e)}parse(e){this.renderer.parser=this;let t="";for(let s=0;s<e.length;s++){let r=e[s];if(this.options.extensions?.renderers?.[r.type]){let l=r,o=this.options.extensions.renderers[l.type].call({parser:this},l);if(o!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(l.type)){t+=o||"";continue}}let i=r;switch(i.type){case"space":{t+=this.renderer.space(i);break}case"hr":{t+=this.renderer.hr(i);break}case"heading":{t+=this.renderer.heading(i);break}case"code":{t+=this.renderer.code(i);break}case"table":{t+=this.renderer.table(i);break}case"blockquote":{t+=this.renderer.blockquote(i);break}case"list":{t+=this.renderer.list(i);break}case"checkbox":{t+=this.renderer.checkbox(i);break}case"html":{t+=this.renderer.html(i);break}case"def":{t+=this.renderer.def(i);break}case"paragraph":{t+=this.renderer.paragraph(i);break}case"text":{t+=this.renderer.text(i);break}default:{let l='Token with "'+i.type+'" type was not found.';if(this.options.silent)return console.error(l),"";throw new Error(l)}}}return t}parseInline(e,t=this.renderer){this.renderer.parser=this;let s="";for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let o=this.options.extensions.renderers[i.type].call({parser:this},i);if(o!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(i.type)){s+=o||"";continue}}let l=i;switch(l.type){case"escape":{s+=t.text(l);break}case"html":{s+=t.html(l);break}case"link":{s+=t.link(l);break}case"image":{s+=t.image(l);break}case"checkbox":{s+=t.checkbox(l);break}case"strong":{s+=t.strong(l);break}case"em":{s+=t.em(l);break}case"codespan":{s+=t.codespan(l);break}case"br":{s+=t.br(l);break}case"del":{s+=t.del(l);break}case"text":{s+=t.text(l);break}default:{let o='Token with "'+l.type+'" type was not found.';if(this.options.silent)return console.error(o),"";throw new Error(o)}}}return s}},P=class{options;block;constructor(n){this.options=n||A}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(n){return n}postprocess(n){return n}processAllTokens(n){return n}emStrongMask(n){return n}provideLexer(n=this.block){return n?m.lex:m.lexInline}provideParser(n=this.block){return n?x.parse:x.parseInline}},ht=class{defaults=Q();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=x;Renderer=B;TextRenderer=U;Lexer=m;Tokenizer=I;Hooks=P;constructor(...n){this.use(...n)}walkTokens(n,e){let t=[];for(let s of n)switch(t=t.concat(e.call(this,s)),s.type){case"table":{let r=s;for(let i of r.header)t=t.concat(this.walkTokens(i.tokens,e));for(let i of r.rows)for(let l of i)t=t.concat(this.walkTokens(l.tokens,e));break}case"list":{let r=s;t=t.concat(this.walkTokens(r.items,e));break}default:{let r=s;this.defaults.extensions?.childTokens?.[r.type]?this.defaults.extensions.childTokens[r.type].forEach(i=>{let l=r[i].flat(1/0);t=t.concat(this.walkTokens(l,e))}):r.tokens&&(t=t.concat(this.walkTokens(r.tokens,e)))}}return t}use(...n){let e=this.defaults.extensions||{renderers:{},childTokens:{}};return n.forEach(t=>{let s={...t};if(s.async=this.defaults.async||s.async||!1,t.extensions&&(t.extensions.forEach(r=>{if(!r.name)throw new Error("extension name required");if("renderer"in r){let i=e.renderers[r.name];i?e.renderers[r.name]=function(...l){let o=r.renderer.apply(this,l);return o===!1&&(o=i.apply(this,l)),o}:e.renderers[r.name]=r.renderer}if("tokenizer"in r){if(!r.level||r.level!=="block"&&r.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let i=e[r.level];i?i.unshift(r.tokenizer):e[r.level]=[r.tokenizer],r.start&&(r.level==="block"?e.startBlock?e.startBlock.push(r.start):e.startBlock=[r.start]:r.level==="inline"&&(e.startInline?e.startInline.push(r.start):e.startInline=[r.start]))}"childTokens"in r&&r.childTokens&&(e.childTokens[r.name]=r.childTokens)}),s.extensions=e),t.renderer){let r=this.defaults.renderer||new B(this.defaults);for(let i in t.renderer){if(!(i in r))throw new Error(`renderer '${i}' does not exist`);if(["options","parser"].includes(i))continue;let l=i,o=t.renderer[l],a=r[l];r[l]=(...c)=>{let h=o.apply(r,c);return h===!1&&(h=a.apply(r,c)),h||""}}s.renderer=r}if(t.tokenizer){let r=this.defaults.tokenizer||new I(this.defaults);for(let i in t.tokenizer){if(!(i in r))throw new Error(`tokenizer '${i}' does not exist`);if(["options","rules","lexer"].includes(i))continue;let l=i,o=t.tokenizer[l],a=r[l];r[l]=(...c)=>{let h=o.apply(r,c);return h===!1&&(h=a.apply(r,c)),h}}s.tokenizer=r}if(t.hooks){let r=this.defaults.hooks||new P;for(let i in t.hooks){if(!(i in r))throw new Error(`hook '${i}' does not exist`);if(["options","block"].includes(i))continue;let l=i,o=t.hooks[l],a=r[l];P.passThroughHooks.has(i)?r[l]=c=>{if(this.defaults.async&&P.passThroughHooksRespectAsync.has(i))return(async()=>{let d=await o.call(r,c);return a.call(r,d)})();let h=o.call(r,c);return a.call(r,h)}:r[l]=(...c)=>{if(this.defaults.async)return(async()=>{let d=await o.apply(r,c);return d===!1&&(d=await a.apply(r,c)),d})();let h=o.apply(r,c);return h===!1&&(h=a.apply(r,c)),h}}s.hooks=r}if(t.walkTokens){let r=this.defaults.walkTokens,i=t.walkTokens;s.walkTokens=function(l){let o=[];return o.push(i.call(this,l)),r&&(o=o.concat(r.call(this,l))),o}}this.defaults={...this.defaults,...s}}),this}setOptions(n){return this.defaults={...this.defaults,...n},this}lexer(n,e){return m.lex(n,e??this.defaults)}parser(n,e){return x.parse(n,e??this.defaults)}parseMarkdown(n){return(e,t)=>{let s={...t},r={...this.defaults,...s},i=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&s.async===!1)return i(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof e>"u"||e===null)return i(new Error("marked(): input parameter is undefined or null"));if(typeof e!="string")return i(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(e)+", string expected"));if(r.hooks&&(r.hooks.options=r,r.hooks.block=n),r.async)return(async()=>{let l=r.hooks?await r.hooks.preprocess(e):e,o=await(r.hooks?await r.hooks.provideLexer(n):n?m.lex:m.lexInline)(l,r),a=r.hooks?await r.hooks.processAllTokens(o):o;r.walkTokens&&await Promise.all(this.walkTokens(a,r.walkTokens));let c=await(r.hooks?await r.hooks.provideParser(n):n?x.parse:x.parseInline)(a,r);return r.hooks?await r.hooks.postprocess(c):c})().catch(i);try{r.hooks&&(e=r.hooks.preprocess(e));let l=(r.hooks?r.hooks.provideLexer(n):n?m.lex:m.lexInline)(e,r);r.hooks&&(l=r.hooks.processAllTokens(l)),r.walkTokens&&this.walkTokens(l,r.walkTokens);let o=(r.hooks?r.hooks.provideParser(n):n?x.parse:x.parseInline)(l,r);return r.hooks&&(o=r.hooks.postprocess(o)),o}catch(l){return i(l)}}}onError(n,e){return t=>{if(t.message+=`
59
+ Please report this to https://github.com/markedjs/marked.`,n){let s="<p>An error occurred:</p><pre>"+w(t.message+"",!0)+"</pre>";return e?Promise.resolve(s):s}if(e)return Promise.reject(t);throw t}}},$=new ht;function g(n,e){return $.parse(n,e)}g.options=g.setOptions=function(n){return $.setOptions(n),g.defaults=$.defaults,ue(g.defaults),g};g.getDefaults=Q;g.defaults=A;g.use=function(...n){return $.use(...n),g.defaults=$.defaults,ue(g.defaults),g};g.walkTokens=function(n,e){return $.walkTokens(n,e)};g.parseInline=$.parseInline;g.Parser=x;g.parser=x.parse;g.Renderer=B;g.TextRenderer=U;g.Lexer=m;g.lexer=m.lex;g.Tokenizer=I;g.Hooks=P;g.parse=g;var dt=g.options,gt=g.setOptions,kt=g.use,ft=g.walkTokens,bt=g.parseInline;var mt=x.parse,xt=m.lex;var J=class extends v{#e=null;#t=null;#s=null;#n=null;#i=null;static get observedAttributes(){return["src"]}setup(){this.#l()}teardown(){this.#t?.abort(),this.removeAttribute("data-rendered"),this.removeAttribute("data-loading")}attributeChangedCallback(e,t,s){e==="src"&&s&&t!==s&&this.isConnected&&this.#l()}get parser(){return this.#e}set parser(e){this.#e=typeof e=="function"?e:null}get markdown(){return this.#n??this.#i??""}set markdown(e){let t=e==null?null:String(e);this.#n!==t&&(this.#n=t,this.#l())}async render(){await this.#l()}async reload(){this.getAttribute("src")&&await this.#l()}#r(){if(this.getAttribute("src"))return null;let e=this.querySelector('script[type="text/markdown"]');if(e)return e.textContent;let t=this.querySelector("template[data-md]");if(t)return t.content.textContent;let s=this.querySelector(":scope > pre");return s?s.textContent:null}async#l(){let e=this.getAttribute("src"),t;if(this.removeAttribute("data-rendered"),this.removeAttribute("data-error"),e){this.#t?.abort(),this.#t=new AbortController,this.setAttribute("data-loading",""),this.#a("markdown-viewer:fetch",{src:e});try{let i=await fetch(e,{signal:this.#t.signal});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);t=await i.text()}catch(i){if(i.name==="AbortError")return;this.removeAttribute("data-loading"),this.setAttribute("data-error",""),this.#a("markdown-viewer:error",{error:i.message});return}this.removeAttribute("data-loading")}else this.#n!=null?t=this.#n:t=this.#r();if(t==null)return;this.#i=t;let s;try{s=await(await this.#h())(t)}catch(i){this.setAttribute("data-error",""),this.#a("markdown-viewer:error",{error:i.message});return}this.#s||(this.#s=document.createElement("div"),this.#s.className="md-content",this.#s.setAttribute("part","content"),this.appendChild(this.#s)),this.#s.innerHTML=s,this.#o(),this.setAttribute("data-rendered","");let r=this.getAttribute("ping");if(r&&navigator.sendBeacon?.(r,JSON.stringify({src:e||"inline"})),this.#a("markdown-viewer:rendered",{src:e,node:this.#s}),this.hasAttribute("highlight"))for(let i of this.#s.querySelectorAll('pre > code[class*="language-"]')){let l=i.className.match(/language-(\S+)/)?.[1]||"";this.#a("markdown-viewer:highlight",{node:i,language:l})}}async#h(){return this.#e?this.#e:e=>g.parse(e,{gfm:!0})}#o(){if(!this.#s)return;let e=this.dataset.theme??this.closest("[data-theme]")?.dataset.theme;e&&(this.#s.dataset.theme=e)}#a(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}};R("markdown-viewer",J);var Y=class extends v{#e=null;#t=null;#s=null;#n=null;#i="";#r=null;static get observedAttributes(){return["name","placeholder","rows"]}setup(){this.#l(),this.#h(),this.#a()}teardown(){this.#r!==null&&clearTimeout(this.#r),this.removeAttribute("data-editing")}attributeChangedCallback(e,t,s){!this.#e||t===s||(e==="name"&&(this.#e.name=s||""),e==="placeholder"&&(this.#e.placeholder=s||""),e==="rows"&&(this.#e.rows=parseInt(s,10)||10))}get value(){return this.#e?.value??""}set value(e){if(!this.#e)return;let t=e==null?"":String(e);this.#e.value!==t&&(this.#e.value=t,this.#a(),this.dispatchEvent(new CustomEvent("markdown-editor:change",{detail:{value:t,source:"api"},bubbles:!0})))}get textarea(){return this.#e}#l(){let t=this.querySelector("textarea")?.value||"";this.#s=document.createElement("section"),this.#s.className="md-editor-pane",this.#s.setAttribute("aria-label","Markdown source"),this.#n=document.createElement("section"),this.#n.className="md-preview-pane",this.#n.setAttribute("aria-label","Rendered preview"),this.#n.setAttribute("aria-live","polite"),this.#e=document.createElement("textarea"),this.#e.className="md-editor-input",this.#e.value=t,this.#e.name=this.getAttribute("name")||"",this.#e.placeholder=this.getAttribute("placeholder")||"Write markdown here...",this.#e.rows=parseInt(this.getAttribute("rows")??"",10)||10,this.#e.setAttribute("spellcheck","true"),this.#t=document.createElement("markdown-viewer"),this.hasAttribute("highlight")&&this.#t.setAttribute("highlight","");let s=this.dataset.theme??this.closest("[data-theme]")?.dataset.theme;s&&(this.#t.dataset.theme=s),this.#s.appendChild(this.#e),this.#n.appendChild(this.#t),this.innerHTML="",this.appendChild(this.#s),this.appendChild(this.#n),this.#i=t}#h(){let e=this.#e;e&&(this.listen(e,"input",()=>{this.#c("markdown-editor:input",{value:e.value}),this.#o()}),this.listen(e,"focus",()=>{this.setAttribute("data-editing","")}),this.listen(e,"blur",()=>{this.removeAttribute("data-editing"),e.value!==this.#i&&(this.#i=e.value,this.#c("markdown-editor:change",{value:e.value}))}),this.hasAttribute("data-tab-indent")&&this.listen(e,"keydown",t=>{let s=t;if(s.key==="Tab"&&!s.shiftKey&&!s.ctrlKey&&!s.metaKey){s.preventDefault();let{selectionStart:r,selectionEnd:i}=e;e.setRangeText(" ",r,i,"end"),e.dispatchEvent(new Event("input",{bubbles:!0}))}}))}#o(){this.#r!==null&&clearTimeout(this.#r),this.#r=setTimeout(()=>this.#a(),150)}#a(){if(!this.#t)return;let e=this.#e?.value||"";if(!e.trim()){let s=this.#t.querySelector(".md-content");s&&(s.innerHTML="");return}let t=this.#t.querySelector('script[type="text/markdown"]');t||(t=document.createElement("script"),t.type="text/markdown",this.#t.prepend(t)),t.textContent=e,this.#t.removeAttribute("data-rendered"),this.#t.render?.()}#c(e,t){this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}};R("markdown-editor",Y);var ee=class extends v{static formAssociated=!0;static observedAttributes=["value","disabled","placeholder","submit-label","cancel-label","data-show-cancel"];#e;#t;#s;#n;#i;#r;#l;#h=null;constructor(){super(),this.#e=this.attachInternals(),this._adoptInternals(this.#e)}setup(){let e=[...this.querySelectorAll(':scope > [slot="toolbar"]')],t=this.querySelector(":scope > markdown-editor");if(!t){t=document.createElement("markdown-editor");let r=document.createElement("textarea");this.hasAttribute("placeholder")&&(r.placeholder=this.getAttribute("placeholder")||""),this.hasAttribute("value")&&(r.value=this.getAttribute("value")||""),t.appendChild(r)}this.#t=t,this.#s=document.createElement("div"),this.#s.className="comment-box-actions",this.#n=document.createElement("div"),this.#n.className="comment-box-toolbar",this.#n.setAttribute("role","toolbar"),e.forEach(r=>this.#n.appendChild(r)),this.#s.appendChild(this.#n);let s=document.createElement("div");s.className="comment-box-buttons",this.hasAttribute("data-show-cancel")&&(this.#r=document.createElement("button"),this.#r.type="button",this.#r.className="comment-box-cancel",this.#r.textContent=this.getAttribute("cancel-label")||"Cancel",s.appendChild(this.#r)),this.#i=document.createElement("button"),this.#i.type="button",this.#i.className="comment-box-submit",this.#i.textContent=this.getAttribute("submit-label")||"Comment",s.appendChild(this.#i),this.#s.appendChild(s),this.hasAttribute("data-max-length")&&(this.#l=document.createElement("span"),this.#l.className="comment-box-counter",this.#l.setAttribute("aria-live","polite"),this.#s.appendChild(this.#l)),this.replaceChildren(this.#t,this.#s),this.listen(this.#i,"click",this.#g),this.#r&&this.listen(this.#r,"click",this.#k),this.#a(),this.#t.hasAttribute("data-upgraded")||this.listen(this.#t,"markdown-editor:upgraded",()=>this.#a(),{once:!0}),this.#f(),this.#u(),this.#p(),this.#d()}get#o(){return this.#t?.textarea??this.#t?.querySelector("textarea")??null}#a(){let e=this.#o;!e||e===this.#h||(this.#h=e,this.listen(e,"input",this.#c),this.listen(e,"keydown",this.#b))}attributeChangedCallback(e,t,s){if(!(!this.isConnected||!this.#t))if(e==="value")this.value=s??"";else if(e==="placeholder"){let r=this.#o;r&&(r.placeholder=s??"")}else e==="disabled"?this.#f():e==="submit-label"?this.#i.textContent=s||"Comment":e==="cancel-label"?this.#r&&(this.#r.textContent=s||"Cancel"):e==="data-show-cancel"&&(this.hasAttribute("data-show-cancel")&&!this.#r?(this.#r=document.createElement("button"),this.#r.type="button",this.#r.className="comment-box-cancel",this.#r.textContent=this.getAttribute("cancel-label")||"Cancel",this.#i.parentNode.insertBefore(this.#r,this.#i),this.listen(this.#r,"click",this.#k)):!this.hasAttribute("data-show-cancel")&&this.#r&&(this.#r.remove(),this.#r=null))}#c=()=>{this.#u(),this.#p(),this.#d(),this.dispatchEvent(new CustomEvent("comment-box:input",{bubbles:!0,detail:{value:this.value,length:this.value.length}}))};#b=e=>{e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),this.#g())};#g=()=>{if(this.#m())return;let e=this.value,t=new CustomEvent("comment-box:submit",{bubbles:!0,cancelable:!0,detail:{value:e}});this.dispatchEvent(t)&&this.clear()};#k=()=>{let e=this.value;this.dispatchEvent(new CustomEvent("comment-box:cancel",{bubbles:!0,detail:{value:e}}))};#m(){return this.hasAttribute("disabled")?!0:!this.#e.checkValidity()}#f(){let e=this.hasAttribute("disabled"),t=this.#o;t&&(t.disabled=e),this.#i.disabled=e,this.#r&&(this.#r.disabled=e)}#u(){this.#e.setFormValue(this.value)}#p(){let e=this.value,t=Number(this.getAttribute("data-min-length"))||0,s=Number(this.getAttribute("data-max-length"))||1/0,r=this.hasAttribute("required"),i=this.#o&&this.contains(this.#o)?this.#o:null;if(r&&e.length===0){this.#e.setValidity({valueMissing:!0},"Please add a comment.",i||void 0);return}if(e.length<t){this.#e.setValidity({tooShort:!0},`At least ${t} characters required.`,i||void 0);return}if(e.length>s){this.#e.setValidity({tooLong:!0},`No more than ${s} characters.`,i||void 0);return}this.#e.setValidity({})}#d(){if(!this.#l)return;let e=Number(this.getAttribute("data-max-length"))||0,t=this.value.length;this.#l.textContent=e?`${t} / ${e}`:String(t),this.#l.classList.toggle("is-over",e>0&&t>e)}get value(){return this.#t?.value??""}set value(e){this.#t&&(this.#t.value=e==null?"":String(e),this.#u(),this.#p(),this.#d())}clear(){this.value="",this.dispatchEvent(new CustomEvent("comment-box:input",{bubbles:!0,detail:{value:"",length:0}}))}focus(){this.#o?.focus()}formResetCallback(){this.value=this.getAttribute("value")??""}formStateRestoreCallback(e){e!=null&&(this.value=e)}get form(){return this.#e.form}get name(){return this.getAttribute("name")}get type(){return this.localName}get validity(){return this.#e.validity}get validationMessage(){return this.#e.validationMessage}checkValidity(){return this.#e.checkValidity()}reportValidity(){return this.#e.reportValidity()}};R("comment-box",ee);export{ee as CommentBox};
60
+ //# sourceMappingURL=comment-box.js.map