/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/next-plugin-preact@3.0.7/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
const{join:join}=require("path"),moduleAlias=require("module-alias"),esc=require("./esc");moduleAlias.addAliases({react:"preact/compat","react-dom":"preact/compat","react-ssr-prepass":"preact-ssr-prepass",webpack:"webpack"});const withPrefresh=require("@prefresh/next");function validateDependencies(){const e=[];for(const r of["preact","preact-render-to-string"])try{require.resolve(r)}catch(t){e.push(r)}const r=/^[\^~<>=\d]/,t=require(join(process.cwd(),"package.json")).dependencies;if(t&&t.react&&!r.test(t.react)||e.push("react@npm:@preact/compat"),t&&t["react-dom"]&&!r.test(t["react-dom"])||e.push("react-dom@npm:@preact/compat"),e.length){const r="-".repeat(Math.max(process.stdout.columns-1,10));console.error(`${r}${esc("31;0m")}\n[preact] Missing/incorrect dependencies.\nPlease run:\n  npm i ${e.join(" ")}\n\nor:\n\n  yarn add ${e.join(" ")}\n${r}${esc("0m")}`),process.exit(-1)}}validateDependencies(),module.exports=function(e={}){return withPrefresh(Object.assign({},e,{webpack(r,t){const{dev:s,isServer:n,nextRuntime:c,defaultLoaders:a}=t,o=t.webpack.version;if(n&&+o.split(".")[0]>=5&&(r.resolve.exportsFields=[]),!a)throw new Error("This plugin is not compatible with Next.js versions below 5.0.0 https://err.sh/next-plugins/upgrade");const p=r.optimization&&r.optimization.splitChunks;if(p&&p.cacheGroups){const e=p.cacheGroups,r=/[\\/]node_modules[\\/](preact|preact-render-to-string|preact-context-provider)[\\/]/;e.framework&&(e.preact=Object.assign({},e.framework,{test:r}))}const i=r.resolve.alias||(r.resolve.alias={});if(i.react=i["react-dom"]="preact/compat",i["react-ssr-prepass"]="preact-ssr-prepass",s&&"edge"!==c){const e=n?"pages/_document":"main.js",t=require("preact-render-to-string/package.json").version.split(".").map(Number),s=t[0]<5||5===t[0]&&(t[1]<1||1===t[1]&&t[2]<=10),c=n&&s?["preact/debug","next-plugin-preact/patches/rts-invoke-diff-hook.js"]:["preact/debug"];n&&s&&process.stdout.write(`${esc("31;1m")}next-plugin-preact:${esc("0m")} The preact-render-to-string in use requires a monkey-patch for options._diff. Upgrade to preact-render-to-string > 5.1.10 once available!\n`);const a=r.entry;r.entry=function(){return a().then((function(r){return r[e]=c.concat(r[e]||[]),r}))}}return"function"==typeof e.webpack&&(r=e.webpack(r,t)),r}}))};
//# sourceMappingURL=/sm/b8d4fd894a1f61493a9b3b4d99a6180f05271c892113c305f8c982c810ba3249.map