UNPKG

@public-ui/hydrate

Version:

Hydrate function for KoliBri - The accessible HTML-Standard.

1,333 lines (1,187 loc) 2.18 MB
/*! * KoliBri - The accessible HTML-Standard */ import { Readable } from 'stream'; const modeResolutionChain = []; function hydrateFactory($stencilWindow, $stencilHydrateOpts, $stencilHydrateResults, $stencilAfterHydrate, $stencilHydrateResolve) { var globalThis = $stencilWindow; var self = $stencilWindow; var top = $stencilWindow; var parent = $stencilWindow; var addEventListener = $stencilWindow.addEventListener.bind($stencilWindow); var alert = $stencilWindow.alert.bind($stencilWindow); var blur = $stencilWindow.blur.bind($stencilWindow); var cancelAnimationFrame = $stencilWindow.cancelAnimationFrame.bind($stencilWindow); var cancelIdleCallback = $stencilWindow.cancelIdleCallback.bind($stencilWindow); var clearInterval = $stencilWindow.clearInterval.bind($stencilWindow); var clearTimeout = $stencilWindow.clearTimeout.bind($stencilWindow); var close = () => {}; var confirm = $stencilWindow.confirm.bind($stencilWindow); var dispatchEvent = $stencilWindow.dispatchEvent.bind($stencilWindow); var focus = $stencilWindow.focus.bind($stencilWindow); var getComputedStyle = $stencilWindow.getComputedStyle.bind($stencilWindow); var matchMedia = $stencilWindow.matchMedia.bind($stencilWindow); var open = $stencilWindow.open.bind($stencilWindow); var prompt = $stencilWindow.prompt.bind($stencilWindow); var removeEventListener = $stencilWindow.removeEventListener.bind($stencilWindow); var requestAnimationFrame = $stencilWindow.requestAnimationFrame.bind($stencilWindow); var requestIdleCallback = $stencilWindow.requestIdleCallback.bind($stencilWindow); var setInterval = $stencilWindow.setInterval.bind($stencilWindow); var setTimeout = $stencilWindow.setTimeout.bind($stencilWindow); var CharacterData = $stencilWindow.CharacterData; var CSS = $stencilWindow.CSS; var CustomEvent = $stencilWindow.CustomEvent; var CSSStyleSheet = $stencilWindow.CSSStyleSheet; var Document = $stencilWindow.Document; var ShadowRoot = $stencilWindow.ShadowRoot; var DocumentFragment = $stencilWindow.DocumentFragment; var DocumentType = $stencilWindow.DocumentType; var DOMTokenList = $stencilWindow.DOMTokenList; var Element = $stencilWindow.Element; var Event = $stencilWindow.Event; var HTMLAnchorElement = $stencilWindow.HTMLAnchorElement; var HTMLBaseElement = $stencilWindow.HTMLBaseElement; var HTMLButtonElement = $stencilWindow.HTMLButtonElement; var HTMLCanvasElement = $stencilWindow.HTMLCanvasElement; var HTMLElement = $stencilWindow.HTMLElement; var HTMLFormElement = $stencilWindow.HTMLFormElement; var HTMLImageElement = $stencilWindow.HTMLImageElement; var HTMLInputElement = $stencilWindow.HTMLInputElement; var HTMLLinkElement = $stencilWindow.HTMLLinkElement; var HTMLMetaElement = $stencilWindow.HTMLMetaElement; var HTMLScriptElement = $stencilWindow.HTMLScriptElement; var HTMLStyleElement = $stencilWindow.HTMLStyleElement; var HTMLTemplateElement = $stencilWindow.HTMLTemplateElement; var HTMLTitleElement = $stencilWindow.HTMLTitleElement; var IntersectionObserver = $stencilWindow.IntersectionObserver; var ResizeObserver = $stencilWindow.ResizeObserver; var KeyboardEvent = $stencilWindow.KeyboardEvent; var MouseEvent = $stencilWindow.MouseEvent; var Node = $stencilWindow.Node; var NodeList = $stencilWindow.NodeList; var URL = $stencilWindow.URL; var console = $stencilWindow.console; var customElements = $stencilWindow.customElements; var history = $stencilWindow.history; var localStorage = $stencilWindow.localStorage; var location = $stencilWindow.location; var navigator = $stencilWindow.navigator; var performance = $stencilWindow.performance; var sessionStorage = $stencilWindow.sessionStorage; var devicePixelRatio = $stencilWindow.devicePixelRatio; var innerHeight = $stencilWindow.innerHeight; var innerWidth = $stencilWindow.innerWidth; var origin = $stencilWindow.origin; var pageXOffset = $stencilWindow.pageXOffset; var pageYOffset = $stencilWindow.pageYOffset; var screen = $stencilWindow.screen; var screenLeft = $stencilWindow.screenLeft; var screenTop = $stencilWindow.screenTop; var screenX = $stencilWindow.screenX; var screenY = $stencilWindow.screenY; var scrollX = $stencilWindow.scrollX; var scrollY = $stencilWindow.scrollY; var exports = {}; var fetch, FetchError, Headers, Request, Response; if (typeof $stencilWindow.fetch === 'function') { fetch = $stencilWindow.fetch; } else { fetch = $stencilWindow.fetch = function() { throw new Error('fetch() is not implemented'); }; } if (typeof $stencilWindow.FetchError === 'function') { FetchError = $stencilWindow.FetchError; } else { FetchError = $stencilWindow.FetchError = class FetchError { constructor() { throw new Error('FetchError is not implemented'); } }; } if (typeof $stencilWindow.Headers === 'function') { Headers = $stencilWindow.Headers; } else { Headers = $stencilWindow.Headers = class Headers { constructor() { throw new Error('Headers is not implemented'); } }; } if (typeof $stencilWindow.Request === 'function') { Request = $stencilWindow.Request; } else { Request = $stencilWindow.Request = class Request { constructor() { throw new Error('Request is not implemented'); } }; } if (typeof $stencilWindow.Response === 'function') { Response = $stencilWindow.Response; } else { Response = $stencilWindow.Response = class Response { constructor() { throw new Error('Response is not implemented'); } }; } function hydrateAppClosure($stencilWindow) { const window = $stencilWindow; const document = $stencilWindow.document; /*hydrateAppClosure start*/ function _mergeNamespaces(n, m) { m.forEach(function (e) { e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) { if (k !== 'default' && !(k in n)) { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); }); return Object.freeze(n); } const NAMESPACE = 'kolibri'; const BUILD = /* kolibri */ { hydratedSelectorName: "hydrated", slotRelocation: true, state: true, updatable: true}; const Env = /* kolibri */ {"kolibriVersion":"3.0.9"}; function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } var loglevel$1 = {exports: {}}; /* * loglevel - https://github.com/pimterry/loglevel * * Copyright (c) 2013 Tim Perry * Licensed under the MIT license. */ var loglevel = loglevel$1.exports; var hasRequiredLoglevel; function requireLoglevel () { if (hasRequiredLoglevel) return loglevel$1.exports; hasRequiredLoglevel = 1; (function (module) { (function (root, definition) { if (module.exports) { module.exports = definition(); } else { root.log = definition(); } }(loglevel, function () { // Slightly dubious tricks to cut down minimized file size var noop = function() {}; var undefinedType = "undefined"; var isIE = (typeof window !== undefinedType) && (typeof window.navigator !== undefinedType) && ( /Trident\/|MSIE /.test(window.navigator.userAgent) ); var logMethods = [ "trace", "debug", "info", "warn", "error" ]; var _loggersByName = {}; var defaultLogger = null; // Cross-browser bind equivalent that works at least back to IE6 function bindMethod(obj, methodName) { var method = obj[methodName]; if (typeof method.bind === 'function') { return method.bind(obj); } else { try { return Function.prototype.bind.call(method, obj); } catch (e) { // Missing bind shim or IE8 + Modernizr, fallback to wrapping return function() { return Function.prototype.apply.apply(method, [obj, arguments]); }; } } } // Trace() doesn't print the message in IE, so for that case we need to wrap it function traceForIE() { if (console.log) { if (console.log.apply) { console.log.apply(console, arguments); } else { // In old IE, native console methods themselves don't have apply(). Function.prototype.apply.apply(console.log, [console, arguments]); } } if (console.trace) console.trace(); } // Build the best logging method possible for this env // Wherever possible we want to bind, not wrap, to preserve stack traces function realMethod(methodName) { if (methodName === 'debug') { methodName = 'log'; } if (typeof console === undefinedType) { return false; // No method possible, for now - fixed later by enableLoggingWhenConsoleArrives } else if (methodName === 'trace' && isIE) { return traceForIE; } else if (console[methodName] !== undefined) { return bindMethod(console, methodName); } else if (console.log !== undefined) { return bindMethod(console, 'log'); } else { return noop; } } // These private functions always need `this` to be set properly function replaceLoggingMethods() { /*jshint validthis:true */ var level = this.getLevel(); // Replace the actual methods. for (var i = 0; i < logMethods.length; i++) { var methodName = logMethods[i]; this[methodName] = (i < level) ? noop : this.methodFactory(methodName, level, this.name); } // Define log.log as an alias for log.debug this.log = this.debug; // Return any important warnings. if (typeof console === undefinedType && level < this.levels.SILENT) { return "No console available for logging"; } } // In old IE versions, the console isn't present until you first open it. // We build realMethod() replacements here that regenerate logging methods function enableLoggingWhenConsoleArrives(methodName) { return function () { if (typeof console !== undefinedType) { replaceLoggingMethods.call(this); this[methodName].apply(this, arguments); } }; } // By default, we use closely bound real methods wherever possible, and // otherwise we wait for a console to appear, and then try again. function defaultMethodFactory(methodName, _level, _loggerName) { /*jshint validthis:true */ return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments); } function Logger(name, factory) { // Private instance variables. var self = this; /** * The level inherited from a parent logger (or a global default). We * cache this here rather than delegating to the parent so that it stays * in sync with the actual logging methods that we have installed (the * parent could change levels but we might not have rebuilt the loggers * in this child yet). * @type {number} */ var inheritedLevel; /** * The default level for this logger, if any. If set, this overrides * `inheritedLevel`. * @type {number|null} */ var defaultLevel; /** * A user-specific level for this logger. If set, this overrides * `defaultLevel`. * @type {number|null} */ var userLevel; var storageKey = "loglevel"; if (typeof name === "string") { storageKey += ":" + name; } else if (typeof name === "symbol") { storageKey = undefined; } function persistLevelIfPossible(levelNum) { var levelName = (logMethods[levelNum] || 'silent').toUpperCase(); if (typeof window === undefinedType || !storageKey) return; // Use localStorage if available try { window.localStorage[storageKey] = levelName; return; } catch (ignore) {} // Use session cookie as fallback try { window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";"; } catch (ignore) {} } function getPersistedLevel() { var storedLevel; if (typeof window === undefinedType || !storageKey) return; try { storedLevel = window.localStorage[storageKey]; } catch (ignore) {} // Fallback to cookies if local storage gives us nothing if (typeof storedLevel === undefinedType) { try { var cookie = window.document.cookie; var cookieName = encodeURIComponent(storageKey); var location = cookie.indexOf(cookieName + "="); if (location !== -1) { storedLevel = /^([^;]+)/.exec( cookie.slice(location + cookieName.length + 1) )[1]; } } catch (ignore) {} } // If the stored level is not valid, treat it as if nothing was stored. if (self.levels[storedLevel] === undefined) { storedLevel = undefined; } return storedLevel; } function clearPersistedLevel() { if (typeof window === undefinedType || !storageKey) return; // Use localStorage if available try { window.localStorage.removeItem(storageKey); } catch (ignore) {} // Use session cookie as fallback try { window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC"; } catch (ignore) {} } function normalizeLevel(input) { var level = input; if (typeof level === "string" && self.levels[level.toUpperCase()] !== undefined) { level = self.levels[level.toUpperCase()]; } if (typeof level === "number" && level >= 0 && level <= self.levels.SILENT) { return level; } else { throw new TypeError("log.setLevel() called with invalid level: " + input); } } /* * * Public logger API - see https://github.com/pimterry/loglevel for details * */ self.name = name; self.levels = { "TRACE": 0, "DEBUG": 1, "INFO": 2, "WARN": 3, "ERROR": 4, "SILENT": 5}; self.methodFactory = factory || defaultMethodFactory; self.getLevel = function () { if (userLevel != null) { return userLevel; } else if (defaultLevel != null) { return defaultLevel; } else { return inheritedLevel; } }; self.setLevel = function (level, persist) { userLevel = normalizeLevel(level); if (persist !== false) { // defaults to true persistLevelIfPossible(userLevel); } // NOTE: in v2, this should call rebuild(), which updates children. return replaceLoggingMethods.call(self); }; self.setDefaultLevel = function (level) { defaultLevel = normalizeLevel(level); if (!getPersistedLevel()) { self.setLevel(level, false); } }; self.resetLevel = function () { userLevel = null; clearPersistedLevel(); replaceLoggingMethods.call(self); }; self.enableAll = function(persist) { self.setLevel(self.levels.TRACE, persist); }; self.disableAll = function(persist) { self.setLevel(self.levels.SILENT, persist); }; self.rebuild = function () { if (defaultLogger !== self) { inheritedLevel = normalizeLevel(defaultLogger.getLevel()); } replaceLoggingMethods.call(self); if (defaultLogger === self) { for (var childName in _loggersByName) { _loggersByName[childName].rebuild(); } } }; // Initialize all the internal levels. inheritedLevel = normalizeLevel( defaultLogger ? defaultLogger.getLevel() : "WARN" ); var initialLevel = getPersistedLevel(); if (initialLevel != null) { userLevel = normalizeLevel(initialLevel); } replaceLoggingMethods.call(self); } /* * * Top-level API * */ defaultLogger = new Logger(); defaultLogger.getLogger = function getLogger(name) { if ((typeof name !== "symbol" && typeof name !== "string") || name === "") { throw new TypeError("You must supply a name when creating a logger."); } var logger = _loggersByName[name]; if (!logger) { logger = _loggersByName[name] = new Logger( name, defaultLogger.methodFactory ); } return logger; }; // Grab the current global log variable in case of overwrite var _log = (typeof window !== undefinedType) ? window.log : undefined; defaultLogger.noConflict = function() { if (typeof window !== undefinedType && window.log === defaultLogger) { window.log = _log; } return defaultLogger; }; defaultLogger.getLoggers = function getLoggers() { return _loggersByName; }; // ES6 default export, for compatibility defaultLogger['default'] = defaultLogger; return defaultLogger; })); } (loglevel$1)); return loglevel$1.exports; } var loglevelExports = requireLoglevel(); var h$1 = /*@__PURE__*/getDefaultExportFromCjs(loglevelExports); const $=()=>{const t=typeof process<"u"&&process.env?process.env:{},e=t.NODE_ENV==="test",s="VITEST"in t,a="JEST_WORKER_ID"in t,o="PLAYWRIGHT_TEST_BASE_URL"in t,r=t.CI==="true",i=t.TEST==="true"||t.IS_TEST==="true",c=typeof navigator<"u"&&navigator.webdriver===true,m=typeof navigator<"u"&&/playwright|puppeteer|webdriver|selenium|testcafe/i.test(navigator.userAgent);return e||s||a||o||r||i||c||m},n$1={A11yUi:{CSS_STYLE_CACHE:new Map,IS_TEST_ENVIRONMENT:$(),PERFORMANCE_MEASURES:new Map,STYLING_TASK_QUEUE:new Map,THEMES:new Map}};let f$1=false;const j=/^[a-z][a-z0-9]{1,}(-[a-z0-9]+)?$/,F=t=>typeof t=="string"&&j.test(t),E=t=>{if(!F(t))throw new Error(`[Theming] The theme identifier "${typeof t=="string"?t:""}" (Type: ${typeof t}) is not valid. Please use only follow this pattern: /^[a-z][a-z0-9]{1,}(-[a-z0-9]+)?$/`)},g=t=>t.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\s*([{},;])\s*/g,"$1").replace(/:\s+/g,":").replace(/\s+/g," ").replace(/;\}/g,"}").trim(),Y=(t,e,s,a)=>u$1(t,e,s,a),u$1=(t,e,s,a)=>{a=a??{},a.append=a.append??false,E(t),!f$1&&(f$1=true,h$1.warn(`[Theming] The theme process is locked. This means that the theme "${t}" should not be patched. import { register } from 'adopted-style-sheets'; import { defineCustomElements } from '...'; import { THEME } from '...'; register(THEME, defineCustomElements) .then(() => { // run your app or website }) .catch(console.warn);`));let o=n$1.A11yUi.THEMES.get(t);if(o||(o=new Map,n$1.A11yUi.THEMES.set(t,o)),a.append&&o.has(e)){const r=o.get(e);o.set(e,g(`${r}${s}`));}else o.set(e,g(s));},k=(t,e,s,a)=>p(t,e,s,a),p=(t,e,s,a)=>(E(t),typeof e=="object"&&e!==null&&Object.getOwnPropertyNames(e).forEach(o=>{const r=e[o],i=o.toLowerCase(),c=typeof a?.transformTagName=="function"&&!["GLOBAL","PROPERTIES"].includes(o)?a.transformTagName(i):o;typeof r=="string"&&r.length>0&&u$1(t,c.toUpperCase(),r,s);}),t),S=t=>{if(t instanceof HTMLElement){if(typeof t.dataset.theme=="string")return t;{let e=t.parentNode;for(;e instanceof ShadowRoot;)e=e.host;return S(e)}}else return null},A=(t={})=>t.themeEncroachCss==="false"||t.themeReset==="true"?false:{mode:t.themeEncroachCssMode==="after"||t.themeEncroachCssMode==="before"?t.themeEncroachCssMode:"before"},C=()=>typeof n$1.A11yUi.Theme=="object"&&n$1.A11yUi.Theme!==null&&typeof n$1.A11yUi.Theme.cache=="boolean"&&typeof n$1.A11yUi.Theme.encroachCss=="object"&&n$1.A11yUi.Theme.encroachCss!==null&&typeof n$1.A11yUi.Theme.encroachCss.mode=="string"&&typeof n$1.A11yUi.Theme.name=="string",b=t=>{if(C())return n$1.A11yUi.Theme;{const e={cache:true,encroachCss:A(),loglevel:"silent",mode:"csr",name:null},s=S(t);return s instanceof HTMLElement&&(e.cache=s.dataset.themeCache!=="false",e.encroachCss=A(s.dataset),e.loglevel=s.dataset.themeLoglevel==="debug"?s.dataset.themeLoglevel:"silent",e.mode=s.dataset.themeMode==="ssr"?s.dataset.themeMode:"csr",e.name=s.dataset.theme||null),e}};const w=new Set,W=/--[^;]+/g,q=/:/,J=typeof MutationObserver<"u";let M=25,N=()=>{M=Math.min(25+Math.log2(n$1.A11yUi.STYLING_TASK_QUEUE.size+1)*20,250);};const X=(t,e)=>{let s=e.match(W);if(Array.isArray(s)){s=s.filter(o=>q.test(o));const a=document.createElement("style");a.innerHTML=`.${t} {${s.join(";")}}`,document.querySelector("head")?.appendChild(a);}w.add(t);},y=(t,e)=>{const s=n$1.A11yUi.THEMES.get(t);return s instanceof Map&&s.has(e)?s.get(e):""},Z=t=>{for(const e of Array.from(t.childNodes))if(e instanceof HTMLStyleElement&&e.tagName==="STYLE"&&e.dataset.themingFallback===void 0)t.removeChild(e);else break},ee=(t,e)=>{try{if(n$1.A11yUi.Theme?.mode==="ssr")throw new Error("SSR");const s=[];e.forEach(a=>{const o=new CSSStyleSheet;o.replaceSync(a),s.push(o);}),t.adoptedStyleSheets=s;}catch{[...e].reverse().forEach((a,o)=>{if(typeof a!="string"||a.length===0)return;const r=document.createElement("style");switch(r.dataset.themingFallback="",o){case 4:r.dataset.themingBaseA11y="";break;case 3:r.dataset.themingBaseGlobal="";break;case 2:r.dataset.themingBaseComponent="";break;case 1:r.dataset.themingCustomGlobal="";break;case 0:r.dataset.themingCustomComponent="";break;default:r.dataset.themingUnknown="";break}r.innerHTML=a,t.insertBefore(r,t.firstChild);});}},te=(t,e,s)=>{if(s!==false){const a=[...Array.from(t.childNodes).filter(r=>r instanceof HTMLStyleElement&&r.tagName==="STYLE")];let o;try{o=[...Array.from(t.adoptedStyleSheets)];}catch{o=[];}s?.mode==="before"?(a.reverse().forEach(r=>e.unshift(r.innerHTML)),o.reverse().forEach(r=>e.unshift(Array.from(r.cssRules).map(i=>i.cssText).join("")))):s?.mode==="after"&&(a.forEach(r=>e.push(r.innerHTML)),o.forEach(r=>e.push(Array.from(r.cssRules).map(i=>i.cssText).join(""))));}},se=(t,e,s)=>{const a=e.name||"default";let o;try{if(t.shadowRoot===null)throw new Error("ShadowRoot is null");o=t.shadowRoot;}catch{o=t;}if(n$1.A11yUi.CSS_STYLE_CACHE.get(a)?.has(t.tagName))v(t,o,n$1.A11yUi.CSS_STYLE_CACHE.get(a)?.get(t.tagName),s);else {const r=y(a,"PROPERTIES"),i=y(a,"GLOBAL"),c=y(a,t.tagName);w.has(a)===false&&X(a,i);const m=[r,i,c];te(o,m,e.encroachCss),e.cache===true&&(n$1.A11yUi.CSS_STYLE_CACHE.has(a)===false&&n$1.A11yUi.CSS_STYLE_CACHE.set(a,new Map),n$1.A11yUi.CSS_STYLE_CACHE.get(a)?.set(t.tagName,m)),v(t,o,m,s);}},v=(t,e,s,a)=>{const o=performance.now();if(Z(e),ee(e,s),H(t),a(),n$1.A11yUi.PERFORMANCE_MEASURES.has(t.tagName)){const r=n$1.A11yUi.PERFORMANCE_MEASURES.get(t.tagName);r.count+=1,r.totalTime+=performance.now()-o;}else n$1.A11yUi.PERFORMANCE_MEASURES.set(t.tagName,{count:1,totalTime:performance.now()-o});},L=t=>{const e=n$1.A11yUi.STYLING_TASK_QUEUE.get(t);if(e){const{resetCss:s,themeDetails:a}=e;se(t,a,s),H(t);}};let T=t=>{const e=setTimeout(()=>{clearTimeout(e),t.classList.contains("hydrated")?L(t):T(t);},M);};const ae={attributes:true,attributeFilter:["class"],childList:false,subtree:false},oe={attributes:true,attributeFilter:[],childList:false,subtree:false},R=J?new MutationObserver((t,e)=>{for(const s of t){const a=s.target;a.classList.contains("hydrated")&&(L(a),e.observe(a,oe));}}):null;R&&(T=t=>R.observe(t,ae),N=()=>{});let _=t=>{const e=getComputedStyle(t).getPropertyValue("--theme-visibility-delay").trim();if(e.endsWith("ms"))return parseFloat(e);if(e.endsWith("s"))return parseFloat(e)*1e3;{const s=parseFloat(e);return isNaN(s)?0:s}};n$1.A11yUi.IS_TEST_ENVIRONMENT&&(_=()=>0);const O=(t,e)=>{t.style.setProperty("visibility",e),t.dataset.themed="";},re=(t,e)=>{const s=t.style.visibility||null;n$1.A11yUi.STYLING_TASK_QUEUE.set(t,{resetCss:()=>{const a=_(t);a>0?setTimeout(()=>{O(t,s);},a):O(t,s);},themeDetails:e}),t.style.setProperty("visibility","hidden","important"),T(t);},H=t=>{n$1.A11yUi.STYLING_TASK_QUEUE.delete(t),N();},ne=(t,e)=>{re(t,{...n$1.A11yUi.Theme,...e});}; var KeyEnum; (function (KeyEnum) { KeyEnum[KeyEnum["error"] = 0] = "error"; KeyEnum[KeyEnum["warning"] = 1] = "warning"; KeyEnum[KeyEnum["info"] = 2] = "info"; KeyEnum[KeyEnum["success"] = 3] = "success"; KeyEnum[KeyEnum["message"] = 4] = "message"; KeyEnum[KeyEnum["close"] = 5] = "close"; KeyEnum[KeyEnum["form-description"] = 6] = "form-description"; KeyEnum[KeyEnum["of"] = 7] = "of"; KeyEnum[KeyEnum["characters"] = 8] = "characters"; KeyEnum[KeyEnum["new"] = 9] = "new"; KeyEnum[KeyEnum["no-entries"] = 10] = "no-entries"; KeyEnum[KeyEnum["change-order"] = 11] = "change-order"; KeyEnum[KeyEnum["action-running"] = 12] = "action-running"; KeyEnum[KeyEnum["action-done"] = 13] = "action-done"; KeyEnum[KeyEnum["page-first"] = 14] = "page-first"; KeyEnum[KeyEnum["page-back"] = 15] = "page-back"; KeyEnum[KeyEnum["page-next"] = 16] = "page-next"; KeyEnum[KeyEnum["page-last"] = 17] = "page-last"; KeyEnum[KeyEnum["entries-per-site"] = 18] = "entries-per-site"; KeyEnum[KeyEnum["page-current"] = 19] = "page-current"; KeyEnum[KeyEnum["page-selected"] = 20] = "page-selected"; KeyEnum[KeyEnum["page-per-site"] = 21] = "page-per-site"; KeyEnum[KeyEnum["logo-description"] = 22] = "logo-description"; KeyEnum[KeyEnum["open-link-in-tab"] = 23] = "open-link-in-tab"; KeyEnum[KeyEnum["kolibri-logo"] = 24] = "kolibri-logo"; })(KeyEnum || (KeyEnum = {})); var TagEnum; (function (TagEnum) { TagEnum[TagEnum["abbr"] = 0] = "abbr"; TagEnum[TagEnum["accordion"] = 1] = "accordion"; TagEnum[TagEnum["alert"] = 2] = "alert"; TagEnum[TagEnum["avatar"] = 3] = "avatar"; TagEnum[TagEnum["badge"] = 4] = "badge"; TagEnum[TagEnum["breadcrumb"] = 5] = "breadcrumb"; TagEnum[TagEnum["button"] = 6] = "button"; TagEnum[TagEnum["button-link"] = 7] = "button-link"; TagEnum[TagEnum["card"] = 8] = "card"; TagEnum[TagEnum["combobox"] = 9] = "combobox"; TagEnum[TagEnum["details"] = 10] = "details"; TagEnum[TagEnum["drawer"] = 11] = "drawer"; TagEnum[TagEnum["form"] = 12] = "form"; TagEnum[TagEnum["heading"] = 13] = "heading"; TagEnum[TagEnum["icon"] = 14] = "icon"; TagEnum[TagEnum["image"] = 15] = "image"; TagEnum[TagEnum["input-checkbox"] = 16] = "input-checkbox"; TagEnum[TagEnum["input-color"] = 17] = "input-color"; TagEnum[TagEnum["input-date"] = 18] = "input-date"; TagEnum[TagEnum["input-email"] = 19] = "input-email"; TagEnum[TagEnum["input-file"] = 20] = "input-file"; TagEnum[TagEnum["input-number"] = 21] = "input-number"; TagEnum[TagEnum["input-password"] = 22] = "input-password"; TagEnum[TagEnum["input-radio"] = 23] = "input-radio"; TagEnum[TagEnum["input-range"] = 24] = "input-range"; TagEnum[TagEnum["input-text"] = 25] = "input-text"; TagEnum[TagEnum["kolibri"] = 26] = "kolibri"; TagEnum[TagEnum["link"] = 27] = "link"; TagEnum[TagEnum["link-button"] = 28] = "link-button"; TagEnum[TagEnum["logo"] = 29] = "logo"; TagEnum[TagEnum["modal"] = 30] = "modal"; TagEnum[TagEnum["nav"] = 31] = "nav"; TagEnum[TagEnum["pagination"] = 32] = "pagination"; TagEnum[TagEnum["popover-button"] = 33] = "popover-button"; TagEnum[TagEnum["progress"] = 34] = "progress"; TagEnum[TagEnum["quote"] = 35] = "quote"; TagEnum[TagEnum["select"] = 36] = "select"; TagEnum[TagEnum["single-select"] = 37] = "single-select"; TagEnum[TagEnum["skip-nav"] = 38] = "skip-nav"; TagEnum[TagEnum["spin"] = 39] = "spin"; TagEnum[TagEnum["split-button"] = 40] = "split-button"; TagEnum[TagEnum["symbol"] = 41] = "symbol"; TagEnum[TagEnum["table"] = 42] = "table"; TagEnum[TagEnum["table-stateful"] = 43] = "table-stateful"; TagEnum[TagEnum["table-stateless"] = 44] = "table-stateless"; TagEnum[TagEnum["tabs"] = 45] = "tabs"; TagEnum[TagEnum["textarea"] = 46] = "textarea"; TagEnum[TagEnum["toast-container"] = 47] = "toast-container"; TagEnum[TagEnum["toolbar"] = 48] = "toolbar"; TagEnum[TagEnum["tooltip"] = 49] = "tooltip"; TagEnum[TagEnum["tree"] = 50] = "tree"; TagEnum[TagEnum["tree-item"] = 51] = "tree-item"; })(TagEnum || (TagEnum = {})); const getWindow$1 = () => { if (typeof window !== 'undefined') return window; return {}; }; const getDocument = () => { const win = getWindow$1(); if (win && typeof win.document !== 'undefined') return win.document; return {}; }; const MODES = ['development', 'production', 'test']; let runtimeMode = 'production'; const setRuntimeMode = (mode) => { try { if (MODES.includes(mode)) { runtimeMode = mode; } else { throw new Error(`Invalid NODE_ENV value: ${mode}. Expected one of ${MODES.join(', ')}.`); } } catch (e) { runtimeMode = 'production'; } }; const getInitialMode = () => { try { const nodeEnv = typeof process !== 'undefined' && process.env ? process.env['NODE_ENV'] : undefined; if (nodeEnv && MODES.includes(nodeEnv)) { return nodeEnv; } } catch (e) { } return 'production'; }; setRuntimeMode(getInitialMode()); let EXPERIMENTAL_MODE = false; let COLOR_CONTRAST_ANALYSIS = false; const isDevMode = () => runtimeMode === 'development'; const isTestMode = () => runtimeMode === 'test'; const getExperimentalMode = () => EXPERIMENTAL_MODE === true; const setExperimentalMode = (mode) => { EXPERIMENTAL_MODE = mode === true; }; const getColorContrastAnalysis = () => COLOR_CONTRAST_ANALYSIS === true; const setColorContrastAnalysis = (mode) => { COLOR_CONTRAST_ANALYSIS = mode === true; }; const LOG_STYLE = 'color: white; background: #666; font-weight: bold; padding: .25em .5em; border-radius: 3px; border: 1px solid #000'; const mapToArray$1 = (msg) => { return Array.isArray(msg) ? msg : [msg]; }; const getLogLabel = (label) => { return `%c${label}`; }; const handleClassifier = (label, classifier) => { if (typeof classifier === 'string' && classifier.length > 0) { return `${getLogLabel(label)} | ${classifier}`; } else { return getLogLabel(label); } }; const getShield = (label, options) => { return [handleClassifier(label, options === null || options === void 0 ? void 0 : options.classifier), `${LOG_STYLE};${(options === null || options === void 0 ? void 0 : options.overwriteStyle) || ''}`]; }; const isDevModeOrForceLog = (forceLog) => isDevMode() || forceLog === true; class Logger { constructor(label) { this.label = label; } debug(msg, options) { if (isDevModeOrForceLog(options === null || options === void 0 ? void 0 : options.forceLog)) { console.debug(...getShield(this.label, options), ...mapToArray$1(msg)); } } info(msg, options) { if (isDevModeOrForceLog(options === null || options === void 0 ? void 0 : options.forceLog)) { console.info(...getShield(this.label, options), ...mapToArray$1(msg)); } } trace(msg, options) { if (isDevModeOrForceLog(options === null || options === void 0 ? void 0 : options.forceLog)) { console.trace(...getShield(this.label, options), ...mapToArray$1(msg)); } } warn(msg, options) { if (isDevModeOrForceLog(options === null || options === void 0 ? void 0 : options.forceLog)) { console.warn(...getShield(this.label, options), ...mapToArray$1(msg)); } } error(msg, options) { console.error(...getShield(this.label, options), ...mapToArray$1(msg)); } throw(msg, options) { if (isDevModeOrForceLog(options === null || options === void 0 ? void 0 : options.forceLog)) { throw new Error(...getShield(this.label, options), ...mapToArray$1(msg)); } } } const Log = new Logger('KoliBri'); const a11yCache = new Set(); const a11yHint = (msg, options) => { if (a11yCache.has(msg) === false || false) { a11yCache.add(msg); Log.debug([msg].concat([]), { classifier: `✋ a11y`, forceLog: false, overwriteStyle: '; background-color: #09f', }); } }; const deprecatedCache = new Set(); const deprecatedHint = (msg, options) => { if (deprecatedCache.has(msg) === false || false) { deprecatedCache.add(msg); Log.warn([msg].concat([]), { classifier: `🔥 deprecated`, forceLog: false, overwriteStyle: '; background-color: #f00', }); } }; const devCache = new Set(); const devHint = (msg, options) => { if (devCache.has(msg) === false || !!(options === null || options === void 0 ? void 0 : options.force)) { devCache.add(msg); Log.debug([msg].concat((options === null || options === void 0 ? void 0 : options.details) || []), { classifier: `💻 dev`, forceLog: !!(options === null || options === void 0 ? void 0 : options.force), overwriteStyle: '; background-color: #f09', }); } }; const devWarning = (msg, options) => { if (devCache.has(msg) === false || false) { devCache.add(msg); Log.warn([msg].concat([]), { classifier: `⚠️ dev`, forceLog: false, overwriteStyle: '; background-color: #f09', }); } }; const featureCache = new Set(); const featureHint = (msg, done = false, options) => { if (featureCache.has(msg) === false || false) { featureCache.add(msg); msg += done === true ? ' ✅' : ''; Log.debug([msg].concat([]), { classifier: `🌟 feature`, forceLog: false, overwriteStyle: '; background-color: #309', }); } }; devHint(`We appreciate any feedback, comments, screenshots, or demo links of an application based on KoliBri (kolibri@itzbund.de). Thank you!`); const uiUxCache = new Set(); const uiUxHint = (msg, options) => { if (uiUxCache.has(msg) === false || false) { uiUxCache.add(msg); Log.debug([msg].concat([]), { classifier: `📑 ui/ux`, forceLog: false, overwriteStyle: '; background-color: #060;', }); } }; const a11yHintDisabled = () => { a11yHint(`"Disabled" limits accessibility and visibility. From an accessibility perspective, we recommend using the readonly attribute instead of disabled.\n- https://uxdesign.cc/is-it-ok-to-grey-out-disabled-buttons-8afa74a0fae`); }; const a11yHintLabelingLandmarks = (value) => { if (typeof value !== 'string' || value === '') { a11yHint(`Some structural elements, such as the nav tag, can be used multiple times on a webpage. To distinguish between similarly named structural elements, it is necessary to set an ARIA label.\n- https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/Navigation_Role#accessibility_concerns`); } }; const uiUxHintMillerscheZahl = (className, length = 8) => { if (length > 7) { uiUxHint(`[${className}] Within navigation structures, it is recommended to use no more than 7 menu items. Link: - https://en.wikipedia.org/wiki/The_Magical_Number_Seven,_Plus_or_Minus_Two`); } }; var n=.2126,r$1=.7152,t=.0722,e=1/12.92;function u(n){return Math.pow((n+.055)/1.055,2.4)}function a$1(a){var i=a[0]/255,c=a[1]/255,o=a[2]/255,s=i<=.03928?i*e:u(i),f=c<=.03928?c*e:u(c),l=o<=.03928?o*e:u(o);return s*n+f*r$1+l*t}function i(n){var r=255;8===(n=n.replace(/^#/,"")).length&&(r=parseInt(n.slice(6,8),16),n=n.substring(0,6)),4===n.length&&(r=parseInt(n.slice(3,4).repeat(2),16),n=n.substring(0,3)),3===n.length&&(n=n[0]+n[0]+n[1]+n[1]+n[2]+n[2]);var t=parseInt(n,16);return [t>>16,t>>8&255,255&t,r]}function c$1(n,r){return (Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function o(n,r){return c$1(a$1(n),a$1(r))}function s(n,r){return o(i(n),i(r))}function f(n){return n>=7?"AAA":n>=4.5?"AA":n>=3?"AA Large":"Fail"} var colorName; var hasRequiredColorName; function requireColorName () { if (hasRequiredColorName) return colorName; hasRequiredColorName = 1; colorName = { "aliceblue": [240, 248, 255], "antiquewhite": [250, 235, 215], "aqua": [0, 255, 255], "aquamarine": [127, 255, 212], "azure": [240, 255, 255], "beige": [245, 245, 220], "bisque": [255, 228, 196], "black": [0, 0, 0], "blanchedalmond": [255, 235, 205], "blue": [0, 0, 255], "blueviolet": [138, 43, 226], "brown": [165, 42, 42], "burlywood": [222, 184, 135], "cadetblue": [95, 158, 160], "chartreuse": [127, 255, 0], "chocolate": [210, 105, 30], "coral": [255, 127, 80], "cornflowerblue": [100, 149, 237], "cornsilk": [255, 248, 220], "crimson": [220, 20, 60], "cyan": [0, 255, 255], "darkblue": [0, 0, 139], "darkcyan": [0, 139, 139], "darkgoldenrod": [184, 134, 11], "darkgray": [169, 169, 169], "darkgreen": [0, 100, 0], "darkgrey": [169, 169, 169], "darkkhaki": [189, 183, 107], "darkmagenta": [139, 0, 139], "darkolivegreen": [85, 107, 47], "darkorange": [255, 140, 0], "darkorchid": [153, 50, 204], "darkred": [139, 0, 0], "darksalmon": [233, 150, 122], "darkseagreen": [143, 188, 143], "darkslateblue": [72, 61, 139], "darkslategray": [47, 79, 79], "darkslategrey": [47, 79, 79], "darkturquoise": [0, 206, 209], "darkviolet": [148, 0, 211], "deeppink": [255, 20, 147], "deepskyblue": [0, 191, 255], "dimgray": [105, 105, 105], "dimgrey": [105, 105, 105], "dodgerblue": [30, 144, 255], "firebrick": [178, 34, 34], "floralwhite": [255, 250, 240], "forestgreen": [34, 139, 34], "fuchsia": [255, 0, 255], "gainsboro": [220, 220, 220], "ghostwhite": [248, 248, 255], "gold": [255, 215, 0], "goldenrod": [218, 165, 32], "gray": [128, 128, 128], "green": [0, 128, 0], "greenyellow": [173, 255, 47], "grey": [128, 128, 128], "honeydew": [240, 255, 240], "hotpink": [255, 105, 180], "indianred": [205, 92, 92], "indigo": [75, 0, 130], "ivory": [255, 255, 240], "khaki": [240, 230, 140], "lavender": [230, 230, 250], "lavenderblush": [255, 240, 245], "lawngreen": [124, 252, 0], "lemonchiffon": [255, 250, 205], "lightblue": [173, 216, 230], "lightcoral": [240, 128, 128], "lightcyan": [224, 255, 255], "lightgoldenrodyellow": [250, 250, 210], "lightgray": [211, 211, 211], "lightgreen": [144, 238, 144], "lightgrey": [211, 211, 211], "lightpink": [255, 182, 193], "lightsalmon": [255, 160, 122], "lightseagreen": [32, 178, 170], "lightskyblue": [135, 206, 250], "lightslategray": [119, 136, 153], "lightslategrey": [119, 136, 153], "lightsteelblue": [176, 196, 222], "lightyellow": [255, 255, 224], "lime": [0, 255, 0], "limegreen": [50, 205, 50], "linen": [250, 240, 230], "magenta": [255, 0, 255], "maroon": [128, 0, 0], "mediumaquamarine": [102, 205, 170], "mediumblue": [0, 0, 205], "mediumorchid": [186, 85, 211], "mediumpurple": [147, 112, 219], "mediumseagreen": [60, 179, 113], "mediumslateblue": [123, 104, 238], "mediumspringgreen": [0, 250, 154], "mediumturquoise": [72, 209, 204], "mediumvioletred": [199, 21, 133], "midnightblue": [25, 25, 112], "mintcream": [245, 255, 250], "mistyrose": [255, 228, 225], "moccasin": [255, 228, 181], "navajowhite": [255, 222, 173], "navy": [0, 0, 128], "oldlace": [253, 245, 230], "olive": [128, 128, 0], "olivedrab": [107, 142, 35], "orange": [255, 165, 0], "orangered": [255, 69, 0], "orchid": [218, 112, 214], "palegoldenrod": [238, 232, 170], "palegreen": [152, 251, 152], "paleturquoise": [175, 238, 238], "palevioletred": [219, 112, 147], "papayawhip": [255, 239, 213], "peachpuff": [255, 218, 185], "peru": [205, 133, 63], "pink": [255, 192, 203], "plum": [221, 160, 221], "powderblue": [176, 224, 230], "purple": [128, 0, 128], "rebeccapurple": [102, 51, 153], "red": [255, 0, 0], "rosybrown": [188, 143, 143], "royalblue": [65, 105, 225], "saddlebrown": [139, 69, 19], "salmon": [250, 128, 114], "sandybrown": [244, 164, 96], "seagreen": [46, 139, 87], "seashell": [255, 245, 238], "sienna": [160, 82, 45], "silver": [192, 192, 192], "skyblue": [135, 206, 235], "slateblue": [106, 90, 205], "slategray": [112, 128, 144], "slategrey": [112, 128, 144], "snow": [255, 250, 250], "springgreen": [0, 255, 127], "steelblue": [70, 130, 180], "tan": [210, 180, 140], "teal": [0, 128, 128], "thistle": [216, 191, 216], "tomato": [255, 99, 71], "turquoise": [64, 224, 208], "violet": [238, 130, 238], "wheat": [245, 222, 179], "white": [255, 255, 255], "whitesmoke": [245, 245, 245], "yellow": [255, 255, 0], "yellowgreen": [154, 205, 50] }; return colorName; } /** * @module color-parse */ var colorParse; var hasRequiredColorParse; function requireColorParse () { if (hasRequiredColorParse) return colorParse; hasRequiredColorParse = 1; var names = requireColorName(); colorParse = parse; /** * Base hues * http://dev.w3.org/csswg/css-color/#typedef-named-hue */ //FIXME: use external hue detector var baseHues = { red: 0, orange: 60, yellow: 120, green: 180, blue: 240, purple: 300 }; /** * Parse color from the string passed * * @return {Object} A space indicator `space`, an array `values` and `alpha` */ function parse(cstr) { var m, parts = [], alpha = 1, space; if (typeof cstr === 'string') { cstr = cstr.toLowerCase(); //keyword if (names[cstr]) { parts = names[cstr].slice(); space = 'rgb'; } //reserved words else if (cstr === 'transparent') { alpha = 0; space = 'rgb'; parts = [0, 0, 0]; } //hex else if (/^#[A-Fa-f0-9]+$/.test(cstr)) { var base = cstr.slice(1); var size = base.length; var isShort = size <= 4; alpha = 1; if (isShort) { parts = [ parseInt(base[0] + base[0], 16), parseInt(base[1] + base[1], 16), parseInt(base[2] + base[2], 16) ]; if (size === 4) { alpha = parseInt(base[3] + base[3], 16) / 255; } } else { parts = [ parseInt(base[0] + base[1], 16), parseInt(base[2] + base[3], 16), parseInt(base[4] + base[5], 16) ]; if (size === 8) { alpha = parseInt(base[6] + base[7], 16) / 255; } } if (!parts[0]) parts[0] = 0; if (!parts[1]) parts[1] = 0; if (!parts[2]) parts[2] = 0; space = 'rgb'; } //color space else if (m = /^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(cstr)) { var name = m[1]; var isRGB = name === 'rgb'; var base = name.replace(/a$/, ''); space = base; var size = base === 'cmyk' ? 4 : base === 'gray' ? 1 : 3; parts = m[2].trim() .split(/\s*[,\/]\s*|\s+/) .map(function (x, i) { //<percentage> if (/%$/.test(x)) { //alpha if (i === size) return parseFloat(x) / 100 //rgb if (base === 'rgb') return parseFloat(x) * 255 / 100 return parseFloat(x) } //hue else if (base[i] === 'h') { //<deg> if (/deg$/.test(x)) { return parseFloat(x) } //<base-hue> else if (baseHues[x] !== undefined) { return baseHues[x] } } return parseFloat(x) }); if (name === base) parts.push(1); alpha = (isRGB) ? 1 : (parts[size] === undefined) ? 1 : parts[size]; parts = parts.slice(0, size); } //named channels case else if (cstr.length > 10 && /[0-9](?:\s|\/)/.test(cstr)) { parts = cstr.match(/([0-9]+)/g).map(function (value) { return parseFloat(value) }); space = cstr.match(/([a-z])/ig).join('').toLowerCase(); } } //numeric case else if (!isNaN(cstr)) { space = 'rgb'; parts = [cstr >>> 16, (cstr & 0x00ff00) >>> 8, cstr & 0x0000ff]; } //array-like else if (Array.isArray(cstr) || cstr.length) { parts = [cstr[0], cstr[1], cstr[2]]; space = 'rgb'; alpha = cstr.length === 4 ? cstr[3] : 1; } //object case - detects css cases of rgb and hsl else if (cstr instanceof Object) { if (cstr.r != null || cstr.red != null || cstr.R != null) { space = 'rgb'; parts = [ cstr.r || cstr.red || cstr.R || 0, cstr.g || cstr.green || cstr.G || 0, cstr.b || cstr.blue || cstr.B || 0 ]; } else { space = 'hsl'; parts = [ cstr.h || cstr.hue || cstr.H || 0, cstr.s || cstr.saturation || cstr.S || 0, cstr.l || cstr.lightness || cstr.L || cstr.b || cstr.brightness ]; } alpha = cstr.a || cstr.alpha || cstr.opacity || 1; if (cstr.opacity != null) alpha /= 100; } return { space: space, values: parts, alpha: alpha } } return colorParse; } var colorParseExports = requireColorParse(); var parse = /*@__PURE__*/getDefaultExportFromCjs(colorParseExports); /** * RGB space. * * @module color-space/rgb */ const rgb = { min: [0, 0, 0], max: [255, 255, 255]}; /** * @module color-space/hsl */ var hsl = { name: 'hsl', min: [0, 0, 0], max: [360, 100, 100], channel: ['hue', 'saturation', 'lightness'], alias: ['HSL'], rgb: function (hsl) { var h = hsl[0] / 360, s = hsl[1] / 100, l = hsl[2] / 100, t1, t2, t3, rgb, val, i = 0; if (s === 0) return val = l * 255, [val, val, val]; t2 = l < 0.5 ? l * (1 + s) : l + s - l * s; t1 = 2 * l - t2; rgb = [0, 0, 0]; for (; i < 3;) { t3 = h + 1 / 3 * - (i - 1); t3 < 0 ? t3++ : t3 > 1 && t3--; val = 6 * t3 < 1 ? t1 + (t2 - t1) * 6 * t3 : 2 * t3 < 1 ? t2 : 3 * t3 < 2 ? t1 + (t2 - t1) * (2 / 3 - t3) * 6 : t1; rgb[i++] = val * 255; } return rgb; } }; //extend rgb rgb.hsl = function (rgb) { var r = rgb[0] / 255, g = rgb[1] / 255, b = rgb[2] / 255, min = Math.min(r, g, b), max = Math.max(r, g, b), delta = max - min, h, s, l; if (max === min) { h = 0; } else if (r === max) { h = (g - b) / delta; } else if (g === max) { h = 2 + (b - r) / delta; } else if (b === max) { h = 4 + (r - g) / delta; } //FIXME h is possibly undefined //@ts-ignore h = Math.min(h * 60, 360); if (h < 0) { h += 360; } l = (min + max) / 2; if (max === min) { s = 0; } else if (l <= 0.5) { s = delta / (max + min); } else { s = delta / (2 - max - min); } return [h, s * 100, l * 100]; }; /** @module color-rgba */ function rgba$1 (color) { // template literals if (Array.isArray(color) && color.raw) color = String.raw(...arguments); var values; //attempt to parse non-array arguments var parsed = parse(color); if (!parsed.space) return [] const min = parsed.space[0] === 'h' ? hsl.min : rgb.min; const max = parsed.space[0] === 'h' ? hsl.max : rgb.max; values = Array(3); values[0] = Math.min(Math.max(parsed.values[0], min[0]), max[0]); values[1] = Math.min(Math.max(parsed.values[1], min[1]), max[1]); values[2] = Math.min(Math.max(parsed.values[2], min[2]), max[2]); if (parsed.space[0] === 'h') { values = hsl.rgb(values); } values.push(Math.min(Math.max(parsed.alpha, 0), 1)); return values } var rgbaConvert = {exports: {}}; var hasRequiredRgbaConvert; function requireRgbaConvert () { if (hasRequiredRgbaConvert) return rgbaConvert.exports; hasRequiredRgbaConvert = 1; rgbaConvert.exports = arr; rgbaConvert.exports.arr = arr; rgbaConvert.exports.obj = obj; rgbaConvert.exports.css = css; rgbaConvert.exports.hex = hex; rgbaConvert.exports.num = num; function arr(data) { var a = parse(data); if (a.length == 3) { return a.concat(255) } else { a[3] = Math.round(a[3]); return a } } function obj(data) { var a = parse(data); return { r: a[0], g: a[1], b: a[2], a: a.length == 3 ? 255 : Math.round(a[3]) } } function css(data) { var a = parse(data); if (a.length == 3) a.push(255); return a[3] == 255 ? 'rgb(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')' : a[3] == 0 ? 'rgba(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', 0)' : 'rgba(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + String(a[3] / 255).substr(1) + ')' } function hex(data) { var a = parse(data); if (a.length == 3) a.push(255); var opaque = a[3] == 255; var r = num2hex(a[0]); var g = num2hex(a[1]); var b = num2hex(a[2]); var a = num2hex(Math.round(a[3])); var is = isshort(r, g, b, a); if (opaque) { return is ? '#' + r.charAt(0) + g.charAt(0) + b.charAt(0) :