"use strict";const p=require("@php-wasm/node"),r=require("fs"),a=require("path");function h(t){const e=[];for(const n of t){const o=n.split(":");if(o.length!==2)throw new Error(`Invalid mount format: ${n}.
				Expected format: /host/path:/vfs/path.
				If your path contains a colon, e.g. C:\\myplugin, use the --mount-dir option instead.
				Example: --mount-dir C:\\my-plugin /wordpress/wp-content/plugins/my-plugin`);const[s,i]=o;if(!r.existsSync(s))throw new Error(`Host path does not exist: ${s}`);e.push({hostPath:s,vfsPath:i})}return e}function l(t){if(t.length%2!==0)throw new Error("Invalid mount format. Expected: /host/path /vfs/path");const e=[];for(let n=0;n<t.length;n+=2){const o=t[n],s=t[n+1];if(!r.existsSync(o))throw new Error(`Host path does not exist: ${o}`);e.push({hostPath:a.resolve(process.cwd(),o),vfsPath:s})}return e}async function d(t,e){for(const n of e)await t.mount(n.vfsPath,p.createNodeFsMountHandler(n.hostPath))}const c={step:"runPHP",code:{filename:"activate-theme.php",content:`<?php
			require_once getenv('DOCROOT') . '/wp-load.php';
			$theme = wp_get_theme();
			if (!$theme->exists()) {
				$themes = wp_get_themes();
				if (count($themes) > 0) {
					$themeName = array_keys($themes)[0];
					switch_theme($themeName);
				}
			}
		`}};function m(t){const e=process.cwd(),n=[...t.mount||[]],o=[...t["mount-before-install"]||[]],s={...t,mount:n,"mount-before-install":o,"additional-blueprint-steps":[...t["additional-blueprint-steps"]||[]]};if(P(e)){const i=a.basename(e);n.push({hostPath:e,vfsPath:`/wordpress/wp-content/plugins/${i}`}),s["additional-blueprint-steps"].push({step:"activatePlugin",pluginPath:`/wordpress/wp-content/plugins/${a.basename(e)}`})}else if(g(e)){const i=a.basename(e);n.push({hostPath:e,vfsPath:`/wordpress/wp-content/themes/${i}`}),s["additional-blueprint-steps"].push({step:"activateTheme",themeDirectoryName:i})}else if(w(e)){const i=r.readdirSync(e);for(const u of i)u!=="index.php"&&n.push({hostPath:`${e}/${u}`,vfsPath:`/wordpress/wp-content/${u}`});s["additional-blueprint-steps"].push(c)}else f(e)?(o.push({hostPath:e,vfsPath:"/wordpress"}),s["additional-blueprint-steps"].push(c)):n.push({hostPath:e,vfsPath:"/wordpress"});return s}function f(t){const e=r.readdirSync(t);return e.includes("wp-admin")&&e.includes("wp-includes")&&e.includes("wp-content")}function w(t){const e=r.readdirSync(t);return e.includes("themes")||e.includes("plugins")||e.includes("mu-plugins")||e.includes("uploads")}function g(t){if(!r.readdirSync(t).includes("style.css"))return!1;const n=r.readFileSync(a.join(t,"style.css"),"utf8");return!!/^(?:[ \t]*<\?php)?[ \t/*#@]*Theme Name:(.*)$/im.exec(n)}function P(t){const e=r.readdirSync(t),n=/^(?:[ \t]*<\?php)?[ \t/*#@]*Plugin Name:(.*)$/im;return!!e.filter(s=>s.endsWith(".php")).find(s=>{const i=r.readFileSync(a.join(t,s),"utf8");return!!n.exec(i)})}exports.expandAutoMounts=m;exports.mountResources=d;exports.parseMountDirArguments=l;exports.parseMountWithDelimiterArguments=h;
//# sourceMappingURL=mounts-D7bhhGq3.cjs.map
