{"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","editor","ContentSelector","fallbackPlugin","renderReactElement","Fragment","NodeTypes","func","useLoadDynamic","internationalization","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n  conditionPlugin,\n  type DeepTransformContent as DeepTransformContentCore,\n  enumerationPlugin,\n  fallbackPlugin,\n  filePlugin,\n  genderPlugin,\n  type IInterpreterPluginState as IInterpreterPluginStateCore,\n  nestedPlugin,\n  type Plugins,\n  pluralPlugin,\n  splitInsertionTemplate,\n  translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n  HTMLContent,\n  InsertionContent,\n  MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n  DeclaredLocales,\n  LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport {\n  createElement,\n  type FC,\n  Fragment,\n  type ReactElement,\n  type ReactNode,\n} from 'react';\nimport { useLoadDynamic } from './client/useLoadDynamic';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/HTMLComponentTypes';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderReactElement } from './reactElement/renderReactElement';\n\nconst markdownRendererModulePromise =\n  process.env['INTLAYER_NODE_TYPE_MARKDOWN'] !== 'false'\n    ? import('./markdown/MarkdownRendererPlugin').then(\n        (m) => m.MarkdownRendererPlugin\n      )\n    : null;\n\nconst htmlRendererModulePromise =\n  process.env['INTLAYER_NODE_TYPE_HTML'] !== 'false'\n    ? import('./html/HTMLRendererPlugin').then((m) => m.HTMLRendererPlugin)\n    : null;\n\n/** ---------------------------------------------\n *  INTLAYER NODE PLUGIN\n *  --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n  ? IntlayerNode<T>\n  : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n  id: 'intlayer-node-plugin',\n  canHandle: (node) =>\n    typeof node === 'bigint' ||\n    typeof node === 'string' ||\n    typeof node === 'number',\n  transform: (\n    _node,\n    {\n      plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n      ...rest\n    }\n  ) =>\n    renderIntlayerNode({\n      ...rest,\n      value: rest.children,\n      children:\n        process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' && editor.enabled ? (\n          <ContentSelector {...rest}>{rest.children}</ContentSelector>\n        ) : (\n          rest.children\n        ),\n    }),\n};\n\n/** ---------------------------------------------\n *  REACT NODE PLUGIN\n *  --------------------------------------------- */\n\nexport type ReactNodeCond<T> = T extends {\n  props: any;\n  key: any;\n}\n  ? ReactNode\n  : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const reactNodePlugins: Plugins =\n  process.env['INTLAYER_NODE_TYPE_REACT_NODE'] === 'false'\n    ? fallbackPlugin\n    : {\n        id: 'react-node-plugin',\n        canHandle: (node) =>\n          typeof node === 'object' &&\n          typeof node?.props !== 'undefined' &&\n          typeof node.key !== 'undefined',\n\n        transform: (\n          node,\n          {\n            plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n            ...rest\n          }\n        ) =>\n          renderIntlayerNode({\n            ...rest,\n            value: '[[react-element]]',\n            children:\n              process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n              editor.enabled ? (\n                <ContentSelector {...rest}>\n                  {renderReactElement(node)}\n                </ContentSelector>\n              ) : (\n                renderReactElement(node)\n              ),\n          }),\n      };\n\n/** ---------------------------------------------\n *  INSERTION PLUGIN\n *  --------------------------------------------- */\n\nexport type InsertionCond<T> = T extends {\n  nodeType: NodeType | string;\n  [NodeTypes.INSERTION]: infer I;\n  fields: readonly string[];\n}\n  ? <V extends { [K in T['fields'][number]]: ReactNode }>(\n      values: V\n    ) => I extends string\n      ? V[keyof V] extends string | number\n        ? IntlayerNode<string>\n        : IntlayerNode<ReactNode>\n      : DeepTransformContent<I>\n  : never;\n\n/**\n * Split insertion string and join with React nodes using shared core logic\n */\nconst splitAndJoinInsertion = (\n  template: string,\n  values: Record<string, string | number | ReactNode>\n): ReactNode => {\n  const result = splitInsertionTemplate(template, values);\n\n  if (result.isSimple) {\n    // Simple string replacement\n    return result.parts as string;\n  }\n\n  // Return as Fragment with proper keys\n  return createElement(\n    Fragment,\n    null,\n    ...(result.parts as any[]).map((part, index) =>\n      createElement(Fragment, { key: index }, part)\n    )\n  );\n};\n\n/** Insertion plugin for React. Handles component/node insertion. */\nexport const insertionPlugin: Plugins =\n  process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false'\n    ? fallbackPlugin\n    : {\n        id: 'insertion-plugin',\n        canHandle: (node) =>\n          typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n        transform: (node: InsertionContent, props, deepTransformNode) => {\n          const newKeyPath: KeyPath[] = [\n            ...props.keyPath,\n            {\n              type: NodeTypes.INSERTION,\n            },\n          ];\n\n          const children = node[NodeTypes.INSERTION];\n\n          /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n          const insertionStringPlugin: Plugins = {\n            id: 'insertion-string-plugin',\n            canHandle: (node) => typeof node === 'string',\n            transform: (node: string, subProps, deepTransformNode) => {\n              const transformedResult = deepTransformNode(node, {\n                ...subProps,\n                children: node,\n                plugins: [\n                  ...(props.plugins ?? ([] as Plugins[])).filter(\n                    (plugin) => plugin.id !== 'intlayer-node-plugin'\n                  ),\n                ],\n              });\n\n              return (\n                values: {\n                  [K in InsertionContent['fields'][number]]:\n                    | string\n                    | number\n                    | ReactNode;\n                }\n              ) => {\n                const result = splitAndJoinInsertion(transformedResult, values);\n\n                return deepTransformNode(result, {\n                  ...subProps,\n                  plugins: props.plugins,\n                  children: result,\n                });\n              };\n            },\n          };\n\n          const result = deepTransformNode(children, {\n            ...props,\n            children,\n            keyPath: newKeyPath,\n            plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n          });\n\n          if (\n            typeof children === 'object' &&\n            children !== null &&\n            'nodeType' in children &&\n            [NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(\n              children.nodeType as\n                | typeof NodeTypes.ENUMERATION\n                | typeof NodeTypes.CONDITION\n            )\n          ) {\n            return (values: any) => (arg: any) => {\n              const func = result as Function;\n              const inner = func(arg);\n\n              if (typeof inner === 'function') {\n                return inner(values);\n              }\n              return inner;\n            };\n          }\n\n          return result;\n        },\n      };\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n  ? IntlayerNode<\n      string,\n      {\n        metadata: DeepTransformContent<string>;\n        use: (components: HTMLComponents<'permissive', {}>) => ReactNode;\n      }\n    >\n  : never;\n\nconst MarkdownSuspenseRenderer: FC<Record<string, any>> = ({\n  children,\n  ...props\n}) => {\n  const MarkdownRendererPlugin = useLoadDynamic(\n    'markdown-renderer-plugin',\n    markdownRendererModulePromise!\n  );\n  return createElement(MarkdownRendererPlugin as any, { ...props, children });\n};\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n  process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n    ? fallbackPlugin\n    : {\n        id: 'markdown-string-plugin',\n        canHandle: (node) => typeof node === 'string',\n        transform: (node: string, props, deepTransformNode) => {\n          const {\n            plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n            ...rest\n          } = props;\n\n          const metadata = getMarkdownMetadata(node) ?? {};\n\n          const metadataPlugins: Plugins = {\n            id: 'markdown-metadata-plugin',\n            canHandle: (metadataNode) =>\n              typeof metadataNode === 'string' ||\n              typeof metadataNode === 'number' ||\n              typeof metadataNode === 'boolean' ||\n              !metadataNode,\n            transform: (metadataNode, props) =>\n              renderIntlayerNode({\n                ...props,\n                value: metadataNode,\n                children:\n                  process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n                  editor.enabled ? (\n                    <ContentSelector {...rest}>{node}</ContentSelector>\n                  ) : (\n                    node\n                  ),\n              }),\n          };\n\n          // Transform metadata while keeping the same structure\n          const metadataNodes = deepTransformNode(metadata, {\n            plugins: [metadataPlugins],\n            dictionaryKey: rest.dictionaryKey,\n            keyPath: [],\n          });\n\n          const render = (components?: HTMLComponents) =>\n            renderIntlayerNode({\n              ...props,\n              value: node,\n              children:\n                process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n                editor.enabled ? (\n                  <ContentSelector {...rest}>\n                    <MarkdownSuspenseRenderer {...rest} components={components}>\n                      {node}\n                    </MarkdownSuspenseRenderer>\n                  </ContentSelector>\n                ) : (\n                  <MarkdownSuspenseRenderer {...rest} components={components}>\n                    {node}\n                  </MarkdownSuspenseRenderer>\n                ),\n              additionalProps: {\n                metadata: metadataNodes,\n              },\n            });\n\n          const element = render() as unknown as ReactElement;\n\n          return new Proxy(element, {\n            get(target, prop, receiver) {\n              if (prop === 'value') return node;\n              if (prop === Symbol.toPrimitive) return () => node;\n              if (prop === 'toString') return () => node;\n              if (prop === 'valueOf') return () => node;\n              if (typeof prop === 'string' && prop !== 'constructor') {\n                const method = (String.prototype as any)[prop];\n                if (typeof method === 'function') return method.bind(node);\n              }\n              if (prop === 'metadata') return metadataNodes;\n              if (prop === 'use')\n                return (components?: HTMLComponents) => render(components);\n              return Reflect.get(target, prop, receiver);\n            },\n          }) as any;\n        },\n      };\n\nexport type MarkdownCond<T> = T extends {\n  nodeType: NodeType | string;\n  [NodeTypes.MARKDOWN]: infer M;\n  tags?: infer U;\n  metadata?: infer V;\n}\n  ? IntlayerNode<\n      M,\n      {\n        use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n        metadata: DeepTransformContent<V>;\n      }\n    >\n  : never;\n\nexport const markdownPlugin: Plugins =\n  process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n    ? fallbackPlugin\n    : {\n        id: 'markdown-plugin',\n        canHandle: (node) =>\n          typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n        transform: (node: MarkdownContent, props, deepTransformNode) => {\n          const newKeyPath: KeyPath[] = [\n            ...props.keyPath,\n            {\n              type: NodeTypes.MARKDOWN,\n            },\n          ];\n\n          const children = node[NodeTypes.MARKDOWN];\n\n          return deepTransformNode(children, {\n            ...props,\n            children,\n            keyPath: newKeyPath,\n            plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n          });\n        },\n      };\n\n/** ---------------------------------------------\n *  HTML PLUGIN\n *  --------------------------------------------- */\n\n/**\n * HTML conditional type that enforces:\n * - All components (Standard or Custom) are OPTIONAL in the `use()` method.\n * - Custom components props are strictly inferred from the dictionary definition.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T> = T extends {\n  nodeType: NodeType | string;\n  [NodeTypes.HTML]: infer I;\n  tags?: infer U;\n}\n  ? IntlayerNode<\n      I,\n      {\n        use: (components?: HTMLComponents<'permissive', U>) => ReactNode;\n      }\n    >\n  : never;\n\nconst HTMLSuspenseRenderer: FC<Record<string, any>> = (props) => {\n  const HTMLRendererPlugin = useLoadDynamic(\n    'html-renderer-plugin',\n    htmlRendererModulePromise!\n  );\n  return createElement(HTMLRendererPlugin as any, props);\n};\n\n/** HTML plugin. Replaces node with a function that takes components => ReactNode. */\nexport const htmlPlugin: Plugins =\n  process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\n    ? fallbackPlugin\n    : {\n        id: 'html-plugin',\n        canHandle: (node) =>\n          typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n\n        transform: (node: HTMLContent<string>, props) => {\n          const html = node[NodeTypes.HTML];\n          const { plugins, ...rest } = props;\n\n          // Type-safe render function that accepts properly typed components\n          const render = (userComponents?: HTMLComponents): ReactNode =>\n            renderIntlayerNode({\n              ...rest,\n              value: html,\n              children:\n                process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n                editor.enabled ? (\n                  <ContentSelector {...rest}>\n                    <HTMLSuspenseRenderer\n                      {...rest}\n                      html={html}\n                      userComponents={userComponents}\n                    />\n                  </ContentSelector>\n                ) : (\n                  <HTMLSuspenseRenderer\n                    {...rest}\n                    html={html}\n                    userComponents={userComponents}\n                  />\n                ),\n            });\n\n          const element = render() as unknown as ReactElement;\n\n          return new Proxy(element, {\n            get(target, prop, receiver) {\n              if (prop === 'value') return html;\n              if (prop === Symbol.toPrimitive) return () => html;\n              if (prop === 'toString') return () => html;\n              if (prop === 'valueOf') return () => html;\n              if (typeof prop === 'string' && prop !== 'constructor') {\n                const method = (String.prototype as any)[prop];\n                if (typeof method === 'function') return method.bind(html);\n              }\n              if (prop === 'use')\n                return (userComponents?: HTMLComponents) =>\n                  render(userComponents);\n              return Reflect.get(target, prop, receiver);\n            },\n          }) as any;\n        },\n      };\n\n/** ---------------------------------------------\n *  PLUGINS RESULT\n *  --------------------------------------------- */\n\nexport type IInterpreterPluginReact<T, _S, _L extends LocalesValues> = {\n  reactNode: ReactNodeCond<T>;\n  reactIntlayerNode: IntlayerNodeCond<T>;\n  reactInsertion: InsertionCond<T>;\n  reactMarkdown: MarkdownCond<T>;\n  reactHtml: HTMLPluginCond<T>;\n};\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `react-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n  IInterpreterPluginStateCore,\n  'insertion' // Remove insertion type from core package\n> & {\n  reactNode: true;\n  reactIntlayerNode: true;\n  reactMarkdown: true;\n  reactHtml: true;\n  reactInsertion: true;\n};\n\nexport type DeepTransformContent<\n  T,\n  L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for React content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n  locale?: LocalesValues,\n  fallback: boolean = true\n): Plugins[] => {\n  const currentLocale = locale ?? internationalization.defaultLocale;\n  const cacheKey = `${currentLocale}_${fallback}`;\n\n  if (pluginsCache.has(cacheKey)) {\n    return pluginsCache.get(cacheKey)!;\n  }\n\n  const plugins = [\n    // Env var allows the bundler to to remove the plugin if not used to make the bundle smaller\n    translationPlugin(\n      locale ?? internationalization.defaultLocale,\n      fallback ? internationalization.defaultLocale : undefined\n    ),\n    enumerationPlugin,\n    pluralPlugin(locale ?? internationalization.defaultLocale),\n    conditionPlugin,\n    nestedPlugin(locale ?? internationalization.defaultLocale),\n\n    filePlugin,\n    genderPlugin,\n    // Always include: handle plain strings/numbers and React elements\n    intlayerNodePlugins,\n    reactNodePlugins,\n    insertionPlugin,\n    markdownPlugin,\n    htmlPlugin,\n  ] as Plugins[];\n\n  pluginsCache.set(cacheKey, plugins);\n\n  return plugins;\n};\n"],"mappings":";;;;;;;;;;;;;;;AAyCA,MAAM,gCACJ,QAAQ,IAAI,mCAAmC,+CAC3C,0CAA4C,MACzC,MAAM,EAAE,uBACV,GACD;AAEN,MAAM,4BACJ,QAAQ,IAAI,+BAA+B,+CACvC,kCAAoC,MAAM,MAAM,EAAE,mBAAmB,GACrE;;AAWN,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YACE,OACA,EACE,SACA,GAAG,WAGLA,wCAAmB;EACjB,GAAG;EACH,OAAO,KAAK;EACZ,UACE,QAAQ,IAAI,+BAA+B,WAAWC,8BAAO,UAC3D,2CAACC,gDAAD;GAAiB,GAAI;aAAO,KAAK;GAA2B,IAE5D,KAAK;EAEV,CAAC;CACL;;AAcD,MAAa,mBACX,QAAQ,IAAI,qCAAqC,UAC7CC,4CACA;CACE,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,MA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