@likec4/mcp 1.55.1 → 1.56.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) hide show
  1. package/README.md +2 -2
  2. package/bin/likec4-mcp.mjs +3 -0
  3. package/dist/chunks/libs/@chevrotain/gast.mjs +1 -0
  4. package/dist/chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -0
  5. package/dist/chunks/libs/@chevrotain/utils.mjs +1 -0
  6. package/dist/chunks/libs/@hono/mcp.mjs +45 -0
  7. package/dist/chunks/libs/@hono/node-server.mjs +1 -0
  8. package/dist/chunks/libs/@logtape/logtape.mjs +4 -0
  9. package/dist/chunks/libs/@lume/kiwi.mjs +1 -0
  10. package/dist/chunks/libs/@modelcontextprotocol/sdk.mjs +12 -0
  11. package/dist/chunks/libs/@radix-ui/colors.mjs +1 -0
  12. package/dist/chunks/libs/@ungap/structured-clone.mjs +1 -0
  13. package/dist/chunks/libs/bail.mjs +1 -0
  14. package/dist/chunks/libs/ccount.mjs +1 -0
  15. package/dist/chunks/libs/chevrotain-allstar.mjs +2 -0
  16. package/dist/chunks/libs/chevrotain.mjs +58 -0
  17. package/dist/chunks/libs/chokidar.mjs +3 -0
  18. package/dist/chunks/libs/chroma-js.mjs +15 -0
  19. package/dist/chunks/libs/citty.mjs +5 -0
  20. package/dist/chunks/libs/comma-separated-tokens.mjs +1 -0
  21. package/dist/chunks/libs/decode-named-character-reference.mjs +1 -0
  22. package/dist/chunks/libs/defu.mjs +1 -0
  23. package/dist/chunks/libs/destr.mjs +1 -0
  24. package/dist/chunks/libs/devlop.mjs +1 -0
  25. package/dist/chunks/libs/escape-string-regexp.mjs +1 -0
  26. package/dist/chunks/libs/eventemitter3.mjs +1 -0
  27. package/dist/chunks/libs/extend.mjs +1 -0
  28. package/dist/chunks/libs/fdir.mjs +1 -0
  29. package/dist/chunks/libs/graphology-dag.mjs +1 -0
  30. package/dist/chunks/libs/graphology.mjs +1 -0
  31. package/dist/chunks/libs/hast-util-sanitize.mjs +1 -0
  32. package/dist/chunks/libs/hast-util-to-html.mjs +9 -0
  33. package/dist/chunks/libs/hono.mjs +1 -0
  34. package/dist/chunks/libs/immer.mjs +1 -0
  35. package/dist/chunks/libs/is-error-instance.mjs +1 -0
  36. package/dist/chunks/libs/is-plain-obj.mjs +1 -0
  37. package/dist/chunks/libs/isexe.mjs +1 -0
  38. package/dist/chunks/libs/json5.mjs +14 -0
  39. package/dist/chunks/libs/khroma.mjs +1 -0
  40. package/dist/chunks/libs/langium.mjs +29 -0
  41. package/dist/chunks/libs/longest-streak.mjs +1 -0
  42. package/dist/chunks/libs/markdown-table.mjs +2 -0
  43. package/dist/chunks/libs/mdast-util-find-and-replace.mjs +1 -0
  44. package/dist/chunks/libs/mdast-util-from-markdown.mjs +3 -0
  45. package/dist/chunks/libs/mdast-util-gfm.mjs +15 -0
  46. package/dist/chunks/libs/mdast-util-to-hast.mjs +11 -0
  47. package/dist/chunks/libs/merge-error-cause.mjs +2 -0
  48. package/dist/chunks/libs/micromark-extension-gfm.mjs +1 -0
  49. package/dist/chunks/libs/mnemonist.mjs +1 -0
  50. package/dist/chunks/libs/nano-spawn.mjs +3 -0
  51. package/dist/chunks/libs/natural-compare-lite.mjs +9 -0
  52. package/dist/chunks/libs/ohash.mjs +1 -0
  53. package/dist/chunks/libs/p-limit.mjs +1 -0
  54. package/dist/chunks/libs/p-queue.mjs +1 -0
  55. package/dist/chunks/libs/p-timeout.mjs +1 -0
  56. package/dist/chunks/libs/parse-ms.mjs +1 -0
  57. package/dist/chunks/libs/pathe.mjs +1 -0
  58. package/dist/chunks/libs/pretty-ms.mjs +1 -0
  59. package/dist/chunks/libs/rehype-sanitize.mjs +1 -0
  60. package/dist/chunks/libs/rehype-stringify.mjs +1 -0
  61. package/dist/chunks/libs/remark-gfm.mjs +1 -0
  62. package/dist/chunks/libs/remark-github-blockquote-alert.mjs +3 -0
  63. package/dist/chunks/libs/remark-parse.mjs +1 -0
  64. package/dist/chunks/libs/remark-rehype.mjs +1 -0
  65. package/dist/chunks/libs/remeda.mjs +1 -0
  66. package/dist/chunks/libs/safe-stringify.mjs +1 -0
  67. package/dist/chunks/libs/strip-indent.mjs +1 -0
  68. package/dist/chunks/libs/tinyrainbow.mjs +1 -0
  69. package/dist/chunks/libs/trough.mjs +1 -0
  70. package/dist/chunks/libs/ts-graphviz.mjs +4 -0
  71. package/dist/chunks/libs/ufo.mjs +1 -0
  72. package/dist/chunks/libs/unified.mjs +1 -0
  73. package/dist/chunks/libs/unstorage.mjs +1 -0
  74. package/dist/chunks/libs/which.mjs +1 -0
  75. package/dist/chunks/libs/word-wrap.mjs +12 -0
  76. package/dist/chunks/rolldown-runtime.mjs +1 -0
  77. package/dist/chunks/src.mjs +1228 -0
  78. package/dist/cli.mjs +1 -1
  79. package/dist/index.mjs +1 -1
  80. package/package.json +21 -17
  81. package/dist/THIRD-PARTY-LICENSES.md +0 -2318
  82. package/dist/_chunks/libs/@chevrotain/cst-dts-gen.mjs +0 -30
  83. package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +0 -9
  84. package/dist/_chunks/libs/@chevrotain/utils.mjs +0 -1
  85. package/dist/_chunks/libs/@hono/mcp.mjs +0 -45
  86. package/dist/_chunks/libs/@hono/node-server.mjs +0 -1
  87. package/dist/_chunks/libs/@logtape/logtape.mjs +0 -4
  88. package/dist/_chunks/libs/@lume/kiwi.mjs +0 -1
  89. package/dist/_chunks/libs/@mantine/colors-generator.mjs +0 -15
  90. package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +0 -12
  91. package/dist/_chunks/libs/@radix-ui/colors.mjs +0 -1
  92. package/dist/_chunks/libs/@ungap/structured-clone.mjs +0 -1
  93. package/dist/_chunks/libs/bail.mjs +0 -1
  94. package/dist/_chunks/libs/ccount.mjs +0 -1
  95. package/dist/_chunks/libs/chevrotain-allstar.mjs +0 -2
  96. package/dist/_chunks/libs/chevrotain.mjs +0 -58
  97. package/dist/_chunks/libs/chokidar.mjs +0 -3
  98. package/dist/_chunks/libs/citty.mjs +0 -5
  99. package/dist/_chunks/libs/comma-separated-tokens.mjs +0 -1
  100. package/dist/_chunks/libs/decode-named-character-reference.mjs +0 -1
  101. package/dist/_chunks/libs/defu.mjs +0 -1
  102. package/dist/_chunks/libs/destr.mjs +0 -1
  103. package/dist/_chunks/libs/devlop.mjs +0 -1
  104. package/dist/_chunks/libs/escape-string-regexp.mjs +0 -1
  105. package/dist/_chunks/libs/eventemitter3.mjs +0 -1
  106. package/dist/_chunks/libs/extend.mjs +0 -1
  107. package/dist/_chunks/libs/fast-equals.mjs +0 -1
  108. package/dist/_chunks/libs/fdir.mjs +0 -1
  109. package/dist/_chunks/libs/graphology-dag.mjs +0 -1
  110. package/dist/_chunks/libs/graphology.mjs +0 -1
  111. package/dist/_chunks/libs/hast-util-sanitize.mjs +0 -1
  112. package/dist/_chunks/libs/hast-util-to-html.mjs +0 -9
  113. package/dist/_chunks/libs/immer.mjs +0 -1
  114. package/dist/_chunks/libs/is-error-instance.mjs +0 -1
  115. package/dist/_chunks/libs/is-plain-obj.mjs +0 -1
  116. package/dist/_chunks/libs/isexe.mjs +0 -1
  117. package/dist/_chunks/libs/json5.mjs +0 -14
  118. package/dist/_chunks/libs/khroma.mjs +0 -1
  119. package/dist/_chunks/libs/langium.mjs +0 -30
  120. package/dist/_chunks/libs/longest-streak.mjs +0 -1
  121. package/dist/_chunks/libs/markdown-table.mjs +0 -2
  122. package/dist/_chunks/libs/mdast-util-find-and-replace.mjs +0 -1
  123. package/dist/_chunks/libs/mdast-util-from-markdown.mjs +0 -3
  124. package/dist/_chunks/libs/mdast-util-gfm.mjs +0 -15
  125. package/dist/_chunks/libs/mdast-util-to-hast.mjs +0 -11
  126. package/dist/_chunks/libs/merge-error-cause.mjs +0 -2
  127. package/dist/_chunks/libs/micromark-extension-gfm.mjs +0 -1
  128. package/dist/_chunks/libs/mnemonist.mjs +0 -1
  129. package/dist/_chunks/libs/nano-spawn.mjs +0 -3
  130. package/dist/_chunks/libs/natural-compare-lite.mjs +0 -9
  131. package/dist/_chunks/libs/ohash.mjs +0 -1
  132. package/dist/_chunks/libs/p-limit.mjs +0 -1
  133. package/dist/_chunks/libs/p-queue.mjs +0 -1
  134. package/dist/_chunks/libs/p-timeout.mjs +0 -1
  135. package/dist/_chunks/libs/parse-ms.mjs +0 -1
  136. package/dist/_chunks/libs/pathe.mjs +0 -1
  137. package/dist/_chunks/libs/pretty-ms.mjs +0 -1
  138. package/dist/_chunks/libs/rehype-sanitize.mjs +0 -1
  139. package/dist/_chunks/libs/rehype-stringify.mjs +0 -1
  140. package/dist/_chunks/libs/remark-gfm.mjs +0 -1
  141. package/dist/_chunks/libs/remark-github-blockquote-alert.mjs +0 -3
  142. package/dist/_chunks/libs/remark-parse.mjs +0 -1
  143. package/dist/_chunks/libs/remark-rehype.mjs +0 -1
  144. package/dist/_chunks/libs/remeda.mjs +0 -2
  145. package/dist/_chunks/libs/safe-stringify.mjs +0 -1
  146. package/dist/_chunks/libs/strip-indent.mjs +0 -1
  147. package/dist/_chunks/libs/tinyrainbow.mjs +0 -1
  148. package/dist/_chunks/libs/trough.mjs +0 -1
  149. package/dist/_chunks/libs/ts-graphviz.mjs +0 -4
  150. package/dist/_chunks/libs/ufo.mjs +0 -1
  151. package/dist/_chunks/libs/unified.mjs +0 -1
  152. package/dist/_chunks/libs/unstorage.mjs +0 -1
  153. package/dist/_chunks/libs/which.mjs +0 -1
  154. package/dist/_chunks/libs/word-wrap.mjs +0 -12
  155. package/dist/_chunks/rolldown-runtime.mjs +0 -1
  156. package/dist/_chunks/src.mjs +0 -1228
  157. /package/dist/{_chunks → chunks}/libs/character-entities-html4.mjs +0 -0
  158. /package/dist/{_chunks → chunks}/libs/character-entities-legacy.mjs +0 -0
  159. /package/dist/{_chunks → chunks}/libs/character-entities.mjs +0 -0
@@ -1 +0,0 @@
1
- import e from"crypto";import{createServer as t}from"http";import{Http2ServerRequest as n,constants as r}from"http2";import{Readable as i}from"stream";var a=class extends Error{constructor(e,t){super(e,t),this.name=`RequestError`}},o=e=>e instanceof a?e:new a(e.message,{cause:e}),s=global.Request,c=class extends s{constructor(e,t){typeof e==`object`&&f in e&&(e=e[f]()),t?.body?.getReader!==void 0&&(t.duplex??=`half`),super(e,t)}},l=e=>{let t=[],n=e.rawHeaders;for(let e=0;e<n.length;e+=2){let{[e]:r,[e+1]:i}=n;r.charCodeAt(0)!==58&&t.push([r,i])}return new Headers(t)},u=Symbol(`wrapBodyStream`),d=(e,t,n,r,a)=>{let o={method:e,headers:n,signal:a.signal};if(e===`TRACE`){o.method=`GET`;let e=new c(t,o);return Object.defineProperty(e,`method`,{get(){return`TRACE`}}),e}if(!(e===`GET`||e===`HEAD`))if(`rawBody`in r&&r.rawBody instanceof Buffer)o.body=new ReadableStream({start(e){e.enqueue(r.rawBody),e.close()}});else if(r[u]){let e;o.body=new ReadableStream({async pull(t){try{e||=i.toWeb(r).getReader();let{done:n,value:a}=await e.read();n?t.close():t.enqueue(a)}catch(e){t.error(e)}}})}else o.body=i.toWeb(r);return new c(t,o)},f=Symbol(`getRequestCache`),p=Symbol(`requestCache`),m=Symbol(`incomingKey`),h=Symbol(`urlKey`),g=Symbol(`headersKey`),_=Symbol(`abortControllerKey`),v={get method(){return this[m].method||`GET`},get url(){return this[h]},get headers(){return this[g]||=l(this[m])},[Symbol(`getAbortController`)](){return this[f](),this[_]},[f](){return this[_]||=new AbortController,this[p]||=d(this.method,this[h],this.headers,this[m],this[_])}};[`body`,`bodyUsed`,`cache`,`credentials`,`destination`,`integrity`,`mode`,`redirect`,`referrer`,`referrerPolicy`,`signal`,`keepalive`].forEach(e=>{Object.defineProperty(v,e,{get(){return this[f]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(v,e,{value:function(){return this[f]()[e]()}})}),Object.setPrototypeOf(v,c.prototype);var y=(e,t)=>{let r=Object.create(v);r[m]=e;let i=e.url||``;if(i[0]!==`/`&&(i.startsWith(`http://`)||i.startsWith(`https://`))){if(e instanceof n)throw new a(`Absolute URL for :path is not allowed in HTTP/2`);try{r[h]=new URL(i).href}catch(e){throw new a(`Invalid absolute URL`,{cause:e})}return r}let o=(e instanceof n?e.authority:e.headers.host)||t;if(!o)throw new a(`Missing host header`);let s;if(e instanceof n){if(s=e.scheme,!(s===`http`||s===`https`))throw new a(`Unsupported scheme`)}else s=e.socket&&e.socket.encrypted?`https`:`http`;let c=new URL(`${s}://${o}${i}`);if(c.hostname.length!==o.length&&c.hostname!==o.replace(/:\d+$/,``))throw new a(`Invalid host header`);return r[h]=c.href,r},b=Symbol(`responseCache`),x=Symbol(`getResponseCache`),S=Symbol(`cache`),C=global.Response,w=class e{#e;#t;[x](){return delete this[S],this[b]||=new C(this.#e,this.#t)}constructor(t,n){let r;if(this.#e=t,n instanceof e){let e=n[b];if(e){this.#t=e,this[x]();return}else this.#t=n.#t,r=new Headers(n.#t.headers)}else this.#t=n;(typeof t==`string`||t?.getReader!==void 0||t instanceof Blob||t instanceof Uint8Array)&&(this[S]=[n?.status||200,t,r||n?.headers])}get headers(){let e=this[S];return e?(e[2]instanceof Headers||(e[2]=new Headers(e[2]||{"content-type":`text/plain; charset=UTF-8`})),e[2]):this[x]().headers}get status(){return this[S]?.[0]??this[x]().status}get ok(){let e=this.status;return e>=200&&e<300}};[`body`,`bodyUsed`,`redirected`,`statusText`,`trailers`,`type`,`url`].forEach(e=>{Object.defineProperty(w.prototype,e,{get(){return this[x]()[e]}})}),[`arrayBuffer`,`blob`,`clone`,`formData`,`json`,`text`].forEach(e=>{Object.defineProperty(w.prototype,e,{value:function(){return this[x]()[e]()}})}),Object.setPrototypeOf(w,C),Object.setPrototypeOf(w.prototype,C.prototype);async function T(e){return Promise.race([e,Promise.resolve().then(()=>Promise.resolve(void 0))])}function E(e,t,n){let r=t=>{e.cancel(t).catch(()=>{})};return t.on(`close`,r),t.on(`error`,r),(n??e.read()).then(o,i),e.closed.finally(()=>{t.off(`close`,r),t.off(`error`,r)});function i(e){e&&t.destroy(e)}function a(){e.read().then(o,i)}function o({done:n,value:r}){try{if(n)t.end();else if(!t.write(r))t.once(`drain`,a);else return e.read().then(o,i)}catch(e){i(e)}}}function D(e,t){if(e.locked)throw TypeError(`ReadableStream is locked.`);return t.destroyed?void 0:E(e.getReader(),t)}var O=e=>{let t={};e instanceof Headers||(e=new Headers(e??void 0));let n=[];for(let[r,i]of e)r===`set-cookie`?n.push(i):t[r]=i;return n.length>0&&(t[`set-cookie`]=n),t[`content-type`]??=`text/plain; charset=UTF-8`,t},k=`x-hono-already-sent`;global.crypto===void 0&&(global.crypto=e);var A=Symbol(`outgoingEnded`),j=Symbol(`incomingDraining`),M=500,N=64*1024*1024,P=e=>{let t=e;if(e.destroyed||t[j])return;if(t[j]=!0,e instanceof n){try{e.stream?.close?.(r.NGHTTP2_NO_ERROR)}catch{}return}let i=0,a=()=>{clearTimeout(s),e.off(`data`,c),e.off(`end`,a),e.off(`error`,a)},o=()=>{a();let t=e.socket;t&&!t.destroyed&&t.destroySoon()},s=setTimeout(o,M);s.unref?.();let c=e=>{i+=e.length,i>N&&o()};e.on(`data`,c),e.on(`end`,a),e.on(`error`,a),e.resume()},F=()=>new Response(null,{status:400}),I=e=>new Response(null,{status:e instanceof Error&&(e.name===`TimeoutError`||e.constructor.name===`TimeoutError`)?504:500}),L=(e,t)=>{let n=e instanceof Error?e:Error(`unknown error`,{cause:e});n.code===`ERR_STREAM_PREMATURE_CLOSE`?console.info(`The user aborted a request.`):(console.error(e),t.headersSent||t.writeHead(500,{"Content-Type":`text/plain`}),t.end(`Error: ${n.message}`),t.destroy(n))},R=e=>{`flushHeaders`in e&&e.writable&&e.flushHeaders()},z=async(e,t)=>{let[n,r,i]=e[S],a=!1;if(!i)i={"content-type":`text/plain; charset=UTF-8`};else if(i instanceof Headers)a=i.has(`content-length`),i=O(i);else if(Array.isArray(i)){let e=new Headers(i);a=e.has(`content-length`),i=O(e)}else for(let e in i)if(e.length===14&&e.toLowerCase()===`content-length`){a=!0;break}a||(typeof r==`string`?i[`Content-Length`]=Buffer.byteLength(r):r instanceof Uint8Array?i[`Content-Length`]=r.byteLength:r instanceof Blob&&(i[`Content-Length`]=r.size)),t.writeHead(n,i),typeof r==`string`||r instanceof Uint8Array?t.end(r):r instanceof Blob?t.end(new Uint8Array(await r.arrayBuffer())):(R(t),await D(r,t)?.catch(e=>L(e,t))),t[A]?.()},B=e=>typeof e.then==`function`,V=async(e,t,n={})=>{if(B(e))if(n.errorHandler)try{e=await e}catch(t){let r=await n.errorHandler(t);if(!r)return;e=r}else e=await e.catch(I);if(S in e)return z(e,t);let r=O(e.headers);if(e.body){let n=e.body.getReader(),i=[],a=!1,o;if(r[`transfer-encoding`]!==`chunked`){let e=2;for(let t=0;t<e;t++){o||=n.read();let r=await T(o).catch(e=>{console.error(e),a=!0});if(!r){if(t===1){await new Promise(e=>setTimeout(e)),e=3;continue}break}if(o=void 0,r.value&&i.push(r.value),r.done){a=!0;break}}a&&!(`content-length`in r)&&(r[`content-length`]=i.reduce((e,t)=>e+t.length,0))}t.writeHead(e.status,r),i.forEach(e=>{t.write(e)}),a?t.end():(i.length===0&&R(t),await E(n,t,o))}else r[k]||(t.writeHead(e.status,r),t.end());t[A]?.()},H=(e,t={})=>{let r=t.autoCleanupIncoming??!0;return t.overrideGlobalObjects!==!1&&global.Request!==c&&(Object.defineProperty(global,`Request`,{value:c}),Object.defineProperty(global,`Response`,{value:w})),async(i,a)=>{let s,c;try{c=y(i,t.hostname);let o=!r||i.method===`GET`||i.method===`HEAD`;if(o||(i[u]=!0,i.on(`end`,()=>{o=!0}),i instanceof n&&(a[A]=()=>{o||setTimeout(()=>{o||setTimeout(()=>{P(i)})})}),a.on(`finish`,()=>{o||P(i)})),a.on(`close`,()=>{c[_]&&(i.errored?c[_].abort(i.errored.toString()):a.writableFinished||c[_].abort(`Client connection prematurely closed.`)),o||setTimeout(()=>{o||setTimeout(()=>{P(i)})})}),s=e(c,{incoming:i,outgoing:a}),S in s)return z(s,a)}catch(e){if(s)return L(e,a);if(t.errorHandler){if(s=await t.errorHandler(c?e:o(e)),!s)return}else s=c?I(e):F()}try{return await V(s,a,t)}catch(e){return L(e,a)}}},U=e=>{let n=e.fetch,r=H(n,{hostname:e.hostname,overrideGlobalObjects:e.overrideGlobalObjects,autoCleanupIncoming:e.autoCleanupIncoming});return(e.createServer||t)(e.serverOptions||{},r)},W=(e,t)=>{let n=U(e);return n.listen(e?.port??3e3,e.hostname,()=>{let e=n.address();t&&t(e)}),n};export{W as t};
@@ -1,4 +0,0 @@
1
- import{r as e}from"../../rolldown-runtime.mjs";import t from"node:util";function n(e){return typeof e==`function`?e:r(e)}function r(e){if(e==null)return()=>!1;if(e===`fatal`)return e=>e.level===`fatal`;if(e===`error`)return e=>e.level===`fatal`||e.level===`error`;if(e===`warning`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`;if(e===`info`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`;if(e===`debug`)return e=>e.level===`fatal`||e.level===`error`||e.level===`warning`||e.level===`info`||e.level===`debug`;if(e===`trace`)return()=>!0;throw TypeError(`Invalid log level: ${e}.`)}const i=[`trace`,`debug`,`info`,`warning`,`error`,`fatal`];function a(e,t){let n=i.indexOf(e);if(n<0)throw TypeError(`Invalid log level: ${JSON.stringify(e)}.`);let r=i.indexOf(t);if(r<0)throw TypeError(`Invalid log level: ${JSON.stringify(t)}.`);return n-r}const o=Symbol.for(`logtape.lazy`);function s(e){return typeof e==`object`&&!!e&&o in e&&e[o]===!0}function c(e){let t={};for(let n in e){let r=e[n];t[n]=s(r)?r.getter():r}return t}function l(e=[]){return d.getLogger(e)}const u=Symbol.for(`logtape.rootLogger`);var d=class e{parent;children;category;sinks;parentSinks=`inherit`;filters;lowestLevel=`trace`;contextLocalStorage;static getLogger(t=[]){let n=u in globalThis?globalThis[u]??null:null;return n??(n=new e(null,[]),globalThis[u]=n),typeof t==`string`?n.getChild(t):t.length===0?n:n.getChild(t)}constructor(e,t){this.parent=e,this.children={},this.category=t,this.sinks=[],this.filters=[]}getChild(t){let n=typeof t==`string`?t:t[0],r=this.children[n],i=r instanceof e?r:r?.deref();return i??(i=new e(this,[...this.category,n]),this.children[n]=`WeakRef`in globalThis?new WeakRef(i):i),typeof t==`string`||t.length===1?i:i.getChild(t.slice(1))}reset(){for(;this.sinks.length>0;)this.sinks.shift();for(this.parentSinks=`inherit`;this.filters.length>0;)this.filters.shift();this.lowestLevel=`trace`}resetDescendants(){for(let t of Object.values(this.children))(t instanceof e?t:t.deref())?.resetDescendants();this.reset()}with(e){return new f(this,{...e})}filter(e){for(let t of this.filters)if(!t(e))return!1;return this.filters.length<1?this.parent?.filter(e)??!0:!0}*getSinks(e){if(!(this.lowestLevel===null||a(e,this.lowestLevel)<0)){if(this.parent!=null&&this.parentSinks===`inherit`)for(let t of this.parent.getSinks(e))yield t;for(let e of this.sinks)yield e}}isEnabledFor(e){if(this.lowestLevel===null||a(e,this.lowestLevel)<0)return!1;for(let t of this.getSinks(e))return!0;return!1}emit(e,t){let n=x(),r=`category`in e?e.category:this.category,i=n.length>0?[...n,...r]:r,o=Object.getOwnPropertyDescriptors(e);o.category={value:i,enumerable:!0,configurable:!0};let s=Object.defineProperties({},o);if(!(this.lowestLevel===null||a(s.level,this.lowestLevel)<0||!this.filter(s))){for(let e of this.getSinks(s.level))if(!t?.has(e))try{e(s)}catch(n){let r=new Set(t);r.add(e),p.log(`fatal`,`Failed to emit a log record to sink {sink}: {error}`,{sink:e,error:n,record:s},r)}}}log(e,t,n,r){let i=S(),a,o=typeof n==`function`?{category:this.category,level:e,timestamp:Date.now(),get message(){return v(t,this.properties)},rawMessage:t,get properties(){return a??={...i,...n()},a}}:{category:this.category,level:e,timestamp:Date.now(),message:v(t,{...i,...n}),rawMessage:t,properties:{...i,...n}};this.emit(o,r)}logLazily(e,t,n={}){let r=S(),i,a;function o(){if((a==null||i==null)&&(a=t((e,...t)=>(i=e,y(e,t))),i==null))throw TypeError(`No log record was made.`);return[a,i]}this.emit({category:this.category,level:e,get message(){return o()[0]},get rawMessage(){return o()[1]},timestamp:Date.now(),properties:{...r,...n}})}logTemplate(e,t,n,r={}){let i=S();this.emit({category:this.category,level:e,message:y(t,n),rawMessage:t,timestamp:Date.now(),properties:{...i,...r}})}trace(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`trace`)?n().then(t=>{this.log(`trace`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`trace`)?t.then(t=>{this.log(`trace`,e,t)}):Promise.resolve();this.log(`trace`,e,t);return}this.log(`trace`,e,n??{})}else typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`debug`)?n().then(t=>{this.log(`debug`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`debug`)?t.then(t=>{this.log(`debug`,e,t)}):Promise.resolve();this.log(`debug`,e,t);return}this.log(`debug`,e,n??{})}else typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`info`)?n().then(t=>{this.log(`info`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`info`)?t.then(t=>{this.log(`info`,e,t)}):Promise.resolve();this.log(`info`,e,t);return}this.log(`info`,e,n??{})}else typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){if(e instanceof Error)this.log(`warning`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`warning`)?n().then(t=>{this.log(`warning`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`warning`)?t.then(t=>{this.log(`warning`,e,t)}):Promise.resolve();this.log(`warning`,e,t);return}this.log(`warning`,e,n??{})}else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){if(e instanceof Error)this.log(`warning`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`warning`)?n().then(t=>{this.log(`warning`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`warning`)?t.then(t=>{this.log(`warning`,e,t)}):Promise.resolve();this.log(`warning`,e,t);return}this.log(`warning`,e,n??{})}else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}error(e,...t){if(e instanceof Error)this.log(`error`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`error`)?n().then(t=>{this.log(`error`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`error`)?t.then(t=>{this.log(`error`,e,t)}):Promise.resolve();this.log(`error`,e,t);return}this.log(`error`,e,n??{})}else typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){if(e instanceof Error)this.log(`fatal`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`fatal`)?n().then(t=>{this.log(`fatal`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`fatal`)?t.then(t=>{this.log(`fatal`,e,t)}):Promise.resolve();this.log(`fatal`,e,t);return}this.log(`fatal`,e,n??{})}else typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}},f=class e{logger;properties;constructor(e,t){this.logger=e,this.properties=t}get category(){return this.logger.category}get parent(){return this.logger.parent}getChild(e){return this.logger.getChild(e).with(this.properties)}with(t){return new e(this.logger,{...this.properties,...t})}log(e,t,n,r){let i=this.properties;this.logger.log(e,t,typeof n==`function`?()=>c({...i,...n()}):()=>c({...i,...n}),r)}logLazily(e,t){this.logger.logLazily(e,t,c(this.properties))}logTemplate(e,t,n){this.logger.logTemplate(e,t,n,c(this.properties))}emit(e){let t={...e,properties:c({...this.properties,...e.properties})};this.logger.emit(t)}isEnabledFor(e){return this.logger.isEnabledFor(e)}trace(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`trace`)?n().then(t=>{this.log(`trace`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`trace`)?t.then(t=>{this.log(`trace`,e,t)}):Promise.resolve();this.log(`trace`,e,t);return}this.log(`trace`,e,n??{})}else typeof e==`function`?this.logLazily(`trace`,e):Array.isArray(e)?this.logTemplate(`trace`,e,t):this.log(`trace`,`{*}`,e)}debug(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`debug`)?n().then(t=>{this.log(`debug`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`debug`)?t.then(t=>{this.log(`debug`,e,t)}):Promise.resolve();this.log(`debug`,e,t);return}this.log(`debug`,e,n??{})}else typeof e==`function`?this.logLazily(`debug`,e):Array.isArray(e)?this.logTemplate(`debug`,e,t):this.log(`debug`,`{*}`,e)}info(e,...t){if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`info`)?n().then(t=>{this.log(`info`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`info`)?t.then(t=>{this.log(`info`,e,t)}):Promise.resolve();this.log(`info`,e,t);return}this.log(`info`,e,n??{})}else typeof e==`function`?this.logLazily(`info`,e):Array.isArray(e)?this.logTemplate(`info`,e,t):this.log(`info`,`{*}`,e)}warn(e,...t){if(e instanceof Error)this.log(`warning`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`warning`)?n().then(t=>{this.log(`warning`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`warning`)?t.then(t=>{this.log(`warning`,e,t)}):Promise.resolve();this.log(`warning`,e,t);return}this.log(`warning`,e,n??{})}else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}warning(e,...t){if(e instanceof Error)this.log(`warning`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`warning`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`warning`)?n().then(t=>{this.log(`warning`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`warning`)?t.then(t=>{this.log(`warning`,e,t)}):Promise.resolve();this.log(`warning`,e,t);return}this.log(`warning`,e,n??{})}else typeof e==`function`?this.logLazily(`warning`,e):Array.isArray(e)?this.logTemplate(`warning`,e,t):this.log(`warning`,`{*}`,e)}error(e,...t){if(e instanceof Error)this.log(`error`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`error`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`error`)?n().then(t=>{this.log(`error`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`error`)?t.then(t=>{this.log(`error`,e,t)}):Promise.resolve();this.log(`error`,e,t);return}this.log(`error`,e,n??{})}else typeof e==`function`?this.logLazily(`error`,e):Array.isArray(e)?this.logTemplate(`error`,e,t):this.log(`error`,`{*}`,e)}fatal(e,...t){if(e instanceof Error)this.log(`fatal`,`{error.message}`,{error:e});else if(typeof e==`string`&&t[0]instanceof Error)this.log(`fatal`,e,{error:t[0]});else if(typeof e==`string`){let n=t[0];if(typeof n==`function`){if(n.constructor.name===`AsyncFunction`)return this.isEnabledFor(`fatal`)?n().then(t=>{this.log(`fatal`,e,t)}):Promise.resolve();let t=n();if(t instanceof Promise)return this.isEnabledFor(`fatal`)?t.then(t=>{this.log(`fatal`,e,t)}):Promise.resolve();this.log(`fatal`,e,t);return}this.log(`fatal`,e,n??{})}else typeof e==`function`?this.logLazily(`fatal`,e):Array.isArray(e)?this.logTemplate(`fatal`,e,t):this.log(`fatal`,`{*}`,e)}};const p=d.getLogger([`logtape`,`meta`]);function m(e){return e.includes(`.`)||e.includes(`[`)||e.includes(`?.`)}function h(e,t){if(!(t===`__proto__`||t===`prototype`||t===`constructor`)&&(typeof e==`object`||typeof e==`function`)&&e!==null)return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0}function g(e,t){let n=e.length,r=t;if(r>=n)return null;let i;if(e[r]===`[`){if(r++,r>=n)return null;if(e[r]===`"`||e[r]===`'`){let t=e[r];r++;let a=``;for(;r<n&&e[r]!==t;)if(e[r]===`\\`){if(r++,r<n){let t=e[r];switch(t){case`n`:a+=`
2
- `;break;case`t`:a+=` `;break;case`r`:a+=`\r`;break;case`b`:a+=`\b`;break;case`f`:a+=`\f`;break;case`v`:a+=`\v`;break;case`0`:a+=`\0`;break;case`\\`:a+=`\\`;break;case`"`:a+=`"`;break;case`'`:a+=`'`;break;case`u`:if(r+4<n){let n=e.slice(r+1,r+5),i=Number.parseInt(n,16);Number.isNaN(i)?a+=t:(a+=String.fromCharCode(i),r+=4)}else a+=t;break;default:a+=t}r++}}else a+=e[r],r++;if(r>=n)return null;i=a,r++}else{let t=r;for(;r<n&&e[r]!==`]`&&e[r]!==`'`&&e[r]!==`"`;)r++;if(r>=n)return null;let a=e.slice(t,r);if(a.length===0)return null;let o=Number(a);i=Number.isNaN(o)?a:o}for(;r<n&&e[r]!==`]`;)r++;r<n&&r++}else{let t=r;for(;r<n&&e[r]!==`.`&&e[r]!==`[`&&e[r]!==`?`&&e[r]!==`]`;)r++;if(i=e.slice(t,r),i.length===0)return null}return r<n&&e[r]===`.`&&r++,{segment:i,nextIndex:r}}function _(e,t){if(typeof t==`string`)return h(e,t);if(Array.isArray(e)&&t>=0&&t<e.length)return e[t]}function ee(e,t){if(e==null||t.length===0||t.endsWith(`.`))return;let n=e,r=0,i=t.length;for(;r<i;){if(t.slice(r,r+2)===`?.`){if(r+=2,n==null)return}else if(n==null)return;let e=g(t,r);if(e===null)return;let{segment:i,nextIndex:a}=e;if(r=a,n=_(n,i),n===void 0)return}return n}function v(e,t){let n=e.length;if(n===0)return[``];if(!e.includes(`{`))return[e];let r=[],i=0;for(let a=0;a<n;a++){let o=e[a];if(o===`{`){if((a+1<n?e[a+1]:``)===`{`){a++;continue}let o=e.indexOf(`}`,a+1);if(o===-1)continue;let s=e.slice(i,a);r.push(s.replace(/{{/g,`{`).replace(/}}/g,`}`));let c=e.slice(a+1,o),l,u=c.trim();u===`*`?l=c in t?t[c]:`*`in t?t[`*`]:t:(l=c===u||c in t?t[c]:t[u],l===void 0&&m(u)&&(l=ee(t,u))),r.push(l),a=o,i=a+1}else o===`}`&&a+1<n&&e[a+1]===`}`&&a++}let a=e.slice(i);return r.push(a.replace(/{{/g,`{`).replace(/}}/g,`}`)),r}function y(e,t){let n=[];for(let r=0;r<e.length;r++)n.push(e[r]),r<t.length&&n.push(t[r]);return n}const b=Symbol.for(`logtape.categoryPrefix`);function x(){let e=d.getLogger().contextLocalStorage?.getStore();if(e==null)return[];let t=e[b];return Array.isArray(t)?t:[]}function S(){let e=d.getLogger().contextLocalStorage?.getStore();if(e==null)return{};let t={};for(let n of Object.keys(e))t[n]=e[n];return t}var C=e({inspect:()=>w});function w(e,n){return t.inspect(e,n)}const T={trace:`TRC`,debug:`DBG`,info:`INF`,warning:`WRN`,error:`ERR`,fatal:`FTL`},E=typeof document<`u`||typeof navigator<`u`&&navigator.product===`ReactNative`?e=>JSON.stringify(e):`Deno`in globalThis&&`inspect`in globalThis.Deno&&typeof globalThis.Deno.inspect==`function`?(e,t)=>globalThis.Deno.inspect(e,{strAbbreviateSize:1/0,iterableLimit:1/0,...t}):C!=null&&`inspect`in C&&typeof w==`function`?(e,t)=>w(e,{maxArrayLength:1/0,maxStringLength:1/0,...t}):e=>JSON.stringify(e);function D(e){return e<10?`0${e}`:`${e}`}function O(e){return e<10?`00${e}`:e<100?`0${e}`:`${e}`}const k={"date-time-timezone":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${D(t.getUTCMonth()+1)}-${D(t.getUTCDate())} ${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())} +00:00`},"date-time-tz":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${D(t.getUTCMonth()+1)}-${D(t.getUTCDate())} ${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())} +00`},"date-time":e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${D(t.getUTCMonth()+1)}-${D(t.getUTCDate())} ${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())}`},"time-timezone":e=>{let t=new Date(e);return`${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())} +00:00`},"time-tz":e=>{let t=new Date(e);return`${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())} +00`},time:e=>{let t=new Date(e);return`${D(t.getUTCHours())}:${D(t.getUTCMinutes())}:${D(t.getUTCSeconds())}.${O(t.getUTCMilliseconds())}`},date:e=>{let t=new Date(e);return`${t.getUTCFullYear()}-${D(t.getUTCMonth()+1)}-${D(t.getUTCDate())}`},rfc3339:e=>new Date(e).toISOString(),none:()=>null},A={ABBR:T,abbr:{trace:`trc`,debug:`dbg`,info:`inf`,warning:`wrn`,error:`err`,fatal:`ftl`},FULL:{trace:`TRACE`,debug:`DEBUG`,info:`INFO`,warning:`WARNING`,error:`ERROR`,fatal:`FATAL`},full:{trace:`trace`,debug:`debug`,info:`info`,warning:`warning`,error:`error`,fatal:`fatal`},L:{trace:`T`,debug:`D`,info:`I`,warning:`W`,error:`E`,fatal:`F`},l:{trace:`t`,debug:`d`,info:`i`,warning:`w`,error:`e`,fatal:`f`}};function j(e){return e===`crlf`?`\r
3
- `:`
4
- `}function M(e,t){if(!(t instanceof Error))return t;let n={name:t.name,message:t.message};typeof t.stack==`string`&&(n.stack=t.stack);let r=t.cause;r!==void 0&&(n.cause=r),typeof AggregateError<`u`&&t instanceof AggregateError&&(n.errors=t.errors);for(let e of Object.keys(t))e in n||(n[e]=t[e]);return n}function N(e={}){let t=(()=>{let t=e.timestamp;return t==null?k[`date-time-timezone`]:t===`disabled`?k.none:typeof t==`string`&&t in k?k[t]:t})(),n=e.category??`·`,r=e.value?t=>e.value(t,E):E,i=(()=>{let t=e.level;return t==null||t===`ABBR`?e=>A.ABBR[e]:t===`abbr`?e=>A.abbr[e]:t===`FULL`?e=>A.FULL[e]:t===`full`?e=>A.full[e]:t===`L`?e=>A.L[e]:t===`l`?e=>A.l[e]:t})(),a=j(e.lineEnding),o=e.format??(({timestamp:e,level:t,category:n,message:r})=>`${e?`${e} `:``}[${t}] ${n}: ${r}`);return e=>{let s=e.message,c=s.length,l;if(c===1)l=s[0];else if(c<=6){l=``;for(let e=0;e<c;e++)l+=e%2==0?s[e]:r(s[e])}else{let e=Array(c);for(let t=0;t<c;t++)e[t]=t%2==0?s[t]:r(s[t]);l=e.join(``)}return`${o({timestamp:t(e.timestamp),level:i(e.level),category:typeof n==`function`?n(e.category):e.category.join(n),message:l,record:e})}${a}`}}N();const P=`\x1B[0m`,F={black:`\x1B[30m`,red:`\x1B[31m`,green:`\x1B[32m`,yellow:`\x1B[33m`,blue:`\x1B[34m`,magenta:`\x1B[35m`,cyan:`\x1B[36m`,white:`\x1B[37m`},I={bold:`\x1B[1m`,dim:`\x1B[2m`,italic:`\x1B[3m`,underline:`\x1B[4m`,strikethrough:`\x1B[9m`},L={trace:null,debug:`blue`,info:`green`,warning:`yellow`,error:`red`,fatal:`magenta`};function R(e={}){let t=e.format,n=e.timestampStyle===void 0?`dim`:e.timestampStyle,r=e.timestampColor??null,i=`${n==null?``:I[n]}${r==null?``:F[r]}`,a=n==null&&r==null?``:P,o=e.levelStyle===void 0?`bold`:e.levelStyle,s=e.levelColors??L,c=e.categoryStyle===void 0?`dim`:e.categoryStyle,l=e.categoryColor??null,u=`${c==null?``:I[c]}${l==null?``:F[l]}`,d=c==null&&l==null?``:P;return N({timestamp:`date-time-tz`,value(e,t){return t(e,{colors:!0})},...e,format({timestamp:e,level:n,category:r,message:c,record:l}){let f=s[l.level];return e=e==null?null:`${i}${e}${a}`,n=`${o==null?``:I[o]}${f==null?``:F[f]}${n}${o==null&&f==null?``:P}`,t==null?`${e==null?``:`${e} `}${n} ${u}${r}:${d} ${c}`:t({timestamp:e,level:n,category:`${u}${r}${d}`,message:c,record:l})}})}R();function z(e={}){let t=j(e.lineEnding);if(!e.categorySeparator&&!e.message&&!e.properties)return e=>{if(e.message.length===3)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0]+JSON.stringify(e.message[1])+e.message[2],logger:e.category.join(`.`),properties:e.properties},M)+t;if(e.message.length===1)return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:e.message[0],logger:e.category.join(`.`),properties:e.properties},M)+t;let n=e.message[0];for(let t=1;t<e.message.length;t++)n+=t&1?JSON.stringify(e.message[t]):e.message[t];return JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:n,logger:e.category.join(`.`),properties:e.properties},M)+t};let n=e.message===`template`,r=e.properties??`nest:properties`,i;if(typeof e.categorySeparator==`function`)i=e.categorySeparator;else{let t=e.categorySeparator??`.`;i=e=>e.join(t)}let a;if(r===`flatten`)a=e=>e;else if(r.startsWith(`prepend:`)){let e=r.substring(8);if(e===``)throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be of the form "prepend:<prefix>" where <prefix> is a non-empty string.`);a=t=>{let n={};for(let r in t)n[`${e}${r}`]=t[r];return n}}else if(r.startsWith(`nest:`)){let e=r.substring(5);a=t=>({[e]:t})}else throw TypeError(`Invalid properties option: ${JSON.stringify(r)}. It must be "flatten", "prepend:<prefix>", or "nest:<key>".`);let o;return o=n?e=>{if(typeof e.rawMessage==`string`)return e.rawMessage;let t=``;for(let n=0;n<e.rawMessage.length;n++)t+=n%2<1?e.rawMessage[n]:`{}`;return t}:e=>{let t=e.message.length;if(t===1)return e.message[0];let n=``;for(let r=0;r<t;r++)n+=r%2<1?e.message[r]:JSON.stringify(e.message[r]);return n},e=>JSON.stringify({"@timestamp":new Date(e.timestamp).toISOString(),level:e.level===`warning`?`WARN`:e.level.toUpperCase(),message:o(e),logger:i(e.category),...a(e.properties)},M)+t}z();const B={trace:`background-color: gray; color: white;`,debug:`background-color: gray; color: white;`,info:`background-color: white; color: black;`,warning:`background-color: orange; color: black;`,error:`background-color: red; color: white;`,fatal:`background-color: maroon; color: white;`};function V(e){let t=``,n=[];for(let r=0;r<e.message.length;r++)r%2==0?t+=e.message[r]:(t+=`%o`,n.push(e.message[r]));let r=new Date(e.timestamp);return[`%c${`${r.getUTCHours().toString().padStart(2,`0`)}:${r.getUTCMinutes().toString().padStart(2,`0`)}:${r.getUTCSeconds().toString().padStart(2,`0`)}.${r.getUTCMilliseconds().toString().padStart(3,`0`)}`} %c${T[e.level]}%c %c${e.category.join(`·`)} %c${t}`,`color: gray;`,B[e.level],`background-color: default;`,`color: gray;`,`color: default;`,...n]}function H(e={}){let t=e.formatter??V,n={trace:`debug`,debug:`debug`,info:`info`,warning:`warn`,error:`error`,fatal:`error`,...e.levelMap??{}},r=e.console??globalThis.console,i=e=>{let i=t(e),a=n[e.level];if(a===void 0)throw TypeError(`Invalid log level: ${e.level}.`);if(typeof i==`string`){let e=i.replace(/\r?\n$/,``);r[a](e)}else r[a](...i)};if(!e.nonBlocking)return i;let a=e.nonBlocking===!0?{}:e.nonBlocking,o=a.bufferSize??100,s=a.flushInterval??100,c=[],l=null,u=!1,d=!1,f=o*2;function p(){if(c.length===0)return;let e=c.splice(0);for(let t of e)try{i(t)}catch{}}function m(){d||(d=!0,setTimeout(()=>{d=!1,p()},0))}function h(){l!==null||u||(l=setInterval(()=>{p()},s))}let g=e=>{u||(c.length>=f&&c.shift(),c.push(e),c.length>=o?m():l===null&&h())};return g[Symbol.dispose]=()=>{u=!0,l!==null&&(clearInterval(l),l=null),p()},g}let U=null;const W=new Set,G=new Set,K=new Set;function q(e){return e.category.length===0||e.category.length===1&&e.category[0]===`logtape`||e.category.length===2&&e.category[0]===`logtape`&&e.category[1]===`meta`}function J(e){let t=e?ne:Q;if(typeof globalThis.EdgeRuntime!=`string`&&`process`in globalThis&&!(`Deno`in globalThis)){let e=globalThis.process,n=e?.on;if(typeof n==`function`){n.call(e,`exit`,t);return}}let n=globalThis.addEventListener;typeof n==`function`&&(`Deno`in globalThis?n.call(globalThis,`unload`,t):n.call(globalThis,`pagehide`,t))}function Y(e){if(U!=null&&!e.reset)throw new $(`Already configured; if you want to reset, turn on the reset flag.`);if(K.size>0)throw new $(`Previously configured async disposables are still active. Use configure() instead or explicitly dispose them using dispose().`);Z();try{X(e,!1)}catch(e){throw e instanceof $&&Z(),e}}function X(e,t){U=e;let r=!1,i=new Set;for(let t of e.loggers){q(t)&&(r=!0);let a=Array.isArray(t.category)?JSON.stringify(t.category):JSON.stringify([t.category]);if(i.has(a))throw new $(`Duplicate logger configuration for category: ${a}. Each category can only be configured once.`);i.add(a);let o=d.getLogger(t.category);for(let n of t.sinks??[]){let t=e.sinks[n];if(!t)throw new $(`Sink not found: ${n}.`);o.sinks.push(t)}o.parentSinks=t.parentSinks??`inherit`,t.lowestLevel!==void 0&&(o.lowestLevel=t.lowestLevel);for(let r of t.filters??[]){let t=e.filters?.[r];if(t===void 0)throw new $(`Filter not found: ${r}.`);o.filters.push(n(t))}W.add(o)}d.getLogger().contextLocalStorage=e.contextLocalStorage;for(let n of Object.values(e.sinks)){if(Symbol.asyncDispose in n)if(t)K.add(n);else throw new $(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&G.add(n)}for(let n of Object.values(e.filters??{}))if(!(n==null||typeof n==`string`)){if(Symbol.asyncDispose in n)if(t)K.add(n);else throw new $(`Async disposables cannot be used with configureSync().`);Symbol.dispose in n&&G.add(n)}J(t);let a=d.getLogger([`logtape`,`meta`]);r||a.sinks.push(H()),a.info(`LogTape loggers are configured. Note that LogTape itself uses the meta logger, which has category {metaLoggerCategory}. The meta logger is used to log internal diagnostics such as sink exceptions. It's recommended to configure the meta logger with a separate sink so that you can easily notice if logging itself fails or is misconfigured. To turn off this message, configure the meta logger with higher log levels than {dismissLevel}. See also <https://logtape.org/manual/categories#meta-logger>.`,{metaLoggerCategory:[`logtape`,`meta`],dismissLevel:`info`})}function Z(){Q(),te()}function te(){let e=d.getLogger([]);e.resetDescendants(),delete e.contextLocalStorage,W.clear(),U=null}async function ne(){Q();let e=[];for(let t of K)e.push(t[Symbol.asyncDispose]()),K.delete(t);await Promise.all(e)}function Q(){for(let e of G)e[Symbol.dispose]();G.clear()}var $=class extends Error{constructor(e){super(e),this.name=`ConfigureError`}};export{l as a,N as i,H as n,R as r,Y as t};
@@ -1 +0,0 @@
1
- function e(){return new t}var t=class e{index={};array=[];size(){return this.array.length}empty(){return this.array.length===0}itemAt(e){return this.array[e]}contains(e){return this.index[e.id()]!==void 0}find(e){let t=this.index[e.id()];return t===void 0?void 0:this.array[t]}setDefault(e,t){let r=this.index[e.id()];if(r===void 0){let r=new n(e,t());return this.index[e.id()]=this.array.length,this.array.push(r),r}else return this.array[r]}insert(e,t){let r=new n(e,t),i=this.index[e.id()];return i===void 0?(this.index[e.id()]=this.array.length,this.array.push(r)):this.array[i]=r,r}erase(e){let t=this.index[e.id()];if(t===void 0)return;this.index[e.id()]=void 0;let n=this.array[t],r=this.array.pop();return n!==r&&(this.array[t]=r,this.index[r.first.id()]=t),n}copy(){let t=new e;for(let e=0;e<this.array.length;e++){let n=this.array[e].copy();t.array[e]=n,t.index[n.first.id()]=e}return t}},n=class e{first;second;constructor(e,t){this.first=e,this.second=t}copy(){return new e(this.first,this.second)}},r=class{constructor(e=``){this._name=e}id(){return this._id}name(){return this._name}setName(e){this._name=e}context(){return this._context}setContext(e){this._context=e}value(){return this._value}setValue(e){this._value=e}plus(e){return new a(this,e)}minus(e){return new a(this,typeof e==`number`?-e:[-1,e])}multiply(e){return new a([e,this])}divide(e){return new a([1/e,this])}toJSON(){return{name:this._name,value:this._value}}toString(){return this._context+`[`+this._name+`:`+this._value+`]`}_name;_value=0;_context=null;_id=i++};let i=0;var a=class e{constructor(){let e=o(arguments);this._terms=e.terms,this._constant=e.constant}terms(){return this._terms}constant(){return this._constant}value(){let e=this._constant;for(let t=0,n=this._terms.size();t<n;t++){let n=this._terms.itemAt(t);e+=n.first.value()*n.second}return e}plus(t){return new e(this,t)}minus(t){return new e(this,typeof t==`number`?-t:[-1,t])}multiply(t){return new e([t,this])}divide(t){return new e([1/t,this])}isConstant(){return this._terms.size()==0}toString(){let e=this._terms.array.map(function(e){return e.second+`*`+e.first.toString()}).join(` + `);return!this.isConstant()&&this._constant!==0&&(e+=` + `),e+=this._constant,e}_terms;_constant};function o(t){let n=0,i=()=>0,o=e();for(let e=0,s=t.length;e<s;++e){let s=t[e];if(typeof s==`number`)n+=s;else if(s instanceof r)o.setDefault(s,i).second+=1;else if(s instanceof a){n+=s.constant();let e=s.terms();for(let t=0,n=e.size();t<n;t++){let n=e.itemAt(t);o.setDefault(n.first,i).second+=n.second}}else if(s instanceof Array){if(s.length!==2)throw Error(`array must have length 2`);let e=s[0],t=s[1];if(typeof e!=`number`)throw Error(`array item 0 must be a number`);if(t instanceof r)o.setDefault(t,i).second+=e;else if(t instanceof a){n+=t.constant()*e;let r=t.terms();for(let t=0,n=r.size();t<n;t++){let n=r.itemAt(t);o.setDefault(n.first,i).second+=n.second*e}}else throw Error(`array item 1 must be a variable or expression`)}else throw Error(`invalid Expression argument: `+s)}return{terms:o,constant:n}}var s=class e{static create(e,t,n,r=1){let i=0;return i+=Math.max(0,Math.min(1e3,e*r))*1e6,i+=Math.max(0,Math.min(1e3,t*r))*1e3,i+=Math.max(0,Math.min(1e3,n*r)),i}static required=e.create(1e3,1e3,1e3);static strong=e.create(1,0,0);static medium=e.create(0,1,0);static weak=e.create(0,0,1);static clip(t){return Math.max(0,Math.min(e.required,t))}},c;(function(e){e[e.Le=0]=`Le`,e[e.Ge=1]=`Ge`,e[e.Eq=2]=`Eq`})(c||={});var l=class{constructor(e,t,n,r=s.required){this._operator=t,this._strength=s.clip(r),n===void 0&&e instanceof a?this._expression=e:this._expression=e.minus(n)}id(){return this._id}expression(){return this._expression}op(){return this._operator}strength(){return this._strength}toString(){return this._expression.toString()+` `+[`<=`,`>=`,`=`][this._operator]+` 0 (`+this._strength.toString()+`)`}_expression;_operator;_strength;_id=u++};let u=0;var d=class{maxIterations=1e3;constructor(){}createConstraint(e,t,n,r=s.required){let i=new l(e,t,n,r);return this.addConstraint(i),i}addConstraint(e){if(this._cnMap.find(e)!==void 0)throw Error(`duplicate constraint`);let t=this._createRow(e),n=t.row,r=t.tag,i=this._chooseSubject(n,r);if(i.type()===_.Invalid&&n.allDummies())if(f(n.constant()))i=r.marker;else throw Error(`unsatisfiable constraint`);if(i.type()===_.Invalid){if(!this._addWithArtificialVariable(n))throw Error(`unsatisfiable constraint`)}else n.solveFor(i),this._substitute(i,n),this._rowMap.insert(i,n);this._cnMap.insert(e,r),this._optimize(this._objective)}removeConstraint(e){let t=this._cnMap.erase(e);if(t===void 0)throw Error(`unknown constraint`);this._removeConstraintEffects(e,t.second);let n=t.second.marker,r=this._rowMap.erase(n);if(r===void 0){let e=this._getMarkerLeavingSymbol(n);if(e.type()===_.Invalid)throw Error(`failed to find leaving row`);r=this._rowMap.erase(e),r.second.solveForEx(e,n),this._substitute(n,r.second)}this._optimize(this._objective)}hasConstraint(e){return this._cnMap.contains(e)}getConstraints(){return this._cnMap.array.map(({first:e})=>e)}addEditVariable(e,t){if(this._editMap.find(e)!==void 0)throw Error(`duplicate edit variable`);if(t=s.clip(t),t===s.required)throw Error(`bad required strength`);let n=new l(new a(e),c.Eq,void 0,t);this.addConstraint(n);let r={tag:this._cnMap.find(n).second,constraint:n,constant:0};this._editMap.insert(e,r)}removeEditVariable(e){let t=this._editMap.erase(e);if(t===void 0)throw Error(`unknown edit variable`);this.removeConstraint(t.second.constraint)}hasEditVariable(e){return this._editMap.contains(e)}suggestValue(e,t){let n=this._editMap.find(e);if(n===void 0)throw Error(`unknown edit variable`);let r=this._rowMap,i=n.second,a=t-i.constant;i.constant=t;let o=i.tag.marker,s=r.find(o);if(s!==void 0){s.second.add(-a)<0&&this._infeasibleRows.push(o),this._dualOptimize();return}let c=i.tag.other;if(s=r.find(c),s!==void 0){s.second.add(a)<0&&this._infeasibleRows.push(c),this._dualOptimize();return}for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e),n=t.second,i=n.coefficientFor(o);i!==0&&n.add(a*i)<0&&t.first.type()!==_.External&&this._infeasibleRows.push(t.first)}this._dualOptimize()}updateVariables(){let e=this._varMap,t=this._rowMap;for(let n=0,r=e.size();n<r;++n){let r=e.itemAt(n),i=t.find(r.second);i===void 0?r.first.setValue(0):r.first.setValue(i.second.constant())}}_getVarSymbol(e){return this._varMap.setDefault(e,()=>this._makeSymbol(_.External)).second}_createRow(e){let t=e.expression(),n=new b(t.constant()),r=t.terms();for(let e=0,t=r.size();e<t;++e){let t=r.itemAt(e);if(!f(t.second)){let e=this._getVarSymbol(t.first),r=this._rowMap.find(e);r===void 0?n.insertSymbol(e,t.second):n.insertRow(r.second,t.second)}}let i=this._objective,a=e.strength(),o={marker:y,other:y};switch(e.op()){case c.Le:case c.Ge:{let t=e.op()===c.Le?1:-1,r=this._makeSymbol(_.Slack);if(o.marker=r,n.insertSymbol(r,t),a<s.required){let e=this._makeSymbol(_.Error);o.other=e,n.insertSymbol(e,-t),i.insertSymbol(e,a)}break}case c.Eq:if(a<s.required){let e=this._makeSymbol(_.Error),t=this._makeSymbol(_.Error);o.marker=e,o.other=t,n.insertSymbol(e,-1),n.insertSymbol(t,1),i.insertSymbol(e,a),i.insertSymbol(t,a)}else{let e=this._makeSymbol(_.Dummy);o.marker=e,n.insertSymbol(e)}break}return n.constant()<0&&n.reverseSign(),{row:n,tag:o}}_chooseSubject(e,t){let n=e.cells();for(let e=0,t=n.size();e<t;++e){let t=n.itemAt(e);if(t.first.type()===_.External)return t.first}let r=t.marker.type();return(r===_.Slack||r===_.Error)&&e.coefficientFor(t.marker)<0?t.marker:(r=t.other.type(),(r===_.Slack||r===_.Error)&&e.coefficientFor(t.other)<0?t.other:y)}_addWithArtificialVariable(e){let t=this._makeSymbol(_.Slack);this._rowMap.insert(t,e.copy()),this._artificial=e.copy(),this._optimize(this._artificial);let n=f(this._artificial.constant());this._artificial=null;let r=this._rowMap.erase(t);if(r!==void 0){let e=r.second;if(e.isConstant())return n;let i=this._anyPivotableSymbol(e);if(i.type()===_.Invalid)return!1;e.solveForEx(t,i),this._substitute(i,e),this._rowMap.insert(i,e)}let i=this._rowMap;for(let e=0,n=i.size();e<n;++e)i.itemAt(e).second.removeSymbol(t);return this._objective.removeSymbol(t),n}_substitute(e,t){let n=this._rowMap;for(let r=0,i=n.size();r<i;++r){let i=n.itemAt(r);i.second.substitute(e,t),i.second.constant()<0&&i.first.type()!==_.External&&this._infeasibleRows.push(i.first)}this._objective.substitute(e,t),this._artificial&&this._artificial.substitute(e,t)}_optimize(e){let t=0;for(;t<this.maxIterations;){let n=this._getEnteringSymbol(e);if(n.type()===_.Invalid)return;let r=this._getLeavingSymbol(n);if(r.type()===_.Invalid)throw Error(`the objective is unbounded`);let i=this._rowMap.erase(r).second;i.solveForEx(r,n),this._substitute(n,i),this._rowMap.insert(n,i),t++}throw Error(`solver iterations exceeded`)}_dualOptimize(){let e=this._rowMap,t=this._infeasibleRows;for(;t.length!==0;){let n=t.pop(),r=e.find(n);if(r!==void 0&&r.second.constant()<0){let t=this._getDualEnteringSymbol(r.second);if(t.type()===_.Invalid)throw Error(`dual optimize failed`);let i=r.second;e.erase(n),i.solveForEx(n,t),this._substitute(t,i),e.insert(t,i)}}}_getEnteringSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first;if(n.second<0&&r.type()!==_.Dummy)return r}return y}_getDualEnteringSymbol(e){let t=Number.MAX_VALUE,n=y,r=e.cells();for(let e=0,i=r.size();e<i;++e){let i=r.itemAt(e),a=i.first,o=i.second;if(o>0&&a.type()!==_.Dummy){let e=this._objective.coefficientFor(a)/o;e<t&&(t=e,n=a)}}return n}_getLeavingSymbol(e){let t=Number.MAX_VALUE,n=y,r=this._rowMap;for(let i=0,a=r.size();i<a;++i){let a=r.itemAt(i),o=a.first;if(o.type()!==_.External){let r=a.second,i=r.coefficientFor(e);if(i<0){let e=-r.constant()/i;e<t&&(t=e,n=o)}}}return n}_getMarkerLeavingSymbol(e){let t=Number.MAX_VALUE,n=t,r=t,i=y,a=i,o=i,s=i,c=this._rowMap;for(let t=0,i=c.size();t<i;++t){let i=c.itemAt(t),l=i.second,u=l.coefficientFor(e);if(u===0)continue;let d=i.first;if(d.type()===_.External)s=d;else if(u<0){let e=-l.constant()/u;e<n&&(n=e,a=d)}else{let e=l.constant()/u;e<r&&(r=e,o=d)}}return a===i?o===i?s:o:a}_removeConstraintEffects(e,t){t.marker.type()===_.Error&&this._removeMarkerEffects(t.marker,e.strength()),t.other.type()===_.Error&&this._removeMarkerEffects(t.other,e.strength())}_removeMarkerEffects(e,t){let n=this._rowMap.find(e);n===void 0?this._objective.insertSymbol(e,-t):this._objective.insertRow(n.second,-t)}_anyPivotableSymbol(e){let t=e.cells();for(let e=0,n=t.size();e<n;++e){let n=t.itemAt(e),r=n.first.type();if(r===_.Slack||r===_.Error)return n.first}return y}_makeSymbol(e){return new v(e,this._idTick++)}_cnMap=p();_rowMap=m();_varMap=h();_editMap=g();_infeasibleRows=[];_objective=new b;_artificial=null;_idTick=0};function f(e){let t=1e-8;return e<0?-e<t:e<t}function p(){return e()}function m(){return e()}function h(){return e()}function g(){return e()}var _;(function(e){e[e.Invalid=0]=`Invalid`,e[e.External=1]=`External`,e[e.Slack=2]=`Slack`,e[e.Error=3]=`Error`,e[e.Dummy=4]=`Dummy`})(_||={});var v=class{constructor(e,t){this._id=t,this._type=e}id(){return this._id}type(){return this._type}_id;_type};let y=new v(_.Invalid,-1);var b=class t{constructor(e=0){this._constant=e}cells(){return this._cellMap}constant(){return this._constant}isConstant(){return this._cellMap.empty()}allDummies(){let e=this._cellMap;for(let t=0,n=e.size();t<n;++t)if(e.itemAt(t).first.type()!==_.Dummy)return!1;return!0}copy(){let e=new t(this._constant);return e._cellMap=this._cellMap.copy(),e}add(e){return this._constant+=e}insertSymbol(e,t=1){let n=this._cellMap.setDefault(e,()=>0);f(n.second+=t)&&this._cellMap.erase(e)}insertRow(e,t=1){this._constant+=e._constant*t;let n=e._cellMap;for(let e=0,r=n.size();e<r;++e){let r=n.itemAt(e);this.insertSymbol(r.first,r.second*t)}}removeSymbol(e){this._cellMap.erase(e)}reverseSign(){this._constant=-this._constant;let e=this._cellMap;for(let t=0,n=e.size();t<n;++t){let n=e.itemAt(t);n.second=-n.second}}solveFor(e){let t=this._cellMap,n=-1/t.erase(e).second;this._constant*=n;for(let e=0,r=t.size();e<r;++e)t.itemAt(e).second*=n}solveForEx(e,t){this.insertSymbol(e,-1),this.solveFor(t)}coefficientFor(e){let t=this._cellMap.find(e);return t===void 0?0:t.second}substitute(e,t){let n=this._cellMap.erase(e);n!==void 0&&this.insertRow(t,n.second)}_cellMap=e();_constant};export{r as a,s as i,l as n,c as r,d as t};
@@ -1,15 +0,0 @@
1
- const{min:e,max:t}=Math;var n=(n,r=0,i=1)=>e(t(r,n),i),r=e=>{e._clipped=!1,e._unclipped=e.slice(0);for(let t=0;t<=3;t++)t<3?((e[t]<0||e[t]>255)&&(e._clipped=!0),e[t]=n(e[t],0,255)):t===3&&(e[t]=n(e[t],0,1));return e};const i={};for(let e of[`Boolean`,`Number`,`String`,`Function`,`Array`,`Date`,`RegExp`,`Undefined`,`Null`])i[`[object ${e}]`]=e.toLowerCase();function a(e){return i[Object.prototype.toString.call(e)]||`object`}var o=(e,t=null)=>e.length>=3?Array.prototype.slice.call(e):a(e[0])==`object`&&t?t.split(``).filter(t=>e[0][t]!==void 0).map(t=>e[0][t]):e[0].slice(0),s=e=>{if(e.length<2)return null;let t=e.length-1;return a(e[t])==`string`?e[t].toLowerCase():null};const{PI:c,min:l,max:u}=Math,d=e=>Math.round(e*100)/100,f=e=>Math.round(e*100)/100,p=c*2,m=c/3,h=c/180,g=180/c;function _(e){return[...e.slice(0,3).reverse(),...e.slice(3)]}var v={format:{},autodetect:[]},y=class{constructor(...e){let t=this;if(a(e[0])===`object`&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];let n=s(e),i=!1;if(!n){i=!0,v.sorted||=(v.autodetect=v.autodetect.sort((e,t)=>t.p-e.p),!0);for(let t of v.autodetect)if(n=t.test(...e),n)break}if(v.format[n])t._rgb=r(v.format[n].apply(null,i?e:e.slice(0,-1)));else throw Error(`unknown format: `+e);t._rgb.length===3&&t._rgb.push(1)}toString(){return a(this.hex)==`function`?this.hex():`[${this._rgb.join(`,`)}]`}};const b=(...e)=>new y(...e);b.version=`3.2.0`;const x={aliceblue:`#f0f8ff`,antiquewhite:`#faebd7`,aqua:`#00ffff`,aquamarine:`#7fffd4`,azure:`#f0ffff`,beige:`#f5f5dc`,bisque:`#ffe4c4`,black:`#000000`,blanchedalmond:`#ffebcd`,blue:`#0000ff`,blueviolet:`#8a2be2`,brown:`#a52a2a`,burlywood:`#deb887`,cadetblue:`#5f9ea0`,chartreuse:`#7fff00`,chocolate:`#d2691e`,coral:`#ff7f50`,cornflowerblue:`#6495ed`,cornsilk:`#fff8dc`,crimson:`#dc143c`,cyan:`#00ffff`,darkblue:`#00008b`,darkcyan:`#008b8b`,darkgoldenrod:`#b8860b`,darkgray:`#a9a9a9`,darkgreen:`#006400`,darkgrey:`#a9a9a9`,darkkhaki:`#bdb76b`,darkmagenta:`#8b008b`,darkolivegreen:`#556b2f`,darkorange:`#ff8c00`,darkorchid:`#9932cc`,darkred:`#8b0000`,darksalmon:`#e9967a`,darkseagreen:`#8fbc8f`,darkslateblue:`#483d8b`,darkslategray:`#2f4f4f`,darkslategrey:`#2f4f4f`,darkturquoise:`#00ced1`,darkviolet:`#9400d3`,deeppink:`#ff1493`,deepskyblue:`#00bfff`,dimgray:`#696969`,dimgrey:`#696969`,dodgerblue:`#1e90ff`,firebrick:`#b22222`,floralwhite:`#fffaf0`,forestgreen:`#228b22`,fuchsia:`#ff00ff`,gainsboro:`#dcdcdc`,ghostwhite:`#f8f8ff`,gold:`#ffd700`,goldenrod:`#daa520`,gray:`#808080`,green:`#008000`,greenyellow:`#adff2f`,grey:`#808080`,honeydew:`#f0fff0`,hotpink:`#ff69b4`,indianred:`#cd5c5c`,indigo:`#4b0082`,ivory:`#fffff0`,khaki:`#f0e68c`,laserlemon:`#ffff54`,lavender:`#e6e6fa`,lavenderblush:`#fff0f5`,lawngreen:`#7cfc00`,lemonchiffon:`#fffacd`,lightblue:`#add8e6`,lightcoral:`#f08080`,lightcyan:`#e0ffff`,lightgoldenrod:`#fafad2`,lightgoldenrodyellow:`#fafad2`,lightgray:`#d3d3d3`,lightgreen:`#90ee90`,lightgrey:`#d3d3d3`,lightpink:`#ffb6c1`,lightsalmon:`#ffa07a`,lightseagreen:`#20b2aa`,lightskyblue:`#87cefa`,lightslategray:`#778899`,lightslategrey:`#778899`,lightsteelblue:`#b0c4de`,lightyellow:`#ffffe0`,lime:`#00ff00`,limegreen:`#32cd32`,linen:`#faf0e6`,magenta:`#ff00ff`,maroon:`#800000`,maroon2:`#7f0000`,maroon3:`#b03060`,mediumaquamarine:`#66cdaa`,mediumblue:`#0000cd`,mediumorchid:`#ba55d3`,mediumpurple:`#9370db`,mediumseagreen:`#3cb371`,mediumslateblue:`#7b68ee`,mediumspringgreen:`#00fa9a`,mediumturquoise:`#48d1cc`,mediumvioletred:`#c71585`,midnightblue:`#191970`,mintcream:`#f5fffa`,mistyrose:`#ffe4e1`,moccasin:`#ffe4b5`,navajowhite:`#ffdead`,navy:`#000080`,oldlace:`#fdf5e6`,olive:`#808000`,olivedrab:`#6b8e23`,orange:`#ffa500`,orangered:`#ff4500`,orchid:`#da70d6`,palegoldenrod:`#eee8aa`,palegreen:`#98fb98`,paleturquoise:`#afeeee`,palevioletred:`#db7093`,papayawhip:`#ffefd5`,peachpuff:`#ffdab9`,peru:`#cd853f`,pink:`#ffc0cb`,plum:`#dda0dd`,powderblue:`#b0e0e6`,purple:`#800080`,purple2:`#7f007f`,purple3:`#a020f0`,rebeccapurple:`#663399`,red:`#ff0000`,rosybrown:`#bc8f8f`,royalblue:`#4169e1`,saddlebrown:`#8b4513`,salmon:`#fa8072`,sandybrown:`#f4a460`,seagreen:`#2e8b57`,seashell:`#fff5ee`,sienna:`#a0522d`,silver:`#c0c0c0`,skyblue:`#87ceeb`,slateblue:`#6a5acd`,slategray:`#708090`,slategrey:`#708090`,snow:`#fffafa`,springgreen:`#00ff7f`,steelblue:`#4682b4`,tan:`#d2b48c`,teal:`#008080`,thistle:`#d8bfd8`,tomato:`#ff6347`,turquoise:`#40e0d0`,violet:`#ee82ee`,wheat:`#f5deb3`,white:`#ffffff`,whitesmoke:`#f5f5f5`,yellow:`#ffff00`,yellowgreen:`#9acd32`},S=/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/,C=/^#?([A-Fa-f0-9]{8}|[A-Fa-f0-9]{4})$/,w=e=>{if(e.match(S)){(e.length===4||e.length===7)&&(e=e.substr(1)),e.length===3&&(e=e.split(``),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]);let t=parseInt(e,16);return[t>>16,t>>8&255,t&255,1]}if(e.match(C)){(e.length===5||e.length===9)&&(e=e.substr(1)),e.length===4&&(e=e.split(``),e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);let t=parseInt(e,16);return[t>>24&255,t>>16&255,t>>8&255,Math.round((t&255)/255*100)/100]}throw Error(`unknown hex color: ${e}`)},{round:T}=Math,E=(...e)=>{let[t,n,r,i]=o(e,`rgba`),a=s(e)||`auto`;i===void 0&&(i=1),a===`auto`&&(a=i<1?`rgba`:`rgb`),t=T(t),n=T(n),r=T(r);let c=`000000`+(t<<16|n<<8|r).toString(16);c=c.substr(c.length-6);let l=`0`+T(i*255).toString(16);switch(l=l.substr(l.length-2),a.toLowerCase()){case`rgba`:return`#${c}${l}`;case`argb`:return`#${l}${c}`;default:return`#${c}`}};y.prototype.name=function(){let e=E(this._rgb,`rgb`);for(let t of Object.keys(x))if(x[t]===e)return t.toLowerCase();return e},v.format.named=e=>{if(e=e.toLowerCase(),x[e])return w(x[e]);throw Error(`unknown color name: `+e)},v.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&a(e)===`string`&&x[e.toLowerCase()])return`named`}}),y.prototype.alpha=function(e,t=!1){return e!==void 0&&a(e)===`number`?t?(this._rgb[3]=e,this):new y([this._rgb[0],this._rgb[1],this._rgb[2],e],`rgb`):this._rgb[3]},y.prototype.clipped=function(){return this._rgb._clipped||!1};const D={Kn:18,labWhitePoint:`d65`,Xn:.95047,Yn:1,Zn:1.08883,t0:.137931034,t1:.206896552,t2:.12841855,t3:.008856452,kE:216/24389,kKE:8,kK:24389/27,RefWhiteRGB:{X:.95047,Y:1,Z:1.08883},MtxRGB2XYZ:{m00:.4124564390896922,m01:.21267285140562253,m02:.0193338955823293,m10:.357576077643909,m11:.715152155287818,m12:.11919202588130297,m20:.18043748326639894,m21:.07217499330655958,m22:.9503040785363679},MtxXYZ2RGB:{m00:3.2404541621141045,m01:-.9692660305051868,m02:.055643430959114726,m10:-1.5371385127977166,m11:1.8760108454466942,m12:-.2040259135167538,m20:-.498531409556016,m21:.041556017530349834,m22:1.0572251882231791},As:.9414285350000001,Bs:1.040417467,Cs:1.089532651,MtxAdaptMa:{m00:.8951,m01:-.7502,m02:.0389,m10:.2664,m11:1.7135,m12:-.0685,m20:-.1614,m21:.0367,m22:1.0296},MtxAdaptMaI:{m00:.9869929054667123,m01:.43230526972339456,m02:-.008528664575177328,m10:-.14705425642099013,m11:.5183602715367776,m12:.04004282165408487,m20:.15996265166373125,m21:.0492912282128556,m22:.9684866957875502}},O=new Map([[`a`,[1.0985,.35585]],[`b`,[1.0985,.35585]],[`c`,[.98074,1.18232]],[`d50`,[.96422,.82521]],[`d55`,[.95682,.92149]],[`d65`,[.95047,1.08883]],[`e`,[1,1,1]],[`f2`,[.99186,.67393]],[`f7`,[.95041,1.08747]],[`f11`,[1.00962,.6435]],[`icc`,[.96422,.82521]]]);function k(e){let t=O.get(String(e).toLowerCase());if(!t)throw Error(`unknown Lab illuminant `+e);D.labWhitePoint=e,D.Xn=t[0],D.Zn=t[1]}function A(){return D.labWhitePoint}const ee=(...e)=>{e=o(e,`lab`);let[t,n,r]=e,[i,a,s]=te(t,n,r),[c,l,u]=ne(i,a,s);return[c,l,u,e.length>3?e[3]:1]},te=(e,t,n)=>{let{kE:r,kK:i,kKE:a,Xn:o,Yn:s,Zn:c}=D,l=(e+16)/116,u=.002*t+l,d=l-.005*n,f=u*u*u,p=d*d*d,m=f>r?f:(116*u-16)/i,h=e>a?((e+16)/116)**3:e/i,g=p>r?p:(116*d-16)/i;return[m*o,h*s,g*c]},j=e=>{let t=Math.sign(e);return e=Math.abs(e),(e<=.0031308?e*12.92:1.055*e**(1/2.4)-.055)*t},ne=(e,t,n)=>{let{MtxAdaptMa:r,MtxAdaptMaI:i,MtxXYZ2RGB:a,RefWhiteRGB:o,Xn:s,Yn:c,Zn:l}=D,u=s*r.m00+c*r.m10+l*r.m20,d=s*r.m01+c*r.m11+l*r.m21,f=s*r.m02+c*r.m12+l*r.m22,p=o.X*r.m00+o.Y*r.m10+o.Z*r.m20,m=o.X*r.m01+o.Y*r.m11+o.Z*r.m21,h=o.X*r.m02+o.Y*r.m12+o.Z*r.m22,g=(e*r.m00+t*r.m10+n*r.m20)*(p/u),_=(e*r.m01+t*r.m11+n*r.m21)*(m/d),v=(e*r.m02+t*r.m12+n*r.m22)*(h/f),y=g*i.m00+_*i.m10+v*i.m20,b=g*i.m01+_*i.m11+v*i.m21,x=g*i.m02+_*i.m12+v*i.m22,S=j(y*a.m00+b*a.m10+x*a.m20),C=j(y*a.m01+b*a.m11+x*a.m21),w=j(y*a.m02+b*a.m12+x*a.m22);return[S*255,C*255,w*255]},M=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=ae(t,n,r),[l,u,d]=re(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};function re(e,t,n){let{Xn:r,Yn:i,Zn:a,kE:o,kK:s}=D,c=e/r,l=t/i,u=n/a,d=c>o?c**(1/3):(s*c+16)/116,f=l>o?l**(1/3):(s*l+16)/116,p=u>o?u**(1/3):(s*u+16)/116;return[116*f-16,500*(d-f),200*(f-p)]}function ie(e){let t=Math.sign(e);return e=Math.abs(e),(e<=.04045?e/12.92:((e+.055)/1.055)**2.4)*t}const ae=(e,t,n)=>{e=ie(e/255),t=ie(t/255),n=ie(n/255);let{MtxRGB2XYZ:r,MtxAdaptMa:i,MtxAdaptMaI:a,Xn:o,Yn:s,Zn:c,As:l,Bs:u,Cs:d}=D,f=e*r.m00+t*r.m10+n*r.m20,p=e*r.m01+t*r.m11+n*r.m21,m=e*r.m02+t*r.m12+n*r.m22,h=o*i.m00+s*i.m10+c*i.m20,g=o*i.m01+s*i.m11+c*i.m21,_=o*i.m02+s*i.m12+c*i.m22,v=f*i.m00+p*i.m10+m*i.m20,y=f*i.m01+p*i.m11+m*i.m21,b=f*i.m02+p*i.m12+m*i.m22;return v*=h/l,y*=g/u,b*=_/d,f=v*a.m00+y*a.m10+b*a.m20,p=v*a.m01+y*a.m11+b*a.m21,m=v*a.m02+y*a.m12+b*a.m22,[f,p,m]};y.prototype.lab=function(){return M(this._rgb)},Object.assign(b,{lab:(...e)=>new y(...e,`lab`),getLabWhitePoint:A,setLabWhitePoint:k}),v.format.lab=ee,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`lab`),a(e)===`array`&&e.length===3)return`lab`}}),y.prototype.darken=function(e=1){let t=this,n=t.lab();return n[0]-=D.Kn*e,new y(n,`lab`).alpha(t.alpha(),!0)},y.prototype.brighten=function(e=1){return this.darken(-e)},y.prototype.darker=y.prototype.darken,y.prototype.brighter=y.prototype.brighten,y.prototype.get=function(e){let[t,n]=e.split(`.`),r=this[t]();if(n){let e=t.indexOf(n)-(t.substr(0,2)===`ok`?2:0);if(e>-1)return r[e];throw Error(`unknown channel ${n} in mode ${t}`)}else return r};const{pow:oe}=Math;y.prototype.luminance=function(e,t=`rgb`){if(e!==void 0&&a(e)===`number`){if(e===0)return new y([0,0,0,this._rgb[3]],`rgb`);if(e===1)return new y([255,255,255,this._rgb[3]],`rgb`);let n=this.luminance(),r=20,i=(n,a)=>{let o=n.interpolate(a,.5,t),s=o.luminance();return Math.abs(e-s)<1e-7||!r--?o:s>e?i(n,o):i(o,a)};return new y([...(n>e?i(new y([0,0,0]),this):i(this,new y([255,255,255]))).rgb(),this._rgb[3]])}return se(...this._rgb.slice(0,3))};const se=(e,t,n)=>(e=ce(e),t=ce(t),n=ce(n),.2126*e+.7152*t+.0722*n),ce=e=>(e/=255,e<=.03928?e/12.92:oe((e+.055)/1.055,2.4));var N={},P=(e,t,n=.5,...r)=>{let i=r[0]||`lrgb`;if(!N[i]&&!r.length&&(i=Object.keys(N)[0]),!N[i])throw Error(`interpolation mode ${i} is not defined`);return a(e)!==`object`&&(e=new y(e)),a(t)!==`object`&&(t=new y(t)),N[i](e,t,n).alpha(e.alpha()+n*(t.alpha()-e.alpha()))};y.prototype.mix=y.prototype.interpolate=function(e,t=.5,...n){return P(this,e,t,...n)},y.prototype.premultiply=function(e=!1){let t=this._rgb,n=t[3];return e?(this._rgb=[t[0]*n,t[1]*n,t[2]*n,n],this):new y([t[0]*n,t[1]*n,t[2]*n,n],`rgb`)};const{sin:le,cos:ue}=Math,de=(...e)=>{let[t,n,r]=o(e,`lch`);return isNaN(r)&&(r=0),r*=h,[t,ue(r)*n,le(r)*n]},fe=(...e)=>{e=o(e,`lch`);let[t,n,r]=e,[i,a,s]=de(t,n,r),[c,l,u]=ee(i,a,s);return[c,l,u,e.length>3?e[3]:1]},pe=(...e)=>fe(..._(o(e,`hcl`))),{sqrt:me,atan2:he,round:ge}=Math,_e=(...e)=>{let[t,n,r]=o(e,`lab`),i=me(n*n+r*r),a=(he(r,n)*g+360)%360;return ge(i*1e4)===0&&(a=NaN),[t,i,a]},ve=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=M(t,n,r),[l,u,d]=_e(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};y.prototype.lch=function(){return ve(this._rgb)},y.prototype.hcl=function(){return _(ve(this._rgb))},Object.assign(b,{lch:(...e)=>new y(...e,`lch`),hcl:(...e)=>new y(...e,`hcl`)}),v.format.lch=fe,v.format.hcl=pe,[`lch`,`hcl`].forEach(e=>v.autodetect.push({p:2,test:(...t)=>{if(t=o(t,e),a(t)===`array`&&t.length===3)return e}})),y.prototype.saturate=function(e=1){let t=this,n=t.lch();return n[1]+=D.Kn*e,n[1]<0&&(n[1]=0),new y(n,`lch`).alpha(t.alpha(),!0)},y.prototype.desaturate=function(e=1){return this.saturate(-e)},y.prototype.set=function(e,t,n=!1){let[r,i]=e.split(`.`),o=this[r]();if(i){let e=r.indexOf(i)-(r.substr(0,2)===`ok`?2:0);if(e>-1){if(a(t)==`string`)switch(t.charAt(0)){case`+`:o[e]+=+t;break;case`-`:o[e]+=+t;break;case`*`:o[e]*=+t.substr(1);break;case`/`:o[e]/=+t.substr(1);break;default:o[e]=+t}else if(a(t)===`number`)o[e]=t;else throw Error(`unsupported value for Color.set`);let i=new y(o,r);return n?(this._rgb=i._rgb,this):i}throw Error(`unknown channel ${i} in mode ${r}`)}else return o},y.prototype.tint=function(e=.5,...t){return P(this,`white`,e,...t)},y.prototype.shade=function(e=.5,...t){return P(this,`black`,e,...t)},N.rgb=(e,t,n)=>{let r=e._rgb,i=t._rgb;return new y(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`rgb`)};const{sqrt:ye,pow:F}=Math;N.lrgb=(e,t,n)=>{let[r,i,a]=e._rgb,[o,s,c]=t._rgb;return new y(ye(F(r,2)*(1-n)+F(o,2)*n),ye(F(i,2)*(1-n)+F(s,2)*n),ye(F(a,2)*(1-n)+F(c,2)*n),`rgb`)},N.lab=(e,t,n)=>{let r=e.lab(),i=t.lab();return new y(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`lab`)};var I=(e,t,n,r)=>{let i,a;r===`hsl`?(i=e.hsl(),a=t.hsl()):r===`hsv`?(i=e.hsv(),a=t.hsv()):r===`hcg`?(i=e.hcg(),a=t.hcg()):r===`hsi`?(i=e.hsi(),a=t.hsi()):r===`lch`||r===`hcl`?(r=`hcl`,i=e.hcl(),a=t.hcl()):r===`oklch`&&(i=e.oklch().reverse(),a=t.oklch().reverse());let o,s,c,l,u,d;(r.substr(0,1)===`h`||r===`oklch`)&&([o,c,u]=i,[s,l,d]=a);let f,p,m,h;return!isNaN(o)&&!isNaN(s)?(h=s>o&&s-o>180?s-(o+360):s<o&&o-s>180?s+360-o:s-o,p=o+n*h):isNaN(o)?isNaN(s)?p=NaN:(p=s,(u==1||u==0)&&r!=`hsv`&&(f=l)):(p=o,(d==1||d==0)&&r!=`hsv`&&(f=c)),f===void 0&&(f=c+n*(l-c)),m=u+n*(d-u),r===`oklch`?new y([m,f,p],r):new y([p,f,m],r)};const be=(e,t,n)=>I(e,t,n,`lch`);N.lch=be,N.hcl=be;const xe=e=>{if(a(e)==`number`&&e>=0&&e<=16777215)return[e>>16,e>>8&255,e&255,1];throw Error(`unknown num color: `+e)},Se=(...e)=>{let[t,n,r]=o(e,`rgb`);return(t<<16)+(n<<8)+r};y.prototype.num=function(){return Se(this._rgb)},Object.assign(b,{num:(...e)=>new y(...e,`num`)}),v.format.num=xe,v.autodetect.push({p:5,test:(...e)=>{if(e.length===1&&a(e[0])===`number`&&e[0]>=0&&e[0]<=16777215)return`num`}}),N.num=(e,t,n)=>{let r=e.num();return new y(r+n*(t.num()-r),`num`)};const{floor:Ce}=Math,we=(...e)=>{e=o(e,`hcg`);let[t,n,r]=e,i,a,s;r*=255;let c=n*255;if(n===0)i=a=s=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let e=Ce(t),o=t-e,l=r*(1-n),u=l+c*(1-o),d=l+c*o,f=l+c;switch(e){case 0:[i,a,s]=[f,d,l];break;case 1:[i,a,s]=[u,f,l];break;case 2:[i,a,s]=[l,f,d];break;case 3:[i,a,s]=[l,u,f];break;case 4:[i,a,s]=[d,l,f];break;case 5:[i,a,s]=[f,l,u];break}}return[i,a,s,e.length>3?e[3]:1]},Te=(...e)=>{let[t,n,r]=o(e,`rgb`),i=l(t,n,r),a=u(t,n,r),s=a-i,c=s*100/255,d=i/(255-s)*100,f;return s===0?f=NaN:(t===a&&(f=(n-r)/s),n===a&&(f=2+(r-t)/s),r===a&&(f=4+(t-n)/s),f*=60,f<0&&(f+=360)),[f,c,d]};y.prototype.hcg=function(){return Te(this._rgb)},b.hcg=(...e)=>new y(...e,`hcg`),v.format.hcg=we,v.autodetect.push({p:1,test:(...e)=>{if(e=o(e,`hcg`),a(e)===`array`&&e.length===3)return`hcg`}}),N.hcg=(e,t,n)=>I(e,t,n,`hcg`);const{cos:L}=Math,Ee=(...e)=>{e=o(e,`hsi`);let[t,r,i]=e,a,s,c;return isNaN(t)&&(t=0),isNaN(r)&&(r=0),t>360&&(t-=360),t<0&&(t+=360),t/=360,t<1/3?(c=(1-r)/3,a=(1+r*L(p*t)/L(m-p*t))/3,s=1-(c+a)):t<2/3?(t-=1/3,a=(1-r)/3,s=(1+r*L(p*t)/L(m-p*t))/3,c=1-(a+s)):(t-=2/3,s=(1-r)/3,c=(1+r*L(p*t)/L(m-p*t))/3,a=1-(s+c)),a=n(i*a*3),s=n(i*s*3),c=n(i*c*3),[a*255,s*255,c*255,e.length>3?e[3]:1]},{min:De,sqrt:Oe,acos:ke}=Math,Ae=(...e)=>{let[t,n,r]=o(e,`rgb`);t/=255,n/=255,r/=255;let i,a=De(t,n,r),s=(t+n+r)/3,c=s>0?1-a/s:0;return c===0?i=NaN:(i=(t-n+(t-r))/2,i/=Oe((t-n)*(t-n)+(t-r)*(n-r)),i=ke(i),r>n&&(i=p-i),i/=p),[i*360,c,s]};y.prototype.hsi=function(){return Ae(this._rgb)},b.hsi=(...e)=>new y(...e,`hsi`),v.format.hsi=Ee,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsi`),a(e)===`array`&&e.length===3)return`hsi`}}),N.hsi=(e,t,n)=>I(e,t,n,`hsi`);const je=(...e)=>{e=o(e,`hsl`);let[t,n,r]=e,i,a,s;if(n===0)i=a=s=r*255;else{let e=[0,0,0],o=[0,0,0],c=r<.5?r*(1+n):r+n-r*n,l=2*r-c,u=t/360;e[0]=u+1/3,e[1]=u,e[2]=u-1/3;for(let t=0;t<3;t++)e[t]<0&&(e[t]+=1),e[t]>1&&--e[t],6*e[t]<1?o[t]=l+(c-l)*6*e[t]:2*e[t]<1?o[t]=c:3*e[t]<2?o[t]=l+(c-l)*(2/3-e[t])*6:o[t]=l;[i,a,s]=[o[0]*255,o[1]*255,o[2]*255]}return e.length>3?[i,a,s,e[3]]:[i,a,s,1]},Me=(...e)=>{e=o(e,`rgba`);let[t,n,r]=e;t/=255,n/=255,r/=255;let i=l(t,n,r),a=u(t,n,r),s=(a+i)/2,c,d;return a===i?(c=0,d=NaN):c=s<.5?(a-i)/(a+i):(a-i)/(2-a-i),t==a?d=(n-r)/(a-i):n==a?d=2+(r-t)/(a-i):r==a&&(d=4+(t-n)/(a-i)),d*=60,d<0&&(d+=360),e.length>3&&e[3]!==void 0?[d,c,s,e[3]]:[d,c,s]};y.prototype.hsl=function(){return Me(this._rgb)},b.hsl=(...e)=>new y(...e,`hsl`),v.format.hsl=je,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsl`),a(e)===`array`&&e.length===3)return`hsl`}}),N.hsl=(e,t,n)=>I(e,t,n,`hsl`);const{floor:Ne}=Math,Pe=(...e)=>{e=o(e,`hsv`);let[t,n,r]=e,i,a,s;if(r*=255,n===0)i=a=s=r;else{t===360&&(t=0),t>360&&(t-=360),t<0&&(t+=360),t/=60;let e=Ne(t),o=t-e,c=r*(1-n),l=r*(1-n*o),u=r*(1-n*(1-o));switch(e){case 0:[i,a,s]=[r,u,c];break;case 1:[i,a,s]=[l,r,c];break;case 2:[i,a,s]=[c,r,u];break;case 3:[i,a,s]=[c,l,r];break;case 4:[i,a,s]=[u,c,r];break;case 5:[i,a,s]=[r,c,l];break}}return[i,a,s,e.length>3?e[3]:1]},{min:Fe,max:Ie}=Math,Le=(...e)=>{e=o(e,`rgb`);let[t,n,r]=e,i=Fe(t,n,r),a=Ie(t,n,r),s=a-i,c,l,u;return u=a/255,a===0?(c=NaN,l=0):(l=s/a,t===a&&(c=(n-r)/s),n===a&&(c=2+(r-t)/s),r===a&&(c=4+(t-n)/s),c*=60,c<0&&(c+=360)),[c,l,u]};y.prototype.hsv=function(){return Le(this._rgb)},b.hsv=(...e)=>new y(...e,`hsv`),v.format.hsv=Pe,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`hsv`),a(e)===`array`&&e.length===3)return`hsv`}}),N.hsv=(e,t,n)=>I(e,t,n,`hsv`);function R(e,t){let n=e.length;Array.isArray(e[0])||(e=[e]),Array.isArray(t[0])||(t=t.map(e=>[e]));let r=t[0].length,i=t[0].map((e,n)=>t.map(e=>e[n])),a=e.map(e=>i.map(t=>Array.isArray(e)?e.reduce((e,n,r)=>e+n*(t[r]||0),0):t.reduce((t,n)=>t+n*e,0)));return n===1&&(a=a[0]),r===1?a.map(e=>e[0]):a}const Re=(...e)=>{e=o(e,`lab`);let[t,n,r,...i]=e,[a,s,c]=ze([t,n,r]),[l,u,d]=ne(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]};function ze(e){return R([[1.2268798758459243,-.5578149944602171,.2813910456659647],[-.0405757452148008,1.112286803280317,-.0717110580655164],[-.0763729366746601,-.4214933324022432,1.5869240198367816]],R([[1,.3963377773761749,.2158037573099136],[1,-.1055613458156586,-.0638541728258133],[1,-.0894841775298119,-1.2914855480194092]],e).map(e=>e**3))}const Be=(...e)=>{let[t,n,r,...i]=o(e,`rgb`);return[...Ve(ae(t,n,r)),...i.length>0&&i[0]<1?[i[0]]:[]]};function Ve(e){return R([[.210454268309314,.7936177747023054,-.0040720430116193],[1.9779985324311684,-2.42859224204858,.450593709617411],[.0259040424655478,.7827717124575296,-.8086757549230774]],R([[.819022437996703,.3619062600528904,-.1288737815209879],[.0329836539323885,.9292868615863434,.0361446663506424],[.0481771893596242,.2642395317527308,.6335478284694309]],e).map(e=>Math.cbrt(e)))}y.prototype.oklab=function(){return Be(this._rgb)},Object.assign(b,{oklab:(...e)=>new y(...e,`oklab`)}),v.format.oklab=Re,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`oklab`),a(e)===`array`&&e.length===3)return`oklab`}}),N.oklab=(e,t,n)=>{let r=e.oklab(),i=t.oklab();return new y(r[0]+n*(i[0]-r[0]),r[1]+n*(i[1]-r[1]),r[2]+n*(i[2]-r[2]),`oklab`)},N.oklch=(e,t,n)=>I(e,t,n,`oklch`);const{pow:He,sqrt:Ue,PI:We,cos:Ge,sin:Ke,atan2:qe}=Math;var Je=(e,t=`lrgb`,n=null)=>{let r=e.length;n||=Array.from(Array(r)).map(()=>1);let i=r/n.reduce(function(e,t){return e+t});if(n.forEach((e,t)=>{n[t]*=i}),e=e.map(e=>new y(e)),t===`lrgb`)return Ye(e,n);let a=e.shift(),o=a.get(t),s=[],c=0,l=0;for(let e=0;e<o.length;e++)if(o[e]=(o[e]||0)*n[0],s.push(isNaN(o[e])?0:n[0]),t.charAt(e)===`h`&&!isNaN(o[e])){let t=o[e]/180*We;c+=Ge(t)*n[0],l+=Ke(t)*n[0]}let u=a.alpha()*n[0];e.forEach((e,r)=>{let i=e.get(t);u+=e.alpha()*n[r+1];for(let e=0;e<o.length;e++)if(!isNaN(i[e]))if(s[e]+=n[r+1],t.charAt(e)===`h`){let t=i[e]/180*We;c+=Ge(t)*n[r+1],l+=Ke(t)*n[r+1]}else o[e]+=i[e]*n[r+1]});for(let e=0;e<o.length;e++)if(t.charAt(e)===`h`){let t=qe(l/s[e],c/s[e])/We*180;for(;t<0;)t+=360;for(;t>=360;)t-=360;o[e]=t}else o[e]=o[e]/s[e];return u/=r,new y(o,t).alpha(u>.99999?1:u,!0)};const Ye=(e,t)=>{let n=e.length,i=[0,0,0,0];for(let r=0;r<e.length;r++){let a=e[r],o=t[r]/n,s=a._rgb;i[0]+=He(s[0],2)*o,i[1]+=He(s[1],2)*o,i[2]+=He(s[2],2)*o,i[3]+=s[3]*o}return i[0]=Ue(i[0]),i[1]=Ue(i[1]),i[2]=Ue(i[2]),i[3]>.9999999&&(i[3]=1),new y(r(i))},{pow:Xe}=Math;function z(e){let t=`rgb`,r=b(`#ccc`),i=0,o=[0,1],s=[0,1],c=[],l=[0,0],u=!1,d=[],f=!1,p=0,m=1,h=!1,g={},_=!0,v=1,y=function(e){if(e||=[`#fff`,`#000`],e&&a(e)===`string`&&b.brewer&&b.brewer[e.toLowerCase()]&&(e=b.brewer[e.toLowerCase()]),a(e)===`array`){e.length===1&&(e=[e[0],e[0]]),e=e.slice(0);for(let t=0;t<e.length;t++)e[t]=b(e[t]);c.length=0;for(let t=0;t<e.length;t++)c.push(t/(e.length-1))}return T(),d=e},x=function(e){if(u!=null){let t=u.length-1,n=0;for(;n<t&&e>=u[n];)n++;return n-1}return 0},S=e=>e,C=e=>e,w=function(e,i){let o,s;if(i??=!1,isNaN(e)||e===null)return r;s=i?e:u&&u.length>2?x(e)/(u.length-2):m===p?1:(e-p)/(m-p),s=C(s),i||(s=S(s)),v!==1&&(s=Xe(s,v)),s=l[0]+s*(1-l[0]-l[1]),s=n(s,0,1);let f=Math.floor(s*1e4);if(_&&g[f])o=g[f];else{if(a(d)===`array`)for(let e=0;e<c.length;e++){let n=c[e];if(s<=n){o=d[e];break}if(s>=n&&e===c.length-1){o=d[e];break}if(s>n&&s<c[e+1]){s=(s-n)/(c[e+1]-n),o=b.interpolate(d[e],d[e+1],s,t);break}}else a(d)===`function`&&(o=d(s));_&&(g[f]=o)}return o};var T=()=>g={};y(e);let E=function(e){let t=b(w(e));return f&&t[f]?t[f]():t};return E.classes=function(e){if(e!=null){if(a(e)===`array`)u=e,o=[e[0],e[e.length-1]];else{let t=b.analyze(o);u=e===0?[t.min,t.max]:b.limits(t,`e`,e)}return E}return u},E.domain=function(e){if(!arguments.length)return s;s=e.slice(0),p=e[0],m=e[e.length-1],c=[];let t=d.length;if(e.length===t&&p!==m)for(let t of Array.from(e))c.push((t-p)/(m-p));else{for(let e=0;e<t;e++)c.push(e/(t-1));if(e.length>2){let t=e.map((t,n)=>n/(e.length-1)),n=e.map(e=>(e-p)/(m-p));n.every((e,n)=>t[n]===e)||(C=e=>{if(e<=0||e>=1)return e;let r=0;for(;e>=n[r+1];)r++;let i=(e-n[r])/(n[r+1]-n[r]);return t[r]+i*(t[r+1]-t[r])})}}return o=[p,m],E},E.mode=function(e){return arguments.length?(t=e,T(),E):t},E.range=function(e,t){return y(e,t),E},E.out=function(e){return f=e,E},E.spread=function(e){return arguments.length?(i=e,E):i},E.correctLightness=function(e){return e??=!0,h=e,T(),S=h?function(e){let t=w(0,!0).lab()[0],n=w(1,!0).lab()[0],r=t>n,i=w(e,!0).lab()[0],a=t+(n-t)*e,o=i-a,s=0,c=1,l=20;for(;Math.abs(o)>.01&&l-- >0;)(function(){return r&&(o*=-1),o<0?(s=e,e+=(c-e)*.5):(c=e,e+=(s-e)*.5),i=w(e,!0).lab()[0],o=i-a})();return e}:e=>e,E},E.padding=function(e){return e==null?l:(a(e)===`number`&&(e=[e,e]),l=e,E)},E.colors=function(t,n){arguments.length<2&&(n=`hex`);let r=[];if(arguments.length===0)r=d.slice(0);else if(t===1)r=[E(.5)];else if(t>1){let e=o[0],n=o[1]-e;r=Ze(0,t,!1).map(r=>E(e+r/(t-1)*n))}else{e=[];let t=[];if(u&&u.length>2)for(let e=1,n=u.length,r=1<=n;r?e<n:e>n;r?e++:e--)t.push((u[e-1]+u[e])*.5);else t=o;r=t.map(e=>E(e))}return b[n]&&(r=r.map(e=>e[n]())),r},E.cache=function(e){return e==null?_:(_=e,E)},E.gamma=function(e){return e==null?v:(v=e,E)},E.nodata=function(e){return e==null?r:(r=b(e),E)},E}function Ze(e,t,n){let r=[],i=e<t,a=n?i?t+1:t-1:t;for(let t=e;i?t<a:t>a;i?t++:t--)r.push(t);return r}const Qe=function(e){let t=[1,1];for(let n=1;n<e;n++){let e=[1];for(let n=1;n<=t.length;n++)e[n]=(t[n]||0)+t[n-1];t=e}return t},$e=function(e){let t,n,r,i;if(e=e.map(e=>new y(e)),e.length===2)[n,r]=e.map(e=>e.lab()),t=function(e){return new y([0,1,2].map(t=>n[t]+e*(r[t]-n[t])),`lab`)};else if(e.length===3)[n,r,i]=e.map(e=>e.lab()),t=function(e){return new y([0,1,2].map(t=>(1-e)*(1-e)*n[t]+2*(1-e)*e*r[t]+e*e*i[t]),`lab`)};else if(e.length===4){let a;[n,r,i,a]=e.map(e=>e.lab()),t=function(e){return new y([0,1,2].map(t=>(1-e)*(1-e)*(1-e)*n[t]+3*(1-e)*(1-e)*e*r[t]+3*(1-e)*e*e*i[t]+e*e*e*a[t]),`lab`)}}else if(e.length>=5){let n,r,i;n=e.map(e=>e.lab()),i=e.length-1,r=Qe(i),t=function(e){let t=1-e;return new y([0,1,2].map(a=>n.reduce((n,o,s)=>n+r[s]*t**(i-s)*e**s*o[a],0)),`lab`)}}else throw RangeError(`No point in running bezier with only one color.`);return t};var et=e=>{let t=$e(e);return t.scale=()=>z(t),t};const{round:tt}=Math;y.prototype.rgb=function(e=!0){return e===!1?this._rgb.slice(0,3):this._rgb.slice(0,3).map(tt)},y.prototype.rgba=function(e=!0){return this._rgb.slice(0,4).map((t,n)=>n<3?e===!1?t:tt(t):t)},Object.assign(b,{rgb:(...e)=>new y(...e,`rgb`)}),v.format.rgb=(...e)=>{let t=o(e,`rgba`);return t[3]===void 0&&(t[3]=1),t},v.autodetect.push({p:3,test:(...e)=>{if(e=o(e,`rgba`),a(e)===`array`&&(e.length===3||e.length===4&&a(e[3])==`number`&&e[3]>=0&&e[3]<=1))return`rgb`}});const B=(e,t,n)=>{if(!B[n])throw Error(`unknown blend mode `+n);return B[n](e,t)},V=e=>(t,n)=>{let r=b(n).rgb(),i=b(t).rgb();return b.rgb(e(r,i))},H=e=>(t,n)=>{let r=[];return r[0]=e(t[0],n[0]),r[1]=e(t[1],n[1]),r[2]=e(t[2],n[2]),r};B.normal=V(H(e=>e)),B.multiply=V(H((e,t)=>e*t/255)),B.screen=V(H((e,t)=>255*(1-(1-e/255)*(1-t/255)))),B.overlay=V(H((e,t)=>t<128?2*e*t/255:255*(1-2*(1-e/255)*(1-t/255)))),B.darken=V(H((e,t)=>e>t?t:e)),B.lighten=V(H((e,t)=>e>t?e:t)),B.dodge=V(H((e,t)=>e===255?255:(e=t/255*255/(1-e/255),e>255?255:e))),B.burn=V(H((e,t)=>255*(1-(1-t/255)/(e/255))));const{pow:nt,sin:rt,cos:it}=Math;function at(e=300,t=-1.5,n=1,i=1,o=[0,1]){let s=0,c;a(o)===`array`?c=o[1]-o[0]:(c=0,o=[o,o]);let l=function(a){let l=p*((e+120)/360+t*a),u=nt(o[0]+c*a,i),d=(s===0?n:n[0]+a*s)*u*(1-u)/2,f=it(l),m=rt(l),h=u+d*(-.14861*f+1.78277*m),g=u+d*(-.29227*f-.90649*m),_=u+1.97294*f*d;return b(r([h*255,g*255,_*255,1]))};return l.start=function(t){return t==null?e:(e=t,l)},l.rotations=function(e){return e==null?t:(t=e,l)},l.gamma=function(e){return e==null?i:(i=e,l)},l.hue=function(e){return e==null?n:(n=e,a(n)===`array`?(s=n[1]-n[0],s===0&&(n=n[1])):s=0,l)},l.lightness=function(e){return e==null?o:(a(e)===`array`?(o=e,c=e[1]-e[0]):(o=[e,e],c=0),l)},l.scale=()=>b.scale(l),l.hue(n),l}const{floor:ot,random:st}=Math;var ct=(e=st)=>{let t=`#`;for(let n=0;n<6;n++)t+=`0123456789abcdef`.charAt(ot(e()*16));return new y(t,`hex`)};const{log:lt,pow:ut,floor:dt,abs:ft}=Math;function pt(e,t=null){let n={min:Number.MAX_VALUE,max:Number.MAX_VALUE*-1,sum:0,values:[],count:0};return a(e)===`object`&&(e=Object.values(e)),e.forEach(e=>{t&&a(e)===`object`&&(e=e[t]),e!=null&&!isNaN(e)&&(n.values.push(e),n.sum+=e,e<n.min&&(n.min=e),e>n.max&&(n.max=e),n.count+=1)}),n.domain=[n.min,n.max],n.limits=(e,t)=>mt(n,e,t),n}function mt(e,t=`equal`,n=7){a(e)==`array`&&(e=pt(e));let{min:r,max:i}=e,o=e.values.sort((e,t)=>e-t);if(n===1)return[r,i];let s=[];if(t.substr(0,1)===`c`&&(s.push(r),s.push(i)),t.substr(0,1)===`e`){s.push(r);for(let e=1;e<n;e++)s.push(r+e/n*(i-r));s.push(i)}else if(t.substr(0,1)===`l`){if(r<=0)throw Error(`Logarithmic scales are only possible for values > 0`);let e=Math.LOG10E*lt(r),t=Math.LOG10E*lt(i);s.push(r);for(let r=1;r<n;r++)s.push(ut(10,e+r/n*(t-e)));s.push(i)}else if(t.substr(0,1)===`q`){s.push(r);for(let e=1;e<n;e++){let t=(o.length-1)*e/n,r=dt(t);if(r===t)s.push(o[r]);else{let e=t-r;s.push(o[r]*(1-e)+o[r+1]*e)}}s.push(i)}else if(t.substr(0,1)===`k`){let e,t=o.length,a=Array(t),c=Array(n),l=!0,u=0,d=null;d=[],d.push(r);for(let e=1;e<n;e++)d.push(r+e/n*(i-r));for(d.push(i);l;){for(let e=0;e<n;e++)c[e]=0;for(let e=0;e<t;e++){let t=o[e],r=Number.MAX_VALUE,i;for(let o=0;o<n;o++){let n=ft(d[o]-t);n<r&&(r=n,i=o),c[i]++,a[e]=i}}let r=Array(n);for(let e=0;e<n;e++)r[e]=null;for(let n=0;n<t;n++)e=a[n],r[e]===null?r[e]=o[n]:r[e]+=o[n];for(let e=0;e<n;e++)r[e]*=1/c[e];l=!1;for(let e=0;e<n;e++)if(r[e]!==d[e]){l=!0;break}d=r,u++,u>200&&(l=!1)}let f={};for(let e=0;e<n;e++)f[e]=[];for(let n=0;n<t;n++)e=a[n],f[e].push(o[n]);let p=[];for(let e=0;e<n;e++)p.push(f[e][0]),p.push(f[e][f[e].length-1]);p=p.sort((e,t)=>e-t),s.push(p[0]);for(let e=1;e<p.length;e+=2){let t=p[e];!isNaN(t)&&s.indexOf(t)===-1&&s.push(t)}}return s}var ht=(e,t)=>{e=new y(e),t=new y(t);let n=e.luminance(),r=t.luminance();return n>r?(n+.05)/(r+.05):(r+.05)/(n+.05)};
2
- /**
3
- * @license
4
- *
5
- * The APCA contrast prediction algorithm is based of the formulas published
6
- * in the APCA-1.0.98G specification by Myndex. The specification is available at:
7
- * https://raw.githubusercontent.com/Myndex/apca-w3/master/images/APCAw3_0.1.17_APCA0.0.98G.svg
8
- *
9
- * Note that the APCA implementation is still beta, so please update to
10
- * future versions of chroma.js when they become available.
11
- *
12
- * You can read more about the APCA Readability Criterion at
13
- * https://readtech.org/ARC/
14
- */
15
- const gt=.027,_t=1.14,U=.022,vt=1.414;var yt=(e,t)=>{e=new y(e),t=new y(t),e.alpha()<1&&(e=P(t,e,e.alpha(),`rgb`));let n=bt(...e.rgb()),r=bt(...t.rgb()),i=n>=U?n:n+(U-n)**+vt,a=r>=U?r:r+(U-r)**+vt,o=a**.56-i**.57,s=a**.65-i**.62,c=Math.abs(a-i)<5e-4?0:i<a?o*_t:s*_t;return(Math.abs(c)<.1?0:c>0?c-gt:c+gt)*100};function bt(e,t,n){return .2126729*(e/255)**2.4+.7151522*(t/255)**2.4+.072175*(n/255)**2.4}const{sqrt:W,pow:G,min:xt,max:St,atan2:Ct,abs:wt,cos:K,sin:Tt,exp:Et,PI:Dt}=Math;function Ot(e,t,n=1,r=1,i=1){var a=function(e){return 360*e/(2*Dt)},o=function(e){return 2*Dt*e/360};e=new y(e),t=new y(t);let[s,c,l]=Array.from(e.lab()),[u,d,f]=Array.from(t.lab()),p=(s+u)/2,m=(W(G(c,2)+G(l,2))+W(G(d,2)+G(f,2)))/2,h=.5*(1-W(G(m,7)/(G(m,7)+G(25,7)))),g=c*(1+h),_=d*(1+h),v=W(G(g,2)+G(l,2)),b=W(G(_,2)+G(f,2)),x=(v+b)/2,S=a(Ct(l,g)),C=a(Ct(f,_)),w=S>=0?S:S+360,T=C>=0?C:C+360,E=wt(w-T)>180?(w+T+360)/2:(w+T)/2,D=1-.17*K(o(E-30))+.24*K(o(2*E))+.32*K(o(3*E+6))-.2*K(o(4*E-63)),O=T-w;O=wt(O)<=180?O:T<=w?O+360:O-360,O=2*W(v*b)*Tt(o(O)/2);let k=u-s,A=b-v,ee=1+.015*G(p-50,2)/W(20+G(p-50,2)),te=1+.045*x,j=1+.015*x*D,ne=30*Et(-G((E-275)/25,2)),M=-(2*W(G(x,7)/(G(x,7)+G(25,7))))*Tt(2*o(ne));return St(0,xt(100,W(G(k/(n*ee),2)+G(A/(r*te),2)+G(O/(i*j),2)+M*(A/(r*te))*(O/(i*j)))))}function kt(e,t,n=`lab`){e=new y(e),t=new y(t);let r=e.get(n),i=t.get(n),a=0;for(let e in r){let t=(r[e]||0)-(i[e]||0);a+=t*t}return Math.sqrt(a)}var At=(...e)=>{try{return new y(...e),!0}catch{return!1}},jt={cool(){return z([b.hsl(180,1,.9),b.hsl(250,.7,.4)])},hot(){return z([`#000`,`#f00`,`#ff0`,`#fff`],[0,.25,.75,1]).mode(`rgb`)}};const Mt={OrRd:[`#fff7ec`,`#fee8c8`,`#fdd49e`,`#fdbb84`,`#fc8d59`,`#ef6548`,`#d7301f`,`#b30000`,`#7f0000`],PuBu:[`#fff7fb`,`#ece7f2`,`#d0d1e6`,`#a6bddb`,`#74a9cf`,`#3690c0`,`#0570b0`,`#045a8d`,`#023858`],BuPu:[`#f7fcfd`,`#e0ecf4`,`#bfd3e6`,`#9ebcda`,`#8c96c6`,`#8c6bb1`,`#88419d`,`#810f7c`,`#4d004b`],Oranges:[`#fff5eb`,`#fee6ce`,`#fdd0a2`,`#fdae6b`,`#fd8d3c`,`#f16913`,`#d94801`,`#a63603`,`#7f2704`],BuGn:[`#f7fcfd`,`#e5f5f9`,`#ccece6`,`#99d8c9`,`#66c2a4`,`#41ae76`,`#238b45`,`#006d2c`,`#00441b`],YlOrBr:[`#ffffe5`,`#fff7bc`,`#fee391`,`#fec44f`,`#fe9929`,`#ec7014`,`#cc4c02`,`#993404`,`#662506`],YlGn:[`#ffffe5`,`#f7fcb9`,`#d9f0a3`,`#addd8e`,`#78c679`,`#41ab5d`,`#238443`,`#006837`,`#004529`],Reds:[`#fff5f0`,`#fee0d2`,`#fcbba1`,`#fc9272`,`#fb6a4a`,`#ef3b2c`,`#cb181d`,`#a50f15`,`#67000d`],RdPu:[`#fff7f3`,`#fde0dd`,`#fcc5c0`,`#fa9fb5`,`#f768a1`,`#dd3497`,`#ae017e`,`#7a0177`,`#49006a`],Greens:[`#f7fcf5`,`#e5f5e0`,`#c7e9c0`,`#a1d99b`,`#74c476`,`#41ab5d`,`#238b45`,`#006d2c`,`#00441b`],YlGnBu:[`#ffffd9`,`#edf8b1`,`#c7e9b4`,`#7fcdbb`,`#41b6c4`,`#1d91c0`,`#225ea8`,`#253494`,`#081d58`],Purples:[`#fcfbfd`,`#efedf5`,`#dadaeb`,`#bcbddc`,`#9e9ac8`,`#807dba`,`#6a51a3`,`#54278f`,`#3f007d`],GnBu:[`#f7fcf0`,`#e0f3db`,`#ccebc5`,`#a8ddb5`,`#7bccc4`,`#4eb3d3`,`#2b8cbe`,`#0868ac`,`#084081`],Greys:[`#ffffff`,`#f0f0f0`,`#d9d9d9`,`#bdbdbd`,`#969696`,`#737373`,`#525252`,`#252525`,`#000000`],YlOrRd:[`#ffffcc`,`#ffeda0`,`#fed976`,`#feb24c`,`#fd8d3c`,`#fc4e2a`,`#e31a1c`,`#bd0026`,`#800026`],PuRd:[`#f7f4f9`,`#e7e1ef`,`#d4b9da`,`#c994c7`,`#df65b0`,`#e7298a`,`#ce1256`,`#980043`,`#67001f`],Blues:[`#f7fbff`,`#deebf7`,`#c6dbef`,`#9ecae1`,`#6baed6`,`#4292c6`,`#2171b5`,`#08519c`,`#08306b`],PuBuGn:[`#fff7fb`,`#ece2f0`,`#d0d1e6`,`#a6bddb`,`#67a9cf`,`#3690c0`,`#02818a`,`#016c59`,`#014636`],Viridis:[`#440154`,`#482777`,`#3f4a8a`,`#31678e`,`#26838f`,`#1f9d8a`,`#6cce5a`,`#b6de2b`,`#fee825`],Spectral:[`#9e0142`,`#d53e4f`,`#f46d43`,`#fdae61`,`#fee08b`,`#ffffbf`,`#e6f598`,`#abdda4`,`#66c2a5`,`#3288bd`,`#5e4fa2`],RdYlGn:[`#a50026`,`#d73027`,`#f46d43`,`#fdae61`,`#fee08b`,`#ffffbf`,`#d9ef8b`,`#a6d96a`,`#66bd63`,`#1a9850`,`#006837`],RdBu:[`#67001f`,`#b2182b`,`#d6604d`,`#f4a582`,`#fddbc7`,`#f7f7f7`,`#d1e5f0`,`#92c5de`,`#4393c3`,`#2166ac`,`#053061`],PiYG:[`#8e0152`,`#c51b7d`,`#de77ae`,`#f1b6da`,`#fde0ef`,`#f7f7f7`,`#e6f5d0`,`#b8e186`,`#7fbc41`,`#4d9221`,`#276419`],PRGn:[`#40004b`,`#762a83`,`#9970ab`,`#c2a5cf`,`#e7d4e8`,`#f7f7f7`,`#d9f0d3`,`#a6dba0`,`#5aae61`,`#1b7837`,`#00441b`],RdYlBu:[`#a50026`,`#d73027`,`#f46d43`,`#fdae61`,`#fee090`,`#ffffbf`,`#e0f3f8`,`#abd9e9`,`#74add1`,`#4575b4`,`#313695`],BrBG:[`#543005`,`#8c510a`,`#bf812d`,`#dfc27d`,`#f6e8c3`,`#f5f5f5`,`#c7eae5`,`#80cdc1`,`#35978f`,`#01665e`,`#003c30`],RdGy:[`#67001f`,`#b2182b`,`#d6604d`,`#f4a582`,`#fddbc7`,`#ffffff`,`#e0e0e0`,`#bababa`,`#878787`,`#4d4d4d`,`#1a1a1a`],PuOr:[`#7f3b08`,`#b35806`,`#e08214`,`#fdb863`,`#fee0b6`,`#f7f7f7`,`#d8daeb`,`#b2abd2`,`#8073ac`,`#542788`,`#2d004b`],Set2:[`#66c2a5`,`#fc8d62`,`#8da0cb`,`#e78ac3`,`#a6d854`,`#ffd92f`,`#e5c494`,`#b3b3b3`],Accent:[`#7fc97f`,`#beaed4`,`#fdc086`,`#ffff99`,`#386cb0`,`#f0027f`,`#bf5b17`,`#666666`],Set1:[`#e41a1c`,`#377eb8`,`#4daf4a`,`#984ea3`,`#ff7f00`,`#ffff33`,`#a65628`,`#f781bf`,`#999999`],Set3:[`#8dd3c7`,`#ffffb3`,`#bebada`,`#fb8072`,`#80b1d3`,`#fdb462`,`#b3de69`,`#fccde5`,`#d9d9d9`,`#bc80bd`,`#ccebc5`,`#ffed6f`],Dark2:[`#1b9e77`,`#d95f02`,`#7570b3`,`#e7298a`,`#66a61e`,`#e6ab02`,`#a6761d`,`#666666`],Paired:[`#a6cee3`,`#1f78b4`,`#b2df8a`,`#33a02c`,`#fb9a99`,`#e31a1c`,`#fdbf6f`,`#ff7f00`,`#cab2d6`,`#6a3d9a`,`#ffff99`,`#b15928`],Pastel2:[`#b3e2cd`,`#fdcdac`,`#cbd5e8`,`#f4cae4`,`#e6f5c9`,`#fff2ae`,`#f1e2cc`,`#cccccc`],Pastel1:[`#fbb4ae`,`#b3cde3`,`#ccebc5`,`#decbe4`,`#fed9a6`,`#ffffcc`,`#e5d8bd`,`#fddaec`,`#f2f2f2`]},Nt=Object.keys(Mt),Pt=new Map(Nt.map(e=>[e.toLowerCase(),e])),Ft=typeof Proxy==`function`?new Proxy(Mt,{get(e,t){let n=t.toLowerCase();if(Pt.has(n))return e[Pt.get(n)]},getOwnPropertyNames(){return Object.getOwnPropertyNames(Nt)}}):Mt,It=(...e)=>{e=o(e,`cmyk`);let[t,n,r,i]=e,a=e.length>4?e[4]:1;return i===1?[0,0,0,a]:[t>=1?0:255*(1-t)*(1-i),n>=1?0:255*(1-n)*(1-i),r>=1?0:255*(1-r)*(1-i),a]},{max:Lt}=Math,Rt=(...e)=>{let[t,n,r]=o(e,`rgb`);t/=255,n/=255,r/=255;let i=1-Lt(t,Lt(n,r)),a=i<1?1/(1-i):0;return[(1-t-i)*a,(1-n-i)*a,(1-r-i)*a,i]};y.prototype.cmyk=function(){return Rt(this._rgb)},Object.assign(b,{cmyk:(...e)=>new y(...e,`cmyk`)}),v.format.cmyk=It,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`cmyk`),a(e)===`array`&&e.length===4)return`cmyk`}});const zt=(...e)=>{let t=o(e,`hsla`),n=s(e)||`lsa`;return t[0]=d(t[0]||0)+`deg`,t[1]=d(t[1]*100)+`%`,t[2]=d(t[2]*100)+`%`,n===`hsla`||t.length>3&&t[3]<1?(t[3]=`/ `+(t.length>3?t[3]:1),n=`hsla`):t.length=3,`${n.substr(0,3)}(${t.join(` `)})`},Bt=(...e)=>{let t=o(e,`lab`),n=s(e)||`lab`;return t[0]=d(t[0])+`%`,t[1]=d(t[1]),t[2]=d(t[2]),n===`laba`||t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`lab(${t.join(` `)})`},Vt=(...e)=>{let t=o(e,`lch`),n=s(e)||`lab`;return t[0]=d(t[0])+`%`,t[1]=d(t[1]),t[2]=isNaN(t[2])?`none`:d(t[2])+`deg`,n===`lcha`||t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`lch(${t.join(` `)})`},Ht=(...e)=>{let t=o(e,`lab`);return t[0]=d(t[0]*100)+`%`,t[1]=f(t[1]),t[2]=f(t[2]),t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`oklab(${t.join(` `)})`},Ut=(...e)=>{let[t,n,r,...i]=o(e,`rgb`),[a,s,c]=Be(t,n,r),[l,u,d]=_e(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]},Wt=(...e)=>{let t=o(e,`lch`);return t[0]=d(t[0]*100)+`%`,t[1]=f(t[1]),t[2]=isNaN(t[2])?`none`:d(t[2])+`deg`,t.length>3&&t[3]<1?t[3]=`/ `+(t.length>3?t[3]:1):t.length=3,`oklch(${t.join(` `)})`},{round:Gt}=Math,Kt=(...e)=>{let t=o(e,`rgba`),n=s(e)||`rgb`;if(n.substr(0,3)===`hsl`)return zt(Me(t),n);if(n.substr(0,3)===`lab`){let e=A();k(`d50`);let r=Bt(M(t),n);return k(e),r}if(n.substr(0,3)===`lch`){let e=A();k(`d50`);let r=Vt(ve(t),n);return k(e),r}return n.substr(0,5)===`oklab`?Ht(Be(t)):n.substr(0,5)===`oklch`?Wt(Ut(t)):(t[0]=Gt(t[0]),t[1]=Gt(t[1]),t[2]=Gt(t[2]),(n===`rgba`||t.length>3&&t[3]<1)&&(t[3]=`/ `+(t.length>3?t[3]:1),n=`rgba`),`${n.substr(0,3)}(${t.slice(0,n===`rgb`?3:4).join(` `)})`)},qt=(...e)=>{e=o(e,`lch`);let[t,n,r,...i]=e,[a,s,c]=de(t,n,r),[l,u,d]=Re(a,s,c);return[l,u,d,...i.length>0&&i[0]<1?[i[0]]:[]]},q=`((?:-?\\d+)|(?:-?\\d+(?:\\.\\d+)?)%|none)`,J=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)%?)|none)`,Y=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)%)|none)`,Jt=`\\s*,\\s*`,Yt=`((?:-?(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:deg)?)|none)`,X=`\\s*(?:\\/\\s*((?:[01]|[01]?\\.\\d+)|\\d+(?:\\.\\d+)?%))?`,Xt=RegExp(`^rgba?\\(\\s*`+[q,q,q].join(`\\s+`)+X+`\\)$`),Zt=RegExp(`^rgb\\(\\s*`+[q,q,q].join(Jt)+`\\s*\\)$`),Qt=RegExp(`^rgba\\(\\s*`+[q,q,q,J].join(Jt)+`\\s*\\)$`),$t=RegExp(`^hsla?\\(\\s*`+[Yt,Y,Y].join(`\\s+`)+X+`\\)$`),en=RegExp(`^hsl?\\(\\s*`+[Yt,Y,Y].join(Jt)+`\\s*\\)$`),tn=/^hsla\(\s*(-?\d+(?:\.\d+)?),\s*(-?\d+(?:\.\d+)?)%\s*,\s*(-?\d+(?:\.\d+)?)%\s*,\s*([01]|[01]?\.\d+)\)$/,nn=RegExp(`^lab\\(\\s*`+[J,J,J].join(`\\s+`)+X+`\\)$`),rn=RegExp(`^lch\\(\\s*`+[J,J,Yt].join(`\\s+`)+X+`\\)$`),an=RegExp(`^oklab\\(\\s*`+[J,J,J].join(`\\s+`)+X+`\\)$`),on=RegExp(`^oklch\\(\\s*`+[J,J,Yt].join(`\\s+`)+X+`\\)$`),{round:sn}=Math,Z=e=>e.map((e,t)=>t<=2?n(sn(e),0,255):e),Q=(e,t=0,n=100,r=!1)=>(typeof e==`string`&&e.endsWith(`%`)&&(e=parseFloat(e.substring(0,e.length-1))/100,e=r?t+(e+1)*.5*(n-t):t+e*(n-t)),+e),$=(e,t)=>e===`none`?t:e,cn=e=>{if(e=e.toLowerCase().trim(),e===`transparent`)return[0,0,0,0];let t;if(v.format.named)try{return v.format.named(e)}catch{}if((t=e.match(Xt))||(t=e.match(Zt))){let e=t.slice(1,4);for(let t=0;t<3;t++)e[t]=+Q($(e[t],0),0,255);e=Z(e);let n=t[4]===void 0?1:+Q(t[4],0,1);return e[3]=n,e}if(t=e.match(Qt)){let e=t.slice(1,5);for(let t=0;t<4;t++)e[t]=+Q(e[t],0,255);return e}if((t=e.match($t))||(t=e.match(en))){let e=t.slice(1,4);e[0]=+$(e[0].replace(`deg`,``),0),e[1]=Q($(e[1],0),0,100)*.01,e[2]=Q($(e[2],0),0,100)*.01;let n=Z(je(e));return n[3]=t[4]===void 0?1:+Q(t[4],0,1),n}if(t=e.match(tn)){let e=t.slice(1,4);e[1]*=.01,e[2]*=.01;let n=je(e);for(let e=0;e<3;e++)n[e]=sn(n[e]);return n[3]=+t[4],n}if(t=e.match(nn)){let e=t.slice(1,4);e[0]=Q($(e[0],0),0,100),e[1]=Q($(e[1],0),-125,125,!0),e[2]=Q($(e[2],0),-125,125,!0);let n=A();k(`d50`);let r=Z(ee(e));return k(n),r[3]=t[4]===void 0?1:+Q(t[4],0,1),r}if(t=e.match(rn)){let e=t.slice(1,4);e[0]=Q(e[0],0,100),e[1]=Q($(e[1],0),0,150,!1),e[2]=+$(e[2].replace(`deg`,``),0);let n=A();k(`d50`);let r=Z(fe(e));return k(n),r[3]=t[4]===void 0?1:+Q(t[4],0,1),r}if(t=e.match(an)){let e=t.slice(1,4);e[0]=Q($(e[0],0),0,1),e[1]=Q($(e[1],0),-.4,.4,!0),e[2]=Q($(e[2],0),-.4,.4,!0);let n=Z(Re(e));return n[3]=t[4]===void 0?1:+Q(t[4],0,1),n}if(t=e.match(on)){let e=t.slice(1,4);e[0]=Q($(e[0],0),0,1),e[1]=Q($(e[1],0),0,.4,!1),e[2]=+$(e[2].replace(`deg`,``),0);let n=Z(qt(e));return n[3]=t[4]===void 0?1:+Q(t[4],0,1),n}};cn.test=e=>Xt.test(e)||$t.test(e)||nn.test(e)||rn.test(e)||an.test(e)||on.test(e)||Zt.test(e)||Qt.test(e)||en.test(e)||tn.test(e)||e===`transparent`,y.prototype.css=function(e){return Kt(this._rgb,e)},b.css=(...e)=>new y(...e,`css`),v.format.css=cn,v.autodetect.push({p:5,test:(e,...t)=>{if(!t.length&&a(e)===`string`&&cn.test(e))return`css`}}),v.format.gl=(...e)=>{let t=o(e,`rgba`);return t[0]*=255,t[1]*=255,t[2]*=255,t},b.gl=(...e)=>new y(...e,`gl`),y.prototype.gl=function(){let e=this._rgb;return[e[0]/255,e[1]/255,e[2]/255,e[3]]},y.prototype.hex=function(e){return E(this._rgb,e)},b.hex=(...e)=>new y(...e,`hex`),v.format.hex=w,v.autodetect.push({p:4,test:(e,...t)=>{if(!t.length&&a(e)===`string`&&[3,4,5,6,7,8,9].indexOf(e.length)>=0)return`hex`}});const{log:ln}=Math,un=e=>{let t=e/100,n,r,i;return t<66?(n=255,r=t<6?0:-155.25485562709179-.44596950469579133*(r=t-2)+104.49216199393888*ln(r),i=t<20?0:-254.76935184120902+.8274096064007395*(i=t-10)+115.67994401066147*ln(i)):(n=351.97690566805693+.114206453784165*(n=t-55)-40.25366309332127*ln(n),r=325.4494125711974+.07943456536662342*(r=t-50)-28.0852963507957*ln(r),i=255),[n,r,i,1]},{round:dn}=Math,fn=(...e)=>{let t=o(e,`rgb`),n=t[0],r=t[2],i=1e3,a=4e4,s;for(;a-i>.4;){s=(a+i)*.5;let e=un(s);e[2]/e[0]>=r/n?a=s:i=s}return dn(s)};y.prototype.temp=y.prototype.kelvin=y.prototype.temperature=function(){return fn(this._rgb)};const pn=(...e)=>new y(...e,`temp`);Object.assign(b,{temp:pn,kelvin:pn,temperature:pn}),v.format.temp=v.format.kelvin=v.format.temperature=un,y.prototype.oklch=function(){return Ut(this._rgb)},Object.assign(b,{oklch:(...e)=>new y(...e,`oklch`)}),v.format.oklch=qt,v.autodetect.push({p:2,test:(...e)=>{if(e=o(e,`oklch`),a(e)===`array`&&e.length===3)return`oklch`}}),Object.assign(b,{analyze:pt,average:Je,bezier:et,blend:B,brewer:Ft,Color:y,colors:x,contrast:ht,contrastAPCA:yt,cubehelix:at,deltaE:Ot,distance:kt,input:v,interpolate:P,limits:mt,mix:P,random:ct,scale:z,scales:jt,valid:At});var mn=b;const hn=[.96,.907,.805,.697,.605,.547,.518,.445,.395,.34],gn=[.32,.16,.08,.04,0,0,.04,.08,.16,.32];function _n(e){let t=e.get(`hsl.l`);return hn.reduce((e,n)=>Math.abs(n-t)<Math.abs(e-t)?n:e)}function vn(e){let t=mn(e),n=_n(t),r=hn.findIndex(e=>e===n),i=hn.map(e=>t.set(`hsl.l`,e)).map(e=>mn(e)).map((e,t)=>{let n=gn[t]-gn[r];return n>=0?e.saturate(n):e.desaturate(n*-1)});return i[r]=mn(e),{baseColorIndex:r,colors:i}}function yn(e){return vn(e).colors.map(e=>e.hex())}export{mn as n,yn as t};