UNPKG

storybook

Version:

Storybook: Develop, document, and test UI components in isolation

1,535 lines (1,472 loc) • 95.3 kB
var Br = Object.create; var ce = Object.defineProperty; var zr = Object.getOwnPropertyDescriptor; var Ur = Object.getOwnPropertyNames; var Gr = Object.getPrototypeOf, Wr = Object.prototype.hasOwnProperty; var n = (e, t) => ce(e, "name", { value: t, configurable: !0 }); var Yr = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), xt = (e, t) => { for (var r in t) ce(e, r, { get: t[r], enumerable: !0 }); }, Vr = (e, t, r, o) => { if (t && typeof t == "object" || typeof t == "function") for (let i of Ur(t)) !Wr.call(e, i) && i !== r && ce(e, i, { get: () => t[i], enumerable: !(o = zr(t, i)) || o.enumerable }); return e; }; var Kr = (e, t, r) => (r = e != null ? Br(Gr(e)) : {}, Vr( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. t || !e || !e.__esModule ? ce(r, "default", { value: e, enumerable: !0 }) : r, e )); // ../node_modules/@ngard/tiny-isequal/index.js var Tt = Yr((Ee) => { Object.defineProperty(Ee, "__esModule", { value: !0 }), Ee.isEqual = /* @__PURE__ */ function() { var e = Object.prototype.toString, t = Object.getPrototypeOf, r = Object.getOwnPropertySymbols ? function(o) { return Object.keys(o).concat(Object.getOwnPropertySymbols(o)); } : Object.keys; return function(o, i) { return (/* @__PURE__ */ n(function s(a, p, c) { var l, y, u, h = e.call(a), T = e.call(p); if (a === p) return !0; if (a == null || p == null) return !1; if (c.indexOf(a) > -1 && c.indexOf(p) > -1) return !0; if (c.push(a, p), h != T || (l = r(a), y = r(p), l.length != y.length || l.some(function(R) { return !s(a[R], p[R], c); }))) return !1; switch (h.slice(8, -1)) { case "Symbol": return a.valueOf() == p.valueOf(); case "Date": case "Number": return +a == +p || +a != +a && +p != +p; case "RegExp": case "Function": case "String": case "Boolean": return "" + a == "" + p; case "Set": case "Map": l = a.entries(), y = p.entries(); do if (!s((u = l.next()).value, y.next().value, c)) return !1; while (!u.done); return !0; case "ArrayBuffer": a = new Uint8Array(a), p = new Uint8Array(p); case "DataView": a = new Uint8Array(a.buffer), p = new Uint8Array(p.buffer); case "Float32Array": case "Float64Array": case "Int8Array": case "Int16Array": case "Int32Array": case "Uint8Array": case "Uint16Array": case "Uint32Array": case "Uint8ClampedArray": case "Arguments": case "Array": if (a.length != p.length) return !1; for (u = 0; u < a.length; u++) if ((u in a || u in p) && (u in a != u in p || !s(a[u], p[u], c))) return !1; return !0; case "Object": return s(t(a), t(p), c); default: return !1; } }, "n"))(o, i, []); }; }(); }); // src/csf/toStartCaseStr.ts function bt(e) { return e.replace(/_/g, " ").replace(/-/g, " ").replace(/\./g, " ").replace(/([^\n])([A-Z])([a-z])/g, (t, r, o, i) => `${r} ${o}${i}`).replace( /([a-z])([A-Z])/g, (t, r, o) => `${r} ${o}`).replace(/([a-z])([0-9])/gi, (t, r, o) => `${r} ${o}`).replace(/([0-9])([a-z])/gi, (t, r, o) => `${r}\ ${o}`).replace(/(\s|^)(\w)/g, (t, r, o) => `${r}${o.toUpperCase()}`).replace(/ +/g, " ").trim(); } n(bt, "toStartCaseStr"); // src/csf/includeConditionalArg.ts var Ce = Kr(Tt(), 1); var St = /* @__PURE__ */ n((e) => e.map((t) => typeof t < "u").filter(Boolean).length, "count"), qr = /* @__PURE__ */ n((e, t) => { let { exists: r, eq: o, neq: i, truthy: s } = e; if (St([r, o, i, s]) > 1) throw new Error(`Invalid conditional test ${JSON.stringify({ exists: r, eq: o, neq: i })}`); if (typeof o < "u") return (0, Ce.isEqual)(t, o); if (typeof i < "u") return !(0, Ce.isEqual)(t, i); if (typeof r < "u") { let p = typeof t < "u"; return r ? p : !p; } return (typeof s > "u" ? !0 : s) ? !!t : !t; }, "testValue"), Xr = /* @__PURE__ */ n((e, t, r) => { if (!e.if) return !0; let { arg: o, global: i } = e.if; if (St([o, i]) !== 1) throw new Error(`Invalid conditional value ${JSON.stringify({ arg: o, global: i })}`); let s = o ? t[o] : r[i]; return qr(e.if, s); }, "includeConditionalArg"); // src/csf/csf-factories.ts import { combineTags as Hn } from "storybook/internal/csf"; // src/preview-api/modules/addons/main.ts import { global as ve } from "@storybook/global"; // src/preview-api/modules/addons/storybook-channel-mock.ts import { Channel as Zr } from "storybook/internal/channels"; function At() { let e = { setHandler: /* @__PURE__ */ n(() => { }, "setHandler"), send: /* @__PURE__ */ n(() => { }, "send") }; return new Zr({ transport: e }); } n(At, "mockChannel"); // src/preview-api/modules/addons/main.ts var Me = class Me { constructor() { this.getChannel = /* @__PURE__ */ n(() => { if (!this.channel) { let t = At(); return this.setChannel(t), t; } return this.channel; }, "getChannel"); this.ready = /* @__PURE__ */ n(() => this.promise, "ready"); this.hasChannel = /* @__PURE__ */ n(() => !!this.channel, "hasChannel"); this.setChannel = /* @__PURE__ */ n((t) => { this.channel = t, this.resolve(); }, "setChannel"); this.promise = new Promise((t) => { this.resolve = () => t(this.getChannel()); }); } }; n(Me, "AddonStore"); var Pe = Me, ke = "__STORYBOOK_ADDONS_PREVIEW"; function Jr() { return ve[ke] || (ve[ke] = new Pe()), ve[ke]; } n(Jr, "getAddonsStore"); var Oe = Jr(); // src/preview-api/modules/addons/hooks.ts import { logger as ri } from "storybook/internal/client-logger"; import { FORCE_RE_RENDER as ni, RESET_STORY_ARGS as ii, STORY_RENDERED as Rt, UPDATE_GLOBALS as si, UPDATE_STORY_ARGS as ai } from "storybook/internal/core-events"; import { global as $e } from "@storybook/global"; var Ie = class Ie { constructor() { this.hookListsMap = void 0; this.mountedDecorators = void 0; this.prevMountedDecorators = void 0; this.currentHooks = void 0; this.nextHookIndex = void 0; this.currentPhase = void 0; this.currentEffects = void 0; this.prevEffects = void 0; this.currentDecoratorName = void 0; this.hasUpdates = void 0; this.currentContext = void 0; this.renderListener = /* @__PURE__ */ n((t) => { t === this.currentContext?.id && (this.triggerEffects(), this.currentContext = null, this.removeRenderListeners()); }, "renderListener"); this.init(); } init() { this.hookListsMap = /* @__PURE__ */ new WeakMap(), this.mountedDecorators = /* @__PURE__ */ new Set(), this.prevMountedDecorators = /* @__PURE__ */ new Set(), this.currentHooks = [], this.nextHookIndex = 0, this.currentPhase = "NONE", this.currentEffects = [], this.prevEffects = [], this.currentDecoratorName = null, this.hasUpdates = !1, this.currentContext = null; } clean() { this.prevEffects.forEach((t) => { t.destroy && t.destroy(); }), this.init(), this.removeRenderListeners(); } getNextHook() { let t = this.currentHooks[this.nextHookIndex]; return this.nextHookIndex += 1, t; } triggerEffects() { this.prevEffects.forEach((t) => { !this.currentEffects.includes(t) && t.destroy && t.destroy(); }), this.currentEffects.forEach((t) => { this.prevEffects.includes(t) || (t.destroy = t.create()); }), this.prevEffects = this.currentEffects, this.currentEffects = []; } addRenderListeners() { this.removeRenderListeners(), Oe.getChannel().on(Rt, this.renderListener); } removeRenderListeners() { Oe.getChannel().removeListener(Rt, this.renderListener); } }; n(Ie, "HooksContext"); var de = Ie; function wt(e) { let t = /* @__PURE__ */ n((...r) => { let { hooks: o } = typeof r[0] == "function" ? r[1] : r[0], i = o.currentPhase, s = o.currentHooks, a = o.nextHookIndex, p = o.currentDecoratorName; o.currentDecoratorName = e.name, o.prevMountedDecorators.has(e) ? (o.currentPhase = "UPDATE", o.currentHooks = o.hookListsMap.get(e) || []) : (o.currentPhase = "MOUNT", o.currentHooks = [], o.hookListsMap.set(e, o.currentHooks), o.prevMountedDecorators.add(e)), o.nextHookIndex = 0; let c = $e.STORYBOOK_HOOKS_CONTEXT; $e.STORYBOOK_HOOKS_CONTEXT = o; let l = e(...r); if ($e.STORYBOOK_HOOKS_CONTEXT = c, o.currentPhase === "UPDATE" && o.getNextHook() != null) throw new Error( "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." ); return o.currentPhase = i, o.currentHooks = s, o.nextHookIndex = a, o.currentDecoratorName = p, l; }, "hookified"); return t.originalFn = e, t; } n(wt, "hookify"); var Fe = 0, Qr = 25, Et = /* @__PURE__ */ n((e) => (t, r) => { let o = e( wt(t), r.map((i) => wt(i)) ); return (i) => { let { hooks: s } = i; s.prevMountedDecorators ??= /* @__PURE__ */ new Set(), s.mountedDecorators = /* @__PURE__ */ new Set([t, ...r]), s.currentContext = i, s. hasUpdates = !1; let a = o(i); for (Fe = 1; s.hasUpdates; ) if (s.hasUpdates = !1, s.currentEffects = [], a = o(i), Fe += 1, Fe > Qr) throw new Error( "Too many re-renders. Storybook limits the number of renders to prevent an infinite loop." ); return s.addRenderListeners(), a; }; }, "applyHooks"); // ../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs function ee(e) { if (!e || typeof e != "object") return !1; let t = Object.getPrototypeOf(e); return t === null || t === Object.prototype || Object.getPrototypeOf(t) === null ? Object.prototype.toString.call(e) === "[object Object]" : !1; } n(ee, "isPlainObject"); // ../node_modules/es-toolkit/dist/object/mapValues.mjs function U(e, t) { let r = {}, o = Object.keys(e); for (let i = 0; i < o.length; i++) { let s = o[i], a = e[s]; r[s] = t(a, s, e); } return r; } n(U, "mapValues"); // ../node_modules/es-toolkit/dist/object/pickBy.mjs function Le(e, t) { let r = {}, o = Object.keys(e); for (let i = 0; i < o.length; i++) { let s = o[i], a = e[s]; t(a, s) && (r[s] = a); } return r; } n(Le, "pickBy"); // src/preview-api/modules/store/args.ts import { once as Ei } from "storybook/internal/client-logger"; // ../node_modules/ts-dedent/esm/index.js function W(e) { for (var t = [], r = 1; r < arguments.length; r++) t[r - 1] = arguments[r]; var o = Array.from(typeof e == "string" ? [e] : e); o[o.length - 1] = o[o.length - 1].replace(/\r?\n([\t ]*)$/, ""); var i = o.reduce(function(p, c) { var l = c.match(/\n([\t ]+|(?!\s).)/g); return l ? p.concat(l.map(function(y) { var u, h; return (h = (u = y.match(/[\t ]/g)) === null || u === void 0 ? void 0 : u.length) !== null && h !== void 0 ? h : 0; })) : p; }, []); if (i.length) { var s = new RegExp(` [ ]{` + Math.min.apply(Math, i) + "}", "g"); o = o.map(function(p) { return p.replace(s, ` `); }); } o[0] = o[0].replace(/^\r?\n/, ""); var a = o[0]; return t.forEach(function(p, c) { var l = a.match(/(?:^|\n)( *)$/), y = l ? l[1] : "", u = p; typeof p == "string" && p.includes(` `) && (u = String(p).split(` `).map(function(h, T) { return T === 0 ? h : "" + y + h; }).join(` `)), a += u + o[c + 1]; }), a; } n(W, "dedent"); // src/preview-api/modules/store/args.ts var vi = Symbol("incompatible"); var ki = Symbol("Deeply equal"); var De = "UNTARGETED"; function Ct({ args: e, argTypes: t }) { let r = {}; return Object.entries(e).forEach(([o, i]) => { let { target: s = De } = t[o] || {}; r[s] = r[s] || {}, r[s][o] = i; }), r; } n(Ct, "groupArgsByTarget"); // src/preview-api/modules/store/csf/getValuesFromArgTypes.ts var vt = /* @__PURE__ */ n((e = {}) => Object.entries(e).reduce((t, [r, { defaultValue: o }]) => (typeof o < "u" && (t[r] = o), t), {}), "ge\ tValuesFromArgTypes"); // src/preview-api/modules/store/csf/normalizeInputTypes.ts var eo = /* @__PURE__ */ n((e) => typeof e == "string" ? { name: e } : e, "normalizeType"), to = /* @__PURE__ */ n((e) => typeof e == "strin\ g" ? { type: e } : e, "normalizeControl"), ro = /* @__PURE__ */ n((e, t) => { let { type: r, control: o, ...i } = e, s = { name: t, ...i }; return r && (s.type = eo(r)), o ? s.control = to(o) : o === !1 && (s.control = { disable: !0 }), s; }, "normalizeInputType"), K = /* @__PURE__ */ n((e) => U(e, ro), "normalizeInputTypes"); // src/preview-api/modules/store/csf/normalizeStory.ts import { deprecate as oo, logger as no } from "storybook/internal/client-logger"; import { storyNameFromExport as io, toId as so } from "storybook/internal/csf"; // src/preview-api/modules/store/csf/normalizeArrays.ts var b = /* @__PURE__ */ n((e) => Array.isArray(e) ? e : e ? [e] : [], "normalizeArrays"); // src/preview-api/modules/store/csf/normalizeStory.ts var ao = W` CSF .story annotations deprecated; annotate story functions directly: - StoryFn.story.name => StoryFn.storyName - StoryFn.story.(parameters|decorators) => StoryFn.(parameters|decorators) See https://github.com/storybookjs/storybook/blob/next/MIGRATION.md#hoisted-csf-annotations for details and codemod. `; function _e(e, t, r) { let o = t, i = typeof t == "function" ? t : null, { story: s } = o; s && (no.debug("deprecated story", s), oo(ao)); let a = io(e), p = typeof o != "function" && o.name || o.storyName || s?.name || a, c = [ ...b(o.decorators), ...b(s?.decorators) ], l = { ...s?.parameters, ...o.parameters }, y = { ...s?.args, ...o.args }, u = { ...s?.argTypes, ...o.argTypes }, h = [...b(o.loaders), ...b( s?.loaders)], T = [ ...b(o.beforeEach), ...b(s?.beforeEach) ], R = [ ...b(o.afterEach), ...b(s?.afterEach) ], { render: P, play: L, tags: O = [], globals: F = {} } = o, A = l.__id || so(r.id, a); return { moduleExport: t, id: A, name: p, tags: O, decorators: c, parameters: l, args: y, argTypes: K(u), loaders: h, beforeEach: T, afterEach: R, globals: F, ...P && { render: P }, ...i && { userStoryFn: i }, ...L && { play: L } }; } n(_e, "normalizeStory"); // src/preview-api/modules/store/csf/normalizeComponentAnnotations.ts import { sanitize as po } from "storybook/internal/csf"; function kt(e, t = e.title, r) { let { id: o, argTypes: i } = e; return { id: po(o || t), ...e, title: t, ...i && { argTypes: K(i) }, parameters: { fileName: r, ...e.parameters } }; } n(kt, "normalizeComponentAnnotations"); // src/preview-api/modules/store/csf/prepareStory.ts import { combineTags as co, includeConditionalArg as mo } from "storybook/internal/csf"; import { NoRenderFunctionError as uo } from "storybook/internal/preview-errors"; import { global as fo } from "@storybook/global"; import { global as yo } from "@storybook/global"; // src/preview-api/modules/preview-web/render/mount-utils.ts function Ot(e) { return e != null && lo(e).includes("mount"); } n(Ot, "mountDestructured"); function lo(e) { let t = e.toString().match(/[^(]*\(([^)]*)/); if (!t) return []; let r = Pt(t[1]); if (!r.length) return []; let o = r[0]; return o.startsWith("{") && o.endsWith("}") ? Pt(o.slice(1, -1).replace(/\s/g, "")).map((s) => s.replace(/:.*|=.*/g, "")) : []; } n(lo, "getUsedProps"); function Pt(e) { let t = [], r = [], o = 0; for (let s = 0; s < e.length; s++) if (e[s] === "{" || e[s] === "[") r.push(e[s] === "{" ? "}" : "]"); else if (e[s] === r[r.length - 1]) r.pop(); else if (!r.length && e[s] === ",") { let a = e.substring(o, s).trim(); a && t.push(a), o = s + 1; } let i = e.substring(o).trim(); return i && t.push(i), t; } n(Pt, "splitByComma"); // src/preview-api/modules/store/decorators.ts function Mt(e, t, r) { let o = r(e); return (i) => t(o, i); } n(Mt, "decorateStory"); function $t({ componentId: e, title: t, kind: r, id: o, name: i, story: s, parameters: a, initialArgs: p, argTypes: c, ...l } = {}) { return l; } n($t, "sanitizeStoryContextUpdate"); function He(e, t) { let r = {}, o = /* @__PURE__ */ n((s) => (a) => { if (!r.value) throw new Error("Decorated function called without init"); return r.value = { ...r.value, ...$t(a) }, s(r.value); }, "bindWithContext"), i = t.reduce( (s, a) => Mt(s, a, o), e ); return (s) => (r.value = s, i(s)); } n(He, "defaultDecorateStory"); // src/preview-api/modules/store/parameters.ts var D = /* @__PURE__ */ n((...e) => { let t = {}, r = e.filter(Boolean), o = r.reduce((i, s) => (Object.entries(s).forEach(([a, p]) => { let c = i[a]; Array.isArray(p) || typeof c > "u" ? i[a] = p : ee(p) && ee(c) ? t[a] = !0 : typeof p < "u" && (i[a] = p); }), i), {}); return Object.keys(t).forEach((i) => { let s = r.filter(Boolean).map((a) => a[i]).filter((a) => typeof a < "u"); s.every((a) => ee(a)) ? o[i] = D(...s) : o[i] = s[s.length - 1]; }), o; }, "combineParameters"); // src/preview-api/modules/store/csf/prepareStory.ts function Ne(e, t, r) { let { moduleExport: o, id: i, name: s } = e || {}, a = go( e, t, r ), p = /* @__PURE__ */ n(async (w) => { let d = {}; for (let m of [ b(r.loaders), b(t.loaders), b(e.loaders) ]) { if (w.abortSignal.aborted) return d; let f = await Promise.all(m.map((x) => x(w))); Object.assign(d, ...f); } return d; }, "applyLoaders"), c = /* @__PURE__ */ n(async (w) => { let d = new Array(); for (let m of [ ...b(r.beforeEach), ...b(t.beforeEach), ...b(e.beforeEach) ]) { if (w.abortSignal.aborted) return d; let f = await m(w); f && d.push(f); } return d; }, "applyBeforeEach"), l = /* @__PURE__ */ n(async (w) => { let d = [ ...b(r.afterEach), ...b(t.afterEach), ...b(e.afterEach) ].reverse(); for (let m of d) { if (w.abortSignal.aborted) return; await m(w); } }, "applyAfterEach"), y = /* @__PURE__ */ n((w) => w.originalStoryFn(w.args, w), "undecoratedStoryFn"), { applyDecorators: u = He, runStep: h } = r, T = [ ...b(e?.decorators), ...b(t?.decorators), ...b(r?.decorators) ], R = e?.userStoryFn || e?.render || t.render || r.render, P = Et(u)(y, T), L = /* @__PURE__ */ n((w) => P(w), "unboundStoryFn"), O = e?. play ?? t?.play, F = Ot(O); if (!R && !F) throw new uo({ id: i }); let A = /* @__PURE__ */ n((w) => async () => (await w.renderToCanvas(), w.canvas), "defaultMount"), S = e.mount ?? t.mount ?? r.mount ?? A, v = r.testingLibraryRender; return { storyGlobals: {}, ...a, moduleExport: o, id: i, name: s, story: s, originalStoryFn: R, undecoratedStoryFn: y, unboundStoryFn: L, applyLoaders: p, applyBeforeEach: c, applyAfterEach: l, playFunction: O, runStep: h, mount: S, testingLibraryRender: v, renderToCanvas: r.renderToCanvas, usesMount: F }; } n(Ne, "prepareStory"); function go(e, t, r) { let o = ["dev", "test"], i = yo.DOCS_OPTIONS?.autodocs === !0 ? ["autodocs"] : [], s = co( ...o, ...i, ...r.tags ?? [], ...t.tags ?? [], ...e?.tags ?? [] ), a = D( r.parameters, t.parameters, e?.parameters ), { argTypesEnhancers: p = [], argsEnhancers: c = [] } = r, l = D( r.argTypes, t.argTypes, e?.argTypes ); if (e) { let O = e?.userStoryFn || e?.render || t.render || r.render; a.__isArgsStory = O && O.length > 0; } let y = { ...r.args, ...t.args, ...e?.args }, u = { ...t.globals, ...e?.globals }, h = { componentId: t.id, title: t.title, kind: t.title, // Back compat id: e?.id || t.id, // if there's no story name, we create a fake one since enhancers expect a name name: e?.name || "__meta", story: e?.name || "__meta", // Back compat component: t.component, subcomponents: t.subcomponents, tags: s, parameters: a, initialArgs: y, argTypes: l, storyGlobals: u }; h.argTypes = p.reduce( (O, F) => F({ ...h, argTypes: O }), h.argTypes ); let T = { ...y }; h.initialArgs = [...c].reduce( (O, F) => ({ ...O, ...F({ ...h, initialArgs: O }) }), T ); let { name: R, story: P, ...L } = h; return L; } n(go, "preparePartialAnnotations"); function Ft(e) { let { args: t } = e, r = { ...e, allArgs: void 0, argsByTarget: void 0 }; if (fo.FEATURES?.argTypeTargetsV7) { let s = Ct(e); r = { ...e, allArgs: e.args, argsByTarget: s, args: s[De] || {} }; } let o = Object.entries(r.args).reduce((s, [a, p]) => { if (!r.argTypes[a]?.mapping) return s[a] = p, s; let c = /* @__PURE__ */ n((l) => { let y = r.argTypes[a].mapping; return y && l in y ? y[l] : l; }, "mappingFn"); return s[a] = Array.isArray(p) ? p.map(c) : c(p), s; }, {}), i = Object.entries(o).reduce((s, [a, p]) => { let c = r.argTypes[a] || {}; return mo(c, o, r.globals) && (s[a] = p), s; }, {}); return { ...r, unmappedArgs: t, args: i }; } n(Ft, "prepareContext"); // src/preview-api/modules/store/inferArgTypes.ts import { logger as ho } from "storybook/internal/client-logger"; var je = /* @__PURE__ */ n((e, t, r) => { let o = typeof e; switch (o) { case "boolean": case "string": case "number": case "function": case "symbol": return { name: o }; default: break; } return e ? r.has(e) ? (ho.warn(W` We've detected a cycle in arg '${t}'. Args should be JSON-serializable. Consider using the mapping feature or fully custom args: - Mapping: https://storybook.js.org/docs/writing-stories/args#mapping-to-complex-arg-values - Custom args: https://storybook.js.org/docs/essentials/controls#fully-custom-args `), { name: "other", value: "cyclic object" }) : (r.add(e), Array.isArray(e) ? { name: "array", value: e.length > 0 ? je(e[0], t, new Set( r)) : { name: "other", value: "unknown" } } : { name: "object", value: U(e, (s) => je(s, t, new Set(r))) }) : { name: "object", value: {} }; }, "inferType"), Be = /* @__PURE__ */ n((e) => { let { id: t, argTypes: r = {}, initialArgs: o = {} } = e, i = U(o, (a, p) => ({ name: p, type: je(a, `${t}.${p}`, /* @__PURE__ */ new Set()) })), s = U(r, (a, p) => ({ name: p })); return D(i, s, r); }, "inferArgTypes"); Be.secondPass = !0; // src/preview-api/modules/store/inferControls.ts import { logger as xo } from "storybook/internal/client-logger"; // src/preview-api/modules/store/filterArgTypes.ts var It = /* @__PURE__ */ n((e, t) => Array.isArray(t) ? t.includes(e) : e.match(t), "matches"), ze = /* @__PURE__ */ n((e, t, r) => !t && !r ? e : e && Le(e, (o, i) => { let s = o.name || i.toString(); return !!(!t || It(s, t)) && (!r || !It(s, r)); }), "filterArgTypes"); // src/preview-api/modules/store/inferControls.ts var bo = /* @__PURE__ */ n((e, t, r) => { let { type: o, options: i } = e; if (o) { if (r.color && r.color.test(t)) { let s = o.name; if (s === "string") return { control: { type: "color" } }; s !== "enum" && xo.warn( `Addon controls: Control of type color only supports string, received "${s}" instead` ); } if (r.date && r.date.test(t)) return { control: { type: "date" } }; switch (o.name) { case "array": return { control: { type: "object" } }; case "boolean": return { control: { type: "boolean" } }; case "string": return { control: { type: "text" } }; case "number": return { control: { type: "number" } }; case "enum": { let { value: s } = o; return { control: { type: s?.length <= 5 ? "radio" : "select" }, options: s }; } case "function": case "symbol": return null; default: return { control: { type: i ? "select" : "object" } }; } } }, "inferControl"), me = /* @__PURE__ */ n((e) => { let { argTypes: t, parameters: { __isArgsStory: r, controls: { include: o = null, exclude: i = null, matchers: s = {} } = {} } } = e; if (!r) return t; let a = ze(t, o, i), p = U(a, (c, l) => c?.type && bo(c, l.toString(), s)); return D(p, a); }, "inferControls"); me.secondPass = !0; // src/preview-api/modules/store/csf/normalizeProjectAnnotations.ts function te({ argTypes: e, globalTypes: t, argTypesEnhancers: r, decorators: o, loaders: i, beforeEach: s, afterEach: a, initialGlobals: p, ...c }) { return { ...e && { argTypes: K(e) }, ...t && { globalTypes: K(t) }, decorators: b(o), loaders: b(i), beforeEach: b(s), afterEach: b(a), argTypesEnhancers: [ ...r || [], Be, // There's an architectural decision to be made regarding embedded addons in core: // // Option 1: Keep embedded addons but ensure consistency by moving addon-specific code // (like inferControls) to live alongside the addon code itself. This maintains the // concept of core addons while improving code organization. // // Option 2: Fully integrate these addons into core, potentially moving UI components // into the manager and treating them as core features rather than addons. This is a // bigger architectural change requiring careful consideration. // // For now, we're keeping inferControls here as we need time to properly evaluate // these options and their implications. Some features (like Angular's cleanArgsDecorator) // currently rely on this behavior. // // TODO: Make an architectural decision on the handling of core addons me ], initialGlobals: p, ...c }; } n(te, "normalizeProjectAnnotations"); // src/preview-api/modules/store/csf/composeConfigs.ts import { global as To } from "@storybook/global"; // src/preview-api/modules/store/csf/beforeAll.ts var Lt = /* @__PURE__ */ n((e) => async () => { let t = []; for (let r of e) { let o = await r(); o && t.unshift(o); } return async () => { for (let r of t) await r(); }; }, "composeBeforeAllHooks"); // src/preview-api/modules/store/csf/stepRunners.ts function Ue(e) { return async (t, r, o) => { await e.reduceRight( (s, a) => async () => a(t, s, o), async () => r(o) )(); }; } n(Ue, "composeStepRunners"); // src/preview-api/modules/store/csf/composeConfigs.ts function oe(e, t) { return e.map((r) => r.default?.[t] ?? r[t]).filter(Boolean); } n(oe, "getField"); function Y(e, t, r = {}) { return oe(e, t).reduce((o, i) => { let s = b(i); return r.reverseFileOrder ? [...s, ...o] : [...o, ...s]; }, []); } n(Y, "getArrayField"); function ue(e, t) { return Object.assign({}, ...oe(e, t)); } n(ue, "getObjectField"); function re(e, t) { return oe(e, t).pop(); } n(re, "getSingletonField"); function ne(e) { let t = Y(e, "argTypesEnhancers"), r = oe(e, "runStep"), o = Y(e, "beforeAll"); return { parameters: D(...oe(e, "parameters")), decorators: Y(e, "decorators", { reverseFileOrder: !(To.FEATURES?.legacyDecoratorFileOrder ?? !1) }), args: ue(e, "args"), argsEnhancers: Y(e, "argsEnhancers"), argTypes: ue(e, "argTypes"), argTypesEnhancers: [ ...t.filter((i) => !i.secondPass), ...t.filter((i) => i.secondPass) ], initialGlobals: ue(e, "initialGlobals"), globalTypes: ue(e, "globalTypes"), loaders: Y(e, "loaders"), beforeAll: Lt(o), beforeEach: Y(e, "beforeEach"), afterEach: Y(e, "afterEach"), render: re(e, "render"), renderToCanvas: re(e, "renderToCanvas"), applyDecorators: re(e, "applyDecorators"), runStep: Ue(r), tags: Y(e, "tags"), mount: re(e, "mount"), testingLibraryRender: re(e, "testingLibraryRender") }; } n(ne, "composeConfigs"); // src/preview-api/modules/store/csf/portable-stories.ts import { isExportStory as Zs } from "storybook/internal/csf"; import { getCoreAnnotations as Qs } from "storybook/internal/csf"; import { MountMustBeDestructuredError as Ao } from "storybook/internal/preview-errors"; // src/preview-api/modules/preview-web/render/animation-utils.ts function Dt() { try { return ( // @ts-expect-error This property exists in Vitest browser mode !!globalThis.__vitest_browser__ || !!globalThis.window?.navigator?.userAgent?.match(/StorybookTestRunner/) ); } catch { return !1; } } n(Dt, "isTestEnvironment"); function _t(e = !0) { if (!("document" in globalThis && "createElement" in globalThis.document)) return () => { }; let t = document.createElement("style"); t.textContent = `*, *:before, *:after { animation: none !important; }`, document.head.appendChild(t); let r = document.createElement("style"); return r.textContent = `*, *:before, *:after { animation-delay: 0s !important; animation-direction: ${e ? "reverse" : "normal"} !important; animation-play-state: paused !important; transition: none !important; }`, document.head.appendChild(r), document.body.clientHeight, document.head.removeChild(t), () => { r.parentNode?.removeChild(r); }; } n(_t, "pauseAnimations"); async function Ht(e) { if (!("document" in globalThis && "getAnimations" in globalThis.document && "querySelectorAll" in globalThis.document)) return; let t = !1; await Promise.race([ // After 50ms, retrieve any running animations and wait for them to finish // If new animations are created while waiting, we'll wait for them too new Promise((r) => { setTimeout(() => { let o = [globalThis.document, ...Nt(globalThis.document)], i = /* @__PURE__ */ n(async () => { if (t || e?.aborted) return; let s = o.flatMap((a) => a?.getAnimations?.() || []).filter((a) => a.playState === "running" && !So(a)); s.length > 0 && (await Promise.all(s.map((a) => a.finished)), await i()); }, "checkAnimationsFinished"); i().then(r); }, 100); }), // If animations don't finish within the timeout, continue without waiting new Promise( (r) => setTimeout(() => { t = !0, r(void 0); }, 5e3) ) ]); } n(Ht, "waitForAnimations"); function Nt(e) { return [e, ...e.querySelectorAll("*")].reduce((t, r) => ("shadowRoot" in r && r.shadowRoot && t.push(r.shadowRoot, ...Nt(r.shadowRoot)), t), []); } n(Nt, "getShadowRoots"); function So(e) { if (e instanceof CSSAnimation && e.effect instanceof KeyframeEffect && e.effect.target) { let t = getComputedStyle(e.effect.target, e.effect.pseudoElement), r = t.animationName?.split(", ").indexOf(e.animationName); return t.animationIterationCount.split(", ")[r] === "infinite"; } return !1; } n(So, "isInfiniteAnimation"); // src/preview-api/modules/store/reporter-api.ts var Ge = class Ge { constructor() { this.reports = []; } async addReport(t) { this.reports.push(t); } }; n(Ge, "ReporterAPI"); var fe = Ge; // src/preview-api/modules/store/csf/portable-stories.ts var Ro = "ComposedStory", wo = "Unnamed Story"; var V = []; function We(e, t, r, o, i) { if (e === void 0) throw new Error("Expected a story but received undefined."); t.title = t.title ?? Ro; let s = kt(t), a = i || e.storyName || e.story?.name || e.name || wo, p = _e( a, e, s ), c = te( ne([ o ?? globalThis.globalProjectAnnotations ?? {}, r ?? {} ]) ), l = Ne( p, s, c ), u = { ...vt(c.globalTypes), ...c.initialGlobals, ...l.storyGlobals }, h = new fe(), T = /* @__PURE__ */ n(() => { let A = Ft({ hooks: new de(), globals: u, args: { ...l.initialArgs }, viewMode: "story", reporting: h, loaded: {}, abortSignal: new AbortController().signal, step: /* @__PURE__ */ n((S, v) => l.runStep(S, v, A), "step"), canvasElement: null, canvas: {}, userEvent: {}, globalTypes: c.globalTypes, ...l, context: null, mount: null }); return A.parameters.__isPortableStory = !0, A.context = A, l.renderToCanvas && (A.renderToCanvas = async () => { let S = await l.renderToCanvas?.( { componentId: l.componentId, title: l.title, id: l.id, name: l.name, tags: l.tags, showMain: /* @__PURE__ */ n(() => { }, "showMain"), showError: /* @__PURE__ */ n((v) => { throw new Error(`${v.title} ${v.description}`); }, "showError"), showException: /* @__PURE__ */ n((v) => { throw v; }, "showException"), forceRemount: !0, storyContext: A, storyFn: /* @__PURE__ */ n(() => l.unboundStoryFn(A), "storyFn"), unboundStoryFn: l.unboundStoryFn }, A.canvasElement ); S && V.push(S); }), A.mount = l.mount(A), A; }, "initializeContext"), R, P = /* @__PURE__ */ n(async (A) => { let S = T(); return S.canvasElement ??= globalThis?.document?.body, R && (S.loaded = R.loaded), Object.assign(S, A), l.playFunction(S); }, "play"), L = /* @__PURE__ */ n((A) => { let S = T(); return Object.assign(S, A), Eo(l, S); }, "run"), O = l.playFunction ? P : void 0; return Object.assign( /* @__PURE__ */ n(function(S) { let v = T(); return R && (v.loaded = R.loaded), v.args = { ...v.initialArgs, ...S }, l.unboundStoryFn(v); }, "storyFn"), { id: l.id, storyName: a, load: /* @__PURE__ */ n(async () => { for (let S of [...V].reverse()) await S(); V.length = 0; let A = T(); A.loaded = await l.applyLoaders(A), V.push(...(await l.applyBeforeEach(A)).filter(Boolean)), R = A; }, "load"), globals: u, args: l.initialArgs, parameters: l.parameters, argTypes: l.argTypes, play: O, run: L, reporting: h, tags: l.tags } ); } n(We, "composeStory"); async function Eo(e, t) { for (let s of [...V].reverse()) await s(); if (V.length = 0, !t.canvasElement) { let s = document.createElement("div"); globalThis?.document?.body?.appendChild(s), t.canvasElement = s, V.push(() => { globalThis?.document?.body?.contains(s) && globalThis?.document?.body?.removeChild(s); }); } if (t.loaded = await e.applyLoaders(t), t.abortSignal.aborted) return; V.push(...(await e.applyBeforeEach(t)).filter(Boolean)); let r = e.playFunction, o = e.usesMount; if (o || await t.mount(), t.abortSignal.aborted) return; r && (o || (t.mount = async () => { throw new Ao({ playFunction: r.toString() }); }), await r(t)); let i; Dt() ? i = _t() : await Ht(t.abortSignal), await e.applyAfterEach(t), await i?.(); } n(Eo, "runStory"); // ../node_modules/tiny-invariant/dist/esm/tiny-invariant.js var Co = !1, Ye = "Invariant failed"; function ye(e, t) { if (!e) { if (Co) throw new Error(Ye); var r = typeof t == "function" ? t() : t, o = r ? "".concat(Ye, ": ").concat(r) : Ye; throw new Error(o); } } n(ye, "invariant"); // src/actions/preview.ts import { definePreviewAddon as Lo } from "storybook/internal/csf"; // src/actions/addArgs.ts var Ke = {}; xt(Ke, { argsEnhancers: () => Mo }); // src/actions/runtime/action.ts import { ImplicitActionsDuringRendering as vo } from "storybook/internal/preview-errors"; import { global as zt } from "@storybook/global"; import { addons as ko } from "storybook/preview-api"; // src/actions/constants.ts var Ve = "storybook/actions", Ia = `${Ve}/panel`, jt = `${Ve}/action-event`, La = `${Ve}/action-clear`; // src/actions/runtime/configureActions.ts var Bt = { depth: 10, clearOnStoryChange: !0, limit: 50 }; // src/actions/runtime/action.ts var Ut = /* @__PURE__ */ n((e, t) => { let r = Object.getPrototypeOf(e); return !r || t(r) ? r : Ut(r, t); }, "findProto"), Po = /* @__PURE__ */ n((e) => !!(typeof e == "object" && e && Ut(e, (t) => /^Synthetic(?:Base)?Event$/.test(t.constructor.name)) && typeof e.persist == "function"), "isReactSyntheticEvent"), Oo = /* @__PURE__ */ n((e) => { if (Po(e)) { let t = Object.create( e.constructor.prototype, Object.getOwnPropertyDescriptors(e) ); t.persist(); let r = Object.getOwnPropertyDescriptor(t, "view"), o = r?.value; return typeof o == "object" && o?.constructor.name === "Window" && Object.defineProperty(t, "view", { ...r, value: Object.create(o.constructor.prototype) }), t; } return e; }, "serializeArg"); function ie(e, t = {}) { let r = { ...Bt, ...t }, o = /* @__PURE__ */ n(function(...s) { if (t.implicit) { let T = ("__STORYBOOK_PREVIEW__" in zt ? zt.__STORYBOOK_PREVIEW__ : void 0)?.storyRenders.find( (R) => R.phase === "playing" || R.phase === "rendering" ); if (T) { let R = !globalThis?.FEATURES?.disallowImplicitActionsInRenderV8, P = new vo({ phase: T.phase, name: e, deprecated: R }); if (R) console.warn(P); else throw P; } } let a = ko.getChannel(), p = Date.now().toString(36) + Math.random().toString(36).substring(2), c = 5, l = s.map(Oo), y = s.length > 1 ? l : l[0], u = { id: p, count: 0, data: { name: e, args: y }, options: { ...r, maxDepth: c + (r.depth || 3) } }; a.emit(jt, u); }, "actionHandler"); return o.isAction = !0, o.implicit = t.implicit, o; } n(ie, "action"); // src/actions/addArgsHelpers.ts var Gt = /* @__PURE__ */ n((e, t) => typeof t[e] > "u" && !(e in t), "isInInitialArgs"), Wt = /* @__PURE__ */ n((e) => { let { initialArgs: t, argTypes: r, id: o, parameters: { actions: i } } = e; if (!i || i.disable || !i.argTypesRegex || !r) return {}; let s = new RegExp(i.argTypesRegex); return Object.entries(r).filter( ([p]) => !!s.test(p) ).reduce((p, [c, l]) => (Gt(c, t) && (p[c] = ie(c, { implicit: !0, id: o })), p), {}); }, "inferActionsFromArgTypesRegex"), Yt = /* @__PURE__ */ n((e) => { let { initialArgs: t, argTypes: r, parameters: { actions: o } } = e; return o?.disable || !r ? {} : Object.entries(r).filter(([s, a]) => !!a.action).reduce((s, [a, p]) => (Gt(a, t) && (s[a] = ie(typeof p.action == "string" ? p.action : a)), s), {}); }, "addActionsFromArgTypes"); // src/actions/addArgs.ts var Mo = [ Yt, Wt ]; // src/actions/loaders.ts var qe = {}; xt(qe, { loaders: () => Io }); import { onMockCall as $o } from "storybook/test"; var Vt = !1, Fo = /* @__PURE__ */ n((e) => { let { parameters: t } = e; t?.actions?.disable || Vt || ($o((r, o) => { let i = r.getMockName(); i !== "spy" && (!/^next\/.*::/.test(i) || [ "next/router::useRouter()", "next/navigation::useRouter()", "next/navigation::redirect", "next/cache::", "next/headers::cookies().set", "next/headers::cookies().delete", "next/headers::headers().set", "next/headers::headers().delete" ].some((s) => i.startsWith(s))) && ie(i)(o); }), Vt = !0); }, "logActionsWhenMockCalled"), Io = [Fo]; // src/actions/preview.ts var Xe = /* @__PURE__ */ n(() => Lo({ ...Ke, ...qe }), "default"); // src/backgrounds/preview.ts import { definePreviewAddon as jo } from "storybook/internal/csf"; // src/backgrounds/constants.ts var Do = "storybook/background", Z = "backgrounds"; var rp = { UPDATE: `${Do}/update` }; // src/backgrounds/decorator.ts import { useEffect as Jt } from "storybook/preview-api"; // src/backgrounds/defaults.ts var Kt = { light: { name: "light", value: "#F8F8F8" }, dark: { name: "dark", value: "#333" } }; // src/backgrounds/utils.ts var { document: N } = globalThis, qt = /* @__PURE__ */ n(() => globalThis?.matchMedia ? !!globalThis.matchMedia("(prefers-reduced-motion: re\ duce)")?.matches : !1, "isReduceMotionEnabled"), Ze = /* @__PURE__ */ n((e) => { (Array.isArray(e) ? e : [e]).forEach(_o); }, "clearStyles"), _o = /* @__PURE__ */ n((e) => { if (!N) return; let t = N.getElementById(e); t && t.parentElement && t.parentElement.removeChild(t); }, "clearStyle"), Xt = /* @__PURE__ */ n((e, t) => { if (!N) return; let r = N.getElementById(e); if (r) r.innerHTML !== t && (r.innerHTML = t); else { let o = N.createElement("style"); o.setAttribute("id", e), o.innerHTML = t, N.head.appendChild(o); } }, "addGridStyle"), Zt = /* @__PURE__ */ n((e, t, r) => { if (!N) return; let o = N.getElementById(e); if (o) o.innerHTML !== t && (o.innerHTML = t); else { let i = N.createElement("style"); i.setAttribute("id", e), i.innerHTML = t; let s = `addon-backgrounds-grid${r ? `-docs-${r}` : ""}`, a = N.getElementById(s); a ? a.parentElement?.insertBefore(i, a) : N.head.appendChild(i); } }, "addBackgroundStyle"); // src/backgrounds/decorator.ts var Ho = { cellSize: 100, cellAmount: 10, opacity: 0.8 }, Qt = "addon-backgrounds", er = "addon-backgrounds-grid", No = qt() ? "" : "transition: background-color 0.3s;", tr = /* @__PURE__ */ n((e, t) => { let { globals: r = {}, parameters: o = {}, viewMode: i, id: s } = t, { options: a = Kt, disable: p, grid: c = Ho } = o[Z] || {}, l = r[Z] || {}, y = typeof l == "string" ? l : l?.value, u = y ? a[y] : void 0, h = typeof u == "string" ? u : u?.value || "transparent", T = typeof l == "string" ? !1 : l.grid || !1, R = !!u && !p, P = i === "docs" ? `#anchor--${s} .docs-story` : ".sb-show-mai\ n", L = i === "docs" ? `#anchor--${s} .docs-story` : ".sb-show-main", O = o.layout === void 0 || o.layout === "padded", F = i === "docs" ? 20 : O ? 16 : 0, { cellAmount: A, cellSize: S, opacity: v, offsetX: w = F, offsetY: d = F } = c, m = i === "docs" ? `${Qt}-docs-${s}` : `${Qt}-\ color`, f = i === "docs" ? s : null; Jt(() => { let g = ` ${P} { background: ${h} !important; ${No} }`; if (!R) { Ze(m); return; } Zt(m, g, f); }, [P, m, f, R, h]); let x = i === "docs" ? `${er}-docs-${s}` : `${er}`; return Jt(() => { if (!T) { Ze(x); return; } let g = [ `${S * A}px ${S * A}px`, `${S * A}px ${S * A}px`, `${S}px ${S}px`, `${S}px ${S}px` ].join(", "), E = ` ${L} { background-size: ${g} !important; background-position: ${w}px ${d}px, ${w}px ${d}px, ${w}px ${d}px, ${w}px ${d}px !important; background-blend-mode: difference !important; background-image: linear-gradient(rgba(130, 130, 130, ${v}) 1px, transparent 1px), linear-gradient(90deg, rgba(130, 130, 130, ${v}) 1px, transparent 1px), linear-gradient(rgba(130, 130, 130, ${v / 2}) 1px, transparent 1px), linear-gradient(90deg, rgba(130, 130, 130, ${v / 2}) 1px, transparent 1px) !important; } `; Xt(x, E); }, [A, S, L, x, T, w, d, v]), e(); }, "withBackgroundAndGrid"); // src/backgrounds/preview.ts var Bo = globalThis.FEATURES?.backgrounds ? [tr] : [], zo = { [Z]: { grid: { cellSize: 20, opacity: 0.5, cellAmount: 5 }, disable: !1 } }, Uo = { [Z]: { value: void 0, grid: !1 } }, Je = /* @__PURE__ */ n(() => jo({ decorators: Bo, parameters: zo, initialGlobals: Uo }), "default"); // src/component-testing/preview.ts import { definePreviewAddon as Go } from "storybook/internal/csf"; import { instrument as Wo } from "storybook/internal/instrumenter"; var { step: Yo } = Wo( { // It seems like the label is unused, but the instrumenter has access to it // The context will be bounded later in StoryRender, so that the user can write just: // await step("label", (context) => { // // labeled step // }); step: /* @__PURE__ */ n(async (e, t, r) => t(r), "step") }, { intercept: !0 } ), Qe = /* @__PURE__ */ n(() => Go({ parameters: { throwPlayFunctionExceptions: !1 }, runStep: Yo }), "default"); // src/highlight/preview.ts import { definePreviewAddon as Zo } from "storybook/internal/csf"; import { addons as ur } from "storybook/preview-api"; // src/highlight/useHighlights.ts import { STORY_RENDER_PHASE_CHANGED as qo } from "storybook/internal/core-events"; // src/highlight/constants.ts var ge = "storybook/highlight", rr = `${ge}/add`, or = `${ge}/remove`, nr = `${ge}/reset`, ir = `${ge}/scroll-into-view`, et = 2147483647, B = 28; // src/highlight/icons.ts var tt = { chevronLeft: [ "M9.10355 10.1464C9.29882 10.3417 9.29882 10.6583 9.10355 10.8536C8.90829 11.0488 8.59171 11.0488 8.39645 10.8536L4.89645 7.35355C4.7011\ 8 7.15829 4.70118 6.84171 4.89645 6.64645L8.39645 3.14645C8.59171 2.95118 8.90829 2.95118 9.10355 3.14645C9.29882 3.34171 9.29882 3.65829 9.\ 10355 3.85355L5.95711 7L9.10355 10.1464Z" ], chevronRight: [ "M4.89645 10.1464C4.70118 10.3417 4.70118 10.6583 4.89645 10.8536C5.09171 11.0488 5.40829 11.0488 5.60355 10.8536L9.10355 7.35355C9.2988\ 2 7.15829 9.29882 6.84171 9.10355 6.64645L5.60355 3.14645C5.40829 2.95118 5.09171 2.95118 4.89645 3.14645C4.70118 3.34171 4.70118 3.65829 4.\ 89645 3.85355L8.04289 7L4.89645 10.1464Z" ], info: [ "M7 5.5a.5.5 0 01.5.5v4a.5.5 0 01-1 0V6a.5.5 0 01.5-.5zM7 4.5A.75.75 0 107 3a.75.75 0 000 1.5z", "M7 14A7 7 0 107 0a7 7 0 000 14zm0-1A6 6 0 107 1a6 6 0 000 12z" ], shareAlt: [ "M2 1.004a1 1 0 00-1 1v10a1 1 0 001 1h10a1 1 0 001-1v-4.5a.5.5 0 00-1 0v4.5H2v-10h4.5a.5.5 0 000-1H2z", "M7.354 7.357L12 2.711v1.793a.5.5 0 001 0v-3a.5.5 0 00-.5-.5h-3a.5.5 0 100 1h1.793L6.646 6.65a.5.5 0 10.708.707z" ] }; // src/highlight/utils.ts var Vo = "svg,path,rect,circle,line,polyline,polygon,ellipse,text".split(","), M = /* @__PURE__ */ n((e, t = {}, r) => { let o = Vo.includes(e) ? document.createElementNS("http://www.w3.org/2000/svg", e) : document.createElement(e); return Object.entries(t).forEach(([i, s]) => { /[A-Z]/.test(i) ? (i === "onClick" && (o.addEventListener("click", s), o.addEventListener("keydown", (a) => { (a.key === "Enter" || a.key === " ") && (a.preventDefault(), s()); })), i === "onMouseEnter" && o.addEventListener("mouseenter", s), i === "onMouseLeave" && o.addEventListener("mouseleave", s)) : o.setAttribute( i, s); }), r?.forEach((i) => { if (!(i == null || i === !1)) try { o.appendChild(i); } catch { o.appendChild(document.createTextNode(String(i))); } }), o; }, "createElement"), ae = /* @__PURE__ */ n((e) => tt[e] && M( "svg", { width: "14", height: "14", viewBox: "0 0 14 14", xmlns: "http://www.w3.org/2000/svg" }, tt[e].map( (t) => M("path", { fill: "currentColor", "fill-rule": "evenodd", "clip-rule": "evenodd", d: t }) ) ), "createIcon"), sr = /* @__PURE__ */ n((e) => { if ("elements" in e) { let { elements: o, color: i, style: s } = e; return { id: void 0, priority: 0, selectors: o, styles: { outline: `2px ${s} ${i}`, outlineOffset: "2px", boxShadow: "0 0 0 6px rgba(255,255,255,0.6)" }, menu: void 0 }; } let { menu: t, ...r } = e; return { id: void 0, priority: 0, styles: { outline: "2px dashed #029cfd" }, ...r, menu: Array.isArray(t) ? t.every(Array.isArray) ? t : [t] : void 0 }; }, "normalizeOptions"), Ko = /* @__PURE__ */ n((e) => e instanceof Function, "isFunction"), se = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), he = /* @__PURE__ */ new Map(), z = /* @__PURE__ */ n((e) => { let t = Symbol(); return q.set(t, []), se.set(t, e), { get: /* @__PURE__ */ n(() => se.get(t), "get"), set: /* @__PURE__ */ n((a) => { let p = se.get(t), c = Ko(a) ? a(p) : a; c !== p && (se.set(t, c), q.get(t)?.forEach((l) => { he.get(l)?.(), he.set(l, l(c)); })); }, "set"), subscribe: /* @__PURE__ */ n((a) => (q.get(t)?.push(a), () => { let p = q.get(t); p && q.set( t, p.filter((c) => c !== a) ); }), "subscribe"), teardown: /* @__PURE__ */ n(() => { q.get(t)?.forEach((a) => { he.get(a)?.(), he.delete(a); }), q.delete(t), se.delete(t); }, "teardown") }; }, "useStore"), rt = /* @__PURE__ */ n((e) => { let t = document.getElementById("storybook-root"), r = /* @__PURE__ */ new Map(); for (let o of e) { let { priority: i = 0 } = o; for (let s of o.selectors) { let a = [ ...document.querySelectorAll( // Elements matching the selector, excluding storybook elements and their descendants. // Necessary to find portaled elements (e.g. children of `body`). `:is(${s}):not([id^="storybook-"], [id^="storybook-"] *, [class^="sb-"], [class^="sb-"] *)` ), // Elements matching the selector inside the storybook root, as these were excluded above. ...t?.querySelectorAll(s) || [] ]; for (let p of a) { let c = r.get(p); (!c || c.priority <= i) && r.set(p, { ...o, priority: i, selectors: Array.from(new Set((c?.selectors || []).concat(s))) }); } } } return r; }, "mapElements"), ar = /*