Flow Youtube Chat

Youtubeのチャットをニコニコ風に画面上へ流す(再アップ) Make youtube chats move in danmaku-style.

目前为 2022-04-04 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Flow Youtube Chat
  3. // @version 1.15.8
  4. // @description Youtubeのチャットをニコニコ風に画面上へ流す(再アップ) Make youtube chats move in danmaku-style.
  5. // @match https://www.youtube.com/*
  6. // @namespace FlowYoutubeChatScript
  7. // @run-at document-end
  8. // @grant GM.setValue
  9. // @grant GM.getValue
  10. // @grant GM.deleteValue
  11. // @grant GM.listValues
  12. // @grant GM.setClipboard
  13. // @noframes
  14. // @license AGPL-3.0-or-later
  15. // @require https://cdn.jsdelivr.net/npm/sweetalert2@11.0.18/dist/sweetalert2.all.min.js#sha384-EoPspU1QiQ0II6WaHKy5pERCBPBD1VqZByJ29O7fDUJxGXwWLyEREDpvym8c4v2S
  16. // @require https://unpkg.com/loglevel@1.7.0/dist/loglevel.min.js#sha384-7gGuWfek8Ql6j/uNDFrS0BCe4x2ZihD4B68w9Eu580OVHJBV+bl3rZmEWC7q5/Gj
  17. // @require https://unpkg.com/rxjs@7.3.0/dist/bundles/rxjs.umd.min.js#sha384-B2HMABdZA26zJ9QwbG/c5zrcdr6+Zs8J4MgKs7udycjXgvRDA5nZKLzJ1vXWzJyH
  18. // @require https://unpkg.com/mithril@2.0.4/mithril.min.js#sha384-vo9crXih40MlEv6JWHqS7SsPiFp+76csaWQFOF2UU0/xI58Jm/ZvK/1UtpaicJT9
  19. // @require https://cdn.jsdelivr.net/npm/check-types@11.1.2/src/check-types.min.js#sha384-KGnImnhVjA5llfqKEbjBiY+1Mp6oa+NvW/TEY1XTPAKWNgrAwa3Qvn//MXL07wBM
  20. // @require https://cdn.jsdelivr.net/npm/deep-diff@1.0.2/index.min.js#sha384-Q/uiWfFlwn9XjOpL49VpFKn01EkScmaC3hh1prAn7S++WoZgXRrrjQvZ7cI7C7Zn
  21. // @require https://cdn.jsdelivr.net/npm/astring@1.7.5/dist/astring.min.js#sha384-mGnfE+xZkK7mo04MqU0t7DI1ZTFZSKwfPNjrLFeibz94N4lJgdHXh5+kI6rf5x10
  22. // @require https://cdn.jsdelivr.net/npm/jsep@0.4.0/build/jsep.min.js#sha384-89PRdfFVlT2bC9VxvLdvlByyVGml9l14DjpPqZYVI9umfvV24KPZ5dY6qBOeKf2z
  23. // @require https://cdn.jsdelivr.net/npm/hash-it@5.0.2/dist/hash-it.min.js#sha384-biRMep0zr/5fw/hIdnBIb56UHRgiIyhAagZrngd9dSxxQ9aDFMP0hbYR8PEj5lVu
  24. // @require https://cdn.jsdelivr.net/npm/micro-memoize@4.0.9/dist/micro-memoize.min.js#sha384-aGxbSIH2oMTKxZ93i+/iQKx5xefR8mHJW3mkbRaiSZizVoCvKS6wzndlLeQzMv9B
  25. // ==/UserScript==
  26.  
  27. /* jshint esversion: 6 */
  28.  
  29. ;(() => {
  30. var __webpack_modules__ = {
  31. 142: (
  32. __unused_webpack_module,
  33. __unused_webpack___webpack_exports__,
  34. __webpack_require__
  35. ) => {
  36. "use strict"
  37. const external_log_namespaceObject = log
  38. var external_log_default = __webpack_require__.n(
  39. external_log_namespaceObject
  40. )
  41. const lib = observer => value => {
  42. observer.next(value)
  43. }
  44. function sleep(time) {
  45. time || (time = 0)
  46. return new Promise(function (res) {
  47. return setTimeout(res, time)
  48. })
  49. }
  50. function randomToken() {
  51. return Math.random().toString(36).substring(2)
  52. }
  53. var lastMs = 0,
  54. additional = 0
  55. function microSeconds() {
  56. var ms = new Date().getTime()
  57. if (ms === lastMs) return 1e3 * ms + ++additional
  58. lastMs = ms
  59. additional = 0
  60. return 1e3 * ms
  61. }
  62. var isNode =
  63. "[object process]" ===
  64. Object.prototype.toString.call(
  65. "undefined" != typeof process ? process : 0
  66. )
  67. const methods_native = {
  68. create: function (channelName) {
  69. var state = {
  70. messagesCallback: null,
  71. bc: new BroadcastChannel(channelName),
  72. subFns: [],
  73. }
  74. state.bc.onmessage = function (msg) {
  75. state.messagesCallback && state.messagesCallback(msg.data)
  76. }
  77. return state
  78. },
  79. close: function (channelState) {
  80. channelState.bc.close()
  81. channelState.subFns = []
  82. },
  83. onMessage: function (channelState, fn) {
  84. channelState.messagesCallback = fn
  85. },
  86. postMessage: function (channelState, messageJson) {
  87. try {
  88. channelState.bc.postMessage(messageJson, !1)
  89. return Promise.resolve()
  90. } catch (err) {
  91. return Promise.reject(err)
  92. }
  93. },
  94. canBeUsed: function () {
  95. if (isNode && "undefined" == typeof window) return !1
  96. if ("function" == typeof BroadcastChannel) {
  97. if (BroadcastChannel._pubkey)
  98. throw new Error(
  99. "BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill"
  100. )
  101. return !0
  102. }
  103. return !1
  104. },
  105. type: "native",
  106. averageResponseTime: function () {
  107. return 150
  108. },
  109. microSeconds,
  110. }
  111. var ObliviousSet = (function () {
  112. function ObliviousSet(ttl) {
  113. this.ttl = ttl
  114. this.set = new Set()
  115. this.timeMap = new Map()
  116. }
  117. ObliviousSet.prototype.has = function (value) {
  118. return this.set.has(value)
  119. }
  120. ObliviousSet.prototype.add = function (value) {
  121. var _this = this
  122. this.timeMap.set(value, now())
  123. this.set.add(value)
  124. setTimeout(function () {
  125. !(function (obliviousSet) {
  126. for (
  127. var olderThen = now() - obliviousSet.ttl,
  128. iterator = obliviousSet.set[Symbol.iterator]();
  129. ;
  130.  
  131. ) {
  132. var value = iterator.next().value
  133. if (!value) return
  134. if (!(obliviousSet.timeMap.get(value) < olderThen)) return
  135. obliviousSet.timeMap.delete(value)
  136. obliviousSet.set.delete(value)
  137. }
  138. })(_this)
  139. }, 0)
  140. }
  141. ObliviousSet.prototype.clear = function () {
  142. this.set.clear()
  143. this.timeMap.clear()
  144. }
  145. return ObliviousSet
  146. })()
  147. function now() {
  148. return new Date().getTime()
  149. }
  150. function options_fillOptionsWithDefaults() {
  151. var originalOptions =
  152. arguments.length > 0 && void 0 !== arguments[0]
  153. ? arguments[0]
  154. : {},
  155. options = JSON.parse(JSON.stringify(originalOptions))
  156. void 0 === options.webWorkerSupport && (options.webWorkerSupport = !0)
  157. options.idb || (options.idb = {})
  158. options.idb.ttl || (options.idb.ttl = 45e3)
  159. options.idb.fallbackInterval || (options.idb.fallbackInterval = 150)
  160. originalOptions.idb &&
  161. "function" == typeof originalOptions.idb.onclose &&
  162. (options.idb.onclose = originalOptions.idb.onclose)
  163. options.localstorage || (options.localstorage = {})
  164. options.localstorage.removeTimeout ||
  165. (options.localstorage.removeTimeout = 6e4)
  166. originalOptions.methods && (options.methods = originalOptions.methods)
  167. options.node || (options.node = {})
  168. options.node.ttl || (options.node.ttl = 12e4)
  169. void 0 === options.node.useFastPath && (options.node.useFastPath = !0)
  170. return options
  171. }
  172. function getIdb() {
  173. if ("undefined" != typeof indexedDB) return indexedDB
  174. if ("undefined" != typeof window) {
  175. if (void 0 !== window.mozIndexedDB) return window.mozIndexedDB
  176. if (void 0 !== window.webkitIndexedDB) return window.webkitIndexedDB
  177. if (void 0 !== window.msIndexedDB) return window.msIndexedDB
  178. }
  179. return !1
  180. }
  181. function _readLoop(state) {
  182. state.closed ||
  183. readNewMessages(state)
  184. .then(function () {
  185. return sleep(state.options.idb.fallbackInterval)
  186. })
  187. .then(function () {
  188. return _readLoop(state)
  189. })
  190. }
  191. function readNewMessages(state) {
  192. return state.closed
  193. ? Promise.resolve()
  194. : state.messagesCallback
  195. ? ((db = state.db),
  196. (lastCursorId = state.lastCursorId),
  197. (objectStore = db
  198. .transaction("messages")
  199. .objectStore("messages")),
  200. (ret = []),
  201. new Promise(function (res) {
  202. ;(function () {
  203. try {
  204. var keyRangeValue = IDBKeyRange.bound(
  205. lastCursorId + 1,
  206. 1 / 0
  207. )
  208. return objectStore.openCursor(keyRangeValue)
  209. } catch (e) {
  210. return objectStore.openCursor()
  211. }
  212. })().onsuccess = function (ev) {
  213. var cursor = ev.target.result
  214. if (cursor)
  215. if (cursor.value.id < lastCursorId + 1)
  216. cursor.continue(lastCursorId + 1)
  217. else {
  218. ret.push(cursor.value)
  219. cursor.continue()
  220. }
  221. else res(ret)
  222. }
  223. })).then(function (newerMessages) {
  224. newerMessages
  225. .filter(function (msgObj) {
  226. return !!msgObj
  227. })
  228. .map(function (msgObj) {
  229. msgObj.id > state.lastCursorId &&
  230. (state.lastCursorId = msgObj.id)
  231. return msgObj
  232. })
  233. .filter(function (msgObj) {
  234. return (function (msgObj, state) {
  235. return !(
  236. msgObj.uuid === state.uuid ||
  237. state.eMIs.has(msgObj.id) ||
  238. msgObj.data.time < state.messagesCallbackTime
  239. )
  240. })(msgObj, state)
  241. })
  242. .sort(function (msgObjA, msgObjB) {
  243. return msgObjA.time - msgObjB.time
  244. })
  245. .forEach(function (msgObj) {
  246. if (state.messagesCallback) {
  247. state.eMIs.add(msgObj.id)
  248. state.messagesCallback(msgObj.data)
  249. }
  250. })
  251. return Promise.resolve()
  252. })
  253. : Promise.resolve()
  254. var db, lastCursorId, objectStore, ret
  255. }
  256. const indexed_db = {
  257. create: function (channelName, options) {
  258. options = options_fillOptionsWithDefaults(options)
  259. return (function (channelName) {
  260. var dbName = "pubkey.broadcast-channel-0-" + channelName,
  261. openRequest = getIdb().open(dbName, 1)
  262. openRequest.onupgradeneeded = function (ev) {
  263. ev.target.result.createObjectStore("messages", {
  264. keyPath: "id",
  265. autoIncrement: !0,
  266. })
  267. }
  268. return new Promise(function (res, rej) {
  269. openRequest.onerror = function (ev) {
  270. return rej(ev)
  271. }
  272. openRequest.onsuccess = function () {
  273. res(openRequest.result)
  274. }
  275. })
  276. })(channelName).then(function (db) {
  277. var state = {
  278. closed: !1,
  279. lastCursorId: 0,
  280. channelName,
  281. options,
  282. uuid: randomToken(),
  283. eMIs: new ObliviousSet(2 * options.idb.ttl),
  284. writeBlockPromise: Promise.resolve(),
  285. messagesCallback: null,
  286. readQueuePromises: [],
  287. db,
  288. }
  289. db.onclose = function () {
  290. state.closed = !0
  291. options.idb.onclose && options.idb.onclose()
  292. }
  293. _readLoop(state)
  294. return state
  295. })
  296. },
  297. close: function (channelState) {
  298. channelState.closed = !0
  299. channelState.db.close()
  300. },
  301. onMessage: function (channelState, fn, time) {
  302. channelState.messagesCallbackTime = time
  303. channelState.messagesCallback = fn
  304. readNewMessages(channelState)
  305. },
  306. postMessage: function (channelState, messageJson) {
  307. channelState.writeBlockPromise = channelState.writeBlockPromise
  308. .then(function () {
  309. return (function (db, readerUuid, messageJson) {
  310. var writeObject = {
  311. uuid: readerUuid,
  312. time: new Date().getTime(),
  313. data: messageJson,
  314. },
  315. transaction = db.transaction(["messages"], "readwrite")
  316. return new Promise(function (res, rej) {
  317. transaction.oncomplete = function () {
  318. return res()
  319. }
  320. transaction.onerror = function (ev) {
  321. return rej(ev)
  322. }
  323. transaction.objectStore("messages").add(writeObject)
  324. })
  325. })(channelState.db, channelState.uuid, messageJson)
  326. })
  327. .then(function () {
  328. 0 === Math.floor(11 * Math.random() + 0) &&
  329. ((db = channelState.db),
  330. (ttl = channelState.options.idb.ttl),
  331. (function (db, ttl) {
  332. var olderThen = new Date().getTime() - ttl,
  333. objectStore = db
  334. .transaction("messages")
  335. .objectStore("messages"),
  336. ret = []
  337. return new Promise(function (res) {
  338. objectStore.openCursor().onsuccess = function (ev) {
  339. var cursor = ev.target.result
  340. if (cursor) {
  341. var msgObk = cursor.value
  342. if (!(msgObk.time < olderThen)) {
  343. res(ret)
  344. return
  345. }
  346. ret.push(msgObk)
  347. cursor.continue()
  348. } else res(ret)
  349. }
  350. })
  351. })(db, ttl).then(function (tooOld) {
  352. return Promise.all(
  353. tooOld.map(function (msgObj) {
  354. return (function (db, id) {
  355. var request = db
  356. .transaction(["messages"], "readwrite")
  357. .objectStore("messages")
  358. .delete(id)
  359. return new Promise(function (res) {
  360. request.onsuccess = function () {
  361. return res()
  362. }
  363. })
  364. })(db, msgObj.id)
  365. })
  366. )
  367. }))
  368. var db, ttl
  369. })
  370. return channelState.writeBlockPromise
  371. },
  372. canBeUsed: function () {
  373. return !isNode && !!getIdb()
  374. },
  375. type: "idb",
  376. averageResponseTime: function (options) {
  377. return 2 * options.idb.fallbackInterval
  378. },
  379. microSeconds,
  380. }
  381. function getLocalStorage() {
  382. var localStorage
  383. if ("undefined" == typeof window) return null
  384. try {
  385. localStorage = window.localStorage
  386. localStorage =
  387. window["ie8-eventlistener/storage"] || window.localStorage
  388. } catch (e) {}
  389. return localStorage
  390. }
  391. function storageKey(channelName) {
  392. return "pubkey.broadcastChannel-" + channelName
  393. }
  394. function localstorage_canBeUsed() {
  395. if (isNode) return !1
  396. var ls = getLocalStorage()
  397. if (!ls) return !1
  398. try {
  399. var key = "__broadcastchannel_check"
  400. ls.setItem(key, "works")
  401. ls.removeItem(key)
  402. } catch (e) {
  403. return !1
  404. }
  405. return !0
  406. }
  407. const localstorage = {
  408. create: function (channelName, options) {
  409. options = options_fillOptionsWithDefaults(options)
  410. if (!localstorage_canBeUsed())
  411. throw new Error("BroadcastChannel: localstorage cannot be used")
  412. var uuid = randomToken(),
  413. eMIs = new ObliviousSet(options.localstorage.removeTimeout),
  414. state = { channelName, uuid, eMIs }
  415. state.listener = (function (channelName, fn) {
  416. var key = storageKey(channelName),
  417. listener = function (ev) {
  418. ev.key === key &&
  419. (function (msgObj) {
  420. if (
  421. state.messagesCallback &&
  422. msgObj.uuid !== uuid &&
  423. msgObj.token &&
  424. !eMIs.has(msgObj.token) &&
  425. !(
  426. msgObj.data.time &&
  427. msgObj.data.time < state.messagesCallbackTime
  428. )
  429. ) {
  430. eMIs.add(msgObj.token)
  431. state.messagesCallback(msgObj.data)
  432. }
  433. })(JSON.parse(ev.newValue))
  434. }
  435. window.addEventListener("storage", listener)
  436. return listener
  437. })(channelName)
  438. return state
  439. },
  440. close: function (channelState) {
  441. ;(listener = channelState.listener),
  442. window.removeEventListener("storage", listener)
  443. var listener
  444. },
  445. onMessage: function (channelState, fn, time) {
  446. channelState.messagesCallbackTime = time
  447. channelState.messagesCallback = fn
  448. },
  449. postMessage: function (channelState, messageJson) {
  450. return new Promise(function (res) {
  451. sleep().then(function () {
  452. var key = storageKey(channelState.channelName),
  453. writeObj = {
  454. token: randomToken(),
  455. time: new Date().getTime(),
  456. data: messageJson,
  457. uuid: channelState.uuid,
  458. },
  459. value = JSON.stringify(writeObj)
  460. getLocalStorage().setItem(key, value)
  461. var ev = document.createEvent("Event")
  462. ev.initEvent("storage", !0, !0)
  463. ev.key = key
  464. ev.newValue = value
  465. window.dispatchEvent(ev)
  466. res()
  467. })
  468. })
  469. },
  470. canBeUsed: localstorage_canBeUsed,
  471. type: "localstorage",
  472. averageResponseTime: function () {
  473. var userAgent = navigator.userAgent.toLowerCase()
  474. return userAgent.includes("safari") && !userAgent.includes("chrome")
  475. ? 240
  476. : 120
  477. },
  478. microSeconds,
  479. }
  480. var simulate_microSeconds = microSeconds,
  481. SIMULATE_CHANNELS = new Set()
  482. const simulate = {
  483. create: function (channelName) {
  484. var state = { name: channelName, messagesCallback: null }
  485. SIMULATE_CHANNELS.add(state)
  486. return state
  487. },
  488. close: function (channelState) {
  489. SIMULATE_CHANNELS.delete(channelState)
  490. },
  491. onMessage: function (channelState, fn) {
  492. channelState.messagesCallback = fn
  493. },
  494. postMessage: function (channelState, messageJson) {
  495. return new Promise(function (res) {
  496. return setTimeout(function () {
  497. Array.from(SIMULATE_CHANNELS)
  498. .filter(function (channel) {
  499. return channel.name === channelState.name
  500. })
  501. .filter(function (channel) {
  502. return channel !== channelState
  503. })
  504. .filter(function (channel) {
  505. return !!channel.messagesCallback
  506. })
  507. .forEach(function (channel) {
  508. return channel.messagesCallback(messageJson)
  509. })
  510. res()
  511. }, 5)
  512. })
  513. },
  514. canBeUsed: function () {
  515. return !0
  516. },
  517. type: "simulate",
  518. averageResponseTime: function () {
  519. return 5
  520. },
  521. microSeconds: simulate_microSeconds,
  522. }
  523. var METHODS = [methods_native, indexed_db, localstorage]
  524. if (isNode) {
  525. var NodeMethod = __webpack_require__(633)
  526. "function" == typeof NodeMethod.canBeUsed && METHODS.push(NodeMethod)
  527. }
  528. var broadcast_channel_BroadcastChannel = function (name, options) {
  529. this.name = name
  530. this.options = options_fillOptionsWithDefaults(options)
  531. this.method = (function (options) {
  532. var chooseMethods = []
  533. .concat(options.methods, METHODS)
  534. .filter(Boolean)
  535. if (options.type) {
  536. if ("simulate" === options.type) return simulate
  537. var ret = chooseMethods.find(function (m) {
  538. return m.type === options.type
  539. })
  540. if (ret) return ret
  541. throw new Error("method-type " + options.type + " not found")
  542. }
  543. options.webWorkerSupport ||
  544. isNode ||
  545. (chooseMethods = chooseMethods.filter(function (m) {
  546. return "idb" !== m.type
  547. }))
  548. var useMethod = chooseMethods.find(function (method) {
  549. return method.canBeUsed()
  550. })
  551. if (useMethod) return useMethod
  552. throw new Error(
  553. "No useable methode found:" +
  554. JSON.stringify(
  555. METHODS.map(function (m) {
  556. return m.type
  557. })
  558. )
  559. )
  560. })(this.options)
  561. this._iL = !1
  562. this._onML = null
  563. this._addEL = { message: [], internal: [] }
  564. this._uMP = new Set()
  565. this._befC = []
  566. this._prepP = null
  567. !(function (channel) {
  568. var obj,
  569. maybePromise = channel.method.create(
  570. channel.name,
  571. channel.options
  572. )
  573. if ((obj = maybePromise) && "function" == typeof obj.then) {
  574. channel._prepP = maybePromise
  575. maybePromise.then(function (s) {
  576. channel._state = s
  577. })
  578. } else channel._state = maybePromise
  579. })(this)
  580. }
  581. broadcast_channel_BroadcastChannel._pubkey = !0
  582. broadcast_channel_BroadcastChannel.prototype = {
  583. postMessage: function (msg) {
  584. if (this.closed)
  585. throw new Error(
  586. "BroadcastChannel.postMessage(): Cannot post message after channel has closed"
  587. )
  588. return _post(this, "message", msg)
  589. },
  590. postInternal: function (msg) {
  591. return _post(this, "internal", msg)
  592. },
  593. set onmessage(fn) {
  594. var listenObj = { time: this.method.microSeconds(), fn }
  595. _removeListenerObject(this, "message", this._onML)
  596. if (fn && "function" == typeof fn) {
  597. this._onML = listenObj
  598. _addListenerObject(this, "message", listenObj)
  599. } else this._onML = null
  600. },
  601. addEventListener: function (type, fn) {
  602. _addListenerObject(this, type, {
  603. time: this.method.microSeconds(),
  604. fn,
  605. })
  606. },
  607. removeEventListener: function (type, fn) {
  608. _removeListenerObject(
  609. this,
  610. type,
  611. this._addEL[type].find(function (obj) {
  612. return obj.fn === fn
  613. })
  614. )
  615. },
  616. close: function () {
  617. var _this = this
  618. if (!this.closed) {
  619. this.closed = !0
  620. var awaitPrepare = this._prepP ? this._prepP : Promise.resolve()
  621. this._onML = null
  622. this._addEL.message = []
  623. return awaitPrepare
  624. .then(function () {
  625. return Promise.all(Array.from(_this._uMP))
  626. })
  627. .then(function () {
  628. return Promise.all(
  629. _this._befC.map(function (fn) {
  630. return fn()
  631. })
  632. )
  633. })
  634. .then(function () {
  635. return _this.method.close(_this._state)
  636. })
  637. }
  638. },
  639. get type() {
  640. return this.method.type
  641. },
  642. get isClosed() {
  643. return this.closed
  644. },
  645. }
  646. function _post(broadcastChannel, type, msg) {
  647. var msgObj = {
  648. time: broadcastChannel.method.microSeconds(),
  649. type,
  650. data: msg,
  651. }
  652. return (
  653. broadcastChannel._prepP
  654. ? broadcastChannel._prepP
  655. : Promise.resolve()
  656. ).then(function () {
  657. var sendPromise = broadcastChannel.method.postMessage(
  658. broadcastChannel._state,
  659. msgObj
  660. )
  661. broadcastChannel._uMP.add(sendPromise)
  662. sendPromise.catch().then(function () {
  663. return broadcastChannel._uMP.delete(sendPromise)
  664. })
  665. return sendPromise
  666. })
  667. }
  668. function _hasMessageListeners(channel) {
  669. return (
  670. channel._addEL.message.length > 0 ||
  671. channel._addEL.internal.length > 0
  672. )
  673. }
  674. function _addListenerObject(channel, type, obj) {
  675. channel._addEL[type].push(obj)
  676. !(function (channel) {
  677. if (!channel._iL && _hasMessageListeners(channel)) {
  678. var listenerFn = function (msgObj) {
  679. channel._addEL[msgObj.type].forEach(function (obj) {
  680. msgObj.time >= obj.time && obj.fn(msgObj.data)
  681. })
  682. },
  683. time = channel.method.microSeconds()
  684. if (channel._prepP)
  685. channel._prepP.then(function () {
  686. channel._iL = !0
  687. channel.method.onMessage(channel._state, listenerFn, time)
  688. })
  689. else {
  690. channel._iL = !0
  691. channel.method.onMessage(channel._state, listenerFn, time)
  692. }
  693. }
  694. })(channel)
  695. }
  696. function _removeListenerObject(channel, type, obj) {
  697. channel._addEL[type] = channel._addEL[type].filter(function (o) {
  698. return o !== obj
  699. })
  700. !(function (channel) {
  701. if (channel._iL && !_hasMessageListeners(channel)) {
  702. channel._iL = !1
  703. var time = channel.method.microSeconds()
  704. channel.method.onMessage(channel._state, null, time)
  705. }
  706. })(channel)
  707. }
  708. const external_DeepDiff_namespaceObject = DeepDiff
  709. function function_identity(a) {
  710. return a
  711. }
  712. function constant(a) {
  713. return function () {
  714. return a
  715. }
  716. }
  717. var constTrue = constant(!0),
  718. constFalse = constant(!1),
  719. constUndefined = constant(void 0)
  720. function function_flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
  721. switch (arguments.length) {
  722. case 1:
  723. return ab
  724. case 2:
  725. return function () {
  726. return bc(ab.apply(this, arguments))
  727. }
  728. case 3:
  729. return function () {
  730. return cd(bc(ab.apply(this, arguments)))
  731. }
  732. case 4:
  733. return function () {
  734. return de(cd(bc(ab.apply(this, arguments))))
  735. }
  736. case 5:
  737. return function () {
  738. return ef(de(cd(bc(ab.apply(this, arguments)))))
  739. }
  740. case 6:
  741. return function () {
  742. return fg(ef(de(cd(bc(ab.apply(this, arguments))))))
  743. }
  744. case 7:
  745. return function () {
  746. return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))
  747. }
  748. case 8:
  749. return function () {
  750. return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))))
  751. }
  752. case 9:
  753. return function () {
  754. return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))))
  755. }
  756. }
  757. }
  758. function function_pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
  759. switch (arguments.length) {
  760. case 1:
  761. return a
  762. case 2:
  763. return ab(a)
  764. case 3:
  765. return bc(ab(a))
  766. case 4:
  767. return cd(bc(ab(a)))
  768. case 5:
  769. return de(cd(bc(ab(a))))
  770. case 6:
  771. return ef(de(cd(bc(ab(a)))))
  772. case 7:
  773. return fg(ef(de(cd(bc(ab(a))))))
  774. case 8:
  775. return gh(fg(ef(de(cd(bc(ab(a)))))))
  776. case 9:
  777. return hi(gh(fg(ef(de(cd(bc(ab(a))))))))
  778. default:
  779. for (var ret = arguments[0], i = 1; i < arguments.length; i++)
  780. ret = arguments[i](ret)
  781. return ret
  782. }
  783. }
  784. var isSome = function (fa) {
  785. return "Some" === fa._tag
  786. },
  787. none = { _tag: "None" },
  788. some = function (a) {
  789. return { _tag: "Some", value: a }
  790. },
  791. isNonEmpty = function (as) {
  792. return as.length > 0
  793. },
  794. head = function (as) {
  795. return as[0]
  796. },
  797. emptyReadonlyArray = [],
  798. Predicate_not =
  799. (Object.prototype.hasOwnProperty,
  800. function (predicate) {
  801. return function (a) {
  802. return !predicate(a)
  803. }
  804. }),
  805. Separated_separated = function (left, right) {
  806. return { left, right }
  807. }
  808. function Witherable_wiltDefault(T, C) {
  809. return function (F) {
  810. var traverseF = T.traverse(F)
  811. return function (wa, f) {
  812. return F.map(traverseF(wa, f), C.separate)
  813. }
  814. }
  815. }
  816. function Witherable_witherDefault(T, C) {
  817. return function (F) {
  818. var traverseF = T.traverse(F)
  819. return function (wa, f) {
  820. return F.map(traverseF(wa, f), C.compact)
  821. }
  822. }
  823. }
  824. var Option_none = none,
  825. Option_some = some
  826. function fromPredicate(predicate) {
  827. return function (a) {
  828. return predicate(a) ? Option_some(a) : Option_none
  829. }
  830. }
  831. var getLeft = function (ma) {
  832. return "Right" === ma._tag ? Option_none : Option_some(ma.left)
  833. },
  834. getRight = function (ma) {
  835. return "Left" === ma._tag ? Option_none : Option_some(ma.right)
  836. },
  837. Option_map = function (fa, f) {
  838. return function_pipe(fa, es6_Option_map(f))
  839. },
  840. _ap = function (fab, fa) {
  841. return function_pipe(fab, ap(fa))
  842. },
  843. _reduce = function (fa, b, f) {
  844. return function_pipe(fa, reduce(b, f))
  845. },
  846. _foldMap = function (M) {
  847. var foldMapM = foldMap(M)
  848. return function (fa, f) {
  849. return function_pipe(fa, foldMapM(f))
  850. }
  851. },
  852. _reduceRight = function (fa, b, f) {
  853. return function_pipe(fa, reduceRight(b, f))
  854. },
  855. _traverse = function (F) {
  856. var traverseF = traverse(F)
  857. return function (ta, f) {
  858. return function_pipe(ta, traverseF(f))
  859. }
  860. },
  861. _filter = function (fa, predicate) {
  862. return function_pipe(fa, filter(predicate))
  863. },
  864. es6_Option_map = function (f) {
  865. return function (fa) {
  866. return Option_isNone(fa) ? Option_none : Option_some(f(fa.value))
  867. }
  868. },
  869. Option_Functor = { URI: "Option", map: Option_map },
  870. of = Option_some,
  871. ap = function (fa) {
  872. return function (fab) {
  873. return Option_isNone(fab) || Option_isNone(fa)
  874. ? Option_none
  875. : Option_some(fab.value(fa.value))
  876. }
  877. },
  878. Apply = { URI: "Option", map: Option_map, ap: _ap },
  879. chain = function (f) {
  880. return function (ma) {
  881. return Option_isNone(ma) ? Option_none : f(ma.value)
  882. }
  883. },
  884. reduce = function (b, f) {
  885. return function (fa) {
  886. return Option_isNone(fa) ? b : f(b, fa.value)
  887. }
  888. },
  889. foldMap = function (M) {
  890. return function (f) {
  891. return function (fa) {
  892. return Option_isNone(fa) ? M.empty : f(fa.value)
  893. }
  894. }
  895. },
  896. reduceRight = function (b, f) {
  897. return function (fa) {
  898. return Option_isNone(fa) ? b : f(fa.value, b)
  899. }
  900. },
  901. alt = function (that) {
  902. return function (fa) {
  903. return Option_isNone(fa) ? that() : fa
  904. }
  905. },
  906. extend = function (f) {
  907. return function (wa) {
  908. return Option_isNone(wa) ? Option_none : Option_some(f(wa))
  909. }
  910. },
  911. compact = chain(function_identity),
  912. defaultSeparated = Separated_separated(Option_none, Option_none),
  913. separate = function (ma) {
  914. return Option_isNone(ma)
  915. ? defaultSeparated
  916. : Separated_separated(getLeft(ma.value), getRight(ma.value))
  917. },
  918. Compactable = { URI: "Option", compact, separate },
  919. filter = function (predicate) {
  920. return function (fa) {
  921. return Option_isNone(fa)
  922. ? Option_none
  923. : predicate(fa.value)
  924. ? fa
  925. : Option_none
  926. }
  927. },
  928. filterMap = function (f) {
  929. return function (fa) {
  930. return Option_isNone(fa) ? Option_none : f(fa.value)
  931. }
  932. },
  933. partition = function (predicate) {
  934. return function (fa) {
  935. return Separated_separated(
  936. _filter(fa, Predicate_not(predicate)),
  937. _filter(fa, predicate)
  938. )
  939. }
  940. },
  941. partitionMap = function (f) {
  942. return function_flow(es6_Option_map(f), separate)
  943. },
  944. traverse = function (F) {
  945. return function (f) {
  946. return function (ta) {
  947. return Option_isNone(ta)
  948. ? F.of(Option_none)
  949. : F.map(f(ta.value), Option_some)
  950. }
  951. }
  952. },
  953. sequence = function (F) {
  954. return function (ta) {
  955. return Option_isNone(ta)
  956. ? F.of(Option_none)
  957. : F.map(ta.value, Option_some)
  958. }
  959. },
  960. Traversable = {
  961. URI: "Option",
  962. map: Option_map,
  963. reduce: _reduce,
  964. foldMap: _foldMap,
  965. reduceRight: _reduceRight,
  966. traverse: _traverse,
  967. sequence,
  968. },
  969. _wither = Witherable_witherDefault(Traversable, Compactable),
  970. _wilt = Witherable_wiltDefault(Traversable, Compactable),
  971. Option_isSome = isSome,
  972. Option_isNone = function (fa) {
  973. return "None" === fa._tag
  974. },
  975. match = function (onNone, onSome) {
  976. return function (ma) {
  977. return Option_isNone(ma) ? onNone() : onSome(ma.value)
  978. }
  979. },
  980. getOrElseW = function (onNone) {
  981. return function (ma) {
  982. return Option_isNone(ma) ? onNone() : ma.value
  983. }
  984. },
  985. getOrElse = getOrElseW,
  986. fromNullable = function (a) {
  987. return null == a ? Option_none : Option_some(a)
  988. },
  989. chainNullableK = function (f) {
  990. return function (ma) {
  991. return Option_isNone(ma) ? Option_none : fromNullable(f(ma.value))
  992. }
  993. },
  994. toUndefined = match(constUndefined, function_identity),
  995. Option_option = {
  996. URI: "Option",
  997. map: Option_map,
  998. of,
  999. ap: _ap,
  1000. chain: function (ma, f) {
  1001. return function_pipe(ma, chain(f))
  1002. },
  1003. reduce: _reduce,
  1004. foldMap: _foldMap,
  1005. reduceRight: _reduceRight,
  1006. traverse: _traverse,
  1007. sequence,
  1008. zero: function () {
  1009. return Option_none
  1010. },
  1011. alt: function (fa, that) {
  1012. return function_pipe(fa, alt(that))
  1013. },
  1014. extend: function (wa, f) {
  1015. return function_pipe(wa, extend(f))
  1016. },
  1017. compact,
  1018. separate,
  1019. filter: _filter,
  1020. filterMap: function (fa, f) {
  1021. return function_pipe(fa, filterMap(f))
  1022. },
  1023. partition: function (fa, predicate) {
  1024. return function_pipe(fa, partition(predicate))
  1025. },
  1026. partitionMap: function (fa, f) {
  1027. return function_pipe(fa, partitionMap(f))
  1028. },
  1029. wither: _wither,
  1030. wilt: _wilt,
  1031. throwError: function () {
  1032. return Option_none
  1033. },
  1034. }
  1035. function Apply_apSecond(A) {
  1036. return function (second) {
  1037. return function (first) {
  1038. return A.ap(
  1039. A.map(first, function () {
  1040. return function (b) {
  1041. return b
  1042. }
  1043. }),
  1044. second
  1045. )
  1046. }
  1047. }
  1048. }
  1049. function Apply_apS(F) {
  1050. return function (name, fb) {
  1051. return function (fa) {
  1052. return F.ap(
  1053. F.map(fa, function (a) {
  1054. return function (b) {
  1055. var _a
  1056. return Object.assign({}, a, (((_a = {})[name] = b), _a))
  1057. }
  1058. }),
  1059. fb
  1060. )
  1061. }
  1062. }
  1063. }
  1064. function Functor_map(F, G) {
  1065. return function (f) {
  1066. return function (fa) {
  1067. return F.map(fa, function (ga) {
  1068. return G.map(ga, f)
  1069. })
  1070. }
  1071. }
  1072. }
  1073. function Functor_bindTo(F) {
  1074. return function (name) {
  1075. return function (fa) {
  1076. return F.map(fa, function (a) {
  1077. var _a
  1078. return ((_a = {})[name] = a), _a
  1079. })
  1080. }
  1081. }
  1082. }
  1083. function OptionT_some(F) {
  1084. return function_flow(Option_some, F.of)
  1085. }
  1086. function OptionT_zero(F) {
  1087. return constant(F.of(Option_none))
  1088. }
  1089. function Compactable_compact(F, G) {
  1090. return function (fga) {
  1091. return F.map(fga, G.compact)
  1092. }
  1093. }
  1094. function Filterable_filter(F, G) {
  1095. return function (predicate) {
  1096. return function (fga) {
  1097. return F.map(fga, function (ga) {
  1098. return G.filter(ga, predicate)
  1099. })
  1100. }
  1101. }
  1102. }
  1103. function Filterable_filterMap(F, G) {
  1104. return function (f) {
  1105. return function (fga) {
  1106. return F.map(fga, function (ga) {
  1107. return G.filterMap(ga, f)
  1108. })
  1109. }
  1110. }
  1111. }
  1112. function Chain_chainFirst(M) {
  1113. return function (f) {
  1114. return function (first) {
  1115. return M.chain(first, function (a) {
  1116. return M.map(f(a), function () {
  1117. return a
  1118. })
  1119. })
  1120. }
  1121. }
  1122. }
  1123. function Chain_bind(M) {
  1124. return function (name, f) {
  1125. return function (ma) {
  1126. return M.chain(ma, function (a) {
  1127. return M.map(f(a), function (b) {
  1128. var _a
  1129. return Object.assign({}, a, (((_a = {})[name] = b), _a))
  1130. })
  1131. })
  1132. }
  1133. }
  1134. }
  1135. var M,
  1136. apM,
  1137. mapM,
  1138. chainM,
  1139. altM,
  1140. foldM,
  1141. getOrElseM,
  1142. zeroM,
  1143. IO_map = function (ma, f) {
  1144. return function () {
  1145. return f(ma())
  1146. }
  1147. },
  1148. IO_ap = function (mab, ma) {
  1149. return function () {
  1150. return mab()(ma())
  1151. }
  1152. },
  1153. IO_chain = function (ma, f) {
  1154. return function () {
  1155. return f(ma())()
  1156. }
  1157. },
  1158. es6_IO_map = function (f) {
  1159. return function (fa) {
  1160. return IO_map(fa, f)
  1161. }
  1162. },
  1163. IO_of = constant,
  1164. es6_IO_chain = function (f) {
  1165. return function (ma) {
  1166. return IO_chain(ma, f)
  1167. }
  1168. },
  1169. IO_Functor = { URI: "IO", map: IO_map },
  1170. IO_Apply = { URI: "IO", map: IO_map, ap: IO_ap },
  1171. IO_apSecond = Apply_apSecond(IO_Apply),
  1172. IO_Chain = { URI: "IO", map: IO_map, ap: IO_ap, chain: IO_chain },
  1173. IO_chainFirst = Chain_chainFirst(IO_Chain),
  1174. fromIO = function_identity,
  1175. IO_bindTo = Functor_bindTo(IO_Functor),
  1176. IO_bind = Chain_bind(IO_Chain),
  1177. IO_apS = Apply_apS(IO_Apply),
  1178. IO_ApT = IO_of(emptyReadonlyArray),
  1179. IO_sequenceArray = (function (f) {
  1180. return (function (f) {
  1181. var g = (function (f) {
  1182. return function (as) {
  1183. return function () {
  1184. for (
  1185. var out = [f(0, head(as))()], i = 1;
  1186. i < as.length;
  1187. i++
  1188. )
  1189. out.push(f(i, as[i])())
  1190. return out
  1191. }
  1192. }
  1193. })(f)
  1194. return function (as) {
  1195. return isNonEmpty(as) ? g(as) : IO_ApT
  1196. }
  1197. })(function (_, a) {
  1198. return f(a)
  1199. })
  1200. })(function_identity),
  1201. IO_io = {
  1202. URI: "IO",
  1203. map: IO_map,
  1204. of: IO_of,
  1205. ap: IO_ap,
  1206. chain: IO_chain,
  1207. fromIO,
  1208. chainRec: function (a, f) {
  1209. return function () {
  1210. for (var e = f(a)(); "Left" === e._tag; ) e = f(e.left)()
  1211. return e.right
  1212. }
  1213. },
  1214. },
  1215. __assign = function () {
  1216. return (__assign =
  1217. Object.assign ||
  1218. function (t) {
  1219. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1220. s = arguments[i]
  1221. for (var p in s)
  1222. Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p])
  1223. }
  1224. return t
  1225. }).apply(this, arguments)
  1226. },
  1227. T =
  1228. ((apM = (function (F) {
  1229. return (function (F, G) {
  1230. return function (fa) {
  1231. return function (fab) {
  1232. return F.ap(
  1233. F.map(fab, function (gab) {
  1234. return function (ga) {
  1235. return G.ap(gab, ga)
  1236. }
  1237. }),
  1238. fa
  1239. )
  1240. }
  1241. }
  1242. })(F, Apply)
  1243. })((M = IO_io))),
  1244. (mapM = (function (F) {
  1245. return Functor_map(F, Option_Functor)
  1246. })(M)),
  1247. (chainM = (function (M) {
  1248. var zeroM = OptionT_zero(M)
  1249. return function (f) {
  1250. return function (ma) {
  1251. return M.chain(
  1252. ma,
  1253. match(function () {
  1254. return zeroM()
  1255. }, f)
  1256. )
  1257. }
  1258. }
  1259. })(M)),
  1260. (altM = (function (M) {
  1261. var _some = OptionT_some(M)
  1262. return function (second) {
  1263. return function (first) {
  1264. return M.chain(first, match(second, _some))
  1265. }
  1266. }
  1267. })(M)),
  1268. (foldM = (function (M) {
  1269. return function (onNone, onSome) {
  1270. return function (ma) {
  1271. return M.chain(ma, match(onNone, onSome))
  1272. }
  1273. }
  1274. })(M)),
  1275. (getOrElseM = (function (M) {
  1276. return function (onNone) {
  1277. return function (fa) {
  1278. return M.chain(fa, match(onNone, M.of))
  1279. }
  1280. }
  1281. })(M)),
  1282. (zeroM = OptionT_zero(M)),
  1283. {
  1284. map: function (fa, f) {
  1285. return function_pipe(fa, mapM(f))
  1286. },
  1287. ap: function (fab, fa) {
  1288. return function_pipe(fab, apM(fa))
  1289. },
  1290. of: OptionT_some(M),
  1291. chain: function (ma, f) {
  1292. return function_pipe(ma, chainM(f))
  1293. },
  1294. alt: function (fa, that) {
  1295. return function_pipe(fa, altM(that))
  1296. },
  1297. fold: function (fa, onNone, onSome) {
  1298. return function_pipe(fa, foldM(onNone, onSome))
  1299. },
  1300. getOrElse: function (fa, onNone) {
  1301. return function_pipe(fa, getOrElseM(onNone))
  1302. },
  1303. fromM: (function (F) {
  1304. return function (ma) {
  1305. return F.map(ma, Option_some)
  1306. }
  1307. })(M),
  1308. none: function () {
  1309. return zeroM()
  1310. },
  1311. }),
  1312. F = (function (F, G) {
  1313. var map = (function (F, G) {
  1314. var _map = Functor_map(F, G)
  1315. return {
  1316. map: function (fga, f) {
  1317. return function_pipe(fga, _map(f))
  1318. },
  1319. }
  1320. })(F, G).map,
  1321. _compact = Compactable_compact(F, G),
  1322. _separate = (function (F, C, G) {
  1323. var _compact = Compactable_compact(F, C),
  1324. _map = Functor_map(F, G)
  1325. return function (fge) {
  1326. return Separated_separated(
  1327. _compact(function_pipe(fge, _map(getLeft))),
  1328. _compact(function_pipe(fge, _map(getRight)))
  1329. )
  1330. }
  1331. })(F, G, G),
  1332. _filter = Filterable_filter(F, G),
  1333. _filterMap = Filterable_filterMap(F, G),
  1334. _partition = (function (F, G) {
  1335. var _filter = Filterable_filter(F, G)
  1336. return function (predicate) {
  1337. var left = _filter(Predicate_not(predicate)),
  1338. right = _filter(predicate)
  1339. return function (fgb) {
  1340. return Separated_separated(left(fgb), right(fgb))
  1341. }
  1342. }
  1343. })(F, G),
  1344. _partitionMap = (function (F, G) {
  1345. var _filterMap = Filterable_filterMap(F, G)
  1346. return function (f) {
  1347. return function (fga) {
  1348. return Separated_separated(
  1349. function_pipe(
  1350. fga,
  1351. _filterMap(function (a) {
  1352. return getLeft(f(a))
  1353. })
  1354. ),
  1355. function_pipe(
  1356. fga,
  1357. _filterMap(function (a) {
  1358. return getRight(f(a))
  1359. })
  1360. )
  1361. )
  1362. }
  1363. }
  1364. })(F, G)
  1365. return {
  1366. map,
  1367. compact: _compact,
  1368. separate: _separate,
  1369. filter: function (fga, f) {
  1370. return function_pipe(fga, _filter(f))
  1371. },
  1372. filterMap: function (fga, f) {
  1373. return function_pipe(fga, _filterMap(f))
  1374. },
  1375. partition: function (fga, p) {
  1376. return function_pipe(fga, _partition(p))
  1377. },
  1378. partitionMap: function (fga, f) {
  1379. return function_pipe(fga, _partitionMap(f))
  1380. },
  1381. }
  1382. })(IO_io, Option_option),
  1383. IOOption_some = (T.none(), T.of),
  1384. IOOption_fromIO = T.fromM,
  1385. fromOption = IO_of,
  1386. IOOption_map = function (f) {
  1387. return function (fa) {
  1388. return T.map(fa, f)
  1389. }
  1390. },
  1391. IOOption_chain = function (f) {
  1392. return function (ma) {
  1393. return T.chain(ma, f)
  1394. }
  1395. },
  1396. IOOption_chainFirst = function (f) {
  1397. return function (ma) {
  1398. return T.chain(ma, function (a) {
  1399. return T.map(f(a), function () {
  1400. return a
  1401. })
  1402. })
  1403. }
  1404. },
  1405. IOOption_filter =
  1406. (F.compact,
  1407. F.separate,
  1408. function (predicate) {
  1409. return function (fa) {
  1410. return F.filter(fa, predicate)
  1411. }
  1412. }),
  1413. eqStrict =
  1414. (T.map,
  1415. T.map,
  1416. T.ap,
  1417. T.map,
  1418. T.ap,
  1419. T.map,
  1420. T.ap,
  1421. T.chain,
  1422. T.map,
  1423. T.alt,
  1424. T.map,
  1425. T.ap,
  1426. T.alt,
  1427. T.map,
  1428. F.filter,
  1429. F.filterMap,
  1430. F.partition,
  1431. F.partitionMap,
  1432. __assign(
  1433. {
  1434. URI: "IOOption",
  1435. of: IOOption_some,
  1436. ap: T.ap,
  1437. chain: T.chain,
  1438. alt: T.alt,
  1439. fromIO: IOOption_fromIO,
  1440. },
  1441. F
  1442. ),
  1443. {
  1444. equals: function (a, b) {
  1445. return a === b
  1446. },
  1447. }),
  1448. es6_Reader_map = function (f) {
  1449. return function (fa) {
  1450. return function (r) {
  1451. return f(fa(r))
  1452. }
  1453. }
  1454. },
  1455. Reader_ApT = constant(emptyReadonlyArray),
  1456. Reader_sequenceArray = (function (f) {
  1457. return (function (f) {
  1458. var g = (function (f) {
  1459. return function (as) {
  1460. return function (r) {
  1461. for (
  1462. var out = [f(0, head(as))(r)], i = 1;
  1463. i < as.length;
  1464. i++
  1465. )
  1466. out.push(f(i, as[i])(r))
  1467. return out
  1468. }
  1469. }
  1470. })(f)
  1471. return function (as) {
  1472. return isNonEmpty(as) ? g(as) : Reader_ApT
  1473. }
  1474. })(function (_, a) {
  1475. return f(a)
  1476. })
  1477. })(function_identity),
  1478. ReadonlyNonEmptyArray_spreadArray = function (to, from) {
  1479. for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
  1480. to[j] = from[i]
  1481. return to
  1482. },
  1483. ReadonlyNonEmptyArray_empty = emptyReadonlyArray,
  1484. ReadonlyNonEmptyArray_isNonEmpty = isNonEmpty,
  1485. ReadonlyNonEmptyArray_head = head,
  1486. ReadonlyNonEmptyArray_tail = function (as) {
  1487. return as.slice(1)
  1488. },
  1489. ReadonlyArray_isNonEmpty = ReadonlyNonEmptyArray_isNonEmpty,
  1490. ReadonlyArray_append = function (end) {
  1491. return function (init) {
  1492. return ReadonlyNonEmptyArray_spreadArray(
  1493. ReadonlyNonEmptyArray_spreadArray([], init),
  1494. [end]
  1495. )
  1496. }
  1497. },
  1498. ReadonlyArray_makeBy = function (n, f) {
  1499. return n <= 0
  1500. ? ReadonlyArray_empty
  1501. : (function (f) {
  1502. return function (n) {
  1503. for (
  1504. var j = Math.max(0, Math.floor(n)), out = [f(0)], i = 1;
  1505. i < j;
  1506. i++
  1507. )
  1508. out.push(f(i))
  1509. return out
  1510. }
  1511. })(f)(n)
  1512. },
  1513. ReadonlyArray_isOutOfBound = function (i, as) {
  1514. return i < 0 || i >= as.length
  1515. },
  1516. findIndex = function (predicate) {
  1517. return function (as) {
  1518. for (var i = 0; i < as.length; i++)
  1519. if (predicate(as[i])) return some(i)
  1520. return none
  1521. }
  1522. },
  1523. ReadonlyArray_reverse = function (as) {
  1524. return as.length <= 1 ? as : as.slice().reverse()
  1525. },
  1526. ReadonlyArray_map = function (fa, f) {
  1527. return function_pipe(fa, es6_ReadonlyArray_map(f))
  1528. },
  1529. ReadonlyArray_reduce = function (fa, b, f) {
  1530. return function_pipe(fa, es6_ReadonlyArray_reduce(b, f))
  1531. },
  1532. ReadonlyArray_zero = function () {
  1533. return ReadonlyArray_empty
  1534. },
  1535. es6_ReadonlyArray_map = function (f) {
  1536. return function (fa) {
  1537. return fa.map(function (a) {
  1538. return f(a)
  1539. })
  1540. }
  1541. },
  1542. es6_ReadonlyArray_mapWithIndex = function (f) {
  1543. return function (fa) {
  1544. return fa.map(function (a, i) {
  1545. return f(i, a)
  1546. })
  1547. }
  1548. },
  1549. es6_ReadonlyArray_filter = function (predicate) {
  1550. return function (as) {
  1551. return as.filter(predicate)
  1552. }
  1553. },
  1554. ReadonlyArray_compact = (function (f) {
  1555. return (function (f) {
  1556. return function (fa) {
  1557. for (var out = [], i = 0; i < fa.length; i++) {
  1558. var optionB = f(i, fa[i])
  1559. isSome(optionB) && out.push(optionB.value)
  1560. }
  1561. return out
  1562. }
  1563. })(function (_, a) {
  1564. return f(a)
  1565. })
  1566. })(function_identity),
  1567. es6_ReadonlyArray_reduce = function (b, f) {
  1568. return es6_ReadonlyArray_reduceWithIndex(b, function (_, b, a) {
  1569. return f(b, a)
  1570. })
  1571. },
  1572. es6_ReadonlyArray_foldMap = function (M) {
  1573. var foldMapWithIndexM = (function (M) {
  1574. return function (f) {
  1575. return function (fa) {
  1576. return fa.reduce(function (b, a, i) {
  1577. return M.concat(b, f(i, a))
  1578. }, M.empty)
  1579. }
  1580. }
  1581. })(M)
  1582. return function (f) {
  1583. return foldMapWithIndexM(function (_, a) {
  1584. return f(a)
  1585. })
  1586. }
  1587. },
  1588. es6_ReadonlyArray_reduceWithIndex = function (b, f) {
  1589. return function (fa) {
  1590. for (var len = fa.length, out = b, i = 0; i < len; i++)
  1591. out = f(i, out, fa[i])
  1592. return out
  1593. }
  1594. },
  1595. es6_ReadonlyArray_reduceRight = function (b, f) {
  1596. return es6_ReadonlyArray_reduceRightWithIndex(
  1597. b,
  1598. function (_, a, b) {
  1599. return f(a, b)
  1600. }
  1601. )
  1602. },
  1603. es6_ReadonlyArray_reduceRightWithIndex = function (b, f) {
  1604. return function (fa) {
  1605. return fa.reduceRight(function (b, a, i) {
  1606. return f(i, a, b)
  1607. }, b)
  1608. }
  1609. },
  1610. es6_ReadonlyArray_traverse = function (F) {
  1611. var traverseWithIndexF = es6_ReadonlyArray_traverseWithIndex(F)
  1612. return function (f) {
  1613. return traverseWithIndexF(function (_, a) {
  1614. return f(a)
  1615. })
  1616. }
  1617. },
  1618. es6_ReadonlyArray_traverseWithIndex = function (F) {
  1619. return function (f) {
  1620. return es6_ReadonlyArray_reduceWithIndex(
  1621. F.of(ReadonlyArray_zero()),
  1622. function (i, fbs, a) {
  1623. return F.ap(
  1624. F.map(fbs, function (bs) {
  1625. return function (b) {
  1626. return function_pipe(bs, ReadonlyArray_append(b))
  1627. }
  1628. }),
  1629. f(i, a)
  1630. )
  1631. }
  1632. )
  1633. }
  1634. },
  1635. ReadonlyArray_Functor = {
  1636. URI: "ReadonlyArray",
  1637. map: ReadonlyArray_map,
  1638. },
  1639. ReadonlyArray_Compactable = {
  1640. URI: "ReadonlyArray",
  1641. compact: ReadonlyArray_compact,
  1642. separate: function (fa) {
  1643. for (
  1644. var left = [], right = [], _i = 0, fa_1 = fa;
  1645. _i < fa_1.length;
  1646. _i++
  1647. ) {
  1648. var e = fa_1[_i]
  1649. "Left" === e._tag ? left.push(e.left) : right.push(e.right)
  1650. }
  1651. return Separated_separated(left, right)
  1652. },
  1653. },
  1654. ReadonlyArray_Traversable = {
  1655. URI: "ReadonlyArray",
  1656. map: ReadonlyArray_map,
  1657. reduce: ReadonlyArray_reduce,
  1658. foldMap: function (M) {
  1659. var foldMapM = es6_ReadonlyArray_foldMap(M)
  1660. return function (fa, f) {
  1661. return function_pipe(fa, foldMapM(f))
  1662. }
  1663. },
  1664. reduceRight: function (fa, b, f) {
  1665. return function_pipe(fa, es6_ReadonlyArray_reduceRight(b, f))
  1666. },
  1667. traverse: function (F) {
  1668. var traverseF = es6_ReadonlyArray_traverse(F)
  1669. return function (ta, f) {
  1670. return function_pipe(ta, traverseF(f))
  1671. }
  1672. },
  1673. sequence: function (F) {
  1674. return function (ta) {
  1675. return ReadonlyArray_reduce(
  1676. ta,
  1677. F.of(ReadonlyArray_zero()),
  1678. function (fas, fa) {
  1679. return F.ap(
  1680. F.map(fas, function (as) {
  1681. return function (a) {
  1682. return function_pipe(as, ReadonlyArray_append(a))
  1683. }
  1684. }),
  1685. fa
  1686. )
  1687. }
  1688. )
  1689. }
  1690. },
  1691. },
  1692. toArray =
  1693. (Witherable_witherDefault(
  1694. ReadonlyArray_Traversable,
  1695. ReadonlyArray_Compactable
  1696. ),
  1697. Witherable_wiltDefault(
  1698. ReadonlyArray_Traversable,
  1699. ReadonlyArray_Compactable
  1700. ),
  1701. function (as) {
  1702. return as.slice()
  1703. }),
  1704. ReadonlyArray_empty = ReadonlyNonEmptyArray_empty,
  1705. ReadonlyArray_bindTo = Functor_bindTo(ReadonlyArray_Functor)
  1706. function chainFirstIOK(F, M) {
  1707. var chainFirstM = Chain_chainFirst(M)
  1708. return function (f) {
  1709. return chainFirstM(function_flow(f, F.fromIO))
  1710. }
  1711. }
  1712. var Task_fromIO = function (ma) {
  1713. return function () {
  1714. return Promise.resolve().then(ma)
  1715. }
  1716. },
  1717. Task_map = function (fa, f) {
  1718. return function_pipe(fa, es6_Task_map(f))
  1719. },
  1720. _apPar = function (fab, fa) {
  1721. return function_pipe(fab, Task_ap(fa))
  1722. },
  1723. es6_Task_map = function (f) {
  1724. return function (fa) {
  1725. return function () {
  1726. return Promise.resolve().then(fa).then(f)
  1727. }
  1728. }
  1729. },
  1730. Task_ap = function (fa) {
  1731. return function (fab) {
  1732. return function () {
  1733. return Promise.all([
  1734. Promise.resolve().then(fab),
  1735. Promise.resolve().then(fa),
  1736. ]).then(function (_a) {
  1737. return (0, _a[0])(_a[1])
  1738. })
  1739. }
  1740. }
  1741. },
  1742. Task_of = function (a) {
  1743. return function () {
  1744. return Promise.resolve(a)
  1745. }
  1746. },
  1747. es6_Task_chain = function (f) {
  1748. return function (ma) {
  1749. return function () {
  1750. return Promise.resolve()
  1751. .then(ma)
  1752. .then(function (a) {
  1753. return f(a)()
  1754. })
  1755. }
  1756. }
  1757. },
  1758. Task_Functor = { URI: "Task", map: Task_map },
  1759. ApplyPar = { URI: "Task", map: Task_map, ap: _apPar },
  1760. Task_Chain = {
  1761. URI: "Task",
  1762. map: Task_map,
  1763. ap: _apPar,
  1764. chain: function (ma, f) {
  1765. return function_pipe(ma, es6_Task_chain(f))
  1766. },
  1767. },
  1768. Task_chainFirstIOK = chainFirstIOK(
  1769. { URI: "Task", fromIO: Task_fromIO },
  1770. Task_Chain
  1771. ),
  1772. Task_bindTo = Functor_bindTo(Task_Functor),
  1773. Task_bind = Chain_bind(Task_Chain),
  1774. Task_apS = Apply_apS(ApplyPar)
  1775. const external_rxjs_namespaceObject = rxjs,
  1776. appendLog =
  1777. log =>
  1778. ([a, ...b]) =>
  1779. function_pipe(
  1780. [...log, `${a}${b.length > 0 ? ": " : ""}${b.join(", ")}`],
  1781. x => (x.length > 1e3 ? x.slice(0, 100) : x)
  1782. ),
  1783. consoleLog = (...[a, ...b]) =>
  1784. function_pipe(
  1785. () =>
  1786. external_log_default().info(
  1787. ...("string" == typeof a ? [`【FYC ${a}`] : ["【FYC】", a])
  1788. ),
  1789. IO_apSecond(
  1790. b.length > 0
  1791. ? () => external_log_default().info(...b)
  1792. : () => {}
  1793. )
  1794. ),
  1795. createChatScreen = () => {
  1796. const element = document.createElement("div")
  1797. element.style.pointerEvents = "none"
  1798. element.style.zIndex = "30"
  1799. element.style.position = "absolute"
  1800. element.style.overflow = "hidden"
  1801. element.style.height = "100%"
  1802. element.style.width = "100%"
  1803. return element
  1804. },
  1805. external_jsep_namespaceObject = jsep
  1806. var external_jsep_default = __webpack_require__.n(
  1807. external_jsep_namespaceObject
  1808. ),
  1809. u = {
  1810. "||": function (r, e) {
  1811. return r || e
  1812. },
  1813. "&&": function (r, e) {
  1814. return r && e
  1815. },
  1816. "|": function (r, e) {
  1817. return r | e
  1818. },
  1819. "^": function (r, e) {
  1820. return r ^ e
  1821. },
  1822. "&": function (r, e) {
  1823. return r & e
  1824. },
  1825. "==": function (r, e) {
  1826. return r == e
  1827. },
  1828. "!=": function (r, e) {
  1829. return r != e
  1830. },
  1831. "===": function (r, e) {
  1832. return r === e
  1833. },
  1834. "!==": function (r, e) {
  1835. return r !== e
  1836. },
  1837. "<": function (r, e) {
  1838. return r < e
  1839. },
  1840. ">": function (r, e) {
  1841. return r > e
  1842. },
  1843. "<=": function (r, e) {
  1844. return r <= e
  1845. },
  1846. ">=": function (r, e) {
  1847. return r >= e
  1848. },
  1849. "<<": function (r, e) {
  1850. return r << e
  1851. },
  1852. ">>": function (r, e) {
  1853. return r >> e
  1854. },
  1855. ">>>": function (r, e) {
  1856. return r >>> e
  1857. },
  1858. "+": function (r, e) {
  1859. return r + e
  1860. },
  1861. "-": function (r, e) {
  1862. return r - e
  1863. },
  1864. "*": function (r, e) {
  1865. return r * e
  1866. },
  1867. "/": function (r, e) {
  1868. return r / e
  1869. },
  1870. "%": function (r, e) {
  1871. return r % e
  1872. },
  1873. },
  1874. i = {
  1875. "-": function (r) {
  1876. return -r
  1877. },
  1878. "+": function (r) {
  1879. return +r
  1880. },
  1881. "~": function (r) {
  1882. return ~r
  1883. },
  1884. "!": function (r) {
  1885. return !r
  1886. },
  1887. }
  1888. function s(r, e) {
  1889. return r.map(function (r) {
  1890. return a(r, e)
  1891. })
  1892. }
  1893. function c(r, e) {
  1894. var n,
  1895. t = a(r.object, e)
  1896. if (
  1897. ((n = r.computed ? a(r.property, e) : r.property.name),
  1898. /^__proto__|prototype|constructor$/.test(n))
  1899. )
  1900. throw Error('Access to member "' + n + '" disallowed.')
  1901. return [t, t[n]]
  1902. }
  1903. function a(r, e) {
  1904. var n = r
  1905. switch (n.type) {
  1906. case "ArrayExpression":
  1907. return s(n.elements, e)
  1908. case "BinaryExpression":
  1909. return u[n.operator](a(n.left, e), a(n.right, e))
  1910. case "CallExpression":
  1911. var t, o, l
  1912. if (
  1913. ("MemberExpression" === n.callee.type
  1914. ? ((t = (l = c(n.callee, e))[0]), (o = l[1]))
  1915. : (o = a(n.callee, e)),
  1916. "function" != typeof o)
  1917. )
  1918. return
  1919. return o.apply(t, s(n.arguments, e))
  1920. case "ConditionalExpression":
  1921. return a(n.test, e) ? a(n.consequent, e) : a(n.alternate, e)
  1922. case "Identifier":
  1923. return e[n.name]
  1924. case "Literal":
  1925. return n.value
  1926. case "LogicalExpression":
  1927. return "||" === n.operator
  1928. ? a(n.left, e) || a(n.right, e)
  1929. : "&&" === n.operator
  1930. ? a(n.left, e) && a(n.right, e)
  1931. : u[n.operator](a(n.left, e), a(n.right, e))
  1932. case "MemberExpression":
  1933. return c(n, e)[1]
  1934. case "ThisExpression":
  1935. return e
  1936. case "UnaryExpression":
  1937. return i[n.operator](a(n.argument, e))
  1938. default:
  1939. return
  1940. }
  1941. }
  1942. var Eq = {
  1943. equals: function (first, second) {
  1944. return first === second
  1945. },
  1946. },
  1947. string_isEmpty = function (s) {
  1948. return 0 === s.length
  1949. },
  1950. split = function (separator) {
  1951. return function (s) {
  1952. var out = s.split(separator)
  1953. return ReadonlyNonEmptyArray_isNonEmpty(out) ? out : [s]
  1954. }
  1955. }
  1956. const fycKey = key => `FYC_${key}`,
  1957. stringsArgs = [
  1958. [],
  1959. function_flow(
  1960. split(/\r\n|\n/),
  1961. es6_ReadonlyArray_filter(Predicate_not(string_isEmpty))
  1962. ),
  1963. x => x.join("\n"),
  1964. ],
  1965. sc = (k, d) =>
  1966. (async (key, defaultVal) => ({
  1967. gmKey: key,
  1968. val: (await GM.getValue(key)) ?? defaultVal,
  1969. defaultVal,
  1970. toGm: function_identity,
  1971. }))(fycKey(k), d),
  1972. ic = (k, d, i, g) =>
  1973. (async (key, defaultVal, toItem, toGm) => {
  1974. const val = await GM.getValue(key)
  1975. return {
  1976. gmKey: key,
  1977. val: void 0 !== val ? toItem(val) : defaultVal,
  1978. defaultVal,
  1979. toGm,
  1980. }
  1981. })(fycKey(k), d, i, g),
  1982. defaultUserConfig = async () => ({
  1983. lang: await sc("LANG", "FYC_EN"),
  1984. font: await sc("FONT", "MS PGothic"),
  1985. chatOpacity: await sc("OPACITY", 0.8),
  1986. color: await sc("COLOR", "#ffffff"),
  1987. ownerColor: await sc("COLOR_OWNER", "#ffd600"),
  1988. moderatorColor: await sc("COLOR_MODERATOR", "#c564ff"),
  1989. memberColor: await sc("COLOR_MEMBER", "#9fffff"),
  1990. fontSize: await sc("SIZE", 1),
  1991. fontWeight: await sc("WEIGHT", 730),
  1992. shadowFontWeight: await sc("WEIGHT_SHADOW", 1),
  1993. maxChatCount: await sc("LIMIT", 40),
  1994. flowSpeed: await sc("SPEED", 18),
  1995. maxChatLength: await sc("MAX", 100),
  1996. laneCount: await sc("LANE_DIV", 12),
  1997. bannedWords: await ic("NG_WORDS", ...stringsArgs),
  1998. bannedWordRegexs: await ic("NG_REG_WORDS", ...stringsArgs),
  1999. bannedUsers: await ic("NG_USERS", ...stringsArgs),
  2000. createChats: await sc("TOGGLE_CREATE_COMMENTS", !0),
  2001. noOverlap: await sc("NO_OVERLAP", !0),
  2002. createBanButton: await sc("NG_BUTTON", !0),
  2003. simplifyChatField: await sc("SIMPLE_CHAT_FIELD", !1),
  2004. displayModName: await sc("DISPLAY_MODERATOR_NAME", !0),
  2005. displaySuperChatAuthor: await sc("DISPLAY_SUPER_CHAT_AUTHOR", !0),
  2006. textOnly: await sc("TEXT_ONLY", !1),
  2007. timingFunction: await sc("TIMING_FUNCTION", "linear"),
  2008. displayChats: await sc("DISPLAY_COMMENTS", !0),
  2009. minSpacing: await sc("MIN_SPACING", 0.5),
  2010. fieldScale: await sc("FIELD_SCALE", 1),
  2011. flowY1: await sc("flowY1", 0),
  2012. flowY2: await sc("flowY2", 1),
  2013. flowX1: await sc("flowX1", 0),
  2014. flowX2: await sc("flowX2", 1),
  2015. shadowColor: await sc("shadowColor", "#000000"),
  2016. }),
  2017. chatApp = () =>
  2018. function_pipe(
  2019. fromNullable(document.querySelector("#chatframe")),
  2020. filter(x => {
  2021. const state = x.contentDocument?.readyState
  2022. return "loading" === state || "complete" === state
  2023. }),
  2024. chainNullableK(x => x.contentDocument),
  2025. alt(() => Option_some(document)),
  2026. chainNullableK(x => x.querySelector("yt-live-chat-app"))
  2027. ),
  2028. livePageYt = () => ({
  2029. toggleChatBtnParent: () =>
  2030. fromNullable(document.querySelector(".ytp-right-controls")),
  2031. settingNextElement: () =>
  2032. fromNullable(
  2033. document.querySelector(
  2034. "#menu-container .dropdown-trigger.ytd-menu-renderer"
  2035. )
  2036. ),
  2037. player: () => fromNullable(document.querySelector("#movie_player")),
  2038. video: () =>
  2039. fromNullable(
  2040. document.querySelector("video.video-stream.html5-main-video")
  2041. ),
  2042. chatField: () =>
  2043. function_pipe(
  2044. chatApp(),
  2045. chainNullableK(x =>
  2046. x.querySelector("#items.yt-live-chat-item-list-renderer")
  2047. )
  2048. ),
  2049. chatTicker: () =>
  2050. function_pipe(
  2051. chatApp(),
  2052. chainNullableK(x =>
  2053. x.querySelector("#items.yt-live-chat-ticker-renderer")
  2054. )
  2055. ),
  2056. chatScroller: () =>
  2057. function_pipe(
  2058. chatApp(),
  2059. chainNullableK(x =>
  2060. x.querySelector(
  2061. "#item-scroller.yt-live-chat-item-list-renderer"
  2062. )
  2063. )
  2064. ),
  2065. offlineSlate: () =>
  2066. fromNullable(document.querySelector(".ytp-offline-slate")),
  2067. }),
  2068. mainCss = () => {
  2069. const element = document.createElement("style")
  2070. element.innerHTML =
  2071. ".fyc_chat {\n line-height: 1;\n z-index: 30;\n position: absolute;\n user-select: none;\n white-space: nowrap;\n will-change: transform;\n }\n .fyc_button {\n display: inline-block;\n border-style: none;\n z-index: 4;\n font-weight: 500;\n color: var(--yt-spec-text-secondary);\n }"
  2072. return element
  2073. },
  2074. observePair = con =>
  2075. function_pipe(
  2076. () => new external_rxjs_namespaceObject.Subject(),
  2077. IO_bindTo("subject"),
  2078. IO_bind("observer", x => () => new con(lib(x.subject)))
  2079. ),
  2080. external_Swal_namespaceObject = Swal
  2081. var external_Swal_default = __webpack_require__.n(
  2082. external_Swal_namespaceObject
  2083. )
  2084. const addBanButton_button = document.createElement("button")
  2085. addBanButton_button.classList.add(
  2086. "style-scope",
  2087. "yt-icon-button",
  2088. "fyc_button"
  2089. )
  2090. Object.assign(addBanButton_button.style, {
  2091. padding: "0px",
  2092. width: "20px",
  2093. height: "20px",
  2094. fill: "#fff",
  2095. })
  2096. addBanButton_button.setAttribute(
  2097. "aria-label",
  2098. "NGに入れる(Ban this user)"
  2099. )
  2100. addBanButton_button.innerHTML =
  2101. '<svg class="style-scope yt-icon" style="width: 100%; height: 75%; fill: var(--yt-spec-text-secondary);" viewBox="0 0 512 512"><path d="M440 78A256 256 0 1 0 73 435 256 256 0 0 0 440 78zm-99 35L113 341C37 179 212 44 341 113zM177 405l228-228c76 162-99 297-228 228z" fill-rule="evenodd"/></svg>'
  2102. const addBanButton = (chat, id, getConfig, setConfig) =>
  2103. chat.children.namedItem("card")
  2104. ? () => {}
  2105. : () => {
  2106. const clone = addBanButton_button.cloneNode(!0)
  2107. clone.onclick = function_pipe(
  2108. getConfig.bannedUsers,
  2109. IOOption_fromIO,
  2110. IOOption_filter(x => !x.includes(id)),
  2111. IOOption_map(
  2112. function_flow(
  2113. ((f = (function (E) {
  2114. return function (as) {
  2115. if (1 === as.length) return as
  2116. for (
  2117. var out = [ReadonlyNonEmptyArray_head(as)],
  2118. _loop_1 = function (a) {
  2119. out.every(function (o) {
  2120. return !E.equals(o, a)
  2121. }) && out.push(a)
  2122. },
  2123. _i = 0,
  2124. rest_1 = ReadonlyNonEmptyArray_tail(as);
  2125. _i < rest_1.length;
  2126. _i++
  2127. )
  2128. _loop_1(rest_1[_i])
  2129. return out
  2130. }
  2131. })(Eq)),
  2132. function (as) {
  2133. return ReadonlyArray_isNonEmpty(as) ? f(as) : as
  2134. }),
  2135. ReadonlyArray_append(id),
  2136. toArray
  2137. )
  2138. ),
  2139. IOOption_chain(x =>
  2140. IOOption_fromIO(() => {
  2141. setConfig.bannedUsers(x)
  2142. external_Swal_default()
  2143. .mixin({
  2144. toast: !0,
  2145. position: "bottom-left",
  2146. timer: 2500,
  2147. timerProgressBar: !0,
  2148. showConfirmButton: !1,
  2149. didOpen: toast => {
  2150. toast.addEventListener(
  2151. "pointerenter",
  2152. external_Swal_default().stopTimer
  2153. )
  2154. toast.addEventListener(
  2155. "pointerleave",
  2156. external_Swal_default().resumeTimer
  2157. )
  2158. },
  2159. })
  2160. .fire({
  2161. title: `Added Banned User: ${id}`,
  2162. icon: "success",
  2163. })
  2164. })
  2165. ),
  2166. IO_apSecond(() => {
  2167. chat.style.display = "none"
  2168. })
  2169. )
  2170. var f
  2171. chat.querySelector("#content #message")?.append(clone)
  2172. },
  2173. getChatFontSize = mainState =>
  2174. Math.round(
  2175. ((Math.max(mainState.getConfig.fontSize() - 0.2, 0.01) *
  2176. mainState.playerRect.height) /
  2177. mainState.getConfig.laneCount()) *
  2178. (mainState.getConfig.flowY2() - mainState.getConfig.flowY1()) *
  2179. 100
  2180. ) / 100
  2181. var equalsDefault = function (compare) {
  2182. return function (first, second) {
  2183. return first === second || 0 === compare(first, second)
  2184. }
  2185. },
  2186. Ord_contramap = function (f) {
  2187. return function (fa) {
  2188. return {
  2189. equals: equalsDefault(
  2190. (compare = function (first, second) {
  2191. return fa.compare(f(first), f(second))
  2192. })
  2193. ),
  2194. compare: function (first, second) {
  2195. return first === second ? 0 : compare(first, second)
  2196. },
  2197. }
  2198. var compare
  2199. }
  2200. },
  2201. number_Ord = {
  2202. equals: function (first, second) {
  2203. return first === second
  2204. },
  2205. compare: function (first, second) {
  2206. return first < second ? -1 : first > second ? 1 : 0
  2207. },
  2208. },
  2209. number_Show_show = function (n) {
  2210. return JSON.stringify(n)
  2211. }
  2212. const external_window_micro_memoize_namespaceObject =
  2213. window["micro-memoize"]
  2214. var external_window_micro_memoize_default = __webpack_require__.n(
  2215. external_window_micro_memoize_namespaceObject
  2216. )
  2217. const getFlowChatProgress = chat =>
  2218. function_pipe(
  2219. chat.animation,
  2220. chainNullableK(x => x.currentTime),
  2221. getOrElse(() => 0)
  2222. ) / chat.animationDuration,
  2223. getFlowChatRect = (chat, mainState) => {
  2224. const { getConfig } = mainState,
  2225. x =
  2226. mainState.playerRect.width * getConfig.flowX2() -
  2227. (chat.width +
  2228. mainState.playerRect.width *
  2229. (getConfig.flowX2() - getConfig.flowX1())) *
  2230. getFlowChatProgress(chat)
  2231. return new DOMRect(x, chat.y, chat.width, chat.height)
  2232. },
  2233. getChatLane = (flowChat, progress, flowChats) => mainState => {
  2234. const flowWidth =
  2235. mainState.playerRect.width *
  2236. (mainState.getConfig.flowX2() - mainState.getConfig.flowX1()),
  2237. chatRect = getFlowChatRect(flowChat, mainState),
  2238. chatWidth = chatRect.width,
  2239. chatHeight = chatRect.height,
  2240. chatX = chatRect.x,
  2241. chatIndex = flowChats.indexOf(flowChat),
  2242. movingChats = function_pipe(
  2243. flowChats,
  2244. ((n = chatIndex >= 0 ? chatIndex : -1),
  2245. function (as) {
  2246. return ReadonlyArray_isOutOfBound(n, as)
  2247. ? as
  2248. : 0 === n
  2249. ? ReadonlyArray_empty
  2250. : as.slice(0, n)
  2251. }),
  2252. es6_ReadonlyArray_filter(
  2253. chat => !chat.animationEnded && chat.width > 0
  2254. ),
  2255. ((O = Ord_contramap(x => x.lane)(number_Ord)),
  2256. function (as) {
  2257. return as.length <= 1 ? as : as.slice().sort(O.compare)
  2258. })
  2259. ),
  2260. tooCloseTo = external_window_micro_memoize_default()(
  2261. i => {
  2262. const otherRect = getFlowChatRect(movingChats[i], mainState),
  2263. otherWidth = otherRect.width,
  2264. otherX = otherRect.x,
  2265. gap =
  2266. (chatHeight * otherWidth * chatWidth) ** 0.333 *
  2267. mainState.getConfig.minSpacing()
  2268. return (
  2269. (flowWidth - otherX) / (flowWidth + otherWidth) - progress <
  2270. (chatWidth + gap) / (flowWidth + chatWidth) ||
  2271. otherX + otherWidth + gap > chatX
  2272. )
  2273. },
  2274. { maxSize: 1e3 }
  2275. ),
  2276. occupyInfo = function_pipe(
  2277. movingChats,
  2278. es6_ReadonlyArray_mapWithIndex((i, x) => ({
  2279. tooClose: () => tooCloseTo(i),
  2280. lane: x.lane,
  2281. })),
  2282. ReadonlyArray_append({
  2283. tooClose: () => !0,
  2284. lane: mainState.getConfig.laneCount(),
  2285. })
  2286. ),
  2287. index = occupyInfo.findIndex(x => x.lane >= flowChat.lane),
  2288. rightFreeLane = function_pipe(
  2289. occupyInfo.slice(index),
  2290. ((predicate = x => x.tooClose()),
  2291. function (as) {
  2292. for (var i = 0; i < as.length; i++)
  2293. if (predicate(as[i])) return some(as[i])
  2294. return none
  2295. }),
  2296. es6_Option_map(x => x.lane),
  2297. getOrElse(() => mainState.getConfig.laneCount())
  2298. )
  2299. var O, n, predicate
  2300. const leftFreeLane = function_pipe(
  2301. occupyInfo.slice(0, index),
  2302. function (as) {
  2303. for (var i = as.length - 1; i >= 0; i--)
  2304. if (as[i].tooClose()) return some(as[i])
  2305. return none
  2306. },
  2307. es6_Option_map(x => x.lane),
  2308. getOrElse(() => -1)
  2309. ),
  2310. formerLaneInterval = Math.min(
  2311. flowChat.lane - leftFreeLane,
  2312. rightFreeLane - flowChat.lane,
  2313. 1
  2314. )
  2315. return function_pipe(
  2316. occupyInfo,
  2317. es6_ReadonlyArray_reduce(
  2318. { maxInterval: 0, maxIntervalLane: 0, lastLane: -1 },
  2319. ({ maxInterval, maxIntervalLane, lastLane }, info) =>
  2320. maxInterval > 0.999 || !info.tooClose()
  2321. ? { maxInterval, maxIntervalLane, lastLane }
  2322. : (() => {
  2323. const nextLane = info.lane,
  2324. interLane = Math.min(
  2325. Math.max((lastLane + nextLane) / 2, 0),
  2326. mainState.getConfig.laneCount() - 1
  2327. ),
  2328. newInterval = Math.min(
  2329. interLane - lastLane,
  2330. nextLane - interLane,
  2331. 1
  2332. )
  2333. return newInterval - maxInterval > 0.001
  2334. ? {
  2335. maxInterval: newInterval,
  2336. maxIntervalLane: Math.max(
  2337. lastLane + newInterval,
  2338. 0
  2339. ),
  2340. lastLane: nextLane,
  2341. }
  2342. : { maxInterval, maxIntervalLane, lastLane: nextLane }
  2343. })()
  2344. ),
  2345. x => ({
  2346. lane:
  2347. Math.abs(formerLaneInterval - x.maxInterval) < 0.001
  2348. ? flowChat.lane
  2349. : x.maxIntervalLane,
  2350. interval: x.maxInterval,
  2351. })
  2352. )
  2353. },
  2354. intervalTooSmall = interval => getConfig =>
  2355. getConfig.noOverlap() && interval < 0.999,
  2356. external_m_namespaceObject = m
  2357. var external_m_default = __webpack_require__.n(
  2358. external_m_namespaceObject
  2359. )
  2360. const textShadow = shadowColor =>
  2361. function_flow(
  2362. x => `${x}px`,
  2363. x => (a, b) => `${a}${x} ${b}${x} ${shadowColor}99`,
  2364. x => [x("-", "-"), x("", "-"), x("-", ""), x("", "")].join(", ")
  2365. ),
  2366. textStyle = { fontFamily: "inherit" },
  2367. renderChat = chat => mainState => () =>
  2368. external_m_default().render(
  2369. chat.element,
  2370. ((chat, mainState) => {
  2371. const { getConfig } = mainState,
  2372. data = chat.getData(getConfig)
  2373. return external_m_default()(
  2374. "span",
  2375. {
  2376. style: {
  2377. fontSize: `${getChatFontSize(mainState)}px`,
  2378. visibility: getConfig.displayChats()
  2379. ? "visible"
  2380. : "hidden",
  2381. color:
  2382. "owner" === data.authorType
  2383. ? getConfig.ownerColor()
  2384. : "moderator" === data.authorType
  2385. ? getConfig.moderatorColor()
  2386. : "member" === data.authorType
  2387. ? getConfig.memberColor()
  2388. : getConfig.color(),
  2389. fontWeight: getConfig.fontWeight().toString(),
  2390. fontFamily: getConfig.font(),
  2391. opacity: getConfig.chatOpacity().toString(),
  2392. textShadow: textShadow(getConfig.shadowColor())(
  2393. getConfig.shadowFontWeight()
  2394. ),
  2395. },
  2396. },
  2397. function_pipe(
  2398. [
  2399. function_pipe(
  2400. data.authorName,
  2401. filter(x => x.visible),
  2402. es6_Option_map(x =>
  2403. external_m_default()(
  2404. "span",
  2405. {
  2406. style: {
  2407. color: toUndefined(data.textColor),
  2408. fontSize: "0.84em",
  2409. ...textStyle,
  2410. },
  2411. },
  2412. `${x.content}: `
  2413. )
  2414. )
  2415. ),
  2416. function_pipe(
  2417. data.messageElement,
  2418. es6_Option_map(x =>
  2419. ((message, getConfig) => {
  2420. const eleWin =
  2421. message.ownerDocument.defaultView ?? window,
  2422. maxChatLength = getConfig.maxChatLength()
  2423. return function_pipe(
  2424. Array.from(message.childNodes),
  2425. es6_ReadonlyArray_reduce(
  2426. { vnodes: [], length: 0 },
  2427. ({ vnodes, length }, node) => {
  2428. return length >= maxChatLength
  2429. ? { vnodes, length }
  2430. : !getConfig.textOnly() &&
  2431. node instanceof eleWin.HTMLImageElement
  2432. ? {
  2433. vnodes: [
  2434. ...vnodes,
  2435. external_m_default()("img", {
  2436. style: {
  2437. height: "1em",
  2438. width: "1em",
  2439. verticalAlign: "text-top",
  2440. },
  2441. src: node.src,
  2442. alt: node.alt,
  2443. }),
  2444. ],
  2445. length: length + 1,
  2446. }
  2447. : function_pipe(
  2448. node.textContent ?? "",
  2449. ((end = maxChatLength),
  2450. function (s) {
  2451. return s.slice(0, end)
  2452. }),
  2453. x =>
  2454. node instanceof
  2455. eleWin.HTMLAnchorElement
  2456. ? {
  2457. vnodes: [
  2458. ...vnodes,
  2459. external_m_default()(
  2460. "span",
  2461. {
  2462. style: {
  2463. fontSize: "0.84em",
  2464. textDecoration:
  2465. "underline",
  2466. ...textStyle,
  2467. },
  2468. },
  2469. x
  2470. ),
  2471. ],
  2472. length: length + x.length,
  2473. }
  2474. : {
  2475. vnodes: [
  2476. ...vnodes,
  2477. external_m_default().fragment(
  2478. {},
  2479. x
  2480. ),
  2481. ],
  2482. length: length + x.length,
  2483. }
  2484. )
  2485. var end
  2486. }
  2487. )
  2488. )
  2489. })(x, getConfig)
  2490. ),
  2491. es6_Option_map(x =>
  2492. external_m_default()(
  2493. "span",
  2494. {
  2495. style: {
  2496. color: toUndefined(data.textColor),
  2497. ...textStyle,
  2498. },
  2499. },
  2500. x.vnodes
  2501. )
  2502. )
  2503. ),
  2504. function_pipe(
  2505. data.paymentInfo,
  2506. filter(x => x.visible),
  2507. es6_Option_map(x =>
  2508. external_m_default()(
  2509. "span",
  2510. {
  2511. style: {
  2512. color: toUndefined(data.paidColor),
  2513. fontSize: "0.84em",
  2514. ...textStyle,
  2515. },
  2516. },
  2517. external_m_default()(
  2518. "strong",
  2519. { style: textStyle },
  2520. x.content
  2521. )
  2522. )
  2523. )
  2524. ),
  2525. ],
  2526. ReadonlyArray_compact,
  2527. toArray
  2528. )
  2529. )
  2530. })(chat, mainState)
  2531. ),
  2532. external_window_hash_it_namespaceObject = window["hash-it"]
  2533. var external_window_hash_it_default = __webpack_require__.n(
  2534. external_window_hash_it_namespaceObject
  2535. )
  2536. const getLaneY = (lane, mainState) =>
  2537. mainState.playerRect.height *
  2538. ((lane / mainState.getConfig.laneCount() + 0.005) *
  2539. (mainState.getConfig.flowY2() - mainState.getConfig.flowY1()) +
  2540. mainState.getConfig.flowY1()),
  2541. setChatPlayState = chat => mainState =>
  2542. function_pipe(
  2543. chat,
  2544. fromPredicate(x => !x.animationEnded),
  2545. fromOption,
  2546. IOOption_chain(
  2547. (function (f) {
  2548. return function () {
  2549. for (var a = [], _i = 0; _i < arguments.length; _i++)
  2550. a[_i] = arguments[_i]
  2551. return fromOption(f.apply(void 0, a))
  2552. }
  2553. })(x => x.animation)
  2554. ),
  2555. IOOption_chainFirst(x =>
  2556. IOOption_fromIO(
  2557. mainState.chatPlaying ? () => x.play() : () => x.pause()
  2558. )
  2559. ),
  2560. IOOption_chain(x =>
  2561. IOOption_fromIO(() => {
  2562. x.playbackRate = mainState.getConfig.flowSpeed() / 15
  2563. })
  2564. )
  2565. ),
  2566. getWidth = external_window_micro_memoize_default()(
  2567. ele => ele?.getBoundingClientRect().width ?? 0,
  2568. {
  2569. maxSize: 2e3,
  2570. transformKey: function_flow(
  2571. es6_ReadonlyArray_map(external_window_hash_it_default()),
  2572. toArray
  2573. ),
  2574. }
  2575. ),
  2576. setChatAnimation = (chat, chats) => mainState =>
  2577. function_pipe(
  2578. { fontSize: getChatFontSize(mainState) },
  2579. IO_of,
  2580. IO_chainFirst(x => () => {
  2581. chat.element.style.transform = `translate(${
  2582. mainState.playerRect.width *
  2583. (mainState.getConfig.flowX2() - mainState.getConfig.flowX1())
  2584. }px, -${2 * x.fontSize}px)`
  2585. }),
  2586. IOOption_fromIO,
  2587. IOOption_filter(() => !chat.animationEnded),
  2588. IOOption_chainFirst(x =>
  2589. IOOption_fromIO(() => {
  2590. chat.animationDuration = 6400
  2591. chat.width = getWidth(chat.element.firstElementChild)
  2592. chat.height = x.fontSize
  2593. })
  2594. ),
  2595. IOOption_map(() => ({ progress: getFlowChatProgress(chat) })),
  2596. IOOption_map(x => ({
  2597. ...x,
  2598. ...getChatLane(chat, x.progress, chats)(mainState),
  2599. })),
  2600. IOOption_chain(ctx =>
  2601. intervalTooSmall(ctx.interval)(mainState.getConfig)
  2602. ? function_pipe(
  2603. chat.animation,
  2604. fromOption,
  2605. IOOption_chain(x =>
  2606. IOOption_fromIO(() => {
  2607. x.finish()
  2608. chat.animation = Option_none
  2609. })
  2610. ),
  2611. es6_IO_map(() => Option_none)
  2612. )
  2613. : IOOption_some(ctx)
  2614. ),
  2615. IOOption_chainFirst(x =>
  2616. IOOption_fromIO(() => {
  2617. chat.lane = x.lane
  2618. })
  2619. ),
  2620. IOOption_map(x => ({
  2621. ...x,
  2622. laneY: getLaneY(chat.lane, mainState),
  2623. })),
  2624. IOOption_chain(ctx =>
  2625. function_pipe(
  2626. [
  2627. function_pipe(
  2628. chat.animation,
  2629. fromOption,
  2630. IOOption_chain(x => IOOption_fromIO(() => x.cancel()))
  2631. ),
  2632. function_pipe(
  2633. [
  2634. [
  2635. mainState.playerRect.width *
  2636. (mainState.getConfig.flowX2() -
  2637. mainState.getConfig.flowX1()),
  2638. ctx.laneY,
  2639. ],
  2640. [-chat.width, ctx.laneY],
  2641. ],
  2642. es6_ReadonlyArray_map(
  2643. es6_ReadonlyArray_map(x => `${x}px`)
  2644. ),
  2645. es6_ReadonlyArray_map(
  2646. ([x, y]) => `translate(${x}, ${y})`
  2647. ),
  2648. ReadonlyArray_bindTo("transform"),
  2649. toArray,
  2650. x =>
  2651. chat.element.animate(x, {
  2652. duration: 6400,
  2653. easing: mainState.getConfig.timingFunction(),
  2654. }),
  2655. x => {
  2656. x.onfinish = () => {
  2657. chat.animationEnded = !0
  2658. }
  2659. chat.y = ctx.laneY
  2660. const newTime = 6400 * ctx.progress
  2661. x.currentTime = newTime
  2662. return x
  2663. },
  2664. Option_some,
  2665. x => () => {
  2666. chat.animation = x
  2667. },
  2668. IO_apSecond(setChatPlayState(chat)(mainState))
  2669. ),
  2670. ],
  2671. IO_sequenceArray,
  2672. IOOption_fromIO
  2673. )
  2674. ),
  2675. es6_IO_map(Option_isSome)
  2676. ),
  2677. emptyElement = document.createElement("span")
  2678. var Monoid_concatAll = function (M) {
  2679. return (function (M) {
  2680. return function (startWith) {
  2681. return function (as) {
  2682. return as.reduce(function (a, acc) {
  2683. return M.concat(a, acc)
  2684. }, startWith)
  2685. }
  2686. }
  2687. })(M)(M.empty)
  2688. },
  2689. MonoidAny = {
  2690. concat: function (first, second) {
  2691. return first || second
  2692. },
  2693. empty: !1,
  2694. }
  2695. const operators = {
  2696. flip: x => b => a => x(a)(b),
  2697. flow: fns => function_flow(...fns),
  2698. and: Monoid_concatAll({
  2699. concat: function (first, second) {
  2700. return first && second
  2701. },
  2702. empty: !0,
  2703. }),
  2704. or: Monoid_concatAll(MonoidAny),
  2705. RA: {
  2706. some: function (predicate) {
  2707. return function (as) {
  2708. return as.some(predicate)
  2709. }
  2710. },
  2711. compact: ReadonlyArray_compact,
  2712. },
  2713. O: {
  2714. exists: function (predicate) {
  2715. return function (ma) {
  2716. return !Option_isNone(ma) && predicate(ma.value)
  2717. }
  2718. },
  2719. },
  2720. allPreds: Monoid_concatAll({
  2721. concat: function (first, second) {
  2722. return function_pipe(
  2723. first,
  2724. (function (second) {
  2725. return function (first) {
  2726. return function (a) {
  2727. return first(a) && second(a)
  2728. }
  2729. }
  2730. })(second)
  2731. )
  2732. },
  2733. empty: constTrue,
  2734. }),
  2735. anyPreds: Monoid_concatAll({
  2736. concat: function (first, second) {
  2737. return function_pipe(
  2738. first,
  2739. (function (second) {
  2740. return function (first) {
  2741. return function (a) {
  2742. return first(a) || second(a)
  2743. }
  2744. }
  2745. })(second)
  2746. )
  2747. },
  2748. empty: constFalse,
  2749. }),
  2750. inText: text => x => text.content.includes(x),
  2751. eqText: text => x => text.content === x,
  2752. matchedByText: text => x =>
  2753. Boolean(text.content.match(RegExp(x, "u"))),
  2754. isVisible: x => x.visible,
  2755. },
  2756. assert_lib = check.assert,
  2757. tapNonNull = x => {
  2758. assert_lib(null != x)
  2759. return x
  2760. },
  2761. onChatFieldMutate = (
  2762. chatScrn,
  2763. flowChats,
  2764. mainState,
  2765. setConfig,
  2766. mainLog
  2767. ) => {
  2768. return function_flow(
  2769. ((f = e => Array.from(e.addedNodes)),
  2770. function (ma) {
  2771. return function_pipe(
  2772. ma,
  2773. (function (f) {
  2774. return function (as) {
  2775. if (
  2776. (function (as) {
  2777. return 0 === as.length
  2778. })(as)
  2779. )
  2780. return ReadonlyArray_empty
  2781. for (var out = [], i = 0; i < as.length; i++)
  2782. out.push.apply(out, f(0, as[i]))
  2783. return out
  2784. }
  2785. })(function (_, a) {
  2786. return f(a)
  2787. })
  2788. )
  2789. }),
  2790. es6_ReadonlyArray_filter(x => x.children.length > 0),
  2791. ReadonlyArray_reverse,
  2792. es6_ReadonlyArray_map(chat => () => {
  2793. const getData = (chat => {
  2794. const chatType = chat.querySelector(
  2795. ".yt-live-chat-ticker-paid-message-item-renderer"
  2796. )
  2797. ? "ticker"
  2798. : chat.querySelector(
  2799. ".yt-live-chat-membership-item-renderer"
  2800. )
  2801. ? "membership"
  2802. : chat.querySelector(
  2803. ".yt-live-chat-viewer-engagement-message-renderer"
  2804. )
  2805. ? "engagement"
  2806. : "normal",
  2807. isPaid =
  2808. "ticker" === chatType ||
  2809. Boolean(chat.querySelector("#card")),
  2810. paymentInfo = function_pipe(
  2811. fromNullable(
  2812. isPaid
  2813. ? chat.querySelector(
  2814. [
  2815. "#purchase-amount",
  2816. "#purchase-amount-chip",
  2817. "#content>#text",
  2818. ].join(",")
  2819. )?.textContent
  2820. : void 0
  2821. ),
  2822. es6_Option_map(x => ({ visible: !0, content: x }))
  2823. ),
  2824. authorType = chat.querySelector(".owner")
  2825. ? "owner"
  2826. : chat.querySelector(".moderator")
  2827. ? "moderator"
  2828. : chat.querySelector(".member")
  2829. ? "member"
  2830. : "normal",
  2831. messageElement = fromNullable(
  2832. chat.querySelector("#message")
  2833. ),
  2834. isPaidNormal =
  2835. !!Option_isSome(paymentInfo) &&
  2836. Boolean(
  2837. chat.querySelector(
  2838. ".yt-live-chat-paid-message-renderer"
  2839. )
  2840. ),
  2841. isPaidSticker =
  2842. !(!Option_isSome(paymentInfo) || isPaidNormal) &&
  2843. Boolean(
  2844. chat.querySelector(
  2845. ".yt-live-chat-paid-sticker-renderer"
  2846. )
  2847. ),
  2848. textColor = fromNullable(
  2849. isPaidNormal
  2850. ? window
  2851. .getComputedStyle(
  2852. tapNonNull(chat.querySelector("#header"))
  2853. )
  2854. .getPropertyValue("background-color")
  2855. : isPaidSticker
  2856. ? window
  2857. .getComputedStyle(chat)
  2858. .getPropertyValue(
  2859. "--yt-live-chat-paid-sticker-chip-background-color"
  2860. )
  2861. : void 0
  2862. ),
  2863. paidColor = fromNullable(
  2864. isPaidNormal
  2865. ? window
  2866. .getComputedStyle(
  2867. tapNonNull(chat.querySelector("#content"))
  2868. )
  2869. .getPropertyValue("background-color")
  2870. : isPaidSticker
  2871. ? window
  2872. .getComputedStyle(chat)
  2873. .getPropertyValue(
  2874. "--yt-live-chat-paid-sticker-background-color"
  2875. )
  2876. : void 0
  2877. ),
  2878. authorPhotoMatches = chat
  2879. .querySelector(["#author-photo", "img"].join(" "))
  2880. ?.src.match(/ytc\/(.*)=/),
  2881. authorID = fromNullable(
  2882. authorPhotoMatches?.[authorPhotoMatches.length - 1]
  2883. ),
  2884. authorName = fromNullable(
  2885. chat.querySelector("#author-name")?.textContent
  2886. ),
  2887. message = function_pipe(
  2888. messageElement,
  2889. es6_Option_map(x => ({
  2890. visible: !0,
  2891. content: x.innerHTML,
  2892. }))
  2893. ),
  2894. messageText = function_pipe(
  2895. messageElement,
  2896. es6_Option_map(x => ({
  2897. visible: !0,
  2898. content: x.textContent ?? "",
  2899. }))
  2900. )
  2901. return getConfig => ({
  2902. chatType,
  2903. authorType,
  2904. authorID,
  2905. authorName: function_pipe(
  2906. authorName,
  2907. es6_Option_map(x => ({
  2908. visible:
  2909. ("moderator" === authorType &&
  2910. getConfig.displayModName()) ||
  2911. (Option_isSome(paymentInfo) &&
  2912. getConfig.displaySuperChatAuthor()),
  2913. content: x,
  2914. }))
  2915. ),
  2916. messageElement,
  2917. message,
  2918. messageText,
  2919. paymentInfo,
  2920. textColor,
  2921. paidColor,
  2922. })
  2923. })(chat),
  2924. { getConfig } = mainState,
  2925. data = getData(getConfig)
  2926. ;(((data, mainState, mainLog) =>
  2927. function_pipe(
  2928. data,
  2929. fromPredicate(() =>
  2930. function_pipe(
  2931. mainState.filterExp,
  2932. es6_Option_map(x =>
  2933. a(
  2934. x,
  2935. (data => ({
  2936. ...operators,
  2937. authorName: data.authorName,
  2938. message: data.message,
  2939. messageText: data.messageText,
  2940. paymentInfo: data.paymentInfo,
  2941. authorID: function_pipe(
  2942. data.authorID,
  2943. es6_Option_map(x => ({
  2944. visible: !1,
  2945. content: x,
  2946. }))
  2947. ),
  2948. }))(data)
  2949. )
  2950. ),
  2951. getOrElse(() => !1)
  2952. )
  2953. ),
  2954. es6_Option_map(x => [
  2955. function_pipe(
  2956. x.message,
  2957. es6_Option_map(m => m.content)
  2958. ),
  2959. function_pipe(
  2960. x.paymentInfo,
  2961. es6_Option_map(p => p.content)
  2962. ),
  2963. ]),
  2964. es6_Option_map(es6_ReadonlyArray_map(getOrElse(() => ""))),
  2965. es6_Option_map(JSON.stringify),
  2966. es6_Option_map(x => mainLog([`Banned: ${x}`])),
  2967. match(
  2968. () => () => !1,
  2969. es6_IO_map(() => !0)
  2970. )
  2971. )())(data, mainState, mainLog)
  2972. ? () => {
  2973. chat.style.display = "none"
  2974. }
  2975. : function_pipe(
  2976. [
  2977. function_pipe(
  2978. void 0,
  2979. fromPredicate(getConfig.createChats),
  2980. filter(() => "normal" === data.chatType),
  2981. fromOption,
  2982. IOOption_chain(() =>
  2983. IOOption_fromIO(
  2984. ((getData, flowChats, chatScrn, mainState) =>
  2985. function_pipe(
  2986. {
  2987. getData,
  2988. element: emptyElement,
  2989. lane: -1,
  2990. animation: Option_none,
  2991. animationDuration: 0,
  2992. animationEnded: !1,
  2993. width: 2,
  2994. height: getChatFontSize(mainState),
  2995. y: 0,
  2996. },
  2997. x =>
  2998. getChatLane(x, 0, flowChats)(mainState)
  2999. .interval,
  3000. intervalTooSmall,
  3001. x => x(mainState.getConfig)
  3002. )
  3003. ? () => {}
  3004. : () => {
  3005. const offScreenIndex = function_pipe(
  3006. flowChats,
  3007. findIndex(
  3008. chat =>
  3009. chat.animationEnded ||
  3010. flowChats.length >=
  3011. mainState.getConfig.maxChatCount()
  3012. )
  3013. ),
  3014. element = function_pipe(
  3015. offScreenIndex,
  3016. es6_Option_map(
  3017. x => flowChats[x].element
  3018. ),
  3019. getOrElseW(() =>
  3020. document.createElement("span")
  3021. )
  3022. )
  3023. function_pipe(
  3024. offScreenIndex,
  3025. match(
  3026. () => () => {
  3027. external_log_default().debug(
  3028. "CreateFlowChat"
  3029. )
  3030. chatScrn.append(element)
  3031. },
  3032. i =>
  3033. function_pipe(
  3034. () =>
  3035. flowChats.splice(i, 1)[0]
  3036. .animation,
  3037. IOOption_chain(oldAnimation =>
  3038. IOOption_fromIO(() =>
  3039. oldAnimation.cancel()
  3040. )
  3041. )
  3042. )
  3043. )
  3044. )()
  3045. const flowChat = {
  3046. getData,
  3047. element,
  3048. lane: -1,
  3049. animation: Option_none,
  3050. animationDuration: 0,
  3051. animationEnded: !1,
  3052. width: 2,
  3053. height: getChatFontSize(mainState),
  3054. y: 0,
  3055. }
  3056. element.classList.add("fyc_chat")
  3057. function_pipe(
  3058. mainState,
  3059. IO_of,
  3060. IO_chainFirst(renderChat(flowChat)),
  3061. es6_IO_chain(
  3062. setChatAnimation(flowChat, flowChats)
  3063. ),
  3064. es6_IO_chain(x =>
  3065. x
  3066. ? () => flowChats.push(flowChat)
  3067. : () => flowChat.element.remove()
  3068. )
  3069. )()
  3070. })(getData, flowChats, chatScrn, mainState)
  3071. )
  3072. )
  3073. ),
  3074. function_pipe(
  3075. data.authorID,
  3076. fromOption,
  3077. IOOption_filter(getConfig.createBanButton),
  3078. IOOption_chain(x =>
  3079. IOOption_fromIO(
  3080. addBanButton(chat, x, getConfig, setConfig)
  3081. )
  3082. ),
  3083. es6_IO_map(() => Option_some(void 0)),
  3084. IOOption_filter(getConfig.simplifyChatField),
  3085. IOOption_chain(() =>
  3086. IOOption_fromIO(
  3087. (chat =>
  3088. chat.querySelector(
  3089. ".style-scope.yt-live-chat-paid-message-renderer"
  3090. )
  3091. ? () => {}
  3092. : function_pipe(
  3093. [
  3094. "#author-photo",
  3095. "yt-live-chat-author-chip.style-scope.yt-live-chat-text-message-renderer",
  3096. ],
  3097. es6_ReadonlyArray_map(x =>
  3098. fromNullable(chat.querySelector(x))
  3099. ),
  3100. ReadonlyArray_compact,
  3101. es6_ReadonlyArray_map(x => () => {
  3102. x.style.display = "none"
  3103. }),
  3104. ReadonlyArray_append(() => {
  3105. chat.style.borderBottom =
  3106. "1px solid var(--yt-spec-text-secondary)"
  3107. }),
  3108. IO_sequenceArray
  3109. ))(chat)
  3110. )
  3111. )
  3112. ),
  3113. ],
  3114. IO_sequenceArray
  3115. ))()
  3116. }),
  3117. IO_sequenceArray
  3118. )
  3119. var f
  3120. },
  3121. removeOldChats = maxChatCount => flowChats =>
  3122. function_pipe(
  3123. () =>
  3124. flowChats.sort((a, b) =>
  3125. a.animationEnded === b.animationEnded
  3126. ? 0
  3127. : a.animationEnded
  3128. ? -1
  3129. : 1
  3130. ),
  3131. IO_apSecond(() =>
  3132. flowChats.splice(
  3133. 0,
  3134. Math.max(0, flowChats.length - maxChatCount)
  3135. )
  3136. ),
  3137. es6_IO_chain(
  3138. removed => () =>
  3139. removed.forEach(x => {
  3140. external_log_default().debug("RemoveChat")
  3141. x.element.remove()
  3142. })
  3143. )
  3144. )
  3145. var EMPTY_OBJ = {},
  3146. EMPTY_ARR = [],
  3147. hyperapp_id = a => a,
  3148. hyperapp_map = EMPTY_ARR.map,
  3149. isArray = Array.isArray,
  3150. enqueue =
  3151. "undefined" != typeof requestAnimationFrame
  3152. ? requestAnimationFrame
  3153. : setTimeout,
  3154. createClass = obj => {
  3155. var out = ""
  3156. if ("string" == typeof obj) return obj
  3157. if (isArray(obj))
  3158. for (var tmp, k = 0; k < obj.length; k++)
  3159. (tmp = createClass(obj[k])) && (out += (out && " ") + tmp)
  3160. else for (var k in obj) obj[k] && (out += (out && " ") + k)
  3161. return out
  3162. },
  3163. shouldRestart = (a, b) => {
  3164. for (var k in { ...a, ...b })
  3165. if ("function" == typeof (isArray(a[k]) ? a[k][0] : a[k]))
  3166. b[k] = a[k]
  3167. else if (a[k] !== b[k]) return !0
  3168. },
  3169. getKey = vdom => (null == vdom ? vdom : vdom.key),
  3170. patchProperty = (node, key, oldValue, newValue, listener, isSvg) => {
  3171. if ("key" === key);
  3172. else if ("style" === key)
  3173. for (var k in { ...oldValue, ...newValue }) {
  3174. oldValue =
  3175. null == newValue || null == newValue[k] ? "" : newValue[k]
  3176. "-" === k[0]
  3177. ? node[key].setProperty(k, oldValue)
  3178. : (node[key][k] = oldValue)
  3179. }
  3180. else
  3181. "o" === key[0] && "n" === key[1]
  3182. ? ((node.events || (node.events = {}))[(key = key.slice(2))] =
  3183. newValue)
  3184. ? oldValue || node.addEventListener(key, listener)
  3185. : node.removeEventListener(key, listener)
  3186. : !isSvg && "list" !== key && "form" !== key && key in node
  3187. ? (node[key] = newValue ?? "")
  3188. : null == newValue ||
  3189. !1 === newValue ||
  3190. ("class" === key && !(newValue = createClass(newValue)))
  3191. ? node.removeAttribute(key)
  3192. : node.setAttribute(key, newValue)
  3193. },
  3194. createNode = (vdom, listener, isSvg) => {
  3195. var props = vdom.props,
  3196. node =
  3197. 3 === vdom.type
  3198. ? document.createTextNode(vdom.tag)
  3199. : (isSvg = isSvg || "svg" === vdom.tag)
  3200. ? document.createElementNS(
  3201. "http://www.w3.org/2000/svg",
  3202. vdom.tag,
  3203. { is: props.is }
  3204. )
  3205. : document.createElement(vdom.tag, { is: props.is })
  3206. for (var k in props)
  3207. patchProperty(node, k, null, props[k], listener, isSvg)
  3208. for (var i = 0; i < vdom.children.length; i++)
  3209. node.appendChild(
  3210. createNode(
  3211. (vdom.children[i] = maybeVNode(vdom.children[i])),
  3212. listener,
  3213. isSvg
  3214. )
  3215. )
  3216. return (vdom.node = node)
  3217. },
  3218. patch = (parent, node, oldVNode, newVNode, listener, isSvg) => {
  3219. if (oldVNode === newVNode);
  3220. else if (
  3221. null != oldVNode &&
  3222. 3 === oldVNode.type &&
  3223. 3 === newVNode.type
  3224. )
  3225. oldVNode.tag !== newVNode.tag && (node.nodeValue = newVNode.tag)
  3226. else if (null == oldVNode || oldVNode.tag !== newVNode.tag) {
  3227. node = parent.insertBefore(
  3228. createNode((newVNode = maybeVNode(newVNode)), listener, isSvg),
  3229. node
  3230. )
  3231. null != oldVNode && parent.removeChild(oldVNode.node)
  3232. } else {
  3233. var tmpVKid,
  3234. oldVKid,
  3235. oldKey,
  3236. newKey,
  3237. oldProps = oldVNode.props,
  3238. newProps = newVNode.props,
  3239. oldVKids = oldVNode.children,
  3240. newVKids = newVNode.children,
  3241. oldHead = 0,
  3242. newHead = 0,
  3243. oldTail = oldVKids.length - 1,
  3244. newTail = newVKids.length - 1
  3245. isSvg = isSvg || "svg" === newVNode.tag
  3246. for (var i in { ...oldProps, ...newProps })
  3247. ("value" === i || "selected" === i || "checked" === i
  3248. ? node[i]
  3249. : oldProps[i]) !== newProps[i] &&
  3250. patchProperty(
  3251. node,
  3252. i,
  3253. oldProps[i],
  3254. newProps[i],
  3255. listener,
  3256. isSvg
  3257. )
  3258. for (
  3259. ;
  3260. newHead <= newTail &&
  3261. oldHead <= oldTail &&
  3262. null != (oldKey = getKey(oldVKids[oldHead])) &&
  3263. oldKey === getKey(newVKids[newHead]);
  3264.  
  3265. )
  3266. patch(
  3267. node,
  3268. oldVKids[oldHead].node,
  3269. oldVKids[oldHead],
  3270. (newVKids[newHead] = maybeVNode(
  3271. newVKids[newHead++],
  3272. oldVKids[oldHead++]
  3273. )),
  3274. listener,
  3275. isSvg
  3276. )
  3277. for (
  3278. ;
  3279. newHead <= newTail &&
  3280. oldHead <= oldTail &&
  3281. null != (oldKey = getKey(oldVKids[oldTail])) &&
  3282. oldKey === getKey(newVKids[newTail]);
  3283.  
  3284. )
  3285. patch(
  3286. node,
  3287. oldVKids[oldTail].node,
  3288. oldVKids[oldTail],
  3289. (newVKids[newTail] = maybeVNode(
  3290. newVKids[newTail--],
  3291. oldVKids[oldTail--]
  3292. )),
  3293. listener,
  3294. isSvg
  3295. )
  3296. if (oldHead > oldTail)
  3297. for (; newHead <= newTail; )
  3298. node.insertBefore(
  3299. createNode(
  3300. (newVKids[newHead] = maybeVNode(newVKids[newHead++])),
  3301. listener,
  3302. isSvg
  3303. ),
  3304. (oldVKid = oldVKids[oldHead]) && oldVKid.node
  3305. )
  3306. else if (newHead > newTail)
  3307. for (; oldHead <= oldTail; )
  3308. node.removeChild(oldVKids[oldHead++].node)
  3309. else {
  3310. var keyed = {},
  3311. newKeyed = {}
  3312. for (i = oldHead; i <= oldTail; i++)
  3313. null != (oldKey = oldVKids[i].key) &&
  3314. (keyed[oldKey] = oldVKids[i])
  3315. for (; newHead <= newTail; ) {
  3316. oldKey = getKey((oldVKid = oldVKids[oldHead]))
  3317. newKey = getKey(
  3318. (newVKids[newHead] = maybeVNode(newVKids[newHead], oldVKid))
  3319. )
  3320. if (
  3321. newKeyed[oldKey] ||
  3322. (null != newKey && newKey === getKey(oldVKids[oldHead + 1]))
  3323. ) {
  3324. null == oldKey && node.removeChild(oldVKid.node)
  3325. oldHead++
  3326. } else if (null == newKey || 1 === oldVNode.type) {
  3327. if (null == oldKey) {
  3328. patch(
  3329. node,
  3330. oldVKid && oldVKid.node,
  3331. oldVKid,
  3332. newVKids[newHead],
  3333. listener,
  3334. isSvg
  3335. )
  3336. newHead++
  3337. }
  3338. oldHead++
  3339. } else {
  3340. if (oldKey === newKey) {
  3341. patch(
  3342. node,
  3343. oldVKid.node,
  3344. oldVKid,
  3345. newVKids[newHead],
  3346. listener,
  3347. isSvg
  3348. )
  3349. newKeyed[newKey] = !0
  3350. oldHead++
  3351. } else if (null != (tmpVKid = keyed[newKey])) {
  3352. patch(
  3353. node,
  3354. node.insertBefore(
  3355. tmpVKid.node,
  3356. oldVKid && oldVKid.node
  3357. ),
  3358. tmpVKid,
  3359. newVKids[newHead],
  3360. listener,
  3361. isSvg
  3362. )
  3363. newKeyed[newKey] = !0
  3364. } else
  3365. patch(
  3366. node,
  3367. oldVKid && oldVKid.node,
  3368. null,
  3369. newVKids[newHead],
  3370. listener,
  3371. isSvg
  3372. )
  3373. newHead++
  3374. }
  3375. }
  3376. for (; oldHead <= oldTail; )
  3377. null == getKey((oldVKid = oldVKids[oldHead++])) &&
  3378. node.removeChild(oldVKid.node)
  3379. for (var i in keyed)
  3380. null == newKeyed[i] && node.removeChild(keyed[i].node)
  3381. }
  3382. }
  3383. return (newVNode.node = node)
  3384. },
  3385. maybeVNode = (newVNode, oldVNode) =>
  3386. !0 !== newVNode && !1 !== newVNode && newVNode
  3387. ? "function" == typeof newVNode.tag
  3388. ? ((!oldVNode ||
  3389. null == oldVNode.memo ||
  3390. ((a, b) => {
  3391. for (var k in a) if (a[k] !== b[k]) return !0
  3392. for (var k in b) if (a[k] !== b[k]) return !0
  3393. })(oldVNode.memo, newVNode.memo)) &&
  3394. ((oldVNode = newVNode.tag(newVNode.memo)).memo =
  3395. newVNode.memo),
  3396. oldVNode)
  3397. : newVNode
  3398. : hyperapp_text(""),
  3399. recycleNode = node =>
  3400. 3 === node.nodeType
  3401. ? hyperapp_text(node.nodeValue, node)
  3402. : createVNode(
  3403. node.nodeName.toLowerCase(),
  3404. EMPTY_OBJ,
  3405. hyperapp_map.call(node.childNodes, recycleNode),
  3406. 1,
  3407. node
  3408. ),
  3409. createVNode = (tag, props, children, type, node) => ({
  3410. tag,
  3411. props,
  3412. key: props.key,
  3413. children,
  3414. type,
  3415. node,
  3416. }),
  3417. hyperapp_text = (value, node) =>
  3418. createVNode(value, EMPTY_OBJ, EMPTY_ARR, 3, node),
  3419. h = (tag, props, children = EMPTY_ARR) =>
  3420. createVNode(tag, props, isArray(children) ? children : [children]),
  3421. app = ({
  3422. node,
  3423. view,
  3424. subscriptions,
  3425. dispatch = hyperapp_id,
  3426. init = EMPTY_OBJ,
  3427. }) => {
  3428. var state,
  3429. busy,
  3430. vdom = node && recycleNode(node),
  3431. subs = [],
  3432. update = newState => {
  3433. if (state !== newState) {
  3434. null == (state = newState) &&
  3435. (dispatch = subscriptions = render = hyperapp_id)
  3436. subscriptions &&
  3437. (subs = ((oldSubs, newSubs = EMPTY_ARR, dispatch) => {
  3438. for (
  3439. var oldSub, newSub, subs = [], i = 0;
  3440. i < oldSubs.length || i < newSubs.length;
  3441. i++
  3442. ) {
  3443. oldSub = oldSubs[i]
  3444. newSub = newSubs[i]
  3445. subs.push(
  3446. newSub && !0 !== newSub
  3447. ? !oldSub ||
  3448. newSub[0] !== oldSub[0] ||
  3449. shouldRestart(newSub[1], oldSub[1])
  3450. ? [
  3451. newSub[0],
  3452. newSub[1],
  3453. (oldSub && oldSub[2](),
  3454. newSub[0](dispatch, newSub[1])),
  3455. ]
  3456. : oldSub
  3457. : oldSub && oldSub[2]()
  3458. )
  3459. }
  3460. return subs
  3461. })(subs, subscriptions(state), dispatch))
  3462. view && !busy && enqueue(render, (busy = !0))
  3463. }
  3464. },
  3465. render = () =>
  3466. (node = patch(
  3467. node.parentNode,
  3468. node,
  3469. vdom,
  3470. (vdom = view(state)),
  3471. listener,
  3472. (busy = !1)
  3473. )),
  3474. listener = function (event) {
  3475. dispatch(this.events[event.type], event)
  3476. }
  3477. return (
  3478. (dispatch = dispatch((action, props) =>
  3479. "function" == typeof action
  3480. ? dispatch(action(state, props))
  3481. : isArray(action)
  3482. ? "function" == typeof action[0]
  3483. ? dispatch(action[0], action[1])
  3484. : action
  3485. .slice(1)
  3486. .map(
  3487. fx => fx && !0 !== fx && fx[0](dispatch, fx[1]),
  3488. update(action[0])
  3489. )
  3490. : update(action)
  3491. ))(init),
  3492. dispatch
  3493. )
  3494. }
  3495. const src_defaultSettingText = {
  3496. setting: ["Settings", "設定"],
  3497. font: ["Font", "フォント"],
  3498. color: ["Color(Normal)", "色(通常)"],
  3499. ownerColor: ["Color(Owner)", "色(オーナー)"],
  3500. moderatorColor: ["Color(Moderator)", "色(モデレーター)"],
  3501. memberColor: ["Color(Member)", "色(メンバー)"],
  3502. feedback: ["Feedback", "バグ報告と要望"],
  3503. eventLog: ["Event log", "イベントログ"],
  3504. giveFeedback: [
  3505. "Give your feedbacks here(Please attach the event log if they're bug related)",
  3506. "バグ報告、要望はこちら(バグの場合は、イベントログを添付してください)",
  3507. ],
  3508. chatOpacity: ["Opacity", "不透明度"],
  3509. fontSize: ["Size", "サイズ"],
  3510. fontWeight: ["Weight", "太さ"],
  3511. shadowFontWeight: ["Weight(Shadow)", "太さ(影)"],
  3512. flowSpeed: ["Speed", "速度"],
  3513. maxChatCount: ["Max number of chats", "最大表示数"],
  3514. maxChatLength: ["Max number of characters", "最大文字数"],
  3515. laneCount: ["Number of rows", "行数"],
  3516. bannedWords: ["Banned Words", "NGワード"],
  3517. bannedWordRegexs: ["Banned Words(Regex)", "NGワード(正規表現)"],
  3518. bannedUsers: ["Banned Users", "NGユーザー"],
  3519. simplifyChatField: ["Simplify", "簡略化する"],
  3520. createBanButton: ["Show ban button", "NGボタンを表示する"],
  3521. displayModName: [
  3522. "Show moderator's name",
  3523. "モデレーターの名前を表示する",
  3524. ],
  3525. displaySuperChatAuthor: [
  3526. "Show super chat author",
  3527. "スパチャの作成者を表示する",
  3528. ],
  3529. createChats: ["Display flowing chats", "チャットを流す"],
  3530. textOnly: [
  3531. "Text only(ignore emojis)",
  3532. "文字のみ(絵文字を無視する)",
  3533. ],
  3534. error: ["Error", "エラー"],
  3535. video: ["Video", "画面"],
  3536. chatField: ["Chat Window", "チャット欄"],
  3537. useStepTiming: ["Move chat in steps", "チャットを段階的に動かす"],
  3538. timingStepCount: ["└Step Count", "└段階数"],
  3539. chatFilter: ["Chat Filter", "チャットフィルター"],
  3540. flowChat: ["Flow Chat", "チャット流れ"],
  3541. clearFlowChats: [
  3542. "Clear Flowing Chats",
  3543. "流れるチャットをクリアする",
  3544. ],
  3545. flowNewChatIf: [
  3546. "A new chat will appear if all of the followings are met:",
  3547. "新しいチャットは以下のすべてを満たす場合に流れます:",
  3548. ],
  3549. noOverlap: ["└Chats won't overlap", "└他のチャットと重ならない"],
  3550. minSpacing: ["Min spacing between chats", "チャットの最小間隔"],
  3551. fieldScale: ["Scale", "拡大率"],
  3552. copy: ["Copy", "コピーする"],
  3553. showChat: ["Show chats", "チャット非表示"],
  3554. hideChat: ["Hide chats", "チャット表示"],
  3555. flowY1: ["Flow area top edge", "流れ範囲の上端"],
  3556. flowY2: ["Flow area bottom edge", "流れ範囲の下端"],
  3557. flowX1: ["Flow area left edge", "流れ範囲の左端"],
  3558. flowX2: ["Flow area right edge", "流れ範囲の右端"],
  3559. shadowColor: ["Color(Shadow)", "色(影)"],
  3560. },
  3561. getLang = lang => key =>
  3562. src_defaultSettingText[key]["FYC_EN" === lang ? 0 : 1],
  3563. colorInput = action => color =>
  3564. h("input", {
  3565. style: { verticalAlign: "middle", width: "5.5em" },
  3566. maxlength: 20,
  3567. value: color,
  3568. ...action,
  3569. }),
  3570. colorPicker = action => color =>
  3571. h("input", {
  3572. style: { width: "36px", verticalAlign: "middle" },
  3573. type: "color",
  3574. value: color,
  3575. oninput: action.onchange,
  3576. }),
  3577. colorTextOutput = textStyle => color =>
  3578. h(
  3579. "span",
  3580. { style: { ...textStyle, color } },
  3581. hyperapp_text("Aa1あア亜")
  3582. ),
  3583. tapIs = (constructor, x) => {
  3584. assert_lib(x instanceof constructor)
  3585. return x
  3586. },
  3587. getValue = e => {
  3588. const target = e.currentTarget ?? e.__target
  3589. if (
  3590. target instanceof HTMLSelectElement ||
  3591. target instanceof HTMLTextAreaElement ||
  3592. target instanceof HTMLInputElement
  3593. )
  3594. return target.value
  3595. throw Error("Event target type isn't acceptable.")
  3596. },
  3597. ui_option = (value, label, selected) =>
  3598. h("option", { value, selected }, hyperapp_text(label)),
  3599. rangeRow = (min, max, step, value, editing, action) =>
  3600. h("div", {}, [
  3601. h("input", {
  3602. style: { width: "150px", verticalAlign: "middle" },
  3603. type: "range",
  3604. min,
  3605. max,
  3606. step,
  3607. value,
  3608. oninput: action.onchange,
  3609. }),
  3610. h("input", {
  3611. style: {
  3612. width: "30px",
  3613. backgroundColor: "transparent",
  3614. color: "inherit",
  3615. borderWidth: "1px",
  3616. verticalAlign: "middle",
  3617. },
  3618. inputmode: "decimal",
  3619. value: editing
  3620. ? value
  3621. : Number.parseFloat(value)
  3622. .toFixed(4)
  3623. .replace(/\.?0+$/, ""),
  3624. ...action,
  3625. }),
  3626. ]),
  3627. settingRow = (label, content) =>
  3628. h("div", {}, [
  3629. h("span", {}, hyperapp_text(label)),
  3630. h("div", {}, content),
  3631. ]),
  3632. tabContainer = (style, labels, tabs, mainTab, ontabSelect) =>
  3633. h("div", {}, [
  3634. h(
  3635. "div",
  3636. {},
  3637. function_pipe(
  3638. labels,
  3639. es6_ReadonlyArray_mapWithIndex((i, x) =>
  3640. h(
  3641. "span",
  3642. {
  3643. style: {
  3644. ...style.label,
  3645. ...(mainTab === i ? style.labelFocus : {}),
  3646. display: "inline-block",
  3647. },
  3648. onpointerdown: [ontabSelect, i],
  3649. },
  3650. hyperapp_text(x)
  3651. )
  3652. )
  3653. )
  3654. ),
  3655. h(
  3656. "div",
  3657. { style: { ...style.container, overflow: "hidden auto" } },
  3658. h(
  3659. "div",
  3660. { style: { ...style.tab } },
  3661. tabs.find((_, i) => i === mainTab)?.()
  3662. )
  3663. ),
  3664. ]),
  3665. style = {
  3666. resize: "horizontal",
  3667. boxSizing: "border-box",
  3668. width: "100%",
  3669. },
  3670. textAreaRow = (rows, value, action) =>
  3671. h("textarea", { rows, value, style, ...action }),
  3672. textColorRow = colorNodes =>
  3673. function_pipe(
  3674. colorNodes,
  3675. Reader_sequenceArray,
  3676. es6_Reader_map(x => h("div", {}, x))
  3677. ),
  3678. panelBoxStyle = width => ({ flex: `0 0 ${width}px`, margin: "2px" }),
  3679. textRowStyle = { width: "70%", boxSizing: "border-box" },
  3680. langs = [
  3681. ["FYC_EN", "English"],
  3682. ["FYC_JA", "日本語"],
  3683. ],
  3684. exampleTextStyle = s => ({
  3685. fontFamily: s.font,
  3686. fontWeight: s.fontWeight.toString(),
  3687. textShadow: textShadow(s.shadowColor)(s.shadowFontWeight),
  3688. }),
  3689. computed = {
  3690. useStepTiming: s => Boolean(s.timingFunction.match(/^steps\(.+/)),
  3691. },
  3692. stepTiming = stepCount => `steps(${stepCount}, jump-end)`,
  3693. settingPanel = command => {
  3694. const { setConfig, act } = command,
  3695. configFx = (k, v) => [() => setConfig[k](v), void 0],
  3696. setState = {
  3697. flowY1: (s, v) =>
  3698. function_pipe(Math.max(s.flowY2, v + 0.05), flowY2 => [
  3699. { ...s, flowY1: v, flowY2 },
  3700. configFx("flowY1", v),
  3701. configFx("flowY2", flowY2),
  3702. ]),
  3703. flowY2: (s, v) =>
  3704. function_pipe(Math.min(s.flowY1, v - 0.05), flowY1 => [
  3705. { ...s, flowY2: v, flowY1 },
  3706. configFx("flowY2", v),
  3707. configFx("flowY1", flowY1),
  3708. ]),
  3709. flowX1: (s, v) =>
  3710. function_pipe(Math.max(s.flowX2, v + 0.05), flowX2 => [
  3711. { ...s, flowX1: v, flowX2 },
  3712. configFx("flowX1", v),
  3713. configFx("flowX2", flowX2),
  3714. ]),
  3715. flowX2: (s, v) =>
  3716. function_pipe(Math.min(s.flowX1, v - 0.05), flowX1 => [
  3717. { ...s, flowX2: v, flowX1 },
  3718. configFx("flowX2", v),
  3719. configFx("flowX1", flowX1),
  3720. ]),
  3721. timingStepCount: (s, v) =>
  3722. function_pipe(stepTiming(v), timingFunction => [
  3723. { ...s, timingStepCount: v, timingFunction },
  3724. configFx("timingFunction", timingFunction),
  3725. ]),
  3726. bannedWordRegexs: (s, v) =>
  3727. function_pipe(
  3728. v,
  3729. es6_ReadonlyArray_reduce(
  3730. { valid: !0, error: "" },
  3731. (acc, cur) => {
  3732. try {
  3733. RegExp(cur, "u")
  3734. return acc
  3735. } catch (e) {
  3736. return {
  3737. valid: !1,
  3738. error: `${acc.error}${e} in ${cur};`,
  3739. }
  3740. }
  3741. }
  3742. ),
  3743. x => [
  3744. {
  3745. ...s,
  3746. bannedWordRegexs: v,
  3747. bannedWordRegexsError: x.error,
  3748. bannedWordRegexsValid: x.valid,
  3749. },
  3750. ...(x.valid ? [configFx("bannedWordRegexs", v)] : []),
  3751. ]
  3752. ),
  3753. },
  3754. setComputed = {
  3755. useStepTiming: (s, v) => {
  3756. const timingFunction = v
  3757. ? stepTiming(s.timingStepCount)
  3758. : "linear"
  3759. return [
  3760. { ...s, timingFunction },
  3761. configFx("timingFunction", timingFunction),
  3762. ]
  3763. },
  3764. },
  3765. doAct = {
  3766. copy: async s => {
  3767. GM.setClipboard(s.eventLog.join("\n"))
  3768. },
  3769. clearFlowChats: async s => {
  3770. act.clearFlowChats()
  3771. },
  3772. },
  3773. getTrueState = (k, s) => (k in computed ? computed[k](s) : s[k]),
  3774. getState = (k, s) =>
  3775. s.editingInput.id === k
  3776. ? s.editingInput.committedState
  3777. : getTrueState(k, s),
  3778. updateAt = (k, v, s) =>
  3779. k in setComputed
  3780. ? setComputed[k](s, v)
  3781. : k in setState
  3782. ? setState[k](s, v)
  3783. : [
  3784. { ...s, [k]: v },
  3785. ...(k in setConfig ? [configFx(k, v)] : []),
  3786. ],
  3787. updateString = key => (s, e) =>
  3788. function_pipe(getValue(e), x => updateAt(key, x, s)),
  3789. updateNumber = key => (s, e) =>
  3790. function_pipe(getValue(e), parseFloat, x =>
  3791. updateAt(key, x, s)
  3792. ),
  3793. updateInt = key => (s, e) =>
  3794. function_pipe(
  3795. getValue(e),
  3796. x => parseInt(x, 10),
  3797. x => updateAt(key, x, s)
  3798. ),
  3799. updateStrings = key => (s, e) =>
  3800. function_pipe(
  3801. getValue(e),
  3802. function_flow(
  3803. split(/\r\n|\n/),
  3804. es6_ReadonlyArray_filter(Predicate_not(string_isEmpty))
  3805. ),
  3806. x => updateAt(key, x, s)
  3807. ),
  3808. editAction = (key, onchange) => ({
  3809. onfocus: (s, e) =>
  3810. updateAt(
  3811. "editingInput",
  3812. {
  3813. id: key,
  3814. committedState: getTrueState(key, s),
  3815. value: getValue(e),
  3816. },
  3817. s
  3818. ),
  3819. onblur: s =>
  3820. updateAt(
  3821. "editingInput",
  3822. { id: "", committedState: "", value: "" },
  3823. s
  3824. ),
  3825. oninput: (s, e) =>
  3826. updateAt(
  3827. "editingInput",
  3828. {
  3829. id: key,
  3830. committedState: s.editingInput.committedState,
  3831. value: getValue(e),
  3832. },
  3833. s
  3834. ),
  3835. onchange: (s, e) => {
  3836. const [s1, ...es1] = onchange(key)(s, e),
  3837. x =
  3838. s1.editingInput.id === key
  3839. ? {
  3840. id: key,
  3841. committedState: getTrueState(key, s1),
  3842. value: getValue(e),
  3843. }
  3844. : s1.editingInput,
  3845. [s2, ...es2] = updateAt("editingInput", x, s1)
  3846. return [s2, ...es1, ...es2]
  3847. },
  3848. }),
  3849. getEditValue = (s, k, t) =>
  3850. s.editingInput.id === k
  3851. ? s.editingInput.value
  3852. : t(getState(k, s))
  3853. return state => {
  3854. const getText = getLang(state.lang),
  3855. checkboxNode = label => {
  3856. return ((label, checked, onchange) =>
  3857. h(
  3858. "div",
  3859. {},
  3860. h("label", {}, [
  3861. hyperapp_text(label),
  3862. h("input", { type: "checkbox", checked, onchange }),
  3863. ])
  3864. ))(
  3865. getText(label),
  3866. getState(label, state),
  3867. ((key = label),
  3868. (s, e) =>
  3869. function_pipe(
  3870. (e => tapIs(HTMLInputElement, e.currentTarget).checked)(
  3871. e
  3872. ),
  3873. x => updateAt(key, x, s)
  3874. ))
  3875. )
  3876. var key
  3877. },
  3878. textColorNode = label =>
  3879. settingRow(getText(label), [
  3880. textColorRow(
  3881. function_pipe(editAction(label, updateString), x => [
  3882. colorPicker(x),
  3883. colorInput(x),
  3884. colorTextOutput(exampleTextStyle(state)),
  3885. ])
  3886. )(getEditValue(state, label, function_identity)),
  3887. ]),
  3888. intNode = (label, min, max, step) =>
  3889. settingRow(getText(label), [
  3890. rangeRow(
  3891. min,
  3892. max,
  3893. step,
  3894. getEditValue(state, label, number_Show_show),
  3895. state.editingInput.id === label,
  3896. editAction(label, updateInt)
  3897. ),
  3898. ]),
  3899. numberNode = (label, min, max, step) =>
  3900. settingRow(getText(label), [
  3901. rangeRow(
  3902. min,
  3903. max,
  3904. step,
  3905. getEditValue(state, label, number_Show_show),
  3906. state.editingInput.id === label,
  3907. editAction(label, updateNumber)
  3908. ),
  3909. ]),
  3910. buttonNode = label =>
  3911. h(
  3912. "button",
  3913. {
  3914. type: "button",
  3915. onclick: s => [s, [() => doAct[label](s), void 0]],
  3916. },
  3917. hyperapp_text(getText(label))
  3918. ),
  3919. textAreaNode = (label, rows) =>
  3920. settingRow(getText(label), [
  3921. textAreaRow(
  3922. rows,
  3923. getEditValue(state, label, x => x.join("\n")),
  3924. editAction(label, updateStrings)
  3925. ),
  3926. ]),
  3927. currentFonts = [
  3928. ["", "Default", "デフォルト"],
  3929. ["arial", "Arial", "Arial"],
  3930. ["arial black", "Arial Black", "Arial Black"],
  3931. ["arial narrow", "Arial Narrow", "Arial Narrow"],
  3932. ["Century", "Century", "Century"],
  3933. ["Comic Sans MS", "Comic Sans MS", "Comic Sans MS"],
  3934. ["Courier", "Courier", "Courier"],
  3935. ["cursive", "cursive", "cursive"],
  3936. ["fantasy", "fantasy", "fantasy"],
  3937. ["Impact", "Impact", "Impact"],
  3938. ["Meiryo", "Meiryo", "メイリオ"],
  3939. ["Meiryo UI", "Meiryo UI", "メイリオ UI"],
  3940. ["monospace", "monospace", "monospace"],
  3941. ["Monotype Corsiva", "Monotype Corsiva", "Monotype Corsiva"],
  3942. ["MS PGothic", "MS PGothic", "MS Pゴシック"],
  3943. ["MS Gothic", "MS Gothic", "MS ゴシック"],
  3944. ["MS Sans Serif", "MS Sans Serif", "MS Sans Serif"],
  3945. ["MS Serif", "MS Serif", "MS Serif"],
  3946. ["MS UI Gothic", "MS UI Gothic", "MS UI Gothic"],
  3947. ["sans-serif", "Sans-serif", "Sans-serif"],
  3948. ["serif", "Serif", "Serif"],
  3949. ["Times New Roman", "Times New Roman", "Times New Roman"],
  3950. ["Yu Gothic", "Yu Gothic", "遊ゴシック"],
  3951. ["YuGothic", "YuGothic", "游ゴシック体"],
  3952. [state.font, "Custom", "カスタム"],
  3953. ],
  3954. logPageLength =
  3955. Math.trunc(getState("eventLog", state).length / 100) + 1
  3956. return state.showPanel
  3957. ? h(
  3958. "div",
  3959. {
  3960. class: "fyc_panel",
  3961. style: {
  3962. backgroundColor: "rgba(30,30,30,0.9)",
  3963. zIndex: "10000",
  3964. position: "absolute",
  3965. bottom: "40px",
  3966. right: "0px",
  3967. color: "#fff",
  3968. fontSize: "14px",
  3969. width: "660px",
  3970. border: "solid 1px #666",
  3971. fontFamily: "MS PGothic",
  3972. lineHeight: "1.2",
  3973. },
  3974. },
  3975. [
  3976. h(
  3977. "div",
  3978. { style: { float: "right", margin: "3px 3px 0 0" } },
  3979. [
  3980. hyperapp_text("🌐"),
  3981. h(
  3982. "select",
  3983. { onchange: updateString("lang") },
  3984. function_pipe(
  3985. langs,
  3986. es6_ReadonlyArray_map(x =>
  3987. ui_option(...x, x[0] === state.lang)
  3988. )
  3989. )
  3990. ),
  3991. ]
  3992. ),
  3993. tabContainer(
  3994. {
  3995. container: { height: "364px" },
  3996. label: { padding: "6px" },
  3997. labelFocus: { background: "#666" },
  3998. tab: { display: "flex", padding: "6px" },
  3999. },
  4000. [
  4001. getText("flowChat"),
  4002. getText("chatFilter"),
  4003. getText("chatField"),
  4004. getText("feedback"),
  4005. ],
  4006. [
  4007. () => {
  4008. return [
  4009. h("div", { style: panelBoxStyle(212) }, [
  4010. settingRow(getText("font"), [
  4011. h(
  4012. "select",
  4013. {
  4014. style: textRowStyle,
  4015. onchange: updateString("font"),
  4016. },
  4017. function_pipe(
  4018. currentFonts,
  4019. findIndex(x => x[0] === state.font),
  4020. getOrElse(() => 0),
  4021. index =>
  4022. function_pipe(
  4023. currentFonts,
  4024. es6_ReadonlyArray_mapWithIndex(
  4025. (i, x) =>
  4026. ui_option(
  4027. x[0],
  4028. "FYC_JA" === state.lang
  4029. ? x[2]
  4030. : x[1],
  4031. i === index
  4032. )
  4033. )
  4034. )
  4035. )
  4036. ),
  4037. ]),
  4038. h("input", {
  4039. style: textRowStyle,
  4040. maxlength: 20,
  4041. value: state.font,
  4042. oninput: updateString("font"),
  4043. }),
  4044. textColorNode("color"),
  4045. textColorNode("ownerColor"),
  4046. textColorNode("moderatorColor"),
  4047. textColorNode("memberColor"),
  4048. ((label = "shadowColor"),
  4049. settingRow(getText(label), [
  4050. textColorRow(
  4051. function_pipe(
  4052. [colorPicker, colorInput],
  4053. es6_ReadonlyArray_map(f =>
  4054. f(editAction(label, updateString))
  4055. )
  4056. )
  4057. )(
  4058. getEditValue(
  4059. state,
  4060. label,
  4061. function_identity
  4062. )
  4063. ),
  4064. ])),
  4065. ]),
  4066. h("div", { style: panelBoxStyle(212) }, [
  4067. numberNode("chatOpacity", 0, 1, 0.05),
  4068. numberNode("fontSize", 0.3, 2, 0.05),
  4069. numberNode("fontWeight", 10, 1e3, 10),
  4070. numberNode("shadowFontWeight", 0, 3, 0.1),
  4071. numberNode("flowSpeed", 1, 50, 1),
  4072. intNode("maxChatCount", 5, 200, 5),
  4073. intNode("maxChatLength", 5, 200, 5),
  4074. intNode("laneCount", 1, 25, 1),
  4075. ]),
  4076. h("div", { style: panelBoxStyle(212) }, [
  4077. numberNode("flowY1", 0, 0.95, 0.05),
  4078. numberNode("flowY2", 0.05, 1, 0.05),
  4079. numberNode("flowX1", 0, 0.95, 0.05),
  4080. numberNode("flowX2", 0.05, 1, 0.05),
  4081. numberNode("minSpacing", 0, 2.5, 0.1),
  4082. checkboxNode("useStepTiming"),
  4083. h(
  4084. "div",
  4085. {
  4086. style: {
  4087. ...(getState("useStepTiming", state)
  4088. ? {}
  4089. : { opacity: "0.5" }),
  4090. },
  4091. },
  4092. intNode("timingStepCount", 1, 400, 1)
  4093. ),
  4094. checkboxNode("createChats"),
  4095. checkboxNode("displayModName"),
  4096. checkboxNode("displaySuperChatAuthor"),
  4097. checkboxNode("textOnly"),
  4098. hyperapp_text(getText("flowNewChatIf")),
  4099. checkboxNode("noOverlap"),
  4100. buttonNode("clearFlowChats"),
  4101. ]),
  4102. ]
  4103. var label
  4104. },
  4105. () => [
  4106. h(
  4107. "div",
  4108. { style: panelBoxStyle(212) },
  4109. textAreaNode("bannedWords", 18)
  4110. ),
  4111. h(
  4112. "div",
  4113. { style: panelBoxStyle(212) },
  4114. settingRow(getText("bannedWordRegexs"), [
  4115. h(
  4116. "span",
  4117. {},
  4118. hyperapp_text(
  4119. state.bannedWordRegexsValid
  4120. ? ""
  4121. : `${getText("error")}: ${
  4122. state.bannedWordRegexsError
  4123. }`
  4124. )
  4125. ),
  4126. textAreaRow(
  4127. 18,
  4128. getEditValue(state, "bannedWordRegexs", x =>
  4129. x.join("\n")
  4130. ),
  4131. editAction("bannedWordRegexs", updateStrings)
  4132. ),
  4133. ])
  4134. ),
  4135. h(
  4136. "div",
  4137. { style: panelBoxStyle(212) },
  4138. textAreaNode("bannedUsers", 18)
  4139. ),
  4140. ],
  4141. () => [
  4142. h("div", { style: panelBoxStyle(644) }, [
  4143. numberNode("fieldScale", 0.7, 1.5, 0.05),
  4144. checkboxNode("simplifyChatField"),
  4145. checkboxNode("createBanButton"),
  4146. ]),
  4147. ],
  4148. () => [
  4149. h("div", { style: panelBoxStyle(644) }, [
  4150. h(
  4151. "div",
  4152. { style: { float: "right" } },
  4153. h(
  4154. "a",
  4155. {
  4156. style: { color: "#f0f" },
  4157. href: "https://greasyfork.org/en/scripts/411442-flow-youtube-chat/feedback",
  4158. target: "_blank",
  4159. },
  4160. hyperapp_text(getText("giveFeedback"))
  4161. )
  4162. ),
  4163. h("div", {}, [
  4164. h(
  4165. "span",
  4166. {},
  4167. hyperapp_text(getText("eventLog"))
  4168. ),
  4169. buttonNode("copy"),
  4170. tabContainer(
  4171. {
  4172. container: { height: "276px" },
  4173. label: {
  4174. padding: "4px",
  4175. width: "2em",
  4176. textAlign: "center",
  4177. },
  4178. labelFocus: { background: "#666" },
  4179. tab: {
  4180. display: "flex",
  4181. flexDirection: "column",
  4182. padding: "6px",
  4183. },
  4184. },
  4185. function_pipe(
  4186. ReadonlyArray_makeBy(
  4187. logPageLength,
  4188. number_Show_show
  4189. )
  4190. ),
  4191. function_pipe(
  4192. ReadonlyArray_makeBy(
  4193. logPageLength,
  4194. i => () =>
  4195. function_pipe(
  4196. getState("eventLog", state).slice(
  4197. 100 * i,
  4198. 100 * (i + 1)
  4199. ),
  4200. es6_ReadonlyArray_mapWithIndex(
  4201. (j, x) =>
  4202. h(
  4203. "div",
  4204. { style: { display: "flex" } },
  4205. [
  4206. h(
  4207. "div",
  4208. {
  4209. style: {
  4210. userSelect: "none",
  4211. flex: "0 0 2em",
  4212. },
  4213. },
  4214. hyperapp_text(100 * i + j)
  4215. ),
  4216. h(
  4217. "div",
  4218. {
  4219. style: {
  4220. background:
  4221. j % 2 == 0
  4222. ? "#fff"
  4223. : "#ddd",
  4224. color: "#000",
  4225. flex: "auto",
  4226. wordBreak: "break-all",
  4227. padding: "0 2px",
  4228. },
  4229. },
  4230. hyperapp_text(x)
  4231. ),
  4232. ]
  4233. )
  4234. )
  4235. )
  4236. )
  4237. ),
  4238. getState("logTab", state),
  4239. (s, n) => updateAt("logTab", n, s)
  4240. ),
  4241. ]),
  4242. ]),
  4243. ],
  4244. ],
  4245. getState("mainTab", state),
  4246. (s, n) => updateAt("mainTab", n, s)
  4247. ),
  4248. ]
  4249. )
  4250. : h("div", {})
  4251. }
  4252. },
  4253. togglePanel = (x, e) => [
  4254. { ...x, showPanel: !x.showPanel },
  4255. [
  4256. x.showPanel
  4257. ? () => tapIs(HTMLElement, e.currentTarget).blur()
  4258. : () => {},
  4259. void 0,
  4260. ],
  4261. ],
  4262. simpleWrap = (comp, init) => {
  4263. const node = document.createElement(comp.tag)
  4264. return { node, dispatch: app({ init, view: comp.view, node }) }
  4265. }
  4266. ;(async () => {
  4267. external_log_namespaceObject.setLevel("info")
  4268. try {
  4269. await function_pipe(
  4270. defaultUserConfig,
  4271. function_flow(
  4272. Task_bindTo("userConfig"),
  4273. Task_bind("configKeys", x =>
  4274. Task_of(Object.keys(x.userConfig))
  4275. ),
  4276. Task_bind("getConfig", ctx =>
  4277. Task_of(
  4278. function_pipe(
  4279. ctx.configKeys,
  4280. es6_ReadonlyArray_map(x => [
  4281. x,
  4282. () => ctx.userConfig[x].val,
  4283. ]),
  4284. Object.fromEntries
  4285. )
  4286. )
  4287. ),
  4288. Task_bind("mainState", x =>
  4289. Task_of({
  4290. chatPlaying: !0,
  4291. playerRect: new DOMRect(0, 0, 600, 400),
  4292. filterExp: Option_none,
  4293. getConfig: x.getConfig,
  4294. })
  4295. ),
  4296. Task_bind("configSubject", ctx =>
  4297. Task_of(
  4298. function_pipe(
  4299. ctx.configKeys,
  4300. es6_ReadonlyArray_map(x => [
  4301. x,
  4302. new external_rxjs_namespaceObject.Subject(),
  4303. ]),
  4304. Object.fromEntries
  4305. )
  4306. )
  4307. ),
  4308. Task_bind("setConfigPlain", ctx =>
  4309. Task_of(
  4310. function_pipe(
  4311. ctx.configKeys,
  4312. es6_ReadonlyArray_map(x => [
  4313. x,
  4314. async val => {
  4315. ctx.userConfig[x].val = val
  4316. ctx.configSubject[x].next(val)
  4317. },
  4318. ]),
  4319. Object.fromEntries
  4320. )
  4321. )
  4322. ),
  4323. Task_apS(
  4324. "channel",
  4325. Task_fromIO(
  4326. () =>
  4327. new broadcast_channel_BroadcastChannel(
  4328. "fyc-0615654655528523"
  4329. )
  4330. )
  4331. ),
  4332. Task_bind("setConfig", ctx =>
  4333. Task_of(
  4334. function_pipe(
  4335. ctx.configKeys,
  4336. es6_ReadonlyArray_map(x => [
  4337. x,
  4338. async val => {
  4339. ctx.setConfigPlain[x](val)
  4340. const item = ctx.userConfig[x]
  4341. ctx.channel.postMessage([x, val])
  4342. GM.setValue(item.gmKey, item.toGm(val))
  4343. },
  4344. ]),
  4345. Object.fromEntries
  4346. )
  4347. )
  4348. )
  4349. ),
  4350. function_flow(
  4351. Task_apS(
  4352. "reinitSubject",
  4353. Task_fromIO(() => new external_rxjs_namespaceObject.Subject())
  4354. ),
  4355. Task_bind("reinitialize", ctx =>
  4356. Task_of(() => {
  4357. requestAnimationFrame(() => lib(ctx.reinitSubject)())
  4358. })
  4359. ),
  4360. Task_bind("toggleChatButtonInit", ctx =>
  4361. Task_of({
  4362. lang: ctx.getConfig.lang(),
  4363. displayChats: ctx.getConfig.displayChats(),
  4364. })
  4365. ),
  4366. Task_bind("wrappedToggleChatBtn", ctx => {
  4367. return Task_of(
  4368. simpleWrap(
  4369. ((setConfig = ctx.setConfig),
  4370. {
  4371. tag: "button",
  4372. view: state => {
  4373. const label = getLang(state.lang)(
  4374. state.displayChats ? "hideChat" : "showChat"
  4375. )
  4376. return h(
  4377. "button",
  4378. {
  4379. class: "ytp-button",
  4380. style: {
  4381. background: "none",
  4382. border: "none",
  4383. cursor: "pointer",
  4384. float: "left",
  4385. fontSize: "1em",
  4386. height: "4em",
  4387. outline: "none",
  4388. overflow: "visible",
  4389. padding: "0 0 0em",
  4390. position: "relative",
  4391. width: "3em",
  4392. },
  4393. type: "button",
  4394. "aria-label": label,
  4395. title: label,
  4396. onclick: s => {
  4397. const displayChats = !s.displayChats
  4398. return [
  4399. { ...s, displayChats },
  4400. [
  4401. () => setConfig.displayChats(displayChats),
  4402. void 0,
  4403. ],
  4404. ]
  4405. },
  4406. },
  4407. [
  4408. h(
  4409. "svg",
  4410. {
  4411. style: { width: "100%" },
  4412. viewBox: "0 0 36 36",
  4413. },
  4414. [
  4415. h("path", {
  4416. class: "chat-button-path",
  4417. d: "m11 12h17q1 0 1 1v9q0 1-1 1h-1v2l-4-2h-12q-1 0-1-1v-9q0-1 1-1z",
  4418. fill: "#fff",
  4419. "fill-opacity": state.displayChats
  4420. ? "1"
  4421. : "0",
  4422. stroke: "#fff",
  4423. "stroke-width": "2",
  4424. }),
  4425. ]
  4426. ),
  4427. ]
  4428. )
  4429. },
  4430. }),
  4431. ctx.toggleChatButtonInit
  4432. )
  4433. )
  4434. var setConfig
  4435. }),
  4436. Task_apS("flowChats", Task_of([])),
  4437. Task_bind("wrappedSetting", ctx => {
  4438. return Task_of(
  4439. simpleWrap(
  4440. (command => {
  4441. const panel = settingPanel(command)
  4442. return {
  4443. tag: "span",
  4444. view: s => {
  4445. return h(
  4446. "span",
  4447. { style: { display: "contents" } },
  4448. [
  4449. panel(s),
  4450. ((state = s),
  4451. h(
  4452. "button",
  4453. {
  4454. class: "fyc_button",
  4455. style: {
  4456. background: "rgba(0,0,0,0)",
  4457. marginLeft: "10px",
  4458. whiteSpace: "nowrap",
  4459. },
  4460. onclick: togglePanel,
  4461. },
  4462. [
  4463. h(
  4464. "svg",
  4465. {
  4466. preserveAspectRatio: "xMidYMid meet",
  4467. viewBox: "0 0 640 640",
  4468. width: "15",
  4469. height: "15",
  4470. style: {
  4471. position: "relative",
  4472. top: "1px",
  4473. },
  4474. },
  4475. [
  4476. h(
  4477. "defs",
  4478. {},
  4479. h("path", {
  4480. id: "d1TbzTC1zI",
  4481. d: "M135 58c25 14 67 30 82 35-7 49 16 109-15 149-50 71-19 184 64 213 74 31 165-18 183-95-3-38 23-62 58-36l120 55c-39 10-106 35-72 85 40 38 1 71-29 98-29 53-70-17-109-5-46 22-25 109-96 85h-55c-24-31-21-103-80-84-32 32-70 31-93-9l-35-36c4-40 57-96-6-120-45 5-58-32-52-68 2-19-4-41 3-59 35-15 100-22 77-79-48-43 1-84 35-115 5-6 12-12 20-14zM577 2c52 3 72 62 62 106-5 51 19 117-27 155-18 24 8 49 11 74-39-8-98-46-146-60-55-1-111 2-167-2-52-15-57-76-52-121S242 52 282 18c38-30 88-11 132-16h163z",
  4482. })
  4483. ),
  4484. h("use", {
  4485. href: "#d1TbzTC1zI",
  4486. opacity: "1",
  4487. fill: "var(--iron-icon-fill-color, currentcolor)",
  4488. "fill-opacity": "1",
  4489. }),
  4490. ]
  4491. ),
  4492. h(
  4493. "span",
  4494. {
  4495. style: {
  4496. position: "relative",
  4497. top: "-2px",
  4498. marginLeft: "8px,",
  4499. },
  4500. },
  4501. hyperapp_text(
  4502. getLang(state.lang)("setting")
  4503. )
  4504. ),
  4505. ]
  4506. )),
  4507. ]
  4508. )
  4509. var state
  4510. },
  4511. }
  4512. })({
  4513. setConfig: ctx.setConfig,
  4514. act: {
  4515. clearFlowChats: async () =>
  4516. removeOldChats(0)(ctx.flowChats)(),
  4517. },
  4518. }),
  4519. ((getConfig = ctx.getConfig),
  4520. {
  4521. ...function_pipe(
  4522. Object.entries(getConfig),
  4523. es6_ReadonlyArray_map(([k, v]) => [k, v()]),
  4524. Object.fromEntries
  4525. ),
  4526. showPanel: !1,
  4527. bannedWordRegexsValid: !0,
  4528. bannedWordRegexsError: "",
  4529. mainTab: 0,
  4530. logTab: 0,
  4531. timingStepCount: parseInt(
  4532. getConfig
  4533. .timingFunction()
  4534. .match(/^steps\((\d+),.+/)?.[1] ?? "150",
  4535. 10
  4536. ),
  4537. eventLog: [],
  4538. editingInput: {
  4539. id: "",
  4540. committedState: void 0,
  4541. value: "",
  4542. },
  4543. })
  4544. )
  4545. )
  4546. var getConfig
  4547. }),
  4548. Task_bind("mainLog", ctx =>
  4549. Task_of(
  4550. x => () =>
  4551. ctx.wrappedSetting.dispatch(s => ({
  4552. ...s,
  4553. eventLog: appendLog(s.eventLog)(x),
  4554. }))
  4555. )
  4556. ),
  4557. Task_bind("mixLog", ctx =>
  4558. Task_of(
  4559. function_pipe(
  4560. [ctx.mainLog, consoleLog],
  4561. Reader_sequenceArray,
  4562. es6_Reader_map(IO_sequenceArray)
  4563. )
  4564. )
  4565. )
  4566. ),
  4567. Task_chainFirstIOK(ctx =>
  4568. function_pipe(
  4569. [
  4570. ["Version", "1.15.8"],
  4571. ["User Agent", window.navigator.userAgent],
  4572. ["UserConfig", JSON.stringify(ctx.userConfig)],
  4573. ],
  4574. es6_ReadonlyArray_map(ctx.mainLog),
  4575. IO_sequenceArray
  4576. )
  4577. ),
  4578. Task_bind("cs", ctx =>
  4579. Task_of(
  4580. function_pipe(
  4581. ctx.configSubject,
  4582. Object.entries,
  4583. es6_ReadonlyArray_map(([k, value]) => [
  4584. k,
  4585. function_pipe(
  4586. value,
  4587. (0, external_rxjs_namespaceObject.tap)(v =>
  4588. function_pipe(
  4589. v,
  4590. x => s => ({ ...s, [k]: x }),
  4591. IO_of,
  4592. IO_chainFirst(
  4593. x => () => ctx.wrappedSetting.dispatch(x)
  4594. ),
  4595. es6_IO_chain(x =>
  4596. k in ctx.toggleChatButtonInit
  4597. ? () => ctx.wrappedToggleChatBtn.dispatch(x)
  4598. : () => {}
  4599. ),
  4600. x => () => requestAnimationFrame(x)
  4601. )()
  4602. )
  4603. ),
  4604. ]),
  4605. Object.fromEntries
  4606. )
  4607. )
  4608. ),
  4609. Task_apS("livePage", Task_fromIO(livePageYt)),
  4610. Task_bind("liveElementKeys", ctx =>
  4611. Task_of(Object.keys(ctx.livePage))
  4612. ),
  4613. Task_bind("live", ctx =>
  4614. Task_of(
  4615. function_pipe(
  4616. key => ({ ele: Option_none, read: ctx.livePage[key] }),
  4617. initState =>
  4618. function_pipe(
  4619. ctx.liveElementKeys,
  4620. es6_ReadonlyArray_map(x => [x, initState(x)]),
  4621. Object.fromEntries
  4622. )
  4623. )
  4624. )
  4625. ),
  4626. Task_apS("chatScreen", Task_fromIO(createChatScreen)),
  4627. Task_bind("config$", ctx =>
  4628. function_pipe(
  4629. ctx.cs,
  4630. cs =>
  4631. (0, external_rxjs_namespaceObject.merge)(
  4632. function_pipe(
  4633. (0, external_rxjs_namespaceObject.merge)(
  4634. cs.bannedWordRegexs,
  4635. cs.bannedWords,
  4636. cs.bannedUsers
  4637. ),
  4638. (0, external_rxjs_namespaceObject.startWith)(void 0),
  4639. (0, external_rxjs_namespaceObject.tap)(() => {
  4640. ctx.mainState.filterExp = Option_some(
  4641. ((getConfig = ctx.getConfig),
  4642. external_jsep_default()(
  4643. `\nor([\nRA.some(anyPreds([\n flip(flow([matchedByText, RA.some]))(${JSON.stringify(
  4644. getConfig.bannedWordRegexs()
  4645. )}),\n flip(flow([inText, RA.some]))(${JSON.stringify(
  4646. getConfig.bannedWords()
  4647. )})\n]))(RA.compact([\n messageText,\n paymentInfo\n])),\nO.exists(\n flip(flow([eqText, RA.some]))(${JSON.stringify(
  4648. getConfig.bannedUsers()
  4649. )})\n)(authorID)\n])\n`
  4650. ))
  4651. )
  4652. var getConfig
  4653. })
  4654. ),
  4655. function_pipe(
  4656. cs.fieldScale,
  4657. (0, external_rxjs_namespaceObject.startWith)(
  4658. ctx.getConfig.fieldScale()
  4659. ),
  4660. (0, external_rxjs_namespaceObject.tap)(scale =>
  4661. function_pipe(
  4662. ctx.live.chatField.ele,
  4663. fromOption,
  4664. IOOption_chain(field =>
  4665. IOOption_fromIO(() =>
  4666. function_pipe(
  4667. [
  4668. function_pipe(
  4669. fromNullable(field.parentElement),
  4670. es6_Option_map(x => () => {
  4671. x.style.transformOrigin =
  4672. (scale >= 1 ? "top" : "bottom") +
  4673. " left"
  4674. x.style.transform = `scale(${scale})`
  4675. x.style.width = 100 / scale + "%"
  4676. x.style.height = `${field.offsetHeight}px`
  4677. })
  4678. ),
  4679. function_pipe(
  4680. ctx.live.chatScroller.ele,
  4681. es6_Option_map(scroller => () => {
  4682. scroller.scrollTop =
  4683. scroller.scrollHeight
  4684. })
  4685. ),
  4686. ],
  4687. ReadonlyArray_compact,
  4688. IO_sequenceArray
  4689. )
  4690. )
  4691. )
  4692. )()
  4693. )
  4694. ),
  4695. function_pipe(
  4696. (0, external_rxjs_namespaceObject.merge)(
  4697. function_pipe(
  4698. (0, external_rxjs_namespaceObject.merge)(
  4699. cs.font,
  4700. cs.fontSize,
  4701. cs.fontWeight,
  4702. cs.laneCount,
  4703. cs.minSpacing,
  4704. cs.flowY1,
  4705. cs.flowY2,
  4706. function_pipe(
  4707. cs.flowX1,
  4708. (0, external_rxjs_namespaceObject.startWith)(
  4709. ctx.getConfig.flowX1()
  4710. ),
  4711. (0, external_rxjs_namespaceObject.tap)(x => {
  4712. ctx.chatScreen.style.left = 100 * x + "%"
  4713. ctx.chatScreen.style.width =
  4714. 100 * (ctx.getConfig.flowX2() - x) + "%"
  4715. })
  4716. ),
  4717. function_pipe(
  4718. cs.flowX2,
  4719. (0, external_rxjs_namespaceObject.tap)(x => {
  4720. ctx.chatScreen.style.left =
  4721. 100 * ctx.getConfig.flowX1() + "%"
  4722. ctx.chatScreen.style.width =
  4723. 100 * (x - ctx.getConfig.flowX1()) + "%"
  4724. })
  4725. ),
  4726. cs.textOnly
  4727. ),
  4728. (0, external_rxjs_namespaceObject.mapTo)({
  4729. render: !0,
  4730. setAnimation: !0,
  4731. })
  4732. ),
  4733. function_pipe(
  4734. (0, external_rxjs_namespaceObject.merge)(
  4735. cs.color,
  4736. cs.ownerColor,
  4737. cs.moderatorColor,
  4738. cs.memberColor,
  4739. cs.shadowColor,
  4740. cs.chatOpacity,
  4741. cs.shadowFontWeight,
  4742. cs.displayChats
  4743. ),
  4744. (0, external_rxjs_namespaceObject.mapTo)({
  4745. render: !0,
  4746. })
  4747. ),
  4748. function_pipe(
  4749. cs.flowSpeed,
  4750. (0, external_rxjs_namespaceObject.mapTo)({
  4751. setPlayState: !0,
  4752. })
  4753. ),
  4754. function_pipe(
  4755. (0, external_rxjs_namespaceObject.merge)(
  4756. function_pipe(
  4757. cs.maxChatCount,
  4758. (0, external_rxjs_namespaceObject.tap)(x =>
  4759. removeOldChats(x)(ctx.flowChats)()
  4760. )
  4761. ),
  4762. cs.noOverlap,
  4763. cs.timingFunction
  4764. ),
  4765. (0, external_rxjs_namespaceObject.mapTo)({
  4766. setAnimation: !0,
  4767. })
  4768. )
  4769. ),
  4770. (0, external_rxjs_namespaceObject.throttleTime)(
  4771. 180,
  4772. void 0,
  4773. { leading: !0, trailing: !0 }
  4774. ),
  4775. (0, external_rxjs_namespaceObject.tap)(config =>
  4776. function_pipe(
  4777. ctx.flowChats,
  4778. es6_ReadonlyArray_filter(x => !x.animationEnded),
  4779. es6_ReadonlyArray_map(chat =>
  4780. function_pipe(
  4781. {
  4782. render: !1,
  4783. setAnimation: !1,
  4784. setPlayState: !1,
  4785. ...config,
  4786. },
  4787. x =>
  4788. function_pipe(
  4789. [
  4790. function_pipe(
  4791. renderChat(chat),
  4792. fromPredicate(() => x.render)
  4793. ),
  4794. function_pipe(
  4795. setChatAnimation(chat, ctx.flowChats),
  4796. fromPredicate(() => x.setAnimation),
  4797. alt(() =>
  4798. function_pipe(
  4799. setChatPlayState(chat),
  4800. fromPredicate(() => x.setPlayState)
  4801. )
  4802. )
  4803. ),
  4804. ],
  4805. ReadonlyArray_compact,
  4806. es6_ReadonlyArray_map(
  4807. (function (a) {
  4808. return function (f) {
  4809. return f(a)
  4810. }
  4811. })(ctx.mainState)
  4812. ),
  4813. IO_sequenceArray
  4814. )
  4815. )
  4816. ),
  4817. IO_sequenceArray
  4818. )()
  4819. )
  4820. ),
  4821. cs.lang,
  4822. cs.maxChatLength,
  4823. cs.simplifyChatField,
  4824. cs.createBanButton,
  4825. cs.createChats,
  4826. cs.displayModName,
  4827. cs.displaySuperChatAuthor,
  4828. cs.fieldScale,
  4829. cs.bannedWords,
  4830. cs.bannedWordRegexs,
  4831. cs.bannedUsers
  4832. ),
  4833. Task_of
  4834. )
  4835. ),
  4836. Task_apS(
  4837. "documentMutationPair",
  4838. Task_fromIO(observePair(MutationObserver))
  4839. ),
  4840. Task_apS(
  4841. "chatMutationPair",
  4842. Task_fromIO(observePair(MutationObserver))
  4843. ),
  4844. Task_apS(
  4845. "playerResizePair",
  4846. Task_fromIO(observePair(ResizeObserver))
  4847. ),
  4848. Task_bind("all$", ctx => {
  4849. return function_pipe(
  4850. {
  4851. css: mainCss(),
  4852. eq: ((E = eqStrict),
  4853. {
  4854. equals: function (x, y) {
  4855. return (
  4856. x === y ||
  4857. (Option_isNone(x)
  4858. ? Option_isNone(y)
  4859. : !Option_isNone(y) && E.equals(x.value, y.value))
  4860. )
  4861. },
  4862. }).equals,
  4863. initDelay: 100,
  4864. urlDelay: 1700,
  4865. changeDetectInterval: 700,
  4866. },
  4867. IO_of,
  4868. IO_apS("chatScreen", createChatScreen),
  4869. IO_apS("documentMutationPair", observePair(MutationObserver)),
  4870. IO_apS("chatMutationPair", observePair(MutationObserver)),
  4871. IO_apS("playerResizePair", observePair(ResizeObserver)),
  4872. es6_IO_map(c =>
  4873. function_pipe(
  4874. ctx.reinitSubject,
  4875. (0, external_rxjs_namespaceObject.observeOn)(
  4876. external_rxjs_namespaceObject.asyncScheduler
  4877. ),
  4878. (0, external_rxjs_namespaceObject.delay)(c.initDelay),
  4879. (0, external_rxjs_namespaceObject.tap)(
  4880. ctx.mixLog(["Init"])
  4881. ),
  4882. (0, external_rxjs_namespaceObject.switchMap)(() =>
  4883. function_pipe(
  4884. (0, external_rxjs_namespaceObject.interval)(
  4885. c.changeDetectInterval
  4886. ),
  4887. (0, external_rxjs_namespaceObject.filter)(() =>
  4888. function_pipe(
  4889. ctx.liveElementKeys,
  4890. es6_ReadonlyArray_map(key =>
  4891. function_pipe(
  4892. ctx.live[key].read(),
  4893. fromPredicate(
  4894. newEle => !c.eq(ctx.live[key].ele, newEle)
  4895. ),
  4896. es6_Option_map(x => () => {
  4897. ctx.live[key].ele = x
  4898. }),
  4899. es6_Option_map(
  4900. IO_apSecond(ctx.mixLog([`${key} changed`]))
  4901. )
  4902. )
  4903. ),
  4904. ReadonlyArray_compact,
  4905. IO_sequenceArray,
  4906. es6_IO_map(ReadonlyArray_isNonEmpty)
  4907. )()
  4908. ),
  4909. (0, external_rxjs_namespaceObject.startWith)(0)
  4910. )
  4911. ),
  4912. (0, external_rxjs_namespaceObject.tap)(
  4913. ctx.mixLog(["Loading..."])
  4914. ),
  4915. (0, external_rxjs_namespaceObject.tap)(() => {
  4916. removeOldChats(0)(ctx.flowChats)()
  4917. ctx.documentMutationPair.observer.disconnect()
  4918. ctx.documentMutationPair.observer.observe(document, {
  4919. childList: !0,
  4920. subtree: !0,
  4921. })
  4922. ctx.chatMutationPair.observer.disconnect()
  4923. ctx.playerResizePair.observer.disconnect()
  4924. document.head.append(c.css)
  4925. function_pipe(
  4926. [
  4927. function_pipe(
  4928. ctx.live.chatField.ele,
  4929. es6_Option_map(x => () => {
  4930. ;((chatField = x),
  4931. () =>
  4932. function_pipe(
  4933. fromNullable(chatField.parentElement),
  4934. es6_Option_map(x => () => {
  4935. x.style.overflow = "unset"
  4936. })
  4937. ))()
  4938. var chatField
  4939. ctx.chatMutationPair.observer.observe(x, {
  4940. childList: !0,
  4941. })
  4942. })
  4943. ),
  4944. function_pipe(
  4945. ctx.live.chatTicker.ele,
  4946. es6_Option_map(
  4947. x => () =>
  4948. ctx.chatMutationPair.observer.observe(x, {
  4949. childList: !0,
  4950. })
  4951. )
  4952. ),
  4953. function_pipe(
  4954. ctx.live.player.ele,
  4955. es6_Option_map(x => () => {
  4956. ctx.playerResizePair.observer.observe(x)
  4957. x.insertAdjacentElement(
  4958. "afterbegin",
  4959. ctx.chatScreen
  4960. )
  4961. })
  4962. ),
  4963. function_pipe(
  4964. ctx.live.toggleChatBtnParent.ele,
  4965. es6_Option_map(
  4966. x => () =>
  4967. x.append(ctx.wrappedToggleChatBtn.node)
  4968. )
  4969. ),
  4970. function_pipe(
  4971. ctx.live.settingNextElement.ele,
  4972. es6_Option_map(x => () => {
  4973. x.insertAdjacentElement(
  4974. "beforebegin",
  4975. ctx.wrappedSetting.node
  4976. )
  4977. })
  4978. ),
  4979. ],
  4980. ReadonlyArray_compact,
  4981. ReadonlyArray_append(
  4982. function_pipe(
  4983. ctx.live.video.ele,
  4984. filter(x => !x.paused),
  4985. alt(() => ctx.live.offlineSlate.ele),
  4986. Option_isSome,
  4987. x => () => {
  4988. ctx.mainState.chatPlaying = x
  4989. }
  4990. )
  4991. ),
  4992. IO_sequenceArray
  4993. )()
  4994. }),
  4995. (0, external_rxjs_namespaceObject.switchMap)(() =>
  4996. (0, external_rxjs_namespaceObject.merge)(
  4997. function_pipe(
  4998. (0, external_rxjs_namespaceObject.fromEvent)(
  4999. ctx.channel,
  5000. "message"
  5001. ),
  5002. (0, external_rxjs_namespaceObject.tap)(
  5003. ([key, val]) =>
  5004. function_pipe(
  5005. [
  5006. "lang",
  5007. "bannedWords",
  5008. "bannedWordRegexs",
  5009. "bannedUsers",
  5010. "simplifyChatField",
  5011. "createBanButton",
  5012. "fieldScale",
  5013. ].includes(key),
  5014. x =>
  5015. x
  5016. ? () => ctx.setConfigPlain[key](val)
  5017. : () => {}
  5018. )()
  5019. )
  5020. ),
  5021. ...function_pipe(
  5022. ctx.configKeys,
  5023. es6_ReadonlyArray_map(key =>
  5024. function_pipe(
  5025. ctx.cs[key],
  5026. (0, external_rxjs_namespaceObject.startWith)(
  5027. ctx.getConfig[key]()
  5028. ),
  5029. (0, external_rxjs_namespaceObject.bufferCount)(
  5030. 2,
  5031. 1
  5032. ),
  5033. (0, external_rxjs_namespaceObject.map)(
  5034. ([x, y]) =>
  5035. (0, external_DeepDiff_namespaceObject.diff)(
  5036. x,
  5037. y
  5038. )
  5039. ),
  5040. (0, external_rxjs_namespaceObject.tap)(x =>
  5041. ctx.mainLog([
  5042. `Config ${key}`,
  5043. JSON.stringify(x, void 0, 2),
  5044. ])()
  5045. )
  5046. )
  5047. )
  5048. ),
  5049. ctx.config$,
  5050. function_pipe(
  5051. ctx.live.video.ele,
  5052. match(
  5053. () => external_rxjs_namespaceObject.EMPTY,
  5054. x => {
  5055. return function_pipe(
  5056. ((video = x),
  5057. (0, external_rxjs_namespaceObject.merge)(
  5058. function_pipe(
  5059. (0,
  5060. external_rxjs_namespaceObject.fromEvent)(
  5061. video,
  5062. "playing"
  5063. ),
  5064. (0, external_rxjs_namespaceObject.mapTo)(
  5065. !0
  5066. )
  5067. ),
  5068. function_pipe(
  5069. (0,
  5070. external_rxjs_namespaceObject.fromEvent)(
  5071. video,
  5072. "waiting"
  5073. ),
  5074. (0, external_rxjs_namespaceObject.mapTo)(
  5075. !1
  5076. )
  5077. ),
  5078. function_pipe(
  5079. (0,
  5080. external_rxjs_namespaceObject.fromEvent)(
  5081. video,
  5082. "pause"
  5083. ),
  5084. (0, external_rxjs_namespaceObject.mapTo)(
  5085. !1
  5086. )
  5087. )
  5088. )),
  5089. (0, external_rxjs_namespaceObject.map)(
  5090. playing =>
  5091. playing ||
  5092. Option_isSome(ctx.live.offlineSlate.ele)
  5093. ),
  5094. (0, external_rxjs_namespaceObject.tap)(
  5095. chatPlaying => {
  5096. ctx.mainState.chatPlaying = chatPlaying
  5097. ctx.flowChats.forEach(chat =>
  5098. setChatPlayState(chat)(ctx.mainState)()
  5099. )
  5100. }
  5101. )
  5102. )
  5103. var video
  5104. }
  5105. )
  5106. ),
  5107. function_pipe(
  5108. ctx.chatMutationPair.subject,
  5109. (0, external_rxjs_namespaceObject.map)(
  5110. onChatFieldMutate(
  5111. ctx.chatScreen,
  5112. ctx.flowChats,
  5113. ctx.mainState,
  5114. ctx.setConfig,
  5115. ctx.mainLog
  5116. )
  5117. ),
  5118. (0, external_rxjs_namespaceObject.tap)(x => x())
  5119. ),
  5120. function_pipe(
  5121. ctx.documentMutationPair.subject,
  5122. (0, external_rxjs_namespaceObject.map)(
  5123. () => window.location.href
  5124. ),
  5125. (0,
  5126. external_rxjs_namespaceObject.distinctUntilChanged)(),
  5127. (0, external_rxjs_namespaceObject.skip)(1),
  5128. (0, external_rxjs_namespaceObject.tap)(x => {
  5129. ctx.mixLog(["URL Changed", x])()
  5130. removeOldChats(0)(ctx.flowChats)()
  5131. ctx.mixLog([`Wait for ${c.urlDelay}ms...`])()
  5132. }),
  5133. (0, external_rxjs_namespaceObject.delay)(
  5134. c.urlDelay
  5135. ),
  5136. (0, external_rxjs_namespaceObject.tap)(
  5137. ctx.reinitialize
  5138. )
  5139. ),
  5140. function_pipe(
  5141. ctx.playerResizePair.subject,
  5142. (0, external_rxjs_namespaceObject.throttleTime)(
  5143. 500,
  5144. void 0,
  5145. { leading: !0, trailing: !0 }
  5146. ),
  5147. (0, external_rxjs_namespaceObject.startWith)([]),
  5148. (0, external_rxjs_namespaceObject.map)(
  5149. () => ctx.live.player.ele
  5150. ),
  5151. (0, external_rxjs_namespaceObject.map)(
  5152. es6_Option_map(x => x.getBoundingClientRect())
  5153. ),
  5154. (0, external_rxjs_namespaceObject.tap)(x => {
  5155. return (
  5156. (rect = x),
  5157. (flowChats = ctx.flowChats),
  5158. (mainState = ctx.mainState),
  5159. (mainLog = ctx.mainLog),
  5160. function_pipe(
  5161. rect,
  5162. match(
  5163. () => () => {},
  5164. x => () => {
  5165. mainLog(["Resize detected"])()
  5166. mainState.playerRect = x
  5167. flowChats.forEach(chat => {
  5168. renderChat(chat)(mainState)()
  5169. setChatAnimation(
  5170. chat,
  5171. flowChats
  5172. )(mainState)()
  5173. })
  5174. }
  5175. )
  5176. )()
  5177. )
  5178. var rect, flowChats, mainState, mainLog
  5179. })
  5180. )
  5181. )
  5182. ),
  5183. (0, external_rxjs_namespaceObject.retryWhen)(e =>
  5184. function_pipe(
  5185. e,
  5186. (0, external_rxjs_namespaceObject.tap)(
  5187. ctx.mixLog(["Errored", e])
  5188. ),
  5189. (0, external_rxjs_namespaceObject.delay)(5e3),
  5190. (0, external_rxjs_namespaceObject.tap)(x =>
  5191. ctx.mixLog(x)()
  5192. ),
  5193. (0, external_rxjs_namespaceObject.tap)(
  5194. ctx.reinitialize
  5195. )
  5196. )
  5197. )
  5198. )
  5199. ),
  5200. Task_fromIO
  5201. )
  5202. var E
  5203. }),
  5204. Task_chainFirstIOK(
  5205. ctx => () =>
  5206. ctx.all$.subscribe({
  5207. error: x => ctx.mixLog(["Stream error", x])(),
  5208. complete: ctx.mixLog(["Stream complete"]),
  5209. })
  5210. ),
  5211. Task_chainFirstIOK(ctx => ctx.reinitialize)
  5212. )()
  5213. } catch (error) {
  5214. external_log_namespaceObject.info("【FYC】 Error", error)
  5215. }
  5216. })()
  5217. },
  5218. 633: () => {},
  5219. },
  5220. __webpack_module_cache__ = {}
  5221. function __webpack_require__(moduleId) {
  5222. var cachedModule = __webpack_module_cache__[moduleId]
  5223. if (void 0 !== cachedModule) return cachedModule.exports
  5224. var module = (__webpack_module_cache__[moduleId] = { exports: {} })
  5225. __webpack_modules__[moduleId](module, module.exports, __webpack_require__)
  5226. return module.exports
  5227. }
  5228. __webpack_require__.n = module => {
  5229. var getter =
  5230. module && module.__esModule ? () => module.default : () => module
  5231. __webpack_require__.d(getter, { a: getter })
  5232. return getter
  5233. }
  5234. __webpack_require__.d = (exports, definition) => {
  5235. for (var key in definition)
  5236. __webpack_require__.o(definition, key) &&
  5237. !__webpack_require__.o(exports, key) &&
  5238. Object.defineProperty(exports, key, {
  5239. enumerable: !0,
  5240. get: definition[key],
  5241. })
  5242. }
  5243. __webpack_require__.o = (obj, prop) =>
  5244. Object.prototype.hasOwnProperty.call(obj, prop)
  5245. __webpack_require__(142)
  5246. })()