diff --git "a/static/management.html" "b/static/management.html" --- "a/static/management.html" +++ "b/static/management.html" @@ -22,7 +22,7 @@ Please change the parent to n.set(s)),n}static accessor(e){const n=(this[zC]=this[zC]={accessors:{}}).accessors,s=this.prototype;function a(r){const o=Cd(r);n[o]||(EB(s,r),n[o]=!0)}return re.isArray(e)?e.forEach(a):a(e),this}};Vn.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);re.reduceDescriptors(Vn.prototype,({value:i},e)=>{let t=e[0].toUpperCase()+e.slice(1);return{get:()=>i,set(n){this[t]=n}}});re.freezeMethods(Vn);function w1(i,e){const t=this||lf,n=e||t,s=Vn.from(n.headers);let a=n.data;return re.forEach(i,function(o){a=o.call(t,a,s.normalize(),e?e.status:void 0)}),s.normalize(),a}function kR(i){return!!(i&&i.__CANCEL__)}function Cu(i,e,t){Ye.call(this,i==null?"canceled":i,Ye.ERR_CANCELED,e,t),this.name="CanceledError"}re.inherits(Cu,Ye,{__CANCEL__:!0});function AR(i,e,t){const n=t.config.validateStatus;!t.status||!n||n(t.status)?i(t):e(new Ye("Request failed with status code "+t.status,[Ye.ERR_BAD_REQUEST,Ye.ERR_BAD_RESPONSE][Math.floor(t.status/100)-4],t.config,t.request,t))}function DB(i){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(i);return e&&e[1]||""}function UB(i,e){i=i||10;const t=new Array(i),n=new Array(i);let s=0,a=0,r;return e=e!==void 0?e:1e3,function(c){const d=Date.now(),h=n[a];r||(r=d),t[s]=c,n[s]=d;let p=a,_=0;for(;p!==s;)_+=t[p++],p=p%i;if(s=(s+1)%i,s===a&&(a=(a+1)%i),d-r{t=h,s=null,a&&(clearTimeout(a),a=null),i(...d)};return[(...d)=>{const h=Date.now(),p=h-t;p>=n?r(d,h):(s=d,a||(a=setTimeout(()=>{a=null,r(s)},n-p)))},()=>s&&r(s)]}const vg=(i,e,t=3)=>{let n=0;const s=UB(50,250);return FB(a=>{const r=a.loaded,o=a.lengthComputable?a.total:void 0,c=r-n,d=s(c),h=r<=o;n=r;const p={loaded:r,total:o,progress:o?r/o:void 0,bytes:c,rate:d||void 0,estimated:d&&o&&h?(o-r)/d:void 0,event:a,lengthComputable:o!=null,[e?"download":"upload"]:!0};i(p)},t)},qC=(i,e)=>{const t=i!=null;return[n=>e[0]({lengthComputable:t,total:i,loaded:n}),e[1]]},HC=i=>(...e)=>re.asap(()=>i(...e)),BB=cn.hasStandardBrowserEnv?((i,e)=>t=>(t=new URL(t,cn.origin),i.protocol===t.protocol&&i.host===t.host&&(e||i.port===t.port)))(new URL(cn.origin),cn.navigator&&/(msie|trident)/i.test(cn.navigator.userAgent)):()=>!0,zB=cn.hasStandardBrowserEnv?{write(i,e,t,n,s,a,r){if(typeof document=="undefined")return;const o=[`${i}=${encodeURIComponent(e)}`];re.isNumber(t)&&o.push(`expires=${new Date(t).toUTCString()}`),re.isString(n)&&o.push(`path=${n}`),re.isString(s)&&o.push(`domain=${s}`),a===!0&&o.push("secure"),re.isString(r)&&o.push(`SameSite=${r}`),document.cookie=o.join("; ")},read(i){if(typeof document=="undefined")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+i+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(i){this.write(i,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function qB(i){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(i)}function HB(i,e){return e?i.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):i}function CR(i,e,t){let n=!qB(e);return i&&(n||t==!1)?HB(i,e):e}const KC=i=>i instanceof Vn?z({},i):i;function jl(i,e){e=e||{};const t={};function n(d,h,p,_){return re.isPlainObject(d)&&re.isPlainObject(h)?re.merge.call({caseless:_},d,h):re.isPlainObject(h)?re.merge({},h):re.isArray(h)?h.slice():h}function s(d,h,p,_){if(re.isUndefined(h)){if(!re.isUndefined(d))return n(void 0,d,p,_)}else return n(d,h,p,_)}function a(d,h){if(!re.isUndefined(h))return n(void 0,h)}function r(d,h){if(re.isUndefined(h)){if(!re.isUndefined(d))return n(void 0,d)}else return n(void 0,h)}function o(d,h,p){if(p in e)return n(d,h);if(p in i)return n(void 0,d)}const c={url:a,method:a,data:a,baseURL:r,transformRequest:r,transformResponse:r,paramsSerializer:r,timeout:r,timeoutMessage:r,withCredentials:r,withXSRFToken:r,adapter:r,responseType:r,xsrfCookieName:r,xsrfHeaderName:r,onUploadProgress:r,onDownloadProgress:r,decompress:r,maxContentLength:r,maxBodyLength:r,beforeRedirect:r,transport:r,httpAgent:r,httpsAgent:r,cancelToken:r,socketPath:r,responseEncoding:r,validateStatus:o,headers:(d,h,p)=>s(KC(d),KC(h),p,!0)};return re.forEach(Object.keys(z(z({},i),e)),function(h){const p=c[h]||s,_=p(i[h],e[h],h);re.isUndefined(_)&&p!==o||(t[h]=_)}),t}const OR=i=>{const e=jl({},i);let{data:t,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:a,headers:r,auth:o}=e;if(e.headers=r=Vn.from(r),e.url=vR(CR(e.baseURL,e.url,e.allowAbsoluteUrls),i.params,i.paramsSerializer),o&&r.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),re.isFormData(t)){if(cn.hasStandardBrowserEnv||cn.hasStandardBrowserWebWorkerEnv)r.setContentType(void 0);else if(re.isFunction(t.getHeaders)){const c=t.getHeaders(),d=["content-type","content-length"];Object.entries(c).forEach(([h,p])=>{d.includes(h.toLowerCase())&&r.set(h,p)})}}if(cn.hasStandardBrowserEnv&&(n&&re.isFunction(n)&&(n=n(e)),n||n!==!1&&BB(e.url))){const c=s&&a&&zB.read(a);c&&r.set(s,c)}return e},KB=typeof XMLHttpRequest!="undefined",VB=KB&&function(i){return new Promise(function(t,n){const s=OR(i);let a=s.data;const r=Vn.from(s.headers).normalize();let{responseType:o,onUploadProgress:c,onDownloadProgress:d}=s,h,p,_,y,x;function v(){y&&y(),x&&x(),s.cancelToken&&s.cancelToken.unsubscribe(h),s.signal&&s.signal.removeEventListener("abort",h)}let w=new XMLHttpRequest;w.open(s.method.toUpperCase(),s.url,!0),w.timeout=s.timeout;function k(){if(!w)return;const O=Vn.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders()),C={data:!o||o==="text"||o==="json"?w.responseText:w.response,status:w.status,statusText:w.statusText,headers:O,config:i,request:w};AR(function(R){t(R),v()},function(R){n(R),v()},C),w=null}"onloadend"in w?w.onloadend=k:w.onreadystatechange=function(){!w||w.readyState!==4||w.status===0&&!(w.responseURL&&w.responseURL.indexOf("file:")===0)||setTimeout(k)},w.onabort=function(){w&&(n(new Ye("Request aborted",Ye.ECONNABORTED,i,w)),w=null)},w.onerror=function(A){const C=A&&A.message?A.message:"Network Error",P=new Ye(C,Ye.ERR_NETWORK,i,w);P.event=A||null,n(P),w=null},w.ontimeout=function(){let A=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const C=s.transitional||SR;s.timeoutErrorMessage&&(A=s.timeoutErrorMessage),n(new Ye(A,C.clarifyTimeoutError?Ye.ETIMEDOUT:Ye.ECONNABORTED,i,w)),w=null},a===void 0&&r.setContentType(null),"setRequestHeader"in w&&re.forEach(r.toJSON(),function(A,C){w.setRequestHeader(C,A)}),re.isUndefined(s.withCredentials)||(w.withCredentials=!!s.withCredentials),o&&o!=="json"&&(w.responseType=s.responseType),d&&([_,x]=vg(d,!0),w.addEventListener("progress",_)),c&&w.upload&&([p,y]=vg(c),w.upload.addEventListener("progress",p),w.upload.addEventListener("loadend",y)),(s.cancelToken||s.signal)&&(h=O=>{w&&(n(!O||O.type?new Cu(null,i,w):O),w.abort(),w=null)},s.cancelToken&&s.cancelToken.subscribe(h),s.signal&&(s.signal.aborted?h():s.signal.addEventListener("abort",h)));const M=DB(s.url);if(M&&cn.protocols.indexOf(M)===-1){n(new Ye("Unsupported protocol "+M+":",Ye.ERR_BAD_REQUEST,i));return}w.send(a||null)})},IB=(i,e)=>{const{length:t}=i=i?i.filter(Boolean):[];if(e||t){let n=new AbortController,s;const a=function(d){if(!s){s=!0,o();const h=d instanceof Error?d:this.reason;n.abort(h instanceof Ye?h:new Cu(h instanceof Error?h.message:h))}};let r=e&&setTimeout(()=>{r=null,a(new Ye(`timeout ${e} of ms exceeded`,Ye.ETIMEDOUT))},e);const o=()=>{i&&(r&&clearTimeout(r),r=null,i.forEach(d=>{d.unsubscribe?d.unsubscribe(a):d.removeEventListener("abort",a)}),i=null)};i.forEach(d=>d.addEventListener("abort",a));const{signal:c}=n;return c.unsubscribe=()=>re.asap(o),c}},WB=function*(i,e){let t=i.byteLength;if(t{const s=XB(i,e);let a=0,r,o=d=>{r||(r=!0,n&&n(d))};return new ReadableStream({pull(d){return pe(this,null,function*(){try{const{done:h,value:p}=yield s.next();if(h){o(),d.close();return}let _=p.byteLength;if(t){let y=a+=_;t(y)}d.enqueue(new Uint8Array(p))}catch(h){throw o(h),h}})},cancel(d){return o(d),s.return()}},{highWaterMark:2})},IC=64*1024,{isFunction:Jp}=re,QB=(({Request:i,Response:e})=>({Request:i,Response:e}))(re.global),{ReadableStream:WC,TextEncoder:XC}=re.global,GC=(i,...e)=>{try{return!!i(...e)}catch(t){return!1}},YB=i=>{i=re.merge.call({skipUndefined:!0},QB,i);const{fetch:e,Request:t,Response:n}=i,s=e?Jp(e):typeof fetch=="function",a=Jp(t),r=Jp(n);if(!s)return!1;const o=s&&Jp(WC),c=s&&(typeof XC=="function"?(x=>v=>x.encode(v))(new XC):x=>pe(null,null,function*(){return new Uint8Array(yield new t(x).arrayBuffer())})),d=a&&o&&GC(()=>{let x=!1;const v=new t(cn.origin,{body:new WC,method:"POST",get duplex(){return x=!0,"half"}}).headers.has("Content-Type");return x&&!v}),h=r&&o&&GC(()=>re.isReadableStream(new n("").body)),p={stream:h&&(x=>x.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(x=>{!p[x]&&(p[x]=(v,w)=>{let k=v&&v[x];if(k)return k.call(v);throw new Ye(`Response type '${x}' is not supported`,Ye.ERR_NOT_SUPPORT,w)})});const _=x=>pe(null,null,function*(){if(x==null)return 0;if(re.isBlob(x))return x.size;if(re.isSpecCompliantForm(x))return(yield new t(cn.origin,{method:"POST",body:x}).arrayBuffer()).byteLength;if(re.isArrayBufferView(x)||re.isArrayBuffer(x))return x.byteLength;if(re.isURLSearchParams(x)&&(x=x+""),re.isString(x))return(yield c(x)).byteLength}),y=(x,v)=>pe(null,null,function*(){const w=re.toFiniteNumber(x.getContentLength());return w==null?_(v):w});return x=>pe(null,null,function*(){let{url:v,method:w,data:k,signal:M,cancelToken:O,timeout:A,onDownloadProgress:C,onUploadProgress:P,responseType:R,headers:E,withCredentials:L="same-origin",fetchOptions:D}=OR(x),q=e||fetch;R=R?(R+"").toLowerCase():"text";let B=IB([M,O&&O.toAbortSignal()],A),H=null;const W=B&&B.unsubscribe&&(()=>{B.unsubscribe()});let V;try{if(P&&d&&w!=="get"&&w!=="head"&&(V=yield y(E,k))!==0){let F=new t(v,{method:"POST",body:k,duplex:"half"}),Y;if(re.isFormData(k)&&(Y=F.headers.get("content-type"))&&E.setContentType(Y),F.body){const[ce,J]=qC(V,vg(HC(P)));k=VC(F.body,IC,ce,J)}}re.isString(L)||(L=L?"include":"omit");const U=a&&"credentials"in t.prototype,G=ee(z({},D),{signal:B,method:w.toUpperCase(),headers:E.normalize().toJSON(),body:k,duplex:"half",credentials:U?L:void 0});H=a&&new t(v,G);let $=yield a?q(H,D):q(v,G);const ie=h&&(R==="stream"||R==="response");if(h&&(C||ie&&W)){const F={};["status","statusText","headers"].forEach(me=>{F[me]=$[me]});const Y=re.toFiniteNumber($.headers.get("content-length")),[ce,J]=C&&qC(Y,vg(HC(C),!0))||[];$=new n(VC($.body,IC,ce,()=>{J&&J(),W&&W()}),F)}R=R||"text";let ue=yield p[re.findKey(p,R)||"text"]($,x);return!ie&&W&&W(),yield new Promise((F,Y)=>{AR(F,Y,{data:ue,headers:Vn.from($.headers),status:$.status,statusText:$.statusText,config:x,request:H})})}catch(U){throw W&&W(),U&&U.name==="TypeError"&&/Load failed|fetch/i.test(U.message)?Object.assign(new Ye("Network Error",Ye.ERR_NETWORK,x,H),{cause:U.cause||U}):Ye.from(U,U&&U.code,x,H)}})},ZB=new Map,TR=i=>{let e=i&&i.env||{};const{fetch:t,Request:n,Response:s}=e,a=[n,s,t];let r=a.length,o=r,c,d,h=ZB;for(;o--;)c=a[o],d=h.get(c),d===void 0&&h.set(c,d=o?new Map:YB(e)),h=d;return d};TR();const Bv={http:pB,xhr:VB,fetch:{get:TR}};re.forEach(Bv,(i,e)=>{if(i){try{Object.defineProperty(i,"name",{value:e})}catch(t){}Object.defineProperty(i,"adapterName",{value:e})}});const QC=i=>`- ${i}`,JB=i=>re.isFunction(i)||i===null||i===!1;function $B(i,e){i=re.isArray(i)?i:[i];const{length:t}=i;let n,s;const a={};for(let r=0;r`adapter ${c} `+(d===!1?"is not supported by the environment":"is not available in the build"));let o=t?r.length>1?`since : `+r.map(QC).join(` `):" "+QC(r[0]):"as no adapter specified";throw new Ye("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return s}const MR={getAdapter:$B,adapters:Bv};function k1(i){if(i.cancelToken&&i.cancelToken.throwIfRequested(),i.signal&&i.signal.aborted)throw new Cu(null,i)}function YC(i){return k1(i),i.headers=Vn.from(i.headers),i.data=w1.call(i,i.transformRequest),["post","put","patch"].indexOf(i.method)!==-1&&i.headers.setContentType("application/x-www-form-urlencoded",!1),MR.getAdapter(i.adapter||lf.adapter,i)(i).then(function(n){return k1(i),n.data=w1.call(i,i.transformResponse,n),n.headers=Vn.from(n.headers),n},function(n){return kR(n)||(k1(i),n&&n.response&&(n.response.data=w1.call(i,i.transformResponse,n.response),n.response.headers=Vn.from(n.response.headers))),Promise.reject(n)})}const NR="1.13.2",b0={};["object","boolean","number","function","string","symbol"].forEach((i,e)=>{b0[i]=function(n){return typeof n===i||"a"+(e<1?"n ":" ")+i}});const ZC={};b0.transitional=function(e,t,n){function s(a,r){return"[Axios v"+NR+"] Transitional option '"+a+"'"+r+(n?". "+n:"")}return(a,r,o)=>{if(e===!1)throw new Ye(s(r," has been removed"+(t?" in "+t:"")),Ye.ERR_DEPRECATED);return t&&!ZC[r]&&(ZC[r]=!0,console.warn(s(r," has been deprecated since v"+t+" and will be removed in the near future"))),e?e(a,r,o):!0}};b0.spelling=function(e){return(t,n)=>(console.warn(`${n} is likely a misspelling of ${e}`),!0)};function ez(i,e,t){if(typeof i!="object")throw new Ye("options must be an object",Ye.ERR_BAD_OPTION_VALUE);const n=Object.keys(i);let s=n.length;for(;s-- >0;){const a=n[s],r=e[a];if(r){const o=i[a],c=o===void 0||r(o,a,i);if(c!==!0)throw new Ye("option "+a+" must be "+c,Ye.ERR_BAD_OPTION_VALUE);continue}if(t!==!0)throw new Ye("Unknown option "+a,Ye.ERR_BAD_OPTION)}}const Gm={assertOptions:ez,validators:b0},da=Gm.validators;let kl=class{constructor(e){this.defaults=e||{},this.interceptors={request:new BC,response:new BC}}request(e,t){return pe(this,null,function*(){try{return yield this._request(e,t)}catch(n){if(n instanceof Error){let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const a=s.stack?s.stack.replace(/^.+\n/,""):"";try{n.stack?a&&!String(n.stack).endsWith(a.replace(/^.+\n.+\n/,""))&&(n.stack+=` -`+a):n.stack=a}catch(r){}}throw n}})}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=jl(this.defaults,t);const{transitional:n,paramsSerializer:s,headers:a}=t;n!==void 0&&Gm.assertOptions(n,{silentJSONParsing:da.transitional(da.boolean),forcedJSONParsing:da.transitional(da.boolean),clarifyTimeoutError:da.transitional(da.boolean)},!1),s!=null&&(re.isFunction(s)?t.paramsSerializer={serialize:s}:Gm.assertOptions(s,{encode:da.function,serialize:da.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Gm.assertOptions(t,{baseUrl:da.spelling("baseURL"),withXsrfToken:da.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=a&&re.merge(a.common,a[t.method]);a&&re.forEach(["delete","get","head","post","put","patch","common"],x=>{delete a[x]}),t.headers=Vn.concat(r,a);const o=[];let c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(t)===!1||(c=c&&v.synchronous,o.unshift(v.fulfilled,v.rejected))});const d=[];this.interceptors.response.forEach(function(v){d.push(v.fulfilled,v.rejected)});let h,p=0,_;if(!c){const x=[YC.bind(this),void 0];for(x.unshift(...o),x.push(...d),_=x.length,h=Promise.resolve(t);p<_;)h=h.then(x[p++],x[p++]);return h}_=o.length;let y=t;for(;p<_;){const x=o[p++],v=o[p++];try{y=x(y)}catch(w){v.call(this,w);break}}try{h=YC.call(this,y)}catch(x){return Promise.reject(x)}for(p=0,_=d.length;p<_;)h=h.then(d[p++],d[p++]);return h}getUri(e){e=jl(this.defaults,e);const t=CR(e.baseURL,e.url,e.allowAbsoluteUrls);return vR(t,e.params,e.paramsSerializer)}};re.forEach(["delete","get","head","options"],function(e){kl.prototype[e]=function(t,n){return this.request(jl(n||{},{method:e,url:t,data:(n||{}).data}))}});re.forEach(["post","put","patch"],function(e){function t(n){return function(a,r,o){return this.request(jl(o||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:a,data:r}))}}kl.prototype[e]=t(),kl.prototype[e+"Form"]=t(!0)});let tz=class RR{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(a){t=a});const n=this;this.promise.then(s=>{if(!n._listeners)return;let a=n._listeners.length;for(;a-- >0;)n._listeners[a](s);n._listeners=null}),this.promise.then=s=>{let a;const r=new Promise(o=>{n.subscribe(o),a=o}).then(s);return r.cancel=function(){n.unsubscribe(a)},r},e(function(a,r,o){n.reason||(n.reason=new Cu(a,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new RR(function(s){e=s}),cancel:e}}};function iz(i){return function(t){return i.apply(null,t)}}function nz(i){return re.isObject(i)&&i.isAxiosError===!0}const Ix={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ix).forEach(([i,e])=>{Ix[e]=i});function PR(i){const e=new kl(i),t=cR(kl.prototype.request,e);return re.extend(t,kl.prototype,e,{allOwnKeys:!0}),re.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return PR(jl(i,s))},t}const li=PR(lf);li.Axios=kl;li.CanceledError=Cu;li.CancelToken=tz;li.isCancel=kR;li.VERSION=NR;li.toFormData=x0;li.AxiosError=Ye;li.Cancel=li.CanceledError;li.all=function(e){return Promise.all(e)};li.spread=iz;li.isAxiosError=nz;li.mergeConfig=jl;li.AxiosHeaders=Vn;li.formToJSON=i=>wR(re.isHTMLForm(i)?new FormData(i):i);li.getAdapter=MR.getAdapter;li.HttpStatusCode=Ix;li.default=li;const{Axios:$le,AxiosError:ece,CanceledError:tce,isCancel:ice,CancelToken:nce,VERSION:sce,all:ace,Cancel:rce,isAxiosError:oce,spread:lce,toFormData:cce,AxiosHeaders:uce,HttpStatusCode:dce,formToJSON:hce,getAdapter:fce,mergeConfig:pce}=li;class sz{constructor(){Ge(this,"instance");Ge(this,"apiBase","");Ge(this,"managementKey","");this.instance=li.create({timeout:RC,headers:{"Content-Type":"application/json"}}),this.setupInterceptors()}setConfig(e){this.apiBase=this.normalizeApiBase(e.apiBase),this.managementKey=e.managementKey,e.timeout?this.instance.defaults.timeout=e.timeout:this.instance.defaults.timeout=RC}normalizeApiBase(e){let t=e.trim();return t=t.replace(/\/?v0\/management\/?$/i,""),t=t.replace(/\/+$/,""),/^https?:\/\//i.test(t)||(t=`http://${t}`),`${t}${Fx}`}readHeader(e,t){if(!e)return null;const n=o=>{if(o==null)return null;if(Array.isArray(o)){const d=o.find(h=>h!=null&&String(h).trim());return d!==void 0?String(d):null}const c=String(o);return c||null},s=e.get;if(typeof s=="function")for(const o of t){const c=n(s.call(e,o));if(c)return c}const a=typeof e.entries=="function"?Array.from(e.entries()):Object.entries(e),r=Object.fromEntries(a.map(([o,c])=>[String(o).toLowerCase(),c]));for(const o of t){const c=n(r[o.toLowerCase()]);if(c)return c}return null}setupInterceptors(){this.instance.interceptors.request.use(e=>(e.baseURL=this.apiBase,e.url&&(e.url=e.url.replace(/\/generative-language-api-key\b/g,"/gemini-api-key")),this.managementKey&&(e.headers.Authorization=`Bearer ${this.managementKey}`),e),e=>Promise.reject(this.handleError(e))),this.instance.interceptors.response.use(e=>{const t=e.headers,n=this.readHeader(t,lF),s=this.readHeader(t,cF);return(n||s)&&window.dispatchEvent(new CustomEvent("server-version-update",{detail:{version:n||null,buildDate:s||null}})),e},e=>Promise.reject(this.handleError(e)))}handleError(e){var n,s,a;if(li.isAxiosError(e)){const r=(n=e.response)==null?void 0:n.data,o=(r==null?void 0:r.error)||(r==null?void 0:r.message)||e.message||"Request failed",c=new Error(o);return c.name="ApiError",c.status=(s=e.response)==null?void 0:s.status,c.code=e.code,c.details=r,c.data=r,((a=e.response)==null?void 0:a.status)===401&&window.dispatchEvent(new Event("unauthorized")),c}const t=new Error((e==null?void 0:e.message)||"Unknown error occurred");return t.name="ApiError",t}get(e,t){return pe(this,null,function*(){return(yield this.instance.get(e,t)).data})}post(e,t,n){return pe(this,null,function*(){return(yield this.instance.post(e,t,n)).data})}put(e,t,n){return pe(this,null,function*(){return(yield this.instance.put(e,t,n)).data})}patch(e,t,n){return pe(this,null,function*(){return(yield this.instance.patch(e,t,n)).data})}delete(e,t){return pe(this,null,function*(){return(yield this.instance.delete(e,t)).data})}getRaw(e,t){return pe(this,null,function*(){return this.instance.get(e,t)})}postForm(e,t,n){return pe(this,null,function*(){return(yield this.instance.post(e,t,ee(z({},n),{headers:ee(z({},(n==null?void 0:n.headers)||{}),{"Content-Type":"multipart/form-data"})}))).data})}requestRaw(e){return pe(this,null,function*(){return this.instance.request(e)})}}const Ce=new sz;function gl(i){return i?Array.isArray(i)?i.reduce((e,t)=>{var a,r;const n=(a=t==null?void 0:t.key)==null?void 0:a.trim(),s=(r=t==null?void 0:t.value)==null?void 0:r.trim();return n&&s!==void 0&&s!==null&&s!==""&&(e[n]=s),e},{}):Object.entries(i).reduce((e,[t,n])=>{const s=t==null?void 0:t.trim(),a=typeof n=="string"?n.trim():n;return s&&a!==void 0&&a!==null&&a!==""&&(e[s]=String(a)),e},{}):{}}function cf(i){return!i||typeof i!="object"?[]:Object.entries(i).filter(([,e])=>e!=null&&e!=="").map(([e,t])=>({key:e,value:String(t)}))}const az=i=>{if(i!=null){if(typeof i=="boolean")return i;if(typeof i=="number")return i!==0;if(typeof i=="string"){const e=i.trim().toLowerCase();if(["true","1","yes","y","on"].includes(e))return!0;if(["false","0","no","n","off"].includes(e))return!1}return!!i}},LR=i=>Array.isArray(i)?i.map(e=>{var o,c;if(!e)return null;const t=e.name||e.id||e.model;if(!t)return null;const n=e.alias||e.display_name||e.displayName,s=(o=e.priority)!=null?o:e.priority,a=(c=e["test-model"])!=null?c:e.testModel,r={name:String(t)};return n&&n!==t&&(r.alias=String(n)),s!==void 0&&(r.priority=Number(s)),a&&(r.testModel=String(a)),r}).filter(Boolean):[],v0=i=>{if(!i||typeof i!="object")return;const e=gl(i);return Object.keys(e).length?e:void 0},zv=i=>{const e=Array.isArray(i)?i:typeof i=="string"?i.split(/[\n,]/):[],t=new Set,n=[];return e.forEach(s=>{const a=String(s!=null?s:"").trim();if(!a)return;const r=a.toLowerCase();t.has(r)||(t.add(r),n.push(a))}),n},qv=i=>{if(i==null)return;const e=String(i).trim();return e||void 0},JC=i=>{var a,r,o,c;if(!i)return null;const e=(o=(r=(a=i["api-key"])!=null?a:i.apiKey)!=null?r:i.key)!=null?o:typeof i=="string"?i:"",t=String(e||"").trim();if(!t)return null;const n=(c=i["proxy-url"])!=null?c:i.proxyUrl,s=v0(i.headers);return{apiKey:t,proxyUrl:n?String(n):void 0,headers:s}},Wc=i=>{var h,p,_,y,x,v,w,k;if(!i)return null;const e=(p=(h=i["api-key"])!=null?h:i.apiKey)!=null?p:typeof i=="string"?i:"",t=String(e||"").trim();if(!t)return null;const n={apiKey:t},s=qv((_=i.prefix)!=null?_:i.prefix);s&&(n.prefix=s);const a=(y=i["base-url"])!=null?y:i.baseUrl,r=(x=i["proxy-url"])!=null?x:i.proxyUrl;a&&(n.baseUrl=String(a)),r&&(n.proxyUrl=String(r));const o=v0(i.headers);o&&(n.headers=o);const c=LR(i.models);c.length&&(n.models=c);const d=zv((k=(w=(v=i["excluded-models"])!=null?v:i.excludedModels)!=null?w:i.excluded_models)!=null?k:i.excluded_models);return d.length&&(n.excludedModels=d),n},jR=i=>{var c,d,h,p,_;if(!i)return null;let e=(c=i["api-key"])!=null?c:i.apiKey;!e&&typeof i=="string"&&(e=i);const t=String(e||"").trim();if(!t)return null;const n={apiKey:t},s=qv((d=i.prefix)!=null?d:i.prefix);s&&(n.prefix=s);const a=(p=(h=i["base-url"])!=null?h:i.baseUrl)!=null?p:i.base_url;a&&(n.baseUrl=String(a));const r=v0(i.headers);r&&(n.headers=r);const o=zv((_=i["excluded-models"])!=null?_:i.excludedModels);return o.length&&(n.excludedModels=o),n},ER=i=>{var h,p,_,y;if(!i||typeof i!="object")return null;const e=i.name||i.id,t=(h=i["base-url"])!=null?h:i.baseUrl;if(!e||!t)return null;let n=[];Array.isArray(i["api-key-entries"])?n=i["api-key-entries"].map(x=>JC(x)).filter(Boolean):Array.isArray(i["api-keys"])&&(n=i["api-keys"].map(x=>JC({"api-key":x})).filter(Boolean));const s=v0(i.headers),a=LR(i.models),r=(p=i.priority)!=null?p:i.priority,o=(_=i["test-model"])!=null?_:i.testModel,c={name:String(e),baseUrl:String(t),apiKeyEntries:n},d=qv((y=i.prefix)!=null?y:i.prefix);return d&&(c.prefix=d),s&&(c.headers=s),a.length&&(c.models=a),r!==void 0&&(c.priority=Number(r)),o&&(c.testModel=String(o)),c},rz=i=>{var n,s;if(!i||typeof i!="object")return;const e=(s=(n=i["oauth-excluded-models"])!=null?n:i.items)!=null?s:i;if(!e||typeof e!="object")return;const t={};return Object.entries(e).forEach(([a,r])=>{const o=String(a||"").trim();if(!o)return;const c=zv(r);t[o.toLowerCase()]=c}),t},DR=i=>{if(!Array.isArray(i))return[];const e=new Set,t=[];return i.forEach(n=>{var o,c,d,h;if(!n||typeof n!="object")return;const s=String((c=(o=n.from)!=null?o:n.from)!=null?c:"").trim(),a=String((h=(d=n.to)!=null?d:n.to)!=null?h:"").trim();if(!s||!a)return;const r=s.toLowerCase();e.has(r)||(e.add(r),t.push({from:s,to:a}))}),t},UR=i=>{var o,c,d,h,p,_,y,x,v;const e=(o=i==null?void 0:i.ampcode)!=null?o:i;if(!e||typeof e!="object")return;const t={},n=(d=(c=e["upstream-url"])!=null?c:e.upstreamUrl)!=null?d:e.upstream_url;n&&(t.upstreamUrl=String(n));const s=(p=(h=e["upstream-api-key"])!=null?h:e.upstreamApiKey)!=null?p:e.upstream_api_key;s&&(t.upstreamApiKey=String(s));const a=az((y=(_=e["force-model-mappings"])!=null?_:e.forceModelMappings)!=null?y:e.force_model_mappings);a!==void 0&&(t.forceModelMappings=a);const r=DR((v=(x=e["model-mappings"])!=null?x:e.modelMappings)!=null?v:e.model_mappings);return r.length&&(t.modelMappings=r),t},oz=i=>{var p,_,y,x,v,w,k,M,O,A,C,P,R,E,L,D,q,B,H,W,V,U,G,$;const e={raw:i||{}};if(!i||typeof i!="object")return e;e.debug=i.debug,e.proxyUrl=(p=i["proxy-url"])!=null?p:i.proxyUrl,e.requestRetry=(_=i["request-retry"])!=null?_:i.requestRetry;const t=(y=i["quota-exceeded"])!=null?y:i.quotaExceeded;t&&typeof t=="object"&&(e.quotaExceeded={switchProject:(x=t["switch-project"])!=null?x:t.switchProject,switchPreviewModel:(v=t["switch-preview-model"])!=null?v:t.switchPreviewModel}),e.usageStatisticsEnabled=(w=i["usage-statistics-enabled"])!=null?w:i.usageStatisticsEnabled,e.requestLog=(k=i["request-log"])!=null?k:i.requestLog,e.loggingToFile=(M=i["logging-to-file"])!=null?M:i.loggingToFile,e.logsMaxTotalSizeMb=(O=i["logs-max-total-size-mb"])!=null?O:i.logsMaxTotalSizeMb,e.wsAuth=(A=i["ws-auth"])!=null?A:i.wsAuth,e.forceModelPrefix=(C=i["force-model-prefix"])!=null?C:i.forceModelPrefix;const n=i.routing;n&&typeof n=="object"?e.routingStrategy=(P=n.strategy)!=null?P:n.strategy:e.routingStrategy=(R=i["routing-strategy"])!=null?R:i.routingStrategy,e.apiKeys=Array.isArray(i["api-keys"])?i["api-keys"].slice():i.apiKeys;const s=(L=(E=i["gemini-api-key"])!=null?E:i.geminiApiKey)!=null?L:i.geminiApiKeys;Array.isArray(s)&&(e.geminiApiKeys=s.map(ie=>jR(ie)).filter(Boolean));const a=(q=(D=i["codex-api-key"])!=null?D:i.codexApiKey)!=null?q:i.codexApiKeys;Array.isArray(a)&&(e.codexApiKeys=a.map(ie=>Wc(ie)).filter(Boolean));const r=(H=(B=i["claude-api-key"])!=null?B:i.claudeApiKey)!=null?H:i.claudeApiKeys;Array.isArray(r)&&(e.claudeApiKeys=r.map(ie=>Wc(ie)).filter(Boolean));const o=(V=(W=i["vertex-api-key"])!=null?W:i.vertexApiKey)!=null?V:i.vertexApiKeys;Array.isArray(o)&&(e.vertexApiKeys=o.map(ie=>Wc(ie)).filter(Boolean));const c=(G=(U=i["openai-compatibility"])!=null?U:i.openaiCompatibility)!=null?G:i.openAICompatibility;Array.isArray(c)&&(e.openaiCompatibility=c.map(ie=>ER(ie)).filter(Boolean));const d=UR(i.ampcode);d&&(e.ampcode=d);const h=rz(($=i["oauth-excluded-models"])!=null?$:i.oauthExcludedModels);return h&&(e.oauthExcludedModels=h),e},Ji={getConfig(){return pe(this,null,function*(){const i=yield Ce.get("/config");return oz(i)})},getRawConfig:()=>Ce.get("/config"),updateDebug:i=>Ce.put("/debug",{value:i}),updateProxyUrl:i=>Ce.put("/proxy-url",{value:i}),clearProxyUrl:()=>Ce.delete("/proxy-url"),updateRequestRetry:i=>Ce.put("/request-retry",{value:i}),updateSwitchProject:i=>Ce.put("/quota-exceeded/switch-project",{value:i}),updateSwitchPreviewModel:i=>Ce.put("/quota-exceeded/switch-preview-model",{value:i}),updateUsageStatistics:i=>Ce.put("/usage-statistics-enabled",{value:i}),updateRequestLog:i=>Ce.put("/request-log",{value:i}),updateLoggingToFile:i=>Ce.put("/logging-to-file",{value:i}),getLogsMaxTotalSizeMb(){return pe(this,null,function*(){var e,t;const i=yield Ce.get("/logs-max-total-size-mb");return(t=(e=i==null?void 0:i["logs-max-total-size-mb"])!=null?e:i==null?void 0:i.logsMaxTotalSizeMb)!=null?t:0})},updateLogsMaxTotalSizeMb:i=>Ce.put("/logs-max-total-size-mb",{value:i}),updateWsAuth:i=>Ce.put("/ws-auth",{value:i}),getForceModelPrefix(){return pe(this,null,function*(){var e,t;const i=yield Ce.get("/force-model-prefix");return(t=(e=i==null?void 0:i["force-model-prefix"])!=null?e:i==null?void 0:i.forceModelPrefix)!=null?t:!1})},updateForceModelPrefix:i=>Ce.put("/force-model-prefix",{value:i}),getRoutingStrategy(){return pe(this,null,function*(){var e,t,n;const i=yield Ce.get("/routing/strategy");return(n=(t=(e=i==null?void 0:i.strategy)!=null?e:i==null?void 0:i["routing-strategy"])!=null?t:i==null?void 0:i.routingStrategy)!=null?n:"round-robin"})},updateRoutingStrategy:i=>Ce.put("/routing/strategy",{value:i})};let $p=0,to=null;const lz=["debug","proxy-url","request-retry","quota-exceeded","usage-statistics-enabled","request-log","logging-to-file","logs-max-total-size-mb","ws-auth","force-model-prefix","routing/strategy","api-keys","ampcode","gemini-api-key","codex-api-key","claude-api-key","vertex-api-key","openai-compatibility","oauth-excluded-models"],Od=(i,e)=>{var t;if(i)switch(e){case"debug":return i.debug;case"proxy-url":return i.proxyUrl;case"request-retry":return i.requestRetry;case"quota-exceeded":return i.quotaExceeded;case"usage-statistics-enabled":return i.usageStatisticsEnabled;case"request-log":return i.requestLog;case"logging-to-file":return i.loggingToFile;case"logs-max-total-size-mb":return i.logsMaxTotalSizeMb;case"ws-auth":return i.wsAuth;case"force-model-prefix":return i.forceModelPrefix;case"routing/strategy":return i.routingStrategy;case"api-keys":return i.apiKeys;case"ampcode":return i.ampcode;case"gemini-api-key":return i.geminiApiKeys;case"codex-api-key":return i.codexApiKeys;case"claude-api-key":return i.claudeApiKeys;case"vertex-api-key":return i.vertexApiKeys;case"openai-compatibility":return i.openaiCompatibility;case"oauth-excluded-models":return i.oauthExcludedModels;default:return e?(t=i.raw)==null?void 0:t[e]:void 0}},Wt=Kl((i,e)=>({config:null,cache:new Map,loading:!1,error:null,fetchConfig:(t,n=!1)=>pe(null,null,function*(){const{cache:s,isCacheValid:a}=e(),r=t||"__full__";if(!n&&a(t)){const c=s.get(r);if(c)return c.data}if(!n&&t&&a()){const c=s.get("__full__");if(c!=null&&c.data)return Od(c.data,t)}if(to){const c=yield to.promise;return t?Od(c,t):c}i({loading:!0,error:null});const o=$p+=1;try{const c=Ji.getConfig();to={id:o,promise:c};const d=yield c,h=Date.now();if(o!==$p)return t?Od(d,t):d;const p=new Map(s);return p.set("__full__",{data:d,timestamp:h}),lz.forEach(_=>{const y=Od(d,_);y!==void 0&&p.set(_,{data:y,timestamp:h})}),i({config:d,cache:p,loading:!1}),t?Od(d,t):d}catch(c){throw o===$p&&i({error:c.message||"Failed to fetch config",loading:!1}),c}finally{(to==null?void 0:to.id)===o&&(to=null)}}),updateConfigValue:(t,n)=>{i(s=>{var o;const a=z({},((o=s.config)==null?void 0:o.raw)||{});a[t]=n;const r=ee(z({},s.config||{}),{raw:a});switch(t){case"debug":r.debug=n;break;case"proxy-url":r.proxyUrl=n;break;case"request-retry":r.requestRetry=n;break;case"quota-exceeded":r.quotaExceeded=n;break;case"usage-statistics-enabled":r.usageStatisticsEnabled=n;break;case"request-log":r.requestLog=n;break;case"logging-to-file":r.loggingToFile=n;break;case"logs-max-total-size-mb":r.logsMaxTotalSizeMb=n;break;case"ws-auth":r.wsAuth=n;break;case"force-model-prefix":r.forceModelPrefix=n;break;case"routing/strategy":r.routingStrategy=n;break;case"api-keys":r.apiKeys=n;break;case"ampcode":r.ampcode=n;break;case"gemini-api-key":r.geminiApiKeys=n;break;case"codex-api-key":r.codexApiKeys=n;break;case"claude-api-key":r.claudeApiKeys=n;break;case"vertex-api-key":r.vertexApiKeys=n;break;case"openai-compatibility":r.openaiCompatibility=n;break;case"oauth-excluded-models":r.oauthExcludedModels=n;break}return{config:r}}),e().clearCache(t)},clearCache:t=>{const{cache:n}=e(),s=new Map(n);if(t){s.delete(t),s.delete("__full__"),i({cache:s});return}else s.clear();$p+=1,to=null,i({config:null,cache:s,loading:!1,error:null})},isCacheValid:t=>{const{cache:n}=e(),s=t||"__full__",a=n.get(s);return a?Date.now()-a.timestamp{let e=(i||"").trim();return e?(e=e.replace(/\/?v0\/management\/?$/i,""),e=e.replace(/\/+$/i,""),/^https?:\/\//i.test(e)||(e=`http://${e}`),e):""},FR=()=>{try{const{protocol:i,hostname:e,port:t}=window.location,n=t?`:${t}`:"";return kh(`${i}//${e}${n}`)}catch(i){return console.warn("Failed to detect api base from location, fallback to default",i),kh(`http://localhost:${oF}`)}};let Td=null;const Ct=Kl()(Ev((i,e)=>({isAuthenticated:!1,apiBase:"",managementKey:"",rememberPassword:!1,serverVersion:null,serverBuildDate:null,connectionStatus:"disconnected",connectionError:null,restoreSession:()=>Td||(Td=pe(null,null,function*(){el.migratePlaintextKeys(["apiBase","apiUrl","managementKey"]);const t=localStorage.getItem("isLoggedIn")==="true",n=el.getItem("apiBase")||el.getItem("apiUrl",{encrypt:!0}),s=el.getItem("managementKey"),{apiBase:a,managementKey:r,rememberPassword:o}=e(),c=kh(a||n||FR()),d=r||s||"",h=o||!!r||!!s;if(i({apiBase:c,managementKey:d,rememberPassword:h}),Ce.setConfig({apiBase:c,managementKey:d}),t&&c&&d)try{return yield e().login({apiBase:c,managementKey:d,rememberPassword:h}),!0}catch(p){return console.warn("Auto login failed:",p),!1}return!1}),Td),login:t=>pe(null,null,function*(){var r,o;const n=kh(t.apiBase),s=t.managementKey.trim(),a=(o=(r=t.rememberPassword)!=null?r:e().rememberPassword)!=null?o:!1;try{i({connectionStatus:"connecting"}),Ce.setConfig({apiBase:n,managementKey:s}),yield Wt.getState().fetchConfig(void 0,!0),i({isAuthenticated:!0,apiBase:n,managementKey:s,rememberPassword:a,connectionStatus:"connected",connectionError:null}),a?localStorage.setItem("isLoggedIn","true"):localStorage.removeItem("isLoggedIn")}catch(c){throw i({connectionStatus:"error",connectionError:c.message||"Connection failed"}),c}}),logout:()=>{Td=null,Wt.getState().clearCache(),i({isAuthenticated:!1,apiBase:"",managementKey:"",serverVersion:null,serverBuildDate:null,connectionStatus:"disconnected",connectionError:null}),localStorage.removeItem("isLoggedIn")},checkAuth:()=>pe(null,null,function*(){const{managementKey:t,apiBase:n}=e();if(!t||!n)return!1;try{return Ce.setConfig({apiBase:n,managementKey:t}),yield Wt.getState().fetchConfig(),i({isAuthenticated:!0,connectionStatus:"connected"}),!0}catch(s){return i({isAuthenticated:!1,connectionStatus:"error"}),!1}}),updateServerVersion:(t,n)=>{i({serverVersion:t||null,serverBuildDate:n||null})},updateConnectionStatus:(t,n=null)=>{i({connectionStatus:t,connectionError:n})}}),{name:nR,storage:aR(()=>({getItem:i=>{const e=el.getItem(i);return e?JSON.stringify(e):null},setItem:(i,e)=>{el.setItem(i,JSON.parse(e))},removeItem:i=>{el.removeItem(i)}})),partialize:i=>ee(z({apiBase:i.apiBase},i.rememberPassword?{managementKey:i.managementKey}:{}),{rememberPassword:i.rememberPassword,serverVersion:i.serverVersion,serverBuildDate:i.serverBuildDate})}));typeof window!="undefined"&&(window.addEventListener("unauthorized",()=>{Ct.getState().logout()}),window.addEventListener("server-version-update",(i=>{const e=i.detail||{};Ct.getState().updateServerVersion(e.version||null,e.buildDate||null)})));const BR=[{id:"gpt",label:"GPT",patterns:[/gpt/i,/\bo\d\b/i,/\bo\d+\.?/i,/\bchatgpt/i]},{id:"claude",label:"Claude",patterns:[/claude/i]},{id:"gemini",label:"Gemini",patterns:[/gemini/i,/\bgai\b/i]},{id:"kimi",label:"Kimi",patterns:[/kimi/i]},{id:"qwen",label:"Qwen",patterns:[/qwen/i]},{id:"glm",label:"GLM",patterns:[/glm/i,/chatglm/i]},{id:"grok",label:"Grok",patterns:[/grok/i]},{id:"deepseek",label:"DeepSeek",patterns:[/deepseek/i]}],cz=i=>{for(const e of BR)if(e.patterns.some(t=>t.test(i)))return e.id;return null};function $C(i,{dedupe:e=!1}={}){const t=r=>{if(typeof r=="string")return{name:r};if(!r||typeof r!="object")return null;const o=r.id||r.name||r.model||r.value;if(!o)return null;const c=r.alias||r.display_name||r.displayName,d=r.description||r.note||r.comment,h={name:String(o)};return c&&c!==o&&(h.alias=String(c)),d&&(h.description=String(d)),h};let n=[];Array.isArray(i)?n=i.map(t):i&&typeof i=="object"&&(Array.isArray(i.data)?n=i.data.map(t):Array.isArray(i.models)&&(n=i.models.map(t)));const s=n.filter(Boolean);if(!e)return s;const a=new Set;return s.filter(r=>{const o=((r==null?void 0:r.name)||"").toLowerCase();return!o||a.has(o)?!1:(a.add(o),!0)})}function uz(i=[],{otherLabel:e="Other"}={}){const t=BR.map(a=>({id:a.id,label:a.label,items:[]})),n={id:"other",label:e,items:[]};i.forEach(a=>{const r=((a==null?void 0:a.name)||"").toString(),o=((a==null?void 0:a.alias)||"").toString(),c=`${r} ${o}`.toLowerCase(),d=cz(c),h=d?t.find(p=>p.id===d):null;h?h.items.push(a):n.items.push(a)});const s=t.filter(a=>a.items.length>0);return n.items.length&&s.push(n),s}const dz=i=>{if(i==null)return{bodyText:"",body:null};if(typeof i=="string"){const e=i,t=e.trim();if(!t)return{bodyText:e,body:null};try{return{bodyText:e,body:JSON.parse(t)}}catch(n){return{bodyText:e,body:e}}}try{return{bodyText:JSON.stringify(i),body:i}}catch(e){return{bodyText:String(i),body:i}}},uf=i=>{var a;const e=i.statusCode,t=i.body,n=i.bodyText;let s="";return t&&typeof t=="object"?s=((a=t==null?void 0:t.error)==null?void 0:a.message)||(t==null?void 0:t.error)||(t==null?void 0:t.message)||"":typeof t=="string"&&(s=t),!s&&n&&(s=n),e&&s?`${e} ${s}`.trim():e?`HTTP ${e}`:s||"Request failed"},df={request:(i,e)=>pe(null,null,function*(){var o,c,d,h;const t=yield Ce.post("/api-call",i,e),n=Number((c=(o=t==null?void 0:t.status_code)!=null?o:t==null?void 0:t.statusCode)!=null?c:0),s=(h=(d=t==null?void 0:t.header)!=null?d:t==null?void 0:t.headers)!=null?h:{},{bodyText:a,body:r}=dz(t==null?void 0:t.body);return{statusCode:n,header:s,bodyText:a,body:r}})},hz=i=>{let e=String(i||"").trim();return e?(e=e.replace(/\/?v0\/management\/?$/i,""),e=e.replace(/\/+$/g,""),/^https?:\/\//i.test(e)||(e=`http://${e}`),e):""},eO=i=>{const e=hz(i);return e?e.endsWith("/v1")?`${e}/models`:`${e}/v1/models`:""},Wx={fetchModels(n,s){return pe(this,arguments,function*(i,e,t={}){var d,h,p,_;const a=eO(i);if(!a)throw new Error("Invalid base url");const r=z({},t);e&&(r.Authorization=`Bearer ${e}`);const o=yield li.get(a,{headers:Object.keys(r).length?r:void 0}),c=(_=(p=(d=o.data)==null?void 0:d.data)!=null?p:(h=o.data)==null?void 0:h.models)!=null?_:o.data;return $C(c,{dedupe:!0})})},fetchModelsViaApiCall(n,s){return pe(this,arguments,function*(i,e,t={}){var h;const a=eO(i);if(!a)throw new Error("Invalid base url");const r=z({},t),o=!!(r.Authorization||r.authorization);e&&!o&&(r.Authorization=`Bearer ${e}`);const c=yield df.request({method:"GET",url:a,header:Object.keys(r).length?r:void 0});if(c.statusCode<200||c.statusCode>=300)throw new Error(uf(c));const d=(h=c.body)!=null?h:c.bodyText;return $C(d,{dedupe:!0})})}},_l=Kl((i,e)=>({models:[],loading:!1,error:null,cache:null,fetchModels:(t,n,s=!1)=>pe(null,null,function*(){const{cache:a,isCacheValid:r}=e();if(!s&&r(t)&&a)return i({models:a.data,error:null}),a.data;i({loading:!0,error:null});try{const o=yield Wx.fetchModels(t,n),c=Date.now();return i({models:o,loading:!1,cache:{data:o,timestamp:c,apiBase:t}}),o}catch(o){const c=(o==null?void 0:o.message)||"Failed to fetch models";throw i({error:c,loading:!1,models:[]}),o}}),clearCache:()=>{i({cache:null,models:[]})},isCacheValid:t=>{const{cache:n}=e();return!n||n.apiBase!==t?!1:Date.now()-n.timestamptypeof i=="function"?i(e):i,Xx=Kl(i=>({antigravityQuota:{},codexQuota:{},geminiCliQuota:{},setAntigravityQuota:e=>i(t=>({antigravityQuota:A1(e,t.antigravityQuota)})),setCodexQuota:e=>i(t=>({codexQuota:A1(e,t.codexQuota)})),setGeminiCliQuota:e=>i(t=>({geminiCliQuota:A1(e,t.geminiCliQuota)})),clearQuotaCache:()=>i({antigravityQuota:{},codexQuota:{},geminiCliQuota:{}})}));function fz(){var U,G;const{t:i}=rt(),e=Ov(),t=Vs(),{showNotification:n}=Zn(),s=wh($=>$.language),a=wh($=>$.toggleLanguage),r=Ct($=>$.isAuthenticated),o=Ct($=>$.login),c=Ct($=>$.restoreSession),d=Ct($=>$.apiBase),h=Ct($=>$.managementKey),p=Ct($=>$.rememberPassword),[_,y]=N.useState(""),[x,v]=N.useState(""),[w,k]=N.useState(!1),[M,O]=N.useState(!1),[A,C]=N.useState(!1),[P,R]=N.useState(!1),[E,L]=N.useState(!0),[D,q]=N.useState(""),B=N.useMemo(()=>FR(),[]),H=i(s==="zh-CN"?"language.english":"language.chinese");if(N.useEffect(()=>{pe(null,null,function*(){try{(yield c())||(y(d||B),v(h||""),C(p||!!h))}finally{L(!1)}})},[B,c,d,h,p]),r){const $=((G=(U=t.state)==null?void 0:U.from)==null?void 0:G.pathname)||"/";return g.jsx(Nv,{to:$,replace:!0})}const W=()=>pe(null,null,function*(){if(!x.trim()){q(i("login.error_required"));return}const $=_?kh(_):B;R(!0),q("");try{yield o({apiBase:$,managementKey:x.trim(),rememberPassword:A}),n(i("common.connected_status"),"success"),e("/",{replace:!0})}catch(ie){const ue=(ie==null?void 0:ie.message)||i("login.error_invalid");q(ue),n(`${i("notification.login_failed")}: ${ue}`,"error")}finally{R(!1)}}),V=N.useCallback($=>{$.key==="Enter"&&!P&&($.preventDefault(),W())},[P,W]);return g.jsx("div",{className:"login-page",children:g.jsxs("div",{className:"login-card",children:[g.jsxs("div",{className:"login-header",children:[g.jsxs("div",{className:"login-title-row",children:[g.jsx("div",{className:"title",children:i("title.login")}),g.jsx(ye,{type:"button",variant:"ghost",size:"sm",className:"login-language-btn",onClick:a,title:i("language.switch"),"aria-label":i("language.switch"),children:H})]}),g.jsx("div",{className:"subtitle",children:i("login.subtitle")})]}),g.jsxs("div",{className:"connection-box",children:[g.jsx("div",{className:"label",children:i("login.connection_current")}),g.jsx("div",{className:"value",children:_||B}),g.jsx("div",{className:"hint",children:i("login.connection_auto_hint")})]}),g.jsxs("div",{className:"toggle-advanced",children:[g.jsx("input",{id:"custom-connection-toggle",type:"checkbox",checked:w,onChange:$=>k($.target.checked)}),g.jsx("label",{htmlFor:"custom-connection-toggle",children:i("login.custom_connection_label")})]}),w&&g.jsx(et,{label:i("login.custom_connection_label"),placeholder:i("login.custom_connection_placeholder"),value:_,onChange:$=>y($.target.value),hint:i("login.custom_connection_hint")}),g.jsx(et,{autoFocus:!0,label:i("login.management_key_label"),placeholder:i("login.management_key_placeholder"),type:M?"text":"password",value:x,onChange:$=>v($.target.value),onKeyDown:V,rightElement:g.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>O($=>!$),"aria-label":M?i("login.hide_key",{defaultValue:"隐藏密钥"}):i("login.show_key",{defaultValue:"显示密钥"}),title:M?i("login.hide_key",{defaultValue:"隐藏密钥"}):i("login.show_key",{defaultValue:"显示密钥"}),children:M?g.jsx(eR,{size:16}):g.jsx(GU,{size:16})})}),g.jsxs("div",{className:"toggle-advanced",children:[g.jsx("input",{id:"remember-password-toggle",type:"checkbox",checked:A,onChange:$=>C($.target.checked)}),g.jsx("label",{htmlFor:"remember-password-toggle",children:i("login.remember_password_label")})]}),g.jsx(ye,{fullWidth:!0,onClick:W,loading:P,children:i(P?"login.submitting":"login.submit_button")}),D&&g.jsx("div",{className:"error-box",children:D}),E&&g.jsxs("div",{className:"connection-box",children:[g.jsx("div",{className:"label",children:i("auto_login.title")}),g.jsx("div",{className:"value",children:i("auto_login.message")})]})]})})}const tO=300;function pz(){const{notifications:i,removeNotification:e}=Zn(),[t,n]=N.useState([]),s=N.useRef([]);N.useEffect(()=>{const r=s.current,o=new Set(r.map(p=>p.id)),c=new Set(i.map(p=>p.id)),d=i.filter(p=>!o.has(p.id)),h=new Set(r.filter(p=>!c.has(p.id)).map(p=>p.id));n(p=>{let _=p.map(y=>h.has(y.id)?ee(z({},y),{isExiting:!0}):y);return d.forEach(y=>{_.find(x=>x.id===y.id)||_.push(ee(z({},y),{isExiting:!1}))}),_=_.filter(y=>c.has(y.id)||y.isExiting),_}),h.size>0&&setTimeout(()=>{n(p=>p.filter(_=>!h.has(_.id)))},tO),s.current=i},[i]);const a=r=>{n(o=>o.map(c=>c.id===r?ee(z({},c),{isExiting:!0}):c)),setTimeout(()=>{e(r)},tO)};return t.length?g.jsx("div",{className:"notification-container",children:t.map(r=>g.jsxs("div",{className:`notification ${r.type} ${r.isExiting?"exiting":"entering"}`,children:[g.jsx("div",{className:"message",children:r.message}),g.jsx("button",{className:"close-btn",onClick:()=>a(r.id),"aria-label":"Close",children:g.jsx(Hl,{size:16})})]},r.id))}):null}const mz=400;function gz({onFinish:i,fadeOut:e=!1}){return N.useEffect(()=>{if(!e)return;const t=setTimeout(()=>{i()},mz);return()=>{clearTimeout(t)}},[e,i]),g.jsx("div",{className:`splash-screen ${e?"fade-out":""}`,children:g.jsxs("div",{className:"splash-content",children:[g.jsx("img",{src:mg,alt:"CPAMC",className:"splash-logo"}),g.jsx("h1",{className:"splash-title",children:"CLI Proxy API"}),g.jsx("p",{className:"splash-subtitle",children:"Management Center"}),g.jsx("div",{className:"splash-loader",children:g.jsx("div",{className:"splash-loader-bar"})})]})})}const _z=350,Sg="modal-open";let th=0;const yz=()=>{var i,e;typeof document!="undefined"&&(th===0&&((i=document.body)==null||i.classList.add(Sg),(e=document.documentElement)==null||e.classList.add(Sg)),th+=1)},xz=()=>{var i,e;typeof document!="undefined"&&(th=Math.max(0,th-1),th===0&&((i=document.body)==null||i.classList.remove(Sg),(e=document.documentElement)==null||e.classList.remove(Sg)))};function zn({open:i,title:e,onClose:t,footer:n,width:s=520,children:a}){const[r,o]=N.useState(!1),[c,d]=N.useState(!1),h=N.useRef(null),p=N.useCallback(k=>{h.current===null&&(d(!0),h.current=window.setTimeout(()=>{o(!1),d(!1),h.current=null,k&&t()},_z))},[t]);N.useEffect(()=>{let k=!1;return i?(h.current!==null&&(window.clearTimeout(h.current),h.current=null),queueMicrotask(()=>{k||(o(!0),d(!1))})):r&&queueMicrotask(()=>{k||p(!1)}),()=>{k=!0}},[i,r,p]);const _=N.useCallback(()=>{p(!0)},[p]);N.useEffect(()=>()=>{h.current!==null&&window.clearTimeout(h.current)},[]);const y=i||r;if(N.useEffect(()=>{if(y)return yz(),()=>xz()},[y]),!i&&!r)return null;const x=`modal-overlay ${c?"modal-overlay-closing":"modal-overlay-entering"}`,v=`modal ${c?"modal-closing":"modal-entering"}`,w=g.jsx("div",{className:x,children:g.jsxs("div",{className:v,style:{width:s},role:"dialog","aria-modal":"true",children:[g.jsx("button",{className:"modal-close-floating",onClick:_,"aria-label":"Close",children:g.jsx(Hl,{size:20})}),g.jsx("div",{className:"modal-header",children:g.jsx("div",{className:"modal-title",children:e})}),g.jsx("div",{className:"modal-body",children:a}),n&&g.jsx("div",{className:"modal-footer",children:n})]})});return typeof document=="undefined"?w:eU.createPortal(w,document.body)}function Sn({checked:i,onChange:e,label:t,disabled:n=!1,labelPosition:s="right"}){const a=o=>{e(o.target.checked)},r=["switch",s==="left"?"switch-label-left":""].filter(Boolean).join(" ");return g.jsxs("label",{className:r,children:[g.jsx("input",{type:"checkbox",checked:i,onChange:a,disabled:n}),g.jsx("span",{className:"track",children:g.jsx("span",{className:"thumb"})}),t&&g.jsx("span",{className:"label",children:t})]})}function rr(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function zR(i,e){i.prototype=Object.create(e.prototype),i.prototype.constructor=i,i.__proto__=e}var ps={autoSleep:120,force3D:"auto",nullTargetWarn:1,units:{lineHeight:""}},au={duration:.5,overwrite:!1,delay:0},Hv,sn,$t,Ls=1e8,Kt=1/Ls,Gx=Math.PI*2,bz=Gx/4,vz=0,qR=Math.sqrt,Sz=Math.cos,wz=Math.sin,Ii=function(e){return typeof e=="string"},hi=function(e){return typeof e=="function"},yr=function(e){return typeof e=="number"},Kv=function(e){return typeof e=="undefined"},Pa=function(e){return typeof e=="object"},In=function(e){return e!==!1},Vv=function(){return typeof window!="undefined"},em=function(e){return hi(e)||Ii(e)},HR=typeof ArrayBuffer=="function"&&ArrayBuffer.isView||function(){},fn=Array.isArray,kz=/random\([^)]+\)/g,Az=/,\s*/g,iO=/(?:-?\.?\d|\.)+/gi,KR=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,Bc=/[-+=.]*\d+[.e-]*\d*[a-z%]*/g,C1=/[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,VR=/[+-]=-?[.\d]+/,Cz=/[^,'"\[\]\s]+/gi,Oz=/^[+\-=e\s\d]*\d+[.\d]*([a-z]*|%)\s*$/i,ri,va,Qx,Iv,gs={},wg={},IR,WR=function(e){return(wg=ru(e,gs))&&Qn},Wv=function(e,t){return console.warn("Invalid property",e,"set to",t,"Missing plugin? gsap.registerPlugin()")},Ah=function(e,t){return!t&&console.warn(e)},XR=function(e,t){return e&&(gs[e]=t)&&wg&&(wg[e]=t)||gs},Ch=function(){return 0},Tz={suppressEvents:!0,isStart:!0,kill:!1},Qm={suppressEvents:!0,kill:!1},Mz={suppressEvents:!0},Xv={},yo=[],Yx={},GR,cs={},O1={},nO=30,Ym=[],Gv="",Qv=function(e){var t=e[0],n,s;if(Pa(t)||hi(t)||(e=[e]),!(n=(t._gsap||{}).harness)){for(s=Ym.length;s--&&!Ym[s].targetTest(t););n=Ym[s]}for(s=e.length;s--;)e[s]&&(e[s]._gsap||(e[s]._gsap=new yP(e[s],n)))||e.splice(s,1);return e},Al=function(e){return e._gsap||Qv(js(e))[0]._gsap},QR=function(e,t,n){return(n=e[t])&&hi(n)?e[t]():Kv(n)&&e.getAttribute&&e.getAttribute(t)||n},Wn=function(e,t){return(e=e.split(",")).forEach(t)||e},yi=function(e){return Math.round(e*1e5)/1e5||0},ai=function(e){return Math.round(e*1e7)/1e7||0},Xc=function(e,t){var n=t.charAt(0),s=parseFloat(t.substr(2));return e=parseFloat(e),n==="+"?e+s:n==="-"?e-s:n==="*"?e*s:e/s},Nz=function(e,t){for(var n=t.length,s=0;e.indexOf(t[s])<0&&++so;)r=r._prev;return r?(t._next=r._next,r._next=t):(t._next=e[n],e[n]=t),t._next?t._next._prev=t:e[s]=t,t._prev=r,t.parent=t._dp=e,t},S0=function(e,t,n,s){n===void 0&&(n="_first"),s===void 0&&(s="_last");var a=t._prev,r=t._next;a?a._next=r:e[n]===t&&(e[n]=r),r?r._prev=a:e[s]===t&&(e[s]=a),t._next=t._prev=t.parent=null},So=function(e,t){e.parent&&(!t||e.parent.autoRemoveChildren)&&e.parent.remove&&e.parent.remove(e),e._act=0},Cl=function(e,t){if(e&&(!t||t._end>e._dur||t._start<0))for(var n=e;n;)n._dirty=1,n=n.parent;return e},Lz=function(e){for(var t=e.parent;t&&t.parent;)t._dirty=1,t.totalDuration(),t=t.parent;return e},Zx=function(e,t,n,s){return e._startAt&&(sn?e._startAt.revert(Qm):e.vars.immediateRender&&!e.vars.autoRevert||e._startAt.render(t,!0,s))},jz=function i(e){return!e||e._ts&&i(e.parent)},aO=function(e){return e._repeat?ou(e._tTime,e=e.duration()+e._rDelay)*e:0},ou=function(e,t){var n=Math.floor(e=ai(e/t));return e&&n===e?n-1:n},Cg=function(e,t){return(e-t._start)*t._ts+(t._ts>=0?0:t._dirty?t.totalDuration():t._tDur)},w0=function(e){return e._end=ai(e._start+(e._tDur/Math.abs(e._ts||e._rts||Kt)||0))},k0=function(e,t){var n=e._dp;return n&&n.smoothChildTiming&&e._ts&&(e._start=ai(n._time-(e._ts>0?t/e._ts:((e._dirty?e.totalDuration():e._tDur)-t)/-e._ts)),w0(e),n._dirty||Cl(n,e)),e},eP=function(e,t){var n;if((t._time||!t._dur&&t._initted||t._startKt)&&t.render(n,!0)),Cl(e,t)._dp&&e._initted&&e._time>=e._dur&&e._ts){if(e._dur=0&&n.totalTime(n._tTime),n=n._dp;e._zTime=-Kt}},wa=function(e,t,n,s){return t.parent&&So(t),t._start=ai((yr(n)?n:n||e!==ri?Rs(e,n,t):e._time)+t._delay),t._end=ai(t._start+(t.totalDuration()/Math.abs(t.timeScale())||0)),$R(e,t,"_first","_last",e._sort?"_start":0),Jx(t)||(e._recent=t),s||eP(e,t),e._ts<0&&k0(e,e._tTime),e},tP=function(e,t){return(gs.ScrollTrigger||Wv("scrollTrigger",t))&&gs.ScrollTrigger.create(t,e)},iP=function(e,t,n,s,a){if(Jv(e,t,a),!e._initted)return 1;if(!n&&e._pt&&!sn&&(e._dur&&e.vars.lazy!==!1||!e._dur&&e.vars.lazy)&&GR!==us.frame)return yo.push(e),e._lazy=[a,s],1},Ez=function i(e){var t=e.parent;return t&&t._ts&&t._initted&&!t._lock&&(t.rawTime()<0||i(t))},Jx=function(e){var t=e.data;return t==="isFromStart"||t==="isStart"},Dz=function(e,t,n,s){var a=e.ratio,r=t<0||!t&&(!e._start&&Ez(e)&&!(!e._initted&&Jx(e))||(e._ts<0||e._dp._ts<0)&&!Jx(e))?0:1,o=e._rDelay,c=0,d,h,p;if(o&&e._repeat&&(c=hf(0,e._tDur,t),h=ou(c,o),e._yoyo&&h&1&&(r=1-r),h!==ou(e._tTime,o)&&(a=1-r,e.vars.repeatRefresh&&e._initted&&e.invalidate())),r!==a||sn||s||e._zTime===Kt||!t&&e._zTime){if(!e._initted&&iP(e,t,s,n,c))return;for(p=e._zTime,e._zTime=t||(n?Kt:0),n||(n=t&&!p),e.ratio=r,e._from&&(r=1-r),e._time=0,e._tTime=c,d=e._pt;d;)d.r(r,d.d),d=d._next;t<0&&Zx(e,t,n,!0),e._onUpdate&&!n&&ds(e,"onUpdate"),c&&e._repeat&&!n&&e.parent&&ds(e,"onRepeat"),(t>=e._tDur||t<0)&&e.ratio===r&&(r&&So(e,1),!n&&!sn&&(ds(e,r?"onComplete":"onReverseComplete",!0),e._prom&&e._prom()))}else e._zTime||(e._zTime=t)},Uz=function(e,t,n){var s;if(n>t)for(s=e._first;s&&s._start<=n;){if(s.data==="isPause"&&s._start>t)return s;s=s._next}else for(s=e._last;s&&s._start>=n;){if(s.data==="isPause"&&s._start0&&!s&&k0(e,e._tTime=e._tDur*o),e.parent&&w0(e),n||Cl(e.parent,e),e},rO=function(e){return e instanceof kn?Cl(e):lu(e,e._dur)},Fz={_start:0,endTime:Ch,totalDuration:Ch},Rs=function i(e,t,n){var s=e.labels,a=e._recent||Fz,r=e.duration()>=Ls?a.endTime(!1):e._dur,o,c,d;return Ii(t)&&(isNaN(t)||t in s)?(c=t.charAt(0),d=t.substr(-1)==="%",o=t.indexOf("="),c==="<"||c===">"?(o>=0&&(t=t.replace(/=/,"")),(c==="<"?a._start:a.endTime(a._repeat>=0))+(parseFloat(t.substr(1))||0)*(d?(o<0?a:n).totalDuration()/100:1)):o<0?(t in s||(s[t]=r),s[t]):(c=parseFloat(t.charAt(o-1)+t.substr(o+1)),d&&n&&(c=c/100*(fn(n)?n[0]:n).totalDuration()),o>1?i(e,t.substr(0,o-1),n)+c:r+c)):t==null?r:+t},nh=function(e,t,n){var s=yr(t[1]),a=(s?2:1)+(e<2?0:1),r=t[a],o,c;if(s&&(r.duration=t[1]),r.parent=n,e){for(o=r,c=n;c&&!("immediateRender"in o);)o=c.vars.defaults||{},c=In(c.vars.inherit)&&c.parent;r.immediateRender=In(o.immediateRender),e<2?r.runBackwards=1:r.startAt=t[a-1]}return new Ni(t[0],r,t[a+1])},Ro=function(e,t){return e||e===0?t(e):t},hf=function(e,t,n){return nt?t:n},un=function(e,t){return!Ii(e)||!(t=Oz.exec(e))?"":t[1]},Bz=function(e,t,n){return Ro(n,function(s){return hf(e,t,s)})},$x=[].slice,nP=function(e,t){return e&&Pa(e)&&"length"in e&&(!t&&!e.length||e.length-1 in e&&Pa(e[0]))&&!e.nodeType&&e!==va},zz=function(e,t,n){return n===void 0&&(n=[]),e.forEach(function(s){var a;return Ii(s)&&!t||nP(s,1)?(a=n).push.apply(a,js(s)):n.push(s)})||n},js=function(e,t,n){return $t&&!t&&$t.selector?$t.selector(e):Ii(e)&&!n&&(Qx||!cu())?$x.call((t||Iv).querySelectorAll(e),0):fn(e)?zz(e,n):nP(e)?$x.call(e,0):e?[e]:[]},eb=function(e){return e=js(e)[0]||Ah("Invalid scope")||{},function(t){var n=e.current||e.nativeElement||e;return js(t,n.querySelectorAll?n:n===e?Ah("Invalid scope")||Iv.createElement("div"):e)}},sP=function(e){return e.sort(function(){return .5-Math.random()})},aP=function(e){if(hi(e))return e;var t=Pa(e)?e:{each:e},n=Ol(t.ease),s=t.from||0,a=parseFloat(t.base)||0,r={},o=s>0&&s<1,c=isNaN(s)||o,d=t.axis,h=s,p=s;return Ii(s)?h=p={center:.5,edges:.5,end:1}[s]||0:!o&&c&&(h=s[0],p=s[1]),function(_,y,x){var v=(x||t).length,w=r[v],k,M,O,A,C,P,R,E,L;if(!w){if(L=t.grid==="auto"?0:(t.grid||[1,Ls])[1],!L){for(R=-Ls;R<(R=x[L++].getBoundingClientRect().left)&&LR&&(R=C),Cv?v-1:d?d==="y"?v/L:L:Math.max(L,v/L))||0)*(s==="edges"?-1:1),w.b=v<0?a-v:a,w.u=un(t.amount||t.each)||0,n=n&&v<0?mP(n):n}return v=(w[_]-w.min)/w.max||0,ai(w.b+(n?n(v):v)*w.v)+w.u}},tb=function(e){var t=Math.pow(10,((e+"").split(".")[1]||"").length);return function(n){var s=ai(Math.round(parseFloat(n)/e)*e*t);return(s-s%1)/t+(yr(n)?0:un(n))}},rP=function(e,t){var n=fn(e),s,a;return!n&&Pa(e)&&(s=n=e.radius||Ls,e.values?(e=js(e.values),(a=!yr(e[0]))&&(s*=s)):e=tb(e.increment)),Ro(t,n?hi(e)?function(r){return a=e(r),Math.abs(a-r)<=s?a:r}:function(r){for(var o=parseFloat(a?r.x:r),c=parseFloat(a?r.y:0),d=Ls,h=0,p=e.length,_,y;p--;)a?(_=e[p].x-o,y=e[p].y-c,_=_*_+y*y):_=Math.abs(e[p]-o),_s?a-r:r)})},Oh=function(e){return e.replace(kz,function(t){var n=t.indexOf("[")+1,s=t.substring(n||7,n?t.indexOf("]"):t.length-1).split(Az);return oP(n?s:+s[0],n?0:+s[1],+s[2]||1e-5)})},cP=function(e,t,n,s,a){var r=t-e,o=s-n;return Ro(a,function(c){return n+((c-e)/r*o||0)})},Wz=function i(e,t,n,s){var a=isNaN(e+t)?0:function(y){return(1-y)*e+y*t};if(!a){var r=Ii(e),o={},c,d,h,p,_;if(n===!0&&(s=1)&&(n=null),r)e={p:e},t={p:t};else if(fn(e)&&!fn(t)){for(h=[],p=e.length,_=p-2,d=1;d(o=Math.abs(o))&&(c=r,a=o);return c},ds=function(e,t,n){var s=e.vars,a=s[t],r=$t,o=e._ctx,c,d,h;if(a)return c=s[t+"Params"],d=s.callbackScope||e,n&&yo.length&&kg(),o&&($t=o),h=c?a.apply(d,c):a.call(d),$t=r,h},Kd=function(e){return So(e),e.scrollTrigger&&e.scrollTrigger.kill(!!sn),e.progress()<1&&ds(e,"onInterrupt"),e},zc,uP=[],dP=function(e){if(e)if(e=!e.name&&e.default||e,Vv()||e.headless){var t=e.name,n=hi(e),s=t&&!n&&e.init?function(){this._props=[]}:e,a={init:Ch,render:t2,add:Zv,kill:l7,modifier:o7,rawVars:0},r={targetTest:0,get:0,getSetter:e2,aliases:{},register:0};if(cu(),e!==s){if(cs[t])return;_s(s,_s(Ag(e,a),r)),ru(s.prototype,ru(a,Ag(e,r))),cs[s.prop=t]=s,e.targetTest&&(Ym.push(s),Xv[t]=1),t=(t==="css"?"CSS":t.charAt(0).toUpperCase()+t.substr(1))+"Plugin"}XR(t,s),e.register&&e.register(Qn,s,Xn)}else uP.push(e)},qt=255,Vd={aqua:[0,qt,qt],lime:[0,qt,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,qt],navy:[0,0,128],white:[qt,qt,qt],olive:[128,128,0],yellow:[qt,qt,0],orange:[qt,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[qt,0,0],pink:[qt,192,203],cyan:[0,qt,qt],transparent:[qt,qt,qt,0]},T1=function(e,t,n){return e+=e<0?1:e>1?-1:0,(e*6<1?t+(n-t)*e*6:e<.5?n:e*3<2?t+(n-t)*(2/3-e)*6:t)*qt+.5|0},hP=function(e,t,n){var s=e?yr(e)?[e>>16,e>>8&qt,e&qt]:0:Vd.black,a,r,o,c,d,h,p,_,y,x;if(!s){if(e.substr(-1)===","&&(e=e.substr(0,e.length-1)),Vd[e])s=Vd[e];else if(e.charAt(0)==="#"){if(e.length<6&&(a=e.charAt(1),r=e.charAt(2),o=e.charAt(3),e="#"+a+a+r+r+o+o+(e.length===5?e.charAt(4)+e.charAt(4):"")),e.length===9)return s=parseInt(e.substr(1,6),16),[s>>16,s>>8&qt,s&qt,parseInt(e.substr(7),16)/255];e=parseInt(e.substr(1),16),s=[e>>16,e>>8&qt,e&qt]}else if(e.substr(0,3)==="hsl"){if(s=x=e.match(iO),!t)c=+s[0]%360/360,d=+s[1]/100,h=+s[2]/100,r=h<=.5?h*(d+1):h+d-h*d,a=h*2-r,s.length>3&&(s[3]*=1),s[0]=T1(c+1/3,a,r),s[1]=T1(c,a,r),s[2]=T1(c-1/3,a,r);else if(~e.indexOf("="))return s=e.match(KR),n&&s.length<4&&(s[3]=1),s}else s=e.match(iO)||Vd.transparent;s=s.map(Number)}return t&&!x&&(a=s[0]/qt,r=s[1]/qt,o=s[2]/qt,p=Math.max(a,r,o),_=Math.min(a,r,o),h=(p+_)/2,p===_?c=d=0:(y=p-_,d=h>.5?y/(2-p-_):y/(p+_),c=p===a?(r-o)/y+(re||k<0)&&(n+=k-t),s+=k,C=s-n,O=C-r,(O>0||M)&&(P=++p.frame,_=C-p.time*1e3,p.time=C=C/1e3,r+=O+(O>=a?4:a-O),A=1),M||(c=d(v)),A)for(y=0;y=k&&y--},_listeners:o},p})(),cu=function(){return!Th&&us.wake()},ht={},Gz=/^[\d.\-M][\d.\-,\s]/,Qz=/["']/g,Yz=function(e){for(var t={},n=e.substr(1,e.length-3).split(":"),s=n[0],a=1,r=n.length,o,c,d;a1&&n.config?n.config.apply(null,~e.indexOf("{")?[Yz(t[1])]:Zz(e).split(",").map(ZR)):ht._CE&&Gz.test(e)?ht._CE("",e):n},mP=function(e){return function(t){return 1-e(1-t)}},gP=function i(e,t){for(var n=e._first,s;n;)n instanceof kn?i(n,t):n.vars.yoyoEase&&(!n._yoyo||!n._repeat)&&n._yoyo!==t&&(n.timeline?i(n.timeline,t):(s=n._ease,n._ease=n._yEase,n._yEase=s,n._yoyo=t)),n=n._next},Ol=function(e,t){return e&&(hi(e)?e:ht[e]||Jz(e))||t},Vl=function(e,t,n,s){n===void 0&&(n=function(c){return 1-t(1-c)}),s===void 0&&(s=function(c){return c<.5?t(c*2)/2:1-t((1-c)*2)/2});var a={easeIn:t,easeOut:n,easeInOut:s},r;return Wn(e,function(o){ht[o]=gs[o]=a,ht[r=o.toLowerCase()]=n;for(var c in a)ht[r+(c==="easeIn"?".in":c==="easeOut"?".out":".inOut")]=ht[o+"."+c]=a[c]}),a},_P=function(e){return function(t){return t<.5?(1-e(1-t*2))/2:.5+e((t-.5)*2)/2}},M1=function i(e,t,n){var s=t>=1?t:1,a=(n||(e?.3:.45))/(t<1?t:1),r=a/Gx*(Math.asin(1/s)||0),o=function(h){return h===1?1:s*Math.pow(2,-10*h)*wz((h-r)*a)+1},c=e==="out"?o:e==="in"?function(d){return 1-o(1-d)}:_P(o);return a=Gx/a,c.config=function(d,h){return i(e,d,h)},c},N1=function i(e,t){t===void 0&&(t=1.70158);var n=function(r){return r?--r*r*((t+1)*r+t)+1:0},s=e==="out"?n:e==="in"?function(a){return 1-n(1-a)}:_P(n);return s.config=function(a){return i(e,a)},s};Wn("Linear,Quad,Cubic,Quart,Quint,Strong",function(i,e){var t=e<5?e+1:e;Vl(i+",Power"+(t-1),e?function(n){return Math.pow(n,t)}:function(n){return n},function(n){return 1-Math.pow(1-n,t)},function(n){return n<.5?Math.pow(n*2,t)/2:1-Math.pow((1-n)*2,t)/2})});ht.Linear.easeNone=ht.none=ht.Linear.easeIn;Vl("Elastic",M1("in"),M1("out"),M1());(function(i,e){var t=1/e,n=2*t,s=2.5*t,a=function(o){return o0?n+(n+this._rDelay)*this._repeat:n):this.totalDuration()&&this._dur},e.totalDuration=function(n){return arguments.length?(this._dirty=0,lu(this,this._repeat<0?n:(n-this._repeat*this._rDelay)/(this._repeat+1))):this._tDur},e.totalTime=function(n,s){if(cu(),!arguments.length)return this._tTime;var a=this._dp;if(a&&a.smoothChildTiming&&this._ts){for(k0(this,n),!a._dp||a.parent||eP(a,this);a&&a.parent;)a.parent._time!==a._start+(a._ts>=0?a._tTime/a._ts:(a.totalDuration()-a._tTime)/-a._ts)&&a.totalTime(a._tTime,!0),a=a.parent;!this.parent&&this._dp.autoRemoveChildren&&(this._ts>0&&n0||!this._tDur&&!n)&&wa(this._dp,this,this._start-this._delay)}return(this._tTime!==n||!this._dur&&!s||this._initted&&Math.abs(this._zTime)===Kt||!this._initted&&this._dur&&n||!n&&!this._initted&&(this.add||this._ptLookup))&&(this._ts||(this._pTime=n),YR(this,n,s)),this},e.time=function(n,s){return arguments.length?this.totalTime(Math.min(this.totalDuration(),n+aO(this))%(this._dur+this._rDelay)||(n?this._dur:0),s):this._time},e.totalProgress=function(n,s){return arguments.length?this.totalTime(this.totalDuration()*n,s):this.totalDuration()?Math.min(1,this._tTime/this._tDur):this.rawTime()>=0&&this._initted?1:0},e.progress=function(n,s){return arguments.length?this.totalTime(this.duration()*(this._yoyo&&!(this.iteration()&1)?1-n:n)+aO(this),s):this.duration()?Math.min(1,this._time/this._dur):this.rawTime()>0?1:0},e.iteration=function(n,s){var a=this.duration()+this._rDelay;return arguments.length?this.totalTime(this._time+(n-1)*a,s):this._repeat?ou(this._tTime,a)+1:1},e.timeScale=function(n,s){if(!arguments.length)return this._rts===-Kt?0:this._rts;if(this._rts===n)return this;var a=this.parent&&this._ts?Cg(this.parent._time,this):this._tTime;return this._rts=+n||0,this._ts=this._ps||n===-Kt?0:this._rts,this.totalTime(hf(-Math.abs(this._delay),this.totalDuration(),a),s!==!1),w0(this),Lz(this)},e.paused=function(n){return arguments.length?(this._ps!==n&&(this._ps=n,n?(this._pTime=this._tTime||Math.max(-this._delay,this.rawTime()),this._ts=this._act=0):(cu(),this._ts=this._rts,this.totalTime(this.parent&&!this.parent.smoothChildTiming?this.rawTime():this._tTime||this._pTime,this.progress()===1&&Math.abs(this._zTime)!==Kt&&(this._tTime-=Kt)))),this):this._ps},e.startTime=function(n){if(arguments.length){this._start=ai(n);var s=this.parent||this._dp;return s&&(s._sort||!this.parent)&&wa(s,this,this._start-this._delay),this}return this._start},e.endTime=function(n){return this._start+(In(n)?this.totalDuration():this.duration())/Math.abs(this._ts||1)},e.rawTime=function(n){var s=this.parent||this._dp;return s?n&&(!this._ts||this._repeat&&this._time&&this.totalProgress()<1)?this._tTime%(this._dur+this._rDelay):this._ts?Cg(s.rawTime(n),this):this._tTime:this._tTime},e.revert=function(n){n===void 0&&(n=Mz);var s=sn;return sn=n,Yv(this)&&(this.timeline&&this.timeline.revert(n),this.totalTime(-.01,n.suppressEvents)),this.data!=="nested"&&n.kill!==!1&&this.kill(),sn=s,this},e.globalTime=function(n){for(var s=this,a=arguments.length?n:s.rawTime();s;)a=s._start+a/(Math.abs(s._ts)||1),s=s._dp;return!this.parent&&this._sat?this._sat.globalTime(n):a},e.repeat=function(n){return arguments.length?(this._repeat=n===1/0?-2:n,rO(this)):this._repeat===-2?1/0:this._repeat},e.repeatDelay=function(n){if(arguments.length){var s=this._time;return this._rDelay=n,rO(this),s?this.time(s):this}return this._rDelay},e.yoyo=function(n){return arguments.length?(this._yoyo=n,this):this._yoyo},e.seek=function(n,s){return this.totalTime(Rs(this,n),In(s))},e.restart=function(n,s){return this.play().totalTime(n?-this._delay:0,In(s)),this._dur||(this._zTime=-Kt),this},e.play=function(n,s){return n!=null&&this.seek(n,s),this.reversed(!1).paused(!1)},e.reverse=function(n,s){return n!=null&&this.seek(n||this.totalDuration(),s),this.reversed(!0).paused(!1)},e.pause=function(n,s){return n!=null&&this.seek(n,s),this.paused(!0)},e.resume=function(){return this.paused(!1)},e.reversed=function(n){return arguments.length?(!!n!==this.reversed()&&this.timeScale(-this._rts||(n?-Kt:0)),this):this._rts<0},e.invalidate=function(){return this._initted=this._act=0,this._zTime=-Kt,this},e.isActive=function(){var n=this.parent||this._dp,s=this._start,a;return!!(!n||this._ts&&this._initted&&n.isActive()&&(a=n.rawTime(!0))>=s&&a1?(s?(r[n]=s,a&&(r[n+"Params"]=a),n==="onUpdate"&&(this._onUpdate=s)):delete r[n],this):r[n]},e.then=function(n){var s=this,a=s._prom;return new Promise(function(r){var o=hi(n)?n:JR,c=function(){var h=s.then;s.then=null,a&&a(),hi(o)&&(o=o(s))&&(o.then||o===s)&&(s.then=h),r(o),s.then=h};s._initted&&s.totalProgress()===1&&s._ts>=0||!s._tTime&&s._ts<0?c():s._prom=c})},e.kill=function(){Kd(this)},i})();_s(Mh.prototype,{_time:0,_start:0,_end:0,_tTime:0,_tDur:0,_dirty:0,_repeat:0,_yoyo:!1,parent:null,_initted:!1,_rDelay:0,_ts:1,_dp:0,ratio:0,_zTime:-Kt,_prom:0,_ps:!1,_rts:1});var kn=(function(i){zR(e,i);function e(n,s){var a;return n===void 0&&(n={}),a=i.call(this,n)||this,a.labels={},a.smoothChildTiming=!!n.smoothChildTiming,a.autoRemoveChildren=!!n.autoRemoveChildren,a._sort=In(n.sortChildren),ri&&wa(n.parent||ri,rr(a),s),n.reversed&&a.reverse(),n.paused&&a.paused(!0),n.scrollTrigger&&tP(rr(a),n.scrollTrigger),a}var t=e.prototype;return t.to=function(s,a,r){return nh(0,arguments,this),this},t.from=function(s,a,r){return nh(1,arguments,this),this},t.fromTo=function(s,a,r,o){return nh(2,arguments,this),this},t.set=function(s,a,r){return a.duration=0,a.parent=this,ih(a).repeatDelay||(a.repeat=0),a.immediateRender=!!a.immediateRender,new Ni(s,a,Rs(this,r),1),this},t.call=function(s,a,r){return wa(this,Ni.delayedCall(0,s,a),r)},t.staggerTo=function(s,a,r,o,c,d,h){return r.duration=a,r.stagger=r.stagger||o,r.onComplete=d,r.onCompleteParams=h,r.parent=this,new Ni(s,r,Rs(this,c)),this},t.staggerFrom=function(s,a,r,o,c,d,h){return r.runBackwards=1,ih(r).immediateRender=In(r.immediateRender),this.staggerTo(s,a,r,o,c,d,h)},t.staggerFromTo=function(s,a,r,o,c,d,h,p){return o.startAt=r,ih(o).immediateRender=In(o.immediateRender),this.staggerTo(s,a,o,c,d,h,p)},t.render=function(s,a,r){var o=this._time,c=this._dirty?this.totalDuration():this._tDur,d=this._dur,h=s<=0?0:ai(s),p=this._zTime<0!=s<0&&(this._initted||!d),_,y,x,v,w,k,M,O,A,C,P,R;if(this!==ri&&h>c&&s>=0&&(h=c),h!==this._tTime||r||p){if(o!==this._time&&d&&(h+=this._time-o,s+=this._time-o),_=h,A=this._start,O=this._ts,k=!O,p&&(d||(o=this._zTime),(s||!a)&&(this._zTime=s)),this._repeat){if(P=this._yoyo,w=d+this._rDelay,this._repeat<-1&&s<0)return this.totalTime(w*100+s,a,r);if(_=ai(h%w),h===c?(v=this._repeat,_=d):(C=ai(h/w),v=~~C,v&&v===C&&(_=d,v--),_>d&&(_=d)),C=ou(this._tTime,w),!o&&this._tTime&&C!==v&&this._tTime-C*w-this._dur<=0&&(C=v),P&&v&1&&(_=d-_,R=1),v!==C&&!this._lock){var E=P&&C&1,L=E===(P&&v&1);if(v=o&&s>=0)for(y=this._first;y;){if(x=y._next,(y._act||_>=y._start)&&y._ts&&M!==y){if(y.parent!==this)return this.render(s,a,r);if(y.render(y._ts>0?(_-y._start)*y._ts:(y._dirty?y.totalDuration():y._tDur)+(_-y._start)*y._ts,a,r),_!==this._time||!this._ts&&!k){M=0,x&&(h+=this._zTime=-Kt);break}}y=x}else{y=this._last;for(var D=s<0?s:_;y;){if(x=y._prev,(y._act||D<=y._end)&&y._ts&&M!==y){if(y.parent!==this)return this.render(s,a,r);if(y.render(y._ts>0?(D-y._start)*y._ts:(y._dirty?y.totalDuration():y._tDur)+(D-y._start)*y._ts,a,r||sn&&Yv(y)),_!==this._time||!this._ts&&!k){M=0,x&&(h+=this._zTime=D?-Kt:Kt);break}}y=x}}if(M&&!a&&(this.pause(),M.render(_>=o?0:-Kt)._zTime=_>=o?1:-1,this._ts))return this._start=A,w0(this),this.render(s,a,r);this._onUpdate&&!a&&ds(this,"onUpdate",!0),(h===c&&this._tTime>=this.totalDuration()||!h&&o)&&(A===this._start||Math.abs(O)!==Math.abs(this._ts))&&(this._lock||((s||!d)&&(h===c&&this._ts>0||!h&&this._ts<0)&&So(this,1),!a&&!(s<0&&!o)&&(h||o||!c)&&(ds(this,h===c&&s>=0?"onComplete":"onReverseComplete",!0),this._prom&&!(h0)&&this._prom())))}return this},t.add=function(s,a){var r=this;if(yr(a)||(a=Rs(this,a,s)),!(s instanceof Mh)){if(fn(s))return s.forEach(function(o){return r.add(o,a)}),this;if(Ii(s))return this.addLabel(s,a);if(hi(s))s=Ni.delayedCall(0,s);else return this}return this!==s?wa(this,s,a):this},t.getChildren=function(s,a,r,o){s===void 0&&(s=!0),a===void 0&&(a=!0),r===void 0&&(r=!0),o===void 0&&(o=-Ls);for(var c=[],d=this._first;d;)d._start>=o&&(d instanceof Ni?a&&c.push(d):(r&&c.push(d),s&&c.push.apply(c,d.getChildren(!0,a,r)))),d=d._next;return c},t.getById=function(s){for(var a=this.getChildren(1,1,1),r=a.length;r--;)if(a[r].vars.id===s)return a[r]},t.remove=function(s){return Ii(s)?this.removeLabel(s):hi(s)?this.killTweensOf(s):(s.parent===this&&S0(this,s),s===this._recent&&(this._recent=this._last),Cl(this))},t.totalTime=function(s,a){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=ai(us.time-(this._ts>0?s/this._ts:(this.totalDuration()-s)/-this._ts))),i.prototype.totalTime.call(this,s,a),this._forcing=0,this):this._tTime},t.addLabel=function(s,a){return this.labels[s]=Rs(this,a),this},t.removeLabel=function(s){return delete this.labels[s],this},t.addPause=function(s,a,r){var o=Ni.delayedCall(0,a||Ch,r);return o.data="isPause",this._hasPause=1,wa(this,o,Rs(this,s))},t.removePause=function(s){var a=this._first;for(s=Rs(this,s);a;)a._start===s&&a.data==="isPause"&&So(a),a=a._next},t.killTweensOf=function(s,a,r){for(var o=this.getTweensOf(s,r),c=o.length;c--;)lo!==o[c]&&o[c].kill(s,a);return this},t.getTweensOf=function(s,a){for(var r=[],o=js(s),c=this._first,d=yr(a),h;c;)c instanceof Ni?Nz(c._targets,o)&&(d?(!lo||c._initted&&c._ts)&&c.globalTime(0)<=a&&c.globalTime(c.totalDuration())>a:!a||c.isActive())&&r.push(c):(h=c.getTweensOf(o,a)).length&&r.push.apply(r,h),c=c._next;return r},t.tweenTo=function(s,a){a=a||{};var r=this,o=Rs(r,s),c=a,d=c.startAt,h=c.onStart,p=c.onStartParams,_=c.immediateRender,y,x=Ni.to(r,_s({ease:a.ease||"none",lazy:!1,immediateRender:!1,time:o,overwrite:"auto",duration:a.duration||Math.abs((o-(d&&"time"in d?d.time:r._time))/r.timeScale())||Kt,onStart:function(){if(r.pause(),!y){var w=a.duration||Math.abs((o-(d&&"time"in d?d.time:r._time))/r.timeScale());x._dur!==w&&lu(x,w,0,1).render(x._time,!0,!0),y=1}h&&h.apply(x,p||[])}},a));return _?x.render(0):x},t.tweenFromTo=function(s,a,r){return this.tweenTo(a,_s({startAt:{time:Rs(this,s)}},r))},t.recent=function(){return this._recent},t.nextLabel=function(s){return s===void 0&&(s=this._time),oO(this,Rs(this,s))},t.previousLabel=function(s){return s===void 0&&(s=this._time),oO(this,Rs(this,s),1)},t.currentLabel=function(s){return arguments.length?this.seek(s,!0):this.previousLabel(this._time+Kt)},t.shiftChildren=function(s,a,r){r===void 0&&(r=0);var o=this._first,c=this.labels,d;for(s=ai(s);o;)o._start>=r&&(o._start+=s,o._end+=s),o=o._next;if(a)for(d in c)c[d]>=r&&(c[d]+=s);return Cl(this)},t.invalidate=function(s){var a=this._first;for(this._lock=0;a;)a.invalidate(s),a=a._next;return i.prototype.invalidate.call(this,s)},t.clear=function(s){s===void 0&&(s=!0);for(var a=this._first,r;a;)r=a._next,this.remove(a),a=r;return this._dp&&(this._time=this._tTime=this._pTime=0),s&&(this.labels={}),Cl(this)},t.totalDuration=function(s){var a=0,r=this,o=r._last,c=Ls,d,h,p;if(arguments.length)return r.timeScale((r._repeat<0?r.duration():r.totalDuration())/(r.reversed()?-s:s));if(r._dirty){for(p=r.parent;o;)d=o._prev,o._dirty&&o.totalDuration(),h=o._start,h>c&&r._sort&&o._ts&&!r._lock?(r._lock=1,wa(r,o,h-o._delay,1)._lock=0):c=h,h<0&&o._ts&&(a-=h,(!p&&!r._dp||p&&p.smoothChildTiming)&&(r._start+=ai(h/r._ts),r._time-=h,r._tTime-=h),r.shiftChildren(-h,!1,-1/0),c=0),o._end>a&&o._ts&&(a=o._end),o=d;lu(r,r===ri&&r._time>a?r._time:a,1,1),r._dirty=0}return r._tDur},e.updateRoot=function(s){if(ri._ts&&(YR(ri,Cg(s,ri)),GR=us.frame),us.frame>=nO){nO+=ps.autoSleep||120;var a=ri._first;if((!a||!a._ts)&&ps.autoSleep&&us._listeners.length<2){for(;a&&!a._ts;)a=a._next;a||us.sleep()}}},e})(Mh);_s(kn.prototype,{_lock:0,_hasPause:0,_forcing:0});var $z=function(e,t,n,s,a,r,o){var c=new Xn(this._pt,e,t,0,1,kP,null,a),d=0,h=0,p,_,y,x,v,w,k,M;for(c.b=n,c.e=s,n+="",s+="",(k=~s.indexOf("random("))&&(s=Oh(s)),r&&(M=[n,s],r(M,e,t),n=M[0],s=M[1]),_=n.match(C1)||[];p=C1.exec(s);)x=p[0],v=s.substring(d,p.index),y?y=(y+1)%5:v.substr(-5)==="rgba("&&(y=1),x!==_[h++]&&(w=parseFloat(_[h-1])||0,c._pt={_next:c._pt,p:v||h===1?v:",",s:w,c:x.charAt(1)==="="?Xc(w,x)-w:parseFloat(x)-w,m:y&&y<4?Math.round:0},d=C1.lastIndex);return c.c=d")}),A.duration();else{P={};for(E in x)E==="ease"||E==="easeEach"||n7(E,x[E],P,x.easeEach);for(E in P)for(H=P[E].sort(function(U,G){return U.t-G.t}),B=0,C=0;Cc-Kt&&!h?c:sd&&(_=d)),k=this._yoyo&&x&1,k&&(A=this._yEase,_=d-_),w=ou(this._tTime,v),_===o&&!r&&this._initted&&x===w)return this._tTime=p,this;x!==w&&(O&&this._yEase&&gP(O,k),this.vars.repeatRefresh&&!k&&!this._lock&&_!==v&&this._initted&&(this._lock=r=1,this.render(ai(v*x),!0).invalidate()._lock=0))}if(!this._initted){if(iP(this,h?s:_,r,a,p))return this._tTime=0,this;if(o!==this._time&&!(r&&this.vars.repeatRefresh&&x!==w))return this;if(d!==this._dur)return this.render(s,a,r)}if(this._tTime=p,this._time=_,!this._act&&this._ts&&(this._act=1,this._lazy=0),this.ratio=M=(A||this._ease)(_/d),this._from&&(this.ratio=M=1-M),!o&&p&&!a&&!w&&(ds(this,"onStart"),this._tTime!==p))return this;for(y=this._pt;y;)y.r(M,y.d),y=y._next;O&&O.render(s<0?s:O._dur*O._ease(_/this._dur),a,r)||this._startAt&&(this._zTime=s),this._onUpdate&&!a&&(h&&Zx(this,s,a,r),ds(this,"onUpdate")),this._repeat&&x!==w&&this.vars.onRepeat&&!a&&this.parent&&ds(this,"onRepeat"),(p===this._tDur||!p)&&this._tTime===p&&(h&&!this._onUpdate&&Zx(this,s,!0,!0),(s||!d)&&(p===this._tDur&&this._ts>0||!p&&this._ts<0)&&So(this,1),!a&&!(h&&!o)&&(p||o||k)&&(ds(this,p===c?"onComplete":"onReverseComplete",!0),this._prom&&!(p0)&&this._prom()))}return this},t.targets=function(){return this._targets},t.invalidate=function(s){return(!s||!this.vars.runBackwards)&&(this._startAt=0),this._pt=this._op=this._onUpdate=this._lazy=this.ratio=0,this._ptLookup=[],this.timeline&&this.timeline.invalidate(s),i.prototype.invalidate.call(this,s)},t.resetTo=function(s,a,r,o,c){Th||us.wake(),this._ts||this.play();var d=Math.min(this._dur,(this._dp._time-this._start)*this._ts),h;return this._initted||Jv(this,d),h=this._ease(d/this._dur),t7(this,s,a,r,o,h,d,c)?this.resetTo(s,a,r,o,1):(k0(this,0),this.parent||$R(this._dp,this,"_first","_last",this._dp._sort?"_start":0),this.render(0))},t.kill=function(s,a){if(a===void 0&&(a="all"),!s&&(!a||a==="all"))return this._lazy=this._pt=0,this.parent?Kd(this):this.scrollTrigger&&this.scrollTrigger.kill(!!sn),this;if(this.timeline){var r=this.timeline.totalDuration();return this.timeline.killTweensOf(s,a,lo&&lo.vars.overwrite!==!0)._first||Kd(this),this.parent&&r!==this.timeline.totalDuration()&&lu(this,this._dur*this.timeline._tDur/r,0,1),this}var o=this._targets,c=s?js(s):o,d=this._ptLookup,h=this._pt,p,_,y,x,v,w,k;if((!a||a==="all")&&Pz(o,c))return a==="all"&&(this._pt=0),Kd(this);for(p=this._op=this._op||[],a!=="all"&&(Ii(a)&&(v={},Wn(a,function(M){return v[M]=1}),a=v),a=i7(o,a)),k=o.length;k--;)if(~c.indexOf(o[k])){_=d[k],a==="all"?(p[k]=a,x=_,y={}):(y=p[k]=p[k]||{},x=a);for(v in x)w=_&&_[v],w&&((!("kill"in w.d)||w.d.kill(v)===!0)&&S0(this,w,"_pt"),delete _[v]),y!=="all"&&(y[v]=1)}return this._initted&&!this._pt&&h&&Kd(this),this},e.to=function(s,a){return new e(s,a,arguments[2])},e.from=function(s,a){return nh(1,arguments)},e.delayedCall=function(s,a,r,o){return new e(a,0,{immediateRender:!1,lazy:!1,overwrite:!1,delay:s,onComplete:a,onReverseComplete:a,onCompleteParams:r,onReverseCompleteParams:r,callbackScope:o})},e.fromTo=function(s,a,r){return nh(2,arguments)},e.set=function(s,a){return a.duration=0,a.repeatDelay||(a.repeat=0),new e(s,a)},e.killTweensOf=function(s,a,r){return ri.killTweensOf(s,a,r)},e})(Mh);_s(Ni.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0});Wn("staggerTo,staggerFrom,staggerFromTo",function(i){Ni[i]=function(){var e=new kn,t=$x.call(arguments,0);return t.splice(i==="staggerFromTo"?5:4,0,0),e[i].apply(e,t)}});var $v=function(e,t,n){return e[t]=n},SP=function(e,t,n){return e[t](n)},s7=function(e,t,n,s){return e[t](s.fp,n)},a7=function(e,t,n){return e.setAttribute(t,n)},e2=function(e,t){return hi(e[t])?SP:Kv(e[t])&&e.setAttribute?a7:$v},wP=function(e,t){return t.set(t.t,t.p,Math.round((t.s+t.c*e)*1e6)/1e6,t)},r7=function(e,t){return t.set(t.t,t.p,!!(t.s+t.c*e),t)},kP=function(e,t){var n=t._pt,s="";if(!e&&t.b)s=t.b;else if(e===1&&t.e)s=t.e;else{for(;n;)s=n.p+(n.m?n.m(n.s+n.c*e):Math.round((n.s+n.c*e)*1e4)/1e4)+s,n=n._next;s+=t.c}t.set(t.t,t.p,s,t)},t2=function(e,t){for(var n=t._pt;n;)n.r(e,n.d),n=n._next},o7=function(e,t,n,s){for(var a=this._pt,r;a;)r=a._next,a.p===s&&a.modifier(e,t,n),a=r},l7=function(e){for(var t=this._pt,n,s;t;)s=t._next,t.p===e&&!t.op||t.op===e?S0(this,t,"_pt"):t.dep||(n=1),t=s;return!n},c7=function(e,t,n,s){s.mSet(e,t,s.m.call(s.tween,n,s.mt),s)},AP=function(e){for(var t=e._pt,n,s,a,r;t;){for(n=t._next,s=a;s&&s.pr>t.pr;)s=s._next;(t._prev=s?s._prev:r)?t._prev._next=t:a=t,(t._next=s)?s._prev=t:r=t,t=n}e._pt=a},Xn=(function(){function i(t,n,s,a,r,o,c,d,h){this.t=n,this.s=a,this.c=r,this.p=s,this.r=o||wP,this.d=c||this,this.set=d||$v,this.pr=h||0,this._next=t,t&&(t._prev=this)}var e=i.prototype;return e.modifier=function(n,s,a){this.mSet=this.mSet||this.set,this.set=c7,this.m=n,this.mt=a,this.tween=s},i})();Wn(Gv+"parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger",function(i){return Xv[i]=1});gs.TweenMax=gs.TweenLite=Ni;gs.TimelineLite=gs.TimelineMax=kn;ri=new kn({sortChildren:!1,defaults:au,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0});ps.stringFilter=pP;var Tl=[],Zm={},u7=[],cO=0,d7=0,R1=function(e){return(Zm[e]||u7).map(function(t){return t()})},nb=function(){var e=Date.now(),t=[];e-cO>2&&(R1("matchMediaInit"),Tl.forEach(function(n){var s=n.queries,a=n.conditions,r,o,c,d;for(o in s)r=va.matchMedia(s[o]).matches,r&&(c=1),r!==a[o]&&(a[o]=r,d=1);d&&(n.revert(),c&&t.push(n))}),R1("matchMediaRevert"),t.forEach(function(n){return n.onMatch(n,function(s){return n.add(null,s)})}),cO=e,R1("matchMedia"))},CP=(function(){function i(t,n){this.selector=n&&eb(n),this.data=[],this._r=[],this.isReverted=!1,this.id=d7++,t&&this.add(t)}var e=i.prototype;return e.add=function(n,s,a){hi(n)&&(a=s,s=n,n=hi);var r=this,o=function(){var d=$t,h=r.selector,p;return d&&d!==r&&d.data.push(r),a&&(r.selector=eb(a)),$t=r,p=s.apply(r,arguments),hi(p)&&r._r.push(p),$t=d,r.selector=h,r.isReverted=!1,p};return r.last=o,n===hi?o(r,function(c){return r.add(null,c)}):n?r[n]=o:o},e.ignore=function(n){var s=$t;$t=null,n(this),$t=s},e.getTweens=function(){var n=[];return this.data.forEach(function(s){return s instanceof i?n.push.apply(n,s.getTweens()):s instanceof Ni&&!(s.parent&&s.parent.data==="nested")&&n.push(s)}),n},e.clear=function(){this._r.length=this.data.length=0},e.kill=function(n,s){var a=this;if(n?(function(){for(var o=a.getTweens(),c=a.data.length,d;c--;)d=a.data[c],d.data==="isFlip"&&(d.revert(),d.getChildren(!0,!0,!1).forEach(function(h){return o.splice(o.indexOf(h),1)}));for(o.map(function(h){return{g:h._dur||h._delay||h._sat&&!h._sat.vars.immediateRender?h.globalTime(0):-1/0,t:h}}).sort(function(h,p){return p.g-h.g||-1/0}).forEach(function(h){return h.t.revert(n)}),c=a.data.length;c--;)d=a.data[c],d instanceof kn?d.data!=="nested"&&(d.scrollTrigger&&d.scrollTrigger.revert(),d.kill()):!(d instanceof Ni)&&d.revert&&d.revert(n);a._r.forEach(function(h){return h(n,a)}),a.isReverted=!0})():this.data.forEach(function(o){return o.kill&&o.kill()}),this.clear(),s)for(var r=Tl.length;r--;)Tl[r].id===this.id&&Tl.splice(r,1)},e.revert=function(n){this.kill(n||{})},i})(),h7=(function(){function i(t){this.contexts=[],this.scope=t,$t&&$t.data.push(this)}var e=i.prototype;return e.add=function(n,s,a){Pa(n)||(n={matches:n});var r=new CP(0,a||this.scope),o=r.conditions={},c,d,h;$t&&!r.selector&&(r.selector=$t.selector),this.contexts.push(r),s=r.add("onMatch",s),r.queries=n;for(d in n)d==="all"?h=1:(c=va.matchMedia(n[d]),c&&(Tl.indexOf(r)<0&&Tl.push(r),(o[d]=c.matches)&&(h=1),c.addListener?c.addListener(nb):c.addEventListener("change",nb)));return h&&s(r,function(p){return r.add(null,p)}),this},e.revert=function(n){this.kill(n||{})},e.kill=function(n){this.contexts.forEach(function(s){return s.kill(n,!0)})},i})(),Og={registerPlugin:function(){for(var e=arguments.length,t=new Array(e),n=0;n1){var s=e.map(function(h){return Qn.quickSetter(h,t,n)}),a=s.length;return function(h){for(var p=a;p--;)s[p](h)}}e=e[0]||{};var r=cs[t],o=Al(e),c=o.harness&&(o.harness.aliases||{})[t]||t,d=r?function(h){var p=new r;zc._pt=0,p.init(e,n?h+n:h,zc,0,[e]),p.render(1,p),zc._pt&&t2(1,zc)}:o.set(e,c);return r?d:function(h){return d(e,c,n?h+n:h,o,1)}},quickTo:function(e,t,n){var s,a=Qn.to(e,_s((s={},s[t]="+=0.1",s.paused=!0,s.stagger=0,s),n||{})),r=function(c,d,h){return a.resetTo(t,c,d,h)};return r.tween=a,r},isTweening:function(e){return ri.getTweensOf(e,!0).length>0},defaults:function(e){return e&&e.ease&&(e.ease=Ol(e.ease,au.ease)),sO(au,e||{})},config:function(e){return sO(ps,e||{})},registerEffect:function(e){var t=e.name,n=e.effect,s=e.plugins,a=e.defaults,r=e.extendTimeline;(s||"").split(",").forEach(function(o){return o&&!cs[o]&&!gs[o]&&Ah(t+" effect requires "+o+" plugin.")}),O1[t]=function(o,c,d){return n(js(o),_s(c||{},a),d)},r&&(kn.prototype[t]=function(o,c,d){return this.add(O1[t](o,Pa(c)?c:(d=c)&&{},this),d)})},registerEase:function(e,t){ht[e]=Ol(t)},parseEase:function(e,t){return arguments.length?Ol(e,t):ht},getById:function(e){return ri.getById(e)},exportRoot:function(e,t){e===void 0&&(e={});var n=new kn(e),s,a;for(n.smoothChildTiming=In(e.smoothChildTiming),ri.remove(n),n._dp=0,n._time=n._tTime=ri._time,s=ri._first;s;)a=s._next,(t||!(!s._dur&&s instanceof Ni&&s.vars.onComplete===s._targets[0]))&&wa(n,s,s._start-s._delay),s=a;return wa(ri,n,0),n},context:function(e,t){return e?new CP(e,t):$t},matchMedia:function(e){return new h7(e)},matchMediaRefresh:function(){return Tl.forEach(function(e){var t=e.conditions,n,s;for(s in t)t[s]&&(t[s]=!1,n=1);n&&e.revert()})||nb()},addEventListener:function(e,t){var n=Zm[e]||(Zm[e]=[]);~n.indexOf(t)||n.push(t)},removeEventListener:function(e,t){var n=Zm[e],s=n&&n.indexOf(t);s>=0&&n.splice(s,1)},utils:{wrap:Vz,wrapYoyo:Iz,distribute:aP,random:oP,snap:rP,normalize:Kz,getUnit:un,clamp:Bz,splitColor:hP,toArray:js,selector:eb,mapRange:cP,pipe:qz,unitize:Hz,interpolate:Wz,shuffle:sP},install:WR,effects:O1,ticker:us,updateRoot:kn.updateRoot,plugins:cs,globalTimeline:ri,core:{PropTween:Xn,globals:XR,Tween:Ni,Timeline:kn,Animation:Mh,getCache:Al,_removeLinkedListItem:S0,reverting:function(){return sn},context:function(e){return e&&$t&&($t.data.push(e),e._ctx=$t),$t},suppressOverwrites:function(e){return Hv=e}}};Wn("to,from,fromTo,delayedCall,set,killTweensOf",function(i){return Og[i]=Ni[i]});us.add(kn.updateRoot);zc=Og.to({},{duration:0});var f7=function(e,t){for(var n=e._pt;n&&n.p!==t&&n.op!==t&&n.fp!==t;)n=n._next;return n},p7=function(e,t){var n=e._targets,s,a,r;for(s in t)for(a=n.length;a--;)r=e._ptLookup[a][s],r&&(r=r.d)&&(r._pt&&(r=f7(r,s)),r&&r.modifier&&r.modifier(t[s],e,n[a],s))},P1=function(e,t){return{name:e,headless:1,rawVars:1,init:function(s,a,r){r._onInit=function(o){var c,d;if(Ii(a)&&(c={},Wn(a,function(h){return c[h]=1}),a=c),t){c={};for(d in a)c[d]=t(a[d]);a=c}p7(o,a)}}}},Qn=Og.registerPlugin({name:"attr",init:function(e,t,n,s,a){var r,o,c;this.tween=n;for(r in t)c=e.getAttribute(r)||"",o=this.add(e,"setAttribute",(c||0)+"",t[r],s,a,0,0,r),o.op=r,o.b=c,this._props.push(r)},render:function(e,t){for(var n=t._pt;n;)sn?n.set(n.t,n.p,n.b,n):n.r(e,n.d),n=n._next}},{name:"endArray",headless:1,init:function(e,t){for(var n=t.length;n--;)this.add(e,n,e[n]||0,t[n],0,0,0,0,0,1)}},P1("roundProps",tb),P1("modifiers"),P1("snap",rP))||Og;Ni.version=kn.version=Qn.version="3.14.2";IR=1;Vv()&&cu();ht.Power0;ht.Power1;ht.Power2;ht.Power3;ht.Power4;ht.Linear;ht.Quad;ht.Cubic;ht.Quart;ht.Quint;ht.Strong;ht.Elastic;ht.Back;ht.SteppedEase;ht.Bounce;ht.Sine;ht.Expo;ht.Circ;var uO,co,Gc,i2,yl,dO,n2,m7=function(){return typeof window!="undefined"},xr={},ol=180/Math.PI,Qc=Math.PI/180,jc=Math.atan2,hO=1e8,s2=/([A-Z])/g,g7=/(left|right|width|margin|padding|x)/i,_7=/[\s,\(]\S/,Ta={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},sb=function(e,t){return t.set(t.t,t.p,Math.round((t.s+t.c*e)*1e4)/1e4+t.u,t)},y7=function(e,t){return t.set(t.t,t.p,e===1?t.e:Math.round((t.s+t.c*e)*1e4)/1e4+t.u,t)},x7=function(e,t){return t.set(t.t,t.p,e?Math.round((t.s+t.c*e)*1e4)/1e4+t.u:t.b,t)},b7=function(e,t){return t.set(t.t,t.p,e===1?t.e:e?Math.round((t.s+t.c*e)*1e4)/1e4+t.u:t.b,t)},v7=function(e,t){var n=t.s+t.c*e;t.set(t.t,t.p,~~(n+(n<0?-.5:.5))+t.u,t)},OP=function(e,t){return t.set(t.t,t.p,e?t.e:t.b,t)},TP=function(e,t){return t.set(t.t,t.p,e!==1?t.b:t.e,t)},S7=function(e,t,n){return e.style[t]=n},w7=function(e,t,n){return e.style.setProperty(t,n)},k7=function(e,t,n){return e._gsap[t]=n},A7=function(e,t,n){return e._gsap.scaleX=e._gsap.scaleY=n},C7=function(e,t,n,s,a){var r=e._gsap;r.scaleX=r.scaleY=n,r.renderTransform(a,r)},O7=function(e,t,n,s,a){var r=e._gsap;r[t]=n,r.renderTransform(a,r)},oi="transform",Gn=oi+"Origin",T7=function i(e,t){var n=this,s=this.target,a=s.style,r=s._gsap;if(e in xr&&a){if(this.tfm=this.tfm||{},e!=="transform")e=Ta[e]||e,~e.indexOf(",")?e.split(",").forEach(function(o){return n.tfm[o]=or(s,o)}):this.tfm[e]=r.x?r[e]:or(s,e),e===Gn&&(this.tfm.zOrigin=r.zOrigin);else return Ta.transform.split(",").forEach(function(o){return i.call(n,o,t)});if(this.props.indexOf(oi)>=0)return;r.svg&&(this.svgo=s.getAttribute("data-svg-origin"),this.props.push(Gn,t,"")),e=oi}(a||t)&&this.props.push(e,t,a[e])},MP=function(e){e.translate&&(e.removeProperty("translate"),e.removeProperty("scale"),e.removeProperty("rotate"))},M7=function(){var e=this.props,t=this.target,n=t.style,s=t._gsap,a,r;for(a=0;a=0?fO[r]:"")+e},rb=function(){m7()&&window.document&&(uO=window,co=uO.document,Gc=co.documentElement,yl=ab("div")||{style:{}},ab("div"),oi=uu(oi),Gn=oi+"Origin",yl.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",RP=!!uu("perspective"),n2=Qn.core.reverting,i2=1)},pO=function(e){var t=e.ownerSVGElement,n=ab("svg",t&&t.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),s=e.cloneNode(!0),a;s.style.display="block",n.appendChild(s),Gc.appendChild(n);try{a=s.getBBox()}catch(r){}return n.removeChild(s),Gc.removeChild(n),a},mO=function(e,t){for(var n=t.length;n--;)if(e.hasAttribute(t[n]))return e.getAttribute(t[n])},PP=function(e){var t,n;try{t=e.getBBox()}catch(s){t=pO(e),n=1}return t&&(t.width||t.height)||n||(t=pO(e)),t&&!t.width&&!t.x&&!t.y?{x:+mO(e,["x","cx","x1"])||0,y:+mO(e,["y","cy","y1"])||0,width:0,height:0}:t},LP=function(e){return!!(e.getCTM&&(!e.parentNode||e.ownerSVGElement)&&PP(e))},wo=function(e,t){if(t){var n=e.style,s;t in xr&&t!==Gn&&(t=oi),n.removeProperty?(s=t.substr(0,2),(s==="ms"||t.substr(0,6)==="webkit")&&(t="-"+t),n.removeProperty(s==="--"?t:t.replace(s2,"-$1").toLowerCase())):n.removeAttribute(t)}},uo=function(e,t,n,s,a,r){var o=new Xn(e._pt,t,n,0,1,r?TP:OP);return e._pt=o,o.b=s,o.e=a,e._props.push(n),o},gO={deg:1,rad:1,turn:1},N7={grid:1,flex:1},ko=function i(e,t,n,s){var a=parseFloat(n)||0,r=(n+"").trim().substr((a+"").length)||"px",o=yl.style,c=g7.test(t),d=e.tagName.toLowerCase()==="svg",h=(d?"client":"offset")+(c?"Width":"Height"),p=100,_=s==="px",y=s==="%",x,v,w,k;if(s===r||!a||gO[s]||gO[r])return a;if(r!=="px"&&!_&&(a=i(e,t,n,"px")),k=e.getCTM&&LP(e),(y||r==="%")&&(xr[t]||~t.indexOf("adius")))return x=k?e.getBBox()[c?"width":"height"]:e[h],yi(y?a/x*p:a/100*x);if(o[c?"width":"height"]=p+(_?r:s),v=s!=="rem"&&~t.indexOf("adius")||s==="em"&&e.appendChild&&!d?e:e.parentNode,k&&(v=(e.ownerSVGElement||{}).parentNode),(!v||v===co||!v.appendChild)&&(v=co.body),w=v._gsap,w&&y&&w.width&&c&&w.time===us.time&&!w.uncache)return yi(a/w.width*p);if(y&&(t==="height"||t==="width")){var M=e.style[t];e.style[t]=p+s,x=e[h],M?e.style[t]=M:wo(e,t)}else(y||r==="%")&&!N7[hs(v,"display")]&&(o.position=hs(e,"position")),v===e&&(o.position="static"),v.appendChild(yl),x=yl[h],v.removeChild(yl),o.position="absolute";return c&&y&&(w=Al(v),w.time=us.time,w.width=v[h]),yi(_?x*a/p:x&&a?p/x*a:0)},or=function(e,t,n,s){var a;return i2||rb(),t in Ta&&t!=="transform"&&(t=Ta[t],~t.indexOf(",")&&(t=t.split(",")[0])),xr[t]&&t!=="transform"?(a=Rh(e,s),a=t!=="transformOrigin"?a[t]:a.svg?a.origin:Mg(hs(e,Gn))+" "+a.zOrigin+"px"):(a=e.style[t],(!a||a==="auto"||s||~(a+"").indexOf("calc("))&&(a=Tg[t]&&Tg[t](e,t,n)||hs(e,t)||QR(e,t)||(t==="opacity"?1:0))),n&&!~(a+"").trim().indexOf(" ")?ko(e,t,a,n)+n:a},R7=function(e,t,n,s){if(!n||n==="none"){var a=uu(t,e,1),r=a&&hs(e,a,1);r&&r!==n?(t=a,n=r):t==="borderColor"&&(n=hs(e,"borderTopColor"))}var o=new Xn(this._pt,e.style,t,0,1,kP),c=0,d=0,h,p,_,y,x,v,w,k,M,O,A,C;if(o.b=n,o.e=s,n+="",s+="",s.substring(0,6)==="var(--"&&(s=hs(e,s.substring(4,s.indexOf(")")))),s==="auto"&&(v=e.style[t],e.style[t]=s,s=hs(e,t)||s,v?e.style[t]=v:wo(e,t)),h=[n,s],pP(h),n=h[0],s=h[1],_=n.match(Bc)||[],C=s.match(Bc)||[],C.length){for(;p=Bc.exec(s);)w=p[0],M=s.substring(c,p.index),x?x=(x+1)%5:(M.substr(-5)==="rgba("||M.substr(-5)==="hsla(")&&(x=1),w!==(v=_[d++]||"")&&(y=parseFloat(v)||0,A=v.substr((y+"").length),w.charAt(1)==="="&&(w=Xc(y,w)+A),k=parseFloat(w),O=w.substr((k+"").length),c=Bc.lastIndex-O.length,O||(O=O||ps.units[t]||A,c===s.length&&(s+=O,o.e+=O)),A!==O&&(y=ko(e,t,v,O)||0),o._pt={_next:o._pt,p:M||d===1?M:",",s:y,c:k-y,m:x&&x<4||t==="zIndex"?Math.round:0});o.c=c-1;)o=a[d],xr[o]&&(c=1,o=o==="transformOrigin"?Gn:oi),wo(n,o);c&&(wo(n,oi),r&&(r.svg&&n.removeAttribute("transform"),s.scale=s.rotate=s.translate="none",Rh(n,1),r.uncache=1,MP(s)))}},Tg={clearProps:function(e,t,n,s,a){if(a.data!=="isFromStart"){var r=e._pt=new Xn(e._pt,t,n,0,0,L7);return r.u=s,r.pr=-10,r.tween=a,e._props.push(n),1}}},Nh=[1,0,0,1,0,0],jP={},EP=function(e){return e==="matrix(1, 0, 0, 1, 0, 0)"||e==="none"||!e},yO=function(e){var t=hs(e,oi);return EP(t)?Nh:t.substr(7).match(KR).map(yi)},a2=function(e,t){var n=e._gsap||Al(e),s=e.style,a=yO(e),r,o,c,d;return n.svg&&e.getAttribute("transform")?(c=e.transform.baseVal.consolidate().matrix,a=[c.a,c.b,c.c,c.d,c.e,c.f],a.join(",")==="1,0,0,1,0,0"?Nh:a):(a===Nh&&!e.offsetParent&&e!==Gc&&!n.svg&&(c=s.display,s.display="block",r=e.parentNode,(!r||!e.offsetParent&&!e.getBoundingClientRect().width)&&(d=1,o=e.nextElementSibling,Gc.appendChild(e)),a=yO(e),c?s.display=c:wo(e,"display"),d&&(o?r.insertBefore(e,o):r?r.appendChild(e):Gc.removeChild(e))),t&&a.length>6?[a[0],a[1],a[4],a[5],a[12],a[13]]:a)},ob=function(e,t,n,s,a,r){var o=e._gsap,c=a||a2(e,!0),d=o.xOrigin||0,h=o.yOrigin||0,p=o.xOffset||0,_=o.yOffset||0,y=c[0],x=c[1],v=c[2],w=c[3],k=c[4],M=c[5],O=t.split(" "),A=parseFloat(O[0])||0,C=parseFloat(O[1])||0,P,R,E,L;n?c!==Nh&&(R=y*w-x*v)&&(E=A*(w/R)+C*(-v/R)+(v*M-w*k)/R,L=A*(-x/R)+C*(y/R)-(y*M-x*k)/R,A=E,C=L):(P=PP(e),A=P.x+(~O[0].indexOf("%")?A/100*P.width:A),C=P.y+(~(O[1]||O[0]).indexOf("%")?C/100*P.height:C)),s||s!==!1&&o.smooth?(k=A-d,M=C-h,o.xOffset=p+(k*y+M*v)-k,o.yOffset=_+(k*x+M*w)-M):o.xOffset=o.yOffset=0,o.xOrigin=A,o.yOrigin=C,o.smooth=!!s,o.origin=t,o.originIsAbsolute=!!n,e.style[Gn]="0px 0px",r&&(uo(r,o,"xOrigin",d,A),uo(r,o,"yOrigin",h,C),uo(r,o,"xOffset",p,o.xOffset),uo(r,o,"yOffset",_,o.yOffset)),e.setAttribute("data-svg-origin",A+" "+C)},Rh=function(e,t){var n=e._gsap||new yP(e);if("x"in n&&!t&&!n.uncache)return n;var s=e.style,a=n.scaleX<0,r="px",o="deg",c=getComputedStyle(e),d=hs(e,Gn)||"0",h,p,_,y,x,v,w,k,M,O,A,C,P,R,E,L,D,q,B,H,W,V,U,G,$,ie,ue,F,Y,ce,J,me;return h=p=_=v=w=k=M=O=A=0,y=x=1,n.svg=!!(e.getCTM&&LP(e)),c.translate&&((c.translate!=="none"||c.scale!=="none"||c.rotate!=="none")&&(s[oi]=(c.translate!=="none"?"translate3d("+(c.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(c.rotate!=="none"?"rotate("+c.rotate+") ":"")+(c.scale!=="none"?"scale("+c.scale.split(" ").join(",")+") ":"")+(c[oi]!=="none"?c[oi]:"")),s.scale=s.rotate=s.translate="none"),R=a2(e,n.svg),n.svg&&(n.uncache?($=e.getBBox(),d=n.xOrigin-$.x+"px "+(n.yOrigin-$.y)+"px",G=""):G=!t&&e.getAttribute("data-svg-origin"),ob(e,G||d,!!G||n.originIsAbsolute,n.smooth!==!1,R)),C=n.xOrigin||0,P=n.yOrigin||0,R!==Nh&&(q=R[0],B=R[1],H=R[2],W=R[3],h=V=R[4],p=U=R[5],R.length===6?(y=Math.sqrt(q*q+B*B),x=Math.sqrt(W*W+H*H),v=q||B?jc(B,q)*ol:0,M=H||W?jc(H,W)*ol+v:0,M&&(x*=Math.abs(Math.cos(M*Qc))),n.svg&&(h-=C-(C*q+P*H),p-=P-(C*B+P*W))):(me=R[6],ce=R[7],ue=R[8],F=R[9],Y=R[10],J=R[11],h=R[12],p=R[13],_=R[14],E=jc(me,Y),w=E*ol,E&&(L=Math.cos(-E),D=Math.sin(-E),G=V*L+ue*D,$=U*L+F*D,ie=me*L+Y*D,ue=V*-D+ue*L,F=U*-D+F*L,Y=me*-D+Y*L,J=ce*-D+J*L,V=G,U=$,me=ie),E=jc(-H,Y),k=E*ol,E&&(L=Math.cos(-E),D=Math.sin(-E),G=q*L-ue*D,$=B*L-F*D,ie=H*L-Y*D,J=W*D+J*L,q=G,B=$,H=ie),E=jc(B,q),v=E*ol,E&&(L=Math.cos(E),D=Math.sin(E),G=q*L+B*D,$=V*L+U*D,B=B*L-q*D,U=U*L-V*D,q=G,V=$),w&&Math.abs(w)+Math.abs(v)>359.9&&(w=v=0,k=180-k),y=yi(Math.sqrt(q*q+B*B+H*H)),x=yi(Math.sqrt(U*U+me*me)),E=jc(V,U),M=Math.abs(E)>2e-4?E*ol:0,A=J?1/(J<0?-J:J):0),n.svg&&(G=e.getAttribute("transform"),n.forceCSS=e.setAttribute("transform","")||!EP(hs(e,oi)),G&&e.setAttribute("transform",G))),Math.abs(M)>90&&Math.abs(M)<270&&(a?(y*=-1,M+=v<=0?180:-180,v+=v<=0?180:-180):(x*=-1,M+=M<=0?180:-180)),t=t||n.uncache,n.x=h-((n.xPercent=h&&(!t&&n.xPercent||(Math.round(e.offsetWidth/2)===Math.round(-h)?-50:0)))?e.offsetWidth*n.xPercent/100:0)+r,n.y=p-((n.yPercent=p&&(!t&&n.yPercent||(Math.round(e.offsetHeight/2)===Math.round(-p)?-50:0)))?e.offsetHeight*n.yPercent/100:0)+r,n.z=_+r,n.scaleX=yi(y),n.scaleY=yi(x),n.rotation=yi(v)+o,n.rotationX=yi(w)+o,n.rotationY=yi(k)+o,n.skewX=M+o,n.skewY=O+o,n.transformPerspective=A+r,(n.zOrigin=parseFloat(d.split(" ")[2])||!t&&n.zOrigin||0)&&(s[Gn]=Mg(d)),n.xOffset=n.yOffset=0,n.force3D=ps.force3D,n.renderTransform=n.svg?E7:RP?DP:j7,n.uncache=0,n},Mg=function(e){return(e=e.split(" "))[0]+" "+e[1]},L1=function(e,t,n){var s=un(t);return yi(parseFloat(t)+parseFloat(ko(e,"x",n+"px",s)))+s},j7=function(e,t){t.z="0px",t.rotationY=t.rotationX="0deg",t.force3D=0,DP(e,t)},tl="0deg",Md="0px",il=") ",DP=function(e,t){var n=t||this,s=n.xPercent,a=n.yPercent,r=n.x,o=n.y,c=n.z,d=n.rotation,h=n.rotationY,p=n.rotationX,_=n.skewX,y=n.skewY,x=n.scaleX,v=n.scaleY,w=n.transformPerspective,k=n.force3D,M=n.target,O=n.zOrigin,A="",C=k==="auto"&&e&&e!==1||k===!0;if(O&&(p!==tl||h!==tl)){var P=parseFloat(h)*Qc,R=Math.sin(P),E=Math.cos(P),L;P=parseFloat(p)*Qc,L=Math.cos(P),r=L1(M,r,R*L*-O),o=L1(M,o,-Math.sin(P)*-O),c=L1(M,c,E*L*-O+O)}w!==Md&&(A+="perspective("+w+il),(s||a)&&(A+="translate("+s+"%, "+a+"%) "),(C||r!==Md||o!==Md||c!==Md)&&(A+=c!==Md||C?"translate3d("+r+", "+o+", "+c+") ":"translate("+r+", "+o+il),d!==tl&&(A+="rotate("+d+il),h!==tl&&(A+="rotateY("+h+il),p!==tl&&(A+="rotateX("+p+il),(_!==tl||y!==tl)&&(A+="skew("+_+", "+y+il),(x!==1||v!==1)&&(A+="scale("+x+", "+v+il),M.style[oi]=A||"translate(0, 0)"},E7=function(e,t){var n=t||this,s=n.xPercent,a=n.yPercent,r=n.x,o=n.y,c=n.rotation,d=n.skewX,h=n.skewY,p=n.scaleX,_=n.scaleY,y=n.target,x=n.xOrigin,v=n.yOrigin,w=n.xOffset,k=n.yOffset,M=n.forceCSS,O=parseFloat(r),A=parseFloat(o),C,P,R,E,L;c=parseFloat(c),d=parseFloat(d),h=parseFloat(h),h&&(h=parseFloat(h),d+=h,c+=h),c||d?(c*=Qc,d*=Qc,C=Math.cos(c)*p,P=Math.sin(c)*p,R=Math.sin(c-d)*-_,E=Math.cos(c-d)*_,d&&(h*=Qc,L=Math.tan(d-h),L=Math.sqrt(1+L*L),R*=L,E*=L,h&&(L=Math.tan(h),L=Math.sqrt(1+L*L),C*=L,P*=L)),C=yi(C),P=yi(P),R=yi(R),E=yi(E)):(C=p,E=_,P=R=0),(O&&!~(r+"").indexOf("px")||A&&!~(o+"").indexOf("px"))&&(O=ko(y,"x",r,"px"),A=ko(y,"y",o,"px")),(x||v||w||k)&&(O=yi(O+x-(x*C+v*R)+w),A=yi(A+v-(x*P+v*E)+k)),(s||a)&&(L=y.getBBox(),O=yi(O+s/100*L.width),A=yi(A+a/100*L.height)),L="matrix("+C+","+P+","+R+","+E+","+O+","+A+")",y.setAttribute("transform",L),M&&(y.style[oi]=L)},D7=function(e,t,n,s,a){var r=360,o=Ii(a),c=parseFloat(a)*(o&&~a.indexOf("rad")?ol:1),d=c-s,h=s+d+"deg",p,_;return o&&(p=a.split("_")[1],p==="short"&&(d%=r,d!==d%(r/2)&&(d+=d<0?r:-r)),p==="cw"&&d<0?d=(d+r*hO)%r-~~(d/r)*r:p==="ccw"&&d>0&&(d=(d-r*hO)%r-~~(d/r)*r)),e._pt=_=new Xn(e._pt,t,n,s,d,y7),_.e=h,_.u="deg",e._props.push(n),_},xO=function(e,t){for(var n in t)e[n]=t[n];return e},U7=function(e,t,n){var s=xO({},n._gsap),a="perspective,force3D,transformOrigin,svgOrigin",r=n.style,o,c,d,h,p,_,y,x;s.svg?(d=n.getAttribute("transform"),n.setAttribute("transform",""),r[oi]=t,o=Rh(n,1),wo(n,oi),n.setAttribute("transform",d)):(d=getComputedStyle(n)[oi],r[oi]=t,o=Rh(n,1),r[oi]=d);for(c in xr)d=s[c],h=o[c],d!==h&&a.indexOf(c)<0&&(y=un(d),x=un(h),p=y!==x?ko(n,c,d,x):parseFloat(d),_=parseFloat(h),e._pt=new Xn(e._pt,o,c,p,_-p,sb),e._pt.u=x||0,e._props.push(c));xO(o,s)};Wn("padding,margin,Width,Radius",function(i,e){var t="Top",n="Right",s="Bottom",a="Left",r=(e<3?[t,n,s,a]:[t+a,t+n,s+n,s+a]).map(function(o){return e<2?i+o:"border"+o+i});Tg[e>1?"border"+i:i]=function(o,c,d,h,p){var _,y;if(arguments.length<4)return _=r.map(function(x){return or(o,x,d)}),y=_.join(" "),y.split(_[0]).length===5?_[0]:y;_=(h+"").split(" "),y={},r.forEach(function(x,v){return y[x]=_[v]=_[v]||_[(v-1)/2|0]}),o.init(c,y,p)}});var UP={name:"css",register:rb,targetTest:function(e){return e.style&&e.nodeType},init:function(e,t,n,s,a){var r=this._props,o=e.style,c=n.vars.startAt,d,h,p,_,y,x,v,w,k,M,O,A,C,P,R,E,L;i2||rb(),this.styles=this.styles||NP(e),E=this.styles.props,this.tween=n;for(v in t)if(v!=="autoRound"&&(h=t[v],!(cs[v]&&xP(v,t,n,s,e,a)))){if(y=typeof h,x=Tg[v],y==="function"&&(h=h.call(n,s,e,a),y=typeof h),y==="string"&&~h.indexOf("random(")&&(h=Oh(h)),x)x(this,e,v,h,n)&&(R=1);else if(v.substr(0,2)==="--")d=(getComputedStyle(e).getPropertyValue(v)+"").trim(),h+="",xo.lastIndex=0,xo.test(d)||(w=un(d),k=un(h),k?w!==k&&(d=ko(e,v,d,k)+k):w&&(h+=w)),this.add(o,"setProperty",d,h,s,a,0,0,v),r.push(v),E.push(v,0,o[v]);else if(y!=="undefined"){if(c&&v in c?(d=typeof c[v]=="function"?c[v].call(n,s,e,a):c[v],Ii(d)&&~d.indexOf("random(")&&(d=Oh(d)),un(d+"")||d==="auto"||(d+=ps.units[v]||un(or(e,v))||""),(d+"").charAt(1)==="="&&(d=or(e,v))):d=or(e,v),_=parseFloat(d),M=y==="string"&&h.charAt(1)==="="&&h.substr(0,2),M&&(h=h.substr(2)),p=parseFloat(h),v in Ta&&(v==="autoAlpha"&&(_===1&&or(e,"visibility")==="hidden"&&p&&(_=0),E.push("visibility",0,o.visibility),uo(this,o,"visibility",_?"inherit":"hidden",p?"inherit":"hidden",!p)),v!=="scale"&&v!=="transform"&&(v=Ta[v],~v.indexOf(",")&&(v=v.split(",")[0]))),O=v in xr,O){if(this.styles.save(v),L=h,y==="string"&&h.substring(0,6)==="var(--"){if(h=hs(e,h.substring(4,h.indexOf(")"))),h.substring(0,5)==="calc("){var D=e.style.perspective;e.style.perspective=h,h=hs(e,"perspective"),D?e.style.perspective=D:wo(e,"perspective")}p=parseFloat(h)}if(A||(C=e._gsap,C.renderTransform&&!t.parseTransform||Rh(e,t.parseTransform),P=t.smoothOrigin!==!1&&C.smooth,A=this._pt=new Xn(this._pt,o,oi,0,1,C.renderTransform,C,0,-1),A.dep=1),v==="scale")this._pt=new Xn(this._pt,C,"scaleY",C.scaleY,(M?Xc(C.scaleY,M+p):p)-C.scaleY||0,sb),this._pt.u=0,r.push("scaleY",v),v+="X";else if(v==="transformOrigin"){E.push(Gn,0,o[Gn]),h=P7(h),C.svg?ob(e,h,0,P,0,this):(k=parseFloat(h.split(" ")[2])||0,k!==C.zOrigin&&uo(this,C,"zOrigin",C.zOrigin,k),uo(this,o,v,Mg(d),Mg(h)));continue}else if(v==="svgOrigin"){ob(e,h,1,P,0,this);continue}else if(v in jP){D7(this,C,v,_,M?Xc(_,M+h):h);continue}else if(v==="smoothOrigin"){uo(this,C,"smooth",C.smooth,h);continue}else if(v==="force3D"){C[v]=h;continue}else if(v==="transform"){U7(this,h,e);continue}}else v in o||(v=uu(v)||v);if(O||(p||p===0)&&(_||_===0)&&!_7.test(h)&&v in o)w=(d+"").substr((_+"").length),p||(p=0),k=un(h)||(v in ps.units?ps.units[v]:w),w!==k&&(_=ko(e,v,d,k)),this._pt=new Xn(this._pt,O?C:o,v,_,(M?Xc(_,M+p):p)-_,!O&&(k==="px"||v==="zIndex")&&t.autoRound!==!1?v7:sb),this._pt.u=k||0,O&&L!==h?(this._pt.b=d,this._pt.e=L,this._pt.r=b7):w!==k&&k!=="%"&&(this._pt.b=d,this._pt.r=x7);else if(v in o)R7.call(this,e,v,d,M?M+h:h);else if(v in e)this.add(e,v,d||e[v],M?M+h:h,s,a);else if(v!=="parseTransform"){Wv(v,h);continue}O||(v in o?E.push(v,0,o[v]):typeof e[v]=="function"?E.push(v,2,e[v]()):E.push(v,1,d||e[v])),r.push(v)}}R&&AP(this)},render:function(e,t){if(t.tween._time||!n2())for(var n=t._pt;n;)n.r(e,n.d),n=n._next;else t.styles.revert()},get:or,aliases:Ta,getSetter:function(e,t,n){var s=Ta[t];return s&&s.indexOf(",")<0&&(t=s),t in xr&&t!==Gn&&(e._gsap.x||or(e,"x"))?n&&dO===n?t==="scale"?A7:k7:(dO=n||{})&&(t==="scale"?C7:O7):e.style&&!Kv(e.style[t])?S7:~t.indexOf("-")?w7:e2(e,t)},core:{_removeProperty:wo,_getMatrix:a2}};Qn.utils.checkPrefix=uu;Qn.core.getStyleSaver=NP;(function(i,e,t,n){var s=Wn(i+","+e+","+t,function(a){xr[a]=1});Wn(e,function(a){ps.units[a]="deg",jP[a]=1}),Ta[s[13]]=i+","+e,Wn(n,function(a){var r=a.split(":");Ta[r[1]]=s[r[0]]})})("x,y,z,scale,scaleX,scaleY,xPercent,yPercent","rotation,rotationX,rotationY,skewX,skewY","transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective","0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY");Wn("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(i){ps.units[i]="px"});Qn.registerPlugin(UP);var Jm=Qn.registerPlugin(UP)||Qn;Jm.core.Tween;const F7=.5,B7=.45,z7=.08;function q7({render:i,getRouteOrder:e,scrollContainerRef:t}){var w,k,M;const n=Vs(),s=N.useRef(null),a=N.useRef(null),r=N.useRef(0),[o,c]=N.useState(!1),[d,h]=N.useState("forward"),[p,_]=N.useState(()=>[{key:n.key,location:n,status:"current"}]),y=(k=(w=p[p.length-1])==null?void 0:w.key)!=null?k:n.key,x=(M=p[p.length-1])==null?void 0:M.location.pathname,v=N.useCallback(()=>t!=null&&t.current?t.current:typeof document=="undefined"?null:document.scrollingElement,[t]);return N.useEffect(()=>{var L;if(o||n.key===y||x===n.pathname)return;const O=v();r.current=(L=O==null?void 0:O.scrollTop)!=null?L:0;const A=D=>{if(!e||!D)return null;const q=e(D);return typeof q=="number"&&q>=0?q:null},C=A(x),P=A(n.pathname),R=C===null||P===null||C===P||P>C?"forward":"backward";let E=!1;return queueMicrotask(()=>{E||(h(R),_(D=>{const q=D[D.length-1];return[q?ee(z({},q),{status:"exiting"}):{key:n.key,location:n,status:"exiting"},{key:n.key,location:n,status:"current"}]}),c(!0))}),()=>{E=!0}},[o,n,y,x,e,v]),N.useLayoutEffect(()=>{var B;if(!o||!s.current)return;const O=v(),A=r.current;O&&A>0&&O.scrollTo({top:0,left:0,behavior:"auto"});const C=(B=O==null?void 0:O.clientHeight)!=null?B:0,P=typeof window=="undefined"?0:window.innerHeight,R=Math.max(C,P,1),E=d==="forward"?R:-R,L=d==="forward"?-R:R,D=A?-A:0,q=Jm.timeline({onComplete:()=>{_(H=>H.filter(W=>W.status!=="exiting")),c(!1)}});return a.current&&(Jm.set(a.current,{y:D}),q.fromTo(a.current,{y:D,opacity:1},{y:D+L,opacity:0,duration:B7,ease:"power2.in",force3D:!0},0)),q.fromTo(s.current,{y:E,opacity:0},{y:0,opacity:1,duration:F7,ease:"power2.out",clearProps:"transform,opacity",force3D:!0},z7),()=>{q.kill(),Jm.killTweensOf([s.current,a.current])}},[o,d,v]),g.jsx("div",{className:`page-transition${o?" page-transition--animating":""}`,children:p.map(O=>g.jsx("div",{className:`page-transition__layer${O.status==="exiting"?" page-transition__layer--exit":""}`,ref:O.status==="exiting"?a:s,children:i(O.location)},O.key))})}const lb={fetchConfigYaml(){return pe(this,null,function*(){const e=(yield Ce.getRaw("/config.yaml",{responseType:"text",headers:{Accept:"application/yaml, text/yaml, text/plain"}})).data;return typeof e=="string"?e:e==null?"":String(e)})},saveConfigYaml(i){return pe(this,null,function*(){yield Ce.put("/config.yaml",i,{headers:{"Content-Type":"application/yaml",Accept:"application/json, text/plain, */*"}})})}},Yc={list(){return pe(this,null,function*(){var t;const i=yield Ce.get("/api-keys"),e=i&&((t=i["api-keys"])!=null?t:i.apiKeys);return Array.isArray(e)?e:[]})},replace:i=>Ce.put("/api-keys",i),update:(i,e)=>Ce.patch("/api-keys",{index:i,value:e}),delete:i=>Ce.delete(`/api-keys?index=${i}`)},nr={getAmpcode(){return pe(this,null,function*(){var e;const i=yield Ce.get("/ampcode");return(e=UR(i))!=null?e:{}})},updateUpstreamUrl:i=>Ce.put("/ampcode/upstream-url",{value:i}),clearUpstreamUrl:()=>Ce.delete("/ampcode/upstream-url"),updateUpstreamApiKey:i=>Ce.put("/ampcode/upstream-api-key",{value:i}),clearUpstreamApiKey:()=>Ce.delete("/ampcode/upstream-api-key"),getModelMappings(){return pe(this,null,function*(){var t,n,s;const i=yield Ce.get("/ampcode/model-mappings"),e=(s=(n=(t=i==null?void 0:i["model-mappings"])!=null?t:i==null?void 0:i.modelMappings)!=null?n:i==null?void 0:i.items)!=null?s:i;return DR(e)})},saveModelMappings:i=>Ce.put("/ampcode/model-mappings",{value:i}),patchModelMappings:i=>Ce.patch("/ampcode/model-mappings",{value:i}),clearModelMappings:()=>Ce.delete("/ampcode/model-mappings"),deleteModelMappings:i=>Ce.delete("/ampcode/model-mappings",{data:{value:i}}),updateForceModelMappings:i=>Ce.put("/ampcode/force-model-mappings",{value:i})},ff=i=>i&&Object.keys(i).length?i:void 0,FP=i=>Array.isArray(i)?i.map(e=>{if(!(e!=null&&e.name))return null;const t={name:e.name};return e.alias&&e.alias!==e.name&&(t.alias=e.alias),e.priority!==void 0&&(t.priority=e.priority),e.testModel&&(t["test-model"]=e.testModel),t}).filter(Boolean):void 0,H7=i=>{const e={"api-key":i.apiKey};i.proxyUrl&&(e["proxy-url"]=i.proxyUrl);const t=ff(i.headers);return t&&(e.headers=t),e},tm=i=>{var s;const e={"api-key":i.apiKey};(s=i.prefix)!=null&&s.trim()&&(e.prefix=i.prefix.trim()),i.baseUrl&&(e["base-url"]=i.baseUrl),i.proxyUrl&&(e["proxy-url"]=i.proxyUrl);const t=ff(i.headers);t&&(e.headers=t);const n=FP(i.models);return n&&n.length&&(e.models=n),i.excludedModels&&i.excludedModels.length&&(e["excluded-models"]=i.excludedModels),e},K7=i=>Array.isArray(i)?i.map(e=>{const t=typeof(e==null?void 0:e.name)=="string"?e.name.trim():"",n=typeof(e==null?void 0:e.alias)=="string"?e.alias.trim():"";return!t||!n?null:{name:t,alias:n}}).filter(Boolean):void 0,bO=i=>{var s;const e={"api-key":i.apiKey};(s=i.prefix)!=null&&s.trim()&&(e.prefix=i.prefix.trim()),i.baseUrl&&(e["base-url"]=i.baseUrl),i.proxyUrl&&(e["proxy-url"]=i.proxyUrl);const t=ff(i.headers);t&&(e.headers=t);const n=K7(i.models);return n&&n.length&&(e.models=n),e},vO=i=>{var n;const e={"api-key":i.apiKey};(n=i.prefix)!=null&&n.trim()&&(e.prefix=i.prefix.trim()),i.baseUrl&&(e["base-url"]=i.baseUrl);const t=ff(i.headers);return t&&(e.headers=t),i.excludedModels&&i.excludedModels.length&&(e["excluded-models"]=i.excludedModels),e},SO=i=>{var s;const e={name:i.name,"base-url":i.baseUrl,"api-key-entries":Array.isArray(i.apiKeyEntries)?i.apiKeyEntries.map(a=>H7(a)):[]};(s=i.prefix)!=null&&s.trim()&&(e.prefix=i.prefix.trim());const t=ff(i.headers);t&&(e.headers=t);const n=FP(i.models);return n&&n.length&&(e.models=n),i.priority!==void 0&&(e.priority=i.priority),i.testModel&&(e["test-model"]=i.testModel),e},qi={getGeminiKeys(){return pe(this,null,function*(){var t,n;const i=yield Ce.get("/gemini-api-key"),e=i&&((n=(t=i["gemini-api-key"])!=null?t:i.items)!=null?n:i);return Array.isArray(e)?e.map(s=>jR(s)).filter(Boolean):[]})},saveGeminiKeys:i=>Ce.put("/gemini-api-key",i.map(e=>vO(e))),updateGeminiKey:(i,e)=>Ce.patch("/gemini-api-key",{index:i,value:vO(e)}),deleteGeminiKey:i=>Ce.delete(`/gemini-api-key?api-key=${encodeURIComponent(i)}`),getCodexConfigs(){return pe(this,null,function*(){var t,n;const i=yield Ce.get("/codex-api-key"),e=i&&((n=(t=i["codex-api-key"])!=null?t:i.items)!=null?n:i);return Array.isArray(e)?e.map(s=>Wc(s)).filter(Boolean):[]})},saveCodexConfigs:i=>Ce.put("/codex-api-key",i.map(e=>tm(e))),updateCodexConfig:(i,e)=>Ce.patch("/codex-api-key",{index:i,value:tm(e)}),deleteCodexConfig:i=>Ce.delete(`/codex-api-key?api-key=${encodeURIComponent(i)}`),getClaudeConfigs(){return pe(this,null,function*(){var t,n;const i=yield Ce.get("/claude-api-key"),e=i&&((n=(t=i["claude-api-key"])!=null?t:i.items)!=null?n:i);return Array.isArray(e)?e.map(s=>Wc(s)).filter(Boolean):[]})},saveClaudeConfigs:i=>Ce.put("/claude-api-key",i.map(e=>tm(e))),updateClaudeConfig:(i,e)=>Ce.patch("/claude-api-key",{index:i,value:tm(e)}),deleteClaudeConfig:i=>Ce.delete(`/claude-api-key?api-key=${encodeURIComponent(i)}`),getVertexConfigs(){return pe(this,null,function*(){var t,n;const i=yield Ce.get("/vertex-api-key"),e=i&&((n=(t=i["vertex-api-key"])!=null?t:i.items)!=null?n:i);return Array.isArray(e)?e.map(s=>Wc(s)).filter(Boolean):[]})},saveVertexConfigs:i=>Ce.put("/vertex-api-key",i.map(e=>bO(e))),updateVertexConfig:(i,e)=>Ce.patch("/vertex-api-key",{index:i,value:bO(e)}),deleteVertexConfig:i=>Ce.delete(`/vertex-api-key?api-key=${encodeURIComponent(i)}`),getOpenAIProviders(){return pe(this,null,function*(){var t,n;const i=yield Ce.get("/openai-compatibility"),e=i&&((n=(t=i["openai-compatibility"])!=null?t:i.items)!=null?n:i);return Array.isArray(e)?e.map(s=>ER(s)).filter(Boolean):[]})},saveOpenAIProviders:i=>Ce.put("/openai-compatibility",i.map(e=>SO(e))),updateOpenAIProvider:(i,e)=>Ce.patch("/openai-compatibility",{index:i,value:SO(e)}),deleteOpenAIProvider:i=>Ce.delete(`/openai-compatibility?name=${encodeURIComponent(i)}`)},wO=i=>{var n,s;if(!i||typeof i!="object")return{};const e=(s=(n=i["oauth-excluded-models"])!=null?n:i.items)!=null?s:i;if(!e||typeof e!="object")return{};const t={};return Object.entries(e).forEach(([a,r])=>{const o=String(a!=null?a:"").trim().toLowerCase();if(!o)return;const c=Array.isArray(r)?r:typeof r=="string"?r.split(/[\n,]+/):[],d=new Set,h=[];c.forEach(p=>{const _=String(p!=null?p:"").trim();if(!_)return;const y=_.toLowerCase();d.has(y)||(d.add(y),h.push(_))}),t[o]=h}),t},zi={list:()=>Ce.get("/auth-files"),upload:i=>{const e=new FormData;return e.append("file",i,i.name),Ce.postForm("/auth-files",e)},deleteFile:i=>Ce.delete(`/auth-files?name=${encodeURIComponent(i)}`),deleteAll:()=>Ce.delete("/auth-files",{params:{all:!0}}),getOauthExcludedModels(){return pe(this,null,function*(){const i=yield Ce.get("/oauth-excluded-models");return wO(i)})},saveOauthExcludedModels:(i,e)=>Ce.patch("/oauth-excluded-models",{provider:i,models:e}),deleteOauthExcludedEntry:i=>Ce.delete(`/oauth-excluded-models?provider=${encodeURIComponent(i)}`),replaceOauthExcludedModels:i=>Ce.put("/oauth-excluded-models",wO(i)),getOauthModelMappings(){return pe(this,null,function*(){var n,s;const i=yield Ce.get("/oauth-model-mappings"),e=i&&((s=(n=i["oauth-model-mappings"])!=null?n:i.items)!=null?s:i);if(!e||typeof e!="object")return{};const t={};return Object.entries(e).forEach(([a,r])=>{if(!Array.isArray(r))return;const o=r.map(c=>{var _,y,x,v;if(!c||typeof c!="object")return null;const d=String((x=(y=(_=c.name)!=null?_:c.id)!=null?y:c.model)!=null?x:"").trim(),h=String((v=c.alias)!=null?v:"").trim();if(!d||!h)return null;const p=c.fork===!0;return p?{name:d,alias:h,fork:p}:{name:d,alias:h}}).filter(Boolean);o.length&&(t[a]=o)}),t})},saveOauthModelMappings:(i,e)=>Ce.patch("/oauth-model-mappings",{channel:i,mappings:e}),deleteOauthModelMappings:i=>Ce.delete(`/oauth-model-mappings?channel=${encodeURIComponent(i)}`),getModelsForAuthFile(i){return pe(this,null,function*(){const e=yield Ce.get(`/auth-files/models?name=${encodeURIComponent(i)}`);return e&&Array.isArray(e.models)?e.models:[]})}},V7=["codex","anthropic","antigravity","gemini-cli"],I7={"gemini-cli":"gemini"},im={startAuth:(i,e)=>{const t={};return V7.includes(i)&&(t.is_webui=!0),i==="gemini-cli"&&(e!=null&&e.projectId)&&(t.project_id=e.projectId),Ce.get(`/${i}-auth-url`,{params:Object.keys(t).length?t:void 0})},getAuthStatus:i=>Ce.get("/get-auth-status",{params:{state:i}}),submitCallback:(i,e)=>{var n;const t=(n=I7[i])!=null?n:i;return Ce.post("/oauth-callback",{provider:t,redirect_url:e})},iflowCookieAuth:i=>Ce.post("/iflow-auth-url",{cookie:i})};function pn(i){if(!i)return"";const e=2,t=i.slice(0,e),n=i.slice(-e),s=Math.max(i.length-e*2,1),a="*".repeat(s);return`${t}${a}${n}`}function kO(i){if(i===0)return"0 B";const e=["B","KB","MB","GB"],t=1024,n=Math.floor(Math.log(i)/Math.log(t));return`${(i/Math.pow(t,n)).toFixed(2)} ${e[n]}`}function W7(i,e){if(i==null||i==="")return"";const t=typeof i=="number"?i:Number(i),n=(()=>{if(!Number.isFinite(t)||Number.isNaN(t))return new Date(String(i));const s=Math.abs(t);return s<1e11?new Date(t*1e3):s<1e14?new Date(t):s<1e17?new Date(Math.round(t/1e3)):new Date(Math.round(t/1e6))})();return Number.isNaN(n.getTime())?"":e?n.toLocaleString(e):n.toLocaleString()}const j1=1e6,BP="cli-proxy-model-prices-v2",X7=i=>{if(typeof i=="number"&&Number.isFinite(i))return i.toString();if(typeof i=="string"){const e=i.trim();return e||null}return null};function zP(i,e=pn){if(i==null)return"";const t=typeof i=="string"?i:String(i);if(!t)return"";let n=t;const s=/([?&])(api[-_]?key|key|token|access_token|authorization)=([^&#\s]+)/gi;n=n.replace(s,(o,c,d,h)=>`${c}${d}=${e(h)}`);const a=/(api[-_]?key|key|token|access[-_]?token|authorization)\s*([:=])\s*([A-Za-z0-9._-]+)/gi;n=n.replace(a,(o,c,d,h)=>`${c}${d}${e(h)}`);const r=/(sk-[A-Za-z0-9]{6,}|AI[a-zA-Z0-9_-]{6,}|AIza[0-9A-Za-z-_]{8,}|hf_[A-Za-z0-9]{6,}|pk_[A-Za-z0-9]{6,}|rk_[A-Za-z0-9]{6,})/g;if(n=n.replace(r,o=>e(o)),n===t){const o=t.trim();if(o&&!/\s/.test(o)&&(/^sk-/i.test(o)||/^AI/i.test(o)||/^AIza/i.test(o)||/^hf_/i.test(o)||/^pk_/i.test(o)||/^rk_/i.test(o)||!/[\\/]/.test(o)&&(/\d/.test(o)||o.length>=10)||o.length>=24))return e(o)}return n}function ro(i){const e=Number(i);return Number.isFinite(e)?`${(e/1e6).toFixed(2)}M`:"0.00M"}function AO(i){const e=Number(i);if(!Number.isFinite(e))return"0.00";const t=Math.abs(e);return t>=1e3?Math.round(e).toLocaleString():t>=100?e.toFixed(0):t>=10?e.toFixed(1):e.toFixed(2)}function r2(i){const e=Number(i);if(!Number.isFinite(e))return"$0.00";const t=e.toFixed(2);return`$${Number(t).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function Po(i){if(!i)return[];const e=i.apis||{},t=[];return Object.values(e).forEach(n=>{const s=(n==null?void 0:n.models)||{};Object.entries(s).forEach(([a,r])=>{(Array.isArray(r.details)?r.details:[]).forEach(c=>{c&&c.timestamp&&t.push(ee(z({},c),{__modelName:a}))})})}),t}function A0(i){const e=(i==null?void 0:i.tokens)||{};if(typeof e.total_tokens=="number")return e.total_tokens;const t=typeof e.input_tokens=="number"?e.input_tokens:0,n=typeof e.output_tokens=="number"?e.output_tokens:0,s=typeof e.reasoning_tokens=="number"?e.reasoning_tokens:0,a=Math.max(typeof e.cached_tokens=="number"?Math.max(e.cached_tokens,0):0,typeof e.cache_tokens=="number"?Math.max(e.cache_tokens,0):0);return t+n+s+a}function G7(i){const e=Po(i);if(!e.length)return{cachedTokens:0,reasoningTokens:0};let t=0,n=0;return e.forEach(s=>{const a=(s==null?void 0:s.tokens)||{};t+=Math.max(typeof a.cached_tokens=="number"?Math.max(a.cached_tokens,0):0,typeof a.cache_tokens=="number"?Math.max(a.cache_tokens,0):0),typeof a.reasoning_tokens=="number"&&(n+=a.reasoning_tokens)}),{cachedTokens:t,reasoningTokens:n}}function Q7(i=30,e){const t=Po(e),n=Number.isFinite(i)&&i>0?i:30;if(!t.length)return{rpm:0,tpm:0,windowMinutes:n,requestCount:0,tokenCount:0};const a=Date.now()-n*60*1e3;let r=0,o=0;t.forEach(d=>{const h=Date.parse(d.timestamp);Number.isNaN(h)||h0?n:1;return{rpm:r/c,tpm:o/c,windowMinutes:n,requestCount:r,tokenCount:o}}function Y7(i){if(!i)return[];const e=i.apis||{},t=new Set;return Object.values(e).forEach(n=>{const s=(n==null?void 0:n.models)||{};Object.keys(s).forEach(a=>{a&&t.add(a)})}),Array.from(t).sort((n,s)=>n.localeCompare(s))}function o2(i,e){const t=i.__modelName||"",n=e[t];if(!n)return 0;const s=(i==null?void 0:i.tokens)||{},a=Number(s.input_tokens),r=Number(s.output_tokens),o=Number(s.cached_tokens),c=Number(s.cache_tokens),d=Number.isFinite(a)?Math.max(a,0):0,h=Number.isFinite(r)?Math.max(r,0):0,p=Math.max(Number.isFinite(o)?Math.max(o,0):0,Number.isFinite(c)?Math.max(c,0):0),y=Math.max(d-p,0)/j1*(Number(n.prompt)||0),x=p/j1*(Number(n.cache)||0),v=h/j1*(Number(n.completion)||0),w=y+x+v;return Number.isFinite(w)&&w>0?w:0}function Z7(i,e){const t=Po(i);return!t.length||!Object.keys(e).length?0:t.reduce((n,s)=>n+o2(s,e),0)}function J7(){try{if(typeof localStorage=="undefined")return{};const i=localStorage.getItem(BP);if(!i)return{};const e=JSON.parse(i);if(!e||typeof e!="object")return{};const t={};return Object.entries(e).forEach(([n,s])=>{if(!n)return;const a=Number(s==null?void 0:s.prompt),r=Number(s==null?void 0:s.completion),o=Number(s==null?void 0:s.cache);if(!Number.isFinite(a)&&!Number.isFinite(r)&&!Number.isFinite(o))return;const c=Number.isFinite(a)&&a>=0?a:0,d=Number.isFinite(r)&&r>=0?r:0,h=Number.isFinite(o)&&o>=0?o:Number.isFinite(a)&&a>=0?a:c;t[n]={prompt:c,completion:d,cache:h}}),t}catch(i){return{}}}function $7(i){try{if(typeof localStorage=="undefined")return;localStorage.setItem(BP,JSON.stringify(i))}catch(e){console.warn("保存模型价格失败")}}function eq(i,e){if(!(i!=null&&i.apis))return[];const t=i.apis,n=[];return Object.entries(t).forEach(([s,a])=>{const r={};let o=0;const c=(a==null?void 0:a.models)||{};Object.entries(c).forEach(([d,h])=>{r[d]={requests:h.total_requests||0,tokens:h.total_tokens||0},e[d]&&(Array.isArray(h.details)?h.details:[]).forEach(y=>{o+=o2(ee(z({},y),{__modelName:d}),e)})}),n.push({endpoint:zP(s)||s,totalRequests:a.total_requests||0,totalTokens:a.total_tokens||0,totalCost:o,models:r})}),n}function tq(i,e){if(!(i!=null&&i.apis))return[];const t=new Map;return Object.values(i.apis).forEach(n=>{const s=(n==null?void 0:n.models)||{};Object.entries(s).forEach(([a,r])=>{const o=t.get(a)||{requests:0,tokens:0,cost:0};o.requests+=r.total_requests||0,o.tokens+=r.total_tokens||0,e[a]&&(Array.isArray(r.details)?r.details:[]).forEach(h=>{o.cost+=o2(ee(z({},h),{__modelName:a}),e)}),t.set(a,o)})}),Array.from(t.entries()).map(([n,s])=>z({model:n},s)).sort((n,s)=>s.requests-n.requests)}function iq(i){if(!(i instanceof Date))return"";const e=(i.getMonth()+1).toString().padStart(2,"0"),t=i.getDate().toString().padStart(2,"0"),n=i.getHours().toString().padStart(2,"0");return`${e}-${t} ${n}:00`}function nq(i){if(!(i instanceof Date))return"";const e=i.getFullYear(),t=(i.getMonth()+1).toString().padStart(2,"0"),n=i.getDate().toString().padStart(2,"0");return`${e}-${t}-${n}`}function sq(i,e="requests"){const n=new Date,s=new Date(n);s.setMinutes(0,0,0);const a=new Date(s);a.setHours(a.getHours()-23);const r=a.getTime(),o=[];for(let p=0;p<24;p++){const _=r+p*36e5;o.push(iq(new Date(_)))}const c=Po(i),d=new Map;let h=!1;return c.length?(c.forEach(p=>{const _=Date.parse(p.timestamp);if(Number.isNaN(_))return;const y=new Date(_);y.setMinutes(0,0,0);const x=y.getTime(),v=r+(o.length-1)*36e5;if(xv)return;const w=Math.floor((x-r)/36e5);if(w<0||w>=o.length)return;const k=p.__modelName||"Unknown";d.has(k)||d.set(k,new Array(o.length).fill(0));const M=d.get(k);e==="tokens"?M[w]+=A0(p):M[w]+=1,h=!0}),{labels:o,dataByModel:d,hasData:h}):{labels:o,dataByModel:d,hasData:h}}function aq(i,e="requests"){const t=Po(i),n=new Map,s=new Set;let a=!1;if(!t.length)return{labels:[],dataByModel:new Map,hasData:a};t.forEach(c=>{const d=Date.parse(c.timestamp);if(Number.isNaN(d))return;const h=nq(new Date(d));if(!h)return;const p=c.__modelName||"Unknown";n.has(p)||n.set(p,new Map);const _=n.get(p),y=e==="tokens"?A0(c):1;_.set(h,(_.get(h)||0)+y),s.add(h),a=!0});const r=Array.from(s).sort(),o=new Map;return n.forEach((c,d)=>{const h=r.map(p=>c.get(p)||0);o.set(d,h)}),{labels:r,dataByModel:o,hasData:a}}const CO=[{borderColor:"#3b82f6",backgroundColor:"rgba(59, 130, 246, 0.15)"},{borderColor:"#22c55e",backgroundColor:"rgba(34, 197, 94, 0.15)"},{borderColor:"#f59e0b",backgroundColor:"rgba(245, 158, 11, 0.15)"},{borderColor:"#ef4444",backgroundColor:"rgba(239, 68, 68, 0.15)"},{borderColor:"#8b5cf6",backgroundColor:"rgba(139, 92, 246, 0.15)"},{borderColor:"#06b6d4",backgroundColor:"rgba(6, 182, 212, 0.15)"},{borderColor:"#ec4899",backgroundColor:"rgba(236, 72, 153, 0.15)"},{borderColor:"#84cc16",backgroundColor:"rgba(132, 204, 22, 0.15)"},{borderColor:"#f97316",backgroundColor:"rgba(249, 115, 22, 0.15)"}],rq=(i,e,t)=>Math.min(Math.max(i,e),t),oq=i=>{const e=i.trim().replace("#","");if(e.length!==6)return null;const t=Number.parseInt(e.slice(0,2),16),n=Number.parseInt(e.slice(2,4),16),s=Number.parseInt(e.slice(4,6),16);return[t,n,s].every(a=>Number.isFinite(a))?{r:t,g:n,b:s}:null},E1=(i,e)=>{const t=oq(i);if(!t)return i;const n=rq(e,0,1);return`rgba(${t.r}, ${t.g}, ${t.b}, ${n})`},lq=(i,e,t)=>{const n=i.chart,s=n.ctx,a=n.chartArea;if(!a)return t;const r=s.createLinearGradient(0,a.top,0,a.bottom);return r.addColorStop(0,E1(e,.28)),r.addColorStop(.6,E1(e,.12)),r.addColorStop(1,E1(e,.02)),r};function OO(i,e="day",t="requests",n=[]){const s=e==="hour"?sq(i,t):aq(i,t),{labels:a,dataByModel:r}=s,o=()=>{const h=new Array(a.length).fill(0);return r.forEach(p=>{p.forEach((_,y)=>{h[y]=(h[y]||0)+_})}),h},c=n.length>0?n:["all"],d=c.map((h,p)=>{const _=h==="all",y=_?o():r.get(h)||new Array(a.length).fill(0),x=p%CO.length,v=CO[x],w=c.length===1||_&&c.length>1;return{label:_?"All Models":h,data:y,borderColor:v.borderColor,backgroundColor:w?k=>lq(k,v.borderColor,v.backgroundColor):v.backgroundColor,pointBackgroundColor:v.borderColor,pointBorderColor:v.borderColor,fill:w,tension:.35}});return{labels:a,datasets:d}}function qs(i,e,t){const r=Date.now(),o=r-36e5,c=Array.from({length:20},()=>({success:0,failure:0}));let d=0,h=0;i.forEach(x=>{const v=Date.parse(x.timestamp);if(Number.isNaN(v)||vr||e!==void 0&&x.source!==e)return;const w=r-v,k=19-Math.floor(w/3e5);k>=0&&k<20&&(x.failed?(c[k].failure+=1,h+=1):(c[k].success+=1,d+=1))});const p=c.map(x=>x.success===0&&x.failure===0?"idle":x.failure===0?"success":x.success===0?"failure":"mixed"),_=d+h,y=_>0?d/_*100:100;return{blocks:p,successRate:y,totalSuccess:d,totalFailure:h}}function cq(i,e=pn){if(!i)return{bySource:{},byAuthIndex:{}};const t={},n={},s=(r,o)=>(r[o]||(r[o]={success:0,failure:0}),r[o]),a=i.apis||{};return Object.values(a).forEach(r=>{const o=(r==null?void 0:r.models)||{};Object.values(o).forEach(c=>{((c==null?void 0:c.details)||[]).forEach(h=>{const p=zP(h==null?void 0:h.source,e),_=X7(h==null?void 0:h.auth_index),y=(h==null?void 0:h.failed)===!0;if(p){const x=s(t,p);y?x.failure+=1:x.success+=1}if(_){const x=s(n,_);y?x.failure+=1:x.success+=1}})})}),{bySource:t,byAuthIndex:n}}const nm=60*1e3,Ml={getUsage:()=>Ce.get("/usage",{timeout:nm}),exportUsage:()=>Ce.get("/usage/export",{timeout:nm}),importUsage:i=>Ce.post("/usage/import",i,{timeout:nm}),getKeyStats(i){return pe(this,null,function*(){var t;let e=i;if(!e){const n=yield Ce.get("/usage",{timeout:nm});e=(t=n==null?void 0:n.usage)!=null?t:n}return cq(e)})}},Nd={fetchLogs:(i={})=>Ce.get("/logs",{params:i,timeout:Zp}),clearLogs:()=>Ce.delete("/logs"),fetchErrorLogs:()=>Ce.get("/request-error-logs",{timeout:Zp}),downloadErrorLog:i=>Ce.getRaw(`/request-error-logs/${encodeURIComponent(i)}`,{responseType:"blob",timeout:Zp}),downloadRequestLogById:i=>Ce.getRaw(`/request-log-by-id/${encodeURIComponent(i)}`,{responseType:"blob",timeout:Zp})},uq={checkLatest:()=>Ce.get("/latest-version")},dq={importCredential:(i,e)=>{const t=new FormData;return t.append("file",i),e&&t.append("location",e),Ce.postForm("/vertex/import",t)}},hq="DashboardPage-module__dashboard___c-JEy",fq="DashboardPage-module__header___DrpYQ",pq="DashboardPage-module__title___aKMJy",mq="DashboardPage-module__subtitle___o9pSe",gq="DashboardPage-module__connectionCard___6o2zO",_q="DashboardPage-module__connectionStatus___UhJ2s",yq="DashboardPage-module__statusDot___4w7W-",xq="DashboardPage-module__connected___CeELY",bq="DashboardPage-module__connecting___j03PZ",vq="DashboardPage-module__disconnected___3l11q",Sq="DashboardPage-module__statusText___QDIvv",wq="DashboardPage-module__connectionInfo___oh7A1",kq="DashboardPage-module__serverUrl___9-jgp",Aq="DashboardPage-module__serverVersion___fmQMs",Cq="DashboardPage-module__buildDate___zr4hY",Oq="DashboardPage-module__statsGrid___y7hZp",Tq="DashboardPage-module__statCard___Du41R",Mq="DashboardPage-module__statIcon___EmbpQ",Nq="DashboardPage-module__statContent___IJemf",Rq="DashboardPage-module__statValue___w491L",Pq="DashboardPage-module__statLabel___b-2c9",Lq="DashboardPage-module__statSublabel___0oB31",jq="DashboardPage-module__section___i4jzh",Eq="DashboardPage-module__sectionTitle___uLbzI",Dq="DashboardPage-module__configGrid___5UhRW",Uq="DashboardPage-module__configItem___NBY1m",Fq="DashboardPage-module__configLabel___RoXI2",Bq="DashboardPage-module__configValue___6vWwa",zq="DashboardPage-module__enabled___R3JFn",qq="DashboardPage-module__disabled___ievwL",Hq="DashboardPage-module__configValueMono___tc-ax",Kq="DashboardPage-module__configItemFull___Apt9u",Vq="DashboardPage-module__viewMoreLink___wKvoJ",ze={dashboard:hq,header:fq,title:pq,subtitle:mq,connectionCard:gq,connectionStatus:_q,statusDot:yq,connected:xq,connecting:bq,disconnected:vq,statusText:Sq,connectionInfo:wq,serverUrl:kq,serverVersion:Aq,buildDate:Cq,statsGrid:Oq,statCard:Tq,statIcon:Mq,statContent:Nq,statValue:Rq,statLabel:Pq,statSublabel:Lq,section:jq,sectionTitle:Eq,configGrid:Dq,configItem:Uq,configLabel:Fq,configValue:Bq,enabled:zq,disabled:qq,configValueMono:Hq,configItemFull:Kq,viewMoreLink:Vq};function TO(){var E,L,D,q,B,H,W,V,U,G,$;const{t:i,i18n:e}=rt(),t=Ct(ie=>ie.connectionStatus),n=Ct(ie=>ie.serverVersion),s=Ct(ie=>ie.serverBuildDate),a=Ct(ie=>ie.apiBase),r=Wt(ie=>ie.config),o=_l(ie=>ie.models),c=_l(ie=>ie.loading),d=_l(ie=>ie.fetchModels),[h,p]=N.useState({apiKeys:null,authFiles:null}),[_,y]=N.useState({gemini:null,codex:null,claude:null,openai:null}),[x,v]=N.useState(!0),w=N.useRef([]);N.useEffect(()=>{w.current=[]},[a,r==null?void 0:r.apiKeys]);const k=ie=>{if(!Array.isArray(ie))return[];const ue=new Set,F=[];return ie.forEach(Y=>{var me,Se;const ce=typeof Y=="string"?Y:(Se=(me=Y==null?void 0:Y["api-key"])!=null?me:Y==null?void 0:Y.apiKey)!=null?Se:"",J=String(ce||"").trim();!J||ue.has(J)||(ue.add(J),F.push(J))}),F},M=N.useCallback(()=>pe(null,null,function*(){if(w.current.length)return w.current;const ie=k(r==null?void 0:r.apiKeys);if(ie.length)return w.current=ie,ie;try{const ue=yield Yc.list(),F=k(ue);return F.length&&(w.current=F),F}catch(ue){return[]}}),[r==null?void 0:r.apiKeys]),O=N.useCallback(()=>pe(null,null,function*(){if(!(t!=="connected"||!a))try{const ue=(yield M())[0];yield d(a,ue)}catch(ie){}}),[t,a,M,d]);N.useEffect(()=>{t==="connected"?(pe(null,null,function*(){v(!0);try{const[ue,F,Y,ce,J,me]=yield Promise.allSettled([Yc.list(),zi.list(),qi.getGeminiKeys(),qi.getCodexConfigs(),qi.getClaudeConfigs(),qi.getOpenAIProviders()]);p({apiKeys:ue.status==="fulfilled"?ue.value.length:null,authFiles:F.status==="fulfilled"?F.value.files.length:null}),y({gemini:Y.status==="fulfilled"?Y.value.length:null,codex:ce.status==="fulfilled"?ce.value.length:null,claude:J.status==="fulfilled"?J.value.length:null,openai:me.status==="fulfilled"?me.value.length:null})}finally{v(!1)}}),O()):v(!1)},[t,O]);const A=_.gemini!==null&&_.codex!==null&&_.claude!==null&&_.openai!==null,C=_.gemini!==null||_.codex!==null||_.claude!==null||_.openai!==null,P=A?((E=_.gemini)!=null?E:0)+((L=_.codex)!=null?L:0)+((D=_.claude)!=null?D:0)+((q=_.openai)!=null?q:0):0,R=[{label:i("nav.api_keys"),value:(B=h.apiKeys)!=null?B:"-",icon:g.jsx(XN,{size:24}),path:"/api-keys",loading:x&&h.apiKeys===null,sublabel:i("dashboard.management_keys")},{label:i("nav.ai_providers"),value:x?"-":A?P:"-",icon:g.jsx(Lv,{size:24}),path:"/ai-providers",loading:x,sublabel:C?i("dashboard.provider_keys_detail",{gemini:(H=_.gemini)!=null?H:"-",codex:(W=_.codex)!=null?W:"-",claude:(V=_.claude)!=null?V:"-",openai:(U=_.openai)!=null?U:"-"}):void 0},{label:i("nav.auth_files"),value:(G=h.authFiles)!=null?G:"-",icon:g.jsx(GN,{size:24}),path:"/auth-files",loading:x&&h.authFiles===null,sublabel:i("dashboard.oauth_credentials")},{label:i("dashboard.available_models"),value:c?"-":o.length,icon:g.jsx(tR,{size:24}),path:"/system",loading:c,sublabel:i("dashboard.available_models_desc")}];return g.jsxs("div",{className:ze.dashboard,children:[g.jsxs("div",{className:ze.header,children:[g.jsx("h1",{className:ze.title,children:i("dashboard.title")}),g.jsx("p",{className:ze.subtitle,children:i("dashboard.subtitle")})]}),g.jsxs("div",{className:ze.connectionCard,children:[g.jsxs("div",{className:ze.connectionStatus,children:[g.jsx("span",{className:`${ze.statusDot} ${t==="connected"?ze.connected:t==="connecting"?ze.connecting:ze.disconnected}`}),g.jsx("span",{className:ze.statusText,children:i(t==="connected"?"common.connected":t==="connecting"?"common.connecting":"common.disconnected")})]}),g.jsxs("div",{className:ze.connectionInfo,children:[g.jsx("span",{className:ze.serverUrl,children:a||"-"}),n&&g.jsxs("span",{className:ze.serverVersion,children:["v",n.trim().replace(/^[vV]+/,"")]}),s&&g.jsx("span",{className:ze.buildDate,children:new Date(s).toLocaleDateString(e.language)})]})]}),g.jsx("div",{className:ze.statsGrid,children:R.map(ie=>g.jsxs(_g,{to:ie.path,className:ze.statCard,children:[g.jsx("div",{className:ze.statIcon,children:ie.icon}),g.jsxs("div",{className:ze.statContent,children:[g.jsx("span",{className:ze.statValue,children:ie.loading?"...":ie.value}),g.jsx("span",{className:ze.statLabel,children:ie.label}),ie.sublabel&&!ie.loading&&g.jsx("span",{className:ze.statSublabel,children:ie.sublabel})]})]},ie.path))}),r&&g.jsxs("div",{className:ze.section,children:[g.jsx("h2",{className:ze.sectionTitle,children:i("dashboard.current_config")}),g.jsxs("div",{className:ze.configGrid,children:[g.jsxs("div",{className:ze.configItem,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.debug_enable")}),g.jsx("span",{className:`${ze.configValue} ${r.debug?ze.enabled:ze.disabled}`,children:r.debug?i("common.yes"):i("common.no")})]}),g.jsxs("div",{className:ze.configItem,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.usage_statistics_enable")}),g.jsx("span",{className:`${ze.configValue} ${r.usageStatisticsEnabled?ze.enabled:ze.disabled}`,children:r.usageStatisticsEnabled?i("common.yes"):i("common.no")})]}),g.jsxs("div",{className:ze.configItem,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.logging_to_file_enable")}),g.jsx("span",{className:`${ze.configValue} ${r.loggingToFile?ze.enabled:ze.disabled}`,children:r.loggingToFile?i("common.yes"):i("common.no")})]}),g.jsxs("div",{className:ze.configItem,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.retry_count_label")}),g.jsx("span",{className:ze.configValue,children:($=r.requestRetry)!=null?$:0})]}),g.jsxs("div",{className:ze.configItem,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.ws_auth_enable")}),g.jsx("span",{className:`${ze.configValue} ${r.wsAuth?ze.enabled:ze.disabled}`,children:r.wsAuth?i("common.yes"):i("common.no")})]}),r.proxyUrl&&g.jsxs("div",{className:`${ze.configItem} ${ze.configItemFull}`,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.proxy_url_label")}),g.jsx("span",{className:ze.configValueMono,children:r.proxyUrl})]})]}),g.jsxs(_g,{to:"/settings",className:ze.viewMoreLink,children:[i("dashboard.edit_settings")," →"]})]})]})}function vt({title:i,extra:e,children:t,className:n}){return g.jsxs("div",{className:n?`card ${n}`:"card",children:[(i||e)&&g.jsxs("div",{className:"card-header",children:[g.jsx("div",{className:"title",children:i}),e]}),t]})}const Iq="Settings-module__container___UY8S9",Wq="Settings-module__pageTitle___ADRp3",Xq="Settings-module__grid___WziyQ",Gq="Settings-module__retryRow___fKNn1",Qq="Settings-module__retryRowAligned___Q7nOm",Yq="Settings-module__retryButton___hpjto",Zq="Settings-module__retryRowInputGrow___T0DJn",Jq="Settings-module__retryInput___-fsAl",vn={container:Iq,pageTitle:Wq,grid:Xq,retryRow:Gq,retryRowAligned:Qq,retryButton:Yq,retryRowInputGrow:Zq,retryInput:Jq};function $q(){var V,U,G,$,ie,ue,F,Y,ce;const{t:i}=rt(),{showNotification:e}=Zn(),t=Ct(J=>J.connectionStatus),n=Wt(J=>J.config),s=Wt(J=>J.fetchConfig),a=Wt(J=>J.updateConfigValue),r=Wt(J=>J.clearCache),[o,c]=N.useState(!0),[d,h]=N.useState(""),[p,_]=N.useState(0),[y,x]=N.useState(0),[v,w]=N.useState("round-robin"),[k,M]=N.useState({}),[O,A]=N.useState(""),C=t!=="connected";N.useEffect(()=>{pe(null,null,function*(){var me;c(!0),A("");try{const[Se,Re,He,Ke]=yield Promise.allSettled([s(),Ji.getLogsMaxTotalSizeMb(),Ji.getForceModelPrefix(),Ji.getRoutingStrategy()]);if(Se.status!=="fulfilled")throw Se.reason;const it=Se.value;h((me=it==null?void 0:it.proxyUrl)!=null?me:""),_(typeof(it==null?void 0:it.requestRetry)=="number"?it.requestRetry:0),Re.status==="fulfilled"&&Number.isFinite(Re.value)&&(x(Math.max(0,Number(Re.value))),a("logs-max-total-size-mb",Math.max(0,Number(Re.value)))),He.status==="fulfilled"&&a("force-model-prefix",!!He.value),Ke.status==="fulfilled"&&Ke.value&&(w(String(Ke.value)),a("routing/strategy",String(Ke.value)))}catch(Se){A((Se==null?void 0:Se.message)||i("notification.refresh_failed"))}finally{c(!1)}})},[s,i,a]),N.useEffect(()=>{var J;n&&(h((J=n.proxyUrl)!=null?J:""),typeof n.requestRetry=="number"&&_(n.requestRetry),typeof n.logsMaxTotalSizeMb=="number"&&x(n.logsMaxTotalSizeMb),n.routingStrategy&&w(n.routingStrategy))},[n==null?void 0:n.proxyUrl,n==null?void 0:n.requestRetry,n==null?void 0:n.logsMaxTotalSizeMb,n==null?void 0:n.routingStrategy]);const P=(J,me)=>{M(Se=>ee(z({},Se),{[J]:me}))},R=(J,me,Se,Re,He)=>pe(null,null,function*(){const Ke=(()=>{var it,fi,Pi,ft,ii;switch(me){case"debug":return(it=n==null?void 0:n.debug)!=null?it:!1;case"usage-statistics-enabled":return(fi=n==null?void 0:n.usageStatisticsEnabled)!=null?fi:!1;case"logging-to-file":return(Pi=n==null?void 0:n.loggingToFile)!=null?Pi:!1;case"ws-auth":return(ft=n==null?void 0:n.wsAuth)!=null?ft:!1;case"force-model-prefix":return(ii=n==null?void 0:n.forceModelPrefix)!=null?ii:!1;default:return!1}})();P(J,!0),a(me,Se);try{yield Re(Se),r(me),e(He,"success")}catch(it){a(me,Ke),e(`${i("notification.update_failed")}: ${(it==null?void 0:it.message)||""}`,"error")}finally{P(J,!1)}}),E=()=>pe(null,null,function*(){var me;const J=(me=n==null?void 0:n.proxyUrl)!=null?me:"";P("proxy",!0),a("proxy-url",d);try{yield Ji.updateProxyUrl(d.trim()),r("proxy-url"),e(i("notification.proxy_updated"),"success")}catch(Se){h(J),a("proxy-url",J),e(`${i("notification.update_failed")}: ${(Se==null?void 0:Se.message)||""}`,"error")}finally{P("proxy",!1)}}),L=()=>pe(null,null,function*(){var me;const J=(me=n==null?void 0:n.proxyUrl)!=null?me:"";P("proxy",!0),a("proxy-url","");try{yield Ji.clearProxyUrl(),r("proxy-url"),h(""),e(i("notification.proxy_cleared"),"success")}catch(Se){h(J),a("proxy-url",J),e(`${i("notification.update_failed")}: ${(Se==null?void 0:Se.message)||""}`,"error")}finally{P("proxy",!1)}}),D=()=>pe(null,null,function*(){var Se;const J=(Se=n==null?void 0:n.requestRetry)!=null?Se:0,me=Number(p);if(!Number.isFinite(me)||me<0){e(i("login.error_invalid"),"error"),_(J);return}P("retry",!0),a("request-retry",me);try{yield Ji.updateRequestRetry(me),r("request-retry"),e(i("notification.retry_updated"),"success")}catch(Re){_(J),a("request-retry",J),e(`${i("notification.update_failed")}: ${(Re==null?void 0:Re.message)||""}`,"error")}finally{P("retry",!1)}}),q=()=>pe(null,null,function*(){var Re;const J=(Re=n==null?void 0:n.logsMaxTotalSizeMb)!=null?Re:0,me=Number(y);if(!Number.isFinite(me)||me<0){e(i("login.error_invalid"),"error"),x(J);return}const Se=Math.max(0,me);P("logsMaxSize",!0),a("logs-max-total-size-mb",Se);try{yield Ji.updateLogsMaxTotalSizeMb(Se),r("logs-max-total-size-mb"),e(i("notification.logs_max_total_size_updated"),"success")}catch(He){x(J),a("logs-max-total-size-mb",J),e(`${i("notification.update_failed")}: ${(He==null?void 0:He.message)||""}`,"error")}finally{P("logsMaxSize",!1)}}),B=()=>pe(null,null,function*(){var Se;const J=v.trim();if(!J){e(i("login.error_invalid"),"error");return}const me=(Se=n==null?void 0:n.routingStrategy)!=null?Se:"round-robin";P("routingStrategy",!0),a("routing/strategy",J);try{yield Ji.updateRoutingStrategy(J),r("routing/strategy"),e(i("notification.routing_strategy_updated"),"success")}catch(Re){w(me),a("routing/strategy",me),e(`${i("notification.update_failed")}: ${(Re==null?void 0:Re.message)||""}`,"error")}finally{P("routingStrategy",!1)}}),H=(U=(V=n==null?void 0:n.quotaExceeded)==null?void 0:V.switchProject)!=null?U:!1,W=($=(G=n==null?void 0:n.quotaExceeded)==null?void 0:G.switchPreviewModel)!=null?$:!1;return g.jsxs("div",{className:vn.container,children:[g.jsx("h1",{className:vn.pageTitle,children:i("basic_settings.title")}),g.jsxs("div",{className:vn.grid,children:[g.jsxs(vt,{children:[O&&g.jsx("div",{className:"error-box",children:O}),g.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[g.jsx(Sn,{label:i("basic_settings.debug_enable"),checked:(ie=n==null?void 0:n.debug)!=null?ie:!1,disabled:C||k.debug||o,onChange:J=>R("debug","debug",J,Ji.updateDebug,i("notification.debug_updated"))}),g.jsx(Sn,{label:i("basic_settings.usage_statistics_enable"),checked:(ue=n==null?void 0:n.usageStatisticsEnabled)!=null?ue:!1,disabled:C||k.usage||o,onChange:J=>R("usage","usage-statistics-enabled",J,Ji.updateUsageStatistics,i("notification.usage_statistics_updated"))}),g.jsx(Sn,{label:i("basic_settings.logging_to_file_enable"),checked:(F=n==null?void 0:n.loggingToFile)!=null?F:!1,disabled:C||k.loggingToFile||o,onChange:J=>R("loggingToFile","logging-to-file",J,Ji.updateLoggingToFile,i("notification.logging_to_file_updated"))}),g.jsx(Sn,{label:i("basic_settings.ws_auth_enable"),checked:(Y=n==null?void 0:n.wsAuth)!=null?Y:!1,disabled:C||k.wsAuth||o,onChange:J=>R("wsAuth","ws-auth",J,Ji.updateWsAuth,i("notification.ws_auth_updated"))}),g.jsx(Sn,{label:i("basic_settings.force_model_prefix_enable"),checked:(ce=n==null?void 0:n.forceModelPrefix)!=null?ce:!1,disabled:C||k.forceModelPrefix||o,onChange:J=>R("forceModelPrefix","force-model-prefix",J,Ji.updateForceModelPrefix,i("notification.force_model_prefix_updated"))})]})]}),g.jsxs(vt,{title:i("basic_settings.proxy_title"),children:[g.jsx(et,{label:i("basic_settings.proxy_url_label"),placeholder:i("basic_settings.proxy_url_placeholder"),value:d,onChange:J=>h(J.target.value),disabled:C||o}),g.jsxs("div",{style:{display:"flex",gap:12},children:[g.jsx(ye,{variant:"secondary",onClick:L,disabled:C||k.proxy||o,children:i("basic_settings.proxy_clear")}),g.jsx(ye,{onClick:E,loading:k.proxy,disabled:C||o,children:i("basic_settings.proxy_update")})]})]}),g.jsx(vt,{title:i("basic_settings.retry_title"),children:g.jsxs("div",{className:vn.retryRow,children:[g.jsx(et,{label:i("basic_settings.retry_count_label"),type:"number",inputMode:"numeric",min:0,step:1,value:p,onChange:J=>_(Number(J.target.value)),disabled:C||o,className:vn.retryInput}),g.jsx(ye,{className:vn.retryButton,onClick:D,loading:k.retry,disabled:C||o,children:i("basic_settings.retry_update")})]})}),g.jsx(vt,{title:i("basic_settings.logs_max_total_size_title"),children:g.jsxs("div",{className:`${vn.retryRow} ${vn.retryRowAligned} ${vn.retryRowInputGrow}`,children:[g.jsx(et,{label:i("basic_settings.logs_max_total_size_label"),hint:i("basic_settings.logs_max_total_size_hint"),type:"number",inputMode:"numeric",min:0,step:1,value:y,onChange:J=>x(Number(J.target.value)),disabled:C||o,className:vn.retryInput}),g.jsx(ye,{className:vn.retryButton,onClick:q,loading:k.logsMaxSize,disabled:C||o,children:i("basic_settings.logs_max_total_size_update")})]})}),g.jsx(vt,{title:i("basic_settings.routing_title"),children:g.jsxs("div",{className:`${vn.retryRow} ${vn.retryRowAligned} ${vn.retryRowInputGrow}`,children:[g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:i("basic_settings.routing_strategy_label")}),g.jsxs("select",{className:"input",value:v,onChange:J=>w(J.target.value),disabled:C||o,children:[g.jsx("option",{value:"round-robin",children:i("basic_settings.routing_strategy_round_robin")}),g.jsx("option",{value:"fill-first",children:i("basic_settings.routing_strategy_fill_first")})]}),g.jsx("div",{className:"hint",children:i("basic_settings.routing_strategy_hint")})]}),g.jsx(ye,{className:vn.retryButton,onClick:B,loading:k.routingStrategy,disabled:C||o,children:i("basic_settings.routing_strategy_update")})]})}),g.jsx(vt,{title:i("basic_settings.quota_title"),children:g.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[g.jsx(Sn,{label:i("basic_settings.quota_switch_project"),checked:H,disabled:C||k.switchProject||o,onChange:J=>pe(null,null,function*(){var Re,He;const me=(He=(Re=n==null?void 0:n.quotaExceeded)==null?void 0:Re.switchProject)!=null?He:!1,Se=ee(z({},(n==null?void 0:n.quotaExceeded)||{}),{switchProject:J});P("switchProject",!0),a("quota-exceeded",Se);try{yield Ji.updateSwitchProject(J),r("quota-exceeded"),e(i("notification.quota_switch_project_updated"),"success")}catch(Ke){a("quota-exceeded",ee(z({},(n==null?void 0:n.quotaExceeded)||{}),{switchProject:me})),e(`${i("notification.update_failed")}: ${(Ke==null?void 0:Ke.message)||""}`,"error")}finally{P("switchProject",!1)}})}),g.jsx(Sn,{label:i("basic_settings.quota_switch_preview"),checked:W,disabled:C||k.switchPreview||o,onChange:J=>pe(null,null,function*(){var Re,He;const me=(He=(Re=n==null?void 0:n.quotaExceeded)==null?void 0:Re.switchPreviewModel)!=null?He:!1,Se=ee(z({},(n==null?void 0:n.quotaExceeded)||{}),{switchPreviewModel:J});P("switchPreview",!0),a("quota-exceeded",Se);try{yield Ji.updateSwitchPreviewModel(J),r("quota-exceeded"),e(i("notification.quota_switch_preview_updated"),"success")}catch(Ke){a("quota-exceeded",ee(z({},(n==null?void 0:n.quotaExceeded)||{}),{switchPreviewModel:me})),e(`${i("notification.update_failed")}: ${(Ke==null?void 0:Ke.message)||""}`,"error")}finally{P("switchPreview",!1)}})})]})})]})]})}function Ps({title:i,description:e,action:t}){return g.jsxs("div",{className:"empty-state",children:[g.jsxs("div",{className:"empty-content",children:[g.jsx("div",{className:"empty-icon","aria-hidden":"true",children:g.jsx(QU,{size:20})}),g.jsxs("div",{children:[g.jsx("div",{className:"empty-title",children:i}),e&&g.jsx("div",{className:"empty-desc",children:e})]})]}),t&&g.jsx("div",{className:"empty-action",children:t})]})}function C0({size:i=20,className:e=""}){return g.jsx("div",{className:`loading-spinner${e?` ${e}`:""}`,style:{width:i,height:i,borderWidth:i/7},role:"status","aria-live":"polite"})}function eH(i){return i?/^[\x21-\x7E]+$/.test(i):!1}const tH="ApiKeysPage-module__container___tdy0z",iH="ApiKeysPage-module__pageTitle___nLQ41",MO={container:tH,pageTitle:iH};function nH(){const{t:i}=rt(),{showNotification:e}=Zn(),t=Ct(V=>V.connectionStatus),n=Wt(V=>V.config),s=Wt(V=>V.fetchConfig),a=Wt(V=>V.updateConfigValue),r=Wt(V=>V.clearCache),[o,c]=N.useState([]),[d,h]=N.useState(!0),[p,_]=N.useState(""),[y,x]=N.useState(!1),[v,w]=N.useState(null),[k,M]=N.useState(""),[O,A]=N.useState(!1),[C,P]=N.useState(null),R=N.useMemo(()=>t!=="connected",[t]),E=N.useCallback((V=!1)=>pe(null,null,function*(){h(!0),_("");try{const U=yield s("api-keys",V),G=Array.isArray(U)?U:[];c(G)}catch(U){_((U==null?void 0:U.message)||i("notification.refresh_failed"))}finally{h(!1)}}),[s,i]);N.useEffect(()=>{E()},[E]),N.useEffect(()=>{Array.isArray(n==null?void 0:n.apiKeys)&&c(n.apiKeys)},[n==null?void 0:n.apiKeys]);const L=()=>{w(null),M(""),x(!0)},D=V=>{var U;w(V),M((U=o[V])!=null?U:""),x(!0)},q=()=>{x(!1),M(""),w(null)},B=()=>pe(null,null,function*(){const V=k.trim();if(!V){e(`${i("notification.please_enter")} ${i("notification.api_key")}`,"error");return}if(!eH(V)){e(i("notification.api_key_invalid_chars"),"error");return}const U=v!==null,G=U?o.map(($,ie)=>ie===v?V:$):[...o,V];A(!0);try{U&&v!==null?(yield Yc.update(v,V),e(i("notification.api_key_updated"),"success")):(yield Yc.replace(G),e(i("notification.api_key_added"),"success")),c(G),a("api-keys",G),r("api-keys"),q()}catch($){e(`${i("notification.update_failed")}: ${($==null?void 0:$.message)||""}`,"error")}finally{A(!1)}}),H=V=>pe(null,null,function*(){if(window.confirm(i("api_keys.delete_confirm"))){P(V);try{yield Yc.delete(V);const U=o.filter((G,$)=>$!==V);c(U),a("api-keys",U),r("api-keys"),e(i("notification.api_key_deleted"),"success")}catch(U){e(`${i("notification.delete_failed")}: ${(U==null?void 0:U.message)||""}`,"error")}finally{P(null)}}}),W=g.jsxs("div",{style:{display:"flex",gap:8},children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>E(!0),disabled:d,children:i("common.refresh")}),g.jsx(ye,{size:"sm",onClick:L,disabled:R,children:i("api_keys.add_button")})]});return g.jsxs("div",{className:MO.container,children:[g.jsx("h1",{className:MO.pageTitle,children:i("api_keys.title")}),g.jsxs(vt,{title:i("api_keys.proxy_auth_title"),extra:W,children:[p&&g.jsx("div",{className:"error-box",children:p}),d?g.jsx("div",{className:"flex-center",style:{padding:"24px 0"},children:g.jsx(C0,{size:28})}):o.length===0?g.jsx(Ps,{title:i("api_keys.empty_title"),description:i("api_keys.empty_desc"),action:g.jsx(ye,{onClick:L,disabled:R,children:i("api_keys.add_button")})}):g.jsx("div",{className:"item-list",children:o.map((V,U)=>g.jsxs("div",{className:"item-row",children:[g.jsxs("div",{className:"item-meta",children:[g.jsxs("div",{className:"pill",children:["#",U+1]}),g.jsx("div",{className:"item-title",children:i("api_keys.item_title")}),g.jsx("div",{className:"item-subtitle",children:pn(String(V||""))})]}),g.jsxs("div",{className:"item-actions",children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>D(U),disabled:R,children:i("common.edit")}),g.jsx(ye,{variant:"danger",size:"sm",onClick:()=>H(U),disabled:R||C===U,loading:C===U,children:i("common.delete")})]})]},U))}),g.jsx(zn,{open:y,onClose:q,title:i(v!==null?"api_keys.edit_modal_title":"api_keys.add_modal_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:q,disabled:O,children:i("common.cancel")}),g.jsx(ye,{onClick:B,loading:O,children:i(v!==null?"common.update":"common.add")})]}),children:g.jsx(et,{label:i(v!==null?"api_keys.edit_modal_key_label":"api_keys.add_modal_key_label"),placeholder:i(v!==null?"api_keys.edit_modal_key_label":"api_keys.add_modal_key_placeholder"),value:k,onChange:V=>M(V.target.value),disabled:O})})]})]})}const O0=i=>!Array.isArray(i)||i.length===0?[{name:"",alias:""}]:i.map(e=>({name:e.name||"",alias:e.alias||""})),NO=i=>i.filter(e=>e.name.trim()).map(e=>{const t={name:e.name.trim()},n=e.alias.trim();return n&&n!==t.name&&(t.alias=n),t});function T0({entries:i,onChange:e,addLabel:t,disabled:n=!1,namePlaceholder:s="model-name",aliasPlaceholder:a="alias (optional)"}){const r=i.length?i:[{name:"",alias:""}],o=(h,p,_)=>{const y=r.map((x,v)=>v===h?ee(z({},x),{[p]:_}):x);e(y)},c=()=>{e([...r,{name:"",alias:""}])},d=h=>{const p=r.filter((_,y)=>y!==h);e(p.length?p:[{name:"",alias:""}])};return g.jsxs("div",{className:"header-input-list",children:[r.map((h,p)=>g.jsx(N.Fragment,{children:g.jsxs("div",{className:"header-input-row",children:[g.jsx("input",{className:"input",placeholder:s,value:h.name,onChange:_=>o(p,"name",_.target.value),disabled:n}),g.jsx("span",{className:"header-separator",children:"→"}),g.jsx("input",{className:"input",placeholder:a,value:h.alias,onChange:_=>o(p,"alias",_.target.value),disabled:n}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>d(p),disabled:n||r.length<=1,title:"Remove","aria-label":"Remove",children:g.jsx(Hl,{size:14})})]})},p)),g.jsx(ye,{variant:"secondary",size:"sm",onClick:c,disabled:n,className:"align-start",children:t})]})}const sH="data:image/svg+xml,%3csvg%20width='400'%20height='400'%20viewBox='0%200%2028%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M13.9197%2013.61L17.3816%2026.566L14.242%2027.4049L11.2645%2016.2643L0.119926%2013.2906L0.957817%2010.15L13.9197%2013.61Z'%20fill='%23F34E3F'/%3e%3cpath%20d='M13.7391%2016.0892L4.88169%2024.9056L2.58872%2022.6019L11.4461%2013.7865L13.7391%2016.0892Z'%20fill='%23F34E3F'/%3e%3cpath%20d='M18.9386%208.58315L22.4005%2021.5392L19.2609%2022.3781L16.2833%2011.2374L5.13879%208.26381L5.97668%205.12318L18.9386%208.58315Z'%20fill='%23F34E3F'/%3e%3cpath%20d='M23.9803%203.55632L27.4422%2016.5124L24.3025%2017.3512L21.325%206.21062L10.1805%203.23698L11.0183%200.0963593L23.9803%203.55632Z'%20fill='%23F34E3F'/%3e%3c/svg%3e",aH="AiProvidersPage-module__container___y-jfS",rH="AiProvidersPage-module__cardTitle___vO4i3",oH="AiProvidersPage-module__cardTitleIcon___-rTw0",lH="AiProvidersPage-module__pageTitle___DoSv8",cH="AiProvidersPage-module__content___E2Czu",uH="AiProvidersPage-module__cardStats___rELY1",dH="AiProvidersPage-module__statPill___d812A",hH="AiProvidersPage-module__statSuccess___5dRtj",fH="AiProvidersPage-module__statFailure___krDjY",pH="AiProvidersPage-module__fieldRow___XK6hX",mH="AiProvidersPage-module__fieldLabel___cLX9f",gH="AiProvidersPage-module__fieldValue___VdFCH",_H="AiProvidersPage-module__headerBadgeList___kwkIM",yH="AiProvidersPage-module__headerBadge___eN0Fd",xH="AiProvidersPage-module__modelTagList___shUnj",bH="AiProvidersPage-module__modelCountLabel___uV8s-",vH="AiProvidersPage-module__modelTag___k-VuJ",SH="AiProvidersPage-module__modelName___-6r4h",wH="AiProvidersPage-module__modelAlias___ljQjM",kH="AiProvidersPage-module__excludedModelTag___emTfi",AH="AiProvidersPage-module__excludedModelsSection___XFykq",CH="AiProvidersPage-module__excludedModelsLabel___Drdds",OH="AiProvidersPage-module__apiKeyEntriesSection___60ydj",TH="AiProvidersPage-module__apiKeyEntriesLabel___c5W8h",MH="AiProvidersPage-module__apiKeyEntryList___-xrgk",NH="AiProvidersPage-module__apiKeyEntryCard___Y5gRi",RH="AiProvidersPage-module__apiKeyEntryIndex___h8oWW",PH="AiProvidersPage-module__apiKeyEntryKey___JgU0c",LH="AiProvidersPage-module__apiKeyEntryProxy___gy9Vu",jH="AiProvidersPage-module__apiKeyEntryStats___Whq5E",EH="AiProvidersPage-module__apiKeyEntryStat___rwvkB",DH="AiProvidersPage-module__apiKeyEntryStatSuccess___GXIwG",UH="AiProvidersPage-module__apiKeyEntryStatFailure___XV9wg",FH="AiProvidersPage-module__modelDiscoveryList___HKeOb",BH="AiProvidersPage-module__modelDiscoveryRow___3J8pc",zH="AiProvidersPage-module__modelDiscoveryRowSelected___VLfIp",qH="AiProvidersPage-module__modelDiscoveryMeta___7D6Y5",HH="AiProvidersPage-module__modelDiscoveryName___yf70V",KH="AiProvidersPage-module__modelDiscoveryAlias___N2nU7",VH="AiProvidersPage-module__modelDiscoveryDesc___nsrtd",IH="AiProvidersPage-module__openaiTestButtonSuccess___ZiymQ",WH="AiProvidersPage-module__openaiTestSelect___7-Upw",XH="AiProvidersPage-module__openaiTestButton___IEmjD",GH="AiProvidersPage-module__statusBar___gAS9s",QH="AiProvidersPage-module__statusBlocks___RESqk",YH="AiProvidersPage-module__statusBlock___nUV1s",ZH="AiProvidersPage-module__statusBlockSuccess___k3qxb",JH="AiProvidersPage-module__statusBlockFailure___rQIEy",$H="AiProvidersPage-module__statusBlockMixed___PmcCP",eK="AiProvidersPage-module__statusBlockIdle___WEMXo",tK="AiProvidersPage-module__statusRate___mqcEs",iK="AiProvidersPage-module__statusRateHigh___GpDhl",nK="AiProvidersPage-module__statusRateMedium___hdtEj",sK="AiProvidersPage-module__statusRateLow___mNI2c",Z={container:aH,cardTitle:rH,cardTitleIcon:oH,pageTitle:lH,content:cH,cardStats:uH,statPill:dH,statSuccess:hH,statFailure:fH,fieldRow:pH,fieldLabel:mH,fieldValue:gH,headerBadgeList:_H,headerBadge:yH,modelTagList:xH,modelCountLabel:bH,modelTag:vH,modelName:SH,modelAlias:wH,excludedModelTag:kH,excludedModelsSection:AH,excludedModelsLabel:CH,apiKeyEntriesSection:OH,apiKeyEntriesLabel:TH,apiKeyEntryList:MH,apiKeyEntryCard:NH,apiKeyEntryIndex:RH,apiKeyEntryKey:PH,apiKeyEntryProxy:LH,apiKeyEntryStats:jH,apiKeyEntryStat:EH,apiKeyEntryStatSuccess:DH,apiKeyEntryStatFailure:UH,modelDiscoveryList:FH,modelDiscoveryRow:BH,modelDiscoveryRowSelected:zH,modelDiscoveryMeta:qH,modelDiscoveryName:HH,modelDiscoveryAlias:KH,modelDiscoveryDesc:VH,openaiTestButtonSuccess:IH,openaiTestSelect:WH,openaiTestButton:XH,statusBar:GH,statusBlocks:QH,statusBlock:YH,statusBlockSuccess:ZH,statusBlockFailure:JH,statusBlockMixed:$H,statusBlockIdle:eK,statusRate:tK,statusRateHigh:iK,statusRateMedium:nK,statusRateLow:sK},l2="*",pr=i=>Array.isArray(i)&&i.some(e=>String(e!=null?e:"").trim()===l2),qP=i=>Array.isArray(i)?i.filter(e=>String(e!=null?e:"").trim()!==l2):[],RO=i=>[...qP(i),l2],PO=i=>qP(i),LO=i=>i.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean),c2=i=>Array.isArray(i)?i.join(` +`+a):n.stack=a}catch(r){}}throw n}})}_request(e,t){typeof e=="string"?(t=t||{},t.url=e):t=e||{},t=jl(this.defaults,t);const{transitional:n,paramsSerializer:s,headers:a}=t;n!==void 0&&Gm.assertOptions(n,{silentJSONParsing:da.transitional(da.boolean),forcedJSONParsing:da.transitional(da.boolean),clarifyTimeoutError:da.transitional(da.boolean)},!1),s!=null&&(re.isFunction(s)?t.paramsSerializer={serialize:s}:Gm.assertOptions(s,{encode:da.function,serialize:da.function},!0)),t.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Gm.assertOptions(t,{baseUrl:da.spelling("baseURL"),withXsrfToken:da.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let r=a&&re.merge(a.common,a[t.method]);a&&re.forEach(["delete","get","head","post","put","patch","common"],x=>{delete a[x]}),t.headers=Vn.concat(r,a);const o=[];let c=!0;this.interceptors.request.forEach(function(v){typeof v.runWhen=="function"&&v.runWhen(t)===!1||(c=c&&v.synchronous,o.unshift(v.fulfilled,v.rejected))});const d=[];this.interceptors.response.forEach(function(v){d.push(v.fulfilled,v.rejected)});let h,p=0,_;if(!c){const x=[YC.bind(this),void 0];for(x.unshift(...o),x.push(...d),_=x.length,h=Promise.resolve(t);p<_;)h=h.then(x[p++],x[p++]);return h}_=o.length;let y=t;for(;p<_;){const x=o[p++],v=o[p++];try{y=x(y)}catch(w){v.call(this,w);break}}try{h=YC.call(this,y)}catch(x){return Promise.reject(x)}for(p=0,_=d.length;p<_;)h=h.then(d[p++],d[p++]);return h}getUri(e){e=jl(this.defaults,e);const t=CR(e.baseURL,e.url,e.allowAbsoluteUrls);return vR(t,e.params,e.paramsSerializer)}};re.forEach(["delete","get","head","options"],function(e){kl.prototype[e]=function(t,n){return this.request(jl(n||{},{method:e,url:t,data:(n||{}).data}))}});re.forEach(["post","put","patch"],function(e){function t(n){return function(a,r,o){return this.request(jl(o||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:a,data:r}))}}kl.prototype[e]=t(),kl.prototype[e+"Form"]=t(!0)});let tz=class RR{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(a){t=a});const n=this;this.promise.then(s=>{if(!n._listeners)return;let a=n._listeners.length;for(;a-- >0;)n._listeners[a](s);n._listeners=null}),this.promise.then=s=>{let a;const r=new Promise(o=>{n.subscribe(o),a=o}).then(s);return r.cancel=function(){n.unsubscribe(a)},r},e(function(a,r,o){n.reason||(n.reason=new Cu(a,r,o),t(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);t!==-1&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=n=>{e.abort(n)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new RR(function(s){e=s}),cancel:e}}};function iz(i){return function(t){return i.apply(null,t)}}function nz(i){return re.isObject(i)&&i.isAxiosError===!0}const Ix={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ix).forEach(([i,e])=>{Ix[e]=i});function PR(i){const e=new kl(i),t=cR(kl.prototype.request,e);return re.extend(t,kl.prototype,e,{allOwnKeys:!0}),re.extend(t,e,null,{allOwnKeys:!0}),t.create=function(s){return PR(jl(i,s))},t}const li=PR(lf);li.Axios=kl;li.CanceledError=Cu;li.CancelToken=tz;li.isCancel=kR;li.VERSION=NR;li.toFormData=x0;li.AxiosError=Ye;li.Cancel=li.CanceledError;li.all=function(e){return Promise.all(e)};li.spread=iz;li.isAxiosError=nz;li.mergeConfig=jl;li.AxiosHeaders=Vn;li.formToJSON=i=>wR(re.isHTMLForm(i)?new FormData(i):i);li.getAdapter=MR.getAdapter;li.HttpStatusCode=Ix;li.default=li;const{Axios:$le,AxiosError:ece,CanceledError:tce,isCancel:ice,CancelToken:nce,VERSION:sce,all:ace,Cancel:rce,isAxiosError:oce,spread:lce,toFormData:cce,AxiosHeaders:uce,HttpStatusCode:dce,formToJSON:hce,getAdapter:fce,mergeConfig:pce}=li;class sz{constructor(){Ge(this,"instance");Ge(this,"apiBase","");Ge(this,"managementKey","");this.instance=li.create({timeout:RC,headers:{"Content-Type":"application/json"}}),this.setupInterceptors()}setConfig(e){this.apiBase=this.normalizeApiBase(e.apiBase),this.managementKey=e.managementKey,e.timeout?this.instance.defaults.timeout=e.timeout:this.instance.defaults.timeout=RC}normalizeApiBase(e){let t=e.trim();return t=t.replace(/\/?v0\/management\/?$/i,""),t=t.replace(/\/+$/,""),/^https?:\/\//i.test(t)||(t=`http://${t}`),`${t}${Fx}`}readHeader(e,t){if(!e)return null;const n=o=>{if(o==null)return null;if(Array.isArray(o)){const d=o.find(h=>h!=null&&String(h).trim());return d!==void 0?String(d):null}const c=String(o);return c||null},s=e.get;if(typeof s=="function")for(const o of t){const c=n(s.call(e,o));if(c)return c}const a=typeof e.entries=="function"?Array.from(e.entries()):Object.entries(e),r=Object.fromEntries(a.map(([o,c])=>[String(o).toLowerCase(),c]));for(const o of t){const c=n(r[o.toLowerCase()]);if(c)return c}return null}setupInterceptors(){this.instance.interceptors.request.use(e=>(e.baseURL=this.apiBase,e.url&&(e.url=e.url.replace(/\/generative-language-api-key\b/g,"/gemini-api-key")),this.managementKey&&(e.headers.Authorization=`Bearer ${this.managementKey}`),e),e=>Promise.reject(this.handleError(e))),this.instance.interceptors.response.use(e=>{const t=e.headers,n=this.readHeader(t,lF),s=this.readHeader(t,cF);return(n||s)&&window.dispatchEvent(new CustomEvent("server-version-update",{detail:{version:n||null,buildDate:s||null}})),e},e=>Promise.reject(this.handleError(e)))}handleError(e){var n,s,a;if(li.isAxiosError(e)){const r=(n=e.response)==null?void 0:n.data,o=(r==null?void 0:r.error)||(r==null?void 0:r.message)||e.message||"Request failed",c=new Error(o);return c.name="ApiError",c.status=(s=e.response)==null?void 0:s.status,c.code=e.code,c.details=r,c.data=r,((a=e.response)==null?void 0:a.status)===401&&window.dispatchEvent(new Event("unauthorized")),c}const t=new Error((e==null?void 0:e.message)||"Unknown error occurred");return t.name="ApiError",t}get(e,t){return pe(this,null,function*(){return(yield this.instance.get(e,t)).data})}post(e,t,n){return pe(this,null,function*(){return(yield this.instance.post(e,t,n)).data})}put(e,t,n){return pe(this,null,function*(){return(yield this.instance.put(e,t,n)).data})}patch(e,t,n){return pe(this,null,function*(){return(yield this.instance.patch(e,t,n)).data})}delete(e,t){return pe(this,null,function*(){return(yield this.instance.delete(e,t)).data})}getRaw(e,t){return pe(this,null,function*(){return this.instance.get(e,t)})}postForm(e,t,n){return pe(this,null,function*(){return(yield this.instance.post(e,t,ee(z({},n),{headers:ee(z({},(n==null?void 0:n.headers)||{}),{"Content-Type":"multipart/form-data"})}))).data})}requestRaw(e){return pe(this,null,function*(){return this.instance.request(e)})}}const Ce=new sz;function gl(i){return i?Array.isArray(i)?i.reduce((e,t)=>{var a,r;const n=(a=t==null?void 0:t.key)==null?void 0:a.trim(),s=(r=t==null?void 0:t.value)==null?void 0:r.trim();return n&&s!==void 0&&s!==null&&s!==""&&(e[n]=s),e},{}):Object.entries(i).reduce((e,[t,n])=>{const s=t==null?void 0:t.trim(),a=typeof n=="string"?n.trim():n;return s&&a!==void 0&&a!==null&&a!==""&&(e[s]=String(a)),e},{}):{}}function cf(i){return!i||typeof i!="object"?[]:Object.entries(i).filter(([,e])=>e!=null&&e!=="").map(([e,t])=>({key:e,value:String(t)}))}const az=i=>{if(i!=null){if(typeof i=="boolean")return i;if(typeof i=="number")return i!==0;if(typeof i=="string"){const e=i.trim().toLowerCase();if(["true","1","yes","y","on"].includes(e))return!0;if(["false","0","no","n","off"].includes(e))return!1}return!!i}},LR=i=>Array.isArray(i)?i.map(e=>{var o,c;if(!e)return null;const t=e.name||e.id||e.model;if(!t)return null;const n=e.alias||e.display_name||e.displayName,s=(o=e.priority)!=null?o:e.priority,a=(c=e["test-model"])!=null?c:e.testModel,r={name:String(t)};return n&&n!==t&&(r.alias=String(n)),s!==void 0&&(r.priority=Number(s)),a&&(r.testModel=String(a)),r}).filter(Boolean):[],v0=i=>{if(!i||typeof i!="object")return;const e=gl(i);return Object.keys(e).length?e:void 0},zv=i=>{const e=Array.isArray(i)?i:typeof i=="string"?i.split(/[\n,]/):[],t=new Set,n=[];return e.forEach(s=>{const a=String(s!=null?s:"").trim();if(!a)return;const r=a.toLowerCase();t.has(r)||(t.add(r),n.push(a))}),n},qv=i=>{if(i==null)return;const e=String(i).trim();return e||void 0},JC=i=>{var a,r,o,c;if(!i)return null;const e=(o=(r=(a=i["api-key"])!=null?a:i.apiKey)!=null?r:i.key)!=null?o:typeof i=="string"?i:"",t=String(e||"").trim();if(!t)return null;const n=(c=i["proxy-url"])!=null?c:i.proxyUrl,s=v0(i.headers);return{apiKey:t,proxyUrl:n?String(n):void 0,headers:s}},Wc=i=>{var h,p,_,y,x,v,w,k;if(!i)return null;const e=(p=(h=i["api-key"])!=null?h:i.apiKey)!=null?p:typeof i=="string"?i:"",t=String(e||"").trim();if(!t)return null;const n={apiKey:t},s=qv((_=i.prefix)!=null?_:i.prefix);s&&(n.prefix=s);const a=(y=i["base-url"])!=null?y:i.baseUrl,r=(x=i["proxy-url"])!=null?x:i.proxyUrl;a&&(n.baseUrl=String(a)),r&&(n.proxyUrl=String(r));const o=v0(i.headers);o&&(n.headers=o);const c=LR(i.models);c.length&&(n.models=c);const d=zv((k=(w=(v=i["excluded-models"])!=null?v:i.excludedModels)!=null?w:i.excluded_models)!=null?k:i.excluded_models);return d.length&&(n.excludedModels=d),n},jR=i=>{var c,d,h,p,_;if(!i)return null;let e=(c=i["api-key"])!=null?c:i.apiKey;!e&&typeof i=="string"&&(e=i);const t=String(e||"").trim();if(!t)return null;const n={apiKey:t},s=qv((d=i.prefix)!=null?d:i.prefix);s&&(n.prefix=s);const a=(p=(h=i["base-url"])!=null?h:i.baseUrl)!=null?p:i.base_url;a&&(n.baseUrl=String(a));const r=v0(i.headers);r&&(n.headers=r);const o=zv((_=i["excluded-models"])!=null?_:i.excludedModels);return o.length&&(n.excludedModels=o),n},ER=i=>{var h,p,_,y;if(!i||typeof i!="object")return null;const e=i.name||i.id,t=(h=i["base-url"])!=null?h:i.baseUrl;if(!e||!t)return null;let n=[];Array.isArray(i["api-key-entries"])?n=i["api-key-entries"].map(x=>JC(x)).filter(Boolean):Array.isArray(i["api-keys"])&&(n=i["api-keys"].map(x=>JC({"api-key":x})).filter(Boolean));const s=v0(i.headers),a=LR(i.models),r=(p=i.priority)!=null?p:i.priority,o=(_=i["test-model"])!=null?_:i.testModel,c={name:String(e),baseUrl:String(t),apiKeyEntries:n},d=qv((y=i.prefix)!=null?y:i.prefix);return d&&(c.prefix=d),s&&(c.headers=s),a.length&&(c.models=a),r!==void 0&&(c.priority=Number(r)),o&&(c.testModel=String(o)),c},rz=i=>{var n,s;if(!i||typeof i!="object")return;const e=(s=(n=i["oauth-excluded-models"])!=null?n:i.items)!=null?s:i;if(!e||typeof e!="object")return;const t={};return Object.entries(e).forEach(([a,r])=>{const o=String(a||"").trim();if(!o)return;const c=zv(r);t[o.toLowerCase()]=c}),t},DR=i=>{if(!Array.isArray(i))return[];const e=new Set,t=[];return i.forEach(n=>{var o,c,d,h;if(!n||typeof n!="object")return;const s=String((c=(o=n.from)!=null?o:n.from)!=null?c:"").trim(),a=String((h=(d=n.to)!=null?d:n.to)!=null?h:"").trim();if(!s||!a)return;const r=s.toLowerCase();e.has(r)||(e.add(r),t.push({from:s,to:a}))}),t},UR=i=>{var o,c,d,h,p,_,y,x,v;const e=(o=i==null?void 0:i.ampcode)!=null?o:i;if(!e||typeof e!="object")return;const t={},n=(d=(c=e["upstream-url"])!=null?c:e.upstreamUrl)!=null?d:e.upstream_url;n&&(t.upstreamUrl=String(n));const s=(p=(h=e["upstream-api-key"])!=null?h:e.upstreamApiKey)!=null?p:e.upstream_api_key;s&&(t.upstreamApiKey=String(s));const a=az((y=(_=e["force-model-mappings"])!=null?_:e.forceModelMappings)!=null?y:e.force_model_mappings);a!==void 0&&(t.forceModelMappings=a);const r=DR((v=(x=e["model-mappings"])!=null?x:e.modelMappings)!=null?v:e.model_mappings);return r.length&&(t.modelMappings=r),t},oz=i=>{var p,_,y,x,v,w,k,M,O,A,C,P,R,E,L,D,q,B,H,W,V,U,G,$;const e={raw:i||{}};if(!i||typeof i!="object")return e;e.debug=i.debug,e.proxyUrl=(p=i["proxy-url"])!=null?p:i.proxyUrl,e.requestRetry=(_=i["request-retry"])!=null?_:i.requestRetry;const t=(y=i["quota-exceeded"])!=null?y:i.quotaExceeded;t&&typeof t=="object"&&(e.quotaExceeded={switchProject:(x=t["switch-project"])!=null?x:t.switchProject,switchPreviewModel:(v=t["switch-preview-model"])!=null?v:t.switchPreviewModel}),e.usageStatisticsEnabled=(w=i["usage-statistics-enabled"])!=null?w:i.usageStatisticsEnabled,e.requestLog=(k=i["request-log"])!=null?k:i.requestLog,e.loggingToFile=(M=i["logging-to-file"])!=null?M:i.loggingToFile,e.logsMaxTotalSizeMb=(O=i["logs-max-total-size-mb"])!=null?O:i.logsMaxTotalSizeMb,e.wsAuth=(A=i["ws-auth"])!=null?A:i.wsAuth,e.forceModelPrefix=(C=i["force-model-prefix"])!=null?C:i.forceModelPrefix;const n=i.routing;n&&typeof n=="object"?e.routingStrategy=(P=n.strategy)!=null?P:n.strategy:e.routingStrategy=(R=i["routing-strategy"])!=null?R:i.routingStrategy,e.apiKeys=Array.isArray(i["api-keys"])?i["api-keys"].slice():i.apiKeys;const s=(L=(E=i["gemini-api-key"])!=null?E:i.geminiApiKey)!=null?L:i.geminiApiKeys;Array.isArray(s)&&(e.geminiApiKeys=s.map(ie=>jR(ie)).filter(Boolean));const a=(q=(D=i["codex-api-key"])!=null?D:i.codexApiKey)!=null?q:i.codexApiKeys;Array.isArray(a)&&(e.codexApiKeys=a.map(ie=>Wc(ie)).filter(Boolean));const r=(H=(B=i["claude-api-key"])!=null?B:i.claudeApiKey)!=null?H:i.claudeApiKeys;Array.isArray(r)&&(e.claudeApiKeys=r.map(ie=>Wc(ie)).filter(Boolean));const o=(V=(W=i["vertex-api-key"])!=null?W:i.vertexApiKey)!=null?V:i.vertexApiKeys;Array.isArray(o)&&(e.vertexApiKeys=o.map(ie=>Wc(ie)).filter(Boolean));const c=(G=(U=i["openai-compatibility"])!=null?U:i.openaiCompatibility)!=null?G:i.openAICompatibility;Array.isArray(c)&&(e.openaiCompatibility=c.map(ie=>ER(ie)).filter(Boolean));const d=UR(i.ampcode);d&&(e.ampcode=d);const h=rz(($=i["oauth-excluded-models"])!=null?$:i.oauthExcludedModels);return h&&(e.oauthExcludedModels=h),e},Ji={getConfig(){return pe(this,null,function*(){const i=yield Ce.get("/config");return oz(i)})},getRawConfig:()=>Ce.get("/config"),updateDebug:i=>Ce.put("/debug",{value:i}),updateProxyUrl:i=>Ce.put("/proxy-url",{value:i}),clearProxyUrl:()=>Ce.delete("/proxy-url"),updateRequestRetry:i=>Ce.put("/request-retry",{value:i}),updateSwitchProject:i=>Ce.put("/quota-exceeded/switch-project",{value:i}),updateSwitchPreviewModel:i=>Ce.put("/quota-exceeded/switch-preview-model",{value:i}),updateUsageStatistics:i=>Ce.put("/usage-statistics-enabled",{value:i}),updateRequestLog:i=>Ce.put("/request-log",{value:i}),updateLoggingToFile:i=>Ce.put("/logging-to-file",{value:i}),getLogsMaxTotalSizeMb(){return pe(this,null,function*(){var e,t;const i=yield Ce.get("/logs-max-total-size-mb");return(t=(e=i==null?void 0:i["logs-max-total-size-mb"])!=null?e:i==null?void 0:i.logsMaxTotalSizeMb)!=null?t:0})},updateLogsMaxTotalSizeMb:i=>Ce.put("/logs-max-total-size-mb",{value:i}),updateWsAuth:i=>Ce.put("/ws-auth",{value:i}),getForceModelPrefix(){return pe(this,null,function*(){var e,t;const i=yield Ce.get("/force-model-prefix");return(t=(e=i==null?void 0:i["force-model-prefix"])!=null?e:i==null?void 0:i.forceModelPrefix)!=null?t:!1})},updateForceModelPrefix:i=>Ce.put("/force-model-prefix",{value:i}),getRoutingStrategy(){return pe(this,null,function*(){var e,t,n;const i=yield Ce.get("/routing/strategy");return(n=(t=(e=i==null?void 0:i.strategy)!=null?e:i==null?void 0:i["routing-strategy"])!=null?t:i==null?void 0:i.routingStrategy)!=null?n:"round-robin"})},updateRoutingStrategy:i=>Ce.put("/routing/strategy",{value:i})};let $p=0,to=null;const lz=["debug","proxy-url","request-retry","quota-exceeded","usage-statistics-enabled","request-log","logging-to-file","logs-max-total-size-mb","ws-auth","force-model-prefix","routing/strategy","api-keys","ampcode","gemini-api-key","codex-api-key","claude-api-key","vertex-api-key","openai-compatibility","oauth-excluded-models"],Od=(i,e)=>{var t;if(i)switch(e){case"debug":return i.debug;case"proxy-url":return i.proxyUrl;case"request-retry":return i.requestRetry;case"quota-exceeded":return i.quotaExceeded;case"usage-statistics-enabled":return i.usageStatisticsEnabled;case"request-log":return i.requestLog;case"logging-to-file":return i.loggingToFile;case"logs-max-total-size-mb":return i.logsMaxTotalSizeMb;case"ws-auth":return i.wsAuth;case"force-model-prefix":return i.forceModelPrefix;case"routing/strategy":return i.routingStrategy;case"api-keys":return i.apiKeys;case"ampcode":return i.ampcode;case"gemini-api-key":return i.geminiApiKeys;case"codex-api-key":return i.codexApiKeys;case"claude-api-key":return i.claudeApiKeys;case"vertex-api-key":return i.vertexApiKeys;case"openai-compatibility":return i.openaiCompatibility;case"oauth-excluded-models":return i.oauthExcludedModels;default:return e?(t=i.raw)==null?void 0:t[e]:void 0}},Wt=Kl((i,e)=>({config:null,cache:new Map,loading:!1,error:null,fetchConfig:(t,n=!1)=>pe(null,null,function*(){const{cache:s,isCacheValid:a}=e(),r=t||"__full__";if(!n&&a(t)){const c=s.get(r);if(c)return c.data}if(!n&&t&&a()){const c=s.get("__full__");if(c!=null&&c.data)return Od(c.data,t)}if(to){const c=yield to.promise;return t?Od(c,t):c}i({loading:!0,error:null});const o=$p+=1;try{const c=Ji.getConfig();to={id:o,promise:c};const d=yield c,h=Date.now();if(o!==$p)return t?Od(d,t):d;const p=new Map(s);return p.set("__full__",{data:d,timestamp:h}),lz.forEach(_=>{const y=Od(d,_);y!==void 0&&p.set(_,{data:y,timestamp:h})}),i({config:d,cache:p,loading:!1}),t?Od(d,t):d}catch(c){throw o===$p&&i({error:c.message||"Failed to fetch config",loading:!1}),c}finally{(to==null?void 0:to.id)===o&&(to=null)}}),updateConfigValue:(t,n)=>{i(s=>{var o;const a=z({},((o=s.config)==null?void 0:o.raw)||{});a[t]=n;const r=ee(z({},s.config||{}),{raw:a});switch(t){case"debug":r.debug=n;break;case"proxy-url":r.proxyUrl=n;break;case"request-retry":r.requestRetry=n;break;case"quota-exceeded":r.quotaExceeded=n;break;case"usage-statistics-enabled":r.usageStatisticsEnabled=n;break;case"request-log":r.requestLog=n;break;case"logging-to-file":r.loggingToFile=n;break;case"logs-max-total-size-mb":r.logsMaxTotalSizeMb=n;break;case"ws-auth":r.wsAuth=n;break;case"force-model-prefix":r.forceModelPrefix=n;break;case"routing/strategy":r.routingStrategy=n;break;case"api-keys":r.apiKeys=n;break;case"ampcode":r.ampcode=n;break;case"gemini-api-key":r.geminiApiKeys=n;break;case"codex-api-key":r.codexApiKeys=n;break;case"claude-api-key":r.claudeApiKeys=n;break;case"vertex-api-key":r.vertexApiKeys=n;break;case"openai-compatibility":r.openaiCompatibility=n;break;case"oauth-excluded-models":r.oauthExcludedModels=n;break}return{config:r}}),e().clearCache(t)},clearCache:t=>{const{cache:n}=e(),s=new Map(n);if(t){s.delete(t),s.delete("__full__"),i({cache:s});return}else s.clear();$p+=1,to=null,i({config:null,cache:s,loading:!1,error:null})},isCacheValid:t=>{const{cache:n}=e(),s=t||"__full__",a=n.get(s);return a?Date.now()-a.timestamp{let e=(i||"").trim();return e?(e=e.replace(/\/?v0\/management\/?$/i,""),e=e.replace(/\/+$/i,""),/^https?:\/\//i.test(e)||(e=`http://${e}`),e):""},FR=()=>{try{const{protocol:i,hostname:e,port:t}=window.location,n=t?`:${t}`:"";return kh(`${i}//${e}${n}`)}catch(i){return console.warn("Failed to detect api base from location, fallback to default",i),kh(`http://localhost:${oF}`)}};let Td=null;const Ct=Kl()(Ev((i,e)=>({isAuthenticated:!1,apiBase:"",managementKey:"",rememberPassword:!1,serverVersion:null,serverBuildDate:null,connectionStatus:"disconnected",connectionError:null,restoreSession:()=>Td||(Td=pe(null,null,function*(){el.migratePlaintextKeys(["apiBase","apiUrl","managementKey"]);const t=localStorage.getItem("isLoggedIn")==="true",n=el.getItem("apiBase")||el.getItem("apiUrl",{encrypt:!0}),s=el.getItem("managementKey"),{apiBase:a,managementKey:r,rememberPassword:o}=e(),c=kh(a||n||FR()),d=r||s||"",h=o||!!r||!!s;if(i({apiBase:c,managementKey:d,rememberPassword:h}),Ce.setConfig({apiBase:c,managementKey:d}),t&&c&&d)try{return yield e().login({apiBase:c,managementKey:d,rememberPassword:h}),!0}catch(p){return console.warn("Auto login failed:",p),!1}return!1}),Td),login:t=>pe(null,null,function*(){var r,o;const n=kh(t.apiBase),s=t.managementKey.trim(),a=(o=(r=t.rememberPassword)!=null?r:e().rememberPassword)!=null?o:!1;try{i({connectionStatus:"connecting"}),Ce.setConfig({apiBase:n,managementKey:s}),yield Wt.getState().fetchConfig(void 0,!0),i({isAuthenticated:!0,apiBase:n,managementKey:s,rememberPassword:a,connectionStatus:"connected",connectionError:null}),a?localStorage.setItem("isLoggedIn","true"):localStorage.removeItem("isLoggedIn")}catch(c){throw i({connectionStatus:"error",connectionError:c.message||"Connection failed"}),c}}),logout:()=>{Td=null,Wt.getState().clearCache(),i({isAuthenticated:!1,apiBase:"",managementKey:"",serverVersion:null,serverBuildDate:null,connectionStatus:"disconnected",connectionError:null}),localStorage.removeItem("isLoggedIn")},checkAuth:()=>pe(null,null,function*(){const{managementKey:t,apiBase:n}=e();if(!t||!n)return!1;try{return Ce.setConfig({apiBase:n,managementKey:t}),yield Wt.getState().fetchConfig(),i({isAuthenticated:!0,connectionStatus:"connected"}),!0}catch(s){return i({isAuthenticated:!1,connectionStatus:"error"}),!1}}),updateServerVersion:(t,n)=>{i({serverVersion:t||null,serverBuildDate:n||null})},updateConnectionStatus:(t,n=null)=>{i({connectionStatus:t,connectionError:n})}}),{name:nR,storage:aR(()=>({getItem:i=>{const e=el.getItem(i);return e?JSON.stringify(e):null},setItem:(i,e)=>{el.setItem(i,JSON.parse(e))},removeItem:i=>{el.removeItem(i)}})),partialize:i=>ee(z({apiBase:i.apiBase},i.rememberPassword?{managementKey:i.managementKey}:{}),{rememberPassword:i.rememberPassword,serverVersion:i.serverVersion,serverBuildDate:i.serverBuildDate})}));typeof window!="undefined"&&(window.addEventListener("unauthorized",()=>{Ct.getState().logout()}),window.addEventListener("server-version-update",(i=>{const e=i.detail||{};Ct.getState().updateServerVersion(e.version||null,e.buildDate||null)})));const BR=[{id:"gpt",label:"GPT",patterns:[/gpt/i,/\bo\d\b/i,/\bo\d+\.?/i,/\bchatgpt/i]},{id:"claude",label:"Claude",patterns:[/claude/i]},{id:"gemini",label:"Gemini",patterns:[/gemini/i,/\bgai\b/i]},{id:"kimi",label:"Kimi",patterns:[/kimi/i]},{id:"qwen",label:"Qwen",patterns:[/qwen/i]},{id:"glm",label:"GLM",patterns:[/glm/i,/chatglm/i]},{id:"grok",label:"Grok",patterns:[/grok/i]},{id:"deepseek",label:"DeepSeek",patterns:[/deepseek/i]}],cz=i=>{for(const e of BR)if(e.patterns.some(t=>t.test(i)))return e.id;return null};function $C(i,{dedupe:e=!1}={}){const t=r=>{if(typeof r=="string")return{name:r};if(!r||typeof r!="object")return null;const o=r.id||r.name||r.model||r.value;if(!o)return null;const c=r.alias||r.display_name||r.displayName,d=r.description||r.note||r.comment,h={name:String(o)};return c&&c!==o&&(h.alias=String(c)),d&&(h.description=String(d)),h};let n=[];Array.isArray(i)?n=i.map(t):i&&typeof i=="object"&&(Array.isArray(i.data)?n=i.data.map(t):Array.isArray(i.models)&&(n=i.models.map(t)));const s=n.filter(Boolean);if(!e)return s;const a=new Set;return s.filter(r=>{const o=((r==null?void 0:r.name)||"").toLowerCase();return!o||a.has(o)?!1:(a.add(o),!0)})}function uz(i=[],{otherLabel:e="Other"}={}){const t=BR.map(a=>({id:a.id,label:a.label,items:[]})),n={id:"other",label:e,items:[]};i.forEach(a=>{const r=((a==null?void 0:a.name)||"").toString(),o=((a==null?void 0:a.alias)||"").toString(),c=`${r} ${o}`.toLowerCase(),d=cz(c),h=d?t.find(p=>p.id===d):null;h?h.items.push(a):n.items.push(a)});const s=t.filter(a=>a.items.length>0);return n.items.length&&s.push(n),s}const dz=i=>{if(i==null)return{bodyText:"",body:null};if(typeof i=="string"){const e=i,t=e.trim();if(!t)return{bodyText:e,body:null};try{return{bodyText:e,body:JSON.parse(t)}}catch(n){return{bodyText:e,body:e}}}try{return{bodyText:JSON.stringify(i),body:i}}catch(e){return{bodyText:String(i),body:i}}},uf=i=>{var a;const e=i.statusCode,t=i.body,n=i.bodyText;let s="";return t&&typeof t=="object"?s=((a=t==null?void 0:t.error)==null?void 0:a.message)||(t==null?void 0:t.error)||(t==null?void 0:t.message)||"":typeof t=="string"&&(s=t),!s&&n&&(s=n),e&&s?`${e} ${s}`.trim():e?`HTTP ${e}`:s||"Request failed"},df={request:(i,e)=>pe(null,null,function*(){var o,c,d,h;const t=yield Ce.post("/api-call",i,e),n=Number((c=(o=t==null?void 0:t.status_code)!=null?o:t==null?void 0:t.statusCode)!=null?c:0),s=(h=(d=t==null?void 0:t.header)!=null?d:t==null?void 0:t.headers)!=null?h:{},{bodyText:a,body:r}=dz(t==null?void 0:t.body);return{statusCode:n,header:s,bodyText:a,body:r}})},hz=i=>{let e=String(i||"").trim();return e?(e=e.replace(/\/?v0\/management\/?$/i,""),e=e.replace(/\/+$/g,""),/^https?:\/\//i.test(e)||(e=`http://${e}`),e):""},eO=i=>{const e=hz(i);return e?e.endsWith("/v1")?`${e}/models`:`${e}/v1/models`:""},Wx={fetchModels(n,s){return pe(this,arguments,function*(i,e,t={}){var d,h,p,_;const a=eO(i);if(!a)throw new Error("Invalid base url");const r=z({},t);e&&(r.Authorization=`Bearer ${e}`);const o=yield li.get(a,{headers:Object.keys(r).length?r:void 0}),c=(_=(p=(d=o.data)==null?void 0:d.data)!=null?p:(h=o.data)==null?void 0:h.models)!=null?_:o.data;return $C(c,{dedupe:!0})})},fetchModelsViaApiCall(n,s){return pe(this,arguments,function*(i,e,t={}){var h;const a=eO(i);if(!a)throw new Error("Invalid base url");const r=z({},t),o=!!(r.Authorization||r.authorization);e&&!o&&(r.Authorization=`Bearer ${e}`);const c=yield df.request({method:"GET",url:a,header:Object.keys(r).length?r:void 0});if(c.statusCode<200||c.statusCode>=300)throw new Error(uf(c));const d=(h=c.body)!=null?h:c.bodyText;return $C(d,{dedupe:!0})})}},_l=Kl((i,e)=>({models:[],loading:!1,error:null,cache:null,fetchModels:(t,n,s=!1)=>pe(null,null,function*(){const{cache:a,isCacheValid:r}=e();if(!s&&r(t)&&a)return i({models:a.data,error:null}),a.data;i({loading:!0,error:null});try{const o=yield Wx.fetchModels(t,n),c=Date.now();return i({models:o,loading:!1,cache:{data:o,timestamp:c,apiBase:t}}),o}catch(o){const c=(o==null?void 0:o.message)||"Failed to fetch models";throw i({error:c,loading:!1,models:[]}),o}}),clearCache:()=>{i({cache:null,models:[]})},isCacheValid:t=>{const{cache:n}=e();return!n||n.apiBase!==t?!1:Date.now()-n.timestamptypeof i=="function"?i(e):i,Xx=Kl(i=>({antigravityQuota:{},codexQuota:{},geminiCliQuota:{},setAntigravityQuota:e=>i(t=>({antigravityQuota:A1(e,t.antigravityQuota)})),setCodexQuota:e=>i(t=>({codexQuota:A1(e,t.codexQuota)})),setGeminiCliQuota:e=>i(t=>({geminiCliQuota:A1(e,t.geminiCliQuota)})),clearQuotaCache:()=>i({antigravityQuota:{},codexQuota:{},geminiCliQuota:{}})}));function fz(){var U,G;const{t:i}=rt(),e=Ov(),t=Vs(),{showNotification:n}=Zn(),s=wh($=>$.language),a=wh($=>$.toggleLanguage),r=Ct($=>$.isAuthenticated),o=Ct($=>$.login),c=Ct($=>$.restoreSession),d=Ct($=>$.apiBase),h=Ct($=>$.managementKey),p=Ct($=>$.rememberPassword),[_,y]=N.useState(""),[x,v]=N.useState(""),[w,k]=N.useState(!1),[M,O]=N.useState(!1),[A,C]=N.useState(!1),[P,R]=N.useState(!1),[E,L]=N.useState(!0),[D,q]=N.useState(""),B=N.useMemo(()=>FR(),[]),H=i(s==="zh-CN"?"language.english":"language.chinese");N.useEffect(()=>{pe(null,null,function*(){try{(yield c())||(y(d||B),v(h||""),C(p||!!h))}finally{L(!1)}})},[B,c,d,h,p]);const W=()=>pe(null,null,function*(){if(!x.trim()){q(i("login.error_required"));return}const $=_?kh(_):B;R(!0),q("");try{yield o({apiBase:$,managementKey:x.trim(),rememberPassword:A}),n(i("common.connected_status"),"success"),e("/",{replace:!0})}catch(ie){const ue=(ie==null?void 0:ie.message)||i("login.error_invalid");q(ue),n(`${i("notification.login_failed")}: ${ue}`,"error")}finally{R(!1)}}),V=N.useCallback($=>{$.key==="Enter"&&!P&&($.preventDefault(),W())},[P,W]);if(r){const $=((G=(U=t.state)==null?void 0:U.from)==null?void 0:G.pathname)||"/";return g.jsx(Nv,{to:$,replace:!0})}return g.jsx("div",{className:"login-page",children:g.jsxs("div",{className:"login-card",children:[g.jsxs("div",{className:"login-header",children:[g.jsxs("div",{className:"login-title-row",children:[g.jsx("div",{className:"title",children:i("title.login")}),g.jsx(ye,{type:"button",variant:"ghost",size:"sm",className:"login-language-btn",onClick:a,title:i("language.switch"),"aria-label":i("language.switch"),children:H})]}),g.jsx("div",{className:"subtitle",children:i("login.subtitle")})]}),g.jsxs("div",{className:"connection-box",children:[g.jsx("div",{className:"label",children:i("login.connection_current")}),g.jsx("div",{className:"value",children:_||B}),g.jsx("div",{className:"hint",children:i("login.connection_auto_hint")})]}),g.jsxs("div",{className:"toggle-advanced",children:[g.jsx("input",{id:"custom-connection-toggle",type:"checkbox",checked:w,onChange:$=>k($.target.checked)}),g.jsx("label",{htmlFor:"custom-connection-toggle",children:i("login.custom_connection_label")})]}),w&&g.jsx(et,{label:i("login.custom_connection_label"),placeholder:i("login.custom_connection_placeholder"),value:_,onChange:$=>y($.target.value),hint:i("login.custom_connection_hint")}),g.jsx(et,{autoFocus:!0,label:i("login.management_key_label"),placeholder:i("login.management_key_placeholder"),type:M?"text":"password",value:x,onChange:$=>v($.target.value),onKeyDown:V,rightElement:g.jsx("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:()=>O($=>!$),"aria-label":M?i("login.hide_key",{defaultValue:"隐藏密钥"}):i("login.show_key",{defaultValue:"显示密钥"}),title:M?i("login.hide_key",{defaultValue:"隐藏密钥"}):i("login.show_key",{defaultValue:"显示密钥"}),children:M?g.jsx(eR,{size:16}):g.jsx(GU,{size:16})})}),g.jsxs("div",{className:"toggle-advanced",children:[g.jsx("input",{id:"remember-password-toggle",type:"checkbox",checked:A,onChange:$=>C($.target.checked)}),g.jsx("label",{htmlFor:"remember-password-toggle",children:i("login.remember_password_label")})]}),g.jsx(ye,{fullWidth:!0,onClick:W,loading:P,children:i(P?"login.submitting":"login.submit_button")}),D&&g.jsx("div",{className:"error-box",children:D}),E&&g.jsxs("div",{className:"connection-box",children:[g.jsx("div",{className:"label",children:i("auto_login.title")}),g.jsx("div",{className:"value",children:i("auto_login.message")})]})]})})}const tO=300;function pz(){const{notifications:i,removeNotification:e}=Zn(),[t,n]=N.useState([]),s=N.useRef([]);N.useEffect(()=>{const r=s.current,o=new Set(r.map(p=>p.id)),c=new Set(i.map(p=>p.id)),d=i.filter(p=>!o.has(p.id)),h=new Set(r.filter(p=>!c.has(p.id)).map(p=>p.id));n(p=>{let _=p.map(y=>h.has(y.id)?ee(z({},y),{isExiting:!0}):y);return d.forEach(y=>{_.find(x=>x.id===y.id)||_.push(ee(z({},y),{isExiting:!1}))}),_=_.filter(y=>c.has(y.id)||y.isExiting),_}),h.size>0&&setTimeout(()=>{n(p=>p.filter(_=>!h.has(_.id)))},tO),s.current=i},[i]);const a=r=>{n(o=>o.map(c=>c.id===r?ee(z({},c),{isExiting:!0}):c)),setTimeout(()=>{e(r)},tO)};return t.length?g.jsx("div",{className:"notification-container",children:t.map(r=>g.jsxs("div",{className:`notification ${r.type} ${r.isExiting?"exiting":"entering"}`,children:[g.jsx("div",{className:"message",children:r.message}),g.jsx("button",{className:"close-btn",onClick:()=>a(r.id),"aria-label":"Close",children:g.jsx(Hl,{size:16})})]},r.id))}):null}const mz=400;function gz({onFinish:i,fadeOut:e=!1}){return N.useEffect(()=>{if(!e)return;const t=setTimeout(()=>{i()},mz);return()=>{clearTimeout(t)}},[e,i]),g.jsx("div",{className:`splash-screen ${e?"fade-out":""}`,children:g.jsxs("div",{className:"splash-content",children:[g.jsx("img",{src:mg,alt:"CPAMC",className:"splash-logo"}),g.jsx("h1",{className:"splash-title",children:"CLI Proxy API"}),g.jsx("p",{className:"splash-subtitle",children:"Management Center"}),g.jsx("div",{className:"splash-loader",children:g.jsx("div",{className:"splash-loader-bar"})})]})})}const _z=350,Sg="modal-open";let th=0;const yz=()=>{var i,e;typeof document!="undefined"&&(th===0&&((i=document.body)==null||i.classList.add(Sg),(e=document.documentElement)==null||e.classList.add(Sg)),th+=1)},xz=()=>{var i,e;typeof document!="undefined"&&(th=Math.max(0,th-1),th===0&&((i=document.body)==null||i.classList.remove(Sg),(e=document.documentElement)==null||e.classList.remove(Sg)))};function zn({open:i,title:e,onClose:t,footer:n,width:s=520,children:a}){const[r,o]=N.useState(!1),[c,d]=N.useState(!1),h=N.useRef(null),p=N.useCallback(k=>{h.current===null&&(d(!0),h.current=window.setTimeout(()=>{o(!1),d(!1),h.current=null,k&&t()},_z))},[t]);N.useEffect(()=>{let k=!1;return i?(h.current!==null&&(window.clearTimeout(h.current),h.current=null),queueMicrotask(()=>{k||(o(!0),d(!1))})):r&&queueMicrotask(()=>{k||p(!1)}),()=>{k=!0}},[i,r,p]);const _=N.useCallback(()=>{p(!0)},[p]);N.useEffect(()=>()=>{h.current!==null&&window.clearTimeout(h.current)},[]);const y=i||r;if(N.useEffect(()=>{if(y)return yz(),()=>xz()},[y]),!i&&!r)return null;const x=`modal-overlay ${c?"modal-overlay-closing":"modal-overlay-entering"}`,v=`modal ${c?"modal-closing":"modal-entering"}`,w=g.jsx("div",{className:x,children:g.jsxs("div",{className:v,style:{width:s},role:"dialog","aria-modal":"true",children:[g.jsx("button",{className:"modal-close-floating",onClick:_,"aria-label":"Close",children:g.jsx(Hl,{size:20})}),g.jsx("div",{className:"modal-header",children:g.jsx("div",{className:"modal-title",children:e})}),g.jsx("div",{className:"modal-body",children:a}),n&&g.jsx("div",{className:"modal-footer",children:n})]})});return typeof document=="undefined"?w:eU.createPortal(w,document.body)}function Sn({checked:i,onChange:e,label:t,disabled:n=!1,labelPosition:s="right"}){const a=o=>{e(o.target.checked)},r=["switch",s==="left"?"switch-label-left":""].filter(Boolean).join(" ");return g.jsxs("label",{className:r,children:[g.jsx("input",{type:"checkbox",checked:i,onChange:a,disabled:n}),g.jsx("span",{className:"track",children:g.jsx("span",{className:"thumb"})}),t&&g.jsx("span",{className:"label",children:t})]})}function rr(i){if(i===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return i}function zR(i,e){i.prototype=Object.create(e.prototype),i.prototype.constructor=i,i.__proto__=e}var ps={autoSleep:120,force3D:"auto",nullTargetWarn:1,units:{lineHeight:""}},au={duration:.5,overwrite:!1,delay:0},Hv,sn,$t,Ls=1e8,Kt=1/Ls,Gx=Math.PI*2,bz=Gx/4,vz=0,qR=Math.sqrt,Sz=Math.cos,wz=Math.sin,Ii=function(e){return typeof e=="string"},hi=function(e){return typeof e=="function"},yr=function(e){return typeof e=="number"},Kv=function(e){return typeof e=="undefined"},Pa=function(e){return typeof e=="object"},In=function(e){return e!==!1},Vv=function(){return typeof window!="undefined"},em=function(e){return hi(e)||Ii(e)},HR=typeof ArrayBuffer=="function"&&ArrayBuffer.isView||function(){},fn=Array.isArray,kz=/random\([^)]+\)/g,Az=/,\s*/g,iO=/(?:-?\.?\d|\.)+/gi,KR=/[-+=.]*\d+[.e\-+]*\d*[e\-+]*\d*/g,Bc=/[-+=.]*\d+[.e-]*\d*[a-z%]*/g,C1=/[-+=.]*\d+\.?\d*(?:e-|e\+)?\d*/gi,VR=/[+-]=-?[.\d]+/,Cz=/[^,'"\[\]\s]+/gi,Oz=/^[+\-=e\s\d]*\d+[.\d]*([a-z]*|%)\s*$/i,ri,va,Qx,Iv,gs={},wg={},IR,WR=function(e){return(wg=ru(e,gs))&&Qn},Wv=function(e,t){return console.warn("Invalid property",e,"set to",t,"Missing plugin? gsap.registerPlugin()")},Ah=function(e,t){return!t&&console.warn(e)},XR=function(e,t){return e&&(gs[e]=t)&&wg&&(wg[e]=t)||gs},Ch=function(){return 0},Tz={suppressEvents:!0,isStart:!0,kill:!1},Qm={suppressEvents:!0,kill:!1},Mz={suppressEvents:!0},Xv={},yo=[],Yx={},GR,cs={},O1={},nO=30,Ym=[],Gv="",Qv=function(e){var t=e[0],n,s;if(Pa(t)||hi(t)||(e=[e]),!(n=(t._gsap||{}).harness)){for(s=Ym.length;s--&&!Ym[s].targetTest(t););n=Ym[s]}for(s=e.length;s--;)e[s]&&(e[s]._gsap||(e[s]._gsap=new yP(e[s],n)))||e.splice(s,1);return e},Al=function(e){return e._gsap||Qv(js(e))[0]._gsap},QR=function(e,t,n){return(n=e[t])&&hi(n)?e[t]():Kv(n)&&e.getAttribute&&e.getAttribute(t)||n},Wn=function(e,t){return(e=e.split(",")).forEach(t)||e},yi=function(e){return Math.round(e*1e5)/1e5||0},ai=function(e){return Math.round(e*1e7)/1e7||0},Xc=function(e,t){var n=t.charAt(0),s=parseFloat(t.substr(2));return e=parseFloat(e),n==="+"?e+s:n==="-"?e-s:n==="*"?e*s:e/s},Nz=function(e,t){for(var n=t.length,s=0;e.indexOf(t[s])<0&&++so;)r=r._prev;return r?(t._next=r._next,r._next=t):(t._next=e[n],e[n]=t),t._next?t._next._prev=t:e[s]=t,t._prev=r,t.parent=t._dp=e,t},S0=function(e,t,n,s){n===void 0&&(n="_first"),s===void 0&&(s="_last");var a=t._prev,r=t._next;a?a._next=r:e[n]===t&&(e[n]=r),r?r._prev=a:e[s]===t&&(e[s]=a),t._next=t._prev=t.parent=null},So=function(e,t){e.parent&&(!t||e.parent.autoRemoveChildren)&&e.parent.remove&&e.parent.remove(e),e._act=0},Cl=function(e,t){if(e&&(!t||t._end>e._dur||t._start<0))for(var n=e;n;)n._dirty=1,n=n.parent;return e},Lz=function(e){for(var t=e.parent;t&&t.parent;)t._dirty=1,t.totalDuration(),t=t.parent;return e},Zx=function(e,t,n,s){return e._startAt&&(sn?e._startAt.revert(Qm):e.vars.immediateRender&&!e.vars.autoRevert||e._startAt.render(t,!0,s))},jz=function i(e){return!e||e._ts&&i(e.parent)},aO=function(e){return e._repeat?ou(e._tTime,e=e.duration()+e._rDelay)*e:0},ou=function(e,t){var n=Math.floor(e=ai(e/t));return e&&n===e?n-1:n},Cg=function(e,t){return(e-t._start)*t._ts+(t._ts>=0?0:t._dirty?t.totalDuration():t._tDur)},w0=function(e){return e._end=ai(e._start+(e._tDur/Math.abs(e._ts||e._rts||Kt)||0))},k0=function(e,t){var n=e._dp;return n&&n.smoothChildTiming&&e._ts&&(e._start=ai(n._time-(e._ts>0?t/e._ts:((e._dirty?e.totalDuration():e._tDur)-t)/-e._ts)),w0(e),n._dirty||Cl(n,e)),e},eP=function(e,t){var n;if((t._time||!t._dur&&t._initted||t._startKt)&&t.render(n,!0)),Cl(e,t)._dp&&e._initted&&e._time>=e._dur&&e._ts){if(e._dur=0&&n.totalTime(n._tTime),n=n._dp;e._zTime=-Kt}},wa=function(e,t,n,s){return t.parent&&So(t),t._start=ai((yr(n)?n:n||e!==ri?Rs(e,n,t):e._time)+t._delay),t._end=ai(t._start+(t.totalDuration()/Math.abs(t.timeScale())||0)),$R(e,t,"_first","_last",e._sort?"_start":0),Jx(t)||(e._recent=t),s||eP(e,t),e._ts<0&&k0(e,e._tTime),e},tP=function(e,t){return(gs.ScrollTrigger||Wv("scrollTrigger",t))&&gs.ScrollTrigger.create(t,e)},iP=function(e,t,n,s,a){if(Jv(e,t,a),!e._initted)return 1;if(!n&&e._pt&&!sn&&(e._dur&&e.vars.lazy!==!1||!e._dur&&e.vars.lazy)&&GR!==us.frame)return yo.push(e),e._lazy=[a,s],1},Ez=function i(e){var t=e.parent;return t&&t._ts&&t._initted&&!t._lock&&(t.rawTime()<0||i(t))},Jx=function(e){var t=e.data;return t==="isFromStart"||t==="isStart"},Dz=function(e,t,n,s){var a=e.ratio,r=t<0||!t&&(!e._start&&Ez(e)&&!(!e._initted&&Jx(e))||(e._ts<0||e._dp._ts<0)&&!Jx(e))?0:1,o=e._rDelay,c=0,d,h,p;if(o&&e._repeat&&(c=hf(0,e._tDur,t),h=ou(c,o),e._yoyo&&h&1&&(r=1-r),h!==ou(e._tTime,o)&&(a=1-r,e.vars.repeatRefresh&&e._initted&&e.invalidate())),r!==a||sn||s||e._zTime===Kt||!t&&e._zTime){if(!e._initted&&iP(e,t,s,n,c))return;for(p=e._zTime,e._zTime=t||(n?Kt:0),n||(n=t&&!p),e.ratio=r,e._from&&(r=1-r),e._time=0,e._tTime=c,d=e._pt;d;)d.r(r,d.d),d=d._next;t<0&&Zx(e,t,n,!0),e._onUpdate&&!n&&ds(e,"onUpdate"),c&&e._repeat&&!n&&e.parent&&ds(e,"onRepeat"),(t>=e._tDur||t<0)&&e.ratio===r&&(r&&So(e,1),!n&&!sn&&(ds(e,r?"onComplete":"onReverseComplete",!0),e._prom&&e._prom()))}else e._zTime||(e._zTime=t)},Uz=function(e,t,n){var s;if(n>t)for(s=e._first;s&&s._start<=n;){if(s.data==="isPause"&&s._start>t)return s;s=s._next}else for(s=e._last;s&&s._start>=n;){if(s.data==="isPause"&&s._start0&&!s&&k0(e,e._tTime=e._tDur*o),e.parent&&w0(e),n||Cl(e.parent,e),e},rO=function(e){return e instanceof kn?Cl(e):lu(e,e._dur)},Fz={_start:0,endTime:Ch,totalDuration:Ch},Rs=function i(e,t,n){var s=e.labels,a=e._recent||Fz,r=e.duration()>=Ls?a.endTime(!1):e._dur,o,c,d;return Ii(t)&&(isNaN(t)||t in s)?(c=t.charAt(0),d=t.substr(-1)==="%",o=t.indexOf("="),c==="<"||c===">"?(o>=0&&(t=t.replace(/=/,"")),(c==="<"?a._start:a.endTime(a._repeat>=0))+(parseFloat(t.substr(1))||0)*(d?(o<0?a:n).totalDuration()/100:1)):o<0?(t in s||(s[t]=r),s[t]):(c=parseFloat(t.charAt(o-1)+t.substr(o+1)),d&&n&&(c=c/100*(fn(n)?n[0]:n).totalDuration()),o>1?i(e,t.substr(0,o-1),n)+c:r+c)):t==null?r:+t},nh=function(e,t,n){var s=yr(t[1]),a=(s?2:1)+(e<2?0:1),r=t[a],o,c;if(s&&(r.duration=t[1]),r.parent=n,e){for(o=r,c=n;c&&!("immediateRender"in o);)o=c.vars.defaults||{},c=In(c.vars.inherit)&&c.parent;r.immediateRender=In(o.immediateRender),e<2?r.runBackwards=1:r.startAt=t[a-1]}return new Ni(t[0],r,t[a+1])},Ro=function(e,t){return e||e===0?t(e):t},hf=function(e,t,n){return nt?t:n},un=function(e,t){return!Ii(e)||!(t=Oz.exec(e))?"":t[1]},Bz=function(e,t,n){return Ro(n,function(s){return hf(e,t,s)})},$x=[].slice,nP=function(e,t){return e&&Pa(e)&&"length"in e&&(!t&&!e.length||e.length-1 in e&&Pa(e[0]))&&!e.nodeType&&e!==va},zz=function(e,t,n){return n===void 0&&(n=[]),e.forEach(function(s){var a;return Ii(s)&&!t||nP(s,1)?(a=n).push.apply(a,js(s)):n.push(s)})||n},js=function(e,t,n){return $t&&!t&&$t.selector?$t.selector(e):Ii(e)&&!n&&(Qx||!cu())?$x.call((t||Iv).querySelectorAll(e),0):fn(e)?zz(e,n):nP(e)?$x.call(e,0):e?[e]:[]},eb=function(e){return e=js(e)[0]||Ah("Invalid scope")||{},function(t){var n=e.current||e.nativeElement||e;return js(t,n.querySelectorAll?n:n===e?Ah("Invalid scope")||Iv.createElement("div"):e)}},sP=function(e){return e.sort(function(){return .5-Math.random()})},aP=function(e){if(hi(e))return e;var t=Pa(e)?e:{each:e},n=Ol(t.ease),s=t.from||0,a=parseFloat(t.base)||0,r={},o=s>0&&s<1,c=isNaN(s)||o,d=t.axis,h=s,p=s;return Ii(s)?h=p={center:.5,edges:.5,end:1}[s]||0:!o&&c&&(h=s[0],p=s[1]),function(_,y,x){var v=(x||t).length,w=r[v],k,M,O,A,C,P,R,E,L;if(!w){if(L=t.grid==="auto"?0:(t.grid||[1,Ls])[1],!L){for(R=-Ls;R<(R=x[L++].getBoundingClientRect().left)&&LR&&(R=C),Cv?v-1:d?d==="y"?v/L:L:Math.max(L,v/L))||0)*(s==="edges"?-1:1),w.b=v<0?a-v:a,w.u=un(t.amount||t.each)||0,n=n&&v<0?mP(n):n}return v=(w[_]-w.min)/w.max||0,ai(w.b+(n?n(v):v)*w.v)+w.u}},tb=function(e){var t=Math.pow(10,((e+"").split(".")[1]||"").length);return function(n){var s=ai(Math.round(parseFloat(n)/e)*e*t);return(s-s%1)/t+(yr(n)?0:un(n))}},rP=function(e,t){var n=fn(e),s,a;return!n&&Pa(e)&&(s=n=e.radius||Ls,e.values?(e=js(e.values),(a=!yr(e[0]))&&(s*=s)):e=tb(e.increment)),Ro(t,n?hi(e)?function(r){return a=e(r),Math.abs(a-r)<=s?a:r}:function(r){for(var o=parseFloat(a?r.x:r),c=parseFloat(a?r.y:0),d=Ls,h=0,p=e.length,_,y;p--;)a?(_=e[p].x-o,y=e[p].y-c,_=_*_+y*y):_=Math.abs(e[p]-o),_s?a-r:r)})},Oh=function(e){return e.replace(kz,function(t){var n=t.indexOf("[")+1,s=t.substring(n||7,n?t.indexOf("]"):t.length-1).split(Az);return oP(n?s:+s[0],n?0:+s[1],+s[2]||1e-5)})},cP=function(e,t,n,s,a){var r=t-e,o=s-n;return Ro(a,function(c){return n+((c-e)/r*o||0)})},Wz=function i(e,t,n,s){var a=isNaN(e+t)?0:function(y){return(1-y)*e+y*t};if(!a){var r=Ii(e),o={},c,d,h,p,_;if(n===!0&&(s=1)&&(n=null),r)e={p:e},t={p:t};else if(fn(e)&&!fn(t)){for(h=[],p=e.length,_=p-2,d=1;d(o=Math.abs(o))&&(c=r,a=o);return c},ds=function(e,t,n){var s=e.vars,a=s[t],r=$t,o=e._ctx,c,d,h;if(a)return c=s[t+"Params"],d=s.callbackScope||e,n&&yo.length&&kg(),o&&($t=o),h=c?a.apply(d,c):a.call(d),$t=r,h},Kd=function(e){return So(e),e.scrollTrigger&&e.scrollTrigger.kill(!!sn),e.progress()<1&&ds(e,"onInterrupt"),e},zc,uP=[],dP=function(e){if(e)if(e=!e.name&&e.default||e,Vv()||e.headless){var t=e.name,n=hi(e),s=t&&!n&&e.init?function(){this._props=[]}:e,a={init:Ch,render:t2,add:Zv,kill:l7,modifier:o7,rawVars:0},r={targetTest:0,get:0,getSetter:e2,aliases:{},register:0};if(cu(),e!==s){if(cs[t])return;_s(s,_s(Ag(e,a),r)),ru(s.prototype,ru(a,Ag(e,r))),cs[s.prop=t]=s,e.targetTest&&(Ym.push(s),Xv[t]=1),t=(t==="css"?"CSS":t.charAt(0).toUpperCase()+t.substr(1))+"Plugin"}XR(t,s),e.register&&e.register(Qn,s,Xn)}else uP.push(e)},qt=255,Vd={aqua:[0,qt,qt],lime:[0,qt,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,qt],navy:[0,0,128],white:[qt,qt,qt],olive:[128,128,0],yellow:[qt,qt,0],orange:[qt,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[qt,0,0],pink:[qt,192,203],cyan:[0,qt,qt],transparent:[qt,qt,qt,0]},T1=function(e,t,n){return e+=e<0?1:e>1?-1:0,(e*6<1?t+(n-t)*e*6:e<.5?n:e*3<2?t+(n-t)*(2/3-e)*6:t)*qt+.5|0},hP=function(e,t,n){var s=e?yr(e)?[e>>16,e>>8&qt,e&qt]:0:Vd.black,a,r,o,c,d,h,p,_,y,x;if(!s){if(e.substr(-1)===","&&(e=e.substr(0,e.length-1)),Vd[e])s=Vd[e];else if(e.charAt(0)==="#"){if(e.length<6&&(a=e.charAt(1),r=e.charAt(2),o=e.charAt(3),e="#"+a+a+r+r+o+o+(e.length===5?e.charAt(4)+e.charAt(4):"")),e.length===9)return s=parseInt(e.substr(1,6),16),[s>>16,s>>8&qt,s&qt,parseInt(e.substr(7),16)/255];e=parseInt(e.substr(1),16),s=[e>>16,e>>8&qt,e&qt]}else if(e.substr(0,3)==="hsl"){if(s=x=e.match(iO),!t)c=+s[0]%360/360,d=+s[1]/100,h=+s[2]/100,r=h<=.5?h*(d+1):h+d-h*d,a=h*2-r,s.length>3&&(s[3]*=1),s[0]=T1(c+1/3,a,r),s[1]=T1(c,a,r),s[2]=T1(c-1/3,a,r);else if(~e.indexOf("="))return s=e.match(KR),n&&s.length<4&&(s[3]=1),s}else s=e.match(iO)||Vd.transparent;s=s.map(Number)}return t&&!x&&(a=s[0]/qt,r=s[1]/qt,o=s[2]/qt,p=Math.max(a,r,o),_=Math.min(a,r,o),h=(p+_)/2,p===_?c=d=0:(y=p-_,d=h>.5?y/(2-p-_):y/(p+_),c=p===a?(r-o)/y+(re||k<0)&&(n+=k-t),s+=k,C=s-n,O=C-r,(O>0||M)&&(P=++p.frame,_=C-p.time*1e3,p.time=C=C/1e3,r+=O+(O>=a?4:a-O),A=1),M||(c=d(v)),A)for(y=0;y=k&&y--},_listeners:o},p})(),cu=function(){return!Th&&us.wake()},ht={},Gz=/^[\d.\-M][\d.\-,\s]/,Qz=/["']/g,Yz=function(e){for(var t={},n=e.substr(1,e.length-3).split(":"),s=n[0],a=1,r=n.length,o,c,d;a1&&n.config?n.config.apply(null,~e.indexOf("{")?[Yz(t[1])]:Zz(e).split(",").map(ZR)):ht._CE&&Gz.test(e)?ht._CE("",e):n},mP=function(e){return function(t){return 1-e(1-t)}},gP=function i(e,t){for(var n=e._first,s;n;)n instanceof kn?i(n,t):n.vars.yoyoEase&&(!n._yoyo||!n._repeat)&&n._yoyo!==t&&(n.timeline?i(n.timeline,t):(s=n._ease,n._ease=n._yEase,n._yEase=s,n._yoyo=t)),n=n._next},Ol=function(e,t){return e&&(hi(e)?e:ht[e]||Jz(e))||t},Vl=function(e,t,n,s){n===void 0&&(n=function(c){return 1-t(1-c)}),s===void 0&&(s=function(c){return c<.5?t(c*2)/2:1-t((1-c)*2)/2});var a={easeIn:t,easeOut:n,easeInOut:s},r;return Wn(e,function(o){ht[o]=gs[o]=a,ht[r=o.toLowerCase()]=n;for(var c in a)ht[r+(c==="easeIn"?".in":c==="easeOut"?".out":".inOut")]=ht[o+"."+c]=a[c]}),a},_P=function(e){return function(t){return t<.5?(1-e(1-t*2))/2:.5+e((t-.5)*2)/2}},M1=function i(e,t,n){var s=t>=1?t:1,a=(n||(e?.3:.45))/(t<1?t:1),r=a/Gx*(Math.asin(1/s)||0),o=function(h){return h===1?1:s*Math.pow(2,-10*h)*wz((h-r)*a)+1},c=e==="out"?o:e==="in"?function(d){return 1-o(1-d)}:_P(o);return a=Gx/a,c.config=function(d,h){return i(e,d,h)},c},N1=function i(e,t){t===void 0&&(t=1.70158);var n=function(r){return r?--r*r*((t+1)*r+t)+1:0},s=e==="out"?n:e==="in"?function(a){return 1-n(1-a)}:_P(n);return s.config=function(a){return i(e,a)},s};Wn("Linear,Quad,Cubic,Quart,Quint,Strong",function(i,e){var t=e<5?e+1:e;Vl(i+",Power"+(t-1),e?function(n){return Math.pow(n,t)}:function(n){return n},function(n){return 1-Math.pow(1-n,t)},function(n){return n<.5?Math.pow(n*2,t)/2:1-Math.pow((1-n)*2,t)/2})});ht.Linear.easeNone=ht.none=ht.Linear.easeIn;Vl("Elastic",M1("in"),M1("out"),M1());(function(i,e){var t=1/e,n=2*t,s=2.5*t,a=function(o){return o0?n+(n+this._rDelay)*this._repeat:n):this.totalDuration()&&this._dur},e.totalDuration=function(n){return arguments.length?(this._dirty=0,lu(this,this._repeat<0?n:(n-this._repeat*this._rDelay)/(this._repeat+1))):this._tDur},e.totalTime=function(n,s){if(cu(),!arguments.length)return this._tTime;var a=this._dp;if(a&&a.smoothChildTiming&&this._ts){for(k0(this,n),!a._dp||a.parent||eP(a,this);a&&a.parent;)a.parent._time!==a._start+(a._ts>=0?a._tTime/a._ts:(a.totalDuration()-a._tTime)/-a._ts)&&a.totalTime(a._tTime,!0),a=a.parent;!this.parent&&this._dp.autoRemoveChildren&&(this._ts>0&&n0||!this._tDur&&!n)&&wa(this._dp,this,this._start-this._delay)}return(this._tTime!==n||!this._dur&&!s||this._initted&&Math.abs(this._zTime)===Kt||!this._initted&&this._dur&&n||!n&&!this._initted&&(this.add||this._ptLookup))&&(this._ts||(this._pTime=n),YR(this,n,s)),this},e.time=function(n,s){return arguments.length?this.totalTime(Math.min(this.totalDuration(),n+aO(this))%(this._dur+this._rDelay)||(n?this._dur:0),s):this._time},e.totalProgress=function(n,s){return arguments.length?this.totalTime(this.totalDuration()*n,s):this.totalDuration()?Math.min(1,this._tTime/this._tDur):this.rawTime()>=0&&this._initted?1:0},e.progress=function(n,s){return arguments.length?this.totalTime(this.duration()*(this._yoyo&&!(this.iteration()&1)?1-n:n)+aO(this),s):this.duration()?Math.min(1,this._time/this._dur):this.rawTime()>0?1:0},e.iteration=function(n,s){var a=this.duration()+this._rDelay;return arguments.length?this.totalTime(this._time+(n-1)*a,s):this._repeat?ou(this._tTime,a)+1:1},e.timeScale=function(n,s){if(!arguments.length)return this._rts===-Kt?0:this._rts;if(this._rts===n)return this;var a=this.parent&&this._ts?Cg(this.parent._time,this):this._tTime;return this._rts=+n||0,this._ts=this._ps||n===-Kt?0:this._rts,this.totalTime(hf(-Math.abs(this._delay),this.totalDuration(),a),s!==!1),w0(this),Lz(this)},e.paused=function(n){return arguments.length?(this._ps!==n&&(this._ps=n,n?(this._pTime=this._tTime||Math.max(-this._delay,this.rawTime()),this._ts=this._act=0):(cu(),this._ts=this._rts,this.totalTime(this.parent&&!this.parent.smoothChildTiming?this.rawTime():this._tTime||this._pTime,this.progress()===1&&Math.abs(this._zTime)!==Kt&&(this._tTime-=Kt)))),this):this._ps},e.startTime=function(n){if(arguments.length){this._start=ai(n);var s=this.parent||this._dp;return s&&(s._sort||!this.parent)&&wa(s,this,this._start-this._delay),this}return this._start},e.endTime=function(n){return this._start+(In(n)?this.totalDuration():this.duration())/Math.abs(this._ts||1)},e.rawTime=function(n){var s=this.parent||this._dp;return s?n&&(!this._ts||this._repeat&&this._time&&this.totalProgress()<1)?this._tTime%(this._dur+this._rDelay):this._ts?Cg(s.rawTime(n),this):this._tTime:this._tTime},e.revert=function(n){n===void 0&&(n=Mz);var s=sn;return sn=n,Yv(this)&&(this.timeline&&this.timeline.revert(n),this.totalTime(-.01,n.suppressEvents)),this.data!=="nested"&&n.kill!==!1&&this.kill(),sn=s,this},e.globalTime=function(n){for(var s=this,a=arguments.length?n:s.rawTime();s;)a=s._start+a/(Math.abs(s._ts)||1),s=s._dp;return!this.parent&&this._sat?this._sat.globalTime(n):a},e.repeat=function(n){return arguments.length?(this._repeat=n===1/0?-2:n,rO(this)):this._repeat===-2?1/0:this._repeat},e.repeatDelay=function(n){if(arguments.length){var s=this._time;return this._rDelay=n,rO(this),s?this.time(s):this}return this._rDelay},e.yoyo=function(n){return arguments.length?(this._yoyo=n,this):this._yoyo},e.seek=function(n,s){return this.totalTime(Rs(this,n),In(s))},e.restart=function(n,s){return this.play().totalTime(n?-this._delay:0,In(s)),this._dur||(this._zTime=-Kt),this},e.play=function(n,s){return n!=null&&this.seek(n,s),this.reversed(!1).paused(!1)},e.reverse=function(n,s){return n!=null&&this.seek(n||this.totalDuration(),s),this.reversed(!0).paused(!1)},e.pause=function(n,s){return n!=null&&this.seek(n,s),this.paused(!0)},e.resume=function(){return this.paused(!1)},e.reversed=function(n){return arguments.length?(!!n!==this.reversed()&&this.timeScale(-this._rts||(n?-Kt:0)),this):this._rts<0},e.invalidate=function(){return this._initted=this._act=0,this._zTime=-Kt,this},e.isActive=function(){var n=this.parent||this._dp,s=this._start,a;return!!(!n||this._ts&&this._initted&&n.isActive()&&(a=n.rawTime(!0))>=s&&a1?(s?(r[n]=s,a&&(r[n+"Params"]=a),n==="onUpdate"&&(this._onUpdate=s)):delete r[n],this):r[n]},e.then=function(n){var s=this,a=s._prom;return new Promise(function(r){var o=hi(n)?n:JR,c=function(){var h=s.then;s.then=null,a&&a(),hi(o)&&(o=o(s))&&(o.then||o===s)&&(s.then=h),r(o),s.then=h};s._initted&&s.totalProgress()===1&&s._ts>=0||!s._tTime&&s._ts<0?c():s._prom=c})},e.kill=function(){Kd(this)},i})();_s(Mh.prototype,{_time:0,_start:0,_end:0,_tTime:0,_tDur:0,_dirty:0,_repeat:0,_yoyo:!1,parent:null,_initted:!1,_rDelay:0,_ts:1,_dp:0,ratio:0,_zTime:-Kt,_prom:0,_ps:!1,_rts:1});var kn=(function(i){zR(e,i);function e(n,s){var a;return n===void 0&&(n={}),a=i.call(this,n)||this,a.labels={},a.smoothChildTiming=!!n.smoothChildTiming,a.autoRemoveChildren=!!n.autoRemoveChildren,a._sort=In(n.sortChildren),ri&&wa(n.parent||ri,rr(a),s),n.reversed&&a.reverse(),n.paused&&a.paused(!0),n.scrollTrigger&&tP(rr(a),n.scrollTrigger),a}var t=e.prototype;return t.to=function(s,a,r){return nh(0,arguments,this),this},t.from=function(s,a,r){return nh(1,arguments,this),this},t.fromTo=function(s,a,r,o){return nh(2,arguments,this),this},t.set=function(s,a,r){return a.duration=0,a.parent=this,ih(a).repeatDelay||(a.repeat=0),a.immediateRender=!!a.immediateRender,new Ni(s,a,Rs(this,r),1),this},t.call=function(s,a,r){return wa(this,Ni.delayedCall(0,s,a),r)},t.staggerTo=function(s,a,r,o,c,d,h){return r.duration=a,r.stagger=r.stagger||o,r.onComplete=d,r.onCompleteParams=h,r.parent=this,new Ni(s,r,Rs(this,c)),this},t.staggerFrom=function(s,a,r,o,c,d,h){return r.runBackwards=1,ih(r).immediateRender=In(r.immediateRender),this.staggerTo(s,a,r,o,c,d,h)},t.staggerFromTo=function(s,a,r,o,c,d,h,p){return o.startAt=r,ih(o).immediateRender=In(o.immediateRender),this.staggerTo(s,a,o,c,d,h,p)},t.render=function(s,a,r){var o=this._time,c=this._dirty?this.totalDuration():this._tDur,d=this._dur,h=s<=0?0:ai(s),p=this._zTime<0!=s<0&&(this._initted||!d),_,y,x,v,w,k,M,O,A,C,P,R;if(this!==ri&&h>c&&s>=0&&(h=c),h!==this._tTime||r||p){if(o!==this._time&&d&&(h+=this._time-o,s+=this._time-o),_=h,A=this._start,O=this._ts,k=!O,p&&(d||(o=this._zTime),(s||!a)&&(this._zTime=s)),this._repeat){if(P=this._yoyo,w=d+this._rDelay,this._repeat<-1&&s<0)return this.totalTime(w*100+s,a,r);if(_=ai(h%w),h===c?(v=this._repeat,_=d):(C=ai(h/w),v=~~C,v&&v===C&&(_=d,v--),_>d&&(_=d)),C=ou(this._tTime,w),!o&&this._tTime&&C!==v&&this._tTime-C*w-this._dur<=0&&(C=v),P&&v&1&&(_=d-_,R=1),v!==C&&!this._lock){var E=P&&C&1,L=E===(P&&v&1);if(v=o&&s>=0)for(y=this._first;y;){if(x=y._next,(y._act||_>=y._start)&&y._ts&&M!==y){if(y.parent!==this)return this.render(s,a,r);if(y.render(y._ts>0?(_-y._start)*y._ts:(y._dirty?y.totalDuration():y._tDur)+(_-y._start)*y._ts,a,r),_!==this._time||!this._ts&&!k){M=0,x&&(h+=this._zTime=-Kt);break}}y=x}else{y=this._last;for(var D=s<0?s:_;y;){if(x=y._prev,(y._act||D<=y._end)&&y._ts&&M!==y){if(y.parent!==this)return this.render(s,a,r);if(y.render(y._ts>0?(D-y._start)*y._ts:(y._dirty?y.totalDuration():y._tDur)+(D-y._start)*y._ts,a,r||sn&&Yv(y)),_!==this._time||!this._ts&&!k){M=0,x&&(h+=this._zTime=D?-Kt:Kt);break}}y=x}}if(M&&!a&&(this.pause(),M.render(_>=o?0:-Kt)._zTime=_>=o?1:-1,this._ts))return this._start=A,w0(this),this.render(s,a,r);this._onUpdate&&!a&&ds(this,"onUpdate",!0),(h===c&&this._tTime>=this.totalDuration()||!h&&o)&&(A===this._start||Math.abs(O)!==Math.abs(this._ts))&&(this._lock||((s||!d)&&(h===c&&this._ts>0||!h&&this._ts<0)&&So(this,1),!a&&!(s<0&&!o)&&(h||o||!c)&&(ds(this,h===c&&s>=0?"onComplete":"onReverseComplete",!0),this._prom&&!(h0)&&this._prom())))}return this},t.add=function(s,a){var r=this;if(yr(a)||(a=Rs(this,a,s)),!(s instanceof Mh)){if(fn(s))return s.forEach(function(o){return r.add(o,a)}),this;if(Ii(s))return this.addLabel(s,a);if(hi(s))s=Ni.delayedCall(0,s);else return this}return this!==s?wa(this,s,a):this},t.getChildren=function(s,a,r,o){s===void 0&&(s=!0),a===void 0&&(a=!0),r===void 0&&(r=!0),o===void 0&&(o=-Ls);for(var c=[],d=this._first;d;)d._start>=o&&(d instanceof Ni?a&&c.push(d):(r&&c.push(d),s&&c.push.apply(c,d.getChildren(!0,a,r)))),d=d._next;return c},t.getById=function(s){for(var a=this.getChildren(1,1,1),r=a.length;r--;)if(a[r].vars.id===s)return a[r]},t.remove=function(s){return Ii(s)?this.removeLabel(s):hi(s)?this.killTweensOf(s):(s.parent===this&&S0(this,s),s===this._recent&&(this._recent=this._last),Cl(this))},t.totalTime=function(s,a){return arguments.length?(this._forcing=1,!this._dp&&this._ts&&(this._start=ai(us.time-(this._ts>0?s/this._ts:(this.totalDuration()-s)/-this._ts))),i.prototype.totalTime.call(this,s,a),this._forcing=0,this):this._tTime},t.addLabel=function(s,a){return this.labels[s]=Rs(this,a),this},t.removeLabel=function(s){return delete this.labels[s],this},t.addPause=function(s,a,r){var o=Ni.delayedCall(0,a||Ch,r);return o.data="isPause",this._hasPause=1,wa(this,o,Rs(this,s))},t.removePause=function(s){var a=this._first;for(s=Rs(this,s);a;)a._start===s&&a.data==="isPause"&&So(a),a=a._next},t.killTweensOf=function(s,a,r){for(var o=this.getTweensOf(s,r),c=o.length;c--;)lo!==o[c]&&o[c].kill(s,a);return this},t.getTweensOf=function(s,a){for(var r=[],o=js(s),c=this._first,d=yr(a),h;c;)c instanceof Ni?Nz(c._targets,o)&&(d?(!lo||c._initted&&c._ts)&&c.globalTime(0)<=a&&c.globalTime(c.totalDuration())>a:!a||c.isActive())&&r.push(c):(h=c.getTweensOf(o,a)).length&&r.push.apply(r,h),c=c._next;return r},t.tweenTo=function(s,a){a=a||{};var r=this,o=Rs(r,s),c=a,d=c.startAt,h=c.onStart,p=c.onStartParams,_=c.immediateRender,y,x=Ni.to(r,_s({ease:a.ease||"none",lazy:!1,immediateRender:!1,time:o,overwrite:"auto",duration:a.duration||Math.abs((o-(d&&"time"in d?d.time:r._time))/r.timeScale())||Kt,onStart:function(){if(r.pause(),!y){var w=a.duration||Math.abs((o-(d&&"time"in d?d.time:r._time))/r.timeScale());x._dur!==w&&lu(x,w,0,1).render(x._time,!0,!0),y=1}h&&h.apply(x,p||[])}},a));return _?x.render(0):x},t.tweenFromTo=function(s,a,r){return this.tweenTo(a,_s({startAt:{time:Rs(this,s)}},r))},t.recent=function(){return this._recent},t.nextLabel=function(s){return s===void 0&&(s=this._time),oO(this,Rs(this,s))},t.previousLabel=function(s){return s===void 0&&(s=this._time),oO(this,Rs(this,s),1)},t.currentLabel=function(s){return arguments.length?this.seek(s,!0):this.previousLabel(this._time+Kt)},t.shiftChildren=function(s,a,r){r===void 0&&(r=0);var o=this._first,c=this.labels,d;for(s=ai(s);o;)o._start>=r&&(o._start+=s,o._end+=s),o=o._next;if(a)for(d in c)c[d]>=r&&(c[d]+=s);return Cl(this)},t.invalidate=function(s){var a=this._first;for(this._lock=0;a;)a.invalidate(s),a=a._next;return i.prototype.invalidate.call(this,s)},t.clear=function(s){s===void 0&&(s=!0);for(var a=this._first,r;a;)r=a._next,this.remove(a),a=r;return this._dp&&(this._time=this._tTime=this._pTime=0),s&&(this.labels={}),Cl(this)},t.totalDuration=function(s){var a=0,r=this,o=r._last,c=Ls,d,h,p;if(arguments.length)return r.timeScale((r._repeat<0?r.duration():r.totalDuration())/(r.reversed()?-s:s));if(r._dirty){for(p=r.parent;o;)d=o._prev,o._dirty&&o.totalDuration(),h=o._start,h>c&&r._sort&&o._ts&&!r._lock?(r._lock=1,wa(r,o,h-o._delay,1)._lock=0):c=h,h<0&&o._ts&&(a-=h,(!p&&!r._dp||p&&p.smoothChildTiming)&&(r._start+=ai(h/r._ts),r._time-=h,r._tTime-=h),r.shiftChildren(-h,!1,-1/0),c=0),o._end>a&&o._ts&&(a=o._end),o=d;lu(r,r===ri&&r._time>a?r._time:a,1,1),r._dirty=0}return r._tDur},e.updateRoot=function(s){if(ri._ts&&(YR(ri,Cg(s,ri)),GR=us.frame),us.frame>=nO){nO+=ps.autoSleep||120;var a=ri._first;if((!a||!a._ts)&&ps.autoSleep&&us._listeners.length<2){for(;a&&!a._ts;)a=a._next;a||us.sleep()}}},e})(Mh);_s(kn.prototype,{_lock:0,_hasPause:0,_forcing:0});var $z=function(e,t,n,s,a,r,o){var c=new Xn(this._pt,e,t,0,1,kP,null,a),d=0,h=0,p,_,y,x,v,w,k,M;for(c.b=n,c.e=s,n+="",s+="",(k=~s.indexOf("random("))&&(s=Oh(s)),r&&(M=[n,s],r(M,e,t),n=M[0],s=M[1]),_=n.match(C1)||[];p=C1.exec(s);)x=p[0],v=s.substring(d,p.index),y?y=(y+1)%5:v.substr(-5)==="rgba("&&(y=1),x!==_[h++]&&(w=parseFloat(_[h-1])||0,c._pt={_next:c._pt,p:v||h===1?v:",",s:w,c:x.charAt(1)==="="?Xc(w,x)-w:parseFloat(x)-w,m:y&&y<4?Math.round:0},d=C1.lastIndex);return c.c=d")}),A.duration();else{P={};for(E in x)E==="ease"||E==="easeEach"||n7(E,x[E],P,x.easeEach);for(E in P)for(H=P[E].sort(function(U,G){return U.t-G.t}),B=0,C=0;Cc-Kt&&!h?c:sd&&(_=d)),k=this._yoyo&&x&1,k&&(A=this._yEase,_=d-_),w=ou(this._tTime,v),_===o&&!r&&this._initted&&x===w)return this._tTime=p,this;x!==w&&(O&&this._yEase&&gP(O,k),this.vars.repeatRefresh&&!k&&!this._lock&&_!==v&&this._initted&&(this._lock=r=1,this.render(ai(v*x),!0).invalidate()._lock=0))}if(!this._initted){if(iP(this,h?s:_,r,a,p))return this._tTime=0,this;if(o!==this._time&&!(r&&this.vars.repeatRefresh&&x!==w))return this;if(d!==this._dur)return this.render(s,a,r)}if(this._tTime=p,this._time=_,!this._act&&this._ts&&(this._act=1,this._lazy=0),this.ratio=M=(A||this._ease)(_/d),this._from&&(this.ratio=M=1-M),!o&&p&&!a&&!w&&(ds(this,"onStart"),this._tTime!==p))return this;for(y=this._pt;y;)y.r(M,y.d),y=y._next;O&&O.render(s<0?s:O._dur*O._ease(_/this._dur),a,r)||this._startAt&&(this._zTime=s),this._onUpdate&&!a&&(h&&Zx(this,s,a,r),ds(this,"onUpdate")),this._repeat&&x!==w&&this.vars.onRepeat&&!a&&this.parent&&ds(this,"onRepeat"),(p===this._tDur||!p)&&this._tTime===p&&(h&&!this._onUpdate&&Zx(this,s,!0,!0),(s||!d)&&(p===this._tDur&&this._ts>0||!p&&this._ts<0)&&So(this,1),!a&&!(h&&!o)&&(p||o||k)&&(ds(this,p===c?"onComplete":"onReverseComplete",!0),this._prom&&!(p0)&&this._prom()))}return this},t.targets=function(){return this._targets},t.invalidate=function(s){return(!s||!this.vars.runBackwards)&&(this._startAt=0),this._pt=this._op=this._onUpdate=this._lazy=this.ratio=0,this._ptLookup=[],this.timeline&&this.timeline.invalidate(s),i.prototype.invalidate.call(this,s)},t.resetTo=function(s,a,r,o,c){Th||us.wake(),this._ts||this.play();var d=Math.min(this._dur,(this._dp._time-this._start)*this._ts),h;return this._initted||Jv(this,d),h=this._ease(d/this._dur),t7(this,s,a,r,o,h,d,c)?this.resetTo(s,a,r,o,1):(k0(this,0),this.parent||$R(this._dp,this,"_first","_last",this._dp._sort?"_start":0),this.render(0))},t.kill=function(s,a){if(a===void 0&&(a="all"),!s&&(!a||a==="all"))return this._lazy=this._pt=0,this.parent?Kd(this):this.scrollTrigger&&this.scrollTrigger.kill(!!sn),this;if(this.timeline){var r=this.timeline.totalDuration();return this.timeline.killTweensOf(s,a,lo&&lo.vars.overwrite!==!0)._first||Kd(this),this.parent&&r!==this.timeline.totalDuration()&&lu(this,this._dur*this.timeline._tDur/r,0,1),this}var o=this._targets,c=s?js(s):o,d=this._ptLookup,h=this._pt,p,_,y,x,v,w,k;if((!a||a==="all")&&Pz(o,c))return a==="all"&&(this._pt=0),Kd(this);for(p=this._op=this._op||[],a!=="all"&&(Ii(a)&&(v={},Wn(a,function(M){return v[M]=1}),a=v),a=i7(o,a)),k=o.length;k--;)if(~c.indexOf(o[k])){_=d[k],a==="all"?(p[k]=a,x=_,y={}):(y=p[k]=p[k]||{},x=a);for(v in x)w=_&&_[v],w&&((!("kill"in w.d)||w.d.kill(v)===!0)&&S0(this,w,"_pt"),delete _[v]),y!=="all"&&(y[v]=1)}return this._initted&&!this._pt&&h&&Kd(this),this},e.to=function(s,a){return new e(s,a,arguments[2])},e.from=function(s,a){return nh(1,arguments)},e.delayedCall=function(s,a,r,o){return new e(a,0,{immediateRender:!1,lazy:!1,overwrite:!1,delay:s,onComplete:a,onReverseComplete:a,onCompleteParams:r,onReverseCompleteParams:r,callbackScope:o})},e.fromTo=function(s,a,r){return nh(2,arguments)},e.set=function(s,a){return a.duration=0,a.repeatDelay||(a.repeat=0),new e(s,a)},e.killTweensOf=function(s,a,r){return ri.killTweensOf(s,a,r)},e})(Mh);_s(Ni.prototype,{_targets:[],_lazy:0,_startAt:0,_op:0,_onInit:0});Wn("staggerTo,staggerFrom,staggerFromTo",function(i){Ni[i]=function(){var e=new kn,t=$x.call(arguments,0);return t.splice(i==="staggerFromTo"?5:4,0,0),e[i].apply(e,t)}});var $v=function(e,t,n){return e[t]=n},SP=function(e,t,n){return e[t](n)},s7=function(e,t,n,s){return e[t](s.fp,n)},a7=function(e,t,n){return e.setAttribute(t,n)},e2=function(e,t){return hi(e[t])?SP:Kv(e[t])&&e.setAttribute?a7:$v},wP=function(e,t){return t.set(t.t,t.p,Math.round((t.s+t.c*e)*1e6)/1e6,t)},r7=function(e,t){return t.set(t.t,t.p,!!(t.s+t.c*e),t)},kP=function(e,t){var n=t._pt,s="";if(!e&&t.b)s=t.b;else if(e===1&&t.e)s=t.e;else{for(;n;)s=n.p+(n.m?n.m(n.s+n.c*e):Math.round((n.s+n.c*e)*1e4)/1e4)+s,n=n._next;s+=t.c}t.set(t.t,t.p,s,t)},t2=function(e,t){for(var n=t._pt;n;)n.r(e,n.d),n=n._next},o7=function(e,t,n,s){for(var a=this._pt,r;a;)r=a._next,a.p===s&&a.modifier(e,t,n),a=r},l7=function(e){for(var t=this._pt,n,s;t;)s=t._next,t.p===e&&!t.op||t.op===e?S0(this,t,"_pt"):t.dep||(n=1),t=s;return!n},c7=function(e,t,n,s){s.mSet(e,t,s.m.call(s.tween,n,s.mt),s)},AP=function(e){for(var t=e._pt,n,s,a,r;t;){for(n=t._next,s=a;s&&s.pr>t.pr;)s=s._next;(t._prev=s?s._prev:r)?t._prev._next=t:a=t,(t._next=s)?s._prev=t:r=t,t=n}e._pt=a},Xn=(function(){function i(t,n,s,a,r,o,c,d,h){this.t=n,this.s=a,this.c=r,this.p=s,this.r=o||wP,this.d=c||this,this.set=d||$v,this.pr=h||0,this._next=t,t&&(t._prev=this)}var e=i.prototype;return e.modifier=function(n,s,a){this.mSet=this.mSet||this.set,this.set=c7,this.m=n,this.mt=a,this.tween=s},i})();Wn(Gv+"parent,duration,ease,delay,overwrite,runBackwards,startAt,yoyo,immediateRender,repeat,repeatDelay,data,paused,reversed,lazy,callbackScope,stringFilter,id,yoyoEase,stagger,inherit,repeatRefresh,keyframes,autoRevert,scrollTrigger",function(i){return Xv[i]=1});gs.TweenMax=gs.TweenLite=Ni;gs.TimelineLite=gs.TimelineMax=kn;ri=new kn({sortChildren:!1,defaults:au,autoRemoveChildren:!0,id:"root",smoothChildTiming:!0});ps.stringFilter=pP;var Tl=[],Zm={},u7=[],cO=0,d7=0,R1=function(e){return(Zm[e]||u7).map(function(t){return t()})},nb=function(){var e=Date.now(),t=[];e-cO>2&&(R1("matchMediaInit"),Tl.forEach(function(n){var s=n.queries,a=n.conditions,r,o,c,d;for(o in s)r=va.matchMedia(s[o]).matches,r&&(c=1),r!==a[o]&&(a[o]=r,d=1);d&&(n.revert(),c&&t.push(n))}),R1("matchMediaRevert"),t.forEach(function(n){return n.onMatch(n,function(s){return n.add(null,s)})}),cO=e,R1("matchMedia"))},CP=(function(){function i(t,n){this.selector=n&&eb(n),this.data=[],this._r=[],this.isReverted=!1,this.id=d7++,t&&this.add(t)}var e=i.prototype;return e.add=function(n,s,a){hi(n)&&(a=s,s=n,n=hi);var r=this,o=function(){var d=$t,h=r.selector,p;return d&&d!==r&&d.data.push(r),a&&(r.selector=eb(a)),$t=r,p=s.apply(r,arguments),hi(p)&&r._r.push(p),$t=d,r.selector=h,r.isReverted=!1,p};return r.last=o,n===hi?o(r,function(c){return r.add(null,c)}):n?r[n]=o:o},e.ignore=function(n){var s=$t;$t=null,n(this),$t=s},e.getTweens=function(){var n=[];return this.data.forEach(function(s){return s instanceof i?n.push.apply(n,s.getTweens()):s instanceof Ni&&!(s.parent&&s.parent.data==="nested")&&n.push(s)}),n},e.clear=function(){this._r.length=this.data.length=0},e.kill=function(n,s){var a=this;if(n?(function(){for(var o=a.getTweens(),c=a.data.length,d;c--;)d=a.data[c],d.data==="isFlip"&&(d.revert(),d.getChildren(!0,!0,!1).forEach(function(h){return o.splice(o.indexOf(h),1)}));for(o.map(function(h){return{g:h._dur||h._delay||h._sat&&!h._sat.vars.immediateRender?h.globalTime(0):-1/0,t:h}}).sort(function(h,p){return p.g-h.g||-1/0}).forEach(function(h){return h.t.revert(n)}),c=a.data.length;c--;)d=a.data[c],d instanceof kn?d.data!=="nested"&&(d.scrollTrigger&&d.scrollTrigger.revert(),d.kill()):!(d instanceof Ni)&&d.revert&&d.revert(n);a._r.forEach(function(h){return h(n,a)}),a.isReverted=!0})():this.data.forEach(function(o){return o.kill&&o.kill()}),this.clear(),s)for(var r=Tl.length;r--;)Tl[r].id===this.id&&Tl.splice(r,1)},e.revert=function(n){this.kill(n||{})},i})(),h7=(function(){function i(t){this.contexts=[],this.scope=t,$t&&$t.data.push(this)}var e=i.prototype;return e.add=function(n,s,a){Pa(n)||(n={matches:n});var r=new CP(0,a||this.scope),o=r.conditions={},c,d,h;$t&&!r.selector&&(r.selector=$t.selector),this.contexts.push(r),s=r.add("onMatch",s),r.queries=n;for(d in n)d==="all"?h=1:(c=va.matchMedia(n[d]),c&&(Tl.indexOf(r)<0&&Tl.push(r),(o[d]=c.matches)&&(h=1),c.addListener?c.addListener(nb):c.addEventListener("change",nb)));return h&&s(r,function(p){return r.add(null,p)}),this},e.revert=function(n){this.kill(n||{})},e.kill=function(n){this.contexts.forEach(function(s){return s.kill(n,!0)})},i})(),Og={registerPlugin:function(){for(var e=arguments.length,t=new Array(e),n=0;n1){var s=e.map(function(h){return Qn.quickSetter(h,t,n)}),a=s.length;return function(h){for(var p=a;p--;)s[p](h)}}e=e[0]||{};var r=cs[t],o=Al(e),c=o.harness&&(o.harness.aliases||{})[t]||t,d=r?function(h){var p=new r;zc._pt=0,p.init(e,n?h+n:h,zc,0,[e]),p.render(1,p),zc._pt&&t2(1,zc)}:o.set(e,c);return r?d:function(h){return d(e,c,n?h+n:h,o,1)}},quickTo:function(e,t,n){var s,a=Qn.to(e,_s((s={},s[t]="+=0.1",s.paused=!0,s.stagger=0,s),n||{})),r=function(c,d,h){return a.resetTo(t,c,d,h)};return r.tween=a,r},isTweening:function(e){return ri.getTweensOf(e,!0).length>0},defaults:function(e){return e&&e.ease&&(e.ease=Ol(e.ease,au.ease)),sO(au,e||{})},config:function(e){return sO(ps,e||{})},registerEffect:function(e){var t=e.name,n=e.effect,s=e.plugins,a=e.defaults,r=e.extendTimeline;(s||"").split(",").forEach(function(o){return o&&!cs[o]&&!gs[o]&&Ah(t+" effect requires "+o+" plugin.")}),O1[t]=function(o,c,d){return n(js(o),_s(c||{},a),d)},r&&(kn.prototype[t]=function(o,c,d){return this.add(O1[t](o,Pa(c)?c:(d=c)&&{},this),d)})},registerEase:function(e,t){ht[e]=Ol(t)},parseEase:function(e,t){return arguments.length?Ol(e,t):ht},getById:function(e){return ri.getById(e)},exportRoot:function(e,t){e===void 0&&(e={});var n=new kn(e),s,a;for(n.smoothChildTiming=In(e.smoothChildTiming),ri.remove(n),n._dp=0,n._time=n._tTime=ri._time,s=ri._first;s;)a=s._next,(t||!(!s._dur&&s instanceof Ni&&s.vars.onComplete===s._targets[0]))&&wa(n,s,s._start-s._delay),s=a;return wa(ri,n,0),n},context:function(e,t){return e?new CP(e,t):$t},matchMedia:function(e){return new h7(e)},matchMediaRefresh:function(){return Tl.forEach(function(e){var t=e.conditions,n,s;for(s in t)t[s]&&(t[s]=!1,n=1);n&&e.revert()})||nb()},addEventListener:function(e,t){var n=Zm[e]||(Zm[e]=[]);~n.indexOf(t)||n.push(t)},removeEventListener:function(e,t){var n=Zm[e],s=n&&n.indexOf(t);s>=0&&n.splice(s,1)},utils:{wrap:Vz,wrapYoyo:Iz,distribute:aP,random:oP,snap:rP,normalize:Kz,getUnit:un,clamp:Bz,splitColor:hP,toArray:js,selector:eb,mapRange:cP,pipe:qz,unitize:Hz,interpolate:Wz,shuffle:sP},install:WR,effects:O1,ticker:us,updateRoot:kn.updateRoot,plugins:cs,globalTimeline:ri,core:{PropTween:Xn,globals:XR,Tween:Ni,Timeline:kn,Animation:Mh,getCache:Al,_removeLinkedListItem:S0,reverting:function(){return sn},context:function(e){return e&&$t&&($t.data.push(e),e._ctx=$t),$t},suppressOverwrites:function(e){return Hv=e}}};Wn("to,from,fromTo,delayedCall,set,killTweensOf",function(i){return Og[i]=Ni[i]});us.add(kn.updateRoot);zc=Og.to({},{duration:0});var f7=function(e,t){for(var n=e._pt;n&&n.p!==t&&n.op!==t&&n.fp!==t;)n=n._next;return n},p7=function(e,t){var n=e._targets,s,a,r;for(s in t)for(a=n.length;a--;)r=e._ptLookup[a][s],r&&(r=r.d)&&(r._pt&&(r=f7(r,s)),r&&r.modifier&&r.modifier(t[s],e,n[a],s))},P1=function(e,t){return{name:e,headless:1,rawVars:1,init:function(s,a,r){r._onInit=function(o){var c,d;if(Ii(a)&&(c={},Wn(a,function(h){return c[h]=1}),a=c),t){c={};for(d in a)c[d]=t(a[d]);a=c}p7(o,a)}}}},Qn=Og.registerPlugin({name:"attr",init:function(e,t,n,s,a){var r,o,c;this.tween=n;for(r in t)c=e.getAttribute(r)||"",o=this.add(e,"setAttribute",(c||0)+"",t[r],s,a,0,0,r),o.op=r,o.b=c,this._props.push(r)},render:function(e,t){for(var n=t._pt;n;)sn?n.set(n.t,n.p,n.b,n):n.r(e,n.d),n=n._next}},{name:"endArray",headless:1,init:function(e,t){for(var n=t.length;n--;)this.add(e,n,e[n]||0,t[n],0,0,0,0,0,1)}},P1("roundProps",tb),P1("modifiers"),P1("snap",rP))||Og;Ni.version=kn.version=Qn.version="3.14.2";IR=1;Vv()&&cu();ht.Power0;ht.Power1;ht.Power2;ht.Power3;ht.Power4;ht.Linear;ht.Quad;ht.Cubic;ht.Quart;ht.Quint;ht.Strong;ht.Elastic;ht.Back;ht.SteppedEase;ht.Bounce;ht.Sine;ht.Expo;ht.Circ;var uO,co,Gc,i2,yl,dO,n2,m7=function(){return typeof window!="undefined"},xr={},ol=180/Math.PI,Qc=Math.PI/180,jc=Math.atan2,hO=1e8,s2=/([A-Z])/g,g7=/(left|right|width|margin|padding|x)/i,_7=/[\s,\(]\S/,Ta={autoAlpha:"opacity,visibility",scale:"scaleX,scaleY",alpha:"opacity"},sb=function(e,t){return t.set(t.t,t.p,Math.round((t.s+t.c*e)*1e4)/1e4+t.u,t)},y7=function(e,t){return t.set(t.t,t.p,e===1?t.e:Math.round((t.s+t.c*e)*1e4)/1e4+t.u,t)},x7=function(e,t){return t.set(t.t,t.p,e?Math.round((t.s+t.c*e)*1e4)/1e4+t.u:t.b,t)},b7=function(e,t){return t.set(t.t,t.p,e===1?t.e:e?Math.round((t.s+t.c*e)*1e4)/1e4+t.u:t.b,t)},v7=function(e,t){var n=t.s+t.c*e;t.set(t.t,t.p,~~(n+(n<0?-.5:.5))+t.u,t)},OP=function(e,t){return t.set(t.t,t.p,e?t.e:t.b,t)},TP=function(e,t){return t.set(t.t,t.p,e!==1?t.b:t.e,t)},S7=function(e,t,n){return e.style[t]=n},w7=function(e,t,n){return e.style.setProperty(t,n)},k7=function(e,t,n){return e._gsap[t]=n},A7=function(e,t,n){return e._gsap.scaleX=e._gsap.scaleY=n},C7=function(e,t,n,s,a){var r=e._gsap;r.scaleX=r.scaleY=n,r.renderTransform(a,r)},O7=function(e,t,n,s,a){var r=e._gsap;r[t]=n,r.renderTransform(a,r)},oi="transform",Gn=oi+"Origin",T7=function i(e,t){var n=this,s=this.target,a=s.style,r=s._gsap;if(e in xr&&a){if(this.tfm=this.tfm||{},e!=="transform")e=Ta[e]||e,~e.indexOf(",")?e.split(",").forEach(function(o){return n.tfm[o]=or(s,o)}):this.tfm[e]=r.x?r[e]:or(s,e),e===Gn&&(this.tfm.zOrigin=r.zOrigin);else return Ta.transform.split(",").forEach(function(o){return i.call(n,o,t)});if(this.props.indexOf(oi)>=0)return;r.svg&&(this.svgo=s.getAttribute("data-svg-origin"),this.props.push(Gn,t,"")),e=oi}(a||t)&&this.props.push(e,t,a[e])},MP=function(e){e.translate&&(e.removeProperty("translate"),e.removeProperty("scale"),e.removeProperty("rotate"))},M7=function(){var e=this.props,t=this.target,n=t.style,s=t._gsap,a,r;for(a=0;a=0?fO[r]:"")+e},rb=function(){m7()&&window.document&&(uO=window,co=uO.document,Gc=co.documentElement,yl=ab("div")||{style:{}},ab("div"),oi=uu(oi),Gn=oi+"Origin",yl.style.cssText="border-width:0;line-height:0;position:absolute;padding:0",RP=!!uu("perspective"),n2=Qn.core.reverting,i2=1)},pO=function(e){var t=e.ownerSVGElement,n=ab("svg",t&&t.getAttribute("xmlns")||"http://www.w3.org/2000/svg"),s=e.cloneNode(!0),a;s.style.display="block",n.appendChild(s),Gc.appendChild(n);try{a=s.getBBox()}catch(r){}return n.removeChild(s),Gc.removeChild(n),a},mO=function(e,t){for(var n=t.length;n--;)if(e.hasAttribute(t[n]))return e.getAttribute(t[n])},PP=function(e){var t,n;try{t=e.getBBox()}catch(s){t=pO(e),n=1}return t&&(t.width||t.height)||n||(t=pO(e)),t&&!t.width&&!t.x&&!t.y?{x:+mO(e,["x","cx","x1"])||0,y:+mO(e,["y","cy","y1"])||0,width:0,height:0}:t},LP=function(e){return!!(e.getCTM&&(!e.parentNode||e.ownerSVGElement)&&PP(e))},wo=function(e,t){if(t){var n=e.style,s;t in xr&&t!==Gn&&(t=oi),n.removeProperty?(s=t.substr(0,2),(s==="ms"||t.substr(0,6)==="webkit")&&(t="-"+t),n.removeProperty(s==="--"?t:t.replace(s2,"-$1").toLowerCase())):n.removeAttribute(t)}},uo=function(e,t,n,s,a,r){var o=new Xn(e._pt,t,n,0,1,r?TP:OP);return e._pt=o,o.b=s,o.e=a,e._props.push(n),o},gO={deg:1,rad:1,turn:1},N7={grid:1,flex:1},ko=function i(e,t,n,s){var a=parseFloat(n)||0,r=(n+"").trim().substr((a+"").length)||"px",o=yl.style,c=g7.test(t),d=e.tagName.toLowerCase()==="svg",h=(d?"client":"offset")+(c?"Width":"Height"),p=100,_=s==="px",y=s==="%",x,v,w,k;if(s===r||!a||gO[s]||gO[r])return a;if(r!=="px"&&!_&&(a=i(e,t,n,"px")),k=e.getCTM&&LP(e),(y||r==="%")&&(xr[t]||~t.indexOf("adius")))return x=k?e.getBBox()[c?"width":"height"]:e[h],yi(y?a/x*p:a/100*x);if(o[c?"width":"height"]=p+(_?r:s),v=s!=="rem"&&~t.indexOf("adius")||s==="em"&&e.appendChild&&!d?e:e.parentNode,k&&(v=(e.ownerSVGElement||{}).parentNode),(!v||v===co||!v.appendChild)&&(v=co.body),w=v._gsap,w&&y&&w.width&&c&&w.time===us.time&&!w.uncache)return yi(a/w.width*p);if(y&&(t==="height"||t==="width")){var M=e.style[t];e.style[t]=p+s,x=e[h],M?e.style[t]=M:wo(e,t)}else(y||r==="%")&&!N7[hs(v,"display")]&&(o.position=hs(e,"position")),v===e&&(o.position="static"),v.appendChild(yl),x=yl[h],v.removeChild(yl),o.position="absolute";return c&&y&&(w=Al(v),w.time=us.time,w.width=v[h]),yi(_?x*a/p:x&&a?p/x*a:0)},or=function(e,t,n,s){var a;return i2||rb(),t in Ta&&t!=="transform"&&(t=Ta[t],~t.indexOf(",")&&(t=t.split(",")[0])),xr[t]&&t!=="transform"?(a=Rh(e,s),a=t!=="transformOrigin"?a[t]:a.svg?a.origin:Mg(hs(e,Gn))+" "+a.zOrigin+"px"):(a=e.style[t],(!a||a==="auto"||s||~(a+"").indexOf("calc("))&&(a=Tg[t]&&Tg[t](e,t,n)||hs(e,t)||QR(e,t)||(t==="opacity"?1:0))),n&&!~(a+"").trim().indexOf(" ")?ko(e,t,a,n)+n:a},R7=function(e,t,n,s){if(!n||n==="none"){var a=uu(t,e,1),r=a&&hs(e,a,1);r&&r!==n?(t=a,n=r):t==="borderColor"&&(n=hs(e,"borderTopColor"))}var o=new Xn(this._pt,e.style,t,0,1,kP),c=0,d=0,h,p,_,y,x,v,w,k,M,O,A,C;if(o.b=n,o.e=s,n+="",s+="",s.substring(0,6)==="var(--"&&(s=hs(e,s.substring(4,s.indexOf(")")))),s==="auto"&&(v=e.style[t],e.style[t]=s,s=hs(e,t)||s,v?e.style[t]=v:wo(e,t)),h=[n,s],pP(h),n=h[0],s=h[1],_=n.match(Bc)||[],C=s.match(Bc)||[],C.length){for(;p=Bc.exec(s);)w=p[0],M=s.substring(c,p.index),x?x=(x+1)%5:(M.substr(-5)==="rgba("||M.substr(-5)==="hsla(")&&(x=1),w!==(v=_[d++]||"")&&(y=parseFloat(v)||0,A=v.substr((y+"").length),w.charAt(1)==="="&&(w=Xc(y,w)+A),k=parseFloat(w),O=w.substr((k+"").length),c=Bc.lastIndex-O.length,O||(O=O||ps.units[t]||A,c===s.length&&(s+=O,o.e+=O)),A!==O&&(y=ko(e,t,v,O)||0),o._pt={_next:o._pt,p:M||d===1?M:",",s:y,c:k-y,m:x&&x<4||t==="zIndex"?Math.round:0});o.c=c-1;)o=a[d],xr[o]&&(c=1,o=o==="transformOrigin"?Gn:oi),wo(n,o);c&&(wo(n,oi),r&&(r.svg&&n.removeAttribute("transform"),s.scale=s.rotate=s.translate="none",Rh(n,1),r.uncache=1,MP(s)))}},Tg={clearProps:function(e,t,n,s,a){if(a.data!=="isFromStart"){var r=e._pt=new Xn(e._pt,t,n,0,0,L7);return r.u=s,r.pr=-10,r.tween=a,e._props.push(n),1}}},Nh=[1,0,0,1,0,0],jP={},EP=function(e){return e==="matrix(1, 0, 0, 1, 0, 0)"||e==="none"||!e},yO=function(e){var t=hs(e,oi);return EP(t)?Nh:t.substr(7).match(KR).map(yi)},a2=function(e,t){var n=e._gsap||Al(e),s=e.style,a=yO(e),r,o,c,d;return n.svg&&e.getAttribute("transform")?(c=e.transform.baseVal.consolidate().matrix,a=[c.a,c.b,c.c,c.d,c.e,c.f],a.join(",")==="1,0,0,1,0,0"?Nh:a):(a===Nh&&!e.offsetParent&&e!==Gc&&!n.svg&&(c=s.display,s.display="block",r=e.parentNode,(!r||!e.offsetParent&&!e.getBoundingClientRect().width)&&(d=1,o=e.nextElementSibling,Gc.appendChild(e)),a=yO(e),c?s.display=c:wo(e,"display"),d&&(o?r.insertBefore(e,o):r?r.appendChild(e):Gc.removeChild(e))),t&&a.length>6?[a[0],a[1],a[4],a[5],a[12],a[13]]:a)},ob=function(e,t,n,s,a,r){var o=e._gsap,c=a||a2(e,!0),d=o.xOrigin||0,h=o.yOrigin||0,p=o.xOffset||0,_=o.yOffset||0,y=c[0],x=c[1],v=c[2],w=c[3],k=c[4],M=c[5],O=t.split(" "),A=parseFloat(O[0])||0,C=parseFloat(O[1])||0,P,R,E,L;n?c!==Nh&&(R=y*w-x*v)&&(E=A*(w/R)+C*(-v/R)+(v*M-w*k)/R,L=A*(-x/R)+C*(y/R)-(y*M-x*k)/R,A=E,C=L):(P=PP(e),A=P.x+(~O[0].indexOf("%")?A/100*P.width:A),C=P.y+(~(O[1]||O[0]).indexOf("%")?C/100*P.height:C)),s||s!==!1&&o.smooth?(k=A-d,M=C-h,o.xOffset=p+(k*y+M*v)-k,o.yOffset=_+(k*x+M*w)-M):o.xOffset=o.yOffset=0,o.xOrigin=A,o.yOrigin=C,o.smooth=!!s,o.origin=t,o.originIsAbsolute=!!n,e.style[Gn]="0px 0px",r&&(uo(r,o,"xOrigin",d,A),uo(r,o,"yOrigin",h,C),uo(r,o,"xOffset",p,o.xOffset),uo(r,o,"yOffset",_,o.yOffset)),e.setAttribute("data-svg-origin",A+" "+C)},Rh=function(e,t){var n=e._gsap||new yP(e);if("x"in n&&!t&&!n.uncache)return n;var s=e.style,a=n.scaleX<0,r="px",o="deg",c=getComputedStyle(e),d=hs(e,Gn)||"0",h,p,_,y,x,v,w,k,M,O,A,C,P,R,E,L,D,q,B,H,W,V,U,G,$,ie,ue,F,Y,ce,J,me;return h=p=_=v=w=k=M=O=A=0,y=x=1,n.svg=!!(e.getCTM&&LP(e)),c.translate&&((c.translate!=="none"||c.scale!=="none"||c.rotate!=="none")&&(s[oi]=(c.translate!=="none"?"translate3d("+(c.translate+" 0 0").split(" ").slice(0,3).join(", ")+") ":"")+(c.rotate!=="none"?"rotate("+c.rotate+") ":"")+(c.scale!=="none"?"scale("+c.scale.split(" ").join(",")+") ":"")+(c[oi]!=="none"?c[oi]:"")),s.scale=s.rotate=s.translate="none"),R=a2(e,n.svg),n.svg&&(n.uncache?($=e.getBBox(),d=n.xOrigin-$.x+"px "+(n.yOrigin-$.y)+"px",G=""):G=!t&&e.getAttribute("data-svg-origin"),ob(e,G||d,!!G||n.originIsAbsolute,n.smooth!==!1,R)),C=n.xOrigin||0,P=n.yOrigin||0,R!==Nh&&(q=R[0],B=R[1],H=R[2],W=R[3],h=V=R[4],p=U=R[5],R.length===6?(y=Math.sqrt(q*q+B*B),x=Math.sqrt(W*W+H*H),v=q||B?jc(B,q)*ol:0,M=H||W?jc(H,W)*ol+v:0,M&&(x*=Math.abs(Math.cos(M*Qc))),n.svg&&(h-=C-(C*q+P*H),p-=P-(C*B+P*W))):(me=R[6],ce=R[7],ue=R[8],F=R[9],Y=R[10],J=R[11],h=R[12],p=R[13],_=R[14],E=jc(me,Y),w=E*ol,E&&(L=Math.cos(-E),D=Math.sin(-E),G=V*L+ue*D,$=U*L+F*D,ie=me*L+Y*D,ue=V*-D+ue*L,F=U*-D+F*L,Y=me*-D+Y*L,J=ce*-D+J*L,V=G,U=$,me=ie),E=jc(-H,Y),k=E*ol,E&&(L=Math.cos(-E),D=Math.sin(-E),G=q*L-ue*D,$=B*L-F*D,ie=H*L-Y*D,J=W*D+J*L,q=G,B=$,H=ie),E=jc(B,q),v=E*ol,E&&(L=Math.cos(E),D=Math.sin(E),G=q*L+B*D,$=V*L+U*D,B=B*L-q*D,U=U*L-V*D,q=G,V=$),w&&Math.abs(w)+Math.abs(v)>359.9&&(w=v=0,k=180-k),y=yi(Math.sqrt(q*q+B*B+H*H)),x=yi(Math.sqrt(U*U+me*me)),E=jc(V,U),M=Math.abs(E)>2e-4?E*ol:0,A=J?1/(J<0?-J:J):0),n.svg&&(G=e.getAttribute("transform"),n.forceCSS=e.setAttribute("transform","")||!EP(hs(e,oi)),G&&e.setAttribute("transform",G))),Math.abs(M)>90&&Math.abs(M)<270&&(a?(y*=-1,M+=v<=0?180:-180,v+=v<=0?180:-180):(x*=-1,M+=M<=0?180:-180)),t=t||n.uncache,n.x=h-((n.xPercent=h&&(!t&&n.xPercent||(Math.round(e.offsetWidth/2)===Math.round(-h)?-50:0)))?e.offsetWidth*n.xPercent/100:0)+r,n.y=p-((n.yPercent=p&&(!t&&n.yPercent||(Math.round(e.offsetHeight/2)===Math.round(-p)?-50:0)))?e.offsetHeight*n.yPercent/100:0)+r,n.z=_+r,n.scaleX=yi(y),n.scaleY=yi(x),n.rotation=yi(v)+o,n.rotationX=yi(w)+o,n.rotationY=yi(k)+o,n.skewX=M+o,n.skewY=O+o,n.transformPerspective=A+r,(n.zOrigin=parseFloat(d.split(" ")[2])||!t&&n.zOrigin||0)&&(s[Gn]=Mg(d)),n.xOffset=n.yOffset=0,n.force3D=ps.force3D,n.renderTransform=n.svg?E7:RP?DP:j7,n.uncache=0,n},Mg=function(e){return(e=e.split(" "))[0]+" "+e[1]},L1=function(e,t,n){var s=un(t);return yi(parseFloat(t)+parseFloat(ko(e,"x",n+"px",s)))+s},j7=function(e,t){t.z="0px",t.rotationY=t.rotationX="0deg",t.force3D=0,DP(e,t)},tl="0deg",Md="0px",il=") ",DP=function(e,t){var n=t||this,s=n.xPercent,a=n.yPercent,r=n.x,o=n.y,c=n.z,d=n.rotation,h=n.rotationY,p=n.rotationX,_=n.skewX,y=n.skewY,x=n.scaleX,v=n.scaleY,w=n.transformPerspective,k=n.force3D,M=n.target,O=n.zOrigin,A="",C=k==="auto"&&e&&e!==1||k===!0;if(O&&(p!==tl||h!==tl)){var P=parseFloat(h)*Qc,R=Math.sin(P),E=Math.cos(P),L;P=parseFloat(p)*Qc,L=Math.cos(P),r=L1(M,r,R*L*-O),o=L1(M,o,-Math.sin(P)*-O),c=L1(M,c,E*L*-O+O)}w!==Md&&(A+="perspective("+w+il),(s||a)&&(A+="translate("+s+"%, "+a+"%) "),(C||r!==Md||o!==Md||c!==Md)&&(A+=c!==Md||C?"translate3d("+r+", "+o+", "+c+") ":"translate("+r+", "+o+il),d!==tl&&(A+="rotate("+d+il),h!==tl&&(A+="rotateY("+h+il),p!==tl&&(A+="rotateX("+p+il),(_!==tl||y!==tl)&&(A+="skew("+_+", "+y+il),(x!==1||v!==1)&&(A+="scale("+x+", "+v+il),M.style[oi]=A||"translate(0, 0)"},E7=function(e,t){var n=t||this,s=n.xPercent,a=n.yPercent,r=n.x,o=n.y,c=n.rotation,d=n.skewX,h=n.skewY,p=n.scaleX,_=n.scaleY,y=n.target,x=n.xOrigin,v=n.yOrigin,w=n.xOffset,k=n.yOffset,M=n.forceCSS,O=parseFloat(r),A=parseFloat(o),C,P,R,E,L;c=parseFloat(c),d=parseFloat(d),h=parseFloat(h),h&&(h=parseFloat(h),d+=h,c+=h),c||d?(c*=Qc,d*=Qc,C=Math.cos(c)*p,P=Math.sin(c)*p,R=Math.sin(c-d)*-_,E=Math.cos(c-d)*_,d&&(h*=Qc,L=Math.tan(d-h),L=Math.sqrt(1+L*L),R*=L,E*=L,h&&(L=Math.tan(h),L=Math.sqrt(1+L*L),C*=L,P*=L)),C=yi(C),P=yi(P),R=yi(R),E=yi(E)):(C=p,E=_,P=R=0),(O&&!~(r+"").indexOf("px")||A&&!~(o+"").indexOf("px"))&&(O=ko(y,"x",r,"px"),A=ko(y,"y",o,"px")),(x||v||w||k)&&(O=yi(O+x-(x*C+v*R)+w),A=yi(A+v-(x*P+v*E)+k)),(s||a)&&(L=y.getBBox(),O=yi(O+s/100*L.width),A=yi(A+a/100*L.height)),L="matrix("+C+","+P+","+R+","+E+","+O+","+A+")",y.setAttribute("transform",L),M&&(y.style[oi]=L)},D7=function(e,t,n,s,a){var r=360,o=Ii(a),c=parseFloat(a)*(o&&~a.indexOf("rad")?ol:1),d=c-s,h=s+d+"deg",p,_;return o&&(p=a.split("_")[1],p==="short"&&(d%=r,d!==d%(r/2)&&(d+=d<0?r:-r)),p==="cw"&&d<0?d=(d+r*hO)%r-~~(d/r)*r:p==="ccw"&&d>0&&(d=(d-r*hO)%r-~~(d/r)*r)),e._pt=_=new Xn(e._pt,t,n,s,d,y7),_.e=h,_.u="deg",e._props.push(n),_},xO=function(e,t){for(var n in t)e[n]=t[n];return e},U7=function(e,t,n){var s=xO({},n._gsap),a="perspective,force3D,transformOrigin,svgOrigin",r=n.style,o,c,d,h,p,_,y,x;s.svg?(d=n.getAttribute("transform"),n.setAttribute("transform",""),r[oi]=t,o=Rh(n,1),wo(n,oi),n.setAttribute("transform",d)):(d=getComputedStyle(n)[oi],r[oi]=t,o=Rh(n,1),r[oi]=d);for(c in xr)d=s[c],h=o[c],d!==h&&a.indexOf(c)<0&&(y=un(d),x=un(h),p=y!==x?ko(n,c,d,x):parseFloat(d),_=parseFloat(h),e._pt=new Xn(e._pt,o,c,p,_-p,sb),e._pt.u=x||0,e._props.push(c));xO(o,s)};Wn("padding,margin,Width,Radius",function(i,e){var t="Top",n="Right",s="Bottom",a="Left",r=(e<3?[t,n,s,a]:[t+a,t+n,s+n,s+a]).map(function(o){return e<2?i+o:"border"+o+i});Tg[e>1?"border"+i:i]=function(o,c,d,h,p){var _,y;if(arguments.length<4)return _=r.map(function(x){return or(o,x,d)}),y=_.join(" "),y.split(_[0]).length===5?_[0]:y;_=(h+"").split(" "),y={},r.forEach(function(x,v){return y[x]=_[v]=_[v]||_[(v-1)/2|0]}),o.init(c,y,p)}});var UP={name:"css",register:rb,targetTest:function(e){return e.style&&e.nodeType},init:function(e,t,n,s,a){var r=this._props,o=e.style,c=n.vars.startAt,d,h,p,_,y,x,v,w,k,M,O,A,C,P,R,E,L;i2||rb(),this.styles=this.styles||NP(e),E=this.styles.props,this.tween=n;for(v in t)if(v!=="autoRound"&&(h=t[v],!(cs[v]&&xP(v,t,n,s,e,a)))){if(y=typeof h,x=Tg[v],y==="function"&&(h=h.call(n,s,e,a),y=typeof h),y==="string"&&~h.indexOf("random(")&&(h=Oh(h)),x)x(this,e,v,h,n)&&(R=1);else if(v.substr(0,2)==="--")d=(getComputedStyle(e).getPropertyValue(v)+"").trim(),h+="",xo.lastIndex=0,xo.test(d)||(w=un(d),k=un(h),k?w!==k&&(d=ko(e,v,d,k)+k):w&&(h+=w)),this.add(o,"setProperty",d,h,s,a,0,0,v),r.push(v),E.push(v,0,o[v]);else if(y!=="undefined"){if(c&&v in c?(d=typeof c[v]=="function"?c[v].call(n,s,e,a):c[v],Ii(d)&&~d.indexOf("random(")&&(d=Oh(d)),un(d+"")||d==="auto"||(d+=ps.units[v]||un(or(e,v))||""),(d+"").charAt(1)==="="&&(d=or(e,v))):d=or(e,v),_=parseFloat(d),M=y==="string"&&h.charAt(1)==="="&&h.substr(0,2),M&&(h=h.substr(2)),p=parseFloat(h),v in Ta&&(v==="autoAlpha"&&(_===1&&or(e,"visibility")==="hidden"&&p&&(_=0),E.push("visibility",0,o.visibility),uo(this,o,"visibility",_?"inherit":"hidden",p?"inherit":"hidden",!p)),v!=="scale"&&v!=="transform"&&(v=Ta[v],~v.indexOf(",")&&(v=v.split(",")[0]))),O=v in xr,O){if(this.styles.save(v),L=h,y==="string"&&h.substring(0,6)==="var(--"){if(h=hs(e,h.substring(4,h.indexOf(")"))),h.substring(0,5)==="calc("){var D=e.style.perspective;e.style.perspective=h,h=hs(e,"perspective"),D?e.style.perspective=D:wo(e,"perspective")}p=parseFloat(h)}if(A||(C=e._gsap,C.renderTransform&&!t.parseTransform||Rh(e,t.parseTransform),P=t.smoothOrigin!==!1&&C.smooth,A=this._pt=new Xn(this._pt,o,oi,0,1,C.renderTransform,C,0,-1),A.dep=1),v==="scale")this._pt=new Xn(this._pt,C,"scaleY",C.scaleY,(M?Xc(C.scaleY,M+p):p)-C.scaleY||0,sb),this._pt.u=0,r.push("scaleY",v),v+="X";else if(v==="transformOrigin"){E.push(Gn,0,o[Gn]),h=P7(h),C.svg?ob(e,h,0,P,0,this):(k=parseFloat(h.split(" ")[2])||0,k!==C.zOrigin&&uo(this,C,"zOrigin",C.zOrigin,k),uo(this,o,v,Mg(d),Mg(h)));continue}else if(v==="svgOrigin"){ob(e,h,1,P,0,this);continue}else if(v in jP){D7(this,C,v,_,M?Xc(_,M+h):h);continue}else if(v==="smoothOrigin"){uo(this,C,"smooth",C.smooth,h);continue}else if(v==="force3D"){C[v]=h;continue}else if(v==="transform"){U7(this,h,e);continue}}else v in o||(v=uu(v)||v);if(O||(p||p===0)&&(_||_===0)&&!_7.test(h)&&v in o)w=(d+"").substr((_+"").length),p||(p=0),k=un(h)||(v in ps.units?ps.units[v]:w),w!==k&&(_=ko(e,v,d,k)),this._pt=new Xn(this._pt,O?C:o,v,_,(M?Xc(_,M+p):p)-_,!O&&(k==="px"||v==="zIndex")&&t.autoRound!==!1?v7:sb),this._pt.u=k||0,O&&L!==h?(this._pt.b=d,this._pt.e=L,this._pt.r=b7):w!==k&&k!=="%"&&(this._pt.b=d,this._pt.r=x7);else if(v in o)R7.call(this,e,v,d,M?M+h:h);else if(v in e)this.add(e,v,d||e[v],M?M+h:h,s,a);else if(v!=="parseTransform"){Wv(v,h);continue}O||(v in o?E.push(v,0,o[v]):typeof e[v]=="function"?E.push(v,2,e[v]()):E.push(v,1,d||e[v])),r.push(v)}}R&&AP(this)},render:function(e,t){if(t.tween._time||!n2())for(var n=t._pt;n;)n.r(e,n.d),n=n._next;else t.styles.revert()},get:or,aliases:Ta,getSetter:function(e,t,n){var s=Ta[t];return s&&s.indexOf(",")<0&&(t=s),t in xr&&t!==Gn&&(e._gsap.x||or(e,"x"))?n&&dO===n?t==="scale"?A7:k7:(dO=n||{})&&(t==="scale"?C7:O7):e.style&&!Kv(e.style[t])?S7:~t.indexOf("-")?w7:e2(e,t)},core:{_removeProperty:wo,_getMatrix:a2}};Qn.utils.checkPrefix=uu;Qn.core.getStyleSaver=NP;(function(i,e,t,n){var s=Wn(i+","+e+","+t,function(a){xr[a]=1});Wn(e,function(a){ps.units[a]="deg",jP[a]=1}),Ta[s[13]]=i+","+e,Wn(n,function(a){var r=a.split(":");Ta[r[1]]=s[r[0]]})})("x,y,z,scale,scaleX,scaleY,xPercent,yPercent","rotation,rotationX,rotationY,skewX,skewY","transform,transformOrigin,svgOrigin,force3D,smoothOrigin,transformPerspective","0:translateX,1:translateY,2:translateZ,8:rotate,8:rotationZ,8:rotateZ,9:rotateX,10:rotateY");Wn("x,y,z,top,right,bottom,left,width,height,fontSize,padding,margin,perspective",function(i){ps.units[i]="px"});Qn.registerPlugin(UP);var Jm=Qn.registerPlugin(UP)||Qn;Jm.core.Tween;const F7=.5,B7=.45,z7=.08;function q7({render:i,getRouteOrder:e,scrollContainerRef:t}){var w,k,M;const n=Vs(),s=N.useRef(null),a=N.useRef(null),r=N.useRef(0),[o,c]=N.useState(!1),[d,h]=N.useState("forward"),[p,_]=N.useState(()=>[{key:n.key,location:n,status:"current"}]),y=(k=(w=p[p.length-1])==null?void 0:w.key)!=null?k:n.key,x=(M=p[p.length-1])==null?void 0:M.location.pathname,v=N.useCallback(()=>t!=null&&t.current?t.current:typeof document=="undefined"?null:document.scrollingElement,[t]);return N.useEffect(()=>{var L;if(o||n.key===y||x===n.pathname)return;const O=v();r.current=(L=O==null?void 0:O.scrollTop)!=null?L:0;const A=D=>{if(!e||!D)return null;const q=e(D);return typeof q=="number"&&q>=0?q:null},C=A(x),P=A(n.pathname),R=C===null||P===null||C===P||P>C?"forward":"backward";let E=!1;return queueMicrotask(()=>{E||(h(R),_(D=>{const q=D[D.length-1];return[q?ee(z({},q),{status:"exiting"}):{key:n.key,location:n,status:"exiting"},{key:n.key,location:n,status:"current"}]}),c(!0))}),()=>{E=!0}},[o,n,y,x,e,v]),N.useLayoutEffect(()=>{var B;if(!o||!s.current)return;const O=v(),A=r.current;O&&A>0&&O.scrollTo({top:0,left:0,behavior:"auto"});const C=(B=O==null?void 0:O.clientHeight)!=null?B:0,P=typeof window=="undefined"?0:window.innerHeight,R=Math.max(C,P,1),E=d==="forward"?R:-R,L=d==="forward"?-R:R,D=A?-A:0,q=Jm.timeline({onComplete:()=>{_(H=>H.filter(W=>W.status!=="exiting")),c(!1)}});return a.current&&(Jm.set(a.current,{y:D}),q.fromTo(a.current,{y:D,opacity:1},{y:D+L,opacity:0,duration:B7,ease:"power2.in",force3D:!0},0)),q.fromTo(s.current,{y:E,opacity:0},{y:0,opacity:1,duration:F7,ease:"power2.out",clearProps:"transform,opacity",force3D:!0},z7),()=>{q.kill(),Jm.killTweensOf([s.current,a.current])}},[o,d,v]),g.jsx("div",{className:`page-transition${o?" page-transition--animating":""}`,children:p.map(O=>g.jsx("div",{className:`page-transition__layer${O.status==="exiting"?" page-transition__layer--exit":""}`,ref:O.status==="exiting"?a:s,children:i(O.location)},O.key))})}const lb={fetchConfigYaml(){return pe(this,null,function*(){const e=(yield Ce.getRaw("/config.yaml",{responseType:"text",headers:{Accept:"application/yaml, text/yaml, text/plain"}})).data;return typeof e=="string"?e:e==null?"":String(e)})},saveConfigYaml(i){return pe(this,null,function*(){yield Ce.put("/config.yaml",i,{headers:{"Content-Type":"application/yaml",Accept:"application/json, text/plain, */*"}})})}},Yc={list(){return pe(this,null,function*(){var t;const i=yield Ce.get("/api-keys"),e=i&&((t=i["api-keys"])!=null?t:i.apiKeys);return Array.isArray(e)?e:[]})},replace:i=>Ce.put("/api-keys",i),update:(i,e)=>Ce.patch("/api-keys",{index:i,value:e}),delete:i=>Ce.delete(`/api-keys?index=${i}`)},nr={getAmpcode(){return pe(this,null,function*(){var e;const i=yield Ce.get("/ampcode");return(e=UR(i))!=null?e:{}})},updateUpstreamUrl:i=>Ce.put("/ampcode/upstream-url",{value:i}),clearUpstreamUrl:()=>Ce.delete("/ampcode/upstream-url"),updateUpstreamApiKey:i=>Ce.put("/ampcode/upstream-api-key",{value:i}),clearUpstreamApiKey:()=>Ce.delete("/ampcode/upstream-api-key"),getModelMappings(){return pe(this,null,function*(){var t,n,s;const i=yield Ce.get("/ampcode/model-mappings"),e=(s=(n=(t=i==null?void 0:i["model-mappings"])!=null?t:i==null?void 0:i.modelMappings)!=null?n:i==null?void 0:i.items)!=null?s:i;return DR(e)})},saveModelMappings:i=>Ce.put("/ampcode/model-mappings",{value:i}),patchModelMappings:i=>Ce.patch("/ampcode/model-mappings",{value:i}),clearModelMappings:()=>Ce.delete("/ampcode/model-mappings"),deleteModelMappings:i=>Ce.delete("/ampcode/model-mappings",{data:{value:i}}),updateForceModelMappings:i=>Ce.put("/ampcode/force-model-mappings",{value:i})},ff=i=>i&&Object.keys(i).length?i:void 0,FP=i=>Array.isArray(i)?i.map(e=>{if(!(e!=null&&e.name))return null;const t={name:e.name};return e.alias&&e.alias!==e.name&&(t.alias=e.alias),e.priority!==void 0&&(t.priority=e.priority),e.testModel&&(t["test-model"]=e.testModel),t}).filter(Boolean):void 0,H7=i=>{const e={"api-key":i.apiKey};i.proxyUrl&&(e["proxy-url"]=i.proxyUrl);const t=ff(i.headers);return t&&(e.headers=t),e},tm=i=>{var s;const e={"api-key":i.apiKey};(s=i.prefix)!=null&&s.trim()&&(e.prefix=i.prefix.trim()),i.baseUrl&&(e["base-url"]=i.baseUrl),i.proxyUrl&&(e["proxy-url"]=i.proxyUrl);const t=ff(i.headers);t&&(e.headers=t);const n=FP(i.models);return n&&n.length&&(e.models=n),i.excludedModels&&i.excludedModels.length&&(e["excluded-models"]=i.excludedModels),e},K7=i=>Array.isArray(i)?i.map(e=>{const t=typeof(e==null?void 0:e.name)=="string"?e.name.trim():"",n=typeof(e==null?void 0:e.alias)=="string"?e.alias.trim():"";return!t||!n?null:{name:t,alias:n}}).filter(Boolean):void 0,bO=i=>{var s;const e={"api-key":i.apiKey};(s=i.prefix)!=null&&s.trim()&&(e.prefix=i.prefix.trim()),i.baseUrl&&(e["base-url"]=i.baseUrl),i.proxyUrl&&(e["proxy-url"]=i.proxyUrl);const t=ff(i.headers);t&&(e.headers=t);const n=K7(i.models);return n&&n.length&&(e.models=n),e},vO=i=>{var n;const e={"api-key":i.apiKey};(n=i.prefix)!=null&&n.trim()&&(e.prefix=i.prefix.trim()),i.baseUrl&&(e["base-url"]=i.baseUrl);const t=ff(i.headers);return t&&(e.headers=t),i.excludedModels&&i.excludedModels.length&&(e["excluded-models"]=i.excludedModels),e},SO=i=>{var s;const e={name:i.name,"base-url":i.baseUrl,"api-key-entries":Array.isArray(i.apiKeyEntries)?i.apiKeyEntries.map(a=>H7(a)):[]};(s=i.prefix)!=null&&s.trim()&&(e.prefix=i.prefix.trim());const t=ff(i.headers);t&&(e.headers=t);const n=FP(i.models);return n&&n.length&&(e.models=n),i.priority!==void 0&&(e.priority=i.priority),i.testModel&&(e["test-model"]=i.testModel),e},qi={getGeminiKeys(){return pe(this,null,function*(){var t,n;const i=yield Ce.get("/gemini-api-key"),e=i&&((n=(t=i["gemini-api-key"])!=null?t:i.items)!=null?n:i);return Array.isArray(e)?e.map(s=>jR(s)).filter(Boolean):[]})},saveGeminiKeys:i=>Ce.put("/gemini-api-key",i.map(e=>vO(e))),updateGeminiKey:(i,e)=>Ce.patch("/gemini-api-key",{index:i,value:vO(e)}),deleteGeminiKey:i=>Ce.delete(`/gemini-api-key?api-key=${encodeURIComponent(i)}`),getCodexConfigs(){return pe(this,null,function*(){var t,n;const i=yield Ce.get("/codex-api-key"),e=i&&((n=(t=i["codex-api-key"])!=null?t:i.items)!=null?n:i);return Array.isArray(e)?e.map(s=>Wc(s)).filter(Boolean):[]})},saveCodexConfigs:i=>Ce.put("/codex-api-key",i.map(e=>tm(e))),updateCodexConfig:(i,e)=>Ce.patch("/codex-api-key",{index:i,value:tm(e)}),deleteCodexConfig:i=>Ce.delete(`/codex-api-key?api-key=${encodeURIComponent(i)}`),getClaudeConfigs(){return pe(this,null,function*(){var t,n;const i=yield Ce.get("/claude-api-key"),e=i&&((n=(t=i["claude-api-key"])!=null?t:i.items)!=null?n:i);return Array.isArray(e)?e.map(s=>Wc(s)).filter(Boolean):[]})},saveClaudeConfigs:i=>Ce.put("/claude-api-key",i.map(e=>tm(e))),updateClaudeConfig:(i,e)=>Ce.patch("/claude-api-key",{index:i,value:tm(e)}),deleteClaudeConfig:i=>Ce.delete(`/claude-api-key?api-key=${encodeURIComponent(i)}`),getVertexConfigs(){return pe(this,null,function*(){var t,n;const i=yield Ce.get("/vertex-api-key"),e=i&&((n=(t=i["vertex-api-key"])!=null?t:i.items)!=null?n:i);return Array.isArray(e)?e.map(s=>Wc(s)).filter(Boolean):[]})},saveVertexConfigs:i=>Ce.put("/vertex-api-key",i.map(e=>bO(e))),updateVertexConfig:(i,e)=>Ce.patch("/vertex-api-key",{index:i,value:bO(e)}),deleteVertexConfig:i=>Ce.delete(`/vertex-api-key?api-key=${encodeURIComponent(i)}`),getOpenAIProviders(){return pe(this,null,function*(){var t,n;const i=yield Ce.get("/openai-compatibility"),e=i&&((n=(t=i["openai-compatibility"])!=null?t:i.items)!=null?n:i);return Array.isArray(e)?e.map(s=>ER(s)).filter(Boolean):[]})},saveOpenAIProviders:i=>Ce.put("/openai-compatibility",i.map(e=>SO(e))),updateOpenAIProvider:(i,e)=>Ce.patch("/openai-compatibility",{index:i,value:SO(e)}),deleteOpenAIProvider:i=>Ce.delete(`/openai-compatibility?name=${encodeURIComponent(i)}`)},wO=i=>{var n,s;if(!i||typeof i!="object")return{};const e=(s=(n=i["oauth-excluded-models"])!=null?n:i.items)!=null?s:i;if(!e||typeof e!="object")return{};const t={};return Object.entries(e).forEach(([a,r])=>{const o=String(a!=null?a:"").trim().toLowerCase();if(!o)return;const c=Array.isArray(r)?r:typeof r=="string"?r.split(/[\n,]+/):[],d=new Set,h=[];c.forEach(p=>{const _=String(p!=null?p:"").trim();if(!_)return;const y=_.toLowerCase();d.has(y)||(d.add(y),h.push(_))}),t[o]=h}),t},zi={list:()=>Ce.get("/auth-files"),upload:i=>{const e=new FormData;return e.append("file",i,i.name),Ce.postForm("/auth-files",e)},deleteFile:i=>Ce.delete(`/auth-files?name=${encodeURIComponent(i)}`),deleteAll:()=>Ce.delete("/auth-files",{params:{all:!0}}),getOauthExcludedModels(){return pe(this,null,function*(){const i=yield Ce.get("/oauth-excluded-models");return wO(i)})},saveOauthExcludedModels:(i,e)=>Ce.patch("/oauth-excluded-models",{provider:i,models:e}),deleteOauthExcludedEntry:i=>Ce.delete(`/oauth-excluded-models?provider=${encodeURIComponent(i)}`),replaceOauthExcludedModels:i=>Ce.put("/oauth-excluded-models",wO(i)),getOauthModelMappings(){return pe(this,null,function*(){var n,s;const i=yield Ce.get("/oauth-model-mappings"),e=i&&((s=(n=i["oauth-model-mappings"])!=null?n:i.items)!=null?s:i);if(!e||typeof e!="object")return{};const t={};return Object.entries(e).forEach(([a,r])=>{if(!Array.isArray(r))return;const o=r.map(c=>{var _,y,x,v;if(!c||typeof c!="object")return null;const d=String((x=(y=(_=c.name)!=null?_:c.id)!=null?y:c.model)!=null?x:"").trim(),h=String((v=c.alias)!=null?v:"").trim();if(!d||!h)return null;const p=c.fork===!0;return p?{name:d,alias:h,fork:p}:{name:d,alias:h}}).filter(Boolean);o.length&&(t[a]=o)}),t})},saveOauthModelMappings:(i,e)=>Ce.patch("/oauth-model-mappings",{channel:i,mappings:e}),deleteOauthModelMappings:i=>Ce.delete(`/oauth-model-mappings?channel=${encodeURIComponent(i)}`),getModelsForAuthFile(i){return pe(this,null,function*(){const e=yield Ce.get(`/auth-files/models?name=${encodeURIComponent(i)}`);return e&&Array.isArray(e.models)?e.models:[]})}},V7=["codex","anthropic","antigravity","gemini-cli"],I7={"gemini-cli":"gemini"},im={startAuth:(i,e)=>{const t={};return V7.includes(i)&&(t.is_webui=!0),i==="gemini-cli"&&(e!=null&&e.projectId)&&(t.project_id=e.projectId),Ce.get(`/${i}-auth-url`,{params:Object.keys(t).length?t:void 0})},getAuthStatus:i=>Ce.get("/get-auth-status",{params:{state:i}}),submitCallback:(i,e)=>{var n;const t=(n=I7[i])!=null?n:i;return Ce.post("/oauth-callback",{provider:t,redirect_url:e})},iflowCookieAuth:i=>Ce.post("/iflow-auth-url",{cookie:i})};function pn(i){if(!i)return"";const e=2,t=i.slice(0,e),n=i.slice(-e),s=Math.max(i.length-e*2,1),a="*".repeat(s);return`${t}${a}${n}`}function kO(i){if(i===0)return"0 B";const e=["B","KB","MB","GB"],t=1024,n=Math.floor(Math.log(i)/Math.log(t));return`${(i/Math.pow(t,n)).toFixed(2)} ${e[n]}`}function W7(i,e){if(i==null||i==="")return"";const t=typeof i=="number"?i:Number(i),n=(()=>{if(!Number.isFinite(t)||Number.isNaN(t))return new Date(String(i));const s=Math.abs(t);return s<1e11?new Date(t*1e3):s<1e14?new Date(t):s<1e17?new Date(Math.round(t/1e3)):new Date(Math.round(t/1e6))})();return Number.isNaN(n.getTime())?"":e?n.toLocaleString(e):n.toLocaleString()}const j1=1e6,BP="cli-proxy-model-prices-v2",X7=i=>{if(typeof i=="number"&&Number.isFinite(i))return i.toString();if(typeof i=="string"){const e=i.trim();return e||null}return null};function zP(i,e=pn){if(i==null)return"";const t=typeof i=="string"?i:String(i);if(!t)return"";let n=t;const s=/([?&])(api[-_]?key|key|token|access_token|authorization)=([^&#\s]+)/gi;n=n.replace(s,(o,c,d,h)=>`${c}${d}=${e(h)}`);const a=/(api[-_]?key|key|token|access[-_]?token|authorization)\s*([:=])\s*([A-Za-z0-9._-]+)/gi;n=n.replace(a,(o,c,d,h)=>`${c}${d}${e(h)}`);const r=/(sk-[A-Za-z0-9]{6,}|AI[a-zA-Z0-9_-]{6,}|AIza[0-9A-Za-z-_]{8,}|hf_[A-Za-z0-9]{6,}|pk_[A-Za-z0-9]{6,}|rk_[A-Za-z0-9]{6,})/g;if(n=n.replace(r,o=>e(o)),n===t){const o=t.trim();if(o&&!/\s/.test(o)&&(/^sk-/i.test(o)||/^AI/i.test(o)||/^AIza/i.test(o)||/^hf_/i.test(o)||/^pk_/i.test(o)||/^rk_/i.test(o)||!/[\\/]/.test(o)&&(/\d/.test(o)||o.length>=10)||o.length>=24))return e(o)}return n}function ro(i){const e=Number(i);return Number.isFinite(e)?`${(e/1e6).toFixed(2)}M`:"0.00M"}function AO(i){const e=Number(i);if(!Number.isFinite(e))return"0.00";const t=Math.abs(e);return t>=1e3?Math.round(e).toLocaleString():t>=100?e.toFixed(0):t>=10?e.toFixed(1):e.toFixed(2)}function r2(i){const e=Number(i);if(!Number.isFinite(e))return"$0.00";const t=e.toFixed(2);return`$${Number(t).toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function Po(i){if(!i)return[];const e=i.apis||{},t=[];return Object.values(e).forEach(n=>{const s=(n==null?void 0:n.models)||{};Object.entries(s).forEach(([a,r])=>{(Array.isArray(r.details)?r.details:[]).forEach(c=>{c&&c.timestamp&&t.push(ee(z({},c),{__modelName:a}))})})}),t}function A0(i){const e=(i==null?void 0:i.tokens)||{};if(typeof e.total_tokens=="number")return e.total_tokens;const t=typeof e.input_tokens=="number"?e.input_tokens:0,n=typeof e.output_tokens=="number"?e.output_tokens:0,s=typeof e.reasoning_tokens=="number"?e.reasoning_tokens:0,a=Math.max(typeof e.cached_tokens=="number"?Math.max(e.cached_tokens,0):0,typeof e.cache_tokens=="number"?Math.max(e.cache_tokens,0):0);return t+n+s+a}function G7(i){const e=Po(i);if(!e.length)return{cachedTokens:0,reasoningTokens:0};let t=0,n=0;return e.forEach(s=>{const a=(s==null?void 0:s.tokens)||{};t+=Math.max(typeof a.cached_tokens=="number"?Math.max(a.cached_tokens,0):0,typeof a.cache_tokens=="number"?Math.max(a.cache_tokens,0):0),typeof a.reasoning_tokens=="number"&&(n+=a.reasoning_tokens)}),{cachedTokens:t,reasoningTokens:n}}function Q7(i=30,e){const t=Po(e),n=Number.isFinite(i)&&i>0?i:30;if(!t.length)return{rpm:0,tpm:0,windowMinutes:n,requestCount:0,tokenCount:0};const a=Date.now()-n*60*1e3;let r=0,o=0;t.forEach(d=>{const h=Date.parse(d.timestamp);Number.isNaN(h)||h0?n:1;return{rpm:r/c,tpm:o/c,windowMinutes:n,requestCount:r,tokenCount:o}}function Y7(i){if(!i)return[];const e=i.apis||{},t=new Set;return Object.values(e).forEach(n=>{const s=(n==null?void 0:n.models)||{};Object.keys(s).forEach(a=>{a&&t.add(a)})}),Array.from(t).sort((n,s)=>n.localeCompare(s))}function o2(i,e){const t=i.__modelName||"",n=e[t];if(!n)return 0;const s=(i==null?void 0:i.tokens)||{},a=Number(s.input_tokens),r=Number(s.output_tokens),o=Number(s.cached_tokens),c=Number(s.cache_tokens),d=Number.isFinite(a)?Math.max(a,0):0,h=Number.isFinite(r)?Math.max(r,0):0,p=Math.max(Number.isFinite(o)?Math.max(o,0):0,Number.isFinite(c)?Math.max(c,0):0),y=Math.max(d-p,0)/j1*(Number(n.prompt)||0),x=p/j1*(Number(n.cache)||0),v=h/j1*(Number(n.completion)||0),w=y+x+v;return Number.isFinite(w)&&w>0?w:0}function Z7(i,e){const t=Po(i);return!t.length||!Object.keys(e).length?0:t.reduce((n,s)=>n+o2(s,e),0)}function J7(){try{if(typeof localStorage=="undefined")return{};const i=localStorage.getItem(BP);if(!i)return{};const e=JSON.parse(i);if(!e||typeof e!="object")return{};const t={};return Object.entries(e).forEach(([n,s])=>{if(!n)return;const a=Number(s==null?void 0:s.prompt),r=Number(s==null?void 0:s.completion),o=Number(s==null?void 0:s.cache);if(!Number.isFinite(a)&&!Number.isFinite(r)&&!Number.isFinite(o))return;const c=Number.isFinite(a)&&a>=0?a:0,d=Number.isFinite(r)&&r>=0?r:0,h=Number.isFinite(o)&&o>=0?o:Number.isFinite(a)&&a>=0?a:c;t[n]={prompt:c,completion:d,cache:h}}),t}catch(i){return{}}}function $7(i){try{if(typeof localStorage=="undefined")return;localStorage.setItem(BP,JSON.stringify(i))}catch(e){console.warn("保存模型价格失败")}}function eq(i,e){if(!(i!=null&&i.apis))return[];const t=i.apis,n=[];return Object.entries(t).forEach(([s,a])=>{const r={};let o=0;const c=(a==null?void 0:a.models)||{};Object.entries(c).forEach(([d,h])=>{r[d]={requests:h.total_requests||0,tokens:h.total_tokens||0},e[d]&&(Array.isArray(h.details)?h.details:[]).forEach(y=>{o+=o2(ee(z({},y),{__modelName:d}),e)})}),n.push({endpoint:zP(s)||s,totalRequests:a.total_requests||0,totalTokens:a.total_tokens||0,totalCost:o,models:r})}),n}function tq(i,e){if(!(i!=null&&i.apis))return[];const t=new Map;return Object.values(i.apis).forEach(n=>{const s=(n==null?void 0:n.models)||{};Object.entries(s).forEach(([a,r])=>{const o=t.get(a)||{requests:0,tokens:0,cost:0};o.requests+=r.total_requests||0,o.tokens+=r.total_tokens||0,e[a]&&(Array.isArray(r.details)?r.details:[]).forEach(h=>{o.cost+=o2(ee(z({},h),{__modelName:a}),e)}),t.set(a,o)})}),Array.from(t.entries()).map(([n,s])=>z({model:n},s)).sort((n,s)=>s.requests-n.requests)}function iq(i){if(!(i instanceof Date))return"";const e=(i.getMonth()+1).toString().padStart(2,"0"),t=i.getDate().toString().padStart(2,"0"),n=i.getHours().toString().padStart(2,"0");return`${e}-${t} ${n}:00`}function nq(i){if(!(i instanceof Date))return"";const e=i.getFullYear(),t=(i.getMonth()+1).toString().padStart(2,"0"),n=i.getDate().toString().padStart(2,"0");return`${e}-${t}-${n}`}function sq(i,e="requests"){const n=new Date,s=new Date(n);s.setMinutes(0,0,0);const a=new Date(s);a.setHours(a.getHours()-23);const r=a.getTime(),o=[];for(let p=0;p<24;p++){const _=r+p*36e5;o.push(iq(new Date(_)))}const c=Po(i),d=new Map;let h=!1;return c.length?(c.forEach(p=>{const _=Date.parse(p.timestamp);if(Number.isNaN(_))return;const y=new Date(_);y.setMinutes(0,0,0);const x=y.getTime(),v=r+(o.length-1)*36e5;if(xv)return;const w=Math.floor((x-r)/36e5);if(w<0||w>=o.length)return;const k=p.__modelName||"Unknown";d.has(k)||d.set(k,new Array(o.length).fill(0));const M=d.get(k);e==="tokens"?M[w]+=A0(p):M[w]+=1,h=!0}),{labels:o,dataByModel:d,hasData:h}):{labels:o,dataByModel:d,hasData:h}}function aq(i,e="requests"){const t=Po(i),n=new Map,s=new Set;let a=!1;if(!t.length)return{labels:[],dataByModel:new Map,hasData:a};t.forEach(c=>{const d=Date.parse(c.timestamp);if(Number.isNaN(d))return;const h=nq(new Date(d));if(!h)return;const p=c.__modelName||"Unknown";n.has(p)||n.set(p,new Map);const _=n.get(p),y=e==="tokens"?A0(c):1;_.set(h,(_.get(h)||0)+y),s.add(h),a=!0});const r=Array.from(s).sort(),o=new Map;return n.forEach((c,d)=>{const h=r.map(p=>c.get(p)||0);o.set(d,h)}),{labels:r,dataByModel:o,hasData:a}}const CO=[{borderColor:"#3b82f6",backgroundColor:"rgba(59, 130, 246, 0.15)"},{borderColor:"#22c55e",backgroundColor:"rgba(34, 197, 94, 0.15)"},{borderColor:"#f59e0b",backgroundColor:"rgba(245, 158, 11, 0.15)"},{borderColor:"#ef4444",backgroundColor:"rgba(239, 68, 68, 0.15)"},{borderColor:"#8b5cf6",backgroundColor:"rgba(139, 92, 246, 0.15)"},{borderColor:"#06b6d4",backgroundColor:"rgba(6, 182, 212, 0.15)"},{borderColor:"#ec4899",backgroundColor:"rgba(236, 72, 153, 0.15)"},{borderColor:"#84cc16",backgroundColor:"rgba(132, 204, 22, 0.15)"},{borderColor:"#f97316",backgroundColor:"rgba(249, 115, 22, 0.15)"}],rq=(i,e,t)=>Math.min(Math.max(i,e),t),oq=i=>{const e=i.trim().replace("#","");if(e.length!==6)return null;const t=Number.parseInt(e.slice(0,2),16),n=Number.parseInt(e.slice(2,4),16),s=Number.parseInt(e.slice(4,6),16);return[t,n,s].every(a=>Number.isFinite(a))?{r:t,g:n,b:s}:null},E1=(i,e)=>{const t=oq(i);if(!t)return i;const n=rq(e,0,1);return`rgba(${t.r}, ${t.g}, ${t.b}, ${n})`},lq=(i,e,t)=>{const n=i.chart,s=n.ctx,a=n.chartArea;if(!a)return t;const r=s.createLinearGradient(0,a.top,0,a.bottom);return r.addColorStop(0,E1(e,.28)),r.addColorStop(.6,E1(e,.12)),r.addColorStop(1,E1(e,.02)),r};function OO(i,e="day",t="requests",n=[]){const s=e==="hour"?sq(i,t):aq(i,t),{labels:a,dataByModel:r}=s,o=()=>{const h=new Array(a.length).fill(0);return r.forEach(p=>{p.forEach((_,y)=>{h[y]=(h[y]||0)+_})}),h},c=n.length>0?n:["all"],d=c.map((h,p)=>{const _=h==="all",y=_?o():r.get(h)||new Array(a.length).fill(0),x=p%CO.length,v=CO[x],w=c.length===1||_&&c.length>1;return{label:_?"All Models":h,data:y,borderColor:v.borderColor,backgroundColor:w?k=>lq(k,v.borderColor,v.backgroundColor):v.backgroundColor,pointBackgroundColor:v.borderColor,pointBorderColor:v.borderColor,fill:w,tension:.35}});return{labels:a,datasets:d}}function qs(i,e,t){const r=Date.now(),o=r-36e5,c=Array.from({length:20},()=>({success:0,failure:0}));let d=0,h=0;i.forEach(x=>{const v=Date.parse(x.timestamp);if(Number.isNaN(v)||vr||e!==void 0&&x.source!==e)return;const w=r-v,k=19-Math.floor(w/3e5);k>=0&&k<20&&(x.failed?(c[k].failure+=1,h+=1):(c[k].success+=1,d+=1))});const p=c.map(x=>x.success===0&&x.failure===0?"idle":x.failure===0?"success":x.success===0?"failure":"mixed"),_=d+h,y=_>0?d/_*100:100;return{blocks:p,successRate:y,totalSuccess:d,totalFailure:h}}function cq(i,e=pn){if(!i)return{bySource:{},byAuthIndex:{}};const t={},n={},s=(r,o)=>(r[o]||(r[o]={success:0,failure:0}),r[o]),a=i.apis||{};return Object.values(a).forEach(r=>{const o=(r==null?void 0:r.models)||{};Object.values(o).forEach(c=>{((c==null?void 0:c.details)||[]).forEach(h=>{const p=zP(h==null?void 0:h.source,e),_=X7(h==null?void 0:h.auth_index),y=(h==null?void 0:h.failed)===!0;if(p){const x=s(t,p);y?x.failure+=1:x.success+=1}if(_){const x=s(n,_);y?x.failure+=1:x.success+=1}})})}),{bySource:t,byAuthIndex:n}}const nm=60*1e3,Ml={getUsage:()=>Ce.get("/usage",{timeout:nm}),exportUsage:()=>Ce.get("/usage/export",{timeout:nm}),importUsage:i=>Ce.post("/usage/import",i,{timeout:nm}),getKeyStats(i){return pe(this,null,function*(){var t;let e=i;if(!e){const n=yield Ce.get("/usage",{timeout:nm});e=(t=n==null?void 0:n.usage)!=null?t:n}return cq(e)})}},Nd={fetchLogs:(i={})=>Ce.get("/logs",{params:i,timeout:Zp}),clearLogs:()=>Ce.delete("/logs"),fetchErrorLogs:()=>Ce.get("/request-error-logs",{timeout:Zp}),downloadErrorLog:i=>Ce.getRaw(`/request-error-logs/${encodeURIComponent(i)}`,{responseType:"blob",timeout:Zp}),downloadRequestLogById:i=>Ce.getRaw(`/request-log-by-id/${encodeURIComponent(i)}`,{responseType:"blob",timeout:Zp})},uq={checkLatest:()=>Ce.get("/latest-version")},dq={importCredential:(i,e)=>{const t=new FormData;return t.append("file",i),e&&t.append("location",e),Ce.postForm("/vertex/import",t)}},hq="DashboardPage-module__dashboard___c-JEy",fq="DashboardPage-module__header___DrpYQ",pq="DashboardPage-module__title___aKMJy",mq="DashboardPage-module__subtitle___o9pSe",gq="DashboardPage-module__connectionCard___6o2zO",_q="DashboardPage-module__connectionStatus___UhJ2s",yq="DashboardPage-module__statusDot___4w7W-",xq="DashboardPage-module__connected___CeELY",bq="DashboardPage-module__connecting___j03PZ",vq="DashboardPage-module__disconnected___3l11q",Sq="DashboardPage-module__statusText___QDIvv",wq="DashboardPage-module__connectionInfo___oh7A1",kq="DashboardPage-module__serverUrl___9-jgp",Aq="DashboardPage-module__serverVersion___fmQMs",Cq="DashboardPage-module__buildDate___zr4hY",Oq="DashboardPage-module__statsGrid___y7hZp",Tq="DashboardPage-module__statCard___Du41R",Mq="DashboardPage-module__statIcon___EmbpQ",Nq="DashboardPage-module__statContent___IJemf",Rq="DashboardPage-module__statValue___w491L",Pq="DashboardPage-module__statLabel___b-2c9",Lq="DashboardPage-module__statSublabel___0oB31",jq="DashboardPage-module__section___i4jzh",Eq="DashboardPage-module__sectionTitle___uLbzI",Dq="DashboardPage-module__configGrid___5UhRW",Uq="DashboardPage-module__configItem___NBY1m",Fq="DashboardPage-module__configLabel___RoXI2",Bq="DashboardPage-module__configValue___6vWwa",zq="DashboardPage-module__enabled___R3JFn",qq="DashboardPage-module__disabled___ievwL",Hq="DashboardPage-module__configValueMono___tc-ax",Kq="DashboardPage-module__configItemFull___Apt9u",Vq="DashboardPage-module__viewMoreLink___wKvoJ",ze={dashboard:hq,header:fq,title:pq,subtitle:mq,connectionCard:gq,connectionStatus:_q,statusDot:yq,connected:xq,connecting:bq,disconnected:vq,statusText:Sq,connectionInfo:wq,serverUrl:kq,serverVersion:Aq,buildDate:Cq,statsGrid:Oq,statCard:Tq,statIcon:Mq,statContent:Nq,statValue:Rq,statLabel:Pq,statSublabel:Lq,section:jq,sectionTitle:Eq,configGrid:Dq,configItem:Uq,configLabel:Fq,configValue:Bq,enabled:zq,disabled:qq,configValueMono:Hq,configItemFull:Kq,viewMoreLink:Vq};function TO(){var E,L,D,q,B,H,W,V,U,G,$;const{t:i,i18n:e}=rt(),t=Ct(ie=>ie.connectionStatus),n=Ct(ie=>ie.serverVersion),s=Ct(ie=>ie.serverBuildDate),a=Ct(ie=>ie.apiBase),r=Wt(ie=>ie.config),o=_l(ie=>ie.models),c=_l(ie=>ie.loading),d=_l(ie=>ie.fetchModels),[h,p]=N.useState({apiKeys:null,authFiles:null}),[_,y]=N.useState({gemini:null,codex:null,claude:null,openai:null}),[x,v]=N.useState(!0),w=N.useRef([]);N.useEffect(()=>{w.current=[]},[a,r==null?void 0:r.apiKeys]);const k=ie=>{if(!Array.isArray(ie))return[];const ue=new Set,F=[];return ie.forEach(Y=>{var me,Se;const ce=typeof Y=="string"?Y:(Se=(me=Y==null?void 0:Y["api-key"])!=null?me:Y==null?void 0:Y.apiKey)!=null?Se:"",J=String(ce||"").trim();!J||ue.has(J)||(ue.add(J),F.push(J))}),F},M=N.useCallback(()=>pe(null,null,function*(){if(w.current.length)return w.current;const ie=k(r==null?void 0:r.apiKeys);if(ie.length)return w.current=ie,ie;try{const ue=yield Yc.list(),F=k(ue);return F.length&&(w.current=F),F}catch(ue){return[]}}),[r==null?void 0:r.apiKeys]),O=N.useCallback(()=>pe(null,null,function*(){if(!(t!=="connected"||!a))try{const ue=(yield M())[0];yield d(a,ue)}catch(ie){}}),[t,a,M,d]);N.useEffect(()=>{t==="connected"?(pe(null,null,function*(){v(!0);try{const[ue,F,Y,ce,J,me]=yield Promise.allSettled([Yc.list(),zi.list(),qi.getGeminiKeys(),qi.getCodexConfigs(),qi.getClaudeConfigs(),qi.getOpenAIProviders()]);p({apiKeys:ue.status==="fulfilled"?ue.value.length:null,authFiles:F.status==="fulfilled"?F.value.files.length:null}),y({gemini:Y.status==="fulfilled"?Y.value.length:null,codex:ce.status==="fulfilled"?ce.value.length:null,claude:J.status==="fulfilled"?J.value.length:null,openai:me.status==="fulfilled"?me.value.length:null})}finally{v(!1)}}),O()):v(!1)},[t,O]);const A=_.gemini!==null&&_.codex!==null&&_.claude!==null&&_.openai!==null,C=_.gemini!==null||_.codex!==null||_.claude!==null||_.openai!==null,P=A?((E=_.gemini)!=null?E:0)+((L=_.codex)!=null?L:0)+((D=_.claude)!=null?D:0)+((q=_.openai)!=null?q:0):0,R=[{label:i("nav.api_keys"),value:(B=h.apiKeys)!=null?B:"-",icon:g.jsx(XN,{size:24}),path:"/api-keys",loading:x&&h.apiKeys===null,sublabel:i("dashboard.management_keys")},{label:i("nav.ai_providers"),value:x?"-":A?P:"-",icon:g.jsx(Lv,{size:24}),path:"/ai-providers",loading:x,sublabel:C?i("dashboard.provider_keys_detail",{gemini:(H=_.gemini)!=null?H:"-",codex:(W=_.codex)!=null?W:"-",claude:(V=_.claude)!=null?V:"-",openai:(U=_.openai)!=null?U:"-"}):void 0},{label:i("nav.auth_files"),value:(G=h.authFiles)!=null?G:"-",icon:g.jsx(GN,{size:24}),path:"/auth-files",loading:x&&h.authFiles===null,sublabel:i("dashboard.oauth_credentials")},{label:i("dashboard.available_models"),value:c?"-":o.length,icon:g.jsx(tR,{size:24}),path:"/system",loading:c,sublabel:i("dashboard.available_models_desc")}];return g.jsxs("div",{className:ze.dashboard,children:[g.jsxs("div",{className:ze.header,children:[g.jsx("h1",{className:ze.title,children:i("dashboard.title")}),g.jsx("p",{className:ze.subtitle,children:i("dashboard.subtitle")})]}),g.jsxs("div",{className:ze.connectionCard,children:[g.jsxs("div",{className:ze.connectionStatus,children:[g.jsx("span",{className:`${ze.statusDot} ${t==="connected"?ze.connected:t==="connecting"?ze.connecting:ze.disconnected}`}),g.jsx("span",{className:ze.statusText,children:i(t==="connected"?"common.connected":t==="connecting"?"common.connecting":"common.disconnected")})]}),g.jsxs("div",{className:ze.connectionInfo,children:[g.jsx("span",{className:ze.serverUrl,children:a||"-"}),n&&g.jsxs("span",{className:ze.serverVersion,children:["v",n.trim().replace(/^[vV]+/,"")]}),s&&g.jsx("span",{className:ze.buildDate,children:new Date(s).toLocaleDateString(e.language)})]})]}),g.jsx("div",{className:ze.statsGrid,children:R.map(ie=>g.jsxs(_g,{to:ie.path,className:ze.statCard,children:[g.jsx("div",{className:ze.statIcon,children:ie.icon}),g.jsxs("div",{className:ze.statContent,children:[g.jsx("span",{className:ze.statValue,children:ie.loading?"...":ie.value}),g.jsx("span",{className:ze.statLabel,children:ie.label}),ie.sublabel&&!ie.loading&&g.jsx("span",{className:ze.statSublabel,children:ie.sublabel})]})]},ie.path))}),r&&g.jsxs("div",{className:ze.section,children:[g.jsx("h2",{className:ze.sectionTitle,children:i("dashboard.current_config")}),g.jsxs("div",{className:ze.configGrid,children:[g.jsxs("div",{className:ze.configItem,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.debug_enable")}),g.jsx("span",{className:`${ze.configValue} ${r.debug?ze.enabled:ze.disabled}`,children:r.debug?i("common.yes"):i("common.no")})]}),g.jsxs("div",{className:ze.configItem,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.usage_statistics_enable")}),g.jsx("span",{className:`${ze.configValue} ${r.usageStatisticsEnabled?ze.enabled:ze.disabled}`,children:r.usageStatisticsEnabled?i("common.yes"):i("common.no")})]}),g.jsxs("div",{className:ze.configItem,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.logging_to_file_enable")}),g.jsx("span",{className:`${ze.configValue} ${r.loggingToFile?ze.enabled:ze.disabled}`,children:r.loggingToFile?i("common.yes"):i("common.no")})]}),g.jsxs("div",{className:ze.configItem,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.retry_count_label")}),g.jsx("span",{className:ze.configValue,children:($=r.requestRetry)!=null?$:0})]}),g.jsxs("div",{className:ze.configItem,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.ws_auth_enable")}),g.jsx("span",{className:`${ze.configValue} ${r.wsAuth?ze.enabled:ze.disabled}`,children:r.wsAuth?i("common.yes"):i("common.no")})]}),r.proxyUrl&&g.jsxs("div",{className:`${ze.configItem} ${ze.configItemFull}`,children:[g.jsx("span",{className:ze.configLabel,children:i("basic_settings.proxy_url_label")}),g.jsx("span",{className:ze.configValueMono,children:r.proxyUrl})]})]}),g.jsxs(_g,{to:"/settings",className:ze.viewMoreLink,children:[i("dashboard.edit_settings")," →"]})]})]})}function vt({title:i,extra:e,children:t,className:n}){return g.jsxs("div",{className:n?`card ${n}`:"card",children:[(i||e)&&g.jsxs("div",{className:"card-header",children:[g.jsx("div",{className:"title",children:i}),e]}),t]})}const Iq="Settings-module__container___UY8S9",Wq="Settings-module__pageTitle___ADRp3",Xq="Settings-module__grid___WziyQ",Gq="Settings-module__retryRow___fKNn1",Qq="Settings-module__retryRowAligned___Q7nOm",Yq="Settings-module__retryButton___hpjto",Zq="Settings-module__retryRowInputGrow___T0DJn",Jq="Settings-module__retryInput___-fsAl",vn={container:Iq,pageTitle:Wq,grid:Xq,retryRow:Gq,retryRowAligned:Qq,retryButton:Yq,retryRowInputGrow:Zq,retryInput:Jq};function $q(){var V,U,G,$,ie,ue,F,Y,ce;const{t:i}=rt(),{showNotification:e}=Zn(),t=Ct(J=>J.connectionStatus),n=Wt(J=>J.config),s=Wt(J=>J.fetchConfig),a=Wt(J=>J.updateConfigValue),r=Wt(J=>J.clearCache),[o,c]=N.useState(!0),[d,h]=N.useState(""),[p,_]=N.useState(0),[y,x]=N.useState(0),[v,w]=N.useState("round-robin"),[k,M]=N.useState({}),[O,A]=N.useState(""),C=t!=="connected";N.useEffect(()=>{pe(null,null,function*(){var me;c(!0),A("");try{const[Se,Re,He,Ke]=yield Promise.allSettled([s(),Ji.getLogsMaxTotalSizeMb(),Ji.getForceModelPrefix(),Ji.getRoutingStrategy()]);if(Se.status!=="fulfilled")throw Se.reason;const it=Se.value;h((me=it==null?void 0:it.proxyUrl)!=null?me:""),_(typeof(it==null?void 0:it.requestRetry)=="number"?it.requestRetry:0),Re.status==="fulfilled"&&Number.isFinite(Re.value)&&(x(Math.max(0,Number(Re.value))),a("logs-max-total-size-mb",Math.max(0,Number(Re.value)))),He.status==="fulfilled"&&a("force-model-prefix",!!He.value),Ke.status==="fulfilled"&&Ke.value&&(w(String(Ke.value)),a("routing/strategy",String(Ke.value)))}catch(Se){A((Se==null?void 0:Se.message)||i("notification.refresh_failed"))}finally{c(!1)}})},[s,i,a]),N.useEffect(()=>{var J;n&&(h((J=n.proxyUrl)!=null?J:""),typeof n.requestRetry=="number"&&_(n.requestRetry),typeof n.logsMaxTotalSizeMb=="number"&&x(n.logsMaxTotalSizeMb),n.routingStrategy&&w(n.routingStrategy))},[n==null?void 0:n.proxyUrl,n==null?void 0:n.requestRetry,n==null?void 0:n.logsMaxTotalSizeMb,n==null?void 0:n.routingStrategy]);const P=(J,me)=>{M(Se=>ee(z({},Se),{[J]:me}))},R=(J,me,Se,Re,He)=>pe(null,null,function*(){const Ke=(()=>{var it,fi,Pi,ft,ii;switch(me){case"debug":return(it=n==null?void 0:n.debug)!=null?it:!1;case"usage-statistics-enabled":return(fi=n==null?void 0:n.usageStatisticsEnabled)!=null?fi:!1;case"logging-to-file":return(Pi=n==null?void 0:n.loggingToFile)!=null?Pi:!1;case"ws-auth":return(ft=n==null?void 0:n.wsAuth)!=null?ft:!1;case"force-model-prefix":return(ii=n==null?void 0:n.forceModelPrefix)!=null?ii:!1;default:return!1}})();P(J,!0),a(me,Se);try{yield Re(Se),r(me),e(He,"success")}catch(it){a(me,Ke),e(`${i("notification.update_failed")}: ${(it==null?void 0:it.message)||""}`,"error")}finally{P(J,!1)}}),E=()=>pe(null,null,function*(){var me;const J=(me=n==null?void 0:n.proxyUrl)!=null?me:"";P("proxy",!0),a("proxy-url",d);try{yield Ji.updateProxyUrl(d.trim()),r("proxy-url"),e(i("notification.proxy_updated"),"success")}catch(Se){h(J),a("proxy-url",J),e(`${i("notification.update_failed")}: ${(Se==null?void 0:Se.message)||""}`,"error")}finally{P("proxy",!1)}}),L=()=>pe(null,null,function*(){var me;const J=(me=n==null?void 0:n.proxyUrl)!=null?me:"";P("proxy",!0),a("proxy-url","");try{yield Ji.clearProxyUrl(),r("proxy-url"),h(""),e(i("notification.proxy_cleared"),"success")}catch(Se){h(J),a("proxy-url",J),e(`${i("notification.update_failed")}: ${(Se==null?void 0:Se.message)||""}`,"error")}finally{P("proxy",!1)}}),D=()=>pe(null,null,function*(){var Se;const J=(Se=n==null?void 0:n.requestRetry)!=null?Se:0,me=Number(p);if(!Number.isFinite(me)||me<0){e(i("login.error_invalid"),"error"),_(J);return}P("retry",!0),a("request-retry",me);try{yield Ji.updateRequestRetry(me),r("request-retry"),e(i("notification.retry_updated"),"success")}catch(Re){_(J),a("request-retry",J),e(`${i("notification.update_failed")}: ${(Re==null?void 0:Re.message)||""}`,"error")}finally{P("retry",!1)}}),q=()=>pe(null,null,function*(){var Re;const J=(Re=n==null?void 0:n.logsMaxTotalSizeMb)!=null?Re:0,me=Number(y);if(!Number.isFinite(me)||me<0){e(i("login.error_invalid"),"error"),x(J);return}const Se=Math.max(0,me);P("logsMaxSize",!0),a("logs-max-total-size-mb",Se);try{yield Ji.updateLogsMaxTotalSizeMb(Se),r("logs-max-total-size-mb"),e(i("notification.logs_max_total_size_updated"),"success")}catch(He){x(J),a("logs-max-total-size-mb",J),e(`${i("notification.update_failed")}: ${(He==null?void 0:He.message)||""}`,"error")}finally{P("logsMaxSize",!1)}}),B=()=>pe(null,null,function*(){var Se;const J=v.trim();if(!J){e(i("login.error_invalid"),"error");return}const me=(Se=n==null?void 0:n.routingStrategy)!=null?Se:"round-robin";P("routingStrategy",!0),a("routing/strategy",J);try{yield Ji.updateRoutingStrategy(J),r("routing/strategy"),e(i("notification.routing_strategy_updated"),"success")}catch(Re){w(me),a("routing/strategy",me),e(`${i("notification.update_failed")}: ${(Re==null?void 0:Re.message)||""}`,"error")}finally{P("routingStrategy",!1)}}),H=(U=(V=n==null?void 0:n.quotaExceeded)==null?void 0:V.switchProject)!=null?U:!1,W=($=(G=n==null?void 0:n.quotaExceeded)==null?void 0:G.switchPreviewModel)!=null?$:!1;return g.jsxs("div",{className:vn.container,children:[g.jsx("h1",{className:vn.pageTitle,children:i("basic_settings.title")}),g.jsxs("div",{className:vn.grid,children:[g.jsxs(vt,{children:[O&&g.jsx("div",{className:"error-box",children:O}),g.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[g.jsx(Sn,{label:i("basic_settings.debug_enable"),checked:(ie=n==null?void 0:n.debug)!=null?ie:!1,disabled:C||k.debug||o,onChange:J=>R("debug","debug",J,Ji.updateDebug,i("notification.debug_updated"))}),g.jsx(Sn,{label:i("basic_settings.usage_statistics_enable"),checked:(ue=n==null?void 0:n.usageStatisticsEnabled)!=null?ue:!1,disabled:C||k.usage||o,onChange:J=>R("usage","usage-statistics-enabled",J,Ji.updateUsageStatistics,i("notification.usage_statistics_updated"))}),g.jsx(Sn,{label:i("basic_settings.logging_to_file_enable"),checked:(F=n==null?void 0:n.loggingToFile)!=null?F:!1,disabled:C||k.loggingToFile||o,onChange:J=>R("loggingToFile","logging-to-file",J,Ji.updateLoggingToFile,i("notification.logging_to_file_updated"))}),g.jsx(Sn,{label:i("basic_settings.ws_auth_enable"),checked:(Y=n==null?void 0:n.wsAuth)!=null?Y:!1,disabled:C||k.wsAuth||o,onChange:J=>R("wsAuth","ws-auth",J,Ji.updateWsAuth,i("notification.ws_auth_updated"))}),g.jsx(Sn,{label:i("basic_settings.force_model_prefix_enable"),checked:(ce=n==null?void 0:n.forceModelPrefix)!=null?ce:!1,disabled:C||k.forceModelPrefix||o,onChange:J=>R("forceModelPrefix","force-model-prefix",J,Ji.updateForceModelPrefix,i("notification.force_model_prefix_updated"))})]})]}),g.jsxs(vt,{title:i("basic_settings.proxy_title"),children:[g.jsx(et,{label:i("basic_settings.proxy_url_label"),placeholder:i("basic_settings.proxy_url_placeholder"),value:d,onChange:J=>h(J.target.value),disabled:C||o}),g.jsxs("div",{style:{display:"flex",gap:12},children:[g.jsx(ye,{variant:"secondary",onClick:L,disabled:C||k.proxy||o,children:i("basic_settings.proxy_clear")}),g.jsx(ye,{onClick:E,loading:k.proxy,disabled:C||o,children:i("basic_settings.proxy_update")})]})]}),g.jsx(vt,{title:i("basic_settings.retry_title"),children:g.jsxs("div",{className:vn.retryRow,children:[g.jsx(et,{label:i("basic_settings.retry_count_label"),type:"number",inputMode:"numeric",min:0,step:1,value:p,onChange:J=>_(Number(J.target.value)),disabled:C||o,className:vn.retryInput}),g.jsx(ye,{className:vn.retryButton,onClick:D,loading:k.retry,disabled:C||o,children:i("basic_settings.retry_update")})]})}),g.jsx(vt,{title:i("basic_settings.logs_max_total_size_title"),children:g.jsxs("div",{className:`${vn.retryRow} ${vn.retryRowAligned} ${vn.retryRowInputGrow}`,children:[g.jsx(et,{label:i("basic_settings.logs_max_total_size_label"),hint:i("basic_settings.logs_max_total_size_hint"),type:"number",inputMode:"numeric",min:0,step:1,value:y,onChange:J=>x(Number(J.target.value)),disabled:C||o,className:vn.retryInput}),g.jsx(ye,{className:vn.retryButton,onClick:q,loading:k.logsMaxSize,disabled:C||o,children:i("basic_settings.logs_max_total_size_update")})]})}),g.jsx(vt,{title:i("basic_settings.routing_title"),children:g.jsxs("div",{className:`${vn.retryRow} ${vn.retryRowAligned} ${vn.retryRowInputGrow}`,children:[g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:i("basic_settings.routing_strategy_label")}),g.jsxs("select",{className:"input",value:v,onChange:J=>w(J.target.value),disabled:C||o,children:[g.jsx("option",{value:"round-robin",children:i("basic_settings.routing_strategy_round_robin")}),g.jsx("option",{value:"fill-first",children:i("basic_settings.routing_strategy_fill_first")})]}),g.jsx("div",{className:"hint",children:i("basic_settings.routing_strategy_hint")})]}),g.jsx(ye,{className:vn.retryButton,onClick:B,loading:k.routingStrategy,disabled:C||o,children:i("basic_settings.routing_strategy_update")})]})}),g.jsx(vt,{title:i("basic_settings.quota_title"),children:g.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[g.jsx(Sn,{label:i("basic_settings.quota_switch_project"),checked:H,disabled:C||k.switchProject||o,onChange:J=>pe(null,null,function*(){var Re,He;const me=(He=(Re=n==null?void 0:n.quotaExceeded)==null?void 0:Re.switchProject)!=null?He:!1,Se=ee(z({},(n==null?void 0:n.quotaExceeded)||{}),{switchProject:J});P("switchProject",!0),a("quota-exceeded",Se);try{yield Ji.updateSwitchProject(J),r("quota-exceeded"),e(i("notification.quota_switch_project_updated"),"success")}catch(Ke){a("quota-exceeded",ee(z({},(n==null?void 0:n.quotaExceeded)||{}),{switchProject:me})),e(`${i("notification.update_failed")}: ${(Ke==null?void 0:Ke.message)||""}`,"error")}finally{P("switchProject",!1)}})}),g.jsx(Sn,{label:i("basic_settings.quota_switch_preview"),checked:W,disabled:C||k.switchPreview||o,onChange:J=>pe(null,null,function*(){var Re,He;const me=(He=(Re=n==null?void 0:n.quotaExceeded)==null?void 0:Re.switchPreviewModel)!=null?He:!1,Se=ee(z({},(n==null?void 0:n.quotaExceeded)||{}),{switchPreviewModel:J});P("switchPreview",!0),a("quota-exceeded",Se);try{yield Ji.updateSwitchPreviewModel(J),r("quota-exceeded"),e(i("notification.quota_switch_preview_updated"),"success")}catch(Ke){a("quota-exceeded",ee(z({},(n==null?void 0:n.quotaExceeded)||{}),{switchPreviewModel:me})),e(`${i("notification.update_failed")}: ${(Ke==null?void 0:Ke.message)||""}`,"error")}finally{P("switchPreview",!1)}})})]})})]})]})}function Ps({title:i,description:e,action:t}){return g.jsxs("div",{className:"empty-state",children:[g.jsxs("div",{className:"empty-content",children:[g.jsx("div",{className:"empty-icon","aria-hidden":"true",children:g.jsx(QU,{size:20})}),g.jsxs("div",{children:[g.jsx("div",{className:"empty-title",children:i}),e&&g.jsx("div",{className:"empty-desc",children:e})]})]}),t&&g.jsx("div",{className:"empty-action",children:t})]})}function C0({size:i=20,className:e=""}){return g.jsx("div",{className:`loading-spinner${e?` ${e}`:""}`,style:{width:i,height:i,borderWidth:i/7},role:"status","aria-live":"polite"})}function eH(i){return i?/^[\x21-\x7E]+$/.test(i):!1}const tH="ApiKeysPage-module__container___tdy0z",iH="ApiKeysPage-module__pageTitle___nLQ41",MO={container:tH,pageTitle:iH};function nH(){const{t:i}=rt(),{showNotification:e}=Zn(),t=Ct(V=>V.connectionStatus),n=Wt(V=>V.config),s=Wt(V=>V.fetchConfig),a=Wt(V=>V.updateConfigValue),r=Wt(V=>V.clearCache),[o,c]=N.useState([]),[d,h]=N.useState(!0),[p,_]=N.useState(""),[y,x]=N.useState(!1),[v,w]=N.useState(null),[k,M]=N.useState(""),[O,A]=N.useState(!1),[C,P]=N.useState(null),R=N.useMemo(()=>t!=="connected",[t]),E=N.useCallback((V=!1)=>pe(null,null,function*(){h(!0),_("");try{const U=yield s("api-keys",V),G=Array.isArray(U)?U:[];c(G)}catch(U){_((U==null?void 0:U.message)||i("notification.refresh_failed"))}finally{h(!1)}}),[s,i]);N.useEffect(()=>{E()},[E]),N.useEffect(()=>{Array.isArray(n==null?void 0:n.apiKeys)&&c(n.apiKeys)},[n==null?void 0:n.apiKeys]);const L=()=>{w(null),M(""),x(!0)},D=V=>{var U;w(V),M((U=o[V])!=null?U:""),x(!0)},q=()=>{x(!1),M(""),w(null)},B=()=>pe(null,null,function*(){const V=k.trim();if(!V){e(`${i("notification.please_enter")} ${i("notification.api_key")}`,"error");return}if(!eH(V)){e(i("notification.api_key_invalid_chars"),"error");return}const U=v!==null,G=U?o.map(($,ie)=>ie===v?V:$):[...o,V];A(!0);try{U&&v!==null?(yield Yc.update(v,V),e(i("notification.api_key_updated"),"success")):(yield Yc.replace(G),e(i("notification.api_key_added"),"success")),c(G),a("api-keys",G),r("api-keys"),q()}catch($){e(`${i("notification.update_failed")}: ${($==null?void 0:$.message)||""}`,"error")}finally{A(!1)}}),H=V=>pe(null,null,function*(){if(window.confirm(i("api_keys.delete_confirm"))){P(V);try{yield Yc.delete(V);const U=o.filter((G,$)=>$!==V);c(U),a("api-keys",U),r("api-keys"),e(i("notification.api_key_deleted"),"success")}catch(U){e(`${i("notification.delete_failed")}: ${(U==null?void 0:U.message)||""}`,"error")}finally{P(null)}}}),W=g.jsxs("div",{style:{display:"flex",gap:8},children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>E(!0),disabled:d,children:i("common.refresh")}),g.jsx(ye,{size:"sm",onClick:L,disabled:R,children:i("api_keys.add_button")})]});return g.jsxs("div",{className:MO.container,children:[g.jsx("h1",{className:MO.pageTitle,children:i("api_keys.title")}),g.jsxs(vt,{title:i("api_keys.proxy_auth_title"),extra:W,children:[p&&g.jsx("div",{className:"error-box",children:p}),d?g.jsx("div",{className:"flex-center",style:{padding:"24px 0"},children:g.jsx(C0,{size:28})}):o.length===0?g.jsx(Ps,{title:i("api_keys.empty_title"),description:i("api_keys.empty_desc"),action:g.jsx(ye,{onClick:L,disabled:R,children:i("api_keys.add_button")})}):g.jsx("div",{className:"item-list",children:o.map((V,U)=>g.jsxs("div",{className:"item-row",children:[g.jsxs("div",{className:"item-meta",children:[g.jsxs("div",{className:"pill",children:["#",U+1]}),g.jsx("div",{className:"item-title",children:i("api_keys.item_title")}),g.jsx("div",{className:"item-subtitle",children:pn(String(V||""))})]}),g.jsxs("div",{className:"item-actions",children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>D(U),disabled:R,children:i("common.edit")}),g.jsx(ye,{variant:"danger",size:"sm",onClick:()=>H(U),disabled:R||C===U,loading:C===U,children:i("common.delete")})]})]},U))}),g.jsx(zn,{open:y,onClose:q,title:i(v!==null?"api_keys.edit_modal_title":"api_keys.add_modal_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:q,disabled:O,children:i("common.cancel")}),g.jsx(ye,{onClick:B,loading:O,children:i(v!==null?"common.update":"common.add")})]}),children:g.jsx(et,{label:i(v!==null?"api_keys.edit_modal_key_label":"api_keys.add_modal_key_label"),placeholder:i(v!==null?"api_keys.edit_modal_key_label":"api_keys.add_modal_key_placeholder"),value:k,onChange:V=>M(V.target.value),disabled:O})})]})]})}const O0=i=>!Array.isArray(i)||i.length===0?[{name:"",alias:""}]:i.map(e=>({name:e.name||"",alias:e.alias||""})),NO=i=>i.filter(e=>e.name.trim()).map(e=>{const t={name:e.name.trim()},n=e.alias.trim();return n&&n!==t.name&&(t.alias=n),t});function T0({entries:i,onChange:e,addLabel:t,disabled:n=!1,namePlaceholder:s="model-name",aliasPlaceholder:a="alias (optional)"}){const r=i.length?i:[{name:"",alias:""}],o=(h,p,_)=>{const y=r.map((x,v)=>v===h?ee(z({},x),{[p]:_}):x);e(y)},c=()=>{e([...r,{name:"",alias:""}])},d=h=>{const p=r.filter((_,y)=>y!==h);e(p.length?p:[{name:"",alias:""}])};return g.jsxs("div",{className:"header-input-list",children:[r.map((h,p)=>g.jsx(N.Fragment,{children:g.jsxs("div",{className:"header-input-row",children:[g.jsx("input",{className:"input",placeholder:s,value:h.name,onChange:_=>o(p,"name",_.target.value),disabled:n}),g.jsx("span",{className:"header-separator",children:"→"}),g.jsx("input",{className:"input",placeholder:a,value:h.alias,onChange:_=>o(p,"alias",_.target.value),disabled:n}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>d(p),disabled:n||r.length<=1,title:"Remove","aria-label":"Remove",children:g.jsx(Hl,{size:14})})]})},p)),g.jsx(ye,{variant:"secondary",size:"sm",onClick:c,disabled:n,className:"align-start",children:t})]})}const sH="data:image/svg+xml,%3csvg%20width='400'%20height='400'%20viewBox='0%200%2028%2028'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M13.9197%2013.61L17.3816%2026.566L14.242%2027.4049L11.2645%2016.2643L0.119926%2013.2906L0.957817%2010.15L13.9197%2013.61Z'%20fill='%23F34E3F'/%3e%3cpath%20d='M13.7391%2016.0892L4.88169%2024.9056L2.58872%2022.6019L11.4461%2013.7865L13.7391%2016.0892Z'%20fill='%23F34E3F'/%3e%3cpath%20d='M18.9386%208.58315L22.4005%2021.5392L19.2609%2022.3781L16.2833%2011.2374L5.13879%208.26381L5.97668%205.12318L18.9386%208.58315Z'%20fill='%23F34E3F'/%3e%3cpath%20d='M23.9803%203.55632L27.4422%2016.5124L24.3025%2017.3512L21.325%206.21062L10.1805%203.23698L11.0183%200.0963593L23.9803%203.55632Z'%20fill='%23F34E3F'/%3e%3c/svg%3e",aH="AiProvidersPage-module__container___y-jfS",rH="AiProvidersPage-module__cardTitle___vO4i3",oH="AiProvidersPage-module__cardTitleIcon___-rTw0",lH="AiProvidersPage-module__pageTitle___DoSv8",cH="AiProvidersPage-module__content___E2Czu",uH="AiProvidersPage-module__cardStats___rELY1",dH="AiProvidersPage-module__statPill___d812A",hH="AiProvidersPage-module__statSuccess___5dRtj",fH="AiProvidersPage-module__statFailure___krDjY",pH="AiProvidersPage-module__fieldRow___XK6hX",mH="AiProvidersPage-module__fieldLabel___cLX9f",gH="AiProvidersPage-module__fieldValue___VdFCH",_H="AiProvidersPage-module__headerBadgeList___kwkIM",yH="AiProvidersPage-module__headerBadge___eN0Fd",xH="AiProvidersPage-module__modelTagList___shUnj",bH="AiProvidersPage-module__modelCountLabel___uV8s-",vH="AiProvidersPage-module__modelTag___k-VuJ",SH="AiProvidersPage-module__modelName___-6r4h",wH="AiProvidersPage-module__modelAlias___ljQjM",kH="AiProvidersPage-module__excludedModelTag___emTfi",AH="AiProvidersPage-module__excludedModelsSection___XFykq",CH="AiProvidersPage-module__excludedModelsLabel___Drdds",OH="AiProvidersPage-module__apiKeyEntriesSection___60ydj",TH="AiProvidersPage-module__apiKeyEntriesLabel___c5W8h",MH="AiProvidersPage-module__apiKeyEntryList___-xrgk",NH="AiProvidersPage-module__apiKeyEntryCard___Y5gRi",RH="AiProvidersPage-module__apiKeyEntryIndex___h8oWW",PH="AiProvidersPage-module__apiKeyEntryKey___JgU0c",LH="AiProvidersPage-module__apiKeyEntryProxy___gy9Vu",jH="AiProvidersPage-module__apiKeyEntryStats___Whq5E",EH="AiProvidersPage-module__apiKeyEntryStat___rwvkB",DH="AiProvidersPage-module__apiKeyEntryStatSuccess___GXIwG",UH="AiProvidersPage-module__apiKeyEntryStatFailure___XV9wg",FH="AiProvidersPage-module__modelDiscoveryList___HKeOb",BH="AiProvidersPage-module__modelDiscoveryRow___3J8pc",zH="AiProvidersPage-module__modelDiscoveryRowSelected___VLfIp",qH="AiProvidersPage-module__modelDiscoveryMeta___7D6Y5",HH="AiProvidersPage-module__modelDiscoveryName___yf70V",KH="AiProvidersPage-module__modelDiscoveryAlias___N2nU7",VH="AiProvidersPage-module__modelDiscoveryDesc___nsrtd",IH="AiProvidersPage-module__openaiTestButtonSuccess___ZiymQ",WH="AiProvidersPage-module__openaiTestSelect___7-Upw",XH="AiProvidersPage-module__openaiTestButton___IEmjD",GH="AiProvidersPage-module__statusBar___gAS9s",QH="AiProvidersPage-module__statusBlocks___RESqk",YH="AiProvidersPage-module__statusBlock___nUV1s",ZH="AiProvidersPage-module__statusBlockSuccess___k3qxb",JH="AiProvidersPage-module__statusBlockFailure___rQIEy",$H="AiProvidersPage-module__statusBlockMixed___PmcCP",eK="AiProvidersPage-module__statusBlockIdle___WEMXo",tK="AiProvidersPage-module__statusRate___mqcEs",iK="AiProvidersPage-module__statusRateHigh___GpDhl",nK="AiProvidersPage-module__statusRateMedium___hdtEj",sK="AiProvidersPage-module__statusRateLow___mNI2c",Z={container:aH,cardTitle:rH,cardTitleIcon:oH,pageTitle:lH,content:cH,cardStats:uH,statPill:dH,statSuccess:hH,statFailure:fH,fieldRow:pH,fieldLabel:mH,fieldValue:gH,headerBadgeList:_H,headerBadge:yH,modelTagList:xH,modelCountLabel:bH,modelTag:vH,modelName:SH,modelAlias:wH,excludedModelTag:kH,excludedModelsSection:AH,excludedModelsLabel:CH,apiKeyEntriesSection:OH,apiKeyEntriesLabel:TH,apiKeyEntryList:MH,apiKeyEntryCard:NH,apiKeyEntryIndex:RH,apiKeyEntryKey:PH,apiKeyEntryProxy:LH,apiKeyEntryStats:jH,apiKeyEntryStat:EH,apiKeyEntryStatSuccess:DH,apiKeyEntryStatFailure:UH,modelDiscoveryList:FH,modelDiscoveryRow:BH,modelDiscoveryRowSelected:zH,modelDiscoveryMeta:qH,modelDiscoveryName:HH,modelDiscoveryAlias:KH,modelDiscoveryDesc:VH,openaiTestButtonSuccess:IH,openaiTestSelect:WH,openaiTestButton:XH,statusBar:GH,statusBlocks:QH,statusBlock:YH,statusBlockSuccess:ZH,statusBlockFailure:JH,statusBlockMixed:$H,statusBlockIdle:eK,statusRate:tK,statusRateHigh:iK,statusRateMedium:nK,statusRateLow:sK},l2="*",pr=i=>Array.isArray(i)&&i.some(e=>String(e!=null?e:"").trim()===l2),qP=i=>Array.isArray(i)?i.filter(e=>String(e!=null?e:"").trim()!==l2):[],RO=i=>[...qP(i),l2],PO=i=>qP(i),LO=i=>i.split(/[\n,]+/).map(e=>e.trim()).filter(Boolean),c2=i=>Array.isArray(i)?i.join(` `):"",HP=i=>{let e=String(i||"").trim();return e?(e=e.replace(/\/?v0\/management\/?$/i,""),e=e.replace(/\/+$/g,""),/^https?:\/\//i.test(e)||(e=`http://${e}`),e):""},aK=i=>{const e=HP(i);return e?e.endsWith("/v1")?`${e}/models`:`${e}/v1/models`:""},rK=i=>{const e=HP(i);return e?e.endsWith("/chat/completions")?e:e.endsWith("/v1")?`${e}/chat/completions`:`${e}/v1/chat/completions`:""},pf=(i,e,t)=>{var a;const n=(a=e.bySource)!=null?a:{},s=t(i);return n[i]||n[s]||{success:0,failure:0}},oK=(i,e,t)=>{var r;const n=(r=e.bySource)!=null?r:{};let s=0,a=0;return(i||[]).forEach(o=>{const c=(o==null?void 0:o.apiKey)||"";if(!c)return;const d=t(c),h=n[c]||n[d]||{success:0,failure:0};s+=h.success,a+=h.failure}),{success:s,failure:a}},Id=i=>{var e,t,n;return{apiKey:(e=i==null?void 0:i.apiKey)!=null?e:"",proxyUrl:(t=i==null?void 0:i.proxyUrl)!=null?t:"",headers:(n=i==null?void 0:i.headers)!=null?n:{}}},lK=i=>!Array.isArray(i)||i.length===0?[{name:"",alias:""}]:i.map(e=>{var t,n;return{name:(t=e.from)!=null?t:"",alias:(n=e.to)!=null?n:""}}),cK=i=>{const e=new Set,t=[];return i.forEach(n=>{const s=n.name.trim(),a=n.alias.trim();if(!s||!a)return;const r=s.toLowerCase();e.has(r)||(e.add(r),t.push({from:s,to:a}))}),t},sm=i=>{var e,t;return{upstreamUrl:(e=i==null?void 0:i.upstreamUrl)!=null?e:"",upstreamApiKey:"",forceModelMappings:(t=i==null?void 0:i.forceModelMappings)!=null?t:!1,mappingEntries:lK(i==null?void 0:i.modelMappings)}};function uK({isOpen:i,disableControls:e,onClose:t,onBusyChange:n}){var L,D;const{t:s}=rt(),{showNotification:a}=Zn(),r=Wt(q=>q.config),o=Wt(q=>q.updateConfigValue),c=Wt(q=>q.clearCache),[d,h]=N.useState(()=>sm(null)),[p,_]=N.useState(!1),[y,x]=N.useState(!1),[v,w]=N.useState(!1),[k,M]=N.useState(""),[O,A]=N.useState(!1),C=N.useRef(!1),P=q=>q instanceof Error?q.message:typeof q=="string"?q:"";N.useEffect(()=>{n==null||n(p||O)},[p,O,n]),N.useEffect(()=>{var q;if(!i){C.current=!1,_(!1),A(!1),M(""),x(!1),w(!1),h(sm(null)),n==null||n(!1);return}C.current||(C.current=!0,_(!0),x(!1),w(!1),M(""),h(sm((q=r==null?void 0:r.ampcode)!=null?q:null)),pe(null,null,function*(){try{const B=yield nr.getAmpcode();x(!0),o("ampcode",B),c("ampcode"),h(sm(B))}catch(B){M(P(B)||s("notification.refresh_failed"))}finally{_(!1)}}))},[c,r==null?void 0:r.ampcode,i,n,s,o]);const R=()=>pe(null,null,function*(){var q;if(window.confirm(s("ai_providers.ampcode_clear_upstream_api_key_confirm"))){A(!0),M("");try{yield nr.clearUpstreamApiKey();const B=(q=r==null?void 0:r.ampcode)!=null?q:{},H=z({},B);delete H.upstreamApiKey,o("ampcode",H),c("ampcode"),a(s("notification.ampcode_upstream_api_key_cleared"),"success")}catch(B){const H=P(B);M(H),a(`${s("notification.update_failed")}: ${H}`,"error")}finally{A(!1)}}}),E=()=>pe(null,null,function*(){var q;if(!(!y&&v&&!window.confirm(s("ai_providers.ampcode_mappings_overwrite_confirm")))){A(!0),M("");try{const B=d.upstreamUrl.trim(),H=d.upstreamApiKey.trim(),W=cK(d.mappingEntries);B?yield nr.updateUpstreamUrl(B):yield nr.clearUpstreamUrl(),yield nr.updateForceModelMappings(d.forceModelMappings),(y||v)&&(W.length?yield nr.saveModelMappings(W):yield nr.clearModelMappings()),H&&(yield nr.updateUpstreamApiKey(H));const V=(q=r==null?void 0:r.ampcode)!=null?q:{},U={upstreamUrl:B||void 0,forceModelMappings:d.forceModelMappings};V.upstreamApiKey&&(U.upstreamApiKey=V.upstreamApiKey),Array.isArray(V.modelMappings)&&(U.modelMappings=V.modelMappings),H&&(U.upstreamApiKey=H),(y||v)&&(W.length?U.modelMappings=W:delete U.modelMappings),o("ampcode",U),c("ampcode"),a(s("notification.ampcode_updated"),"success"),t()}catch(B){const H=P(B);M(H),a(`${s("notification.update_failed")}: ${H}`,"error")}finally{A(!1)}}});return g.jsxs(zn,{open:i,onClose:t,title:s("ai_providers.ampcode_modal_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:t,disabled:O,children:s("common.cancel")}),g.jsx(ye,{onClick:E,loading:O,disabled:e||p,children:s("common.save")})]}),children:[k&&g.jsx("div",{className:"error-box",children:k}),g.jsx(et,{label:s("ai_providers.ampcode_upstream_url_label"),placeholder:s("ai_providers.ampcode_upstream_url_placeholder"),value:d.upstreamUrl,onChange:q=>h(B=>ee(z({},B),{upstreamUrl:q.target.value})),disabled:p||O,hint:s("ai_providers.ampcode_upstream_url_hint")}),g.jsx(et,{label:s("ai_providers.ampcode_upstream_api_key_label"),placeholder:s("ai_providers.ampcode_upstream_api_key_placeholder"),type:"password",value:d.upstreamApiKey,onChange:q=>h(B=>ee(z({},B),{upstreamApiKey:q.target.value})),disabled:p||O,hint:s("ai_providers.ampcode_upstream_api_key_hint")}),g.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",marginTop:-8,marginBottom:12,flexWrap:"wrap"},children:[g.jsx("div",{className:"hint",style:{margin:0},children:s("ai_providers.ampcode_upstream_api_key_current",{key:(L=r==null?void 0:r.ampcode)!=null&&L.upstreamApiKey?pn(r.ampcode.upstreamApiKey):s("common.not_set")})}),g.jsx(ye,{variant:"danger",size:"sm",onClick:R,disabled:p||O||!((D=r==null?void 0:r.ampcode)!=null&&D.upstreamApiKey),children:s("ai_providers.ampcode_clear_upstream_api_key")})]}),g.jsxs("div",{className:"form-group",children:[g.jsx(Sn,{label:s("ai_providers.ampcode_force_model_mappings_label"),checked:d.forceModelMappings,onChange:q=>h(B=>ee(z({},B),{forceModelMappings:q})),disabled:p||O}),g.jsx("div",{className:"hint",children:s("ai_providers.ampcode_force_model_mappings_hint")})]}),g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:s("ai_providers.ampcode_model_mappings_label")}),g.jsx(T0,{entries:d.mappingEntries,onChange:q=>{w(!0),h(B=>ee(z({},B),{mappingEntries:q}))},addLabel:s("ai_providers.ampcode_model_mappings_add_btn"),namePlaceholder:s("ai_providers.ampcode_model_mappings_from_placeholder"),aliasPlaceholder:s("ai_providers.ampcode_model_mappings_to_placeholder"),disabled:p||O}),g.jsx("div",{className:"hint",children:s("ai_providers.ampcode_model_mappings_hint")})]})]})}function dK({config:i,loading:e,disableControls:t,isSaving:n,isSwitching:s,isBusy:a,isModalOpen:r,onOpen:o,onCloseModal:c,onBusyChange:d}){var p,_,y;const{t:h}=rt();return g.jsxs(g.Fragment,{children:[g.jsx(vt,{title:g.jsxs("span",{className:Z.cardTitle,children:[g.jsx("img",{src:sH,alt:"",className:Z.cardTitleIcon}),h("ai_providers.ampcode_title")]}),extra:g.jsx(ye,{size:"sm",onClick:o,disabled:t||n||a||s,children:h("common.edit")}),children:e?g.jsx("div",{className:"hint",children:h("common.loading")}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[h("ai_providers.ampcode_upstream_url_label"),":"]}),g.jsx("span",{className:Z.fieldValue,children:(i==null?void 0:i.upstreamUrl)||h("common.not_set")})]}),g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[h("ai_providers.ampcode_upstream_api_key_label"),":"]}),g.jsx("span",{className:Z.fieldValue,children:i!=null&&i.upstreamApiKey?pn(i.upstreamApiKey):h("common.not_set")})]}),g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[h("ai_providers.ampcode_force_model_mappings_label"),":"]}),g.jsx("span",{className:Z.fieldValue,children:(p=i==null?void 0:i.forceModelMappings)!=null&&p?h("common.yes"):h("common.no")})]}),g.jsxs("div",{className:Z.fieldRow,style:{marginTop:8},children:[g.jsxs("span",{className:Z.fieldLabel,children:[h("ai_providers.ampcode_model_mappings_count"),":"]}),g.jsx("span",{className:Z.fieldValue,children:((_=i==null?void 0:i.modelMappings)==null?void 0:_.length)||0})]}),(y=i==null?void 0:i.modelMappings)!=null&&y.length?g.jsxs("div",{className:Z.modelTagList,children:[i.modelMappings.slice(0,5).map(x=>g.jsxs("span",{className:Z.modelTag,children:[g.jsx("span",{className:Z.modelName,children:x.from}),g.jsx("span",{className:Z.modelAlias,children:x.to})]},`${x.from}→${x.to}`)),i.modelMappings.length>5&&g.jsx("span",{className:Z.modelTag,children:g.jsxs("span",{className:Z.modelName,children:["+",i.modelMappings.length-5]})})]}):null]})}),g.jsx(uK,{isOpen:r,disableControls:t,onClose:c,onBusyChange:d})]})}const KP="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eClaude%3c/title%3e%3cpath%20d='M4.709%2015.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0%2011.784l.055-.352.48-.321.686.06%201.52.103%202.278.158%201.652.097%202.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686%201.908%201.476%202.491%201.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97%202.97%200%2001-.104-.729L6.283.134%206.696%200l.996.134.42.364.62%201.414%201.002%202.229%201.555%203.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286%201.851-.559%202.903-.364%201.942h.212l.243-.242.985-1.306%201.652-2.064.73-.82.85-.904.547-.431h1.033l.76%201.129-.34%201.166-1.064%201.347-.881%201.142-1.264%201.7-.79%201.36.073.11.188-.02%202.856-.606%201.543-.28%201.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061%201.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093%201.068%202.006%201.81%202.509%202.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649%202.345%203.521.122%201.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674%207.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434%201.967-2.18%202.945-1.726%201.845-.414.164-.717-.37.067-.662.401-.589%202.388-3.036%201.44-1.882.93-1.086-.006-.158h-.055L4.132%2018.56l-1.13.146-.487-.456.061-.746.231-.243%201.908-1.312-.006.006z'%20fill='%23D97757'%20fill-rule='nonzero'%3e%3c/path%3e%3c/svg%3e";function mf({items:i,loading:e,keyField:t,renderContent:n,onEdit:s,onDelete:a,emptyTitle:r,emptyDescription:o,deleteLabel:c,actionsDisabled:d=!1,getRowDisabled:h,renderExtraActions:p}){const{t:_}=rt();return e?g.jsx("div",{className:"hint",children:_("common.loading")}):i.length?g.jsx("div",{className:"item-list",children:i.map((y,x)=>{const v=h?h(y,x):!1;return g.jsxs("div",{className:"item-row",style:v?{opacity:.6}:void 0,children:[g.jsx("div",{className:"item-meta",children:n(y,x)}),g.jsxs("div",{className:"item-actions",children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>s(x),disabled:d,children:_("common.edit")}),g.jsx(ye,{variant:"danger",size:"sm",onClick:()=>a(x),disabled:d,children:c||_("common.delete")}),p?p(y,x):null]})]},t(y))})}):g.jsx(Ps,{title:r,description:o})}function gf({statusData:i}){const e=i.totalSuccess+i.totalFailure>0,t=e?i.successRate>=90?Z.statusRateHigh:i.successRate>=50?Z.statusRateMedium:Z.statusRateLow:"";return g.jsxs("div",{className:Z.statusBar,children:[g.jsx("div",{className:Z.statusBlocks,children:i.blocks.map((n,s)=>{const a=n==="success"?Z.statusBlockSuccess:n==="failure"?Z.statusBlockFailure:n==="mixed"?Z.statusBlockMixed:Z.statusBlockIdle;return g.jsx("div",{className:`${Z.statusBlock} ${a}`},s)})}),g.jsx("span",{className:`${Z.statusRate} ${t}`,children:e?`${i.successRate.toFixed(1)}%`:"--"})]})}function _f({entries:i,onChange:e,addLabel:t,disabled:n=!1,keyPlaceholder:s="X-Custom-Header",valuePlaceholder:a="value"}){const r=i.length?i:[{key:"",value:""}],o=(h,p,_)=>{const y=r.map((x,v)=>v===h?ee(z({},x),{[p]:_}):x);e(y)},c=()=>{e([...r,{key:"",value:""}])},d=h=>{const p=r.filter((_,y)=>y!==h);e(p.length?p:[{key:"",value:""}])};return g.jsxs("div",{className:"header-input-list",children:[r.map((h,p)=>g.jsx(N.Fragment,{children:g.jsxs("div",{className:"header-input-row",children:[g.jsx("input",{className:"input",placeholder:s,value:h.key,onChange:_=>o(p,"key",_.target.value),disabled:n}),g.jsx("span",{className:"header-separator",children:":"}),g.jsx("input",{className:"input",placeholder:a,value:h.value,onChange:_=>o(p,"value",_.target.value),disabled:n}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>d(p),disabled:n||r.length<=1,title:"Remove","aria-label":"Remove",children:g.jsx(Hl,{size:14})})]})},p)),g.jsx(ye,{variant:"secondary",size:"sm",onClick:c,disabled:n,className:"align-start",children:t})]})}const jO=()=>({apiKey:"",prefix:"",baseUrl:"",proxyUrl:"",headers:[],models:[],excludedModels:[],modelEntries:[{name:"",alias:""}],excludedText:""});function hK({isOpen:i,editIndex:e,initialData:t,onClose:n,onSave:s,isSaving:a}){var d,h,p;const{t:r}=rt(),[o,c]=N.useState(jO);return N.useEffect(()=>{if(i){if(t){c(ee(z({},t),{headers:cf(t.headers),modelEntries:O0(t.models),excludedText:c2(t.excludedModels)}));return}c(jO())}},[t,i]),g.jsxs(zn,{open:i,onClose:n,title:r(e!==null?"ai_providers.claude_edit_modal_title":"ai_providers.claude_add_modal_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:n,disabled:a,children:r("common.cancel")}),g.jsx(ye,{onClick:()=>void s(o,e),loading:a,children:r("common.save")})]}),children:[g.jsx(et,{label:r("ai_providers.claude_add_modal_key_label"),value:o.apiKey,onChange:_=>c(y=>ee(z({},y),{apiKey:_.target.value}))}),g.jsx(et,{label:r("ai_providers.prefix_label"),placeholder:r("ai_providers.prefix_placeholder"),value:(d=o.prefix)!=null?d:"",onChange:_=>c(y=>ee(z({},y),{prefix:_.target.value})),hint:r("ai_providers.prefix_hint")}),g.jsx(et,{label:r("ai_providers.claude_add_modal_url_label"),value:(h=o.baseUrl)!=null?h:"",onChange:_=>c(y=>ee(z({},y),{baseUrl:_.target.value}))}),g.jsx(et,{label:r("ai_providers.claude_add_modal_proxy_label"),value:(p=o.proxyUrl)!=null?p:"",onChange:_=>c(y=>ee(z({},y),{proxyUrl:_.target.value}))}),g.jsx(_f,{entries:o.headers,onChange:_=>c(y=>ee(z({},y),{headers:_})),addLabel:r("common.custom_headers_add"),keyPlaceholder:r("common.custom_headers_key_placeholder"),valuePlaceholder:r("common.custom_headers_value_placeholder")}),g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:r("ai_providers.claude_models_label")}),g.jsx(T0,{entries:o.modelEntries,onChange:_=>c(y=>ee(z({},y),{modelEntries:_})),addLabel:r("ai_providers.claude_models_add_btn"),namePlaceholder:r("common.model_name_placeholder"),aliasPlaceholder:r("common.model_alias_placeholder"),disabled:a})]}),g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:r("ai_providers.excluded_models_label")}),g.jsx("textarea",{className:"input",placeholder:r("ai_providers.excluded_models_placeholder"),value:o.excludedText,onChange:_=>c(y=>ee(z({},y),{excludedText:_.target.value})),rows:4}),g.jsx("div",{className:"hint",children:r("ai_providers.excluded_models_hint")})]})]})}function fK({configs:i,keyStats:e,usageDetails:t,loading:n,disableControls:s,isSaving:a,isSwitching:r,isModalOpen:o,modalIndex:c,onAdd:d,onEdit:h,onDelete:p,onToggle:_,onCloseModal:y,onSave:x}){const{t:v}=rt(),w=s||a||r,k=s||n||a||r,M=N.useMemo(()=>{const A=new Map,C=new Set;return i.forEach(P=>P.apiKey&&C.add(P.apiKey)),C.forEach(P=>{A.set(P,qs(t,P))}),A},[i,t]),O=c!==null?i[c]:void 0;return g.jsxs(g.Fragment,{children:[g.jsx(vt,{title:g.jsxs("span",{className:Z.cardTitle,children:[g.jsx("img",{src:KP,alt:"",className:Z.cardTitleIcon}),v("ai_providers.claude_title")]}),extra:g.jsx(ye,{size:"sm",onClick:d,disabled:w,children:v("ai_providers.claude_add_button")}),children:g.jsx(mf,{items:i,loading:n,keyField:A=>A.apiKey,emptyTitle:v("ai_providers.claude_empty_title"),emptyDescription:v("ai_providers.claude_empty_desc"),onEdit:h,onDelete:p,actionsDisabled:w,getRowDisabled:A=>pr(A.excludedModels),renderExtraActions:(A,C)=>g.jsx(Sn,{label:v("ai_providers.config_toggle_label"),checked:!pr(A.excludedModels),disabled:k,onChange:P=>void _(C,P)}),renderContent:A=>{var D,q;const C=pf(A.apiKey,e,pn),P=Object.entries(A.headers||{}),R=pr(A.excludedModels),E=(D=A.excludedModels)!=null?D:[],L=M.get(A.apiKey)||qs([],A.apiKey);return g.jsxs(N.Fragment,{children:[g.jsx("div",{className:"item-title",children:v("ai_providers.claude_item_title")}),g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[v("common.api_key"),":"]}),g.jsx("span",{className:Z.fieldValue,children:pn(A.apiKey)})]}),A.prefix&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[v("common.prefix"),":"]}),g.jsx("span",{className:Z.fieldValue,children:A.prefix})]}),A.baseUrl&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[v("common.base_url"),":"]}),g.jsx("span",{className:Z.fieldValue,children:A.baseUrl})]}),A.proxyUrl&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[v("common.proxy_url"),":"]}),g.jsx("span",{className:Z.fieldValue,children:A.proxyUrl})]}),P.length>0&&g.jsx("div",{className:Z.headerBadgeList,children:P.map(([B,H])=>g.jsxs("span",{className:Z.headerBadge,children:[g.jsxs("strong",{children:[B,":"]})," ",H]},B))}),R&&g.jsx("div",{className:"status-badge warning",style:{marginTop:8,marginBottom:0},children:v("ai_providers.config_disabled_badge")}),(q=A.models)!=null&&q.length?g.jsxs("div",{className:Z.modelTagList,children:[g.jsxs("span",{className:Z.modelCountLabel,children:[v("ai_providers.claude_models_count"),": ",A.models.length]}),A.models.map(B=>g.jsxs("span",{className:Z.modelTag,children:[g.jsx("span",{className:Z.modelName,children:B.name}),B.alias&&B.alias!==B.name&&g.jsx("span",{className:Z.modelAlias,children:B.alias})]},B.name))]}):null,E.length?g.jsxs("div",{className:Z.excludedModelsSection,children:[g.jsx("div",{className:Z.excludedModelsLabel,children:v("ai_providers.excluded_models_count",{count:E.length})}),g.jsx("div",{className:Z.modelTagList,children:E.map(B=>g.jsx("span",{className:`${Z.modelTag} ${Z.excludedModelTag}`,children:g.jsx("span",{className:Z.modelName,children:B})},B))})]}):null,g.jsxs("div",{className:Z.cardStats,children:[g.jsxs("span",{className:`${Z.statPill} ${Z.statSuccess}`,children:[v("stats.success"),": ",C.success]}),g.jsxs("span",{className:`${Z.statPill} ${Z.statFailure}`,children:[v("stats.failure"),": ",C.failure]})]}),g.jsx(gf,{statusData:L})]})}})}),g.jsx(hK,{isOpen:o,editIndex:c,initialData:O,onClose:y,onSave:x,isSaving:a})]})}const u2="data:image/svg+xml,%3csvg%20fill='%23000000'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenAI%3c/title%3e%3cpath%20d='M21.55%2010.004a5.416%205.416%200%2000-.478-4.501c-1.217-2.09-3.662-3.166-6.05-2.66A5.59%205.59%200%200010.831%201C8.39.995%206.224%202.546%205.473%204.838A5.553%205.553%200%20001.76%207.496a5.487%205.487%200%2000.691%206.5%205.416%205.416%200%2000.477%204.502c1.217%202.09%203.662%203.165%206.05%202.66A5.586%205.586%200%200013.168%2023c2.443.006%204.61-1.546%205.361-3.84a5.553%205.553%200%20003.715-2.66%205.488%205.488%200%2000-.693-6.497v.001zm-8.381%2011.558a4.199%204.199%200%2001-2.675-.954c.034-.018.093-.05.132-.074l4.44-2.53a.71.71%200%2000.364-.623v-6.176l1.877%201.069c.02.01.033.029.036.05v5.115c-.003%202.274-1.87%204.118-4.174%204.123zM4.192%2017.78a4.059%204.059%200%2001-.498-2.763c.032.02.09.055.131.078l4.44%202.53c.225.13.504.13.73%200l5.42-3.088v2.138a.068.068%200%2001-.027.057L9.9%2019.288c-1.999%201.136-4.552.46-5.707-1.51h-.001zM3.023%208.216A4.15%204.15%200%20015.198%206.41l-.002.151v5.06a.711.711%200%2000.364.624l5.42%203.087-1.876%201.07a.067.067%200%2001-.063.005l-4.489-2.559c-1.995-1.14-2.679-3.658-1.53-5.63h.001zm15.417%203.54l-5.42-3.088L14.896%207.6a.067.067%200%2001.063-.006l4.489%202.557c1.998%201.14%202.683%203.662%201.529%205.633a4.163%204.163%200%2001-2.174%201.807V12.38a.71.71%200%2000-.363-.623zm1.867-2.773a6.04%206.04%200%2000-.132-.078l-4.44-2.53a.731.731%200%2000-.729%200l-5.42%203.088V7.325a.068.068%200%2001.027-.057L14.1%204.713c2-1.137%204.555-.46%205.707%201.513.487.833.664%201.809.499%202.757h.001zm-11.741%203.81l-1.877-1.068a.065.065%200%2001-.036-.051V6.559c.001-2.277%201.873-4.122%204.181-4.12.976%200%201.92.338%202.671.954-.034.018-.092.05-.131.073l-4.44%202.53a.71.71%200%2000-.365.623l-.003%206.173v.002zm1.02-2.168L12%209.25l2.414%201.375v2.75L12%2014.75l-2.415-1.375v-2.75z'%3e%3c/path%3e%3c/svg%3e",d2="data:image/svg+xml,%3csvg%20fill='%23ffffff'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eOpenAI%3c/title%3e%3cpath%20d='M21.55%2010.004a5.416%205.416%200%2000-.478-4.501c-1.217-2.09-3.662-3.166-6.05-2.66A5.59%205.59%200%200010.831%201C8.39.995%206.224%202.546%205.473%204.838A5.553%205.553%200%20001.76%207.496a5.487%205.487%200%2000.691%206.5%205.416%205.416%200%2000.477%204.502c1.217%202.09%203.662%203.165%206.05%202.66A5.586%205.586%200%200013.168%2023c2.443.006%204.61-1.546%205.361-3.84a5.553%205.553%200%20003.715-2.66%205.488%205.488%200%2000-.693-6.497v.001zm-8.381%2011.558a4.199%204.199%200%2001-2.675-.954c.034-.018.093-.05.132-.074l4.44-2.53a.71.71%200%2000.364-.623v-6.176l1.877%201.069c.02.01.033.029.036.05v5.115c-.003%202.274-1.87%204.118-4.174%204.123zM4.192%2017.78a4.059%204.059%200%2001-.498-2.763c.032.02.09.055.131.078l4.44%202.53c.225.13.504.13.73%200l5.42-3.088v2.138a.068.068%200%2001-.027.057L9.9%2019.288c-1.999%201.136-4.552.46-5.707-1.51h-.001zM3.023%208.216A4.15%204.15%200%20015.198%206.41l-.002.151v5.06a.711.711%200%2000.364.624l5.42%203.087-1.876%201.07a.067.067%200%2001-.063.005l-4.489-2.559c-1.995-1.14-2.679-3.658-1.53-5.63h.001zm15.417%203.54l-5.42-3.088L14.896%207.6a.067.067%200%2001.063-.006l4.489%202.557c1.998%201.14%202.683%203.662%201.529%205.633a4.163%204.163%200%2001-2.174%201.807V12.38a.71.71%200%2000-.363-.623zm1.867-2.773a6.04%206.04%200%2000-.132-.078l-4.44-2.53a.731.731%200%2000-.729%200l-5.42%203.088V7.325a.068.068%200%2001.027-.057L14.1%204.713c2-1.137%204.555-.46%205.707%201.513.487.833.664%201.809.499%202.757h.001zm-11.741%203.81l-1.877-1.068a.065.065%200%2001-.036-.051V6.559c.001-2.277%201.873-4.122%204.181-4.12.976%200%201.92.338%202.671.954-.034.018-.092.05-.131.073l-4.44%202.53a.71.71%200%2000-.365.623l-.003%206.173v.002zm1.02-2.168L12%209.25l2.414%201.375v2.75L12%2014.75l-2.415-1.375v-2.75z'%3e%3c/path%3e%3c/svg%3e",EO=()=>({apiKey:"",prefix:"",baseUrl:"",proxyUrl:"",headers:[],models:[],excludedModels:[],modelEntries:[{name:"",alias:""}],excludedText:""});function pK({isOpen:i,editIndex:e,initialData:t,onClose:n,onSave:s,isSaving:a}){var d,h,p;const{t:r}=rt(),[o,c]=N.useState(EO);return N.useEffect(()=>{if(i){if(t){c(ee(z({},t),{headers:cf(t.headers),modelEntries:O0(t.models),excludedText:c2(t.excludedModels)}));return}c(EO())}},[t,i]),g.jsxs(zn,{open:i,onClose:n,title:r(e!==null?"ai_providers.codex_edit_modal_title":"ai_providers.codex_add_modal_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:n,disabled:a,children:r("common.cancel")}),g.jsx(ye,{onClick:()=>void s(o,e),loading:a,children:r("common.save")})]}),children:[g.jsx(et,{label:r("ai_providers.codex_add_modal_key_label"),value:o.apiKey,onChange:_=>c(y=>ee(z({},y),{apiKey:_.target.value}))}),g.jsx(et,{label:r("ai_providers.prefix_label"),placeholder:r("ai_providers.prefix_placeholder"),value:(d=o.prefix)!=null?d:"",onChange:_=>c(y=>ee(z({},y),{prefix:_.target.value})),hint:r("ai_providers.prefix_hint")}),g.jsx(et,{label:r("ai_providers.codex_add_modal_url_label"),value:(h=o.baseUrl)!=null?h:"",onChange:_=>c(y=>ee(z({},y),{baseUrl:_.target.value}))}),g.jsx(et,{label:r("ai_providers.codex_add_modal_proxy_label"),value:(p=o.proxyUrl)!=null?p:"",onChange:_=>c(y=>ee(z({},y),{proxyUrl:_.target.value}))}),g.jsx(_f,{entries:o.headers,onChange:_=>c(y=>ee(z({},y),{headers:_})),addLabel:r("common.custom_headers_add"),keyPlaceholder:r("common.custom_headers_key_placeholder"),valuePlaceholder:r("common.custom_headers_value_placeholder")}),g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:r("ai_providers.excluded_models_label")}),g.jsx("textarea",{className:"input",placeholder:r("ai_providers.excluded_models_placeholder"),value:o.excludedText,onChange:_=>c(y=>ee(z({},y),{excludedText:_.target.value})),rows:4}),g.jsx("div",{className:"hint",children:r("ai_providers.excluded_models_hint")})]})]})}function mK({configs:i,keyStats:e,usageDetails:t,loading:n,disableControls:s,isSaving:a,isSwitching:r,resolvedTheme:o,isModalOpen:c,modalIndex:d,onAdd:h,onEdit:p,onDelete:_,onToggle:y,onCloseModal:x,onSave:v}){const{t:w}=rt(),k=s||a||r,M=s||n||a||r,O=N.useMemo(()=>{const C=new Map,P=new Set;return i.forEach(R=>R.apiKey&&P.add(R.apiKey)),P.forEach(R=>{C.set(R,qs(t,R))}),C},[i,t]),A=d!==null?i[d]:void 0;return g.jsxs(g.Fragment,{children:[g.jsx(vt,{title:g.jsxs("span",{className:Z.cardTitle,children:[g.jsx("img",{src:o==="dark"?d2:u2,alt:"",className:Z.cardTitleIcon}),w("ai_providers.codex_title")]}),extra:g.jsx(ye,{size:"sm",onClick:h,disabled:k,children:w("ai_providers.codex_add_button")}),children:g.jsx(mf,{items:i,loading:n,keyField:C=>C.apiKey,emptyTitle:w("ai_providers.codex_empty_title"),emptyDescription:w("ai_providers.codex_empty_desc"),onEdit:p,onDelete:_,actionsDisabled:k,getRowDisabled:C=>pr(C.excludedModels),renderExtraActions:(C,P)=>g.jsx(Sn,{label:w("ai_providers.config_toggle_label"),checked:!pr(C.excludedModels),disabled:M,onChange:R=>void y(P,R)}),renderContent:C=>{var q;const P=pf(C.apiKey,e,pn),R=Object.entries(C.headers||{}),E=pr(C.excludedModels),L=(q=C.excludedModels)!=null?q:[],D=O.get(C.apiKey)||qs([],C.apiKey);return g.jsxs(N.Fragment,{children:[g.jsx("div",{className:"item-title",children:w("ai_providers.codex_item_title")}),g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[w("common.api_key"),":"]}),g.jsx("span",{className:Z.fieldValue,children:pn(C.apiKey)})]}),C.prefix&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[w("common.prefix"),":"]}),g.jsx("span",{className:Z.fieldValue,children:C.prefix})]}),C.baseUrl&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[w("common.base_url"),":"]}),g.jsx("span",{className:Z.fieldValue,children:C.baseUrl})]}),C.proxyUrl&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[w("common.proxy_url"),":"]}),g.jsx("span",{className:Z.fieldValue,children:C.proxyUrl})]}),R.length>0&&g.jsx("div",{className:Z.headerBadgeList,children:R.map(([B,H])=>g.jsxs("span",{className:Z.headerBadge,children:[g.jsxs("strong",{children:[B,":"]})," ",H]},B))}),E&&g.jsx("div",{className:"status-badge warning",style:{marginTop:8,marginBottom:0},children:w("ai_providers.config_disabled_badge")}),L.length?g.jsxs("div",{className:Z.excludedModelsSection,children:[g.jsx("div",{className:Z.excludedModelsLabel,children:w("ai_providers.excluded_models_count",{count:L.length})}),g.jsx("div",{className:Z.modelTagList,children:L.map(B=>g.jsx("span",{className:`${Z.modelTag} ${Z.excludedModelTag}`,children:g.jsx("span",{className:Z.modelName,children:B})},B))})]}):null,g.jsxs("div",{className:Z.cardStats,children:[g.jsxs("span",{className:`${Z.statPill} ${Z.statSuccess}`,children:[w("stats.success"),": ",P.success]}),g.jsxs("span",{className:`${Z.statPill} ${Z.statFailure}`,children:[w("stats.failure"),": ",P.failure]})]}),g.jsx(gf,{statusData:D})]})}})}),g.jsx(pK,{isOpen:c,editIndex:d,initialData:A,onClose:x,onSave:v,isSaving:a})]})}const VP="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eGemini%3c/title%3e%3cpath%20d='M20.616%2010.835a14.147%2014.147%200%2001-4.45-3.001%2014.111%2014.111%200%2001-3.678-6.452.503.503%200%2000-.975%200%2014.134%2014.134%200%2001-3.679%206.452%2014.155%2014.155%200%2001-4.45%203.001c-.65.28-1.318.505-2.002.678a.502.502%200%20000%20.975c.684.172%201.35.397%202.002.677a14.147%2014.147%200%20014.45%203.001%2014.112%2014.112%200%20013.679%206.453.502.502%200%2000.975%200c.172-.685.397-1.351.677-2.003a14.145%2014.145%200%20013.001-4.45%2014.113%2014.113%200%20016.453-3.678.503.503%200%20000-.975%2013.245%2013.245%200%2001-2.003-.678z'%20fill='%233186FF'%3e%3c/path%3e%3cpath%20d='M20.616%2010.835a14.147%2014.147%200%2001-4.45-3.001%2014.111%2014.111%200%2001-3.678-6.452.503.503%200%2000-.975%200%2014.134%2014.134%200%2001-3.679%206.452%2014.155%2014.155%200%2001-4.45%203.001c-.65.28-1.318.505-2.002.678a.502.502%200%20000%20.975c.684.172%201.35.397%202.002.677a14.147%2014.147%200%20014.45%203.001%2014.112%2014.112%200%20013.679%206.453.502.502%200%2000.975%200c.172-.685.397-1.351.677-2.003a14.145%2014.145%200%20013.001-4.45%2014.113%2014.113%200%20016.453-3.678.503.503%200%20000-.975%2013.245%2013.245%200%2001-2.003-.678z'%20fill='url(%23lobe-icons-gemini-fill-0)'%3e%3c/path%3e%3cpath%20d='M20.616%2010.835a14.147%2014.147%200%2001-4.45-3.001%2014.111%2014.111%200%2001-3.678-6.452.503.503%200%2000-.975%200%2014.134%2014.134%200%2001-3.679%206.452%2014.155%2014.155%200%2001-4.45%203.001c-.65.28-1.318.505-2.002.678a.502.502%200%20000%20.975c.684.172%201.35.397%202.002.677a14.147%2014.147%200%20014.45%203.001%2014.112%2014.112%200%20013.679%206.453.502.502%200%2000.975%200c.172-.685.397-1.351.677-2.003a14.145%2014.145%200%20013.001-4.45%2014.113%2014.113%200%20016.453-3.678.503.503%200%20000-.975%2013.245%2013.245%200%2001-2.003-.678z'%20fill='url(%23lobe-icons-gemini-fill-1)'%3e%3c/path%3e%3cpath%20d='M20.616%2010.835a14.147%2014.147%200%2001-4.45-3.001%2014.111%2014.111%200%2001-3.678-6.452.503.503%200%2000-.975%200%2014.134%2014.134%200%2001-3.679%206.452%2014.155%2014.155%200%2001-4.45%203.001c-.65.28-1.318.505-2.002.678a.502.502%200%20000%20.975c.684.172%201.35.397%202.002.677a14.147%2014.147%200%20014.45%203.001%2014.112%2014.112%200%20013.679%206.453.502.502%200%2000.975%200c.172-.685.397-1.351.677-2.003a14.145%2014.145%200%20013.001-4.45%2014.113%2014.113%200%20016.453-3.678.503.503%200%20000-.975%2013.245%2013.245%200%2001-2.003-.678z'%20fill='url(%23lobe-icons-gemini-fill-2)'%3e%3c/path%3e%3cdefs%3e%3clinearGradient%20gradientUnits='userSpaceOnUse'%20id='lobe-icons-gemini-fill-0'%20x1='7'%20x2='11'%20y1='15.5'%20y2='12'%3e%3cstop%20stop-color='%2308B962'%3e%3c/stop%3e%3cstop%20offset='1'%20stop-color='%2308B962'%20stop-opacity='0'%3e%3c/stop%3e%3c/linearGradient%3e%3clinearGradient%20gradientUnits='userSpaceOnUse'%20id='lobe-icons-gemini-fill-1'%20x1='8'%20x2='11.5'%20y1='5.5'%20y2='11'%3e%3cstop%20stop-color='%23F94543'%3e%3c/stop%3e%3cstop%20offset='1'%20stop-color='%23F94543'%20stop-opacity='0'%3e%3c/stop%3e%3c/linearGradient%3e%3clinearGradient%20gradientUnits='userSpaceOnUse'%20id='lobe-icons-gemini-fill-2'%20x1='3.5'%20x2='17.5'%20y1='13.5'%20y2='12'%3e%3cstop%20stop-color='%23FABC12'%3e%3c/stop%3e%3cstop%20offset='.46'%20stop-color='%23FABC12'%20stop-opacity='0'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",DO=()=>({apiKey:"",prefix:"",baseUrl:"",headers:[],excludedModels:[],excludedText:""});function gK({isOpen:i,editIndex:e,initialData:t,onClose:n,onSave:s,isSaving:a}){var h,p;const{t:r}=rt(),[o,c]=N.useState(DO);N.useEffect(()=>{if(i){if(t){c(ee(z({},t),{headers:cf(t.headers),excludedText:c2(t.excludedModels)}));return}c(DO())}},[t,i]);const d=()=>{s(o,e)};return g.jsxs(zn,{open:i,onClose:n,title:r(e!==null?"ai_providers.gemini_edit_modal_title":"ai_providers.gemini_add_modal_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:n,disabled:a,children:r("common.cancel")}),g.jsx(ye,{onClick:d,loading:a,children:r("common.save")})]}),children:[g.jsx(et,{label:r("ai_providers.gemini_add_modal_key_label"),placeholder:r("ai_providers.gemini_add_modal_key_placeholder"),value:o.apiKey,onChange:_=>c(y=>ee(z({},y),{apiKey:_.target.value}))}),g.jsx(et,{label:r("ai_providers.prefix_label"),placeholder:r("ai_providers.prefix_placeholder"),value:(h=o.prefix)!=null?h:"",onChange:_=>c(y=>ee(z({},y),{prefix:_.target.value})),hint:r("ai_providers.prefix_hint")}),g.jsx(et,{label:r("ai_providers.gemini_base_url_label"),placeholder:r("ai_providers.gemini_base_url_placeholder"),value:(p=o.baseUrl)!=null?p:"",onChange:_=>c(y=>ee(z({},y),{baseUrl:_.target.value}))}),g.jsx(_f,{entries:o.headers,onChange:_=>c(y=>ee(z({},y),{headers:_})),addLabel:r("common.custom_headers_add"),keyPlaceholder:r("common.custom_headers_key_placeholder"),valuePlaceholder:r("common.custom_headers_value_placeholder")}),g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:r("ai_providers.excluded_models_label")}),g.jsx("textarea",{className:"input",placeholder:r("ai_providers.excluded_models_placeholder"),value:o.excludedText,onChange:_=>c(y=>ee(z({},y),{excludedText:_.target.value})),rows:4}),g.jsx("div",{className:"hint",children:r("ai_providers.excluded_models_hint")})]})]})}function _K({configs:i,keyStats:e,usageDetails:t,loading:n,disableControls:s,isSaving:a,isSwitching:r,isModalOpen:o,modalIndex:c,onAdd:d,onEdit:h,onDelete:p,onToggle:_,onCloseModal:y,onSave:x}){const{t:v}=rt(),w=s||a||r,k=s||n||a||r,M=N.useMemo(()=>{const A=new Map,C=new Set;return i.forEach(P=>P.apiKey&&C.add(P.apiKey)),C.forEach(P=>{A.set(P,qs(t,P))}),A},[i,t]),O=c!==null?i[c]:void 0;return g.jsxs(g.Fragment,{children:[g.jsx(vt,{title:g.jsxs("span",{className:Z.cardTitle,children:[g.jsx("img",{src:VP,alt:"",className:Z.cardTitleIcon}),v("ai_providers.gemini_title")]}),extra:g.jsx(ye,{size:"sm",onClick:d,disabled:w,children:v("ai_providers.gemini_add_button")}),children:g.jsx(mf,{items:i,loading:n,keyField:A=>A.apiKey,emptyTitle:v("ai_providers.gemini_empty_title"),emptyDescription:v("ai_providers.gemini_empty_desc"),onEdit:h,onDelete:p,actionsDisabled:w,getRowDisabled:A=>pr(A.excludedModels),renderExtraActions:(A,C)=>g.jsx(Sn,{label:v("ai_providers.config_toggle_label"),checked:!pr(A.excludedModels),disabled:k,onChange:P=>void _(C,P)}),renderContent:(A,C)=>{var q;const P=pf(A.apiKey,e,pn),R=Object.entries(A.headers||{}),E=pr(A.excludedModels),L=(q=A.excludedModels)!=null?q:[],D=M.get(A.apiKey)||qs([],A.apiKey);return g.jsxs(N.Fragment,{children:[g.jsxs("div",{className:"item-title",children:[v("ai_providers.gemini_item_title")," #",C+1]}),g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[v("common.api_key"),":"]}),g.jsx("span",{className:Z.fieldValue,children:pn(A.apiKey)})]}),A.prefix&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[v("common.prefix"),":"]}),g.jsx("span",{className:Z.fieldValue,children:A.prefix})]}),A.baseUrl&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[v("common.base_url"),":"]}),g.jsx("span",{className:Z.fieldValue,children:A.baseUrl})]}),R.length>0&&g.jsx("div",{className:Z.headerBadgeList,children:R.map(([B,H])=>g.jsxs("span",{className:Z.headerBadge,children:[g.jsxs("strong",{children:[B,":"]})," ",H]},B))}),E&&g.jsx("div",{className:"status-badge warning",style:{marginTop:8,marginBottom:0},children:v("ai_providers.config_disabled_badge")}),L.length?g.jsxs("div",{className:Z.excludedModelsSection,children:[g.jsx("div",{className:Z.excludedModelsLabel,children:v("ai_providers.excluded_models_count",{count:L.length})}),g.jsx("div",{className:Z.modelTagList,children:L.map(B=>g.jsx("span",{className:`${Z.modelTag} ${Z.excludedModelTag}`,children:g.jsx("span",{className:Z.modelName,children:B})},B))})]}):null,g.jsxs("div",{className:Z.cardStats,children:[g.jsxs("span",{className:`${Z.statPill} ${Z.statSuccess}`,children:[v("stats.success"),": ",P.success]}),g.jsxs("span",{className:`${Z.statPill} ${Z.statFailure}`,children:[v("stats.failure"),": ",P.failure]})]}),g.jsx(gf,{statusData:D})]})}})}),g.jsx(gK,{isOpen:o,editIndex:c,initialData:O,onClose:y,onSave:x,isSaving:a})]})}function yK({isOpen:i,baseUrl:e,headers:t,apiKeyEntries:n,onClose:s,onApply:a}){const{t:r}=rt(),[o,c]=N.useState(""),[d,h]=N.useState([]),[p,_]=N.useState(!1),[y,x]=N.useState(""),[v,w]=N.useState(""),[k,M]=N.useState(new Set),O=E=>E instanceof Error?E.message:typeof E=="string"?E:"",A=N.useMemo(()=>{const E=v.trim().toLowerCase();return E?d.filter(L=>{const D=(L.name||"").toLowerCase(),q=(L.alias||"").toLowerCase(),B=(L.description||"").toLowerCase();return D.includes(E)||q.includes(E)||B.includes(E)}):d},[d,v]),C=N.useCallback((...L)=>pe(null,[...L],function*({allowFallback:E=!0}={}){var q,B;const D=e.trim();if(D){_(!0),x("");try{const H=gl(t),W=(B=(q=n.find(G=>{var $;return($=G.apiKey)==null?void 0:$.trim()}))==null?void 0:q.apiKey)==null?void 0:B.trim(),V=!!(H.Authorization||H.authorization),U=yield Wx.fetchModelsViaApiCall(D,V?void 0:W,H);h(U)}catch(H){if(E)try{const W=yield Wx.fetchModelsViaApiCall(D);h(W);return}catch(W){const V=O(W)||O(H);h([]),x(`${r("ai_providers.openai_models_fetch_error")}: ${V}`)}else h([]),x(`${r("ai_providers.openai_models_fetch_error")}: ${O(H)}`)}finally{_(!1)}}}),[n,e,t,r]);N.useEffect(()=>{i&&(c(aK(e)),h([]),w(""),M(new Set),x(""),C())},[e,C,i]);const P=E=>{M(L=>{const D=new Set(L);return D.has(E)?D.delete(E):D.add(E),D})},R=()=>{const E=d.filter(L=>k.has(L.name));a(E)};return g.jsxs(zn,{open:i,onClose:s,title:r("ai_providers.openai_models_fetch_title"),width:720,footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:s,disabled:p,children:r("ai_providers.openai_models_fetch_back")}),g.jsx(ye,{onClick:R,disabled:p,children:r("ai_providers.openai_models_fetch_apply")})]}),children:[g.jsx("div",{className:"hint",style:{marginBottom:8},children:r("ai_providers.openai_models_fetch_hint")}),g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:r("ai_providers.openai_models_fetch_url_label")}),g.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[g.jsx("input",{className:"input",readOnly:!0,value:o}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>void C({allowFallback:!0}),loading:p,children:r("ai_providers.openai_models_fetch_refresh")})]})]}),g.jsx(et,{label:r("ai_providers.openai_models_search_label"),placeholder:r("ai_providers.openai_models_search_placeholder"),value:v,onChange:E=>w(E.target.value)}),y&&g.jsx("div",{className:"error-box",children:y}),p?g.jsx("div",{className:"hint",children:r("ai_providers.openai_models_fetch_loading")}):d.length===0?g.jsx("div",{className:"hint",children:r("ai_providers.openai_models_fetch_empty")}):A.length===0?g.jsx("div",{className:"hint",children:r("ai_providers.openai_models_search_empty")}):g.jsx("div",{className:Z.modelDiscoveryList,children:A.map(E=>{const L=k.has(E.name);return g.jsxs("label",{className:`${Z.modelDiscoveryRow} ${L?Z.modelDiscoveryRowSelected:""}`,children:[g.jsx("input",{type:"checkbox",checked:L,onChange:()=>P(E.name)}),g.jsxs("div",{className:Z.modelDiscoveryMeta,children:[g.jsxs("div",{className:Z.modelDiscoveryName,children:[E.name,E.alias&&g.jsx("span",{className:Z.modelDiscoveryAlias,children:E.alias})]}),E.description&&g.jsx("div",{className:Z.modelDiscoveryDesc,children:E.description})]})]},E.name)})})]})}const UO=3e4,FO=()=>({name:"",prefix:"",baseUrl:"",headers:[],apiKeyEntries:[Id()],modelEntries:[{name:"",alias:""}],testModel:void 0});function xK({isOpen:i,editIndex:e,initialData:t,onClose:n,onSave:s,isSaving:a}){var E;const{t:r}=rt(),{showNotification:o}=Zn(),[c,d]=N.useState(FO),[h,p]=N.useState(!1),[_,y]=N.useState(""),[x,v]=N.useState("idle"),[w,k]=N.useState(""),M=L=>L instanceof Error?L.message:typeof L=="string"?L:"",O=N.useMemo(()=>c.modelEntries.map(L=>L.name.trim()).filter(Boolean),[c.modelEntries]);N.useEffect(()=>{var L,D;if(!i){p(!1);return}if(t){const q=O0(t.models);d({name:t.name,prefix:(L=t.prefix)!=null?L:"",baseUrl:t.baseUrl,headers:cf(t.headers),testModel:t.testModel,modelEntries:q,apiKeyEntries:(D=t.apiKeyEntries)!=null&&D.length?t.apiKeyEntries:[Id()]});const B=q.map(W=>W.name.trim()).filter(Boolean),H=t.testModel&&B.includes(t.testModel)?t.testModel:B[0]||"";y(H)}else d(FO()),y("");v("idle"),k(""),p(!1)},[t,i]),N.useEffect(()=>{if(i){if(O.length===0){_&&(y(""),v("idle"),k(""));return}(!_||!O.includes(_))&&(y(O[0]),v("idle"),k(""))}},[O,i,_]);const A=L=>{const D=L.length?L:[Id()],q=(W,V,U)=>{const G=D.map(($,ie)=>ie===W?ee(z({},$),{[V]:U}):$);d($=>ee(z({},$),{apiKeyEntries:G}))},B=W=>{const V=D.filter((U,G)=>G!==W);d(U=>ee(z({},U),{apiKeyEntries:V.length?V:[Id()]}))},H=()=>{d(W=>ee(z({},W),{apiKeyEntries:[...D,Id()]}))};return g.jsxs("div",{className:"stack",children:[D.map((W,V)=>{var U;return g.jsxs("div",{className:"item-row",children:[g.jsxs("div",{className:"item-meta",children:[g.jsx(et,{label:`${r("common.api_key")} #${V+1}`,value:W.apiKey,onChange:G=>q(V,"apiKey",G.target.value)}),g.jsx(et,{label:r("common.proxy_url"),value:(U=W.proxyUrl)!=null?U:"",onChange:G=>q(V,"proxyUrl",G.target.value)})]}),g.jsx("div",{className:"item-actions",children:g.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>B(V),disabled:D.length<=1||a,children:r("common.delete")})})]},V)}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:H,disabled:a,children:r("ai_providers.openai_keys_add_btn")})]})},C=()=>{if(!c.baseUrl.trim()){o(r("ai_providers.openai_models_fetch_invalid_url"),"error");return}p(!0)},P=L=>{if(!L.length){p(!1);return}const D=new Map;c.modelEntries.forEach(H=>{var V;const W=H.name.trim();W&&D.set(W,{name:W,alias:((V=H.alias)==null?void 0:V.trim())||""})});let q=0;L.forEach(H=>{var V;const W=H.name.trim();!W||D.has(W)||(D.set(W,{name:W,alias:(V=H.alias)!=null?V:""}),q+=1)});const B=Array.from(D.values());d(H=>ee(z({},H),{modelEntries:B.length?B:[{name:"",alias:""}]})),p(!1),q>0&&o(r("ai_providers.openai_models_fetch_added",{count:q}),"success")},R=()=>pe(null,null,function*(){const L=c.baseUrl.trim();if(!L){const V=r("notification.openai_test_url_required");v("error"),k(V),o(V,"error");return}const D=rK(L);if(!D){const V=r("notification.openai_test_url_required");v("error"),k(V),o(V,"error");return}const q=c.apiKeyEntries.find(V=>{var U;return(U=V.apiKey)==null?void 0:U.trim()});if(!q){const V=r("notification.openai_test_key_required");v("error"),k(V),o(V,"error");return}const B=_.trim()||O[0]||"";if(!B){const V=r("notification.openai_test_model_required");v("error"),k(V),o(V,"error");return}const H=gl(c.headers),W=z({"Content-Type":"application/json"},H);!W.Authorization&&!W.authorization&&(W.Authorization=`Bearer ${q.apiKey.trim()}`),v("loading"),k(r("ai_providers.openai_test_running"));try{const V=yield df.request({method:"POST",url:D,header:Object.keys(W).length?W:void 0,data:JSON.stringify({model:B,messages:[{role:"user",content:"Hi"}],stream:!1,max_tokens:5})},{timeout:UO});if(V.statusCode<200||V.statusCode>=300)throw new Error(uf(V));v("success"),k(r("ai_providers.openai_test_success"))}catch(V){v("error");const U=M(V),$=(typeof V=="object"&&V!==null&&"code"in V?String(V.code):"")==="ECONNABORTED"||U.toLowerCase().includes("timeout");k($?r("ai_providers.openai_test_timeout",{seconds:UO/1e3}):`${r("ai_providers.openai_test_failed")}: ${U}`)}});return g.jsxs(g.Fragment,{children:[g.jsxs(zn,{open:i,onClose:n,title:r(e!==null?"ai_providers.openai_edit_modal_title":"ai_providers.openai_add_modal_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:n,disabled:a,children:r("common.cancel")}),g.jsx(ye,{onClick:()=>void s(c,e),loading:a,children:r("common.save")})]}),children:[g.jsx(et,{label:r("ai_providers.openai_add_modal_name_label"),value:c.name,onChange:L=>d(D=>ee(z({},D),{name:L.target.value}))}),g.jsx(et,{label:r("ai_providers.prefix_label"),placeholder:r("ai_providers.prefix_placeholder"),value:(E=c.prefix)!=null?E:"",onChange:L=>d(D=>ee(z({},D),{prefix:L.target.value})),hint:r("ai_providers.prefix_hint")}),g.jsx(et,{label:r("ai_providers.openai_add_modal_url_label"),value:c.baseUrl,onChange:L=>d(D=>ee(z({},D),{baseUrl:L.target.value}))}),g.jsx(_f,{entries:c.headers,onChange:L=>d(D=>ee(z({},D),{headers:L})),addLabel:r("common.custom_headers_add"),keyPlaceholder:r("common.custom_headers_key_placeholder"),valuePlaceholder:r("common.custom_headers_value_placeholder")}),g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:r(e!==null?"ai_providers.openai_edit_modal_models_label":"ai_providers.openai_add_modal_models_label")}),g.jsx("div",{className:"hint",children:r("ai_providers.openai_models_hint")}),g.jsx(T0,{entries:c.modelEntries,onChange:L=>d(D=>ee(z({},D),{modelEntries:L})),addLabel:r("ai_providers.openai_models_add_btn"),namePlaceholder:r("common.model_name_placeholder"),aliasPlaceholder:r("common.model_alias_placeholder"),disabled:a}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:C,disabled:a,children:r("ai_providers.openai_models_fetch_button")})]}),g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:r("ai_providers.openai_test_title")}),g.jsx("div",{className:"hint",children:r("ai_providers.openai_test_hint")}),g.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[g.jsxs("select",{className:`input ${Z.openaiTestSelect}`,value:_,onChange:L=>{y(L.target.value),v("idle"),k("")},disabled:a||O.length===0,children:[g.jsx("option",{value:"",children:O.length?r("ai_providers.openai_test_select_placeholder"):r("ai_providers.openai_test_select_empty")}),c.modelEntries.filter(L=>L.name.trim()).map((L,D)=>{const q=L.name.trim(),B=L.alias.trim(),H=B&&B!==q?`${q} (${B})`:q;return g.jsx("option",{value:q,children:H},`${q}-${D}`)})]}),g.jsx(ye,{variant:x==="error"?"danger":"secondary",className:`${Z.openaiTestButton} ${x==="success"?Z.openaiTestButtonSuccess:""}`,onClick:R,loading:x==="loading",disabled:a||O.length===0,children:r("ai_providers.openai_test_action")})]}),w&&g.jsx("div",{className:`status-badge ${x==="error"?"error":x==="success"?"success":"muted"}`,children:w})]}),g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:r("ai_providers.openai_add_modal_keys_label")}),A(c.apiKeyEntries)]})]}),g.jsx(yK,{isOpen:h,baseUrl:c.baseUrl,headers:c.headers,apiKeyEntries:c.apiKeyEntries,onClose:()=>p(!1),onApply:P})]})}function bK({configs:i,keyStats:e,usageDetails:t,loading:n,disableControls:s,isSaving:a,isSwitching:r,resolvedTheme:o,isModalOpen:c,modalIndex:d,onAdd:h,onEdit:p,onDelete:_,onCloseModal:y,onSave:x}){const{t:v}=rt(),w=s||a||r,k=N.useMemo(()=>{const O=new Map;return i.forEach(A=>{const C=(A.apiKeyEntries||[]).map(R=>R.apiKey).filter(Boolean),P=t.filter(R=>C.includes(R.source));O.set(A.name,qs(P))}),O},[i,t]),M=d!==null?i[d]:void 0;return g.jsxs(g.Fragment,{children:[g.jsx(vt,{title:g.jsxs("span",{className:Z.cardTitle,children:[g.jsx("img",{src:o==="dark"?d2:u2,alt:"",className:Z.cardTitleIcon}),v("ai_providers.openai_title")]}),extra:g.jsx(ye,{size:"sm",onClick:h,disabled:w,children:v("ai_providers.openai_add_button")}),children:g.jsx(mf,{items:i,loading:n,keyField:O=>O.name,emptyTitle:v("ai_providers.openai_empty_title"),emptyDescription:v("ai_providers.openai_empty_desc"),onEdit:p,onDelete:_,actionsDisabled:w,renderContent:O=>{var E,L;const A=oK(O.apiKeyEntries,e,pn),C=Object.entries(O.headers||{}),P=O.apiKeyEntries||[],R=k.get(O.name)||qs([]);return g.jsxs(N.Fragment,{children:[g.jsx("div",{className:"item-title",children:O.name}),O.prefix&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[v("common.prefix"),":"]}),g.jsx("span",{className:Z.fieldValue,children:O.prefix})]}),g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[v("common.base_url"),":"]}),g.jsx("span",{className:Z.fieldValue,children:O.baseUrl})]}),C.length>0&&g.jsx("div",{className:Z.headerBadgeList,children:C.map(([D,q])=>g.jsxs("span",{className:Z.headerBadge,children:[g.jsxs("strong",{children:[D,":"]})," ",q]},D))}),P.length>0&&g.jsxs("div",{className:Z.apiKeyEntriesSection,children:[g.jsxs("div",{className:Z.apiKeyEntriesLabel,children:[v("ai_providers.openai_keys_count"),": ",P.length]}),g.jsx("div",{className:Z.apiKeyEntryList,children:P.map((D,q)=>{const B=pf(D.apiKey,e,pn);return g.jsxs("div",{className:Z.apiKeyEntryCard,children:[g.jsx("span",{className:Z.apiKeyEntryIndex,children:q+1}),g.jsx("span",{className:Z.apiKeyEntryKey,children:pn(D.apiKey)}),D.proxyUrl&&g.jsx("span",{className:Z.apiKeyEntryProxy,children:D.proxyUrl}),g.jsxs("div",{className:Z.apiKeyEntryStats,children:[g.jsxs("span",{className:`${Z.apiKeyEntryStat} ${Z.apiKeyEntryStatSuccess}`,children:[g.jsx(XU,{size:12})," ",B.success]}),g.jsxs("span",{className:`${Z.apiKeyEntryStat} ${Z.apiKeyEntryStatFailure}`,children:[g.jsx(Hl,{size:12})," ",B.failure]})]})]},q)})})]}),g.jsxs("div",{className:Z.fieldRow,style:{marginTop:"8px"},children:[g.jsxs("span",{className:Z.fieldLabel,children:[v("ai_providers.openai_models_count"),":"]}),g.jsx("span",{className:Z.fieldValue,children:((E=O.models)==null?void 0:E.length)||0})]}),(L=O.models)!=null&&L.length?g.jsx("div",{className:Z.modelTagList,children:O.models.map(D=>g.jsxs("span",{className:Z.modelTag,children:[g.jsx("span",{className:Z.modelName,children:D.name}),D.alias&&D.alias!==D.name&&g.jsx("span",{className:Z.modelAlias,children:D.alias})]},D.name))}):null,O.testModel&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsx("span",{className:Z.fieldLabel,children:"Test Model:"}),g.jsx("span",{className:Z.fieldValue,children:O.testModel})]}),g.jsxs("div",{className:Z.cardStats,children:[g.jsxs("span",{className:`${Z.statPill} ${Z.statSuccess}`,children:[v("stats.success"),": ",A.success]}),g.jsxs("span",{className:`${Z.statPill} ${Z.statFailure}`,children:[v("stats.failure"),": ",A.failure]})]}),g.jsx(gf,{statusData:R})]})}})}),g.jsx(xK,{isOpen:c,editIndex:d,initialData:M,onClose:y,onSave:x,isSaving:a})]})}const IP="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%20width='24px'%20height='24px'%3e%3cpath%20d='M20,13.89A.77.77,0,0,0,19,13.73l-7,5.14v.22a.72.72,0,1,1,0,1.43v0a.74.74,0,0,0,.45-.15l7.41-5.47A.76.76,0,0,0,20,13.89Z'%20style='fill:%23669df6'/%3e%3cpath%20d='M12,20.52a.72.72,0,0,1,0-1.43h0v-.22L5,13.73a.76.76,0,0,0-1,.16.74.74,0,0,0,.16,1l7.41,5.47a.73.73,0,0,0,.44.15v0Z'%20style='fill:%23aecbfa'/%3e%3cpath%20d='M12,18.34a1.47,1.47,0,1,0,1.47,1.47A1.47,1.47,0,0,0,12,18.34Zm0,2.18a.72.72,0,1,1,.72-.71A.71.71,0,0,1,12,20.52Z'%20style='fill:%234285f4'/%3e%3cpath%20d='M6,6.11a.76.76,0,0,1-.75-.75V3.48a.76.76,0,1,1,1.51,0V5.36A.76.76,0,0,1,6,6.11Z'%20style='fill:%23aecbfa'/%3e%3ccircle%20cx='5.98'%20cy='12'%20r='0.76'%20style='fill:%23aecbfa'/%3e%3ccircle%20cx='5.98'%20cy='9.79'%20r='0.76'%20style='fill:%23aecbfa'/%3e%3ccircle%20cx='5.98'%20cy='7.57'%20r='0.76'%20style='fill:%23aecbfa'/%3e%3cpath%20d='M18,8.31a.76.76,0,0,1-.75-.76V5.67a.75.75,0,1,1,1.5,0V7.55A.75.75,0,0,1,18,8.31Z'%20style='fill:%234285f4'/%3e%3ccircle%20cx='18.02'%20cy='12.01'%20r='0.76'%20style='fill:%234285f4'/%3e%3ccircle%20cx='18.02'%20cy='9.76'%20r='0.76'%20style='fill:%234285f4'/%3e%3ccircle%20cx='18.02'%20cy='3.48'%20r='0.76'%20style='fill:%234285f4'/%3e%3cpath%20d='M12,15a.76.76,0,0,1-.75-.75V12.34a.76.76,0,0,1,1.51,0v1.89A.76.76,0,0,1,12,15Z'%20style='fill:%23669df6'/%3e%3ccircle%20cx='12'%20cy='16.45'%20r='0.76'%20style='fill:%23669df6'/%3e%3ccircle%20cx='12'%20cy='10.14'%20r='0.76'%20style='fill:%23669df6'/%3e%3ccircle%20cx='12'%20cy='7.92'%20r='0.76'%20style='fill:%23669df6'/%3e%3cpath%20d='M15,10.54a.76.76,0,0,1-.75-.75V7.91a.76.76,0,1,1,1.51,0V9.79A.76.76,0,0,1,15,10.54Z'%20style='fill:%234285f4'/%3e%3ccircle%20cx='15.01'%20cy='5.69'%20r='0.76'%20style='fill:%234285f4'/%3e%3ccircle%20cx='15.01'%20cy='14.19'%20r='0.76'%20style='fill:%234285f4'/%3e%3ccircle%20cx='15.01'%20cy='11.97'%20r='0.76'%20style='fill:%234285f4'/%3e%3ccircle%20cx='8.99'%20cy='14.19'%20r='0.76'%20style='fill:%23aecbfa'/%3e%3ccircle%20cx='8.99'%20cy='7.92'%20r='0.76'%20style='fill:%23aecbfa'/%3e%3ccircle%20cx='8.99'%20cy='5.69'%20r='0.76'%20style='fill:%23aecbfa'/%3e%3cpath%20d='M9,12.73A.76.76,0,0,1,8.24,12V10.1a.75.75,0,1,1,1.5,0V12A.75.75,0,0,1,9,12.73Z'%20style='fill:%23aecbfa'/%3e%3c/svg%3e",BO=()=>({apiKey:"",prefix:"",baseUrl:"",proxyUrl:"",headers:[],models:[],modelEntries:[{name:"",alias:""}]});function vK({isOpen:i,editIndex:e,initialData:t,onClose:n,onSave:s,isSaving:a}){var d,h,p;const{t:r}=rt(),[o,c]=N.useState(BO);return N.useEffect(()=>{if(i){if(t){c(ee(z({},t),{headers:cf(t.headers),modelEntries:O0(t.models)}));return}c(BO())}},[t,i]),g.jsxs(zn,{open:i,onClose:n,title:r(e!==null?"ai_providers.vertex_edit_modal_title":"ai_providers.vertex_add_modal_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:n,disabled:a,children:r("common.cancel")}),g.jsx(ye,{onClick:()=>void s(o,e),loading:a,children:r("common.save")})]}),children:[g.jsx(et,{label:r("ai_providers.vertex_add_modal_key_label"),placeholder:r("ai_providers.vertex_add_modal_key_placeholder"),value:o.apiKey,onChange:_=>c(y=>ee(z({},y),{apiKey:_.target.value}))}),g.jsx(et,{label:r("ai_providers.prefix_label"),placeholder:r("ai_providers.prefix_placeholder"),value:(d=o.prefix)!=null?d:"",onChange:_=>c(y=>ee(z({},y),{prefix:_.target.value})),hint:r("ai_providers.prefix_hint")}),g.jsx(et,{label:r("ai_providers.vertex_add_modal_url_label"),placeholder:r("ai_providers.vertex_add_modal_url_placeholder"),value:(h=o.baseUrl)!=null?h:"",onChange:_=>c(y=>ee(z({},y),{baseUrl:_.target.value}))}),g.jsx(et,{label:r("ai_providers.vertex_add_modal_proxy_label"),placeholder:r("ai_providers.vertex_add_modal_proxy_placeholder"),value:(p=o.proxyUrl)!=null?p:"",onChange:_=>c(y=>ee(z({},y),{proxyUrl:_.target.value}))}),g.jsx(_f,{entries:o.headers,onChange:_=>c(y=>ee(z({},y),{headers:_})),addLabel:r("common.custom_headers_add"),keyPlaceholder:r("common.custom_headers_key_placeholder"),valuePlaceholder:r("common.custom_headers_value_placeholder")}),g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:r("ai_providers.vertex_models_label")}),g.jsx(T0,{entries:o.modelEntries,onChange:_=>c(y=>ee(z({},y),{modelEntries:_})),addLabel:r("ai_providers.vertex_models_add_btn"),namePlaceholder:r("common.model_name_placeholder"),aliasPlaceholder:r("common.model_alias_placeholder"),disabled:a}),g.jsx("div",{className:"hint",children:r("ai_providers.vertex_models_hint")})]})]})}function SK({configs:i,keyStats:e,usageDetails:t,loading:n,disableControls:s,isSaving:a,isSwitching:r,isModalOpen:o,modalIndex:c,onAdd:d,onEdit:h,onDelete:p,onCloseModal:_,onSave:y}){const{t:x}=rt(),v=s||a||r,w=N.useMemo(()=>{const M=new Map,O=new Set;return i.forEach(A=>A.apiKey&&O.add(A.apiKey)),O.forEach(A=>{M.set(A,qs(t,A))}),M},[i,t]),k=c!==null?i[c]:void 0;return g.jsxs(g.Fragment,{children:[g.jsx(vt,{title:g.jsxs("span",{className:Z.cardTitle,children:[g.jsx("img",{src:IP,alt:"",className:Z.cardTitleIcon}),x("ai_providers.vertex_title")]}),extra:g.jsx(ye,{size:"sm",onClick:d,disabled:v,children:x("ai_providers.vertex_add_button")}),children:g.jsx(mf,{items:i,loading:n,keyField:M=>M.apiKey,emptyTitle:x("ai_providers.vertex_empty_title"),emptyDescription:x("ai_providers.vertex_empty_desc"),onEdit:h,onDelete:p,actionsDisabled:v,renderContent:(M,O)=>{var R;const A=pf(M.apiKey,e,pn),C=Object.entries(M.headers||{}),P=w.get(M.apiKey)||qs([],M.apiKey);return g.jsxs(N.Fragment,{children:[g.jsxs("div",{className:"item-title",children:[x("ai_providers.vertex_item_title")," #",O+1]}),g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[x("common.api_key"),":"]}),g.jsx("span",{className:Z.fieldValue,children:pn(M.apiKey)})]}),M.prefix&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[x("common.prefix"),":"]}),g.jsx("span",{className:Z.fieldValue,children:M.prefix})]}),M.baseUrl&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[x("common.base_url"),":"]}),g.jsx("span",{className:Z.fieldValue,children:M.baseUrl})]}),M.proxyUrl&&g.jsxs("div",{className:Z.fieldRow,children:[g.jsxs("span",{className:Z.fieldLabel,children:[x("common.proxy_url"),":"]}),g.jsx("span",{className:Z.fieldValue,children:M.proxyUrl})]}),C.length>0&&g.jsx("div",{className:Z.headerBadgeList,children:C.map(([E,L])=>g.jsxs("span",{className:Z.headerBadge,children:[g.jsxs("strong",{children:[E,":"]})," ",L]},E))}),(R=M.models)!=null&&R.length?g.jsxs("div",{className:Z.modelTagList,children:[g.jsxs("span",{className:Z.modelCountLabel,children:[x("ai_providers.vertex_models_count"),": ",M.models.length]}),M.models.map(E=>g.jsxs("span",{className:Z.modelTag,children:[g.jsx("span",{className:Z.modelName,children:E.name}),E.alias&&g.jsx("span",{className:Z.modelAlias,children:E.alias})]},`${E.name}-${E.alias||"default"}`))]}):null,g.jsxs("div",{className:Z.cardStats,children:[g.jsxs("span",{className:`${Z.statPill} ${Z.statSuccess}`,children:[x("stats.success"),": ",A.success]}),g.jsxs("span",{className:`${Z.statPill} ${Z.statFailure}`,children:[x("stats.failure"),": ",A.failure]})]}),g.jsx(gf,{statusData:P})]})}})}),g.jsx(vK,{isOpen:o,editIndex:c,initialData:k,onClose:_,onSave:y,isSaving:a})]})}function WP(i,e){const t=N.useRef(null);N.useEffect(()=>{t.current=i},[i]),N.useEffect(()=>{const s=setInterval(()=>{var a;(a=t.current)==null||a.call(t)},e);return()=>clearInterval(s)},[e])}const wK={bySource:{},byAuthIndex:{}},kK=()=>{const[i,e]=N.useState(wK),[t,n]=N.useState([]),[s,a]=N.useState(!1),r=N.useRef(!1),o=N.useCallback(()=>pe(null,null,function*(){var c;if(!r.current){r.current=!0,a(!0);try{const d=yield Ml.getUsage(),h=(c=d==null?void 0:d.usage)!=null?c:d,p=yield Ml.getKeyStats(h);e(p),n(Po(h))}catch(d){}finally{r.current=!1,a(!1)}}}),[]);return WP(o,24e4),{keyStats:i,usageDetails:t,loadKeyStats:o,isLoading:s}};function AK(){const{t:i}=rt(),{showNotification:e}=Zn(),t=_r(he=>he.resolvedTheme),n=Ct(he=>he.connectionStatus),s=Wt(he=>he.config),a=Wt(he=>he.fetchConfig),r=Wt(he=>he.updateConfigValue),o=Wt(he=>he.clearCache),[c,d]=N.useState(!0),[h,p]=N.useState(""),[_,y]=N.useState([]),[x,v]=N.useState([]),[w,k]=N.useState([]),[M,O]=N.useState([]),[A,C]=N.useState([]),[P,R]=N.useState(!1),[E,L]=N.useState(null),[D,q]=N.useState(null),[B,H]=N.useState(!1),W=n!=="connected",V=!!E,{keyStats:U,usageDetails:G,loadKeyStats:$}=kK(),ie=he=>he instanceof Error?he.message:typeof he=="string"?he:"",ue=N.useCallback(()=>pe(null,null,function*(){d(!0),p("");try{const[he,X,we]=yield Promise.allSettled([a(),qi.getVertexConfigs(),nr.getAmpcode()]);if(he.status!=="fulfilled")throw he.reason;const be=he.value;y((be==null?void 0:be.geminiApiKeys)||[]),v((be==null?void 0:be.codexApiKeys)||[]),k((be==null?void 0:be.claudeApiKeys)||[]),O((be==null?void 0:be.vertexApiKeys)||[]),C((be==null?void 0:be.openaiCompatibility)||[]),X.status==="fulfilled"&&(O(X.value||[]),r("vertex-api-key",X.value||[]),o("vertex-api-key")),we.status==="fulfilled"&&(r("ampcode",we.value),o("ampcode"))}catch(he){const X=ie(he)||i("notification.refresh_failed");p(X)}finally{d(!1)}}),[o,a,i,r]);N.useEffect(()=>{ue(),$()},[ue,$]),N.useEffect(()=>{s!=null&&s.geminiApiKeys&&y(s.geminiApiKeys),s!=null&&s.codexApiKeys&&v(s.codexApiKeys),s!=null&&s.claudeApiKeys&&k(s.claudeApiKeys),s!=null&&s.vertexApiKeys&&O(s.vertexApiKeys),s!=null&&s.openaiCompatibility&&C(s.openaiCompatibility)},[s==null?void 0:s.geminiApiKeys,s==null?void 0:s.codexApiKeys,s==null?void 0:s.claudeApiKeys,s==null?void 0:s.vertexApiKeys,s==null?void 0:s.openaiCompatibility]);const F=()=>{q(null)},Y=he=>{q({type:"gemini",index:he})},ce=(he,X)=>{q({type:he,index:X})},J=he=>{q({type:"vertex",index:he})},me=()=>{q({type:"ampcode",index:null})},Se=he=>{q({type:"openai",index:he})},Re=(he,X)=>pe(null,null,function*(){var we,be;R(!0);try{const je={apiKey:he.apiKey.trim(),prefix:((we=he.prefix)==null?void 0:we.trim())||void 0,baseUrl:((be=he.baseUrl)==null?void 0:be.trim())||void 0,headers:gl(he.headers),excludedModels:LO(he.excludedText)},Ve=X!==null?_.map((Mt,Nt)=>Nt===X?je:Mt):[..._,je];yield qi.saveGeminiKeys(Ve),y(Ve),r("gemini-api-key",Ve),o("gemini-api-key");const Tt=i(X!==null?"notification.gemini_key_updated":"notification.gemini_key_added");e(Tt,"success"),F()}catch(je){const Ve=ie(je);e(`${i("notification.update_failed")}: ${Ve}`,"error")}finally{R(!1)}}),He=he=>pe(null,null,function*(){const X=_[he];if(X&&window.confirm(i("ai_providers.gemini_delete_confirm")))try{yield qi.deleteGeminiKey(X.apiKey);const we=_.filter((be,je)=>je!==he);y(we),r("gemini-api-key",we),o("gemini-api-key"),e(i("notification.gemini_key_deleted"),"success")}catch(we){const be=ie(we);e(`${i("notification.delete_failed")}: ${be}`,"error")}}),Ke=(he,X,we)=>pe(null,null,function*(){if(he==="gemini"){const wt=_[X];if(!wt)return;const Bt=`${he}:${wt.apiKey}`;L(Bt);const pi=_,Wi=we?PO(wt.excludedModels):RO(wt.excludedModels),xs=ee(z({},wt),{excludedModels:Wi}),si=pi.map((bs,Jn)=>Jn===X?xs:bs);y(si),r("gemini-api-key",si),o("gemini-api-key");try{yield qi.saveGeminiKeys(si),e(i(we?"notification.config_enabled":"notification.config_disabled"),"success")}catch(bs){const Jn=ie(bs);y(pi),r("gemini-api-key",pi),o("gemini-api-key"),e(`${i("notification.update_failed")}: ${Jn}`,"error")}finally{L(null)}return}const be=he==="codex"?x:w,je=be[X];if(!je)return;const Ve=`${he}:${je.apiKey}`;L(Ve);const Tt=be,Mt=we?PO(je.excludedModels):RO(je.excludedModels),Nt=ee(z({},je),{excludedModels:Mt}),ni=Tt.map((wt,Bt)=>Bt===X?Nt:wt);he==="codex"?(v(ni),r("codex-api-key",ni),o("codex-api-key")):(k(ni),r("claude-api-key",ni),o("claude-api-key"));try{he==="codex"?yield qi.saveCodexConfigs(ni):yield qi.saveClaudeConfigs(ni),e(i(we?"notification.config_enabled":"notification.config_disabled"),"success")}catch(wt){const Bt=ie(wt);he==="codex"?(v(Tt),r("codex-api-key",Tt),o("codex-api-key")):(k(Tt),r("claude-api-key",Tt),o("claude-api-key")),e(`${i("notification.update_failed")}: ${Bt}`,"error")}finally{L(null)}}),it=(he,X,we)=>pe(null,null,function*(){var Ve,Tt,Mt;const je=((Ve=X.baseUrl)!=null?Ve:"").trim()||void 0;if(he==="codex"&&!je){e(i("notification.codex_base_url_required"),"error");return}R(!0);try{const Nt=he==="codex"?x:w,ni={apiKey:X.apiKey.trim(),prefix:((Tt=X.prefix)==null?void 0:Tt.trim())||void 0,baseUrl:je,proxyUrl:((Mt=X.proxyUrl)==null?void 0:Mt.trim())||void 0,headers:gl(X.headers),models:NO(X.modelEntries),excludedModels:LO(X.excludedText)},wt=we!==null?Nt.map((Bt,pi)=>pi===we?ni:Bt):[...Nt,ni];if(he==="codex"){yield qi.saveCodexConfigs(wt),v(wt),r("codex-api-key",wt),o("codex-api-key");const Bt=i(we!==null?"notification.codex_config_updated":"notification.codex_config_added");e(Bt,"success")}else{yield qi.saveClaudeConfigs(wt),k(wt),r("claude-api-key",wt),o("claude-api-key");const Bt=i(we!==null?"notification.claude_config_updated":"notification.claude_config_added");e(Bt,"success")}F()}catch(Nt){const ni=ie(Nt);e(`${i("notification.update_failed")}: ${ni}`,"error")}finally{R(!1)}}),fi=(he,X)=>pe(null,null,function*(){const be=(he==="codex"?x:w)[X];if(be&&window.confirm(i(`ai_providers.${he}_delete_confirm`)))try{if(he==="codex"){yield qi.deleteCodexConfig(be.apiKey);const je=x.filter((Ve,Tt)=>Tt!==X);v(je),r("codex-api-key",je),o("codex-api-key"),e(i("notification.codex_config_deleted"),"success")}else{yield qi.deleteClaudeConfig(be.apiKey);const je=w.filter((Ve,Tt)=>Tt!==X);k(je),r("claude-api-key",je),o("claude-api-key"),e(i("notification.claude_config_deleted"),"success")}}catch(je){const Ve=ie(je);e(`${i("notification.delete_failed")}: ${Ve}`,"error")}}),Pi=(he,X)=>pe(null,null,function*(){var je,Ve,Tt;const be=((je=he.baseUrl)!=null?je:"").trim()||void 0;if(!be){e(i("notification.vertex_base_url_required"),"error");return}R(!0);try{const Mt={apiKey:he.apiKey.trim(),prefix:((Ve=he.prefix)==null?void 0:Ve.trim())||void 0,baseUrl:be,proxyUrl:((Tt=he.proxyUrl)==null?void 0:Tt.trim())||void 0,headers:gl(he.headers),models:he.modelEntries.map(wt=>{const Bt=wt.name.trim(),pi=wt.alias.trim();return!Bt||!pi?null:{name:Bt,alias:pi}}).filter(Boolean)},Nt=X!==null?M.map((wt,Bt)=>Bt===X?Mt:wt):[...M,Mt];yield qi.saveVertexConfigs(Nt),O(Nt),r("vertex-api-key",Nt),o("vertex-api-key");const ni=i(X!==null?"notification.vertex_config_updated":"notification.vertex_config_added");e(ni,"success"),F()}catch(Mt){const Nt=ie(Mt);e(`${i("notification.update_failed")}: ${Nt}`,"error")}finally{R(!1)}}),ft=he=>pe(null,null,function*(){const X=M[he];if(X&&window.confirm(i("ai_providers.vertex_delete_confirm")))try{yield qi.deleteVertexConfig(X.apiKey);const we=M.filter((be,je)=>je!==he);O(we),r("vertex-api-key",we),o("vertex-api-key"),e(i("notification.vertex_config_deleted"),"success")}catch(we){const be=ie(we);e(`${i("notification.delete_failed")}: ${be}`,"error")}}),ii=(he,X)=>pe(null,null,function*(){var we;R(!0);try{const be={name:he.name.trim(),prefix:((we=he.prefix)==null?void 0:we.trim())||void 0,baseUrl:he.baseUrl.trim(),headers:gl(he.headers),apiKeyEntries:he.apiKeyEntries.map(Mt=>{var Nt;return{apiKey:Mt.apiKey.trim(),proxyUrl:((Nt=Mt.proxyUrl)==null?void 0:Nt.trim())||void 0,headers:Mt.headers}})};he.testModel&&(be.testModel=he.testModel.trim());const je=NO(he.modelEntries);je.length&&(be.models=je);const Ve=X!==null?A.map((Mt,Nt)=>Nt===X?be:Mt):[...A,be];yield qi.saveOpenAIProviders(Ve),C(Ve),r("openai-compatibility",Ve),o("openai-compatibility");const Tt=i(X!==null?"notification.openai_provider_updated":"notification.openai_provider_added");e(Tt,"success"),F()}catch(be){const je=ie(be);e(`${i("notification.update_failed")}: ${je}`,"error")}finally{R(!1)}}),Tn=he=>pe(null,null,function*(){const X=A[he];if(X&&window.confirm(i("ai_providers.openai_delete_confirm")))try{yield qi.deleteOpenAIProvider(X.name);const we=A.filter((be,je)=>je!==he);C(we),r("openai-compatibility",we),o("openai-compatibility"),e(i("notification.openai_provider_deleted"),"success")}catch(we){const be=ie(we);e(`${i("notification.delete_failed")}: ${be}`,"error")}}),Mn=(D==null?void 0:D.type)==="gemini"?D.index:null,aa=(D==null?void 0:D.type)==="codex"?D.index:null,vi=(D==null?void 0:D.type)==="claude"?D.index:null,Ee=(D==null?void 0:D.type)==="vertex"?D.index:null,_t=(D==null?void 0:D.type)==="openai"?D.index:null;return g.jsxs("div",{className:Z.container,children:[g.jsx("h1",{className:Z.pageTitle,children:i("ai_providers.title")}),g.jsxs("div",{className:Z.content,children:[h&&g.jsx("div",{className:"error-box",children:h}),g.jsx(_K,{configs:_,keyStats:U,usageDetails:G,loading:c,disableControls:W,isSaving:P,isSwitching:V,isModalOpen:(D==null?void 0:D.type)==="gemini",modalIndex:Mn,onAdd:()=>Y(null),onEdit:he=>Y(he),onDelete:He,onToggle:(he,X)=>void Ke("gemini",he,X),onCloseModal:F,onSave:Re}),g.jsx(mK,{configs:x,keyStats:U,usageDetails:G,loading:c,disableControls:W,isSaving:P,isSwitching:V,resolvedTheme:t,isModalOpen:(D==null?void 0:D.type)==="codex",modalIndex:aa,onAdd:()=>ce("codex",null),onEdit:he=>ce("codex",he),onDelete:he=>void fi("codex",he),onToggle:(he,X)=>void Ke("codex",he,X),onCloseModal:F,onSave:(he,X)=>it("codex",he,X)}),g.jsx(fK,{configs:w,keyStats:U,usageDetails:G,loading:c,disableControls:W,isSaving:P,isSwitching:V,isModalOpen:(D==null?void 0:D.type)==="claude",modalIndex:vi,onAdd:()=>ce("claude",null),onEdit:he=>ce("claude",he),onDelete:he=>void fi("claude",he),onToggle:(he,X)=>void Ke("claude",he,X),onCloseModal:F,onSave:(he,X)=>it("claude",he,X)}),g.jsx(SK,{configs:M,keyStats:U,usageDetails:G,loading:c,disableControls:W,isSaving:P,isSwitching:V,isModalOpen:(D==null?void 0:D.type)==="vertex",modalIndex:Ee,onAdd:()=>J(null),onEdit:he=>J(he),onDelete:ft,onCloseModal:F,onSave:Pi}),g.jsx(dK,{config:s==null?void 0:s.ampcode,loading:c,disableControls:W,isSaving:P,isSwitching:V,isBusy:B,isModalOpen:(D==null?void 0:D.type)==="ampcode",onOpen:me,onCloseModal:F,onBusyChange:H}),g.jsx(bK,{configs:A,keyStats:U,usageDetails:G,loading:c,disableControls:W,isSaving:P,isSwitching:V,resolvedTheme:t,isModalOpen:(D==null?void 0:D.type)==="openai",modalIndex:_t,onAdd:()=>Se(null),onEdit:he=>Se(he),onDelete:Tn,onCloseModal:F,onSave:ii})]})]})}let ah=null;const XP=()=>pe(null,null,function*(){ah&&(yield ah())}),M0=i=>{N.useEffect(()=>{if(i)return ah=i,()=>{ah===i&&(ah=null)}},[i])},CK="AuthFilesPage-module__container___u1c4k",OK="AuthFilesPage-module__pageHeader___DVV58",TK="AuthFilesPage-module__pageTitle___1TOZn",MK="AuthFilesPage-module__description___N3RjR",NK="AuthFilesPage-module__headerActions___j0ROO",RK="AuthFilesPage-module__titleWrapper___PLYyj",PK="AuthFilesPage-module__countBadge___DQWug",LK="AuthFilesPage-module__errorBox___A9vF2",jK="AuthFilesPage-module__filterSection___qQ3Zo",EK="AuthFilesPage-module__filterTags___A24A3",DK="AuthFilesPage-module__filterTag___-YnCU",UK="AuthFilesPage-module__filterTagActive___Rnbcs",FK="AuthFilesPage-module__filterControls___PfZDU",BK="AuthFilesPage-module__filterItem___Kko4o",zK="AuthFilesPage-module__pageSizeSelect___yEBvp",qK="AuthFilesPage-module__fileGrid___ajvi5",HK="AuthFilesPage-module__fileCard___j9Jtq",KK="AuthFilesPage-module__cardHeader___uJMtL",VK="AuthFilesPage-module__typeBadge___Dtm6A",IK="AuthFilesPage-module__fileName___DZ39s",WK="AuthFilesPage-module__cardMeta___H6kAQ",XK="AuthFilesPage-module__cardStats___JQ4ig",GK="AuthFilesPage-module__statPill___wFsBu",QK="AuthFilesPage-module__statSuccess___mh8iR",YK="AuthFilesPage-module__statFailure___ivDGu",ZK="AuthFilesPage-module__statusBar___n-3Gp",JK="AuthFilesPage-module__statusBlocks___DpQaY",$K="AuthFilesPage-module__statusBlock___RPMAs",eV="AuthFilesPage-module__statusBlockSuccess___PXcPO",tV="AuthFilesPage-module__statusBlockFailure___JRavf",iV="AuthFilesPage-module__statusBlockMixed___UKdLP",nV="AuthFilesPage-module__statusBlockIdle___6Uc0C",sV="AuthFilesPage-module__statusRate___LZm5e",aV="AuthFilesPage-module__statusRateHigh___seYyb",rV="AuthFilesPage-module__statusRateMedium___aNblo",oV="AuthFilesPage-module__statusRateLow___BxxBi",lV="AuthFilesPage-module__cardActions___mJgkW",cV="AuthFilesPage-module__iconButton___XT5TY",uV="AuthFilesPage-module__actionIcon___F2TRI",dV="AuthFilesPage-module__virtualBadge___s32vc",hV="AuthFilesPage-module__pagination___Hwpg2",fV="AuthFilesPage-module__pageInfo___Fkfbg",pV="AuthFilesPage-module__excludedList___9OGiS",mV="AuthFilesPage-module__excludedItem___J3Xxa",gV="AuthFilesPage-module__excludedInfo___0hKQa",_V="AuthFilesPage-module__excludedProvider___6pkYz",yV="AuthFilesPage-module__excludedModels___QdpJB",xV="AuthFilesPage-module__excludedActions___jP49M",bV="AuthFilesPage-module__providerField___end0y",vV="AuthFilesPage-module__providerTagList___dCCYW",SV="AuthFilesPage-module__providerTag___RADdc",wV="AuthFilesPage-module__providerTagActive___j4vQJ",kV="AuthFilesPage-module__mappingRow___b1MBs",AV="AuthFilesPage-module__mappingSeparator___Wx18F",CV="AuthFilesPage-module__mappingFork___nRhwu",OV="AuthFilesPage-module__detailContent___K3wet",TV="AuthFilesPage-module__jsonContent___5lYBo",MV="AuthFilesPage-module__formGroup___1YGlp",NV="AuthFilesPage-module__textarea___IAg4a",RV="AuthFilesPage-module__hint___YExGS",PV="AuthFilesPage-module__modelsList___KKhRE",LV="AuthFilesPage-module__modelItem___VMfPD",jV="AuthFilesPage-module__modelId___4wMUh",EV="AuthFilesPage-module__modelDisplayName___znKrk",DV="AuthFilesPage-module__modelType___B0C7D",UV="AuthFilesPage-module__modelItemExcluded___I5sBn",FV="AuthFilesPage-module__modelExcludedBadge___FyRdH",Ae={container:CK,pageHeader:OK,pageTitle:TK,description:MK,headerActions:NK,titleWrapper:RK,countBadge:PK,errorBox:LK,filterSection:jK,filterTags:EK,filterTag:DK,filterTagActive:UK,filterControls:FK,filterItem:BK,pageSizeSelect:zK,fileGrid:qK,fileCard:HK,cardHeader:KK,typeBadge:VK,fileName:IK,cardMeta:WK,cardStats:XK,statPill:GK,statSuccess:QK,statFailure:YK,statusBar:ZK,statusBlocks:JK,statusBlock:$K,statusBlockSuccess:eV,statusBlockFailure:tV,statusBlockMixed:iV,statusBlockIdle:nV,statusRate:sV,statusRateHigh:aV,statusRateMedium:rV,statusRateLow:oV,cardActions:lV,iconButton:cV,actionIcon:uV,virtualBadge:dV,pagination:hV,pageInfo:fV,excludedList:pV,excludedItem:mV,excludedInfo:gV,excludedProvider:_V,excludedModels:yV,excludedActions:xV,providerField:bV,providerTagList:vV,providerTag:SV,providerTagActive:wV,mappingRow:kV,mappingSeparator:AV,mappingFork:CV,detailContent:OV,jsonContent:TV,formGroup:MV,textarea:NV,hint:RV,modelsList:PV,modelItem:LV,modelId:jV,modelDisplayName:EV,modelType:DV,modelItemExcluded:UV,modelExcludedBadge:FV},zO={qwen:{light:{bg:"#e8f5e9",text:"#2e7d32"},dark:{bg:"#1b5e20",text:"#81c784"}},gemini:{light:{bg:"#e3f2fd",text:"#1565c0"},dark:{bg:"#0d47a1",text:"#64b5f6"}},"gemini-cli":{light:{bg:"#e7efff",text:"#1e4fa3"},dark:{bg:"#1c3f73",text:"#a8c7ff"}},aistudio:{light:{bg:"#f0f2f5",text:"#2f343c"},dark:{bg:"#373c42",text:"#cfd3db"}},claude:{light:{bg:"#fce4ec",text:"#c2185b"},dark:{bg:"#880e4f",text:"#f48fb1"}},codex:{light:{bg:"#fff3e0",text:"#ef6c00"},dark:{bg:"#e65100",text:"#ffb74d"}},antigravity:{light:{bg:"#e0f7fa",text:"#006064"},dark:{bg:"#004d40",text:"#80deea"}},iflow:{light:{bg:"#f3e5f5",text:"#7b1fa2"},dark:{bg:"#4a148c",text:"#ce93d8"}},empty:{light:{bg:"#f5f5f5",text:"#616161"},dark:{bg:"#424242",text:"#bdbdbd"}},unknown:{light:{bg:"#f0f0f0",text:"#666666",border:"1px dashed #999999"},dark:{bg:"#3a3a3a",text:"#aaaaaa",border:"1px dashed #666666"}}},qO=["gemini-cli","vertex","aistudio","antigravity","claude","codex","qwen","iflow"],BV=new Set(["all","unknown","empty"]),GP=3,QP=30,HO=50*1024,zV=i=>Math.min(QP,Math.max(GP,Math.round(i))),Rd=()=>({name:"",alias:"",fork:!1});function $m(i){if(typeof i=="number"&&Number.isFinite(i))return i.toString();if(typeof i=="string"){const e=i.trim();return e||null}return null}function D1(i){var t;const e=(t=i.runtime_only)!=null?t:i.runtimeOnly;return typeof e=="boolean"?e:typeof e=="string"?e.trim().toLowerCase()==="true":!1}function qV(i,e){var r,o,c,d;const t={success:0,failure:0},n=(i==null?void 0:i.name)||"",s=(r=i.auth_index)!=null?r:i.authIndex,a=$m(s);if(a&&((o=e.byAuthIndex)!=null&&o[a]))return e.byAuthIndex[a];if(n&&((c=e.bySource)!=null&&c[n])){const h=e.bySource[n];if(h.success>0||h.failure>0)return h}if(n){const h=n.replace(/\.[^/.]+$/,"");if(h&&h!==n){const p=(d=e.bySource)==null?void 0:d[h];if(p&&(p.success>0||p.failure>0))return p}}return t}function HV(){const{t:i}=rt(),{showNotification:e}=Zn(),t=Ct(I=>I.connectionStatus),n=_r(I=>I.resolvedTheme),[s,a]=N.useState([]),[r,o]=N.useState(!0),[c,d]=N.useState(""),[h,p]=N.useState("all"),[_,y]=N.useState(""),[x,v]=N.useState(1),[w,k]=N.useState(9),[M,O]=N.useState(!1),[A,C]=N.useState(null),[P,R]=N.useState(!1),[E,L]=N.useState({bySource:{},byAuthIndex:{}}),[D,q]=N.useState([]),[B,H]=N.useState(!1),[W,V]=N.useState(null),[U,G]=N.useState(!1),[$,ie]=N.useState(!1),[ue,F]=N.useState([]),[Y,ce]=N.useState(""),[J,me]=N.useState(""),[Se,Re]=N.useState(null),[He,Ke]=N.useState({}),[it,fi]=N.useState(null),[Pi,ft]=N.useState(!1),[ii,Tn]=N.useState({provider:"",modelsText:""}),[Mn,aa]=N.useState(!1),[vi,Ee]=N.useState({}),[_t,he]=N.useState(null),[X,we]=N.useState(!1),[be,je]=N.useState({provider:"",mappings:[Rd()]}),[Ve,Tt]=N.useState(!1),Mt=N.useRef(null),Nt=N.useRef(!1),ni=N.useRef(!1),wt=N.useRef(!1),Bt=t!=="connected",pi=I=>I.trim().toLowerCase(),Wi=I=>{const de=I.currentTarget.valueAsNumber;Number.isFinite(de)&&(k(zV(de)),v(1))},xs=I=>{var Te;const de=(Te=I.modtime)!=null?Te:I.modified;if(!de)return"-";const ve=Number(de),Pe=Number.isFinite(ve)&&!Number.isNaN(ve)?new Date(ve<1e12?ve*1e3:ve):new Date(String(de));return Number.isNaN(Pe.getTime())?"-":Pe.toLocaleString()},si=N.useCallback(()=>pe(null,null,function*(){o(!0),d("");try{const I=yield zi.list();a((I==null?void 0:I.files)||[])}catch(I){const de=I instanceof Error?I.message:i("notification.refresh_failed");d(de)}finally{o(!1)}}),[i]),bs=N.useCallback(()=>pe(null,null,function*(){var I;if(!Nt.current){Nt.current=!0;try{const de=yield Ml.getUsage(),ve=(I=de==null?void 0:de.usage)!=null?I:de,Pe=yield Ml.getKeyStats(ve);L(Pe);const Te=Po(ve);q(Te)}catch(de){}finally{Nt.current=!1}}}),[]),Jn=N.useCallback(()=>pe(null,null,function*(){try{const I=yield zi.getOauthExcludedModels();ni.current=!1,Ke(I||{}),fi(null)}catch(I){if((typeof I=="object"&&I!==null&&"status"in I?I.status:void 0)===404){Ke({}),fi("unsupported"),ni.current||(ni.current=!0,e(i("oauth_excluded.upgrade_required"),"warning"));return}}}),[e,i]),Cr=N.useCallback(()=>pe(null,null,function*(){try{const I=yield zi.getOauthModelMappings();wt.current=!1,Ee(I||{}),he(null)}catch(I){if((typeof I=="object"&&I!==null&&"status"in I?I.status:void 0)===404){Ee({}),he("unsupported"),wt.current||(wt.current=!0,e(i("oauth_model_mappings.upgrade_required"),"warning"));return}}}),[e,i]),jo=N.useCallback(()=>pe(null,null,function*(){yield Promise.all([si(),bs(),Jn(),Cr()])}),[si,bs,Jn,Cr]);M0(jo),N.useEffect(()=>{si(),bs(),Jn(),Cr()},[si,bs,Jn,Cr]),WP(bs,24e4);const Gl=N.useMemo(()=>{const I=new Set(["all"]);return s.forEach(de=>{de.type&&I.add(de.type)}),Array.from(I)},[s]),Ql=N.useMemo(()=>{const I=new Map;return Object.keys(He).forEach(de=>{const ve=de.trim().toLowerCase();ve&&!I.has(ve)&&I.set(ve,de)}),I},[He]),Ua=N.useMemo(()=>{const I=new Map;return Object.keys(vi).forEach(de=>{const ve=de.trim().toLowerCase();ve&&!I.has(ve)&&I.set(ve,de)}),I},[vi]),Ws=N.useMemo(()=>{const I=new Set;Object.keys(He).forEach(Te=>{I.add(Te)}),Object.keys(vi).forEach(Te=>{I.add(Te)}),s.forEach(Te=>{typeof Te.type=="string"&&I.add(Te.type),typeof Te.provider=="string"&&I.add(Te.provider)});const de=Array.from(I).map(Te=>Te.trim()).filter(Te=>Te&&!BV.has(Te.toLowerCase())),ve=new Set(qO.map(Te=>Te.toLowerCase())),Pe=de.filter(Te=>!ve.has(Te.toLowerCase())).sort((Te,yt)=>Te.localeCompare(yt));return[...qO,...Pe]},[He,s,vi]),ra=N.useMemo(()=>s.filter(I=>{const de=h==="all"||I.type===h,ve=_.trim().toLowerCase(),Pe=!ve||I.name.toLowerCase().includes(ve)||(I.type||"").toString().toLowerCase().includes(ve)||(I.provider||"").toString().toLowerCase().includes(ve);return de&&Pe}),[s,h,_]),Yl=Math.max(1,Math.ceil(ra.length/w)),Fa=Math.min(x,Yl),Zl=(Fa-1)*w,Or=ra.slice(Zl,Zl+w),Y0=()=>{var I;(I=Mt.current)==null||I.click()},Mf=I=>pe(null,null,function*(){const de=I.target.files;if(!de||de.length===0)return;const ve=Array.from(de),Pe=[],Te=[],yt=[];if(ve.forEach(kt=>{if(!kt.name.endsWith(".json")){Te.push(kt.name);return}if(kt.size>HO){yt.push(kt.name);return}Pe.push(kt)}),Te.length>0&&e(i("auth_files.upload_error_json"),"error"),yt.length>0&&e(i("auth_files.upload_error_size",{maxSize:kO(HO)}),"error"),Pe.length===0){I.target.value="";return}O(!0);let ci=0;const Rt=[];for(const kt of Pe)try{yield zi.upload(kt),ci++}catch(ki){const Uf=ki instanceof Error?ki.message:"Unknown error";Rt.push({name:kt.name,message:Uf})}if(ci>0){const kt=Pe.length>1?` (${ci}/${Pe.length})`:"";e(`${i("auth_files.upload_success")}${kt}`,Rt.length?"warning":"success"),yield si(),yield bs()}if(Rt.length>0){const kt=Rt.map(ki=>`${ki.name}: ${ki.message}`).join("; ");e(`${i("notification.upload_failed")}: ${kt}`,"error")}O(!1),I.target.value=""}),Nf=I=>pe(null,null,function*(){if(window.confirm(`${i("auth_files.delete_confirm")} "${I}" ?`)){C(I);try{yield zi.deleteFile(I),e(i("auth_files.delete_success"),"success"),a(de=>de.filter(ve=>ve.name!==I))}catch(de){const ve=de instanceof Error?de.message:"";e(`${i("notification.delete_failed")}: ${ve}`,"error")}finally{C(null)}}}),Rf=()=>pe(null,null,function*(){const I=h!=="all",de=I?xn(h):i("auth_files.filter_all"),ve=I?i("auth_files.delete_filtered_confirm",{type:de}):i("auth_files.delete_all_confirm");if(window.confirm(ve)){R(!0);try{if(!I)yield zi.deleteAll(),e(i("auth_files.delete_all_success"),"success"),a(Pe=>Pe.filter(Te=>D1(Te)));else{const Pe=s.filter(Rt=>Rt.type===h&&!D1(Rt));if(Pe.length===0){e(i("auth_files.delete_filtered_none",{type:de}),"info"),R(!1);return}let Te=0,yt=0;const ci=[];for(const Rt of Pe)try{yield zi.deleteFile(Rt.name),Te++,ci.push(Rt.name)}catch(kt){yt++}a(Rt=>Rt.filter(kt=>!ci.includes(kt.name))),yt===0?e(i("auth_files.delete_filtered_success",{count:Te,type:de}),"success"):e(i("auth_files.delete_filtered_partial",{success:Te,failed:yt,type:de}),"warning"),p("all")}}catch(Pe){const Te=Pe instanceof Error?Pe.message:"";e(`${i("notification.delete_failed")}: ${Te}`,"error")}finally{R(!1)}}}),Nu=I=>pe(null,null,function*(){try{const de=yield Ce.getRaw(`/auth-files/download?name=${encodeURIComponent(I)}`,{responseType:"blob"}),ve=new Blob([de.data]),Pe=window.URL.createObjectURL(ve),Te=document.createElement("a");Te.href=Pe,Te.download=I,Te.click(),window.URL.revokeObjectURL(Pe),e(i("auth_files.download_success"),"success")}catch(de){const ve=de instanceof Error?de.message:"";e(`${i("notification.download_failed")}: ${ve}`,"error")}}),Ru=I=>{V(I),H(!0)},Pf=I=>pe(null,null,function*(){ce(I.name),me(I.type||""),F([]),Re(null),G(!0),ie(!0);try{const de=yield zi.getModelsForAuthFile(I.name);F(de)}catch(de){const ve=de instanceof Error?de.message:"";ve.includes("404")||ve.includes("not found")||ve.includes("Not Found")?Re("unsupported"):e(`${i("notification.load_failed")}: ${ve}`,"error")}finally{ie(!1)}}),Lf=(I,de)=>{const ve=pi(de);return(He[ve]||He[de]||[]).some(Te=>Te.includes("*")?new RegExp("^"+Te.replace(/\*/g,".*")+"$","i").test(I):Te.toLowerCase()===I.toLowerCase())},xn=I=>{const de=`auth_files.filter_${I}`,ve=i(de);return ve!==de?ve:I.toLowerCase()==="iflow"?"iFlow":I.charAt(0).toUpperCase()+I.slice(1)},Si=I=>{const de=zO[I]||zO.unknown;return n==="dark"&&de.dark?de.dark:de.light},Xi=I=>{const ve=pi(I||"")||(h!=="all"?pi(String(h)):""),Pe=ve?Ql.get(ve):void 0,Te=Pe?He[Pe]:[];Tn({provider:Pe||ve,modelsText:Array.isArray(Te)?Te.join(` `):""}),ft(!0)},Tr=()=>pe(null,null,function*(){const I=pi(ii.provider);if(!I){e(i("oauth_excluded.provider_required"),"error");return}const de=ii.modelsText.split(/[\n,]+/).map(ve=>ve.trim()).filter(Boolean);aa(!0);try{de.length?yield zi.saveOauthExcludedModels(I,de):yield zi.deleteOauthExcludedEntry(I),yield Jn(),e(i("oauth_excluded.save_success"),"success"),ft(!1)}catch(ve){const Pe=ve instanceof Error?ve.message:"";e(`${i("oauth_excluded.save_failed")}: ${Pe}`,"error")}finally{aa(!1)}}),Pu=I=>pe(null,null,function*(){const de=I.trim()||I;if(!window.confirm(i("oauth_excluded.delete_confirm",{provider:de})))return;const ve=pi(I);if(!ve){e(i("oauth_excluded.provider_required"),"error");return}try{yield zi.deleteOauthExcludedEntry(ve),yield Jn(),e(i("oauth_excluded.delete_success"),"success")}catch(Pe){try{const Te=yield zi.getOauthExcludedModels(),yt={};Object.entries(Te).forEach(([ci,Rt])=>{pi(ci)!==ve&&(yt[ci]=Rt)}),yield zi.replaceOauthExcludedModels(yt),yield Jn(),e(i("oauth_excluded.delete_success"),"success")}catch(Te){const yt=Te instanceof Error?Te.message:Pe instanceof Error?Pe.message:"";e(`${i("oauth_excluded.delete_failed")}: ${yt}`,"error")}}}),Z0=I=>!Array.isArray(I)||I.length===0?[Rd()]:I.map(de=>{var ve,Pe;return{name:(ve=de.name)!=null?ve:"",alias:(Pe=de.alias)!=null?Pe:"",fork:!!de.fork}}),jf=I=>{const ve=(I||"").trim()||(h!=="all"?String(h):""),Pe=ve?Ua.get(ve.toLowerCase()):void 0,Te=Pe?vi[Pe]:[];je({provider:Pe||ve,mappings:Z0(Te)}),we(!0)},Jl=(I,de,ve)=>{je(Pe=>ee(z({},Pe),{mappings:Pe.mappings.map((Te,yt)=>yt===I?ee(z({},Te),{[de]:ve}):Te)}))},Eo=()=>{je(I=>ee(z({},I),{mappings:[...I.mappings,Rd()]}))},Lu=I=>{je(de=>{const ve=de.mappings.filter((Pe,Te)=>Te!==I);return ee(z({},de),{mappings:ve.length?ve:[Rd()]})})},Mr=()=>pe(null,null,function*(){const I=be.provider.trim();if(!I){e(i("oauth_model_mappings.provider_required"),"error");return}const de=new Set,ve=be.mappings.map(Pe=>{var Rt,kt;const Te=String((Rt=Pe.name)!=null?Rt:"").trim(),yt=String((kt=Pe.alias)!=null?kt:"").trim();if(!Te||!yt)return null;const ci=`${Te.toLowerCase()}::${yt.toLowerCase()}::${Pe.fork?"1":"0"}`;return de.has(ci)?null:(de.add(ci),Pe.fork?{name:Te,alias:yt,fork:!0}:{name:Te,alias:yt})}).filter(Boolean);Tt(!0);try{ve.length?yield zi.saveOauthModelMappings(I,ve):yield zi.deleteOauthModelMappings(I),yield Cr(),e(i("oauth_model_mappings.save_success"),"success"),we(!1)}catch(Pe){const Te=Pe instanceof Error?Pe.message:"";e(`${i("oauth_model_mappings.save_failed")}: ${Te}`,"error")}finally{Tt(!1)}}),Nr=I=>pe(null,null,function*(){if(window.confirm(i("oauth_model_mappings.delete_confirm",{provider:I})))try{yield zi.deleteOauthModelMappings(I),yield Cr(),e(i("oauth_model_mappings.delete_success"),"success")}catch(de){const ve=de instanceof Error?de.message:"";e(`${i("oauth_model_mappings.delete_failed")}: ${ve}`,"error")}}),Do=()=>g.jsx("div",{className:Ae.filterTags,children:Gl.map(I=>{const de=h===I,ve=I==="all"?{bg:"var(--bg-tertiary)",text:"var(--text-primary)"}:Si(I),Pe=n==="dark"?"#111827":"#fff";return g.jsx("button",{className:`${Ae.filterTag} ${de?Ae.filterTagActive:""}`,style:{backgroundColor:de?ve.text:ve.bg,color:de?Pe:ve.text,borderColor:ve.text},onClick:()=>{p(I),v(1)},children:xn(I)},I)})}),Rr=N.useMemo(()=>{const I=new Map;return s.forEach(de=>{var Te;const ve=(Te=de.auth_index)!=null?Te:de.authIndex,Pe=$m(ve);if(Pe){const yt=D.filter(ci=>{const Rt=$m(ci.auth_index);return Rt!==null&&Rt===Pe});I.set(Pe,qs(yt))}}),I},[D,s]),wi=I=>{var ci;const de=(ci=I.auth_index)!=null?ci:I.authIndex,ve=$m(de),Pe=ve&&Rr.get(ve)||qs([]),Te=Pe.totalSuccess+Pe.totalFailure>0,yt=Te?Pe.successRate>=90?Ae.statusRateHigh:Pe.successRate>=50?Ae.statusRateMedium:Ae.statusRateLow:"";return g.jsxs("div",{className:Ae.statusBar,children:[g.jsx("div",{className:Ae.statusBlocks,children:Pe.blocks.map((Rt,kt)=>{const ki=Rt==="success"?Ae.statusBlockSuccess:Rt==="failure"?Ae.statusBlockFailure:Rt==="mixed"?Ae.statusBlockMixed:Ae.statusBlockIdle;return g.jsx("div",{className:`${Ae.statusBlock} ${ki}`},kt)})}),g.jsx("span",{className:`${Ae.statusRate} ${yt}`,children:Te?`${Pe.successRate.toFixed(1)}%`:"--"})]})},Ef=I=>{const de=qV(I,E),ve=D1(I),Pe=(I.type||"").toLowerCase()==="aistudio",Te=!ve||Pe,yt=Si(I.type||"unknown");return g.jsxs("div",{className:Ae.fileCard,children:[g.jsxs("div",{className:Ae.cardHeader,children:[g.jsx("span",{className:Ae.typeBadge,style:z({backgroundColor:yt.bg,color:yt.text},yt.border?{border:yt.border}:{}),children:xn(I.type||"unknown")}),g.jsx("span",{className:Ae.fileName,children:I.name})]}),g.jsxs("div",{className:Ae.cardMeta,children:[g.jsxs("span",{children:[i("auth_files.file_size"),": ",I.size?kO(I.size):"-"]}),g.jsxs("span",{children:[i("auth_files.file_modified"),": ",xs(I)]})]}),g.jsxs("div",{className:Ae.cardStats,children:[g.jsxs("span",{className:`${Ae.statPill} ${Ae.statSuccess}`,children:[i("stats.success"),": ",de.success]}),g.jsxs("span",{className:`${Ae.statPill} ${Ae.statFailure}`,children:[i("stats.failure"),": ",de.failure]})]}),wi(I),g.jsxs("div",{className:Ae.cardActions,children:[Te&&g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>Pf(I),className:Ae.iconButton,title:i("auth_files.models_button",{defaultValue:"模型"}),disabled:Bt,children:g.jsx(Lv,{className:Ae.actionIcon,size:16})}),!ve&&g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>Ru(I),className:Ae.iconButton,title:i("common.info",{defaultValue:"关于"}),disabled:Bt,children:g.jsx(QN,{className:Ae.actionIcon,size:16})}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>Nu(I.name),className:Ae.iconButton,title:i("auth_files.download_button"),disabled:Bt,children:g.jsx(ZN,{className:Ae.actionIcon,size:16})}),g.jsx(ye,{variant:"danger",size:"sm",onClick:()=>Nf(I.name),className:Ae.iconButton,title:i("auth_files.delete_button"),disabled:Bt||A===I.name,children:A===I.name?g.jsx(C0,{size:14}):g.jsx(JN,{className:Ae.actionIcon,size:16})})]}),ve&&g.jsx("div",{className:Ae.virtualBadge,children:i("auth_files.type_virtual")||"虚拟认证文件"})]})]},I.name)},Df=g.jsxs("div",{className:Ae.titleWrapper,children:[g.jsx("span",{children:i("auth_files.title_section")}),s.length>0&&g.jsx("span",{className:Ae.countBadge,children:s.length})]});return g.jsxs("div",{className:Ae.container,children:[g.jsxs("div",{className:Ae.pageHeader,children:[g.jsx("h1",{className:Ae.pageTitle,children:i("auth_files.title")}),g.jsx("p",{className:Ae.description,children:i("auth_files.description")})]}),g.jsxs(vt,{title:Df,extra:g.jsxs("div",{className:Ae.headerActions,children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:jo,disabled:r,children:i("common.refresh")}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:Rf,disabled:Bt||r||P,loading:P,children:h==="all"?i("auth_files.delete_all_button"):`${i("common.delete")} ${xn(h)}`}),g.jsx(ye,{size:"sm",onClick:Y0,disabled:Bt||M,loading:M,children:i("auth_files.upload_button")}),g.jsx("input",{ref:Mt,type:"file",accept:".json,application/json",multiple:!0,style:{display:"none"},onChange:Mf})]}),children:[c&&g.jsx("div",{className:Ae.errorBox,children:c}),g.jsxs("div",{className:Ae.filterSection,children:[Do(),g.jsxs("div",{className:Ae.filterControls,children:[g.jsxs("div",{className:Ae.filterItem,children:[g.jsx("label",{children:i("auth_files.search_label")}),g.jsx(et,{value:_,onChange:I=>{y(I.target.value),v(1)},placeholder:i("auth_files.search_placeholder")})]}),g.jsxs("div",{className:Ae.filterItem,children:[g.jsx("label",{children:i("auth_files.page_size_label")}),g.jsx("input",{className:Ae.pageSizeSelect,type:"number",min:GP,max:QP,step:1,value:w,onChange:Wi})]})]})]}),r?g.jsx("div",{className:Ae.hint,children:i("common.loading")}):Or.length===0?g.jsx(Ps,{title:i("auth_files.search_empty_title"),description:i("auth_files.search_empty_desc")}):g.jsx("div",{className:Ae.fileGrid,children:Or.map(Ef)}),!r&&ra.length>w&&g.jsxs("div",{className:Ae.pagination,children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>v(Math.max(1,Fa-1)),disabled:Fa<=1,children:i("auth_files.pagination_prev")}),g.jsx("div",{className:Ae.pageInfo,children:i("auth_files.pagination_info",{current:Fa,total:Yl,count:ra.length})}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>v(Math.min(Yl,Fa+1)),disabled:Fa>=Yl,children:i("auth_files.pagination_next")})]})]}),g.jsx(vt,{title:i("oauth_excluded.title"),extra:g.jsx(ye,{size:"sm",onClick:()=>Xi(),disabled:Bt||it==="unsupported",children:i("oauth_excluded.add")}),children:it==="unsupported"?g.jsx(Ps,{title:i("oauth_excluded.upgrade_required_title"),description:i("oauth_excluded.upgrade_required_desc")}):Object.keys(He).length===0?g.jsx(Ps,{title:i("oauth_excluded.list_empty_all")}):g.jsx("div",{className:Ae.excludedList,children:Object.entries(He).map(([I,de])=>g.jsxs("div",{className:Ae.excludedItem,children:[g.jsxs("div",{className:Ae.excludedInfo,children:[g.jsx("div",{className:Ae.excludedProvider,children:I}),g.jsx("div",{className:Ae.excludedModels,children:de!=null&&de.length?i("oauth_excluded.model_count",{count:de.length}):i("oauth_excluded.no_models")})]}),g.jsxs("div",{className:Ae.excludedActions,children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>Xi(I),children:i("common.edit")}),g.jsx(ye,{variant:"danger",size:"sm",onClick:()=>Pu(I),children:i("oauth_excluded.delete")})]})]},I))})}),g.jsx(vt,{title:i("oauth_model_mappings.title"),extra:g.jsx(ye,{size:"sm",onClick:()=>jf(),disabled:Bt||_t==="unsupported",children:i("oauth_model_mappings.add")}),children:_t==="unsupported"?g.jsx(Ps,{title:i("oauth_model_mappings.upgrade_required_title"),description:i("oauth_model_mappings.upgrade_required_desc")}):Object.keys(vi).length===0?g.jsx(Ps,{title:i("oauth_model_mappings.list_empty_all")}):g.jsx("div",{className:Ae.excludedList,children:Object.entries(vi).map(([I,de])=>g.jsxs("div",{className:Ae.excludedItem,children:[g.jsxs("div",{className:Ae.excludedInfo,children:[g.jsx("div",{className:Ae.excludedProvider,children:I}),g.jsx("div",{className:Ae.excludedModels,children:de!=null&&de.length?i("oauth_model_mappings.model_count",{count:de.length}):i("oauth_model_mappings.no_models")})]}),g.jsxs("div",{className:Ae.excludedActions,children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>jf(I),children:i("common.edit")}),g.jsx(ye,{variant:"danger",size:"sm",onClick:()=>Nr(I),children:i("oauth_model_mappings.delete")})]})]},I))})}),g.jsx(zn,{open:B,onClose:()=>H(!1),title:(W==null?void 0:W.name)||i("auth_files.title_section"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:()=>H(!1),children:i("common.close")}),g.jsx(ye,{onClick:()=>{if(W){const I=JSON.stringify(W,null,2);navigator.clipboard.writeText(I).then(()=>{e(i("notification.link_copied"),"success")})}},children:i("common.copy")})]}),children:W&&g.jsx("div",{className:Ae.detailContent,children:g.jsx("pre",{className:Ae.jsonContent,children:JSON.stringify(W,null,2)})})}),g.jsx(zn,{open:U,onClose:()=>G(!1),title:i("auth_files.models_title",{defaultValue:"支持的模型"})+` - ${Y}`,footer:g.jsx(ye,{variant:"secondary",onClick:()=>G(!1),children:i("common.close")}),children:$?g.jsx("div",{className:Ae.hint,children:i("auth_files.models_loading",{defaultValue:"正在加载模型列表..."})}):Se==="unsupported"?g.jsx(Ps,{title:i("auth_files.models_unsupported",{defaultValue:"当前版本不支持此功能"}),description:i("auth_files.models_unsupported_desc",{defaultValue:"请更新 CLI Proxy API 到最新版本后重试"})}):ue.length===0?g.jsx(Ps,{title:i("auth_files.models_empty",{defaultValue:"该凭证暂无可用模型"}),description:i("auth_files.models_empty_desc",{defaultValue:"该认证凭证可能尚未被服务器加载或没有绑定任何模型"})}):g.jsx("div",{className:Ae.modelsList,children:ue.map(I=>{const de=Lf(I.id,J);return g.jsxs("div",{className:`${Ae.modelItem} ${de?Ae.modelItemExcluded:""}`,onClick:()=>{navigator.clipboard.writeText(I.id),e(i("notification.link_copied",{defaultValue:"已复制到剪贴板"}),"success")},title:de?i("auth_files.models_excluded_hint",{defaultValue:"此模型已被 OAuth 排除"}):i("common.copy",{defaultValue:"点击复制"}),children:[g.jsx("span",{className:Ae.modelId,children:I.id}),I.display_name&&I.display_name!==I.id&&g.jsx("span",{className:Ae.modelDisplayName,children:I.display_name}),I.type&&g.jsx("span",{className:Ae.modelType,children:I.type}),de&&g.jsx("span",{className:Ae.modelExcludedBadge,children:i("auth_files.models_excluded_badge",{defaultValue:"已排除"})})]},I.id)})})}),g.jsxs(zn,{open:Pi,onClose:()=>ft(!1),title:i("oauth_excluded.add_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:()=>ft(!1),disabled:Mn,children:i("common.cancel")}),g.jsx(ye,{onClick:Tr,loading:Mn,children:i("oauth_excluded.save")})]}),children:[g.jsxs("div",{className:Ae.providerField,children:[g.jsx(et,{id:"oauth-excluded-provider",list:"oauth-excluded-provider-options",label:i("oauth_excluded.provider_label"),hint:i("oauth_excluded.provider_hint"),placeholder:i("oauth_excluded.provider_placeholder"),value:ii.provider,onChange:I=>Tn(de=>ee(z({},de),{provider:I.target.value}))}),g.jsx("datalist",{id:"oauth-excluded-provider-options",children:Ws.map(I=>g.jsx("option",{value:I},I))}),Ws.length>0&&g.jsx("div",{className:Ae.providerTagList,children:Ws.map(I=>{const de=ii.provider.trim().toLowerCase()===I.toLowerCase();return g.jsx("button",{type:"button",className:`${Ae.providerTag} ${de?Ae.providerTagActive:""}`,onClick:()=>Tn(ve=>ee(z({},ve),{provider:I})),disabled:Mn,children:xn(I)},I)})})]}),g.jsxs("div",{className:Ae.formGroup,children:[g.jsx("label",{children:i("oauth_excluded.models_label")}),g.jsx("textarea",{className:Ae.textarea,rows:4,placeholder:i("oauth_excluded.models_placeholder"),value:ii.modelsText,onChange:I=>Tn(de=>ee(z({},de),{modelsText:I.target.value}))}),g.jsx("div",{className:Ae.hint,children:i("oauth_excluded.models_hint")})]})]}),g.jsxs(zn,{open:X,onClose:()=>we(!1),title:i("oauth_model_mappings.add_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:()=>we(!1),disabled:Ve,children:i("common.cancel")}),g.jsx(ye,{onClick:Mr,loading:Ve,children:i("oauth_model_mappings.save")})]}),children:[g.jsxs("div",{className:Ae.providerField,children:[g.jsx(et,{id:"oauth-model-mappings-provider",list:"oauth-model-mappings-provider-options",label:i("oauth_model_mappings.provider_label"),hint:i("oauth_model_mappings.provider_hint"),placeholder:i("oauth_model_mappings.provider_placeholder"),value:be.provider,onChange:I=>je(de=>ee(z({},de),{provider:I.target.value}))}),g.jsx("datalist",{id:"oauth-model-mappings-provider-options",children:Ws.map(I=>g.jsx("option",{value:I},I))}),Ws.length>0&&g.jsx("div",{className:Ae.providerTagList,children:Ws.map(I=>{const de=be.provider.trim().toLowerCase()===I.toLowerCase();return g.jsx("button",{type:"button",className:`${Ae.providerTag} ${de?Ae.providerTagActive:""}`,onClick:()=>je(ve=>ee(z({},ve),{provider:I})),disabled:Ve,children:xn(I)},I)})})]}),g.jsxs("div",{className:Ae.formGroup,children:[g.jsx("label",{children:i("oauth_model_mappings.mappings_label")}),g.jsxs("div",{className:"header-input-list",children:[(be.mappings.length?be.mappings:[Rd()]).map((I,de)=>g.jsxs("div",{className:Ae.mappingRow,children:[g.jsx("input",{className:"input",placeholder:i("oauth_model_mappings.mapping_name_placeholder"),value:I.name,onChange:ve=>Jl(de,"name",ve.target.value),disabled:Ve}),g.jsx("span",{className:Ae.mappingSeparator,children:"→"}),g.jsx("input",{className:"input",placeholder:i("oauth_model_mappings.mapping_alias_placeholder"),value:I.alias,onChange:ve=>Jl(de,"alias",ve.target.value),disabled:Ve}),g.jsx("div",{className:Ae.mappingFork,children:g.jsx(Sn,{label:i("oauth_model_mappings.mapping_fork_label"),labelPosition:"left",checked:!!I.fork,onChange:ve=>Jl(de,"fork",ve),disabled:Ve})}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:()=>Lu(de),disabled:Ve||be.mappings.length<=1,title:i("common.delete"),"aria-label":i("common.delete"),children:g.jsx(Hl,{size:14})})]},`${I.name}-${I.alias}-${de}`)),g.jsx(ye,{variant:"secondary",size:"sm",onClick:Eo,disabled:Ve,className:"align-start",children:i("oauth_model_mappings.add_mapping")})]}),g.jsx("div",{className:Ae.hint,children:i("oauth_model_mappings.mappings_hint")})]})]})]})}const KV="OAuthPage-module__container___LCCdH",VV="OAuthPage-module__cardTitle___yFaP0",IV="OAuthPage-module__cardTitleIcon___eAnql",WV="OAuthPage-module__pageTitle___BQQ2z",XV="OAuthPage-module__content___Phg9V",GV="OAuthPage-module__callbackSection___8kA31",QV="OAuthPage-module__callbackActions___wtkMI",YV="OAuthPage-module__authUrlBox___Iu1d4",ZV="OAuthPage-module__authUrlLabel___mYFJB",JV="OAuthPage-module__authUrlValue___axvUJ",$V="OAuthPage-module__authUrlActions___venPj",eI="OAuthPage-module__geminiProjectField___g456A",tI="OAuthPage-module__filePicker___NmFjy",iI="OAuthPage-module__fileName___9ZbQI",nI="OAuthPage-module__fileNamePlaceholder___WHjj4",ji={container:KV,cardTitle:VV,cardTitleIcon:IV,pageTitle:WV,content:XV,callbackSection:GV,callbackActions:QV,authUrlBox:YV,authUrlLabel:ZV,authUrlValue:JV,authUrlActions:$V,geminiProjectField:eI,filePicker:tI,fileName:iI,fileNamePlaceholder:nI},sI="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3c!--%20Generator:%20visioncortex%20VTracer%200.6.4%20--%3e%3csvg%20version='1.1'%20xmlns='http://www.w3.org/2000/svg'%20width='64'%20height='59'%3e%3cpath%20d='M0,0%20L8,0%20L14,4%20L19,14%20L27,40%20L32,50%20L36,54%20L35,59%20L30,59%20L22,52%20L11,35%20L6,33%20L-1,34%20L-6,39%20L-14,52%20L-22,59%20L-28,59%20L-27,53%20L-22,47%20L-17,34%20L-10,12%20L-5,3%20Z%20'%20fill='%233789F9'%20transform='translate(28,0)'/%3e%3cpath%20d='M0,0%20L8,0%20L14,4%20L19,14%20L25,35%20L21,34%20L16,29%20L11,26%20L7,20%20L7,18%20L2,16%20L-3,15%20L-8,18%20L-12,19%20L-9,9%20L-4,2%20Z%20'%20fill='%236D80D8'%20transform='translate(28,0)'/%3e%3cpath%20d='M0,0%20L8,0%20L14,4%20L19,14%20L20,19%20L13,15%20L10,12%20L3,10%20L-1,8%20L-7,7%20L-4,2%20Z%20'%20fill='%23D78240'%20transform='translate(28,0)'/%3e%3cpath%20d='M0,0%20L5,1%20L10,4%20L12,9%20L1,8%20L-5,13%20L-10,21%20L-13,26%20L-16,26%20L-9,5%20L-4,2%20Z%20M6,7%20Z%20'%20fill='%233294CC'%20transform='translate(25,14)'/%3e%3cpath%20d='M0,0%20L5,2%20L10,10%20L12,18%20L5,14%20L1,10%20L0,4%20L-3,3%20L0,2%20Z%20'%20fill='%23E45C49'%20transform='translate(36,1)'/%3e%3cpath%20d='M0,0%20L9,1%20L12,3%20L12,5%20L7,6%20L4,8%20L-1,11%20L-5,12%20L-2,2%20Z%20'%20fill='%2390AE64'%20transform='translate(21,7)'/%3e%3cpath%20d='M0,0%20L5,1%20L5,4%20L-2,7%20L-7,11%20L-11,10%20L-9,5%20L-4,2%20Z%20'%20fill='%2353A89A'%20transform='translate(25,14)'/%3e%3cpath%20d='M0,0%20L5,0%20L16,9%20L17,13%20L12,12%20L8,9%20L8,7%20L4,5%20L0,2%20Z%20'%20fill='%23B5677D'%20transform='translate(33,11)'/%3e%3cpath%20d='M0,0%20L6,0%20L14,6%20L19,11%20L23,12%20L22,15%20L15,12%20L10,8%20L10,6%20L4,5%20Z%20'%20fill='%23778998'%20transform='translate(27,12)'/%3e%3cpath%20d='M0,0%20L4,2%20L-11,17%20L-12,14%20L-5,4%20Z%20'%20fill='%233390DF'%20transform='translate(26,21)'/%3e%3cpath%20d='M0,0%20L2,1%20L-4,5%20L-9,9%20L-13,13%20L-14,10%20L-13,7%20L-6,4%20L-3,1%20Z%20'%20fill='%233FA1B7'%20transform='translate(27,18)'/%3e%3cpath%20d='M0,0%20L4,0%20L9,5%20L13,6%20L12,9%20L5,6%20L0,2%20Z%20'%20fill='%238277BB'%20transform='translate(37,18)'/%3e%3cpath%20d='M0,0%20L5,1%20L7,6%20L-2,5%20Z%20M1,4%20Z%20'%20fill='%234989CF'%20transform='translate(30,17)'/%3e%3cpath%20d='M0,0%20L5,1%20L2,3%20L-3,6%20L-7,7%20L-6,3%20Z%20'%20fill='%2371B774'%20transform='translate(23,12)'/%3e%3cpath%20d='M0,0%20L7,1%20L9,7%20L5,6%20L0,1%20Z%20'%20fill='%236687E9'%20transform='translate(44,28)'/%3e%3cpath%20d='M0,0%20L7,0%20L5,1%20L5,3%20L8,4%20L4,5%20L-2,4%20Z%20'%20fill='%23C7AF38'%20transform='translate(23,3)'/%3e%3cpath%20d='M0,0%20L8,0%20L8,3%20L4,4%20L-4,3%20Z%20'%20fill='%23EF842A'%20transform='translate(28,0)'/%3e%3cpath%20d='M0,0%20L7,4%20L7,6%20L10,6%20L11,10%20L4,6%20L0,2%20Z%20'%20fill='%23CD5D67'%20transform='translate(37,9)'/%3e%3cpath%20d='M0,0%20L5,2%20L9,8%20L8,11%20L2,3%20L0,2%20Z%20'%20fill='%23F35241'%20transform='translate(36,1)'/%3e%3cpath%20d='M0,0%20L8,2%20L9,6%20L4,5%20L0,2%20Z%20'%20fill='%23A667A2'%20transform='translate(41,18)'/%3e%3cpath%20d='M0,0%20L9,1%20L8,3%20L-2,3%20Z%20'%20fill='%23A4B34C'%20transform='translate(21,7)'/%3e%3cpath%20d='M0,0%20L2,0%20L7,5%20L8,7%20L3,6%20L0,2%20Z%20'%20fill='%23617FCF'%20transform='translate(35,18)'/%3e%3cpath%20d='M0,0%20L5,2%20L8,7%20L4,5%20L0,2%20Z%20'%20fill='%239D7784'%20transform='translate(33,11)'/%3e%3cpath%20d='M0,0%20L6,2%20L6,4%20L0,3%20Z%20'%20fill='%23BC7F59'%20transform='translate(31,7)'/%3e%3c/svg%3e",aI="data:image/svg+xml,%3csvg%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3ctitle%3eQwen%3c/title%3e%3cpath%20d='M12.604%201.34c.393.69.784%201.382%201.174%202.075a.18.18%200%2000.157.091h5.552c.174%200%20.322.11.446.327l1.454%202.57c.19.337.24.478.024.837-.26.43-.513.864-.76%201.3l-.367.658c-.106.196-.223.28-.04.512l2.652%204.637c.172.301.111.494-.043.77-.437.785-.882%201.564-1.335%202.34-.159.272-.352.375-.68.37-.777-.016-1.552-.01-2.327.016a.099.099%200%2000-.081.05%20575.097%20575.097%200%2001-2.705%204.74c-.169.293-.38.363-.725.364-.997.003-2.002.004-3.017.002a.537.537%200%2001-.465-.271l-1.335-2.323a.09.09%200%2000-.083-.049H4.982c-.285.03-.553-.001-.805-.092l-1.603-2.77a.543.543%200%2001-.002-.54l1.207-2.12a.198.198%200%20000-.197%20550.951%20550.951%200%2001-1.875-3.272l-.79-1.395c-.16-.31-.173-.496.095-.965.465-.813.927-1.625%201.387-2.436.132-.234.304-.334.584-.335a338.3%20338.3%200%20012.589-.001.124.124%200%2000.107-.063l2.806-4.895a.488.488%200%2001.422-.246c.524-.001%201.053%200%201.583-.006L11.704%201c.341-.003.724.032.9.34zm-3.432.403a.06.06%200%2000-.052.03L6.254%206.788a.157.157%200%2001-.135.078H3.253c-.056%200-.07.025-.041.074l5.81%2010.156c.025.042.013.062-.034.063l-2.795.015a.218.218%200%2000-.2.116l-1.32%202.31c-.044.078-.021.118.068.118l5.716.008c.046%200%20.08.02.104.061l1.403%202.454c.046.081.092.082.139%200l5.006-8.76.783-1.382a.055.055%200%2001.096%200l1.424%202.53a.122.122%200%2000.107.062l2.763-.02a.04.04%200%2000.035-.02.041.041%200%20000-.04l-2.9-5.086a.108.108%200%20010-.113l.293-.507%201.12-1.977c.024-.041.012-.062-.035-.062H9.2c-.059%200-.073-.026-.043-.077l1.434-2.505a.107.107%200%20000-.114L9.225%201.774a.06.06%200%2000-.053-.031zm6.29%208.02c.046%200%20.058.02.034.06l-.832%201.465-2.613%204.585a.056.056%200%2001-.05.029.058.058%200%2001-.05-.029L8.498%209.841c-.02-.034-.01-.052.028-.054l.216-.012%206.722-.012z'%20fill='url(%23lobe-icons-qwen-fill)'%20fill-rule='nonzero'%3e%3c/path%3e%3cdefs%3e%3clinearGradient%20id='lobe-icons-qwen-fill'%20x1='0%25'%20x2='100%25'%20y1='0%25'%20y2='0%25'%3e%3cstop%20offset='0%25'%20stop-color='%236336E7'%20stop-opacity='.84'%3e%3c/stop%3e%3cstop%20offset='100%25'%20stop-color='%236F69F7'%20stop-opacity='.84'%3e%3c/stop%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",rI="data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20fill='none'%20version='1.1'%20width='32'%20height='32'%20viewBox='0%200%2032%2032'%3e%3cdefs%3e%3cfilter%20id='master_svg0_278_51503'%20filterUnits='objectBoundingBox'%20color-interpolation-filters='sRGB'%20x='0'%20y='0'%20width='1'%20height='1'%3e%3cfeFlood%20flood-opacity='0'%20result='BackgroundImageFix'/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='BackgroundImageFix'%20result='shape'/%3e%3cfeGaussianBlur%20in='BackgroundImageFix'%20stdDeviation='1.3333334922790527'/%3e%3cfeComposite%20in2='SourceAlpha'%20operator='in'%20result='effect1_foregroundBlur'/%3e%3cfeBlend%20mode='normal'%20in='SourceGraphic'%20in2='effect1_foregroundBlur'%20result='shape'/%3e%3c/filter%3e%3clinearGradient%20x1='0.07353696972131729'%20y1='0.12899449467658997'%20x2='0.9907095821060244'%20y2='0.9383787344260006'%20id='master_svg1_93_40276'%3e%3cstop%20offset='0%25'%20stop-color='%235C5CFF'%20stop-opacity='1'/%3e%3cstop%20offset='100%25'%20stop-color='%23AE5CFF'%20stop-opacity='1'/%3e%3c/linearGradient%3e%3c/defs%3e%3cg%3e%3cg%20filter='url(%23master_svg0_278_51503)'%3e%3crect%20x='0'%20y='0'%20width='32'%20height='32'%20rx='16'%20fill='%23F0F2F5'%20fill-opacity='0'/%3e%3c/g%3e%3cg%3e%3cg%3e%3cpath%20d='M31.843111328125,14.751C31.315411328125,7.18121,25.497411328125,1.04691,17.966011328125,0.119698C10.434711328125,-0.807512,3.302541328125,3.73244,0.954596328125,10.9482C0.345662328125,12.8248,1.732821328125,14.751,3.705641328125,14.751C4.950051328125,14.7517,6.055631328125,13.9569,6.451401328125,12.7772C7.497331328125,9.65101,10.504411328125,3.91401,18.482011328125,3.91401Q29.445911328125,3.91401,31.843111328125,14.751ZM9.127681328125,17.3314L9.127681328125,13.0862Q9.127681328125,13.0022,9.144081328125,12.9198Q9.160481328125,12.8373,9.192641328125,12.7597Q9.224801328125,12.682,9.271501328125,12.6122Q9.318191328125,12.5423,9.377621328125,12.4828Q9.437051328125,12.4234,9.506931328125,12.3767Q9.576811328125,12.33,9.654461328125,12.2979Q9.732111328125,12.2657,9.814541328125,12.2493Q9.896971328125,12.2329,9.981021328125,12.2329L11.049211328125,12.2329Q11.133211328125,12.2329,11.215711328125,12.2493Q11.298111328125,12.2657,11.375811328125,12.2979Q11.453411328125,12.33,11.523311328125,12.3767Q11.593211328125,12.4234,11.652611328125,12.4828Q11.712011328125,12.5423,11.758711328125,12.6122Q11.805411328125,12.682,11.837611328125,12.7597Q11.869711328125,12.8373,11.886111328125,12.9198Q11.902511328125,13.0022,11.902511328125,13.0862L11.902511328125,17.3314Q11.902511328125,17.4154,11.886111328125,17.4978Q11.869711328125,17.5803,11.837611328125,17.6579Q11.805411328125,17.7356,11.758711328125,17.8055Q11.712011328125,17.8753,11.652611328125,17.9348Q11.593211328125,17.9942,11.523311328125,18.0409Q11.453411328125,18.0876,11.375811328125,18.1197Q11.298111328125,18.1519,11.215711328125,18.1683Q11.133211328125,18.1847,11.049211328125,18.1847L9.981021328125,18.1847Q9.896971328125,18.1847,9.814541328125,18.1683Q9.732111328125,18.1519,9.654461328125,18.1197Q9.576811328125,18.0876,9.506931328125,18.0409Q9.437051328125,17.9942,9.377621328125,17.9348Q9.318191328125,17.8753,9.271501328125,17.8055Q9.224801328125,17.7356,9.192641328125,17.6579Q9.160481328125,17.5803,9.144081328125,17.4978Q9.127681328125,17.4154,9.127681328125,17.3314ZM17.273611328125,17.3295C17.272611328125,17.8015,17.654911328125,18.1847,18.126911328125,18.1847L19.408411328125,18.1847C19.879011328125,18.1847,20.260711328125,17.8038,20.261811328125,17.3332L20.266411328125,15.2107L20.266411328125,15.2069L20.261811328125,13.0844C20.260711328125,12.6138,19.879011328125,12.2329,19.408411328125,12.2329L18.126911328125,12.2329C17.654911328125,12.2329,17.272611328125,12.6161,17.273611328125,13.0881L17.278211328125,15.2069L17.278211328125,15.2107L17.273611328125,17.3295ZM13.574711328125,28.0523C21.552211328125,28.0523,24.559311328125,22.3153,25.605811328125,19.1897C26.001411328125,18.0098,27.107111328125,17.215,28.351511328125,17.2158C30.323811328125,17.2158,31.711511328125,19.1416,31.102611328125,21.0181C30.552411328125,22.7189,29.716211328125,24.3134,28.629811328125,25.733L30.137611328125,30.2235L24.775211328125,29.3432C14.645911328125,36.0484,1.048779328125,29.3346,0.214111328125,17.2158Q2.611231328125,28.0523,13.574711328125,28.0523Z'%20fill-rule='evenodd'%20fill='url(%23master_svg1_93_40276)'%20fill-opacity='1'/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",oI=[{id:"codex",titleKey:"auth_login.codex_oauth_title",hintKey:"auth_login.codex_oauth_hint",urlLabelKey:"auth_login.codex_oauth_url_label",icon:{light:u2,dark:d2}},{id:"anthropic",titleKey:"auth_login.anthropic_oauth_title",hintKey:"auth_login.anthropic_oauth_hint",urlLabelKey:"auth_login.anthropic_oauth_url_label",icon:KP},{id:"antigravity",titleKey:"auth_login.antigravity_oauth_title",hintKey:"auth_login.antigravity_oauth_hint",urlLabelKey:"auth_login.antigravity_oauth_url_label",icon:sI},{id:"gemini-cli",titleKey:"auth_login.gemini_cli_oauth_title",hintKey:"auth_login.gemini_cli_oauth_hint",urlLabelKey:"auth_login.gemini_cli_oauth_url_label",icon:VP},{id:"qwen",titleKey:"auth_login.qwen_oauth_title",hintKey:"auth_login.qwen_oauth_hint",urlLabelKey:"auth_login.qwen_oauth_url_label",icon:aI}],lI=["codex","anthropic","antigravity","gemini-cli"],cI=i=>i.replace("-","_"),io=(i,e)=>`auth_login.${cI(i)}_${e}`,uI=(i,e)=>typeof i=="string"?i:i[e];function dI(){const{t:i}=rt(),{showNotification:e}=Zn(),t=_r(A=>A.resolvedTheme),[n,s]=N.useState({}),[a,r]=N.useState({cookie:"",loading:!1}),[o,c]=N.useState({fileName:"",location:"",loading:!1}),d=N.useRef({}),h=N.useRef(null);N.useEffect(()=>()=>{Object.values(d.current).forEach(A=>window.clearInterval(A))},[]);const p=(A,C)=>{s(P=>{var R;return ee(z({},P),{[A]:z(z({},(R=P[A])!=null?R:{}),C)})})},_=(A,C)=>{d.current[A]&&clearInterval(d.current[A]);const P=window.setInterval(()=>pe(null,null,function*(){try{const R=yield im.getAuthStatus(C);R.status==="ok"?(p(A,{status:"success",polling:!1}),e(i(io(A,"oauth_status_success")),"success"),window.clearInterval(P),delete d.current[A]):R.status==="error"&&(p(A,{status:"error",error:R.error,polling:!1}),e(`${i(io(A,"oauth_status_error"))} ${R.error||""}`,"error"),window.clearInterval(P),delete d.current[A])}catch(R){p(A,{status:"error",error:R==null?void 0:R.message,polling:!1}),window.clearInterval(P),delete d.current[A]}}),3e3);d.current[A]=P},y=A=>pe(null,null,function*(){var P;const C=A==="gemini-cli"?(((P=n[A])==null?void 0:P.projectId)||"").trim():void 0;A==="gemini-cli"&&p(A,{projectIdError:void 0}),p(A,{status:"waiting",polling:!0,error:void 0,callbackStatus:void 0,callbackError:void 0,callbackUrl:""});try{const R=yield im.startAuth(A,A==="gemini-cli"?{projectId:C||void 0}:void 0);p(A,{url:R.url,state:R.state,status:"waiting",polling:!0}),R.state&&_(A,R.state)}catch(R){p(A,{status:"error",error:R==null?void 0:R.message,polling:!1}),e(`${i(io(A,"oauth_start_error"))} ${(R==null?void 0:R.message)||""}`,"error")}}),x=A=>pe(null,null,function*(){if(A)try{yield navigator.clipboard.writeText(A),e(i("notification.link_copied"),"success")}catch(C){e("Copy failed","error")}}),v=A=>pe(null,null,function*(){var P;const C=(((P=n[A])==null?void 0:P.callbackUrl)||"").trim();if(!C){e(i("auth_login.oauth_callback_required"),"warning");return}p(A,{callbackSubmitting:!0,callbackStatus:void 0,callbackError:void 0});try{yield im.submitCallback(A,C),p(A,{callbackSubmitting:!1,callbackStatus:"success"}),e(i("auth_login.oauth_callback_success"),"success")}catch(R){const E=(R==null?void 0:R.status)===404?i("auth_login.oauth_callback_upgrade_hint",{defaultValue:"Please update CLI Proxy API or check the connection."}):R==null?void 0:R.message;p(A,{callbackSubmitting:!1,callbackStatus:"error",callbackError:E});const L=E?`${i("auth_login.oauth_callback_error")} ${E}`:i("auth_login.oauth_callback_error");e(L,"error")}}),w=()=>pe(null,null,function*(){const A=a.cookie.trim();if(!A){e(i("auth_login.iflow_cookie_required"),"warning");return}r(C=>ee(z({},C),{loading:!0,error:void 0,errorType:void 0,result:void 0}));try{const C=yield im.iflowCookieAuth(A);C.status==="ok"?(r(P=>ee(z({},P),{loading:!1,result:C})),e(i("auth_login.iflow_cookie_status_success"),"success")):(r(P=>ee(z({},P),{loading:!1,error:C.error,errorType:"error"})),e(`${i("auth_login.iflow_cookie_status_error")} ${C.error||""}`,"error"))}catch(C){if((C==null?void 0:C.status)===409){const P=i("auth_login.iflow_cookie_config_duplicate");r(R=>ee(z({},R),{loading:!1,error:P,errorType:"warning"})),e(P,"warning");return}r(P=>ee(z({},P),{loading:!1,error:C==null?void 0:C.message,errorType:"error"})),e(`${i("auth_login.iflow_cookie_start_error")} ${(C==null?void 0:C.message)||""}`,"error")}}),k=()=>{var A;(A=h.current)==null||A.click()},M=A=>{var P;const C=(P=A.target.files)==null?void 0:P[0];if(C){if(!C.name.endsWith(".json")){e(i("vertex_import.file_required"),"warning"),A.target.value="";return}c(R=>ee(z({},R),{file:C,fileName:C.name,error:void 0,result:void 0})),A.target.value=""}},O=()=>pe(null,null,function*(){var C;if(!o.file){const P=i("vertex_import.file_required");c(R=>ee(z({},R),{error:P})),e(P,"warning");return}const A=o.location.trim();c(P=>ee(z({},P),{loading:!0,error:void 0,result:void 0}));try{const P=yield dq.importCredential(o.file,A||void 0),R={projectId:P.project_id,email:P.email,location:P.location,authFile:(C=P["auth-file"])!=null?C:P.auth_file};c(E=>ee(z({},E),{loading:!1,result:R})),e(i("vertex_import.success"),"success")}catch(P){const R=(P==null?void 0:P.message)||"";c(L=>ee(z({},L),{loading:!1,error:R||i("notification.upload_failed")}));const E=R?`${i("notification.upload_failed")}: ${R}`:i("notification.upload_failed");e(E,"error")}});return g.jsxs("div",{className:ji.container,children:[g.jsx("h1",{className:ji.pageTitle,children:i("nav.oauth",{defaultValue:"OAuth"})}),g.jsxs("div",{className:ji.content,children:[oI.map(A=>{const C=n[A.id]||{},P=lI.includes(A.id)&&!!C.url;return g.jsx("div",{children:g.jsxs(vt,{title:g.jsxs("span",{className:ji.cardTitle,children:[g.jsx("img",{src:uI(A.icon,t),alt:"",className:ji.cardTitleIcon}),i(A.titleKey)]}),extra:g.jsx(ye,{onClick:()=>y(A.id),loading:C.polling,children:i("common.login")}),children:[g.jsx("div",{className:"hint",children:i(A.hintKey)}),A.id==="gemini-cli"&&g.jsx("div",{className:ji.geminiProjectField,children:g.jsx(et,{label:i("auth_login.gemini_cli_project_id_label"),hint:i("auth_login.gemini_cli_project_id_hint"),value:C.projectId||"",error:C.projectIdError,onChange:R=>p(A.id,{projectId:R.target.value,projectIdError:void 0}),placeholder:i("auth_login.gemini_cli_project_id_placeholder")})}),C.url&&g.jsxs("div",{className:`connection-box ${ji.authUrlBox}`,children:[g.jsx("div",{className:ji.authUrlLabel,children:i(A.urlLabelKey)}),g.jsx("div",{className:ji.authUrlValue,children:C.url}),g.jsxs("div",{className:ji.authUrlActions,children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>x(C.url),children:i(io(A.id,"copy_link"))}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>window.open(C.url,"_blank","noopener,noreferrer"),children:i(io(A.id,"open_link"))})]})]}),P&&g.jsxs("div",{className:ji.callbackSection,children:[g.jsx(et,{label:i("auth_login.oauth_callback_label"),hint:i("auth_login.oauth_callback_hint"),value:C.callbackUrl||"",onChange:R=>p(A.id,{callbackUrl:R.target.value,callbackStatus:void 0,callbackError:void 0}),placeholder:i("auth_login.oauth_callback_placeholder")}),g.jsx("div",{className:ji.callbackActions,children:g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>v(A.id),loading:C.callbackSubmitting,children:i("auth_login.oauth_callback_button")})}),C.callbackStatus==="success"&&C.status==="waiting"&&g.jsx("div",{className:"status-badge success",style:{marginTop:8},children:i("auth_login.oauth_callback_status_success")}),C.callbackStatus==="error"&&g.jsxs("div",{className:"status-badge error",style:{marginTop:8},children:[i("auth_login.oauth_callback_status_error")," ",C.callbackError||""]})]}),C.status&&C.status!=="idle"&&g.jsx("div",{className:"status-badge",style:{marginTop:8},children:C.status==="success"?i(io(A.id,"oauth_status_success")):C.status==="error"?`${i(io(A.id,"oauth_status_error"))} ${C.error||""}`:i(io(A.id,"oauth_status_waiting"))})]})},A.id)}),g.jsxs(vt,{title:g.jsxs("span",{className:ji.cardTitle,children:[g.jsx("img",{src:IP,alt:"",className:ji.cardTitleIcon}),i("vertex_import.title")]}),extra:g.jsx(ye,{onClick:O,loading:o.loading,children:i("vertex_import.import_button")}),children:[g.jsx("div",{className:"hint",children:i("vertex_import.description")}),g.jsx(et,{label:i("vertex_import.location_label"),hint:i("vertex_import.location_hint"),value:o.location,onChange:A=>c(C=>ee(z({},C),{location:A.target.value})),placeholder:i("vertex_import.location_placeholder")}),g.jsxs("div",{className:"form-group",children:[g.jsx("label",{children:i("vertex_import.file_label")}),g.jsxs("div",{className:ji.filePicker,children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:k,children:i("vertex_import.choose_file")}),g.jsx("div",{className:`${ji.fileName} ${o.fileName?"":ji.fileNamePlaceholder}`.trim(),children:o.fileName||i("vertex_import.file_placeholder")})]}),g.jsx("div",{className:"hint",children:i("vertex_import.file_hint")}),g.jsx("input",{ref:h,type:"file",accept:".json,application/json",style:{display:"none"},onChange:M})]}),o.error&&g.jsx("div",{className:"status-badge error",style:{marginTop:8},children:o.error}),o.result&&g.jsxs("div",{className:"connection-box",style:{marginTop:12},children:[g.jsx("div",{className:"label",children:i("vertex_import.result_title")}),g.jsxs("div",{className:"key-value-list",children:[o.result.projectId&&g.jsxs("div",{className:"key-value-item",children:[g.jsx("span",{className:"key",children:i("vertex_import.result_project")}),g.jsx("span",{className:"value",children:o.result.projectId})]}),o.result.email&&g.jsxs("div",{className:"key-value-item",children:[g.jsx("span",{className:"key",children:i("vertex_import.result_email")}),g.jsx("span",{className:"value",children:o.result.email})]}),o.result.location&&g.jsxs("div",{className:"key-value-item",children:[g.jsx("span",{className:"key",children:i("vertex_import.result_location")}),g.jsx("span",{className:"value",children:o.result.location})]}),o.result.authFile&&g.jsxs("div",{className:"key-value-item",children:[g.jsx("span",{className:"key",children:i("vertex_import.result_file")}),g.jsx("span",{className:"value",children:o.result.authFile})]})]})]})]}),g.jsxs(vt,{title:g.jsxs("span",{className:ji.cardTitle,children:[g.jsx("img",{src:rI,alt:"",className:ji.cardTitleIcon}),i("auth_login.iflow_cookie_title")]}),extra:g.jsx(ye,{onClick:w,loading:a.loading,children:i("auth_login.iflow_cookie_button")}),children:[g.jsx("div",{className:"hint",children:i("auth_login.iflow_cookie_hint")}),g.jsx("div",{className:"hint",style:{marginTop:4},children:i("auth_login.iflow_cookie_key_hint")}),g.jsxs("div",{className:"form-item",style:{marginTop:12},children:[g.jsx("label",{className:"label",children:i("auth_login.iflow_cookie_label")}),g.jsx(et,{value:a.cookie,onChange:A=>r(C=>ee(z({},C),{cookie:A.target.value})),placeholder:i("auth_login.iflow_cookie_placeholder")})]}),a.error&&g.jsxs("div",{className:`status-badge ${a.errorType==="warning"?"warning":"error"}`,style:{marginTop:8},children:[a.errorType==="warning"?i("auth_login.iflow_cookie_status_duplicate"):i("auth_login.iflow_cookie_status_error")," ",a.error]}),a.result&&a.result.status==="ok"&&g.jsxs("div",{className:"connection-box",style:{marginTop:12},children:[g.jsx("div",{className:"label",children:i("auth_login.iflow_cookie_result_title")}),g.jsxs("div",{className:"key-value-list",children:[a.result.email&&g.jsxs("div",{className:"key-value-item",children:[g.jsx("span",{className:"key",children:i("auth_login.iflow_cookie_result_email")}),g.jsx("span",{className:"value",children:a.result.email})]}),a.result.expired&&g.jsxs("div",{className:"key-value-item",children:[g.jsx("span",{className:"key",children:i("auth_login.iflow_cookie_result_expired")}),g.jsx("span",{className:"value",children:a.result.expired})]}),a.result.saved_path&&g.jsxs("div",{className:"key-value-item",children:[g.jsx("span",{className:"key",children:i("auth_login.iflow_cookie_result_path")}),g.jsx("span",{className:"value",children:a.result.saved_path})]}),a.result.type&&g.jsxs("div",{className:"key-value-item",children:[g.jsx("span",{className:"key",children:i("auth_login.iflow_cookie_result_type")}),g.jsx("span",{className:"value",children:a.result.type})]})]})]})]})]})]})}const KO={qwen:{light:{bg:"#e8f5e9",text:"#2e7d32"},dark:{bg:"#1b5e20",text:"#81c784"}},gemini:{light:{bg:"#e3f2fd",text:"#1565c0"},dark:{bg:"#0d47a1",text:"#64b5f6"}},"gemini-cli":{light:{bg:"#e7efff",text:"#1e4fa3"},dark:{bg:"#1c3f73",text:"#a8c7ff"}},aistudio:{light:{bg:"#f0f2f5",text:"#2f343c"},dark:{bg:"#373c42",text:"#cfd3db"}},claude:{light:{bg:"#fce4ec",text:"#c2185b"},dark:{bg:"#880e4f",text:"#f48fb1"}},codex:{light:{bg:"#fff3e0",text:"#ef6c00"},dark:{bg:"#e65100",text:"#ffb74d"}},antigravity:{light:{bg:"#e0f7fa",text:"#006064"},dark:{bg:"#004d40",text:"#80deea"}},iflow:{light:{bg:"#f3e5f5",text:"#7b1fa2"},dark:{bg:"#4a148c",text:"#ce93d8"}},empty:{light:{bg:"#f5f5f5",text:"#616161"},dark:{bg:"#424242",text:"#bdbdbd"}},unknown:{light:{bg:"#f0f0f0",text:"#666666",border:"1px dashed #999999"},dark:{bg:"#3a3a3a",text:"#aaaaaa",border:"1px dashed #666666"}}},hI=["https://daily-cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels","https://daily-cloudcode-pa.sandbox.googleapis.com/v1internal:fetchAvailableModels","https://cloudcode-pa.googleapis.com/v1internal:fetchAvailableModels"],fI={Authorization:"Bearer $TOKEN$","Content-Type":"application/json","User-Agent":"antigravity/1.11.5 windows/amd64"},pI=[{id:"claude-gpt",label:"Claude/GPT",identifiers:["claude-sonnet-4-5-thinking","claude-opus-4-5-thinking","claude-sonnet-4-5","gpt-oss-120b-medium"]},{id:"gemini-3-pro",label:"Gemini 3 Pro",identifiers:["gemini-3-pro-high","gemini-3-pro-low"]},{id:"gemini-2-5-flash",label:"Gemini 2.5 Flash",identifiers:["gemini-2.5-flash","gemini-2.5-flash-thinking"]},{id:"gemini-2-5-flash-lite",label:"Gemini 2.5 Flash Lite",identifiers:["gemini-2.5-flash-lite"]},{id:"gemini-2-5-cu",label:"Gemini 2.5 CU",identifiers:["rev19-uic3-1p"]},{id:"gemini-3-flash",label:"Gemini 3 Flash",identifiers:["gemini-3-flash"]},{id:"gemini-image",label:"gemini-3-pro-image",identifiers:["gemini-3-pro-image"],labelFromModel:!0}],mI="https://cloudcode-pa.googleapis.com/v1internal:retrieveUserQuota",gI={Authorization:"Bearer $TOKEN$","Content-Type":"application/json"},_I=[{id:"gemini-2-5-flash-series",label:"Gemini 2.5 Flash Series",modelIds:["gemini-2.5-flash","gemini-2.5-flash-lite"]},{id:"gemini-2-5-pro",label:"Gemini 2.5 Pro",modelIds:["gemini-2.5-pro"]},{id:"gemini-3-pro-preview",label:"Gemini 3 Pro Preview",modelIds:["gemini-3-pro-preview"]},{id:"gemini-3-flash-preview",label:"Gemini 3 Flash Preview",modelIds:["gemini-3-flash-preview"]}],yI=new Map(_I.flatMap(i=>i.modelIds.map(e=>[e,i]))),xI=["gemini-2.0-flash"],bI="https://chatgpt.com/backend-api/wham/usage",vI={Authorization:"Bearer $TOKEN$","Content-Type":"application/json","User-Agent":"codex_cli_rs/0.76.0 (Debian 13.0.0; x86_64) WindowsTerminal"};function h2(i){if(typeof i=="number"&&Number.isFinite(i))return i.toString();if(typeof i=="string"){const e=i.trim();return e||null}return null}function rh(i){if(typeof i=="string"){const e=i.trim();return e||null}return typeof i=="number"&&Number.isFinite(i)?i.toString():null}function Ph(i){if(typeof i=="number"&&Number.isFinite(i))return i;if(typeof i=="string"){const e=i.trim();if(!e)return null;const t=Number(e);return Number.isFinite(t)?t:null}return null}function YP(i){const e=Ph(i);if(e!==null)return e;if(typeof i=="string"){const t=i.trim();if(!t)return null;if(t.endsWith("%")){const n=Number(t.slice(0,-1));return Number.isFinite(n)?n/100:null}}return null}function Ng(i){const e=rh(i);return e?e.toLowerCase():null}function SI(i){const e=i.trim();if(!e)return null;try{const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");if(typeof window!="undefined"&&typeof window.atob=="function")return window.atob(n);if(typeof atob=="function")return atob(n)}catch(t){return null}return null}function wI(i){if(!i)return null;if(typeof i=="object")return Array.isArray(i)?null:i;if(typeof i!="string")return null;const e=i.trim();if(!e)return null;try{const s=JSON.parse(e);if(s&&typeof s=="object")return s}catch(s){}const t=e.split(".");if(t.length<2)return null;const n=SI(t[1]);if(!n)return null;try{const s=JSON.parse(n);if(s&&typeof s=="object")return s}catch(s){return null}return null}function kI(i){if(i==null)return null;if(typeof i=="string"){const e=i.trim();if(!e)return null;try{return JSON.parse(e)}catch(t){return null}}return typeof i=="object"?i:null}function AI(i){if(i==null)return null;if(typeof i=="string"){const e=i.trim();if(!e)return null;try{return JSON.parse(e)}catch(t){return null}}return typeof i=="object"?i:null}function CI(i){if(i==null)return null;if(typeof i=="string"){const e=i.trim();if(!e)return null;try{return JSON.parse(e)}catch(t){return null}}return typeof i=="object"?i:null}function OI(i){var t;const e=wI(i);return e?rh((t=e.chatgpt_account_id)!=null?t:e.chatgptAccountId):null}function TI(i){const e=i&&typeof i.metadata=="object"&&i.metadata!==null?i.metadata:null,t=i&&typeof i.attributes=="object"&&i.attributes!==null?i.attributes:null,n=[i.id_token,e==null?void 0:e.id_token,t==null?void 0:t.id_token];for(const s of n){const a=OI(s);if(a)return a}return null}function MI(i){const e=i&&typeof i.metadata=="object"&&i.metadata!==null?i.metadata:null,t=i&&typeof i.attributes=="object"&&i.attributes!==null?i.attributes:null,n=i&&typeof i.id_token=="object"&&i.id_token!==null?i.id_token:null,s=e&&typeof e.id_token=="object"&&e.id_token!==null?e.id_token:null,a=[i.plan_type,i.planType,i.plan_type,i.planType,i.id_token,n==null?void 0:n.plan_type,n==null?void 0:n.planType,e==null?void 0:e.plan_type,e==null?void 0:e.planType,e==null?void 0:e.id_token,s==null?void 0:s.plan_type,s==null?void 0:s.planType,t==null?void 0:t.plan_type,t==null?void 0:t.planType,t==null?void 0:t.id_token];for(const r of a){const o=Ng(r);if(o)return o}return null}function NI(i){var n,s;if(typeof i!="string")return null;const e=Array.from(i.matchAll(/\(([^()]+)\)/g));if(e.length===0)return null;const t=(s=(n=e[e.length-1])==null?void 0:n[1])==null?void 0:s.trim();return t||null}function RI(i){const e=i&&typeof i.metadata=="object"&&i.metadata!==null?i.metadata:null,t=i&&typeof i.attributes=="object"&&i.attributes!==null?i.attributes:null,n=[i.account,i.account,e==null?void 0:e.account,t==null?void 0:t.account];for(const s of n){const a=NI(s);if(a)return a}return null}function ZP(i){if(!i)return"-";const e=new Date(i);return Number.isNaN(e.getTime())?"-":e.toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1})}function VO(i){if(!i)return"-";const e=new Date(i*1e3);return Number.isNaN(e.getTime())?"-":e.toLocaleString(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hour12:!1})}function PI(i){var n,s;if(!i)return"-";const e=Ph((n=i.reset_at)!=null?n:i.resetAt);if(e!==null&&e>0)return VO(e);const t=Ph((s=i.reset_after_seconds)!=null?s:i.resetAfterSeconds);if(t!==null&&t>0){const a=Math.floor(Date.now()/1e3+t);return VO(a)}return"-"}function f2(i,e){const t=new Error(i);return e!==void 0&&(t.status=e),t}function JP(i){if(typeof i=="object"&&i!==null&&"status"in i){const e=i.status;if(typeof e=="number"&&Number.isFinite(e))return e;const t=Number(e);if(Number.isFinite(t)&&t>0)return t}}function p2(i){var t,n;const e=(n=(t=i.provider)!=null?t:i.type)!=null?n:"";return String(e).trim().toLowerCase()}function LI(i){return p2(i)==="antigravity"}function jI(i){return p2(i)==="codex"}function EI(i){return p2(i)==="gemini-cli"}function DI(i){var t;const e=(t=i.runtime_only)!=null?t:i.runtimeOnly;return typeof e=="boolean"?e:typeof e=="string"?e.trim().toLowerCase()==="true":!1}function UI(i){return xI.some(e=>i===e||i.startsWith(`${e}-`))}function FI(i,e){if(!i)return e;if(!e)return i;const t=new Date(i).getTime(),n=new Date(e).getTime();return Number.isNaN(t)?e:Number.isNaN(n)||t<=n?i:e}function IO(i,e){return i===null?e:e===null?i:Math.min(i,e)}function BI(i){if(i.length===0)return[];const e=new Map;return i.forEach(t=>{var d,h,p;if(UI(t.modelId))return;const n=yI.get(t.modelId),s=(d=n==null?void 0:n.id)!=null?d:t.modelId,a=(h=n==null?void 0:n.label)!=null?h:t.modelId,r=(p=t.tokenType)!=null?p:"",o=`${s}::${r}`,c=e.get(o);if(!c){e.set(o,{id:`${s}${r?`-${r}`:""}`,label:a,remainingFraction:t.remainingFraction,remainingAmount:t.remainingAmount,resetTime:t.resetTime,tokenType:t.tokenType,modelIds:[t.modelId]});return}c.remainingFraction=IO(c.remainingFraction,t.remainingFraction),c.remainingAmount=IO(c.remainingAmount,t.remainingAmount),c.resetTime=FI(c.resetTime,t.resetTime),c.modelIds.push(t.modelId)}),Array.from(e.values()).map(t=>{const n=Array.from(new Set(t.modelIds));return{id:t.id,label:t.label,remainingFraction:t.remainingFraction,remainingAmount:t.remainingAmount,resetTime:t.resetTime,tokenType:t.tokenType,modelIds:n}})}function zI(i){var o,c,d,h,p;if(!i)return{remainingFraction:null};const e=(c=(o=i.quotaInfo)!=null?o:i.quota_info)!=null?c:{},t=(h=(d=e.remainingFraction)!=null?d:e.remaining_fraction)!=null?h:e.remaining,n=YP(t),s=(p=e.resetTime)!=null?p:e.reset_time,a=typeof s=="string"?s:void 0,r=typeof i.displayName=="string"?i.displayName:void 0;return{remainingFraction:n,resetTime:a,displayName:r}}function qI(i,e){const t=i[e];if(t)return{id:e,entry:t};const n=Object.entries(i).find(([,s])=>(typeof(s==null?void 0:s.displayName)=="string"?s.displayName:"").toLowerCase()===e.toLowerCase());return n?{id:n[0],entry:n[1]}:null}function HI(i){const e=[];let t;const[n,s,a,r,o,c,d]=pI,h=(M,O)=>{const C=M.identifiers.map(D=>qI(i,D)).filter(D=>!!D).map(({id:D,entry:q})=>{var W;const B=zI(q),H=(W=B.remainingFraction)!=null?W:B.resetTime?0:null;return H===null?null:{id:D,remainingFraction:H,resetTime:B.resetTime,displayName:B.displayName}}).filter(D=>D!==null);if(C.length===0)return null;const P=Math.min(...C.map(D=>D.remainingFraction)),R=O!=null?O:C.map(D=>D.resetTime).find(Boolean),E=C.map(D=>D.displayName).find(Boolean),L=M.labelFromModel&&E?E:M.label;return{id:M.id,label:L,models:C.map(D=>D.id),remainingFraction:P,resetTime:R}},p=h(n);p&&e.push(p);const _=h(s);_&&(t=_.resetTime,e.push(_));const y=h(a);y&&e.push(y);const x=h(r);x&&e.push(x);const v=h(o);v&&e.push(v);const w=h(c);w&&e.push(w);const k=h(d,t);return k&&e.push(k),e}const KI="QuotaPage-module__container___CkTNE",VI="QuotaPage-module__pageHeader___7RVAE",II="QuotaPage-module__pageTitle___c6BF7",WI="QuotaPage-module__description___qDPuI",XI="QuotaPage-module__headerActions___Jfu3A",GI="QuotaPage-module__titleWrapper___lHVCF",QI="QuotaPage-module__countBadge___tuPLs",YI="QuotaPage-module__errorBox___Ub2Qs",ZI="QuotaPage-module__pageSizeSelect___1AaaU",JI="QuotaPage-module__statsInfo___coFxw",$I="QuotaPage-module__antigravityGrid___d29-f",eW="QuotaPage-module__codexGrid___gQjcK",tW="QuotaPage-module__geminiCliGrid___R6KEW",iW="QuotaPage-module__antigravityControls___jdhuf",nW="QuotaPage-module__codexControls___ZabMA",sW="QuotaPage-module__geminiCliControls___aWZsx",aW="QuotaPage-module__antigravityControl___Z2Ti6",rW="QuotaPage-module__codexControl___P4r4g",oW="QuotaPage-module__geminiCliControl___SIXi-",lW="QuotaPage-module__viewModeToggle___BHo1O",cW="QuotaPage-module__antigravityCard___0jKaG",uW="QuotaPage-module__codexCard___2xhZX",dW="QuotaPage-module__geminiCliCard___i8Qjn",hW="QuotaPage-module__quotaSection___Yb6bk",fW="QuotaPage-module__quotaRow___uNjD0",pW="QuotaPage-module__quotaRowHeader___jr9zd",mW="QuotaPage-module__quotaModel___-3mcR",gW="QuotaPage-module__quotaBar___ATY20",_W="QuotaPage-module__quotaBarFill___arMGf",yW="QuotaPage-module__quotaBarFillHigh___yfdzz",xW="QuotaPage-module__quotaBarFillMedium___PbU2j",bW="QuotaPage-module__quotaBarFillLow___1dvgT",vW="QuotaPage-module__quotaMeta___2Gr-S",SW="QuotaPage-module__quotaPercent___dwFKN",wW="QuotaPage-module__quotaReset___AQC0c",kW="QuotaPage-module__quotaAmount___liJkK",AW="QuotaPage-module__quotaMessage___tXEKQ",CW="QuotaPage-module__quotaError___rIKP-",OW="QuotaPage-module__quotaWarning___phfIc",TW="QuotaPage-module__codexPlan___cNsir",MW="QuotaPage-module__codexPlanLabel___NR4tn",NW="QuotaPage-module__codexPlanValue___TZDzO",RW="QuotaPage-module__fileCard___7ZTk-",PW="QuotaPage-module__cardHeader___vBGld",LW="QuotaPage-module__typeBadge___ubtCA",jW="QuotaPage-module__fileName___ATlvN",EW="QuotaPage-module__pagination___W2eGv",DW="QuotaPage-module__pageInfo___yNU7E",UW="QuotaPage-module__warningOverlay___lVjB7",FW="QuotaPage-module__warningModal___2pPNd",$e={container:KI,pageHeader:VI,pageTitle:II,description:WI,headerActions:XI,titleWrapper:GI,countBadge:QI,errorBox:YI,pageSizeSelect:ZI,statsInfo:JI,antigravityGrid:$I,codexGrid:eW,geminiCliGrid:tW,antigravityControls:iW,codexControls:nW,geminiCliControls:sW,antigravityControl:aW,codexControl:rW,geminiCliControl:oW,viewModeToggle:lW,antigravityCard:cW,codexCard:uW,geminiCliCard:dW,quotaSection:hW,quotaRow:fW,quotaRowHeader:pW,quotaModel:mW,quotaBar:gW,quotaBarFill:_W,quotaBarFillHigh:yW,quotaBarFillMedium:xW,quotaBarFillLow:bW,quotaMeta:vW,quotaPercent:SW,quotaReset:wW,quotaAmount:kW,quotaMessage:AW,quotaError:CW,quotaWarning:OW,codexPlan:TW,codexPlanLabel:MW,codexPlanValue:NW,fileCard:RW,cardHeader:PW,typeBadge:LW,fileName:jW,pagination:EW,pageInfo:DW,warningOverlay:UW,warningModal:FW};function BW({percent:i,highThreshold:e,mediumThreshold:t}){const s=i===null?null:((o,c,d)=>Math.min(d,Math.max(c,o)))(i,0,100),a=s===null?$e.quotaBarFillMedium:s>=e?$e.quotaBarFillHigh:s>=t?$e.quotaBarFillMedium:$e.quotaBarFillLow,r=Math.round(s!=null?s:0);return g.jsx("div",{className:$e.quotaBar,children:g.jsx("div",{className:`${$e.quotaBarFill} ${a}`,style:{width:`${r}%`}})})}function zW({item:i,quota:e,resolvedTheme:t,i18nPrefix:n,cardClassName:s,defaultType:a,renderQuotaItems:r}){var x;const{t:o}=rt(),c=i.type||i.provider||a,d=KO[c]||KO.unknown,h=t==="dark"&&d.dark?d.dark:d.light,p=(x=e==null?void 0:e.status)!=null?x:"idle",_=qW(o,e==null?void 0:e.errorStatus,(e==null?void 0:e.error)||o("common.unknown_error")),y=v=>{const w=`auth_files.filter_${v}`,k=o(w);return k!==w?k:v.toLowerCase()==="iflow"?"iFlow":v.charAt(0).toUpperCase()+v.slice(1)};return g.jsxs("div",{className:`${$e.fileCard} ${s}`,children:[g.jsxs("div",{className:$e.cardHeader,children:[g.jsx("span",{className:$e.typeBadge,style:z({backgroundColor:h.bg,color:h.text},h.border?{border:h.border}:{}),children:y(c)}),g.jsx("span",{className:$e.fileName,children:i.name})]}),g.jsx("div",{className:$e.quotaSection,children:p==="loading"?g.jsx("div",{className:$e.quotaMessage,children:o(`${n}.loading`)}):p==="idle"?g.jsx("div",{className:$e.quotaMessage,children:o(`${n}.idle`)}):p==="error"?g.jsx("div",{className:$e.quotaError,children:o(`${n}.load_failed`,{message:_})}):e?r(e,o,{styles:$e,QuotaProgressBar:BW}):g.jsx("div",{className:$e.quotaMessage,children:o(`${n}.idle`)})})]})}const qW=(i,e,t)=>e===404?i("common.quota_update_required"):e===403?i("common.quota_check_credential"):t;function HW(i){const{t:e}=rt(),t=Xx(i.storeSelector),n=Xx(o=>o[i.storeSetter]),s=N.useRef(!1),a=N.useRef(0),r=N.useCallback((o,c,d)=>pe(null,null,function*(){if(s.current)return;s.current=!0;const h=++a.current;d(!0,c);try{if(o.length===0)return;n(_=>{const y=z({},_);return o.forEach(x=>{y[x.name]=i.buildLoadingState()}),y});const p=yield Promise.all(o.map(_=>pe(null,null,function*(){try{const y=yield i.fetchQuota(_,e);return{name:_.name,status:"success",data:y}}catch(y){const x=y instanceof Error?y.message:e("common.unknown_error"),v=JP(y);return{name:_.name,status:"error",error:x,errorStatus:v}}})));if(h!==a.current)return;n(_=>{const y=z({},_);return p.forEach(x=>{x.status==="success"?y[x.name]=i.buildSuccessState(x.data):y[x.name]=i.buildErrorState(x.error||e("common.unknown_error"),x.errorStatus)}),y})}finally{h===a.current&&(d(!1),s.current=!1)}}),[i,n,e]);return{quota:t,loadQuota:r}}function KW(i,e=16){const[t,n]=N.useState(1),[s,a]=N.useState(null),r=N.useCallback(o=>{a(o)},[]);return N.useEffect(()=>{if(!s)return;const o=()=>{const d=s.clientWidth,h=i+e,p=Math.floor((d+e)/h);n(Math.max(1,p))};o();const c=new ResizeObserver(()=>{o()});return c.observe(s),()=>c.disconnect()},[s,i,e]),[t,r]}const VW=14,WO=30,IW=(i,e=6)=>{const[t,n]=N.useState(1),[s,a]=N.useState(e),[r,o]=N.useState(!1),[c,d]=N.useState(null),h=N.useMemo(()=>Math.max(1,Math.ceil(i.length/s)),[i.length,s]),p=N.useMemo(()=>Math.min(t,h),[t,h]),_=N.useMemo(()=>{const k=(p-1)*s;return i.slice(k,k+s)},[i,p,s]),y=N.useCallback(k=>{a(k),n(1)},[]),x=N.useCallback(()=>{n(k=>Math.max(1,k-1))},[]),v=N.useCallback(()=>{n(k=>Math.min(h,k+1))},[h]),w=N.useCallback((k,M)=>{o(k),d(k&&M!=null?M:null)},[]);return{pageSize:s,totalPages:h,currentPage:p,pageItems:_,setPageSize:y,goToPrev:x,goToNext:v,loading:r,loadingScope:c,setLoading:w}};function U1({config:i,files:e,loading:t,disabled:n}){const{t:s}=rt(),a=_r(U=>U.resolvedTheme),r=Xx(U=>U[i.storeSetter]),[o,c]=KW(380),[d,h]=N.useState("paged"),[p,_]=N.useState(!1),y=N.useMemo(()=>e.filter(U=>i.filterFn(U)),[e,i]),x=y.length<=WO,v=d==="all"&&!x?"paged":d,{pageSize:w,totalPages:k,currentPage:M,pageItems:O,setPageSize:A,goToPrev:C,goToNext:P,loading:R,setLoading:E}=IW(y);N.useEffect(()=>{if(x||d!=="all")return;let U=!1;return queueMicrotask(()=>{U||(h("paged"),_(!0))}),()=>{U=!0}},[x,d]),N.useEffect(()=>{A(v==="all"?Math.max(1,y.length):Math.min(o*3,VW))},[v,o,y.length,A]);const{quota:L,loadQuota:D}=HW(i),q=N.useRef(!1),B=N.useRef(t),H=N.useCallback(()=>{q.current=!0,XP()},[]);N.useEffect(()=>{const U=B.current;if(B.current=t,!q.current||t||!U)return;q.current=!1;const G=v==="all"?"all":"page",$=v==="all"?y:O;$.length!==0&&D($,G,E)},[t,v,y,O,D,E]),N.useEffect(()=>{if(!t){if(y.length===0){r({});return}r(U=>{const G={};return y.forEach($=>{const ie=U[$.name];ie&&(G[$.name]=ie)}),G})}},[y,t,r]);const W=g.jsxs("div",{className:$e.titleWrapper,children:[g.jsx("span",{children:s(`${i.i18nPrefix}.title`)}),y.length>0&&g.jsx("span",{className:$e.countBadge,children:y.length})]}),V=R||t;return g.jsxs(vt,{title:W,extra:g.jsxs("div",{className:$e.headerActions,children:[g.jsxs("div",{className:$e.viewModeToggle,children:[g.jsx(ye,{variant:v==="paged"?"primary":"secondary",size:"sm",onClick:()=>h("paged"),children:s("auth_files.view_mode_paged")}),g.jsx(ye,{variant:v==="all"?"primary":"secondary",size:"sm",onClick:()=>{y.length>WO?_(!0):h("all")},children:s("auth_files.view_mode_all")})]}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:H,disabled:n||V,loading:V,title:s("quota_management.refresh_files_and_quota"),"aria-label":s("quota_management.refresh_files_and_quota"),children:!V&&g.jsx(YN,{size:16})})]}),children:[y.length===0?g.jsx(Ps,{title:s(`${i.i18nPrefix}.empty_title`),description:s(`${i.i18nPrefix}.empty_desc`)}):g.jsxs(g.Fragment,{children:[g.jsx("div",{ref:c,className:i.gridClassName,children:O.map(U=>g.jsx(zW,{item:U,quota:L[U.name],resolvedTheme:a,i18nPrefix:i.i18nPrefix,cardClassName:i.cardClassName,defaultType:i.type,renderQuotaItems:i.renderQuotaItems},U.name))}),y.length>w&&v==="paged"&&g.jsxs("div",{className:$e.pagination,children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:C,disabled:M<=1,children:s("auth_files.pagination_prev")}),g.jsx("div",{className:$e.pageInfo,children:s("auth_files.pagination_info",{current:M,total:k,count:y.length})}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:P,disabled:M>=k,children:s("auth_files.pagination_next")})]})]}),p&&g.jsx("div",{className:$e.warningOverlay,onClick:()=>_(!1),children:g.jsxs("div",{className:$e.warningModal,onClick:U=>U.stopPropagation(),children:[g.jsx("p",{children:s("auth_files.too_many_files_warning")}),g.jsx(ye,{variant:"primary",size:"sm",onClick:()=>_(!1),children:s("common.confirm")})]})})]})}const WW=(i,e)=>pe(null,null,function*(){var c,d;const t=(c=i.auth_index)!=null?c:i.authIndex,n=h2(t);if(!n)throw new Error(e("antigravity_quota.missing_auth_index"));let s="",a,r,o=!1;for(const h of hI)try{const p=yield df.request({authIndex:n,method:"POST",url:h,header:z({},fI),data:"{}"});if(p.statusCode<200||p.statusCode>=300){s=uf(p),a=p.statusCode,(p.statusCode===403||p.statusCode===404)&&(r!=null||(r=p.statusCode));continue}o=!0;const _=kI((d=p.body)!=null?d:p.bodyText),y=_==null?void 0:_.models;if(!y||typeof y!="object"||Array.isArray(y)){s=e("antigravity_quota.empty_models");continue}const x=HI(y);if(x.length===0){s=e("antigravity_quota.empty_models");continue}return x}catch(p){s=p instanceof Error?p.message:e("common.unknown_error");const _=JP(p);_&&(a=_,(_===403||_===404)&&(r!=null||(r=_)))}if(o)return[];throw f2(s||e("common.unknown_error"),r!=null?r:a)}),XW=(i,e)=>{var r,o,c,d,h,p,_,y,x,v;const t=(o=(r=i.rate_limit)!=null?r:i.rateLimit)!=null?o:void 0,n=(d=(c=i.code_review_rate_limit)!=null?c:i.codeReviewRateLimit)!=null?d:void 0,s=[],a=(w,k,M,O,A)=>{var L;if(!M)return;const C=PI(M),P=Ph((L=M.used_percent)!=null?L:M.usedPercent),R=!!O||A===!1,E=P!=null?P:R&&C!=="-"?100:null;s.push({id:w,label:e(k),labelKey:k,usedPercent:E,resetLabel:C})};return a("primary","codex_quota.primary_window",(h=t==null?void 0:t.primary_window)!=null?h:t==null?void 0:t.primaryWindow,(p=t==null?void 0:t.limit_reached)!=null?p:t==null?void 0:t.limitReached,t==null?void 0:t.allowed),a("secondary","codex_quota.secondary_window",(_=t==null?void 0:t.secondary_window)!=null?_:t==null?void 0:t.secondaryWindow,(y=t==null?void 0:t.limit_reached)!=null?y:t==null?void 0:t.limitReached,t==null?void 0:t.allowed),a("code-review","codex_quota.code_review_window",(x=n==null?void 0:n.primary_window)!=null?x:n==null?void 0:n.primaryWindow,(v=n==null?void 0:n.limit_reached)!=null?v:n==null?void 0:n.limitReached,n==null?void 0:n.allowed),s},GW=(i,e)=>pe(null,null,function*(){var p,_,y;const t=(p=i.auth_index)!=null?p:i.authIndex,n=h2(t);if(!n)throw new Error(e("codex_quota.missing_auth_index"));const s=MI(i),a=TI(i);if(!a)throw new Error(e("codex_quota.missing_account_id"));const r=ee(z({},vI),{"Chatgpt-Account-Id":a}),o=yield df.request({authIndex:n,method:"GET",url:bI,header:r});if(o.statusCode<200||o.statusCode>=300)throw f2(uf(o),o.statusCode);const c=AI((_=o.body)!=null?_:o.bodyText);if(!c)throw new Error(e("codex_quota.empty_windows"));const d=Ng((y=c.plan_type)!=null?y:c.planType),h=XW(c,e);return{planType:d!=null?d:s,windows:h}}),QW=(i,e)=>pe(null,null,function*(){var d,h;const t=(d=i.auth_index)!=null?d:i.authIndex,n=h2(t);if(!n)throw new Error(e("gemini_cli_quota.missing_auth_index"));const s=RI(i);if(!s)throw new Error(e("gemini_cli_quota.missing_project_id"));const a=yield df.request({authIndex:n,method:"POST",url:mI,header:z({},gI),data:JSON.stringify({project:s})});if(a.statusCode<200||a.statusCode>=300)throw f2(uf(a),a.statusCode);const r=CI((h=a.body)!=null?h:a.bodyText),o=Array.isArray(r==null?void 0:r.buckets)?r==null?void 0:r.buckets:[];if(o.length===0)return[];const c=o.map(p=>{var O,A,C,P,R,E;const _=rh((O=p.modelId)!=null?O:p.model_id);if(!_)return null;const y=rh((A=p.tokenType)!=null?A:p.token_type),x=YP((C=p.remainingFraction)!=null?C:p.remaining_fraction),v=Ph((P=p.remainingAmount)!=null?P:p.remaining_amount),w=(E=rh((R=p.resetTime)!=null?R:p.reset_time))!=null?E:void 0;let k=null;v!==null?k=v<=0?0:null:w&&(k=0);const M=x!=null?x:k;return{modelId:_,tokenType:y,remainingFraction:M,remainingAmount:v,resetTime:w}}).filter(p=>p!==null);return BI(c)}),YW=(i,e,t)=>{var o;const{styles:n,QuotaProgressBar:s}=t,{createElement:a}=pl,r=(o=i.groups)!=null?o:[];return r.length===0?a("div",{className:n.quotaMessage},e("antigravity_quota.empty_models")):r.map(c=>{const d=Math.max(0,Math.min(1,c.remainingFraction)),h=Math.round(d*100),p=ZP(c.resetTime);return a("div",{key:c.id,className:n.quotaRow},a("div",{className:n.quotaRowHeader},a("span",{className:n.quotaModel,title:c.models.join(", ")},c.label),a("div",{className:n.quotaMeta},a("span",{className:n.quotaPercent},`${h}%`),a("span",{className:n.quotaReset},p))),a(s,{percent:h,highThreshold:60,mediumThreshold:20}))})},ZW=(i,e,t)=>{var y,x;const{styles:n,QuotaProgressBar:s}=t,{createElement:a,Fragment:r}=pl,o=(y=i.windows)!=null?y:[],c=(x=i.planType)!=null?x:null,h=(v=>{const w=Ng(v);return w?w==="plus"?e("codex_quota.plan_plus"):w==="team"?e("codex_quota.plan_team"):w==="free"?e("codex_quota.plan_free"):v||w:null})(c),p=Ng(c)==="free",_=[];return h&&_.push(a("div",{key:"plan",className:n.codexPlan},a("span",{className:n.codexPlanLabel},e("codex_quota.plan_label")),a("span",{className:n.codexPlanValue},h))),p?(_.push(a("div",{key:"warning",className:n.quotaWarning},e("codex_quota.no_access"))),a(r,null,..._)):o.length===0?(_.push(a("div",{key:"empty",className:n.quotaMessage},e("codex_quota.empty_windows"))),a(r,null,..._)):(_.push(...o.map(v=>{const w=v.usedPercent,k=w===null?null:Math.max(0,Math.min(100,w)),M=k===null?null:Math.max(0,Math.min(100,100-k)),O=M===null?"--":`${Math.round(M)}%`,A=v.labelKey?e(v.labelKey):v.label;return a("div",{key:v.id,className:n.quotaRow},a("div",{className:n.quotaRowHeader},a("span",{className:n.quotaModel},A),a("div",{className:n.quotaMeta},a("span",{className:n.quotaPercent},O),a("span",{className:n.quotaReset},v.resetLabel))),a(s,{percent:M,highThreshold:80,mediumThreshold:50}))})),a(r,null,..._))},JW=(i,e,t)=>{var o;const{styles:n,QuotaProgressBar:s}=t,{createElement:a}=pl,r=(o=i.buckets)!=null?o:[];return r.length===0?a("div",{className:n.quotaMessage},e("gemini_cli_quota.empty_buckets")):r.map(c=>{const d=c.remainingFraction,h=d===null?null:Math.max(0,Math.min(1,d)),p=h===null?null:Math.round(h*100),_=p===null?"--":`${p}%`,y=c.remainingAmount===null||c.remainingAmount===void 0?null:e("gemini_cli_quota.remaining_amount",{count:c.remainingAmount}),x=c.modelIds&&c.modelIds.length>0?c.modelIds.join(", "):c.label,v=c.tokenType?`${x} (${c.tokenType})`:x,w=ZP(c.resetTime);return a("div",{key:c.id,className:n.quotaRow},a("div",{className:n.quotaRowHeader},a("span",{className:n.quotaModel,title:v},c.label),a("div",{className:n.quotaMeta},a("span",{className:n.quotaPercent},_),y?a("span",{className:n.quotaAmount},y):null,a("span",{className:n.quotaReset},w))),a(s,{percent:p,highThreshold:60,mediumThreshold:20}))})},$W={type:"antigravity",i18nPrefix:"antigravity_quota",filterFn:i=>LI(i),fetchQuota:WW,storeSelector:i=>i.antigravityQuota,storeSetter:"setAntigravityQuota",buildLoadingState:()=>({status:"loading",groups:[]}),buildSuccessState:i=>({status:"success",groups:i}),buildErrorState:(i,e)=>({status:"error",groups:[],error:i,errorStatus:e}),cardClassName:$e.antigravityCard,controlsClassName:$e.antigravityControls,controlClassName:$e.antigravityControl,gridClassName:$e.antigravityGrid,renderQuotaItems:YW},eX={type:"codex",i18nPrefix:"codex_quota",filterFn:i=>jI(i),fetchQuota:GW,storeSelector:i=>i.codexQuota,storeSetter:"setCodexQuota",buildLoadingState:()=>({status:"loading",windows:[]}),buildSuccessState:i=>({status:"success",windows:i.windows,planType:i.planType}),buildErrorState:(i,e)=>({status:"error",windows:[],error:i,errorStatus:e}),cardClassName:$e.codexCard,controlsClassName:$e.codexControls,controlClassName:$e.codexControl,gridClassName:$e.codexGrid,renderQuotaItems:ZW},tX={type:"gemini-cli",i18nPrefix:"gemini_cli_quota",filterFn:i=>EI(i)&&!DI(i),fetchQuota:QW,storeSelector:i=>i.geminiCliQuota,storeSetter:"setGeminiCliQuota",buildLoadingState:()=>({status:"loading",buckets:[]}),buildSuccessState:i=>({status:"success",buckets:i}),buildErrorState:(i,e)=>({status:"error",buckets:[],error:i,errorStatus:e}),cardClassName:$e.geminiCliCard,controlsClassName:$e.geminiCliControls,controlClassName:$e.geminiCliControl,gridClassName:$e.geminiCliGrid,renderQuotaItems:JW};function iX(){const{t:i}=rt(),e=Ct(_=>_.connectionStatus),[t,n]=N.useState([]),[s,a]=N.useState(!0),[r,o]=N.useState(""),c=e!=="connected",d=N.useCallback(()=>pe(null,null,function*(){try{yield lb.fetchConfigYaml()}catch(_){const y=_ instanceof Error?_.message:i("notification.refresh_failed");o(x=>x||y)}}),[i]),h=N.useCallback(()=>pe(null,null,function*(){a(!0),o("");try{const _=yield zi.list();n((_==null?void 0:_.files)||[])}catch(_){const y=_ instanceof Error?_.message:i("notification.refresh_failed");o(y)}finally{a(!1)}}),[i]),p=N.useCallback(()=>pe(null,null,function*(){yield Promise.all([d(),h()])}),[d,h]);return M0(p),N.useEffect(()=>{h(),d()},[h,d]),g.jsxs("div",{className:$e.container,children:[g.jsxs("div",{className:$e.pageHeader,children:[g.jsx("h1",{className:$e.pageTitle,children:i("quota_management.title")}),g.jsx("p",{className:$e.description,children:i("quota_management.description")})]}),r&&g.jsx("div",{className:$e.errorBox,children:r}),g.jsx(U1,{config:$W,files:t,loading:s,disabled:c}),g.jsx(U1,{config:eX,files:t,loading:s,disabled:c}),g.jsx(U1,{config:tX,files:t,loading:s,disabled:c})]})}function yf(i){return i+.5|0}const ho=(i,e,t)=>Math.max(Math.min(i,t),e);function Wd(i){return ho(yf(i*2.55),0,255)}function bo(i){return ho(yf(i*255),0,255)}function lr(i){return ho(yf(i/2.55)/100,0,1)}function XO(i){return ho(yf(i*100),0,100)}const Ns={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,A:10,B:11,C:12,D:13,E:14,F:15,a:10,b:11,c:12,d:13,e:14,f:15},cb=[..."0123456789ABCDEF"],nX=i=>cb[i&15],sX=i=>cb[(i&240)>>4]+cb[i&15],am=i=>(i&240)>>4===(i&15),aX=i=>am(i.r)&&am(i.g)&&am(i.b)&&am(i.a);function rX(i){var e=i.length,t;return i[0]==="#"&&(e===4||e===5?t={r:255&Ns[i[1]]*17,g:255&Ns[i[2]]*17,b:255&Ns[i[3]]*17,a:e===5?Ns[i[4]]*17:255}:(e===7||e===9)&&(t={r:Ns[i[1]]<<4|Ns[i[2]],g:Ns[i[3]]<<4|Ns[i[4]],b:Ns[i[5]]<<4|Ns[i[6]],a:e===9?Ns[i[7]]<<4|Ns[i[8]]:255})),t}const oX=(i,e)=>i<255?e(i):"";function lX(i){var e=aX(i)?nX:sX;return i?"#"+e(i.r)+e(i.g)+e(i.b)+oX(i.a,e):void 0}const cX=/^(hsla?|hwb|hsv)\(\s*([-+.e\d]+)(?:deg)?[\s,]+([-+.e\d]+)%[\s,]+([-+.e\d]+)%(?:[\s,]+([-+.e\d]+)(%)?)?\s*\)$/;function $P(i,e,t){const n=e*Math.min(t,1-t),s=(a,r=(a+i/30)%12)=>t-n*Math.max(Math.min(r-3,9-r,1),-1);return[s(0),s(8),s(4)]}function uX(i,e,t){const n=(s,a=(s+i/60)%6)=>t-t*e*Math.max(Math.min(a,4-a,1),0);return[n(5),n(3),n(1)]}function dX(i,e,t){const n=$P(i,1,.5);let s;for(e+t>1&&(s=1/(e+t),e*=s,t*=s),s=0;s<3;s++)n[s]*=1-e-t,n[s]+=e;return n}function hX(i,e,t,n,s){return i===s?(e-t)/n+(e.5?h/(2-a-r):h/(a+r),c=hX(t,n,s,h,a),c=c*60+.5),[c|0,d||0,o]}function g2(i,e,t,n){return(Array.isArray(e)?i(e[0],e[1],e[2]):i(e,t,n)).map(bo)}function _2(i,e,t){return g2($P,i,e,t)}function fX(i,e,t){return g2(dX,i,e,t)}function pX(i,e,t){return g2(uX,i,e,t)}function eL(i){return(i%360+360)%360}function mX(i){const e=cX.exec(i);let t=255,n;if(!e)return;e[5]!==n&&(t=e[6]?Wd(+e[5]):bo(+e[5]));const s=eL(+e[2]),a=+e[3]/100,r=+e[4]/100;return e[1]==="hwb"?n=fX(s,a,r):e[1]==="hsv"?n=pX(s,a,r):n=_2(s,a,r),{r:n[0],g:n[1],b:n[2],a:t}}function gX(i,e){var t=m2(i);t[0]=eL(t[0]+e),t=_2(t),i.r=t[0],i.g=t[1],i.b=t[2]}function _X(i){if(!i)return;const e=m2(i),t=e[0],n=XO(e[1]),s=XO(e[2]);return i.a<255?`hsla(${t}, ${n}%, ${s}%, ${lr(i.a)})`:`hsl(${t}, ${n}%, ${s}%)`}const GO={x:"dark",Z:"light",Y:"re",X:"blu",W:"gr",V:"medium",U:"slate",A:"ee",T:"ol",S:"or",B:"ra",C:"lateg",D:"ights",R:"in",Q:"turquois",E:"hi",P:"ro",O:"al",N:"le",M:"de",L:"yello",F:"en",K:"ch",G:"arks",H:"ea",I:"ightg",J:"wh"},QO={OiceXe:"f0f8ff",antiquewEte:"faebd7",aqua:"ffff",aquamarRe:"7fffd4",azuY:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"0",blanKedOmond:"ffebcd",Xe:"ff",XeviTet:"8a2be2",bPwn:"a52a2a",burlywood:"deb887",caMtXe:"5f9ea0",KartYuse:"7fff00",KocTate:"d2691e",cSO:"ff7f50",cSnflowerXe:"6495ed",cSnsilk:"fff8dc",crimson:"dc143c",cyan:"ffff",xXe:"8b",xcyan:"8b8b",xgTMnPd:"b8860b",xWay:"a9a9a9",xgYF:"6400",xgYy:"a9a9a9",xkhaki:"bdb76b",xmagFta:"8b008b",xTivegYF:"556b2f",xSange:"ff8c00",xScEd:"9932cc",xYd:"8b0000",xsOmon:"e9967a",xsHgYF:"8fbc8f",xUXe:"483d8b",xUWay:"2f4f4f",xUgYy:"2f4f4f",xQe:"ced1",xviTet:"9400d3",dAppRk:"ff1493",dApskyXe:"bfff",dimWay:"696969",dimgYy:"696969",dodgerXe:"1e90ff",fiYbrick:"b22222",flSOwEte:"fffaf0",foYstWAn:"228b22",fuKsia:"ff00ff",gaRsbSo:"dcdcdc",ghostwEte:"f8f8ff",gTd:"ffd700",gTMnPd:"daa520",Way:"808080",gYF:"8000",gYFLw:"adff2f",gYy:"808080",honeyMw:"f0fff0",hotpRk:"ff69b4",RdianYd:"cd5c5c",Rdigo:"4b0082",ivSy:"fffff0",khaki:"f0e68c",lavFMr:"e6e6fa",lavFMrXsh:"fff0f5",lawngYF:"7cfc00",NmoncEffon:"fffacd",ZXe:"add8e6",ZcSO:"f08080",Zcyan:"e0ffff",ZgTMnPdLw:"fafad2",ZWay:"d3d3d3",ZgYF:"90ee90",ZgYy:"d3d3d3",ZpRk:"ffb6c1",ZsOmon:"ffa07a",ZsHgYF:"20b2aa",ZskyXe:"87cefa",ZUWay:"778899",ZUgYy:"778899",ZstAlXe:"b0c4de",ZLw:"ffffe0",lime:"ff00",limegYF:"32cd32",lRF:"faf0e6",magFta:"ff00ff",maPon:"800000",VaquamarRe:"66cdaa",VXe:"cd",VScEd:"ba55d3",VpurpN:"9370db",VsHgYF:"3cb371",VUXe:"7b68ee",VsprRggYF:"fa9a",VQe:"48d1cc",VviTetYd:"c71585",midnightXe:"191970",mRtcYam:"f5fffa",mistyPse:"ffe4e1",moccasR:"ffe4b5",navajowEte:"ffdead",navy:"80",Tdlace:"fdf5e6",Tive:"808000",TivedBb:"6b8e23",Sange:"ffa500",SangeYd:"ff4500",ScEd:"da70d6",pOegTMnPd:"eee8aa",pOegYF:"98fb98",pOeQe:"afeeee",pOeviTetYd:"db7093",papayawEp:"ffefd5",pHKpuff:"ffdab9",peru:"cd853f",pRk:"ffc0cb",plum:"dda0dd",powMrXe:"b0e0e6",purpN:"800080",YbeccapurpN:"663399",Yd:"ff0000",Psybrown:"bc8f8f",PyOXe:"4169e1",saddNbPwn:"8b4513",sOmon:"fa8072",sandybPwn:"f4a460",sHgYF:"2e8b57",sHshell:"fff5ee",siFna:"a0522d",silver:"c0c0c0",skyXe:"87ceeb",UXe:"6a5acd",UWay:"708090",UgYy:"708090",snow:"fffafa",sprRggYF:"ff7f",stAlXe:"4682b4",tan:"d2b48c",teO:"8080",tEstN:"d8bfd8",tomato:"ff6347",Qe:"40e0d0",viTet:"ee82ee",JHt:"f5deb3",wEte:"ffffff",wEtesmoke:"f5f5f5",Lw:"ffff00",LwgYF:"9acd32"};function yX(){const i={},e=Object.keys(QO),t=Object.keys(GO);let n,s,a,r,o;for(n=0;n>16&255,a>>8&255,a&255]}return i}let rm;function xX(i){rm||(rm=yX(),rm.transparent=[0,0,0,0]);const e=rm[i.toLowerCase()];return e&&{r:e[0],g:e[1],b:e[2],a:e.length===4?e[3]:255}}const bX=/^rgba?\(\s*([-+.\d]+)(%)?[\s,]+([-+.e\d]+)(%)?[\s,]+([-+.e\d]+)(%)?(?:[\s,/]+([-+.e\d]+)(%)?)?\s*\)$/;function vX(i){const e=bX.exec(i);let t=255,n,s,a;if(e){if(e[7]!==n){const r=+e[7];t=e[8]?Wd(r):ho(r*255,0,255)}return n=+e[1],s=+e[3],a=+e[5],n=255&(e[2]?Wd(n):ho(n,0,255)),s=255&(e[4]?Wd(s):ho(s,0,255)),a=255&(e[6]?Wd(a):ho(a,0,255)),{r:n,g:s,b:a,a:t}}}function SX(i){return i&&(i.a<255?`rgba(${i.r}, ${i.g}, ${i.b}, ${lr(i.a)})`:`rgb(${i.r}, ${i.g}, ${i.b})`)}const F1=i=>i<=.0031308?i*12.92:Math.pow(i,1/2.4)*1.055-.055,Ec=i=>i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4);function wX(i,e,t){const n=Ec(lr(i.r)),s=Ec(lr(i.g)),a=Ec(lr(i.b));return{r:bo(F1(n+t*(Ec(lr(e.r))-n))),g:bo(F1(s+t*(Ec(lr(e.g))-s))),b:bo(F1(a+t*(Ec(lr(e.b))-a))),a:i.a+t*(e.a-i.a)}}function om(i,e,t){if(i){let n=m2(i);n[e]=Math.max(0,Math.min(n[e]+n[e]*t,e===0?360:1)),n=_2(n),i.r=n[0],i.g=n[1],i.b=n[2]}}function tL(i,e){return i&&Object.assign(e||{},i)}function YO(i){var e={r:0,g:0,b:0,a:255};return Array.isArray(i)?i.length>=3&&(e={r:i[0],g:i[1],b:i[2],a:255},i.length>3&&(e.a=bo(i[3]))):(e=tL(i,{r:0,g:0,b:0,a:1}),e.a=bo(e.a)),e}function kX(i){return i.charAt(0)==="r"?vX(i):mX(i)}class Lh{constructor(e){if(e instanceof Lh)return e;const t=typeof e;let n;t==="object"?n=YO(e):t==="string"&&(n=rX(e)||xX(e)||kX(e)),this._rgb=n,this._valid=!!n}get valid(){return this._valid}get rgb(){var e=tL(this._rgb);return e&&(e.a=lr(e.a)),e}set rgb(e){this._rgb=YO(e)}rgbString(){return this._valid?SX(this._rgb):void 0}hexString(){return this._valid?lX(this._rgb):void 0}hslString(){return this._valid?_X(this._rgb):void 0}mix(e,t){if(e){const n=this.rgb,s=e.rgb;let a;const r=t===a?.5:t,o=2*r-1,c=n.a-s.a,d=((o*c===-1?o:(o+c)/(1+o*c))+1)/2;a=1-d,n.r=255&d*n.r+a*s.r+.5,n.g=255&d*n.g+a*s.g+.5,n.b=255&d*n.b+a*s.b+.5,n.a=r*n.a+(1-r)*s.a,this.rgb=n}return this}interpolate(e,t){return e&&(this._rgb=wX(this._rgb,e._rgb,t)),this}clone(){return new Lh(this.rgb)}alpha(e){return this._rgb.a=bo(e),this}clearer(e){const t=this._rgb;return t.a*=1-e,this}greyscale(){const e=this._rgb,t=yf(e.r*.3+e.g*.59+e.b*.11);return e.r=e.g=e.b=t,this}opaquer(e){const t=this._rgb;return t.a*=1+e,this}negate(){const e=this._rgb;return e.r=255-e.r,e.g=255-e.g,e.b=255-e.b,this}lighten(e){return om(this._rgb,2,e),this}darken(e){return om(this._rgb,2,-e),this}saturate(e){return om(this._rgb,1,e),this}desaturate(e){return om(this._rgb,1,-e),this}rotate(e){return gX(this._rgb,e),this}}function ir(){}const AX=(()=>{let i=0;return()=>i++})();function It(i){return i==null}function Ui(i){if(Array.isArray&&Array.isArray(i))return!0;const e=Object.prototype.toString.call(i);return e.slice(0,7)==="[object"&&e.slice(-6)==="Array]"}function pt(i){return i!==null&&Object.prototype.toString.call(i)==="[object Object]"}function mn(i){return(typeof i=="number"||i instanceof Number)&&isFinite(+i)}function ha(i,e){return mn(i)?i:e}function dt(i,e){return typeof i=="undefined"?e:i}const CX=(i,e)=>typeof i=="string"&&i.endsWith("%")?parseFloat(i)/100*e:+i;function Qt(i,e,t){if(i&&typeof i.call=="function")return i.apply(t,e)}function jt(i,e,t,n){let s,a,r;if(Ui(i))for(a=i.length,s=0;si,x:i=>i.x,y:i=>i.y};function MX(i){const e=i.split("."),t=[];let n="";for(const s of e)n+=s,n.endsWith("\\")?n=n.slice(0,-1)+".":(t.push(n),n="");return t}function NX(i){const e=MX(i);return t=>{for(const n of e){if(n==="")break;t=t&&t[n]}return t}}function Lg(i,e){return(ZO[e]||(ZO[e]=NX(e)))(i)}function y2(i){return i.charAt(0).toUpperCase()+i.slice(1)}const jg=i=>typeof i!="undefined",Ao=i=>typeof i=="function",JO=(i,e)=>{if(i.size!==e.size)return!1;for(const t of i)if(!e.has(t))return!1;return!0};function RX(i){return i.type==="mouseup"||i.type==="click"||i.type==="contextmenu"}const Vi=Math.PI,$s=2*Vi,PX=$s+Vi,Eg=Number.POSITIVE_INFINITY,LX=Vi/180,Zs=Vi/2,nl=Vi/4,$O=Vi*2/3,nL=Math.log10,du=Math.sign;function lh(i,e,t){return Math.abs(i-e)s-a).pop(),e}function EX(i){return typeof i=="symbol"||typeof i=="object"&&i!==null&&!(Symbol.toPrimitive in i||"toString"in i||"valueOf"in i)}function Eh(i){return!EX(i)&&!isNaN(parseFloat(i))&&isFinite(i)}function DX(i,e){const t=Math.round(i);return t-e<=i&&t+e>=i}function UX(i,e,t){let n,s,a;for(n=0,s=i.length;nc&&d=Math.min(e,t)-n&&i<=Math.max(e,t)+n}function x2(i,e,t){t=t||(r=>i[r]1;)a=s+n>>1,t(a)?s=a:n=a;return{lo:s,hi:n}}const bl=(i,e,t,n)=>x2(i,t,n?s=>{const a=i[s][e];return ai[s][e]x2(i,t,n=>i[n][e]>=t);function KX(i,e,t){let n=0,s=i.length;for(;nn&&i[s-1]>t;)s--;return n>0||s{const n="_onData"+y2(t),s=i[t];Object.defineProperty(i,t,{configurable:!0,enumerable:!1,value(...a){const r=s.apply(this,a);return i._chartjs.listeners.forEach(o=>{typeof o[n]=="function"&&o[n](...a)}),r}})})}function iT(i,e){const t=i._chartjs;if(!t)return;const n=t.listeners,s=n.indexOf(e);s!==-1&&n.splice(s,1),!(n.length>0)&&(aL.forEach(a=>{delete i[a]}),delete i._chartjs)}function IX(i){const e=new Set(i);return e.size===i.length?i:Array.from(e)}const rL=(function(){return typeof window=="undefined"?function(i){return i()}:window.requestAnimationFrame})();function oL(i,e){let t=[],n=!1;return function(...s){t=s,n||(n=!0,rL.call(window,()=>{n=!1,i.apply(e,t)}))}}function WX(i,e){let t;return function(...n){return e?(clearTimeout(t),t=setTimeout(i,e,n)):i.apply(this,n),e}}const b2=i=>i==="start"?"left":i==="end"?"right":"center",on=(i,e,t)=>i==="start"?e:i==="end"?t:(e+t)/2,XX=(i,e,t,n)=>i===(n?"left":"right")?t:i==="center"?(e+t)/2:e;function GX(i,e,t){const n=e.length;let s=0,a=n;if(i._sorted){const{iScale:r,vScale:o,_parsed:c}=i,d=i.dataset&&i.dataset.options?i.dataset.options.spanGaps:null,h=r.axis,{min:p,max:_,minDefined:y,maxDefined:x}=r.getUserBounds();if(y){if(s=Math.min(bl(c,h,p).lo,t?n:bl(e,h,r.getPixelForValue(p)).lo),d){const v=c.slice(0,s+1).reverse().findIndex(w=>!It(w[o.axis]));s-=Math.max(0,v)}s=Es(s,0,n-1)}if(x){let v=Math.max(bl(c,r.axis,_,!0).hi+1,t?0:bl(e,h,r.getPixelForValue(_),!0).hi+1);if(d){const w=c.slice(v-1).findIndex(k=>!It(k[o.axis]));v+=Math.max(0,w)}a=Es(v,s,n)-s}else a=n-s}return{start:s,count:a}}function QX(i){const{xScale:e,yScale:t,_scaleRanges:n}=i,s={xmin:e.min,xmax:e.max,ymin:t.min,ymax:t.max};if(!n)return i._scaleRanges=s,!0;const a=n.xmin!==e.min||n.xmax!==e.max||n.ymin!==t.min||n.ymax!==t.max;return Object.assign(n,s),a}const lm=i=>i===0||i===1,nT=(i,e,t)=>-(Math.pow(2,10*(i-=1))*Math.sin((i-e)*$s/t)),sT=(i,e,t)=>Math.pow(2,-10*i)*Math.sin((i-e)*$s/t)+1,ch={linear:i=>i,easeInQuad:i=>i*i,easeOutQuad:i=>-i*(i-2),easeInOutQuad:i=>(i/=.5)<1?.5*i*i:-.5*(--i*(i-2)-1),easeInCubic:i=>i*i*i,easeOutCubic:i=>(i-=1)*i*i+1,easeInOutCubic:i=>(i/=.5)<1?.5*i*i*i:.5*((i-=2)*i*i+2),easeInQuart:i=>i*i*i*i,easeOutQuart:i=>-((i-=1)*i*i*i-1),easeInOutQuart:i=>(i/=.5)<1?.5*i*i*i*i:-.5*((i-=2)*i*i*i-2),easeInQuint:i=>i*i*i*i*i,easeOutQuint:i=>(i-=1)*i*i*i*i+1,easeInOutQuint:i=>(i/=.5)<1?.5*i*i*i*i*i:.5*((i-=2)*i*i*i*i+2),easeInSine:i=>-Math.cos(i*Zs)+1,easeOutSine:i=>Math.sin(i*Zs),easeInOutSine:i=>-.5*(Math.cos(Vi*i)-1),easeInExpo:i=>i===0?0:Math.pow(2,10*(i-1)),easeOutExpo:i=>i===1?1:-Math.pow(2,-10*i)+1,easeInOutExpo:i=>lm(i)?i:i<.5?.5*Math.pow(2,10*(i*2-1)):.5*(-Math.pow(2,-10*(i*2-1))+2),easeInCirc:i=>i>=1?i:-(Math.sqrt(1-i*i)-1),easeOutCirc:i=>Math.sqrt(1-(i-=1)*i),easeInOutCirc:i=>(i/=.5)<1?-.5*(Math.sqrt(1-i*i)-1):.5*(Math.sqrt(1-(i-=2)*i)+1),easeInElastic:i=>lm(i)?i:nT(i,.075,.3),easeOutElastic:i=>lm(i)?i:sT(i,.075,.3),easeInOutElastic(i){return lm(i)?i:i<.5?.5*nT(i*2,.1125,.45):.5+.5*sT(i*2-1,.1125,.45)},easeInBack(i){return i*i*((1.70158+1)*i-1.70158)},easeOutBack(i){return(i-=1)*i*((1.70158+1)*i+1.70158)+1},easeInOutBack(i){let e=1.70158;return(i/=.5)<1?.5*(i*i*(((e*=1.525)+1)*i-e)):.5*((i-=2)*i*(((e*=1.525)+1)*i+e)+2)},easeInBounce:i=>1-ch.easeOutBounce(1-i),easeOutBounce(i){return i<1/2.75?7.5625*i*i:i<2/2.75?7.5625*(i-=1.5/2.75)*i+.75:i<2.5/2.75?7.5625*(i-=2.25/2.75)*i+.9375:7.5625*(i-=2.625/2.75)*i+.984375},easeInOutBounce:i=>i<.5?ch.easeInBounce(i*2)*.5:ch.easeOutBounce(i*2-1)*.5+.5};function v2(i){if(i&&typeof i=="object"){const e=i.toString();return e==="[object CanvasPattern]"||e==="[object CanvasGradient]"}return!1}function aT(i){return v2(i)?i:new Lh(i)}function B1(i){return v2(i)?i:new Lh(i).saturate(.5).darken(.1).hexString()}const YX=["x","y","borderWidth","radius","tension"],ZX=["color","borderColor","backgroundColor"];function JX(i){i.set("animation",{delay:void 0,duration:1e3,easing:"easeOutQuart",fn:void 0,from:void 0,loop:void 0,to:void 0,type:void 0}),i.describe("animation",{_fallback:!1,_indexable:!1,_scriptable:e=>e!=="onProgress"&&e!=="onComplete"&&e!=="fn"}),i.set("animations",{colors:{type:"color",properties:ZX},numbers:{type:"number",properties:YX}}),i.describe("animations",{_fallback:"animation"}),i.set("transitions",{active:{animation:{duration:400}},resize:{animation:{duration:0}},show:{animations:{colors:{from:"transparent"},visible:{type:"boolean",duration:0}}},hide:{animations:{colors:{to:"transparent"},visible:{type:"boolean",easing:"linear",fn:e=>e|0}}}})}function $X(i){i.set("layout",{autoPadding:!0,padding:{top:0,right:0,bottom:0,left:0}})}const rT=new Map;function eG(i,e){e=e||{};const t=i+JSON.stringify(e);let n=rT.get(t);return n||(n=new Intl.NumberFormat(i,e),rT.set(t,n)),n}function lL(i,e,t){return eG(e,t).format(i)}const tG={values(i){return Ui(i)?i:""+i},numeric(i,e,t){if(i===0)return"0";const n=this.chart.options.locale;let s,a=i;if(t.length>1){const d=Math.max(Math.abs(t[0].value),Math.abs(t[t.length-1].value));(d<1e-4||d>1e15)&&(s="scientific"),a=iG(i,t)}const r=nL(Math.abs(a)),o=isNaN(r)?1:Math.max(Math.min(-1*Math.floor(r),20),0),c={notation:s,minimumFractionDigits:o,maximumFractionDigits:o};return Object.assign(c,this.options.ticks.format),lL(i,n,c)}};function iG(i,e){let t=e.length>3?e[2].value-e[1].value:e[1].value-e[0].value;return Math.abs(t)>=1&&i!==Math.floor(i)&&(t=i-Math.floor(i)),t}var cL={formatters:tG};function nG(i){i.set("scale",{display:!0,offset:!1,reverse:!1,beginAtZero:!1,bounds:"ticks",clip:!0,grace:0,grid:{display:!0,lineWidth:1,drawOnChartArea:!0,drawTicks:!0,tickLength:8,tickWidth:(e,t)=>t.lineWidth,tickColor:(e,t)=>t.color,offset:!1},border:{display:!0,dash:[],dashOffset:0,width:1},title:{display:!1,text:"",padding:{top:4,bottom:4}},ticks:{minRotation:0,maxRotation:50,mirror:!1,textStrokeWidth:0,textStrokeColor:"",padding:3,display:!0,autoSkip:!0,autoSkipPadding:3,labelOffset:0,callback:cL.formatters.values,minor:{},major:{},align:"center",crossAlign:"near",showLabelBackdrop:!1,backdropColor:"rgba(255, 255, 255, 0.75)",backdropPadding:2}}),i.route("scale.ticks","color","","color"),i.route("scale.grid","color","","borderColor"),i.route("scale.border","color","","borderColor"),i.route("scale.title","color","","color"),i.describe("scale",{_fallback:!1,_scriptable:e=>!e.startsWith("before")&&!e.startsWith("after")&&e!=="callback"&&e!=="parser",_indexable:e=>e!=="borderDash"&&e!=="tickBorderDash"&&e!=="dash"}),i.describe("scales",{_fallback:"scale"}),i.describe("scale.ticks",{_scriptable:e=>e!=="backdropPadding"&&e!=="callback",_indexable:e=>e!=="backdropPadding"})}const El=Object.create(null),db=Object.create(null);function uh(i,e){if(!e)return i;const t=e.split(".");for(let n=0,s=t.length;nn.chart.platform.getDevicePixelRatio(),this.elements={},this.events=["mousemove","mouseout","click","touchstart","touchmove"],this.font={family:"'Helvetica Neue', 'Helvetica', 'Arial', sans-serif",size:12,style:"normal",lineHeight:1.2,weight:null},this.hover={},this.hoverBackgroundColor=(n,s)=>B1(s.backgroundColor),this.hoverBorderColor=(n,s)=>B1(s.borderColor),this.hoverColor=(n,s)=>B1(s.color),this.indexAxis="x",this.interaction={mode:"nearest",intersect:!0,includeInvisible:!1},this.maintainAspectRatio=!0,this.onHover=null,this.onClick=null,this.parsing=!0,this.plugins={},this.responsive=!0,this.scale=void 0,this.scales={},this.showLine=!0,this.drawActiveElementsOnTop=!0,this.describe(e),this.apply(t)}set(e,t){return z1(this,e,t)}get(e){return uh(this,e)}describe(e,t){return z1(db,e,t)}override(e,t){return z1(El,e,t)}route(e,t,n,s){const a=uh(this,e),r=uh(this,n),o="_"+t;Object.defineProperties(a,{[o]:{value:a[t],writable:!0},[t]:{enumerable:!0,get(){const c=this[o],d=r[s];return pt(c)?Object.assign({},d,c):dt(c,d)},set(c){this[o]=c}}})}apply(e){e.forEach(t=>t(this))}}var xi=new sG({_scriptable:i=>!i.startsWith("on"),_indexable:i=>i!=="events",hover:{_fallback:"interaction"},interaction:{_scriptable:!1,_indexable:!1}},[JX,$X,nG]);function aG(i){return!i||It(i.size)||It(i.family)?null:(i.style?i.style+" ":"")+(i.weight?i.weight+" ":"")+i.size+"px "+i.family}function oT(i,e,t,n,s){let a=e[s];return a||(a=e[s]=i.measureText(s).width,t.push(s)),a>n&&(n=a),n}function sl(i,e,t){const n=i.currentDevicePixelRatio,s=t!==0?Math.max(t/2,.5):0;return Math.round((e-s)*n)/n+s}function lT(i,e){!e&&!i||(e=e||i.getContext("2d"),e.save(),e.resetTransform(),e.clearRect(0,0,i.width,i.height),e.restore())}function hb(i,e,t,n){uL(i,e,t,n,null)}function uL(i,e,t,n,s){let a,r,o,c,d,h,p,_;const y=e.pointStyle,x=e.rotation,v=e.radius;let w=(x||0)*LX;if(y&&typeof y=="object"&&(a=y.toString(),a==="[object HTMLImageElement]"||a==="[object HTMLCanvasElement]")){i.save(),i.translate(t,n),i.rotate(w),i.drawImage(y,-y.width/2,-y.height/2,y.width,y.height),i.restore();return}if(!(isNaN(v)||v<=0)){switch(i.beginPath(),y){default:s?i.ellipse(t,n,s/2,v,0,0,$s):i.arc(t,n,v,0,$s),i.closePath();break;case"triangle":h=s?s/2:v,i.moveTo(t+Math.sin(w)*h,n-Math.cos(w)*v),w+=$O,i.lineTo(t+Math.sin(w)*h,n-Math.cos(w)*v),w+=$O,i.lineTo(t+Math.sin(w)*h,n-Math.cos(w)*v),i.closePath();break;case"rectRounded":d=v*.516,c=v-d,r=Math.cos(w+nl)*c,p=Math.cos(w+nl)*(s?s/2-d:c),o=Math.sin(w+nl)*c,_=Math.sin(w+nl)*(s?s/2-d:c),i.arc(t-p,n-o,d,w-Vi,w-Zs),i.arc(t+_,n-r,d,w-Zs,w),i.arc(t+p,n+o,d,w,w+Zs),i.arc(t-_,n+r,d,w+Zs,w+Vi),i.closePath();break;case"rect":if(!x){c=Math.SQRT1_2*v,h=s?s/2:c,i.rect(t-h,n-c,2*h,2*c);break}w+=nl;case"rectRot":p=Math.cos(w)*(s?s/2:v),r=Math.cos(w)*v,o=Math.sin(w)*v,_=Math.sin(w)*(s?s/2:v),i.moveTo(t-p,n-o),i.lineTo(t+_,n-r),i.lineTo(t+p,n+o),i.lineTo(t-_,n+r),i.closePath();break;case"crossRot":w+=nl;case"cross":p=Math.cos(w)*(s?s/2:v),r=Math.cos(w)*v,o=Math.sin(w)*v,_=Math.sin(w)*(s?s/2:v),i.moveTo(t-p,n-o),i.lineTo(t+p,n+o),i.moveTo(t+_,n-r),i.lineTo(t-_,n+r);break;case"star":p=Math.cos(w)*(s?s/2:v),r=Math.cos(w)*v,o=Math.sin(w)*v,_=Math.sin(w)*(s?s/2:v),i.moveTo(t-p,n-o),i.lineTo(t+p,n+o),i.moveTo(t+_,n-r),i.lineTo(t-_,n+r),w+=nl,p=Math.cos(w)*(s?s/2:v),r=Math.cos(w)*v,o=Math.sin(w)*v,_=Math.sin(w)*(s?s/2:v),i.moveTo(t-p,n-o),i.lineTo(t+p,n+o),i.moveTo(t+_,n-r),i.lineTo(t-_,n+r);break;case"line":r=s?s/2:Math.cos(w)*v,o=Math.sin(w)*v,i.moveTo(t-r,n-o),i.lineTo(t+r,n+o);break;case"dash":i.moveTo(t,n),i.lineTo(t+Math.cos(w)*(s?s/2:v),n+Math.sin(w)*v);break;case!1:i.closePath();break}i.fill(),e.borderWidth>0&&i.stroke()}}function Dh(i,e,t){return t=t||.5,!e||i&&i.x>e.left-t&&i.xe.top-t&&i.y0&&a.strokeColor!=="";let c,d;for(i.save(),i.font=s.string,lG(i,a),c=0;c+i||0;function dL(i,e){const t={},n=pt(e),s=n?Object.keys(e):e,a=pt(i)?n?r=>dt(i[r],i[e[r]]):r=>i[r]:()=>i;for(const r of s)t[r]=pG(a(r));return t}function mG(i){return dL(i,{top:"y",right:"x",bottom:"y",left:"x"})}function dh(i){return dL(i,["topLeft","topRight","bottomLeft","bottomRight"])}function Hs(i){const e=mG(i);return e.width=e.left+e.right,e.height=e.top+e.bottom,e}function hn(i,e){i=i||{},e=e||xi.font;let t=dt(i.size,e.size);typeof t=="string"&&(t=parseInt(t,10));let n=dt(i.style,e.style);n&&!(""+n).match(hG)&&(console.warn('Invalid font style specified: "'+n+'"'),n=void 0);const s={family:dt(i.family,e.family),lineHeight:fG(dt(i.lineHeight,e.lineHeight),t),size:t,style:n,weight:dt(i.weight,e.weight),string:""};return s.string=aG(s),s}function cm(i,e,t,n){let s,a,r;for(s=0,a=i.length;st&&o===0?0:o+c;return{min:r(n,-Math.abs(a)),max:r(s,a)}}function Il(i,e){return Object.assign(Object.create(i),e)}function S2(i,e=[""],t,n,s=()=>i[0]){const a=t||i;typeof n=="undefined"&&(n=mL("_fallback",i));const r={[Symbol.toStringTag]:"Object",_cacheable:!0,_scopes:i,_rootScopes:a,_fallback:n,_getTarget:s,override:o=>S2([o,...i],e,a,n)};return new Proxy(r,{deleteProperty(o,c){return delete o[c],delete o._keys,delete i[0][c],!0},get(o,c){return fL(o,c,()=>kG(c,e,i,o))},getOwnPropertyDescriptor(o,c){return Reflect.getOwnPropertyDescriptor(o._scopes[0],c)},getPrototypeOf(){return Reflect.getPrototypeOf(i[0])},has(o,c){return uT(o).includes(c)},ownKeys(o){return uT(o)},set(o,c,d){const h=o._storage||(o._storage=s());return o[c]=h[c]=d,delete o._keys,!0}})}function hu(i,e,t,n){const s={_cacheable:!1,_proxy:i,_context:e,_subProxy:t,_stack:new Set,_descriptors:hL(i,n),setContext:a=>hu(i,a,t,n),override:a=>hu(i.override(a),e,t,n)};return new Proxy(s,{deleteProperty(a,r){return delete a[r],delete i[r],!0},get(a,r,o){return fL(a,r,()=>yG(a,r,o))},getOwnPropertyDescriptor(a,r){return a._descriptors.allKeys?Reflect.has(i,r)?{enumerable:!0,configurable:!0}:void 0:Reflect.getOwnPropertyDescriptor(i,r)},getPrototypeOf(){return Reflect.getPrototypeOf(i)},has(a,r){return Reflect.has(i,r)},ownKeys(){return Reflect.ownKeys(i)},set(a,r,o){return i[r]=o,delete a[r],!0}})}function hL(i,e={scriptable:!0,indexable:!0}){const{_scriptable:t=e.scriptable,_indexable:n=e.indexable,_allKeys:s=e.allKeys}=i;return{allKeys:s,scriptable:t,indexable:n,isScriptable:Ao(t)?t:()=>t,isIndexable:Ao(n)?n:()=>n}}const _G=(i,e)=>i?i+y2(e):e,w2=(i,e)=>pt(e)&&i!=="adapters"&&(Object.getPrototypeOf(e)===null||e.constructor===Object);function fL(i,e,t){if(Object.prototype.hasOwnProperty.call(i,e)||e==="constructor")return i[e];const n=t();return i[e]=n,n}function yG(i,e,t){const{_proxy:n,_context:s,_subProxy:a,_descriptors:r}=i;let o=n[e];return Ao(o)&&r.isScriptable(e)&&(o=xG(e,o,i,t)),Ui(o)&&o.length&&(o=bG(e,o,i,r.isIndexable)),w2(e,o)&&(o=hu(o,s,a&&a[e],r)),o}function xG(i,e,t,n){const{_proxy:s,_context:a,_subProxy:r,_stack:o}=t;if(o.has(i))throw new Error("Recursion detected: "+Array.from(o).join("->")+"->"+i);o.add(i);let c=e(a,r||n);return o.delete(i),w2(i,c)&&(c=k2(s._scopes,s,i,c)),c}function bG(i,e,t,n){const{_proxy:s,_context:a,_subProxy:r,_descriptors:o}=t;if(typeof a.index!="undefined"&&n(i))return e[a.index%e.length];if(pt(e[0])){const c=e,d=s._scopes.filter(h=>h!==c);e=[];for(const h of c){const p=k2(d,s,i,h);e.push(hu(p,a,r&&r[i],o))}}return e}function pL(i,e,t){return Ao(i)?i(e,t):i}const vG=(i,e)=>i===!0?e:typeof i=="string"?Lg(e,i):void 0;function SG(i,e,t,n,s){for(const a of e){const r=vG(t,a);if(r){i.add(r);const o=pL(r._fallback,t,s);if(typeof o!="undefined"&&o!==t&&o!==n)return o}else if(r===!1&&typeof n!="undefined"&&t!==n)return null}return!1}function k2(i,e,t,n){const s=e._rootScopes,a=pL(e._fallback,t,n),r=[...i,...s],o=new Set;o.add(n);let c=cT(o,r,t,a||t,n);return c===null||typeof a!="undefined"&&a!==t&&(c=cT(o,r,a,c,n),c===null)?!1:S2(Array.from(o),[""],s,a,()=>wG(e,t,n))}function cT(i,e,t,n,s){for(;t;)t=SG(i,e,t,n,s);return t}function wG(i,e,t){const n=i._getTarget();e in n||(n[e]={});const s=n[e];return Ui(s)&&pt(t)?t:s||{}}function kG(i,e,t,n){let s;for(const a of e)if(s=mL(_G(a,i),t),typeof s!="undefined")return w2(i,s)?k2(t,n,i,s):s}function mL(i,e){for(const t of e){if(!t)continue;const n=t[i];if(typeof n!="undefined")return n}}function uT(i){let e=i._keys;return e||(e=i._keys=AG(i._scopes)),e}function AG(i){const e=new Set;for(const t of i)for(const n of Object.keys(t).filter(s=>!s.startsWith("_")))e.add(n);return Array.from(e)}const CG=Number.EPSILON||1e-14,fu=(i,e)=>ei==="x"?"y":"x";function OG(i,e,t,n){const s=i.skip?e:i,a=e,r=t.skip?e:t,o=ub(a,s),c=ub(r,a);let d=o/(o+c),h=c/(o+c);d=isNaN(d)?0:d,h=isNaN(h)?0:h;const p=n*d,_=n*h;return{previous:{x:a.x-p*(r.x-s.x),y:a.y-p*(r.y-s.y)},next:{x:a.x+_*(r.x-s.x),y:a.y+_*(r.y-s.y)}}}function TG(i,e,t){const n=i.length;let s,a,r,o,c,d=fu(i,0);for(let h=0;h!d.skip)),e.cubicInterpolationMode==="monotone")NG(i,s);else{let d=n?i[i.length-1]:i[0];for(a=0,r=i.length;ai.ownerDocument.defaultView.getComputedStyle(i,null);function LG(i,e){return P0(i).getPropertyValue(e)}const jG=["top","right","bottom","left"];function Nl(i,e,t){const n={};t=t?"-"+t:"";for(let s=0;s<4;s++){const a=jG[s];n[a]=parseFloat(i[e+"-"+a+t])||0}return n.width=n.left+n.right,n.height=n.top+n.bottom,n}const EG=(i,e,t)=>(i>0||e>0)&&(!t||!t.shadowRoot);function DG(i,e){const t=i.touches,n=t&&t.length?t[0]:i,{offsetX:s,offsetY:a}=n;let r=!1,o,c;if(EG(s,a,i.target))o=s,c=a;else{const d=e.getBoundingClientRect();o=n.clientX-d.left,c=n.clientY-d.top,r=!0}return{x:o,y:c,box:r}}function ll(i,e){if("native"in i)return i;const{canvas:t,currentDevicePixelRatio:n}=e,s=P0(t),a=s.boxSizing==="border-box",r=Nl(s,"padding"),o=Nl(s,"border","width"),{x:c,y:d,box:h}=DG(i,t),p=r.left+(h&&o.left),_=r.top+(h&&o.top);let{width:y,height:x}=e;return a&&(y-=r.width+o.width,x-=r.height+o.height),{x:Math.round((c-p)/y*t.width/n),y:Math.round((d-_)/x*t.height/n)}}function UG(i,e,t){let n,s;if(e===void 0||t===void 0){const a=i&&C2(i);if(!a)e=i.clientWidth,t=i.clientHeight;else{const r=a.getBoundingClientRect(),o=P0(a),c=Nl(o,"border","width"),d=Nl(o,"padding");e=r.width-d.width-c.width,t=r.height-d.height-c.height,n=Dg(o.maxWidth,a,"clientWidth"),s=Dg(o.maxHeight,a,"clientHeight")}}return{width:e,height:t,maxWidth:n||Eg,maxHeight:s||Eg}}const fo=i=>Math.round(i*10)/10;function FG(i,e,t,n){const s=P0(i),a=Nl(s,"margin"),r=Dg(s.maxWidth,i,"clientWidth")||Eg,o=Dg(s.maxHeight,i,"clientHeight")||Eg,c=UG(i,e,t);let{width:d,height:h}=c;if(s.boxSizing==="content-box"){const _=Nl(s,"border","width"),y=Nl(s,"padding");d-=y.width+_.width,h-=y.height+_.height}return d=Math.max(0,d-a.width),h=Math.max(0,n?d/n:h-a.height),d=fo(Math.min(d,r,c.maxWidth)),h=fo(Math.min(h,o,c.maxHeight)),d&&!h&&(h=fo(d/2)),(e!==void 0||t!==void 0)&&n&&c.height&&h>c.height&&(h=c.height,d=fo(Math.floor(h*n))),{width:d,height:h}}function dT(i,e,t){const n=e||1,s=fo(i.height*n),a=fo(i.width*n);i.height=fo(i.height),i.width=fo(i.width);const r=i.canvas;return r.style&&(t||!r.style.height&&!r.style.width)&&(r.style.height=`${i.height}px`,r.style.width=`${i.width}px`),i.currentDevicePixelRatio!==n||r.height!==s||r.width!==a?(i.currentDevicePixelRatio=n,r.height=s,r.width=a,i.ctx.setTransform(n,0,0,n,0,0),!0):!1}const BG=(function(){let i=!1;try{const e={get passive(){return i=!0,!1}};A2()&&(window.addEventListener("test",null,e),window.removeEventListener("test",null,e))}catch(e){}return i})();function hT(i,e){const t=LG(i,e),n=t&&t.match(/^(\d+)(\.\d+)?px$/);return n?+n[1]:void 0}function cl(i,e,t,n){return{x:i.x+t*(e.x-i.x),y:i.y+t*(e.y-i.y)}}function zG(i,e,t,n){return{x:i.x+t*(e.x-i.x),y:n==="middle"?t<.5?i.y:e.y:n==="after"?t<1?i.y:e.y:t>0?e.y:i.y}}function qG(i,e,t,n){const s={x:i.cp2x,y:i.cp2y},a={x:e.cp1x,y:e.cp1y},r=cl(i,s,t),o=cl(s,a,t),c=cl(a,e,t),d=cl(r,o,t),h=cl(o,c,t);return cl(d,h,t)}const HG=function(i,e){return{x(t){return i+i+e-t},setWidth(t){e=t},textAlign(t){return t==="center"?t:t==="right"?"left":"right"},xPlus(t,n){return t-n},leftForLtr(t,n){return t-n}}},KG=function(){return{x(i){return i},setWidth(i){},textAlign(i){return i},xPlus(i,e){return i+e},leftForLtr(i,e){return i}}};function Zc(i,e,t){return i?HG(e,t):KG()}function _L(i,e){let t,n;(e==="ltr"||e==="rtl")&&(t=i.canvas.style,n=[t.getPropertyValue("direction"),t.getPropertyPriority("direction")],t.setProperty("direction",e,"important"),i.prevTextDirection=n)}function yL(i,e){e!==void 0&&(delete i.prevTextDirection,i.canvas.style.setProperty("direction",e[0],e[1]))}function xL(i){return i==="angle"?{between:sL,compare:zX,normalize:Sa}:{between:qc,compare:(e,t)=>e-t,normalize:e=>e}}function fT({start:i,end:e,count:t,loop:n,style:s}){return{start:i%t,end:e%t,loop:n&&(e-i+1)%t===0,style:s}}function VG(i,e,t){const{property:n,start:s,end:a}=t,{between:r,normalize:o}=xL(n),c=e.length;let{start:d,end:h,loop:p}=i,_,y;if(p){for(d+=c,h+=c,_=0,y=c;_c(s,O,k)&&o(s,O)!==0,C=()=>o(a,k)===0||c(a,O,k),P=()=>v||A(),R=()=>!v||C();for(let E=h,L=h;E<=p;++E)M=e[E%r],!M.skip&&(k=d(M[n]),k!==O&&(v=c(k,s,a),w===null&&P()&&(w=o(k,s)===0?E:L),w!==null&&R()&&(x.push(fT({start:w,end:E,loop:_,count:r,style:y})),w=null),L=E,O=k));return w!==null&&x.push(fT({start:w,end:p,loop:_,count:r,style:y})),x}function vL(i,e){const t=[],n=i.segments;for(let s=0;ss&&i[a%e].skip;)a--;return a%=e,{start:s,end:a}}function WG(i,e,t,n){const s=i.length,a=[];let r=e,o=i[e],c;for(c=e+1;c<=t;++c){const d=i[c%s];d.skip||d.stop?o.skip||(n=!1,a.push({start:e%s,end:(c-1)%s,loop:n}),e=r=d.stop?c:null):(r=c,o.skip&&(e=c)),o=d}return r!==null&&a.push({start:e%s,end:r%s,loop:n}),a}function XG(i,e){const t=i.points,n=i.options.spanGaps,s=t.length;if(!s)return[];const a=!!i._loop,{start:r,end:o}=IG(t,s,a,n);if(n===!0)return pT(i,[{start:r,end:o,loop:a}],t,e);const c=oo({chart:e,initial:t.initial,numSteps:r,currentStep:Math.min(n-t.start,r)}))}_refresh(){this._request||(this._running=!0,this._request=rL.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let t=0;this._charts.forEach((n,s)=>{if(!n.running||!n.items.length)return;const a=n.items;let r=a.length-1,o=!1,c;for(;r>=0;--r)c=a[r],c._active?(c._total>n.duration&&(n.duration=c._total),c.tick(e),o=!0):(a[r]=a[a.length-1],a.pop());o&&(s.draw(),this._notify(s,n,e,"progress")),a.length||(n.running=!1,this._notify(s,n,e,"complete"),n.initial=!1),t+=a.length}),this._lastDate=e,t===0&&(this._running=!1)}_getAnims(e){const t=this._charts;let n=t.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},t.set(e,n)),n}listen(e,t,n){this._getAnims(e).listeners[t].push(n)}add(e,t){!t||!t.length||this._getAnims(e).items.push(...t)}has(e){return this._getAnims(e).items.length>0}start(e){const t=this._charts.get(e);t&&(t.running=!0,t.start=Date.now(),t.duration=t.items.reduce((n,s)=>Math.max(n,s._duration),0),this._refresh())}running(e){if(!this._running)return!1;const t=this._charts.get(e);return!(!t||!t.running||!t.items.length)}stop(e){const t=this._charts.get(e);if(!t||!t.items.length)return;const n=t.items;let s=n.length-1;for(;s>=0;--s)n[s].cancel();t.items=[],this._notify(e,t,Date.now(),"complete")}remove(e){return this._charts.delete(e)}}var sr=new ZG;const gT="transparent",JG={boolean(i,e,t){return t>.5?e:i},color(i,e,t){const n=aT(i||gT),s=n.valid&&aT(e||gT);return s&&s.valid?s.mix(n,t).hexString():e},number(i,e,t){return i+(e-i)*t}};class $G{constructor(e,t,n,s){const a=t[n];s=cm([e.to,s,a,e.from]);const r=cm([e.from,a,s]);this._active=!0,this._fn=e.fn||JG[e.type||typeof r],this._easing=ch[e.easing]||ch.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=t,this._prop=n,this._from=r,this._to=s,this._promises=void 0}active(){return this._active}update(e,t,n){if(this._active){this._notify(!1);const s=this._target[this._prop],a=n-this._start,r=this._duration-a;this._start=n,this._duration=Math.floor(Math.max(r,e.duration)),this._total+=a,this._loop=!!e.loop,this._to=cm([e.to,t,s,e.from]),this._from=cm([e.from,s,t])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){const t=e-this._start,n=this._duration,s=this._prop,a=this._from,r=this._loop,o=this._to;let c;if(this._active=a!==o&&(r||t1?2-c:c,c=this._easing(Math.min(1,Math.max(0,c))),this._target[s]=this._fn(a,o,c)}wait(){const e=this._promises||(this._promises=[]);return new Promise((t,n)=>{e.push({res:t,rej:n})})}_notify(e){const t=e?"res":"rej",n=this._promises||[];for(let s=0;s{const a=e[s];if(!pt(a))return;const r={};for(const o of t)r[o]=a[o];(Ui(a.properties)&&a.properties||[s]).forEach(o=>{(o===s||!n.has(o))&&n.set(o,r)})})}_animateOptions(e,t){const n=t.options,s=tQ(e,n);if(!s)return[];const a=this._createAnimations(s,n);return n.$shared&&eQ(e.options.$animations,n).then(()=>{e.options=n},()=>{}),a}_createAnimations(e,t){const n=this._properties,s=[],a=e.$animations||(e.$animations={}),r=Object.keys(t),o=Date.now();let c;for(c=r.length-1;c>=0;--c){const d=r[c];if(d.charAt(0)==="$")continue;if(d==="options"){s.push(...this._animateOptions(e,t));continue}const h=t[d];let p=a[d];const _=n.get(d);if(p)if(_&&p.active()){p.update(_,h,o);continue}else p.cancel();if(!_||!_.duration){e[d]=h;continue}a[d]=p=new $G(_,e,d,h),s.push(p)}return s}update(e,t){if(this._properties.size===0){Object.assign(e,t);return}const n=this._createAnimations(e,t);if(n.length)return sr.add(this._chart,n),!0}}function eQ(i,e){const t=[],n=Object.keys(e);for(let s=0;s0||!t&&a<0)return s.index}return null}function bT(i,e){const{chart:t,_cachedMeta:n}=i,s=t._stacks||(t._stacks={}),{iScale:a,vScale:r,index:o}=n,c=a.axis,d=r.axis,h=aQ(a,r,n),p=e.length;let _;for(let y=0;yt[n].axis===e).shift()}function lQ(i,e){return Il(i,{active:!1,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}function cQ(i,e,t){return Il(i,{active:!1,dataIndex:e,parsed:void 0,raw:void 0,element:t,index:e,mode:"default",type:"data"})}function Pd(i,e){const t=i.controller.index,n=i.vScale&&i.vScale.axis;if(n){e=e||i._parsed;for(const s of e){const a=s._stacks;if(!a||a[n]===void 0||a[n][t]===void 0)return;delete a[n][t],a[n]._visualValues!==void 0&&a[n]._visualValues[t]!==void 0&&delete a[n]._visualValues[t]}}}const K1=i=>i==="reset"||i==="none",vT=(i,e)=>e?i:Object.assign({},i),uQ=(i,e,t)=>i&&!e.hidden&&e._stacked&&{keys:kL(t,!0),values:null};class hh{constructor(e,t){this.chart=e,this._ctx=e.ctx,this.index=t,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=q1(e.vScale,e),this.addElements(),this.options.fill&&!this.chart.isPluginEnabled("filler")&&console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}updateIndex(e){this.index!==e&&Pd(this._cachedMeta),this.index=e}linkScales(){const e=this.chart,t=this._cachedMeta,n=this.getDataset(),s=(p,_,y,x)=>p==="x"?_:p==="r"?x:y,a=t.xAxisID=dt(n.xAxisID,H1(e,"x")),r=t.yAxisID=dt(n.yAxisID,H1(e,"y")),o=t.rAxisID=dt(n.rAxisID,H1(e,"r")),c=t.indexAxis,d=t.iAxisID=s(c,a,r,o),h=t.vAxisID=s(c,r,a,o);t.xScale=this.getScaleForId(a),t.yScale=this.getScaleForId(r),t.rScale=this.getScaleForId(o),t.iScale=this.getScaleForId(d),t.vScale=this.getScaleForId(h)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){const t=this._cachedMeta;return e===t.iScale?t.vScale:t.iScale}reset(){this._update("reset")}_destroy(){const e=this._cachedMeta;this._data&&iT(this._data,this),e._stacked&&Pd(e)}_dataCheck(){const e=this.getDataset(),t=e.data||(e.data=[]),n=this._data;if(pt(t)){const s=this._cachedMeta;this._data=sQ(t,s)}else if(n!==t){if(n){iT(n,this);const s=this._cachedMeta;Pd(s),s._parsed=[]}t&&Object.isExtensible(t)&&VX(t,this),this._syncList=[],this._data=t}}addElements(){const e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){const t=this._cachedMeta,n=this.getDataset();let s=!1;this._dataCheck();const a=t._stacked;t._stacked=q1(t.vScale,t),t.stack!==n.stack&&(s=!0,Pd(t),t.stack=n.stack),this._resyncElements(e),(s||a!==t._stacked)&&(bT(this,t._parsed),t._stacked=q1(t.vScale,t))}configure(){const e=this.chart.config,t=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),t,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,t){const{_cachedMeta:n,_data:s}=this,{iScale:a,_stacked:r}=n,o=a.axis;let c=e===0&&t===s.length?!0:n._sorted,d=e>0&&n._parsed[e-1],h,p,_;if(this._parsing===!1)n._parsed=s,n._sorted=!0,_=s;else{Ui(s[e])?_=this.parseArrayData(n,s,e,t):pt(s[e])?_=this.parseObjectData(n,s,e,t):_=this.parsePrimitiveData(n,s,e,t);const y=()=>p[o]===null||d&&p[o]v||p=0;--_)if(!x()){this.updateRangeFromParsed(d,e,y,c);break}}return d}getAllParsedValues(e){const t=this._cachedMeta._parsed,n=[];let s,a,r;for(s=0,a=t.length;s=0&&ethis.getContext(n,s,t),v=d.resolveNamedOptions(_,y,x,p);return v.$shared&&(v.$shared=c,a[r]=Object.freeze(vT(v,c))),v}_resolveAnimations(e,t,n){const s=this.chart,a=this._cachedDataOpts,r=`animation-${t}`,o=a[r];if(o)return o;let c;if(s.options.animation!==!1){const h=this.chart.config,p=h.datasetAnimationScopeKeys(this._type,t),_=h.getOptionScopes(this.getDataset(),p);c=h.createResolver(_,this.getContext(e,n,t))}const d=new wL(s,c&&c.animations);return c&&c._cacheable&&(a[r]=Object.freeze(d)),d}getSharedOptions(e){if(e.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},e))}includeOptions(e,t){return!t||K1(e)||this.chart._animationsDisabled}_getSharedOptions(e,t){const n=this.resolveDataElementOptions(e,t),s=this._sharedOptions,a=this.getSharedOptions(n),r=this.includeOptions(t,a)||a!==s;return this.updateSharedOptions(a,t,n),{sharedOptions:a,includeOptions:r}}updateElement(e,t,n,s){K1(s)?Object.assign(e,n):this._resolveAnimations(t,s).update(e,n)}updateSharedOptions(e,t,n){e&&!K1(t)&&this._resolveAnimations(void 0,t).update(e,n)}_setStyle(e,t,n,s){e.active=s;const a=this.getStyle(t,s);this._resolveAnimations(t,n,s).update(e,{options:!s&&this.getSharedOptions(a)||a})}removeHoverStyle(e,t,n){this._setStyle(e,n,"active",!1)}setHoverStyle(e,t,n){this._setStyle(e,n,"active",!0)}_removeDatasetHoverStyle(){const e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!1)}_setDatasetHoverStyle(){const e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!0)}_resyncElements(e){const t=this._data,n=this._cachedMeta.data;for(const[o,c,d]of this._syncList)this[o](c,d);this._syncList=[];const s=n.length,a=t.length,r=Math.min(a,s);r&&this.parse(0,r),a>s?this._insertElements(s,a-s,e):a{for(d.length+=t,o=d.length-1;o>=r;o--)d[o]=d[o-t]};for(c(a),o=e;o0&&this.getParsed(t-1);for(let C=0;C=M){R.skip=!0;continue}const E=this.getParsed(C),L=It(E[y]),D=R[_]=r.getPixelForValue(E[_],C),q=R[y]=a||L?o.getBasePixel():o.getPixelForValue(c?this.applyStack(o,E,c):E[y],C);R.skip=isNaN(D)||isNaN(q)||L,R.stop=C>0&&Math.abs(E[_]-A[_])>w,v&&(R.parsed=E,R.raw=d.data[C]),p&&(R.options=h||this.resolveDataElementOptions(C,P.active?"active":s)),k||this.updateElement(P,C,R,s),A=E}}getMaxOverflow(){const e=this._cachedMeta,t=e.dataset,n=t.options&&t.options.borderWidth||0,s=e.data||[];if(!s.length)return n;const a=s[0].size(this.resolveDataElementOptions(0)),r=s[s.length-1].size(this.resolveDataElementOptions(s.length-1));return Math.max(n,a,r)/2}draw(){const e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}}Ge(eg,"id","line"),Ge(eg,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),Ge(eg,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});function al(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class O2{constructor(e){Ge(this,"options");this.options=e||{}}static override(e){Object.assign(O2.prototype,e)}init(){}formats(){return al()}parse(){return al()}format(){return al()}add(){return al()}diff(){return al()}startOf(){return al()}endOf(){return al()}}var dQ={_date:O2};function hQ(i,e,t,n){const{controller:s,data:a,_sorted:r}=i,o=s._cachedMeta.iScale,c=i.dataset&&i.dataset.options?i.dataset.options.spanGaps:null;if(o&&e===o.axis&&e!=="r"&&r&&a.length){const d=o._reversePixels?HX:bl;if(n){if(s._sharedOptions){const h=a[0],p=typeof h.getRange=="function"&&h.getRange(e);if(p){const _=d(a,e,t-p),y=d(a,e,t+p);return{lo:_.lo,hi:y.hi}}}}else{const h=d(a,e,t);if(c){const{vScale:p}=s._cachedMeta,{_parsed:_}=i,y=_.slice(0,h.lo+1).reverse().findIndex(v=>!It(v[p.axis]));h.lo-=Math.max(0,y);const x=_.slice(h.hi).findIndex(v=>!It(v[p.axis]));h.hi+=Math.max(0,x)}return h}}return{lo:0,hi:a.length-1}}function L0(i,e,t,n,s){const a=i.getSortedVisibleDatasetMetas(),r=t[e];for(let o=0,c=a.length;o{c[r]&&c[r](e[t],s)&&(a.push({element:c,datasetIndex:d,index:h}),o=o||c.inRange(e.x,e.y,s))}),n&&!o?[]:a}var gQ={modes:{index(i,e,t,n){const s=ll(e,i),a=t.axis||"x",r=t.includeInvisible||!1,o=t.intersect?V1(i,s,a,n,r):I1(i,s,a,!1,n,r),c=[];return o.length?(i.getSortedVisibleDatasetMetas().forEach(d=>{const h=o[0].index,p=d.data[h];p&&!p.skip&&c.push({element:p,datasetIndex:d.index,index:h})}),c):[]},dataset(i,e,t,n){const s=ll(e,i),a=t.axis||"xy",r=t.includeInvisible||!1;let o=t.intersect?V1(i,s,a,n,r):I1(i,s,a,!1,n,r);if(o.length>0){const c=o[0].datasetIndex,d=i.getDatasetMeta(c).data;o=[];for(let h=0;ht.pos===e)}function wT(i,e){return i.filter(t=>AL.indexOf(t.pos)===-1&&t.box.axis===e)}function jd(i,e){return i.sort((t,n)=>{const s=e?n:t,a=e?t:n;return s.weight===a.weight?s.index-a.index:s.weight-a.weight})}function _Q(i){const e=[];let t,n,s,a,r,o;for(t=0,n=(i||[]).length;td.box.fullSize),!0),n=jd(Ld(e,"left"),!0),s=jd(Ld(e,"right")),a=jd(Ld(e,"top"),!0),r=jd(Ld(e,"bottom")),o=wT(e,"x"),c=wT(e,"y");return{fullSize:t,leftAndTop:n.concat(a),rightAndBottom:s.concat(c).concat(r).concat(o),chartArea:Ld(e,"chartArea"),vertical:n.concat(s).concat(c),horizontal:a.concat(r).concat(o)}}function kT(i,e,t,n){return Math.max(i[t],e[t])+Math.max(i[n],e[n])}function CL(i,e){i.top=Math.max(i.top,e.top),i.left=Math.max(i.left,e.left),i.bottom=Math.max(i.bottom,e.bottom),i.right=Math.max(i.right,e.right)}function vQ(i,e,t,n){const{pos:s,box:a}=t,r=i.maxPadding;if(!pt(s)){t.size&&(i[s]-=t.size);const p=n[t.stack]||{size:0,count:1};p.size=Math.max(p.size,t.horizontal?a.height:a.width),t.size=p.size/p.count,i[s]+=t.size}a.getPadding&&CL(r,a.getPadding());const o=Math.max(0,e.outerWidth-kT(r,i,"left","right")),c=Math.max(0,e.outerHeight-kT(r,i,"top","bottom")),d=o!==i.w,h=c!==i.h;return i.w=o,i.h=c,t.horizontal?{same:d,other:h}:{same:h,other:d}}function SQ(i){const e=i.maxPadding;function t(n){const s=Math.max(e[n]-i[n],0);return i[n]+=s,s}i.y+=t("top"),i.x+=t("left"),t("right"),t("bottom")}function wQ(i,e){const t=e.maxPadding;function n(s){const a={left:0,top:0,right:0,bottom:0};return s.forEach(r=>{a[r]=Math.max(e[r],t[r])}),a}return n(i?["left","right"]:["top","bottom"])}function Xd(i,e,t,n){const s=[];let a,r,o,c,d,h;for(a=0,r=i.length,d=0;a{typeof v.beforeLayout=="function"&&v.beforeLayout()});const h=c.reduce((v,w)=>w.box.options&&w.box.options.display===!1?v:v+1,0)||1,p=Object.freeze({outerWidth:e,outerHeight:t,padding:s,availableWidth:a,availableHeight:r,vBoxMaxWidth:a/2/h,hBoxMaxHeight:r/2}),_=Object.assign({},s);CL(_,Hs(n));const y=Object.assign({maxPadding:_,w:a,h:r,x:s.left,y:s.top},s),x=xQ(c.concat(d),p);Xd(o.fullSize,y,p,x),Xd(c,y,p,x),Xd(d,y,p,x)&&Xd(c,y,p,x),SQ(y),AT(o.leftAndTop,y,p,x),y.x+=y.w,y.y+=y.h,AT(o.rightAndBottom,y,p,x),i.chartArea={left:y.left,top:y.top,right:y.left+y.w,bottom:y.top+y.h,height:y.h,width:y.w},jt(o.chartArea,v=>{const w=v.box;Object.assign(w,i.chartArea),w.update(y.w,y.h,{left:0,top:0,right:0,bottom:0})})}};class OL{acquireContext(e,t){}releaseContext(e){return!1}addEventListener(e,t,n){}removeEventListener(e,t,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,t,n,s){return t=Math.max(0,t||e.width),n=n||e.height,{width:t,height:Math.max(0,s?Math.floor(t/s):n)}}isAttached(e){return!0}updateConfig(e){}}class kQ extends OL{acquireContext(e){return e&&e.getContext&&e.getContext("2d")||null}updateConfig(e){e.options.animation=!1}}const tg="$chartjs",AQ={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},CT=i=>i===null||i==="";function CQ(i,e){const t=i.style,n=i.getAttribute("height"),s=i.getAttribute("width");if(i[tg]={initial:{height:n,width:s,style:{display:t.display,height:t.height,width:t.width}}},t.display=t.display||"block",t.boxSizing=t.boxSizing||"border-box",CT(s)){const a=hT(i,"width");a!==void 0&&(i.width=a)}if(CT(n))if(i.style.height==="")i.height=i.width/(e||2);else{const a=hT(i,"height");a!==void 0&&(i.height=a)}return i}const TL=BG?{passive:!0}:!1;function OQ(i,e,t){i&&i.addEventListener(e,t,TL)}function TQ(i,e,t){i&&i.canvas&&i.canvas.removeEventListener(e,t,TL)}function MQ(i,e){const t=AQ[i.type]||i.type,{x:n,y:s}=ll(i,e);return{type:t,chart:e,native:i,x:n!==void 0?n:null,y:s!==void 0?s:null}}function Ug(i,e){for(const t of i)if(t===e||t.contains(e))return!0}function NQ(i,e,t){const n=i.canvas,s=new MutationObserver(a=>{let r=!1;for(const o of a)r=r||Ug(o.addedNodes,n),r=r&&!Ug(o.removedNodes,n);r&&t()});return s.observe(document,{childList:!0,subtree:!0}),s}function RQ(i,e,t){const n=i.canvas,s=new MutationObserver(a=>{let r=!1;for(const o of a)r=r||Ug(o.removedNodes,n),r=r&&!Ug(o.addedNodes,n);r&&t()});return s.observe(document,{childList:!0,subtree:!0}),s}const Fh=new Map;let OT=0;function ML(){const i=window.devicePixelRatio;i!==OT&&(OT=i,Fh.forEach((e,t)=>{t.currentDevicePixelRatio!==i&&e()}))}function PQ(i,e){Fh.size||window.addEventListener("resize",ML),Fh.set(i,e)}function LQ(i){Fh.delete(i),Fh.size||window.removeEventListener("resize",ML)}function jQ(i,e,t){const n=i.canvas,s=n&&C2(n);if(!s)return;const a=oL((o,c)=>{const d=s.clientWidth;t(o,c),d{const c=o[0],d=c.contentRect.width,h=c.contentRect.height;d===0&&h===0||a(d,h)});return r.observe(s),PQ(i,a),r}function W1(i,e,t){t&&t.disconnect(),e==="resize"&&LQ(i)}function EQ(i,e,t){const n=i.canvas,s=oL(a=>{i.ctx!==null&&t(MQ(a,i))},i);return OQ(n,e,s),s}class DQ extends OL{acquireContext(e,t){const n=e&&e.getContext&&e.getContext("2d");return n&&n.canvas===e?(CQ(e,t),n):null}releaseContext(e){const t=e.canvas;if(!t[tg])return!1;const n=t[tg].initial;["height","width"].forEach(a=>{const r=n[a];It(r)?t.removeAttribute(a):t.setAttribute(a,r)});const s=n.style||{};return Object.keys(s).forEach(a=>{t.style[a]=s[a]}),t.width=t.width,delete t[tg],!0}addEventListener(e,t,n){this.removeEventListener(e,t);const s=e.$proxies||(e.$proxies={}),r={attach:NQ,detach:RQ,resize:jQ}[t]||EQ;s[t]=r(e,t,n)}removeEventListener(e,t){const n=e.$proxies||(e.$proxies={}),s=n[t];if(!s)return;({attach:W1,detach:W1,resize:W1}[t]||TQ)(e,t,s),n[t]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,t,n,s){return FG(e,t,n,s)}isAttached(e){const t=e&&C2(e);return!!(t&&t.isConnected)}}function UQ(i){return!A2()||typeof OffscreenCanvas!="undefined"&&i instanceof OffscreenCanvas?kQ:DQ}class br{constructor(){Ge(this,"x");Ge(this,"y");Ge(this,"active",!1);Ge(this,"options");Ge(this,"$animations")}tooltipPosition(e){const{x:t,y:n}=this.getProps(["x","y"],e);return{x:t,y:n}}hasValue(){return Eh(this.x)&&Eh(this.y)}getProps(e,t){const n=this.$animations;if(!t||!n)return this;const s={};return e.forEach(a=>{s[a]=n[a]&&n[a].active()?n[a]._to:this[a]}),s}}Ge(br,"defaults",{}),Ge(br,"defaultRoutes");function FQ(i,e){const t=i.options.ticks,n=BQ(i),s=Math.min(t.maxTicksLimit||n,n),a=t.major.enabled?qQ(e):[],r=a.length,o=a[0],c=a[r-1],d=[];if(r>s)return HQ(e,d,a,r/s),d;const h=zQ(a,e,s);if(r>0){let p,_;const y=r>1?Math.round((c-o)/(r-1)):null;for(fm(e,d,h,It(y)?0:o-y,o),p=0,_=r-1;p<_;p++)fm(e,d,h,a[p],a[p+1]);return fm(e,d,h,c,It(y)?e.length:c+y),d}return fm(e,d,h),d}function BQ(i){const e=i.options.offset,t=i._tickSize(),n=i._length/t+(e?0:1),s=i._maxLength/t;return Math.floor(Math.min(n,s))}function zQ(i,e,t){const n=KQ(i),s=e.length/t;if(!n)return Math.max(s,1);const a=jX(n);for(let r=0,o=a.length-1;rs)return c}return Math.max(s,1)}function qQ(i){const e=[];let t,n;for(t=0,n=i.length;ti==="left"?"right":i==="right"?"left":i,TT=(i,e,t)=>e==="top"||e==="left"?i[e]+t:i[e]-t,MT=(i,e)=>Math.min(e||i,i);function NT(i,e){const t=[],n=i.length/e,s=i.length;let a=0;for(;ar+o)))return c}function WQ(i,e){jt(i,t=>{const n=t.gc,s=n.length/2;let a;if(s>e){for(a=0;an?n:t,n=s&&t>n?t:n,{min:ha(t,ha(n,t)),max:ha(n,ha(t,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(e))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){Qt(this.options.beforeUpdate,[this])}update(e,t,n){const{beginAtZero:s,grace:a,ticks:r}=this.options,o=r.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=t,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=gG(this,a,s),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const c=o=a||n<=1||!this.isHorizontal()){this.labelRotation=s;return}const h=this._getLabelSizes(),p=h.widest.width,_=h.highest.height,y=Es(this.chart.width-p,0,this.maxWidth);o=e.offset?this.maxWidth/n:y/(n-1),p+6>o&&(o=y/(n-(e.offset?.5:1)),c=this.maxHeight-Ed(e.grid)-t.padding-RT(e.title,this.chart.options.font),d=Math.sqrt(p*p+_*_),r=FX(Math.min(Math.asin(Es((h.highest.height+6)/o,-1,1)),Math.asin(Es(c/d,-1,1))-Math.asin(Es(_/d,-1,1)))),r=Math.max(s,Math.min(a,r))),this.labelRotation=r}afterCalculateLabelRotation(){Qt(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){Qt(this.options.beforeFit,[this])}fit(){const e={width:0,height:0},{chart:t,options:{ticks:n,title:s,grid:a}}=this,r=this._isVisible(),o=this.isHorizontal();if(r){const c=RT(s,t.options.font);if(o?(e.width=this.maxWidth,e.height=Ed(a)+c):(e.height=this.maxHeight,e.width=Ed(a)+c),n.display&&this.ticks.length){const{first:d,last:h,widest:p,highest:_}=this._getLabelSizes(),y=n.padding*2,x=xl(this.labelRotation),v=Math.cos(x),w=Math.sin(x);if(o){const k=n.mirror?0:w*p.width+v*_.height;e.height=Math.min(this.maxHeight,e.height+k+y)}else{const k=n.mirror?0:v*p.width+w*_.height;e.width=Math.min(this.maxWidth,e.width+k+y)}this._calculatePadding(d,h,w,v)}}this._handleMargins(),o?(this.width=this._length=t.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=t.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,t,n,s){const{ticks:{align:a,padding:r},position:o}=this.options,c=this.labelRotation!==0,d=o!=="top"&&this.axis==="x";if(this.isHorizontal()){const h=this.getPixelForTick(0)-this.left,p=this.right-this.getPixelForTick(this.ticks.length-1);let _=0,y=0;c?d?(_=s*e.width,y=n*t.height):(_=n*e.height,y=s*t.width):a==="start"?y=t.width:a==="end"?_=e.width:a!=="inner"&&(_=e.width/2,y=t.width/2),this.paddingLeft=Math.max((_-h+r)*this.width/(this.width-h),0),this.paddingRight=Math.max((y-p+r)*this.width/(this.width-p),0)}else{let h=t.height/2,p=e.height/2;a==="start"?(h=0,p=e.height):a==="end"&&(h=t.height,p=0),this.paddingTop=h+r,this.paddingBottom=p+r}}_handleMargins(){this._margins&&(this._margins.left=Math.max(this.paddingLeft,this._margins.left),this._margins.top=Math.max(this.paddingTop,this._margins.top),this._margins.right=Math.max(this.paddingRight,this._margins.right),this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom))}afterFit(){Qt(this.options.afterFit,[this])}isHorizontal(){const{axis:e,position:t}=this.options;return t==="top"||t==="bottom"||e==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let t,n;for(t=0,n=e.length;t({width:r[L]||0,height:o[L]||0});return{first:E(0),last:E(t-1),widest:E(P),highest:E(R),widths:r,heights:o}}getLabelForValue(e){return e}getPixelForValue(e,t){return NaN}getValueForPixel(e){}getPixelForTick(e){const t=this.ticks;return e<0||e>t.length-1?null:this.getPixelForValue(t[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);const t=this._startPixel+e*this._length;return qX(this._alignToPixels?sl(this.chart,t,0):t)}getDecimalForPixel(e){const t=(e-this._startPixel)/this._length;return this._reversePixels?1-t:t}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:e,max:t}=this;return e<0&&t<0?t:e>0&&t>0?e:0}getContext(e){const t=this.ticks||[];if(e>=0&&eo*s?o/n:c/s:c*s0}_computeGridLineItems(e){const t=this.axis,n=this.chart,s=this.options,{grid:a,position:r,border:o}=s,c=a.offset,d=this.isHorizontal(),p=this.ticks.length+(c?1:0),_=Ed(a),y=[],x=o.setContext(this.getContext()),v=x.display?x.width:0,w=v/2,k=function(U){return sl(n,U,v)};let M,O,A,C,P,R,E,L,D,q,B,H;if(r==="top")M=k(this.bottom),R=this.bottom-_,L=M-w,q=k(e.top)+w,H=e.bottom;else if(r==="bottom")M=k(this.top),q=e.top,H=k(e.bottom)-w,R=M+w,L=this.top+_;else if(r==="left")M=k(this.right),P=this.right-_,E=M-w,D=k(e.left)+w,B=e.right;else if(r==="right")M=k(this.left),D=e.left,B=k(e.right)-w,P=M+w,E=this.left+_;else if(t==="x"){if(r==="center")M=k((e.top+e.bottom)/2+.5);else if(pt(r)){const U=Object.keys(r)[0],G=r[U];M=k(this.chart.scales[U].getPixelForValue(G))}q=e.top,H=e.bottom,R=M+w,L=R+_}else if(t==="y"){if(r==="center")M=k((e.left+e.right)/2);else if(pt(r)){const U=Object.keys(r)[0],G=r[U];M=k(this.chart.scales[U].getPixelForValue(G))}P=M-w,E=P-_,D=e.left,B=e.right}const W=dt(s.ticks.maxTicksLimit,p),V=Math.max(1,Math.ceil(p/W));for(O=0;O0&&(Se-=J/2);break}F={left:Se,top:me,width:J+Y.width,height:ce+Y.height,color:V.backdropColor}}w.push({label:A,font:L,textOffset:B,options:{rotation:v,color:G,strokeColor:$,strokeWidth:ie,textAlign:ue,textBaseline:H,translation:[C,P],backdrop:F}})}return w}_getXAxisLabelAlignment(){const{position:e,ticks:t}=this.options;if(-xl(this.labelRotation))return e==="top"?"left":"right";let s="center";return t.align==="start"?s="left":t.align==="end"?s="right":t.align==="inner"&&(s="inner"),s}_getYAxisLabelAlignment(e){const{position:t,ticks:{crossAlign:n,mirror:s,padding:a}}=this.options,r=this._getLabelSizes(),o=e+a,c=r.widest.width;let d,h;return t==="left"?s?(h=this.right+a,n==="near"?d="left":n==="center"?(d="center",h+=c/2):(d="right",h+=c)):(h=this.right-o,n==="near"?d="right":n==="center"?(d="center",h-=c/2):(d="left",h=this.left)):t==="right"?s?(h=this.left+a,n==="near"?d="right":n==="center"?(d="center",h-=c/2):(d="left",h-=c)):(h=this.left+o,n==="near"?d="left":n==="center"?(d="center",h+=c/2):(d="right",h=this.right)):d="right",{textAlign:d,x:h}}_computeLabelArea(){if(this.options.ticks.mirror)return;const e=this.chart,t=this.options.position;if(t==="left"||t==="right")return{top:0,left:this.left,bottom:e.height,right:this.right};if(t==="top"||t==="bottom")return{top:this.top,left:0,bottom:this.bottom,right:e.width}}drawBackground(){const{ctx:e,options:{backgroundColor:t},left:n,top:s,width:a,height:r}=this;t&&(e.save(),e.fillStyle=t,e.fillRect(n,s,a,r),e.restore())}getLineWidthForValue(e){const t=this.options.grid;if(!this._isVisible()||!t.display)return 0;const s=this.ticks.findIndex(a=>a.value===e);return s>=0?t.setContext(this.getContext(s)).lineWidth:0}drawGrid(e){const t=this.options.grid,n=this.ctx,s=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(e));let a,r;const o=(c,d,h)=>{!h.width||!h.color||(n.save(),n.lineWidth=h.width,n.strokeStyle=h.color,n.setLineDash(h.borderDash||[]),n.lineDashOffset=h.borderDashOffset,n.beginPath(),n.moveTo(c.x,c.y),n.lineTo(d.x,d.y),n.stroke(),n.restore())};if(t.display)for(a=0,r=s.length;a{this.draw(a)}}]:[{z:n,draw:a=>{this.drawBackground(),this.drawGrid(a),this.drawTitle()}},{z:s,draw:()=>{this.drawBorder()}},{z:t,draw:a=>{this.drawLabels(a)}}]}getMatchingVisibleMetas(e){const t=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",s=[];let a,r;for(a=0,r=t.length;a{const n=t.split("."),s=n.pop(),a=[i].concat(n).join("."),r=e[t].split("."),o=r.pop(),c=r.join(".");xi.route(a,s,c,o)})}function $Q(i){return"id"in i&&"defaults"in i}class eY{constructor(){this.controllers=new pm(hh,"datasets",!0),this.elements=new pm(br,"elements"),this.plugins=new pm(Object,"plugins"),this.scales=new pm(Ou,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each("register",e)}remove(...e){this._each("unregister",e)}addControllers(...e){this._each("register",e,this.controllers)}addElements(...e){this._each("register",e,this.elements)}addPlugins(...e){this._each("register",e,this.plugins)}addScales(...e){this._each("register",e,this.scales)}getController(e){return this._get(e,this.controllers,"controller")}getElement(e){return this._get(e,this.elements,"element")}getPlugin(e){return this._get(e,this.plugins,"plugin")}getScale(e){return this._get(e,this.scales,"scale")}removeControllers(...e){this._each("unregister",e,this.controllers)}removeElements(...e){this._each("unregister",e,this.elements)}removePlugins(...e){this._each("unregister",e,this.plugins)}removeScales(...e){this._each("unregister",e,this.scales)}_each(e,t,n){[...t].forEach(s=>{const a=n||this._getRegistryForType(s);n||a.isForType(s)||a===this.plugins&&s.id?this._exec(e,a,s):jt(s,r=>{const o=n||this._getRegistryForType(r);this._exec(e,o,r)})})}_exec(e,t,n){const s=y2(e);Qt(n["before"+s],[],n),t[e](n),Qt(n["after"+s],[],n)}_getRegistryForType(e){for(let t=0;ta.filter(o=>!r.some(c=>o.plugin.id===c.plugin.id));this._notify(s(t,n),e,"stop"),this._notify(s(n,t),e,"start")}}function iY(i){const e={},t=[],n=Object.keys(ba.plugins.items);for(let a=0;a1&&PT(i[0].toLowerCase());if(n)return n}throw new Error(`Cannot determine type of '${i}' axis. Please provide 'axis' or 'position' option.`)}function LT(i,e,t){if(t[e+"AxisID"]===i)return{axis:e}}function cY(i,e){if(e.data&&e.data.datasets){const t=e.data.datasets.filter(n=>n.xAxisID===i||n.yAxisID===i);if(t.length)return LT(i,"x",t[0])||LT(i,"y",t[0])}return{}}function uY(i,e){const t=El[i.type]||{scales:{}},n=e.scales||{},s=pb(i.type,e),a=Object.create(null);return Object.keys(n).forEach(r=>{const o=n[r];if(!pt(o))return console.error(`Invalid scale configuration for scale: ${r}`);if(o._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${r}`);const c=mb(r,o,cY(r,i),xi.scales[o.type]),d=oY(c,s),h=t.scales||{};a[r]=oh(Object.create(null),[{axis:c},o,h[c],h[d]])}),i.data.datasets.forEach(r=>{const o=r.type||i.type,c=r.indexAxis||pb(o,e),h=(El[o]||{}).scales||{};Object.keys(h).forEach(p=>{const _=rY(p,c),y=r[_+"AxisID"]||_;a[y]=a[y]||Object.create(null),oh(a[y],[{axis:_},n[y],h[p]])})}),Object.keys(a).forEach(r=>{const o=a[r];oh(o,[xi.scales[o.type],xi.scale])}),a}function NL(i){const e=i.options||(i.options={});e.plugins=dt(e.plugins,{}),e.scales=uY(i,e)}function RL(i){return i=i||{},i.datasets=i.datasets||[],i.labels=i.labels||[],i}function dY(i){return i=i||{},i.data=RL(i.data),NL(i),i}const jT=new Map,PL=new Set;function mm(i,e){let t=jT.get(i);return t||(t=e(),jT.set(i,t),PL.add(t)),t}const Dd=(i,e,t)=>{const n=Lg(e,t);n!==void 0&&i.add(n)};class hY{constructor(e){this._config=dY(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=RL(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){const e=this._config;this.clearCache(),NL(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return mm(e,()=>[[`datasets.${e}`,""]])}datasetAnimationScopeKeys(e,t){return mm(`${e}.transition.${t}`,()=>[[`datasets.${e}.transitions.${t}`,`transitions.${t}`],[`datasets.${e}`,""]])}datasetElementScopeKeys(e,t){return mm(`${e}-${t}`,()=>[[`datasets.${e}.elements.${t}`,`datasets.${e}`,`elements.${t}`,""]])}pluginScopeKeys(e){const t=e.id,n=this.type;return mm(`${n}-plugin-${t}`,()=>[[`plugins.${t}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,t){const n=this._scopeCache;let s=n.get(e);return(!s||t)&&(s=new Map,n.set(e,s)),s}getOptionScopes(e,t,n){const{options:s,type:a}=this,r=this._cachedScopes(e,n),o=r.get(t);if(o)return o;const c=new Set;t.forEach(h=>{e&&(c.add(e),h.forEach(p=>Dd(c,e,p))),h.forEach(p=>Dd(c,s,p)),h.forEach(p=>Dd(c,El[a]||{},p)),h.forEach(p=>Dd(c,xi,p)),h.forEach(p=>Dd(c,db,p))});const d=Array.from(c);return d.length===0&&d.push(Object.create(null)),PL.has(t)&&r.set(t,d),d}chartOptionScopes(){const{options:e,type:t}=this;return[e,El[t]||{},xi.datasets[t]||{},{type:t},xi,db]}resolveNamedOptions(e,t,n,s=[""]){const a={$shared:!0},{resolver:r,subPrefixes:o}=ET(this._resolverCache,e,s);let c=r;if(pY(r,t)){a.$shared=!1,n=Ao(n)?n():n;const d=this.createResolver(e,n,o);c=hu(r,n,d)}for(const d of t)a[d]=c[d];return a}createResolver(e,t,n=[""],s){const{resolver:a}=ET(this._resolverCache,e,n);return pt(t)?hu(a,t,void 0,s):a}}function ET(i,e,t){let n=i.get(e);n||(n=new Map,i.set(e,n));const s=t.join();let a=n.get(s);return a||(a={resolver:S2(e,t),subPrefixes:t.filter(o=>!o.toLowerCase().includes("hover"))},n.set(s,a)),a}const fY=i=>pt(i)&&Object.getOwnPropertyNames(i).some(e=>Ao(i[e]));function pY(i,e){const{isScriptable:t,isIndexable:n}=hL(i);for(const s of e){const a=t(s),r=n(s),o=(r||a)&&i[s];if(a&&(Ao(o)||fY(o))||r&&Ui(o))return!0}return!1}var mY="4.5.1";const gY=["top","bottom","left","right","chartArea"];function DT(i,e){return i==="top"||i==="bottom"||gY.indexOf(i)===-1&&e==="x"}function UT(i,e){return function(t,n){return t[i]===n[i]?t[e]-n[e]:t[i]-n[i]}}function FT(i){const e=i.chart,t=e.options.animation;e.notifyPlugins("afterRender"),Qt(t&&t.onComplete,[i],e)}function _Y(i){const e=i.chart,t=e.options.animation;Qt(t&&t.onProgress,[i],e)}function LL(i){return A2()&&typeof i=="string"?i=document.getElementById(i):i&&i.length&&(i=i[0]),i&&i.canvas&&(i=i.canvas),i}const ig={},BT=i=>{const e=LL(i);return Object.values(ig).filter(t=>t.canvas===e).pop()};function yY(i,e,t){const n=Object.keys(i);for(const s of n){const a=+s;if(a>=e){const r=i[s];delete i[s],(t>0||a>e)&&(i[a+t]=r)}}}function xY(i,e,t,n){return!t||i.type==="mouseout"?null:n?e:i}var no;let j0=(no=class{static register(...e){ba.add(...e),zT()}static unregister(...e){ba.remove(...e),zT()}constructor(e,t){const n=this.config=new hY(t),s=LL(e),a=BT(s);if(a)throw new Error("Canvas is already in use. Chart with ID '"+a.id+"' must be destroyed before the canvas with ID '"+a.canvas.id+"' can be reused.");const r=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||UQ(s)),this.platform.updateConfig(n);const o=this.platform.acquireContext(s,r.aspectRatio),c=o&&o.canvas,d=c&&c.height,h=c&&c.width;if(this.id=AX(),this.ctx=o,this.canvas=c,this.width=h,this.height=d,this._options=r,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new tY,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=WX(p=>this.update(p),r.resizeDelay||0),this._dataChanges=[],ig[this.id]=this,!o||!c){console.error("Failed to create chart: can't acquire context from the given item");return}sr.listen(this,"complete",FT),sr.listen(this,"progress",_Y),this._initialize(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:e,maintainAspectRatio:t},width:n,height:s,_aspectRatio:a}=this;return It(e)?t&&a?a:s?n/s:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return ba}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():dT(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return lT(this.canvas,this.ctx),this}stop(){return sr.stop(this),this}resize(e,t){sr.running(this)?this._resizeBeforeDraw={width:e,height:t}:this._resize(e,t)}_resize(e,t){const n=this.options,s=this.canvas,a=n.maintainAspectRatio&&this.aspectRatio,r=this.platform.getMaximumSize(s,e,t,a),o=n.devicePixelRatio||this.platform.getDevicePixelRatio(),c=this.width?"resize":"attach";this.width=r.width,this.height=r.height,this._aspectRatio=this.aspectRatio,dT(this,o,!0)&&(this.notifyPlugins("resize",{size:r}),Qt(n.onResize,[this,r],this),this.attached&&this._doResize(c)&&this.render())}ensureScalesHaveIDs(){const t=this.options.scales||{};jt(t,(n,s)=>{n.id=s})}buildOrUpdateScales(){const e=this.options,t=e.scales,n=this.scales,s=Object.keys(n).reduce((r,o)=>(r[o]=!1,r),{});let a=[];t&&(a=a.concat(Object.keys(t).map(r=>{const o=t[r],c=mb(r,o),d=c==="r",h=c==="x";return{options:o,dposition:d?"chartArea":h?"bottom":"left",dtype:d?"radialLinear":h?"category":"linear"}}))),jt(a,r=>{const o=r.options,c=o.id,d=mb(c,o),h=dt(o.type,r.dtype);(o.position===void 0||DT(o.position,d)!==DT(r.dposition))&&(o.position=r.dposition),s[c]=!0;let p=null;if(c in n&&n[c].type===h)p=n[c];else{const _=ba.getScale(h);p=new _({id:c,type:h,ctx:this.ctx,chart:this}),n[p.id]=p}p.init(o,e)}),jt(s,(r,o)=>{r||delete n[o]}),jt(n,r=>{Ds.configure(this,r,r.options),Ds.addBox(this,r)})}_updateMetasets(){const e=this._metasets,t=this.data.datasets.length,n=e.length;if(e.sort((s,a)=>s.index-a.index),n>t){for(let s=t;st.length&&delete this._stacks,e.forEach((n,s)=>{t.filter(a=>a===n._dataset).length===0&&this._destroyDatasetMeta(s)})}buildOrUpdateControllers(){const e=[],t=this.data.datasets;let n,s;for(this._removeUnreferencedMetasets(),n=0,s=t.length;n{this.getDatasetMeta(t).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(e){const t=this.config;t.update();const n=this._options=t.createResolver(t.chartOptionScopes(),this.getContext()),s=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:e,cancelable:!0})===!1)return;const a=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let r=0;for(let d=0,h=this.data.datasets.length;d{d.reset()}),this._updateDatasets(e),this.notifyPlugins("afterUpdate",{mode:e}),this._layers.sort(UT("z","_idx"));const{_active:o,_lastEvent:c}=this;c?this._eventHandler(c,!0):o.length&&this._updateHoverStyles(o,o,!0),this.render()}_updateScales(){jt(this.scales,e=>{Ds.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const e=this.options,t=new Set(Object.keys(this._listeners)),n=new Set(e.events);(!JO(t,n)||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:e}=this,t=this._getUniformDataChanges()||[];for(const{method:n,start:s,count:a}of t){const r=n==="_removeElements"?-a:a;yY(e,s,r)}}_getUniformDataChanges(){const e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];const t=this.data.datasets.length,n=a=>new Set(e.filter(r=>r[0]===a).map((r,o)=>o+","+r.splice(1).join(","))),s=n(0);for(let a=1;aa.split(",")).map(a=>({method:a[1],start:+a[2],count:+a[3]}))}_updateLayout(e){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;Ds.update(this,this.width,this.height,e);const t=this.chartArea,n=t.width<=0||t.height<=0;this._layers=[],jt(this.boxes,s=>{n&&s.position==="chartArea"||(s.configure&&s.configure(),this._layers.push(...s._layers()))},this),this._layers.forEach((s,a)=>{s._idx=a}),this.notifyPlugins("afterLayout")}_updateDatasets(e){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:e,cancelable:!0})!==!1){for(let t=0,n=this.data.datasets.length;t=0;--t)this._drawDataset(e[t]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(e){const t=this.ctx,n={meta:e,index:e.index,cancelable:!0},s=SL(this,e);this.notifyPlugins("beforeDatasetDraw",n)!==!1&&(s&&N0(t,s),e.controller.draw(),s&&R0(t),n.cancelable=!1,this.notifyPlugins("afterDatasetDraw",n))}isPointInArea(e){return Dh(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,t,n,s){const a=gQ.modes[t];return typeof a=="function"?a(this,e,n,s):[]}getDatasetMeta(e){const t=this.data.datasets[e],n=this._metasets;let s=n.filter(a=>a&&a._dataset===t).pop();return s||(s={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:t&&t.order||0,index:e,_dataset:t,_parsed:[],_sorted:!1},n.push(s)),s}getContext(){return this.$context||(this.$context=Il(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){const t=this.data.datasets[e];if(!t)return!1;const n=this.getDatasetMeta(e);return typeof n.hidden=="boolean"?!n.hidden:!t.hidden}setDatasetVisibility(e,t){const n=this.getDatasetMeta(e);n.hidden=!t}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,t,n){const s=n?"show":"hide",a=this.getDatasetMeta(e),r=a.controller._resolveAnimations(void 0,s);jg(t)?(a.data[t].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),r.update(a,{visible:n}),this.update(o=>o.datasetIndex===e?s:void 0))}hide(e,t){this._updateVisibility(e,t,!1)}show(e,t){this._updateVisibility(e,t,!0)}_destroyDatasetMeta(e){const t=this._metasets[e];t&&t.controller&&t.controller._destroy(),delete this._metasets[e]}_stop(){let e,t;for(this.stop(),sr.remove(this),e=0,t=this.data.datasets.length;e{t.addEventListener(this,a,r),e[a]=r},s=(a,r,o)=>{a.offsetX=r,a.offsetY=o,this._eventHandler(a)};jt(this.options.events,a=>n(a,s))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const e=this._responsiveListeners,t=this.platform,n=(c,d)=>{t.addEventListener(this,c,d),e[c]=d},s=(c,d)=>{e[c]&&(t.removeEventListener(this,c,d),delete e[c])},a=(c,d)=>{this.canvas&&this.resize(c,d)};let r;const o=()=>{s("attach",o),this.attached=!0,this.resize(),n("resize",a),n("detach",r)};r=()=>{this.attached=!1,s("resize",a),this._stop(),this._resize(0,0),n("attach",o)},t.isAttached(this.canvas)?o():r()}unbindEvents(){jt(this._listeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._listeners={},jt(this._responsiveListeners,(e,t)=>{this.platform.removeEventListener(this,t,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,t,n){const s=n?"set":"remove";let a,r,o,c;for(t==="dataset"&&(a=this.getDatasetMeta(e[0].datasetIndex),a.controller["_"+s+"DatasetHoverStyle"]()),o=0,c=e.length;o{const o=this.getDatasetMeta(a);if(!o)throw new Error("No dataset found at index "+a);return{datasetIndex:a,element:o.data[r],index:r}});!Rg(n,t)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,t))}notifyPlugins(e,t,n){return this._plugins.notify(this,e,t,n)}isPluginEnabled(e){return this._plugins._cache.filter(t=>t.plugin.id===e).length===1}_updateHoverStyles(e,t,n){const s=this.options.hover,a=(c,d)=>c.filter(h=>!d.some(p=>h.datasetIndex===p.datasetIndex&&h.index===p.index)),r=a(t,e),o=n?e:a(e,t);r.length&&this.updateHoverStyle(r,s.mode,!1),o.length&&s.mode&&this.updateHoverStyle(o,s.mode,!0)}_eventHandler(e,t){const n={event:e,replay:t,cancelable:!0,inChartArea:this.isPointInArea(e)},s=r=>(r.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins("beforeEvent",n,s)===!1)return;const a=this._handleEvent(e,t,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,s),(a||n.changed)&&this.render(),this}_handleEvent(e,t,n){const{_active:s=[],options:a}=this,r=t,o=this._getActiveElements(e,s,n,r),c=RX(e),d=xY(e,this._lastEvent,n,c);n&&(this._lastEvent=null,Qt(a.onHover,[e,o,this],this),c&&Qt(a.onClick,[e,o,this],this));const h=!Rg(o,s);return(h||t)&&(this._active=o,this._updateHoverStyles(o,s,t)),this._lastEvent=d,h}_getActiveElements(e,t,n,s){if(e.type==="mouseout")return[];if(!n)return t;const a=this.options.hover;return this.getElementsAtEventForMode(e,a.mode,a,s)}},Ge(no,"defaults",xi),Ge(no,"instances",ig),Ge(no,"overrides",El),Ge(no,"registry",ba),Ge(no,"version",mY),Ge(no,"getChart",BT),no);function zT(){return jt(j0.instances,i=>i._plugins.invalidate())}function jL(i,e,t=e){i.lineCap=dt(t.borderCapStyle,e.borderCapStyle),i.setLineDash(dt(t.borderDash,e.borderDash)),i.lineDashOffset=dt(t.borderDashOffset,e.borderDashOffset),i.lineJoin=dt(t.borderJoinStyle,e.borderJoinStyle),i.lineWidth=dt(t.borderWidth,e.borderWidth),i.strokeStyle=dt(t.borderColor,e.borderColor)}function bY(i,e,t){i.lineTo(t.x,t.y)}function vY(i){return i.stepped?rG:i.tension||i.cubicInterpolationMode==="monotone"?oG:bY}function EL(i,e,t={}){const n=i.length,{start:s=0,end:a=n-1}=t,{start:r,end:o}=e,c=Math.max(s,r),d=Math.min(a,o),h=so&&a>o;return{count:n,start:c,loop:e.loop,ilen:d(r+(d?o-A:A))%a,O=()=>{v!==w&&(i.lineTo(h,w),i.lineTo(h,v),i.lineTo(h,k))};for(c&&(y=s[M(0)],i.moveTo(y.x,y.y)),_=0;_<=o;++_){if(y=s[M(_)],y.skip)continue;const A=y.x,C=y.y,P=A|0;P===x?(Cw&&(w=C),h=(p*h+A)/++p):(O(),i.lineTo(A,C),x=P,p=0,v=w=C),k=C}O()}function gb(i){const e=i.options,t=e.borderDash&&e.borderDash.length;return!i._decimated&&!i._loop&&!e.tension&&e.cubicInterpolationMode!=="monotone"&&!e.stepped&&!t?wY:SY}function kY(i){return i.stepped?zG:i.tension||i.cubicInterpolationMode==="monotone"?qG:cl}function AY(i,e,t,n){let s=e._path;s||(s=e._path=new Path2D,e.path(s,t,n)&&s.closePath()),jL(i,e.options),i.stroke(s)}function CY(i,e,t,n){const{segments:s,options:a}=e,r=gb(e);for(const o of s)jL(i,a,o.style),i.beginPath(),r(i,e,o,{start:t,end:t+n-1})&&i.closePath(),i.stroke()}const OY=typeof Path2D=="function";function TY(i,e,t,n){OY&&!e.options.segment?AY(i,e,t,n):CY(i,e,t,n)}class po extends br{constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,t){const n=this.options;if((n.tension||n.cubicInterpolationMode==="monotone")&&!n.stepped&&!this._pointsUpdated){const s=n.spanGaps?this._loop:this._fullLoop;PG(this._points,n,e,s,t),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=XG(this,this.options.segment))}first(){const e=this.segments,t=this.points;return e.length&&t[e[0].start]}last(){const e=this.segments,t=this.points,n=e.length;return n&&t[e[n-1].end]}interpolate(e,t){const n=this.options,s=e[t],a=this.points,r=vL(this,{property:t,start:s,end:s});if(!r.length)return;const o=[],c=kY(n);let d,h;for(d=0,h=r.length;de!=="borderDash"&&e!=="fill"});function qT(i,e,t,n){const s=i.options,{[t]:a}=i.getProps([t],n);return Math.abs(e-a){o=E0(r,o,s);const c=s[r],d=s[o];n!==null?(a.push({x:c.x,y:n}),a.push({x:d.x,y:n})):t!==null&&(a.push({x:t,y:c.y}),a.push({x:t,y:d.y}))}),a}function E0(i,e,t){for(;e>i;e--){const n=t[e];if(!isNaN(n.x)&&!isNaN(n.y))break}return e}function HT(i,e,t,n){return i&&e?n(i[t],e[t]):i?i[t]:e?e[t]:0}function DL(i,e){let t=[],n=!1;return Ui(i)?(n=!0,t=i):t=NY(i,e),t.length?new po({points:t,options:{tension:0},_loop:n,_fullLoop:n}):null}function KT(i){return i&&i.fill!==!1}function RY(i,e,t){let s=i[e].fill;const a=[e];let r;if(!t)return s;for(;s!==!1&&a.indexOf(s)===-1;){if(!mn(s))return s;if(r=i[s],!r)return!1;if(r.visible)return s;a.push(s),s=r.fill}return!1}function PY(i,e,t){const n=DY(i);if(pt(n))return isNaN(n.value)?!1:n;let s=parseFloat(n);return mn(s)&&Math.floor(s)===s?LY(n[0],e,s,t):["origin","start","end","stack","shape"].indexOf(n)>=0&&n}function LY(i,e,t,n){return(i==="-"||i==="+")&&(t=e+t),t===e||t<0||t>=n?!1:t}function jY(i,e){let t=null;return i==="start"?t=e.bottom:i==="end"?t=e.top:pt(i)?t=e.getPixelForValue(i.value):e.getBasePixel&&(t=e.getBasePixel()),t}function EY(i,e,t){let n;return i==="start"?n=t:i==="end"?n=e.options.reverse?e.min:e.max:pt(i)?n=i.value:n=e.getBaseValue(),n}function DY(i){const e=i.options,t=e.fill;let n=dt(t&&t.target,t);return n===void 0&&(n=!!e.backgroundColor),n===!1||n===null?!1:n===!0?"origin":n}function UY(i){const{scale:e,index:t,line:n}=i,s=[],a=n.segments,r=n.points,o=FY(e,t);o.push(DL({x:null,y:e.bottom},n));for(let c=0;c=0;--r){const o=s[r].$filler;o&&(o.line.updateControlPoints(a,o.axis),n&&o.fill&&X1(i.ctx,o,a))}},beforeDatasetsDraw(i,e,t){if(t.drawTime!=="beforeDatasetsDraw")return;const n=i.getSortedVisibleDatasetMetas();for(let s=n.length-1;s>=0;--s){const a=n[s].$filler;KT(a)&&X1(i.ctx,a,i.chartArea)}},beforeDatasetDraw(i,e,t){const n=e.meta.$filler;!KT(n)||t.drawTime!=="beforeDatasetDraw"||X1(i.ctx,n,i.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const XT=(i,e)=>{let{boxHeight:t=e,boxWidth:n=e}=i;return i.usePointStyle&&(t=Math.min(t,e),n=i.pointStyleWidth||Math.min(n,e)),{boxWidth:n,boxHeight:t,itemHeight:Math.max(e,t)}},QY=(i,e)=>i!==null&&e!==null&&i.datasetIndex===e.datasetIndex&&i.index===e.index;class GT extends br{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t,n){this.maxWidth=e,this.maxHeight=t,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const e=this.options.labels||{};let t=Qt(e.generateLabels,[this.chart],this)||[];e.filter&&(t=t.filter(n=>e.filter(n,this.chart.data))),e.sort&&(t=t.sort((n,s)=>e.sort(n,s,this.chart.data))),this.options.reverse&&t.reverse(),this.legendItems=t}fit(){const{options:e,ctx:t}=this;if(!e.display){this.width=this.height=0;return}const n=e.labels,s=hn(n.font),a=s.size,r=this._computeTitleHeight(),{boxWidth:o,itemHeight:c}=XT(n,a);let d,h;t.font=s.string,this.isHorizontal()?(d=this.maxWidth,h=this._fitRows(r,a,o,c)+10):(h=this.maxHeight,d=this._fitCols(r,s,o,c)+10),this.width=Math.min(d,e.maxWidth||this.maxWidth),this.height=Math.min(h,e.maxHeight||this.maxHeight)}_fitRows(e,t,n,s){const{ctx:a,maxWidth:r,options:{labels:{padding:o}}}=this,c=this.legendHitBoxes=[],d=this.lineWidths=[0],h=s+o;let p=e;a.textAlign="left",a.textBaseline="middle";let _=-1,y=-h;return this.legendItems.forEach((x,v)=>{const w=n+t/2+a.measureText(x.text).width;(v===0||d[d.length-1]+w+2*o>r)&&(p+=h,d[d.length-(v>0?0:1)]=0,y+=h,_++),c[v]={left:0,top:y,row:_,width:w,height:s},d[d.length-1]+=w+o}),p}_fitCols(e,t,n,s){const{ctx:a,maxHeight:r,options:{labels:{padding:o}}}=this,c=this.legendHitBoxes=[],d=this.columnSizes=[],h=r-e;let p=o,_=0,y=0,x=0,v=0;return this.legendItems.forEach((w,k)=>{const{itemWidth:M,itemHeight:O}=YY(n,t,a,w,s);k>0&&y+O+2*o>h&&(p+=_+o,d.push({width:_,height:y}),x+=_+o,v++,_=y=0),c[k]={left:x,top:y,col:v,width:M,height:O},_=Math.max(_,M),y+=O+o}),p+=_,d.push({width:_,height:y}),p}adjustHitBoxes(){if(!this.options.display)return;const e=this._computeTitleHeight(),{legendHitBoxes:t,options:{align:n,labels:{padding:s},rtl:a}}=this,r=Zc(a,this.left,this.width);if(this.isHorizontal()){let o=0,c=on(n,this.left+s,this.right-this.lineWidths[o]);for(const d of t)o!==d.row&&(o=d.row,c=on(n,this.left+s,this.right-this.lineWidths[o])),d.top+=this.top+e+s,d.left=r.leftForLtr(r.x(c),d.width),c+=d.width+s}else{let o=0,c=on(n,this.top+e+s,this.bottom-this.columnSizes[o].height);for(const d of t)d.col!==o&&(o=d.col,c=on(n,this.top+e+s,this.bottom-this.columnSizes[o].height)),d.top=c,d.left+=this.left+s,d.left=r.leftForLtr(r.x(d.left),d.width),c+=d.height+s}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const e=this.ctx;N0(e,this),this._draw(),R0(e)}}_draw(){const{options:e,columnSizes:t,lineWidths:n,ctx:s}=this,{align:a,labels:r}=e,o=xi.color,c=Zc(e.rtl,this.left,this.width),d=hn(r.font),{padding:h}=r,p=d.size,_=p/2;let y;this.drawTitle(),s.textAlign=c.textAlign("left"),s.textBaseline="middle",s.lineWidth=.5,s.font=d.string;const{boxWidth:x,boxHeight:v,itemHeight:w}=XT(r,p),k=function(P,R,E){if(isNaN(x)||x<=0||isNaN(v)||v<0)return;s.save();const L=dt(E.lineWidth,1);if(s.fillStyle=dt(E.fillStyle,o),s.lineCap=dt(E.lineCap,"butt"),s.lineDashOffset=dt(E.lineDashOffset,0),s.lineJoin=dt(E.lineJoin,"miter"),s.lineWidth=L,s.strokeStyle=dt(E.strokeStyle,o),s.setLineDash(dt(E.lineDash,[])),r.usePointStyle){const D={radius:v*Math.SQRT2/2,pointStyle:E.pointStyle,rotation:E.rotation,borderWidth:L},q=c.xPlus(P,x/2),B=R+_;uL(s,D,q,B,r.pointStyleWidth&&x)}else{const D=R+Math.max((p-v)/2,0),q=c.leftForLtr(P,x),B=dh(E.borderRadius);s.beginPath(),Object.values(B).some(H=>H!==0)?fb(s,{x:q,y:D,w:x,h:v,radius:B}):s.rect(q,D,x,v),s.fill(),L!==0&&s.stroke()}s.restore()},M=function(P,R,E){Uh(s,E.text,P,R+w/2,d,{strikethrough:E.hidden,textAlign:c.textAlign(E.textAlign)})},O=this.isHorizontal(),A=this._computeTitleHeight();O?y={x:on(a,this.left+h,this.right-n[0]),y:this.top+h+A,line:0}:y={x:this.left+h,y:on(a,this.top+A+h,this.bottom-t[0].height),line:0},_L(this.ctx,e.textDirection);const C=w+h;this.legendItems.forEach((P,R)=>{s.strokeStyle=P.fontColor,s.fillStyle=P.fontColor;const E=s.measureText(P.text).width,L=c.textAlign(P.textAlign||(P.textAlign=r.textAlign)),D=x+_+E;let q=y.x,B=y.y;c.setWidth(this.width),O?R>0&&q+D+h>this.right&&(B=y.y+=C,y.line++,q=y.x=on(a,this.left+h,this.right-n[y.line])):R>0&&B+C>this.bottom&&(q=y.x=q+t[y.line].width+h,y.line++,B=y.y=on(a,this.top+A+h,this.bottom-t[y.line].height));const H=c.x(q);if(k(H,B,P),q=XX(L,q+x+_,O?q+D:this.right,e.rtl),M(c.x(q),B,P),O)y.x+=D+h;else if(typeof P.text!="string"){const W=d.lineHeight;y.y+=FL(P,W)+h}else y.y+=C}),yL(this.ctx,e.textDirection)}drawTitle(){const e=this.options,t=e.title,n=hn(t.font),s=Hs(t.padding);if(!t.display)return;const a=Zc(e.rtl,this.left,this.width),r=this.ctx,o=t.position,c=n.size/2,d=s.top+c;let h,p=this.left,_=this.width;if(this.isHorizontal())_=Math.max(...this.lineWidths),h=this.top+d,p=on(e.align,p,this.right-_);else{const x=this.columnSizes.reduce((v,w)=>Math.max(v,w.height),0);h=d+on(e.align,this.top,this.bottom-x-e.labels.padding-this._computeTitleHeight())}const y=on(o,p,p+_);r.textAlign=a.textAlign(b2(o)),r.textBaseline="middle",r.strokeStyle=t.color,r.fillStyle=t.color,r.font=n.string,Uh(r,t.text,y,h,n)}_computeTitleHeight(){const e=this.options.title,t=hn(e.font),n=Hs(e.padding);return e.display?t.lineHeight+n.height:0}_getLegendItemAt(e,t){let n,s,a;if(qc(e,this.left,this.right)&&qc(t,this.top,this.bottom)){for(a=this.legendHitBoxes,n=0;na.length>r.length?a:r)),e+t.size/2+n.measureText(s).width}function JY(i,e,t){let n=i;return typeof e.text!="string"&&(n=FL(e,t)),n}function FL(i,e){const t=i.text?i.text.length:0;return e*t}function $Y(i,e){return!!((i==="mousemove"||i==="mouseout")&&(e.onHover||e.onLeave)||e.onClick&&(i==="click"||i==="mouseup"))}var eZ={id:"legend",_element:GT,start(i,e,t){const n=i.legend=new GT({ctx:i.ctx,options:t,chart:i});Ds.configure(i,n,t),Ds.addBox(i,n)},stop(i){Ds.removeBox(i,i.legend),delete i.legend},beforeUpdate(i,e,t){const n=i.legend;Ds.configure(i,n,t),n.options=t},afterUpdate(i){const e=i.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(i,e){e.replay||i.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(i,e,t){const n=e.datasetIndex,s=t.chart;s.isDatasetVisible(n)?(s.hide(n),e.hidden=!0):(s.show(n),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:i=>i.chart.options.color,boxWidth:40,padding:10,generateLabels(i){const e=i.data.datasets,{labels:{usePointStyle:t,pointStyle:n,textAlign:s,color:a,useBorderRadius:r,borderRadius:o}}=i.legend.options;return i._getSortedDatasetMetas().map(c=>{const d=c.controller.getStyle(t?0:void 0),h=Hs(d.borderWidth);return{text:e[c.index].label,fillStyle:d.backgroundColor,fontColor:a,hidden:!c.visible,lineCap:d.borderCapStyle,lineDash:d.borderDash,lineDashOffset:d.borderDashOffset,lineJoin:d.borderJoinStyle,lineWidth:(h.width+h.height)/4,strokeStyle:d.borderColor,pointStyle:n||d.pointStyle,rotation:d.rotation,textAlign:s||d.textAlign,borderRadius:r&&(o||d.borderRadius),datasetIndex:c.index}},this)}},title:{color:i=>i.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:i=>!i.startsWith("on"),labels:{_scriptable:i=>!["generateLabels","filter","sort"].includes(i)}}};class BL extends br{constructor(e){super(),this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this._padding=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.width=void 0,this.height=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,t){const n=this.options;if(this.left=0,this.top=0,!n.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=e,this.height=this.bottom=t;const s=Ui(n.text)?n.text.length:1;this._padding=Hs(n.padding);const a=s*hn(n.font).lineHeight+this._padding.height;this.isHorizontal()?this.height=a:this.width=a}isHorizontal(){const e=this.options.position;return e==="top"||e==="bottom"}_drawArgs(e){const{top:t,left:n,bottom:s,right:a,options:r}=this,o=r.align;let c=0,d,h,p;return this.isHorizontal()?(h=on(o,n,a),p=t+e,d=a-n):(r.position==="left"?(h=n+e,p=on(o,s,t),c=Vi*-.5):(h=a-e,p=on(o,t,s),c=Vi*.5),d=s-t),{titleX:h,titleY:p,maxWidth:d,rotation:c}}draw(){const e=this.ctx,t=this.options;if(!t.display)return;const n=hn(t.font),a=n.lineHeight/2+this._padding.top,{titleX:r,titleY:o,maxWidth:c,rotation:d}=this._drawArgs(a);Uh(e,t.text,0,0,n,{color:t.color,maxWidth:c,rotation:d,textAlign:b2(t.align),textBaseline:"middle",translation:[r,o]})}}function tZ(i,e){const t=new BL({ctx:i.ctx,options:e,chart:i});Ds.configure(i,t,e),Ds.addBox(i,t),i.titleBlock=t}var iZ={id:"title",_element:BL,start(i,e,t){tZ(i,t)},stop(i){const e=i.titleBlock;Ds.removeBox(i,e),delete i.titleBlock},beforeUpdate(i,e,t){const n=i.titleBlock;Ds.configure(i,n,t),n.options=t},defaults:{align:"center",display:!1,font:{weight:"bold"},fullSize:!0,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:!0,_indexable:!1}};const Gd={average(i){if(!i.length)return!1;let e,t,n=new Set,s=0,a=0;for(e=0,t=i.length;eo+c)/n.size,y:s/a}},nearest(i,e){if(!i.length)return!1;let t=e.x,n=e.y,s=Number.POSITIVE_INFINITY,a,r,o;for(a=0,r=i.length;a-1?i.split(` @@ -38,7 +38,7 @@ Please change the parent to =0&&!/[\\p{Alphabetic}\\p{Number}_]/.test(t.text.slice(Math.max(0,n.updateRangeStart-1),Math.min(t.text.length,n.updateRangeStart+1)))&&this.handlers.compositionend(n)},this.handlers.characterboundsupdate=n=>{let s=[],a=null;for(let r=this.toEditorPos(n.rangeStart),o=this.toEditorPos(n.rangeEnd);r{let s=[];for(let a of n.getTextFormats()){let r=a.underlineStyle,o=a.underlineThickness;if(!/none/i.test(r)&&!/none/i.test(o)){let c=this.toEditorPos(a.rangeStart),d=this.toEditorPos(a.rangeEnd);if(c{e.inputState.composing<0&&(e.inputState.composing=0,e.inputState.compositionFirstChange=!0)},this.handlers.compositionend=()=>{if(e.inputState.composing=-1,e.inputState.compositionFirstChange=null,this.composing){let{drifted:n}=this.composing;this.composing=null,n&&this.reset(e.state)}};for(let n in this.handlers)t.addEventListener(n,this.handlers[n]);this.measureReq={read:n=>{this.editContext.updateControlBounds(n.contentDOM.getBoundingClientRect());let s=Hh(n.root);s&&s.rangeCount&&this.editContext.updateSelectionBounds(s.getRangeAt(0).getBoundingClientRect())}}}applyEdits(e){let t=0,n=!1,s=this.pendingContextChange;return e.changes.iterChanges((a,r,o,c,d)=>{if(n)return;let h=d.length-(r-a);if(s&&r>=s.to)if(s.from==a&&s.to==r&&s.insert.eq(d)){s=this.pendingContextChange=null,t+=h,this.to+=h;return}else s=null,this.revertPending(e.state);if(a+=t,r+=t,r<=this.from)this.from+=h,this.to+=h;else if(athis.to||this.to-this.from+d.length>3e4){n=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(r),d.toString()),this.to+=h}t+=h}),s&&!n&&this.revertPending(e.state),!n}update(e){let t=this.pendingContextChange,n=e.startState.selection.main;this.composing&&(this.composing.drifted||!e.changes.touchesRange(n.from,n.to)&&e.transactions.some(s=>!s.isUserEvent("input.type")&&s.changes.touchesRange(this.from,this.to)))?(this.composing.drifted=!0,this.composing.editorBase=e.changes.mapPos(this.composing.editorBase)):!this.applyEdits(e)||!this.rangeIsValid(e.state)?(this.pendingContextChange=null,this.reset(e.state)):(e.docChanged||e.selectionSet||t)&&this.setSelection(e.state),(e.geometryChanged||e.docChanged||e.selectionSet)&&e.view.requestMeasure(this.measureReq)}resetRange(e){let{head:t}=e.selection.main;this.from=Math.max(0,t-1e4),this.to=Math.min(e.doc.length,t+1e4)}reset(e){this.resetRange(e),this.editContext.updateText(0,this.editContext.text.length,e.doc.sliceString(this.from,this.to)),this.setSelection(e)}revertPending(e){let t=this.pendingContextChange;this.pendingContextChange=null,this.editContext.updateText(this.toContextPos(t.from),this.toContextPos(t.from+t.insert.length),e.doc.sliceString(t.from,t.to))}setSelection(e){let{main:t}=e.selection,n=this.toContextPos(Math.max(this.from,Math.min(this.to,t.anchor))),s=this.toContextPos(t.head);(this.editContext.selectionStart!=n||this.editContext.selectionEnd!=s)&&this.editContext.updateSelection(n,s)}rangeIsValid(e){let{head:t}=e.selection.main;return!(this.from>0&&t-this.from<500||this.to1e4*3)}toEditorPos(e,t=this.to-this.from){e=Math.min(e,t);let n=this.composing;return n&&n.drifted?n.editorBase+(e-n.contextBase):e+this.from}toContextPos(e){let t=this.composing;return t&&t.drifted?t.contextBase+(e-t.editorBase):e-this.from}destroy(){for(let e in this.handlers)this.editContext.removeEventListener(e,this.handlers[e])}}class Ne{get state(){return this.viewState.state}get viewport(){return this.viewState.viewport}get visibleRanges(){return this.viewState.visibleRanges}get inView(){return this.viewState.inView}get composing(){return!!this.inputState&&this.inputState.composing>0}get compositionStarted(){return!!this.inputState&&this.inputState.composing>=0}get root(){return this._root}get win(){return this.dom.ownerDocument.defaultView||window}constructor(e={}){var t;this.plugins=[],this.pluginMap=new Map,this.editorAttrs={},this.contentAttrs={},this.bidiCache=[],this.destroyed=!1,this.updateState=2,this.measureScheduled=-1,this.measureRequests=[],this.contentDOM=document.createElement("div"),this.scrollDOM=document.createElement("div"),this.scrollDOM.tabIndex=-1,this.scrollDOM.className="cm-scroller",this.scrollDOM.appendChild(this.contentDOM),this.announceDOM=document.createElement("div"),this.announceDOM.className="cm-announced",this.announceDOM.setAttribute("aria-live","polite"),this.dom=document.createElement("div"),this.dom.appendChild(this.announceDOM),this.dom.appendChild(this.scrollDOM),e.parent&&e.parent.appendChild(this.dom);let{dispatch:n}=e;this.dispatchTransactions=e.dispatchTransactions||n&&(s=>s.forEach(a=>n(a,this)))||(s=>this.update(s)),this.dispatch=this.dispatch.bind(this),this._root=e.root||C$(e.parent)||document,this.viewState=new GM(e.state||ut.create(e)),e.scrollTo&&e.scrollTo.is(Sm)&&(this.viewState.scrollTarget=e.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Hc).map(s=>new $1(s));for(let s of this.plugins)s.update(this);this.observer=new Kee(this),this.inputState=new hee(this),this.inputState.ensureHandlers(this.plugins),this.docView=new MM(this),this.mountStyles(),this.updateAttrs(),this.updateState=0,this.requestMeasure(),!((t=document.fonts)===null||t===void 0)&&t.ready&&document.fonts.ready.then(()=>this.requestMeasure())}dispatch(...e){let t=e.length==1&&e[0]instanceof Fi?e:e.length==1&&Array.isArray(e[0])?e[0]:[this.state.update(...e)];this.dispatchTransactions(t,this)}update(e){if(this.updateState!=0)throw new Error("Calls to EditorView.update are not allowed while an update is in progress");let t=!1,n=!1,s,a=this.state;for(let _ of e){if(_.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=_.state}if(this.destroyed){this.viewState.state=a;return}let r=this.hasFocus,o=0,c=null;e.some(_=>_.annotation(t5))?(this.inputState.notifiedFocused=r,o=1):r!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=r,c=i5(a,r),c||(o=1));let d=this.observer.delayedAndroidKey,h=null;if(d?(this.observer.clearDelayedAndroidKey(),h=this.observer.readChange(),(h&&!this.state.doc.eq(a.doc)||!this.state.selection.eq(a.selection))&&(h=null)):this.observer.clear(),a.facet(ut.phrases)!=this.state.facet(ut.phrases))return this.setState(a);s=Kg.create(this,a,e),s.flags|=o;let p=this.viewState.scrollTarget;try{this.updateState=2;for(let _ of e){if(p&&(p=p.map(_.changes)),_.scrollIntoView){let{main:y}=_.state.selection;p=new eu(y.empty?y:xe.cursor(y.head,y.head>y.anchor?-1:1))}for(let y of _.effects)y.is(Sm)&&(p=y.value.clip(this.state))}this.viewState.update(s,p),this.bidiCache=Ig.update(this.bidiCache,s.changes),s.empty||(this.updatePlugins(s),this.inputState.update(s)),t=this.docView.update(s),this.state.facet(Qd)!=this.styleModules&&this.mountStyles(),n=this.updateAttrs(),this.showAnnouncements(e),this.docView.updateSelection(t,e.some(_=>_.isUserEvent("select.pointer")))}finally{this.updateState=0}if(s.startState.facet(Tm)!=s.state.facet(Tm)&&(this.viewState.mustMeasureContent=!0),(t||n||p||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),t&&this.docViewUpdate(),!s.empty)for(let _ of this.state.facet(Gb))try{_(s)}catch(y){qn(this.state,y,"update listener")}(c||h)&&Promise.resolve().then(()=>{c&&this.state==c.startState&&this.dispatch(c),h&&!G4(this,h)&&d.force&&$c(this.contentDOM,d.key,d.keyCode)})}setState(e){if(this.updateState!=0)throw new Error("Calls to EditorView.setState are not allowed while an update is in progress");if(this.destroyed){this.viewState.state=e;return}this.updateState=2;let t=this.hasFocus;try{for(let n of this.plugins)n.destroy(this);this.viewState=new GM(e),this.plugins=e.facet(Hc).map(n=>new $1(n)),this.pluginMap.clear();for(let n of this.plugins)n.update(this);this.docView.destroy(),this.docView=new MM(this),this.inputState.ensureHandlers(this.plugins),this.mountStyles(),this.updateAttrs(),this.bidiCache=[]}finally{this.updateState=0}t&&this.focus(),this.requestMeasure()}updatePlugins(e){let t=e.startState.facet(Hc),n=e.state.facet(Hc);if(t!=n){let s=[];for(let a of n){let r=t.indexOf(a);if(r<0)s.push(new $1(a));else{let o=this.plugins[r];o.mustUpdate=e,s.push(o)}}for(let a of this.plugins)a.mustUpdate!=e&&a.destroy(this);this.plugins=s,this.pluginMap.clear()}else for(let s of this.plugins)s.mustUpdate=e;for(let s=0;s-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.observer.delayedAndroidKey){this.measureScheduled=-1,this.requestMeasure();return}this.measureScheduled=0,e&&this.observer.forceFlush();let t=null,n=this.scrollDOM,s=n.scrollTop*this.scaleY,{scrollAnchorPos:a,scrollAnchorHeight:r}=this.viewState;Math.abs(s-this.viewState.scrollTop)>1&&(r=-1),this.viewState.scrollAnchorHeight=-1;try{for(let o=0;;o++){if(r<0)if(m4(n))a=-1,r=this.viewState.heightMap.height;else{let y=this.viewState.scrollAnchorAt(s);a=y.from,r=y.top}this.updateState=1;let c=this.viewState.measure(this);if(!c&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(o>5){console.warn(this.measureRequests.length?"Measure loop restarted more than 5 times":"Viewport failed to stabilize");break}let d=[];c&4||([this.measureRequests,d]=[d,this.measureRequests]);let h=d.map(y=>{try{return y.read(this)}catch(x){return qn(this.state,x),JM}}),p=Kg.create(this,this.state,[]),_=!1;p.flags|=c,t?t.flags|=c:t=p,this.updateState=2,p.empty||(this.updatePlugins(p),this.inputState.update(p),this.updateAttrs(),_=this.docView.update(p),_&&this.docViewUpdate());for(let y=0;y1||x<-1){s=s+x,n.scrollTop=s/this.scaleY,r=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(t&&!t.empty)for(let o of this.state.facet(Gb))o(t)}get themeClasses(){return $b+" "+(this.state.facet(Jb)?r5:a5)+" "+this.state.facet(Tm)}updateAttrs(){let e=$M(this,z4,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),t={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(dr)?"true":"false",class:"cm-content",style:`${Me.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(t["aria-readonly"]="true"),$M(this,D2,t);let n=this.observer.ignore(()=>{let s=Kb(this.contentDOM,this.contentAttrs,t),a=Kb(this.dom,this.editorAttrs,e);return s||a});return this.editorAttrs=e,this.contentAttrs=t,n}showAnnouncements(e){let t=!0;for(let n of e)for(let s of n.effects)if(s.is(Ne.announce)){t&&(this.announceDOM.textContent=""),t=!1;let a=this.announceDOM.appendChild(document.createElement("div"));a.textContent=s.value}}mountStyles(){this.styleModules=this.state.facet(Qd);let e=this.state.facet(Ne.cspNonce);Co.mount(this.root,this.styleModules.concat(qee).reverse(),e?{nonce:e}:void 0)}readMeasured(){if(this.updateState==2)throw new Error("Reading the editor layout isn't allowed during an update");this.updateState==0&&this.measureScheduled>-1&&this.measure(!1)}requestMeasure(e){if(this.measureScheduled<0&&(this.measureScheduled=this.win.requestAnimationFrame(()=>this.measure())),e){if(this.measureRequests.indexOf(e)>-1)return;if(e.key!=null){for(let t=0;tn.plugin==e)||null),t&&t.update(this).value}get documentTop(){return this.contentDOM.getBoundingClientRect().top+this.viewState.paddingTop}get documentPadding(){return{top:this.viewState.paddingTop,bottom:this.viewState.paddingBottom}}get scaleX(){return this.viewState.scaleX}get scaleY(){return this.viewState.scaleY}elementAtHeight(e){return this.readMeasured(),this.viewState.elementAtHeight(e)}lineBlockAtHeight(e){return this.readMeasured(),this.viewState.lineBlockAtHeight(e)}get viewportLineBlocks(){return this.viewState.viewportLines}lineBlockAt(e){return this.viewState.lineBlockAt(e)}get contentHeight(){return this.viewState.contentHeight}moveByChar(e,t,n){return tx(this,e,jM(this,e,t,n))}moveByGroup(e,t){return tx(this,e,jM(this,e,t,n=>nee(this,e.head,n)))}visualLineSide(e,t){let n=this.bidiSpans(e),s=this.textDirectionAt(e.from),a=n[t?n.length-1:0];return xe.cursor(a.side(t,s)+e.from,a.forward(!t,s)?1:-1)}moveToLineBoundary(e,t,n=!0){return iee(this,e,t,n)}moveVertically(e,t,n){return tx(this,e,see(this,e,t,n))}domAtPos(e){return this.docView.domAtPos(e)}posAtDOM(e,t=0){return this.docView.posFromDOM(e,t)}posAtCoords(e,t=!0){return this.readMeasured(),I4(this,e,t)}coordsAtPos(e,t=1){this.readMeasured();let n=this.docView.coordsAt(e,t);if(!n||n.left==n.right)return n;let s=this.state.doc.lineAt(e),a=this.bidiSpans(s),r=a[go.find(a,e-s.from,-1,t)];return xf(n,r.dir==Zt.LTR==t>0)}coordsForChar(e){return this.readMeasured(),this.docView.coordsForChar(e)}get defaultCharacterWidth(){return this.viewState.heightOracle.charWidth}get defaultLineHeight(){return this.viewState.heightOracle.lineHeight}get textDirection(){return this.viewState.defaultTextDirection}textDirectionAt(e){return!this.state.facet(D4)||ethis.viewport.to?this.textDirection:(this.readMeasured(),this.docView.textDirectionAt(e))}get lineWrapping(){return this.viewState.heightOracle.lineWrapping}bidiSpans(e){if(e.length>Wee)return T4(e.length);let t=this.textDirectionAt(e.from),n;for(let a of this.bidiCache)if(a.from==e.from&&a.dir==t&&(a.fresh||O4(a.isolates,n=TM(this,e))))return a.order;n||(n=TM(this,e));let s=z$(e.text,t,n);return this.bidiCache.push(new Ig(e.from,e.to,t,n,!0,s)),s}get hasFocus(){var e;return(this.dom.ownerDocument.hasFocus()||Me.safari&&((e=this.inputState)===null||e===void 0?void 0:e.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{f4(this.contentDOM),this.docView.updateSelection()})}setRoot(e){this._root!=e&&(this._root=e,this.observer.setWindow((e.nodeType==9?e:e.ownerDocument).defaultView||window),this.mountStyles())}destroy(){this.root.activeElement==this.contentDOM&&this.contentDOM.blur();for(let e of this.plugins)e.destroy(this);this.plugins=[],this.inputState.destroy(),this.docView.destroy(),this.dom.remove(),this.observer.destroy(),this.measureScheduled>-1&&this.win.cancelAnimationFrame(this.measureScheduled),this.destroyed=!0}static scrollIntoView(e,t={}){return Sm.of(new eu(typeof e=="number"?xe.cursor(e):e,t.y,t.x,t.yMargin,t.xMargin))}scrollSnapshot(){let{scrollTop:e,scrollLeft:t}=this.scrollDOM,n=this.viewState.scrollAnchorAt(e);return Sm.of(new eu(xe.cursor(n.from),"start","start",n.top-e,t,!0))}setTabFocusMode(e){e==null?this.inputState.tabFocusMode=this.inputState.tabFocusMode<0?0:-1:typeof e=="boolean"?this.inputState.tabFocusMode=e?0:-1:this.inputState.tabFocusMode!=0&&(this.inputState.tabFocusMode=Date.now()+e)}static domEventHandlers(e){return bi.define(()=>({}),{eventHandlers:e})}static domEventObservers(e){return bi.define(()=>({}),{eventObservers:e})}static theme(e,t){let n=Co.newName(),s=[Tm.of(n),Qd.of(ev(`.${n}`,e))];return t&&t.dark&&s.push(Jb.of(!0)),s}static baseTheme(e){return Wl.lowest(Qd.of(ev("."+$b,e,o5)))}static findFromDOM(e){var t;let n=e.querySelector(".cm-content"),s=n&&Ft.get(n)||Ft.get(e);return((t=s==null?void 0:s.rootView)===null||t===void 0?void 0:t.view)||null}}Ne.styleModule=Qd;Ne.inputHandler=j4;Ne.clipboardInputFilter=j2;Ne.clipboardOutputFilter=E2;Ne.scrollHandler=F4;Ne.focusChangeEffect=E4;Ne.perLineTextDirection=D4;Ne.exceptionSink=L4;Ne.updateListener=Gb;Ne.editable=dr;Ne.mouseSelectionStyle=P4;Ne.dragMovesSelection=R4;Ne.clickAddsSelectionRange=N4;Ne.decorations=Kh;Ne.outerDecorations=q4;Ne.atomicRanges=Sf;Ne.bidiIsolatedRanges=H4;Ne.scrollMargins=K4;Ne.darkTheme=Jb;Ne.cspNonce=Le.define({combine:i=>i.length?i[0]:""});Ne.contentAttributes=D2;Ne.editorAttributes=z4;Ne.lineWrapping=Ne.contentAttributes.of({class:"cm-lineWrapping"});Ne.announce=Ze.define();const Wee=4096,JM={};class Ig{constructor(e,t,n,s,a,r){this.from=e,this.to=t,this.dir=n,this.isolates=s,this.fresh=a,this.order=r}static update(e,t){if(t.empty&&!e.some(a=>a.fresh))return e;let n=[],s=e.length?e[e.length-1].dir:Zt.LTR;for(let a=Math.max(0,e.length-10);a=0;s--){let a=n[s],r=typeof a=="function"?a(i):a;r&&Hb(r,t)}return t}const Xee=Me.mac?"mac":Me.windows?"win":Me.linux?"linux":"key";function Gee(i,e){const t=i.split(/-(?!$)/);let n=t[t.length-1];n=="Space"&&(n=" ");let s,a,r,o;for(let c=0;cn.concat(s),[]))),t}function Yee(i,e,t){return c5(l5(i.state),e,i,t)}let oo=null;const Zee=4e3;function Jee(i,e=Xee){let t=Object.create(null),n=Object.create(null),s=(r,o)=>{let c=n[r];if(c==null)n[r]=o;else if(c!=o)throw new Error("Key binding "+r+" is used both as a regular binding and as a multi-stroke prefix")},a=(r,o,c,d,h)=>{var p,_;let y=t[r]||(t[r]=Object.create(null)),x=o.split(/ (?!$)/).map(k=>Gee(k,e));for(let k=1;k{let A=oo={view:O,prefix:M,scope:r};return setTimeout(()=>{oo==A&&(oo=null)},Zee),!0}]})}let v=x.join(" ");s(v,!1);let w=y[v]||(y[v]={preventDefault:!1,stopPropagation:!1,run:((_=(p=y._any)===null||p===void 0?void 0:p.run)===null||_===void 0?void 0:_.slice())||[]});c&&w.run.push(c),d&&(w.preventDefault=!0),h&&(w.stopPropagation=!0)};for(let r of i){let o=r.scope?r.scope.split(" "):["editor"];if(r.any)for(let d of o){let h=t[d]||(t[d]=Object.create(null));h._any||(h._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:p}=r;for(let _ in h)h[_].run.push(y=>p(y,tv))}let c=r[e]||r.key;if(c)for(let d of o)a(d,c,r.run,r.preventDefault,r.stopPropagation),r.shift&&a(d,"Shift-"+c,r.shift,r.preventDefault,r.stopPropagation)}return t}let tv=null;function c5(i,e,t,n){tv=e;let s=b$(e),a=Un(s,0),r=Aa(a)==s.length&&s!=" ",o="",c=!1,d=!1,h=!1;oo&&oo.view==t&&oo.scope==n&&(o=oo.prefix+" ",Z4.indexOf(e.keyCode)<0&&(d=!0,oo=null));let p=new Set,_=w=>{if(w){for(let k of w.run)if(!p.has(k)&&(p.add(k),k(t)))return w.stopPropagation&&(h=!0),!0;w.preventDefault&&(w.stopPropagation&&(h=!0),d=!0)}return!1},y=i[n],x,v;return y&&(_(y[o+Mm(s,e,!r)])?c=!0:r&&(e.altKey||e.metaKey||e.ctrlKey)&&!(Me.windows&&e.ctrlKey&&e.altKey)&&!(Me.mac&&e.altKey&&!(e.ctrlKey||e.metaKey))&&(x=Oo[e.keyCode])&&x!=s?(_(y[o+Mm(x,e,!0)])||e.shiftKey&&(v=qh[e.keyCode])!=s&&v!=x&&_(y[o+Mm(v,e,!1)]))&&(c=!0):r&&e.shiftKey&&_(y[o+Mm(s,e,!0)])&&(c=!0),!c&&_(y._any)&&(c=!0)),d&&(c=!0),c&&h&&e.stopPropagation(),tv=null,c}class kf{constructor(e,t,n,s,a){this.className=e,this.left=t,this.top=n,this.width=s,this.height=a}draw(){let e=document.createElement("div");return e.className=this.className,this.adjust(e),e}update(e,t){return t.className!=this.className?!1:(this.adjust(e),!0)}adjust(e){e.style.left=this.left+"px",e.style.top=this.top+"px",this.width!=null&&(e.style.width=this.width+"px"),e.style.height=this.height+"px"}eq(e){return this.left==e.left&&this.top==e.top&&this.width==e.width&&this.height==e.height&&this.className==e.className}static forRange(e,t,n){if(n.empty){let s=e.coordsAtPos(n.head,n.assoc||1);if(!s)return[];let a=u5(e);return[new kf(t,s.left-a.left,s.top-a.top,null,s.bottom-s.top)]}else return $ee(e,t,n)}}function u5(i){let e=i.scrollDOM.getBoundingClientRect();return{left:(i.textDirection==Zt.LTR?e.left:e.right-i.scrollDOM.clientWidth*i.scaleX)-i.scrollDOM.scrollLeft*i.scaleX,top:e.top-i.scrollDOM.scrollTop*i.scaleY}}function t3(i,e,t,n){let s=i.coordsAtPos(e,t*2);if(!s)return n;let a=i.dom.getBoundingClientRect(),r=(s.top+s.bottom)/2,o=i.posAtCoords({x:a.left+1,y:r}),c=i.posAtCoords({x:a.right-1,y:r});return o==null||c==null?n:{from:Math.max(n.from,Math.min(o,c)),to:Math.min(n.to,Math.max(o,c))}}function $ee(i,e,t){if(t.to<=i.viewport.from||t.from>=i.viewport.to)return[];let n=Math.max(t.from,i.viewport.from),s=Math.min(t.to,i.viewport.to),a=i.textDirection==Zt.LTR,r=i.contentDOM,o=r.getBoundingClientRect(),c=u5(i),d=r.querySelector(".cm-line"),h=d&&window.getComputedStyle(d),p=o.left+(h?parseInt(h.paddingLeft)+Math.min(0,parseInt(h.textIndent)):0),_=o.right-(h?parseInt(h.paddingRight):0),y=Yb(i,n,1),x=Yb(i,s,-1),v=y.type==Cn.Text?y:null,w=x.type==Cn.Text?x:null;if(v&&(i.lineWrapping||y.widgetLineBreaks)&&(v=t3(i,n,1,v)),w&&(i.lineWrapping||x.widgetLineBreaks)&&(w=t3(i,s,-1,w)),v&&w&&v.from==w.from&&v.to==w.to)return M(O(t.from,t.to,v));{let C=v?O(t.from,null,v):A(y,!1),P=w?O(null,t.to,w):A(x,!0),R=[];return(v||y).to<(w||x).from-(v&&w?1:0)||y.widgetLineBreaks>1&&C.bottom+i.defaultLineHeight/2B&&W.from=U)break;ue>V&&q(Math.max(ie,V),C==null&&ie<=B,Math.min(ue,U),P==null&&ue>=H,$.dir)}if(V=G.to+1,V>=U)break}return D.length==0&&q(B,C==null,H,P==null,i.textDirection),{top:E,bottom:L,horizontal:D}}function A(C,P){let R=o.top+(P?C.top:C.bottom);return{top:R,bottom:R,horizontal:[]}}}function ete(i,e){return i.constructor==e.constructor&&i.eq(e)}class tte{constructor(e,t){this.view=e,this.layer=t,this.drawn=[],this.scaleX=1,this.scaleY=1,this.measureReq={read:this.measure.bind(this),write:this.draw.bind(this)},this.dom=e.scrollDOM.appendChild(document.createElement("div")),this.dom.classList.add("cm-layer"),t.above&&this.dom.classList.add("cm-layer-above"),t.class&&this.dom.classList.add(t.class),this.scale(),this.dom.setAttribute("aria-hidden","true"),this.setOrder(e.state),e.requestMeasure(this.measureReq),t.mount&&t.mount(this.dom,e)}update(e){e.startState.facet(cg)!=e.state.facet(cg)&&this.setOrder(e.state),(this.layer.update(e,this.dom)||e.geometryChanged)&&(this.scale(),e.view.requestMeasure(this.measureReq))}docViewUpdate(e){this.layer.updateOnDocViewUpdate!==!1&&e.requestMeasure(this.measureReq)}setOrder(e){let t=0,n=e.facet(cg);for(;t!ete(t,this.drawn[n]))){let t=this.dom.firstChild,n=0;for(let s of e)s.update&&t&&s.constructor&&this.drawn[n].constructor&&s.update(t,this.drawn[n])?(t=t.nextSibling,n++):this.dom.insertBefore(s.draw(),t);for(;t;){let s=t.nextSibling;t.remove(),t=s}this.drawn=e,Me.safari&&Me.safari_version>=26&&(this.dom.style.display=this.dom.firstChild?"":"none")}}destroy(){this.layer.destroy&&this.layer.destroy(this.dom,this.view),this.dom.remove()}}const cg=Le.define();function d5(i){return[bi.define(e=>new tte(e,i)),cg.of(i)]}const Vh=Le.define({combine(i){return Da(i,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(e,t)=>Math.min(e,t),drawRangeCursor:(e,t)=>e||t})}});function ite(i={}){return[Vh.of(i),nte,ste,ate,U4.of(!0)]}function h5(i){return i.startState.facet(Vh)!=i.state.facet(Vh)}const nte=d5({above:!0,markers(i){let{state:e}=i,t=e.facet(Vh),n=[];for(let s of e.selection.ranges){let a=s==e.selection.main;if(s.empty||t.drawRangeCursor){let r=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",o=s.empty?s:xe.cursor(s.head,s.head>s.anchor?-1:1);for(let c of kf.forRange(i,r,o))n.push(c)}}return n},update(i,e){i.transactions.some(n=>n.selection)&&(e.style.animationName=e.style.animationName=="cm-blink"?"cm-blink2":"cm-blink");let t=h5(i);return t&&i3(i.state,e),i.docChanged||i.selectionSet||t},mount(i,e){i3(e.state,i)},class:"cm-cursorLayer"});function i3(i,e){e.style.animationDuration=i.facet(Vh).cursorBlinkRate+"ms"}const ste=d5({above:!1,markers(i){return i.state.selection.ranges.map(e=>e.empty?[]:kf.forRange(i,"cm-selectionBackground",e)).reduce((e,t)=>e.concat(t))},update(i,e){return i.docChanged||i.selectionSet||i.viewportChanged||h5(i)},class:"cm-selectionLayer"}),ate=Wl.highest(Ne.theme({".cm-line":{"& ::selection, &::selection":{backgroundColor:"transparent !important"},caretColor:"transparent !important"},".cm-content":{caretColor:"transparent !important","& :focus":{caretColor:"initial !important","&::selection, & ::selection":{backgroundColor:"Highlight !important"}}}})),f5=Ze.define({map(i,e){return i==null?null:e.mapPos(i)}}),Jd=an.define({create(){return null},update(i,e){return i!=null&&(i=e.changes.mapPos(i)),e.effects.reduce((t,n)=>n.is(f5)?n.value:t,i)}}),rte=bi.fromClass(class{constructor(i){this.view=i,this.cursor=null,this.measureReq={read:this.readPos.bind(this),write:this.drawCursor.bind(this)}}update(i){var e;let t=i.state.field(Jd);t==null?this.cursor!=null&&((e=this.cursor)===null||e===void 0||e.remove(),this.cursor=null):(this.cursor||(this.cursor=this.view.scrollDOM.appendChild(document.createElement("div")),this.cursor.className="cm-dropCursor"),(i.startState.field(Jd)!=t||i.docChanged||i.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:i}=this,e=i.state.field(Jd),t=e!=null&&i.coordsAtPos(e);if(!t)return null;let n=i.scrollDOM.getBoundingClientRect();return{left:t.left-n.left+i.scrollDOM.scrollLeft*i.scaleX,top:t.top-n.top+i.scrollDOM.scrollTop*i.scaleY,height:t.bottom-t.top}}drawCursor(i){if(this.cursor){let{scaleX:e,scaleY:t}=this.view;i?(this.cursor.style.left=i.left/e+"px",this.cursor.style.top=i.top/t+"px",this.cursor.style.height=i.height/t+"px"):this.cursor.style.left="-100000px"}}destroy(){this.cursor&&this.cursor.remove()}setDropPos(i){this.view.state.field(Jd)!=i&&this.view.dispatch({effects:f5.of(i)})}},{eventObservers:{dragover(i){this.setDropPos(this.view.posAtCoords({x:i.clientX,y:i.clientY}))},dragleave(i){(i.target==this.view.contentDOM||!this.view.contentDOM.contains(i.relatedTarget))&&this.setDropPos(null)},dragend(){this.setDropPos(null)},drop(){this.setDropPos(null)}}});function ote(){return[Jd,rte]}function n3(i,e,t,n,s){e.lastIndex=0;for(let a=i.iterRange(t,n),r=t,o;!a.next().done;r+=a.value.length)if(!a.lineBreak)for(;o=e.exec(a.value);)s(r+o.index,o)}function lte(i,e){let t=i.visibleRanges;if(t.length==1&&t[0].from==i.viewport.from&&t[0].to==i.viewport.to)return t;let n=[];for(let{from:s,to:a}of t)s=Math.max(i.state.doc.lineAt(s).from,s-e),a=Math.min(i.state.doc.lineAt(a).to,a+e),n.length&&n[n.length-1].to>=s?n[n.length-1].to=a:n.push({from:s,to:a});return n}class cte{constructor(e){const{regexp:t,decoration:n,decorate:s,boundary:a,maxLength:r=1e3}=e;if(!t.global)throw new RangeError("The regular expression given to MatchDecorator should have its 'g' flag set");if(this.regexp=t,s)this.addMatch=(o,c,d,h)=>s(h,d,d+o[0].length,o,c);else if(typeof n=="function")this.addMatch=(o,c,d,h)=>{let p=n(o,c,d);p&&h(d,d+o[0].length,p)};else if(n)this.addMatch=(o,c,d,h)=>h(d,d+o[0].length,n);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=a,this.maxLength=r}createDeco(e){let t=new vr,n=t.add.bind(t);for(let{from:s,to:a}of lte(e,this.maxLength))n3(e.state.doc,this.regexp,s,a,(r,o)=>this.addMatch(o,e,r,n));return t.finish()}updateDeco(e,t){let n=1e9,s=-1;return e.docChanged&&e.changes.iterChanges((a,r,o,c)=>{c>=e.view.viewport.from&&o<=e.view.viewport.to&&(n=Math.min(o,n),s=Math.max(c,s))}),e.viewportMoved||s-n>1e3?this.createDeco(e.view):s>-1?this.updateRange(e.view,t.map(e.changes),n,s):t}updateRange(e,t,n,s){for(let a of e.visibleRanges){let r=Math.max(a.from,n),o=Math.min(a.to,s);if(o>=r){let c=e.state.doc.lineAt(r),d=c.toc.from;r--)if(this.boundary.test(c.text[r-1-c.from])){h=r;break}for(;o_.push(k.range(v,w));if(c==d)for(this.regexp.lastIndex=h-c.from;(y=this.regexp.exec(c.text))&&y.indexthis.addMatch(w,e,v,x));t=t.update({filterFrom:h,filterTo:p,filter:(v,w)=>vp,add:_})}}return t}}const iv=/x/.unicode!=null?"gu":"g",ute=new RegExp(`[\0-\b --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,iv),dte={0:"null",7:"bell",8:"backspace",10:"newline",11:"vertical tab",13:"carriage return",27:"escape",8203:"zero width space",8204:"zero width non-joiner",8205:"zero width joiner",8206:"left-to-right mark",8207:"right-to-left mark",8232:"line separator",8237:"left-to-right override",8238:"right-to-left override",8294:"left-to-right isolate",8295:"right-to-left isolate",8297:"pop directional isolate",8233:"paragraph separator",65279:"zero width no-break space",65532:"object replacement"};let sx=null;function hte(){var i;if(sx==null&&typeof document!="undefined"&&document.body){let e=document.body.style;sx=((i=e.tabSize)!==null&&i!==void 0?i:e.MozTabSize)!=null}return sx||!1}const ug=Le.define({combine(i){let e=Da(i,{render:null,specialChars:ute,addSpecialChars:null});return(e.replaceTabs=!hte())&&(e.specialChars=new RegExp(" |"+e.specialChars.source,iv)),e.addSpecialChars&&(e.specialChars=new RegExp(e.specialChars.source+"|"+e.addSpecialChars.source,iv)),e}});function fte(i={}){return[ug.of(i),pte()]}let s3=null;function pte(){return s3||(s3=bi.fromClass(class{constructor(i){this.view=i,this.decorations=qe.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(i.state.facet(ug)),this.decorations=this.decorator.createDeco(i)}makeDecorator(i){return new cte({regexp:i.specialChars,decoration:(e,t,n)=>{let{doc:s}=t.state,a=Un(e[0],0);if(a==9){let r=s.lineAt(n),o=t.state.tabSize,c=Tu(r.text,o,n-r.from);return qe.replace({widget:new yte((o-c%o)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=qe.replace({widget:new _te(i,a)}))},boundary:i.replaceTabs?void 0:/[^]/})}update(i){let e=i.state.facet(ug);i.startState.facet(ug)!=e?(this.decorator=this.makeDecorator(e),this.decorations=this.decorator.createDeco(i.view)):this.decorations=this.decorator.updateDeco(i,this.decorations)}},{decorations:i=>i.decorations}))}const mte="•";function gte(i){return i>=32?mte:i==10?"␤":String.fromCharCode(9216+i)}class _te extends Ar{constructor(e,t){super(),this.options=e,this.code=t}eq(e){return e.code==this.code}toDOM(e){let t=gte(this.code),n=e.state.phrase("Control character")+" "+(dte[this.code]||"0x"+this.code.toString(16)),s=this.options.render&&this.options.render(this.code,n,t);if(s)return s;let a=document.createElement("span");return a.textContent=t,a.title=n,a.setAttribute("aria-label",n),a.className="cm-specialChar",a}ignoreEvent(){return!1}}class yte extends Ar{constructor(e){super(),this.width=e}eq(e){return e.width==this.width}toDOM(){let e=document.createElement("span");return e.textContent=" ",e.className="cm-tab",e.style.width=this.width+"px",e}ignoreEvent(){return!1}}function xte(){return vte}const bte=qe.line({class:"cm-activeLine"}),vte=bi.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.docChanged||i.selectionSet)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=-1,t=[];for(let n of i.state.selection.ranges){let s=i.lineBlockAt(n.head);s.from>e&&(t.push(bte.range(s.from)),e=s.from)}return qe.set(t)}},{decorations:i=>i.decorations});class Ste extends Ar{constructor(e){super(),this.content=e}toDOM(e){let t=document.createElement("span");return t.className="cm-placeholder",t.style.pointerEvents="none",t.appendChild(typeof this.content=="string"?document.createTextNode(this.content):typeof this.content=="function"?this.content(e):this.content.cloneNode(!0)),t.setAttribute("aria-hidden","true"),t}coordsAt(e){let t=e.firstChild?mu(e.firstChild):[];if(!t.length)return null;let n=window.getComputedStyle(e.parentNode),s=xf(t[0],n.direction!="rtl"),a=parseInt(n.lineHeight);return s.bottom-s.top>a*1.5?{left:s.left,right:s.right,top:s.top,bottom:s.top+a}:s}ignoreEvent(){return!1}}function wte(i){let e=bi.fromClass(class{constructor(t){this.view=t,this.placeholder=i?qe.set([qe.widget({widget:new Ste(i),side:1}).range(0)]):qe.none}get decorations(){return this.view.state.doc.length?qe.none:this.placeholder}},{decorations:t=>t.decorations});return typeof i=="string"?[e,Ne.contentAttributes.of({"aria-placeholder":i})]:e}const nv=2e3;function kte(i,e,t){let n=Math.min(e.line,t.line),s=Math.max(e.line,t.line),a=[];if(e.off>nv||t.off>nv||e.col<0||t.col<0){let r=Math.min(e.off,t.off),o=Math.max(e.off,t.off);for(let c=n;c<=s;c++){let d=i.doc.line(c);d.length<=o&&a.push(xe.range(d.from+r,d.to+o))}}else{let r=Math.min(e.col,t.col),o=Math.max(e.col,t.col);for(let c=n;c<=s;c++){let d=i.doc.line(c),h=jb(d.text,r,i.tabSize,!0);if(h<0)a.push(xe.cursor(d.to));else{let p=jb(d.text,o,i.tabSize);a.push(xe.range(d.from+h,d.from+p))}}}return a}function Ate(i,e){let t=i.coordsAtPos(i.viewport.from);return t?Math.round(Math.abs((t.left-e)/i.defaultCharacterWidth)):-1}function a3(i,e){let t=i.posAtCoords({x:e.clientX,y:e.clientY},!1),n=i.state.doc.lineAt(t),s=t-n.from,a=s>nv?-1:s==n.length?Ate(i,e.clientX):Tu(n.text,i.state.tabSize,t-n.from);return{line:n.number,col:a,off:s}}function Cte(i,e){let t=a3(i,e),n=i.state.selection;return t?{update(s){if(s.docChanged){let a=s.changes.mapPos(s.startState.doc.line(t.line).from),r=s.state.doc.lineAt(a);t={line:r.number,col:t.col,off:Math.min(t.off,r.length)},n=n.map(s.changes)}},get(s,a,r){let o=a3(i,s);if(!o)return n;let c=kte(i.state,t,o);return c.length?r?xe.create(c.concat(n.ranges)):xe.create(c):n}}:null}function Ote(i){let e=(t=>t.altKey&&t.button==0);return Ne.mouseSelectionStyle.of((t,n)=>e(n)?Cte(t,n):null)}const Tte={Alt:[18,i=>!!i.altKey],Control:[17,i=>!!i.ctrlKey],Shift:[16,i=>!!i.shiftKey],Meta:[91,i=>!!i.metaKey]},Mte={style:"cursor: crosshair"};function Nte(i={}){let[e,t]=Tte[i.key||"Alt"],n=bi.fromClass(class{constructor(s){this.view=s,this.isDown=!1}set(s){this.isDown!=s&&(this.isDown=s,this.view.update([]))}},{eventObservers:{keydown(s){this.set(s.keyCode==e||t(s))},keyup(s){(s.keyCode==e||!t(s))&&this.set(!1)},mousemove(s){this.set(t(s))}}});return[n,Ne.contentAttributes.of(s=>{var a;return!((a=s.plugin(n))===null||a===void 0)&&a.isDown?Mte:null})]}const Nm="-10000px";class p5{constructor(e,t,n,s){this.facet=t,this.createTooltipView=n,this.removeTooltipView=s,this.input=e.state.facet(t),this.tooltips=this.input.filter(r=>r);let a=null;this.tooltipViews=this.tooltips.map(r=>a=n(r,a))}update(e,t){var n;let s=e.state.facet(this.facet),a=s.filter(c=>c);if(s===this.input){for(let c of this.tooltipViews)c.update&&c.update(e);return!1}let r=[],o=t?[]:null;for(let c=0;ct[d]=c),t.length=o.length),this.input=s,this.tooltips=a,this.tooltipViews=r,!0}}function Rte(i){let e=i.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:e.clientHeight,right:e.clientWidth}}const ax=Le.define({combine:i=>{var e,t,n;return{position:Me.ios?"absolute":((e=i.find(s=>s.position))===null||e===void 0?void 0:e.position)||"fixed",parent:((t=i.find(s=>s.parent))===null||t===void 0?void 0:t.parent)||null,tooltipSpace:((n=i.find(s=>s.tooltipSpace))===null||n===void 0?void 0:n.tooltipSpace)||Rte}}}),r3=new WeakMap,q2=bi.fromClass(class{constructor(i){this.view=i,this.above=[],this.inView=!0,this.madeAbsolute=!1,this.lastTransaction=0,this.measureTimeout=-1;let e=i.state.facet(ax);this.position=e.position,this.parent=e.parent,this.classes=i.themeClasses,this.createContainer(),this.measureReq={read:this.readMeasure.bind(this),write:this.writeMeasure.bind(this),key:this},this.resizeObserver=typeof ResizeObserver=="function"?new ResizeObserver(()=>this.measureSoon()):null,this.manager=new p5(i,H2,(t,n)=>this.createTooltip(t,n),t=>{this.resizeObserver&&this.resizeObserver.unobserve(t.dom),t.dom.remove()}),this.above=this.manager.tooltips.map(t=>!!t.above),this.intersectionObserver=typeof IntersectionObserver=="function"?new IntersectionObserver(t=>{Date.now()>this.lastTransaction-50&&t.length>0&&t[t.length-1].intersectionRatio<1&&this.measureSoon()},{threshold:[1]}):null,this.observeIntersection(),i.win.addEventListener("resize",this.measureSoon=this.measureSoon.bind(this)),this.maybeMeasure()}createContainer(){this.parent?(this.container=document.createElement("div"),this.container.style.position="relative",this.container.className=this.view.themeClasses,this.parent.appendChild(this.container)):this.container=this.view.dom}observeIntersection(){if(this.intersectionObserver){this.intersectionObserver.disconnect();for(let i of this.manager.tooltipViews)this.intersectionObserver.observe(i.dom)}}measureSoon(){this.measureTimeout<0&&(this.measureTimeout=setTimeout(()=>{this.measureTimeout=-1,this.maybeMeasure()},50))}update(i){i.transactions.length&&(this.lastTransaction=Date.now());let e=this.manager.update(i,this.above);e&&this.observeIntersection();let t=e||i.geometryChanged,n=i.state.facet(ax);if(n.position!=this.position&&!this.madeAbsolute){this.position=n.position;for(let s of this.manager.tooltipViews)s.dom.style.position=this.position;t=!0}if(n.parent!=this.parent){this.parent&&this.container.remove(),this.parent=n.parent,this.createContainer();for(let s of this.manager.tooltipViews)this.container.appendChild(s.dom);t=!0}else this.parent&&this.view.themeClasses!=this.classes&&(this.classes=this.container.className=this.view.themeClasses);t&&this.maybeMeasure()}createTooltip(i,e){let t=i.create(this.view),n=e?e.dom:null;if(t.dom.classList.add("cm-tooltip"),i.arrow&&!t.dom.querySelector(".cm-tooltip > .cm-tooltip-arrow")){let s=document.createElement("div");s.className="cm-tooltip-arrow",t.dom.appendChild(s)}return t.dom.style.position=this.position,t.dom.style.top=Nm,t.dom.style.left="0px",this.container.insertBefore(t.dom,n),t.mount&&t.mount(this.view),this.resizeObserver&&this.resizeObserver.observe(t.dom),t}destroy(){var i,e,t;this.view.win.removeEventListener("resize",this.measureSoon);for(let n of this.manager.tooltipViews)n.dom.remove(),(i=n.destroy)===null||i===void 0||i.call(n);this.parent&&this.container.remove(),(e=this.resizeObserver)===null||e===void 0||e.disconnect(),(t=this.intersectionObserver)===null||t===void 0||t.disconnect(),clearTimeout(this.measureTimeout)}readMeasure(){let i=1,e=1,t=!1;if(this.position=="fixed"&&this.manager.tooltipViews.length){let{dom:a}=this.manager.tooltipViews[0];if(Me.safari){let r=a.getBoundingClientRect();t=Math.abs(r.top+1e4)>1||Math.abs(r.left)>1}else t=!!a.offsetParent&&a.offsetParent!=this.container.ownerDocument.body}if(t||this.position=="absolute")if(this.parent){let a=this.parent.getBoundingClientRect();a.width&&a.height&&(i=a.width/this.parent.offsetWidth,e=a.height/this.parent.offsetHeight)}else({scaleX:i,scaleY:e}=this.view.viewState);let n=this.view.scrollDOM.getBoundingClientRect(),s=U2(this.view);return{visible:{left:n.left+s.left,top:n.top+s.top,right:n.right-s.right,bottom:n.bottom-s.bottom},parent:this.parent?this.container.getBoundingClientRect():this.view.dom.getBoundingClientRect(),pos:this.manager.tooltips.map((a,r)=>{let o=this.manager.tooltipViews[r];return o.getCoords?o.getCoords(a.pos):this.view.coordsAtPos(a.pos)}),size:this.manager.tooltipViews.map(({dom:a})=>a.getBoundingClientRect()),space:this.view.state.facet(ax).tooltipSpace(this.view),scaleX:i,scaleY:e,makeAbsolute:t}}writeMeasure(i){var e;if(i.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let o of this.manager.tooltipViews)o.dom.style.position="absolute"}let{visible:t,space:n,scaleX:s,scaleY:a}=i,r=[];for(let o=0;o=Math.min(t.bottom,n.bottom)||p.rightMath.min(t.right,n.right)+.1)){h.style.top=Nm;continue}let y=c.arrow?d.dom.querySelector(".cm-tooltip-arrow"):null,x=y?7:0,v=_.right-_.left,w=(e=r3.get(d))!==null&&e!==void 0?e:_.bottom-_.top,k=d.offset||Lte,M=this.view.textDirection==Zt.LTR,O=_.width>n.right-n.left?M?n.left:n.right-_.width:M?Math.max(n.left,Math.min(p.left-(y?14:0)+k.x,n.right-v)):Math.min(Math.max(n.left,p.left-v+(y?14:0)-k.x),n.right-v),A=this.above[o];!c.strictSide&&(A?p.top-w-x-k.yn.bottom)&&A==n.bottom-p.bottom>p.top-n.top&&(A=this.above[o]=!A);let C=(A?p.top-n.top:n.bottom-p.bottom)-x;if(CO&&E.topP&&(P=A?E.top-w-2-x:E.bottom+x+2);if(this.position=="absolute"?(h.style.top=(P-i.parent.top)/a+"px",o3(h,(O-i.parent.left)/s)):(h.style.top=P/a+"px",o3(h,O/s)),y){let E=p.left+(M?k.x:-k.x)-(O+14-7);y.style.left=E/s+"px"}d.overlap!==!0&&r.push({left:O,top:P,right:R,bottom:P+w}),h.classList.toggle("cm-tooltip-above",A),h.classList.toggle("cm-tooltip-below",!A),d.positioned&&d.positioned(i.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let i of this.manager.tooltipViews)i.dom.style.top=Nm}},{eventObservers:{scroll(){this.maybeMeasure()}}});function o3(i,e){let t=parseInt(i.style.left,10);(isNaN(t)||Math.abs(e-t)>1)&&(i.style.left=e+"px")}const Pte=Ne.baseTheme({".cm-tooltip":{zIndex:500,boxSizing:"border-box"},"&light .cm-tooltip":{border:"1px solid #bbb",backgroundColor:"#f5f5f5"},"&light .cm-tooltip-section:not(:first-child)":{borderTop:"1px solid #bbb"},"&dark .cm-tooltip":{backgroundColor:"#333338",color:"white"},".cm-tooltip-arrow":{height:"7px",width:"14px",position:"absolute",zIndex:-1,overflow:"hidden","&:before, &:after":{content:"''",position:"absolute",width:0,height:0,borderLeft:"7px solid transparent",borderRight:"7px solid transparent"},".cm-tooltip-above &":{bottom:"-7px","&:before":{borderTop:"7px solid #bbb"},"&:after":{borderTop:"7px solid #f5f5f5",bottom:"1px"}},".cm-tooltip-below &":{top:"-7px","&:before":{borderBottom:"7px solid #bbb"},"&:after":{borderBottom:"7px solid #f5f5f5",top:"1px"}}},"&dark .cm-tooltip .cm-tooltip-arrow":{"&:before":{borderTopColor:"#333338",borderBottomColor:"#333338"},"&:after":{borderTopColor:"transparent",borderBottomColor:"transparent"}}}),Lte={x:0,y:0},H2=Le.define({enables:[q2,Pte]}),Wg=Le.define({combine:i=>i.reduce((e,t)=>e.concat(t),[])});class z0{static create(e){return new z0(e)}constructor(e){this.view=e,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new p5(e,Wg,(t,n)=>this.createHostedView(t,n),t=>t.dom.remove())}createHostedView(e,t){let n=e.create(this.view);return n.dom.classList.add("cm-tooltip-section"),this.dom.insertBefore(n.dom,t?t.dom.nextSibling:this.dom.firstChild),this.mounted&&n.mount&&n.mount(this.view),n}mount(e){for(let t of this.manager.tooltipViews)t.mount&&t.mount(e);this.mounted=!0}positioned(e){for(let t of this.manager.tooltipViews)t.positioned&&t.positioned(e)}update(e){this.manager.update(e)}destroy(){var e;for(let t of this.manager.tooltipViews)(e=t.destroy)===null||e===void 0||e.call(t)}passProp(e){let t;for(let n of this.manager.tooltipViews){let s=n[e];if(s!==void 0){if(t===void 0)t=s;else if(t!==s)return}}return t}get offset(){return this.passProp("offset")}get getCoords(){return this.passProp("getCoords")}get overlap(){return this.passProp("overlap")}get resize(){return this.passProp("resize")}}const jte=H2.compute([Wg],i=>{let e=i.facet(Wg);return e.length===0?null:{pos:Math.min(...e.map(t=>t.pos)),end:Math.max(...e.map(t=>{var n;return(n=t.end)!==null&&n!==void 0?n:t.pos})),create:z0.create,above:e[0].above,arrow:e.some(t=>t.arrow)}});class Ete{constructor(e,t,n,s,a){this.view=e,this.source=t,this.field=n,this.setHover=s,this.hoverTime=a,this.hoverTimeout=-1,this.restartTimeout=-1,this.pending=null,this.lastMove={x:0,y:0,target:e.dom,time:0},this.checkHover=this.checkHover.bind(this),e.dom.addEventListener("mouseleave",this.mouseleave=this.mouseleave.bind(this)),e.dom.addEventListener("mousemove",this.mousemove=this.mousemove.bind(this))}update(){this.pending&&(this.pending=null,clearTimeout(this.restartTimeout),this.restartTimeout=setTimeout(()=>this.startHover(),20))}get active(){return this.view.state.field(this.field)}checkHover(){if(this.hoverTimeout=-1,this.active.length)return;let e=Date.now()-this.lastMove.time;eo.bottom||t.xo.right+e.defaultCharacterWidth)return;let c=e.bidiSpans(e.state.doc.lineAt(s)).find(h=>h.from<=s&&h.to>=s),d=c&&c.dir==Zt.RTL?-1:1;a=t.x{this.pending==o&&(this.pending=null,c&&!(Array.isArray(c)&&!c.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(c)?c:[c])}))},c=>qn(e.state,c,"hover tooltip"))}else r&&!(Array.isArray(r)&&!r.length)&&e.dispatch({effects:this.setHover.of(Array.isArray(r)?r:[r])})}get tooltip(){let e=this.view.plugin(q2),t=e?e.manager.tooltips.findIndex(n=>n.create==z0.create):-1;return t>-1?e.manager.tooltipViews[t]:null}mousemove(e){var t,n;this.lastMove={x:e.clientX,y:e.clientY,target:e.target,time:Date.now()},this.hoverTimeout<0&&(this.hoverTimeout=setTimeout(this.checkHover,this.hoverTime));let{active:s,tooltip:a}=this;if(s.length&&a&&!Dte(a.dom,e)||this.pending){let{pos:r}=s[0]||this.pending,o=(n=(t=s[0])===null||t===void 0?void 0:t.end)!==null&&n!==void 0?n:r;(r==o?this.view.posAtCoords(this.lastMove)!=r:!Ute(this.view,r,o,e.clientX,e.clientY))&&(this.view.dispatch({effects:this.setHover.of([])}),this.pending=null)}}mouseleave(e){clearTimeout(this.hoverTimeout),this.hoverTimeout=-1;let{active:t}=this;if(t.length){let{tooltip:n}=this;n&&n.dom.contains(e.relatedTarget)?this.watchTooltipLeave(n.dom):this.view.dispatch({effects:this.setHover.of([])})}}watchTooltipLeave(e){let t=n=>{e.removeEventListener("mouseleave",t),this.active.length&&!this.view.dom.contains(n.relatedTarget)&&this.view.dispatch({effects:this.setHover.of([])})};e.addEventListener("mouseleave",t)}destroy(){clearTimeout(this.hoverTimeout),this.view.dom.removeEventListener("mouseleave",this.mouseleave),this.view.dom.removeEventListener("mousemove",this.mousemove)}}const Rm=4;function Dte(i,e){let{left:t,right:n,top:s,bottom:a}=i.getBoundingClientRect(),r;if(r=i.querySelector(".cm-tooltip-arrow")){let o=r.getBoundingClientRect();s=Math.min(o.top,s),a=Math.max(o.bottom,a)}return e.clientX>=t-Rm&&e.clientX<=n+Rm&&e.clientY>=s-Rm&&e.clientY<=a+Rm}function Ute(i,e,t,n,s,a){let r=i.scrollDOM.getBoundingClientRect(),o=i.documentTop+i.documentPadding.top+i.contentHeight;if(r.left>n||r.rights||Math.min(r.bottom,o)=e&&c<=t}function Fte(i,e={}){let t=Ze.define(),n=an.define({create(){return[]},update(s,a){if(s.length&&(e.hideOnChange&&(a.docChanged||a.selection)?s=[]:e.hideOn&&(s=s.filter(r=>!e.hideOn(a,r))),a.docChanged)){let r=[];for(let o of s){let c=a.changes.mapPos(o.pos,-1,An.TrackDel);if(c!=null){let d=Object.assign(Object.create(null),o);d.pos=c,d.end!=null&&(d.end=a.changes.mapPos(d.end)),r.push(d)}}s=r}for(let r of a.effects)r.is(t)&&(s=r.value),r.is(Bte)&&(s=[]);return s},provide:s=>Wg.from(s)});return{active:n,extension:[n,bi.define(s=>new Ete(s,i,n,t,e.hoverTime||300)),jte]}}function m5(i,e){let t=i.plugin(q2);if(!t)return null;let n=t.manager.tooltips.indexOf(e);return n<0?null:t.manager.tooltipViews[n]}const Bte=Ze.define(),l3=Le.define({combine(i){let e,t;for(let n of i)e=e||n.topContainer,t=t||n.bottomContainer;return{topContainer:e,bottomContainer:t}}});function Ih(i,e){let t=i.plugin(g5),n=t?t.specs.indexOf(e):-1;return n>-1?t.panels[n]:null}const g5=bi.fromClass(class{constructor(i){this.input=i.state.facet(Wh),this.specs=this.input.filter(t=>t),this.panels=this.specs.map(t=>t(i));let e=i.state.facet(l3);this.top=new Pm(i,!0,e.topContainer),this.bottom=new Pm(i,!1,e.bottomContainer),this.top.sync(this.panels.filter(t=>t.top)),this.bottom.sync(this.panels.filter(t=>!t.top));for(let t of this.panels)t.dom.classList.add("cm-panel"),t.mount&&t.mount()}update(i){let e=i.state.facet(l3);this.top.container!=e.topContainer&&(this.top.sync([]),this.top=new Pm(i.view,!0,e.topContainer)),this.bottom.container!=e.bottomContainer&&(this.bottom.sync([]),this.bottom=new Pm(i.view,!1,e.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let t=i.state.facet(Wh);if(t!=this.input){let n=t.filter(c=>c),s=[],a=[],r=[],o=[];for(let c of n){let d=this.specs.indexOf(c),h;d<0?(h=c(i.view),o.push(h)):(h=this.panels[d],h.update&&h.update(i)),s.push(h),(h.top?a:r).push(h)}this.specs=n,this.panels=s,this.top.sync(a),this.bottom.sync(r);for(let c of o)c.dom.classList.add("cm-panel"),c.mount&&c.mount()}else for(let n of this.panels)n.update&&n.update(i)}destroy(){this.top.sync([]),this.bottom.sync([])}},{provide:i=>Ne.scrollMargins.of(e=>{let t=e.plugin(i);return t&&{top:t.top.scrollMargin(),bottom:t.bottom.scrollMargin()}})});class Pm{constructor(e,t,n){this.view=e,this.top=t,this.container=n,this.dom=void 0,this.classes="",this.panels=[],this.syncClasses()}sync(e){for(let t of this.panels)t.destroy&&e.indexOf(t)<0&&t.destroy();this.panels=e,this.syncDOM()}syncDOM(){if(this.panels.length==0){this.dom&&(this.dom.remove(),this.dom=void 0);return}if(!this.dom){this.dom=document.createElement("div"),this.dom.className=this.top?"cm-panels cm-panels-top":"cm-panels cm-panels-bottom",this.dom.style[this.top?"top":"bottom"]="0";let t=this.container||this.view.dom;t.insertBefore(this.dom,this.top?t.firstChild:null)}let e=this.dom.firstChild;for(let t of this.panels)if(t.dom.parentNode==this.dom){for(;e!=t.dom;)e=c3(e);e=e.nextSibling}else this.dom.insertBefore(t.dom,e);for(;e;)e=c3(e)}scrollMargin(){return!this.dom||this.container?0:Math.max(0,this.top?this.dom.getBoundingClientRect().bottom-Math.max(0,this.view.scrollDOM.getBoundingClientRect().top):Math.min(innerHeight,this.view.scrollDOM.getBoundingClientRect().bottom)-this.dom.getBoundingClientRect().top)}syncClasses(){if(!(!this.container||this.classes==this.view.themeClasses)){for(let e of this.classes.split(" "))e&&this.container.classList.remove(e);for(let e of(this.classes=this.view.themeClasses).split(" "))e&&this.container.classList.add(e)}}}function c3(i){let e=i.nextSibling;return i.remove(),e}const Wh=Le.define({enables:g5});class wr extends Dl{compare(e){return this==e||this.constructor==e.constructor&&this.eq(e)}eq(e){return!1}destroy(e){}}wr.prototype.elementClass="";wr.prototype.toDOM=void 0;wr.prototype.mapMode=An.TrackBefore;wr.prototype.startSide=wr.prototype.endSide=-1;wr.prototype.point=!0;const dg=Le.define(),zte=Le.define(),qte={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>mt.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{},side:"before"},yh=Le.define();function Hte(i){return[_5(),yh.of(z(z({},qte),i))]}const u3=Le.define({combine:i=>i.some(e=>e)});function _5(i){return[Kte]}const Kte=bi.fromClass(class{constructor(i){this.view=i,this.domAfter=null,this.prevViewport=i.viewport,this.dom=document.createElement("div"),this.dom.className="cm-gutters cm-gutters-before",this.dom.setAttribute("aria-hidden","true"),this.dom.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.gutters=i.state.facet(yh).map(e=>new h3(i,e)),this.fixed=!i.state.facet(u3);for(let e of this.gutters)e.config.side=="after"?this.getDOMAfter().appendChild(e.dom):this.dom.appendChild(e.dom);this.fixed&&(this.dom.style.position="sticky"),this.syncGutters(!1),i.scrollDOM.insertBefore(this.dom,i.contentDOM)}getDOMAfter(){return this.domAfter||(this.domAfter=document.createElement("div"),this.domAfter.className="cm-gutters cm-gutters-after",this.domAfter.setAttribute("aria-hidden","true"),this.domAfter.style.minHeight=this.view.contentHeight/this.view.scaleY+"px",this.domAfter.style.position=this.fixed?"sticky":"",this.view.scrollDOM.appendChild(this.domAfter)),this.domAfter}update(i){if(this.updateGutters(i)){let e=this.prevViewport,t=i.view.viewport,n=Math.min(e.to,t.to)-Math.max(e.from,t.from);this.syncGutters(n<(t.to-t.from)*.8)}if(i.geometryChanged){let e=this.view.contentHeight/this.view.scaleY+"px";this.dom.style.minHeight=e,this.domAfter&&(this.domAfter.style.minHeight=e)}this.view.state.facet(u3)!=!this.fixed&&(this.fixed=!this.fixed,this.dom.style.position=this.fixed?"sticky":"",this.domAfter&&(this.domAfter.style.position=this.fixed?"sticky":"")),this.prevViewport=i.view.viewport}syncGutters(i){let e=this.dom.nextSibling;i&&(this.dom.remove(),this.domAfter&&this.domAfter.remove());let t=mt.iter(this.view.state.facet(dg),this.view.viewport.from),n=[],s=this.gutters.map(a=>new Vte(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(n.length&&(n=[]),Array.isArray(a.type)){let r=!0;for(let o of a.type)if(o.type==Cn.Text&&r){sv(t,n,o.from);for(let c of s)c.line(this.view,o,n);r=!1}else if(o.widget)for(let c of s)c.widget(this.view,o)}else if(a.type==Cn.Text){sv(t,n,a.from);for(let r of s)r.line(this.view,a,n)}else if(a.widget)for(let r of s)r.widget(this.view,a);for(let a of s)a.finish();i&&(this.view.scrollDOM.insertBefore(this.dom,e),this.domAfter&&this.view.scrollDOM.appendChild(this.domAfter))}updateGutters(i){let e=i.startState.facet(yh),t=i.state.facet(yh),n=i.docChanged||i.heightChanged||i.viewportChanged||!mt.eq(i.startState.facet(dg),i.state.facet(dg),i.view.viewport.from,i.view.viewport.to);if(e==t)for(let s of this.gutters)s.update(i)&&(n=!0);else{n=!0;let s=[];for(let a of t){let r=e.indexOf(a);r<0?s.push(new h3(this.view,a)):(this.gutters[r].update(i),s.push(this.gutters[r]))}for(let a of this.gutters)a.dom.remove(),s.indexOf(a)<0&&a.destroy();for(let a of s)a.config.side=="after"?this.getDOMAfter().appendChild(a.dom):this.dom.appendChild(a.dom);this.gutters=s}return n}destroy(){for(let i of this.gutters)i.destroy();this.dom.remove(),this.domAfter&&this.domAfter.remove()}},{provide:i=>Ne.scrollMargins.of(e=>{let t=e.plugin(i);if(!t||t.gutters.length==0||!t.fixed)return null;let n=t.dom.offsetWidth*e.scaleX,s=t.domAfter?t.domAfter.offsetWidth*e.scaleX:0;return e.textDirection==Zt.LTR?{left:n,right:s}:{right:n,left:s}})});function d3(i){return Array.isArray(i)?i:[i]}function sv(i,e,t){for(;i.value&&i.from<=t;)i.from==t&&e.push(i.value),i.next()}class Vte{constructor(e,t,n){this.gutter=e,this.height=n,this.i=0,this.cursor=mt.iter(e.markers,t.from)}addElement(e,t,n){let{gutter:s}=this,a=(t.top-this.height)/e.scaleY,r=t.height/e.scaleY;if(this.i==s.elements.length){let o=new y5(e,r,a,n);s.elements.push(o),s.dom.appendChild(o.dom)}else s.elements[this.i].update(e,r,a,n);this.height=t.bottom,this.i++}line(e,t,n){let s=[];sv(this.cursor,s,t.from),n.length&&(s=s.concat(n));let a=this.gutter.config.lineMarker(e,t,s);a&&s.unshift(a);let r=this.gutter;s.length==0&&!r.config.renderEmptyElements||this.addElement(e,t,s)}widget(e,t){let n=this.gutter.config.widgetMarker(e,t.widget,t),s=n?[n]:null;for(let a of e.state.facet(zte)){let r=a(e,t.widget,t);r&&(s||(s=[])).push(r)}s&&this.addElement(e,t,s)}finish(){let e=this.gutter;for(;e.elements.length>this.i;){let t=e.elements.pop();e.dom.removeChild(t.dom),t.destroy()}}}class h3{constructor(e,t){this.view=e,this.config=t,this.elements=[],this.spacer=null,this.dom=document.createElement("div"),this.dom.className="cm-gutter"+(this.config.class?" "+this.config.class:"");for(let n in t.domEventHandlers)this.dom.addEventListener(n,s=>{let a=s.target,r;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let c=a.getBoundingClientRect();r=(c.top+c.bottom)/2}else r=s.clientY;let o=e.lineBlockAtHeight(r-e.documentTop);t.domEventHandlers[n](e,o,s)&&s.preventDefault()});this.markers=d3(t.markers(e)),t.initialSpacer&&(this.spacer=new y5(e,0,0,[t.initialSpacer(e)]),this.dom.appendChild(this.spacer.dom),this.spacer.dom.style.cssText+="visibility: hidden; pointer-events: none")}update(e){let t=this.markers;if(this.markers=d3(this.config.markers(e.view)),this.spacer&&this.config.updateSpacer){let s=this.config.updateSpacer(this.spacer.markers[0],e);s!=this.spacer.markers[0]&&this.spacer.update(e.view,0,0,[s])}let n=e.view.viewport;return!mt.eq(this.markers,t,n.from,n.to)||(this.config.lineMarkerChange?this.config.lineMarkerChange(e):!1)}destroy(){for(let e of this.elements)e.destroy()}}class y5{constructor(e,t,n,s){this.height=-1,this.above=0,this.markers=[],this.dom=document.createElement("div"),this.dom.className="cm-gutterElement",this.update(e,t,n,s)}update(e,t,n,s){this.height!=t&&(this.height=t,this.dom.style.height=t+"px"),this.above!=n&&(this.dom.style.marginTop=(this.above=n)?n+"px":""),Ite(this.markers,s)||this.setMarkers(e,s)}setMarkers(e,t){let n="cm-gutterElement",s=this.dom.firstChild;for(let a=0,r=0;;){let o=r,c=aa(o,c,d)||r(o,c,d):r}return n}})}});class rx extends wr{constructor(e){super(),this.number=e}eq(e){return this.number==e.number}toDOM(){return document.createTextNode(this.number)}}function ox(i,e){return i.state.facet(Kc).formatNumber(e,i.state)}const Gte=yh.compute([Kc],i=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(e){return e.state.facet(Wte)},lineMarker(e,t,n){return n.some(s=>s.toDOM)?null:new rx(ox(e,e.state.doc.lineAt(t.from).number))},widgetMarker:(e,t,n)=>{for(let s of e.state.facet(Xte)){let a=s(e,t,n);if(a)return a}return null},lineMarkerChange:e=>e.startState.facet(Kc)!=e.state.facet(Kc),initialSpacer(e){return new rx(ox(e,f3(e.state.doc.lines)))},updateSpacer(e,t){let n=ox(t.view,f3(t.view.state.doc.lines));return n==e.number?e:new rx(n)},domEventHandlers:i.facet(Kc).domEventHandlers,side:"before"}));function Qte(i={}){return[Kc.of(i),_5(),Gte]}function f3(i){let e=9;for(;e{let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.head).from;s>t&&(t=s,e.push(Yte.range(s)))}return mt.of(e)});function Jte(){return Zte}const x5=1024;let $te=0;class lx{constructor(e,t){this.from=e,this.to=t}}class nt{constructor(e={}){this.id=$te++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Yn.match(e)),t=>{let n=e(t);return n===void 0?null:[this,n]}}}nt.closedBy=new nt({deserialize:i=>i.split(" ")});nt.openedBy=new nt({deserialize:i=>i.split(" ")});nt.group=new nt({deserialize:i=>i.split(" ")});nt.isolate=new nt({deserialize:i=>{if(i&&i!="rtl"&&i!="ltr"&&i!="auto")throw new RangeError("Invalid value for isolate: "+i);return i||"auto"}});nt.contextHash=new nt({perNode:!0});nt.lookAhead=new nt({perNode:!0});nt.mounted=new nt({perNode:!0});class Xg{constructor(e,t,n){this.tree=e,this.overlay=t,this.parser=n}static get(e){return e&&e.props&&e.props[nt.mounted.id]}}const eie=Object.create(null);class Yn{constructor(e,t,n,s=0){this.name=e,this.props=t,this.id=n,this.flags=s}static define(e){let t=e.props&&e.props.length?Object.create(null):eie,n=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),s=new Yn(e.name||"",t,e.id,n);if(e.props){for(let a of e.props)if(Array.isArray(a)||(a=a(s)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");t[a[0].id]=a[1]}}return s}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let t=this.prop(nt.group);return t?t.indexOf(e)>-1:!1}return this.id==e}static match(e){let t=Object.create(null);for(let n in e)for(let s of n.split(" "))t[s]=e[n];return n=>{for(let s=n.prop(nt.group),a=-1;a<(s?s.length:0);a++){let r=t[a<0?n.name:s[a]];if(r)return r}}}}Yn.none=new Yn("",Object.create(null),0,8);class K2{constructor(e){this.types=e;for(let t=0;t0;for(let c=this.cursor(r|Hi.IncludeAnonymous);;){let d=!1;if(c.from<=a&&c.to>=s&&(!o&&c.type.isAnonymous||t(c)!==!1)){if(c.firstChild())continue;d=!0}for(;d&&n&&(o||!c.type.isAnonymous)&&n(c),!c.nextSibling();){if(!c.parent())return;d=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let t in this.props)e.push([+t,this.props[t]]);return e}balance(e={}){return this.children.length<=8?this:W2(Yn.none,this.children,this.positions,0,this.children.length,0,this.length,(t,n,s)=>new Ri(this.type,t,n,s,this.propValues),e.makeTree||((t,n,s)=>new Ri(Yn.none,t,n,s)))}static build(e){return sie(e)}}Ri.empty=new Ri(Yn.none,[],[],0);class V2{constructor(e,t){this.buffer=e,this.index=t}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new V2(this.buffer,this.index)}}class Mo{constructor(e,t,n){this.buffer=e,this.length=t,this.set=n}get type(){return Yn.none}toString(){let e=[];for(let t=0;t0));c=r[c+3]);return o}slice(e,t,n){let s=this.buffer,a=new Uint16Array(t-e),r=0;for(let o=e,c=0;o=e&&te;case 1:return t<=e&&n>e;case 2:return n>e;case 4:return!0}}function Xh(i,e,t,n){for(var s;i.from==i.to||(t<1?i.from>=e:i.from>e)||(t>-1?i.to<=e:i.to0?o.length:-1;e!=d;e+=t){let h=o[e],p=c[e]+r.from;if(b5(s,n,p,p+h.length)){if(h instanceof Mo){if(a&Hi.ExcludeBuffers)continue;let _=h.findChild(0,h.buffer.length,t,n-p,s);if(_>-1)return new _o(new tie(r,h,e,p),null,_)}else if(a&Hi.IncludeAnonymous||!h.type.isAnonymous||I2(h)){let _;if(!(a&Hi.IgnoreMounts)&&(_=Xg.get(h))&&!_.overlay)return new zs(_.tree,p,e,r);let y=new zs(h,p,e,r);return a&Hi.IncludeAnonymous||!y.type.isAnonymous?y:y.nextChild(t<0?h.children.length-1:0,t,n,s)}}}if(a&Hi.IncludeAnonymous||!r.type.isAnonymous||(r.index>=0?e=r.index+t:e=t<0?-1:r._parent._tree.children.length,r=r._parent,!r))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,t,n=0){let s;if(!(n&Hi.IgnoreOverlays)&&(s=Xg.get(this._tree))&&s.overlay){let a=e-this.from;for(let{from:r,to:o}of s.overlay)if((t>0?r<=a:r=a:o>a))return new zs(s.tree,s.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,t,n)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function m3(i,e,t,n){let s=i.cursor(),a=[];if(!s.firstChild())return a;if(t!=null){for(let r=!1;!r;)if(r=s.type.is(t),!s.nextSibling())return a}for(;;){if(n!=null&&s.type.is(n))return a;if(s.type.is(e)&&a.push(s.node),!s.nextSibling())return n==null?a:[]}}function av(i,e,t=e.length-1){for(let n=i;t>=0;n=n.parent){if(!n)return!1;if(!n.type.isAnonymous){if(e[t]&&e[t]!=n.name)return!1;t--}}return!0}class tie{constructor(e,t,n,s){this.parent=e,this.buffer=t,this.index=n,this.start=s}}class _o extends v5{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,t,n){super(),this.context=e,this._parent=t,this.index=n,this.type=e.buffer.set.types[e.buffer.buffer[n]]}child(e,t,n){let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.context.start,n);return a<0?null:new _o(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,t,n=0){if(n&Hi.ExcludeBuffers)return null;let{buffer:s}=this.context,a=s.findChild(this.index+4,s.buffer[this.index+3],t>0?1:-1,e-this.context.start,t);return a<0?null:new _o(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,t=e.buffer[this.index+3];return t<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new _o(this.context,this._parent,t):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,t=this._parent?this._parent.index+4:0;return this.index==t?this.externalSibling(-1):new _o(this.context,this._parent,e.findChild(t,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],t=[],{buffer:n}=this.context,s=this.index+4,a=n.buffer[this.index+3];if(a>s){let r=n.buffer[this.index+1];e.push(n.slice(s,a,r)),t.push(0)}return new Ri(this.type,e,t,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function S5(i){if(!i.length)return null;let e=0,t=i[0];for(let a=1;at.from||r.to=e){let o=new zs(r.tree,r.overlay[0].from+a.from,-1,a);(s||(s=[n])).push(Xh(o,e,t,!1))}}return s?S5(s):n}class rv{get name(){return this.type.name}constructor(e,t=0){if(this.mode=t,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,e instanceof zs)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let n=e._parent;n;n=n._parent)this.stack.unshift(n.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,t){this.index=e;let{start:n,buffer:s}=this.buffer;return this.type=t||s.set.types[s.buffer[e]],this.from=n+s.buffer[e+1],this.to=n+s.buffer[e+2],!0}yield(e){return e?e instanceof zs?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,t,n){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,t,n,this.mode));let{buffer:s}=this.buffer,a=s.findChild(this.index+4,s.buffer[this.index+3],e,t-this.buffer.start,n);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,t,n=this.mode){return this.buffer?n&Hi.ExcludeBuffers?!1:this.enterChild(1,e,t):this.yield(this._tree.enter(e,t,n))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Hi.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Hi.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:t}=this.buffer,n=this.stack.length-1;if(e<0){let s=n<0?0:this.stack[n]+4;if(this.index!=s)return this.yieldBuf(t.findChild(s,this.index,-1,0,4))}else{let s=t.buffer[this.index+3];if(s<(n<0?t.buffer.length:t.buffer[this.stack[n]+3]))return this.yieldBuf(s)}return n<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let t,n,{buffer:s}=this;if(s){if(e>0){if(this.index-1)for(let a=t+e,r=e<0?-1:n._tree.children.length;a!=r;a+=e){let o=n._tree.children[a];if(this.mode&Hi.IncludeAnonymous||o instanceof Mo||!o.type.isAnonymous||I2(o))return!1}return!0}move(e,t){if(t&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,t=0){for(;(this.from==this.to||(t<1?this.from>=e:this.from>e)||(t>-1?this.to<=e:this.to=0;){for(let r=e;r;r=r._parent)if(r.index==s){if(s==this.index)return r;t=r,n=a+1;break e}s=this.stack[--a]}for(let s=n;s=0;a--){if(a<0)return av(this._tree,e,s);let r=n[t.buffer[this.stack[a]]];if(!r.isAnonymous){if(e[s]&&e[s]!=r.name)return!1;s--}}return!0}}function I2(i){return i.children.some(e=>e instanceof Mo||!e.type.isAnonymous||I2(e))}function sie(i){var e;let{buffer:t,nodeSet:n,maxBufferLength:s=x5,reused:a=[],minRepeatType:r=n.types.length}=i,o=Array.isArray(t)?new V2(t,t.length):t,c=n.types,d=0,h=0;function p(C,P,R,E,L,D){let{id:q,start:B,end:H,size:W}=o,V=h,U=d;if(W<0)if(o.next(),W==-1){let F=a[q];R.push(F),E.push(B-C);return}else if(W==-3){d=q;return}else if(W==-4){h=q;return}else throw new RangeError(`Unrecognized record size: ${W}`);let G=c[q],$,ie,ue=B-C;if(H-B<=s&&(ie=w(o.pos-P,L))){let F=new Uint16Array(ie.size-ie.skip),Y=o.pos-ie.size,ce=F.length;for(;o.pos>Y;)ce=k(ie.start,F,ce);$=new Mo(F,H-ie.start,n),ue=ie.start-C}else{let F=o.pos-W;o.next();let Y=[],ce=[],J=q>=r?q:-1,me=0,Se=H;for(;o.pos>F;)J>=0&&o.id==J&&o.size>=0?(o.end<=Se-s&&(x(Y,ce,B,me,o.end,Se,J,V,U),me=Y.length,Se=o.end),o.next()):D>2500?_(B,F,Y,ce):p(B,F,Y,ce,J,D+1);if(J>=0&&me>0&&me-1&&me>0){let Re=y(G,U);$=W2(G,Y,ce,0,Y.length,0,H-B,Re,Re)}else $=v(G,Y,ce,H-B,V-H,U)}R.push($),E.push(ue)}function _(C,P,R,E){let L=[],D=0,q=-1;for(;o.pos>P;){let{id:B,start:H,end:W,size:V}=o;if(V>4)o.next();else{if(q>-1&&H=0;W-=3)B[V++]=L[W],B[V++]=L[W+1]-H,B[V++]=L[W+2]-H,B[V++]=V;R.push(new Mo(B,L[2]-H,n)),E.push(H-C)}}function y(C,P){return(R,E,L)=>{let D=0,q=R.length-1,B,H;if(q>=0&&(B=R[q])instanceof Ri){if(!q&&B.type==C&&B.length==L)return B;(H=B.prop(nt.lookAhead))&&(D=E[q]+B.length+H)}return v(C,R,E,L,D,P)}}function x(C,P,R,E,L,D,q,B,H){let W=[],V=[];for(;C.length>E;)W.push(C.pop()),V.push(P.pop()+R-L);C.push(v(n.types[q],W,V,D-L,B-D,H)),P.push(L-R)}function v(C,P,R,E,L,D,q){if(D){let B=[nt.contextHash,D];q=q?[B].concat(q):[B]}if(L>25){let B=[nt.lookAhead,L];q=q?[B].concat(q):[B]}return new Ri(C,P,R,E,q)}function w(C,P){let R=o.fork(),E=0,L=0,D=0,q=R.end-s,B={size:0,start:0,skip:0};e:for(let H=R.pos-C;R.pos>H;){let W=R.size;if(R.id==P&&W>=0){B.size=E,B.start=L,B.skip=D,D+=4,E+=4,R.next();continue}let V=R.pos-W;if(W<0||V=r?4:0,G=R.start;for(R.next();R.pos>V;){if(R.size<0)if(R.size==-3||R.size==-4)U+=4;else break e;else R.id>=r&&(U+=4);R.next()}L=G,E+=W,D+=U}return(P<0||E==C)&&(B.size=E,B.start=L,B.skip=D),B.size>4?B:void 0}function k(C,P,R){let{id:E,start:L,end:D,size:q}=o;if(o.next(),q>=0&&E4){let H=o.pos-(q-4);for(;o.pos>H;)R=k(C,P,R)}P[--R]=B,P[--R]=D-C,P[--R]=L-C,P[--R]=E}else q==-3?d=E:q==-4&&(h=E);return R}let M=[],O=[];for(;o.pos>0;)p(i.start||0,i.bufferStart||0,M,O,-1,0);let A=(e=i.length)!==null&&e!==void 0?e:M.length?O[0]+M[0].length:0;return new Ri(c[i.topID],M.reverse(),O.reverse(),A)}const g3=new WeakMap;function hg(i,e){if(!i.isAnonymous||e instanceof Mo||e.type!=i)return 1;let t=g3.get(e);if(t==null){t=1;for(let n of e.children){if(n.type!=i||!(n instanceof Ri)){t=1;break}t+=hg(i,n)}g3.set(e,t)}return t}function W2(i,e,t,n,s,a,r,o,c){let d=0;for(let x=n;x=h)break;P+=R}if(O==A+1){if(P>h){let R=x[A];y(R.children,R.positions,0,R.children.length,v[A]+M);continue}p.push(x[A])}else{let R=v[O-1]+x[O-1].length-C;p.push(W2(i,x,v,A,O,C,R,null,c))}_.push(C+M-a)}}return y(e,t,n,s,0),(o||c)(p,_,r)}class Rl{constructor(e,t,n,s,a=!1,r=!1){this.from=e,this.to=t,this.tree=n,this.offset=s,this.open=(a?1:0)|(r?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,t=[],n=!1){let s=[new Rl(0,e.length,e,0,!1,n)];for(let a of t)a.to>e.length&&s.push(a);return s}static applyChanges(e,t,n=128){if(!t.length)return e;let s=[],a=1,r=e.length?e[0]:null;for(let o=0,c=0,d=0;;o++){let h=o=n)for(;r&&r.from=_.from||p<=_.to||d){let y=Math.max(_.from,c)-d,x=Math.min(_.to,p)-d;_=y>=x?null:new Rl(y,x,_.tree,_.offset+d,o>0,!!h)}if(_&&s.push(_),r.to>p)break;r=anew lx(s.from,s.to)):[new lx(0,0)]:[new lx(0,e.length)],this.createParse(e,t||[],n)}parse(e,t,n){let s=this.startParse(e,t,n);for(;;){let a=s.advance();if(a)return a}}}class aie{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,t){return this.string.slice(e,t)}}new nt({perNode:!0});let rie=0,cr=class ov{constructor(e,t,n,s){this.name=e,this.set=t,this.base=n,this.modified=s,this.id=rie++}toString(){let{name:e}=this;for(let t of this.modified)t.name&&(e=`${t.name}(${e})`);return e}static define(e,t){let n=typeof e=="string"?e:"?";if(e instanceof ov&&(t=e),t!=null&&t.base)throw new Error("Can not derive from a modified tag");let s=new ov(n,[],null,[]);if(s.set.push(s),t)for(let a of t.set)s.set.push(a);return s}static defineModifier(e){let t=new Gg(e);return n=>n.modified.indexOf(t)>-1?n:Gg.get(n.base||n,n.modified.concat(t).sort((s,a)=>s.id-a.id))}},oie=0;class Gg{constructor(e){this.name=e,this.instances=[],this.id=oie++}static get(e,t){if(!t.length)return e;let n=t[0].instances.find(o=>o.base==e&&lie(t,o.modified));if(n)return n;let s=[],a=new cr(e.name,s,e,t);for(let o of t)o.instances.push(a);let r=cie(t);for(let o of e.set)if(!o.modified.length)for(let c of r)s.push(Gg.get(o,c));return a}}function lie(i,e){return i.length==e.length&&i.every((t,n)=>t==e[n])}function cie(i){let e=[[]];for(let t=0;tn.length-t.length)}function k5(i){let e=Object.create(null);for(let t in i){let n=i[t];Array.isArray(n)||(n=[n]);for(let s of t.split(" "))if(s){let a=[],r=2,o=s;for(let p=0;;){if(o=="..."&&p>0&&p+3==s.length){r=1;break}let _=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);if(!_)throw new RangeError("Invalid path: "+s);if(a.push(_[0]=="*"?"":_[0][0]=='"'?JSON.parse(_[0]):_[0]),p+=_[0].length,p==s.length)break;let y=s[p++];if(p==s.length&&y=="!"){r=0;break}if(y!="/")throw new RangeError("Invalid path: "+s);o=s.slice(p)}let c=a.length-1,d=a[c];if(!d)throw new RangeError("Invalid path: "+s);let h=new Gh(n,r,c>0?a.slice(0,c):null);e[d]=h.sort(e[d])}}return A5.add(e)}const A5=new nt({combine(i,e){let t,n,s;for(;i||e;){if(!i||e&&i.depth>=e.depth?(s=e,e=e.next):(s=i,i=i.next),t&&t.mode==s.mode&&!s.context&&!t.context)continue;let a=new Gh(s.tags,s.mode,s.context);t?t.next=a:n=a,t=a}return n}});class Gh{constructor(e,t,n,s){this.tags=e,this.mode=t,this.context=n,this.next=s}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth{let r=s;for(let o of a)for(let c of o.set){let d=t[c.id];if(d){r=r?r+" "+d:d;break}}return r},scope:n}}function uie(i,e){let t=null;for(let n of i){let s=n.style(e);s&&(t=t?t+" "+s:s)}return t}function die(i,e,t,n=0,s=i.length){let a=new hie(n,Array.isArray(e)?e:[e],t);a.highlightRange(i.cursor(),n,s,"",a.highlighters),a.flush(s)}class hie{constructor(e,t,n){this.at=e,this.highlighters=t,this.span=n,this.class=""}startSpan(e,t){t!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=t)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,t,n,s,a){let{type:r,from:o,to:c}=e;if(o>=n||c<=t)return;r.isTop&&(a=this.highlighters.filter(y=>!y.scope||y.scope(r)));let d=s,h=fie(e)||Gh.empty,p=uie(a,h.tags);if(p&&(d&&(d+=" "),d+=p,h.mode==1&&(s+=(s?" ":"")+p)),this.startSpan(Math.max(t,o),d),h.opaque)return;let _=e.tree&&e.tree.prop(nt.mounted);if(_&&_.overlay){let y=e.node.enter(_.overlay[0].from+o,1),x=this.highlighters.filter(w=>!w.scope||w.scope(_.tree.type)),v=e.firstChild();for(let w=0,k=o;;w++){let M=w<_.overlay.length?_.overlay[w]:null,O=M?M.from+o:c,A=Math.max(t,k),C=Math.min(n,O);if(A=O||!e.nextSibling())););if(!M||O>n)break;k=M.to+o,k>t&&(this.highlightRange(y.cursor(),Math.max(t,M.from+o),Math.min(n,k),"",x),this.startSpan(Math.min(n,k),d))}v&&e.parent()}else if(e.firstChild()){_&&(s="");do if(!(e.to<=t)){if(e.from>=n)break;this.highlightRange(e,t,n,s,a),this.startSpan(Math.min(n,e.to),d)}while(e.nextSibling());e.parent()}}}function fie(i){let e=i.type.prop(A5);for(;e&&e.context&&!i.matchContext(e.context);)e=e.next;return e||null}const Oe=cr.define,jm=Oe(),so=Oe(),_3=Oe(so),y3=Oe(so),ao=Oe(),Em=Oe(ao),cx=Oe(ao),xa=Oe(),rl=Oe(xa),pa=Oe(),ma=Oe(),lv=Oe(),Bd=Oe(lv),Dm=Oe(),le={comment:jm,lineComment:Oe(jm),blockComment:Oe(jm),docComment:Oe(jm),name:so,variableName:Oe(so),typeName:_3,tagName:Oe(_3),propertyName:y3,attributeName:Oe(y3),className:Oe(so),labelName:Oe(so),namespace:Oe(so),macroName:Oe(so),literal:ao,string:Em,docString:Oe(Em),character:Oe(Em),attributeValue:Oe(Em),number:cx,integer:Oe(cx),float:Oe(cx),bool:Oe(ao),regexp:Oe(ao),escape:Oe(ao),color:Oe(ao),url:Oe(ao),keyword:pa,self:Oe(pa),null:Oe(pa),atom:Oe(pa),unit:Oe(pa),modifier:Oe(pa),operatorKeyword:Oe(pa),controlKeyword:Oe(pa),definitionKeyword:Oe(pa),moduleKeyword:Oe(pa),operator:ma,derefOperator:Oe(ma),arithmeticOperator:Oe(ma),logicOperator:Oe(ma),bitwiseOperator:Oe(ma),compareOperator:Oe(ma),updateOperator:Oe(ma),definitionOperator:Oe(ma),typeOperator:Oe(ma),controlOperator:Oe(ma),punctuation:lv,separator:Oe(lv),bracket:Bd,angleBracket:Oe(Bd),squareBracket:Oe(Bd),paren:Oe(Bd),brace:Oe(Bd),content:xa,heading:rl,heading1:Oe(rl),heading2:Oe(rl),heading3:Oe(rl),heading4:Oe(rl),heading5:Oe(rl),heading6:Oe(rl),contentSeparator:Oe(xa),list:Oe(xa),quote:Oe(xa),emphasis:Oe(xa),strong:Oe(xa),link:Oe(xa),monospace:Oe(xa),strikethrough:Oe(xa),inserted:Oe(),deleted:Oe(),changed:Oe(),invalid:Oe(),meta:Dm,documentMeta:Oe(Dm),annotation:Oe(Dm),processingInstruction:Oe(Dm),definition:cr.defineModifier("definition"),constant:cr.defineModifier("constant"),function:cr.defineModifier("function"),standard:cr.defineModifier("standard"),local:cr.defineModifier("local"),special:cr.defineModifier("special")};for(let i in le){let e=le[i];e instanceof cr&&(e.name=i)}C5([{tag:le.link,class:"tok-link"},{tag:le.heading,class:"tok-heading"},{tag:le.emphasis,class:"tok-emphasis"},{tag:le.strong,class:"tok-strong"},{tag:le.keyword,class:"tok-keyword"},{tag:le.atom,class:"tok-atom"},{tag:le.bool,class:"tok-bool"},{tag:le.url,class:"tok-url"},{tag:le.labelName,class:"tok-labelName"},{tag:le.inserted,class:"tok-inserted"},{tag:le.deleted,class:"tok-deleted"},{tag:le.literal,class:"tok-literal"},{tag:le.string,class:"tok-string"},{tag:le.number,class:"tok-number"},{tag:[le.regexp,le.escape,le.special(le.string)],class:"tok-string2"},{tag:le.variableName,class:"tok-variableName"},{tag:le.local(le.variableName),class:"tok-variableName tok-local"},{tag:le.definition(le.variableName),class:"tok-variableName tok-definition"},{tag:le.special(le.variableName),class:"tok-variableName2"},{tag:le.definition(le.propertyName),class:"tok-propertyName tok-definition"},{tag:le.typeName,class:"tok-typeName"},{tag:le.namespace,class:"tok-namespace"},{tag:le.className,class:"tok-className"},{tag:le.macroName,class:"tok-macroName"},{tag:le.propertyName,class:"tok-propertyName"},{tag:le.operator,class:"tok-operator"},{tag:le.comment,class:"tok-comment"},{tag:le.meta,class:"tok-meta"},{tag:le.invalid,class:"tok-invalid"},{tag:le.punctuation,class:"tok-punctuation"}]);var ux;const Vc=new nt;function pie(i){return Le.define({combine:i?e=>e.concat(i):void 0})}const mie=new nt;class Js{constructor(e,t,n=[],s=""){this.data=e,this.name=s,ut.prototype.hasOwnProperty("tree")||Object.defineProperty(ut.prototype,"tree",{get(){return gn(this)}}),this.parser=t,this.extension=[No.of(this),ut.languageData.of((a,r,o)=>{let c=x3(a,r,o),d=c.type.prop(Vc);if(!d)return[];let h=a.facet(d),p=c.type.prop(mie);if(p){let _=c.resolve(r-c.from,o);for(let y of p)if(y.test(_,a)){let x=a.facet(y.facet);return y.type=="replace"?x:x.concat(h)}}return h})].concat(n)}isActiveAt(e,t,n=-1){return x3(e,t,n).type.prop(Vc)==this.data}findRegions(e){let t=e.facet(No);if((t==null?void 0:t.data)==this.data)return[{from:0,to:e.doc.length}];if(!t||!t.allowsNesting)return[];let n=[],s=(a,r)=>{if(a.prop(Vc)==this.data){n.push({from:r,to:r+a.length});return}let o=a.prop(nt.mounted);if(o){if(o.tree.prop(Vc)==this.data){if(o.overlay)for(let c of o.overlay)n.push({from:c.from+r,to:c.to+r});else n.push({from:r,to:r+a.length});return}else if(o.overlay){let c=n.length;if(s(o.tree,o.overlay[0].from+r),n.length>c)return}}for(let c=0;cn.isTop?t:void 0)]}),e.name)}configure(e,t){return new Qg(this.data,this.parser.configure(e),t||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function gn(i){let e=i.field(Js.state,!1);return e?e.tree:Ri.empty}class gie{constructor(e){this.doc=e,this.cursorPos=0,this.string="",this.cursor=e.iter()}get length(){return this.doc.length}syncTo(e){return this.string=this.cursor.next(e-this.cursorPos).value,this.cursorPos=e+this.string.length,this.cursorPos-this.string.length}chunk(e){return this.syncTo(e),this.string}get lineChunks(){return!0}read(e,t){let n=this.cursorPos-this.string.length;return e=this.cursorPos?this.doc.sliceString(e,t):this.string.slice(e-n,t-n)}}let zd=null;class Yg{constructor(e,t,n=[],s,a,r,o,c){this.parser=e,this.state=t,this.fragments=n,this.tree=s,this.treeLen=a,this.viewport=r,this.skipped=o,this.scheduleOn=c,this.parse=null,this.tempSkipped=[]}static create(e,t,n){return new Yg(e,t,[],Ri.empty,0,n,[],null)}startParse(){return this.parser.startParse(new gie(this.state.doc),this.fragments)}work(e,t){return t!=null&&t>=this.state.doc.length&&(t=void 0),this.tree!=Ri.empty&&this.isDone(t!=null?t:this.state.doc.length)?(this.takeTree(),!0):this.withContext(()=>{var n;if(typeof e=="number"){let s=Date.now()+e;e=()=>Date.now()>s}for(this.parse||(this.parse=this.startParse()),t!=null&&(this.parse.stoppedAt==null||this.parse.stoppedAt>t)&&t=this.treeLen&&((this.parse.stoppedAt==null||this.parse.stoppedAt>e)&&this.parse.stopAt(e),this.withContext(()=>{for(;!(t=this.parse.advance()););}),this.treeLen=e,this.tree=t,this.fragments=this.withoutTempSkipped(Rl.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(e){let t=zd;zd=this;try{return e()}finally{zd=t}}withoutTempSkipped(e){for(let t;t=this.tempSkipped.pop();)e=b3(e,t.from,t.to);return e}changes(e,t){let{fragments:n,tree:s,treeLen:a,viewport:r,skipped:o}=this;if(this.takeTree(),!e.empty){let c=[];if(e.iterChangedRanges((d,h,p,_)=>c.push({fromA:d,toA:h,fromB:p,toB:_})),n=Rl.applyChanges(n,c),s=Ri.empty,a=0,r={from:e.mapPos(r.from,-1),to:e.mapPos(r.to,1)},this.skipped.length){o=[];for(let d of this.skipped){let h=e.mapPos(d.from,1),p=e.mapPos(d.to,-1);he.from&&(this.fragments=b3(this.fragments,s,a),this.skipped.splice(n--,1))}return this.skipped.length>=t?!1:(this.reset(),!0)}reset(){this.parse&&(this.takeTree(),this.parse=null)}skipUntilInView(e,t){this.skipped.push({from:e,to:t})}static getSkippingParser(e){return new class extends w5{createParse(t,n,s){let a=s[0].from,r=s[s.length-1].to;return{parsedPos:a,advance(){let c=zd;if(c){for(let d of s)c.tempSkipped.push(d);e&&(c.scheduleOn=c.scheduleOn?Promise.all([c.scheduleOn,e]):e)}return this.parsedPos=r,new Ri(Yn.none,[],[],r-a)},stoppedAt:null,stopAt(){}}}}}isDone(e){e=Math.min(e,this.state.doc.length);let t=this.fragments;return this.treeLen>=e&&t.length&&t[0].from==0&&t[0].to>=e}static get(){return zd}}function b3(i,e,t){return Rl.applyChanges(i,[{fromA:e,toA:t,fromB:e,toB:t}])}class xu{constructor(e){this.context=e,this.tree=e.tree}apply(e){if(!e.docChanged&&this.tree==this.context.tree)return this;let t=this.context.changes(e.changes,e.state),n=this.context.treeLen==e.startState.doc.length?void 0:Math.max(e.changes.mapPos(this.context.treeLen),t.viewport.to);return t.work(20,n)||t.takeTree(),new xu(t)}static init(e){let t=Math.min(3e3,e.doc.length),n=Yg.create(e.facet(No).parser,e,{from:0,to:t});return n.work(20,t)||n.takeTree(),new xu(n)}}Js.state=an.define({create:xu.init,update(i,e){for(let t of e.effects)if(t.is(Js.setState))return t.value;return e.startState.facet(No)!=e.state.facet(No)?xu.init(e.state):i.apply(e)}});let O5=i=>{let e=setTimeout(()=>i(),500);return()=>clearTimeout(e)};typeof requestIdleCallback!="undefined"&&(O5=i=>{let e=-1,t=setTimeout(()=>{e=requestIdleCallback(i,{timeout:400})},100);return()=>e<0?clearTimeout(t):cancelIdleCallback(e)});const dx=typeof navigator!="undefined"&&(!((ux=navigator.scheduling)===null||ux===void 0)&&ux.isInputPending)?()=>navigator.scheduling.isInputPending():null,_ie=bi.fromClass(class{constructor(e){this.view=e,this.working=null,this.workScheduled=0,this.chunkEnd=-1,this.chunkBudget=-1,this.work=this.work.bind(this),this.scheduleWork()}update(e){let t=this.view.state.field(Js.state).context;(t.updateViewport(e.view.viewport)||this.view.viewport.to>t.treeLen)&&this.scheduleWork(),(e.docChanged||e.selectionSet)&&(this.view.hasFocus&&(this.chunkBudget+=50),this.scheduleWork()),this.checkAsyncSchedule(t)}scheduleWork(){if(this.working)return;let{state:e}=this.view,t=e.field(Js.state);(t.tree!=t.context.tree||!t.context.isDone(e.doc.length))&&(this.working=O5(this.work))}work(e){this.working=null;let t=Date.now();if(this.chunkEnds+1e3,c=a.context.work(()=>dx&&dx()||Date.now()>r,s+(o?0:1e5));this.chunkBudget-=Date.now()-t,(c||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:Js.setState.of(new xu(a.context))})),this.chunkBudget>0&&!(c&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(e){e.scheduleOn&&(this.workScheduled++,e.scheduleOn.then(()=>this.scheduleWork()).catch(t=>qn(this.view.state,t)).then(()=>this.workScheduled--),e.scheduleOn=null)}destroy(){this.working&&this.working()}isWorking(){return!!(this.working||this.workScheduled>0)}},{eventHandlers:{focus(){this.scheduleWork()}}}),No=Le.define({combine(i){return i.length?i[0]:null},enables:i=>[Js.state,_ie,Ne.contentAttributes.compute([i],e=>{let t=e.facet(i);return t&&t.name?{"data-language":t.name}:{}})]});class yie{constructor(e,t=[]){this.language=e,this.support=t,this.extension=[e,t]}}const xie=Le.define(),q0=Le.define({combine:i=>{if(!i.length)return" ";let e=i[0];if(!e||/\S/.test(e)||Array.from(e).some(t=>t!=e[0]))throw new Error("Invalid indent unit: "+JSON.stringify(i[0]));return e}});function Zg(i){let e=i.facet(q0);return e.charCodeAt(0)==9?i.tabSize*e.length:e.length}function Qh(i,e){let t="",n=i.tabSize,s=i.facet(q0)[0];if(s==" "){for(;e>=n;)t+=" ",e-=n;s=" "}for(let a=0;a=e?bie(i,t,e):null}class H0{constructor(e,t={}){this.state=e,this.options=t,this.unit=Zg(e)}lineAt(e,t=1){let n=this.state.doc.lineAt(e),{simulateBreak:s,simulateDoubleBreak:a}=this.options;return s!=null&&s>=n.from&&s<=n.to?a&&s==e?{text:"",from:e}:(t<0?s-1&&(a+=r-this.countColumn(n,n.search(/\S|$/))),a}countColumn(e,t=e.length){return Tu(e,this.state.tabSize,t)}lineIndent(e,t=1){let{text:n,from:s}=this.lineAt(e,t),a=this.options.overrideIndentation;if(a){let r=a(s);if(r>-1)return r}return this.countColumn(n,n.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const T5=new nt;function bie(i,e,t){let n=e.resolveStack(t),s=e.resolveInner(t,-1).resolve(t,0).enterUnfinishedNodesBefore(t);if(s!=n.node){let a=[];for(let r=s;r&&!(r.fromn.node.to||r.from==n.node.from&&r.type==n.node.type);r=r.parent)a.push(r);for(let r=a.length-1;r>=0;r--)n={node:a[r],next:n}}return M5(n,i,t)}function M5(i,e,t){for(let n=i;n;n=n.next){let s=Sie(n.node);if(s)return s(G2.create(e,t,n))}return 0}function vie(i){return i.pos==i.options.simulateBreak&&i.options.simulateDoubleBreak}function Sie(i){let e=i.type.prop(T5);if(e)return e;let t=i.firstChild,n;if(t&&(n=t.type.prop(nt.closedBy))){let s=i.lastChild,a=s&&n.indexOf(s.name)>-1;return r=>N5(r,!0,1,void 0,a&&!vie(r)?s.from:void 0)}return i.parent==null?wie:null}function wie(){return 0}class G2 extends H0{constructor(e,t,n){super(e.state,e.options),this.base=e,this.pos=t,this.context=n}get node(){return this.context.node}static create(e,t,n){return new G2(e,t,n)}get textAfter(){return this.textAfterPos(this.pos)}get baseIndent(){return this.baseIndentFor(this.node)}baseIndentFor(e){let t=this.state.doc.lineAt(e.from);for(;;){let n=e.resolve(t.from);for(;n.parent&&n.parent.from==n.from;)n=n.parent;if(kie(n,e))break;t=this.state.doc.lineAt(n.from)}return this.lineIndent(t.from)}continue(){return M5(this.context.next,this.base,this.pos)}}function kie(i,e){for(let t=e;t;t=t.parent)if(i==t)return!0;return!1}function Aie(i){let e=i.node,t=e.childAfter(e.from),n=e.lastChild;if(!t)return null;let s=i.options.simulateBreak,a=i.state.doc.lineAt(t.from),r=s==null||s<=a.from?a.to:Math.min(a.to,s);for(let o=t.to;;){let c=e.childAfter(o);if(!c||c==n)return null;if(!c.type.isSkipped){if(c.from>=r)return null;let d=/^ */.exec(a.text.slice(t.to-a.from))[0].length;return{from:t.from,to:t.to+d}}o=c.to}}function v3({closing:i,align:e=!0,units:t=1}){return n=>N5(n,e,t,i)}function N5(i,e,t,n,s){let a=i.textAfter,r=a.match(/^\s*/)[0].length,o=n&&a.slice(r,r+n.length)==n||s==i.pos+r,c=e?Aie(i):null;return c?o?i.column(c.from):i.column(c.to):i.baseIndent+(o?0:i.unit*t)}const Cie=200;function Oie(){return ut.transactionFilter.of(i=>{if(!i.docChanged||!i.isUserEvent("input.type")&&!i.isUserEvent("input.complete"))return i;let e=i.startState.languageDataAt("indentOnInput",i.startState.selection.main.head);if(!e.length)return i;let t=i.newDoc,{head:n}=i.newSelection.main,s=t.lineAt(n);if(n>s.from+Cie)return i;let a=t.sliceString(s.from,n);if(!e.some(d=>d.test(a)))return i;let{state:r}=i,o=-1,c=[];for(let{head:d}of r.selection.ranges){let h=r.doc.lineAt(d);if(h.from==o)continue;o=h.from;let p=X2(r,h.from);if(p==null)continue;let _=/^\s*/.exec(h.text)[0],y=Qh(r,p);_!=y&&c.push({from:h.from,to:h.from+_.length,insert:y})}return c.length?[i,{changes:c,sequential:!0}]:i})}const Tie=Le.define(),R5=new nt;function Mie(i){let e=i.firstChild,t=i.lastChild;return e&&e.tot)continue;if(a&&o.from=e&&d.to>t&&(a=d)}}return a}function Rie(i){let e=i.lastChild;return e&&e.to==i.to&&e.type.isError}function Jg(i,e,t){for(let n of i.facet(Tie)){let s=n(i,e,t);if(s)return s}return Nie(i,e,t)}function P5(i,e){let t=e.mapPos(i.from,1),n=e.mapPos(i.to,-1);return t>=n?void 0:{from:t,to:n}}const K0=Ze.define({map:P5}),Af=Ze.define({map:P5});function L5(i){let e=[];for(let{head:t}of i.state.selection.ranges)e.some(n=>n.from<=t&&n.to>=t)||e.push(i.lineBlockAt(t));return e}const zl=an.define({create(){return qe.none},update(i,e){e.isUserEvent("delete")&&e.changes.iterChangedRanges((t,n)=>i=S3(i,t,n)),i=i.map(e.changes);for(let t of e.effects)if(t.is(K0)&&!Pie(i,t.value.from,t.value.to)){let{preparePlaceholder:n}=e.state.facet(D5),s=n?qe.replace({widget:new Bie(n(e.state,t.value))}):w3;i=i.update({add:[s.range(t.value.from,t.value.to)]})}else t.is(Af)&&(i=i.update({filter:(n,s)=>t.value.from!=n||t.value.to!=s,filterFrom:t.value.from,filterTo:t.value.to}));return e.selection&&(i=S3(i,e.selection.main.head)),i},provide:i=>Ne.decorations.from(i),toJSON(i,e){let t=[];return i.between(0,e.doc.length,(n,s)=>{t.push(n,s)}),t},fromJSON(i){if(!Array.isArray(i)||i.length%2)throw new RangeError("Invalid JSON for fold state");let e=[];for(let t=0;t{se&&(n=!0)}),n?i.update({filterFrom:e,filterTo:t,filter:(s,a)=>s>=t||a<=e}):i}function $g(i,e,t){var n;let s=null;return(n=i.field(zl,!1))===null||n===void 0||n.between(e,t,(a,r)=>{(!s||s.from>a)&&(s={from:a,to:r})}),s}function Pie(i,e,t){let n=!1;return i.between(e,e,(s,a)=>{s==e&&a==t&&(n=!0)}),n}function j5(i,e){return i.field(zl,!1)?e:e.concat(Ze.appendConfig.of(U5()))}const Lie=i=>{for(let e of L5(i)){let t=Jg(i.state,e.from,e.to);if(t)return i.dispatch({effects:j5(i.state,[K0.of(t),E5(i,t)])}),!0}return!1},jie=i=>{if(!i.state.field(zl,!1))return!1;let e=[];for(let t of L5(i)){let n=$g(i.state,t.from,t.to);n&&e.push(Af.of(n),E5(i,n,!1))}return e.length&&i.dispatch({effects:e}),e.length>0};function E5(i,e,t=!0){let n=i.state.doc.lineAt(e.from).number,s=i.state.doc.lineAt(e.to).number;return Ne.announce.of(`${i.state.phrase(t?"Folded lines":"Unfolded lines")} ${n} ${i.state.phrase("to")} ${s}.`)}const Eie=i=>{let{state:e}=i,t=[];for(let n=0;n{let e=i.state.field(zl,!1);if(!e||!e.size)return!1;let t=[];return e.between(0,i.state.doc.length,(n,s)=>{t.push(Af.of({from:n,to:s}))}),i.dispatch({effects:t}),!0},Uie=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Lie},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:jie},{key:"Ctrl-Alt-[",run:Eie},{key:"Ctrl-Alt-]",run:Die}],Fie={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},D5=Le.define({combine(i){return Da(i,Fie)}});function U5(i){return[zl,Hie]}function F5(i,e){let{state:t}=i,n=t.facet(D5),s=r=>{let o=i.lineBlockAt(i.posAtDOM(r.target)),c=$g(i.state,o.from,o.to);c&&i.dispatch({effects:Af.of(c)}),r.preventDefault()};if(n.placeholderDOM)return n.placeholderDOM(i,s,e);let a=document.createElement("span");return a.textContent=n.placeholderText,a.setAttribute("aria-label",t.phrase("folded code")),a.title=t.phrase("unfold"),a.className="cm-foldPlaceholder",a.onclick=s,a}const w3=qe.replace({widget:new class extends Ar{toDOM(i){return F5(i,null)}}});class Bie extends Ar{constructor(e){super(),this.value=e}eq(e){return this.value==e.value}toDOM(e){return F5(e,this.value)}}const zie={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class hx extends wr{constructor(e,t){super(),this.config=e,this.open=t}eq(e){return this.config==e.config&&this.open==e.open}toDOM(e){if(this.config.markerDOM)return this.config.markerDOM(this.open);let t=document.createElement("span");return t.textContent=this.open?this.config.openText:this.config.closedText,t.title=e.state.phrase(this.open?"Fold line":"Unfold line"),t}}function qie(i={}){let e=z(z({},zie),i),t=new hx(e,!0),n=new hx(e,!1),s=bi.fromClass(class{constructor(r){this.from=r.viewport.from,this.markers=this.buildMarkers(r)}update(r){(r.docChanged||r.viewportChanged||r.startState.facet(No)!=r.state.facet(No)||r.startState.field(zl,!1)!=r.state.field(zl,!1)||gn(r.startState)!=gn(r.state)||e.foldingChanged(r))&&(this.markers=this.buildMarkers(r.view))}buildMarkers(r){let o=new vr;for(let c of r.viewportLineBlocks){let d=$g(r.state,c.from,c.to)?n:Jg(r.state,c.from,c.to)?t:null;d&&o.add(c.from,c.from,d)}return o.finish()}}),{domEventHandlers:a}=e;return[s,Hte({class:"cm-foldGutter",markers(r){var o;return((o=r.plugin(s))===null||o===void 0?void 0:o.markers)||mt.empty},initialSpacer(){return new hx(e,!1)},domEventHandlers:ee(z({},a),{click:(r,o,c)=>{if(a.click&&a.click(r,o,c))return!0;let d=$g(r.state,o.from,o.to);if(d)return r.dispatch({effects:Af.of(d)}),!0;let h=Jg(r.state,o.from,o.to);return h?(r.dispatch({effects:K0.of(h)}),!0):!1}})}),U5()]}const Hie=Ne.baseTheme({".cm-foldPlaceholder":{backgroundColor:"#eee",border:"1px solid #ddd",color:"#888",borderRadius:".2em",margin:"0 1px",padding:"0 1px",cursor:"pointer"},".cm-foldGutter span":{padding:"0 1px",cursor:"pointer"}});class Cf{constructor(e,t){this.specs=e;let n;function s(o){let c=Co.newName();return(n||(n=Object.create(null)))["."+c]=o,c}const a=typeof t.all=="string"?t.all:t.all?s(t.all):void 0,r=t.scope;this.scope=r instanceof Js?o=>o.prop(Vc)==r.data:r?o=>o==r:void 0,this.style=C5(e.map(o=>({tag:o.tag,class:o.class||s(Object.assign({},o,{tag:null}))})),{all:a}).style,this.module=n?new Co(n):null,this.themeType=t.themeType}static define(e,t){return new Cf(e,t||{})}}const cv=Le.define(),B5=Le.define({combine(i){return i.length?[i[0]]:null}});function fx(i){let e=i.facet(cv);return e.length?e:i.facet(B5)}function z5(i,e){let t=[Vie],n;return i instanceof Cf&&(i.module&&t.push(Ne.styleModule.of(i.module)),n=i.themeType),e!=null&&e.fallback?t.push(B5.of(i)):n?t.push(cv.computeN([Ne.darkTheme],s=>s.facet(Ne.darkTheme)==(n=="dark")?[i]:[])):t.push(cv.of(i)),t}class Kie{constructor(e){this.markCache=Object.create(null),this.tree=gn(e.state),this.decorations=this.buildDeco(e,fx(e.state)),this.decoratedTo=e.viewport.to}update(e){let t=gn(e.state),n=fx(e.state),s=n!=fx(e.startState),{viewport:a}=e.view,r=e.changes.mapPos(this.decoratedTo,1);t.length=a.to?(this.decorations=this.decorations.map(e.changes),this.decoratedTo=r):(t!=this.tree||e.viewportChanged||s)&&(this.tree=t,this.decorations=this.buildDeco(e.view,n),this.decoratedTo=a.to)}buildDeco(e,t){if(!t||!this.tree.length)return qe.none;let n=new vr;for(let{from:s,to:a}of e.visibleRanges)die(this.tree,t,(r,o,c)=>{n.add(r,o,this.markCache[c]||(this.markCache[c]=qe.mark({class:c})))},s,a);return n.finish()}}const Vie=Wl.high(bi.fromClass(Kie,{decorations:i=>i.decorations})),Iie=Cf.define([{tag:le.meta,color:"#404740"},{tag:le.link,textDecoration:"underline"},{tag:le.heading,textDecoration:"underline",fontWeight:"bold"},{tag:le.emphasis,fontStyle:"italic"},{tag:le.strong,fontWeight:"bold"},{tag:le.strikethrough,textDecoration:"line-through"},{tag:le.keyword,color:"#708"},{tag:[le.atom,le.bool,le.url,le.contentSeparator,le.labelName],color:"#219"},{tag:[le.literal,le.inserted],color:"#164"},{tag:[le.string,le.deleted],color:"#a11"},{tag:[le.regexp,le.escape,le.special(le.string)],color:"#e40"},{tag:le.definition(le.variableName),color:"#00f"},{tag:le.local(le.variableName),color:"#30a"},{tag:[le.typeName,le.namespace],color:"#085"},{tag:le.className,color:"#167"},{tag:[le.special(le.variableName),le.macroName],color:"#256"},{tag:le.definition(le.propertyName),color:"#00c"},{tag:le.comment,color:"#940"},{tag:le.invalid,color:"#f00"}]),Wie=Ne.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),q5=1e4,H5="()[]{}",K5=Le.define({combine(i){return Da(i,{afterCursor:!0,brackets:H5,maxScanDistance:q5,renderMatch:Qie})}}),Xie=qe.mark({class:"cm-matchingBracket"}),Gie=qe.mark({class:"cm-nonmatchingBracket"});function Qie(i){let e=[],t=i.matched?Xie:Gie;return e.push(t.range(i.start.from,i.start.to)),i.end&&e.push(t.range(i.end.from,i.end.to)),e}const Yie=an.define({create(){return qe.none},update(i,e){if(!e.docChanged&&!e.selection)return i;let t=[],n=e.state.facet(K5);for(let s of e.state.selection.ranges){if(!s.empty)continue;let a=Ma(e.state,s.head,-1,n)||s.head>0&&Ma(e.state,s.head-1,1,n)||n.afterCursor&&(Ma(e.state,s.head,1,n)||s.headNe.decorations.from(i)}),Zie=[Yie,Wie];function Jie(i={}){return[K5.of(i),Zie]}const $ie=new nt;function uv(i,e,t){let n=i.prop(e<0?nt.openedBy:nt.closedBy);if(n)return n;if(i.name.length==1){let s=t.indexOf(i.name);if(s>-1&&s%2==(e<0?1:0))return[t[s+e]]}return null}function dv(i){let e=i.type.prop($ie);return e?e(i.node):i}function Ma(i,e,t,n={}){let s=n.maxScanDistance||q5,a=n.brackets||H5,r=gn(i),o=r.resolveInner(e,t);for(let c=o;c;c=c.parent){let d=uv(c.type,t,a);if(d&&c.from0?e>=h.from&&eh.from&&e<=h.to))return ene(i,e,t,c,h,d,a)}}return tne(i,e,t,r,o.type,s,a)}function ene(i,e,t,n,s,a,r){let o=n.parent,c={from:s.from,to:s.to},d=0,h=o==null?void 0:o.cursor();if(h&&(t<0?h.childBefore(n.from):h.childAfter(n.to)))do if(t<0?h.to<=n.from:h.from>=n.to){if(d==0&&a.indexOf(h.type.name)>-1&&h.from0)return null;let d={from:t<0?e-1:e,to:t>0?e+1:e},h=i.doc.iterRange(e,t>0?i.doc.length:0),p=0;for(let _=0;!h.next().done&&_<=a;){let y=h.value;t<0&&(_+=y.length);let x=e+_*t;for(let v=t>0?0:y.length-1,w=t>0?y.length:-1;v!=w;v+=t){let k=r.indexOf(y[v]);if(!(k<0||n.resolveInner(x+v,1).type!=s))if(k%2==0==t>0)p++;else{if(p==1)return{start:d,end:{from:x+v,to:x+v+1},matched:k>>1==c>>1};p--}}t>0&&(_+=y.length)}return h.done?{start:d,matched:!1}:null}const ine=Object.create(null),k3=[Yn.none],A3=[],C3=Object.create(null),nne=Object.create(null);for(let[i,e]of[["variable","variableName"],["variable-2","variableName.special"],["string-2","string.special"],["def","variableName.definition"],["tag","tagName"],["attribute","attributeName"],["type","typeName"],["builtin","variableName.standard"],["qualifier","modifier"],["error","invalid"],["header","heading"],["property","propertyName"]])nne[i]=sne(ine,e);function px(i,e){A3.indexOf(i)>-1||(A3.push(i),console.warn(e))}function sne(i,e){let t=[];for(let o of e.split(" ")){let c=[];for(let d of o.split(".")){let h=i[d]||le[d];h?typeof h=="function"?c.length?c=c.map(h):px(d,`Modifier ${d} used at start of tag`):c.length?px(d,`Tag ${d} used as modifier`):c=Array.isArray(h)?h:[h]:px(d,`Unknown highlighting tag ${d}`)}for(let d of c)t.push(d)}if(!t.length)return 0;let n=e.replace(/ /g,"_"),s=n+" "+t.map(o=>o.id),a=C3[s];if(a)return a.id;let r=C3[s]=Yn.define({id:k3.length,name:n,props:[k5({[n]:t})]});return k3.push(r),r.id}Zt.RTL,Zt.LTR;const ane=i=>{let{state:e}=i,t=e.doc.lineAt(e.selection.main.from),n=Y2(i.state,t.from);return n.line?rne(i):n.block?lne(i):!1};function Q2(i,e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let s=i(e,t);return s?(n(t.update(s)),!0):!1}}const rne=Q2(dne,0),one=Q2(V5,0),lne=Q2((i,e)=>V5(i,e,une(e)),0);function Y2(i,e){let t=i.languageDataAt("commentTokens",e,1);return t.length?t[0]:{}}const qd=50;function cne(i,{open:e,close:t},n,s){let a=i.sliceDoc(n-qd,n),r=i.sliceDoc(s,s+qd),o=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(r)[0].length,d=a.length-o;if(a.slice(d-e.length,d)==e&&r.slice(c,c+t.length)==t)return{open:{pos:n-o,margin:o&&1},close:{pos:s+c,margin:c&&1}};let h,p;s-n<=2*qd?h=p=i.sliceDoc(n,s):(h=i.sliceDoc(n,n+qd),p=i.sliceDoc(s-qd,s));let _=/^\s*/.exec(h)[0].length,y=/\s*$/.exec(p)[0].length,x=p.length-y-t.length;return h.slice(_,_+e.length)==e&&p.slice(x,x+t.length)==t?{open:{pos:n+_+e.length,margin:/\s/.test(h.charAt(_+e.length))?1:0},close:{pos:s-y-t.length,margin:/\s/.test(p.charAt(x-1))?1:0}}:null}function une(i){let e=[];for(let t of i.selection.ranges){let n=i.doc.lineAt(t.from),s=t.to<=n.to?n:i.doc.lineAt(t.to);s.from>n.from&&s.from==t.to&&(s=t.to==n.to+1?n:i.doc.lineAt(t.to-1));let a=e.length-1;a>=0&&e[a].to>n.from?e[a].to=s.to:e.push({from:n.from+/^\s*/.exec(n.text)[0].length,to:s.to})}return e}function V5(i,e,t=e.selection.ranges){let n=t.map(a=>Y2(e,a.from).block);if(!n.every(a=>a))return null;let s=t.map((a,r)=>cne(e,n[r],a.from,a.to));if(i!=2&&!s.every(a=>a))return{changes:e.changes(t.map((a,r)=>s[r]?[]:[{from:a.from,insert:n[r].open+" "},{from:a.to,insert:" "+n[r].close}]))};if(i!=1&&s.some(a=>a)){let a=[];for(let r=0,o;rs&&(a==r||r>p.from)){s=p.from;let _=/^\s*/.exec(p.text)[0].length,y=_==p.length,x=p.text.slice(_,_+d.length)==d?_:-1;_a.comment<0&&(!a.empty||a.single))){let a=[];for(let{line:o,token:c,indent:d,empty:h,single:p}of n)(p||!h)&&a.push({from:o.from+d,insert:c+" "});let r=e.changes(a);return{changes:r,selection:e.selection.map(r,1)}}else if(i!=1&&n.some(a=>a.comment>=0)){let a=[];for(let{line:r,comment:o,token:c}of n)if(o>=0){let d=r.from+o,h=d+c.length;r.text[h-r.from]==" "&&h++,a.push({from:d,to:h})}return{changes:a}}return null}const hv=Ea.define(),hne=Ea.define(),fne=Le.define(),I5=Le.define({combine(i){return Da(i,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,s)=>e(n,s)||t(n,s)})}}),W5=an.define({create(){return Na.empty},update(i,e){let t=e.state.facet(I5),n=e.annotation(hv);if(n){let c=Hn.fromTransaction(e,n.selection),d=n.side,h=d==0?i.undone:i.done;return c?h=e0(h,h.length,t.minDepth,c):h=Q5(h,e.startState.selection),new Na(d==0?n.rest:h,d==0?h:n.rest)}let s=e.annotation(hne);if((s=="full"||s=="before")&&(i=i.isolate()),e.annotation(Fi.addToHistory)===!1)return e.changes.empty?i:i.addMapping(e.changes.desc);let a=Hn.fromTransaction(e),r=e.annotation(Fi.time),o=e.annotation(Fi.userEvent);return a?i=i.addChanges(a,r,o,t,e):e.selection&&(i=i.addSelection(e.startState.selection,r,o,t.newGroupDelay)),(s=="full"||s=="after")&&(i=i.isolate()),i},toJSON(i){return{done:i.done.map(e=>e.toJSON()),undone:i.undone.map(e=>e.toJSON())}},fromJSON(i){return new Na(i.done.map(Hn.fromJSON),i.undone.map(Hn.fromJSON))}});function pne(i={}){return[W5,I5.of(i),Ne.domEventHandlers({beforeinput(e,t){let n=e.inputType=="historyUndo"?X5:e.inputType=="historyRedo"?fv:null;return n?(e.preventDefault(),n(t)):!1}})]}function V0(i,e){return function({state:t,dispatch:n}){if(!e&&t.readOnly)return!1;let s=t.field(W5,!1);if(!s)return!1;let a=s.pop(i,t,e);return a?(n(a),!0):!1}}const X5=V0(0,!1),fv=V0(1,!1),mne=V0(0,!0),gne=V0(1,!0);class Hn{constructor(e,t,n,s,a){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=s,this.selectionsAfter=a}setSelAfter(e){return new Hn(this.changes,this.effects,this.mapped,this.startSelection,e)}toJSON(){var e,t,n;return{changes:(e=this.changes)===null||e===void 0?void 0:e.toJSON(),mapped:(t=this.mapped)===null||t===void 0?void 0:t.toJSON(),startSelection:(n=this.startSelection)===null||n===void 0?void 0:n.toJSON(),selectionsAfter:this.selectionsAfter.map(s=>s.toJSON())}}static fromJSON(e){return new Hn(e.changes&&Di.fromJSON(e.changes),[],e.mapped&&Ra.fromJSON(e.mapped),e.startSelection&&xe.fromJSON(e.startSelection),e.selectionsAfter.map(xe.fromJSON))}static fromTransaction(e,t){let n=Us;for(let s of e.startState.facet(fne)){let a=s(e);a.length&&(n=n.concat(a))}return!n.length&&e.changes.empty?null:new Hn(e.changes.invert(e.startState.doc),n,void 0,t||e.startState.selection,Us)}static selection(e){return new Hn(void 0,Us,void 0,void 0,e)}}function e0(i,e,t,n){let s=e+1>t+20?e-t-1:0,a=i.slice(s,e);return a.push(n),a}function _ne(i,e){let t=[],n=!1;return i.iterChangedRanges((s,a)=>t.push(s,a)),e.iterChangedRanges((s,a,r,o)=>{for(let c=0;c=d&&r<=h&&(n=!0)}}),n}function yne(i,e){return i.ranges.length==e.ranges.length&&i.ranges.filter((t,n)=>t.empty!=e.ranges[n].empty).length===0}function G5(i,e){return i.length?e.length?i.concat(e):i:e}const Us=[],xne=200;function Q5(i,e){if(i.length){let t=i[i.length-1],n=t.selectionsAfter.slice(Math.max(0,t.selectionsAfter.length-xne));return n.length&&n[n.length-1].eq(e)?i:(n.push(e),e0(i,i.length-1,1e9,t.setSelAfter(n)))}else return[Hn.selection([e])]}function bne(i){let e=i[i.length-1],t=i.slice();return t[i.length-1]=e.setSelAfter(e.selectionsAfter.slice(0,e.selectionsAfter.length-1)),t}function mx(i,e){if(!i.length)return i;let t=i.length,n=Us;for(;t;){let s=vne(i[t-1],e,n);if(s.changes&&!s.changes.empty||s.effects.length){let a=i.slice(0,t);return a[t-1]=s,a}else e=s.mapped,t--,n=s.selectionsAfter}return n.length?[Hn.selection(n)]:Us}function vne(i,e,t){let n=G5(i.selectionsAfter.length?i.selectionsAfter.map(o=>o.map(e)):Us,t);if(!i.changes)return Hn.selection(n);let s=i.changes.map(e),a=e.mapDesc(i.changes,!0),r=i.mapped?i.mapped.composeDesc(a):a;return new Hn(s,Ze.mapEffects(i.effects,e),r,i.startSelection.map(a),n)}const Sne=/^(input\.type|delete)($|\.)/;class Na{constructor(e,t,n=0,s=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=s}isolate(){return this.prevTime?new Na(this.done,this.undone):this}addChanges(e,t,n,s,a){let r=this.done,o=r[r.length-1];return o&&o.changes&&!o.changes.empty&&e.changes&&(!n||Sne.test(n))&&(!o.selectionsAfter.length&&t-this.prevTime0&&t-this.prevTimet.empty?i.moveByChar(t,e):I0(t,e))}function yn(i){return i.textDirectionAt(i.state.selection.main.head)==Zt.LTR}const Z5=i=>Y5(i,!yn(i)),J5=i=>Y5(i,yn(i));function $5(i,e){return sa(i,t=>t.empty?i.moveByGroup(t,e):I0(t,e))}const kne=i=>$5(i,!yn(i)),Ane=i=>$5(i,yn(i));function Cne(i,e,t){if(e.type.prop(t))return!0;let n=e.to-e.from;return n&&(n>2||/[^\s,.;:]/.test(i.sliceDoc(e.from,e.to)))||e.firstChild}function W0(i,e,t){let n=gn(i).resolveInner(e.head),s=t?nt.closedBy:nt.openedBy;for(let c=e.head;;){let d=t?n.childAfter(c):n.childBefore(c);if(!d)break;Cne(i,d,s)?n=d:c=t?d.to:d.from}let a=n.type.prop(s),r,o;return a&&(r=t?Ma(i,n.from,1):Ma(i,n.to,-1))&&r.matched?o=t?r.end.to:r.end.from:o=t?n.to:n.from,xe.cursor(o,t?-1:1)}const One=i=>sa(i,e=>W0(i.state,e,!yn(i))),Tne=i=>sa(i,e=>W0(i.state,e,yn(i)));function ej(i,e){return sa(i,t=>{if(!t.empty)return I0(t,e);let n=i.moveVertically(t,e);return n.head!=t.head?n:i.moveToLineBoundary(t,e)})}const tj=i=>ej(i,!1),ij=i=>ej(i,!0);function nj(i){let e=i.scrollDOM.clientHeightr.empty?i.moveVertically(r,e,t.height):I0(r,e));if(s.eq(n.selection))return!1;let a;if(t.selfScroll){let r=i.coordsAtPos(n.selection.main.head),o=i.scrollDOM.getBoundingClientRect(),c=o.top+t.marginTop,d=o.bottom-t.marginBottom;r&&r.top>c&&r.bottomsj(i,!1),pv=i=>sj(i,!0);function Lo(i,e,t){let n=i.lineBlockAt(e.head),s=i.moveToLineBoundary(e,t);if(s.head==e.head&&s.head!=(t?n.to:n.from)&&(s=i.moveToLineBoundary(e,t,!1)),!t&&s.head==n.from&&n.length){let a=/^\s*/.exec(i.state.sliceDoc(n.from,Math.min(n.from+100,n.to)))[0].length;a&&e.head!=n.from+a&&(s=xe.cursor(n.from+a))}return s}const Mne=i=>sa(i,e=>Lo(i,e,!0)),Nne=i=>sa(i,e=>Lo(i,e,!1)),Rne=i=>sa(i,e=>Lo(i,e,!yn(i))),Pne=i=>sa(i,e=>Lo(i,e,yn(i))),Lne=i=>sa(i,e=>xe.cursor(i.lineBlockAt(e.head).from,1)),jne=i=>sa(i,e=>xe.cursor(i.lineBlockAt(e.head).to,-1));function Ene(i,e,t){let n=!1,s=Mu(i.selection,a=>{let r=Ma(i,a.head,-1)||Ma(i,a.head,1)||a.head>0&&Ma(i,a.head-1,1)||a.headEne(i,e);function Is(i,e){let t=Mu(i.state.selection,n=>{let s=e(n);return xe.range(n.anchor,s.head,s.goalColumn,s.bidiLevel||void 0)});return t.eq(i.state.selection)?!1:(i.dispatch(na(i.state,t)),!0)}function aj(i,e){return Is(i,t=>i.moveByChar(t,e))}const rj=i=>aj(i,!yn(i)),oj=i=>aj(i,yn(i));function lj(i,e){return Is(i,t=>i.moveByGroup(t,e))}const Une=i=>lj(i,!yn(i)),Fne=i=>lj(i,yn(i)),Bne=i=>Is(i,e=>W0(i.state,e,!yn(i))),zne=i=>Is(i,e=>W0(i.state,e,yn(i)));function cj(i,e){return Is(i,t=>i.moveVertically(t,e))}const uj=i=>cj(i,!1),dj=i=>cj(i,!0);function hj(i,e){return Is(i,t=>i.moveVertically(t,e,nj(i).height))}const T3=i=>hj(i,!1),M3=i=>hj(i,!0),qne=i=>Is(i,e=>Lo(i,e,!0)),Hne=i=>Is(i,e=>Lo(i,e,!1)),Kne=i=>Is(i,e=>Lo(i,e,!yn(i))),Vne=i=>Is(i,e=>Lo(i,e,yn(i))),Ine=i=>Is(i,e=>xe.cursor(i.lineBlockAt(e.head).from)),Wne=i=>Is(i,e=>xe.cursor(i.lineBlockAt(e.head).to)),N3=({state:i,dispatch:e})=>(e(na(i,{anchor:0})),!0),R3=({state:i,dispatch:e})=>(e(na(i,{anchor:i.doc.length})),!0),P3=({state:i,dispatch:e})=>(e(na(i,{anchor:i.selection.main.anchor,head:0})),!0),L3=({state:i,dispatch:e})=>(e(na(i,{anchor:i.selection.main.anchor,head:i.doc.length})),!0),Xne=({state:i,dispatch:e})=>(e(i.update({selection:{anchor:0,head:i.doc.length},userEvent:"select"})),!0),Gne=({state:i,dispatch:e})=>{let t=X0(i).map(({from:n,to:s})=>xe.range(n,Math.min(s+1,i.doc.length)));return e(i.update({selection:xe.create(t),userEvent:"select"})),!0},Qne=({state:i,dispatch:e})=>{let t=Mu(i.selection,n=>{let s=gn(i),a=s.resolveStack(n.from,1);if(n.empty){let r=s.resolveStack(n.from,-1);r.node.from>=a.node.from&&r.node.to<=a.node.to&&(a=r)}for(let r=a;r;r=r.next){let{node:o}=r;if((o.from=n.to||o.to>n.to&&o.from<=n.from)&&r.next)return xe.range(o.to,o.from)}return n});return t.eq(i.selection)?!1:(e(na(i,t)),!0)};function fj(i,e){let{state:t}=i,n=t.selection,s=t.selection.ranges.slice();for(let a of t.selection.ranges){let r=t.doc.lineAt(a.head);if(e?r.to0)for(let o=a;;){let c=i.moveVertically(o,e);if(c.headr.to){s.some(d=>d.head==c.head)||s.push(c);break}else{if(c.head==o.head)break;o=c}}}return s.length==n.ranges.length?!1:(i.dispatch(na(t,xe.create(s,s.length-1))),!0)}const Yne=i=>fj(i,!1),Zne=i=>fj(i,!0),Jne=({state:i,dispatch:e})=>{let t=i.selection,n=null;return t.ranges.length>1?n=xe.create([t.main]):t.main.empty||(n=xe.create([xe.cursor(t.main.head)])),n?(e(na(i,n)),!0):!1};function Of(i,e){if(i.state.readOnly)return!1;let t="delete.selection",{state:n}=i,s=n.changeByRange(a=>{let{from:r,to:o}=a;if(r==o){let c=e(a);cr&&(t="delete.forward",c=Um(i,c,!0)),r=Math.min(r,c),o=Math.max(o,c)}else r=Um(i,r,!1),o=Um(i,o,!0);return r==o?{range:a}:{changes:{from:r,to:o},range:xe.cursor(r,rs(i)))n.between(e,e,(s,a)=>{se&&(e=t?a:s)});return e}const pj=(i,e,t)=>Of(i,n=>{let s=n.from,{state:a}=i,r=a.doc.lineAt(s),o,c;if(t&&!e&&s>r.from&&spj(i,!1,!0),mj=i=>pj(i,!0,!1),gj=(i,e)=>Of(i,t=>{let n=t.head,{state:s}=i,a=s.doc.lineAt(n),r=s.charCategorizer(n);for(let o=null;;){if(n==(e?a.to:a.from)){n==t.head&&a.number!=(e?s.doc.lines:1)&&(n+=e?1:-1);break}let c=tn(a.text,n-a.from,e)+a.from,d=a.text.slice(Math.min(n,c)-a.from,Math.max(n,c)-a.from),h=r(d);if(o!=null&&h!=o)break;(d!=" "||n!=t.head)&&(o=h),n=c}return n}),_j=i=>gj(i,!1),$ne=i=>gj(i,!0),ese=i=>Of(i,e=>{let t=i.lineBlockAt(e.head).to;return e.headOf(i,e=>{let t=i.moveToLineBoundary(e,!1).head;return e.head>t?t:Math.max(0,e.head-1)}),ise=i=>Of(i,e=>{let t=i.moveToLineBoundary(e,!0).head;return e.head{if(i.readOnly)return!1;let t=i.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:gt.of(["",""])},range:xe.cursor(n.from)}));return e(i.update(t,{scrollIntoView:!0,userEvent:"input"})),!0},sse=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=i.changeByRange(n=>{if(!n.empty||n.from==0||n.from==i.doc.length)return{range:n};let s=n.from,a=i.doc.lineAt(s),r=s==a.from?s-1:tn(a.text,s-a.from,!1)+a.from,o=s==a.to?s+1:tn(a.text,s-a.from,!0)+a.from;return{changes:{from:r,to:o,insert:i.doc.slice(s,o).append(i.doc.slice(r,s))},range:xe.cursor(o)}});return t.changes.empty?!1:(e(i.update(t,{scrollIntoView:!0,userEvent:"move.character"})),!0)};function X0(i){let e=[],t=-1;for(let n of i.selection.ranges){let s=i.doc.lineAt(n.from),a=i.doc.lineAt(n.to);if(!n.empty&&n.to==a.from&&(a=i.doc.lineAt(n.to-1)),t>=s.number){let r=e[e.length-1];r.to=a.to,r.ranges.push(n)}else e.push({from:s.from,to:a.to,ranges:[n]});t=a.number+1}return e}function yj(i,e,t){if(i.readOnly)return!1;let n=[],s=[];for(let a of X0(i)){if(t?a.to==i.doc.length:a.from==0)continue;let r=i.doc.lineAt(t?a.to+1:a.from-1),o=r.length+1;if(t){n.push({from:a.to,to:r.to},{from:a.from,insert:r.text+i.lineBreak});for(let c of a.ranges)s.push(xe.range(Math.min(i.doc.length,c.anchor+o),Math.min(i.doc.length,c.head+o)))}else{n.push({from:r.from,to:a.from},{from:a.to,insert:i.lineBreak+r.text});for(let c of a.ranges)s.push(xe.range(c.anchor-o,c.head-o))}}return n.length?(e(i.update({changes:n,scrollIntoView:!0,selection:xe.create(s,i.selection.mainIndex),userEvent:"move.line"})),!0):!1}const ase=({state:i,dispatch:e})=>yj(i,e,!1),rse=({state:i,dispatch:e})=>yj(i,e,!0);function xj(i,e,t){if(i.readOnly)return!1;let n=[];for(let s of X0(i))t?n.push({from:s.from,insert:i.doc.slice(s.from,s.to)+i.lineBreak}):n.push({from:s.to,insert:i.lineBreak+i.doc.slice(s.from,s.to)});return e(i.update({changes:n,scrollIntoView:!0,userEvent:"input.copyline"})),!0}const ose=({state:i,dispatch:e})=>xj(i,e,!1),lse=({state:i,dispatch:e})=>xj(i,e,!0),cse=i=>{if(i.state.readOnly)return!1;let{state:e}=i,t=e.changes(X0(e).map(({from:s,to:a})=>(s>0?s--:a{let a;if(i.lineWrapping){let r=i.lineBlockAt(s.head),o=i.coordsAtPos(s.head,s.assoc||1);o&&(a=r.bottom+i.documentTop-o.bottom+i.defaultLineHeight/2)}return i.moveVertically(s,!0,a)}).map(t);return i.dispatch({changes:t,selection:n,scrollIntoView:!0,userEvent:"delete.line"}),!0};function use(i,e){if(/\(\)|\[\]|\{\}/.test(i.sliceDoc(e-1,e+1)))return{from:e,to:e};let t=gn(i).resolveInner(e),n=t.childBefore(e),s=t.childAfter(e),a;return n&&s&&n.to<=e&&s.from>=e&&(a=n.type.prop(nt.closedBy))&&a.indexOf(s.name)>-1&&i.doc.lineAt(n.to).from==i.doc.lineAt(s.from).from&&!/\S/.test(i.sliceDoc(n.to,s.from))?{from:n.to,to:s.from}:null}const j3=bj(!1),dse=bj(!0);function bj(i){return({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(s=>{let{from:a,to:r}=s,o=e.doc.lineAt(a),c=!i&&a==r&&use(e,a);i&&(a=r=(r<=o.to?o:e.doc.lineAt(r)).to);let d=new H0(e,{simulateBreak:a,simulateDoubleBreak:!!c}),h=X2(d,a);for(h==null&&(h=Tu(/^\s*/.exec(e.doc.lineAt(a).text)[0],e.tabSize));ro.from&&a{let s=[];for(let r=n.from;r<=n.to;){let o=i.doc.lineAt(r);o.number>t&&(n.empty||n.to>o.from)&&(e(o,s,n),t=o.number),r=o.to+1}let a=i.changes(s);return{changes:s,range:xe.range(a.mapPos(n.anchor,1),a.mapPos(n.head,1))}})}const hse=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let t=Object.create(null),n=new H0(i,{overrideIndentation:a=>{let r=t[a];return r==null?-1:r}}),s=Z2(i,(a,r,o)=>{let c=X2(n,a.from);if(c==null)return;/\S/.test(a.text)||(c=0);let d=/^\s*/.exec(a.text)[0],h=Qh(i,c);(d!=h||o.fromi.readOnly?!1:(e(i.update(Z2(i,(t,n)=>{n.push({from:t.from,insert:i.facet(q0)})}),{userEvent:"input.indent"})),!0),Sj=({state:i,dispatch:e})=>i.readOnly?!1:(e(i.update(Z2(i,(t,n)=>{let s=/^\s*/.exec(t.text)[0];if(!s)return;let a=Tu(s,i.tabSize),r=0,o=Qh(i,Math.max(0,a-Zg(i)));for(;r(i.setTabFocusMode(),!0),pse=[{key:"Ctrl-b",run:Z5,shift:rj,preventDefault:!0},{key:"Ctrl-f",run:J5,shift:oj},{key:"Ctrl-p",run:tj,shift:uj},{key:"Ctrl-n",run:ij,shift:dj},{key:"Ctrl-a",run:Lne,shift:Ine},{key:"Ctrl-e",run:jne,shift:Wne},{key:"Ctrl-d",run:mj},{key:"Ctrl-h",run:mv},{key:"Ctrl-k",run:ese},{key:"Ctrl-Alt-h",run:_j},{key:"Ctrl-o",run:nse},{key:"Ctrl-t",run:sse},{key:"Ctrl-v",run:pv}],mse=[{key:"ArrowLeft",run:Z5,shift:rj,preventDefault:!0},{key:"Mod-ArrowLeft",mac:"Alt-ArrowLeft",run:kne,shift:Une,preventDefault:!0},{mac:"Cmd-ArrowLeft",run:Rne,shift:Kne,preventDefault:!0},{key:"ArrowRight",run:J5,shift:oj,preventDefault:!0},{key:"Mod-ArrowRight",mac:"Alt-ArrowRight",run:Ane,shift:Fne,preventDefault:!0},{mac:"Cmd-ArrowRight",run:Pne,shift:Vne,preventDefault:!0},{key:"ArrowUp",run:tj,shift:uj,preventDefault:!0},{mac:"Cmd-ArrowUp",run:N3,shift:P3},{mac:"Ctrl-ArrowUp",run:O3,shift:T3},{key:"ArrowDown",run:ij,shift:dj,preventDefault:!0},{mac:"Cmd-ArrowDown",run:R3,shift:L3},{mac:"Ctrl-ArrowDown",run:pv,shift:M3},{key:"PageUp",run:O3,shift:T3},{key:"PageDown",run:pv,shift:M3},{key:"Home",run:Nne,shift:Hne,preventDefault:!0},{key:"Mod-Home",run:N3,shift:P3},{key:"End",run:Mne,shift:qne,preventDefault:!0},{key:"Mod-End",run:R3,shift:L3},{key:"Enter",run:j3,shift:j3},{key:"Mod-a",run:Xne},{key:"Backspace",run:mv,shift:mv,preventDefault:!0},{key:"Delete",run:mj,preventDefault:!0},{key:"Mod-Backspace",mac:"Alt-Backspace",run:_j,preventDefault:!0},{key:"Mod-Delete",mac:"Alt-Delete",run:$ne,preventDefault:!0},{mac:"Mod-Backspace",run:tse,preventDefault:!0},{mac:"Mod-Delete",run:ise,preventDefault:!0}].concat(pse.map(i=>({mac:i.key,run:i.run,shift:i.shift}))),gse=[{key:"Alt-ArrowLeft",mac:"Ctrl-ArrowLeft",run:One,shift:Bne},{key:"Alt-ArrowRight",mac:"Ctrl-ArrowRight",run:Tne,shift:zne},{key:"Alt-ArrowUp",run:ase},{key:"Shift-Alt-ArrowUp",run:ose},{key:"Alt-ArrowDown",run:rse},{key:"Shift-Alt-ArrowDown",run:lse},{key:"Mod-Alt-ArrowUp",run:Yne},{key:"Mod-Alt-ArrowDown",run:Zne},{key:"Escape",run:Jne},{key:"Mod-Enter",run:dse},{key:"Alt-l",mac:"Ctrl-l",run:Gne},{key:"Mod-i",run:Qne,preventDefault:!0},{key:"Mod-[",run:Sj},{key:"Mod-]",run:vj},{key:"Mod-Alt-\\",run:hse},{key:"Shift-Mod-k",run:cse},{key:"Shift-Mod-\\",run:Dne},{key:"Mod-/",run:ane},{key:"Alt-A",run:one},{key:"Ctrl-m",mac:"Shift-Alt-m",run:fse}].concat(mse),_se={key:"Tab",run:vj,shift:Sj},E3=typeof String.prototype.normalize=="function"?i=>i.normalize("NFKD"):i=>i;class bu{constructor(e,t,n=0,s=e.length,a,r){this.test=r,this.value={from:0,to:0},this.done=!1,this.matches=[],this.buffer="",this.bufferPos=0,this.iter=e.iterRange(n,s),this.bufferStart=n,this.normalize=a?o=>a(E3(o)):E3,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return Un(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=T2(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=Aa(e);let s=this.normalize(t);if(s.length)for(let a=0,r=n;;a++){let o=s.charCodeAt(a),c=this.match(o,r,this.bufferPos+this.bufferStart);if(a==s.length-1){if(c)return this.value=c,this;break}r==n&&athis.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine="":this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,s=n+t[0].length;if(this.matchPos=t0(this.text,s+(n==s?1:0)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(nthis.value.to)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length=n||s.to<=t){let o=new tu(t,e.sliceString(t,n));return gx.set(e,o),o}if(s.from==t&&s.to==n)return s;let{text:a,from:r}=s;return r>t&&(a=e.sliceString(t,r)+a,r=t),s.to=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let n=this.flat.from+t.index,s=n+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(n,s,t)))return this.value={from:n,to:s,match:t},this.matchPos=t0(this.text,s+(n==s?1:0)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=tu.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}}typeof Symbol!="undefined"&&(kj.prototype[Symbol.iterator]=Aj.prototype[Symbol.iterator]=function(){return this});function yse(i){try{return new RegExp(i,J2),!0}catch(e){return!1}}function t0(i,e){if(e>=i.length)return e;let t=i.lineAt(e),n;for(;e=56320&&n<57344;)e++;return e}function gv(i){let e=String(i.state.doc.lineAt(i.state.selection.main.head).number),t=Ht("input",{class:"cm-textfield",name:"line",value:e}),n=Ht("form",{class:"cm-gotoLine",onkeydown:a=>{a.keyCode==27?(a.preventDefault(),i.dispatch({effects:xh.of(!1)}),i.focus()):a.keyCode==13&&(a.preventDefault(),s())},onsubmit:a=>{a.preventDefault(),s()}},Ht("label",i.state.phrase("Go to line"),": ",t)," ",Ht("button",{class:"cm-button",type:"submit"},i.state.phrase("go")),Ht("button",{name:"close",onclick:()=>{i.dispatch({effects:xh.of(!1)}),i.focus()},"aria-label":i.state.phrase("close"),type:"button"},["×"]));function s(){let a=/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.value);if(!a)return;let{state:r}=i,o=r.doc.lineAt(r.selection.main.head),[,c,d,h,p]=a,_=h?+h.slice(1):0,y=d?+d:o.number;if(d&&p){let w=y/100;c&&(w=w*(c=="-"?-1:1)+o.number/r.doc.lines),y=Math.round(r.doc.lines*w)}else d&&c&&(y=y*(c=="-"?-1:1)+o.number);let x=r.doc.line(Math.max(1,Math.min(r.doc.lines,y))),v=xe.cursor(x.from+Math.max(0,Math.min(_,x.length)));i.dispatch({effects:[xh.of(!1),Ne.scrollIntoView(v.from,{y:"center"})],selection:v}),i.focus()}return{dom:n}}const xh=Ze.define(),D3=an.define({create(){return!0},update(i,e){for(let t of e.effects)t.is(xh)&&(i=t.value);return i},provide:i=>Wh.from(i,e=>e?gv:null)}),xse=i=>{let e=Ih(i,gv);if(!e){let t=[xh.of(!0)];i.state.field(D3,!1)==null&&t.push(Ze.appendConfig.of([D3,bse])),i.dispatch({effects:t}),e=Ih(i,gv)}return e&&e.dom.querySelector("input").select(),!0},bse=Ne.baseTheme({".cm-panel.cm-gotoLine":{padding:"2px 6px 4px",position:"relative","& label":{fontSize:"80%"},"& [name=close]":{position:"absolute",top:"0",bottom:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:"0"}}}),vse={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Sse=Le.define({combine(i){return Da(i,vse,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function Cj(i){return[Ose,Cse]}const wse=qe.mark({class:"cm-selectionMatch"}),kse=qe.mark({class:"cm-selectionMatch cm-selectionMatch-main"});function U3(i,e,t,n){return(t==0||i(e.sliceDoc(t-1,t))!=ei.Word)&&(n==e.doc.length||i(e.sliceDoc(n,n+1))!=ei.Word)}function Ase(i,e,t,n){return i(e.sliceDoc(t,t+1))==ei.Word&&i(e.sliceDoc(n-1,n))==ei.Word}const Cse=bi.fromClass(class{constructor(i){this.decorations=this.getDeco(i)}update(i){(i.selectionSet||i.docChanged||i.viewportChanged)&&(this.decorations=this.getDeco(i.view))}getDeco(i){let e=i.state.facet(Sse),{state:t}=i,n=t.selection;if(n.ranges.length>1)return qe.none;let s=n.main,a,r=null;if(s.empty){if(!e.highlightWordAroundCursor)return qe.none;let c=t.wordAt(s.head);if(!c)return qe.none;r=t.charCategorizer(s.head),a=t.sliceDoc(c.from,c.to)}else{let c=s.to-s.from;if(c200)return qe.none;if(e.wholeWords){if(a=t.sliceDoc(s.from,s.to),r=t.charCategorizer(s.head),!(U3(r,t,s.from,s.to)&&Ase(r,t,s.from,s.to)))return qe.none}else if(a=t.sliceDoc(s.from,s.to),!a)return qe.none}let o=[];for(let c of i.visibleRanges){let d=new bu(t.doc,a,c.from,c.to);for(;!d.next().done;){let{from:h,to:p}=d.value;if((!r||U3(r,t,h,p))&&(s.empty&&h<=s.from&&p>=s.to?o.push(kse.range(h,p)):(h>=s.to||p<=s.from)&&o.push(wse.range(h,p)),o.length>e.maxMatches))return qe.none}}return qe.set(o)}},{decorations:i=>i.decorations}),Ose=Ne.baseTheme({".cm-selectionMatch":{backgroundColor:"#99ff7780"},".cm-searchMatch .cm-selectionMatch":{backgroundColor:"transparent"}}),Tse=({state:i,dispatch:e})=>{let{selection:t}=i,n=xe.create(t.ranges.map(s=>i.wordAt(s.head)||xe.cursor(s.head)),t.mainIndex);return n.eq(t)?!1:(e(i.update({selection:n})),!0)};function Mse(i,e){let{main:t,ranges:n}=i.selection,s=i.wordAt(t.head),a=s&&s.from==t.from&&s.to==t.to;for(let r=!1,o=new bu(i.doc,e,n[n.length-1].to);;)if(o.next(),o.done){if(r)return null;o=new bu(i.doc,e,0,Math.max(0,n[n.length-1].from-1)),r=!0}else{if(r&&n.some(c=>c.from==o.value.from))continue;if(a){let c=i.wordAt(o.value.from);if(!c||c.from!=o.value.from||c.to!=o.value.to)continue}return o.value}}const Nse=({state:i,dispatch:e})=>{let{ranges:t}=i.selection;if(t.some(a=>a.from===a.to))return Tse({state:i,dispatch:e});let n=i.sliceDoc(t[0].from,t[0].to);if(i.selection.ranges.some(a=>i.sliceDoc(a.from,a.to)!=n))return!1;let s=Mse(i,n);return s?(e(i.update({selection:i.selection.addRange(xe.range(s.from,s.to),!1),effects:Ne.scrollIntoView(s.to)})),!0):!1},Xl=Le.define({combine(i){return Da(i,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Hse(e),scrollToMatch:e=>Ne.scrollIntoView(e)})}});function Rse(i){return i?[Xl.of(i),yv]:yv}class Oj{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||"",this.valid=!!this.search&&(!this.regexp||yse(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(t,n)=>n=="n"?` `:n=="r"?"\r":n=="t"?" ":"\\")}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord}create(){return this.regexp?new Ese(this):new Lse(this)}getCursor(e,t=0,n){let s=e.doc?e:ut.create({doc:e});return n==null&&(n=s.doc.length),this.regexp?Uc(this,s,t,n):Dc(this,s,t,n)}}class Tj{constructor(e){this.spec=e}}function Dc(i,e,t,n){return new bu(e.doc,i.unquoted,t,n,i.caseSensitive?void 0:s=>s.toLowerCase(),i.wholeWord?Pse(e.doc,e.charCategorizer(e.selection.main.head)):void 0)}function Pse(i,e){return(t,n,s,a)=>((a>t||a+s.length=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let a=Dc(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}function Uc(i,e,t,n){return new kj(e.doc,i.search,{ignoreCase:!i.caseSensitive,test:i.wholeWord?jse(e.charCategorizer(e.selection.main.head)):void 0},t,n)}function i0(i,e){return i.slice(tn(i,e,!1),e)}function n0(i,e){return i.slice(e,tn(i,e))}function jse(i){return(e,t,n)=>!n[0].length||(i(i0(n.input,n.index))!=ei.Word||i(n0(n.input,n.index))!=ei.Word)&&(i(n0(n.input,n.index+n[0].length))!=ei.Word||i(i0(n.input,n.index+n[0].length))!=ei.Word)}class Ese extends Tj{nextMatch(e,t,n){let s=Uc(this.spec,e,n,e.doc.length).next();return s.done&&(s=Uc(this.spec,e,0,t).next()),s.done?null:s.value}prevMatchInRange(e,t,n){for(let s=1;;s++){let a=Math.max(t,n-s*1e4),r=Uc(this.spec,e,a,n),o=null;for(;!r.next().done;)o=r.value;if(o&&(a==t||o.from>a+10))return o;if(a==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n=="&")return e.match[0];if(n=="$")return"$";for(let s=n.length;s>0;s--){let a=+n.slice(0,s);if(a>0&&a=t)return null;s.push(n.value)}return s}highlight(e,t,n,s){let a=Uc(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!a.next().done;)s(a.value.from,a.value.to)}}const Yh=Ze.define(),$2=Ze.define(),vo=an.define({create(i){return new _x(_v(i).create(),null)},update(i,e){for(let t of e.effects)t.is(Yh)?i=new _x(t.value.create(),i.panel):t.is($2)&&(i=new _x(i.query,t.value?eS:null));return i},provide:i=>Wh.from(i,e=>e.panel)});class _x{constructor(e,t){this.query=e,this.panel=t}}const Dse=qe.mark({class:"cm-searchMatch"}),Use=qe.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Fse=bi.fromClass(class{constructor(i){this.view=i,this.decorations=this.highlight(i.state.field(vo))}update(i){let e=i.state.field(vo);(e!=i.startState.field(vo)||i.docChanged||i.selectionSet||i.viewportChanged)&&(this.decorations=this.highlight(e))}highlight({query:i,panel:e}){if(!e||!i.spec.valid)return qe.none;let{view:t}=this,n=new vr;for(let s=0,a=t.visibleRanges,r=a.length;sa[s+1].from-500;)c=a[++s].to;i.highlight(t.state,o,c,(d,h)=>{let p=t.state.selection.ranges.some(_=>_.from==d&&_.to==h);n.add(d,h,p?Use:Dse)})}return n.finish()}},{decorations:i=>i.decorations});function Tf(i){return e=>{let t=e.state.field(vo,!1);return t&&t.query.spec.valid?i(e,t):Rj(e)}}const s0=Tf((i,{query:e})=>{let{to:t}=i.state.selection.main,n=e.nextMatch(i.state,t,t);if(!n)return!1;let s=xe.single(n.from,n.to),a=i.state.facet(Xl);return i.dispatch({selection:s,effects:[tS(i,n),a.scrollToMatch(s.main,i)],userEvent:"select.search"}),Nj(i),!0}),a0=Tf((i,{query:e})=>{let{state:t}=i,{from:n}=t.selection.main,s=e.prevMatch(t,n,n);if(!s)return!1;let a=xe.single(s.from,s.to),r=i.state.facet(Xl);return i.dispatch({selection:a,effects:[tS(i,s),r.scrollToMatch(a.main,i)],userEvent:"select.search"}),Nj(i),!0}),Bse=Tf((i,{query:e})=>{let t=e.matchAll(i.state,1e3);return!t||!t.length?!1:(i.dispatch({selection:xe.create(t.map(n=>xe.range(n.from,n.to))),userEvent:"select.search.matches"}),!0)}),zse=({state:i,dispatch:e})=>{let t=i.selection;if(t.ranges.length>1||t.main.empty)return!1;let{from:n,to:s}=t.main,a=[],r=0;for(let o=new bu(i.doc,i.sliceDoc(n,s));!o.next().done;){if(a.length>1e3)return!1;o.value.from==n&&(r=a.length),a.push(xe.range(o.value.from,o.value.to))}return e(i.update({selection:xe.create(a,r),userEvent:"select.search.matches"})),!0},F3=Tf((i,{query:e})=>{let{state:t}=i,{from:n,to:s}=t.selection.main;if(t.readOnly)return!1;let a=e.nextMatch(t,n,n);if(!a)return!1;let r=a,o=[],c,d,h=[];r.from==n&&r.to==s&&(d=t.toText(e.getReplacement(r)),o.push({from:r.from,to:r.to,insert:d}),r=e.nextMatch(t,r.from,r.to),h.push(Ne.announce.of(t.phrase("replaced match on line $",t.doc.lineAt(n).number)+".")));let p=i.state.changes(o);return r&&(c=xe.single(r.from,r.to).map(p),h.push(tS(i,r)),h.push(t.facet(Xl).scrollToMatch(c.main,i))),i.dispatch({changes:p,selection:c,effects:h,userEvent:"input.replace"}),!0}),qse=Tf((i,{query:e})=>{if(i.state.readOnly)return!1;let t=e.matchAll(i.state,1e9).map(s=>{let{from:a,to:r}=s;return{from:a,to:r,insert:e.getReplacement(s)}});if(!t.length)return!1;let n=i.state.phrase("replaced $ matches",t.length)+".";return i.dispatch({changes:t,effects:Ne.announce.of(n),userEvent:"input.replace.all"}),!0});function eS(i){return i.state.facet(Xl).createPanel(i)}function _v(i,e){var t,n,s,a,r;let o=i.selection.main,c=o.empty||o.to>o.from+100?"":i.sliceDoc(o.from,o.to);if(e&&!c)return e;let d=i.facet(Xl);return new Oj({search:((t=e==null?void 0:e.literal)!==null&&t!==void 0?t:d.literal)?c:c.replace(/\n/g,"\\n"),caseSensitive:(n=e==null?void 0:e.caseSensitive)!==null&&n!==void 0?n:d.caseSensitive,literal:(s=e==null?void 0:e.literal)!==null&&s!==void 0?s:d.literal,regexp:(a=e==null?void 0:e.regexp)!==null&&a!==void 0?a:d.regexp,wholeWord:(r=e==null?void 0:e.wholeWord)!==null&&r!==void 0?r:d.wholeWord})}function Mj(i){let e=Ih(i,eS);return e&&e.dom.querySelector("[main-field]")}function Nj(i){let e=Mj(i);e&&e==i.root.activeElement&&e.select()}const Rj=i=>{let e=i.state.field(vo,!1);if(e&&e.panel){let t=Mj(i);if(t&&t!=i.root.activeElement){let n=_v(i.state,e.query.spec);n.valid&&i.dispatch({effects:Yh.of(n)}),t.focus(),t.select()}}else i.dispatch({effects:[$2.of(!0),e?Yh.of(_v(i.state,e.query.spec)):Ze.appendConfig.of(yv)]});return!0},Pj=i=>{let e=i.state.field(vo,!1);if(!e||!e.panel)return!1;let t=Ih(i,eS);return t&&t.dom.contains(i.root.activeElement)&&i.focus(),i.dispatch({effects:$2.of(!1)}),!0},Lj=[{key:"Mod-f",run:Rj,scope:"editor search-panel"},{key:"F3",run:s0,shift:a0,scope:"editor search-panel",preventDefault:!0},{key:"Mod-g",run:s0,shift:a0,scope:"editor search-panel",preventDefault:!0},{key:"Escape",run:Pj,scope:"editor search-panel"},{key:"Mod-Shift-l",run:zse},{key:"Mod-Alt-g",run:xse},{key:"Mod-d",run:Nse,preventDefault:!0}];class Hse{constructor(e){this.view=e;let t=this.query=e.state.field(vo).query.spec;this.commit=this.commit.bind(this),this.searchField=Ht("input",{value:t.search,placeholder:rs(e,"Find"),"aria-label":rs(e,"Find"),class:"cm-textfield",name:"search",form:"","main-field":"true",onchange:this.commit,onkeyup:this.commit}),this.replaceField=Ht("input",{value:t.replace,placeholder:rs(e,"Replace"),"aria-label":rs(e,"Replace"),class:"cm-textfield",name:"replace",form:"",onchange:this.commit,onkeyup:this.commit}),this.caseField=Ht("input",{type:"checkbox",name:"case",form:"",checked:t.caseSensitive,onchange:this.commit}),this.reField=Ht("input",{type:"checkbox",name:"re",form:"",checked:t.regexp,onchange:this.commit}),this.wordField=Ht("input",{type:"checkbox",name:"word",form:"",checked:t.wholeWord,onchange:this.commit});function n(s,a,r){return Ht("button",{class:"cm-button",name:s,onclick:a,type:"button"},r)}this.dom=Ht("div",{onkeydown:s=>this.keydown(s),class:"cm-search"},[this.searchField,n("next",()=>s0(e),[rs(e,"next")]),n("prev",()=>a0(e),[rs(e,"previous")]),n("select",()=>Bse(e),[rs(e,"all")]),Ht("label",null,[this.caseField,rs(e,"match case")]),Ht("label",null,[this.reField,rs(e,"regexp")]),Ht("label",null,[this.wordField,rs(e,"by word")]),...e.state.readOnly?[]:[Ht("br"),this.replaceField,n("replace",()=>F3(e),[rs(e,"replace")]),n("replaceAll",()=>qse(e),[rs(e,"replace all")])],Ht("button",{name:"close",onclick:()=>Pj(e),"aria-label":rs(e,"close"),type:"button"},["×"])])}commit(){let e=new Oj({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:Yh.of(e)}))}keydown(e){Yee(this.view,e,"search-panel")?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?a0:s0)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),F3(this.view))}update(e){for(let t of e.transactions)for(let n of t.effects)n.is(Yh)&&!n.value.eq(this.query)&&this.setQuery(n.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(Xl).top}}function rs(i,e){return i.state.phrase(e)}const Fm=30,Bm=/[\s\.,:;?!]/;function tS(i,{from:e,to:t}){let n=i.state.doc.lineAt(e),s=i.state.doc.lineAt(t).to,a=Math.max(n.from,e-Fm),r=Math.min(s,t+Fm),o=i.state.sliceDoc(a,r);if(a!=n.from){for(let c=0;co.length-Fm;c--)if(!Bm.test(o[c-1])&&Bm.test(o[c])){o=o.slice(0,c);break}}return Ne.announce.of(`${i.state.phrase("current match")}. ${o} ${i.state.phrase("on line")} ${n.number}.`)}const Kse=Ne.baseTheme({".cm-panel.cm-search":{padding:"2px 6px 4px",position:"relative","& [name=close]":{position:"absolute",top:"0",right:"4px",backgroundColor:"inherit",border:"none",font:"inherit",padding:0,margin:0},"& input, & button, & label":{margin:".2em .6em .2em 0"},"& input[type=checkbox]":{marginRight:".2em"},"& label":{fontSize:"80%",whiteSpace:"pre"}},"&light .cm-searchMatch":{backgroundColor:"#ffff0054"},"&dark .cm-searchMatch":{backgroundColor:"#00ffff8a"},"&light .cm-searchMatch-selected":{backgroundColor:"#ff6a0054"},"&dark .cm-searchMatch-selected":{backgroundColor:"#ff00ff8a"}}),yv=[vo,Wl.low(Fse),Kse];class jj{constructor(e,t,n,s){this.state=e,this.pos=t,this.explicit=n,this.view=s,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=gn(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),s=t.text.slice(n-t.from,this.pos-t.from),a=s.search(Ej(e,!1));return a<0?null:{from:n+a,to:this.pos,text:s.slice(a)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e=="abort"&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}}function B3(i){let e=Object.keys(i).join(""),t=/\w/.test(e);return t&&(e=e.replace(/\w/g,"")),`[${t?"\\w":""}${e.replace(/[^\w\s]/g,"\\$&")}]`}function Vse(i){let e=Object.create(null),t=Object.create(null);for(let{label:s}of i){e[s[0]]=!0;for(let a=1;atypeof s=="string"?{label:s}:s),[t,n]=e.every(s=>/^\w+$/.test(s.label))?[/\w*$/,/\w+$/]:Vse(e);return s=>{let a=s.matchBefore(n);return a||s.explicit?{from:a?a.from:s.pos,options:e,validFor:t}:null}}class z3{constructor(e,t,n,s){this.completion=e,this.source=t,this.match=n,this.score=s}}function Pl(i){return i.selection.main.from}function Ej(i,e){var t;let{source:n}=i,s=e&&n[0]!="^",a=n[n.length-1]!="$";return!s&&!a?i:new RegExp(`${s?"^":""}(?:${n})${a?"$":""}`,(t=i.flags)!==null&&t!==void 0?t:i.ignoreCase?"i":"")}const Dj=Ea.define();function Wse(i,e,t,n){let{main:s}=i.selection,a=t-s.from,r=n-s.from;return ee(z({},i.changeByRange(o=>{if(o!=s&&t!=n&&i.sliceDoc(o.from+a,o.from+r)!=i.sliceDoc(t,n))return{range:o};let c=i.toText(e);return{changes:{from:o.from+a,to:n==s.from?o.to:o.from+r,insert:c},range:xe.cursor(o.from+a+c.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const q3=new WeakMap;function Xse(i){if(!Array.isArray(i))return i;let e=q3.get(i);return e||q3.set(i,e=Ise(i)),e}const r0=Ze.define(),Zh=Ze.define();class Gse{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t=48&&C<=57||C>=97&&C<=122?2:C>=65&&C<=90?1:0:(P=T2(C))!=P.toLowerCase()?1:P!=P.toUpperCase()?2:0;(!M||R==1&&w||A==0&&R!=0)&&(t[p]==C||n[p]==C&&(_=!0)?r[p++]=M:r.length&&(k=!1)),A=R,M+=Aa(C)}return p==c&&r[0]==0&&k?this.result(-100+(_?-200:0),r,e):y==c&&x==0?this.ret(-200-e.length+(v==e.length?0:-100),[0,v]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):y==c?this.ret(-900-e.length,[x,v]):p==c?this.result(-100+(_?-200:0)+-700+(k?0:-1100),r,e):t.length==2?null:this.result((s[0]?-700:0)+-200+-1100,s,e)}result(e,t,n){let s=[],a=0;for(let r of t){let o=r+(this.astral?Aa(Un(n,r)):1);a&&s[a-1]==r?s[a-1]=o:(s[a++]=r,s[a++]=o)}return this.ret(e-n.length,s)}}class Qse{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>"",optionClass:()=>"",aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:Yse,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>H3(e(n),t(n)),optionClass:(e,t)=>n=>H3(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function H3(i,e){return i?e?i+" "+e:i:e}function Yse(i,e,t,n,s,a){let r=i.textDirection==Zt.RTL,o=r,c=!1,d="top",h,p,_=e.left-s.left,y=s.right-e.right,x=n.right-n.left,v=n.bottom-n.top;if(o&&_=v||M>e.top?h=t.bottom-e.top:(d="bottom",h=e.bottom-t.top)}let w=(e.bottom-e.top)/a.offsetHeight,k=(e.right-e.left)/a.offsetWidth;return{style:`${d}: ${h/w}px; max-width: ${p/k}px`,class:"cm-completionInfo-"+(c?r?"left-narrow":"right-narrow":o?"left":"right")}}function Zse(i){let e=i.addToOptions.slice();return i.icons&&e.push({render(t){let n=document.createElement("div");return n.classList.add("cm-completionIcon"),t.type&&n.classList.add(...t.type.split(/\s+/g).map(s=>"cm-completionIcon-"+s)),n.setAttribute("aria-hidden","true"),n},position:20}),e.push({render(t,n,s,a){let r=document.createElement("span");r.className="cm-completionLabel";let o=t.displayLabel||t.label,c=0;for(let d=0;dc&&r.appendChild(document.createTextNode(o.slice(c,h)));let _=r.appendChild(document.createElement("span"));_.appendChild(document.createTextNode(o.slice(h,p))),_.className="cm-completionMatchedText",c=p}return ct.position-n.position).map(t=>t.render)}function yx(i,e,t){if(i<=t)return{from:0,to:i};if(e<0&&(e=0),e<=i>>1){let s=Math.floor(e/t);return{from:s*t,to:(s+1)*t}}let n=Math.floor((i-e)/t);return{from:i-(n+1)*t,to:i-n*t}}class Jse{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:c=>this.placeInfo(c),key:this},this.space=null,this.currentClass="";let s=e.state.field(t),{options:a,selected:r}=s.open,o=e.state.facet(Ki);this.optionContent=Zse(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=yx(a.length,r,o.maxRenderedOptions),this.dom=document.createElement("div"),this.dom.className="cm-tooltip-autocomplete",this.updateTooltipClass(e.state),this.dom.addEventListener("mousedown",c=>{let{options:d}=e.state.field(t).open;for(let h=c.target,p;h&&h!=this.dom;h=h.parentNode)if(h.nodeName=="LI"&&(p=/-(\d+)$/.exec(h.id))&&+p[1]{let d=e.state.field(this.stateField,!1);d&&d.tooltip&&e.state.facet(Ki).closeOnBlur&&c.relatedTarget!=e.contentDOM&&e.dispatch({effects:Zh.of(null)})}),this.showOptions(a,s.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener("scroll",()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){var t;let n=e.state.field(this.stateField),s=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),n!=s){let{options:a,selected:r,disabled:o}=n.open;(!s.open||s.open.options!=a)&&(this.range=yx(a.length,r,e.state.facet(Ki).maxRenderedOptions),this.showOptions(a,n.id)),this.updateSel(),o!=((t=s.open)===null||t===void 0?void 0:t.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let n of this.currentClass.split(" "))n&&this.dom.classList.remove(n);for(let n of t.split(" "))n&&this.dom.classList.add(n);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected=this.range.to)&&(this.range=yx(t.options.length,t.selected,this.view.state.facet(Ki).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:s}=t.options[t.selected],{info:a}=s;if(!a)return;let r=typeof a=="string"?document.createTextNode(a):a(s);if(!r)return;"then"in r?r.then(o=>{o&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(o,s)}).catch(o=>qn(this.view.state,o,"completion info")):(this.addInfoPane(r,s),n.setAttribute("aria-describedby",this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement("div");if(n.className="cm-tooltip cm-completionInfo",n.id="cm-completionInfo-"+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:s,destroy:a}=e;n.appendChild(s),this.infoDestroy=a||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,s=this.range.from;n;n=n.nextSibling,s++)n.nodeName!="LI"||!n.id?s--:s==e?n.hasAttribute("aria-selected")||(n.setAttribute("aria-selected","true"),t=n):n.hasAttribute("aria-selected")&&(n.removeAttribute("aria-selected"),n.removeAttribute("aria-describedby"));return t&&eae(this.list,t),t}measureInfo(){let e=this.dom.querySelector("[aria-selected]");if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),s=e.getBoundingClientRect(),a=this.space;if(!a){let r=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:r.clientWidth,bottom:r.clientHeight}}return s.top>Math.min(a.bottom,t.bottom)-10||s.bottom{r.target==s&&r.preventDefault()});let a=null;for(let r=n.from;rn.from||n.from==0))if(a=_,typeof d!="string"&&d.header)s.appendChild(d.header(d));else{let y=s.appendChild(document.createElement("completion-section"));y.textContent=_}}const h=s.appendChild(document.createElement("li"));h.id=t+"-"+r,h.setAttribute("role","option");let p=this.optionClass(o);p&&(h.className=p);for(let _ of this.optionContent){let y=_(o,this.view.state,this.view,c);y&&h.appendChild(y)}}return n.from&&s.classList.add("cm-completionListIncompleteTop"),n.tonew Jse(t,i,e)}function eae(i,e){let t=i.getBoundingClientRect(),n=e.getBoundingClientRect(),s=t.height/i.offsetHeight;n.topt.bottom&&(i.scrollTop+=(n.bottom-t.bottom)/s)}function K3(i){return(i.boost||0)*100+(i.apply?10:0)+(i.info?5:0)+(i.type?1:0)}function tae(i,e){let t=[],n=null,s=null,a=h=>{t.push(h);let{section:p}=h.completion;if(p){n||(n=[]);let _=typeof p=="string"?p:p.name;n.some(y=>y.name==_)||n.push(typeof p=="string"?{name:_}:p)}},r=e.facet(Ki);for(let h of i)if(h.hasResult()){let p=h.result.getMatch;if(h.result.filter===!1)for(let _ of h.result.options)a(new z3(_,h.source,p?p(_):[],1e9-t.length));else{let _=e.sliceDoc(h.from,h.to),y,x=r.filterStrict?new Qse(_):new Gse(_);for(let v of h.result.options)if(y=x.match(v.label)){let w=v.displayLabel?p?p(v,y.matched):[]:y.matched,k=y.score+(v.boost||0);if(a(new z3(v,h.source,w,k)),typeof v.section=="object"&&v.section.rank==="dynamic"){let{name:M}=v.section;s||(s=Object.create(null)),s[M]=Math.max(k,s[M]||-1e9)}}}}if(n){let h=Object.create(null),p=0,_=(y,x)=>(y.rank==="dynamic"&&x.rank==="dynamic"?s[x.name]-s[y.name]:0)||(typeof y.rank=="number"?y.rank:1e9)-(typeof x.rank=="number"?x.rank:1e9)||(y.name_.score-p.score||d(p.completion,_.completion))){let p=h.completion;!c||c.label!=p.label||c.detail!=p.detail||c.type!=null&&p.type!=null&&c.type!=p.type||c.apply!=p.apply||c.boost!=p.boost?o.push(h):K3(h.completion)>K3(c)&&(o[o.length-1]=h),c=h.completion}return o}class Ic{constructor(e,t,n,s,a,r){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=s,this.selected=a,this.disabled=r}setSelected(e,t){return e==this.selected||e>=this.options.length?this:new Ic(this.options,V3(t,e),this.tooltip,this.timestamp,e,this.disabled)}static build(e,t,n,s,a,r){if(s&&!r&&e.some(d=>d.isPending))return s.setDisabled();let o=tae(e,t);if(!o.length)return s&&e.some(d=>d.isPending)?s.setDisabled():null;let c=t.facet(Ki).selectOnOpen?0:-1;if(s&&s.selected!=c&&s.selected!=-1){let d=s.options[s.selected].completion;for(let h=0;hh.hasResult()?Math.min(d,h.from):d,1e8),create:oae,above:a.aboveCursor},s?s.timestamp:Date.now(),c,!1)}map(e){return new Ic(this.options,this.attrs,ee(z({},this.tooltip),{pos:e.mapPos(this.tooltip.pos)}),this.timestamp,this.selected,this.disabled)}setDisabled(){return new Ic(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class o0{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new o0(aae,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(e){let{state:t}=e,n=t.facet(Ki),a=(n.override||t.languageDataAt("autocomplete",Pl(t)).map(Xse)).map(c=>(this.active.find(h=>h.source==c)||new Fs(c,this.active.some(h=>h.state!=0)?1:0)).update(e,n));a.length==this.active.length&&a.every((c,d)=>c==this.active[d])&&(a=this.active);let r=this.open,o=e.effects.some(c=>c.is(iS));r&&e.docChanged&&(r=r.map(e.changes)),e.selection||a.some(c=>c.hasResult()&&e.changes.touchesRange(c.from,c.to))||!iae(a,this.active)||o?r=Ic.build(a,t,this.id,r,n,o):r&&r.disabled&&!a.some(c=>c.isPending)&&(r=null),!r&&a.every(c=>!c.isPending)&&a.some(c=>c.hasResult())&&(a=a.map(c=>c.hasResult()?new Fs(c.source,0):c));for(let c of e.effects)c.is(Fj)&&(r=r&&r.setSelected(c.value,this.id));return a==this.active&&r==this.open?this:new o0(a,this.id,r)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?nae:sae}}function iae(i,e){if(i==e)return!0;for(let t=0,n=0;;){for(;t-1&&(t["aria-activedescendant"]=i+"-"+e),t}const aae=[];function Uj(i,e){if(i.isUserEvent("input.complete")){let n=i.annotation(Dj);if(n&&e.activateOnCompletion(n))return 12}let t=i.isUserEvent("input.type");return t&&e.activateOnTyping?5:t?1:i.isUserEvent("delete.backward")?2:i.selection?8:i.docChanged?16:0}class Fs{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(e,t){let n=Uj(e,t),s=this;(n&8||n&16&&this.touches(e))&&(s=new Fs(s.source,0)),n&4&&s.state==0&&(s=new Fs(this.source,1)),s=s.updateFor(e,n);for(let a of e.effects)if(a.is(r0))s=new Fs(s.source,1,a.value);else if(a.is(Zh))s=new Fs(s.source,0);else if(a.is(iS))for(let r of a.value)r.source==s.source&&(s=r);return s}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(Pl(e.state))}}class iu extends Fs{constructor(e,t,n,s,a,r){super(e,3,t),this.limit=n,this.result=s,this.from=a,this.to=r}hasResult(){return!0}updateFor(e,t){var n;if(!(t&3))return this.map(e.changes);let s=this.result;s.map&&!e.changes.empty&&(s=s.map(s,e.changes));let a=e.changes.mapPos(this.from),r=e.changes.mapPos(this.to,1),o=Pl(e.state);if(o>r||!s||t&2&&(Pl(e.startState)==this.from||ot.map(e))}}),Fj=Ze.define(),Fn=an.define({create(){return o0.start()},update(i,e){return i.update(e)},provide:i=>[H2.from(i,e=>e.tooltip),Ne.contentAttributes.from(i,e=>e.attrs)]});function nS(i,e){const t=e.completion.apply||e.completion.label;let n=i.state.field(Fn).active.find(s=>s.source==e.source);return n instanceof iu?(typeof t=="string"?i.dispatch(ee(z({},Wse(i.state,t,n.from,n.to)),{annotations:Dj.of(e.completion)})):t(i,e.completion,n.from,n.to),!0):!1}const oae=$se(Fn,nS);function zm(i,e="option"){return t=>{let n=t.state.field(Fn,!1);if(!n||!n.open||n.open.disabled||Date.now()-n.open.timestamp-1?n.open.selected+s*(i?1:-1):i?0:r-1;return o<0?o=e=="page"?0:r-1:o>=r&&(o=e=="page"?r-1:0),t.dispatch({effects:Fj.of(o)}),!0}}const lae=i=>{let e=i.state.field(Fn,!1);return i.state.readOnly||!e||!e.open||e.open.selected<0||e.open.disabled||Date.now()-e.open.timestampi.state.field(Fn,!1)?(i.dispatch({effects:r0.of(!0)}),!0):!1,cae=i=>{let e=i.state.field(Fn,!1);return!e||!e.active.some(t=>t.state!=0)?!1:(i.dispatch({effects:Zh.of(null)}),!0)};class uae{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}}const dae=50,hae=1e3,fae=bi.fromClass(class{constructor(i){this.view=i,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let e of i.state.field(Fn).active)e.isPending&&this.startQuery(e)}update(i){let e=i.state.field(Fn),t=i.state.facet(Ki);if(!i.selectionSet&&!i.docChanged&&i.startState.field(Fn)==e)return;let n=i.transactions.some(a=>{let r=Uj(a,t);return r&8||(a.selection||a.docChanged)&&!(r&3)});for(let a=0;adae&&Date.now()-r.time>hae){for(let o of r.context.abortListeners)try{o()}catch(c){qn(this.view.state,c)}r.context.abortListeners=null,this.running.splice(a--,1)}else r.updates.push(...i.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),i.transactions.some(a=>a.effects.some(r=>r.is(r0)))&&(this.pendingStart=!0);let s=this.pendingStart?50:t.activateOnTypingDelay;if(this.debounceUpdate=e.active.some(a=>a.isPending&&!this.running.some(r=>r.active.source==a.source))?setTimeout(()=>this.startUpdate(),s):-1,this.composing!=0)for(let a of i.transactions)a.isUserEvent("input.type")?this.composing=2:this.composing==2&&a.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:i}=this.view,e=i.field(Fn);for(let t of e.active)t.isPending&&!this.running.some(n=>n.active.source==t.source)&&this.startQuery(t);this.running.length&&e.open&&e.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ki).updateSyncTime))}startQuery(i){let{state:e}=this.view,t=Pl(e),n=new jj(e,t,i.explicit,this.view),s=new uae(i,n);this.running.push(s),Promise.resolve(i.source(n)).then(a=>{s.context.aborted||(s.done=a||null,this.scheduleAccept())},a=>{this.view.dispatch({effects:Zh.of(null)}),qn(this.view.state,a)})}scheduleAccept(){this.running.every(i=>i.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(Ki).updateSyncTime))}accept(){var i;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(Ki),n=this.view.state.field(Fn);for(let s=0;so.source==a.active.source);if(r&&r.isPending)if(a.done==null){let o=new Fs(a.active.source,0);for(let c of a.updates)o=o.update(c,t);o.isPending||e.push(o)}else this.startQuery(r)}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:iS.of(e)})}},{eventHandlers:{blur(i){let e=this.view.state.field(Fn,!1);if(e&&e.tooltip&&this.view.state.facet(Ki).closeOnBlur){let t=e.open&&m5(this.view,e.open.tooltip);(!t||!t.dom.contains(i.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Zh.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:r0.of(!1)}),20),this.composing=0}}}),pae=typeof navigator=="object"&&/Win/.test(navigator.platform),mae=Wl.highest(Ne.domEventHandlers({keydown(i,e){let t=e.state.field(Fn,!1);if(!t||!t.open||t.open.disabled||t.open.selected<0||i.key.length>1||i.ctrlKey&&!(pae&&i.altKey)||i.metaKey)return!1;let n=t.open.options[t.open.selected],s=t.active.find(r=>r.source==n.source),a=n.completion.commitCharacters||s.result.commitCharacters;return a&&a.indexOf(i.key)>-1&&nS(e,n),!1}})),gae=Ne.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:"monospace",whiteSpace:"nowrap",overflow:"hidden auto",maxWidth_fallback:"700px",maxWidth:"min(700px, 95vw)",minWidth:"250px",maxHeight:"10em",height:"100%",listStyle:"none",margin:0,padding:0,"& > li, & > completion-section":{padding:"1px 3px",lineHeight:1.2},"& > li":{overflowX:"hidden",textOverflow:"ellipsis",cursor:"pointer"},"& > completion-section":{display:"list-item",borderBottom:"1px solid silver",paddingLeft:"0.5em",opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#17c",color:"white"},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#777"},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:"#347",color:"white"},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:"#444"},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:'"···"',opacity:.5,display:"block",textAlign:"center"},".cm-tooltip.cm-completionInfo":{position:"absolute",padding:"3px 9px",width:"max-content",maxWidth:"400px",boxSizing:"border-box",whiteSpace:"pre-line"},".cm-completionInfo.cm-completionInfo-left":{right:"100%"},".cm-completionInfo.cm-completionInfo-right":{left:"100%"},".cm-completionInfo.cm-completionInfo-left-narrow":{right:"30px"},".cm-completionInfo.cm-completionInfo-right-narrow":{left:"30px"},"&light .cm-snippetField":{backgroundColor:"#00000022"},"&dark .cm-snippetField":{backgroundColor:"#ffffff22"},".cm-snippetFieldPosition":{verticalAlign:"text-top",width:0,height:"1.15em",display:"inline-block",margin:"0 -0.7px -.7em",borderLeft:"1.4px dotted #888"},".cm-completionMatchedText":{textDecoration:"underline"},".cm-completionDetail":{marginLeft:"0.5em",fontStyle:"italic"},".cm-completionIcon":{fontSize:"90%",width:".8em",display:"inline-block",textAlign:"center",paddingRight:".6em",opacity:"0.6",boxSizing:"content-box"},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:"'ƒ'"}},".cm-completionIcon-class":{"&:after":{content:"'○'"}},".cm-completionIcon-interface":{"&:after":{content:"'◌'"}},".cm-completionIcon-variable":{"&:after":{content:"'𝑥'"}},".cm-completionIcon-constant":{"&:after":{content:"'𝐶'"}},".cm-completionIcon-type":{"&:after":{content:"'𝑡'"}},".cm-completionIcon-enum":{"&:after":{content:"'∪'"}},".cm-completionIcon-property":{"&:after":{content:"'□'"}},".cm-completionIcon-keyword":{"&:after":{content:"'🔑︎'"}},".cm-completionIcon-namespace":{"&:after":{content:"'▢'"}},".cm-completionIcon-text":{"&:after":{content:"'abc'",fontSize:"50%",verticalAlign:"middle"}}}),Jh={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Sl=Ze.define({map(i,e){let t=e.mapPos(i,-1,An.TrackAfter);return t==null?void 0:t}}),sS=new class extends Dl{};sS.startSide=1;sS.endSide=-1;const Bj=an.define({create(){return mt.empty},update(i,e){if(i=i.map(e.changes),e.selection){let t=e.state.doc.lineAt(e.selection.main.head);i=i.update({filter:n=>n>=t.from&&n<=t.to})}for(let t of e.effects)t.is(Sl)&&(i=i.update({add:[sS.range(t.value,t.value+1)]}));return i}});function _ae(){return[xae,Bj]}const bx="()[]{}<>«»»«[]{}";function zj(i){for(let e=0;e{if((yae?i.composing:i.compositionStarted)||i.state.readOnly)return!1;let s=i.state.selection.main;if(n.length>2||n.length==2&&Aa(Un(n,0))==1||e!=s.from||t!=s.to)return!1;let a=Sae(i.state,n);return a?(i.dispatch(a),!0):!1}),bae=({state:i,dispatch:e})=>{if(i.readOnly)return!1;let n=qj(i,i.selection.main.head).brackets||Jh.brackets,s=null,a=i.changeByRange(r=>{if(r.empty){let o=wae(i.doc,r.head);for(let c of n)if(c==o&&G0(i.doc,r.head)==zj(Un(c,0)))return{changes:{from:r.head-c.length,to:r.head+c.length},range:xe.cursor(r.head-c.length)}}return{range:s=r}});return s||e(i.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!s},vae=[{key:"Backspace",run:bae}];function Sae(i,e){let t=qj(i,i.selection.main.head),n=t.brackets||Jh.brackets;for(let s of n){let a=zj(Un(s,0));if(e==s)return a==s?Cae(i,s,n.indexOf(s+s+s)>-1,t):kae(i,s,a,t.before||Jh.before);if(e==a&&Hj(i,i.selection.main.from))return Aae(i,s,a)}return null}function Hj(i,e){let t=!1;return i.field(Bj).between(0,i.doc.length,n=>{n==e&&(t=!0)}),t}function G0(i,e){let t=i.sliceString(e,e+2);return t.slice(0,Aa(Un(t,0)))}function wae(i,e){let t=i.sliceString(e-2,e);return Aa(Un(t,0))==t.length?t:t.slice(1)}function kae(i,e,t,n){let s=null,a=i.changeByRange(r=>{if(!r.empty)return{changes:[{insert:e,from:r.from},{insert:t,from:r.to}],effects:Sl.of(r.to+e.length),range:xe.range(r.anchor+e.length,r.head+e.length)};let o=G0(i.doc,r.head);return!o||/\s/.test(o)||n.indexOf(o)>-1?{changes:{insert:e+t,from:r.head},effects:Sl.of(r.head+e.length),range:xe.cursor(r.head+e.length)}:{range:s=r}});return s?null:i.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function Aae(i,e,t){let n=null,s=i.changeByRange(a=>a.empty&&G0(i.doc,a.head)==t?{changes:{from:a.head,to:a.head+t.length,insert:t},range:xe.cursor(a.head+t.length)}:n={range:a});return n?null:i.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function Cae(i,e,t,n){let s=n.stringPrefixes||Jh.stringPrefixes,a=null,r=i.changeByRange(o=>{if(!o.empty)return{changes:[{insert:e,from:o.from},{insert:e,from:o.to}],effects:Sl.of(o.to+e.length),range:xe.range(o.anchor+e.length,o.head+e.length)};let c=o.head,d=G0(i.doc,c),h;if(d==e){if(I3(i,c))return{changes:{insert:e+e,from:c},effects:Sl.of(c+e.length),range:xe.cursor(c+e.length)};if(Hj(i,c)){let _=t&&i.sliceDoc(c,c+e.length*3)==e+e+e?e+e+e:e;return{changes:{from:c,to:c+_.length,insert:_},range:xe.cursor(c+_.length)}}}else{if(t&&i.sliceDoc(c-2*e.length,c)==e+e&&(h=W3(i,c-2*e.length,s))>-1&&I3(i,h))return{changes:{insert:e+e+e+e,from:c},effects:Sl.of(c+e.length),range:xe.cursor(c+e.length)};if(i.charCategorizer(c)(d)!=ei.Word&&W3(i,c,s)>-1&&!Oae(i,c,e,s))return{changes:{insert:e+e,from:c},effects:Sl.of(c+e.length),range:xe.cursor(c+e.length)}}return{range:a=o}});return a?null:i.update(r,{scrollIntoView:!0,userEvent:"input.type"})}function I3(i,e){let t=gn(i).resolveInner(e+1);return t.parent&&t.from==e}function Oae(i,e,t,n){let s=gn(i).resolveInner(e,-1),a=n.reduce((r,o)=>Math.max(r,o.length),0);for(let r=0;r<5;r++){let o=i.sliceDoc(s.from,Math.min(s.to,s.from+t.length+a)),c=o.indexOf(t);if(!c||c>-1&&n.indexOf(o.slice(0,c))>-1){let h=s.firstChild;for(;h&&h.from==s.from&&h.to-h.from>t.length+c;){if(i.sliceDoc(h.to-t.length,h.to)==t)return!1;h=h.firstChild}return!0}let d=s.to==e&&s.parent;if(!d)break;s=d}return!1}function W3(i,e,t){let n=i.charCategorizer(e);if(n(i.sliceDoc(e-1,e))!=ei.Word)return e;for(let s of t){let a=e-s.length;if(i.sliceDoc(a,e)==s&&n(i.sliceDoc(a-1,a))!=ei.Word)return a}return-1}function Tae(i={}){return[mae,Fn,Ki.of(i),fae,Mae,gae]}const Kj=[{key:"Ctrl-Space",run:xx},{mac:"Alt-`",run:xx},{mac:"Alt-i",run:xx},{key:"Escape",run:cae},{key:"ArrowDown",run:zm(!0)},{key:"ArrowUp",run:zm(!1)},{key:"PageDown",run:zm(!0,"page")},{key:"PageUp",run:zm(!1,"page")},{key:"Enter",run:lae}],Mae=Wl.highest(wf.computeN([Ki],i=>i.facet(Ki).defaultKeymap?[Kj]:[]));class X3{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}}class hl{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(e,t,n){let s=n.facet($h).markerFilter;s&&(e=s(e,n));let a=e.slice().sort((y,x)=>y.from-x.from||y.to-x.to),r=new vr,o=[],c=0,d=n.doc.iter(),h=0,p=n.doc.length;for(let y=0;;){let x=y==a.length?null:a[y];if(!x&&!o.length)break;let v,w;if(o.length)v=c,w=o.reduce((O,A)=>Math.min(O,A.to),x&&x.from>v?x.from:1e8);else{if(v=x.from,v>p)break;w=x.to,o.push(x),y++}for(;yO.from||O.to==v))o.push(O),y++,w=Math.min(O.to,w);else{w=Math.min(O.from,w);break}}w=Math.min(w,p);let k=!1;if(o.some(O=>O.from==v&&(O.to==w||w==p))&&(k=v==w,!k&&w-v<10)){let O=v-(h+d.value.length);O>0&&(d.next(O),h=v);for(let A=v;;){if(A>=w){k=!0;break}if(!d.lineBreak&&h+d.value.length>A)break;A=h+d.value.length,h+=d.value.length,d.next()}}let M=Hae(o);if(k)r.add(v,v,qe.widget({widget:new Fae(M),diagnostics:o.slice()}));else{let O=o.reduce((A,C)=>C.markClass?A+" "+C.markClass:A,"");r.add(v,w,qe.mark({class:"cm-lintRange cm-lintRange-"+M+O,diagnostics:o.slice(),inclusiveEnd:o.some(A=>A.to>w)}))}if(c=w,c==p)break;for(let O=0;O{if(!(e&&r.diagnostics.indexOf(e)<0))if(!n)n=new X3(s,a,e||r.diagnostics[0]);else{if(r.diagnostics.indexOf(n.diagnostic)<0)return!1;n=new X3(n.from,a,n.diagnostic)}}),n}function Nae(i,e){let t=e.pos,n=e.end||t,s=i.state.facet($h).hideOn(i,t,n);if(s!=null)return s;let a=i.startState.doc.lineAt(e.pos);return!!(i.effects.some(r=>r.is(Vj))||i.changes.touchesRange(a.from,Math.max(a.to,n)))}function Rae(i,e){return i.field(fs,!1)?e:e.concat(Ze.appendConfig.of(Kae))}const Vj=Ze.define(),aS=Ze.define(),Ij=Ze.define(),fs=an.define({create(){return new hl(qe.none,null,null)},update(i,e){if(e.docChanged&&i.diagnostics.size){let t=i.diagnostics.map(e.changes),n=null,s=i.panel;if(i.selected){let a=e.changes.mapPos(i.selected.from,1);n=vu(t,i.selected.diagnostic,a)||vu(t,null,a)}!t.size&&s&&e.state.facet($h).autoPanel&&(s=null),i=new hl(t,s,n)}for(let t of e.effects)if(t.is(Vj)){let n=e.state.facet($h).autoPanel?t.value.length?ef.open:null:i.panel;i=hl.init(t.value,n,e.state)}else t.is(aS)?i=new hl(i.diagnostics,t.value?ef.open:null,i.selected):t.is(Ij)&&(i=new hl(i.diagnostics,i.panel,t.value));return i},provide:i=>[Wh.from(i,e=>e.panel),Ne.decorations.from(i,e=>e.diagnostics)]}),Pae=qe.mark({class:"cm-lintRange cm-lintRange-active"});function Lae(i,e,t){let{diagnostics:n}=i.state.field(fs),s,a=-1,r=-1;n.between(e-(t<0?1:0),e+(t>0?1:0),(c,d,{spec:h})=>{if(e>=c&&e<=d&&(c==d||(e>c||t>0)&&(eXj(i,t,!1)))}const Eae=i=>{let e=i.state.field(fs,!1);(!e||!e.panel)&&i.dispatch({effects:Rae(i.state,[aS.of(!0)])});let t=Ih(i,ef.open);return t&&t.dom.querySelector(".cm-panel-lint ul").focus(),!0},G3=i=>{let e=i.state.field(fs,!1);return!e||!e.panel?!1:(i.dispatch({effects:aS.of(!1)}),!0)},Dae=i=>{let e=i.state.field(fs,!1);if(!e)return!1;let t=i.state.selection.main,n=e.diagnostics.iter(t.to+1);return!n.value&&(n=e.diagnostics.iter(0),!n.value||n.from==t.from&&n.to==t.to)?!1:(i.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0}),!0)},Uae=[{key:"Mod-Shift-m",run:Eae,preventDefault:!0},{key:"F8",run:Dae}],$h=Le.define({combine(i){return z({sources:i.map(e=>e.source).filter(e=>e!=null)},Da(i.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:Q3,tooltipFilter:Q3,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,s,a)=>e(n,s,a)||t(n,s,a):e:t,autoPanel:(e,t)=>e||t}))}});function Q3(i,e){return i?e?(t,n)=>e(i(t,n),n):i:e}function Wj(i){let e=[];if(i)e:for(let{name:t}of i){for(let n=0;na.toLowerCase()==s.toLowerCase())){e.push(s);continue e}}e.push("")}return e}function Xj(i,e,t){var n;let s=t?Wj(e.actions):[];return Ht("li",{class:"cm-diagnostic cm-diagnostic-"+e.severity},Ht("span",{class:"cm-diagnosticText"},e.renderMessage?e.renderMessage(i):e.message),(n=e.actions)===null||n===void 0?void 0:n.map((a,r)=>{let o=!1,c=y=>{if(y.preventDefault(),o)return;o=!0;let x=vu(i.state.field(fs).diagnostics,e);x&&a.apply(i,x.from,x.to)},{name:d}=a,h=s[r]?d.indexOf(s[r]):-1,p=h<0?d:[d.slice(0,h),Ht("u",d.slice(h,h+1)),d.slice(h+1)],_=a.markClass?" "+a.markClass:"";return Ht("button",{type:"button",class:"cm-diagnosticAction"+_,onclick:c,onmousedown:c,"aria-label":` Action: ${d}${h<0?"":` (access key "${s[r]})"`}.`},p)}),e.source&&Ht("div",{class:"cm-diagnosticSource"},e.source))}class Fae extends Ar{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return Ht("span",{class:"cm-lintPoint cm-lintPoint-"+this.sev})}}class Y3{constructor(e,t){this.diagnostic=t,this.id="item_"+Math.floor(Math.random()*4294967295).toString(16),this.dom=Xj(e,t,!0),this.dom.id=this.id,this.dom.setAttribute("role","option")}}class ef{constructor(e){this.view=e,this.items=[];let t=s=>{if(s.keyCode==27)G3(this.view),this.view.focus();else if(s.keyCode==38||s.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(s.keyCode==40||s.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(s.keyCode==36)this.moveSelection(0);else if(s.keyCode==35)this.moveSelection(this.items.length-1);else if(s.keyCode==13)this.view.focus();else if(s.keyCode>=65&&s.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:a}=this.items[this.selectedIndex],r=Wj(a.actions);for(let o=0;o{for(let a=0;aG3(this.view)},"×")),this.update()}get selectedIndex(){let e=this.view.state.field(fs).selected;if(!e)return-1;for(let t=0;t{for(let h of d.diagnostics){if(r.has(h))continue;r.add(h);let p=-1,_;for(let y=n;yn&&(this.items.splice(n,p-n),s=!0)),t&&_.diagnostic==t.diagnostic?_.dom.hasAttribute("aria-selected")||(_.dom.setAttribute("aria-selected","true"),a=_):_.dom.hasAttribute("aria-selected")&&_.dom.removeAttribute("aria-selected"),n++}});n({sel:a.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:o,panel:c})=>{let d=c.height/this.list.offsetHeight;o.topc.bottom&&(this.list.scrollTop+=(o.bottom-c.bottom)/d)}})):this.selectedIndex<0&&this.list.removeAttribute("aria-activedescendant"),s&&this.sync()}sync(){let e=this.list.firstChild;function t(){let n=e;e=n.nextSibling,n.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=this.view.state.field(fs),n=vu(t.diagnostics,this.items[e].diagnostic);n&&this.view.dispatch({selection:{anchor:n.from,head:n.to},scrollIntoView:!0,effects:Ij.of(n)})}static open(e){return new ef(e)}}function Bae(i,e='viewBox="0 0 40 40"'){return`url('data:image/svg+xml,${encodeURIComponent(i)}')`}function qm(i){return Bae(``,'width="6" height="3"')}const zae=Ne.baseTheme({".cm-diagnostic":{padding:"3px 6px 3px 8px",marginLeft:"-1px",display:"block",whiteSpace:"pre-wrap"},".cm-diagnostic-error":{borderLeft:"5px solid #d11"},".cm-diagnostic-warning":{borderLeft:"5px solid orange"},".cm-diagnostic-info":{borderLeft:"5px solid #999"},".cm-diagnostic-hint":{borderLeft:"5px solid #66d"},".cm-diagnosticAction":{font:"inherit",border:"none",padding:"2px 4px",backgroundColor:"#444",color:"white",borderRadius:"3px",marginLeft:"8px",cursor:"pointer"},".cm-diagnosticSource":{fontSize:"70%",opacity:.7},".cm-lintRange":{backgroundPosition:"left bottom",backgroundRepeat:"repeat-x",paddingBottom:"0.7px"},".cm-lintRange-error":{backgroundImage:qm("#d11")},".cm-lintRange-warning":{backgroundImage:qm("orange")},".cm-lintRange-info":{backgroundImage:qm("#999")},".cm-lintRange-hint":{backgroundImage:qm("#66d")},".cm-lintRange-active":{backgroundColor:"#ffdd9980"},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:"relative","&:after":{content:'""',position:"absolute",bottom:0,left:"-2px",borderLeft:"3px solid transparent",borderRight:"3px solid transparent",borderBottom:"4px solid #d11"}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:"orange"}},".cm-lintPoint-info":{"&:after":{borderBottomColor:"#999"}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:"#66d"}},".cm-panel.cm-panel-lint":{position:"relative","& ul":{maxHeight:"100px",overflowY:"auto","& [aria-selected]":{backgroundColor:"#ddd","& u":{textDecoration:"underline"}},"&:focus [aria-selected]":{background_fallback:"#bdf",backgroundColor:"Highlight",color_fallback:"white",color:"HighlightText"},"& u":{textDecoration:"none"},padding:0,margin:0},"& [name=close]":{position:"absolute",top:"0",right:"2px",background:"inherit",border:"none",font:"inherit",padding:0,margin:0}}});function qae(i){return i=="error"?4:i=="warning"?3:i=="info"?2:1}function Hae(i){let e="hint",t=1;for(let n of i){let s=qae(n.severity);s>t&&(t=s,e=n.severity)}return e}const Kae=[fs,Ne.decorations.compute([fs],i=>{let{selected:e,panel:t}=i.field(fs);return!e||!t||e.from==e.to?qe.none:qe.set([Pae.range(e.from,e.to)])}),Fte(Lae,{hideOn:Nae}),zae];var Z3=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(vae)),e.defaultKeymap!==!1&&(n=n.concat(gse)),e.searchKeymap!==!1&&(n=n.concat(Lj)),e.historyKeymap!==!1&&(n=n.concat(wne)),e.foldKeymap!==!1&&(n=n.concat(Uie)),e.completionKeymap!==!1&&(n=n.concat(Kj)),e.lintKeymap!==!1&&(n=n.concat(Uae));var s=[];return e.lineNumbers!==!1&&s.push(Qte()),e.highlightActiveLineGutter!==!1&&s.push(Jte()),e.highlightSpecialChars!==!1&&s.push(fte()),e.history!==!1&&s.push(pne()),e.foldGutter!==!1&&s.push(qie()),e.drawSelection!==!1&&s.push(ite()),e.dropCursor!==!1&&s.push(ote()),e.allowMultipleSelections!==!1&&s.push(ut.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&s.push(Oie()),e.syntaxHighlighting!==!1&&s.push(z5(Iie,{fallback:!0})),e.bracketMatching!==!1&&s.push(Jie()),e.closeBrackets!==!1&&s.push(_ae()),e.autocompletion!==!1&&s.push(Tae()),e.rectangularSelection!==!1&&s.push(Ote()),t!==!1&&s.push(Nte()),e.highlightActiveLine!==!1&&s.push(xte()),e.highlightSelectionMatches!==!1&&s.push(Cj()),e.tabSize&&typeof e.tabSize=="number"&&s.push(q0.of(" ".repeat(e.tabSize))),s.concat([wf.of(n.flat())]).filter(Boolean)};const Vae="#e5c07b",J3="#e06c75",Iae="#56b6c2",Wae="#ffffff",fg="#abb2bf",xv="#7d8799",Xae="#61afef",Gae="#98c379",$3="#d19a66",Qae="#c678dd",Yae="#21252b",eN="#2c313a",tN="#282c34",vx="#353a42",Zae="#3E4451",iN="#528bff",Jae=Ne.theme({"&":{color:fg,backgroundColor:tN},".cm-content":{caretColor:iN},".cm-cursor, .cm-dropCursor":{borderLeftColor:iN},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Zae},".cm-panels":{backgroundColor:Yae,color:fg},".cm-panels.cm-panels-top":{borderBottom:"2px solid black"},".cm-panels.cm-panels-bottom":{borderTop:"2px solid black"},".cm-searchMatch":{backgroundColor:"#72a1ff59",outline:"1px solid #457dff"},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff2f"},".cm-activeLine":{backgroundColor:"#6699ff0b"},".cm-selectionMatch":{backgroundColor:"#aafe661a"},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bad0f847"},".cm-gutters":{backgroundColor:tN,color:xv,border:"none"},".cm-activeLineGutter":{backgroundColor:eN},".cm-foldPlaceholder":{backgroundColor:"transparent",border:"none",color:"#ddd"},".cm-tooltip":{border:"none",backgroundColor:vx},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:"transparent",borderBottomColor:"transparent"},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:vx,borderBottomColor:vx},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:eN,color:fg}}},{dark:!0}),$ae=Cf.define([{tag:le.keyword,color:Qae},{tag:[le.name,le.deleted,le.character,le.propertyName,le.macroName],color:J3},{tag:[le.function(le.variableName),le.labelName],color:Xae},{tag:[le.color,le.constant(le.name),le.standard(le.name)],color:$3},{tag:[le.definition(le.name),le.separator],color:fg},{tag:[le.typeName,le.className,le.number,le.changed,le.annotation,le.modifier,le.self,le.namespace],color:Vae},{tag:[le.operator,le.operatorKeyword,le.url,le.escape,le.regexp,le.link,le.special(le.string)],color:Iae},{tag:[le.meta,le.comment],color:xv},{tag:le.strong,fontWeight:"bold"},{tag:le.emphasis,fontStyle:"italic"},{tag:le.strikethrough,textDecoration:"line-through"},{tag:le.link,color:xv,textDecoration:"underline"},{tag:le.heading,fontWeight:"bold",color:J3},{tag:[le.atom,le.bool,le.special(le.variableName)],color:$3},{tag:[le.processingInstruction,le.string,le.inserted],color:Gae},{tag:le.invalid,color:Wae}]),ere=[Jae,z5($ae)];var tre=Ne.theme({"&":{backgroundColor:"#fff"}},{dark:!1}),ire=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:s=!1,theme:a="light",placeholder:r="",basicSetup:o=!0}=e,c=[];switch(t&&c.unshift(wf.of([_se])),o&&(typeof o=="boolean"?c.unshift(Z3()):c.unshift(Z3(o))),r&&c.unshift(wte(r)),a){case"light":c.push(tre);break;case"dark":c.push(ere);break;case"none":break;default:c.push(a);break}return n===!1&&c.push(Ne.editable.of(!1)),s&&c.push(ut.readOnly.of(!0)),[...c]},nre=i=>({line:i.state.doc.lineAt(i.state.selection.main.from),lineCount:i.state.doc.lines,lineBreak:i.state.lineBreak,length:i.state.doc.length,readOnly:i.state.readOnly,tabSize:i.state.tabSize,selection:i.state.selection,selectionAsSingle:i.state.selection.asSingle().main,ranges:i.state.selection.ranges,selectionCode:i.state.sliceDoc(i.state.selection.main.from,i.state.selection.main.to),selections:i.state.selection.ranges.map(e=>i.state.sliceDoc(e.from,e.to)),selectedText:i.state.selection.ranges.some(e=>!e.empty)});class sre{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(t=>{try{t()}catch(n){console.error("TimeoutLatch callback error:",n)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}}class nN{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}}var Sx=null,are=()=>typeof window=="undefined"?new nN:(Sx||(Sx=new nN),Sx),sN=Ea.define(),rre=200,ore=[];function lre(i){var{value:e,selection:t,onChange:n,onStatistics:s,onCreateEditor:a,onUpdate:r,extensions:o=ore,autoFocus:c,theme:d="light",height:h=null,minHeight:p=null,maxHeight:_=null,width:y=null,minWidth:x=null,maxWidth:v=null,placeholder:w="",editable:k=!0,readOnly:M=!1,indentWithTab:O=!0,basicSetup:A=!0,root:C,initialState:P}=i,[R,E]=N.useState(),[L,D]=N.useState(),[q,B]=N.useState(),H=N.useState(()=>({current:null}))[0],W=N.useState(()=>({current:null}))[0],V=Ne.theme({"&":{height:h,minHeight:p,maxHeight:_,width:y,minWidth:x,maxWidth:v},"& .cm-scroller":{height:"100% !important"}}),U=Ne.updateListener.of(ie=>{if(ie.docChanged&&typeof n=="function"&&!ie.transactions.some(Y=>Y.annotation(sN))){H.current?H.current.reset():(H.current=new sre(()=>{if(W.current){var Y=W.current;W.current=null,Y()}H.current=null},rre),are().add(H.current));var ue=ie.state.doc,F=ue.toString();n(F,ie)}s&&s(nre(ie))}),G=ire({theme:d,editable:k,readOnly:M,placeholder:w,indentWithTab:O,basicSetup:A}),$=[U,V,...G];return r&&typeof r=="function"&&$.push(Ne.updateListener.of(r)),$=$.concat(o),N.useLayoutEffect(()=>{if(R&&!q){var ie={doc:e,selection:t,extensions:$},ue=P?ut.fromJSON(P.json,ie,P.fields):ut.create(ie);if(B(ue),!L){var F=new Ne({state:ue,parent:R,root:C});D(F),a&&a(F,ue)}}return()=>{L&&(B(void 0),D(void 0))}},[R,q]),N.useEffect(()=>{i.container&&E(i.container)},[i.container]),N.useEffect(()=>()=>{L&&(L.destroy(),D(void 0)),H.current&&(H.current.cancel(),H.current=null)},[L]),N.useEffect(()=>{c&&L&&L.focus()},[c,L]),N.useEffect(()=>{L&&L.dispatch({effects:Ze.reconfigure.of($)})},[d,o,h,p,_,y,x,v,w,k,M,O,A,n,r]),N.useEffect(()=>{if(e!==void 0){var ie=L?L.state.doc.toString():"";if(L&&e!==ie){var ue=H.current&&!H.current.isDone,F=()=>{L&&e!==L.state.doc.toString()&&L.dispatch({changes:{from:0,to:L.state.doc.toString().length,insert:e||""},annotations:[sN.of(!0)]})};ue?W.current=F:F()}}},[e,L]),{state:q,setState:B,view:L,setView:D,container:R,setContainer:E}}var cre=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"],Gj=N.forwardRef((i,e)=>{var{className:t,value:n="",selection:s,extensions:a=[],onChange:r,onStatistics:o,onCreateEditor:c,onUpdate:d,autoFocus:h,theme:p="light",height:_,minHeight:y,maxHeight:x,width:v,minWidth:w,maxWidth:k,basicSetup:M,placeholder:O,indentWithTab:A,editable:C,readOnly:P,root:R,initialState:E}=i,L=ZJ(i,cre),D=N.useRef(null),{state:q,view:B,container:H,setContainer:W}=lre({root:R,value:n,autoFocus:h,theme:p,height:_,minHeight:y,maxHeight:x,width:v,minWidth:w,maxWidth:k,basicSetup:M,placeholder:O,indentWithTab:A,editable:C,readOnly:P,selection:s,onChange:r,onStatistics:o,onCreateEditor:c,onUpdate:d,extensions:a,initialState:E});N.useImperativeHandle(e,()=>({editor:D.current,state:q,view:B}),[D,H,q,B]);var V=N.useCallback(G=>{D.current=G,W(G)},[W]);if(typeof n!="string")throw new Error("value must be typeof string but got "+typeof n);var U=typeof p=="string"?"cm-theme-"+p:"cm-theme";return g.jsx("div",vb({ref:V,className:""+U+(t?" "+t:"")},L))});Gj.displayName="CodeMirror";var aN={};class l0{constructor(e,t,n,s,a,r,o,c,d,h=0,p){this.p=e,this.stack=t,this.state=n,this.reducePos=s,this.pos=a,this.score=r,this.buffer=o,this.bufferBase=c,this.curContext=d,this.lookAhead=h,this.parent=p}toString(){return`[${this.stack.filter((e,t)=>t%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,t,n=0){let s=e.parser.context;return new l0(e,[],t,n,n,0,[],0,s?new rN(s,s.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,t){this.stack.push(this.state,t,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var t;let n=e>>19,s=e&65535,{parser:a}=this.p,r=this.reducePos=2e3&&!(!((t=this.p.parser.nodeSet.types[s])===null||t===void 0)&&t.isAnonymous)&&(d==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=h):this.p.lastBigReductionSizec;)this.stack.pop();this.reduceContext(s,d)}storeNode(e,t,n,s=4,a=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]0&&r.buffer[o-4]==0&&r.buffer[o-1]>-1){if(t==n)return;if(r.buffer[o-2]>=t){r.buffer[o-2]=n;return}}}if(!a||this.pos==n)this.buffer.push(e,t,n,s);else{let r=this.buffer.length;if(r>0&&(this.buffer[r-4]!=0||this.buffer[r-1]<0)){let o=!1;for(let c=r;c>0&&this.buffer[c-2]>n;c-=4)if(this.buffer[c-1]>=0){o=!0;break}if(o)for(;r>0&&this.buffer[r-2]>n;)this.buffer[r]=this.buffer[r-4],this.buffer[r+1]=this.buffer[r-3],this.buffer[r+2]=this.buffer[r-2],this.buffer[r+3]=this.buffer[r-1],r-=4,s>4&&(s-=4)}this.buffer[r]=e,this.buffer[r+1]=t,this.buffer[r+2]=n,this.buffer[r+3]=s}}shift(e,t,n,s){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let a=e,{parser:r}=this.p;(s>this.pos||t<=r.maxNode)&&(this.pos=s,r.stateFlag(a,1)||(this.reducePos=s)),this.pushState(a,n),this.shiftContext(t,n),t<=r.maxNode&&this.buffer.push(t,n,s,4)}else this.pos=s,this.shiftContext(t,n),t<=this.p.parser.maxNode&&this.buffer.push(t,n,s,4)}apply(e,t,n,s){e&65536?this.reduce(e):this.shift(e,t,n,s)}useNode(e,t){let n=this.p.reused.length-1;(n<0||this.p.reused[n]!=e)&&(this.p.reused.push(e),n++);let s=this.pos;this.reducePos=this.pos=s+e.length,this.pushState(t,s),this.buffer.push(n,s,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,t=e.buffer.length;for(;t>0&&e.buffer[t-2]>e.reducePos;)t-=4;let n=e.buffer.slice(t),s=e.bufferBase+t;for(;e&&s==e.bufferBase;)e=e.parent;return new l0(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,n,s,this.curContext,this.lookAhead,e)}recoverByDelete(e,t){let n=e<=this.p.parser.maxNode;n&&this.storeNode(e,this.pos,t,4),this.storeNode(0,this.pos,t,n?8:4),this.pos=this.reducePos=t,this.score-=190}canShift(e){for(let t=new ure(this);;){let n=this.p.parser.stateSlot(t.state,4)||this.p.parser.hasAction(t.state,e);if(n==0)return!1;if((n&65536)==0)return!0;t.reduce(n)}}recoverByInsert(e){if(this.stack.length>=300)return[];let t=this.p.parser.nextStates(this.state);if(t.length>8||this.stack.length>=120){let s=[];for(let a=0,r;ac&1&&o==r)||s.push(t[a],r)}t=s}let n=[];for(let s=0;s>19,s=t&65535,a=this.stack.length-n*3;if(a<0||e.getGoto(this.stack[a],s,!1)<0){let r=this.findForcedReduction();if(r==null)return!1;t=r}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(t),!0}findForcedReduction(){let{parser:e}=this.p,t=[],n=(s,a)=>{if(!t.includes(s))return t.push(s),e.allActions(s,r=>{if(!(r&393216))if(r&65536){let o=(r>>19)-a;if(o>1){let c=r&65535,d=this.stack.length-o*3;if(d>=0&&e.getGoto(this.stack[d],c,!1)>=0)return o<<19|65536|c}}else{let o=n(r,a+1);if(o!=null)return o}})};return n(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let t=0;t0&&this.emitLookAhead()}}class rN{constructor(e,t){this.tracker=e,this.context=t,this.hash=e.strict?e.hash(t):0}}class ure{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let t=e&65535,n=e>>19;n==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(n-1)*3;let s=this.start.p.parser.getGoto(this.stack[this.base-3],t,!0);this.state=s}}class c0{constructor(e,t,n){this.stack=e,this.pos=t,this.index=n,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,t=e.bufferBase+e.buffer.length){return new c0(e,t,t-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new c0(this.stack,this.pos,this.index)}}function Hm(i,e=Uint16Array){if(typeof i!="string")return i;let t=null;for(let n=0,s=0;n=92&&r--,r>=34&&r--;let c=r-32;if(c>=46&&(c-=46,o=!0),a+=c,o)break;a*=46}t?t[s++]=a:t=new e(a)}return t}class pg{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const oN=new pg;class dre{constructor(e,t){this.input=e,this.ranges=t,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=oN,this.rangeIndex=0,this.pos=this.chunkPos=t[0].from,this.range=t[0],this.end=t[t.length-1].to,this.readNext()}resolveOffset(e,t){let n=this.range,s=this.rangeIndex,a=this.pos+e;for(;an.to:a>=n.to;){if(s==this.ranges.length-1)return null;let r=this.ranges[++s];a+=r.from-n.to,n=r}return a}clipPos(e){if(e>=this.range.from&&ee)return Math.max(e,t.from);return this.end}peek(e){let t=this.chunkOff+e,n,s;if(t>=0&&t=this.chunk2Pos&&no.to&&(this.chunk2=this.chunk2.slice(0,o.to-n)),s=this.chunk2.charCodeAt(0)}}return n>=this.token.lookAhead&&(this.token.lookAhead=n+1),s}acceptToken(e,t=0){let n=t?this.resolveOffset(t,-1):this.pos;if(n==null||n=this.chunk2Pos&&this.posthis.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,t){if(t?(this.token=t,t.start=e,t.lookAhead=e+1,t.value=t.extended=-1):this.token=oN,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e=this.chunkPos&&t<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,t-this.chunkPos);if(e>=this.chunk2Pos&&t<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,t-this.chunk2Pos);if(e>=this.range.from&&t<=this.range.to)return this.input.read(e,t);let n="";for(let s of this.ranges){if(s.from>=t)break;s.to>e&&(n+=this.input.read(Math.max(s.from,e),Math.min(s.to,t)))}return n}}class nu{constructor(e,t){this.data=e,this.id=t}token(e,t){let{parser:n}=t.p;hre(this.data,e,t,this.id,n.data,n.tokenPrecTable)}}nu.prototype.contextual=nu.prototype.fallback=nu.prototype.extend=!1;nu.prototype.fallback=nu.prototype.extend=!1;class Q0{constructor(e,t={}){this.token=e,this.contextual=!!t.contextual,this.fallback=!!t.fallback,this.extend=!!t.extend}}function hre(i,e,t,n,s,a){let r=0,o=1<0){let x=i[y];if(c.allows(x)&&(e.token.value==-1||e.token.value==x||fre(x,e.token.value,s,a))){e.acceptToken(x);break}}let h=e.next,p=0,_=i[r+2];if(e.next<0&&_>p&&i[d+_*3-3]==65535){r=i[d+_*3-1];continue e}for(;p<_;){let y=p+_>>1,x=d+y+(y<<1),v=i[x],w=i[x+1]||65536;if(h=w)p=y+1;else{r=i[x+2],e.advance();continue e}}break}}function lN(i,e,t){for(let n=e,s;(s=i[n])!=65535;n++)if(s==t)return n-e;return-1}function fre(i,e,t,n){let s=lN(t,n,e);return s<0||lN(t,n,i)e)&&!n.type.isError)return t<0?Math.max(0,Math.min(n.to-1,e-25)):Math.min(i.length,Math.max(n.from+1,e+25));if(t<0?n.prevSibling():n.nextSibling())break;if(!n.parent())return t<0?0:i.length}}class pre{constructor(e,t){this.fragments=e,this.nodeSet=t,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?cN(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?cN(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(ee)return this.nextStart=r,null;if(a instanceof Ri){if(r==e){if(r=Math.max(this.safeFrom,e)&&(this.trees.push(a),this.start.push(r),this.index.push(0))}else this.index[t]++,this.nextStart=r+a.length}}}class mre{constructor(e,t){this.stream=t,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(n=>new pg)}getActions(e){let t=0,n=null,{parser:s}=e.p,{tokenizers:a}=s,r=s.stateSlot(e.state,3),o=e.curContext?e.curContext.hash:0,c=0;for(let d=0;dp.end+25&&(c=Math.max(p.lookAhead,c)),p.value!=0)){let _=t;if(p.extended>-1&&(t=this.addActions(e,p.extended,p.end,t)),t=this.addActions(e,p.value,p.end,t),!h.extend&&(n=p,t>_))break}}for(;this.actions.length>t;)this.actions.pop();return c&&e.setLookAhead(c),!n&&e.pos==this.stream.end&&(n=new pg,n.value=e.p.parser.eofTerm,n.start=n.end=e.pos,t=this.addActions(e,n.value,n.end,t)),this.mainToken=n,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let t=new pg,{pos:n,p:s}=e;return t.start=n,t.end=Math.min(n+1,s.stream.end),t.value=n==s.stream.end?s.parser.eofTerm:0,t}updateCachedToken(e,t,n){let s=this.stream.clipPos(n.pos);if(t.token(this.stream.reset(s,e),n),e.value>-1){let{parser:a}=n.p;for(let r=0;r=0&&n.p.parser.dialect.allows(o>>1)){(o&1)==0?e.value=o>>1:e.extended=o>>1;break}}}else e.value=0,e.end=this.stream.clipPos(s+1)}putAction(e,t,n,s){for(let a=0;ae.bufferLength*4?new pre(n,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,t=this.minStackPos,n=this.stacks=[],s,a;if(this.bigReductionCount>300&&e.length==1){let[r]=e;for(;r.forceReduce()&&r.stack.length&&r.stack[r.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let r=0;rt)n.push(o);else{if(this.advanceStack(o,n,e))continue;{s||(s=[],a=[]),s.push(o);let c=this.tokens.getMainToken(o);a.push(c.value,c.end)}}break}}if(!n.length){let r=s&&xre(s);if(r)return os&&console.log("Finish with "+this.stackID(r)),this.stackToTree(r);if(this.parser.strict)throw os&&s&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+t);this.recovering||(this.recovering=5)}if(this.recovering&&s){let r=this.stoppedAt!=null&&s[0].pos>this.stoppedAt?s[0]:this.runRecovery(s,a,n);if(r)return os&&console.log("Force-finish "+this.stackID(r)),this.stackToTree(r.forceAll())}if(this.recovering){let r=this.recovering==1?1:this.recovering*3;if(n.length>r)for(n.sort((o,c)=>c.score-o.score);n.length>r;)n.pop();n.some(o=>o.reducePos>t)&&this.recovering--}else if(n.length>1){e:for(let r=0;r500&&d.buffer.length>500)if((o.score-d.score||o.buffer.length-d.buffer.length)>0)n.splice(c--,1);else{n.splice(r--,1);continue e}}}n.length>12&&n.splice(12,n.length-12)}this.minStackPos=n[0].pos;for(let r=1;r ":"";if(this.stoppedAt!=null&&s>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let d=e.curContext&&e.curContext.tracker.strict,h=d?e.curContext.hash:0;for(let p=this.fragments.nodeAt(s);p;){let _=this.parser.nodeSet.types[p.type.id]==p.type?a.getGoto(e.state,p.type.id):-1;if(_>-1&&p.length&&(!d||(p.prop(nt.contextHash)||0)==h))return e.useNode(p,_),os&&console.log(r+this.stackID(e)+` (via reuse of ${a.getName(p.type.id)})`),!0;if(!(p instanceof Ri)||p.children.length==0||p.positions[0]>0)break;let y=p.children[0];if(y instanceof Ri&&p.positions[0]==0)p=y;else break}}let o=a.stateSlot(e.state,4);if(o>0)return e.reduce(o),os&&console.log(r+this.stackID(e)+` (via always-reduce ${a.getName(o&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let c=this.tokens.getActions(e);for(let d=0;ds?t.push(x):n.push(x)}return!1}advanceFully(e,t){let n=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>n)return uN(e,t),!0}}runRecovery(e,t,n){let s=null,a=!1;for(let r=0;r ":"";if(o.deadEnd&&(a||(a=!0,o.restart(),os&&console.log(h+this.stackID(o)+" (restarted)"),this.advanceFully(o,n))))continue;let p=o.split(),_=h;for(let y=0;y<10&&p.forceReduce()&&(os&&console.log(_+this.stackID(p)+" (via force-reduce)"),!this.advanceFully(p,n));y++)os&&(_=this.stackID(p)+" -> ");for(let y of o.recoverByInsert(c))os&&console.log(h+this.stackID(y)+" (via recover-insert)"),this.advanceFully(y,n);this.stream.end>o.pos?(d==o.pos&&(d++,c=0),o.recoverByDelete(c,d),os&&console.log(h+this.stackID(o)+` (via recover-delete ${this.parser.getName(c)})`),uN(o,n)):(!s||s.scorei;class yre{constructor(e){this.start=e.start,this.shift=e.shift||kx,this.reduce=e.reduce||kx,this.reuse=e.reuse||kx,this.hash=e.hash||(()=>0),this.strict=e.strict!==!1}}class u0 extends w5{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let t=e.nodeNames.split(" ");this.minRepeatTerm=t.length;for(let o=0;oe.topRules[o][1]),s=[];for(let o=0;o=0)a(h,c,o[d++]);else{let p=o[d+-h];for(let _=-h;_>0;_--)a(o[d++],c,p);d++}}}this.nodeSet=new K2(t.map((o,c)=>Yn.define({name:c>=this.minRepeatTerm?void 0:o,id:c,props:s[c],top:n.indexOf(c)>-1,error:c==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(c)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=x5;let r=Hm(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let o=0;otypeof o=="number"?new nu(r,o):o),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,t,n){let s=new gre(this,e,t,n);for(let a of this.wrappers)s=a(s,e,t,n);return s}getGoto(e,t,n=!1){let s=this.goto;if(t>=s[0])return-1;for(let a=s[t+1];;){let r=s[a++],o=r&1,c=s[a++];if(o&&n)return c;for(let d=a+(r>>1);a0}validAction(e,t){return!!this.allActions(e,n=>n==t?!0:null)}allActions(e,t){let n=this.stateSlot(e,4),s=n?t(n):void 0;for(let a=this.stateSlot(e,1);s==null;a+=3){if(this.data[a]==65535)if(this.data[a+1]==1)a=ur(this.data,a+2);else break;s=t(ur(this.data,a+1))}return s}nextStates(e){let t=[];for(let n=this.stateSlot(e,1);;n+=3){if(this.data[n]==65535)if(this.data[n+1]==1)n=ur(this.data,n+2);else break;if((this.data[n+2]&1)==0){let s=this.data[n+1];t.some((a,r)=>r&1&&a==s)||t.push(this.data[n],s)}}return t}configure(e){let t=Object.assign(Object.create(u0.prototype),this);if(e.props&&(t.nodeSet=this.nodeSet.extend(...e.props)),e.top){let n=this.topRules[e.top];if(!n)throw new RangeError(`Invalid top rule name ${e.top}`);t.top=n}return e.tokenizers&&(t.tokenizers=this.tokenizers.map(n=>{let s=e.tokenizers.find(a=>a.from==n);return s?s.to:n})),e.specializers&&(t.specializers=this.specializers.slice(),t.specializerSpecs=this.specializerSpecs.map((n,s)=>{let a=e.specializers.find(o=>o.from==n.external);if(!a)return n;let r=Object.assign(Object.assign({},n),{external:a.to});return t.specializers[s]=dN(r),r})),e.contextTracker&&(t.context=e.contextTracker),e.dialect&&(t.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(t.strict=e.strict),e.wrap&&(t.wrappers=t.wrappers.concat(e.wrap)),e.bufferLength!=null&&(t.bufferLength=e.bufferLength),t}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let t=this.dynamicPrecedences;return t==null?0:t[e]||0}parseDialect(e){let t=Object.keys(this.dialects),n=t.map(()=>!1);if(e)for(let a of e.split(" ")){let r=t.indexOf(a);r>=0&&(n[r]=!0)}let s=null;for(let a=0;an)&&t.p.parser.stateFlag(t.state,2)&&(!e||e.scorei.external(t,n)<<1|e}return i.get}const Fc=63,hN=64,bre=1,vre=2,Qj=3,Sre=4,Yj=5,wre=6,kre=7,Zj=65,Are=66,Cre=8,Ore=9,Tre=10,Mre=11,Nre=12,Jj=13,Rre=19,Pre=20,Lre=29,jre=33,Ere=34,Dre=47,Ure=0,rS=1,bv=2,tf=3,vv=4;class fl{constructor(e,t,n){this.parent=e,this.depth=t,this.type=n,this.hash=(e?e.hash+e.hash<<8:0)+t+(t<<4)+n}}fl.top=new fl(null,-1,Ure);function bh(i,e){for(let t=0,n=e-i.pos-1;;n--,t++){let s=i.peek(n);if(kr(s)||s==-1)return t}}function Sv(i){return i==32||i==9}function kr(i){return i==10||i==13}function $j(i){return Sv(i)||kr(i)}function wl(i){return i<0||$j(i)}const Fre=new yre({start:fl.top,reduce(i,e){return i.type==tf&&(e==Pre||e==Ere)?i.parent:i},shift(i,e,t,n){if(e==Qj)return new fl(i,bh(n,n.pos),rS);if(e==Zj||e==Yj)return new fl(i,bh(n,n.pos),bv);if(e==Fc)return i.parent;if(e==Rre||e==jre)return new fl(i,0,tf);if(e==Jj&&i.type==vv)return i.parent;if(e==Dre){let s=/[1-9]/.exec(n.read(n.pos,t.pos));if(s)return new fl(i,i.depth+ +s[0],vv)}return i},hash(i){return i.hash}});function Su(i,e,t=0){return i.peek(t)==e&&i.peek(t+1)==e&&i.peek(t+2)==e&&wl(i.peek(t+3))}const Bre=new Q0((i,e)=>{if(i.next==-1&&e.canShift(hN))return i.acceptToken(hN);let t=i.peek(-1);if((kr(t)||t<0)&&e.context.type!=tf){if(Su(i,45))if(e.canShift(Fc))i.acceptToken(Fc);else return i.acceptToken(bre,3);if(Su(i,46))if(e.canShift(Fc))i.acceptToken(Fc);else return i.acceptToken(vre,3);let n=0;for(;i.next==32;)n++,i.advance();(n{if(e.context.type==tf){i.next==63&&(i.advance(),wl(i.next)&&i.acceptToken(kre));return}if(i.next==45)i.advance(),wl(i.next)&&i.acceptToken(e.context.type==rS&&e.context.depth==bh(i,i.pos-1)?Sre:Qj);else if(i.next==63)i.advance(),wl(i.next)&&i.acceptToken(e.context.type==bv&&e.context.depth==bh(i,i.pos-1)?wre:Yj);else{let t=i.pos;for(;;)if(Sv(i.next)){if(i.pos==t)return;i.advance()}else if(i.next==33)eE(i);else if(i.next==38)wv(i);else if(i.next==42){wv(i);break}else if(i.next==39||i.next==34){if(oS(i,!0))break;return}else if(i.next==91||i.next==123){if(!Hre(i))return;break}else{tE(i,!0,!1,0);break}for(;Sv(i.next);)i.advance();if(i.next==58){if(i.pos==t&&e.canShift(Lre))return;let n=i.peek(1);wl(n)&&i.acceptTokenTo(e.context.type==bv&&e.context.depth==bh(i,t)?Are:Zj,t)}}},{contextual:!0});function qre(i){return i>32&&i<127&&i!=34&&i!=37&&i!=44&&i!=60&&i!=62&&i!=92&&i!=94&&i!=96&&i!=123&&i!=124&&i!=125}function fN(i){return i>=48&&i<=57||i>=97&&i<=102||i>=65&&i<=70}function pN(i,e){return i.next==37?(i.advance(),fN(i.next)&&i.advance(),fN(i.next)&&i.advance(),!0):qre(i.next)||e&&i.next==44?(i.advance(),!0):!1}function eE(i){if(i.advance(),i.next==60){for(i.advance();;)if(!pN(i,!0)){i.next==62&&i.advance();break}}else for(;pN(i,!1););}function wv(i){for(i.advance();!wl(i.next)&&d0(i.tag)!="f";)i.advance()}function oS(i,e){let t=i.next,n=!1,s=i.pos;for(i.advance();;){let a=i.next;if(a<0)break;if(i.advance(),a==t)if(a==39)if(i.next==39)i.advance();else break;else break;else if(a==92&&t==34)i.next>=0&&i.advance();else if(kr(a)){if(e)return!1;n=!0}else if(e&&i.pos>=s+1024)return!1}return!n}function Hre(i){for(let e=[],t=i.pos+1024;;)if(i.next==91||i.next==123)e.push(i.next),i.advance();else if(i.next==39||i.next==34){if(!oS(i,!0))return!1}else if(i.next==93||i.next==125){if(e[e.length-1]!=i.next-2)return!1;if(e.pop(),i.advance(),!e.length)return!0}else{if(i.next<0||i.pos>t||kr(i.next))return!1;i.advance()}}const Kre="iiisiiissisfissssssssssssisssiiissssssssssssssssssssssssssfsfssissssssssssssssssssssssssssfif";function d0(i){return i<33?"u":i>125?"s":Kre[i-33]}function Ax(i,e){let t=d0(i);return t!="u"&&!(e&&t=="f")}function tE(i,e,t,n){if(d0(i.next)=="s"||(i.next==63||i.next==58||i.next==45)&&Ax(i.peek(1),t))i.advance();else return!1;let s=i.pos;for(;;){let a=i.next,r=0,o=n+1;for(;$j(a);){if(kr(a)){if(e)return!1;o=0}else o++;a=i.peek(++r)}if(!(a>=0&&(a==58?Ax(i.peek(r+1),t):a==35?i.peek(r-1)!=32:Ax(a,t)))||!t&&o<=n||o==0&&!t&&(Su(i,45,r)||Su(i,46,r)))break;if(e&&d0(a)=="f")return!1;for(let d=r;d>=0;d--)i.advance();if(e&&i.pos>s+1024)return!1}return!0}const Vre=new Q0((i,e)=>{if(i.next==33)eE(i),i.acceptToken(Nre);else if(i.next==38||i.next==42){let t=i.next==38?Tre:Mre;wv(i),i.acceptToken(t)}else i.next==39||i.next==34?(oS(i,!1),i.acceptToken(Ore)):tE(i,!1,e.context.type==tf,e.context.depth)&&i.acceptToken(Cre)}),Ire=new Q0((i,e)=>{let t=e.context.type==vv?e.context.depth:-1,n=i.pos;e:for(;;){let s=0,a=i.next;for(;a==32;)a=i.peek(++s);if(!s&&(Su(i,45,s)||Su(i,46,s))||!kr(a)&&(t<0&&(t=Math.max(e.context.depth+1,s)),sYAN>Y",stateData:";S~O!fOS!gOS^OS~OP_OQbORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!V[O!cTO~O`cO~P]OVkOWROXROYeOZfO[dOcPOmhOqQO~OboO~P!bOVtOWROXROYeOZfO[dOcPOmrOqQO~OpwO~P#WORSOTUOWROXROYYOZZO[XOcPOqQO!PVO!cTO~OSvP!avP!bvP~P#|OWROXROYeOZfO[dOcPOqQO~OmzO~P%OOm!OOUzP!azP!bzP!dzP~P#|O^!SO!b!QO!f!TO!g!RO~ORSOTUOWROXROcPOqQO!PVO!cTO~OY!UOP!QXQ!QX!V!QX!`!QXS!QX!a!QX!b!QXU!QXm!QX!d!QX~P&aO[!WOP!SXQ!SX!V!SX!`!SXS!SX!a!SX!b!SXU!SXm!SX!d!SX~P&aO^!ZO!W![O!b!YO!f!]O!g!YO~OP!_O!V[OQaX!`aX~OPaXQaX!VaX!`aX~P#|OP!bOQ!cO!V[O~OP_O!V[O~P#|OWROXROY!fOcPOqQObfXmfXofXpfX~OWROXRO[!hOcPOqQObhXmhXohXphX~ObeXmlXoeX~ObkXokX~P%OOm!kO~Om!lObnPonP~P%OOb!pOo!oO~Ob!pO~P!bOm!sOosXpsX~OosXpsX~P%OOm!uOotPptP~P%OOo!xOp!yO~Op!yO~P#WOS!|O!a#OO!b#OO~OUyX!ayX!byX!dyX~P#|Om#QO~OU#SO!a#UO!b#UO!d#RO~Om#WOUzX!azX!bzX!dzX~O]#XO~O!b#XO!g#YO~O^#ZO!b#XO!g#YO~OP!RXQ!RX!V!RX!`!RXS!RX!a!RX!b!RXU!RXm!RX!d!RX~P&aOP!TXQ!TX!V!TX!`!TXS!TX!a!TX!b!TXU!TXm!TX!d!TX~P&aO!b#^O!g#^O~O^#_O!b#^O!f#`O!g#^O~O^#_O!W#aO!b#^O!g#^O~OPaaQaa!Vaa!`aa~P#|OP#cO!V[OQ!XX!`!XX~OP!XXQ!XX!V!XX!`!XX~P#|OP_O!V[OQ!_X!`!_X~P#|OWROXROcPOqQObgXmgXogXpgX~OWROXROcPOqQObiXmiXoiXpiX~Obkaoka~P%OObnXonX~P%OOm#kO~Ob#lOo!oO~Oosapsa~P%OOotXptX~P%OOm#pO~Oo!xOp#qO~OSwP!awP!bwP~P#|OS!|O!a#vO!b#vO~OUya!aya!bya!dya~P#|Om#xO~P%OOm#{OU}P!a}P!b}P!d}P~P#|OU#SO!a$OO!b$OO!d#RO~O]$QO~O!b$QO!g$RO~O!b$SO!g$SO~O^$TO!b$SO!g$SO~O^$TO!b$SO!f$UO!g$SO~OP!XaQ!Xa!V!Xa!`!Xa~P#|Obnaona~P%OOotapta~P%OOo!xO~OU|X!a|X!b|X!d|X~P#|Om$ZO~Om$]OU}X!a}X!b}X!d}X~O]$^O~O!b$_O!g$_O~O^$`O!b$_O!g$_O~OU|a!a|a!b|a!d|a~P#|O!b$cO!g$cO~O",goto:",]!mPPPPPPPPPPPPPPPPP!nPP!v#v#|$`#|$c$f$j$nP%VPPP!v%Y%^%a%{&O%a&R&U&X&_&b%aP&e&{&e'O'RPP']'a'g'm's'y(XPPPPPPPP(_)e*X+c,VUaObcR#e!c!{ROPQSTUXY_bcdehknrtvz!O!U!W!_!b!c!f!h!k!l!s!u!|#Q#R#S#W#c#k#p#x#{$Z$]QmPR!qnqfPQThknrtv!k!l!s!u#R#k#pR!gdR!ieTlPnTjPnSiPnSqQvQ{TQ!mkQ!trQ!vtR#y#RR!nkTsQvR!wt!RWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]RySR#t!|R|TR|UQ!PUR#|#SR#z#RR#z#SyZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]R!VXR!XYa]O^abc!a!c!eT!da!eQnPR!rnQvQR!{vQ!}yR#u!}Q#T|R#}#TW^Obc!cS!^^!aT!aa!eQ!eaR#f!eW`Obc!cQxSS}U#SQ!`_Q#PzQ#V!OQ#b!_Q#d!bQ#s!|Q#w#QQ$P#WQ$V#cQ$Y#xQ$[#{Q$a$ZR$b$]xZOSU_bcz!O!_!b!c!|#Q#S#W#c#x#{$Z$]Q!VXQ!XYQ#[!UR#]!W!QWOSUXY_bcz!O!U!W!_!b!c!|#Q#S#W#c#x#{$Z$]pfPQThknrtv!k!l!s!u#R#k#pQ!gdQ!ieQ#g!fR#h!hSgPn^pQTkrtv#RQ!jhQ#i!kQ#j!lQ#n!sQ#o!uQ$W#kR$X#pQuQR!zv",nodeNames:"⚠ DirectiveEnd DocEnd - - ? ? ? Literal QuotedLiteral Anchor Alias Tag BlockLiteralContent Comment Stream BOM Document ] [ FlowSequence Item Tagged Anchored Anchored Tagged FlowMapping Pair Key : Pair , } { FlowMapping Pair Pair BlockSequence Item Item BlockMapping Pair Pair Key Pair Pair BlockLiteral BlockLiteralHeader Tagged Anchored Anchored Tagged Directive DirectiveName DirectiveContent Document",maxTerm:74,context:Fre,nodeProps:[["isolate",-3,8,9,14,""],["openedBy",18,"[",32,"{"],["closedBy",19,"]",33,"}"]],propSources:[Wre],skippedNodes:[0],repeatNodeCount:6,tokenData:"-Y~RnOX#PXY$QYZ$]Z]#P]^$]^p#Ppq$Qqs#Pst$btu#Puv$yv|#P|}&e}![#P![!]'O!]!`#P!`!a'i!a!}#P!}#O*g#O#P#P#P#Q+Q#Q#o#P#o#p+k#p#q'i#q#r,U#r;'S#P;'S;=`#z<%l?HT#P?HT?HU,o?HUO#PQ#UU!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PQ#kTOY#PZs#Pt;'S#P;'S;=`#z<%lO#PQ#}P;=`<%l#P~$VQ!f~XY$Qpq$Q~$bO!g~~$gS^~OY$bZ;'S$b;'S;=`$s<%lO$b~$vP;=`<%l$bR%OX!WQOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR%rX!WQ!VPOX%kXY#PZ]%k]^#P^p%kpq#hq;'S%k;'S;=`&_<%lO%kR&bP;=`<%l%kR&lUoP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'VUmP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR'p[!PP!WQOY#PZp#Ppq#hq{#P{|(f|}#P}!O(f!O!R#P!R![)p![;'S#P;'S;=`#z<%lO#PR(mW!PP!WQOY#PZp#Ppq#hq!R#P!R![)V![;'S#P;'S;=`#z<%lO#PR)^U!PP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR)wY!PP!WQOY#PZp#Ppq#hq{#P{|)V|}#P}!O)V!O;'S#P;'S;=`#z<%lO#PR*nUcP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+XUbP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR+rUqP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,]UpP!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#PR,vU`P!WQOY#PZp#Ppq#hq;'S#P;'S;=`#z<%lO#P",tokenizers:[Bre,zre,Vre,Ire,0,1],topRules:{Stream:[0,15]},tokenPrec:0}),Gre=Qg.define({name:"yaml",parser:Xre.configure({props:[T5.add({Stream:i=>{for(let e=i.node.resolve(i.pos,-1);e&&e.to>=i.pos;e=e.parent){if(e.name=="BlockLiteralContent"&&e.fromi.pos)return null}}return null},FlowMapping:v3({closing:"}"}),FlowSequence:v3({closing:"]"})}),R5.add({"FlowMapping FlowSequence":Mie,"Item Pair BlockLiteral":(i,e)=>({from:e.doc.lineAt(i.from).to,to:i.to})})]}),languageData:{commentTokens:{line:"#"},indentOnInput:/^\s*[\]\}]$/}});function Qre(){return new yie(Gre)}const Yre="ConfigPage-module__container___5kN-Y",Zre="ConfigPage-module__pageTitle___BoVLE",Jre="ConfigPage-module__description___qruwQ",$re="ConfigPage-module__content___PgFbt",eoe="ConfigPage-module__searchInputWrapper___-GeEQ",toe="ConfigPage-module__searchInput___ock8o",ioe="ConfigPage-module__searchCount___AIry7",noe="ConfigPage-module__searchRight___pwWBV",soe="ConfigPage-module__searchButton___GRbfi",aoe="ConfigPage-module__searchActions___ZGITa",roe="ConfigPage-module__controls___OTpD4",ooe="ConfigPage-module__status___QYXYr",loe="ConfigPage-module__modified___4mzgT",coe="ConfigPage-module__saved___zmZx2",uoe="ConfigPage-module__error___qlpX1",doe="ConfigPage-module__editorWrapper___yBudn",hoe="ConfigPage-module__floatingControls___RqBnu",foe="ConfigPage-module__configCard___DdVq0",poe="ConfigPage-module__actions___4RDYM",Ei={container:Yre,pageTitle:Zre,description:Jre,content:$re,searchInputWrapper:eoe,searchInput:toe,searchCount:ioe,searchRight:noe,searchButton:soe,searchActions:aoe,controls:roe,status:ooe,modified:loe,saved:coe,error:uoe,editorWrapper:doe,floatingControls:hoe,configCard:foe,actions:poe};function moe(){const{t:i}=rt(),{showNotification:e}=Zn(),t=Ct(ue=>ue.connectionStatus),n=_r(ue=>ue.resolvedTheme),[s,a]=N.useState(""),[r,o]=N.useState(!0),[c,d]=N.useState(!1),[h,p]=N.useState(""),[_,y]=N.useState(!1),[x,v]=N.useState(""),[w,k]=N.useState({current:0,total:0}),[M,O]=N.useState(""),A=N.useRef(null),C=N.useRef(null),P=N.useRef(null),R=t!=="connected",E=N.useCallback(()=>pe(null,null,function*(){o(!0),p("");try{const ue=yield lb.fetchConfigYaml();a(ue),y(!1)}catch(ue){const F=ue instanceof Error?ue.message:i("notification.refresh_failed");p(F)}finally{o(!1)}}),[i]);N.useEffect(()=>{E()},[E]);const L=()=>pe(null,null,function*(){d(!0);try{yield lb.saveConfigYaml(s),y(!1),e(i("config_management.save_success"),"success")}catch(ue){const F=ue instanceof Error?ue.message:"";e(`${i("notification.save_failed")}: ${F}`,"error")}finally{d(!1)}}),D=N.useCallback(ue=>{a(ue),y(!0)},[]),q=N.useCallback((ue,F="next")=>{var Pi;if(!ue||!((Pi=A.current)!=null&&Pi.view))return;const Y=A.current.view,ce=Y.state.doc.toString(),J=[],me=ue.toLowerCase(),Se=ce.toLowerCase();let Re=0;for(;ReKe){it=ft;break}ft===J.length-1&&(it=0)}else for(let ft=J.length-1;ft>=0;ft--){if(J[ft]{v(ue),ue?k({current:0,total:0}):(k({current:0,total:0}),O(""))},[]),H=N.useCallback((ue="next")=>{x&&(O(x),q(x,ue))},[x,q]),W=N.useCallback(ue=>{ue.key==="Enter"&&(ue.preventDefault(),H(ue.shiftKey?"prev":"next"))},[H]),V=N.useCallback(()=>{M&&q(M,"prev")},[M,q]),U=N.useCallback(()=>{M&&q(M,"next")},[M,q]);N.useLayoutEffect(()=>{const ue=C.current,F=P.current;if(!ue||!F)return;const Y=()=>{const J=ue.getBoundingClientRect().height;F.style.setProperty("--floating-controls-height",`${J}px`)};Y(),window.addEventListener("resize",Y);const ce=typeof ResizeObserver=="undefined"?null:new ResizeObserver(Y);return ce==null||ce.observe(ue),()=>{ce==null||ce.disconnect(),window.removeEventListener("resize",Y)}},[]);const G=N.useMemo(()=>[Qre(),Rse(),Cj(),wf.of(Lj)],[]),$=()=>i(R?"config_management.status_disconnected":r?"config_management.status_loading":h?"config_management.status_load_failed":c?"config_management.status_saving":_?"config_management.status_dirty":"config_management.status_loaded"),ie=()=>h?Ei.error:_?Ei.modified:!r&&!c?Ei.saved:"";return g.jsxs("div",{className:Ei.container,children:[g.jsx("h1",{className:Ei.pageTitle,children:i("config_management.title")}),g.jsx("p",{className:Ei.description,children:i("config_management.description")}),g.jsx(vt,{className:Ei.configCard,children:g.jsxs("div",{className:Ei.content,children:[h&&g.jsx("div",{className:"error-box",children:h}),g.jsxs("div",{className:Ei.editorWrapper,ref:P,children:[g.jsxs("div",{className:Ei.floatingControls,ref:C,children:[g.jsx("div",{className:Ei.searchInputWrapper,children:g.jsx(et,{value:x,onChange:ue=>B(ue.target.value),onKeyDown:W,placeholder:i("config_management.search_placeholder",{defaultValue:"搜索配置内容..."}),disabled:R||r,className:Ei.searchInput,rightElement:g.jsxs("div",{className:Ei.searchRight,children:[x&&M===x&&g.jsx("span",{className:Ei.searchCount,children:w.total>0?`${w.current} / ${w.total}`:i("config_management.search_no_results",{defaultValue:"无结果"})}),g.jsx("button",{type:"button",className:Ei.searchButton,onClick:()=>H("next"),disabled:!x||R||r,title:i("config_management.search_button",{defaultValue:"搜索"}),children:g.jsx($N,{size:16})})]})})}),g.jsxs("div",{className:Ei.searchActions,children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:V,disabled:!x||M!==x||w.total===0,title:i("config_management.search_prev",{defaultValue:"上一个"}),children:g.jsx(IU,{size:16})}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:U,disabled:!x||M!==x||w.total===0,title:i("config_management.search_next",{defaultValue:"下一个"}),children:g.jsx(WU,{size:16})})]})]}),g.jsx(Gj,{ref:A,value:s,onChange:D,extensions:G,theme:n,editable:!R&&!r,placeholder:i("config_management.editor_placeholder"),height:"100%",style:{height:"100%"},basicSetup:{lineNumbers:!0,highlightActiveLineGutter:!0,highlightActiveLine:!0,foldGutter:!0,dropCursor:!0,allowMultipleSelections:!0,indentOnInput:!0,bracketMatching:!0,closeBrackets:!0,autocompletion:!1,rectangularSelection:!0,crosshairCursor:!1,highlightSelectionMatches:!0,closeBracketsKeymap:!0,searchKeymap:!0,foldKeymap:!0,completionKeymap:!1,lintKeymap:!0}})]}),g.jsxs("div",{className:Ei.controls,children:[g.jsx("span",{className:`${Ei.status} ${ie()}`,children:$()}),g.jsxs("div",{className:Ei.actions,children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:E,disabled:r,children:i("config_management.reload")}),g.jsx(ye,{size:"sm",onClick:L,loading:c,disabled:R||r||!_,children:i("config_management.save")})]})]})]})})]})}const goe="LogsPage-module__container___aQ0JL",_oe="LogsPage-module__pageTitle___vZY55",yoe="LogsPage-module__tabBar___bI3hW",xoe="LogsPage-module__tabItem___5tb4J",boe="LogsPage-module__tabActive___JjbWX",voe="LogsPage-module__content___hGaGn",Soe="LogsPage-module__logCard___KG4Jd",woe="LogsPage-module__toolbar___9dY5F",koe="LogsPage-module__filters___nUahU",Aoe="LogsPage-module__searchWrapper___mrEmr",Coe="LogsPage-module__searchInput___eoPij",Ooe="LogsPage-module__searchIcon___73cvF",Toe="LogsPage-module__searchClear___yTM1y",Moe="LogsPage-module__actionButton___aYJPR",Noe="LogsPage-module__buttonContent___qjHrB",Roe="LogsPage-module__switchLabel___EfB3d",Poe="LogsPage-module__logPanel___2wjiP",Loe="LogsPage-module__errorPanel___0w-se",joe="LogsPage-module__loadMoreBanner___BUD0t",Eoe="LogsPage-module__loadMoreCount___UsdBd",Doe="LogsPage-module__loadMoreStats___e9bVk",Uoe="LogsPage-module__logList___lFt6f",Foe="LogsPage-module__logRow___rxZS5",Boe="LogsPage-module__rowWarn___Lhg4M",zoe="LogsPage-module__rowError___XQ3Qi",qoe="LogsPage-module__timestamp___TZvLq",Hoe="LogsPage-module__rowMain___f--We",Koe="LogsPage-module__badge___tR566",Voe="LogsPage-module__pill___vGA2z",Ioe="LogsPage-module__source___nv7Zu",Woe="LogsPage-module__requestIdBadge___yPO1b",Xoe="LogsPage-module__statusBadge___hj08j",Goe="LogsPage-module__statusSuccess___3llcn",Qoe="LogsPage-module__statusInfo___B6DaE",Yoe="LogsPage-module__statusWarn___1Dwki",Zoe="LogsPage-module__statusError___xxTDc",Joe="LogsPage-module__levelInfo___oZMOp",$oe="LogsPage-module__levelWarn___DsCD0",ele="LogsPage-module__levelError___8VjWc",tle="LogsPage-module__levelDebug___l-5yk",ile="LogsPage-module__levelTrace___XvRLF",nle="LogsPage-module__methodBadge___Cf9jC",sle="LogsPage-module__path___frHAs",ale="LogsPage-module__message___bNHRw",Fe={container:goe,pageTitle:_oe,tabBar:yoe,tabItem:xoe,tabActive:boe,content:voe,logCard:Soe,toolbar:woe,filters:koe,searchWrapper:Aoe,searchInput:Coe,searchIcon:Ooe,searchClear:Toe,actionButton:Moe,buttonContent:Noe,switchLabel:Roe,logPanel:Poe,errorPanel:Loe,loadMoreBanner:joe,loadMoreCount:Eoe,loadMoreStats:Doe,logList:Uoe,logRow:Foe,rowWarn:Boe,rowError:zoe,timestamp:qoe,rowMain:Hoe,badge:Koe,pill:Voe,source:Ioe,requestIdBadge:Woe,statusBadge:Xoe,statusSuccess:Goe,statusInfo:Qoe,statusWarn:Yoe,statusError:Zoe,levelInfo:Joe,levelWarn:$oe,levelError:ele,levelDebug:tle,levelTrace:ile,methodBadge:nle,path:sle,message:ale},rle=100,ole=200,mN=1e4,lle=72,cle=650,gN=10,iE=["GET","POST","PUT","PATCH","DELETE","OPTIONS","HEAD"],ule=new RegExp(`\\b(${iE.join("|")})\\b`),dle=/^\[?(\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?)\]?/,hle=/^\[?(trace|debug|info|warn|warning|error|fatal)\s*\]?(?=\s|\[|$)\s*/i,Cx=/^\[([^\]]+)\]/,nE=/\b(?:\d+(?:\.\d+)?\s*(?:µs|us|ms|s|m))(?:\s*\d+(?:\.\d+)?\s*(?:µs|us|ms|s|m))*\b/i,fle=/\b(?:\d{1,3}\.){3}\d{1,3}\b/,ple=/\b(?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}\b/i,_N=/^([a-f0-9]{8}|--------)$/i,mle=/^\d{1,2}:\d{2}:\d{2}(?:\.\d{1,3})?$/,Ox=/^\[GIN\]\s+(\d{4})\/(\d{2})\/(\d{2})\s*-\s*(\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?)\s*$/,gle=[/\|\s*([1-5]\d{2})\s*\|/,/\b([1-5]\d{2})\s*-/,new RegExp(`\\b(?:${iE.join("|")})\\s+\\S+\\s+([1-5]\\d{2})\\b`),/\b(?:status|code|http)[:\s]+([1-5]\d{2})\b/i,/\b([1-5]\d{2})\s+(?:OK|Created|Accepted|No Content|Moved|Found|Bad Request|Unauthorized|Forbidden|Not Found|Method Not Allowed|Internal Server Error|Bad Gateway|Service Unavailable|Gateway Timeout)\b/i],_le=i=>{for(const e of gle){const t=i.match(e);if(!t)continue;const n=Number.parseInt(t[1],10);if(Number.isFinite(n)&&n>=100&&n<=599)return n}},Tx=i=>{const e=i.match(fle);if(e)return e[0];const t=i.match(ple);if(!t)return;const n=t[0];if(!mle.test(n)&&!(!n.includes("::")&&n.split(":").length!==8))return n},Km=i=>{const e=i.trim(),t=e.match(/^(\d{4}-\d{2}-\d{2})[ T](\d{2}:\d{2}:\d{2})/);return t?`${t[1]} ${t[2]}`:e},yN=i=>{const e=i.match(nE);if(e)return e[0].replace(/\s+/g,"")},yle=i=>{const e=i.trim().toLowerCase();if(e==="warning"||e==="warn")return"warn";if(e==="info")return"info";if(e==="error")return"error";if(e==="fatal")return"fatal";if(e==="debug")return"debug";if(e==="trace")return"trace"},xle=i=>{const e=i.toLowerCase();if(/\bfatal\b/.test(e))return"fatal";if(/\berror\b/.test(e))return"error";if(/\bwarn(?:ing)?\b/.test(e)||i.includes("警告"))return"warn";if(/\binfo\b/.test(e))return"info";if(/\bdebug\b/.test(e))return"debug";if(/\btrace\b/.test(e))return"trace"},Mx=i=>{var r;const e=i.match(ule);if(!e)return{};const t=e[1],n=(r=e.index)!=null?r:0,s=i.slice(n+e[0].length).trim(),a=s?s.split(/\s+/)[0]:void 0;return{method:t,path:a}},ble=i=>{let e=i.trim(),t;const n=e.match(dle);n&&(t=n[1],e=e.slice(n[0].length).trim());let s;const a=e.match(/^\[([a-f0-9]{8}|--------)\]\s*/i);if(a){const w=a[1];/^-+$/.test(w)||(s=w),e=e.slice(a[0].length).trim()}let r;const o=e.match(hle);o&&(r=yle(o[1]),e=e.slice(o[0].length).trim());let c;const d=e.match(Cx);d&&(c=d[1],e=e.slice(d[0].length).trim());let h,p,_,y,x,v=e;if(e.includes("|")){const w=e.split("|").map(L=>L.trim()).filter(Boolean),k=new Set,M=w.findIndex(L=>Ox.test(L));if(M>=0){const L=w[M].match(Ox);if(L){const D=`${L[1]}-${L[2]}-${L[3]} ${L[4]}`,q=Km(D),B=t?Km(t):void 0;t?B===q&&k.add(M):(t=D,k.add(M))}}const O=w.findIndex(L=>_N.test(L));if(O>=0){const L=w[O].match(_N);if(L){const D=L[1];/^-+$/.test(D)||(s=D),k.add(O)}}const A=w.findIndex(L=>/^\d{3}$/.test(L));if(A>=0){const L=w[A].match(/^(\d{3})$/);if(L){const D=Number.parseInt(L[1],10);D>=100&&D<=599&&(h=D,k.add(A))}}const C=w.findIndex(L=>nE.test(L));if(C>=0){const L=yN(w[C]);L&&(p=L,k.add(C))}const P=w.findIndex(L=>!!Tx(L));if(P>=0){const L=Tx(w[P]);L&&(_=L,k.add(P))}const R=w.findIndex(L=>{const{method:D}=Mx(L);return!!D});if(R>=0){const L=Mx(w[R]);y=L.method,x=L.path,k.add(R)}const E=w.findIndex(L=>Cx.test(L));if(E>=0){const L=w[E].match(Cx);L&&(c=L[1],k.add(E))}v=w.filter((L,D)=>!k.has(D)).join(" | ")}else{h=_le(e);const w=yN(e);w&&(p=w),_=Tx(e);const k=Mx(e);y=k.method,x=k.path}if(r||(r=xle(i)),v){const w=v.match(Ox);if(w){const k=`${w[1]}-${w[2]}-${w[3]} ${w[4]}`;t||(t=k),Km(t)===Km(k)&&(v="")}}return{raw:i,timestamp:t,level:r,source:c,requestId:s,statusCode:h,latency:p,ip:_,method:y,path:x,message:v}},Hd=i=>{if(i instanceof Error)return i.message;if(typeof i=="string")return i;if(typeof i!="object"||i===null||!("message"in i))return"";const e=i.message;return typeof e=="string"?e:""},vle=i=>pe(null,null,function*(){try{return yield navigator.clipboard.writeText(i),!0}catch(e){try{const t=document.createElement("textarea");t.value=i,t.style.position="fixed",t.style.opacity="0",t.style.left="-9999px",t.style.top="0",document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");return document.body.removeChild(t),n}catch(t){return!1}}});function Sle(){const{t:i}=rt(),{showNotification:e}=Zn(),t=Ct(X=>X.connectionStatus),n=Wt(X=>{var we,be;return(be=(we=X.config)==null?void 0:we.requestLog)!=null?be:!1}),[s,a]=N.useState("logs"),[r,o]=N.useState({buffer:[],visibleFrom:0}),[c,d]=N.useState(!0),[h,p]=N.useState(""),[_,y]=N.useState(!1),[x,v]=N.useState(""),w=N.useDeferredValue(x),[k,M]=N.useState(!0),[O,A]=N.useState([]),[C,P]=N.useState(!1),[R,E]=N.useState(""),[L,D]=N.useState(null),[q,B]=N.useState(!1),H=N.useRef(null),W=N.useRef(!1),V=N.useRef(null),U=N.useRef(null),G=N.useRef(0),$=t!=="connected",ie=X=>X?X.scrollHeight-X.scrollTop-X.clientHeight<=24:!0,ue=()=>{const X=H.current;X&&(X.scrollTop=X.scrollHeight)},F=(X=!1)=>pe(null,null,function*(){if(t!=="connected"){d(!1);return}X||d(!0),p("");try{W.current=!X||ie(H.current);const we=X&&G.current>0?{after:G.current}:{},be=yield Nd.fetchLogs(we);be["latest-timestamp"]&&(G.current=be["latest-timestamp"]);const je=Array.isArray(be.lines)?be.lines:[];if(X&&je.length>0)o(Ve=>{const Tt=Ve.buffer.length-Ve.visibleFrom,Mt=[...Ve.buffer,...je],Nt=Math.max(Mt.length-mN,0),ni=Nt>0?Mt.slice(Nt):Mt;let wt=Math.max(Ve.visibleFrom-Nt,0);return W.current&&(wt=Math.max(ni.length-Tt,0)),{buffer:ni,visibleFrom:wt}});else if(!X){const Ve=je.slice(-mN),Tt=Math.max(Ve.length-rle,0);o({buffer:Ve,visibleFrom:Tt})}}catch(we){console.error("Failed to load logs:",we),X||p(Hd(we)||i("logs.load_error"))}finally{X||d(!1)}});M0(()=>F(!1));const Y=()=>pe(null,null,function*(){if(window.confirm(i("logs.clear_confirm")))try{yield Nd.clearLogs(),o({buffer:[],visibleFrom:0}),G.current=0,e(i("logs.clear_success"),"success")}catch(X){const we=Hd(X);e(`${i("notification.delete_failed")}${we?`: ${we}`:""}`,"error")}}),ce=()=>{const X=r.buffer.join(` -`),we=new Blob([X],{type:"text/plain"}),be=window.URL.createObjectURL(we),je=document.createElement("a");je.href=be,je.download="logs.txt",je.click(),window.URL.revokeObjectURL(be),e(i("logs.download_success"),"success")},J=()=>pe(null,null,function*(){if(t!=="connected"){P(!1);return}P(!0),E("");try{const X=yield Nd.fetchErrorLogs();A(Array.isArray(X.files)?X.files:[])}catch(X){console.error("Failed to load error logs:",X),A([]);const we=Hd(X);E(we?`${i("logs.error_logs_load_error")}: ${we}`:i("logs.error_logs_load_error"))}finally{P(!1)}}),me=X=>pe(null,null,function*(){try{const we=yield Nd.downloadErrorLog(X),be=new Blob([we.data],{type:"text/plain"}),je=window.URL.createObjectURL(be),Ve=document.createElement("a");Ve.href=je,Ve.download=X,Ve.click(),window.URL.revokeObjectURL(je),e(i("logs.error_log_download_success"),"success")}catch(we){const be=Hd(we);e(`${i("notification.download_failed")}${be?`: ${be}`:""}`,"error")}});N.useEffect(()=>{t==="connected"&&(G.current=0,F(!1))},[t]),N.useEffect(()=>{s==="errors"&&t==="connected"&&J()},[s,t,n]),N.useEffect(()=>{if(!_||t!=="connected")return;const X=window.setInterval(()=>{F(!0)},8e3);return()=>window.clearInterval(X)},[_,t]),N.useEffect(()=>{W.current&&(c||H.current&&(ue(),W.current=!1))},[c,r.buffer,r.visibleFrom]);const Se=N.useMemo(()=>r.buffer.slice(r.visibleFrom),[r.buffer,r.visibleFrom]),Re=w.trim(),He=Re.length>0,Ke=He?r.buffer:Se,{filteredLines:it,removedCount:fi}=N.useMemo(()=>{let X=Ke,we=0;if(k){const be=[];for(const je of X)je.includes(Fx)?we+=1:be.push(je);X=be}if(Re){const be=Re.toLowerCase(),je=[];for(const Ve of X)Ve.toLowerCase().includes(be)?je.push(Ve):we+=1;X=je}return{filteredLines:X,removedCount:we}},[Ke,k,Re]),Pi=N.useMemo(()=>it.map(X=>ble(X)),[it]),ft=!He&&r.visibleFrom>0,ii=()=>{const X=H.current;X&&(He||ft&&(V.current||X.scrollTop>lle||(V.current={scrollHeight:X.scrollHeight,scrollTop:X.scrollTop},o(we=>ee(z({},we),{visibleFrom:Math.max(we.visibleFrom-ole,0)})))))};N.useLayoutEffect(()=>{const X=H.current,we=V.current;if(!X||!we)return;const be=X.scrollHeight-we.scrollHeight;X.scrollTop=we.scrollTop+be,V.current=null},[r.visibleFrom]);const Tn=X=>pe(null,null,function*(){(yield vle(X))?e(i("logs.copy_success",{defaultValue:"Copied to clipboard"}),"success"):e(i("logs.copy_failed",{defaultValue:"Copy failed"}),"error")}),Mn=()=>{var X;(X=U.current)!=null&&X.timer&&(window.clearTimeout(U.current.timer),U.current.timer=null)},aa=(X,we)=>{n&&we&&(L||(Mn(),U.current={timer:window.setTimeout(()=>{D(we),U.current&&(U.current.fired=!0,U.current.timer=null)},cle),startX:X.clientX,startY:X.clientY,fired:!1}))},vi=()=>{Mn(),U.current=null},Ee=X=>{const we=U.current;if(!we||we.timer===null||we.fired)return;const be=Math.abs(X.clientX-we.startX),je=Math.abs(X.clientY-we.startY);(be>gN||je>gN)&&vi()},_t=()=>{q||D(null)},he=X=>pe(null,null,function*(){B(!0);try{const we=yield Nd.downloadRequestLogById(X),be=new Blob([we.data],{type:"text/plain"}),je=window.URL.createObjectURL(be),Ve=document.createElement("a");Ve.href=je,Ve.download=`request-${X}.log`,Ve.click(),window.URL.revokeObjectURL(je),e(i("logs.request_log_download_success"),"success"),D(null)}catch(we){const be=Hd(we);e(`${i("notification.download_failed")}${be?`: ${be}`:""}`,"error")}finally{B(!1)}});return N.useEffect(()=>()=>{var X;(X=U.current)!=null&&X.timer&&(window.clearTimeout(U.current.timer),U.current.timer=null)},[]),g.jsxs("div",{className:Fe.container,children:[g.jsx("h1",{className:Fe.pageTitle,children:i("logs.title")}),g.jsxs("div",{className:Fe.tabBar,children:[g.jsx("button",{type:"button",className:`${Fe.tabItem} ${s==="logs"?Fe.tabActive:""}`,onClick:()=>a("logs"),children:i("logs.log_content")}),g.jsx("button",{type:"button",className:`${Fe.tabItem} ${s==="errors"?Fe.tabActive:""}`,onClick:()=>a("errors"),children:i("logs.error_logs_modal_title")})]}),g.jsxs("div",{className:Fe.content,children:[s==="logs"&&g.jsxs(vt,{className:Fe.logCard,children:[h&&g.jsx("div",{className:"error-box",children:h}),g.jsxs("div",{className:Fe.filters,children:[g.jsx("div",{className:Fe.searchWrapper,children:g.jsx(et,{value:x,onChange:X=>v(X.target.value),placeholder:i("logs.search_placeholder"),className:Fe.searchInput,rightElement:x?g.jsx("button",{type:"button",className:Fe.searchClear,onClick:()=>v(""),title:"Clear","aria-label":"Clear",children:g.jsx(Hl,{size:16})}):g.jsx($N,{size:16,className:Fe.searchIcon})})}),g.jsx(Sn,{checked:k,onChange:M,label:g.jsxs("span",{className:Fe.switchLabel,children:[g.jsx(eR,{size:16}),i("logs.hide_management_logs",{prefix:Fx})]})}),g.jsxs("div",{className:Fe.toolbar,children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>F(!1),disabled:$||c,className:Fe.actionButton,children:g.jsxs("span",{className:Fe.buttonContent,children:[g.jsx(YN,{size:16}),i("logs.refresh_button")]})}),g.jsx(Sn,{checked:_,onChange:X=>y(X),disabled:$,label:g.jsxs("span",{className:Fe.switchLabel,children:[g.jsx(jv,{size:16}),i("logs.auto_refresh")]})}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:ce,disabled:r.buffer.length===0,className:Fe.actionButton,children:g.jsxs("span",{className:Fe.buttonContent,children:[g.jsx(ZN,{size:16}),i("logs.download_button")]})}),g.jsx(ye,{variant:"danger",size:"sm",onClick:Y,disabled:$,className:Fe.actionButton,children:g.jsxs("span",{className:Fe.buttonContent,children:[g.jsx(JN,{size:16}),i("logs.clear_button")]})})]})]}),c?g.jsx("div",{className:"hint",children:i("logs.loading")}):r.buffer.length>0&&Pi.length>0?g.jsxs("div",{ref:H,className:Fe.logPanel,onScroll:ii,children:[ft&&g.jsxs("div",{className:Fe.loadMoreBanner,children:[g.jsx("span",{children:i("logs.load_more_hint")}),g.jsxs("div",{className:Fe.loadMoreStats,children:[g.jsx("span",{children:i("logs.loaded_lines",{count:Pi.length})}),fi>0&&g.jsx("span",{className:Fe.loadMoreCount,children:i("logs.filtered_lines",{count:fi})}),g.jsx("span",{className:Fe.loadMoreCount,children:i("logs.hidden_lines",{count:r.visibleFrom})})]})]}),g.jsx("div",{className:Fe.logList,children:Pi.map((X,we)=>{const be=[Fe.logRow];return X.level==="warn"&&be.push(Fe.rowWarn),(X.level==="error"||X.level==="fatal")&&be.push(Fe.rowError),g.jsxs("div",{className:be.join(" "),onDoubleClick:()=>{Tn(X.raw)},onPointerDown:je=>aa(je,X.requestId),onPointerUp:vi,onPointerLeave:vi,onPointerCancel:vi,onPointerMove:Ee,title:i("logs.double_click_copy_hint",{defaultValue:"Double-click to copy"}),children:[g.jsx("div",{className:Fe.timestamp,children:X.timestamp||""}),g.jsxs("div",{className:Fe.rowMain,children:[X.level&&g.jsx("span",{className:[Fe.badge,X.level==="info"?Fe.levelInfo:"",X.level==="warn"?Fe.levelWarn:"",X.level==="error"||X.level==="fatal"?Fe.levelError:"",X.level==="debug"?Fe.levelDebug:"",X.level==="trace"?Fe.levelTrace:""].filter(Boolean).join(" "),children:X.level.toUpperCase()}),X.source&&g.jsx("span",{className:Fe.source,title:X.source,children:X.source}),X.requestId&&g.jsx("span",{className:[Fe.badge,Fe.requestIdBadge].join(" "),title:X.requestId,children:X.requestId}),typeof X.statusCode=="number"&&g.jsx("span",{className:[Fe.badge,Fe.statusBadge,X.statusCode>=200&&X.statusCode<300?Fe.statusSuccess:X.statusCode>=300&&X.statusCode<400?Fe.statusInfo:X.statusCode>=400&&X.statusCode<500?Fe.statusWarn:Fe.statusError].join(" "),children:X.statusCode}),X.latency&&g.jsx("span",{className:Fe.pill,children:X.latency}),X.ip&&g.jsx("span",{className:Fe.pill,children:X.ip}),X.method&&g.jsx("span",{className:[Fe.badge,Fe.methodBadge].join(" "),children:X.method}),X.path&&g.jsx("span",{className:Fe.path,title:X.path,children:X.path}),X.message&&g.jsx("span",{className:Fe.message,children:X.message})]})]},`${r.visibleFrom+we}-${X.raw}`)})})]}):r.buffer.length>0?g.jsx(Ps,{title:i("logs.search_empty_title"),description:i("logs.search_empty_desc")}):g.jsx(Ps,{title:i("logs.empty_title"),description:i("logs.empty_desc")})]}),s==="errors"&&g.jsx(vt,{extra:g.jsx(ye,{variant:"secondary",size:"sm",onClick:J,loading:C,disabled:$,children:i("common.refresh")}),children:g.jsxs("div",{className:"stack",children:[g.jsx("div",{className:"hint",children:i("logs.error_logs_description")}),n&&g.jsx("div",{children:g.jsx("div",{className:"status-badge warning",children:i("logs.error_logs_request_log_enabled")})}),R&&g.jsx("div",{className:"error-box",children:R}),g.jsx("div",{className:Fe.errorPanel,children:C?g.jsx("div",{className:"hint",children:i("common.loading")}):O.length===0?g.jsx("div",{className:"hint",children:i("logs.error_logs_empty")}):g.jsx("div",{className:"item-list",children:O.map(X=>g.jsxs("div",{className:"item-row",children:[g.jsxs("div",{className:"item-meta",children:[g.jsx("div",{className:"item-title",children:X.name}),g.jsxs("div",{className:"item-subtitle",children:[X.size?`${(X.size/1024).toFixed(1)} KB`:""," ",X.modified?W7(X.modified):""]})]}),g.jsx("div",{className:"item-actions",children:g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>me(X.name),disabled:$,children:i("logs.error_logs_download")})})]},X.name))})})]})})]}),g.jsx(zn,{open:!!L,onClose:_t,title:i("logs.request_log_download_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:_t,disabled:q,children:i("common.cancel")}),g.jsx(ye,{onClick:()=>{L&&he(L)},loading:q,disabled:!L,children:i("common.confirm")})]}),children:L?i("logs.request_log_download_confirm",{id:L}):null})]})}const wle="SystemPage-module__container___KAydo",kle="SystemPage-module__pageTitle___DiF5E",Ale="SystemPage-module__content___SauLn",Cle="SystemPage-module__sectionDescription___nI7Jo",Ole="SystemPage-module__clearLoginActions___4ek-m",Tle="SystemPage-module__modelTags___M0sci",Mle="SystemPage-module__modelTag___5Ar53",Nle="SystemPage-module__modelName___LKdAK",Rle="SystemPage-module__modelAlias___zioM-",Ple="SystemPage-module__quickLinks___QTmT3",Lle="SystemPage-module__linkCard___iSrVF",jle="SystemPage-module__linkIcon___gNqz2",Ele="SystemPage-module__github___V8I3m",Dle="SystemPage-module__docs___cA-rG",Ule="SystemPage-module__linkContent___Rfh7h",Fle="SystemPage-module__linkTitle___Zpr4Q",Ble="SystemPage-module__linkDesc___KKavC",At={container:wle,pageTitle:kle,content:Ale,sectionDescription:Cle,clearLoginActions:Ole,modelTags:Tle,modelTag:Mle,modelName:Nle,modelAlias:Rle,quickLinks:Ple,linkCard:Lle,linkIcon:jle,github:Ele,docs:Dle,linkContent:Ule,linkTitle:Fle,linkDesc:Ble};function zle(){const{t:i,i18n:e}=rt(),{showNotification:t}=Zn(),n=Ct(),s=Wt(O=>O.config),a=Wt(O=>O.fetchConfig),r=_l(O=>O.models),o=_l(O=>O.loading),c=_l(O=>O.error),d=_l(O=>O.fetchModels),[h,p]=N.useState(),_=N.useRef([]),y=N.useMemo(()=>{var O;return(O=e.language)!=null&&O.toLowerCase().startsWith("zh")?"其他":"Other"},[e.language]),x=N.useMemo(()=>uz(r,{otherLabel:y}),[r,y]),v=O=>{if(!Array.isArray(O))return[];const A=new Set,C=[];return O.forEach(P=>{var L,D;const R=typeof P=="string"?P:(D=(L=P==null?void 0:P["api-key"])!=null?L:P==null?void 0:P.apiKey)!=null?D:"",E=String(R||"").trim();!E||A.has(E)||(A.add(E),C.push(E))}),C},w=N.useCallback(()=>pe(null,null,function*(){if(_.current.length)return _.current;const O=v(s==null?void 0:s.apiKeys);if(O.length)return _.current=O,O;try{const A=yield Yc.list(),C=v(A);return C.length&&(_.current=C),C}catch(A){return console.warn("Auto loading API keys for models failed:",A),[]}}),[s==null?void 0:s.apiKeys]),k=(...A)=>pe(null,[...A],function*({forceRefresh:O=!1}={}){if(n.connectionStatus!=="connected"){p({type:"warning",message:i("notification.connection_required")});return}if(!n.apiBase){t(i("notification.connection_required"),"warning");return}O&&(_.current=[]),p({type:"muted",message:i("system_info.models_loading")});try{const P=(yield w())[0],R=yield d(n.apiBase,P,O),E=R.length>0;p({type:E?"success":"warning",message:E?i("system_info.models_count",{count:R.length}):i("system_info.models_empty")})}catch(C){const P=`${i("system_info.models_error")}: ${(C==null?void 0:C.message)||""}`;p({type:"error",message:P})}}),M=()=>{if(!window.confirm(i("system_info.clear_login_confirm"))||(n.logout(),typeof localStorage=="undefined"))return;[nR,"isLoggedIn","apiBase","apiUrl","managementKey"].forEach(A=>localStorage.removeItem(A)),t(i("notification.login_storage_cleared"),"success")};return N.useEffect(()=>{a().catch(()=>{})},[a]),N.useEffect(()=>{k()},[n.connectionStatus,n.apiBase]),g.jsxs("div",{className:At.container,children:[g.jsx("h1",{className:At.pageTitle,children:i("system_info.title")}),g.jsxs("div",{className:At.content,children:[g.jsx(vt,{title:i("system_info.connection_status_title"),extra:g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>a(void 0,!0),children:i("common.refresh")}),children:g.jsxs("div",{className:"grid cols-2",children:[g.jsxs("div",{className:"stat-card",children:[g.jsx("div",{className:"stat-label",children:i("connection.server_address")}),g.jsx("div",{className:"stat-value",children:n.apiBase||"-"})]}),g.jsxs("div",{className:"stat-card",children:[g.jsx("div",{className:"stat-label",children:i("footer.api_version")}),g.jsx("div",{className:"stat-value",children:n.serverVersion||i("system_info.version_unknown")})]}),g.jsxs("div",{className:"stat-card",children:[g.jsx("div",{className:"stat-label",children:i("footer.build_date")}),g.jsx("div",{className:"stat-value",children:n.serverBuildDate?new Date(n.serverBuildDate).toLocaleString():i("system_info.version_unknown")})]}),g.jsxs("div",{className:"stat-card",children:[g.jsx("div",{className:"stat-label",children:i("connection.status")}),g.jsx("div",{className:"stat-value",children:i(`common.${n.connectionStatus}_status`)})]})]})}),g.jsxs(vt,{title:i("system_info.quick_links_title"),children:[g.jsx("p",{className:At.sectionDescription,children:i("system_info.quick_links_desc")}),g.jsxs("div",{className:At.quickLinks,children:[g.jsxs("a",{href:"https://github.com/router-for-me/CLIProxyAPI",target:"_blank",rel:"noopener noreferrer",className:At.linkCard,children:[g.jsx("div",{className:`${At.linkIcon} ${At.github}`,children:g.jsx($U,{size:22})}),g.jsxs("div",{className:At.linkContent,children:[g.jsxs("div",{className:At.linkTitle,children:[i("system_info.link_main_repo"),g.jsx(v1,{size:14})]}),g.jsx("div",{className:At.linkDesc,children:i("system_info.link_main_repo_desc")})]})]}),g.jsxs("a",{href:"https://github.com/router-for-me/Cli-Proxy-API-Management-Center",target:"_blank",rel:"noopener noreferrer",className:At.linkCard,children:[g.jsx("div",{className:`${At.linkIcon} ${At.github}`,children:g.jsx(tF,{size:22})}),g.jsxs("div",{className:At.linkContent,children:[g.jsxs("div",{className:At.linkTitle,children:[i("system_info.link_webui_repo"),g.jsx(v1,{size:14})]}),g.jsx("div",{className:At.linkDesc,children:i("system_info.link_webui_repo_desc")})]})]}),g.jsxs("a",{href:"https://help.router-for.me/",target:"_blank",rel:"noopener noreferrer",className:At.linkCard,children:[g.jsx("div",{className:`${At.linkIcon} ${At.docs}`,children:g.jsx(eF,{size:22})}),g.jsxs("div",{className:At.linkContent,children:[g.jsxs("div",{className:At.linkTitle,children:[i("system_info.link_docs"),g.jsx(v1,{size:14})]}),g.jsx("div",{className:At.linkDesc,children:i("system_info.link_docs_desc")})]})]})]})]}),g.jsxs(vt,{title:i("system_info.models_title"),extra:g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>k({forceRefresh:!0}),loading:o,children:i("common.refresh")}),children:[g.jsx("p",{className:At.sectionDescription,children:i("system_info.models_desc")}),h&&g.jsx("div",{className:`status-badge ${h.type}`,children:h.message}),c&&g.jsx("div",{className:"error-box",children:c}),o?g.jsx("div",{className:"hint",children:i("common.loading")}):r.length===0?g.jsx("div",{className:"hint",children:i("system_info.models_empty")}):g.jsx("div",{className:"item-list",children:x.map(O=>g.jsxs("div",{className:"item-row",children:[g.jsxs("div",{className:"item-meta",children:[g.jsx("div",{className:"item-title",children:O.label}),g.jsx("div",{className:"item-subtitle",children:i("system_info.models_count",{count:O.items.length})})]}),g.jsx("div",{className:At.modelTags,children:O.items.map(A=>{var C;return g.jsxs("span",{className:At.modelTag,title:A.description||"",children:[g.jsx("span",{className:At.modelName,children:A.name}),A.alias&&g.jsx("span",{className:At.modelAlias,children:A.alias})]},`${A.name}-${(C=A.alias)!=null?C:"default"}`)})})]},O.id))})]}),g.jsxs(vt,{title:i("system_info.clear_login_title"),children:[g.jsx("p",{className:At.sectionDescription,children:i("system_info.clear_login_desc")}),g.jsx("div",{className:At.clearLoginActions,children:g.jsx(ye,{variant:"danger",onClick:M,children:i("system_info.clear_login_button")})})]})]})]})}const qle=[{path:"/",element:g.jsx(TO,{})},{path:"/dashboard",element:g.jsx(TO,{})},{path:"/settings",element:g.jsx($q,{})},{path:"/api-keys",element:g.jsx(nH,{})},{path:"/ai-providers",element:g.jsx(AK,{})},{path:"/auth-files",element:g.jsx(HV,{})},{path:"/oauth",element:g.jsx(dI,{})},{path:"/quota",element:g.jsx(iX,{})},{path:"/usage",element:g.jsx(YJ,{})},{path:"/config",element:g.jsx(moe,{})},{path:"/logs",element:g.jsx(Sle,{})},{path:"/system",element:g.jsx(zle,{})},{path:"*",element:g.jsx(Nv,{to:"/",replace:!0})}];function Hle({location:i}){return PN(qle,i)}const Ys={dashboard:g.jsx(iF,{size:18}),settings:g.jsx(zU,{size:18}),apiKeys:g.jsx(XN,{size:18}),aiProviders:g.jsx(Lv,{size:18}),authFiles:g.jsx(GN,{size:18}),oauth:g.jsx(qU,{size:18}),quota:g.jsx(jv,{size:18}),usage:g.jsx(HU,{size:18}),config:g.jsx(KU,{size:18}),logs:g.jsx(VU,{size:18}),system:g.jsx(QN,{size:18})},ga={width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},_a={refresh:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),g.jsx("path",{d:"M21 3v5h-5"})]})),update:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("path",{d:"M12 19V5"}),g.jsx("path",{d:"m5 12 7-7 7 7"})]})),menu:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("path",{d:"M4 7h16"}),g.jsx("path",{d:"M4 12h16"}),g.jsx("path",{d:"M4 17h16"})]})),chevronLeft:g.jsx("svg",ee(z({},ga),{children:g.jsx("path",{d:"m14 18-6-6 6-6"})})),chevronRight:g.jsx("svg",ee(z({},ga),{children:g.jsx("path",{d:"m10 6 6 6-6 6"})})),language:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("circle",{cx:"12",cy:"12",r:"10"}),g.jsx("path",{d:"M2 12h20"}),g.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})),sun:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("circle",{cx:"12",cy:"12",r:"4"}),g.jsx("path",{d:"M12 2v2"}),g.jsx("path",{d:"M12 20v2"}),g.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),g.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),g.jsx("path",{d:"M2 12h2"}),g.jsx("path",{d:"M20 12h2"}),g.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),g.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})),moon:g.jsx("svg",ee(z({},ga),{children:g.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9z"})})),autoTheme:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("defs",{children:g.jsx("clipPath",{id:"mainLayoutAutoThemeSunLeftHalf",children:g.jsx("rect",{x:"0",y:"0",width:"12",height:"24"})})}),g.jsx("circle",{cx:"12",cy:"12",r:"4"}),g.jsx("circle",{cx:"12",cy:"12",r:"4",clipPath:"url(#mainLayoutAutoThemeSunLeftHalf)",fill:"currentColor"}),g.jsx("path",{d:"M12 2v2"}),g.jsx("path",{d:"M12 20v2"}),g.jsx("path",{d:"M4.93 4.93l1.41 1.41"}),g.jsx("path",{d:"M17.66 17.66l1.41 1.41"}),g.jsx("path",{d:"M2 12h2"}),g.jsx("path",{d:"M20 12h2"}),g.jsx("path",{d:"M6.34 17.66l-1.41 1.41"}),g.jsx("path",{d:"M19.07 4.93l-1.41 1.41"})]})),logout:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),g.jsx("path",{d:"m16 17 5-5-5-5"}),g.jsx("path",{d:"M21 12H9"})]}))},xN=i=>{if(!i)return null;const e=i.trim().replace(/^v/i,"");if(!e)return null;const t=e.split(/[^0-9]+/).filter(Boolean).map(n=>Number.parseInt(n,10)).filter(Number.isFinite);return t.length?t:null},Kle=(i,e)=>{const t=xN(i),n=xN(e);if(!t||!n)return null;const s=Math.max(t.length,n.length);for(let a=0;ao)return 1;if(rEe.apiBase),a=Ct(Ee=>Ee.serverVersion),r=Ct(Ee=>Ee.serverBuildDate),o=Ct(Ee=>Ee.connectionStatus),c=Ct(Ee=>Ee.logout),d=Wt(Ee=>Ee.config),h=Wt(Ee=>Ee.fetchConfig),p=Wt(Ee=>Ee.clearCache),_=Wt(Ee=>Ee.updateConfigValue),y=_r(Ee=>Ee.theme),x=_r(Ee=>Ee.cycleTheme),v=wh(Ee=>Ee.toggleLanguage),[w,k]=N.useState(!1),[M,O]=N.useState(!1),[A,C]=N.useState(!1),[P,R]=N.useState(!0),[E,L]=N.useState(!1),[D,q]=N.useState(!1),[B,H]=N.useState(!1),[W,V]=N.useState(!1),U=N.useRef(null),G=N.useRef(null),$=N.useRef(null),ie=N.useRef(0),ue=N.useRef(null),F="CLI Proxy API Management Center",Y=i("title.abbr"),ce=(vi=d==null?void 0:d.requestLog)!=null?vi:!1,J=D!==ce,me=o==="connected"&&!!d,Se=n.pathname.startsWith("/logs");N.useLayoutEffect(()=>{const Ee=()=>{var X;const he=(X=$.current)==null?void 0:X.offsetHeight;he&&document.documentElement.style.setProperty("--header-height",`${he}px`)};Ee();const _t=typeof ResizeObserver!="undefined"&&$.current?new ResizeObserver(Ee):null;return _t&&$.current&&_t.observe($.current),window.addEventListener("resize",Ee),()=>{_t&&_t.disconnect(),window.removeEventListener("resize",Ee)}},[]),N.useEffect(()=>(G.current=setTimeout(()=>{R(!1)},5e3),()=>{G.current&&clearTimeout(G.current)}),[]),N.useEffect(()=>{E&&!B&&q(ce)},[E,B,ce]),N.useEffect(()=>()=>{ue.current&&clearTimeout(ue.current)},[]);const Re=N.useCallback(()=>{P||(R(!0),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{R(!1)},5e3))},[P]),He=N.useCallback(()=>{H(!1),q(ce),L(!0)},[ce]),Ke=N.useCallback(()=>{L(!1),H(!1)},[]),it=N.useCallback(()=>{ie.current+=1,ue.current&&clearTimeout(ue.current),ue.current=setTimeout(()=>{ie.current=0},1500),ie.current>=7&&(ie.current=0,ue.current&&(clearTimeout(ue.current),ue.current=null),He())},[He]),fi=()=>pe(null,null,function*(){if(!me)return;if(!J){L(!1);return}const Ee=ce;V(!0),_("request-log",D);try{yield Ji.updateRequestLog(D),p("request-log"),t(i("notification.request_log_updated"),"success"),L(!1)}catch(_t){_("request-log",Ee),t(`${i("notification.update_failed")}: ${(_t==null?void 0:_t.message)||""}`,"error")}finally{V(!1)}});N.useEffect(()=>{h().catch(()=>{})},[h]);const Pi=o==="connected"?"success":o==="connecting"?"warning":o==="error"?"error":"muted",ft=[{path:"/",label:i("nav.dashboard"),icon:Ys.dashboard},{path:"/settings",label:i("nav.basic_settings"),icon:Ys.settings},{path:"/api-keys",label:i("nav.api_keys"),icon:Ys.apiKeys},{path:"/ai-providers",label:i("nav.ai_providers"),icon:Ys.aiProviders},{path:"/auth-files",label:i("nav.auth_files"),icon:Ys.authFiles},{path:"/oauth",label:i("nav.oauth",{defaultValue:"OAuth"}),icon:Ys.oauth},{path:"/quota",label:i("nav.quota_management"),icon:Ys.quota},{path:"/usage",label:i("nav.usage_stats"),icon:Ys.usage},{path:"/config",label:i("nav.config_management"),icon:Ys.config},...d!=null&&d.loggingToFile?[{path:"/logs",label:i("nav.logs"),icon:Ys.logs}]:[],{path:"/system",label:i("nav.system_info"),icon:Ys.system}],ii=ft.map(Ee=>Ee.path),Tn=Ee=>{const _t=Ee.length>1&&Ee.endsWith("/")?Ee.slice(0,-1):Ee,he=_t==="/dashboard"?"/":_t,X=ii.indexOf(he);if(X!==-1)return X;const we=ii.findIndex(be=>be!=="/"&&he.startsWith(`${be}/`));return we===-1?null:we},Mn=()=>pe(null,null,function*(){p();const _t=(yield Promise.allSettled([h(void 0,!0),XP()])).find(he=>he.status==="rejected");if(_t&&_t.status==="rejected"){const he=_t.reason,X=typeof he=="string"?he:he instanceof Error?he.message:"";t(`${i("notification.refresh_failed")}${X?`: ${X}`:""}`,"error");return}t(i("notification.data_refreshed"),"success")}),aa=()=>pe(null,null,function*(){var Ee,_t,he;C(!0);try{const X=yield uq.checkLatest(),we=(he=(_t=(Ee=X==null?void 0:X["latest-version"])!=null?Ee:X==null?void 0:X.latest_version)!=null?_t:X==null?void 0:X.latest)!=null?he:"",be=Kle(we,a);if(!we){t(i("system_info.version_check_error"),"error");return}if(be===null){t(i("system_info.version_current_missing"),"warning");return}be>0?t(i("system_info.version_update_available",{version:we}),"warning"):t(i("system_info.version_is_latest"),"success")}catch(X){t(`${i("system_info.version_check_error")}: ${(X==null?void 0:X.message)||""}`,"error")}finally{C(!1)}});return g.jsxs("div",{className:"app-shell",children:[g.jsxs("header",{className:"main-header",ref:$,children:[g.jsxs("div",{className:"left",children:[g.jsx("button",{className:"sidebar-toggle-header",onClick:()=>O(Ee=>!Ee),title:M?i("sidebar.expand",{defaultValue:"展开"}):i("sidebar.collapse",{defaultValue:"收起"}),children:M?_a.chevronRight:_a.chevronLeft}),g.jsx("img",{src:mg,alt:"CPAMC logo",className:"brand-logo"}),g.jsxs("div",{className:`brand-header ${P?"expanded":"collapsed"}`,onClick:Re,title:P?void 0:F,children:[g.jsx("span",{className:"brand-full",children:F}),g.jsx("span",{className:"brand-abbr",children:Y})]})]}),g.jsxs("div",{className:"right",children:[g.jsxs("div",{className:"connection",children:[g.jsx("span",{className:`status-badge ${Pi}`,children:i(o==="connected"?"common.connected_status":o==="connecting"?"common.connecting_status":"common.disconnected_status")}),g.jsx("span",{className:"base",children:s||"-"})]}),g.jsxs("div",{className:"header-actions",children:[g.jsx(ye,{className:"mobile-menu-btn",variant:"ghost",size:"sm",onClick:()=>k(Ee=>!Ee),children:_a.menu}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:Mn,title:i("header.refresh_all"),children:_a.refresh}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:aa,loading:A,title:i("system_info.version_check_button"),children:_a.update}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:v,title:i("language.switch"),children:_a.language}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:x,title:i("theme.switch"),children:y==="auto"?_a.autoTheme:y==="dark"?_a.moon:_a.sun}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:c,title:i("header.logout"),children:_a.logout})]})]})]}),g.jsxs("div",{className:"main-body",children:[g.jsx("aside",{className:`sidebar ${w?"open":""} ${M?"collapsed":""}`,children:g.jsx("div",{className:"nav-section",children:ft.map(Ee=>g.jsxs(BN,{to:Ee.path,className:({isActive:_t})=>`nav-item ${_t?"active":""}`,onClick:()=>k(!1),title:M?Ee.label:void 0,children:[g.jsx("span",{className:"nav-icon",children:Ee.icon}),!M&&g.jsx("span",{className:"nav-label",children:Ee.label})]},Ee.path))})}),g.jsxs("div",{className:`content${Se?" content-logs":""}`,ref:U,children:[g.jsx("main",{className:`main-content${Se?" main-content-logs":""}`,children:g.jsx(q7,{render:Ee=>g.jsx(Hle,{location:Ee}),getRouteOrder:Tn,scrollContainerRef:U})}),g.jsxs("footer",{className:"footer",children:[g.jsxs("span",{children:[i("footer.api_version"),": ",a||i("system_info.version_unknown")]}),g.jsxs("span",{className:"footer-version",onClick:it,children:[i("footer.version"),": ","v1.2.16"]}),g.jsxs("span",{children:[i("footer.build_date"),":"," ",r?new Date(r).toLocaleString(e.language):i("system_info.version_unknown")]})]})]})]}),g.jsx(zn,{open:E,onClose:Ke,title:i("basic_settings.request_log_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:Ke,disabled:W,children:i("common.cancel")}),g.jsx(ye,{onClick:fi,loading:W,disabled:!me||!J,children:i("common.save")})]}),children:g.jsxs("div",{className:"request-log-modal",children:[g.jsx("div",{className:"status-badge warning",children:i("basic_settings.request_log_warning")}),g.jsx(Sn,{label:i("basic_settings.request_log_enable"),labelPosition:"left",checked:D,disabled:!me||W,onChange:Ee=>{q(Ee),H(!0)}})]})})]})}function Ile({children:i}){const e=Vs(),t=Ct(c=>c.isAuthenticated),n=Ct(c=>c.managementKey),s=Ct(c=>c.apiBase),a=Ct(c=>c.checkAuth),[r,o]=N.useState(!1);return N.useEffect(()=>{pe(null,null,function*(){if(!t&&n&&s){o(!0);try{yield a()}finally{o(!1)}}})},[s,t,n,a]),r?g.jsx("div",{className:"main-content",children:g.jsx(C0,{})}):t?i:g.jsx(Nv,{to:"/login",replace:!0,state:{from:e}})}const Wle=1500,Xle=400;function Gle(){const i=_r(p=>p.initializeTheme),e=wh(p=>p.language),t=wh(p=>p.setLanguage),n=Ct(p=>p.restoreSession),[s,a]=N.useState(!1),[r,o]=N.useState(!0),[c,d]=N.useState(!1);N.useEffect(()=>{const p=i();return n().finally(()=>{d(!0)}),p},[i,n]),N.useEffect(()=>{t(e)},[]),N.useEffect(()=>{document.documentElement.lang=e},[e]),N.useEffect(()=>{const p=setTimeout(()=>{a(!0)},Wle-Xle);return()=>clearTimeout(p)},[]);const h=N.useCallback(()=>{o(!1)},[]);return r?g.jsx(gz,{fadeOut:s&&c,onFinish:h}):g.jsxs(I6,{children:[g.jsx(pz,{}),g.jsxs(v6,{children:[g.jsx(Px,{path:"/login",element:g.jsx(fz,{})}),g.jsx(Px,{path:"/*",element:g.jsx(Ile,{children:g.jsx(Vle,{})})})]})]})}document.title="CLI Proxy API Management Center";const Nx=document.querySelector('link[rel="icon"]');if(Nx)Nx.href=mg,Nx.type="image/jpeg";else{const i=document.createElement("link");i.rel="icon",i.type="image/jpeg",i.href=mg,document.head.appendChild(i)}A8.createRoot(document.getElementById("root")).render(g.jsx(N.StrictMode,{children:g.jsx(Gle,{})}))});export default Qle(); +`),we=new Blob([X],{type:"text/plain"}),be=window.URL.createObjectURL(we),je=document.createElement("a");je.href=be,je.download="logs.txt",je.click(),window.URL.revokeObjectURL(be),e(i("logs.download_success"),"success")},J=()=>pe(null,null,function*(){if(t!=="connected"){P(!1);return}P(!0),E("");try{const X=yield Nd.fetchErrorLogs();A(Array.isArray(X.files)?X.files:[])}catch(X){console.error("Failed to load error logs:",X),A([]);const we=Hd(X);E(we?`${i("logs.error_logs_load_error")}: ${we}`:i("logs.error_logs_load_error"))}finally{P(!1)}}),me=X=>pe(null,null,function*(){try{const we=yield Nd.downloadErrorLog(X),be=new Blob([we.data],{type:"text/plain"}),je=window.URL.createObjectURL(be),Ve=document.createElement("a");Ve.href=je,Ve.download=X,Ve.click(),window.URL.revokeObjectURL(je),e(i("logs.error_log_download_success"),"success")}catch(we){const be=Hd(we);e(`${i("notification.download_failed")}${be?`: ${be}`:""}`,"error")}});N.useEffect(()=>{t==="connected"&&(G.current=0,F(!1))},[t]),N.useEffect(()=>{s==="errors"&&t==="connected"&&J()},[s,t,n]),N.useEffect(()=>{if(!_||t!=="connected")return;const X=window.setInterval(()=>{F(!0)},8e3);return()=>window.clearInterval(X)},[_,t]),N.useEffect(()=>{W.current&&(c||H.current&&(ue(),W.current=!1))},[c,r.buffer,r.visibleFrom]);const Se=N.useMemo(()=>r.buffer.slice(r.visibleFrom),[r.buffer,r.visibleFrom]),Re=w.trim(),He=Re.length>0,Ke=He?r.buffer:Se,{filteredLines:it,removedCount:fi}=N.useMemo(()=>{let X=Ke,we=0;if(k){const be=[];for(const je of X)je.includes(Fx)?we+=1:be.push(je);X=be}if(Re){const be=Re.toLowerCase(),je=[];for(const Ve of X)Ve.toLowerCase().includes(be)?je.push(Ve):we+=1;X=je}return{filteredLines:X,removedCount:we}},[Ke,k,Re]),Pi=N.useMemo(()=>it.map(X=>ble(X)),[it]),ft=!He&&r.visibleFrom>0,ii=()=>{const X=H.current;X&&(He||ft&&(V.current||X.scrollTop>lle||(V.current={scrollHeight:X.scrollHeight,scrollTop:X.scrollTop},o(we=>ee(z({},we),{visibleFrom:Math.max(we.visibleFrom-ole,0)})))))};N.useLayoutEffect(()=>{const X=H.current,we=V.current;if(!X||!we)return;const be=X.scrollHeight-we.scrollHeight;X.scrollTop=we.scrollTop+be,V.current=null},[r.visibleFrom]);const Tn=X=>pe(null,null,function*(){(yield vle(X))?e(i("logs.copy_success",{defaultValue:"Copied to clipboard"}),"success"):e(i("logs.copy_failed",{defaultValue:"Copy failed"}),"error")}),Mn=()=>{var X;(X=U.current)!=null&&X.timer&&(window.clearTimeout(U.current.timer),U.current.timer=null)},aa=(X,we)=>{n&&we&&(L||(Mn(),U.current={timer:window.setTimeout(()=>{D(we),U.current&&(U.current.fired=!0,U.current.timer=null)},cle),startX:X.clientX,startY:X.clientY,fired:!1}))},vi=()=>{Mn(),U.current=null},Ee=X=>{const we=U.current;if(!we||we.timer===null||we.fired)return;const be=Math.abs(X.clientX-we.startX),je=Math.abs(X.clientY-we.startY);(be>gN||je>gN)&&vi()},_t=()=>{q||D(null)},he=X=>pe(null,null,function*(){B(!0);try{const we=yield Nd.downloadRequestLogById(X),be=new Blob([we.data],{type:"text/plain"}),je=window.URL.createObjectURL(be),Ve=document.createElement("a");Ve.href=je,Ve.download=`request-${X}.log`,Ve.click(),window.URL.revokeObjectURL(je),e(i("logs.request_log_download_success"),"success"),D(null)}catch(we){const be=Hd(we);e(`${i("notification.download_failed")}${be?`: ${be}`:""}`,"error")}finally{B(!1)}});return N.useEffect(()=>()=>{var X;(X=U.current)!=null&&X.timer&&(window.clearTimeout(U.current.timer),U.current.timer=null)},[]),g.jsxs("div",{className:Fe.container,children:[g.jsx("h1",{className:Fe.pageTitle,children:i("logs.title")}),g.jsxs("div",{className:Fe.tabBar,children:[g.jsx("button",{type:"button",className:`${Fe.tabItem} ${s==="logs"?Fe.tabActive:""}`,onClick:()=>a("logs"),children:i("logs.log_content")}),g.jsx("button",{type:"button",className:`${Fe.tabItem} ${s==="errors"?Fe.tabActive:""}`,onClick:()=>a("errors"),children:i("logs.error_logs_modal_title")})]}),g.jsxs("div",{className:Fe.content,children:[s==="logs"&&g.jsxs(vt,{className:Fe.logCard,children:[h&&g.jsx("div",{className:"error-box",children:h}),g.jsxs("div",{className:Fe.filters,children:[g.jsx("div",{className:Fe.searchWrapper,children:g.jsx(et,{value:x,onChange:X=>v(X.target.value),placeholder:i("logs.search_placeholder"),className:Fe.searchInput,rightElement:x?g.jsx("button",{type:"button",className:Fe.searchClear,onClick:()=>v(""),title:"Clear","aria-label":"Clear",children:g.jsx(Hl,{size:16})}):g.jsx($N,{size:16,className:Fe.searchIcon})})}),g.jsx(Sn,{checked:k,onChange:M,label:g.jsxs("span",{className:Fe.switchLabel,children:[g.jsx(eR,{size:16}),i("logs.hide_management_logs",{prefix:Fx})]})}),g.jsxs("div",{className:Fe.toolbar,children:[g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>F(!1),disabled:$||c,className:Fe.actionButton,children:g.jsxs("span",{className:Fe.buttonContent,children:[g.jsx(YN,{size:16}),i("logs.refresh_button")]})}),g.jsx(Sn,{checked:_,onChange:X=>y(X),disabled:$,label:g.jsxs("span",{className:Fe.switchLabel,children:[g.jsx(jv,{size:16}),i("logs.auto_refresh")]})}),g.jsx(ye,{variant:"secondary",size:"sm",onClick:ce,disabled:r.buffer.length===0,className:Fe.actionButton,children:g.jsxs("span",{className:Fe.buttonContent,children:[g.jsx(ZN,{size:16}),i("logs.download_button")]})}),g.jsx(ye,{variant:"danger",size:"sm",onClick:Y,disabled:$,className:Fe.actionButton,children:g.jsxs("span",{className:Fe.buttonContent,children:[g.jsx(JN,{size:16}),i("logs.clear_button")]})})]})]}),c?g.jsx("div",{className:"hint",children:i("logs.loading")}):r.buffer.length>0&&Pi.length>0?g.jsxs("div",{ref:H,className:Fe.logPanel,onScroll:ii,children:[ft&&g.jsxs("div",{className:Fe.loadMoreBanner,children:[g.jsx("span",{children:i("logs.load_more_hint")}),g.jsxs("div",{className:Fe.loadMoreStats,children:[g.jsx("span",{children:i("logs.loaded_lines",{count:Pi.length})}),fi>0&&g.jsx("span",{className:Fe.loadMoreCount,children:i("logs.filtered_lines",{count:fi})}),g.jsx("span",{className:Fe.loadMoreCount,children:i("logs.hidden_lines",{count:r.visibleFrom})})]})]}),g.jsx("div",{className:Fe.logList,children:Pi.map((X,we)=>{const be=[Fe.logRow];return X.level==="warn"&&be.push(Fe.rowWarn),(X.level==="error"||X.level==="fatal")&&be.push(Fe.rowError),g.jsxs("div",{className:be.join(" "),onDoubleClick:()=>{Tn(X.raw)},onPointerDown:je=>aa(je,X.requestId),onPointerUp:vi,onPointerLeave:vi,onPointerCancel:vi,onPointerMove:Ee,title:i("logs.double_click_copy_hint",{defaultValue:"Double-click to copy"}),children:[g.jsx("div",{className:Fe.timestamp,children:X.timestamp||""}),g.jsxs("div",{className:Fe.rowMain,children:[X.level&&g.jsx("span",{className:[Fe.badge,X.level==="info"?Fe.levelInfo:"",X.level==="warn"?Fe.levelWarn:"",X.level==="error"||X.level==="fatal"?Fe.levelError:"",X.level==="debug"?Fe.levelDebug:"",X.level==="trace"?Fe.levelTrace:""].filter(Boolean).join(" "),children:X.level.toUpperCase()}),X.source&&g.jsx("span",{className:Fe.source,title:X.source,children:X.source}),X.requestId&&g.jsx("span",{className:[Fe.badge,Fe.requestIdBadge].join(" "),title:X.requestId,children:X.requestId}),typeof X.statusCode=="number"&&g.jsx("span",{className:[Fe.badge,Fe.statusBadge,X.statusCode>=200&&X.statusCode<300?Fe.statusSuccess:X.statusCode>=300&&X.statusCode<400?Fe.statusInfo:X.statusCode>=400&&X.statusCode<500?Fe.statusWarn:Fe.statusError].join(" "),children:X.statusCode}),X.latency&&g.jsx("span",{className:Fe.pill,children:X.latency}),X.ip&&g.jsx("span",{className:Fe.pill,children:X.ip}),X.method&&g.jsx("span",{className:[Fe.badge,Fe.methodBadge].join(" "),children:X.method}),X.path&&g.jsx("span",{className:Fe.path,title:X.path,children:X.path}),X.message&&g.jsx("span",{className:Fe.message,children:X.message})]})]},`${r.visibleFrom+we}-${X.raw}`)})})]}):r.buffer.length>0?g.jsx(Ps,{title:i("logs.search_empty_title"),description:i("logs.search_empty_desc")}):g.jsx(Ps,{title:i("logs.empty_title"),description:i("logs.empty_desc")})]}),s==="errors"&&g.jsx(vt,{extra:g.jsx(ye,{variant:"secondary",size:"sm",onClick:J,loading:C,disabled:$,children:i("common.refresh")}),children:g.jsxs("div",{className:"stack",children:[g.jsx("div",{className:"hint",children:i("logs.error_logs_description")}),n&&g.jsx("div",{children:g.jsx("div",{className:"status-badge warning",children:i("logs.error_logs_request_log_enabled")})}),R&&g.jsx("div",{className:"error-box",children:R}),g.jsx("div",{className:Fe.errorPanel,children:C?g.jsx("div",{className:"hint",children:i("common.loading")}):O.length===0?g.jsx("div",{className:"hint",children:i("logs.error_logs_empty")}):g.jsx("div",{className:"item-list",children:O.map(X=>g.jsxs("div",{className:"item-row",children:[g.jsxs("div",{className:"item-meta",children:[g.jsx("div",{className:"item-title",children:X.name}),g.jsxs("div",{className:"item-subtitle",children:[X.size?`${(X.size/1024).toFixed(1)} KB`:""," ",X.modified?W7(X.modified):""]})]}),g.jsx("div",{className:"item-actions",children:g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>me(X.name),disabled:$,children:i("logs.error_logs_download")})})]},X.name))})})]})})]}),g.jsx(zn,{open:!!L,onClose:_t,title:i("logs.request_log_download_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:_t,disabled:q,children:i("common.cancel")}),g.jsx(ye,{onClick:()=>{L&&he(L)},loading:q,disabled:!L,children:i("common.confirm")})]}),children:L?i("logs.request_log_download_confirm",{id:L}):null})]})}const wle="SystemPage-module__container___KAydo",kle="SystemPage-module__pageTitle___DiF5E",Ale="SystemPage-module__content___SauLn",Cle="SystemPage-module__sectionDescription___nI7Jo",Ole="SystemPage-module__clearLoginActions___4ek-m",Tle="SystemPage-module__modelTags___M0sci",Mle="SystemPage-module__modelTag___5Ar53",Nle="SystemPage-module__modelName___LKdAK",Rle="SystemPage-module__modelAlias___zioM-",Ple="SystemPage-module__quickLinks___QTmT3",Lle="SystemPage-module__linkCard___iSrVF",jle="SystemPage-module__linkIcon___gNqz2",Ele="SystemPage-module__github___V8I3m",Dle="SystemPage-module__docs___cA-rG",Ule="SystemPage-module__linkContent___Rfh7h",Fle="SystemPage-module__linkTitle___Zpr4Q",Ble="SystemPage-module__linkDesc___KKavC",At={container:wle,pageTitle:kle,content:Ale,sectionDescription:Cle,clearLoginActions:Ole,modelTags:Tle,modelTag:Mle,modelName:Nle,modelAlias:Rle,quickLinks:Ple,linkCard:Lle,linkIcon:jle,github:Ele,docs:Dle,linkContent:Ule,linkTitle:Fle,linkDesc:Ble};function zle(){const{t:i,i18n:e}=rt(),{showNotification:t}=Zn(),n=Ct(),s=Wt(O=>O.config),a=Wt(O=>O.fetchConfig),r=_l(O=>O.models),o=_l(O=>O.loading),c=_l(O=>O.error),d=_l(O=>O.fetchModels),[h,p]=N.useState(),_=N.useRef([]),y=N.useMemo(()=>{var O;return(O=e.language)!=null&&O.toLowerCase().startsWith("zh")?"其他":"Other"},[e.language]),x=N.useMemo(()=>uz(r,{otherLabel:y}),[r,y]),v=O=>{if(!Array.isArray(O))return[];const A=new Set,C=[];return O.forEach(P=>{var L,D;const R=typeof P=="string"?P:(D=(L=P==null?void 0:P["api-key"])!=null?L:P==null?void 0:P.apiKey)!=null?D:"",E=String(R||"").trim();!E||A.has(E)||(A.add(E),C.push(E))}),C},w=N.useCallback(()=>pe(null,null,function*(){if(_.current.length)return _.current;const O=v(s==null?void 0:s.apiKeys);if(O.length)return _.current=O,O;try{const A=yield Yc.list(),C=v(A);return C.length&&(_.current=C),C}catch(A){return console.warn("Auto loading API keys for models failed:",A),[]}}),[s==null?void 0:s.apiKeys]),k=(...A)=>pe(null,[...A],function*({forceRefresh:O=!1}={}){if(n.connectionStatus!=="connected"){p({type:"warning",message:i("notification.connection_required")});return}if(!n.apiBase){t(i("notification.connection_required"),"warning");return}O&&(_.current=[]),p({type:"muted",message:i("system_info.models_loading")});try{const P=(yield w())[0],R=yield d(n.apiBase,P,O),E=R.length>0;p({type:E?"success":"warning",message:E?i("system_info.models_count",{count:R.length}):i("system_info.models_empty")})}catch(C){const P=`${i("system_info.models_error")}: ${(C==null?void 0:C.message)||""}`;p({type:"error",message:P})}}),M=()=>{if(!window.confirm(i("system_info.clear_login_confirm"))||(n.logout(),typeof localStorage=="undefined"))return;[nR,"isLoggedIn","apiBase","apiUrl","managementKey"].forEach(A=>localStorage.removeItem(A)),t(i("notification.login_storage_cleared"),"success")};return N.useEffect(()=>{a().catch(()=>{})},[a]),N.useEffect(()=>{k()},[n.connectionStatus,n.apiBase]),g.jsxs("div",{className:At.container,children:[g.jsx("h1",{className:At.pageTitle,children:i("system_info.title")}),g.jsxs("div",{className:At.content,children:[g.jsx(vt,{title:i("system_info.connection_status_title"),extra:g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>a(void 0,!0),children:i("common.refresh")}),children:g.jsxs("div",{className:"grid cols-2",children:[g.jsxs("div",{className:"stat-card",children:[g.jsx("div",{className:"stat-label",children:i("connection.server_address")}),g.jsx("div",{className:"stat-value",children:n.apiBase||"-"})]}),g.jsxs("div",{className:"stat-card",children:[g.jsx("div",{className:"stat-label",children:i("footer.api_version")}),g.jsx("div",{className:"stat-value",children:n.serverVersion||i("system_info.version_unknown")})]}),g.jsxs("div",{className:"stat-card",children:[g.jsx("div",{className:"stat-label",children:i("footer.build_date")}),g.jsx("div",{className:"stat-value",children:n.serverBuildDate?new Date(n.serverBuildDate).toLocaleString():i("system_info.version_unknown")})]}),g.jsxs("div",{className:"stat-card",children:[g.jsx("div",{className:"stat-label",children:i("connection.status")}),g.jsx("div",{className:"stat-value",children:i(`common.${n.connectionStatus}_status`)})]})]})}),g.jsxs(vt,{title:i("system_info.quick_links_title"),children:[g.jsx("p",{className:At.sectionDescription,children:i("system_info.quick_links_desc")}),g.jsxs("div",{className:At.quickLinks,children:[g.jsxs("a",{href:"https://github.com/router-for-me/CLIProxyAPI",target:"_blank",rel:"noopener noreferrer",className:At.linkCard,children:[g.jsx("div",{className:`${At.linkIcon} ${At.github}`,children:g.jsx($U,{size:22})}),g.jsxs("div",{className:At.linkContent,children:[g.jsxs("div",{className:At.linkTitle,children:[i("system_info.link_main_repo"),g.jsx(v1,{size:14})]}),g.jsx("div",{className:At.linkDesc,children:i("system_info.link_main_repo_desc")})]})]}),g.jsxs("a",{href:"https://github.com/router-for-me/Cli-Proxy-API-Management-Center",target:"_blank",rel:"noopener noreferrer",className:At.linkCard,children:[g.jsx("div",{className:`${At.linkIcon} ${At.github}`,children:g.jsx(tF,{size:22})}),g.jsxs("div",{className:At.linkContent,children:[g.jsxs("div",{className:At.linkTitle,children:[i("system_info.link_webui_repo"),g.jsx(v1,{size:14})]}),g.jsx("div",{className:At.linkDesc,children:i("system_info.link_webui_repo_desc")})]})]}),g.jsxs("a",{href:"https://help.router-for.me/",target:"_blank",rel:"noopener noreferrer",className:At.linkCard,children:[g.jsx("div",{className:`${At.linkIcon} ${At.docs}`,children:g.jsx(eF,{size:22})}),g.jsxs("div",{className:At.linkContent,children:[g.jsxs("div",{className:At.linkTitle,children:[i("system_info.link_docs"),g.jsx(v1,{size:14})]}),g.jsx("div",{className:At.linkDesc,children:i("system_info.link_docs_desc")})]})]})]})]}),g.jsxs(vt,{title:i("system_info.models_title"),extra:g.jsx(ye,{variant:"secondary",size:"sm",onClick:()=>k({forceRefresh:!0}),loading:o,children:i("common.refresh")}),children:[g.jsx("p",{className:At.sectionDescription,children:i("system_info.models_desc")}),h&&g.jsx("div",{className:`status-badge ${h.type}`,children:h.message}),c&&g.jsx("div",{className:"error-box",children:c}),o?g.jsx("div",{className:"hint",children:i("common.loading")}):r.length===0?g.jsx("div",{className:"hint",children:i("system_info.models_empty")}):g.jsx("div",{className:"item-list",children:x.map(O=>g.jsxs("div",{className:"item-row",children:[g.jsxs("div",{className:"item-meta",children:[g.jsx("div",{className:"item-title",children:O.label}),g.jsx("div",{className:"item-subtitle",children:i("system_info.models_count",{count:O.items.length})})]}),g.jsx("div",{className:At.modelTags,children:O.items.map(A=>{var C;return g.jsxs("span",{className:At.modelTag,title:A.description||"",children:[g.jsx("span",{className:At.modelName,children:A.name}),A.alias&&g.jsx("span",{className:At.modelAlias,children:A.alias})]},`${A.name}-${(C=A.alias)!=null?C:"default"}`)})})]},O.id))})]}),g.jsxs(vt,{title:i("system_info.clear_login_title"),children:[g.jsx("p",{className:At.sectionDescription,children:i("system_info.clear_login_desc")}),g.jsx("div",{className:At.clearLoginActions,children:g.jsx(ye,{variant:"danger",onClick:M,children:i("system_info.clear_login_button")})})]})]})]})}const qle=[{path:"/",element:g.jsx(TO,{})},{path:"/dashboard",element:g.jsx(TO,{})},{path:"/settings",element:g.jsx($q,{})},{path:"/api-keys",element:g.jsx(nH,{})},{path:"/ai-providers",element:g.jsx(AK,{})},{path:"/auth-files",element:g.jsx(HV,{})},{path:"/oauth",element:g.jsx(dI,{})},{path:"/quota",element:g.jsx(iX,{})},{path:"/usage",element:g.jsx(YJ,{})},{path:"/config",element:g.jsx(moe,{})},{path:"/logs",element:g.jsx(Sle,{})},{path:"/system",element:g.jsx(zle,{})},{path:"*",element:g.jsx(Nv,{to:"/",replace:!0})}];function Hle({location:i}){return PN(qle,i)}const Ys={dashboard:g.jsx(iF,{size:18}),settings:g.jsx(zU,{size:18}),apiKeys:g.jsx(XN,{size:18}),aiProviders:g.jsx(Lv,{size:18}),authFiles:g.jsx(GN,{size:18}),oauth:g.jsx(qU,{size:18}),quota:g.jsx(jv,{size:18}),usage:g.jsx(HU,{size:18}),config:g.jsx(KU,{size:18}),logs:g.jsx(VU,{size:18}),system:g.jsx(QN,{size:18})},ga={width:16,height:16,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false"},_a={refresh:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),g.jsx("path",{d:"M21 3v5h-5"})]})),update:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("path",{d:"M12 19V5"}),g.jsx("path",{d:"m5 12 7-7 7 7"})]})),menu:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("path",{d:"M4 7h16"}),g.jsx("path",{d:"M4 12h16"}),g.jsx("path",{d:"M4 17h16"})]})),chevronLeft:g.jsx("svg",ee(z({},ga),{children:g.jsx("path",{d:"m14 18-6-6 6-6"})})),chevronRight:g.jsx("svg",ee(z({},ga),{children:g.jsx("path",{d:"m10 6 6 6-6 6"})})),language:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("circle",{cx:"12",cy:"12",r:"10"}),g.jsx("path",{d:"M2 12h20"}),g.jsx("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})),sun:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("circle",{cx:"12",cy:"12",r:"4"}),g.jsx("path",{d:"M12 2v2"}),g.jsx("path",{d:"M12 20v2"}),g.jsx("path",{d:"m4.93 4.93 1.41 1.41"}),g.jsx("path",{d:"m17.66 17.66 1.41 1.41"}),g.jsx("path",{d:"M2 12h2"}),g.jsx("path",{d:"M20 12h2"}),g.jsx("path",{d:"m6.34 17.66-1.41 1.41"}),g.jsx("path",{d:"m19.07 4.93-1.41 1.41"})]})),moon:g.jsx("svg",ee(z({},ga),{children:g.jsx("path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9z"})})),autoTheme:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("defs",{children:g.jsx("clipPath",{id:"mainLayoutAutoThemeSunLeftHalf",children:g.jsx("rect",{x:"0",y:"0",width:"12",height:"24"})})}),g.jsx("circle",{cx:"12",cy:"12",r:"4"}),g.jsx("circle",{cx:"12",cy:"12",r:"4",clipPath:"url(#mainLayoutAutoThemeSunLeftHalf)",fill:"currentColor"}),g.jsx("path",{d:"M12 2v2"}),g.jsx("path",{d:"M12 20v2"}),g.jsx("path",{d:"M4.93 4.93l1.41 1.41"}),g.jsx("path",{d:"M17.66 17.66l1.41 1.41"}),g.jsx("path",{d:"M2 12h2"}),g.jsx("path",{d:"M20 12h2"}),g.jsx("path",{d:"M6.34 17.66l-1.41 1.41"}),g.jsx("path",{d:"M19.07 4.93l-1.41 1.41"})]})),logout:g.jsxs("svg",ee(z({},ga),{children:[g.jsx("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),g.jsx("path",{d:"m16 17 5-5-5-5"}),g.jsx("path",{d:"M21 12H9"})]}))},xN=i=>{if(!i)return null;const e=i.trim().replace(/^v/i,"");if(!e)return null;const t=e.split(/[^0-9]+/).filter(Boolean).map(n=>Number.parseInt(n,10)).filter(Number.isFinite);return t.length?t:null},Kle=(i,e)=>{const t=xN(i),n=xN(e);if(!t||!n)return null;const s=Math.max(t.length,n.length);for(let a=0;ao)return 1;if(rEe.apiBase),a=Ct(Ee=>Ee.serverVersion),r=Ct(Ee=>Ee.serverBuildDate),o=Ct(Ee=>Ee.connectionStatus),c=Ct(Ee=>Ee.logout),d=Wt(Ee=>Ee.config),h=Wt(Ee=>Ee.fetchConfig),p=Wt(Ee=>Ee.clearCache),_=Wt(Ee=>Ee.updateConfigValue),y=_r(Ee=>Ee.theme),x=_r(Ee=>Ee.cycleTheme),v=wh(Ee=>Ee.toggleLanguage),[w,k]=N.useState(!1),[M,O]=N.useState(!1),[A,C]=N.useState(!1),[P,R]=N.useState(!0),[E,L]=N.useState(!1),[D,q]=N.useState(!1),[B,H]=N.useState(!1),[W,V]=N.useState(!1),U=N.useRef(null),G=N.useRef(null),$=N.useRef(null),ie=N.useRef(0),ue=N.useRef(null),F="CLI Proxy API Management Center",Y=i("title.abbr"),ce=(vi=d==null?void 0:d.requestLog)!=null?vi:!1,J=D!==ce,me=o==="connected"&&!!d,Se=n.pathname.startsWith("/logs");N.useLayoutEffect(()=>{const Ee=()=>{var X;const he=(X=$.current)==null?void 0:X.offsetHeight;he&&document.documentElement.style.setProperty("--header-height",`${he}px`)};Ee();const _t=typeof ResizeObserver!="undefined"&&$.current?new ResizeObserver(Ee):null;return _t&&$.current&&_t.observe($.current),window.addEventListener("resize",Ee),()=>{_t&&_t.disconnect(),window.removeEventListener("resize",Ee)}},[]),N.useEffect(()=>(G.current=setTimeout(()=>{R(!1)},5e3),()=>{G.current&&clearTimeout(G.current)}),[]),N.useEffect(()=>{E&&!B&&q(ce)},[E,B,ce]),N.useEffect(()=>()=>{ue.current&&clearTimeout(ue.current)},[]);const Re=N.useCallback(()=>{P||(R(!0),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>{R(!1)},5e3))},[P]),He=N.useCallback(()=>{H(!1),q(ce),L(!0)},[ce]),Ke=N.useCallback(()=>{L(!1),H(!1)},[]),it=N.useCallback(()=>{ie.current+=1,ue.current&&clearTimeout(ue.current),ue.current=setTimeout(()=>{ie.current=0},1500),ie.current>=7&&(ie.current=0,ue.current&&(clearTimeout(ue.current),ue.current=null),He())},[He]),fi=()=>pe(null,null,function*(){if(!me)return;if(!J){L(!1);return}const Ee=ce;V(!0),_("request-log",D);try{yield Ji.updateRequestLog(D),p("request-log"),t(i("notification.request_log_updated"),"success"),L(!1)}catch(_t){_("request-log",Ee),t(`${i("notification.update_failed")}: ${(_t==null?void 0:_t.message)||""}`,"error")}finally{V(!1)}});N.useEffect(()=>{h().catch(()=>{})},[h]);const Pi=o==="connected"?"success":o==="connecting"?"warning":o==="error"?"error":"muted",ft=[{path:"/",label:i("nav.dashboard"),icon:Ys.dashboard},{path:"/settings",label:i("nav.basic_settings"),icon:Ys.settings},{path:"/api-keys",label:i("nav.api_keys"),icon:Ys.apiKeys},{path:"/ai-providers",label:i("nav.ai_providers"),icon:Ys.aiProviders},{path:"/auth-files",label:i("nav.auth_files"),icon:Ys.authFiles},{path:"/oauth",label:i("nav.oauth",{defaultValue:"OAuth"}),icon:Ys.oauth},{path:"/quota",label:i("nav.quota_management"),icon:Ys.quota},{path:"/usage",label:i("nav.usage_stats"),icon:Ys.usage},{path:"/config",label:i("nav.config_management"),icon:Ys.config},...d!=null&&d.loggingToFile?[{path:"/logs",label:i("nav.logs"),icon:Ys.logs}]:[],{path:"/system",label:i("nav.system_info"),icon:Ys.system}],ii=ft.map(Ee=>Ee.path),Tn=Ee=>{const _t=Ee.length>1&&Ee.endsWith("/")?Ee.slice(0,-1):Ee,he=_t==="/dashboard"?"/":_t,X=ii.indexOf(he);if(X!==-1)return X;const we=ii.findIndex(be=>be!=="/"&&he.startsWith(`${be}/`));return we===-1?null:we},Mn=()=>pe(null,null,function*(){p();const _t=(yield Promise.allSettled([h(void 0,!0),XP()])).find(he=>he.status==="rejected");if(_t&&_t.status==="rejected"){const he=_t.reason,X=typeof he=="string"?he:he instanceof Error?he.message:"";t(`${i("notification.refresh_failed")}${X?`: ${X}`:""}`,"error");return}t(i("notification.data_refreshed"),"success")}),aa=()=>pe(null,null,function*(){var Ee,_t,he;C(!0);try{const X=yield uq.checkLatest(),we=(he=(_t=(Ee=X==null?void 0:X["latest-version"])!=null?Ee:X==null?void 0:X.latest_version)!=null?_t:X==null?void 0:X.latest)!=null?he:"",be=Kle(we,a);if(!we){t(i("system_info.version_check_error"),"error");return}if(be===null){t(i("system_info.version_current_missing"),"warning");return}be>0?t(i("system_info.version_update_available",{version:we}),"warning"):t(i("system_info.version_is_latest"),"success")}catch(X){t(`${i("system_info.version_check_error")}: ${(X==null?void 0:X.message)||""}`,"error")}finally{C(!1)}});return g.jsxs("div",{className:"app-shell",children:[g.jsxs("header",{className:"main-header",ref:$,children:[g.jsxs("div",{className:"left",children:[g.jsx("button",{className:"sidebar-toggle-header",onClick:()=>O(Ee=>!Ee),title:M?i("sidebar.expand",{defaultValue:"展开"}):i("sidebar.collapse",{defaultValue:"收起"}),children:M?_a.chevronRight:_a.chevronLeft}),g.jsx("img",{src:mg,alt:"CPAMC logo",className:"brand-logo"}),g.jsxs("div",{className:`brand-header ${P?"expanded":"collapsed"}`,onClick:Re,title:P?void 0:F,children:[g.jsx("span",{className:"brand-full",children:F}),g.jsx("span",{className:"brand-abbr",children:Y})]})]}),g.jsxs("div",{className:"right",children:[g.jsxs("div",{className:"connection",children:[g.jsx("span",{className:`status-badge ${Pi}`,children:i(o==="connected"?"common.connected_status":o==="connecting"?"common.connecting_status":"common.disconnected_status")}),g.jsx("span",{className:"base",children:s||"-"})]}),g.jsxs("div",{className:"header-actions",children:[g.jsx(ye,{className:"mobile-menu-btn",variant:"ghost",size:"sm",onClick:()=>k(Ee=>!Ee),children:_a.menu}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:Mn,title:i("header.refresh_all"),children:_a.refresh}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:aa,loading:A,title:i("system_info.version_check_button"),children:_a.update}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:v,title:i("language.switch"),children:_a.language}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:x,title:i("theme.switch"),children:y==="auto"?_a.autoTheme:y==="dark"?_a.moon:_a.sun}),g.jsx(ye,{variant:"ghost",size:"sm",onClick:c,title:i("header.logout"),children:_a.logout})]})]})]}),g.jsxs("div",{className:"main-body",children:[g.jsx("aside",{className:`sidebar ${w?"open":""} ${M?"collapsed":""}`,children:g.jsx("div",{className:"nav-section",children:ft.map(Ee=>g.jsxs(BN,{to:Ee.path,className:({isActive:_t})=>`nav-item ${_t?"active":""}`,onClick:()=>k(!1),title:M?Ee.label:void 0,children:[g.jsx("span",{className:"nav-icon",children:Ee.icon}),!M&&g.jsx("span",{className:"nav-label",children:Ee.label})]},Ee.path))})}),g.jsxs("div",{className:`content${Se?" content-logs":""}`,ref:U,children:[g.jsx("main",{className:`main-content${Se?" main-content-logs":""}`,children:g.jsx(q7,{render:Ee=>g.jsx(Hle,{location:Ee}),getRouteOrder:Tn,scrollContainerRef:U})}),g.jsxs("footer",{className:"footer",children:[g.jsxs("span",{children:[i("footer.api_version"),": ",a||i("system_info.version_unknown")]}),g.jsxs("span",{className:"footer-version",onClick:it,children:[i("footer.version"),": ","v1.2.17"]}),g.jsxs("span",{children:[i("footer.build_date"),":"," ",r?new Date(r).toLocaleString(e.language):i("system_info.version_unknown")]})]})]})]}),g.jsx(zn,{open:E,onClose:Ke,title:i("basic_settings.request_log_title"),footer:g.jsxs(g.Fragment,{children:[g.jsx(ye,{variant:"secondary",onClick:Ke,disabled:W,children:i("common.cancel")}),g.jsx(ye,{onClick:fi,loading:W,disabled:!me||!J,children:i("common.save")})]}),children:g.jsxs("div",{className:"request-log-modal",children:[g.jsx("div",{className:"status-badge warning",children:i("basic_settings.request_log_warning")}),g.jsx(Sn,{label:i("basic_settings.request_log_enable"),labelPosition:"left",checked:D,disabled:!me||W,onChange:Ee=>{q(Ee),H(!0)}})]})})]})}function Ile({children:i}){const e=Vs(),t=Ct(c=>c.isAuthenticated),n=Ct(c=>c.managementKey),s=Ct(c=>c.apiBase),a=Ct(c=>c.checkAuth),[r,o]=N.useState(!1);return N.useEffect(()=>{pe(null,null,function*(){if(!t&&n&&s){o(!0);try{yield a()}finally{o(!1)}}})},[s,t,n,a]),r?g.jsx("div",{className:"main-content",children:g.jsx(C0,{})}):t?i:g.jsx(Nv,{to:"/login",replace:!0,state:{from:e}})}const Wle=1500,Xle=400;function Gle(){const i=_r(p=>p.initializeTheme),e=wh(p=>p.language),t=wh(p=>p.setLanguage),n=Ct(p=>p.restoreSession),[s,a]=N.useState(!1),[r,o]=N.useState(!0),[c,d]=N.useState(!1);N.useEffect(()=>{const p=i();return n().finally(()=>{d(!0)}),p},[i,n]),N.useEffect(()=>{t(e)},[]),N.useEffect(()=>{document.documentElement.lang=e},[e]),N.useEffect(()=>{const p=setTimeout(()=>{a(!0)},Wle-Xle);return()=>clearTimeout(p)},[]);const h=N.useCallback(()=>{o(!1)},[]);return r?g.jsx(gz,{fadeOut:s&&c,onFinish:h}):g.jsxs(I6,{children:[g.jsx(pz,{}),g.jsxs(v6,{children:[g.jsx(Px,{path:"/login",element:g.jsx(fz,{})}),g.jsx(Px,{path:"/*",element:g.jsx(Ile,{children:g.jsx(Vle,{})})})]})]})}document.title="CLI Proxy API Management Center";const Nx=document.querySelector('link[rel="icon"]');if(Nx)Nx.href=mg,Nx.type="image/jpeg";else{const i=document.createElement("link");i.rel="icon",i.type="image/jpeg",i.href=mg,document.head.appendChild(i)}A8.createRoot(document.getElementById("root")).render(g.jsx(N.StrictMode,{children:g.jsx(Gle,{})}))});export default Qle();