var fr = Object.create;
var Re = Object.defineProperty;
var dr = Object.getOwnPropertyDescriptor;
var Tr = Object.getOwnPropertyNames;
var gr = Object.getPrototypeOf, hr = Object.prototype.hasOwnProperty;
var r = (n, s) => Re(n, "name", { value: s, configurable: !0 });
var xr = (n, s) => () => (s || n((s = { exports: {} }).exports, s), s.exports);
var Jr = (n, s, a, p) => {
  if (s && typeof s == "object" || typeof s == "function")
    for (let c of Tr(s))
      !hr.call(n, c) && c !== a && Re(n, c, { get: () => s[c], enumerable: !(p = dr(s, c)) || p.enumerable });
  return n;
};
var wr = (n, s, a) => (a = n != null ? fr(gr(n)) : {}, Jr(
  // 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.
  s || !n || !n.__esModule ? Re(a, "default", { value: n, enumerable: !0 }) : a,
  n
));

// ../node_modules/jsdoc-type-pratt-parser/dist/index.js
var dt = xr((ye, ft) => {
  (function(n, s) {
    typeof ye == "object" && typeof ft < "u" ? s(ye) : typeof define == "function" && define.amd ? define(["exports"], s) : (n = typeof globalThis <
    "u" ? globalThis : n || self, s(n.jtpp = {}));
  })(ye, function(n) {
    "use strict";
    function s(e) {
      return e.text !== void 0 && e.text !== "" ? `'${e.type}' with value '${e.text}'` : `'${e.type}'`;
    }
    r(s, "tokenToString");
    let ne = class ne extends Error {
      constructor(t) {
        super(`No parslet found for token: ${s(t)}`), this.token = t, Object.setPrototypeOf(this, ne.prototype);
      }
      getToken() {
        return this.token;
      }
    };
    r(ne, "NoParsletFoundError");
    let a = ne, oe = class oe extends Error {
      constructor(t) {
        super(`The parsing ended early. The next token was: ${s(t)}`), this.token = t, Object.setPrototypeOf(this, oe.prototype);
      }
      getToken() {
        return this.token;
      }
    };
    r(oe, "EarlyEndOfParseError");
    let p = oe, se = class se extends Error {
      constructor(t, o) {
        let i = `Unexpected type: '${t.type}'.`;
        o !== void 0 && (i += ` Message: ${o}`), super(i), Object.setPrototypeOf(this, se.prototype);
      }
    };
    r(se, "UnexpectedTypeError");
    let c = se;
    function u(e) {
      return (t) => t.startsWith(e) ? { type: e, text: e } : null;
    }
    r(u, "makePunctuationRule");
    function m(e) {
      let t = 0, o, i = e[0], l = !1;
      if (i !== "'" && i !== '"')
        return null;
      for (; t < e.length; ) {
        if (t++, o = e[t], !l && o === i) {
          t++;
          break;
        }
        l = !l && o === "\\";
      }
      if (o !== i)
        throw new Error("Unterminated String");
      return e.slice(0, t);
    }
    r(m, "getQuoted");
    let T = /[$_\p{ID_Start}]|\\u\p{Hex_Digit}{4}|\\u\{0*(?:\p{Hex_Digit}{1,5}|10\p{Hex_Digit}{4})\}/u, g = /[$\-\p{ID_Continue}\u200C\u200D]|\\u\p{Hex_Digit}{4}|\\u\{0*(?:\p{Hex_Digit}{1,5}|10\p{Hex_Digit}{4})\}/u;
    function P(e) {
      let t = e[0];
      if (!T.test(t))
        return null;
      let o = 1;
      do {
        if (t = e[o], !g.test(t))
          break;
        o++;
      } while (o < e.length);
      return e.slice(0, o);
    }
    r(P, "getIdentifier");
    let b = /^(NaN|-?((\d*\.\d+|\d+)([Ee][+-]?\d+)?|Infinity))/;
    function de(e) {
      var t, o;
      return (o = (t = b.exec(e)) === null || t === void 0 ? void 0 : t[0]) !== null && o !== void 0 ? o : null;
    }
    r(de, "getNumber");
    let q = /* @__PURE__ */ r((e) => {
      let t = P(e);
      return t == null ? null : {
        type: "Identifier",
        text: t
      };
    }, "identifierRule");
    function E(e) {
      return (t) => {
        if (!t.startsWith(e))
          return null;
        let o = t[e.length];
        return o !== void 0 && g.test(o) ? null : {
          type: e,
          text: e
        };
      };
    }
    r(E, "makeKeyWordRule");
    let X = /* @__PURE__ */ r((e) => {
      let t = m(e);
      return t == null ? null : {
        type: "StringValue",
        text: t
      };
    }, "stringValueRule"), Te = /* @__PURE__ */ r((e) => e.length > 0 ? null : {
      type: "EOF",
      text: ""
    }, "eofRule"), ge = /* @__PURE__ */ r((e) => {
      let t = de(e);
      return t === null ? null : {
        type: "Number",
        text: t
      };
    }, "numberRule"), It = [
      Te,
      u("=>"),
      u("("),
      u(")"),
      u("{"),
      u("}"),
      u("["),
      u("]"),
      u("|"),
      u("&"),
      u("<"),
      u(">"),
      u(","),
      u(";"),
      u("*"),
      u("?"),
      u("!"),
      u("="),
      u(":"),
      u("..."),
      u("."),
      u("#"),
      u("~"),
      u("/"),
      u("@"),
      E("undefined"),
      E("null"),
      E("function"),
      E("this"),
      E("new"),
      E("module"),
      E("event"),
      E("external"),
      E("typeof"),
      E("keyof"),
      E("readonly"),
      E("import"),
      E("is"),
      E("in"),
      ge,
      q,
      X
    ], Ft = /^\s*\n\s*/, U = class U {
      static create(t) {
        let o = this.read(t);
        t = o.text;
        let i = this.read(t);
        return t = i.text, new U(t, void 0, o.token, i.token);
      }
      constructor(t, o, i, l) {
        this.text = "", this.text = t, this.previous = o, this.current = i, this.next = l;
      }
      static read(t, o = !1) {
        o = o || Ft.test(t), t = t.trim();
        for (let i of It) {
          let l = i(t);
          if (l !== null) {
            let y = Object.assign(Object.assign({}, l), { startOfLine: o });
            return t = t.slice(y.text.length), { text: t, token: y };
          }
        }
        throw new Error("Unexpected Token " + t);
      }
      advance() {
        let t = U.read(this.text);
        return new U(t.text, this.current, this.next, t.token);
      }
    };
    r(U, "Lexer");
    let he = U;
    function w(e) {
      if (e === void 0)
        throw new Error("Unexpected undefined");
      if (e.type === "JsdocTypeKeyValue" || e.type === "JsdocTypeParameterList" || e.type === "JsdocTypeProperty" || e.type === "JsdocTypeRe\
adonlyProperty" || e.type === "JsdocTypeObjectField" || e.type === "JsdocTypeJsdocObjectField" || e.type === "JsdocTypeIndexSignature" || e.
      type === "JsdocTypeMappedType")
        throw new c(e);
      return e;
    }
    r(w, "assertRootResult");
    function xe(e) {
      return e.type === "JsdocTypeKeyValue" ? H(e) : w(e);
    }
    r(xe, "assertPlainKeyValueOrRootResult");
    function jt(e) {
      return e.type === "JsdocTypeName" ? e : H(e);
    }
    r(jt, "assertPlainKeyValueOrNameResult");
    function H(e) {
      if (e.type !== "JsdocTypeKeyValue")
        throw new c(e);
      return e;
    }
    r(H, "assertPlainKeyValueResult");
    function Lt(e) {
      var t;
      if (e.type === "JsdocTypeVariadic") {
        if (((t = e.element) === null || t === void 0 ? void 0 : t.type) === "JsdocTypeName")
          return e;
        throw new c(e);
      }
      if (e.type !== "JsdocTypeNumber" && e.type !== "JsdocTypeName")
        throw new c(e);
      return e;
    }
    r(Lt, "assertNumberOrVariadicNameResult");
    function Je(e) {
      return e.type === "JsdocTypeIndexSignature" || e.type === "JsdocTypeMappedType";
    }
    r(Je, "isSquaredProperty");
    var f;
    (function(e) {
      e[e.ALL = 0] = "ALL", e[e.PARAMETER_LIST = 1] = "PARAMETER_LIST", e[e.OBJECT = 2] = "OBJECT", e[e.KEY_VALUE = 3] = "KEY_VALUE", e[e.UNION =
      4] = "UNION", e[e.INTERSECTION = 5] = "INTERSECTION", e[e.PREFIX = 6] = "PREFIX", e[e.INFIX = 7] = "INFIX", e[e.TUPLE = 8] = "TUPLE", e[e.
      SYMBOL = 9] = "SYMBOL", e[e.OPTIONAL = 10] = "OPTIONAL", e[e.NULLABLE = 11] = "NULLABLE", e[e.KEY_OF_TYPE_OF = 12] = "KEY_OF_TYPE_OF",
      e[e.FUNCTION = 13] = "FUNCTION", e[e.ARROW = 14] = "ARROW", e[e.ARRAY_BRACKETS = 15] = "ARRAY_BRACKETS", e[e.GENERIC = 16] = "GENERIC",
      e[e.NAME_PATH = 17] = "NAME_PATH", e[e.PARENTHESIS = 18] = "PARENTHESIS", e[e.SPECIAL_TYPES = 19] = "SPECIAL_TYPES";
    })(f || (f = {}));
    let Ae = class Ae {
      constructor(t, o, i) {
        this.grammar = t, typeof o == "string" ? this._lexer = he.create(o) : this._lexer = o, this.baseParser = i;
      }
      get lexer() {
        return this._lexer;
      }
      /**
       * Parses a given string and throws an error if the parse ended before the end of the string.
       */
      parse() {
        let t = this.parseType(f.ALL);
        if (this.lexer.current.type !== "EOF")
          throw new p(this.lexer.current);
        return t;
      }
      /**
       * Parses with the current lexer and asserts that the result is a {@link RootResult}.
       */
      parseType(t) {
        return w(this.parseIntermediateType(t));
      }
      /**
       * The main parsing function. First it tries to parse the current state in the prefix step, and then it continues
       * to parse the state in the infix step.
       */
      parseIntermediateType(t) {
        let o = this.tryParslets(null, t);
        if (o === null)
          throw new a(this.lexer.current);
        return this.parseInfixIntermediateType(o, t);
      }
      /**
       * In the infix parsing step the parser continues to parse the current state with all parslets until none returns
       * a result.
       */
      parseInfixIntermediateType(t, o) {
        let i = this.tryParslets(t, o);
        for (; i !== null; )
          t = i, i = this.tryParslets(t, o);
        return t;
      }
      /**
       * Tries to parse the current state with all parslets in the grammar and returns the first non null result.
       */
      tryParslets(t, o) {
        for (let i of this.grammar) {
          let l = i(this, o, t);
          if (l !== null)
            return l;
        }
        return null;
      }
      /**
       * If the given type equals the current type of the {@link Lexer} advance the lexer. Return true if the lexer was
       * advanced.
       */
      consume(t) {
        return Array.isArray(t) || (t = [t]), t.includes(this.lexer.current.type) ? (this._lexer = this.lexer.advance(), !0) : !1;
      }
      acceptLexerState(t) {
        this._lexer = t.lexer;
      }
    };
    r(Ae, "Parser");
    let R = Ae;
    function Ye(e) {
      return e === "EOF" || e === "|" || e === "," || e === ")" || e === ">";
    }
    r(Ye, "isQuestionMarkUnknownType");
    let we = /* @__PURE__ */ r((e, t, o) => {
      let i = e.lexer.current.type, l = e.lexer.next.type;
      return o == null && i === "?" && !Ye(l) || o != null && i === "?" ? (e.consume("?"), o == null ? {
        type: "JsdocTypeNullable",
        element: e.parseType(f.NULLABLE),
        meta: {
          position: "prefix"
        }
      } : {
        type: "JsdocTypeNullable",
        element: w(o),
        meta: {
          position: "suffix"
        }
      }) : null;
    }, "nullableParslet");
    function h(e) {
      let t = /* @__PURE__ */ r((o, i, l) => {
        let y = o.lexer.current.type, d = o.lexer.next.type;
        if (l === null) {
          if ("parsePrefix" in e && e.accept(y, d))
            return e.parsePrefix(o);
        } else if ("parseInfix" in e && e.precedence > i && e.accept(y, d))
          return e.parseInfix(o, l);
        return null;
      }, "parslet");
      return Object.defineProperty(t, "name", {
        value: e.name
      }), t;
    }
    r(h, "composeParslet");
    let Q = h({
      name: "optionalParslet",
      accept: /* @__PURE__ */ r((e) => e === "=", "accept"),
      precedence: f.OPTIONAL,
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("="), {
        type: "JsdocTypeOptional",
        element: e.parseType(f.OPTIONAL),
        meta: {
          position: "prefix"
        }
      }), "parsePrefix"),
      parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("="), {
        type: "JsdocTypeOptional",
        element: w(t),
        meta: {
          position: "suffix"
        }
      }), "parseInfix")
    }), Z = h({
      name: "numberParslet",
      accept: /* @__PURE__ */ r((e) => e === "Number", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        let t = parseFloat(e.lexer.current.text);
        return e.consume("Number"), {
          type: "JsdocTypeNumber",
          value: t
        };
      }, "parsePrefix")
    }), Vt = h({
      name: "parenthesisParslet",
      accept: /* @__PURE__ */ r((e) => e === "(", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        if (e.consume("("), e.consume(")"))
          return {
            type: "JsdocTypeParameterList",
            elements: []
          };
        let t = e.parseIntermediateType(f.ALL);
        if (!e.consume(")"))
          throw new Error("Unterminated parenthesis");
        return t.type === "JsdocTypeParameterList" ? t : t.type === "JsdocTypeKeyValue" ? {
          type: "JsdocTypeParameterList",
          elements: [t]
        } : {
          type: "JsdocTypeParenthesis",
          element: w(t)
        };
      }, "parsePrefix")
    }), _t = h({
      name: "specialTypesParslet",
      accept: /* @__PURE__ */ r((e, t) => e === "?" && Ye(t) || e === "null" || e === "undefined" || e === "*", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        if (e.consume("null"))
          return {
            type: "JsdocTypeNull"
          };
        if (e.consume("undefined"))
          return {
            type: "JsdocTypeUndefined"
          };
        if (e.consume("*"))
          return {
            type: "JsdocTypeAny"
          };
        if (e.consume("?"))
          return {
            type: "JsdocTypeUnknown"
          };
        throw new Error("Unacceptable token: " + e.lexer.current.text);
      }, "parsePrefix")
    }), Ut = h({
      name: "notNullableParslet",
      accept: /* @__PURE__ */ r((e) => e === "!", "accept"),
      precedence: f.NULLABLE,
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("!"), {
        type: "JsdocTypeNotNullable",
        element: e.parseType(f.NULLABLE),
        meta: {
          position: "prefix"
        }
      }), "parsePrefix"),
      parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("!"), {
        type: "JsdocTypeNotNullable",
        element: w(t),
        meta: {
          position: "suffix"
        }
      }), "parseInfix")
    });
    function Bt({ allowTrailingComma: e }) {
      return h({
        name: "parameterListParslet",
        accept: /* @__PURE__ */ r((t) => t === ",", "accept"),
        precedence: f.PARAMETER_LIST,
        parseInfix: /* @__PURE__ */ r((t, o) => {
          let i = [
            xe(o)
          ];
          t.consume(",");
          do
            try {
              let l = t.parseIntermediateType(f.PARAMETER_LIST);
              i.push(xe(l));
            } catch (l) {
              if (e && l instanceof a)
                break;
              throw l;
            }
          while (t.consume(","));
          if (i.length > 0 && i.slice(0, -1).some((l) => l.type === "JsdocTypeVariadic"))
            throw new Error("Only the last parameter may be a rest parameter");
          return {
            type: "JsdocTypeParameterList",
            elements: i
          };
        }, "parseInfix")
      });
    }
    r(Bt, "createParameterListParslet");
    let Ct = h({
      name: "genericParslet",
      accept: /* @__PURE__ */ r((e, t) => e === "<" || e === "." && t === "<", "accept"),
      precedence: f.GENERIC,
      parseInfix: /* @__PURE__ */ r((e, t) => {
        let o = e.consume(".");
        e.consume("<");
        let i = [];
        do
          i.push(e.parseType(f.PARAMETER_LIST));
        while (e.consume(","));
        if (!e.consume(">"))
          throw new Error("Unterminated generic parameter list");
        return {
          type: "JsdocTypeGeneric",
          left: w(t),
          elements: i,
          meta: {
            brackets: "angle",
            dot: o
          }
        };
      }, "parseInfix")
    }), Mt = h({
      name: "unionParslet",
      accept: /* @__PURE__ */ r((e) => e === "|", "accept"),
      precedence: f.UNION,
      parseInfix: /* @__PURE__ */ r((e, t) => {
        e.consume("|");
        let o = [];
        do
          o.push(e.parseType(f.UNION));
        while (e.consume("|"));
        return {
          type: "JsdocTypeUnion",
          elements: [w(t), ...o]
        };
      }, "parseInfix")
    }), Pe = [
      we,
      Q,
      Z,
      Vt,
      _t,
      Ut,
      Bt({
        allowTrailingComma: !0
      }),
      Ct,
      Mt,
      Q
    ];
    function ee({ allowSquareBracketsOnAnyType: e, allowJsdocNamePaths: t, pathGrammar: o }) {
      return /* @__PURE__ */ r(function(l, y, d) {
        if (d == null || y >= f.NAME_PATH)
          return null;
        let x = l.lexer.current.type, N = l.lexer.next.type;
        if (!(x === "." && N !== "<" || x === "[" && (e || d.type === "JsdocTypeName") || t && (x === "~" || x === "#")))
          return null;
        let O, ae = !1;
        l.consume(".") ? O = "property" : l.consume("[") ? (O = "property-brackets", ae = !0) : l.consume("~") ? O = "inner" : (l.consume("#"),
        O = "instance");
        let rt = o !== null ? new R(o, l.lexer, l) : l, k = rt.parseIntermediateType(f.NAME_PATH);
        l.acceptLexerState(rt);
        let G;
        switch (k.type) {
          case "JsdocTypeName":
            G = {
              type: "JsdocTypeProperty",
              value: k.value,
              meta: {
                quote: void 0
              }
            };
            break;
          case "JsdocTypeNumber":
            G = {
              type: "JsdocTypeProperty",
              value: k.value.toString(10),
              meta: {
                quote: void 0
              }
            };
            break;
          case "JsdocTypeStringValue":
            G = {
              type: "JsdocTypeProperty",
              value: k.value,
              meta: {
                quote: k.meta.quote
              }
            };
            break;
          case "JsdocTypeSpecialNamePath":
            if (k.specialType === "event")
              G = k;
            else
              throw new c(k, "Type 'JsdocTypeSpecialNamePath' is only allowed with specialType 'event'");
            break;
          default:
            throw new c(k, "Expecting 'JsdocTypeName', 'JsdocTypeNumber', 'JsdocStringValue' or 'JsdocTypeSpecialNamePath'");
        }
        if (ae && !l.consume("]")) {
          let nt = l.lexer.current;
          throw new Error(`Unterminated square brackets. Next token is '${nt.type}' with text '${nt.text}'`);
        }
        return {
          type: "JsdocTypeNamePath",
          left: w(d),
          right: G,
          pathType: O
        };
      }, "namePathParslet");
    }
    r(ee, "createNamePathParslet");
    function I({ allowedAdditionalTokens: e }) {
      return h({
        name: "nameParslet",
        accept: /* @__PURE__ */ r((t) => t === "Identifier" || t === "this" || t === "new" || e.includes(t), "accept"),
        parsePrefix: /* @__PURE__ */ r((t) => {
          let { type: o, text: i } = t.lexer.current;
          return t.consume(o), {
            type: "JsdocTypeName",
            value: i
          };
        }, "parsePrefix")
      });
    }
    r(I, "createNameParslet");
    let Y = h({
      name: "stringValueParslet",
      accept: /* @__PURE__ */ r((e) => e === "StringValue", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        let t = e.lexer.current.text;
        return e.consume("StringValue"), {
          type: "JsdocTypeStringValue",
          value: t.slice(1, -1),
          meta: {
            quote: t[0] === "'" ? "single" : "double"
          }
        };
      }, "parsePrefix")
    });
    function te({ pathGrammar: e, allowedTypes: t }) {
      return h({
        name: "specialNamePathParslet",
        accept: /* @__PURE__ */ r((o) => t.includes(o), "accept"),
        parsePrefix: /* @__PURE__ */ r((o) => {
          let i = o.lexer.current.type;
          if (o.consume(i), !o.consume(":"))
            return {
              type: "JsdocTypeName",
              value: i
            };
          let l, y = o.lexer.current;
          if (o.consume("StringValue"))
            l = {
              type: "JsdocTypeSpecialNamePath",
              value: y.text.slice(1, -1),
              specialType: i,
              meta: {
                quote: y.text[0] === "'" ? "single" : "double"
              }
            };
          else {
            let N = "", S = ["Identifier", "@", "/"];
            for (; S.some((O) => o.consume(O)); )
              N += y.text, y = o.lexer.current;
            l = {
              type: "JsdocTypeSpecialNamePath",
              value: N,
              specialType: i,
              meta: {
                quote: void 0
              }
            };
          }
          let d = new R(e, o.lexer, o), x = d.parseInfixIntermediateType(l, f.ALL);
          return o.acceptLexerState(d), w(x);
        }, "parsePrefix")
      });
    }
    r(te, "createSpecialNamePathParslet");
    let We = [
      I({
        allowedAdditionalTokens: ["external", "module"]
      }),
      Y,
      Z,
      ee({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: null
      })
    ], _ = [
      ...We,
      te({
        allowedTypes: ["event"],
        pathGrammar: We
      })
    ];
    function be(e) {
      let t;
      if (e.type === "JsdocTypeParameterList")
        t = e.elements;
      else if (e.type === "JsdocTypeParenthesis")
        t = [e.element];
      else
        throw new c(e);
      return t.map((o) => xe(o));
    }
    r(be, "getParameters");
    function Kt(e) {
      let t = be(e);
      if (t.some((o) => o.type === "JsdocTypeKeyValue"))
        throw new Error("No parameter should be named");
      return t;
    }
    r(Kt, "getUnnamedParameters");
    function Ee({ allowNamedParameters: e, allowNoReturnType: t, allowWithoutParenthesis: o, allowNewAsFunctionKeyword: i }) {
      return h({
        name: "functionParslet",
        accept: /* @__PURE__ */ r((l, y) => l === "function" || i && l === "new" && y === "(", "accept"),
        parsePrefix: /* @__PURE__ */ r((l) => {
          let y = l.consume("new");
          l.consume("function");
          let d = l.lexer.current.type === "(";
          if (!d) {
            if (!o)
              throw new Error("function is missing parameter list");
            return {
              type: "JsdocTypeName",
              value: "function"
            };
          }
          let x = {
            type: "JsdocTypeFunction",
            parameters: [],
            arrow: !1,
            constructor: y,
            parenthesis: d
          }, N = l.parseIntermediateType(f.FUNCTION);
          if (e === void 0)
            x.parameters = Kt(N);
          else {
            if (y && N.type === "JsdocTypeFunction" && N.arrow)
              return x = N, x.constructor = !0, x;
            x.parameters = be(N);
            for (let S of x.parameters)
              if (S.type === "JsdocTypeKeyValue" && !e.includes(S.key))
                throw new Error(`only allowed named parameters are ${e.join(", ")} but got ${S.type}`);
          }
          if (l.consume(":"))
            x.returnType = l.parseType(f.PREFIX);
          else if (!t)
            throw new Error("function is missing return type");
          return x;
        }, "parsePrefix")
      });
    }
    r(Ee, "createFunctionParslet");
    function Se({ allowPostfix: e, allowEnclosingBrackets: t }) {
      return h({
        name: "variadicParslet",
        accept: /* @__PURE__ */ r((o) => o === "...", "accept"),
        precedence: f.PREFIX,
        parsePrefix: /* @__PURE__ */ r((o) => {
          o.consume("...");
          let i = t && o.consume("[");
          try {
            let l = o.parseType(f.PREFIX);
            if (i && !o.consume("]"))
              throw new Error("Unterminated variadic type. Missing ']'");
            return {
              type: "JsdocTypeVariadic",
              element: w(l),
              meta: {
                position: "prefix",
                squareBrackets: i
              }
            };
          } catch (l) {
            if (l instanceof a) {
              if (i)
                throw new Error("Empty square brackets for variadic are not allowed.");
              return {
                type: "JsdocTypeVariadic",
                meta: {
                  position: void 0,
                  squareBrackets: !1
                }
              };
            } else
              throw l;
          }
        }, "parsePrefix"),
        parseInfix: e ? (o, i) => (o.consume("..."), {
          type: "JsdocTypeVariadic",
          element: w(i),
          meta: {
            position: "suffix",
            squareBrackets: !1
          }
        }) : void 0
      });
    }
    r(Se, "createVariadicParslet");
    let Ge = h({
      name: "symbolParslet",
      accept: /* @__PURE__ */ r((e) => e === "(", "accept"),
      precedence: f.SYMBOL,
      parseInfix: /* @__PURE__ */ r((e, t) => {
        if (t.type !== "JsdocTypeName")
          throw new Error("Symbol expects a name on the left side. (Reacting on '(')");
        e.consume("(");
        let o = {
          type: "JsdocTypeSymbol",
          value: t.value
        };
        if (!e.consume(")")) {
          let i = e.parseIntermediateType(f.SYMBOL);
          if (o.element = Lt(i), !e.consume(")"))
            throw new Error("Symbol does not end after value");
        }
        return o;
      }, "parseInfix")
    }), ze = h({
      name: "arrayBracketsParslet",
      precedence: f.ARRAY_BRACKETS,
      accept: /* @__PURE__ */ r((e, t) => e === "[" && t === "]", "accept"),
      parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("["), e.consume("]"), {
        type: "JsdocTypeGeneric",
        left: {
          type: "JsdocTypeName",
          value: "Array"
        },
        elements: [
          w(t)
        ],
        meta: {
          brackets: "square",
          dot: !1
        }
      }), "parseInfix")
    });
    function Ne({ objectFieldGrammar: e, allowKeyTypes: t }) {
      return h({
        name: "objectParslet",
        accept: /* @__PURE__ */ r((o) => o === "{", "accept"),
        parsePrefix: /* @__PURE__ */ r((o) => {
          o.consume("{");
          let i = {
            type: "JsdocTypeObject",
            meta: {
              separator: "comma"
            },
            elements: []
          };
          if (!o.consume("}")) {
            let l, y = new R(e, o.lexer, o);
            for (; ; ) {
              y.acceptLexerState(o);
              let d = y.parseIntermediateType(f.OBJECT);
              o.acceptLexerState(y), d === void 0 && t && (d = o.parseIntermediateType(f.OBJECT));
              let x = !1;
              if (d.type === "JsdocTypeNullable" && (x = !0, d = d.element), d.type === "JsdocTypeNumber" || d.type === "JsdocTypeName" || d.
              type === "JsdocTypeStringValue") {
                let S;
                d.type === "JsdocTypeStringValue" && (S = d.meta.quote), i.elements.push({
                  type: "JsdocTypeObjectField",
                  key: d.value.toString(),
                  right: void 0,
                  optional: x,
                  readonly: !1,
                  meta: {
                    quote: S
                  }
                });
              } else if (d.type === "JsdocTypeObjectField" || d.type === "JsdocTypeJsdocObjectField")
                i.elements.push(d);
              else
                throw new c(d);
              if (o.lexer.current.startOfLine)
                l = "linebreak";
              else if (o.consume(","))
                l = "comma";
              else if (o.consume(";"))
                l = "semicolon";
              else
                break;
              if (o.lexer.current.type === "}")
                break;
            }
            if (i.meta.separator = l ?? "comma", !o.consume("}"))
              throw new Error("Unterminated record type. Missing '}'");
          }
          return i;
        }, "parsePrefix")
      });
    }
    r(Ne, "createObjectParslet");
    function De({ allowSquaredProperties: e, allowKeyTypes: t, allowReadonly: o, allowOptional: i }) {
      return h({
        name: "objectFieldParslet",
        precedence: f.KEY_VALUE,
        accept: /* @__PURE__ */ r((l) => l === ":", "accept"),
        parseInfix: /* @__PURE__ */ r((l, y) => {
          var d;
          let x = !1, N = !1;
          i && y.type === "JsdocTypeNullable" && (x = !0, y = y.element), o && y.type === "JsdocTypeReadonlyProperty" && (N = !0, y = y.element);
          let S = (d = l.baseParser) !== null && d !== void 0 ? d : l;
          if (S.acceptLexerState(l), y.type === "JsdocTypeNumber" || y.type === "JsdocTypeName" || y.type === "JsdocTypeStringValue" || Je(y)) {
            if (Je(y) && !e)
              throw new c(y);
            S.consume(":");
            let O;
            y.type === "JsdocTypeStringValue" && (O = y.meta.quote);
            let ae = S.parseType(f.KEY_VALUE);
            return l.acceptLexerState(S), {
              type: "JsdocTypeObjectField",
              key: Je(y) ? y : y.value.toString(),
              right: ae,
              optional: x,
              readonly: N,
              meta: {
                quote: O
              }
            };
          } else {
            if (!t)
              throw new c(y);
            S.consume(":");
            let O = S.parseType(f.KEY_VALUE);
            return l.acceptLexerState(S), {
              type: "JsdocTypeJsdocObjectField",
              left: w(y),
              right: O
            };
          }
        }, "parseInfix")
      });
    }
    r(De, "createObjectFieldParslet");
    function Oe({ allowOptional: e, allowVariadic: t }) {
      return h({
        name: "keyValueParslet",
        precedence: f.KEY_VALUE,
        accept: /* @__PURE__ */ r((o) => o === ":", "accept"),
        parseInfix: /* @__PURE__ */ r((o, i) => {
          let l = !1, y = !1;
          if (e && i.type === "JsdocTypeNullable" && (l = !0, i = i.element), t && i.type === "JsdocTypeVariadic" && i.element !== void 0 &&
          (y = !0, i = i.element), i.type !== "JsdocTypeName")
            throw new c(i);
          o.consume(":");
          let d = o.parseType(f.KEY_VALUE);
          return {
            type: "JsdocTypeKeyValue",
            key: i.value,
            right: d,
            optional: l,
            variadic: y
          };
        }, "parseInfix")
      });
    }
    r(Oe, "createKeyValueParslet");
    let Xe = [
      ...Pe,
      Ee({
        allowWithoutParenthesis: !0,
        allowNamedParameters: ["this", "new"],
        allowNoReturnType: !0,
        allowNewAsFunctionKeyword: !1
      }),
      Y,
      te({
        allowedTypes: ["module", "external", "event"],
        pathGrammar: _
      }),
      Se({
        allowEnclosingBrackets: !0,
        allowPostfix: !0
      }),
      I({
        allowedAdditionalTokens: ["keyof"]
      }),
      Ge,
      ze,
      ee({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: _
      })
    ], $t = [
      ...Xe,
      Ne({
        // jsdoc syntax allows full types as keys, so we need to pull in the full grammar here
        // we leave out the object type deliberately
        objectFieldGrammar: [
          I({
            allowedAdditionalTokens: ["module", "in"]
          }),
          De({
            allowSquaredProperties: !1,
            allowKeyTypes: !0,
            allowOptional: !1,
            allowReadonly: !1
          }),
          ...Xe
        ],
        allowKeyTypes: !0
      }),
      Oe({
        allowOptional: !0,
        allowVariadic: !0
      })
    ], He = h({
      name: "typeOfParslet",
      accept: /* @__PURE__ */ r((e) => e === "typeof", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("typeof"), {
        type: "JsdocTypeTypeof",
        element: w(e.parseType(f.KEY_OF_TYPE_OF))
      }), "parsePrefix")
    }), qt = [
      I({
        allowedAdditionalTokens: ["module", "keyof", "event", "external", "in"]
      }),
      we,
      Q,
      Y,
      Z,
      De({
        allowSquaredProperties: !1,
        allowKeyTypes: !1,
        allowOptional: !1,
        allowReadonly: !1
      })
    ], Yt = [
      ...Pe,
      Ne({
        allowKeyTypes: !1,
        objectFieldGrammar: qt
      }),
      I({
        allowedAdditionalTokens: ["event", "external", "in"]
      }),
      He,
      Ee({
        allowWithoutParenthesis: !1,
        allowNamedParameters: ["this", "new"],
        allowNoReturnType: !0,
        allowNewAsFunctionKeyword: !1
      }),
      Se({
        allowEnclosingBrackets: !1,
        allowPostfix: !1
      }),
      // additional name parslet is needed for some special cases
      I({
        allowedAdditionalTokens: ["keyof"]
      }),
      te({
        allowedTypes: ["module"],
        pathGrammar: _
      }),
      ee({
        allowSquareBracketsOnAnyType: !1,
        allowJsdocNamePaths: !0,
        pathGrammar: _
      }),
      Oe({
        allowOptional: !1,
        allowVariadic: !1
      }),
      Ge
    ];
    function Wt({ allowQuestionMark: e }) {
      return h({
        name: "tupleParslet",
        accept: /* @__PURE__ */ r((t) => t === "[", "accept"),
        parsePrefix: /* @__PURE__ */ r((t) => {
          t.consume("[");
          let o = {
            type: "JsdocTypeTuple",
            elements: []
          };
          if (t.consume("]"))
            return o;
          let i = t.parseIntermediateType(f.ALL);
          if (i.type === "JsdocTypeParameterList" ? i.elements[0].type === "JsdocTypeKeyValue" ? o.elements = i.elements.map(H) : o.elements =
          i.elements.map(w) : i.type === "JsdocTypeKeyValue" ? o.elements = [H(i)] : o.elements = [w(i)], !t.consume("]"))
            throw new Error("Unterminated '['");
          if (!e && o.elements.some((l) => l.type === "JsdocTypeUnknown"))
            throw new Error("Question mark in tuple not allowed");
          return o;
        }, "parsePrefix")
      });
    }
    r(Wt, "createTupleParslet");
    let Gt = h({
      name: "keyOfParslet",
      accept: /* @__PURE__ */ r((e) => e === "keyof", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("keyof"), {
        type: "JsdocTypeKeyof",
        element: w(e.parseType(f.KEY_OF_TYPE_OF))
      }), "parsePrefix")
    }), zt = h({
      name: "importParslet",
      accept: /* @__PURE__ */ r((e) => e === "import", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        if (e.consume("import"), !e.consume("("))
          throw new Error("Missing parenthesis after import keyword");
        let t = e.parseType(f.PREFIX);
        if (t.type !== "JsdocTypeStringValue")
          throw new Error("Only string values are allowed as paths for imports");
        if (!e.consume(")"))
          throw new Error("Missing closing parenthesis after import keyword");
        return {
          type: "JsdocTypeImport",
          element: t
        };
      }, "parsePrefix")
    }), Xt = h({
      name: "readonlyPropertyParslet",
      accept: /* @__PURE__ */ r((e) => e === "readonly", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => (e.consume("readonly"), {
        type: "JsdocTypeReadonlyProperty",
        element: e.parseType(f.KEY_VALUE)
      }), "parsePrefix")
    }), Ht = h({
      name: "arrowFunctionParslet",
      precedence: f.ARROW,
      accept: /* @__PURE__ */ r((e) => e === "=>", "accept"),
      parseInfix: /* @__PURE__ */ r((e, t) => (e.consume("=>"), {
        type: "JsdocTypeFunction",
        parameters: be(t).map(jt),
        arrow: !0,
        constructor: !1,
        parenthesis: !0,
        returnType: e.parseType(f.OBJECT)
      }), "parseInfix")
    }), Qt = h({
      name: "intersectionParslet",
      accept: /* @__PURE__ */ r((e) => e === "&", "accept"),
      precedence: f.INTERSECTION,
      parseInfix: /* @__PURE__ */ r((e, t) => {
        e.consume("&");
        let o = [];
        do
          o.push(e.parseType(f.INTERSECTION));
        while (e.consume("&"));
        return {
          type: "JsdocTypeIntersection",
          elements: [w(t), ...o]
        };
      }, "parseInfix")
    }), Zt = h({
      name: "predicateParslet",
      precedence: f.INFIX,
      accept: /* @__PURE__ */ r((e) => e === "is", "accept"),
      parseInfix: /* @__PURE__ */ r((e, t) => {
        if (t.type !== "JsdocTypeName")
          throw new c(t, "A typescript predicate always has to have a name on the left side.");
        return e.consume("is"), {
          type: "JsdocTypePredicate",
          left: t,
          right: w(e.parseIntermediateType(f.INFIX))
        };
      }, "parseInfix")
    }), er = h({
      name: "objectSquareBracketPropertyParslet",
      accept: /* @__PURE__ */ r((e) => e === "[", "accept"),
      parsePrefix: /* @__PURE__ */ r((e) => {
        if (e.baseParser === void 0)
          throw new Error("Only allowed inside object grammar");
        e.consume("[");
        let t = e.lexer.current.text;
        e.consume("Identifier");
        let o;
        if (e.consume(":")) {
          let i = e.baseParser;
          i.acceptLexerState(e), o = {
            type: "JsdocTypeIndexSignature",
            key: t,
            right: i.parseType(f.ARRAY_BRACKETS)
          }, e.acceptLexerState(i);
        } else if (e.consume("in")) {
          let i = e.baseParser;
          i.acceptLexerState(e), o = {
            type: "JsdocTypeMappedType",
            key: t,
            right: i.parseType(f.ARRAY_BRACKETS)
          }, e.acceptLexerState(i);
        } else
          throw new Error("Missing ':' or 'in' inside square bracketed property.");
        if (!e.consume("]"))
          throw new Error("Unterminated square brackets");
        return o;
      }, "parsePrefix")
    }), tr = [
      Xt,
      I({
        allowedAdditionalTokens: ["module", "event", "keyof", "event", "external", "in"]
      }),
      we,
      Q,
      Y,
      Z,
      De({
        allowSquaredProperties: !0,
        allowKeyTypes: !1,
        allowOptional: !0,
        allowReadonly: !0
      }),
      er
    ], rr = [
      ...Pe,
      Ne({
        allowKeyTypes: !1,
        objectFieldGrammar: tr
      }),
      He,
      Gt,
      zt,
      Y,
      Ee({
        allowWithoutParenthesis: !0,
        allowNoReturnType: !1,
        allowNamedParameters: ["this", "new", "args"],
        allowNewAsFunctionKeyword: !0
      }),
      Wt({
        allowQuestionMark: !1
      }),
      Se({
        allowEnclosingBrackets: !1,
        allowPostfix: !1
      }),
      I({
        allowedAdditionalTokens: ["event", "external", "in"]
      }),
      te({
        allowedTypes: ["module"],
        pathGrammar: _
      }),
      ze,
      Ht,
      ee({
        allowSquareBracketsOnAnyType: !0,
        allowJsdocNamePaths: !1,
        pathGrammar: _
      }),
      Qt,
      Zt,
      Oe({
        allowVariadic: !0,
        allowOptional: !0
      })
    ];
    function Qe(e, t) {
      switch (t) {
        case "closure":
          return new R(Yt, e).parse();
        case "jsdoc":
          return new R($t, e).parse();
        case "typescript":
          return new R(rr, e).parse();
      }
    }
    r(Qe, "parse");
    function nr(e, t = ["typescript", "closure", "jsdoc"]) {
      let o;
      for (let i of t)
        try {
          return Qe(e, i);
        } catch (l) {
          o = l;
        }
      throw o;
    }
    r(nr, "tryParse");
    function W(e, t) {
      let o = e[t.type];
      if (o === void 0)
        throw new Error(`In this set of transform rules exists no rule for type ${t.type}.`);
      return o(t, (i) => W(e, i));
    }
    r(W, "transform");
    function D(e) {
      throw new Error("This transform is not available. Are you trying the correct parsing mode?");
    }
    r(D, "notAvailableTransform");
    function Ze(e) {
      let t = {
        params: []
      };
      for (let o of e.parameters)
        o.type === "JsdocTypeKeyValue" ? o.key === "this" ? t.this = o.right : o.key === "new" ? t.new = o.right : t.params.push(o) : t.params.
        push(o);
      return t;
    }
    r(Ze, "extractSpecialParams");
    function re(e, t, o) {
      return e === "prefix" ? o + t : t + o;
    }
    r(re, "applyPosition");
    function F(e, t) {
      switch (t) {
        case "double":
          return `"${e}"`;
        case "single":
          return `'${e}'`;
        case void 0:
          return e;
      }
    }
    r(F, "quote");
    function et() {
      return {
        JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => `(${e.element !== void 0 ? t(e.element) : ""})`, "JsdocTypeParenthesis"),
        JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => `keyof ${t(e.element)}`, "JsdocTypeKeyof"),
        JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
          if (e.arrow) {
            if (e.returnType === void 0)
              throw new Error("Arrow function needs a return type.");
            let o = `(${e.parameters.map(t).join(", ")}) => ${t(e.returnType)}`;
            return e.constructor && (o = "new " + o), o;
          } else {
            let o = e.constructor ? "new" : "function";
            return e.parenthesis && (o += `(${e.parameters.map(t).join(", ")})`, e.returnType !== void 0 && (o += `: ${t(e.returnType)}`)), o;
          }
        }, "JsdocTypeFunction"),
        JsdocTypeName: /* @__PURE__ */ r((e) => e.value, "JsdocTypeName"),
        JsdocTypeTuple: /* @__PURE__ */ r((e, t) => `[${e.elements.map(t).join(", ")}]`, "JsdocTypeTuple"),
        JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => e.meta.position === void 0 ? "..." : re(e.meta.position, t(e.element), "..."), "Jsdoc\
TypeVariadic"),
        JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
          let o = t(e.left), i = t(e.right);
          switch (e.pathType) {
            case "inner":
              return `${o}~${i}`;
            case "instance":
              return `${o}#${i}`;
            case "property":
              return `${o}.${i}`;
            case "property-brackets":
              return `${o}[${i}]`;
          }
        }, "JsdocTypeNamePath"),
        JsdocTypeStringValue: /* @__PURE__ */ r((e) => F(e.value, e.meta.quote), "JsdocTypeStringValue"),
        JsdocTypeAny: /* @__PURE__ */ r(() => "*", "JsdocTypeAny"),
        JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => {
          if (e.meta.brackets === "square") {
            let o = e.elements[0], i = t(o);
            return o.type === "JsdocTypeUnion" || o.type === "JsdocTypeIntersection" ? `(${i})[]` : `${i}[]`;
          } else
            return `${t(e.left)}${e.meta.dot ? "." : ""}<${e.elements.map(t).join(", ")}>`;
        }, "JsdocTypeGeneric"),
        JsdocTypeImport: /* @__PURE__ */ r((e, t) => `import(${t(e.element)})`, "JsdocTypeImport"),
        JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
          let o = "";
          return e.readonly && (o += "readonly "), typeof e.key == "string" ? o += F(e.key, e.meta.quote) : o += t(e.key), e.optional && (o +=
          "?"), e.right === void 0 ? o : o + `: ${t(e.right)}`;
        }, "JsdocTypeObjectField"),
        JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => `${t(e.left)}: ${t(e.right)}`, "JsdocTypeJsdocObjectField"),
        JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => {
          let o = e.key;
          return e.optional && (o += "?"), e.variadic && (o = "..." + o), e.right === void 0 ? o : o + `: ${t(e.right)}`;
        }, "JsdocTypeKeyValue"),
        JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => `${e.specialType}:${F(e.value, e.meta.quote)}`, "JsdocTypeSpecialNamePath"),
        JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => re(e.meta.position, t(e.element), "!"), "JsdocTypeNotNullable"),
        JsdocTypeNull: /* @__PURE__ */ r(() => "null", "JsdocTypeNull"),
        JsdocTypeNullable: /* @__PURE__ */ r((e, t) => re(e.meta.position, t(e.element), "?"), "JsdocTypeNullable"),
        JsdocTypeNumber: /* @__PURE__ */ r((e) => e.value.toString(), "JsdocTypeNumber"),
        JsdocTypeObject: /* @__PURE__ */ r((e, t) => `{${e.elements.map(t).join((e.meta.separator === "comma" ? "," : ";") + " ")}}`, "Jsdoc\
TypeObject"),
        JsdocTypeOptional: /* @__PURE__ */ r((e, t) => re(e.meta.position, t(e.element), "="), "JsdocTypeOptional"),
        JsdocTypeSymbol: /* @__PURE__ */ r((e, t) => `${e.value}(${e.element !== void 0 ? t(e.element) : ""})`, "JsdocTypeSymbol"),
        JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => `typeof ${t(e.element)}`, "JsdocTypeTypeof"),
        JsdocTypeUndefined: /* @__PURE__ */ r(() => "undefined", "JsdocTypeUndefined"),
        JsdocTypeUnion: /* @__PURE__ */ r((e, t) => e.elements.map(t).join(" | "), "JsdocTypeUnion"),
        JsdocTypeUnknown: /* @__PURE__ */ r(() => "?", "JsdocTypeUnknown"),
        JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => e.elements.map(t).join(" & "), "JsdocTypeIntersection"),
        JsdocTypeProperty: /* @__PURE__ */ r((e) => F(e.value, e.meta.quote), "JsdocTypeProperty"),
        JsdocTypePredicate: /* @__PURE__ */ r((e, t) => `${t(e.left)} is ${t(e.right)}`, "JsdocTypePredicate"),
        JsdocTypeIndexSignature: /* @__PURE__ */ r((e, t) => `[${e.key}: ${t(e.right)}]`, "JsdocTypeIndexSignature"),
        JsdocTypeMappedType: /* @__PURE__ */ r((e, t) => `[${e.key} in ${t(e.right)}]`, "JsdocTypeMappedType")
      };
    }
    r(et, "stringifyRules");
    let or = et();
    function sr(e) {
      return W(or, e);
    }
    r(sr, "stringify");
    let ar = [
      "null",
      "true",
      "false",
      "break",
      "case",
      "catch",
      "class",
      "const",
      "continue",
      "debugger",
      "default",
      "delete",
      "do",
      "else",
      "export",
      "extends",
      "finally",
      "for",
      "function",
      "if",
      "import",
      "in",
      "instanceof",
      "new",
      "return",
      "super",
      "switch",
      "this",
      "throw",
      "try",
      "typeof",
      "var",
      "void",
      "while",
      "with",
      "yield"
    ];
    function j(e) {
      let t = {
        type: "NameExpression",
        name: e
      };
      return ar.includes(e) && (t.reservedWord = !0), t;
    }
    r(j, "makeName");
    let ir = {
      JsdocTypeOptional: /* @__PURE__ */ r((e, t) => {
        let o = t(e.element);
        return o.optional = !0, o;
      }, "JsdocTypeOptional"),
      JsdocTypeNullable: /* @__PURE__ */ r((e, t) => {
        let o = t(e.element);
        return o.nullable = !0, o;
      }, "JsdocTypeNullable"),
      JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => {
        let o = t(e.element);
        return o.nullable = !1, o;
      }, "JsdocTypeNotNullable"),
      JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
        if (e.element === void 0)
          throw new Error("dots without value are not allowed in catharsis mode");
        let o = t(e.element);
        return o.repeatable = !0, o;
      }, "JsdocTypeVariadic"),
      JsdocTypeAny: /* @__PURE__ */ r(() => ({
        type: "AllLiteral"
      }), "JsdocTypeAny"),
      JsdocTypeNull: /* @__PURE__ */ r(() => ({
        type: "NullLiteral"
      }), "JsdocTypeNull"),
      JsdocTypeStringValue: /* @__PURE__ */ r((e) => j(F(e.value, e.meta.quote)), "JsdocTypeStringValue"),
      JsdocTypeUndefined: /* @__PURE__ */ r(() => ({
        type: "UndefinedLiteral"
      }), "JsdocTypeUndefined"),
      JsdocTypeUnknown: /* @__PURE__ */ r(() => ({
        type: "UnknownLiteral"
      }), "JsdocTypeUnknown"),
      JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
        let o = Ze(e), i = {
          type: "FunctionType",
          params: o.params.map(t)
        };
        return o.this !== void 0 && (i.this = t(o.this)), o.new !== void 0 && (i.new = t(o.new)), e.returnType !== void 0 && (i.result = t(e.
        returnType)), i;
      }, "JsdocTypeFunction"),
      JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => ({
        type: "TypeApplication",
        applications: e.elements.map((o) => t(o)),
        expression: t(e.left)
      }), "JsdocTypeGeneric"),
      JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => j(e.specialType + ":" + F(e.value, e.meta.quote)), "JsdocTypeSpecialNamePath"),
      JsdocTypeName: /* @__PURE__ */ r((e) => e.value !== "function" ? j(e.value) : {
        type: "FunctionType",
        params: []
      }, "JsdocTypeName"),
      JsdocTypeNumber: /* @__PURE__ */ r((e) => j(e.value.toString()), "JsdocTypeNumber"),
      JsdocTypeObject: /* @__PURE__ */ r((e, t) => {
        let o = {
          type: "RecordType",
          fields: []
        };
        for (let i of e.elements)
          i.type !== "JsdocTypeObjectField" && i.type !== "JsdocTypeJsdocObjectField" ? o.fields.push({
            type: "FieldType",
            key: t(i),
            value: void 0
          }) : o.fields.push(t(i));
        return o;
      }, "JsdocTypeObject"),
      JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
        if (typeof e.key != "string")
          throw new Error("Index signatures and mapped types are not supported");
        return {
          type: "FieldType",
          key: j(F(e.key, e.meta.quote)),
          value: e.right === void 0 ? void 0 : t(e.right)
        };
      }, "JsdocTypeObjectField"),
      JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => ({
        type: "FieldType",
        key: t(e.left),
        value: t(e.right)
      }), "JsdocTypeJsdocObjectField"),
      JsdocTypeUnion: /* @__PURE__ */ r((e, t) => ({
        type: "TypeUnion",
        elements: e.elements.map((o) => t(o))
      }), "JsdocTypeUnion"),
      JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => ({
        type: "FieldType",
        key: j(e.key),
        value: e.right === void 0 ? void 0 : t(e.right)
      }), "JsdocTypeKeyValue"),
      JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
        let o = t(e.left), i;
        e.right.type === "JsdocTypeSpecialNamePath" ? i = t(e.right).name : i = F(e.right.value, e.right.meta.quote);
        let l = e.pathType === "inner" ? "~" : e.pathType === "instance" ? "#" : ".";
        return j(`${o.name}${l}${i}`);
      }, "JsdocTypeNamePath"),
      JsdocTypeSymbol: /* @__PURE__ */ r((e) => {
        let t = "", o = e.element, i = !1;
        return o?.type === "JsdocTypeVariadic" && (o.meta.position === "prefix" ? t = "..." : i = !0, o = o.element), o?.type === "JsdocType\
Name" ? t += o.value : o?.type === "JsdocTypeNumber" && (t += o.value.toString()), i && (t += "..."), j(`${e.value}(${t})`);
      }, "JsdocTypeSymbol"),
      JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => t(w(e.element)), "JsdocTypeParenthesis"),
      JsdocTypeMappedType: D,
      JsdocTypeIndexSignature: D,
      JsdocTypeImport: D,
      JsdocTypeKeyof: D,
      JsdocTypeTuple: D,
      JsdocTypeTypeof: D,
      JsdocTypeIntersection: D,
      JsdocTypeProperty: D,
      JsdocTypePredicate: D
    };
    function pr(e) {
      return W(ir, e);
    }
    r(pr, "catharsisTransform");
    function V(e) {
      switch (e) {
        case void 0:
          return "none";
        case "single":
          return "single";
        case "double":
          return "double";
      }
    }
    r(V, "getQuoteStyle");
    function cr(e) {
      switch (e) {
        case "inner":
          return "INNER_MEMBER";
        case "instance":
          return "INSTANCE_MEMBER";
        case "property":
          return "MEMBER";
        case "property-brackets":
          return "MEMBER";
      }
    }
    r(cr, "getMemberType");
    function ve(e, t) {
      return t.length === 2 ? {
        type: e,
        left: t[0],
        right: t[1]
      } : {
        type: e,
        left: t[0],
        right: ve(e, t.slice(1))
      };
    }
    r(ve, "nestResults");
    let lr = {
      JsdocTypeOptional: /* @__PURE__ */ r((e, t) => ({
        type: "OPTIONAL",
        value: t(e.element),
        meta: {
          syntax: e.meta.position === "prefix" ? "PREFIX_EQUAL_SIGN" : "SUFFIX_EQUALS_SIGN"
        }
      }), "JsdocTypeOptional"),
      JsdocTypeNullable: /* @__PURE__ */ r((e, t) => ({
        type: "NULLABLE",
        value: t(e.element),
        meta: {
          syntax: e.meta.position === "prefix" ? "PREFIX_QUESTION_MARK" : "SUFFIX_QUESTION_MARK"
        }
      }), "JsdocTypeNullable"),
      JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => ({
        type: "NOT_NULLABLE",
        value: t(e.element),
        meta: {
          syntax: e.meta.position === "prefix" ? "PREFIX_BANG" : "SUFFIX_BANG"
        }
      }), "JsdocTypeNotNullable"),
      JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
        let o = {
          type: "VARIADIC",
          meta: {
            syntax: e.meta.position === "prefix" ? "PREFIX_DOTS" : e.meta.position === "suffix" ? "SUFFIX_DOTS" : "ONLY_DOTS"
          }
        };
        return e.element !== void 0 && (o.value = t(e.element)), o;
      }, "JsdocTypeVariadic"),
      JsdocTypeName: /* @__PURE__ */ r((e) => ({
        type: "NAME",
        name: e.value
      }), "JsdocTypeName"),
      JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => ({
        type: "TYPE_QUERY",
        name: t(e.element)
      }), "JsdocTypeTypeof"),
      JsdocTypeTuple: /* @__PURE__ */ r((e, t) => ({
        type: "TUPLE",
        entries: e.elements.map(t)
      }), "JsdocTypeTuple"),
      JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => ({
        type: "KEY_QUERY",
        value: t(e.element)
      }), "JsdocTypeKeyof"),
      JsdocTypeImport: /* @__PURE__ */ r((e) => ({
        type: "IMPORT",
        path: {
          type: "STRING_VALUE",
          quoteStyle: V(e.element.meta.quote),
          string: e.element.value
        }
      }), "JsdocTypeImport"),
      JsdocTypeUndefined: /* @__PURE__ */ r(() => ({
        type: "NAME",
        name: "undefined"
      }), "JsdocTypeUndefined"),
      JsdocTypeAny: /* @__PURE__ */ r(() => ({
        type: "ANY"
      }), "JsdocTypeAny"),
      JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
        let o = Ze(e), i = {
          type: e.arrow ? "ARROW" : "FUNCTION",
          params: o.params.map((l) => {
            if (l.type === "JsdocTypeKeyValue") {
              if (l.right === void 0)
                throw new Error("Function parameter without ':' is not expected to be 'KEY_VALUE'");
              return {
                type: "NAMED_PARAMETER",
                name: l.key,
                typeName: t(l.right)
              };
            } else
              return t(l);
          }),
          new: null,
          returns: null
        };
        return o.this !== void 0 ? i.this = t(o.this) : e.arrow || (i.this = null), o.new !== void 0 && (i.new = t(o.new)), e.returnType !==
        void 0 && (i.returns = t(e.returnType)), i;
      }, "JsdocTypeFunction"),
      JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => {
        let o = {
          type: "GENERIC",
          subject: t(e.left),
          objects: e.elements.map(t),
          meta: {
            syntax: e.meta.brackets === "square" ? "SQUARE_BRACKET" : e.meta.dot ? "ANGLE_BRACKET_WITH_DOT" : "ANGLE_BRACKET"
          }
        };
        return e.meta.brackets === "square" && e.elements[0].type === "JsdocTypeFunction" && !e.elements[0].parenthesis && (o.objects[0] = {
          type: "NAME",
          name: "function"
        }), o;
      }, "JsdocTypeGeneric"),
      JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => {
        if (typeof e.key != "string")
          throw new Error("Index signatures and mapped types are not supported");
        if (e.right === void 0)
          return {
            type: "RECORD_ENTRY",
            key: e.key,
            quoteStyle: V(e.meta.quote),
            value: null,
            readonly: !1
          };
        let o = t(e.right);
        return e.optional && (o = {
          type: "OPTIONAL",
          value: o,
          meta: {
            syntax: "SUFFIX_KEY_QUESTION_MARK"
          }
        }), {
          type: "RECORD_ENTRY",
          key: e.key.toString(),
          quoteStyle: V(e.meta.quote),
          value: o,
          readonly: !1
        };
      }, "JsdocTypeObjectField"),
      JsdocTypeJsdocObjectField: /* @__PURE__ */ r(() => {
        throw new Error("Keys may not be typed in jsdoctypeparser.");
      }, "JsdocTypeJsdocObjectField"),
      JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => {
        if (e.right === void 0)
          return {
            type: "RECORD_ENTRY",
            key: e.key,
            quoteStyle: "none",
            value: null,
            readonly: !1
          };
        let o = t(e.right);
        return e.optional && (o = {
          type: "OPTIONAL",
          value: o,
          meta: {
            syntax: "SUFFIX_KEY_QUESTION_MARK"
          }
        }), {
          type: "RECORD_ENTRY",
          key: e.key,
          quoteStyle: "none",
          value: o,
          readonly: !1
        };
      }, "JsdocTypeKeyValue"),
      JsdocTypeObject: /* @__PURE__ */ r((e, t) => {
        let o = [];
        for (let i of e.elements)
          (i.type === "JsdocTypeObjectField" || i.type === "JsdocTypeJsdocObjectField") && o.push(t(i));
        return {
          type: "RECORD",
          entries: o
        };
      }, "JsdocTypeObject"),
      JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => {
        if (e.specialType !== "module")
          throw new Error(`jsdoctypeparser does not support type ${e.specialType} at this point.`);
        return {
          type: "MODULE",
          value: {
            type: "FILE_PATH",
            quoteStyle: V(e.meta.quote),
            path: e.value
          }
        };
      }, "JsdocTypeSpecialNamePath"),
      JsdocTypeNamePath: /* @__PURE__ */ r((e, t) => {
        let o = !1, i, l;
        e.right.type === "JsdocTypeSpecialNamePath" && e.right.specialType === "event" ? (o = !0, i = e.right.value, l = V(e.right.meta.quote)) :
        (i = e.right.value, l = V(e.right.meta.quote));
        let y = {
          type: cr(e.pathType),
          owner: t(e.left),
          name: i,
          quoteStyle: l,
          hasEventPrefix: o
        };
        if (y.owner.type === "MODULE") {
          let d = y.owner;
          return y.owner = y.owner.value, d.value = y, d;
        } else
          return y;
      }, "JsdocTypeNamePath"),
      JsdocTypeUnion: /* @__PURE__ */ r((e, t) => ve("UNION", e.elements.map(t)), "JsdocTypeUnion"),
      JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => ({
        type: "PARENTHESIS",
        value: t(w(e.element))
      }), "JsdocTypeParenthesis"),
      JsdocTypeNull: /* @__PURE__ */ r(() => ({
        type: "NAME",
        name: "null"
      }), "JsdocTypeNull"),
      JsdocTypeUnknown: /* @__PURE__ */ r(() => ({
        type: "UNKNOWN"
      }), "JsdocTypeUnknown"),
      JsdocTypeStringValue: /* @__PURE__ */ r((e) => ({
        type: "STRING_VALUE",
        quoteStyle: V(e.meta.quote),
        string: e.value
      }), "JsdocTypeStringValue"),
      JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => ve("INTERSECTION", e.elements.map(t)), "JsdocTypeIntersection"),
      JsdocTypeNumber: /* @__PURE__ */ r((e) => ({
        type: "NUMBER_VALUE",
        number: e.value.toString()
      }), "JsdocTypeNumber"),
      JsdocTypeSymbol: D,
      JsdocTypeProperty: D,
      JsdocTypePredicate: D,
      JsdocTypeMappedType: D,
      JsdocTypeIndexSignature: D
    };
    function ur(e) {
      return W(lr, e);
    }
    r(ur, "jtpTransform");
    function mr() {
      return {
        JsdocTypeIntersection: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeIntersection",
          elements: e.elements.map(t)
        }), "JsdocTypeIntersection"),
        JsdocTypeGeneric: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeGeneric",
          left: t(e.left),
          elements: e.elements.map(t),
          meta: {
            dot: e.meta.dot,
            brackets: e.meta.brackets
          }
        }), "JsdocTypeGeneric"),
        JsdocTypeNullable: /* @__PURE__ */ r((e) => e, "JsdocTypeNullable"),
        JsdocTypeUnion: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeUnion",
          elements: e.elements.map(t)
        }), "JsdocTypeUnion"),
        JsdocTypeUnknown: /* @__PURE__ */ r((e) => e, "JsdocTypeUnknown"),
        JsdocTypeUndefined: /* @__PURE__ */ r((e) => e, "JsdocTypeUndefined"),
        JsdocTypeTypeof: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeTypeof",
          element: t(e.element)
        }), "JsdocTypeTypeof"),
        JsdocTypeSymbol: /* @__PURE__ */ r((e, t) => {
          let o = {
            type: "JsdocTypeSymbol",
            value: e.value
          };
          return e.element !== void 0 && (o.element = t(e.element)), o;
        }, "JsdocTypeSymbol"),
        JsdocTypeOptional: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeOptional",
          element: t(e.element),
          meta: {
            position: e.meta.position
          }
        }), "JsdocTypeOptional"),
        JsdocTypeObject: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeObject",
          meta: {
            separator: "comma"
          },
          elements: e.elements.map(t)
        }), "JsdocTypeObject"),
        JsdocTypeNumber: /* @__PURE__ */ r((e) => e, "JsdocTypeNumber"),
        JsdocTypeNull: /* @__PURE__ */ r((e) => e, "JsdocTypeNull"),
        JsdocTypeNotNullable: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeNotNullable",
          element: t(e.element),
          meta: {
            position: e.meta.position
          }
        }), "JsdocTypeNotNullable"),
        JsdocTypeSpecialNamePath: /* @__PURE__ */ r((e) => e, "JsdocTypeSpecialNamePath"),
        JsdocTypeObjectField: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeObjectField",
          key: e.key,
          right: e.right === void 0 ? void 0 : t(e.right),
          optional: e.optional,
          readonly: e.readonly,
          meta: e.meta
        }), "JsdocTypeObjectField"),
        JsdocTypeJsdocObjectField: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeJsdocObjectField",
          left: t(e.left),
          right: t(e.right)
        }), "JsdocTypeJsdocObjectField"),
        JsdocTypeKeyValue: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeKeyValue",
          key: e.key,
          right: e.right === void 0 ? void 0 : t(e.right),
          optional: e.optional,
          variadic: e.variadic
        }), "JsdocTypeKeyValue"),
        JsdocTypeImport: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeImport",
          element: t(e.element)
        }), "JsdocTypeImport"),
        JsdocTypeAny: /* @__PURE__ */ r((e) => e, "JsdocTypeAny"),
        JsdocTypeStringValue: /* @__PURE__ */ r((e) => e, "JsdocTypeStringValue"),
        JsdocTypeNamePath: /* @__PURE__ */ r((e) => e, "JsdocTypeNamePath"),
        JsdocTypeVariadic: /* @__PURE__ */ r((e, t) => {
          let o = {
            type: "JsdocTypeVariadic",
            meta: {
              position: e.meta.position,
              squareBrackets: e.meta.squareBrackets
            }
          };
          return e.element !== void 0 && (o.element = t(e.element)), o;
        }, "JsdocTypeVariadic"),
        JsdocTypeTuple: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeTuple",
          elements: e.elements.map(t)
        }), "JsdocTypeTuple"),
        JsdocTypeName: /* @__PURE__ */ r((e) => e, "JsdocTypeName"),
        JsdocTypeFunction: /* @__PURE__ */ r((e, t) => {
          let o = {
            type: "JsdocTypeFunction",
            arrow: e.arrow,
            parameters: e.parameters.map(t),
            constructor: e.constructor,
            parenthesis: e.parenthesis
          };
          return e.returnType !== void 0 && (o.returnType = t(e.returnType)), o;
        }, "JsdocTypeFunction"),
        JsdocTypeKeyof: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeKeyof",
          element: t(e.element)
        }), "JsdocTypeKeyof"),
        JsdocTypeParenthesis: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeParenthesis",
          element: t(e.element)
        }), "JsdocTypeParenthesis"),
        JsdocTypeProperty: /* @__PURE__ */ r((e) => e, "JsdocTypeProperty"),
        JsdocTypePredicate: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypePredicate",
          left: t(e.left),
          right: t(e.right)
        }), "JsdocTypePredicate"),
        JsdocTypeIndexSignature: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeIndexSignature",
          key: e.key,
          right: t(e.right)
        }), "JsdocTypeIndexSignature"),
        JsdocTypeMappedType: /* @__PURE__ */ r((e, t) => ({
          type: "JsdocTypeMappedType",
          key: e.key,
          right: t(e.right)
        }), "JsdocTypeMappedType")
      };
    }
    r(mr, "identityTransformRules");
    let tt = {
      JsdocTypeAny: [],
      JsdocTypeFunction: ["parameters", "returnType"],
      JsdocTypeGeneric: ["left", "elements"],
      JsdocTypeImport: [],
      JsdocTypeIndexSignature: ["right"],
      JsdocTypeIntersection: ["elements"],
      JsdocTypeKeyof: ["element"],
      JsdocTypeKeyValue: ["right"],
      JsdocTypeMappedType: ["right"],
      JsdocTypeName: [],
      JsdocTypeNamePath: ["left", "right"],
      JsdocTypeNotNullable: ["element"],
      JsdocTypeNull: [],
      JsdocTypeNullable: ["element"],
      JsdocTypeNumber: [],
      JsdocTypeObject: ["elements"],
      JsdocTypeObjectField: ["right"],
      JsdocTypeJsdocObjectField: ["left", "right"],
      JsdocTypeOptional: ["element"],
      JsdocTypeParenthesis: ["element"],
      JsdocTypeSpecialNamePath: [],
      JsdocTypeStringValue: [],
      JsdocTypeSymbol: ["element"],
      JsdocTypeTuple: ["elements"],
      JsdocTypeTypeof: ["element"],
      JsdocTypeUndefined: [],
      JsdocTypeUnion: ["elements"],
      JsdocTypeUnknown: [],
      JsdocTypeVariadic: ["element"],
      JsdocTypeProperty: [],
      JsdocTypePredicate: ["left", "right"]
    };
    function ke(e, t, o, i, l) {
      i?.(e, t, o);
      let y = tt[e.type];
      for (let d of y) {
        let x = e[d];
        if (x !== void 0)
          if (Array.isArray(x))
            for (let N of x)
              ke(N, e, d, i, l);
          else
            ke(x, e, d, i, l);
      }
      l?.(e, t, o);
    }
    r(ke, "_traverse");
    function yr(e, t, o) {
      ke(e, void 0, void 0, t, o);
    }
    r(yr, "traverse"), n.catharsisTransform = pr, n.identityTransformRules = mr, n.jtpTransform = ur, n.parse = Qe, n.stringify = sr, n.stringifyRules =
    et, n.transform = W, n.traverse = yr, n.tryParse = nr, n.visitorKeys = tt;
  });
});

// src/docs-tools/argTypes/convert/flow/convert.ts
import { UnknownArgTypesError as Pr } from "storybook/internal/preview-errors";
var br = /* @__PURE__ */ r((n) => n.name === "literal", "isLiteral"), Er = /* @__PURE__ */ r((n) => n.value.replace(/['|"]/g, ""), "toEnumOp\
tion"), Sr = /* @__PURE__ */ r((n) => {
  switch (n.type) {
    case "function":
      return { name: "function" };
    case "object":
      let s = {};
      return n.signature.properties.forEach((a) => {
        s[a.key] = B(a.value);
      }), {
        name: "object",
        value: s
      };
    default:
      throw new Pr({ type: n, language: "Flow" });
  }
}, "convertSig"), B = /* @__PURE__ */ r((n) => {
  let { name: s, raw: a } = n, p = {};
  switch (typeof a < "u" && (p.raw = a), n.name) {
    case "literal":
      return { ...p, name: "other", value: n.value };
    case "string":
    case "number":
    case "symbol":
    case "boolean":
      return { ...p, name: s };
    case "Array":
      return { ...p, name: "array", value: n.elements.map(B) };
    case "signature":
      return { ...p, ...Sr(n) };
    case "union":
      return n.elements?.every(br) ? { ...p, name: "enum", value: n.elements?.map(Er) } : { ...p, name: s, value: n.elements?.map(B) };
    case "intersection":
      return { ...p, name: s, value: n.elements?.map(B) };
    default:
      return { ...p, name: "other", value: s };
  }
}, "convert");

// ../node_modules/es-toolkit/dist/predicate/isPlainObject.mjs
function z(n) {
  if (typeof n != "object" || n == null)
    return !1;
  if (Object.getPrototypeOf(n) === null)
    return !0;
  if (n.toString() !== "[object Object]")
    return !1;
  let s = n;
  for (; Object.getPrototypeOf(s) !== null; )
    s = Object.getPrototypeOf(s);
  return Object.getPrototypeOf(n) === s;
}
r(z, "isPlainObject");

// ../node_modules/es-toolkit/dist/object/mapValues.mjs
function Ie(n, s) {
  let a = {}, p = Object.keys(n);
  for (let c = 0; c < p.length; c++) {
    let u = p[c], m = n[u];
    a[u] = s(m, u, n);
  }
  return a;
}
r(Ie, "mapValues");

// src/docs-tools/argTypes/convert/utils.ts
var ot = /^['"]|['"]$/g, Nr = /* @__PURE__ */ r((n) => n.replace(ot, ""), "trimQuotes"), Dr = /* @__PURE__ */ r((n) => ot.test(n), "includes\
Quotes"), ie = /* @__PURE__ */ r((n) => {
  let s = Nr(n);
  return Dr(n) || Number.isNaN(Number(s)) ? s : Number(s);
}, "parseLiteral");

// src/docs-tools/argTypes/convert/proptypes/convert.ts
var Or = /^\(.*\) => /, C = /* @__PURE__ */ r((n) => {
  let { name: s, raw: a, computed: p, value: c } = n, u = {};
  switch (typeof a < "u" && (u.raw = a), s) {
    case "enum": {
      let T = p ? c : c.map((g) => ie(g.value));
      return { ...u, name: s, value: T };
    }
    case "string":
    case "number":
    case "symbol":
      return { ...u, name: s };
    case "func":
      return { ...u, name: "function" };
    case "bool":
    case "boolean":
      return { ...u, name: "boolean" };
    case "arrayOf":
    case "array":
      return { ...u, name: "array", value: c && C(c) };
    case "object":
      return { ...u, name: s };
    case "objectOf":
      return { ...u, name: s, value: C(c) };
    case "shape":
    case "exact":
      let m = Ie(c, (T) => C(T));
      return { ...u, name: "object", value: m };
    case "union":
      return { ...u, name: "union", value: c.map((T) => C(T)) };
    case "instanceOf":
    case "element":
    case "elementType":
    default: {
      if (s?.indexOf("|") > 0)
        try {
          let P = s.split("|").map((b) => JSON.parse(b));
          return { ...u, name: "enum", value: P };
        } catch {
        }
      let T = c ? `${s}(${c})` : s, g = Or.test(s) ? "function" : "other";
      return { ...u, name: g, value: T };
    }
  }
}, "convert");

// src/docs-tools/argTypes/convert/typescript/convert.ts
import { UnknownArgTypesError as vr } from "storybook/internal/preview-errors";
var kr = /* @__PURE__ */ r((n) => {
  switch (n.type) {
    case "function":
      return { name: "function" };
    case "object":
      let s = {};
      return n.signature.properties.forEach((a) => {
        s[a.key] = M(a.value);
      }), {
        name: "object",
        value: s
      };
    default:
      throw new vr({ type: n, language: "Typescript" });
  }
}, "convertSig"), M = /* @__PURE__ */ r((n) => {
  let { name: s, raw: a } = n, p = {};
  switch (typeof a < "u" && (p.raw = a), n.name) {
    case "string":
    case "number":
    case "symbol":
    case "boolean":
      return { ...p, name: s };
    case "Array":
      return { ...p, name: "array", value: n.elements.map(M) };
    case "signature":
      return { ...p, ...kr(n) };
    case "union":
      let c;
      return n.elements?.every((u) => u.name === "literal") ? c = {
        ...p,
        name: "enum",
        // @ts-expect-error fix types
        value: n.elements?.map((u) => ie(u.value))
      } : c = { ...p, name: s, value: n.elements?.map(M) }, c;
    case "intersection":
      return { ...p, name: s, value: n.elements?.map(M) };
    default:
      return { ...p, name: "other", value: s };
  }
}, "convert");

// src/docs-tools/argTypes/convert/index.ts
var pe = /* @__PURE__ */ r((n) => {
  let { type: s, tsType: a, flowType: p } = n;
  try {
    if (s != null)
      return C(s);
    if (a != null)
      return M(a);
    if (p != null)
      return B(p);
  } catch (c) {
    console.error(c);
  }
  return null;
}, "convert");

// src/docs-tools/argTypes/docgen/types.ts
var Ar = /* @__PURE__ */ ((c) => (c.JAVASCRIPT = "JavaScript", c.FLOW = "Flow", c.TYPESCRIPT = "TypeScript", c.UNKNOWN = "Unknown", c))(Ar ||
{});

// src/docs-tools/argTypes/docgen/utils/defaultValue.ts
var Rr = ["null", "undefined"];
function K(n) {
  return Rr.some((s) => s === n);
}
r(K, "isDefaultValueBlacklisted");

// src/docs-tools/argTypes/docgen/utils/string.ts
var st = /* @__PURE__ */ r((n) => {
  if (!n)
    return "";
  if (typeof n == "string")
    return n;
  throw new Error(`Description: expected string, got: ${JSON.stringify(n)}`);
}, "str");

// src/docs-tools/argTypes/docgen/utils/docgenInfo.ts
function at(n) {
  return !!n.__docgenInfo;
}
r(at, "hasDocgen");
function it(n) {
  return n != null && Object.keys(n).length > 0;
}
r(it, "isValidDocgenSection");
function pt(n, s) {
  return at(n) ? n.__docgenInfo[s] : null;
}
r(pt, "getDocgenSection");
function ct(n) {
  return at(n) ? st(n.__docgenInfo.description) : "";
}
r(ct, "getDocgenDescription");

// ../node_modules/comment-parser/es6/primitives.js
var v;
(function(n) {
  n.start = "/**", n.nostart = "/***", n.delim = "*", n.end = "*/";
})(v = v || (v = {}));

// ../node_modules/comment-parser/es6/util.js
function Fe(n) {
  return /^\s+$/.test(n);
}
r(Fe, "isSpace");
function lt(n) {
  let s = n.match(/\r+$/);
  return s == null ? ["", n] : [n.slice(-s[0].length), n.slice(0, -s[0].length)];
}
r(lt, "splitCR");
function A(n) {
  let s = n.match(/^\s+/);
  return s == null ? ["", n] : [n.slice(0, s[0].length), n.slice(s[0].length)];
}
r(A, "splitSpace");
function ut(n) {
  return n.split(/\n/);
}
r(ut, "splitLines");
function mt(n = {}) {
  return Object.assign({ tag: "", name: "", type: "", optional: !1, description: "", problems: [], source: [] }, n);
}
r(mt, "seedSpec");
function je(n = {}) {
  return Object.assign({ start: "", delimiter: "", postDelimiter: "", tag: "", postTag: "", name: "", postName: "", type: "", postType: "", description: "",
  end: "", lineEnd: "" }, n);
}
r(je, "seedTokens");

// ../node_modules/comment-parser/es6/parser/block-parser.js
var Ir = /^@\S+/;
function Le({ fence: n = "```" } = {}) {
  let s = Fr(n), a = /* @__PURE__ */ r((p, c) => s(p) ? !c : c, "toggleFence");
  return /* @__PURE__ */ r(function(c) {
    let u = [[]], m = !1;
    for (let T of c)
      Ir.test(T.tokens.description) && !m ? u.push([T]) : u[u.length - 1].push(T), m = a(T.tokens.description, m);
    return u;
  }, "parseBlock");
}
r(Le, "getParser");
function Fr(n) {
  return typeof n == "string" ? (s) => s.split(n).length % 2 === 0 : n;
}
r(Fr, "getFencer");

// ../node_modules/comment-parser/es6/parser/source-parser.js
function Ve({ startLine: n = 0, markers: s = v } = {}) {
  let a = null, p = n;
  return /* @__PURE__ */ r(function(u) {
    let m = u, T = je();
    if ([T.lineEnd, m] = lt(m), [T.start, m] = A(m), a === null && m.startsWith(s.start) && !m.startsWith(s.nostart) && (a = [], T.delimiter =
    m.slice(0, s.start.length), m = m.slice(s.start.length), [T.postDelimiter, m] = A(m)), a === null)
      return p++, null;
    let g = m.trimRight().endsWith(s.end);
    if (T.delimiter === "" && m.startsWith(s.delim) && !m.startsWith(s.end) && (T.delimiter = s.delim, m = m.slice(s.delim.length), [T.postDelimiter,
    m] = A(m)), g) {
      let P = m.trimRight();
      T.end = m.slice(P.length - s.end.length), m = P.slice(0, -s.end.length);
    }
    if (T.description = m, a.push({ number: p, source: u, tokens: T }), p++, g) {
      let P = a.slice();
      return a = null, P;
    }
    return null;
  }, "parseSource");
}
r(Ve, "getParser");

// ../node_modules/comment-parser/es6/parser/spec-parser.js
function _e({ tokenizers: n }) {
  return /* @__PURE__ */ r(function(a) {
    var p;
    let c = mt({ source: a });
    for (let u of n)
      if (c = u(c), !((p = c.problems[c.problems.length - 1]) === null || p === void 0) && p.critical)
        break;
    return c;
  }, "parseSpec");
}
r(_e, "getParser");

// ../node_modules/comment-parser/es6/parser/tokenizers/tag.js
function ce() {
  return (n) => {
    let { tokens: s } = n.source[0], a = s.description.match(/\s*(@(\S+))(\s*)/);
    return a === null ? (n.problems.push({
      code: "spec:tag:prefix",
      message: 'tag should start with "@" symbol',
      line: n.source[0].number,
      critical: !0
    }), n) : (s.tag = a[1], s.postTag = a[3], s.description = s.description.slice(a[0].length), n.tag = a[2], n);
  };
}
r(ce, "tagTokenizer");

// ../node_modules/comment-parser/es6/parser/tokenizers/type.js
function le(n = "compact") {
  let s = Lr(n);
  return (a) => {
    let p = 0, c = [];
    for (let [T, { tokens: g }] of a.source.entries()) {
      let P = "";
      if (T === 0 && g.description[0] !== "{")
        return a;
      for (let b of g.description)
        if (b === "{" && p++, b === "}" && p--, P += b, p === 0)
          break;
      if (c.push([g, P]), p === 0)
        break;
    }
    if (p !== 0)
      return a.problems.push({
        code: "spec:type:unpaired-curlies",
        message: "unpaired curlies",
        line: a.source[0].number,
        critical: !0
      }), a;
    let u = [], m = c[0][0].postDelimiter.length;
    for (let [T, [g, P]] of c.entries())
      g.type = P, T > 0 && (g.type = g.postDelimiter.slice(m) + P, g.postDelimiter = g.postDelimiter.slice(0, m)), [g.postType, g.description] =
      A(g.description.slice(P.length)), u.push(g.type);
    return u[0] = u[0].slice(1), u[u.length - 1] = u[u.length - 1].slice(0, -1), a.type = s(u), a;
  };
}
r(le, "typeTokenizer");
var jr = /* @__PURE__ */ r((n) => n.trim(), "trim");
function Lr(n) {
  return n === "compact" ? (s) => s.map(jr).join("") : n === "preserve" ? (s) => s.join(`
`) : n;
}
r(Lr, "getJoiner");

// ../node_modules/comment-parser/es6/parser/tokenizers/name.js
var Vr = /* @__PURE__ */ r((n) => n && n.startsWith('"') && n.endsWith('"'), "isQuoted");
function ue() {
  let n = /* @__PURE__ */ r((s, { tokens: a }, p) => a.type === "" ? s : p, "typeEnd");
  return (s) => {
    let { tokens: a } = s.source[s.source.reduce(n, 0)], p = a.description.trimLeft(), c = p.split('"');
    if (c.length > 1 && c[0] === "" && c.length % 2 === 1)
      return s.name = c[1], a.name = `"${c[1]}"`, [a.postName, a.description] = A(p.slice(a.name.length)), s;
    let u = 0, m = "", T = !1, g;
    for (let b of p) {
      if (u === 0 && Fe(b))
        break;
      b === "[" && u++, b === "]" && u--, m += b;
    }
    if (u !== 0)
      return s.problems.push({
        code: "spec:name:unpaired-brackets",
        message: "unpaired brackets",
        line: s.source[0].number,
        critical: !0
      }), s;
    let P = m;
    if (m[0] === "[" && m[m.length - 1] === "]") {
      T = !0, m = m.slice(1, -1);
      let b = m.split("=");
      if (m = b[0].trim(), b[1] !== void 0 && (g = b.slice(1).join("=").trim()), m === "")
        return s.problems.push({
          code: "spec:name:empty-name",
          message: "empty name",
          line: s.source[0].number,
          critical: !0
        }), s;
      if (g === "")
        return s.problems.push({
          code: "spec:name:empty-default",
          message: "empty default value",
          line: s.source[0].number,
          critical: !0
        }), s;
      if (!Vr(g) && /=(?!>)/.test(g))
        return s.problems.push({
          code: "spec:name:invalid-default",
          message: "invalid default value syntax",
          line: s.source[0].number,
          critical: !0
        }), s;
    }
    return s.optional = T, s.name = m, a.name = P, g !== void 0 && (s.default = g), [a.postName, a.description] = A(p.slice(a.name.length)),
    s;
  };
}
r(ue, "nameTokenizer");

// ../node_modules/comment-parser/es6/parser/tokenizers/description.js
function me(n = "compact", s = v) {
  let a = Ue(n);
  return (p) => (p.description = a(p.source, s), p);
}
r(me, "descriptionTokenizer");
function Ue(n) {
  return n === "compact" ? _r : n === "preserve" ? Cr : n;
}
r(Ue, "getJoiner");
function _r(n, s = v) {
  return n.map(({ tokens: { description: a } }) => a.trim()).filter((a) => a !== "").join(" ");
}
r(_r, "compactJoiner");
var Ur = /* @__PURE__ */ r((n, { tokens: s }, a) => s.type === "" ? n : a, "lineNo"), Br = /* @__PURE__ */ r(({ tokens: n }) => (n.delimiter ===
"" ? n.start : n.postDelimiter.slice(1)) + n.description, "getDescription");
function Cr(n, s = v) {
  if (n.length === 0)
    return "";
  n[0].tokens.description === "" && n[0].tokens.delimiter === s.start && (n = n.slice(1));
  let a = n[n.length - 1];
  return a !== void 0 && a.tokens.description === "" && a.tokens.end.endsWith(s.end) && (n = n.slice(0, -1)), n = n.slice(n.reduce(Ur, 0)), n.
  map(Br).join(`
`);
}
r(Cr, "preserveJoiner");

// ../node_modules/comment-parser/es6/parser/index.js
function Be({ startLine: n = 0, fence: s = "```", spacing: a = "compact", markers: p = v, tokenizers: c = [
  ce(),
  le(a),
  ue(),
  me(a)
] } = {}) {
  if (n < 0 || n % 1 > 0)
    throw new Error("Invalid startLine");
  let u = Ve({ startLine: n, markers: p }), m = Le({ fence: s }), T = _e({ tokenizers: c }), g = Ue(a);
  return function(P) {
    let b = [];
    for (let de of ut(P)) {
      let q = u(de);
      if (q === null)
        continue;
      let E = m(q), X = E.slice(1).map(T);
      b.push({
        description: g(E[0], p),
        tags: X,
        source: q,
        problems: X.reduce((Te, ge) => Te.concat(ge.problems), [])
      });
    }
    return b;
  };
}
r(Be, "getParser");

// ../node_modules/comment-parser/es6/stringifier/index.js
function Mr(n) {
  return n.start + n.delimiter + n.postDelimiter + n.tag + n.postTag + n.type + n.postType + n.name + n.postName + n.description + n.end + n.
  lineEnd;
}
r(Mr, "join");
function Ce() {
  return (n) => n.source.map(({ tokens: s }) => Mr(s)).join(`
`);
}
r(Ce, "getStringifier");

// ../node_modules/comment-parser/es6/stringifier/inspect.js
var Kr = {
  line: 0,
  start: 0,
  delimiter: 0,
  postDelimiter: 0,
  tag: 0,
  postTag: 0,
  name: 0,
  postName: 0,
  type: 0,
  postType: 0,
  description: 0,
  end: 0,
  lineEnd: 0
};
var Wo = Object.keys(Kr);

// ../node_modules/comment-parser/es6/index.js
function yt(n, s = {}) {
  return Be(s)(n);
}
r(yt, "parse");
var fs = Ce();

// src/docs-tools/argTypes/jsdocParser.ts
var $ = wr(dt(), 1);
function $r(n) {
  return n != null && n.includes("@");
}
r($r, "containsJsDoc");
function qr(n) {
  let p = `/**
` + (n ?? "").split(`
`).map((u) => ` * ${u}`).join(`
`) + `
*/`, c = yt(p, {
    spacing: "preserve"
  });
  if (!c || c.length === 0)
    throw new Error("Cannot parse JSDoc tags.");
  return c[0];
}
r(qr, "parse");
var Yr = {
  tags: ["param", "arg", "argument", "returns", "ignore", "deprecated"]
}, Tt = /* @__PURE__ */ r((n, s = Yr) => {
  if (!$r(n))
    return {
      includesJsDoc: !1,
      ignore: !1
    };
  let a = qr(n), p = Wr(a, s.tags);
  return p.ignore ? {
    includesJsDoc: !0,
    ignore: !0
  } : {
    includesJsDoc: !0,
    ignore: !1,
    // Always use the parsed description to ensure JSDoc is removed from the description.
    description: a.description.trim(),
    extractedTags: p
  };
}, "parseJsDoc");
function Wr(n, s) {
  let a = {
    params: null,
    deprecated: null,
    returns: null,
    ignore: !1
  };
  for (let p of n.tags)
    if (!(s !== void 0 && !s.includes(p.tag)))
      if (p.tag === "ignore") {
        a.ignore = !0;
        break;
      } else
        switch (p.tag) {
          // arg & argument are aliases for param.
          case "param":
          case "arg":
          case "argument": {
            let c = zr(p);
            c != null && (a.params == null && (a.params = []), a.params.push(c));
            break;
          }
          case "deprecated": {
            let c = Xr(p);
            c != null && (a.deprecated = c);
            break;
          }
          case "returns": {
            let c = Hr(p);
            c != null && (a.returns = c);
            break;
          }
          default:
            break;
        }
  return a;
}
r(Wr, "extractJsDocTags");
function Gr(n) {
  return n.replace(/[\.-]$/, "");
}
r(Gr, "normaliseParamName");
function zr(n) {
  if (!n.name || n.name === "-")
    return null;
  let s = xt(n.type);
  return {
    name: n.name,
    type: s,
    description: ht(n.description),
    getPrettyName: /* @__PURE__ */ r(() => Gr(n.name), "getPrettyName"),
    getTypeName: /* @__PURE__ */ r(() => s ? Jt(s) : null, "getTypeName")
  };
}
r(zr, "extractParam");
function Xr(n) {
  return n.name ? gt(n.name, n.description) : null;
}
r(Xr, "extractDeprecated");
function gt(n, s) {
  let a = n === "" ? s : `${n} ${s}`;
  return ht(a);
}
r(gt, "joinNameAndDescription");
function ht(n) {
  let s = n.replace(/^- /g, "").trim();
  return s === "" ? null : s;
}
r(ht, "normaliseDescription");
function Hr(n) {
  let s = xt(n.type);
  return s ? {
    type: s,
    description: gt(n.name, n.description),
    getTypeName: /* @__PURE__ */ r(() => Jt(s), "getTypeName")
  } : null;
}
r(Hr, "extractReturns");
var L = (0, $.stringifyRules)(), Qr = L.JsdocTypeObject;
L.JsdocTypeAny = () => "any";
L.JsdocTypeObject = (n, s) => `(${Qr(n, s)})`;
L.JsdocTypeOptional = (n, s) => s(n.element);
L.JsdocTypeNullable = (n, s) => s(n.element);
L.JsdocTypeNotNullable = (n, s) => s(n.element);
L.JsdocTypeUnion = (n, s) => n.elements.map(s).join("|");
function xt(n) {
  try {
    return (0, $.parse)(n, "typescript");
  } catch {
    return null;
  }
}
r(xt, "extractType");
function Jt(n) {
  return (0, $.transform)(L, n);
}
r(Jt, "extractTypeName");

// src/docs-tools/argTypes/utils.ts
var bs = 90, Es = 50;
function Ke(n) {
  return n.length > 90;
}
r(Ke, "isTooLongForTypeSummary");
function wt(n) {
  return n.length > 50;
}
r(wt, "isTooLongForDefaultValueSummary");
function J(n, s) {
  return n === s ? { summary: n } : { summary: n, detail: s };
}
r(J, "createSummaryValue");
var Ss = /* @__PURE__ */ r((n) => n.replace(/\\r\\n/g, "\\n"), "normalizeNewlines");

// src/docs-tools/argTypes/docgen/flow/createDefaultValue.ts
function Pt(n, s) {
  if (n != null) {
    let { value: a } = n;
    if (!K(a))
      return wt(a) ? J(s?.name, a) : J(a);
  }
  return null;
}
r(Pt, "createDefaultValue");

// src/docs-tools/argTypes/docgen/flow/createType.ts
function bt({ name: n, value: s, elements: a, raw: p }) {
  return s ?? (a != null ? a.map(bt).join(" | ") : p ?? n);
}
r(bt, "generateUnionElement");
function Zr({ name: n, raw: s, elements: a }) {
  return a != null ? J(a.map(bt).join(" | ")) : s != null ? J(s.replace(/^\|\s*/, "")) : J(n);
}
r(Zr, "generateUnion");
function en({ type: n, raw: s }) {
  return s != null ? J(s) : J(n);
}
r(en, "generateFuncSignature");
function tn({ type: n, raw: s }) {
  return s != null ? Ke(s) ? J(n, s) : J(s) : J(n);
}
r(tn, "generateObjectSignature");
function rn(n) {
  let { type: s } = n;
  return s === "object" ? tn(n) : en(n);
}
r(rn, "generateSignature");
function nn({ name: n, raw: s }) {
  return s != null ? Ke(s) ? J(n, s) : J(s) : J(n);
}
r(nn, "generateDefault");
function Et(n) {
  if (n == null)
    return null;
  switch (n.name) {
    case "union":
      return Zr(n);
    case "signature":
      return rn(n);
    default:
      return nn(n);
  }
}
r(Et, "createType");

// src/docs-tools/argTypes/docgen/flow/createPropDef.ts
var St = /* @__PURE__ */ r((n, s) => {
  let { flowType: a, description: p, required: c, defaultValue: u } = s;
  return {
    name: n,
    type: Et(a),
    required: c,
    description: p,
    defaultValue: Pt(u ?? null, a ?? null)
  };
}, "createFlowPropDef");

// src/docs-tools/argTypes/docgen/typeScript/createDefaultValue.ts
function Nt({ defaultValue: n }) {
  if (n != null) {
    let { value: s } = n;
    if (!K(s))
      return J(s);
  }
  return null;
}
r(Nt, "createDefaultValue");

// src/docs-tools/argTypes/docgen/typeScript/createType.ts
function Dt({ tsType: n, required: s }) {
  if (n == null)
    return null;
  let a = n.name;
  return s || (a = a.replace(" | undefined", "")), J(
    ["Array", "Record", "signature"].includes(n.name) ? n.raw : a
  );
}
r(Dt, "createType");

// src/docs-tools/argTypes/docgen/typeScript/createPropDef.ts
var Ot = /* @__PURE__ */ r((n, s) => {
  let { description: a, required: p } = s;
  return {
    name: n,
    type: Dt(s),
    required: p,
    description: a,
    defaultValue: Nt(s)
  };
}, "createTsPropDef");

// src/docs-tools/argTypes/docgen/createPropDef.ts
function on(n) {
  return n != null ? J(n.name) : null;
}
r(on, "createType");
function sn(n) {
  let { computed: s, func: a } = n;
  return typeof s > "u" && typeof a > "u";
}
r(sn, "isReactDocgenTypescript");
function an(n) {
  return n ? n.name === "string" ? !0 : n.name === "enum" ? Array.isArray(n.value) && n.value.every(
    ({ value: s }) => typeof s == "string" && s[0] === '"' && s[s.length - 1] === '"'
  ) : !1 : !1;
}
r(an, "isStringValued");
function pn(n, s) {
  if (n != null) {
    let { value: a } = n;
    if (!K(a))
      return sn(n) && an(s) ? J(JSON.stringify(a)) : J(a);
  }
  return null;
}
r(pn, "createDefaultValue");
function vt(n, s, a) {
  let { description: p, required: c, defaultValue: u } = a;
  return {
    name: n,
    type: on(s),
    required: c,
    description: p,
    defaultValue: pn(u, s)
  };
}
r(vt, "createBasicPropDef");
function fe(n, s) {
  if (s?.includesJsDoc) {
    let { description: a, extractedTags: p } = s;
    a != null && (n.description = s.description);
    let c = {
      ...p,
      params: p?.params?.map(
        (u) => ({
          name: u.getPrettyName(),
          description: u.description
        })
      )
    };
    Object.values(c).filter(Boolean).length > 0 && (n.jsDocTags = c);
  }
  return n;
}
r(fe, "applyJsDocResult");
var cn = /* @__PURE__ */ r((n, s, a) => {
  let p = vt(n, s.type, s);
  return p.sbType = pe(s), fe(p, a);
}, "javaScriptFactory"), ln = /* @__PURE__ */ r((n, s, a) => {
  let p = Ot(n, s);
  return p.sbType = pe(s), fe(p, a);
}, "tsFactory"), un = /* @__PURE__ */ r((n, s, a) => {
  let p = St(n, s);
  return p.sbType = pe(s), fe(p, a);
}, "flowFactory"), mn = /* @__PURE__ */ r((n, s, a) => {
  let p = vt(n, { name: "unknown" }, s);
  return fe(p, a);
}, "unknownFactory"), $e = /* @__PURE__ */ r((n) => {
  switch (n) {
    case "JavaScript":
      return cn;
    case "TypeScript":
      return ln;
    case "Flow":
      return un;
    default:
      return mn;
  }
}, "getPropDefFactory");

// src/docs-tools/argTypes/docgen/extractDocgenProps.ts
var kt = /* @__PURE__ */ r((n) => n.type != null ? "JavaScript" : n.flowType != null ? "Flow" : n.tsType != null ? "TypeScript" : "Unknown",
"getTypeSystem"), yn = /* @__PURE__ */ r((n) => {
  let s = kt(n[0]), a = $e(s);
  return n.map((p) => {
    let c = p;
    return p.type?.elements && (c = {
      ...p,
      type: {
        ...p.type,
        value: p.type.elements
      }
    }), At(c.name, c, s, a);
  });
}, "extractComponentSectionArray"), fn = /* @__PURE__ */ r((n) => {
  let s = Object.keys(n), a = kt(n[s[0]]), p = $e(a);
  return s.map((c) => {
    let u = n[c];
    return u != null ? At(c, u, a, p) : null;
  }).filter(Boolean);
}, "extractComponentSectionObject"), aa = /* @__PURE__ */ r((n, s) => {
  let a = pt(n, s);
  return it(a) ? Array.isArray(a) ? yn(a) : fn(a) : [];
}, "extractComponentProps");
function At(n, s, a, p) {
  let c = Tt(s.description);
  return c.includesJsDoc && c.ignore ? null : {
    propDef: p(n, s, c),
    jsDocTags: c.extractedTags,
    docgenInfo: s,
    typeSystem: a
  };
}
r(At, "extractProp");
function ia(n) {
  return n != null ? ct(n) : "";
}
r(ia, "extractComponentDescription");

// src/preview-api/modules/store/parameters.ts
var qe = /* @__PURE__ */ r((...n) => {
  let s = {}, a = n.filter(Boolean), p = a.reduce((c, u) => (Object.entries(u).forEach(([m, T]) => {
    let g = c[m];
    Array.isArray(T) || typeof g > "u" ? c[m] = T : z(T) && z(g) ? s[m] = !0 : typeof T < "u" && (c[m] = T);
  }), c), {});
  return Object.keys(s).forEach((c) => {
    let u = a.filter(Boolean).map((m) => m[c]).filter((m) => typeof m < "u");
    u.every((m) => z(m)) ? p[c] = qe(...u) : p[c] = u[u.length - 1];
  }), p;
}, "combineParameters");

// src/docs-tools/argTypes/enhanceArgTypes.ts
var fa = /* @__PURE__ */ r((n) => {
  let {
    component: s,
    argTypes: a,
    parameters: { docs: p = {} }
  } = n, { extractArgTypes: c } = p, u = c && s ? c(s) : {};
  return u ? qe(u, a) : a;
}, "enhanceArgTypes");

// src/docs-tools/shared.ts
var Rt = "storybook/docs", ga = `${Rt}/panel`, ha = "docs", xa = `${Rt}/snippet-rendered`, dn = /* @__PURE__ */ ((p) => (p.AUTO = "auto", p.
CODE = "code", p.DYNAMIC = "dynamic", p))(dn || {});

// src/docs-tools/hasDocsOrControls.ts
var Tn = /(addons\/|addon-|addon-essentials\/)(docs|controls)/, wa = /* @__PURE__ */ r((n) => n.presetsList?.some((s) => Tn.test(s.name)), "\
hasDocsOrControls");
export {
  Rt as ADDON_ID,
  Es as MAX_DEFAULT_VALUE_SUMMARY_LENGTH,
  bs as MAX_TYPE_SUMMARY_LENGTH,
  ga as PANEL_ID,
  ha as PARAM_KEY,
  xa as SNIPPET_RENDERED,
  dn as SourceType,
  Ar as TypeSystem,
  pe as convert,
  J as createSummaryValue,
  fa as enhanceArgTypes,
  ia as extractComponentDescription,
  aa as extractComponentProps,
  yn as extractComponentSectionArray,
  fn as extractComponentSectionObject,
  ct as getDocgenDescription,
  pt as getDocgenSection,
  at as hasDocgen,
  wa as hasDocsOrControls,
  K as isDefaultValueBlacklisted,
  wt as isTooLongForDefaultValueSummary,
  Ke as isTooLongForTypeSummary,
  it as isValidDocgenSection,
  Ss as normalizeNewlines,
  Tt as parseJsDoc,
  st as str
};
