import { c as create_ssr_component, v as validate_component, f as escape, l as each } from "../../../_app/immutable/chunks/index-27250121.js";
import { isScalarType, isEnumType, isInterfaceType, isUnionType, isObjectType, isInputObjectType } from "graphql";
import { A as AnchorHeader, C as CarbonMarkdown, S as StructuredList, c as StructuredListBody, d as StructuredListRow, e as StructuredListCell, f as ListItem, g as AppList, P as PreviousNextPage } from "../../../_app/immutable/chunks/PreviousNextPage-aa1b7b9e.js";
import { T as TypeTag, F as FiedsList, a as TypeEnumeration, A as AppExpandButton, O as ObjectType } from "../../../_app/immutable/chunks/ObjectType-ef80b091.js";
import { D as DeprecatedTag, a as TypeLinkTag, N as NullableTag, b as DefaultValueDisplay, T as TypeLink } from "../../../_app/immutable/chunks/ArgsList-5cf1bc5a.js";
import { s as schema, n as getTypeByName, o as getTypeUsages, f as findPageByHref } from "../../../_app/immutable/chunks/pages-a57618e2.js";
import _ from "lodash";
import { ReferenceKind } from "@magidoc/plugin-reverse-schema-mapper";
import "../../../_app/immutable/chunks/paths-b9644fda.js";
import "@magidoc/plugin-starter-variables";
const ScalarType = create_ssr_component(($$result, $$props, $$bindings, slots) => {
  let { type } = $$props;
  if ($$props.type === void 0 && $$bindings.type && type !== void 0)
    $$bindings.type(type);
  return `<section>${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "title", depth: 1 }, {}, {
    default: () => {
      return `${escape(type.name)}
    ${validate_component(TypeTag, "TypeTag").$$render($$result, { type }, {}, {})}`;
    }
  })}

  ${validate_component(CarbonMarkdown, "CarbonMarkdown").$$render($$result, { source: type.description }, {}, {})}</section>`;
});
const EnumType = create_ssr_component(($$result, $$props, $$bindings, slots) => {
  let { type } = $$props;
  if ($$props.type === void 0 && $$bindings.type && type !== void 0)
    $$bindings.type(type);
  return `<section>${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "title", depth: 1 }, {}, {
    default: () => {
      return `${escape(type.name)}
    ${validate_component(TypeTag, "TypeTag").$$render($$result, { type }, {}, {})}`;
    }
  })}

  ${validate_component(CarbonMarkdown, "CarbonMarkdown").$$render($$result, { source: type.description }, {}, {})}

  ${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "possible-values", depth: 2 }, {}, {
    default: () => {
      return `Possible Values`;
    }
  })}

  ${validate_component(StructuredList, "StructuredList").$$render($$result, { condensed: true }, {}, {
    default: () => {
      return `${validate_component(StructuredListBody, "StructuredListBody").$$render($$result, {}, {}, {
        default: () => {
          return `${each(type.getValues(), (value) => {
            return `${validate_component(StructuredListRow, "StructuredListRow").$$render($$result, {}, {}, {
              default: () => {
                return `${validate_component(StructuredListCell, "StructuredListCell").$$render($$result, {}, {}, {
                  default: () => {
                    return `<p><span style="${"font-weight: bold"}">${escape(value.name)}</span>
              ${validate_component(DeprecatedTag, "DeprecatedTag").$$render($$result, { reason: value.deprecationReason }, {}, {})}</p>
            ${value.description ? `<p>${escape(value.description)}</p>` : ``}
          `;
                  }
                })}
        `;
              }
            })}`;
          })}`;
        }
      })}`;
    }
  })}</section>`;
});
const InterfaceType = create_ssr_component(($$result, $$props, $$bindings, slots) => {
  let { type } = $$props;
  let implementations;
  if ($$props.type === void 0 && $$bindings.type && type !== void 0)
    $$bindings.type(type);
  implementations = schema.getPossibleTypes(type);
  return `<section>${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "title", depth: 1 }, {}, {
    default: () => {
      return `${escape(type.name)}
    ${validate_component(TypeTag, "TypeTag").$$render($$result, { type }, {}, {})}`;
    }
  })}
  ${validate_component(CarbonMarkdown, "CarbonMarkdown").$$render($$result, { source: type.description }, {}, {})}

  ${Object.keys(type.getFields()).length > 0 ? `${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "fields", depth: 2 }, {}, {
    default: () => {
      return `Fields`;
    }
  })}
    ${validate_component(FiedsList, "FiedsTable").$$render(
    $$result,
    {
      data: _.map(type.getFields(), (arg) => arg)
    },
    {},
    {}
  )}` : ``}

  ${implementations.length > 0 ? `${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "implementations", depth: 2 }, {}, {
    default: () => {
      return `Implementations
    `;
    }
  })}
    Implemented by ${validate_component(TypeEnumeration, "TypeEnumeration").$$render($$result, { types: implementations }, {}, {})}.` : ``}

  ${type.getInterfaces().length > 0 ? `${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "interfaces", depth: 2 }, {}, {
    default: () => {
      return `Interfaces`;
    }
  })}
    <p>Also implements ${validate_component(TypeEnumeration, "TypeEnumeration").$$render($$result, { types: type.getInterfaces() }, {}, {})}.
    </p>` : ``}</section>`;
});
const UnionType = create_ssr_component(($$result, $$props, $$bindings, slots) => {
  let { type } = $$props;
  if ($$props.type === void 0 && $$bindings.type && type !== void 0)
    $$bindings.type(type);
  return `<section>${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "title", depth: 1 }, {}, {
    default: () => {
      return `${escape(type.name)}
    ${validate_component(TypeTag, "TypeTag").$$render($$result, { type }, {}, {})}`;
    }
  })}

  ${validate_component(CarbonMarkdown, "CarbonMarkdown").$$render($$result, { source: type.description }, {}, {})}

  ${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "types", depth: 2 }, {}, {
    default: () => {
      return `Types`;
    }
  })}

  <p>Union of types ${validate_component(TypeEnumeration, "TypeEnumeration").$$render($$result, { types: type.getTypes() }, {}, {})}.
  </p></section>`;
});
const InputFieldsList = create_ssr_component(($$result, $$props, $$bindings, slots) => {
  let items;
  let { data } = $$props;
  if ($$props.data === void 0 && $$bindings.data && data !== void 0)
    $$bindings.data(data);
  items = _.sortBy(
    data.map((arg) => ({
      id: arg.name,
      deprecationReason: arg.deprecationReason,
      name: arg.name,
      type: arg.type,
      description: arg.description,
      default: arg.defaultValue
    })),
    (item) => item.name
  ) || [];
  return `${validate_component(StructuredList, "StructuredList").$$render($$result, { condensed: true }, {}, {
    default: () => {
      return `${validate_component(StructuredListBody, "StructuredListBody").$$render($$result, {}, {}, {
        default: () => {
          return `${each(items, (item) => {
            return `${validate_component(StructuredListRow, "StructuredListRow").$$render($$result, {}, {}, {
              default: () => {
                return `${validate_component(StructuredListCell, "StructuredListCell").$$render($$result, {}, {}, {
                  default: () => {
                    return `<p><span style="${"font-weight: bold"}">${escape(item.name)}</span>
            ${validate_component(TypeLinkTag, "TypeLinkTag").$$render($$result, { type: item.type }, {}, {})}
            ${validate_component(DeprecatedTag, "DeprecatedTag").$$render($$result, { reason: item.deprecationReason }, {}, {})}
            ${validate_component(NullableTag, "NullableTag").$$render($$result, { type: item.type }, {}, {})}</p>
          ${item.description ? `<p>${escape(item.description)}</p>` : ``}
          ${item.default ? `Default: ${validate_component(DefaultValueDisplay, "DefaultValueDisplay").$$render($$result, { value: item.default }, {}, {})}` : ``}
        `;
                  }
                })}
      `;
              }
            })}`;
          })}`;
        }
      })}`;
    }
  })}`;
});
const InputObjectType = create_ssr_component(($$result, $$props, $$bindings, slots) => {
  let { type } = $$props;
  if ($$props.type === void 0 && $$bindings.type && type !== void 0)
    $$bindings.type(type);
  return `<section>${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "title", depth: 1 }, {}, {
    default: () => {
      return `${escape(type.name)}
    ${validate_component(TypeTag, "TypeTag").$$render($$result, { type }, {}, {})}`;
    }
  })}

  ${validate_component(CarbonMarkdown, "CarbonMarkdown").$$render($$result, { source: type.description }, {}, {})}

  ${Object.keys(type.getFields()).length > 0 ? `${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "fields", depth: 2 }, {}, {
    default: () => {
      return `Fields`;
    }
  })}
    ${validate_component(InputFieldsList, "InputFieldsTable").$$render(
    $$result,
    {
      data: _.map(type.getFields(), (item) => item)
    },
    {},
    {}
  )}` : ``}</section>`;
});
const AppListItem_svelte_svelte_type_style_lang = "";
const css = {
  code: ".markdown-list-item{margin-top:0.5rem;margin-bottom:0.5rem}",
  map: null
};
const AppListItem = create_ssr_component(($$result, $$props, $$bindings, slots) => {
  $$result.css.add(css);
  return `${validate_component(ListItem, "ListItem").$$render($$result, { class: "markdown-list-item" }, {}, {
    default: () => {
      return `${slots.default ? slots.default({}) : ``}`;
    }
  })}`;
});
const TypeUsagePreview = create_ssr_component(($$result, $$props, $$bindings, slots) => {
  let { items } = $$props;
  let expanded = false;
  if ($$props.items === void 0 && $$bindings.items && items !== void 0)
    $$bindings.items(items);
  let $$settled;
  let $$rendered;
  do {
    $$settled = true;
    $$rendered = `${expanded ? `${each(items, (_2, index) => {
      return `${slots.default ? slots.default({ index }) : ``}`;
    })}` : `${each(items.slice(0, 3), (_2, index) => {
      return `${slots.default ? slots.default({ index }) : ``}`;
    })}`}

${items.length > 3 ? `${validate_component(AppExpandButton, "AppExpandButton").$$render(
      $$result,
      {
        totalItems: items.length,
        collapsedText: "Show more",
        expandedText: "Show less",
        expanded
      },
      {
        expanded: ($$value) => {
          expanded = $$value;
          $$settled = false;
        }
      },
      {}
    )}` : ``}`;
  } while (!$$settled);
  return $$rendered;
});
const TypeUsages = create_ssr_component(($$result, $$props, $$bindings, slots) => {
  let { usages } = $$props;
  if ($$props.usages === void 0 && $$bindings.usages && usages !== void 0)
    $$bindings.usages(usages);
  return `${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "usages", depth: 2 }, {}, {
    default: () => {
      return `Usages`;
    }
  })}
${validate_component(AnchorHeader, "AnchorHeader").$$render($$result, { id: "references", depth: 4 }, {}, {
    default: () => {
      return `References`;
    }
  })}
${validate_component(TypeUsagePreview, "TypeUsagePreview").$$render($$result, { items: usages.references }, {}, {
    default: ({ index }) => {
      return `${validate_component(AppList, "AppList").$$render($$result, {}, {}, {
        default: () => {
          let item = usages.references[index];
          return `${validate_component(AppListItem, "AppListItem").$$render($$result, {}, {}, {
            default: () => {
              return `${item.kind === ReferenceKind.UNION && item.by ? `Part of union ${validate_component(TypeLink, "TypeLink").$$render($$result, { type: item.by }, {}, {})}` : `${item.kind === ReferenceKind.FIELD ? `Field <em>${escape(item.by.name)}</em> from ${validate_component(TypeLink, "TypeLink").$$render($$result, { type: item.parent }, {}, {})}` : `${item.kind === ReferenceKind.ARGUMENT ? `Argument <em>${escape(item.by.name)}</em> of field <em>${escape(item.field.name)}</em>
        from type ${validate_component(TypeLink, "TypeLink").$$render($$result, { type: item.type }, {}, {})}` : ``}`}`}`;
            }
          })}`;
        }
      })}`;
    }
  })}`;
});
function load({ params, url }) {
  const type = getTypeByName(params.type);
  const usages = getTypeUsages(type);
  const page = findPageByHref(url.pathname);
  if (!type || !page) {
    return {
      status: 404,
      error: `Type ${params.type} not found.`
    };
  }
  return { props: { type, usages, page } };
}
const U5Btypeu5D = create_ssr_component(($$result, $$props, $$bindings, slots) => {
  let { type } = $$props;
  let { usages } = $$props;
  let { page } = $$props;
  if ($$props.type === void 0 && $$bindings.type && type !== void 0)
    $$bindings.type(type);
  if ($$props.usages === void 0 && $$bindings.usages && usages !== void 0)
    $$bindings.usages(usages);
  if ($$props.page === void 0 && $$bindings.page && page !== void 0)
    $$bindings.page(page);
  return `${$$result.head += `${$$result.title = `<title>Type - ${escape(type.name)}</title>`, ""}`, ""}

${isScalarType(type) ? `${validate_component(ScalarType, "ScalarType").$$render($$result, { type }, {}, {})}` : `${isEnumType(type) ? `${validate_component(EnumType, "EnumType").$$render($$result, { type }, {}, {})}` : `${isInterfaceType(type) ? `${validate_component(InterfaceType, "InterfaceType").$$render($$result, { type }, {}, {})}` : `${isUnionType(type) ? `${validate_component(UnionType, "UnionType").$$render($$result, { type }, {}, {})}` : `${isObjectType(type) ? `${validate_component(ObjectType, "ObjectType").$$render($$result, { type }, {}, {})}` : `${isInputObjectType(type) ? `${validate_component(InputObjectType, "InputObjectType").$$render($$result, { type }, {}, {})}` : ``}`}`}`}`}`}

${usages ? `${validate_component(TypeUsages, "TypeUsages").$$render($$result, { usages }, {}, {})}` : ``}

${validate_component(PreviousNextPage, "PreviousNextPage").$$render($$result, { page }, {}, {})}`;
});
export {
  U5Btypeu5D as default,
  load
};
