@aceshooting/lyra-ui 31.0.0 → 31.1.1
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 +129 -0
- package/dist/autoloader-cdn.js +1 -1
- package/dist/components/agent-tools/budget-meter/budget-meter.class.d.ts +12 -1
- package/dist/components/agent-tools/budget-meter/budget-meter.class.js +4 -4
- package/dist/components/charts/chart/lite-chart.class.js +1 -1
- package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +18 -8
- package/dist/components/conversation/chat-composer/chat-composer.class.js +11 -9
- package/dist/components/conversation/chat-composer/chat-composer.styles.js +1 -1
- package/dist/components/conversation/message-feedback/message-feedback.class.d.ts +11 -3
- package/dist/components/conversation/message-feedback/message-feedback.class.js +12 -6
- package/dist/components/conversation/message-feedback/message-feedback.styles.js +1 -1
- package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +6 -3
- package/dist/components/conversation/prompt-input/prompt-input.class.js +3 -2
- package/dist/components/conversation/push-to-talk/push-to-talk.class.js +1 -1
- package/dist/components/conversation/thread-list/thread-list.class.d.ts +1 -1
- package/dist/components/conversation/thread-list/thread-list.class.js +2 -2
- package/dist/components/data/document-library/document-library-cursor.js +1 -0
- package/dist/components/data/document-library/document-library-types.d.ts +20 -0
- package/dist/components/data/document-library/document-library.class.d.ts +37 -26
- package/dist/components/data/document-library/document-library.class.js +20 -11
- package/dist/components/data/document-library/document-library.styles.js +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.d.ts +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.js +1 -1
- package/dist/components/data/timeline/timeline.class.js +1 -1
- package/dist/components/forms/combobox/combobox.class.d.ts +20 -12
- package/dist/components/forms/combobox/combobox.class.js +2 -2
- package/dist/components/layout/dock-panel/dock-panel.class.d.ts +1 -1
- package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
- package/dist/components/layout/page/page.class.d.ts +3 -3
- package/dist/components/layout/page/page.class.js +1 -1
- package/dist/components/layout/segmented/segmented.class.d.ts +20 -7
- package/dist/components/layout/segmented/segmented.class.js +34 -24
- package/dist/components/layout/segmented/segmented.styles.js +1 -1
- package/dist/components/layout/stepper/stepper.styles.js +1 -1
- package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
- package/dist/components/media/map/map-anchor-controller.js +1 -1
- package/dist/components/media/map/map-canvas-target.js +1 -0
- package/dist/components/media/map/map.class.d.ts +10 -1
- package/dist/components/media/map/map.class.js +4 -4
- package/dist/components/media/map/map.styles.js +1 -1
- package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +21 -9
- package/dist/components/media/sequence-playback/sequence-playback.class.js +7 -6
- package/dist/components/media/sequence-playback/sequence-playback.styles.js +1 -1
- package/dist/components/overlays/overlay/overlay.styles.js +1 -1
- package/dist/components/retrieval/graph/graph-spatial-controller.js +1 -1
- package/dist/components/retrieval/graph/graph.class.js +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue-presentation.d.ts +11 -0
- package/dist/components/retrieval/ingestion-queue/ingestion-queue-presentation.js +1 -0
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +18 -7
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +13 -26
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.styles.js +1 -1
- package/dist/components/utility/diff-view/diff-view.class.d.ts +5 -5
- package/dist/components/utility/diff-view/diff-view.class.js +1 -1
- package/dist/components/utility/icon/icon.class.js +1 -1
- package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
- package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
- package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
- package/dist/components/viewers/document-preview/document-preview.class.js +2 -2
- package/dist/components/viewers/docx-viewer/docx-viewer.class.d.ts +1 -1
- package/dist/components/viewers/docx-viewer/docx-viewer.class.js +1 -1
- package/dist/components/viewers/email-viewer/email-viewer.class.d.ts +1 -1
- package/dist/components/viewers/email-viewer/email-viewer.class.js +2 -2
- package/dist/components/viewers/html-viewer/html-viewer.class.js +1 -1
- package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +2 -2
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +1 -1
- package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +1 -1
- package/dist/components/viewers/svg-viewer/svg-viewer.class.js +1 -1
- package/dist/components/viewers/xml-viewer/xml-viewer.class.js +2 -2
- package/dist/data-sources.d.ts +10 -0
- package/dist/events.d.ts +9 -4
- package/dist/framework-types.d.ts +1 -1
- package/dist/internal/default-strings/conversation.generated.js +1 -1
- package/dist/internal/default-strings/data.generated.js +1 -1
- package/dist/internal/default-strings/retrieval.generated.js +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +1 -1
- package/dist/internal/lyra-element.js +2 -2
- package/dist/internal/native-modal-context.js +1 -1
- package/dist/internal/overlay-manager.js +1 -1
- package/dist/internal/overlay-order.js +1 -1
- package/dist/internal/overlay-stack.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/runtime-diagnostics.js +1 -0
- package/dist/internal/source-cursor-controller.js +1 -0
- package/dist/internal/source-cursor-projection.js +1 -0
- package/dist/internal/source-page-scope.js +1 -1
- package/dist/lyra.d.ts +1 -1
- package/dist/theme/theme-bootstrap.js +1 -1
- package/dist/theme/theme.js +1 -1
- package/dist/utilities/overlay-manager.d.ts +2 -0
- package/llms/components/lr-budget-meter.md +31 -0
- package/llms/components/lr-chat-composer.md +13 -2
- package/llms/components/lr-combobox.md +27 -1
- package/llms/components/lr-diff-view.md +6 -0
- package/llms/components/lr-document-library.md +90 -6
- package/llms/components/lr-graph.md +5 -0
- package/llms/components/lr-ingestion-queue.md +76 -8
- package/llms/components/lr-json-viewer.md +34 -0
- package/llms/components/lr-lite-chart.md +2 -1
- package/llms/components/lr-map.md +33 -0
- package/llms/components/lr-message-feedback.md +38 -3
- package/llms/components/lr-page.md +4 -2
- package/llms/components/lr-prompt-input.md +5 -2
- package/llms/components/lr-segmented.md +30 -10
- package/llms/components/lr-sequence-playback.md +47 -12
- package/llms/components/lr-virtual-list.md +3 -1
- package/llms/peers.md +2 -2
- package/llms/shared/events-and-types.md +61 -2
- package/llms/shared/forms-and-accessibility.md +25 -0
- package/llms/shared/imports-and-registration.md +154 -110
- package/llms/shared/testing-and-utilities.md +5 -1
- package/llms/shared.md +245 -113
- package/locales.json +1 -1
- package/package.json +8 -8
- package/registrations.json +1 -1
package/dist/theme/theme.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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.createElementNS("http://www.w3.org/1999/xhtml","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.createElementNS("http://www.w3.org/1999/xhtml","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 hexRgb(color){return[parseInt(color.slice(1,3),16),parseInt(color.slice(3,5),16),parseInt(color.slice(5,7),16)]}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].map(hexRgb),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(U,q,D,R,G,J,W,S){const{surfaces:_,contrast:H,accent:Q}=S,b=new Map;for(const r of S.inputs.split(" "))b.set(`--lr-theme-${r.slice(1)}`,Number(r[0]));const A=[...b.keys()];function v(r,n,s=!1){return`--_lr-${s?"a":"l"}${n==="light"?"l":"d"}-${r.slice(11)}`}function V(r,n){const s=b.get(r)??0;let g=`var(${v(r,n)})`;if(s&2){const k=n==="light"?"l":"d",u=r.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");g=`var(--_lr-f${k}-${r.slice(11)},${g})var(--_lr-o${k}-${r.slice(11)},var(${v(u,n,!0)},var(${v(u,n)})))`}return s&4?`var(${v(r,n,!0)},${g})`:g}function X(r){const n=`var(--_lr-dark-on,${V(r,"light")})var(--_lr-light-on,${V(r,"dark")})`;if(!((b.get(r)??0)&1))return n;const s=r.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${n})var(--_lr-dense-off,max(calc((${n}) * var(--_lr-density-${s?"space":"control"},1)),${s?"0px":"var(--_lr-density-target-min,0px)"}))`}try{const r=document.currentScript,n=r?.getAttribute("data-lr-theme-restore"),s=(n==="all"||n==="mode"?n:S.restore)==="mode",g=r?.getAttribute("data-lr-theme-storage-key"),k=g&&g.length<=200?g:U,u=r?.getAttribute("data-lr-theme-attributes")?.trim().split(/\s+/),E=u?.length&&u.length<=8&&new Set(u).size===u.length&&u.every(t=>t.length<=64&&/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(t))?u:q;let w;try{w=JSON.parse(localStorage.getItem(k)??"null")}catch{}if(s){const t=w;w={version:t?.version,mode:t?.mode}}const o=document.documentElement,[Z,tt,et]=D(),f=J(w,S.defaults,Z,tt,(t,e)=>R(t,e,A),Q),y=f.mode,$=y==="unset"?null:y==="system"?matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":y,p={},C=!s&&getComputedStyle(o).getPropertyValue("--_lr-style-resolver").trim()==="1",L=(t,e)=>typeof t=="string"?t:t?.[e],rt=f.tokens,ot=f.overrides,O={...rt,...ot},T=f.look;if(s||(p["data-lr-look"]=T,p["data-lr-density"]=f.density,p["data-lr-surface"]=f.treatment),y!=="unset"&&(p["data-lr-mode"]=y),$)for(const t of E)p[t]=$;const z=f.accentName;let h=f.accent;y!=="unset"&&h&&typeof h=="object"&&!Object.values(h).some(t=>typeof t=="string"||t&&Object.values(t).some(Boolean))&&(h=null),s||(p["data-lr-accent"]=z??(h?"custom":"none"));const a=new Map;if(y==="unset")for(const[t,e]of Object.entries(O))typeof e=="string"&&a.set(t,e);for(const t of s?[]:["light","dark"]){const e=L(f.surface,t),j=L(O["--lr-theme-color-surface-default"],t),c=(Object.hasOwn(_,T)?_[T]:_.lyra)[t],M=e??j??c[0];for(const m of[!1,!0]){if(m&&(!h||z))continue;const st=et(m?{}:O,t,M,m?h:null,m?H[t].map(l=>[1,3,5].map(d=>parseInt(l.slice(d,d+2),16))):[],c);for(const[l,d]of st){if(l==="--lr-theme-accent"){t===$&&a.set(l,d);continue}const B=b.get(l);if(B!==void 0&&R(l,d,A)){const F=l.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1],N=!m&&F&&d===`var(--lr-theme-color-brand-${F})`,I=l.slice(11),K=t==="light"?"l":"d";N||a.set(v(l,t,m),d),!m&&B&2&&(a.set(`--_lr-f${K}-${I}`,N?" ":"initial"),a.set(`--_lr-o${K}-${I}`,N?"initial":" ")),t===$&&a.set(l,C?X(l):d)}else t===$&&a.set(l,d)}}}(a.size||y==="unset"&&h&&!z)&&(p["data-lr-theme-scope"]=""),!s&&!C&&W(a,f.treatment);const Y=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),P=o;let x;try{x=G(P[Y])}catch{}const i=x??{attributes:new Map,properties:new Map};if(y==="unset")for(const t of E)i.attributes.has(t)||o.removeAttribute(t);try{const t=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),e=P[t];if(!s&&Array.isArray(e)){const j=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[...j,...A.filter(M=>b.get(M)&4),"--lr-theme-accent"])!i.properties.has(c)&&o.style.getPropertyValue(c)&&i.properties.set(c,{before:null,priority:"",written:o.style.getPropertyValue(c)});try{delete P[t]}catch{}}}catch{}for(const[t,e]of i.attributes)s&&t!=="data-lr-mode"&&!E.includes(t)||Object.hasOwn(p,t)||(o.getAttribute(t)===e.written&&(e.before===null?o.removeAttribute(t):o.setAttribute(t,e.before)),i.attributes.delete(t));for(const[t,e]of Object.entries(p))i.attributes.has(t)||i.attributes.set(t,{before:o.getAttribute(t),priority:"",written:e}),o.setAttribute(t,e),i.attributes.get(t).written=e;for(const[t,e]of i.properties)s||a.has(t)||(o.style.getPropertyValue(t)===e.written&&!o.style.getPropertyPriority(t)&&(e.before?o.style.setProperty(t,e.before,e.priority):o.style.removeProperty(t)),i.properties.delete(t));for(const[t,e]of a)i.properties.has(t)||i.properties.set(t,{before:o.style.getPropertyValue(t),priority:o.style.getPropertyPriority(t),written:null}),o.style.getPropertyPriority(t)&&o.style.removeProperty(t),o.style.setProperty(t,e,""),i.properties.get(t).written=o.style.getPropertyValue(t);try{P[Y]=i}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")}const BOOTSTRAP_FUNCTIONS=[applyStoredStyleBeforePaint,applyStoredThemeBeforePaint,styleTokenAllowed,readStyleOwnership,resolveStyleStartup,styleMaterial];function bootstrapParts(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({restore:options.restore==="mode"?"mode":"all",defaults:STYLE_DEFAULTS,inputs,surfaces:STYLE_REFERENCE_SURFACES,contrast:STYLE_CONTRAST_SURFACES,accent:STYLE_GEMSTONES});return{storageKey,model}}function createLyraThemeBootstrap(options={}){const{storageKey,model}=bootstrapParts(options),functions=BOOTSTRAP_FUNCTIONS.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,detachedStyleOwnership=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 publishStyleOwnership(element,ownership){const descriptor=Object.getOwnPropertyDescriptor(element,STYLE_OWNERSHIP);return descriptor&&(!("value"in descriptor)||!descriptor.writable)?!1:Reflect.defineProperty(element,STYLE_OWNERSHIP,{value:ownership,writable:!0,enumerable:descriptor?.enumerable??!0,configurable:descriptor?.configurable??!0})}function ownershipFor(element){const node=element;try{const source=node[STYLE_OWNERSHIP],detached=detachedStyleOwnership.get(element);if(detached&&detached.source===source)return detached.ownership;detachedStyleOwnership.delete(element);const existing=readStyleOwnership(source);if(existing){styleOwnershipFallback.set(element,existing);try{publishStyleOwnership(element,existing)||detachedStyleOwnership.set(element,{source,ownership:existing})}catch{detachedStyleOwnership.set(element,{source,ownership:existing})}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{publishStyleOwnership(element,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")??STYLE_DEFAULTS.look,colors=(Object.hasOwn(STYLE_REFERENCE_SURFACES,look)?STYLE_REFERENCE_SURFACES[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;if(!element.style)return desired;const 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),adoptTokenLayerForScope(element),diagnoseStyleSheets(element,state,fields)}function adoptTokenLayerForScope(element){const root=element.getRootNode();if(root===element.ownerDocument||root.nodeType!==11)return;const adopt=globalThis[Symbol.for("@aceshooting/lyra-ui.adopt-lyra-tokens.v1")];typeof adopt=="function"&&adopt(root)}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,profile=[];if(selected("look")&&!state.tokens&&state.look===DEFAULT_STYLE.look&&profile.push(["--_lr-look-installed",`${state.look}-1`,`the stylesheet for look '${state.look}'`]),selected("surface")&&state.surface==="glass"&&profile.push(["--_lr-surface-installed","1","surfaces/glass.css"]),selected("accent")&&state.accentName===DEFAULT_STYLE.accentName&&profile.push(["--_lr-accent-installed",`${state.accentName}-1`,"accents.css"]),!required.length&&!profile.length&&!scopedRuntime&&!alternateProfile)return;const computed=element.ownerDocument.defaultView?.getComputedStyle(element);if(computed){computed.getPropertyValue("--_lr-style-resolver").trim()!=="1"?(required.length||scopedRuntime||alternateProfile)&&devWarnOnce("lyra-style:resolver","Lyra style choices require theme.css in the scope that owns their attributes."):required.push(...profile);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"){applyRootStyle(next)&&persistStyle(next);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 applyRootStyle(next){const root=document.documentElement;(next.mode!=="system"||styleModeRoot?.deref()!==root)&&(styleModeCleanup?.(),styleModeCleanup=void 0,styleModeRoot=void 0),adoptLegacyOwnership(root);const requestedAccent=next.accent;return applyStyleState(root,next),next.mode==="system"&&!styleModeCleanup&&(styleModeRoot=new WeakRef(root),styleModeCleanup=attachStyleMode(root,element=>{applyStyleState(element,lastStyle),emitStyleChange(lastStyle,["resolvedMode"])})),!accentsEqual(requestedAccent,next.accent)}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 startLyraStyle(){const state=readStyleState();return typeof document>"u"?styleSnapshot(state):(state.accent=normalizeAccent(state.accent),typeof state.accentBackground=="string"&&(state.accentBackground=normalizeColor(state.accentBackground)),state.accent||(state.accentName=null),lastStyle=state,applyRootStyle(state),styleSnapshot(state,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=/* @__PURE__ */createLyraThemeBootstrap();export{accentsEqual,applyLyraStyleScope,createLyraThemeBootstrap,defineLyraLook,getLyraStyle,isLyraThemeTokenName,isSafeLyraThemeTokenValue,lyraStyleAttributes,lyraThemeBootstrap,parseLyraStyleRecord,resetLyraStyle,setLyraStyle,startLyraStyle,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.createElementNS("http://www.w3.org/1999/xhtml","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.createElementNS("http://www.w3.org/1999/xhtml","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 hexRgb(color){return[parseInt(color.slice(1,3),16),parseInt(color.slice(3,5),16),parseInt(color.slice(5,7),16)]}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].map(hexRgb),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]*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]*.2126+n[1]*.7152+n[2]*.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(U,q,D,R,G,J,W,S){const{surfaces:_,contrast:H,accent:Q}=S,b=new Map;for(const r of S.inputs.split(" "))b.set(`--lr-theme-${r.slice(1)}`,Number(r[0]));const A=[...b.keys()];function v(r,n,s=!1){return`--_lr-${s?"a":"l"}${n==="light"?"l":"d"}-${r.slice(11)}`}function V(r,n){const s=b.get(r)??0;let g=`var(${v(r,n)})`;if(s&2){const k=n==="light"?"l":"d",u=r.replace(/color-(?:success|warning|danger|neutral)-/,"color-brand-");g=`var(--_lr-f${k}-${r.slice(11)},${g})var(--_lr-o${k}-${r.slice(11)},var(${v(u,n,!0)},var(${v(u,n)})))`}return s&4?`var(${v(r,n,!0)},${g})`:g}function X(r){const n=`var(--_lr-dark-on,${V(r,"light")})var(--_lr-light-on,${V(r,"dark")})`;if(!((b.get(r)??0)&1))return n;const s=r.startsWith("--lr-theme-space-");return`var(--_lr-dense-on,${n})var(--_lr-dense-off,max(calc((${n}) * var(--_lr-density-${s?"space":"control"},1)),${s?"0px":"var(--_lr-density-target-min,0px)"}))`}try{const r=document.currentScript,n=r?.getAttribute("data-lr-theme-restore"),s=(n==="all"||n==="mode"?n:S.restore)==="mode",g=r?.getAttribute("data-lr-theme-storage-key"),k=g&&g.length<=200?g:U,u=r?.getAttribute("data-lr-theme-attributes")?.trim().split(/\s+/),E=u?.length&&u.length<=8&&new Set(u).size===u.length&&u.every(t=>t.length<=64&&/^data-[a-z0-9]+(?:-[a-z0-9]+)*$/.test(t))?u:q;let w;try{w=JSON.parse(localStorage.getItem(k)??"null")}catch{}if(s){const t=w;w={version:t?.version,mode:t?.mode}}const o=document.documentElement,[Z,tt,et]=D(),f=J(w,S.defaults,Z,tt,(t,e)=>R(t,e,A),Q),y=f.mode,$=y==="unset"?null:y==="system"?matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":y,p={},C=!s&&getComputedStyle(o).getPropertyValue("--_lr-style-resolver").trim()==="1",L=(t,e)=>typeof t=="string"?t:t?.[e],rt=f.tokens,ot=f.overrides,O={...rt,...ot},T=f.look;if(s||(p["data-lr-look"]=T,p["data-lr-density"]=f.density,p["data-lr-surface"]=f.treatment),y!=="unset"&&(p["data-lr-mode"]=y),$)for(const t of E)p[t]=$;const z=f.accentName;let h=f.accent;y!=="unset"&&h&&typeof h=="object"&&!Object.values(h).some(t=>typeof t=="string"||t&&Object.values(t).some(Boolean))&&(h=null),s||(p["data-lr-accent"]=z??(h?"custom":"none"));const a=new Map;if(y==="unset")for(const[t,e]of Object.entries(O))typeof e=="string"&&a.set(t,e);for(const t of s?[]:["light","dark"]){const e=L(f.surface,t),j=L(O["--lr-theme-color-surface-default"],t),c=(Object.hasOwn(_,T)?_[T]:_.lyra)[t],M=e??j??c[0];for(const m of[!1,!0]){if(m&&(!h||z))continue;const st=et(m?{}:O,t,M,m?h:null,m?H[t].map(l=>[1,3,5].map(d=>parseInt(l.slice(d,d+2),16))):[],c);for(const[l,d]of st){if(l==="--lr-theme-accent"){t===$&&a.set(l,d);continue}const B=b.get(l);if(B!==void 0&&R(l,d,A)){const F=l.match(/^--lr-theme-color-(?:success|warning|danger|neutral)-((?:fill|border|on)-(?:quiet|normal|loud))$/)?.[1],N=!m&&F&&d===`var(--lr-theme-color-brand-${F})`,I=l.slice(11),K=t==="light"?"l":"d";N||a.set(v(l,t,m),d),!m&&B&2&&(a.set(`--_lr-f${K}-${I}`,N?" ":"initial"),a.set(`--_lr-o${K}-${I}`,N?"initial":" ")),t===$&&a.set(l,C?X(l):d)}else t===$&&a.set(l,d)}}}(a.size||y==="unset"&&h&&!z)&&(p["data-lr-theme-scope"]=""),!s&&!C&&W(a,f.treatment);const Y=Symbol.for("@aceshooting/lyra-ui.style-ownership.v1"),P=o;let x;try{x=G(P[Y])}catch{}const i=x??{attributes:new Map,properties:new Map};if(y==="unset")for(const t of E)i.attributes.has(t)||o.removeAttribute(t);try{const t=Symbol.for("@aceshooting/lyra-ui.theme-tokens.v1"),e=P[t];if(!s&&Array.isArray(e)){const j=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[...j,...A.filter(M=>b.get(M)&4),"--lr-theme-accent"])!i.properties.has(c)&&o.style.getPropertyValue(c)&&i.properties.set(c,{before:null,priority:"",written:o.style.getPropertyValue(c)});try{delete P[t]}catch{}}}catch{}for(const[t,e]of i.attributes)s&&t!=="data-lr-mode"&&!E.includes(t)||Object.hasOwn(p,t)||(o.getAttribute(t)===e.written&&(e.before===null?o.removeAttribute(t):o.setAttribute(t,e.before)),i.attributes.delete(t));for(const[t,e]of Object.entries(p))i.attributes.has(t)||i.attributes.set(t,{before:o.getAttribute(t),priority:"",written:e}),o.setAttribute(t,e),i.attributes.get(t).written=e;for(const[t,e]of i.properties)s||a.has(t)||(o.style.getPropertyValue(t)===e.written&&!o.style.getPropertyPriority(t)&&(e.before?o.style.setProperty(t,e.before,e.priority):o.style.removeProperty(t)),i.properties.delete(t));for(const[t,e]of a)i.properties.has(t)||i.properties.set(t,{before:o.style.getPropertyValue(t),priority:o.style.getPropertyPriority(t),written:null}),o.style.getPropertyPriority(t)&&o.style.removeProperty(t),o.style.setProperty(t,e,""),i.properties.get(t).written=o.style.getPropertyValue(t);try{P[Y]=i}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")}const BOOTSTRAP_FUNCTIONS=[applyStoredStyleBeforePaint,applyStoredThemeBeforePaint,styleTokenAllowed,readStyleOwnership,resolveStyleStartup,styleMaterial];function bootstrapParts(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({restore:options.restore==="mode"?"mode":"all",defaults:STYLE_DEFAULTS,inputs,surfaces:STYLE_REFERENCE_SURFACES,contrast:STYLE_CONTRAST_SURFACES,accent:STYLE_GEMSTONES});return{storageKey,model}}function createLyraThemeBootstrap(options={}){const{storageKey,model}=bootstrapParts(options),functions=BOOTSTRAP_FUNCTIONS.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,detachedStyleOwnership=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 publishStyleOwnership(element,ownership){const descriptor=Object.getOwnPropertyDescriptor(element,STYLE_OWNERSHIP);return descriptor&&(!("value"in descriptor)||!descriptor.writable)?!1:Reflect.defineProperty(element,STYLE_OWNERSHIP,{value:ownership,writable:!0,enumerable:descriptor?.enumerable??!0,configurable:descriptor?.configurable??!0})}function ownershipFor(element){const node=element;try{const source=node[STYLE_OWNERSHIP],detached=detachedStyleOwnership.get(element);if(detached&&detached.source===source)return detached.ownership;detachedStyleOwnership.delete(element);const existing=readStyleOwnership(source);if(existing){styleOwnershipFallback.set(element,existing);try{publishStyleOwnership(element,existing)||detachedStyleOwnership.set(element,{source,ownership:existing})}catch{detachedStyleOwnership.set(element,{source,ownership:existing})}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{publishStyleOwnership(element,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")??STYLE_DEFAULTS.look,colors=(Object.hasOwn(STYLE_REFERENCE_SURFACES,look)?STYLE_REFERENCE_SURFACES[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;if(!element.style)return desired;const 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),adoptTokenLayerForScope(element),diagnoseStyleSheets(element,state,fields)}function adoptTokenLayerForScope(element){const root=element.getRootNode();if(root===element.ownerDocument||root.nodeType!==11)return;const adopt=globalThis[Symbol.for("@aceshooting/lyra-ui.adopt-lyra-tokens.v1")];typeof adopt=="function"&&adopt(root)}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,profile=[];if(selected("look")&&!state.tokens&&state.look===DEFAULT_STYLE.look&&profile.push(["--_lr-look-installed",`${state.look}-1`,`the stylesheet for look '${state.look}'`]),selected("surface")&&state.surface==="glass"&&profile.push(["--_lr-surface-installed","1","surfaces/glass.css"]),selected("accent")&&state.accentName===DEFAULT_STYLE.accentName&&profile.push(["--_lr-accent-installed",`${state.accentName}-1`,"accents.css"]),!required.length&&!profile.length&&!scopedRuntime&&!alternateProfile)return;const computed=element.ownerDocument.defaultView?.getComputedStyle(element);if(computed){computed.getPropertyValue("--_lr-style-resolver").trim()!=="1"?(required.length||scopedRuntime||alternateProfile)&&devWarnOnce("lyra-style:resolver","Lyra style choices require theme.css in the scope that owns their attributes."):required.push(...profile);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"){applyRootStyle(next)&&persistStyle(next);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 applyRootStyle(next){const root=document.documentElement;(next.mode!=="system"||styleModeRoot?.deref()!==root)&&(styleModeCleanup?.(),styleModeCleanup=void 0,styleModeRoot=void 0),adoptLegacyOwnership(root);const requestedAccent=next.accent;return applyStyleState(root,next),next.mode==="system"&&!styleModeCleanup&&(styleModeRoot=new WeakRef(root),styleModeCleanup=attachStyleMode(root,element=>{applyStyleState(element,lastStyle),emitStyleChange(lastStyle,["resolvedMode"])})),!accentsEqual(requestedAccent,next.accent)}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 startLyraStyle(){const state=readStyleState();return typeof document>"u"?styleSnapshot(state):(state.accent=normalizeAccent(state.accent),typeof state.accentBackground=="string"&&(state.accentBackground=normalizeColor(state.accentBackground)),state.accent||(state.accentName=null),lastStyle=state,applyRootStyle(state),styleSnapshot(state,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=/* @__PURE__ */createLyraThemeBootstrap();export{accentsEqual,applyLyraStyleScope,createLyraThemeBootstrap,defineLyraLook,getLyraStyle,isLyraThemeTokenName,isSafeLyraThemeTokenValue,lyraStyleAttributes,lyraThemeBootstrap,parseLyraStyleRecord,resetLyraStyle,setLyraStyle,startLyraStyle,tokensEqual};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `activateOverlay()` — the per-document topmost-overlay stack that coordinates
|
|
3
3
|
* Escape handling, light dismiss and focus return across every overlay in the library.
|
|
4
|
+
* All components and utilities in a document must resolve to one application-owned package
|
|
5
|
+
* runtime, including lazy chunks. Equal package versions do not make separate copies coordinate.
|
|
4
6
|
*
|
|
5
7
|
* Part of the curated `@aceshooting/lyra-ui/utilities/*` surface: these re-exports are the
|
|
6
8
|
* supported entry points, and they are covered by semver. The `internal/` modules they forward to
|
|
@@ -25,6 +25,37 @@ its own localized accessible name.
|
|
|
25
25
|
|
|
26
26
|
**Heading and unit:** `headingLevel: LyraHeadingLevel = '2'` (attribute `heading-level`); an empty `label` renders no heading. The unit is passed bare to `budgetMeterValue`, so a translated message owns the spacing around `{unit}`.
|
|
27
27
|
|
|
28
|
+
**Quantity formatting:** property-only `valueFormatter?: BudgetMeterValueFormatter` uses
|
|
29
|
+
`BudgetMeterValueFormatter = (value: number, context: BudgetMeterFormatContext) => string`.
|
|
30
|
+
`BudgetMeterFormatContext { readonly locale: string; }` contains only the effective locale and is
|
|
31
|
+
frozen when passed to the callback. Both types are exported from
|
|
32
|
+
`@aceshooting/lyra-ui/components/agent-tools/budget-meter/budget-meter.class.js`.
|
|
33
|
+
The callback receives `used` and `limit`
|
|
34
|
+
independently, each normalized to a finite nonnegative number; usage is not clamped to the limit
|
|
35
|
+
before formatting. It must be synchronous and side-effect-free. Return nonblank plain text of at
|
|
36
|
+
most 65,536 UTF-16 code units per quantity. Text is escaped normally, never interpreted as markup.
|
|
37
|
+
|
|
38
|
+
The same accepted pair feeds visible value text and `aria-valuetext`. The localized
|
|
39
|
+
`budgetMeterValue` sentence and optional `unit` still wrap those strings; omit `unit` when each
|
|
40
|
+
formatted quantity already includes one. Numeric ARIA values, percentage, fill clamping and
|
|
41
|
+
exceeded/unavailable state retain their numeric semantics. An unset formatter, throw, nonstring,
|
|
42
|
+
blank or oversized result restores numeric formatting for **both** quantities. A callback that
|
|
43
|
+
changes the meter or requests an update invalidates its pair and is not automatically retried in
|
|
44
|
+
that render chain; a later external update can retry the same callback. Formatting adds no event
|
|
45
|
+
or slot.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import '@aceshooting/lyra-ui/components/lr-budget-meter.js';
|
|
49
|
+
import { formatBytes } from '@aceshooting/lyra-ui/utilities/format.js';
|
|
50
|
+
|
|
51
|
+
const meter = document.querySelector('lr-budget-meter')!;
|
|
52
|
+
meter.used = 10 * 1024 ** 3;
|
|
53
|
+
meter.limit = 50 * 1024 ** 3;
|
|
54
|
+
// formatBytes supplies the unit for each quantity.
|
|
55
|
+
meter.unit = undefined;
|
|
56
|
+
meter.valueFormatter = (value, { locale }) => formatBytes(value, locale) ?? '';
|
|
57
|
+
```
|
|
58
|
+
|
|
28
59
|
**CSS parts:**
|
|
29
60
|
|
|
30
61
|
| Part | Purpose |
|
|
@@ -59,6 +59,15 @@ reveals the invalid state, and `form.reset()` clears the touched presentation.
|
|
|
59
59
|
`max-rows` growth and inner scrolling are unchanged in every layout. Layout
|
|
60
60
|
only; slot content, empty-slot hiding and the built-in button are unchanged. Invalid direct or
|
|
61
61
|
attribute values normalize and reflect as `'inline'`.
|
|
62
|
+
- `toolbarPlacement: ChatComposerToolbarPlacement = 'above'` (reflected, attribute
|
|
63
|
+
`toolbar-placement`) — `'above' | 'actions'`. By default the toolbar remains above attachments
|
|
64
|
+
and the input row. With `actionsLayout='below'`, `'actions'` places it between `start` and `end`
|
|
65
|
+
below the textarea, while attachments stay above the textarea. Inline and stacked layouts retain
|
|
66
|
+
the upper toolbar. Bottom controls use native Tab order: textarea, start, toolbar, end; callers
|
|
67
|
+
own keyboard behavior inside their toolbar controls. Long toolbar content stays in a bounded
|
|
68
|
+
wrapping/scrolling region so start and send remain visible at narrow widths and in RTL. Live
|
|
69
|
+
placement changes retain the textarea, draft, selection and focused caller controls. Invalid or
|
|
70
|
+
removed placement values normalize and reflect as `'above'`.
|
|
62
71
|
- `withoutEnterSubmit: boolean = false` (reflected, attribute `without-enter-submit`) — when set,
|
|
63
72
|
Enter always inserts a newline instead of submitting.
|
|
64
73
|
- `submitDisabled: boolean = false` (reflected, attribute `submit-disabled`) — consumer-controlled
|
|
@@ -105,8 +114,10 @@ validity and recomputes the current intrinsic constraints.
|
|
|
105
114
|
preventing it also prevents the native `invalid` event that produced it
|
|
106
115
|
|
|
107
116
|
**Slots:** `toolbar` (auxiliary controls, e.g. a model or provider picker, rendered inside the
|
|
108
|
-
frame above the chips tray and input row,
|
|
109
|
-
`
|
|
117
|
+
frame above the chips tray and input row by default, or between start/end below the textarea with
|
|
118
|
+
`toolbar-placement="actions"` and `actions-layout="below"`, sharing `[part="base"]`'s
|
|
119
|
+
`:focus-within` affordance),
|
|
120
|
+
`start` (content at the logical start of the input/action layout, e.g. an attach-file trigger button), `end` (overrides the
|
|
110
121
|
built-in send/stop button entirely when it has assigned content), `chips` (an attachment tray
|
|
111
122
|
rendered above the input row).
|
|
112
123
|
|
|
@@ -246,6 +246,11 @@ other value (a plain object, a function) is dropped from the row instead of reac
|
|
|
246
246
|
mapped IDLs `inputmode` and `enterkeyhint` delegate to the corresponding camel-case native
|
|
247
247
|
properties
|
|
248
248
|
- `inputValue: string` — the live filter input text; programmatic writes are event-silent
|
|
249
|
+
- `minQueryLength: number = 0` (attribute `min-query-length`) — opt-in minimum Unicode code
|
|
250
|
+
points in the trimmed query before suggestions can open or `source` can be called. The actual
|
|
251
|
+
displayed and provider query is preserved verbatim; counting is not grapheme segmentation.
|
|
252
|
+
Negative values clamp to zero, fractional values truncate, and non-finite values fall back to
|
|
253
|
+
zero. Unset or zero preserves unrestricted opening and current source behavior.
|
|
249
254
|
- `maxOptionsVisible: number = 3` (attribute `max-options-visible` — caps how many selected **tags**
|
|
250
255
|
show before collapsing to `+N`; nothing to do with the suggestion list, see the three-caps note
|
|
251
256
|
below)
|
|
@@ -337,6 +342,26 @@ including during SSR, a committed value renders as its raw code without an unava
|
|
|
337
342
|
synthetic unknown option or custom unknown label. Once the slot has been observed, even when
|
|
338
343
|
empty, ordinary matched/unmatched presentation applies.
|
|
339
344
|
|
|
345
|
+
**Minimum query length:** a positive `minQueryLength` applies to local suggestions and every
|
|
346
|
+
source/opening path, including focus, input, arrow keys, `show()`, direct `open`, public text edits,
|
|
347
|
+
refresh, clear/pick resets and reconnect. A rejected `show()` resolves immediately without
|
|
348
|
+
show/after-show events. Below the minimum the popup and its expanded/active-descendant ARIA state
|
|
349
|
+
stay closed. Typing a qualifying query follows the normal opening/debounce behavior.
|
|
350
|
+
|
|
351
|
+
When editing falls below the minimum, the popup closes without clearing the typed draft, moving
|
|
352
|
+
focus or changing the committed selection. This threshold-forced close is non-cancelable and
|
|
353
|
+
reports hide/after-hide only if the popup was already open; it emits no selection or clear events.
|
|
354
|
+
Ordinary explicit dismissal keeps its existing query-reset contract. Armed searches are canceled,
|
|
355
|
+
in-flight searches are aborted, and obsolete results/errors cannot restore suggestions. Already
|
|
356
|
+
known selected-row labels/data are retained. Raising the minimum reconciles the current query;
|
|
357
|
+
lowering it does not independently reopen or fetch before another normal query/open/refresh action.
|
|
358
|
+
|
|
359
|
+
A positive minimum also suppresses the closed selected-value `source('')` warmup: no short-query
|
|
360
|
+
metadata exception invokes the provider. A newly assigned async selection whose label has never
|
|
361
|
+
been resolved keeps the existing unresolved-selection presentation until a qualifying response can
|
|
362
|
+
resolve it. This does not change `selectedRows`' current/deferred resolution contract. Leave the
|
|
363
|
+
minimum at zero when empty-query label lookup or immediate catalog browsing is required.
|
|
364
|
+
|
|
340
365
|
**Methods:** `focus(options?)`, `blur()`, `select()`, `setSelectionRange()`, and `setRangeText()`
|
|
341
366
|
forward to the internal input. `setRangeText()` synchronizes the filter query and visible options.
|
|
342
367
|
`show(): Promise<void>` and `hide(): Promise<void>` settle after `lr-after-show` and
|
|
@@ -426,7 +451,8 @@ disconnect or a positioning runtime failure are non-cancelable because they cann
|
|
|
426
451
|
Vetoing an ordinary connected close
|
|
427
452
|
is atomic: the filter query, active option, async result rows, reflected `open` state, and overlay
|
|
428
453
|
ownership remain unchanged, so the host can defer dismissal without reconstructing the search.
|
|
429
|
-
|
|
454
|
+
A minimum-query-length forced close is also non-cancelable because an ineligible query cannot
|
|
455
|
+
keep suggestions open. `lr-after-show` and
|
|
430
456
|
`lr-after-hide` fire when the corresponding transition settles. `lr-create` carries
|
|
431
457
|
`detail: { inputValue }` and is also cancelable: preventing it suppresses the default append/select
|
|
432
458
|
action so the host can normalize and commit its own option.
|
|
@@ -86,6 +86,12 @@ resolving `false` when there are none); `clearSearch()` clears the query, matche
|
|
|
86
86
|
marks. `scrollToAnchor(target)` (inherited from `DocumentAnchorTarget`) resolves a `line-range`
|
|
87
87
|
anchor or a `highlights` id string.
|
|
88
88
|
|
|
89
|
+
Search/navigation work belongs to the compared inputs and current host lifecycle. If a
|
|
90
|
+
`lr-search-change` listener clears or replaces the search, or the compared source, connection or
|
|
91
|
+
document changes before scrolling, a superseded `search()` resolves zero and superseded
|
|
92
|
+
`searchNext()`/`searchPrevious()` resolves `false`. Retired work does not scroll a revealed fold or
|
|
93
|
+
borrow a newer search's active match. A fresh search can navigate the current source normally.
|
|
94
|
+
|
|
89
95
|
**Events:**
|
|
90
96
|
|
|
91
97
|
- `lr-copy` (`detail: LyraClipboardWriteSuccess`, `{ ok: true; text: string }`) — the frozen full
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
- **Release history** [CHANGELOG.md](../../CHANGELOG.md)
|
|
10
10
|
- **Deprecations** none
|
|
11
11
|
- **Optional peers** none
|
|
12
|
-
- **Themeable via**
|
|
12
|
+
- **Themeable via** 29 parts, 0 custom properties — see this component's own `@csspart`/`@cssprop` list below
|
|
13
13
|
- **Library-wide behavior** (events, form association, `locale`/`strings`, tokens, TS types): `llms/shared.md`
|
|
14
14
|
|
|
15
15
|
---
|
|
@@ -20,7 +20,7 @@ Controlled searchable and filterable document inventory with versions, tags, own
|
|
|
20
20
|
sorting, and bulk selection. It composes the table's bounded 100-row default, so a large document
|
|
21
21
|
collection stays reachable through pagination without mounting an unbounded grid.
|
|
22
22
|
|
|
23
|
-
With `dataSource` unset, the tag facet displays the first 500 locale-sorted distinct tags. A localized `[part="limit"]`
|
|
23
|
+
With both `dataSource` and `cursorSource` unset, the tag facet displays the first 500 locale-sorted distinct tags. A localized `[part="limit"]`
|
|
24
24
|
note reports the omitted count. Search and a controlled `tagFilter` continue to match all admitted
|
|
25
25
|
document tags, including tags outside the facet window. Matching rows, sorting, and folded search
|
|
26
26
|
fields are reused when their inputs are unchanged; loading and selection updates reuse the current
|
|
@@ -66,6 +66,7 @@ the nested table.
|
|
|
66
66
|
The provider query type is `DocumentLibrarySourceQuery { readonly searchTerm: string;
|
|
67
67
|
readonly tagFilter: readonly string[]; readonly sortKey: LibraryDocumentSortKey;
|
|
68
68
|
readonly sortDir: 'asc' | 'desc'; readonly filter: LyraDocumentLibrary['filter'] }`.
|
|
69
|
+
The component's `filter` property uses this same callback contract.
|
|
69
70
|
|
|
70
71
|
**Full-source paging:** Set property-only `dataSource: DocumentLibrarySource | undefined`
|
|
71
72
|
(default `undefined`) to browse a host-owned logical collection. `DocumentLibrarySource` is
|
|
@@ -102,17 +103,98 @@ User `lr-selection-change` carries the complete accepted ID list, and programmat
|
|
|
102
103
|
remain silent. Page/query changes and page retry reuse the independent selected-record cache.
|
|
103
104
|
`lr-filter-change.matchCount` reports the accepted global query total.
|
|
104
105
|
|
|
105
|
-
A defined
|
|
106
|
+
A defined `dataSource` takes display precedence over `documents`; it never overwrites that legacy
|
|
106
107
|
getter. Invalid defined sources fail visibly. Setting `dataSource = undefined` restores the
|
|
107
|
-
current legacy documents and their existing limits. The source remains host-owned by identity;
|
|
108
|
+
current legacy documents and their existing limits when `cursorSource` is also unset. The source remains host-owned by identity;
|
|
108
109
|
after changing its contents or revision, reassign it (including the same object) or call unnamed
|
|
109
110
|
`requestUpdate()`. Replacement, explicit refresh, locale change, disconnect and adoption revoke
|
|
110
111
|
obsolete work. Named presentation updates reuse accepted data. Both source and legacy routes
|
|
111
112
|
forward instance `strings` to the composed table.
|
|
112
113
|
|
|
114
|
+
**Unknown-total cursor batches:** property-only `cursorSource: DocumentLibraryCursorSource | undefined`
|
|
115
|
+
(default `undefined`) accepts
|
|
116
|
+
`LyraCursorSource<LibraryDocument, DocumentLibrarySourceQuery>`. This is a separate route from
|
|
117
|
+
counted `dataSource`: setting both fails visibly without invoking either provider or falling back
|
|
118
|
+
to `documents`. With both unset, the legacy array route keeps its existing behavior.
|
|
119
|
+
`DocumentLibraryCursorSource = LyraCursorSource<LibraryDocument, DocumentLibrarySourceQuery>` and
|
|
120
|
+
`DocumentLibraryQueryChangeDetail { readonly searchTerm: string;
|
|
121
|
+
readonly tags: readonly string[]; }` are exported by the component class entry. The generic cursor types
|
|
122
|
+
come from `@aceshooting/lyra-ui/data-sources.js`; see the [provider guide](../shared/events-and-types.md#large-collection-sources).
|
|
123
|
+
|
|
124
|
+
The provider supplies a nonempty identity `scope`, a `revision`, and
|
|
125
|
+
`query({ scope, revision, locale, signal, query, cursor, limit })`, returning
|
|
126
|
+
`{ rows: [{ key, value }], nextCursor }`. Each key must exactly equal its document's nonblank ID.
|
|
127
|
+
There is no required total, numeric order, lookup or locate. `cursor: null` starts the query;
|
|
128
|
+
`nextCursor: null` is the only end marker. Nonempty tokens are opaque: preserve them unchanged,
|
|
129
|
+
without parsing, displaying or persisting them. An empty or short batch can still have a next
|
|
130
|
+
token. The provider applies the complete search, AND tag filtering, optional custom filter and
|
|
131
|
+
sort **before** paging, with the same query/callback semantics as the counted route. It must
|
|
132
|
+
reject a query it cannot implement instead of silently ignoring it or filtering only loaded rows.
|
|
133
|
+
|
|
134
|
+
The nested table renders only the current batch. `sourcePageSize` supplies the request limit
|
|
135
|
+
(default 100, normalized to 1–500); `sourcePage` is inactive, and assigning it does not refetch.
|
|
136
|
+
`sourceTotal` remains `null`, including at the end. No match count, facet catalogue or total is
|
|
137
|
+
inferred from visited batches. The built-in tag picker and omitted-facet count are absent;
|
|
138
|
+
document tags still render, and a host may bind `tagFilter` from an external control. Partial
|
|
139
|
+
batches never prune that filter.
|
|
140
|
+
|
|
141
|
+
Readonly frozen `cursorNavigation: LyraCursorNavigationState` contains `status` (`'idle' |
|
|
142
|
+
'loading' | 'ready' | 'error'`), `canGoBack`, `canGoForward`, `atEnd`, and `historyTruncated` only:
|
|
143
|
+
no rows, tokens, absolute positions or counts. End is reported only for a ready terminal result,
|
|
144
|
+
never for a failure. `nextCursorPage(): Promise<boolean>`, `previousCursorPage(): Promise<boolean>`
|
|
145
|
+
and `restartCursorSource(): Promise<boolean>` resolve `true` only for their own accepted commits;
|
|
146
|
+
unavailable, externally blocked, failed or superseded actions resolve `false`.
|
|
147
|
+
|
|
148
|
+
Previous refetches a visited request cursor, retaining at most 32 visited cursors including the
|
|
149
|
+
current one. It discards the old forward branch; Next follows that newly accepted continuation.
|
|
150
|
+
Earlier history can be evicted, which sets `historyTruncated`; Start over discards history and
|
|
151
|
+
requests `null`. No previous batch rows or prefetch queue are retained. Retry repeats the exact
|
|
152
|
+
failed cursor request; Start over is the explicit way to discard an expired token. Known cycles
|
|
153
|
+
within retained history are rejected; global cycle detection across evicted history is not
|
|
154
|
+
promised. Empty continuation batches stay navigable without automatic fetch/skip loops.
|
|
155
|
+
|
|
156
|
+
Cursor selection is bounded **unverified selected-ID intent**, not proof of global membership.
|
|
157
|
+
Selecting the page preserves off-page IDs; hosts validate membership before mutations. IDs
|
|
158
|
+
survive query, revision, refresh, reconnect and same-scope provider replacement. A different
|
|
159
|
+
scope clears the old selection immediately, including after temporary source removal. Reusing
|
|
160
|
+
a scope asserts compatible document identity. When restoring selection for a new namespace,
|
|
161
|
+
assign the new source first, then the IDs:
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
import '@aceshooting/lyra-ui/components/lr-document-library.js';
|
|
165
|
+
import type { DocumentLibraryCursorSource } from '@aceshooting/lyra-ui/components/data/document-library/document-library.class.js';
|
|
166
|
+
|
|
167
|
+
declare const source: DocumentLibraryCursorSource; // Host-owned query implementation.
|
|
168
|
+
declare const restoredIds: readonly string[];
|
|
169
|
+
const library = document.querySelector('lr-document-library')!;
|
|
170
|
+
library.cursorSource = source;
|
|
171
|
+
library.selectedDocumentIds = restoredIds;
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Cursor `tagFilter` and selected-ID assignments inspect at most 10,000 raw entries, deduplicate
|
|
175
|
+
stably, then admit at most 500 unique tags or 10,000 unique selected IDs. Each nonblank ID is at
|
|
176
|
+
most 65,536 UTF-16 units; owned unique text is at most 2,000,000 units per input. Query search is
|
|
177
|
+
at most 65,536 units and shares the query text allowance with tag IDs. Malformed, sparse or
|
|
178
|
+
oversized inputs fail atomically rather than truncating. Scope, nonnull token and string revision
|
|
179
|
+
are nonempty and at most 8,192 units each. Replies contain at most the requested number of rows;
|
|
180
|
+
duplicate/invalid keys or documents reject the whole batch. Documents retain the provider-row
|
|
181
|
+
500-tag/65,536-display-unit limit, and combined keys plus display text are bounded to 2,000,000
|
|
182
|
+
units per batch. None of these cursor admission rules changes the legacy array/counting limits.
|
|
183
|
+
|
|
184
|
+
Source reassignment (including the same object), keyless `requestUpdate()`, query/locale/limit
|
|
185
|
+
changes, explicit restart or reconnect starts at `null` and revokes old results. Named visual
|
|
186
|
+
updates reuse accepted data; observe revision changes by reassigning or explicitly refreshing.
|
|
187
|
+
Navigation/selection closures from an obsolete batch cannot act on a new same-ID row. A callback
|
|
188
|
+
must settle promptly on `signal` abort: ignoring cancellation holds the physical page permit, so
|
|
189
|
+
newer requests wait instead of overlapping it. The host owns callback cost and backend work.
|
|
190
|
+
|
|
113
191
|
**Events:**
|
|
114
192
|
|
|
115
|
-
- `lr-filter-change` — non-cancelable
|
|
193
|
+
- `lr-filter-change` — array/counted routes only; non-cancelable, with fresh frozen readonly
|
|
194
|
+
`{ searchTerm, tags, matchCount }` and the exact admitted/global match count.
|
|
195
|
+
- `lr-query-change` — cursor route only; non-cancelable, with fresh frozen readonly
|
|
196
|
+
`{ searchTerm, tags }` after a user search edit. It is an immediate input notification, not a
|
|
197
|
+
result/total notification; programmatic assignments are silent and no `matchCount` is fabricated.
|
|
116
198
|
- `lr-sort-request` — cancelable; proposes frozen readonly `{ phase: 'request', sortKey, sortDir }`.
|
|
117
199
|
- `lr-sort` — non-cancelable; an accepted sort commits the same fields with `phase: 'commit'`.
|
|
118
200
|
- `lr-selection-change` — non-cancelable; fresh frozen readonly `{ documentIds }`.
|
|
@@ -129,7 +211,9 @@ button, while a host or provider load error is shown.
|
|
|
129
211
|
`clear-selection`, `table`, `row`, `cell`, `header-cell`, `document-name`, `error-row`, `error-cell`,
|
|
130
212
|
`error` (the nested table's built-in `lr-empty` host), `error-base`, `error-icon`, `error-heading`,
|
|
131
213
|
`error-description`, `error-actions`, `retry-button`, `limit` (the count of distinct tags omitted
|
|
132
|
-
from the facet), `selection-status` (source selection loading/error),
|
|
214
|
+
from the facet), `selection-status` (counted-source selection loading/error), `selection-retry`,
|
|
215
|
+
`cursor-navigation` (the named navigation region), `cursor-previous`, `cursor-next`,
|
|
216
|
+
`cursor-restart`, and `cursor-status` (end/history-boundary text).
|
|
133
217
|
|
|
134
218
|
`selection-bar` is visible ordinary content, not a shadow live region. `selectedDocumentIds`
|
|
135
219
|
assignments stay silent; each selection change the user makes (row or select-all checkbox, "Clear
|
|
@@ -568,6 +568,11 @@ of the box with no host styling required); a host typically computes the set fro
|
|
|
568
568
|
it back — `lr-knowledge-graph-explorer`'s own `highlight` property is exactly this composition,
|
|
569
569
|
built-in. Empty (the default) renders every node/edge at full opacity, unchanged from today.
|
|
570
570
|
|
|
571
|
+
An activation listener that replaces controlled selection, active graph data, view, renderer,
|
|
572
|
+
selection mode, hidden types or the host connection retires the originating action: it emits no later selection proposal from that
|
|
573
|
+
activation. A subsequent activation uses the current graph normally. This applies to both array
|
|
574
|
+
and column inputs; it does not make selection uncontrolled.
|
|
575
|
+
|
|
571
576
|
`nodes`, `edges`, `nodeTypes`, and `communities` use nonblank first-wins identities before lookup,
|
|
572
577
|
layout, rendering, selection, or events. An edge uses its explicit `id`, or `source->target` when
|
|
573
578
|
`id` is omitted; a blank explicit `id` is invalid, while distinct explicit ids deliberately allow
|