import { developHelper } from "@next-core/brick-kit" ; import { isBrickNode , isRouteNode } from "../assertions" ; import { BuilderRuntimeNode } from "../interfaces" ; const ANY_BRICK_EDITOR = "basic-bricks.any-brick--editor" ; const ANY_ROUTE_EDITOR = "basic-bricks.any-route--editor" ; param node param editor returns export async function getEditorBrick ( node , editor ? ) { const tryEditorBricks = [ ] ; if ( isRouteNode ( node ) ) { tryEditorBricks . push ( ANY_ROUTE_EDITOR ) ; } else if ( isBrickNode ( node ) ) { if ( node . brick . includes ( "-" ) ) { tryEditorBricks . push ( `${ node . brick }--editor` ) ; } if ( editor ) { tryEditorBricks . push ( editor ) ; } tryEditorBricks . push ( ANY_BRICK_EDITOR ) ; } else { throw new Error ( `Unsupported node type: ${ node . type }` ) ; } for ( const editorBrick of tryEditorBricks ) { try { await developHelper . loadEditorBricks ( [ editorBrick ] ) ; } catch ( error ) { throw new Error ( `Load editor brick "${ editorBrick }" failed` ) ; } if ( customElements . get ( editorBrick ) ) { return editorBrick ; } } throw new Error ( `Editor brick "${ tryEditorBricks . join ( ", " ) }" not found` ) ; }