"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("node:module"),y=require("@rollup/plugin-inject"),B=require("node-stdlib-browser"),x=require("node-stdlib-browser/helpers/rollup/plugin"),P=require("node-stdlib-browser/helpers/esbuild/plugin");var a=typeof document<"u"?document.currentScript:null;const d=e=>e&&e.__esModule?e:{default:e},T=d(y),j=d(B),q=d(P),b=(e,r)=>p(e)===p(r),i=(e,r)=>e?e===!0?!0:e===r:!1,R=e=>e.startsWith("node:"),S=e=>{const r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`^${r}$`)},p=e=>e.replace(/^node:/,""),g=["import __buffer_polyfill from 'vite-plugin-node-polyfills/shims/buffer'","import __global_polyfill from 'vite-plugin-node-polyfills/shims/global'","import __process_polyfill from 'vite-plugin-node-polyfills/shims/process'","","globalThis.Buffer = globalThis.Buffer || __buffer_polyfill","globalThis.global = globalThis.global || __global_polyfill","globalThis.process = globalThis.process || __process_polyfill",""].join(` `),$=(e={})=>{const r=_.createRequire(typeof document>"u"?require("url").pathToFileURL(__filename).href:a&&a.src||new URL("index.cjs",document.baseURI).href),f=[r.resolve("vite-plugin-node-polyfills/shims/buffer"),r.resolve("vite-plugin-node-polyfills/shims/global"),r.resolve("vite-plugin-node-polyfills/shims/process")],l={include:[],exclude:[],overrides:{},protocolImports:!0,...e,globals:{Buffer:!0,global:!0,process:!0,...e.globals}},v=o=>l.include.length>0?!l.include.some(s=>b(o,s)):l.exclude.some(s=>b(o,s)),m=o=>{if(i(l.globals.Buffer,"dev")&&/^buffer$/.test(o))return"vite-plugin-node-polyfills/shims/buffer";if(i(l.globals.global,"dev")&&/^global$/.test(o))return"vite-plugin-node-polyfills/shims/global";if(i(l.globals.process,"dev")&&/^process$/.test(o))return"vite-plugin-node-polyfills/shims/process";if(o in l.overrides)return l.overrides[o]},c=Object.entries(j.default).reduce((o,[s,t])=>(!l.protocolImports&&R(s)||v(s)||(o[s]=m(p(s))||t),o),{});return{name:"vite-plugin-node-polyfills",config:(o,s)=>{const t=s.command==="serve";return{build:{rollupOptions:{onwarn:(n,u)=>{x.handleCircularDependancyWarning(n,()=>{if(o.build?.rollupOptions?.onwarn)return o.build.rollupOptions.onwarn(n,u);u(n)})},plugins:[{...T.default({...i(l.globals.Buffer,"build")?{Buffer:"vite-plugin-node-polyfills/shims/buffer"}:{},...i(l.globals.global,"build")?{global:"vite-plugin-node-polyfills/shims/global"}:{},...i(l.globals.process,"build")?{process:"vite-plugin-node-polyfills/shims/process"}:{}})}]}},esbuild:{banner:t?g:void 0},optimizeDeps:{exclude:[...f],esbuildOptions:{banner:t?{js:g}:void 0,define:{...t&&i(l.globals.Buffer,"dev")?{Buffer:"Buffer"}:{},...t&&i(l.globals.global,"dev")?{global:"global"}:{},...t&&i(l.globals.process,"dev")?{process:"process"}:{}},inject:[...f],plugins:[q.default(c),{name:"vite-plugin-node-polyfills-shims-resolver",setup(n){for(const u of f){const h=S(u);n.onResolve({filter:h},()=>({external:!1,path:u}))}}}]}},resolve:{alias:{...c}}}}}};exports.nodePolyfills=$; //# sourceMappingURL=index.cjs.map