From 845e38cae84a012f13ea5fb7179f54a37f1db44c Mon Sep 17 00:00:00 2001 From: Physton Date: Fri, 14 Jul 2023 17:02:12 +0800 Subject: [PATCH] #151 New Feature: API KEY Masking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新功能:API KEY 脱敏处理。前端和API接口中,用*号代替。 --- javascript/main.entry.js | 2 +- javascript/main.entry.js.map | 2 +- scripts/on_app_started.py | 25 ++++-- scripts/physton_prompt/gen_openai.py | 2 + scripts/physton_prompt/get_translate_apis.py | 80 ++++++++++++++++++++ scripts/physton_prompt/storage.py | 10 ++- scripts/physton_prompt/translate.py | 7 +- src/src/components/chatgptPrompt.vue | 11 +-- tests/privacy_api_config.py | 23 ++++++ translate_apis.json | 78 ++++++++++++------- 10 files changed, 196 insertions(+), 44 deletions(-) create mode 100644 tests/privacy_api_config.py diff --git a/javascript/main.entry.js b/javascript/main.entry.js index bba2928..dbbf1b0 100644 --- a/javascript/main.entry.js +++ b/javascript/main.entry.js @@ -53,7 +53,7 @@ sfsdfsdf complete!`,setTimeout(this.close,2e3)),this.scrollToBottom()},n=()=>{let i=e.shift();if(!i)return t(!0);this.gradioAPI.installPackage(i.name,i.package).then(r=>{this.result+=`${r.message} `,r.state?(this.scrollToBottom(),n()):t(!1)}).catch(r=>{console.log(r),this.result+=`${i.name} install failed ${r.message} -`,t(!1)})};n()},scrollToBottom(){this.$nextTick(()=>{this.$refs.result.scrollTop=this.$refs.result.scrollHeight})},onTodayNotShowChange(){this.todayNotShow=!this.todayNotShow,this.gradioAPI.setData("packagesStateTodayNotShow",new Date().toLocaleDateString())},open(){this.gradioAPI.getData("packagesStateTodayNotShow").then(e=>{e&&e===new Date().toLocaleDateString()?this.close():(this.result="",this.loading=!1,this.showResult=!1,this.isOpen=!0)}).catch(e=>{})},close(){this.isOpen=!1}}},l0={class:"today-now-show"},u0=["value"],c0={class:"state-body-name"},f0=["innerHTML"],d0={class:"package-list"},p0={class:"package-name"},h0={class:"package-command"},g0={key:0,class:"install-result"};function m0(e,t,n,i,r,o){const l=Pt("icon-svg");return r.isOpen?(F(),U("div",{key:0,class:"physton-packages-state",onClick:t[6]||(t[6]=(...c)=>o.close&&o.close(...c))},[_("div",{class:"state-main",onClick:t[5]||(t[5]=ct(()=>{},["stop"]))},[_("div",{class:"state-close",onClick:t[0]||(t[0]=(...c)=>o.close&&o.close(...c))},[De(l,{name:"close"})]),_("div",{class:"state-body",onClick:t[4]||(t[4]=ct(()=>{},["stop"]))},[_("div",l0,[_("label",null,[_("input",{type:"checkbox",value:r.todayNotShow,onChange:t[1]||(t[1]=(...c)=>o.onTodayNotShowChange&&o.onTodayNotShowChange(...c))},null,40,u0),$t(" "+ve(e.getLang("today_not_show")),1)])]),_("div",c0,ve(e.globals.shortName),1),_("div",{class:"state-body-language",onClick:t[2]||(t[2]=c=>e.$emit("click:selectLanguage",c))},[De(l,{name:"i18n"}),_("div",null,"Language: "+ve(e.langName),1)]),_("div",{class:"state-body-desc",innerHTML:e.getLang("packages_desc")},null,8,f0),_("div",d0,[(F(!0),U($e,null,yt(n.packagesState,c=>(F(),U("div",{key:c.name,class:"package-item"},[_("div",p0,ve(c.name),1),_("div",{class:Lt(["package-state",c.state?"installed":"not_install"])},ve(e.getLang(c.state?"installed":"not_install")),3),_("div",h0,ve(o.getCommand(c)),1)]))),128))]),_("div",{class:"btn-packages-install hover-scale-120",onClick:t[3]||(t[3]=(...c)=>o.onInstallClick&&o.onInstallClick(...c))},[r.loading?(F(),wt(l,{key:0,name:"loading"})):(F(),U($e,{key:1},[$t(ve(e.getLang("install")),1)],64))]),r.showResult?(F(),U("div",g0,[$t(ve(e.getLang("packages_installing"))+" ",1),r.result?(F(),U("div",{key:0,class:"result-content",ref:"result"},ve(r.result),513)):qe("",!0)])):qe("",!0)])])])):qe("",!0)}const v0=un(a0,[["render",m0]]),y0={name:"ChatgptPrompt",components:{IconSvg:Bn},mixins:[Gn],props:{},data(){return{isOpen:!1,api:{},configs:[],chatPreset:"",hidePanels:{api:!0},imageDesc:"",promptResult:"",saveConfigIng:!1,genIng:!1}},emits:["use"],computed:{},mounted(){},methods:{open(){this.isOpen=!0,this.saveConfigIng=!1,this.genIng=!1,this.gradioAPI.getDatas(["chatgpt_prompts_preset","chatgpt_key","translate_api.openai"]).then(e=>{console.log(e),e.chatgpt_prompts_preset!==null?this.chatPreset=e.chatgpt_prompts_preset:this.chatPreset=this.getLang("chatgpt_prompts_preset"),this.configs=[];let t={},n=he.getTranslateApiItem(this.translateApis,"openai");if(n=JSON.parse(JSON.stringify(n)),e.chatgpt_key&&typeof e.chatgpt_key=="object")for(const i of n.config)t[i.key]=e.chatgpt_key[i.key]||i.default||"";else if(e["translate_api.openai"]&&e["translate_api.openai"].api_key)for(const i of n.config)t[i.key]=e["translate_api.openai"][i.key]||i.default||"";else for(const i of n.config)t[i.key]=i.default||"";t.api_key||(this.hidePanels.api=!1);for(const i of n.config)i.value=t[i.key],this.configs.push(i)})},close(){this.isOpen=!1},onUnfoldClick(e){this.hidePanels[e]=!this.hidePanels[e]},onSaveConfigClick(){if(this.saveConfigIng)return;this.saveConfigIng=!0;let e={};this.configs.forEach(t=>{e[t.key]=t.value}),this.gradioAPI.setData("chatgpt_key",e).then(t=>{this.$toastr.success(this.getLang("success")),this.saveConfigIng=!1}).catch(t=>{this.$toastr.error(t.message||t),this.saveConfigIng=!1})},onPresetChange(e){this.chatPreset=e.target.value,this._saveChatPreset()},onRestoreClick(){this.chatPreset=this.getLang("chatgpt_prompts_preset"),this._saveChatPreset()},_saveChatPreset(){this.gradioAPI.setData("chatgpt_prompts_preset",this.chatPreset)},onGenClick(){if(this.genIng)return;if(!this.imageDesc)return this.$refs.imageDesc.focus();if(this.imageDesc=this.imageDesc.trim(),!this.imageDesc)return this.$refs.imageDesc.focus();this.genIng=!0;let e=[{role:"user",content:this.chatPreset},{role:"user",content:this.imageDesc}],t={};this.configs.forEach(n=>{t[n.key]=n.value}),this.gradioAPI.genOpenAI(e,t).then(n=>{n.success?this.promptResult=n.result:this.$toastr.error(n.message||"error"),this.genIng=!1}).catch(n=>{this.$toastr.error(n.message||n),this.genIng=!1})},onUseClick(){this.$emit("use",this.promptResult),this.close()}}},b0={class:"panel-header"},C0={class:"panel-title"},w0={class:"panel-content"},_0={class:"body-line"},T0={class:"line-title"},E0={class:"line-content"},k0=["onUpdate:modelValue"],S0=["onUpdate:modelValue"],x0=["value"],A0=["innerHTML"],L0={class:"body-line"},O0=_("div",{class:"line-title"},null,-1),D0={class:"line-content text-right"},I0={class:"panel-header"},P0={class:"panel-title"},N0={class:"panel-content"},R0={class:"body-line"},M0={class:"line-title"},F0={class:"line-subtitle"},H0={class:"line-content"},B0=["value"],j0={class:"body-line"},$0=_("div",{class:"line-title"},null,-1),U0={class:"line-content text-right"},W0={class:"body-line"},K0={class:"line-title"},q0={class:"line-subtitle"},V0={class:"line-content"},z0=["placeholder"],X0={class:"body-line"},Y0=_("div",{class:"line-title"},null,-1),G0={class:"line-content text-right"},J0={class:"panel-header"},Z0={class:"panel-title"},Q0={class:"panel-content"},eC={class:"body-line"},tC={class:"line-title"},nC={class:"line-content"},iC={key:0,class:"body-line"},rC=_("div",{class:"line-title"},null,-1),sC={class:"line-content text-right"};function oC(e,t,n,i,r,o){const l=Pt("icon-svg");return r.isOpen?(F(),U("div",{key:0,class:"physton-chatgpt-prompt",onClick:t[13]||(t[13]=(...c)=>o.close&&o.close(...c))},[_("div",{class:"chatgpt-main",onClick:t[12]||(t[12]=ct(()=>{},["stop"]))},[_("div",{class:"chatgpt-close",onClick:t[0]||(t[0]=(...c)=>o.close&&o.close(...c))},[De(l,{name:"close"})]),_("div",{class:"chatgpt-body",onClick:t[11]||(t[11]=ct(()=>{},["stop"]))},[_("div",{class:Lt(["body-panel",r.hidePanels.api?"fold":""])},[_("div",b0,[_("div",{class:"panel-unfold",onClick:t[1]||(t[1]=c=>o.onUnfoldClick("api"))},[De(l,{class:"hover-scale-120",name:"unfold"})]),_("div",C0,ve(e.getLang("api_config")),1)]),_("div",w0,[(F(!0),U($e,null,yt(r.configs,c=>(F(),U("div",_0,[_("div",T0,ve(c.title),1),_("div",E0,[c.type=="input"?xe((F(),U("input",{key:0,type:"text","onUpdate:modelValue":d=>c.value=d},null,8,k0)),[[Hi,c.value]]):qe("",!0),c.type=="select"?xe((F(),U("select",{key:1,"onUpdate:modelValue":d=>c.value=d},[(F(!0),U($e,null,yt(c.options,d=>(F(),U("option",{value:d},ve(d),9,x0))),256))],8,S0)),[[jr,c.value]]):qe("",!0),c.desc?(F(),U("div",{key:2,innerHTML:c.desc},null,8,A0)):qe("",!0)])]))),256)),_("div",L0,[O0,_("div",D0,[_("div",{class:"common-btn hover-scale-120",onClick:t[2]||(t[2]=(...c)=>o.onSaveConfigClick&&o.onSaveConfigClick(...c))},[r.saveConfigIng?(F(),wt(l,{key:0,name:"loading"})):(F(),U($e,{key:1},[$t(ve(e.getLang("save")),1)],64))])])])])],2),_("div",{class:Lt(["body-panel",r.hidePanels.send?"fold":""])},[_("div",I0,[_("div",{class:"panel-unfold",onClick:t[3]||(t[3]=c=>o.onUnfoldClick("send"))},[De(l,{class:"hover-scale-120",name:"unfold"})]),_("div",P0,ve(e.getLang("image_desc")),1)]),_("div",N0,[_("div",R0,[_("div",M0,[$t(ve(e.getLang("preset"))+" ",1),_("div",F0,ve(e.getLang("ai_one")),1)]),_("div",H0,[_("textarea",{value:r.chatPreset,onChange:t[4]||(t[4]=(...c)=>o.onPresetChange&&o.onPresetChange(...c)),style:{height:"100px"}},null,40,B0)])]),_("div",j0,[$0,_("div",U0,[_("a",{href:"javascript:",onClick:t[5]||(t[5]=(...c)=>o.onRestoreClick&&o.onRestoreClick(...c))},ve(e.getLang("restore_to_default")),1)])]),_("div",W0,[_("div",K0,[$t(ve(e.getLang("image_desc"))+" ",1),_("div",q0,ve(e.getLang("ai_two")),1)]),_("div",V0,[xe(_("textarea",{style:{height:"100px"},ref:"imageDesc","onUpdate:modelValue":t[6]||(t[6]=c=>r.imageDesc=c),placeholder:e.getLang("input_image_desc")},null,8,z0),[[Hi,r.imageDesc]])])]),_("div",X0,[Y0,_("div",G0,[_("div",{class:"common-btn hover-scale-120",onClick:t[7]||(t[7]=(...c)=>o.onGenClick&&o.onGenClick(...c))},[r.genIng?(F(),wt(l,{key:0,name:"loading"})):(F(),U($e,{key:1},[$t(ve(e.getLang("generate")),1)],64))])])])])],2),_("div",{class:Lt(["body-panel",r.hidePanels.result?"fold":""])},[_("div",J0,[_("div",{class:"panel-unfold",onClick:t[8]||(t[8]=c=>o.onUnfoldClick("result"))},[De(l,{class:"hover-scale-120",name:"unfold"})]),_("div",Z0,ve(e.getLang("generate_result")),1)]),_("div",Q0,[_("div",eC,[_("div",tC,ve(e.getLang("generate_result")),1),_("div",nC,[xe(_("textarea",{style:{height:"100px"},"onUpdate:modelValue":t[9]||(t[9]=c=>r.promptResult=c)},null,512),[[Hi,r.promptResult]])])]),r.promptResult?(F(),U("div",iC,[rC,_("div",sC,[_("div",{class:"common-btn hover-scale-120",onClick:t[10]||(t[10]=(...c)=>o.onUseClick&&o.onUseClick(...c))},ve(e.getLang("use")),1)])])):qe("",!0)])],2)])])])):qe("",!0)}const aC=un(y0,[["render",oC]]),lC={name:"About",components:{IconSvg:Bn},mixins:[Gn],data(){return{version:"",latestVersion:"",isLatestVersion:!0,isOpen:!1,loading:!1,versions:[],icons:[]}},emits:["use"],computed:{},mounted(){this.icons=[{title:"GitHub stars",url:this.globals.github+"/stargazers",image:"https://img.shields.io/github/stars/"+this.globals.name+"?style=flat-square"},{title:"GitHub forks",url:this.globals.github+"/network/members",image:"https://img.shields.io/github/forks/"+this.globals.name+"?style=flat-square"},{title:"GitHub issues",url:this.globals.github+"/issues",image:"https://img.shields.io/github/issues/"+this.globals.name+"?style=flat-square"},{title:"GitHub issues closed",url:this.globals.github+"/issues?q=is%3Aissue+is%3Aclosed",image:"https://img.shields.io/github/issues-closed/"+this.globals.name+"?style=flat-square"},{title:"GitHub license",url:this.globals.github+"/blob/master/LICENSE.md",image:"https://img.shields.io/github/license/"+this.globals.name+"?style=flat-square"},{title:"GitHub commits",url:this.globals.github+"/commits/main",image:"https://img.shields.io/github/last-commit/"+this.globals.name+"?style=flat-square"}]},methods:{open(){this.isOpen=!0,this.version="",this.latestVersion="",this.isLatestVersion=!0,this.versions=[],this.loading=!0,this.gradioAPI.getVersion().then(e=>{this.version=e.version,this.latestVersion=e.latest_version,this.isLatestVersion=e.version===e.latest_version}),this.gradioAPI.getRemoteVersions().then(e=>{this.loading=!1;let t=[];e.forEach((n,i)=>{n.is_update_readme||(n.date=he.formatTime(n.date),t.push(n))}),this.versions=t}).catch(e=>{this.loading=!1})},close(){this.isOpen=!1},commitUrl(e){return this.globals.github+"/commit/"+e},formatVersion(e){return e?e.slice(0,7):this.getLang("unknown_version")},message(e){return e=he.escapeHtml(e),e=e.replace(/Former-commit-id: [a-z0-9]{40}/g,""),e=e.trim(),e=e.replace(` +`,t(!1)})};n()},scrollToBottom(){this.$nextTick(()=>{this.$refs.result.scrollTop=this.$refs.result.scrollHeight})},onTodayNotShowChange(){this.todayNotShow=!this.todayNotShow,this.gradioAPI.setData("packagesStateTodayNotShow",new Date().toLocaleDateString())},open(){this.gradioAPI.getData("packagesStateTodayNotShow").then(e=>{e&&e===new Date().toLocaleDateString()?this.close():(this.result="",this.loading=!1,this.showResult=!1,this.isOpen=!0)}).catch(e=>{})},close(){this.isOpen=!1}}},l0={class:"today-now-show"},u0=["value"],c0={class:"state-body-name"},f0=["innerHTML"],d0={class:"package-list"},p0={class:"package-name"},h0={class:"package-command"},g0={key:0,class:"install-result"};function m0(e,t,n,i,r,o){const l=Pt("icon-svg");return r.isOpen?(F(),U("div",{key:0,class:"physton-packages-state",onClick:t[6]||(t[6]=(...c)=>o.close&&o.close(...c))},[_("div",{class:"state-main",onClick:t[5]||(t[5]=ct(()=>{},["stop"]))},[_("div",{class:"state-close",onClick:t[0]||(t[0]=(...c)=>o.close&&o.close(...c))},[De(l,{name:"close"})]),_("div",{class:"state-body",onClick:t[4]||(t[4]=ct(()=>{},["stop"]))},[_("div",l0,[_("label",null,[_("input",{type:"checkbox",value:r.todayNotShow,onChange:t[1]||(t[1]=(...c)=>o.onTodayNotShowChange&&o.onTodayNotShowChange(...c))},null,40,u0),$t(" "+ve(e.getLang("today_not_show")),1)])]),_("div",c0,ve(e.globals.shortName),1),_("div",{class:"state-body-language",onClick:t[2]||(t[2]=c=>e.$emit("click:selectLanguage",c))},[De(l,{name:"i18n"}),_("div",null,"Language: "+ve(e.langName),1)]),_("div",{class:"state-body-desc",innerHTML:e.getLang("packages_desc")},null,8,f0),_("div",d0,[(F(!0),U($e,null,yt(n.packagesState,c=>(F(),U("div",{key:c.name,class:"package-item"},[_("div",p0,ve(c.name),1),_("div",{class:Lt(["package-state",c.state?"installed":"not_install"])},ve(e.getLang(c.state?"installed":"not_install")),3),_("div",h0,ve(o.getCommand(c)),1)]))),128))]),_("div",{class:"btn-packages-install hover-scale-120",onClick:t[3]||(t[3]=(...c)=>o.onInstallClick&&o.onInstallClick(...c))},[r.loading?(F(),wt(l,{key:0,name:"loading"})):(F(),U($e,{key:1},[$t(ve(e.getLang("install")),1)],64))]),r.showResult?(F(),U("div",g0,[$t(ve(e.getLang("packages_installing"))+" ",1),r.result?(F(),U("div",{key:0,class:"result-content",ref:"result"},ve(r.result),513)):qe("",!0)])):qe("",!0)])])])):qe("",!0)}const v0=un(a0,[["render",m0]]),y0={name:"ChatgptPrompt",components:{IconSvg:Bn},mixins:[Gn],props:{},data(){return{isOpen:!1,api:{},configs:[],chatPreset:"",hidePanels:{api:!0},imageDesc:"",promptResult:"",saveConfigIng:!1,genIng:!1}},emits:["use"],computed:{},mounted(){},methods:{open(){this.isOpen=!0,this.saveConfigIng=!1,this.genIng=!1,this.gradioAPI.getDatas(["chatgpt_prompts_preset","chatgpt_key","translate_api.openai"]).then(e=>{console.log(e),e.chatgpt_prompts_preset!==null?this.chatPreset=e.chatgpt_prompts_preset:this.chatPreset=this.getLang("chatgpt_prompts_preset"),this.configs=[];let t={},n=he.getTranslateApiItem(this.translateApis,"openai");if(n=JSON.parse(JSON.stringify(n)),e.chatgpt_key&&typeof e.chatgpt_key=="object")for(const i of n.config)t[i.key]=e.chatgpt_key[i.key]||i.default||"";else for(const i of n.config)t[i.key]=i.default||"";t.api_key||(this.hidePanels.api=!1);for(const i of n.config)i.value=t[i.key],this.configs.push(i)})},close(){this.isOpen=!1},onUnfoldClick(e){this.hidePanels[e]=!this.hidePanels[e]},onSaveConfigClick(){if(this.saveConfigIng)return;this.saveConfigIng=!0;let e={};this.configs.forEach(t=>{e[t.key]=t.value}),this.gradioAPI.setData("chatgpt_key",e).then(t=>{this.$toastr.success(this.getLang("success")),this.saveConfigIng=!1}).catch(t=>{this.$toastr.error(t.message||t),this.saveConfigIng=!1})},onPresetChange(e){this.chatPreset=e.target.value,this._saveChatPreset()},onRestoreClick(){this.chatPreset=this.getLang("chatgpt_prompts_preset"),this._saveChatPreset()},_saveChatPreset(){this.gradioAPI.setData("chatgpt_prompts_preset",this.chatPreset)},onGenClick(){if(this.genIng)return;if(!this.imageDesc)return this.$refs.imageDesc.focus();if(this.imageDesc=this.imageDesc.trim(),!this.imageDesc)return this.$refs.imageDesc.focus();this.genIng=!0;let e=[{role:"user",content:this.chatPreset},{role:"user",content:this.imageDesc}],t={};this.configs.forEach(n=>{t[n.key]=n.value}),this.gradioAPI.genOpenAI(e,t).then(n=>{n.success?this.promptResult=n.result:this.$toastr.error(n.message||"error"),this.genIng=!1}).catch(n=>{this.$toastr.error(n.message||n),this.genIng=!1})},onUseClick(){this.$emit("use",this.promptResult),this.close()}}},b0={class:"panel-header"},C0={class:"panel-title"},w0={class:"panel-content"},_0={class:"body-line"},T0={class:"line-title"},E0={class:"line-content"},k0=["onUpdate:modelValue"],S0=["onUpdate:modelValue"],x0=["value"],A0=["innerHTML"],L0={class:"body-line"},O0=_("div",{class:"line-title"},null,-1),D0={class:"line-content text-right"},I0={class:"panel-header"},P0={class:"panel-title"},N0={class:"panel-content"},R0={class:"body-line"},M0={class:"line-title"},F0={class:"line-subtitle"},H0={class:"line-content"},B0=["value"],j0={class:"body-line"},$0=_("div",{class:"line-title"},null,-1),U0={class:"line-content text-right"},W0={class:"body-line"},K0={class:"line-title"},q0={class:"line-subtitle"},V0={class:"line-content"},z0=["placeholder"],X0={class:"body-line"},Y0=_("div",{class:"line-title"},null,-1),G0={class:"line-content text-right"},J0={class:"panel-header"},Z0={class:"panel-title"},Q0={class:"panel-content"},eC={class:"body-line"},tC={class:"line-title"},nC={class:"line-content"},iC={key:0,class:"body-line"},rC=_("div",{class:"line-title"},null,-1),sC={class:"line-content text-right"};function oC(e,t,n,i,r,o){const l=Pt("icon-svg");return r.isOpen?(F(),U("div",{key:0,class:"physton-chatgpt-prompt",onClick:t[13]||(t[13]=(...c)=>o.close&&o.close(...c))},[_("div",{class:"chatgpt-main",onClick:t[12]||(t[12]=ct(()=>{},["stop"]))},[_("div",{class:"chatgpt-close",onClick:t[0]||(t[0]=(...c)=>o.close&&o.close(...c))},[De(l,{name:"close"})]),_("div",{class:"chatgpt-body",onClick:t[11]||(t[11]=ct(()=>{},["stop"]))},[_("div",{class:Lt(["body-panel",r.hidePanels.api?"fold":""])},[_("div",b0,[_("div",{class:"panel-unfold",onClick:t[1]||(t[1]=c=>o.onUnfoldClick("api"))},[De(l,{class:"hover-scale-120",name:"unfold"})]),_("div",C0,ve(e.getLang("api_config")),1)]),_("div",w0,[(F(!0),U($e,null,yt(r.configs,c=>(F(),U("div",_0,[_("div",T0,ve(c.title),1),_("div",E0,[c.type=="input"?xe((F(),U("input",{key:0,type:"text","onUpdate:modelValue":d=>c.value=d},null,8,k0)),[[Hi,c.value]]):qe("",!0),c.type=="select"?xe((F(),U("select",{key:1,"onUpdate:modelValue":d=>c.value=d},[(F(!0),U($e,null,yt(c.options,d=>(F(),U("option",{value:d},ve(d),9,x0))),256))],8,S0)),[[jr,c.value]]):qe("",!0),c.desc?(F(),U("div",{key:2,innerHTML:c.desc},null,8,A0)):qe("",!0)])]))),256)),_("div",L0,[O0,_("div",D0,[_("div",{class:"common-btn hover-scale-120",onClick:t[2]||(t[2]=(...c)=>o.onSaveConfigClick&&o.onSaveConfigClick(...c))},[r.saveConfigIng?(F(),wt(l,{key:0,name:"loading"})):(F(),U($e,{key:1},[$t(ve(e.getLang("save")),1)],64))])])])])],2),_("div",{class:Lt(["body-panel",r.hidePanels.send?"fold":""])},[_("div",I0,[_("div",{class:"panel-unfold",onClick:t[3]||(t[3]=c=>o.onUnfoldClick("send"))},[De(l,{class:"hover-scale-120",name:"unfold"})]),_("div",P0,ve(e.getLang("image_desc")),1)]),_("div",N0,[_("div",R0,[_("div",M0,[$t(ve(e.getLang("preset"))+" ",1),_("div",F0,ve(e.getLang("ai_one")),1)]),_("div",H0,[_("textarea",{value:r.chatPreset,onChange:t[4]||(t[4]=(...c)=>o.onPresetChange&&o.onPresetChange(...c)),style:{height:"100px"}},null,40,B0)])]),_("div",j0,[$0,_("div",U0,[_("a",{href:"javascript:",onClick:t[5]||(t[5]=(...c)=>o.onRestoreClick&&o.onRestoreClick(...c))},ve(e.getLang("restore_to_default")),1)])]),_("div",W0,[_("div",K0,[$t(ve(e.getLang("image_desc"))+" ",1),_("div",q0,ve(e.getLang("ai_two")),1)]),_("div",V0,[xe(_("textarea",{style:{height:"100px"},ref:"imageDesc","onUpdate:modelValue":t[6]||(t[6]=c=>r.imageDesc=c),placeholder:e.getLang("input_image_desc")},null,8,z0),[[Hi,r.imageDesc]])])]),_("div",X0,[Y0,_("div",G0,[_("div",{class:"common-btn hover-scale-120",onClick:t[7]||(t[7]=(...c)=>o.onGenClick&&o.onGenClick(...c))},[r.genIng?(F(),wt(l,{key:0,name:"loading"})):(F(),U($e,{key:1},[$t(ve(e.getLang("generate")),1)],64))])])])])],2),_("div",{class:Lt(["body-panel",r.hidePanels.result?"fold":""])},[_("div",J0,[_("div",{class:"panel-unfold",onClick:t[8]||(t[8]=c=>o.onUnfoldClick("result"))},[De(l,{class:"hover-scale-120",name:"unfold"})]),_("div",Z0,ve(e.getLang("generate_result")),1)]),_("div",Q0,[_("div",eC,[_("div",tC,ve(e.getLang("generate_result")),1),_("div",nC,[xe(_("textarea",{style:{height:"100px"},"onUpdate:modelValue":t[9]||(t[9]=c=>r.promptResult=c)},null,512),[[Hi,r.promptResult]])])]),r.promptResult?(F(),U("div",iC,[rC,_("div",sC,[_("div",{class:"common-btn hover-scale-120",onClick:t[10]||(t[10]=(...c)=>o.onUseClick&&o.onUseClick(...c))},ve(e.getLang("use")),1)])])):qe("",!0)])],2)])])])):qe("",!0)}const aC=un(y0,[["render",oC]]),lC={name:"About",components:{IconSvg:Bn},mixins:[Gn],data(){return{version:"",latestVersion:"",isLatestVersion:!0,isOpen:!1,loading:!1,versions:[],icons:[]}},emits:["use"],computed:{},mounted(){this.icons=[{title:"GitHub stars",url:this.globals.github+"/stargazers",image:"https://img.shields.io/github/stars/"+this.globals.name+"?style=flat-square"},{title:"GitHub forks",url:this.globals.github+"/network/members",image:"https://img.shields.io/github/forks/"+this.globals.name+"?style=flat-square"},{title:"GitHub issues",url:this.globals.github+"/issues",image:"https://img.shields.io/github/issues/"+this.globals.name+"?style=flat-square"},{title:"GitHub issues closed",url:this.globals.github+"/issues?q=is%3Aissue+is%3Aclosed",image:"https://img.shields.io/github/issues-closed/"+this.globals.name+"?style=flat-square"},{title:"GitHub license",url:this.globals.github+"/blob/master/LICENSE.md",image:"https://img.shields.io/github/license/"+this.globals.name+"?style=flat-square"},{title:"GitHub commits",url:this.globals.github+"/commits/main",image:"https://img.shields.io/github/last-commit/"+this.globals.name+"?style=flat-square"}]},methods:{open(){this.isOpen=!0,this.version="",this.latestVersion="",this.isLatestVersion=!0,this.versions=[],this.loading=!0,this.gradioAPI.getVersion().then(e=>{this.version=e.version,this.latestVersion=e.latest_version,this.isLatestVersion=e.version===e.latest_version}),this.gradioAPI.getRemoteVersions().then(e=>{this.loading=!1;let t=[];e.forEach((n,i)=>{n.is_update_readme||(n.date=he.formatTime(n.date),t.push(n))}),this.versions=t}).catch(e=>{this.loading=!1})},close(){this.isOpen=!1},commitUrl(e){return this.globals.github+"/commit/"+e},formatVersion(e){return e?e.slice(0,7):this.getLang("unknown_version")},message(e){return e=he.escapeHtml(e),e=e.replace(/Former-commit-id: [a-z0-9]{40}/g,""),e=e.trim(),e=e.replace(` `,"
"),e=e.replace(/#(\d+)/g,'#$1'),e}}},uC={class:"body-title"},cC=["href"],fC=["href"],dC=["src","alt"],pC={key:0},hC=["href"],gC={key:0,class:"has-new-version"},mC=["href"],vC=["href"],yC={class:"version-list"},bC={class:"item-header"},CC={class:"version-sha"},wC=["href"],_C={class:"version-date"},TC=["innerHTML"];function EC(e,t,n,i,r,o){const l=Pt("icon-svg");return r.isOpen?(F(),U("div",{key:0,class:"physton-about-prompt",onClick:t[3]||(t[3]=(...c)=>o.close&&o.close(...c))},[_("div",{class:"about-main",onClick:t[2]||(t[2]=ct(()=>{},["stop"]))},[_("div",{class:"about-close",onClick:t[0]||(t[0]=(...c)=>o.close&&o.close(...c))},[De(l,{name:"close"})]),_("div",{class:"about-body",onClick:t[1]||(t[1]=ct(()=>{},["stop"]))},[_("p",uC,[_("a",{href:e.globals.github,target:"_blank"},ve(e.globals.name),9,cC)]),_("p",null,[(F(!0),U($e,null,yt(r.icons,c=>(F(),U("a",{key:c.title,href:c.url,target:"_blank"},[_("img",{src:c.image,alt:c.title},null,8,dC)],8,fC))),128))]),r.loading?qe("",!0):(F(),U("p",pC,[_("span",null,[$t(ve(e.getLang("version"))+": ",1),_("a",{href:o.commitUrl(r.version),target:"_blank"},ve(o.formatVersion(r.version)),9,hC)]),!r.isLatestVersion&&r.latestVersion?(F(),U("span",gC,[$t("    ("+ve(e.getLang("has_new_version"))+": ",1),_("a",{href:o.commitUrl(r.latestVersion),target:"_blank"},ve(o.formatVersion(r.latestVersion)),9,mC),$t(")")])):qe("",!0)])),_("p",null,[$t(ve(e.getLang("wiki_desc"))+" ",1),_("a",{href:e.replaceGlobals("{{docs}}"),target:"_blank"},"Wiki",8,vC)]),_("div",yC,[r.loading?(F(),wt(l,{key:0,name:"loading"})):qe("",!0),(F(!0),U($e,null,yt(r.versions,c=>(F(),U("div",{class:"version-item",key:c.version},[_("div",bC,[_("div",CC,[_("a",{href:o.commitUrl(c.version),target:"_blank"},ve(o.formatVersion(c.version)),9,wC)]),_("div",_C,ve(c.date),1)]),_("div",{class:"version-msg",innerHTML:o.message(c.message)},null,8,TC)]))),128))])])])])):qe("",!0)}const kC={name:"App",components:{About:un(lC,[["render",EC]]),ChatgptPrompt:aC,PackagesState:v0,PromptFormat:o0,ExtensionCss:qb,IconSvg:Bn,History:Mb,Favorite:sb,SelectLanguage:Ly,TranslateSetting:ky,PhystonPrompt:yv},mixins:[],data(){return{prompts:[{tab:"tab_txt2img",prompt:"txt2img_prompt",counter:"txt2img_token_counter",button:"txt2img_token_button",steps:"txt2img_steps",historyKey:"txt2img",favoriteKey:"txt2img",$prompt:null,$textarea:null,$steps:null,name:"txt2img_prompt",neg:!1,hideDefaultInputKey:"txt2ImgHideDefaultInput",hideDefaultInput:!1,hidePanelKey:"txt2ImgHidePanel",hidePanel:!1,id:"phystonPrompt_txt2img_prompt"},{tab:"tab_txt2img",prompt:"txt2img_neg_prompt",counter:"txt2img_negative_token_counter",button:"txt2img_negative_token_button",steps:"txt2img_steps",historyKey:"txt2img_neg",favoriteKey:"txt2img_neg",$prompt:null,$textarea:null,$steps:null,name:"txt2img_neg_prompt",neg:!0,hideDefaultInputKey:"txt2ImgNegHideDefaultInput",hideDefaultInput:!1,hidePanelKey:"txt2ImgNegHidePanel",hidePanel:!1,id:"phystonPrompt_txt2img_neg_prompt"},{tab:"tab_img2img",prompt:"img2img_prompt",counter:"img2img_token_counter",button:"img2img_token_button",steps:"img2img_steps",historyKey:"img2img",favoriteKey:"img2img",$prompt:null,$textarea:null,$steps:null,name:"img2img_prompt",neg:!1,hideDefaultInputKey:"img2ImgHideDefaultInput",hideDefaultInput:!1,hidePanelKey:"img2ImgHidePanel",hidePanel:!1,id:"phystonPrompt_img2img_prompt"},{tab:"tab_img2img",prompt:"img2img_neg_prompt",counter:"img2img_negative_token_counter",button:"img2img_negative_token_button",steps:"img2img_steps",historyKey:"img2img_neg",favoriteKey:"img2img_neg",$prompt:null,$textarea:null,$steps:null,name:"img2img_neg_prompt",neg:!0,hideDefaultInputKey:"img2ImgNegHideDefaultInput",hideDefaultInput:!1,hidePanelKey:"img2ImgNegHidePanel",hidePanel:!1,id:"phystonPrompt_img2img_neg_prompt"}],languageCode:"",languages:{},translateApis:[],translateApi:"",translateApiConfig:{},canOneTranslate:!1,autoTranslate:!1,autoTranslateToEnglish:!1,autoTranslateToLocal:!1,autoRemoveSpace:!0,autoRemoveLastComma:!1,autoKeepWeightZero:!1,autoKeepWeightOne:!1,enableTooltip:!0,tagCompleteFile:"",onlyCsvOnAuto:!1,startWatchSave:!1,pasteBtn:null,showPastePopup:!1,pasteTitle:"",pasteContent:"",pasteLoading:!1,historyCurrentPrompt:"",favoriteCurrentPrompt:"",chatgptCurrentPrompt:"",extraNetworks:[],loras:[],lycos:[],embeddings:[],python:"",packagesState:[],version:"",latestVersion:"",isLatestVersion:!0,theme:"dark"}},watch:{languageCode:{handler:function(e,t){this.startWatchSave&&(console.log("onLanguageCodeChange",e),this.canOneTranslate=he.canOneTranslate(this.languageCode),this.gradioAPI.setData("languageCode",e).then(n=>{}).catch(n=>{}))},immediate:!1},autoTranslateToEnglish:{handler:function(e,t){this.startWatchSave&&(console.log("onAutoTranslateToEnglishChange",e),this.gradioAPI.setData("autoTranslateToEnglish",e).then(n=>{}).catch(n=>{}))},immediate:!1},autoTranslateToLocal:{handler:function(e,t){this.startWatchSave&&(console.log("onAutoTranslateToLocalChange",e),this.gradioAPI.setData("autoTranslateToLocal",e).then(n=>{}).catch(n=>{}))},immediate:!1},autoTranslate:{handler:function(e,t){this.startWatchSave&&(this.autoTranslateToEnglish=this.autoTranslate,this.autoTranslateToLocal=this.autoTranslate,console.log("onAutoTranslateChange",e),this.gradioAPI.setData("autoTranslate",e).then(n=>{}).catch(n=>{}))},immediate:!1},autoRemoveSpace:{handler:function(e,t){this.startWatchSave&&(console.log("onAutoRemoveSpaceChange",e),this.gradioAPI.setData("autoRemoveSpace",e).then(n=>{}).catch(n=>{}))},immediate:!1},autoRemoveLastComma:{handler:function(e,t){this.startWatchSave&&(console.log("onAutoRemoveLastCommaChange",e),this.gradioAPI.setData("autoRemoveLastComma",e).then(n=>{}).catch(n=>{}))},immediate:!1},autoKeepWeightZero:{handler:function(e,t){this.startWatchSave&&(console.log("onAutoKeepWeightZeroChange",e),this.gradioAPI.setData("autoKeepWeightZero",e).then(n=>{}).catch(n=>{}))},immediate:!1},autoKeepWeightOne:{handler:function(e,t){this.startWatchSave&&(console.log("onAutoKeepWeightOneChange",e),this.gradioAPI.setData("autoKeepWeightOne",e).then(n=>{}).catch(n=>{}))},immediate:!1},enableTooltip:{handler:function(e,t){this.startWatchSave&&(localStorage.setItem("phystonPromptEnableTooltip",e?"true":"false"),this.updateTippyState(),this.gradioAPI.setData("enableTooltip",e).then(n=>{}).catch(n=>{}))},immediate:!1},translateApi:{handler:function(e,t){this.startWatchSave&&(console.log("onTranslateApiChange",e,t),this.updateTranslateApiConfig(),this.gradioAPI.setData("translateApi",e).then(n=>{}).catch(n=>{}))},immediate:!1},tagCompleteFile:{handler:function(e,t){this.startWatchSave&&(console.log("onTagCompleteFileChange",e,t),this.gradioAPI.setData("tagCompleteFile",e).then(n=>{}).catch(n=>{}))},immediate:!1},onlyCsvOnAuto(){this.startWatchSave&&(console.log("onOnlyCsvOnAutoChange",this.onlyCsvOnAuto),this.gradioAPI.setData("onlyCsvOnAuto",this.onlyCsvOnAuto).then(e=>{}).catch(e=>{}))}},mounted(){he.loadCSS("toastr.min.css","physton-prompt-toastr",!0,!0,!1),he.loadCSS("tippy.css","physton-prompt-tippy",!0,!0,!1),he.loadCSS("main.min.css","physton-prompt-main",!0);let t=new URLSearchParams(window.location.search).get("__theme");["dark","light"].includes(t)&&(this.theme=t,he.gradioApp().classList.contains(this.theme)||he.gradioApp().classList.add(this.theme)),setTimeout(()=>{document.querySelector('meta[content="LobeHub"]')&&he.gradioApp().classList.add("physton-prompt-lobehub")},3e3),this.gradioAPI.getConfig().then(n=>{console.log("config:",n),this.languageCode=n.i18n.default,this.translateApi=n.translate_apis.default,this.translateApis=n.translate_apis.apis,this.python=n.python,this.packagesState=n.packages_state;let i={};n.i18n.languages.forEach(r=>{i[r.code]=r}),this.languages=i,this.init()}).catch(n=>{this.$toastr.error("Connection to backend API service failed. Please manually refresh the webpage. If it still doesn't work, please restart the WebUI.
连接到后台接口服务失败,请手动再刷新一次网页。如果还是不行,请重启WebUI。

"+n.message,co.shortName,{timeOut:2e4}),console.log(n)})},methods:{getLang(e){return he.getLang(e,this.languageCode,this.languages)},init(){this.loadExtraNetworks();let e=["languageCode","autoTranslate","autoTranslateToEnglish","autoTranslateToLocal","autoRemoveSpace","autoRemoveLastComma","autoKeepWeightZero","autoKeepWeightOne","translateApi","enableTooltip","tagCompleteFile","onlyCsvOnAuto","extensionSelect.minimalist"];this.prompts.forEach(t=>{e.push(t.hideDefaultInputKey),e.push(t.hidePanelKey)}),this.gradioAPI.getDatas(e).then(t=>{if(t.languageCode!==null){let n=!1;for(let i in this.languages)if(this.languages[i].code===t.languageCode){n=!0;break}n&&(this.languageCode=t.languageCode,this.$forceUpdate(),this.gradioAPI.setData("languageCode",this.languageCode))}else{let n=navigator.language||navigator.userLanguage||"";if(n){for(let i in this.languages)if(he.isSameLang(this.languages[i].code,n)){this.languageCode=this.languages[i].code,this.$forceUpdate(),this.gradioAPI.setData("languageCode",this.languageCode);break}}}this.canOneTranslate=he.canOneTranslate(this.languageCode),t.autoTranslateToEnglish!==null&&(this.autoTranslateToEnglish=t.autoTranslateToEnglish),t.autoTranslateToLocal!==null&&(this.autoTranslateToLocal=t.autoTranslateToLocal),t.autoTranslate!==null?this.canOneTranslate?(this.autoTranslate=t.autoTranslate,this.autoTranslateToEnglish=this.autoTranslate,this.autoTranslateToLocal=this.autoTranslate):this.autoTranslate=!1:this.canOneTranslate?(this.autoTranslate=this.autoTranslateToEnglish||this.autoTranslateToLocal,this.autoTranslateToEnglish=!0,this.autoTranslateToLocal=!0):this.autoTranslate=!1,t.autoRemoveSpace!==null&&(this.autoRemoveSpace=t.autoRemoveSpace),t.autoRemoveLastComma!==null&&(this.autoRemoveLastComma=t.autoRemoveLastComma),t.autoKeepWeightZero!==null&&(this.autoKeepWeightZero=t.autoKeepWeightZero),t.autoKeepWeightOne!==null&&(this.autoKeepWeightOne=t.autoKeepWeightOne),t.enableTooltip!==null&&(this.enableTooltip=t.enableTooltip),localStorage.setItem("phystonPromptEnableTooltip",this.enableTooltip?"true":"false"),this.updateTippyState(),t.translateApi!==null&&(this.translateApi=t.translateApi),t.tagCompleteFile!==null&&(this.tagCompleteFile=t.tagCompleteFile,this.$nextTick(()=>{this.$refs.translateSetting.getCSV(this.tagCompleteFile)})),t.onlyCsvOnAuto!==null&&(this.onlyCsvOnAuto=t.onlyCsvOnAuto),t["extensionSelect.minimalist"]===null&&this.gradioAPI.setData("extensionSelect.minimalist",!0),this.updateTranslateApiConfig(),this.$refs.extensionCss.init(),this.prompts.forEach(n=>{t[n.hideDefaultInputKey]!==null&&(n.hideDefaultInput=t[n.hideDefaultInputKey]),t[n.hidePanelKey]!==null&&(n.hidePanel=t[n.hidePanelKey]),n.$prompt=he.gradioApp().querySelector("#"+n.prompt),n.$textarea=n.$prompt.getElementsByTagName("textarea")[0],n.$steps=he.gradioApp().querySelector("#"+n.steps)}),this.$nextTick(()=>{this.prompts.forEach(n=>{const i=he.gradioApp().querySelector("#"+n.id);n.$prompt.parentElement.parentElement.parentElement.appendChild(i),n.$prompt.parentElement.parentElement.style.display=n.hideDefaultInput?"none":"flex"}),this.startWatchSave=!0}),this.handlePaste()})},updateTippyState(){for(const e of this.$tippyList)this.enableTooltip?e.enable():e.disable()},updateTranslateApiConfig(){this.gradioAPI.getData("translate_api."+this.translateApi).then(e=>{let t={};const n=he.getTranslateApiItem(this.translateApis,this.translateApi);if(n.config){for(const i of n.config)n.type==="translators"&&i.key==="region"&&!e.region?t[i.key]=this.languageCode==="zh_CN"||this.languageCode==="zh_HK"||this.languageCode==="zh_TW"?"China":"EN":e?t[i.key]=e[i.key]:t[i.key]=i.default||"";t.concurrent=n.concurrent||0}this.translateApiConfig=t})},onPromptFormatClick(e){this.$refs.promptFormat.open(e)},onSelectLanguageClick(e){this.$refs.selectLanguage.open(e)},onTranslateApiClick(){this.$refs.translateSetting.open(this.translateApi)},onSelectThemeClick(){this.$refs.extensionCss.open()},handlePaste(){if(typeof gradioApp!="function")return;const e=gradioApp().querySelectorAll("#paste");!e||e.length<=0||e.forEach((t,n)=>{const i=t.cloneNode(!0);i.id="paste-new-"+n,i.innerHTML="🗒",t.parentNode.insertBefore(i,t.nextSibling),i.addEventListener("click",()=>{this.pasteBtn=t,this.openPastePopup()}),this.pasteTitle=t.title})},openPastePopup(){this.pasteContent="",this.pasteLoading=!1,this.showPastePopup=!0},closePastePopup(){this.showPastePopup=!1},onClickPasteSubmit(){this.pasteLoading=!0;const e=get_uiCurrentTabContent();let t=null,n=null,i=null,r=null,o=[];for(const l of this.prompts)l.tab==e.id&&(console.log(l),o.push(l.id),l.neg?(n=l.$textarea,r=l.$prompt):(t=l.$textarea,i=l.$prompt));if(!t||!i||!r){this.pasteLoading=!1;return}t.value=this.pasteContent,t.dispatchEvent(new Event("input")),this.pasteBtn.dispatchEvent(new Event("click")),setTimeout(()=>{let l=0,c=0;l=setInterval(()=>{if(c++,c>100){this.pasteLoading=!1,clearInterval(l);return}i.getElementsByClassName("hide").length>0&&r.getElementsByClassName("hide").length>0&&(this.pasteLoading=!1,this.closePastePopup(),clearInterval(l),he.hideCompleteResults(t),he.hideCompleteResults(n),o.forEach((d,m)=>{setTimeout(()=>{this.$refs[d][0].onTextareaChange(!0)},1e3)}))},100)},1e3)},onUpdateHideDefaultInput(e,t){const n=this.prompts.find(i=>i.id==e);n&&(n.hideDefaultInput=t,this.gradioAPI.setData(n.hideDefaultInputKey,n.hideDefaultInput),n.$prompt.parentElement.parentElement.style.display=n.hideDefaultInput?"none":"flex")},onUpdateHidePanel(e,t){const n=this.prompts.find(i=>i.id==e);n&&(n.hidePanel=t,this.gradioAPI.setData(n.hidePanelKey,n.hidePanel))},onShowHistory(e,t){this.$refs.favorite.hide(),this.historyCurrentPrompt=e;const n=this.prompts.find(i=>i.id==e);n&&this.$refs.history.show(n.historyKey,t)},onUseHistory(e){if(!this.historyCurrentPrompt)return;const t=this.prompts.find(n=>n.id==this.historyCurrentPrompt);t&&this.$refs[t.id][0].useFavorite(e)},onShowFavorite(e,t){this.$refs.history.hide(),this.favoriteCurrentPrompt=e;const n=this.prompts.find(i=>i.id==e);n&&this.$refs.favorite.show(n.favoriteKey,t)},onUseFavorite(e){if(!this.favoriteCurrentPrompt)return;const t=this.prompts.find(n=>n.id==this.favoriteCurrentPrompt);t&&this.$refs[t.id][0].useFavorite(e)},onRefreshFavorites(e){this.$refs.favorite.getFavorites(e)},onShowChatgpt(e,t){this.chatgptCurrentPrompt=e,this.prompts.find(i=>i.id==e)&&this.$refs.chatgptPrompt.open()},onUseChatgpt(e){if(!this.chatgptCurrentPrompt)return;const t=this.prompts.find(n=>n.id==this.chatgptCurrentPrompt);t&&this.$refs[t.id][0].useChatgpt(e)},onShowAbout(){this.$refs.about.open()},onSwitchTheme(){this.theme=this.theme==="dark"?"light":"dark";let e=window.location.href,t=new URL(e),n=new URLSearchParams(t.search);n.has("__theme")?n.set("__theme",this.theme):n.append("__theme",this.theme);let i=t.origin+t.pathname+"?"+n.toString();window.location.href=i}}},SC={class:"paste-popup-title"},xC={class:"paste-popup-body"},AC=["placeholder"],LC={key:1,class:"paste-submit"};function OC(e,t,n,i,r,o){const l=Pt("physton-prompt"),c=Pt("translate-setting"),d=Pt("select-language"),m=Pt("prompt-format"),g=Pt("history"),w=Pt("favorite"),T=Pt("extension-css"),H=Pt("packages-state"),x=Pt("chatgpt-prompt"),I=Pt("about"),V=Pt("icon-svg");return F(),U("div",null,[(F(!0),U($e,null,yt(r.prompts,N=>(F(),U($e,{key:N.name},[N.$textarea?(F(),wt(l,{key:0,id:N.id,ref_for:!0,ref:N.id,name:N.name,neg:N.neg,textarea:N.$textarea,steps:N.$steps,"language-code":r.languageCode,"onUpdate:languageCode":t[0]||(t[0]=te=>r.languageCode=te),"translate-apis":r.translateApis,languages:r.languages,"history-key":N.historyKey,"onClick:showHistory":te=>o.onShowHistory(N.id,te),"favorite-key":N.favoriteKey,onRefreshFavorites:o.onRefreshFavorites,"onClick:showFavorite":te=>o.onShowFavorite(N.id,te),"can-one-translate":r.canOneTranslate,"onUpdate:canOneTranslate":t[1]||(t[1]=te=>r.canOneTranslate=te),"auto-translate":r.autoTranslate,"onUpdate:autoTranslate":t[2]||(t[2]=te=>r.autoTranslate=te),"auto-translate-to-english":r.autoTranslateToEnglish,"onUpdate:autoTranslateToEnglish":t[3]||(t[3]=te=>r.autoTranslateToEnglish=te),"auto-translate-to-local":r.autoTranslateToLocal,"onUpdate:autoTranslateToLocal":t[4]||(t[4]=te=>r.autoTranslateToLocal=te),"auto-remove-space":r.autoRemoveSpace,"onUpdate:autoRemoveSpace":t[5]||(t[5]=te=>r.autoRemoveSpace=te),"auto-remove-last-comma":r.autoRemoveLastComma,"onUpdate:autoRemoveLastComma":t[6]||(t[6]=te=>r.autoRemoveLastComma=te),"auto-keep-weight-zero":r.autoKeepWeightZero,"onUpdate:autoKeepWeightZero":t[7]||(t[7]=te=>r.autoKeepWeightZero=te),"auto-keep-weight-one":r.autoKeepWeightOne,"onUpdate:autoKeepWeightOne":t[8]||(t[8]=te=>r.autoKeepWeightOne=te),"hide-default-input":N.hideDefaultInput,"onUpdate:hideDefaultInput":te=>o.onUpdateHideDefaultInput(N.id,te),"hide-panel":N.hidePanel,"onUpdate:hidePanel":te=>o.onUpdateHidePanel(N.id,te),"enable-tooltip":r.enableTooltip,"onUpdate:enableTooltip":t[9]||(t[9]=te=>r.enableTooltip=te),"translate-api":r.translateApi,"onUpdate:translateApi":t[10]||(t[10]=te=>r.translateApi=te),"translate-api-config":r.translateApiConfig,"onClick:translateApi":o.onTranslateApiClick,"onClick:promptFormat":o.onPromptFormatClick,"tag-complete-file":r.tagCompleteFile,"onUpdate:tagCompleteFile":t[11]||(t[11]=te=>r.tagCompleteFile=te),"only-csv-on-auto":r.onlyCsvOnAuto,"onUpdate:onlyCsvOnAuto":t[12]||(t[12]=te=>r.onlyCsvOnAuto=te),"onClick:selectLanguage":o.onSelectLanguageClick,"onClick:selectTheme":o.onSelectThemeClick,"onClick:showChatgpt":te=>o.onShowChatgpt(N.id,te),"extra-networks":r.extraNetworks,loras:r.loras,lycos:r.lycos,embeddings:r.embeddings,version:r.version,"latest-version":r.latestVersion,"is-latest-version":r.isLatestVersion,"onClick:showAbout":o.onShowAbout,theme:r.theme,"onClick:switchTheme":o.onSwitchTheme},null,8,["id","name","neg","textarea","steps","language-code","translate-apis","languages","history-key","onClick:showHistory","favorite-key","onRefreshFavorites","onClick:showFavorite","can-one-translate","auto-translate","auto-translate-to-english","auto-translate-to-local","auto-remove-space","auto-remove-last-comma","auto-keep-weight-zero","auto-keep-weight-one","hide-default-input","onUpdate:hideDefaultInput","hide-panel","onUpdate:hidePanel","enable-tooltip","translate-api","translate-api-config","onClick:translateApi","onClick:promptFormat","tag-complete-file","only-csv-on-auto","onClick:selectLanguage","onClick:selectTheme","onClick:showChatgpt","extra-networks","loras","lycos","embeddings","version","latest-version","is-latest-version","onClick:showAbout","theme","onClick:switchTheme"])):qe("",!0)],64))),128)),De(c,{ref:"translateSetting","language-code":r.languageCode,"onUpdate:languageCode":t[13]||(t[13]=N=>r.languageCode=N),"translate-apis":r.translateApis,languages:r.languages,"onForceUpdate:translateApi":o.updateTranslateApiConfig,"tag-complete-file":r.tagCompleteFile,"onUpdate:tagCompleteFile":t[14]||(t[14]=N=>r.tagCompleteFile=N),"only-csv-on-auto":r.onlyCsvOnAuto,"onUpdate:onlyCsvOnAuto":t[15]||(t[15]=N=>r.onlyCsvOnAuto=N),"translate-api":r.translateApi,"onUpdate:translateApi":t[16]||(t[16]=N=>r.translateApi=N)},null,8,["language-code","translate-apis","languages","onForceUpdate:translateApi","tag-complete-file","only-csv-on-auto","translate-api"]),De(d,{ref:"selectLanguage","language-code":r.languageCode,"onUpdate:languageCode":t[17]||(t[17]=N=>r.languageCode=N),"translate-apis":r.translateApis,languages:r.languages,"translate-api":r.translateApi,"onUpdate:translateApi":t[18]||(t[18]=N=>r.translateApi=N),"tag-complete-file":r.tagCompleteFile,"onUpdate:tagCompleteFile":t[19]||(t[19]=N=>r.tagCompleteFile=N),"only-csv-on-auto":r.onlyCsvOnAuto,"onUpdate:onlyCsvOnAuto":t[20]||(t[20]=N=>r.onlyCsvOnAuto=N)},null,8,["language-code","translate-apis","languages","translate-api","tag-complete-file","only-csv-on-auto"]),De(m,{ref:"promptFormat","language-code":r.languageCode,"onUpdate:languageCode":t[21]||(t[21]=N=>r.languageCode=N),"translate-apis":r.translateApis,languages:r.languages,"auto-remove-space":r.autoRemoveSpace,"onUpdate:autoRemoveSpace":t[22]||(t[22]=N=>r.autoRemoveSpace=N),"auto-remove-last-comma":r.autoRemoveLastComma,"onUpdate:autoRemoveLastComma":t[23]||(t[23]=N=>r.autoRemoveLastComma=N),"auto-keep-weight-zero":r.autoKeepWeightZero,"onUpdate:autoKeepWeightZero":t[24]||(t[24]=N=>r.autoKeepWeightZero=N),"auto-keep-weight-one":r.autoKeepWeightOne,"onUpdate:autoKeepWeightOne":t[25]||(t[25]=N=>r.autoKeepWeightOne=N)},null,8,["language-code","translate-apis","languages","auto-remove-space","auto-remove-last-comma","auto-keep-weight-zero","auto-keep-weight-one"]),De(g,{ref:"history","language-code":r.languageCode,"onUpdate:languageCode":t[26]||(t[26]=N=>r.languageCode=N),"translate-apis":r.translateApis,languages:r.languages,"tag-complete-file":r.tagCompleteFile,"onUpdate:tagCompleteFile":t[27]||(t[27]=N=>r.tagCompleteFile=N),"only-csv-on-auto":r.onlyCsvOnAuto,"onUpdate:onlyCsvOnAuto":t[28]||(t[28]=N=>r.onlyCsvOnAuto=N),onRefreshFavorites:o.onRefreshFavorites,onUse:o.onUseHistory},null,8,["language-code","translate-apis","languages","tag-complete-file","only-csv-on-auto","onRefreshFavorites","onUse"]),De(w,{ref:"favorite","language-code":r.languageCode,"onUpdate:languageCode":t[29]||(t[29]=N=>r.languageCode=N),"translate-apis":r.translateApis,languages:r.languages,"tag-complete-file":r.tagCompleteFile,"onUpdate:tagCompleteFile":t[30]||(t[30]=N=>r.tagCompleteFile=N),"only-csv-on-auto":r.onlyCsvOnAuto,"onUpdate:onlyCsvOnAuto":t[31]||(t[31]=N=>r.onlyCsvOnAuto=N),onUse:o.onUseFavorite},null,8,["language-code","translate-apis","languages","tag-complete-file","only-csv-on-auto","onUse"]),De(T,{ref:"extensionCss","language-code":r.languageCode,"onUpdate:languageCode":t[32]||(t[32]=N=>r.languageCode=N),"translate-apis":r.translateApis,languages:r.languages},null,8,["language-code","translate-apis","languages"]),De(H,{ref:"packagesState","language-code":r.languageCode,"onUpdate:languageCode":t[33]||(t[33]=N=>r.languageCode=N),"translate-apis":r.translateApis,languages:r.languages,"onClick:selectLanguage":o.onSelectLanguageClick,"packages-state":r.packagesState,python:r.python},null,8,["language-code","translate-apis","languages","onClick:selectLanguage","packages-state","python"]),De(x,{ref:"chatgptPrompt","language-code":r.languageCode,"onUpdate:languageCode":t[34]||(t[34]=N=>r.languageCode=N),"translate-apis":r.translateApis,languages:r.languages,onUse:o.onUseChatgpt},null,8,["language-code","translate-apis","languages","onUse"]),De(I,{ref:"about","language-code":r.languageCode,"onUpdate:languageCode":t[35]||(t[35]=N=>r.languageCode=N),"translate-apis":r.translateApis,languages:r.languages},null,8,["language-code","translate-apis","languages"]),r.showPastePopup?(F(),U("div",{key:0,class:"physton-paste-popup",onClick:t[40]||(t[40]=(...N)=>o.closePastePopup&&o.closePastePopup(...N))},[_("div",{class:"paste-popup-main",onClick:t[39]||(t[39]=ct(()=>{},["stop"]))},[_("div",{class:"paste-popup-close",onClick:t[36]||(t[36]=(...N)=>o.closePastePopup&&o.closePastePopup(...N))},[De(V,{name:"close"})]),_("div",SC,ve(r.pasteTitle),1),_("div",xC,[xe(_("textarea",{class:"paste-content","onUpdate:modelValue":t[37]||(t[37]=N=>r.pasteContent=N),placeholder:o.getLang("please_enter_the_content_here")},null,8,AC),[[Hi,r.pasteContent]]),r.pasteLoading?(F(),U("div",LC,[De(V,{name:"loading"})])):(F(),U("div",{key:0,class:"paste-submit",onClick:t[38]||(t[38]=(...N)=>o.onClickPasteSubmit&&o.onClickPasteSubmit(...N))},"Submit"))])])])):qe("",!0)])}const DC=un(kC,[["render",OC]]);var Ic={exports:{}},Ua={exports:{}};/*! * jQuery JavaScript Library v3.6.4 * https://jquery.com/ diff --git a/javascript/main.entry.js.map b/javascript/main.entry.js.map index 037d6fe..e872a55 100644 --- a/javascript/main.entry.js.map +++ b/javascript/main.entry.js.map @@ -1 +1 @@ -{"version":3,"file":"main.entry.js","sources":["../src/node_modules/@vue/shared/dist/shared.esm-bundler.js","../src/node_modules/@vue/reactivity/dist/reactivity.esm-bundler.js","../src/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js","../src/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js","../src/node_modules/sortablejs/modular/sortable.esm.js","../src/src/utils/splitTags.js","../src/globals.js","../src/src/utils/common.js","../src/node_modules/papaparse/papaparse.min.js","../src/src/mixins/languageMixin.js","../src/src/components/vue-number-input.vue","../src/src/mixins/phystonPrompt/headerMixin.js","../src/src/mixins/phystonPrompt/dropMixin.js","../src/node_modules/autosize-input/index.js","../src/src/mixins/phystonPrompt/tagMixin.js","../src/src/components/iconSvg.vue","../src/src/components/highlightPrompt.vue","../src/src/components/phystonPrompt.vue","../src/src/components/translateSetting.vue","../src/src/components/selectLanguage.vue","../src/src/components/favorite.vue","../src/src/components/history.vue","../src/src/components/extensionCss.vue","../src/src/components/promptFormat.vue","../src/src/components/packagesState.vue","../src/src/components/chatgptPrompt.vue","../src/src/components/about.vue","../src/src/App.vue","../src/node_modules/jquery/dist/jquery.js","../src/node_modules/toastr/toastr.js","../src/node_modules/clipboard/dist/clipboard.js","../src/node_modules/vue-clipboard3/dist/esm/index.js","../src/node_modules/axios/lib/helpers/bind.js","../src/node_modules/axios/lib/utils.js","../src/node_modules/axios/lib/core/AxiosError.js","../src/node_modules/axios/lib/helpers/null.js","../src/node_modules/axios/lib/helpers/toFormData.js","../src/node_modules/axios/lib/helpers/AxiosURLSearchParams.js","../src/node_modules/axios/lib/helpers/buildURL.js","../src/node_modules/axios/lib/core/InterceptorManager.js","../src/node_modules/axios/lib/defaults/transitional.js","../src/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js","../src/node_modules/axios/lib/platform/browser/classes/FormData.js","../src/node_modules/axios/lib/platform/browser/classes/Blob.js","../src/node_modules/axios/lib/platform/browser/index.js","../src/node_modules/axios/lib/helpers/toURLEncodedForm.js","../src/node_modules/axios/lib/helpers/formDataToJSON.js","../src/node_modules/axios/lib/defaults/index.js","../src/node_modules/axios/lib/helpers/parseHeaders.js","../src/node_modules/axios/lib/core/AxiosHeaders.js","../src/node_modules/axios/lib/core/transformData.js","../src/node_modules/axios/lib/cancel/isCancel.js","../src/node_modules/axios/lib/cancel/CanceledError.js","../src/node_modules/axios/lib/core/settle.js","../src/node_modules/axios/lib/helpers/cookies.js","../src/node_modules/axios/lib/helpers/isAbsoluteURL.js","../src/node_modules/axios/lib/helpers/combineURLs.js","../src/node_modules/axios/lib/core/buildFullPath.js","../src/node_modules/axios/lib/helpers/isURLSameOrigin.js","../src/node_modules/axios/lib/helpers/parseProtocol.js","../src/node_modules/axios/lib/helpers/speedometer.js","../src/node_modules/axios/lib/adapters/xhr.js","../src/node_modules/axios/lib/adapters/adapters.js","../src/node_modules/axios/lib/core/dispatchRequest.js","../src/node_modules/axios/lib/core/mergeConfig.js","../src/node_modules/axios/lib/env/data.js","../src/node_modules/axios/lib/helpers/validator.js","../src/node_modules/axios/lib/core/Axios.js","../src/node_modules/axios/lib/cancel/CancelToken.js","../src/node_modules/axios/lib/helpers/spread.js","../src/node_modules/axios/lib/helpers/isAxiosError.js","../src/node_modules/axios/lib/helpers/HttpStatusCode.js","../src/node_modules/axios/lib/axios.js","../src/src/utils/gradioAPI.js","../src/src/mixins/commonMixin.js","../src/node_modules/@popperjs/core/lib/enums.js","../src/node_modules/@popperjs/core/lib/dom-utils/getNodeName.js","../src/node_modules/@popperjs/core/lib/dom-utils/getWindow.js","../src/node_modules/@popperjs/core/lib/dom-utils/instanceOf.js","../src/node_modules/@popperjs/core/lib/modifiers/applyStyles.js","../src/node_modules/@popperjs/core/lib/utils/getBasePlacement.js","../src/node_modules/@popperjs/core/lib/utils/math.js","../src/node_modules/@popperjs/core/lib/utils/userAgent.js","../src/node_modules/@popperjs/core/lib/dom-utils/isLayoutViewport.js","../src/node_modules/@popperjs/core/lib/dom-utils/getBoundingClientRect.js","../src/node_modules/@popperjs/core/lib/dom-utils/getLayoutRect.js","../src/node_modules/@popperjs/core/lib/dom-utils/contains.js","../src/node_modules/@popperjs/core/lib/dom-utils/getComputedStyle.js","../src/node_modules/@popperjs/core/lib/dom-utils/isTableElement.js","../src/node_modules/@popperjs/core/lib/dom-utils/getDocumentElement.js","../src/node_modules/@popperjs/core/lib/dom-utils/getParentNode.js","../src/node_modules/@popperjs/core/lib/dom-utils/getOffsetParent.js","../src/node_modules/@popperjs/core/lib/utils/getMainAxisFromPlacement.js","../src/node_modules/@popperjs/core/lib/utils/within.js","../src/node_modules/@popperjs/core/lib/utils/getFreshSideObject.js","../src/node_modules/@popperjs/core/lib/utils/mergePaddingObject.js","../src/node_modules/@popperjs/core/lib/utils/expandToHashMap.js","../src/node_modules/@popperjs/core/lib/modifiers/arrow.js","../src/node_modules/@popperjs/core/lib/utils/getVariation.js","../src/node_modules/@popperjs/core/lib/modifiers/computeStyles.js","../src/node_modules/@popperjs/core/lib/modifiers/eventListeners.js","../src/node_modules/@popperjs/core/lib/utils/getOppositePlacement.js","../src/node_modules/@popperjs/core/lib/utils/getOppositeVariationPlacement.js","../src/node_modules/@popperjs/core/lib/dom-utils/getWindowScroll.js","../src/node_modules/@popperjs/core/lib/dom-utils/getWindowScrollBarX.js","../src/node_modules/@popperjs/core/lib/dom-utils/getViewportRect.js","../src/node_modules/@popperjs/core/lib/dom-utils/getDocumentRect.js","../src/node_modules/@popperjs/core/lib/dom-utils/isScrollParent.js","../src/node_modules/@popperjs/core/lib/dom-utils/getScrollParent.js","../src/node_modules/@popperjs/core/lib/dom-utils/listScrollParents.js","../src/node_modules/@popperjs/core/lib/utils/rectToClientRect.js","../src/node_modules/@popperjs/core/lib/dom-utils/getClippingRect.js","../src/node_modules/@popperjs/core/lib/utils/computeOffsets.js","../src/node_modules/@popperjs/core/lib/utils/detectOverflow.js","../src/node_modules/@popperjs/core/lib/utils/computeAutoPlacement.js","../src/node_modules/@popperjs/core/lib/modifiers/flip.js","../src/node_modules/@popperjs/core/lib/modifiers/hide.js","../src/node_modules/@popperjs/core/lib/modifiers/offset.js","../src/node_modules/@popperjs/core/lib/modifiers/popperOffsets.js","../src/node_modules/@popperjs/core/lib/utils/getAltAxis.js","../src/node_modules/@popperjs/core/lib/modifiers/preventOverflow.js","../src/node_modules/@popperjs/core/lib/dom-utils/getHTMLElementScroll.js","../src/node_modules/@popperjs/core/lib/dom-utils/getNodeScroll.js","../src/node_modules/@popperjs/core/lib/dom-utils/getCompositeRect.js","../src/node_modules/@popperjs/core/lib/utils/orderModifiers.js","../src/node_modules/@popperjs/core/lib/utils/debounce.js","../src/node_modules/@popperjs/core/lib/utils/mergeByName.js","../src/node_modules/@popperjs/core/lib/createPopper.js","../src/node_modules/@popperjs/core/lib/popper.js","../src/node_modules/tippy.js/dist/tippy.esm.js","../src/src/main.js"],"sourcesContent":["/**\n * Make a map and return a function for checking if a key\n * is in that map.\n * IMPORTANT: all calls of this function must be prefixed with\n * \\/\\*#\\_\\_PURE\\_\\_\\*\\/\n * So that rollup can tree-shake them if necessary.\n */\nfunction makeMap(str, expectsLowerCase) {\n const map = Object.create(null);\n const list = str.split(',');\n for (let i = 0; i < list.length; i++) {\n map[list[i]] = true;\n }\n return expectsLowerCase ? val => !!map[val.toLowerCase()] : val => !!map[val];\n}\n\n/**\n * dev only flag -> name mapping\n */\nconst PatchFlagNames = {\n [1 /* PatchFlags.TEXT */]: `TEXT`,\n [2 /* PatchFlags.CLASS */]: `CLASS`,\n [4 /* PatchFlags.STYLE */]: `STYLE`,\n [8 /* PatchFlags.PROPS */]: `PROPS`,\n [16 /* PatchFlags.FULL_PROPS */]: `FULL_PROPS`,\n [32 /* PatchFlags.HYDRATE_EVENTS */]: `HYDRATE_EVENTS`,\n [64 /* PatchFlags.STABLE_FRAGMENT */]: `STABLE_FRAGMENT`,\n [128 /* PatchFlags.KEYED_FRAGMENT */]: `KEYED_FRAGMENT`,\n [256 /* PatchFlags.UNKEYED_FRAGMENT */]: `UNKEYED_FRAGMENT`,\n [512 /* PatchFlags.NEED_PATCH */]: `NEED_PATCH`,\n [1024 /* PatchFlags.DYNAMIC_SLOTS */]: `DYNAMIC_SLOTS`,\n [2048 /* PatchFlags.DEV_ROOT_FRAGMENT */]: `DEV_ROOT_FRAGMENT`,\n [-1 /* PatchFlags.HOISTED */]: `HOISTED`,\n [-2 /* PatchFlags.BAIL */]: `BAIL`\n};\n\n/**\n * Dev only\n */\nconst slotFlagsText = {\n [1 /* SlotFlags.STABLE */]: 'STABLE',\n [2 /* SlotFlags.DYNAMIC */]: 'DYNAMIC',\n [3 /* SlotFlags.FORWARDED */]: 'FORWARDED'\n};\n\nconst GLOBALS_WHITE_LISTED = 'Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,' +\n 'decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,' +\n 'Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt';\nconst isGloballyWhitelisted = /*#__PURE__*/ makeMap(GLOBALS_WHITE_LISTED);\n\nconst range = 2;\nfunction generateCodeFrame(source, start = 0, end = source.length) {\n // Split the content into individual lines but capture the newline sequence\n // that separated each line. This is important because the actual sequence is\n // needed to properly take into account the full line length for offset\n // comparison\n let lines = source.split(/(\\r?\\n)/);\n // Separate the lines and newline sequences into separate arrays for easier referencing\n const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);\n lines = lines.filter((_, idx) => idx % 2 === 0);\n let count = 0;\n const res = [];\n for (let i = 0; i < lines.length; i++) {\n count +=\n lines[i].length +\n ((newlineSequences[i] && newlineSequences[i].length) || 0);\n if (count >= start) {\n for (let j = i - range; j <= i + range || end > count; j++) {\n if (j < 0 || j >= lines.length)\n continue;\n const line = j + 1;\n res.push(`${line}${' '.repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`);\n const lineLength = lines[j].length;\n const newLineSeqLength = (newlineSequences[j] && newlineSequences[j].length) || 0;\n if (j === i) {\n // push underline\n const pad = start - (count - (lineLength + newLineSeqLength));\n const length = Math.max(1, end > count ? lineLength - pad : end - start);\n res.push(` | ` + ' '.repeat(pad) + '^'.repeat(length));\n }\n else if (j > i) {\n if (end > count) {\n const length = Math.max(Math.min(end - count, lineLength), 1);\n res.push(` | ` + '^'.repeat(length));\n }\n count += lineLength + newLineSeqLength;\n }\n }\n break;\n }\n }\n return res.join('\\n');\n}\n\nfunction normalizeStyle(value) {\n if (isArray(value)) {\n const res = {};\n for (let i = 0; i < value.length; i++) {\n const item = value[i];\n const normalized = isString(item)\n ? parseStringStyle(item)\n : normalizeStyle(item);\n if (normalized) {\n for (const key in normalized) {\n res[key] = normalized[key];\n }\n }\n }\n return res;\n }\n else if (isString(value)) {\n return value;\n }\n else if (isObject(value)) {\n return value;\n }\n}\nconst listDelimiterRE = /;(?![^(]*\\))/g;\nconst propertyDelimiterRE = /:([^]+)/;\nconst styleCommentRE = /\\/\\*.*?\\*\\//gs;\nfunction parseStringStyle(cssText) {\n const ret = {};\n cssText\n .replace(styleCommentRE, '')\n .split(listDelimiterRE)\n .forEach(item => {\n if (item) {\n const tmp = item.split(propertyDelimiterRE);\n tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());\n }\n });\n return ret;\n}\nfunction stringifyStyle(styles) {\n let ret = '';\n if (!styles || isString(styles)) {\n return ret;\n }\n for (const key in styles) {\n const value = styles[key];\n const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);\n if (isString(value) || typeof value === 'number') {\n // only render valid values\n ret += `${normalizedKey}:${value};`;\n }\n }\n return ret;\n}\nfunction normalizeClass(value) {\n let res = '';\n if (isString(value)) {\n res = value;\n }\n else if (isArray(value)) {\n for (let i = 0; i < value.length; i++) {\n const normalized = normalizeClass(value[i]);\n if (normalized) {\n res += normalized + ' ';\n }\n }\n }\n else if (isObject(value)) {\n for (const name in value) {\n if (value[name]) {\n res += name + ' ';\n }\n }\n }\n return res.trim();\n}\nfunction normalizeProps(props) {\n if (!props)\n return null;\n let { class: klass, style } = props;\n if (klass && !isString(klass)) {\n props.class = normalizeClass(klass);\n }\n if (style) {\n props.style = normalizeStyle(style);\n }\n return props;\n}\n\n// These tag configs are shared between compiler-dom and runtime-dom, so they\n// https://developer.mozilla.org/en-US/docs/Web/HTML/Element\nconst HTML_TAGS = 'html,body,base,head,link,meta,style,title,address,article,aside,footer,' +\n 'header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,' +\n 'figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,' +\n 'data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,' +\n 'time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,' +\n 'canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,' +\n 'th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,' +\n 'option,output,progress,select,textarea,details,dialog,menu,' +\n 'summary,template,blockquote,iframe,tfoot';\n// https://developer.mozilla.org/en-US/docs/Web/SVG/Element\nconst SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' +\n 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' +\n 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' +\n 'feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' +\n 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' +\n 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' +\n 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' +\n 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' +\n 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' +\n 'text,textPath,title,tspan,unknown,use,view';\nconst VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr';\n/**\n * Compiler only.\n * Do NOT use in runtime code paths unless behind `(process.env.NODE_ENV !== 'production')` flag.\n */\nconst isHTMLTag = /*#__PURE__*/ makeMap(HTML_TAGS);\n/**\n * Compiler only.\n * Do NOT use in runtime code paths unless behind `(process.env.NODE_ENV !== 'production')` flag.\n */\nconst isSVGTag = /*#__PURE__*/ makeMap(SVG_TAGS);\n/**\n * Compiler only.\n * Do NOT use in runtime code paths unless behind `(process.env.NODE_ENV !== 'production')` flag.\n */\nconst isVoidTag = /*#__PURE__*/ makeMap(VOID_TAGS);\n\n/**\n * On the client we only need to offer special cases for boolean attributes that\n * have different names from their corresponding dom properties:\n * - itemscope -> N/A\n * - allowfullscreen -> allowFullscreen\n * - formnovalidate -> formNoValidate\n * - ismap -> isMap\n * - nomodule -> noModule\n * - novalidate -> noValidate\n * - readonly -> readOnly\n */\nconst specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;\nconst isSpecialBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs);\n/**\n * The full list is needed during SSR to produce the correct initial markup.\n */\nconst isBooleanAttr = /*#__PURE__*/ makeMap(specialBooleanAttrs +\n `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,` +\n `loop,open,required,reversed,scoped,seamless,` +\n `checked,muted,multiple,selected`);\n/**\n * Boolean attributes should be included if the value is truthy or ''.\n * e.g. `