'use strict'; function findLocalPage(pathname, localPages) { const match = localPages.find( ({ url }) => url instanceof RegExp ? url.test(pathname) : url === pathname ); return match; } const InertiaLocalVisit = { install(app, options) { app.config.globalProperties.$localVisit = (url, props) => { const pathname = new URL(url).pathname; const localPage = findLocalPage(pathname, options.localPages); if (!localPage) { throw new Error(`Local Page(${url}) Not Found!`); } const page = { component: localPage.component, url, props }; return app.config.globalProperties.$inertia.setPage(page); }; } }; exports.InertiaLocalVisit = InertiaLocalVisit; exports.findLocalPage = findLocalPage;