{"version":3,"sources":["jsdelivr-header.js","/npm/@sunmao-ui/editor@0.11.3/src/components/Editor.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/StructureTree/StructureTree.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/StructureTree/ComponentNode.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/StructureTree/ComponentItemView.tsx","/npm/@sunmao-ui/editor@0.11.3/src/operations/type.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/component/removeComponentLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/component/adjustComponentOrderLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/component/createComponentLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/component/modifyComponentIdLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/component/modifyComponentPropertiesLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/constants/index.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/component/pasteComponentLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/component/moveComponentLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/trait/removeTraitLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/trait/createTraitLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/trait/modifyTraitPropertiesLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/replaceAppLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/leaf/updateSelectComponentLeafOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/branch/component/createComponentBranchOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/branch/component/modifyComponentIdBranchOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/branch/component/removeComponentBranchOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/branch/component/moveComponentBranchOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/branch/component/extractModuleBranchOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/branch/datasource/createDataSourceBranchOperation.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/index.ts","/npm/@sunmao-ui/editor@0.11.3/src/components/StructureTree/DropComponentWrapper.tsx","/npm/@sunmao-ui/editor@0.11.3/src/AppModel/AppModel.ts","/npm/@sunmao-ui/editor@0.11.3/src/AppModel/utils.ts","/npm/@sunmao-ui/editor@0.11.3/src/AppModel/FieldModel.ts","/npm/@sunmao-ui/editor@0.11.3/src/validator/utils.ts","/npm/@sunmao-ui/editor@0.11.3/src/AppModel/TraitModel.ts","/npm/@sunmao-ui/editor@0.11.3/src/AppModel/ComponentModel.ts","/npm/node_modules/mitt/src/index.ts","/npm/@sunmao-ui/editor@0.11.3/src/components/RelationshipModal/RelationshipView.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/RelationshipModal/RelationshipModal.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ExtractModuleModal/ExtractModuleStep.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ExtractModuleModal/Placeholder.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ExtractModuleModal/ExtractModulePropertyForm.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ExtractModuleModal/ExtractModuleStateForm.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ExtractModuleModal/ExtractModuleEventForm.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/Explorer/ExplorerForm/ModuleMetaDataForm.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/CodeEditor/StateViewer.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ErrorBoundary.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/CodeEditor/CodeEditor.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ExtractModuleModal/ExtractModuleView.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ExtractModuleModal/utils.ts","/npm/@sunmao-ui/editor@0.11.3/src/components/ExtractModuleModal/ExtractModuleModal.tsx","/npm/@sunmao-ui/editor@0.11.3/src/utils/copy.ts","/npm/@sunmao-ui/editor@0.11.3/src/hooks/useModal.tsx","/npm/@sunmao-ui/editor@0.11.3/src/utils/resolveApplicationComponents.ts","/npm/@sunmao-ui/editor@0.11.3/src/components/StructureTree/useStructureTreeState.ts","/npm/@sunmao-ui/editor@0.11.3/src/components/ComponentsList/ComponentFilter.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/StructureTree/ComponentSearch.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ComponentsList/ComponentList.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/EditorHeader/EditorHeader.tsx","/npm/@sunmao-ui/editor@0.11.3/src/operations/PasteManager.ts","/npm/@sunmao-ui/editor@0.11.3/src/components/KeyboardEventWrapper.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/DataSource/DataSourceGroup.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/DataSource/DataSourceList.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ComponentForm/EventTraitForm/EventTraitForm.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ComponentForm/GeneralTraitFormList/AddTraitButton.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ComponentForm/style.ts","/npm/@sunmao-ui/editor@0.11.3/src/components/ComponentForm/GeneralTraitFormList/GeneralTraitForm.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ComponentForm/GeneralTraitFormList/GeneralTraitFormList.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ComponentForm/StyleTraitForm/StyleTraitForm.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ComponentForm/FormSection.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ComponentForm/TagForm.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/ComponentForm/ComponentForm.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/GeneralModal.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/PreviewModal/PreviewModal.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/WarningArea/Pagination.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/WarningArea/const.ts","/npm/@sunmao-ui/editor@0.11.3/src/components/WarningArea/Table.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/WarningArea/Logs.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/WarningArea/ErrorLogs.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/WarningArea/WarningArea.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/EditorMaskWrapper/SlotDropArea.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/EditorMaskWrapper/DropSlotMask.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/EditorMaskWrapper/EditorMaskManager.ts","/npm/@sunmao-ui/editor@0.11.3/src/components/EditorMaskWrapper/EditorMask.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/EditorMaskWrapper/EditorMaskWrapper.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/Explorer/ExplorerForm/AppMetaDataForm.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/Explorer/ExplorerForm/ExplorerForm.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/Explorer/ExplorerTree.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/Explorer/Explorer.tsx","/npm/@sunmao-ui/editor@0.11.3/src/components/CodeModeModal.tsx","/npm/@sunmao-ui/editor@0.11.3/src/operations/branch/batch.ts","/npm/@sunmao-ui/editor@0.11.3/src/operations/AppModelManager.ts","/npm/@sunmao-ui/editor@0.11.3/src/services/eventBus.ts","/npm/@sunmao-ui/editor@0.11.3/src/services/EditorStore.ts","/npm/@sunmao-ui/editor@0.11.3/src/utils/addModuleId.ts","/npm/@sunmao-ui/editor@0.11.3/src/services/AppStorage.ts","/npm/@sunmao-ui/editor@0.11.3/src/init.tsx","/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AAA,cAAC,QAAA,eAAA,CAAe,MAAO,GACrB,QAAA,QAAA,cAAC,OAAA,CACC,MACA,OAAQ,EAAG,OACX,WACA,WAAY,EACZ,WACA,MAAM,OAAA,EAAA,EAAM,mBAAN,EAAA,EAAoB,OAAQ,GAClC,YACA,cAAc,OAAA,EAAA,EAAM,mBAAN,EAAA,EAAoB,eAAgB,CAAC,IAEvD,EAUF,WACA,WAEJ,CCnJO,IAAM,qBAAN,MAIL,YAAA,GACE,IACE,MAAM,EAAY,aAAa,QAAQ,qBAAoB,UAC3D,OAAI,EACK,KAAK,MAAM,GAEb,cACT,OAAS,GACP,OAAO,cACT,CACF,CAEA,gBAAA,GACE,IACE,MAAM,EAAgB,aAAa,QAAQ,qBAAoB,cAC/D,OAAI,EACK,KAAK,MAAM,GAEb,EACT,OAAS,GACP,MAAO,EACT,CACF,CAEA,WAAA,CAAY,GACV,aAAa,QAAQ,qBAAoB,SAAU,KAAK,UAAU,GACpE,CAEA,eAAA,CAAgB,GACd,aAAa,QAAQ,qBAAoB,aAAc,KAAK,UAAU,GACxE,GAlCW,oBAAN,qBAAM,oBACJ,SAAW,SADP,oBAEJ,aAAe,U","file":"/npm/@sunmao-ui/editor@0.11.3/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@sunmao-ui/editor@0.11.3/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import React, { useMemo, useState, useCallback, useEffect } from 'react';\nimport { Application } from '@sunmao-ui/core';\nimport { DIALOG_CONTAINER_ID, initSunmaoUI, SunmaoLib } from '@sunmao-ui/runtime';\nimport { Box, Tabs, TabList, Tab, TabPanels, TabPanel, Flex } from '@chakra-ui/react';\nimport { observer } from 'mobx-react-lite';\nimport { StructureTree } from './StructureTree';\nimport { ComponentList } from './ComponentsList';\nimport { EditorHeader } from './EditorHeader';\nimport { KeyboardEventWrapper } from './KeyboardEventWrapper';\nimport { StateViewer } from './CodeEditor';\nimport { DataSourceList } from './DataSource';\nimport { ComponentForm } from './ComponentForm';\nimport ErrorBoundary from './ErrorBoundary';\nimport { PreviewModal } from './PreviewModal';\nimport { WarningArea } from './WarningArea';\nimport { EditorServices } from '../types';\nimport { EditorMaskWrapper } from './EditorMaskWrapper';\nimport { Explorer } from './Explorer';\nimport { Resizable } from 're-resizable';\nimport { CodeModeModal } from './CodeModeModal';\n\ntype ReturnOfInit = ReturnType<typeof initSunmaoUI>;\n\ntype Props = {\n  App: ReturnOfInit['App'];\n  eleMap: ReturnOfInit['eleMap'];\n  registry: ReturnOfInit['registry'];\n  stateStore: ReturnOfInit['stateManager']['store'];\n  services: EditorServices;\n  libs: SunmaoLib[];\n  dependencies: Record<string, any>;\n  onRefresh: () => void;\n};\n\nexport const Editor: React.FC<Props> = observer(\n  ({ App, stateStore, services, libs, dependencies, onRefresh: onRefreshApp }) => {\n    const { editorStore } = services;\n    const {\n      components,\n      selectedComponentId,\n      modules,\n      toolMenuTab,\n      explorerMenuTab,\n      setToolMenuTab,\n      setExplorerMenuTab,\n    } = editorStore;\n\n    const [isDisplayLeftMenu, setIsDisplayLeftMenu] = useState(true);\n    const [isDisplayRightMenu, setIsDisplayRightMenu] = useState(true);\n    const [preview, setPreview] = useState(false);\n    const [codeMode, setCodeMode] = useState(false);\n    const [isDisplayApp, setIsDisplayApp] = useState(true);\n\n    const app = useMemo<Application>(() => {\n      return {\n        version: 'sunmao/v1',\n        kind: 'Application',\n        metadata: {\n          name: 'some App',\n        },\n        spec: {\n          components,\n        },\n      };\n    }, [components]);\n\n    const appComponent = useMemo(() => {\n      return isDisplayApp ? (\n        <ErrorBoundary>\n          <App options={app} />\n        </ErrorBoundary>\n      ) : null;\n    }, [App, app, isDisplayApp]);\n\n    const inspectForm = <ComponentForm services={services} />;\n\n    const onRefresh = useCallback(() => {\n      setIsDisplayApp(false);\n      onRefreshApp();\n    }, [onRefreshApp]);\n    useEffect(() => {\n      // Wait until the app is completely unmounted before remounting it\n      if (isDisplayApp === false) {\n        setIsDisplayApp(true);\n      }\n    }, [isDisplayApp]);\n    const onPreview = useCallback(() => setPreview(true), []);\n    const onRightTabChange = useCallback(\n      activatedTab => {\n        setToolMenuTab(activatedTab);\n      },\n      [setToolMenuTab]\n    );\n\n    const renderMain = () => {\n      const appBox = (\n        <Flex flexDirection=\"column\" width=\"full\" height=\"full\" overflow=\"hidden\">\n          <Box\n            id=\"editor-main\"\n            display=\"flex\"\n            transform=\"auto\"\n            flexDirection=\"column\"\n            width=\"full\"\n            height=\"full\"\n            position=\"relative\"\n            overflow=\"hidden\"\n          >\n            <EditorMaskWrapper services={services}>\n              {appComponent}\n              <Box id={DIALOG_CONTAINER_ID} />\n            </EditorMaskWrapper>\n          </Box>\n          <Box id=\"warning-area\" position=\"relative\" flex=\"0 0 auto\">\n            <WarningArea services={services} />\n          </Box>\n        </Flex>\n      );\n\n      return (\n        <>\n          {isDisplayLeftMenu ? (\n            <Resizable\n              defaultSize={{\n                width: 300,\n                height: '100%',\n              }}\n              enable={{ right: true }}\n              style={{ zIndex: 2 }}\n              maxWidth={480}\n              minWidth={300}\n            >\n              <Box\n                borderRightWidth=\"1px\"\n                borderColor=\"gray.200\"\n                position=\"relative\"\n                zIndex=\"sideMenuIndex\"\n                height=\"full\"\n              >\n                <Tabs\n                  height=\"100%\"\n                  display=\"flex\"\n                  flexDirection=\"column\"\n                  textAlign=\"left\"\n                  lazyBehavior=\"keepMounted\"\n                  isLazy\n                  index={explorerMenuTab}\n                  onChange={activatedTab => {\n                    setExplorerMenuTab(activatedTab);\n                  }}\n                >\n                  <TabList\n                    background=\"gray.50\"\n                    whiteSpace=\"nowrap\"\n                    justifyContent=\"center\"\n                  >\n                    <Tab>Explorer</Tab>\n                    <Tab>UI</Tab>\n                    <Tab>Data</Tab>\n                    <Tab>State</Tab>\n                  </TabList>\n                  <TabPanels overflow=\"hidden\" height=\"full\" flex=\"1\">\n                    <TabPanel height=\"full\" overflow=\"auto\" p={0}>\n                      <Explorer services={services} />\n                    </TabPanel>\n                    <TabPanel height=\"full\" overflow=\"auto\" p={0}>\n                      <StructureTree services={services} />\n                    </TabPanel>\n                    <TabPanel height=\"full\" overflow=\"auto\" p={0}>\n                      <DataSourceList services={services} />\n                    </TabPanel>\n                    <TabPanel overflow=\"auto\" p={0} height=\"100%\">\n                      <StateViewer store={stateStore} services={services} />\n                    </TabPanel>\n                  </TabPanels>\n                </Tabs>\n              </Box>\n            </Resizable>\n          ) : null}\n          <Flex flex={1} position=\"relative\" overflow=\"hidden\">\n            {appBox}\n            {isDisplayRightMenu ? (\n              <Resizable\n                defaultSize={{\n                  width: 360,\n                  height: '100%',\n                }}\n                enable={{ left: true }}\n                maxWidth={480}\n                minWidth={300}\n              >\n                <Box\n                  height=\"full\"\n                  borderLeftWidth=\"1px\"\n                  borderColor=\"gray.400\"\n                  position=\"relative\"\n                  zIndex=\"sideMenuIndex\"\n                >\n                  <Tabs\n                    align=\"center\"\n                    textAlign=\"left\"\n                    height=\"100%\"\n                    display=\"flex\"\n                    flexDirection=\"column\"\n                    lazyBehavior=\"keepMounted\"\n                    isLazy\n                    index={toolMenuTab}\n                    onChange={onRightTabChange}\n                  >\n                    <TabList background=\"gray.50\">\n                      <Tab>Inspect</Tab>\n                      <Tab>Insert</Tab>\n                    </TabList>\n                    <TabPanels flex=\"1\" overflow=\"auto\" background=\"gray.50\">\n                      <TabPanel p={0}>{inspectForm}</TabPanel>\n                      <TabPanel p={0}>\n                        <ComponentList services={services} />\n                      </TabPanel>\n                    </TabPanels>\n                  </Tabs>\n                </Box>\n              </Resizable>\n            ) : null}\n          </Flex>\n        </>\n      );\n    };\n\n    return (\n      <KeyboardEventWrapper\n        components={components}\n        selectedComponentId={selectedComponentId}\n        services={services}\n      >\n        <Box display=\"flex\" height=\"100%\" width=\"100%\" flexDirection=\"column\">\n          <EditorHeader\n            onPreview={onPreview}\n            onRefresh={onRefresh}\n            isDisplayLeftMenu={isDisplayLeftMenu}\n            isDisplayRightMenu={isDisplayRightMenu}\n            setIsDisplayLeftMenu={setIsDisplayLeftMenu}\n            setIsDisplayRightMenu={setIsDisplayRightMenu}\n            onCodeMode={() => setCodeMode(true)}\n            services={services}\n          />\n          <Box display=\"flex\" flex=\"1\" overflow=\"auto\">\n            {renderMain()}\n          </Box>\n        </Box>\n        {preview && (\n          <PreviewModal\n            onClose={() => setPreview(false)}\n            app={app}\n            modules={modules}\n            libs={libs}\n            dependencies={dependencies}\n          />\n        )}\n        {codeMode && (\n          <CodeModeModal\n            onClose={() => setCodeMode(false)}\n            app={app}\n            services={services}\n          />\n        )}\n      </KeyboardEventWrapper>\n    );\n  }\n);\n","import React, { useRef, useEffect } from 'react';\nimport { Box, Text, VStack } from '@chakra-ui/react';\nimport scrollIntoView from 'scroll-into-view';\nimport { observer } from 'mobx-react-lite';\nimport { ComponentNode } from './ComponentNode';\nimport { DropComponentWrapper } from './DropComponentWrapper';\nimport ErrorBoundary from '../ErrorBoundary';\nimport { useStructureTreeState } from './useStructureTreeState';\nimport { ComponentSearch } from './ComponentSearch';\nimport { EditorServices } from '../../types';\n\ntype Props = {\n  services: EditorServices;\n};\n\nexport const StructureTree: React.FC<Props> = observer(props => {\n  const { editorStore } = props.services;\n  const { setSelectedComponentId, selectedComponentId, components } = editorStore;\n  const scrollWrapper = useRef<HTMLDivElement>(null);\n\n  const {\n    shouldRenderNodes,\n    expandedMap,\n    onToggleExpand,\n    expandNode,\n    undroppableMap,\n    setDraggingId,\n  } = useStructureTreeState(editorStore);\n\n  // auto expand and scroll node into view when the node is selected\n  useEffect(() => {\n    expandNode(selectedComponentId);\n\n    setTimeout(() => {\n      const selectedElement: HTMLElement | undefined | null =\n        scrollWrapper.current?.querySelector(`#tree-item-${selectedComponentId}`);\n\n      const wrapperRect = scrollWrapper.current?.getBoundingClientRect();\n      const eleRect = selectedElement?.getBoundingClientRect();\n      // check whether selected node is outside of view\n      if (\n        selectedElement &&\n        eleRect &&\n        wrapperRect &&\n        (eleRect.top < wrapperRect.top ||\n          eleRect.top > wrapperRect.top + wrapperRect?.height)\n      ) {\n        scrollIntoView(selectedElement, { align: { lockX: true } });\n      }\n    });\n  }, [expandNode, selectedComponentId]);\n\n  const componentEles = shouldRenderNodes.map((node, i) => {\n    const prevNode = i > 0 ? shouldRenderNodes[i - 1] : null;\n    let shouldShowSlot = false;\n    // Conditions in which a component should show the slot name it belongs\n    // 1. It is in a slot and the slot is not 'content' or the slot is 'content' but its parent slot is not unique.\n    // 2. And its previous node is its parent(has the same parent).\n    // 3. Or its previous node is its sibling and is in different slot.\n    if (\n      node.slot &&\n      !(node.parentSlots!.length === 1 && node.slot === 'content') &&\n      prevNode\n    ) {\n      const prevNodeIsParent = prevNode.id === node.parentId;\n      const prevNodeInDifferentSlot =\n        prevNode.parentId === node.parentId && prevNode.slot !== node.slot;\n      shouldShowSlot = prevNodeIsParent || prevNodeInDifferentSlot;\n    }\n    return (\n      <ComponentNode\n        id={node.id}\n        key={node.id}\n        component={node.component}\n        parentId={node.parentId}\n        slot={node.slot}\n        onSelectComponent={setSelectedComponentId}\n        services={props.services}\n        droppable={!undroppableMap[node.id]}\n        depth={node.depth}\n        isSelected={editorStore.selectedComponent?.id === node.id}\n        isExpanded={!!expandedMap[node.id]}\n        onToggleExpand={onToggleExpand}\n        shouldShowSelfSlotName={shouldShowSlot}\n        notEmptySlots={node.notEmptySlots}\n        onDragStart={id => setDraggingId(id)}\n        onDragEnd={() => setDraggingId('')}\n      />\n    );\n  });\n\n  return (\n    <VStack\n      height=\"full\"\n      paddingY=\"4\"\n      alignItems=\"start\"\n      overflowX=\"hidden\"\n      overflowY=\"auto\"\n    >\n      <VStack alignItems=\"start\" width=\"full\" paddingX=\"4\">\n        <Text fontSize=\"lg\" fontWeight=\"bold\">\n          Components\n        </Text>\n        <ComponentSearch\n          tags={[]}\n          checkedTags={[]}\n          onTagsChange={() => null}\n          components={components}\n          onChange={id => setSelectedComponentId(id)}\n          services={props.services}\n        />\n      </VStack>\n      <Box\n        ref={scrollWrapper}\n        width=\"full\"\n        flex={1}\n        minHeight={0}\n        overflowY=\"auto\"\n        overflowX=\"hidden\"\n      >\n        {componentEles.length > 0 ? (\n          componentEles\n        ) : (\n          <Box padding=\"4\">\n            <Placeholder services={props.services} />\n          </Box>\n        )}\n      </Box>\n    </VStack>\n  );\n});\n\nfunction Placeholder(props: { services: EditorServices }) {\n  return (\n    <ErrorBoundary>\n      <Box width=\"full\">\n        <DropComponentWrapper\n          componentId={undefined}\n          parentId={undefined}\n          parentSlot={undefined}\n          services={props.services}\n          isDropInOnly\n          isExpanded={false}\n          droppable\n          hasSlot={true}\n        >\n          <Text padding=\"2\" border=\"2px dashed\" color=\"gray.400\" borderColor=\"gray.400\">\n            There is no components now. You can drag component into here to create it.\n          </Text>\n        </DropComponentWrapper>\n      </Box>\n    </ErrorBoundary>\n  );\n}\n","import React, { useCallback, useState } from 'react';\nimport { CopyIcon, DeleteIcon, HamburgerIcon, ViewIcon } from '@chakra-ui/icons';\nimport {\n  Text,\n  VStack,\n  Menu,\n  MenuButton,\n  MenuItem,\n  MenuList,\n  IconButton,\n  useToast,\n} from '@chakra-ui/react';\nimport { isEqual, xor } from 'lodash';\nimport { ComponentItemView } from './ComponentItemView';\nimport { DropComponentWrapper } from './DropComponentWrapper';\nimport { genOperation } from '../../operations';\nimport { EditorServices } from '../../types';\nimport { ComponentNodeWithState } from './type';\nimport { AppModel } from '../../AppModel/AppModel';\nimport { ComponentId } from '../../AppModel/IAppModel';\nimport { RootId } from '../../constants';\nimport { RelationshipModal } from '../RelationshipModal';\nimport { ExplorerMenuTabs } from '../../constants/enum';\nimport { ExtractModuleModal } from '../ExtractModuleModal';\nimport { copyToClipboard } from '../../utils/copy';\nimport { getRelations } from '../RelationshipModal/RelationshipView';\nimport useModal from '../../hooks/useModal';\n\nconst IndextWidth = 24;\n\ntype Props = ComponentNodeWithState & {\n  services: EditorServices;\n  onSelectComponent: (id: string) => void;\n  onToggleExpand: (id: string) => void;\n  onDragStart: (id: string) => void;\n  onDragEnd: (id: string) => void;\n  prefix?: React.ReactNode;\n};\n\nconst ComponentNodeImpl = (props: Props) => {\n  const {\n    component,\n    onSelectComponent,\n    services,\n    droppable,\n    depth,\n    isSelected,\n    isExpanded,\n    onToggleExpand,\n    parentId,\n    slot,\n    shouldShowSelfSlotName,\n    notEmptySlots,\n    onDragStart,\n    onDragEnd,\n    prefix,\n  } = props;\n  const toast = useToast();\n  const { registry, eventBus, appModelManager, editorStore, stateManager } = services;\n  const { appModel } = appModelManager;\n  const [isShowRelationshipModal, setIsShowRelationshipModal] = useState(false);\n  const [isShowExtractModuleModal, setIsShowExtractModuleModal] = useState(false);\n  const { modal: messageModal, open: openMessageModal } = useModal();\n  const slots = Object.keys(registry.getComponentByType(component.type).spec.slots);\n  const paddingLeft = depth * IndextWidth;\n\n  const onClickRemove = useCallback(\n    (e: React.MouseEvent) => {\n      e.stopPropagation();\n      const { expressionRelations, methodRelations } = getRelations(\n        component.id as ComponentId,\n        appModel\n      );\n\n      if (expressionRelations.length || methodRelations.length) {\n        openMessageModal({\n          title: 'Remove component failed',\n          message: 'Its state or methods are used by another component.',\n        });\n      } else {\n        eventBus.send(\n          'operation',\n          genOperation(registry, 'removeComponent', {\n            componentId: component.id,\n          })\n        );\n      }\n    },\n    [component.id, eventBus, registry, appModel, openMessageModal]\n  );\n  const onClickDuplicate = useCallback(\n    (e: React.MouseEvent) => {\n      e.stopPropagation();\n      const copiedComponents = appModelManager.appModel.getComponentById(\n        component.id as ComponentId\n      );\n      const clonedComponent = new AppModel(\n        copiedComponents!.allComponents.map(c => c.toSchema()),\n        registry\n      ).getComponentById(component.id as ComponentId);\n      eventBus.send(\n        'operation',\n        genOperation(registry, 'pasteComponent', {\n          parentId: parentId || RootId,\n          slot: slot || '',\n          component: clonedComponent!,\n        })\n      );\n    },\n    [appModelManager.appModel, component.id, eventBus, parentId, registry, slot]\n  );\n\n  const onClickShowRelationshipModal = useCallback((e: React.MouseEvent) => {\n    e.stopPropagation();\n    setIsShowRelationshipModal(true);\n  }, []);\n  const onClickShowState = useCallback(\n    (e: React.MouseEvent) => {\n      e.stopPropagation();\n      editorStore.setExplorerMenuTab(ExplorerMenuTabs.STATE);\n      editorStore.setViewStateComponentId(component.id);\n    },\n    [component.id, editorStore]\n  );\n  const onClickCopyState = useCallback(\n    (e: React.MouseEvent) => {\n      e.stopPropagation();\n\n      const componentState = stateManager.store[component.id];\n\n      if (componentState) {\n        const success = copyToClipboard(JSON.stringify(componentState, null, 2));\n\n        if (success) {\n          toast({\n            title: 'Copy state to clipboard successfully.',\n            status: 'success',\n            position: 'top',\n            duration: 1500,\n          });\n        } else {\n          toast({\n            title: 'Copy state to clipboard failed.',\n            status: 'warning',\n            position: 'top',\n            duration: 1500,\n          });\n        }\n      }\n    },\n    [component.id, stateManager, toast]\n  );\n  const onClickExtractToModule = useCallback((e: React.MouseEvent) => {\n    e.stopPropagation();\n    setIsShowExtractModuleModal(true);\n  }, []);\n\n  const onClickItem = useCallback(() => {\n    onSelectComponent(component.id);\n  }, [component.id, onSelectComponent]);\n  const onClickExpand = useCallback(() => {\n    onToggleExpand(component.id);\n  }, [component.id, onToggleExpand]);\n  const _onDragStart = useCallback(\n    () => onDragStart(component.id),\n    [component.id, onDragStart]\n  );\n  const _onDragEnd = useCallback(\n    () => onDragEnd(component.id),\n    [component.id, onDragEnd]\n  );\n  const onMouseOver = useCallback(() => {\n    editorStore.setHoverComponentId(component.id);\n  }, [component.id, editorStore]);\n  const onMouseLeave = useCallback(() => {\n    editorStore.setHoverComponentId('');\n  }, [editorStore]);\n  const emptySlots = xor(notEmptySlots, slots);\n\n  const emptyChildrenSlotsPlaceholder = isExpanded\n    ? emptySlots.map(_slot => {\n        return (\n          <DropComponentWrapper\n            key={_slot}\n            parentId={component.id}\n            parentSlot={_slot!}\n            services={services}\n            isExpanded={isExpanded}\n            isDropInOnly\n            droppable={droppable}\n            hasSlot={true}\n          >\n            {_slot === 'content' && slots.length === 1 ? null : (\n              <Text\n                fontSize={12}\n                color=\"gray.500\"\n                paddingY={1}\n                paddingLeft={`${paddingLeft + IndextWidth}px`}\n              >\n                {_slot}\n              </Text>\n            )}\n            <Text\n              height=\"32px\"\n              lineHeight=\"32px\"\n              fontSize={14}\n              color=\"gray.500\"\n              paddingLeft={`${paddingLeft + IndextWidth * 2}px`}\n            >\n              Empty\n            </Text>\n          </DropComponentWrapper>\n        );\n      })\n    : undefined;\n\n  const actionMenu = (\n    <Menu isLazy gutter={4}>\n      <MenuButton\n        as={IconButton}\n        variant=\"ghost\"\n        height=\"24px\"\n        width=\"24px\"\n        minWidth=\"24px\"\n        marginInlineEnd=\"8px !important\"\n        icon={<HamburgerIcon width=\"16px\" height=\"16px\" />}\n        onClick={e => e.stopPropagation()}\n      />\n      <MenuList>\n        <MenuItem icon={<CopyIcon />} onClick={onClickDuplicate}>\n          Duplicate\n        </MenuItem>\n        <MenuItem icon={<ViewIcon />} onClick={onClickShowRelationshipModal}>\n          Show Relationship\n        </MenuItem>\n        <MenuItem icon={<ViewIcon />} onClick={onClickShowState}>\n          Show State\n        </MenuItem>\n        <MenuItem icon={<CopyIcon />} onClick={onClickCopyState}>\n          Copy State\n        </MenuItem>\n        <MenuItem icon={<ViewIcon />} onClick={onClickExtractToModule}>\n          Extract to Module\n        </MenuItem>\n        <MenuItem icon={<DeleteIcon />} color=\"red.500\" onClick={onClickRemove}>\n          Remove\n        </MenuItem>\n      </MenuList>\n    </Menu>\n  );\n\n  const relationshipViewModal = isShowRelationshipModal ? (\n    <RelationshipModal\n      componentId={component.id}\n      services={services}\n      onClose={() => setIsShowRelationshipModal(false)}\n    />\n  ) : null;\n\n  const extractModuleModal = isShowExtractModuleModal ? (\n    <ExtractModuleModal\n      componentId={component.id}\n      services={services}\n      onClose={() => setIsShowExtractModuleModal(false)}\n    />\n  ) : null;\n\n  return (\n    <VStack\n      key={component.id}\n      position=\"relative\"\n      spacing=\"0\"\n      width=\"full\"\n      alignItems=\"start\"\n      marginTop=\"0 !important\"\n    >\n      {shouldShowSelfSlotName ? (\n        <DropComponentWrapper\n          parentId={parentId!}\n          parentSlot={slot!}\n          services={services}\n          isExpanded={isExpanded}\n          isDropInOnly\n          droppable={droppable}\n          hasSlot={true}\n        >\n          <Text\n            fontSize={12}\n            color=\"gray.500\"\n            paddingY={1}\n            paddingLeft={`${paddingLeft}px`}\n          >\n            {slot}\n          </Text>\n        </DropComponentWrapper>\n      ) : undefined}\n      <DropComponentWrapper\n        componentId={component.id}\n        parentSlot={slot!}\n        parentId={parentId!}\n        services={props.services}\n        isExpanded={isExpanded}\n        droppable={droppable}\n        hasSlot={slots.length > 0}\n      >\n        <ComponentItemView\n          id={component.id}\n          title={component.id}\n          isSelected={isSelected}\n          onClick={onClickItem}\n          noChevron={slots.length === 0}\n          isExpanded={isExpanded}\n          onClickExpand={onClickExpand}\n          onDragStart={_onDragStart}\n          onDragEnd={_onDragEnd}\n          onMouseOver={onMouseOver}\n          onMouseLeave={onMouseLeave}\n          paddingLeft={paddingLeft}\n          actionMenu={actionMenu}\n          prefix={prefix}\n        />\n      </DropComponentWrapper>\n      {emptyChildrenSlotsPlaceholder}\n      {relationshipViewModal}\n      {extractModuleModal}\n      {messageModal}\n    </VStack>\n  );\n};\n\nconst MemoComponentNode: React.FC<Props> = React.memo(\n  ComponentNodeImpl,\n  (prevProps, nextProps) => {\n    const isSame =\n      prevProps.component === nextProps.component &&\n      prevProps.parentId === nextProps.parentId &&\n      prevProps.slot === nextProps.slot &&\n      prevProps.droppable === nextProps.droppable &&\n      prevProps.depth === nextProps.depth &&\n      prevProps.isSelected === nextProps.isSelected &&\n      prevProps.isExpanded === nextProps.isExpanded &&\n      prevProps.shouldShowSelfSlotName === nextProps.shouldShowSelfSlotName &&\n      isEqual(prevProps.notEmptySlots, nextProps.notEmptySlots);\n    return isSame;\n  }\n);\n\nexport const ComponentNode = MemoComponentNode;\n","import { TriangleDownIcon } from '@chakra-ui/icons';\nimport { Box, HStack, IconButton, Spacer, Text } from '@chakra-ui/react';\nimport React, { useMemo, useState } from 'react';\n\ntype Props = {\n  id: string;\n  title: string;\n  isSelected: boolean;\n  onClick: () => void;\n  noChevron: boolean;\n  isExpanded?: boolean;\n  onClickExpand: () => void;\n  onDragStart: () => void;\n  onDragEnd: () => void;\n  onMouseOver: () => void;\n  onMouseLeave: () => void;\n  paddingLeft: number;\n  actionMenu?: React.ReactNode;\n  prefix?: React.ReactNode;\n};\n\nconst ChevronWidth = 24;\n\nexport const ComponentItemView: React.FC<Props> = props => {\n  const {\n    id,\n    title,\n    isSelected,\n    noChevron,\n    isExpanded,\n    onClick,\n    onClickExpand,\n    onDragStart,\n    onDragEnd,\n    onMouseOver,\n    onMouseLeave,\n    paddingLeft,\n    actionMenu,\n    prefix,\n  } = props;\n  const [isHover, setIsHover] = useState(false);\n\n  const expandIcon = useMemo(\n    () => (\n      <IconButton\n        aria-label=\"showChildren\"\n        size=\"xs\"\n        variant=\"unstyled\"\n        onClick={e => {\n          e.stopPropagation();\n          onClickExpand();\n        }}\n        _focus={{\n          outline: '0',\n        }}\n        icon={\n          isExpanded ? (\n            <TriangleDownIcon />\n          ) : (\n            <TriangleDownIcon transform=\"rotate(-90deg)\" />\n          )\n        }\n      />\n    ),\n    [isExpanded, onClickExpand]\n  );\n\n  const _onDragStart = (e: React.DragEvent) => {\n    e.dataTransfer.setData('moveComponent', id);\n    onDragStart && onDragStart();\n  };\n\n  const _onDragEnd = () => {\n    onDragEnd && onDragEnd();\n  };\n\n  const _onMouseOver = () => {\n    setIsHover(true);\n    onMouseOver();\n  };\n\n  const _onMouseLeave = () => {\n    setIsHover(false);\n    onMouseLeave();\n  };\n\n  const backgroundColor = useMemo(() => {\n    if (isSelected) {\n      return 'blue.100';\n    }\n    if (isHover) {\n      return 'blue.50';\n    }\n    return undefined;\n  }, [isHover, isSelected]);\n\n  return (\n    <Box\n      id={`tree-item-${id}`}\n      width=\"full\"\n      height=\"32px\"\n      lineHeight=\"24px\"\n      paddingY=\"4px\"\n      onMouseOver={_onMouseOver}\n      onMouseLeave={_onMouseLeave}\n      onDragStart={_onDragStart}\n      onDragEnd={_onDragEnd}\n      draggable\n      cursor=\"pointer\"\n      position=\"relative\"\n      onClick={onClick}\n      backgroundColor={backgroundColor}\n    >\n      <HStack\n        width=\"full\"\n        justify=\"space-between\"\n        spacing=\"0\"\n        margin=\"auto\"\n        paddingLeft={`${paddingLeft + (noChevron ? ChevronWidth : 0)}px`}\n      >\n        {noChevron ? null : expandIcon}\n        {prefix}\n        <Text\n          cursor=\"pointer\"\n          overflow=\"hidden\"\n          whiteSpace=\"nowrap\"\n          textOverflow=\"ellipsis\"\n          fontSize=\"sm\"\n          title={title}\n        >\n          {title}\n        </Text>\n        <Spacer />\n        {isHover ? actionMenu : undefined}\n      </HStack>\n    </Box>\n  );\n};\n","import { RegistryInterface } from '@sunmao-ui/runtime';\nimport { AppModel } from \"../AppModel/AppModel\";\n\nexport const leafSymbol = Symbol('leaf');\nexport const branchSymbol = Symbol('branch');\n\n/**\n * an operation list, it is based on a doubly linked list with a cursor point to current operation executed\n */\nexport class OperationList<TOperation extends IOperation = IOperation> {\n  /**\n   * head node is only a dummy node, it represent the initial state of the app\n   */\n  private readonly head = new ListNode<null, never, TOperation | null>(null);\n  /**\n   * cursor mean the last executed operation\n   */\n  private _cursor: ListNode<TOperation | null>;\n  /**\n   * a public getter for cursor's value\n   */\n  public get cursor(): ListNode<TOperation | null> {\n    return this._cursor;\n  }\n\n  constructor() {\n    this._cursor = this.head;\n  }\n\n  /**\n   * insert a new node after cursor, unlink node after cursor and move cursor to the new node\n   * @param value inserted operation\n   * @returns {TOperation} the inserted node's value\n   */\n  insert(value: TOperation) {\n    if (this._cursor.next) {\n      // unlink cursor's next from list\n      this._cursor.next.prev = null;\n    }\n    // connect new node to cursor and move cursor to the created node\n    this._cursor = this._cursor.next = new ListNode(value, this._cursor);\n    return this.cursor;\n  }\n\n  /**\n   * move cursor to its next sibling\n   * @returns {TOperation} current cursor's value\n   */\n  moveNext() {\n    if (this._cursor.next) {\n      this._cursor = this._cursor.next;\n    } else {\n      throw new Error('cursor has already been moved to tail.');\n    }\n    return this.cursor;\n  }\n\n  /**\n   * move cursor to its previous sibling\n   * @returns {IOperation} current cursor's value\n   */\n  movePrev() {\n    if (this._cursor.prev) {\n      this._cursor = this._cursor.prev;\n    } else {\n      throw new Error('cursor has already been moved to head.');\n    }\n    return this.cursor;\n  }\n\n  /**\n   * iterate and reduce each node by reduce function\n   * @param cb reduce function\n   * @param initialData intial data for reduceLeft\n   * @returns reduced value\n   */\n  reduce<TData>(cb: (prev: TData, node: TOperation) => TData, initialData: TData): TData {\n    // ignore dummy head;\n    let node = this.head.next;\n    while (node && node.val) {\n      initialData = cb(initialData, node.val);\n      node = node.next;\n    }\n    return initialData;\n  }\n\n  /**\n   * reverse iterate and reduce each node by reduce function\n   * @param cb reduce function\n   * @param initialData intial data for reduceRight\n   * @returns reduced value\n   */\n  reduceRight<TData>(\n    cb: (prev: TData, node: TOperation) => TData,\n    initialData: TData\n  ): TData {\n    let node: ListNode<TOperation | null, TOperation | null, TOperation | null> | null =\n      this.cursor;\n    while (node && node.val) {\n      initialData = cb(initialData, node.val);\n      node = node.prev;\n    }\n    return initialData;\n  }\n}\n\n/**\n * list node of doubly linked list\n */\nexport class ListNode<T, TPrev = T, TNext = T> {\n  constructor(\n    public val: T,\n    public prev: ListNode<TPrev> | null = null,\n    public next: ListNode<TNext> | null = null\n  ) {}\n}\n\nexport interface IUndoRedo {\n  do(...args: any[]): any;\n  redo(...args: any[]): any;\n  undo(...args: any[]): any;\n}\n\nexport interface IUndoRedoManager extends IUndoRedo {\n  operationStack: OperationList;\n}\n\nexport interface IOperation<TContext = any> extends IUndoRedo {\n  /**\n   * the context of operation, provide any information an operation needed\n   */\n  context: TContext;\n  /**\n   * infer the type of operation, leaf or branch\n   */\n  type: symbol;\n  do(prev: AppModel): AppModel;\n  redo(prev: AppModel): AppModel;\n  undo(prev: AppModel): AppModel;\n}\n\n/**\n * leaf operation is the operation that actually change the schema\n */\nexport abstract class BaseLeafOperation<TContext> implements IOperation<TContext> {\n  context: TContext;\n  registry: RegistryInterface;\n  type = leafSymbol;\n\n  constructor(registry: RegistryInterface, context: TContext) {\n    this.registry = registry;\n    this.context = context;\n  }\n\n  /**\n   * do a leaf operation, implement it in subclass\n   * @param prev prev application schema\n   * @returns changed application schema\n   */\n  abstract do(prev: AppModel): AppModel;\n  /**\n   * for leaf operation, most time redo is the same as do, override it if not\n   * @param prev prev application schema\n   * @returns changed application schema\n   */\n  redo(prev: AppModel): AppModel {\n    return this.do(prev);\n  }\n\n  /**\n   * undo a leaf operation, implement it in subclass\n   * @param prev prev application schema\n   * @returns changed application schema\n   */\n  abstract undo(prev: AppModel): AppModel;\n\n  static isLeafOperation<T>(op: IOperation<T>): op is BaseLeafOperation<T> {\n    return op.type === leafSymbol;\n  }\n}\n/**\n * branch operation is the operation that contains other child operation.\n */\nexport abstract class BaseBranchOperation<TContext>\n  implements IOperation<TContext>, IUndoRedoManager\n{\n  operationStack: OperationList;\n  context: TContext;\n  registry: RegistryInterface;\n  type = branchSymbol;\n\n  constructor(registry: RegistryInterface, context: TContext) {\n    this.context = context;\n    this.registry = registry;\n    this.operationStack = new OperationList();\n  }\n\n  /**\n   * for branch operation, do will do all the child operation for the head to tail\n   * it don't concern about cursor because a branch operation should do all redo all its children\n   * @param prev prev application schema\n   * @returns changed application schema\n   */\n  abstract do(prev: AppModel): AppModel;\n\n  /**\n   * for branch operation, redo is the same as do\n   * @param prev prev application schema\n   * @returns changed application schema\n   */\n  redo(prev: AppModel): AppModel {\n    return this.operationStack.reduce((prev, node) => {\n      prev = node.redo(prev);\n      return prev;\n    }, prev);\n  }\n\n  /**\n   * for branch operation, undo will undo all the child operation for the tail to head\n   * it don't concern about cursor because a branch operation should undo all its children, the cursor should always be its tail\n   * @param prev prev application schema\n   * @returns changed application schema\n   */\n  undo(prev: AppModel): AppModel {\n    return this.operationStack.reduceRight((prev, node) => {\n      prev = node.undo(prev);\n      return prev;\n    }, prev);\n  }\n\n  static isBranchOperation<T>(op: IOperation<T>): op is BaseBranchOperation<T> {\n    return op.type === branchSymbol;\n  }\n}\n","\nimport { AppModel } from '../../../AppModel/AppModel';\nimport { ComponentId, IComponentModel, SlotName } from '../../../AppModel/IAppModel';\nimport { BaseLeafOperation } from '../../type';\n\nexport type RemoveComponentLeafOperationContext = {\n  componentId: string;\n};\n\nexport class RemoveComponentLeafOperation extends BaseLeafOperation<RemoveComponentLeafOperationContext> {\n  private deletedComponent?: IComponentModel;\n  private prevComponent?: IComponentModel;\n\n  do(prev: AppModel): AppModel {\n    this.deletedComponent = prev.getComponentById(\n      this.context.componentId as ComponentId\n    );\n    this.prevComponent = this.deletedComponent?.prevSibling || undefined;\n    prev.removeComponent(this.context.componentId as ComponentId);\n    return prev;\n  }\n\n  redo(prev: AppModel): AppModel {\n    return this.do(prev);\n  }\n\n  undo(prev: AppModel): AppModel {\n    if (!this.deletedComponent) {\n      return prev;\n    }\n    const parent = prev.getComponentById(\n      this.deletedComponent.parentId as ComponentId\n    );\n    if (parent) {\n      parent.appendChild(\n        this.deletedComponent,\n        this.deletedComponent.parentSlot as SlotName\n      );\n    } else {\n      prev.appendChild(this.deletedComponent);\n    }\n    this.deletedComponent.moveAfter(this.prevComponent || null);\n    return prev;\n  }\n}\n","import { AppModel } from '../../../AppModel/AppModel';\nimport { ComponentId } from '../../../AppModel/IAppModel';\nimport { BaseLeafOperation } from '../../type';\nexport type AdjustComponentOrderLeafOperationContext = {\n  componentId: ComponentId;\n  targetId?: ComponentId;\n  direction: 'prev' | 'next';\n};\n\nexport class AdjustComponentOrderLeafOperation extends BaseLeafOperation<AdjustComponentOrderLeafOperationContext> {\n  private prevComponentId?: ComponentId;\n  do(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    this.prevComponentId = component?.prevSibling?.id;\n    return this.move(prev, this.context.targetId, this.context.direction);\n  }\n\n  redo(prev: AppModel): AppModel {\n    return this.do(prev);\n  }\n\n  undo(prev: AppModel): AppModel {\n    return this.move(prev, this.prevComponentId!, 'next');\n  }\n\n  private move(\n    prev: AppModel,\n    targetId: ComponentId | undefined,\n    direction: 'prev' | 'next'\n  ): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (!component) {\n      console.warn('component not found');\n      return prev;\n    }\n    const targetComponent = prev.getComponentById(targetId as ComponentId);\n\n    switch (direction) {\n      case 'prev':\n        component.moveAfter(targetComponent?.prevSibling || null);\n        break;\n      case 'next':\n        component.moveAfter(targetComponent || null);\n        break;\n    }\n    return prev;\n  }\n}\n","import { AppModel } from '../../../AppModel/AppModel';\nimport {\n  ComponentId,\n  ComponentType,\n  IComponentModel,\n  SlotName,\n} from '../../../AppModel/IAppModel';\nimport { BaseLeafOperation } from '../../type';\n\nexport type CreateComponentLeafOperationContext = {\n  componentType: string;\n  componentId: string;\n  parentId?: ComponentId;\n  slot?: SlotName;\n};\n\nexport class CreateComponentLeafOperation extends BaseLeafOperation<CreateComponentLeafOperationContext> {\n  private component!: IComponentModel;\n\n  do(prev: AppModel): AppModel {\n    const component = prev.createComponent(\n      this.context.componentType as ComponentType,\n      this.context.componentId as ComponentId\n    );\n    if (this.context.parentId) {\n      const parent = prev.getComponentById(this.context.parentId);\n      if (parent) {\n        component.appendTo(parent, this.context.slot);\n      }\n    } else {\n      component.appendTo();\n    }\n    this.component = component;\n    return prev;\n  }\n\n  redo(prev: AppModel): AppModel {\n    return this.do(prev);\n  }\n\n  undo(prev: AppModel): AppModel {\n    prev.removeComponent(this.component.id);\n    return prev;\n  }\n}\n","import { AppModel } from '../../../AppModel/AppModel';\nimport { ComponentId } from '../../../AppModel/IAppModel';\nimport { BaseLeafOperation } from '../../type';\n\nexport type ModifyComponentIdLeafOperationContext = {\n  componentId: string;\n  newId: string;\n};\n\nexport class ModifyComponentIdLeafOperation extends BaseLeafOperation<ModifyComponentIdLeafOperationContext> {\n  do(prev: AppModel): AppModel {\n    const oldId = this.context.componentId as ComponentId;\n    const newId = this.context.newId as ComponentId;\n    const component = prev.getComponentById(oldId);\n    if (!component) {\n      console.warn('component not found');\n      return prev;\n    }\n    component.changeId(newId);\n    return prev;\n  }\n\n  redo(prev: AppModel): AppModel {\n    return this.do(prev);\n  }\n\n  undo(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.newId as ComponentId)!;\n    component.changeId(this.context.componentId as ComponentId);\n    return prev;\n  }\n}\n","import { BaseLeafOperation } from '../../type';\nimport { isFunction, cloneDeep } from 'lodash';\nimport { AppModel } from '../../../AppModel/AppModel';\nimport { ComponentId } from '../../../AppModel/IAppModel';\nexport type ModifyComponentPropertiesLeafOperationContext = {\n  componentId: string;\n  properties: Record<string, any | (<T = any>(prev: T) => T)>;\n};\n\nexport class ModifyComponentPropertiesLeafOperation extends BaseLeafOperation<ModifyComponentPropertiesLeafOperationContext> {\n  private previousState: Record<string, any> = {};\n  do(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (component) {\n      for (const property in this.context.properties) {\n        const oldValue = component.rawProperties[property];\n        // assign previous data\n        this.previousState[property] = oldValue;\n        let newValue = this.context.properties[property];\n        if (isFunction(newValue)) {\n          // if modified value is a lazy function, execute it and assign\n          newValue = newValue(cloneDeep(oldValue));\n        }\n        component.updateComponentProperty(property, newValue);\n        this.context.properties[property] = newValue;\n      }\n    } else {\n      console.warn('component not found');\n      return prev;\n    }\n\n    return prev;\n  }\n\n  redo(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (!component) {\n      console.warn('component not found');\n      return prev;\n    }\n\n    for (const property in this.context.properties) {\n      component.updateComponentProperty(property, this.context.properties[property]);\n    }\n    return prev;\n  }\n\n  undo(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (!component) {\n      console.warn('component not found');\n      return prev;\n    }\n\n    for (const property in this.previousState) {\n      component.updateComponentProperty(property, this.previousState[property]);\n    }\n\n    return prev;\n  }\n}\n","import { Application } from '@sunmao-ui/core';\nimport { ImplementedRuntimeModule } from '@sunmao-ui/runtime';\nimport { CORE_VERSION, CoreTraitName } from '@sunmao-ui/shared';\n\nexport const unremovableTraits = [\n  `${CORE_VERSION}/${CoreTraitName.Slot}`,\n  `core/v2/${CoreTraitName.Slot}`,\n];\n\nexport const hideCreateTraitsList = [\n  `${CORE_VERSION}/${CoreTraitName.Event}`,\n  `${CORE_VERSION}/${CoreTraitName.Style}`,\n  `${CORE_VERSION}/${CoreTraitName.Slot}`,\n  `core/v2/${CoreTraitName.Slot}`,\n];\n\nexport const hasSpecialFormTraitList = [\n  `${CORE_VERSION}/${CoreTraitName.Event}`,\n  `${CORE_VERSION}/${CoreTraitName.Style}`,\n];\n\nexport const RootId = '__root__';\n\nexport const EmptyAppSchema: Application = {\n  kind: 'Application',\n  version: 'example/v1',\n  metadata: { name: 'sunmao application', description: 'sunmao empty application' },\n  spec: {\n    components: [],\n  },\n};\n\n// need not add moduleId, because it is used in runtime of editor\nexport const DefaultNewModule: ImplementedRuntimeModule = {\n  kind: 'Module',\n  parsedVersion: { category: 'custom/v1', value: 'myModule' },\n  version: 'custom/v1',\n  metadata: { name: 'myModule', description: 'my module', exampleProperties: {} },\n  spec: {\n    stateMap: {},\n    events: [],\n    properties: { type: 'object', properties: {} },\n    methods: [],\n  },\n  impl: [\n    {\n      id: 'text1',\n      type: 'core/v1/text',\n      properties: { value: { raw: 'Hello, world!', format: 'plain' } },\n      traits: [],\n    },\n  ],\n};\n","import { AppModel } from '../../../AppModel/AppModel';\nimport { ComponentId, IComponentModel, SlotName } from '../../../AppModel/IAppModel';\nimport { BaseLeafOperation } from '../../type';\nimport { RootId } from '../../../constants';\n\nexport type PasteComponentLeafOperationContext = {\n  parentId: string;\n  slot: string;\n  component: IComponentModel;\n};\n\nexport class PasteComponentLeafOperation extends BaseLeafOperation<PasteComponentLeafOperationContext> {\n  private componentCopy!: IComponentModel;\n\n  do(prev: AppModel): AppModel {\n    let copyTimes = 0;\n    const ids = prev.allComponents.map(c => c.id);\n    this.context.component.allComponents.forEach(c => {\n      let copyId = `${c.id}_copy${copyTimes}`;\n      while (ids.includes(copyId as ComponentId)) {\n        copyTimes++;\n        copyId = `${c.id}_copy${copyTimes}`;\n      }\n      c.changeId(copyId as ComponentId);\n    });\n\n    this.componentCopy = this.context.component;\n\n    return this.pasteComponent(prev);\n  }\n\n  redo(prev: AppModel): AppModel {\n    return this.pasteComponent(prev);\n  }\n\n  undo(prev: AppModel): AppModel {\n    prev.removeComponent(this.componentCopy.id);\n    return prev;\n  }\n\n  private pasteComponent(prev: AppModel): AppModel {\n    if (this.context.parentId === RootId) {\n      prev.appendChild(this.componentCopy);\n    } else {\n      const targetParent = prev.getComponentById(this.context.parentId as ComponentId);\n      if (targetParent && targetParent.slots.includes(this.context.slot as SlotName)) {\n        targetParent.appendChild(this.componentCopy, this.context.slot as SlotName);\n      }\n    }\n    return prev;\n  }\n}\n","import { BaseLeafOperation } from '../../type';\nimport { AppModel } from '../../../AppModel/AppModel';\nimport { ComponentId, SlotName } from '../../../AppModel/IAppModel';\n\nexport type MoveComponentLeafOperationContext = {\n  componentId: string;\n  parent?: string;\n  slot?: string;\n};\n\nexport class MoveComponentLeafOperation extends BaseLeafOperation<MoveComponentLeafOperationContext> {\n  private originParent: ComponentId | null = null;\n  private originSlot: SlotName | null = null;\n  do(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (!component) {\n      console.warn('component not found');\n      return prev;\n    }\n    this.originParent = component.parentId;\n    this.originSlot = component.parentSlot;\n\n    if (!this.context.parent || !this.context.slot) {\n      prev.appendChild(component);\n      return prev;\n    }\n\n    const parent = prev.getComponentById(this.context.parent as ComponentId);\n    if (!parent) {\n      prev.appendChild(component);\n    } else {\n      parent.appendChild(component, this.context.slot as SlotName);\n    }\n\n    return prev;\n  }\n\n  redo(prev: AppModel): AppModel {\n    return this.do(prev);\n  }\n\n  undo(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId)!;\n    if (!this.originParent) {\n      prev.appendChild(component);\n    } else {\n      const parent = prev.getComponentById(this.originParent)!;\n      parent.appendChild(component, this.originSlot!);\n    }\n\n    return prev;\n  }\n}\n","import { AppModel } from '../../../AppModel/AppModel';\nimport { ComponentId, ITraitModel } from '../../../AppModel/IAppModel';\nimport { BaseLeafOperation } from '../../type';\n\nexport type RemoveTraitLeafOperationContext = {\n  componentId: string;\n  index: number;\n};\n\nexport class RemoveTraitLeafOperation extends BaseLeafOperation<RemoveTraitLeafOperationContext> {\n  private deletedTrait!: ITraitModel;\n  do(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (!component) {\n      console.warn('component not found');\n      return prev;\n    }\n\n    this.deletedTrait = component.traits[this.context.index];\n    component.removeTrait(this.deletedTrait.id);\n    return prev;\n  }\n\n  redo(prev: AppModel): AppModel {\n    return this.do(prev);\n  }\n\n  undo(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (!component) {\n      console.warn('component not found');\n      return prev;\n    }\n\n    component.addTrait(this.deletedTrait.type, this.deletedTrait.rawProperties);\n    return prev;\n  }\n}\n","import { AppModel } from '../../../AppModel/AppModel';\nimport { ComponentId, TraitId, TraitType } from '../../../AppModel/IAppModel';\nimport { BaseLeafOperation } from '../../type';\n\nexport type CreateTraitLeafOperationContext = {\n  componentId: string;\n  traitType: string;\n  properties: Record<string, any>;\n};\n\nexport class CreateTraitLeafOperation extends BaseLeafOperation<CreateTraitLeafOperationContext> {\n  private traitId!: TraitId;\n\n  do(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (!component) {\n      return prev;\n    }\n    const trait = component.addTrait(\n      this.context.traitType as TraitType,\n      this.context.properties\n    );\n    this.traitId = trait.id;\n    return prev;\n  }\n\n  redo(prev: AppModel): AppModel {\n    return this.do(prev);\n  }\n\n  undo(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (!component) {\n      return prev;\n    }\n    component.removeTrait(this.traitId);\n    return prev;\n  }\n}\n","import { isFunction, cloneDeep } from 'lodash';\nimport { BaseLeafOperation } from '../../type';\nimport { AppModel } from '../../../AppModel/AppModel';\nimport { ComponentId } from '../../../AppModel/IAppModel';\n\nexport type ModifyTraitPropertiesLeafOperationContext = {\n  componentId: string;\n  traitIndex: number;\n  properties: Record<string, any | (<T = any>(prev: T) => T)>;\n};\n\nexport class ModifyTraitPropertiesLeafOperation extends BaseLeafOperation<ModifyTraitPropertiesLeafOperationContext> {\n  private previousState: Record<string, any> = {};\n  do(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (!component) {\n      console.warn('component not found');\n      return prev;\n    }\n    const trait = component.traits[this.context.traitIndex];\n    for (const property in this.context.properties) {\n      const oldValue = trait.rawProperties[property];\n      this.previousState[property] = oldValue;\n      let newValue = this.context.properties[property];\n      if (isFunction(newValue)) {\n        // if modified value is a lazy function, execute it and assign\n        newValue = newValue(cloneDeep(oldValue));\n      }\n      this.context.properties[property] = newValue;\n      trait.updateProperty(property, this.context.properties[property]);\n    }\n\n    return prev;\n  }\n\n  redo(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (!component) {\n      console.warn('component not found');\n      return prev;\n    }\n    const trait = component.traits[this.context.traitIndex];\n\n    for (const property in this.context.properties) {\n      trait.updateProperty(property, this.context.properties[property]);\n    }\n\n    return prev;\n  }\n\n  undo(prev: AppModel): AppModel {\n    const component = prev.getComponentById(this.context.componentId as ComponentId);\n    if (!component) {\n      console.warn('component not found');\n      return prev;\n    }\n    const trait = component.traits[this.context.traitIndex];\n\n    for (const property in this.previousState) {\n      trait.updateProperty(property, this.previousState[property]);\n    }\n\n    return prev;\n  }\n}\n","import { AppModel } from '../../AppModel/AppModel';\nimport { BaseLeafOperation } from '../type';\n\nexport type ReplaceAppLeafOperationContext = {\n  app: AppModel;\n};\n\nexport class ReplaceAppLeafOperation extends BaseLeafOperation<ReplaceAppLeafOperationContext> {\n  private previousState!: AppModel;\n  do(): AppModel {\n    return this.context.app;\n  }\n\n  redo(): AppModel {\n    return this.context.app;\n  }\n\n  undo(): AppModel {\n    return this.previousState;\n  }\n}\n","\nimport { AppModel } from '../../AppModel/AppModel';\nimport { BaseLeafOperation } from '../type';\n\nexport type UpdateSelectComponentLeafOperationContext = {\n  componentId?: string;\n  newId: string;\n};\n\nexport class UpdateSelectComponentLeafOperation extends BaseLeafOperation<UpdateSelectComponentLeafOperationContext> {\n  prevId!: string;\n  do(prev: AppModel): AppModel {\n    this.prevId = this.context.componentId || prev.topComponents[0].id;\n    setTimeout(() => {\n      // eventBus.send('selectComponent', this.context.newId);\n    });\n    return prev;\n  }\n\n  redo(prev: AppModel): AppModel {\n    setTimeout(() => {\n      // eventBus.send('selectComponent', this.context.newId);\n    });\n    return prev;\n  }\n\n  undo(prev: AppModel): AppModel {\n    setTimeout(() => {\n      // eventBus.send('selectComponent', this.prevId);\n    });\n    return prev;\n  }\n}\n","import { AppModel } from '../../../AppModel/AppModel';\nimport { ComponentId, ComponentType, SlotName } from '../../../AppModel/IAppModel';\nimport {\n  AdjustComponentOrderLeafOperation,\n  CreateComponentLeafOperation,\n} from '../../leaf';\nimport { BaseBranchOperation } from '../../type';\n\nexport type CreateComponentBranchOperationContext = {\n  componentType: string;\n  componentId?: string;\n  slot?: string;\n  parentId?: string;\n  targetId?: string;\n  direction?: 'prev' | 'next';\n};\n\nexport class CreateComponentBranchOperation extends BaseBranchOperation<CreateComponentBranchOperationContext> {\n  do(prev: AppModel): AppModel {\n    // gen component id\n    if (!this.context.componentId) {\n      this.context.componentId = prev.genId(this.context.componentType as ComponentType);\n    }\n    // insert a new component to schema\n    this.operationStack.insert(\n      new CreateComponentLeafOperation(this.registry, {\n        componentId: this.context.componentId!,\n        componentType: this.context.componentType,\n        parentId: this.context.parentId as ComponentId,\n        slot: this.context.slot as SlotName,\n      })\n    );\n    // add a slot trait if it has a parent\n    if (this.context.parentId && this.context.slot) {\n      // try to find parent\n      const parentComponent = prev.getComponentById(this.context.parentId as ComponentId);\n\n      if (!parentComponent) {\n        console.warn(\"insert element has an invalid parent, it won't show in the view\");\n      }\n    }\n\n    if (this.context.direction) {\n      this.operationStack.insert(\n        new AdjustComponentOrderLeafOperation(this.registry, {\n          componentId: this.context.componentId as ComponentId,\n          targetId: this.context.targetId as ComponentId,\n          direction: this.context.direction,\n        })\n      );\n    }\n\n    return this.operationStack.reduce((prev, node) => {\n      prev = node.do(prev);\n      return prev;\n    }, prev);\n  }\n}\n","import { AppModel } from '../../../AppModel/AppModel';\nimport { BaseBranchOperation } from '../../type';\nimport {\n  ModifyComponentIdLeafOperation,\n  UpdateSelectComponentLeafOperation,\n} from '../../leaf';\n\nexport type ModifyComponentIdBranchOperationContext = {\n  componentId: string;\n  newId: string;\n};\n\nexport class ModifyComponentIdBranchOperation extends BaseBranchOperation<ModifyComponentIdBranchOperationContext> {\n  do(prev: AppModel): AppModel {\n    this.operationStack.insert(new ModifyComponentIdLeafOperation(this.registry, this.context));\n\n    // update selectid\n    this.operationStack.insert(\n      new UpdateSelectComponentLeafOperation(this.registry, {\n        // TODO:  need a way to get selectedComponent.id here\n        // componentId: ApplicationComponent[]Instance.selectedComponent?.id,\n        componentId: '',\n        newId: this.context.newId,\n      })\n    );\n\n    return this.operationStack.reduce((prev, node) => {\n      prev = node.do(prev);\n      return prev;\n    }, prev);\n  }\n}\n","import { AppModel } from '../../../AppModel/AppModel';\nimport { RemoveComponentLeafOperation } from '../../leaf';\nimport { BaseBranchOperation } from '../../type';\n\nexport type RemoveComponentBranchOperationContext = {\n  componentId: string;\n};\n\nexport class RemoveComponentBranchOperation extends BaseBranchOperation<RemoveComponentBranchOperationContext> {\n  do(prev: AppModel): AppModel {\n    // free component from schema\n    this.operationStack.insert(\n      new RemoveComponentLeafOperation(this.registry, {\n        componentId: this.context.componentId,\n      })\n    );\n\n    // do the operation in order\n    return this.operationStack.reduce((prev, node) => {\n      prev = node.do(prev);\n      return prev;\n    }, prev);\n  }\n}\n","import { AppModel } from '../../../AppModel/AppModel';\nimport { BaseBranchOperation } from '../../type';\nimport {\n  AdjustComponentOrderLeafOperation,\n  MoveComponentLeafOperation,\n} from '../../leaf';\nimport { ComponentId } from '../../../AppModel/IAppModel';\n\nexport type MoveComponentBranchOperationContext = {\n  fromId: string;\n  toId?: string;\n  slot?: string;\n  targetId?: string;\n  direction?: 'prev' | 'next';\n};\n\nexport class MoveComponentBranchOperation extends BaseBranchOperation<MoveComponentBranchOperationContext> {\n  do(prev: AppModel): AppModel {\n    const from = prev.getComponentById(this.context.fromId as ComponentId);\n    if (!from) return prev;\n\n    if (from.parentId !== this.context.toId || from.parentSlot !== this.context.slot) {\n      this.operationStack.insert(\n        new MoveComponentLeafOperation(this.registry, {\n          componentId: this.context.fromId,\n          parent: this.context.toId,\n          slot: this.context.slot,\n        })\n      );\n    }\n\n    if (this.context.direction) {\n      this.operationStack.insert(\n        new AdjustComponentOrderLeafOperation(this.registry, {\n          componentId: this.context.fromId as ComponentId,\n          targetId: this.context.targetId as ComponentId,\n          direction: this.context.direction,\n        })\n      );\n    }\n\n    return this.operationStack.reduce((prev, node) => {\n      prev = node.do(prev);\n      return prev;\n    }, prev);\n  }\n}\n","import { AppModel } from '../../../AppModel/AppModel';\nimport {\n  CreateComponentLeafOperation,\n  ModifyComponentPropertiesLeafOperation,\n  ModifyTraitPropertiesLeafOperation,\n} from '../../leaf';\nimport { BaseBranchOperation } from '../../type';\nimport { EventHandlerSpec } from '@sunmao-ui/shared';\nimport { Static } from '@sinclair/typebox';\nimport { MoveComponentBranchOperation, RemoveComponentBranchOperation } from '..';\nimport { ComponentId, SlotName } from '../../../AppModel/IAppModel';\n\ntype TraitNewProperties = {\n  componentId: string;\n  traitIndex: number;\n  properties: Record<string, any>;\n};\nexport type ExtractModuleBranchOperationContext = {\n  moduleContainerId: string;\n  moduleContainerProperties: Record<string, any>;\n  moduleId: string;\n  moduleRootId: string;\n  moduleType: string;\n  moduleHandlers: Static<typeof EventHandlerSpec>[];\n  outsideComponentNewProperties: Record<string, any>;\n  outsideTraitNewProperties: TraitNewProperties[];\n  toDeleteComponentIds: string[];\n};\n\nexport class ExtractModuleBranchOperation extends BaseBranchOperation<ExtractModuleBranchOperationContext> {\n  do(prev: AppModel): AppModel {\n    const root = prev.getComponentById(this.context.moduleRootId as ComponentId);\n    if (!root) {\n      console.warn('component not found');\n      return prev;\n    }\n    // create module container component\n    this.operationStack.insert(\n      new CreateComponentLeafOperation(this.registry, {\n        componentId: this.context.moduleContainerId,\n        componentType: `core/v1/moduleContainer`,\n      })\n    );\n\n    // add properties to module container component\n    this.operationStack.insert(\n      new ModifyComponentPropertiesLeafOperation(this.registry, {\n        componentId: this.context.moduleContainerId,\n        properties: {\n          id: this.context.moduleId,\n          type: this.context.moduleType,\n          properties: this.context.moduleContainerProperties,\n          handlers: this.context.moduleHandlers,\n        },\n      })\n    );\n\n    // move module container to the position of root\n    this.operationStack.insert(\n      new MoveComponentBranchOperation(this.registry, {\n        fromId: this.context.moduleContainerId,\n        toId: root.parentId as ComponentId,\n        slot: root.parentSlot as SlotName,\n        targetId: root.id,\n        direction: 'next',\n      })\n    );\n\n    // update the properties of outside components\n    for (const id in this.context.outsideComponentNewProperties) {\n      this.operationStack.insert(\n        new ModifyComponentPropertiesLeafOperation(this.registry, {\n          componentId: id,\n          properties: this.context.outsideComponentNewProperties[id],\n        })\n      );\n    }\n    // update the properties of outside components' trait\n    this.context.outsideTraitNewProperties.forEach(\n      ({ componentId, traitIndex, properties }) => {\n        this.operationStack.insert(\n          new ModifyTraitPropertiesLeafOperation(this.registry, {\n            componentId,\n            traitIndex,\n            properties,\n          })\n        );\n      }\n    );\n\n    // remove the module root component\n    this.operationStack.insert(\n      new RemoveComponentBranchOperation(this.registry, {\n        componentId: this.context.moduleRootId,\n      })\n    );\n\n    // remove other components which are moved in to module\n    this.context.toDeleteComponentIds.forEach(id => {\n      this.operationStack.insert(\n        new RemoveComponentBranchOperation(this.registry, {\n          componentId: id,\n        })\n      );\n    });\n\n    return this.operationStack.reduce((prev, node) => {\n      prev = node.do(prev);\n      return prev;\n    }, prev);\n  }\n}\n","import { AppModel } from '../../../AppModel/AppModel';\nimport { BaseBranchOperation } from '../../type';\nimport { CreateComponentBranchOperation } from '../index';\nimport { CreateTraitLeafOperation } from '../../leaf';\nimport {\n  generateDefaultValueFromSpec,\n  CORE_VERSION,\n  CoreComponentName,\n} from '@sunmao-ui/shared';\nimport { JSONSchema7Object } from 'json-schema';\n\nexport type CreateDataSourceBranchOperationContext = {\n  id: string;\n  type: string;\n  defaultProperties?: Record<string, any>;\n};\n\nexport class CreateDataSourceBranchOperation extends BaseBranchOperation<CreateDataSourceBranchOperationContext> {\n  do(prev: AppModel): AppModel {\n    const { id, type, defaultProperties } = this.context;\n    const traitDefine = this.registry.getTraitByType(type);\n    const traitSpec = traitDefine.spec;\n    const initProperties =\n      traitDefine.metadata.exampleProperties ||\n      (generateDefaultValueFromSpec(traitSpec.properties, {\n        genArrayItemDefaults: true,\n      }) as JSONSchema7Object);\n\n    this.operationStack.insert(\n      new CreateComponentBranchOperation(this.registry, {\n        componentType: `${CORE_VERSION}/${CoreComponentName.Dummy}`,\n        componentId: id,\n      })\n    );\n    this.operationStack.insert(\n      new CreateTraitLeafOperation(this.registry, {\n        componentId: id,\n        traitType: type,\n        properties: defaultProperties || initProperties,\n      })\n    );\n\n    // do the operation in order\n    return this.operationStack.reduce((prev, node) => {\n      prev = node.do(prev);\n      return prev;\n    }, prev);\n  }\n}\n","import { RegistryInterface } from '@sunmao-ui/runtime';\nimport {\n  CreateComponentBranchOperation,\n  CreateComponentBranchOperationContext,\n  ModifyComponentIdBranchOperation,\n  ModifyComponentIdBranchOperationContext,\n  RemoveComponentBranchOperation,\n  RemoveComponentBranchOperationContext,\n  MoveComponentBranchOperation,\n  MoveComponentBranchOperationContext,\n  ExtractModuleBranchOperation,\n  ExtractModuleBranchOperationContext,\n  CreateDataSourceBranchOperation,\n  CreateDataSourceBranchOperationContext,\n} from './branch';\nimport {\n  AdjustComponentOrderLeafOperation,\n  AdjustComponentOrderLeafOperationContext,\n  CreateTraitLeafOperation,\n  CreateTraitLeafOperationContext,\n  ModifyComponentPropertiesLeafOperation,\n  ModifyComponentPropertiesLeafOperationContext,\n  ModifyTraitPropertiesLeafOperation,\n  ModifyTraitPropertiesLeafOperationContext,\n  RemoveTraitLeafOperation,\n  RemoveTraitLeafOperationContext,\n  ReplaceAppLeafOperation,\n  ReplaceAppLeafOperationContext,\n  PasteComponentLeafOperation,\n  PasteComponentLeafOperationContext,\n} from './leaf';\nimport { IOperation } from './type';\n\nexport const OperationConstructors: Record<\n  OperationTypes,\n  OperationConfigMaps[OperationTypes]['constructor']\n> = {\n  createComponent: CreateComponentBranchOperation,\n  removeComponent: RemoveComponentBranchOperation,\n  modifyComponentProperties: ModifyComponentPropertiesLeafOperation,\n  modifyComponentId: ModifyComponentIdBranchOperation,\n  adjustComponentOrder: AdjustComponentOrderLeafOperation,\n  createTrait: CreateTraitLeafOperation,\n  removeTrait: RemoveTraitLeafOperation,\n  modifyTraitProperty: ModifyTraitPropertiesLeafOperation,\n  replaceApp: ReplaceAppLeafOperation,\n  pasteComponent: PasteComponentLeafOperation,\n  moveComponent: MoveComponentBranchOperation,\n  extractModule: ExtractModuleBranchOperation,\n  createDataSource: CreateDataSourceBranchOperation,\n};\n\ntype OperationTypes = keyof OperationConfigMaps;\n\ntype OperationConfigMap<TOperation, TContext> = {\n  constructor: new (registry: RegistryInterface, context: TContext) => TOperation;\n  context: TContext;\n  registry: RegistryInterface;\n};\n\nexport type OperationConfigMaps = {\n  createComponent: OperationConfigMap<\n    CreateComponentBranchOperation,\n    CreateComponentBranchOperationContext\n  >;\n  removeComponent: OperationConfigMap<\n    RemoveComponentBranchOperation,\n    RemoveComponentBranchOperationContext\n  >;\n  modifyComponentProperties: OperationConfigMap<\n    ModifyComponentPropertiesLeafOperation,\n    ModifyComponentPropertiesLeafOperationContext\n  >;\n  modifyComponentId: OperationConfigMap<\n    ModifyComponentIdBranchOperation,\n    ModifyComponentIdBranchOperationContext\n  >;\n  adjustComponentOrder: OperationConfigMap<\n    AdjustComponentOrderLeafOperation,\n    AdjustComponentOrderLeafOperationContext\n  >;\n  createTrait: OperationConfigMap<\n    CreateTraitLeafOperation,\n    CreateTraitLeafOperationContext\n  >;\n  removeTrait: OperationConfigMap<\n    RemoveTraitLeafOperation,\n    RemoveTraitLeafOperationContext\n  >;\n  modifyTraitProperty: OperationConfigMap<\n    ModifyTraitPropertiesLeafOperation,\n    ModifyTraitPropertiesLeafOperationContext\n  >;\n  replaceApp: OperationConfigMap<ReplaceAppLeafOperation, ReplaceAppLeafOperationContext>;\n\n  pasteComponent: OperationConfigMap<\n    PasteComponentLeafOperation,\n    PasteComponentLeafOperationContext\n  >;\n  moveComponent: OperationConfigMap<\n    MoveComponentBranchOperation,\n    MoveComponentBranchOperationContext\n  >;\n  extractModule: OperationConfigMap<\n    ExtractModuleBranchOperation,\n    ExtractModuleBranchOperationContext\n  >;\n  createDataSource: OperationConfigMap<\n    CreateDataSourceBranchOperation,\n    CreateDataSourceBranchOperationContext\n  >;\n};\n\nexport const genOperation = <T extends OperationTypes>(\n  registry: RegistryInterface,\n  type: T,\n  context: OperationConfigMaps[T]['context']\n): IOperation => {\n  const OperationConstructor = OperationConstructors[\n    type\n  ] as OperationConfigMaps[T]['constructor'];\n  return new OperationConstructor(registry, context as any);\n};\n","import { Box } from '@chakra-ui/react';\nimport React, { useMemo, useRef, useState, useCallback } from 'react';\nimport { ComponentId } from '../../AppModel/IAppModel';\nimport { genOperation } from '../../operations';\nimport { EditorServices } from '../../types';\n\ntype Props = {\n  componentId?: string;\n  parentId?: string;\n  parentSlot?: string;\n  isExpanded: boolean;\n  // only can be drop in and cannot drop before or after\n  isDropInOnly?: boolean;\n  droppable: boolean;\n  services: EditorServices;\n  hasSlot: boolean;\n};\n\nexport const DropComponentWrapper: React.FC<Props> = props => {\n  const {\n    componentId,\n    parentId,\n    parentSlot,\n    services,\n    isDropInOnly,\n    isExpanded,\n    droppable,\n    hasSlot,\n  } = props;\n  const { registry, eventBus, appModelManager } = services;\n  const ref = useRef<HTMLDivElement>(null);\n  const [dragDirection, setDragDirection] = useState<'prev' | 'next' | undefined>();\n  const [isDragOver, setIsDragOver] = useState<boolean>(false);\n\n  const onDragOver = useCallback(\n    (e: React.DragEvent) => {\n      if (!droppable) {\n        return;\n      }\n      setIsDragOver(true);\n      e.preventDefault();\n      e.stopPropagation();\n\n      if (isDropInOnly) return;\n\n      const rect = ref.current?.getBoundingClientRect();\n\n      if (!rect) return;\n\n      if (e.clientY < rect.top + rect.height / 2) {\n        setDragDirection('prev');\n      } else if (e.clientY >= rect.top + rect.height / 2) {\n        setDragDirection('next');\n      }\n    },\n    [droppable, isDropInOnly]\n  );\n\n  const onDragLeave = useCallback(() => {\n    if (!droppable) {\n      return;\n    }\n    setDragDirection(undefined);\n    setIsDragOver(false);\n  }, [droppable]);\n\n  const onDrop = useCallback(\n    (e: React.DragEvent) => {\n      if (!droppable) {\n        return;\n      }\n      e.stopPropagation();\n      e.preventDefault();\n      const creatingComponent = e.dataTransfer?.getData('component') || '';\n      const movingComponent = e.dataTransfer?.getData('moveComponent') || '';\n\n      let targetParentId = parentId;\n      let targetParentSlot = parentSlot;\n      let targetId = componentId;\n      if (dragDirection === 'next' && componentId && isExpanded && hasSlot) {\n        targetParentId = componentId;\n        // get first slot of component\n        targetParentSlot =\n          appModelManager.appModel.getComponentById(componentId as ComponentId)\n            ?.slots[0] || '';\n        targetId = undefined;\n      }\n\n      // move component before or after currentComponent\n      if (movingComponent) {\n        eventBus.send(\n          'operation',\n          genOperation(registry, 'moveComponent', {\n            fromId: movingComponent,\n            toId: targetParentId,\n            slot: targetParentSlot,\n            targetId: targetId,\n            direction: dragDirection,\n          })\n        );\n      }\n\n      // create component as children\n      if (creatingComponent) {\n        eventBus.send(\n          'operation',\n          genOperation(registry, 'createComponent', {\n            componentType: creatingComponent,\n            parentId: targetParentId,\n            slot: targetParentSlot,\n            targetId: targetId,\n            direction: dragDirection,\n          })\n        );\n      }\n      setDragDirection(undefined);\n      setIsDragOver(false);\n    },\n    [\n      droppable,\n      parentId,\n      parentSlot,\n      componentId,\n      dragDirection,\n      isExpanded,\n      hasSlot,\n      appModelManager.appModel,\n      eventBus,\n      registry,\n    ]\n  );\n\n  const boxShadow = useMemo(() => {\n    if (isDropInOnly) return '';\n    switch (dragDirection) {\n      case 'prev':\n        return '0 -2px 0 0 #ff8080';\n      case 'next':\n        return '0 2px 0 0 #ff8080';\n    }\n  }, [dragDirection, isDropInOnly]);\n\n  return (\n    <Box\n      ref={ref}\n      width=\"full\"\n      boxShadow={boxShadow}\n      background={isDragOver ? '#ffc6c6' : undefined}\n      onDrop={onDrop}\n      onDragOver={onDragOver}\n      onDragLeave={onDragLeave}\n    >\n      {props.children}\n    </Box>\n  );\n};\n","import { ComponentSchema, parseType } from '@sunmao-ui/core';\nimport { RegistryInterface } from '@sunmao-ui/runtime';\nimport { CORE_VERSION, CoreComponentName } from '@sunmao-ui/shared';\nimport { ComponentModel } from './ComponentModel';\nimport {\n  ComponentId,\n  ComponentType,\n  IAppModel,\n  IComponentModel,\n  IFieldModel,\n  ModuleId,\n  SlotName,\n} from './IAppModel';\nimport { genComponent } from './utils';\nimport mitt from 'mitt';\nimport { forEach } from 'lodash';\n\nexport class AppModel implements IAppModel {\n  topComponents: IComponentModel[] = [];\n  emitter: IAppModel['emitter'] = mitt();\n  // modules: IModuleModel[] = [];\n  private schema: ComponentSchema[] = [];\n  private componentMap: Record<ComponentId, IComponentModel> = {};\n  private componentsCount = 0;\n\n  constructor(components: ComponentSchema[], private registry: RegistryInterface) {\n    this.schema = components;\n    this.componentsCount = components.length;\n    this.resolveTree(components);\n  }\n\n  get allComponents(): IComponentModel[] {\n    const result: IComponentModel[] = [];\n    this.traverseTree(c => {\n      result.push(c);\n    });\n    return result;\n  }\n\n  // get from componentMap\n  get allComponentsWithOrphan(): IComponentModel[] {\n    return Object.values(this.componentMap);\n  }\n\n  get moduleIds(): ModuleId[] {\n    return this.allComponents\n      .filter(c => c.type === `${CORE_VERSION}/${CoreComponentName.ModuleContainer}`)\n      .map(c => c.properties.rawValue.id);\n  }\n\n  toSchema(): ComponentSchema[] {\n    this.schema = this.allComponents.map(c => {\n      return c.toSchema();\n    });\n\n    return this.schema;\n  }\n\n  appendChild(component: IComponentModel) {\n    component.appModel.removeComponent(component.id);\n    component.parentId = null;\n    component.parentSlot = null;\n    component.parent = null;\n    if (component._slotTrait) {\n      component.removeTrait(component._slotTrait.id);\n    }\n    this.topComponents.push(component);\n    this.traverseTree(c => {\n      this._bindComponentToModel(c);\n    });\n  }\n\n  createComponent(type: ComponentType, id?: ComponentId): IComponentModel {\n    const component = genComponent(this.registry, type, id || this.genId(type));\n    return new ComponentModel(component, this.registry, this);\n  }\n\n  getComponentById(componentId: ComponentId): IComponentModel | undefined {\n    return this.componentMap[componentId];\n  }\n\n  removeComponent(componentId: ComponentId) {\n    const comp = this.componentMap[componentId];\n    if (!comp) return;\n    delete this.componentMap[componentId];\n    if (comp.parentSlot && comp.parent) {\n      const children = comp.parent.children[comp.parentSlot];\n      comp.parent.children[comp.parentSlot] = children.filter(c => c !== comp);\n    } else {\n      this.topComponents.splice(this.topComponents.indexOf(comp), 1);\n    }\n  }\n\n  changeComponentMapId(oldId: ComponentId, newId: ComponentId) {\n    this.componentMap[newId] = this.componentMap[oldId];\n    delete this.componentMap[oldId];\n  }\n\n  _bindComponentToModel(component: IComponentModel) {\n    this.componentMap[component.id] = component;\n    component.appModel = this;\n  }\n\n  genId(type: ComponentType): ComponentId {\n    const { name } = parseType(type);\n    const newId = `${name}${this.componentsCount++}` as ComponentId;\n    if (this.allComponents.some(c => c.id === newId)) {\n      return this.genId(type);\n    }\n    return newId;\n  }\n\n  private resolveTree(components: ComponentSchema[]) {\n    const allComponents = components.map(c => {\n      if (this.componentMap[c.id as ComponentId]) {\n        throw new Error(`Duplicate component id: ${c.id}`);\n      } else {\n        const comp = new ComponentModel(c, this.registry, this);\n        this.componentMap[c.id as ComponentId] = comp;\n        return comp;\n      }\n    });\n\n    allComponents.forEach(child => {\n      if (!child.parentId || !child.parentSlot) {\n        this.topComponents.push(child);\n        return;\n      }\n      const parent = this.componentMap[child.parentId];\n      if (parent && parent.slots.includes(child.parentSlot)) {\n        child.parent = parent;\n        if (parent.children[child.parentSlot]) {\n          parent.children[child.parentSlot].push(child);\n        } else {\n          parent.children[child.parentSlot] = [child];\n        }\n      }\n    });\n  }\n\n  traverseTree(cb: (c: IComponentModel) => void) {\n    function traverse(root: IComponentModel) {\n      cb(root);\n      for (const slot in root.children) {\n        root.children[slot as SlotName].forEach(child => {\n          traverse(child);\n        });\n      }\n    }\n    if (this.topComponents.length) {\n      this.topComponents.forEach(parent => {\n        traverse(parent);\n      });\n    } else {\n      // When all the components have slot trait, there is no topComponents.\n      // Just iterate them in order.\n      Object.values(this.componentMap).forEach(c => {\n        cb(c);\n      });\n    }\n  }\n\n  traverseAllFields(cb: (f: IFieldModel) => void) {\n    function traverseField(field: IFieldModel) {\n      cb(field);\n      const value = field.getValue();\n      if (typeof value === 'object') {\n        forEach(value, childField => {\n          traverseField(childField);\n        });\n      }\n    }\n\n    this.traverseTree(c => {\n      traverseField(c.properties);\n      c.traits.forEach(t => {\n        traverseField(t.properties);\n      });\n    });\n  }\n}\n","import { ComponentSchema, TraitSchema } from '@sunmao-ui/core';\nimport { RegistryInterface } from '@sunmao-ui/runtime';\n\nexport function genComponent(\n  registry: RegistryInterface,\n  type: string,\n  id: string,\n  properties?: Record<string, unknown>,\n  traits: TraitSchema[] = []\n): ComponentSchema {\n  const cImpl = registry.getComponentByType(type);\n  const initProperties = properties || cImpl.metadata.exampleProperties || {};\n  return {\n    id,\n    type: type,\n    properties: initProperties,\n    traits,\n  };\n}\n\nexport function genTrait(\n  type: string,\n  properties: Record<string, unknown> = {}\n): TraitSchema {\n  return {\n    type,\n    properties,\n  };\n}\n","import { parseExpression, expChunkToString } from '@sunmao-ui/shared';\nimport { CustomOptions } from '@sinclair/typebox';\nimport * as acorn from 'acorn';\nimport * as acornLoose from 'acorn-loose';\nimport { simple as simpleWalk } from 'acorn-walk';\nimport { flattenDeep, isArray, isObject } from 'lodash';\nimport { isExpression } from '../validator/utils';\nimport {\n  ComponentId,\n  IComponentModel,\n  ITraitModel,\n  IFieldModel,\n  ModuleId,\n  RefInfo,\n  ASTNode,\n} from './IAppModel';\nimport escodegen from 'escodegen';\nimport { JSONSchema7 } from 'json-schema';\n\nexport type FunctionNode = ASTNode & { params: ASTNode[] };\nexport type DeclaratorNode = ASTNode & { id: ASTNode };\nexport type ObjectPatternNode = ASTNode & { properties: PropertyNode[] };\nexport type ArrayPatternNode = ASTNode & { elements: ASTNode[] };\nexport type PropertyNode = ASTNode & { value: ASTNode };\nexport type LiteralNode = ASTNode & { raw: string };\nexport type SequenceExpressionNode = ASTNode & { expressions: LiteralNode[] };\nexport type ExpressionNode = ASTNode & {\n  object: ExpressionNode;\n  property: ExpressionNode | LiteralNode;\n};\nexport class FieldModel implements IFieldModel {\n  isDynamic = false;\n  refComponentInfos: Record<ComponentId | ModuleId, RefInfo> = {};\n  private astNodes: Record<string, ASTNode> = {};\n  private value: unknown | Array<IFieldModel> | Record<string, IFieldModel>;\n\n  constructor(\n    value: unknown,\n    private componentModel?: IComponentModel,\n    public spec?: JSONSchema7 & CustomOptions,\n    private traitModel?: ITraitModel\n  ) {\n    this.update(value);\n  }\n\n  get rawValue() {\n    if (isObject(this.value)) {\n      if (isArray(this.value)) {\n        return this.value.map(field => field.rawValue);\n      } else {\n        const _thisValue = this.value as Record<string, IFieldModel>;\n        const res: Record<string, any> = {};\n        for (const key in _thisValue) {\n          res[key] = _thisValue[key].rawValue;\n        }\n        return res;\n      }\n    }\n    return this.value;\n  }\n\n  private updateValue(value: unknown, shouldExtendValues = true) {\n    if (isObject(value)) {\n      const isArrayValue = isArray(value);\n      const isOldValueObject = isObject(this.value);\n\n      this.value = (Object.keys(value) as Array<keyof typeof value>).reduce(\n        (result, key) => {\n          const oldValue: IFieldModel | null = isObject(this.value)\n            ? this.value[key]\n            : null;\n          let newValue: FieldModel;\n\n          if (oldValue) {\n            (oldValue as FieldModel).updateValue(value[key], false);\n            newValue = oldValue;\n          } else {\n            newValue = new FieldModel(\n              value[key],\n              this.componentModel,\n              (this.spec?.properties?.[key] || this.spec?.items) as\n                | (JSONSchema7 & CustomOptions)\n                | undefined,\n              this.traitModel\n            );\n          }\n\n          if (isArray(result)) {\n            result.push(newValue);\n          } else {\n            result[key] = newValue;\n          }\n\n          return result;\n        },\n        (isArrayValue\n          ? []\n          : shouldExtendValues && isOldValueObject\n          ? this.value\n          : {}) as Record<string, IFieldModel>\n      );\n    } else {\n      this.value = value;\n    }\n    this.isDynamic = isExpression(value);\n    this.parseReferences();\n  }\n\n  update(value: unknown) {\n    this.updateValue(value);\n  }\n\n  getProperty(key: string | number): FieldModel | undefined {\n    if (typeof this.value === 'object') {\n      return (this.value as any)[key];\n    }\n    return undefined;\n  }\n\n  // path is like the param of lodash.get, eg: 'foo.bar.0.value'\n  getPropertyByPath(path: string): FieldModel | undefined {\n    if (!path) return undefined;\n    const arr = path.split('.');\n    // eslint-disable-next-line @typescript-eslint/no-this-alias\n    let res: FieldModel | undefined = this;\n    arr.forEach(key => {\n      if (res) {\n        res = res.getProperty(key);\n      }\n    });\n    return res;\n  }\n\n  getValue() {\n    return this.value;\n  }\n\n  traverse(cb: (f: IFieldModel, key: string) => void) {\n    function _traverse(field: FieldModel, key: string) {\n      if (isObject(field.value)) {\n        for (const _key in field.value) {\n          const val = field.getProperty(_key);\n          if (val instanceof FieldModel) {\n            _traverse(val, `${key}.${_key}`);\n          }\n        }\n      } else {\n        cb(field, key);\n      }\n    }\n    _traverse(this, '');\n  }\n\n  private parseReferences() {\n    if (!this.isDynamic || typeof this.value !== 'string') return;\n\n    const exps = flattenDeep(\n      parseExpression(this.value as string).filter(exp => typeof exp !== 'string')\n    );\n\n    this.refComponentInfos = {};\n    this.astNodes = {};\n\n    exps.forEach(exp => {\n      let lastIdentifier: ComponentId = '' as ComponentId;\n      const node = (acornLoose as typeof acorn).parse(exp, { ecmaVersion: 2020 });\n      this.astNodes[exp] = node as ASTNode;\n      // These are variables of iife or other identifiers, they can't be validated\n      // so they should not be added in refs\n      let whiteList: ASTNode[] = [];\n\n      simpleWalk(node, {\n        Function: functionNode => {\n          whiteList = [...whiteList, ...(functionNode as FunctionNode).params];\n        },\n        Expression: expressionNode => {\n          switch (expressionNode.type) {\n            case 'Identifier':\n              const key = exp.slice(\n                expressionNode.start,\n                expressionNode.end\n              ) as ComponentId;\n\n              if (this.refComponentInfos[key]) {\n                this.refComponentInfos[key].componentIdASTNodes.push(\n                  expressionNode as ASTNode\n                );\n              } else if (key) {\n                this.refComponentInfos[key] = {\n                  componentIdASTNodes: [expressionNode as ASTNode],\n                  refProperties: [],\n                };\n              }\n              lastIdentifier = key;\n\n              break;\n            case 'MemberExpression':\n              if (lastIdentifier) {\n                this.refComponentInfos[lastIdentifier]?.refProperties.push(\n                  this.genPathFromMemberExpressionNode(expressionNode as ExpressionNode)\n                );\n              }\n              break;\n            case 'SequenceExpression':\n              const sequenceExpression = expressionNode as SequenceExpressionNode;\n              whiteList.push(sequenceExpression.expressions[1]);\n              break;\n            case 'Literal':\n              // do nothing, just stop it from going to default\n              break;\n            default:\n              // clear lastIdentifier when meet other astNode to break the MemberExpression chain\n              lastIdentifier = '' as ComponentId;\n          }\n        },\n        ObjectPattern: objPatternNode => {\n          const propertyNodes = (objPatternNode as ObjectPatternNode).properties;\n          propertyNodes.forEach(property => {\n            whiteList.push(property.value);\n          });\n        },\n        ArrayPattern: arrayPatternNode => {\n          whiteList = [...whiteList, ...(arrayPatternNode as ArrayPatternNode).elements];\n        },\n        VariableDeclarator: declarator => {\n          whiteList.push((declarator as DeclaratorNode).id);\n        },\n      });\n      // remove whiteList from refs\n      for (const key in this.refComponentInfos) {\n        if (whiteList.some(({ name }) => key === name)) {\n          delete this.refComponentInfos[key as any];\n        }\n      }\n    });\n  }\n\n  private genPathFromMemberExpressionNode(expNode: ExpressionNode) {\n    const path: string[] = [];\n    function travel(node: ExpressionNode) {\n      path.unshift(\n        node.property?.name || (node.property as LiteralNode)?.raw || node.name\n      );\n      if (node.object) {\n        travel(node.object);\n      }\n    }\n\n    travel(expNode);\n    return path.slice(1).join('.');\n  }\n\n  changeReferenceId(oldId: ComponentId, newId: ComponentId) {\n    if (!this.componentModel) {\n      return;\n    }\n\n    if (this.spec?.isComponentId && this.value === oldId) {\n      // the normal string property but the `isComponentId` which like the event trait's `componentId` property\n      // just simply change its value\n      if (this.traitModel) {\n        this.traitModel._isDirty = true;\n      }\n      this.componentModel._isDirty = true;\n      this.update(newId);\n    } else if (this.refComponentInfos[oldId]) {\n      // the component vars in the expressions\n      // change the AST nodes values of the related component vars\n      // then generate the new expression\n      const exps = parseExpression(this.value as string);\n      const newExps = exps.map(exp => {\n        const node = this.astNodes[exp.toString()];\n\n        if (node) {\n          const ref = this.refComponentInfos[oldId];\n\n          ref.componentIdASTNodes.forEach(refNode => {\n            refNode.name = newId;\n          });\n\n          this.refComponentInfos[newId] = ref;\n          delete this.refComponentInfos[oldId];\n\n          return [escodegen.generate(node)];\n        }\n\n        return exp;\n      });\n      const value = expChunkToString(newExps);\n\n      if (this.traitModel) {\n        this.traitModel._isDirty = true;\n      }\n      this.componentModel._isDirty = true;\n      this.update(value);\n    }\n  }\n}\n","export function isExpression(str: unknown) {\n  return typeof str === 'string' && /[\\s\\S]*{{[\\s\\S]*}}[\\s\\S]*/m.test(str);\n}\n","import { TraitSchema, RuntimeTrait } from '@sunmao-ui/core';\nimport { RegistryInterface } from '@sunmao-ui/runtime';\nimport {\n  IComponentModel,\n  TraitType,\n  ITraitModel,\n  IFieldModel,\n  TraitId,\n} from './IAppModel';\nimport { FieldModel } from './FieldModel';\nimport { genTrait } from './utils';\n\nlet traitIdCount = 0;\n\nexport class TraitModel implements ITraitModel {\n  private schema: TraitSchema;\n  spec: RuntimeTrait;\n  id: TraitId;\n  type: TraitType;\n  properties: IFieldModel;\n  _isDirty = false;\n\n  constructor(\n    trait: TraitSchema,\n    private registry: RegistryInterface,\n    public parent: IComponentModel\n  ) {\n    this.schema = trait;\n    this.parent = parent;\n    this.type = trait.type as TraitType;\n    this.id = `${this.parent.id}_trait${traitIdCount++}` as TraitId;\n    this.spec = this.registry.getTraitByType(this.type);\n\n    this.properties = new FieldModel(\n      trait.properties,\n      this.parent,\n      this.spec.spec.properties,\n      this\n    );\n  }\n\n  get rawProperties() {\n    return this.properties.rawValue;\n  }\n\n  get methods() {\n    return this.spec ? this.spec.spec.methods : [];\n  }\n\n  toSchema(): TraitSchema {\n    if (this._isDirty) {\n      this.schema = genTrait(this.type, this.rawProperties);\n    }\n    return this.schema;\n  }\n\n  updateProperty(key: string, value: any) {\n    this.properties.update({ [key]: value });\n    this._isDirty = true;\n    this.parent._isDirty = true;\n  }\n}\n","import { merge } from 'lodash';\nimport { RegistryInterface } from '@sunmao-ui/runtime';\nimport {\n  generateDefaultValueFromSpec,\n  CORE_VERSION,\n  CoreTraitName,\n  AnyTypePlaceholder,\n} from '@sunmao-ui/shared';\nimport {\n  ComponentSchema,\n  MethodSchema,\n  RuntimeComponent,\n  SlotSpec,\n} from '@sunmao-ui/core';\nimport { genComponent, genTrait } from './utils';\nimport {\n  ComponentId,\n  ComponentType,\n  IAppModel,\n  IComponentModel,\n  SlotName,\n  StyleSlotName,\n  ITraitModel,\n  IFieldModel,\n  EventName,\n  TraitType,\n  TraitId,\n  MethodName,\n} from './IAppModel';\nimport { TraitModel } from './TraitModel';\nimport { FieldModel } from './FieldModel';\nimport { AppModel } from './AppModel';\n\nconst SlotTraitType: TraitType = `${CORE_VERSION}/${CoreTraitName.Slot}` as TraitType;\nconst SlotTraitTypeV2: TraitType = `core/v2/${CoreTraitName.Slot}` as TraitType;\nconst DynamicStateTrait = [\n  `${CORE_VERSION}/${CoreTraitName.State}`,\n  `${CORE_VERSION}/${CoreTraitName.LocalStorage}`,\n];\n\ntype ComponentSpecModel = RuntimeComponent<\n  any,\n  any,\n  Record<MethodName, MethodSchema['parameters']>,\n  ReadonlyArray<StyleSlotName>,\n  Record<SlotName, SlotSpec>,\n  ReadonlyArray<EventName>\n>;\nexport class ComponentModel implements IComponentModel {\n  spec: ComponentSpecModel;\n  id: ComponentId;\n  type: ComponentType;\n  properties: IFieldModel;\n  children: Record<SlotName, IComponentModel[]> = {};\n  parent: IComponentModel | null = null;\n  parentId: ComponentId | null = null;\n  parentSlot: SlotName | null = null;\n  traits: ITraitModel[] = [];\n  stateExample: Record<string, any> = {};\n  _isDirty = false;\n\n  constructor(\n    private schema: ComponentSchema,\n    private registry: RegistryInterface,\n    public appModel: IAppModel\n  ) {\n    this.schema = schema;\n\n    this.id = schema.id as ComponentId;\n    this.type = schema.type as ComponentType;\n    this.spec = this.registry.getComponentByType(this.type) as any;\n\n    this.traits = schema.traits.map(t => new TraitModel(t, this.registry, this));\n    this.genStateExample();\n    this.parentId = this._slotTrait?.rawProperties.container.id;\n    this.parentSlot = this._slotTrait?.rawProperties.container.slot;\n    this.properties = new FieldModel(schema.properties, this, this.spec.spec.properties);\n  }\n\n  get slots() {\n    return (this.spec ? Object.keys(this.spec.spec.slots) : []) as SlotName[];\n  }\n\n  get events() {\n    return (this.spec ? this.spec.spec.events : []) as EventName[];\n  }\n\n  get methods() {\n    if (!this.spec) return [];\n    const componentMethods = [];\n    for (const methodName in this.spec.spec.methods) {\n      componentMethods.push({\n        name: methodName,\n        parameters: this.spec.spec.methods[methodName as MethodName]!,\n      });\n    }\n    const traitMethods: MethodSchema[] = this.traits.reduce(\n      (acc, t) => acc.concat(t.methods),\n      [] as MethodSchema[]\n    );\n    return [...componentMethods, ...traitMethods];\n  }\n\n  get styleSlots() {\n    return (this.spec ? this.spec.spec.styleSlots : []) as StyleSlotName[];\n  }\n\n  get rawProperties() {\n    return this.properties.rawValue;\n  }\n\n  get prevSibling() {\n    let components: IComponentModel[];\n    if (!this.parent) {\n      components = this.appModel.topComponents;\n    } else {\n      components = this.parent.children[this.parentSlot!];\n    }\n    const index = components.indexOf(this);\n    if (index === 0) return null;\n    return components[index - 1];\n  }\n\n  get nextSibling() {\n    let components: IComponentModel[];\n    if (!this.parent) {\n      components = this.appModel.topComponents;\n    } else {\n      components = this.parent.children[this.parentSlot!];\n    }\n    const index = components.indexOf(this);\n    if (index === components.length - 1) return null;\n    return components[index + 1];\n  }\n\n  get _slotTrait() {\n    return (\n      this.traits.find(t => t.type === SlotTraitType || t.type === SlotTraitTypeV2) ||\n      null\n    );\n  }\n\n  get allComponents(): IComponentModel[] {\n    const result: IComponentModel[] = [];\n    this.traverseTree(c => {\n      result.push(c);\n    });\n    return result;\n  }\n\n  toSchema(): ComponentSchema {\n    if (this._isDirty) {\n      this._isDirty = false;\n      const newProperties = this.rawProperties;\n      const newTraits = this.traits.map(t => t.toSchema());\n      const newSchema = genComponent(\n        this.registry,\n        this.type,\n        this.id,\n        newProperties,\n        newTraits\n      );\n      this.schema = newSchema;\n    }\n    return this.schema;\n  }\n\n  updateComponentProperty(propertyName: string, value: any) {\n    this.properties.update({ [propertyName]: value });\n    this._isDirty = true;\n  }\n\n  addTrait(traitType: TraitType, properties: Record<string, unknown>): ITraitModel {\n    const traitSchema = genTrait(traitType, properties);\n    const trait = new TraitModel(traitSchema, this.registry, this);\n    this.traits.push(trait);\n    this._isDirty = true;\n    this.genStateExample();\n    return trait;\n  }\n\n  appendTo = (parent?: IComponentModel, slot?: SlotName) => {\n    // remove from current position\n    if (this.parent) {\n      this.parent.removeChild(this);\n    }\n    if (!parent || !slot) {\n      this.appModel.appendChild(this);\n      return;\n    }\n    // update parent\n    if (!parent.children[slot]) {\n      parent.children[slot] = [];\n    }\n\n    parent.children[slot].push(this);\n    parent.appModel._bindComponentToModel(this);\n    this.parent = parent;\n    this.parentSlot = slot;\n    this.parentId = parent.id;\n    // update trait\n    this.updateSlotTrait(parent.id, slot);\n    this._isDirty = true;\n  };\n\n  removeChild(child: IComponentModel) {\n    const slotChildren = this.children[child.parentSlot!];\n    if (slotChildren) {\n      const index = slotChildren.indexOf(child);\n      if (index > -1) {\n        slotChildren.splice(slotChildren.indexOf(child), 1);\n        child._isDirty = true;\n        this._isDirty = true;\n      }\n    }\n  }\n\n  removeTrait(traitId: TraitId) {\n    const traitIndex = this.traits.findIndex(t => t.id === traitId);\n    if (traitIndex === -1) return;\n    this.traits.splice(traitIndex, 1);\n    this._isDirty = true;\n    this.genStateExample();\n  }\n\n  changeId(newId: ComponentId) {\n    const oldId = this.id;\n    const isIdExist = !!this.appModel.getComponentById(newId);\n\n    if (isIdExist) {\n      throw Error(`Id ${newId} already exist`);\n    }\n\n    this.id = newId;\n    for (const slot in this.children) {\n      const slotChildren = this.children[slot as SlotName];\n\n      slotChildren.forEach(child => {\n        child.parentId = newId;\n      });\n    }\n    this._isDirty = true;\n    this.appModel.changeComponentMapId(oldId, newId);\n    this.appModel.traverseAllFields(field => field.changeReferenceId(oldId, newId));\n\n    return this;\n  }\n\n  moveAfter(after: IComponentModel | null) {\n    let siblings: IComponentModel[] = [];\n    if (this.parent) {\n      siblings = this.parent.children[this.parentSlot as SlotName];\n    } else {\n      siblings = this.appModel.topComponents;\n    }\n    // update model\n    siblings.splice(siblings.indexOf(this), 1);\n    const afterIndexInSiblings = after\n      ? siblings.findIndex(c => c.id === after.id) + 1\n      : 0;\n    siblings.splice(afterIndexInSiblings, 0, this);\n    return this;\n  }\n\n  appendChild(child: IComponentModel, slot: SlotName) {\n    if (child.parent) {\n      child.parent.removeChild(child);\n    } else {\n      child.appModel.removeComponent(child.id);\n    }\n    if (!this.children[slot]) {\n      this.children[slot] = [];\n    }\n    this.children[slot].push(child);\n    child.parent = this;\n    child.parentSlot = slot;\n    child.parentId = this.id;\n    child.updateSlotTrait(this.id, slot);\n    this.appModel._bindComponentToModel(child);\n    this.traverseTree(c => {\n      this.appModel._bindComponentToModel(c);\n    });\n  }\n\n  updateTraitProperties(traitId: TraitId, properties: Record<string, unknown>) {\n    const trait = this.traits.find(t => t.id === traitId);\n    if (!trait) return;\n    for (const property in properties) {\n      trait.updateProperty(property, properties[property]);\n    }\n    trait._isDirty = true;\n    this._isDirty = true;\n  }\n\n  updateSlotTrait(parent: ComponentId, slot: SlotName) {\n    if (this._slotTrait) {\n      this._slotTrait.properties.update({ container: { id: parent, slot } });\n      this._slotTrait._isDirty = true;\n    } else {\n      this.addTrait(SlotTraitTypeV2, {\n        container: { id: parent, slot },\n        ifCondition: true,\n      });\n    }\n    this._isDirty = true;\n  }\n\n  removeSlotTrait() {\n    if (this._slotTrait) {\n      this.removeTrait(this._slotTrait.id);\n    }\n  }\n\n  clone() {\n    return new AppModel(\n      this.allComponents.map(c => c.toSchema()),\n      this.registry\n    ).getComponentById(this.id)!;\n  }\n\n  private traverseTree(cb: (c: IComponentModel) => void) {\n    function traverse(root: IComponentModel) {\n      cb(root);\n      for (const slot in root.children) {\n        root.children[slot as SlotName].forEach(child => {\n          traverse(child);\n        });\n      }\n    }\n    traverse(this);\n  }\n\n  // should be called after changing traits length\n  private genStateExample() {\n    if (!this.spec) return [];\n    const componentStateSpec = this.spec.spec.state;\n    let _temp = generateDefaultValueFromSpec(componentStateSpec, {\n      returnPlaceholderForAny: true,\n      genArrayItemDefaults: true,\n    }) as Record<string, any>;\n\n    this.traits.forEach(t => {\n      // if component has state trait, read state trait key and add it in\n      if (DynamicStateTrait.includes(t.type)) {\n        const key = t.properties.rawValue.key;\n        if (typeof key === 'string') {\n          _temp[key] = AnyTypePlaceholder;\n        }\n      } else {\n        _temp = merge(\n          _temp,\n          generateDefaultValueFromSpec(t.spec.spec.state, {\n            returnPlaceholderForAny: true,\n            genArrayItemDefaults: true,\n          })\n        );\n      }\n    });\n    this.stateExample = _temp;\n  }\n}\n","export type EventType = string | symbol;\n\n// An event handler can take an optional event argument\n// and should not return a value\nexport type Handler<T = unknown> = (event: T) => void;\nexport type WildcardHandler<T = Record<string, unknown>> = (\n\ttype: keyof T,\n\tevent: T[keyof T]\n) => void;\n\n// An array of all currently registered event handlers for a type\nexport type EventHandlerList<T = unknown> = Array<Handler<T>>;\nexport type WildCardEventHandlerList<T = Record<string, unknown>> = Array<WildcardHandler<T>>;\n\n// A map of event types and their corresponding event handlers.\nexport type EventHandlerMap<Events extends Record<EventType, unknown>> = Map<\n\tkeyof Events | '*',\n\tEventHandlerList<Events[keyof Events]> | WildCardEventHandlerList<Events>\n>;\n\nexport interface Emitter<Events extends Record<EventType, unknown>> {\n\tall: EventHandlerMap<Events>;\n\n\ton<Key extends keyof Events>(type: Key, handler: Handler<Events[Key]>): void;\n\ton(type: '*', handler: WildcardHandler<Events>): void;\n\n\toff<Key extends keyof Events>(type: Key, handler?: Handler<Events[Key]>): void;\n\toff(type: '*', handler: WildcardHandler<Events>): void;\n\n\temit<Key extends keyof Events>(type: Key, event: Events[Key]): void;\n\temit<Key extends keyof Events>(type: undefined extends Events[Key] ? Key : never): void;\n}\n\n/**\n * Mitt: Tiny (~200b) functional event emitter / pubsub.\n * @name mitt\n * @returns {Mitt}\n */\nexport default function mitt<Events extends Record<EventType, unknown>>(\n\tall?: EventHandlerMap<Events>\n): Emitter<Events> {\n\ttype GenericEventHandler =\n\t\t| Handler<Events[keyof Events]>\n\t\t| WildcardHandler<Events>;\n\tall = all || new Map();\n\n\treturn {\n\n\t\t/**\n\t\t * A Map of event names to registered handler functions.\n\t\t */\n\t\tall,\n\n\t\t/**\n\t\t * Register an event handler for the given type.\n\t\t * @param {string|symbol} type Type of event to listen for, or `'*'` for all events\n\t\t * @param {Function} handler Function to call in response to given event\n\t\t * @memberOf mitt\n\t\t */\n\t\ton<Key extends keyof Events>(type: Key, handler: GenericEventHandler) {\n\t\t\tconst handlers: Array<GenericEventHandler> | undefined = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\thandlers.push(handler);\n\t\t\t}\n\t\t\telse {\n\t\t\t\tall!.set(type, [handler] as EventHandlerList<Events[keyof Events]>);\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Remove an event handler for the given type.\n\t\t * If `handler` is omitted, all handlers of the given type are removed.\n\t\t * @param {string|symbol} type Type of event to unregister `handler` from, or `'*'`\n\t\t * @param {Function} [handler] Handler function to remove\n\t\t * @memberOf mitt\n\t\t */\n\t\toff<Key extends keyof Events>(type: Key, handler?: GenericEventHandler) {\n\t\t\tconst handlers: Array<GenericEventHandler> | undefined = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\tif (handler) {\n\t\t\t\t\thandlers.splice(handlers.indexOf(handler) >>> 0, 1);\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tall!.set(type, []);\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * Invoke all handlers for the given type.\n\t\t * If present, `'*'` handlers are invoked after type-matched handlers.\n\t\t *\n\t\t * Note: Manually firing '*' handlers is not supported.\n\t\t *\n\t\t * @param {string|symbol} type The event type to invoke\n\t\t * @param {Any} [evt] Any value (object is recommended and powerful), passed to each handler\n\t\t * @memberOf mitt\n\t\t */\n\t\temit<Key extends keyof Events>(type: Key, evt?: Events[Key]) {\n\t\t\tlet handlers = all!.get(type);\n\t\t\tif (handlers) {\n\t\t\t\t(handlers as EventHandlerList<Events[keyof Events]>)\n\t\t\t\t\t.slice()\n\t\t\t\t\t.map((handler) => {\n\t\t\t\t\t\thandler(evt!);\n\t\t\t\t\t});\n\t\t\t}\n\n\t\t\thandlers = all!.get('*');\n\t\t\tif (handlers) {\n\t\t\t\t(handlers as WildCardEventHandlerList<Events>)\n\t\t\t\t\t.slice()\n\t\t\t\t\t.map((handler) => {\n\t\t\t\t\t\thandler(type, evt!);\n\t\t\t\t\t});\n\t\t\t}\n\t\t}\n\t};\n}\n","import React, { useCallback } from 'react';\nimport {\n  Text,\n  Heading,\n  Table,\n  Tbody,\n  Td,\n  Th,\n  Thead,\n  Tr,\n  VStack,\n  Link,\n} from '@chakra-ui/react';\nimport { EditorServices } from '../../types';\nimport { ComponentId } from '../../AppModel/IAppModel';\nimport { CoreTraitName, CORE_VERSION, EventHandlerSpec } from '@sunmao-ui/shared';\nimport { Static } from '@sinclair/typebox';\nimport { AppModel } from '../../AppModel/AppModel';\n\ntype Props = {\n  componentId: string;\n  services: EditorServices;\n};\n\ntype ExpressionRelation = {\n  componentId: string;\n  exp: string;\n  key: string;\n};\ntype MethodRelation = {\n  componentId: string;\n  event: string;\n  method: string;\n};\n\nexport const RelationshipView: React.FC<Props> = ({ componentId, services }) => {\n  const { appModelManager, editorStore } = services;\n  const { appModel } = appModelManager;\n\n  const { expressionRelations, methodRelations } = getRelations(\n    componentId as ComponentId,\n    appModel\n  );\n\n  const idLink = useCallback(\n    (id: string) => {\n      return (\n        <Link\n          size=\"sm\"\n          onClick={() => {\n            editorStore.setSelectedComponentId(id);\n          }}\n        >\n          {id}\n        </Link>\n      );\n    },\n    [editorStore]\n  );\n\n  const expressionTable = () => {\n    if (!expressionRelations.length) {\n      return <Placeholder />;\n    }\n    return (\n      <Table size=\"sm\" border=\"1px solid\" borderColor=\"gray.100\">\n        <Thead>\n          <Tr>\n            <Th>ComponentId</Th>\n            <Th>Key</Th>\n            <Th>Expression</Th>\n          </Tr>\n        </Thead>\n        <Tbody>\n          {expressionRelations.map((d, i) => {\n            return (\n              <Tr key={i}>\n                <Td>{idLink(d.componentId)}</Td>\n                <Td>{d.key}</Td>\n                <Td>{d.exp}</Td>\n              </Tr>\n            );\n          })}\n        </Tbody>\n      </Table>\n    );\n  };\n\n  const methodTable = () => {\n    if (!methodRelations.length) {\n      return <Placeholder />;\n    }\n    return (\n      <Table size=\"sm\" border=\"1px solid\" borderColor=\"gray.100\">\n        <Thead>\n          <Tr>\n            <Th>ComponentId</Th>\n            <Th>Event</Th>\n            <Th>Method</Th>\n          </Tr>\n        </Thead>\n        <Tbody>\n          {methodRelations.map((d, i) => {\n            return (\n              <Tr key={i}>\n                <Td>{idLink(d.componentId)}</Td>\n                <Td>{d.event}</Td>\n                <Td>{d.method}</Td>\n              </Tr>\n            );\n          })}\n        </Tbody>\n      </Table>\n    );\n  };\n\n  return (\n    <VStack spacing=\"6\" width=\"full\" alignItems=\"start\">\n      <VStack width=\"full\" alignItems=\"start\">\n        <Heading size=\"md\">Who uses my states?</Heading>\n        {expressionTable()}\n      </VStack>\n      <VStack width=\"full\" alignItems=\"start\">\n        <Heading size=\"md\">Who calls my methods?</Heading>\n        {methodTable()}\n      </VStack>\n    </VStack>\n  );\n};\n\nexport function getRelations(componentId: ComponentId, appModel: AppModel) {\n  const expressionRelations: ExpressionRelation[] = [];\n  const methodRelations: MethodRelation[] = [];\n  appModel.traverseTree(c => {\n    c.properties.traverse((field, key) => {\n      if (field.isDynamic && field.refComponentInfos[componentId]) {\n        expressionRelations.push({\n          componentId: c.id,\n          exp: field.rawValue,\n          key: key,\n        });\n      }\n    });\n    c.traits.forEach(t => {\n      t.properties.traverse((field, key) => {\n        if (field.isDynamic && field.refComponentInfos[componentId]) {\n          expressionRelations.push({\n            componentId: c.id,\n            exp: field.rawValue,\n            key: key,\n          });\n        }\n      });\n\n      if (t.type === `${CORE_VERSION}/${CoreTraitName.Event}`) {\n        t.rawProperties.handlers.forEach((h: Static<typeof EventHandlerSpec>) => {\n          if (h.componentId === componentId) {\n            methodRelations.push({\n              componentId: c.id,\n              event: h.type,\n              method: h.method.name,\n            });\n          }\n        });\n      }\n      // special treat for core/v1/fetch, because its event handler is not in event trait\n      if (t.type === `${CORE_VERSION}/${CoreTraitName.Fetch}`) {\n        t.rawProperties.onComplete.forEach((h: Static<typeof EventHandlerSpec>) => {\n          if (h.componentId === componentId) {\n            methodRelations.push({\n              componentId: c.id,\n              event: 'onComplete',\n              method: h.method.name,\n            });\n          }\n        });\n        t.rawProperties.onError.forEach((h: Static<typeof EventHandlerSpec>) => {\n          if (h.componentId === componentId) {\n            methodRelations.push({\n              componentId: c.id,\n              event: 'onError',\n              method: h.method.name,\n            });\n          }\n        });\n      }\n    });\n  });\n  return { expressionRelations, methodRelations };\n}\n\nconst Placeholder = () => {\n  return (\n    <Text\n      width=\"full\"\n      padding=\"12px\"\n      background=\"gray.100\"\n      color=\"gray.500\"\n      borderRadius=\"4px\"\n      textAlign=\"center\"\n    >\n      No body\n    </Text>\n  );\n};\n","import React from 'react';\nimport {\n  Modal,\n  ModalOverlay,\n  ModalHeader,\n  ModalContent,\n  ModalCloseButton,\n  ModalBody,\n} from '@chakra-ui/react';\nimport { EditorServices } from '../../types';\nimport { RelationshipView } from './RelationshipView';\n\ntype Props = {\n  componentId: string;\n  onClose: () => void;\n  services: EditorServices;\n};\n\nexport const RelationshipModal: React.FC<Props> = ({\n  componentId,\n  onClose,\n  services,\n}) => {\n  return (\n    <Modal onClose={onClose} isOpen>\n      <ModalOverlay />\n      <ModalContent maxWidth=\"60vw\">\n        <ModalHeader>Relationships of {componentId}</ModalHeader>\n        <ModalCloseButton />\n        <ModalBody flex=\"1 1 auto\" height=\"75vh\" alignItems=\"start\" overflow=\"auto\">\n          <RelationshipView componentId={componentId} services={services} />\n        </ModalBody>\n      </ModalContent>\n    </Modal>\n  );\n};\n","import React from 'react';\nimport { List, ListItem, ListIcon } from '@chakra-ui/react';\nimport { CheckCircleIcon, SettingsIcon } from '@chakra-ui/icons';\n\ntype Props = {\n  activeIndex: number;\n};\n\nexport const ExtractModuleStep: React.FC<Props> = ({ activeIndex }) => {\n  return (\n    <List spacing={3} width=\"150px\" flex=\"0 0 auto\">\n      <ListItem\n        fontWeight={activeIndex === 0 ? 'bold' : 'normal'}\n        color={activeIndex > 0 ? 'gray.500' : 'gray.900'}\n      >\n        <ListIcon as={activeIndex > 0 ? CheckCircleIcon : SettingsIcon} />\n        Module Properties\n      </ListItem>\n\n      <ListItem\n        fontWeight={activeIndex === 1 ? 'bold' : 'normal'}\n        color={activeIndex > 1 ? 'gray.500' : 'gray.900'}\n      >\n        <ListIcon as={activeIndex > 1 ? CheckCircleIcon : SettingsIcon} />\n        Module State\n      </ListItem>\n\n      <ListItem\n        fontWeight={activeIndex === 2 ? 'bold' : 'normal'}\n        color={activeIndex > 2 ? 'gray.500' : 'gray.900'}\n      >\n        <ListIcon as={activeIndex > 2 ? CheckCircleIcon : SettingsIcon} />\n        Module Events\n      </ListItem>\n\n      <ListItem\n        fontWeight={activeIndex === 3 ? 'bold' : 'normal'}\n        color={activeIndex > 3 ? 'gray.500' : 'gray.900'}\n      >\n        <ListIcon as={activeIndex > 3 ? CheckCircleIcon : SettingsIcon} />\n        Preview\n      </ListItem>\n    </List>\n  );\n};\n","import { Text } from '@chakra-ui/react';\nimport React from 'react';\n\nexport const Placeholder: React.FC<{ text: string }> = ({ text }) => {\n  return (\n    <Text\n      width=\"full\"\n      padding=\"12px\"\n      background=\"gray.100\"\n      color=\"gray.500\"\n      borderRadius=\"4px\"\n      textAlign=\"center\"\n    >\n      {text}\n    </Text>\n  );\n};\n","import React, { useEffect, useMemo, useState } from 'react';\nimport {\n  Heading,\n  VStack,\n  Button,\n  HStack,\n  Radio,\n  RadioGroup,\n  FormControl,\n  FormLabel,\n  Text,\n  Tooltip,\n  Table,\n  Tbody,\n  Td,\n  Th,\n  Thead,\n  Tr,\n} from '@chakra-ui/react';\nimport { groupBy, uniq } from 'lodash';\nimport { EditorServices } from '../../types';\nimport { InsideExpRelation, RefTreatmentMap, RefTreatment } from './type';\nimport { RelationshipModal } from '../RelationshipModal';\nimport { Placeholder } from './Placeholder';\n\ntype Props = {\n  insideExpRelations: InsideExpRelation[];\n  onChange: (value: RefTreatmentMap) => void;\n  services: EditorServices;\n};\n\nconst RadioOptions = [\n  {\n    value: RefTreatment.keep,\n    label: 'Keep outside',\n    desc: `Keep this outside and pass this component's state into module by properties.`,\n  },\n  {\n    value: RefTreatment.move,\n    label: 'Move into module',\n    desc: 'Move this component into module and delete it outside.',\n  },\n  {\n    value: RefTreatment.duplicate,\n    label: 'Dupliacte',\n    desc: 'Copy and paste this component into module and keep it outside at the same time.',\n  },\n  {\n    value: RefTreatment.ignore,\n    label: 'Ignore',\n    desc: `Don't do anything.`,\n  },\n];\n\nexport const ExtractModulePropertyForm: React.FC<Props> = ({\n  insideExpRelations,\n  onChange,\n  services,\n}) => {\n  const [showRelationId, setShowRelationId] = useState('');\n  const [value, setValue] = useState<RefTreatmentMap>({});\n\n  const [relationGroups, refIds] = useMemo(\n    () => [\n      groupBy(insideExpRelations, r => r.componentId),\n      uniq(insideExpRelations.map(r => r.componentId)),\n    ],\n    [insideExpRelations]\n  );\n\n  useEffect(() => {\n    const map: RefTreatmentMap = {};\n    refIds.forEach(r => {\n      map[r] = RefTreatment.keep;\n    });\n    setValue(map);\n  }, [refIds]);\n\n  useEffect(() => {\n    onChange(value);\n  }, [onChange, value]);\n\n  let content = <Placeholder text={`No component uses outside components' state.`} />;\n  if (refIds.length) {\n    content = (\n      <VStack width=\"full\" spacing={4}>\n        {Object.keys(value).map(id => {\n          return (\n            <VStack key={id} width=\"full\">\n              <FormControl as=\"fieldset\" width=\"full\">\n                <FormLabel>\n                  <Button\n                    variant=\"link\"\n                    colorScheme=\"blue\"\n                    size=\"sm\"\n                    onClick={() => setShowRelationId(id)}\n                  >\n                    {id}\n                  </Button>\n                </FormLabel>\n\n                <RadioGroup\n                  onChange={newValue => {\n                    const next = { ...value, [id]: newValue as any };\n                    setValue(next);\n                  }}\n                  value={value[id]}\n                >\n                  <HStack>\n                    {RadioOptions.map(o => (\n                      <Radio key={o.value} value={o.value} cursor=\"pointer\">\n                        <Tooltip cursor=\"pointer\" label={o.desc}>\n                          {o.label}\n                        </Tooltip>\n                      </Radio>\n                    ))}\n                  </HStack>\n                </RadioGroup>\n              </FormControl>\n\n              <Table\n                size=\"sm\"\n                border=\"1px solid\"\n                borderColor=\"gray.100\"\n                width=\"full\"\n                style={{\n                  tableLayout: 'fixed',\n                }}\n              >\n                <Thead>\n                  <Tr>\n                    <Th>Component Id</Th>\n                    <Th>Property Key</Th>\n                    <Th>Expression</Th>\n                  </Tr>\n                </Thead>\n                <Tbody>\n                  {relationGroups[id].map((r, i) => {\n                    return (\n                      <Tr key={i}>\n                        <Td>\n                          <Text color=\"red.500\">\n                            {r.source}\n                            {r.traitType ? `-${r.traitType}` : ''}\n                          </Text>\n                        </Td>\n                        <Td>{r.key}</Td>\n                        <Td>{r.exp}</Td>\n                      </Tr>\n                    );\n                  })}\n                </Tbody>\n              </Table>\n            </VStack>\n          );\n        })}\n      </VStack>\n    );\n  }\n\n  const relationshipViewModal = showRelationId ? (\n    <RelationshipModal\n      componentId={showRelationId}\n      services={services}\n      onClose={() => setShowRelationId('')}\n    />\n  ) : null;\n  return (\n    <>\n      <VStack width=\"full\" alignItems=\"start\">\n        <Heading size=\"md\">Module Properties</Heading>\n        <Text>\n          These components are used by the components of module, you have to decide how to\n          treat them.\n        </Text>\n        {content}\n      </VStack>\n      {relationshipViewModal}\n    </>\n  );\n};\n","import React, { useEffect, useState } from 'react';\nimport {\n  Heading,\n  Table,\n  Tbody,\n  Td,\n  Th,\n  Thead,\n  Tr,\n  VStack,\n  Input,\n  Text,\n} from '@chakra-ui/react';\nimport { OutsideExpRelation, OutsideExpRelationWithState } from './type';\nimport { Placeholder } from './Placeholder';\nimport produce from 'immer';\n\ntype Props = {\n  outsideExpRelations: OutsideExpRelation[];\n  onChange: (value: OutsideExpRelationWithState[]) => void;\n};\n\nexport const ExtractModuleStateForm: React.FC<Props> = ({\n  outsideExpRelations,\n  onChange,\n}) => {\n  const [value, setValue] = useState<OutsideExpRelationWithState[]>([]);\n\n  useEffect(() => {\n    const newValue = outsideExpRelations.map(r => {\n      return {\n        ...r,\n        stateName: `${r.relyOn}${r.valuePath}`,\n      };\n    });\n    setValue(newValue);\n  }, [outsideExpRelations]);\n\n  useEffect(() => {\n    onChange(value);\n  }, [onChange, value]);\n\n  let content = (\n    <Placeholder text={`No outside component uses in-module components' state.`} />\n  );\n  if (outsideExpRelations.length) {\n    content = (\n      <Table\n        size=\"sm\"\n        border=\"1px solid\"\n        borderColor=\"gray.100\"\n        style={{\n          tableLayout: 'fixed',\n        }}\n      >\n        <Thead>\n          <Tr>\n            <Th>Component</Th>\n            <Th>Key</Th>\n            <Th>Expression</Th>\n            <Th>RawExp</Th>\n            <Th>StateName</Th>\n          </Tr>\n        </Thead>\n        <Tbody>\n          {value.map((d, i) => {\n            const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n              const newValue = produce(value, draft => {\n                draft[i].stateName = e.target.value;\n                return draft;\n              });\n              setValue(newValue);\n            };\n            return (\n              <Tr key={i}>\n                <Td>\n                  <Text color=\"blue.500\">{d.componentId}</Text>\n                </Td>\n                <Td>{d.key}</Td>\n                <Td>{d.exp}</Td>\n                <Td>{`${d.relyOn}.${d.valuePath}`}</Td>\n                <Td>\n                  <Input size=\"sm\" value={d.stateName} onChange={onChange} />\n                </Td>\n              </Tr>\n            );\n          })}\n        </Tbody>\n      </Table>\n    );\n  }\n\n  return (\n    <VStack width=\"full\" alignItems=\"start\">\n      <Heading size=\"md\">Module State</Heading>\n      <Text>\n        {`These outside components used in-module components' state.\n        You have to give these expression a new name which will become the state exposed by module.`}\n      </Text>\n      {content}\n    </VStack>\n  );\n};\n","import React, { useCallback } from 'react';\nimport {\n  Heading,\n  Table,\n  Tbody,\n  Td,\n  Th,\n  Thead,\n  Tr,\n  VStack,\n  Link,\n  Text,\n} from '@chakra-ui/react';\nimport { EditorServices } from '../../types';\nimport { InsideMethodRelation } from './type';\nimport { Placeholder } from './Placeholder';\n\ntype Props = {\n  methodRelations: InsideMethodRelation[];\n  services: EditorServices;\n};\n\nexport const ExtractModuleEventForm: React.FC<Props> = ({\n  methodRelations,\n  services,\n}) => {\n  const { editorStore } = services;\n\n  const idLink = useCallback(\n    (id: string) => {\n      return (\n        <Link\n          size=\"sm\"\n          onClick={() => {\n            editorStore.setSelectedComponentId(id);\n          }}\n        >\n          {id}\n        </Link>\n      );\n    },\n    [editorStore]\n  );\n\n  let content = (\n    <Placeholder text={`No event handler calls outside components' method.`} />\n  );\n\n  if (methodRelations.length) {\n    content = (\n      <Table\n        size=\"sm\"\n        border=\"1px solid\"\n        borderColor=\"gray.100\"\n        style={{\n          tableLayout: 'fixed',\n        }}\n      >\n        <Thead>\n          <Tr>\n            <Th>Source</Th>\n            <Th>Event</Th>\n            <Th>Target</Th>\n            <Th>Method</Th>\n            <Th>Module Event Name</Th>\n          </Tr>\n        </Thead>\n        <Tbody>\n          {methodRelations.map((d, i) => {\n            return (\n              <Tr key={i}>\n                <Td>\n                  <Text color=\"blue.500\">{d.source}</Text>\n                </Td>\n                <Td>{d.event}</Td>\n                <Td>{idLink(d.target)}</Td>\n                <Td>{d.method}</Td>\n                <Td fontWeight=\"bold\">{d.source + d.event}</Td>\n              </Tr>\n            );\n          })}\n        </Tbody>\n      </Table>\n    );\n  }\n\n  return (\n    <VStack width=\"full\" alignItems=\"start\">\n      <Heading size=\"md\">Module Events</Heading>\n      <Text>\n        {`These components' event handlers call outside components' methods.\n        These events will be convert automatically to module's events and exposed to outside components.\n        You don't have to do anything.`}\n      </Text>\n      {content}\n    </VStack>\n  );\n};\n","import React, { useEffect, useState } from 'react';\nimport {\n  Button,\n  FormControl,\n  FormLabel,\n  Input,\n  VStack,\n  IconButton,\n  HStack,\n  FormErrorMessage,\n} from '@chakra-ui/react';\nimport { RecordEditor } from '@sunmao-ui/editor-sdk';\nimport { ModuleMethodSpec } from '@sunmao-ui/core';\nimport { useFormik } from 'formik';\nimport { observer } from 'mobx-react-lite';\nimport { EditorServices } from '../../../types';\nimport { JSONSchema7Object } from 'json-schema';\nimport { CloseIcon } from '@chakra-ui/icons';\nimport produce from 'immer';\nimport { CodeEditor } from '../../CodeEditor';\nimport { css } from '@emotion/css';\n\nexport type ModuleMetaDataFormData = {\n  name: string;\n  version: string;\n  stateMap: Record<string, string>;\n  events: string[];\n  methods: ModuleMethodSpec[];\n  exampleProperties: JSONSchema7Object;\n};\n\ntype ModuleMetaDataFormProps = {\n  initData: ModuleMetaDataFormData;\n  services: EditorServices;\n  onSubmit?: (value: ModuleMetaDataFormData) => void;\n  disabled?: boolean;\n};\n\nconst genEventsName = (events: string[]) => {\n  let count = events.length;\n  let name = `event${count}`;\n\n  while (events.includes(name)) {\n    name = `event${++count}`;\n  }\n\n  return `event${count}`;\n};\n\nconst EventInput: React.FC<{\n  name: string;\n  events: string[];\n  index: number;\n  onChange: (value: string) => void;\n}> = ({ name: defaultName, onChange, events, index }) => {\n  const [name, setName] = useState(defaultName);\n  const [isRepeated, setIsRepeated] = useState(false);\n\n  useEffect(() => {\n    setName(defaultName);\n  }, [defaultName]);\n\n  return (\n    <FormControl w=\"33.33%\" isInvalid={isRepeated}>\n      <Input\n        name=\"name\"\n        onChange={e => {\n          setName(e.target.value);\n        }}\n        onBlur={() => {\n          const newEvents = [...events];\n          newEvents.splice(index, 1);\n          if (newEvents.find(eventName => eventName === name)) {\n            setIsRepeated(true);\n            return;\n          }\n          setIsRepeated(false);\n          onChange(name);\n        }}\n        value={name}\n      />\n      <FormErrorMessage mt=\"0\" pl=\"10px\">\n        event name already exists\n      </FormErrorMessage>\n    </FormControl>\n  );\n};\n\nexport const ModuleMetaDataForm: React.FC<ModuleMetaDataFormProps> = observer(\n  ({ initData, services, onSubmit: onSubmitForm }) => {\n    const onSubmit = (value: ModuleMetaDataFormData) => {\n      onSubmitForm?.(value);\n    };\n    const formik = useFormik({\n      initialValues: initData,\n      onSubmit,\n    });\n\n    const isModuleVersionError = formik.values.version === '';\n    const isModuleNameError = formik.values.name === '';\n    return (\n      <VStack w=\"full\" spacing=\"5\">\n        <HStack w=\"full\" align=\"normal\">\n          <FormControl isInvalid={isModuleVersionError}>\n            <HStack align=\"normal\">\n              <FormLabel>Version</FormLabel>\n              <VStack w=\"full\" align=\"normal\">\n                <Input\n                  name=\"version\"\n                  value={formik.values.version}\n                  onChange={formik.handleChange}\n                  onBlur={() => {\n                    if (formik.values.version && formik.values.name) {\n                      formik.submitForm();\n                    }\n                  }}\n                />\n                {isModuleVersionError && (\n                  <FormErrorMessage>Module version can not be empty</FormErrorMessage>\n                )}\n              </VStack>\n            </HStack>\n          </FormControl>\n          <FormControl isInvalid={isModuleNameError}>\n            <HStack align=\"normal\">\n              <FormLabel>Name</FormLabel>\n              <VStack w=\"full\" align=\"normal\">\n                <Input\n                  name=\"name\"\n                  value={formik.values.name}\n                  onChange={formik.handleChange}\n                  onBlur={() => {\n                    if (formik.values.version && formik.values.name) {\n                      formik.submitForm();\n                    }\n                  }}\n                />\n                {isModuleNameError && (\n                  <FormErrorMessage>Module name can not be empty</FormErrorMessage>\n                )}\n              </VStack>\n            </HStack>\n          </FormControl>\n        </HStack>\n        <FormControl>\n          <FormLabel>Module StateMap</FormLabel>\n          <RecordEditor\n            services={services}\n            value={formik.values.stateMap}\n            onChange={json => {\n              formik.setFieldValue('stateMap', json);\n              formik.submitForm();\n            }}\n          />\n        </FormControl>\n        <FormControl>\n          <FormLabel>Example Properties</FormLabel>\n          <RecordEditor\n            services={services}\n            value={formik.values.exampleProperties}\n            onChange={json => {\n              formik.setFieldValue('exampleProperties', json);\n              formik.submitForm();\n            }}\n          />\n        </FormControl>\n        <FormControl>\n          <FormLabel>Events</FormLabel>\n          {formik.values.events.map((eventName, i) => {\n            return (\n              <HStack m=\"10px 0 10px 0\" alignItems=\"normal\" key={eventName}>\n                <EventInput\n                  events={formik.values.events}\n                  index={i}\n                  onChange={newName => {\n                    const newEvents = produce(formik.values.events, draft => {\n                      draft[i] = newName;\n                    });\n                    formik.setFieldValue('events', newEvents);\n                    formik.submitForm();\n                  }}\n                  name={eventName}\n                />\n                <IconButton\n                  aria-label=\"remove row\"\n                  icon={<CloseIcon />}\n                  size=\"xs\"\n                  onClick={() => {\n                    const newEvents = produce(formik.values.events, draft => {\n                      draft.splice(i, 1);\n                    });\n                    formik.setFieldValue('events', newEvents);\n                    formik.submitForm();\n                  }}\n                  variant=\"ghost\"\n                />\n              </HStack>\n            );\n          })}\n          <Button\n            onClick={() => {\n              const newEvents = produce(formik.values.events, draft => {\n                draft.push(genEventsName(draft));\n              });\n              formik.setFieldValue('events', newEvents);\n              formik.submitForm();\n            }}\n            size=\"xs\"\n            alignSelf=\"start\"\n          >\n            + Add\n          </Button>\n        </FormControl>\n        <FormControl>\n          <FormLabel>Methods</FormLabel>\n          <CodeEditor\n            className={css`\n              width: 100%;\n              height: 120px;\n            `}\n            mode=\"json\"\n            defaultCode={JSON.stringify(formik.values.methods)}\n            onBlur={v => {\n              try {\n                const newMethods = JSON.parse(v);\n                formik.setFieldValue('methods', newMethods);\n                formik.submitForm();\n              } catch {}\n            }}\n            needRerenderAfterMount\n          />\n        </FormControl>\n      </VStack>\n    );\n  }\n);\n","import React, { useEffect, useMemo, useState } from 'react';\nimport { Box, Input } from '@chakra-ui/react';\nimport { css } from '@emotion/css';\nimport { JSONTree } from 'react-json-tree';\nimport { pickBy } from 'lodash';\nimport { watch } from '@sunmao-ui/runtime';\nimport ErrorBoundary from '../ErrorBoundary';\nimport { EditorServices } from '../../types';\nimport { observer } from 'mobx-react-lite';\n\nconst theme = {\n  base0A: '#fded02',\n  base0B: '#01a252',\n  base0C: '#b5e4f4',\n  base0D: '#01a0e4',\n  base0E: '#a16a94',\n  base0F: '#cdab53',\n  base00: '#090300',\n  base01: '#3a3432',\n  base02: '#4a4543',\n  base03: '#5c5855',\n  base04: '#807d7c',\n  base05: '#a5a2a2',\n  base06: '#d6d5d4',\n  base07: '#f7f7f7',\n  base08: '#db2d20',\n  base09: '#e8bbd0',\n};\n\nconst style = css`\n  ul {\n    padding-left: 0.25em !important;\n    flex: 1;\n    margin: 0 !important;\n    background-color: white !important;\n  }\n`;\n\ntype Props = {\n  store: Record<string, unknown>;\n  services: EditorServices;\n};\n\nexport const StateViewer: React.FC<Props> = observer(({ store, services }) => {\n  const { viewStateComponentId, setViewStateComponentId } = services.editorStore;\n  const [filterText, setFilterText] = useState('');\n  const [refreshFlag, setRefreshFlag] = useState(0);\n  const data = useMemo(() => {\n    return pickBy(store, (_v, key) => {\n      return filterText ? key.includes(filterText) : true;\n    });\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [store, filterText, refreshFlag]);\n\n  useEffect(() => {\n    const stop = watch(store, () => {\n      setRefreshFlag(v => v + 1);\n    });\n\n    return stop;\n  }, [store]);\n\n  useEffect(() => {\n    if (viewStateComponentId) {\n      setFilterText(viewStateComponentId);\n      setViewStateComponentId('');\n    }\n  }, [setViewStateComponentId, viewStateComponentId]);\n\n  return (\n    <ErrorBoundary>\n      <Box height=\"100%\" className={style} display=\"flex\" flexDirection=\"column\">\n        <Input\n          placeholder=\"filter the states\"\n          value={filterText}\n          onChange={evt => setFilterText(evt.currentTarget.value)}\n        />\n        <JSONTree\n          data={data}\n          theme={theme}\n          hideRoot\n          sortObjectKeys\n          shouldExpandNode={keyPath => {\n            return keyPath[0] === filterText;\n          }}\n        />\n      </Box>\n    </ErrorBoundary>\n  );\n});\n","import { css } from '@emotion/css';\nimport React from 'react';\n\ntype Props = {\n  onError?: (error: Error | null) => void;\n};\n\nconst ErrorStyle = css`\n  white-space: pre-line;\n  font-family: monospace;\n  color: red;\n`;\nclass ErrorBoundary extends React.Component<Props, { error: Error | null }> {\n  constructor(props: Props) {\n    super(props);\n    this.state = { error: null };\n  }\n\n  static getDerivedStateFromError(error: Error) {\n    return { error };\n  }\n\n  componentDidMount() {\n    this.props.onError?.(null);\n  }\n\n  componentDidCatch(error: Error) {\n    this.props.onError?.(error);\n  }\n\n  render() {\n    if (this.state.error) {\n      return <div className={ErrorStyle}>{this.state.error.stack}</div>;\n    }\n\n    return this.props.children;\n  }\n}\n\nexport default ErrorBoundary;\n","import React, { useEffect, useRef, useState } from 'react';\nimport { UnControlled as CodeMirror } from 'react-codemirror2';\nimport 'codemirror/mode/css/css';\nimport 'codemirror/addon/fold/brace-fold';\nimport 'codemirror/addon/fold/foldgutter';\nimport 'codemirror/addon/display/autorefresh';\nimport type { ModeSpec, ModeSpecOptions } from 'codemirror';\n\n// Result\nimport 'codemirror/mode/javascript/javascript';\nimport { css, cx } from '@emotion/css';\n\nexport const CodeEditor: React.FC<{\n  defaultCode: string;\n  className?: string;\n  mode?: string | ModeSpec<ModeSpecOptions>;\n  onChange?: (v: string) => void;\n  onBlur?: (v: string) => void;\n  needRerenderAfterMount?: boolean;\n  readOnly?: boolean;\n}> = ({\n  defaultCode,\n  mode,\n  needRerenderAfterMount,\n  className,\n  onChange,\n  onBlur,\n  readOnly,\n}) => {\n  const valueRef = useRef(defaultCode);\n  const [rerenderFlag, setRerenderFlag] = useState(0);\n\n  // react-codemirror2 only updates onBlur in componentDidMount\n  // This causes the cssProperties in the `props.onBlur` closure context\n  // to always be the same as when the component was mounted, thus overwriting the latest cssProperties\n  // So subsequent onBlur triggers will use ref to get the latest props.onBlur to get the new closure context\n  // see https://github.com/scniro/react-codemirror2/blob/master/src/index.tsx#L204\n  // https://github.com/scniro/react-codemirror2/blob/master/src/index.tsx#L756\n  // https://github.com/scniro/react-codemirror2/issues/142\n  const blurRef = useRef<((v: string) => void) | undefined>(undefined);\n  blurRef.current = onBlur;\n\n  const style = css`\n    .CodeMirror {\n      height: 100%;\n    }\n  `;\n\n  // StyleTraitForm has animation which will affect the position calculation of CodeMirror.\n  // So it need a force rerender to correct the position of CodeMirror after mount.\n  useEffect(() => {\n    if (needRerenderAfterMount) {\n      requestIdleCallback(() => {\n        setRerenderFlag(1);\n      });\n    }\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n\n  return (\n    <CodeMirror\n      key={rerenderFlag}\n      className={cx([style, className])}\n      value={defaultCode}\n      onChange={(_x, _y, v: string) => {\n        valueRef.current = v;\n        onChange?.(v);\n      }}\n      onBlur={() => {\n        blurRef.current?.(valueRef.current);\n      }}\n      options={{\n        mode: mode || 'css',\n        foldGutter: true,\n        lineWrapping: true,\n        lineNumbers: false,\n        gutters: ['CodeMirror-linenumbers', 'CodeMirror-foldgutter'],\n        foldOptions: {\n          widget: () => {\n            return '\\u002E\\u002E\\u002E';\n          },\n        },\n        theme: 'ayu-mirage',\n        readOnly,\n      }}\n    />\n  );\n};\n","import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport {\n  VStack,\n  Button,\n  HStack,\n  Box,\n  ButtonGroup,\n  Spacer,\n  Heading,\n  Text,\n} from '@chakra-ui/react';\nimport { EventHandlerSpec, GLOBAL_MODULE_ID } from '@sunmao-ui/shared';\nimport { Static } from '@sinclair/typebox';\nimport { set, uniq } from 'lodash';\nimport { EditorServices } from '../../types';\nimport { ComponentId } from '../../AppModel/IAppModel';\nimport {\n  RefTreatmentMap,\n  OutsideExpRelationWithState,\n  RefTreatment,\n  InsideExpRelation,\n  InsideMethodRelation,\n} from './type';\nimport { ExtractModuleStep } from './ExtractModuleStep';\nimport { ExtractModulePropertyForm } from './ExtractModulePropertyForm';\nimport { ExtractModuleStateForm } from './ExtractModuleStateForm';\nimport { ExtractModuleEventForm } from './ExtractModuleEventForm';\nimport {\n  ModuleMetaDataForm,\n  ModuleMetaDataFormData,\n} from '../Explorer/ExplorerForm/ModuleMetaDataForm';\nimport { toJS } from 'mobx';\nimport { json2JsonSchema } from '@sunmao-ui/editor-sdk';\nimport { genOperation } from '../../operations';\nimport { getInsideRelations, getOutsideExpRelations } from './utils';\n\ntype Props = {\n  componentId: string;\n  services: EditorServices;\n  onClose: () => void;\n};\n\ntype InsideRelations = {\n  exp: InsideExpRelation[];\n  method: InsideMethodRelation[];\n};\n\nexport const ExtractModuleView: React.FC<Props> = ({\n  componentId,\n  services,\n  onClose,\n}) => {\n  const { appModelManager } = services;\n  const { appModel } = appModelManager;\n  const refTreatmentMap = useRef<RefTreatmentMap>({});\n  const outsideExpRelationsValueRef = useRef<OutsideExpRelationWithState[]>([]);\n  const [activeIndex, setActiveIndex] = useState(0);\n  const [genModuleResult, serGenModuleResult] = useState<\n    ReturnType<typeof genModule> | undefined\n  >();\n  const [moduleFormInitData, setModuleFormInitData] = useState<\n    ModuleMetaDataFormData | undefined\n  >();\n  const moduleFormValueRef = useRef<ModuleMetaDataFormData | undefined>();\n\n  const { insideExpRelations, methodRelations, outsideExpRelations } = useMemo(() => {\n    const root = appModel.getComponentById(componentId as ComponentId)!;\n    const moduleComponents = root.allComponents;\n    const insideRelations = moduleComponents.reduce<InsideRelations>(\n      (res, c) => {\n        const { expressionRelations, methodRelations } = getInsideRelations(\n          c,\n          moduleComponents\n        );\n        res.exp = res.exp.concat(expressionRelations);\n        res.method = res.method.concat(methodRelations);\n        return res;\n      },\n      { exp: [], method: [] }\n    );\n    const outsideExpRelations = getOutsideExpRelations(appModel.allComponents, root);\n    return {\n      insideExpRelations: insideRelations.exp,\n      methodRelations: insideRelations.method,\n      outsideExpRelations,\n    };\n  }, [appModel, componentId]);\n\n  const genModule = useCallback(() => {\n    const exampleProperties: Record<string, string> = {};\n    const moduleContainerProperties: Record<string, string> = {};\n    let toMoveComponentIds: string[] = [];\n    let toDeleteComponentIds: string[] = [];\n    insideExpRelations.forEach(relation => {\n      switch (refTreatmentMap.current[relation.componentId]) {\n        case RefTreatment.move:\n          toMoveComponentIds.push(relation.componentId);\n          toDeleteComponentIds.push(relation.componentId);\n          break;\n        case RefTreatment.keep:\n          moduleContainerProperties[relation.componentId] = `{{${relation.componentId}}}`;\n          const value = toJS(services.stateManager.store[relation.componentId]);\n          if (typeof value === 'string') {\n            exampleProperties[relation.componentId] = value;\n          } else {\n            // save value as expression\n            exampleProperties[relation.componentId] = `{{${JSON.stringify(value)}}}`;\n          }\n          break;\n        case RefTreatment.duplicate:\n          toMoveComponentIds.push(relation.componentId);\n          break;\n      }\n    });\n\n    toMoveComponentIds = uniq(toMoveComponentIds);\n    toDeleteComponentIds = uniq(toDeleteComponentIds);\n\n    const root = services.appModelManager.appModel\n      .getComponentById(componentId as ComponentId)!\n      .clone();\n    const newModuleContainerId = `${componentId}__module`;\n    const newModuleId = `${componentId}Module`;\n    // remove root slot\n    root.removeSlotTrait();\n\n    // covert in-module components to schema\n    const eventSpec: string[] = [];\n    const moduleComponentsSchema = root?.allComponents.map(c => {\n      const eventTrait = c.traits.find(t => t.type === 'core/v1/event');\n      // conver in-module components' event handlers\n      if (eventTrait) {\n        const cache: Record<string, boolean> = {};\n        const handlers: Static<typeof EventHandlerSpec>[] = [];\n        eventTrait?.rawProperties.handlers.forEach(\n          (h: Static<typeof EventHandlerSpec>) => {\n            const newEventName = `${c.id}${h.type}`;\n            const hasRelation = methodRelations.find(r => {\n              return (\n                r.source === c.id && r.event === h.type && r.target === h.componentId\n              );\n            });\n            if (hasRelation) {\n              // if component has another handler emit the same event, don't emit it again\n              if (cache[newEventName]) {\n                return;\n              }\n              // emit new $module event\n              cache[newEventName] = true;\n              eventSpec.push(newEventName);\n              handlers.push({\n                type: h.type,\n                componentId: GLOBAL_MODULE_ID,\n                method: {\n                  name: newEventName,\n                  parameters: {\n                    moduleId: '{{$moduleId}}',\n                  },\n                },\n                disabled: false,\n                wait: { type: 'delay', time: 0 },\n              });\n            } else {\n              handlers.push(h);\n            }\n          }\n        );\n        eventTrait.updateProperty('handlers', handlers);\n      }\n      return c.toSchema();\n    });\n\n    // add moved and duplicated components\n    if (toMoveComponentIds.length) {\n      toMoveComponentIds.forEach(id => {\n        const comp = services.appModelManager.appModel.getComponentById(\n          id as ComponentId\n        )!;\n        moduleComponentsSchema.push(comp.toSchema());\n      });\n    }\n\n    // generate event handlers for module container\n    const moduleHandlers = methodRelations.map(r => {\n      const { handler } = r;\n      return {\n        ...handler,\n        type: `${r.source}${r.event}`,\n      };\n    });\n\n    // generate StateMap\n    const stateMap: Record<string, string> = {};\n    const outsideComponentNewProperties: Record<string, any> = {};\n    type TraitNewProperties = {\n      componentId: string;\n      traitIndex: number;\n      properties: Record<string, any>;\n    };\n    const outsideTraitNewProperties: TraitNewProperties[] = [];\n    outsideExpRelationsValueRef.current.forEach(r => {\n      if (r.stateName) {\n        const origin = `${r.relyOn}.${r.valuePath}`;\n        stateMap[r.stateName] = origin;\n        // replace ref with new state name in expressions\n        const newExp = r.exp.replaceAll(origin, `${newModuleId}.${r.stateName}`);\n        const c = services.appModelManager.appModel.getComponentById(\n          r.componentId as ComponentId\n        )!;\n        const fieldKey = r.key.startsWith('.') ? r.key.slice(1) : r.key;\n        if (r.traitType) {\n          c.traits.forEach((t, i) => {\n            const newProperties = set(t.properties.rawValue, fieldKey, newExp);\n            if (t.type === r.traitType) {\n              outsideTraitNewProperties.push({\n                componentId: r.componentId,\n                traitIndex: i,\n                properties: newProperties,\n              });\n            }\n          });\n        } else {\n          const fieldKey = r.key.startsWith('.') ? r.key.slice(1) : r.key;\n          const newProperties = set(c.properties.rawValue, fieldKey, newExp);\n          outsideComponentNewProperties[r.componentId] = newProperties;\n        }\n      }\n    });\n\n    return {\n      exampleProperties,\n      moduleContainerProperties,\n      eventSpec,\n      toMoveComponentIds,\n      toDeleteComponentIds,\n      methodRelations,\n      moduleComponentsSchema,\n      moduleHandlers,\n      stateMap,\n      newModuleContainerId,\n      newModuleId,\n      outsideComponentNewProperties,\n      outsideTraitNewProperties,\n      moduleRootId: componentId,\n    };\n  }, [\n    componentId,\n    insideExpRelations,\n    methodRelations,\n    services.appModelManager.appModel,\n    services.stateManager.store,\n  ]);\n\n  const onExtract = () => {\n    if (!genModuleResult || !moduleFormValueRef.current) return;\n    services.editorStore.appStorage.createModule({\n      components: genModuleResult.moduleComponentsSchema,\n      propertySpec: json2JsonSchema(genModuleResult.exampleProperties),\n      exampleProperties: genModuleResult.exampleProperties,\n      events: genModuleResult.eventSpec,\n      moduleVersion: moduleFormValueRef.current.version,\n      moduleName: moduleFormValueRef.current.name,\n      stateMap: genModuleResult.stateMap,\n    });\n\n    services.eventBus.send(\n      'operation',\n      genOperation(services.registry, 'extractModule', {\n        moduleContainerId: genModuleResult.newModuleContainerId,\n        moduleContainerProperties: genModuleResult.moduleContainerProperties,\n        moduleId: genModuleResult.newModuleId,\n        moduleRootId: genModuleResult.moduleRootId,\n        moduleType: `${moduleFormValueRef.current.version}/${moduleFormValueRef.current.name}`,\n        moduleHandlers: genModuleResult.moduleHandlers,\n        outsideComponentNewProperties: genModuleResult.outsideComponentNewProperties,\n        outsideTraitNewProperties: genModuleResult.outsideTraitNewProperties,\n        toDeleteComponentIds: genModuleResult.toDeleteComponentIds,\n      })\n    );\n    onClose();\n  };\n\n  // generate module spec for preview\n  useEffect(() => {\n    if (activeIndex === 3) {\n      const result = genModule();\n      serGenModuleResult(result);\n      const moduleFormData = {\n        name: componentId,\n        version: 'custom/v1',\n        stateMap: result.stateMap,\n        events: result.eventSpec,\n        exampleProperties: result.exampleProperties,\n        methods: [],\n      };\n      setModuleFormInitData(moduleFormData);\n      moduleFormValueRef.current = moduleFormData;\n    }\n  }, [activeIndex, componentId, genModule]);\n\n  return (\n    <HStack spacing=\"12\" height=\"full\" alignItems=\"start\">\n      <ExtractModuleStep activeIndex={activeIndex} />\n      <VStack height=\"full\" width=\"full\" alignItems=\"end\">\n        <Box width=\"full\" overflow=\"auto\">\n          <Box width=\"full\" display={activeIndex === 0 ? 'block' : 'none'}>\n            <ExtractModulePropertyForm\n              insideExpRelations={insideExpRelations}\n              onChange={val => (refTreatmentMap.current = val)}\n              services={services}\n            />\n          </Box>\n          <Box width=\"full\" display={activeIndex === 1 ? 'block' : 'none'}>\n            <ExtractModuleStateForm\n              outsideExpRelations={outsideExpRelations}\n              onChange={v => {\n                outsideExpRelationsValueRef.current = v;\n              }}\n            />\n          </Box>\n          <Box width=\"full\" display={activeIndex === 2 ? 'block' : 'none'}>\n            <ExtractModuleEventForm\n              methodRelations={methodRelations}\n              services={services}\n            />\n          </Box>\n          <VStack width=\"full\" display={activeIndex === 3 ? 'block' : 'none'}>\n            <Heading size=\"md\">Preview Module Spec</Heading>\n            <Text>\n              {`The Spec has generated automatically, you don't need to change anything except version and name.`}\n            </Text>\n            {activeIndex === 3 && moduleFormInitData ? (\n              <ModuleMetaDataForm\n                services={services}\n                initData={moduleFormInitData}\n                onSubmit={value => (moduleFormValueRef.current = value)}\n              />\n            ) : undefined}\n          </VStack>\n        </Box>\n        <Spacer />\n        <ButtonGroup flex=\"0 0\">\n          {activeIndex > 0 ? (\n            <Button variant=\"outline\" onClick={() => setActiveIndex(v => v - 1)}>\n              Prev\n            </Button>\n          ) : undefined}\n          {activeIndex < 3 ? (\n            <Button colorScheme=\"blue\" onClick={() => setActiveIndex(v => v + 1)}>\n              Next\n            </Button>\n          ) : undefined}\n          {activeIndex === 3 ? (\n            <Button colorScheme=\"blue\" onClick={onExtract}>\n              Extract\n            </Button>\n          ) : undefined}\n        </ButtonGroup>\n      </VStack>\n    </HStack>\n  );\n};\n","import {\n  CoreTraitName,\n  CORE_VERSION,\n  EventHandlerSpec,\n  ExpressionKeywords,\n} from '@sunmao-ui/shared';\nimport { Static } from '@sinclair/typebox';\nimport { IComponentModel, IFieldModel, ComponentId } from '../../AppModel/IAppModel';\nimport { OutsideExpRelation, InsideExpRelation, InsideMethodRelation } from './type';\n\nexport function getOutsideExpRelations(\n  allComponents: IComponentModel[],\n  moduleRoot: IComponentModel\n): OutsideExpRelation[] {\n  const res: OutsideExpRelation[] = [];\n  const clonedRoot = moduleRoot.clone();\n  const ids = clonedRoot.allComponents.map(c => c.id);\n  allComponents.forEach(c => {\n    if (clonedRoot.appModel.getComponentById(c.id)) {\n      // component is in module, ignore.\n      return;\n    }\n    const handler = (field: IFieldModel, key: string, traitType?: string) => {\n      if (field.isDynamic) {\n        const relyRefs = Object.keys(field.refComponentInfos).filter(refId =>\n          ids.includes(refId as ComponentId)\n        );\n        relyRefs.forEach(refId => {\n          res.push({\n            componentId: c.id,\n            traitType,\n            exp: field.getValue() as string,\n            key,\n            valuePath:\n              field.refComponentInfos[refId as ComponentId].refProperties.slice(-1)[0],\n            relyOn: refId,\n          });\n        });\n      }\n    };\n    // traverse all the expressions of all outisde components and traits\n    c.properties.traverse((field, key) => {\n      handler(field, key);\n      c.traits.forEach(t => {\n        t.properties.traverse((field, key) => {\n          handler(field, key, t.type);\n        });\n      });\n    });\n  });\n  return res;\n}\n\nexport function getInsideRelations(\n  component: IComponentModel,\n  moduleComponents: IComponentModel[]\n) {\n  const expressionRelations: InsideExpRelation[] = [];\n  const methodRelations: InsideMethodRelation[] = [];\n  const ids = moduleComponents.map(c => c.id) as string[];\n\n  const handler = (field: IFieldModel, key: string, traitType?: string) => {\n    if (field.isDynamic) {\n      const usedIds = Object.keys(field.refComponentInfos);\n      usedIds.forEach(usedId => {\n        // ignore global vraiable and sunmao keywords\n        if (\n          !ids.includes(usedId) &&\n          !(usedId in window) &&\n          !ExpressionKeywords.includes(usedId)\n        ) {\n          expressionRelations.push({\n            traitType: traitType,\n            source: component.id,\n            componentId: usedId,\n            exp: field.rawValue,\n            key: key,\n          });\n        }\n      });\n    }\n  };\n\n  component.properties.traverse((field, key) => {\n    handler(field, key);\n  });\n\n  component.traits.forEach(t => {\n    t.properties.traverse((field, key) => {\n      handler(field, key, t.type);\n    });\n\n    // check event traits, see if component call outside methods\n    if (t.type === `${CORE_VERSION}/${CoreTraitName.Event}`) {\n      t.rawProperties.handlers.forEach((h: Static<typeof EventHandlerSpec>) => {\n        if (!ids.includes(h.componentId)) {\n          methodRelations.push({\n            source: component.id,\n            event: h.type,\n            target: h.componentId,\n            method: h.method.name,\n            handler: h,\n          });\n        }\n      });\n    }\n  });\n\n  return { expressionRelations, methodRelations };\n}\n","import React from 'react';\nimport {\n  Modal,\n  ModalOverlay,\n  ModalHeader,\n  ModalContent,\n  ModalCloseButton,\n  ModalBody,\n  Text,\n} from '@chakra-ui/react';\nimport { EditorServices } from '../../types';\nimport { ExtractModuleView } from './ExtractModuleView';\n\ntype Props = {\n  componentId: string;\n  onClose: () => void;\n  services: EditorServices;\n};\n\nexport const ExtractModuleModal: React.FC<Props> = ({\n  componentId,\n  onClose,\n  services,\n}) => {\n  return (\n    <Modal onClose={onClose} isOpen>\n      <ModalOverlay />\n      <ModalContent maxWidth=\"60vw\">\n        <ModalHeader>\n          Extract component{' '}\n          <Text display=\"inline\" color=\"red.500\">\n            {componentId}\n          </Text>{' '}\n          to module\n        </ModalHeader>\n        <ModalCloseButton />\n        <ModalBody flex=\"1 1 auto\" height=\"75vh\" alignItems=\"start\" overflow=\"auto\">\n          <ExtractModuleView\n            componentId={componentId}\n            services={services}\n            onClose={onClose}\n          />\n        </ModalBody>\n      </ModalContent>\n    </Modal>\n  );\n};\n","export function copyToClipboard(text: string) {\n  const textarea = document.createElement('textarea');\n\n  textarea.textContent = text;\n  textarea.style.position = 'fixed';\n  document.body.appendChild(textarea);\n  textarea.select();\n\n  try {\n    return document.execCommand('copy');\n  } catch (ex) {\n    return false;\n  } finally {\n    document.body.removeChild(textarea);\n  }\n}\n","import React, { useCallback, useState } from 'react';\nimport {\n  Modal,\n  ModalOverlay,\n  ModalContent,\n  ModalHeader,\n  ModalCloseButton,\n  ModalBody,\n  ModalFooter,\n  Button,\n  useDisclosure,\n} from '@chakra-ui/react';\n\nexport type OpenOptions = {\n  title?: string;\n  message?: string;\n};\n\nfunction useModal() {\n  const { isOpen, onOpen, onClose } = useDisclosure();\n  const [options, setOptions] = useState<Partial<OpenOptions>>({});\n  const { title, message } = options;\n  const open = useCallback(\n    (options: OpenOptions) => {\n      setOptions(options);\n      onOpen();\n    },\n    [onOpen]\n  );\n\n  const modal = (\n    <Modal onClose={onClose} size=\"md\" isOpen={isOpen}>\n      <ModalOverlay />\n      <ModalContent>\n        {title ? <ModalHeader>{title}</ModalHeader> : null}\n        <ModalCloseButton />\n        <ModalBody>{message}</ModalBody>\n        <ModalFooter>\n          <Button onClick={onClose}>Close</Button>\n        </ModalFooter>\n      </ModalContent>\n    </Modal>\n  );\n\n  return {\n    modal,\n    open,\n    close: onClose,\n  };\n}\n\nexport default useModal;\n","import { ComponentSchema } from '@sunmao-ui/core';\nimport { CORE_VERSION, CoreTraitName } from '@sunmao-ui/shared';\n\nexport type ChildrenMap = Map<string, SlotsMap>;\ntype SlotsMap = Map<string, ComponentSchema[]>;\n\nexport function resolveApplicationComponents(components: ComponentSchema[]): {\n  topLevelComponents: ComponentSchema[];\n  childrenMap: ChildrenMap;\n} {\n  const topLevelComponents: ComponentSchema[] = [];\n  const childrenMap: ChildrenMap = new Map();\n  components.forEach(c => {\n    const slotTrait = c.traits.find(\n      t =>\n        t.type === `${CORE_VERSION}/${CoreTraitName.Slot}` ||\n        t.type === `core/v2/${CoreTraitName.Slot}`\n    );\n    if (slotTrait) {\n      const { id: parentId, slot } = slotTrait.properties.container as any;\n      if (!childrenMap.has(parentId)) {\n        childrenMap.set(parentId, new Map());\n      }\n      if (!childrenMap.get(parentId)?.has(slot)) {\n        childrenMap.get(parentId)?.set(slot, []);\n      }\n\n      childrenMap.get(parentId)!.get(slot)!.push(c);\n    } else {\n      topLevelComponents.push(c);\n    }\n  });\n  return {\n    topLevelComponents,\n    childrenMap,\n  };\n}\n","import { ComponentSchema } from '@sunmao-ui/core';\nimport { useCallback, useMemo, useState } from 'react';\nimport { EditorStore } from '../../services/EditorStore';\nimport {\n  ChildrenMap,\n  resolveApplicationComponents,\n} from '../../utils/resolveApplicationComponents';\nimport { ComponentNode } from './type';\n\nexport function useStructureTreeState(editorStore: EditorStore) {\n  const [expandedMap, setExpandedMap] = useState<Record<string, boolean>>({});\n  const [draggingId, setDraggingId] = useState('');\n\n  // format components schema to ComponentNode\n  const { nodes, nodesMapCache, childrenMap } = useMemo(() => {\n    const nodes: ComponentNode[] = [];\n    const nodesMapCache: Record<string, ComponentNode> = {};\n    const depthMap: Record<string, number> = {};\n    const resolvedComponents = resolveApplicationComponents(editorStore.uiComponents);\n    const { topLevelComponents, childrenMap } = resolvedComponents;\n\n    topLevelComponents.forEach(c => {\n      const cb = (params: Required<TraverseParams>) => {\n        const notEmptySlots = [];\n        const slots = childrenMap.get(params.root.id);\n        if (slots) {\n          for (const slot of slots.keys()) {\n            if (slots.get(slot)?.length) {\n              notEmptySlots.push(slot);\n            }\n          }\n        }\n        const node = {\n          id: params.root.id,\n          component: params.root,\n          depth: params.depth,\n          parentId: params.parentId,\n          slot: params.slot,\n          parentSlots: params.parentSlots,\n          notEmptySlots,\n        };\n        nodesMapCache[params.root.id] = node;\n        depthMap[params.root.id] = params.depth;\n        nodes.push(node);\n      };\n\n      traverse({\n        childrenMap,\n        root: c,\n        depth: 0,\n        parentId: null,\n        slot: null,\n        parentSlots: [],\n        cb,\n      });\n    });\n\n    return { nodes, nodesMapCache, childrenMap };\n  }, [editorStore.components]);\n\n  const onToggleExpand = useCallback(\n    (id: string) => {\n      setExpandedMap(prevMap => {\n        const nextExpanded = !prevMap[id];\n        if (nextExpanded) {\n          return { ...prevMap, [id]: nextExpanded };\n        }\n        // if collapse, collapse all its children\n        const newExpandedMap = { ...prevMap };\n        traverse({\n          childrenMap,\n          root: nodesMapCache[id].component,\n          cb: params => delete newExpandedMap[params.root.id],\n        });\n        return newExpandedMap;\n      });\n    },\n    [childrenMap, nodesMapCache]\n  );\n\n  // expand all the ancestors of a node\n  const expandNode = useCallback(\n    (id: string) => {\n      setExpandedMap(prevMap => {\n        if (prevMap[id]) return prevMap;\n        const newExpandedMap = { ...prevMap };\n        // don't expand its self\n        let curr: string = nodesMapCache[id]?.parentId || '';\n        while (curr) {\n          newExpandedMap[curr] = true;\n          curr = nodesMapCache[curr]?.parentId || '';\n        }\n        return newExpandedMap;\n      });\n    },\n    [nodesMapCache]\n  );\n\n  // nodes whose parent is expanded\n  const shouldRenderNodes = useMemo(\n    () =>\n      nodes.filter((node: ComponentNode) => {\n        if (!node.parentId) return true;\n        if (expandedMap[node.parentId]) return true;\n        return false;\n      }),\n    [expandedMap, nodes]\n  );\n\n  // nodes that is being dragged or its ancestor is being dragged\n  const undroppableMap = useMemo(() => {\n    const map: Record<string, boolean> = {};\n\n    if (!draggingId) return map;\n\n    traverse({\n      childrenMap,\n      root: nodesMapCache[draggingId].component,\n      cb: params => {\n        map[params.root.id] = true;\n      },\n    });\n    return map;\n  }, [childrenMap, draggingId, nodesMapCache]);\n\n  return {\n    nodes,\n    shouldRenderNodes,\n    expandedMap,\n    onToggleExpand,\n    expandNode,\n    undroppableMap,\n    setDraggingId,\n  };\n}\n\ntype TraverseParams = {\n  childrenMap: ChildrenMap;\n  root: ComponentSchema;\n  depth?: number;\n  parentId?: string | null;\n  slot?: string | null;\n  parentSlots?: string[];\n  cb: (params: Required<TraverseParams>) => void;\n};\n\nfunction traverse(params: TraverseParams) {\n  const {\n    root,\n    depth = 0,\n    parentId = null,\n    slot = null,\n    childrenMap,\n    cb,\n    parentSlots = [],\n  } = params;\n  const safeParams = { childrenMap, root, depth, parentId, slot, cb, parentSlots };\n  cb(safeParams);\n  const slots = childrenMap.get(root.id);\n  if (slots) {\n    for (const key of slots.keys()) {\n      const children = slots.get(key)!;\n      children.forEach(child => {\n        traverse({\n          childrenMap,\n          root: child,\n          depth: depth + 1,\n          parentId: root.id,\n          parentSlots: Array.from(slots.keys()),\n          slot: key,\n          cb,\n        });\n      });\n    }\n  }\n}\n","import {\n  Button,\n  Popover,\n  Checkbox,\n  PopoverContent,\n  chakra,\n  PopoverTrigger,\n  createIcon,\n} from '@chakra-ui/react';\nimport React from 'react';\n\nconst FilterIcon = createIcon({\n  displayName: 'FilterIcon',\n  viewBox: '0 0 24 24',\n  path: [\n    <path\n      key=\"Stroke 1\"\n      id=\"Stroke 1\"\n      d=\"M11.1437 17.8829H4.67114\"\n      stroke=\"#130F26\"\n      strokeWidth=\"1.5\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n    />,\n    <path\n      key=\"Stroke 3\"\n      id=\"Stroke 3\"\n      fillRule=\"evenodd\"\n      clipRule=\"evenodd\"\n      d=\"M15.205 17.8839C15.205 19.9257 15.8859 20.6057 17.9267 20.6057C19.9676 20.6057 20.6485 19.9257 20.6485 17.8839C20.6485 15.8421 19.9676 15.1621 17.9267 15.1621C15.8859 15.1621 15.205 15.8421 15.205 17.8839Z\"\n      stroke=\"#130F26\"\n      strokeWidth=\"1.5\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n    />,\n    <path\n      key=\"Stroke 5\"\n      id=\"Stroke 5\"\n      d=\"M14.1765 7.39439H20.6481\"\n      stroke=\"#130F26\"\n      strokeWidth=\"1.5\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n    />,\n    <path\n      key=\"Stroke 7\"\n      id=\"Stroke 7\"\n      fillRule=\"evenodd\"\n      clipRule=\"evenodd\"\n      d=\"M10.1153 7.39293C10.1153 5.35204 9.43436 4.67114 7.39346 4.67114C5.35167 4.67114 4.67078 5.35204 4.67078 7.39293C4.67078 9.43472 5.35167 10.1147 7.39346 10.1147C9.43436 10.1147 10.1153 9.43472 10.1153 7.39293Z\"\n      stroke=\"#130F26\"\n      strokeWidth=\"1.5\"\n      strokeLinecap=\"round\"\n      strokeLinejoin=\"round\"\n    />,\n  ],\n});\n\ntype FilterProps = {\n  options: string[];\n  checkedOptions: string[];\n  onChange: (v: string[]) => void;\n};\n\nexport const ComponentFilter: React.FC<FilterProps> = ({\n  options,\n  checkedOptions,\n  onChange,\n}) => {\n  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n    const checked = e.target.checked;\n    const value = e.target.value;\n    const newCheckedOptions = [...checkedOptions];\n    if (checked) {\n      newCheckedOptions.push(value);\n    } else {\n      const idx = newCheckedOptions.findIndex(c => c === value);\n      newCheckedOptions.splice(idx, 1);\n    }\n    onChange(newCheckedOptions);\n  };\n\n  const checkVersion = (version: string) => {\n    return checkedOptions.includes(version);\n  };\n\n  return (\n    <Popover isLazy closeOnBlur placement=\"bottom\">\n      <PopoverTrigger>\n        <Button\n          _focus={{ boxShadow: 'none' }}\n          colorScheme=\"blue\"\n          variant={checkedOptions.length > 0 ? 'solid' : 'ghost'}\n          h=\"1.75rem\"\n          size=\"sm\"\n        >\n          <FilterIcon />\n        </Button>\n      </PopoverTrigger>\n      <chakra.div\n        sx={{\n          '.chakra-popover__popper': {\n            inset: '0px auto auto -3px !import',\n          },\n        }}\n      >\n        <PopoverContent\n          mt=\"1\"\n          p=\"2\"\n          opacity=\"0\"\n          rounded=\"md\"\n          maxH=\"350px\"\n          shadow=\"base\"\n          zIndex=\"popover\"\n          overflowY=\"auto\"\n          width=\"200px\"\n          _focus={{ boxShadow: 'none' }}\n        >\n          {options.map(version => {\n            return (\n              <Checkbox\n                key={version}\n                value={version}\n                isChecked={checkVersion(version)}\n                onChange={handleChange}\n              >\n                {version}\n              </Checkbox>\n            );\n          })}\n        </PopoverContent>\n      </chakra.div>\n    </Popover>\n  );\n};\n","import React, { useMemo } from 'react';\nimport { EditorServices } from '../../types';\nimport { css } from '@emotion/css';\nimport { observer } from 'mobx-react-lite';\nimport { ComponentSchema } from '@sunmao-ui/core';\nimport { Select } from '@sunmao-ui/editor-sdk';\nimport { ComponentFilter } from '../ComponentsList/ComponentFilter';\nimport { HStack } from '@chakra-ui/react';\ntype Props = {\n  components: ComponentSchema[];\n  onChange: (id: string) => void;\n  tags: string[];\n  checkedTags: string[];\n  onTagsChange: (v: string[]) => void;\n  services: EditorServices;\n};\n\nconst SelectStyle = css`\n  height: 40px;\n  &&& .sunmao-select-selector,\n  &&& .sunmao-select-selector input {\n    height: 100%;\n  }\n  &&& .sunmao-select-selector {\n    border-radius: 0.375rem;\n  }\n  &&& .sunmao-select-selector .sunmao-select-selection-placeholder,\n  &&& .sunmao-select-selector .sunmao-select-selection-search,\n  &&& .sunmao-select-selector .sunmao-select-selection-item {\n    line-height: 40px;\n    font-size: 1rem;\n  }\n`;\n\nexport const ComponentSearch: React.FC<Props> = observer(props => {\n  const { components, onChange, tags, checkedTags, onTagsChange } = props;\n\n  const options = useMemo(() => {\n    return components.map(c => ({\n      label: c.id,\n      value: c.id,\n    }));\n  }, [components]);\n\n  return (\n    <HStack width=\"full\">\n      <Select\n        bordered={false}\n        className={SelectStyle}\n        placeholder=\"Search component\"\n        onSelect={onChange}\n        showArrow={false}\n        showSearch\n        style={{ width: '100%' }}\n        options={options}\n      />\n      {tags.length > 0 ? (\n        <ComponentFilter\n          options={tags}\n          checkedOptions={checkedTags}\n          onChange={v => onTagsChange(v)}\n        />\n      ) : null}\n    </HStack>\n  );\n});\n","import React, { useMemo, useState } from 'react';\nimport {\n  Flex,\n  Box,\n  Accordion,\n  AccordionItem,\n  AccordionPanel,\n  AccordionButton,\n  AccordionIcon,\n  Input,\n  InputGroup,\n  InputRightElement,\n  Tag,\n} from '@chakra-ui/react';\nimport { groupBy, sortBy } from 'lodash';\nimport { EditorServices } from '../../types';\nimport { ExplorerMenuTabs } from '../../constants/enum';\nimport { RuntimeComponent, SlotSpec } from '@sunmao-ui/core';\nimport { css } from '@emotion/css';\nimport { ComponentFilter } from './ComponentFilter';\nimport { JSONSchema7 } from 'json-schema';\n\ntype Props = {\n  services: EditorServices;\n};\n\ntype Category = {\n  name: string;\n  components: RuntimeComponent<\n    any,\n    any,\n    Record<string, JSONSchema7 | undefined>,\n    ReadonlyArray<string>,\n    Record<string, SlotSpec>,\n    ReadonlyArray<string>\n  >[];\n};\n\nconst PRESET_CATEGORY_ORDER = {\n  Layout: 5,\n  Input: 4,\n  Display: 3,\n  Advance: -Infinity,\n};\n\nfunction getCategoryOrder(name: string): number {\n  return name in PRESET_CATEGORY_ORDER\n    ? PRESET_CATEGORY_ORDER[name as keyof typeof PRESET_CATEGORY_ORDER]\n    : 0;\n}\n\nfunction getTagColor(version: string): string {\n  if (version.startsWith('chakra_ui/')) {\n    return 'teal';\n  } else if (version.startsWith('core/')) {\n    return 'yellow';\n  } else {\n    return 'blackAlpha';\n  }\n}\n\nconst tagStyle = css`\n  overflow: hidden;\n  text-overflow: ellipsis;\n  white-space: nowrap;\n`;\n\nexport const ComponentList: React.FC<Props> = ({ services }) => {\n  const { registry, editorStore } = services;\n  const [filterText, setFilterText] = useState('');\n  const [checkedVersions, setCheckedVersions] = useState<string[]>([]);\n\n  const versions = useMemo<string[]>(() => {\n    const versions: Record<string, string> = {};\n    registry.getAllComponents().forEach(c => {\n      versions[c.version] = '';\n    });\n    return Object.keys(versions);\n  }, [registry]);\n\n  const categories = useMemo<Category[]>(() => {\n    const grouped = groupBy(\n      registry.getAllComponents().filter(c => {\n        if (\n          c.metadata.isDataSource ||\n          c.metadata.deprecated ||\n          (checkedVersions.length && !checkedVersions.includes(c.version))\n        ) {\n          return false;\n        } else if (!filterText) {\n          return true;\n        }\n        return new RegExp(filterText, 'i').test(c.metadata.displayName);\n      }),\n      c => c.metadata.annotations?.category || 'Advance'\n    );\n    return sortBy(\n      Object.keys(grouped).map(name => ({\n        name,\n        components: sortBy(grouped[name], 'metadata.name'),\n      })),\n      c => -getCategoryOrder(c.name)\n    );\n  }, [filterText, registry, checkedVersions]);\n\n  return (\n    <>\n      <InputGroup>\n        <Input\n          placeholder=\"filter the components\"\n          value={filterText}\n          onChange={evt => setFilterText(evt.currentTarget.value)}\n        />\n        <InputRightElement>\n          <ComponentFilter\n            options={versions}\n            checkedOptions={checkedVersions}\n            onChange={setCheckedVersions}\n          />\n        </InputRightElement>\n      </InputGroup>\n      <Accordion\n        allowMultiple\n        defaultIndex={categories.map((_, idx) => idx)}\n        reduceMotion\n      >\n        {categories.map(category => {\n          return (\n            <AccordionItem key={category.name}>\n              <AccordionButton>\n                <Box flex=\"1\" textAlign=\"left\">\n                  {category.name}\n                </Box>\n                <AccordionIcon />\n              </AccordionButton>\n              <AccordionPanel>\n                {category.components.map(c => {\n                  const onDragStart = (e: any) => {\n                    e.dataTransfer.setData(\n                      'component',\n                      `${c.version}/${c.metadata.name}`\n                    );\n                    editorStore.setExplorerMenuTab(ExplorerMenuTabs.UI_TREE);\n                    editorStore.setIsDraggingNewComponent(true);\n                  };\n                  const onDragEnd = () => {\n                    editorStore.setIsDraggingNewComponent(false);\n                  };\n                  const cEle = (\n                    <Flex\n                      key={`${c.version}/${c.metadata.name}`}\n                      className=\"droppable-element\"\n                      cursor=\"move\"\n                      background=\"gray.100\"\n                      width=\"100%\"\n                      borderRadius=\"md\"\n                      align=\"center\"\n                      justify=\"space-between\"\n                      transition=\"ease 0.2s\"\n                      _hover={{\n                        transform: 'scale(1.05)',\n                        background: 'gray.200',\n                      }}\n                      p={2}\n                      mb={1}\n                      draggable\n                      unselectable=\"on\"\n                      onDragStart={onDragStart}\n                      onDragEnd={onDragEnd}\n                    >\n                      {c.metadata.displayName}\n                      <Tag colorScheme={getTagColor(c.version)} size=\"sm\">\n                        <div className={tagStyle}>{c.version}</div>\n                      </Tag>\n                    </Flex>\n                  );\n                  return cEle;\n                })}\n              </AccordionPanel>\n            </AccordionItem>\n          );\n        })}\n      </Accordion>\n    </>\n  );\n};\n","import React, { useState } from 'react';\nimport { Flex, Button, Icon } from '@chakra-ui/react';\nimport { ExpressionWidget } from '@sunmao-ui/editor-sdk';\nimport { Type } from '@sinclair/typebox';\nimport { EditorServices } from '../../types';\nconst SideBarIcon: React.FC<{\n  transform?: string;\n  color?: string;\n  onClick?: () => void;\n}> = props => (\n  <Icon cursor=\"pointer\" {...props} viewBox=\"-5 -5 24 24\" width=\"24px\" height=\"24px\">\n    <path\n      fillRule=\"evenodd\"\n      clipRule=\"evenodd\"\n      d=\"M13 2.5H8v11h5a.5.5 0 0 0 .5-.5V3a.5.5 0 0 0-.5-.5Zm-10 0h3.5v11H3a.5.5 0 0 1-.5-.5V3a.5.5 0 0 1 .5-.5ZM3 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2H3Zm1.5 11.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2Zm1-4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0Zm-1-2.5a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z\"\n      fill=\"currentColor\"\n    />\n  </Icon>\n);\n\nconst MockComp = {\n  id: 'mock',\n  type: 'core/v1/dummy',\n  properties: {},\n  traits: [],\n};\n\nexport const EditorHeader: React.FC<{\n  isDisplayLeftMenu: boolean;\n  isDisplayRightMenu: boolean;\n  setIsDisplayLeftMenu: (show: boolean) => void;\n  setIsDisplayRightMenu: (show: boolean) => void;\n  onPreview: () => void;\n  onCodeMode: () => void;\n  onRefresh: () => void;\n  services: EditorServices;\n}> = ({\n  onPreview,\n  onCodeMode,\n  onRefresh,\n  setIsDisplayLeftMenu,\n  setIsDisplayRightMenu,\n  isDisplayLeftMenu,\n  isDisplayRightMenu,\n  services,\n}) => {\n  const [exp, setExp] = useState('');\n  return (\n    <Flex p={2} borderBottomWidth=\"2px\" borderColor=\"gray.200\" align=\"center\">\n      <Flex flex=\"1\">\n        <ExpressionWidget\n          key={services.editorStore.selectedComponentId}\n          component={MockComp}\n          spec={Type.Any()}\n          services={services}\n          path={[]}\n          level={0}\n          value={exp}\n          onChange={v => setExp(v)}\n        />\n      </Flex>\n      <Flex flex=\"1\" align=\"center\" justify=\"center\">\n        <SideBarIcon\n          color={isDisplayLeftMenu ? '#000' : '#eee'}\n          onClick={() => setIsDisplayLeftMenu(!isDisplayLeftMenu)}\n        />\n        <SideBarIcon\n          transform=\"rotateY(180deg)\"\n          color={isDisplayRightMenu ? '#000' : '#eee'}\n          onClick={() => setIsDisplayRightMenu(!isDisplayRightMenu)}\n        />\n      </Flex>\n      <Flex flex=\"1\" justify=\"end\">\n        <Button colorScheme=\"blue\" mr={3} onClick={onCodeMode}>\n          Code Mode\n        </Button>\n        <Button colorScheme=\"blue\" mr={3} onClick={onRefresh}>\n          Refresh\n        </Button>\n        <Button colorScheme=\"blue\" onClick={onPreview}>\n          Preview\n        </Button>\n      </Flex>\n    </Flex>\n  );\n};\n","import { IComponentModel } from '../AppModel/IAppModel';\n\nexport class PasteManager {\n  componentCache: IComponentModel | undefined;\n\n  setPasteComponents(component: IComponentModel) {\n    this.componentCache = component;\n  }\n}\n","import React, { useRef } from 'react';\nimport { Box } from '@chakra-ui/react';\nimport { css } from '@emotion/css';\nimport { ComponentSchema } from '@sunmao-ui/core';\nimport { genOperation } from '../operations';\nimport { PasteManager } from '../operations/PasteManager';\nimport { EditorServices } from '../types';\nimport { AppModel } from '../AppModel/AppModel';\nimport { ComponentId } from '../AppModel/IAppModel';\nimport { RootId } from '../constants';\n\ntype Props = {\n  selectedComponentId: string;\n  components: ComponentSchema[];\n  services: EditorServices;\n};\n\nconst KeyboardEventWrapperId = 'keyboard-event-wrapper';\n\nexport const KeyboardEventWrapper: React.FC<Props> = ({\n  selectedComponentId,\n  components,\n  services,\n  children,\n}) => {\n  const { eventBus, registry, appModelManager } = services;\n  const pasteManager = useRef(new PasteManager());\n  const style = css`\n    &:focus {\n      outline: none;\n    }\n  `;\n\n  function getComponentFirstSlot(componentId: string) {\n    const component = appModelManager.appModel.getComponentById(\n      componentId as ComponentId\n    );\n    return component?.slots[0] || '';\n  }\n\n  const onKeyDown = (e: React.KeyboardEvent) => {\n    // if user is focusing input elements, prevent keyboard events\n    if (\n      document.activeElement?.tagName === 'TEXTAREA' ||\n      document.activeElement?.tagName === 'INPUT'\n    )\n      return;\n    switch (e.key) {\n      case 'Delete':\n      case 'Backspace':\n        // if `selectionStart` available,think it is textarea or text input\n        if ((e.target as any).selectionStart !== undefined) {\n          return;\n        }\n        eventBus.send(\n          'operation',\n          genOperation(registry, 'removeComponent', {\n            componentId: selectedComponentId,\n          })\n        );\n        break;\n      case 'z':\n        // FIXME: detect os version and set redo/undo logic\n        if (e.metaKey || e.ctrlKey) {\n          if (e.shiftKey) {\n            eventBus.send('redo');\n          } else {\n            eventBus.send('undo');\n          }\n        }\n        break;\n      case 'y':\n        if (e.metaKey || e.ctrlKey) {\n          eventBus.send('redo');\n        }\n        break;\n      case 'c':\n        // FIXME: detect os version and set redo/undo logic\n        if (e.metaKey || e.ctrlKey) {\n          const appModel = new AppModel(components, registry);\n          const copiedComponent = appModel.getComponentById(\n            selectedComponentId as ComponentId\n          );\n          if (copiedComponent) {\n            pasteManager.current.setPasteComponents(copiedComponent);\n          }\n        }\n        break;\n      case 'x':\n        if (e.metaKey || e.ctrlKey) {\n          const appModel = new AppModel(components, registry);\n          const copiedComponent = appModel.getComponentById(\n            selectedComponentId as ComponentId\n          );\n          if (copiedComponent) {\n            pasteManager.current.setPasteComponents(copiedComponent);\n          }\n          eventBus.send(\n            'operation',\n            genOperation(registry, 'removeComponent', {\n              componentId: selectedComponentId,\n            })\n          );\n        }\n        break;\n      case 'v':\n        if (e.metaKey || e.ctrlKey) {\n          if (pasteManager.current.componentCache) {\n            // Clone the component which is going to copy, otherwise the new component will have the same reference.\n            const copiedComponentId = pasteManager.current.componentCache.id;\n            const copiedComponentsSchema =\n              pasteManager.current.componentCache.allComponents.map(c => c.toSchema());\n            const clonedComponent = new AppModel(\n              copiedComponentsSchema,\n              registry\n            ).getComponentById(copiedComponentId);\n            eventBus.send(\n              'operation',\n              genOperation(registry, 'pasteComponent', {\n                parentId: selectedComponentId || RootId,\n                slot: getComponentFirstSlot(selectedComponentId),\n                component: clonedComponent!,\n              })\n            );\n          }\n        }\n        break;\n    }\n  };\n\n  return (\n    <Box\n      id={KeyboardEventWrapperId}\n      className={style}\n      width=\"100%\"\n      height=\"100%\"\n      onKeyDown={onKeyDown}\n      tabIndex={-1}\n    >\n      {children}\n    </Box>\n  );\n};\n","import React from 'react';\nimport { ComponentSchema } from '@sunmao-ui/core';\nimport {\n  Text,\n  AccordionItem,\n  AccordionButton,\n  AccordionIcon,\n  AccordionPanel,\n  Tag,\n  HStack,\n} from '@chakra-ui/react';\nimport { EditorServices } from '../../types';\nimport { ComponentNode } from '../StructureTree/ComponentNode';\n\ninterface Props {\n  dataSources: ComponentSchema[];\n  title: string;\n  services: EditorServices;\n  type: string;\n}\n\nconst COLOR_MAP = {\n  GET: 'green',\n  POST: 'orange',\n  PUT: 'yellow',\n  PATCH: 'yellow',\n  DELETE: 'red',\n};\n\nexport const DataSourceGroup: React.FC<Props> = props => {\n  const { dataSources = [], title, services, type } = props;\n  const { editorStore } = services;\n\n  const StateItems = () => (\n    <>\n      {dataSources.map(dataSource => {\n        let tag = '';\n\n        const fetchTrait = dataSource.traits.find(({ type }) => type === `core/v1/fetch`);\n        if (fetchTrait?.properties) {\n          tag = ((fetchTrait.properties as any)?.method as string)?.toUpperCase();\n        }\n\n        return (\n          <ComponentNode\n            id={dataSource.id}\n            key={dataSource.id}\n            component={dataSource}\n            parentId={null}\n            slot={null}\n            onSelectComponent={editorStore.setSelectedComponentId}\n            services={services}\n            droppable={false}\n            depth={0}\n            isSelected={editorStore.selectedComponent?.id === dataSource.id}\n            isExpanded={false}\n            onToggleExpand={() => undefined}\n            shouldShowSelfSlotName={false}\n            notEmptySlots={[]}\n            onDragStart={() => undefined}\n            onDragEnd={() => undefined}\n            prefix={\n              tag ? (\n                <Tag\n                  size=\"sm\"\n                  colorScheme={COLOR_MAP[tag as keyof typeof COLOR_MAP]}\n                  marginLeft=\"-3\"\n                  marginRight=\"1\"\n                >\n                  {tag}\n                </Tag>\n              ) : undefined\n            }\n          />\n        );\n      })}\n    </>\n  );\n\n  return (\n    <AccordionItem>\n      <AccordionButton justifyContent=\"space-between\">\n        <HStack>\n          {type === 'component' ? <Tag colorScheme=\"blue\">C</Tag> : undefined}\n          <Text fontWeight=\"bold\">{title || 'Unknown'}</Text>\n        </HStack>\n        <AccordionIcon />\n      </AccordionButton>\n      <AccordionPanel padding=\"0\">\n        {dataSources.length ? <StateItems /> : <Text padding=\"2\">Empty</Text>}\n      </AccordionPanel>\n    </AccordionItem>\n  );\n};\n","import React, { useCallback, useMemo, useState } from 'react';\nimport {\n  VStack,\n  Spacer,\n  Text,\n  Menu,\n  MenuItem,\n  MenuButton,\n  MenuList,\n  Accordion,\n  MenuGroup,\n  HStack,\n  Button,\n} from '@chakra-ui/react';\nimport { ChevronDownIcon } from '@chakra-ui/icons';\nimport { DataSourceGroup } from './DataSourceGroup';\nimport { EditorServices } from '../../types';\nimport { groupBy } from 'lodash';\nimport { genOperation } from '../../operations';\nimport { generateDefaultValueFromSpec } from '@sunmao-ui/shared';\nimport { JSONSchema7 } from 'json-schema';\nimport { ToolMenuTabs } from '../../constants/enum';\nimport { ComponentSearch } from '../StructureTree/ComponentSearch';\nimport { ComponentSchema } from '@sunmao-ui/core';\n\ninterface Props {\n  services: EditorServices;\n}\n\nexport const DataSourceList: React.FC<Props> = props => {\n  const { services } = props;\n  const { editorStore, eventBus, registry } = services;\n  const { dataSources, setSelectedComponentId, setToolMenuTab } = editorStore;\n  const [checkedTags, setCheckedTags] = useState<string[]>([]);\n  const tagMap = services.editorStore.app.metadata.annotations?.componentsTagMap;\n  // filter datasources by tag\n  const filteredDataSources = useMemo(() => {\n    if (!tagMap || checkedTags.length === 0) {\n      return dataSources;\n    }\n\n    const dataSourceIds = checkedTags.reduce<string[]>((result, curr) => {\n      return result.concat(tagMap[curr]);\n    }, []);\n\n    return dataSources.filter(d => dataSourceIds.includes(d.id)) as ComponentSchema[];\n  }, [checkedTags, dataSources, tagMap]);\n\n  const tDataSources = filteredDataSources.filter(ds => ds.type === 'core/v1/dummy');\n  const cDataSources = filteredDataSources.filter(ds => ds.type !== 'core/v1/dummy');\n  const cdsMap = groupBy(cDataSources, c => c.type);\n  const tdsMap = groupBy(tDataSources, c => c.traits[0]?.type || '');\n  const cdsGroups = Object.keys(cdsMap).map(type => {\n    return {\n      title: type,\n      dataSources: cdsMap[type],\n      type: 'component',\n    };\n  });\n  const tdsGroups = Object.keys(tdsMap).map(type => {\n    return {\n      title: type,\n      dataSources: tdsMap[type] || [],\n      type: 'trait',\n    };\n  });\n\n  const dsGroups = cdsGroups.concat(tdsGroups);\n\n  // cdsTypes: component data source types\n  // tdsTypes: trait data source types\n  const { cdsTypes, tdsTypes } = useMemo(() => {\n    const cdsTypes = registry\n      .getAllComponents()\n      .filter(c => c.metadata.isDataSource && c.metadata.name !== 'dummy')\n      .map(c => `${c.version}/${c.metadata.name}`);\n    const tdsTypes = registry\n      .getAllTraits()\n      .filter(t => t.metadata.isDataSource)\n      .map(t => `${t.version}/${t.metadata.name}`);\n    return { cdsTypes, tdsTypes };\n  }, [registry]);\n\n  const getNewId = useCallback(\n    (name: string): string => {\n      let count = dataSources.length;\n      let id = `${name}${count}`;\n      const ids = dataSources.map(({ id }) => id);\n\n      while (ids.includes(id)) {\n        id = `${name}${++count}`;\n      }\n\n      return `${name}${count}`;\n    },\n    [dataSources]\n  );\n  const onCreateDSFromComponent = useCallback(\n    (type: string) => {\n      const name = type.split('/')[2];\n      const id = getNewId(name);\n\n      eventBus.send(\n        'operation',\n        genOperation(registry, 'createComponent', {\n          componentType: type,\n          componentId: id,\n        })\n      );\n\n      setSelectedComponentId(id);\n      setToolMenuTab(ToolMenuTabs.INSPECT);\n    },\n    [eventBus, getNewId, registry, setSelectedComponentId, setToolMenuTab]\n  );\n  const onCreateDSFromTrait = useCallback(\n    (type: string) => {\n      const traitDefine = registry.getTraitByType(type);\n      const propertiesSpec = traitDefine.spec.properties;\n      const defaultProperties =\n        traitDefine.metadata.exampleProperties ||\n        generateDefaultValueFromSpec(propertiesSpec, {\n          genArrayItemDefaults: false,\n        });\n      const name = type.split('/')[2];\n      const id = getNewId(name);\n\n      eventBus.send(\n        'operation',\n        genOperation(registry, 'createDataSource', {\n          id,\n          type,\n          defaultProperties: defaultProperties as JSONSchema7,\n        })\n      );\n\n      setSelectedComponentId(id);\n      setToolMenuTab(ToolMenuTabs.INSPECT);\n    },\n    [eventBus, getNewId, registry, setSelectedComponentId, setToolMenuTab]\n  );\n\n  return (\n    <VStack spacing=\"2\" alignItems=\"stretch\">\n      <HStack padding=\"4\" paddingBottom=\"0\">\n        <Text fontSize=\"lg\" fontWeight=\"bold\">\n          DataSources\n        </Text>\n        <Spacer />\n        <Menu isLazy>\n          <MenuButton\n            as={Button}\n            size=\"sm\"\n            variant=\"ghost\"\n            rightIcon={<ChevronDownIcon />}\n            colorScheme=\"blue\"\n          >\n            Add\n          </MenuButton>\n          <MenuList>\n            {cdsTypes.length ? (\n              <MenuGroup title=\"From Component\">\n                {cdsTypes.map(type => (\n                  <MenuItem key={type} onClick={() => onCreateDSFromComponent(type)}>\n                    {type}\n                  </MenuItem>\n                ))}\n              </MenuGroup>\n            ) : undefined}\n            <MenuGroup title=\"From Trait\">\n              {tdsTypes.map(type => (\n                <MenuItem key={type} onClick={() => onCreateDSFromTrait(type)}>\n                  {type}\n                </MenuItem>\n              ))}\n            </MenuGroup>\n          </MenuList>\n        </Menu>\n      </HStack>\n      <ComponentSearch\n        components={dataSources}\n        onChange={id => setSelectedComponentId(id)}\n        services={props.services}\n        tags={tagMap ? Object.keys(tagMap) : []}\n        checkedTags={checkedTags}\n        onTagsChange={v => setCheckedTags(v)}\n      />\n      <Accordion\n        reduceMotion\n        defaultIndex={[0].concat(dsGroups.map((_, i) => i + 1))}\n        allowMultiple\n      >\n        {dsGroups.map(group => (\n          <DataSourceGroup\n            key={group.title}\n            title={group.title}\n            type={group.type}\n            dataSources={group.dataSources}\n            services={services}\n          />\n        ))}\n      </Accordion>\n    </VStack>\n  );\n};\n","import React, { useMemo, useCallback } from 'react';\nimport { VStack } from '@chakra-ui/react';\nimport { Static } from '@sinclair/typebox';\nimport { ComponentSchema } from '@sunmao-ui/core';\nimport {\n  CORE_VERSION,\n  CoreTraitName,\n  EventHandlerSpec,\n  MountEvents,\n} from '@sunmao-ui/shared';\nimport { ArrayField, mergeWidgetOptionsIntoSpec } from '@sunmao-ui/editor-sdk';\nimport { genOperation } from '../../../operations';\nimport { EditorServices } from '../../../types';\n\ntype EventHandler = Static<typeof EventHandlerSpec>;\n\ntype Props = {\n  component: ComponentSchema;\n  services: EditorServices;\n};\n\nconst EVENT_TRAIT_TYPE = `${CORE_VERSION}/${CoreTraitName.Event}`;\n\nexport const EventTraitForm: React.FC<Props> = props => {\n  const { component, services } = props;\n  const { eventBus, registry } = services;\n\n  const spec = registry.getTraitByType(EVENT_TRAIT_TYPE);\n  const handlers: EventHandler[] = useMemo(() => {\n    return component.traits.find(t => t.type === EVENT_TRAIT_TYPE)?.properties\n      .handlers as Array<Static<typeof EventHandlerSpec>>;\n  }, [component]);\n\n  const eventTypes = useMemo(() => {\n    return [...registry.getComponentByType(component.type).spec.events, ...MountEvents];\n  }, [component.type, registry]);\n\n  const onChange = useCallback(\n    (newHandlers: EventHandler[]) => {\n      if (handlers) {\n        const index = component.traits.findIndex(t => t.type === EVENT_TRAIT_TYPE);\n\n        eventBus.send(\n          'operation',\n          genOperation(registry, 'modifyTraitProperty', {\n            componentId: component.id,\n            traitIndex: index,\n            properties: {\n              handlers: newHandlers,\n            },\n          })\n        );\n      } else {\n        eventBus.send(\n          'operation',\n          genOperation(registry, 'createTrait', {\n            componentId: component.id,\n            traitType: EVENT_TRAIT_TYPE,\n            properties: { handlers: newHandlers },\n          })\n        );\n      }\n    },\n    [component, handlers, registry, eventBus]\n  );\n\n  if (!eventTypes.length) return <span>No events.</span>;\n\n  return (\n    <VStack width=\"full\" spacing=\"2\" alignItems=\"self-start\">\n      <VStack width=\"full\" spacing=\"0\">\n        <ArrayField\n          component={component}\n          services={services}\n          spec={mergeWidgetOptionsIntoSpec<'core/v1/array'>(\n            spec.spec.properties.properties!.handlers as any,\n            {\n              displayedKeys: ['componentId', 'type'],\n            }\n          )}\n          value={handlers || []}\n          level={1}\n          path={[]}\n          onChange={onChange}\n        />\n      </VStack>\n    </VStack>\n  );\n};\n","import { AddIcon } from '@chakra-ui/icons';\nimport {\n  Box,\n  Button,\n  Menu,\n  MenuButton,\n  MenuItem,\n  MenuList,\n  Portal,\n} from '@chakra-ui/react';\nimport { RegistryInterface } from '@sunmao-ui/runtime';\nimport React, { useMemo, useRef } from 'react';\nimport { hideCreateTraitsList } from '../../../constants';\nimport { ComponentSchema } from '@sunmao-ui/core';\nimport { ComponentFormElementId } from '@sunmao-ui/editor-sdk';\n\ntype Props = {\n  registry: RegistryInterface;\n  onAddTrait: (traitType: string) => void;\n  component: ComponentSchema;\n};\n\nexport const AddTraitButton: React.FC<Props> = props => {\n  const { onAddTrait, registry, component } = props;\n  const containerRef = useRef(document.getElementById(ComponentFormElementId) || null);\n  const componentTraitsMap = useMemo(\n    () =>\n      component.traits.reduce((result, trait) => {\n        result[trait.type] = true;\n        return result;\n      }, {} as Record<string, boolean>),\n    [component]\n  );\n  const traits = useMemo(() => {\n    return registry\n      .getAllTraits()\n      .filter(\n        t =>\n          !t.metadata.deprecated &&\n          !hideCreateTraitsList.includes(`${t.version}/${t.metadata.name}`)\n      );\n  }, [registry]);\n\n  const menuItems = traits.map(t => {\n    const type = `${t.version}/${t.metadata.name}`;\n    return (\n      <MenuItem\n        key={type}\n        isDisabled={componentTraitsMap[type]}\n        onClick={() => onAddTrait(type)}\n      >\n        {type}\n      </MenuItem>\n    );\n  });\n  return (\n    <Box>\n      <Menu isLazy>\n        <MenuButton\n          as={Button}\n          aria-label=\"add event\"\n          size=\"sm\"\n          variant=\"ghost\"\n          colorScheme=\"blue\"\n          leftIcon={<AddIcon />}\n        >\n          Add Trait\n        </MenuButton>\n        <Portal containerRef={containerRef}>\n          <MenuList zIndex={100}>{menuItems}</MenuList>\n        </Portal>\n      </Menu>\n    </Box>\n  );\n};\n","import { css } from '@emotion/css';\n\nexport const formWrapperCSS = css`\n  width: 100%;\n  padding: var(--chakra-space-4);\n  background: white;\n  border: 1px solid var(--chakra-colors-gray-200);\n  align-items: start;\n`;\n","import React from 'react';\nimport { ComponentSchema, TraitSchema } from '@sunmao-ui/core';\nimport { HStack, IconButton, VStack } from '@chakra-ui/react';\nimport { CloseIcon } from '@chakra-ui/icons';\nimport { SpecWidget } from '@sunmao-ui/editor-sdk';\nimport { formWrapperCSS } from '../style';\nimport { EditorServices } from '../../../types';\nimport { genOperation } from '../../../operations';\n\ntype Props = {\n  component: ComponentSchema;\n  trait: TraitSchema;\n  traitIndex: number;\n  onRemove?: (() => void) | null;\n  services: EditorServices;\n};\n\nexport const GeneralTraitForm: React.FC<Props> = props => {\n  const { trait, traitIndex, component, onRemove, services } = props;\n  const { registry, eventBus } = services;\n\n  const tImpl = registry.getTraitByType(trait.type);\n  const properties = trait.properties;\n  const onChange = (newValue: any) => {\n    const operation = genOperation(registry, 'modifyTraitProperty', {\n      componentId: component.id,\n      traitIndex: traitIndex,\n      properties: newValue,\n    });\n\n    eventBus.send('operation', operation);\n  };\n\n  return (\n    <VStack key={trait.type} className={formWrapperCSS}>\n      <HStack width=\"full\" justifyContent=\"space-between\">\n        <strong>{trait.type}</strong>\n        {onRemove ? (\n          <IconButton\n            aria-label=\"remove trait\"\n            variant=\"ghost\"\n            colorScheme=\"red\"\n            size=\"xs\"\n            icon={<CloseIcon />}\n            onClick={onRemove}\n          />\n        ) : null}\n      </HStack>\n      <SpecWidget\n        level={0}\n        path={[]}\n        // don't show category in trait form\n        hideCategory\n        spec={tImpl.spec.properties}\n        value={properties}\n        services={services}\n        component={component}\n        onChange={onChange}\n      />\n    </VStack>\n  );\n};\n","import React from 'react';\nimport { ComponentSchema } from '@sunmao-ui/core';\nimport { generateDefaultValueFromSpec } from '@sunmao-ui/shared';\nimport { VStack } from '@chakra-ui/react';\n\nimport { AddTraitButton } from './AddTraitButton';\nimport { GeneralTraitForm } from './GeneralTraitForm';\nimport { hasSpecialFormTraitList, unremovableTraits } from '../../../constants';\nimport { genOperation } from '../../../operations';\nimport { EditorServices } from '../../../types';\nimport { JSONSchema7Object } from 'json-schema';\n\ntype Props = {\n  component: ComponentSchema;\n  services: EditorServices;\n};\n\nexport const GeneralTraitFormList: React.FC<Props> = props => {\n  const { component, services } = props;\n  const { eventBus, registry } = services;\n\n  const onAddTrait = (type: string) => {\n    const traitDefine = registry.getTraitByType(type);\n    const traitSpec = traitDefine.spec;\n    const initProperties =\n      traitDefine.metadata.exampleProperties ||\n      (generateDefaultValueFromSpec(traitSpec.properties) as JSONSchema7Object);\n    eventBus.send(\n      'operation',\n      genOperation(registry, 'createTrait', {\n        componentId: component.id,\n        traitType: type,\n        properties: initProperties,\n      })\n    );\n  };\n\n  const traitFields = component.traits.map((trait, index) => {\n    if (hasSpecialFormTraitList.includes(trait.type)) {\n      return null;\n    }\n    const onRemoveTrait = unremovableTraits.includes(trait.type)\n      ? null\n      : () => {\n          eventBus.send(\n            'operation',\n            genOperation(registry, 'removeTrait', {\n              componentId: component.id,\n              index,\n            })\n          );\n        };\n\n    return (\n      <GeneralTraitForm\n        key={index}\n        component={component}\n        trait={trait}\n        traitIndex={index}\n        onRemove={onRemoveTrait}\n        services={services}\n      />\n    );\n  });\n\n  return (\n    <VStack width=\"full\" alignItems=\"start\" spacing=\"2\">\n      {traitFields}\n      <AddTraitButton onAddTrait={onAddTrait} registry={registry} component={component} />\n    </VStack>\n  );\n};\n","import React, { useCallback, useMemo, useState } from 'react';\nimport produce from 'immer';\nimport { AddIcon, ChevronDownIcon, ChevronUpIcon, CloseIcon } from '@chakra-ui/icons';\nimport {\n  Box,\n  FormControl,\n  FormLabel,\n  VStack,\n  HStack,\n  IconButton,\n  Text,\n  Select,\n  Button,\n  Accordion,\n  AccordionItem,\n  AccordionButton,\n  AccordionIcon,\n  AccordionPanel,\n} from '@chakra-ui/react';\nimport { ComponentSchema } from '@sunmao-ui/core';\nimport { CORE_VERSION, CoreTraitName } from '@sunmao-ui/shared';\nimport { FontWidget, SizeWidget, ColorWidget, SpaceWidget } from '@sunmao-ui/editor-sdk';\nimport { capitalize } from 'lodash';\nimport { genOperation } from '../../../operations';\nimport { formWrapperCSS } from '../style';\nimport { EditorServices } from '../../../types';\nimport { CodeEditor } from '../../CodeEditor';\nimport { css } from '@emotion/css';\n\ntype PartialCSSProperties = Partial<Record<keyof React.CSSProperties, any>>;\n\ntype Props = {\n  component: ComponentSchema;\n  services: EditorServices;\n};\n\ntype Styles = Array<{\n  styleSlot: string;\n  style: string;\n  cssProperties: PartialCSSProperties;\n}>;\n\nconst STYLE_TRAIT_TYPE = `${CORE_VERSION}/${CoreTraitName.Style}`;\n\nexport const StyleTraitForm: React.FC<Props> = props => {\n  const { component, services } = props;\n  const { eventBus, registry } = services;\n\n  const styleSlots = useMemo(() => {\n    return registry.getComponentByType(component.type).spec.styleSlots;\n  }, [component, registry]);\n\n  const styleTraitIndex = useMemo(() => {\n    return component.traits.findIndex(t => t.type === STYLE_TRAIT_TYPE);\n  }, [component]);\n\n  const styleTrait = component.traits[styleTraitIndex];\n  const styles = styleTrait?.properties.styles as Styles | undefined;\n\n  const createStyleTrait = () => {\n    eventBus.send(\n      'operation',\n      genOperation(registry, 'createTrait', {\n        componentId: component.id,\n        traitType: STYLE_TRAIT_TYPE,\n        properties: {\n          styles: [\n            {\n              styleSlot: styleSlots[0],\n              style: '',\n              cssProperties: {},\n            },\n          ],\n        },\n      })\n    );\n  };\n\n  const updateStyles = useCallback(\n    (newStyles: Styles) => {\n      eventBus.send(\n        'operation',\n        genOperation(registry, 'modifyTraitProperty', {\n          componentId: component.id,\n          traitIndex: styleTraitIndex,\n          properties: {\n            styles: newStyles,\n          },\n        })\n      );\n    },\n    [component.id, eventBus, registry, styleTraitIndex]\n  );\n\n  const addStyle = useCallback(() => {\n    const newStyles: Styles = (styles || []).concat({\n      styleSlot: styleSlots[0],\n      style: '',\n      cssProperties: {},\n    });\n    updateStyles(newStyles);\n  }, [updateStyles, styleSlots, styles]);\n\n  const onClickCreate = () => {\n    if (!styleTrait) {\n      createStyleTrait();\n    } else {\n      addStyle();\n    }\n  };\n\n  const changeStyleContent = useCallback(\n    (i: number, value: string) => {\n      if (!styles) return;\n      const newStyles = produce(styles, draft => {\n        draft[i].style = value;\n      });\n      updateStyles(newStyles);\n    },\n    [updateStyles, styles]\n  );\n\n  const changeStyleSlot = useCallback(\n    (i: number, newSlot: string) => {\n      if (!styles) return;\n      const newStyles = produce(styles, draft => {\n        draft[i].styleSlot = newSlot;\n      });\n      updateStyles(newStyles);\n    },\n    [updateStyles, styles]\n  );\n\n  const widgetProps = useMemo(() => {\n    return {\n      component,\n      spec: {},\n      services,\n      path: [],\n      level: 1,\n    };\n  }, [component, services]);\n\n  const styleForms = useMemo(() => {\n    if (!styles) {\n      return null;\n    }\n    return styles.map(({ style, styleSlot, cssProperties }, i) => {\n      const _cssProperties = cssProperties || {};\n      const removeStyle = (e: React.MouseEvent) => {\n        e.stopPropagation();\n        const newStyles = styles.filter((_, j) => j !== i);\n        updateStyles(newStyles);\n      };\n\n      const changeCssProperties = (newCss: PartialCSSProperties) => {\n        const newCssProperties = Object.assign({}, cssProperties, newCss);\n        const newStyles = produce(styles, draft => {\n          draft[i].cssProperties = newCssProperties;\n        });\n        updateStyles(newStyles);\n      };\n      return (\n        <AccordionItem width=\"full\" key={`${styleSlot}${i}`}>\n          <AccordionButton width=\"full\" justifyContent=\"space-between\">\n            <span>{styleSlot}</span>\n            <HStack>\n              <IconButton\n                aria-label=\"remove style\"\n                size=\"sm\"\n                variant=\"ghost\"\n                colorScheme=\"red\"\n                as=\"div\"\n                icon={<CloseIcon fontSize=\"12px\" />}\n                onClick={removeStyle}\n              />\n              <AccordionIcon />\n            </HStack>\n          </AccordionButton>\n          <AccordionPanel bg=\"white\" padding=\"0\">\n            <VStack\n              key={`${styleSlot}-${i}`}\n              className={formWrapperCSS}\n              width=\"full\"\n              spacing=\"2\"\n            >\n              <CollapsibleFormControl label=\"Style Slot\">\n                <Select\n                  value={styleSlot}\n                  onChange={e => changeStyleSlot(i, e.target.value)}\n                >\n                  {styleSlots.map(s => (\n                    <option key={s} value={s}>\n                      {s}\n                    </option>\n                  ))}\n                </Select>\n              </CollapsibleFormControl>\n              <CollapsibleFormControl label=\"Size\">\n                <SizeWidget\n                  {...widgetProps}\n                  value={_cssProperties}\n                  onChange={changeCssProperties}\n                />\n              </CollapsibleFormControl>\n              <CollapsibleFormControl label=\"Space\">\n                <SpaceWidget\n                  {...widgetProps}\n                  value={{\n                    margin: [\n                      _cssProperties.marginTop,\n                      _cssProperties.marginRight,\n                      _cssProperties.marginBottom,\n                      _cssProperties.marginLeft,\n                    ],\n                    padding: [\n                      _cssProperties.paddingTop,\n                      _cssProperties.paddingRight,\n                      _cssProperties.paddingBottom,\n                      _cssProperties.paddingLeft,\n                    ],\n                  }}\n                  onChange={(v: string, direction: string, type: string) => {\n                    const key = `${type}${capitalize(direction)}`;\n                    changeCssProperties({\n                      ..._cssProperties,\n                      [key]: v,\n                    });\n                  }}\n                />\n              </CollapsibleFormControl>\n              <CollapsibleFormControl label=\"Font\">\n                <FontWidget\n                  value={_cssProperties || {}}\n                  onChange={changeCssProperties}\n                  {...widgetProps}\n                />\n              </CollapsibleFormControl>\n              <CollapsibleFormControl label=\"Color\">\n                <Box mb=\"8px\">\n                  <Text mb=\"8px\">Text Color</Text>\n                  <ColorWidget\n                    {...widgetProps}\n                    value={_cssProperties.color || ''}\n                    onChange={(color: string) =>\n                      changeCssProperties({ ..._cssProperties, color })\n                    }\n                  />\n                </Box>\n                <Box mb=\"8px\">\n                  <Text mb=\"8px\">Background Color</Text>\n                  <ColorWidget\n                    {...widgetProps}\n                    value={_cssProperties.backgroundColor || ''}\n                    onChange={(color: string) =>\n                      changeCssProperties({ ..._cssProperties, backgroundColor: color })\n                    }\n                  />\n                </Box>\n              </CollapsibleFormControl>\n              <CollapsibleFormControl label=\"CSS\">\n                <CodeEditor\n                  className={css`\n                    width: 100%;\n                    height: 120px;\n                  `}\n                  mode=\"css\"\n                  defaultCode={style}\n                  onBlur={v => changeStyleContent(i, v)}\n                  needRerenderAfterMount\n                />\n              </CollapsibleFormControl>\n            </VStack>\n          </AccordionPanel>\n        </AccordionItem>\n      );\n    });\n  }, [\n    styles,\n    styleSlots,\n    widgetProps,\n    updateStyles,\n    changeStyleSlot,\n    changeStyleContent,\n  ]);\n\n  return (\n    <VStack width=\"full\" alignItems=\"self-start\" spacing=\"2\">\n      <Accordion width=\"full\" defaultIndex={[0]} allowMultiple reduceMotion>\n        {styleForms}\n      </Accordion>\n      <Button\n        leftIcon={<AddIcon />}\n        colorScheme=\"blue\"\n        size=\"sm\"\n        variant=\"ghost\"\n        onClick={onClickCreate}\n      >\n        Add Style\n      </Button>\n    </VStack>\n  );\n};\n\nconst CollapsibleFormControl: React.FC<{ label: string }> = props => {\n  const [isCollapsed, setIsCollapsed] = useState(true);\n  return (\n    <FormControl>\n      <FormLabel marginInlineEnd=\"0\">\n        <HStack width=\"full\" justify=\"space-between\">\n          <Text fontSize=\"14px\" fontWeight=\"normal\">\n            {props.label}\n          </Text>\n          <IconButton\n            aria-label=\"toggle collapse\"\n            size=\"sm\"\n            variant=\"ghost\"\n            icon={\n              isCollapsed ? (\n                <ChevronDownIcon fontSize=\"20px\" />\n              ) : (\n                <ChevronUpIcon fontSize=\"20px\" />\n              )\n            }\n            onClick={() => setIsCollapsed(!isCollapsed)}\n          />\n        </HStack>\n      </FormLabel>\n      {isCollapsed ? props.children : null}\n    </FormControl>\n  );\n};\n","import React from 'react';\nimport {\n  AccordionButton,\n  AccordionIcon,\n  AccordionItem,\n  AccordionPanel,\n  HStack,\n  Text,\n} from '@chakra-ui/react';\nimport { css } from '@emotion/css';\n\ntype Props = {\n  title: string;\n  style?: React.CSSProperties;\n};\n\nconst FormSectionCSS = css`\n  padding: 12px;\n  padding-top: 8px;\n  width: 100%;\n  border-bottom: 1px solid var(--chakra-colors-gray-400);\n`;\n\nconst SectionTitleCSS = css`\n  position: sticky;\n  padding: 4px 0;\n  top: 0;\n  z-index: 1;\n  font-size: 18px;\n  font-weight: 600;\n  color: var(--chakra-colors-gray-600);\n  justify-content: space-between;\n  background: var(--chakra-colors-gray-50);\n`;\n\nconst PanelCSS = css`\n  position: relative;\n  z-index: 0;\n`;\n\nexport const FormSection: React.FC<Props> = props => {\n  return (\n    <AccordionItem style={props.style} className={FormSectionCSS} width=\"full\">\n      <HStack className={SectionTitleCSS}>\n        <Text flex=\"1\">{props.title}</Text>\n        <AccordionButton width=\"auto\">\n          <AccordionIcon />\n        </AccordionButton>\n      </HStack>\n\n      <AccordionPanel padding=\"0\" className={PanelCSS}>\n        {props.children}\n      </AccordionPanel>\n    </AccordionItem>\n  );\n};\n","import React from 'react';\nimport { Text, VStack, Checkbox } from '@chakra-ui/react';\nimport { EditorServices } from '../../types';\n\ntype Props = {\n  services: EditorServices;\n};\n\nexport const TagForm: React.FC<Props> = ({ services }) => {\n  const { editorStore } = services;\n  const tagMap = editorStore.app.metadata.annotations?.componentsTagMap;\n  const componentId = editorStore.selectedComponentId;\n\n  if (!tagMap) return null;\n\n  const tagItems = Object.keys(tagMap).map(tag => {\n    const checked = tagMap[tag].includes(editorStore.selectedComponentId);\n\n    const onChange = (e: React.ChangeEvent<HTMLInputElement>) => {\n      const newTagMap = tagMap;\n      const nextValue = e.target.checked;\n      if (nextValue) {\n        newTagMap[tag].push(componentId);\n      } else {\n        newTagMap[tag] = tagMap[tag].filter(id => id !== componentId);\n      }\n      services.editorStore.appStorage.saveAppAnnotations({\n        componentsTagMap: newTagMap,\n      });\n    };\n\n    return (\n      <Checkbox key={tag} defaultChecked={checked} onChange={onChange}>\n        <Text>{tag}</Text>\n      </Checkbox>\n    );\n  });\n\n  return <VStack align=\"flex-start\">{tagItems}</VStack>;\n};\n","import React from 'react';\nimport { observer } from 'mobx-react-lite';\nimport { Accordion, Input, Text, VStack } from '@chakra-ui/react';\nimport { ComponentFormElementId, SpecWidget } from '@sunmao-ui/editor-sdk';\nimport { parseType } from '@sunmao-ui/core';\nimport { css } from '@emotion/css';\n\nimport { EventTraitForm } from './EventTraitForm';\nimport { GeneralTraitFormList } from './GeneralTraitFormList';\nimport { genOperation } from '../../operations';\nimport ErrorBoundary from '../ErrorBoundary';\nimport { StyleTraitForm } from './StyleTraitForm';\nimport { EditorServices } from '../../types';\nimport { FormSection } from './FormSection';\nimport { TagForm } from './TagForm';\n\n// avoid the expression tip would be covered\nconst ComponentFormStyle = css`\n  .chakra-collapse {\n    overflow: initial !important;\n  }\n`;\n\ntype Props = {\n  services: EditorServices;\n};\n\nexport const ComponentForm: React.FC<Props> = observer(props => {\n  const { services } = props;\n  const { editorStore, registry, eventBus } = services;\n  const { selectedComponent, selectedComponentId, selectedComponentIsDataSource } =\n    editorStore;\n  if (!selectedComponentId) {\n    return (\n      <Text p={2} fontSize=\"md\">\n        No components selected. Click on a component to select it.\n      </Text>\n    );\n  }\n\n  if (!selectedComponent) {\n    return (\n      <Text p={2} fontSize=\"md\">\n        Cannot find component with id: {selectedComponentId}.\n      </Text>\n    );\n  }\n  const { version, name } = parseType(selectedComponent.type);\n  const cImpl = registry.getComponent(version, name);\n  const properties = selectedComponent.properties;\n\n  const changeComponentId = (selectedComponentId: string, value: string) => {\n    eventBus.send(\n      'operation',\n      genOperation(registry, 'modifyComponentId', {\n        componentId: selectedComponentId,\n        newId: value,\n      })\n    );\n    editorStore.setSelectedComponentId(value);\n  };\n\n  const onKeyDown = (e: React.KeyboardEvent) => {\n    // prevent form keyboard events to accidentally trigger operation shortcut\n    e.stopPropagation();\n  };\n\n  const sections = [\n    {\n      title: 'Component Type',\n      node: <Text paddingLeft=\"3\">{selectedComponent.type}</Text>,\n    },\n    {\n      title: 'Component ID',\n      node: (\n        <Input\n          key={selectedComponent.id}\n          background=\"white\"\n          border=\"1px solid\"\n          borderColor=\"gray.400\"\n          defaultValue={selectedComponent.id}\n          onBlur={e => changeComponentId(selectedComponent?.id, e.target.value)}\n        />\n      ),\n    },\n    {\n      title: 'Properties',\n      node: (\n        <VStack width=\"full\" background=\"white\">\n          <SpecWidget\n            key={selectedComponent.id}\n            component={selectedComponent}\n            spec={cImpl.spec.properties}\n            value={properties}\n            path={[]}\n            level={0}\n            onChange={newFormData => {\n              eventBus.send(\n                'operation',\n                genOperation(registry, 'modifyComponentProperties', {\n                  componentId: selectedComponentId,\n                  properties: newFormData,\n                })\n              );\n            }}\n            services={services}\n          />\n        </VStack>\n      ),\n      hide: Object.keys(cImpl.spec.properties.properties).length === 0,\n    },\n    {\n      title: 'Events',\n      node: <EventTraitForm component={selectedComponent} services={services} />,\n    },\n    {\n      title: 'Styles',\n      node: (\n        <StyleTraitForm\n          key={selectedComponentId}\n          component={selectedComponent}\n          services={services}\n        />\n      ),\n      hide: selectedComponentIsDataSource,\n    },\n    {\n      title: 'Traits',\n      node: <GeneralTraitFormList component={selectedComponent} services={services} />,\n    },\n    {\n      title: 'Tags',\n      node: <TagForm services={services} />,\n    },\n  ];\n\n  return (\n    <ErrorBoundary>\n      <Accordion\n        id={ComponentFormElementId}\n        reduceMotion\n        className={ComponentFormStyle}\n        defaultIndex={sections.map((_, i) => i)}\n        background=\"gray.50\"\n        paddingBottom=\"200px\"\n        allowMultiple\n        onKeyDown={onKeyDown}\n      >\n        {sections.map((section, i) => {\n          if (section.hide) return undefined;\n          return (\n            <FormSection\n              style={{ position: 'relative', zIndex: sections.length - i }}\n              title={section.title}\n              key={`${section.title}-${selectedComponentId}`}\n            >\n              {section.node}\n            </FormSection>\n          );\n        })}\n      </Accordion>\n    </ErrorBoundary>\n  );\n});\n","import React from 'react';\nimport {\n  Modal,\n  ModalOverlay,\n  ModalHeader,\n  ModalContent,\n  ModalCloseButton,\n  ModalBody,\n} from '@chakra-ui/react';\n\nexport const GeneralModal: React.FC<{\n  onClose: () => void;\n  title: string;\n  size?: string;\n  scrollBehavior?: 'inside' | 'outside';\n}> = ({ title, onClose, size = 'full', children, scrollBehavior = 'inside' }) => {\n  return (\n    <Modal onClose={onClose} scrollBehavior={scrollBehavior} size={size} isOpen>\n      <ModalOverlay />\n      <ModalContent>\n        <ModalHeader>{title}</ModalHeader>\n        <ModalCloseButton />\n        <ModalBody>{children}</ModalBody>\n      </ModalContent>\n    </Modal>\n  );\n};\n","import { Box } from '@chakra-ui/react';\nimport { Application, createModule, Module } from '@sunmao-ui/core';\nimport { initSunmaoUI, SunmaoLib } from '@sunmao-ui/runtime';\nimport React from 'react';\nimport ErrorBoundary from '../ErrorBoundary';\nimport { GeneralModal } from '../GeneralModal';\n\ntype Props = {\n  app: Application;\n  modules: Module[];\n  libs: SunmaoLib[];\n  dependencies: Record<string, any>;\n  onClose: () => void;\n};\n\nexport const PreviewModal: React.FC<Props> = ({\n  app,\n  modules,\n  libs,\n  dependencies,\n  onClose,\n}) => {\n  const { App, registry } = initSunmaoUI({ libs, dependencies });\n  modules.forEach(m => registry.registerModule(createModule(m)));\n\n  return (\n    <GeneralModal onClose={onClose} title=\"Preview Modal\">\n      <Box width=\"full\" height=\"full\">\n        <ErrorBoundary>\n          <App options={app} debugEvent={false} debugStore={false} />\n        </ErrorBoundary>\n      </Box>\n    </GeneralModal>\n  );\n};\n","import { ChevronLeftIcon, ChevronRightIcon } from '@chakra-ui/icons';\nimport { Button, HStack, IconButton } from '@chakra-ui/react';\nimport React from 'react';\n\ntype Props = {\n  currentPage: number;\n  lastPage: number;\n  hideOnSinglePage?: boolean;\n  handlePageClick: (page: number) => void;\n};\n\nexport const Pagination: React.FC<Props> = ({\n  currentPage,\n  lastPage,\n  handlePageClick,\n  hideOnSinglePage = false,\n}) => {\n  if (lastPage === 1 && hideOnSinglePage) {\n    return null;\n  }\n\n  const pages = [];\n  if (currentPage - 1 >= 0) {\n    const prevPage = currentPage - 1;\n    pages.push(\n      <IconButton\n        size=\"xs\"\n        aria-label=\"left\"\n        icon={<ChevronLeftIcon />}\n        value={prevPage}\n        onClick={() => handlePageClick(prevPage)}\n        key={`prev-page-${prevPage}`}\n      />\n    );\n  }\n  const ShowPagesNumber = 5;\n  let startIdx;\n  let endIdx;\n  if (currentPage - 1 >= 0) {\n    startIdx = currentPage - 1;\n    endIdx = startIdx + ShowPagesNumber;\n  } else {\n    startIdx = 0;\n    endIdx = ShowPagesNumber;\n  }\n  if (currentPage + 4 >= lastPage) {\n    startIdx = Math.max(0, lastPage - ShowPagesNumber);\n    endIdx = lastPage;\n  }\n\n  for (let idx = startIdx; idx < endIdx; idx++) {\n    const offset = idx + 1;\n    pages.push(\n      <Button\n        size=\"xs\"\n        key={`page-${offset}`}\n        onClick={() => handlePageClick(idx)}\n        value={idx}\n        color={idx === currentPage ? 'blue.200' : undefined}\n      >\n        {offset}\n      </Button>\n    );\n  }\n\n  if (endIdx < lastPage) {\n    const offset = lastPage - 1;\n    pages.push(\n      <React.Fragment key={`last-page-${lastPage}`}>\n        <Button size=\"xs\" value={offset}>\n          ...\n        </Button>\n        <Button size=\"xs\" onClick={() => handlePageClick(lastPage)} value={offset}>\n          {lastPage}\n        </Button>\n      </React.Fragment>\n    );\n  }\n\n  if (currentPage + 1 < lastPage) {\n    const nextPage = currentPage + 1;\n    pages.push(\n      <IconButton\n        size=\"xs\"\n        aria-label=\"right\"\n        icon={<ChevronRightIcon />}\n        value={nextPage}\n        onClick={() => handlePageClick(nextPage)}\n        key={`next-page-${nextPage}`}\n      />\n    );\n  }\n  return <HStack>{pages}</HStack>;\n};\n","export const defaultPageSize = 5;\nexport const MERGE_STATE = 'Merge State';\nexport const TRIGGER_EVENT = 'Trigger Event';\nexport const MODULE_EVENT = 'Module Event';\nexport const paginationHeight = 40;\n","import React, { ReactNode, useEffect } from 'react';\nimport { Box, HStack, Table, Tbody, Td, Th, Thead, Tr } from '@chakra-ui/react';\nimport { Pagination } from './Pagination';\nimport { defaultPageSize, paginationHeight } from './const';\n\ntype Column = {\n  title: string;\n  dataIndex: string;\n  render?: (col: any, item: any, index: number) => React.ReactElement;\n};\n\ntype TableProps = {\n  className?: string;\n  columns: Column[];\n  pagination?: {\n    pageSize?: number;\n    lastPage?: number;\n    hideOnSinglePage?: boolean;\n  };\n  data: any[];\n  footer?: ReactNode;\n  emptyMessage?: string;\n};\n\nexport const DebugTable: React.FC<TableProps> = ({\n  columns = [],\n  pagination = {},\n  data,\n  footer,\n  emptyMessage = 'No Data',\n  className,\n}) => {\n  const { pageSize = defaultPageSize, hideOnSinglePage = false, lastPage } = pagination;\n  const [currPage, setCurrPage] = React.useState(0);\n  const currentData = data.slice(currPage * pageSize, currPage * pageSize + pageSize);\n\n  useEffect(() => {\n    if (data.length <= Number(pageSize) * (currPage - 1)) {\n      setCurrPage(0);\n    }\n  }, [currPage, data.length, pageSize]);\n\n  return (\n    <>\n      <Table\n        className={className}\n        size=\"sm\"\n        width=\"full\"\n        maxHeight=\"200px\"\n        overflow=\"auto\"\n      >\n        <Thead>\n          <Tr>\n            {columns.map(c => {\n              return <Th key={c.title + c.dataIndex}>{c.title}</Th>;\n            })}\n          </Tr>\n        </Thead>\n        <Tbody>\n          {!data.length ? (\n            <Tr>\n              <Td colSpan={columns.length}>\n                <Box textAlign=\"center\">{emptyMessage}</Box>\n              </Td>\n            </Tr>\n          ) : (\n            currentData.map((d, i) => {\n              return (\n                <Tr key={i}>\n                  {columns.map(c => {\n                    if (c.render) {\n                      return <Td key={c.dataIndex}>{c.render(c, d, i)}</Td>;\n                    }\n                    return <Td key={c.dataIndex}>{d[c.dataIndex]}</Td>;\n                  })}\n                </Tr>\n              );\n            })\n          )}\n        </Tbody>\n      </Table>\n      <HStack w=\"full\" h={paginationHeight + 'px'}>\n        <Box flex=\"1\">{footer}</Box>\n        <Pagination\n          currentPage={currPage}\n          lastPage={lastPage || Math.ceil(data.length / pageSize)}\n          handlePageClick={page => setCurrPage(page)}\n          hideOnSinglePage={hideOnSinglePage}\n        />\n      </HStack>\n    </>\n  );\n};\n","import { Props, DisplayedLog } from './type';\nimport React, { useCallback } from 'react';\nimport { DebugTable } from './Table';\nimport { Box, Button, Tooltip } from '@chakra-ui/react';\nimport { css } from '@emotion/css';\nimport { ExplorerMenuTabs } from '../../constants/enum';\nimport { MERGE_STATE, MODULE_EVENT, TRIGGER_EVENT } from './const';\nimport { ComponentId } from '../../AppModel/IAppModel';\n\ntype LogsProps = Props & {\n  logs: DisplayedLog[];\n  setLogs: React.Dispatch<React.SetStateAction<DisplayedLog[]>>;\n  count?: number;\n};\n\nexport const Logs: React.FC<LogsProps> = ({ services, logs, setLogs, count = 5 }) => {\n  const {\n    setSelectedComponentId,\n    setExplorerMenuTab,\n    setViewStateComponentId,\n    dataSourceTypeCache: isDataSourceTypeCache,\n  } = services.editorStore;\n\n  const handleClick = useCallback(\n    (type: string, componentId: ComponentId) => {\n      switch (type) {\n        case MERGE_STATE:\n          setExplorerMenuTab(ExplorerMenuTabs.STATE);\n          setViewStateComponentId(componentId);\n          break;\n        case MODULE_EVENT: // TODO\n        case TRIGGER_EVENT:\n        default:\n          const component =\n            services.appModelManager.appModel.getComponentById(componentId);\n          if (component && isDataSourceTypeCache[component.type]) {\n            setExplorerMenuTab(ExplorerMenuTabs.DATA);\n          } else {\n            setExplorerMenuTab(ExplorerMenuTabs.UI_TREE);\n          }\n          setSelectedComponentId(componentId);\n          break;\n      }\n    },\n    [\n      isDataSourceTypeCache,\n      services.appModelManager.appModel,\n      setExplorerMenuTab,\n      setSelectedComponentId,\n      setViewStateComponentId,\n    ]\n  );\n\n  const eventColumns = [\n    {\n      title: 'Time',\n      dataIndex: 'time',\n    },\n    {\n      title: 'Event',\n      dataIndex: 'eventType',\n    },\n    {\n      title: 'Target',\n      dataIndex: 'target',\n      render: (_col: any, item: any) => {\n        return (\n          <Box\n            cursor=\"pointer\"\n            fontWeight=\"bold\"\n            onClick={() => {\n              handleClick(item.type, item.target);\n            }}\n          >\n            {item.target}\n          </Box>\n        );\n      },\n    },\n    {\n      title: 'Parameters',\n      dataIndex: 'parameters',\n      render: (_col: any, item: any) => {\n        const parameters = JSON.stringify(item.parameters);\n        return (\n          <Tooltip label={parameters}>\n            <div\n              className={css`\n                text-overflow: ellipsis;\n                white-space: nowrap;\n                overflow: hidden;\n              `}\n            >\n              {parameters}\n            </div>\n          </Tooltip>\n        );\n      },\n    },\n    {\n      title: 'Method',\n      dataIndex: 'methodName',\n    },\n    {\n      title: 'TriggerId',\n      dataIndex: 'triggerId',\n      render: (_col: any, item: any) => {\n        return (\n          <Box\n            cursor=\"pointer\"\n            fontWeight=\"bold\"\n            onClick={() => {\n              handleClick(item.type, item.triggerId);\n            }}\n          >\n            {item.triggerId}\n          </Box>\n        );\n      },\n    },\n  ];\n\n  return (\n    <Box>\n      <DebugTable\n        className={css`\n          table-layout: fixed;\n          tbody td {\n            height: 40px;\n          }\n        `}\n        columns={eventColumns}\n        data={logs}\n        pagination={{ hideOnSinglePage: true, pageSize: count }}\n        emptyMessage=\"No Logs\"\n        footer={\n          !!logs.length && (\n            <Button\n              onClick={() => {\n                setLogs([]);\n              }}\n              size=\"sm\"\n            >\n              clear\n            </Button>\n          )\n        }\n      />\n    </Box>\n  );\n};\n","import { Props } from './type';\nimport React from 'react';\nimport { DebugTable } from './Table';\nimport { Box } from '@chakra-ui/react';\n\nexport const ErrorLogs: React.FC<Props> = ({ services }) => {\n  const { setSelectedComponentId } = services.editorStore;\n  const errorColumns = [\n    {\n      title: 'Component Id',\n      dataIndex: 'componentId',\n      render: (_col: any, item: any) => {\n        return (\n          <Box\n            cursor=\"pointer\"\n            fontWeight=\"bold\"\n            onClick={() => setSelectedComponentId(item.componentId)}\n          >\n            {item.componentId}\n          </Box>\n        );\n      },\n    },\n    {\n      title: 'Trait Type',\n      dataIndex: 'traitType',\n    },\n    {\n      title: 'Property',\n      dataIndex: 'property',\n    },\n    {\n      title: 'Message',\n      dataIndex: 'message',\n    },\n  ];\n\n  return (\n    <DebugTable\n      data={[]}\n      pagination={{ hideOnSinglePage: true }}\n      columns={errorColumns}\n      emptyMessage=\"No Errors\"\n    />\n  );\n};\n","import { ChevronDownIcon, ChevronUpIcon } from '@chakra-ui/icons';\nimport {\n  Badge,\n  Button,\n  HStack,\n  IconButton,\n  Tabs,\n  TabPanel,\n  TabPanels,\n  TabList,\n  Tab,\n  Box,\n} from '@chakra-ui/react';\nimport { observer } from 'mobx-react-lite';\nimport React, { useEffect, useMemo, useState } from 'react';\nimport { Logs } from './Logs';\nimport { ErrorLogs } from './ErrorLogs';\nimport type { Props, Log, DisplayedLog } from './type';\nimport produce from 'immer';\nimport { Resizable } from 're-resizable';\nimport { MERGE_STATE, MODULE_EVENT, paginationHeight, TRIGGER_EVENT } from './const';\n\nconst WARNING_AREA_COLLAPSED__MIN_HEIGHT = 48;\nconst WARNING_AREA_EXPANDED_MIN_HEIGHT = 320;\nconst WARNING_AREA_MAX_HEIGHT = 800;\nconst getMinHeight = (isCollapsed: boolean) => {\n  return isCollapsed\n    ? WARNING_AREA_COLLAPSED__MIN_HEIGHT\n    : WARNING_AREA_EXPANDED_MIN_HEIGHT;\n};\n\nexport const WarningArea: React.FC<Props> = observer(({ services }) => {\n  const { editorStore } = services;\n  const [isCollapsed, setIsCollapsed] = useState(true);\n  const [height, setHeight] = useState(WARNING_AREA_COLLAPSED__MIN_HEIGHT);\n  const [logs, setLogs] = useState<DisplayedLog[]>([]);\n\n  useEffect(() => {\n    const handler = (params: unknown) => {\n      setLogs(cur => {\n        return produce(cur, draft => {\n          const { name, triggerId, componentId, parameters, eventType, type, id } =\n            params as Log;\n          draft.unshift({\n            time: new Date().toLocaleTimeString(),\n            type,\n            eventType: eventType || type,\n            target: componentId || id,\n            parameters,\n            methodName: name,\n            triggerId: triggerId,\n          });\n        });\n      });\n    };\n    services.apiService.on('mergeState', params => {\n      handler({\n        ...params,\n        eventType: 'mergeState',\n        type: MERGE_STATE,\n      });\n    });\n    services.apiService.on('uiMethod', params => {\n      handler({\n        type: TRIGGER_EVENT,\n        ...params,\n      });\n    });\n    services.apiService.on('moduleEvent', params => {\n      handler({\n        ...params,\n        type: MODULE_EVENT,\n        eventType: 'moduleEvent',\n        triggerId: params.fromId,\n        componentId: params.fromId,\n      });\n    });\n    return () => {\n      services.apiService.off('mergeState');\n      services.apiService.off('uiMethod');\n      services.apiService.off('moduleEvent');\n    };\n  }, [services.apiService]);\n\n  const savedBadge = useMemo(() => {\n    return <Badge colorScheme=\"green\">Saved</Badge>;\n  }, []);\n\n  const unsaveBadge = useMemo(() => {\n    return (\n      <HStack>\n        <Button\n          colorScheme=\"red\"\n          variant=\"ghost\"\n          size=\"sm\"\n          onClick={() => editorStore.saveCurrentComponents()}\n        >\n          Save anyway\n        </Button>\n        <Badge colorScheme=\"red\">Unsave</Badge>\n      </HStack>\n    );\n  }, [editorStore]);\n  const tabListHeight = 40;\n\n  const logsCount = useMemo(() => {\n    const tableHeaderHeight = 40;\n    const tableCeilHight = 45;\n    const padding = 16;\n    return (\n      Math.floor(\n        (height - padding - tabListHeight - paginationHeight - tableHeaderHeight) /\n          tableCeilHight\n      ) || 1\n    );\n  }, [height]);\n\n  return (\n    <Resizable\n      size={{\n        width: '100%',\n        height: height,\n      }}\n      enable={{ top: true }}\n      maxHeight={WARNING_AREA_MAX_HEIGHT}\n      minHeight={WARNING_AREA_COLLAPSED__MIN_HEIGHT}\n      snap={{ y: [WARNING_AREA_COLLAPSED__MIN_HEIGHT] }}\n      snapGap={WARNING_AREA_COLLAPSED__MIN_HEIGHT}\n      onResizeStop={(_e, _direction, _ref, d) => {\n        setHeight(prevH => prevH + d.height);\n        if (height + d.height === WARNING_AREA_COLLAPSED__MIN_HEIGHT) {\n          setIsCollapsed(true);\n        } else {\n          setIsCollapsed(false);\n        }\n      }}\n    >\n      <Box\n        h=\"full\"\n        position=\"absolute\"\n        bottom=\"0\"\n        left=\"0\"\n        right=\"0\"\n        paddingY=\"2\"\n        paddingX=\"4\"\n        boxShadow=\"0 0 4px rgba(0, 0, 0, 0.1)\"\n        background=\"white\"\n        width=\"full\"\n      >\n        <Tabs h=\"full\" w=\"full\" variant=\"soft-rounded\" colorScheme=\"gray\">\n          <TabList>\n            <Tab>Logs</Tab>\n            <HStack w=\"full\" justify=\"end\">\n              {editorStore.isSaved ? savedBadge : unsaveBadge}\n              <IconButton\n                aria-label=\"show errors\"\n                size=\"sm\"\n                variant=\"ghost\"\n                icon={isCollapsed ? <ChevronUpIcon /> : <ChevronDownIcon />}\n                onClick={() => {\n                  setIsCollapsed(prev => !prev);\n                  setHeight(getMinHeight(!isCollapsed));\n                }}\n              />\n            </HStack>\n          </TabList>\n          {!isCollapsed && (\n            <TabPanels h={height - tabListHeight}>\n              <TabPanel h=\"full\" overflow=\"auto\">\n                <ErrorLogs services={services} />\n              </TabPanel>\n              <TabPanel h=\"full\" overflow=\"auto\">\n                <Logs\n                  setLogs={setLogs}\n                  services={services}\n                  logs={logs}\n                  count={logsCount}\n                />\n              </TabPanel>\n            </TabPanels>\n          )}\n        </Tabs>\n      </Box>\n    </Resizable>\n  );\n});\n","import React from 'react';\nimport { Box, Text } from '@chakra-ui/react';\n\nexport const SlotDropArea: React.FC<{\n  componentId: string;\n  slotId: string;\n  isOver: boolean;\n}> = ({ componentId, slotId, isOver }) => {\n  return (\n    <Box flex=\"1 1 0\" position=\"relative\">\n      <Text\n        position=\"absolute\"\n        text-align=\"center\"\n        top=\"50%\"\n        left=\"50%\"\n        transform=\"translate(-50%, -50%)\"\n      >\n        {componentId}-{slotId}\n      </Text>\n      <Box\n        top=\"4px\"\n        bottom=\"4px\"\n        left=\"4px\"\n        right=\"4px\"\n        position=\"absolute\"\n        transform=\"translate3d(0, 0, 0)\"\n        opacity=\"0.5\"\n        backgroundColor={isOver ? 'orange' : undefined}\n        boxShadow={isOver ? '0px 0px 30px rgba(0, 0, 0, 0.6)' : undefined}\n      />\n    </Box>\n  );\n};\n","import React, { useEffect, useMemo, useRef, useState } from 'react';\nimport { observer } from 'mobx-react-lite';\nimport { Box } from '@chakra-ui/react';\nimport { SlotDropArea } from './SlotDropArea';\nimport { EditorServices } from '../../types';\nimport { CORE_VERSION, CoreComponentName } from '@sunmao-ui/shared';\n\nconst verticalStackList = ['chakra_ui/v1/vstack'];\n\ntype Props = {\n  services: EditorServices;\n  hoverId: string;\n  mousePosition: [number, number];\n  dragOverSlotRef: React.MutableRefObject<string>;\n};\n\nexport const DropSlotMask: React.FC<Props> = observer((props: Props) => {\n  const { services, hoverId, mousePosition, dragOverSlotRef } = props;\n  const { registry, editorStore } = services;\n  const [dragOverSlot, setDragOverSlot] = useState('');\n  const maskRef = useRef<HTMLDivElement>(null);\n\n  const hoverComponentType =\n    editorStore.components.find(c => c.id === hoverId)?.type ||\n    `${CORE_VERSION}/${CoreComponentName.Text}`;\n\n  const slots = useMemo(() => {\n    return Object.keys(registry.getComponentByType(hoverComponentType).spec.slots) || [];\n  }, [hoverComponentType, registry]);\n\n  // calculate the slot which is being dragged over\n  useEffect(() => {\n    if (!maskRef.current) return;\n    const maskRect = maskRef.current?.getBoundingClientRect();\n    const index = Math.floor(\n      (mousePosition[0] - maskRect.left) / (maskRect.width / slots.length)\n    );\n    setDragOverSlot(slots[index]);\n    dragOverSlotRef.current = slots[index];\n  }, [dragOverSlotRef, mousePosition, slots]);\n\n  const vertical = useMemo(() => {\n    if (!hoverComponentType) return false;\n    verticalStackList.includes(hoverComponentType);\n  }, [hoverComponentType]);\n\n  const isDroppable = slots.length > 0;\n\n  if (!isDroppable) {\n    return null;\n  }\n\n  return (\n    <Box\n      position=\"absolute\"\n      top=\"0\"\n      bottom=\"0\"\n      left=\"0\"\n      right=\"0\"\n      display=\"flex\"\n      flexDirection={vertical ? 'column' : 'row'}\n      ref={maskRef}\n      border=\"1px solid orange\"\n    >\n      {slots.map(slot => {\n        return (\n          <SlotDropArea\n            key={slot}\n            componentId={hoverId}\n            isOver={dragOverSlot === slot}\n            slotId={slot}\n          />\n        );\n      })}\n    </Box>\n  );\n});\n","import { debounce } from 'lodash';\nimport { action, autorun, makeObservable, observable } from 'mobx';\nimport React from 'react';\nimport { traverse as traverseFiber } from 'react-fiber-traverse';\nimport { EditorServices } from '../../types';\n\ntype MaskPosition = {\n  id: string;\n  style: {\n    top: number;\n    left: number;\n    height: number;\n    width: number;\n  };\n};\nexport class EditorMaskManager {\n  hoverMaskPosition: MaskPosition | null = null;\n  selectedMaskPosition: MaskPosition | null = null;\n  mousePosition: [number, number] = [0, 0];\n  // the elements get by fiber\n  private fiberEleMap = new Map<string, Element>();\n  private elementIdMap = new Map<Element, string>();\n  // rect of mask container\n  private maskContainerRect: DOMRect | null = null;\n  private resizeObserver: ResizeObserver;\n  private containerResizeObserver: ResizeObserver | null = null;\n  private visibleMap = new Map<Element, boolean>();\n  private intersectionObserver: IntersectionObserver;\n  private MaskPadding = 4;\n  private lastHoverElement: Element | null = null;\n\n  get hoverComponentId() {\n    return this.services.editorStore.hoverComponentId;\n  }\n\n  constructor(\n    public services: EditorServices,\n    public wrapperRef: React.MutableRefObject<HTMLDivElement | null>,\n    public maskContainerRef: React.MutableRefObject<HTMLDivElement | null>\n  ) {\n    makeObservable(this, {\n      mousePosition: observable,\n      hoverMaskPosition: observable.ref,\n      selectedMaskPosition: observable.ref,\n      setMousePosition: action,\n      setHoverMaskPosition: action,\n      setSelectedMaskPosition: action,\n    });\n\n    this.resizeObserver = new ResizeObserver(() => {\n      this.refreshHoverElement();\n    });\n\n    this.intersectionObserver = this.initIntersectionObserver();\n    // listen to the DOM elements' mount and unmount events\n    // TODO: This is not very accurate, because sunmao runtime 'didDOMUpdate' hook is not accurate.\n    // We will refactor the 'didDOMUpdate' hook with components' life cycle in the future.\n    this.services.eventBus.on('HTMLElementsUpdated', this.onHTMLElementsUpdated);\n\n    // listen scroll events\n    // scroll events' timing is similar to intersection events, but they are different. Both of them are necessary.\n    this.services.eventBus.on('MaskWrapperScrollCapture', this.onScroll);\n  }\n\n  init() {\n    this.unsafeAutoFindNoRefElement();\n    this.updateElementIdMap();\n    this.observeContainerResize();\n    this.observeIntersection();\n    this.observeResize();\n\n    // when hoverComponentId & selectedComponentId change, refresh mask position\n    autorun(() => {\n      this.refreshMaskPosition();\n    });\n\n    // listen mousePosition change to refreshHoverElement\n    autorun(() => {\n      this.refreshHoverElement();\n    });\n  }\n\n  destroy() {\n    this.intersectionObserver.disconnect();\n    this.resizeObserver.disconnect();\n    this.containerResizeObserver?.disconnect();\n    this.services.eventBus.off('HTMLElementsUpdated', this.onHTMLElementsUpdated);\n\n    // listen scroll events\n    // scroll events' timing is similar to intersection events, but they are different. Both of them are necessary.\n    this.services.eventBus.off('MaskWrapperScrollCapture', this.onScroll);\n  }\n\n  private initIntersectionObserver(): IntersectionObserver {\n    const options = {\n      root: null,\n      rootMargin: '0px',\n      threshold: buildThresholdList(),\n    };\n\n    return new IntersectionObserver(entries => {\n      // Update visibleMap.\n      // Every time intersection observer is triggered, some components' visibility must have changed.\n      entries.forEach(e => {\n        this.visibleMap.set(e.target, e.isIntersecting);\n      });\n      // Refresh the mask, because the component visibility changed,\n      this.refreshMaskPosition();\n    }, options);\n  }\n\n  // listen resize events of dom elements\n  private observeResize() {\n    this.resizeObserver.disconnect();\n    this.eleMap.forEach(ele => {\n      this.resizeObserver.observe(ele);\n    });\n    this.fiberEleMap.forEach(ele => {\n      this.intersectionObserver.observe(ele);\n    });\n  }\n\n  private observeContainerResize() {\n    this.containerResizeObserver = new ResizeObserver(() => {\n      this.maskContainerRect =\n        this.maskContainerRef.current?.getBoundingClientRect() || null;\n    });\n\n    this.containerResizeObserver.observe(this.maskContainerRef.current!);\n  }\n\n  private observeIntersection() {\n    this.intersectionObserver.disconnect();\n    this.eleMap.forEach(ele => {\n      this.intersectionObserver.observe(ele);\n    });\n    this.fiberEleMap.forEach(ele => {\n      this.intersectionObserver.observe(ele);\n    });\n  }\n\n  private onHTMLElementsUpdated = debounce(() => {\n    this.unsafeAutoFindNoRefElement();\n    this.updateElementIdMap();\n    this.observeIntersection();\n    this.observeResize();\n    this.refreshHoverElement();\n    this.refreshMaskPosition();\n  }, 16);\n\n  private onScroll = () => {\n    this.refreshHoverElement();\n    this.refreshMaskPosition();\n  };\n\n  private getHTMLElement(id: string) {\n    return this.eleMap.get(id) || this.fiberEleMap.get(id);\n  }\n\n  private getMaskPosition(id: string) {\n    if (!id) return null;\n    const rect = this.getHTMLElement(id)?.getBoundingClientRect();\n    if (!this.maskContainerRect || !rect) return null;\n    return {\n      id,\n      style: {\n        top:\n          rect.top -\n          this.maskContainerRect.top -\n          this.MaskPadding +\n          this.wrapperScrollTop,\n        left:\n          rect.left -\n          this.maskContainerRect.left -\n          this.MaskPadding +\n          this.wrapperScrollLeft,\n        height: rect.height + this.MaskPadding * 2,\n        width: rect.width + this.MaskPadding * 2,\n      },\n    };\n  }\n\n  private updateElementIdMap() {\n    // generate elementIdMap, this only aim to improving the  performance of refreshHoverElement method\n    this.eleMap.forEach((ele, id) => {\n      this.elementIdMap.set(ele, id);\n    });\n    this.fiberEleMap.forEach((ele, id) => {\n      this.elementIdMap.set(ele, id);\n    });\n  }\n\n  private getElementsByFiber(ids: string[]): Record<string, HTMLElement | undefined> {\n    const map: Record<string, HTMLElement | undefined> = {};\n    const rootFiberNode = (document.getElementById('root') as any)._reactRootContainer\n      ._internalRoot.current;\n    traverseFiber(rootFiberNode, (fiber: any) => {\n      if (!fiber.memoizedProps) {\n        return;\n      }\n      const componentId = fiber.memoizedProps['data-sunmao-id'];\n      const i = ids.indexOf(componentId);\n      if (i === -1) {\n        return;\n      }\n      ids.splice(i, 1);\n      // find the nearest child HTMLElement\n      let curr = fiber;\n      while (!curr.stateNode && curr.child) {\n        curr = curr.child;\n      }\n      if (curr.stateNode instanceof HTMLElement) {\n        map[componentId] = curr.stateNode;\n      }\n    });\n    return map;\n  }\n\n  // Auto find the components that does not have ref by React Fiber\n  // This function is a fallback.\n  // And because it uses React Fiber, it is not stable.\n  private unsafeAutoFindNoRefElement() {\n    try {\n      const noEleComponentIds: string[] = [];\n      this.services.appModelManager.appModel.allComponents.forEach(c => {\n        if (!this.eleMap.has(c.id)) {\n          const eleFromFiber = this.fiberEleMap.get(c.id);\n          if (!eleFromFiber || !eleFromFiber.isConnected) {\n            noEleComponentIds.push(c.id);\n          }\n        }\n      });\n      if (noEleComponentIds.length === 0) return;\n      const fiberElements = this.getElementsByFiber(noEleComponentIds);\n      for (const key in fiberElements) {\n        const ele = fiberElements[key];\n        if (ele) this.fiberEleMap.set(key, ele);\n      }\n    } catch {}\n  }\n\n  private refreshHoverElement() {\n    const hoverElement = document.elementFromPoint(\n      this.mousePosition[0] - this.wrapperScrollLeft,\n      this.mousePosition[1] - this.wrapperScrollTop\n    );\n    if (!hoverElement) return;\n    if (hoverElement === this.lastHoverElement) return;\n    const root = this.wrapperRef.current;\n\n    // check all the parents of hoverElement, until find a sunmao component's element\n    let curr = hoverElement;\n    while (!this.elementIdMap.has(curr)) {\n      if (curr !== root && curr.parentElement) {\n        curr = curr.parentElement;\n      } else {\n        break;\n      }\n    }\n\n    this.lastHoverElement = hoverElement;\n    this.services.editorStore.setHoverComponentId(this.elementIdMap.get(curr) || '');\n  }\n\n  private refreshMaskPosition() {\n    this.setHoverMaskPosition(this.getMaskPosition(this.hoverComponentId));\n    const selectedComponentId = this.services.editorStore.selectedComponentId;\n    const selectedComponentEle = this.getHTMLElement(selectedComponentId);\n    if (selectedComponentEle && this.visibleMap.get(selectedComponentEle)) {\n      this.setSelectedMaskPosition(this.getMaskPosition(selectedComponentId));\n    } else {\n      this.setSelectedMaskPosition(null);\n    }\n  }\n\n  setMousePosition(mousePosition: [number, number]) {\n    this.mousePosition = mousePosition;\n  }\n\n  setHoverMaskPosition(hoverMaskPosition: MaskPosition | null) {\n    this.hoverMaskPosition = hoverMaskPosition;\n  }\n\n  setSelectedMaskPosition(selectedMaskPosition: MaskPosition | null) {\n    this.selectedMaskPosition = selectedMaskPosition;\n  }\n\n  private get eleMap() {\n    return this.services.editorStore.eleMap;\n  }\n\n  private get wrapperScrollTop() {\n    return this.wrapperRef.current?.scrollTop || 0;\n  }\n\n  private get wrapperScrollLeft() {\n    return this.wrapperRef.current?.scrollLeft || 0;\n  }\n}\n\nfunction buildThresholdList() {\n  const thresholds: number[] = [];\n  const numSteps = 20;\n\n  for (let i = 1.0; i <= numSteps; i++) {\n    const ratio = i / numSteps;\n    thresholds.push(ratio);\n  }\n\n  thresholds.push(0);\n  return thresholds;\n}\n","import React, { CSSProperties, useEffect, useRef } from 'react';\nimport { css } from '@emotion/css';\nimport { Box, Text } from '@chakra-ui/react';\nimport { observer, useLocalObservable } from 'mobx-react-lite';\nimport { DropSlotMask } from './DropSlotMask';\nimport { EditorMaskManager } from './EditorMaskManager';\nimport { EditorServices } from '../../types';\n\nconst outlineMaskTextStyle = css`\n  position: absolute;\n  z-index: 1;\n  right: 0px;\n  padding: 0 4px;\n  height: 20px;\n  right: 0;\n  max-width: 100%;\n  color: white;\n  font-size: 14px;\n  white-space: nowrap;\n  text-overflow: ellipsis;\n  overflow: hidden;\n  border-top-left-radius: 4px;\n  border-top-right-radius: 4px;\n  transform: translateY(-100%);\n`;\n\nconst outlineMaskStyle = css`\n  position: absolute;\n  border: 1px solid transparent;\n  /* create a bfc */\n  transform: translate3d(0, 0, 0);\n  z-index: 10;\n  top: 0;\n  left: 0;\n  width: 0;\n  height: 0;\n  pointer-events: none;\n`;\n\ntype Props = {\n  services: EditorServices;\n  mousePosition: [number, number];\n  dragOverSlotRef: React.MutableRefObject<string>;\n  wrapperRef: React.MutableRefObject<HTMLDivElement | null>;\n};\n\n// Read this pr to understand the coordinates system before you modify this component.\n// https://github.com/smartxworks/sunmao-ui/pull/286\nexport const EditorMask: React.FC<Props> = observer((props: Props) => {\n  const { services, mousePosition, wrapperRef, dragOverSlotRef } = props;\n  const { editorStore } = services;\n  const { isDraggingNewComponent, hoverComponentId } = editorStore;\n  const maskContainerRef = useRef<HTMLDivElement>(null);\n\n  const manager = useLocalObservable(\n    () => new EditorMaskManager(services, wrapperRef, maskContainerRef)\n  );\n\n  const { hoverMaskPosition, selectedMaskPosition } = manager;\n\n  useEffect(() => {\n    setTimeout(() => {\n      manager.init();\n    }, 0);\n    return () => {\n      manager.destroy();\n    };\n  }, [manager]);\n\n  useEffect(() => {\n    if (mousePosition[0] > 0 && mousePosition[1] > 0) {\n      manager.setMousePosition(mousePosition);\n    }\n  }, [manager, mousePosition]);\n\n  const hoverMask = hoverMaskPosition ? (\n    <HoverMask style={hoverMaskPosition.style} id={hoverMaskPosition.id} />\n  ) : undefined;\n\n  const dragMask = hoverMaskPosition ? (\n    <Box className={outlineMaskStyle} style={hoverMaskPosition.style} zIndex=\"2\">\n      <DropSlotMask\n        services={services}\n        hoverId={hoverComponentId}\n        mousePosition={mousePosition}\n        dragOverSlotRef={dragOverSlotRef}\n      />\n    </Box>\n  ) : undefined;\n\n  const selectMask = selectedMaskPosition ? (\n    <SelectMask style={selectedMaskPosition.style} id={selectedMaskPosition.id} />\n  ) : undefined;\n\n  return (\n    <Box\n      id=\"editor-mask-container\"\n      position=\"absolute\"\n      top=\"0\"\n      left=\"0\"\n      right=\"0\"\n      bottom=\"0\"\n      pointerEvents=\"none\"\n      zIndex=\"editorMask\"\n      ref={maskContainerRef}\n    >\n      {isDraggingNewComponent ? dragMask : hoverMask}\n      {selectMask}\n    </Box>\n  );\n});\n\ntype MaskProps = {\n  style: CSSProperties;\n  id: string;\n};\n\nconst HoverMask: React.FC<MaskProps> = (props: MaskProps) => {\n  return (\n    <Box\n      className={outlineMaskStyle}\n      borderColor=\"gray.700\"\n      zIndex=\"1\"\n      style={props.style}\n    >\n      <Text className={outlineMaskTextStyle} background=\"gray.700\">\n        {props.id}\n      </Text>\n    </Box>\n  );\n};\n\nconst SelectMask: React.FC<MaskProps> = (props: MaskProps) => {\n  return (\n    <Box\n      className={outlineMaskStyle}\n      borderColor=\"blue.500\"\n      zIndex=\"0\"\n      style={props.style}\n    >\n      <Text className={outlineMaskTextStyle} background=\"blue.500\">\n        {props.id}\n      </Text>\n    </Box>\n  );\n};\n","import React, { useMemo, useRef, useState, useEffect } from 'react';\nimport { EditorServices } from '../../types';\nimport { observer } from 'mobx-react-lite';\nimport { Box } from '@chakra-ui/react';\nimport { EditorMask } from './EditorMask';\nimport { throttle } from 'lodash';\nimport { ExplorerMenuTabs } from '../../constants/enum';\nimport { genOperation } from '../../operations';\n\ntype Props = {\n  services: EditorServices;\n};\n\nexport const EditorMaskWrapper: React.FC<Props> = observer(props => {\n  const { children, services } = props;\n  const { editorStore, eventBus, registry } = services;\n  const {\n    setSelectedComponentId,\n    setExplorerMenuTab,\n    selectedComponentId,\n    hoverComponentId,\n  } = editorStore;\n  const [mousePosition, setMousePosition] = useState<[number, number]>([0, 0]);\n  const [scrollOffset, setScrollOffset] = useState<[number, number]>([0, 0]);\n  const wrapperRef = useRef<HTMLDivElement | null>(null);\n  const dragOverSlotRef = useRef<string>('');\n\n  const onMouseMove = (e: React.MouseEvent<HTMLDivElement>) => {\n    setMousePosition([e.clientX, e.clientY]);\n  };\n  const onMouseLeave = () => {\n    setMousePosition([-Infinity, -Infinity]);\n  };\n  const onScroll = () => {\n    if (wrapperRef.current) {\n      setScrollOffset([wrapperRef.current.scrollLeft, wrapperRef.current.scrollTop]);\n      eventBus.send('MaskWrapperScrollCapture');\n    }\n  };\n\n  const onClick = () => {\n    if (hoverComponentId) {\n      setSelectedComponentId(hoverComponentId);\n    }\n  };\n\n  const throttleSetMousePosition = useMemo(() => {\n    return throttle((position: [number, number]) => {\n      setMousePosition(position);\n    }, 50);\n  }, [setMousePosition]);\n\n  const onDragOver = (e: React.MouseEvent<HTMLDivElement>) => {\n    e.preventDefault();\n    throttleSetMousePosition([e.clientX, e.clientY]);\n  };\n\n  const onDrop = (e: React.DragEvent) => {\n    e.stopPropagation();\n    e.preventDefault();\n    setExplorerMenuTab(ExplorerMenuTabs.UI_TREE);\n    const creatingComponent = e.dataTransfer?.getData('component') || '';\n    eventBus.send(\n      'operation',\n      genOperation(registry, 'createComponent', {\n        componentType: creatingComponent,\n        parentId: hoverComponentId,\n        slot: dragOverSlotRef.current,\n      })\n    );\n  };\n\n  useEffect(() => {\n    // can't capture the iframe click event\n    // use `setInterval` to check whether the iframe is selected\n    const timer = setInterval(function () {\n      if (document.activeElement?.tagName === 'IFRAME') {\n        const currentSelectedComponentId =\n          document.activeElement?.getAttribute('title') || '';\n\n        if (selectedComponentId !== currentSelectedComponentId) {\n          setSelectedComponentId(currentSelectedComponentId);\n        }\n      }\n    }, 100);\n\n    return () => {\n      clearInterval(timer);\n    };\n  });\n\n  const mousePositionWithOffset: [number, number] = [\n    mousePosition[0] + scrollOffset[0],\n    mousePosition[1] + scrollOffset[1],\n  ];\n\n  return (\n    <Box\n      id=\"editor-mask-wrapper\"\n      width=\"full\"\n      height=\"full\"\n      overflow=\"auto\"\n      position=\"relative\"\n      padding=\"20px\"\n      // some components stop click event propagation, so here we should capture onClick\n      onClickCapture={onClick}\n      onMouseMove={onMouseMove}\n      onMouseLeave={onMouseLeave}\n      onDragOver={onDragOver}\n      onDrop={onDrop}\n      // here we use capture to detect all the components and their children's scroll event\n      // because every scroll event may change their children's location in coordinates system\n      onScrollCapture={onScroll}\n      ref={wrapperRef}\n    >\n      {children}\n      <EditorMask\n        services={services}\n        mousePosition={mousePositionWithOffset}\n        dragOverSlotRef={dragOverSlotRef}\n        wrapperRef={wrapperRef}\n      />\n    </Box>\n  );\n});\n","import React from 'react';\nimport {\n  FormControl,\n  FormErrorMessage,\n  FormLabel,\n  HStack,\n  Input,\n  VStack,\n} from '@chakra-ui/react';\nimport { useFormik } from 'formik';\nimport { observer } from 'mobx-react-lite';\nimport { EditorServices } from '../../../types';\n\nexport type AppMetaDataFormData = {\n  name: string;\n  version: string;\n};\n\ntype AppMetaDataFormProps = {\n  data: AppMetaDataFormData;\n  services: EditorServices;\n  onSubmit?: (data: AppMetaDataFormData) => void;\n};\n\nexport const AppMetaDataForm: React.FC<AppMetaDataFormProps> = observer(\n  ({ data, services, onSubmit: onSubmitForm }) => {\n    const { editorStore } = services;\n    const onSubmit = (value: AppMetaDataFormData) => {\n      editorStore.appStorage.saveAppMetaData(value);\n      onSubmitForm?.(value);\n    };\n    const formik = useFormik({\n      initialValues: data,\n      onSubmit,\n    });\n\n    const isAppVersionError = formik.values.version === '';\n    const isAppNameError = formik.values.name === '';\n    return (\n      <VStack w=\"full\" spacing=\"5\">\n        <HStack w=\"full\" align=\"normal\">\n          <FormControl isInvalid={isAppVersionError}>\n            <HStack align=\"normal\">\n              <FormLabel>Version</FormLabel>\n              <VStack w=\"full\" align=\"normal\">\n                <Input\n                  name=\"version\"\n                  value={formik.values.version}\n                  onChange={formik.handleChange}\n                  onBlur={() => {\n                    if (formik.values.version && formik.values.name) {\n                      formik.submitForm();\n                    }\n                  }}\n                />\n                {isAppVersionError && (\n                  <FormErrorMessage>\n                    Application version can not be empty\n                  </FormErrorMessage>\n                )}\n              </VStack>\n            </HStack>\n          </FormControl>\n          <FormControl isInvalid={isAppNameError}>\n            <HStack align=\"normal\">\n              <FormLabel>Name</FormLabel>\n              <VStack w=\"full\" align=\"normal\">\n                <Input\n                  name=\"name\"\n                  value={formik.values.name}\n                  onChange={formik.handleChange}\n                  onBlur={() => {\n                    if (formik.values.version && formik.values.name) {\n                      formik.submitForm();\n                    }\n                  }}\n                />\n                {isAppNameError && (\n                  <FormErrorMessage>Application name can not be empty</FormErrorMessage>\n                )}\n              </VStack>\n            </HStack>\n          </FormControl>\n        </HStack>\n      </VStack>\n    );\n  }\n);\n","import React, { useRef } from 'react';\nimport { observer } from 'mobx-react-lite';\nimport { Button, ButtonGroup, Spacer, VStack } from '@chakra-ui/react';\nimport { AppMetaDataForm, AppMetaDataFormData } from './AppMetaDataForm';\nimport { ModuleMetaDataForm, ModuleMetaDataFormData } from './ModuleMetaDataForm';\nimport { EditorServices } from '../../../types';\nimport { Type } from '@sinclair/typebox';\nimport { cloneDeep } from 'lodash';\nimport { json2JsonSchema } from '@sunmao-ui/editor-sdk';\n\ntype Props = {\n  formType: 'app' | 'module';\n  version: string;\n  name: string;\n  setCurrentVersion?: (version: string) => void;\n  setCurrentName?: (name: string) => void;\n  services: EditorServices;\n  onClose: () => void;\n};\n\nexport const ExplorerForm: React.FC<Props> = observer(\n  ({ formType, version, name, setCurrentVersion, setCurrentName, services, onClose }) => {\n    const { editorStore } = services;\n    const newModuleMetaDataRef = useRef<ModuleMetaDataFormData | undefined>();\n    const newAppMetaDataRef = useRef<AppMetaDataFormData | undefined>();\n    const onModuleMetaDataChange = (value: ModuleMetaDataFormData) => {\n      newModuleMetaDataRef.current = value;\n    };\n    const onAppMetaDataChange = (value: AppMetaDataFormData) => {\n      newAppMetaDataRef.current = value;\n    };\n    const saveModuleMetaData = () => {\n      if (!newModuleMetaDataRef.current) return;\n      const propertiesSpec = json2JsonSchema(\n        services.stateManager.deepEval(newModuleMetaDataRef.current.exampleProperties)\n      );\n      editorStore.appStorage.saveModuleMetaData(\n        { originName: name, originVersion: version },\n        { ...newModuleMetaDataRef.current, properties: propertiesSpec }\n      );\n      editorStore.setModuleDependencies(newModuleMetaDataRef.current.exampleProperties);\n      setCurrentVersion?.(newModuleMetaDataRef.current.version);\n      setCurrentName?.(newModuleMetaDataRef.current.name);\n    };\n    const saveAppMetaData = () => {\n      if (!newAppMetaDataRef.current) return;\n      editorStore.appStorage.saveAppMetaData(newAppMetaDataRef.current);\n      setCurrentVersion?.(newAppMetaDataRef.current.version);\n      setCurrentName?.(newAppMetaDataRef.current.name);\n    };\n\n    const onSave = () => {\n      switch (formType) {\n        case 'app':\n          saveAppMetaData();\n          break;\n        case 'module':\n          saveModuleMetaData();\n          break;\n      }\n      onClose();\n    };\n\n    let form;\n    switch (formType) {\n      case 'app':\n        const appMetaData = {\n          name,\n          version,\n        };\n        form = (\n          <AppMetaDataForm\n            data={appMetaData}\n            services={services}\n            onSubmit={onAppMetaDataChange}\n          />\n        );\n        break;\n      case 'module':\n        // Don't get from registry, because module from registry has __$moduleId\n        const moduleSpec = editorStore.appStorage.modules.find(\n          m => m.version === version && m.metadata.name === name\n        )!;\n\n        const moduleMetaData = cloneDeep({\n          name,\n          version,\n          stateMap: moduleSpec?.spec.stateMap || {},\n          properties: moduleSpec?.spec.properties || Type.Object({}),\n          exampleProperties: moduleSpec?.metadata.exampleProperties || {},\n          events: moduleSpec?.spec.events || [],\n          methods: moduleSpec?.spec.methods || [],\n        });\n        form = (\n          <ModuleMetaDataForm\n            services={services}\n            initData={moduleMetaData}\n            onSubmit={onModuleMetaDataChange}\n          />\n        );\n        break;\n    }\n\n    return (\n      <VStack h=\"full\" w=\"full\" alignItems=\"end\">\n        {form}\n        <Spacer />\n        <ButtonGroup flex=\"0 0\">\n          <Button variant=\"outline\" onClick={() => onClose()}>\n            Cancel\n          </Button>\n          <Button colorScheme=\"blue\" onClick={() => onSave()}>\n            Save\n          </Button>\n        </ButtonGroup>\n      </VStack>\n    );\n  }\n);\n","import React from 'react';\nimport { Divider, HStack, IconButton, Text, Tooltip, VStack } from '@chakra-ui/react';\nimport { observer } from 'mobx-react-lite';\nimport { AddIcon, DeleteIcon, EditIcon } from '@chakra-ui/icons';\nimport { EditorServices } from '../../types';\n\ntype ExplorerTreeProps = {\n  onEdit: (kind: 'app' | 'module', version: string, name: string) => void;\n  services: EditorServices;\n};\n\nfunction genItemId(kind: 'app' | 'module', version: string, name: string) {\n  return `${kind}-${version}-${name}`;\n}\n\nexport const ExplorerTree: React.FC<ExplorerTreeProps> = observer(\n  ({ onEdit, services }) => {\n    const { editorStore } = services;\n    const { app, modules, currentEditingTarget, updateCurrentEditingTarget } =\n      editorStore;\n    const appItemId = genItemId('app', app.version, app.metadata.name);\n    const [selectedItem, setSelectedItem] = React.useState<string | undefined>(\n      genItemId(\n        currentEditingTarget.kind,\n        currentEditingTarget.version,\n        currentEditingTarget.name\n      )\n    );\n\n    const onClickApp = () => {\n      setSelectedItem(appItemId);\n      updateCurrentEditingTarget('app', app.version, app.metadata.name);\n    };\n    const onEditApp = () => {\n      onEdit('app', app.version, app.metadata.name);\n    };\n\n    const appEditable =\n      currentEditingTarget.kind === 'app' &&\n      currentEditingTarget.name === app.metadata.name &&\n      currentEditingTarget.version === app.version;\n\n    const appItem = (\n      <ExplorerTreeItem\n        key={app.metadata.name}\n        title={`${app.version}/${app.metadata.name}`}\n        onClick={onClickApp}\n        isActive={selectedItem === appItemId}\n        onEdit={onEditApp}\n        editable={appEditable}\n      />\n    );\n\n    const moduleItems = modules.map(module => {\n      const moduleItemId = genItemId('module', module.version, module.metadata.name);\n      const onClickModule = () => {\n        setSelectedItem(moduleItemId);\n        updateCurrentEditingTarget(\n          'module',\n          module.version,\n          module.metadata.name,\n          module.spec,\n          module.metadata\n        );\n      };\n      const onEditModule = () => {\n        onEdit('module', module.version, module.metadata.name);\n      };\n      const onRemove = () => {\n        editorStore.appStorage.removeModule(module.version, module.metadata.name);\n      };\n      const editable =\n        currentEditingTarget.kind === 'module' &&\n        currentEditingTarget.name === module.metadata.name &&\n        currentEditingTarget.version === module.version;\n      return (\n        <ExplorerTreeItem\n          key={module.metadata.name}\n          title={`${module.version}/${module.metadata.name}`}\n          onClick={onClickModule}\n          onRemove={onRemove}\n          isActive={selectedItem === moduleItemId}\n          onEdit={onEditModule}\n          editable={editable}\n        />\n      );\n    });\n\n    return (\n      <VStack alignItems=\"start\">\n        <Text fontSize=\"lg\" fontWeight=\"bold\">\n          Applications\n        </Text>\n        {appItem}\n        <Divider />\n        <HStack width=\"full\" justifyContent=\"space-between\">\n          <Text fontSize=\"lg\" fontWeight=\"bold\">\n            Modules\n          </Text>\n          <IconButton\n            aria-label=\"create module\"\n            size=\"xs\"\n            icon={<AddIcon />}\n            onClick={() => editorStore.appStorage.createModule({})}\n          />\n        </HStack>\n        {moduleItems}\n      </VStack>\n    );\n  }\n);\n\ntype ExplorerTreeItemProps = {\n  title: string;\n  isActive: boolean;\n  onClick: () => void;\n  onEdit: () => void;\n  editable: boolean;\n  onRemove?: () => void;\n};\n\nconst ExplorerTreeItem: React.FC<ExplorerTreeItemProps> = ({\n  title,\n  isActive,\n  onClick,\n  onRemove,\n  onEdit,\n  editable,\n}) => {\n  const _onEdit = (e: React.MouseEvent<HTMLElement>) => {\n    e.stopPropagation();\n    onEdit();\n  };\n  return (\n    <HStack\n      width=\"full\"\n      justify=\"space-between\"\n      cursor=\"pointer\"\n      borderRadius=\"5\"\n      padding=\"2\"\n      backgroundColor={isActive ? 'gray.100' : 'white'}\n    >\n      <Tooltip label={title} openDelay={500}>\n        <Text\n          fontSize=\"lg\"\n          overflow=\"hidden\"\n          whiteSpace=\"nowrap\"\n          textOverflow=\"ellipsis\"\n          onClick={onClick}\n        >\n          {title}\n        </Text>\n      </Tooltip>\n      <HStack>\n        {editable ? (\n          <IconButton\n            variant=\"ghost\"\n            size=\"smx\"\n            aria-label=\"edit\"\n            icon={<EditIcon />}\n            onClick={_onEdit}\n          />\n        ) : null}\n        {onRemove ? (\n          <IconButton\n            variant=\"ghost\"\n            size=\"smx\"\n            aria-label=\"remove\"\n            icon={<DeleteIcon />}\n            onClick={onRemove}\n          />\n        ) : null}\n      </HStack>\n    </HStack>\n  );\n};\n","import React from 'react';\nimport ErrorBoundary from '../ErrorBoundary';\nimport { ExplorerForm } from './ExplorerForm/ExplorerForm';\nimport { ExplorerTree } from './ExplorerTree';\nimport { EditorServices } from '../../types';\nimport {\n  Box,\n  Modal,\n  ModalBody,\n  ModalCloseButton,\n  ModalContent,\n  ModalHeader,\n  ModalOverlay,\n} from '@chakra-ui/react';\n\ntype Props = {\n  services: EditorServices;\n};\n\nexport const Explorer: React.FC<Props> = ({ services }) => {\n  const [isEditingMode, setIsEditingMode] = React.useState(false);\n  const [formType, setFormType] = React.useState<'app' | 'module'>('app');\n  const [currentVersion, setCurrentVersion] = React.useState<string>('');\n  const [currentName, setCurrentName] = React.useState<string>('');\n  const onEdit = (type: 'app' | 'module', version: string, name: string) => {\n    setFormType(type);\n    setCurrentVersion(version);\n    setCurrentName(name);\n    setIsEditingMode(true);\n  };\n\n  return (\n    <ErrorBoundary>\n      <Box padding={4}>\n        <ExplorerTree onEdit={onEdit} services={services} />\n        <Modal\n          onClose={() => {\n            setIsEditingMode(false);\n          }}\n          closeOnOverlayClick\n          isOpen={isEditingMode}\n        >\n          <ModalOverlay />\n          <ModalContent p=\"10px\" maxW=\"800px\">\n            <ModalCloseButton />\n            <ModalHeader> {formType === 'app' ? 'Application' : 'Module'}</ModalHeader>\n            <ModalBody\n              w=\"full\"\n              flex=\"1 1 auto\"\n              height=\"75vh\"\n              alignItems=\"start\"\n              overflow=\"auto\"\n            >\n              <ExplorerForm\n                formType={formType}\n                version={currentVersion}\n                name={currentName}\n                setCurrentVersion={setCurrentVersion}\n                setCurrentName={setCurrentName}\n                services={services}\n                onClose={() => setIsEditingMode(false)}\n              />\n            </ModalBody>\n          </ModalContent>\n        </Modal>\n      </Box>\n    </ErrorBoundary>\n  );\n};\n","import React, { useState, useCallback } from 'react';\nimport {\n  Modal,\n  ModalOverlay,\n  ModalContent,\n  ModalHeader,\n  ModalCloseButton,\n  ModalBody,\n  ModalFooter,\n  Button,\n  Box,\n} from '@chakra-ui/react';\nimport { observer } from 'mobx-react-lite';\nimport { genOperation } from '../operations';\nimport { AppModel } from '../AppModel/AppModel';\nimport { EditorServices } from '../types';\nimport { Application } from '@sunmao-ui/core';\nimport { CodeEditor } from './CodeEditor/CodeEditor';\nimport { css } from '@emotion/css';\n\ntype Props = {\n  app: Application;\n  onClose: () => void;\n  services: EditorServices;\n};\n\nexport const CodeModeModal: React.FC<Props> = observer(({ app, onClose, services }) => {\n  const { registry, eventBus } = services;\n  const [code, setCode] = useState('');\n\n  const onSave = useCallback(() => {\n    onClose();\n    if (code) {\n      eventBus.send(\n        'operation',\n        genOperation(registry, 'replaceApp', {\n          app: new AppModel(JSON.parse(code).spec.components, registry),\n        })\n      );\n    }\n  }, [code, eventBus, onClose, registry]);\n\n  return (\n    <Modal isOpen size=\"6xl\" onClose={onClose}>\n      <ModalOverlay />\n      <ModalContent width=\"800px\">\n        <ModalHeader>Code Mode</ModalHeader>\n        <ModalCloseButton />\n        <ModalBody>\n          <Box overflow=\"auto\" height=\"calc(100vh - 270px)\">\n            <CodeEditor\n              className={css`\n                height: 100%;\n              `}\n              mode={{\n                name: 'javascript',\n                json: true,\n              }}\n              defaultCode={JSON.stringify(app, null, 2)}\n              onChange={setCode}\n            />\n          </Box>\n        </ModalBody>\n        <ModalFooter>\n          <Button variant=\"ghost\" mr={3} onClick={() => onClose()}>\n            Close\n          </Button>\n          <Button colorScheme=\"blue\" onClick={onSave}>\n            Save\n          </Button>\n        </ModalFooter>\n      </ModalContent>\n    </Modal>\n  );\n});\n","import { AppModel } from '../../AppModel/AppModel';\nimport { BaseBranchOperation } from '../type';\nimport { OperationConstructors } from '../index';\n\ntype Operation = {\n  type: keyof typeof OperationConstructors;\n  props: any;\n};\n\nexport type BatchBranchOperationContext = {\n  operations: Operation[];\n};\n\nexport class BatchBranchOperation extends BaseBranchOperation<BatchBranchOperationContext> {\n  do(prev: AppModel): AppModel {\n    const { operations } = this.context;\n\n    operations.forEach(operation => {\n      this.operationStack.insert(\n        new OperationConstructors[operation.type](this.registry, operation.props)\n      );\n    });\n\n    // do the operation in order\n    return this.operationStack.reduce((prev, node) => {\n      prev = node.do(prev);\n      return prev;\n    }, prev);\n  }\n}\n","import { ComponentSchema } from '@sunmao-ui/core';\nimport { RegistryInterface } from '@sunmao-ui/runtime';\nimport { EventBusType } from '../services/eventBus';\nimport { AppModel } from '../AppModel/AppModel';\nimport { IUndoRedoManager, IOperation, OperationList } from './type';\nimport { BatchBranchOperation, type BatchBranchOperationContext } from './branch/batch';\n\nexport class AppModelManager implements IUndoRedoManager {\n  appModel: AppModel;\n  operationStack: OperationList<IOperation> = new OperationList();\n\n  constructor(\n    private eventBus: EventBusType,\n    private registry: RegistryInterface,\n    initComponents: ComponentSchema[]\n  ) {\n    this.appModel = new AppModel(initComponents, this.registry);\n\n    eventBus.on('undo', () => this.undo());\n    eventBus.on('redo', () => this.redo());\n    eventBus.on('operation', o => this.do(o));\n    eventBus.on('componentsRefresh', components => {\n      this.appModel = new AppModel(components, this.registry);\n      this.operationStack = new OperationList();\n    });\n  }\n\n  updateComponents(appModel: AppModel) {\n    this.appModel = appModel;\n    this.eventBus.send('componentsChange', this.appModel.toSchema());\n  }\n\n  do(operation: IOperation): void {\n    // TODO: replace by logger\n    // console.log('do', operation);\n    const newComponents = operation.do(this.appModel);\n    this.operationStack.insert(operation);\n    this.updateComponents(newComponents);\n  }\n\n  redo(): void {\n    if (!this.operationStack.cursor.next) {\n      return;\n    }\n    try {\n      this.operationStack.moveNext();\n    } catch {\n      console.warn('cannot redo as cannot move to next cursor', this.operationStack);\n      return;\n    }\n    const newComponents = this.operationStack.cursor?.val?.redo(this.appModel);\n    // console.log('redo', this.operationStack.cursor?.val);\n    if (newComponents) {\n      this.updateComponents(newComponents);\n    } else {\n      // rollback move next\n      this.operationStack.movePrev();\n      console.warn('cannot redo as next cursor has no operation', this.operationStack);\n    }\n  }\n\n  undo(): void {\n    if (!this.operationStack.cursor.prev) {\n      return;\n    }\n    try {\n      this.operationStack.movePrev();\n    } catch {\n      console.warn('cannot undo as cannot move to prev cursor', this.operationStack);\n      return;\n    }\n    const newComponents = this.operationStack.cursor.next?.val?.undo(this.appModel);\n    // console.log('undo', this.operationStack.cursor.next?.val);\n    if (newComponents) {\n      this.updateComponents(newComponents);\n    } else {\n      // rollback move prev\n      this.operationStack.moveNext();\n      console.warn('cannot undo as cursor has no operation', this.operationStack);\n    }\n  }\n\n  doOperations(operations: BatchBranchOperationContext['operations']) {\n    const context = {\n      operations,\n    };\n    const operation = new BatchBranchOperation(this.registry, context);\n\n    this.do(operation);\n  }\n}\n","import mitt from 'mitt';\nimport { ComponentSchema } from '@sunmao-ui/core';\nimport { IOperation } from '../operations/type';\n\nexport type EventNames = {\n  operation: IOperation;\n  redo: undefined;\n  undo: undefined;\n  // when switch app or module, current components refresh\n  componentsRefresh: ComponentSchema[];\n  // components change by operation\n  stateRefresh: undefined;\n  componentsChange: ComponentSchema[];\n  // it is only used for some operations' side effect\n  selectComponent: string;\n  HTMLElementsUpdated: undefined;\n  MaskWrapperScrollCapture: undefined;\n};\n\nexport const initEventBus = () => {\n  const emitter = mitt<EventNames>();\n  return {\n    on: emitter.on,\n    off: emitter.off,\n    send: emitter.emit,\n  };\n};\n\nexport type EventBusType = ReturnType<typeof initEventBus>;\n","import { action, makeAutoObservable, observable, reaction, toJS } from 'mobx';\nimport { ComponentSchema, createModule } from '@sunmao-ui/core';\nimport { RegistryInterface, StateManagerInterface } from '@sunmao-ui/runtime';\nimport { isEqual } from 'lodash';\n\nimport { EventBusType } from './eventBus';\nimport { AppStorage } from './AppStorage';\nimport { ExplorerMenuTabs, ToolMenuTabs } from '../constants/enum';\n\nimport type { Metadata } from '@sunmao-ui/core';\n\ntype EditingTarget = {\n  kind: 'app' | 'module';\n  version: string;\n  name: string;\n  spec?: {};\n  metadata?: Metadata;\n};\n\nexport class EditorStore {\n  globalDependencies: Record<string, unknown> = {};\n  components: ComponentSchema[] = [];\n  // currentEditingComponents, it could be app's or module's components\n  _selectedComponentId = '';\n  _dragOverComponentId = '';\n  hoverComponentId = '';\n  explorerMenuTab = ExplorerMenuTabs.UI_TREE;\n  toolMenuTab = ToolMenuTabs.INSERT;\n  viewStateComponentId = '';\n  // current editor editing target(app or module)\n  currentEditingTarget: EditingTarget = {\n    kind: 'app',\n    version: '',\n\n    name: '',\n  };\n\n  // not observable, just reference\n  eleMap = new Map<string, HTMLElement>();\n  isDraggingNewComponent = false;\n\n  // when componentsChange event is triggered, currentComponentsVersion++\n  currentComponentsVersion = 0;\n  lastSavedComponentsVersion = 0;\n\n  private isDataSourceTypeCache: Record<string, boolean> = {};\n\n  constructor(\n    private eventBus: EventBusType,\n    private registry: RegistryInterface,\n    private stateManager: StateManagerInterface,\n    public appStorage: AppStorage\n  ) {\n    this.globalDependencies = this.stateManager.dependencies;\n    makeAutoObservable(this, {\n      eleMap: false,\n      components: observable.shallow,\n      setComponents: action,\n      setHoverComponentId: action,\n      setDragOverComponentId: action,\n    });\n\n    this.eventBus.on('selectComponent', id => {\n      this.setSelectedComponentId(id);\n    });\n    // listen the change by operations, and save newComponents\n    this.eventBus.on('componentsChange', components => {\n      this.setComponents(components);\n      this.setCurrentComponentsVersion(this.currentComponentsVersion + 1);\n      this.saveCurrentComponents();\n    });\n\n    // when switch app or module, components should refresh\n    reaction(\n      () => this.currentEditingTarget,\n      (target, prevTarget) => {\n        if (isEqual(prevTarget, target)) {\n          return;\n        }\n\n        if (target.name) {\n          this.setCurrentComponentsVersion(0);\n          this.setLastSavedComponentsVersion(0);\n          // clear currrent components and store\n          this.clearSunmaoGlobalState();\n          this.eventBus.send('stateRefresh');\n          this.eventBus.send('componentsRefresh', []);\n          this.setComponents([]);\n          setTimeout(() => {\n            // set new components\n            this.setSelectedComponentId(this.originComponents[0]?.id || '');\n            this.setModuleDependencies(target.metadata?.exampleProperties);\n            this.eventBus.send('componentsRefresh', this.originComponents);\n            this.setComponents(this.originComponents);\n          }, 0);\n        }\n      }\n    );\n\n    reaction(\n      () => this.selectedComponentId,\n      () => {\n        if (this.selectedComponentId) {\n          this.setToolMenuTab(ToolMenuTabs.INSPECT);\n        }\n      }\n    );\n\n    reaction(\n      () => this.rawModules,\n      () => {\n        // Remove old modules and re-register all modules,\n        this.registry.unregisterAllModules();\n        this.rawModules.forEach(m => {\n          const modules = createModule(m);\n          this.registry.registerModule(modules, true);\n        });\n      }\n    );\n\n    this.updateCurrentEditingTarget('app', this.app.version, this.app.metadata.name);\n  }\n\n  get app() {\n    return this.appStorage.app;\n  }\n\n  get modules() {\n    return this.appStorage.modules;\n  }\n\n  get rawModules() {\n    return this.appStorage.rawModules;\n  }\n\n  get selectedComponent() {\n    return this.components.find(c => c.id === this._selectedComponentId);\n  }\n\n  get selectedComponentId() {\n    return this._selectedComponentId;\n  }\n\n  get selectedComponentIsDataSource() {\n    if (!this.selectedComponent) return false;\n    return !!this.isDataSourceTypeCache[this.selectedComponent.type];\n  }\n\n  get dragOverComponentId() {\n    return this._dragOverComponentId;\n  }\n\n  get isSaved() {\n    // return this.currentComponentsVersion === this.lastSavedComponentsVersion;\n    return true;\n  }\n\n  // origin components of app of module\n  // when switch app or module, components should refresh\n  get originComponents(): ComponentSchema[] {\n    switch (this.currentEditingTarget.kind) {\n      case 'module':\n        const module = this.modules.find(\n          m =>\n            m.version === this.currentEditingTarget.version &&\n            m.metadata.name === this.currentEditingTarget.name\n        );\n        return module?.impl || [];\n      case 'app':\n        return this.app.spec.components;\n    }\n  }\n\n  get uiComponents(): ComponentSchema[] {\n    return this.components.filter(component => {\n      if (this.isDataSourceTypeCache[component.type]) return false;\n      const spec = this.registry.getComponentByType(component.type);\n      if (spec.metadata.isDataSource) {\n        this.isDataSourceTypeCache[component.type] = true;\n        return false;\n      }\n      return true;\n    });\n  }\n\n  get dataSources(): ComponentSchema[] {\n    return this.components.filter(component => {\n      if (this.isDataSourceTypeCache[component.type]) return true;\n      const spec = this.registry.getComponentByType(component.type);\n      if (spec.metadata.isDataSource) {\n        this.isDataSourceTypeCache[component.type] = true;\n        return true;\n      }\n      return false;\n    });\n  }\n\n  get dataSourceTypeCache() {\n    return this.isDataSourceTypeCache;\n  }\n\n  clearSunmaoGlobalState() {\n    this.stateManager.clear();\n    this.setSelectedComponentId('');\n\n    // Remove old modules and re-register all modules,\n    this.registry.unregisterAllModules();\n    this.rawModules.forEach(m => {\n      const modules = createModule(m);\n      this.registry.registerModule(modules, true);\n    });\n  }\n\n  saveCurrentComponents() {\n    this.appStorage.saveComponents(\n      this.currentEditingTarget.kind,\n      this.currentEditingTarget.version,\n      this.currentEditingTarget.name,\n      toJS(this.components)\n    );\n    this.setLastSavedComponentsVersion(this.currentComponentsVersion);\n  }\n\n  updateCurrentEditingTarget = (\n    kind: 'app' | 'module',\n    version: string,\n    name: string,\n    spec?: EditingTarget['spec'],\n    metadata?: EditingTarget['metadata']\n  ) => {\n    this.currentEditingTarget = {\n      kind,\n      name,\n      version,\n      spec,\n      metadata,\n    };\n  };\n\n  setSelectedComponentId = (val: string) => {\n    this._selectedComponentId = val;\n  };\n\n  setComponents = (val: ComponentSchema[]) => {\n    this.components = val;\n  };\n\n  setDragOverComponentId = (val: string) => {\n    this._dragOverComponentId = val;\n  };\n\n  setHoverComponentId = (val: string) => {\n    this.hoverComponentId = val;\n  };\n\n  setCurrentComponentsVersion = (val: number) => {\n    this.currentComponentsVersion = val;\n  };\n\n  setLastSavedComponentsVersion = (val: number) => {\n    this.lastSavedComponentsVersion = val;\n  };\n\n  setExplorerMenuTab = (val: ExplorerMenuTabs) => {\n    this.explorerMenuTab = val;\n  };\n\n  setViewStateComponentId = (val: string) => {\n    this.viewStateComponentId = val;\n  };\n\n  setToolMenuTab = (val: ToolMenuTabs) => {\n    this.toolMenuTab = val;\n  };\n\n  setIsDraggingNewComponent = (val: boolean) => {\n    this.isDraggingNewComponent = val;\n  };\n\n  setModuleDependencies = (exampleProperties?: Record<string, unknown>) => {\n    const evaledDependencies = this.stateManager.deepEval(exampleProperties || {}, {\n      fallbackWhenError: () => undefined,\n    });\n\n    this.stateManager.setDependencies({\n      ...this.globalDependencies,\n      ...evaledDependencies,\n    });\n  };\n}\n","import { Module } from '@sunmao-ui/core';\nimport * as acorn from 'acorn';\nimport * as acornLoose from 'acorn-loose';\nimport { simple as simpleWalk } from 'acorn-walk';\nimport produce from 'immer';\nimport { CORE_VERSION, CoreComponentName } from '@sunmao-ui/shared';\n\nconst ModuleIdPrefix = '{{ $moduleId }}__';\n\ntype StringPos = {\n  start: number;\n  end: number;\n  replaceStr: string;\n};\n\n// add {{$moduleId}} in moduleSchema\nexport function addModuleId(originModule: Module): Module {\n  return produce(originModule, module => {\n    const ids: string[] = [];\n    module.impl.forEach(c => {\n      ids.push(c.id);\n      if (c.type === `${CORE_VERSION}/${CoreComponentName.ModuleContainer}`) {\n        ids.push(c.properties.id as string);\n      }\n\n      if (c.type === 'chakra_ui/v1/list') {\n        ids.push((c.properties.template as any).id);\n      }\n    });\n    function traverse(tree: Record<string, any>, isValueExp = false) {\n      for (const key in tree) {\n        const val = tree[key];\n        if (typeof val === 'string') {\n          if (isValueExp) {\n            // case 1: value is expression, replace it\n            const newField = replaceIdsInExp(val, ids);\n            tree[key] = newField;\n          } else if (ids.includes(val)) {\n            // case 2: value is equal to a component id\n            tree[key] = `${ModuleIdPrefix}${val}`;\n          } else {\n            // case 3: value is normal string, try to replace the componentIds in this string\n            const newField = replaceIdsInProperty(val, ids);\n            tree[key] = newField;\n          }\n        } else if (typeof val === 'object') {\n          // case 4: value is object, recurse it\n          traverse(val, isValueExp);\n        }\n      }\n    }\n\n    traverse(module.impl);\n    // value of stateMap is expression, not property\n    traverse(module.spec.stateMap, true);\n    traverse(module.spec.methods, true);\n  });\n}\n\n// remove '{{$moduleId}}__' in moduleSchema\nexport function removeModuleId(originModule: Module): Module {\n  return produce(originModule, module => {\n    function traverse(tree: Record<string, any>) {\n      for (const key in tree) {\n        const val = tree[key];\n        if (typeof val === 'string') {\n          tree[key] = val.replace(/{{ \\$moduleId }}__/g, '');\n        } else if (typeof val === 'object') {\n          traverse(val);\n        }\n      }\n    }\n\n    traverse(module.impl);\n    traverse(module.spec.stateMap);\n    traverse(module.spec.methods);\n  });\n}\n\n// example: replaceIdsInExp('{{input1.value}} + {{input2.value}}', ids: ['input1']])\nexport function replaceIdsInProperty(property: string, ids: string[]): string {\n  const matches = [...property.matchAll(/{{((.|\\n)*?)}}/g)];\n\n  if (matches.length === 0) return property;\n\n  const expPos: StringPos[] = [];\n  matches.forEach(match => {\n    const newExp = replaceIdsInExp(match[1], ids);\n    if (newExp) {\n      expPos.push({\n        // + 2 because of '{{' length is 2\n        start: match.index! + 2,\n        end: match.index! + 2 + match[1].length,\n        replaceStr: newExp,\n      });\n    }\n  });\n  if (expPos.length === 0) return property;\n\n  return expPos.reverse().reduce((result, { start, end, replaceStr }) => {\n    return result.slice(0, start) + `${replaceStr}` + result.slice(end);\n  }, property);\n}\n\n// example: replaceIdsInExp('input1.value', ids: ['input1']])\nfunction replaceIdsInExp(exp: string, ids: string[]): string | void {\n  const identifierPos: StringPos[] = [];\n  simpleWalk((acornLoose as typeof acorn).parse(exp, { ecmaVersion: 2020 }), {\n    Identifier: node => {\n      const objectName = exp.slice(node.start, node.end);\n      if (ids.includes(objectName)) {\n        identifierPos.push({\n          start: node.start,\n          end: node.end,\n          replaceStr: `${ModuleIdPrefix}${objectName}`,\n        });\n      }\n    },\n  });\n\n  if (identifierPos.length === 0) {\n    return exp;\n  }\n  const newExp = identifierPos.reverse().reduce((result, { start, end, replaceStr }) => {\n    return result.slice(0, start) + `${replaceStr}` + result.slice(end);\n  }, exp);\n\n  return newExp;\n}\n","import { observable, makeObservable, action, toJS } from 'mobx';\nimport {\n  Application,\n  ApplicationMetadata,\n  ComponentSchema,\n  Module,\n  ModuleMethodSpec,\n  parseVersion,\n  RuntimeModule,\n} from '@sunmao-ui/core';\nimport { produce } from 'immer';\nimport { DefaultNewModule, EmptyAppSchema } from '../constants';\nimport { addModuleId, removeModuleId } from '../utils/addModuleId';\nimport { StorageHandler } from '../types';\nimport { JSONSchema7, JSONSchema7Object } from 'json-schema';\n\nexport class AppStorage {\n  app: Application;\n  modules: Module[];\n  // modules that have {{$moduleId}}__\n  rawModules: Module[];\n  static AppLSKey = 'schema';\n  static ModulesLSKey = 'modules';\n\n  constructor(\n    defaultApplication?: Application,\n    defaultModules?: Module[],\n    private storageHandler?: StorageHandler\n  ) {\n    this.app = defaultApplication || EmptyAppSchema;\n    this.modules = defaultModules?.map(removeModuleId) || [];\n    this.rawModules = defaultModules || [];\n\n    makeObservable(this, {\n      app: observable.shallow,\n      modules: observable.shallow,\n      rawModules: observable.shallow,\n      setApp: action,\n      setModules: action,\n      setRawModules: action,\n    });\n  }\n\n  createModule(props: {\n    components?: ComponentSchema[];\n    propertySpec?: JSONSchema7;\n    exampleProperties?: Record<string, any>;\n    events?: string[];\n    moduleVersion?: string;\n    moduleName?: string;\n    stateMap?: Record<string, string>;\n  }): Module {\n    const {\n      components,\n      propertySpec,\n      exampleProperties,\n      events,\n      moduleVersion,\n      moduleName,\n      stateMap,\n    } = props;\n    let index = this.modules.length;\n\n    this.modules.forEach(module => {\n      if (module.metadata.name === `myModule${index}`) {\n        index++;\n      }\n    });\n\n    const name = `myModule${index}`;\n    const newModule: RuntimeModule = {\n      ...DefaultNewModule,\n      version: moduleVersion || DefaultNewModule.version,\n      parsedVersion: moduleVersion\n        ? parseVersion(moduleVersion)\n        : DefaultNewModule.parsedVersion,\n      metadata: {\n        ...DefaultNewModule.metadata,\n        name: moduleName || name,\n      },\n    };\n\n    if (components) {\n      newModule.impl = components;\n    }\n\n    if (propertySpec) {\n      newModule.spec.properties = propertySpec;\n    }\n    if (exampleProperties) {\n      for (const key in exampleProperties) {\n        const value = exampleProperties[key];\n        if (typeof value === 'string') {\n          newModule.metadata.exampleProperties![key] = value;\n        } else {\n          // save value as expression\n          newModule.metadata.exampleProperties![key] = `{{${JSON.stringify(value)}}}`;\n        }\n      }\n    }\n    if (events) {\n      newModule.spec.events = events;\n    }\n    if (stateMap) {\n      newModule.spec.stateMap = stateMap;\n    }\n\n    this.setModules([...this.modules, newModule]);\n    const rawModules = this.modules.map(addModuleId);\n    this.setRawModules(rawModules);\n    this.saveModules();\n    return rawModules[rawModules.length - 1];\n  }\n\n  removeModule(v: string, n: string) {\n    this.setModules(\n      this.modules.filter(\n        ({ version, metadata: { name } }) => version !== v || name !== n\n      )\n    );\n    this.setRawModules(this.modules.map(addModuleId));\n    this.saveModules();\n  }\n\n  saveComponents(\n    type: 'app' | 'module',\n    version: string,\n    name: string,\n    components: ComponentSchema[]\n  ) {\n    switch (type) {\n      case 'app':\n        const newApp = produce(toJS(this.app), draft => {\n          draft.spec.components = components;\n        });\n        this.setApp(newApp);\n        this.saveApplication();\n        break;\n      case 'module':\n        const i = this.modules.findIndex(\n          m => m.version === version && m.metadata.name === name\n        );\n        const newModules = produce(toJS(this.modules), draft => {\n          draft[i].impl = components;\n        });\n        this.setModules(newModules);\n        const rawModules = newModules.map(addModuleId);\n        this.setRawModules(rawModules);\n        this.saveModules();\n        break;\n    }\n  }\n\n  saveAppMetaData({ version, name }: { version: string; name: string }) {\n    const newApp = produce(toJS(this.app), draft => {\n      draft.metadata.name = name;\n      draft.version = version;\n    });\n    this.setApp(newApp);\n    this.saveApplication();\n  }\n\n  saveAppAnnotations(annotations: ApplicationMetadata['annotations']) {\n    if (!annotations) return;\n    const newApp = produce(toJS(this.app), draft => {\n      if (!draft.metadata.annotations) {\n        draft.metadata.annotations = {};\n      }\n      Object.keys(annotations).forEach(key => {\n        draft.metadata.annotations![key] = annotations[key];\n      });\n    });\n    this.setApp(newApp);\n    this.saveApplication();\n  }\n\n  saveModuleMetaData(\n    { originName, originVersion }: { originName: string; originVersion: string },\n    {\n      version,\n      name,\n      stateMap,\n      properties,\n      exampleProperties,\n      events,\n      methods,\n    }: {\n      version: string;\n      name: string;\n      stateMap: Record<string, string>;\n      properties: JSONSchema7;\n      exampleProperties: JSONSchema7Object;\n      events: string[];\n      methods: ModuleMethodSpec[];\n    }\n  ) {\n    const i = this.modules.findIndex(\n      m => m.version === originVersion && m.metadata.name === originName\n    );\n    const newModules = produce(toJS(this.modules), draft => {\n      draft[i].metadata.name = name;\n      draft[i].metadata.exampleProperties = exampleProperties;\n      draft[i].spec.stateMap = stateMap;\n      draft[i].spec.properties = properties;\n      draft[i].version = version;\n      draft[i].spec.events = events;\n      draft[i].spec.methods = methods;\n    });\n\n    this.setModules(newModules);\n    const rawModules = newModules.map(addModuleId);\n    this.setRawModules(rawModules);\n    this.saveModules();\n  }\n\n  private saveApplication() {\n    this.storageHandler?.onSaveApp && this.storageHandler?.onSaveApp(toJS(this.app));\n  }\n\n  private saveModules() {\n    // save rawModules rather than modules because rawModules have {{$moduleId}}__\n    this.storageHandler?.onSaveModules &&\n      this.storageHandler?.onSaveModules(this.rawModules);\n  }\n\n  setApp(app: Application) {\n    this.app = app;\n  }\n\n  setModules(modules: Module[]) {\n    this.modules = modules;\n  }\n\n  setRawModules(modules: Module[]) {\n    this.rawModules = modules;\n  }\n}\n","import { Editor as _Editor } from './components/Editor';\nimport { initSunmaoUI, SunmaoUIRuntimeProps } from '@sunmao-ui/runtime';\nimport { AppModelManager } from './operations/AppModelManager';\nimport React, { useState, useCallback, useEffect } from 'react';\nimport {\n  widgets as internalWidgets,\n  WidgetManager,\n  ImplementedWidget,\n} from '@sunmao-ui/editor-sdk';\nimport {\n  ChakraProvider,\n  extendTheme,\n  withDefaultSize,\n  withDefaultVariant,\n  theme,\n} from '@chakra-ui/react';\nimport { initEventBus } from './services/eventBus';\nimport { EditorStore } from './services/EditorStore';\nimport { StorageHandler } from './types';\nimport { AppStorage } from './services/AppStorage';\nimport { Application, Module } from '@sunmao-ui/core';\nimport './styles.css';\n\ntype SunmaoUIEditorProps = {\n  widgets?: ImplementedWidget<any>[];\n  runtimeProps?: SunmaoUIRuntimeProps;\n  storageHandler?: StorageHandler;\n  defaultApplication?: Application;\n  defaultModules?: Module[];\n};\n\nconst zIndices = {\n  zIndices: {\n    ...theme.zIndices,\n    // smaller than the default value of zIndex for chakra modal (1400)\n    editorMask: 1399,\n    sideMenuIndex: 2,\n  },\n};\n\nexport function initSunmaoUIEditor(props: SunmaoUIEditorProps = {}) {\n  const editorTheme = extendTheme(\n    withDefaultSize({\n      size: 'sm',\n      components: [\n        'Input',\n        'NumberInput',\n        'Checkbox',\n        'Radio',\n        'Textarea',\n        'Select',\n        'Switch',\n      ],\n    }),\n    withDefaultVariant({\n      variant: 'filled',\n      components: ['Input', 'NumberInput', 'Textarea', 'Select'],\n    }),\n    zIndices\n  );\n  const didMount = () => {\n    eventBus.send('HTMLElementsUpdated');\n    if (props.runtimeProps?.hooks?.didMount) props.runtimeProps.hooks.didMount();\n  };\n  const didUpdate = () => {\n    eventBus.send('HTMLElementsUpdated');\n    if (props.runtimeProps?.hooks?.didUpdate) props.runtimeProps.hooks.didUpdate();\n  };\n  const didDomUpdate = () => {\n    eventBus.send('HTMLElementsUpdated');\n    if (props.runtimeProps?.hooks?.didDomUpdate) props.runtimeProps.hooks.didDomUpdate();\n  };\n\n  const ui = initSunmaoUI({\n    ...props.runtimeProps,\n    hooks: { didMount, didUpdate, didDomUpdate },\n  });\n\n  const App = ui.App;\n  const registry = ui.registry;\n\n  const stateManager = ui.stateManager;\n  const eventBus = initEventBus();\n  const appStorage = new AppStorage(\n    props.defaultApplication,\n    props.defaultModules,\n    props.storageHandler\n  );\n  const appModelManager = new AppModelManager(\n    eventBus,\n    registry,\n    appStorage.app.spec.components\n  );\n  const widgetManager = new WidgetManager();\n  const editorStore = new EditorStore(eventBus, registry, stateManager, appStorage);\n  editorStore.eleMap = ui.eleMap;\n\n  const services = {\n    ...ui,\n    appModelManager,\n    widgetManager,\n    eventBus,\n    editorStore,\n  };\n\n  const Editor: React.FC = () => {\n    const [store, setStore] = useState(stateManager.store);\n    const onRefresh = useCallback(() => {\n      // need to reregister all the traits to clear the trait states which like `HasInitializedMap`\n      const traits = registry.getAllTraits();\n\n      stateManager.clear();\n      setStore(stateManager.store);\n      registry.unregisterAllTraits();\n      traits.forEach(trait => {\n        registry.registerTrait(trait);\n      });\n    }, []);\n\n    useEffect(() => {\n      eventBus.on('stateRefresh', onRefresh);\n      return () => {\n        eventBus.off('stateRefresh');\n      };\n    }, [onRefresh]);\n    return (\n      <ChakraProvider theme={editorTheme}>\n        <_Editor\n          App={App}\n          eleMap={ui.eleMap}\n          registry={registry}\n          stateStore={store}\n          services={services}\n          libs={props.runtimeProps?.libs || []}\n          onRefresh={onRefresh}\n          dependencies={props.runtimeProps?.dependencies || {}}\n        />\n      </ChakraProvider>\n    );\n  };\n\n  internalWidgets.concat(props.widgets || []).forEach(widget => {\n    widgetManager.registerWidget(widget);\n  });\n\n  return {\n    Editor,\n    registry,\n    services,\n  };\n}\n","import { Application, Module } from '@sunmao-ui/core';\nimport { EmptyAppSchema } from './constants';\n\nexport class LocalStorageManager {\n  static AppLSKey = 'schema';\n  static ModulesLSKey = 'modules';\n\n  getAppFromLS(): Application {\n    try {\n      const appFromLS = localStorage.getItem(LocalStorageManager.AppLSKey);\n      if (appFromLS) {\n        return JSON.parse(appFromLS);\n      }\n      return EmptyAppSchema;\n    } catch (error) {\n      return EmptyAppSchema;\n    }\n  }\n\n  getModulesFromLS(): Module[] {\n    try {\n      const modulesFromLS = localStorage.getItem(LocalStorageManager.ModulesLSKey);\n      if (modulesFromLS) {\n        return JSON.parse(modulesFromLS);\n      }\n      return [];\n    } catch (error) {\n      return [];\n    }\n  }\n\n  saveAppInLS(app: Application) {\n    localStorage.setItem(LocalStorageManager.AppLSKey, JSON.stringify(app));\n  }\n\n  saveModulesInLS(modules: Module[]) {\n    localStorage.setItem(LocalStorageManager.ModulesLSKey, JSON.stringify(modules));\n  }\n}\n"]}