"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const S=require("@php-wasm/node"),M=require("@php-wasm/progress"),r=require("@php-wasm/universal"),W=require("@php-wasm/util"),F=require("@wp-playground/common"),D=require("@wp-playground/wordpress"),E=require("tls"),H=require("wasm-feature-detect"),h=require("worker_threads"),P=require("./mounts-D7bhhGq3.cjs");function I(c,e,...s){console.log(performance.now().toFixed(6).padStart(15,"0"),c.toString().padStart(16,"0"),W.sprintf(e,...s))}class w extends r.PHPWorker{constructor(e){super(void 0,e),this.booted=!1}async useFileLockManager(e){await H.jspi()?this.fileLockManager=r.consumeAPI(e):this.fileLockManager=await r.consumeAPISync(e)}async boot({absoluteUrl:e,mountsBeforeWpInstall:s,mountsAfterWpInstall:m,phpVersion:y=F.RecommendedPHPVersion,wordPressZip:l,sqliteIntegrationPluginZip:d,firstProcessId:n,processIdSpaceLength:g,dataSqlPath:f,followSymlinks:b,trace:q,internalCookieStore:k,withXdebug:_}){if(this.booted)throw new Error("Playground already booted");this.booted=!0;let o=n;const v=n+g-1;try{const t={WP_DEBUG:!0,WP_DEBUG_LOG:!0,WP_DEBUG_DISPLAY:!1},u=await D.bootWordPress({siteUrl:e,createPhpRuntime:async()=>{const i=o;return o<v?o++:o=n,await S.loadNodeRuntime(y,{emscriptenOptions:{fileLockManager:this.fileLockManager,processId:i,trace:q?I:void 0},followSymlinks:b,withXdebug:_})},wordPressZip:l!==void 0?new File([l],"wordpress.zip"):void 0,sqliteIntegrationPluginZip:d!==void 0?new File([d],"sqlite-integration-plugin.zip"):void 0,sapiName:"cli",createFiles:{"/internal/shared/ca-bundle.crt":E.rootCertificates.join(`
`)},constants:t,phpIniEntries:{"openssl.cafile":"/internal/shared/ca-bundle.crt",allow_url_fopen:"1",disable_functions:""},hooks:{async beforeWordPressFiles(i){P.mountResources(i,s)}},cookieStore:k?void 0:!1,dataSqlPath:f,spawnHandler:r.sandboxedSpawnHandlerFactory});this.__internal_setRequestHandler(u);const p=await u.getPrimaryPhp();await this.setPrimaryPHP(p),P.mountResources(p,m),L()}catch(t){throw R(t),t}}async dispose(){await this[Symbol.asyncDispose]()}}const a=new h.MessageChannel,[L,R]=r.exposeAPI(new w(new M.EmscriptenDownloadMonitor),void 0,a.port1);h.parentPort.postMessage({command:"worker-script-initialized",phpPort:a.port2},[a.port2]);exports.PlaygroundCliWorker=w;
//# sourceMappingURL=worker-thread.cjs.map
