import { SavedObjectAttributes } from 'opensearch-dashboards/public' ; import { EmbeddableFactoryDefinition } from './embeddable_factory_definition' ; import { EmbeddableInput , EmbeddableOutput , IEmbeddable } from './i_embeddable' ; import { EmbeddableFactory } from './embeddable_factory' ; import { IContainer } from '..' ; export const defaultEmbeddableFactoryProvider = < I extends EmbeddableInput = EmbeddableInput , O extends EmbeddableOutput = EmbeddableOutput , E extends IEmbeddable < I , O > = IEmbeddable < I , O > , T extends SavedObjectAttributes = SavedObjectAttributes > ( def ) : EmbeddableFactory < I , O , E , T > => { const factory = { isContainerType : def . isContainerType ?? false , canCreateNew : def . canCreateNew ? def . canCreateNew . bind ( def ) : ( ) => true , getDefaultInput : def . getDefaultInput ? def . getDefaultInput . bind ( def ) : ( ) => ( { } ) , getExplicitInput : def . getExplicitInput ? def . getExplicitInput . bind ( def ) : ( ) => Promise . resolve ( { } ) , createFromSavedObject : def . createFromSavedObject ? def . createFromSavedObject . bind ( def ) : ( savedObjectId , input , parent ? ) => { throw new Error ( `Creation from saved object not supported by type ${ def . type }` ) ; } , create : def . create . bind ( def ) , type : def . type , isEditable : def . isEditable . bind ( def ) , getDisplayName : def . getDisplayName . bind ( def ) , savedObjectMetaData : def . savedObjectMetaData , telemetry : def . telemetry || ( ( ) => ( { } ) ) , inject : def . inject || ( ( state ) => state ) , extract : def . extract || ( ( state ) => ( { state , references : [ ] } ) ) , } ; return factory ; } ;