@aceshooting/lyra-ui 24.1.0 → 25.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -20
- package/README.md +24 -28
- package/custom-elements.json +1 -1
- package/design-tokens.json +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.styles.js +1 -1
- package/dist/components/agent-tools/task-list/task-list.styles.js +1 -1
- package/dist/components/agent-tools/thinking-panel/thinking-panel.styles.js +1 -1
- package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
- package/dist/components/conversation/code-block/code-block.styles.js +1 -1
- package/dist/components/conversation/markdown/markdown.styles.js +1 -1
- package/dist/components/conversation/model-select/model-select.class.js +2 -1
- package/dist/components/conversation/model-select/model-select.styles.js +1 -1
- package/dist/components/conversation/selection-toolbar/selection-toolbar.styles.js +1 -1
- package/dist/components/conversation/voice-picker/voice-picker.class.js +2 -1
- package/dist/components/conversation/voice-picker/voice-picker.styles.js +1 -1
- package/dist/components/data/document-library/document-library.class.js +1 -1
- package/dist/components/data/table/table.class.d.ts +14 -3
- package/dist/components/data/table/table.class.js +8 -6
- package/dist/components/data/table/table.styles.js +1 -1
- package/dist/components/forms/color-picker/color-picker.class.js +2 -1
- package/dist/components/forms/color-picker/color-picker.styles.js +1 -1
- package/dist/components/forms/combobox/combobox.class.js +2 -1
- package/dist/components/forms/combobox/combobox.styles.js +1 -1
- package/dist/components/forms/date-picker/date-input.class.d.ts +3 -0
- package/dist/components/forms/date-picker/date-input.class.js +2 -1
- package/dist/components/forms/date-picker/date-input.styles.js +1 -1
- package/dist/components/forms/input/time-input.class.js +2 -1
- package/dist/components/forms/input/time-input.styles.js +1 -1
- package/dist/components/forms/locale-picker/locale-picker.class.d.ts +2 -1
- package/dist/components/forms/locale-picker/locale-picker.class.js +2 -1
- package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
- package/dist/components/forms/otp-input/otp-input.class.js +1 -1
- package/dist/components/forms/select/select.class.js +2 -1
- package/dist/components/forms/select/select.styles.js +1 -1
- package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +6 -1
- package/dist/components/forms/swatch-picker/swatch-picker.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail.styles.js +1 -1
- package/dist/components/layout/menu/menu.styles.js +1 -1
- package/dist/components/layout/menubar/menubar.styles.js +1 -1
- package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +2 -2
- package/dist/components/layout/navigation-menu-item/navigation-menu-item.styles.js +1 -1
- package/dist/components/layout/scroller/scroller.styles.js +1 -1
- package/dist/components/media/av-player/av-player.styles.js +1 -1
- package/dist/components/media/image-viewer/image-viewer.styles.js +1 -1
- package/dist/components/media/map/map.class.d.ts +5 -2
- package/dist/components/media/map/map.class.js +4 -3
- package/dist/components/media/map/map.styles.js +1 -1
- package/dist/components/overlays/dialog/dialog.class.d.ts +1 -1
- package/dist/components/overlays/dialog/dialog.class.js +2 -1
- package/dist/components/overlays/dialog/dialog.styles.js +1 -1
- package/dist/components/overlays/overlay/overlay.styles.d.ts +1 -1
- package/dist/components/overlays/overlay/overlay.styles.js +1 -1
- package/dist/components/overlays/overlay/popover-glass.styles.d.ts +1 -0
- package/dist/components/overlays/overlay/popover-glass.styles.js +1 -0
- package/dist/components/overlays/overlay/popover.class.d.ts +11 -3
- package/dist/components/overlays/overlay/popover.class.js +1 -1
- package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +1 -1
- package/dist/components/retrieval/source-list/source-list.styles.js +1 -1
- package/dist/components/utility/export-button/export-button.class.d.ts +1 -1
- package/dist/components/utility/export-button/export-button.class.js +2 -1
- package/dist/components/utility/export-button/export-button.styles.js +1 -1
- package/dist/components/utility/mention-popover/mention-popover.class.d.ts +1 -1
- package/dist/components/utility/mention-popover/mention-popover.class.js +2 -1
- package/dist/components/utility/mention-popover/mention-popover.styles.js +1 -1
- package/dist/components/viewers/document-compare/document-compare.styles.js +1 -1
- package/dist/components/viewers/document-preview/document-preview.class.js +1 -1
- package/dist/framework-types.d.ts +1 -1
- package/dist/internal/default-strings.generated.d.ts +1 -1
- package/dist/internal/default-strings.generated.js +1 -1
- package/dist/internal/glass-independent-root.styles.d.ts +2 -0
- package/dist/internal/glass-independent-root.styles.js +1 -0
- package/dist/internal/glass-scroll-layer.d.ts +1 -1
- package/dist/internal/glass-scroll-layer.js +1 -1
- package/dist/internal/glass-scroll-layer.styles.d.ts +2 -0
- package/dist/internal/glass-scroll-layer.styles.js +1 -0
- package/dist/internal/glass-surface.styles.d.ts +0 -2
- package/dist/internal/glass-surface.styles.js +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +1 -1
- package/dist/internal/native-modal-carrier.js +2 -2
- package/dist/internal/package-metadata.d.ts +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/positioner.js +1 -1
- package/dist/internal/sizes.styles.js +1 -1
- package/dist/internal/specialist-tokens.styles.js +1 -1
- package/dist/internal/theme-token-types.d.ts +16 -0
- package/dist/internal/tokens/palette.styles.js +1 -1
- package/dist/internal/tokens.styles.js +1 -1
- package/dist/looks/material.css +1 -1
- package/dist/styles/design-tokens.css +1 -1
- package/dist/styles/tokens-root.css +1 -1
- package/dist/surfaces/glass.css +1 -1
- package/dist/theme/gemstones.d.ts +7 -0
- package/dist/theme/gemstones.js +1 -1
- package/dist/theme/looks/material.d.ts +1 -1
- package/dist/theme/looks/material.js +1 -1
- package/dist/theme/startup-resolution.d.ts +1 -0
- package/dist/theme/startup-resolution.js +1 -0
- package/dist/theme/style-ownership.js +1 -1
- package/dist/theme/theme-bootstrap.js +1 -1
- package/dist/theme/theme.d.ts +6 -21
- package/dist/theme/theme.js +1 -1
- package/dist/theme.css +1 -1
- package/dist/translations/am/data.js +1 -1
- package/dist/translations/ar/data.js +1 -1
- package/dist/translations/bho/data.js +1 -1
- package/dist/translations/bn/data.js +1 -1
- package/dist/translations/cs/data.js +1 -1
- package/dist/translations/da/data.js +1 -1
- package/dist/translations/de/data.js +1 -1
- package/dist/translations/el/data.js +1 -1
- package/dist/translations/es/data.js +1 -1
- package/dist/translations/fa/data.js +1 -1
- package/dist/translations/fa-AF/data.js +1 -1
- package/dist/translations/fi/data.js +1 -1
- package/dist/translations/fr/data.js +1 -1
- package/dist/translations/gu/data.js +1 -1
- package/dist/translations/ha/data.js +1 -1
- package/dist/translations/he/data.js +1 -1
- package/dist/translations/hi/data.js +1 -1
- package/dist/translations/hr/data.js +1 -1
- package/dist/translations/hu/data.js +1 -1
- package/dist/translations/id/data.js +1 -1
- package/dist/translations/ig/data.js +1 -1
- package/dist/translations/it/data.js +1 -1
- package/dist/translations/ja/data.js +1 -1
- package/dist/translations/jv/data.js +1 -1
- package/dist/translations/kk/data.js +1 -1
- package/dist/translations/kn/data.js +1 -1
- package/dist/translations/ko/data.js +1 -1
- package/dist/translations/ln/data.js +1 -1
- package/dist/translations/ml/data.js +1 -1
- package/dist/translations/mr/data.js +1 -1
- package/dist/translations/ms/data.js +1 -1
- package/dist/translations/my/data.js +1 -1
- package/dist/translations/nb/data.js +1 -1
- package/dist/translations/ne/data.js +1 -1
- package/dist/translations/nl/data.js +1 -1
- package/dist/translations/nn/data.js +1 -1
- package/dist/translations/om/data.js +1 -1
- package/dist/translations/or/data.js +1 -1
- package/dist/translations/pa/data.js +1 -1
- package/dist/translations/pcm/data.js +1 -1
- package/dist/translations/pl/data.js +1 -1
- package/dist/translations/pnb/data.js +1 -1
- package/dist/translations/ps/data.js +1 -1
- package/dist/translations/pt-BR/data.js +1 -1
- package/dist/translations/pt-PT/data.js +1 -1
- package/dist/translations/ro/data.js +1 -1
- package/dist/translations/ru/data.js +1 -1
- package/dist/translations/sd/data.js +1 -1
- package/dist/translations/sl/data.js +1 -1
- package/dist/translations/su/data.js +1 -1
- package/dist/translations/sv/data.js +1 -1
- package/dist/translations/sw/data.js +1 -1
- package/dist/translations/ta/data.js +1 -1
- package/dist/translations/te/data.js +1 -1
- package/dist/translations/th/data.js +1 -1
- package/dist/translations/tl/data.js +1 -1
- package/dist/translations/tr/data.js +1 -1
- package/dist/translations/uk/data.js +1 -1
- package/dist/translations/ur/data.js +1 -1
- package/dist/translations/uz/data.js +1 -1
- package/dist/translations/vi/data.js +1 -1
- package/dist/translations/yo/data.js +1 -1
- package/dist/translations/zh-CN/data.js +1 -1
- package/dist/translations/zh-TW/data.js +1 -1
- package/dist/translations/zu/data.js +1 -1
- package/llms/components/lr-date-input.md +1 -1
- package/llms/components/lr-date-picker.md +6 -0
- package/llms/components/lr-dialog.md +3 -0
- package/llms/components/lr-export-button.md +2 -0
- package/llms/components/lr-icon.md +1 -1
- package/llms/components/lr-locale-picker.md +7 -1
- package/llms/components/lr-map.md +7 -0
- package/llms/components/lr-mention-popover.md +3 -0
- package/llms/components/lr-model-select.md +3 -0
- package/llms/components/lr-navigation-menu.md +3 -0
- package/llms/components/lr-otp-input.md +3 -1
- package/llms/components/lr-popover.md +15 -5
- package/llms/components/lr-select.md +3 -0
- package/llms/components/lr-swatch-picker.md +17 -5
- package/llms/components/lr-table.md +14 -1
- package/llms/components/lr-voice-picker.md +3 -0
- package/llms/shared/native-styles-and-utilities.md +40 -0
- package/llms/shared/styles-and-tokens.md +257 -60
- package/llms/shared/testing-and-utilities.md +4 -1
- package/llms/shared.md +300 -61
- package/llms/tokens.md +82 -82
- package/locales.json +138 -138
- package/package.json +2 -2
- package/registrations.json +1 -1
- package/vscode-css-data.json +1 -1
- package/vscode-html-data.json +1 -1
- package/web-types.json +1 -1
- package/dist/components/agent-tools/run-events.js +0 -1
- package/dist/components/agent-tools/tool-param-form/tool-param-types.js +0 -1
- package/dist/components/forms/emoji-picker/emoji-types.js +0 -1
- package/dist/components/layout/dashboard-grid/layout-types.js +0 -1
- package/dist/components/layout/details/accordion-types.js +0 -1
- package/dist/components/viewers/viewer-diagnostics.js +0 -1
- package/dist/internal/localization-types.js +0 -1
- package/dist/internal/node-type-style.js +0 -1
- package/dist/internal/picker-value.js +0 -1
- package/dist/internal/shared-unions.js +0 -1
- package/dist/internal/stream-phase.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(function applyStoredStyleBeforePaint(U,W,T,L,q,z){const{surfaces:N,contrastSurfaces:G,gemstones:j}=z,S=[],R=[],E=[],P=[];for(const s of z.inputs.split(" ")){const n=Number(s[0]),c=`--lr-theme-${s.slice(1)}`;S.push(c),n&1&&R.push(c),n&2&&E.push(c),n&4&&P.push(c)}function g(s,n,c=!1){return`--_lr-${c?"a":"l"}${n==="light"?"l":"d"}-${s.slice(11)}`}function M(s,n){let c=`var(${g(s,n)})`;if(E.includes(s)){const u=n==="light"?"l":"d",b=s.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");c=`var(--_lr-f${u}-${s.slice(11)},${c})var(--_lr-o${u}-${s.slice(11)},var(${g(b,n,!0)},var(${g(b,n)})))`}return P.includes(s)?`var(${g(s,n,!0)},${c})`:c}function J(s){const n=`var(--_lr-dark-on,${M(s,"light")})var(--_lr-light-on,${M(s,"dark")})`;if(!R.includes(s))return n;const c=s.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${n})var(--_lr-dense-off,max(calc((${n}) * var(--_lr-density-${c?"space":"control"},1)),${c?"0px":"var(--_lr-density-target-min,0px)"}))`}try{const s=document.currentScript,n=s?.getAttribute("data-lr-theme-storage-key"),c=n&&n.length<=200?n:U,u=s?.getAttribute("data-lr-theme-attributes")?.trim().split(/\s+/),b=u?.length&&u.length<=8&&new Set(u).size===u.length&&u.every(e=>e.length<=64&&/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e))?u:W;let t={};const H=localStorage.getItem(c);try{const e=JSON.parse(H??"null");e&&typeof e=="object"&&!Array.isArray(e)&&(t=e)}catch{}t.version!==void 0&&t.version!==2&&(t={});const h=t.mode==="light"||t.mode==="dark"||t.mode==="unset"?t.mode:"system",v=h==="unset"?null:h==="system"?matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":h,o=document.documentElement,y={},Q=getComputedStyle(o).getPropertyValue("--_lr-style-resolver").trim()==="1",X=e=>typeof e=="string"&&e.length<=64&&/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e),V=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},Y=e=>T({root:document.createElement("div"),record:{mode:"unset",tokens:e},normalizeOnly:!0})??{},I=Y(t.tokens),Z=Object.fromEntries(Object.entries(Y(t.overrides)).filter(([e,r])=>L(e,r,S))),m={...I,...Z},C=X(t.look)?t.look:Object.keys(I).length?"custom":"lyra";if(y["data-lr-look"]=C,y["data-lr-density"]=t.density==="compact"||t.density==="touch"?t.density:"comfortable",y["data-lr-surface"]=t.treatment==="glass"?"glass":"solid",h!=="unset"&&(y["data-lr-mode"]=h),v)for(const e of b)y[e]=v;const $=t.version===2&&typeof t.accentName=="string"&&Object.hasOwn(j,t.accentName)?t.accentName:null,_=$?j[$]:t.accent;y["data-lr-accent"]=$??(_?"custom":"none");const a=new Map;if(h==="unset")for(const[e,r]of Object.entries(m))typeof r=="string"&&a.set(e,r);for(const e of["light","dark"]){const r=typeof t.surface=="string"?t.surface:V(t.surface)[e],A=typeof m["--lr-theme-color-surface-default"]=="string"?m["--lr-theme-color-surface-default"]:V(m["--lr-theme-color-surface-default"])[e],f=r??A??N[C]?.[e];for(const p of[!1,!0]){if(p&&(!_||$))continue;const w=document.createElement("div");T({root:w,tokens:p?{}:m,references:p?G[e].map(i=>[1,3,5].map(d=>parseInt(i.slice(d,d+2),16))):[],record:{mode:e,surface:p&&$?N.lyra?.[e]:f,tokens:p?null:m,accent:p?_:null}});for(const i of w.style){const d=w.style.getPropertyValue(i);if(i==="--lr-theme-accent"){e===v&&a.set(i,d);continue}if(S.includes(i)&&L(i,d,S)){const K=i.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1],O=!p&&K&&d===`var(--lr-theme-color-brand-${K})`,B=i.slice(11),D=e==="light"?"l":"d";O||a.set(g(i,e,p),d),!p&&E.includes(i)&&(a.set(`--_lr-f${D}-${B}`,O?" ":"initial"),a.set(`--_lr-o${D}-${B}`,O?"initial":" ")),e===v&&a.set(i,Q?J(i):d)}else e===v&&a.set(i,d)}}}a.size&&(y["data-lr-theme-scope"]="");const F=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),k=o;let x;try{x=q(k[F])}catch{}const l=x??{attributes:new Map,properties:new Map};if(h==="unset")for(const e of b)l.attributes.has(e)||o.removeAttribute(e);try{const e=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),r=k[e];if(Array.isArray(r)){const A=r.slice(0,528).filter(f=>typeof f=="string"&&f.length<=80&&/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(f));for(const f of[...A,...P,"--lr-theme-accent"])!l.properties.has(f)&&o.style.getPropertyValue(f)&&l.properties.set(f,{before:null,priority:"",written:o.style.getPropertyValue(f)});try{delete k[e]}catch{}}}catch{}for(const[e,r]of l.attributes)Object.hasOwn(y,e)||(o.getAttribute(e)===r.written&&(r.before===null?o.removeAttribute(e):o.setAttribute(e,r.before)),l.attributes.delete(e));for(const[e,r]of Object.entries(y))l.attributes.has(e)||l.attributes.set(e,{before:o.getAttribute(e),priority:"",written:r}),o.setAttribute(e,r),l.attributes.get(e).written=r;for(const[e,r]of l.properties)a.has(e)||(o.style.getPropertyValue(e)===r.written&&!o.style.getPropertyPriority(e)&&(r.before?o.style.setProperty(e,r.before,r.priority):o.style.removeProperty(e)),l.properties.delete(e));for(const[e,r]of a)l.properties.has(e)||l.properties.set(e,{before:o.style.getPropertyValue(e),priority:o.style.getPropertyPriority(e),written:null}),o.style.getPropertyPriority(e)&&o.style.removeProperty(e),o.style.setProperty(e,r,""),l.properties.get(e).written=o.style.getPropertyValue(e);try{k[F]=l}catch{}}catch{}})("lyra-theme",["data-lr-theme","data-theme"],function applyStoredThemeBeforePaint(A){try{const x=A.record,S=x.mode==="light"||x.mode==="dark"||x.mode==="unset"?x.mode:"auto";let a=null;S==="light"||S==="dark"?a=S:S==="auto"&&(a=matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");const N=A.root,i=N.style,O=["brand","success","warning","danger","neutral"],rt=["fill","border","on"],W=["quiet","normal","loud"],B=[];for(const t of O)for(const e of rt)for(const o of W)B.push(`--lr-theme-color-${t}-${e}-${o}`);B.push("--lr-theme-color-focus");const nt=/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/,st=80,ct="--lr-theme-accent",_=512,lt=16,at=256,it=/[\x00-\x1f\x7f\\;{}!<>@[\]`$^|~=?&:\u2028\u2029]|\/\*|\*\//,G=/^(?:inherit|initial|revert(?:-layer)?|unset)$/i,ft=/([a-z0-9_-]+)\s*\(/gi,ut="rgb rgba hsl hsla hwb lab lch oklab oklch color color-mix light-dark calc min max clamp var cubic-bezier steps linear".split(" "),H=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),ht={light:{surface:[255,255,255],raised:[246,248,250],text:[26,26,26],overlayStrongAlpha:.92},dark:{surface:[26,26,26],raised:[34,39,46],text:[242,242,242],overlayStrongAlpha:.95}},J=t=>{let e=0,o="";for(const r of t){if(o){r===o&&(o="");continue}if(r==="'"||r==='"')o=r;else if(r==="(")e+=1;else if(r===")"&&(e-=1)<0)return!1}return o===""&&e===0},U=t=>typeof t=="string"&&t.length<=st&&nt.test(t)&&t!==ct,C=t=>{if(typeof t!="string")return null;const e=t.trim();if(!e||e.length>at||it.test(e)||G.test(e))return null;for(const o of e.matchAll(ft))if(!ut.includes((o[1]??"").toLowerCase()))return null;return J(e)?e:null},D=t=>{if(typeof t!="object"||t===null||Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null},E=[];try{const t=N[H];if(Array.isArray(t)){const e=Math.min(t.length,_+lt);for(let o=0;o<e;o+=1){const r=t[o];U(r)&&E.push(r)}}}catch{E.length=0}for(const t of[...B,"--lr-theme-accent",...E])i.removeProperty(t);const R={};try{const t=x.tokens,e=D(t)?Object.keys(t):[];if(D(t)&&e.length<=_)for(const o of e){if(!U(o))continue;const r=t[o];if(typeof r=="string"){const m=C(r);m!==null&&(R[o]=m);continue}if(!D(r))continue;const c=Object.prototype.hasOwnProperty.call(r,"light"),p=Object.prototype.hasOwnProperty.call(r,"dark");if(!c&&!p||Object.keys(r).some(m=>m!=="light"&&m!=="dark"))continue;const f=C(r.light),d=C(r.dark);(f!==null||d!==null)&&(R[o]={light:f,dark:d})}}catch{}if(A.normalizeOnly)return R;const u=new Map;for(const[t,e]of Object.entries(A.tokens??R)){const o=typeof e=="string"?e:a?e[a]:null;o&&u.set(t,o)}const dt=t=>G.test(t)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(t)||/\bcurrentcolor\b/i.test(t)||/\bvar\s*\(/i.test(t)||/\blight-dark\s*\(/i.test(t)||/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\s*\(\s*from\b/i.test(t),v=t=>{if(typeof t!="string")return null;const e=t.trim();if(!e||!J(e)||dt(e))return null;const o=document.createElement("span");return o.style.color=e,o.style.color?e:null},mt=t=>{if(typeof t=="string")return v(t);if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;return!a||!("light"in e)&&!("dark"in e)?null:v(e[a])},T={},z=x.accent;if(typeof z=="string"){const t=v(z);t&&(T.brand=t)}else if(z&&typeof z=="object"&&!Array.isArray(z))for(const t of O){const e=mt(z[t]);e&&(T[t]=e)}let b=null;if(a&&(u.size>0||Object.keys(T).length>0))try{const t=document.createElement("canvas");t.width=1,t.height=1,b=t.getContext("2d",{willReadFrequently:!0})}catch{b=null}const V=(t,e)=>{if(!b)return null;try{b.clearRect(0,0,1,1),b.fillStyle=t,b.fillRect(0,0,1,1);const o=[...b.getImageData(0,0,1,1).data],r=(o[3]??0)/255;return[0,1,2].map(c=>Math.round((o[c]??0)*r+(e[c]??0)*(1-r)))}catch{return null}},P=(t,e,o)=>t.map((r,c)=>Math.round(r*(1-o)+(e[c]??0)*o)),X=t=>{const e=t.map(o=>{const r=o/255;return r<=.04045?r/12.92:((r+.055)/1.055)**2.4});return(e[0]??0)*.2126+(e[1]??0)*.7152+(e[2]??0)*.0722},k=(t,e)=>{const o=X(t),r=X(e);return(Math.max(o,r)+.05)/(Math.min(o,r)+.05)},M=[0,0,0],j=[255,255,255],w=t=>k(t,M)>=k(t,j)?M:j,q=(t,e,o=3,r=e)=>{const c=f=>k(f,e)>=o&&k(f,r)>=o&&(A.references??[]).every(d=>k(f,d)>=o);if(c(t))return t;const p=k(e,M)>=k(e,j)?M:j;for(let f=1;f<=10;f+=1){const d=P(t,p,f/10);if(c(d))return d}return p},h=t=>`rgb(${t.join(" ")})`,F=ht[a??"light"],Y=F.surface,Z=v(x.surface)??v(u.get("--lr-theme-color-surface-default")),s=Z&&V(Z,Y)||Y,$=new Map(u);if(a){const t="--lr-theme-",e=(n,l)=>n!==void 0&&l&&v(n)?V(n,l):null,r=((n,l)=>u.has(t+n)?e(u.get(t+n),s):l)("color-surface-raised",F.raised),c=(n,l,g,L,tt)=>{const et=$.get(n);if(et===void 0||!g||tt===null)return;const Q=e(et,l);if(!Q)return;const ot=q(Q,g,L,tt??g);ot!==Q&&$.set(n,h(ot))};c(`${t}color-text-normal`,s,s,4.5,r),c(`${t}color-text-quiet`,s,s,4.5,r);const p=u.has(`${t}color-text-normal`)?e($.get(`${t}color-text-normal`),s):F.text,f=new Map,d=(n,l)=>{if(!l)return;const g=$.get(n);if(g===void 0){f.set(n,h(w(l)));return}const L=e(g,l);L&&k(L,l)<4.5&&$.set(n,h(w(l)))};for(const n of O)for(const l of W){const g=`${t}color-${n}-fill-${l}`;u.has(g)&&d(`${t}color-${n}-on-${l}`,e(u.get(g),s))}const m=`${t}color-overlay-strong`,K=u.has(m)?e(u.get(m),s):P(s,M,F.overlayStrongAlpha);(u.has(m)||u.has(`${t}color-on-strong-overlay`))&&d(`${t}color-on-strong-overlay`,K);const y=[...O.flatMap(n=>[`${t}color-${n}-border-normal`,`${t}color-${n}-border-loud`]),`${t}color-surface-border`,`${t}color-border-strong`,`${t}color-focus`];for(const n of y)c(n,s,s,3);for(const n of u.keys())/^--lr-theme-color-chart-\d+$/.test(n)?c(n,s,s,3):/^--lr-theme-terminal-color-[a-z0-9-]+$/.test(n)?c(n,r,r,4.5):/^--lr-theme-terminal-bg-[a-z0-9-]+$/.test(n)&&c(n,r,p,4.5);for(const[n,l]of f)$.set(n,l)}try{N[H]=Object.freeze([...$.keys()])}catch{}for(const[t,e]of $)i.setProperty(t,e);if(!a||!b){i.removeProperty("--lr-theme-accent");return}let I=null;for(const t of O){const e=T[t];if(!e)continue;const o=V(e,s);if(!o)continue;const r=P(s,o,a==="dark"?.24:.14),c=P(s,o,a==="dark"?.62:.55),p=q(o,s,4.5,r),f=a==="dark"?j:M,d=P(s,o,a==="dark"?.46:.38),m=q(P(s,o,a==="dark"?.78:.72),s),K=q(P(p,f,.2),s),y=`--lr-theme-color-${t}`;i.setProperty(`${y}-fill-quiet`,h(r)),i.setProperty(`${y}-fill-normal`,h(c)),i.setProperty(`${y}-fill-loud`,h(p)),i.setProperty(`${y}-border-quiet`,h(d)),i.setProperty(`${y}-border-normal`,h(m)),i.setProperty(`${y}-border-loud`,h(K)),i.setProperty(`${y}-on-quiet`,h(w(r))),i.setProperty(`${y}-on-normal`,h(w(c))),i.setProperty(`${y}-on-loud`,h(w(p))),t==="brand"&&(i.setProperty("--lr-theme-color-focus",h(q(o,s))),I=e)}I?i.setProperty("--lr-theme-accent",I):i.removeProperty("--lr-theme-accent")}catch{}},function styleTokenAllowed(e,r,o=STYLE_SLOTTED){if(e.startsWith("--lr-theme-surface-")||typeof r!="string"&&!o.includes(e))return!1;for(const t of typeof r=="string"?[r]:[r.light,r.dark])if(t)for(const c of t.matchAll(/var\(\s*(--[\w-]+)/g)){if(c[1]==="--lr-theme-shadow-color")continue;const n=e.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1];if(!n||t!==`var(--lr-theme-color-brand-${n})`)return!1}return!0},function readStyleOwnership(i){try{if(!i||typeof i!="object")return;const e=(r,s)=>Object.getOwnPropertyDescriptor(r,s)?.value,c={attributes:new Map,properties:new Map};for(const r of["attributes","properties"]){const s=e(i,r);let d=0;Map.prototype.forEach.call(s,(t,n)=>{if(++d>8192||typeof n!="string"||n.length>96||!(r==="attributes"?/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/:/^--(?:lr-theme-|_lr-)[a-z0-9-]+$/).test(n)||!t||typeof t!="object")throw new TypeError("Invalid style ownership");const p=e(t,"before"),f=e(t,"written"),y=e(t,"priority"),o=e(t,"requested");if(p!==null&&typeof p!="string"||f!==null&&typeof f!="string"||typeof y!="string"||o!==void 0&&typeof o!="string")throw new TypeError("Invalid style ownership value");c[r].set(n,{before:p,written:f,priority:y,...o===void 0?{}:{requested:o}})})}return c}catch{return}},{"inputs":"0color-border-strong 4color-brand-border-loud 4color-brand-border-normal 4color-brand-border-quiet 4color-brand-fill-loud 4color-brand-fill-normal 4color-brand-fill-quiet 4color-brand-on-loud 4color-brand-on-normal 4color-brand-on-quiet 0color-chart-1 0color-chart-2 0color-chart-3 0color-chart-4 0color-chart-5 0color-chart-6 0color-chart-7 0color-chart-8 0color-chart-diverging-1 0color-chart-diverging-2 0color-chart-diverging-3 0color-chart-sequential-1 0color-chart-sequential-2 0color-chart-sequential-3 6color-danger-border-loud 6color-danger-border-normal 6color-danger-border-quiet 6color-danger-fill-loud 6color-danger-fill-normal 6color-danger-fill-quiet 6color-danger-on-loud 6color-danger-on-normal 6color-danger-on-quiet 4color-focus 0color-mix-partner 6color-neutral-border-loud 6color-neutral-border-normal 6color-neutral-border-quiet 6color-neutral-fill-loud 6color-neutral-fill-normal 6color-neutral-fill-quiet 6color-neutral-on-loud 6color-neutral-on-normal 6color-neutral-on-quiet 0color-no-data 0color-on-strong-overlay 0color-overlay 0color-overlay-strong 6color-success-border-loud 6color-success-border-normal 6color-success-border-quiet 6color-success-fill-loud 6color-success-fill-normal 6color-success-fill-quiet 6color-success-on-loud 6color-success-on-normal 6color-success-on-quiet 0color-surface-border 0color-surface-border-subtle 0color-surface-container 0color-surface-container-high 0color-surface-container-highest 0color-surface-container-low 0color-surface-container-lowest 0color-surface-default 0color-surface-overlay 0color-surface-raised 0color-text-normal 0color-text-quiet 6color-warning-border-loud 6color-warning-border-normal 6color-warning-border-quiet 6color-warning-fill-loud 6color-warning-fill-normal 6color-warning-fill-quiet 6color-warning-on-loud 6color-warning-on-normal 6color-warning-on-quiet 1form-control-height-2xs 1form-control-height-l 1form-control-height-m 1form-control-height-s 1form-control-height-xl 1form-control-height-xs 0graph-cat-1 0graph-cat-2 0graph-cat-3 0graph-cat-4 0graph-cat-5 0graph-cat-6 0graph-cat-7 0graph-cat-8 1icon-button-size 0shadow-l 0shadow-m 0shadow-s 0shadow-xl 0shadow-xs 1space-2xl 1space-2xs 1space-l 1space-m 1space-s 1space-xs 0terminal-bg-black 0terminal-bg-blue 0terminal-bg-bright-black 0terminal-bg-bright-blue 0terminal-bg-bright-cyan 0terminal-bg-bright-green 0terminal-bg-bright-magenta 0terminal-bg-bright-red 0terminal-bg-bright-white 0terminal-bg-bright-yellow 0terminal-bg-cyan 0terminal-bg-green 0terminal-bg-magenta 0terminal-bg-red 0terminal-bg-white 0terminal-bg-yellow 0terminal-color-black 0terminal-color-blue 0terminal-color-bright-black 0terminal-color-bright-blue 0terminal-color-bright-cyan 0terminal-color-bright-green 0terminal-color-bright-magenta 0terminal-color-bright-red 0terminal-color-bright-white 0terminal-color-bright-yellow 0terminal-color-cyan 0terminal-color-green 0terminal-color-magenta 0terminal-color-red 0terminal-color-white 0terminal-color-yellow","surfaces":{"lyra":{"light":"#ffffff","dark":"#1a1a1a"},"data":{"light":"#ffffff","dark":"#101820"},"high-contrast":{"light":"#ffffff","dark":"#000000"},"material":{"light":"#fff8f5","dark":"#18120f"},"shadcn":{"light":"#ffffff","dark":"#0a0a0a"},"terminal":{"light":"#fcfdf9","dark":"#0e1713"}},"contrastSurfaces":{"light":["#ffffff","#f6f8fa","#f2f5f8","#fff8f5","#f8eeea","#fcf2ed","#f2e7e0","#ecdfd7","#fafafa","#fcfdf9","#f1f5eb"],"dark":["#1a1a1a","#22272e","#2b3038","#101820","#192630","#202e39","#000000","#18120f","#251d19","#302621","#120d0a","#211914","#3a2f29","#0a0a0a","#171717","#0e1713","#18271e","#203227"]},"gemstones":{"emerald":"#34d399","peridot":"#a8d84a","topaz":"#f0a83c","ruby":"#e63950","tourmaline":"#ec4899","amethyst":"#9d6df0","aquamarine":"#22d3ee","sapphire":"#4f8ff7","hematite":"#94a3b8"}});
|
|
1
|
+
(function(I,K,U,z,q,D,G,w){const{surfaces:M,contrast:J,accent:W}=w,m=new Map;for(const o of w.inputs.split(" "))m.set(`--lr-theme-${o.slice(1)}`,Number(o[0]));const P=[...m.keys()];function b(o,s,u=!1){return`--_lr-${u?"a":"l"}${s==="light"?"l":"d"}-${o.slice(11)}`}function N(o,s){const u=m.get(o)??0;let i=`var(${b(o,s)})`;if(u&2){const v=s==="light"?"l":"d",$=o.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");i=`var(--_lr-f${v}-${o.slice(11)},${i})var(--_lr-o${v}-${o.slice(11)},var(${b($,s,!0)},var(${b($,s)})))`}return u&4?`var(${b(o,s,!0)},${i})`:i}function H(o){const s=`var(--_lr-dark-on,${N(o,"light")})var(--_lr-light-on,${N(o,"dark")})`;if(!((m.get(o)??0)&1))return s;const u=o.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${s})var(--_lr-dense-off,max(calc((${s}) * var(--_lr-density-${u?"space":"control"},1)),${u?"0px":"var(--_lr-density-target-min,0px)"}))`}try{const o=document.currentScript,s=o?.getAttribute("data-lr-theme-storage-key"),u=s&&s.length<=200?s:I,i=o?.getAttribute("data-lr-theme-attributes")?.trim().split(/\s+/),v=i?.length&&i.length<=8&&new Set(i).size===i.length&&i.every(t=>t.length<=64&&/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(t))?i:K;let $;try{$=JSON.parse(localStorage.getItem(u)??"null")}catch{}const r=document.documentElement,[Q,X,Z]=U(),f=D($,w.defaults,Q,X,(t,e)=>z(t,e,P),W),y=f.mode,S=y==="unset"?null:y==="system"?matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":y,p={},V=getComputedStyle(r).getPropertyValue("--_lr-style-resolver").trim()==="1",j=(t,e)=>typeof t=="string"?t:t?.[e],tt=f.tokens,et=f.overrides,_={...tt,...et},C=f.look;if(p["data-lr-look"]=C,p["data-lr-density"]=f.density,p["data-lr-surface"]=f.treatment,y!=="unset"&&(p["data-lr-mode"]=y),S)for(const t of v)p[t]=S;const A=f.accentName;let d=f.accent;y!=="unset"&&d&&typeof d=="object"&&!Object.values(d).some(t=>typeof t=="string"||t&&Object.values(t).some(Boolean))&&(d=null),p["data-lr-accent"]=A??(d?"custom":"none");const a=new Map;if(y==="unset")for(const[t,e]of Object.entries(_))typeof e=="string"&&a.set(t,e);for(const t of["light","dark"]){const e=j(f.surface,t),E=j(_["--lr-theme-color-surface-default"],t),c=(M[C]??M.lyra)[t],T=e??E??c[0];for(const h of[!1,!0]){if(h&&(!d||A))continue;const rt=Z(h?{}:_,t,T,h?d:null,h?J[t].map(l=>[1,3,5].map(g=>parseInt(l.slice(g,g+2),16))):[],c);for(const[l,g]of rt){if(l==="--lr-theme-accent"){t===S&&a.set(l,g);continue}const Y=m.get(l);if(Y!==void 0&&z(l,g,P)){const x=l.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1],O=!h&&x&&g===`var(--lr-theme-color-brand-${x})`,B=l.slice(11),F=t==="light"?"l":"d";O||a.set(b(l,t,h),g),!h&&Y&2&&(a.set(`--_lr-f${F}-${B}`,O?" ":"initial"),a.set(`--_lr-o${F}-${B}`,O?"initial":" ")),t===S&&a.set(l,V?H(l):g)}else t===S&&a.set(l,g)}}}(a.size||y==="unset"&&d&&!A)&&(p["data-lr-theme-scope"]=""),V||G(a,f.treatment);const R=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),k=r;let L;try{L=q(k[R])}catch{}const n=L??{attributes:new Map,properties:new Map};if(y==="unset")for(const t of v)n.attributes.has(t)||r.removeAttribute(t);try{const t=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),e=k[t];if(Array.isArray(e)){const E=e.slice(0,528).filter(c=>typeof c=="string"&&c.length<=80&&/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(c));for(const c of[...E,...P.filter(T=>m.get(T)&4),"--lr-theme-accent"])!n.properties.has(c)&&r.style.getPropertyValue(c)&&n.properties.set(c,{before:null,priority:"",written:r.style.getPropertyValue(c)});try{delete k[t]}catch{}}}catch{}for(const[t,e]of n.attributes)Object.hasOwn(p,t)||(r.getAttribute(t)===e.written&&(e.before===null?r.removeAttribute(t):r.setAttribute(t,e.before)),n.attributes.delete(t));for(const[t,e]of Object.entries(p))n.attributes.has(t)||n.attributes.set(t,{before:r.getAttribute(t),priority:"",written:e}),r.setAttribute(t,e),n.attributes.get(t).written=e;for(const[t,e]of n.properties)a.has(t)||(r.style.getPropertyValue(t)===e.written&&!r.style.getPropertyPriority(t)&&(e.before?r.style.setProperty(t,e.before,e.priority):r.style.removeProperty(t)),n.properties.delete(t));for(const[t,e]of a)n.properties.has(t)||n.properties.set(t,{before:r.style.getPropertyValue(t),priority:r.style.getPropertyPriority(t),written:null}),r.style.getPropertyPriority(t)&&r.style.removeProperty(t),r.style.setProperty(t,e,""),n.properties.get(t).written=r.style.getPropertyValue(t);try{k[R]=n}catch{}}catch{}})("lyra-theme",["data-lr-theme","data-theme"],function(){const R=["brand","success","warning","danger","neutral"],Q=["quiet","normal","loud"],W=/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/,_="--lr-theme-accent",G=/[\x00-\x1f\x7f\\;{}!<>@[\]`$^|~=?&:\u2028\u2029]|\/\*|\*\//,H=/^(?:inherit|initial|revert(?:-layer)?|unset)$/i,J=/([a-z0-9_-]+)\s*\(/gi,K="rgb rgba hsl hsla hwb lab lch oklab oklch color color-mix light-dark calc min max clamp var cubic-bezier steps linear".split(" "),U={light:[255,255,255],dark:[10,10,10]},X=r=>{let o=0,h="";for(const a of r){if(h){a===h&&(h="");continue}if(a==="'"||a==='"')h=a;else if(a==="(")o+=1;else if(a===")"&&(o-=1)<0)return!1}return h===""&&o===0},Y=r=>typeof r=="string"&&r.length<=80&&W.test(r)&&r!==_,P=r=>{if(typeof r!="string")return null;const o=r.trim();if(!o||o.length>256||G.test(o)||H.test(o))return null;for(const h of o.matchAll(J))if(!K.includes((h[1]??"").toLowerCase()))return null;return X(o)?o:null},A=r=>{if(typeof r!="object"||r===null||Array.isArray(r))return!1;const o=Object.getPrototypeOf(r);return o===Object.prototype||o===null},Z=r=>{const o={};try{if(!A(r))return o;const h=Object.keys(r);if(h.length<=512)for(const a of h){if(!Y(a))continue;const g=r[a];if(typeof g=="string"){const u=P(g);u!==null&&(o[a]=u);continue}if(!A(g))continue;const j=Object.hasOwn(g,"light"),i=Object.hasOwn(g,"dark");if(!j&&!i||Object.keys(g).some(u=>u!=="light"&&u!=="dark"))continue;const M=P(g.light),y=P(g.dark);(M!==null||y!==null)&&(o[a]={light:M,dark:y})}}catch{}return o},C=r=>{const o=P(r);if(!(!o||/\b(?:var|light-dark)\s*\(|\b(?:currentcolor|from)\b/i.test(o)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(o)))return CSS.supports("color",o)?o:void 0};return[Z,C,(r,o,h,a,g,j)=>{const i=new Map;for(const[t,n]of Object.entries(r)){const e=typeof n=="string"?n:n[o];e&&i.set(t,e)}const M=typeof a=="string"?{brand:a}:a,y={};for(const t of R){const n=M?.[t],e=typeof n=="string"?n:n?.[o];e&&(y[t]=e)}let u=null;if(i.size>0||Object.keys(y).length>0)try{const t=document.createElement("canvas");t.width=1,t.height=1,u=t.getContext("2d",{willReadFrequently:!0})}catch{u=null}const S=(t,n)=>{if(!u)return null;try{u.clearRect(0,0,1,1),u.fillStyle=t,u.fillRect(0,0,1,1);const e=u.getImageData(0,0,1,1).data,c=(e[3]??0)/255;return[0,1,2].map(f=>Math.round((e[f]??0)*c+(n[f]??0)*(1-c)))}catch{return null}},z=(t,n,e)=>t.map((c,f)=>Math.round(c*(1-e)+(n[f]??0)*e)),B=t=>{const n=t.map(e=>{const c=e/255;return c<=.04045?c/12.92:((c+.055)/1.055)**2.4});return(n[0]??0)*.2126+(n[1]??0)*.7152+(n[2]??0)*.0722},O=(t,n)=>{const e=B(t),c=B(n);return(Math.max(e,c)+.05)/(Math.min(e,c)+.05)},v=[0,0,0],F=[255,255,255],w=t=>O(t,v)>=O(t,F)?v:F,q=(t,n,e=3,c=n)=>{const f=d=>O(d,n)>=e&&O(d,c)>=e&&g.every(k=>O(d,k)>=e);if(f(t))return t;const p=w(n);for(let d=1;d<=10;d+=1){const k=z(t,p,d/10);if(f(k))return k}return p},m=t=>`rgb(${t.join(" ")})`,D=U[o],E=C(h)??C(i.get("--lr-theme-color-surface-default")),s=E&&S(E,D)||D,l=new Map(i),b="--lr-theme-",$=(t,n)=>t!==void 0&&n&&C(t)?S(t,n):null,tt=`${b}color-surface-raised`,N=$(i.get(tt)??j[1],s),L=(t,n,e,c,f)=>{const p=l.get(t);if(p===void 0||!e||f===null)return;const d=$(p,n);if(!d)return;const k=q(d,e,c,f??e);k!==d&&l.set(t,m(k))};L(`${b}color-text-normal`,s,s,4.5,N),L(`${b}color-text-quiet`,s,s,4.5,N);const et=i.has(`${b}color-text-normal`)?$(l.get(`${b}color-text-normal`),s):$(j[2],s),I=(t,n)=>{if(!n)return;const e=l.get(t),c=e===void 0?null:$(e,n);(e===void 0||c&&O(c,n)<4.5)&&l.set(t,m(w(n)))};for(const t of R)for(const n of Q){const e=`${b}color-${t}-fill-${n}`;i.has(e)&&I(`${b}color-${t}-on-${n}`,$(i.get(e),s))}const T=`${b}color-overlay-strong`;(i.has(T)||i.has(`${b}color-on-strong-overlay`))&&I(`${b}color-on-strong-overlay`,i.has(T)?$(i.get(T),s):$(j[3],s));for(const t of i.keys())/^--lr-theme-color-(?:(?:brand|success|warning|danger|neutral)-border-(?:normal|loud)|surface-border|border-strong|focus|chart-\d+)$/.test(t)?L(t,s,s,3):/^--lr-theme-terminal-color-[a-z0-9-]+$/.test(t)?L(t,N,N,4.5):/^--lr-theme-terminal-bg-[a-z0-9-]+$/.test(t)&&L(t,N,et,4.5);if(!u)return l;let V=null;for(const t of R){const n=y[t];if(!n)continue;const e=S(n,s);if(!e)continue;const c=z(s,e,o==="dark"?.24:.14),f=z(s,e,o==="dark"?.62:.55),p=q(e,s,4.5,c),d=o==="dark"?F:v,k=z(s,e,o==="dark"?.46:.38),nt=q(z(s,e,o==="dark"?.78:.72),s),ot=q(z(p,d,.2),s),x=`--lr-theme-color-${t}`;l.set(`${x}-fill-quiet`,m(c)),l.set(`${x}-fill-normal`,m(f)),l.set(`${x}-fill-loud`,m(p)),l.set(`${x}-border-quiet`,m(k)),l.set(`${x}-border-normal`,m(nt)),l.set(`${x}-border-loud`,m(ot)),l.set(`${x}-on-quiet`,m(w(c))),l.set(`${x}-on-normal`,m(w(f))),l.set(`${x}-on-loud`,m(w(p))),t==="brand"&&(l.set("--lr-theme-color-focus",m(q(e,s))),V=n)}return V&&l.set("--lr-theme-accent",V),l}]},function(e,r,o=STYLE_SLOTTED){if(e.startsWith("--lr-theme-surface-")||typeof r!="string"&&!o.includes(e))return!1;for(const t of typeof r=="string"?[r]:[r.light,r.dark])if(t)for(const c of t.matchAll(/var\(\s*(--[\w-]+)/g)){if(c[1]==="--lr-theme-shadow-color")continue;const n=e.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1];if(!n||t!==`var(--lr-theme-color-brand-${n})`)return!1}return!0},function(i){try{if(!i||typeof i!="object")return;const e=(r,s)=>Object.getOwnPropertyDescriptor(r,s)?.value,c={attributes:new Map,properties:new Map};for(const r of["attributes","properties"]){const s=e(i,r);let d=0;Map.prototype.forEach.call(s,(t,o)=>{if(++d>8192||typeof o!="string"||o.length>96||!(r==="attributes"?/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/:/^--(?:lr-theme-|_lr-)[a-z0-9-]+$/).test(o)||!t||typeof t!="object")throw new TypeError;const p=e(t,"before"),f=e(t,"written"),y=e(t,"priority"),n=e(t,"requested");if(p!==null&&typeof p!="string"||f!==null&&typeof f!="string"||typeof y!="string"||n!==void 0&&typeof n!="string")throw new TypeError;c[r].set(o,{before:p,written:f,priority:y,...n===void 0?{}:{requested:n}})})}return c}catch{return}},function(c,i,N,k,z,d){const f=n=>n!==null&&typeof n=="object"&&!Array.isArray(n),o=(n,t)=>{if(!f(n))return;const e=Object.getOwnPropertyDescriptor(n,t);return e&&"value"in e?e.value:void 0},m=n=>typeof n=="string"&&n.length<=64&&/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(n),p=n=>{const t=N(n);return t&&Object.keys(t).length?t:null},l=n=>{if(n===null)return null;if(typeof n=="string")return k(n);if(!f(n))return;const t={};for(const e of["light","dark"]){const s=o(n,e),O=s===null?null:k(s);O!==void 0&&(t[e]=O)}return Object.keys(t).length?{light:t.light??null,dark:t.dark??null}:void 0},w=n=>{if(n===null||typeof n=="string")return l(n);if(!f(n))return;const t={};for(const e of["brand","success","warning","danger","neutral"]){const s=l(o(n,e));s!==void 0&&(t[e]=s)}return Object.keys(t).length?t:void 0},r={version:2,look:i.look,treatment:i.surface,density:i.density,mode:i.mode,accent:d[i.accent],accentName:i.accent,surface:null},a=o(c,"version");if(!f(c)||a!==void 0&&a!==2)return r;const y=o(c,"look"),g=p(o(c,"tokens"));(m(y)||g)&&(r.look=m(y)?y:"custom",g&&(r.tokens=g));for(const[n,t]of[["treatment",["solid","glass"]],["density",["comfortable","compact","touch"]],["mode",["light","dark","system","auto","unset"]]]){const e=o(c,n);typeof e=="string"&&t.includes(e)&&(r[n]=e==="auto"?"system":e)}const u=o(c,"accentName"),b=w(o(c,"accent"));a===2&&typeof u=="string"&&Object.hasOwn(d,u)?(r.accentName=u,r.accent=d[u]):b!==void 0&&(delete r.accentName,r.accent=b);const h=l(o(c,"surface"));h!==void 0&&(r.surface=h);const j=Object.entries(p(o(c,"overrides"))??{}).filter(([n,t])=>z(n,t));return j.length&&(r.overrides=Object.fromEntries(j)),r},function(l,n){const t=n==="glass";for(const[a,i]of Object.entries({enabled:t?"1":"0",content:t?"''":"none",isolation:t?"isolate":"auto","root-filter":t?"initial":"none","child-filter":t?"none":"initial","child-opacity":t?"1":"0"}))l.set(`--_lr-surface-${a}`,i);l.set("--_lr-glass-blocker",t?"initial":"none"),t||(l.set("--_lr-glass-parent-opacity","0"),l.set("--_lr-next-glass-opacity","0"))},{"defaults":{"look":"shadcn","surface":"glass","density":"comfortable","mode":"system","accent":"emerald"},"inputs":"0color-border-strong 4color-brand-border-loud 4color-brand-border-normal 4color-brand-border-quiet 4color-brand-fill-loud 4color-brand-fill-normal 4color-brand-fill-quiet 4color-brand-on-loud 4color-brand-on-normal 4color-brand-on-quiet 0color-chart-1 0color-chart-2 0color-chart-3 0color-chart-4 0color-chart-5 0color-chart-6 0color-chart-7 0color-chart-8 0color-chart-diverging-1 0color-chart-diverging-2 0color-chart-diverging-3 0color-chart-sequential-1 0color-chart-sequential-2 0color-chart-sequential-3 6color-danger-border-loud 6color-danger-border-normal 6color-danger-border-quiet 6color-danger-fill-loud 6color-danger-fill-normal 6color-danger-fill-quiet 6color-danger-on-loud 6color-danger-on-normal 6color-danger-on-quiet 4color-focus 0color-mix-partner 6color-neutral-border-loud 6color-neutral-border-normal 6color-neutral-border-quiet 6color-neutral-fill-loud 6color-neutral-fill-normal 6color-neutral-fill-quiet 6color-neutral-on-loud 6color-neutral-on-normal 6color-neutral-on-quiet 0color-no-data 0color-on-strong-overlay 0color-overlay 0color-overlay-strong 6color-success-border-loud 6color-success-border-normal 6color-success-border-quiet 6color-success-fill-loud 6color-success-fill-normal 6color-success-fill-quiet 6color-success-on-loud 6color-success-on-normal 6color-success-on-quiet 0color-surface-border 0color-surface-border-subtle 0color-surface-container 0color-surface-container-high 0color-surface-container-highest 0color-surface-container-low 0color-surface-container-lowest 0color-surface-default 0color-surface-overlay 0color-surface-raised 0color-text-normal 0color-text-quiet 6color-warning-border-loud 6color-warning-border-normal 6color-warning-border-quiet 6color-warning-fill-loud 6color-warning-fill-normal 6color-warning-fill-quiet 6color-warning-on-loud 6color-warning-on-normal 6color-warning-on-quiet 1form-control-height-2xs 1form-control-height-l 1form-control-height-m 1form-control-height-s 1form-control-height-xl 1form-control-height-xs 0graph-cat-1 0graph-cat-2 0graph-cat-3 0graph-cat-4 0graph-cat-5 0graph-cat-6 0graph-cat-7 0graph-cat-8 1icon-button-size 0shadow-l 0shadow-m 0shadow-s 0shadow-xl 0shadow-xs 1space-2xl 1space-2xs 1space-l 1space-m 1space-s 1space-xs 0terminal-bg-black 0terminal-bg-blue 0terminal-bg-bright-black 0terminal-bg-bright-blue 0terminal-bg-bright-cyan 0terminal-bg-bright-green 0terminal-bg-bright-magenta 0terminal-bg-bright-red 0terminal-bg-bright-white 0terminal-bg-bright-yellow 0terminal-bg-cyan 0terminal-bg-green 0terminal-bg-magenta 0terminal-bg-red 0terminal-bg-white 0terminal-bg-yellow 0terminal-color-black 0terminal-color-blue 0terminal-color-bright-black 0terminal-color-bright-blue 0terminal-color-bright-cyan 0terminal-color-bright-green 0terminal-color-bright-magenta 0terminal-color-bright-red 0terminal-color-bright-white 0terminal-color-bright-yellow 0terminal-color-cyan 0terminal-color-green 0terminal-color-magenta 0terminal-color-red 0terminal-color-white 0terminal-color-yellow","surfaces":{"lyra":{"light":["#ffffff","#f6f8fa","#1a1a1a","rgb(0 0 0 / 0.92)"],"dark":["#1a1a1a","#22272e","#f2f2f2","rgb(0 0 0 / 0.95)"]},"data":{"light":["#ffffff","#f2f5f8","#10202c","#17212b"],"dark":["#101820","#192630","#eef5fa","#e7eef4"]},"high-contrast":{"light":["#ffffff","#ffffff","#000000","#17212b"],"dark":["#000000","#000000","#ffffff","#e7eef4"]},"material":{"light":["#fff8f5","#f8eeea","#241b17","rgb(0 0 0 / 0.92)"],"dark":["#18120f","#251d19","#f8eee8","rgb(0 0 0 / 0.95)"]},"shadcn":{"light":["#ffffff","#fafafa","#0a0a0a","rgb(0 0 0 / 0.92)"],"dark":["#0a0a0a","#171717","#fafafa","rgb(0 0 0 / 0.95)"]},"terminal":{"light":["#fcfdf9","#f1f5eb","#0d2115","#17212b"],"dark":["#0e1713","#18271e","#e5f5e9","#e7eef4"]}},"contrast":{"light":["#ffffff","#f6f8fa","#f2f5f8","#fff8f5","#f8eeea","#fcf2ed","#f2e7e0","#ecdfd7","#fafafa","#fcfdf9","#f1f5eb"],"dark":["#1a1a1a","#22272e","#2b3038","#101820","#192630","#202e39","#000000","#18120f","#251d19","#302621","#120d0a","#211914","#352a24","#0a0a0a","#171717","#0e1713","#18271e","#203227"]},"accent":{"emerald":"#34d399","peridot":"#a8d84a","topaz":"#f0a83c","ruby":"#e63950","tourmaline":"#ec4899","amethyst":"#9d6df0","aquamarine":"#22d3ee","sapphire":"#4f8ff7","hematite":"#94a3b8"}});
|
package/dist/theme/theme.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Standalone style runtime, published as the `@aceshooting/lyra-ui/theme.js`
|
|
3
|
-
* subpath.
|
|
3
|
+
* subpath. Shared helpers remain dependency-free; applications need no component imports.
|
|
4
4
|
* Applications persist and apply styles without importing Lit or the component graph.
|
|
5
5
|
*
|
|
6
6
|
* This module is side-effect-free -- importing it never touches the document or storage -- and
|
|
7
7
|
* therefore carries no `package.json#sideEffects` entry, so bundlers may drop it when unused.
|
|
8
8
|
*/
|
|
9
|
-
export interface LyraThemeBootstrapOptions{
|
|
9
|
+
import type{LyraThemeTokens}from'../internal/theme-token-types.js';export type{LyraThemeTokenName,LyraThemeTokens,LyraThemeTokenValue}from'../internal/theme-token-types.js';export interface LyraThemeBootstrapOptions{
|
|
10
10
|
/** The localStorage key holding a `{ mode, accent, surface, tokens? }` theme record. */
|
|
11
11
|
storageKey?:string;}
|
|
12
12
|
/**
|
|
@@ -32,26 +32,11 @@ export type LyraThemeAccentValue=string|null|{readonly light?:string|null;readon
|
|
|
32
32
|
*/
|
|
33
33
|
export type LyraThemeAccent=string|null|{readonly[role in LyraThemeSemanticRole]?:LyraThemeAccentValue;};
|
|
34
34
|
/**
|
|
35
|
-
* A theme input a token map may set: a `--lr-theme-*` custom property name. At run time a name
|
|
36
|
-
* must also match `^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$`, be at most 80 characters long, and not be
|
|
37
|
-
* `--lr-theme-accent`, which the accent runtime owns.
|
|
38
|
-
*/
|
|
39
|
-
export type LyraThemeTokenName=`--lr-theme-${string}`;
|
|
40
|
-
/**
|
|
41
|
-
* A token's CSS value for both resolved modes, or a `{ light?, dark? }` pair. A `null` or omitted
|
|
42
|
-
* branch leaves that mode to the stylesheets.
|
|
43
|
-
*/
|
|
44
|
-
export type LyraThemeTokenValue=string|{readonly light?:string|null;readonly dark?:string|null;};
|
|
45
|
-
/**
|
|
46
|
-
* Validated `--lr-theme-*` overrides, written inline on the document root. A map always replaces
|
|
47
|
-
* the previous one wholesale; compose maps with object spread.
|
|
48
|
-
*/
|
|
49
|
-
export type LyraThemeTokens={readonly[name:LyraThemeTokenName]:LyraThemeTokenValue;};
|
|
50
|
-
/**
|
|
51
35
|
* Creates a self-contained IIFE body, safe to inline into a `<script>` tag placed before any
|
|
52
36
|
* stylesheet in `<head>`, that applies a persisted `{ mode, accent, surface, tokens? }` theme before
|
|
53
37
|
* first paint -- including the stored token map, validated and contrast-floored exactly as the runtime
|
|
54
|
-
* does. Missing and
|
|
38
|
+
* does. Missing and invalid fields independently use the built-in Shadcn/Glass/Emerald/System
|
|
39
|
+
* profile. Explicit saved choices, including Solid surfaces and null accents, take precedence.
|
|
55
40
|
* The serialized options escape HTML script terminators and JavaScript line separators.
|
|
56
41
|
* Pass an application-owned `storageKey` to reuse the no-flash bootstrap independently of this
|
|
57
42
|
* v1 theme records and the current style API's `lyra-theme` persistence key.
|
|
@@ -85,11 +70,11 @@ readonly accentName:LyraAccentName|null;readonly accentBackground:LyraAccentBack
|
|
|
85
70
|
export interface LyraStyleScopeChoices{look?:LyraLookId|LyraLook;surface?:LyraSurface;density?:LyraDensity;mode?:'light'|'dark'|'system';accent?:LyraAccent;accentBackground?:LyraAccentBackground;overrides?:LyraThemeTokens;}export interface LyraStyleChangeDetail{readonly style:Readonly<LyraStyle>;readonly changed:readonly(LyraStyleField|'resolvedMode')[];}declare global{interface WindowEventMap{'lr-style-change':CustomEvent<LyraStyleChangeDetail>;}}
|
|
86
71
|
/** Validates and freezes a look definition; it does not register an id or install CSS. */
|
|
87
72
|
export declare function defineLyraLook<const Look extends LyraLook>(look:Look):Readonly<Look>;
|
|
88
|
-
/** Normalizes a parsed persisted record without
|
|
73
|
+
/** Normalizes a parsed persisted record without browser APIs; CSS color validation is syntactic. */
|
|
89
74
|
export declare function parseLyraStyleRecord(value:unknown):Readonly<LyraStyle>;
|
|
90
75
|
/** Requested-axis attributes for server rendering. Resolved-mode attributes belong to the browser. */
|
|
91
76
|
export declare function lyraStyleAttributes(style:Partial<LyraStyle>):Readonly<Record<string,string>>;
|
|
92
|
-
/** Selects independent axes on the document root. Omitted fields keep their choices; null resets. */
|
|
77
|
+
/** Selects independent axes on the document root. Omitted fields keep their choices; null resets, except accent null clears. */
|
|
93
78
|
export declare function setLyraStyle(choices:LyraStyleChoices):Readonly<LyraStyle>;
|
|
94
79
|
/** Reads the persisted selection, falling back to the applied state if persistence failed. */
|
|
95
80
|
export declare function getLyraStyle():Readonly<LyraStyle>;
|
package/dist/theme/theme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{devWarnOnce,litDevWarnings}from"../internal/dev-warning.js";import{readStyleOwnership}from"./style-ownership.js";const STORAGE_KEY="lyra-theme",TOKEN_NAME_PATTERN=/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/,TOKEN_NAME_MAX_LENGTH=80,TOKEN_RESERVED_NAME="--lr-theme-accent",TOKEN_ENTRY_MAX=512,TOKEN_SYNTHESIZED_MAX=16,TOKEN_VALUE_MAX_LENGTH=256,TOKEN_FORBIDDEN_PATTERN=/[\x00-\x1f\x7f\\;{}!<>@[\]`$^|~=?&:\u2028\u2029]|\/\*|\*\//,TOKEN_CSS_WIDE_PATTERN=/^(?:inherit|initial|revert(?:-layer)?|unset)$/i,TOKEN_FUNCTION_PATTERN=/([a-z0-9_-]+)\s*\(/gi,TOKEN_ALLOWED_FUNCTIONS="rgb rgba hsl hsla hwb lab lch oklab oklch color color-mix light-dark calc min max clamp var cubic-bezier steps linear".split(" "),TOKEN_OWNERSHIP_MAX=TOKEN_ENTRY_MAX+TOKEN_SYNTHESIZED_MAX,TOKEN_OWNERSHIP_SYMBOL="@aceshooting/lyra-ui.theme-tokens.v1",MODE_DEFAULTS={light:{surface:[255,255,255],raised:[246,248,250],text:[26,26,26],overlayStrongAlpha:.92},dark:{surface:[26,26,26],raised:[34,39,46],text:[242,242,242],overlayStrongAlpha:.95}},COLOR_SCHEME_QUERY="(prefers-color-scheme: dark)",SEMANTIC_ROLES=["brand","success","warning","danger","neutral"],RAMP_CHANNELS=["fill","border","on"],RAMP_TIERS=["quiet","normal","loud"];function roleRampProperties(role){const properties=[];for(const channel of RAMP_CHANNELS)for(const tier of RAMP_TIERS)properties.push(`--lr-theme-color-${role}-${channel}-${tier}`);return properties}const ALL_RAMP_PROPERTIES=[...SEMANTIC_ROLES.flatMap(roleRampProperties),"--lr-theme-color-focus"],MODE_ATTRIBUTES=["data-lr-theme","data-theme"];function isBalancedCssValue(value){let depth=0,quote="";for(const character of value){if(quote){character===quote&&(quote="");continue}if(character==="'"||character==='"')quote=character;else if(character==="(")depth+=1;else if(character===")"&&(depth-=1)<0)return!1}return quote===""&&depth===0}function isLyraThemeTokenName(name){return typeof name=="string"&&name.length<=TOKEN_NAME_MAX_LENGTH&&TOKEN_NAME_PATTERN.test(name)&&name!==TOKEN_RESERVED_NAME}function isSafeLyraThemeTokenValue(value){if(typeof value!="string")return!1;const trimmed=value.trim();if(!trimmed||trimmed.length>TOKEN_VALUE_MAX_LENGTH||TOKEN_FORBIDDEN_PATTERN.test(trimmed)||TOKEN_CSS_WIDE_PATTERN.test(trimmed))return!1;for(const match of trimmed.matchAll(TOKEN_FUNCTION_PATTERN))if(!TOKEN_ALLOWED_FUNCTIONS.includes((match[1]??"").toLowerCase()))return!1;return isBalancedCssValue(trimmed)}function isPlainRecord(value){if(typeof value!="object"||value===null||Array.isArray(value))return!1;const prototype=Object.getPrototypeOf(value);if(prototype===Object.prototype||prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructor=Object.getOwnPropertyDescriptor(prototype,"constructor")?.value;return typeof constructor=="function"&&Function.prototype.toString.call(constructor)===Function.prototype.toString.call(Object)}function normalizeTokenBranch(value){return isSafeLyraThemeTokenValue(value)?value.trim():null}function normalizeTokens(raw){try{if(!isPlainRecord(raw))return null;const names=Object.keys(raw);if(names.length===0||names.length>TOKEN_ENTRY_MAX)return null;const result={};let kept=0;for(const name of names){if(!isLyraThemeTokenName(name))continue;const value=ownField(raw,name);if(typeof value=="string"){const normalized=normalizeTokenBranch(value);if(normalized===null)continue;result[name]=normalized,kept+=1;continue}if(!isPlainRecord(value))continue;const keys=Object.keys(value),hasLight=Object.prototype.hasOwnProperty.call(value,"light"),hasDark=Object.prototype.hasOwnProperty.call(value,"dark");if(!hasLight&&!hasDark||keys.some(key=>key!=="light"&&key!=="dark"))continue;const light=normalizeTokenBranch(ownField(value,"light")),dark=normalizeTokenBranch(ownField(value,"dark"));light===null&&dark===null||(result[name]=Object.freeze({light,dark}),kept+=1)}return kept>0?Object.freeze(result):null}catch{return null}}function tokensEqual(left,right){const leftNames=left?Object.keys(left):[],rightNames=right?Object.keys(right):[];if(leftNames.length!==rightNames.length)return!1;if(leftNames.length===0)return!0;const leftMap=left,rightMap=right;return leftNames.every(name=>{if(!Object.prototype.hasOwnProperty.call(rightMap,name))return!1;const a=leftMap[name],b=rightMap[name];return typeof a=="string"||typeof b=="string"?a===b:!a||!b?!1:(a.light??null)===(b.light??null)&&(a.dark??null)===(b.dark??null)})}function normalizeColor(value,owner=document){if(typeof value!="string"||!value.trim())return null;const candidate=value.trim();if(!isBalancedCssValue(candidate)||TOKEN_CSS_WIDE_PATTERN.test(candidate)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(candidate)||/\bcurrentcolor\b/i.test(candidate)||/\bvar\s*\(/i.test(candidate)||/\blight-dark\s*\(/i.test(candidate)||/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\s*\(\s*from\b/i.test(candidate))return null;const probe=owner.createElement("span");return probe.style.color=candidate,probe.style.color?candidate:null}function normalizeAccentValue(value){if(typeof value=="string"||value===null)return normalizeColor(value);if(typeof value!="object"||Array.isArray(value))return null;const record=value;if(!("light"in record)&&!("dark"in record))return null;const light=normalizeColor(record.light),dark=normalizeColor(record.dark);return light||dark?{light,dark}:null}function normalizeAccent(value){if(typeof value=="string")return normalizeColor(value);if(value===null||typeof value!="object"||Array.isArray(value))return null;const record=value,result={};let hasRole=!1;for(const role of SEMANTIC_ROLES)role in record&&(hasRole=!0,result[role]=normalizeAccentValue(record[role]));return hasRole?result:null}function resolveAccentValueForMode(value,mode){return typeof value=="string"?value:value?value[mode]??null:null}function accentValueEqual(left,right){return left===right?!0:typeof left=="string"||typeof right=="string"||left===null||right===null?!1:(left.light??null)===(right.light??null)&&(left.dark??null)===(right.dark??null)}function accentsEqual(left,right){if(left===right)return!0;if(typeof left=="string"||typeof right=="string"||left===null||right===null)return!1;const leftKeys=Object.keys(left),rightKeys=Object.keys(right);return leftKeys.length!==rightKeys.length?!1:leftKeys.every(role=>accentValueEqual(left[role],right[role]))}function parseResolvedRgb(value,background,owner=document){if(!normalizeColor(value,owner))return null;try{const canvas=owner.createElement("canvas");canvas.width=1,canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0});if(!context)return null;context.clearRect(0,0,1,1),context.fillStyle=value,context.fillRect(0,0,1,1);const channels=context.getImageData(0,0,1,1).data,red=channels[0]??0,green=channels[1]??0,blue=channels[2]??0,alpha=(channels[3]??0)/255;return[Math.round(red*alpha+background[0]*(1-alpha)),Math.round(green*alpha+background[1]*(1-alpha)),Math.round(blue*alpha+background[2]*(1-alpha))]}catch{return null}}function mixRgb(base,color,colorWeight){return[Math.round(base[0]*(1-colorWeight)+color[0]*colorWeight),Math.round(base[1]*(1-colorWeight)+color[1]*colorWeight),Math.round(base[2]*(1-colorWeight)+color[2]*colorWeight)]}function serializeRgb(color){return`rgb(${color.join(" ")})`}function relativeLuminance(color){const linearize=channel=>{const normalized=channel/255;return normalized<=.04045?normalized/12.92:((normalized+.055)/1.055)**2.4};return linearize(color[0])*.2126+linearize(color[1])*.7152+linearize(color[2])*.0722}function contrastRatio(left,right){const a=relativeLuminance(left),b=relativeLuminance(right);return(Math.max(a,b)+.05)/(Math.min(a,b)+.05)}function contrastForeground(fill){const black=[0,0,0],white=[255,255,255];return contrastRatio(fill,black)>=contrastRatio(fill,white)?black:white}function ensureSurfaceContrast(color,background,minimum=3,alsoAgainst=background,references=[]){const passes=candidate=>contrastRatio(candidate,background)>=minimum&&contrastRatio(candidate,alsoAgainst)>=minimum&&references.every(reference=>contrastRatio(candidate,reference)>=minimum);if(passes(color))return color;const black=[0,0,0],white=[255,255,255],target=contrastRatio(background,black)>=contrastRatio(background,white)?black:white;for(let step=1;step<=10;step+=1){const candidate=mixRgb(color,target,step/10);if(passes(candidate))return candidate}return target}function createRoleRamp(role,base,mode,background,owner=document){const references=STYLE_CONTRAST_SURFACES[mode].flatMap(color=>{const value=parseResolvedRgb(color,MODE_DEFAULTS[mode].surface,owner);return value?[value]:[]}),resolved=parseResolvedRgb(base,background,owner);if(!resolved)return null;const quiet=mixRgb(background,resolved,mode==="dark"?.24:.14),normal=mixRgb(background,resolved,mode==="dark"?.62:.55),loud=ensureSurfaceContrast(resolved,background,4.5,quiet,references),borderTarget=mode==="dark"?[255,255,255]:[0,0,0],borderQuiet=mixRgb(background,resolved,mode==="dark"?.46:.38),borderNormal=ensureSurfaceContrast(mixRgb(background,resolved,mode==="dark"?.78:.72),background,3,background,references),borderLoud=ensureSurfaceContrast(mixRgb(loud,borderTarget,.2),background,3,background,references),prefix=`--lr-theme-color-${role}`,ramp={[`${prefix}-fill-quiet`]:serializeRgb(quiet),[`${prefix}-fill-normal`]:serializeRgb(normal),[`${prefix}-fill-loud`]:serializeRgb(loud),[`${prefix}-border-quiet`]:serializeRgb(borderQuiet),[`${prefix}-border-normal`]:serializeRgb(borderNormal),[`${prefix}-border-loud`]:serializeRgb(borderLoud),[`${prefix}-on-quiet`]:serializeRgb(contrastForeground(quiet)),[`${prefix}-on-normal`]:serializeRgb(contrastForeground(normal)),[`${prefix}-on-loud`]:serializeRgb(contrastForeground(loud))};return role==="brand"&&(ramp["--lr-theme-color-focus"]=serializeRgb(ensureSurfaceContrast(resolved,background,3,background,references))),ramp}function paintAccent(accent,mode,background,owner=document){const properties=new Map;if(!accent)return{applied:null,properties};if(!mode)return{applied:accent,properties};if(typeof accent=="string"){const ramp=createRoleRamp("brand",accent,mode,background,owner);if(!ramp)return{applied:null,properties};properties.set("--lr-theme-accent",accent);for(const[property,value]of Object.entries(ramp))properties.set(property,value);return{applied:accent,properties}}const applied={};let appliedBrandColor=null;for(const role of SEMANTIC_ROLES){const value=accent[role];if(!value)continue;const isPerMode=typeof value!="string",base=resolveAccentValueForMode(value,mode);let painted=!1;if(base){const ramp=createRoleRamp(role,base,mode,background,owner);if(ramp){for(const[property,propertyValue]of Object.entries(ramp))properties.set(property,propertyValue);painted=!0,role==="brand"&&(appliedBrandColor=base)}}(painted||isPerMode)&&(applied[role]=value)}return appliedBrandColor&&properties.set("--lr-theme-accent",appliedBrandColor),{applied:Object.keys(applied).length>0?applied:null,properties}}function tokenEntries(tokens,mode){const entries=new Map;if(!tokens)return entries;for(const[name,value]of Object.entries(tokens))if(typeof value=="string")entries.set(name,value);else if(mode){const branch=value[mode];branch&&entries.set(name,branch)}return entries}function resolveTokenColor(value,background,owner){return value===void 0||!background||!normalizeColor(value,owner)?null:parseResolvedRgb(value,background,owner)}function floorTokenEntries(entries,mode,surface,owner=document){const resolveColor=(value,background)=>resolveTokenColor(value,background,owner),painted=new Map(entries),prefix="--lr-theme-",defaults=MODE_DEFAULTS[mode],raised=((name,fallback)=>entries.has(prefix+name)?resolveColor(entries.get(prefix+name),surface):fallback)("color-surface-raised",defaults.raised),floor=(name,over,against,minimum,alsoAgainst)=>{const value=painted.get(name);if(value===void 0||!against||alsoAgainst===null)return;const color=resolveColor(value,over);if(!color)return;const repaired=ensureSurfaceContrast(color,against,minimum,alsoAgainst??against);repaired!==color&&painted.set(name,serializeRgb(repaired))};floor(`${prefix}color-text-normal`,surface,surface,4.5,raised),floor(`${prefix}color-text-quiet`,surface,surface,4.5,raised);const text=entries.has(`${prefix}color-text-normal`)?resolveColor(painted.get(`${prefix}color-text-normal`),surface):defaults.text,synthesized=new Map,pairForeground=(onName,fill)=>{if(!fill)return;const on=painted.get(onName);if(on===void 0){synthesized.set(onName,serializeRgb(contrastForeground(fill)));return}const color=resolveColor(on,fill);color&&contrastRatio(color,fill)<4.5&&painted.set(onName,serializeRgb(contrastForeground(fill)))};for(const role of SEMANTIC_ROLES)for(const tier of RAMP_TIERS){const fillName=`${prefix}color-${role}-fill-${tier}`;entries.has(fillName)&&pairForeground(`${prefix}color-${role}-on-${tier}`,resolveColor(entries.get(fillName),surface))}const overlayName=`${prefix}color-overlay-strong`,overlay=entries.has(overlayName)?resolveColor(entries.get(overlayName),surface):mixRgb(surface,[0,0,0],defaults.overlayStrongAlpha);(entries.has(overlayName)||entries.has(`${prefix}color-on-strong-overlay`))&&pairForeground(`${prefix}color-on-strong-overlay`,overlay);const boundaries=[...SEMANTIC_ROLES.flatMap(role=>[`${prefix}color-${role}-border-normal`,`${prefix}color-${role}-border-loud`]),`${prefix}color-surface-border`,`${prefix}color-border-strong`,`${prefix}color-focus`];for(const name of boundaries)floor(name,surface,surface,3);for(const name of entries.keys())/^--lr-theme-color-chart-\d+$/.test(name)?floor(name,surface,surface,3):/^--lr-theme-terminal-color-[a-z0-9-]+$/.test(name)?floor(name,raised,raised,4.5):/^--lr-theme-terminal-bg-[a-z0-9-]+$/.test(name)&&floor(name,raised,text,4.5);for(const[name,value]of synthesized)painted.set(name,value);return painted}function readOwnershipList(){try{const list=document.documentElement[Symbol.for(TOKEN_OWNERSHIP_SYMBOL)];if(!Array.isArray(list))return[];const names=[],length=Math.min(list.length,TOKEN_OWNERSHIP_MAX);for(let index=0;index<length;index+=1){const name=list[index];isLyraThemeTokenName(name)&&names.push(name)}return names}catch{return[]}}function applyStoredThemeBeforePaint(A){try{const x=A.record,S=x.mode==="light"||x.mode==="dark"||x.mode==="unset"?x.mode:"auto";let a=null;S==="light"||S==="dark"?a=S:S==="auto"&&(a=matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light");const N=A.root,i=N.style,O=["brand","success","warning","danger","neutral"],rt=["fill","border","on"],W=["quiet","normal","loud"],B=[];for(const t of O)for(const e of rt)for(const o of W)B.push(`--lr-theme-color-${t}-${e}-${o}`);B.push("--lr-theme-color-focus");const nt=/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/,st=80,ct="--lr-theme-accent",_=512,lt=16,at=256,it=/[\x00-\x1f\x7f\\;{}!<>@[\]`$^|~=?&:\u2028\u2029]|\/\*|\*\//,G=/^(?:inherit|initial|revert(?:-layer)?|unset)$/i,ft=/([a-z0-9_-]+)\s*\(/gi,ut="rgb rgba hsl hsla hwb lab lch oklab oklch color color-mix light-dark calc min max clamp var cubic-bezier steps linear".split(" "),H=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),ht={light:{surface:[255,255,255],raised:[246,248,250],text:[26,26,26],overlayStrongAlpha:.92},dark:{surface:[26,26,26],raised:[34,39,46],text:[242,242,242],overlayStrongAlpha:.95}},J=t=>{let e=0,o="";for(const r of t){if(o){r===o&&(o="");continue}if(r==="'"||r==='"')o=r;else if(r==="(")e+=1;else if(r===")"&&(e-=1)<0)return!1}return o===""&&e===0},U=t=>typeof t=="string"&&t.length<=st&&nt.test(t)&&t!==ct,C=t=>{if(typeof t!="string")return null;const e=t.trim();if(!e||e.length>at||it.test(e)||G.test(e))return null;for(const o of e.matchAll(ft))if(!ut.includes((o[1]??"").toLowerCase()))return null;return J(e)?e:null},D=t=>{if(typeof t!="object"||t===null||Array.isArray(t))return!1;const e=Object.getPrototypeOf(t);return e===Object.prototype||e===null},E=[];try{const t=N[H];if(Array.isArray(t)){const e=Math.min(t.length,_+lt);for(let o=0;o<e;o+=1){const r=t[o];U(r)&&E.push(r)}}}catch{E.length=0}for(const t of[...B,"--lr-theme-accent",...E])i.removeProperty(t);const R={};try{const t=x.tokens,e=D(t)?Object.keys(t):[];if(D(t)&&e.length<=_)for(const o of e){if(!U(o))continue;const r=t[o];if(typeof r=="string"){const m=C(r);m!==null&&(R[o]=m);continue}if(!D(r))continue;const c=Object.prototype.hasOwnProperty.call(r,"light"),p=Object.prototype.hasOwnProperty.call(r,"dark");if(!c&&!p||Object.keys(r).some(m=>m!=="light"&&m!=="dark"))continue;const f=C(r.light),d=C(r.dark);(f!==null||d!==null)&&(R[o]={light:f,dark:d})}}catch{}if(A.normalizeOnly)return R;const u=new Map;for(const[t,e]of Object.entries(A.tokens??R)){const o=typeof e=="string"?e:a?e[a]:null;o&&u.set(t,o)}const dt=t=>G.test(t)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(t)||/\bcurrentcolor\b/i.test(t)||/\bvar\s*\(/i.test(t)||/\blight-dark\s*\(/i.test(t)||/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\s*\(\s*from\b/i.test(t),v=t=>{if(typeof t!="string")return null;const e=t.trim();if(!e||!J(e)||dt(e))return null;const o=document.createElement("span");return o.style.color=e,o.style.color?e:null},mt=t=>{if(typeof t=="string")return v(t);if(!t||typeof t!="object"||Array.isArray(t))return null;const e=t;return!a||!("light"in e)&&!("dark"in e)?null:v(e[a])},T={},z=x.accent;if(typeof z=="string"){const t=v(z);t&&(T.brand=t)}else if(z&&typeof z=="object"&&!Array.isArray(z))for(const t of O){const e=mt(z[t]);e&&(T[t]=e)}let b=null;if(a&&(u.size>0||Object.keys(T).length>0))try{const t=document.createElement("canvas");t.width=1,t.height=1,b=t.getContext("2d",{willReadFrequently:!0})}catch{b=null}const V=(t,e)=>{if(!b)return null;try{b.clearRect(0,0,1,1),b.fillStyle=t,b.fillRect(0,0,1,1);const o=[...b.getImageData(0,0,1,1).data],r=(o[3]??0)/255;return[0,1,2].map(c=>Math.round((o[c]??0)*r+(e[c]??0)*(1-r)))}catch{return null}},P=(t,e,o)=>t.map((r,c)=>Math.round(r*(1-o)+(e[c]??0)*o)),X=t=>{const e=t.map(o=>{const r=o/255;return r<=.04045?r/12.92:((r+.055)/1.055)**2.4});return(e[0]??0)*.2126+(e[1]??0)*.7152+(e[2]??0)*.0722},k=(t,e)=>{const o=X(t),r=X(e);return(Math.max(o,r)+.05)/(Math.min(o,r)+.05)},M=[0,0,0],j=[255,255,255],w=t=>k(t,M)>=k(t,j)?M:j,q=(t,e,o=3,r=e)=>{const c=f=>k(f,e)>=o&&k(f,r)>=o&&(A.references??[]).every(d=>k(f,d)>=o);if(c(t))return t;const p=k(e,M)>=k(e,j)?M:j;for(let f=1;f<=10;f+=1){const d=P(t,p,f/10);if(c(d))return d}return p},h=t=>`rgb(${t.join(" ")})`,F=ht[a??"light"],Y=F.surface,Z=v(x.surface)??v(u.get("--lr-theme-color-surface-default")),s=Z&&V(Z,Y)||Y,$=new Map(u);if(a){const t="--lr-theme-",e=(n,l)=>n!==void 0&&l&&v(n)?V(n,l):null,r=((n,l)=>u.has(t+n)?e(u.get(t+n),s):l)("color-surface-raised",F.raised),c=(n,l,g,L,tt)=>{const et=$.get(n);if(et===void 0||!g||tt===null)return;const Q=e(et,l);if(!Q)return;const ot=q(Q,g,L,tt??g);ot!==Q&&$.set(n,h(ot))};c(`${t}color-text-normal`,s,s,4.5,r),c(`${t}color-text-quiet`,s,s,4.5,r);const p=u.has(`${t}color-text-normal`)?e($.get(`${t}color-text-normal`),s):F.text,f=new Map,d=(n,l)=>{if(!l)return;const g=$.get(n);if(g===void 0){f.set(n,h(w(l)));return}const L=e(g,l);L&&k(L,l)<4.5&&$.set(n,h(w(l)))};for(const n of O)for(const l of W){const g=`${t}color-${n}-fill-${l}`;u.has(g)&&d(`${t}color-${n}-on-${l}`,e(u.get(g),s))}const m=`${t}color-overlay-strong`,K=u.has(m)?e(u.get(m),s):P(s,M,F.overlayStrongAlpha);(u.has(m)||u.has(`${t}color-on-strong-overlay`))&&d(`${t}color-on-strong-overlay`,K);const y=[...O.flatMap(n=>[`${t}color-${n}-border-normal`,`${t}color-${n}-border-loud`]),`${t}color-surface-border`,`${t}color-border-strong`,`${t}color-focus`];for(const n of y)c(n,s,s,3);for(const n of u.keys())/^--lr-theme-color-chart-\d+$/.test(n)?c(n,s,s,3):/^--lr-theme-terminal-color-[a-z0-9-]+$/.test(n)?c(n,r,r,4.5):/^--lr-theme-terminal-bg-[a-z0-9-]+$/.test(n)&&c(n,r,p,4.5);for(const[n,l]of f)$.set(n,l)}try{N[H]=Object.freeze([...$.keys()])}catch{}for(const[t,e]of $)i.setProperty(t,e);if(!a||!b){i.removeProperty("--lr-theme-accent");return}let I=null;for(const t of O){const e=T[t];if(!e)continue;const o=V(e,s);if(!o)continue;const r=P(s,o,a==="dark"?.24:.14),c=P(s,o,a==="dark"?.62:.55),p=q(o,s,4.5,r),f=a==="dark"?j:M,d=P(s,o,a==="dark"?.46:.38),m=q(P(s,o,a==="dark"?.78:.72),s),K=q(P(p,f,.2),s),y=`--lr-theme-color-${t}`;i.setProperty(`${y}-fill-quiet`,h(r)),i.setProperty(`${y}-fill-normal`,h(c)),i.setProperty(`${y}-fill-loud`,h(p)),i.setProperty(`${y}-border-quiet`,h(d)),i.setProperty(`${y}-border-normal`,h(m)),i.setProperty(`${y}-border-loud`,h(K)),i.setProperty(`${y}-on-quiet`,h(w(r))),i.setProperty(`${y}-on-normal`,h(w(c))),i.setProperty(`${y}-on-loud`,h(w(p))),t==="brand"&&(i.setProperty("--lr-theme-color-focus",h(q(o,s))),I=e)}I?i.setProperty("--lr-theme-accent",I):i.removeProperty("--lr-theme-accent")}catch{}}function applyStoredStyleBeforePaint(U,W,T,L,q,z){const{surfaces:N,contrastSurfaces:G,gemstones:j}=z,S=[],R=[],E=[],P=[];for(const s of z.inputs.split(" ")){const n=Number(s[0]),c=`--lr-theme-${s.slice(1)}`;S.push(c),n&1&&R.push(c),n&2&&E.push(c),n&4&&P.push(c)}function g(s,n,c=!1){return`--_lr-${c?"a":"l"}${n==="light"?"l":"d"}-${s.slice(11)}`}function M(s,n){let c=`var(${g(s,n)})`;if(E.includes(s)){const u=n==="light"?"l":"d",b=s.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");c=`var(--_lr-f${u}-${s.slice(11)},${c})var(--_lr-o${u}-${s.slice(11)},var(${g(b,n,!0)},var(${g(b,n)})))`}return P.includes(s)?`var(${g(s,n,!0)},${c})`:c}function J(s){const n=`var(--_lr-dark-on,${M(s,"light")})var(--_lr-light-on,${M(s,"dark")})`;if(!R.includes(s))return n;const c=s.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${n})var(--_lr-dense-off,max(calc((${n}) * var(--_lr-density-${c?"space":"control"},1)),${c?"0px":"var(--_lr-density-target-min,0px)"}))`}try{const s=document.currentScript,n=s?.getAttribute("data-lr-theme-storage-key"),c=n&&n.length<=200?n:U,u=s?.getAttribute("data-lr-theme-attributes")?.trim().split(/\s+/),b=u?.length&&u.length<=8&&new Set(u).size===u.length&&u.every(e=>e.length<=64&&/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e))?u:W;let t={};const H=localStorage.getItem(c);try{const e=JSON.parse(H??"null");e&&typeof e=="object"&&!Array.isArray(e)&&(t=e)}catch{}t.version!==void 0&&t.version!==2&&(t={});const h=t.mode==="light"||t.mode==="dark"||t.mode==="unset"?t.mode:"system",v=h==="unset"?null:h==="system"?matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":h,o=document.documentElement,y={},Q=getComputedStyle(o).getPropertyValue("--_lr-style-resolver").trim()==="1",X=e=>typeof e=="string"&&e.length<=64&&/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e),V=e=>e&&typeof e=="object"&&!Array.isArray(e)?e:{},Y=e=>T({root:document.createElement("div"),record:{mode:"unset",tokens:e},normalizeOnly:!0})??{},I=Y(t.tokens),Z=Object.fromEntries(Object.entries(Y(t.overrides)).filter(([e,r])=>L(e,r,S))),m={...I,...Z},C=X(t.look)?t.look:Object.keys(I).length?"custom":"lyra";if(y["data-lr-look"]=C,y["data-lr-density"]=t.density==="compact"||t.density==="touch"?t.density:"comfortable",y["data-lr-surface"]=t.treatment==="glass"?"glass":"solid",h!=="unset"&&(y["data-lr-mode"]=h),v)for(const e of b)y[e]=v;const $=t.version===2&&typeof t.accentName=="string"&&Object.hasOwn(j,t.accentName)?t.accentName:null,_=$?j[$]:t.accent;y["data-lr-accent"]=$??(_?"custom":"none");const a=new Map;if(h==="unset")for(const[e,r]of Object.entries(m))typeof r=="string"&&a.set(e,r);for(const e of["light","dark"]){const r=typeof t.surface=="string"?t.surface:V(t.surface)[e],A=typeof m["--lr-theme-color-surface-default"]=="string"?m["--lr-theme-color-surface-default"]:V(m["--lr-theme-color-surface-default"])[e],f=r??A??N[C]?.[e];for(const p of[!1,!0]){if(p&&(!_||$))continue;const w=document.createElement("div");T({root:w,tokens:p?{}:m,references:p?G[e].map(i=>[1,3,5].map(d=>parseInt(i.slice(d,d+2),16))):[],record:{mode:e,surface:p&&$?N.lyra?.[e]:f,tokens:p?null:m,accent:p?_:null}});for(const i of w.style){const d=w.style.getPropertyValue(i);if(i==="--lr-theme-accent"){e===v&&a.set(i,d);continue}if(S.includes(i)&&L(i,d,S)){const K=i.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1],O=!p&&K&&d===`var(--lr-theme-color-brand-${K})`,B=i.slice(11),D=e==="light"?"l":"d";O||a.set(g(i,e,p),d),!p&&E.includes(i)&&(a.set(`--_lr-f${D}-${B}`,O?" ":"initial"),a.set(`--_lr-o${D}-${B}`,O?"initial":" ")),e===v&&a.set(i,Q?J(i):d)}else e===v&&a.set(i,d)}}}a.size&&(y["data-lr-theme-scope"]="");const F=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),k=o;let x;try{x=q(k[F])}catch{}const l=x??{attributes:new Map,properties:new Map};if(h==="unset")for(const e of b)l.attributes.has(e)||o.removeAttribute(e);try{const e=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),r=k[e];if(Array.isArray(r)){const A=r.slice(0,528).filter(f=>typeof f=="string"&&f.length<=80&&/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(f));for(const f of[...A,...P,"--lr-theme-accent"])!l.properties.has(f)&&o.style.getPropertyValue(f)&&l.properties.set(f,{before:null,priority:"",written:o.style.getPropertyValue(f)});try{delete k[e]}catch{}}}catch{}for(const[e,r]of l.attributes)Object.hasOwn(y,e)||(o.getAttribute(e)===r.written&&(r.before===null?o.removeAttribute(e):o.setAttribute(e,r.before)),l.attributes.delete(e));for(const[e,r]of Object.entries(y))l.attributes.has(e)||l.attributes.set(e,{before:o.getAttribute(e),priority:"",written:r}),o.setAttribute(e,r),l.attributes.get(e).written=r;for(const[e,r]of l.properties)a.has(e)||(o.style.getPropertyValue(e)===r.written&&!o.style.getPropertyPriority(e)&&(r.before?o.style.setProperty(e,r.before,r.priority):o.style.removeProperty(e)),l.properties.delete(e));for(const[e,r]of a)l.properties.has(e)||l.properties.set(e,{before:o.style.getPropertyValue(e),priority:o.style.getPropertyPriority(e),written:null}),o.style.getPropertyPriority(e)&&o.style.removeProperty(e),o.style.setProperty(e,r,""),l.properties.get(e).written=o.style.getPropertyValue(e);try{k[F]=l}catch{}}catch{}}const LINE_SEPARATOR="\u2028",PARAGRAPH_SEPARATOR="\u2029";function serializeInlineScriptData(value){return JSON.stringify(value).replace(/</g,"\\u003c").replace(new RegExp(LINE_SEPARATOR,"g"),"\\u2028").replace(new RegExp(PARAGRAPH_SEPARATOR,"g"),"\\u2029")}function createLyraThemeBootstrap(options={}){const storageKey=options.storageKey??STORAGE_KEY,inputs=STYLE_SLOTTED.map(name=>`${Number(STYLE_DENSITY.includes(name))|Number(STYLE_FOLLOW.includes(name))<<1|Number(ALL_RAMP_PROPERTIES.includes(name))<<2}${name.slice(11)}`).join(" "),model=JSON.stringify({inputs,surfaces:STYLE_REFERENCE_SURFACES,contrastSurfaces:STYLE_CONTRAST_SURFACES,gemstones:STYLE_GEMSTONES});return`(${applyStoredStyleBeforePaint.toString()})(${serializeInlineScriptData(storageKey)},${serializeInlineScriptData(MODE_ATTRIBUTES)},${applyStoredThemeBeforePaint.toString()},${styleTokenAllowed.toString()},${readStyleOwnership.toString()},${model});`}const STYLE_SLOTTED=["--lr-theme-color-border-strong","--lr-theme-color-brand-border-loud","--lr-theme-color-brand-border-normal","--lr-theme-color-brand-border-quiet","--lr-theme-color-brand-fill-loud","--lr-theme-color-brand-fill-normal","--lr-theme-color-brand-fill-quiet","--lr-theme-color-brand-on-loud","--lr-theme-color-brand-on-normal","--lr-theme-color-brand-on-quiet","--lr-theme-color-chart-1","--lr-theme-color-chart-2","--lr-theme-color-chart-3","--lr-theme-color-chart-4","--lr-theme-color-chart-5","--lr-theme-color-chart-6","--lr-theme-color-chart-7","--lr-theme-color-chart-8","--lr-theme-color-chart-diverging-1","--lr-theme-color-chart-diverging-2","--lr-theme-color-chart-diverging-3","--lr-theme-color-chart-sequential-1","--lr-theme-color-chart-sequential-2","--lr-theme-color-chart-sequential-3","--lr-theme-color-danger-border-loud","--lr-theme-color-danger-border-normal","--lr-theme-color-danger-border-quiet","--lr-theme-color-danger-fill-loud","--lr-theme-color-danger-fill-normal","--lr-theme-color-danger-fill-quiet","--lr-theme-color-danger-on-loud","--lr-theme-color-danger-on-normal","--lr-theme-color-danger-on-quiet","--lr-theme-color-focus","--lr-theme-color-mix-partner","--lr-theme-color-neutral-border-loud","--lr-theme-color-neutral-border-normal","--lr-theme-color-neutral-border-quiet","--lr-theme-color-neutral-fill-loud","--lr-theme-color-neutral-fill-normal","--lr-theme-color-neutral-fill-quiet","--lr-theme-color-neutral-on-loud","--lr-theme-color-neutral-on-normal","--lr-theme-color-neutral-on-quiet","--lr-theme-color-no-data","--lr-theme-color-on-strong-overlay","--lr-theme-color-overlay","--lr-theme-color-overlay-strong","--lr-theme-color-success-border-loud","--lr-theme-color-success-border-normal","--lr-theme-color-success-border-quiet","--lr-theme-color-success-fill-loud","--lr-theme-color-success-fill-normal","--lr-theme-color-success-fill-quiet","--lr-theme-color-success-on-loud","--lr-theme-color-success-on-normal","--lr-theme-color-success-on-quiet","--lr-theme-color-surface-border","--lr-theme-color-surface-border-subtle","--lr-theme-color-surface-container","--lr-theme-color-surface-container-high","--lr-theme-color-surface-container-highest","--lr-theme-color-surface-container-low","--lr-theme-color-surface-container-lowest","--lr-theme-color-surface-default","--lr-theme-color-surface-overlay","--lr-theme-color-surface-raised","--lr-theme-color-text-normal","--lr-theme-color-text-quiet","--lr-theme-color-warning-border-loud","--lr-theme-color-warning-border-normal","--lr-theme-color-warning-border-quiet","--lr-theme-color-warning-fill-loud","--lr-theme-color-warning-fill-normal","--lr-theme-color-warning-fill-quiet","--lr-theme-color-warning-on-loud","--lr-theme-color-warning-on-normal","--lr-theme-color-warning-on-quiet","--lr-theme-form-control-height-2xs","--lr-theme-form-control-height-l","--lr-theme-form-control-height-m","--lr-theme-form-control-height-s","--lr-theme-form-control-height-xl","--lr-theme-form-control-height-xs","--lr-theme-graph-cat-1","--lr-theme-graph-cat-2","--lr-theme-graph-cat-3","--lr-theme-graph-cat-4","--lr-theme-graph-cat-5","--lr-theme-graph-cat-6","--lr-theme-graph-cat-7","--lr-theme-graph-cat-8","--lr-theme-icon-button-size","--lr-theme-shadow-l","--lr-theme-shadow-m","--lr-theme-shadow-s","--lr-theme-shadow-xl","--lr-theme-shadow-xs","--lr-theme-space-2xl","--lr-theme-space-2xs","--lr-theme-space-l","--lr-theme-space-m","--lr-theme-space-s","--lr-theme-space-xs","--lr-theme-terminal-bg-black","--lr-theme-terminal-bg-blue","--lr-theme-terminal-bg-bright-black","--lr-theme-terminal-bg-bright-blue","--lr-theme-terminal-bg-bright-cyan","--lr-theme-terminal-bg-bright-green","--lr-theme-terminal-bg-bright-magenta","--lr-theme-terminal-bg-bright-red","--lr-theme-terminal-bg-bright-white","--lr-theme-terminal-bg-bright-yellow","--lr-theme-terminal-bg-cyan","--lr-theme-terminal-bg-green","--lr-theme-terminal-bg-magenta","--lr-theme-terminal-bg-red","--lr-theme-terminal-bg-white","--lr-theme-terminal-bg-yellow","--lr-theme-terminal-color-black","--lr-theme-terminal-color-blue","--lr-theme-terminal-color-bright-black","--lr-theme-terminal-color-bright-blue","--lr-theme-terminal-color-bright-cyan","--lr-theme-terminal-color-bright-green","--lr-theme-terminal-color-bright-magenta","--lr-theme-terminal-color-bright-red","--lr-theme-terminal-color-bright-white","--lr-theme-terminal-color-bright-yellow","--lr-theme-terminal-color-cyan","--lr-theme-terminal-color-green","--lr-theme-terminal-color-magenta","--lr-theme-terminal-color-red","--lr-theme-terminal-color-white","--lr-theme-terminal-color-yellow"],STYLE_DENSITY=["--lr-theme-space-2xs","--lr-theme-space-xs","--lr-theme-space-s","--lr-theme-space-m","--lr-theme-space-l","--lr-theme-space-2xl","--lr-theme-form-control-height-2xs","--lr-theme-form-control-height-xs","--lr-theme-form-control-height-s","--lr-theme-form-control-height-m","--lr-theme-form-control-height-l","--lr-theme-form-control-height-xl","--lr-theme-icon-button-size"],STYLE_FOLLOW=["--lr-theme-color-danger-border-loud","--lr-theme-color-danger-border-normal","--lr-theme-color-danger-border-quiet","--lr-theme-color-danger-fill-loud","--lr-theme-color-danger-fill-normal","--lr-theme-color-danger-fill-quiet","--lr-theme-color-danger-on-loud","--lr-theme-color-danger-on-normal","--lr-theme-color-danger-on-quiet","--lr-theme-color-neutral-border-loud","--lr-theme-color-neutral-border-normal","--lr-theme-color-neutral-border-quiet","--lr-theme-color-neutral-fill-loud","--lr-theme-color-neutral-fill-normal","--lr-theme-color-neutral-fill-quiet","--lr-theme-color-neutral-on-loud","--lr-theme-color-neutral-on-normal","--lr-theme-color-neutral-on-quiet","--lr-theme-color-success-border-loud","--lr-theme-color-success-border-normal","--lr-theme-color-success-border-quiet","--lr-theme-color-success-fill-loud","--lr-theme-color-success-fill-normal","--lr-theme-color-success-fill-quiet","--lr-theme-color-success-on-loud","--lr-theme-color-success-on-normal","--lr-theme-color-success-on-quiet","--lr-theme-color-warning-border-loud","--lr-theme-color-warning-border-normal","--lr-theme-color-warning-border-quiet","--lr-theme-color-warning-fill-loud","--lr-theme-color-warning-fill-normal","--lr-theme-color-warning-fill-quiet","--lr-theme-color-warning-on-loud","--lr-theme-color-warning-on-normal","--lr-theme-color-warning-on-quiet"],STYLE_REFERENCE_SURFACES={lyra:{light:"#ffffff",dark:"#1a1a1a"},data:{light:"#ffffff",dark:"#101820"},"high-contrast":{light:"#ffffff",dark:"#000000"},material:{light:"#fff8f5",dark:"#18120f"},shadcn:{light:"#ffffff",dark:"#0a0a0a"},terminal:{light:"#fcfdf9",dark:"#0e1713"}},STYLE_CONTRAST_SURFACES={light:["#ffffff","#f6f8fa","#f2f5f8","#fff8f5","#f8eeea","#fcf2ed","#f2e7e0","#ecdfd7","#fafafa","#fcfdf9","#f1f5eb"],dark:["#1a1a1a","#22272e","#2b3038","#101820","#192630","#202e39","#000000","#18120f","#251d19","#302621","#120d0a","#211914","#3a2f29","#0a0a0a","#171717","#0e1713","#18271e","#203227"]},STYLE_GEMSTONES={emerald:"#34d399",peridot:"#a8d84a",topaz:"#f0a83c",ruby:"#e63950",tourmaline:"#ec4899",amethyst:"#9d6df0",aquamarine:"#22d3ee",sapphire:"#4f8ff7",hematite:"#94a3b8"},LOOK_ID=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,LOOK_STAMP=Symbol.for("@aceshooting/lyra-ui.look.v1"),STYLE_OWNERSHIP=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),STYLE_FIELDS=["look","surface","density","mode","accent","accentBackground","overrides"],DEFAULT_STYLE=Object.freeze({look:"lyra",tokens:null,surface:"solid",density:"comfortable",mode:"system",accent:null,accentName:null,accentBackground:null,overrides:null});let lastStyle={...DEFAULT_STYLE},stylePersistenceFailed=!1,styleModeCleanup,styleModeRoot;const styleOwnershipFallback=new WeakMap,scopeModes=new WeakMap;function ownField(value,key){const descriptor=Object.getOwnPropertyDescriptor(value,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}function styleId(value){return typeof value=="string"&&value.length<=64&&LOOK_ID.test(value)}function styleTokenAllowed(e,r,o=STYLE_SLOTTED){if(e.startsWith("--lr-theme-surface-")||typeof r!="string"&&!o.includes(e))return!1;for(const t of typeof r=="string"?[r]:[r.light,r.dark])if(t)for(const c of t.matchAll(/var\(\s*(--[\w-]+)/g)){if(c[1]==="--lr-theme-shadow-color")continue;const n=e.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1];if(!n||t!==`var(--lr-theme-color-brand-${n})`)return!1}return!0}function styleTokens(value){const tokens=normalizeTokens(value);if(!tokens)return null;const entries=Object.entries(tokens).filter(([name,input])=>styleTokenAllowed(name,input));return entries.length?Object.freeze(Object.fromEntries(entries)):null}function defineLyraLook(look){if(!look||!styleId(ownField(look,"id"))||look.id==="custom")throw new TypeError("Invalid look id");const raw=ownField(look,"tokens");if(!isPlainRecord(raw)||Object.keys(raw).length>TOKEN_ENTRY_MAX)throw new TypeError("Invalid look tokens");for(const[name,descriptor]of Object.entries(Object.getOwnPropertyDescriptors(raw))){if(!("value"in descriptor))throw new TypeError(`Look inputs must be data properties: ${name}`);const value=descriptor.value;if(typeof value=="string"){if(!isSafeLyraThemeTokenValue(value))throw new TypeError(`Invalid look value: ${name}`);continue}if(!isPlainRecord(value)||!STYLE_SLOTTED.includes(name))throw new TypeError(`Invalid per-mode look input: ${name}`);const branches=Object.entries(Object.getOwnPropertyDescriptors(value));if(!branches.length||branches.some(([key,branch])=>!["light","dark"].includes(key)||!("value"in branch)||branch.value!==null&&!isSafeLyraThemeTokenValue(branch.value)))throw new TypeError(`Invalid look mode pair: ${name}`)}const tokens=styleTokens(raw);if(Object.keys(raw).length!==Object.keys(tokens??{}).length)throw new TypeError("Invalid look token or cross-axis reference");const stamped={...tokens,[LOOK_STAMP]:look.id};return Object.freeze(stamped),Object.freeze({id:look.id,tokens:stamped})}function styleColor(value){if(!isSafeLyraThemeTokenValue(value))return null;const text=value.trim();return/\b(?:var|light-dark)\s*\(|\b(?:currentcolor|from)\b/i.test(text)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(text)?null:/^(?:#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})|[a-z]+|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\(.+\))$/i.test(text)?text:null}function styleColorPair(value){if(typeof value=="string")return styleColor(value);if(!isPlainRecord(value))return null;const light=styleColor(ownField(value,"light")),dark=styleColor(ownField(value,"dark"));return light||dark?Object.freeze({light,dark}):null}function styleAccent(value){if(typeof value=="string")return styleColor(value);if(!isPlainRecord(value))return null;const entries=SEMANTIC_ROLES.filter(role=>Object.hasOwn(value,role)).map(role=>[role,styleColorPair(ownField(value,role))]);return entries.length?Object.freeze(Object.fromEntries(entries)):null}function normalizeStyleChoices(raw,base){const next={...base};if(!isPlainRecord(raw))return next;const look=ownField(raw,"look");if(look!==void 0){if(next.look="lyra",next.tokens=null,styleId(look))next.look=look;else if(isPlainRecord(look))try{const definition=defineLyraLook(look);next.look=definition.id,next.tokens=definition.tokens}catch{}}const surface=ownField(raw,"surface");surface!==void 0&&(next.surface=surface==="glass"?"glass":"solid");const density=ownField(raw,"density");density!==void 0&&(next.density=density==="compact"||density==="touch"?density:"comfortable");const mode=ownField(raw,"mode");mode!==void 0&&(next.mode=mode==="light"||mode==="dark"||mode==="unset"?mode:"system");const accent=ownField(raw,"accent");accent!==void 0&&(next.accentName=typeof accent=="string"&&Object.hasOwn(STYLE_GEMSTONES,accent)?accent:null,next.accent=next.accentName?STYLE_GEMSTONES[next.accentName]:styleAccent(accent));const background=ownField(raw,"accentBackground");background!==void 0&&(next.accentBackground=styleColorPair(background));const overrides=ownField(raw,"overrides");return overrides!==void 0&&(next.overrides=styleTokens(overrides)),next}function styleFromRecord(value){if(!isPlainRecord(value))return{...DEFAULT_STYLE};const version=ownField(value,"version");if(version!==void 0&&version!==2)return{...DEFAULT_STYLE};const state=normalizeStyleChoices({look:ownField(value,"look"),mode:ownField(value,"mode"),density:ownField(value,"density"),surface:ownField(value,"treatment"),overrides:ownField(value,"overrides"),accentBackground:ownField(value,"surface")},{...DEFAULT_STYLE});state.accent=styleAccent(ownField(value,"accent"));const accentName=ownField(value,"accentName");return version===2&&typeof accentName=="string"&&Object.hasOwn(STYLE_GEMSTONES,accentName)&&(state.accentName=accentName,state.accent=STYLE_GEMSTONES[accentName]),state.tokens=normalizeTokens(ownField(value,"tokens")),state.tokens&&!styleId(ownField(value,"look"))&&(state.look="custom"),state}function styleRecord(state){return{version:2,mode:state.mode,look:state.look,density:state.density,treatment:state.surface,accent:state.accent,surface:state.accentBackground,...state.accentName?{accentName:state.accentName}:{},...state.tokens?{tokens:state.tokens}:{},...state.overrides?{overrides:state.overrides}:{}}}function styleResolvedMode(mode,view){return mode==="unset"?null:mode!=="system"?mode:view?.matchMedia?.(COLOR_SCHEME_QUERY).matches?"dark":"light"}function styleSnapshot(state,view){return Object.freeze({look:state.look,lookForm:state.tokens?"runtime":"stylesheet",surface:state.surface,density:state.density,mode:state.mode,accent:state.accentName??state.accent,accentName:state.accentName,accentBackground:state.accentBackground,...state.overrides?{overrides:state.overrides}:{},resolvedMode:styleResolvedMode(state.mode,view)})}function parseLyraStyleRecord(value){const state=styleFromRecord(value),result=styleSnapshot(state);return state.mode==="system"?Object.freeze({...result,resolvedMode:null}):result}function lyraStyleAttributes(style){const attributes={};return styleId(style.look)&&(attributes["data-lr-look"]=style.look),(style.surface==="solid"||style.surface==="glass")&&(attributes["data-lr-surface"]=style.surface),(style.density==="compact"||style.density==="comfortable"||style.density==="touch")&&(attributes["data-lr-density"]=style.density),(style.mode==="light"||style.mode==="dark"||style.mode==="system")&&(attributes["data-lr-mode"]=style.mode),style.accent!==void 0&&(attributes["data-lr-accent"]=style.accent===null?"none":style.accentName===null?"custom":typeof style.accent=="string"&&Object.hasOwn(STYLE_GEMSTONES,style.accent)?style.accent:"custom"),Object.freeze(attributes)}function readStyleState(){if(stylePersistenceFailed)return{...lastStyle};let stored;try{stored=localStorage.getItem(STORAGE_KEY)}catch{return{...lastStyle}}try{return styleFromRecord(JSON.parse(stored??"null"))}catch{return{...DEFAULT_STYLE}}}function persistStyle(state){try{localStorage.setItem(STORAGE_KEY,JSON.stringify(styleRecord(state))),stylePersistenceFailed=!1}catch{stylePersistenceFailed=!0}lastStyle=state}function ownershipFor(element){const node=element;try{const existing=readStyleOwnership(node[STYLE_OWNERSHIP]);if(existing){styleOwnershipFallback.set(element,existing);try{node[STYLE_OWNERSHIP]=existing}catch{}return existing}}catch{}const fallback=styleOwnershipFallback.get(element);if(fallback)return fallback;const record={attributes:new Map,properties:new Map};styleOwnershipFallback.set(element,record);try{node[STYLE_OWNERSHIP]=record}catch{}return record}function writeStyleAttributes(element,desired){const ownership=ownershipFor(element).attributes;for(const[name,value]of ownership)Object.hasOwn(desired,name)||(element.getAttribute(name)===value.written&&(value.before===null?element.removeAttribute(name):element.setAttribute(name,value.before)),ownership.delete(name));for(const[name,value]of Object.entries(desired))ownership.has(name)||ownership.set(name,{before:element.getAttribute(name),priority:"",written:value}),element.getAttribute(name)!==value&&element.setAttribute(name,value),ownership.get(name).written=value}function writeStyleProperties(element,desired){const style=element.style;if(!style)return;const ownership=ownershipFor(element).properties;for(const[name,value]of ownership)desired.has(name)||(style.getPropertyValue(name)===value.written&&style.getPropertyPriority(name)===""&&(value.before?style.setProperty(name,value.before,value.priority):style.removeProperty(name)),ownership.delete(name));for(const[name,value]of desired){ownership.has(name)||ownership.set(name,{before:style.getPropertyValue(name),priority:style.getPropertyPriority(name),written:null});const record=ownership.get(name);(style.getPropertyPriority(name)!==""||style.getPropertyValue(name)!==value&&!(record.requested===value&&record.written===style.getPropertyValue(name)))&&(style.getPropertyPriority(name)&&style.removeProperty(name),style.setProperty(name,value,"")),record.requested=value,record.written=style.getPropertyValue(name)}}function styleSlot(name,mode,accent=!1){return`--_lr-${accent?"a":"l"}${mode==="light"?"l":"d"}-${name.slice(11)}`}function styleFollow(name,value){const channel=name.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1];return!!(channel&&value===`var(--lr-theme-color-brand-${channel})`)}function styleBranch(name,mode){let result=`var(${styleSlot(name,mode)})`;if(STYLE_FOLLOW.includes(name)){const key=mode==="light"?"l":"d",target=name.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");result=`var(--_lr-f${key}-${name.slice(11)},${result})var(--_lr-o${key}-${name.slice(11)},var(${styleSlot(target,mode,!0)},var(${styleSlot(target,mode)})))`}return ALL_RAMP_PROPERTIES.includes(name)?`var(${styleSlot(name,mode,!0)},${result})`:result}function styleResolvedInput(name){const input=`var(--_lr-dark-on,${styleBranch(name,"light")})var(--_lr-light-on,${styleBranch(name,"dark")})`;if(!STYLE_DENSITY.includes(name))return input;const spacing=name.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${input})var(--_lr-dense-off,max(calc((${input}) * var(--_lr-density-${spacing?"space":"control"},1)),${spacing?"0px":"var(--_lr-density-target-min,0px)"}))`}function styleBackground(state,entries,mode,element){const explicit=typeof state.accentBackground=="string"?state.accentBackground:state.accentBackground?.[mode],ownLook=element.getAttribute("data-lr-look");let reference=explicit??entries.get("--lr-theme-color-surface-default")??(ownLook?(STYLE_REFERENCE_SURFACES[ownLook]??STYLE_REFERENCE_SURFACES.lyra)?.[mode]:void 0);if(!reference){const slot=styleSlot("--lr-theme-color-surface-default",mode),style=element.style,owned=ownershipFor(element).properties.get(slot),suspend=owned&&style?.getPropertyValue(slot)===owned.written&&!style.getPropertyPriority(slot);try{suspend&&(owned.before?style.setProperty(slot,owned.before,owned.priority):style.removeProperty(slot)),reference=element.ownerDocument.defaultView?.getComputedStyle(element).getPropertyValue(slot).trim()}finally{suspend&&owned.written!==null&&style.setProperty(slot,owned.written)}}return reference}const stylePaintCache=new WeakMap;function stylePaint(state,element,wholeDocument){const desired=new Map,mode=styleResolvedMode(state.mode,element.ownerDocument.defaultView),tokens={...state.tokens,...state.overrides};if(wholeDocument&&mode===null)for(const[name,value]of tokenEntries(tokens,null))desired.set(name,value);if(!Object.keys(tokens).length&&(!state.accent||state.accentName))return stylePaintCache.delete(element),desired;const resolver=element.ownerDocument.defaultView?.getComputedStyle(element).getPropertyValue("--_lr-style-resolver").trim()==="1";let cache=stylePaintCache.get(element);cache||(cache=new Map,stylePaintCache.set(element,cache));let applied=state.accent;for(const branch of["light","dark"]){const entries=tokenEntries(tokens,branch),reference=styleBackground(state,entries,branch,element),key=JSON.stringify([tokens,state.accent,state.accentName,reference]);let cached=cache.get(branch);if(!cached||cached.key!==key){const background=reference?parseResolvedRgb(reference,MODE_DEFAULTS[branch].surface,element.ownerDocument)??MODE_DEFAULTS[branch].surface:MODE_DEFAULTS[branch].surface,accent=state.accentName?{applied:state.accent,properties:new Map}:paintAccent(state.accent,branch,background,element.ownerDocument);cached={key,tokens:floorTokenEntries(entries,branch,background,element.ownerDocument),accent:accent.properties,applied:accent.applied},cache.set(branch,cached)}branch===mode&&(applied=cached.applied);const painted=cached.tokens;for(const[name,value]of painted)STYLE_SLOTTED.includes(name)&&styleTokenAllowed(name,value)?(styleFollow(name,value)?(desired.set(`--_lr-f${branch==="light"?"l":"d"}-${name.slice(11)}`," "),desired.set(`--_lr-o${branch==="light"?"l":"d"}-${name.slice(11)}`,"initial")):(desired.set(styleSlot(name,branch),value),STYLE_FOLLOW.includes(name)&&(desired.set(`--_lr-f${branch==="light"?"l":"d"}-${name.slice(11)}`,"initial"),desired.set(`--_lr-o${branch==="light"?"l":"d"}-${name.slice(11)}`," "))),wholeDocument&&branch===mode&&desired.set(name,resolver?styleResolvedInput(name):value)):(wholeDocument?branch===mode:typeof tokens[name]=="string"&&!STYLE_SLOTTED.includes(name))&&desired.set(name,value);if(state.accent&&!state.accentName)for(const[name,value]of cached.accent){if(name==="--lr-theme-accent"){branch===mode&&desired.set(name,value);continue}desired.set(styleSlot(name,branch,!0),value),wholeDocument&&branch===mode&&desired.set(name,resolver?styleResolvedInput(name):value)}}return state.accent=applied,desired}const styleModeGroups=new WeakMap;function attachStyleMode(element,callback){const view=element.ownerDocument.defaultView;if(!view?.matchMedia)return()=>{};let group=styleModeGroups.get(view);if(!group){const query=view.matchMedia(COLOR_SCHEME_QUERY),subscriptions=new Set,modern=typeof query.addEventListener=="function"&&typeof query.removeEventListener=="function",detach=()=>{modern?query.removeEventListener("change",listener):query.removeListener?.(listener)},listener=()=>{for(const subscription2 of subscriptions){const node=subscription2.element.deref();node?.ownerDocument.defaultView===view?subscription2.callback(node):subscriptions.delete(subscription2)}subscriptions.size||(detach(),styleModeGroups.delete(view))};group={query,subscriptions,detach},styleModeGroups.set(view,group),modern?query.addEventListener("change",listener):query.addListener?.(listener)}const subscription={element:new WeakRef(element),callback};group.subscriptions.add(subscription);const active=group;return()=>{active.subscriptions.delete(subscription),active.subscriptions.size||(active.detach(),styleModeGroups.delete(view))}}function applyStyleState(element,state,fields){const snapshot=styleSnapshot(state,element.ownerDocument.defaultView),attributes={...lyraStyleAttributes(snapshot)};if(fields)for(const[field,name]of[["look","look"],["surface","surface"],["density","density"],["mode","mode"],["accent","accent"]])fields.has(field)||delete attributes[`data-lr-${name}`];state.accent&&!state.accentName&&(!fields||fields.has("accent"))&&(attributes["data-lr-accent"]="custom"),(!fields||fields.has("mode"))&&snapshot.resolvedMode&&(attributes["data-lr-theme"]=snapshot.resolvedMode,attributes["data-theme"]=snapshot.resolvedMode),(state.tokens||state.overrides||state.accent&&!state.accentName)&&(attributes["data-lr-theme-scope"]=""),writeStyleAttributes(element,attributes);const desired=stylePaint(state,element,!fields);!state.accent&&snapshot.accent&&(attributes["data-lr-accent"]="none",!state.tokens&&!state.overrides&&delete attributes["data-lr-theme-scope"],writeStyleAttributes(element,attributes)),writeStyleProperties(element,desired),diagnoseStyleSheets(element,state,fields)}function diagnoseStyleSheets(element,state,fields){if(!litDevWarnings())return;const selected=field=>!fields||fields.has(field),required=[];selected("look")&&!state.tokens&&state.look!=="lyra"&&required.push(["--_lr-look-installed",`${state.look}-1`,`the stylesheet for look '${state.look}'`]),selected("surface")&&state.surface==="glass"&&required.push(["--_lr-surface-installed","1","surfaces/glass.css"]),selected("density")&&state.density!=="comfortable"&&required.push(["--_lr-density-installed","1","density.css"]),selected("accent")&&state.accentName&&required.push(["--_lr-accent-installed",`${state.accentName}-1`,"accents.css"]);const scopedRuntime=!!(fields&&(state.tokens||state.overrides||state.accent&&!state.accentName));if(!required.length&&!scopedRuntime)return;const computed=element.ownerDocument.defaultView?.getComputedStyle(element);if(computed){computed.getPropertyValue("--_lr-style-resolver").trim()!=="1"&&devWarnOnce("lyra-style:resolver","Lyra style choices require theme.css in the scope that owns their attributes.");for(const[property,expected,stylesheet]of required)computed.getPropertyValue(property).trim()!==expected&&devWarnOnce(`lyra-style:${property}:${expected}`,`Lyra could not find ${stylesheet} in this style scope; import or adopt the stylesheet before selecting it.`)}}function emitStyleChange(state,changed){const style=styleSnapshot(state,window);window.dispatchEvent(new CustomEvent("lr-style-change",{detail:Object.freeze({style,changed:Object.freeze([...changed])})}))}function setLyraStyle(choices){const before=readStyleState();return commitStyle(before,normalizeStyleChoices(choices,before))}function commitStyle(before,next){if(typeof document<"u"&&(next.accent=normalizeAccent(next.accent),typeof next.accentBackground=="string"&&(next.accentBackground=normalizeColor(next.accentBackground)),next.accent||(next.accentName=null)),persistStyle(next),typeof document<"u"){const root=document.documentElement;(next.mode!=="system"||styleModeRoot?.deref()!==root)&&(styleModeCleanup?.(),styleModeCleanup=void 0,styleModeRoot=void 0),adoptLegacyOwnership(root);const requestedAccent=next.accent;applyStyleState(root,next),accentsEqual(requestedAccent,next.accent)||persistStyle(next),next.mode==="system"&&!styleModeCleanup&&(styleModeRoot=new WeakRef(root),styleModeCleanup=attachStyleMode(root,element=>{applyStyleState(element,lastStyle),emitStyleChange(lastStyle,["resolvedMode"])}));const changed=STYLE_FIELDS.filter(field=>field==="look"?before.look!==next.look||!tokensEqual(before.tokens,next.tokens):field==="accent"?before.accentName!==next.accentName||!accentsEqual(before.accent,next.accent):JSON.stringify(before[field])!==JSON.stringify(next[field]));emitStyleChange(next,changed)}return styleSnapshot(next,typeof window>"u"?void 0:window)}function adoptLegacyOwnership(root){const symbol=Symbol.for(TOKEN_OWNERSHIP_SYMBOL),node=root;try{if(!Array.isArray(node[symbol]))return}catch{return}const ownership=ownershipFor(root).properties;for(const name of[...readOwnershipList(),...ALL_RAMP_PROPERTIES,"--lr-theme-accent"])ownership.has(name)||!root.style.getPropertyValue(name)||ownership.set(name,{before:null,priority:"",written:root.style.getPropertyValue(name)});try{delete node[symbol]}catch{}}function getLyraStyle(){return styleSnapshot(readStyleState(),typeof window>"u"?void 0:window)}function resetLyraStyle(fields=STYLE_FIELDS){return setLyraStyle(Object.fromEntries(fields.filter(field=>STYLE_FIELDS.includes(field)).map(field=>[field,null])))}function applyLyraStyleScope(element,choices){if(scopeModes.get(element)?.(),scopeModes.delete(element),choices===null){writeStyleAttributes(element,{}),writeStyleProperties(element,new Map);return}const state=normalizeStyleChoices(choices,{...DEFAULT_STYLE}),fields=new Set(STYLE_FIELDS.filter(field=>ownField(choices,field)!==void 0));applyStyleState(element,state,fields),choices.mode==="system"&&scopeModes.set(element,attachStyleMode(element,node=>applyStyleState(node,state,fields)))}const lyraThemeBootstrap=createLyraThemeBootstrap();export{accentsEqual,applyLyraStyleScope,createLyraThemeBootstrap,defineLyraLook,getLyraStyle,isLyraThemeTokenName,isSafeLyraThemeTokenValue,lyraStyleAttributes,lyraThemeBootstrap,parseLyraStyleRecord,resetLyraStyle,setLyraStyle,tokensEqual};
|
|
1
|
+
import{devWarnOnce,litDevWarnings}from"../internal/dev-warning.js";import{readStyleOwnership}from"./style-ownership.js";import{resolveStyleStartup}from"./startup-resolution.js";const STORAGE_KEY="lyra-theme",TOKEN_NAME_PATTERN=/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/,TOKEN_NAME_MAX_LENGTH=80,TOKEN_RESERVED_NAME="--lr-theme-accent",TOKEN_ENTRY_MAX=512,TOKEN_SYNTHESIZED_MAX=16,TOKEN_VALUE_MAX_LENGTH=256,TOKEN_FORBIDDEN_PATTERN=/[\x00-\x1f\x7f\\;{}!<>@[\]`$^|~=?&:\u2028\u2029]|\/\*|\*\//,TOKEN_CSS_WIDE_PATTERN=/^(?:inherit|initial|revert(?:-layer)?|unset)$/i,TOKEN_FUNCTION_PATTERN=/([a-z0-9_-]+)\s*\(/gi,TOKEN_ALLOWED_FUNCTIONS="rgb rgba hsl hsla hwb lab lch oklab oklch color color-mix light-dark calc min max clamp var cubic-bezier steps linear".split(" "),TOKEN_OWNERSHIP_MAX=TOKEN_ENTRY_MAX+TOKEN_SYNTHESIZED_MAX,TOKEN_OWNERSHIP_SYMBOL="@aceshooting/lyra-ui.theme-tokens.v1",MODE_SURFACES={light:[255,255,255],dark:[10,10,10]},COLOR_SCHEME_QUERY="(prefers-color-scheme: dark)",SEMANTIC_ROLES=["brand","success","warning","danger","neutral"],RAMP_CHANNELS=["fill","border","on"],RAMP_TIERS=["quiet","normal","loud"];function roleRampProperties(role){const properties=[];for(const channel of RAMP_CHANNELS)for(const tier of RAMP_TIERS)properties.push(`--lr-theme-color-${role}-${channel}-${tier}`);return properties}const ALL_RAMP_PROPERTIES=[...SEMANTIC_ROLES.flatMap(roleRampProperties),"--lr-theme-color-focus"],MODE_ATTRIBUTES=["data-lr-theme","data-theme"];function isBalancedCssValue(value){let depth=0,quote="";for(const character of value){if(quote){character===quote&&(quote="");continue}if(character==="'"||character==='"')quote=character;else if(character==="(")depth+=1;else if(character===")"&&(depth-=1)<0)return!1}return quote===""&&depth===0}function isLyraThemeTokenName(name){return typeof name=="string"&&name.length<=TOKEN_NAME_MAX_LENGTH&&TOKEN_NAME_PATTERN.test(name)&&name!==TOKEN_RESERVED_NAME}function isSafeLyraThemeTokenValue(value){if(typeof value!="string")return!1;const trimmed=value.trim();if(!trimmed||trimmed.length>TOKEN_VALUE_MAX_LENGTH||TOKEN_FORBIDDEN_PATTERN.test(trimmed)||TOKEN_CSS_WIDE_PATTERN.test(trimmed))return!1;for(const match of trimmed.matchAll(TOKEN_FUNCTION_PATTERN))if(!TOKEN_ALLOWED_FUNCTIONS.includes((match[1]??"").toLowerCase()))return!1;return isBalancedCssValue(trimmed)}function isPlainRecord(value){if(typeof value!="object"||value===null||Array.isArray(value))return!1;const prototype=Object.getPrototypeOf(value);if(prototype===Object.prototype||prototype===null)return!0;if(Object.getPrototypeOf(prototype)!==null)return!1;const constructor=Object.getOwnPropertyDescriptor(prototype,"constructor")?.value;return typeof constructor=="function"&&Function.prototype.toString.call(constructor)===Function.prototype.toString.call(Object)}function normalizeTokenBranch(value){return isSafeLyraThemeTokenValue(value)?value.trim():null}function normalizeTokens(raw){try{if(!isPlainRecord(raw))return null;const names=Object.keys(raw);if(names.length===0||names.length>TOKEN_ENTRY_MAX)return null;const result={};let kept=0;for(const name of names){if(!isLyraThemeTokenName(name))continue;const value=ownField(raw,name);if(typeof value=="string"){const normalized=normalizeTokenBranch(value);if(normalized===null)continue;result[name]=normalized,kept+=1;continue}if(!isPlainRecord(value))continue;const keys=Object.keys(value),hasLight=Object.prototype.hasOwnProperty.call(value,"light"),hasDark=Object.prototype.hasOwnProperty.call(value,"dark");if(!hasLight&&!hasDark||keys.some(key=>key!=="light"&&key!=="dark"))continue;const light=normalizeTokenBranch(ownField(value,"light")),dark=normalizeTokenBranch(ownField(value,"dark"));light===null&&dark===null||(result[name]=Object.freeze({light,dark}),kept+=1)}return kept>0?Object.freeze(result):null}catch{return null}}function tokensEqual(left,right){const leftNames=left?Object.keys(left):[],rightNames=right?Object.keys(right):[];if(leftNames.length!==rightNames.length)return!1;if(leftNames.length===0)return!0;const leftMap=left,rightMap=right;return leftNames.every(name=>{if(!Object.prototype.hasOwnProperty.call(rightMap,name))return!1;const a=leftMap[name],b=rightMap[name];return typeof a=="string"||typeof b=="string"?a===b:!a||!b?!1:(a.light??null)===(b.light??null)&&(a.dark??null)===(b.dark??null)})}function normalizeColor(value,owner=document){if(typeof value!="string"||!value.trim())return null;const candidate=value.trim();if(!isBalancedCssValue(candidate)||TOKEN_CSS_WIDE_PATTERN.test(candidate)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(candidate)||/\bcurrentcolor\b/i.test(candidate)||/\bvar\s*\(/i.test(candidate)||/\blight-dark\s*\(/i.test(candidate)||/\b(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color)\s*\(\s*from\b/i.test(candidate))return null;const probe=owner.createElement("span");return probe.style.color=candidate,probe.style.color?candidate:null}function normalizeAccentValue(value){if(typeof value=="string"||value===null)return normalizeColor(value);if(typeof value!="object"||Array.isArray(value))return null;const record=value;if(!("light"in record)&&!("dark"in record))return null;const light=normalizeColor(record.light),dark=normalizeColor(record.dark);return light||dark?{light,dark}:null}function normalizeAccent(value){if(typeof value=="string")return normalizeColor(value);if(value===null||typeof value!="object"||Array.isArray(value))return null;const record=value,result={};let hasRole=!1;for(const role of SEMANTIC_ROLES)role in record&&(hasRole=!0,result[role]=normalizeAccentValue(record[role]));return hasRole?result:null}function resolveAccentValueForMode(value,mode){return typeof value=="string"?value:value?value[mode]??null:null}function accentValueEqual(left,right){return left===right?!0:typeof left=="string"||typeof right=="string"||left===null||right===null?!1:(left.light??null)===(right.light??null)&&(left.dark??null)===(right.dark??null)}function accentsEqual(left,right){if(left===right)return!0;if(typeof left=="string"||typeof right=="string"||left===null||right===null)return!1;const leftKeys=Object.keys(left),rightKeys=Object.keys(right);return leftKeys.length!==rightKeys.length?!1:leftKeys.every(role=>accentValueEqual(left[role],right[role]))}function parseResolvedRgb(value,background,owner=document){if(!normalizeColor(value,owner))return null;try{const canvas=owner.createElement("canvas");canvas.width=1,canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0});if(!context)return null;context.clearRect(0,0,1,1),context.fillStyle=value,context.fillRect(0,0,1,1);const channels=context.getImageData(0,0,1,1).data,red=channels[0]??0,green=channels[1]??0,blue=channels[2]??0,alpha=(channels[3]??0)/255;return[Math.round(red*alpha+background[0]*(1-alpha)),Math.round(green*alpha+background[1]*(1-alpha)),Math.round(blue*alpha+background[2]*(1-alpha))]}catch{return null}}function mixRgb(base,color,colorWeight){return[Math.round(base[0]*(1-colorWeight)+color[0]*colorWeight),Math.round(base[1]*(1-colorWeight)+color[1]*colorWeight),Math.round(base[2]*(1-colorWeight)+color[2]*colorWeight)]}function serializeRgb(color){return`rgb(${color.join(" ")})`}function relativeLuminance(color){const linearize=channel=>{const normalized=channel/255;return normalized<=.04045?normalized/12.92:((normalized+.055)/1.055)**2.4};return linearize(color[0])*.2126+linearize(color[1])*.7152+linearize(color[2])*.0722}function contrastRatio(left,right){const a=relativeLuminance(left),b=relativeLuminance(right);return(Math.max(a,b)+.05)/(Math.min(a,b)+.05)}function contrastForeground(fill){const black=[0,0,0],white=[255,255,255];return contrastRatio(fill,black)>=contrastRatio(fill,white)?black:white}function ensureSurfaceContrast(color,background,minimum=3,alsoAgainst=background,references=[]){const passes=candidate=>contrastRatio(candidate,background)>=minimum&&contrastRatio(candidate,alsoAgainst)>=minimum&&references.every(reference=>contrastRatio(candidate,reference)>=minimum);if(passes(color))return color;const black=[0,0,0],white=[255,255,255],target=contrastRatio(background,black)>=contrastRatio(background,white)?black:white;for(let step=1;step<=10;step+=1){const candidate=mixRgb(color,target,step/10);if(passes(candidate))return candidate}return target}function createRoleRamp(role,base,mode,background,owner=document){const references=STYLE_CONTRAST_SURFACES[mode].flatMap(color=>{const value=parseResolvedRgb(color,MODE_SURFACES[mode],owner);return value?[value]:[]}),resolved=parseResolvedRgb(base,background,owner);if(!resolved)return null;const quiet=mixRgb(background,resolved,mode==="dark"?.24:.14),normal=mixRgb(background,resolved,mode==="dark"?.62:.55),loud=ensureSurfaceContrast(resolved,background,4.5,quiet,references),borderTarget=mode==="dark"?[255,255,255]:[0,0,0],borderQuiet=mixRgb(background,resolved,mode==="dark"?.46:.38),borderNormal=ensureSurfaceContrast(mixRgb(background,resolved,mode==="dark"?.78:.72),background,3,background,references),borderLoud=ensureSurfaceContrast(mixRgb(loud,borderTarget,.2),background,3,background,references),prefix=`--lr-theme-color-${role}`,ramp={[`${prefix}-fill-quiet`]:serializeRgb(quiet),[`${prefix}-fill-normal`]:serializeRgb(normal),[`${prefix}-fill-loud`]:serializeRgb(loud),[`${prefix}-border-quiet`]:serializeRgb(borderQuiet),[`${prefix}-border-normal`]:serializeRgb(borderNormal),[`${prefix}-border-loud`]:serializeRgb(borderLoud),[`${prefix}-on-quiet`]:serializeRgb(contrastForeground(quiet)),[`${prefix}-on-normal`]:serializeRgb(contrastForeground(normal)),[`${prefix}-on-loud`]:serializeRgb(contrastForeground(loud))};return role==="brand"&&(ramp["--lr-theme-color-focus"]=serializeRgb(ensureSurfaceContrast(resolved,background,3,background,references))),ramp}function paintAccent(accent,mode,background,owner=document){const properties=new Map;if(!accent)return{applied:null,properties};if(!mode)return{applied:accent,properties};if(typeof accent=="string"){const ramp=createRoleRamp("brand",accent,mode,background,owner);if(!ramp)return{applied:null,properties};properties.set("--lr-theme-accent",accent);for(const[property,value]of Object.entries(ramp))properties.set(property,value);return{applied:accent,properties}}const applied={};let appliedBrandColor=null;for(const role of SEMANTIC_ROLES){const value=accent[role];if(!value)continue;const isPerMode=typeof value!="string",base=resolveAccentValueForMode(value,mode);let painted=!1;if(base){const ramp=createRoleRamp(role,base,mode,background,owner);if(ramp){for(const[property,propertyValue]of Object.entries(ramp))properties.set(property,propertyValue);painted=!0,role==="brand"&&(appliedBrandColor=base)}}(painted||isPerMode)&&(applied[role]=value)}return appliedBrandColor&&properties.set("--lr-theme-accent",appliedBrandColor),{applied:Object.keys(applied).length>0?applied:null,properties}}function tokenEntries(tokens,mode){const entries=new Map;if(!tokens)return entries;for(const[name,value]of Object.entries(tokens))if(typeof value=="string")entries.set(name,value);else if(mode){const branch=value[mode];branch&&entries.set(name,branch)}return entries}function resolveTokenColor(value,background,owner){return value===void 0||!background||!normalizeColor(value,owner)?null:parseResolvedRgb(value,background,owner)}function floorTokenEntries(entries,surface,owner,references){if(!entries.size)return new Map;const resolveColor=(value,background)=>resolveTokenColor(value,background,owner),painted=new Map(entries),prefix="--lr-theme-",raised=resolveColor(entries.get(`${prefix}color-surface-raised`)??references[1],surface),floor=(name,over,against,minimum,alsoAgainst)=>{const value=painted.get(name);if(value===void 0||!against||alsoAgainst===null)return;const color=resolveColor(value,over);if(!color)return;const repaired=ensureSurfaceContrast(color,against,minimum,alsoAgainst??against);repaired!==color&&painted.set(name,serializeRgb(repaired))};floor(`${prefix}color-text-normal`,surface,surface,4.5,raised),floor(`${prefix}color-text-quiet`,surface,surface,4.5,raised);const text=entries.has(`${prefix}color-text-normal`)?resolveColor(painted.get(`${prefix}color-text-normal`),surface):resolveColor(references[2],surface),pairForeground=(onName,fill)=>{if(!fill)return;const on=painted.get(onName);if(on===void 0){painted.set(onName,serializeRgb(contrastForeground(fill)));return}const color=resolveColor(on,fill);color&&contrastRatio(color,fill)<4.5&&painted.set(onName,serializeRgb(contrastForeground(fill)))};for(const role of SEMANTIC_ROLES)for(const tier of RAMP_TIERS){const fillName=`${prefix}color-${role}-fill-${tier}`;entries.has(fillName)&&pairForeground(`${prefix}color-${role}-on-${tier}`,resolveColor(entries.get(fillName),surface))}const overlayName=`${prefix}color-overlay-strong`,overlay=entries.has(overlayName)?resolveColor(entries.get(overlayName),surface):resolveColor(references[3],surface);(entries.has(overlayName)||entries.has(`${prefix}color-on-strong-overlay`))&&pairForeground(`${prefix}color-on-strong-overlay`,overlay);for(const name of entries.keys())/^--lr-theme-color-(?:(?:brand|success|warning|danger|neutral)-border-(?:normal|loud)|surface-border|border-strong|focus|chart-\d+)$/.test(name)?floor(name,surface,surface,3):/^--lr-theme-terminal-color-[a-z0-9-]+$/.test(name)?floor(name,raised,raised,4.5):/^--lr-theme-terminal-bg-[a-z0-9-]+$/.test(name)&&floor(name,raised,text,4.5);return painted}function readOwnershipList(){try{const list=document.documentElement[Symbol.for(TOKEN_OWNERSHIP_SYMBOL)];if(!Array.isArray(list))return[];const names=[],length=Math.min(list.length,TOKEN_OWNERSHIP_MAX);for(let index=0;index<length;index+=1){const name=list[index];isLyraThemeTokenName(name)&&names.push(name)}return names}catch{return[]}}function applyStoredThemeBeforePaint(){const R=["brand","success","warning","danger","neutral"],Q=["quiet","normal","loud"],W=/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/,_="--lr-theme-accent",G=/[\x00-\x1f\x7f\\;{}!<>@[\]`$^|~=?&:\u2028\u2029]|\/\*|\*\//,H=/^(?:inherit|initial|revert(?:-layer)?|unset)$/i,J=/([a-z0-9_-]+)\s*\(/gi,K="rgb rgba hsl hsla hwb lab lch oklab oklch color color-mix light-dark calc min max clamp var cubic-bezier steps linear".split(" "),U={light:[255,255,255],dark:[10,10,10]},X=r=>{let o=0,h="";for(const a of r){if(h){a===h&&(h="");continue}if(a==="'"||a==='"')h=a;else if(a==="(")o+=1;else if(a===")"&&(o-=1)<0)return!1}return h===""&&o===0},Y=r=>typeof r=="string"&&r.length<=80&&W.test(r)&&r!==_,P=r=>{if(typeof r!="string")return null;const o=r.trim();if(!o||o.length>256||G.test(o)||H.test(o))return null;for(const h of o.matchAll(J))if(!K.includes((h[1]??"").toLowerCase()))return null;return X(o)?o:null},A=r=>{if(typeof r!="object"||r===null||Array.isArray(r))return!1;const o=Object.getPrototypeOf(r);return o===Object.prototype||o===null},Z=r=>{const o={};try{if(!A(r))return o;const h=Object.keys(r);if(h.length<=512)for(const a of h){if(!Y(a))continue;const g=r[a];if(typeof g=="string"){const u=P(g);u!==null&&(o[a]=u);continue}if(!A(g))continue;const j=Object.hasOwn(g,"light"),i=Object.hasOwn(g,"dark");if(!j&&!i||Object.keys(g).some(u=>u!=="light"&&u!=="dark"))continue;const M=P(g.light),y=P(g.dark);(M!==null||y!==null)&&(o[a]={light:M,dark:y})}}catch{}return o},C=r=>{const o=P(r);if(!(!o||/\b(?:var|light-dark)\s*\(|\b(?:currentcolor|from)\b/i.test(o)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(o)))return CSS.supports("color",o)?o:void 0};return[Z,C,(r,o,h,a,g,j)=>{const i=new Map;for(const[t,n]of Object.entries(r)){const e=typeof n=="string"?n:n[o];e&&i.set(t,e)}const M=typeof a=="string"?{brand:a}:a,y={};for(const t of R){const n=M?.[t],e=typeof n=="string"?n:n?.[o];e&&(y[t]=e)}let u=null;if(i.size>0||Object.keys(y).length>0)try{const t=document.createElement("canvas");t.width=1,t.height=1,u=t.getContext("2d",{willReadFrequently:!0})}catch{u=null}const S=(t,n)=>{if(!u)return null;try{u.clearRect(0,0,1,1),u.fillStyle=t,u.fillRect(0,0,1,1);const e=u.getImageData(0,0,1,1).data,c=(e[3]??0)/255;return[0,1,2].map(f=>Math.round((e[f]??0)*c+(n[f]??0)*(1-c)))}catch{return null}},z=(t,n,e)=>t.map((c,f)=>Math.round(c*(1-e)+(n[f]??0)*e)),B=t=>{const n=t.map(e=>{const c=e/255;return c<=.04045?c/12.92:((c+.055)/1.055)**2.4});return(n[0]??0)*.2126+(n[1]??0)*.7152+(n[2]??0)*.0722},O=(t,n)=>{const e=B(t),c=B(n);return(Math.max(e,c)+.05)/(Math.min(e,c)+.05)},v=[0,0,0],F=[255,255,255],w=t=>O(t,v)>=O(t,F)?v:F,q=(t,n,e=3,c=n)=>{const f=d=>O(d,n)>=e&&O(d,c)>=e&&g.every(k=>O(d,k)>=e);if(f(t))return t;const p=w(n);for(let d=1;d<=10;d+=1){const k=z(t,p,d/10);if(f(k))return k}return p},m=t=>`rgb(${t.join(" ")})`,D=U[o],E=C(h)??C(i.get("--lr-theme-color-surface-default")),s=E&&S(E,D)||D,l=new Map(i),b="--lr-theme-",$=(t,n)=>t!==void 0&&n&&C(t)?S(t,n):null,tt=`${b}color-surface-raised`,N=$(i.get(tt)??j[1],s),L=(t,n,e,c,f)=>{const p=l.get(t);if(p===void 0||!e||f===null)return;const d=$(p,n);if(!d)return;const k=q(d,e,c,f??e);k!==d&&l.set(t,m(k))};L(`${b}color-text-normal`,s,s,4.5,N),L(`${b}color-text-quiet`,s,s,4.5,N);const et=i.has(`${b}color-text-normal`)?$(l.get(`${b}color-text-normal`),s):$(j[2],s),I=(t,n)=>{if(!n)return;const e=l.get(t),c=e===void 0?null:$(e,n);(e===void 0||c&&O(c,n)<4.5)&&l.set(t,m(w(n)))};for(const t of R)for(const n of Q){const e=`${b}color-${t}-fill-${n}`;i.has(e)&&I(`${b}color-${t}-on-${n}`,$(i.get(e),s))}const T=`${b}color-overlay-strong`;(i.has(T)||i.has(`${b}color-on-strong-overlay`))&&I(`${b}color-on-strong-overlay`,i.has(T)?$(i.get(T),s):$(j[3],s));for(const t of i.keys())/^--lr-theme-color-(?:(?:brand|success|warning|danger|neutral)-border-(?:normal|loud)|surface-border|border-strong|focus|chart-\d+)$/.test(t)?L(t,s,s,3):/^--lr-theme-terminal-color-[a-z0-9-]+$/.test(t)?L(t,N,N,4.5):/^--lr-theme-terminal-bg-[a-z0-9-]+$/.test(t)&&L(t,N,et,4.5);if(!u)return l;let V=null;for(const t of R){const n=y[t];if(!n)continue;const e=S(n,s);if(!e)continue;const c=z(s,e,o==="dark"?.24:.14),f=z(s,e,o==="dark"?.62:.55),p=q(e,s,4.5,c),d=o==="dark"?F:v,k=z(s,e,o==="dark"?.46:.38),nt=q(z(s,e,o==="dark"?.78:.72),s),ot=q(z(p,d,.2),s),x=`--lr-theme-color-${t}`;l.set(`${x}-fill-quiet`,m(c)),l.set(`${x}-fill-normal`,m(f)),l.set(`${x}-fill-loud`,m(p)),l.set(`${x}-border-quiet`,m(k)),l.set(`${x}-border-normal`,m(nt)),l.set(`${x}-border-loud`,m(ot)),l.set(`${x}-on-quiet`,m(w(c))),l.set(`${x}-on-normal`,m(w(f))),l.set(`${x}-on-loud`,m(w(p))),t==="brand"&&(l.set("--lr-theme-color-focus",m(q(e,s))),V=n)}return V&&l.set("--lr-theme-accent",V),l}]}function styleMaterial(l,n){const t=n==="glass";for(const[a,i]of Object.entries({enabled:t?"1":"0",content:t?"''":"none",isolation:t?"isolate":"auto","root-filter":t?"initial":"none","child-filter":t?"none":"initial","child-opacity":t?"1":"0"}))l.set(`--_lr-surface-${a}`,i);l.set("--_lr-glass-blocker",t?"initial":"none"),t||(l.set("--_lr-glass-parent-opacity","0"),l.set("--_lr-next-glass-opacity","0"))}function applyStoredStyleBeforePaint(I,K,U,z,q,D,G,w){const{surfaces:M,contrast:J,accent:W}=w,m=new Map;for(const o of w.inputs.split(" "))m.set(`--lr-theme-${o.slice(1)}`,Number(o[0]));const P=[...m.keys()];function b(o,s,u=!1){return`--_lr-${u?"a":"l"}${s==="light"?"l":"d"}-${o.slice(11)}`}function N(o,s){const u=m.get(o)??0;let i=`var(${b(o,s)})`;if(u&2){const v=s==="light"?"l":"d",$=o.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");i=`var(--_lr-f${v}-${o.slice(11)},${i})var(--_lr-o${v}-${o.slice(11)},var(${b($,s,!0)},var(${b($,s)})))`}return u&4?`var(${b(o,s,!0)},${i})`:i}function H(o){const s=`var(--_lr-dark-on,${N(o,"light")})var(--_lr-light-on,${N(o,"dark")})`;if(!((m.get(o)??0)&1))return s;const u=o.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${s})var(--_lr-dense-off,max(calc((${s}) * var(--_lr-density-${u?"space":"control"},1)),${u?"0px":"var(--_lr-density-target-min,0px)"}))`}try{const o=document.currentScript,s=o?.getAttribute("data-lr-theme-storage-key"),u=s&&s.length<=200?s:I,i=o?.getAttribute("data-lr-theme-attributes")?.trim().split(/\s+/),v=i?.length&&i.length<=8&&new Set(i).size===i.length&&i.every(t=>t.length<=64&&/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(t))?i:K;let $;try{$=JSON.parse(localStorage.getItem(u)??"null")}catch{}const r=document.documentElement,[Q,X,Z]=U(),f=D($,w.defaults,Q,X,(t,e)=>z(t,e,P),W),y=f.mode,S=y==="unset"?null:y==="system"?matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":y,p={},V=getComputedStyle(r).getPropertyValue("--_lr-style-resolver").trim()==="1",j=(t,e)=>typeof t=="string"?t:t?.[e],tt=f.tokens,et=f.overrides,_={...tt,...et},C=f.look;if(p["data-lr-look"]=C,p["data-lr-density"]=f.density,p["data-lr-surface"]=f.treatment,y!=="unset"&&(p["data-lr-mode"]=y),S)for(const t of v)p[t]=S;const A=f.accentName;let d=f.accent;y!=="unset"&&d&&typeof d=="object"&&!Object.values(d).some(t=>typeof t=="string"||t&&Object.values(t).some(Boolean))&&(d=null),p["data-lr-accent"]=A??(d?"custom":"none");const a=new Map;if(y==="unset")for(const[t,e]of Object.entries(_))typeof e=="string"&&a.set(t,e);for(const t of["light","dark"]){const e=j(f.surface,t),E=j(_["--lr-theme-color-surface-default"],t),c=(M[C]??M.lyra)[t],T=e??E??c[0];for(const h of[!1,!0]){if(h&&(!d||A))continue;const rt=Z(h?{}:_,t,T,h?d:null,h?J[t].map(l=>[1,3,5].map(g=>parseInt(l.slice(g,g+2),16))):[],c);for(const[l,g]of rt){if(l==="--lr-theme-accent"){t===S&&a.set(l,g);continue}const Y=m.get(l);if(Y!==void 0&&z(l,g,P)){const x=l.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1],O=!h&&x&&g===`var(--lr-theme-color-brand-${x})`,B=l.slice(11),F=t==="light"?"l":"d";O||a.set(b(l,t,h),g),!h&&Y&2&&(a.set(`--_lr-f${F}-${B}`,O?" ":"initial"),a.set(`--_lr-o${F}-${B}`,O?"initial":" ")),t===S&&a.set(l,V?H(l):g)}else t===S&&a.set(l,g)}}}(a.size||y==="unset"&&d&&!A)&&(p["data-lr-theme-scope"]=""),V||G(a,f.treatment);const R=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),k=r;let L;try{L=q(k[R])}catch{}const n=L??{attributes:new Map,properties:new Map};if(y==="unset")for(const t of v)n.attributes.has(t)||r.removeAttribute(t);try{const t=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),e=k[t];if(Array.isArray(e)){const E=e.slice(0,528).filter(c=>typeof c=="string"&&c.length<=80&&/^--lr-theme-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(c));for(const c of[...E,...P.filter(T=>m.get(T)&4),"--lr-theme-accent"])!n.properties.has(c)&&r.style.getPropertyValue(c)&&n.properties.set(c,{before:null,priority:"",written:r.style.getPropertyValue(c)});try{delete k[t]}catch{}}}catch{}for(const[t,e]of n.attributes)Object.hasOwn(p,t)||(r.getAttribute(t)===e.written&&(e.before===null?r.removeAttribute(t):r.setAttribute(t,e.before)),n.attributes.delete(t));for(const[t,e]of Object.entries(p))n.attributes.has(t)||n.attributes.set(t,{before:r.getAttribute(t),priority:"",written:e}),r.setAttribute(t,e),n.attributes.get(t).written=e;for(const[t,e]of n.properties)a.has(t)||(r.style.getPropertyValue(t)===e.written&&!r.style.getPropertyPriority(t)&&(e.before?r.style.setProperty(t,e.before,e.priority):r.style.removeProperty(t)),n.properties.delete(t));for(const[t,e]of a)n.properties.has(t)||n.properties.set(t,{before:r.style.getPropertyValue(t),priority:r.style.getPropertyPriority(t),written:null}),r.style.getPropertyPriority(t)&&r.style.removeProperty(t),r.style.setProperty(t,e,""),n.properties.get(t).written=r.style.getPropertyValue(t);try{k[R]=n}catch{}}catch{}}const LINE_SEPARATOR="\u2028",PARAGRAPH_SEPARATOR="\u2029";function serializeInlineScriptData(value){return JSON.stringify(value).replace(/</g,"\\u003c").replace(new RegExp(LINE_SEPARATOR,"g"),"\\u2028").replace(new RegExp(PARAGRAPH_SEPARATOR,"g"),"\\u2029")}function createLyraThemeBootstrap(options={}){const storageKey=options.storageKey??STORAGE_KEY,inputs=STYLE_SLOTTED.map(name=>`${Number(STYLE_DENSITY.includes(name))|Number(STYLE_FOLLOW.includes(name))<<1|Number(ALL_RAMP_PROPERTIES.includes(name))<<2}${name.slice(11)}`).join(" "),model=JSON.stringify({defaults:STYLE_DEFAULTS,inputs,surfaces:STYLE_REFERENCE_SURFACES,contrast:STYLE_CONTRAST_SURFACES,accent:STYLE_GEMSTONES}),functions=[applyStoredStyleBeforePaint,applyStoredThemeBeforePaint,styleTokenAllowed,readStyleOwnership,resolveStyleStartup,styleMaterial].map(helper=>helper.toString().replace(/^function\s+[\w$]+/,"function"));return`(${functions[0]})(${serializeInlineScriptData(storageKey)},${serializeInlineScriptData(MODE_ATTRIBUTES)},${functions.slice(1).join(",")},${model});`}const STYLE_DEFAULTS=Object.freeze({look:"shadcn",surface:"glass",density:"comfortable",mode:"system",accent:"emerald"}),STYLE_SLOTTED=["--lr-theme-color-border-strong","--lr-theme-color-brand-border-loud","--lr-theme-color-brand-border-normal","--lr-theme-color-brand-border-quiet","--lr-theme-color-brand-fill-loud","--lr-theme-color-brand-fill-normal","--lr-theme-color-brand-fill-quiet","--lr-theme-color-brand-on-loud","--lr-theme-color-brand-on-normal","--lr-theme-color-brand-on-quiet","--lr-theme-color-chart-1","--lr-theme-color-chart-2","--lr-theme-color-chart-3","--lr-theme-color-chart-4","--lr-theme-color-chart-5","--lr-theme-color-chart-6","--lr-theme-color-chart-7","--lr-theme-color-chart-8","--lr-theme-color-chart-diverging-1","--lr-theme-color-chart-diverging-2","--lr-theme-color-chart-diverging-3","--lr-theme-color-chart-sequential-1","--lr-theme-color-chart-sequential-2","--lr-theme-color-chart-sequential-3","--lr-theme-color-danger-border-loud","--lr-theme-color-danger-border-normal","--lr-theme-color-danger-border-quiet","--lr-theme-color-danger-fill-loud","--lr-theme-color-danger-fill-normal","--lr-theme-color-danger-fill-quiet","--lr-theme-color-danger-on-loud","--lr-theme-color-danger-on-normal","--lr-theme-color-danger-on-quiet","--lr-theme-color-focus","--lr-theme-color-mix-partner","--lr-theme-color-neutral-border-loud","--lr-theme-color-neutral-border-normal","--lr-theme-color-neutral-border-quiet","--lr-theme-color-neutral-fill-loud","--lr-theme-color-neutral-fill-normal","--lr-theme-color-neutral-fill-quiet","--lr-theme-color-neutral-on-loud","--lr-theme-color-neutral-on-normal","--lr-theme-color-neutral-on-quiet","--lr-theme-color-no-data","--lr-theme-color-on-strong-overlay","--lr-theme-color-overlay","--lr-theme-color-overlay-strong","--lr-theme-color-success-border-loud","--lr-theme-color-success-border-normal","--lr-theme-color-success-border-quiet","--lr-theme-color-success-fill-loud","--lr-theme-color-success-fill-normal","--lr-theme-color-success-fill-quiet","--lr-theme-color-success-on-loud","--lr-theme-color-success-on-normal","--lr-theme-color-success-on-quiet","--lr-theme-color-surface-border","--lr-theme-color-surface-border-subtle","--lr-theme-color-surface-container","--lr-theme-color-surface-container-high","--lr-theme-color-surface-container-highest","--lr-theme-color-surface-container-low","--lr-theme-color-surface-container-lowest","--lr-theme-color-surface-default","--lr-theme-color-surface-overlay","--lr-theme-color-surface-raised","--lr-theme-color-text-normal","--lr-theme-color-text-quiet","--lr-theme-color-warning-border-loud","--lr-theme-color-warning-border-normal","--lr-theme-color-warning-border-quiet","--lr-theme-color-warning-fill-loud","--lr-theme-color-warning-fill-normal","--lr-theme-color-warning-fill-quiet","--lr-theme-color-warning-on-loud","--lr-theme-color-warning-on-normal","--lr-theme-color-warning-on-quiet","--lr-theme-form-control-height-2xs","--lr-theme-form-control-height-l","--lr-theme-form-control-height-m","--lr-theme-form-control-height-s","--lr-theme-form-control-height-xl","--lr-theme-form-control-height-xs","--lr-theme-graph-cat-1","--lr-theme-graph-cat-2","--lr-theme-graph-cat-3","--lr-theme-graph-cat-4","--lr-theme-graph-cat-5","--lr-theme-graph-cat-6","--lr-theme-graph-cat-7","--lr-theme-graph-cat-8","--lr-theme-icon-button-size","--lr-theme-shadow-l","--lr-theme-shadow-m","--lr-theme-shadow-s","--lr-theme-shadow-xl","--lr-theme-shadow-xs","--lr-theme-space-2xl","--lr-theme-space-2xs","--lr-theme-space-l","--lr-theme-space-m","--lr-theme-space-s","--lr-theme-space-xs","--lr-theme-terminal-bg-black","--lr-theme-terminal-bg-blue","--lr-theme-terminal-bg-bright-black","--lr-theme-terminal-bg-bright-blue","--lr-theme-terminal-bg-bright-cyan","--lr-theme-terminal-bg-bright-green","--lr-theme-terminal-bg-bright-magenta","--lr-theme-terminal-bg-bright-red","--lr-theme-terminal-bg-bright-white","--lr-theme-terminal-bg-bright-yellow","--lr-theme-terminal-bg-cyan","--lr-theme-terminal-bg-green","--lr-theme-terminal-bg-magenta","--lr-theme-terminal-bg-red","--lr-theme-terminal-bg-white","--lr-theme-terminal-bg-yellow","--lr-theme-terminal-color-black","--lr-theme-terminal-color-blue","--lr-theme-terminal-color-bright-black","--lr-theme-terminal-color-bright-blue","--lr-theme-terminal-color-bright-cyan","--lr-theme-terminal-color-bright-green","--lr-theme-terminal-color-bright-magenta","--lr-theme-terminal-color-bright-red","--lr-theme-terminal-color-bright-white","--lr-theme-terminal-color-bright-yellow","--lr-theme-terminal-color-cyan","--lr-theme-terminal-color-green","--lr-theme-terminal-color-magenta","--lr-theme-terminal-color-red","--lr-theme-terminal-color-white","--lr-theme-terminal-color-yellow"],STYLE_DENSITY=["--lr-theme-space-2xs","--lr-theme-space-xs","--lr-theme-space-s","--lr-theme-space-m","--lr-theme-space-l","--lr-theme-space-2xl","--lr-theme-form-control-height-2xs","--lr-theme-form-control-height-xs","--lr-theme-form-control-height-s","--lr-theme-form-control-height-m","--lr-theme-form-control-height-l","--lr-theme-form-control-height-xl","--lr-theme-icon-button-size"],STYLE_FOLLOW=["--lr-theme-color-danger-border-loud","--lr-theme-color-danger-border-normal","--lr-theme-color-danger-border-quiet","--lr-theme-color-danger-fill-loud","--lr-theme-color-danger-fill-normal","--lr-theme-color-danger-fill-quiet","--lr-theme-color-danger-on-loud","--lr-theme-color-danger-on-normal","--lr-theme-color-danger-on-quiet","--lr-theme-color-neutral-border-loud","--lr-theme-color-neutral-border-normal","--lr-theme-color-neutral-border-quiet","--lr-theme-color-neutral-fill-loud","--lr-theme-color-neutral-fill-normal","--lr-theme-color-neutral-fill-quiet","--lr-theme-color-neutral-on-loud","--lr-theme-color-neutral-on-normal","--lr-theme-color-neutral-on-quiet","--lr-theme-color-success-border-loud","--lr-theme-color-success-border-normal","--lr-theme-color-success-border-quiet","--lr-theme-color-success-fill-loud","--lr-theme-color-success-fill-normal","--lr-theme-color-success-fill-quiet","--lr-theme-color-success-on-loud","--lr-theme-color-success-on-normal","--lr-theme-color-success-on-quiet","--lr-theme-color-warning-border-loud","--lr-theme-color-warning-border-normal","--lr-theme-color-warning-border-quiet","--lr-theme-color-warning-fill-loud","--lr-theme-color-warning-fill-normal","--lr-theme-color-warning-fill-quiet","--lr-theme-color-warning-on-loud","--lr-theme-color-warning-on-normal","--lr-theme-color-warning-on-quiet"],STYLE_REFERENCE_SURFACES={lyra:{light:["#ffffff","#f6f8fa","#1a1a1a","rgb(0 0 0 / 0.92)"],dark:["#1a1a1a","#22272e","#f2f2f2","rgb(0 0 0 / 0.95)"]},data:{light:["#ffffff","#f2f5f8","#10202c","#17212b"],dark:["#101820","#192630","#eef5fa","#e7eef4"]},"high-contrast":{light:["#ffffff","#ffffff","#000000","#17212b"],dark:["#000000","#000000","#ffffff","#e7eef4"]},material:{light:["#fff8f5","#f8eeea","#241b17","rgb(0 0 0 / 0.92)"],dark:["#18120f","#251d19","#f8eee8","rgb(0 0 0 / 0.95)"]},shadcn:{light:["#ffffff","#fafafa","#0a0a0a","rgb(0 0 0 / 0.92)"],dark:["#0a0a0a","#171717","#fafafa","rgb(0 0 0 / 0.95)"]},terminal:{light:["#fcfdf9","#f1f5eb","#0d2115","#17212b"],dark:["#0e1713","#18271e","#e5f5e9","#e7eef4"]}},STYLE_CONTRAST_SURFACES={light:["#ffffff","#f6f8fa","#f2f5f8","#fff8f5","#f8eeea","#fcf2ed","#f2e7e0","#ecdfd7","#fafafa","#fcfdf9","#f1f5eb"],dark:["#1a1a1a","#22272e","#2b3038","#101820","#192630","#202e39","#000000","#18120f","#251d19","#302621","#120d0a","#211914","#352a24","#0a0a0a","#171717","#0e1713","#18271e","#203227"]},STYLE_GEMSTONES={emerald:"#34d399",peridot:"#a8d84a",topaz:"#f0a83c",ruby:"#e63950",tourmaline:"#ec4899",amethyst:"#9d6df0",aquamarine:"#22d3ee",sapphire:"#4f8ff7",hematite:"#94a3b8"},LOOK_ID=/^[a-z0-9]+(?:-[a-z0-9]+)*$/,LOOK_STAMP=Symbol.for("@aceshooting/lyra-ui.look.v1"),STYLE_OWNERSHIP=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),STYLE_FIELDS=["look","surface","density","mode","accent","accentBackground","overrides"],DEFAULT_STYLE=Object.freeze({...STYLE_DEFAULTS,tokens:null,accent:STYLE_GEMSTONES[STYLE_DEFAULTS.accent],accentName:STYLE_DEFAULTS.accent,accentBackground:null,overrides:null});let lastStyle={...DEFAULT_STYLE},stylePersistenceFailed=!1,styleModeCleanup,styleModeRoot;const styleOwnershipFallback=new WeakMap,scopeModes=new WeakMap;function ownField(value,key){const descriptor=Object.getOwnPropertyDescriptor(value,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}function styleId(value){return typeof value=="string"&&value.length<=64&&LOOK_ID.test(value)}function styleTokenAllowed(e,r,o=STYLE_SLOTTED){if(e.startsWith("--lr-theme-surface-")||typeof r!="string"&&!o.includes(e))return!1;for(const t of typeof r=="string"?[r]:[r.light,r.dark])if(t)for(const c of t.matchAll(/var\(\s*(--[\w-]+)/g)){if(c[1]==="--lr-theme-shadow-color")continue;const n=e.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1];if(!n||t!==`var(--lr-theme-color-brand-${n})`)return!1}return!0}function styleTokens(value){const tokens=normalizeTokens(value);if(!tokens)return null;const entries=Object.entries(tokens).filter(([name,input])=>styleTokenAllowed(name,input));return entries.length?Object.freeze(Object.fromEntries(entries)):null}function defineLyraLook(look){if(!look||!styleId(ownField(look,"id"))||look.id==="custom")throw new TypeError("Invalid look id");const raw=ownField(look,"tokens");if(!isPlainRecord(raw)||Object.keys(raw).length>TOKEN_ENTRY_MAX)throw new TypeError("Invalid look tokens");for(const[name,descriptor]of Object.entries(Object.getOwnPropertyDescriptors(raw))){if(!("value"in descriptor))throw new TypeError(`Look inputs must be data properties: ${name}`);const value=descriptor.value;if(typeof value=="string"){if(!isSafeLyraThemeTokenValue(value))throw new TypeError(`Invalid look value: ${name}`);continue}if(!isPlainRecord(value)||!STYLE_SLOTTED.includes(name))throw new TypeError(`Invalid per-mode look input: ${name}`);const branches=Object.entries(Object.getOwnPropertyDescriptors(value));if(!branches.length||branches.some(([key,branch])=>!["light","dark"].includes(key)||!("value"in branch)||branch.value!==null&&!isSafeLyraThemeTokenValue(branch.value)))throw new TypeError(`Invalid look mode pair: ${name}`)}const tokens=styleTokens(raw);if(Object.keys(raw).length!==Object.keys(tokens??{}).length)throw new TypeError("Invalid look token or cross-axis reference");const stamped={...tokens,[LOOK_STAMP]:look.id};return Object.freeze(stamped),Object.freeze({id:look.id,tokens:stamped})}function styleColor(value,browserColors=!1){if(!isSafeLyraThemeTokenValue(value))return null;const text=value.trim();return/\b(?:var|light-dark)\s*\(|\b(?:currentcolor|from)\b/i.test(text)||/^(?:accentcolor|accentcolortext|activetext|buttonborder|buttonface|buttontext|canvas|canvastext|field|fieldtext|graytext|highlight|highlighttext|linktext|mark|marktext|selecteditem|selecteditemtext|visitedtext)$/i.test(text)?null:browserColors&&typeof CSS<"u"?CSS.supports("color",text)?text:null:/^(?:#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})|[a-z]+|(?:rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\(.+\))$/i.test(text)?text:null}function styleColorPair(value){if(typeof value=="string")return styleColor(value);if(!isPlainRecord(value))return null;const light=styleColor(ownField(value,"light")),dark=styleColor(ownField(value,"dark"));return light||dark?Object.freeze({light,dark}):null}function styleAccent(value){if(typeof value=="string")return styleColor(value);if(!isPlainRecord(value))return null;const entries=SEMANTIC_ROLES.filter(role=>Object.hasOwn(value,role)).map(role=>[role,styleColorPair(ownField(value,role))]);return entries.length?Object.freeze(Object.fromEntries(entries)):null}function normalizeStyleChoices(raw,base){const next={...base};if(!isPlainRecord(raw))return next;const look=ownField(raw,"look");if(look!==void 0){if(next.look=DEFAULT_STYLE.look,next.tokens=null,styleId(look))next.look=look;else if(isPlainRecord(look))try{const definition=defineLyraLook(look);next.look=definition.id,next.tokens=definition.tokens}catch{}}const surface=ownField(raw,"surface");surface!==void 0&&(next.surface=surface==="glass"||surface==="solid"?surface:DEFAULT_STYLE.surface);const density=ownField(raw,"density");density!==void 0&&(next.density=density==="comfortable"||density==="compact"||density==="touch"?density:DEFAULT_STYLE.density);const mode=ownField(raw,"mode");mode!==void 0&&(next.mode=mode==="light"||mode==="dark"||mode==="system"||mode==="unset"?mode:DEFAULT_STYLE.mode);const accent=ownField(raw,"accent");accent!==void 0&&(next.accentName=typeof accent=="string"&&Object.hasOwn(STYLE_GEMSTONES,accent)?accent:null,next.accent=next.accentName?STYLE_GEMSTONES[next.accentName]:styleAccent(accent));const background=ownField(raw,"accentBackground");background!==void 0&&(next.accentBackground=styleColorPair(background));const overrides=ownField(raw,"overrides");return overrides!==void 0&&(next.overrides=styleTokens(overrides)),next}function styleFromRecord(value,browserColors=!1){const record=resolveStyleStartup(value,STYLE_DEFAULTS,normalizeTokens,input=>styleColor(input,browserColors)??void 0,styleTokenAllowed,STYLE_GEMSTONES),state=normalizeStyleChoices({look:ownField(record,"look"),mode:ownField(record,"mode"),density:ownField(record,"density"),surface:ownField(record,"treatment"),overrides:ownField(record,"overrides"),accentBackground:ownField(record,"surface")},{...DEFAULT_STYLE});state.accent=styleAccent(ownField(record,"accent"));const accentName=ownField(record,"accentName");return state.accentName=null,typeof accentName=="string"&&Object.hasOwn(STYLE_GEMSTONES,accentName)&&(state.accentName=accentName,state.accent=STYLE_GEMSTONES[accentName]),state.tokens=normalizeTokens(ownField(record,"tokens")),state.tokens&&!styleId(ownField(record,"look"))&&(state.look="custom"),state}function styleRecord(state){return{version:2,mode:state.mode,look:state.look,density:state.density,treatment:state.surface,accent:state.accent,surface:state.accentBackground,...state.accentName?{accentName:state.accentName}:{},...state.tokens?{tokens:state.tokens}:{},...state.overrides?{overrides:state.overrides}:{}}}function styleResolvedMode(mode,view){return mode==="unset"?null:mode!=="system"?mode:view?.matchMedia?.(COLOR_SCHEME_QUERY).matches?"dark":"light"}function styleSnapshot(state,view){return Object.freeze({look:state.look,lookForm:state.tokens?"runtime":"stylesheet",surface:state.surface,density:state.density,mode:state.mode,accent:state.accentName??state.accent,accentName:state.accentName,accentBackground:state.accentBackground,...state.overrides?{overrides:state.overrides}:{},resolvedMode:styleResolvedMode(state.mode,view)})}function parseLyraStyleRecord(value){const state=styleFromRecord(value),result=styleSnapshot(state);return state.mode==="system"?Object.freeze({...result,resolvedMode:null}):result}function lyraStyleAttributes(style){const attributes={};return styleId(style.look)&&(attributes["data-lr-look"]=style.look),(style.surface==="solid"||style.surface==="glass")&&(attributes["data-lr-surface"]=style.surface),(style.density==="compact"||style.density==="comfortable"||style.density==="touch")&&(attributes["data-lr-density"]=style.density),(style.mode==="light"||style.mode==="dark"||style.mode==="system")&&(attributes["data-lr-mode"]=style.mode),style.accent!==void 0&&(attributes["data-lr-accent"]=style.accent===null?"none":style.accentName===null?"custom":typeof style.accent=="string"&&Object.hasOwn(STYLE_GEMSTONES,style.accent)?style.accent:"custom"),Object.freeze(attributes)}function readStyleState(){if(stylePersistenceFailed)return{...lastStyle};let stored;try{stored=localStorage.getItem(STORAGE_KEY)}catch{return{...lastStyle}}try{return styleFromRecord(JSON.parse(stored??"null"),!0)}catch{return{...DEFAULT_STYLE}}}function persistStyle(state){try{localStorage.setItem(STORAGE_KEY,JSON.stringify(styleRecord(state))),stylePersistenceFailed=!1}catch{stylePersistenceFailed=!0}lastStyle=state}function ownershipFor(element){const node=element;try{const existing=readStyleOwnership(node[STYLE_OWNERSHIP]);if(existing){styleOwnershipFallback.set(element,existing);try{node[STYLE_OWNERSHIP]=existing}catch{}return existing}}catch{}const fallback=styleOwnershipFallback.get(element);if(fallback)return fallback;const record={attributes:new Map,properties:new Map};styleOwnershipFallback.set(element,record);try{node[STYLE_OWNERSHIP]=record}catch{}return record}function writeStyleAttributes(element,desired){const ownership=ownershipFor(element).attributes;for(const[name,value]of ownership)Object.hasOwn(desired,name)||(element.getAttribute(name)===value.written&&(value.before===null?element.removeAttribute(name):element.setAttribute(name,value.before)),ownership.delete(name));for(const[name,value]of Object.entries(desired))ownership.has(name)||ownership.set(name,{before:element.getAttribute(name),priority:"",written:value}),element.getAttribute(name)!==value&&element.setAttribute(name,value),ownership.get(name).written=value}function writeStyleProperties(element,desired){const style=element.style;if(!style)return;const ownership=ownershipFor(element).properties;for(const[name,value]of ownership)desired.has(name)||(style.getPropertyValue(name)===value.written&&style.getPropertyPriority(name)===""&&(value.before?style.setProperty(name,value.before,value.priority):style.removeProperty(name)),ownership.delete(name));for(const[name,value]of desired){ownership.has(name)||ownership.set(name,{before:style.getPropertyValue(name),priority:style.getPropertyPriority(name),written:null});const record=ownership.get(name);(style.getPropertyPriority(name)!==""||style.getPropertyValue(name)!==value&&!(record.requested===value&&record.written===style.getPropertyValue(name)))&&(style.getPropertyPriority(name)&&style.removeProperty(name),style.setProperty(name,value,"")),record.requested=value,record.written=style.getPropertyValue(name)}}function styleSlot(name,mode,accent=!1){return`--_lr-${accent?"a":"l"}${mode==="light"?"l":"d"}-${name.slice(11)}`}function styleFollow(name,value){const channel=name.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1];return!!(channel&&value===`var(--lr-theme-color-brand-${channel})`)}function styleBranch(name,mode){let result=`var(${styleSlot(name,mode)})`;if(STYLE_FOLLOW.includes(name)){const key=mode==="light"?"l":"d",target=name.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");result=`var(--_lr-f${key}-${name.slice(11)},${result})var(--_lr-o${key}-${name.slice(11)},var(${styleSlot(target,mode,!0)},var(${styleSlot(target,mode)})))`}return ALL_RAMP_PROPERTIES.includes(name)?`var(${styleSlot(name,mode,!0)},${result})`:result}function styleResolvedInput(name){const input=`var(--_lr-dark-on,${styleBranch(name,"light")})var(--_lr-light-on,${styleBranch(name,"dark")})`;if(!STYLE_DENSITY.includes(name))return input;const spacing=name.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${input})var(--_lr-dense-off,max(calc((${input}) * var(--_lr-density-${spacing?"space":"control"},1)),${spacing?"0px":"var(--_lr-density-target-min,0px)"}))`}function styleReferences(state,entries,mode,element,previous){const look=element.closest("[data-lr-look]")?.getAttribute("data-lr-look"),colors=(STYLE_REFERENCE_SURFACES[look??STYLE_DEFAULTS.look]??STYLE_REFERENCE_SURFACES.lyra)[mode],names=["color-surface-default","color-surface-raised","color-text-normal","color-overlay-strong"].slice(0,entries.size?4:1).map(suffix=>`--lr-theme-${suffix}`),supplied=names.map(name=>entries.get(name)),background=typeof state.accentBackground=="string"?state.accentBackground:state.accentBackground?.[mode],style=element.style,ownership=ownershipFor(element).properties,projected=names.flatMap((name,index)=>{const slot=styleSlot(name,mode),owned=ownership.get(slot),before=style?.getPropertyValue(slot)??"",priority=style?.getPropertyPriority(slot)??"",owns=owned&&before===owned.written&&!priority;if(supplied[index]!==void 0&&previous?.[index]===supplied[index]&&owns)return[];if(supplied[index]===void 0&&!owns)return[];const value=supplied[index]??owned?.before??"",nextPriority=supplied[index]===void 0?owned?.priority??"":"";return before===value&&priority===nextPriority?[]:[{slot,before,priority,value,nextPriority}]});try{for(const{slot,value,nextPriority}of projected)style.getPropertyPriority(slot)&&style.removeProperty(slot),value?style.setProperty(slot,value,nextPriority):style.removeProperty(slot);const computed=element.ownerDocument.defaultView?.getComputedStyle(element);return{supplied,colors:names.map((name,index)=>(index===0?background:void 0)??supplied[index]??(computed?.getPropertyValue(styleSlot(name,mode)).trim()||colors[index]))}}finally{for(const{slot,before,priority}of projected)style.getPropertyPriority(slot)&&style.removeProperty(slot),before?style.setProperty(slot,before,priority):style.removeProperty(slot)}}const stylePaintCache=new WeakMap;function stylePaint(state,element,wholeDocument){const desired=new Map,mode=styleResolvedMode(state.mode,element.ownerDocument.defaultView),tokens={...state.tokens,...state.overrides};if(wholeDocument&&mode===null)for(const[name,value]of tokenEntries(tokens,null))desired.set(name,value);if(!Object.keys(tokens).length&&(!state.accent||state.accentName))return stylePaintCache.delete(element),desired;const resolver=element.ownerDocument.defaultView?.getComputedStyle(element).getPropertyValue("--_lr-style-resolver").trim()==="1";let cache=stylePaintCache.get(element);cache||(cache=new Map,stylePaintCache.set(element,cache));let applied=state.accent;for(const branch of["light","dark"]){const entries=tokenEntries(tokens,branch),{colors:references,supplied}=styleReferences(state,entries,branch,element,cache.get(branch)?.supplied),reference=references[0],key=JSON.stringify([tokens,state.accent,state.accentName,references]);let cached=cache.get(branch);if(!cached||cached.key!==key){const background=reference?parseResolvedRgb(reference,MODE_SURFACES[branch],element.ownerDocument)??MODE_SURFACES[branch]:MODE_SURFACES[branch],accent=state.accentName?{applied:state.accent,properties:new Map}:paintAccent(state.accent,branch,background,element.ownerDocument);cached={key,supplied,tokens:floorTokenEntries(entries,background,element.ownerDocument,references),accent:accent.properties,applied:accent.applied},cache.set(branch,cached)}branch===mode&&(applied=cached.applied);const painted=cached.tokens;for(const[name,value]of painted)STYLE_SLOTTED.includes(name)&&styleTokenAllowed(name,value)?(styleFollow(name,value)?(desired.set(`--_lr-f${branch==="light"?"l":"d"}-${name.slice(11)}`," "),desired.set(`--_lr-o${branch==="light"?"l":"d"}-${name.slice(11)}`,"initial")):(desired.set(styleSlot(name,branch),value),STYLE_FOLLOW.includes(name)&&(desired.set(`--_lr-f${branch==="light"?"l":"d"}-${name.slice(11)}`,"initial"),desired.set(`--_lr-o${branch==="light"?"l":"d"}-${name.slice(11)}`," "))),wholeDocument&&branch===mode&&desired.set(name,resolver?styleResolvedInput(name):value)):(wholeDocument?branch===mode:typeof tokens[name]=="string"&&!STYLE_SLOTTED.includes(name))&&desired.set(name,value);if(state.accent&&!state.accentName)for(const[name,value]of cached.accent){if(name==="--lr-theme-accent"){branch===mode&&desired.set(name,value);continue}desired.set(styleSlot(name,branch,!0),value),wholeDocument&&branch===mode&&desired.set(name,resolver?styleResolvedInput(name):value)}}return state.accent=applied,desired}const styleModeGroups=new WeakMap;function attachStyleMode(element,callback){const view=element.ownerDocument.defaultView;if(!view?.matchMedia)return()=>{};let group=styleModeGroups.get(view);if(!group){const query=view.matchMedia(COLOR_SCHEME_QUERY),subscriptions=new Set,modern=typeof query.addEventListener=="function"&&typeof query.removeEventListener=="function",detach=()=>{modern?query.removeEventListener("change",listener):query.removeListener?.(listener)},listener=()=>{for(const subscription2 of subscriptions){const node=subscription2.element.deref();node?.ownerDocument.defaultView===view?subscription2.callback(node):subscriptions.delete(subscription2)}subscriptions.size||(detach(),styleModeGroups.delete(view))};group={query,subscriptions,detach},styleModeGroups.set(view,group),modern?query.addEventListener("change",listener):query.addListener?.(listener)}const subscription={element:new WeakRef(element),callback};group.subscriptions.add(subscription);const active=group;return()=>{active.subscriptions.delete(subscription),active.subscriptions.size||(active.detach(),styleModeGroups.delete(view))}}function applyStyleState(element,state,fields){const snapshot=styleSnapshot(state,element.ownerDocument.defaultView),attributes={...lyraStyleAttributes(snapshot)};if(fields)for(const[field,name]of[["look","look"],["surface","surface"],["density","density"],["mode","mode"],["accent","accent"]])fields.has(field)||delete attributes[`data-lr-${name}`];state.accent&&!state.accentName&&(!fields||fields.has("accent"))&&(attributes["data-lr-accent"]="custom"),(!fields||fields.has("mode"))&&snapshot.resolvedMode&&(attributes["data-lr-theme"]=snapshot.resolvedMode,attributes["data-theme"]=snapshot.resolvedMode),(state.tokens||state.overrides||state.accent&&!state.accentName)&&(attributes["data-lr-theme-scope"]=""),writeStyleAttributes(element,attributes);const desired=stylePaint(state,element,!fields);(!fields||fields.has("surface"))&&element.ownerDocument.defaultView?.getComputedStyle(element).getPropertyValue("--_lr-style-resolver").trim()!=="1"&&styleMaterial(desired,state.surface),!state.accent&&snapshot.accent&&(attributes["data-lr-accent"]="none",!state.tokens&&!state.overrides&&delete attributes["data-lr-theme-scope"],writeStyleAttributes(element,attributes)),writeStyleProperties(element,desired),diagnoseStyleSheets(element,state,fields)}function diagnoseStyleSheets(element,state,fields){if(!litDevWarnings())return;const selected=field=>!fields||fields.has(field),required=[];selected("look")&&!state.tokens&&state.look!=="lyra"&&state.look!==DEFAULT_STYLE.look&&required.push(["--_lr-look-installed",`${state.look}-1`,`the stylesheet for look '${state.look}'`]),selected("surface")&&state.surface==="glass"&&state.surface!==DEFAULT_STYLE.surface&&required.push(["--_lr-surface-installed","1","surfaces/glass.css"]),selected("density")&&state.density!=="comfortable"&&required.push(["--_lr-density-installed","1","density.css"]),selected("accent")&&state.accentName&&state.accentName!==DEFAULT_STYLE.accentName&&required.push(["--_lr-accent-installed",`${state.accentName}-1`,"accents.css"]);const scopedRuntime=!!(fields&&(state.tokens||state.overrides||state.accent&&!state.accentName)),alternateProfile=selected("look")&&!state.tokens&&state.look!==DEFAULT_STYLE.look||selected("accent")&&!state.accent;if(!required.length&&!scopedRuntime&&!alternateProfile)return;const computed=element.ownerDocument.defaultView?.getComputedStyle(element);if(computed){computed.getPropertyValue("--_lr-style-resolver").trim()!=="1"&&devWarnOnce("lyra-style:resolver","Lyra style choices require theme.css in the scope that owns their attributes.");for(const[property,expected,stylesheet]of required)computed.getPropertyValue(property).trim()!==expected&&devWarnOnce(`lyra-style:${property}:${expected}`,`Lyra could not find ${stylesheet} in this style scope; import or adopt the stylesheet before selecting it.`)}}function emitStyleChange(state,changed){const style=styleSnapshot(state,window);window.dispatchEvent(new CustomEvent("lr-style-change",{detail:Object.freeze({style,changed:Object.freeze([...changed])})}))}function setLyraStyle(choices){const before=readStyleState();return commitStyle(before,normalizeStyleChoices(choices,before))}function commitStyle(before,next){if(typeof document<"u"&&(next.accent=normalizeAccent(next.accent),typeof next.accentBackground=="string"&&(next.accentBackground=normalizeColor(next.accentBackground)),next.accent||(next.accentName=null)),persistStyle(next),typeof document<"u"){const root=document.documentElement;(next.mode!=="system"||styleModeRoot?.deref()!==root)&&(styleModeCleanup?.(),styleModeCleanup=void 0,styleModeRoot=void 0),adoptLegacyOwnership(root);const requestedAccent=next.accent;applyStyleState(root,next),accentsEqual(requestedAccent,next.accent)||persistStyle(next),next.mode==="system"&&!styleModeCleanup&&(styleModeRoot=new WeakRef(root),styleModeCleanup=attachStyleMode(root,element=>{applyStyleState(element,lastStyle),emitStyleChange(lastStyle,["resolvedMode"])}));const changed=STYLE_FIELDS.filter(field=>field==="look"?before.look!==next.look||!tokensEqual(before.tokens,next.tokens):field==="accent"?before.accentName!==next.accentName||!accentsEqual(before.accent,next.accent):JSON.stringify(before[field])!==JSON.stringify(next[field]));emitStyleChange(next,changed)}return styleSnapshot(next,typeof window>"u"?void 0:window)}function adoptLegacyOwnership(root){const symbol=Symbol.for(TOKEN_OWNERSHIP_SYMBOL),node=root;try{if(!Array.isArray(node[symbol]))return}catch{return}const ownership=ownershipFor(root).properties;for(const name of[...readOwnershipList(),...ALL_RAMP_PROPERTIES,"--lr-theme-accent"])ownership.has(name)||!root.style.getPropertyValue(name)||ownership.set(name,{before:null,priority:"",written:root.style.getPropertyValue(name)});try{delete node[symbol]}catch{}}function getLyraStyle(){return styleSnapshot(readStyleState(),typeof window>"u"?void 0:window)}function resetLyraStyle(fields=STYLE_FIELDS){const defaults={...STYLE_DEFAULTS,accentBackground:null,overrides:null};return setLyraStyle(Object.fromEntries(fields.filter(field=>STYLE_FIELDS.includes(field)).map(field=>[field,defaults[field]])))}function applyLyraStyleScope(element,choices){if(scopeModes.get(element)?.(),scopeModes.delete(element),choices===null){writeStyleAttributes(element,{}),writeStyleProperties(element,new Map);return}const state=normalizeStyleChoices(choices,{...DEFAULT_STYLE}),fields=new Set(STYLE_FIELDS.filter(field=>ownField(choices,field)!==void 0));applyStyleState(element,state,fields),choices.mode==="system"&&scopeModes.set(element,attachStyleMode(element,node=>applyStyleState(node,state,fields)))}const lyraThemeBootstrap=createLyraThemeBootstrap();export{accentsEqual,applyLyraStyleScope,createLyraThemeBootstrap,defineLyraLook,getLyraStyle,isLyraThemeTokenName,isSafeLyraThemeTokenValue,lyraStyleAttributes,lyraThemeBootstrap,parseLyraStyleRecord,resetLyraStyle,setLyraStyle,tokensEqual};
|