/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/web3-providers-ipc@4.0.7/lib/commonjs/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.IpcProvider=void 0;const net_1=require("net"),web3_errors_1=require("web3-errors"),web3_utils_1=require("web3-utils"),fs_1=require("fs");class IpcProvider extends web3_utils_1.SocketProvider{constructor(e,o,t){super(e,o,t)}getStatus(){var e;return(null===(e=this._socketConnection)||void 0===e?void 0:e.connecting)?"connecting":this._connectionStatus}_openSocketConnection(){if(!(0,fs_1.existsSync)(this._socketPath))throw new web3_errors_1.InvalidClientError(this._socketPath);this._socketConnection&&"disconnected"!==this.getStatus()||(this._socketConnection=new net_1.Socket(this._socketOptions)),this._socketConnection.connect({path:this._socketPath})}_closeSocketConnection(e,o){var t;null===(t=this._socketConnection)||void 0===t||t.end((()=>{this._onDisconnect(e,o)}))}_sendToSocket(e){var o;if("disconnected"===this.getStatus())throw new web3_errors_1.ConnectionNotOpenError;null===(o=this._socketConnection)||void 0===o||o.write(JSON.stringify(e))}_parseResponses(e){return this.chunkResponseParser.parseResponse("string"==typeof e?e:(0,web3_utils_1.toUtf8)(e))}_addSocketListeners(){var e,o,t,n,s;null===(e=this._socketConnection)||void 0===e||e.on("data",this._onMessageHandler),null===(o=this._socketConnection)||void 0===o||o.on("connect",this._onOpenHandler),null===(t=this._socketConnection)||void 0===t||t.on("close",this._onClose.bind(this)),null===(n=this._socketConnection)||void 0===n||n.on("end",this._onCloseHandler),null===(s=this._socketConnection)||void 0===s||s.on("error",this._onErrorHandler)}_removeSocketListeners(){var e,o,t,n;null===(e=this._socketConnection)||void 0===e||e.removeAllListeners("connect"),null===(o=this._socketConnection)||void 0===o||o.removeAllListeners("end"),null===(t=this._socketConnection)||void 0===t||t.removeAllListeners("close"),null===(n=this._socketConnection)||void 0===n||n.removeAllListeners("data")}_onCloseEvent(e){var o;if(!e&&this._reconnectOptions.autoReconnect)return this._connectionStatus="disconnected",void this._reconnect();this._clearQueues(e),this._removeSocketListeners(),this._onDisconnect(null==e?void 0:e.code,null==e?void 0:e.reason),null===(o=this._socketConnection)||void 0===o||o.removeAllListeners("error")}_onClose(e){this._clearQueues(e),this._removeSocketListeners()}}exports.default=IpcProvider,exports.IpcProvider=IpcProvider;
//# sourceMappingURL=/sm/529e8616968d8198ec468148813613a8b82faa70f537138cc30fa594a4726ef1.map