vanilla-breeze 0.5.0 → 0.6.0

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 (263) hide show
  1. package/custom-elements.json +22381 -13213
  2. package/dist/cdn/components/accordion-wc.js +1 -1
  3. package/dist/cdn/components/activity-feed.js +1 -1
  4. package/dist/cdn/components/ai-chat.js +5 -5
  5. package/dist/cdn/components/ai-summary.js +2 -2
  6. package/dist/cdn/components/analytics-panel.js +2 -2
  7. package/dist/cdn/components/audio-player.js +4 -4
  8. package/dist/cdn/components/audio-visualizer.js +2 -2
  9. package/dist/cdn/components/author-index.js +2 -2
  10. package/dist/cdn/components/brand-mark.js +1 -1
  11. package/dist/cdn/components/bread-crumb.js +1 -1
  12. package/dist/cdn/components/calendar-wc.js +2 -2
  13. package/dist/cdn/components/card-list.js +1 -1
  14. package/dist/cdn/components/carousel-wc.js +1 -1
  15. package/dist/cdn/components/change-set.js +1 -1
  16. package/dist/cdn/components/chart-wc.js +6 -6
  17. package/dist/cdn/components/chat-input.js +1 -1
  18. package/dist/cdn/components/chat-window.js +1 -1
  19. package/dist/cdn/components/color-picker.js +1 -1
  20. package/dist/cdn/components/combo-box.js +1 -1
  21. package/dist/cdn/components/command-palette.js +1 -1
  22. package/dist/cdn/components/comment-box.js +51 -50
  23. package/dist/cdn/components/comment-thread.js +50 -49
  24. package/dist/cdn/components/comment-wc.js +1 -1
  25. package/dist/cdn/components/compare-surface.js +1 -1
  26. package/dist/cdn/components/consent-banner.js +1 -1
  27. package/dist/cdn/components/content-lens.js +1 -1
  28. package/dist/cdn/components/content-swap.js +1 -1
  29. package/dist/cdn/components/context-menu.js +1 -1
  30. package/dist/cdn/components/data-table.js +1 -1
  31. package/dist/cdn/components/date-picker.js +1 -1
  32. package/dist/cdn/components/day-view.js +1 -1
  33. package/dist/cdn/components/diagram-wc.js +2 -2
  34. package/dist/cdn/components/drag-surface.js +1 -1
  35. package/dist/cdn/components/drop-down.js +1 -1
  36. package/dist/cdn/components/emoji-picker.js +1 -1
  37. package/dist/cdn/components/flow-diagram.js +1 -1
  38. package/dist/cdn/components/foot-notes.js +1 -1
  39. package/dist/cdn/components/form-field.js +1 -1
  40. package/dist/cdn/components/geo-map.js +170 -54
  41. package/dist/cdn/components/glossary-index.js +1 -1
  42. package/dist/cdn/components/glossary-wc.js +1 -1
  43. package/dist/cdn/components/heading-links.js +1 -1
  44. package/dist/cdn/components/highlight-wc.js +6 -2
  45. package/dist/cdn/components/icon-wc.js +11 -10
  46. package/dist/cdn/components/image-gallery.js +1 -1
  47. package/dist/cdn/components/image-map.js +1 -1
  48. package/dist/cdn/components/include-file.js +1 -1
  49. package/dist/cdn/components/manifest.json +101 -101
  50. package/dist/cdn/components/markdown-editor.js +60 -1
  51. package/dist/cdn/components/markdown-viewer.js +50 -49
  52. package/dist/cdn/components/nav-bar.js +1 -1
  53. package/dist/cdn/components/note-wc.js +6 -2
  54. package/dist/cdn/components/notification-wc.js +33 -32
  55. package/dist/cdn/components/page-info.js +6 -72
  56. package/dist/cdn/components/page-stats.js +1 -1
  57. package/dist/cdn/components/page-toc.js +1 -1
  58. package/dist/cdn/components/page-tools.js +1 -1
  59. package/dist/cdn/components/page-tour.js +1 -38
  60. package/dist/cdn/components/pager-wc.js +1 -1
  61. package/dist/cdn/components/poll-wc.js +1 -1
  62. package/dist/cdn/components/pop-over.js +1 -1
  63. package/dist/cdn/components/popularity-index.js +1 -8
  64. package/dist/cdn/components/print-page.js +1 -1
  65. package/dist/cdn/components/progress-tracker.js +1 -1
  66. package/dist/cdn/components/qr-code.js +1 -1
  67. package/dist/cdn/components/reaction-bar.js +1 -1
  68. package/dist/cdn/components/reader-view.js +25 -25
  69. package/dist/cdn/components/reading-progress.js +1 -1
  70. package/dist/cdn/components/recently-visited.js +1 -26
  71. package/dist/cdn/components/score-card.js +21 -5
  72. package/dist/cdn/components/selection-menu.js +1 -1
  73. package/dist/cdn/components/settings-panel.js +88 -142
  74. package/dist/cdn/components/share-wc.js +2 -2
  75. package/dist/cdn/components/short-cuts.js +1 -1
  76. package/dist/cdn/components/site-index.js +1 -10
  77. package/dist/cdn/components/site-map.js +1 -1
  78. package/dist/cdn/components/site-search.js +1 -51
  79. package/dist/cdn/components/slide-accept.js +1 -1
  80. package/dist/cdn/components/social-embed.js +1 -1
  81. package/dist/cdn/components/split-surface.js +1 -1
  82. package/dist/cdn/components/star-rating.js +1 -1
  83. package/dist/cdn/components/status-wc.js +1 -1
  84. package/dist/cdn/components/stepper-wc.js +1 -1
  85. package/dist/cdn/components/tab-set.js +1 -1
  86. package/dist/cdn/components/text-reader.js +2 -2
  87. package/dist/cdn/components/theme-picker.js +86 -83
  88. package/dist/cdn/components/time-index.js +1 -11
  89. package/dist/cdn/components/time-picker.js +1 -1
  90. package/dist/cdn/components/toast-msg.js +6 -6
  91. package/dist/cdn/components/tool-tip.js +1 -1
  92. package/dist/cdn/components/topic-map.js +6 -3
  93. package/dist/cdn/components/trust-filter.js +1 -3
  94. package/dist/cdn/components/version-switcher.js +5 -5
  95. package/dist/cdn/components/video-player.js +67 -9
  96. package/dist/cdn/components/watch-wc.js +6 -2
  97. package/dist/cdn/components/week-view.js +1 -1
  98. package/dist/cdn/components/youtube-player.js +1 -1
  99. package/dist/cdn/emoji-extended.js +2 -0
  100. package/dist/cdn/fonts/atkinson-hyperlegible-OFL.txt +93 -0
  101. package/dist/cdn/fonts/atkinson-hyperlegible-latin-400-italic.woff2 +0 -0
  102. package/dist/cdn/fonts/atkinson-hyperlegible-latin-400-normal.woff2 +0 -0
  103. package/dist/cdn/fonts/atkinson-hyperlegible-latin-700-italic.woff2 +0 -0
  104. package/dist/cdn/fonts/atkinson-hyperlegible-latin-700-normal.woff2 +0 -0
  105. package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-400-italic.woff2 +0 -0
  106. package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-400-normal.woff2 +0 -0
  107. package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-700-italic.woff2 +0 -0
  108. package/dist/cdn/fonts/atkinson-hyperlegible-latin-ext-700-normal.woff2 +0 -0
  109. package/dist/cdn/fonts/latinmodern-math-GUST-LICENSE.txt +30 -0
  110. package/dist/cdn/fonts/latinmodern-math.woff2 +0 -0
  111. package/dist/cdn/fonts/math-fonts.css +14 -0
  112. package/dist/cdn/packs/effects.full.css +1 -1
  113. package/dist/cdn/packs/effects.full.js +1 -1
  114. package/dist/cdn/packs/fonts-display.full.css +1 -1
  115. package/dist/cdn/packs/fonts-display.theme.css +1 -1
  116. package/dist/cdn/packs/icons.bundle.js +1 -1
  117. package/dist/cdn/packs/icons.full.css +1 -1
  118. package/dist/cdn/packs/icons.theme.css +1 -1
  119. package/dist/cdn/packs/journal.effects.css +1 -1
  120. package/dist/cdn/packs/journal.full.css +1 -1
  121. package/dist/cdn/packs/kawaii.effects.css +1 -1
  122. package/dist/cdn/packs/kawaii.full.css +2 -2
  123. package/dist/cdn/packs/kawaii.full.js +4 -4
  124. package/dist/cdn/packs/kawaii.theme.css +1 -1
  125. package/dist/cdn/packs/manifest.json +17 -17
  126. package/dist/cdn/packs/memphis.full.css +1 -1
  127. package/dist/cdn/packs/memphis.theme.css +1 -1
  128. package/dist/cdn/packs/ui.full.css +1 -1
  129. package/dist/cdn/packs/ui.full.js +89 -86
  130. package/dist/cdn/themes/8bit.css +1 -1
  131. package/dist/cdn/themes/8bit.tokens.json +1 -1
  132. package/dist/cdn/themes/alpha1999-dark.tokens.json +1 -1
  133. package/dist/cdn/themes/alpha1999.css +1 -1
  134. package/dist/cdn/themes/alpha1999.tokens.json +1 -1
  135. package/dist/cdn/themes/art-deco-dark.tokens.json +1 -1
  136. package/dist/cdn/themes/art-deco.css +1 -1
  137. package/dist/cdn/themes/art-deco.tokens.json +1 -1
  138. package/dist/cdn/themes/bauhaus-dark.tokens.json +1 -1
  139. package/dist/cdn/themes/bauhaus.css +1 -1
  140. package/dist/cdn/themes/bauhaus.tokens.json +1 -1
  141. package/dist/cdn/themes/brutalist-dark.tokens.json +1 -1
  142. package/dist/cdn/themes/brutalist.css +1 -1
  143. package/dist/cdn/themes/brutalist.tokens.json +1 -1
  144. package/dist/cdn/themes/catppuccin-frappe.css +1 -1
  145. package/dist/cdn/themes/catppuccin-frappe.tokens.json +1 -1
  146. package/dist/cdn/themes/catppuccin-latte-dark.tokens.json +1 -1
  147. package/dist/cdn/themes/catppuccin-latte.css +1 -1
  148. package/dist/cdn/themes/catppuccin-latte.tokens.json +1 -1
  149. package/dist/cdn/themes/catppuccin-macchiato.css +1 -1
  150. package/dist/cdn/themes/catppuccin-macchiato.tokens.json +1 -1
  151. package/dist/cdn/themes/catppuccin-mocha.css +1 -1
  152. package/dist/cdn/themes/catppuccin-mocha.tokens.json +1 -1
  153. package/dist/cdn/themes/classic-dark.tokens.json +1 -1
  154. package/dist/cdn/themes/classic.css +1 -1
  155. package/dist/cdn/themes/classic.tokens.json +1 -1
  156. package/dist/cdn/themes/claymorphism-dark.tokens.json +1 -1
  157. package/dist/cdn/themes/claymorphism.css +1 -1
  158. package/dist/cdn/themes/claymorphism.tokens.json +2 -1
  159. package/dist/cdn/themes/clinical-dark.tokens.json +1 -1
  160. package/dist/cdn/themes/clinical.css +1 -1
  161. package/dist/cdn/themes/clinical.tokens.json +1 -1
  162. package/dist/cdn/themes/cottagecore-dark.tokens.json +1 -1
  163. package/dist/cdn/themes/cottagecore.css +1 -1
  164. package/dist/cdn/themes/cottagecore.tokens.json +1 -1
  165. package/dist/cdn/themes/cyber.css +1 -1
  166. package/dist/cdn/themes/cyber.tokens.json +1 -1
  167. package/dist/cdn/themes/dawn-dark.tokens.json +1 -1
  168. package/dist/cdn/themes/dawn.css +1 -1
  169. package/dist/cdn/themes/dawn.tokens.json +1 -1
  170. package/dist/cdn/themes/dracula.css +1 -1
  171. package/dist/cdn/themes/dracula.tokens.json +1 -1
  172. package/dist/cdn/themes/dusk.css +1 -1
  173. package/dist/cdn/themes/dusk.tokens.json +1 -1
  174. package/dist/cdn/themes/editorial-dark.tokens.json +1 -1
  175. package/dist/cdn/themes/editorial.css +1 -1
  176. package/dist/cdn/themes/editorial.tokens.json +1 -1
  177. package/dist/cdn/themes/financial-dark.tokens.json +1 -1
  178. package/dist/cdn/themes/financial.css +1 -1
  179. package/dist/cdn/themes/financial.tokens.json +1 -1
  180. package/dist/cdn/themes/genai.css +1 -1
  181. package/dist/cdn/themes/genai.tokens.json +1 -1
  182. package/dist/cdn/themes/glassmorphism-dark.tokens.json +1 -1
  183. package/dist/cdn/themes/glassmorphism.css +1 -1
  184. package/dist/cdn/themes/glassmorphism.tokens.json +1 -1
  185. package/dist/cdn/themes/government-dark.tokens.json +1 -1
  186. package/dist/cdn/themes/government.css +1 -1
  187. package/dist/cdn/themes/government.tokens.json +1 -1
  188. package/dist/cdn/themes/gruvbox-dark.tokens.json +1 -1
  189. package/dist/cdn/themes/gruvbox.css +1 -1
  190. package/dist/cdn/themes/gruvbox.tokens.json +1 -1
  191. package/dist/cdn/themes/high-noon-dark.tokens.json +1 -1
  192. package/dist/cdn/themes/high-noon.css +1 -1
  193. package/dist/cdn/themes/high-noon.tokens.json +1 -1
  194. package/dist/cdn/themes/journal-dark.tokens.json +4 -2
  195. package/dist/cdn/themes/journal.css +1 -1
  196. package/dist/cdn/themes/journal.tokens.json +4 -2
  197. package/dist/cdn/themes/kawaii-dark.tokens.json +1 -1
  198. package/dist/cdn/themes/kawaii.css +1 -1
  199. package/dist/cdn/themes/kawaii.tokens.json +1 -1
  200. package/dist/cdn/themes/magna-dark.tokens.json +1 -1
  201. package/dist/cdn/themes/magna.css +1 -1
  202. package/dist/cdn/themes/magna.tokens.json +1 -1
  203. package/dist/cdn/themes/manifest.json +44 -44
  204. package/dist/cdn/themes/midnight.css +1 -1
  205. package/dist/cdn/themes/midnight.tokens.json +1 -1
  206. package/dist/cdn/themes/minimal-dark.tokens.json +1 -1
  207. package/dist/cdn/themes/minimal.css +1 -1
  208. package/dist/cdn/themes/minimal.tokens.json +1 -1
  209. package/dist/cdn/themes/modern-dark.tokens.json +1 -1
  210. package/dist/cdn/themes/modern.css +1 -1
  211. package/dist/cdn/themes/modern.tokens.json +1 -1
  212. package/dist/cdn/themes/nes-dark.tokens.json +7 -2
  213. package/dist/cdn/themes/nes.css +1 -1
  214. package/dist/cdn/themes/nes.tokens.json +1 -1
  215. package/dist/cdn/themes/neumorphism-dark.tokens.json +1 -1
  216. package/dist/cdn/themes/neumorphism.css +1 -1
  217. package/dist/cdn/themes/neumorphism.tokens.json +1 -1
  218. package/dist/cdn/themes/nord-dark.tokens.json +1 -1
  219. package/dist/cdn/themes/nord.css +1 -1
  220. package/dist/cdn/themes/nord.tokens.json +1 -1
  221. package/dist/cdn/themes/organic-dark.tokens.json +1 -1
  222. package/dist/cdn/themes/organic.css +1 -1
  223. package/dist/cdn/themes/organic.tokens.json +1 -1
  224. package/dist/cdn/themes/rose-pine-dark.tokens.json +1 -1
  225. package/dist/cdn/themes/rose-pine.css +1 -1
  226. package/dist/cdn/themes/rose-pine.tokens.json +1 -1
  227. package/dist/cdn/themes/rough-dark.tokens.json +1 -1
  228. package/dist/cdn/themes/rough.css +1 -1
  229. package/dist/cdn/themes/rough.tokens.json +1 -1
  230. package/dist/cdn/themes/solarized-dark.tokens.json +1 -1
  231. package/dist/cdn/themes/solarized.css +1 -1
  232. package/dist/cdn/themes/solarized.tokens.json +1 -1
  233. package/dist/cdn/themes/startup-dark.tokens.json +1 -1
  234. package/dist/cdn/themes/startup.css +1 -1
  235. package/dist/cdn/themes/startup.tokens.json +1 -1
  236. package/dist/cdn/themes/super2026-dark.tokens.json +1 -1
  237. package/dist/cdn/themes/super2026.css +1 -1
  238. package/dist/cdn/themes/super2026.tokens.json +1 -1
  239. package/dist/cdn/themes/swiss-dark.tokens.json +1 -1
  240. package/dist/cdn/themes/swiss.css +1 -1
  241. package/dist/cdn/themes/swiss.tokens.json +1 -1
  242. package/dist/cdn/themes/terminal.css +1 -1
  243. package/dist/cdn/themes/terminal.tokens.json +1 -1
  244. package/dist/cdn/themes/tokyo-night-dark.tokens.json +1 -1
  245. package/dist/cdn/themes/tokyo-night.css +1 -1
  246. package/dist/cdn/themes/tokyo-night.tokens.json +1 -1
  247. package/dist/cdn/themes/vaporwave-dark.tokens.json +1 -1
  248. package/dist/cdn/themes/vaporwave.css +1 -1
  249. package/dist/cdn/themes/vaporwave.tokens.json +1 -1
  250. package/dist/cdn/themes/win9x-dark.tokens.json +6 -2
  251. package/dist/cdn/themes/win9x.css +1 -1
  252. package/dist/cdn/themes/win9x.tokens.json +3 -1
  253. package/dist/cdn/vanilla-breeze-autoload.js +187 -297
  254. package/dist/cdn/vanilla-breeze-charts.css +1 -1
  255. package/dist/cdn/vanilla-breeze-charts.js +6 -6
  256. package/dist/cdn/vanilla-breeze-core.css +1 -1
  257. package/dist/cdn/vanilla-breeze-core.js +166 -262
  258. package/dist/cdn/vanilla-breeze-dev.js +1 -1
  259. package/dist/cdn/vanilla-breeze-extras.js +272 -130
  260. package/dist/cdn/vanilla-breeze.css +1 -1
  261. package/dist/cdn/vanilla-breeze.js +536 -621
  262. package/dist/cdn/view-transitions.css +2 -0
  263. package/package.json +15 -7
@@ -1,2 +1,2 @@
1
- var it=window.matchMedia("(prefers-reduced-motion: reduce)");var D=new Map;function F(i,t,e={}){let s=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:s},r=D.get(i);if(customElements.get(i)){if(!r||r.priority>=s){r&&r.priority===s&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${i}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=s){r.priority===s&&console.warn(`[VB Bundle] Tag <${i}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}D.set(i,n),customElements.define(i,t)}var E=class extends HTMLElement{#d=[];#n;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))}_reinit(){for(let t of this.#d)t();this.#d=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#n||(this.#n=this.attachInternals());let s=this.#n.states;try{e?s.add(t):s.delete(t)}catch{let n=`--${t}`;e?s.add(n):s.delete(n)}}_adoptInternals(t){this.#n||(this.#n=t)}};var O="popover"in HTMLElement.prototype;var k="[data-copy], [data-copy-target], [data-paste-target]",B="Copied to clipboard",q="Pasted from clipboard",w=new WeakMap;async function T(i,t={}){if(i==null||i==="")return!1;let{button:e,announceMessage:s=B,duration:n=1500}=t;try{await navigator.clipboard.writeText(i)}catch{return!1}return I({button:e,duration:n,announceMessage:s,eventDetail:{text:i}}),!0}function I({button:i,duration:t,announceMessage:e,eventDetail:s,state:n="copied",eventName:r="copy"}){if(i){i.dataset.state=n;let h=w.get(i);h&&clearTimeout(h),w.set(i,setTimeout(()=>{delete i.dataset.state,w.delete(i)},t)),i.dispatchEvent(new CustomEvent(r,{bubbles:!0,detail:s}))}W(e,i??document.body)}async function U(i,t={}){let{button:e,announceMessage:s=q,duration:n=1500}=t,r;try{r=await navigator.clipboard.readText()}catch{return null}return i&&("value"in i&&(i instanceof HTMLInputElement||i instanceof HTMLTextAreaElement||i instanceof HTMLSelectElement)?i.value=r:i.textContent=r,i.dispatchEvent(new Event("input",{bubbles:!0}))),I({button:e,duration:n,announceMessage:s,eventDetail:{text:r},state:"pasted",eventName:"paste"}),r}function P(i=document){i.querySelectorAll(k).forEach(M)}function M(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=V(i);t&&T(t,{button:i})}))}function V(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 W(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",()=>P()):P();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(k)&&M(s),s.querySelectorAll(k).forEach(n=>M(n))}});j.observe(document.documentElement,{childList:!0,subtree:!0});function b(i,t,e){t/=100,e/=100;let s=h=>(h+i/30)%12,n=t*Math.min(e,1-e),r=h=>e-n*Math.max(-1,Math.min(s(h)-3,9-s(h),1));return{r:Math.round(r(0)*255),g:Math.round(r(8)*255),b:Math.round(r(4)*255)}}function C(i,t,e,s=!1){i/=255,t/=255,e/=255;let n=Math.max(i,t,e),r=Math.min(i,t,e),h=(n+r)/2,o=0,a=0;if(n!==r){let l=n-r;switch(a=h>.5?l/(2-n-r):l/(n+r),n){case i:o=((t-e)/l+(t<e?6:0))/6;break;case t:o=((e-i)/l+2)/6;break;case e:o=((i-t)/l+4)/6;break}}return s?{h:o*360,s:a*100,l:h*100}:{h:Math.round(o*360),s:Math.round(a*100),l:Math.round(h*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 p(i,t=!1){let{r:e,g:s,b:n}=G(i);return C(e,s,n,t)}function m(i,t,e){let{r:s,g:n,b:r}=b(i,t,e);return K(s,n,r)}function c(i,t,e){return Math.max(t,Math.min(e,i))}function N(i){return i/=255,i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function L(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=N(i),n=N(t),r=N(e),h=.4122214708*s+.5363325363*n+.0514459929*r,o=.2119034982*s+.6806995451*n+.1073969566*r,a=.0883024619*s+.2817188376*n+.6299787005*r,l=Math.cbrt(h),u=Math.cbrt(o),d=Math.cbrt(a),f=.2104542553*l+.793617785*u-.0040720468*d,y=1.9779984951*l-2.428592205*u+.4505937099*d,x=.0259040371*l+.7827717662*u-.808675766*d,H=Math.sqrt(y*y+x*x),A=Math.atan2(x,y)*180/Math.PI;return A<0&&(A+=360),H<1e-4&&(A=0),{L:f,C:H,H:A}}function X(i,t,e){let s=e*Math.PI/180,n=t*Math.cos(s),r=t*Math.sin(s),h=i+.3963377774*n+.2158037573*r,o=i-.1055613458*n-.0638541728*r,a=i-.0894841775*n-1.291485548*r,l=h**3,u=o**3,d=a**3,f=4.0767416621*l-3.3077115913*u+.2309699292*d,y=-1.2684380046*l+2.6097574011*u-.3413193965*d,x=-.0041960863*l-.7034186147*u+1.707614701*d;return{r:L(f),g:L(y),b:L(x)}}function S(i,t,e){let s=b(i,t,e);return z(s.r,s.g,s.b)}function R(i,t,e,s=!1){let{r:n,g:r,b:h}=X(i,t,e);return C(n,r,h,s)}function Y(i,t,e){return m(i,t,e)}function J(i,t,e){let{r:s,g:n,b:r}=b(i,t,e);return`rgb(${s} ${n} ${r})`}function Q(i,t,e){return`hsl(${Math.round(i)}deg ${Math.round(t)}% ${Math.round(e)}%)`}function Z(i,t,e){let{L:s,C:n,H:r}=S(i,t,e);return`oklch(${(s*100).toFixed(1)}% ${n.toFixed(3)} ${r.toFixed(1)}deg)`}function _(i,t,e,s){switch(i){case"rgb":return J(t,e,s);case"hsl":return Q(t,e,s);case"oklch":return Z(t,e,s);default:return Y(t,e,s)}}var v=["hex","rgb","hsl","oklch"],tt="hex",et=/^#[0-9a-fA-F]{6}$/,g=8,st=0,$=class extends E{static formAssociated=!0;#d;#n;#i;#w;#v;#g;#a;#r;#y;#o;#k;#b;#m={};#x=tt;#c;#f;#u;#p=!1;#E=!1;#H=!1;#S=`cp${++st}`;#t=0;#e=100;#s=50;#M;static get observedAttributes(){return["disabled"]}constructor(){super(),this.#d=this.attachInternals(),this._adoptInternals(this.#d)}setup(){if(this.#n=this.querySelector(':scope > input[type="color"]'),!this.#n)return!1;if(!this.#H){let s=this.getAttribute("format");s&&v.includes(s)&&(this.#x=s),this.#H=!0}if(this.#M===void 0){let s=this.#n.defaultValue;this.#M=et.test(s)?s.toLowerCase():this.#n.value||"#000000"}let t=p(this.#n.value||this.#M,!0);this.#t=t.h,this.#e=t.s,this.#s=t.l;let e=this.#n.getAttribute("name");return e&&(this.hasAttribute("name")||this.setAttribute("name",e),this.#n.removeAttribute("name")),this.#n.hasAttribute("disabled")&&(this.#n.removeAttribute("disabled"),this.hasAttribute("disabled")||this.setAttribute("disabled","")),this.#n.setAttribute("tabindex","-1"),this.#n.setAttribute("aria-hidden","true"),this.#n.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.listen(this.#n,"click",this.#I),this.#_(),this.#B(),this.#C(),this.#L(),this.#E=O,this.#E&&this.#a.setAttribute("popover","manual"),this.listen(document,"click",this.#tt),this.listen(this,"keydown",this.#R),this.#$(this.matches(":disabled")),!0}teardown(){this.#p=!1,this.removeAttribute("open"),window.removeEventListener("scroll",this.#A,{capture:!0}),window.removeEventListener("resize",this.#A),this.#i?.remove(),this.#a?.remove()}attributeChangedCallback(t){t==="disabled"&&this.#i&&this.#$(this.matches(":disabled"))}formDisabledCallback(t){this.#i&&this.#$(t)}#$(t){this.#i.disabled=t,t&&this.#N()}#I=t=>{t.preventDefault(),this.#i.disabled||this.#i.focus()};#R=t=>{t.key!=="Escape"||!this.#p||(t.preventDefault(),t.stopPropagation(),this.#N(),this.#i.focus())};#_(){this.#i=document.createElement("button"),this.#i.type="button",this.#i.className="color-trigger",this.#i.setAttribute("aria-haspopup","dialog"),this.#i.setAttribute("aria-expanded","false"),this.#w=document.createElement("span"),this.#w.className="color-swatch",this.#v=document.createElement("span"),this.#v.className="color-hex",this.#v.id=`${this.#S}-value`,this.#i.appendChild(this.#w),this.#i.appendChild(this.#v);let t=[];for(let e of Array.from(this.#n.labels||[]))e.id||(e.id=`${this.#S}-label-${t.length}`),t.push(e.id);t.length===0&&(this.#g=document.createElement("span"),this.#g.className="visually-hidden",this.#g.id=`${this.#S}-name`,this.#g.textContent=this.#n.getAttribute("aria-label")||this.getAttribute("aria-label")||"Color",this.#i.prepend(this.#g),t.push(this.#g.id)),this.#i.setAttribute("aria-labelledby",[...t,this.#v.id].join(" ")),this.appendChild(this.#i),this.listen(this.#i,"click",()=>{this.#p?this.#N():this.#Z()})}#B(){this.#c=void 0,this.#f=void 0,this.#a=document.createElement("div"),this.#a.className="color-panel",this.#a.setAttribute("role","dialog"),this.#a.setAttribute("aria-label","Color picker"),this.#r=document.createElement("div"),this.#r.className="color-area",this.#r.setAttribute("role","slider"),this.#r.setAttribute("aria-label","Saturation and lightness"),this.#r.setAttribute("aria-valuemin","0"),this.#r.setAttribute("aria-valuemax","100"),this.#r.setAttribute("tabindex","0"),this.#y=document.createElement("div"),this.#y.className="color-area-thumb",this.#r.appendChild(this.#y),this.#a.appendChild(this.#r);let t=document.createElement("div");t.className="color-hue-wrap",this.#o=document.createElement("div"),this.#o.className="color-hue",this.#o.setAttribute("role","slider"),this.#o.setAttribute("aria-label","Hue"),this.#o.setAttribute("aria-valuemin","0"),this.#o.setAttribute("aria-valuemax","360"),this.#o.setAttribute("tabindex","0"),this.#k=document.createElement("div"),this.#k.className="color-hue-thumb",this.#o.appendChild(this.#k),t.appendChild(this.#o),this.#a.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.#b=document.createElement("select"),this.#b.className="color-format-select";for(let o of v){let a=document.createElement("option");a.value=o,a.textContent=o.toUpperCase(),this.#b.appendChild(a)}this.#b.value=this.#x,s.appendChild(n),s.appendChild(this.#b),e.appendChild(s),this.#a.appendChild(e),this.listen(this.#b,"change",this.#q),this.#m.hex=this.#T("hex",[{label:"Hex",channel:"hex",kind:"text",maxLength:7}]),this.#m.rgb=this.#T("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.#m.hsl=this.#T("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.#m.oklch=this.#T("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 o of v)this.#a.appendChild(this.#m[o].wrapper);this.#D();let r=this.querySelector(":scope > datalist");if(r){this.#c=document.createElement("div"),this.#c.className="color-swatches",this.#c.setAttribute("role","group"),this.#c.setAttribute("aria-label","Preset colors");for(let o of r.querySelectorAll("option[value]")){let a=document.createElement("button");a.type="button",a.setAttribute("aria-pressed","false"),a.style.background=o.value,a.setAttribute("aria-label",o.textContent||o.value),a.setAttribute("data-color",o.value),this.#c.appendChild(a)}this.#a.appendChild(this.#c),this.listen(this.#c,"click",this.#Y)}let h=document.createElement("div");h.className="color-actions","EyeDropper"in window&&(this.#f=document.createElement("button"),this.#f.type="button",this.#f.className="color-eyedropper",this.#f.setAttribute("aria-label","Pick color from screen"),this.#f.textContent="\u{1F4A7}",h.appendChild(this.#f),this.listen(this.#f,"click",this.#J)),this.#u=document.createElement("button"),this.#u.type="button",this.#u.className="color-copy",this.#u.setAttribute("aria-label","Copy hex value"),this.#u.textContent="Copy",h.appendChild(this.#u),this.listen(this.#u,"click",this.#Q),this.#a.appendChild(h),this.appendChild(this.#a),this.listen(this.#r,"pointerdown",this.#U),this.listen(this.#r,"keydown",this.#V),this.listen(this.#o,"pointerdown",this.#W),this.listen(this.#o,"keydown",this.#j);for(let o of v){let a=o==="hex"?this.#G:o==="rgb"?this.#K:o==="hsl"?this.#z:this.#X;for(let{el:l}of this.#m[o].inputs)this.listen(l,"change",a)}}#T(t,e){let s=document.createElement("div");s.className=`color-inputs color-inputs-${t}`,s.setAttribute("data-format",t);let n=[];for(let r of e){let h=document.createElement("label");h.className="color-input-label";let o=document.createElement("span");o.textContent=r.label;let a=document.createElement("input");a.type=r.kind,a.setAttribute("data-channel",r.channel),a.setAttribute("autocomplete","off"),a.setAttribute("spellcheck","false"),r.kind==="text"&&r.maxLength&&a.setAttribute("maxlength",String(r.maxLength)),r.kind==="number"&&(a.min=String(r.min),a.max=String(r.max),r.step!=null&&(a.step=String(r.step))),h.appendChild(o),h.appendChild(a),s.appendChild(h),n.push({el:a,channel:r.channel})}return{wrapper:s,inputs:n}}#D(){for(let t of v)this.#m[t].wrapper.hidden=t!==this.#x;this.#u&&this.#u.setAttribute("aria-label",`Copy ${this.#x.toUpperCase()} value`)}#q=()=>{let t=this.#b.value;v.includes(t)&&(this.#x=t,this.#D(),this.#C())};#U=t=>{t.preventDefault(),this.#r.setPointerCapture(t.pointerId),this.#F(t);let e=n=>this.#F(n),s=n=>{this.#r.releasePointerCapture(n.pointerId),this.#r.removeEventListener("pointermove",e),this.#r.removeEventListener("pointerup",s)};this.#r.addEventListener("pointermove",e),this.#r.addEventListener("pointerup",s)};#F(t){let e=this.#r.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.#l("pointer")}#V=t=>{let e=t.shiftKey?10:1;switch(this.#e=Math.round(this.#e),this.#s=Math.round(this.#s),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.#l("keyboard")};#W=t=>{t.preventDefault(),this.#o.setPointerCapture(t.pointerId),this.#O(t);let e=n=>this.#O(n),s=n=>{this.#o.releasePointerCapture(n.pointerId),this.#o.removeEventListener("pointermove",e),this.#o.removeEventListener("pointerup",s)};this.#o.addEventListener("pointermove",e),this.#o.addEventListener("pointerup",s)};#O(t){let e=this.#o.getBoundingClientRect(),s=c((t.clientX-e.left)/e.width,0,1);this.#t=Math.round(s*360),this.#l("pointer")}#j=t=>{let e=t.shiftKey?10:1;switch(this.#t=Math.round(this.#t),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("keyboard")};#h(t,e){return this.#m[t].inputs.find(s=>s.channel===e)?.el}#G=()=>{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=p(e,!0);this.#t=s.h,this.#e=s.s,this.#s=s.l,this.#l()}};#K=()=>{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=C(t,e,s,!0);this.#t=n.h,this.#e=n.s,this.#s=n.l,this.#l()};#z=()=>{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.#l()};#X=()=>{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=R(t,e,s,!0);this.#t=n.h,this.#e=n.s,this.#s=n.l,this.#l()};#Y=t=>{let e=t.target.closest("button[data-color]");if(!e)return;let s=e.getAttribute("data-color"),n=p(s,!0);this.#t=n.h,this.#e=n.s,this.#s=n.l,this.#l()};#J=async()=>{try{let e=await new window.EyeDropper().open(),s=p(e.sRGBHex,!0);this.#t=s.h,this.#e=s.s,this.#s=s.l,this.#l()}catch{}};#Q=()=>{let t=_(this.#x,this.#t,this.#e,this.#s);T(t,{button:this.#u,announceMessage:"Color copied"})};#l(t="internal"){this.#C(),this.#L();let e=m(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:Math.round(this.#t),s:Math.round(this.#e),l:Math.round(this.#s)},source:t}}))}#C(){let t=m(this.#t,this.#e,this.#s),e=b(this.#t,this.#e,this.#s),s=m(this.#t,100,50);this.#w.style.background=t,this.#v.textContent=t,this.#r.style.setProperty("--area-hue",s),this.#y.style.left=`${this.#e}%`,this.#y.style.top=`${100-this.#s}%`,this.#y.style.background=t;let n=Math.round(this.#t),r=Math.round(this.#e),h=Math.round(this.#s);this.#r.setAttribute("aria-valuenow",String(r)),this.#r.setAttribute("aria-valuetext",`Saturation ${r}%, lightness ${h}%`),this.#k.style.left=`${this.#t/360*100}%`,this.#o.setAttribute("aria-valuenow",String(n)),this.#o.setAttribute("aria-valuetext",`Hue ${n}\xB0`);let o=(l,u,d)=>{let f=this.#h(l,u);f&&(f.value=String(d))};o("hex","hex",t),o("rgb","r",e.r),o("rgb","g",e.g),o("rgb","b",e.b),o("hsl","h",n),o("hsl","s",r),o("hsl","l",h);let a=S(this.#t,this.#e,this.#s);if(o("oklch","oL",(a.L*100).toFixed(1)),o("oklch","oC",a.C.toFixed(3)),o("oklch","oH",a.H.toFixed(1)),this.#c)for(let l of this.#c.querySelectorAll("button[data-color]")){let u=(l.getAttribute("data-color")||"").toLowerCase()===t.toLowerCase();l.setAttribute("aria-pressed",String(u))}}#Z(){if(!(this.#p||this.#i.disabled)){if(this.#p=!0,this.setAttribute("open",""),this.#i.setAttribute("aria-expanded","true"),this.#E){try{this.#a.showPopover()}catch{}this.#P(),window.addEventListener("scroll",this.#A,{capture:!0,passive:!0}),window.addEventListener("resize",this.#A,{passive:!0})}requestAnimationFrame(()=>this.#r.focus()),this.dispatchEvent(new CustomEvent("color-picker:open",{bubbles:!0}))}}#N(){if(this.#p){if(this.#p=!1,this.removeAttribute("open"),this.#i.setAttribute("aria-expanded","false"),this.#E){try{this.#a.hidePopover()}catch{}window.removeEventListener("scroll",this.#A,{capture:!0}),window.removeEventListener("resize",this.#A)}this.dispatchEvent(new CustomEvent("color-picker:close",{bubbles:!0}))}}#P(){if(!this.#E)return;let t=this.#i.getBoundingClientRect(),e=this.#a.offsetWidth,s=this.#a.offsetHeight,n=document.documentElement.clientWidth,r=document.documentElement.clientHeight,o=getComputedStyle(this).direction==="rtl"?t.right-e:t.left;o=Math.min(o,n-e-g),o=Math.max(o,g);let a=t.bottom+4;a+s>r-g&&t.top-s-4>=g&&(a=t.top-s-4),a=Math.max(g,Math.min(a,r-s-g)),this.#a.style.setProperty("--panel-top",`${Math.round(a)}px`),this.#a.style.setProperty("--panel-left",`${Math.round(o)}px`)}#A=()=>{this.#p&&this.#P()};#tt=t=>{this.#p&&!this.contains(t.target)&&this.#N()};#L(){let t=m(this.#t,this.#e,this.#s);this.#d.setFormValue(t),this.#n.value=t,this.#n.dispatchEvent(new Event("input",{bubbles:!0}))}formResetCallback(){if(!this.#i)return;let t=p(this.#M,!0);this.#t=t.h,this.#e=t.s,this.#s=t.l,this.#C(),this.#L()}formStateRestoreCallback(t){if(!t||!this.#i)return;let e=p(t,!0);this.#t=e.h,this.#e=e.s,this.#s=e.l,this.#C(),this.#L()}get value(){return m(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=m(this.#t,this.#e,this.#s).toLowerCase(),s=t.toLowerCase();if(e===s||e===s.toLowerCase())return;let n=p(t,!0);this.#t=n.h,this.#e=n.s,this.#s=n.l,this.#l("api")}};F("color-picker",$);export{$ as ColorPicker};
1
+ var lt=window.matchMedia("(prefers-reduced-motion: reduce)");var F=new Map;function P(s,t,e={}){let i=e.priority??10,n={impl:t,bundle:e.bundle,contract:e.contract,priority:i},r=F.get(s);if(customElements.get(s)){if(!r||r.priority>=i){r&&r.priority===i&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${s}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${s}> 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 <${s}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}F.set(s,n),customElements.define(s,t)}var E=class extends HTMLElement{#d=[];#n;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}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,i,n){t.addEventListener(e,i,n),this.#d.push(()=>t.removeEventListener(e,i,n))}_reinit(){for(let t of this.#d)t();this.#d=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#n||(this.#n=this.attachInternals());let i=this.#n.states;try{e?i.add(t):i.delete(t)}catch{let n=`--${t}`;e?i.add(n):i.delete(n)}}_adoptInternals(t){this.#n||(this.#n=t)}#t(){return this.constructor.formAssociated&&this.#n?this.#n:null}get validity(){return this.#t()?.validity}get validationMessage(){return this.#t()?.validationMessage??""}get willValidate(){return this.#t()?.willValidate??!1}get form(){return this.#t()?.form??null}checkValidity(){return this.#t()?.checkValidity()??!0}reportValidity(){return this.#t()?.reportValidity()??!0}};var R="popover"in HTMLElement.prototype;var W=["position:absolute","inline-size:1px","block-size:1px","padding:0","margin:-1px","overflow:hidden","clip-path:inset(50%)","white-space:nowrap","border:0"].join(";"),I=new WeakMap;function j(s,t){let e=I.get(t);e||I.set(t,e=new Map);let i=e.get(s);if(!i||!i.region.isConnected){let r=(t.ownerDocument||document).createElement("span");r.setAttribute("data-vb-announcer",s),r.setAttribute("role",s==="assertive"?"alert":"status"),r.setAttribute("aria-live",s),r.setAttribute("aria-atomic","true"),r.style.cssText=W,t.appendChild(r),i={region:r},e.set(s,i)}return i}function _(s,{politeness:t="polite",root:e}={}){let i=String(s??"").trim();if(!i||typeof document>"u")return null;let n=e||document.body;if(!n)return null;let a=j(t==="assertive"?"assertive":"polite",n);return clearTimeout(a.write),clearTimeout(a.clear),a.region.textContent="",a.write=setTimeout(()=>{a.region.textContent=i,a.clear=setTimeout(()=>{a.region.textContent=""},7e3)},50),a.region}function w(s,t,e,i){let n=`data-label-${t}`,a=s?.closest?.(`[${n}]`)?.getAttribute(n)||e;return i?a.replace(/\{(\w+)\}/g,(o,l)=>l in i?String(i[l]):o):a}var B=1500,U="[data-copy], [data-copy-target], [data-paste-target]",A={copied:"Copied to clipboard",pasted:"Pasted from clipboard","copy-failed":"Copy failed","copy-failed-selected":"Copy failed. Text selected, press Ctrl+C to copy","paste-failed":"Paste failed"},T=new WeakMap;function z(s){if(typeof document.execCommand!="function"||!document.body)return!1;let t=document.activeElement,e=document.createElement("textarea");e.value=s,e.setAttribute("readonly",""),e.setAttribute("aria-hidden","true"),e.style.cssText="position:fixed;inset-block-start:0;inset-inline-start:0;opacity:0;pointer-events:none",document.body.appendChild(e),e.select();let i=!1;try{i=document.execCommand("copy")}catch{i=!1}return e.remove(),t?.focus?.({preventScroll:!0}),i}function G(s){if(!s)return!1;if(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)return s.focus(),s.select(),!0;let t=window.getSelection?.();if(!t)return!1;let e=document.createRange();return e.selectNodeContents(s),t.removeAllRanges(),t.addRange(e),!t.isCollapsed}async function L(s,t={}){if(s==null||s==="")return!1;let{button:e,duration:i=B}=t,n=!1,r=null;try{if(!navigator.clipboard?.writeText)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(s),n=!0}catch(o){r=o,n=z(s)}if(n)return k({button:e,duration:i,state:"copied",eventName:"copy:done",eventDetail:{text:s},message:t.announceMessage??w(e,"copied",A.copied)}),!0;let a=G(t.source);return k({button:e,duration:i,state:"failed",eventName:"copy:error",eventDetail:{text:s,error:r},message:t.failureMessage??w(e,"copy-failed",a?A["copy-failed-selected"]:A["copy-failed"])}),!1}function k({button:s,duration:t,message:e,eventDetail:i,state:n,eventName:r}){if(s){s.dataset.state=n;let a=T.get(s);a&&clearTimeout(a),T.set(s,setTimeout(()=>{s.dataset.state===n&&delete s.dataset.state,T.delete(s)},t)),s.dispatchEvent(new CustomEvent(r,{bubbles:!0,detail:i}))}_(e,{politeness:n==="failed"?"assertive":"polite"})}async function K(s,t={}){let{button:e,duration:i=B}=t,n;try{if(!navigator.clipboard?.readText)throw new Error("Clipboard API unavailable");n=await navigator.clipboard.readText()}catch(r){return k({button:e,duration:i,state:"failed",eventName:"paste:error",eventDetail:{target:s,error:r},message:t.failureMessage??w(e,"paste-failed",A["paste-failed"])}),null}return s&&(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||s instanceof HTMLSelectElement?s.value=n:s.textContent=n,s.dispatchEvent(new Event("input",{bubbles:!0}))),k({button:e,duration:i,state:"pasted",eventName:"paste:done",eventDetail:{text:n,target:s},message:t.announceMessage??w(e,"pasted",A.pasted)}),n}function O(s){let t=s.dataset.copyTarget;if(!t)return null;try{return document.querySelector(t)}catch{return null}}function Y(s){if(s.dataset.copy)return s.dataset.copy;let t=O(s);if(!t)return"";let e=s.dataset.copyAttr;return e?t.getAttribute(e)??"":t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t.value:t.textContent??""}function X(s){let t=s.target?.closest?.(U);if(!t||t.matches(':disabled, [aria-disabled="true"]'))return;if(t.dataset.pasteTarget){let i=null;try{i=document.querySelector(t.dataset.pasteTarget)}catch{}if(!i)return;K(i,{button:t});return}let e=Y(t);e&&L(e,{button:t,source:O(t)??void 0})}typeof document<"u"&&!document.__vbCopyDelegated&&(document.__vbCopyDelegated=!0,document.addEventListener("click",X));function b(s,t,e){t/=100,e/=100;let i=a=>(a+s/30)%12,n=t*Math.min(e,1-e),r=a=>e-n*Math.max(-1,Math.min(i(a)-3,9-i(a),1));return{r:Math.round(r(0)*255),g:Math.round(r(8)*255),b:Math.round(r(4)*255)}}function M(s,t,e,i=!1){s/=255,t/=255,e/=255;let n=Math.max(s,t,e),r=Math.min(s,t,e),a=(n+r)/2,o=0,l=0;if(n!==r){let h=n-r;switch(l=a>.5?h/(2-n-r):h/(n+r),n){case s:o=((t-e)/h+(t<e?6:0))/6;break;case t:o=((e-s)/h+2)/6;break;case e:o=((s-t)/h+4)/6;break}}return i?{h:o*360,s:l*100,l:a*100}:{h:Math.round(o*360),s:Math.round(l*100),l:Math.round(a*100)}}function J(s){s=s.replace(/^#/,""),s.length===3&&(s=s[0]+s[0]+s[1]+s[1]+s[2]+s[2]);let t=parseInt(s,16);return{r:t>>16&255,g:t>>8&255,b:t&255}}function Q(s,t,e){return"#"+[s,t,e].map(i=>Math.max(0,Math.min(255,Math.round(i))).toString(16).padStart(2,"0")).join("")}function p(s,t=!1){let{r:e,g:i,b:n}=J(s);return M(e,i,n,t)}function f(s,t,e){let{r:i,g:n,b:r}=b(s,t,e);return Q(i,n,r)}function c(s,t,e){return Math.max(t,Math.min(e,s))}function S(s){return s/=255,s<=.04045?s/12.92:Math.pow((s+.055)/1.055,2.4)}function H(s){let t=s<=.0031308?s*12.92:1.055*Math.pow(s,.4166666666666667)-.055;return Math.round(c(t,0,1)*255)}function Z(s,t,e){let i=S(s),n=S(t),r=S(e),a=.4122214708*i+.5363325363*n+.0514459929*r,o=.2119034982*i+.6806995451*n+.1073969566*r,l=.0883024619*i+.2817188376*n+.6299787005*r,h=Math.cbrt(a),u=Math.cbrt(o),d=Math.cbrt(l),m=.2104542553*h+.793617785*u-.0040720468*d,y=1.9779984951*h-2.428592205*u+.4505937099*d,x=.0259040371*h+.7827717662*u-.808675766*d,D=Math.sqrt(y*y+x*x),C=Math.atan2(x,y)*180/Math.PI;return C<0&&(C+=360),D<1e-4&&(C=0),{L:m,C:D,H:C}}function tt(s,t,e){let i=e*Math.PI/180,n=t*Math.cos(i),r=t*Math.sin(i),a=s+.3963377774*n+.2158037573*r,o=s-.1055613458*n-.0638541728*r,l=s-.0894841775*n-1.291485548*r,h=a**3,u=o**3,d=l**3,m=4.0767416621*h-3.3077115913*u+.2309699292*d,y=-1.2684380046*h+2.6097574011*u-.3413193965*d,x=-.0041960863*h-.7034186147*u+1.707614701*d;return{r:H(m),g:H(y),b:H(x)}}function N(s,t,e){let i=b(s,t,e);return Z(i.r,i.g,i.b)}function q(s,t,e,i=!1){let{r:n,g:r,b:a}=tt(s,t,e);return M(n,r,a,i)}function et(s,t,e){return f(s,t,e)}function it(s,t,e){let{r:i,g:n,b:r}=b(s,t,e);return`rgb(${i} ${n} ${r})`}function st(s,t,e){return`hsl(${Math.round(s)}deg ${Math.round(t)}% ${Math.round(e)}%)`}function nt(s,t,e){let{L:i,C:n,H:r}=N(s,t,e);return`oklch(${(i*100).toFixed(1)}% ${n.toFixed(3)} ${r.toFixed(1)}deg)`}function V(s,t,e,i){switch(s){case"rgb":return it(t,e,i);case"hsl":return st(t,e,i);case"oklch":return nt(t,e,i);default:return et(t,e,i)}}var g=["hex","rgb","hsl","oklch"],rt="hex",ot=/^#[0-9a-fA-F]{6}$/,v=8,at=0,$=class extends E{static formAssociated=!0;#d;#n;#t;#E;#g;#v;#a;#r;#y;#o;#k;#b;#f={};#x=rt;#c;#m;#u;#p=!1;#A=!1;#$=!1;#H=`cp${++at}`;#e=0;#i=100;#s=50;#M;static get observedAttributes(){return["disabled"]}constructor(){super(),this.#d=this.attachInternals(),this._adoptInternals(this.#d)}setup(){if(this.#n=this.querySelector(':scope > input[type="color"]'),!this.#n)return!1;if(!this.#$){let i=this.getAttribute("format");i&&g.includes(i)&&(this.#x=i),this.#$=!0}if(this.#M===void 0){let i=this.#n.defaultValue;this.#M=ot.test(i)?i.toLowerCase():this.#n.value||"#000000"}let t=p(this.#n.value||this.#M,!0);this.#e=t.h,this.#i=t.s,this.#s=t.l;let e=this.#n.getAttribute("name");return e&&(this.hasAttribute("name")||this.setAttribute("name",e),this.#n.removeAttribute("name")),this.#n.hasAttribute("disabled")&&(this.#n.removeAttribute("disabled"),this.hasAttribute("disabled")||this.setAttribute("disabled","")),this.#n.setAttribute("tabindex","-1"),this.#n.setAttribute("aria-hidden","true"),this.#n.style.cssText="position:absolute;opacity:0;pointer-events:none;width:1px;height:1px;overflow:hidden;",this.listen(this.#n,"click",this.#I),this.#B(),this.#O(),this.#C(),this.#S(),this.#A=R,this.#A&&this.#a.setAttribute("popover","manual"),this.listen(document,"click",this.#tt),this.listen(this,"keydown",this.#_),this.#N(this.matches(":disabled")),!0}teardown(){this.#p=!1,this.removeAttribute("open"),window.removeEventListener("scroll",this.#w,{capture:!0}),window.removeEventListener("resize",this.#w),this.#t?.remove(),this.#a?.remove()}attributeChangedCallback(t){t==="disabled"&&this.#t&&this.#N(this.matches(":disabled"))}formDisabledCallback(t){this.#t&&this.#N(t)}#N(t){this.#t.disabled=t,t&&this.#L()}#I=t=>{t.preventDefault(),this.#t.disabled||this.#t.focus()};#_=t=>{t.key!=="Escape"||!this.#p||(t.preventDefault(),t.stopPropagation(),this.#L(),this.#t.focus())};#B(){this.#t=document.createElement("button"),this.#t.type="button",this.#t.className="color-trigger",this.#t.setAttribute("aria-haspopup","dialog"),this.#t.setAttribute("aria-expanded","false"),this.#E=document.createElement("span"),this.#E.className="color-swatch",this.#g=document.createElement("span"),this.#g.className="color-hex",this.#g.id=`${this.#H}-value`,this.#t.appendChild(this.#E),this.#t.appendChild(this.#g);let t=[];for(let e of Array.from(this.#n.labels||[]))e.id||(e.id=`${this.#H}-label-${t.length}`),t.push(e.id);t.length===0&&(this.#v=document.createElement("span"),this.#v.className="visually-hidden",this.#v.id=`${this.#H}-name`,this.#v.textContent=this.#n.getAttribute("aria-label")||this.getAttribute("aria-label")||"Color",this.#t.prepend(this.#v),t.push(this.#v.id)),this.#t.setAttribute("aria-labelledby",[...t,this.#g.id].join(" ")),this.appendChild(this.#t),this.listen(this.#t,"click",()=>{this.#p?this.#L():this.#Z()})}#O(){this.#c=void 0,this.#m=void 0,this.#a=document.createElement("div"),this.#a.className="color-panel",this.#a.setAttribute("role","dialog"),this.#a.setAttribute("aria-label","Color picker"),this.#r=document.createElement("div"),this.#r.className="color-area",this.#r.setAttribute("role","slider"),this.#r.setAttribute("aria-label","Saturation and lightness"),this.#r.setAttribute("aria-valuemin","0"),this.#r.setAttribute("aria-valuemax","100"),this.#r.setAttribute("tabindex","0"),this.#y=document.createElement("div"),this.#y.className="color-area-thumb",this.#r.appendChild(this.#y),this.#a.appendChild(this.#r);let t=document.createElement("div");t.className="color-hue-wrap",this.#o=document.createElement("div"),this.#o.className="color-hue",this.#o.setAttribute("role","slider"),this.#o.setAttribute("aria-label","Hue"),this.#o.setAttribute("aria-valuemin","0"),this.#o.setAttribute("aria-valuemax","360"),this.#o.setAttribute("tabindex","0"),this.#k=document.createElement("div"),this.#k.className="color-hue-thumb",this.#o.appendChild(this.#k),t.appendChild(this.#o),this.#a.appendChild(t);let e=document.createElement("div");e.className="color-format-row";let i=document.createElement("label");i.className="color-format-label";let n=document.createElement("span");n.textContent="Format",this.#b=document.createElement("select"),this.#b.className="color-format-select";for(let o of g){let l=document.createElement("option");l.value=o,l.textContent=o.toUpperCase(),this.#b.appendChild(l)}this.#b.value=this.#x,i.appendChild(n),i.appendChild(this.#b),e.appendChild(i),this.#a.appendChild(e),this.listen(this.#b,"change",this.#q),this.#f.hex=this.#T("hex",[{label:"Hex",channel:"hex",kind:"text",maxLength:7}]),this.#f.rgb=this.#T("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.#f.hsl=this.#T("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.#f.oklch=this.#T("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 o of g)this.#a.appendChild(this.#f[o].wrapper);this.#D();let r=this.querySelector(":scope > datalist");if(r){this.#c=document.createElement("div"),this.#c.className="color-swatches",this.#c.setAttribute("role","group"),this.#c.setAttribute("aria-label","Preset colors");for(let o of r.querySelectorAll("option[value]")){let l=document.createElement("button");l.type="button",l.setAttribute("aria-pressed","false"),l.style.background=o.value,l.setAttribute("aria-label",o.textContent||o.value),l.setAttribute("data-color",o.value),this.#c.appendChild(l)}this.#a.appendChild(this.#c),this.listen(this.#c,"click",this.#X)}let a=document.createElement("div");a.className="color-actions","EyeDropper"in window&&(this.#m=document.createElement("button"),this.#m.type="button",this.#m.className="color-eyedropper",this.#m.setAttribute("aria-label","Pick color from screen"),this.#m.textContent="\u{1F4A7}",a.appendChild(this.#m),this.listen(this.#m,"click",this.#J)),this.#u=document.createElement("button"),this.#u.type="button",this.#u.className="color-copy",this.#u.setAttribute("aria-label","Copy hex value"),this.#u.textContent="Copy",a.appendChild(this.#u),this.listen(this.#u,"click",this.#Q),this.#a.appendChild(a),this.appendChild(this.#a),this.listen(this.#r,"pointerdown",this.#V),this.listen(this.#r,"keydown",this.#W),this.listen(this.#o,"pointerdown",this.#j),this.listen(this.#o,"keydown",this.#U);for(let o of g){let l=o==="hex"?this.#z:o==="rgb"?this.#G:o==="hsl"?this.#K:this.#Y;for(let{el:h}of this.#f[o].inputs)this.listen(h,"change",l)}}#T(t,e){let i=document.createElement("div");i.className=`color-inputs color-inputs-${t}`,i.setAttribute("data-format",t);let n=[];for(let r of e){let a=document.createElement("label");a.className="color-input-label";let o=document.createElement("span");o.textContent=r.label;let l=document.createElement("input");l.type=r.kind,l.setAttribute("data-channel",r.channel),l.setAttribute("autocomplete","off"),l.setAttribute("spellcheck","false"),r.kind==="text"&&r.maxLength&&l.setAttribute("maxlength",String(r.maxLength)),r.kind==="number"&&(l.min=String(r.min),l.max=String(r.max),r.step!=null&&(l.step=String(r.step))),a.appendChild(o),a.appendChild(l),i.appendChild(a),n.push({el:l,channel:r.channel})}return{wrapper:i,inputs:n}}#D(){for(let t of g)this.#f[t].wrapper.hidden=t!==this.#x;this.#u&&this.#u.setAttribute("aria-label",`Copy ${this.#x.toUpperCase()} value`)}#q=()=>{let t=this.#b.value;g.includes(t)&&(this.#x=t,this.#D(),this.#C())};#V=t=>{t.preventDefault(),this.#r.setPointerCapture(t.pointerId),this.#F(t);let e=n=>this.#F(n),i=n=>{this.#r.releasePointerCapture(n.pointerId),this.#r.removeEventListener("pointermove",e),this.#r.removeEventListener("pointerup",i)};this.#r.addEventListener("pointermove",e),this.#r.addEventListener("pointerup",i)};#F(t){let e=this.#r.getBoundingClientRect(),i=c((t.clientX-e.left)/e.width,0,1),n=c((t.clientY-e.top)/e.height,0,1);this.#i=Math.round(i*100),this.#s=Math.round((1-n)*100),this.#h("pointer")}#W=t=>{let e=t.shiftKey?10:1;switch(this.#i=Math.round(this.#i),this.#s=Math.round(this.#s),t.key){case"ArrowRight":t.preventDefault(),this.#i=c(this.#i+e,0,100);break;case"ArrowLeft":t.preventDefault(),this.#i=c(this.#i-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.#h("keyboard")};#j=t=>{t.preventDefault(),this.#o.setPointerCapture(t.pointerId),this.#P(t);let e=n=>this.#P(n),i=n=>{this.#o.releasePointerCapture(n.pointerId),this.#o.removeEventListener("pointermove",e),this.#o.removeEventListener("pointerup",i)};this.#o.addEventListener("pointermove",e),this.#o.addEventListener("pointerup",i)};#P(t){let e=this.#o.getBoundingClientRect(),i=c((t.clientX-e.left)/e.width,0,1);this.#e=Math.round(i*360),this.#h("pointer")}#U=t=>{let e=t.shiftKey?10:1;switch(this.#e=Math.round(this.#e),t.key){case"ArrowRight":case"ArrowUp":t.preventDefault(),this.#e=(this.#e+e)%361;break;case"ArrowLeft":case"ArrowDown":t.preventDefault(),this.#e=(this.#e-e+361)%361;break;default:return}this.#h("keyboard")};#l(t,e){return this.#f[t].inputs.find(i=>i.channel===e)?.el}#z=()=>{let t=this.#l("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 i=p(e,!0);this.#e=i.h,this.#i=i.s,this.#s=i.l,this.#h()}};#G=()=>{let t=c(Number(this.#l("rgb","r").value)||0,0,255),e=c(Number(this.#l("rgb","g").value)||0,0,255),i=c(Number(this.#l("rgb","b").value)||0,0,255),n=M(t,e,i,!0);this.#e=n.h,this.#i=n.s,this.#s=n.l,this.#h()};#K=()=>{let t=c(Number(this.#l("hsl","h").value)||0,0,360)%361,e=c(Number(this.#l("hsl","s").value)||0,0,100),i=c(Number(this.#l("hsl","l").value)||0,0,100);this.#e=t,this.#i=e,this.#s=i,this.#h()};#Y=()=>{let t=c(Number(this.#l("oklch","oL").value)||0,0,100)/100,e=c(Number(this.#l("oklch","oC").value)||0,0,.4),i=c(Number(this.#l("oklch","oH").value)||0,0,360),n=q(t,e,i,!0);this.#e=n.h,this.#i=n.s,this.#s=n.l,this.#h()};#X=t=>{let e=t.target.closest("button[data-color]");if(!e)return;let i=e.getAttribute("data-color"),n=p(i,!0);this.#e=n.h,this.#i=n.s,this.#s=n.l,this.#h()};#J=async()=>{try{let e=await new window.EyeDropper().open(),i=p(e.sRGBHex,!0);this.#e=i.h,this.#i=i.s,this.#s=i.l,this.#h()}catch{}};#Q=()=>{let t=V(this.#x,this.#e,this.#i,this.#s);L(t,{button:this.#u,announceMessage:"Color copied"})};#h(t="internal"){this.#C(),this.#S();let e=f(this.#e,this.#i,this.#s),i=b(this.#e,this.#i,this.#s);this.dispatchEvent(new CustomEvent("color-picker:change",{bubbles:!0,detail:{hex:e,rgb:{r:i.r,g:i.g,b:i.b},hsl:{h:Math.round(this.#e),s:Math.round(this.#i),l:Math.round(this.#s)},source:t}}))}#C(){let t=f(this.#e,this.#i,this.#s),e=b(this.#e,this.#i,this.#s),i=f(this.#e,100,50);this.#E.style.background=t,this.#g.textContent=t,this.#r.style.setProperty("--area-hue",i),this.#y.style.left=`${this.#i}%`,this.#y.style.top=`${100-this.#s}%`,this.#y.style.background=t;let n=Math.round(this.#e),r=Math.round(this.#i),a=Math.round(this.#s);this.#r.setAttribute("aria-valuenow",String(r)),this.#r.setAttribute("aria-valuetext",`Saturation ${r}%, lightness ${a}%`),this.#k.style.left=`${this.#e/360*100}%`,this.#o.setAttribute("aria-valuenow",String(n)),this.#o.setAttribute("aria-valuetext",`Hue ${n}\xB0`);let o=(h,u,d)=>{let m=this.#l(h,u);m&&(m.value=String(d))};o("hex","hex",t),o("rgb","r",e.r),o("rgb","g",e.g),o("rgb","b",e.b),o("hsl","h",n),o("hsl","s",r),o("hsl","l",a);let l=N(this.#e,this.#i,this.#s);if(o("oklch","oL",(l.L*100).toFixed(1)),o("oklch","oC",l.C.toFixed(3)),o("oklch","oH",l.H.toFixed(1)),this.#c)for(let h of this.#c.querySelectorAll("button[data-color]")){let u=(h.getAttribute("data-color")||"").toLowerCase()===t.toLowerCase();h.setAttribute("aria-pressed",String(u))}}#Z(){if(!(this.#p||this.#t.disabled)){if(this.#p=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#A){try{this.#a.showPopover()}catch{}this.#R(),window.addEventListener("scroll",this.#w,{capture:!0,passive:!0}),window.addEventListener("resize",this.#w,{passive:!0})}requestAnimationFrame(()=>this.#r.focus()),this.dispatchEvent(new CustomEvent("color-picker:open",{bubbles:!0}))}}#L(){if(this.#p){if(this.#p=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#A){try{this.#a.hidePopover()}catch{}window.removeEventListener("scroll",this.#w,{capture:!0}),window.removeEventListener("resize",this.#w)}this.dispatchEvent(new CustomEvent("color-picker:close",{bubbles:!0}))}}#R(){if(!this.#A)return;let t=this.#t.getBoundingClientRect(),e=this.#a.offsetWidth,i=this.#a.offsetHeight,n=document.documentElement.clientWidth,r=document.documentElement.clientHeight,o=getComputedStyle(this).direction==="rtl"?t.right-e:t.left;o=Math.min(o,n-e-v),o=Math.max(o,v);let l=t.bottom+4;l+i>r-v&&t.top-i-4>=v&&(l=t.top-i-4),l=Math.max(v,Math.min(l,r-i-v)),this.#a.style.setProperty("--panel-top",`${Math.round(l)}px`),this.#a.style.setProperty("--panel-left",`${Math.round(o)}px`)}#w=()=>{this.#p&&this.#R()};#tt=t=>{this.#p&&!this.contains(t.target)&&this.#L()};#S(){let t=f(this.#e,this.#i,this.#s);this.#d.setFormValue(t),this.#n.value=t,this.#n.dispatchEvent(new Event("input",{bubbles:!0}))}formResetCallback(){if(!this.#t)return;let t=p(this.#M,!0);this.#e=t.h,this.#i=t.s,this.#s=t.l,this.#C(),this.#S()}formStateRestoreCallback(t){if(!t||!this.#t)return;let e=p(t,!0);this.#e=e.h,this.#i=e.s,this.#s=e.l,this.#C(),this.#S()}get value(){return f(this.#e,this.#i,this.#s)}set value(t){if(!/^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(t))return;let e=f(this.#e,this.#i,this.#s).toLowerCase(),i=t.toLowerCase();if(e===i||e===i.toLowerCase())return;let n=p(t,!0);this.#e=n.h,this.#i=n.s,this.#s=n.l,this.#h("api")}};P("color-picker",$);export{$ as ColorPicker};
2
2
  //# sourceMappingURL=color-picker.js.map
@@ -1,2 +1,2 @@
1
- var y=window.matchMedia("(prefers-reduced-motion: reduce)");var b=new Map;function u(n,t,e={}){let i=e.priority??10,o={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=b.get(n);if(customElements.get(n)){if(!s||s.priority>=i){s&&s.priority===i&&s.impl!==t&&console.warn(`[VB Bundle] Tag <${n}> already registered by "${s.bundle}" (priority ${s.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${n}> 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 <${n}> already registered by "${s.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}b.set(n,o),customElements.define(n,t)}var c=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,i,o){t.addEventListener(e,i,o),this.#e.push(()=>t.removeEventListener(e,i,o))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let i=this.#t.states;try{e?i.add(t):i.delete(t)}catch{let o=`--${t}`;e?i.add(o):i.delete(o)}}_adoptInternals(t){this.#t||(this.#t=t)}};var d=CSS.supports("anchor-name","--x"),v=CSS.supports("position-area","bottom"),g=0,f=class extends c{#e=null;#t=null;#o=null;#i=null;setup(){this.id||(this.id=`pop-over-${++g}`);let t=this.dataset.mode||"auto";this.hasAttribute("popover")||this.setAttribute("popover",t),this.#l(),this.#r(),this.#o=e=>{let i=e.newState==="open"?"show":"hide";this.dispatchEvent(new CustomEvent(`pop-over:${i}`,{detail:{state:e.newState},bubbles:!0,composed:!0})),!d&&e.newState==="open"&&this.#e&&this.#a()},this.listen(this,"beforetoggle",this.#o),d||(this.#i=()=>{this.matches(":popover-open")&&this.#e&&this.#a()},this.listen(window,"resize",this.#i),this.listen(window,"scroll",this.#i,{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")}#l(){let t=this.dataset.anchor;t?this.#e=document.getElementById(t)||document.querySelector(t):this.#e=document.querySelector(`[popovertarget="${CSS.escape(this.id)}"]`)}#r(){if(!(!this.#e||!d)&&(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.#c(t)}}#c(t){let e="var(--_pop-over-offset, var(--size-xs))",i={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],s=i[o]||i.bottom;Object.entries(s).forEach(([r,a])=>this.style.setProperty(r,a))}#a(){if(!this.#e)return;let t=this.#e.getBoundingClientRect(),e=this.dataset.position||"bottom",i=this.#n(),o,s;switch(e.split("-")[0]){case"top":o=t.top-this.offsetHeight-i,s=t.left;break;case"left":o=t.top,s=t.left-this.offsetWidth-i;break;case"right":o=t.top,s=t.right+i;break;default:o=t.bottom+i,s=t.left;break}e.endsWith("-end")&&(e.startsWith("top")||e.startsWith("bottom")?s=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(s)}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}};u("pop-over",f);var A=0,p=class extends c{static formAssociated=!0;#e;#t;#o;#i;#l=[];#r=[];#c=-1;#a=!1;#n="";#b="";#y;#g=!1;#u;#E;#s=[];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.#t.getAttribute("name");e&&(this.hasAttribute("name")||this.setAttribute("name",e),this.#t.removeAttribute("name"));let i=this.querySelector("ul, ol");if(!i)return!1;if(this.#o=i,this.#h){let h=this.querySelector(":scope > .tags-input-area");if(!h){h=document.createElement("div"),h.className="tags-input-area";let m=this.querySelector(":scope > pop-over[data-combobox-host]")||this.#o;this.insertBefore(h,m)}this.#u=h,this.#t.parentNode!==this.#u&&this.#u.appendChild(this.#t);let l=this.querySelector(":scope > [data-combobox-live]");l||(l=document.createElement("div"),l.setAttribute("aria-live","polite"),l.setAttribute("aria-atomic","true"),l.setAttribute("data-combobox-live",""),l.className="visually-hidden",this.appendChild(l)),this.#E=l}let o=this.getAttribute("placeholder");o&&!this.#t.getAttribute("placeholder")&&this.#t.setAttribute("placeholder",o);let s=`cb${++A}`;this.#o.id||(this.#o.id=`combobox-listbox-${s}`),this.#t.setAttribute("role","combobox"),this.#t.setAttribute("aria-expanded","false"),this.#t.setAttribute("aria-autocomplete","list"),this.#t.setAttribute("aria-controls",this.#o.id),this.#t.setAttribute("autocomplete","off"),this.#o.setAttribute("role","listbox"),this.#h&&this.#o.setAttribute("aria-multiselectable","true");let r=this.#h?this.#u:this.#t;r.id||(r.id=`combobox-anchor-${s}`);let a=this.querySelector(":scope > pop-over[data-combobox-host]");if(a?this.#i=a:(this.#i=document.createElement("pop-over"),this.#i.setAttribute("data-combobox-host",""),this.#i.id=`combobox-pop-${s}`,this.#i.dataset.mode="manual",this.#i.dataset.position="bottom-start",this.#i.dataset.anchor=r.id,this.#i.appendChild(this.#o),this.appendChild(this.#i)),this.#i.dataset.anchor=r.id,this.#o.parentElement!==this.#i&&this.#i.appendChild(this.#o),this.#N(),!this.#h){let h=this.getAttribute("value");h&&this.#A(h,!1),this.#y===void 0&&(this.#y=this.#n)}return this.listen(this.#t,"input",this.#P),this.listen(this.#t,"keydown",this.#T),this.listen(this.#t,"focus",this.#F),this.listen(this.#t,"click",this.#O),this.listen(this.#o,"click",this.#I),this.listen(this.#o,"pointerdown",this.#L),this.listen(document,"click",this.#W),this.listen(this.#i,"pop-over:hide",this.#H),this.listen(this,"invalid",this.#B),this.#f(),this.#p(),this.#d(),this.#k(this.matches(":disabled")),!0}teardown(){}#B=()=>{this.#t.setAttribute("aria-invalid","true")};formDisabledCallback(t){this.#t&&this.#k(t)}#k(t){this.#g=t,t&&this.#d();let e=this.#S(),i=this.#h&&e>0&&this.#s.length>=e;if(this.#t.disabled=t||i,this.#u)for(let o of this.#u.querySelectorAll(".tag button"))o.disabled=t}#N(){this.#l=Array.from(this.#o.querySelectorAll(":scope > li[data-value]")),this.#l.forEach((t,e)=>{t.setAttribute("role","option"),t.setAttribute("aria-selected","false"),t.id||(t.id=`${this.#o.id}-option-${e}`)}),this.#r=[...this.#l]}#x(t,e){if(this.#s.some(a=>a.value===t))return;let i=this.#S();if(i&&this.#s.length>=i)return;this.#s.push({value:t,label:e});let o=document.createElement("span");o.className="tag",o.dataset.value=t,o.textContent=e+" ";let s=document.createElement("button");s.type="button",s.setAttribute("aria-label",`Remove ${e}`),s.innerHTML="&times;",s.disabled=this.#g,s.addEventListener("click",a=>{a.stopPropagation(),this.#q(t)}),o.appendChild(s),this.#u.insertBefore(o,this.#t);let r=this.#l.find(a=>a.getAttribute("data-value")===t);r&&r.setAttribute("aria-selected","true"),this.#M(`${e} added`),this.#t.value="",this.#m(""),this.#f(),this.#p(),this.#V(),i&&this.#s.length>=i&&(this.#t.disabled=!0,this.#d())}#q(t){let e=this.#s.findIndex(a=>a.value===t);if(e===-1)return;let i=this.#s.splice(e,1)[0],o=this.#u.querySelector(`.tag[data-value="${CSS.escape(t)}"]`);o&&o.remove();let s=this.#l.find(a=>a.getAttribute("data-value")===t);s&&s.setAttribute("aria-selected","false"),this.#M(`${i.label} removed`),this.#S()&&this.#t.disabled&&(this.#t.disabled=this.#g),this.#m(this.#t.value.trim()),this.#f(),this.#p(),this.#V(),this.#t.focus()}#S(){let t=this.getAttribute("max");return t?parseInt(t,10):0}#M(t){this.#E&&(this.#E.textContent="",requestAnimationFrame(()=>{this.#E.textContent=t}))}#P=()=>{let t=this.#t.value.trim();if(!this.#h&&this.#n){let e=this.#o.querySelector('[aria-selected="true"]');e&&e.setAttribute("aria-selected","false"),this.#n="",this.#b="",this.removeAttribute("value"),this.#f(),this.#p()}this.#m(t),this.#v()};#T=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#a||this.#v(),this.#w(this.#c+1);break;case"ArrowUp":t.preventDefault(),this.#a||this.#v(),this.#w(this.#c-1);break;case"Home":this.#a&&(t.preventDefault(),this.#w(0));break;case"End":this.#a&&(t.preventDefault(),this.#w(this.#r.length-1));break;case"Enter":if(t.preventDefault(),this.#a&&this.#c>=0&&this.#r[this.#c]){let e=this.#r[this.#c];this.#h?this.#x(e.getAttribute("data-value"),e.textContent.trim()):this.#$(e)}else if(this.#h&&this.hasAttribute("custom")&&this.#t.value.trim()){let e=this.#t.value.trim();this.#x(e,e)}break;case"Backspace":if(this.#h&&!this.#t.value&&this.#s.length>0){let e=this.#s[this.#s.length-1];this.#q(e.value)}break;case",":if(this.#h&&this.hasAttribute("custom")&&this.#t.value.trim()){t.preventDefault();let e=this.#t.value.trim();this.#x(e,e)}break;case"Escape":this.#a&&(t.preventDefault(),t.stopPropagation(),this.#d(),this.#t.focus());break;case"Tab":this.#a&&this.#d();break}};#F=()=>{this.#h?(this.#m(this.#t.value.trim()),this.#v()):(this.#t.value||!this.#n)&&(this.#m(this.#t.value.trim()),this.#v())};#O=()=>{this.#a||(this.#m(this.#t.value.trim()),this.#v())};#I=t=>{let e=t.target.closest("li[data-value]");e&&this.#r.includes(e)&&(this.#h?this.#x(e.getAttribute("data-value"),e.textContent.trim()):this.#$(e))};#L=t=>{t.preventDefault()};#W=t=>{this.#a&&!this.contains(t.target)&&this.#d()};#m(t){let e=this.getAttribute("filter")||"contains",i=t.toLowerCase(),o=this.#h?new Set(this.#s.map(s=>s.value)):null;this.#r=[],this.#l.forEach(s=>{let r=s.getAttribute("data-value"),a=s.textContent.trim().toLowerCase();if(o&&o.has(r)){s.hidden=!0;return}let h;t?e==="startsWith"?h=a.startsWith(i):h=a.includes(i):h=!0,s.hidden=!h,h&&this.#r.push(s)}),this.#c=-1,this.#C(),this.setState("no-matches",this.#r.length===0)}#w(t){if(this.#r.length===0)return;t<0&&(t=this.#r.length-1),t>=this.#r.length&&(t=0),this.#c>=0&&this.#r[this.#c]&&this.#r[this.#c].removeAttribute("data-active"),this.#c=t;let e=this.#r[t];e.setAttribute("data-active",""),e.scrollIntoView({block:"nearest"}),this.#t.setAttribute("aria-activedescendant",e.id)}#C(){this.#l.forEach(t=>t.removeAttribute("data-active")),this.#t.removeAttribute("aria-activedescendant")}#$(t,e="internal"){let i=t.getAttribute("data-value")||"",o=t.textContent.trim();if(this.#n===i){this.#t.value=o,this.#d(),this.#t.focus();return}this.#l.forEach(s=>s.setAttribute("aria-selected","false")),t.setAttribute("aria-selected","true"),this.#n=i,this.#b=o,this.#t.value=o,this.setAttribute("value",i),this.#f(),this.#p(),this.#d(),this.#t.focus(),this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{value:i,label:o,source:e}}))}#A(t,e=!0,i="api"){let o=this.#l.find(s=>s.getAttribute("data-value")===t);o&&(e?this.#$(o,i):(this.#l.forEach(s=>s.setAttribute("aria-selected","false")),o.setAttribute("aria-selected","true"),this.#n=t,this.#b=o.textContent.trim(),this.#t.value=this.#b,this.setAttribute("value",t)))}#v(){this.#a||this.#g||(this.#a=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#i?.show(),this.dispatchEvent(new CustomEvent("combo-box:open",{bubbles:!0})))}#d(){this.#a&&(this.#a=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#c=-1,this.#C(),this.#i?.hide(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))}#H=()=>{this.#a&&(this.#a=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#c=-1,this.#C(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))};#f(){if(this.#h)if(this.#s.length>0){let t=new FormData,e=this.getAttribute("name")||"";for(let i of this.#s)t.append(e,i.value);this.#e.setFormValue(t)}else this.#e.setFormValue(null);else this.#n?this.#e.setFormValue(this.#n,this.#b):this.#e.setFormValue(null)}#p(){this.hasAttribute("required")?this.#h?this.#s.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({}),this.#e.validity.valid&&this.#t.removeAttribute("aria-invalid")}#V(){this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{values:this.#s.map(t=>t.value),labels:this.#s.map(t=>t.label),source:"internal"}}))}formResetCallback(){this.#h?(this.#u.querySelectorAll(".tag").forEach(t=>t.remove()),this.#s=[],this.#t.value="",this.#t.disabled=this.#g):(this.#n="",this.#b="",this.#t.value="",this.removeAttribute("value")),this.#l.forEach(t=>{t.setAttribute("aria-selected","false"),t.hidden=!1}),this.#r=[...this.#l],this.#c=-1,this.#C(),this.#d(),this.#t.removeAttribute("aria-invalid"),!this.#h&&this.#y&&this.#A(this.#y,!1),this.#f(),this.#p()}formStateRestoreCallback(t){t&&(this.#h||(this.#A(t,!1),this.#f(),this.#p()))}get value(){return this.#n}set value(t){t?this.#A(t):this.#D()}#D(){this.#l.forEach(t=>t.setAttribute("aria-selected","false")),this.#n="",this.#b="",this.#t&&(this.#t.value=""),this.removeAttribute("value"),this.#f(),this.#p()}get label(){return this.#b}get values(){return this.#s.map(t=>t.value)}get labels(){return this.#s.map(t=>t.label)}static get observedAttributes(){return["value","disabled"]}attributeChangedCallback(t,e,i){if(!this.#t)return;if(t==="disabled"){this.#k(this.matches(":disabled"));return}let o=i??"";t==="value"&&o!==this.#n&&(o?(this.#A(o,!1),this.#f(),this.#p()):this.#D())}};u("combo-box",p);export{p as ComboBox};
1
+ var N=window.matchMedia("(prefers-reduced-motion: reduce)");var E=new Map;function p(h,t,e={}){let i=e.priority??10,o={impl:t,bundle:e.bundle,contract:e.contract,priority:i},s=E.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}E.set(h,o),customElements.define(h,t)}var d=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}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,i,o){t.addEventListener(e,i,o),this.#e.push(()=>t.removeEventListener(e,i,o))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let i=this.#t.states;try{e?i.add(t):i.delete(t)}catch{let o=`--${t}`;e?i.add(o):i.delete(o)}}_adoptInternals(t){this.#t||(this.#t=t)}#i(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#i()?.validity}get validationMessage(){return this.#i()?.validationMessage??""}get willValidate(){return this.#i()?.willValidate??!1}get form(){return this.#i()?.form??null}checkValidity(){return this.#i()?.checkValidity()??!0}reportValidity(){return this.#i()?.reportValidity()??!0}};var b=CSS.supports("anchor-name","--x"),S=CSS.supports("position-area","bottom"),$=(()=>{let h=document.createElement("span");return h.setAttribute("popover","hint"),h.popover==="hint"})(),V=["auto","manual","hint"];function M(h){let t=V.includes(h||"")?h:"auto";return t==="hint"&&!$?"auto":t}var P=["top","bottom","left","right","inset-inline-start","inset-inline-end"],q=["position","top","left","right","bottom","margin"],x=8,D=0,O=0;function w(h){return!h||h==="none"?[]:h.split(",").map(t=>t.trim()).filter(Boolean)}var v=class extends d{static get observedAttributes(){return["data-mode","data-anchor","data-position"]}#e=null;#t=null;#i=`--pop-over-anchor-${++O}`;#s=!1;#h=!1;#o=!1;setup(){if(this.id||(this.id=`pop-over-${++D}`),(!this.hasAttribute("popover")||this.#s)&&this.#l(),this.#n(),this.#c(),this.listen(this,"beforetoggle",t=>{let e=t.newState==="open"?"show":"hide";this.dispatchEvent(new CustomEvent(`pop-over:${e}`,{detail:{state:t.newState},bubbles:!0,composed:!0})),!b&&t.newState==="open"&&this.#e&&queueMicrotask(()=>{this.matches(":popover-open")&&this.#f()})}),!b){let t=()=>{this.matches(":popover-open")&&this.#e&&this.#f()};this.listen(window,"resize",t),this.listen(window,"scroll",t,{capture:!0,passive:!0})}}teardown(){this.#d(),this.#h&&(P.forEach(t=>this.style.removeProperty(t)),this.#h=!1),this.#o&&(q.forEach(t=>this.style.removeProperty(t)),this.#o=!1),this.#e=null}attributeChangedCallback(t,e,i){if(e!==i){if(!this.hasAttribute("data-upgraded")){t==="data-mode"&&this.hasAttribute("popover")&&!this.isConnected&&(this.#s=!0);return}if(t==="data-mode"){this.#l();return}this._reinit()}}#l(){let t=M(this.dataset.mode);this.getAttribute("popover")!==t&&this.setAttribute("popover",t),this.#s=!0}show(){this.matches(":popover-open")||(this.showPopover(),!b&&this.#e&&this.matches(":popover-open")&&this.#f())}hide(){this.matches(":popover-open")&&this.hidePopover()}toggle(){this.matches(":popover-open")?this.hide():this.show()}get open(){return this.matches(":popover-open")}#n(){let t=this.dataset.anchor;if(t){let e=document.getElementById(t);if(!e)try{e=document.querySelector(t)}catch{e=null}this.#e=e}else this.#e=document.querySelector(`[popovertarget="${CSS.escape(this.id)}"]`)}#c(){if(!this.#e||!b)return;let t=this.#e,e=t.style.getPropertyValue("anchor-name"),i=w(e||getComputedStyle(t).getPropertyValue("anchor-name"));i.includes(this.#i)||i.push(this.#i),t.style.setProperty("anchor-name",i.join(", ")),this.#t=this.#i,this.style.setProperty("position-anchor",this.#i),this.setAttribute("data-anchor-name",this.#i),S||this.#v(this.dataset.position||"bottom")}#d(){if(this.#e&&this.#t){let t=w(this.#e.style.getPropertyValue("anchor-name")).filter(e=>e!==this.#t);t.length?this.#e.style.setProperty("anchor-name",t.join(", ")):this.#e.style.removeProperty("anchor-name")}this.#t=null,this.style.getPropertyValue("position-anchor")&&this.style.removeProperty("position-anchor"),this.hasAttribute("data-anchor-name")&&this.removeAttribute("data-anchor-name")}#v(t){let e="var(--_pop-over-offset, var(--size-xs))",i=t.endsWith("-end")?{"inset-inline-end":"anchor(end)"}:{"inset-inline-start":"anchor(start)"},o={top:{bottom:`calc(anchor(top) + ${e})`,...i},bottom:{top:`calc(anchor(bottom) + ${e})`,...i},left:{right:`calc(anchor(left) + ${e})`,top:"anchor(top)"},right:{left:`calc(anchor(right) + ${e})`,top:"anchor(top)"}},s=t.split("-")[0],n=o[s]||o.bottom;Object.entries(n).forEach(([a,r])=>this.style.setProperty(a,r)),this.#h=!0}#f(){if(!this.#e)return;let t=this.#e.getBoundingClientRect(),e=this.dataset.position||"bottom",i=this.#u(),o=document.documentElement.clientWidth,s=document.documentElement.clientHeight;this.style.position="fixed",this.style.margin="0",this.style.right="auto",this.style.bottom="auto",this.#o=!0;let n=this.offsetWidth,a=this.offsetHeight,r=e.split("-")[0];["top","bottom","left","right"].includes(r)||(r="bottom");let l={top:t.top-i,bottom:s-t.bottom-i,left:t.left-i,right:o-t.right-i},f={top:"bottom",bottom:"top",left:"right",right:"left"},C=r==="top"||r==="bottom"?a:n;l[r]<C&&l[f[r]]>l[r]&&(r=f[r]);let c,u;switch(r){case"top":c=t.top-a-i,u=t.left;break;case"left":c=t.top,u=t.left-n-i;break;case"right":c=t.top,u=t.right+i;break;default:c=t.bottom+i,u=t.left;break}if(r==="top"||r==="bottom"){let m=getComputedStyle(this).direction==="rtl";u=e.endsWith("-end")!==m?t.right-n:t.left}else e.endsWith("-end")&&(c=t.bottom-a);let A=(m,y,k)=>Math.max(x,Math.min(m,k-y-x));u=A(u,n,o),c=A(c,a,s),this.style.top=`${Math.round(c)}px`,this.style.left=`${Math.round(u)}px`}#u(){let t={none:0,xs:4,s:8,m:16,l:24};return t[this.dataset.offset||""]??t.xs}};p("pop-over",v);var I=0,g=class extends d{static formAssociated=!0;#e;#t;#i;#s;#h=[];#o=[];#l=-1;#n=!1;#c="";#d="";#v;#f=!1;#u;#E;#r=[];constructor(){super(),this.#e=this.attachInternals(),this._adoptInternals(this.#e)}get#a(){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.#t.getAttribute("name");e&&(this.hasAttribute("name")||this.setAttribute("name",e),this.#t.removeAttribute("name"));let i=this.querySelector("ul, ol");if(!i)return!1;if(this.#i=i,this.#a){let r=this.querySelector(":scope > .tags-input-area");if(!r){r=document.createElement("div"),r.className="tags-input-area";let f=this.querySelector(":scope > pop-over[data-combobox-host]")||this.#i;this.insertBefore(r,f)}this.#u=r,this.#t.parentNode!==this.#u&&this.#u.appendChild(this.#t);let l=this.querySelector(":scope > [data-combobox-live]");l||(l=document.createElement("div"),l.setAttribute("aria-live","polite"),l.setAttribute("aria-atomic","true"),l.setAttribute("data-combobox-live",""),l.className="visually-hidden",this.appendChild(l)),this.#E=l}let o=this.getAttribute("placeholder");o&&!this.#t.getAttribute("placeholder")&&this.#t.setAttribute("placeholder",o);let s=`cb${++I}`;this.#i.id||(this.#i.id=`combobox-listbox-${s}`),this.#t.setAttribute("role","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.#a&&this.#i.setAttribute("aria-multiselectable","true");let n=this.#a?this.#u:this.#t;n.id||(n.id=`combobox-anchor-${s}`);let a=this.querySelector(":scope > pop-over[data-combobox-host]");if(a?this.#s=a:(this.#s=document.createElement("pop-over"),this.#s.setAttribute("data-combobox-host",""),this.#s.id=`combobox-pop-${s}`,this.#s.dataset.mode="manual",this.#s.dataset.position="bottom-start",this.#s.dataset.anchor=n.id,this.#s.appendChild(this.#i),this.appendChild(this.#s)),this.#s.dataset.anchor=n.id,this.#i.parentElement!==this.#s&&this.#s.appendChild(this.#i),this.#O(),!this.#a){let r=this.getAttribute("value");r&&this.#y(r,!1),this.#v===void 0&&(this.#v=this.#c)}return this.listen(this.#t,"input",this.#I),this.listen(this.#t,"keydown",this.#N),this.listen(this.#t,"focus",this.#T),this.listen(this.#t,"click",this.#B),this.listen(this.#i,"click",this.#F),this.listen(this.#i,"pointerdown",this.#L),this.listen(document,"click",this.#R),this.listen(this.#s,"pop-over:hide",this.#_),this.listen(this,"invalid",this.#D),this.#b(),this.#m(),this.#p(),this.#k(this.matches(":disabled")),!0}teardown(){}#D=()=>{this.#t.setAttribute("aria-invalid","true")};formDisabledCallback(t){this.#t&&this.#k(t)}#k(t){this.#f=t,t&&this.#p();let e=this.#S(),i=this.#a&&e>0&&this.#r.length>=e;if(this.#t.disabled=t||i,this.#u)for(let o of this.#u.querySelectorAll(".tag button"))o.disabled=t}#O(){this.#h=Array.from(this.#i.querySelectorAll(":scope > li[data-value]")),this.#h.forEach((t,e)=>{t.setAttribute("role","option"),t.setAttribute("aria-selected","false"),t.id||(t.id=`${this.#i.id}-option-${e}`)}),this.#o=[...this.#h]}#x(t,e){if(this.#r.some(a=>a.value===t))return;let i=this.#S();if(i&&this.#r.length>=i)return;this.#r.push({value:t,label:e});let o=document.createElement("span");o.className="tag",o.dataset.value=t,o.textContent=e+" ";let s=document.createElement("button");s.type="button",s.setAttribute("aria-label",`Remove ${e}`),s.innerHTML="&times;",s.disabled=this.#f,s.addEventListener("click",a=>{a.stopPropagation(),this.#V(t)}),o.appendChild(s),this.#u.insertBefore(o,this.#t);let n=this.#h.find(a=>a.getAttribute("data-value")===t);n&&n.setAttribute("aria-selected","true"),this.#M(`${e} added`),this.#t.value="",this.#g(""),this.#b(),this.#m(),this.#P(),i&&this.#r.length>=i&&(this.#t.disabled=!0,this.#p())}#V(t){let e=this.#r.findIndex(a=>a.value===t);if(e===-1)return;let i=this.#r.splice(e,1)[0],o=this.#u.querySelector(`.tag[data-value="${CSS.escape(t)}"]`);o&&o.remove();let s=this.#h.find(a=>a.getAttribute("data-value")===t);s&&s.setAttribute("aria-selected","false"),this.#M(`${i.label} removed`),this.#S()&&this.#t.disabled&&(this.#t.disabled=this.#f),this.#g(this.#t.value.trim()),this.#b(),this.#m(),this.#P(),this.#t.focus()}#S(){let t=this.getAttribute("max");return t?parseInt(t,10):0}#M(t){this.#E&&(this.#E.textContent="",requestAnimationFrame(()=>{this.#E.textContent=t}))}#I=()=>{let t=this.#t.value.trim();if(!this.#a&&this.#c){let e=this.#i.querySelector('[aria-selected="true"]');e&&e.setAttribute("aria-selected","false"),this.#c="",this.#d="",this.removeAttribute("value"),this.#b(),this.#m()}this.#g(t),this.#A()};#N=t=>{switch(t.key){case"ArrowDown":t.preventDefault(),this.#n||this.#A(),this.#w(this.#l+1);break;case"ArrowUp":t.preventDefault(),this.#n||this.#A(),this.#w(this.#l-1);break;case"Home":this.#n&&(t.preventDefault(),this.#w(0));break;case"End":this.#n&&(t.preventDefault(),this.#w(this.#o.length-1));break;case"Enter":if(t.preventDefault(),this.#n&&this.#l>=0&&this.#o[this.#l]){let e=this.#o[this.#l];this.#a?this.#x(e.getAttribute("data-value"),e.textContent.trim()):this.#$(e)}else if(this.#a&&this.hasAttribute("custom")&&this.#t.value.trim()){let e=this.#t.value.trim();this.#x(e,e)}break;case"Backspace":if(this.#a&&!this.#t.value&&this.#r.length>0){let e=this.#r[this.#r.length-1];this.#V(e.value)}break;case",":if(this.#a&&this.hasAttribute("custom")&&this.#t.value.trim()){t.preventDefault();let e=this.#t.value.trim();this.#x(e,e)}break;case"Escape":this.#n&&(t.preventDefault(),t.stopPropagation(),this.#p(),this.#t.focus());break;case"Tab":this.#n&&this.#p();break}};#T=()=>{this.#a?(this.#g(this.#t.value.trim()),this.#A()):(this.#t.value||!this.#c)&&(this.#g(this.#t.value.trim()),this.#A())};#B=()=>{this.#n||(this.#g(this.#t.value.trim()),this.#A())};#F=t=>{let e=t.target.closest("li[data-value]");e&&this.#o.includes(e)&&(this.#a?this.#x(e.getAttribute("data-value"),e.textContent.trim()):this.#$(e))};#L=t=>{t.preventDefault()};#R=t=>{this.#n&&!this.contains(t.target)&&this.#p()};#g(t){let e=this.getAttribute("filter")||"contains",i=t.toLowerCase(),o=this.#a?new Set(this.#r.map(s=>s.value)):null;this.#o=[],this.#h.forEach(s=>{let n=s.getAttribute("data-value"),a=s.textContent.trim().toLowerCase();if(o&&o.has(n)){s.hidden=!0;return}let r;t?e==="startsWith"?r=a.startsWith(i):r=a.includes(i):r=!0,s.hidden=!r,r&&this.#o.push(s)}),this.#l=-1,this.#C(),this.setState("no-matches",this.#o.length===0)}#w(t){if(this.#o.length===0)return;t<0&&(t=this.#o.length-1),t>=this.#o.length&&(t=0),this.#l>=0&&this.#o[this.#l]&&this.#o[this.#l].removeAttribute("data-active"),this.#l=t;let e=this.#o[t];e.setAttribute("data-active",""),e.scrollIntoView({block:"nearest"}),this.#t.setAttribute("aria-activedescendant",e.id)}#C(){this.#h.forEach(t=>t.removeAttribute("data-active")),this.#t.removeAttribute("aria-activedescendant")}#$(t,e="internal"){let i=t.getAttribute("data-value")||"",o=t.textContent.trim();if(this.#c===i){this.#t.value=o,this.#p(),this.#t.focus();return}this.#h.forEach(s=>s.setAttribute("aria-selected","false")),t.setAttribute("aria-selected","true"),this.#c=i,this.#d=o,this.#t.value=o,this.setAttribute("value",i),this.#b(),this.#m(),this.#p(),this.#t.focus(),this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{value:i,label:o,source:e}}))}#y(t,e=!0,i="api"){let o=this.#h.find(s=>s.getAttribute("data-value")===t);o&&(e?this.#$(o,i):(this.#h.forEach(s=>s.setAttribute("aria-selected","false")),o.setAttribute("aria-selected","true"),this.#c=t,this.#d=o.textContent.trim(),this.#t.value=this.#d,this.setAttribute("value",t)))}#A(){this.#n||this.#f||(this.#n=!0,this.setAttribute("open",""),this.#t.setAttribute("aria-expanded","true"),this.#s?.show(),this.dispatchEvent(new CustomEvent("combo-box:open",{bubbles:!0})))}#p(){this.#n&&(this.#n=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#l=-1,this.#C(),this.#s?.hide(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))}#_=()=>{this.#n&&(this.#n=!1,this.removeAttribute("open"),this.#t.setAttribute("aria-expanded","false"),this.#l=-1,this.#C(),this.dispatchEvent(new CustomEvent("combo-box:close",{bubbles:!0})))};#b(){if(this.#a)if(this.#r.length>0){let t=new FormData,e=this.getAttribute("name")||"";for(let i of this.#r)t.append(e,i.value);this.#e.setFormValue(t)}else this.#e.setFormValue(null);else this.#c?this.#e.setFormValue(this.#c,this.#d):this.#e.setFormValue(null)}#m(){this.hasAttribute("required")?this.#a?this.#r.length===0?this.#e.setValidity({valueMissing:!0},"Please select at least one option",this.#t):this.#e.setValidity({}):this.#c?this.#e.setValidity({}):this.#e.setValidity({valueMissing:!0},"Please select an option",this.#t):this.#e.setValidity({}),this.#e.validity.valid&&this.#t.removeAttribute("aria-invalid")}#P(){this.dispatchEvent(new CustomEvent("combo-box:change",{bubbles:!0,detail:{values:this.#r.map(t=>t.value),labels:this.#r.map(t=>t.label),source:"internal"}}))}formResetCallback(){this.#a?(this.#u.querySelectorAll(".tag").forEach(t=>t.remove()),this.#r=[],this.#t.value="",this.#t.disabled=this.#f):(this.#c="",this.#d="",this.#t.value="",this.removeAttribute("value")),this.#h.forEach(t=>{t.setAttribute("aria-selected","false"),t.hidden=!1}),this.#o=[...this.#h],this.#l=-1,this.#C(),this.#p(),this.#t.removeAttribute("aria-invalid"),!this.#a&&this.#v&&this.#y(this.#v,!1),this.#b(),this.#m()}formStateRestoreCallback(t){t&&(this.#a||(this.#y(t,!1),this.#b(),this.#m()))}get value(){return this.#c}set value(t){t?this.#y(t):this.#q()}#q(){this.#h.forEach(t=>t.setAttribute("aria-selected","false")),this.#c="",this.#d="",this.#t&&(this.#t.value=""),this.removeAttribute("value"),this.#b(),this.#m()}get label(){return this.#d}get values(){return this.#r.map(t=>t.value)}get labels(){return this.#r.map(t=>t.label)}static get observedAttributes(){return["value","disabled"]}attributeChangedCallback(t,e,i){if(!this.#t)return;if(t==="disabled"){this.#k(this.matches(":disabled"));return}let o=i??"";t==="value"&&o!==this.#c&&(o?(this.#y(o,!1),this.#b(),this.#m()):this.#q())}};p("combo-box",g);export{g as ComboBox};
2
2
  //# sourceMappingURL=combo-box.js.map
@@ -1,2 +1,2 @@
1
- var f=/Mac|iPhone|iPad|iPod/.test(navigator.platform??""),E={mac:{meta:"\u2318",cmd:"\u2318",alt:"\u2325",shift:"\u21E7",ctrl:"\u2303"},other:{meta:"Ctrl",cmd:"Ctrl",alt:"Alt",shift:"Shift",ctrl:"Ctrl"}};function A(r){let t=f?E.mac:E.other;return r.split("+").map(e=>{let s=e.trim().toLowerCase();return t[s]??s.toUpperCase()}).join(f?"":"+")}function k(r){let t=r.toLowerCase().split("+").map(s=>s.trim());return{key:t.pop()??"",meta:t.includes("meta")||t.includes("cmd"),ctrl:t.includes("ctrl"),shift:t.includes("shift"),alt:t.includes("alt")}}function C(r,t){if(r.key.toLowerCase()!==t.key)return!1;let e,s;return f?(e=t.meta,s=t.ctrl):(e=!1,s=t.meta||t.ctrl),!(e!==r.metaKey||s!==r.ctrlKey||t.shift!==r.shiftKey||t.alt!==r.altKey)}var M=new Set(["INPUT","TEXTAREA","SELECT"]),h=[],w=!1;function N(r){let t=M.has(r.target.tagName)||r.target.isContentEditable;for(let e of h)if(!(t&&!e.global)&&C(r,e.descriptor)){r.preventDefault(),e.callback(r);return}}function S(){w||(document.addEventListener("keydown",N),w=!0)}function b(r,t,e={}){S();let s=k(r),i={combo:r,descriptor:s,callback:t,global:e.global===!0};return h.find(a=>a.combo===r)&&console.warn(`[hotkey-bind] Shortcut "${r}" already bound. Last-connected-wins.`),h.unshift(i),function(){let o=h.indexOf(i);o!==-1&&h.splice(o,1)}}var D=window.matchMedia("(prefers-reduced-motion: reduce)");var L=new Map;function m(r,t,e={}){let s=e.priority??10,i={impl:t,bundle:e.bundle,contract:e.contract,priority:s},n=L.get(r);if(customElements.get(r)){if(!n||n.priority>=s){n&&n.priority===s&&n.impl!==t&&console.warn(`[VB Bundle] Tag <${r}> already registered by "${n.bundle}" (priority ${n.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${r}> 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 <${r}> already registered by "${n.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}L.set(r,i),customElements.define(r,t)}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 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))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}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 x=0,y=class extends p{#e=null;#t;#s;#i=[];#n=-1;#c=[];#r=[];#o=[];#a="";#l=0;setup(){this.#a=`cmdp-${++x}`,this.#l=0,this.#y(),this.#g(),this.hasAttribute("discover")&&this.#E()}teardown(){this.#r.forEach(t=>t()),this.#r=[],this.#e?.remove(),this.#e=null,this.#i=[],this.#c=[],this.#o=[],this.#n=-1}get commands(){let t=[];for(let e of this.querySelectorAll("command-group")){let s=e.getAttribute("label")||"";for(let i of e.querySelectorAll("command-item"))t.push({value:i.getAttribute("value")||"",label:i.textContent.trim(),hotkey:i.getAttribute("data-hotkey")||void 0,group:s||void 0})}return t}set commands(t){let e=Array.isArray(t)?t:[],s=new Map;for(let i of e){let n=i.group||"";s.has(n)||s.set(n,[]),s.get(n).push(i)}for(let i of[...this.children])(i.tagName==="COMMAND-GROUP"||i.tagName==="COMMAND-ITEM")&&i.remove();for(let[i,n]of s){let a=document.createElement("command-group");i&&a.setAttribute("label",i);for(let o of n){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._reinit(),this.dispatchEvent(new CustomEvent("command-palette:commands-changed",{detail:{commands:e,source:"property"},bubbles:!0}))}#y(){this.#e=document.createElement("dialog"),this.#e.className="command-dialog",this.#e.setAttribute("aria-label",this.getAttribute("label")||"Command palette"),this.#e.addEventListener("click",s=>{s.target===this.#e&&this.close()}),this.#e.addEventListener("close",()=>{this.#t?.setAttribute("aria-expanded","false"),this.#t?.removeAttribute("aria-activedescendant"),this.dispatchEvent(new CustomEvent("command-palette:close",{bubbles:!0}))});let t=document.createElement("div");t.className="command-search",this.#s=document.createElement("div"),this.#s.className="command-list",this.#s.id=`${this.#a}-list`,this.#s.setAttribute("role","listbox"),this.#s.setAttribute("aria-label","Commands"),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.setAttribute("role","combobox"),this.#t.setAttribute("aria-autocomplete","list"),this.#t.setAttribute("aria-controls",this.#s.id),this.#t.setAttribute("aria-expanded","false"),this.#t.addEventListener("input",this.#u),this.#t.addEventListener("keydown",this.#v),t.appendChild(this.#t),this.#c=Array.from(this.querySelectorAll("command-group")),this.#c.forEach(s=>{let i=this.#d(s.getAttribute("label")||"");this.#s.appendChild(i),s.querySelectorAll("command-item").forEach(n=>{let a=n.querySelector('[slot="icon"]'),o=this.#m(n.textContent.trim(),a?a.cloneNode(!0):null,n.getAttribute("data-hotkey"));o.dataset.value=n.getAttribute("value")||"",o.addEventListener("click",()=>{this.#f(o.dataset.value)}),i.appendChild(o),this.#i.push({btn:o,group:i,source:n})})});let e=document.createElement("div");e.className="command-empty",e.textContent="No results found.",e.hidden=!0,this.#s.appendChild(e),this.#e.appendChild(t),this.#e.appendChild(this.#s),this.appendChild(this.#e)}#d(t){let e=document.createElement("div");e.className="command-group",e.setAttribute("role","group");let s=document.createElement("div");return s.className="command-group-header",s.id=`${this.#a}-g${++this.#l}`,s.setAttribute("aria-hidden","true"),s.textContent=t,t?e.setAttribute("aria-labelledby",s.id):s.hidden=!0,e.appendChild(s),e}#g(){let t=this.getAttribute("hotkey")||"meta+k";this.#r.push(b(t,()=>{this.#e?.open?this.close():this.open()},{global:!0}));for(let{btn:e,source:s}of this.#i){let i=s?.getAttribute("data-hotkey");if(!i||i.toLowerCase()===t.toLowerCase())continue;let n=e.dataset.value;this.#r.push(b(i,()=>this.#f(n)))}}#u=()=>{let t=this.#t.value.toLowerCase().trim(),e=0,s=new Set;this.#i.forEach(({btn:n,group:a})=>{let o=!t||(n.dataset.searchText??"").includes(t);n.hidden=!o,o&&(e++,s.add(a))}),this.#s.querySelectorAll(":scope > .command-group").forEach(n=>{n.hidden=!s.has(n)});let i=this.#s.querySelector(".command-empty");i&&(i.hidden=e>0),this.#n=-1,this.#i.forEach(({btn:n})=>{n.removeAttribute("data-active"),n.setAttribute("aria-selected","false")}),this.#t.removeAttribute("aria-activedescendant"),e>0&&this.#h(0)};#v=t=>{let e=this.#p();switch(t.key){case"ArrowDown":t.preventDefault(),this.#h(this.#n+1);break;case"ArrowUp":t.preventDefault(),this.#h(this.#n-1);break;case"Enter":t.preventDefault(),this.#n>=0&&e[this.#n]&&e[this.#n].btn.click();break;case"Escape":t.preventDefault(),this.close();break}};#p(){return this.#i.filter(({btn:t})=>!t.hidden)}#h(t){let e=this.#p();if(e.length===0)return;e.forEach(({btn:i})=>{i.removeAttribute("data-active"),i.setAttribute("aria-selected","false")}),t<0&&(t=e.length-1),t>=e.length&&(t=0),this.#n=t;let{btn:s}=e[t];s.setAttribute("data-active",""),s.setAttribute("aria-selected","true"),this.#t.setAttribute("aria-activedescendant",s.id),s.scrollIntoView({block:"nearest"})}#f(t){this.close(),this.dispatchEvent(new CustomEvent("command-palette:select",{bubbles:!0,detail:{value:t}}))}#E(){this.listen(document,"vb:command-registry-change",this.#A)}#A=()=>{this.#e?.open&&(this.#b(),this.#u())};#b(){if(!this.hasAttribute("discover"))return;let{getRegisteredCommands:t,scanAutoDiscoverable:e}=window.__commandRegistry||{};if(!t)return;this.#i=this.#i.filter(n=>!n.discovered),this.#o.forEach(n=>n.remove()),this.#o=[];let s=this.#s.querySelector(".command-empty"),i=t();for(let[n,a]of i){let o=this.#d(n);this.#s.insertBefore(o,s),this.#o.push(o);for(let c of a){if(this.contains(c.element))continue;let l=this.#m(c.label,c.icon,c.shortcut);l.dataset.value=`__discovered:${c.label}`,l.addEventListener("click",()=>{this.close(),c.element.click()}),o.appendChild(l),this.#i.push({btn:l,group:o,source:null,discovered:!0})}}if(this.getAttribute("discover")==="auto"&&e){let n=e(),a=new Map;for(let o of n){let c=a.get(o.group)||[];c.push(o),a.set(o.group,c)}for(let[o,c]of a){let l=this.#d(o);this.#s.insertBefore(l,s),this.#o.push(l);for(let d of c){if(this.contains(d.element))continue;let u=this.#m(d.label,d.icon,d.shortcut);u.dataset.value=`__auto:${d.label}`,u.dataset.auto="",u.addEventListener("click",()=>{this.close(),d.action?d.action():d.element.click()}),l.appendChild(u),this.#i.push({btn:u,group:l,source:null,discovered:!0})}}}}#m(t,e,s){let i=document.createElement("button");if(i.type="button",i.className="command-option",i.id=`${this.#a}-opt-${++this.#l}`,i.setAttribute("role","option"),i.setAttribute("aria-selected","false"),i.tabIndex=-1,i.dataset.searchText=t.toLowerCase(),e){let a=document.createElement("span");if(a.className="command-icon",typeof e=="string"){let o=document.createElement("icon-wc");o.setAttribute("name",e),a.appendChild(o)}else a.appendChild(e);i.appendChild(a)}let n=document.createElement("span");if(n.className="command-label",n.textContent=t,i.appendChild(n),s){let a=document.createElement("kbd");a.className="command-kbd",a.setAttribute("aria-hidden","true"),a.textContent=A(s),i.appendChild(a),i.setAttribute("aria-keyshortcuts",s)}return i}open(){!this.#e||this.#e.open||(this.#b(),this.#e.showModal(),this.#t.setAttribute("aria-expanded","true"),this.#t.value="",this.#u(),this.#t.focus(),this.dispatchEvent(new CustomEvent("command-palette:open",{bubbles:!0})))}close(){this.#e?.open&&this.#e.close()}get isOpen(){return this.#e?.open??!1}},g=class extends HTMLElement{},v=class extends HTMLElement{};m("command-palette",y);m("command-group",g);m("command-item",v);export{y as CommandPalette};
1
+ var d=/Mac|iPhone|iPad|iPod/.test(navigator.platform??""),v={mac:{meta:"\u2318",cmd:"\u2318",alt:"\u2325",option:"\u2325",shift:"\u21E7",ctrl:"\u2303",control:"\u2303"},other:{meta:"Ctrl",cmd:"Ctrl",alt:"Alt",option:"Alt",shift:"Shift",ctrl:"Ctrl",control:"Ctrl"}},C={mac:{meta:"Command",cmd:"Command",alt:"Option",option:"Option",shift:"Shift",ctrl:"Control",control:"Control"},other:{meta:"Control",cmd:"Control",alt:"Alt",option:"Alt",shift:"Shift",ctrl:"Control",control:"Control"}},H={escape:{label:"Esc",spoken:"Escape"},esc:{label:"Esc",spoken:"Escape"},enter:{label:"Enter",spoken:"Enter"},return:{label:"Enter",spoken:"Enter"},tab:{label:"Tab",spoken:"Tab"},space:{label:"Space",spoken:"Space"},backspace:{label:"Backspace",spoken:"Backspace"},delete:{label:"Del",spoken:"Delete"},del:{label:"Del",spoken:"Delete"},insert:{label:"Ins",spoken:"Insert"},home:{label:"Home",spoken:"Home"},end:{label:"End",spoken:"End"},pageup:{label:"PgUp",spoken:"Page up"},pagedown:{label:"PgDn",spoken:"Page down"},arrowup:{label:"\u2191",spoken:"Up arrow"},up:{label:"\u2191",spoken:"Up arrow"},arrowdown:{label:"\u2193",spoken:"Down arrow"},down:{label:"\u2193",spoken:"Down arrow"},arrowleft:{label:"\u2190",spoken:"Left arrow"},left:{label:"\u2190",spoken:"Left arrow"},arrowright:{label:"\u2192",spoken:"Right arrow"},right:{label:"\u2192",spoken:"Right arrow"},"+":{label:"+",spoken:"Plus"},plus:{label:"+",spoken:"Plus"}};function S(o){return[...String(o??"").trim().toLowerCase().matchAll(/([^+]+|\+)(?:\+|$)/g)].map(e=>e[1].trim()).filter(Boolean).map(e=>e==="plus"?"+":e)}function I(o,t=d){let e=t?v.mac:v.other;if(o in e)return{label:e[o],spoken:(t?C.mac:C.other)[o],modifier:!0};let n=H[o];if(n)return{...n,modifier:!1};let s=o.toUpperCase();return{label:s,spoken:s,modifier:!1}}function L(o){return S(o).map(t=>I(t).label).join(d?"":"+")}var O={esc:"escape",return:"enter",del:"delete",ins:"insert",up:"arrowup",down:"arrowdown",left:"arrowleft",right:"arrowright",space:" ",spacebar:" ",plus:"+",pgup:"pageup",pgdn:"pagedown"};function _(o){let t=String(o??"").toLowerCase();return O[t]??t}function p(o){let t=S(o);return{key:_(t.pop()??""),meta:t.includes("meta")||t.includes("cmd"),ctrl:t.includes("ctrl")||t.includes("control"),shift:t.includes("shift"),alt:t.includes("alt")||t.includes("option")}}function M(o){return o.length===1&&!/[a-z0-9 ]/.test(o)}function x(o,t){let n=(o.key==="Spacebar"?" ":String(o.key??"").toLowerCase())===t.key;if(!n&&(o.altKey||o.shiftKey)&&/^[a-z0-9]$/.test(t.key)){let a=/\d/.test(t.key)?`Digit${t.key}`:`Key${t.key.toUpperCase()}`;n=o.code===a}if(!n)return!1;let s,r;return d?(s=t.meta,r=t.ctrl):(s=!1,r=t.meta||t.ctrl),!(s!==o.metaKey||r!==o.ctrlKey||!M(t.key)&&t.shift!==o.shiftKey||t.alt!==o.altKey)}function N(o){let t=typeof o=="string"?p(o):o;return!t.meta&&!t.ctrl&&!t.alt&&t.key.length===1}function T(o,t){let e=p(o),n=p(t),s=d?e.ctrl:e.ctrl||e.meta,r=d?n.ctrl:n.ctrl||n.meta,a=d&&e.meta,i=d&&n.meta,c=!M(e.key);return e.key===n.key&&s===r&&a===i&&e.alt===n.alt&&(!c||e.shift===n.shift)}var g="data-char-shortcuts";var q="vb:settings:extensions";function y(){return typeof document>"u"?!0:document.documentElement.getAttribute(g)!=="off"}function P(){try{let o=globalThis.localStorage?.getItem(q);if(!o)return null;let t=JSON.parse(o)?.data?.charShortcuts;return typeof t=="boolean"?t:null}catch{return null}}var B=!0;if(typeof document<"u"){let o=P();o===null&&(B=y()),o===!1?document.documentElement.setAttribute(g,"off"):o===!0&&document.documentElement.removeAttribute(g)}var K=new Set(["INPUT","TEXTAREA","SELECT"]),m=[],$=!1;function R(o){let t=o;return!t||!t.tagName?!1:K.has(t.tagName)||t.isContentEditable}function U(o){if(o.repeat||o.isComposing||o.defaultPrevented)return;let t=R(o.target),e=!y(),n=document.activeElement;for(let s of m)if(!(t&&!s.global)&&!(s.scope&&!(s.scope.isConnected&&s.scope.contains(n)))&&!(e&&s.character&&!s.scope)&&!(s.enabled&&!s.enabled())&&x(o,s.descriptor)){o.preventDefault(),s.callback(o);return}}function V(){$||(document.addEventListener("keydown",U),$=!0)}function k(o,t,e={}){V();let n=p(o),s={combo:o,descriptor:n,callback:t,global:e.global===!0,scope:e.scope??null,enabled:typeof e.enabled=="function"?e.enabled:null,character:N(n)},r=m.find(a=>!a.scope&&!s.scope&&T(a.combo,o));return r&&console.warn(`[hotkey-bind] Shortcut "${o}" is already bound as "${r.combo}". Last-bound wins.`),m.unshift(s),function(){let i=m.indexOf(s);i!==-1&&m.splice(i,1)}}var X=window.matchMedia("(prefers-reduced-motion: reduce)");var D=new Map;function f(o,t,e={}){let n=e.priority??10,s={impl:t,bundle:e.bundle,contract:e.contract,priority:n},r=D.get(o);if(customElements.get(o)){if(!r||r.priority>=n){r&&r.priority===n&&r.impl!==t&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${r.bundle}" (priority ${r.priority}). Skipping "${e.bundle}".`);return}console.warn(`[VB Bundle] Tag <${o}> defined by "${r.bundle}" cannot be replaced (customElements.define is permanent). "${e.bundle}" has higher priority but arrived late.`);return}if(r&&r.priority>=n){r.priority===n&&console.warn(`[VB Bundle] Tag <${o}> already registered by "${r.bundle}". Skipping "${e.bundle}" (first wins at equal priority).`);return}D.set(o,s),customElements.define(o,t)}var b=class extends HTMLElement{#e=[];#t;constructor(){super(),this.hasAttribute("data-upgraded")&&this.removeAttribute("data-upgraded")}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,n,s){t.addEventListener(e,n,s),this.#e.push(()=>t.removeEventListener(e,n,s))}_reinit(){for(let t of this.#e)t();this.#e=[],this.teardown(),this.removeAttribute("data-upgraded"),this.isConnected&&this.setup()!==!1&&this.setAttribute("data-upgraded","")}setup(){}teardown(){}setState(t,e){this.#t||(this.#t=this.attachInternals());let n=this.#t.states;try{e?n.add(t):n.delete(t)}catch{let s=`--${t}`;e?n.add(s):n.delete(s)}}_adoptInternals(t){this.#t||(this.#t=t)}#s(){return this.constructor.formAssociated&&this.#t?this.#t:null}get validity(){return this.#s()?.validity}get validationMessage(){return this.#s()?.validationMessage??""}get willValidate(){return this.#s()?.willValidate??!1}get form(){return this.#s()?.form??null}checkValidity(){return this.#s()?.checkValidity()??!0}reportValidity(){return this.#s()?.reportValidity()??!0}};var F=0,E=class extends b{#e=null;#t;#s;#n=[];#o=-1;#c=[];#i=[];#r=[];#a="";#l=0;setup(){this.#a=`cmdp-${++F}`,this.#l=0,this.#g(),this.#y(),this.hasAttribute("discover")&&this.#E()}teardown(){this.#i.forEach(t=>t()),this.#i=[],this.#e?.remove(),this.#e=null,this.#n=[],this.#c=[],this.#r=[],this.#o=-1}get commands(){let t=[];for(let e of this.querySelectorAll("command-group")){let n=e.getAttribute("label")||"";for(let s of e.querySelectorAll("command-item"))t.push({value:s.getAttribute("value")||"",label:s.textContent.trim(),hotkey:s.getAttribute("data-hotkey")||void 0,group:n||void 0})}return t}set commands(t){let e=Array.isArray(t)?t:[],n=new Map;for(let s of e){let r=s.group||"";n.has(r)||n.set(r,[]),n.get(r).push(s)}for(let s of[...this.children])(s.tagName==="COMMAND-GROUP"||s.tagName==="COMMAND-ITEM")&&s.remove();for(let[s,r]of n){let a=document.createElement("command-group");s&&a.setAttribute("label",s);for(let i of r){let c=document.createElement("command-item");if(i.value&&c.setAttribute("value",i.value),i.hotkey&&c.setAttribute("data-hotkey",i.hotkey),i.icon){let l=document.createElement("span");l.setAttribute("slot","icon"),l.innerHTML=i.icon,c.appendChild(l)}c.appendChild(document.createTextNode(i.label||i.value||"")),a.appendChild(c)}this.appendChild(a)}this._reinit(),this.dispatchEvent(new CustomEvent("command-palette:commands-changed",{detail:{commands:e,source:"property"},bubbles:!0}))}#g(){this.#e=document.createElement("dialog"),this.#e.className="command-dialog",this.#e.setAttribute("aria-label",this.getAttribute("label")||"Command palette"),this.#e.addEventListener("click",n=>{n.target===this.#e&&this.close()}),this.#e.addEventListener("close",()=>{this.#t?.setAttribute("aria-expanded","false"),this.#t?.removeAttribute("aria-activedescendant"),this.dispatchEvent(new CustomEvent("command-palette:close",{bubbles:!0}))});let t=document.createElement("div");t.className="command-search",this.#s=document.createElement("div"),this.#s.className="command-list",this.#s.id=`${this.#a}-list`,this.#s.setAttribute("role","listbox"),this.#s.setAttribute("aria-label","Commands"),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.setAttribute("role","combobox"),this.#t.setAttribute("aria-autocomplete","list"),this.#t.setAttribute("aria-controls",this.#s.id),this.#t.setAttribute("aria-expanded","false"),this.#t.addEventListener("input",this.#d),this.#t.addEventListener("keydown",this.#k),t.appendChild(this.#t),this.#c=Array.from(this.querySelectorAll("command-group")),this.#c.forEach(n=>{let s=this.#u(n.getAttribute("label")||"");this.#s.appendChild(s),n.querySelectorAll("command-item").forEach(r=>{let a=r.querySelector('[slot="icon"]'),i=this.#p(r.textContent.trim(),a?a.cloneNode(!0):null,r.getAttribute("data-hotkey"));i.dataset.value=r.getAttribute("value")||"",i.addEventListener("click",()=>{this.#f(i.dataset.value)}),s.appendChild(i),this.#n.push({btn:i,group:s,source:r})})});let e=document.createElement("div");e.className="command-empty",e.textContent="No results found.",e.hidden=!0,this.#s.appendChild(e),this.#e.appendChild(t),this.#e.appendChild(this.#s),this.appendChild(this.#e)}#u(t){let e=document.createElement("div");e.className="command-group",e.setAttribute("role","group");let n=document.createElement("div");return n.className="command-group-header",n.id=`${this.#a}-g${++this.#l}`,n.setAttribute("aria-hidden","true"),n.textContent=t,t?e.setAttribute("aria-labelledby",n.id):n.hidden=!0,e.appendChild(n),e}#y(){let t=this.getAttribute("hotkey")||"meta+k";this.#i.push(k(t,()=>{this.#e?.open?this.close():this.open()},{global:!0}));for(let{btn:e,source:n}of this.#n){let s=n?.getAttribute("data-hotkey");if(!s||s.toLowerCase()===t.toLowerCase())continue;let r=e.dataset.value;this.#i.push(k(s,()=>this.#f(r)))}}#d=()=>{let t=this.#t.value.toLowerCase().trim(),e=0,n=new Set;this.#n.forEach(({btn:r,group:a})=>{let i=!t||(r.dataset.searchText??"").includes(t);r.hidden=!i,i&&(e++,n.add(a))}),this.#s.querySelectorAll(":scope > .command-group").forEach(r=>{r.hidden=!n.has(r)});let s=this.#s.querySelector(".command-empty");s&&(s.hidden=e>0),this.#o=-1,this.#n.forEach(({btn:r})=>{r.removeAttribute("data-active"),r.setAttribute("aria-selected","false")}),this.#t.removeAttribute("aria-activedescendant"),e>0&&this.#h(0)};#k=t=>{let e=this.#m();switch(t.key){case"ArrowDown":t.preventDefault(),this.#h(this.#o+1);break;case"ArrowUp":t.preventDefault(),this.#h(this.#o-1);break;case"Enter":t.preventDefault(),this.#o>=0&&e[this.#o]&&e[this.#o].btn.click();break;case"Escape":t.preventDefault(),this.close();break}};#m(){return this.#n.filter(({btn:t})=>!t.hidden)}#h(t){let e=this.#m();if(e.length===0)return;e.forEach(({btn:s})=>{s.removeAttribute("data-active"),s.setAttribute("aria-selected","false")}),t<0&&(t=e.length-1),t>=e.length&&(t=0),this.#o=t;let{btn:n}=e[t];n.setAttribute("data-active",""),n.setAttribute("aria-selected","true"),this.#t.setAttribute("aria-activedescendant",n.id),n.scrollIntoView({block:"nearest"})}#f(t){this.close(),this.dispatchEvent(new CustomEvent("command-palette:select",{bubbles:!0,detail:{value:t}}))}#E(){this.listen(document,"vb:command-registry-change",this.#A)}#A=()=>{this.#e?.open&&(this.#b(),this.#d())};#b(){if(!this.hasAttribute("discover"))return;let{getRegisteredCommands:t,scanAutoDiscoverable:e}=window.__commandRegistry||{};if(!t)return;this.#n=this.#n.filter(r=>!r.discovered),this.#r.forEach(r=>r.remove()),this.#r=[];let n=this.#s.querySelector(".command-empty"),s=t();for(let[r,a]of s){let i=this.#u(r);this.#s.insertBefore(i,n),this.#r.push(i);for(let c of a){if(this.contains(c.element))continue;let l=this.#p(c.label,c.icon,c.shortcut);l.dataset.value=`__discovered:${c.label}`,l.addEventListener("click",()=>{this.close(),c.element.click()}),i.appendChild(l),this.#n.push({btn:l,group:i,source:null,discovered:!0})}}if(this.getAttribute("discover")==="auto"&&e){let r=e(),a=new Map;for(let i of r){let c=a.get(i.group)||[];c.push(i),a.set(i.group,c)}for(let[i,c]of a){let l=this.#u(i);this.#s.insertBefore(l,n),this.#r.push(l);for(let u of c){if(this.contains(u.element))continue;let h=this.#p(u.label,u.icon,u.shortcut);h.dataset.value=`__auto:${u.label}`,h.dataset.auto="",h.addEventListener("click",()=>{this.close(),u.action?u.action():u.element.click()}),l.appendChild(h),this.#n.push({btn:h,group:l,source:null,discovered:!0})}}}}#p(t,e,n){let s=document.createElement("button");if(s.type="button",s.className="command-option",s.id=`${this.#a}-opt-${++this.#l}`,s.setAttribute("role","option"),s.setAttribute("aria-selected","false"),s.tabIndex=-1,s.dataset.searchText=t.toLowerCase(),e){let a=document.createElement("span");if(a.className="command-icon",typeof e=="string"){let i=document.createElement("icon-wc");i.setAttribute("name",e),a.appendChild(i)}else a.appendChild(e);s.appendChild(a)}let r=document.createElement("span");if(r.className="command-label",r.textContent=t,s.appendChild(r),n){let a=document.createElement("kbd");a.className="command-kbd",a.setAttribute("aria-hidden","true"),a.textContent=L(n),s.appendChild(a),s.setAttribute("aria-keyshortcuts",n)}return s}open(){!this.#e||this.#e.open||(this.#b(),this.#e.showModal(),this.#t.setAttribute("aria-expanded","true"),this.#t.value="",this.#d(),this.#t.focus(),this.dispatchEvent(new CustomEvent("command-palette:open",{bubbles:!0})))}close(){this.#e?.open&&this.#e.close()}get isOpen(){return this.#e?.open??!1}},A=class extends HTMLElement{},w=class extends HTMLElement{};f("command-palette",E);f("command-group",A);f("command-item",w);export{E as CommandPalette};
2
2
  //# sourceMappingURL=command-palette.js.map