@mintlify/msft-sdk 1.1.33 → 1.1.36

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import "react/jsx-runtime";
2
- const t = (e) => e.type === "enum<integer>" || e.type === "enum<number>" || e.type === "enum<string>";
2
+ import "@mintlify/validation";
3
+ const r = (t) => t.type === "enum<integer>" || t.type === "enum<number>" || t.type === "enum<string>";
3
4
  export {
4
- t as isEnum
5
+ r as isEnum
5
6
  };
6
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../../src/api-playground/EndpointFields/ParamFields/PrimitiveParamField/index.tsx"],"sourcesContent":["\nimport {\n AnySchema,\n BooleanSchema,\n DataSchema,\n DataSchemaArray,\n FileSchema,\n IncrementalDataSchema,\n IncrementalDataSchemaArray,\n NullSchema,\n NumberEnumSchema,\n NumberSchema,\n StringEnumSchema,\n StringSchema,\n} from '@mintlify/validation';\n\nimport { ParamHead } from '@/components/Api/Param';\nimport { cn } from '@/api-playground-2/schemaGraph/utils';\n\nimport { Description } from '../../components/Description';\nimport { ExampleDescription } from '../ExampleDescription';\nimport { EnumConstTable, EnumOptions } from './Enum';\nimport { NumberMetadata } from './NumberMetadata';\nimport { StringMetadata } from './StringMetadata';\nimport { FieldType } from '@/api-playground-2/types/api';\n\nexport type PrimitiveParamFieldParams = {\n fieldType: FieldType;\n schema:\n | BooleanSchema\n | StringSchema\n | NumberSchema\n | StringEnumSchema\n | NumberEnumSchema\n | FileSchema\n | NullSchema\n | AnySchema;\n schemaArray?: DataSchemaArray | IncrementalDataSchemaArray;\n typeOptions: string[];\n name?: string | null;\n location?: string;\n selectedIndex?: number;\n onSelectTypeOption?: (index: number) => void;\n parentName?: string;\n paramId?: string;\n style?: string;\n explode?: boolean;\n};\n\nexport const PrimitiveParamField = ({\n fieldType,\n schema,\n schemaArray,\n name,\n location,\n typeOptions,\n selectedIndex,\n onSelectTypeOption,\n parentName,\n paramId,\n style,\n explode,\n}: PrimitiveParamFieldParams) => {\n const typeLabel = typeOptions[selectedIndex ?? 0];\n\n const description =\n schema.description ??\n (name === undefined ? `The ${fieldType} is of type \\`${typeLabel}\\`.` : undefined);\n\n return (\n <div className=\"mint:py-6\">\n <ParamHead\n id={paramId}\n name={name}\n typeLabel={typeLabel}\n location={location}\n fieldType={fieldType}\n required={schema.required}\n deprecated={schema.deprecated}\n defaultValue={schema.default}\n typeOptions={typeOptions}\n selectedTypeOptionIndex={selectedIndex}\n onSelectTypeOption={onSelectTypeOption}\n parentName={parentName}\n style={style}\n explode={explode}\n />\n <div className={cn({ 'mint:mt-4': description || isEnum(schema) })}>\n {description && <Description markdown={description} />}\n {schemaArray && isEnumWithConsts(schemaArray) ? (\n <EnumConstTable schemaArray={schemaArray} />\n ) : (\n isEnum(schema) && <EnumOptions schema={schema} />\n )}\n {isStringSchema(schema) && <StringMetadata schema={schema} description={description} />}\n {isNumberSchema(schema) && <NumberMetadata schema={schema} />}\n <ExampleDescription schema={schema} />\n </div>\n </div>\n );\n};\n\nexport const isEnum = (\n schema: DataSchema | IncrementalDataSchema\n): schema is NumberEnumSchema | StringEnumSchema => {\n return (\n schema.type === 'enum<integer>' ||\n schema.type === 'enum<number>' ||\n schema.type === 'enum<string>'\n );\n};\n\nexport const isEnumWithConsts = (\n schemaArray?: DataSchemaArray | IncrementalDataSchemaArray\n): boolean => {\n if (!schemaArray) return false;\n return schemaArray.some((schema) => isEnum(schema) && 'const' in schema);\n};\n\nconst isStringSchema = (schema: DataSchema | IncrementalDataSchema): schema is StringSchema => {\n return schema.type === 'string';\n};\n\nconst isNumberSchema = (schema: DataSchema | IncrementalDataSchema): schema is NumberSchema => {\n return schema.type === 'number' || schema.type === 'integer';\n};\n"],"names":["isEnum","schema"],"mappings":";AAsGO,MAAMA,IAAS,CACpBC,MAGEA,EAAO,SAAS,mBAChBA,EAAO,SAAS,kBAChBA,EAAO,SAAS;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../../src/api-playground/EndpointFields/ParamFields/PrimitiveParamField/index.tsx"],"sourcesContent":["\nimport {\n AnySchema,\n BooleanSchema,\n DataSchema,\n DataSchemaArray,\n FileSchema,\n IncrementalDataSchema,\n IncrementalDataSchemaArray,\n NullSchema,\n NumberEnumSchema,\n NumberSchema,\n StringEnumSchema,\n StringSchema,\n} from '@mintlify/validation';\n\nimport { ParamHead } from '@/components/Api/Param';\nimport { cn } from '@/api-playground-2/schemaGraph/utils';\n\nimport { Description } from '../../components/Description';\nimport { ExampleDescription } from '../ExampleDescription';\nimport { EnumConstTable, EnumOptions } from './Enum';\nimport { NumberMetadata } from './NumberMetadata';\nimport { StringMetadata } from './StringMetadata';\nimport { FieldType } from '@/api-playground-2/types/api';\n\nexport type PrimitiveParamFieldParams = {\n fieldType: FieldType;\n schema:\n | BooleanSchema\n | StringSchema\n | NumberSchema\n | StringEnumSchema\n | NumberEnumSchema\n | FileSchema\n | NullSchema\n | AnySchema;\n schemaArray?: DataSchemaArray | IncrementalDataSchemaArray;\n typeOptions: string[];\n name?: string | null;\n location?: string;\n selectedIndex?: number;\n onSelectTypeOption?: (index: number) => void;\n parentName?: string;\n paramId?: string;\n style?: string;\n explode?: boolean;\n};\n\nexport const PrimitiveParamField = ({\n fieldType,\n schema,\n schemaArray,\n name,\n location,\n typeOptions,\n selectedIndex,\n onSelectTypeOption,\n parentName,\n paramId,\n style,\n explode,\n}: PrimitiveParamFieldParams) => {\n const typeLabel = typeOptions[selectedIndex ?? 0];\n\n const description =\n schema.description ??\n (name === undefined ? `The ${fieldType} is of type \\`${typeLabel}\\`.` : undefined);\n\n return (\n <div className=\"mint:py-6\">\n <ParamHead\n id={paramId}\n name={name}\n typeLabel={typeLabel}\n location={location}\n fieldType={fieldType}\n required={schema.required}\n deprecated={schema.deprecated}\n defaultValue={schema.default}\n typeOptions={typeOptions}\n selectedTypeOptionIndex={selectedIndex}\n onSelectTypeOption={onSelectTypeOption}\n parentName={parentName}\n style={style}\n explode={explode}\n />\n <div className={cn({ 'mint:mt-4': description || isEnum(schema) })}>\n {description && <Description markdown={description} />}\n {schemaArray && isEnumWithConsts(schemaArray) ? (\n <EnumConstTable schemaArray={schemaArray} />\n ) : (\n isEnum(schema) && <EnumOptions schema={schema} />\n )}\n {isStringSchema(schema) && <StringMetadata schema={schema} description={description} />}\n {isNumberSchema(schema) && <NumberMetadata schema={schema} />}\n <ExampleDescription schema={schema} />\n </div>\n </div>\n );\n};\n\nexport const isEnum = (\n schema: DataSchema | IncrementalDataSchema\n): schema is NumberEnumSchema | StringEnumSchema => {\n return (\n schema.type === 'enum<integer>' ||\n schema.type === 'enum<number>' ||\n schema.type === 'enum<string>'\n );\n};\n\nexport const isEnumWithConsts = (\n schemaArray?: DataSchemaArray | IncrementalDataSchemaArray\n): boolean => {\n if (!schemaArray) return false;\n return schemaArray.some((schema) => isEnum(schema) && 'const' in schema);\n};\n\nconst isStringSchema = (schema: DataSchema | IncrementalDataSchema): schema is StringSchema => {\n return schema.type === 'string';\n};\n\nconst isNumberSchema = (schema: DataSchema | IncrementalDataSchema): schema is NumberSchema => {\n return schema.type === 'number' || schema.type === 'integer';\n};\n"],"names":["isEnum","schema"],"mappings":";;AAsGO,MAAMA,IAAS,CACpBC,MAGEA,EAAO,SAAS,mBAChBA,EAAO,SAAS,kBAChBA,EAAO,SAAS;"}
@@ -1,14 +1,13 @@
1
1
  import "react/jsx-runtime";
2
- import i from "@sindresorhus/slugify";
3
- import "../../../contexts/EndpointLocationContext.js";
4
- const s = (r, t, e, $) => i(
5
- `${r ? `${r}-` : ""}${e ? `${e}-` : ""}${t || ""}-`,
2
+ import $ from "@sindresorhus/slugify";
3
+ const c = (r, e, t, i) => $(
4
+ `${r ? `${r}-` : ""}${t ? `${t}-` : ""}${e || ""}-`,
6
5
  {
7
6
  decamelize: !0
8
7
  }
9
- ), m = (r, t) => r ? `${t ? `${t}` : ""}${r}.` : "";
8
+ ), s = (r, e) => r ? `${e ? `${e}` : ""}${r}.` : "";
10
9
  export {
11
- s as buildRecursiveParamFieldId,
12
- m as getRecursiveParentName
10
+ c as buildRecursiveParamFieldId,
11
+ s as getRecursiveParentName
13
12
  };
14
13
  //# sourceMappingURL=RecursiveParamField.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"RecursiveParamField.js","sources":["../../../../src/api-playground/EndpointFields/ParamFields/RecursiveParamField.tsx"],"sourcesContent":["\nimport { DataSchema, DataSchemaArray, IncrementalDataSchemaArray } from '@mintlify/validation';\nimport slugify from '@sindresorhus/slugify';\n\nimport { useEndpointLocation } from '@/contexts/EndpointLocationContext';\nimport { getConstFilteredSchemaArray } from '@/openapi/filterEnums';\nimport {\n getAuthFilteredSchemaArray,\n isDataSchemaArrayOrIncrementalDataSchemaArray,\n} from '@/openapi/getAuthFilteredSchemaArray';\nimport { getNextPropertiesByType } from '@/utils/api-reference/getNextPropertiesByType';\n\nimport { RecursiveParamFieldWithChildrenObserver } from './RecursiveParamFieldWithChildrenObserver';\nimport { RecursiveParamFieldWithObserver } from './RecursiveParamFieldWithObserver';\nimport { FieldType, RenderedRefs } from '@/api-playground-2/types/api';\n\nexport type RecursiveParamFieldParams = {\n fieldType: FieldType;\n schemaArray: DataSchemaArray | IncrementalDataSchemaArray;\n renderedRefs?: RenderedRefs;\n name?: string | null;\n location?: string;\n parentName?: string;\n depth?: number;\n hideDescription?: boolean;\n circularRefs?: string[];\n paramId?: string;\n style?: string;\n explode?: boolean;\n};\n\nexport const RecursiveParamField = ({\n fieldType,\n schemaArray,\n name,\n location,\n parentName,\n depth = 0,\n hideDescription = false,\n renderedRefs = new Set(),\n circularRefs,\n paramId,\n style,\n explode,\n}: RecursiveParamFieldParams) => {\n const { anchor } = useEndpointLocation();\n let filteredSchemaArray: DataSchemaArray | IncrementalDataSchemaArray | null = schemaArray;\n filteredSchemaArray = getAuthFilteredSchemaArray({ schemaArray, userGroups: undefined });\n\n if (\n filteredSchemaArray &&\n filteredSchemaArray.some((schema) => 'enum' in schema && 'const' in schema)\n ) {\n filteredSchemaArray = getConstFilteredSchemaArray({ schemaArray });\n }\n\n if (!isDataSchemaArrayOrIncrementalDataSchemaArray(filteredSchemaArray)) {\n return null;\n }\n\n const RecursiveParamFieldType = anchor\n ? RecursiveParamFieldWithChildrenObserver\n : RecursiveParamFieldWithObserver;\n\n return (\n <RecursiveParamFieldType\n fieldType={fieldType}\n schemaArray={filteredSchemaArray}\n name={name}\n location={location}\n parentName={parentName}\n depth={depth}\n style={style}\n explode={explode}\n hideDescription={hideDescription}\n renderedRefs={renderedRefs}\n circularRefs={circularRefs}\n paramId={paramId}\n />\n );\n};\n\ntype RenderNextPropertiesRecursivelyParams = {\n properties: [string, DataSchemaArray | IncrementalDataSchemaArray][];\n fieldType: FieldType;\n depth: number;\n refs: Set<string>;\n parentName?: string;\n name?: string | null;\n currentSchemaRef: string | undefined;\n style?: string;\n explode?: boolean;\n hideParentName?: boolean;\n};\n\nexport const renderNextPropertiesRecursively = ({\n currentSchemaRef,\n properties,\n fieldType,\n parentName,\n name,\n depth,\n refs,\n style,\n explode,\n hideParentName,\n}: RenderNextPropertiesRecursivelyParams) => {\n // Create a new set with the current refs for this level\n const currentLevelRefs = new Set(refs);\n\n if (currentSchemaRef) {\n currentLevelRefs.add(currentSchemaRef);\n }\n\n if (currentLevelRefs.size > 0) {\n return properties.map((property) => {\n const [propertyName, schemaArray] = property;\n const nextSchemaArray = schemaArray[0];\n const nextSchemaArrayProperties = getNextPropertiesByType(nextSchemaArray);\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName, propertyName);\n const passedName = hideParentName ? '' : name;\n let circularReferences: string[] = [];\n if (\n Object.values(nextSchemaArrayProperties).some(\n (value: unknown) => typeof value === 'string' && currentLevelRefs.has(value)\n )\n ) {\n circularReferences = Object.values(nextSchemaArrayProperties).filter(\n (value: unknown) => typeof value === 'string' && currentLevelRefs.has(value)\n );\n }\n return (\n <RecursiveParamField\n paramId={paramId}\n fieldType={fieldType}\n key={propertyName}\n schemaArray={schemaArray}\n name={propertyName}\n parentName={\n style === 'deepObject' && explode\n ? getDeepObjectParentName(passedName, parentName)\n : getRecursiveParentName(passedName, parentName)\n }\n depth={depth + 1}\n renderedRefs={new Set(currentLevelRefs)}\n circularRefs={circularReferences}\n style={style}\n explode={explode}\n />\n );\n });\n } else {\n return properties.map(([propertyName, schemaArray]) => {\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName, propertyName);\n const passedName = hideParentName ? '' : name;\n return (\n <RecursiveParamField\n paramId={paramId}\n fieldType={fieldType}\n key={propertyName}\n schemaArray={schemaArray}\n name={propertyName}\n parentName={\n style === 'deepObject' && explode\n ? getDeepObjectParentName(passedName, parentName)\n : getRecursiveParentName(passedName, parentName)\n }\n depth={depth + 1}\n renderedRefs={new Set()}\n style={style}\n explode={explode}\n />\n );\n });\n }\n};\n\ntype RenderTruncatedNextPropertiesParams = {\n properties: [string, DataSchemaArray | IncrementalDataSchemaArray][];\n fieldType: FieldType;\n parentName?: string;\n name?: string | null;\n depth: number;\n};\n\nexport const renderTruncatedNextProperties = ({\n properties,\n fieldType,\n parentName,\n name,\n depth,\n}: RenderTruncatedNextPropertiesParams) => {\n return properties.map((property) => {\n const [propertyName, schemaArray] = property;\n const nextSchemaArray = schemaArray[0];\n const baseSchema: DataSchema = nextSchemaArray as DataSchema;\n if (baseSchema.type === 'array') {\n baseSchema.items = [{ type: 'any' }];\n } else if (baseSchema.type === 'object') {\n baseSchema.properties = {};\n }\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName);\n const id = `${paramId}-${propertyName}`;\n return (\n <RecursiveParamField\n fieldType={fieldType}\n key={propertyName}\n schemaArray={[baseSchema]}\n name={propertyName}\n paramId={id}\n depth={depth + 1}\n renderedRefs={new Set()}\n />\n );\n });\n};\n\nexport const buildRecursiveParamFieldId = (\n fieldType: FieldType | undefined,\n name: string | undefined | null,\n parentName: string | undefined,\n propertyName?: string | undefined\n) => {\n return slugify(\n `${fieldType ? `${fieldType}-` : ''}${parentName ? `${parentName}-` : ''}${name ? name : ''}-${propertyName ? propertyName : ''}`,\n {\n decamelize: true,\n }\n );\n};\n\nexport const getRecursiveParentName = (name?: string | null, parentName?: string): string => {\n if (!name) {\n return '';\n }\n\n return `${parentName ? `${parentName}` : ''}${name}.`;\n};\n\nexport const getDeepObjectParentName = (name?: string | null, parentName?: string): string => {\n if (!name) {\n return '';\n }\n\n return parentName ? `${parentName}${name}][` : `${name}[`;\n};\n"],"names":["buildRecursiveParamFieldId","fieldType","name","parentName","propertyName","slugify","getRecursiveParentName"],"mappings":";;;AAyNO,MAAMA,IAA6B,CACxCC,GACAC,GACAC,GACAC,MAEOC;AAAA,EACL,GAAGJ,IAAY,GAAGA,CAAS,MAAM,EAAE,GAAGE,IAAa,GAAGA,CAAU,MAAM,EAAE,GAAGD,KAAc,EAAE;AAAA,EAC3F;AAAA,IACE,YAAY;AAAA,EAAA;AACd,GAISI,IAAyB,CAACJ,GAAsBC,MACtDD,IAIE,GAAGC,IAAa,GAAGA,CAAU,KAAK,EAAE,GAAGD,CAAI,MAHzC;"}
1
+ {"version":3,"file":"RecursiveParamField.js","sources":["../../../../src/api-playground/EndpointFields/ParamFields/RecursiveParamField.tsx"],"sourcesContent":["\nimport { DataSchema, DataSchemaArray, IncrementalDataSchemaArray } from '@mintlify/validation';\nimport slugify from '@sindresorhus/slugify';\n\nimport { useEndpointLocation } from '@/contexts/EndpointLocationContext';\nimport { getConstFilteredSchemaArray } from '@/openapi/filterEnums';\nimport {\n getAuthFilteredSchemaArray,\n isDataSchemaArrayOrIncrementalDataSchemaArray,\n} from '@/openapi/getAuthFilteredSchemaArray';\nimport { getNextPropertiesByType } from '@/utils/api-reference/getNextPropertiesByType';\n\nimport { RecursiveParamFieldWithChildrenObserver } from './RecursiveParamFieldWithChildrenObserver';\nimport { RecursiveParamFieldWithObserver } from './RecursiveParamFieldWithObserver';\nimport { FieldType, RenderedRefs } from '@/api-playground-2/types/api';\n\nexport type RecursiveParamFieldParams = {\n fieldType: FieldType;\n schemaArray: DataSchemaArray | IncrementalDataSchemaArray;\n renderedRefs?: RenderedRefs;\n name?: string | null;\n location?: string;\n parentName?: string;\n depth?: number;\n hideDescription?: boolean;\n circularRefs?: string[];\n paramId?: string;\n style?: string;\n explode?: boolean;\n};\n\nexport const RecursiveParamField = ({\n fieldType,\n schemaArray,\n name,\n location,\n parentName,\n depth = 0,\n hideDescription = false,\n renderedRefs = new Set(),\n circularRefs,\n paramId,\n style,\n explode,\n}: RecursiveParamFieldParams) => {\n const { anchor } = useEndpointLocation();\n let filteredSchemaArray: DataSchemaArray | IncrementalDataSchemaArray | null = schemaArray;\n filteredSchemaArray = getAuthFilteredSchemaArray({ schemaArray, userGroups: undefined });\n\n if (\n filteredSchemaArray &&\n filteredSchemaArray.some((schema) => 'enum' in schema && 'const' in schema)\n ) {\n filteredSchemaArray = getConstFilteredSchemaArray({ schemaArray });\n }\n\n if (!isDataSchemaArrayOrIncrementalDataSchemaArray(filteredSchemaArray)) {\n return null;\n }\n\n const RecursiveParamFieldType = anchor\n ? RecursiveParamFieldWithChildrenObserver\n : RecursiveParamFieldWithObserver;\n\n return (\n <RecursiveParamFieldType\n fieldType={fieldType}\n schemaArray={filteredSchemaArray}\n name={name}\n location={location}\n parentName={parentName}\n depth={depth}\n style={style}\n explode={explode}\n hideDescription={hideDescription}\n renderedRefs={renderedRefs}\n circularRefs={circularRefs}\n paramId={paramId}\n />\n );\n};\n\ntype RenderNextPropertiesRecursivelyParams = {\n properties: [string, DataSchemaArray | IncrementalDataSchemaArray][];\n fieldType: FieldType;\n depth: number;\n refs: Set<string>;\n parentName?: string;\n name?: string | null;\n currentSchemaRef: string | undefined;\n style?: string;\n explode?: boolean;\n hideParentName?: boolean;\n};\n\nexport const renderNextPropertiesRecursively = ({\n currentSchemaRef,\n properties,\n fieldType,\n parentName,\n name,\n depth,\n refs,\n style,\n explode,\n hideParentName,\n}: RenderNextPropertiesRecursivelyParams) => {\n // Create a new set with the current refs for this level\n const currentLevelRefs = new Set(refs);\n\n if (currentSchemaRef) {\n currentLevelRefs.add(currentSchemaRef);\n }\n\n if (currentLevelRefs.size > 0) {\n return properties.map((property) => {\n const [propertyName, schemaArray] = property;\n const nextSchemaArray = schemaArray[0];\n const nextSchemaArrayProperties = getNextPropertiesByType(nextSchemaArray);\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName, propertyName);\n const passedName = hideParentName ? '' : name;\n let circularReferences: string[] = [];\n if (\n Object.values(nextSchemaArrayProperties).some(\n (value: unknown) => typeof value === 'string' && currentLevelRefs.has(value)\n )\n ) {\n circularReferences = Object.values(nextSchemaArrayProperties).filter(\n (value: unknown) => typeof value === 'string' && currentLevelRefs.has(value)\n );\n }\n return (\n <RecursiveParamField\n paramId={paramId}\n fieldType={fieldType}\n key={propertyName}\n schemaArray={schemaArray}\n name={propertyName}\n parentName={\n style === 'deepObject' && explode\n ? getDeepObjectParentName(passedName, parentName)\n : getRecursiveParentName(passedName, parentName)\n }\n depth={depth + 1}\n renderedRefs={new Set(currentLevelRefs)}\n circularRefs={circularReferences}\n style={style}\n explode={explode}\n />\n );\n });\n } else {\n return properties.map(([propertyName, schemaArray]) => {\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName, propertyName);\n const passedName = hideParentName ? '' : name;\n return (\n <RecursiveParamField\n paramId={paramId}\n fieldType={fieldType}\n key={propertyName}\n schemaArray={schemaArray}\n name={propertyName}\n parentName={\n style === 'deepObject' && explode\n ? getDeepObjectParentName(passedName, parentName)\n : getRecursiveParentName(passedName, parentName)\n }\n depth={depth + 1}\n renderedRefs={new Set()}\n style={style}\n explode={explode}\n />\n );\n });\n }\n};\n\ntype RenderTruncatedNextPropertiesParams = {\n properties: [string, DataSchemaArray | IncrementalDataSchemaArray][];\n fieldType: FieldType;\n parentName?: string;\n name?: string | null;\n depth: number;\n};\n\nexport const renderTruncatedNextProperties = ({\n properties,\n fieldType,\n parentName,\n name,\n depth,\n}: RenderTruncatedNextPropertiesParams) => {\n return properties.map((property) => {\n const [propertyName, schemaArray] = property;\n const nextSchemaArray = schemaArray[0];\n const baseSchema: DataSchema = nextSchemaArray as DataSchema;\n if (baseSchema.type === 'array') {\n baseSchema.items = [{ type: 'any' }];\n } else if (baseSchema.type === 'object') {\n baseSchema.properties = {};\n }\n const paramId = buildRecursiveParamFieldId(fieldType, name, parentName);\n const id = `${paramId}-${propertyName}`;\n return (\n <RecursiveParamField\n fieldType={fieldType}\n key={propertyName}\n schemaArray={[baseSchema]}\n name={propertyName}\n paramId={id}\n depth={depth + 1}\n renderedRefs={new Set()}\n />\n );\n });\n};\n\nexport const buildRecursiveParamFieldId = (\n fieldType: FieldType | undefined,\n name: string | undefined | null,\n parentName: string | undefined,\n propertyName?: string | undefined\n) => {\n return slugify(\n `${fieldType ? `${fieldType}-` : ''}${parentName ? `${parentName}-` : ''}${name ? name : ''}-${propertyName ? propertyName : ''}`,\n {\n decamelize: true,\n }\n );\n};\n\nexport const getRecursiveParentName = (name?: string | null, parentName?: string): string => {\n if (!name) {\n return '';\n }\n\n return `${parentName ? `${parentName}` : ''}${name}.`;\n};\n\nexport const getDeepObjectParentName = (name?: string | null, parentName?: string): string => {\n if (!name) {\n return '';\n }\n\n return parentName ? `${parentName}${name}][` : `${name}[`;\n};\n"],"names":["buildRecursiveParamFieldId","fieldType","name","parentName","propertyName","slugify","getRecursiveParentName"],"mappings":";;AAyNO,MAAMA,IAA6B,CACxCC,GACAC,GACAC,GACAC,MAEOC;AAAA,EACL,GAAGJ,IAAY,GAAGA,CAAS,MAAM,EAAE,GAAGE,IAAa,GAAGA,CAAU,MAAM,EAAE,GAAGD,KAAc,EAAE;AAAA,EAC3F;AAAA,IACE,YAAY;AAAA,EAAA;AACd,GAISI,IAAyB,CAACJ,GAAsBC,MACtDD,IAIE,GAAGC,IAAa,GAAGA,CAAU,KAAK,EAAE,GAAGD,CAAI,MAHzC;"}
@@ -1,8 +1,7 @@
1
1
  import "react/jsx-runtime";
2
- import "../../contexts/EndpointLocationContext.js";
3
- import { useOpenApiEndpoint as t } from "../../hooks/useEndpoint.js";
4
- const i = () => (t(), null);
2
+ import { useOpenApiEndpoint as n } from "../../hooks/useEndpoint.js";
3
+ const p = () => (n(), null);
5
4
  export {
6
- i as default
5
+ p as default
7
6
  };
8
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/api-playground/EndpointFields/index.tsx"],"sourcesContent":["\nimport { EndpointLocationProvider } from '@/contexts/EndpointLocationContext';\nimport { useOpenApiEndpoint } from '@/hooks/useEndpoint';\nimport { getFilteredSecurityOptions } from '@/utils/api-reference/getFilteredSecurityOptions';\n\nimport { EndpointBody } from './EndpointBody';\nimport { EndpointParameters } from './EndpointParameters';\nimport { EndpointResponse } from './EndpointResponse';\nimport { EndpointSecurity } from './EndpointSecurity';\n\nconst EndpointFields = () => {\n const endpoint = useOpenApiEndpoint();\n const newApiReferencePage = true;\n\n if (endpoint === undefined || newApiReferencePage) {\n return null;\n }\n\n // TODO(ronan): remove when all security options are handled (none should be empty)\n const filteredSecurityOptions = getFilteredSecurityOptions(endpoint);\n\n return (\n <>\n {filteredSecurityOptions.length > 0 && (\n <EndpointSecurity securityOptions={filteredSecurityOptions} />\n )}\n <EndpointParameters parameters={endpoint.request.parameters} />\n <EndpointLocationProvider location=\"request\">\n <EndpointBody body={endpoint.request.body} />\n </EndpointLocationProvider>\n <EndpointLocationProvider location=\"response\">\n {Object.entries(endpoint.response)[0] && <EndpointResponse response={endpoint.response} />}\n </EndpointLocationProvider>\n </>\n );\n};\n\nexport default EndpointFields;\n"],"names":["EndpointFields","useOpenApiEndpoint"],"mappings":";;;AAUA,MAAMA,IAAiB,OACJC,EAAA,GAIR;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/api-playground/EndpointFields/index.tsx"],"sourcesContent":["\nimport { EndpointLocationProvider } from '@/contexts/EndpointLocationContext';\nimport { useOpenApiEndpoint } from '@/hooks/useEndpoint';\nimport { getFilteredSecurityOptions } from '@/utils/api-reference/getFilteredSecurityOptions';\n\nimport { EndpointBody } from './EndpointBody';\nimport { EndpointParameters } from './EndpointParameters';\nimport { EndpointResponse } from './EndpointResponse';\nimport { EndpointSecurity } from './EndpointSecurity';\n\nconst EndpointFields = () => {\n const endpoint = useOpenApiEndpoint();\n const newApiReferencePage = true;\n\n if (endpoint === undefined || newApiReferencePage) {\n return null;\n }\n\n // TODO(ronan): remove when all security options are handled (none should be empty)\n const filteredSecurityOptions = getFilteredSecurityOptions(endpoint);\n\n return (\n <>\n {filteredSecurityOptions.length > 0 && (\n <EndpointSecurity securityOptions={filteredSecurityOptions} />\n )}\n <EndpointParameters parameters={endpoint.request.parameters} />\n <EndpointLocationProvider location=\"request\">\n <EndpointBody body={endpoint.request.body} />\n </EndpointLocationProvider>\n <EndpointLocationProvider location=\"response\">\n {Object.entries(endpoint.response)[0] && <EndpointResponse response={endpoint.response} />}\n </EndpointLocationProvider>\n </>\n );\n};\n\nexport default EndpointFields;\n"],"names":["EndpointFields","useOpenApiEndpoint"],"mappings":";;AAUA,MAAMA,IAAiB,OACJC,EAAA,GAIR;"}
@@ -1,17 +1,17 @@
1
1
  import { jsx as o, jsxs as v } from "react/jsx-runtime";
2
- import N, { useState as C, useEffect as B } from "react";
2
+ import { ClipboardCheckmarkRegular as N, Copy20Regular as B } from "@fluentui/react-icons";
3
3
  import b from "prismjs";
4
- import "prismjs/components/prism-javascript.js";
5
- import "prismjs/components/prism-typescript.js";
6
- import "prismjs/components/prism-python.js";
7
4
  import "prismjs/components/prism-bash.js";
5
+ import "prismjs/components/prism-csharp.js";
6
+ import "prismjs/components/prism-javascript.js";
8
7
  import "prismjs/components/prism-json.js";
9
8
  import "prismjs/components/prism-markdown.js";
10
- import "prismjs/components/prism-csharp.js";
11
9
  import "prismjs/components/prism-powershell.js";
12
- import { getNodeText as I } from "../../utils/get-node-text.js";
10
+ import "prismjs/components/prism-python.js";
11
+ import "prismjs/components/prism-typescript.js";
12
+ import I, { useState as C, useEffect as A } from "react";
13
13
  import { cn as h } from "../../utils/cn.js";
14
- import { ClipboardCheckmarkRegular as A, Copy20Regular as R } from "@fluentui/react-icons";
14
+ import { getNodeText as R } from "../../utils/get-node-text.js";
15
15
  const w = ["image/png", "text/plain"];
16
16
  function g() {
17
17
  const [t, e] = C(!1), n = async (r) => {
@@ -52,18 +52,24 @@ function _({ onClick: t, isCopied: e, showTooltip: n = !0 }) {
52
52
  onClick: t,
53
53
  className: "mint:flex mint:items-center mint:gap-1.5 mint:px-2 mint:py-1 mint:text-xs mint:text-[#737373] mint:dark:text-[#a3a3a3] mint:rounded mint:transition-colors mint:duration-150 mint:border-none mint:bg-transparent mint:cursor-pointer mint:hover:text-[#9263f1] mint:dark:hover:text-[#c9aaf9]",
54
54
  "aria-label": e ? "Copied" : "Copy code",
55
- children: e ? /* @__PURE__ */ o(A, { className: "mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]" }) : /* @__PURE__ */ o(R, { className: "mint:w-5 mint:h-5" })
55
+ children: e ? /* @__PURE__ */ o(N, { className: "mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]" }) : /* @__PURE__ */ o(B, { className: "mint:w-5 mint:h-5" })
56
56
  }
57
57
  )
58
58
  ] });
59
59
  }
60
- function q({ textToCopy: t, showTooltip: e = !0 }) {
60
+ function q({
61
+ textToCopy: t,
62
+ showTooltip: e = !0
63
+ }) {
61
64
  const { isCopied: n, copy: p } = g();
62
65
  return /* @__PURE__ */ o(_, { onClick: () => {
63
66
  p(t);
64
67
  }, isCopied: n, showTooltip: e });
65
68
  }
66
- function G({ data: t, showTooltip: e = !0 }) {
69
+ function G({
70
+ data: t,
71
+ showTooltip: e = !0
72
+ }) {
67
73
  const { isCopied: n, copy: p, copyBlob: r } = g();
68
74
  return /* @__PURE__ */ o(_, { onClick: () => {
69
75
  t.contentType && w.includes(t.contentType) ? r(t.blob, t.contentType) : t.type === "other" && t.content ? p(t.content) : console.error("Unsupported content type for clipboard");
@@ -79,7 +85,7 @@ function J({
79
85
  }) {
80
86
  const [i, a] = C("");
81
87
  g();
82
- const m = p || (e == null ? void 0 : e.replace(/^language-/, "")) || "text", d = I(t), k = !!n, u = N.useMemo(() => {
88
+ const m = p || (e == null ? void 0 : e.replace(/^language-/, "")) || "text", d = R(t), k = !!n, u = I.useMemo(() => {
83
89
  var f, y;
84
90
  if (typeof t != "object" || t == null)
85
91
  return !1;
@@ -93,7 +99,7 @@ function J({
93
99
  }
94
100
  return !1;
95
101
  }, [t]);
96
- return B(() => {
102
+ return A(() => {
97
103
  if (!u)
98
104
  try {
99
105
  const s = b.languages[m] || b.languages.plaintext, f = b.highlight(d, s, m);
@@ -1 +1 @@
1
- {"version":3,"file":"code-block.js","sources":["../../../src/components/content-components/code-block.tsx"],"sourcesContent":["\nimport React, { useEffect, useState } from \"react\";\nimport Prism from \"prismjs\";\nimport \"prismjs/components/prism-javascript.js\";\nimport \"prismjs/components/prism-typescript.js\";\nimport \"prismjs/components/prism-python.js\";\nimport \"prismjs/components/prism-bash.js\";\nimport \"prismjs/components/prism-json.js\";\nimport \"prismjs/components/prism-markdown.js\";\nimport \"prismjs/components/prism-csharp.js\";\nimport \"prismjs/components/prism-powershell.js\";\nimport { getNodeText } from \"../../utils/get-node-text\";\nimport { capitalize } from \"../../utils/string\";\nimport { cn } from \"../../utils/cn\";\nimport {\n Copy20Regular,\n ClipboardCheckmarkRegular,\n} from \"@fluentui/react-icons\";\n\nconst SUPPORTED_CLIPBOARD_CONTENT_TYPES = [\"image/png\", \"text/plain\"];\n\n// Hook for clipboard operations\nexport function useCopyToClipboard() {\n const [isCopied, setIsCopied] = useState(false);\n\n const copy = async (text: string) => {\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } catch (error) {\n console.error(\"Failed to copy to clipboard:\", error);\n }\n };\n\n const copyBlob = async (blob: Blob, contentType: string) => {\n try {\n // image/png, text/plain, and text/html are the only filetypes supported in the chromium\n // clipboard - however, text/html crashes chrome for some reason\n if (SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(contentType)) {\n const buffer = await blob.arrayBuffer();\n const newBlob = new Blob([buffer], { type: contentType });\n const clipboardItem = new ClipboardItem({\n [contentType]: newBlob,\n });\n await navigator.clipboard.write([clipboardItem]);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } else {\n // Fallback to text copy for unsupported types\n const text = await blob.text();\n await copy(text);\n }\n } catch (error) {\n console.error(\"Failed to copy blob to clipboard:\", error);\n // Fallback to text copy if blob copy fails\n try {\n const text = await blob.text();\n await copy(text);\n } catch (fallbackError) {\n console.error(\"Failed to copy as text fallback:\", fallbackError);\n }\n }\n };\n\n return { isCopied, copy, copyBlob };\n}\n\n// Base copy icon button component\ninterface CopyIconButtonProps {\n onClick: () => void;\n isCopied: boolean;\n showTooltip?: boolean;\n}\n\nexport function CopyIconButton({ onClick, isCopied, showTooltip = true }: CopyIconButtonProps) {\n return (\n <div className=\"mint:relative\">\n {showTooltip && isCopied && (\n <div className=\"mint:absolute mint:bottom-[calc(100%+0.5rem)] mint:left-1/2 mint:-translate-x-1/2 mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#171717] mint:dark:text-[#fafafa] mint:px-2.5 mint:py-1.5 mint:rounded-md mint:text-xs mint:font-medium mint:whitespace-nowrap mint:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.1),0_2px_4px_-1px_rgba(0,0,0,0.06)] mint:dark:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.3),0_2px_4px_-1px_rgba(0,0,0,0.2)] mint:z-10 mint:animate-[fadeIn_0.15s_ease-out] mint:after:content-[''] mint:after:absolute mint:after:top-full mint:after:left-1/2 mint:after:-translate-x-1/2 mint:after:w-0 mint:after:h-0 mint:after:border-l-[6px] mint:after:border-l-transparent mint:after:border-r-[6px] mint:after:border-r-transparent mint:after:border-t-[6px] mint:after:border-t-white mint:dark:after:border-t-[#1a1a1a]\">\n Copied!\n </div>\n )}\n <button\n onClick={onClick}\n className=\"mint:flex mint:items-center mint:gap-1.5 mint:px-2 mint:py-1 mint:text-xs mint:text-[#737373] mint:dark:text-[#a3a3a3] mint:rounded mint:transition-colors mint:duration-150 mint:border-none mint:bg-transparent mint:cursor-pointer mint:hover:text-[#9263f1] mint:dark:hover:text-[#c9aaf9]\"\n aria-label={isCopied ? \"Copied\" : \"Copy code\"}\n >\n {isCopied ? (\n <ClipboardCheckmarkRegular className=\"mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]\" />\n ) : (\n <Copy20Regular className=\"mint:w-5 mint:h-5\" />\n )}\n </button>\n </div>\n );\n}\n\n// Convenience component that handles text copying\ninterface CopyToClipboardButtonProps {\n textToCopy: string;\n showTooltip?: boolean;\n}\n\nexport function CopyToClipboardButton({ textToCopy, showTooltip = true }: CopyToClipboardButtonProps) {\n const { isCopied, copy } = useCopyToClipboard();\n\n const handleCopy = () => {\n copy(textToCopy);\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\n// Convenience component that handles blob/data copying\ninterface CopyDataToClipboardButtonProps {\n data: {\n type: 'image' | 'audio' | 'video' | 'other';\n blob: Blob;\n contentType?: string;\n content?: string;\n };\n showTooltip?: boolean;\n}\n\nexport function CopyDataToClipboardButton({ data, showTooltip = true }: CopyDataToClipboardButtonProps) {\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n\n const handleCopy = () => {\n // Check if we can copy as blob (for images, etc.)\n if (data.contentType && SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(data.contentType)) {\n copyBlob(data.blob, data.contentType);\n } else if (data.type === 'other' && data.content) {\n // For text content, copy as text\n copy(data.content);\n } else {\n console.error('Unsupported content type for clipboard');\n }\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\ninterface CodeBlockProps {\n children: React.ReactNode;\n className?: string;\n language?: string;\n fileName?: string;\n // Support for copying blobs (images, etc.)\n blob?: Blob;\n contentType?: string;\n}\n\nexport function CodeBlock({\n children,\n className,\n fileName,\n language,\n blob,\n contentType,\n}: CodeBlockProps) {\n const [highlightedCode, setHighlightedCode] = useState<string>(\"\");\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n const lang = language || className?.replace(/^language-/, \"\") || \"text\";\n const codeText = getNodeText(children);\n const showContainer = !!fileName;\n\n const isSSRHighlighted = React.useMemo(() => {\n if (typeof children !== \"object\" || children == null) {\n return false;\n }\n\n const childrenArray = Array.isArray(children) ? children : [children];\n for (const child of childrenArray) {\n if (\n typeof child === \"object\" &&\n child != null &&\n \"props\" in child &&\n child.props?.children\n ) {\n const codeChildren = Array.isArray(child.props.children)\n ? child.props.children\n : [child.props.children];\n\n for (const codeChild of codeChildren) {\n if (\n typeof codeChild === \"object\" &&\n codeChild != null &&\n \"props\" in codeChild &&\n codeChild.props?.className\n ) {\n return true;\n }\n }\n }\n }\n return false;\n }, [children]);\n\n useEffect(() => {\n if (isSSRHighlighted) {\n return;\n }\n\n try {\n const grammar = Prism.languages[lang] || Prism.languages.plaintext;\n const html = Prism.highlight(codeText, grammar, lang);\n setHighlightedCode(html);\n } catch (error) {\n console.error(\"Failed to highlight code:\", error);\n setHighlightedCode(codeText);\n }\n }, [codeText, lang, isSSRHighlighted]);\n\n const handleCopy = () => {\n // If blob and contentType are provided, use blob copying\n if (blob && contentType) {\n copyBlob(blob, contentType);\n } else {\n // Otherwise, use text copying\n copy(codeText);\n }\n };\n\n return (\n <div\n className={\n showContainer\n ? \"mint:flex mint:flex-col mint:gap-2 mint:px-0.5 mint:pb-0.5 mint:rounded-xl mint:overflow-hidden\"\n : undefined\n }\n >\n <div className=\"not-prose mint:relative mint:rounded-xl mint:bg-[#f5f5f5] mint:dark:bg-[#141414]\">\n <div className=\"mint:code-scrollbar mint:overflow-x-scroll\">\n <pre className=\"mint:px-4 mint:py-2 mint:m-0 mint:whitespace-pre mint:text-sm\">\n {isSSRHighlighted ? (\n <code\n className={cn(\n `language-${lang}`,\n \"mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]\"\n )}\n >\n {children}\n </code>\n ) : highlightedCode ? (\n <code\n className={cn(\n `language-${lang}`,\n \"mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]\"\n )}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n />\n ) : (\n <code\n className={cn(\n `language-${lang}`,\n \"mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]\"\n )}\n >\n {codeText}\n </code>\n )}\n </pre>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["SUPPORTED_CLIPBOARD_CONTENT_TYPES","useCopyToClipboard","isCopied","setIsCopied","useState","copy","text","error","blob","contentType","buffer","newBlob","clipboardItem","fallbackError","CopyIconButton","onClick","showTooltip","jsxs","jsx","ClipboardCheckmarkRegular","Copy20Regular","CopyToClipboardButton","textToCopy","CopyDataToClipboardButton","data","copyBlob","CodeBlock","children","className","fileName","language","highlightedCode","setHighlightedCode","lang","codeText","getNodeText","showContainer","isSSRHighlighted","React","childrenArray","child","_a","codeChildren","codeChild","_b","useEffect","grammar","Prism","html","cn"],"mappings":";;;;;;;;;;;;;;AAmBA,MAAMA,IAAoC,CAAC,aAAa,YAAY;AAG7D,SAASC,IAAqB;AACnC,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK,GAExCC,IAAO,OAAOC,MAAiB;AACnC,QAAI;AACF,YAAM,UAAU,UAAU,UAAUA,CAAI,GACxCH,EAAY,EAAI,GAChB,WAAW,MAAMA,EAAY,EAAK,GAAG,GAAI;AAAA,IAC3C,SAASI,GAAO;AACd,cAAQ,MAAM,gCAAgCA,CAAK;AAAA,IACrD;AAAA,EACF;AAgCA,SAAO,EAAE,UAAAL,GAAU,MAAAG,GAAM,UA9BR,OAAOG,GAAYC,MAAwB;AAC1D,QAAI;AAGF,UAAIT,EAAkC,SAASS,CAAW,GAAG;AAC3D,cAAMC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C;AAAA,QAAA;AAAA,MAAA,EACH,CAEJ,GACF,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"code-block.js","sources":["../../../src/components/content-components/code-block.tsx"],"sourcesContent":["import { Copy20Regular, ClipboardCheckmarkRegular } from '@fluentui/react-icons';\nimport Prism from 'prismjs';\nimport 'prismjs/components/prism-bash.js';\nimport 'prismjs/components/prism-csharp.js';\nimport 'prismjs/components/prism-javascript.js';\nimport 'prismjs/components/prism-json.js';\nimport 'prismjs/components/prism-markdown.js';\nimport 'prismjs/components/prism-powershell.js';\nimport 'prismjs/components/prism-python.js';\nimport 'prismjs/components/prism-typescript.js';\nimport React, { useEffect, useState } from 'react';\n\nimport { cn } from '../../utils/cn';\nimport { getNodeText } from '../../utils/get-node-text';\nimport { capitalize } from '../../utils/string';\n\nconst SUPPORTED_CLIPBOARD_CONTENT_TYPES = ['image/png', 'text/plain'];\n\n// Hook for clipboard operations\nexport function useCopyToClipboard() {\n const [isCopied, setIsCopied] = useState(false);\n\n const copy = async (text: string) => {\n try {\n await navigator.clipboard.writeText(text);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } catch (error) {\n console.error('Failed to copy to clipboard:', error);\n }\n };\n\n const copyBlob = async (blob: Blob, contentType: string) => {\n try {\n // image/png, text/plain, and text/html are the only filetypes supported in the chromium\n // clipboard - however, text/html crashes chrome for some reason\n if (SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(contentType)) {\n const buffer = await blob.arrayBuffer();\n const newBlob = new Blob([buffer], { type: contentType });\n const clipboardItem = new ClipboardItem({\n [contentType]: newBlob,\n });\n await navigator.clipboard.write([clipboardItem]);\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n } else {\n // Fallback to text copy for unsupported types\n const text = await blob.text();\n await copy(text);\n }\n } catch (error) {\n console.error('Failed to copy blob to clipboard:', error);\n // Fallback to text copy if blob copy fails\n try {\n const text = await blob.text();\n await copy(text);\n } catch (fallbackError) {\n console.error('Failed to copy as text fallback:', fallbackError);\n }\n }\n };\n\n return { isCopied, copy, copyBlob };\n}\n\n// Base copy icon button component\ninterface CopyIconButtonProps {\n onClick: () => void;\n isCopied: boolean;\n showTooltip?: boolean;\n}\n\nexport function CopyIconButton({ onClick, isCopied, showTooltip = true }: CopyIconButtonProps) {\n return (\n <div className=\"mint:relative\">\n {showTooltip && isCopied && (\n <div className=\"mint:absolute mint:bottom-[calc(100%+0.5rem)] mint:left-1/2 mint:-translate-x-1/2 mint:bg-white mint:dark:bg-[#1a1a1a] mint:text-[#171717] mint:dark:text-[#fafafa] mint:px-2.5 mint:py-1.5 mint:rounded-md mint:text-xs mint:font-medium mint:whitespace-nowrap mint:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.1),0_2px_4px_-1px_rgba(0,0,0,0.06)] mint:dark:shadow-[0_4px_6px_-1px_rgba(0,0,0,0.3),0_2px_4px_-1px_rgba(0,0,0,0.2)] mint:z-10 mint:animate-[fadeIn_0.15s_ease-out] mint:after:content-[''] mint:after:absolute mint:after:top-full mint:after:left-1/2 mint:after:-translate-x-1/2 mint:after:w-0 mint:after:h-0 mint:after:border-l-[6px] mint:after:border-l-transparent mint:after:border-r-[6px] mint:after:border-r-transparent mint:after:border-t-[6px] mint:after:border-t-white mint:dark:after:border-t-[#1a1a1a]\">\n Copied!\n </div>\n )}\n <button\n onClick={onClick}\n className=\"mint:flex mint:items-center mint:gap-1.5 mint:px-2 mint:py-1 mint:text-xs mint:text-[#737373] mint:dark:text-[#a3a3a3] mint:rounded mint:transition-colors mint:duration-150 mint:border-none mint:bg-transparent mint:cursor-pointer mint:hover:text-[#9263f1] mint:dark:hover:text-[#c9aaf9]\"\n aria-label={isCopied ? 'Copied' : 'Copy code'}\n >\n {isCopied ? (\n <ClipboardCheckmarkRegular className=\"mint:w-5 mint:h-5 mint:text-[#737373] mint:dark:text-[#a3a3a3]\" />\n ) : (\n <Copy20Regular className=\"mint:w-5 mint:h-5\" />\n )}\n </button>\n </div>\n );\n}\n\n// Convenience component that handles text copying\ninterface CopyToClipboardButtonProps {\n textToCopy: string;\n showTooltip?: boolean;\n}\n\nexport function CopyToClipboardButton({\n textToCopy,\n showTooltip = true,\n}: CopyToClipboardButtonProps) {\n const { isCopied, copy } = useCopyToClipboard();\n\n const handleCopy = () => {\n copy(textToCopy);\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\n// Convenience component that handles blob/data copying\ninterface CopyDataToClipboardButtonProps {\n data: {\n type: 'image' | 'audio' | 'video' | 'other';\n blob: Blob;\n contentType?: string;\n content?: string;\n };\n showTooltip?: boolean;\n}\n\nexport function CopyDataToClipboardButton({\n data,\n showTooltip = true,\n}: CopyDataToClipboardButtonProps) {\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n\n const handleCopy = () => {\n // Check if we can copy as blob (for images, etc.)\n if (data.contentType && SUPPORTED_CLIPBOARD_CONTENT_TYPES.includes(data.contentType)) {\n copyBlob(data.blob, data.contentType);\n } else if (data.type === 'other' && data.content) {\n // For text content, copy as text\n copy(data.content);\n } else {\n console.error('Unsupported content type for clipboard');\n }\n };\n\n return <CopyIconButton onClick={handleCopy} isCopied={isCopied} showTooltip={showTooltip} />;\n}\n\ninterface CodeBlockProps {\n children: React.ReactNode;\n className?: string;\n language?: string;\n fileName?: string;\n // Support for copying blobs (images, etc.)\n blob?: Blob;\n contentType?: string;\n}\n\nexport function CodeBlock({\n children,\n className,\n fileName,\n language,\n blob,\n contentType,\n}: CodeBlockProps) {\n const [highlightedCode, setHighlightedCode] = useState<string>('');\n const { isCopied, copy, copyBlob } = useCopyToClipboard();\n const lang = language || className?.replace(/^language-/, '') || 'text';\n const codeText = getNodeText(children);\n const showContainer = !!fileName;\n\n const isSSRHighlighted = React.useMemo(() => {\n if (typeof children !== 'object' || children == null) {\n return false;\n }\n\n const childrenArray = Array.isArray(children) ? children : [children];\n for (const child of childrenArray) {\n if (typeof child === 'object' && child != null && 'props' in child && child.props?.children) {\n const codeChildren = Array.isArray(child.props.children)\n ? child.props.children\n : [child.props.children];\n\n for (const codeChild of codeChildren) {\n if (\n typeof codeChild === 'object' &&\n codeChild != null &&\n 'props' in codeChild &&\n codeChild.props?.className\n ) {\n return true;\n }\n }\n }\n }\n return false;\n }, [children]);\n\n useEffect(() => {\n if (isSSRHighlighted) {\n return;\n }\n\n try {\n const grammar = Prism.languages[lang] || Prism.languages.plaintext;\n const html = Prism.highlight(codeText, grammar, lang);\n setHighlightedCode(html);\n } catch (error) {\n console.error('Failed to highlight code:', error);\n setHighlightedCode(codeText);\n }\n }, [codeText, lang, isSSRHighlighted]);\n\n const handleCopy = () => {\n // If blob and contentType are provided, use blob copying\n if (blob && contentType) {\n copyBlob(blob, contentType);\n } else {\n // Otherwise, use text copying\n copy(codeText);\n }\n };\n\n return (\n <div\n className={\n showContainer\n ? 'mint:flex mint:flex-col mint:gap-2 mint:px-0.5 mint:pb-0.5 mint:rounded-xl mint:overflow-hidden'\n : undefined\n }\n >\n <div className=\"not-prose mint:relative mint:rounded-xl mint:bg-[#f5f5f5] mint:dark:bg-[#141414]\">\n <div className=\"mint:code-scrollbar mint:overflow-x-scroll\">\n <pre className=\"mint:px-4 mint:py-2 mint:m-0 mint:whitespace-pre mint:text-sm\">\n {isSSRHighlighted ? (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n >\n {children}\n </code>\n ) : highlightedCode ? (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n dangerouslySetInnerHTML={{ __html: highlightedCode }}\n />\n ) : (\n <code\n className={cn(\n `language-${lang}`,\n 'mint:block mint:text-[#24292e] mint:dark:text-[#e6edf3]'\n )}\n >\n {codeText}\n </code>\n )}\n </pre>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["SUPPORTED_CLIPBOARD_CONTENT_TYPES","useCopyToClipboard","isCopied","setIsCopied","useState","copy","text","error","blob","contentType","buffer","newBlob","clipboardItem","fallbackError","CopyIconButton","onClick","showTooltip","jsxs","jsx","ClipboardCheckmarkRegular","Copy20Regular","CopyToClipboardButton","textToCopy","CopyDataToClipboardButton","data","copyBlob","CodeBlock","children","className","fileName","language","highlightedCode","setHighlightedCode","lang","codeText","getNodeText","showContainer","isSSRHighlighted","React","childrenArray","child","_a","codeChildren","codeChild","_b","useEffect","grammar","Prism","html","cn"],"mappings":";;;;;;;;;;;;;;AAgBA,MAAMA,IAAoC,CAAC,aAAa,YAAY;AAG7D,SAASC,IAAqB;AACnC,QAAM,CAACC,GAAUC,CAAW,IAAIC,EAAS,EAAK,GAExCC,IAAO,OAAOC,MAAiB;AACnC,QAAI;AACF,YAAM,UAAU,UAAU,UAAUA,CAAI,GACxCH,EAAY,EAAI,GAChB,WAAW,MAAMA,EAAY,EAAK,GAAG,GAAI;AAAA,IAC3C,SAASI,GAAO;AACd,cAAQ,MAAM,gCAAgCA,CAAK;AAAA,IACrD;AAAA,EACF;AAgCA,SAAO,EAAE,UAAAL,GAAU,MAAAG,GAAM,UA9BR,OAAOG,GAAYC,MAAwB;AAC1D,QAAI;AAGF,UAAIT,EAAkC,SAASS,CAAW,GAAG;AAC3D,cAAMC,IAAS,MAAMF,EAAK,YAAA,GACpBG,IAAU,IAAI,KAAK,CAACD,CAAM,GAAG,EAAE,MAAMD,GAAa,GAClDG,IAAgB,IAAI,cAAc;AAAA,UACtC,CAACH,CAAW,GAAGE;AAAA,QAAA,CAChB;AACD,cAAM,UAAU,UAAU,MAAM,CAACC,CAAa,CAAC,GAC/CT,EAAY,EAAI,GAChB,WAAW,MAAMA,EAAY,EAAK,GAAG,GAAI;AAAA,MAC3C,OAAO;AAEL,cAAMG,IAAO,MAAME,EAAK,KAAA;AACxB,cAAMH,EAAKC,CAAI;AAAA,MACjB;AAAA,IACF,SAASC,GAAO;AACd,cAAQ,MAAM,qCAAqCA,CAAK;AAExD,UAAI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gB,CAAI;AAAA,MACzB,SAASzC,GAAO;AACd,gBAAQ,MAAM,6BAA6BA,CAAK,GAChDyB,EAAmBE,CAAQ;AAAA,MAC7B;AAAA,EACF,GAAG,CAACA,GAAUD,GAAMI,CAAgB,CAAC,GAanC,gBAAAnB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,WACEkB,IACI,oGACA;AAAA,MAGN,UAAA,gBAAAlB,EAAC,OAAA,EAAI,WAAU,oFACb,UAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,8CACb,UAAA,gBAAAA,EAAC,OAAA,EAAI,WAAU,iEACZ,UAAAmB,IACC,gBAAAnB;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW+B;AAAA,YACT,YAAYhB,CAAI;AAAA,YAChB;AAAA,UAAA;AAAA,UAGD,UAAAN;AAAA,QAAA;AAAA,MAAA,IAEDI,IACF,gBAAAb;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW+B;AAAA,YACT,YAAYhB,CAAI;AAAA,YAChB;AAAA,UAAA;AAAA,UAEF,yBAAyB,EAAE,QAAQF,EAAA;AAAA,QAAgB;AAAA,MAAA,IAGrD,gBAAAb;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,WAAW+B;AAAA,YACT,YAAYhB,CAAI;AAAA,YAChB;AAAA,UAAA;AAAA,UAGD,UAAAC;AAAA,QAAA;AAAA,MAAA,EACH,CAEJ,GACF,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -1,56 +1,53 @@
1
- import { jsxs as h, jsx as e } from "react/jsx-runtime";
2
- import { useState as d } from "react";
3
- import { cn as n } from "../../utils/cn.js";
4
- const x = ({
5
- id: t,
6
- level: a,
7
- children: o,
8
- className: r = ""
9
- }) => {
10
- const l = `h${a}`, [m, i] = d(!1), s = (c) => {
11
- c.preventDefault();
12
- const p = window.location.href.split("#")[0] + "#" + t;
13
- navigator.clipboard.writeText(p).then(() => {
14
- i(!0), setTimeout(() => i(!1), 2e3);
15
- }), window.location.hash = t;
1
+ import { jsxs as x, jsx as n } from "react/jsx-runtime";
2
+ import { useState as C } from "react";
3
+ import { cn as a } from "../../utils/cn.js";
4
+ const B = ({ id: t, level: r, children: c, className: s = "" }) => {
5
+ const m = `h${r}`, [p, o] = C(!1), d = (u) => {
6
+ u.preventDefault();
7
+ const g = window.location.href.split("#")[0] + "#" + t;
8
+ navigator.clipboard.writeText(g).then(() => {
9
+ o(!0), setTimeout(() => o(!1), 2e3);
10
+ });
11
+ const e = document.getElementById("main-content"), i = document.getElementById(t);
12
+ if (e && i) {
13
+ const l = window.getComputedStyle(document.documentElement), f = parseFloat(l.getPropertyValue("--scroll-mt") || "0"), h = parseFloat(l.fontSize), w = f * h, y = e.getBoundingClientRect(), v = i.getBoundingClientRect().top - y.top + e.scrollTop - w;
14
+ e.scrollTo({
15
+ top: v,
16
+ behavior: "instant"
17
+ });
18
+ }
19
+ history.replaceState(null, "", `#${t}`);
16
20
  };
17
- return /* @__PURE__ */ h(
18
- l,
19
- {
20
- id: t,
21
- className: n("mint:group mint:relative", r),
22
- children: [
23
- o,
24
- /* @__PURE__ */ e(
25
- "a",
21
+ return /* @__PURE__ */ x(m, { id: t, className: a("mint:group mint:relative", s), children: [
22
+ c,
23
+ /* @__PURE__ */ n(
24
+ "a",
25
+ {
26
+ href: `#${t}`,
27
+ onClick: d,
28
+ className: a(
29
+ "mint:absolute mint:-left-6 mint:top-1/2 mint:-translate-y-1/2 mint:opacity-0 mint:transition-opacity mint:duration-200",
30
+ "mint:group-hover:opacity-100 mint:text-[#0078d4] mint:dark:text-[#75b6e7]",
31
+ "mint:no-underline mint:flex mint:items-center mint:justify-center mint:w-5 mint:h-5",
32
+ "hover:mint:text-[#005a9e] hover:mint:dark:text-[#9ed2f7]"
33
+ ),
34
+ "aria-label": `Link to ${t}`,
35
+ title: p ? "Link copied!" : "Copy link",
36
+ children: /* @__PURE__ */ n(
37
+ "svg",
26
38
  {
27
- href: `#${t}`,
28
- onClick: s,
29
- className: n(
30
- "mint:absolute mint:-left-6 mint:top-1/2 mint:-translate-y-1/2 mint:opacity-0 mint:transition-opacity mint:duration-200",
31
- "mint:group-hover:opacity-100 mint:text-[#0078d4] mint:dark:text-[#75b6e7]",
32
- "mint:no-underline mint:flex mint:items-center mint:justify-center mint:w-5 mint:h-5",
33
- "hover:mint:text-[#005a9e] hover:mint:dark:text-[#9ed2f7]"
34
- ),
35
- "aria-label": `Link to ${t}`,
36
- title: m ? "Link copied!" : "Copy link",
37
- children: /* @__PURE__ */ e(
38
- "svg",
39
- {
40
- xmlns: "http://www.w3.org/2000/svg",
41
- viewBox: "0 0 16 16",
42
- fill: "currentColor",
43
- className: "mint:w-4 mint:h-4",
44
- children: /* @__PURE__ */ e("path", { d: "M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z" })
45
- }
46
- )
39
+ xmlns: "http://www.w3.org/2000/svg",
40
+ viewBox: "0 0 16 16",
41
+ fill: "currentColor",
42
+ className: "mint:w-4 mint:h-4",
43
+ children: /* @__PURE__ */ n("path", { d: "M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z" })
47
44
  }
48
45
  )
49
- ]
50
- }
51
- );
46
+ }
47
+ )
48
+ ] });
52
49
  };
53
50
  export {
54
- x as Heading
51
+ B as Heading
55
52
  };
56
53
  //# sourceMappingURL=heading.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"heading.js","sources":["../../../src/components/content-components/heading.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { cn } from \"../../utils/cn\";\n\nexport interface HeadingProps {\n id: string;\n level: 1 | 2 | 3 | 4 | 5 | 6;\n children: React.ReactNode;\n className?: string;\n}\n\nexport const Heading = ({\n id,\n level,\n children,\n className = \"\",\n}: HeadingProps) => {\n const Tag = `h${level}` as keyof JSX.IntrinsicElements;\n const [isCopied, setIsCopied] = useState(false);\n\n const handleAnchorClick = (e: React.MouseEvent<HTMLAnchorElement>) => {\n e.preventDefault();\n const url = window.location.href.split('#')[0] + '#' + id;\n navigator.clipboard.writeText(url).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n });\n window.location.hash = id;\n };\n\n return (\n <Tag\n id={id}\n className={cn(\"mint:group mint:relative\", className)}\n >\n {children}\n <a\n href={`#${id}`}\n onClick={handleAnchorClick}\n className={cn(\n \"mint:absolute mint:-left-6 mint:top-1/2 mint:-translate-y-1/2 mint:opacity-0 mint:transition-opacity mint:duration-200\",\n \"mint:group-hover:opacity-100 mint:text-[#0078d4] mint:dark:text-[#75b6e7]\",\n \"mint:no-underline mint:flex mint:items-center mint:justify-center mint:w-5 mint:h-5\",\n \"hover:mint:text-[#005a9e] hover:mint:dark:text-[#9ed2f7]\"\n )}\n aria-label={`Link to ${id}`}\n title={isCopied ? \"Link copied!\" : \"Copy link\"}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n className=\"mint:w-4 mint:h-4\"\n >\n <path d=\"M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z\" />\n </svg>\n </a>\n </Tag>\n );\n};\n"],"names":["Heading","id","level","children","className","Tag","isCopied","setIsCopied","useState","handleAnchorClick","e","url","jsxs","cn","jsx"],"mappings":";;;AAUO,MAAMA,IAAU,CAAC;AAAA,EACtB,IAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC,IAAY;AACd,MAAoB;AAClB,QAAMC,IAAM,IAAIH,CAAK,IACf,CAACI,GAAUC,CAAW,IAAIC,EAAS,EAAK,GAExCC,IAAoB,CAACC,MAA2C;AACpE,IAAAA,EAAE,eAAA;AACF,UAAMC,IAAM,OAAO,SAAS,KAAK,MAAM,GAAG,EAAE,CAAC,IAAI,MAAMV;AACvD,cAAU,UAAU,UAAUU,CAAG,EAAE,KAAK,MAAM;AAC5C,MAAAJ,EAAY,EAAI,GAChB,WAAW,MAAMA,EAAY,EAAK,GAAG,GAAI;AAAA,IAC3C,CAAC,GACD,OAAO,SAAS,OAAON;AAAA,EACzB;AAEA,SACE,gBAAAW;AAAA,IAACP;AAAA,IAAA;AAAA,MACC,IAAAJ;AAAA,MACA,WAAWY,EAAG,4BAA4BT,CAAS;AAAA,MAElD,UAAA;AAAA,QAAAD;AAAA,QACD,gBAAAW;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAM,IAAIb,CAAE;AAAA,YACZ,SAASQ;AAAA,YACT,WAAWI;AAAA,cACT;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,YAAA;AAAA,YAEF,cAAY,WAAWZ,CAAE;AAAA,YACzB,OAAOK,IAAW,iBAAiB;AAAA,YAEnC,UAAA,gBAAAQ;AAAA,cAAC;AAAA,cAAA;AAAA,gBACC,OAAM;AAAA,gBACN,SAAQ;AAAA,gBACR,MAAK;AAAA,gBACL,WAAU;AAAA,gBAEV,UAAA,gBAAAA,EAAC,QAAA,EAAK,GAAE,kWAAA,CAAkW;AAAA,cAAA;AAAA,YAAA;AAAA,UAC5W;AAAA,QAAA;AAAA,MACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"heading.js","sources":["../../../src/components/content-components/heading.tsx"],"sourcesContent":["import React, { useState } from 'react';\n\nimport { cn } from '../../utils/cn';\n\nexport interface HeadingProps {\n id: string;\n level: 1 | 2 | 3 | 4 | 5 | 6;\n children: React.ReactNode;\n className?: string;\n}\n\nexport const Heading = ({ id, level, children, className = '' }: HeadingProps) => {\n const Tag = `h${level}` as keyof JSX.IntrinsicElements;\n const [isCopied, setIsCopied] = useState(false);\n\n const handleAnchorClick = (e: React.MouseEvent<HTMLAnchorElement>) => {\n e.preventDefault();\n const url = window.location.href.split('#')[0] + '#' + id;\n navigator.clipboard.writeText(url).then(() => {\n setIsCopied(true);\n setTimeout(() => setIsCopied(false), 2000);\n });\n\n const scrollContainer = document.getElementById('main-content');\n const targetElement = document.getElementById(id);\n\n if (scrollContainer && targetElement) {\n const style = window.getComputedStyle(document.documentElement);\n const scrollMtRem = parseFloat(style.getPropertyValue('--scroll-mt') || '0');\n const fontSize = parseFloat(style.fontSize);\n const scrollOffset = scrollMtRem * fontSize;\n\n const containerRect = scrollContainer.getBoundingClientRect();\n const targetRect = targetElement.getBoundingClientRect();\n const relativeTop =\n targetRect.top - containerRect.top + scrollContainer.scrollTop - scrollOffset;\n\n scrollContainer.scrollTo({\n top: relativeTop,\n behavior: 'instant',\n });\n }\n\n history.replaceState(null, '', `#${id}`);\n };\n\n return (\n <Tag id={id} className={cn('mint:group mint:relative', className)}>\n {children}\n <a\n href={`#${id}`}\n onClick={handleAnchorClick}\n className={cn(\n 'mint:absolute mint:-left-6 mint:top-1/2 mint:-translate-y-1/2 mint:opacity-0 mint:transition-opacity mint:duration-200',\n 'mint:group-hover:opacity-100 mint:text-[#0078d4] mint:dark:text-[#75b6e7]',\n 'mint:no-underline mint:flex mint:items-center mint:justify-center mint:w-5 mint:h-5',\n 'hover:mint:text-[#005a9e] hover:mint:dark:text-[#9ed2f7]'\n )}\n aria-label={`Link to ${id}`}\n title={isCopied ? 'Link copied!' : 'Copy link'}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 16 16\"\n fill=\"currentColor\"\n className=\"mint:w-4 mint:h-4\"\n >\n <path d=\"M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z\" />\n </svg>\n </a>\n </Tag>\n );\n};\n"],"names":["Heading","id","level","children","className","Tag","isCopied","setIsCopied","useState","handleAnchorClick","e","url","scrollContainer","targetElement","style","scrollMtRem","fontSize","scrollOffset","containerRect","relativeTop","cn","jsx"],"mappings":";;;AAWO,MAAMA,IAAU,CAAC,EAAE,IAAAC,GAAI,OAAAC,GAAO,UAAAC,GAAU,WAAAC,IAAY,SAAuB;AAChF,QAAMC,IAAM,IAAIH,CAAK,IACf,CAACI,GAAUC,CAAW,IAAIC,EAAS,EAAK,GAExCC,IAAoB,CAACC,MAA2C;AACpE,IAAAA,EAAE,eAAA;A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AA,CAAkW;AAAA,UAAA;AAAA,QAAA;AAAA,MAC5W;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
@@ -1,52 +1,52 @@
1
- import { jsx as a, jsxs as p } from "react/jsx-runtime";
2
- import s, { useState as k, useRef as w, useEffect as x } from "react";
3
- import { cn as f } from "../../../utils/cn.js";
4
- const A = s.createContext({
1
+ import { jsx as a, jsxs as u } from "react/jsx-runtime";
2
+ import m, { useState as k, useRef as w, useEffect as N } from "react";
3
+ import { cn as p } from "../../../utils/cn.js";
4
+ const x = m.createContext({
5
5
  activeTab: 0,
6
6
  setActiveTab: () => {
7
7
  }
8
8
  });
9
- function E({ children: h, defaultTab: v = 0, defaultTabIndex: y, className: g, onClickTab: m, onChange: c }) {
10
- const [o, b] = k(y ?? v), l = w([]), r = s.Children.toArray(h);
11
- x(() => {
12
- l.current = l.current.slice(0, r.length);
13
- }, [r.length]);
9
+ function E({ children: h, defaultTab: v = 0, defaultTabIndex: y, className: g, onClickTab: o, onChange: c }) {
10
+ const [s, b] = k(y ?? v), l = w([]), n = m.Children.toArray(h);
11
+ N(() => {
12
+ l.current = l.current.slice(0, n.length);
13
+ }, [n.length]);
14
14
  const _ = (e, t) => {
15
15
  var i;
16
- let n = t;
16
+ let r = t;
17
17
  switch (e.key) {
18
18
  case "ArrowRight":
19
- e.preventDefault(), n = (t + 1) % r.length;
19
+ e.preventDefault(), r = (t + 1) % n.length;
20
20
  break;
21
21
  case "ArrowLeft":
22
- e.preventDefault(), n = (t - 1 + r.length) % r.length;
22
+ e.preventDefault(), r = (t - 1 + n.length) % n.length;
23
23
  break;
24
24
  case "Home":
25
- e.preventDefault(), n = 0;
25
+ e.preventDefault(), r = 0;
26
26
  break;
27
27
  case "End":
28
- e.preventDefault(), n = r.length - 1;
28
+ e.preventDefault(), r = n.length - 1;
29
29
  break;
30
30
  default:
31
31
  return;
32
32
  }
33
- b(n), (i = l.current[n]) == null || i.focus();
33
+ b(r), (i = l.current[r]) == null || i.focus();
34
34
  };
35
- return /* @__PURE__ */ a(A.Provider, { value: { activeTab: o, setActiveTab: b }, children: /* @__PURE__ */ p("div", { className: f("mint:my-6", g), children: [
35
+ return /* @__PURE__ */ a(x.Provider, { value: { activeTab: s, setActiveTab: b }, children: /* @__PURE__ */ u("div", { className: p("mint:my-6", g), children: [
36
36
  /* @__PURE__ */ a(
37
37
  "div",
38
38
  {
39
39
  role: "tablist",
40
40
  "aria-label": "Content tabs",
41
41
  className: "mint:flex mint:gap-1 mint:border-b mint:border-gray-200 mint:mb-4 mint:overflow-x-auto mint:dark:border-b-gray-700",
42
- children: r.map((e, t) => {
43
- if (!s.isValidElement(e)) return null;
44
- const n = e.props.title || `Tab ${t + 1}`, i = e.props.icon, d = o === t;
42
+ children: n.map((e, t) => {
43
+ if (!m.isValidElement(e)) return null;
44
+ const r = e.props.title || `Tab ${t + 1}`, i = e.props.icon, d = s === t;
45
45
  return /* @__PURE__ */ a(
46
46
  "button",
47
47
  {
48
- ref: (u) => {
49
- l.current[t] = u;
48
+ ref: (f) => {
49
+ l.current[t] = f;
50
50
  },
51
51
  role: "tab",
52
52
  "aria-selected": d,
@@ -54,16 +54,19 @@ function E({ children: h, defaultTab: v = 0, defaultTabIndex: y, className: g, o
54
54
  id: `tab-${t}`,
55
55
  tabIndex: d ? 0 : -1,
56
56
  onClick: () => {
57
- b(t), m == null || m(t), c == null || c(t);
57
+ b(t), o == null || o(t), c == null || c(t);
58
58
  },
59
- onKeyDown: (u) => _(u, t),
60
- className: f(
61
- "mint:px-4 mint:py-2 mint:text-sm mint:font-medium mint:border-0 mint:border-b-2 mint:rounded-t mint:bg-transparent mint:cursor-pointer mint:transition-all mint:duration-150 mint:focus:outline-none mint:focus-visible:shadow-[0_0_0_2px_#fff,0_0_0_4px_#75b6e7] mint:focus-visible:outline-offset-2",
62
- d ? "mint:border-b-[#0078d4] mint:text-[#0078d4] mint:dark:border-b-[#75b6e7] mint:dark:text-[#75b6e7]" : "mint:border-b-transparent mint:text-gray-600 mint:hover:text-gray-900 mint:hover:border-b-gray-300 mint:dark:text-gray-400 mint:dark:hover:text-gray-200 mint:dark:hover:border-b-gray-600"
59
+ onKeyDown: (f) => _(f, t),
60
+ className: p(
61
+ "mint:px-4 mint:py-2 mint:text-sm mint:font-medium mint:border-0 mint:border-b-2 mint:rounded-t mint:bg-transparent mint:cursor-pointer mint:focus:outline-none mint:focus-visible:shadow-[0_0_0_2px_#fff,0_0_0_4px_#75b6e7] mint:focus-visible:outline-offset-2",
62
+ d ? "mint:border-b-[#8251ee] mint:text-[#242424] mint:dark:border-b-[#9263f1] mint:dark:text-[#ffffff] mint:font-semibold" : "mint:border-b-transparent mint:text-gray-600 mint:hover:text-gray-900 mint:hover:border-b-gray-300 mint:dark:text-gray-400 mint:dark:hover:text-gray-200 mint:dark:hover:border-b-gray-600"
63
63
  ),
64
- children: /* @__PURE__ */ p("span", { className: "mint:flex mint:items-center mint:gap-2", children: [
64
+ children: /* @__PURE__ */ u("span", { className: "mint:flex mint:items-center mint:gap-2", children: [
65
65
  i && /* @__PURE__ */ a("span", { "aria-hidden": "true", children: i }),
66
- n
66
+ /* @__PURE__ */ u("span", { className: "mint:relative", children: [
67
+ /* @__PURE__ */ a("span", { className: "mint:invisible mint:font-semibold", "aria-hidden": "true", children: r }),
68
+ /* @__PURE__ */ a("span", { className: "mint:absolute mint:inset-0", children: r })
69
+ ] })
67
70
  ] })
68
71
  },
69
72
  t
@@ -71,19 +74,19 @@ function E({ children: h, defaultTab: v = 0, defaultTabIndex: y, className: g, o
71
74
  })
72
75
  }
73
76
  ),
74
- /* @__PURE__ */ a("div", { children: r.map((e, t) => /* @__PURE__ */ a(
77
+ /* @__PURE__ */ a("div", { children: n.map((e, t) => /* @__PURE__ */ a(
75
78
  "div",
76
79
  {
77
80
  role: "tabpanel",
78
81
  id: `tabpanel-${t}`,
79
82
  "aria-labelledby": `tab-${t}`,
80
83
  tabIndex: 0,
81
- hidden: o !== t,
82
- className: f(
84
+ hidden: s !== t,
85
+ className: p(
83
86
  "mint:outline-none",
84
- o !== t && "mint:hidden"
87
+ s !== t && "mint:hidden"
85
88
  ),
86
- children: s.isValidElement(e) ? e.props.children : null
89
+ children: m.isValidElement(e) ? e.props.children : null
87
90
  },
88
91
  t
89
92
  )) })
@@ -91,6 +94,6 @@ function E({ children: h, defaultTab: v = 0, defaultTabIndex: y, className: g, o
91
94
  }
92
95
  export {
93
96
  E as Tabs,
94
- A as TabsContext
97
+ x as TabsContext
95
98
  };
96
99
  //# sourceMappingURL=tabs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tabs.js","sources":["../../../../src/components/content-components/tabs/tabs.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from \"react\";\nimport { cn } from \"../../../utils/cn\";\n\ninterface TabsProps {\n children: React.ReactNode;\n defaultTab?: number;\n defaultTabIndex?: number;\n className?: string;\n onClickTab?: (index: number) => void;\n onChange?: (index: number) => void;\n}\n\ninterface TabsContextValue {\n activeTab: number;\n setActiveTab: (index: number) => void;\n}\n\nexport const TabsContext = React.createContext<TabsContextValue>({\n activeTab: 0,\n setActiveTab: () => {},\n});\n\nexport function Tabs({ children, defaultTab = 0, defaultTabIndex, className, onClickTab, onChange }: TabsProps) {\n const [activeTab, setActiveTab] = useState(defaultTabIndex ?? defaultTab);\n const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);\n\n const tabs = React.Children.toArray(children);\n\n useEffect(() => {\n tabRefs.current = tabRefs.current.slice(0, tabs.length);\n }, [tabs.length]);\n\n const handleKeyDown = (event: React.KeyboardEvent, currentIndex: number) => {\n let newIndex = currentIndex;\n\n switch (event.key) {\n case \"ArrowRight\":\n event.preventDefault();\n newIndex = (currentIndex + 1) % tabs.length;\n break;\n case \"ArrowLeft\":\n event.preventDefault();\n newIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n break;\n case \"Home\":\n event.preventDefault();\n newIndex = 0;\n break;\n case \"End\":\n event.preventDefault();\n newIndex = tabs.length - 1;\n break;\n default:\n return;\n }\n\n setActiveTab(newIndex);\n tabRefs.current[newIndex]?.focus();\n };\n\n return (\n <TabsContext.Provider value={{ activeTab, setActiveTab }}>\n <div className={cn(\"mint:my-6\", className)}>\n <div\n role=\"tablist\"\n aria-label=\"Content tabs\"\n className=\"mint:flex mint:gap-1 mint:border-b mint:border-gray-200 mint:mb-4 mint:overflow-x-auto mint:dark:border-b-gray-700\"\n >\n {tabs.map((tab, index) => {\n if (!React.isValidElement(tab)) return null;\n const title = tab.props.title || `Tab ${index + 1}`;\n const icon = tab.props.icon;\n const isActive = activeTab === index;\n\n return (\n <button\n key={index}\n ref={(el) => {tabRefs.current[index] = el}}\n role=\"tab\"\n aria-selected={isActive}\n aria-controls={`tabpanel-${index}`}\n id={`tab-${index}`}\n tabIndex={isActive ? 0 : -1}\n onClick={() => {\n setActiveTab(index);\n onClickTab?.(index);\n onChange?.(index);\n }}\n onKeyDown={(e) => handleKeyDown(e, index)}\n className={cn(\n \"mint:px-4 mint:py-2 mint:text-sm mint:font-medium mint:border-0 mint:border-b-2 mint:rounded-t mint:bg-transparent mint:cursor-pointer mint:transition-all mint:duration-150 mint:focus:outline-none mint:focus-visible:shadow-[0_0_0_2px_#fff,0_0_0_4px_#75b6e7] mint:focus-visible:outline-offset-2\",\n isActive\n ? \"mint:border-b-[#0078d4] mint:text-[#0078d4] mint:dark:border-b-[#75b6e7] mint:dark:text-[#75b6e7]\"\n : \"mint:border-b-transparent mint:text-gray-600 mint:hover:text-gray-900 mint:hover:border-b-gray-300 mint:dark:text-gray-400 mint:dark:hover:text-gray-200 mint:dark:hover:border-b-gray-600\"\n )}\n >\n <span className=\"mint:flex mint:items-center mint:gap-2\">\n {icon && <span aria-hidden=\"true\">{icon}</span>}\n {title}\n </span>\n </button>\n );\n })}\n </div>\n\n <div>\n {tabs.map((tab, index) => (\n <div\n key={index}\n role=\"tabpanel\"\n id={`tabpanel-${index}`}\n aria-labelledby={`tab-${index}`}\n tabIndex={0}\n hidden={activeTab !== index}\n className={cn(\n \"mint:outline-none\",\n activeTab !== index && \"mint:hidden\"\n )}\n >\n {React.isValidElement(tab) ? tab.props.children : null}\n </div>\n ))}\n </div>\n </div>\n </TabsContext.Provider>\n );\n}\n"],"names":["TabsContext","React","Tabs","children","defaultTab","defaultTabIndex","className","onClickTab","onChange","activeTab","setActiveTab","useState","tabRefs","useRef","tabs","useEffect","handleKeyDown","event","currentIndex","newIndex","_a","jsx","cn","tab","index","title","icon","isActive","el","e","jsxs"],"mappings":";;;AAiBO,MAAMA,IAAcC,EAAM,cAAgC;AAAA,EAC/D,WAAW;AAAA,EACX,cAAc,MAAM;AAAA,EAAC;AACvB,CAAC;AAEM,SAASC,EAAK,EAAE,UAAAC,GAAU,YAAAC,IAAa,GAAG,iBAAAC,GAAiB,WAAAC,GAAW,YAAAC,GAAY,UAAAC,KAAuB;AAC9G,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAASN,KAAmBD,CAAU,GAClEQ,IAAUC,EAAqC,EAAE,GAEjDC,IAAOb,EAAM,SAAS,QAAQE,CAAQ;AAE5C,EAAAY,EAAU,MAAM;AACd,IAAAH,EAAQ,UAAUA,EAAQ,QAAQ,MAAM,GAAGE,EAAK,MAAM;AAAA,EACxD,GAAG,CAACA,EAAK,MAAM,CAAC;AAEhB,QAAME,IAAgB,CAACC,GAA4BC,MAAyB;;AAC1E,QAAIC,IAAWD;AAEf,YAAQD,EAAM,KAAA;AAAA,MACZ,KAAK;AACH,QAAAA,EAAM,eAAA,GACNE,KAAYD,IAAe,KAAKJ,EAAK;AACrC;AAAA,MACF,KAAK;AACH,QAAAG,EAAM,eAAA,GACNE,KAAYD,IAAe,IAAIJ,EAAK,UAAUA,EAAK;AACnD;AAAA,MACF,KAAK;AACH,QAAAG,EAAM,eAAA,GACNE,IAAW;AACX;AAAA,MACF,KAAK;AACH,QAAAF,EAAM,eAAA,GACNE,IAAWL,EAAK,SAAS;AACzB;AAAA,MACF;AACE;AAAA,IAAA;AAGJ,IAAAJ,EAAaS,CAAQ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UAAA;AAAA,QA0BX,CAAC;AAAA,MAAA;AAAA,IAAA;AAAA,sBAGF,OAAA,EACE,UAAAV,EAAK,IAAI,CAACS,GAAKC,MACd,gBAAAH;AAAA,MAAC;AAAA,MAAA;AAAA,QAEC,MAAK;AAAA,QACL,IAAI,YAAYG,CAAK;AAAA,QACrB,mBAAiB,OAAOA,CAAK;AAAA,QAC7B,UAAU;AAAA,QACV,QAAQf,MAAce;AAAA,QACtB,WAAWF;AAAA,UACT;AAAA,UACAb,MAAce,KAAS;AAAA,QAAA;AAAA,QAGxB,YAAM,eAAeD,CAAG,IAAIA,EAAI,MAAM,WAAW;AAAA,MAAA;AAAA,MAX7CC;AAAA,IAAA,CAaR,EAAA,CACH;AAAA,EAAA,EAAA,CACF,EAAA,CACF;AAEJ;"}
1
+ {"version":3,"file":"tabs.js","sources":["../../../../src/components/content-components/tabs/tabs.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from \"react\";\nimport { cn } from \"../../../utils/cn\";\n\ninterface TabsProps {\n children: React.ReactNode;\n defaultTab?: number;\n defaultTabIndex?: number;\n className?: string;\n onClickTab?: (index: number) => void;\n onChange?: (index: number) => void;\n}\n\ninterface TabsContextValue {\n activeTab: number;\n setActiveTab: (index: number) => void;\n}\n\nexport const TabsContext = React.createContext<TabsContextValue>({\n activeTab: 0,\n setActiveTab: () => {},\n});\n\nexport function Tabs({ children, defaultTab = 0, defaultTabIndex, className, onClickTab, onChange }: TabsProps) {\n const [activeTab, setActiveTab] = useState(defaultTabIndex ?? defaultTab);\n const tabRefs = useRef<(HTMLButtonElement | null)[]>([]);\n\n const tabs = React.Children.toArray(children);\n\n useEffect(() => {\n tabRefs.current = tabRefs.current.slice(0, tabs.length);\n }, [tabs.length]);\n\n const handleKeyDown = (event: React.KeyboardEvent, currentIndex: number) => {\n let newIndex = currentIndex;\n\n switch (event.key) {\n case \"ArrowRight\":\n event.preventDefault();\n newIndex = (currentIndex + 1) % tabs.length;\n break;\n case \"ArrowLeft\":\n event.preventDefault();\n newIndex = (currentIndex - 1 + tabs.length) % tabs.length;\n break;\n case \"Home\":\n event.preventDefault();\n newIndex = 0;\n break;\n case \"End\":\n event.preventDefault();\n newIndex = tabs.length - 1;\n break;\n default:\n return;\n }\n\n setActiveTab(newIndex);\n tabRefs.current[newIndex]?.focus();\n };\n\n return (\n <TabsContext.Provider value={{ activeTab, setActiveTab }}>\n <div className={cn(\"mint:my-6\", className)}>\n <div\n role=\"tablist\"\n aria-label=\"Content tabs\"\n className=\"mint:flex mint:gap-1 mint:border-b mint:border-gray-200 mint:mb-4 mint:overflow-x-auto mint:dark:border-b-gray-700\"\n >\n {tabs.map((tab, index) => {\n if (!React.isValidElement(tab)) return null;\n const title = tab.props.title || `Tab ${index + 1}`;\n const icon = tab.props.icon;\n const isActive = activeTab === index;\n\n return (\n <button\n key={index}\n ref={(el) => {tabRefs.current[index] = el}}\n role=\"tab\"\n aria-selected={isActive}\n aria-controls={`tabpanel-${index}`}\n id={`tab-${index}`}\n tabIndex={isActive ? 0 : -1}\n onClick={() => {\n setActiveTab(index);\n onClickTab?.(index);\n onChange?.(index);\n }}\n onKeyDown={(e) => handleKeyDown(e, index)}\n className={cn(\n \"mint:px-4 mint:py-2 mint:text-sm mint:font-medium mint:border-0 mint:border-b-2 mint:rounded-t mint:bg-transparent mint:cursor-pointer mint:focus:outline-none mint:focus-visible:shadow-[0_0_0_2px_#fff,0_0_0_4px_#75b6e7] mint:focus-visible:outline-offset-2\",\n isActive\n ? \"mint:border-b-[#8251ee] mint:text-[#242424] mint:dark:border-b-[#9263f1] mint:dark:text-[#ffffff] mint:font-semibold\"\n : \"mint:border-b-transparent mint:text-gray-600 mint:hover:text-gray-900 mint:hover:border-b-gray-300 mint:dark:text-gray-400 mint:dark:hover:text-gray-200 mint:dark:hover:border-b-gray-600\"\n )}\n >\n <span className=\"mint:flex mint:items-center mint:gap-2\">\n {icon && <span aria-hidden=\"true\">{icon}</span>}\n <span className=\"mint:relative\">\n <span className=\"mint:invisible mint:font-semibold\" aria-hidden=\"true\">\n {title}\n </span>\n <span className=\"mint:absolute mint:inset-0\">\n {title}\n </span>\n </span>\n </span>\n </button>\n );\n })}\n </div>\n\n <div>\n {tabs.map((tab, index) => (\n <div\n key={index}\n role=\"tabpanel\"\n id={`tabpanel-${index}`}\n aria-labelledby={`tab-${index}`}\n tabIndex={0}\n hidden={activeTab !== index}\n className={cn(\n \"mint:outline-none\",\n activeTab !== index && \"mint:hidden\"\n )}\n >\n {React.isValidElement(tab) ? tab.props.children : null}\n </div>\n ))}\n </div>\n </div>\n </TabsContext.Provider>\n );\n}\n"],"names":["TabsContext","React","Tabs","children","defaultTab","defaultTabIndex","className","onClickTab","onChange","activeTab","setActiveTab","useState","tabRefs","useRef","tabs","useEffect","handleKeyDown","event","currentIndex","newIndex","_a","jsx","cn","tab","index","title","icon","isActive","el","e","jsxs"],"mappings":";;;AAiBO,MAAMA,IAAcC,EAAM,cAAgC;AAAA,EAC/D,WAAW;AAAA,EACX,cAAc,MAAM;AAAA,EAAC;AACvB,CAAC;AAEM,SAASC,EAAK,EAAE,UAAAC,GAAU,YAAAC,IAAa,GAAG,iBAAAC,GAAiB,WAAAC,GAAW,YAAAC,GAAY,UAAAC,KAAuB;AAC9G,QAAM,CAACC,GAAWC,CAAY,IAAIC,EAASN,KAAmBD,CAAU,GAClEQ,IAAUC,EAAqC,EAAE,GAEjDC,IAAOb,EAAM,SAAS,QAAQE,CAAQ;AAE5C,EAAAY,EAAU,MAAM;AACd,IAAAH,EAAQ,UAAUA,EAAQ,QAAQ,MAAM,GAAGE,EAAK,MAAM;AAAA,EACxD,GAAG,CAACA,EAAK,MAAM,CAAC;AAEhB,QAAME,IAAgB,CAACC,GAA4BC,MAAyB;;AAC1E,QAAIC,IAAWD;AAEf,YAAQD,EAAM,KAAA;AAAA,MACZ,KAAK;AACH,QAAAA,EAAM,eAAA,GACNE,KAAYD,IAAe,KAAKJ,EAAK;AACrC;AAAA,MACF,KAAK;AACH,QAAAG,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