import { FieldSchema } from '@ephox/boulder';
import { Optional } from '@ephox/katamari';
import { Composing } from '../behaviour/Composing';
import { Representing } from '../behaviour/Representing';
import { SketchBehaviours } from '../component/SketchBehaviours';
import * as AlloyEvents from '../events/AlloyEvents';
import * as Sketcher from './Sketcher';
const factory = (detail) => ({
    uid: detail.uid,
    dom: detail.dom,
    behaviours: SketchBehaviours.augment(detail.dataBehaviours, [
        Representing.config({
            store: {
                mode: 'memory',
                initialValue: detail.getInitialValue()
            }
        }),
        Composing.config({
            find: Optional.some
        })
    ]),
    events: AlloyEvents.derive([
        AlloyEvents.runOnAttached((component, _simulatedEvent) => {
            Representing.setValue(component, detail.getInitialValue());
        })
    ])
});
const DataField = Sketcher.single({
    name: 'DataField',
    factory,
    configFields: [
        FieldSchema.required('uid'),
        FieldSchema.required('dom'),
        FieldSchema.required('getInitialValue'),
        SketchBehaviours.field('dataBehaviours', [Representing, Composing])
    ]
});
export { DataField };
//# sourceMappingURL=DataField.js.map