{"ast":null,"code":"const Polling = require(\"./polling\");\n\nconst globalThis = require(\"../globalThis\");\n\nconst rNewline = /\\n/g;\nconst rEscapedNewline = /\\\\n/g;\n/**\n * Global JSONP callbacks.\n */\n\nlet callbacks;\n\nclass JSONPPolling extends Polling {\n  /**\n   * JSONP Polling constructor.\n   *\n   * @param {Object} opts.\n   * @api public\n   */\n  constructor(opts) {\n    super(opts);\n    this.query = this.query || {}; // define global callbacks array if not present\n    // we do this here (lazily) to avoid unneeded global pollution\n\n    if (!callbacks) {\n      // we need to consider multiple engines in the same page\n      callbacks = globalThis.___eio = globalThis.___eio || [];\n    } // callback identifier\n\n\n    this.index = callbacks.length; // add callback to jsonp global\n\n    const self = this;\n    callbacks.push(function (msg) {\n      self.onData(msg);\n    }); // append to query string\n\n    this.query.j = this.index;\n  }\n  /**\n   * JSONP only supports binary as base64 encoded strings\n   */\n\n\n  get supportsBinary() {\n    return false;\n  }\n  /**\n   * Closes the socket.\n   *\n   * @api private\n   */\n\n\n  doClose() {\n    if (this.script) {\n      // prevent spurious errors from being emitted when the window is unloaded\n      this.script.onerror = () => {};\n\n      this.script.parentNode.removeChild(this.script);\n      this.script = null;\n    }\n\n    if (this.form) {\n      this.form.parentNode.removeChild(this.form);\n      this.form = null;\n      this.iframe = null;\n    }\n\n    super.doClose();\n  }\n  /**\n   * Starts a poll cycle.\n   *\n   * @api private\n   */\n\n\n  doPoll() {\n    const self = this;\n    const script = document.createElement(\"script\");\n\n    if (this.script) {\n      this.script.parentNode.removeChild(this.script);\n      this.script = null;\n    }\n\n    script.async = true;\n    script.src = this.uri();\n\n    script.onerror = function (e) {\n      self.onError(\"jsonp poll error\", e);\n    };\n\n    const insertAt = document.getElementsByTagName(\"script\")[0];\n\n    if (insertAt) {\n      insertAt.parentNode.insertBefore(script, insertAt);\n    } else {\n      (document.head || document.body).appendChild(script);\n    }\n\n    this.script = script;\n    const isUAgecko = \"undefined\" !== typeof navigator && /gecko/i.test(navigator.userAgent);\n\n    if (isUAgecko) {\n      setTimeout(function () {\n        const iframe = document.createElement(\"iframe\");\n        document.body.appendChild(iframe);\n        document.body.removeChild(iframe);\n      }, 100);\n    }\n  }\n  /**\n   * Writes with a hidden iframe.\n   *\n   * @param {String} data to send\n   * @param {Function} called upon flush.\n   * @api private\n   */\n\n\n  doWrite(data, fn) {\n    const self = this;\n    let iframe;\n\n    if (!this.form) {\n      const form = document.createElement(\"form\");\n      const area = document.createElement(\"textarea\");\n      const id = this.iframeId = \"eio_iframe_\" + this.index;\n      form.className = \"socketio\";\n      form.style.position = \"absolute\";\n      form.style.top = \"-1000px\";\n      form.style.left = \"-1000px\";\n      form.target = id;\n      form.method = \"POST\";\n      form.setAttribute(\"accept-charset\", \"utf-8\");\n      area.name = \"d\";\n      form.appendChild(area);\n      document.body.appendChild(form);\n      this.form = form;\n      this.area = area;\n    }\n\n    this.form.action = this.uri();\n\n    function complete() {\n      initIframe();\n      fn();\n    }\n\n    function initIframe() {\n      if (self.iframe) {\n        try {\n          self.form.removeChild(self.iframe);\n        } catch (e) {\n          self.onError(\"jsonp polling iframe removal error\", e);\n        }\n      }\n\n      try {\n        // ie6 dynamic iframes with target=\"\" support (thanks Chris Lambacher)\n        const html = '<iframe src=\"javascript:0\" name=\"' + self.iframeId + '\">';\n        iframe = document.createElement(html);\n      } catch (e) {\n        iframe = document.createElement(\"iframe\");\n        iframe.name = self.iframeId;\n        iframe.src = \"javascript:0\";\n      }\n\n      iframe.id = self.iframeId;\n      self.form.appendChild(iframe);\n      self.iframe = iframe;\n    }\n\n    initIframe(); // escape \\n to prevent it from being converted into \\r\\n by some UAs\n    // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side\n\n    data = data.replace(rEscapedNewline, \"\\\\\\n\");\n    this.area.value = data.replace(rNewline, \"\\\\n\");\n\n    try {\n      this.form.submit();\n    } catch (e) {}\n\n    if (this.iframe.attachEvent) {\n      this.iframe.onreadystatechange = function () {\n        if (self.iframe.readyState === \"complete\") {\n          complete();\n        }\n      };\n    } else {\n      this.iframe.onload = complete;\n    }\n  }\n\n}\n\nmodule.exports = JSONPPolling;","map":{"version":3,"sources":["C:/laragon/www/iot.mksolusi/DriverOPCDA/frontend/node_modules/engine.io-client/lib/transports/polling-jsonp.js"],"names":["Polling","require","globalThis","rNewline","rEscapedNewline","callbacks","JSONPPolling","constructor","opts","query","___eio","index","length","self","push","msg","onData","j","supportsBinary","doClose","script","onerror","parentNode","removeChild","form","iframe","doPoll","document","createElement","async","src","uri","e","onError","insertAt","getElementsByTagName","insertBefore","head","body","appendChild","isUAgecko","navigator","test","userAgent","setTimeout","doWrite","data","fn","area","id","iframeId","className","style","position","top","left","target","method","setAttribute","name","action","complete","initIframe","html","replace","value","submit","attachEvent","onreadystatechange","readyState","onload","module","exports"],"mappings":"AAAA,MAAMA,OAAO,GAAGC,OAAO,CAAC,WAAD,CAAvB;;AACA,MAAMC,UAAU,GAAGD,OAAO,CAAC,eAAD,CAA1B;;AAEA,MAAME,QAAQ,GAAG,KAAjB;AACA,MAAMC,eAAe,GAAG,MAAxB;AAEA;AACA;AACA;;AAEA,IAAIC,SAAJ;;AAEA,MAAMC,YAAN,SAA2BN,OAA3B,CAAmC;AACjC;AACF;AACA;AACA;AACA;AACA;AACEO,EAAAA,WAAW,CAACC,IAAD,EAAO;AAChB,UAAMA,IAAN;AAEA,SAAKC,KAAL,GAAa,KAAKA,KAAL,IAAc,EAA3B,CAHgB,CAKhB;AACA;;AACA,QAAI,CAACJ,SAAL,EAAgB;AACd;AACAA,MAAAA,SAAS,GAAGH,UAAU,CAACQ,MAAX,GAAoBR,UAAU,CAACQ,MAAX,IAAqB,EAArD;AACD,KAVe,CAYhB;;;AACA,SAAKC,KAAL,GAAaN,SAAS,CAACO,MAAvB,CAbgB,CAehB;;AACA,UAAMC,IAAI,GAAG,IAAb;AACAR,IAAAA,SAAS,CAACS,IAAV,CAAe,UAASC,GAAT,EAAc;AAC3BF,MAAAA,IAAI,CAACG,MAAL,CAAYD,GAAZ;AACD,KA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AUe,WAAV,CAAsBd,MAAtB;AACAZ,MAAAA,IAAI,CAACY,MAAL,GAAcA,MAAd;AACD;;AAEDqC,IAAAA,UAAU,GAxDM,CA0DhB;AACA;;AACAhB,IAAAA,IAAI,GAAGA,IAAI,CAACkB,OAAL,CAAa5D,eAAb,EAA8B,MAA9B,CAAP;AACA,SAAK4C,IAAL,CAAUiB,KAAV,GAAkBnB,IAAI,CAACkB,OAAL,CAAa7D,QAAb,EAAuB,KAAvB,CAAlB;;AAEA,QAAI;AACF,WAAKqB,IAAL,CAAU0C,MAAV;AACD,KAFD,CAEE,OAAOlC,CAAP,EAAU,CAAE;;AAEd,QAAI,KAAKP,MAAL,CAAY0C,WAAhB,EAA6B;AAC3B,WAAK1C,MAAL,CAAY2C,kBAAZ,GAAiC,YAAW;AAC1C,YAAIvD,IAAI,CAACY,MAAL,CAAY4C,UAAZ,KAA2B,UAA/B,EAA2C;AACzCR,UAAAA,QAAQ;AACT;AACF,OAJD;AAKD,KAND,MAMO;AACL,WAAKpC,MAAL,CAAY6C,MAAZ,GAAqBT,QAArB;AACD;AACF;;AAxLgC;;AA2LnCU,MAAM,CAACC,OAAP,GAAiBlE,YAAjB","sourcesContent":["const Polling = require(\"./polling\");\nconst globalThis = require(\"../globalThis\");\n\nconst rNewline = /\\n/g;\nconst rEscapedNewline = /\\\\n/g;\n\n/**\n * Global JSONP callbacks.\n */\n\nlet callbacks;\n\nclass JSONPPolling extends Polling {\n  /**\n   * JSONP Polling constructor.\n   *\n   * @param {Object} opts.\n   * @api public\n   */\n  constructor(opts) {\n    super(opts);\n\n    this.query = this.query || {};\n\n    // define global callbacks array if not present\n    // we do this here (lazily) to avoid unneeded global pollution\n    if (!callbacks) {\n      // we need to consider multiple engines in the same page\n      callbacks = globalThis.___eio = globalThis.___eio || [];\n    }\n\n    // callback identifier\n    this.index = callbacks.length;\n\n    // add callback to jsonp global\n    const self = this;\n    callbacks.push(function(msg) {\n      self.onData(msg);\n    });\n\n    // append to query string\n    this.query.j = this.index;\n  }\n\n  /**\n   * JSONP only supports binary as base64 encoded strings\n   */\n  get supportsBinary() {\n    return false;\n  }\n\n  /**\n   * Closes the socket.\n   *\n   * @api private\n   */\n  doClose() {\n    if (this.script) {\n      // prevent spurious errors from being emitted when the window is unloaded\n      this.script.onerror = () => {};\n      this.script.parentNode.removeChild(this.script);\n      this.script = null;\n    }\n\n    if (this.form) {\n      this.form.parentNode.removeChild(this.form);\n      this.form = null;\n      this.iframe = null;\n    }\n\n    super.doClose();\n  }\n\n  /**\n   * Starts a poll cycle.\n   *\n   * @api private\n   */\n  doPoll() {\n    const self = this;\n    const script = document.createElement(\"script\");\n\n    if (this.script) {\n      this.script.parentNode.removeChild(this.script);\n      this.script = null;\n    }\n\n    script.async = true;\n    script.src = this.uri();\n    script.onerror = function(e) {\n      self.onError(\"jsonp poll error\", e);\n    };\n\n    const insertAt = document.getElementsByTagName(\"script\")[0];\n    if (insertAt) {\n      insertAt.parentNode.insertBefore(script, insertAt);\n    } else {\n      (document.head || document.body).appendChild(script);\n    }\n    this.script = script;\n\n    const isUAgecko =\n      \"undefined\" !== typeof navigator && /gecko/i.test(navigator.userAgent);\n\n    if (isUAgecko) {\n      setTimeout(function() {\n        const iframe = document.createElement(\"iframe\");\n        document.body.appendChild(iframe);\n        document.body.removeChild(iframe);\n      }, 100);\n    }\n  }\n\n  /**\n   * Writes with a hidden iframe.\n   *\n   * @param {String} data to send\n   * @param {Function} called upon flush.\n   * @api private\n   */\n  doWrite(data, fn) {\n    const self = this;\n    let iframe;\n\n    if (!this.form) {\n      const form = document.createElement(\"form\");\n      const area = document.createElement(\"textarea\");\n      const id = (this.iframeId = \"eio_iframe_\" + this.index);\n\n      form.className = \"socketio\";\n      form.style.position = \"absolute\";\n      form.style.top = \"-1000px\";\n      form.style.left = \"-1000px\";\n      form.target = id;\n      form.method = \"POST\";\n      form.setAttribute(\"accept-charset\", \"utf-8\");\n      area.name = \"d\";\n      form.appendChild(area);\n      document.body.appendChild(form);\n\n      this.form = form;\n      this.area = area;\n    }\n\n    this.form.action = this.uri();\n\n    function complete() {\n      initIframe();\n      fn();\n    }\n\n    function initIframe() {\n      if (self.iframe) {\n        try {\n          self.form.removeChild(self.iframe);\n        } catch (e) {\n          self.onError(\"jsonp polling iframe removal error\", e);\n        }\n      }\n\n      try {\n        // ie6 dynamic iframes with target=\"\" support (thanks Chris Lambacher)\n        const html = '<iframe src=\"javascript:0\" name=\"' + self.iframeId + '\">';\n        iframe = document.createElement(html);\n      } catch (e) {\n        iframe = document.createElement(\"iframe\");\n        iframe.name = self.iframeId;\n        iframe.src = \"javascript:0\";\n      }\n\n      iframe.id = self.iframeId;\n\n      self.form.appendChild(iframe);\n      self.iframe = iframe;\n    }\n\n    initIframe();\n\n    // escape \\n to prevent it from being converted into \\r\\n by some UAs\n    // double escaping is required for escaped new lines because unescaping of new lines can be done safely on server-side\n    data = data.replace(rEscapedNewline, \"\\\\\\n\");\n    this.area.value = data.replace(rNewline, \"\\\\n\");\n\n    try {\n      this.form.submit();\n    } catch (e) {}\n\n    if (this.iframe.attachEvent) {\n      this.iframe.onreadystatechange = function() {\n        if (self.iframe.readyState === \"complete\") {\n          complete();\n        }\n      };\n    } else {\n      this.iframe.onload = complete;\n    }\n  }\n}\n\nmodule.exports = JSONPPolling;\n"]},"metadata":{},"sourceType":"script"}