>>8^n;return(t^-1)>>>0},MD5:function(e){var t=e&&typeof e.uppercase=="boolean"?e.uppercase:!1,n=e&&typeof e.pad=="string"?e.pad:"=",r=e&&typeof e.utf8=="boolean"?e.utf8:!0;this.hex=function(m){return Jr(a(m,r),t)},this.b64=function(m){return Xr(a(m),n)},this.any=function(m,p){return Zr(a(m,r),p)},this.raw=function(m){return a(m,r)},this.hex_hmac=function(m,p){return Jr(i(m,p),t)},this.b64_hmac=function(m,p){return Xr(i(m,p),n)},this.any_hmac=function(m,p,g){return Zr(i(m,p),g)},this.vm_test=function(){return hex("abc").toLowerCase()==="900150983cd24fb0d6963f7d28e17f72"},this.setUpperCase=function(m){return typeof m=="boolean"&&(t=m),this},this.setPad=function(m){return n=m||n,this},this.setUTF8=function(m){return typeof m=="boolean"&&(r=m),this};function a(m){return m=r?cn(m):m,_6(o(Qo(m),m.length*8))}function i(m,p){var g,b,h,f,y;for(m=r?cn(m):m,p=r?cn(p):p,g=Qo(m),g.length>16&&(g=o(g,m.length*8)),b=Array(16),h=Array(16),y=0;y<16;y+=1)b[y]=g[y]^909522486,h[y]=g[y]^1549556828;return f=o(b.concat(Qo(p)),512+p.length*8),_6(o(h.concat(f),512+128))}function o(m,p){var g,b,h,f,y,v=1732584193,S=-271733879,w=-1732584194,C=271733878;for(m[p>>5]|=128<>>9<<4)+14]=p,g=0;g16&&(d=o(d,l.length*8)),m=Array(16),p=Array(16),g=0;g<16;g+=1)m[g]=d[g]^909522486,p[g]=d[g]^1549556828;return b=o(m.concat(Sa(c)),512+c.length*8),Yo(o(p.concat(b),512+160))}function o(l,c){var d,m,p,g,b,h,f,y,v=Array(80),S=1732584193,w=-271733879,C=-1732584194,T=271733878,A=-1009589776;for(l[c>>5]|=128<<24-c%32,l[(c+64>>9<<4)+15]=c,d=0;d16&&(A=v(A,S.length*8));T<16;T+=1)D[T]=A[T]^909522486,I[T]=A[T]^1549556828;return C=v(D.concat(Sa(w)),512+w.length*8),Yo(v(I.concat(C),512+256))}function s(S,w){return S>>>w|S<<32-w}function u(S,w){return S>>>w}function l(S,w,C){return S&w^~S&C}function c(S,w,C){return S&w^S&C^w&C}function d(S){return s(S,2)^s(S,13)^s(S,22)}function m(S){return s(S,6)^s(S,11)^s(S,25)}function p(S){return s(S,7)^s(S,18)^u(S,3)}function g(S){return s(S,17)^s(S,19)^u(S,10)}function b(S){return s(S,28)^s(S,34)^s(S,39)}function h(S){return s(S,14)^s(S,18)^s(S,41)}function f(S){return s(S,1)^s(S,8)^u(S,7)}function y(S){return s(S,19)^s(S,61)^u(S,6)}a=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998];function v(S,w){var C=[1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225],T=new Array(64),A,D,I,F,R,B,P,_,O,z,V,ie;for(S[w>>5]|=128<<24-w%32,S[(w+64>>9<<4)+15]=w,O=0;O32&&(S=s(S,h.length*8));v<32;v+=1)w[v]=S[v]^909522486,C[v]=S[v]^1549556828;return y=s(w.concat(Sa(f)),1024+f.length*8),Yo(s(C.concat(y),1024+512))}function s(h,f){var y,v,S,w=new Array(80),C=new Array(16),T=[new u(1779033703,-205731576),new u(-1150833019,-2067093701),new u(1013904242,-23791573),new u(-1521486534,1595750129),new u(1359893119,-1377402159),new u(-1694144372,725511199),new u(528734635,-79577749),new u(1541459225,327033209)],A=new u(0,0),D=new u(0,0),I=new u(0,0),F=new u(0,0),R=new u(0,0),B=new u(0,0),P=new u(0,0),_=new u(0,0),O=new u(0,0),z=new u(0,0),V=new u(0,0),ie=new u(0,0),je=new u(0,0),Le=new u(0,0),N=new u(0,0),q=new u(0,0),Z=new u(0,0);for(a===void 0&&(a=[new u(1116352408,-685199838),new u(1899447441,602891725),new u(-1245643825,-330482897),new u(-373957723,-2121671748),new u(961987163,-213338824),new u(1508970993,-1241133031),new u(-1841331548,-1357295717),new u(-1424204075,-630357736),new u(-670586216,-1560083902),new u(310598401,1164996542),new u(607225278,1323610764),new u(1426881987,-704662302),new u(1925078388,-226784913),new u(-2132889090,991336113),new u(-1680079193,633803317),new u(-1046744716,-815192428),new u(-459576895,-1628353838),new u(-272742522,944711139),new u(264347078,-1953704523),new u(604807628,2007800933),new u(770255983,1495990901),new u(1249150122,1856431235),new u(1555081692,-1119749164),new u(1996064986,-2096016459),new u(-1740746414,-295247957),new u(-1473132947,766784016),new u(-1341970488,-1728372417),new u(-1084653625,-1091629340),new u(-958395405,1034457026),new u(-710438585,-1828018395),new u(113926993,-536640913),new u(338241895,168717936),new u(666307205,1188179964),new u(773529912,1546045734),new u(1294757372,1522805485),new u(1396182291,-1651133473),new u(1695183700,-1951439906),new u(1986661051,1014477480),new u(-2117940946,1206759142),new u(-1838011259,344077627),new u(-1564481375,1290863460),new u(-1474664885,-1136513023),new u(-1035236496,-789014639),new u(-949202525,106217008),new u(-778901479,-688958952),new u(-694614492,1432725776),new u(-200395387,1467031594),new u(275423344,851169720),new u(430227734,-1194143544),new u(506948616,1363258195),new u(659060556,-544281703),new u(883997877,-509917016),new u(958139571,-976659869),new u(1322822218,-482243893),new u(1537002063,2003034995),new u(1747873779,-692930397),new u(1955562222,1575990012),new u(2024104815,1125592928),new u(-2067236844,-1578062990),new u(-1933114872,442776044),new u(-1866530822,593698344),new u(-1538233109,-561857047),new u(-1090935817,-1295615723),new u(-965641998,-479046869),new u(-903397682,-366583396),new u(-779700025,566280711),new u(-354779690,-840897762),new u(-176337025,-294727304),new u(116418474,1914138554),new u(174292421,-1563912026),new u(289380356,-1090974290),new u(460393269,320620315),new u(685471733,587496836),new u(852142971,1086792851),new u(1017036298,365543100),new u(1126000580,-1676669620),new u(1288033470,-885112138),new u(1501505948,-60457430),new u(1607167915,987167468),new u(1816402316,1246189591)]),v=0;v<80;v+=1)w[v]=new u(0,0);for(h[f>>5]|=128<<24-(f&31),h[(f+128>>10<<5)+31]=f,S=h.length,v=0;v>>y|f.h<<32-y,h.h=f.h>>>y|f.l<<32-y}function d(h,f,y){h.l=f.h>>>y|f.l<<32-y,h.h=f.l>>>y|f.h<<32-y}function m(h,f,y){h.l=f.l>>>y|f.h<<32-y,h.h=f.h>>>y}function p(h,f,y){var v=(f.l&65535)+(y.l&65535),S=(f.l>>>16)+(y.l>>>16)+(v>>>16),w=(f.h&65535)+(y.h&65535)+(S>>>16),C=(f.h>>>16)+(y.h>>>16)+(w>>>16);h.l=v&65535|S<<16,h.h=w&65535|C<<16}function g(h,f,y,v,S){var w=(f.l&65535)+(y.l&65535)+(v.l&65535)+(S.l&65535),C=(f.l>>>16)+(y.l>>>16)+(v.l>>>16)+(S.l>>>16)+(w>>>16),T=(f.h&65535)+(y.h&65535)+(v.h&65535)+(S.h&65535)+(C>>>16),A=(f.h>>>16)+(y.h>>>16)+(v.h>>>16)+(S.h>>>16)+(T>>>16);h.l=w&65535|C<<16,h.h=T&65535|A<<16}function b(h,f,y,v,S,w){var C=(f.l&65535)+(y.l&65535)+(v.l&65535)+(S.l&65535)+(w.l&65535),T=(f.l>>>16)+(y.l>>>16)+(v.l>>>16)+(S.l>>>16)+(w.l>>>16)+(C>>>16),A=(f.h&65535)+(y.h&65535)+(v.h&65535)+(S.h&65535)+(w.h&65535)+(T>>>16),D=(f.h>>>16)+(y.h>>>16)+(v.h>>>16)+(S.h>>>16)+(w.h>>>16)+(A>>>16);h.l=C&65535|T<<16,h.h=A&65535|D<<16}},RMD160:function(e){var t=e&&typeof e.uppercase=="boolean"?e.uppercase:!1,n=e&&typeof e.pad=="string"?e.pa:"=",r=e&&typeof e.utf8=="boolean"?e.utf8:!0,a=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],i=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],o=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],s=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11];this.hex=function(b){return Jr(u(b,r))},this.b64=function(b){return Xr(u(b,r),n)},this.any=function(b,h){return Zr(u(b,r),h)},this.raw=function(b){return u(b,r)},this.hex_hmac=function(b,h){return Jr(l(b,h))},this.b64_hmac=function(b,h){return Xr(l(b,h),n)},this.any_hmac=function(b,h,f){return Zr(l(b,h),f)},this.vm_test=function(){return hex("abc").toLowerCase()==="900150983cd24fb0d6963f7d28e17f72"},this.setUpperCase=function(b){return typeof b=="boolean"&&(t=b),this},this.setPad=function(b){return typeof b<"u"&&(n=b),this},this.setUTF8=function(b){return typeof b=="boolean"&&(r=b),this};function u(b){return b=r?cn(b):b,c(d(Qo(b),b.length*8))}function l(b,h){b=r?cn(b):b,h=r?cn(h):h;var f,y,v=Qo(b),S=Array(16),w=Array(16);for(v.length>16&&(v=d(v,b.length*8)),f=0;f<16;f+=1)S[f]=v[f]^909522486,w[f]=v[f]^1549556828;return y=d(S.concat(Qo(h)),512+h.length*8),c(d(w.concat(y),512+160))}function c(b){var h,f="",y=b.length*32;for(h=0;h>5]>>>h%32&255);return f}function d(b,h){var f,y,v,S,w=1732584193,C=4023233417,T=2562383102,A=271733878,D=3285377520,I,F,R,B,P,_,O,z,V,ie;for(b[h>>5]|=128<>>9<<4)+14]=h,S=b.length,v=0;v[n,t]));SHA1;AccessKeyID="";AccessKeySecret="";isSupportList=!0;scene="general";maxTextGroupLength=50;maxTextLength=1e3;constructor(t,n,r,a){if(super(t,n,r,a),!t||!t.AccessKeyID||!t.AccessKeySecret)throw new j("AccessKeyID and AccessKeySecret are required");this.AccessKeyID=t.AccessKeyID?.trim(),this.AccessKeySecret=t.AccessKeySecret?.trim(),this.SHA1=new O6.SHA1,t.scene&&(this.scene=t.scene)}async translate(t){let{text:n,from:r,to:a}=t,i={FormatType:"text",Scene:this.scene,SourceLanguage:e.langMap.get(r)||"auto",SourceText:n,TargetLanguage:e.langMap.get(a)||a},o=this.scene=="general"?"TranslateGeneral":"Translate",s=await this.signedRequest({secretId:this.AccessKeyID,secretKey:this.AccessKeySecret,action:o,payload:i,service:"mt",version:"2018-10-12"});return{text:s.Data.Translated,from:s.Data.DetectedLanguage&&e.langMapReverse.get(s.Data.DetectedLanguage)||r||"auto",to:e.langMapReverse.get(a)||a}}async translateList(t){let{text:n,from:r,to:a}=t,i=this.scene=="general"?"translate_standard":"translate_ecommerce",o={FormatType:"text",Scene:this.scene,SourceLanguage:e.langMap.get(r)||"auto",SourceText:JSON.stringify(n.reduce((l,c,d)=>(l[d]=c,l),{})),TargetLanguage:e.langMap.get(a)||a,ApiType:i},s=await this.signedRequest({secretId:this.AccessKeyID,secretKey:this.AccessKeySecret,action:"GetBatchTranslate",payload:o,service:"mt",version:"2018-10-12"}),u=s.TranslatedList.length&&s.TranslatedList[0].detectedLanguage;return{text:s.TranslatedList.sort((l,c)=>parseInt(l.index)-parseInt(c.index)).map(l=>l.translated),from:u&&e.langMapReverse.get(u)||r||"auto",to:e.langMapReverse.get(a)||a}}encode(t){return encodeURIComponent(t).replace(/!/g,"%21").replace(/'/g,"%27").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A")}async signedRequest({secretId:t,secretKey:n,action:r,payload:a,service:i,version:o}){let s=new Date().toISOString(),u=Math.random().toString(36).slice(2),l={Action:r,Version:o,Format:"JSON",AccessKeyId:t,SignatureNonce:u,Timestamp:s,SignatureMethod:"HMAC-SHA1",SignatureVersion:"1.0"},d=(b=>{let f=Object.keys(b).sort().map(y=>`${this.encode(y)}=${this.encode(b[y])}`).join("&");return`POST&%2F&${this.encode(f)}`})(Object.assign({},l,a)),m=this.SHA1.b64_hmac(`${n}&`,d),p=new URLSearchParams(Object.assign({},l,{Signature:m})).toString(),g=await K({retry:this.retry,url:`https://${i}.aliyuncs.com?${p}`,method:"POST",headers:{"content-type":"application/x-www-form-urlencoded"},body:new URLSearchParams(a).toString(),timeout:this.requestTimeout});if(g instanceof Error)throw g;if(g.Code!=="200")throw new j(g.Message);return g}};var SP=["authorization","content-type","content-length","user-agent","presigned-expires","expect"],jt={algorithm:"HMAC-SHA256",v4Identifier:"request",dateHeader:"X-Date",tokenHeader:"X-Security-Token",contentSha256Header:"X-Content-Sha256",notSignBody:"X-NotSignBody",kDatePrefix:"",credential:"X-Credential",algorithmKey:"X-Algorithm",signHeadersKey:"X-SignedHeaders",signQueriesKey:"X-SignedQueries",signatureKey:"X-Signature"},Bg=e=>{try{return encodeURIComponent(e).replace(/[^A-Za-z0-9_.~\-%]+/g,escape).replace(/[*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`)}catch{return""}},_g=e=>Object.keys(e).map(t=>{let n=e[t];if(typeof n>"u"||n===null)return;let r=Bg(t);if(r)return Array.isArray(n)?`${r}=${n.map(Bg).sort().join(`&${r}=`)}`:`${r}=${Bg(n)}`}).filter(t=>t).join("&"),Jo=class{request;serviceName;bodySha256;constructor(t,n,r){this.request=t,this.request.headers=t.headers||{},this.serviceName=n,r=r||{},this.bodySha256=r.bodySha256,this.request.params=this.sortParams(this.request.params)}sortParams(t){let n={};return t&&Object.keys(t).filter(r=>{let a=t[r];return typeof a<"u"&&a!==null}).sort().map(r=>{n[r]=t[r]}),n}async addAuthorization(t,n){let r=this.getDateTime(n);await this.addHeaders(t,r),this.request.headers.Authorization=await this.authorization(t,r)}async authorization(t,n){let r=[],a=this.credentialString(n);return r.push(`${jt.algorithm} Credential=${t.accessKeyId}/${a}`),r.push(`SignedHeaders=${this.signedHeaders()}`),r.push(`Signature=${await this.signature(t,n)}`),r.join(", ")}async getSignUrl(t,n){let r=this.getDateTime(n),a={...this.request.params},i=this.request.params,o=this.request.headers;t.sessionToken&&(a[jt.tokenHeader]=t.sessionToken),a[jt.dateHeader]=r,a[jt.notSignBody]="",a[jt.credential]=`${t.accessKeyId}/${this.credentialString(r)}`,a[jt.algorithmKey]=jt.algorithm,a[jt.signHeadersKey]="",a[jt.signQueriesKey]=void 0,a[jt.signatureKey]=void 0,a=this.sortParams(a),this.request.params=a,this.request.headers={};let s=await this.signature(t,r);return this.request.params=i,this.request.headers=o,a[jt.signQueriesKey]=Object.keys(a).sort().join(";"),a[jt.signatureKey]=s,_g(a)}getDateTime(t){return this.iso8601(t).replace(/[:\-]|\.\d{3}/g,"")}async addHeaders(t,n){if(this.request.headers[jt.dateHeader]=n,t.sessionToken&&(this.request.headers[jt.tokenHeader]=t.sessionToken),this.request.body){let r=this.request.body;this.request.headers[jt.contentSha256Header]=await Hn(r)}}async signature(t,n){let r=await this.getSigningKey(t,n.substr(0,8),this.request.region,this.serviceName);return Uo(await ar(await this.stringToSign(n),r))}async stringToSign(t){let n=[];n.push(jt.algorithm),n.push(t),n.push(this.credentialString(t));let r=await this.canonicalString();return n.push(await this.hexEncodedHash(r)),n.join(`
+`)}async canonicalString(){let t=[],n=this.request.pathname||"/";t.push(this.request.method.toUpperCase()),t.push(n);let r=_g(this.request.params)||"";return t.push(r),t.push(`${this.canonicalHeaders()}
`),t.push(this.signedHeaders()),t.push(await this.hexEncodedBodyHash()),t.join(`
`)}canonicalHeaders(){let t=[];Object.keys(this.request.headers).forEach(r=>{t.push([r,this.request.headers[r]])}),t.sort((r,a)=>r[0].toLowerCase(){let a=r[0].toLowerCase();if(this.isSignableHeader(a)){let i=r[1];if(typeof i>"u"||i===null||typeof i.toString!="function")throw new j(`Header ${a} contains invalid value`);n.push(`${a}:${this.canonicalHeaderValues(i.toString())}`)}}),n.join(`
-`)}canonicalHeaderValues(t){return t.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")}signedHeaders(){let t=[];return Object.keys(this.request.headers).forEach(n=>{n=n.toLowerCase(),this.isSignableHeader(n)&&t.push(n)}),t.sort().join(";")}signedQueries(){return Object.keys(this.request.params).join(";")}credentialString(t){return this.createScope(t.substr(0,8),this.request.region,this.serviceName)}async hexEncodedHash(t){return await Hn(t)}async hexEncodedBodyHash(){return this.request.headers[jt.contentSha256Header]?this.request.headers[jt.contentSha256Header]:this.request.body?await this.hexEncodedHash(Bg(this.request.body)):await this.hexEncodedHash("")}isSignableHeader(t){return SP.indexOf(t)<0}iso8601(t){return t===void 0&&(t=new Date),t.toISOString().replace(/\.\d{3}Z$/,"Z")}async getSigningKey(t,n,r,a){let i=await ar(n,`${jt.kDatePrefix}${t.secretKey}`),o=await ar(r,i),s=await ar(a,o);return ar(jt.v4Identifier,s)}createScope(t,n,r){return[t.substr(0,8),n,r,jt.v4Identifier].join("/")}};var j6=[["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["en","en"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fj","fj"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["he","he"],["hi","hi"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["tn","tn"],["to","to"],["tr","tr"],["ty","ty"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zh-CN","zh"],["zh-TW","zh-Hans"],["zu","zu"]],_g=new Map(j6),TP=new Map(j6.map(([e,t])=>[t,e])),Og=class extends Ee{static langMap=_g;accessKeyId="";secretAccessKey="";maxTextGroupLength=8;constructor(t,n,r,a){if(super(t,n,r,a),!t||!t.accessKeyId||!t.secretAccessKey)throw new j("accessKeyId and secretAccessKey are required");this.accessKeyId=t.accessKeyId?.trim(),this.secretAccessKey=t.secretAccessKey?.trim()}async remoteDetectLanguage(t){let r={region:"cn-north-1",method:"POST",params:{Action:"LangDetect",Version:"2020-06-01"},pathname:"/",headers:{"Content-Type":"application/json",host:"open.volcengineapi.com"},body:JSON.stringify({TextList:[t]})},a=new Qo(r,"translate");await a.addAuthorization({accessKeyId:this.accessKeyId,secretKey:this.secretAccessKey});let i=new URLSearchParams(r.params),o=await K({retry:2,url:"https://open.volcengineapi.com"+r.pathname+"?"+i.toString(),headers:a.request.headers,method:r.method,body:r.body});if(o.DetectedLanguageList&&o.DetectedLanguageList.length>0)return o.DetectedLanguageList[0].Language;if(o.ResponseMetadata&&o.ResponseMetadata.Error){let s=o.ResponseMetadata.Error;throw new j(s.Code,s.Message)}else if(o.ResponseMetaData&&o.ResponseMetaData.Error){let s=o.ResponseMetaData.Error;throw new j(s.Code,s.Message)}else throw new j("response: "+JSON.stringify(o))}async translateList(t){let{text:n,from:r,to:a}=t,i=_g.get(r),o={TargetLanguage:_g.get(a)||a,TextList:n};i?o.SourceLanguage=i:o.SourceLanguage=await this.remoteDetectLanguage(n.join(`
-`).slice(0,1e3));let s={region:"cn-north-1",method:"POST",params:{Action:"TranslateText",Version:"2020-06-01"},pathname:"/",headers:{"Content-Type":"application/json",host:"open.volcengineapi.com"},body:JSON.stringify(o)},u=new Qo(s,"translate");await u.addAuthorization({accessKeyId:this.accessKeyId,secretKey:this.secretAccessKey});let l=new URLSearchParams(s.params),c=await K({retry:2,url:"https://open.volcengineapi.com"+s.pathname+"?"+l.toString(),headers:u.request.headers,method:s.method,body:s.body});if(c.TranslationList){let d=c.TranslationList.map(p=>p.Translation),m=r;return c.TranslationList.length>0&&c.TranslationList[0].DetectedSourceLanguage&&(m=TP.get(c.TranslationList[0].DetectedSourceLanguage)||r),{text:d,from:m,to:a}}else if(c.ResponseMetadata&&c.ResponseMetadata.Error){let d=c.ResponseMetadata.Error;throw new j(d.Code,d.Message)}else if(c.ResponseMetaData&&c.ResponseMetaData.Error){let d=c.ResponseMetaData.Error;throw new j(d.Code,d.Message)}else throw new j("response: "+JSON.stringify(c))}},U6=Og;var H6=[["auto","detect"],["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["en","en"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fj","fj"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["he","he"],["hi","hi"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["tn","tn"],["to","to"],["tr","tr"],["ty","ty"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zh-CN","zh"],["zh-TW","zh-Hans"],["zu","zu"]],Ng=new Map(H6),CP=new Map(H6.map(([e,t])=>[t,e])),Tu=class extends Ee{static langMap=Ng;maxTextGroupLength=50;isSupportList=!1;async translate(t){let{text:n,from:r,to:a}=t,i=Ng.get(r)||"detect",o=Ng.get(a)||a,u=await K({url:"https://translate.volcengine.com/crx/translate/v1/",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_language:i,target_language:o,text:n}),retry:this.retry});if(u.base_resp&&u.base_resp.status_code===0){let l=u.translation,c=r;return u.detected_language&&(c=CP.get(u.detected_language)||r),{text:l,from:c,to:a}}else{let l=u.base_resp;throw new j(l.status_code.toString(),l.status_message)}}};var wP=[["auto","auto"],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH-HANT"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],jg=new Map(wP),Cu=class extends Ee{static langMap=jg;url="";isSupportList=!1;maxTextGroupLength=1;apiKeys=[];constructor(t,n,r,a){if(super(t,n,r,a),!t||!t.url)throw new j("deeplx custom url are required, please check your settings.");this.url=t.url,this.apiKeys=this.url.split(",").map(i=>i.trim())}getRandomKey(){let t=Math.floor(Math.random()*this.apiKeys.length);return this.apiKeys[t]}async translate(t){let{text:n,from:r,to:a}=t,i=this.getRandomKey(),o={source_lang:jg.get(r)||r,target_lang:jg.get(a)||a,text:n,tag_handling:"html"};this.isRichTranslate||delete o.tag_handling;let u=await K({retry:this.retry,url:i,headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify(o),timeout:this.requestTimeout});if(u.code===200)return{text:Tg(this.serviceConfig,u.data,a),from:r,to:a};throw new j(u.message||u.message||"API Error")}};var q6=[["auto","auto"],["zh-CN","zh"],["en","en"],["yue","yue"],["wyw","wyw"],["ja","jp"],["ko","kor"],["fr","fra"],["es","spa"],["th","th"],["ar","ara"],["ru","ru"],["pt","pt"],["de","de"],["it","it"],["el","el"],["nl","nl"],["pl","pl"],["bg","bul"],["et","est"],["da","dan"],["fi","fin"],["cs","cs"],["ro","rom"],["sl","slo"],["sv","swe"],["hu","hu"],["zh-TW","cht"],["vi","vie"]],Ug=new Map(q6),EP=new Map(q6.map(([e,t])=>[t,e])),Hg=class extends Ee{static langMap=Ug;endpoint="https://api.fanyi.baidu.com/api/trans/vip/translate";fieldEndpoint="https://fanyi-api.baidu.com/api/trans/vip/fieldtranslate";appid="";key="";isSupportList=!1;maxTextGroupLength=3;action=!1;domain="";constructor(t,n,r,a){if(super(t,n,r,a),!t||!t.appid||!t.key)throw new j("appid and key are required");this.appid=t.appid?.trim(),this.key=t.key?.trim(),t.action&&(this.action=!0),t.endpoint&&(this.endpoint=t.endpoint),t.fieldEndpoint&&(this.fieldEndpoint=t.fieldEndpoint),t.domain&&(this.domain=t.domain,this.endpoint=this.fieldEndpoint)}getDefaultRateLimit(){return{limit:1,interval:1550}}async translate(t){let n=Date.now().toString(),{endpoint:r}=this,{appid:a,key:i}=this,{text:o,from:s,to:u}=t,l=nr(a+o+n+i);this.domain&&(l=nr(a+o+n+this.domain+i));let c=new URLSearchParams({from:Ug.get(s)||"auto",to:Ug.get(u)||u,q:o,salt:n,appid:a,sign:l});this.action&&c.set("action","1"),this.domain&&c.set("domain",this.domain);let d=new URL(r);d.search=c.toString();let m=await K({url:d.toString(),retry:this.retry,timeout:this.requestTimeout});if(m.error_code)throw new j("API_SERVER_ERROR",m.error_msg);let{trans_result:p,from:g}=m,b=p.map(({dst:f})=>f);return{from:EP.get(g)||g,to:u,text:b.join(`
-`)}}},z6=Hg;var _i=class extends Ee{langMap;requestBaseConfig;apiServiceConfig;constructor(t,n,r,a){super(t,n,r,a),this.apiServiceConfig=this.serviceConfig,this.isSupportList=this.apiServiceConfig.isSupportList,this.langMap=new Map(this.apiServiceConfig.langs),this.requestBaseConfig=this.handleBaseApiServiceConfig(this.apiServiceConfig)}async translate(t){if(!Object.keys(this.apiServiceConfig).length)throw"serivce id not found config";let{text:n,from:r,to:a}=t;if(!this.langMap.has(a))throw new j(`Unsupported language: ${a}`);a=this.langMap.get(a);let i=await this.checkLang(r,n);if(!i)return{text:n,from:r,to:a};r=i;let o=this.handleRequest(n,r,a),s=await Xs(o);return{text:this.handleResponseText(s),from:r,to:a}}async translateList(t){if(!Object.keys(this.apiServiceConfig).length)throw new j("serivce id not found config");let{text:n,from:r,to:a}=t;if(!this.langMap.has(a))throw new j(`Unsupported language: ${a}`);a=this.langMap.get(a);let i=await this.checkLang(r,n.join(" "));if(!i)return{text:n,from:r,to:a};r=i;let o=this.handleRequest(n,r,a),s=await Xs(o);return{text:this.handleResponseText(s),from:r,to:a}}handleBaseApiServiceConfig(t){let n=t.request.url,r=t.request.headers||{};return r["content-type"]||(r["content-type"]="application/json"),{url:n,retry:t.request.retry||this.retry,method:t.request.method||"POST",headers:r,body:JSON.stringify(t.request.body),timeout:this.requestTimeout}}async checkLang(t,n){if(t=="auto"){if(this.langMap.has("auto"))return"auto";t=await this.detectLanguageRemotely(n.slice(0,this.apiServiceConfig.checkLangLenth||10))}return this.langMap.has(t)?this.langMap.get(t):null}handleRequest(t,n,r){let a={...this.requestBaseConfig},i=a?.body||"",o=this.apiServiceConfig.keywords||{};a.body=u(i);let s=a.headers||{};return Object.keys(s).forEach(l=>{s[l]=u(s[l])}),a.headers={...s,...this.headerConfigs},a.url=u(a.url||""),a;function u(l){return l.replaceAll('"{text}"',()=>Array.isArray(t)?JSON.stringify(t):`"${t}"`).replaceAll("{from}",n).replaceAll("{to}",r).replaceAll(/{([a-z:_]+)}/gi,(d,m)=>{let[p,g]=m.split(":"),b=o[p];return g==="random"?AP(b.split(",")):b})}}handleResponseText(t){let n=this.apiServiceConfig.response,r=t,a=n.text.split(".");for(let i of a){if(Array.isArray(r))return r=r.map(o=>o[i]),r;r=r[i]}return r}detectLanguageRemotely(t){return ha.detectLanguageRemotelyByTransmart(t)}};function AP(e){let t=Math.floor(Math.random()*e.length);return e[t]}var W6=[["zh-CN","zh"],["en","en"],["ja","ja"],["ko","ko"],["fr","fr"],["es","es"],["ru","ru"]],qg=class extends _i{static langMap=new Map(W6);constructor(t,n,r,a){if(!t?.token)throw new j("token are required");super({...t,isSupportList:!0,langs:W6,keywords:{token:t.token?.trim()},request:{headers:{"content-type":"application/json","x-authorization":"token {token:random}"},url:"https://api.interpreter.caiyunai.com/v1/translator",retry:2,body:{source:"{text}",trans_type:"{from}2{to}"}},response:{text:"target"}},n,r,a)}},G6=qg;var kP=[["auto","auto"],["zh-CN","zh"],["en","en"],["ja","ja"]],C0=new Map(kP),zg=class extends Ee{static langMap=C0;token="ssdj273ksdiwi923bsd9";constructor(t,n,r,a){super(t,n,r,a)}getDefaultRateLimit(){return{limit:5,interval:1050}}async translateList(t){let{text:n,from:r,to:a}=t;if(!C0.get(a))throw new j(`Unsupported language: ${a}`);if(r==="auto")throw new j("Unsupported language: auto");let o=n;return{text:(await K({retry:this.retry,url:"https://api.interpreter.caiyunai.com/v1/translator",headers:{"content-type":"application/json","x-authorization":"token "+this.token},method:"POST",body:JSON.stringify({source:o,trans_type:`${C0.get(r)||"auto"}2${C0.get(a)}`}),timeout:this.requestTimeout})).target,from:r,to:a}}},V6=zg;var K6=[["auto","auto"],["en","en"],["ru","ru"],["pt","pt"],["es","es"],["zh-CN","zh-CHS"],["ja","ja"],["ko","ko"],["fr","fr"],["ar","ar"],["id","id"],["vi","vi"],["it","it"]],Wg=new Map(K6),DP=new Map(K6.map(([e,t])=>[t,e]));function LP(e){let t=e.length;return t<=20?e:e.substring(0,10)+t+e.substring(t-10,t)}var Gg=class extends Ee{static langMap=Wg;isSupportList=!1;appId="";appSecret="";throttleLimit=5;domain="general";vocabId="";constructor(t,n,r,a){if(super(t,n,r,a),!t||!t.appId||!t.appSecret)throw new j("appId and appSecret are required");this.appId=t.appId?.trim(),this.appSecret=t.appSecret?.trim(),t.domain&&(this.domain=t.domain),t&&t.vocabId&&(this.vocabId=t.vocabId)}getDefaultRateLimit(){return{limit:5,interval:1050}}async translate(t){let{text:n,from:r,to:a}=t,i=PP(32),o=Math.round(new Date().getTime()/1e3),s=this.appId+LP(n)+i+o+this.appSecret,u=await Hn(s),l={q:n,appKey:this.appId,salt:i.toString(),from:Wg.get(r)||"auto",to:Wg.get(a)||a,sign:u,signType:"v3",curtime:o.toString()};this.domain&&this.domain!=="general"&&(l.domain=this.domain),this.vocabId&&(l.vocabId=this.vocabId);let c=new URLSearchParams(l),m=await K({url:"https://openapi.youdao.com/api",method:"POST",body:c.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"},retry:this.retry,timeout:this.requestTimeout});if(!m.translation)throw new j(JSON.stringify(m));let p=m.l,[g,b]=p.split("2");return{text:m.translation.join(`
-`),from:DP.get(g),to:a}}};function PP(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a[t,e]));var Kg=class extends Ee{static langMap=Vg;isSupportList=!1;appId="";appSecret="";maxTextLength=800;constructor(t,n,r,a){super(t,n,r,a)}getDefaultRateLimit(){return{limit:5,interval:1050}}async translate(t){let{text:n,from:r,to:a}=t,i={q:n,from:Vg.get(r)||"auto",to:Vg.get(a)||a},o=new URLSearchParams(i),s=await K({url:"https://aidemo.youdao.com/trans",method:"POST",body:o.toString(),headers:{"content-type":"application/x-www-form-urlencoded; charset=UTF-8","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"},retry:this.retry,timeout:this.requestTimeout});if(s&&s.translation)return{text:s.translation.join(`
-`),from:r,to:a};throw new j("Youdao translation failed: "+JSON.stringify(s))}},J6=Kg;var wu=class extends _i{constructor(t,n,r,a){super({...t,isSupportList:!0,langs:(t.langs||"zh-CN,en").split(",").map(i=>[i,i]),limitPerSecond:t.limitPerSecond||5,maxTextLengthPerRequest:t.maxTextLengthPerRequest||1200,maxTextGroupLengthPerRequest:t.maxTextGroupLengthPerRequest||1,placeholderDelimiters:t.placeholderDelimiters||io,request:{url:t.url,retry:2,body:{text_list:"{text}",source_lang:"{from}",target_lang:"{to}"}},response:{text:"translations.text"}},n,r,a)}};var Yg=class extends Xa{provider="custom";immersiveProApiUrl="";temperature=0;userToken="";initPro(t,n){if(t.provider&&(this.provider=t.provider),t.temperature!==void 0&&(this.temperature=parseFloat(t.temperature)),this.provider==="pro"){if(this.userToken=n.userToken||"",!this.userToken)throw new j("Login required, \u767B\u5F55\u540E\u624D\u53EF\u4EE5\u4F7F\u7528\u3002");if(!n.isPro)throw new j("Please activate Pro membership first, \u8BF7\u5148\u5F00\u901A Pro \u4F1A\u5458\u3002");t.proModel&&(t.model=t.proModel,this.model=t.proModel),t.proLimit&&(t.limit=t.proLimit),t&&t.immersiveProApiUrl&&(this.immersiveProApiUrl=xt(this.immersiveProApiUrl,t.immersiveProApiUrl))}}handleProOptions(t,n,r){let a={};r.refresh&&(a["X-Refresh"]="True"),r.debug&&(a["X-Debug"]="True");let i=[{role:"system",content:t},{role:"user",content:n}],o={...this.bodyConfigs,model:this.model,temperature:this.temperature,messages:i};isNaN(o.temperature)&&delete o.temperature;let s={url:this.immersiveProApiUrl,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o,null,2),timeout:this.requestTimeout,retry:this.retry};return s.headers.token=this.userToken,s.headers={...s.headers,...a},s}parseProResponse(t){return t?.choices?.[0]?.message?.content?.trim()}},w0=Yg;var Z6=L+"-gemini-fake-user-key",MP=[["auto","auto"],["zh-CN","Simplified Chinese"],["zh-TW","Traditional Chinese"],["en","English"],["ar","Arabic"],["bn","Bengali"],["bg","Bulgarian"],["hr","Croatian"],["cs","Czech"],["da","Danish"],["nl","Dutch"],["et","Estonian"],["fi","Finnish"],["fr","French"],["de","German"],["el","Greek"],["he","iw"],["hi","Hindi"],["hu","Hungarian"],["id","Indonesian"],["it","Italian"],["ja","Japanese"],["ko","Korean"],["lv","Latvian"],["lt","Lithuanian"],["no","Norway"],["pl","Polish"],["pt","Portuguese"],["ro","Romanian"],["ru","Russian"],["sr","Serbian"],["sk","Slovak"],["sl","Slovene"],["es","Spanish"],["sw","Swahili"],["sv","Swedish"],["th","Thai"],["tr","Turkish"],["uk","Ukrainian"],["vi","Vietnamese"]],X6=new Map(MP),Qg=class extends w0{static langMap=X6;provider="custom";randomPrefix="My user id is {{id}}. ";fakeId="";immersiveProApiUrl=rt+"gemini/translate";constructor(t,n,r,a){super(t,n,r,a),t||(t={}),t.provider&&(this.provider=t.provider),t.randomPrefix&&t.randomPrefix!==void 0&&(this.randomPrefix=t.randomPrefix),this.apiUrl="https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}",t?.apiUrl&&(this.apiUrl=t.apiUrl),this.maxTextGroupLength=this.maxTextGroupLength||10,this.model=this.model||"gemini-1.5-pro-latest",this.initPro(t,r)}getLangMap(){return X6}getDefaultRateLimit(){return{limit:1,interval:1050}}async handleOptions({systemPrompt:t,finalPrompt:n,payload:r}){if(this.provider=="pro")return this.handleProOptions(t,n,r);this.fakeId="",this.randomPrefix&&this.randomPrefix?.trim()&&this.randomPrefix!=="none"&&(this.fakeId=await wi(Z6,""),this.fakeId||(this.fakeId=RP(10),await Ei(Z6,this.fakeId)));let a=this.getRandomKey(),i={url:this.apiUrl.replace("{model}",this.model),method:"POST",headers:{"content-type":"application/json",...this.headerConfigs},timeout:this.requestTimeout,retry:this.retry};a&&(i.url=i.url.replace("{key}",a));let o=this.systemPrompt+" "+n;this.randomPrefix&&this.randomPrefix?.trim()&&this.randomPrefix!=="none"&&(o=this.randomPrefix.replace("{{id}}",this.fakeId)+o);let s={contents:[{role:"user",parts:[{text:o}]}],...this.bodyConfigs};return i.body=JSON.stringify(s,null,2),i}parseResponse(t){if(this.provider=="pro")return this.parseProResponse(t);let n=t?.candidates?.[0]?.content?.parts?.[0]?.text;if(!n&&t?.promptFeedback)throw new j("parseResponse",JSON.stringify(t));return n||""}filterContent(t,n,r,a){if(this.provider=="pro")return super.filterContent(t,n,r);let i=super.filterContent(t,n,r);return this.fakeId&&i?.includes(this.fakeId)&&a.length<=1?t:i}};function RP(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let n=(await Kr({url:"https://translate.yandex.net/website-widget/v1/widget.js?widgetId=ytWidget&pageLang=es&widgetTheme=light&autoMode=false",method:"GET",responseType:"text"})).match(/sid\:\s\'[0-9a-f\.]+/),r="",a=Date.now()+1*60*1e3;return n&&n[0]&&n[0].length>7&&(r=n[0].substring(6),a=Date.now()+30*60*1e3),{accessToken:r,accessTokenExpiresAt:new Date(a).toISOString()}})}async translateList(t){let{text:n,from:r,to:a}=t;if(!n)return{...t};let i=await this.getAccessToken(),o=new URLSearchParams;o.append("srv","tr-url-widget"),o.append("id",`${i.accessToken}-0-0`),o.append("format","html"),o.append("lang",`${r==="auto"?"":Zg.get(r)+"-"}${Zg.get(a)}`),n.forEach(l=>{o.append("text",l)});let s=await K({url:`https://translate.yandex.net/api/v1/tr.json/translate?${o.toString()}`});if(s?.code!==200)return{...t};let u=s.text?.map(l=>l);return{from:r,to:a,text:u||n}}getDefaultRateLimit(){return{limit:5,interval:1050}}};var BP=[["auto","auto"],["zh-CN","Simplified Chinese"],["zh-TW","Traditional Chinese"],["en","English"],["ja","Japanese"],["ko","Korean"],["fr","French"],["de","German"],["es","Spanish"],["it","Italian"],["ru","Russian"],["pt","Portuguese"],["pt-br","Portuguese (Brazil)"],["nl","Dutch"],["pl","Polish"],["ar","Arabic"],["af","Afrikaans"],["am","Amharic"],["az","Azerbaijani"],["be","Belarusian"],["bg","Bulgarian"],["bn","Bengali"],["bs","Bosnian"],["ca","Catalan"],["ceb","Cebuano"],["co","Corsican"],["cs","Czech"],["cy","Welsh"],["da","Danish"],["el","Greek"],["eo","Esperanto"],["et","Estonian"],["eu","Basque"],["fa","Persian"],["fi","Finnish"],["fil","Filipino"],["ga","Irish"],["gd","Scots Gaelic"],["gl","Galician"],["gu","Gujarati"],["ha","Hausa"],["haw","Hawaiian"],["he","Hebrew"],["hi","Hindi"],["hmn","Hmong"],["hr","Croatian"],["ht","Haitian Creole"],["hu","Hungarian"],["hy","Armenian"],["id","Indonesian"],["ig","Igbo"],["is","Icelandic"],["jw","Javanese"],["ka","Georgian"],["kk","Kazakh"],["km","Khmer"],["kn","Kannada"],["ku","Kurdish (Kurmanji)"],["ky","Kyrgyz"],["lb","Luxembourgish"],["lo","Lao"],["lt","Lithuanian"],["lv","Latvian"],["mg","Malagasy"],["mi","Maori"],["mk","Macedonian"],["ml","Malayalam"],["mn","Mongolian"],["mr","Marathi"],["ms","Malay"],["mt","Maltese"],["my","Myanmar (Burmese)"],["pa","Punjabi"],["ps","Pashto"],["ro","Romanian"],["si","Sinhala (Sinhalese)"],["sk","Slovak"],["sl","Slovenian"],["sa","Sanskrit"],["sm","Samoan"],["sn","Shona"],["so","Somali"],["sq","Albanian"],["sr","Serbian"],["st","Sesotho"],["su","Sundanese"],["sv","Swedish"],["sw","Swahili"],["ta","Tamil"],["te","Telugu"],["tg","Tajik"],["th","Thai"],["tr","Turkish"],["ug","Uyghur"],["uk","Ukrainian"],["ur","Urdu"],["uz","Uzbek"],["vi","Vietnamese"],["xh","Xhosa"],["yi","Yiddish"],["yo","Yoruba"],["zu","Zulu"]],nx=new Map(BP),Au=class extends Xa{static langMap=nx;provider="custom";temperature=1;AccessKeyID="";AccessKeySecret="";constructor(t,n,r,a){super(t,n,r,a),t||(t={}),t.provider&&(this.provider=t.provider),t.temperature!==void 0&&(this.temperature=parseFloat(t.temperature)),this.AccessKeyID=t.AccessKeyID?.trim(),this.AccessKeySecret=t.AccessKeySecret?.trim(),this.apiUrl="https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/{model}?access_token={key}",t.apiUrl&&(this.apiUrl=xt(this.apiUrl,t.apiUrl)),this.model=t.model||"ernie_speed",this.maxTextGroupLength=this.maxTextGroupLength||10,this.bodyConfigs=t?.bodyConfigs||{}}async getAccessToken(t,n){return await Yr(Om+t,()=>this.requestAccessToken(t,n))}async requestAccessToken(t,n){let r=await Kr({url:`https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=${t}&client_secret=${n}`,method:"POST",responseType:"json"}),i=Date.now()+r.expires_in*1e3,s=new Date(i).toISOString();return{accessToken:r.access_token,accessTokenExpiresAt:s}}getLangMap(){return nx}getDefaultRateLimit(){return{limit:10,interval:1300}}parseResponse(t){if(t.error_code&&t.error_msg)throw t.error_code===110||t.error_code===111?(x0(Om+this.AccessKeyID,()=>this.requestAccessToken(this.AccessKeyID,this.AccessKeySecret)),new j("token\u8FC7\u671F\uFF0C\u5DF2\u91CD\u65B0\u751F\u6210\uFF0C\u8BF7\u91CD\u8BD5")):new j(t.error_msg);return t?.result?.trim()||""}async handleOptions({systemPrompt:t,finalPrompt:n,payload:r}){let a={};r.refresh&&(a["X-Refresh"]="True"),r.debug&&(a["X-Debug"]="True");let i=[{role:"user",content:t},{role:"assistant",content:"ok"},{role:"user",content:n}],o={temperature:this.temperature,messages:i,...this.bodyConfigs};isNaN(o.temperature)&&delete o.temperature;let s={url:this.apiUrl.replace("{model}",this.model),method:"POST",headers:{"Content-Type":"application/json",...this.headerConfigs},body:JSON.stringify(o,null,2),timeout:this.requestTimeout,retry:this.retry},{accessToken:u}=await this.getAccessToken(this.AccessKeyID,this.AccessKeySecret);return s.headers={...s.headers,...a},u&&(s.url=s.url.replace("{key}",u)),s}};var _P=[["auto","auto"],["zh-CN","Simplified Chinese"],["zh-TW","Traditional Chinese"],["zh-CN-NE","Northeastern Chinese"],["en","English"],["yue","Cantonese"],["bo","\u85CF\u8BED"],["wyw","Classical Chinese"],["ja","Japanese"],["ko","Korean"],["fr","French"],["de","German"],["es","Spanish"],["it","Italian"],["ru","Russian"],["pt","Portuguese"],["pt-br","Portuguese (Brazil)"],["nl","Dutch"],["pl","Polish"],["ar","Arabic"],["af","Afrikaans"],["am","Amharic"],["az","Azerbaijani"],["be","Belarusian"],["bg","Bulgarian"],["bn","Bengali"],["bs","Bosnian"],["ca","Catalan"],["ceb","Cebuano"],["co","Corsican"],["cs","Czech"],["cy","Welsh"],["da","Danish"],["el","Greek"],["eo","Esperanto"],["et","Estonian"],["eu","Basque"],["fa","Persian"],["fi","Finnish"],["fj","Fijian"],["fil","Filipino"],["fy","Western Frisian"],["ga","Irish"],["gd","Scottish Gaelic"],["gl","Galician"],["gu","Gujarati"],["ha","Hausa"],["haw","Hawaiian"],["he","Hebrew"],["hi","Hindi"],["hmn","Hmong"],["hr","Croatian"],["ht","Haitian Creole"],["hu","Hungarian"],["hy","Armenian"],["id","Indonesian"],["ig","Igbo"],["is","Icelandic"],["jw","Javanese"],["ka","Georgian"],["kk","Kazakh"],["km","Khmer"],["kn","Kannada"],["ku","Kurdish"],["ky","Kyrgyz"],["la","Lao"],["lb","Luxembourgish"],["lo","Lao"],["lt","Lithuanian"],["lv","Latvian"],["mg","Malagasy"],["mi","Maori"],["mk","Macedonian"],["ml","Malayalam"],["mn","Mongolian"],["mr","Marathi"],["ms","Malay"],["mt","Maltese"],["my","Burmese"],["pa","Punjabi"],["ps","Pashto"],["ro","Romanian"],["si","Sinhala"],["sk","Slovak"],["sl","Slovene"],["sa","Sanskrit"],["sm","Samoan"],["sn","Shona"],["so","Somali"],["sq","Albanian"],["sr","Serbian"],["sr-Cyrl","Serbian (Cyrillic)"],["sr-Latn","Serbian (Latin)"],["st","Southern Sotho"],["su","Sundanese"],["sv","Swedish"],["sw","Swahili"],["ta","Tamil"],["te","Telugu"],["tg","Tajik"],["th","Thai"],["tr","Turkish"],["ug","Uyghur"],["uk","Ukrainian"],["ur","Urdu"],["ur-roman","Roman Urdu"],["uz","Uzbek"],["vi","Vietnamese"],["xh","Xhosa"],["yi","Yiddish"],["yo","Yoruba"],["zu","Zulu"]],rx=new Map(_P),qn=class extends Xa{static langMap=rx;provider="custom";temperature=0;constructor(t,n,r,a){super(t,n,r,a),t||(t={}),t.provider&&(this.provider=t.provider),t.temperature!==void 0&&(this.temperature=parseFloat(t.temperature)),this.apiUrl="https://api.openai.com/v1/chat/completions",t.apiUrl&&(this.apiUrl=xt(this.apiUrl,t.apiUrl)),this.model=t.model||"gpt-3.5-turbo"}getLangMap(){return rx}getDefaultRateLimit(){return{limit:10,interval:1300}}parseResponse(t){return t?.choices?.[0]?.message?.content?.trim()||""}async handleOptions({systemPrompt:t,finalPrompt:n,payload:r}){let a={};r.refresh&&(a["X-Refresh"]="True"),r.debug&&(a["X-Debug"]="True");let i=[];t&&i.push({role:"system",content:t}),n&&i.push({role:"user",content:n});let o={model:this.model,temperature:this.temperature,messages:i,...this.bodyConfigs};isNaN(o.temperature)&&delete o.temperature;let s={url:this.apiUrl,method:"POST",headers:{"Content-Type":"application/json",...this.headerConfigs},body:JSON.stringify(o,null,2),timeout:this.requestTimeout,retry:this.retry},u=this.getRandomKey();return s.headers.Authorization="Bearer "+u,s.headers["api-key"]=u,s}};var E0=class extends qn{action="ChatCompletions";version="2023-09-01";secret_id;secret_key;service="hunyuan";constructor(t,n,r,a){super(t,n,r,a),this.apiUrl="https://hunyuan.tencentcloudapi.com",this.model=t.model||"hunyuan-lite",this.secret_id=t.secret_id,this.secret_key=t.secret_key}parseResponse(t){let n=t.Response;if(n?.Error)throw new j(n?.Error.Message);return n?.Choices?.[0]?.Message?.Content?.trim()||""}async handleOptions({systemPrompt:t,finalPrompt:n,payload:r}){let a={},i=new Date;r.refresh&&(a["X-Refresh"]="True"),r.debug&&(a["X-Debug"]="True");let o=[{Role:"system",Content:t},{Role:"user",Content:n}],s={Model:this.model,Temperature:this.temperature,Messages:o,...this.bodyConfigs};isNaN(s.Temperature)&&delete s.Temperature;let u=JSON.stringify(s,null,2),l={url:this.apiUrl,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Host:this.apiUrl,"X-TC-Action":this.action,"X-TC-Version":this.version,"X-TC-Timestamp":Math.floor(i.valueOf()/1e3).toString(),...this.headerConfigs},body:u,timeout:this.requestTimeout,retry:this.retry};return l.headers.Authorization=await this.getSignV3(i,u),l}async getSignV3(t,n){let r=this.getDate(t),a=Math.floor(t.valueOf()/1e3),{signedHeaders:i,canonicalRequest:o}=await this.getCanonicalRequest(n),{credentialScope:s,stringToSign:u}=await this.getStringToSign(r,a,o),l=await this.getSignature(r,u);return"TC3-HMAC-SHA256 Credential="+this.secret_id+"/"+s+", SignedHeaders="+i+", Signature="+l}async getSignature(t,n){let r=await ar(t,"TC3"+this.secret_key),a=await ar(this.service,r),i=await ar("tc3_request",a),o=await ar(n,i);return jo(o)}async getStringToSign(t,n,r){let a="TC3-HMAC-SHA256",i=await Hn(r),o=t+"/"+this.service+"/tc3_request";return{credentialScope:o,stringToSign:a+`
+`)}canonicalHeaderValues(t){return t.replace(/\s+/g," ").replace(/^\s+|\s+$/g,"")}signedHeaders(){let t=[];return Object.keys(this.request.headers).forEach(n=>{n=n.toLowerCase(),this.isSignableHeader(n)&&t.push(n)}),t.sort().join(";")}signedQueries(){return Object.keys(this.request.params).join(";")}credentialString(t){return this.createScope(t.substr(0,8),this.request.region,this.serviceName)}async hexEncodedHash(t){return await Hn(t)}async hexEncodedBodyHash(){return this.request.headers[jt.contentSha256Header]?this.request.headers[jt.contentSha256Header]:this.request.body?await this.hexEncodedHash(_g(this.request.body)):await this.hexEncodedHash("")}isSignableHeader(t){return SP.indexOf(t)<0}iso8601(t){return t===void 0&&(t=new Date),t.toISOString().replace(/\.\d{3}Z$/,"Z")}async getSigningKey(t,n,r,a){let i=await ar(n,`${jt.kDatePrefix}${t.secretKey}`),o=await ar(r,i),s=await ar(a,o);return ar(jt.v4Identifier,s)}createScope(t,n,r){return[t.substr(0,8),n,r,jt.v4Identifier].join("/")}};var j6=[["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["en","en"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fj","fj"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["he","he"],["hi","hi"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["tn","tn"],["to","to"],["tr","tr"],["ty","ty"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zh-CN","zh"],["zh-TW","zh-Hans"],["zu","zu"]],Og=new Map(j6),TP=new Map(j6.map(([e,t])=>[t,e])),Ng=class extends Ee{static langMap=Og;accessKeyId="";secretAccessKey="";maxTextGroupLength=8;constructor(t,n,r,a){if(super(t,n,r,a),!t||!t.accessKeyId||!t.secretAccessKey)throw new j("accessKeyId and secretAccessKey are required");this.accessKeyId=t.accessKeyId?.trim(),this.secretAccessKey=t.secretAccessKey?.trim()}async remoteDetectLanguage(t){let r={region:"cn-north-1",method:"POST",params:{Action:"LangDetect",Version:"2020-06-01"},pathname:"/",headers:{"Content-Type":"application/json",host:"open.volcengineapi.com"},body:JSON.stringify({TextList:[t]})},a=new Jo(r,"translate");await a.addAuthorization({accessKeyId:this.accessKeyId,secretKey:this.secretAccessKey});let i=new URLSearchParams(r.params),o=await K({retry:2,url:"https://open.volcengineapi.com"+r.pathname+"?"+i.toString(),headers:a.request.headers,method:r.method,body:r.body});if(o.DetectedLanguageList&&o.DetectedLanguageList.length>0)return o.DetectedLanguageList[0].Language;if(o.ResponseMetadata&&o.ResponseMetadata.Error){let s=o.ResponseMetadata.Error;throw new j(s.Code,s.Message)}else if(o.ResponseMetaData&&o.ResponseMetaData.Error){let s=o.ResponseMetaData.Error;throw new j(s.Code,s.Message)}else throw new j("response: "+JSON.stringify(o))}async translateList(t){let{text:n,from:r,to:a}=t,i=Og.get(r),o={TargetLanguage:Og.get(a)||a,TextList:n};i?o.SourceLanguage=i:o.SourceLanguage=await this.remoteDetectLanguage(n.join(`
+`).slice(0,1e3));let s={region:"cn-north-1",method:"POST",params:{Action:"TranslateText",Version:"2020-06-01"},pathname:"/",headers:{"Content-Type":"application/json",host:"open.volcengineapi.com"},body:JSON.stringify(o)},u=new Jo(s,"translate");await u.addAuthorization({accessKeyId:this.accessKeyId,secretKey:this.secretAccessKey});let l=new URLSearchParams(s.params),c=await K({retry:2,url:"https://open.volcengineapi.com"+s.pathname+"?"+l.toString(),headers:u.request.headers,method:s.method,body:s.body});if(c.TranslationList){let d=c.TranslationList.map(p=>p.Translation),m=r;return c.TranslationList.length>0&&c.TranslationList[0].DetectedSourceLanguage&&(m=TP.get(c.TranslationList[0].DetectedSourceLanguage)||r),{text:d,from:m,to:a}}else if(c.ResponseMetadata&&c.ResponseMetadata.Error){let d=c.ResponseMetadata.Error;throw new j(d.Code,d.Message)}else if(c.ResponseMetaData&&c.ResponseMetaData.Error){let d=c.ResponseMetaData.Error;throw new j(d.Code,d.Message)}else throw new j("response: "+JSON.stringify(c))}},U6=Ng;var H6=[["auto","detect"],["af","af"],["am","am"],["ar","ar"],["az","az"],["be","be"],["bg","bg"],["bn","bn"],["bs","bs"],["ca","ca"],["co","co"],["cs","cs"],["cy","cy"],["da","da"],["de","de"],["el","el"],["en","en"],["eo","eo"],["es","es"],["et","et"],["eu","eu"],["fa","fa"],["fi","fi"],["fj","fj"],["fr","fr"],["fy","fy"],["ga","ga"],["gd","gd"],["gl","gl"],["gu","gu"],["ha","ha"],["he","he"],["hi","hi"],["hr","hr"],["ht","ht"],["hu","hu"],["hy","hy"],["id","id"],["ig","ig"],["is","is"],["it","it"],["ja","ja"],["ka","ka"],["kk","kk"],["km","km"],["kn","kn"],["ko","ko"],["ku","ku"],["ky","ky"],["la","la"],["lb","lb"],["lo","lo"],["lt","lt"],["lv","lv"],["mg","mg"],["mi","mi"],["mk","mk"],["ml","ml"],["mn","mn"],["mr","mr"],["ms","ms"],["mt","mt"],["my","my"],["ne","ne"],["nl","nl"],["no","no"],["ny","ny"],["pa","pa"],["pl","pl"],["ps","ps"],["pt","pt"],["ro","ro"],["ru","ru"],["sd","sd"],["si","si"],["sk","sk"],["sl","sl"],["sm","sm"],["sn","sn"],["so","so"],["sq","sq"],["sr","sr"],["st","st"],["su","su"],["sv","sv"],["sw","sw"],["ta","ta"],["te","te"],["tg","tg"],["th","th"],["tn","tn"],["to","to"],["tr","tr"],["ty","ty"],["ug","ug"],["uk","uk"],["ur","ur"],["uz","uz"],["vi","vi"],["xh","xh"],["yi","yi"],["yo","yo"],["zh-CN","zh"],["zh-TW","zh-Hans"],["zu","zu"]],jg=new Map(H6),CP=new Map(H6.map(([e,t])=>[t,e])),Tu=class extends Ee{static langMap=jg;maxTextGroupLength=50;isSupportList=!1;async translate(t){let{text:n,from:r,to:a}=t,i=jg.get(r)||"detect",o=jg.get(a)||a,u=await K({url:"https://translate.volcengine.com/crx/translate/v1/",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({source_language:i,target_language:o,text:n}),retry:this.retry});if(u.base_resp&&u.base_resp.status_code===0){let l=u.translation,c=r;return u.detected_language&&(c=CP.get(u.detected_language)||r),{text:l,from:c,to:a}}else{let l=u.base_resp;throw new j(l.status_code.toString(),l.status_message)}}};var wP=[["auto","auto"],["en","EN"],["ja","JA"],["pl","PL"],["zh-CN","ZH"],["zh-TW","ZH-HANT"],["ja","JA"],["ko","KO"],["es","ES"],["de","DE"],["fr","FR"],["pt","PT"],["ru","RU"],["it","IT"],["id","ID"],["nl","NL"],["pl","PL"],["bg","BG"],["cs","CS"],["da","DA"],["el","EL"],["et","ET"],["fi","FI"],["hu","HU"],["lt","LT"],["lv","LV"],["ro","RO"],["sk","SK"],["sl","SL"],["sv","SV"],["tr","TR"],["uk","UK"]],Ug=new Map(wP),Cu=class extends Ee{static langMap=Ug;url="";isSupportList=!1;maxTextGroupLength=1;apiKeys=[];constructor(t,n,r,a){if(super(t,n,r,a),!t||!t.url)throw new j("deeplx custom url are required, please check your settings.");this.url=t.url,this.apiKeys=this.url.split(",").map(i=>i.trim())}getRandomKey(){let t=Math.floor(Math.random()*this.apiKeys.length);return this.apiKeys[t]}async translate(t){let{text:n,from:r,to:a}=t,i=this.getRandomKey(),o={source_lang:Ug.get(r)||r,target_lang:Ug.get(a)||a,text:n,tag_handling:"html"};this.isRichTranslate||delete o.tag_handling;let u=await K({retry:this.retry,url:i,headers:{"content-type":"application/json"},method:"POST",body:JSON.stringify(o),timeout:this.requestTimeout});if(u.code===200)return{text:Cg(this.serviceConfig,u.data,a),from:r,to:a};throw new j(u.message||u.message||"API Error")}};var q6=[["auto","auto"],["zh-CN","zh"],["en","en"],["yue","yue"],["wyw","wyw"],["ja","jp"],["ko","kor"],["fr","fra"],["es","spa"],["th","th"],["ar","ara"],["ru","ru"],["pt","pt"],["de","de"],["it","it"],["el","el"],["nl","nl"],["pl","pl"],["bg","bul"],["et","est"],["da","dan"],["fi","fin"],["cs","cs"],["ro","rom"],["sl","slo"],["sv","swe"],["hu","hu"],["zh-TW","cht"],["vi","vie"]],Hg=new Map(q6),EP=new Map(q6.map(([e,t])=>[t,e])),qg=class extends Ee{static langMap=Hg;endpoint="https://api.fanyi.baidu.com/api/trans/vip/translate";fieldEndpoint="https://fanyi-api.baidu.com/api/trans/vip/fieldtranslate";appid="";key="";isSupportList=!1;maxTextGroupLength=3;action=!1;domain="";constructor(t,n,r,a){if(super(t,n,r,a),!t||!t.appid||!t.key)throw new j("appid and key are required");this.appid=t.appid?.trim(),this.key=t.key?.trim(),t.action&&(this.action=!0),t.endpoint&&(this.endpoint=t.endpoint),t.fieldEndpoint&&(this.fieldEndpoint=t.fieldEndpoint),t.domain&&(this.domain=t.domain,this.endpoint=this.fieldEndpoint)}getDefaultRateLimit(){return{limit:1,interval:1550}}async translate(t){let n=Date.now().toString(),{endpoint:r}=this,{appid:a,key:i}=this,{text:o,from:s,to:u}=t,l=nr(a+o+n+i);this.domain&&(l=nr(a+o+n+this.domain+i));let c=new URLSearchParams({from:Hg.get(s)||"auto",to:Hg.get(u)||u,q:o,salt:n,appid:a,sign:l});this.action&&c.set("action","1"),this.domain&&c.set("domain",this.domain);let d=new URL(r);d.search=c.toString();let m=await K({url:d.toString(),retry:this.retry,timeout:this.requestTimeout});if(m.error_code)throw new j("API_SERVER_ERROR",m.error_msg);let{trans_result:p,from:g}=m,b=p.map(({dst:f})=>f);return{from:EP.get(g)||g,to:u,text:b.join(`
+`)}}},z6=qg;var Oi=class extends Ee{langMap;requestBaseConfig;apiServiceConfig;constructor(t,n,r,a){super(t,n,r,a),this.apiServiceConfig=this.serviceConfig,this.isSupportList=this.apiServiceConfig.isSupportList,this.langMap=new Map(this.apiServiceConfig.langs),this.requestBaseConfig=this.handleBaseApiServiceConfig(this.apiServiceConfig)}async translate(t){if(!Object.keys(this.apiServiceConfig).length)throw"serivce id not found config";let{text:n,from:r,to:a}=t;if(!this.langMap.has(a))throw new j(`Unsupported language: ${a}`);a=this.langMap.get(a);let i=await this.checkLang(r,n);if(!i)return{text:n,from:r,to:a};r=i;let o=this.handleRequest(n,r,a),s=await Xs(o);return{text:this.handleResponseText(s),from:r,to:a}}async translateList(t){if(!Object.keys(this.apiServiceConfig).length)throw new j("serivce id not found config");let{text:n,from:r,to:a}=t;if(!this.langMap.has(a))throw new j(`Unsupported language: ${a}`);a=this.langMap.get(a);let i=await this.checkLang(r,n.join(" "));if(!i)return{text:n,from:r,to:a};r=i;let o=this.handleRequest(n,r,a),s=await Xs(o);return{text:this.handleResponseText(s),from:r,to:a}}handleBaseApiServiceConfig(t){let n=t.request.url,r=t.request.headers||{};return r["content-type"]||(r["content-type"]="application/json"),{url:n,retry:t.request.retry||this.retry,method:t.request.method||"POST",headers:r,body:JSON.stringify(t.request.body),timeout:this.requestTimeout}}async checkLang(t,n){if(t=="auto"){if(this.langMap.has("auto"))return"auto";t=await this.detectLanguageRemotely(n.slice(0,this.apiServiceConfig.checkLangLenth||10))}return this.langMap.has(t)?this.langMap.get(t):null}handleRequest(t,n,r){let a={...this.requestBaseConfig},i=a?.body||"",o=this.apiServiceConfig.keywords||{};a.body=u(i);let s=a.headers||{};return Object.keys(s).forEach(l=>{s[l]=u(s[l])}),a.headers={...s,...this.headerConfigs},a.url=u(a.url||""),a;function u(l){return l.replaceAll('"{text}"',()=>Array.isArray(t)?JSON.stringify(t):`"${t}"`).replaceAll("{from}",n).replaceAll("{to}",r).replaceAll(/{([a-z:_]+)}/gi,(d,m)=>{let[p,g]=m.split(":"),b=o[p];return g==="random"?AP(b.split(",")):b})}}handleResponseText(t){let n=this.apiServiceConfig.response,r=t,a=n.text.split(".");for(let i of a){if(Array.isArray(r))return r=r.map(o=>o[i]),r;r=r[i]}return r}detectLanguageRemotely(t){return ba.detectLanguageRemotelyByTransmart(t)}};function AP(e){let t=Math.floor(Math.random()*e.length);return e[t]}var W6=[["zh-CN","zh"],["en","en"],["ja","ja"],["ko","ko"],["fr","fr"],["es","es"],["ru","ru"]],zg=class extends Oi{static langMap=new Map(W6);constructor(t,n,r,a){if(!t?.token)throw new j("token are required");super({...t,isSupportList:!0,langs:W6,keywords:{token:t.token?.trim()},request:{headers:{"content-type":"application/json","x-authorization":"token {token:random}"},url:"https://api.interpreter.caiyunai.com/v1/translator",retry:2,body:{source:"{text}",trans_type:"{from}2{to}"}},response:{text:"target"}},n,r,a)}},G6=zg;var kP=[["auto","auto"],["zh-CN","zh"],["en","en"],["ja","ja"]],C0=new Map(kP),Wg=class extends Ee{static langMap=C0;token="ssdj273ksdiwi923bsd9";constructor(t,n,r,a){super(t,n,r,a)}getDefaultRateLimit(){return{limit:5,interval:1050}}async translateList(t){let{text:n,from:r,to:a}=t;if(!C0.get(a))throw new j(`Unsupported language: ${a}`);if(r==="auto")throw new j("Unsupported language: auto");let o=n;return{text:(await K({retry:this.retry,url:"https://api.interpreter.caiyunai.com/v1/translator",headers:{"content-type":"application/json","x-authorization":"token "+this.token},method:"POST",body:JSON.stringify({source:o,trans_type:`${C0.get(r)||"auto"}2${C0.get(a)}`}),timeout:this.requestTimeout})).target,from:r,to:a}}},V6=Wg;var K6=[["auto","auto"],["en","en"],["ru","ru"],["pt","pt"],["es","es"],["zh-CN","zh-CHS"],["ja","ja"],["ko","ko"],["fr","fr"],["ar","ar"],["id","id"],["vi","vi"],["it","it"]],Gg=new Map(K6),DP=new Map(K6.map(([e,t])=>[t,e]));function LP(e){let t=e.length;return t<=20?e:e.substring(0,10)+t+e.substring(t-10,t)}var Vg=class extends Ee{static langMap=Gg;isSupportList=!1;appId="";appSecret="";throttleLimit=5;domain="general";vocabId="";constructor(t,n,r,a){if(super(t,n,r,a),!t||!t.appId||!t.appSecret)throw new j("appId and appSecret are required");this.appId=t.appId?.trim(),this.appSecret=t.appSecret?.trim(),t.domain&&(this.domain=t.domain),t&&t.vocabId&&(this.vocabId=t.vocabId)}getDefaultRateLimit(){return{limit:5,interval:1050}}async translate(t){let{text:n,from:r,to:a}=t,i=PP(32),o=Math.round(new Date().getTime()/1e3),s=this.appId+LP(n)+i+o+this.appSecret,u=await Hn(s),l={q:n,appKey:this.appId,salt:i.toString(),from:Gg.get(r)||"auto",to:Gg.get(a)||a,sign:u,signType:"v3",curtime:o.toString()};this.domain&&this.domain!=="general"&&(l.domain=this.domain),this.vocabId&&(l.vocabId=this.vocabId);let c=new URLSearchParams(l),m=await K({url:"https://openapi.youdao.com/api",method:"POST",body:c.toString(),headers:{"Content-Type":"application/x-www-form-urlencoded"},retry:this.retry,timeout:this.requestTimeout});if(!m.translation)throw new j(JSON.stringify(m));let p=m.l,[g,b]=p.split("2");return{text:m.translation.join(`
+`),from:DP.get(g),to:a}}};function PP(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a[t,e]));var Yg=class extends Ee{static langMap=Kg;isSupportList=!1;appId="";appSecret="";maxTextLength=800;constructor(t,n,r,a){super(t,n,r,a)}getDefaultRateLimit(){return{limit:5,interval:1050}}async translate(t){let{text:n,from:r,to:a}=t,i={q:n,from:Kg.get(r)||"auto",to:Kg.get(a)||a},o=new URLSearchParams(i),s=await K({url:"https://aidemo.youdao.com/trans",method:"POST",body:o.toString(),headers:{"content-type":"application/x-www-form-urlencoded; charset=UTF-8","user-agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"},retry:this.retry,timeout:this.requestTimeout});if(s&&s.translation)return{text:s.translation.join(`
+`),from:r,to:a};throw new j("Youdao translation failed: "+JSON.stringify(s))}},J6=Yg;var wu=class extends Oi{constructor(t,n,r,a){super({...t,isSupportList:!0,langs:(t.langs||"zh-CN,en").split(",").map(i=>[i,i]),limitPerSecond:t.limitPerSecond||5,maxTextLengthPerRequest:t.maxTextLengthPerRequest||1200,maxTextGroupLengthPerRequest:t.maxTextGroupLengthPerRequest||1,placeholderDelimiters:t.placeholderDelimiters||oo,request:{url:t.url,retry:2,body:{text_list:"{text}",source_lang:"{from}",target_lang:"{to}"}},response:{text:"translations.text"}},n,r,a)}};var Qg=class extends $a{provider="custom";immersiveProApiUrl="";temperature=0;userToken="";initPro(t,n){if(t.provider&&(this.provider=t.provider),t.temperature!==void 0&&(this.temperature=parseFloat(t.temperature)),this.provider==="pro"){if(this.userToken=n.userToken||"",!this.userToken)throw new j("Login required, \u767B\u5F55\u540E\u624D\u53EF\u4EE5\u4F7F\u7528\u3002");if(!n.isPro)throw new j("Please activate Pro membership first, \u8BF7\u5148\u5F00\u901A Pro \u4F1A\u5458\u3002");t.proModel&&(t.model=t.proModel,this.model=t.proModel),t.proLimit&&(t.limit=t.proLimit),t&&t.immersiveProApiUrl&&(this.immersiveProApiUrl=xt(this.immersiveProApiUrl,t.immersiveProApiUrl))}}handleProOptions(t,n,r){let a={};r.refresh&&(a["X-Refresh"]="True"),r.debug&&(a["X-Debug"]="True");let i=[{role:"system",content:t},{role:"user",content:n}],o={...this.bodyConfigs,model:this.model,temperature:this.temperature,messages:i};isNaN(o.temperature)&&delete o.temperature;let s={url:this.immersiveProApiUrl,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o,null,2),timeout:this.requestTimeout,retry:this.retry};return s.headers.token=this.userToken,s.headers={...s.headers,...a},s}parseProResponse(t){return t?.choices?.[0]?.message?.content?.trim()}},w0=Qg;var Z6=L+"-gemini-fake-user-key",MP=[["auto","auto"],["zh-CN","Simplified Chinese"],["zh-TW","Traditional Chinese"],["en","English"],["ar","Arabic"],["bn","Bengali"],["bg","Bulgarian"],["hr","Croatian"],["cs","Czech"],["da","Danish"],["nl","Dutch"],["et","Estonian"],["fi","Finnish"],["fr","French"],["de","German"],["el","Greek"],["he","iw"],["hi","Hindi"],["hu","Hungarian"],["id","Indonesian"],["it","Italian"],["ja","Japanese"],["ko","Korean"],["lv","Latvian"],["lt","Lithuanian"],["no","Norway"],["pl","Polish"],["pt","Portuguese"],["ro","Romanian"],["ru","Russian"],["sr","Serbian"],["sk","Slovak"],["sl","Slovene"],["es","Spanish"],["sw","Swahili"],["sv","Swedish"],["th","Thai"],["tr","Turkish"],["uk","Ukrainian"],["vi","Vietnamese"]],X6=new Map(MP),Jg=class extends w0{static langMap=X6;provider="custom";randomPrefix="My user id is {{id}}. ";fakeId="";immersiveProApiUrl=rt+"gemini/translate";constructor(t,n,r,a){super(t,n,r,a),t||(t={}),t.provider&&(this.provider=t.provider),t.randomPrefix&&t.randomPrefix!==void 0&&(this.randomPrefix=t.randomPrefix),this.apiUrl="https://generativelanguage.googleapis.com/v1beta/models/{model}:generateContent?key={key}",t?.apiUrl&&(this.apiUrl=t.apiUrl),this.maxTextGroupLength=this.maxTextGroupLength||10,this.model=this.model||"gemini-1.5-pro-latest",this.initPro(t,r)}getLangMap(){return X6}getDefaultRateLimit(){return{limit:1,interval:1050}}async handleOptions({systemPrompt:t,finalPrompt:n,payload:r}){if(this.provider=="pro")return this.handleProOptions(t,n,r);this.fakeId="",this.randomPrefix&&this.randomPrefix?.trim()&&this.randomPrefix!=="none"&&(this.fakeId=await Ei(Z6,""),this.fakeId||(this.fakeId=RP(10),await Ai(Z6,this.fakeId)));let a=this.getRandomKey(),i={url:this.apiUrl.replace("{model}",this.model),method:"POST",headers:{"content-type":"application/json",...this.headerConfigs},timeout:this.requestTimeout,retry:this.retry};a&&(i.url=i.url.replace("{key}",a));let o=this.systemPrompt+" "+n;this.randomPrefix&&this.randomPrefix?.trim()&&this.randomPrefix!=="none"&&(o=this.randomPrefix.replace("{{id}}",this.fakeId)+o);let s={contents:[{role:"user",parts:[{text:o}]}],...this.bodyConfigs};return i.body=JSON.stringify(s,null,2),i}parseResponse(t){if(this.provider=="pro")return this.parseProResponse(t);let n=t?.candidates?.[0]?.content?.parts?.[0]?.text;if(!n&&t?.promptFeedback)throw new j("parseResponse",JSON.stringify(t));return n||""}filterContent(t,n,r,a){if(this.provider=="pro")return super.filterContent(t,n,r);let i=super.filterContent(t,n,r);return this.fakeId&&i?.includes(this.fakeId)&&a.length<=1?t:i}};function RP(e){let t="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",r=n.length,a=0;for(;a{let n=(await Kr({url:"https://translate.yandex.net/website-widget/v1/widget.js?widgetId=ytWidget&pageLang=es&widgetTheme=light&autoMode=false",method:"GET",responseType:"text"})).match(/sid\:\s\'[0-9a-f\.]+/),r="",a=Date.now()+1*60*1e3;return n&&n[0]&&n[0].length>7&&(r=n[0].substring(6),a=Date.now()+30*60*1e3),{accessToken:r,accessTokenExpiresAt:new Date(a).toISOString()}})}async translateList(t){let{text:n,from:r,to:a}=t;if(!n)return{...t};let i=await this.getAccessToken(),o=new URLSearchParams;o.append("srv","tr-url-widget"),o.append("id",`${i.accessToken}-0-0`),o.append("format","html"),o.append("lang",`${r==="auto"?"":Xg.get(r)+"-"}${Xg.get(a)}`),n.forEach(l=>{o.append("text",l)});let s=await K({url:`https://translate.yandex.net/api/v1/tr.json/translate?${o.toString()}`});if(s?.code!==200)return{...t};let u=s.text?.map(l=>l);return{from:r,to:a,text:u||n}}getDefaultRateLimit(){return{limit:5,interval:1050}}};var BP=[["auto","auto"],["zh-CN","Simplified Chinese"],["zh-TW","Traditional Chinese"],["en","English"],["ja","Japanese"],["ko","Korean"],["fr","French"],["de","German"],["es","Spanish"],["it","Italian"],["ru","Russian"],["pt","Portuguese"],["pt-br","Portuguese (Brazil)"],["nl","Dutch"],["pl","Polish"],["ar","Arabic"],["af","Afrikaans"],["am","Amharic"],["az","Azerbaijani"],["be","Belarusian"],["bg","Bulgarian"],["bn","Bengali"],["bs","Bosnian"],["ca","Catalan"],["ceb","Cebuano"],["co","Corsican"],["cs","Czech"],["cy","Welsh"],["da","Danish"],["el","Greek"],["eo","Esperanto"],["et","Estonian"],["eu","Basque"],["fa","Persian"],["fi","Finnish"],["fil","Filipino"],["ga","Irish"],["gd","Scots Gaelic"],["gl","Galician"],["gu","Gujarati"],["ha","Hausa"],["haw","Hawaiian"],["he","Hebrew"],["hi","Hindi"],["hmn","Hmong"],["hr","Croatian"],["ht","Haitian Creole"],["hu","Hungarian"],["hy","Armenian"],["id","Indonesian"],["ig","Igbo"],["is","Icelandic"],["jw","Javanese"],["ka","Georgian"],["kk","Kazakh"],["km","Khmer"],["kn","Kannada"],["ku","Kurdish (Kurmanji)"],["ky","Kyrgyz"],["lb","Luxembourgish"],["lo","Lao"],["lt","Lithuanian"],["lv","Latvian"],["mg","Malagasy"],["mi","Maori"],["mk","Macedonian"],["ml","Malayalam"],["mn","Mongolian"],["mr","Marathi"],["ms","Malay"],["mt","Maltese"],["my","Myanmar (Burmese)"],["pa","Punjabi"],["ps","Pashto"],["ro","Romanian"],["si","Sinhala (Sinhalese)"],["sk","Slovak"],["sl","Slovenian"],["sa","Sanskrit"],["sm","Samoan"],["sn","Shona"],["so","Somali"],["sq","Albanian"],["sr","Serbian"],["st","Sesotho"],["su","Sundanese"],["sv","Swedish"],["sw","Swahili"],["ta","Tamil"],["te","Telugu"],["tg","Tajik"],["th","Thai"],["tr","Turkish"],["ug","Uyghur"],["uk","Ukrainian"],["ur","Urdu"],["uz","Uzbek"],["vi","Vietnamese"],["xh","Xhosa"],["yi","Yiddish"],["yo","Yoruba"],["zu","Zulu"]],nx=new Map(BP),Au=class extends $a{static langMap=nx;provider="custom";temperature=1;AccessKeyID="";AccessKeySecret="";constructor(t,n,r,a){super(t,n,r,a),t||(t={}),t.provider&&(this.provider=t.provider),t.temperature!==void 0&&(this.temperature=parseFloat(t.temperature)),this.AccessKeyID=t.AccessKeyID?.trim(),this.AccessKeySecret=t.AccessKeySecret?.trim(),this.apiUrl="https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/{model}?access_token={key}",t.apiUrl&&(this.apiUrl=xt(this.apiUrl,t.apiUrl)),this.model=t.model||"ernie_speed",this.maxTextGroupLength=this.maxTextGroupLength||10,this.bodyConfigs=t?.bodyConfigs||{}}async getAccessToken(t,n){return await Yr(Om+t,()=>this.requestAccessToken(t,n))}async requestAccessToken(t,n){let r=await Kr({url:`https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=${t}&client_secret=${n}`,method:"POST",responseType:"json"}),i=Date.now()+r.expires_in*1e3,s=new Date(i).toISOString();return{accessToken:r.access_token,accessTokenExpiresAt:s}}getLangMap(){return nx}getDefaultRateLimit(){return{limit:10,interval:1300}}parseResponse(t){if(t.error_code&&t.error_msg)throw t.error_code===110||t.error_code===111?(x0(Om+this.AccessKeyID,()=>this.requestAccessToken(this.AccessKeyID,this.AccessKeySecret)),new j("token\u8FC7\u671F\uFF0C\u5DF2\u91CD\u65B0\u751F\u6210\uFF0C\u8BF7\u91CD\u8BD5")):new j(t.error_msg);return t?.result?.trim()||""}async handleOptions({systemPrompt:t,finalPrompt:n,payload:r}){let a={};r.refresh&&(a["X-Refresh"]="True"),r.debug&&(a["X-Debug"]="True");let i=[{role:"user",content:t},{role:"assistant",content:"ok"},{role:"user",content:n}],o={temperature:this.temperature,messages:i,...this.bodyConfigs};isNaN(o.temperature)&&delete o.temperature;let s={url:this.apiUrl.replace("{model}",this.model),method:"POST",headers:{"Content-Type":"application/json",...this.headerConfigs},body:JSON.stringify(o,null,2),timeout:this.requestTimeout,retry:this.retry},{accessToken:u}=await this.getAccessToken(this.AccessKeyID,this.AccessKeySecret);return s.headers={...s.headers,...a},u&&(s.url=s.url.replace("{key}",u)),s}};var _P=[["auto","auto"],["zh-CN","Simplified Chinese"],["zh-TW","Traditional Chinese"],["zh-CN-NE","Northeastern Chinese"],["en","English"],["yue","Cantonese"],["bo","\u85CF\u8BED"],["wyw","Classical Chinese"],["ja","Japanese"],["ko","Korean"],["fr","French"],["de","German"],["es","Spanish"],["it","Italian"],["ru","Russian"],["pt","Portuguese"],["pt-br","Portuguese (Brazil)"],["nl","Dutch"],["pl","Polish"],["ar","Arabic"],["af","Afrikaans"],["am","Amharic"],["az","Azerbaijani"],["be","Belarusian"],["bg","Bulgarian"],["bn","Bengali"],["bs","Bosnian"],["ca","Catalan"],["ceb","Cebuano"],["co","Corsican"],["cs","Czech"],["cy","Welsh"],["da","Danish"],["el","Greek"],["eo","Esperanto"],["et","Estonian"],["eu","Basque"],["fa","Persian"],["fi","Finnish"],["fj","Fijian"],["fil","Filipino"],["fy","Western Frisian"],["ga","Irish"],["gd","Scottish Gaelic"],["gl","Galician"],["gu","Gujarati"],["ha","Hausa"],["haw","Hawaiian"],["he","Hebrew"],["hi","Hindi"],["hmn","Hmong"],["hr","Croatian"],["ht","Haitian Creole"],["hu","Hungarian"],["hy","Armenian"],["id","Indonesian"],["ig","Igbo"],["is","Icelandic"],["jw","Javanese"],["ka","Georgian"],["kk","Kazakh"],["km","Khmer"],["kn","Kannada"],["ku","Kurdish"],["ky","Kyrgyz"],["la","Lao"],["lb","Luxembourgish"],["lo","Lao"],["lt","Lithuanian"],["lv","Latvian"],["mg","Malagasy"],["mi","Maori"],["mk","Macedonian"],["ml","Malayalam"],["mn","Mongolian"],["mr","Marathi"],["ms","Malay"],["mt","Maltese"],["my","Burmese"],["pa","Punjabi"],["ps","Pashto"],["ro","Romanian"],["si","Sinhala"],["sk","Slovak"],["sl","Slovene"],["sa","Sanskrit"],["sm","Samoan"],["sn","Shona"],["so","Somali"],["sq","Albanian"],["sr","Serbian"],["sr-Cyrl","Serbian (Cyrillic)"],["sr-Latn","Serbian (Latin)"],["st","Southern Sotho"],["su","Sundanese"],["sv","Swedish"],["sw","Swahili"],["ta","Tamil"],["te","Telugu"],["tg","Tajik"],["th","Thai"],["tr","Turkish"],["ug","Uyghur"],["uk","Ukrainian"],["ur","Urdu"],["ur-roman","Roman Urdu"],["uz","Uzbek"],["vi","Vietnamese"],["xh","Xhosa"],["yi","Yiddish"],["yo","Yoruba"],["zu","Zulu"]],rx=new Map(_P),qn=class extends $a{static langMap=rx;provider="custom";temperature=0;constructor(t,n,r,a){super(t,n,r,a),t||(t={}),t.provider&&(this.provider=t.provider),t.temperature!==void 0&&(this.temperature=parseFloat(t.temperature)),this.apiUrl="https://api.openai.com/v1/chat/completions",t.apiUrl&&(this.apiUrl=xt(this.apiUrl,t.apiUrl)),this.model=t.model||"gpt-3.5-turbo"}getLangMap(){return rx}getDefaultRateLimit(){return{limit:10,interval:1300}}parseResponse(t){return t?.choices?.[0]?.message?.content?.trim()||""}async handleOptions({systemPrompt:t,finalPrompt:n,payload:r}){let a={};r.refresh&&(a["X-Refresh"]="True"),r.debug&&(a["X-Debug"]="True");let i=[];t&&i.push({role:"system",content:t}),n&&i.push({role:"user",content:n});let o={model:this.model,temperature:this.temperature,messages:i,...this.bodyConfigs};isNaN(o.temperature)&&delete o.temperature;let s={url:this.apiUrl,method:"POST",headers:{"Content-Type":"application/json",...this.headerConfigs},body:JSON.stringify(o,null,2),timeout:this.requestTimeout,retry:this.retry},u=this.getRandomKey();return s.headers.Authorization="Bearer "+u,s.headers["api-key"]=u,s}};var E0=class extends qn{action="ChatCompletions";version="2023-09-01";secret_id;secret_key;service="hunyuan";constructor(t,n,r,a){super(t,n,r,a),this.apiUrl="https://hunyuan.tencentcloudapi.com",this.model=t.model||"hunyuan-lite",this.secret_id=t.secret_id,this.secret_key=t.secret_key}parseResponse(t){let n=t.Response;if(n?.Error)throw new j(n?.Error.Message);return n?.Choices?.[0]?.Message?.Content?.trim()||""}async handleOptions({systemPrompt:t,finalPrompt:n,payload:r}){let a={},i=new Date;r.refresh&&(a["X-Refresh"]="True"),r.debug&&(a["X-Debug"]="True");let o=[{Role:"system",Content:t},{Role:"user",Content:n}],s={Model:this.model,Temperature:this.temperature,Messages:o,...this.bodyConfigs};isNaN(s.Temperature)&&delete s.Temperature;let u=JSON.stringify(s,null,2),l={url:this.apiUrl,method:"POST",headers:{"Content-Type":"application/json; charset=utf-8",Host:this.apiUrl,"X-TC-Action":this.action,"X-TC-Version":this.version,"X-TC-Timestamp":Math.floor(i.valueOf()/1e3).toString(),...this.headerConfigs},body:u,timeout:this.requestTimeout,retry:this.retry};return l.headers.Authorization=await this.getSignV3(i,u),l}async getSignV3(t,n){let r=this.getDate(t),a=Math.floor(t.valueOf()/1e3),{signedHeaders:i,canonicalRequest:o}=await this.getCanonicalRequest(n),{credentialScope:s,stringToSign:u}=await this.getStringToSign(r,a,o),l=await this.getSignature(r,u);return"TC3-HMAC-SHA256 Credential="+this.secret_id+"/"+s+", SignedHeaders="+i+", Signature="+l}async getSignature(t,n){let r=await ar(t,"TC3"+this.secret_key),a=await ar(this.service,r),i=await ar("tc3_request",a),o=await ar(n,i);return Uo(o)}async getStringToSign(t,n,r){let a="TC3-HMAC-SHA256",i=await Hn(r),o=t+"/"+this.service+"/tc3_request";return{credentialScope:o,stringToSign:a+`
`+n+`
`+o+`
`+i}}async getCanonicalRequest(t){let n=await Hn(t),r="POST",a="/",i="",o=`content-type:application/json; charset=utf-8
@@ -5928,8 +5927,8 @@ x-tc-action:`+this.action.toLowerCase()+`
`+i+`
`+o+`
`+s+`
-`+n}}getDate(t){let n=t.getUTCFullYear(),r=("0"+(t.getUTCMonth()+1)).slice(-2),a=("0"+t.getUTCDate()).slice(-2);return`${n}-${r}-${a}`}};var A0=class extends qn{service="siliconcloud";userToken;deviceId="";constructor(t,n,r,a){super(t,n,r,a),this.userToken=r.userToken,this.model=t.model||"Qwen/Qwen1.5-7B-Chat"}async init(){if(this.apiKeys.length)return;try{this.deviceId=await Lr()}catch{this.deviceId="fake-device-id"}let{accessToken:t}=await this.getAPIKey();this.apiKeys=[t]}async getAPIKey(){return await Yr(G3,async()=>{let t=await Kr({responseType:"json",url:`${rt}silicon/get-token?deviceId=${this.deviceId}`,headers:{token:this.userToken,"X-trigger":this.getXTrigger()},body:null,method:"GET",timeout:2e4,retry:this.retry}),n=Date.now()+t.expireTime*1e3,r=new Date(n).toISOString();return{accessToken:t.apiToken,accessTokenExpiresAt:r}})}};var Xg=["glm-4-flash"],k0=class extends qn{service="zhipu";userToken;deviceId="";enableFallback=!1;constructor(t,n,r,a){super(t,n,r,a),this.userToken=r.userToken,this.model=t.model||"glm-4",t.enableFallback!==void 0&&(this.enableFallback=!!t.enableFallback)}parseResponse(t){return"error"in t?t.error.message:t.choices[0]?.message.content.trim()||""}async rawRequest(t){try{return await super.rawRequest(t)}catch(n){if(n?.message){let r=JSON.parse(n.message);if(this.isContentFilterError(r))return r}throw n}}async init(){if(!Xg.includes(this.model)&&!this.apiKeys.length)throw new j("apiKey are required");if(!Xg.includes(this.model)||this.apiKeys.length)return;try{this.deviceId=await Lr()}catch{this.deviceId="fake-device-id"}let{accessToken:t}=await this.getAPIKey();this.apiKeys=[t]}async getAPIKey(){return await Yr(V3,async()=>{let t=await Kr({responseType:"json",url:`${rt}big-model/get-token?deviceId=${this.deviceId}`,headers:{token:this.userToken,"X-trigger":this.getXTrigger()},body:null,method:"GET",timeout:2e4,retry:this.retry}),n=Date.now()+t.expireTime*1e3,r=new Date(n).toISOString();return{accessToken:t.apiToken,accessTokenExpiresAt:r}})}async interceptResponse(t,n){let r=await this.checkIgnoreAndRetryByBing(t,n);return r==t?{handled:!1}:{handled:!0,result:r}}async checkIgnoreAndRetryByBing(t,n){try{return!this.enableFallback||!Ir.langMap.has(n.to)||!Ir.langMap.has(n.from)?t:t&&this.ignoreResReges&&this.ignoreResReges.length&&this.ignoreResReges.some(a=>new RegExp(a).test(t))?(await new Ir(this.serviceConfig,this.generalConfig,this.translationOptions,this.isRichTranslate||!1).translateList(n)).text.join(this.translationTextSeparator):t}catch{return t}}isContentFilterError(t){if(this.ignoreResReges.some(r=>new RegExp(r).test(t?.error?.message)))return t}static isApiKeyRequired(t,n,r){return t!=="APIKEY"?r:n==="glm-4-flash"?!1:r}static getDescriptionKey(t,n){return t.name==="APIKEY"&&Xg.includes(n.model)?"description.zhipuFreeAPIKey":t.descriptionKey}};var D0={mock:Ho,mock2:Ho,custom:wu,google:yu,transmart:xu,deepl:zo,volc:U6,volcAlpha:Tu,bing:Ir,tencent:hu,tenAlpha:bu,baidu:z6,caiyun:G6,cai:V6,openl:h0,youdao:Y6,you:J6,d:Uo,dpro:Uo,deeplx:Cu,niu:C6,azure:w6,openai:B6,gemini:$6,claude:tx,papago:E6,aliyun:Su,yandex:Eu,qianfan:Au,"custom-ai":qn,deepseek:qn,"aliyun-bailian":qn,doubao:qn,hunyuan:E0,siliconcloud:A0,lingyiwanwu:qn,zhipu:k0};globalThis.TranslationServicesClass=D0;var ei={};Object.keys(kr).forEach(e=>{ei[e]={...kr[e],class:D0[e]}});function L0(e,t){let n=Xn;if(ei[e]&&ei[e].class&&ei[e].class.langMap&&ei[e].class.langMap.size>0){let r=ei[e].class.langMap,a=n.filter(i=>r.get(i));return a.includes(t)||a.unshift("placeholder"),a}else return Xn}async function Oi(e,t,n){if(!e.text)return e;let r=null,a=await Qt({sentences:[e]},t,(i,o,s)=>{i&&(r=i)},n);if(r)throw r;if(a.sentences.length>0)return{...e,...a.sentences[0]};throw new j("translateFailed","translate failed")}async function ax(e,t){for(let n of e)try{return await Oi({id:1e6,text:"Hello world",from:"en",to:"zh-CN",url:"https://google.com",fromByClient:"auto"},{...t,translationService:n,sourceProgram:"verify"},{retry:1,requestTimeout:t.config.verifyRequestTimeout||5*1e3}),n}catch{continue}return null}async function $g(e){let{config:t,translationService:n}=e,r=t.translationGeneralConfig,a=t.translationServices,i=n,o=a[i]||{},s=ft(e.user);await new ei[i].class(o,r,{translationService:i,userToken:e.user?.token,isPro:s,sourceProgram:e.sourceProgram,glossaries:e.rule.glossaries,excludeRegexps:e.rule.excludeRegexps},e.isRichTranslate||!1).init()}function OP(e){if(!e?.length)return"auto";let t=e[0].from;return e[0].fromByClient&&e[0].fromByClient!=="auto"&&(t=e[0].fromByClient),t}async function Qt(e,t,n,r){if(!e.sentences.length)return{...e};let{config:a,translationService:i,state:o}=t,s=a.translationGeneralConfig,u=a.translationServices,l=i,c=t.targetLanguage;e?.sentences?.[0]?.to&&(c=e.sentences[0].to);let d=u[l]||{},m=a.rawUserConfig?.translationServices?.[l]||{};d.type==="custom-ai"&&(l=d.type),xa(a,t.localConfig,!1),d=await R6(m,d,{sourceLanguage:OP(e.sentences),targetLanguage:c,model:d.model||"",url:t.url,isPro:!!t.isPro+"",sourceProgram:t.sourceProgram||"",translationService:l},t.localConfig.aiAssistants||[],t.specialAiAssistant),r&&(d={...d,...r});let p=a.beta,g=o.cache===!1&&p,b=a.debug===!0&&p;e.sentences&&e.sentences.length>0&&(e.sentences=e.sentences.map(A=>(g&&(A.refresh=!0),b&&(A.debug=!0),A.text&&(A.text=NP(A.text)),A))),l==="openai"&&(e.sentences=e.sentences.map(A=>({...A,from:"auto"})));let h=[],f={sentences:Array(e.sentences.length)},y=e.sentences.length,v=-1,S=ft(t.user),w;try{w=new ei[l].class(d,s,{translationService:l,userToken:t.user?.token,isPro:S,sourceProgram:t.sourceProgram,glossaries:t.rule.glossaries,excludeRegexps:t.rule.excludeRegexps,minTextCount:t.rule.paragraphMinTextCount,enableContextDiffPreview:t.config.enableContextDiffPreview},t.isRichTranslate||!1),await w.init()}catch(A){if(n){h.push(...e.sentences);let D={translationService:l,isPro:!!t.isPro,isLogin:!!t.user?.token};for(let I of h){let F=A instanceof j?new j(A.name,A.message).initNetWork(A.status).initData(A.data||D):A;n(F,null,I)}}return{sentences:[]}}if(o.cache&&!So(a))for(let A of e.sentences){v++;let D=l;l==="openl"&&(D=l+"-"+d.codename||h0.DEFAULT_CODENAME);let I=w.getCacheKeyPrefix();I&&(D=I+"-"+D);let F=null;try{F=await yl(k9({originalText:A.text,from:A.from,to:A.to,service:D}),200)}catch(R){k.warn("query cache DB error, but it's ok",R)}if(F){let R={...A,text:F.translatedText};f.sentences[v]=R,n&&n(null,R,A)}else h.push(A)}else h.push(...e.sentences);let C=h.length;if(y-C>0&&k.debug(`use ${y-C} sentences from cache`),!h.length)return f;let T=await w.multipleTranslate({sentences:h},d,(A,D,I)=>{if(n&&n(A,D,I),!A&&D&&!l.startsWith("mock")&&o.cache){let F=l;l==="openl"&&(F=l+"-"+d.codename||h0.DEFAULT_CODENAME);let R=w.getCacheKeyPrefix();R&&(F=R+"-"+F),o.cache&&yl(D9({translatedText:D.text,from:I.from,to:I.to,detectedFrom:D.from,key:nr(I.text),service:F}),3e3).catch(B=>{k.warn("set cache DB error",B)})}});for(let A of T?.sentences||[]){let D=f.sentences.findIndex(I=>!I);if(D===-1)throw new j("translateFailed","can not match the result");f.sentences[D]=A}return f}function NP(e){if(!e)return e;let t=e.length;for(;t>0&&(e[t-1]===" "||e[t-1]===" ");)t--;return e.substring(0,t)}var jP=1e5;var ix=Date.now();async function Sa(e){let{onParagraph:t,filterRule:n,id:r,engineCtx:a}=e;n=UP(n);let{stayOriginalSelectors:i,globalStyles:o,selectors:s,isTransformPreTagNewLine:u,lineBreakMaxTextCount:l,globalAttributes:c,isModifyImage:d,skipEditableCheck:m}=n,p={commonAncestorContainer:e.container,rootNodes:[],flatNodes:[],_currentStacks:[],isPreWhitespace:!1},g=!1,b=null;async function h(C){let{container:T,onFrame:A,onIgnoreElement:D,id:I,isLongHtml:F}=C,R=document.createTreeWalker(T,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,_=>{let O=P(_);return O==NodeFilter.FILTER_ACCEPT?ht.mark(_,I,m):YP(_,O,n)&&y(),O}),B=T;if(P(B)===NodeFilter.FILTER_REJECT)return;for(ht.mark(B,I,m);B;){if(a?.interruptEffectDOM)return;let _=Date.now()-ix;if(_>50&&(k.debug("taskTime",_,T),ix=Date.now(),await ot(0)),s&&s.length>0){let{currentNode:O,isMatchedSelection:z}=f(R,B,s);if(O)B=O;else break;if(!z)continue}if(B.nodeType===Node.ELEMENT_NODE||B.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let O=B;if(O.nodeName==="IFRAME"){A&&A(O),y(),ef(p,!0),B=R.nextNode();continue}O.nodeType===Node.ELEMENT_NODE&&(o&&tf(O,o),c&&rf(O,c));let z=Ur(O,{blockSelectors:n.blockSelectors,extraInlineSelectors:n.extraInlineSelectors,extraBlockSelectors:n.extraBlockSelectors,atomicBlockSelectors:n.atomicBlockSelectors},O.immersiveTranslateComputedStyle||null);if(z&&n.paragraphFirstLetterFontSize>0&&O.childNodes.length==1&&O.childNodes[0].nodeType===Node.TEXT_NODE&&O.innerText?.length==1&&O?.immersiveTranslateComputedStyle?.fontSize>=n.paragraphFirstLetterFontSize+"px"&&(z=!1),At(O,i)&&!z){v(O);let je=null;for(;!(je=R.nextSibling())&&R.parentNode(););B=je;continue}let V=Pi(O);if(!ox(p,O)||z){y(O);let je=z?O:O.parentElement;je&&je.childNodes.length>0&&S(p,je,je.immersiveTranslateComputedStyle||null)}V&&O.shadowRoot?.mode==="open"&&(z?A?.(O.shadowRoot):h({...C,container:O.shadowRoot})),O.nodeType===Node.ELEMENT_NODE&&At(O,n.likePreSelectors)&&u&&(F||WP(O,n.advanceTransformPreTagNewLine))}else if(B.nodeType===Node.TEXT_NODE)v(B);else throw new Error("should not be here");B=R.nextNode(),p.commonAncestorContainer&&B&&B.parentNode===p.commonAncestorContainer&&(p._currentStacks=[]),p.commonAncestorContainer&&B&&B.nodeType===Node.ELEMENT_NODE&&p._currentStacks.push(B)}function P(_){if(_.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return NodeFilter.FILTER_ACCEPT;if(Mi(_)){if(c){let ie=Object.keys(c);if(ie.length>0&&At(_,ie))for(let Le of ie){let N=c[Le];if(_.matches(Le)){let q=c[Le],Z=Object.keys(q);for(let we of Z){let pe=q[we];_.getAttribute(we)!==pe&&(pe===null?_.removeAttribute(we):_.setAttribute(we,pe))}break}}}if(!C.force&&ht.isMarked(_,I)||xy(_,I)||P0(_,{excludeSelectors:n.excludeSelectors,selectors:n.selectors,excludeSelectorsRegexes:n.excludeSelectorsRegexes,stayOriginalSelectors:i})||_.nodeName==="IFRAME"&&!Oa(_))return NodeFilter.FILTER_REJECT;if(_.nodeType===Node.ELEMENT_NODE){let ie=window.getComputedStyle(_);if(_.immersiveTranslateComputedStyle=ie,nf(ie))return D&&D(_),NodeFilter.FILTER_REJECT;let je=Ur(_,{blockSelectors:n.blockSelectors,extraInlineSelectors:n.extraInlineSelectors,extraBlockSelectors:n.extraBlockSelectors,atomicBlockSelectors:n.atomicBlockSelectors},ie||null);if(_.isBlock=je,At(_,i)&&je)return NodeFilter.FILTER_REJECT}let O=_.getBoundingClientRect(),{width:z,height:V}=O;return _.nodeName==="IMG"&&(z>48&&V>48?_.immersiveTranslateComputedStyle={display:"block"}:z>0&&V>0&&d!==!1&&(_.setAttribute("width",z),_.setAttribute("height",V))),!_.childNodes||_.childNodes&&_.childNodes.length===0?NodeFilter.FILTER_ACCEPT:!p.isPreWhitespace&&(z>0&&z<4||V>0&&V<4)&&(_.textContent?.trim().length||0)<2?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}else if(_.nodeType===Node.TEXT_NODE){let O=_.textContent?.trim();if(!O)return/^( )+$/.test(_.parentElement?.innerHTML?.trim()||"")||p.isPreWhitespace||/^\u00A0+$/.test(_.textContent||"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT;let z=_.parentNode;if(z.getBoundingClientRect){let{width:V,height:ie}=z.getBoundingClientRect();if(V>0&&V<4||ie>0&&ie<4)return NodeFilter.FILTER_REJECT}return l>0&&O.length>=l&&GP(_,l,n.lineBreakRegexStr),NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_REJECT}}try{await h(e)}catch(C){k.error(C)}p&&p.commonAncestorContainer&&p.flatNodes.length>0&&y();function f(C,T,A){let D=T.immersiveTranslateComputedStyle||null;if(b){if(!b.contains(T))if(g=!1,T&&T.nodeType===Node.ELEMENT_NODE)if(ku(T,A))g=!0,b=T,y(),S(p,b,D);else return g=!1,T=C.nextNode(),{currentNode:T,isMatchedSelection:g};else return g=!1,T=C.nextNode(),{currentNode:T,isMatchedSelection:g}}else if(T&&T.nodeType===Node.ELEMENT_NODE)if(ku(T,A))g=!0,b=T,y(),S(p,b,D);else return g=!1,T=C.nextNode(),{currentNode:T,isMatchedSelection:g};else return g=!1,T=C.nextNode(),{currentNode:T,isMatchedSelection:g};return{currentNode:T,isMatchedSelection:!0}}function y(C){let T=p.flatNodes.length-1;if(n.skipTrailTextRegex&&T>0)for(let D=T;D>=0;D--){let F=p.flatNodes[D]?.textContent?.trim()||"";if(!F||new RegExp(n.skipTrailTextRegex).test(F)){p.flatNodes.splice(D,1);continue}break}if(C&&C.nodeName==="BR"){if(C.hasAttribute("data-imt")&&a?.translateState=="translation")return;p.commonAncestorContainer=QP(C,n);let D=[...p.flatNodes],I=p.flatNodes.filter(F=>C.parentNode?.contains(F));I.length>0&&D.length!=I.length&&(p.flatNodes=I,p.flatNodes.original=D)}let A=zP(p,r,n);A&&t&&t(A),ef(p)}function v(C){if(!ox(p,C)){y(),ef(p);let T=C.parentNode;T&&S(p,T,T.computedStyle)}p.flatNodes.push(C)}function S(C,T,A){C.commonAncestorContainer=T;let D=w(A);C.isPreWhitespace=D}function w(C){return C&&C.whiteSpace&&C.whiteSpace.startsWith("pre")||C&&C.whiteSpace==="break-spaces"||!1}}function ox(e,t){let n=!1;(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE)&&(n=Pi(t));let r=qP(e),a=!0;return!n&&!r&&(e.commonAncestorContainer&&e.commonAncestorContainer.contains(t)?a=!0:e.commonAncestorContainer&&(a=!1,e._currentStacks=[])),a}function UP(e){let{isTransformPreTagNewLine:t}=e;return e.excludeSelectors=e.excludeSelectors.filter(n=>{let r=n!=="iframe";return t?r&&n!=="pre":r}),e}function HP(e,t,n){if(t){for(let r of t.childNodes)if(r.contains(n))return r}return e._currentStacks.length>0?(e.commonAncestorContainer||(e.commonAncestorContainer=e._currentStacks[0]),e._currentStacks[0]):null}function tf(e,t){if(t){let n=Object.keys(t);if(n.length>0&&At(e,n))for(let a of n){let i=t[a];if(e.matches(a)){let o=e.style.cssText||"";o&&(o=o.trim()),o&&!o.endsWith(";")&&(o+=";"),e.style.cssText=o+i;break}}}}function qP(e){return e&&e._currentStacks?e._currentStacks.some(t=>Pi(t)):!1}function zP(e,t,n){let{flatNodes:r,commonAncestorContainer:a}=e;if(a&&r.length>0){if(!r.map(p=>p.textContent?.trim()||"").join("")){if(!(r.original||[]).map(g=>g.textContent?.trim()||"").join())return null;e.flatNodes=r.original||[]}let o=Uc(r,a,n);o||(o=a);let s=[];for(let p of r){let g=HP(e,o,p);g&&(s.includes(g)||s.push(g))}if(s.length<1)return null;let u=s[0],l=s[s.length-1],c=[],d=u,m=0;for(;d&&(c.push(d),d!==l);){if(m++,m>jP){k.warn("loop too many times for convert root nodes, break");break}d=d.nextSibling}return{ctxId:t,rootNodes:c,stepState:1,flatNodes:r,commonAncestorContainer:o,variables:{},richVariables:{},isPreWhitespace:e.isPreWhitespace,xpath:"",display:wy(o)}}else return null}function ef(e,t=!1){e.rootNodes=[],e.flatNodes=[],e._currentStacks=[],t&&(e.commonAncestorContainer=null)}function nf(e){return e.display==="none"}var ht={_marked_key:r1,isMarked(e,t){return Lp(e,this._marked_key,t)},clearMark(e){if(!(!e||e.nodeType!==Node.ELEMENT_NODE)&&!(e instanceof HTMLIFrameElement||Pi(e)))return hb(e,this._marked_key)},clearToParentMark(e,t){let n=e;for(;n&&t&&n!=t;)ht.clearMark(n),n=n.parentElement},mark(e,t,n){if(!(!e||e.nodeType!==Node.ELEMENT_NODE)&&!(e instanceof HTMLIFrameElement||Pi(e)))return wt(e,this._marked_key,t,!1,n)},isSkipMarkEle(e){return e?!!(e instanceof HTMLIFrameElement||Pi(e)||e.nodeType==Node.DOCUMENT_FRAGMENT_NODE):!1}};function WP(e,t){let n=e.innerHTML,r=n.replace(/\n\r? *\n\r?/g,"
").replace(/\n\r? *\n\r?/g,"
");if(r!=n){try{if(t){let a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),i=[],o;for(;o=a.nextNode();)i.push(o);i.forEach(s=>{let u=(s.nodeValue||"")?.split(/\n\r? *\n\r?/);if(u?.length<=1&&(u=(s.nodeValue||"")?.split(/\n\r? *\n\r?/)),u.length>1){let l=s;l.nodeValue=u[0],u.slice(1).forEach(c=>{let d=document.createElement("br");d.setAttribute("data-imt","1");let m=document.createTextNode(c);l.parentNode.insertBefore(d,l.nextSibling),l.parentNode.insertBefore(m,d.nextSibling),l=m,l.parentNode.formatHtml=!0})}});return}}catch{}e.innerHTML=Bn?.createHTML(r)||r,e.immersive=!0,e.formatHtml=!0}}function GP(e,t,n){let r=e.textContent||"",a=Ty(r,{wordRegexStr:n,sentenceMaxLength:t});if(!a)return;let i=e.parentNode;e.recordLength=a[0]?.length,e.textContent=a[0];let o=e.nextSibling;e.immersive=!0;for(let s=1;s0)for(let r of n){let a=t[r],i=Object.keys(a),o=sb(e,[r]);for(let s of o)for(let u of i){let l=a[u];s.getAttribute(u)!==l&&(l===null?s.removeAttribute(u):s.setAttribute(u,l))}}}function ux(e,t,n,r,a,i,o){if(!e)return;let s=Object.keys(t);if(s.length>0)for(let u of s){let{selectAll:l,...c}=t[u],d=Object.keys(c);(l?e.querySelectorAll(u):[e.querySelector(u)]).forEach(p=>{if(p)for(let g of d){let b=c[g];if(g==="translate"&&b==="no"){let f=p.innerText||p.textContent||"";if(!f.trim()||KP(p,a,i,o)||!lb(f,n,r))continue}p.getAttribute(g)!==b&&(b===null?p.removeAttribute(g):p.setAttribute(g,b))}})}}function rf(e,t){if(t){let n=Object.keys(t);if(n.length>0&&At(e,n))for(let a of n){let i=t[a];if(e.matches(a)){let o=t[a],s=Object.keys(o);for(let u of s){let l=o[u];e.getAttribute(u)!==l&&(l===null?e.removeAttribute(u):e.setAttribute(u,l))}break}}}}function P0(e,t){return VP(e,t.excludeSelectorsRegexes)?!0:At(e,t.excludeSelectors||[])?At(e,t.selectors||[])?!1:!At(e,t.stayOriginalSelectors||[]):!1}function VP(e,t){try{if(!t)return;let n=t;for(let[r,a]of Object.entries(n)){if(!At(e,[r]))continue;if(Nc(a,e?.textContent?.trim()||""))return!0}return!1}catch(n){return k.error(n),!1}}function ku(e,t){if(t.length===0)return!1;let n=t.filter(r=>!r.endsWith("*")).map(r=>r+" *");return At(e,t.concat(n))}function KP(e,t,n,r){let a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,i=>i.nodeType===Node.ELEMENT_NODE&&P0(i,{excludeSelectors:r.excludeSelectors,selectors:r.selectors,excludeSelectorsRegexes:r.excludeSelectorsRegexes,stayOriginalSelectors:r.stayOriginalSelectors})?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT);for(;a.nextNode();){let i=a.currentNode;if(i.nodeType===Node.TEXT_NODE&&parent){let o=i.textContent||"";if(o.includes("Copyright"))continue;if(yo(o,t,n))return!0}}return!1}function YP(e,t,n){return t==NodeFilter.FILTER_REJECT&&e.nodeType==Node.ELEMENT_NODE&&e.childNodes.length>=1&&e.childNodes[0].childNodes.length>=1&&Ur(e,{blockSelectors:n.blockSelectors,extraInlineSelectors:n.extraInlineSelectors,extraBlockSelectors:n.extraBlockSelectors,atomicBlockSelectors:n.atomicBlockSelectors},null)}function QP(e,t){let n=e.parentElement;for(let r=0;r<5;r++){if(!n)return e?.parentElement;if(n.isBlock==!0||n.isBlock==null&&Ur(n,{blockSelectors:t.blockSelectors,extraInlineSelectors:t.extraInlineSelectors,extraBlockSelectors:t.extraBlockSelectors,atomicBlockSelectors:t.atomicBlockSelectors},null))return n;n=n?.parentElement}return e?.parentElement}function lx(e,t,n,r,a){let i=t,o=g1[i]||[],s="";e&&o&&o.length>0&&o.forEach(c=>{let{name:d}=c;if(e&&n&&n[d]){let m=n[d];if(["borderRadius"].includes(d)&&(m+="px"),s+=`--${L}-theme-${i}-${d}: ${m};
-`,t==="marker"&&d==="backgroundColor"&&typeof m=="string"){let{r:p,g,b}=yb(m);s+=`--${L}-theme-${i}-${d}-rgb: ${p}, ${g}, ${b};
+`+n}}getDate(t){let n=t.getUTCFullYear(),r=("0"+(t.getUTCMonth()+1)).slice(-2),a=("0"+t.getUTCDate()).slice(-2);return`${n}-${r}-${a}`}};var A0=class extends qn{service="siliconcloud";userToken;deviceId="";constructor(t,n,r,a){super(t,n,r,a),this.userToken=r.userToken,this.model=t.model||"Qwen/Qwen1.5-7B-Chat"}async init(){if(this.apiKeys.length)return;try{this.deviceId=await Lr()}catch{this.deviceId="fake-device-id"}let{accessToken:t}=await this.getAPIKey();this.apiKeys=[t]}async getAPIKey(){return await Yr(V3,async()=>{let t=await Kr({responseType:"json",url:`${rt}silicon/get-token?deviceId=${this.deviceId}`,headers:{token:this.userToken,"X-trigger":this.getXTrigger()},body:null,method:"GET",timeout:2e4,retry:this.retry}),n=Date.now()+t.expireTime*1e3,r=new Date(n).toISOString();return{accessToken:t.apiToken,accessTokenExpiresAt:r}})}};var $g=["glm-4-flash"],k0=class extends qn{service="zhipu";userToken;deviceId="";enableFallback=!1;constructor(t,n,r,a){super(t,n,r,a),this.userToken=r.userToken,this.model=t.model||"glm-4",t.enableFallback!==void 0&&(this.enableFallback=!!t.enableFallback)}parseResponse(t){return"error"in t?t.error.message:t.choices[0]?.message.content.trim()||""}async rawRequest(t){try{return await super.rawRequest(t)}catch(n){if(n?.message){let r=JSON.parse(n.message);if(this.isContentFilterError(r))return r}throw n}}async init(){if(!$g.includes(this.model)&&!this.apiKeys.length)throw new j("apiKey are required");if(!$g.includes(this.model)||this.apiKeys.length)return;try{this.deviceId=await Lr()}catch{this.deviceId="fake-device-id"}let{accessToken:t}=await this.getAPIKey();this.apiKeys=[t]}async getAPIKey(){return await Yr(K3,async()=>{let t=await Kr({responseType:"json",url:`${rt}big-model/get-token?deviceId=${this.deviceId}`,headers:{token:this.userToken,"X-trigger":this.getXTrigger()},body:null,method:"GET",timeout:2e4,retry:this.retry}),n=Date.now()+t.expireTime*1e3,r=new Date(n).toISOString();return{accessToken:t.apiToken,accessTokenExpiresAt:r}})}async interceptResponse(t,n){let r=await this.checkIgnoreAndRetryByBing(t,n);return r==t?{handled:!1}:{handled:!0,result:r}}async checkIgnoreAndRetryByBing(t,n){try{return!this.enableFallback||!Ir.langMap.has(n.to)||!Ir.langMap.has(n.from)?t:t&&this.ignoreResReges&&this.ignoreResReges.length&&this.ignoreResReges.some(a=>new RegExp(a).test(t))?(await new Ir(this.serviceConfig,this.generalConfig,this.translationOptions,this.isRichTranslate||!1).translateList(n)).text.join(this.translationTextSeparator):t}catch{return t}}isContentFilterError(t){if(this.ignoreResReges.some(r=>new RegExp(r).test(t?.error?.message)))return t}static isApiKeyRequired(t,n,r){return t!=="APIKEY"?r:n==="glm-4-flash"?!1:r}static getDescriptionKey(t,n){return t.name==="APIKEY"&&$g.includes(n.model)?"description.zhipuFreeAPIKey":t.descriptionKey}};var D0={mock:qo,mock2:qo,custom:wu,google:yu,transmart:xu,deepl:Wo,volc:U6,volcAlpha:Tu,bing:Ir,tencent:hu,tenAlpha:bu,baidu:z6,caiyun:G6,cai:V6,openl:h0,youdao:Y6,you:J6,d:Ho,dpro:Ho,deeplx:Cu,niu:C6,azure:w6,openai:B6,gemini:$6,claude:tx,papago:E6,aliyun:Su,yandex:Eu,qianfan:Au,"custom-ai":qn,deepseek:qn,"aliyun-bailian":qn,doubao:qn,hunyuan:E0,siliconcloud:A0,lingyiwanwu:qn,zhipu:k0};globalThis.TranslationServicesClass=D0;var ti={};Object.keys(kr).forEach(e=>{ti[e]={...kr[e],class:D0[e]}});function L0(e,t){let n=Xn;if(ti[e]&&ti[e].class&&ti[e].class.langMap&&ti[e].class.langMap.size>0){let r=ti[e].class.langMap,a=n.filter(i=>r.get(i));return a.includes(t)||a.unshift("placeholder"),a}else return Xn}async function Ni(e,t,n){if(!e.text)return e;let r=null,a=await Qt({sentences:[e]},t,(i,o,s)=>{i&&(r=i)},n);if(r)throw r;if(a.sentences.length>0)return{...e,...a.sentences[0]};throw new j("translateFailed","translate failed")}async function ax(e,t){for(let n of e)try{return await Ni({id:1e6,text:"Hello world",from:"en",to:"zh-CN",url:"https://google.com",fromByClient:"auto"},{...t,translationService:n,sourceProgram:"verify"},{retry:1,requestTimeout:t.config.verifyRequestTimeout||5*1e3}),n}catch{continue}return null}async function ef(e){let{config:t,translationService:n}=e,r=t.translationGeneralConfig,a=t.translationServices,i=n,o=a[i]||{},s=ft(e.user);await new ti[i].class(o,r,{translationService:i,userToken:e.user?.token,isPro:s,sourceProgram:e.sourceProgram,glossaries:e.rule.glossaries,excludeRegexps:e.rule.excludeRegexps},e.isRichTranslate||!1).init()}function OP(e){if(!e?.length)return"auto";let t=e[0].from;return e[0].fromByClient&&e[0].fromByClient!=="auto"&&(t=e[0].fromByClient),t}async function Qt(e,t,n,r){if(!e.sentences.length)return{...e};let{config:a,translationService:i,state:o}=t,s=a.translationGeneralConfig,u=a.translationServices,l=i,c=t.targetLanguage;e?.sentences?.[0]?.to&&(c=e.sentences[0].to);let d=u[l]||{},m=a.rawUserConfig?.translationServices?.[l]||{};d.type==="custom-ai"&&(l=d.type),va(a,t.localConfig,!1),d=await R6(m,d,{sourceLanguage:OP(e.sentences),targetLanguage:c,model:d.model||"",url:t.url,isPro:!!t.isPro+"",sourceProgram:t.sourceProgram||"",translationService:l},t.localConfig.aiAssistants||[],t.specialAiAssistant),r&&(d={...d,...r});let p=a.beta,g=o.cache===!1&&p,b=a.debug===!0&&p;e.sentences&&e.sentences.length>0&&(e.sentences=e.sentences.map(A=>(g&&(A.refresh=!0),b&&(A.debug=!0),A.text&&(A.text=NP(A.text)),A))),l==="openai"&&(e.sentences=e.sentences.map(A=>({...A,from:"auto"})));let h=[],f={sentences:Array(e.sentences.length)},y=e.sentences.length,v=-1,S=ft(t.user),w;try{w=new ti[l].class(d,s,{translationService:l,userToken:t.user?.token,isPro:S,sourceProgram:t.sourceProgram,glossaries:t.rule.glossaries,excludeRegexps:t.rule.excludeRegexps,minTextCount:t.rule.paragraphMinTextCount,enableContextDiffPreview:t.config.enableContextDiffPreview},t.isRichTranslate||!1),await w.init()}catch(A){if(n){h.push(...e.sentences);let D={translationService:l,isPro:!!t.isPro,isLogin:!!t.user?.token};for(let I of h){let F=A instanceof j?new j(A.name,A.message).initNetWork(A.status).initData(A.data||D):A;n(F,null,I)}}return{sentences:[]}}if(o.cache&&!To(a))for(let A of e.sentences){v++;let D=l;l==="openl"&&(D=l+"-"+d.codename||h0.DEFAULT_CODENAME);let I=w.getCacheKeyPrefix();I&&(D=I+"-"+D);let F=null;try{F=await yl(k9({originalText:A.text,from:A.from,to:A.to,service:D}),200)}catch(R){k.warn("query cache DB error, but it's ok",R)}if(F){let R={...A,text:F.translatedText};f.sentences[v]=R,n&&n(null,R,A)}else h.push(A)}else h.push(...e.sentences);let C=h.length;if(y-C>0&&k.debug(`use ${y-C} sentences from cache`),!h.length)return f;let T=await w.multipleTranslate({sentences:h},d,(A,D,I)=>{if(n&&n(A,D,I),!A&&D&&!l.startsWith("mock")&&o.cache){let F=l;l==="openl"&&(F=l+"-"+d.codename||h0.DEFAULT_CODENAME);let R=w.getCacheKeyPrefix();R&&(F=R+"-"+F),o.cache&&yl(D9({translatedText:D.text,from:I.from,to:I.to,detectedFrom:D.from,key:nr(I.text),service:F}),3e3).catch(B=>{k.warn("set cache DB error",B)})}});for(let A of T?.sentences||[]){let D=f.sentences.findIndex(I=>!I);if(D===-1)throw new j("translateFailed","can not match the result");f.sentences[D]=A}return f}function NP(e){if(!e)return e;let t=e.length;for(;t>0&&(e[t-1]===" "||e[t-1]===" ");)t--;return e.substring(0,t)}var jP=1e5;var ix=Date.now();async function Ta(e){let{onParagraph:t,filterRule:n,id:r,engineCtx:a}=e;n=UP(n);let{stayOriginalSelectors:i,globalStyles:o,selectors:s,isTransformPreTagNewLine:u,lineBreakMaxTextCount:l,globalAttributes:c,isModifyImage:d,skipEditableCheck:m}=n,p={commonAncestorContainer:e.container,rootNodes:[],flatNodes:[],_currentStacks:[],isPreWhitespace:!1},g=!1,b=null;async function h(C){let{container:T,onFrame:A,onIgnoreElement:D,id:I,isLongHtml:F}=C,R=document.createTreeWalker(T,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,_=>{let O=P(_);return O==NodeFilter.FILTER_ACCEPT?ht.mark(_,I,m):YP(_,O,n)&&y(),O}),B=T;if(P(B)===NodeFilter.FILTER_REJECT)return;for(ht.mark(B,I,m);B;){if(a?.interruptEffectDOM)return;let _=Date.now()-ix;if(_>50&&(k.debug("taskTime",_,T),ix=Date.now(),await ot(0)),s&&s.length>0){let{currentNode:O,isMatchedSelection:z}=f(R,B,s);if(O)B=O;else break;if(!z)continue}if(B.nodeType===Node.ELEMENT_NODE||B.nodeType===Node.DOCUMENT_FRAGMENT_NODE){let O=B;if(O.nodeName==="IFRAME"){A&&A(O),y(),tf(p,!0),B=R.nextNode();continue}O.nodeType===Node.ELEMENT_NODE&&(o&&nf(O,o),c&&af(O,c));let z=Ur(O,{blockSelectors:n.blockSelectors,extraInlineSelectors:n.extraInlineSelectors,extraBlockSelectors:n.extraBlockSelectors,atomicBlockSelectors:n.atomicBlockSelectors},O.immersiveTranslateComputedStyle||null);if(z&&n.paragraphFirstLetterFontSize>0&&O.childNodes.length==1&&O.childNodes[0].nodeType===Node.TEXT_NODE&&O.innerText?.length==1&&O?.immersiveTranslateComputedStyle?.fontSize>=n.paragraphFirstLetterFontSize+"px"&&(z=!1),At(O,i)&&!z){v(O);let je=null;for(;!(je=R.nextSibling())&&R.parentNode(););B=je;continue}let V=Mi(O);if(!ox(p,O)||z){y(O);let je=z?O:O.parentElement;je&&je.childNodes.length>0&&S(p,je,je.immersiveTranslateComputedStyle||null)}V&&O.shadowRoot?.mode==="open"&&(z?A?.(O.shadowRoot):h({...C,container:O.shadowRoot})),O.nodeType===Node.ELEMENT_NODE&&At(O,n.likePreSelectors)&&u&&(F||WP(O,n.advanceTransformPreTagNewLine))}else if(B.nodeType===Node.TEXT_NODE)v(B);else throw new Error("should not be here");B=R.nextNode(),p.commonAncestorContainer&&B&&B.parentNode===p.commonAncestorContainer&&(p._currentStacks=[]),p.commonAncestorContainer&&B&&B.nodeType===Node.ELEMENT_NODE&&p._currentStacks.push(B)}function P(_){if(_.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return NodeFilter.FILTER_ACCEPT;if(Ri(_)){if(c){let ie=Object.keys(c);if(ie.length>0&&At(_,ie))for(let Le of ie){let N=c[Le];if(_.matches(Le)){let q=c[Le],Z=Object.keys(q);for(let we of Z){let pe=q[we];_.getAttribute(we)!==pe&&(pe===null?_.removeAttribute(we):_.setAttribute(we,pe))}break}}}if(!C.force&&ht.isMarked(_,I)||vy(_,I)||P0(_,{excludeSelectors:n.excludeSelectors,selectors:n.selectors,excludeSelectorsRegexes:n.excludeSelectorsRegexes,stayOriginalSelectors:i})||_.nodeName==="IFRAME"&&!Na(_))return NodeFilter.FILTER_REJECT;if(_.nodeType===Node.ELEMENT_NODE){let ie=window.getComputedStyle(_);if(_.immersiveTranslateComputedStyle=ie,rf(ie))return D&&D(_),NodeFilter.FILTER_REJECT;let je=Ur(_,{blockSelectors:n.blockSelectors,extraInlineSelectors:n.extraInlineSelectors,extraBlockSelectors:n.extraBlockSelectors,atomicBlockSelectors:n.atomicBlockSelectors},ie||null);if(_.isBlock=je,At(_,i)&&je)return NodeFilter.FILTER_REJECT}let O=_.getBoundingClientRect(),{width:z,height:V}=O;return _.nodeName==="IMG"&&(z>48&&V>48?_.immersiveTranslateComputedStyle={display:"block"}:z>0&&V>0&&d!==!1&&(_.setAttribute("width",z),_.setAttribute("height",V))),!_.childNodes||_.childNodes&&_.childNodes.length===0?NodeFilter.FILTER_ACCEPT:!p.isPreWhitespace&&(z>0&&z<4||V>0&&V<4)&&(_.textContent?.trim().length||0)<2?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}else if(_.nodeType===Node.TEXT_NODE){let O=_.textContent?.trim();if(!O)return/^( )+$/.test(_.parentElement?.innerHTML?.trim()||"")||p.isPreWhitespace||/^\u00A0+$/.test(_.textContent||"")?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT;let z=_.parentNode;if(z.getBoundingClientRect){let{width:V,height:ie}=z.getBoundingClientRect();if(V>0&&V<4||ie>0&&ie<4)return NodeFilter.FILTER_REJECT}return l>0&&O.length>=l&&GP(_,l,n.lineBreakRegexStr),NodeFilter.FILTER_ACCEPT}return NodeFilter.FILTER_REJECT}}try{await h(e)}catch(C){k.error(C)}p&&p.commonAncestorContainer&&p.flatNodes.length>0&&y();function f(C,T,A){let D=T.immersiveTranslateComputedStyle||null;if(b){if(!b.contains(T))if(g=!1,T&&T.nodeType===Node.ELEMENT_NODE)if(ku(T,A))g=!0,b=T,y(),S(p,b,D);else return g=!1,T=C.nextNode(),{currentNode:T,isMatchedSelection:g};else return g=!1,T=C.nextNode(),{currentNode:T,isMatchedSelection:g}}else if(T&&T.nodeType===Node.ELEMENT_NODE)if(ku(T,A))g=!0,b=T,y(),S(p,b,D);else return g=!1,T=C.nextNode(),{currentNode:T,isMatchedSelection:g};else return g=!1,T=C.nextNode(),{currentNode:T,isMatchedSelection:g};return{currentNode:T,isMatchedSelection:!0}}function y(C){let T=p.flatNodes.length-1;if(n.skipTrailTextRegex&&T>0)for(let D=T;D>=0;D--){let F=p.flatNodes[D]?.textContent?.trim()||"";if(!F||new RegExp(n.skipTrailTextRegex).test(F)){p.flatNodes.splice(D,1);continue}break}if(C&&C.nodeName==="BR"){if(C.hasAttribute("data-imt")&&a?.translateState=="translation")return;p.commonAncestorContainer=QP(C,n);let D=[...p.flatNodes],I=p.flatNodes.filter(F=>C.parentNode?.contains(F));I.length>0&&D.length!=I.length&&(p.flatNodes=I,p.flatNodes.original=D)}let A=zP(p,r,n);A&&t&&t(A),tf(p)}function v(C){if(!ox(p,C)){y(),tf(p);let T=C.parentNode;T&&S(p,T,T.computedStyle)}p.flatNodes.push(C)}function S(C,T,A){C.commonAncestorContainer=T;let D=w(A);C.isPreWhitespace=D}function w(C){return C&&C.whiteSpace&&C.whiteSpace.startsWith("pre")||C&&C.whiteSpace==="break-spaces"||!1}}function ox(e,t){let n=!1;(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.DOCUMENT_FRAGMENT_NODE)&&(n=Mi(t));let r=qP(e),a=!0;return!n&&!r&&(e.commonAncestorContainer&&e.commonAncestorContainer.contains(t)?a=!0:e.commonAncestorContainer&&(a=!1,e._currentStacks=[])),a}function UP(e){let{isTransformPreTagNewLine:t}=e;return e.excludeSelectors=e.excludeSelectors.filter(n=>{let r=n!=="iframe";return t?r&&n!=="pre":r}),e}function HP(e,t,n){if(t){for(let r of t.childNodes)if(r.contains(n))return r}return e._currentStacks.length>0?(e.commonAncestorContainer||(e.commonAncestorContainer=e._currentStacks[0]),e._currentStacks[0]):null}function nf(e,t){if(t){let n=Object.keys(t);if(n.length>0&&At(e,n))for(let a of n){let i=t[a];if(e.matches(a)){let o=e.style.cssText||"";o&&(o=o.trim()),o&&!o.endsWith(";")&&(o+=";"),e.style.cssText=o+i;break}}}}function qP(e){return e&&e._currentStacks?e._currentStacks.some(t=>Mi(t)):!1}function zP(e,t,n){let{flatNodes:r,commonAncestorContainer:a}=e;if(a&&r.length>0){if(!r.map(p=>p.textContent?.trim()||"").join("")){if(!(r.original||[]).map(g=>g.textContent?.trim()||"").join())return null;e.flatNodes=r.original||[]}let o=Uc(r,a,n);o||(o=a);let s=[];for(let p of r){let g=HP(e,o,p);g&&(s.includes(g)||s.push(g))}if(s.length<1)return null;let u=s[0],l=s[s.length-1],c=[],d=u,m=0;for(;d&&(c.push(d),d!==l);){if(m++,m>jP){k.warn("loop too many times for convert root nodes, break");break}d=d.nextSibling}return{ctxId:t,rootNodes:c,stepState:1,flatNodes:r,commonAncestorContainer:o,variables:{},richVariables:{},isPreWhitespace:e.isPreWhitespace,xpath:"",display:Ey(o)}}else return null}function tf(e,t=!1){e.rootNodes=[],e.flatNodes=[],e._currentStacks=[],t&&(e.commonAncestorContainer=null)}function rf(e){return e.display==="none"}var ht={_marked_key:a1,isMarked(e,t){return Lp(e,this._marked_key,t)},clearMark(e){if(!(!e||e.nodeType!==Node.ELEMENT_NODE)&&!(e instanceof HTMLIFrameElement||Mi(e)))return bb(e,this._marked_key)},clearToParentMark(e,t){let n=e;for(;n&&t&&n!=t;)ht.clearMark(n),n=n.parentElement},mark(e,t,n){if(!(!e||e.nodeType!==Node.ELEMENT_NODE)&&!(e instanceof HTMLIFrameElement||Mi(e)))return wt(e,this._marked_key,t,!1,n)},isSkipMarkEle(e){return e?!!(e instanceof HTMLIFrameElement||Mi(e)||e.nodeType==Node.DOCUMENT_FRAGMENT_NODE):!1}};function WP(e,t){let n=e.innerHTML,r=n.replace(/\n\r? *\n\r?/g,"
").replace(/\n\r? *\n\r?/g,"
");if(r!=n){try{if(t){let a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),i=[],o;for(;o=a.nextNode();)i.push(o);i.forEach(s=>{let u=(s.nodeValue||"")?.split(/\n\r? *\n\r?/);if(u?.length<=1&&(u=(s.nodeValue||"")?.split(/\n\r? *\n\r?/)),u.length>1){let l=s;l.nodeValue=u[0],u.slice(1).forEach(c=>{let d=document.createElement("br");d.setAttribute("data-imt","1");let m=document.createTextNode(c);l.parentNode.insertBefore(d,l.nextSibling),l.parentNode.insertBefore(m,d.nextSibling),l=m,l.parentNode.formatHtml=!0})}});return}}catch{}e.innerHTML=Bn?.createHTML(r)||r,e.immersive=!0,e.formatHtml=!0}}function GP(e,t,n){let r=e.textContent||"",a=Cy(r,{wordRegexStr:n,sentenceMaxLength:t});if(!a)return;let i=e.parentNode;e.recordLength=a[0]?.length,e.textContent=a[0];let o=e.nextSibling;e.immersive=!0;for(let s=1;s0)for(let r of n){let a=t[r],i=Object.keys(a),o=ub(e,[r]);for(let s of o)for(let u of i){let l=a[u];s.getAttribute(u)!==l&&(l===null?s.removeAttribute(u):s.setAttribute(u,l))}}}function ux(e,t,n,r,a,i,o){if(!e)return;let s=Object.keys(t);if(s.length>0)for(let u of s){let{selectAll:l,...c}=t[u],d=Object.keys(c);(l?e.querySelectorAll(u):[e.querySelector(u)]).forEach(p=>{if(p)for(let g of d){let b=c[g];if(g==="translate"&&b==="no"){let f=p.innerText||p.textContent||"";if(!f.trim()||KP(p,a,i,o)||!cb(f,n,r))continue}p.getAttribute(g)!==b&&(b===null?p.removeAttribute(g):p.setAttribute(g,b))}})}}function af(e,t){if(t){let n=Object.keys(t);if(n.length>0&&At(e,n))for(let a of n){let i=t[a];if(e.matches(a)){let o=t[a],s=Object.keys(o);for(let u of s){let l=o[u];e.getAttribute(u)!==l&&(l===null?e.removeAttribute(u):e.setAttribute(u,l))}break}}}}function P0(e,t){return VP(e,t.excludeSelectorsRegexes)?!0:At(e,t.excludeSelectors||[])?At(e,t.selectors||[])?!1:!At(e,t.stayOriginalSelectors||[]):!1}function VP(e,t){try{if(!t)return;let n=t;for(let[r,a]of Object.entries(n)){if(!At(e,[r]))continue;if(Nc(a,e?.textContent?.trim()||""))return!0}return!1}catch(n){return k.error(n),!1}}function ku(e,t){if(t.length===0)return!1;let n=t.filter(r=>!r.endsWith("*")).map(r=>r+" *");return At(e,t.concat(n))}function KP(e,t,n,r){let a=document.createTreeWalker(e,NodeFilter.SHOW_TEXT|NodeFilter.SHOW_ELEMENT,i=>i.nodeType===Node.ELEMENT_NODE&&P0(i,{excludeSelectors:r.excludeSelectors,selectors:r.selectors,excludeSelectorsRegexes:r.excludeSelectorsRegexes,stayOriginalSelectors:r.stayOriginalSelectors})?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT);for(;a.nextNode();){let i=a.currentNode;if(i.nodeType===Node.TEXT_NODE&&parent){let o=i.textContent||"";if(o.includes("Copyright"))continue;if(xo(o,t,n))return!0}}return!1}function YP(e,t,n){return t==NodeFilter.FILTER_REJECT&&e.nodeType==Node.ELEMENT_NODE&&e.childNodes.length>=1&&e.childNodes[0].childNodes.length>=1&&Ur(e,{blockSelectors:n.blockSelectors,extraInlineSelectors:n.extraInlineSelectors,extraBlockSelectors:n.extraBlockSelectors,atomicBlockSelectors:n.atomicBlockSelectors},null)}function QP(e,t){let n=e.parentElement;for(let r=0;r<5;r++){if(!n)return e?.parentElement;if(n.isBlock==!0||n.isBlock==null&&Ur(n,{blockSelectors:t.blockSelectors,extraInlineSelectors:t.extraInlineSelectors,extraBlockSelectors:t.extraBlockSelectors,atomicBlockSelectors:t.atomicBlockSelectors},null))return n;n=n?.parentElement}return e?.parentElement}function lx(e,t,n,r,a){let i=t,o=f1[i]||[],s="";e&&o&&o.length>0&&o.forEach(c=>{let{name:d}=c;if(e&&n&&n[d]){let m=n[d];if(["borderRadius"].includes(d)&&(m+="px"),s+=`--${L}-theme-${i}-${d}: ${m};
+`,t==="marker"&&d==="backgroundColor"&&typeof m=="string"){let{r:p,g,b}=xb(m);s+=`--${L}-theme-${i}-${d}-rgb: ${p}, ${g}, ${b};
`}}}),r||(r="inherit"),e&&(s+=`
.${L}-target-inner { font-family: ${r}; }
`);let u="";if(n&&n.textColor){let c=n.textColor;u+=`
@@ -5942,17 +5941,17 @@ x-tc-action:`+this.action.toLowerCase()+`
[imt-state="dual"] .${L}-target-translation-theme-${i}-inner{font-style: italic;}
`);let l="";s&&(l=`:root {
${s}}
-`),u&&(l+=u),l?fn(e,l,L+"-user-custom-style"):a&&fn(e,"",L+"-user-custom-style")}function Jo(e,t){let r=ke().IMMERSIVE_TRANSLATE_INJECTED_CSS;fn(e,r,L+"-default-injected-css");let a=t.config.translationThemePatterns||{},i=t.state.translationTheme,o=a[i]||{};lx(e,i,o,t.config.selectTranslationFont);let s="";(t.rule.injectedCss||t.rule.additionalInjectedCss)&&(t.rule.injectedCss&&Array.isArray(t.rule.injectedCss)&&t.rule.injectedCss.length>0?s+=t.rule.injectedCss.join(`
+`),u&&(l+=u),l?fn(e,l,L+"-user-custom-style"):a&&fn(e,"",L+"-user-custom-style")}function Zo(e,t){let r=ke().IMMERSIVE_TRANSLATE_INJECTED_CSS;fn(e,r,L+"-default-injected-css");let a=t.config.translationThemePatterns||{},i=t.state.translationTheme,o=a[i]||{};lx(e,i,o,t.config.selectTranslationFont);let s="";(t.rule.injectedCss||t.rule.additionalInjectedCss)&&(t.rule.injectedCss&&Array.isArray(t.rule.injectedCss)&&t.rule.injectedCss.length>0?s+=t.rule.injectedCss.join(`
`):t.rule.injectedCss&&(s+=t.rule.injectedCss),t.rule.additionalInjectedCss&&Array.isArray(t.rule.additionalInjectedCss)&&t.rule.additionalInjectedCss.length>0?s+=`
`+t.rule.additionalInjectedCss.join(`
`):t.rule.additionalInjectedCss&&(s+=`
-`+t.rule.additionalInjectedCss)),s&&fn(e,s,L+"-dynamic-injected-css")}async function cx(){let e="auto",t=[Ct(),"en"];return document.body&&document.body.textContent&&document.body.textContent.trim()&&(e=await Ne({text:xo(document.body),pageLangs:t})),e}function af(e,t,n=[],r){let a=["notranslate"];return r&&a.push(p1),e&&(a.push(`${L}-target-translation-theme-${e}`),t?a.push(`${Vm}-theme-${e}`):a.push(`${Gm}-theme-${e}`)),n.length>0&&a.push(...n),t?a.push(Vm):a.push(Gm),a}function of(e){let t=["notranslate",Gl];return e&&t.push(`${L}-target-translation-theme-${e}-inner`),t}function dx(e,t,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=e;o=o||[];let{text:u}=t,{wrapperPrefix:l,wrapperSuffix:c}=r,d=Li(n.config.translationServices,n.translationService,!0),m="afterend",p=d[0],g=d[1],b=`${p}(\\d+)${g}`,h=new RegExp(b,"g"),f=u;o.length>0&&(f=f.replace(h,S=>{let w=f.indexOf(S),C=f[w-1]===" ",T=f[w+S.length]===" ",D=S.replace(new RegExp(d[0],"g"),"").replace(new RegExp(d[1],"g"),""),I=Number(D);if(isNaN(I))return S;let F=o[I];if(F&&F.type==="element"){let R=Ze.sanitize(F.value.outerHTML,{ADD_TAGS:n.rule.domPurifyAddTags});return C||(R=" "+R),T||(R=R+" "),R}else k.error("variable type not supported",F,S);return S}));let y=af(i,e.inline,r.translationClasses||[],e.preWhitespace);s&&y.push(m1);let v=of(i);return sf({targetWrapperTag:n.rule.targetWrapperTag,innerClassList:v,classList:y,html:f,targetElementEffectAttributeName:ao,inline:e.inline,wrapperPrefix:l,wrapperSuffix:c,position:m,translationBlockStyle:r.translationBlockStyle,translationPosition:n.config.translationPosition||""})}function M0(e,t,n,r,a){let i=t.original||t,o=iy(a,e,i,n.ignoreRichSelectors||[],n.domPurifyAddTags),s=null,{stayOriginalSelectors:u,delimiters:l,isPreWhitespace:c}=n,d=[],m={};for(let g=0;g0){let g="";for(let f=0;f0&&i[f].textContent.length0&&(S=d[f-1].text),fg.type==="text").map(g=>g.text).join(" "),n.richMoreWordPercent&&d.length>4&&d.length/(s.pureText||"").split(/\s+/).length>n.richMoreWordPercent&&(s.html=void 0)),s}function mx(e,t){let n=`${e[0]}${t}${e[1]}`;return e[2]&&(n=`<${e[2]}${t}>${e[2]}${t}>`),n}function px(e,t){let{rule:n}=t;if(!e.targetText)return"";let r=So(t.config),a=r?.configEnable||t.config.enableRenderHtmlTag;a?e.targetText=su(e.targetText):e.targetText=Ze.sanitize(su(e.targetText),{ADD_TAGS:t.rule.domPurifyAddTags});let i=[];if(e.variables){let p=Object.keys(e.variables);for(let g=0;g/g,">"))}!r?.configEnable&&r?.queryEnable&&(e.targetText=wc(e.contextTargetText,e.targetText));let o=t.config.translationServices[t.translationService];t.isRichTranslate&&(e.targetText=ly(e.richVariables,e.targetText,o.richTag,o.richIdName));let s=!1,u=e.text,l=u.split(" ").length,c=u.split(`
-`).length;l<=n.blockMinWordCount&&u.length<=n.blockMinTextCount&&c<2&&(s=!0),e.display?.includes("flex")&&(s=!0);let d={id:Number(e.id),elements:[],isVertical:!1,rootFrame:e.commonAncestorContainer,text:e.text,variables:i,inline:s,preWhitespace:e.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},m=Li(t.config.translationServices,t.translationService);if(m.length>2){let p=m[2];return JP({delimiterTag:p,targetText:e.targetText,inline:s,preWhitespace:e.isPreWhitespace||!1,wrapperPrefix:t.rule.wrapperPrefix,wrapperSuffix:t.rule.wrapperSuffix,targetWrapperTag:t.rule.targetWrapperTag,translationTheme:t.state.translationTheme,translationBlockStyle:t.rule.translationBlockStyle,translationClasses:t.rule.translationClasses,variables:i,ctx:t}).html}else{let p=dx(d,{id:Number(e.id),url:"https://google.com",text:e.targetText,from:"auto",to:"auto",fromByClient:"auto"},t);return p.html}}function uf(e){return(e?.innerText||e.textContent||"").replace(/\s+/g," ")||""}function JP(e){let{delimiterTag:t,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:i,variables:o,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c,ctx:d}=e;o=o||[];let p=e.targetText,g=new RegExp(`<${t}(\\d+)>(.*?)${t}\\d+>`,"g"),b=new RegExp(`<${t}(\\d+)>`);o.length>0&&(p=p.replace(g,y=>{let v=p.indexOf(y),S=p[v-1]===" ",w=p[v+y.length]===" ",C=y.match(b);if(!C)return y;let T=C[1],A=Number(T);if(isNaN(A))return y;let D=o[Number(A)];if(D&&D.type==="element"){let I=Ze.sanitize(D.value.outerHTML,{ADD_TAGS:d.rule.domPurifyAddTags});return S||(I=" "+I),w||(I=I+" "),I}else if(D&&D.type==="text"){let I=D.value;return S||(I=" "+I),w||(I=I+" "),I}else k.error("variable type not supported",D,y);return y}));let h=af(l,n,r||[],s),f=of(l);return sf({targetWrapperTag:a,innerClassList:f,classList:h,html:p,targetElementEffectAttributeName:ao,inline:n,wrapperPrefix:i,wrapperSuffix:u,position:"afterend",translationBlockStyle:c,translationPosition:d.config.translationPosition||""})}function sf({targetWrapperTag:e,innerClassList:t,classList:n,html:r,targetElementEffectAttributeName:a,inline:i,wrapperPrefix:o,wrapperSuffix:s,position:u,translationBlockStyle:l,translationPosition:c}){let d="";l&&(d=`style="${l}"`),r=`<${e} class="${t.join(" ")}" ${a}="1">${r}${e}>`,c!="before"&&(r=p(r));let m=[r];return i?o!=="smart"?m=[o,r]:m=[`<${e} class="notranslate" ${a}="1"> ${e}>`,r]:o==="smart"?m=["
",r]:m=[o,r],r=c=="before"?m.reverse().join(""):m.join(""),c=="before"&&(r=p(r)),c!="before"&&(s==="smart"?r=`${r}`:r=`${r}${s}`),{html:r,position:u};function p(g){return`<${e} ${d} class="${n.join(" ")}" ${a}="1">${g}${e}>`}}function lf(e){let t=e[e.length-1];return t?t.text:""}function gx(e,t){let n=null,r=null,a=e.rule.bodyRule;if(!a.enable)return{bodyIsRoot:!1,bodyNode:n,articleNode:r};if(a.bodySelector&&(n=document.querySelector(a.bodySelector)),a.articleSelector&&(r=document.querySelector(a.articleSelector)),n||r)return k.debug("body rule has confirm"),{bodyIsRoot:i(),bodyNode:n,articleNode:r||n};if(document.body.scrollHeight!=0&&document.body.scrollHeight>=window.innerHeight*a.maxBodyScreenLength)return k.debug("content dom elements too long"),{bodyIsRoot:!1,bodyNode:n,articleNode:r};try{let o=window.document.cloneNode(!0),u=new Pl(o,{keepClasses:!0}).parse();if(!u)throw new Error("article is null");n=XP(u.content,t),n&&eM(a,n)&&(r=n)}catch(o){k.debug(o)}return{bodyIsRoot:i(),bodyNode:n,articleNode:r,preElements:Ey(a.preSelectors)};function i(){return e.state.translationArea==="body"?!1:!!a.bodyIsRoot}}function fx(e,t){if(!e.rule.bodyRule.articleSelector||t.nodeType!==Node.ELEMENT_NODE)return;let n=t.querySelector(e.rule.bodyRule.articleSelector);n&&(e.articleNode!=n&&k.debug("update article node",n),e.articleNode=n)}function ZP(e,t){try{let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),r;for(;r=n.nextNode();)if((r.textContent?.trim().length||0)>t){let a=r.parentNode.innerText.trim().split(`
-`),i="";return a.forEach(o=>{i.length *");if(a.length<=0)return null;let i=[];if(a.forEach(o=>{let s=ZP(o,20),u=$P(o),l=null;for(let c of u){let d=document.body.querySelectorAll(c);if(d.length&&(d.forEach(m=>{let p=m.textContent?.trim().length||0,g=l?.textContent?.trim().length||0;p>g&&(s?m.innerText?.includes(s)&&(l=m):l=m)}),l)){i.push(l);break}}}),!!i.length)return Uc(i,document.body,t)}function $P(e){let t=[],n=e.id,r=[];e.classList.forEach(i=>{i.includes(".")||i.includes(":")||i.includes("/")||i.includes("[")||r.push("."+i.trim())}),n?(t.push(`#${n}${r.join("")}`),t.push(`#${n}${r.filter(i=>i!=".container").join("")}`),t.push(`#${n}`)):(t.push(`${r.join("")}`),t.push(`${r.filter(i=>i!=".container").join("")}`));let a=[...new Set(t)].filter(i=>!!i);return a.length?a:[e.tagName]}function eM(e,t){let n=!1;for(let[a,{minNum:i,maxNum:o}]of Object.entries(e.matchNodeRule)){let s=t.querySelectorAll(a).length;if(o){n=s>=i&&s<=o;break}else if(s>=i){n=!0;break}}let r=t.innerText.length;return n&&r>=e.minTextLength}function hx(e){let t=document.querySelector("title"),n;return t&&(n=new MutationObserver(function(r){r.length>0&&(r[0].target.text.includes(Wl)||cf(e).catch(i=>{k.error("translateTitle error:",i.name,i.message,i.details||"")}))}),n.observe(t,{subtree:!0,characterData:!0,childList:!0})),n}var Du="";async function cf(e){let t=document.title;if(!t||t.includes(Wl))return;Du!==t&&(Du=t);let n=await Ne({text:t,pageLangs:[pt(),"en"]});if(!ko(e,n))try{let r=await Oi({id:0,url:e.url,text:t,from:n,to:e.targetLanguage,fromByClient:n,force:!0},e);r&&r.text&&(document.originTitle=Du,document.title=r.text+Wl+Du)}catch(r){throw r}}function bx(e){e.rule.isTranslateTitle&&(document.title=Du)}function Zo(e){return(e.config.rtlLanguages||["ar","arc","az","dv","he","ckb","fa","ur"]).includes(e.targetLanguage)}function R0(e){try{let t=document.head?.cloneNode(!0),r=document.body.cloneNode(!0),a=e.rule.shareConfig;[...a?.removeSelectors||[]].forEach(l=>{[...t?.querySelectorAll(l),...r?.querySelectorAll(l)].forEach(c=>{c.nodeName.toLowerCase()=="script"&&c.type=="application/ld+json"||c.remove()})});let o=a.injectCss?Gp():"",s="";globalThis.document.documentElement.getAttributeNames().forEach(l=>{s+=`${l}="${globalThis.document.documentElement.getAttribute(l)}" `});let u="";return globalThis.document.body.getAttributeNames().forEach(l=>{u+=`${l}="${globalThis.document.body.getAttribute(l)}" `}),`
+`+t.rule.additionalInjectedCss)),s&&fn(e,s,L+"-dynamic-injected-css")}async function cx(){let e="auto",t=[Ct(),"en"];return document.body&&document.body.textContent&&document.body.textContent.trim()&&(e=await Ne({text:vo(document.body),pageLangs:t})),e}function of(e,t,n=[],r){let a=["notranslate"];return r&&a.push(g1),e&&(a.push(`${L}-target-translation-theme-${e}`),t?a.push(`${Vm}-theme-${e}`):a.push(`${Gm}-theme-${e}`)),n.length>0&&a.push(...n),t?a.push(Vm):a.push(Gm),a}function sf(e){let t=["notranslate",Gl];return e&&t.push(`${L}-target-translation-theme-${e}-inner`),t}function dx(e,t,n){let{rule:r,state:a}=n,{translationTheme:i}=a,{variables:o,isVertical:s}=e;o=o||[];let{text:u}=t,{wrapperPrefix:l,wrapperSuffix:c}=r,d=Pi(n.config.translationServices,n.translationService,!0),m="afterend",p=d[0],g=d[1],b=`${p}(\\d+)${g}`,h=new RegExp(b,"g"),f=u;o.length>0&&(f=f.replace(h,S=>{let w=f.indexOf(S),C=f[w-1]===" ",T=f[w+S.length]===" ",D=S.replace(new RegExp(d[0],"g"),"").replace(new RegExp(d[1],"g"),""),I=Number(D);if(isNaN(I))return S;let F=o[I];if(F&&F.type==="element"){let R=Ze.sanitize(F.value.outerHTML,{ADD_TAGS:n.rule.domPurifyAddTags});return C||(R=" "+R),T||(R=R+" "),R}else k.error("variable type not supported",F,S);return S}));let y=of(i,e.inline,r.translationClasses||[],e.preWhitespace);s&&y.push(p1);let v=sf(i);return uf({targetWrapperTag:n.rule.targetWrapperTag,innerClassList:v,classList:y,html:f,targetElementEffectAttributeName:io,inline:e.inline,wrapperPrefix:l,wrapperSuffix:c,position:m,translationBlockStyle:r.translationBlockStyle,translationPosition:n.config.translationPosition||""})}function M0(e,t,n,r,a){let i=t.original||t,o=oy(a,e,i,n.ignoreRichSelectors||[],n.domPurifyAddTags),s=null,{stayOriginalSelectors:u,delimiters:l,isPreWhitespace:c}=n,d=[],m={};for(let g=0;g0){let g="";for(let f=0;f0&&i[f].textContent.length0&&(S=d[f-1].text),fg.type==="text").map(g=>g.text).join(" "),n.richMoreWordPercent&&d.length>4&&d.length/(s.pureText||"").split(/\s+/).length>n.richMoreWordPercent&&(s.html=void 0)),s}function mx(e,t){let n=`${e[0]}${t}${e[1]}`;return e[2]&&(n=`<${e[2]}${t}>${e[2]}${t}>`),n}function px(e,t){let{rule:n}=t;if(!e.targetText)return"";let r=To(t.config),a=r?.configEnable||t.config.enableRenderHtmlTag;a?e.targetText=su(e.targetText):e.targetText=Ze.sanitize(su(e.targetText),{ADD_TAGS:t.rule.domPurifyAddTags});let i=[];if(e.variables){let p=Object.keys(e.variables);for(let g=0;g/g,">"))}!r?.configEnable&&r?.queryEnable&&(e.targetText=wc(e.contextTargetText,e.targetText));let o=t.config.translationServices[t.translationService];t.isRichTranslate&&(e.targetText=cy(e.richVariables,e.targetText,o.richTag,o.richIdName));let s=!1,u=e.text,l=u.split(" ").length,c=u.split(`
+`).length;l<=n.blockMinWordCount&&u.length<=n.blockMinTextCount&&c<2&&(s=!0),e.display?.includes("flex")&&(s=!0);let d={id:Number(e.id),elements:[],isVertical:!1,rootFrame:e.commonAncestorContainer,text:e.text,variables:i,inline:s,preWhitespace:e.isPreWhitespace||!1,languageByLocal:"auto",languageByClient:"auto"},m=Pi(t.config.translationServices,t.translationService);if(m.length>2){let p=m[2];return JP({delimiterTag:p,targetText:e.targetText,inline:s,preWhitespace:e.isPreWhitespace||!1,wrapperPrefix:t.rule.wrapperPrefix,wrapperSuffix:t.rule.wrapperSuffix,targetWrapperTag:t.rule.targetWrapperTag,translationTheme:t.state.translationTheme,translationBlockStyle:t.rule.translationBlockStyle,translationClasses:t.rule.translationClasses,variables:i,ctx:t}).html}else{let p=dx(d,{id:Number(e.id),url:"https://google.com",text:e.targetText,from:"auto",to:"auto",fromByClient:"auto"},t);return p.html}}function lf(e){return(e?.innerText||e.textContent||"").replace(/\s+/g," ")||""}function JP(e){let{delimiterTag:t,inline:n,translationClasses:r,targetWrapperTag:a,wrapperPrefix:i,variables:o,preWhitespace:s,wrapperSuffix:u,translationTheme:l,translationBlockStyle:c,ctx:d}=e;o=o||[];let p=e.targetText,g=new RegExp(`<${t}(\\d+)>(.*?)${t}\\d+>`,"g"),b=new RegExp(`<${t}(\\d+)>`);o.length>0&&(p=p.replace(g,y=>{let v=p.indexOf(y),S=p[v-1]===" ",w=p[v+y.length]===" ",C=y.match(b);if(!C)return y;let T=C[1],A=Number(T);if(isNaN(A))return y;let D=o[Number(A)];if(D&&D.type==="element"){let I=Ze.sanitize(D.value.outerHTML,{ADD_TAGS:d.rule.domPurifyAddTags});return S||(I=" "+I),w||(I=I+" "),I}else if(D&&D.type==="text"){let I=D.value;return S||(I=" "+I),w||(I=I+" "),I}else k.error("variable type not supported",D,y);return y}));let h=of(l,n,r||[],s),f=sf(l);return uf({targetWrapperTag:a,innerClassList:f,classList:h,html:p,targetElementEffectAttributeName:io,inline:n,wrapperPrefix:i,wrapperSuffix:u,position:"afterend",translationBlockStyle:c,translationPosition:d.config.translationPosition||""})}function uf({targetWrapperTag:e,innerClassList:t,classList:n,html:r,targetElementEffectAttributeName:a,inline:i,wrapperPrefix:o,wrapperSuffix:s,position:u,translationBlockStyle:l,translationPosition:c}){let d="";l&&(d=`style="${l}"`),r=`<${e} class="${t.join(" ")}" ${a}="1">${r}${e}>`,c!="before"&&(r=p(r));let m=[r];return i?o!=="smart"?m=[o,r]:m=[`<${e} class="notranslate" ${a}="1"> ${e}>`,r]:o==="smart"?m=["
",r]:m=[o,r],r=c=="before"?m.reverse().join(""):m.join(""),c=="before"&&(r=p(r)),c!="before"&&(s==="smart"?r=`${r}`:r=`${r}${s}`),{html:r,position:u};function p(g){return`<${e} ${d} class="${n.join(" ")}" ${a}="1">${g}${e}>`}}function cf(e){let t=e[e.length-1];return t?t.text:""}function gx(e,t){let n=null,r=null,a=e.rule.bodyRule;if(!a.enable)return{bodyIsRoot:!1,bodyNode:n,articleNode:r};if(a.bodySelector&&(n=document.querySelector(a.bodySelector)),a.articleSelector&&(r=document.querySelector(a.articleSelector)),n||r)return k.debug("body rule has confirm"),{bodyIsRoot:i(),bodyNode:n,articleNode:r||n,preElements:Vp(a.preSelectors)};if(document.body.scrollHeight!=0&&document.body.scrollHeight>=window.innerHeight*a.maxBodyScreenLength)return k.debug("content dom elements too long"),{bodyIsRoot:!1,bodyNode:n,articleNode:r};try{let o=window.document.cloneNode(!0),u=new Pl(o,{keepClasses:!0}).parse();if(!u)throw new Error("article is null");n=XP(u.content,t),n&&eM(a,n)&&(r=n)}catch(o){k.debug(o)}return{bodyIsRoot:i(),bodyNode:n,articleNode:r,preElements:Vp(a.preSelectors)};function i(){return e.state.translationArea==="body"?!1:!!a.bodyIsRoot}}function fx(e,t){if(!e.rule.bodyRule.articleSelector||t.nodeType!==Node.ELEMENT_NODE)return;let n=t.querySelector(e.rule.bodyRule.articleSelector);n&&(e.articleNode!=n&&k.debug("update article node",n),e.articleNode=n)}function ZP(e,t){try{let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,null),r;for(;r=n.nextNode();)if((r.textContent?.trim().length||0)>t){let a=r.parentNode.innerText.trim().split(`
+`),i="";return a.forEach(o=>{i.length *");if(a.length<=0)return null;let i=[];if(a.forEach(o=>{let s=ZP(o,20),u=$P(o),l=null;for(let c of u){let d=document.body.querySelectorAll(c);if(d.length&&(d.forEach(m=>{let p=m.textContent?.trim().length||0,g=l?.textContent?.trim().length||0;p>g&&(s?m.innerText?.includes(s)&&(l=m):l=m)}),l)){i.push(l);break}}}),!!i.length)return Uc(i,document.body,t)}function $P(e){let t=[],n=e.id,r=[];e.classList.forEach(i=>{i.includes(".")||i.includes(":")||i.includes("/")||i.includes("[")||r.push("."+i.trim())}),n?(t.push(`#${n}${r.join("")}`),t.push(`#${n}${r.filter(i=>i!=".container").join("")}`),t.push(`#${n}`)):(t.push(`${r.join("")}`),t.push(`${r.filter(i=>i!=".container").join("")}`));let a=[...new Set(t)].filter(i=>!!i);return a.length?a:[e.tagName]}function eM(e,t){let n=!1;for(let[a,{minNum:i,maxNum:o}]of Object.entries(e.matchNodeRule)){let s=t.querySelectorAll(a).length;if(o&&s>=i&&s<=o){n=!0;break}else if(s>=i){n=!0;break}}let r=t.innerText.length;return n&&r>=e.minTextLength}function hx(e){let t=document.querySelector("title"),n;return t&&(n=new MutationObserver(function(r){r.length>0&&(r[0].target.text.includes(Wl)||df(e).catch(i=>{k.error("translateTitle error:",i.name,i.message,i.details||"")}))}),n.observe(t,{subtree:!0,characterData:!0,childList:!0})),n}var Du="";async function df(e){let t=document.title;if(!t||t.includes(Wl))return;Du!==t&&(Du=t);let n=await Ne({text:t,pageLangs:[pt(),"en"]});if(!Do(e,n))try{let r=await Ni({id:0,url:e.url,text:t,from:n,to:e.targetLanguage,fromByClient:n,force:!0},e);r&&r.text&&(document.originTitle=Du,document.title=r.text+Wl+Du)}catch(r){throw r}}function bx(e){e.rule.isTranslateTitle&&(document.title=Du)}function $r(e,t){return(e||["ar","arc","az","dv","he","ckb","fa","ur"]).includes(t)}function R0(e){try{let t=document.head?.cloneNode(!0),r=document.body.cloneNode(!0),a=e.rule.shareConfig;[...a?.removeSelectors||[]].forEach(l=>{[...t?.querySelectorAll(l),...r?.querySelectorAll(l)].forEach(c=>{c.nodeName.toLowerCase()=="script"&&c.type=="application/ld+json"||c.remove()})});let o=a.injectCss?Gp():"",s="";globalThis.document.documentElement.getAttributeNames().forEach(l=>{s+=`${l}="${globalThis.document.documentElement.getAttribute(l)}" `});let u="";return globalThis.document.body.getAttributeNames().forEach(l=>{u+=`${l}="${globalThis.document.body.getAttribute(l)}" `}),`
${t.innerHTML}
${r.innerHTML}`}catch{return""}}function yx(e){try{let t=document.head?.cloneNode(!0),r=document.body.cloneNode(!0),a=e.rule.shareConfig;[...a?.removeSelectors||[]].forEach(l=>{[...t?.querySelectorAll(l),...r?.querySelectorAll(l)].forEach(c=>{c.nodeName.toLowerCase()=="script"&&c.type=="application/ld+json"||c.remove()})});let o=a.injectCss?Gp():"",s="";globalThis.document.documentElement.getAttributeNames().forEach(l=>{s+=`${l}="${globalThis.document.documentElement.getAttribute(l)}" `});let u="";return globalThis.document.body.getAttributeNames().forEach(l=>{u+=`${l}="${globalThis.document.body.getAttribute(l)}" `}),`
${t.innerHTML}
- ${r.innerHTML}`.replaceAll(`data-${L}-translation-element-mark="1"`,"dim_m='1'").replace(/data-immersive-translate-walked=\".+?\"/g,"dim_w='1'").replace(/data-on-parse-paragraph=\".+?\"/g,"").replace(/data-consume-paragraph=\".+?\"/g,"").replace(/data-consume-container=\".+?\"/g,"").replace(/immersive-translate-target-([a-z\-]+)/g,(l,c)=>"imt_"+c.replaceAll("translation","t"))}catch{return""}}function I0(e){let t=py(e);return t.stayOriginalTags.map(r=>r.toLowerCase()).concat(t.stayOriginalSelectors).concat(t.additionalStayOriginalSelectors)}function on(e,t){if(!t&&e.filterRule)return e.filterRule;let n=e.rule;e.isRichTranslate&&(n=Up(n));let r=[...n.selectors],a=[...n.excludeTags],i=[...n.excludeSelectors],o={...n.excludeSelectorsRegexes};return e.state.translationArea==="body"?(r=[],i=[],o={}):(n.preTranslateLimiter?.keys||[]).forEach(u=>{n.preTranslateLimiter[`${u}.enableTranslate`]||i.push(...n.preTranslateLimiter[`${u}.selectors`]||[])}),{paragraphFirstLetterFontSize:n.paragraphFirstLetterFontSize,globalStyles:n.globalStyles,globalAttributes:n.globalAttributes,selectors:r,atomicBlockSelectors:n.atomicBlockSelectors,skipEditableCheck:n.skipEditableCheck,lineBreakMaxTextCount:n.lineBreakMaxTextCount,lineBreakRegexStr:n.lineBreakRegexStr,isTransformPreTagNewLine:n.isTransformPreTagNewLine,likePreSelectors:n.likePreSelectors,skipBuildContainerSelectors:n.skipBuildContainerSelectors,buildContainerSelectors:n.buildContainerSelectors,excludeSelectors:a.map(u=>u.toLowerCase()).filter(u=>u!=="code"&&u!=="img").concat(i).concat(n.additionalExcludeSelectors),excludeSelectorsRegexes:o,blockSelectors:n.allBlockTags.map(u=>u.toLowerCase()).concat(n.extraBlockSelectors),extraBlockSelectors:n.extraBlockSelectors,extraInlineSelectors:n.extraInlineSelectors.concat(n.additionalInlineSelectors),stayOriginalSelectors:n.stayOriginalTags.map(u=>u.toLowerCase()).concat(n.stayOriginalSelectors).concat(n.additionalStayOriginalSelectors),skipTrailTextRegex:n.skipTrailTextRegex,advanceTransformPreTagNewLine:n.advanceTransformPreTagNewLine}}var tM={sanitize:e=>e};async function gf(e,t){if(e.interruptEffectDOM)return;fa("consumeContainer");let n=on(e.ctx);await e.walkContainer({id:e.id,container:t,articleNode:e.ctx.articleNode,filterRule:n,bodyRule:e.ctx.rule.bodyRule,onParagraph:ji.bind(null,e),onFrame:r=>{df(e,r,!0)},onIgnoreElement:r=>{ht.mark(r,e.id,n.skipEditableCheck),e.ignoreResizeObserver?.observe(r)},engineCtx:e}),Xi&&wt(t,"consumeContainer",e.id)}function df(e,t,n){try{if(t instanceof HTMLIFrameElement){if(!Oa(t))return;k.debug("onFrame fragment",t);let r=t?.contentWindow?.document.body;if(r){if(t?.contentWindow?.document.querySelector(`[data-id="${Hl}"]`))return;e.injectCssToDocument(t,e.ctx);let a=e.inlineIFrames||[];a.push(t),e.inlineIFrames=a,qr(t.contentWindow?.document.documentElement,e.translateState),ni(r,e,n),e.dynamicContainerObserver?.observe(r,{childList:!0,subtree:!0,characterData:!0})}}else{if(k.debug("onFrame shadowRoot",t.host),!t.host)return;e.injectCssToDocument(t,e.ctx),ni(t,e,n),e.dynamicContainerObserver?.observe(t,{childList:!0,subtree:!0,characterData:!0})}}catch{}}async function ni(e,t,n=!0){fa("buildContainer");let r=Date.now(),{globalStyles:a,globalAttributes:i}=on(t.ctx),o=0;if(l(t,e,n))return;if(Mi(e)&&u(e)){ht.mark(e,t.id,t.ctx.rule.skipEditableCheck),await s(e);return}try{let c=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,d=>t.interruptEffectDOM?(k.debug("\u4E2D\u65AD"),NodeFilter.FILTER_REJECT):(Mi(d)&&(a&&tf(d,a),i&&rf(d,i)),l(t,d,n)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT));for(ht.mark(c.currentNode,t.id,t.ctx.rule.skipEditableCheck);c.nextNode()&&!t.interruptEffectDOM;){ht.mark(c.currentNode,t.id,t.ctx.rule.skipEditableCheck);let d=c.currentNode;if(u(d))for(await s(d);!t.interruptEffectDOM;){if(c.nextSibling()){let m=c.currentNode;if(ht.mark(c.currentNode,t.id,t.ctx.rule.skipEditableCheck),u(m)){await s(m);continue}else break}if(!c.parentNode())return}}}catch{}if(o==0&&e instanceof HTMLElement){await s(e);return}return t.observeContainers;async function s(c){if(!t.interruptEffectDOM)if(o++,ht.clearMark(c),t.immediateTranslateCapacity>=0){await gf(t,c);let d=Date.now()-r;d>100&&(k.debug("batchTaskTime",d,c),r=Date.now(),await ot(0))}else Xi&&wt(c,"observeContainer",t.id),t.containerVisibleObserver?.unobserve(c),t.containerVisibleObserver?.observe(c)}function u(c){let d=c.nodeName.toLowerCase();if(c.shadowRoot)return df(t,c.shadowRoot,n),!1;if(d==="iframe")return df(t,c,n),!1;if(["script","#document-fragment","img"].includes(d))return!1;let m=t.containerRule;if(m.selectors&&m.selectors?.length>0)return ku(c,m.selectors);if(t.ctx.rule.enableSkipBuildContainer||m.containerSelectors&&ku(c,m.containerSelectors))return!0;if(m.pageHeight){let p=c.scrollHeight;if(p>0&&pm.pageHeight*g)if(Ve()){if(p>m.pageHeight*2*g)return!1}else return!1;for(let b of c.childNodes)if(b.nodeType==Node.TEXT_NODE&&b.textContent&&b.textContent.trim().length>0)return!0}}return!1}function l(c,d,m){fx(c.ctx,d);let p=d.nodeName.toLowerCase();if(p=="script")return d.childNodes.length==0||d.childNodes.length==1&&d.childNodes[0].nodeType==Node.TEXT_NODE;if(d.nodeType===Node.DOCUMENT_FRAGMENT_NODE)return!1;if(d.nodeType!==Node.ELEMENT_NODE||m&&ht.isMarked(d,c.id))return!0;if(c.ctx.rule.isTransformPreTagNewLine&&p==="pre")return!1;let g=on(c.ctx);return!!(P0(d,{excludeSelectors:g.excludeSelectors,selectors:g.selectors,excludeSelectorsRegexes:g.excludeSelectorsRegexes,stayOriginalSelectors:g.stayOriginalSelectors})||At(d,g.skipBuildContainerSelectors)||At(d,g.stayOriginalSelectors))}}function Lu(e,t,n){if(!t.targetNodes)return;let r=t.state||"original",a=t.commonAncestorContainer;if(!ht.isSkipMarkEle(a)&&!ht.isMarked(a,t.ctxId))return;let i=a.contains(t.rootNodes[0]),o=a.contains(t.targetNodes[0]);if(i&&o)r="dual";else if(i)r="original";else if(o)r="translation";else return;if(n!=r){t.state=n;try{if(r=="dual"&&n=="translation"&&Ni(t.rootNodes),r=="original"&&n=="translation"){let s=Xo(e,t.rootNodes);if(mf(s))return;ti(e,s,a,t.targetNodes||[]),Ni(t.rootNodes)}if(r=="translation"&&n=="dual"){let s=e.config.translationPosition=="before"?"after":"before",u=Xo(e,t.targetNodes,s);ti(e,u,a,t.rootNodes||[],s)}if(r=="original"&&n=="dual"){let s=Xo(e,t.rootNodes);if(mf(s))return;ti(e,s,a,t.targetNodes||[])}if(r=="translation"&&n=="original"){let s=Xo(e,t.targetNodes);ti(e,s,a,t.rootNodes||[]),Ni(t.targetNodes)}r=="dual"&&n=="original"&&Ni(t.targetNodes),bf(t)}catch(s){k.error(s)}fa("inserted"),Dy()}}function mf(e){return!e||!Mi(e)?!1:e.classList.contains(Lt)}function Xo(e,t,n){return t?(n||e.config.translationPosition)=="before"?t[0]:t[t.length-1].nextSibling:null}function Ni(e){(e||[]).forEach(t=>t.parentNode?.removeChild(t))}function ti(e,t,n,r,a){let i=a||e.config.translationPosition;if(n){if(i=="before"&&!t&&n.childNodes.length){let o=n.childNodes[0];r.forEach(s=>{n.insertBefore(s,o)});return}t?r.forEach(o=>{t.parentNode?.insertBefore(o,t)}):r.forEach(o=>{n.appendChild(o)})}}var nM=Yn(F0,300);async function ji(e,t,n=!1,r="web"){if(e.interruptEffectDOM)return;fa("parseParagraph");let a=t.commonAncestorContainer;if(a instanceof ShadowRoot||rM(t.rootNodes)||t.stepState>=2)return;t.stepState=2,Xi&&wt(a,"onParseParagraph",e.id);let{ctx:i}=e,{rule:o}=i,s=Li(i.config.translationServices,e.translationService),u=i.config.translationServices[i.translationService],l=M0(t.commonAncestorContainer,t.flatNodes,{isPreWhitespace:t.isPreWhitespace||!1,delimiters:s,stayOriginalSelectors:I0(i),ignoreRichSelectors:o.ignoreRichSelectors,smallCodeLength:o.smallCodeLength,domPurifyAddTags:o.domPurifyAddTags,richMoreWordPercent:o.richMoreWordPercent||0},u,!!i.isRichTranslate);if(!l)return;let c=i?.config?.translationLanguagePattern?.excludeMatches||[],d=await hf(i,t,l,{excludeLanguages:n?[]:c,targetLanguage:i.targetLanguage,noTranslateRegexp:i.rule.noTranslateRegexp,delimiters:Hr(i.config.translationServices[i.translationService]),minTextCount:n?3:o.paragraphMinTextCount,minWordCount:o.paragraphMinWordCount,isDetectParagraphLanguage:o.detectParagraphLanguage||i.state.isDetectParagraphLanguage,ignoreZhCNandZhTW:i.rule.ignoreZhCNandZhTW});if(d){if(k.debug("on paragraph",d.text,d),a.paragraphs=a.paragraphs||[],a.paragraphs.includes(d))return;a.paragraphs.push(d),e.immediateTranslateCapacity>0||n?(n&&(t.force=!0),aM(e,t.text),ff(e,t,r)):(Xi&&wt(a,"observeParagraph",e.id),e.observeParagraphs.push(d),e.paragraphVisibleObserver?.unobserve(a),e.paragraphVisibleObserver?.observe(a))}return d}function rM(e){if(!e)return!1;let t=e[e.length-1].nextSibling;return t?Mi(t)&&t.classList.contains(Lt):!1}function aM(e,t){e.ctx.state.translationStartMode!=="immediate"&&(e.immediateTranslateCapacity-=t?.length||0)}function ff(e,t,n="web"){if(e.interruptEffectDOM||t.stepState>=3)return;fa("consumeParagraph"),t.stepState=3;let r=e.autoIncreaseParagraphId++;if(t.id=r.toString(),e.paragraphEntities[r]=t,e.paragraphQueue.push(r.toString()),Xi&&wt(t.commonAncestorContainer,"consumeParagraph",e.id),wt(t.commonAncestorContainer,a1,"1",!0),n=="hover"){F0.call(e,e.ctx);return}let a=e.allTextLength>50*1e4&&e.ctx.state.translationStartMode==="immediate";nM.call(e,e.ctx,a)}async function F0(e,t=!1){if(this.interruptEffectDOM)return;let n=this.paragraphQueue;this.paragraphQueue=[];let r=[],a=[];for(let o=0;o{await B0(o,{...e,translationService:this.translationService},this.translateState,t)})}async function B0(e,t,n,r=!1){let a={sentences:[]};for(let i of e){let o=i.id,s=lu(t,o,r),u=i.rootNodes[i.rootNodes.length-1].nextSibling;ti(t,u,i.commonAncestorContainer,[s]),bf(i),a.sentences.push({id:parseInt(o),url:t.encryptedUrl,text:i.text,from:i.languageByLocal||"auto",fromByClient:i.languageByClient||"auto",to:t.targetLanguage,xpath:i.xpath,force:i.force,inArticleContext:i.inArticleContext})}if(a.sentences.length>0)try{await Qt(a,t,(i,o,s)=>{let u=s.id,l=iM(e,u.toString());l&&oM.call(null,i,o,s,l,t,n)})}catch(i){k.error("translateCurrentQueue error",i);return}}function iM(e,t){return e.find(n=>n.id===t)}function oM(e,t,n,r,a,i){fa("translated");let o=!1,s=r;Do(s.commonAncestorContainer,n.id)?.remove(),bf(r),s&&(e||!t)?l(e):u(r),document.dispatchEvent(new CustomEvent(Ot,{detail:JSON.stringify({type:"paragraphTranslated",payload:{ok:o}})}));function u(c){if(!c){k.error("paragraph not found",n.id);return}if(s.error=void 0,c.targetText=t?.text||"",c.contextTargetText=t?.contextText,c.text?.trim().toLocaleLowerCase()==c.targetText?.trim().toLocaleLowerCase()){let m=c.commonAncestorContainer?.paragraphs||[],p=m?.indexOf(c);p>=0&&m.splice(p,1)}else{let m=document.createElement(a.rule.targetWrapperTag);m.classList.add("notranslate",Lt),m.setAttribute(ao,"1");let p=px(c,a);a.config.enableEditTranslation&&m.setAttribute("contenteditable","true"),Zo(a)&&m.setAttribute("dir","rtl"),m.setAttribute("lang",a.targetLanguage);let g=tM.sanitize(p);m.innerHTML=Bn?.createHTML(g)||g,c.targetNodes=[m],Lu(a,c,i)}o=!0}function l(c){c||(k.error("translate error",n,c,t),c=new Error("no response from server"));let{rule:d}=a,m=n.id,p=document.createElement(d.targetWrapperTag);wt(p,u1,m.toString()),p.classList.add("notranslate",Lt,Lt+"-error"),p.setAttribute("translate","no"),p.setAttribute("lang",a.targetLanguage);let g=r.rootNodes[r.rootNodes.length-1].nextSibling;if(mf(g)||ti(a,g,r.commonAncestorContainer,[p]),s&&(s.error=c),p){let b=sM(a,c).replaceAll(`
+ ${r.innerHTML}`.replaceAll(`data-${L}-translation-element-mark="1"`,"dim_m='1'").replace(/data-immersive-translate-walked=\".+?\"/g,"dim_w='1'").replace(/data-on-parse-paragraph=\".+?\"/g,"").replace(/data-consume-paragraph=\".+?\"/g,"").replace(/data-consume-container=\".+?\"/g,"").replace(/immersive-translate-target-([a-z\-]+)/g,(l,c)=>"imt_"+c.replaceAll("translation","t"))}catch{return""}}function I0(e){let t=gy(e);return t.stayOriginalTags.map(r=>r.toLowerCase()).concat(t.stayOriginalSelectors).concat(t.additionalStayOriginalSelectors)}function on(e,t){if(!t&&e.filterRule)return e.filterRule;let n=e.rule;e.isRichTranslate&&(n=Up(n));let r=[...n.selectors],a=[...n.excludeTags],i=[...n.excludeSelectors],o={...n.excludeSelectorsRegexes};return e.state.translationArea==="body"?(r=[],i=[],o={}):(n.preTranslateLimiter?.keys||[]).forEach(u=>{n.preTranslateLimiter[`${u}.enableTranslate`]||i.push(...n.preTranslateLimiter[`${u}.selectors`]||[])}),{paragraphFirstLetterFontSize:n.paragraphFirstLetterFontSize,globalStyles:n.globalStyles,globalAttributes:n.globalAttributes,selectors:r,atomicBlockSelectors:n.atomicBlockSelectors,skipEditableCheck:n.skipEditableCheck,lineBreakMaxTextCount:n.lineBreakMaxTextCount,lineBreakRegexStr:n.lineBreakRegexStr,isTransformPreTagNewLine:n.isTransformPreTagNewLine,likePreSelectors:n.likePreSelectors,skipBuildContainerSelectors:n.skipBuildContainerSelectors,buildContainerSelectors:n.buildContainerSelectors,excludeSelectors:a.map(u=>u.toLowerCase()).filter(u=>u!=="code"&&u!=="img").concat(i).concat(n.additionalExcludeSelectors),excludeSelectorsRegexes:o,blockSelectors:n.allBlockTags.map(u=>u.toLowerCase()).concat(n.extraBlockSelectors),extraBlockSelectors:n.extraBlockSelectors,extraInlineSelectors:n.extraInlineSelectors.concat(n.additionalInlineSelectors),stayOriginalSelectors:n.stayOriginalTags.map(u=>u.toLowerCase()).concat(n.stayOriginalSelectors).concat(n.additionalStayOriginalSelectors),skipTrailTextRegex:n.skipTrailTextRegex,advanceTransformPreTagNewLine:n.advanceTransformPreTagNewLine}}var tM={sanitize:e=>e};async function ff(e,t){if(e.interruptEffectDOM)return;ha("consumeContainer");let n=on(e.ctx);await e.walkContainer({id:e.id,container:t,articleNode:e.ctx.articleNode,filterRule:n,bodyRule:e.ctx.rule.bodyRule,onParagraph:Ui.bind(null,e),onFrame:r=>{mf(e,r,!0)},onIgnoreElement:r=>{ht.mark(r,e.id,n.skipEditableCheck),e.ignoreResizeObserver?.observe(r)},engineCtx:e}),$i&&wt(t,"consumeContainer",e.id)}function mf(e,t,n){try{if(t instanceof HTMLIFrameElement){if(!Na(t))return;k.debug("onFrame fragment",t);let r=t?.contentWindow?.document.body;if(r){if(t?.contentWindow?.document.querySelector(`[data-id="${Hl}"]`))return;e.injectCssToDocument(t,e.ctx);let a=e.inlineIFrames||[];a.push(t),e.inlineIFrames=a,qr(t.contentWindow?.document.documentElement,e.translateState),ri(r,e,n),e.dynamicContainerObserver?.observe(r,{childList:!0,subtree:!0,characterData:!0})}}else{if(k.debug("onFrame shadowRoot",t.host),!t.host)return;e.injectCssToDocument(t,e.ctx),ri(t,e,n),e.dynamicContainerObserver?.observe(t,{childList:!0,subtree:!0,characterData:!0})}}catch{}}async function ri(e,t,n=!0){ha("buildContainer");let r=Date.now(),{globalStyles:a,globalAttributes:i}=on(t.ctx),o=0;if(l(t,e,n))return;if(Ri(e)&&u(e)){ht.mark(e,t.id,t.ctx.rule.skipEditableCheck),await s(e);return}try{let c=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,d=>t.interruptEffectDOM?(k.debug("\u4E2D\u65AD"),NodeFilter.FILTER_REJECT):(Ri(d)&&(a&&nf(d,a),i&&af(d,i)),l(t,d,n)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT));for(ht.mark(c.currentNode,t.id,t.ctx.rule.skipEditableCheck);c.nextNode()&&!t.interruptEffectDOM;){ht.mark(c.currentNode,t.id,t.ctx.rule.skipEditableCheck);let d=c.currentNode;if(u(d))for(await s(d);!t.interruptEffectDOM;){if(c.nextSibling()){let m=c.currentNode;if(ht.mark(c.currentNode,t.id,t.ctx.rule.skipEditableCheck),u(m)){await s(m);continue}else break}if(!c.parentNode())return}}}catch{}if(o==0&&e instanceof HTMLElement){await s(e);return}return t.observeContainers;async function s(c){if(!t.interruptEffectDOM)if(o++,ht.clearMark(c),t.immediateTranslateCapacity>=0){await ff(t,c);let d=Date.now()-r;d>100&&(k.debug("batchTaskTime",d,c),r=Date.now(),await ot(0))}else $i&&wt(c,"observeContainer",t.id),t.containerVisibleObserver?.unobserve(c),t.containerVisibleObserver?.observe(c)}function u(c){let d=c.nodeName.toLowerCase();if(c.shadowRoot)return mf(t,c.shadowRoot,n),!1;if(d==="iframe")return mf(t,c,n),!1;if(["script","#document-fragment","img"].includes(d))return!1;let m=t.containerRule;if(m.selectors&&m.selectors?.length>0)return ku(c,m.selectors);if(t.ctx.rule.enableSkipBuildContainer||m.containerSelectors&&ku(c,m.containerSelectors))return!0;if(m.pageHeight){let p=c.scrollHeight;if(p>0&&p