/**
 * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
 * SPDX-License-Identifier: MIT
 */

import React from 'react';

import { Field } from '@flowgram.ai/free-layout-editor';

import { FreeFormMetaStoryBuilder, FormHeader } from '../../free-form-meta-story-builder';

const ConditionRow = React.lazy(() =>
  import('@flowgram.ai/form-materials').then((module) => ({
    default: module.ConditionRow,
  }))
);

export const BasicStory = () => (
  <FreeFormMetaStoryBuilder
    filterEndNode
    formMeta={{
      render: () => (
        <>
          <FormHeader />
          <Field<any | undefined>
            name="condition_row"
            defaultValue={{
              left: {
                type: 'ref',
                content: ['start_0', 'str'],
              },
              operator: 'eq',
              right: {
                type: 'constant',
                content: 'Hello World!',
                schema: {
                  type: 'string',
                },
              },
            }}
          >
            {({ field }) => (
              <ConditionRow value={field.value} onChange={(value) => field.onChange(value)} />
            )}
          </Field>
        </>
      ),
    }}
  />
);
