{"version":3,"file":"ContentSelector.cjs","names":["isEnabled"],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { FunctionalComponent, HTMLAttributes } from 'preact';\nimport { useEffect } from 'preact/hooks';\n\n// JSX declaration for the Lit web component in Preact\ndeclare module 'preact' {\n  namespace JSX {\n    interface IntrinsicElements {\n      'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {\n        'key-path'?: string;\n        'dictionary-key'?: string;\n      };\n    }\n  }\n}\n\nexport type ContentSelectorWrapperProps = NodeProps &\n  Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FunctionalComponent<\n  ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n  useEffect(() => {\n    if (\n      process.env.INTLAYER_EDITOR_ENABLED === 'false' ||\n      !isEnabled ||\n      typeof window === 'undefined'\n    )\n      return;\n    import('@intlayer/editor')\n      .then(({ defineIntlayerElements }) => {\n        defineIntlayerElements();\n      })\n      .catch(() => {});\n  }, [isEnabled]);\n\n  if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) {\n    return children;\n  }\n\n  return (\n    <intlayer-content-selector-wrapper\n      key-path={JSON.stringify(keyPath)}\n      dictionary-key={dictionaryKey}\n    >\n      {children}\n    </intlayer-content-selector-wrapper>\n  );\n};\n"],"mappings":";;;;;;AAoBA,MAAa,mBAER,EAAE,UAAU,eAAe,cAAc;CAC5C,kCAAgB;EACd,IACE,QAAQ,IAAI,4BAA4B,WACxC,CAACA,wCACD,OAAO,WAAW,aAElB;EACF,OAAO,mBAAmB,CACvB,MAAM,EAAE,6BAA6B;GACpC,uBAAuB;EACzB,CAAC,CAAC,CACD,YAAY,CAAC,CAAC;CACnB,GAAG,CAACA,oCAAS,CAAC;CAEd,IAAI,QAAQ,IAAI,4BAA4B,WAAW,CAACA,sCACtD,OAAO;CAGT,OACE,4CAAC,qCAAD;EACE,YAAU,KAAK,UAAU,OAAO;EAChC,kBAAgB;EAEf;CACgC;AAEvC"}