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,YAAY,EACnC,MAAAE,EAAkBF,EAAS,UAAU,CAE/C,CAEA,eAAeE,EAAkBC,EAAiB,CAChD,UAAWC,KAAQD,EAAO,CACpB,GAAAC,EAAK,WAAa,KAAK,aAAc,SACzC,MAAMC,EAAUD,EAEZC,EAAQ,QAAQhB,CAAc,GAChC,MAAMM,EAAmBU,CAAO,EAElC,UAAWX,KAAMW,EAAQ,iBAAiBhB,CAAc,EACtD,MAAMM,EAAmBD,CAAE,CAC7B,CAEJ,CAEA,eAAeC,EAAmBS,EAAe,SAC3C,GAAAA,EAAK,WAAa,KAAK,aAAc,OAEzC,MAAMV,EAAKU,EAIP,KAHAE,EAAAZ,EAAG,UAAH,YAAAY,EAAY,UAAW,QACvBC,EAAAb,EAAG,UAAH,YAAAa,EAAY,0BAA2B,MAEvCH,EAAK,aAAad,CAAgB,EAAG,OACpCc,EAAA,aAAad,EAAkB,EAAE,EAEtC,MAAMkB,EAAmB,KAAK,MAAMd,EAAG,QAAQ,OAAO,GAEpD,MADgBA,EAAG,WAAW,OAAS,EAAIX,EAAiBP,GAC5C,MAAMQ,EAAiBU,EAAG,QAAQ,uBAAuB,EAAGc,CAAgB,GAAG,MAAMJ,CAAI,CAC7G,CAEA,SAASH,EAAoBE,EAAiB,CAC5C,UAAWC,KAAQD,EAAO,CACpB,GAAAC,EAAK,WAAa,KAAK,aAAc,SACzC,MAAMC,EAAUD,EAEZC,EAAQ,QAAQhB,CAAc,GAChCoB,EAAoBJ,CAAO,EAE7B,UAAWX,KAAMW,EAAQ,iBAAiBhB,CAAc,EACtDoB,EAAoBf,CAAE,CACxB,CAEJ,CAYA,SAASe,EAAoBL,EAAe,CACtCA,EAAK,SAAcA,EAAA,QAAQ,QAAQ,CACzC","names":["setupVueApp","rootComponent","rootProps","module","dynamicImportWithRetry","__vitePreload","_setupSync","setupVueSSRApp","resolveVueModule","vue_module_logical_path","component_key","m","__vite_default__","QUERY_SELECTOR","ACTIVE_ATTRIBUTE","init_run","init","whenI18nReady","el","createVueComponent","initMutationObserver","callback","mutationList","_observer","mutation","processRemovedNodes","processAddedNodes","nodes","node","node_el","_a","_b","vueComponentData","destroyVueComponent"],"ignoreList":[],"sources":["../../../app/assets/javascripts/plugins/vue/setup-async.ts","../../../app/assets/javascripts/vue_module_resolver.ts","../../../app/assets/javascripts/app/vue/semi-auto-init/index.ts"],"sourcesContent":["import { dynamicImportWithRetry } from \"@fatso83/retry-dynamic-import\"\nimport type { Component } from \"vue\"\n\nexport async function setupVueApp(rootComponent: Component, rootProps?: {[key: string]: any}) {\n const module = await dynamicImportWithRetry(() => import(\"./setup\"))\n const _setupSync = module?.setupVueApp\n return _setupSync?.(rootComponent, rootProps)\n}\n\nexport async function setupVueSSRApp(rootComponent: Component, rootProps?: {[key: string]: any}) {\n const module = await dynamicImportWithRetry(() => import(\"./setup\"))\n const _setupSync = module?.setupVueSSRApp\n return _setupSync?.(rootComponent, rootProps)\n}\n","// SSR related (used on both server & client side)\n\nexport async function resolveVueModule(vue_module_logical_path: string) {\n if (vue_module_logical_path.startsWith(\"apps/spacious_website/pages/\") && vue_module_logical_path.endsWith(\".vue\")) {\n // entry keys (value in `component_key`) are relative path from `sourceCodeDir`\n // return APPS_SPACIOUS_WEBSITE_PAGES_MODULES[`/javascripts/${vue_module_logical_path}`]\n //\n // glob pattern (1st argument in `import.meta.glob` MUST stay as string instead of variable/constant)\n // Vite can only transform these into dynamic imports this way\n // From doc - https://vitejs.dev/guide/features#glob-import-caveats\n // > You should also be aware that all the arguments in the import.meta.glob must be passed as literals. You can NOT use variables or expressions in them.\n const component_key = `/javascripts/${vue_module_logical_path}`\n if (import.meta.env.SSR) {\n // For server side, eager import enabled\n return import.meta.glob(\"apps/spacious_website/pages/**/*.vue\", {\n import: \"default\",\n eager: true,\n })[component_key]\n }\n // For client side, lazy import enabled\n const modules = import.meta.glob(\"apps/spacious_website/pages/**/*.vue\", {\n import: \"default\",\n })\n // The values are functions (to be executed to import modules, lazily)\n return modules[component_key]()\n }\n else {\n switch (vue_module_logical_path) {\n case \"~/ssr/App.vue\":\n // For testing only\n return (await import(\"~/ssr/App.vue\")).default\n default:\n // Nothing we can do, not found\n return null\n }\n }\n}\n","// Modified from https://dev.to/bdtomlin/using-vue-js-as-an-alternative-to-stimulus-js-1ic0\n\nimport { setupVueApp, setupVueSSRApp } from \"plugins/vue/setup-async\"\nimport { whenI18nReady } from \"plugins/i18n-js/state\"\n\nimport { resolveVueModule } from \"vue_module_resolver\"\n\nconst QUERY_SELECTOR = \"[data-vue-component-logical-path]\"\nconst ACTIVE_ATTRIBUTE = \"data-vueified\"\n\nlet init_run = false\n\nexport async function init() {\n if (init_run) return\n init_run = true\n\n // Otherwise locale might not be assigned in HTML yet\n await whenI18nReady()\n\n for (const el of document.querySelectorAll(QUERY_SELECTOR)) {\n await createVueComponent(el)\n }\n initMutationObserver()\n}\n\nfunction initMutationObserver() {\n const observer = new MutationObserver(callback)\n observer.observe(document.documentElement, { childList: true, subtree: true })\n}\n\nasync function callback(mutationList: MutationRecord[], _observer: MutationObserver) {\n for (const mutation of mutationList) {\n // order matters! remove those old nodes before adding the new!\n processRemovedNodes(mutation.removedNodes)\n await processAddedNodes(mutation.addedNodes)\n }\n}\n\nasync function processAddedNodes(nodes: NodeList) {\n for (const node of nodes) {\n if (node.nodeType !== Node.ELEMENT_NODE) continue\n const node_el = node as HTMLElement\n\n if (node_el.matches(QUERY_SELECTOR)) {\n await createVueComponent(node_el)\n }\n for (const el of node_el.querySelectorAll(QUERY_SELECTOR)) {\n await createVueComponent(el)\n }\n }\n}\n\nasync function createVueComponent(node: Element) {\n if (node.nodeType !== Node.ELEMENT_NODE) return\n\n const el = node as HTMLElement\n if (el.dataset?.vueData == null) return\n if (el.dataset?.vueComponentLogicalPath == null) return\n\n if (node.hasAttribute(ACTIVE_ATTRIBUTE)) return\n node.setAttribute(ACTIVE_ATTRIBUTE, \"\")\n\n const vueComponentData = JSON.parse(el.dataset.vueData)\n const setupFunc = el.childNodes.length > 0 ? setupVueSSRApp : setupVueApp\n ;(await setupFunc(await resolveVueModule(el.dataset.vueComponentLogicalPath), vueComponentData)).mount(node)\n}\n\nfunction processRemovedNodes(nodes: NodeList) {\n for (const node of nodes) {\n if (node.nodeType !== Node.ELEMENT_NODE) continue\n const node_el = node as Element\n\n if (node_el.matches(QUERY_SELECTOR)) {\n destroyVueComponent(node_el)\n }\n for (const el of node_el.querySelectorAll(QUERY_SELECTOR)) {\n destroyVueComponent(el)\n }\n }\n}\n\ndeclare global {\n interface Element {\n // Vue 3\n __vue__?: {\n // https://vuejs.org/api/application.html#app-unmount\n unmount: () => void\n }\n }\n}\n\nfunction destroyVueComponent(node: Element) {\n if (node.__vue__) node.__vue__.unmount()\n}\n"],"file":"assets/index-D8kRj30M.js"}