PageSourceSearch

https://twitchat.fr/assets/LabelsEditor-DD9P754q.js

js twitchat.fr collected 2026-10-04 03:10:06 UTC 13,881 bytes, 3 lines download raw bytes

1import{e as G,A as Z}from"./main-CXxo6Mbi-16.17.4.js";import{C as U,T as H,t as I,B as Y,S,w as F,g as T,d as A,_ as z,r as C,E as q,o as d,c as b,b as g,h as E,l as N,i as K,f as v,F as R,e as P,s as B,a as $,G as J,U as M,j as Q,k as X,K as _,ac as x}from"./storeCommon-B5rHKIdG.js";import{_ as ee}from"./vue-contenteditable.es-C2t02THh.js";import{A as te}from"./ApiHelper-BEUOzmvV.js";import{BlobWriter as se,ZipWriter as le,TextReader as oe}from"https://deno.land/x/[email protected]/index.js";import"./json-CvUwrRud.js";import"./index-DJKgcEvR.js";import"./vue-i18n-CuSJuSql.js";import"./SFXRUtils-l72HvzkJ.js";import"./index-QEDHeLLS.js";import"./SSEHelper-Daop_d89.js";import"./OverlayCounter-BVt9FDxs.js";import"./SetIntervalWorker-DPlpF8Rs.js";import"./InfiniteList-BA_EICS6.js";import"./OverlayMusicPlayer-BpL9FzKU.js";import"./OverlayCustomTrainRenderer-C-KkzsXO.js";var W=Object.defineProperty,ie=Object.getOwnPropertyDescriptor,ne=(t,e,s)=>e in t?W(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,V=(t,e,s,i)=>{for(var r=i>1?void 0:i?ie(e,s):e,h=t.length-1,n;h>=0;h--)(n=t[h])&&(r=(i?n(e,s,r):n(r))||r);return i&&r&&W(e,s,r),r},f=(t,e,s)=>ne(t,typeof e!="symbol"?e+"":e,s);let w=class extends Y{constructor(){super(...arguments),f(this,"value"),f(this,"path"),f(this,"pathToSelect"),f(this,"langRef"),f(this,"labelValue",""),f(this,"showSources",!1),f(this,"defaultLabel","### MISSING LABEL ###"),f(this,"missingLabel",!1),f(this,"uselessLabel",!1),f(this,"uselessCategory",!1),f(this,"opened",!1),f(this,"wasErrored",!1),f(this,"defaultHeight",0),f(this,"prevValue",""),f(this,"originalType","string"),f(this,"clickHandler")}get isLabel(){return typeof this.value=="string"||typeof this.value=="number"||typeof this.value=="boolean"}getUnparsedLabel(e){let i=S.i18n.getLocaleMessage(e);const r=this.path;for(let h=0;h<r.length;h++){const n=r[h];if(i=i[n],i==null)return null}return i}get classes(){const e=["labelseditorentry","card-item"];return this.isArray&&e.push("isArray"),this.uselessCategory&&e.push("uselessCategory"),this.uselessLabel&&e.push("uselessLabel"),this.missingLabel&&e.push("missingLabel"),e}get isArray(){return Array.isArray(this.value)}beforeMount(){this.originalType=typeof this.value,this.initLabel(),this.clickHandler=e=>{let s=e.target;for(;s!=this.$el&&s!=document.body&&s;)s=s.parentElement;s==document.body&&this.close()},document.addEventListener("click",this.clickHandler),F(()=>this.$i18n.locale,()=>{this.initLabel()})}mounted(){this.path.join(".")==(this.pathToSelect||[]).join(".")&&(this.$el.scrollIntoView({behavior:"auto",block:"center"}),T.fromTo(this.$el,{scaleY:1.5,filter:"brightness(4)"},{duration:.5,scaleY:1,ease:"sine.in",filter:"brightness(1)",clearProps:"filter,scaleY",delay:.25,immediateRender:!1}))}beforeUnmount(){document.removeEventListener("click",this.clickHandler)}initLabel(){let e=this.getUnparsedLabel(this.langRef),s=this.getUnparsedLabel(this.$i18n.locale);this.missingLabel=!1,this.uselessLabel=!1,this.isLabel?s==null&&e!=null?(this.missingLabel=!0,this.labelValue=this.defaultLabel):s!=null&&e==null?(this.uselessLabel=!0,this.labelValue=s):this.labelValue=s?.toString()||"":e||(this.uselessCategory=!0)}copyValue(e){const s=this.labelValue==this.defaultLabel;this.wasErrored=s,this.labelValue=e,this.onEditLabel()}open(e){if(this.opened)return;this.opened=!0,this.showSources=!0;const s=this.$el.getBoundingClientRect();this.defaultHeight=s.height,this.$nextTick().then(()=>{T.from(this.$el,{height:this.defaultHeight,duration:.25,clearProps:"height"})})}close(){this.opened&&(this.opened=!1,T.to(this.$el,{height:this.defaultHeight,duration:.25,clearProps:"height",onComplete:()=>{this.showSources=!1}}))}onEditLabel(e=!0,s=!1){let i=S.i18n.getLocaleMessage(this.langRef),r=S.i18n.getLocaleMessage(this.$i18n.locale),h=r,n=[];const c=this.path;for(let l=0;l<c.length;l++){const a=c[l];if(n.push(a),l<c.length-1){let o=!0,p=i;for(const y of n)if(p&&y in p)p=p[y];else{o=!1;break}if(o)h=h[a];else{let y=this.$tm(n.join("."));Array.isArray(y)?h=h[a]=[]:typeof y=="object"?h=h[a]={}:s||(h=y)}}else if(s){delete h[a];continue}else if(this.labelValue!=this.defaultLabel){let o=this.labelValue.replace(/\n/gi,`
2`);this.originalType=="boolean"?o=o==="true":this.originalType=="number"&&(o=parseFloat(o)),h[a]=o}}S.i18n.setLocaleMessage(this.$i18n.locale,r),e&&this.initLabel();const u=this.labelValue==this.defaultLabel;!e&&!s?(this.wasErrored=u,this.prevValue=this.labelValue):(this.wasErrored!=u||this.prevValue!=this.labelValue||s)&&(this.$emit("change"),s&&this.$emit("delete"))}deleteLabel(){this.$confirm("Delete entry?").then(()=>{this.onEditLabel(!1,!0)}).catch(()=>{})}};V([A],w.prototype,"value",2);V([A],w.prototype,"path",2);V([A],w.prototype,"pathToSelect",2);V([A],w.prototype,"langRef",2);w=V([U({name:"LabelsEditorEntry",components:{TTButton:H,CountryFlag:G,contenteditable:ee},emits:["change","delete"]})],w);const ae=I(w),re={class:"header"},he={class:"title"},ce={class:"key"},ue={class:"form"},de={key:0,class:"sources"};function pe(t,e,s,i,r,h){const n=C("TTButton"),c=C("LabelsEditorEntry",!0),u=C("contenteditable"),l=C("CountryFlag"),a=q("tooltip");return t.isLabel?(d(),b("div",{key:1,class:B(["label",t.classes]),onClick:e[7]||(e[7]=o=>t.open(o))},[t.uselessLabel?(d(),E(n,{key:0,icon:"trash",alert:"",light:"",class:"deleteBt",onClick:e[3]||(e[3]=N(o=>t.deleteLabel(),["stop"]))})):K("",!0),g("strong",ce,v(t.path[t.path.length-1]),1),g("div",ue,[(d(),E(u,{class:"text",tag:"div",key:"label_"+t.path.join(),contenteditable:!0,modelValue:t.labelValue,"onUpdate:modelValue":e[4]||(e[4]=o=>t.labelValue=o),"no-html":!0,onFocus:e[5]||(e[5]=o=>{t.onEditLabel(!1),t.labelValue=t.labelValue==t.defaultLabel?"":t.labelValue}),onBlur:e[6]||(e[6]=o=>t.onEditLabel())},null,8,["modelValue"])),t.showSources?(d(),b("div",de,[(d(!0),b(R,null,P(t.$i18n.availableLocales.filter(o=>o!=t.$i18n.locale),o=>(d(),b("div",null,[$(l,{country:t.$t("global.lang_flag",1,{locale:o}),class:"flag"},null,8,["country"]),J($(n,{transparent:"",icon:"copy",onClick:p=>t.copyValue(t.getUnparsedLabel(o)||"")},null,8,["onClick"]),[[a,"Copy value"]]),g("span",null,v(t.getUnparsedLabel(o)),1)]))),256))])):K("",!0)])],2)):(d(),b("div",{key:0,class:B(["section",t.classes])},[g("div",re,[t.uselessCategory?(d(),E(n,{key:0,icon:"trash",alert:"",light:"",class:"deleteBt",onClick:e[0]||(e[0]=N(o=>t.deleteLabel(),["stop"]))})):K("",!0),g("h2",he,v(t.path[t.path.length-1]),1)]),(d(!0),b(R,null,P(t.value,(o,p)=>(d(),E(c,{key:[...t.path,p].join(),onChange:e[1]||(e[1]=y=>t.$emit("change")),onDelete:e[2]||(e[2]=y=>t.$emit("delete")),value:o,langRef:t.langRef,path:[...t.path,p],pathToSelect:t.pathToSelect,"data-test":[...t.path,p].join(".")},null,8,["value","langRef","path","pathToSelect","data-test"]))),128))],2))}const fe=z(ae,[["render",pe],["__scopeId","data-v-b0bc0b68"]]);var ge=Object.defineProperty,be=Object.getOwnPropertyDescriptor,ye=(t,e,s)=>e in t?ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,me=(t,e,s,i)=>{for(var r=i>1?void 0:i?be(e,s):e,h=t.length-1,n;h>=0;h--)(n=t[h])&&(r=n(r)||r);return r},m=(t,e,s)=>ye(t,typeof e!="symbol"?e+"":e,s);let D=class extends Y{constructor(){super(...arguments),m(this,"selectedSectionKey",""),m(this,"selectedSectionLabels",null),m(this,"labelsCurrent",{}),m(this,"labelsRef",{}),m(this,"progresses",{}),m(this,"langRef","en"),m(this,"search",""),m(this,"searchKeys",[]),m(this,"pathToSelect",[]),m(this,"noResult",!1),m(this,"currentErrorIndex",-1)}getProgressClasses(e){const s=[],i=this.progresses[e];return i.done/i.total<.9?s.push("alert"):i.done/i.total<1?s.push("secondary"):i.done/i.total>1?s.push("premium"):s.push("primary"),s}beforeMount(){const e=()=>{this.labelsRef=S.i18n.getLocaleMessage(this.langRef),this.computeProgresses(!0),this.selectedSectionKey&&this.onSelectSection(this.selectedSectionKey,[],!0)};e(),F(()=>this.langRef,()=>e()),F(()=>this.$i18n.locale,()=>{this.computeProgresses(!0),this.selectedSectionKey&&this.onSelectSection(this.selectedSectionKey,[],!0)}),this.computeProgresses()}onSelectSection(e,s=[],i=!1,r){if(r&&(r.ctrlKey||r.metaKey)){this.langRef=e,this.computeProgresses();return}if(this.selectedSectionKey===e&&!i)return;let h=this.labelsRef[e],n=this.labelsCurrent[e];const c=(u,l)=>{let a={...u};for(let o in l)l.hasOwnProperty(o)&&(a.hasOwnProperty(o)?!Array.isArray(a[o])&&!Array.isArray(l[o])&&(typeof a[o]=="object"&&typeof l[o]=="object"?a[o]=c(a[o],l[o]):a[o]=l[o]):a[o]=l[o]);return a};this.selectedSectionLabels=c(h,n),this.selectedSectionKey=e,this.currentErrorIndex=-1,this.pathToSelect=s,this.computeProgresses()}async downloadSection(){const e={};e[this.selectedSectionKey]=this.selectedSectionLabels,M.downloadFile(this.selectedSectionKey+".json",JSON.stringify(e))}async exportZIP(){const e=S.i18n.getLocaleMessage(this.$i18n.locale),s=new se,i=new le(s);for(const h in e){let n={};n[h]=e[h];const c=new oe(JSON.stringify(n));await i.add(h+".json",c)}await i.close();const r=await s.getData();M.downloadFile("labels_"+this.$i18n.locale+".zip",r)}computeProgresses(e=!1){const s=this.labelsRef,i=S.i18n.getLocaleMessage(this.$i18n.locale);if(this.labelsCurrent=i,i==null)return;const r=(n,c=[])=>{let u=[];for(const l in n){const a=[...c,l];Array.isArray(n[l])||(typeof n[l]=="object"&&n[l]!==null&&Object.keys(n[l]).length>0?u=u.concat(r(n[l],a)):u.push(a))}return u},h=this.selectedSectionKey&&!e?[this.selectedSectionKey]:Object.keys(s);for(let n=0;n<h.length;n++){let c=0,u=0;const l=h[n];let a=r(s[l],[l]).concat(r(i[l],[l])),o={};a=a.filter(p=>
2o[p.join(".")]==!0?!1:(o[p.join(".")]=!0,!0));for(let p=0;p<a.length;p++){c++;let y=a[p],L=i,k=s;for(let O=0;O<y.length;O++){const j=y[O];if(L=L[j],k=k[j],k==null){c--;break}else if(L==null||L==""&&k!=""){L=null;break}}L!=null&&L!=null&&u++}this.progresses[l]={done:u,total:c}}}nextError(){this.currentErrorIndex++;const e=document.getElementsByClassName("missingLabel"),s=e[this.currentErrorIndex%e.length],i=s.getBoundingClientRect(),r=document.body.getElementsByClassName("app")[0];T.to(r,{duration:.5,scrollTo:{y:i.top+r.scrollTop-document.body.clientHeight/2.5}}),T.fromTo(s,{scaleY:1.5,filter:"brightness(2)"},{duration:.25,scaleY:1,filter:"brightness(1)",clearProps:"filter,scaleY",delay:.5,immediateRender:!1})}doSearch(){if(this.search.length<2)return;const e=S.i18n.getLocaleMessage(this.$i18n.locale),s=(i,r,h=[])=>{let n=[];for(const c in i){const u=h.concat(c);if(typeof i[c]=="object"){const l=s(i[c],r,u);n=n.concat(l)}else typeof i[c]=="string"&&i[c].toLowerCase().includes(r)&&n.push(u)}return n};this.selectedSectionLabels=null,this.selectedSectionKey="",this.searchKeys=s(e,this.search.toLowerCase()),this.noResult=this.searchKeys.length==0,window.setTimeout(()=>{this.noResult=!1},1e3)}async saveSection(e){if(e||(e=this.selectedSectionKey),!e)return;const s=S.i18n.getLocaleMessage(this.$i18n.locale);let i={section:e,lang:this.$i18n.locale,labels:s[e]};await te.call("admin/labels","POST",i,!1)}};D=me([U({components:{TTButton:H,AppLangSelector:Z,LabelsEditorEntry:fe},emits:[]})],D);const ve=I(D),Se={class:"labelseditor"},Le={class:"head"},$e={class:"sectionList"},Ce={key:0,class:"card-item alert"},we={class:"labels card-item"},Ee={class:"header"},Re={class:"title"},Ke={key:0,class:"floatingActions"},Te=["data-test"],Pe={class:"header"},Ve={class:"title"},ke={class:"content"};function Be(t,e,s,i,r,h){const n=C("AppLangSelector"),c=C("TTButton"),u=C("LabelsEditorEntry");return d(),b("div",Se,[g("div",Le,[$(n,{class:"langSelector",allLocales:"",langRef:t.langRef,"onUpdate:langRef":e[0]||(e[0]=l=>t.langRef=l),showRef:""},null,8,["langRef"]),g("div",$e,[(d(!0),b(R,null,P(t.labelsRef,(l,a)=>(d(),E(c,{key:a,selected:t.selectedSectionKey==a,value:l,parentKey:a,class:B(t.getProgressClasses(a)),onClick:o=>t.onSelectSection(a)},{default:Q(()=>[X(v(a),1)]),_:2},1032,["selected","value","parentKey","class","onClick"]))),128))]),g("form",{class:"searchForm",onSubmit:e[3]||(e[3]=N(l=>t.doSearch(),["prevent"]))},[J(g("input",{"onUpdate:modelValue":e[1]||(e[1]=l=>t.search=l),type:"text",placeholder:"search text...",onKeydown:e[2]||(e[2]=x(l=>{t.search="",t.searchKeys=[]},["esc"]))},null,544),[[_,t.search]]),$(c,{icon:"checkmark",type:"submit"})],32),t.noResult?(d(),b("div",Ce,"No result")):K("",!0)]),t.selectedSectionLabels?(d(),b(R,{key:0},[g("div",{class:B(["card-item progress",t.getProgressClasses(t.selectedSectionKey)])},"Translations done: "+v(t.progresses[t.selectedSectionKey].done)+"/"+v(t.progresses[t.selectedSectionKey].total)+" ("+v((t.progresses[t.selectedSectionKey].done/t.progresses[t.selectedSectionKey].total*100).toFixed(0))+"%)",3),g("div",we,[g("div",Ee,[g("h2",Re,v(t.selectedSectionKey),1)]),(d(!0),b(R,null,P(t.selectedSectionLabels,(l,a)=>(d(),E(u,{key:[t.selectedSectionKey,a].join("."),value:l,langRef:t.langRef,pathToSelect:t.pathToSelect,path:[t.selectedSectionKey,a],onChange:e[4]||(e[4]=o=>{t.computeProgresses(),t.saveSection()}),onDelete:e[5]||(e[5]=o=>{t.computeProgresses(),t.saveSection(),t.onSelectSection(t.selectedSectionKey,[],!0)})},null,8,["value","langRef","pathToSelect","path"]))),128))]),t.progresses[t.selectedSectionKey].done<t.progresses[t.selectedSectionKey].total?(d(),b("div",Ke,[$(c,{icon:"down",alert:"",onClick:e[6]||(e[6]=l=>t.nextError())})])):K("",!0)],64)):t.searchKeys.length>0?(d(!0),b(R,{key:1},P(t.searchKeys,l=>(d(),b("div",{class:"labels card-item search",key:l.join("."),"data-test":l.join(".")},[g("div",Pe,[g("h2",Ve,v(l.slice(0,l.length-1).join(".")),1)]),g("div",ke,[$(u,{value:"",langRef:t.langRef,path:l,onChange:a=>t.saveSection(l[0])},null,8,["langRef","path","onChange"]),$(c,{icon:"newtab",onClick:a=>t.onSelectSection(l[0],l)},null,8,["onClick"])])],8,Te))),128)):K("",!0)])}const Xe=z(ve,[["render",Be],["__scopeId","data-v-c795bbe8"]]);export{Xe as default};
3//# sourceMappingURL=LabelsEditor-DD9P754q.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.