{"version":3,"file":"index.mjs","sources":["../src/constants.ts","../src/plugins/editor-plugin-name.ts","../src/plugins/uidl-store-plugins/editor-plugin-uidl-store.ts","../src/plugins/uidl-utils-config-plugins/editor-plugin-uidl-utils-config.ts","../src/plugins/uidl-utils-config-plugins/editor-plugin-uidl-utils-config-init.ts","../src/plugins/uidl-utils-config-plugins/index.ts","../src/plugins/editor-plugin-emitter.ts","../src/plugins/uidl-store-plugins/editor-plugin-uidl-store-edit.ts","../src/plugins/uidl-store-plugins/editor-plugin-uidl-store-components.ts","../src/plugins/uidl-store-plugins/editor-plugin-uidl-store-init.ts","../src/plugins/uidl-store-plugins/index.ts","../src/plugins/layout-store-plugins/editor-plugin-layout-store.ts","../src/plugins/editor-plugin-render.tsx","../src/plugins/editor-plugin-editor-react-context.tsx","../src/plugins/context-menu-store-plugins/context-menu.tsx","../src/plugins/context-menu-store-plugins/editor-plugin-context-menu-store.tsx","../src/plugins/context-menu-store-plugins/editor-plugin-context-menu-store-element.ts","../src/plugins/context-menu-store-plugins/use-context-menu.ts","../src/plugins/context-menu-store-plugins/index.ts","../src/plugins/editor-plugin-root-host/root.tsx","../src/plugins/editor-plugin-root-host/index.tsx","../src/plugins/dnd-store-plugins/editor-plugin-dnd-store.ts","../src/plugins/dnd-store-plugins/components/dnd-mask.tsx","../src/plugins/dnd-store-plugins/editor-plugin-dnd-store-mask.tsx","../src/plugins/dnd-store-plugins/editor-plugin-dnd-store-element-renderer.tsx","../src/plugins/dnd-store-plugins/components/draggable-element-renderer.tsx","../src/plugins/dnd-store-plugins/components/draggable-component-renderer.tsx","../src/plugins/dnd-store-plugins/editor-plugin-dnd-store-component-renderer.tsx","../src/plugins/dnd-store-plugins/hooks/use-drag-move.ts","../src/plugins/dnd-store-plugins/hooks/use-drag-auto-scroll.ts","../src/plugins/dnd-store-plugins/hooks/use-draggable.ts","../src/plugins/dnd-store-plugins/hooks/use-droppable.ts","../src/plugins/dnd-store-plugins/utils.ts","../src/plugins/dnd-store-plugins/index.ts","../src/plugins/element-store-plugins/editor-plugin-element-store.ts","../src/plugins/i18n-store-plugins/editor-plugin-i18n-store.ts","../src/plugins/i18n-store-plugins/editor-plugin-i18n-store-init.ts","../src/plugins/i18n-store-plugins/editor-plugin-i18n-store-load-state.ts","../src/plugins/i18n-store-plugins/index.ts","../src/plugins/pd-store-plugins/editor-plugin-pd-store.ts","../src/plugins/pd-store-plugins/editor-plugin-pd-store-init.ts","../src/plugins/pd-store-plugins/index.ts","../src/plugins/element-store-plugins/editor-plugin-element-store-find.ts","../src/plugins/layout-store-plugins/editor-plugin-layout-store-init.ts","../src/plugins/layout-store-plugins/editor-plugin-layout-store-load-state.ts","../src/plugins/layout-store-plugins/index.ts","../src/plugins/element-store-plugins/editor-plugin-element-store-select.ts","../src/plugins/element-store-plugins/editor-plugin-element-store-edit.ts","../src/plugins/element-store-plugins/editor-plugin-element-store-copy-paste.ts","../src/plugins/element-store-plugins/editor-plugin-element-store-is.ts","../src/plugins/element-store-plugins/index.ts","../src/plugins/save-store-plugins/editor-plugin-save-store.ts","../src/plugins/save-store-plugins/editor-plugin-save-store-init.ts","../src/plugins/save-store-plugins/index.ts","../src/plugins/style-store-plugins/editor-plugin-style-store.ts","../src/plugins/style-store-plugins/editor-plugin-style-store-init.ts","../src/plugins/style-store-plugins/index.ts","../src/plugins/index.ts","../src/editor.ts"],"sourcesContent":["/**\n * 上下文类型：编辑器\n */\nexport const CONTEXT_TYPE_EDITOR = 'editor'\n\n/**\n * 编辑器扩展键值\n */\nexport const editorExtKeys = [CONTEXT_TYPE_EDITOR] as const\n","import type { EditorRawPlugin } from '../types'\n\n/**\n * 编辑器名称插件属性扩展\n */\nexport interface EditorPluginNamePropertiesExt {\n  editor: {\n    /**\n     * 名称\n     */\n    name: string\n  }\n  editorInitOptions: {\n    /**\n     * 名称\n     */\n    name?: string\n  }\n}\n\n/**\n * 编辑器名称插件\n */\nexport const editorPluginName: EditorRawPlugin<EditorPluginNamePropertiesExt> =\n  {\n    id: 'name',\n    initEditor(ctx) {\n      ctx.name = ctx.initOptions.name || 'lc-editor'\n    },\n  }\n","import type { SoftAs } from '@p-lc/shared'\nimport type { EditorUidl } from '@p-lc/uidl'\nimport type { ElementOfUidl } from '@p-lc/uidl-utils'\nimport { makeObservable, observable } from 'mobx'\nimport type { Get } from 'type-fest'\nimport type { AnyEditorPlugin, Editor, EditorRawPlugin } from '../../types'\n\n/**\n * 编辑器 UIDL 仓库插件属性扩展\n */\nexport interface EditorPluginUidlStorePropertiesExt {\n  editor: {\n    /**\n     * UIDL 仓库\n     */\n    uidlStore: {\n      /**\n       * UIDL 键值\n       */\n      uidlKey?: string\n      /**\n       * UIDL\n       */\n      uidl: EditorUidl | null\n    }\n  }\n}\n\n/**\n * UIDL 仓库 UIDL\n */\nexport type UidlStoreUidl<Plugin extends AnyEditorPlugin> = SoftAs<\n  NonNullable<Get<Editor<Plugin>, ['uidlStore', 'uidl']>>,\n  EditorUidl\n>\n\n/**\n * UIDL 仓库 UIDL 元素\n */\nexport type UidlStoreUidlElement<Plugin extends AnyEditorPlugin> =\n  ElementOfUidl<UidlStoreUidl<Plugin>>\n\n/**\n * 编辑器 UIDL 仓库插件\n */\nexport const editorPluginUidlStore: EditorRawPlugin<EditorPluginUidlStorePropertiesExt> =\n  {\n    id: 'uidl-store',\n    initEditor(ctx) {\n      const uidlStore = (ctx.uidlStore = {} as typeof ctx.uidlStore)\n      uidlStore.uidl = null\n      makeObservable(uidlStore, {\n        uidl: observable.ref,\n      })\n    },\n  }\n","import type { UidlUtilsConfig } from '@p-lc/uidl-utils'\nimport { defaultEditorUidlUtilsConfig } from '@p-lc/uidl-utils'\nimport { cloneDeep } from 'lodash-uni'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport type { UidlStoreUidl } from '../uidl-store-plugins'\nimport { type editorPluginUidlStore } from '../uidl-store-plugins'\n\n/**\n * 编辑器 UIDL 工具集配置插件属性扩展高等类型\n */\nexport interface EditorPluginUidlUtilsConfigPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * UIDL 工具集配置\n     */\n    uidlUtilsConfig: UidlUtilsConfig<UidlStoreUidl<Plugin>>\n  }\n}\n\n/**\n * EditorPluginUidlUtilsConfigPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginUidlUtilsConfigPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginUidlUtilsConfigPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器 UIDL 工具集配置插件\n */\nexport const editorPluginUidlUtilsConfig: EditorRawPlugin<\n  $EditorPluginUidlUtilsConfigPropertiesExtHkt,\n  typeof editorPluginUidlStore\n> = {\n  id: 'uidl-utils-config',\n  initEditor(ctx) {\n    ctx.uidlUtilsConfig = cloneDeep(\n      defaultEditorUidlUtilsConfig as unknown as typeof ctx.uidlUtilsConfig,\n    )\n  },\n}\n","import type { UidlUtilsConfig } from '@p-lc/uidl-utils'\nimport { merge } from 'lodash-uni'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport type { UidlStoreUidl } from '../uidl-store-plugins'\nimport { type editorPluginUidlUtilsConfig } from './editor-plugin-uidl-utils-config'\n\n/**\n * 编辑器 UIDL 工具集配置初始化插件属性扩展高等类型\n */\nexport interface EditorPluginUidlUtilsConfigInitPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editorInitOptions: {\n    /**\n     * UIDL 工具集配置，使用 merge 合并\n     */\n    uidlUtilsConfig?: Partial<UidlUtilsConfig<UidlStoreUidl<Plugin>>>\n  }\n}\n\n/**\n * EditorPluginUidlUtilsConfigInitPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginUidlUtilsConfigInitPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginUidlUtilsConfigInitPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器 UIDL 工具集配置初始化插件\n */\nexport const editorPluginUidlUtilsConfigInit: EditorRawPlugin<\n  $EditorPluginUidlUtilsConfigInitPropertiesExtHkt,\n  typeof editorPluginUidlUtilsConfig\n> = {\n  id: 'uidl-utils-config-init',\n  initEditor(ctx) {\n    merge(ctx.uidlUtilsConfig, ctx.initOptions.uidlUtilsConfig)\n  },\n}\n","import { editorPluginUidlUtilsConfig } from './editor-plugin-uidl-utils-config'\nimport { editorPluginUidlUtilsConfigInit } from './editor-plugin-uidl-utils-config-init'\n\nexport * from './editor-plugin-uidl-utils-config'\nexport * from './editor-plugin-uidl-utils-config-init'\n\n/**\n * 编辑器 UIDL 工具集配置插件\n */\nexport const editorUidlUtilsConfigPlugins = [\n  editorPluginUidlUtilsConfig,\n  editorPluginUidlUtilsConfigInit,\n]\n","import type { ForceToObject, LiteralObject } from '@p-lc/shared'\nimport type { Emitter } from 'mitt'\nimport mitt from 'mitt'\nimport { action, makeObservable } from 'mobx'\nimport type { Get } from 'type-fest'\nimport type {\n  AnyEditorPlugin,\n  Editor,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../types'\n\n/**\n * 编辑器发射器插件属性扩展高等类型\n */\nexport interface EditorPluginEmitterPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 发射器事件，由其他插件扩展，只用于类型推导\n     */\n    emitterEvents: LiteralObject\n    /**\n     * 发射器\n     */\n    emitter: Emitter<ForceToObject<Get<Editor<Plugin>, ['emitterEvents']>>>\n  }\n}\n\n/**\n * EditorPluginEmitterPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginEmitterPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginEmitterPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器发射器插件\n */\nexport const editorPluginEmitter: EditorRawPlugin<$EditorPluginEmitterPropertiesExtHkt> =\n  {\n    id: 'emitter',\n    initEditor(ctx) {\n      ctx.emitter = mitt()\n      makeObservable(ctx.emitter, {\n        emit: action,\n      })\n    },\n  }\n","import type { UndoRedoListRecipe } from '@p-lc/shared'\nimport { definePropertyByGetter, UndoRedoList } from '@p-lc/shared'\nimport type { Patch } from 'immer'\nimport { action, makeObservable, observable } from 'mobx'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginEmitter } from '../editor-plugin-emitter'\nimport type { UidlStoreUidl } from './editor-plugin-uidl-store'\nimport { type editorPluginUidlStore } from './editor-plugin-uidl-store'\n\n/**\n * 编辑器 UIDL 仓库编辑插件属性扩展高等类型\n */\nexport interface EditorPluginUidlStoreEditPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 发射器事件\n     */\n    emitterEvents: {\n      /**\n       * UIDL 变化（初始化、更新）事件\n       */\n      uidl: {\n        /**\n         * 类型\n         */\n        type:\n          | typeof EDITOR_EVENT_UIDL_TYPE_INIT\n          | typeof EDITOR_EVENT_UIDL_TYPE_UPDATE\n        /**\n         * UIDL\n         */\n        uidl: UidlStoreUidl<Plugin>\n        /**\n         * 补丁\n         */\n        patchs: Patch[]\n      }\n      /**\n       * UIDL 合成开始事件\n       */\n      uidlCompositionStart: {\n        /**\n         * UIDL\n         */\n        uidl: UidlStoreUidl<Plugin>\n      }\n      /**\n       * UIDL 合成更新事件\n       */\n      uidlCompositionUpdate: {\n        /**\n         * UIDL 草稿\n         */\n        draft: UidlStoreUidl<Plugin>\n        /**\n         * UIDL\n         */\n        uidl: UidlStoreUidl<Plugin>\n      }\n      /**\n       * UIDL 合成结束事件\n       */\n      uidlCompositionEnd: {\n        /**\n         * UIDL\n         */\n        uidl: UidlStoreUidl<Plugin>\n      }\n    }\n    /**\n     * UIDL 仓库\n     */\n    uidlStore: {\n      /**\n       * 最大撤销重做大小，最小 8，默认值：256\n       */\n      maxUndoRedoSize?: number\n      /**\n       * 是可撤销的\n       */\n      isUndoable: boolean\n      /**\n       * 是可重做的\n       */\n      isRedoable: boolean\n      /**\n       * 大小\n       */\n      size: number\n      /**\n       * 撤销重做列表\n       */\n      undoRedoList: UndoRedoList<NonNullable<UidlStoreUidl<Plugin>>>\n      /**\n       * 获取 UIDL，编辑中拿草稿，不存在就抛出异常\n       */\n      getUidlOrThrow: () => UidlStoreUidl<Plugin>\n      /**\n       * 草稿\n       */\n      draft: UidlStoreUidl<Plugin> | null\n      /**\n       * 正在编辑中\n       */\n      isEditing: boolean\n      /**\n       * 编辑（UIDL），支持嵌套调用\n       * @param recipe 配方函数\n       * @param recipeId 配方 ID\n       */\n      edit(\n        recipe: UndoRedoListRecipe<UidlStoreUidl<Plugin>>,\n        recipeId?: string | number | null,\n      ): void\n      /**\n       * 撤销\n       */\n      undo(): void\n      /**\n       * 重做\n       */\n      redo(): void\n    }\n  }\n  editorInitOptions: {\n    /**\n     * 最大撤销重做大小，最小 8，默认值：256\n     */\n    maxUndoRedoSize?: number\n  }\n}\n\n/**\n * 编辑器事件键值：UIDL 变化\n */\nexport const EDITOR_EVENT_KEY_UIDL = 'uidl'\n\n/**\n * 编辑器事件键值：UIDL 合成开始\n */\nexport const EDITOR_EVENT_KEY_UIDL_COMPOSITION_START = 'uidlCompositionStart'\n\n/**\n * 编辑器事件键值：UIDL 合成更新\n */\nexport const EDITOR_EVENT_KEY_UIDL_COMPOSITION_UPDATE = 'uidlCompositionUpdate'\n\n/**\n * 编辑器事件键值：UIDL 合成结束\n */\nexport const EDITOR_EVENT_KEY_UIDL_COMPOSITION_END = 'uidlCompositionEnd'\n\n/**\n * 运行时 UIDL 变化事件类型：初始化\n */\nexport const EDITOR_EVENT_UIDL_TYPE_INIT = 'init'\n\n/**\n * 运行时 UIDL 变化事件类型：更新\n */\nexport const EDITOR_EVENT_UIDL_TYPE_UPDATE = 'update'\n\n/**\n * EditorPluginUidlStoreEditPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginUidlStoreEditPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginUidlStoreEditPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器 UIDL 仓库编辑插件\n */\nexport const editorPluginUidlStoreEdit: EditorRawPlugin<\n  $EditorPluginUidlStoreEditPropertiesExtHkt,\n  typeof editorPluginUidlStore | typeof editorPluginEmitter\n> = {\n  id: 'uidl-store-edit',\n  initEditor(ctx) {\n    const { uidlStore, emitter } = ctx\n    uidlStore.maxUndoRedoSize = ctx.initOptions.maxUndoRedoSize\n    const initUndoRedoState = action(() => {\n      uidlStore.isUndoable = false\n      uidlStore.isRedoable = false\n      uidlStore.size = 0\n    })\n    initUndoRedoState()\n    emitter.on(EDITOR_EVENT_KEY_UIDL, ({ type: evType, uidl }) => {\n      if (evType === EDITOR_EVENT_UIDL_TYPE_INIT) {\n        initUndoRedoState()\n        const undoRedoList = (uidlStore.undoRedoList = new UndoRedoList({\n          initState: uidl,\n          maxSize: uidlStore.maxUndoRedoSize,\n          onChange: action((type, newUidl, patchs): void => {\n            void type\n            uidlStore.uidl = newUidl\n            uidlStore.isUndoable = undoRedoList.isUndoable\n            uidlStore.isRedoable = undoRedoList.isRedoable\n            uidlStore.size = undoRedoList.size\n            emitter.emit(EDITOR_EVENT_KEY_UIDL, {\n              type: EDITOR_EVENT_UIDL_TYPE_UPDATE,\n              uidl: newUidl,\n              patchs,\n            })\n          }),\n        }))\n      }\n    })\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    uidlStore.getUidlOrThrow = () => {\n      const { draft, uidl } = uidlStore\n      const u = draft || uidl\n      if (!u) {\n        throw new Error('Can not get uidl before init.')\n      }\n      return u\n    }\n    uidlStore.draft = null\n    definePropertyByGetter(uidlStore, 'isEditing', () => {\n      return !!uidlStore.draft\n    })\n    uidlStore.edit = action((recipe, recipeId) => {\n      const { undoRedoList } = uidlStore\n      if (!uidlStore.draft) {\n        emitter.emit(EDITOR_EVENT_KEY_UIDL_COMPOSITION_START, {\n          uidl: undoRedoList.currentState,\n        })\n      }\n      const ret = undoRedoList.produce((draft) => {\n        uidlStore.draft = draft\n        return recipe(draft)\n      }, recipeId)\n      const draft = (uidlStore.draft = undoRedoList.draft)\n      const { currentState } = undoRedoList\n      if (draft) {\n        emitter.emit(EDITOR_EVENT_KEY_UIDL_COMPOSITION_UPDATE, {\n          draft,\n          uidl: currentState,\n        })\n      } else {\n        emitter.emit(EDITOR_EVENT_KEY_UIDL_COMPOSITION_END, {\n          uidl: currentState,\n        })\n      }\n      return ret\n    })\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    uidlStore.undo = () => {\n      uidlStore.undoRedoList.undo()\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    uidlStore.redo = () => {\n      uidlStore.undoRedoList.redo()\n    }\n    makeObservable(uidlStore, {\n      isUndoable: observable,\n      isRedoable: observable,\n      size: observable,\n    })\n  },\n}\n","import { createWeakMemoizeArrayToMap, jsonStringify } from '@p-lc/shared'\nimport type { UidlComponent } from '@p-lc/uidl'\nimport {\n  addUidlComponent,\n  createUidlComponent,\n  DEFAULT_IMPORT_EXPORT_PATH,\n  DEFAULT_PKG_NAME,\n  DEFAULT_PKG_VERSION,\n  dfsElement,\n} from '@p-lc/uidl-utils'\nimport { isNull } from 'lodash-uni'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport type { PdStore } from '../pd-store-plugins'\nimport { type editorPluginUidlUtilsConfig } from '../uidl-utils-config-plugins'\nimport { type editorPluginUidlStore } from './editor-plugin-uidl-store'\nimport { type editorPluginUidlStoreEdit } from './editor-plugin-uidl-store-edit'\n\n/**\n * 编辑器 UIDL 仓库组件插件属性扩展高等类型\n */\nexport interface EditorPluginUidlStoreComponentsPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * PD 仓库，防止循环引用\n     */\n    pdStore: PdStore<Plugin>\n    /**\n     * UIDL 仓库\n     */\n    uidlStore: {\n      /**\n       * 创建 UIDL 组件，修改 UIDL\n       * @param pkgName 包名\n       * @param componentType 组件类型\n       */\n      createUidlComponent(pkgName: string, componentType: string): UidlComponent\n      /**\n       * 清理 UIDL 组件\n       */\n      clearUidlComponents(): void\n      /**\n       * 获取 UIDL 组件\n       * @param elementType 元素类型\n       */\n      getUidlComponent(elementType: string): UidlComponent\n      /**\n       * 获取元素类型\n       * @param pkgName 包名\n       * @param componentType 组件类型\n       */\n      getElementType(pkgName: string, componentType: string): string | null\n      /**\n       * 获取元素类型，不存在就抛出异常\n       * @param pkgName 包名\n       * @param componentType 组件类型\n       */\n      getElementTypeOrThrow(pkgName: string, componentType: string): string\n      /**\n       * 确保元素类型\n       * @param pkgName 包名\n       * @param componentType 组件类型\n       */\n      ensureElementType(pkgName: string, componentType: string): string\n    }\n  }\n}\n\n/**\n * EditorPluginUidlStoreComponentsPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginUidlStoreComponentsPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginUidlStoreComponentsPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器 UIDL 仓库组件插件\n */\nexport const editorPluginUidlStoreComponents: EditorRawPlugin<\n  $EditorPluginUidlStoreComponentsPropertiesExtHkt,\n  | typeof editorPluginUidlStore\n  | typeof editorPluginUidlStoreEdit\n  | typeof editorPluginUidlUtilsConfig\n> = {\n  id: 'uidl-store-components',\n  initEditor(ctx) {\n    const { uidlStore, uidlUtilsConfig } = ctx\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    uidlStore.createUidlComponent = (pkgName, componentType) => {\n      const { pdStore } = ctx\n      const pd = pdStore.getPd(pkgName)\n      const cd = pdStore.getCd(pkgName, componentType)\n      const component = createUidlComponent(\n        uidlStore.getUidlOrThrow(),\n        pkgName,\n        pd.pkgVersion,\n        componentType,\n        cd.code.importPath || DEFAULT_IMPORT_EXPORT_PATH,\n      )\n      uidlStore.edit((uidl) => {\n        addUidlComponent(uidl, component)\n      })\n      return component\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    uidlStore.clearUidlComponents = () => {\n      uidlStore.edit((uidl) => {\n        const { components } = uidl\n        if (!components) return\n        const currentElementTypeSet = new Set(\n          components.map((component) => component.elementType),\n        )\n        const usingElementTypeSet = new Set<string>()\n        for (const ed of dfsElement(uidlUtilsConfig, uidl)) {\n          usingElementTypeSet.add(ed.element.type)\n        }\n        if (currentElementTypeSet.size === usingElementTypeSet.size) {\n          return\n        }\n        uidl.components = components.filter((component) =>\n          usingElementTypeSet.has(component.elementType),\n        )\n      })\n    }\n    const componentsToElementTypeMap = createWeakMemoizeArrayToMap(\n      (component: UidlComponent) => component.elementType,\n    )\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    uidlStore.getUidlComponent = (elementType) => {\n      const { components } = uidlStore.getUidlOrThrow()\n      return (\n        (components &&\n          componentsToElementTypeMap(components).get(elementType)) || {\n          elementType,\n          pkgName: DEFAULT_PKG_NAME,\n          pkgVersion: DEFAULT_PKG_VERSION,\n          componentType: elementType,\n        }\n      )\n    }\n    const componentsToPkgNameComponentTypeMap = createWeakMemoizeArrayToMap(\n      (component: UidlComponent) =>\n        jsonStringify([component.pkgName, component.componentType]),\n    )\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    uidlStore.getElementType = (pkgName, componentType) => {\n      if (pkgName === DEFAULT_PKG_NAME) {\n        return componentType\n      }\n      const { components } = uidlStore.getUidlOrThrow()\n      const component =\n        components &&\n        componentsToPkgNameComponentTypeMap(components).get(\n          jsonStringify([pkgName, componentType]),\n        )\n      return component?.elementType ?? null\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    uidlStore.getElementTypeOrThrow = (pkgName, componentType) => {\n      const ret = uidlStore.getElementType(pkgName, componentType)\n      if (isNull(ret)) {\n        throw new Error(\n          `The elementType not exists for pkgName=${pkgName} and componentType=${componentType}.`,\n        )\n      }\n      return ret\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    uidlStore.ensureElementType = (pkgName, componentType) => {\n      const ret = uidlStore.getElementType(pkgName, componentType)\n      if (isNull(ret)) {\n        return uidlStore.createUidlComponent(pkgName, componentType).elementType\n      }\n      return ret\n    }\n  },\n}\n","import type { Promisable } from '@p-lc/shared'\nimport { promisableThen } from '@p-lc/shared'\nimport { action } from 'mobx'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginEmitter } from '../editor-plugin-emitter'\nimport type { UidlStoreUidl } from './editor-plugin-uidl-store'\nimport { type editorPluginUidlStore } from './editor-plugin-uidl-store'\nimport {\n  EDITOR_EVENT_KEY_UIDL,\n  EDITOR_EVENT_UIDL_TYPE_INIT,\n  type editorPluginUidlStoreEdit,\n} from './editor-plugin-uidl-store-edit'\n\n/**\n * 编辑器 UIDL 仓库初始化插件属性扩展高等类型\n */\nexport interface EditorPluginUidlStoreInitPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * UIDL 仓库\n     */\n    uidlStore: {\n      /**\n       * 初始化\n       * @param uidl UIDL\n       */\n      init: (uidl: UidlStoreUidl<Plugin>) => void\n    }\n  }\n  editorInitOptions: {\n    /**\n     * UIDL 键值\n     */\n    uidlKey?: string\n    /**\n     * UIDL\n     */\n    uidl?: UidlStoreUidl<Plugin>\n    /**\n     * 加载 UIDL\n     */\n    loadUidl?: () => Promisable<UidlStoreUidl<Plugin>>\n  }\n}\n\n/**\n * EditorPluginUidlStoreInitPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginUidlStoreInitPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginUidlStoreInitPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器 UIDL 仓库初始化插件\n */\nexport const editorPluginUidlStoreInit: EditorRawPlugin<\n  $EditorPluginUidlStoreInitPropertiesExtHkt,\n  | typeof editorPluginUidlStore\n  | typeof editorPluginUidlStoreEdit\n  | typeof editorPluginEmitter\n> = {\n  id: 'uidl-store-init',\n  initEditor(ctx) {\n    const {\n      uidlStore,\n      emitter,\n      initOptions: {\n        uidlKey: initUidlKey,\n        uidl: initUidl,\n        loadUidl: initLoadUidl,\n      },\n    } = ctx\n    uidlStore.init = action((uidl) => {\n      uidlStore.uidl = uidl\n      emitter.emit(EDITOR_EVENT_KEY_UIDL, {\n        type: EDITOR_EVENT_UIDL_TYPE_INIT,\n        uidl,\n        patchs: [],\n      })\n    })\n    uidlStore.uidlKey = initUidlKey\n    if (initUidl) uidlStore.init(initUidl)\n    else if (initLoadUidl) {\n      promisableThen(initLoadUidl(), uidlStore.init)\n    }\n  },\n}\n","import { editorPluginUidlStore } from './editor-plugin-uidl-store'\nimport { editorPluginUidlStoreComponents } from './editor-plugin-uidl-store-components'\nimport { editorPluginUidlStoreEdit } from './editor-plugin-uidl-store-edit'\nimport { editorPluginUidlStoreInit } from './editor-plugin-uidl-store-init'\n\nexport * from './editor-plugin-uidl-store'\nexport * from './editor-plugin-uidl-store-components'\nexport * from './editor-plugin-uidl-store-edit'\nexport * from './editor-plugin-uidl-store-init'\n\n/**\n * 编辑器 UIDL 仓库插件\n */\nexport const editorUidlStorePlugins = [\n  editorPluginUidlStore,\n  editorPluginUidlStoreEdit,\n  editorPluginUidlStoreInit,\n  editorPluginUidlStoreComponents,\n]\n","import type { DataLoader, LiteralObject } from '@p-lc/shared'\nimport { LocalStorageDataLoader, defineLazyInitProperty } from '@p-lc/shared'\nimport { assign, debounce } from 'lodash-uni'\nimport { action, observable } from 'mobx'\nimport type { ReactNode } from 'react'\nimport type { Get } from 'type-fest'\nimport type {\n  AnyEditorPlugin,\n  Editor,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginName } from '../editor-plugin-name'\nimport { type editorPluginUidlStore } from '../uidl-store-plugins'\n\n/**\n * 编辑器布局仓库插件属性扩展高等类型\n */\nexport interface EditorPluginLayoutStorePropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 布局仓库\n     */\n    layoutStore: {\n      /**\n       * 配置\n       */\n      config: LiteralObject\n      /**\n       * 状态\n       */\n      state: LiteralObject\n      /**\n       * 设置状态\n       * @param state 状态\n       * @param autoSave 自动保存，默认 true\n       */\n      setState: (\n        state: Partial<LayoutStoreState<Plugin>>,\n        autoSave?: boolean,\n      ) => void\n      /**\n       * 状态加载器\n       */\n      stateLoader: LayoutStoreStateLoader<Plugin> | null\n      /**\n       * UIDL 状态\n       */\n      uidlState: LiteralObject\n      /**\n       * 设置 UIDL 状态\n       * @param uidlState UIDL 状态\n       * @param autoSave 自动保存，默认 true\n       */\n      setUidlState: (\n        uidlState: Partial<LayoutStoreUidlState<Plugin>>,\n        autoSave?: boolean,\n      ) => void\n      /**\n       * UIDL 状态加载器\n       */\n      uidlStateLoader: LayoutStoreUidlStateLoader<Plugin> | null\n      /**\n       * 渲染布局，由其他插件实现\n       */\n      render: () => ReactNode\n    }\n  }\n}\n\n/**\n * 布局仓库状态\n */\nexport type LayoutStoreState<Plugin extends AnyEditorPlugin> = Get<\n  Editor<Plugin>,\n  ['layoutStore', 'state']\n>\n\n/**\n * 布局仓库状态加载器\n */\nexport type LayoutStoreStateLoader<Plugin extends AnyEditorPlugin> =\n  DataLoader<LayoutStoreState<Plugin> | null>\n\n/**\n * 布局仓库 UIDL 状态\n */\nexport type LayoutStoreUidlState<Plugin extends AnyEditorPlugin> = Get<\n  Editor<Plugin>,\n  ['layoutStore', 'uidlState']\n>\n\n/**\n * 布局仓库 UIDL 状态加载器\n */\nexport type LayoutStoreUidlStateLoader<Plugin extends AnyEditorPlugin> =\n  DataLoader<LayoutStoreUidlState<Plugin> | null>\n\n/**\n * EditorPluginLayoutStorePropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginLayoutStorePropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginLayoutStorePropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器布局仓库插件\n */\nexport const editorPluginLayoutStore: EditorRawPlugin<\n  $EditorPluginLayoutStorePropertiesExtHkt,\n  typeof editorPluginName | typeof editorPluginUidlStore\n> = {\n  id: 'layout-store',\n  initEditor(ctx) {\n    const {\n      name: editorName,\n      uidlStore: { uidlKey },\n    } = ctx\n    const layoutStore = (ctx.layoutStore = {} as typeof ctx.layoutStore)\n    layoutStore.config = {}\n    layoutStore.state = observable({})\n    defineLazyInitProperty(\n      layoutStore,\n      'stateLoader',\n      () =>\n        new LocalStorageDataLoader<LiteralObject | null>(\n          `${editorName}:layout-state`,\n          null,\n        ),\n    )\n    const debounceSaveState = debounce(() => {\n      layoutStore.stateLoader?.save(layoutStore.state)\n    })\n    layoutStore.setState = action(\n      (state, autoSave = !!layoutStore.stateLoader) => {\n        assign(layoutStore.state, state)\n        if (autoSave) {\n          debounceSaveState()\n        }\n      },\n    )\n    layoutStore.uidlState = observable({})\n    defineLazyInitProperty(\n      layoutStore,\n      'uidlStateLoader',\n      () =>\n        new LocalStorageDataLoader<LiteralObject | null>(\n          `${editorName}:layout-uidl-state:${uidlKey}`,\n          null,\n        ),\n    )\n    const debounceSaveUidlState = debounce(() => {\n      layoutStore.uidlStateLoader?.save(layoutStore.uidlState)\n    })\n    layoutStore.setUidlState = action(\n      (uidlState, autoSave = !!layoutStore.uidlStateLoader) => {\n        assign(layoutStore.uidlState, uidlState)\n        if (autoSave) {\n          debounceSaveUidlState()\n        }\n      },\n    )\n  },\n}\n","import type { ReactElement } from 'react'\nimport type { EditorRawPlugin } from '../types'\nimport { type editorPluginLayoutStore } from './layout-store-plugins/editor-plugin-layout-store'\n\n/**\n * 编辑器渲染插件属性扩展\n */\nexport interface EditorPluginRenderPropertiesExt {\n  editor: {\n    /**\n     * 渲染\n     */\n    render: () => ReactElement\n  }\n}\n\n/**\n * 编辑器渲染插件\n */\nexport const editorPluginRender: EditorRawPlugin<\n  EditorPluginRenderPropertiesExt,\n  typeof editorPluginLayoutStore\n> = {\n  id: 'render',\n  initEditor(ctx) {\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    ctx.render = () => {\n      return <>{ctx.layoutStore.render()}</>\n    }\n  },\n}\n","import { createContext, useContext } from 'react'\nimport type { AnyEditor, DefaultEditor } from '../types'\nimport { type editorPluginRender } from './editor-plugin-render'\n\n/**\n * 编辑器 React 上下文\n */\nexport const EditorReactContext = createContext<AnyEditor | null>(null)\n\n/**\n * 编辑器 React 上下文提供者\n */\nexport const EditorReactContextProvider = EditorReactContext.Provider\n\n/**\n * 编辑器 React 上下文消费者\n */\nexport const EditorReactContextConsumer = EditorReactContext.Consumer\n\n/**\n * 使用编辑器\n */\nexport function useEditor<E = DefaultEditor>(): E {\n  return useContext(EditorReactContext)\n}\n\n/**\n * 编辑器 React 上下文插件\n */\nexport const editorPluginEditorReactContext: typeof editorPluginRender = {\n  id: 'editor-react-context',\n  initEditor(ctx) {\n    const { render: oldRender } = ctx\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    ctx.render = () => {\n      return (\n        <EditorReactContextProvider value={ctx}>\n          {oldRender()}\n        </EditorReactContextProvider>\n      )\n    }\n  },\n}\n","import type { StyleProps } from '@p-lc/react-shared'\nimport {\n  StyleablePopover,\n  useLatestFn,\n  withStylePropsObserver,\n} from '@p-lc/react-shared'\nimport { VCVN_Z_INDEX_MAX } from '@p-lc/shared'\nimport { Menu } from 'antd'\nimport type { MenuItemType } from 'antd/es/menu/interface'\nimport type { CSSProperties, FC } from 'react'\nimport React, { useMemo, useRef } from 'react'\nimport styled from 'styled-components'\nimport { useEditor } from '../editor-plugin-editor-react-context'\n\n/**\n * 上下文菜单属性\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface ContextMenuProps extends StyleProps {}\n\n/**\n * 上下文菜单\n */\nexport const ContextMenu: FC<ContextMenuProps> = withStylePropsObserver(() => {\n  const {\n    contextMenuStore: { visible, displayPoint, matchedItems, close },\n    i18nStore: { tText },\n  } = useEditor()\n  const refElContextMenu = useRef<HTMLDivElement>(null)\n  const getPopupContainer = useLatestFn(\n    () => refElContextMenu.current || document.body,\n  )\n  const anchorStyle = useMemo(\n    () =>\n      ({\n        left: displayPoint.x,\n        top: displayPoint.y,\n      }) satisfies CSSProperties,\n    [displayPoint],\n  )\n  const menuItems: MenuItemType[] = useMemo(\n    () =>\n      matchedItems.map(({ id, label }) => ({ key: id, label: tText(label) })),\n    [matchedItems, tText],\n  )\n  const handleContainerContextMenu = useLatestFn((ev: React.MouseEvent) => {\n    ev.preventDefault()\n    close()\n  })\n  const handleMaskClick = useLatestFn(() => close())\n  const handleMenuSelect = useLatestFn(({ key }: { key: string }) => {\n    close(matchedItems.find(({ id }) => id === key))\n  })\n  if (!visible) return null\n  return (\n    <InternalContextMenuContainer\n      className=\"lc-context-menu\"\n      onContextMenu={handleContainerContextMenu}\n      ref={refElContextMenu}\n    >\n      <div className=\"lc-mask\" onClick={handleMaskClick} />\n      <InternalContextMenuPopover\n        open\n        arrow={false}\n        placement=\"rightTop\"\n        mouseEnterDelay={0}\n        getPopupContainer={getPopupContainer}\n        content={<Menu items={menuItems} onSelect={handleMenuSelect} />}\n      >\n        <div className=\"lc-anchor\" style={anchorStyle} />\n      </InternalContextMenuPopover>\n    </InternalContextMenuContainer>\n  )\n})\n\n/**\n * 内部：上下文菜单容器\n */\nexport const InternalContextMenuContainer = styled.div`\n  position: fixed;\n  inset: 0;\n  z-index: ${VCVN_Z_INDEX_MAX};\n\n  .lc-mask {\n    position: absolute;\n    inset: 0;\n  }\n\n  .lc-anchor {\n    position: absolute;\n  }\n`\n\n/**\n * 内部：上下文菜单气泡卡片\n */\nexport const InternalContextMenuPopover = styled(StyleablePopover)`\n  .ant-popover-inner {\n    padding: 0;\n  }\n`\n","import type { HardAs, LiteralObject, Point, Text } from '@p-lc/shared'\nimport { zeroPoint } from '@p-lc/shared'\nimport { once, sortBy } from 'lodash-uni'\nimport { action, makeObservable, observable } from 'mobx'\nimport type { Get } from 'type-fest'\nimport type {\n  AnyEditorPlugin,\n  Editor,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginRender } from '../editor-plugin-render'\nimport { ContextMenu } from './context-menu'\n\n/**\n * 编辑器上下文菜单仓库插件属性扩展高等类型\n */\nexport interface EditorPluginContextMenuStorePropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 上下文菜单仓库\n     */\n    contextMenuStore: {\n      /**\n       * 上下文菜单实体，由其他插件扩展，只用于类型推导\n       */\n      contextMenuEntities: LiteralObject\n      /**\n       * 条目，id -> 条目\n       */\n      items: Record<string, ContextMenuItem<Plugin>>\n      /**\n       * 是否可见\n       */\n      visible: boolean\n      /**\n       * 展示点\n       */\n      displayPoint: Point\n      /**\n       * 已匹配的条目\n       */\n      matchedItems: ContextMenuItem<Plugin>[]\n      /**\n       * 当前实体\n       */\n      currentEntity: ContextMenuEntity<Plugin> | null\n      /**\n       * 打开\n       * @param entity 实体\n       * @param point 点\n       * @returns 是否成功打开\n       */\n      open(entity: ContextMenuEntity<Plugin>, point: Point): boolean\n      /**\n       * 关闭\n       * @item 需要执行的条目\n       */\n      close(item?: ContextMenuItem<Plugin>): void\n    }\n  }\n}\n\n/**\n * 上下文菜单实体基础部分\n */\nexport interface ContextMenuEntityBase {\n  /**\n   * 类型\n   */\n  type: string\n}\n\n/**\n * 上下文菜单实体\n */\nexport type ContextMenuEntities<Plugin extends AnyEditorPlugin> = Get<\n  Editor<Plugin>,\n  ['contextMenuStore', 'contextMenuEntities']\n>\n\n/**\n * 上下文菜单实体\n */\nexport type ContextMenuEntity<Plugin extends AnyEditorPlugin> = HardAs<\n  Get<ContextMenuEntities<Plugin>, [ContextMenuEntityType<Plugin>]>,\n  ContextMenuEntityBase\n>\n\n/**\n * 上下文菜单实体类型\n */\nexport type ContextMenuEntityType<Plugin extends AnyEditorPlugin> = HardAs<\n  keyof ContextMenuEntities<Plugin>,\n  string\n>\n\n/**\n * 上下文菜单条目\n */\nexport interface ContextMenuItem<Plugin extends AnyEditorPlugin> {\n  /**\n   * 唯一标识\n   */\n  id: string\n  /**\n   * 下标，小的在前，默认：Infinity\n   */\n  index?: number\n  /**\n   * 标签\n   */\n  label: Text\n  /**\n   * 匹配，匹配后才展示\n   * @param entity 实体\n   * @param ctx 上下文，编辑器\n   */\n  match(entity: ContextMenuEntity<Plugin>, ctx: Editor<Plugin>): boolean\n  /**\n   * 操作\n   * @param entity 实体\n   * @param ctx 上下文，编辑器\n   */\n  action(entity: ContextMenuEntity<Plugin>, ctx: Editor<Plugin>): void\n}\n\n/**\n * EditorPluginContextMenuStorePropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginContextMenuStorePropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginContextMenuStorePropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器上下文菜单仓库插件\n */\nexport const editorPluginContextMenuStore: EditorRawPlugin<\n  $EditorPluginContextMenuStorePropertiesExtHkt,\n  typeof editorPluginRender\n> = {\n  id: 'context-menu-store',\n  initEditor(ctx) {\n    const { render: oldRender } = ctx\n    const contextMenuStore = (ctx.contextMenuStore =\n      {} as typeof ctx.contextMenuStore)\n    contextMenuStore.items = {}\n    contextMenuStore.visible = false\n    contextMenuStore.displayPoint = zeroPoint\n    contextMenuStore.matchedItems = []\n    const getSortedItems = once(() =>\n      sortBy(contextMenuStore.items, ({ index = Infinity }) => index),\n    )\n    contextMenuStore.open = action((entity, point) => {\n      const matchedItems = getSortedItems().filter((item) =>\n        item.match(entity, ctx),\n      )\n      if (!matchedItems.length) return false\n      contextMenuStore.visible = true\n      contextMenuStore.displayPoint = point\n      contextMenuStore.matchedItems = matchedItems\n      contextMenuStore.currentEntity = entity\n      return true\n    })\n    contextMenuStore.close = action((item) => {\n      contextMenuStore.visible = false\n      if (item) {\n        // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n        item.action(contextMenuStore.currentEntity!, ctx)\n      }\n    })\n    makeObservable(contextMenuStore, {\n      visible: observable,\n    })\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    ctx.render = () => (\n      <>\n        {oldRender()}\n        <ContextMenu />\n      </>\n    )\n  },\n}\n","import type { SoftAs } from '@p-lc/shared'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport type {\n  ContextMenuEntity,\n  ContextMenuEntityBase,\n} from './editor-plugin-context-menu-store'\n\n/**\n * 编辑器上下文菜单仓库元素插件属性扩展\n */\nexport interface EditorPluginContextMenuStoreElementPropertiesExt {\n  editor: {\n    /**\n     * 上下文菜单仓库\n     */\n    contextMenuStore: {\n      /**\n       * 上下文菜单实体\n       */\n      contextMenuEntities: {\n        /**\n         * 上下文菜单元素\n         */\n        [K in ContextMenuEntityTypeElement]: ContextMenuElement\n      }\n    }\n  }\n}\n\n/**\n * 上下文菜单实体类型：元素\n */\nexport const CONTEXT_MENU_ENTITY_TYPE_ELEMENT = 'element'\n\n/**\n * 上下文菜单实体类型：元素\n */\nexport type ContextMenuEntityTypeElement =\n  typeof CONTEXT_MENU_ENTITY_TYPE_ELEMENT\n\n/**\n * 上下文菜单元素\n */\nexport interface ContextMenuElement extends ContextMenuEntityBase {\n  /**\n   * 类型\n   */\n  type: ContextMenuEntityTypeElement\n  /**\n   * 元素 ID\n   */\n  elementId: string\n}\n\n/**\n * 是上下文菜单元素\n * @param entity 实体\n */\nexport function isContextMenuElement<\n  Plugin extends AnyEditorPlugin = EditorDefaultPlugin,\n>(\n  entity: ContextMenuEntity<Plugin>,\n): entity is SoftAs<ContextMenuElement, ContextMenuEntity<Plugin>> {\n  return entity.type === CONTEXT_MENU_ENTITY_TYPE_ELEMENT\n}\n\n/**\n * 编辑器上下文菜单仓库元素插件\n */\nexport const editorPluginContextMenuStoreElement: EditorRawPlugin<EditorPluginContextMenuStoreElementPropertiesExt> =\n  {\n    id: 'context-menu-store-element',\n  }\n","import type { Point, Returnable } from '@p-lc/shared'\nimport { createPointByEventClient, getReturnValue } from '@p-lc/shared'\nimport type { MouseEventHandler } from 'react'\nimport { useMemo } from 'react'\nimport { useLatest } from 'react-use'\nimport type { AnyEditorPlugin, EditorDefaultPlugin } from '../../types'\nimport { useEditor } from '../editor-plugin-editor-react-context'\nimport type { ContextMenuEntity } from './editor-plugin-context-menu-store'\n\n/**\n * 使用上下文菜单属性\n */\nexport interface UseContextMenuProps {\n  /**\n   * 上下文菜单事件处理\n   */\n  onContextMenu: MouseEventHandler\n}\n\n/**\n * 使用上下文菜单\n * @param entity 实体，null 表示不打开\n */\nexport function useContextMenu<\n  Plugin extends AnyEditorPlugin = EditorDefaultPlugin,\n>(\n  entity: Returnable<\n    ContextMenuEntity<Plugin> | null,\n    [React.MouseEvent<Element, MouseEvent>, Point]\n  >,\n): UseContextMenuProps {\n  const {\n    contextMenuStore: { open },\n  } = useEditor()\n  const refLatestEntity = useLatest(entity)\n  return useMemo(\n    () => ({\n      onContextMenu(ev): void {\n        // TODO: 按住 Alt 或 option 键时，不打开右键菜单，模式（design mode/preview mode）\n        const point = createPointByEventClient(ev)\n        const et = getReturnValue(\n          refLatestEntity.current,\n          ev,\n          point,\n        ) as unknown as ContextMenuEntity<EditorDefaultPlugin> | null\n        if (!et) return\n        if (open(et, point)) {\n          ev.preventDefault()\n        }\n      },\n    }),\n    [open, refLatestEntity],\n  )\n}\n","import { editorPluginContextMenuStore } from './editor-plugin-context-menu-store'\nimport { editorPluginContextMenuStoreElement } from './editor-plugin-context-menu-store-element'\n\nexport * from './context-menu'\nexport * from './editor-plugin-context-menu-store'\nexport * from './editor-plugin-context-menu-store-element'\nexport * from './use-context-menu'\n\n/**\n * 编辑器上下文菜单仓库插件\n */\nexport const editorContextMenuStorePlugins = [\n  editorPluginContextMenuStore,\n  editorPluginContextMenuStoreElement,\n]\n","import { useLatestFn } from '@p-lc/react-shared'\nimport type { AnyObject } from '@p-lc/shared'\nimport type { FC, ReactNode } from 'react'\nimport { memo } from 'react'\nimport styled from 'styled-components'\nimport { useEditor } from '../editor-plugin-editor-react-context'\n\n/**\n * 根属性\n */\nexport interface RootProps {\n  children?: ReactNode\n}\n\n/**\n * 根\n */\nexport const Root: FC<RootProps> = memo(({ children }) => {\n  const ctx = useEditor()\n  const ref = useLatestFn((el: HTMLDivElement) => {\n    ctx.elRoot = el\n  })\n  const {\n    styleStore: { cssVars },\n  } = ctx\n  return (\n    <InternalRootContainer className=\"lc-root\" $cssVars={cssVars} ref={ref}>\n      {children}\n    </InternalRootContainer>\n  )\n})\n\n/**\n * 内部根容器\n */\nexport const InternalRootContainer = styled.div<{ $cssVars: AnyObject }>`\n  ${\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    (props) => props.$cssVars\n  }\n  width: 100%;\n  height: 100%;\n`\n","import type { EditorRawPlugin } from '../../types'\nimport { type editorPluginRender } from '../editor-plugin-render'\nimport { Root } from './root'\n\nexport * from './root'\n\n/**\n * 编辑器根宿主插件属性扩展\n */\nexport interface EditorPluginRootHostPropertiesExt {\n  editor: {\n    /**\n     * 根宿主元素\n     */\n    elRoot: HTMLElement | null\n  }\n}\n\n/**\n * 编辑器根宿主插件\n */\nexport const editorPluginRootHost: EditorRawPlugin<\n  EditorPluginRootHostPropertiesExt,\n  typeof editorPluginRender\n> = {\n  id: 'root-host',\n  initEditor(ctx) {\n    const { render: oldRender } = ctx\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    ctx.render = () => <Root>{oldRender()}</Root>\n  },\n}\n","import type {\n  HardAs,\n  LiteralObject,\n  Point,\n  Rectangle,\n  ReturnValueFn,\n} from '@p-lc/shared'\nimport {\n  createPointByEventClient,\n  distanceSquare,\n  getClosestHtmlElementBy,\n  winAddEventListener,\n  winRemoveEventListener,\n  zeroPoint,\n} from '@p-lc/shared'\nimport { isNull, now } from 'lodash-uni'\nimport { action, autorun, makeObservable, observable } from 'mobx'\nimport type { Get } from 'type-fest'\nimport type {\n  AnyEditorPlugin,\n  Editor,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginEmitter } from '../editor-plugin-emitter'\nimport { type editorPluginRootHost } from '../editor-plugin-root-host'\n\n/**\n * 编辑器拖放仓库插件属性扩展高等类型\n */\nexport interface EditorPluginDndStorePropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 发射器事件\n     */\n    emitterEvents: {\n      /**\n       * 拖拽开始\n       */\n      dragStart: {\n        /**\n         * 实体\n         */\n        entity: DraggableEntity<Plugin>\n        /**\n         * 点\n         */\n        point: Point\n      }\n      /**\n       * 拖拽移动\n       */\n      dragMove: {\n        /**\n         * 点\n         */\n        point: Point\n        /**\n         * 事件目标\n         */\n        target: EventTarget | null\n      }\n      /**\n       * 拖拽移动带位置\n       */\n      dragMoveWithPos: {\n        /**\n         * 点\n         */\n        point: Point\n        /**\n         * 位置\n         */\n        pos: DroppablePosition<Plugin> | null\n      }\n      /**\n       * 拖拽结束\n       */\n      dragEnd: void\n    }\n    /**\n     * 拖放仓库\n     */\n    dndStore: {\n      /**\n       * 可拖拽实体，由其他插件扩展，只用于类型推导\n       */\n      draggableEntities: LiteralObject\n      /**\n       * 可放置位置，由其他插件扩展，只用于类型推导\n       */\n      droppablePositions: LiteralObject\n      /**\n       * 拖拽中的实体\n       */\n      draggingEntity: DraggableEntity<Plugin> | null\n      /**\n       * 准备距离\n       */\n      preparingDistance: number\n      /**\n       * 准备（拖拽）中\n       */\n      isPreparing: boolean\n      /**\n       * 拖拽中\n       */\n      isDragging: boolean\n      /**\n       * 拖拽中的点\n       */\n      draggingPoint: Point\n      /**\n       * 可放置选项映射表\n       */\n      droppableOptionsMap: Map<\n        HTMLElement,\n        ReturnValueFn<DroppableOptions<Plugin>>\n      >\n      /**\n       * 悬浮的（可放置）位置\n       */\n      hoveringPosition: DroppablePosition<Plugin> | null\n      /**\n       * 可放置位置操作映射表\n       */\n      droppablePositionActionMap: Map<\n        DroppablePositionType<Plugin>,\n        DroppablePositionAction<Plugin>\n      >\n      /**\n       * 自动滚动（判定）距离，默认：50\n       */\n      autoScrollDistance: number\n      /**\n       * 自动滚动速度，每秒滚动的像素值，默认：500\n       */\n      autoScrollSpeed: number\n      /**\n       * 拖拽开始\n       * @param entity 实体\n       * @param point 点\n       */\n      dragStart(entity: DraggableEntity<Plugin>, point: Point): void\n      /**\n       * 拖拽移动\n       * @param point 点\n       * @param target 事件目标\n       */\n      dragMove(point: Point, target: EventTarget | null): void\n      /**\n       * 拖拽结束\n       */\n      dragEnd(): void\n      /**\n       * 应该阻止点击事件，拖拽后产生的点击事件需要被阻止\n       */\n      shouldPreventClick(): boolean\n      /**\n       * 应该阻止点击事件时长，默认 100 毫秒\n       */\n      shouldPreventClickDuration: number\n    }\n  }\n}\n\n/**\n * 编辑器事件键值：拖拽开始\n */\nexport const EDITOR_EVENT_KEY_DRAG_START = 'dragStart'\n\n/**\n * 编辑器事件键值：拖拽移动\n */\nexport const EDITOR_EVENT_KEY_DRAG_MOVE = 'dragMove'\n\n/**\n * 编辑器事件键值：拖拽移动带位置\n */\nexport const EDITOR_EVENT_KEY_DRAG_MOVE_WITH_POS = 'dragMoveWithPos'\n\n/**\n * 编辑器事件键值：拖拽结束\n */\nexport const EDITOR_EVENT_KEY_DRAG_END = 'dragEnd'\n\n/**\n * 可拖拽实体基础部分\n */\nexport interface DraggableEntityBase {\n  /**\n   * 类型\n   */\n  type: string\n}\n\n/**\n * 可拖拽实体\n */\nexport type DraggableEntities<Plugin extends AnyEditorPlugin> = Get<\n  Editor<Plugin>,\n  ['dndStore', 'draggableEntities']\n>\n\n/**\n * 可拖拽实体\n */\nexport type DraggableEntity<Plugin extends AnyEditorPlugin> = HardAs<\n  Get<DraggableEntities<Plugin>, [DraggableEntityType<Plugin>]>,\n  DraggableEntityBase\n>\n\n/**\n * 可拖拽实体类型\n */\nexport type DraggableEntityType<Plugin extends AnyEditorPlugin> = HardAs<\n  keyof DraggableEntities<Plugin>,\n  string\n>\n\n/**\n * 可放置位置基础部分\n */\nexport interface DroppablePositionBase {\n  /**\n   * 类型\n   */\n  type: string\n  /**\n   * 边界\n   */\n  bounding: Rectangle\n}\n\n/**\n * 可放置位置\n */\nexport type DroppablePositions<Plugin extends AnyEditorPlugin> = Get<\n  Editor<Plugin>,\n  ['dndStore', 'droppablePositions']\n>\n\n/**\n * 可放置位置\n */\nexport type DroppablePosition<Plugin extends AnyEditorPlugin> = HardAs<\n  Get<DroppablePositions<Plugin>, [DroppablePositionType<Plugin>]>,\n  DroppablePositionBase\n>\n\n/**\n * 可放置位置类型\n */\nexport type DroppablePositionType<Plugin extends AnyEditorPlugin> = HardAs<\n  keyof DroppablePositions<Plugin>,\n  string\n>\n\n/**\n * 可放置位置操作\n */\nexport interface DroppablePositionAction<Plugin extends AnyEditorPlugin> {\n  /**\n   * 可放置位置操作\n   * @param entity 实体\n   * @param pos 位置\n   */\n  (entity: DraggableEntity<Plugin>, pos: DroppablePosition<Plugin>): void\n}\n\n/**\n * 可放置选项\n */\nexport interface DroppableOptions<Plugin extends AnyEditorPlugin> {\n  /**\n   * 计算悬浮的位置\n   */\n  calcHoveringPosition: CaclHoveringPosition<Plugin>\n}\n\n/**\n * 计算悬浮的位置，当拖拽到当前原生元素上方时会触发\n */\nexport interface CaclHoveringPosition<Plugin extends AnyEditorPlugin> {\n  /**\n   * 计算悬浮的位置，当拖拽到当前原生元素上方时会触发\n   * @param entity 实体\n   * @param point 鼠标悬浮的点\n   * @param el HTML 元素\n   * @returns 返回位置或 null 将不会继续遍历原生父元素\n   */\n  (\n    entity: DraggableEntity<Plugin>,\n    point: Point,\n    el: HTMLElement,\n  ): DroppablePosition<Plugin> | null | void\n}\n\n/**\n * EditorPluginDndStorePropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginDndStorePropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginDndStorePropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器拖放仓库插件\n */\nexport const editorPluginDndStore: EditorRawPlugin<\n  $EditorPluginDndStorePropertiesExtHkt,\n  typeof editorPluginEmitter | typeof editorPluginRootHost\n> = {\n  id: 'dnd-store',\n  initEditor(ctx) {\n    const { emitter } = ctx\n    const dndStore = (ctx.dndStore = {} as typeof ctx.dndStore)\n    resetDraggingState()\n    dndStore.preparingDistance = 10\n    dndStore.draggingPoint = zeroPoint\n    const droppableOptionsMap = (dndStore.droppableOptionsMap =\n      new Map()) as typeof dndStore.droppableOptionsMap\n    const droppablePositionActionMap = (dndStore.droppablePositionActionMap =\n      new Map()) as typeof dndStore.droppablePositionActionMap\n    dndStore.autoScrollDistance = 50\n    dndStore.autoScrollSpeed = 500\n    dndStore.dragStart = action((entity, point) => {\n      resetDraggingState()\n      dndStore.draggingEntity = entity\n      dndStore.draggingPoint = point\n      addDragEventListeners()\n      emitter.emit(EDITOR_EVENT_KEY_DRAG_START, { entity, point })\n    })\n    dndStore.dragMove = action((point, target) => {\n      emitter.emit(EDITOR_EVENT_KEY_DRAG_MOVE, { point, target })\n      const entity = dndStore.draggingEntity\n      if (!entity) {\n        return\n      }\n      if (dndStore.isDragging) {\n        dndStore.draggingPoint = point\n      } else if (\n        distanceSquare(point, dndStore.draggingPoint) >\n        dndStore.preparingDistance ** 2\n      ) {\n        dndStore.isDragging = true\n        dndStore.draggingPoint = point\n      } else {\n        return\n      }\n      let pos: typeof dndStore.hoveringPosition = null\n      getClosestHtmlElementBy(target, (el) => {\n        const p = droppableOptionsMap\n          .get(el)?.()\n          .calcHoveringPosition(entity, point, el)\n        if (p || isNull(p)) {\n          pos = p\n          return true\n        }\n        return false\n      })\n      dndStore.hoveringPosition = pos\n      emitter.emit(EDITOR_EVENT_KEY_DRAG_MOVE_WITH_POS, { point, pos })\n    })\n    dndStore.dragEnd = action(() => {\n      const { draggingEntity, hoveringPosition, isDragging } = dndStore\n      if (isDragging) {\n        lastDragEndTime = now()\n      }\n      if (draggingEntity && hoveringPosition) {\n        droppablePositionActionMap.get(hoveringPosition.type)?.(\n          draggingEntity,\n          hoveringPosition,\n        )\n      }\n      resetDraggingState()\n      removeDragEventListeners()\n      emitter.emit(EDITOR_EVENT_KEY_DRAG_END)\n    })\n    makeObservable(dndStore, {\n      draggingEntity: observable.ref,\n      isPreparing: observable,\n      isDragging: observable,\n      draggingPoint: observable.ref,\n      hoveringPosition: observable.ref,\n    })\n    const preventUserSelectDisposer = autorun(() => {\n      document.body.style.userSelect = dndStore.draggingEntity ? 'none' : ''\n    })\n    let lastDragEndTime = 0\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    dndStore.shouldPreventClick = () => {\n      const currentTime = now()\n      const preventTime = lastDragEndTime + dndStore.shouldPreventClickDuration\n      return currentTime < preventTime\n    }\n    dndStore.shouldPreventClickDuration = 100\n    addClickEventListener()\n    return () => {\n      removeDragEventListeners()\n      removeClickEventListener()\n      preventUserSelectDisposer()\n    }\n\n    function resetDraggingState(): void {\n      dndStore.draggingEntity = null\n      dndStore.isPreparing = false\n      dndStore.isDragging = false\n      dndStore.hoveringPosition = null\n    }\n\n    function handleMouseMove(ev: MouseEvent): void {\n      if (!ctx.elRoot) {\n        // 没有挂载，取消事件处理\n        return\n      }\n      const point = createPointByEventClient(ev)\n      dndStore.dragMove(point, ev.target)\n    }\n\n    function handleMouseUp(): void {\n      if (!ctx.elRoot) {\n        // 没有挂载，取消事件处理\n        return\n      }\n      dndStore.dragEnd()\n    }\n\n    function addDragEventListeners(): void {\n      winAddEventListener('mousemove', handleMouseMove)\n      winAddEventListener('mouseup', handleMouseUp)\n    }\n\n    function removeDragEventListeners(): void {\n      winRemoveEventListener('mousemove', handleMouseMove)\n      winRemoveEventListener('mouseup', handleMouseUp)\n    }\n\n    function handleWinClickCapture(ev: MouseEvent): void {\n      if (!ctx.elRoot) {\n        // 没有挂载，取消事件处理\n        return\n      }\n      if (dndStore.shouldPreventClick()) ev.stopImmediatePropagation()\n    }\n\n    function addClickEventListener(): void {\n      winAddEventListener('click', handleWinClickCapture, true)\n    }\n\n    function removeClickEventListener(): void {\n      winRemoveEventListener('click', handleWinClickCapture, true)\n    }\n  },\n}\n","import type { StyleProps } from '@p-lc/react-shared'\nimport { withStylePropsObserver } from '@p-lc/react-shared'\nimport {\n  VCVN_BORDER_RADIUS,\n  VCVN_Z_INDEX_MAX,\n  getRectangleHeight,\n  getRectangleWidth,\n  pointToTranslate,\n} from '@p-lc/shared'\nimport type { FC } from 'react'\nimport styled from 'styled-components'\nimport { useEditor } from '../../editor-plugin-editor-react-context'\n\n/**\n * 拖放遮罩\n */\nexport const DndMask: FC<StyleProps> = withStylePropsObserver(() => {\n  const {\n    dndStore: { isDragging },\n  } = useEditor()\n  if (!isDragging) return null\n  return (\n    <InternalDndMaskContainer className=\"lc-dnd-mask\">\n      <DndDroppablePosition />\n      <DndDraggingEntity />\n    </InternalDndMaskContainer>\n  )\n})\n\n/**\n * 内部：拖放遮罩容器\n */\nexport const InternalDndMaskContainer = styled.div`\n  position: fixed;\n  inset: 0px;\n  z-index: ${VCVN_Z_INDEX_MAX};\n  pointer-events: none;\n  user-select: none;\n`\n\n/**\n * 可放置位置\n */\nexport const DndDroppablePosition: FC<StyleProps> = withStylePropsObserver(\n  () => {\n    const {\n      dndStore: { droppablePositionRendererMap, hoveringPosition },\n    } = useEditor()\n    const Renderer =\n      hoveringPosition &&\n      droppablePositionRendererMap.get(hoveringPosition.type)\n    const bounding = hoveringPosition?.bounding\n    return (\n      <InternalDndDroppablePositionContainer\n        style={\n          bounding && {\n            top: bounding.s.y,\n            left: bounding.s.x,\n            width: getRectangleWidth(bounding),\n            height: getRectangleHeight(bounding),\n          }\n        }\n      >\n        {Renderer && <Renderer {...hoveringPosition} />}\n      </InternalDndDroppablePositionContainer>\n    )\n  },\n)\n\n/**\n * 内部：可放置位置容器\n */\nexport const InternalDndDroppablePositionContainer = styled.div`\n  position: absolute;\n  z-index: 1;\n`\n\n/**\n * 拖拽中的实体\n */\nexport const DndDraggingEntity: FC<StyleProps> = withStylePropsObserver(() => {\n  const {\n    dndStore: { draggableEntityRendererMap, draggingEntity, draggingPoint },\n  } = useEditor()\n  const Renderer =\n    draggingEntity && draggableEntityRendererMap.get(draggingEntity.type)\n  if (!Renderer) return null\n  return (\n    <InternalDndDraggingEntityContainer\n      className=\"lc-dnd-entity\"\n      style={{\n        transform: pointToTranslate(draggingPoint),\n      }}\n    >\n      <Renderer {...draggingEntity} />\n    </InternalDndDraggingEntityContainer>\n  )\n})\n\n/**\n * 内部：拖拽中的实体容器\n */\nexport const InternalDndDraggingEntityContainer = styled.div`\n  position: absolute;\n  top: 0;\n  left: 0;\n  padding: 4px;\n  border: 1px solid;\n  border-radius: ${VCVN_BORDER_RADIUS};\n  background: #bec8c8;\n  opacity: 0.6;\n  z-index: 2;\n`\n","import type { FC } from 'react'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginRender } from '../editor-plugin-render'\nimport { DndMask } from './components'\nimport type {\n  DraggableEntity,\n  DraggableEntityType,\n  DroppablePosition,\n  DroppablePositionType,\n} from './editor-plugin-dnd-store'\n\n/**\n * 编辑器拖放仓库遮罩插件属性扩展高等类型\n */\nexport interface EditorPluginDndStoreMaskPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 拖放仓库\n     */\n    dndStore: {\n      /**\n       * 可拖拽的实体渲染器映射表\n       */\n      draggableEntityRendererMap: Map<\n        DraggableEntityType<Plugin>,\n        DraggableEntityRenderer<Plugin>\n      >\n      /**\n       * 可放置位置渲染器映射表\n       */\n      droppablePositionRendererMap: Map<\n        DroppablePositionType<Plugin>,\n        DroppablePositionRenderer<Plugin>\n      >\n    }\n  }\n}\n\n/**\n * 可拖拽实体渲染器\n */\nexport type DraggableEntityRenderer<Plugin extends AnyEditorPlugin> = FC<\n  DraggableEntity<Plugin>\n>\n\n/**\n * 可放置位置渲染器\n */\nexport type DroppablePositionRenderer<Plugin extends AnyEditorPlugin> = FC<\n  DroppablePosition<Plugin>\n>\n\n/**\n * EditorPluginDndStoreMaskPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginDndStoreMaskPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginDndStoreMaskPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器拖放仓库遮罩插件\n */\nexport const editorPluginDndStoreMask: EditorRawPlugin<\n  $EditorPluginDndStoreMaskPropertiesExtHkt,\n  typeof editorPluginRender\n> = {\n  id: 'dnd-store-mask',\n  initEditor(ctx) {\n    const { dndStore, render: oldRender } = ctx\n    dndStore.draggableEntityRendererMap = new Map()\n    dndStore.droppablePositionRendererMap = new Map()\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    ctx.render = () => (\n      <>\n        {oldRender()}\n        <DndMask />\n      </>\n    )\n  },\n}\n","import type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport type { UidlStoreUidlElement } from '../uidl-store-plugins'\nimport { type editorPluginUidlStore } from '../uidl-store-plugins'\nimport { DraggableElementRenderer } from './components'\nimport type { DraggableEntityBase } from './editor-plugin-dnd-store'\nimport { type editorPluginDndStoreMask } from './editor-plugin-dnd-store-mask'\n\n/**\n * 编辑器拖放仓库元素渲染器插件属性扩展高等类型\n */\nexport interface EditorPluginDndStoreElementRendererPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 拖放仓库\n     */\n    dndStore: {\n      /**\n       * 可拖拽实体\n       */\n      draggableEntities: {\n        /**\n         * 可拖拽元素\n         */\n        [K in DraggableEntityTypeElement]: DraggableElement<Plugin>\n      }\n    }\n  }\n}\n\n/**\n * 可拖拽元素\n */\nexport interface DraggableElement<Plugin extends AnyEditorPlugin>\n  extends DraggableEntityBase {\n  /**\n   * 类型\n   */\n  type: DraggableEntityTypeElement\n  /**\n   * 元素\n   */\n  element: UidlStoreUidlElement<Plugin>\n}\n\n/**\n * 可拖拽实体类型：元素\n */\nexport const DRAGGABLE_ENTITY_TYPE_ELEMENT = 'element'\n\n/**\n * 可拖拽实体类型：元素\n */\nexport type DraggableEntityTypeElement = typeof DRAGGABLE_ENTITY_TYPE_ELEMENT\n\n/**\n * EditorPluginDndStoreElementRendererPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginDndStoreElementRendererPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginDndStoreElementRendererPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器拖放仓库元素渲染器插件\n */\nexport const editorPluginDndStoreElementRenderer: EditorRawPlugin<\n  $EditorPluginDndStoreElementRendererPropertiesExtHkt,\n  typeof editorPluginDndStoreMask | typeof editorPluginUidlStore\n> = {\n  id: 'dnd-store-element-renderer',\n  initEditor(ctx) {\n    const { dndStore } = ctx\n    dndStore.draggableEntityRendererMap.set(\n      DRAGGABLE_ENTITY_TYPE_ELEMENT,\n      DraggableElementRenderer,\n    )\n  },\n}\n","import type { StyleProps } from '@p-lc/react-shared'\nimport {\n  ComponentIcon,\n  TypographyText,\n  withStylePropsMemo,\n} from '@p-lc/react-shared'\nimport type { FC } from 'react'\nimport { memo } from 'react'\nimport styled from 'styled-components'\nimport type { DepPluginUniteEditorPlugin } from '../../../types'\nimport { useEditor } from '../../editor-plugin-editor-react-context'\nimport type { DraggableElement } from '../editor-plugin-dnd-store-element-renderer'\nimport { type editorPluginDndStoreElementRenderer } from '../editor-plugin-dnd-store-element-renderer'\n\n/**\n * 可拖拽元素渲染器属性\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface DraggableElementRendererProps\n  extends DraggableElement<\n    DepPluginUniteEditorPlugin<typeof editorPluginDndStoreElementRenderer>\n  > {}\n\n/**\n * 可拖拽元素渲染器\n */\nexport const DraggableElementRenderer: FC<DraggableElementRendererProps> = memo(\n  ({ element }) => {\n    const {\n      pdStore: { getComponentIconByEt },\n    } = useEditor()\n    const icon = getComponentIconByEt(element.type)\n    return <DraggableIconAndName icon={icon} name={element.name} />\n  },\n)\n\n/**\n * 可拖拽的图标和名称属性\n */\nexport interface DraggableElementIconAndNameProps extends StyleProps {\n  /**\n   * 图标\n   */\n  icon?: string | null\n  /**\n   * 名称\n   */\n  name?: string | null\n}\n\n/**\n * 可拖拽的图标和名称\n */\nexport const DraggableIconAndName: FC<DraggableElementIconAndNameProps> =\n  withStylePropsMemo(({ icon, name }) => {\n    return (\n      <InternalDraggableIconAndNameContainer className=\"lc-draggable-icon-name\">\n        {icon && <ComponentIcon icon={icon} />}\n        {name && <TypographyText className=\"lc-name\">{name}</TypographyText>}\n      </InternalDraggableIconAndNameContainer>\n    )\n  })\n\n/**\n * 内部可拖拽的图标和名称称容器\n */\nexport const InternalDraggableIconAndNameContainer = styled.div`\n  display: flex;\n  align-items: center;\n`\n","import type { FC } from 'react'\nimport { memo } from 'react'\nimport { useEditor } from '../../editor-plugin-editor-react-context'\nimport type { DraggableComponent } from '../editor-plugin-dnd-store-component-renderer'\nimport { DraggableIconAndName } from './draggable-element-renderer'\n\n/**\n * 可拖拽组件渲染器属性\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-object-type\nexport interface DraggableComponentRendererProps extends DraggableComponent {}\n\n/**\n * 可拖拽组件渲染器\n */\nexport const DraggableComponentRenderer: FC<DraggableComponentRendererProps> =\n  memo(({ pkgName, componentType }) => {\n    const {\n      pdStore: { getComponentIcon, getComponentName },\n    } = useEditor()\n    const icon = getComponentIcon(pkgName, componentType)\n    const name = getComponentName(pkgName, componentType)\n    return <DraggableIconAndName icon={icon} name={name} />\n  })\n","import type { EditorRawPlugin } from '../../types'\nimport { type editorPluginUidlStore } from '../uidl-store-plugins'\nimport { DraggableComponentRenderer } from './components'\nimport type { DraggableEntityBase } from './editor-plugin-dnd-store'\nimport { type editorPluginDndStoreMask } from './editor-plugin-dnd-store-mask'\n\n/**\n * 编辑器拖放仓库组件渲染器插件属性扩展\n */\nexport interface EditorPluginDndStoreComponentRendererPropertiesExt {\n  editor: {\n    /**\n     * 拖放仓库\n     */\n    dndStore: {\n      /**\n       * 可拖拽实体\n       */\n      draggableEntities: {\n        /**\n         * 可拖拽组件\n         */\n        [K in DraggableEntityTypeComponent]: DraggableComponent\n      }\n    }\n  }\n}\n\n/**\n * 可拖拽组件\n */\nexport interface DraggableComponent extends DraggableEntityBase {\n  /**\n   * 类型\n   */\n  type: DraggableEntityTypeComponent\n  /**\n   * 包名\n   */\n  pkgName: string\n  /**\n   * 组件类型\n   */\n  componentType: string\n}\n\n/**\n * 可拖拽实体类型：组件\n */\nexport const DRAGGABLE_ENTITY_TYPE_COMPONENT = 'component'\n\n/**\n * 可拖拽实体类型：组件\n */\nexport type DraggableEntityTypeComponent =\n  typeof DRAGGABLE_ENTITY_TYPE_COMPONENT\n\n/**\n * 编辑器拖放仓库组件渲染器插件\n */\nexport const editorPluginDndStoreComponentRenderer: EditorRawPlugin<\n  EditorPluginDndStoreComponentRendererPropertiesExt,\n  typeof editorPluginDndStoreMask | typeof editorPluginUidlStore\n> = {\n  id: 'dnd-store-component-renderer',\n  initEditor(ctx) {\n    const { dndStore } = ctx\n    dndStore.draggableEntityRendererMap.set(\n      DRAGGABLE_ENTITY_TYPE_COMPONENT,\n      DraggableComponentRenderer,\n    )\n  },\n}\n","import { useEffect } from 'react'\nimport { useLatest } from 'react-use'\nimport type { Get } from 'type-fest'\nimport type { DefaultEditor } from '../../../types'\nimport { useEditor } from '../../editor-plugin-editor-react-context'\nimport {\n  EDITOR_EVENT_KEY_DRAG_END,\n  EDITOR_EVENT_KEY_DRAG_MOVE,\n} from '../editor-plugin-dnd-store'\n\n/**\n * 使用拖拽移动回调选项\n */\nexport type UseDragMoveCbOptions<E = DefaultEditor> = Get<\n  E,\n  ['emitterEvents', typeof EDITOR_EVENT_KEY_DRAG_MOVE]\n>\n\n/**\n * 使用拖拽移动回调\n */\nexport interface UseDragMoveCb<E = DefaultEditor> {\n  /**\n   * 使用拖拽移动回调\n   * @param options 选项\n   */\n  (options: UseDragMoveCbOptions<E>): void\n}\n\n/**\n * 使用拖拽移动\n * @param cb 回调\n * @param endCb 拖拽结束回调\n */\nexport function useDragMove<E = DefaultEditor>(\n  cb: UseDragMoveCb<E>,\n  endCb?: () => void,\n): void {\n  const refLatestCb = useLatest(cb)\n  const refLatestEndCb = useLatest(endCb)\n  const { emitter } = useEditor()\n  useEffect(() => {\n    emitter.on(EDITOR_EVENT_KEY_DRAG_MOVE, dragMove)\n    emitter.on(EDITOR_EVENT_KEY_DRAG_END, dragEnd)\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    return () => {\n      emitter.off(EDITOR_EVENT_KEY_DRAG_MOVE, dragMove)\n      emitter.off(EDITOR_EVENT_KEY_DRAG_END, dragEnd)\n    }\n\n    function dragMove(options: UseDragMoveCbOptions): void {\n      refLatestCb.current(options as UseDragMoveCbOptions<E>)\n    }\n\n    function dragEnd(): void {\n      refLatestEndCb.current?.()\n    }\n  }, [emitter, refLatestCb, refLatestEndCb])\n}\n","import { useLatestFn } from '@p-lc/react-shared'\nimport type { ContinuousScroller, Point } from '@p-lc/shared'\nimport {\n  createPoint,\n  createRectangleByHtmlElement,\n  createRectangleByZoom,\n  getClosestHtmlElementBy,\n  isChildHtmlElement,\n  isInRectangle,\n  isScrollableHtmlElement,\n  mathAbs,\n  startContinuousScroll,\n  zeroPoint,\n} from '@p-lc/shared'\nimport type { RefObject } from 'react'\nimport { useRef } from 'react'\nimport type { DefaultEditor } from '../../../types'\nimport { useEditor } from '../../editor-plugin-editor-react-context'\nimport type { UseDragMoveCbOptions } from './use-drag-move'\nimport { useDragMove } from './use-drag-move'\n\n/**\n * 使用拖拽自动滚动获取可滚动元素\n */\nexport interface UseDragAutoScrollGetScrollable<\n  T extends HTMLElement,\n  E = DefaultEditor,\n> {\n  /**\n   * 使用拖拽移动回调\n   * @param options 选项\n   */\n  (options: UseDragMoveCbOptions<E>): T | null | undefined\n}\n\n/**\n * 使用拖拽自动滚动\n */\nexport function useDragAutoScroll<T extends HTMLElement, E = DefaultEditor>(\n  getScrollable: UseDragAutoScrollGetScrollable<T, E>,\n): void {\n  const {\n    dndStore: { autoScrollDistance, autoScrollSpeed },\n  } = useEditor()\n  const getVector = useLatestFn((el: T, point: Point) => {\n    const bounding = createRectangleByHtmlElement(el)\n    if (\n      !isInRectangle(point, createRectangleByZoom(bounding, autoScrollDistance))\n    ) {\n      return zeroPoint\n    }\n    let dx = 0\n    let dy = 0\n    if (mathAbs(point.x - bounding.s.x) < autoScrollDistance) {\n      dx = -autoScrollSpeed\n    } else if (mathAbs(bounding.e.x - point.x) < autoScrollDistance) {\n      dx = autoScrollSpeed\n    }\n    if (mathAbs(point.y - bounding.s.y) < autoScrollDistance) {\n      dy = -autoScrollSpeed\n    } else if (mathAbs(bounding.e.y - point.y) < autoScrollDistance) {\n      dy = autoScrollSpeed\n    }\n    return createPoint(dx, dy)\n  })\n  const refContinuousScroller = useRef<ContinuousScroller<T>>()\n  useDragMove(\n    (options) => {\n      const { point } = options\n      const el = getScrollable(options as UseDragMoveCbOptions<E>)\n      let scroller = refContinuousScroller.current\n      if (!el) {\n        scroller?.dispose()\n        refContinuousScroller.current = undefined\n        return\n      }\n      const v = getVector(el, point)\n      if (scroller?.obj !== el) {\n        scroller?.dispose()\n        scroller = refContinuousScroller.current = startContinuousScroll(el, v)\n      } else {\n        scroller.vector = v\n      }\n    },\n    () => {\n      const scroller = refContinuousScroller.current\n      if (!scroller) return\n      scroller.dispose()\n      delete refContinuousScroller.current\n    },\n  )\n}\n\n/**\n * 使用拖拽自动滚动引用\n * @param shouldFindScrollableChild 需要查找可滚动的子元素\n * @param checkDisable 检查是否禁止\n */\nexport function useDragAutoScrollRef<T extends HTMLElement>(\n  shouldFindScrollableChild?: boolean,\n  checkDisable?: () => boolean,\n): RefObject<T> {\n  void shouldFindScrollableChild\n  const refEl = useRef<T>(null)\n  useDragAutoScroll(({ target }) => {\n    if (checkDisable?.()) return null\n    let el = refEl.current\n    if (el && shouldFindScrollableChild) {\n      const elScrollable = getClosestHtmlElementBy(\n        target,\n        isScrollableHtmlElement,\n      )\n      if (isChildHtmlElement(el, elScrollable)) {\n        el = elScrollable as T\n      }\n    }\n    return el\n  })\n  return refEl\n}\n","import type { Point, Returnable } from '@p-lc/shared'\nimport { createPointByEventClient, getReturnValue } from '@p-lc/shared'\nimport type React from 'react'\nimport type { MouseEventHandler } from 'react'\nimport { useMemo } from 'react'\nimport { useLatest } from 'react-use'\nimport type { AnyEditorPlugin, EditorDefaultPlugin } from '../../../types'\nimport { useEditor } from '../../editor-plugin-editor-react-context'\nimport type { DraggableEntity } from '../editor-plugin-dnd-store'\n\n/**\n * 可拖拽属性\n */\nexport interface DraggableProps {\n  /**\n   * 鼠标按压事件处理\n   */\n  onMouseDown: MouseEventHandler\n}\n\n/**\n * 使用可拖拽\n * @param entity 实体，null 表示不可拖拽\n */\nexport function useDraggable<\n  Plugin extends AnyEditorPlugin = EditorDefaultPlugin,\n>(\n  entity: Returnable<\n    DraggableEntity<Plugin> | null,\n    [React.MouseEvent<Element, MouseEvent>, Point]\n  >,\n): DraggableProps {\n  const {\n    dndStore: { dragStart },\n  } = useEditor()\n  const refLatestEntity = useLatest(entity)\n  return useMemo(\n    () => ({\n      onMouseDown(ev): void {\n        // 非左键返回\n        if (ev.buttons !== 1) return\n        // TODO: 按住 Alt 或 option 键时，不发起拖拽，模式（design mode/preview mode）\n        const point = createPointByEventClient(ev)\n        const et = getReturnValue(\n          refLatestEntity.current,\n          ev,\n          point,\n        ) as unknown as DraggableEntity<EditorDefaultPlugin> | null\n        if (!et) return\n        dragStart(et, point)\n      },\n    }),\n    [dragStart, refLatestEntity],\n  )\n}\n","import { useLatestFn } from '@p-lc/react-shared'\nimport type { RefCallback } from 'react'\nimport { useMemo } from 'react'\nimport type { AnyEditorPlugin, EditorDefaultPlugin } from '../../../types'\nimport { useEditor } from '../../editor-plugin-editor-react-context'\nimport type {\n  CaclHoveringPosition,\n  DroppableOptions,\n} from '../editor-plugin-dnd-store'\n\n/**\n * 可放置属性\n */\nexport interface DroppableProps {\n  /**\n   * 引用\n   */\n  ref: RefCallback<HTMLElement>\n}\n\n/**\n * 使用可放置\n * @param calcHoveringPosition 计算悬浮的位置\n */\nexport function useDroppable<\n  Plugin extends AnyEditorPlugin = EditorDefaultPlugin,\n>(calcHoveringPosition: CaclHoveringPosition<Plugin>): DroppableProps {\n  const latestCalcHoveringPosition = useLatestFn(calcHoveringPosition)\n  const {\n    dndStore: { droppableOptionsMap },\n  } = useEditor()\n  const ref: RefCallback<HTMLElement> = useMemo(() => {\n    let lastEl: HTMLElement | null | undefined\n    return (el) => {\n      if (lastEl) {\n        droppableOptionsMap.delete(lastEl)\n      }\n      if (el) {\n        droppableOptionsMap.set(\n          el,\n          () =>\n            ({\n              calcHoveringPosition: latestCalcHoveringPosition,\n            }) as unknown as DroppableOptions<EditorDefaultPlugin>,\n        )\n      }\n      lastEl = el\n    }\n  }, [droppableOptionsMap, latestCalcHoveringPosition])\n  return useMemo(\n    () => ({\n      ref,\n    }),\n    [ref],\n  )\n}\n","import type { SoftAs } from '@p-lc/shared'\nimport type { AnyEditorPlugin, EditorDefaultPlugin } from '../../types'\nimport type { DraggableEntity } from './editor-plugin-dnd-store'\nimport type { DraggableComponent } from './editor-plugin-dnd-store-component-renderer'\nimport { DRAGGABLE_ENTITY_TYPE_COMPONENT } from './editor-plugin-dnd-store-component-renderer'\nimport type { DraggableElement } from './editor-plugin-dnd-store-element-renderer'\nimport { DRAGGABLE_ENTITY_TYPE_ELEMENT } from './editor-plugin-dnd-store-element-renderer'\n\n/**\n * 是可拖拽元素或组件\n * @param entity 实体\n */\nexport function isDraggableElementOrComponent<\n  Plugin extends AnyEditorPlugin = EditorDefaultPlugin,\n>(\n  entity: DraggableEntity<Plugin>,\n): entity is SoftAs<\n  DraggableElement<Plugin> | DraggableComponent,\n  DraggableEntity<Plugin>\n> {\n  return [\n    DRAGGABLE_ENTITY_TYPE_ELEMENT,\n    DRAGGABLE_ENTITY_TYPE_COMPONENT,\n  ].includes(entity.type)\n}\n","import { editorPluginDndStore } from './editor-plugin-dnd-store'\nimport { editorPluginDndStoreComponentRenderer } from './editor-plugin-dnd-store-component-renderer'\nimport { editorPluginDndStoreElementRenderer } from './editor-plugin-dnd-store-element-renderer'\nimport { editorPluginDndStoreMask } from './editor-plugin-dnd-store-mask'\n\nexport * from './components'\nexport * from './editor-plugin-dnd-store'\nexport * from './editor-plugin-dnd-store-component-renderer'\nexport * from './editor-plugin-dnd-store-element-renderer'\nexport * from './editor-plugin-dnd-store-mask'\nexport * from './hooks'\nexport * from './utils'\n\n/**\n * 编辑器拖放仓库插件\n */\nexport const editorDndStorePlugins = [\n  editorPluginDndStore,\n  editorPluginDndStoreMask,\n  editorPluginDndStoreElementRenderer,\n  editorPluginDndStoreComponentRenderer,\n]\n","import type { LiteralObject } from '@p-lc/shared'\nimport type { EditorRawPlugin } from '../../types'\nimport { type editorPluginUidlStore } from '../uidl-store-plugins'\n\n/**\n * 编辑器元素仓库插件属性扩展\n */\nexport interface EditorPluginElementStorePropertiesExt {\n  editor: {\n    /**\n     * 元素仓库\n     */\n    elementStore: LiteralObject\n  }\n}\n\n/**\n * 编辑器元素仓库插件\n */\nexport const editorPluginElementStore: EditorRawPlugin<\n  EditorPluginElementStorePropertiesExt,\n  typeof editorPluginUidlStore\n> = {\n  id: 'element-store',\n  initEditor(ctx) {\n    ctx.elementStore = {} as typeof ctx.elementStore\n  },\n}\n","import { mergePkgNameToI18nKey } from '@p-lc/pd-utils'\nimport type {\n  AnyObject,\n  DataLoader,\n  I18nResource,\n  LiteralObject,\n  Text,\n} from '@p-lc/shared'\nimport {\n  EN_US,\n  LocalStorageDataLoader,\n  NAME_EN_US,\n  NAME_ZH_CN,\n  ZH_CN,\n  create,\n  defaultLanguageNames,\n  defineLazyInitProperty,\n  defineProperty,\n  getLanguageByUa,\n} from '@p-lc/shared'\nimport { debounce, get, isString, keys, merge, once } from 'lodash-uni'\nimport { action } from 'mobx'\nimport type { Get } from 'type-fest'\nimport type {\n  AnyEditorPlugin,\n  Editor,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport type { editorPluginName } from '../editor-plugin-name'\n\n/**\n * 编辑器国际化仓库插件属性扩展高等类型\n */\nexport interface EditorPluginI18nStorePropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 国际化仓库\n     */\n    i18nStore: {\n      /**\n       * 所有支持的语言\n       */\n      languages: string[]\n      /**\n       * 语言名称\n       */\n      languageNames: Record<string, string>\n      /**\n       * 设置语言名称\n       * @param languageNames 语言名称\n       */\n      setLanguageNames(languageNames: Record<string, string>): void\n      /**\n       * （当前）语言\n       */\n      language: string\n      /**\n       * 设置语言\n       * @param language 语言\n       * @param save 保存当前语言，默认为: true\n       */\n      setLanguage(language: string, save?: boolean): void\n      /**\n       * 添加资源，以 merge 的形式\n       * @param resource 资源\n       * @param isImportant 重要，默认：false，为 true 时会覆盖 初始化选项里的资源\n       */\n      addResource(resource: I18nResource, isImportant?: boolean): void\n      /**\n       * 翻译键值选项，由其他插件扩展，只用于类型推导\n       */\n      tKeyOptions?: LiteralObject\n      /**\n       * 翻译\n       * @param key 键值\n       * @param options 选项\n       */\n      t<T extends keyof I18nStoreTKeyOptions<Plugin>>(\n        key: T,\n        options?: I18nStoreTKeyOptions<Plugin>[T],\n      ): string\n      t(key: string, options?: AnyObject): string\n      /**\n       * 翻译（国际化）文本\n       * @param text 文本\n       * @param options 选项\n       */\n      tText<T extends keyof I18nStoreTKeyOptions<Plugin>>(\n        text: Text<T extends string ? T : string>,\n        options?: I18nStoreTKeyOptions<Plugin>[T],\n      ): string\n      tText(text: Text, options?: AnyObject): string\n      /**\n       * 国际化状态加载器\n       */\n      i18nStateLoader: DataLoader<I18nState | null> | null\n    }\n  }\n}\n\n/**\n * 国际化仓库翻译键值选项\n */\nexport type I18nStoreTKeyOptions<Plugin extends AnyEditorPlugin> = Get<\n  Editor<Plugin>,\n  ['i18nStore', 'tKeyOptions']\n>\n\n/**\n * 国际化状态\n */\nexport interface I18nState {\n  /**\n   * 语言\n   */\n  language: string\n}\n\n/**\n * EditorPluginI18nStorePropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginI18nStorePropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginI18nStorePropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器国际化仓库插件\n */\nexport const editorPluginI18nStore: EditorRawPlugin<\n  $EditorPluginI18nStorePropertiesExtHkt,\n  typeof editorPluginName\n> = {\n  id: 'i18n-store',\n  initEditor(ctx) {\n    const { name: editorName } = ctx\n    const i18nStore = (ctx.i18nStore = {} as typeof ctx.i18nStore)\n    const setLanguageByUa = process.env.LC_LANGUAGE\n      ? null\n      : once((languages: string[]) => {\n          if (!languages.length) return\n          i18nStore.setLanguage(getLanguageByUa(languages), false)\n        })\n    const setLanguageNames = (i18nStore.setLanguageNames = action(\n      (languageNames) => {\n        const languages = (i18nStore.languages = keys(languageNames))\n        i18nStore.languageNames = languageNames\n        setLanguageByUa?.(languages)\n      },\n    ))\n    // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n    i18nStore.language = process.env.LC_LANGUAGE!\n    i18nStore.setLanguage = action((language, save = true) => {\n      i18nStore.language = language\n      if (save) {\n        debounceSaveI18nState({ language })\n      }\n    })\n    let initLanguageNames: typeof i18nStore.languageNames = {}\n    //#region i18n 摇树\n    // 打包器预处理，只能处理 if-else，不能处理 switch-case\n    if (!process.env.LC_LANGUAGE) {\n      initLanguageNames = defaultLanguageNames\n    } else if (process.env.LC_LANGUAGE === EN_US) {\n      initLanguageNames = {\n        [EN_US]: NAME_EN_US,\n      }\n    } else if (process.env.LC_LANGUAGE === ZH_CN) {\n      initLanguageNames = {\n        [ZH_CN]: NAME_ZH_CN,\n      }\n    }\n    //#endregion\n    setLanguageNames(initLanguageNames)\n    const resource: I18nResource = create(null)\n    const importantResource: I18nResource = create(null)\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    i18nStore.addResource = (res, isImportant) => {\n      merge(isImportant ? importantResource : resource, res)\n    }\n    if (process.env.NODE_ENV === 'development') {\n      defineProperty(i18nStore, 'debugResources', {\n        get() {\n          return { resource, importantResource }\n        },\n      })\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    i18nStore.t = (key: string, options?: AnyObject) => {\n      const pkgName = options?.pkgName\n      if (isString(pkgName)) {\n        key = mergePkgNameToI18nKey(pkgName, key)\n      }\n      const path = [ctx.i18nStore.language, key]\n      return get(importantResource, path) ?? get(resource, path, key)\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    i18nStore.tText = (text: Text, options?: AnyObject) => {\n      if (isString(text)) return text\n      return ctx.i18nStore.t(text.key, options)\n    }\n    defineLazyInitProperty(\n      i18nStore,\n      'i18nStateLoader',\n      () =>\n        new LocalStorageDataLoader<I18nState | null>(\n          `${editorName}:i18n-state`,\n          null,\n        ),\n    )\n    const debounceSaveI18nState = debounce((i18nState: I18nState) => {\n      i18nStore.i18nStateLoader?.save(i18nState)\n    })\n\n    // 暂不支持原地修改语言，需要刷新\n    // makeObservable(i18nStore, {\n    //   languages: observable.ref,\n    //   languageNames: observable.ref,\n    //   language: observable,\n    // })\n  },\n}\n","import type { I18nResource } from '@p-lc/pd'\nimport { defineLazyInitProperty, type DataLoader } from '@p-lc/shared'\nimport { isNil } from 'lodash-uni'\nimport type { EditorRawPlugin } from '../../types'\nimport {\n  type editorPluginI18nStore,\n  type I18nState,\n} from './editor-plugin-i18n-store'\n\n/**\n * 编辑器国际化仓库初始化插件属性扩展\n */\nexport interface EditorPluginI18nStoreInitPropertiesExt {\n  editorInitOptions: {\n    /**\n     * （当前）语言\n     */\n    language?: string\n    /**\n     * 国际化资源，会自动覆盖插件的国际化资源\n     */\n    i18n?: I18nResource\n    /**\n     * 语言名称\n     */\n    languageNames?: Record<string, string>\n    /**\n     * 国际化状态加载器\n     */\n    i18nStateLoader?: DataLoader<I18nState | null> | null\n  }\n}\n\n/**\n * 编辑器国际化仓库初始化插件\n */\nexport const editorPluginI18nStoreInit: EditorRawPlugin<\n  EditorPluginI18nStoreInitPropertiesExt,\n  typeof editorPluginI18nStore\n> = {\n  id: 'i18n-store-init',\n  initEditor(ctx) {\n    const {\n      i18nStore,\n      initOptions: { language, i18n, languageNames, i18nStateLoader },\n    } = ctx\n    if (language) i18nStore.setLanguage(language, false)\n    if (languageNames) i18nStore.setLanguageNames(languageNames)\n    if (i18n) i18nStore.addResource(i18n, true)\n    if (!isNil(i18nStateLoader)) {\n      defineLazyInitProperty(\n        i18nStore,\n        'i18nStateLoader',\n        () => i18nStateLoader || null,\n      )\n    }\n  },\n}\n","import { promisableThen } from '@p-lc/shared'\nimport { type editorPluginI18nStore } from './editor-plugin-i18n-store'\n\n/**\n * 编辑器国际化仓库加载状态插件\n */\nexport const editorPluginI18nStoreLoadState: typeof editorPluginI18nStore = {\n  id: 'i18n-store-load-state',\n  initEditor(ctx) {\n    const { i18nStore } = ctx\n    promisableThen(\n      i18nStore.i18nStateLoader?.load(),\n      (ret) => ret && i18nStore.setLanguage(ret.language, false),\n    )\n  },\n}\n","import { editorPluginI18nStore } from './editor-plugin-i18n-store'\nimport { editorPluginI18nStoreInit } from './editor-plugin-i18n-store-init'\nimport { editorPluginI18nStoreLoadState } from './editor-plugin-i18n-store-load-state'\n\nexport * from './editor-plugin-i18n-store'\nexport * from './editor-plugin-i18n-store-init'\nexport * from './editor-plugin-i18n-store-load-state'\n\n/**\n * 编辑器国际化仓库插件\n */\nexport const editorI18nStorePlugins = [\n  // 手动顺序\n  editorPluginI18nStore,\n  editorPluginI18nStoreInit,\n  editorPluginI18nStoreLoadState,\n]\n","import type { Cd, Pd, Slot, StaticPathSlot } from '@p-lc/pd'\nimport {\n  createUnknownTempSlot,\n  isChildrenSlot,\n  isSlotMatched,\n  mergePkgNameToI18nResource,\n} from '@p-lc/pd-utils'\nimport type { JsonPath, ReadonlyUnknownArray } from '@p-lc/shared'\nimport { create, jsonStringify } from '@p-lc/shared'\nimport { childrenSlotLogicPath } from '@p-lc/uidl-utils'\nimport { isString } from 'lodash-uni'\nimport { action, makeObservable, observable } from 'mobx'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginElementStoreFind } from '../element-store-plugins'\nimport { type editorPluginI18nStore } from '../i18n-store-plugins'\nimport type { UidlStoreUidlElement } from '../uidl-store-plugins'\nimport {\n  type editorPluginUidlStore,\n  type editorPluginUidlStoreComponents,\n} from '../uidl-store-plugins'\n\n/**\n * 编辑器 PD 仓库插件属性扩展高等类型\n */\nexport interface EditorPluginPdStorePropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * PD 仓库\n     */\n    pdStore: PdStore<Plugin>\n  }\n}\n\n/**\n * PD 仓库\n */\nexport interface PdStore<Plugin extends AnyEditorPlugin> {\n  /**\n   * PD（对照表），pkgName -> PD\n   */\n  pds: Record<string, Pd | undefined>\n  /**\n   * 添加 PD\n   * @param pd PD\n   */\n  addPd(pd: Pd): void\n  /**\n   * 删除 PD\n   * @param pkgName 包名\n   */\n  deletePd(pkgName: string): void\n  /**\n   * 获取 PD\n   * @param pkgName 包名\n   */\n  getPd(pkgName: string): Pd\n  /**\n   * 获取包版本\n   * @param pkgName 报名\n   */\n  getPkgVersion(pkgName: string): string\n  /**\n   * CD（对照表），pkgName -> componentType -> CD\n   */\n  cds: Record<string, Record<string, Cd | undefined> | undefined>\n  /**\n   * 获取 CD\n   * @param pkgName 包名\n   * @param componentType 组件类型\n   */\n  getCd(pkgName: string, componentType: string): Cd\n  /**\n   * 通过元素类型获取 CD\n   * @param elementType 元素类型\n   */\n  getCdByEt(elementType: string): Cd\n  /**\n   * 获取组件名称\n   * @param pkgName 包名\n   * @param componentType 组件类型\n   */\n  getComponentName(pkgName: string, componentType: string): string\n  /**\n   * 通过元素类型获取组件名称\n   * @param elementType 元素类型\n   */\n  getComponentNameByEt(elementType: string): string\n  /**\n   * 获取组件图标\n   * @param pkgName 包名\n   * @param componentType 组件类型\n   */\n  getComponentIcon(pkgName: string, componentType: string): string | null\n  /**\n   * 通过元素类型获取组件图标\n   * @param elementType 元素类型\n   */\n  getComponentIconByEt(elementType: string): string | null\n  /**\n   * 获取插槽\n   * @param pkgName 包名\n   * @param componentType 组件类型\n   */\n  getSlots(pkgName: string, componentType: string): Slot[]\n  /**\n   * 通过元素类型获取插槽\n   * @param elementType 元素类型\n   */\n  getSlotsByEt(elementType: string): Slot[]\n  /**\n   * 获取插槽\n   * @param pkgName 包名\n   * @param componentType 组件类型\n   * @param logicPath 逻辑路径\n   */\n  getSlot(\n    pkgName: string,\n    componentType: string,\n    logicPath: JsonPath,\n  ): Slot | null\n  /**\n   * 通过元素类型获取插槽\n   * @param elementType 元素类型\n   * @param logicPath 逻辑路径\n   */\n  getSlotByEt(elementType: string, logicPath: JsonPath): Slot | null\n  /**\n   * 是容器组件，有默认子元素插槽\n   * @param pkgName 包名\n   * @param componentType 组件类型\n   */\n  isContainerComponent(pkgName: string, componentType: string): boolean\n  /**\n   * 通过元素类型判断为容器组件，有默认子元素插槽\n   * @param elementType 元素类型\n   */\n  isContainerComponentByEt(elementType: string): boolean\n  /**\n   * 获取默认子元素插槽，会自动创建未知插槽\n   * @param element 元素或元素 ID\n   */\n  getChildrenSlotWithUnknown(\n    element: UidlStoreUidlElement<Plugin> | string,\n  ): StaticPathSlot | null\n}\n\n/**\n * EditorPluginPdStorePropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginPdStorePropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginPdStorePropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器 PD 仓库插件\n */\nexport const editorPluginPdStore: EditorRawPlugin<\n  $EditorPluginPdStorePropertiesExtHkt,\n  | typeof editorPluginI18nStore\n  | typeof editorPluginUidlStore\n  | typeof editorPluginUidlStoreComponents\n  | typeof editorPluginElementStoreFind\n> = {\n  id: 'pd-store',\n  initEditor(ctx) {\n    const { i18nStore, uidlStore } = ctx\n    const pdStore = (ctx.pdStore = {} as typeof ctx.pdStore)\n    pdStore.pds = create(null) as typeof pdStore.pds\n    pdStore.cds = create(null) as typeof pdStore.cds\n    const { pds, cds } = makeObservable(pdStore, {\n      pds: observable.shallow,\n      cds: observable.shallow,\n    })\n    pdStore.addPd = action((pd) => {\n      const pkgName = pd.pkgName\n      pds[pkgName] = pd\n      for (const cd of pd.components) {\n        const cs = cds[pkgName] || (cds[pkgName] = create(null))\n        cs[cd.type] = cd\n      }\n      if (pd.i18n) {\n        i18nStore.addResource(mergePkgNameToI18nResource(pd.pkgName, pd.i18n))\n      }\n    })\n    pdStore.deletePd = action((pkgName) => {\n      delete pds[pkgName]\n      delete cds[pkgName]\n    })\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    pdStore.getPd = (pkgName) => {\n      const pd = pds[pkgName]\n      if (!pd) {\n        throw new Error(`The pd ${jsonStringify(pkgName)} is not exists.`)\n      }\n      return pd\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    pdStore.getPkgVersion = (pkgName) => {\n      return pdStore.getPd(pkgName).pkgVersion\n    }\n    pdStore.getCdByEt = byElementType(\n      // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n      (pdStore.getCd = (pkgName, componentType) => {\n        const cs = cds[pkgName]\n        if (!cs) {\n          throw new Error(`The pd ${jsonStringify(pkgName)} is not exists.`)\n        }\n        const cd = cs[componentType]\n        if (!cd) {\n          throw new Error(\n            `The component ${jsonStringify(componentType)} of pd ${jsonStringify(pkgName)} is not exists.`,\n          )\n        }\n        return cd\n      }),\n    )\n    pdStore.getComponentNameByEt = byElementType(\n      // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n      (pdStore.getComponentName = (pkgName, componentType) => {\n        const cd = pdStore.getCd(pkgName, componentType)\n        return i18nStore.tText(cd.name, { pkgName })\n      }),\n    )\n    pdStore.getComponentIconByEt = byElementType(\n      // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n      (pdStore.getComponentIcon = (pkgName, componentType) => {\n        const cd = pdStore.getCd(pkgName, componentType)\n        return cd.icon ?? null\n      }),\n    )\n    pdStore.getSlotsByEt = byElementType(\n      // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n      (pdStore.getSlots = (pkgName, componentType) => {\n        const cd = pdStore.getCd(pkgName, componentType)\n        return cd.slots || []\n      }),\n    )\n    pdStore.getSlotByEt = byElementType(\n      // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n      (pdStore.getSlot = (pkgName, componentType, logicPath) => {\n        return (\n          pdStore\n            .getSlots(pkgName, componentType)\n            .find((slot) => isSlotMatched(slot, logicPath, false)) || null\n        )\n      }),\n    )\n    pdStore.isContainerComponentByEt = byElementType(\n      // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n      (pdStore.isContainerComponent = (pkgName, componentType) => {\n        const slots = pdStore.getSlots(pkgName, componentType)\n        const childrenSlot = slots.find(isChildrenSlot)\n        return !!childrenSlot\n      }),\n    )\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    pdStore.getChildrenSlotWithUnknown = (element) => {\n      if (isString(element)) {\n        const ed = ctx.elementStore.findElementDetail(element)\n        if (!ed) return ed\n        element = ed.element\n      }\n      const rawSlots = ctx.pdStore.getSlotsByEt(element.type)\n      let childrenSlot = rawSlots.find(isChildrenSlot)\n      if (!childrenSlot && element.children?.length) {\n        childrenSlot = createUnknownTempSlot(childrenSlotLogicPath)\n      }\n      return childrenSlot || null\n    }\n\n    function byElementType<Args extends ReadonlyUnknownArray, Return>(\n      fn: (pkgName: string, componentType: string, ...args: Args) => Return,\n    ): (elementType: string, ...args: Args) => Return {\n      return (elementType, ...args) => {\n        const { pkgName, componentType } =\n          uidlStore.getUidlComponent(elementType)\n        return fn(pkgName, componentType, ...args)\n      }\n    }\n  },\n}\n","import type { Pd } from '@p-lc/pd'\nimport type { EditorRawPlugin } from '../../types'\nimport { type editorPluginPdStore } from './editor-plugin-pd-store'\n\n/**\n * 编辑器 PD 仓库初始化插件属性扩展\n */\nexport interface EditorPluginPdStoreInitPropertiesExt {\n  editorInitOptions: {\n    /**\n     * PD\n     */\n    pds?: Pd[]\n  }\n}\n\n/**\n * 编辑器 PD 仓库初始化插件\n */\nexport const editorPluginPdStoreInit: EditorRawPlugin<\n  EditorPluginPdStoreInitPropertiesExt,\n  typeof editorPluginPdStore\n> = {\n  id: 'pd-store-init',\n  initEditor(ctx) {\n    const {\n      initOptions: { pds: initPds },\n      pdStore,\n    } = ctx\n    for (const pd of initPds || []) {\n      pdStore.addPd(pd)\n    }\n  },\n}\n","import { editorPluginPdStore } from './editor-plugin-pd-store'\nimport { editorPluginPdStoreInit } from './editor-plugin-pd-store-init'\n\nexport * from './editor-plugin-pd-store'\nexport * from './editor-plugin-pd-store-init'\n\n/**\n * 编辑器 PD 仓库插件\n */\nexport const editorPdStorePlugins = [\n  editorPluginPdStore,\n  editorPluginPdStoreInit,\n]\n","import type { TraverseElementDetail } from '@p-lc/uidl-utils'\nimport { dfsElement } from '@p-lc/uidl-utils'\nimport { action, makeObservable, observable } from 'mobx'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginEmitter } from '../editor-plugin-emitter'\nimport type { UidlStoreUidl } from '../uidl-store-plugins'\nimport {\n  EDITOR_EVENT_KEY_UIDL,\n  EDITOR_EVENT_KEY_UIDL_COMPOSITION_UPDATE,\n  type editorPluginUidlStore,\n  type editorPluginUidlStoreEdit,\n} from '../uidl-store-plugins'\nimport { type editorPluginUidlUtilsConfig } from '../uidl-utils-config-plugins'\n\n/**\n * 编辑器元素仓库查找插件属性扩展高等类型\n */\nexport interface EditorPluginElementStoreFindPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 元素仓库\n     */\n    elementStore: {\n      /**\n       * 元素详情缓存表\n       */\n      elementDetailCacheMap: Map<\n        string,\n        TraverseElementDetail<UidlStoreUidl<Plugin>>\n      >\n      /**\n       * 元素名称集合\n       */\n      elementNameSet: Set<string>\n      /**\n       * 将被缓存的 UIDL\n       */\n      uidlToBeCached: UidlStoreUidl<Plugin> | null\n      /**\n       * 已缓存的 UIDL\n       */\n      cachedUidl: UidlStoreUidl<Plugin> | null\n      /**\n       * 刷新查找缓存\n       */\n      refreshFindCache(): void\n      /**\n       * 查找元素详情\n       * @param id 元素 ID\n       */\n      findElementDetail(\n        id: string,\n      ): TraverseElementDetail<UidlStoreUidl<Plugin>> | null\n      /**\n       * 是否有元素名称\n       * @param name 元素名称\n       */\n      hasElementName(name: string): boolean\n      /**\n       * 生成元素名称\n       * @param componentName 组件名称\n       */\n      generateElementName(componentName: string): string\n      /**\n       * 是子元素\n       * @param parentId 父元素 ID\n       * @param childId 子元素 ID\n       * @param deep 深度判断，默认 true\n       */\n      isChildElement(parentId: string, childId: string, deep?: boolean): boolean\n      /**\n       * 获取父元素 ID\n       * @param id 元素 ID\n       */\n      getParentElementId(id?: string | null): string | null\n    }\n  }\n}\n\n/**\n * EditorPluginElementStoreFindPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginElementStoreFindPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginElementStoreFindPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器元素仓库查找插件\n */\nexport const editorPluginElementStoreFind: EditorRawPlugin<\n  $EditorPluginElementStoreFindPropertiesExtHkt,\n  | typeof editorPluginUidlStore\n  | typeof editorPluginUidlStoreEdit\n  | typeof editorPluginEmitter\n  | typeof editorPluginUidlUtilsConfig\n> = {\n  id: 'element-store-fd',\n  initEditor(ctx) {\n    const { emitter, uidlUtilsConfig, uidlStore, elementStore } = ctx\n    const elementDetailCacheMap = (elementStore.elementDetailCacheMap =\n      new Map() as typeof elementStore.elementDetailCacheMap)\n    const elementNameSet = (elementStore.elementNameSet =\n      new Set() as typeof elementStore.elementNameSet)\n    elementStore.uidlToBeCached = uidlStore.uidl\n    elementStore.cachedUidl = null\n    const componentNameIndexMap = new Map<string, number>()\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.refreshFindCache = () => {\n      const uidl = elementStore.uidlToBeCached\n      if (elementStore.cachedUidl === uidl) {\n        return\n      }\n      elementStore.cachedUidl = uidl\n      elementDetailCacheMap.clear()\n      elementNameSet.clear()\n      if (uidl) {\n        for (const ed of dfsElement(uidlUtilsConfig, uidl)) {\n          elementDetailCacheMap.set(ed.element.id, ed)\n          elementNameSet.add(ed.element.name)\n        }\n      }\n      componentNameIndexMap.clear()\n    }\n    emitter.on(\n      EDITOR_EVENT_KEY_UIDL,\n      action(({ uidl }) => {\n        elementStore.uidlToBeCached = uidl\n      }),\n    )\n    emitter.on(\n      EDITOR_EVENT_KEY_UIDL_COMPOSITION_UPDATE,\n      action(({ draft }) => {\n        elementStore.uidlToBeCached = draft\n      }),\n    )\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.findElementDetail = (id) => {\n      elementStore.refreshFindCache()\n      return elementDetailCacheMap.get(id) || null\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.hasElementName = (name) => {\n      elementStore.refreshFindCache()\n      return elementNameSet.has(name)\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.generateElementName = (componentName) => {\n      let elementName = componentName\n      let i = componentNameIndexMap.get(componentName) || 2\n      while (elementStore.hasElementName(elementName)) {\n        elementName = `${componentName} ${i++}`\n      }\n      componentNameIndexMap.set(componentName, i)\n      elementNameSet.add(elementName)\n      return elementName\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.isChildElement = (parentId, childId, deep = true) => {\n      const childEd = elementStore.findElementDetail(childId)\n      if (!childEd) return false\n      return deep\n        ? childEd.elementIdPath.includes(parentId)\n        : childEd.parentElementId === parentId\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.getParentElementId = (id) => {\n      return (id && elementStore.findElementDetail(id)?.parentElementId) || null\n    }\n    makeObservable(elementStore, {\n      uidlToBeCached: observable.ref,\n    })\n  },\n}\n","import { defineLazyInitProperty } from '@p-lc/shared'\nimport { isNil, merge } from 'lodash-uni'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport type {\n  LayoutStoreStateLoader,\n  LayoutStoreUidlStateLoader,\n} from './editor-plugin-layout-store'\nimport { type editorPluginLayoutStore } from './editor-plugin-layout-store'\n\n/**\n * 编辑器布局仓库初始化插件属性扩展高等类型\n */\nexport interface EditorPluginLayoutStoreInitPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 布局仓库\n     */\n    layoutStore: {\n      /**\n       * 配置\n       */\n      config: {\n        /**\n         * 状态加载器，默认自动使用 localStorage 加载、保存，false 表示不需要自动保存\n         */\n        stateLoader?: LayoutStoreStateLoader<Plugin> | false\n        /**\n         * UIDL 状态加载器，默认自动使用 localStorage 加载、保存，false 表示不需要自动保存\n         */\n        uidlStateLoader?: LayoutStoreUidlStateLoader<Plugin> | false\n      }\n    }\n  }\n  editorInitOptions: {\n    /**\n     * 布局（配置）\n     */\n    layout?: {\n      /**\n       * 状态加载器，默认自动使用 localStorage 加载、保存，false 表示不需要自动保存\n       */\n      stateLoader?: LayoutStoreStateLoader<Plugin> | false\n      /**\n       * UIDL 状态加载器，默认自动使用 localStorage 加载、保存，false 表示不需要自动保存\n       */\n      uidlStateLoader?: LayoutStoreUidlStateLoader<Plugin> | false\n    }\n  }\n}\n\n/**\n * EditorPluginLayoutStoreInitPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginLayoutStoreInitPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginLayoutStoreInitPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器布局仓库初始化插件\n */\nexport const editorPluginLayoutStoreInit: EditorRawPlugin<\n  $EditorPluginLayoutStoreInitPropertiesExtHkt,\n  typeof editorPluginLayoutStore\n> = {\n  id: 'layout-store-init',\n  initEditor(ctx) {\n    const { layoutStore } = ctx\n    const { stateLoader, uidlStateLoader } = merge(\n      layoutStore.config,\n      ctx.initOptions.layout,\n    )\n    if (!isNil(stateLoader)) {\n      defineLazyInitProperty(\n        layoutStore,\n        'stateLoader',\n        () => stateLoader || null,\n      )\n    }\n    if (!isNil(uidlStateLoader)) {\n      defineLazyInitProperty(\n        layoutStore,\n        'uidlStateLoader',\n        () => uidlStateLoader || null,\n      )\n    }\n  },\n}\n","import { promisableThen } from '@p-lc/shared'\nimport { type editorPluginLayoutStore } from './editor-plugin-layout-store'\n\n/**\n * 编辑器布局仓库加载状态插件\n */\nexport const editorPluginLayoutStoreLoadState: typeof editorPluginLayoutStore =\n  {\n    id: 'layout-store-load-state',\n    initEditor(ctx) {\n      const { layoutStore } = ctx\n      promisableThen(\n        layoutStore.stateLoader?.load(),\n        (ret) => ret && layoutStore.setState(ret, false),\n      )\n      promisableThen(\n        layoutStore.uidlStateLoader?.load(),\n        (ret) => ret && layoutStore.setUidlState(ret, false),\n      )\n    },\n  }\n","import { editorPluginLayoutStore } from './editor-plugin-layout-store'\nimport { editorPluginLayoutStoreInit } from './editor-plugin-layout-store-init'\nimport { editorPluginLayoutStoreLoadState } from './editor-plugin-layout-store-load-state'\n\nexport * from './editor-plugin-layout-store'\nexport * from './editor-plugin-layout-store-init'\nexport * from './editor-plugin-layout-store-load-state'\n\n/**\n * 编辑器布局仓库插件\n */\nexport const editorLayoutStorePlugins = [\n  // 手动顺序\n  editorPluginLayoutStore,\n  editorPluginLayoutStoreInit,\n  editorPluginLayoutStoreLoadState,\n]\n","import type { Cd, Pd } from '@p-lc/pd'\nimport { definePropertyByGetter } from '@p-lc/shared'\nimport { isNull } from 'lodash-uni'\nimport { computed, makeObservable } from 'mobx'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginLayoutStore } from '../layout-store-plugins'\nimport { type editorPluginPdStore } from '../pd-store-plugins'\nimport type { UidlStoreUidlElement } from '../uidl-store-plugins'\nimport {\n  type editorPluginUidlStore,\n  type editorPluginUidlStoreComponents,\n} from '../uidl-store-plugins'\nimport { type editorPluginUidlUtilsConfig } from '../uidl-utils-config-plugins'\nimport { type editorPluginElementStoreFind } from './editor-plugin-element-store-find'\n\n/**\n * 编辑器元素仓库选择插件属性扩展高等类型\n */\nexport interface EditorPluginElementStoreSelectPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 元素仓库\n     */\n    elementStore: {\n      /**\n       * 选中的元素 ID\n       */\n      selectedElementId: string | null\n      /**\n       * 选中的元素\n       */\n      selectedElement: UidlStoreUidlElement<Plugin> | null\n      /**\n       * 选中的元素对应的包声明\n       */\n      selectedPd: Pd | null\n      /**\n       * 选中的元素对应的组件声明\n       */\n      selectedCd: Cd | null\n      /**\n       * 选择元素\n       * @param elementId 元素 ID\n       */\n      selectElement(elementId: string | null): void\n    }\n    /**\n     * 布局仓库\n     */\n    layoutStore: {\n      /**\n       * UIDL 状态\n       */\n      uidlState: {\n        /**\n         * 选中的元素 ID\n         */\n        selectedElementId?: string | null\n      }\n    }\n  }\n}\n\n/**\n * EditorPluginElementStoreSelectPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginElementStoreSelectPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginElementStoreSelectPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器元素仓库选择插件\n */\nexport const editorPluginElementStoreSelect: EditorRawPlugin<\n  $EditorPluginElementStoreSelectPropertiesExtHkt,\n  | typeof editorPluginUidlUtilsConfig\n  | typeof editorPluginLayoutStore\n  | typeof editorPluginElementStoreFind\n  | typeof editorPluginUidlStore\n  | typeof editorPluginPdStore\n  | typeof editorPluginUidlStoreComponents\n> = {\n  id: 'element-store-select',\n  initEditor(ctx) {\n    const { layoutStore, elementStore, pdStore, uidlStore } = ctx\n    definePropertyByGetter(elementStore, 'selectedElementId', () => {\n      return layoutStore.uidlState.selectedElementId || null\n    })\n    definePropertyByGetter(elementStore, 'selectedElement', () => {\n      const { selectedElementId } = elementStore\n      if (isNull(selectedElementId)) return null\n      return elementStore.findElementDetail(selectedElementId)?.element || null\n    })\n    definePropertyByGetter(elementStore, 'selectedPd', () => {\n      const { selectedElement } = elementStore\n      if (!selectedElement) return null\n      const { pkgName } = uidlStore.getUidlComponent(selectedElement.type)\n      return pdStore.getPd(pkgName)\n    })\n    definePropertyByGetter(elementStore, 'selectedCd', () => {\n      const { selectedElement } = elementStore\n      if (!selectedElement) return null\n      return pdStore.getCdByEt(selectedElement.type)\n    })\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.selectElement = (elementId) => {\n      layoutStore.setUidlState({\n        selectedElementId: elementId,\n      })\n    }\n    makeObservable(elementStore, {\n      selectedElementId: computed,\n      selectedElement: computed,\n      selectedCd: computed,\n    })\n  },\n}\n","import type { JsonPath, POSITION_TYPE_BEFORE } from '@p-lc/shared'\nimport {\n  getObjectValueOrFirstValue,\n  POSITION_TYPE_AFTER,\n  unsetClean,\n} from '@p-lc/shared'\nimport type { UidlExpressionSlot } from '@p-lc/uidl'\nimport type { ElementOfUidl } from '@p-lc/uidl-utils'\nimport {\n  childrenSlotLogicPath,\n  createElementId,\n  EXPRESSION_TYPE_SLOT,\n  logicGetElementArrayInElement,\n  logicSetElementInElement,\n  logicSetExpressionInElement,\n} from '@p-lc/uidl-utils'\nimport { get, isArray, isNumber, last, set } from 'lodash-uni'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginI18nStore } from '../i18n-store-plugins'\nimport { type editorPluginPdStore } from '../pd-store-plugins'\nimport type { UidlStoreUidlElement } from '../uidl-store-plugins'\nimport {\n  type editorPluginUidlStore,\n  type editorPluginUidlStoreComponents,\n  type editorPluginUidlStoreEdit,\n} from '../uidl-store-plugins'\nimport { type editorPluginUidlUtilsConfig } from '../uidl-utils-config-plugins'\nimport { type editorPluginElementStoreFind } from './editor-plugin-element-store-find'\nimport type { editorPluginElementStoreIs } from './editor-plugin-element-store-is'\nimport { type editorPluginElementStoreSelect } from './editor-plugin-element-store-select'\n\n/**\n * 编辑器元素仓库编辑插件属性扩展高等类型\n */\nexport interface EditorPluginElementStoreEditPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 元素仓库\n     */\n    elementStore: {\n      /**\n       * 创建元素\n       * @param pkgName 包名\n       * @param componentType 组件类型\n       */\n      createElement(\n        pkgName: string,\n        componentType: string,\n      ): UidlStoreUidlElement<Plugin>\n      /**\n       * 添加元素到尾部\n       * @param elementId 元素 ID\n       * @param slotLogicPath 插槽逻辑路径\n       * @param dynamicRender 动态渲染\n       * @param childElement （将被插入的）子元素\n       */\n      appendElement(\n        elementId: string,\n        slotLogicPath: JsonPath,\n        dynamicRender: boolean,\n        childElement: UidlStoreUidlElement<Plugin>,\n      ): void\n      /**\n       * 插入元素\n       * @param elementId 元素 ID\n       * @param siblingElement （将被插入的）兄弟元素\n       * @param order 兄弟元素处在该元素的前面还是后面，默认：`'after'`\n       */\n      insertElement(\n        elementId: string,\n        siblingElement: UidlStoreUidlElement<Plugin>,\n        order?: typeof POSITION_TYPE_BEFORE | typeof POSITION_TYPE_AFTER,\n      ): void\n      /**\n       * 可以通过目标元素（定位）添加元素\n       * @param targetElement 目标元素\n       */\n      canAddElementByElement(\n        targetElement?: UidlStoreUidlElement<Plugin> | null,\n      ): boolean\n      /**\n       * 通过目标元素（定位）添加元素：\n       * * 目标元素为容器组件：添加到目标元素子元素末尾\n       * * 目标元素为非容器组件：添加到目标元素之后\n       * * 目标元素不存在：添加到根元素末尾\n       * @param element 元素\n       * @param targetElement 目标元素\n       */\n      addElementByElement(\n        element: UidlStoreUidlElement<Plugin>,\n        targetElement?: UidlStoreUidlElement<Plugin> | null,\n      ): void\n      /**\n       * 删除元素\n       * @param elementId 元素 ID\n       * @param clearUidlComponents 清理 UIDL 组件，默认：true\n       */\n      deleteElement(\n        elementId: string,\n        clearUidlComponents?: boolean,\n      ): UidlStoreUidlElement<Plugin> | null\n      /**\n       * 编辑元素，根据元素 ID 编辑\n       * @param element 元素\n       * @param recipeId 配方 ID\n       */\n      editElement(\n        element: UidlStoreUidlElement<Plugin>,\n        recipeId?: string | number | null,\n      ): void\n    }\n  }\n}\n\n/**\n * EditorPluginElementStoreEditPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginElementStoreEditPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginElementStoreEditPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器元素仓库编辑插件\n */\nexport const editorPluginElementStoreEdit: EditorRawPlugin<\n  $EditorPluginElementStoreEditPropertiesExtHkt,\n  | typeof editorPluginUidlStore\n  | typeof editorPluginUidlStoreEdit\n  | typeof editorPluginUidlStoreComponents\n  | typeof editorPluginElementStoreIs\n  | typeof editorPluginElementStoreFind\n  | typeof editorPluginElementStoreSelect\n  | typeof editorPluginUidlUtilsConfig\n  | typeof editorPluginPdStore\n  | typeof editorPluginI18nStore\n> = {\n  id: 'element-store-edit',\n  initEditor(ctx) {\n    const { elementStore, uidlStore, uidlUtilsConfig, pdStore, i18nStore } = ctx\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.createElement = (pkgName, componentType) => {\n      const elementType = uidlStore.ensureElementType(pkgName, componentType)\n      const componentName = pdStore.getComponentName(pkgName, componentType)\n      const id = createElementId()\n      const name = elementStore.generateElementName(componentName)\n      const cd = pdStore.getCd(pkgName, componentType)\n      return {\n        id,\n        name,\n        type: elementType,\n        ...getObjectValueOrFirstValue(\n          cd.initializer?.partialElement,\n          i18nStore.language,\n        ),\n      }\n    }\n    elementStore.appendElement = (\n      elementId,\n      slotLogicPath,\n      dynamicRender,\n      childElement,\n      // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    ) => {\n      const ed = elementStore.findElementDetail(elementId)\n      if (!ed) return\n      uidlStore.edit((uidl) => {\n        type Element = ElementOfUidl<typeof uidl>\n        const editingElement = get(uidl, ed.fullJsonPath) as Element\n        const arr = logicGetElementArrayInElement(\n          uidlUtilsConfig,\n          editingElement,\n          slotLogicPath,\n        )\n        const len = arr?.length || 0\n        if (!len) {\n          const expr: UidlExpressionSlot = {\n            type: EXPRESSION_TYPE_SLOT,\n            value: [childElement],\n          }\n          if (dynamicRender) {\n            expr.dynamic = dynamicRender\n          }\n          logicSetExpressionInElement(\n            uidlUtilsConfig,\n            editingElement,\n            slotLogicPath,\n            expr,\n          )\n        } else {\n          logicSetElementInElement(\n            uidlUtilsConfig,\n            editingElement,\n            [...slotLogicPath, len],\n            childElement,\n          )\n        }\n      })\n    }\n    elementStore.insertElement = (\n      elementId,\n      childElement,\n      order = POSITION_TYPE_AFTER,\n      // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    ) => {\n      const ed = elementStore.findElementDetail(elementId)\n      if (!ed || elementStore.isRootElement(elementId)) return\n      uidlStore.edit((uidl) => {\n        const arr = get(uidl, ed.fullJsonPath.slice(0, -1))\n        let index = last(ed.fullJsonPath)\n        if (!isArray(arr) || !isNumber(index)) return\n        if (order === POSITION_TYPE_AFTER) index++\n        arr.splice(index, 0, childElement)\n      })\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.canAddElementByElement = (targetElement) => {\n      const { rootElement } = elementStore\n      targetElement = targetElement || rootElement\n      if (!targetElement) return false\n      const targetElementIsContainer = pdStore.isContainerComponentByEt(\n        targetElement.type,\n      )\n      if (targetElement === rootElement && !targetElementIsContainer) {\n        return false\n      }\n      return true\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.addElementByElement = (element, targetElement) => {\n      const { rootElement } = elementStore\n      targetElement = targetElement || rootElement\n      if (!targetElement) return\n      const targetElementIsContainer = pdStore.isContainerComponentByEt(\n        targetElement.type,\n      )\n      uidlStore.edit(() => {\n        const targetElementId = targetElement.id\n        if (targetElementIsContainer) {\n          elementStore.appendElement(\n            targetElementId,\n            childrenSlotLogicPath,\n            false,\n            element,\n          )\n        } else {\n          elementStore.insertElement(targetElementId, element)\n        }\n      })\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.deleteElement = (elementId, clearUidlComponents = true) => {\n      if (elementStore.isRootElement(elementId)) {\n        return null\n      }\n      const ed = elementStore.findElementDetail(elementId)\n      if (!ed) return null\n      uidlStore.edit((uidl) => {\n        unsetClean(uidl, ed.fullJsonPath)\n        if (clearUidlComponents) {\n          uidlStore.clearUidlComponents()\n        }\n      })\n      return ed.element\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.editElement = (element, recipeId) => {\n      const ed = elementStore.findElementDetail(element.id)\n      if (!ed) return\n      uidlStore.edit((uidl) => {\n        set(uidl, ed.fullJsonPath, element)\n      }, recipeId)\n    }\n  },\n}\n","import { readJsonFromClipboard, writeJsonToClipboard } from '@p-lc/shared'\nimport type { UidlComponent } from '@p-lc/uidl'\nimport { createElementId, dfsElementInElement } from '@p-lc/uidl-utils'\nimport { runInAction } from 'mobx'\nimport type {\n  AnyEditorPlugin,\n  EditorDefaultPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginName } from '../editor-plugin-name'\nimport { type editorPluginPdStore } from '../pd-store-plugins'\nimport type { UidlStoreUidlElement } from '../uidl-store-plugins'\nimport {\n  type editorPluginUidlStore,\n  type editorPluginUidlStoreComponents,\n  type editorPluginUidlStoreEdit,\n} from '../uidl-store-plugins'\nimport { type editorPluginUidlUtilsConfig } from '../uidl-utils-config-plugins'\nimport { type editorPluginElementStoreEdit } from './editor-plugin-element-store-edit'\nimport { type editorPluginElementStoreFind } from './editor-plugin-element-store-find'\nimport { type editorPluginElementStoreSelect } from './editor-plugin-element-store-select'\n\n/**\n * 编辑器元素仓库复制粘贴插件属性扩展\n */\nexport interface EditorPluginElementStoreCopyPastePropertiesExt {\n  editor: {\n    /**\n     * 元素仓库\n     */\n    elementStore: {\n      /**\n       * 撤销\n       * @param elementId 元素 ID\n       */\n      copy(elementId: string): Promise<void>\n      /**\n       * 重做\n       * @param elementId 元素 ID\n       */\n      paste(elementId?: string | null): Promise<void>\n    }\n  }\n}\n\n/**\n * 剪贴板 JSON：元素\n */\nexport interface ClipboardJsonElement<\n  Plugin extends AnyEditorPlugin = EditorDefaultPlugin,\n> {\n  /**\n   * 组件\n   */\n  components?: UidlComponent[]\n  /**\n   * 元素\n   */\n  element: UidlStoreUidlElement<Plugin>\n}\n\n/**\n * 编辑器元素仓库复制粘贴插件\n */\nexport const editorPluginElementStoreCopyPaste: EditorRawPlugin<\n  EditorPluginElementStoreCopyPastePropertiesExt,\n  | typeof editorPluginName\n  | typeof editorPluginUidlStore\n  | typeof editorPluginUidlStoreEdit\n  | typeof editorPluginUidlStoreComponents\n  | typeof editorPluginUidlUtilsConfig\n  | typeof editorPluginElementStoreFind\n  | typeof editorPluginElementStoreEdit\n  | typeof editorPluginElementStoreSelect\n  | typeof editorPluginPdStore\n> = {\n  id: 'element-store-copy-paste',\n  initEditor(ctx) {\n    const { name, uidlStore, elementStore, uidlUtilsConfig, pdStore } = ctx\n    const jsonType = `p-lc:${name}:element`\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.copy = async (elementId) => {\n      const ed = elementStore.findElementDetail(elementId)\n      if (!ed) return\n      const { uidl } = uidlStore\n      const { element } = ed\n      const elementTypeSet = new Set<string>()\n      for (const d of dfsElementInElement(uidlUtilsConfig, element)) {\n        elementTypeSet.add(d.element.type)\n      }\n      const components = uidl?.components?.filter(({ elementType }) =>\n        elementTypeSet.has(elementType),\n      )\n      const json: ClipboardJsonElement = {\n        element,\n        components,\n      }\n      return writeJsonToClipboard(jsonType, json)\n    }\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.paste = async (elementId) => {\n      const json = await readJsonFromClipboard<ClipboardJsonElement>(jsonType)\n      if (!json) return\n      const { components = [], element } = json\n      let targetElement: typeof element | undefined\n      if (elementId) {\n        targetElement = elementStore.findElementDetail(elementId)?.element\n      }\n      if (!elementStore.canAddElementByElement(targetElement)) {\n        return\n      }\n      runInAction(() => {\n        uidlStore.edit(() => {\n          const elementTypeMap = new Map<string, string>()\n          for (const component of components) {\n            const { elementType, pkgName, componentType } = component\n            const newElementType = uidlStore.ensureElementType(\n              pkgName,\n              componentType,\n            )\n            elementTypeMap.set(elementType, newElementType)\n          }\n          for (const { element: ele } of dfsElementInElement(\n            uidlUtilsConfig,\n            element,\n          )) {\n            ele.id = createElementId()\n            // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n            const newElementType = elementTypeMap.get(ele.type)!\n            ele.type = newElementType\n            const componentName = pdStore.getComponentNameByEt(newElementType)\n            ele.name = elementStore.generateElementName(componentName)\n          }\n          elementStore.addElementByElement(element, targetElement)\n        })\n        elementStore.selectElement(element.id)\n      })\n    }\n  },\n}\n","import {\n  definePropertyByGetter,\n  deleteUndefinedValues,\n  isPartialObject,\n} from '@p-lc/shared'\nimport { isObject } from 'lodash-uni'\nimport type {\n  AnyEditorPlugin,\n  DepPluginUniteEditorPlugin,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport type {\n  editorPluginUidlStoreComponents,\n  UidlStoreUidlElement,\n} from '../uidl-store-plugins'\nimport { type editorPluginUidlStore } from '../uidl-store-plugins'\nimport type { editorPluginElementStoreFind } from './editor-plugin-element-store-find'\n\n/**\n * 编辑器元素仓库是否判断插件属性扩展高等类型\n */\nexport interface EditorPluginElementStoreIsPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 元素仓库\n     */\n    elementStore: {\n      /**\n       * 根元素 ID\n       */\n      rootElementId: string | null\n      /**\n       * 根元素\n       */\n      rootElement: UidlStoreUidlElement<Plugin> | null\n      /**\n       * 获取元素 ID\n       * @param elementOrId 元素或元素 ID\n       */\n      getElementId(elementOrId: UidlStoreUidlElement<Plugin> | string): string\n      /**\n       * 是根元素\n       * @param elementOrId 元素或元素 ID\n       */\n      isRootElement(elementOrId: UidlStoreUidlElement<Plugin> | string): boolean\n      /**\n       * 是元素类型\n       * @param elementOrId 元素或元素 ID\n       * @param pkgName 包名\n       * @param componentType 组件类型\n       * @param pkgVersion 包版本，可选\n       */\n      isElementType(\n        elementOrId: UidlStoreUidlElement<Plugin> | string,\n        pkgName: string,\n        componentType: string,\n        pkgVersion?: string,\n      ): boolean\n    }\n  }\n}\n\n/**\n * EditorPluginElementStoreIsPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginElementStoreIsPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginElementStoreIsPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器元素仓库是否判断插件\n */\nexport const editorPluginElementStoreIs: EditorRawPlugin<\n  $EditorPluginElementStoreIsPropertiesExtHkt,\n  | typeof editorPluginUidlStore\n  | typeof editorPluginElementStoreFind\n  | typeof editorPluginUidlStoreComponents\n> = {\n  id: 'element-store-is',\n  initEditor(ctx) {\n    const { uidlStore, elementStore } = ctx\n    definePropertyByGetter(elementStore, 'rootElementId', () => {\n      return elementStore.rootElement?.id || null\n    })\n    definePropertyByGetter(elementStore, 'rootElement', () => {\n      return uidlStore.uidl?.view || null\n    })\n    elementStore.getElementId = getElementId\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    elementStore.isRootElement = (elementOrId) => {\n      elementOrId = getElementId(elementOrId)\n      return elementOrId === elementStore.rootElementId\n    }\n    elementStore.isElementType = (\n      elementOrId,\n      pkgName,\n      componentType,\n      pkgVersion,\n      // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    ) => {\n      elementOrId = getElementId(elementOrId)\n      const ed = elementStore.findElementDetail(elementOrId)\n      if (!ed) return false\n      const uidlComponent = uidlStore.getUidlComponent(ed.element.type)\n      return isPartialObject(\n        uidlComponent,\n        deleteUndefinedValues({\n          pkgName,\n          componentType,\n          pkgVersion,\n        }),\n      )\n    }\n\n    function getElementId(\n      elementOrId:\n        | UidlStoreUidlElement<\n            DepPluginUniteEditorPlugin<typeof editorPluginUidlStore>\n          >\n        | string,\n    ): string {\n      return isObject(elementOrId) ? elementOrId.id : elementOrId\n    }\n  },\n}\n","import { editorPluginElementStore } from './editor-plugin-element-store'\nimport { editorPluginElementStoreCopyPaste } from './editor-plugin-element-store-copy-paste'\nimport { editorPluginElementStoreEdit } from './editor-plugin-element-store-edit'\nimport { editorPluginElementStoreFind } from './editor-plugin-element-store-find'\nimport { editorPluginElementStoreIs } from './editor-plugin-element-store-is'\nimport { editorPluginElementStoreSelect } from './editor-plugin-element-store-select'\n\nexport * from './editor-plugin-element-store'\nexport * from './editor-plugin-element-store-copy-paste'\nexport * from './editor-plugin-element-store-edit'\nexport * from './editor-plugin-element-store-find'\nexport * from './editor-plugin-element-store-is'\nexport * from './editor-plugin-element-store-select'\n\n/**\n * 编辑器元素仓库插件\n */\nexport const editorElementStorePlugins = [\n  // 手动顺序\n  editorPluginElementStore,\n  // 字典顺序\n  editorPluginElementStoreCopyPaste,\n  editorPluginElementStoreEdit,\n  editorPluginElementStoreFind,\n  editorPluginElementStoreIs,\n  editorPluginElementStoreSelect,\n]\n","import type { Promisable } from '@p-lc/shared'\nimport { definePropertyByGetter, promisableThen } from '@p-lc/shared'\nimport { action, computed, makeObservable, observable } from 'mobx'\nimport type {\n  AnyEditorPlugin,\n  Editor,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport { type editorPluginEmitter } from '../editor-plugin-emitter'\nimport type { UidlStoreUidl } from '../uidl-store-plugins'\nimport {\n  EDITOR_EVENT_KEY_UIDL,\n  EDITOR_EVENT_UIDL_TYPE_INIT,\n  type editorPluginUidlStore,\n  type editorPluginUidlStoreEdit,\n} from '../uidl-store-plugins'\n\n/**\n * 编辑器保存仓库插件属性扩展\n */\nexport interface EditorPluginSaveStorePropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editor: {\n    /**\n     * 发射器事件\n     */\n    emitterEvents: {\n      /**\n       * 保存事件\n       */\n      save: {\n        /**\n         * UIDL\n         */\n        uidl: UidlStoreUidl<Plugin>\n      }\n    }\n    /**\n     * 保存仓库\n     */\n    saveStore: {\n      /**\n       * 已保存的 UIDL\n       */\n      savedUidl: UidlStoreUidl<Plugin> | null\n      /**\n       * 是可保存的\n       */\n      isSavable: boolean\n      /**\n       * 可保存检查，用于其他插件覆盖 isSavable 逻辑\n       */\n      checkSavable(): boolean\n      /**\n       * 正在保存\n       */\n      isSaving: boolean\n      /**\n       * 保存\n       */\n      save(): void\n      /**\n       * 保存事件\n       * @param uidl UIDL\n       * @param ctx 上下文，编辑器\n       */\n      onSave?(\n        uidl: UidlStoreUidl<Plugin>,\n        ctx: Editor<Plugin>,\n      ): Promisable<void>\n    }\n  }\n}\n\n/**\n * 编辑器事件键值：保存\n */\nexport const EDITOR_EVENT_KEY_SAVE = 'save'\n\n/**\n * EditorPluginSaveStorePropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginSaveStorePropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginSaveStorePropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器保存仓库插件\n */\nexport const editorPluginSaveStore: EditorRawPlugin<\n  $EditorPluginSaveStorePropertiesExtHkt,\n  | typeof editorPluginEmitter\n  | typeof editorPluginUidlStore\n  | typeof editorPluginUidlStoreEdit\n> = {\n  id: 'save-store',\n  initEditor(ctx) {\n    const { emitter, uidlStore } = ctx\n    const saveStore = (ctx.saveStore = {} as typeof ctx.saveStore)\n    saveStore.savedUidl = uidlStore.uidl\n    definePropertyByGetter(saveStore, 'isSavable', () =>\n      saveStore.checkSavable(),\n    )\n    // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n    saveStore.checkSavable = () => {\n      return uidlStore.uidl !== saveStore.savedUidl\n    }\n    saveStore.isSaving = false\n    saveStore.save = action(() => {\n      const { uidl } = uidlStore\n      if (!uidl || !saveStore.isSavable) return\n      saveStore.savedUidl = uidl\n      saveStore.isSaving = true\n      promisableThen(\n        saveStore.onSave?.(uidl, ctx),\n        action(() => {\n          saveStore.isSaving = false\n        }),\n      )\n      emitter.emit(EDITOR_EVENT_KEY_SAVE, { uidl })\n    })\n    makeObservable(saveStore, {\n      savedUidl: observable.ref,\n      isSavable: computed,\n      isSaving: observable,\n    })\n    emitter.on(EDITOR_EVENT_KEY_UIDL, ({ type: evType, uidl }) => {\n      if (evType === EDITOR_EVENT_UIDL_TYPE_INIT) {\n        saveStore.savedUidl = uidl\n      }\n    })\n  },\n}\n","import type { Promisable } from '@p-lc/shared'\nimport type {\n  AnyEditorPlugin,\n  Editor,\n  EditorDefaultPropertiesExtHkt,\n  EditorDefaultPropertiesExtHktPlugin,\n  EditorRawPlugin,\n} from '../../types'\nimport type { UidlStoreUidl } from '../uidl-store-plugins'\nimport { type editorPluginSaveStore } from './editor-plugin-save-store'\n\n/**\n * 编辑器保存仓库插件初始化属性扩展\n */\nexport interface EditorPluginSaveStoreInitPropertiesExtHkt<\n  Plugin extends AnyEditorPlugin,\n> {\n  editorInitOptions: {\n    /**\n     * 保存事件\n     * @param uidl\n     * @param ctx 上下文，编辑器\n     */\n    onSave?(uidl: UidlStoreUidl<Plugin>, ctx: Editor<Plugin>): Promisable<void>\n  }\n}\n\n/**\n * EditorPluginSaveStoreInitPropertiesExtHkt 辅助类型\n */\nexport interface $EditorPluginSaveStoreInitPropertiesExtHkt\n  extends EditorDefaultPropertiesExtHkt {\n  type: EditorPluginSaveStoreInitPropertiesExtHkt<\n    EditorDefaultPropertiesExtHktPlugin<this>\n  >\n}\n\n/**\n * 编辑器保存仓库初始化插件\n */\nexport const editorPluginSaveStoreInit: EditorRawPlugin<\n  $EditorPluginSaveStoreInitPropertiesExtHkt,\n  typeof editorPluginSaveStore\n> = {\n  id: 'save-store-init',\n  initEditor(ctx) {\n    const { saveStore } = ctx\n    saveStore.onSave = ctx.initOptions.onSave || saveStore.onSave\n  },\n}\n","import { editorPluginSaveStore } from './editor-plugin-save-store'\nimport { editorPluginSaveStoreInit } from './editor-plugin-save-store-init'\n\nexport * from './editor-plugin-save-store'\nexport * from './editor-plugin-save-store-init'\n\n/**\n * 编辑器保存仓库插件\n */\nexport const editorSaveStorePlugins = [\n  editorPluginSaveStore,\n  editorPluginSaveStoreInit,\n]\n","import type { AnyObject } from '@p-lc/shared'\nimport { assign } from 'lodash-uni'\nimport type { EditorRawPlugin } from '../../types'\n\n/**\n * 编辑器样式仓库插件属性扩展\n */\nexport interface EditorPluginStyleStorePropertiesExt {\n  editor: {\n    /**\n     * 样式仓库\n     */\n    styleStore: {\n      /**\n       * CSS 变量\n       */\n      cssVars: AnyObject\n      /**\n       * 设置 CSS 变量\n       * @param cssVars CSS 变量\n       */\n      setCssVars(cssVars: AnyObject): void\n    }\n  }\n}\n\n/**\n * 编辑器样式仓库插件\n */\nexport const editorPluginStyleStore: EditorRawPlugin<EditorPluginStyleStorePropertiesExt> =\n  {\n    id: 'style-store',\n    initEditor(ctx) {\n      const styleStore = (ctx.styleStore = {} as typeof ctx.styleStore)\n      styleStore.cssVars = {}\n      // eslint-disable-next-line @typescript-eslint/explicit-function-return-type\n      styleStore.setCssVars = (cssVars) => {\n        assign(styleStore.cssVars, cssVars)\n      }\n    },\n  }\n","import type { AnyObject } from '@p-lc/shared'\nimport { assign } from 'lodash-uni'\nimport type { EditorRawPlugin } from '../../types'\nimport { type editorPluginStyleStore } from './editor-plugin-style-store'\n\n/**\n * 编辑器样式仓库初始化插件属性扩展\n */\nexport interface EditorPluginStyleStoreInitPropertiesExt {\n  editorInitOptions: {\n    /**\n     * CSS 变量\n     */\n    cssVars?: AnyObject\n  }\n}\n\n/**\n * 编辑器样式仓库初始化插件\n */\nexport const editorPluginStyleStoreInit: EditorRawPlugin<\n  EditorPluginStyleStoreInitPropertiesExt,\n  typeof editorPluginStyleStore\n> = {\n  id: 'style-store-init',\n  initEditor(ctx) {\n    const { styleStore } = ctx\n    assign(styleStore.cssVars, ctx.initOptions.cssVars)\n  },\n}\n","import { editorPluginStyleStore } from './editor-plugin-style-store'\nimport { editorPluginStyleStoreInit } from './editor-plugin-style-store-init'\n\nexport * from './editor-plugin-style-store'\nexport * from './editor-plugin-style-store-init'\n\n/**\n * 编辑器样式仓库插件\n */\nexport const editorStyleStorePlugins = [\n  editorPluginStyleStore,\n  editorPluginStyleStoreInit,\n]\n","import { editorContextMenuStorePlugins } from './context-menu-store-plugins'\nimport { editorDndStorePlugins } from './dnd-store-plugins'\nimport { editorPluginEditorReactContext } from './editor-plugin-editor-react-context'\nimport { editorPluginEmitter } from './editor-plugin-emitter'\nimport { editorPluginName } from './editor-plugin-name'\nimport { editorPluginRender } from './editor-plugin-render'\nimport { editorPluginRootHost } from './editor-plugin-root-host'\nimport { editorElementStorePlugins } from './element-store-plugins'\nimport { editorI18nStorePlugins } from './i18n-store-plugins'\nimport { editorLayoutStorePlugins } from './layout-store-plugins'\nimport { editorPdStorePlugins } from './pd-store-plugins'\nimport { editorSaveStorePlugins } from './save-store-plugins'\nimport { editorStyleStorePlugins } from './style-store-plugins'\nimport { editorUidlStorePlugins } from './uidl-store-plugins'\nimport { editorUidlUtilsConfigPlugins } from './uidl-utils-config-plugins'\n\nexport * from './context-menu-store-plugins'\nexport * from './dnd-store-plugins'\nexport * from './editor-plugin-editor-react-context'\nexport * from './editor-plugin-emitter'\nexport * from './editor-plugin-name'\nexport * from './editor-plugin-render'\nexport * from './editor-plugin-root-host'\nexport * from './element-store-plugins'\nexport * from './i18n-store-plugins'\nexport * from './layout-store-plugins'\nexport * from './pd-store-plugins'\nexport * from './save-store-plugins'\nexport * from './style-store-plugins'\nexport * from './uidl-store-plugins'\nexport * from './uidl-utils-config-plugins'\n\n/**\n * 编辑器默认插件\n */\nexport const editorDefaultPlugins = [\n  // 手动顺序\n  editorPluginName,\n  editorPluginEmitter,\n  editorPluginRender, // overwrite render\n  ...editorStyleStorePlugins,\n  ...editorI18nStorePlugins,\n  ...editorUidlUtilsConfigPlugins,\n  ...editorUidlStorePlugins,\n  ...editorLayoutStorePlugins,\n  ...editorPdStorePlugins,\n  ...editorElementStorePlugins,\n  ...editorDndStorePlugins, // overwrite render\n  ...editorContextMenuStorePlugins, // overwrite render\n  ...editorSaveStorePlugins,\n  editorPluginRootHost, // overwrite render\n  editorPluginEditorReactContext, // overwrite render\n]\n","import { Mobo } from '@mobo-ts/mobo'\nimport { editorExtKeys } from './constants'\nimport { editorDefaultPlugins } from './plugins'\nimport type { DefaultEditor } from './types'\n\n/**\n * 创建编辑器\n */\nexport function createEditor(): DefaultEditor {\n  return new Mobo(editorDefaultPlugins, editorExtKeys)\n}\n"],"names":["CONTEXT_TYPE_EDITOR","editorExtKeys","editorPluginName","ctx","editorPluginUidlStore","uidlStore","makeObservable","observable","editorPluginUidlUtilsConfig","cloneDeep","defaultEditorUidlUtilsConfig","editorPluginUidlUtilsConfigInit","merge","editorUidlUtilsConfigPlugins","editorPluginEmitter","mitt","action","EDITOR_EVENT_KEY_UIDL","EDITOR_EVENT_KEY_UIDL_COMPOSITION_START","EDITOR_EVENT_KEY_UIDL_COMPOSITION_UPDATE","EDITOR_EVENT_KEY_UIDL_COMPOSITION_END","EDITOR_EVENT_UIDL_TYPE_INIT","EDITOR_EVENT_UIDL_TYPE_UPDATE","editorPluginUidlStoreEdit","emitter","initUndoRedoState","evType","uidl","undoRedoList","UndoRedoList","type","newUidl","patchs","draft","u","definePropertyByGetter","recipe","recipeId","ret","currentState","editorPluginUidlStoreComponents","uidlUtilsConfig","pkgName","componentType","pdStore","pd","cd","component","createUidlComponent","DEFAULT_IMPORT_EXPORT_PATH","addUidlComponent","components","currentElementTypeSet","usingElementTypeSet","ed","dfsElement","componentsToElementTypeMap","createWeakMemoizeArrayToMap","elementType","DEFAULT_PKG_NAME","DEFAULT_PKG_VERSION","componentsToPkgNameComponentTypeMap","jsonStringify","isNull","editorPluginUidlStoreInit","initUidlKey","initUidl","initLoadUidl","promisableThen","editorUidlStorePlugins","editorPluginLayoutStore","editorName","uidlKey","layoutStore","defineLazyInitProperty","LocalStorageDataLoader","debounceSaveState","debounce","state","autoSave","assign","debounceSaveUidlState","uidlState","editorPluginRender","jsx","Fragment","EditorReactContext","createContext","EditorReactContextProvider","EditorReactContextConsumer","useEditor","useContext","editorPluginEditorReactContext","oldRender","ContextMenu","withStylePropsObserver","visible","displayPoint","matchedItems","close","tText","refElContextMenu","useRef","getPopupContainer","useLatestFn","anchorStyle","useMemo","menuItems","id","label","handleContainerContextMenu","ev","handleMaskClick","handleMenuSelect","key","jsxs","InternalContextMenuContainer","InternalContextMenuPopover","Menu","styled","VCVN_Z_INDEX_MAX","StyleablePopover","editorPluginContextMenuStore","contextMenuStore","zeroPoint","getSortedItems","once","sortBy","index","entity","point","item","CONTEXT_MENU_ENTITY_TYPE_ELEMENT","isContextMenuElement","editorPluginContextMenuStoreElement","useContextMenu","open","refLatestEntity","useLatest","createPointByEventClient","et","getReturnValue","editorContextMenuStorePlugins","Root","memo","children","ref","el","cssVars","InternalRootContainer","props","editorPluginRootHost","EDITOR_EVENT_KEY_DRAG_START","EDITOR_EVENT_KEY_DRAG_MOVE","EDITOR_EVENT_KEY_DRAG_MOVE_WITH_POS","EDITOR_EVENT_KEY_DRAG_END","editorPluginDndStore","dndStore","resetDraggingState","droppableOptionsMap","droppablePositionActionMap","addDragEventListeners","target","distanceSquare","pos","getClosestHtmlElementBy","p","draggingEntity","hoveringPosition","isDragging","lastDragEndTime","now","removeDragEventListeners","preventUserSelectDisposer","autorun","currentTime","preventTime","addClickEventListener","removeClickEventListener","handleMouseMove","handleMouseUp","winAddEventListener","winRemoveEventListener","handleWinClickCapture","DndMask","InternalDndMaskContainer","DndDroppablePosition","DndDraggingEntity","droppablePositionRendererMap","Renderer","bounding","InternalDndDroppablePositionContainer","getRectangleWidth","getRectangleHeight","draggableEntityRendererMap","draggingPoint","InternalDndDraggingEntityContainer","pointToTranslate","VCVN_BORDER_RADIUS","editorPluginDndStoreMask","DRAGGABLE_ENTITY_TYPE_ELEMENT","editorPluginDndStoreElementRenderer","DraggableElementRenderer","element","getComponentIconByEt","icon","DraggableIconAndName","withStylePropsMemo","name","InternalDraggableIconAndNameContainer","ComponentIcon","TypographyText","DraggableComponentRenderer","getComponentIcon","getComponentName","DRAGGABLE_ENTITY_TYPE_COMPONENT","editorPluginDndStoreComponentRenderer","useDragMove","cb","endCb","refLatestCb","refLatestEndCb","useEffect","dragMove","dragEnd","options","useDragAutoScroll","getScrollable","autoScrollDistance","autoScrollSpeed","getVector","createRectangleByHtmlElement","isInRectangle","createRectangleByZoom","dx","dy","mathAbs","createPoint","refContinuousScroller","scroller","v","startContinuousScroll","useDragAutoScrollRef","shouldFindScrollableChild","checkDisable","refEl","elScrollable","isScrollableHtmlElement","isChildHtmlElement","useDraggable","dragStart","useDroppable","calcHoveringPosition","latestCalcHoveringPosition","lastEl","isDraggableElementOrComponent","editorDndStorePlugins","editorPluginElementStore","editorPluginI18nStore","i18nStore","setLanguageByUa","languages","getLanguageByUa","setLanguageNames","languageNames","keys","language","save","debounceSaveI18nState","initLanguageNames","EN_US","NAME_EN_US","ZH_CN","NAME_ZH_CN","defaultLanguageNames","resource","create","importantResource","res","isImportant","defineProperty","isString","mergePkgNameToI18nKey","path","get","text","i18nState","editorPluginI18nStoreInit","i18n","i18nStateLoader","isNil","editorPluginI18nStoreLoadState","editorI18nStorePlugins","editorPluginPdStore","pds","cds","cs","mergePkgNameToI18nResource","byElementType","logicPath","slot","isSlotMatched","isChildrenSlot","childrenSlot","createUnknownTempSlot","childrenSlotLogicPath","fn","args","editorPluginPdStoreInit","initPds","editorPdStorePlugins","editorPluginElementStoreFind","elementStore","elementDetailCacheMap","elementNameSet","componentNameIndexMap","componentName","elementName","i","parentId","childId","deep","childEd","editorPluginLayoutStoreInit","stateLoader","uidlStateLoader","editorPluginLayoutStoreLoadState","editorLayoutStorePlugins","editorPluginElementStoreSelect","selectedElementId","selectedElement","elementId","computed","editorPluginElementStoreEdit","createElementId","getObjectValueOrFirstValue","slotLogicPath","dynamicRender","childElement","editingElement","len","logicGetElementArrayInElement","logicSetElementInElement","expr","EXPRESSION_TYPE_SLOT","logicSetExpressionInElement","order","POSITION_TYPE_AFTER","arr","last","isArray","isNumber","targetElement","rootElement","targetElementIsContainer","targetElementId","clearUidlComponents","unsetClean","set","editorPluginElementStoreCopyPaste","jsonType","elementTypeSet","d","dfsElementInElement","writeJsonToClipboard","json","readJsonFromClipboard","runInAction","elementTypeMap","newElementType","ele","editorPluginElementStoreIs","getElementId","elementOrId","pkgVersion","uidlComponent","isPartialObject","deleteUndefinedValues","isObject","editorElementStorePlugins","EDITOR_EVENT_KEY_SAVE","editorPluginSaveStore","saveStore","editorPluginSaveStoreInit","editorSaveStorePlugins","editorPluginStyleStore","styleStore","editorPluginStyleStoreInit","editorStyleStorePlugins","editorDefaultPlugins","createEditor","Mobo"],"mappings":";;;;;;;;;;;;;AAGO,MAAMA,KAAsB,UAKtBC,KAAgB,CAACD,EAAmB,GCepCE,KACX;AAAA,EACE,IAAI;AAAA,EACJ,WAAWC,GAAK;AACV,IAAAA,EAAA,OAAOA,EAAI,YAAY,QAAQ;AAAA,EACrC;AACF,GCgBWC,KACX;AAAA,EACE,IAAI;AAAA,EACJ,WAAWD,GAAK;AACR,UAAAE,IAAaF,EAAI,YAAY;AACnC,IAAAE,EAAU,OAAO,MACjBC,EAAeD,GAAW;AAAA,MACxB,MAAME,EAAW;AAAA,IAAA,CAClB;AAAA,EACH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