Files
TwitchNotes/extension/twitch-notes.js

1 line
31 KiB
JavaScript

(()=>{"use strict";var t={144:(t,e,n)=>{n.d(e,{Z:()=>a});var o=n(81),i=n.n(o),r=n(645),s=n.n(r)()(i());s.push([t.id,".twitch-note-container{position:fixed;z-index:1000000;min-width:420px;max-width:95vw;min-height:240px;max-height:50vh;background:var(--color-background-base);border:var(--border-width-default) solid var(--color-border-base) !important}.twitch-note-header{width:100%;height:32px;line-height:32px;border-bottom:var(--border-width-default) solid var(--color-border-base) !important;position:relative;cursor:move}.twitch-note-title{color:var(--color-text-alt) !important;font-size:var(--font-size-6) !important;font-weight:var(--font-weight-semibold) !important;text-transform:uppercase !important;padding-left:calc((32px - var(--font-size-6))/2)}.twitch-note-close-button{position:absolute;right:5px;top:5px;width:22px;height:22px;line-height:22px;text-align:center;aspect-ratio:1;color:var(--color-text-alt) !important;font-size:var(--font-size-6) !important;font-weight:var(--font-weight-semibold) !important;text-transform:uppercase !important;cursor:pointer}.twitch-note-content{position:absolute;top:32px;left:0;right:0;bottom:32px;background:rgba(0,0,0,0);color:var(--color-text-base) !important;font-family:var(--font-base);vertical-align:baseline;outline:none;overflow:auto;padding:calc((32px - var(--font-size-6))/2)}.twitch-note-save-button{position:absolute;bottom:0;left:0;right:0;height:32px;border-top:var(--border-width-default) solid var(--color-border-base) !important;cursor:pointer;color:var(--color-text-alt) !important;font-size:var(--font-size-6) !important;font-weight:var(--font-weight-semibold) !important;text-transform:uppercase !important;text-align:center;line-height:32px}.twitch-notes-settings-button{z-index:var(--z-index-default) !important;position:relative !important;background-color:var(--color-background-button-primary-default);color:var(--color-text-button-primary);text-decoration:none;cursor:pointer;display:inline-flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;vertical-align:middle;overflow:hidden;white-space:nowrap;user-select:none;font-weight:var(--font-weight-semibold);border-radius:var(--border-radius-medium);font-size:var(--button-text-default);height:var(--button-size-default);padding:0 var(--button-padding-x)}.twitch-notes-settings-button__outline{background:rgba(0,0,0,0);border:2px solid var(--color-text-button-primary)}.twitch-notes-settings-container{border:0;font:inherit;padding:0;vertical-align:baseline;position:fixed;z-index:var(--z-index-balloon);inset:auto 0 0 auto;margin:0 69px 48px 0}.twitch-notes-settings-balloon{display:inline-block;max-width:90vw;min-width:0;white-space:nowrap;border-radius:.6rem !important;background-color:var(--color-background-base) !important;box-shadow:var(--shadow-elevation-2) !important;color:inherit !important}.twitch-notes-settings-popover{white-space:normal;width:32rem}.twitch-notes-settings-header{display:flex !important;-webkit-box-align:center !important;align-items:center !important;position:relative !important;padding-left:1rem !important;padding-right:1rem !important;background-color:var(--color-background-base) !important;min-height:4rem}.twitch-notes-settings-header-left-element{left:0 !important;margin-right:.5rem !important;width:3rem}.twitch-notes-settings-header-center-element{-webkit-box-align:center !important;align-items:center !important;display:flex !important;text-align:center !important;-webkit-box-flex:1 !important;flex-grow:1 !important;-webkit-box-pack:center !important;justify-content:center !important}.twitch-notes-settings-header-center-element-content{line-height:1.5;color:var(--color-text-alt) !important;font-size:var(--font-size-5) !important;font-weight:var(--font-weight-semibold) !important}.twitch-notes-settings-header-right-element{right:0 !important;margin-left:.5rem !important}.twitch-notes-settings-close-button{cursor:default;text-transform:none;text-indent:0;text-shadow:none;letter-spacing:normal;text-rendering:auto;appearance:auto;writing-mode:horizontal-tb !important;box-sizing:border-box;margin:0;font:inherit;border:none;font-size:var(--button-text-default);font-weight:var(--font-weight-semibold);vertical-align:middle;overflow:hidden;text-decoration:none;white-space:nowrap;position:relative;display:inline-flex;-webkit-box-align:center;align-items:center;-webkit-box-pack:center;justify-content:center;user-select:none;border-radius:var(--border-radius-medium);height:calc(var(--button-size-default) - 1rem);width:calc(var(--button-size-default) - 1rem);background-color:var(--color-background-button-text-default);color:var(--color-fill-button-icon)}.twitch-notes-settings-scrollable-area{display:flex;overflow:hidden;z-index:0;height:100%;position:relative;max-height:478px}.twitch-notes-settings-content{box-sizing:content-box;min-width:100%;overflow-x:hidden;overflow-y:auto;max-height:inherit !important;margin:1rem;padding-bottom:0 !important}.twitch-notes-settings-option-line{position:relative !important;width:calc(100% - 2rem) !important}.twitch-notes-settings-option-line-button{border-radius:var(--border-radius-medium);display:block;width:100%;color:inherit}.twitch-notes-settings-option-line-button:hover{cursor:pointer;text-decoration:none;color:inherit;background-color:var(--color-background-interactable-hover)}.twitch-notes-settings-option-line-button-container{display:flex !important;-webkit-box-align:center !important;align-items:center !important;position:relative !important;padding:.5rem !important}.twitch-notes-settings-option-line-button-container-content{-webkit-box-flex:1 !important;flex-grow:1 !important}.twitch-note-settings-separator{border-top:1px solid var(--color-border-base);margin-top:1rem !important;margin-left:.5rem !important;margin-right:.5rem !important;padding-bottom:1rem !important}.twitch-notes-x-button{position:absolute;left:0;width:100%;min-height:100%;top:0;fill:currentcolor}.twitch-notes-blurred-background{position:fixed;inset:0 0 0 0;z-index:2000000;background:rgba(0,0,0,.4);backdrop-filter:blur(2px)}.twitch-notes-center-floating-container{background:var(--color-background-base);border:var(--border-width-default) solid var(--color-border-base) !important;padding:4rem 2rem 2rem;position:fixed;top:50vh;left:50vw;transform:translate(-50%, -50%);max-height:90vh;max-width:90vw;overflow:auto}.twitch-notes-user-list-user{padding:1rem;border-bottom:var(--border-width-default) solid var(--color-border-base) !important;cursor:pointer}.twitch-notes-user-list-user[data-active]{background:rgba(119,44,232,.2)}",""]);const a=s},645:t=>{t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",o=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),o&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),o&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,o,i,r){"string"==typeof t&&(t=[[null,t,void 0]]);var s={};if(o)for(var a=0;a<this.length;a++){var l=this[a][0];null!=l&&(s[l]=!0)}for(var c=0;c<t.length;c++){var d=[].concat(t[c]);o&&s[d[0]]||(void 0!==r&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=r),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),i&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=i):d[4]="".concat(i)),e.push(d))}},e}},81:t=>{t.exports=function(t){return t[1]}},379:t=>{var e=[];function n(t){for(var n=-1,o=0;o<e.length;o++)if(e[o].identifier===t){n=o;break}return n}function o(t,o){for(var r={},s=[],a=0;a<t.length;a++){var l=t[a],c=o.base?l[0]+o.base:l[0],d=r[c]||0,u="".concat(c," ").concat(d);r[c]=d+1;var p=n(u),h={css:l[1],media:l[2],sourceMap:l[3],supports:l[4],layer:l[5]};if(-1!==p)e[p].references++,e[p].updater(h);else{var m=i(h,o);o.byIndex=a,e.splice(a,0,{identifier:u,updater:m,references:1})}s.push(u)}return s}function i(t,e){var n=e.domAPI(e);return n.update(t),function(e){if(e){if(e.css===t.css&&e.media===t.media&&e.sourceMap===t.sourceMap&&e.supports===t.supports&&e.layer===t.layer)return;n.update(t=e)}else n.remove()}}t.exports=function(t,i){var r=o(t=t||[],i=i||{});return function(t){t=t||[];for(var s=0;s<r.length;s++){var a=n(r[s]);e[a].references--}for(var l=o(t,i),c=0;c<r.length;c++){var d=n(r[c]);0===e[d].references&&(e[d].updater(),e.splice(d,1))}r=l}}},569:t=>{var e={};t.exports=function(t,n){var o=function(t){if(void 0===e[t]){var n=document.querySelector(t);if(window.HTMLIFrameElement&&n instanceof window.HTMLIFrameElement)try{n=n.contentDocument.head}catch(t){n=null}e[t]=n}return e[t]}(t);if(!o)throw new Error("Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid.");o.appendChild(n)}},216:t=>{t.exports=function(t){var e=document.createElement("style");return t.setAttributes(e,t.attributes),t.insert(e,t.options),e}},565:(t,e,n)=>{t.exports=function(t){var e=n.nc;e&&t.setAttribute("nonce",e)}},795:t=>{t.exports=function(t){var e=t.insertStyleElement(t);return{update:function(n){!function(t,e,n){var o="";n.supports&&(o+="@supports (".concat(n.supports,") {")),n.media&&(o+="@media ".concat(n.media," {"));var i=void 0!==n.layer;i&&(o+="@layer".concat(n.layer.length>0?" ".concat(n.layer):""," {")),o+=n.css,i&&(o+="}"),n.media&&(o+="}"),n.supports&&(o+="}");var r=n.sourceMap;r&&"undefined"!=typeof btoa&&(o+="\n/*# sourceMappingURL=data:application/json;base64,".concat(btoa(unescape(encodeURIComponent(JSON.stringify(r))))," */")),e.styleTagTransform(o,t,e.options)}(e,t,n)},remove:function(){!function(t){if(null===t.parentNode)return!1;t.parentNode.removeChild(t)}(e)}}}},589:t=>{t.exports=function(t,e){if(e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}}},e={};function n(o){var i=e[o];if(void 0!==i)return i.exports;var r=e[o]={id:o,exports:{}};return t[o](r,r.exports,n),r.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.nc=void 0,(()=>{var t=n(379),e=n.n(t),o=n(795),i=n.n(o),r=n(569),s=n.n(r),a=n(565),l=n.n(a),c=n(216),d=n.n(c),u=n(589),p=n.n(u),h=n(144),m={};m.styleTagTransform=p(),m.setAttributes=l(),m.insert=s().bind(null,"head"),m.domAPI=i(),m.insertStyleElement=d(),e()(h.Z,m),h.Z&&h.Z.locals&&h.Z.locals;var v="twitch-note-all-users-list",f="twitch-note-";const g=function(){function t(){}return t.getSavedUserList=function(){return JSON.parse(localStorage.getItem(v)||"[]")},t.getNote=function(t){return localStorage.getItem(f+t)||""},t.addUserToSavedList=function(t){var e=this.getSavedUserList();e.includes(t)||(e.push(t),localStorage.setItem(v,JSON.stringify(e)))},t.removeUserFromSavedList=function(t){var e=this.getSavedUserList();(e=e.filter((function(e){return e!==t}))).length?localStorage.setItem(v,JSON.stringify(e)):localStorage.removeItem(v)},t.saveNote=function(t,e){this.addUserToSavedList(t),localStorage.setItem(f+t,e)},t.deleteNote=function(t){this.removeUserFromSavedList(t),localStorage.removeItem(f+t)},t.exportNotes=function(){var t=this,e={users:this.getSavedUserList(),notes:this.getSavedUserList().map((function(e){return{user:e,note:t.getNote(e)}})),settings:{}},n=JSON.stringify(e),o=new Blob([n],{type:"text/json"}),i=window.document.createElement("a");i.href=window.URL.createObjectURL(o),i.download="twitch-notes-"+Date.now()+".json",document.body.appendChild(i),i.click(),document.body.removeChild(i)},t.clearData=function(){for(var t=0,e=this.getSavedUserList();t<e.length;t++){var n=e[t];this.deleteNote(n)}},t.inputData={users:[],notes:[],settings:{}},t}();var b,w,y=(b=function(t,e){return b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},b(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),x=function(){function t(t,e){if(this.element=document.createElement(t),e.id?this.setId(e.id):this.setId(t+"-generated-id-"+Math.floor(1e7*Math.random())),e.class)if("string"==typeof e.class)this.addClass(e.class);else for(var n=0,o=e.class;n<o.length;n++){var i=o[n];this.addClass(i)}if(e.attributes)for(var r in e.attributes)this.addAttribute(r,e.attributes[r]);e.css&&this.setStyle(e.css),e.body&&("string"==typeof e.body?this.setBody(e.body):this.appendChild(e.body)),e.customBody&&this.appendCustomChild(e.customBody)}return t.prototype.setId=function(t){return this.element.id=t,this},t.prototype.addClass=function(t){return this.element.classList.add(t),this},t.prototype.addAttribute=function(t,e){return this.element.setAttribute(t,e),this},t.prototype.setStyle=function(t){for(var e in t)this.element.style[e]=t[e]||"";return this},t.prototype.setBody=function(t){return this.element.innerHTML=t,this},t.prototype.appendBody=function(t){return this.element.innerHTML+=t,this},t.prototype.appendChild=function(t){return this.element.appendChild(t),this},t.prototype.appendCustomChild=function(t){return this.element.appendChild(t.getElement()),this},t.prototype.getElement=function(){return this.element},t.prototype.setClickListener=function(t){return this.element.addEventListener("click",(function(){return t()})),this},t.prototype.setChangeListener=function(t){return this.element.addEventListener("change",(function(){return t()})),this},t.prototype.setMouseMoveListener=function(t){return this.element.addEventListener("mousemove",(function(){return t()})),this},t.prototype.setMouseDownListener=function(t){return this.element.addEventListener("mousedown",(function(){return t()})),this},t.prototype.setMouseUpListener=function(t){return this.element.addEventListener("mouseup",(function(){return t()})),this},t.prototype.remove=function(){this.element.remove()},t.prototype.show=function(){return this.setStyle({display:"unset"}),this},t.prototype.hide=function(){return this.setStyle({display:"none"}),this},t}(),C=function(t){function e(e,n){return void 0===e&&(e=""),void 0===n&&(n=""),t.call(this,"div",{class:e,body:n})||this}return y(e,t),e}(x),S=function(t){function e(e){return void 0===e&&(e=""),t.call(this,"input",{class:e})||this}return y(e,t),e}(x),L=function(t){function e(e,n){return void 0===e&&(e=""),void 0===n&&(n=""),t.call(this,"p",{class:e,body:n})||this}return y(e,t),e}(x),k=function(t){function e(e,n){return void 0===e&&(e=""),void 0===n&&(n=""),t.call(this,"button",{class:e,body:n})||this}return y(e,t),e}(x),E=function(t){function e(e,n){return void 0===e&&(e=""),void 0===n&&(n=""),t.call(this,"a",{class:e,body:n})||this}return y(e,t),e}(x),M=function(t){function e(e,n){return void 0===e&&(e=""),void 0===n&&(n=""),t.call(this,"span",{class:e,body:n})||this}return y(e,t),e}(x);function N(t,e){for(var n,o,i,r=[],s=[],a=[],l=function(t){g.getNote(t)?(null===(n=g.inputData.notes.find((function(e){return e.user===t})))||void 0===n?void 0:n.resolved)||g.getNote(t)!==(null===(o=g.inputData.notes.find((function(e){return e.user===t})))||void 0===o?void 0:o.note)?s.push(t):a.push(t):r.push(t)},c=0,d=g.inputData.users;c<d.length;c++)l(d[c]);var u=new C;if(s.length){var p=new C("","<strong>Note conflicts found for:</strong><br />");p.setStyle({marginTop:"1rem"});for(var h=function(n){var o=new C("",n+" "),r=null===(i=g.inputData.notes.find((function(t){return t.user===n})))||void 0===i?void 0:i.resolved;o.setStyle({color:r?"green":"red"});var s=new E("",r?"[update]":"[resolve]");s.setStyle({cursor:"pointer"}),s.setClickListener((function(){!function(t,e,n,o){var i=new C("twitch-notes-blurred-background"),r=new C("twitch-notes-center-floating-container","<strong>Select which note to keep for <em>"+t+"</em></strong><br /><em>You can modify notes to merge them and keep updated one</em><br /><br />"),s=new C;s.setStyle({display:"flex",flexDirection:"row",flexWrap:"no-wrap",width:"100%"});var a={minWidth:"320px",padding:"6px",border:"1px solid #FFFFFF19",outline:"none"},l=["contentEditable","true"],c=new C,d=new L("","<strong>Locally saved note</strong>");c.appendCustomChild(d);var u=new C;u.setStyle(a),u.addAttribute.apply(u,l),u.setId("local-value-container");var p=new k("twitch-notes-settings-button","Save this");p.setClickListener((function(){var r,s=(null===(r=document.getElementById("local-value-container"))||void 0===r?void 0:r.innerHTML)||"";g.inputData.notes=g.inputData.notes.map((function(e){return e.user===t?{user:e.user,note:s,resolved:!0}:e})),i.remove(),e.remove(),N(n,o)})),c.appendCustomChild(u),c.appendBody("<br />"),c.appendCustomChild(p);var h=new C,m=new L("","<strong>Imported note</strong>");h.appendCustomChild(m);var v=new C("",g.inputData.notes.filter((function(e){return e.user===t}))[0].note||"");v.setId("import-value-container"),v.setStyle(a),v.addAttribute.apply(v,l);var f=new k("twitch-notes-settings-button","Save this");f.setClickListener((function(){var r,s=(null===(r=document.getElementById("import-value-container"))||void 0===r?void 0:r.innerHTML)||"";g.inputData.notes=g.inputData.notes.map((function(e){return e.user===t?{user:e.user,note:s,resolved:!0}:e})),i.remove(),e.remove(),N(n,o)})),h.appendCustomChild(v),h.appendBody("<br />"),h.appendCustomChild(f),s.appendCustomChild(c),s.appendCustomChild(h),r.appendCustomChild(s),i.appendCustomChild(r),document.body.appendChild(i.getElement())}(n,u,t,e)})),o.appendCustomChild(s),p.appendCustomChild(o)},m=0,v=s;m<v.length;m++)h(v[m]);u.appendCustomChild(p)}if(r.length){var f=new C("","<strong>Note will be added for:</strong><br />"+r.join("<br />"));f.setStyle({marginTop:"1rem",color:"white"}),u.appendCustomChild(f)}if(a.length){var b=new C("","<strong>No changes for:</strong><br />"+a.join("<br />"));b.setStyle({marginTop:"1rem",color:"gray"}),u.appendCustomChild(b)}var w=new C;w.setStyle({height:"24px"}),u.appendCustomChild(w),s=s.filter((function(t){var e;return!(null===(e=g.inputData.notes.find((function(e){return e.user===t})))||void 0===e?void 0:e.resolved)}));var y=new k("twitch-notes-settings-button","Complete import");if(y.setStyle({}),s.length>0&&y.setStyle({background:"gray"}),s.length>0&&y.addAttribute("disabled","true"),u.appendCustomChild(y),s.length>0){var x=new C("","<em>Import cannot be completed while there are unresolved conflicts</em>");x.setStyle({color:"gray"}),u.appendCustomChild(x)}else y.setClickListener((function(){for(var t=0,n=g.inputData.notes;t<n.length;t++){var o=n[t];g.saveNote(o.user,o.note)}e.remove(),g.inputData={users:[],notes:[],settings:{}}}));t.appendCustomChild(u)}function T(t,e){return{element:"div",class:"twitch-notes-settings-option-line",content:[{element:"button",class:"twitch-notes-settings-option-line-button",content:[{element:"div",class:"twitch-notes-settings-option-line-button-container",content:[{element:"div",class:"twitch-notes-settings-option-line-button-container-content",content:[t]}]}]}],mouseClickEvent:function(){return e?e():function(){}}}}y((function(t,e){return void 0===t&&(t=""),void 0===e&&(e=""),w.call(this,"img",{class:t,body:e})||this}),w=x);const U=function(){function t(t){var e;this.element=document.createElement(t.element),this.setId(null!==(e=t.id)&&void 0!==e?e:t.element+"-custom-element-"+Math.floor(1e6*Math.random())),t.class&&this.setClasses(t.class),t.attributes&&this.setAttributes(t.attributes),t.style&&this.setStyles(t.style),t.mouseClickEvent&&this.setMouseClickListener(t.mouseClickEvent),t.mouseMoveEvent&&this.setMouseClickListener(t.mouseMoveEvent),t.mouseDownEvent&&this.setMouseClickListener(t.mouseDownEvent),t.mouseUpEvent&&this.setMouseClickListener(t.mouseUpEvent),t.keyUpEvent&&this.setKeyUpListener(t.keyUpEvent),t.content&&this.setContent(t.content)}return t.prototype.setId=function(t){this.element.id=t},t.prototype.setClasses=function(t){if("string"==typeof t)this.addClass(t);else for(var e=0,n=t;e<n.length;e++){var o=n[e];this.addClass(o)}},t.prototype.addClass=function(t){this.element.classList.add(t)},t.prototype.setAttributes=function(t){for(var e in t)t[e]&&this.addAttribute(e,t[e])},t.prototype.addAttribute=function(t,e){this.element.setAttribute(t,e)},t.prototype.setStyles=function(t){for(var e in t)this.addStyle(e,t[e]||"")},t.prototype.addStyle=function(t,e){this.element.style.setProperty(t,e)},t.prototype.setMouseClickListener=function(t){this.element.addEventListener("click",(function(){return t()}))},t.prototype.setContent=function(t){for(var e=0,n=t;e<n.length;e++){var o=n[e];this.addContent(o)}},t.prototype.addContent=function(e){if("string"==typeof e)this.element.innerHTML+=e;else{var n=new t(e);this.element.appendChild(n.element)}},t.prototype.setMouseMoveListener=function(t){this.element.addEventListener("mousemove",(function(){return t()}))},t.prototype.setMouseDownListener=function(t){this.element.addEventListener("mousedown",(function(){return t()}))},t.prototype.setMouseUpListener=function(t){this.element.addEventListener("mouseup",(function(){return t()}))},t.prototype.setKeyUpListener=function(t){var e=this;this.element.addEventListener("keyup",(function(){return t(e.element.innerHTML)}))},t.prototype.getElement=function(){return this.element},t.prototype.remove=function(){this.element.remove()},t}();function D(){var t=document.querySelector(".twitch-notes-settings-container");if(t)t.remove();else{var e={element:"div",class:"twitch-notes-settings-container",content:[{element:"div",class:"twitch-notes-settings-balloon",content:[{element:"div",class:"twitch-notes-settings-popover",content:[{element:"div",class:"twitch-notes-settings-header",content:[{element:"div",class:"twitch-notes-settings-header-left-element"},{element:"div",class:"twitch-notes-settings-header-center-element",content:[{element:"p",class:"twitch-notes-settings-header-center-element-content",content:["Twitch Notes Settings"]}]},{element:"div",class:"twitch-notes-settings-header-right-element",content:[{element:"button",class:"twitch-notes-settings-close-button",content:['<svg width="100%" height="100%" viewBox="0 0 20 20" x="0px" y="0px" class="twitch-notes-x-button">\n <g>\n <path d="M8.5 10L4 5.5 5.5 4 10 8.5 14.5 4 16 5.5 11.5 10l4.5 4.5-1.5 1.5-4.5-4.5L5.5 16 4 14.5 8.5 10z"></path>\n </g>\n </svg>'],mouseClickEvent:function(){return D()}}]}]},{element:"div",class:"twitch-notes-settings-scrollable-area",content:[{element:"div",class:"twitch-notes-settings-content",content:[T("Export Notes",(function(){g.exportNotes(),D()})),T("Import Notes",(function(){!function(){var t=new C("twitch-notes-blurred-background"),e=new C("twitch-notes-center-floating-container","<strong>WARNING!</strong> <em>This action might override existing data!</em><br /><br />"),n=new C("","Select exported twitch notes file<br /><br />"),o=new S("twitch-notes-file-input");o.addAttribute("type","file").addAttribute("accept","json");var i=new k("twitch-notes-settings-close-button",'<svg width="100%" height="100%" viewBox="0 0 20 20" x="0px" y="0px" class="twitch-notes-x-button">\n <g>\n <path d="M8.5 10L4 5.5 5.5 4 10 8.5 14.5 4 16 5.5 11.5 10l4.5 4.5-1.5 1.5-4.5-4.5L5.5 16 4 14.5 8.5 10z"></path>\n </g>\n </svg>');i.setStyle({position:"absolute",top:"1rem",right:"1rem"}),n.appendCustomChild(o),i.setClickListener((function(){t.remove()})),o.setChangeListener((function(){var i;if(null===(i=null==o?void 0:o.getElement())||void 0===i?void 0:i.files){var r=o.getElement().files.item(0);if(r){var s=new FileReader;s.readAsText(r,"UTF-8"),s.onload=function(o){var i;(null===(i=null==o?void 0:o.target)||void 0===i?void 0:i.result)&&(g.inputData=JSON.parse(o.target.result.toString()),g.inputData&&(n.setStyle({display:"none"}),N(e,t)))},s.onerror=function(){console.error("error reading file")}}}})),e.appendCustomChild(i),e.appendCustomChild(n),t.appendCustomChild(e),document.body.appendChild(t.getElement())}(),D()})),T("Clear Data",(function(){!function(){var t=new C("twitch-notes-blurred-background"),e=new C("twitch-notes-center-floating-container","<strong>This action will delete all saved notes!</strong><br /><br /><em>Consider exporting notes before performing this action in case you will need to use notes again</em>"),n=new C;n.setStyle({height:"24px"});var o=new k("twitch-notes-settings-button","DELETE ALL NOTES");o.setStyle({background:"red"}),o.setClickListener((function(){g.clearData(),t.remove()}));var i=new k("twitch-notes-settings-button","Cancel");i.setClickListener((function(){t.remove()})),e.appendCustomChild(n),e.appendCustomChild(o),e.appendCustomChild(i),t.appendCustomChild(e),document.body.appendChild(t.getElement())}(),D()})),{element:"div",class:"twitch-note-settings-separator"},T("View All Notes",(function(){!function(){var t="",e=new C("twitch-notes-blurred-background"),n=new M("","Note saved!");n.setStyle({color:"green",marginLeft:"2rem"}),n.hide();var o=new C("twitch-notes-center-floating-container");o.setStyle({padding:"0",paddingTop:"1rem",width:"100%",maxWidth:"800px",height:"calc(320px + 5rem)",maxHeight:"90vh"});var i=new k("twitch-notes-settings-close-button",'<svg width="100%" height="100%" viewBox="0 0 20 20" x="0px" y="0px" class="twitch-notes-x-button">\n <g>\n <path d="M8.5 10L4 5.5 5.5 4 10 8.5 14.5 4 16 5.5 11.5 10l4.5 4.5-1.5 1.5-4.5-4.5L5.5 16 4 14.5 8.5 10z"></path>\n </g>\n </svg>');i.setStyle({position:"absolute",top:"1rem",right:"1rem"});var r=new C("twitch-note-title","Notes:");r.setStyle({borderBottom:"1px solid #FFFFFF19",paddingBottom:"1rem"}),o.appendCustomChild(r);var s=new C;s.setStyle({display:"flex",flexDirection:"row",flexWrap:"no-wrap",width:"100%",height:"320px"}),o.appendCustomChild(s),i.setClickListener((function(){e.remove()})),o.appendCustomChild(i);var a=new C;a.setStyle({borderRight:"1px solid #FFFFFF19",height:"320px",minWidth:"240px",overflowY:"auto",overflowX:"hidden"});var l=new C;l.setStyle({height:"320px",padding:"1rem",width:"100%",opacity:"0"});var c=new C;c.setStyle({marginBottom:"3rem",border:"1px solid #FFFFFF19",height:"calc(320px - 7rem)",width:"100%",padding:"6px",outline:"none",overflowY:"auto",overflowX:"hidden"}),c.addAttribute("contentEditable","true");var d=new k("twitch-notes-settings-button","Save Note");d.setStyle({position:"absolute",bottom:"1rem",left:"1rem"}),d.setClickListener((function(){t&&(g.saveNote(t,c.getElement().innerHTML),n.setStyle({display:"inline-block"}))}));for(var u=function(e){var o=new C("twitch-notes-user-list-user",e);o.setClickListener((function(){for(var i,r=document.getElementsByClassName("twitch-notes-user-list-user"),s=0;s<r.length;s++)null===(i=r.item(s))||void 0===i||i.removeAttribute("data-active");n.hide(),o.addAttribute("data-active","true"),l.setStyle({opacity:"1"}),c.getElement().innerHTML=g.getNote(e),t=e})),a.appendCustomChild(o)},p=0,h=g.getSavedUserList();p<h.length;p++)u(h[p]);l.appendCustomChild(c),l.appendCustomChild(d),l.appendCustomChild(n),s.appendCustomChild(a),s.appendCustomChild(l),e.appendCustomChild(o),document.body.appendChild(e.getElement())}(),D()}))]}]}]}]}]},n=new U(e);document.body.appendChild(n.getElement())}}const F={activeContainer:"",containers:{},addContainer:function(t,e){this.containers[t]||(this.containers[t]=e)},removeContainer:function(t){this.containers[t]&&(this.containers[t].remove(),delete this.containers[t])}};var z=function(){return z=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},z.apply(this,arguments)};const I=function(){function t(){}return t.setupListeners=function(){t.listenersSetUp||(document.addEventListener("mousemove",t.handleMouseMove),document.addEventListener("mouseup",t.handleMouseUp),t.listenersSetUp=!0)},t.handleMouseUp=function(){F.activeContainer="",t.isMouseDown=!1},t.updateMousePosition=function(e,n){t.lastMousePosition=z({},this.mousePosition),t.mousePosition={x:e,y:n}},t.handleMouseMove=function(e){if(t.isMouseDown&&F.activeContainer){var n=t.mousePosition.x-t.lastMousePosition.x,o=t.mousePosition.y-t.lastMousePosition.y;F.containers[F.activeContainer].setStyles({top:parseInt(F.containers[F.activeContainer].getElement().style.top)+o+"px",left:parseInt(F.containers[F.activeContainer].getElement().style.left)+n+"px"})}t.updateMousePosition(e.clientX,e.clientY)},t.isMouseDown=!1,t.mousePosition={x:0,y:0},t.lastMousePosition={x:0,y:0},t.listenersSetUp=!1,t}();var A=function(){function t(){this.observer=null}return t.prototype.init=function(t){var e=this;this.chatContainerNode=t,this.startObserver(t),this.addNotesButton(),setTimeout((function(){e.addUserNoteBadges()}),1e3)},t.prototype.startObserver=function(t){var e=this;this.observer&&this.observer.disconnect();var n=!1;this.observer=new MutationObserver((function(t){if(!n)for(var o=0,i=t;o<i.length;o++)"childList"===i[o].type&&(n=!0,e.addUserNoteBadges(),n=!1)})),this.observer.observe(t,{attributes:!0,childList:!0,subtree:!0})},t.prototype.addNotesButton=function(){var t=this,e=document.querySelector(".".concat("chat-input__buttons-container"));if(e){var n=new U({element:"div",style:{marginLeft:"0.5rem !important"},content:[{element:"div",style:{display:"inline-flex !important"},content:[{element:"button",class:["twitch-notes-settings-button","twitch-notes-settings-button__outline"],content:["Notes"],mouseClickEvent:function(){return D()}}]}]});e.lastChild?e.lastChild.insertBefore(n.getElement(),e.lastChild.lastChild):e.appendChild(n.getElement())}else setTimeout((function(){return t.addNotesButton()}),100)},t.prototype.addUserNoteBadges=function(){for(var t=document.getElementsByClassName("chat-line__message"),e=function(e){var n=t.item(e);if(!n)return"continue";var o=n.querySelector(".chat-author__display-name");if(!o)return"continue";var i=n.querySelector(".chat-line__username-container");if(!i)return"continue";var r=o.getAttribute("data-a-user");if(r&&!i.querySelector(".twitch-note")){var s=new U({element:"span",class:"twitch-note",style:{cursor:"pointer"},mouseClickEvent:function(){return function(t){if(!F.containers[t]){var e=g.getNote(t),n={element:"div",class:"twitch-note-container",style:{left:I.mousePosition.x+"px",top:I.mousePosition.y+10+"px"},content:[{element:"div",class:"twitch-note-header",mouseDownEvent:function(){F.activeContainer=t,I.isMouseDown=!0},content:[{element:"span",class:"twitch-note-close-button",content:['<svg width="100%" height="100%" viewBox="0 0 20 20" x="0px" y="0px" class="twitch-notes-x-button">\n <g>\n <path d="M8.5 10L4 5.5 5.5 4 10 8.5 14.5 4 16 5.5 11.5 10l4.5 4.5-1.5 1.5-4.5-4.5L5.5 16 4 14.5 8.5 10z"></path>\n </g>\n </svg>'],mouseClickEvent:function(){return F.removeContainer(t)}},{element:"span",class:"twitch-note-title",content:[t]}]},{element:"div",class:"twitch-note-content",content:[g.getNote(t)],attributes:{contentEditable:"true"},keyUpEvent:function(t){e=t}},{element:"div",class:"twitch-note-save-button",content:["SAVE"],mouseClickEvent:function(){g.saveNote(t,e),F.removeContainer(t)}}]},o=new U(n);document.body.appendChild(o.getElement()),F.addContainer(t,o)}}(r)},content:[{element:"img",style:{height:"18px",paddingRight:"4px"},attributes:{src:"https://cdn.rdarius.lt/icons/32-id-card.png"}}]});i.insertBefore(s.getElement(),i.firstChild)}},n=0;n<t.length;n++)e(n)},t}(),B=new A,_=!1,O="";setInterval((function(){var t=window.location.href;if(O!==t)return O=t,void(_=!1);var e=document.querySelector(".".concat("chat-scrollable-area__message-container"));e?(_||(B.init(e),I.setupListeners()),_=!0):_=!1}),1e3)})()})();