{"version":3,"sources":["jsdelivr-header.js","/npm/@tscircuit/eval-webworker@0.0.83/lib/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,UCLY,YAAa,UASlB,IAAM,uBAAyB,MACpC,IAEI,EAAc,SAChB,QAAQ,IACN,oDACA,GAIJ,IAAI,EACF,EAAc,kBAAoB,EAAc,aAElD,IAAK,EAAe,CAClB,MAAM,EACJ,iFAEI,QAAmB,MAAM,GAAQ,MAAM,GAAQ,EAAI,SACzD,EAAgB,IAAI,gBAAgB,EACtC,CAEA,MAAM,EAAY,IAAI,OAAO,EAAe,CAAE,KAAM,WAC9C,EAAwB,QAAA,KAA2B,GAErD,EAAc,0BACV,EAAc,sBAAsB,EAAc,oBAoB1D,MAhBkC,CAChC,oBAAqB,EAAc,oBAAoB,KAAK,GAC5D,QAAS,EAAc,QAAQ,KAAK,GACpC,iBAAkB,EAAc,iBAAiB,KAAK,GACtD,mBAAoB,EAAc,mBAAmB,KAAK,GAC1D,eAAgB,EAAc,eAAe,KAAK,GAClD,GAAI,CAAC,EAAe,KAClB,MAAM,EAA0B,QAAA,MAAM,GACtC,EAAc,GAAG,EAAO,EAAe,EAEzC,KAAM,UACJ,EAAsB,QAAA,gBACtB,EAAU,WAAU,EAIjB,S","file":"/npm/@tscircuit/eval-webworker@0.0.83/dist/lib/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@tscircuit/eval-webworker@0.0.83/dist/lib/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import type { AnyCircuitElement } from \"circuit-json\"\nimport * as Comlink from \"comlink\"\nimport type {\n  InternalWebWorkerApi,\n  WebWorkerConfiguration,\n  CircuitWebWorker,\n} from \"./shared/types\"\n\nexport type { CircuitWebWorker, WebWorkerConfiguration }\n\nexport const createCircuitWebWorker = async (\n  configuration: Partial<WebWorkerConfiguration>,\n): Promise<CircuitWebWorker> => {\n  if (configuration.verbose) {\n    console.log(\n      \"[Worker] Creating circuit web worker with config:\",\n      configuration,\n    )\n  }\n\n  let workerBlobUrl =\n    configuration.webWorkerBlobUrl ?? configuration.webWorkerUrl\n\n  if (!workerBlobUrl) {\n    const cdnUrl =\n      \"https://cdn.jsdelivr.net/npm/@tscircuit/eval-webworker/dist/webworker/index.js\"\n\n    const workerBlob = await fetch(cdnUrl).then((res) => res.blob())\n    workerBlobUrl = URL.createObjectURL(workerBlob)\n  }\n\n  const rawWorker = new Worker(workerBlobUrl, { type: \"module\" })\n  const comlinkWorker = Comlink.wrap<InternalWebWorkerApi>(rawWorker)\n\n  if (configuration.snippetsApiBaseUrl) {\n    await comlinkWorker.setSnippetsApiBaseUrl(configuration.snippetsApiBaseUrl)\n  }\n\n  // Create a wrapper that handles events directly through circuit instance\n  const wrapper: CircuitWebWorker = {\n    clearEventListeners: comlinkWorker.clearEventListeners.bind(comlinkWorker),\n    execute: comlinkWorker.execute.bind(comlinkWorker),\n    executeWithFsMap: comlinkWorker.executeWithFsMap.bind(comlinkWorker),\n    renderUntilSettled: comlinkWorker.renderUntilSettled.bind(comlinkWorker),\n    getCircuitJson: comlinkWorker.getCircuitJson.bind(comlinkWorker),\n    on: (event: string, callback: (...args: any[]) => void) => {\n      const proxiedCallback = Comlink.proxy(callback)\n      comlinkWorker.on(event, proxiedCallback)\n    },\n    kill: async () => {\n      comlinkWorker[Comlink.releaseProxy]()\n      rawWorker.terminate()\n    },\n  }\n\n  return wrapper\n}\n"]}