@macrulez/devtoolz 0.4.1 → 0.4.3

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 (90) hide show
  1. package/README.md +16 -1
  2. package/dist/cli.js +2 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/image-batch/cli.js +16 -0
  5. package/dist/commands/image-batch/cli.js.map +1 -1
  6. package/dist/commands/image-batch/config.d.ts +1 -0
  7. package/dist/commands/image-batch/config.js +11 -0
  8. package/dist/commands/image-batch/config.js.map +1 -1
  9. package/dist/commands/image-batch/run.d.ts +5 -1
  10. package/dist/commands/image-batch/run.js +7 -0
  11. package/dist/commands/image-batch/run.js.map +1 -1
  12. package/dist/commands/image-hash/sharp-loader.d.ts +3 -0
  13. package/dist/commands/image-hash/sharp-loader.js.map +1 -1
  14. package/dist/commands/ui/cli.d.ts +2 -0
  15. package/dist/commands/ui/cli.js +78 -0
  16. package/dist/commands/ui/cli.js.map +1 -0
  17. package/dist/commands/ui/fs-routes.d.ts +7 -0
  18. package/dist/commands/ui/fs-routes.js +135 -0
  19. package/dist/commands/ui/fs-routes.js.map +1 -0
  20. package/dist/commands/ui/http.d.ts +41 -0
  21. package/dist/commands/ui/http.js +81 -0
  22. package/dist/commands/ui/http.js.map +1 -0
  23. package/dist/commands/ui/jobs.d.ts +15 -0
  24. package/dist/commands/ui/jobs.js +73 -0
  25. package/dist/commands/ui/jobs.js.map +1 -0
  26. package/dist/commands/ui/modules/checks.d.ts +28 -0
  27. package/dist/commands/ui/modules/checks.js +556 -0
  28. package/dist/commands/ui/modules/checks.js.map +1 -0
  29. package/dist/commands/ui/modules/cleanup.d.ts +2 -0
  30. package/dist/commands/ui/modules/cleanup.js +305 -0
  31. package/dist/commands/ui/modules/cleanup.js.map +1 -0
  32. package/dist/commands/ui/modules/image-batch-backups.d.ts +2 -0
  33. package/dist/commands/ui/modules/image-batch-backups.js +116 -0
  34. package/dist/commands/ui/modules/image-batch-backups.js.map +1 -0
  35. package/dist/commands/ui/modules/image-batch-manage.d.ts +2 -0
  36. package/dist/commands/ui/modules/image-batch-manage.js +245 -0
  37. package/dist/commands/ui/modules/image-batch-manage.js.map +1 -0
  38. package/dist/commands/ui/modules/image-batch.d.ts +2 -0
  39. package/dist/commands/ui/modules/image-batch.js +225 -0
  40. package/dist/commands/ui/modules/image-batch.js.map +1 -0
  41. package/dist/commands/ui/modules/image-hash.d.ts +2 -0
  42. package/dist/commands/ui/modules/image-hash.js +158 -0
  43. package/dist/commands/ui/modules/image-hash.js.map +1 -0
  44. package/dist/commands/ui/modules/index.d.ts +2 -0
  45. package/dist/commands/ui/modules/index.js +11 -0
  46. package/dist/commands/ui/modules/index.js.map +1 -0
  47. package/dist/commands/ui/open-browser.d.ts +1 -0
  48. package/dist/commands/ui/open-browser.js +18 -0
  49. package/dist/commands/ui/open-browser.js.map +1 -0
  50. package/dist/commands/ui/scan.d.ts +20 -0
  51. package/dist/commands/ui/scan.js +57 -0
  52. package/dist/commands/ui/scan.js.map +1 -0
  53. package/dist/commands/ui/server.d.ts +18 -0
  54. package/dist/commands/ui/server.js +196 -0
  55. package/dist/commands/ui/server.js.map +1 -0
  56. package/dist/ui/assets/ChecksPage-Ia4QJkV3.js +1 -0
  57. package/dist/ui/assets/ChecksPage-VewKhd5A.css +1 -0
  58. package/dist/ui/assets/CleanupPage-DqqrgWSI.js +4 -0
  59. package/dist/ui/assets/CleanupPage-nxJE8S0P.css +1 -0
  60. package/dist/ui/assets/FolderBrowser-Cdzt7edI.js +1 -0
  61. package/dist/ui/assets/FolderBrowser-CkH9R4jg.css +1 -0
  62. package/dist/ui/assets/ImageBatchPage-9HgS9uVf.js +4 -0
  63. package/dist/ui/assets/ImageBatchPage-EhlvnXbP.css +1 -0
  64. package/dist/ui/assets/ImageHashPage-BT4S8t3Y.css +1 -0
  65. package/dist/ui/assets/ImageHashPage-C0ltmpOF.js +1 -0
  66. package/dist/ui/assets/SourcePicker-6fQmtLgo.css +1 -0
  67. package/dist/ui/assets/SourcePicker-xk00AG2e.js +1 -0
  68. package/dist/ui/assets/UiSegmented-BT3dOelo.css +1 -0
  69. package/dist/ui/assets/UiSegmented-CsTRUZoX.js +1 -0
  70. package/dist/ui/assets/core-DVezgdzc.js +12 -0
  71. package/dist/ui/assets/css-Z72CF80r.js +1 -0
  72. package/dist/ui/assets/engine-javascript-CNmxVhbB.js +141 -0
  73. package/dist/ui/assets/github-dark-DHJKELXO.js +1 -0
  74. package/dist/ui/assets/github-light-DAi9KRSo.js +1 -0
  75. package/dist/ui/assets/highlight-DT7vvdYt.js +2 -0
  76. package/dist/ui/assets/html-BlS82ilI.js +1 -0
  77. package/dist/ui/assets/index-Ch5kTxCO.css +1 -0
  78. package/dist/ui/assets/index-D8H-zVzo.js +11 -0
  79. package/dist/ui/assets/javascript-wDzz0qaB.js +1 -0
  80. package/dist/ui/assets/json-Cp-IABpG.js +1 -0
  81. package/dist/ui/assets/jsx-g9-lgVsj.js +1 -0
  82. package/dist/ui/assets/markdown-Cvjx9yec.js +1 -0
  83. package/dist/ui/assets/scss-Cw6XMfVs.js +1 -0
  84. package/dist/ui/assets/tsx-COt5Ahok.js +1 -0
  85. package/dist/ui/assets/typescript-BPQ3VLAy.js +1 -0
  86. package/dist/ui/assets/useCopy-i_vlQfC-.js +1 -0
  87. package/dist/ui/assets/vue-CwSeJimo.js +1 -0
  88. package/dist/ui/assets/yaml-Buea-lGh.js +1 -0
  89. package/dist/ui/index.html +17 -0
  90. package/package.json +17 -4
@@ -0,0 +1 @@
1
+ import{d as _e,G as Xe,x as V,q as Me,w as Fe,e as Ve,H as ke,r as O,a as Se,o as _,c as k,I as Ge,D as rt,h as u,s as me,F as re,b as ue,i as J,t as C,l as L,j as le,p as lt,E as He,g as Ee,y as yt,J as gt,n as Oe,k as ve,z as Le,K as Ye}from"./index-D8H-zVzo.js";import{S as pt}from"./SourcePicker-xk00AG2e.js";import{u as it}from"./useCopy-i_vlQfC-.js";import{U as bt}from"./FolderBrowser-Cdzt7edI.js";function _t(t,n,s,e){if(t==="auto")return Math.max(1,Math.floor((n+e)/(s+e)));if(typeof t=="number")return Math.max(1,Math.floor(t));const a=Object.keys(t).filter(c=>c!=="default").map(Number).sort((c,o)=>c-o);for(const c of a)if(n<=c)return Math.max(1,Math.floor(t[c]));return Math.max(1,Math.floor(t.default))}function wt(t,n,s){return Math.max(0,(t-(n-1)*s)/n)}function kt(t,n){return n!==void 0?Math.max(1,Math.floor(n)):t===void 0||t==="auto"?2:typeof t=="number"?Math.max(1,Math.floor(t)):Math.max(1,Math.floor(t.default))}function xt(t,n,s,e="balanced"){const a=Math.max(1,Math.floor(n)||1),c=new Array(a).fill(0),o=[];let i=0;for(const M of t){const w=Math.min(Math.max(1,Math.floor(M.span)||1),a);let y;if(e==="ordered")y=i+w<=a?i:0,i=y+w,i>=a&&(i=0);else{let g=0,I=1/0;for(let b=0;b<=a-w;b++){let v=0;for(let z=b;z<b+w;z++)v=Math.max(v,c[z]);v<I&&(I=v,g=b)}y=g}let h=0;for(let g=y;g<y+w;g++)h=Math.max(h,c[g]);o.push({id:M.id,laneIndex:y,span:w,mainPos:h});const S=h+M.mainSize+s;for(let g=y;g<y+w;g++)c[g]=S}const m=o.length?Math.max(0,Math.max(...c)-s):0;return{items:o,totalMainSize:m}}function Mt(t){const n=new Set;let s=!1;function e(){s||(s=!0,requestAnimationFrame(()=>{s=!1,t()}))}const a=typeof ResizeObserver>"u"?null:new ResizeObserver(e);return{observe(c){n.has(c)||(n.add(c),a?.observe(c))},unobserveAll(){for(const c of n)a?.unobserve(c);n.clear()},scheduleNow:e,destroy(){a?.disconnect(),n.clear()}}}var St=240,Je=16,Ze=600,Ct=250,It="cubic-bezier(0.2, 0, 0, 1)";function Re(t){return typeof t.el=="function"?t.el():t.el??null}function zt(t){return(t instanceof HTMLImageElement?[t]:Array.from(t.querySelectorAll("img"))).filter(s=>!s.complete)}function At(t,n={}){const s=n.direction??"vertical",e=n.minLaneSize??St,a=n.placement??"balanced",c=typeof n.gap=="number"?n.gap:n.gap?.main??Je,o=typeof n.gap=="number"?n.gap:n.gap?.cross??Je,i=s==="horizontal"?n.rows??"auto":n.columns??"auto",m=!!n.virtualize,M=typeof n.virtualize=="object"?n.virtualize.overscan??Ze:Ze,w=n.scrollContainer??(s==="vertical"?"window":"self"),y=n.estimateSize,h=n.animate??!0,S=n.transitionDuration??Ct,g=n.transitionEasing??It,I=`transform ${S}ms ${g}, opacity ${S}ms ${g}`;t.style.position="relative",h&&(t.style.setProperty("--mk-transition-duration",`${S}ms`),t.style.setProperty("--mk-transition-easing",g));let b=null;s==="horizontal"?(t.style.overflowX="auto",t.style.overflowY="hidden",b=document.createElement("div"),b.setAttribute("aria-hidden","true"),b.style.position="absolute",b.style.top="0",b.style.left="0",b.style.width="1px",b.style.height="1px",b.style.visibility="hidden",b.style.pointerEvents="none",t.appendChild(b)):t.style.overflowX="clip";const v=new Map;let z=[],E=[],j=[];const R=new Map,U=new WeakSet;let Z=!1,Q=null;const se=new Map;function de(r,f){for(const p of se.get(r)??[])p(f)}const D=Mt(l);function F(){D.scheduleNow()}const $=m?w==="window"?window:w==="self"?t:w:null;$?.addEventListener("scroll",F,{passive:!0});function ee(){return z.map((r,f)=>({id:r,key:v.get(r)?.order??f})).sort((r,f)=>r.key-f.key).map(r=>r.id)}function G(){D.unobserveAll(),D.observe(t);for(const r of z){const f=Re(v.get(r));f&&D.observe(f)}}function q(r){if(!h)return;const f=v.get(r),p=f?Re(f):null;p&&(p.classList.add("mk-item-leave"),p.style.transition=I,p.style.opacity="0")}function W(r){const f=p=>{p.target===r&&(r.style.willChange="auto",r.classList.remove("mk-item-moving"),r.removeEventListener("transitionend",f))};r.style.willChange="transform",r.addEventListener("transitionend",f)}function T(r,f,p){const P=`translate(${f}px, ${p}px)`;return r.style.transform===""?h?(r.style.transition="none",r.style.transform=P,r.style.opacity="0",r.classList.add("mk-item-enter"),!0):(r.style.transform=P,!1):(r.style.transform===P||(h&&(r.style.transition=I,r.classList.add("mk-item-moving"),W(r)),r.style.transform=P),!1)}function te(){if(w==="self"){const x=s==="vertical"?t.scrollTop:t.scrollLeft,N=s==="vertical"?t.clientHeight:t.clientWidth;return[x-M,x+N+M]}const r=t.getBoundingClientRect(),f=s==="vertical"?r.top:r.left;let p,P;if(w==="window")p=0,P=s==="vertical"?window.innerHeight:window.innerWidth;else{const x=w.getBoundingClientRect();p=s==="vertical"?x.top:x.left,P=s==="vertical"?w.clientHeight:w.clientWidth}return[p-f-M,p+P-f+M]}function K(r,f){if(m&&r.estimatedSize!==void 0)return r.estimatedSize;if(r.aspectRatio)return s==="vertical"?f/r.aspectRatio:f*r.aspectRatio;if(!m)return;if(y)return y(r);Z||(Z=!0,console.warn("[masonry-kit] `virtualize` is on but an item has no `estimatedSize`, no `aspectRatio`, and `estimateSize` returned nothing — falling back to a guessed size. Set one of these for accurate initial positions."));const p=[...R.values()];return p.length>0?p.reduce((P,x)=>P+x,0)/p.length:f}function l(){const r=t.getBoundingClientRect(),f=s==="vertical"?r.width:r.height,p=_t(i,f,e,o),P=wt(f,p,o),x=ee().filter(A=>A!==Q),N=new Map,B=new Map,ne=new Map;for(const A of x){const ie=v.get(A),he=s==="vertical"?ie.colSpan??1:ie.rowSpan??1,oe=Math.min(Math.max(1,Math.floor(he)||1),p);B.set(A,oe);const H=oe*P+(oe-1)*o;ne.set(A,H);const X=Re(ie);X&&(N.set(A,X),X.style.position="absolute",X.style.top="0",X.style.left="0",s==="vertical"?X.style.width=`${H}px`:X.style.height=`${H}px`)}const fe=new Map,We=[];for(const A of x){const ie=v.get(A),he=ne.get(A),oe=N.get(A);let H;if(oe){const X=zt(oe);if(X.length===0){const ae=s==="vertical"?oe.getBoundingClientRect().height:oe.getBoundingClientRect().width;ae>0&&(H=ae,R.set(A,ae))}else for(const ae of X)U.has(ae)||(U.add(ae),ae.addEventListener("load",l,{once:!0}),ae.addEventListener("error",l,{once:!0}))}H===void 0&&(H=R.get(A)),H===void 0&&(H=K(ie,he)),H!==void 0&&(fe.set(A,H),We.push({id:A,span:B.get(A),mainSize:H}))}const{items:mt,totalMainSize:Ke}=xt(We,p,c,a),Ce=m?te():null,Ie=[],ze=[],we=[];for(const A of mt){const ie=ne.get(A.id),he=fe.get(A.id),oe=A.laneIndex*(P+o),H=s==="vertical"?oe:A.mainPos,X=s==="vertical"?A.mainPos:oe,ae=s==="vertical"?ie:he,vt=s==="vertical"?he:ie,Ae=N.get(A.id);Ae&&T(Ae,H,X)&&we.push(Ae),Ie.push({id:A.id,x:H,y:X,width:ae,height:vt}),(!Ce||A.mainPos+he>=Ce[0]&&A.mainPos<=Ce[1])&&ze.push(A.id)}if(s==="vertical"?t.style.height=`${Ke}px`:b&&(b.style.transform=`translate(${Ke}px, 0)`),we.length>0){we[0].offsetHeight;for(const A of we)A.style.transition=I,A.style.opacity="1",W(A)}E=Ie,j=ze,de("layout",{items:Ie,visibleIds:ze})}function d(r){const f=new Set(r.map(p=>p.id));for(const p of z)f.has(p)||(q(p),R.delete(p));v.clear(),z=r.map(p=>p.id);for(const p of r)v.set(p.id,p);G()}return D.observe(t),{setItems(r){d(r),l()},updateItem(r,f){const p=v.get(r);p&&(v.set(r,{...p,...f}),G(),l())},addItem(r,f){v.set(r.id,r),f===void 0||f>=z.length?z.push(r.id):z.splice(f,0,r.id),G(),l()},removeItem(r){q(r),v.delete(r),z=z.filter(f=>f!==r),R.delete(r),G(),l()},relayout:l,getLayout(){return[...E]},getVisibleIds(){return[...j]},setDragging(r){Q!==r&&(Q=r,l())},on(r,f){se.has(r)||se.set(r,new Set);const p=se.get(r);return p.add(f),()=>p.delete(f)},destroy(){D.destroy(),$?.removeEventListener("scroll",F),b?.remove(),v.clear(),z=[],E=[],j=[],R.clear(),Q=null,se.clear()}}}function ct(t,n){if(t===n)return!0;if(typeof t!="object"||typeof n!="object"||t===null||n===null||typeof Node<"u"&&(t instanceof Node||n instanceof Node))return!1;const s=Object.keys(t),e=Object.keys(n);return s.length!==e.length?!1:s.every(a=>ct(t[a],n[a]))}function Et(t,n){if(t===n)return!0;const s=new Set([...Object.keys(t),...Object.keys(n)]);for(const e of s)if(!ct(t[e],n[e]))return!1;return!0}var ce={},Qe=new WeakMap,Ot=0;function Y(t){if(t.id!==void 0)return t.id;let n=Qe.get(t);return n===void 0&&(n=`mk-auto-${++Ot}`,Qe.set(t,n)),n}var Lt=0,$e={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"},Rt=_e({name:"MasonryGrid",props:{items:{type:Array,required:!0},options:{type:Object,default:()=>({})},sortable:{type:Boolean,default:!1}},emits:["layout","reorder"],setup(t,{slots:n,emit:s}){const e=`mk-${++Lt}`,a=O(null),c=new Map,o=new Map;let i=null,m=null,M=null,w=null,y=!1;const h=Xe(t.options.virtualize?new Set:null),S=O(!1),g=Xe(new Map),I=new Map;let b=new Set;const v=V(()=>{const l=h.value===null?t.items:t.items.filter(f=>h.value.has(Y(f)));if(g.value.size===0)return l;const d=new Set(l.map(f=>Y(f))),r=[...g.value.values()].filter(f=>!d.has(Y(f)));return r.length===0?l:[...l,...r]});function z(l,d){if(l.size!==d.size)return!1;for(const r of l)if(!d.has(r))return!1;return!0}function E(){return t.options.animate??ce.animate??!0}function j(){return t.options.transitionDuration??ce.transitionDuration??250}function R(){const l=t.options.gap??ce.gap;return typeof l=="number"?{main:l,cross:l}:{main:l?.main??16,cross:l?.cross??16}}function U(){const d=(t.options.direction??ce.direction)==="horizontal"?t.options.rows??ce.rows:t.options.columns??ce.columns;return kt(d,t.options.ssrColumns??ce.ssrColumns)}function Z(l){const d=new Set(l.map(f=>Y(f)));for(const f of l)I.set(Y(f),f);let r=null;for(const f of b){if(d.has(f)||g.value.has(f)||!c.get(f)||!E())continue;const p=I.get(f);p&&(r??(r=new Map(g.value)),r.set(f,p),setTimeout(()=>{const P=new Map(g.value);P.delete(f),g.value=P,I.delete(f)},j()))}r&&(g.value=r),b=d}function Q(){if(!i)return;const l=t.items.map(d=>{const r=Y(d);return{id:r,el:c.get(r),colSpan:d.colSpan,rowSpan:d.rowSpan,aspectRatio:d.aspectRatio,estimatedSize:d.estimatedSize,order:d.order}});i.setItems(l)}function se(){y||(y=!0,queueMicrotask(()=>{y=!1,Q()}))}function de(l){let d=o.get(l);return d||(d=r=>{r!==c.get(l)&&(r?c.set(l,r):(c.delete(l),o.delete(l)),se())},o.set(l,d),d)}function D(){if(a.value){h.value=t.options.virtualize?new Set:null,b=new Set(t.items.map(l=>Y(l))),I.clear();for(const l of t.items)I.set(Y(l),l);i=At(a.value,{...ce,...t.options}),m=i.on("layout",l=>{if(S.value=!0,s("layout",l.items),t.options.virtualize){const d=new Set(l.visibleIds);(!h.value||!z(h.value,d))&&(h.value=d)}}),Q()}}const F=O(null),$=O(""),ee=`${e}-instructions`,G=`${e}-live`;function q(l){$.value=l}function W(l,d){return`item ${d.findIndex(f=>Y(f)===l)+1} of ${d.length}`}let T=null;function te(l,d,r){const f=l.findIndex(x=>Y(x)===d);if(f===-1)return l;const p=[...l],[P]=p.splice(f,1);return p.splice(Math.max(0,Math.min(r,p.length)),0,P),p}function K(l,d){if(!t.sortable||!i)return;const r=Y(d);if(l.key===" "||l.key==="Enter"){l.preventDefault(),F.value===r?(F.value=null,T=null,i.setDragging(null),q(`Dropped ${W(r,t.items)}.`)):F.value===null&&(F.value=r,T=t.items,i.setDragging(r),q(`Picked up ${W(r,t.items)}. Use arrow keys to move, space to drop, escape to cancel.`));return}if(F.value!==r)return;if(l.key==="Escape"){l.preventDefault(),F.value=null,i.setDragging(null),T&&s("reorder",T),T=null,q("Reordering cancelled.");return}const f=t.options.direction==="horizontal",p=f?"ArrowRight":"ArrowDown",P=f?"ArrowLeft":"ArrowUp";if(l.key!==p&&l.key!==P)return;l.preventDefault();const x=t.items.findIndex(fe=>Y(fe)===r),N=l.key===p?1:-1,B=x+N;if(B<0||B>=t.items.length)return;const ne=te(t.items,r,B);s("reorder",ne),q(`Moved to ${W(r,ne)}.`)}return Me(()=>{!a.value||typeof window>"u"||(D(),M=Fe(()=>t.items,l=>{Z(l),Q()},{deep:!0}),w=Fe(()=>t.options,(l,d)=>{Et(l,d)||(m?.(),i?.destroy(),D())},{deep:!0}))}),Ve(()=>{M?.(),w?.(),m?.(),i?.destroy()}),()=>ke("div",{ref:a,class:"mk-grid",style:S.value?{}:{columns:U(),columnGap:`${R().cross}px`}},[...v.value.map(l=>{const d=Y(l),r=g.value.has(d),f=t.sortable?{tabindex:0,role:"button","aria-roledescription":"Reorderable item","aria-describedby":ee,"aria-pressed":F.value===d?"true":"false",onKeydown:p=>K(p,l)}:{};return ke("div",{key:d,class:"mk-item",style:{...S.value?{}:{breakInside:"avoid",marginBottom:`${R().main}px`},...r?{pointerEvents:"none"}:{}},ref:de(d),...f},n.item?.({item:l}))}),t.sortable?ke("span",{id:ee,style:$e},"Press space or enter to pick up this item. While picked up, use the arrow keys to move it, space or enter to drop it, or escape to cancel."):null,t.sortable?ke("span",{id:G,role:"status","aria-live":"polite",style:$e},$.value):null])}});const Pt=_e({__name:"PlaceholderCanvas",props:{rgba:{type:[Object,null],required:!0}},setup(t,{expose:n}){n();const s=t,e=O();function a(){const o=e.value;if(!o||!s.rgba)return;o.width=s.rgba.width,o.height=s.rgba.height;const i=o.getContext("2d");if(!i)return;const m=i.createImageData(s.rgba.width,s.rgba.height);m.data.set(s.rgba.data),i.putImageData(m,0,0)}Me(a),Fe(()=>s.rgba,a);const c={props:s,canvas:e,draw:a};return Object.defineProperty(c,"__isScriptSetup",{enumerable:!1,value:!0}),c}}),Nt={key:0,ref:"canvas",class:"canvas"},Tt={key:1,class:"canvas canvas--bad",title:"Could not decode this hash"};function jt(t,n,s,e,a,c){return s.rgba?(_(),k("canvas",Nt,null,512)):(_(),k("div",Tt,"?"))}const ut=Se(Pt,[["render",jt],["__scopeId","data-v-512bf9cf"],["__file","C:/work/NPM/devtoolz/ui/src/modules/image-hash/PlaceholderCanvas.vue"]]);var Ut=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","#","$","%","*","+",",","-",".",":",";","=","?","@","[","]","^","_","{","|","}","~"],ye=t=>{let n=0;for(let s=0;s<t.length;s++){let e=t[s],a=Ut.indexOf(e);n=n*83+a}return n},Pe=t=>{let n=t/255;return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)},Ne=t=>{let n=Math.max(0,Math.min(1,t));return n<=.0031308?Math.trunc(n*12.92*255+.5):Math.trunc((1.055*Math.pow(n,.4166666666666667)-.055)*255+.5)},Dt=t=>t<0?-1:1,Te=(t,n)=>Dt(t)*Math.pow(Math.abs(t),n),et=class extends Error{constructor(t){super(t),this.name="ValidationError",this.message=t}},Bt=t=>{if(!t||t.length<6)throw new et("The blurhash string must be at least 6 characters");let n=ye(t[0]),s=Math.floor(n/9)+1,e=n%9+1;if(t.length!==4+2*e*s)throw new et(`blurhash length mismatch: length is ${t.length} but it should be ${4+2*e*s}`)},Ft=t=>{let n=t>>16,s=t>>8&255,e=t&255;return[Pe(n),Pe(s),Pe(e)]},Ht=(t,n)=>{let s=Math.floor(t/361),e=Math.floor(t/19)%19,a=t%19;return[Te((s-9)/9,2)*n,Te((e-9)/9,2)*n,Te((a-9)/9,2)*n]},Vt=(t,n,s,e)=>{Bt(t),e=e|1;let a=ye(t[0]),c=Math.floor(a/9)+1,o=a%9+1,i=(ye(t[1])+1)/166,m=new Array(o*c);for(let y=0;y<m.length;y++)if(y===0){let h=ye(t.substring(2,6));m[y]=Ft(h)}else{let h=ye(t.substring(4+y*2,6+y*2));m[y]=Ht(h,i*e)}let M=n*4,w=new Uint8ClampedArray(M*s);for(let y=0;y<s;y++)for(let h=0;h<n;h++){let S=0,g=0,I=0;for(let E=0;E<c;E++)for(let j=0;j<o;j++){let R=Math.cos(Math.PI*h*j/n)*Math.cos(Math.PI*y*E/s),U=m[j+E*o];S+=U[0]*R,g+=U[1]*R,I+=U[2]*R}let b=Ne(S),v=Ne(g),z=Ne(I);w[4*h+0+y*M]=b,w[4*h+1+y*M]=v,w[4*h+2+y*M]=z,w[4*h+3+y*M]=255}return w},Gt=Vt;const tt=new Map;function nt(t,n){const s=t*4096+n;let e=tt.get(s);if(!e){e=new Float64Array(t*n);for(let a=0;a<t;a++)for(let c=0;c<n;c++)e[a*n+c]=Math.cos(Math.PI*a*(c+.5)/n);tt.set(s,e)}return e}function qt(t,n,s,e,a,c,o){const i=nt(s,a),m=nt(e,c),M=new Float64Array(s);for(let w=0;w<c;w++){for(let y=0;y<s;y++){let h=0;for(let S=0;S<e;S++){const g=t[S*n+y];g!==0&&(h+=g*m[S*c+w])}M[y]=h}for(let y=0;y<a;y++){let h=0;for(let S=0;S<s;S++)h+=M[S]*i[S*a+y];o[w*a+y]=h}}}var pe=class extends Error{constructor(t,n){super(n?`${t}: ${n}`:t),this.name="PlaceholderError",this.code=t}};const Wt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",dt=new Int8Array(128).fill(-1);for(let t=0;t<64;t++)dt[Wt.charCodeAt(t)]=t;function Kt(t){const n=t.length;if(n%4===1)throw new pe("InvalidLength");const s=new Uint8Array(Math.floor(n*6/8));let e=0,a=0,c=0;for(let o=0;o<n;o++){const i=t.charCodeAt(o),m=i<128?dt[i]:-1;if(m<0)throw new pe("InvalidCharacter");e=e<<6|m,a+=6,a>=8&&(a-=8,s[c++]=e>>a&255,e&=(1<<a)-1)}return s}function Xt(t){return typeof t=="string"?Kt(t):t}var ft=class{constructor(t,n=0){this.bytes=t,this.pos=n*8,this.end=t.length*8}bit(){if(this.pos>=this.end)return 0;const t=this.pos++;return this.bytes[t>>3]>>7-(t&7)&1}bits(t){let n=0;for(let s=0;s<t;s++)n=n<<1|this.bit();return n>>>0}};function Yt(t,n){let s=0;for(;t.bit()===1;)s++;const e=s*(1<<n)+(n>0?t.bits(n):0);return e&1?-((e+1)/2):e/2}function Jt(t){return t?9:7}function Zt(t){return Math.pow(2,(t-32)/8)}function Qt(t,n){return t>=1?[n,Math.max(1,Math.round(n/t))]:[Math.max(1,Math.round(n*t)),n]}function $t(t){if(t.length<7||t.length>1024)throw new pe("InvalidLength");const n=new ft(t);if(n.bits(2)!==0)throw new pe("UnsupportedVersion");const s=n.bit()===1;if(s&&t.length<9)throw new pe("InvalidLength");const e={aspectCode:n.bits(6),alpha:s,Lx:n.bits(3)+1,Ly:n.bits(3)+1,Cx:n.bits(2)+1,Cy:n.bits(2)+1,Ax:1,Ay:1,dc:[0,0,0,0],scale:[0,0,0,0],k:[0,0,0,0]};for(let a=0;a<3;a++)e.dc[a]=n.bits(6);for(let a=0;a<3;a++)e.scale[a]=n.bits(4);for(let a=0;a<3;a++)e.k[a]=n.bits(2);return n.bit(),s&&(e.dc[3]=n.bits(5),e.Ax=n.bits(2)+1,e.Ay=n.bits(2)+1,e.scale[3]=n.bits(4),e.k[3]=n.bits(2)),e}const be={qmaxL:7,qmaxC:3,smaxL:.64,smaxC:.32,reconOffset:0};function en(t){return t===0?be.qmaxL:be.qmaxC}function tn(t,n,s,e){return 2*(t*e+n*s)<3*s*e}function qe(t,n){return n===0?[t.Lx,t.Ly]:n===3?[t.Ax,t.Ay]:[t.Cx,t.Cy]}function nn(t){const n=[],s=t.alpha?[0,1,2,3]:[0,1,2];for(const e of s){const[a,c]=qe(t,e);for(let o=0;o<c;o++)for(let i=0;i<a;i++)i===0&&o===0||!tn(i,o,a,c)||n.push({ch:e,i,j:o,nx:a,ny:c,qmax:en(e)})}return n.sort((e,a)=>{const c=e.i*e.i*e.ny*e.ny+e.j*e.j*e.nx*e.nx,o=e.nx*e.nx*e.ny*e.ny,i=a.i*a.i*a.ny*a.ny+a.j*a.j*a.nx*a.nx,m=c*(a.nx*a.nx*a.ny*a.ny)-i*o;return m!==0?m:e.ch!==a.ch?e.ch-a.ch:e.j!==a.j?e.j-a.j:e.i-a.i}),n}function xe(t,n,s){return t<n?n:t>s?s:t}function sn(t,n){return t===0?n/63:t===3?n/31:n*.64/63-.32}const on=Array.from({length:16},(t,n)=>Math.pow(2,-(15-n)/3));function an(t,n){return(t===1||t===2?be.smaxC:be.smaxL)*on[n]}function rn(t,n,s){if(t===0)return 0;const e=(Math.abs(t)-be.reconOffset)/s,a=n*e*e;return t<0?-a:a}function ln(t){return t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055}function je(t,n,s,e){const a=t+.3963377774*n+.2158037573*s,c=t-.1055613458*n-.0638541728*s,o=t-.0894841775*n-1.291485548*s,i=a*a*a,m=c*c*c,M=o*o*o;e[0]=4.0767416621*i-3.3077115913*m+.2309699292*M,e[1]=-1.2684380046*i+2.6097574011*m-.3413193965*M,e[2]=-.0041960863*i-.7034186147*m+1.707614701*M}const Ue=-5e-4,De=1.0005,st=[0,0,0];function ot(t){return t[0]>=Ue&&t[0]<=De&&t[1]>=Ue&&t[1]<=De&&t[2]>=Ue&&t[2]<=De}function cn(t,n,s,e){if(je(t,n,s,e),!ot(e)){let a=0,c=1;for(let o=0;o<8;o++){const i=(a+c)/2;je(t,n*i,s*i,st),ot(st)?a=i:c=i}je(t,n*a,s*a,e)}for(let a=0;a<3;a++)e[a]=e[a]<0?0:e[a]>1?1:e[a]}function un(t,n){const s=n,e=n.alpha?[0,1,2,3]:[0,1,2],a=[];for(const i of e){const[m,M]=qe(s,i),w=new Float64Array(m*M);w[0]=sn(i,n.dc[i]),a[i]=w}const c=e.map(i=>an(i,n.scale[i])),o=new ft(t,Jt(n.alpha));for(const i of nn(s)){let m=Yt(o,n.k[i.ch]);m=m>i.qmax?i.qmax:m<-i.qmax?-i.qmax:m,a[i.ch][i.j*i.nx+i.i]=rn(m,c[i.ch],i.qmax)}return a}function dn(t,n={}){const s=Xt(t),e=$t(s),a=Math.round(xe(n.size??32,4,128)),c=n.dither??!0,[o,i]=Qt(Zt(e.aspectCode),a),m=un(s,e),M=e,w=o*i,y=[];for(let g=0;g<m.length;g++){const[I,b]=qe(M,g),v=new Float64Array(w);qt(m[g],I,I,b,o,i,v),y.push(v)}const h=new Uint8ClampedArray(w*4),S=[0,0,0];for(let g=0;g<i;g++)for(let I=0;I<o;I++){const b=g*o+I;cn(xe(y[0][b],0,1),y[1][b],y[2][b],S);const v=c?at(52.9829189*at(.06711056*I+.00583715*g)):.5,z=b*4;for(let E=0;E<3;E++){const j=ln(S[E])*255;h[z+E]=xe(Math.floor(j+v),0,255)}h[z+3]=e.alpha?Math.round(xe(y[3][b],0,1)*255):255}return{width:o,height:i,data:h}}function at(t){return t-Math.floor(t)}function fn(t){let{PI:n,min:s,max:e,cos:a,round:c}=Math,o=t[0]|t[1]<<8|t[2]<<16,i=t[3]|t[4]<<8,m=(o&63)/63,M=(o>>6&63)/31.5-1,w=(o>>12&63)/31.5-1,y=(o>>18&31)/31,h=o>>23,S=(i>>3&63)/63,g=(i>>9&63)/63,I=i>>15,b=e(3,I?h?5:7:i&7),v=e(3,I?i&7:h?5:7),z=h?(t[5]&15)/15:1,E=(t[5]>>4)/15,j=h?6:5,R=0,U=(W,T,te)=>{let K=[];for(let l=0;l<T;l++)for(let d=l?0:1;d*T<W*(T-l);d++)K.push(((t[j+(R>>1)]>>((R++&1)<<2)&15)/7.5-1)*te);return K},Z=U(b,v,y),Q=U(3,3,S*1.25),se=U(3,3,g*1.25),de=h&&U(5,5,E),D=hn(t),F=c(D>1?32:32*D),$=c(D>1?32/D:32),ee=new Uint8Array(F*$*4),G=[],q=[];for(let W=0,T=0;W<$;W++)for(let te=0;te<F;te++,T+=4){let K=m,l=M,d=w,r=z;for(let x=0,N=e(b,h?5:3);x<N;x++)G[x]=a(n/F*(te+.5)*x);for(let x=0,N=e(v,h?5:3);x<N;x++)q[x]=a(n/$*(W+.5)*x);for(let x=0,N=0;x<v;x++)for(let B=x?0:1,ne=q[x]*2;B*v<b*(v-x);B++,N++)K+=Z[N]*G[B]*ne;for(let x=0,N=0;x<3;x++)for(let B=x?0:1,ne=q[x]*2;B<3-x;B++,N++){let fe=G[B]*ne;l+=Q[N]*fe,d+=se[N]*fe}if(h)for(let x=0,N=0;x<5;x++)for(let B=x?0:1,ne=q[x]*2;B<5-x;B++,N++)r+=de[N]*G[B]*ne;let f=K-2/3*l,p=(3*K-f+d)/2,P=p-d;ee[T]=e(0,255*s(1,p)),ee[T+1]=e(0,255*s(1,P)),ee[T+2]=e(0,255*s(1,f)),ee[T+3]=e(0,255*s(1,r))}return{w:F,h:$,rgba:ee}}function hn(t){let n=t[3],s=t[2]&128,e=t[4]&128,a=e?s?5:7:n&7,c=e?n&7:s?5:7;return a/c}const ge=32;function mn(t,n,s){const e=n>0&&s>0?n/s:1,a=e>=1?ge:Math.max(1,Math.round(ge*e)),c=e>=1?Math.max(1,Math.round(ge/e)):ge;try{return{width:a,height:c,data:Gt(t,a,c)}}catch{return null}}function vn(t){try{const n=atob(t),s=Uint8Array.from(n,a=>a.charCodeAt(0)),e=fn(s);return{width:e.w,height:e.h,data:new Uint8ClampedArray(e.rgba)}}catch{return null}}function yn(t){try{const n=dn(t,{size:ge});return{width:n.width,height:n.height,data:new Uint8ClampedArray(n.data)}}catch{return null}}function ht(t,n,s,e){return t==="blurhash"?mn(n,s,e):t==="thumbhash"?vn(n):yn(n)}const gn=_e({__name:"ResultCard",props:{entry:{type:Object,required:!0}},emits:["open"],setup(t,{expose:n,emit:s}){n();const e=t,a=s,c=["hazehash","blurhash","thumbhash"],{copied:o,copy:i}=it(),m=V(()=>{const{width:h,height:S}=e.entry;return h>0&&S>0?Math.min(Math.max(h/S,.5),2):1}),M=V(()=>c.filter(h=>e.entry[h]!==void 0).map(h=>({type:h,rgba:ht(h,e.entry[h],e.entry.width,e.entry.height)}))),w=V(()=>{const h=[];for(const S of["hazehash","blurhash","thumbhash","color"]){const g=e.entry[S];g!==void 0&&h.push({key:S,value:g})}return h}),y={props:e,emit:a,DECODABLE:c,copied:o,copy:i,aspect:m,decoded:M,lines:w,get imageUrl(){return rt},Icon:Ge,PlaceholderCanvas:ut};return Object.defineProperty(y,"__isScriptSetup",{enumerable:!1,value:!0}),y}}),pn={class:"item card"},bn=["aria-label"],_n=["alt","src"],wn={class:"strip__label"},kn=["src"],xn={class:"meta"},Mn=["title"],Sn={class:"muted"},Cn={class:"hashes"},In={class:"hashes__key"},zn=["title"],An=["aria-label","onClick"];function En(t,n,s,e,a,c){return _(),k("article",pn,[u("button",{class:"item__open","aria-label":`Open ${s.entry.file}`,onClick:n[0]||(n[0]=o=>e.emit("open"))},[u("span",{class:"shots",style:me({aspectRatio:String(e.aspect)})},[u("img",{class:"shot",loading:"lazy",alt:s.entry.file,src:e.imageUrl(s.entry.path,480)},null,8,_n)],4),e.decoded.length>0?(_(),k("span",{key:0,class:"strip",style:me({aspectRatio:String(e.aspect*e.decoded.length)})},[(_(!0),k(re,null,ue(e.decoded,o=>(_(),k("span",{key:o.type,class:"strip__cell"},[J(e.PlaceholderCanvas,{rgba:o.rgba},null,8,["rgba"]),u("span",wn,C(o.type),1)]))),128))],4)):L("v-if",!0),s.entry.preview?(_(),k("img",{key:1,class:"preview",alt:"Tiny preview",src:s.entry.preview},null,8,kn)):L("v-if",!0)],8,bn),u("div",xn,[u("strong",{class:"meta__name",title:s.entry.path},C(s.entry.file),9,Mn),u("span",Sn,C(s.entry.width)+"×"+C(s.entry.height),1)]),u("ul",Cn,[(_(!0),k(re,null,ue(e.lines,o=>(_(),k("li",{key:o.key},[u("span",In,[o.key==="color"?(_(),k("span",{key:0,class:"swatch",style:me({background:o.value})},null,4)):L("v-if",!0),le(" "+C(o.key),1)]),u("code",{class:"hashes__value",title:o.value},C(o.value),9,zn),u("button",{class:"btn btn--ghost btn--small","aria-label":`Copy ${o.key}`,onClick:i=>e.copy(o.key,o.value)},[J(e.Icon,{name:e.copied===o.key?"check":"copy",size:14},null,8,["name"])],8,An)]))),128))])])}const On=Se(gn,[["render",En],["__scopeId","data-v-e50ba89f"],["__file","C:/work/NPM/devtoolz/ui/src/modules/image-hash/ResultCard.vue"]]),Ln=_e({__name:"ResultModal",props:{entries:{type:Array,required:!0},index:{type:Number,required:!0}},emits:["close","update:index"],setup(t,{expose:n,emit:s}){n();const e=t,a=s,c=["hazehash","blurhash","thumbhash"],{copied:o,copy:i}=it(),m=V(()=>e.entries[e.index]),M=V(()=>e.index>0),w=V(()=>e.index<e.entries.length-1),y=V(()=>{const{width:v,height:z}=m.value;return v>0&&z>0?v/z:1}),h=V(()=>c.filter(v=>m.value[v]!==void 0).map(v=>({type:v,rgba:ht(v,m.value[v],m.value.width,m.value.height)}))),S=V(()=>{const v=[];for(const z of["hazehash","blurhash","thumbhash","color"]){const E=m.value[z];E!==void 0&&v.push({key:z,value:E})}return v});function g(v){const z=e.index+v;z>=0&&z<e.entries.length&&a("update:index",z)}function I(v){v.target instanceof HTMLInputElement||(v.key==="ArrowLeft"&&g(-1),v.key==="ArrowRight"&&g(1))}Me(()=>window.addEventListener("keydown",I)),Ve(()=>window.removeEventListener("keydown",I));const b={props:e,emit:a,DECODABLE:c,copied:o,copy:i,entry:m,hasPrev:M,hasNext:w,aspect:y,decoded:h,lines:S,go:g,onKey:I,get imageUrl(){return rt},Icon:Ge,UiModal:bt,PlaceholderCanvas:ut};return Object.defineProperty(b,"__isScriptSetup",{enumerable:!1,value:!0}),b}}),Rn={class:"muted counter"},Pn=["disabled"],Nn=["disabled"],Tn={class:"scroll"},jn={class:"stage"},Un=["alt","src"],Dn={key:0,class:"compare"},Bn={key:0,class:"compare__item"},Fn=["src"],Hn={class:"facts"},Vn={class:"facts__row"},Gn={class:"facts__mono"},qn={class:"facts__row"},Wn={class:"facts__mono facts__hash"},Kn=["aria-label","onClick"];function Xn(t,n,s,e,a,c){return _(),lt(e.UiModal,{title:e.entry.file,width:"1040px",onClose:n[2]||(n[2]=o=>e.emit("close"))},{actions:He(()=>[u("span",Rn,C(s.index+1)+" / "+C(s.entries.length),1),u("button",{class:"btn btn--small",disabled:!e.hasPrev,"aria-label":"Previous image",onClick:n[0]||(n[0]=o=>e.go(-1))},[J(e.Icon,{name:"left",size:15})],8,Pn),u("button",{class:"btn btn--small",disabled:!e.hasNext,"aria-label":"Next image",onClick:n[1]||(n[1]=o=>e.go(1))},[J(e.Icon,{name:"right",size:15})],8,Nn)]),default:He(()=>[u("div",Tn,[u("div",jn,[(_(),k("img",{key:e.entry.path,class:"stage__img",alt:e.entry.file,src:e.imageUrl(e.entry.path,1600)},null,8,Un))]),e.decoded.length?(_(),k("div",Dn,[(_(!0),k(re,null,ue(e.decoded,o=>(_(),k("figure",{key:o.type,class:"compare__item"},[u("div",{class:"compare__frame",style:me({aspectRatio:String(e.aspect)})},[J(e.PlaceholderCanvas,{rgba:o.rgba},null,8,["rgba"])],4),u("figcaption",null,C(o.type),1)]))),128)),e.entry.preview?(_(),k("figure",Bn,[u("div",{class:"compare__frame",style:me({aspectRatio:String(e.aspect)})},[u("img",{class:"compare__preview",alt:"Tiny preview",src:e.entry.preview},null,8,Fn)],4),n[3]||(n[3]=u("figcaption",null,"preview",-1))])):L("v-if",!0)])):L("v-if",!0),u("dl",Hn,[u("div",Vn,[n[4]||(n[4]=u("dt",null,"File",-1)),u("dd",Gn,C(e.entry.path),1)]),u("div",qn,[n[5]||(n[5]=u("dt",null,"Size",-1)),u("dd",null,C(e.entry.width)+" × "+C(e.entry.height)+" px",1)]),(_(!0),k(re,null,ue(e.lines,o=>(_(),k("div",{key:o.key,class:"facts__row"},[u("dt",null,[o.key==="color"?(_(),k("span",{key:0,class:"swatch",style:me({background:o.value})},null,4)):L("v-if",!0),le(" "+C(o.key),1)]),u("dd",Wn,C(o.value),1),u("button",{class:"btn btn--ghost btn--small","aria-label":`Copy ${o.key}`,onClick:i=>e.copy(o.key,o.value)},[J(e.Icon,{name:e.copied===o.key?"check":"copy",size:14},null,8,["name"])],8,Kn)]))),128))])])]),_:1},8,["title"])}const Yn=Se(Ln,[["render",Xn],["__scopeId","data-v-6aef2e16"],["__file","C:/work/NPM/devtoolz/ui/src/modules/image-hash/ResultModal.vue"]]),Be=48,Jn=_e({__name:"ImageHashPage",props:{module:{type:Object,required:!0},status:{type:null,required:!0}},setup(t,{expose:n}){n();const s={columns:"auto",minLaneSize:250,gap:14},e=["auto","3x3","4x3","4x4","5x4","6x4","8x6"],a={json:"json",plain:"txt",csv:"csv",ts:"ts",js:"js"},c=O(),o=O([]),i=O(!0),m=O(["hazehash","color"]),M=O(28),w=O("auto"),y=O("json"),h=O("imageHashes"),S=O(null),g=O("idle"),I=O({done:0,total:0,cached:0}),b=O(""),v=O(),z=O("gallery"),E=O(Be),j=O(""),R=O(""),U=O(!1);let Z;const Q=V(()=>b.value.toLowerCase().includes("sharp")),se=V(()=>o.value.length>0&&m.value.length>0&&g.value!=="running"),de=V(()=>I.value.total>0?Math.round(I.value.done/I.value.total*100):0),D=V(()=>v.value?.entries.slice(0,E.value)??[]),F=V(()=>D.value.map((l,d)=>({id:l.path,position:d})));function $(l){return D.value[Number(l.position)]}function ee(l){m.value=m.value.includes(l)?m.value.filter(d=>d!==l):[...m.value,l]}function G(l,d){const r=l.includes("\\")?"\\":"/";return`${l}${l.endsWith(r)?"":r}image-hashes.${a[d]??"txt"}`}async function q(l=!1){Z?.(),g.value="running",b.value="",v.value=void 0,R.value="",I.value={done:0,total:0,cached:0},E.value=Be,S.value=null;try{const{jobId:d}=await Ee.post("/api/image-hash/run",{paths:o.value,recursive:i.value,types:m.value,components:w.value,budget:M.value,format:y.value,exportName:h.value,installSharp:l});Z=yt(d,{onProgress:r=>{I.value=r},onDone:r=>{v.value=r,g.value="done",z.value="gallery",j.value=G(r.base,r.format)},onFailed:r=>{b.value=r,g.value="failed"}})}catch(d){b.value=d instanceof Error?d.message:String(d),g.value="failed"}}async function W(){if(v.value?.output)try{await navigator.clipboard.writeText(v.value.output),U.value=!0,setTimeout(()=>U.value=!1,1200)}catch{U.value=!1}}function T(){const l=v.value?.output;if(!l)return;const d=new Blob([l],{type:"text/plain;charset=utf-8"}),r=document.createElement("a");r.href=URL.createObjectURL(d),r.download=`image-hashes.${a[v.value?.format??"json"]??"txt"}`,r.click(),URL.revokeObjectURL(r.href)}async function te(l=!1){if(v.value?.output){R.value="";try{const d=await Ee.post("/api/image-hash/save",{path:j.value,content:v.value.output,overwrite:l});R.value=`Saved to ${d.path}`}catch(d){if(d instanceof gt&&d.status===409){window.confirm(`${d.message}. Replace it?`)&&await te(!0);return}R.value=d instanceof Error?d.message:String(d)}}}Me(async()=>{try{c.value=await Ee.get("/api/image-hash/options"),M.value=c.value.budget.default,w.value=c.value.components.auto?"auto":c.value.components.default,h.value=c.value.exportName}catch(l){b.value=l instanceof Error?l.message:String(l),g.value="failed"}}),Ve(()=>{Z?.()});const K={PAGE:Be,MASONRY_OPTIONS:s,COMPONENT_CHOICES:e,EXTENSIONS:a,options:c,sources:o,recursive:i,types:m,budget:M,components:w,format:y,exportName:h,viewing:S,phase:g,progress:I,failure:b,result:v,tab:z,shown:E,savePath:j,saveNote:R,copiedOutput:U,get stopWatching(){return Z},set stopWatching(l){Z=l},needsSharp:Q,canRun:se,percent:de,visible:D,masonryItems:F,entryOf:$,toggleType:ee,defaultSavePath:G,run:q,copyOutput:W,download:T,save:te,get MasonryGrid(){return Rt},SourcePicker:pt,Icon:Ge,ResultCard:On,ResultModal:Yn};return Object.defineProperty(K,"__isScriptSetup",{enumerable:!1,value:!0}),K}}),Zn={class:"page"},Qn={class:"page__head"},$n={class:"muted"},es={key:0,class:"notice notice--warn"},ts={class:"card block"},ns={class:"types"},ss=["checked","onChange"],os={class:"type__title"},as={class:"type__text muted"},rs={class:"grid"},ls={key:0,class:"field"},is=["min","max"],cs={key:1,class:"field"},us=["value"],ds={class:"field"},fs=["value"],hs={key:2,class:"field"},ms={class:"runbar"},vs=["disabled"],ys={key:0,class:"muted"},gs={key:1,class:"muted"},ps={key:1,class:"card block",role:"status"},bs={class:"progress"},_s={class:"muted"},ws={key:0},ks={key:2,class:"notice notice--error"},xs={key:3,class:"card block"},Ms={class:"block__head"},Ss={class:"muted"},Cs={key:0},Is={key:1},zs={key:0,class:"errors"},As={class:"tabs",role:"tablist"},Es=["aria-selected"],Os=["aria-selected"],Ls={key:0,class:"muted"},Rs={key:1,class:"more"},Ps={class:"outbar"},Ns=["disabled"],Ts={key:0,class:"muted"},js={class:"output"};function Us(t,n,s,e,a,c){return _(),k("div",Zn,[u("header",Qn,[u("h1",null,C(s.module.title),1),u("p",$n,C(s.module.description),1)]),e.options&&!e.options.sharp?(_(),k("div",es," The sharp image library is not installed yet. Previews are limited, and the first run will offer to install it. ")):L("v-if",!0),J(e.SourcePicker,{sources:e.sources,"onUpdate:sources":n[0]||(n[0]=o=>e.sources=o),recursive:e.recursive,"onUpdate:recursive":n[1]||(n[1]=o=>e.recursive=o),"scan-url":"/api/image-hash/scan",start:s.status?.cwd??""},null,8,["sources","recursive","start"]),u("section",ts,[n[19]||(n[19]=u("h2",null,"Placeholders",-1)),u("div",ns,[(_(!0),k(re,null,ue(e.options?.types,o=>(_(),k("label",{key:o.id,class:Oe(["type",{"type--on":e.types.includes(o.id)}])},[u("input",{type:"checkbox",checked:e.types.includes(o.id),onChange:i=>e.toggleType(o.id)},null,40,ss),u("span",os,C(o.title),1),u("span",as,C(o.description),1)],2))),128))]),u("div",rs,[e.types.includes("hazehash")?(_(),k("label",ls,[u("span",null,"Hazehash size: "+C(e.budget)+" bytes",1),ve(u("input",{"onUpdate:modelValue":n[2]||(n[2]=o=>e.budget=o),type:"range",min:e.options?.budget.min,max:e.options?.budget.max},null,8,is),[[Le,e.budget,void 0,{number:!0}]])])):L("v-if",!0),e.types.includes("blurhash")?(_(),k("label",cs,[n[16]||(n[16]=u("span",null,"Blurhash components",-1)),ve(u("select",{"onUpdate:modelValue":n[3]||(n[3]=o=>e.components=o),class:"select"},[(_(),k(re,null,ue(e.COMPONENT_CHOICES,o=>u("option",{key:o,value:o},C(o==="auto"?"auto (by aspect ratio)":o),9,us)),64))],512),[[Ye,e.components]])])):L("v-if",!0),u("label",ds,[n[17]||(n[17]=u("span",null,"Output format",-1)),ve(u("select",{"onUpdate:modelValue":n[4]||(n[4]=o=>e.format=o),class:"select"},[(_(!0),k(re,null,ue(e.options?.formats,o=>(_(),k("option",{key:o,value:o},C(o),9,fs))),128))],512),[[Ye,e.format]])]),e.format==="ts"||e.format==="js"?(_(),k("label",hs,[n[18]||(n[18]=u("span",null,"Export name",-1)),ve(u("input",{"onUpdate:modelValue":n[5]||(n[5]=o=>e.exportName=o),class:"input",spellcheck:"false"},null,512),[[Le,e.exportName]])])):L("v-if",!0)])]),u("div",ms,[u("button",{class:"btn btn--primary",disabled:!e.canRun,onClick:n[6]||(n[6]=o=>e.run(!1))},[J(e.Icon,{name:"play",size:15}),le(" "+C(e.phase==="running"?"Working…":"Compute hashes"),1)],8,vs),e.sources.length===0?(_(),k("span",ys,"Add at least one folder or image.")):e.types.length===0?(_(),k("span",gs,"Pick at least one placeholder.")):L("v-if",!0)]),e.phase==="running"?(_(),k("div",ps,[u("div",bs,[u("div",{class:"progress__bar",style:me({width:`${e.percent}%`})},null,4)]),u("span",_s,[le(C(e.progress.done)+" of "+C(e.progress.total||"…")+" images",1),e.progress.cached?(_(),k("span",ws," · "+C(e.progress.cached)+" from cache",1)):L("v-if",!0)])])):L("v-if",!0),e.phase==="failed"?(_(),k("div",ks,[u("p",null,C(e.failure),1),e.needsSharp?(_(),k("button",{key:0,class:"btn btn--small",onClick:n[7]||(n[7]=o=>e.run(!0))}," Install sharp and retry ")):L("v-if",!0)])):L("v-if",!0),e.result?(_(),k("section",xs,[u("div",Ms,[n[20]||(n[20]=u("h2",null,"Result",-1)),u("span",Ss,[le(C(e.result.entries.length)+" image"+C(e.result.entries.length===1?"":"s")+" ",1),e.result.cached?(_(),k("span",Cs,"· "+C(e.result.cached)+" cached",1)):L("v-if",!0),e.result.errors.length?(_(),k("span",Is,"· "+C(e.result.errors.length)+" failed",1)):L("v-if",!0)])]),e.result.errors.length?(_(),k("ul",zs,[(_(!0),k(re,null,ue(e.result.errors,o=>(_(),k("li",{key:o.file},[u("code",null,C(o.file),1),le(" — "+C(o.message),1)]))),128))])):L("v-if",!0),u("div",As,[u("button",{class:Oe(["tab",{"tab--on":e.tab==="gallery"}]),role:"tab","aria-selected":e.tab==="gallery",onClick:n[8]||(n[8]=o=>e.tab="gallery")}," Gallery ",10,Es),u("button",{class:Oe(["tab",{"tab--on":e.tab==="output"}]),role:"tab","aria-selected":e.tab==="output",onClick:n[9]||(n[9]=o=>e.tab="output")}," Output ("+C(e.result.format)+") ",11,Os)]),e.tab==="gallery"?(_(),k(re,{key:1},[e.result.entries.length===0?(_(),k("p",Ls,"No images were found.")):L("v-if",!0),J(e.MasonryGrid,{class:"gallery",items:e.masonryItems,options:e.MASONRY_OPTIONS},{item:He(({item:o})=>[J(e.ResultCard,{entry:e.entryOf(o),onOpen:i=>e.viewing=Number(o.position)},null,8,["entry","onOpen"])]),_:1},8,["items"]),e.shown<e.result.entries.length?(_(),k("div",Rs,[u("button",{class:"btn",onClick:n[10]||(n[10]=o=>e.shown+=e.PAGE)}," Show more ("+C(e.result.entries.length-e.shown)+" left) ",1),u("button",{class:"btn",onClick:n[11]||(n[11]=o=>e.shown=e.result.entries.length)}," Show all ("+C(e.result.entries.length)+") ",1)])):L("v-if",!0)],64)):(_(),k(re,{key:2},[u("div",Ps,[u("button",{class:"btn btn--small",onClick:e.copyOutput},[J(e.Icon,{name:e.copiedOutput?"check":"copy",size:15},null,8,["name"]),le(" "+C(e.copiedOutput?"Copied":"Copy"),1)]),u("button",{class:"btn btn--small",onClick:e.download},[J(e.Icon,{name:"download",size:15}),n[21]||(n[21]=le(" Download ",-1))]),ve(u("input",{"onUpdate:modelValue":n[12]||(n[12]=o=>e.savePath=o),class:"input outbar__path",spellcheck:"false","aria-label":"File to write"},null,512),[[Le,e.savePath]]),u("button",{class:"btn btn--small",disabled:e.savePath.trim()==="",onClick:n[13]||(n[13]=o=>e.save(!1))},[J(e.Icon,{name:"save",size:15}),n[22]||(n[22]=le(" Write to file ",-1))],8,Ns)]),e.saveNote?(_(),k("p",Ts,C(e.saveNote),1)):L("v-if",!0),u("pre",js,C(e.result.output),1)],64))])):L("v-if",!0),e.result&&e.viewing!==null?(_(),lt(e.ResultModal,{key:4,index:e.viewing,"onUpdate:index":n[14]||(n[14]=o=>e.viewing=o),entries:e.result.entries,onClose:n[15]||(n[15]=o=>e.viewing=null)},null,8,["index","entries"])):L("v-if",!0)])}const Vs=Se(Jn,[["render",Us],["__scopeId","data-v-0458e07e"],["__file","C:/work/NPM/devtoolz/ui/src/modules/image-hash/ImageHashPage.vue"]]);export{Vs as default};
@@ -0,0 +1 @@
1
+ .block[data-v-297ee74f]{display:flex;flex-direction:column;gap:14px;padding:18px}.block__head[data-v-297ee74f]{display:flex;align-items:center;justify-content:space-between;gap:12px}.sources[data-v-297ee74f]{display:flex;flex-direction:column;gap:8px;margin:0;padding:0;list-style:none}.source[data-v-297ee74f]{display:flex;align-items:center;gap:10px;padding:6px 6px 6px 12px;border-radius:9px;background:var(--surface-2)}.source--bad[data-v-297ee74f]{background:var(--danger-soft);color:var(--danger)}.source__path[data-v-297ee74f]{flex:1;min-width:0;font-family:ui-monospace,Cascadia Code,SF Mono,Menlo,Consolas,monospace;font-size:12px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.source__stats[data-v-297ee74f]{flex:none;color:var(--muted);font-size:12px}.source--bad .source__stats[data-v-297ee74f]{color:inherit}.source__x[data-v-297ee74f]{display:grid;place-items:center;width:24px;height:24px;flex:none;border:0;border-radius:50%;background:transparent;color:inherit;cursor:pointer}.source__x[data-v-297ee74f]:hover{background:#7f7f7f33}@media(max-width:560px){.source[data-v-297ee74f]{flex-wrap:wrap}.source__stats[data-v-297ee74f]{order:3;width:100%}}.summary[data-v-297ee74f]{padding:10px 14px;border-radius:9px;background:var(--accent-soft)}.summary--warn[data-v-297ee74f]{background:var(--warn-soft);color:var(--warn)}
@@ -0,0 +1 @@
1
+ import{d as V,u as F,w as T,e as U,I as A,m as I,r as C,f as S,g as j,a as D,o as t,c as o,h as i,t as c,i as x,j as v,F as y,b as E,n as M,k as L,v as O,l as b,p as R}from"./index-D8H-zVzo.js";import{F as G}from"./FolderBrowser-Cdzt7edI.js";const H=V({__name:"SourcePicker",props:I({scanUrl:{type:String,required:!0},start:{type:String,required:!0},title:{type:String,required:!1}},{sources:{type:Array,required:!0},sourcesModifiers:{},recursive:{type:Boolean,required:!0},recursiveModifiers:{}}),emits:I(["scanned"],["update:sources","update:recursive"]),setup(k,{expose:n,emit:g}){n();const e=k,a=F(k,"sources"),_=F(k,"recursive"),r=g,h=C(!1),u=C(),f=C(!1);let m,d=0;function w(s,l){return`${s} ${l}${s===1?"":"s"}`}function N(s){return u.value?.sources.find(l=>l.path===s)}function q(s){return s?s.exists?s.kind==="file"?S(s.bytes):s.files===0?"no images":`${w(s.files,"image")} · ${w(s.folders,"folder")} · ${S(s.bytes)}`:"not found":f.value?"…":""}function z(s){a.value=[...new Set([...a.value,...s])],h.value=!1}function P(s){a.value=a.value.filter(l=>l!==s)}function B(){if(clearTimeout(m),a.value.length===0){u.value=void 0,f.value=!1,r("scanned",void 0);return}f.value=!0,m=setTimeout(async()=>{const s=++d;try{const l=await j.post(e.scanUrl,{paths:a.value,recursive:_.value});s===d&&(u.value=l,r("scanned",l))}catch{s===d&&(u.value=void 0,r("scanned",void 0))}finally{s===d&&(f.value=!1)}},200)}T([a,_],B,{deep:!0,immediate:!0}),U(()=>clearTimeout(m));const p={props:e,sources:a,recursive:_,emit:r,browsing:h,scanned:u,scanning:f,get timer(){return m},set timer(s){m=s},get token(){return d},set token(s){d=s},plural:w,statsFor:N,describe:q,add:z,remove:P,schedule:B,get formatBytes(){return S},FolderBrowser:G,Icon:A};return Object.defineProperty(p,"__isScriptSetup",{enumerable:!1,value:!0}),p}}),J={class:"card block"},K={class:"block__head"},Q={key:0,class:"muted"},W={key:1,class:"sources"},X=["title"],Y={class:"source__stats"},Z=["aria-label","onClick"],$={class:"check"},ee={key:0,class:"muted"};function se(k,n,g,e,a,_){return t(),o("section",J,[i("div",K,[i("h2",null,c(g.title??"Images"),1),i("button",{class:"btn",onClick:n[0]||(n[0]=r=>e.browsing=!0)},[x(e.Icon,{name:"plus",size:16}),n[3]||(n[3]=v(" Add folder or images ",-1))])]),e.sources.length===0?(t(),o("p",Q," Add the folders and images to process. Subfolders are included when the box below is ticked. ")):(t(),o("ul",W,[(t(!0),o(y,null,E(e.sources,r=>(t(),o("li",{key:r,class:M(["source",{"source--bad":e.statsFor(r)?.exists===!1}])},[x(e.Icon,{name:e.statsFor(r)?.kind==="file"?"image":"folder",size:16},null,8,["name"]),i("span",{class:"source__path",title:r},c(r),9,X),i("span",Y,c(e.describe(e.statsFor(r))),1),i("button",{class:"source__x","aria-label":`Remove ${r}`,onClick:h=>e.remove(r)},[x(e.Icon,{name:"close",size:14})],8,Z)],2))),128))])),i("label",$,[L(i("input",{"onUpdate:modelValue":n[1]||(n[1]=r=>e.recursive=r),type:"checkbox"},null,512),[[O,e.recursive]]),n[4]||(n[4]=v(" Include subfolders",-1))]),e.sources.length>0?(t(),o("p",{key:2,class:M(["summary",{"summary--warn":e.scanned&&e.scanned.total.files===0}]),role:"status"},[e.scanning&&!e.scanned?(t(),o(y,{key:0},[v("Counting images…")],64)):e.scanned&&e.scanned.total.files===0?(t(),o(y,{key:1},[v(" No images found. Check the paths"+c(e.recursive?"":' or tick "Include subfolders"')+". ",1)],64)):e.scanned?(t(),o(y,{key:2},[i("strong",null,c(e.plural(e.scanned.total.files,"image")),1),v(" in "+c(e.plural(e.scanned.total.folders,"folder"))+" · "+c(e.formatBytes(e.scanned.total.bytes))+" ",1),e.scanning?(t(),o("span",ee,"· updating…")):b("v-if",!0)],64)):b("v-if",!0)],2)):b("v-if",!0),e.browsing?(t(),R(e.FolderBrowser,{key:3,start:e.sources[0]??g.start,onClose:n[2]||(n[2]=r=>e.browsing=!1),onConfirm:e.add},null,8,["start"])):b("v-if",!0)])}const te=D(H,[["render",se],["__scopeId","data-v-297ee74f"],["__file","C:/work/NPM/devtoolz/ui/src/components/SourcePicker.vue"]]);export{te as S};
@@ -0,0 +1 @@
1
+ .seg[data-v-b36a2015]{display:inline-flex;align-self:flex-start;flex-wrap:wrap;padding:3px;border:1px solid var(--border);border-radius:9px;background:var(--surface-2)}.seg__btn[data-v-b36a2015]{padding:5px 12px;border:0;border-radius:6px;background:transparent;color:var(--muted);cursor:pointer}.seg__btn[data-v-b36a2015]:focus-visible{outline:2px solid var(--accent);outline-offset:1px}.seg__btn--on[data-v-b36a2015]{background:var(--surface);color:var(--text);font-weight:600;box-shadow:var(--shadow)}
@@ -0,0 +1 @@
1
+ import{d as n,u as d,m as i,a as u,o as l,c as r,F as c,b as _,n as m,t as p}from"./index-D8H-zVzo.js";const b=n({__name:"UiSegmented",props:i({options:{type:Array,required:!0},label:{type:String,required:!1}},{modelValue:{type:null,required:!0},modelModifiers:{}}),emits:["update:modelValue"],setup(o,{expose:s}){s();const e={model:d(o,"modelValue")};return Object.defineProperty(e,"__isScriptSetup",{enumerable:!1,value:!0}),e}}),f=["aria-label"],g=["aria-checked","title","onClick"];function v(o,s,t,e,k,y){return l(),r("div",{class:"seg",role:"radiogroup","aria-label":t.label},[(l(!0),r(c,null,_(t.options,a=>(l(),r("button",{key:a.value,class:m(["seg__btn",{"seg__btn--on":e.model===a.value}]),role:"radio","aria-checked":e.model===a.value,title:a.hint,onClick:S=>e.model=a.value},p(a.label),11,g))),128))],8,f)}const C=u(b,[["render",v],["__scopeId","data-v-b36a2015"],["__file","C:/work/NPM/devtoolz/ui/src/ui-components/UiSegmented.vue"]]);export{C as U};
@@ -0,0 +1,12 @@
1
+ var k=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function yn(t){return Ue(t)}function Ue(t){return Array.isArray(t)?_n(t):t instanceof RegExp?t:typeof t=="object"?bn(t):t}function _n(t){let e=[];for(let n=0,r=t.length;n<r;n++)e[n]=Ue(t[n]);return e}function bn(t){let e={};for(let n in t)e[n]=Ue(t[n]);return e}function vt(t,...e){return e.forEach(n=>{for(let r in n)t[r]=n[r]}),t}function Rt(t){const e=~t.lastIndexOf("/")||~t.lastIndexOf("\\");return e===0?t:~e===t.length-1?Rt(t.substring(0,t.length-1)):t.substr(~e+1)}var Te=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,se=class{static hasCaptures(t){return t===null?!1:(Te.lastIndex=0,Te.test(t))}static replaceCaptures(t,e,n){return t.replace(Te,(r,s,o,a)=>{let i=n[parseInt(s||o,10)];if(i){let l=e.substring(i.start,i.end);for(;l[0]===".";)l=l.substring(1);switch(a){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return r})}};function Tt(t,e){return t<e?-1:t>e?1:0}function At(t,e){if(t===null&&e===null)return 0;if(!t)return-1;if(!e)return 1;let n=t.length,r=e.length;if(n===r){for(let s=0;s<n;s++){let o=Tt(t[s],e[s]);if(o!==0)return o}return 0}return n-r}function tt(t){return!!(/^#[0-9a-f]{6}$/i.test(t)||/^#[0-9a-f]{8}$/i.test(t)||/^#[0-9a-f]{3}$/i.test(t)||/^#[0-9a-f]{4}$/i.test(t))}function Nt(t){return t.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var xt=class{constructor(t){this.fn=t}cache=new Map;get(t){if(this.cache.has(t))return this.cache.get(t);const e=this.fn(t);return this.cache.set(t,e),e}},ce=class{constructor(t,e,n){this._colorMap=t,this._defaults=e,this._root=n}static createFromRawTheme(t,e){return this.createFromParsedTheme(wn(t),e)}static createFromParsedTheme(t,e){return vn(t,e)}_cachedMatchRoot=new xt(t=>this._root.match(t));getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(t){if(t===null)return this._defaults;const e=t.scopeName,r=this._cachedMatchRoot.get(e).find(s=>Sn(t.parent,s.parentScopes));return r?new Lt(r.fontStyle,r.foreground,r.background):null}},Ae=class ie{constructor(e,n){this.parent=e,this.scopeName=n}static push(e,n){for(const r of n)e=new ie(e,r);return e}static from(...e){let n=null;for(let r=0;r<e.length;r++)n=new ie(n,e[r]);return n}push(e){return new ie(this,e)}getSegments(){let e=this;const n=[];for(;e;)n.push(e.scopeName),e=e.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push(r.scopeName),r=r.parent;return r===e?n.reverse():void 0}};function Sn(t,e){if(e.length===0)return!0;for(let n=0;n<e.length;n++){let r=e[n],s=!1;if(r===">"){if(n===e.length-1)return!1;r=e[++n],s=!0}for(;t&&!Cn(t.scopeName,r);){if(s)return!1;t=t.parent}if(!t)return!1;t=t.parent}return!0}function Cn(t,e){return e===t||t.startsWith(e)&&t[e.length]==="."}var Lt=class{constructor(t,e,n){this.fontStyle=t,this.foregroundId=e,this.backgroundId=n}};function wn(t){if(!t)return[];if(!t.settings||!Array.isArray(t.settings))return[];let e=t.settings,n=[],r=0;for(let s=0,o=e.length;s<o;s++){let a=e[s];if(!a.settings)continue;let i;if(typeof a.scope=="string"){let h=a.scope;h=h.replace(/^[,]+/,""),h=h.replace(/[,]+$/,""),i=h.split(",")}else Array.isArray(a.scope)?i=a.scope:i=[""];let l=-1;if(typeof a.settings.fontStyle=="string"){l=0;let h=a.settings.fontStyle.split(" ");for(let f=0,g=h.length;f<g;f++)switch(h[f]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof a.settings.foreground=="string"&&tt(a.settings.foreground)&&(c=a.settings.foreground);let u=null;typeof a.settings.background=="string"&&tt(a.settings.background)&&(u=a.settings.background);for(let h=0,f=i.length;h<f;h++){let p=i[h].trim().split(" "),b=p[p.length-1],_=null;p.length>1&&(_=p.slice(0,p.length-1),_.reverse()),n[r++]=new kn(b,_,s,l,c,u)}}return n}var kn=class{constructor(t,e,n,r,s,o){this.scope=t,this.parentScopes=e,this.index=n,this.fontStyle=r,this.foreground=s,this.background=o}},x=(t=>(t[t.NotSet=-1]="NotSet",t[t.None=0]="None",t[t.Italic=1]="Italic",t[t.Bold=2]="Bold",t[t.Underline=4]="Underline",t[t.Strikethrough=8]="Strikethrough",t))(x||{});function vn(t,e){t.sort((l,c)=>{let u=Tt(l.scope,c.scope);return u!==0||(u=At(l.parentScopes,c.parentScopes),u!==0)?u:l.index-c.index});let n=0,r="#000000",s="#ffffff";for(;t.length>=1&&t[0].scope==="";){let l=t.shift();l.fontStyle!==-1&&(n=l.fontStyle),l.foreground!==null&&(r=l.foreground),l.background!==null&&(s=l.background)}let o=new Rn(e),a=new Lt(n,o.getId(r),o.getId(s)),i=new An(new Ie(0,null,-1,0,0),[]);for(let l=0,c=t.length;l<c;l++){let u=t[l];i.insert(0,u.scope,u.parentScopes,u.fontStyle,o.getId(u.foreground),o.getId(u.background))}return new ce(o,a,i)}var Rn=class{_isFrozen;_lastColorId;_id2color;_color2id;constructor(t){if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(t)){this._isFrozen=!0;for(let e=0,n=t.length;e<n;e++)this._color2id[t[e]]=e,this._id2color[e]=t[e]}else this._isFrozen=!1}getId(t){if(t===null)return 0;t=t.toUpperCase();let e=this._color2id[t];if(e)return e;if(this._isFrozen)throw new Error(`Missing color in color map - ${t}`);return e=++this._lastColorId,this._color2id[t]=e,this._id2color[e]=t,e}getColorMap(){return this._id2color.slice(0)}},Tn=Object.freeze([]),Ie=class Et{scopeDepth;parentScopes;fontStyle;foreground;background;constructor(e,n,r,s,o){this.scopeDepth=e,this.parentScopes=n||Tn,this.fontStyle=r,this.foreground=s,this.background=o}clone(){return new Et(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let n=[];for(let r=0,s=e.length;r<s;r++)n[r]=e[r].clone();return n}acceptOverwrite(e,n,r,s){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),s!==0&&(this.background=s)}},An=class Oe{constructor(e,n=[],r={}){this._mainRule=e,this._children=r,this._rulesWithParentScopes=n}_rulesWithParentScopes;static _cmpBySpecificity(e,n){if(e.scopeDepth!==n.scopeDepth)return n.scopeDepth-e.scopeDepth;let r=0,s=0;for(;e.parentScopes[r]===">"&&r++,n.parentScopes[s]===">"&&s++,!(r>=e.parentScopes.length||s>=n.parentScopes.length);){const o=n.parentScopes[s].length-e.parentScopes[r].length;if(o!==0)return o;r++,s++}return n.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let r=e.indexOf("."),s,o;if(r===-1?(s=e,o=""):(s=e.substring(0,r),o=e.substring(r+1)),this._children.hasOwnProperty(s))return this._children[s].match(o)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Oe._cmpBySpecificity),n}insert(e,n,r,s,o,a){if(n===""){this._doInsertHere(e,r,s,o,a);return}let i=n.indexOf("."),l,c;i===-1?(l=n,c=""):(l=n.substring(0,i),c=n.substring(i+1));let u;this._children.hasOwnProperty(l)?u=this._children[l]:(u=new Oe(this._mainRule.clone(),Ie.cloneArr(this._rulesWithParentScopes)),this._children[l]=u),u.insert(e+1,c,r,s,o,a)}_doInsertHere(e,n,r,s,o){if(n===null){this._mainRule.acceptOverwrite(e,r,s,o);return}for(let a=0,i=this._rulesWithParentScopes.length;a<i;a++){let l=this._rulesWithParentScopes[a];if(At(l.parentScopes,n)===0){l.acceptOverwrite(e,r,s,o);return}}r===-1&&(r=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),o===0&&(o=this._mainRule.background),this._rulesWithParentScopes.push(new Ie(e,n,r,s,o))}},j=class I{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const n=I.getLanguageId(e),r=I.getTokenType(e),s=I.getFontStyle(e),o=I.getForeground(e),a=I.getBackground(e);console.log({languageId:n,tokenType:r,fontStyle:s,foreground:o,background:a})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,n,r,s,o,a,i){let l=I.getLanguageId(e),c=I.getTokenType(e),u=I.containsBalancedBrackets(e)?1:0,h=I.getFontStyle(e),f=I.getForeground(e),g=I.getBackground(e);return n!==0&&(l=n),r!==8&&(c=r),s!==null&&(u=s?1:0),o!==-1&&(h=o),a!==0&&(f=a),i!==0&&(g=i),(l<<0|c<<8|u<<10|h<<11|f<<15|g<<24)>>>0}};function ue(t,e){const n=[],r=Nn(t);let s=r.next();for(;s!==null;){let l=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=r.next()}let c=a();if(n.push({matcher:c,priority:l}),s!==",")break;s=r.next()}return n;function o(){if(s==="-"){s=r.next();const l=o();return c=>!!l&&!l(c)}if(s==="("){s=r.next();const l=i();return s===")"&&(s=r.next()),l}if(nt(s)){const l=[];do l.push(s),s=r.next();while(nt(s));return c=>e(l,c)}return null}function a(){const l=[];let c=o();for(;c;)l.push(c),c=o();return u=>l.every(h=>h(u))}function i(){const l=[];let c=a();for(;c&&(l.push(c),s==="|"||s===",");){do s=r.next();while(s==="|"||s===",");c=a()}return u=>l.some(h=>h(u))}}function nt(t){return!!t&&!!t.match(/[\w\.:]+/)}function Nn(t){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=e.exec(t);return{next:()=>{if(!n)return null;const r=n[0];return n=e.exec(t),r}}}function Pt(t){typeof t.dispose=="function"&&t.dispose()}var Y=class{constructor(t){this.scopeName=t}toKey(){return this.scopeName}},xn=class{constructor(t,e){this.scopeName=t,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},Ln=class{_references=[];_seenReferenceKeys=new Set;get references(){return this._references}visitedRule=new Set;add(t){const e=t.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(t))}},En=class{constructor(t,e){this.repo=t,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new Y(this.initialScopeName)]}seenFullScopeRequests=new Set;seenPartialScopeRequests=new Set;Q;processQueue(){const t=this.Q;this.Q=[];const e=new Ln;for(const n of t)Pn(n,this.initialScopeName,this.repo,e);for(const n of e.references)if(n instanceof Y){if(this.seenFullScopeRequests.has(n.scopeName))continue;this.seenFullScopeRequests.add(n.scopeName),this.Q.push(n)}else{if(this.seenFullScopeRequests.has(n.scopeName)||this.seenPartialScopeRequests.has(n.toKey()))continue;this.seenPartialScopeRequests.add(n.toKey()),this.Q.push(n)}}};function Pn(t,e,n,r){const s=n.lookup(t.scopeName);if(!s){if(t.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const o=n.lookup(e);t instanceof Y?le({baseGrammar:o,selfGrammar:s},r):Me(t.ruleName,{baseGrammar:o,selfGrammar:s,repository:s.repository},r);const a=n.injections(t.scopeName);if(a)for(const i of a)r.add(new Y(i))}function Me(t,e,n){if(e.repository&&e.repository[t]){const r=e.repository[t];he([r],e,n)}}function le(t,e){t.selfGrammar.patterns&&Array.isArray(t.selfGrammar.patterns)&&he(t.selfGrammar.patterns,{...t,repository:t.selfGrammar.repository},e),t.selfGrammar.injections&&he(Object.values(t.selfGrammar.injections),{...t,repository:t.selfGrammar.repository},e)}function he(t,e,n){for(const r of t){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const s=r.repository?vt({},e.repository,r.repository):e.repository;Array.isArray(r.patterns)&&he(r.patterns,{...e,repository:s},n);const o=r.include;if(!o)continue;const a=It(o);switch(a.kind){case 0:le({...e,selfGrammar:e.baseGrammar},n);break;case 1:le(e,n);break;case 2:Me(a.ruleName,{...e,repository:s},n);break;case 3:case 4:const i=a.scopeName===e.selfGrammar.scopeName?e.selfGrammar:a.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(i){const l={baseGrammar:e.baseGrammar,selfGrammar:i,repository:s};a.kind===4?Me(a.ruleName,l,n):le(l,n)}else a.kind===4?n.add(new xn(a.scopeName,a.ruleName)):n.add(new Y(a.scopeName));break}}}var In=class{kind=0},On=class{kind=1},Mn=class{constructor(t){this.ruleName=t}kind=2},Bn=class{constructor(t){this.scopeName=t}kind=3},Gn=class{constructor(t,e){this.scopeName=t,this.ruleName=e}kind=4};function It(t){if(t==="$base")return new In;if(t==="$self")return new On;const e=t.indexOf("#");if(e===-1)return new Bn(t);if(e===0)return new Mn(t.substring(1));{const n=t.substring(0,e),r=t.substring(e+1);return new Gn(n,r)}}var $n=/\\(\d+)/,rt=/\\(\d+)/g,Dn=-1,Ot=-2;var te=class{$location;id;_nameIsCapturing;_name;_contentNameIsCapturing;_contentName;constructor(t,e,n,r){this.$location=t,this.id=e,this._name=n||null,this._nameIsCapturing=se.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=se.hasCaptures(this._contentName)}get debugName(){const t=this.$location?`${Rt(this.$location.filename)}:${this.$location.line}`:"unknown";return`${this.constructor.name}#${this.id} @ ${t}`}getName(t,e){return!this._nameIsCapturing||this._name===null||t===null||e===null?this._name:se.replaceCaptures(this._name,t,e)}getContentName(t,e){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:se.replaceCaptures(this._contentName,t,e)}},jn=class extends te{retokenizeCapturedWithRuleId;constructor(t,e,n,r,s){super(t,e,n,r),this.retokenizeCapturedWithRuleId=s}dispose(){}collectPatterns(t,e){throw new Error("Not supported!")}compile(t,e){throw new Error("Not supported!")}compileAG(t,e,n,r){throw new Error("Not supported!")}},Fn=class extends te{_match;captures;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,null),this._match=new X(r,this.id),this.captures=s,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(t,e){e.push(this._match)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new J,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},st=class extends te{hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s){super(t,e,n,r),this.patterns=s.patterns,this.hasMissingPatterns=s.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(t,e){for(const n of this.patterns)t.getRule(n).collectPatterns(t,e)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new J,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Be=class extends te{_begin;beginCaptures;_end;endHasBackReferences;endCaptures;applyEndPatternLast;hasMissingPatterns;patterns;_cachedCompiledPatterns;constructor(t,e,n,r,s,o,a,i,l,c){super(t,e,n,r),this._begin=new X(s,this.id),this.beginCaptures=o,this._end=new X(a||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=i,this.applyEndPatternLast=l||!1,this.patterns=c.patterns,this.hasMissingPatterns=c.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,e){return this._end.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t,e).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t,e).compileAG(t,n,r)}_getCachedCompiledPatterns(t,e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new J;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,e):this._cachedCompiledPatterns.setSource(0,e)),this._cachedCompiledPatterns}},de=class extends te{_begin;beginCaptures;whileCaptures;_while;whileHasBackReferences;hasMissingPatterns;patterns;_cachedCompiledPatterns;_cachedCompiledWhilePatterns;constructor(t,e,n,r,s,o,a,i,l){super(t,e,n,r),this._begin=new X(s,this.id),this.beginCaptures=o,this.whileCaptures=i,this._while=new X(a,Ot),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=l.patterns,this.hasMissingPatterns=l.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,e){return this._while.resolveBackReferences(t,e)}collectPatterns(t,e){e.push(this._begin)}compile(t,e){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,e,n,r){return this._getCachedCompiledPatterns(t).compileAG(t,n,r)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new J;for(const e of this.patterns)t.getRule(e).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,e){return this._getCachedCompiledWhilePatterns(t,e).compile(t)}compileWhileAG(t,e,n,r){return this._getCachedCompiledWhilePatterns(t,e).compileAG(t,n,r)}_getCachedCompiledWhilePatterns(t,e){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new J,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,e||"￿"),this._cachedCompiledWhilePatterns}},Mt=class N{static createCaptureRule(e,n,r,s,o){return e.registerRule(a=>new jn(n,a,r,s,o))}static getCompiledRuleId(e,n,r){return e.id||n.registerRule(s=>{if(e.id=s,e.match)return new Fn(e.$vscodeTextmateLocation,e.id,e.name,e.match,N._compileCaptures(e.captures,n,r));if(typeof e.begin>"u"){e.repository&&(r=vt({},r,e.repository));let o=e.patterns;return typeof o>"u"&&e.include&&(o=[{include:e.include}]),new st(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,N._compilePatterns(o,n,r))}return e.while?new de(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,N._compileCaptures(e.beginCaptures||e.captures,n,r),e.while,N._compileCaptures(e.whileCaptures||e.captures,n,r),N._compilePatterns(e.patterns,n,r)):new Be(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,N._compileCaptures(e.beginCaptures||e.captures,n,r),e.end,N._compileCaptures(e.endCaptures||e.captures,n,r),e.applyEndPatternLast,N._compilePatterns(e.patterns,n,r))}),e.id}static _compileCaptures(e,n,r){let s=[];if(e){let o=0;for(const a in e){if(a==="$vscodeTextmateLocation")continue;const i=parseInt(a,10);i>o&&(o=i)}for(let a=0;a<=o;a++)s[a]=null;for(const a in e){if(a==="$vscodeTextmateLocation")continue;const i=parseInt(a,10);let l=0;e[a].patterns&&(l=N.getCompiledRuleId(e[a],n,r)),s[i]=N.createCaptureRule(n,e[a].$vscodeTextmateLocation,e[a].name,e[a].contentName,l)}}return s}static _compilePatterns(e,n,r){let s=[];if(e)for(let o=0,a=e.length;o<a;o++){const i=e[o];let l=-1;if(i.include){const c=It(i.include);switch(c.kind){case 0:case 1:l=N.getCompiledRuleId(r[i.include],n,r);break;case 2:let u=r[c.ruleName];u&&(l=N.getCompiledRuleId(u,n,r));break;case 3:case 4:const h=c.scopeName,f=c.kind===4?c.ruleName:null,g=n.getExternalGrammar(h,r);if(g)if(f){let p=g.repository[f];p&&(l=N.getCompiledRuleId(p,n,g.repository))}else l=N.getCompiledRuleId(g.repository.$self,n,g.repository);break}}else l=N.getCompiledRuleId(i,n,r);if(l!==-1){const c=n.getRule(l);let u=!1;if((c instanceof st||c instanceof Be||c instanceof de)&&c.hasMissingPatterns&&c.patterns.length===0&&(u=!0),u)continue;s.push(l)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},X=class Bt{source;ruleId;hasAnchor;hasBackReferences;_anchorCache;constructor(e,n){if(e&&typeof e=="string"){const r=e.length;let s=0,o=[],a=!1;for(let i=0;i<r;i++)if(e.charAt(i)==="\\"&&i+1<r){const c=e.charAt(i+1);c==="z"?(o.push(e.substring(s,i)),o.push("$(?!\\n)(?<!\\n)"),s=i+2):(c==="A"||c==="G")&&(a=!0),i++}this.hasAnchor=a,s===0?this.source=e:(o.push(e.substring(s,r)),this.source=o.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=n,typeof this.source=="string"?this.hasBackReferences=$n.test(this.source):this.hasBackReferences=!1}clone(){return new Bt(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(s=>e.substring(s.start,s.end));return rt.lastIndex=0,this.source.replace(rt,(s,o)=>Nt(r[parseInt(o,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],n=[],r=[],s=[],o,a,i,l;for(o=0,a=this.source.length;o<a;o++)i=this.source.charAt(o),e[o]=i,n[o]=i,r[o]=i,s[o]=i,i==="\\"&&o+1<a&&(l=this.source.charAt(o+1),l==="A"?(e[o+1]="￿",n[o+1]="￿",r[o+1]="A",s[o+1]="A"):l==="G"?(e[o+1]="￿",n[o+1]="G",r[o+1]="￿",s[o+1]="G"):(e[o+1]=l,n[o+1]=l,r[o+1]=l,s[o+1]=l),o++);return{A0_G0:e.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:s.join("")}}resolveAnchors(e,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},J=class{_items;_hasAnchors;_cached;_anchorCache;constructor(){this._items=[],this._hasAnchors=!1,this._cached=null,this._anchorCache={A0_G0:null,A0_G1:null,A1_G0:null,A1_G1:null}}dispose(){this._disposeCaches()}_disposeCaches(){this._cached&&(this._cached.dispose(),this._cached=null),this._anchorCache.A0_G0&&(this._anchorCache.A0_G0.dispose(),this._anchorCache.A0_G0=null),this._anchorCache.A0_G1&&(this._anchorCache.A0_G1.dispose(),this._anchorCache.A0_G1=null),this._anchorCache.A1_G0&&(this._anchorCache.A1_G0.dispose(),this._anchorCache.A1_G0=null),this._anchorCache.A1_G1&&(this._anchorCache.A1_G1.dispose(),this._anchorCache.A1_G1=null)}push(t){this._items.push(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}unshift(t){this._items.unshift(t),this._hasAnchors=this._hasAnchors||t.hasAnchor}length(){return this._items.length}setSource(t,e){this._items[t].source!==e&&(this._disposeCaches(),this._items[t].setSource(e))}compile(t){if(!this._cached){let e=this._items.map(n=>n.source);this._cached=new ot(t,e,this._items.map(n=>n.ruleId))}return this._cached}compileAG(t,e,n){return this._hasAnchors?e?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(t,e,n)),this._anchorCache.A0_G0):this.compile(t)}_resolveAnchors(t,e,n){let r=this._items.map(s=>s.resolveAnchors(e,n));return new ot(t,r,this._items.map(s=>s.ruleId))}},ot=class{constructor(t,e,n){this.regExps=e,this.rules=n,this.scanner=t.createOnigScanner(e)}scanner;dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const t=[];for(let e=0,n=this.rules.length;e<n;e++)t.push(" - "+this.rules[e]+": "+this.regExps[e]);return t.join(`
2
+ `)}findNextMatchSync(t,e,n){const r=this.scanner.findNextMatchSync(t,e,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Ne=class{constructor(t,e){this.languageId=t,this.tokenType=e}},Wn=class Ge{_defaultAttributes;_embeddedLanguagesMatcher;constructor(e,n){this._defaultAttributes=new Ne(e,8),this._embeddedLanguagesMatcher=new zn(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?Ge._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}static _NULL_SCOPE_METADATA=new Ne(0,0);_getBasicScopeAttributes=new xt(e=>{const n=this._scopeToLanguage(e),r=this._toStandardTokenType(e);return new Ne(n,r)});_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const n=e.match(Ge.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}static STANDARD_TOKEN_TYPE_REGEXP=/\b(comment|string|regex|meta\.embedded)\b/},zn=class{values;scopesRegExp;constructor(t){if(t.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(t);const e=t.map(([n,r])=>Nt(n));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(t){if(!this.scopesRegExp)return;const e=t.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},at=class{constructor(t,e){this.stack=t,this.stoppedEarly=e}};function Gt(t,e,n,r,s,o,a,i){const l=e.content.length;let c=!1,u=-1;if(a){const g=Hn(t,e,n,r,s,o);s=g.stack,r=g.linePos,n=g.isFirstLine,u=g.anchorPosition}const h=Date.now();for(;!c;){if(i!==0&&Date.now()-h>i)return new at(s,!0);f()}return new at(s,!1);function f(){const g=Un(t,e,n,r,s,u);if(!g){o.produce(s,l),c=!0;return}const p=g.captureIndices,b=g.matchedRuleId,_=p&&p.length>0?p[0].end>r:!1;if(b===Dn){const y=s.getRule(t);o.produce(s,p[0].start),s=s.withContentNameScopesList(s.nameScopesList),V(t,e,n,s,o,y.endCaptures,p),o.produce(s,p[0].end);const m=s;if(s=s.parent,u=m.getAnchorPos(),!_&&m.getEnterPos()===r){s=m,o.produce(s,l),c=!0;return}}else{const y=t.getRule(b);o.produce(s,p[0].start);const m=s,C=y.getName(e.content,p),v=s.contentNameScopesList.pushAttributed(C,t);if(s=s.push(b,r,u,p[0].end===l,null,v,v),y instanceof Be){const A=y;V(t,e,n,s,o,A.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const P=A.getContentName(e.content,p),B=v.pushAttributed(P,t);if(s=s.withContentNameScopesList(B),A.endHasBackReferences&&(s=s.withEndRule(A.getEndWithResolvedBackReferences(e.content,p))),!_&&m.hasSameRuleAs(s)){s=s.pop(),o.produce(s,l),c=!0;return}}else if(y instanceof de){const A=y;V(t,e,n,s,o,A.beginCaptures,p),o.produce(s,p[0].end),u=p[0].end;const P=A.getContentName(e.content,p),B=v.pushAttributed(P,t);if(s=s.withContentNameScopesList(B),A.whileHasBackReferences&&(s=s.withEndRule(A.getWhileWithResolvedBackReferences(e.content,p))),!_&&m.hasSameRuleAs(s)){s=s.pop(),o.produce(s,l),c=!0;return}}else if(V(t,e,n,s,o,y.captures,p),o.produce(s,p[0].end),s=s.pop(),!_){s=s.safePop(),o.produce(s,l),c=!0;return}}p[0].end>r&&(r=p[0].end,n=!1)}}function Hn(t,e,n,r,s,o){let a=s.beginRuleCapturedEOL?0:-1;const i=[];for(let l=s;l;l=l.pop()){const c=l.getRule(t);c instanceof de&&i.push({rule:c,stack:l})}for(let l=i.pop();l;l=i.pop()){const{ruleScanner:c,findOptions:u}=Kn(l.rule,t,l.stack.endRule,n,r===a),h=c.findNextMatchSync(e,r,u);if(h){if(h.ruleId!==Ot){s=l.stack.pop();break}h.captureIndices&&h.captureIndices.length&&(o.produce(l.stack,h.captureIndices[0].start),V(t,e,n,l.stack,o,l.rule.whileCaptures,h.captureIndices),o.produce(l.stack,h.captureIndices[0].end),a=h.captureIndices[0].end,h.captureIndices[0].end>r&&(r=h.captureIndices[0].end,n=!1))}else{s=l.stack.pop();break}}return{stack:s,linePos:r,anchorPosition:a,isFirstLine:n}}function Un(t,e,n,r,s,o){const a=qn(t,e,n,r,s,o),i=t.getInjections();if(i.length===0)return a;const l=Vn(i,t,e,n,r,s,o);if(!l)return a;if(!a)return l;const c=a.captureIndices[0].start,u=l.captureIndices[0].start;return u<c||l.priorityMatch&&u===c?l:a}function qn(t,e,n,r,s,o){const a=s.getRule(t),{ruleScanner:i,findOptions:l}=$t(a,t,s.endRule,n,r===o),c=i.findNextMatchSync(e,r,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function Vn(t,e,n,r,s,o,a){let i=Number.MAX_VALUE,l=null,c,u=0;const h=o.contentNameScopesList.getScopeNames();for(let f=0,g=t.length;f<g;f++){const p=t[f];if(!p.matcher(h))continue;const b=e.getRule(p.ruleId),{ruleScanner:_,findOptions:y}=$t(b,e,null,r,s===a),m=_.findNextMatchSync(n,s,y);if(!m)continue;const C=m.captureIndices[0].start;if(!(C>=i)&&(i=C,l=m.captureIndices,c=m.ruleId,u=p.priority,i===s))break}return l?{priorityMatch:u===-1,captureIndices:l,matchedRuleId:c}:null}function $t(t,e,n,r,s){return{ruleScanner:t.compileAG(e,n,r,s),findOptions:0}}function Kn(t,e,n,r,s){return{ruleScanner:t.compileWhileAG(e,n,r,s),findOptions:0}}function V(t,e,n,r,s,o,a){if(o.length===0)return;const i=e.content,l=Math.min(o.length,a.length),c=[],u=a[0].end;for(let h=0;h<l;h++){const f=o[h];if(f===null)continue;const g=a[h];if(g.length===0)continue;if(g.start>u)break;for(;c.length>0&&c[c.length-1].endPos<=g.start;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?s.produceFromScopes(c[c.length-1].scopes,g.start):s.produce(r,g.start),f.retokenizeCapturedWithRuleId){const b=f.getName(i,a),_=r.contentNameScopesList.pushAttributed(b,t),y=f.getContentName(i,a),m=_.pushAttributed(y,t),C=r.push(f.retokenizeCapturedWithRuleId,g.start,-1,!1,null,_,m),v=t.createOnigString(i.substring(0,g.end));Gt(t,v,n&&g.start===0,g.start,C,s,!1,0),Pt(v);continue}const p=f.getName(i,a);if(p!==null){const _=(c.length>0?c[c.length-1].scopes:r.contentNameScopesList).pushAttributed(p,t);c.push(new Yn(_,g.end))}}for(;c.length>0;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var Yn=class{scopes;endPos;constructor(t,e){this.scopes=t,this.endPos=e}};function Xn(t,e,n,r,s,o,a,i){return new Qn(t,e,n,r,s,o,a,i)}function it(t,e,n,r,s){const o=ue(e,fe),a=Mt.getCompiledRuleId(n,r,s.repository);for(const i of o)t.push({debugSelector:e,matcher:i.matcher,ruleId:a,grammar:s,priority:i.priority})}function fe(t,e){if(e.length<t.length)return!1;let n=0;return t.every(r=>{for(let s=n;s<e.length;s++)if(Jn(e[s],r))return n=s+1,!0;return!1})}function Jn(t,e){if(!t)return!1;if(t===e)return!0;const n=e.length;return t.length>n&&t.substr(0,n)===e&&t[n]==="."}var Qn=class{constructor(t,e,n,r,s,o,a,i){if(this._rootScopeName=t,this.balancedBracketSelectors=o,this._onigLib=i,this._basicScopeAttributesProvider=new Wn(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=a,this._grammar=lt(e,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const l of Object.keys(s)){const c=ue(l,fe);for(const u of c)this._tokenTypeMatchers.push({matcher:u.matcher,type:s[l]})}}_rootId;_lastRuleId;_ruleId2desc;_includedGrammars;_grammarRepository;_grammar;_injections;_basicScopeAttributesProvider;_tokenTypeMatchers;get themeProvider(){return this._grammarRepository}dispose(){for(const t of this._ruleId2desc)t&&t.dispose()}createOnigScanner(t){return this._onigLib.createOnigScanner(t)}createOnigString(t){return this._onigLib.createOnigString(t)}getMetadataForScope(t){return this._basicScopeAttributesProvider.getBasicScopeAttributes(t)}_collectInjections(){const t={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},e=[],n=this._rootScopeName,r=t.lookup(n);if(r){const s=r.injections;if(s)for(let a in s)it(e,a,s[a],this,r);const o=this._grammarRepository.injections(n);o&&o.forEach(a=>{const i=this.getExternalGrammar(a);if(i){const l=i.injectionSelector;l&&it(e,l,i,this,i)}})}return e.sort((s,o)=>s.priority-o.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(t){const e=++this._lastRuleId,n=t(e);return this._ruleId2desc[e]=n,n}getRule(t){return this._ruleId2desc[t]}getExternalGrammar(t,e){if(this._includedGrammars[t])return this._includedGrammars[t];if(this._grammarRepository){const n=this._grammarRepository.lookup(t);if(n)return this._includedGrammars[t]=lt(n,e&&e.$base),this._includedGrammars[t]}}tokenizeLine(t,e,n=0){const r=this._tokenize(t,e,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(t,e,n=0){const r=this._tokenize(t,e,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(t,e,n,r){this._rootId===-1&&(this._rootId=Mt.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!e||e===$e.NULL){s=!0;const c=this._basicScopeAttributesProvider.getDefaultAttributes(),u=this.themeProvider.getDefaults(),h=j.set(0,c.languageId,c.tokenType,null,u.fontStyle,u.foregroundId,u.backgroundId),f=this.getRule(this._rootId).getName(null,null);let g;f?g=K.createRootAndLookUpScopeName(f,h,this):g=K.createRoot("unknown",h),e=new $e(null,this._rootId,-1,-1,!1,null,g,g)}else s=!1,e.reset();t=t+`
3
+ `;const o=this.createOnigString(t),a=o.content.length,i=new er(n,t,this._tokenTypeMatchers,this.balancedBracketSelectors),l=Gt(this,o,s,0,e,i,!0,r);return Pt(o),{lineLength:a,lineTokens:i,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function lt(t,e){return t=yn(t),t.repository=t.repository||{},t.repository.$self={$vscodeTextmateLocation:t.$vscodeTextmateLocation,patterns:t.patterns,name:t.scopeName},t.repository.$base=e||t.repository.$self,t}var K=class O{constructor(e,n,r){this.parent=e,this.scopePath=n,this.tokenAttributes=r}static fromExtension(e,n){let r=e,s=e?.scopePath??null;for(const o of n)s=Ae.push(s,o.scopeNames),r=new O(r,s,o.encodedTokenAttributes);return r}static createRoot(e,n){return new O(null,new Ae(null,e),n)}static createRootAndLookUpScopeName(e,n,r){const s=r.getMetadataForScope(e),o=new Ae(null,e),a=r.themeProvider.themeMatch(o),i=O.mergeAttributes(n,s,a);return new O(null,o,i)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return O.equals(this,e)}static equals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.scopeName!==n.scopeName||e.tokenAttributes!==n.tokenAttributes)return!1;e=e.parent,n=n.parent}while(!0)}static mergeAttributes(e,n,r){let s=-1,o=0,a=0;return r!==null&&(s=r.fontStyle,o=r.foregroundId,a=r.backgroundId),j.set(e,n.languageId,n.tokenType,null,s,o,a)}pushAttributed(e,n){if(e===null)return this;if(e.indexOf(" ")===-1)return O._pushAttributed(this,e,n);const r=e.split(/ /g);let s=this;for(const o of r)s=O._pushAttributed(s,o,n);return s}static _pushAttributed(e,n,r){const s=r.getMetadataForScope(n),o=e.scopePath.push(n),a=r.themeProvider.themeMatch(o),i=O.mergeAttributes(e.tokenAttributes,s,a);return new O(e,o,i)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){const n=[];let r=this;for(;r&&r!==e;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(r.parent?.scopePath??null)}),r=r.parent;return r===e?n.reverse():void 0}},$e=class ${constructor(e,n,r,s,o,a,i,l){this.parent=e,this.ruleId=n,this.beginRuleCapturedEOL=o,this.endRule=a,this.nameScopesList=i,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=r,this._anchorPos=s}_stackElementBrand=void 0;static NULL=new $(null,0,0,0,!1,null,null,null);_enterPos;_anchorPos;depth;equals(e){return e===null?!1:$._equals(this,e)}static _equals(e,n){return e===n?!0:this._structuralEquals(e,n)?K.equals(e.contentNameScopesList,n.contentNameScopesList):!1}static _structuralEquals(e,n){do{if(e===n||!e&&!n)return!0;if(!e||!n||e.depth!==n.depth||e.ruleId!==n.ruleId||e.endRule!==n.endRule)return!1;e=e.parent,n=n.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){$._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,n,r,s,o,a,i){return new $(this,e,n,r,s,o,a,i)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,n){return this.parent&&(n=this.parent._writeString(e,n)),e[n++]=`(${this.ruleId}, ${this.nameScopesList?.toString()}, ${this.contentNameScopesList?.toString()})`,n}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new $(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let n=this;for(;n&&n._enterPos===e._enterPos;){if(n.ruleId===e.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:this.nameScopesList?.getExtensionIfDefined(this.parent?.nameScopesList??null)??[],contentNameScopesList:this.contentNameScopesList?.getExtensionIfDefined(this.nameScopesList)??[]}}static pushFrame(e,n){const r=K.fromExtension(e?.nameScopesList??null,n.nameScopesList);return new $(e,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,K.fromExtension(r,n.contentNameScopesList))}},Zn=class{balancedBracketScopes;unbalancedBracketScopes;allowAny=!1;constructor(t,e){this.balancedBracketScopes=t.flatMap(n=>n==="*"?(this.allowAny=!0,[]):ue(n,fe).map(r=>r.matcher)),this.unbalancedBracketScopes=e.flatMap(n=>ue(n,fe).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(t){for(const e of this.unbalancedBracketScopes)if(e(t))return!1;for(const e of this.balancedBracketScopes)if(e(t))return!0;return this.allowAny}},er=class{constructor(t,e,n,r){this.balancedBracketSelectors=r,this._emitBinaryTokens=t,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}_emitBinaryTokens;_lineText;_tokens;_binaryTokens;_lastTokenEndIndex;_tokenTypeOverrides;produce(t,e){this.produceFromScopes(t.contentNameScopesList,e)}produceFromScopes(t,e){if(this._lastTokenEndIndex>=e)return;if(this._emitBinaryTokens){let r=t?.tokenAttributes??0,s=!1;if(this.balancedBracketSelectors?.matchesAlways&&(s=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const o=t?.getScopeNames()??[];for(const a of this._tokenTypeOverrides)a.matcher(o)&&(r=j.set(r,0,a.type,null,-1,0,0));this.balancedBracketSelectors&&(s=this.balancedBracketSelectors.match(o))}if(s&&(r=j.set(r,0,8,s,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=e;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=e;return}const n=t?.getScopeNames()??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:e,scopes:n}),this._lastTokenEndIndex=e}getResult(t,e){return this._tokens.length>0&&this._tokens[this._tokens.length-1].startIndex===e-1&&this._tokens.pop(),this._tokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._tokens[this._tokens.length-1].startIndex=0),this._tokens}getBinaryResult(t,e){this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-2]===e-1&&(this._binaryTokens.pop(),this._binaryTokens.pop()),this._binaryTokens.length===0&&(this._lastTokenEndIndex=-1,this.produce(t,e),this._binaryTokens[this._binaryTokens.length-2]=0);const n=new Uint32Array(this._binaryTokens.length);for(let r=0,s=this._binaryTokens.length;r<s;r++)n[r]=this._binaryTokens[r];return n}},tr=class{constructor(t,e){this._onigLib=e,this._theme=t}_grammars=new Map;_rawGrammars=new Map;_injectionGrammars=new Map;_theme;dispose(){for(const t of this._grammars.values())t.dispose()}setTheme(t){this._theme=t}getColorMap(){return this._theme.getColorMap()}addGrammar(t,e){this._rawGrammars.set(t.scopeName,t),e&&this._injectionGrammars.set(t.scopeName,e)}lookup(t){return this._rawGrammars.get(t)}injections(t){return this._injectionGrammars.get(t)}getDefaults(){return this._theme.getDefaults()}themeMatch(t){return this._theme.match(t)}grammarForScopeName(t,e,n,r,s){if(!this._grammars.has(t)){let o=this._rawGrammars.get(t);if(!o)return null;this._grammars.set(t,Xn(t,o,e,n,r,s,this,this._onigLib))}return this._grammars.get(t)}},nr=class{_options;_syncRegistry;_ensureGrammarCache;constructor(e){this._options=e,this._syncRegistry=new tr(ce.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,n){this._syncRegistry.setTheme(ce.createFromRawTheme(e,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,n,r){return this.loadGrammarWithConfiguration(e,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(e,n,r){return this._loadGrammar(e,n,r.embeddedLanguages,r.tokenTypes,new Zn(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,n,r,s,o){const a=new En(this._syncRegistry,e);for(;a.Q.length>0;)a.Q.map(i=>this._loadSingleGrammar(i.scopeName)),a.processQueue();return this._grammarForScopeName(e,n,r,s,o)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const n=this._options.loadGrammar(e);if(n){const r=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(e,n=[],r=0,s=null){return this._syncRegistry.addGrammar(e,n),this._grammarForScopeName(e.scopeName,r,s)}_grammarForScopeName(e,n=0,r=null,s=null,o=null){return this._syncRegistry.grammarForScopeName(e,n,r,s,o)}},De=$e.NULL;function ge(t,e){const n=typeof t=="string"?{}:{...t.colorReplacements},r=typeof t=="string"?t:t.name;for(const[s,o]of Object.entries(e?.colorReplacements||{}))typeof o=="string"?n[s]=o:s===r&&Object.assign(n,o);return n}function G(t,e){return t&&(e?.[t?.toLowerCase()]||t)}function rr(t){return Array.isArray(t)?t:[t]}async function Dt(t){return Promise.resolve(typeof t=="function"?t():t).then(e=>e.default||e)}function _e(t){return!t||["plaintext","txt","text","plain"].includes(t)}function jt(t){return t==="ansi"||_e(t)}function be(t){return t==="none"}function Ft(t){return be(t)}const sr=/(\r?\n)/g;function Se(t,e=!1){if(t.length===0)return[["",0]];const n=t.split(sr);let r=0;const s=[];for(let o=0;o<n.length;o+=2){const a=e?n[o]+(n[o+1]||""):n[o];s.push([a,r]),r+=n[o].length,r+=n[o+1]?.length||0}return s}const ct={light:"#333333",dark:"#bbbbbb"},ut={light:"#fffffe",dark:"#1e1e1e"},ht="__shiki_resolved";function qe(t){if(t?.[ht])return t;const e={...t};e.tokenColors&&!e.settings&&(e.settings=e.tokenColors,delete e.tokenColors),e.type||="dark",e.colorReplacements={...e.colorReplacements},e.settings||=[];let{bg:n,fg:r}=e;if(!n||!r){const i=e.settings?e.settings.find(l=>!l.name&&!l.scope):void 0;i?.settings?.foreground&&(r=i.settings.foreground),i?.settings?.background&&(n=i.settings.background),!r&&e?.colors?.["editor.foreground"]&&(r=e.colors["editor.foreground"]),!n&&e?.colors?.["editor.background"]&&(n=e.colors["editor.background"]),r||(r=e.type==="light"?ct.light:ct.dark),n||(n=e.type==="light"?ut.light:ut.dark),e.fg=r,e.bg=n}e.settings[0]&&e.settings[0].settings&&!e.settings[0].scope||e.settings.unshift({settings:{foreground:e.fg,background:e.bg}});let s=0;const o=new Map;function a(i){if(o.has(i))return o.get(i);s+=1;const l=`#${s.toString(16).padStart(8,"0").toLowerCase()}`;return e.colorReplacements?.[`#${l}`]?a(i):(o.set(i,l),l)}e.settings=e.settings.map(i=>{const l=i.settings?.foreground&&!i.settings.foreground.startsWith("#"),c=i.settings?.background&&!i.settings.background.startsWith("#");if(!l&&!c)return i;const u={...i,settings:{...i.settings}};if(l){const h=a(i.settings.foreground);e.colorReplacements[h]=i.settings.foreground,u.settings.foreground=h}if(c){const h=a(i.settings.background);e.colorReplacements[h]=i.settings.background,u.settings.background=h}return u});for(const i of Object.keys(e.colors||{}))if((i==="editor.foreground"||i==="editor.background"||i.startsWith("terminal.ansi"))&&!e.colors[i]?.startsWith("#")){const l=a(e.colors[i]);e.colorReplacements[l]=e.colors[i],e.colors[i]=l}return Object.defineProperty(e,ht,{enumerable:!1,writable:!1,value:!0}),e}async function Wt(t){return[...new Set((await Promise.all(t.filter(e=>!jt(e)).map(async e=>await Dt(e).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function zt(t){return(await Promise.all(t.map(async e=>Ft(e)?null:qe(await Dt(e))))).filter(e=>!!e)}function Ht(t,e){if(!e)return t;if(e[t]){const n=new Set([t]);for(;e[t];){if(t=e[t],n.has(t))throw new k(`Circular alias \`${[...n].join(" -> ")} -> ${t}\``);n.add(t)}}return t}var or=class extends nr{_resolver;_themes;_langs;_alias;_resolvedThemes=new Map;_resolvedGrammars=new Map;_langMap=new Map;_langGraph=new Map;_textmateThemeCache=new WeakMap;_loadedThemesCache=null;_loadedLanguagesCache=null;constructor(t,e,n,r={}){super(t),this._resolver=t,this._themes=e,this._langs=n,this._alias=r,this._themes.map(s=>this.loadTheme(s)),this.loadLanguages(this._langs)}getTheme(t){return typeof t=="string"?this._resolvedThemes.get(t):this.loadTheme(t)}loadTheme(t){const e=qe(t);return e.name&&(this._resolvedThemes.set(e.name,e),this._loadedThemesCache=null),e}getLoadedThemes(){return this._loadedThemesCache||(this._loadedThemesCache=[...this._resolvedThemes.keys()]),this._loadedThemesCache}setTheme(t){let e=this._textmateThemeCache.get(t);e||(e=ce.createFromRawTheme(t),this._textmateThemeCache.set(t,e)),this._syncRegistry.setTheme(e)}getGrammar(t){return t=Ht(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){if(this.getGrammar(t.name))return;const e=new Set([...this._langMap.values()].filter(s=>s.embeddedLangsLazy?.includes(t.name)));this._resolver.addLanguage(t);const n={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const r=this.loadGrammarWithConfiguration(t.scopeName,1,n);if(r.name=t.name,this._resolvedGrammars.set(t.name,r),t.aliases&&t.aliases.forEach(s=>{this._alias[s]=t.name}),this._loadedLanguagesCache=null,e.size)for(const s of e)this._syncRegistry?._grammars?.get(s.scopeName)?.dispose(),this._resolvedGrammars.delete(s.name),this._loadedLanguagesCache=null,this._syncRegistry?._injectionGrammars?.delete(s.scopeName),this._syncRegistry?._grammars?.delete(s.scopeName),this.loadLanguage(this._langMap.get(s.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(const r of t)this.resolveEmbeddedLanguages(r);const e=[...this._langGraph.entries()],n=e.filter(([r,s])=>!s);if(n.length){const r=e.filter(([s,o])=>o?(o.embeddedLanguages||o.embeddedLangs)?.some(a=>n.map(([i])=>i).includes(a)):!1).filter(s=>!n.includes(s));throw new k(`Missing languages ${n.map(([s])=>`\`${s}\``).join(", ")}, required by ${r.map(([s])=>`\`${s}\``).join(", ")}`)}for(const[r,s]of e)this._resolver.addLanguage(s);for(const[r,s]of e)this.loadLanguage(s)}getLoadedLanguages(){return this._loadedLanguagesCache||(this._loadedLanguagesCache=[...new Set([...this._resolvedGrammars.keys(),...Object.keys(this._alias)])]),this._loadedLanguagesCache}resolveEmbeddedLanguages(t){this._langMap.set(t.name,t),this._langGraph.set(t.name,t);const e=t.embeddedLanguages??t.embeddedLangs;if(e)for(const n of e)this._langGraph.set(n,this._langMap.get(n))}},ar=class{_langs=new Map;_scopeToLang=new Map;_injections=new Map;_onigLib;constructor(t,e){this._onigLib={createOnigScanner:n=>t.createScanner(n),createOnigString:n=>t.createString(n)},e.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(t){return this._langs.get(t)}loadGrammar(t){return this._scopeToLang.get(t)}addLanguage(t){this._langs.set(t.name,t),t.aliases&&t.aliases.forEach(e=>{this._langs.set(e,t)}),this._scopeToLang.set(t.scopeName,t),t.injectTo&&t.injectTo.forEach(e=>{this._injections.get(e)||this._injections.set(e,[]),this._injections.get(e).includes(t.scopeName)||this._injections.get(e).push(t.scopeName)})}getInjections(t){const e=t.split(".");let n=[];for(let r=1;r<=e.length;r++){const s=e.slice(0,r).join(".");n=[...n,...this._injections.get(s)||[]]}return n}};let q=0;function Ve(t){q+=1,t.warnings!==!1&&q>=10&&q%10===0&&console.warn(`[Shiki] ${q} instances have been created. Shiki is supposed to be used as a singleton, consider refactoring your code to cache your highlighter instance; Or call \`highlighter.dispose()\` to release unused instances.`);let e=!1;if(!t.engine)throw new k("`engine` option is required for synchronous mode");const n=(t.langs||[]).flat(1),r=(t.themes||[]).flat(1).map(qe),s=new or(new ar(t.engine,n),r,n,t.langAlias);let o;function a(m){return Ht(m,t.langAlias)}function i(m){_();const C=s.getGrammar(typeof m=="string"?m:m.name);if(!C)throw new k(`Language \`${m}\` not found, you may need to load it first`);return C}function l(m){if(m==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};_();const C=s.getTheme(m);if(!C)throw new k(`Theme \`${m}\` not found, you may need to load it first`);return C}function c(m){_();const C=l(m);return o!==m&&(s.setTheme(C),o=m),{theme:C,colorMap:s.getColorMap()}}function u(){return _(),s.getLoadedThemes()}function h(){return _(),s.getLoadedLanguages()}function f(...m){_(),s.loadLanguages(m.flat(1))}async function g(...m){return f(await Wt(m))}function p(...m){_();for(const C of m.flat(1))s.loadTheme(C)}async function b(...m){return _(),p(await zt(m))}function _(){if(e)throw new k("Shiki instance has been disposed")}function y(){e||(e=!0,s.dispose(),q-=1)}return{setTheme:c,getTheme:l,getLanguage:i,getLoadedThemes:u,getLoadedLanguages:h,resolveLangAlias:a,loadLanguage:g,loadLanguageSync:f,loadTheme:b,loadThemeSync:p,dispose:y,[Symbol.dispose]:y}}const go=Ve;async function Ut(t){t.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[e,n,r]=await Promise.all([zt(t.themes||[]),Wt(t.langs||[]),t.engine]);return Ve({...t,themes:e,langs:n,engine:r})}const po=Ut,qt=new WeakMap;function Ce(t,e){qt.set(t,e)}function Q(t){return qt.get(t)}var we=class Vt{_stacks={};lang;get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(e,n){return new Vt(Object.fromEntries(rr(n).map(r=>[r,De])),e)}constructor(...e){if(e.length===2){const[n,r]=e;this.lang=r,this._stacks=n}else{const[n,r,s]=e;this.lang=r,this._stacks={[s]:n}}}getInternalStack(e=this.theme){return this._stacks[e]}getScopes(e=this.theme){return ir(this._stacks[e])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function ir(t){const e=[],n=new Set;function r(s){if(n.has(s))return;n.add(s);const o=s?.nameScopesList?.scopeName;o&&e.push(o),s.parent&&r(s.parent)}return r(t),e}function lr(t,e){if(!(t instanceof we))throw new k("Invalid grammar state");return t.getInternalStack(e)}const cr=/,/,ur=/ /;function Kt(t,e,n={}){const{theme:r=t.getLoadedThemes()[0]}=n;if(_e(t.resolveLangAlias(n.lang||"text"))||be(r))return Se(e).map(i=>[{content:i[0],offset:i[1]}]);const{theme:s,colorMap:o}=t.setTheme(r),a=t.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==a.name)throw new k(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${a.name}"`);if(!n.grammarState.themes.includes(s.name))throw new k(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${s.name}"`)}return hr(e,a,s,o,n)}function Yt(...t){if(t.length===2)return Q(t[1]);const[e,n,r={}]=t,{lang:s="text",theme:o=e.getLoadedThemes()[0]}=r;if(_e(s)||be(o))throw new k("Plain language does not have grammar state");if(s==="ansi")throw new k("ANSI language does not have grammar state");const{theme:a,colorMap:i}=e.setTheme(o),l=e.getLanguage(s);return new we(Ke(n,l,a,i,r).stateStack,l.name,a.name)}function hr(t,e,n,r,s){const o=Ke(t,e,n,r,s),a=new we(o.stateStack,e.name,n.name);return Ce(o.tokens,a),o.tokens}function Ke(t,e,n,r,s){const o=ge(n,s),{tokenizeMaxLineLength:a=0,tokenizeTimeLimit:i=500,includeExplanation:l=!1}=s,c=Se(t);let u=s.grammarState?lr(s.grammarState,n.name)??De:s.grammarContextCode!=null?Ke(s.grammarContextCode,e,n,r,{...s,grammarState:void 0,grammarContextCode:void 0}).stateStack:De,h=[];const f=[];for(let g=0,p=c.length;g<p;g++){const[b,_]=c[g];if(b===""){h=[],f.push([]);continue}if(a>0&&b.length>=a){h=[],f.push([{content:b,offset:_,color:"",fontStyle:0}]);continue}let y,m,C;l&&l!=="tokenType"&&(y=e.tokenizeLine(b,u,i),m=y.tokens,C=0);const v=e.tokenizeLine2(b,u,i),A=v.tokens.length/2;for(let P=0;P<A;P++){const B=v.tokens[2*P],ke=P+1<A?v.tokens[2*P+2]:b.length;if(B===ke)continue;const ve=v.tokens[2*P+1],pn=G(r[j.getForeground(ve)],o),mn=j.getFontStyle(ve),re={content:b.substring(B,ke),offset:_+B,color:pn,fontStyle:mn};if(l==="tokenType")re.type=j.getTokenType(ve);else if(l){const Ze=[];if(l!=="scopeName")for(const M of n.settings){let z;switch(typeof M.scope){case"string":z=M.scope.split(cr).map(Re=>Re.trim());break;case"object":z=M.scope;break;default:continue}Ze.push({settings:M,selectors:z.map(Re=>Re.split(ur))})}re.explanation=[];let et=0;for(;B+et<ke;){const M=m[C],z=b.substring(M.startIndex,M.endIndex);et+=z.length,re.explanation.push({content:z,scopes:l==="scopeName"?dr(M.scopes):fr(Ze,M.scopes)}),C+=1}}h.push(re)}f.push(h),h=[],u=v.ruleStack}return{tokens:f,stateStack:u}}function dr(t){return t.map(e=>({scopeName:e}))}function fr(t,e){const n=[];for(let r=0,s=e.length;r<s;r++){const o=e[r];n[r]={scopeName:o,themeMatches:pr(t,o,e.slice(0,r))}}return n}function dt(t,e){return t===e||e.substring(0,t.length)===t&&e[t.length]==="."}function gr(t,e,n){if(!dt(t.at(-1),e))return!1;let r=t.length-2,s=n.length-1;for(;r>=0&&s>=0;)dt(t[r],n[s])&&(r-=1),s-=1;return r===-1}function pr(t,e,n){const r=[];for(const{selectors:s,settings:o}of t)for(const a of s)if(gr(a,e,n)){r.push(o);break}return r}function Ye(t,e,n,r=Kt){const s=Object.entries(n.themes).filter(c=>c[1]).map(c=>({color:c[0],theme:c[1]})),o=s.map(c=>{const u=r(t,e,{...n,theme:c.theme});return{tokens:u,state:Q(u),theme:typeof c.theme=="string"?c.theme:c.theme.name}}),a=mr(...o.map(c=>c.tokens)),i=a[0].map((c,u)=>c.map((h,f)=>{const g={content:h.content,variants:{},offset:h.offset};return"includeExplanation"in n&&n.includeExplanation&&(g.explanation=h.explanation),a.forEach((p,b)=>{const{content:_,explanation:y,offset:m,...C}=p[u][f];g.variants[s[b].color]=C}),g})),l=o[0].state?new we(Object.fromEntries(o.map(c=>[c.theme,c.state?.getInternalStack(c.theme)])),o[0].state.lang):void 0;return l&&Ce(i,l),i}function mr(...t){const e=t.map(()=>[]),n=t.length;for(let r=0;r<t[0].length;r++){const s=t.map(l=>l[r]),o=e.map(()=>[]);e.forEach((l,c)=>l.push(o[c]));const a=s.map(()=>0),i=s.map(l=>l[0]);for(;i.every(l=>l);){const l=Math.min(...i.map(c=>c.content.length));for(let c=0;c<n;c++){const u=i[c];u.content.length===l?(o[c].push(u),a[c]+=1,i[c]=s[c][a[c]]):(o[c].push({...u,content:u.content.slice(0,l)}),i[c]={...u,content:u.content.slice(l),offset:u.offset+l})}}}return e}const yr=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class ne{constructor(e,n,r){this.normal=n,this.property=e,r&&(this.space=r)}}ne.prototype.normal={};ne.prototype.property={};ne.prototype.space=void 0;function Xt(t,e){const n={},r={};for(const s of t)Object.assign(n,s.property),Object.assign(r,s.normal);return new ne(n,r,e)}function je(t){return t.toLowerCase()}class L{constructor(e,n){this.attribute=n,this.property=e}}L.prototype.attribute="";L.prototype.booleanish=!1;L.prototype.boolean=!1;L.prototype.commaOrSpaceSeparated=!1;L.prototype.commaSeparated=!1;L.prototype.defined=!1;L.prototype.mustUseProperty=!1;L.prototype.number=!1;L.prototype.overloadedBoolean=!1;L.prototype.property="";L.prototype.spaceSeparated=!1;L.prototype.space=void 0;let _r=0;const S=W(),R=W(),Fe=W(),d=W(),w=W(),F=W(),E=W();function W(){return 2**++_r}const We=Object.freeze(Object.defineProperty({__proto__:null,boolean:S,booleanish:R,commaOrSpaceSeparated:E,commaSeparated:F,number:d,overloadedBoolean:Fe,spaceSeparated:w},Symbol.toStringTag,{value:"Module"})),xe=Object.keys(We);class Xe extends L{constructor(e,n,r,s){let o=-1;if(super(e,n),ft(this,"space",s),typeof r=="number")for(;++o<xe.length;){const a=xe[o];ft(this,xe[o],(r&We[a])===We[a])}}}Xe.prototype.defined=!0;function ft(t,e,n){n&&(t[e]=n)}function U(t){const e={},n={};for(const[r,s]of Object.entries(t.properties)){const o=new Xe(r,t.transform(t.attributes||{},r),s,t.space);t.mustUseProperty&&t.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),e[r]=o,n[je(r)]=r,n[je(o.attribute)]=r}return new ne(e,n,t.space)}const Jt=U({properties:{ariaActiveDescendant:null,ariaAtomic:R,ariaAutoComplete:null,ariaBusy:R,ariaChecked:R,ariaColCount:d,ariaColIndex:d,ariaColSpan:d,ariaControls:w,ariaCurrent:null,ariaDescribedBy:w,ariaDetails:null,ariaDisabled:R,ariaDropEffect:w,ariaErrorMessage:null,ariaExpanded:R,ariaFlowTo:w,ariaGrabbed:R,ariaHasPopup:null,ariaHidden:R,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:w,ariaLevel:d,ariaLive:null,ariaModal:R,ariaMultiLine:R,ariaMultiSelectable:R,ariaOrientation:null,ariaOwns:w,ariaPlaceholder:null,ariaPosInSet:d,ariaPressed:R,ariaReadOnly:R,ariaRelevant:null,ariaRequired:R,ariaRoleDescription:w,ariaRowCount:d,ariaRowIndex:d,ariaRowSpan:d,ariaSelected:R,ariaSetSize:d,ariaSort:null,ariaValueMax:d,ariaValueMin:d,ariaValueNow:d,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function Qt(t,e){return e in t?t[e]:e}function Zt(t,e){return Qt(t,e.toLowerCase())}const br=U({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:F,acceptCharset:w,accessKey:w,action:null,allow:null,allowFullScreen:S,allowPaymentRequest:S,allowUserMedia:S,alpha:S,alt:null,as:null,async:S,autoCapitalize:null,autoComplete:w,autoFocus:S,autoPlay:S,blocking:w,capture:null,charSet:null,checked:S,cite:null,className:w,closedBy:null,colorSpace:null,cols:d,colSpan:d,command:null,commandFor:null,content:null,contentEditable:R,controls:S,controlsList:w,coords:d|F,crossOrigin:null,data:null,dateTime:null,decoding:null,default:S,defer:S,dir:null,dirName:null,disabled:S,download:Fe,draggable:R,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:S,formTarget:null,headers:w,height:d,hidden:Fe,high:d,href:null,hrefLang:null,htmlFor:w,httpEquiv:w,id:null,imageSizes:null,imageSrcSet:null,inert:S,inputMode:null,integrity:null,is:null,isMap:S,itemId:null,itemProp:w,itemRef:w,itemScope:S,itemType:w,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:S,low:d,manifest:null,max:null,maxLength:d,media:null,method:null,min:null,minLength:d,multiple:S,muted:S,name:null,nonce:null,noModule:S,noValidate:S,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:S,optimum:d,pattern:null,ping:w,placeholder:null,playsInline:S,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:S,referrerPolicy:null,rel:w,required:S,reversed:S,rows:d,rowSpan:d,sandbox:w,scope:null,scoped:S,seamless:S,selected:S,shadowRootClonable:S,shadowRootCustomElementRegistry:S,shadowRootDelegatesFocus:S,shadowRootMode:null,shadowRootSerializable:S,shape:null,size:d,sizes:null,slot:null,span:d,spellCheck:R,src:null,srcDoc:null,srcLang:null,srcSet:null,start:d,step:null,style:null,tabIndex:d,target:null,title:null,translate:null,type:null,typeMustMatch:S,useMap:null,value:R,width:d,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:w,axis:null,background:null,bgColor:null,border:d,borderColor:null,bottomMargin:d,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:S,declare:S,event:null,face:null,frame:null,frameBorder:null,hSpace:d,leftMargin:d,link:null,longDesc:null,lowSrc:null,marginHeight:d,marginWidth:d,noResize:S,noHref:S,noShade:S,noWrap:S,object:null,profile:null,prompt:null,rev:null,rightMargin:d,rules:null,scheme:null,scrolling:R,standby:null,summary:null,text:null,topMargin:d,valueType:null,version:null,vAlign:null,vLink:null,vSpace:d,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:S,disablePictureInPicture:S,disableRemotePlayback:S,exportParts:F,part:w,prefix:null,property:null,results:d,security:null,unselectable:null},space:"html",transform:Zt}),Sr=U({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:E,accentHeight:d,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:d,amplitude:d,arabicForm:null,ascent:d,attributeName:null,attributeType:null,azimuth:d,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:d,by:null,calcMode:null,capHeight:d,className:w,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:d,diffuseConstant:d,direction:null,display:null,dur:null,divisor:d,dominantBaseline:null,download:S,dx:null,dy:null,edgeMode:null,editable:null,elevation:d,enableBackground:null,end:null,event:null,exponent:d,externalResourcesRequired:null,fill:null,fillOpacity:d,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:F,g2:F,glyphName:F,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:d,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:d,horizOriginX:d,horizOriginY:d,id:null,ideographic:d,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:d,k:d,k1:d,k2:d,k3:d,k4:d,kernelMatrix:E,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:d,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:d,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:d,overlineThickness:d,paintOrder:null,panose1:null,path:null,pathLength:d,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:w,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:d,pointsAtY:d,pointsAtZ:d,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:E,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:E,rev:E,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:E,requiredFeatures:E,requiredFonts:E,requiredFormats:E,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:d,specularExponent:d,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:d,strikethroughThickness:d,string:null,stroke:null,strokeDashArray:E,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:d,strokeOpacity:d,strokeWidth:null,style:null,surfaceScale:d,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:E,tabIndex:d,tableValues:null,target:null,targetX:d,targetY:d,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:E,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:d,underlineThickness:d,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:d,values:null,vAlphabetic:d,vMathematical:d,vectorEffect:null,vHanging:d,vIdeographic:d,version:null,vertAdvY:d,vertOriginX:d,vertOriginY:d,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:d,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Qt}),en=U({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),tn=U({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Zt}),nn=U({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),Cr=/[A-Z]/g,gt=/-[a-z]/g,wr=/^data[-\w.:]+$/i;function kr(t,e){const n=je(e);let r=e,s=L;if(n in t.normal)return t.property[t.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&wr.test(e)){if(e.charAt(4)==="-"){const o=e.slice(5).replace(gt,Rr);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=e.slice(4);if(!gt.test(o)){let a=o.replace(Cr,vr);a.charAt(0)!=="-"&&(a="-"+a),e="data"+a}}s=Xe}return new s(r,e)}function vr(t){return"-"+t.toLowerCase()}function Rr(t){return t.charAt(1).toUpperCase()}const Tr=Xt([Jt,br,en,tn,nn],"html"),rn=Xt([Jt,Sr,en,tn,nn],"svg"),pt={}.hasOwnProperty;function Ar(t,e){const n=e||{};function r(s,...o){let a=r.invalid;const i=r.handlers;if(s&&pt.call(s,t)){const l=String(s[t]);a=pt.call(i,l)?i[l]:r.unknown}if(a)return a.call(this,s,...o)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const Nr=/["&'<>`]/g,xr=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Lr=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Er=/[|\\{}()[\]^$+*?.]/g,mt=new WeakMap;function Pr(t,e){if(t=t.replace(e.subset?Ir(e.subset):Nr,r),e.subset||e.escapeOnly)return t;return t.replace(xr,n).replace(Lr,r);function n(s,o,a){return e.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,a.charCodeAt(o+2),e)}function r(s,o,a){return e.format(s.charCodeAt(0),a.charCodeAt(o+1),e)}}function Ir(t){let e=mt.get(t);return e||(e=Or(t),mt.set(t,e)),e}function Or(t){const e=[];let n=-1;for(;++n<t.length;)e.push(t[n].replace(Er,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const Mr=/[\dA-Fa-f]/;function Br(t,e,n){const r="&#x"+t.toString(16).toUpperCase();return n&&e&&!Mr.test(String.fromCharCode(e))?r:r+";"}const Gr=/\d/;function $r(t,e,n){const r="&#"+String(t);return n&&e&&!Gr.test(String.fromCharCode(e))?r:r+";"}const Dr=["AElig","AMP","Aacute","Acirc","Agrave","Aring","Atilde","Auml","COPY","Ccedil","ETH","Eacute","Ecirc","Egrave","Euml","GT","Iacute","Icirc","Igrave","Iuml","LT","Ntilde","Oacute","Ocirc","Ograve","Oslash","Otilde","Ouml","QUOT","REG","THORN","Uacute","Ucirc","Ugrave","Uuml","Yacute","aacute","acirc","acute","aelig","agrave","amp","aring","atilde","auml","brvbar","ccedil","cedil","cent","copy","curren","deg","divide","eacute","ecirc","egrave","eth","euml","frac12","frac14","frac34","gt","iacute","icirc","iexcl","igrave","iquest","iuml","laquo","lt","macr","micro","middot","nbsp","not","ntilde","oacute","ocirc","ograve","ordf","ordm","oslash","otilde","ouml","para","plusmn","pound","quot","raquo","reg","sect","shy","sup1","sup2","sup3","szlig","thorn","times","uacute","ucirc","ugrave","uml","uuml","yacute","yen","yuml"],Le={nbsp:" ",iexcl:"¡",cent:"¢",pound:"£",curren:"¤",yen:"¥",brvbar:"¦",sect:"§",uml:"¨",copy:"©",ordf:"ª",laquo:"«",not:"¬",shy:"­",reg:"®",macr:"¯",deg:"°",plusmn:"±",sup2:"²",sup3:"³",acute:"´",micro:"µ",para:"¶",middot:"·",cedil:"¸",sup1:"¹",ordm:"º",raquo:"»",frac14:"¼",frac12:"½",frac34:"¾",iquest:"¿",Agrave:"À",Aacute:"Á",Acirc:"Â",Atilde:"Ã",Auml:"Ä",Aring:"Å",AElig:"Æ",Ccedil:"Ç",Egrave:"È",Eacute:"É",Ecirc:"Ê",Euml:"Ë",Igrave:"Ì",Iacute:"Í",Icirc:"Î",Iuml:"Ï",ETH:"Ð",Ntilde:"Ñ",Ograve:"Ò",Oacute:"Ó",Ocirc:"Ô",Otilde:"Õ",Ouml:"Ö",times:"×",Oslash:"Ø",Ugrave:"Ù",Uacute:"Ú",Ucirc:"Û",Uuml:"Ü",Yacute:"Ý",THORN:"Þ",szlig:"ß",agrave:"à",aacute:"á",acirc:"â",atilde:"ã",auml:"ä",aring:"å",aelig:"æ",ccedil:"ç",egrave:"è",eacute:"é",ecirc:"ê",euml:"ë",igrave:"ì",iacute:"í",icirc:"î",iuml:"ï",eth:"ð",ntilde:"ñ",ograve:"ò",oacute:"ó",ocirc:"ô",otilde:"õ",ouml:"ö",divide:"÷",oslash:"ø",ugrave:"ù",uacute:"ú",ucirc:"û",uuml:"ü",yacute:"ý",thorn:"þ",yuml:"ÿ",fnof:"ƒ",Alpha:"Α",Beta:"Β",Gamma:"Γ",Delta:"Δ",Epsilon:"Ε",Zeta:"Ζ",Eta:"Η",Theta:"Θ",Iota:"Ι",Kappa:"Κ",Lambda:"Λ",Mu:"Μ",Nu:"Ν",Xi:"Ξ",Omicron:"Ο",Pi:"Π",Rho:"Ρ",Sigma:"Σ",Tau:"Τ",Upsilon:"Υ",Phi:"Φ",Chi:"Χ",Psi:"Ψ",Omega:"Ω",alpha:"α",beta:"β",gamma:"γ",delta:"δ",epsilon:"ε",zeta:"ζ",eta:"η",theta:"θ",iota:"ι",kappa:"κ",lambda:"λ",mu:"μ",nu:"ν",xi:"ξ",omicron:"ο",pi:"π",rho:"ρ",sigmaf:"ς",sigma:"σ",tau:"τ",upsilon:"υ",phi:"φ",chi:"χ",psi:"ψ",omega:"ω",thetasym:"ϑ",upsih:"ϒ",piv:"ϖ",bull:"•",hellip:"…",prime:"′",Prime:"″",oline:"‾",frasl:"⁄",weierp:"℘",image:"ℑ",real:"ℜ",trade:"™",alefsym:"ℵ",larr:"←",uarr:"↑",rarr:"→",darr:"↓",harr:"↔",crarr:"↵",lArr:"⇐",uArr:"⇑",rArr:"⇒",dArr:"⇓",hArr:"⇔",forall:"∀",part:"∂",exist:"∃",empty:"∅",nabla:"∇",isin:"∈",notin:"∉",ni:"∋",prod:"∏",sum:"∑",minus:"−",lowast:"∗",radic:"√",prop:"∝",infin:"∞",ang:"∠",and:"∧",or:"∨",cap:"∩",cup:"∪",int:"∫",there4:"∴",sim:"∼",cong:"≅",asymp:"≈",ne:"≠",equiv:"≡",le:"≤",ge:"≥",sub:"⊂",sup:"⊃",nsub:"⊄",sube:"⊆",supe:"⊇",oplus:"⊕",otimes:"⊗",perp:"⊥",sdot:"⋅",lceil:"⌈",rceil:"⌉",lfloor:"⌊",rfloor:"⌋",lang:"〈",rang:"〉",loz:"◊",spades:"♠",clubs:"♣",hearts:"♥",diams:"♦",quot:'"',amp:"&",lt:"<",gt:">",OElig:"Œ",oelig:"œ",Scaron:"Š",scaron:"š",Yuml:"Ÿ",circ:"ˆ",tilde:"˜",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",lrm:"‎",rlm:"‏",ndash:"–",mdash:"—",lsquo:"‘",rsquo:"’",sbquo:"‚",ldquo:"“",rdquo:"”",bdquo:"„",dagger:"†",Dagger:"‡",permil:"‰",lsaquo:"‹",rsaquo:"›",euro:"€"},jr=["cent","copy","divide","gt","lt","not","para","times"],sn={}.hasOwnProperty,ze={};let oe;for(oe in Le)sn.call(Le,oe)&&(ze[Le[oe]]=oe);const Fr=/[^\dA-Za-z]/;function Wr(t,e,n,r){const s=String.fromCharCode(t);if(sn.call(ze,s)){const o=ze[s],a="&"+o;return n&&Dr.includes(o)&&!jr.includes(o)&&(!r||e&&e!==61&&Fr.test(String.fromCharCode(e)))?a:a+";"}return""}function zr(t,e,n){let r=Br(t,e,n.omitOptionalSemicolons),s;if((n.useNamedReferences||n.useShortestReferences)&&(s=Wr(t,e,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!s)&&n.useShortestReferences){const o=$r(t,e,n.omitOptionalSemicolons);o.length<r.length&&(r=o)}return s&&(!n.useShortestReferences||s.length<r.length)?s:r}function H(t,e){return Pr(t,Object.assign({format:zr},e))}const Hr=/^>|^->|<!--|-->|--!>|<!-$/g,Ur=[">"],qr=["<",">"];function Vr(t,e,n,r){return r.settings.bogusComments?"<?"+H(t.value,Object.assign({},r.settings.characterReferences,{subset:Ur}))+">":"<!--"+t.value.replace(Hr,s)+"-->";function s(o){return H(o,Object.assign({},r.settings.characterReferences,{subset:qr}))}}function Kr(t,e,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function yt(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let r=0,s=n.indexOf(e);for(;s!==-1;)r++,s=n.indexOf(e,s+e.length);return r}function Yr(t,e){const n=e||{};return(t[t.length-1]===""?[...t,""]:t).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function Xr(t){return t.join(" ").trim()}const Jr=/[ \t\n\f\r]/g;function Je(t){return typeof t=="object"?t.type==="text"?_t(t.value):!1:_t(t)}function _t(t){return t.replace(Jr,"")===""}const T=an(1),on=an(-1),Qr=[];function an(t){return e;function e(n,r,s){const o=n?n.children:Qr;let a=(r||0)+t,i=o[a];if(!s)for(;i&&Je(i);)a+=t,i=o[a];return i}}const Zr={}.hasOwnProperty;function ln(t){return e;function e(n,r,s){return Zr.call(t,n.tagName)&&t[n.tagName](n,r,s)}}const Qe=ln({body:ts,caption:Ee,colgroup:Ee,dd:os,dt:ss,head:Ee,html:es,li:rs,optgroup:as,option:is,p:ns,rp:bt,rt:bt,tbody:cs,td:St,tfoot:us,th:St,thead:ls,tr:hs});function Ee(t,e,n){const r=T(n,e,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&Je(r.value.charAt(0)))}function es(t,e,n){const r=T(n,e);return!r||r.type!=="comment"}function ts(t,e,n){const r=T(n,e);return!r||r.type!=="comment"}function ns(t,e,n){const r=T(n,e);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function rs(t,e,n){const r=T(n,e);return!r||r.type==="element"&&r.tagName==="li"}function ss(t,e,n){const r=T(n,e);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function os(t,e,n){const r=T(n,e);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function bt(t,e,n){const r=T(n,e);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function as(t,e,n){const r=T(n,e);return!r||r.type==="element"&&r.tagName==="optgroup"}function is(t,e,n){const r=T(n,e);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function ls(t,e,n){const r=T(n,e);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function cs(t,e,n){const r=T(n,e);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function us(t,e,n){return!T(n,e)}function hs(t,e,n){const r=T(n,e);return!r||r.type==="element"&&r.tagName==="tr"}function St(t,e,n){const r=T(n,e);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const ds=ln({body:ps,colgroup:ms,head:gs,html:fs,tbody:ys});function fs(t){const e=T(t,-1);return!e||e.type!=="comment"}function gs(t){const e=new Set;for(const r of t.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(e.has(r.tagName))return!1;e.add(r.tagName)}const n=t.children[0];return!n||n.type==="element"}function ps(t){const e=T(t,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&Je(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function ms(t,e,n){const r=on(n,e),s=T(t,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&Qe(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="col")}function ys(t,e,n){const r=on(n,e),s=T(t,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&Qe(r,n.children.indexOf(r),n)?!1:!!(s&&s.type==="element"&&s.tagName==="tr")}const ae={name:[[`
4
+ \f\r &/=>`.split(""),`
5
+ \f\r "&'/=>\``.split("")],[`\0
6
+ \f\r "&'/<=>`.split(""),`\0
7
+ \f\r "&'/<=>\``.split("")]],unquoted:[[`
8
+ \f\r &>`.split(""),`\0
9
+ \f\r "&'<=>\``.split("")],[`\0
10
+ \f\r "&'<=>\``.split(""),`\0
11
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function _s(t,e,n,r){const s=r.schema,o=s.space==="svg"?!1:r.settings.omitOptionalTags;let a=s.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(t.tagName.toLowerCase());const i=[];let l;s.space==="html"&&t.tagName==="svg"&&(r.schema=rn);const c=bs(r,t.properties),u=r.all(s.space==="html"&&t.tagName==="template"?t.content:t);return r.schema=s,u&&(a=!1),(c||!o||!ds(t,e,n))&&(i.push("<",t.tagName,c?" "+c:""),a&&(s.space==="svg"||r.settings.closeSelfClosing)&&(l=c.charAt(c.length-1),(!r.settings.tightSelfClosing||l==="/"||l&&l!=='"'&&l!=="'")&&i.push(" "),i.push("/")),i.push(">")),i.push(u),!a&&(!o||!Qe(t,e,n))&&i.push("</"+t.tagName+">"),i.join("")}function bs(t,e){const n=[];let r=-1,s;if(e){for(s in e)if(e[s]!==null&&e[s]!==void 0){const o=Ss(t,s,e[s]);o&&n.push(o)}}for(;++r<n.length;){const o=t.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&o!=='"'&&o!=="'"&&(n[r]+=" ")}return n.join("")}function Ss(t,e,n){const r=kr(t.schema,e),s=t.settings.allowParseErrors&&t.schema.space==="html"?0:1,o=t.settings.allowDangerousCharacters?0:1;let a=t.quote,i;if(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const l=H(r.attribute,Object.assign({},t.settings.characterReferences,{subset:ae.name[s][o]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?Yr:Xr)(n,{padLeft:!t.settings.tightCommaSeparatedLists}):String(n),t.settings.collapseEmptyAttributes&&!n)?l:(t.settings.preferUnquoted&&(i=H(n,Object.assign({},t.settings.characterReferences,{attribute:!0,subset:ae.unquoted[s][o]}))),i!==n&&(t.settings.quoteSmart&&yt(n,a)>yt(n,t.alternative)&&(a=t.alternative),i=a+H(n,Object.assign({},t.settings.characterReferences,{subset:(a==="'"?ae.single:ae.double)[s][o],attribute:!0}))+a),l+(i&&"="+i))}const Cs=["<","&"];function cn(t,e,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?t.value:H(t.value,Object.assign({},r.settings.characterReferences,{subset:Cs}))}function ws(t,e,n,r){return r.settings.allowDangerousHtml?t.value:cn(t,e,n,r)}function ks(t,e,n,r){return r.all(t)}const vs=Ar("type",{invalid:Rs,unknown:Ts,handlers:{comment:Vr,doctype:Kr,element:_s,raw:ws,root:ks,text:cn}});function Rs(t){throw new Error("Expected node, not `"+t+"`")}function Ts(t){const e=t;throw new Error("Cannot compile unknown node `"+e.type+"`")}const As={},Ns={},xs=[];function Ls(t,e){const n=e||As,r=n.quote||'"',s=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:Es,all:Ps,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||yr,characterReferences:n.characterReferences||Ns,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?rn:Tr,quote:r,alternative:s}.one(Array.isArray(t)?{type:"root",children:t}:t,void 0,void 0)}function Es(t,e,n){return vs(t,e,n,this)}function Ps(t){const e=[],n=t&&t.children||xs;let r=-1;for(;++r<n.length;)e[r]=this.one(n[r],r,t);return e.join("")}const Ct=/\s+/g;function un(t,e){if(!e)return t;t.properties||={},t.properties.class||=[],typeof t.properties.class=="string"&&(t.properties.class=t.properties.class.split(Ct)),Array.isArray(t.properties.class)||(t.properties.class=[]);const n=Array.isArray(e)?e:e.split(Ct);for(const r of n)r&&!t.properties.class.includes(r)&&t.properties.class.push(r);return t}const Is=/:?lang=["']([^"']+)["']/g,Os=/(?:```|~~~)([\w-]+)/g,Ms=/\\begin\{([\w-]+)\}/g,Bs=/<script\s+(?:type|lang)=["']([^"']+)["']/gi,Gs=/^\s*---\r?\n[\s\S]*?\r?\n---(?:\r?\n|\s*$)/;function $s(t){const e=Se(t,!0).map(([s])=>s);function n(s){if(s===t.length)return{line:e.length-1,character:e.at(-1).length};let o=s,a=0;for(const i of e){if(o<i.length)break;o-=i.length,a++}return{line:a,character:o}}function r(s,o){let a=0;for(let i=0;i<s;i++)a+=e[i].length;return a+=o,a}return{lines:e,indexToPos:n,posToIndex:r}}function mo(t,e,n){const r=new Set;for(const o of t.matchAll(Is)){const a=o[1].toLowerCase().trim();a&&r.add(a)}for(const o of t.matchAll(Os)){const a=o[1].toLowerCase().trim();a&&r.add(a)}for(const o of t.matchAll(Ms)){const a=o[1].toLowerCase().trim();a&&r.add(a)}for(const o of t.matchAll(Bs)){const a=o[1].toLowerCase().trim(),i=a.includes("/")?a.split("/").pop():a;i&&r.add(i)}if(Gs.test(t)&&r.add("yaml"),!n)return[...r];const s=n.getBundledLanguages();return[...r].filter(o=>o&&s[o])}const Ds=["color","background-color"];function js(t,e){let n=0;const r=[];for(const s of e)s>n&&r.push({...t,content:t.content.slice(n,s),offset:t.offset+n}),n=s;return n<t.content.length&&r.push({...t,content:t.content.slice(n),offset:t.offset+n}),r}function Fs(t,e){let n=0,r=t.length;for(;n<r;){const s=n+(r-n>>1);t[s]<=e?n=s+1:r=s}return n}function Ws(t,e){const n=[...e instanceof Set?e:new Set(e)].sort((r,s)=>r-s);return n.length?t.map(r=>r.flatMap(s=>{const o=s.offset+s.content.length,a=Fs(n,s.offset);let i=a;for(;i<n.length&&n[i]<o;)i++;if(a===i)return s;const l=n.slice(a,i);for(let c=0;c<l.length;c++)l[c]-=s.offset;return js(s,l)})):t}function zs(t,e,n,r,s="css-vars"){const o={content:t.content,explanation:t.explanation,offset:t.offset},a=e.map(u=>pe(t.variants[u])),i=new Set(a.flatMap(u=>Object.keys(u))),l={},c=(u,h)=>{const f=h==="color"?"":h==="background-color"?"-bg":`-${h}`;return n+e[u]+(h==="color"?"":f)};return a.forEach((u,h)=>{for(const f of i){const g=u[f]||"inherit";if(h===0&&r&&Ds.includes(f))if(r==="light-dark()"&&a.length>1){const p=e.findIndex(m=>m==="light"),b=e.findIndex(m=>m==="dark");if(p===-1||b===-1)throw new k('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');const _=a[p][f]||"inherit",y=a[b][f]||"inherit";l[f]=`light-dark(${_}, ${y})`,s==="css-vars"&&(l[c(h,f)]=g)}else l[f]=g;else s==="css-vars"&&(l[c(h,f)]=g)}}),o.htmlStyle=l,o}function pe(t){const e={};if(t.color&&(e.color=t.color),t.bgColor&&(e["background-color"]=t.bgColor),t.fontStyle){t.fontStyle&x.Italic&&(e["font-style"]="italic"),t.fontStyle&x.Bold&&(e["font-weight"]="bold");const n=[];t.fontStyle&x.Underline&&n.push("underline"),t.fontStyle&x.Strikethrough&&n.push("line-through"),n.length&&(e["text-decoration"]=n.join(" "))}return e}function He(t){return typeof t=="string"?t:Object.entries(t).map(([e,n])=>`${e}:${n}`).join(";")}function Hs(){const t=new WeakMap;function e(n){if(!t.has(n.meta)){let s=function(a){if(typeof a=="number"){if(a<0||a>n.source.length)throw new k(`Invalid decoration offset: ${a}. Code length: ${n.source.length}`);return{...r.indexToPos(a),offset:a}}else{const i=r.lines[a.line];if(i===void 0)throw new k(`Invalid decoration position ${JSON.stringify(a)}. Lines length: ${r.lines.length}`);let l=a.character;if(l<0&&(l=i.length+l),l<0||l>i.length)throw new k(`Invalid decoration position ${JSON.stringify(a)}. Line ${a.line} length: ${i.length}`);return{...a,character:l,offset:r.posToIndex(a.line,l)}}};const r=$s(n.source),o=(n.options.decorations||[]).map(a=>({...a,start:s(a.start),end:s(a.end)}));Us(o),t.set(n.meta,{decorations:o,converter:r,source:n.source})}return t.get(n.meta)}return{name:"shiki:decorations",tokens(n){if(this.options.decorations?.length)return Ws(n,e(this).decorations.flatMap(r=>[r.start.offset,r.end.offset]))},code(n){if(!this.options.decorations?.length)return;const r=e(this),s=[...n.children].filter(u=>u.type==="element"&&u.tagName==="span");if(s.length!==r.converter.lines.length)throw new k(`Number of lines in code element (${s.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function o(u,h,f,g){const p=s[u];let b="",_=-1,y=-1;if(h===0&&(_=0),f===0&&(y=0),f===Number.POSITIVE_INFINITY&&(y=p.children.length),_===-1||y===-1)for(let C=0;C<p.children.length;C++)b+=hn(p.children[C]),_===-1&&b.length===h&&(_=C+1),y===-1&&b.length===f&&(y=C+1);if(_===-1)throw new k(`Failed to find start index for decoration ${JSON.stringify(g.start)}`);if(y===-1)throw new k(`Failed to find end index for decoration ${JSON.stringify(g.end)}`);const m=p.children.slice(_,y);if(!g.alwaysWrap&&m.length===p.children.length)i(p,g,"line");else if(!g.alwaysWrap&&m.length===1&&m[0].type==="element")i(m[0],g,"token");else{const C={type:"element",tagName:"span",properties:{},children:m};i(C,g,"wrapper"),p.children.splice(_,m.length,C)}}function a(u,h){s[u]=i(s[u],h,"line")}function i(u,h,f){const g=h.properties||{},p=h.transform||(b=>b);return u.tagName=h.tagName||"span",u.properties={...u.properties,...g,class:u.properties.class},h.properties?.class&&un(u,h.properties.class),u=p(u,f)||u,u}const l=[],c=r.decorations.sort((u,h)=>h.start.offset-u.start.offset||u.end.offset-h.end.offset);for(const u of c){const{start:h,end:f}=u;if(h.line===f.line)o(h.line,h.character,f.character,u);else if(h.line<f.line){o(h.line,h.character,Number.POSITIVE_INFINITY,u);for(let g=h.line+1;g<f.line;g++)l.unshift(()=>a(g,u));o(f.line,0,f.character,u)}}l.forEach(u=>u())}}}function Us(t){for(let e=0;e<t.length;e++){const n=t[e];if(n.start.offset>n.end.offset)throw new k(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=e+1;r<t.length;r++){const s=t[r],o=n.start.offset<=s.start.offset&&s.start.offset<n.end.offset,a=n.start.offset<s.end.offset&&s.end.offset<=n.end.offset,i=s.start.offset<=n.start.offset&&n.start.offset<s.end.offset,l=s.start.offset<n.end.offset&&n.end.offset<=s.end.offset;if(o||a||i||l){if(o&&a||i&&l||i&&n.start.offset===n.end.offset||a&&s.start.offset===s.end.offset)continue;throw new k(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(s.start)} intersect.`)}}}}function hn(t){return t.type==="text"?t.value:t.type==="element"?t.children.map(hn).join(""):""}const qs=[Hs()];function me(t){const e=Vs(t.transformers||[]);return[...e.pre,...e.normal,...e.post,...qs]}function Vs(t){const e=[],n=[],r=[];for(const s of t)switch(s.enforce){case"pre":e.push(s);break;case"post":n.push(s);break;default:r.push(s)}return{pre:e,post:n,normal:r}}var D=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Pe={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function Ks(t,e){const n=t.indexOf("\x1B",e);if(n!==-1&&t[n+1]==="["){const r=t.indexOf("m",n);if(r!==-1)return{sequence:t.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:t.length}}function wt(t){const e=t.shift();if(e==="2"){const n=t.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(e==="5"){const n=t.shift();if(n)return{type:"table",index:Number(n)}}}function Ys(t){const e=[];for(;t.length>0;){const n=t.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)e.push({type:"resetAll"});else if(r<=9)Pe[r]&&e.push({type:"setDecoration",value:Pe[r]});else if(r<=29){const s=Pe[r-20];s&&(e.push({type:"resetDecoration",value:s}),s==="dim"&&e.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)e.push({type:"setForegroundColor",value:{type:"named",name:D[r-30]}});else if(r===38){const s=wt(t);s&&e.push({type:"setForegroundColor",value:s})}else if(r===39)e.push({type:"resetForegroundColor"});else if(r<=47)e.push({type:"setBackgroundColor",value:{type:"named",name:D[r-40]}});else if(r===48){const s=wt(t);s&&e.push({type:"setBackgroundColor",value:s})}else r===49?e.push({type:"resetBackgroundColor"}):r===53?e.push({type:"setDecoration",value:"overline"}):r===55?e.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?e.push({type:"setForegroundColor",value:{type:"named",name:D[r-90+8]}}):r>=100&&r<=107&&e.push({type:"setBackgroundColor",value:{type:"named",name:D[r-100+8]}})}return e}function Xs(){let t=null,e=null,n=new Set;return{parse(r){const s=[];let o=0;do{const a=Ks(r,o),i=a.sequence?r.substring(o,a.startPosition):r.substring(o);if(i.length>0&&s.push({value:i,foreground:t,background:e,decorations:new Set(n)}),a.sequence){const l=Ys(a.sequence);for(const c of l)c.type==="resetAll"?(t=null,e=null,n.clear()):c.type==="resetForegroundColor"?t=null:c.type==="resetBackgroundColor"?e=null:c.type==="resetDecoration"&&n.delete(c.value);for(const c of l)c.type==="setForegroundColor"?t=c.value:c.type==="setBackgroundColor"?e=c.value:c.type==="setDecoration"&&n.add(c.value)}o=a.position}while(o<r.length);return s}}}var Js={black:"#000000",red:"#bb0000",green:"#00bb00",yellow:"#bbbb00",blue:"#0000bb",magenta:"#ff00ff",cyan:"#00bbbb",white:"#eeeeee",brightBlack:"#555555",brightRed:"#ff5555",brightGreen:"#00ff00",brightYellow:"#ffff55",brightBlue:"#5555ff",brightMagenta:"#ff55ff",brightCyan:"#55ffff",brightWhite:"#ffffff"};function Qs(t=Js){function e(i){return t[i]}function n(i){return`#${i.map(l=>Math.max(0,Math.min(l,255)).toString(16).padStart(2,"0")).join("")}`}let r;function s(){if(r)return r;r=[];for(let c=0;c<D.length;c++)r.push(e(D[c]));let i=[0,95,135,175,215,255];for(let c=0;c<6;c++)for(let u=0;u<6;u++)for(let h=0;h<6;h++)r.push(n([i[c],i[u],i[h]]));let l=8;for(let c=0;c<24;c++,l+=10)r.push(n([l,l,l]));return r}function o(i){return s()[i]}function a(i){switch(i.type){case"named":return e(i.name);case"rgb":return n(i.rgb);case"table":return o(i.index)}}return{value:a}}const Zs=/#([0-9a-f]{3,8})/i,eo=/var\((--[\w-]+-ansi-[\w-]+)\)/,to={black:"#000000",red:"#cd3131",green:"#0DBC79",yellow:"#E5E510",blue:"#2472C8",magenta:"#BC3FBC",cyan:"#11A8CD",white:"#E5E5E5",brightBlack:"#666666",brightRed:"#F14C4C",brightGreen:"#23D18B",brightYellow:"#F5F543",brightBlue:"#3B8EEA",brightMagenta:"#D670D6",brightCyan:"#29B8DB",brightWhite:"#FFFFFF"};function no(t,e,n){const r=ge(t,n),s=Se(e),o=Qs(Object.fromEntries(D.map(i=>{const l=`terminal.ansi${i[0].toUpperCase()}${i.substring(1)}`;return[i,t.colors?.[l]||to[i]]}))),a=Xs();return s.map(i=>a.parse(i[0]).map(l=>{let c,u;l.decorations.has("reverse")?(c=l.background?o.value(l.background):t.bg,u=l.foreground?o.value(l.foreground):t.fg):(c=l.foreground?o.value(l.foreground):t.fg,u=l.background?o.value(l.background):void 0),c=G(c,r),u=G(u,r),l.decorations.has("dim")&&(c=ro(c));let h=x.None;return l.decorations.has("bold")&&(h|=x.Bold),l.decorations.has("italic")&&(h|=x.Italic),l.decorations.has("underline")&&(h|=x.Underline),l.decorations.has("strikethrough")&&(h|=x.Strikethrough),{content:l.value,offset:i[1],color:c,bgColor:u,fontStyle:h}}))}function ro(t){const e=t.match(Zs);if(e){const r=e[1];if(r.length===8){const s=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${s}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const s=r[0],o=r[1],a=r[2],i=r[3];return`#${s}${s}${o}${o}${a}${a}${Math.round(Number.parseInt(`${i}${i}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const s=r[0],o=r[1],a=r[2];return`#${s}${s}${o}${o}${a}${a}80`}}}const n=t.match(eo);return n?`var(${n[1]}-dim)`:t}function ye(t,e,n={}){const r=t.resolveLangAlias(n.lang||"text"),{theme:s=t.getLoadedThemes()[0]}=n;if(!_e(r)&&!be(s)&&r==="ansi"){const{theme:o}=t.setTheme(s);return no(o,e,n)}return Kt(t,e,n)}function Z(t,e,n){let r,s,o,a,i,l;if("themes"in n){const{defaultColor:c="light",cssVariablePrefix:u="--shiki-",colorsRendering:h="css-vars"}=n,f=Object.entries(n.themes).filter(y=>y[1]).map(y=>({color:y[0],theme:y[1]})).sort((y,m)=>y.color===c?-1:m.color===c?1:0);if(f.length===0)throw new k("`themes` option must not be empty");const g=Ye(t,e,n,ye);if(l=Q(g),c&&c!=="light-dark()"&&!f.some(y=>y.color===c))throw new k(`\`themes\` option must contain the defaultColor key \`${c}\``);const p=f.map(y=>t.getTheme(y.theme)),b=f.map(y=>y.color);o=g.map(y=>y.map(m=>zs(m,b,u,c,h))),l&&Ce(o,l);const _=f.map(y=>ge(y.theme,n));s=kt(f,p,_,u,c,"fg",h),r=kt(f,p,_,u,c,"bg",h),a=`shiki-themes ${p.map(y=>y.name).join(" ")}`,i=c?void 0:[s,r].join(";")}else if("theme"in n){const c=ge(n.theme,n);o=ye(t,e,n);const u=t.getTheme(n.theme);r=G(u.bg,c),s=G(u.fg,c),a=u.name,l=Q(o)}else throw new k("Invalid options, either `theme` or `themes` must be provided");return{tokens:o,fg:s,bg:r,themeName:a,rootStyle:i,grammarState:l}}function kt(t,e,n,r,s,o,a){return t.map((i,l)=>{const c=G(e[l][o],n[l])||"inherit",u=`${r+i.color}${o==="bg"?"-bg":""}:${c}`;if(l===0&&s){if(s==="light-dark()"&&t.length>1){const h=t.findIndex(g=>g.color==="light"),f=t.findIndex(g=>g.color==="dark");if(h===-1||f===-1)throw new k('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${G(e[h][o],n[h])||"inherit"}, ${G(e[f][o],n[f])||"inherit"});${u}`}return c}return a==="css-vars"?u:null}).filter(i=>!!i).join(";")}const dn=/^\s+$/,so=/^(\s*)(.*?)(\s*)$/;function ee(t,e,n,r={meta:{},options:n,codeToHast:(s,o)=>ee(t,s,o),codeToTokens:(s,o)=>Z(t,s,o)}){let s=e;for(const p of me(n))s=p.preprocess?.call(r,s,n)||s;let{tokens:o,fg:a,bg:i,themeName:l,rootStyle:c,grammarState:u}=Z(t,s,n);const{mergeWhitespaces:h=!0,mergeSameStyleTokens:f=!1}=n;h===!0?o=ao(o):h==="never"&&(o=io(o)),f&&(o=lo(o));const g={...r,get source(){return s}};for(const p of me(n))o=p.tokens?.call(g,o)||o;return oo(o,{...n,fg:a,bg:i,themeName:l,rootStyle:n.rootStyle===!1?!1:n.rootStyle??c},g,u)}function oo(t,e,n,r=Q(t)){const s=me(e),o=[],a={type:"root",children:[]},{structure:i="classic",tabindex:l="0"}=e,c={class:`shiki ${e.themeName||""}`};e.rootStyle!==!1&&(e.rootStyle!=null?c.style=e.rootStyle:c.style=`background-color:${e.bg};color:${e.fg}`),l!==!1&&l!=null&&(c.tabindex=l.toString());for(const[b,_]of Object.entries(e.meta||{}))b.startsWith("_")||(c[b]=_);let u={type:"element",tagName:"pre",properties:c,children:[],data:e.data},h={type:"element",tagName:"code",properties:{},children:o};const f=[],g={...n,structure:i,addClassToHast:un,get source(){return n.source},get tokens(){return t},get options(){return e},get root(){return a},get pre(){return u},get code(){return h},get lines(){return f}};if(t.forEach((b,_)=>{_&&(i==="inline"?a.children.push({type:"element",tagName:"br",properties:{},children:[]}):i==="classic"&&o.push({type:"text",value:`
12
+ `}));let y={type:"element",tagName:"span",properties:{class:"line"},children:[]},m=0;for(const C of b){let v={type:"element",tagName:"span",properties:{...C.htmlAttrs},children:[{type:"text",value:C.content}]};const A=He(C.htmlStyle||pe(C));A&&(v.properties.style=A);for(const P of s)v=P?.span?.call(g,v,_+1,m,y,C)||v;i==="inline"?a.children.push(v):i==="classic"&&y.children.push(v),m+=C.content.length}if(i==="classic"){for(const C of s)y=C?.line?.call(g,y,_+1)||y;f.push(y),o.push(y)}else i==="inline"&&f.push(y)}),i==="classic"){for(const b of s)h=b?.code?.call(g,h)||h;u.children.push(h);for(const b of s)u=b?.pre?.call(g,u)||u;a.children.push(u)}else if(i==="inline"){const b=[];let _={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const m of a.children)m.type==="element"&&m.tagName==="br"?(b.push(_),_={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(m.type==="element"||m.type==="text")&&_.children.push(m);b.push(_);let y={type:"element",tagName:"code",properties:{},children:b};for(const m of s)y=m?.code?.call(g,y)||y;a.children=[];for(let m=0;m<y.children.length;m++){m>0&&a.children.push({type:"element",tagName:"br",properties:{},children:[]});const C=y.children[m];C.type==="element"&&a.children.push(...C.children)}}let p=a;for(const b of s)p=b?.root?.call(g,p)||p;return r&&Ce(p,r),p}function ao(t){return t.map(e=>{const n=[];let r="",s;return e.forEach((o,a)=>{const i=!(o.fontStyle&&(o.fontStyle&x.Underline||o.fontStyle&x.Strikethrough));i&&dn.test(o.content)&&e[a+1]?(s===void 0&&(s=o.offset),r+=o.content):r?(i?n.push({...o,offset:s,content:r+o.content}):n.push({content:r,offset:s},o),s=void 0,r=""):n.push(o)}),n})}function io(t){return t.map(e=>e.flatMap(n=>{if(dn.test(n.content))return n;const r=n.content.match(so);if(!r)return n;const[,s,o,a]=r;if(!s&&!a)return n;const i=[{...n,offset:n.offset+s.length,content:o}];return s&&i.unshift({content:s,offset:n.offset}),a&&i.push({content:a,offset:n.offset+s.length+o.length}),i}))}function lo(t){return t.map(e=>{const n=[];for(const r of e){if(n.length===0){n.push({...r});continue}const s=n.at(-1),o=He(s.htmlStyle||pe(s)),a=He(r.htmlStyle||pe(r)),i=s.fontStyle&&(s.fontStyle&x.Underline||s.fontStyle&x.Strikethrough),l=r.fontStyle&&(r.fontStyle&x.Underline||r.fontStyle&x.Strikethrough);!i&&!l&&o===a?s.content+=r.content:n.push({...r})}return n})}const co=Ls;function fn(t,e,n){const r={meta:{},options:n,codeToHast:(o,a)=>ee(t,o,a),codeToTokens:(o,a)=>Z(t,o,a)};let s=co(ee(t,e,n,r));for(const o of me(n))s=o.postprocess?.call(r,s,n)||s;return s}async function gn(t){const e=await Ut(t);return{getLastGrammarState:(...n)=>Yt(e,...n),codeToTokensBase:(n,r)=>ye(e,n,r),codeToTokensWithThemes:(n,r)=>Ye(e,n,r),codeToTokens:(n,r)=>Z(e,n,r),codeToHast:(n,r)=>ee(e,n,r),codeToHtml:(n,r)=>fn(e,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}function yo(t){const e=Ve(t);return{getLastGrammarState:(...n)=>Yt(e,...n),codeToTokensBase:(n,r)=>ye(e,n,r),codeToTokensWithThemes:(n,r)=>Ye(e,n,r),codeToTokens:(n,r)=>Z(e,n,r),codeToHast:(n,r)=>ee(e,n,r),codeToHtml:(n,r)=>fn(e,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...e,getInternalContext:()=>e}}function uo(t){let e;async function n(r){if(e){const s=await e;return await Promise.all([s.loadTheme(...r.themes||[]),s.loadLanguage(...r.langs||[])]),s}else return e=t({...r,themes:r.themes||[],langs:r.langs||[]}),e}return n}const _o=uo(gn);function bo(t){const e=t.langs,n=t.themes,r=t.engine;async function s(o){function a(h){if(typeof h=="string"){if(h=o.langAlias?.[h]||h,jt(h))return[];const f=e[h];if(!f)throw new k(`Language \`${h}\` is not included in this bundle. You may want to load it from external source.`);return f}return h}function i(h){if(Ft(h))return"none";if(typeof h=="string"){const f=n[h];if(!f)throw new k(`Theme \`${h}\` is not included in this bundle. You may want to load it from external source.`);return f}return h}const l=(o.themes??[]).map(h=>i(h)),c=(o.langs??[]).map(h=>a(h)),u=await gn({engine:o.engine??r(),...o,themes:l,langs:c});return{...u,loadLanguage(...h){return u.loadLanguage(...h.map(a))},loadTheme(...h){return u.loadTheme(...h.map(i))},getBundledLanguages(){return e},getBundledThemes(){return n}}}return s}function ho(t){let e;async function n(r={}){if(e){const s=await e;return await Promise.all([s.loadTheme(...r.themes||[]),s.loadLanguage(...r.langs||[])]),s}else{e=t({...r,themes:[],langs:[]});const s=await e;return await Promise.all([s.loadTheme(...r.themes||[]),s.loadLanguage(...r.langs||[])]),s}}return n}function So(t,e){const n=ho(t);async function r(s,o){const a=await n({langs:[o.lang],themes:"theme"in o?[o.theme]:Object.values(o.themes)}),i=await e?.guessEmbeddedLanguages?.(s,o.lang,a);return i&&await a.loadLanguage(...i),a}return{getSingletonHighlighter(s){return n(s)},async codeToHtml(s,o){return(await r(s,o)).codeToHtml(s,o)},async codeToHast(s,o){return(await r(s,o)).codeToHast(s,o)},async codeToTokens(s,o){return(await r(s,o)).codeToTokens(s,o)},async codeToTokensBase(s,o){return(await r(s,o)).codeToTokensBase(s,o)},async codeToTokensWithThemes(s,o){return(await r(s,o)).codeToTokensWithThemes(s,o)},async getLastGrammarState(s,o){return(await n({langs:[o.lang],themes:[o.theme]})).getLastGrammarState(s,o)}}}function Co(t={}){const{name:e="css-variables",variablePrefix:n="--shiki-",fontStyle:r=!0}=t,s=a=>t.variableDefaults?.[a]?`var(${n}${a}, ${t.variableDefaults[a]})`:`var(${n}${a})`,o={name:e,type:"dark",colors:{"editor.foreground":s("foreground"),"editor.background":s("background"),"terminal.ansiBlack":s("ansi-black"),"terminal.ansiRed":s("ansi-red"),"terminal.ansiGreen":s("ansi-green"),"terminal.ansiYellow":s("ansi-yellow"),"terminal.ansiBlue":s("ansi-blue"),"terminal.ansiMagenta":s("ansi-magenta"),"terminal.ansiCyan":s("ansi-cyan"),"terminal.ansiWhite":s("ansi-white"),"terminal.ansiBrightBlack":s("ansi-bright-black"),"terminal.ansiBrightRed":s("ansi-bright-red"),"terminal.ansiBrightGreen":s("ansi-bright-green"),"terminal.ansiBrightYellow":s("ansi-bright-yellow"),"terminal.ansiBrightBlue":s("ansi-bright-blue"),"terminal.ansiBrightMagenta":s("ansi-bright-magenta"),"terminal.ansiBrightCyan":s("ansi-bright-cyan"),"terminal.ansiBrightWhite":s("ansi-bright-white")},tokenColors:[{scope:["keyword.operator.accessor","meta.group.braces.round.function.arguments","meta.template.expression","markup.fenced_code meta.embedded.block"],settings:{foreground:s("foreground")}},{scope:"emphasis",settings:{fontStyle:"italic"}},{scope:["strong","markup.heading.markdown","markup.bold.markdown"],settings:{fontStyle:"bold"}},{scope:["markup.italic.markdown"],settings:{fontStyle:"italic"}},{scope:"meta.link.inline.markdown",settings:{fontStyle:"underline",foreground:s("token-link")}},{scope:["string","markup.fenced_code","markup.inline"],settings:{foreground:s("token-string")}},{scope:["comment","string.quoted.docstring.multi"],settings:{foreground:s("token-comment")}},{scope:["constant.numeric","constant.language","constant.other.placeholder","constant.character.format.placeholder","variable.language.this","variable.other.object","variable.other.class","variable.other.constant","meta.property-name","meta.property-value","support"],settings:{foreground:s("token-constant")}},{scope:["keyword","storage.modifier","storage.type","storage.control.clojure","entity.name.function.clojure","entity.name.tag.yaml","support.function.node","support.type.property-name.json","punctuation.separator.key-value","punctuation.definition.template-expression"],settings:{foreground:s("token-keyword")}},{scope:"variable.parameter.function",settings:{foreground:s("token-parameter")}},{scope:["support.function","entity.name.type","entity.other.inherited-class","meta.function-call","meta.instance.constructor","entity.other.attribute-name","entity.name.function","constant.keyword.clojure"],settings:{foreground:s("token-function")}},{scope:["entity.name.tag","string.quoted","string.regexp","string.interpolated","string.template","string.unquoted.plain.out.yaml","keyword.other.template"],settings:{foreground:s("token-string-expression")}},{scope:["punctuation.definition.arguments","punctuation.definition.dict","punctuation.separator","meta.function-call.arguments"],settings:{foreground:s("token-punctuation")}},{scope:["markup.underline.link","punctuation.definition.metadata.markdown"],settings:{foreground:s("token-link")}},{scope:["beginning.punctuation.definition.list.markdown"],settings:{foreground:s("token-string")}},{scope:["punctuation.definition.string.begin.markdown","punctuation.definition.string.end.markdown","string.other.link.title.markdown","string.other.link.description.markdown"],settings:{foreground:s("token-keyword")}},{scope:["markup.inserted","meta.diff.header.to-file","punctuation.definition.inserted"],settings:{foreground:s("token-inserted")}},{scope:["markup.deleted","meta.diff.header.from-file","punctuation.definition.deleted"],settings:{foreground:s("token-deleted")}},{scope:["markup.changed","punctuation.definition.changed"],settings:{foreground:s("token-changed")}}]};return r||(o.tokenColors=o.tokenColors?.map(a=>(a.settings?.fontStyle&&delete a.settings.fontStyle,a))),o}export{k as ShikiError,un as addClassToHast,G as applyColorReplacements,ee as codeToHast,fn as codeToHtml,Z as codeToTokens,ye as codeToTokensBase,Ye as codeToTokensWithThemes,bo as createBundledHighlighter,Co as createCssVariablesTheme,gn as createHighlighterCore,yo as createHighlighterCoreSync,$s as createPositionConverter,po as createShikiInternal,go as createShikiInternalSync,Ve as createShikiPrimitive,Ut as createShikiPrimitiveAsync,So as createSingletonShorthands,zs as flatTokenVariants,Yt as getLastGrammarState,_o as getSingletonHighlighterCore,pe as getTokenStyleObject,mo as guessEmbeddedLanguages,co as hastToHtml,be as isNoneTheme,_e as isPlainLang,jt as isSpecialLang,Ft as isSpecialTheme,ho as makeSingletonHighlighter,uo as makeSingletonHighlighterCore,Dt as normalizeGetter,qe as normalizeTheme,ge as resolveColorReplacements,Se as splitLines,js as splitToken,Ws as splitTokens,He as stringifyTokenStyle,rr as toArray,no as tokenizeAnsiWithTheme,hr as tokenizeWithTheme,oo as tokensToHast,Hs as transformerDecorations};