/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/node-wav-player@1.0.0/lib/wav-player.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";const mFs=require("fs"),mSpawn=require("child_process").spawn;class WavPlayer{constructor(){this._OS=process.platform,this._proc=null,this._called_stop=!1}async play(e){if(this._called_stop=!1,!e||"object"!=typeof e)throw new Error("The `path` is required.");let o="";if(!("path"in e))throw new Error("The `path` is required.");if(o=e.path,"string"!=typeof o||""===o)throw new Error("The `path` must be a non-empty string.");if(!mFs.existsSync(o))throw new Error("The file of the `path` was not found.");let t=!1;if("sync"in e&&(t=e.sync),"boolean"!=typeof t)throw new Error("The `sync` must be a boolean.");let r=!1;if("loop"in e&&(r=e.loop),"boolean"!=typeof r)throw new Error("The `loop` must be a boolean.");r&&(t=!1),await this._play({path:o,sync:t,loop:r})}_play(e){return new Promise(((o,t)=>{const r=e.path,s=e.loop,l=e.sync,i=this._OS;"win32"===i?(this._proc=mSpawn("powershell",["-c",'(New-Object System.Media.SoundPlayer "'+r+'").PlaySync();']),this._proc.stdin.end()):"darwin"===i?this._proc=mSpawn("afplay",[r]):"linux"===i?this._proc=mSpawn("aplay",[r]):t(new Error("The wav file can not be played on this platform."));let n=null;l||(n=setTimeout((()=>{s||this._proc.removeAllListeners("close"),o()}),500)),this._proc.on("error",(function(e){t(new Error("Failed to play the wav file ("+e+")"))})),this._proc.on("close",(r=>{n&&clearTimeout(n),!0===this._called_stop?o():0===r?l?o():s&&this._play(e):t(new Error("Failed to play the wav file ("+r+")"))}))}))}stop(){this._called_stop=!0,this._proc.removeAllListeners("close"),this._proc&&this._proc.kill()}}module.exports=new WavPlayer;
//# sourceMappingURL=/sm/8605a8830b35b680d5f6fa9d214087eba4f449e8487df12880d4216de2ec80e7.map