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ts"],"sourcesContent":["import { DebugLogger } from '@affine/debug';\nimport { DEFAULT_WORKSPACE_NAME } from '@affine/env/constant';\nimport { WorkspaceFlavour } from '@affine/env/workspace';\nimport onboardingUrl from '@affine/templates/onboarding.zip';\nimport { ZipTransformer } from '@blocksuite/blocks';\nimport type { WorkspacesService } from '@toeverything/infra';\nimport { DocsService, initEmptyPage } from '@toeverything/infra';\n\nexport async function buildShowcaseWorkspace(\n workspacesService: WorkspacesService,\n flavour: WorkspaceFlavour,\n workspaceName: string\n) {\n const meta = await workspacesService.create(flavour, async docCollection => {\n docCollection.meta.initialize();\n docCollection.meta.setName(workspaceName);\n const blob = await (await fetch(onboardingUrl)).blob();\n\n await ZipTransformer.importDocs(docCollection, blob);\n });\n\n const { workspace, dispose } = workspacesService.open({ metadata: meta });\n\n await workspace.engine.waitForRootDocReady();\n\n const docsService = workspace.scope.get(DocsService);\n\n // should jump to \"Write, Draw, Plan all at Once.\" in edgeless by default\n const defaultDoc = docsService.list.docs$.value.find(p =>\n p.title$.value.startsWith('Write, Draw, Plan all at Once.')\n );\n\n if (defaultDoc) {\n // page 모드로 생성\n defaultDoc.setMode('page');\n }\n\n dispose();\n\n return { meta, defaultDocId: defaultDoc?.id };\n}\n\nconst logger = new DebugLogger('createFirstAppData');\n\nexport async function createFirstAppData(workspacesService: WorkspacesService) {\n if (localStorage.getItem('is-first-open') !== null) {\n return;\n }\n localStorage.setItem('is-first-open', 'false');\n if (runtimeConfig.enablePreloading) {\n const { meta, defaultDocId } = await buildShowcaseWorkspace(\n workspacesService,\n WorkspaceFlavour.LOCAL,\n DEFAULT_WORKSPACE_NAME\n );\n logger.info('create first workspace', defaultDocId);\n return { meta, defaultPageId: defaultDocId };\n } else {\n let defaultPageId: string | undefined = undefined;\n const workspaceMetadata = await workspacesService.create(\n WorkspaceFlavour.LOCAL,\n async workspace => {\n workspace.meta.initialize();\n workspace.meta.setName(DEFAULT_WORKSPACE_NAME);\n const page = workspace.createDoc();\n defaultPageId = page.id;\n initEmptyPage(page);\n }\n );\n logger.info('create first workspace', workspaceMetadata);\n return { meta: workspaceMetadata, defaultPageId };\n }\n}\n"],"names":["buildShowcaseWorkspace","workspacesService","flavour","workspaceName","meta","create","docCollection","initialize","setName","blob","fetch","onboardingUrl","ZipTransformer","importDocs","workspace","dispose","open","metadata","engine","waitForRootDocReady","defaultDoc","docsService","scope","get","DocsService","list","docs$","value","find","p","title$","startsWith","setMode","defaultDocId","id","logger","DebugLogger","createFirstAppData","localStorage","getItem","setItem","WorkspaceFlavour","LOCAL","DEFAULT_WORKSPACE_NAME","info","defaultPageId"],"sourceRoot":""}