@kimiclaw/cli 1.0.44 → 1.0.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -19
- package/package.json +9 -9
- package/web/dist/assets/{AssistantsView-Y4TXobGE.js → AssistantsView-Y3nFezhd.js} +1 -1
- package/web/dist/assets/AutomationView-bf7_zU_p.js +4 -0
- package/web/dist/assets/Button-B43HsIQ3.js +1 -0
- package/web/dist/assets/{ChannelConfigView-WJ-zUV8p.js → ChannelConfigView---Dwl3Fk.js} +3 -3
- package/web/dist/assets/ChartsView-Dw6G-jf3.js +1 -0
- package/web/dist/assets/{ConnectorsView-DaHmxnGE.js → ConnectorsView-BWvdrpyK.js} +2 -2
- package/web/dist/assets/{DiffPreview-D8tIj_aF.js → DiffPreview-WQihq3bK.js} +57 -56
- package/web/dist/assets/{FileContextMenu-C5WYeBNu.js → FileContextMenu-CyjXlSHp.js} +1 -1
- package/web/dist/assets/FileTreeView-Cafy33nT.js +1 -0
- package/web/dist/assets/HookConfigView-D-lASVju.js +2 -0
- package/web/dist/assets/InboxView-BWajw-Yx.js +1 -0
- package/web/dist/assets/InputArea-CSqaA55j.js +31 -0
- package/web/dist/assets/Install-ClEm4oGX.js +2 -0
- package/web/dist/assets/MemoryView-DLri75dm.js +1 -0
- package/web/dist/assets/ModelsView-BBLUMzR5.js +1 -0
- package/web/dist/assets/PluginsView-C-fnbDGZ.js +1 -0
- package/web/dist/assets/ProjectsView-BruI2W_l.js +1 -0
- package/web/dist/assets/{SessionGrid-BQSrCDqQ.js → SessionGrid-7GLpwn6d.js} +4 -4
- package/web/dist/assets/SettingsModal-cc9Qu2QU.js +4 -0
- package/web/dist/assets/SkillsView-Bf-2-U_q.js +1 -0
- package/web/dist/assets/TemplatesTab-CKul8nbL.js +2 -0
- package/web/dist/assets/{ToolsView-CjdYiaNz.js → ToolsView-D_aluOsK.js} +1 -1
- package/web/dist/assets/WorkspaceDirPicker-Z42YqE4a.js +5 -0
- package/web/dist/assets/{agentIconSet-CDeMxTHf.js → agentIconSet-Cqhm4UOl.js} +1 -1
- package/web/dist/assets/api-BW4-5gtM.js +1 -0
- package/web/dist/assets/chatStore-D8Zzr1hE.js +242 -0
- package/web/dist/assets/cn-CoHJgTJ5.js +1 -0
- package/web/dist/assets/{common-CPZxdYLs.js → common-CP2UB8TN.js} +99 -99
- package/web/dist/assets/icons-CittejKL.js +1 -0
- package/web/dist/assets/imageUrl-BVgcEm7e.js +2 -0
- package/web/dist/assets/index-CEUbTcNL.css +1 -0
- package/web/dist/assets/index-CxrzleFg.js +122 -0
- package/web/dist/assets/{markdown-Cps-36Z5.js → markdown-DZQBOzWk.js} +1 -1
- package/web/dist/assets/{panels-DCwx2Pbu.js → panels-CuDz4aqU.js} +1 -1
- package/web/dist/assets/projectsStore-B7fdKRzl.js +1 -0
- package/web/dist/assets/{react-vendor-CXI113IS.js → react-vendor-BEA-EtI-.js} +1 -1
- package/web/dist/assets/{settingsStore-BSdi9gNd.js → settingsStore-DYqiXodu.js} +1 -1
- package/web/dist/assets/src-55YckF5W.js +2 -0
- package/web/dist/assets/{state-pOTP5BEk.js → state-A4wJ8QgR.js} +1 -1
- package/web/dist/assets/{statusAxesRefresh--2evRuAU.js → statusAxesRefresh-BBqszCp-.js} +1 -1
- package/web/dist/assets/sttLanguages-jnSk4aqg.js +6 -0
- package/web/dist/assets/threadStore-CQi4OzSe.js +1 -0
- package/web/dist/assets/useConfirm-kTv3x0H6.js +1 -0
- package/web/dist/assets/{useTranslation-gGKZZfux.js → useTranslation-2BGEBvJE.js} +1 -1
- package/web/dist/assets/websocket-DCs7f54y.js +1 -0
- package/web/dist/assets/whatsNewStore-DoCQvcMq.js +1 -0
- package/web/dist/index.html +27 -23
- package/web/dist/assets/AutomationView-DfAF2L92.js +0 -3
- package/web/dist/assets/Button-D-g7PgYh.js +0 -1
- package/web/dist/assets/ChartsView-CSAfGqTC.js +0 -1
- package/web/dist/assets/FileTreeView-B7IN0KmE.js +0 -1
- package/web/dist/assets/HookConfigView-9gqvrRhQ.js +0 -2
- package/web/dist/assets/InboxView-BcEfijbj.js +0 -1
- package/web/dist/assets/InputArea-D5F91Uwk.js +0 -14
- package/web/dist/assets/Install-Cuelo0If.js +0 -2
- package/web/dist/assets/MemoryView-BvZSh5-T.js +0 -1
- package/web/dist/assets/ModelsView-BgvMN8xv.js +0 -1
- package/web/dist/assets/PluginsView-C3d6e8vV.js +0 -1
- package/web/dist/assets/ProjectsView-CM7GOsoK.js +0 -1
- package/web/dist/assets/SettingsModal-BvGXq5EE.js +0 -4
- package/web/dist/assets/SkillsView-87kGRliE.js +0 -1
- package/web/dist/assets/TemplatesTab-8MLwVNwV.js +0 -1
- package/web/dist/assets/api-ZQf0Ys8y.js +0 -1
- package/web/dist/assets/icons-B8Ngx6rM.js +0 -1
- package/web/dist/assets/imageUrl-CrQM4gmf.js +0 -74
- package/web/dist/assets/index-Bm7r92T3.css +0 -1
- package/web/dist/assets/index-STsyoFCk.js +0 -145
- package/web/dist/assets/src-BK8SoTFV.js +0 -1
- package/web/dist/assets/sttLanguages-BPcOF0nQ.js +0 -2
- package/web/dist/assets/useConfirm-CQjBnYuP.js +0 -1
- package/web/dist/assets/websocket-CeKJTCdp.js +0 -1
- package/web/dist/assets/whatsNewStore-C0hbStfc.js +0 -1
- package/web/dist/assets/workspaceSemantics-CW8ytHq2.js +0 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{ni as n}from"./icons-B8Ngx6rM.js";var r=e(n()),i=e=>typeof e==`string`,a=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},o=e=>e==null?``:String(e),s=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},c=/###/g,l=e=>e&&e.includes(`###`)?e.replace(c,`.`):e,u=e=>!e||i(e),d=(e,t,n)=>{let r=i(t)?t.split(`.`):t,a=0;for(;a<r.length-1;){if(u(e))return{};let t=l(r[a]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++a}return u(e)?{}:{obj:e,k:l(r[a])}},f=(e,t,n)=>{let{obj:r,k:i}=d(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=d(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=d(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},p=(e,t,n,r)=>{let{obj:i,k:a}=d(e,t,Object);i[a]=i[a]||[],i[a].push(n)},m=(e,t)=>{let{obj:n,k:r}=d(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},h=(e,t,n)=>{let r=m(e,n);return r===void 0?m(t,n):r},g=(e,t,n)=>{for(let r in t)r!==`__proto__`&&r!==`constructor`&&(Object.prototype.hasOwnProperty.call(e,r)?i(e[r])||e[r]instanceof String||i(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):g(e[r],t[r],n):e[r]=t[r]);return e},_=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),v={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`,"/":`/`},y=e=>i(e)?e.replace(/[&<>"'\/]/g,e=>v[e]):e,b=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},x=[` `,`,`,`?`,`!`,`;`],S=new b(20),C=(e,t,n)=>{t||=``,n||=``;let r=x.filter(e=>!t.includes(e)&&!n.includes(e));if(r.length===0)return!0;let i=S.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},w=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].includes(typeof t)&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},T=e=>e?.replace(/_/g,`-`),E={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},D=new class e{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||E,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,n,r){return r&&!this.debug?null:(e=e.map(e=>i(e)?e.replace(/[\r\n\x00-\x1F\x7F]/g,` `):e),i(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t||=this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},O=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(([n,r])=>{for(let i=0;i<r;i++)n(e,...t)})}},k=new WeakSet,A=class extends O{constructor(e,t={ns:[`translation`],defaultNS:`translation`}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n,r={}){let a=r.keySeparator===void 0?this.options.keySeparator:r.keySeparator,o=r.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:r.ignoreJSONStructure,s;e.includes(`.`)?s=e.split(`.`):(s=[e,t],n&&(Array.isArray(n)?s.push(...n):i(n)&&a?s.push(...n.split(a)):s.push(n)));let c=m(this.data,s);return!c&&!t&&!n&&e.includes(`.`)&&(e=s[0],t=s[1],n=s.slice(2).join(`.`)),c||!o||!i(n)?c:w(this.data?.[e]?.[t],n,a)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.includes(`.`)&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),f(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(i(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(`added`,e,t,n)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.includes(`.`)&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=m(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?g(s,n,i):s={...s,...n},f(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>{let n=t[e];return k.has(n)?!0:!n||Object.keys(n).length===0?!1:(typeof n==`object`&&k.add(n),!0)})}toJSON(){return this.data}},j={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},M=Symbol(`i18next/PATH_KEY`);function ee(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===M?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function N(e,t){let{[M]:n}=e(ee()),r=t?.keySeparator??`.`,i=t?.nsSeparator??`:`,a=t?.enableSelector===`strict`;if(n.length>1&&i){let e=t?.ns,o=a?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(o&&(a?o:o.length>1?o.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}var P=e=>!i(e)&&typeof e!=`boolean`&&typeof e!=`number`,F=class e extends O{constructor(e,t={}){super(),s([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=D.create(`translator`),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=P(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(e,t){let n=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;n===void 0&&(n=`:`);let r=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,a=t.ns||this.options.defaultNS||[],o=n&&e.includes(n),s=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!C(e,n,r);if(o&&!s){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:i(a)?[a]:a};let o=e.split(n);(n!==r||n===r&&this.options.ns.includes(o[0]))&&(a=o.shift()),e=o.join(r)}return{key:e,namespaces:i(a)?[a]:a}}translate(t,n,r){let a=typeof n==`object`?{...n}:n;if(typeof a!=`object`&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a==`object`&&(a={...a}),a||={},t==null)return``;typeof t==`function`&&(t=N(t,{...this.options,...a})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>typeof e==`function`?N(e,{...this.options,...a}):String(e));let o=a.returnDetails===void 0?this.options.returnDetails:a.returnDetails,s=a.keySeparator===void 0?this.options.keySeparator:a.keySeparator,{key:c,namespaces:l}=this.extractFromKey(t[t.length-1],a),u=l[l.length-1],d=a.nsSeparator===void 0?this.options.nsSeparator:a.nsSeparator;d===void 0&&(d=`:`);let f=a.lng||this.language,p=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()===`cimode`)return p?o?{res:`${u}${d}${c}`,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(a)}:`${u}${d}${c}`:o?{res:c,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(a)}:c;let m=this.resolve(t,a),h=m?.res,g=m?.usedKey||c,_=m?.exactUsedKey||c,v=[`[object Number]`,`[object Function]`,`[object RegExp]`],y=a.joinArrays===void 0?this.options.joinArrays:a.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,x=a.count!==void 0&&!i(a.count),S=e.hasDefaultValue(a),C=x?this.pluralResolver.getSuffix(f,a.count,a):``,w=a.ordinal&&x?this.pluralResolver.getSuffix(f,a.count,{ordinal:!1}):``,T=x&&!a.ordinal&&a.count===0,E=T&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${C}`]||a[`defaultValue${w}`]||a.defaultValue,D=h;b&&!h&&S&&(D=E);let O=P(D),k=Object.prototype.toString.apply(D);if(b&&D&&O&&!v.includes(k)&&!(i(y)&&Array.isArray(D))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,D,{...a,ns:l}):`key '${c} (${this.language})' returned an object instead of string.`;return o?(m.res=e,m.usedParams=this.getUsedParamsDetails(a),m):e}if(s){let e=Array.isArray(D),t=e?[]:{},n=e?_:g;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let r=`${n}${s}${e}`;t[e]=S&&!h?this.translate(r,{...a,defaultValue:P(E)?E[e]:void 0,joinArrays:!1,ns:l}):this.translate(r,{...a,joinArrays:!1,ns:l}),t[e]===r&&(t[e]=D[e])}h=t}}else if(b&&i(y)&&Array.isArray(h))h=h.join(y),h&&=this.extendTranslation(h,t,a,r);else{let e=!1,n=!1;!this.isValidLookup(h)&&S&&(e=!0,h=E),this.isValidLookup(h)||(n=!0,h=c);let i=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:h,o=S&&E!==h&&this.options.updateMissing;if(n||e||o){if(this.logger.log(o?`updateKey`:`missingKey`,f,u,x&&!o?`${c}${this.pluralResolver.getSuffix(f,a.count,a)}`:c,o?E:h),s){let e=this.resolve(c,{...a,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(a.lng||this.language):e.push(a.lng||this.language);let n=(e,t,n)=>{let r=S&&n!==h?n:i;this.options.missingKeyHandler?this.options.missingKeyHandler(e,u,t,r,o,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,u,t,r,o,a),this.emit(`missingKey`,e,u,t,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&x?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,a);T&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],c+t,a[`defaultValue${t}`]||E)})}):n(e,c,E))}h=this.extendTranslation(h,t,a,m,r),n&&h===c&&this.options.appendNamespaceToMissingKey&&(h=`${u}${d}${c}`),(n||e)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${c}`:c,e?h:void 0,a))}return o?(m.res=h,m.usedParams=this.getUsedParamsDetails(a),m):h}extendTranslation(e,t,n,r,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let o=i(e)&&(n?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:n.interpolation.skipOnVariables),s;if(o){let t=e.match(this.interpolator.nestingRegexp);s=t&&t.length}let c=n.replace&&!i(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),e=this.interpolator.interpolate(e,c,n.lng||this.language||r.usedLng,n),o){let t=e.match(this.interpolator.nestingRegexp),r=t&&t.length;s<r&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,(...e)=>a?.[0]===e[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):this.translate(...e,t),n)),n.interpolation&&this.interpolator.reset()}let o=n.postProcess||this.options.postProcess,s=i(o)?[o]:o;return e!=null&&s?.length&&n.applyPostProcessor!==!1&&(e=j.handle(s,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,a,o,s;return i(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(e=>typeof e==`function`?N(e,{...this.options,...t}):e)),e.forEach(e=>{if(this.isValidLookup(n))return;let c=this.extractFromKey(e,t),l=c.key;r=l;let u=c.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let d=t.count!==void 0&&!i(t.count),f=d&&!t.ordinal&&t.count===0,p=t.context!==void 0&&(i(t.context)||typeof t.context==`number`)&&t.context!==``,m=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(n)||(s=e,!this.checkedLoadedFor[`${m[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(s)&&(this.checkedLoadedFor[`${m[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${m.join(`, `)}" won't get resolved as namespace "${s}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),m.forEach(r=>{if(this.isValidLookup(n))return;o=r;let i=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(i,l,r,e,t);else{let e;d&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(t.ordinal&&e.startsWith(a)&&i.push(l+e.replace(a,this.options.pluralSeparator)),i.push(l+e),f&&i.push(l+n)),p){let r=`${l}${this.options.contextSeparator||`_`}${t.context}`;i.push(r),d&&(t.ordinal&&e.startsWith(a)&&i.push(r+e.replace(a,this.options.pluralSeparator)),i.push(r+e),f&&i.push(r+n))}}let s;for(;s=i.pop();)this.isValidLookup(n)||(a=s,n=this.getResource(r,e,s,t))}))})}),{res:n,usedKey:r,exactUsedKey:a,usedLng:o,usedNS:s}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],n=e.replace&&!i(e.replace),r=n?e.replace:e;if(n&&e.count!==void 0&&(r={...r,count:e.count}),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(let e of t)delete r[e]}return r}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith(`defaultValue`)&&e[t]!==void 0)return!0;return!1}},I=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=D.create(`languageUtils`),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(e=T(e),!e||!e.includes(`-`))return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=T(e),!e||!e.includes(`-`))return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(i(e)&&e.includes(`-`)){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?!0:!e.includes(`-`)&&!r.includes(`-`)?!1:!!(e.includes(`-`)&&!r.includes(`-`)&&e.slice(0,e.indexOf(`-`))===r||e.startsWith(r)&&r.length>1))}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),i(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||=e[this.getScriptPartFromCode(t)],n||=e[this.formatLanguageCode(t)],n||=e[this.getLanguagePartFromCode(t)],n||=e.default,n||[]}toResolveHierarchy(e,t){let n=this.options.fallbackLng,r=Array.isArray(n)?n.join(`|`):n;r!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=r);let a=t===void 0||t===!1||i(t),o=t===void 0&&typeof this.options.fallbackLng==`function`,s=i(e)&&a&&!o,c=null;if(s){let n;n=t===void 0?`undefined`:t===!1?`boolean:false`:`string:${t}`,c=`${e.length}:${e}|${n}`}if(c!==null){let e=this.resolveHierarchyCache[c];if(e!==void 0)return e.slice()}let l=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),u=[],d=e=>{e&&(this.isSupportedCode(e)?u.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return i(e)&&(e.includes(`-`)||e.includes(`_`))?(this.options.load!==`languageOnly`&&d(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&d(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&d(this.getLanguagePartFromCode(e))):i(e)&&d(this.formatLanguageCode(e)),l.forEach(e=>{let t=this.formatLanguageCode(e);u.includes(t)||d(t)}),c===null?u:(this.resolveHierarchyCache[c]=u,u.slice())}},L={zero:0,one:1,two:2,few:3,many:4,other:5},R={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},te=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=D.create(`pluralResolver`),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=T(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(typeof Intl>`u`)return this.logger.error(`No Intl support, please use an Intl polyfill!`),R;if(!e.match(/-|_/))return R;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>L[e]-L[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},z=(e,t,n,r=`.`,a=!0)=>{let o=h(e,t,n);return!o&&a&&i(n)&&(o=w(e,n,r),o===void 0&&(o=w(t,n,r))),o},B=class{constructor(e={}){this.logger=D.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:v}=e.interpolation;this.escape=t===void 0?y:t,this.escapeValue=n===void 0||n,this.useRawValueToEscape=r!==void 0&&r,this.prefix=i?_(i):a||`{{`,this.suffix=o?_(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u?_(u):`-`,this.unescapeSuffix=this.unescapePrefix?``:l?_(l):``,this.nestingPrefix=d?_(d):f||_(`$t(`),this.nestingSuffix=p?_(p):m||_(`)`),this.nestingOptionsSeparator=h||`,`,this.maxReplaces=g||1e3,this.alwaysFormat=v!==void 0&&v,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']|"[^"]*"|'[^']*'|\\((?:[^()"']|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let a,s,c,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=e=>{if(!e.includes(this.formatSeparator)){let i=z(t,l,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(z(t,l,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp(),!this.escapeValue&&typeof e==`string`&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn(`nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.`);let d=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e):e}].forEach(t=>{for(c=0;a=t.regex.exec(e);){let n=a[1].trim();if(s=u(n),s===void 0){if(typeof d==`function`){let t=d(e,a,r);s=i(t)?t:``}else if(r&&Object.prototype.hasOwnProperty.call(r,n))s=``;else if(f){s=a[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),s=``}else!i(s)&&!this.useRawValueToEscape&&(s=o(s));let l=o(t.safeValue(s));if(e=e.slice(0,a.index)+l+e.slice(a.index+a[0].length),f?(t.regex.lastIndex+=l.length,t.regex.lastIndex-=a[0].length):t.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,t,n={}){let r,a,s,c=(e,t)=>{let n=this.nestingOptionsSeparator;if(!e.includes(n))return e;let r=e.split(RegExp(`${_(n)}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,s);let a=i.match(/'/g),o=i.match(/"/g);((a?.length??0)%2==0&&!o||(o?.length??0)%2!=0)&&(i=i.replace(/'/g,`"`));try{s=JSON.parse(i),t&&(s={...t,...s})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return s.defaultValue&&s.defaultValue.includes(this.prefix)&&delete s.defaultValue,e},l=new RegExp(this.nestingRegexp),u=``,d=0;for(;r=l.exec(e);){let f=[];s={...n},s=s.replace&&!i(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;let p=/{.*}/s.test(r[1])?r[1].lastIndexOf(`}`)+1:r[1].indexOf(this.formatSeparator);if(p!==-1&&(f=r[1].slice(p).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,p)),a=t(c.call(this,r[1].trim(),s),s),a&&r[0]===e&&!i(a))return a;i(a)||(a=o(a)),a||=(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),``),f.length&&(a=f.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),a.trim())),u+=e.slice(d,r.index)+o(a),d=l.lastIndex,this.regexp.lastIndex=0}return d?u+e.slice(d):e}},ne=e=>{let t=e.toLowerCase().trim(),n={};if(e.includes(`(`)){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].slice(0,-1);t===`currency`&&!i.includes(`:`)?n.currency||=i.trim():t===`relativetime`&&!i.includes(`:`)?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},V=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(T(r),i),t[o]=s),s(n)}},re=e=>(t,n,r)=>e(T(n),r)(t),ie=class{constructor(e={}){this.logger=D.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?V:re;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=V(t)}format(e,t,n,r={}){if(!t||e==null)return e;let i=t.split(this.formatSeparator),a=[];for(let e=0;e<i.length;e++){let t=i[e];for(;t.indexOf(`(`)>-1&&!t.includes(`)`)&&e+1<i.length;)t=`${t}${this.formatSeparator}${i[++e]}`;a.push(t)}return a.reduce((e,t)=>{let{formatName:i,formatOptions:a}=ne(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e},e)}},ae=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},oe=class extends O{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=D.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{p(n.loaded,[i],a),ae(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}o&&s&&r<this.maxRetries?setTimeout(()=>{this.read(e,t,n,r+1,i*2,a)},i):a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2)try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}else return s(e,t,o)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),r&&r();i(e)&&(e=this.languageUtils.toResolveHierarchy(e)),i(t)&&(t=[t]);let a=this.queueLoad(e,t,n,r);if(!a.toLoad.length)return a.pending.length||r(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);else if(n!=null&&n!==``){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}},H=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),i(e[1])&&(t.defaultValue=e[1]),i(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),U=e=>(i(e.ns)&&(e.ns=[e.ns]),i(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),i(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes(`cimode`)&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),e),W=()=>{},se=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},G=class e extends O{constructor(e={},t){if(super(),this.options=U(e),this.services={},this.logger=D,this.modules={external:[]},se(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e==`function`&&(t=e,e={}),e.defaultNS==null&&e.ns&&(i(e.ns)?e.defaultNS=e.ns:e.ns.includes(`translation`)||(e.defaultNS=e.ns[0]));let n=H();this.options={...n,...this.options,...U(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!=`function`&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler);let r=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?D.init(r(this.modules.logger),this.options):D.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:ie;let t=new I(this.options);this.store=new A(this.options.resources,this.options);let n=this.services;n.logger=D,n.resourceStore=this.store,n.languageUtils=t,n.pluralResolver=new te(t,{prepend:this.options.pluralSeparator}),e&&(n.formatter=r(e),n.formatter.init&&n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new B(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new oe(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(n.languageDetector=r(this.modules.languageDetector),n.languageDetector.init&&n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=r(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new F(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||=W,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let o=a(),s=()=>{let e=(e,n)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),o.resolve(n),t(e,n)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?s():setTimeout(s,0),o}loadResources(e,t=W){let n=t,r=i(e)?e:this.language;if(typeof e==`function`&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return n();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&(e.includes(t)||e.push(t))})};r?t(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(e)})}else n(null)}reloadResources(e,t,n){let r=a();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||=this.languages,t||=this.options.ns,n||=W,this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&j.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&![`cimode`,`dev`].includes(e)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(![`cimode`,`dev`].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let n=a();this.emit(`languageChanging`,e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(i,a)=>{a?this.isLanguageChangingTo===e&&(r(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,a),this.logger.log(`languageChanged`,a)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(i,(...e)=>this.t(...e))},s=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let n=i(t)?t:t&&t[0],a=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(i(t)?[t]:t);a&&(this.language||r(a),this.translator.language||this.translator.changeLanguage(a),this.services.languageDetector?.cacheUserLanguage?.(a)),this.loadResources(a,e=>{o(e,a)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e),n}getFixedT(e,t,n,r){let a=r?.scopeNs,o=(e,t,...r)=>{let i;i=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(r)),i.lng=i.lng||o.lng,i.lngs=i.lngs||o.lngs;let s=i.ns!==void 0&&i.ns!==null;i.ns=i.ns||o.ns,i.keyPrefix!==``&&(i.keyPrefix=i.keyPrefix||n||o.keyPrefix);let c={...this.options,...i};Array.isArray(a)&&!s&&(c.ns=a),typeof i.keyPrefix==`function`&&(i.keyPrefix=N(i.keyPrefix,c));let l=this.options.keySeparator||`.`,u;return i.keyPrefix&&Array.isArray(e)?u=e.map(e=>(typeof e==`function`&&(e=N(e,c)),`${i.keyPrefix}${l}${e}`)):(typeof e==`function`&&(e=N(e,c)),u=i.keyPrefix?`${i.keyPrefix}${l}${e}`:e),this.t(u,i)};return i(e)?o.lng=e:o.lngs=e,o.ns=t,o.keyPrefix=n,o}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}if(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages)return!0;let{languageUtils:o}=this.services,s=t.lng?o.isSupportedCode(n)&&o.toResolveHierarchy(n,!1)[0]:n;return!(s&&!a(s,e)||r&&!a(i,e))}loadNamespaces(e,t){let n=a();return this.options.ns?(i(e)&&(e=[e]),e.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=a();i(e)&&(e=[e]);let r=this.options.preload||[],o=e.filter(e=>!r.includes(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=r.concat(o),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new I(H());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.includes(n.getLanguagePartFromCode(e))||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(t={},n){let r=new e(t,n);return r.createInstance=e.createInstance,r}cloneInstance(t={},n=W){let r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,preload:!1,...t,isClone:!0},a=new e(i);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new A(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),i),a.services.resourceStore=a.store),t.interpolation){let e={...H().interpolation,...this.options.interpolation,...t.interpolation},n={...i,interpolation:e};a.services.interpolator=new B(n)}return a.translator=new F(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance();G.createInstance,G.dir,G.init,G.loadResources,G.reloadResources,G.use,G.changeLanguage,G.getFixedT,G.t,G.exists,G.setDefaultNamespace,G.hasLoadedNamespace,G.loadNamespaces,G.loadLanguages;var ce=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);Z(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},K={},q=(e,t,n,r)=>{Z(n)&&K[n]||(Z(n)&&(K[n]=new Date),ce(e,t,n,r))},J=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},Y=(e,t,n)=>{e.loadNamespaces(t,J(e,n))},X=(e,t,n,r)=>{if(Z(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return Y(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,J(e,r))},le=(e,t,n={})=>!t.languages||!t.languages.length?(q(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),Z=e=>typeof e==`string`,ue=e=>typeof e==`object`&&!!e,de=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,fe={"&":`&`,"&":`&`,"<":`<`,"<":`<`,">":`>`,">":`>`,"'":`'`,"'":`'`,""":`"`,""":`"`," ":`\xA0`," ":`\xA0`,"©":`©`,"©":`©`,"®":`®`,"®":`®`,"…":`…`,"…":`…`,"/":`/`,"/":`/`},pe=e=>fe[e],Q={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(de,pe),transDefaultProps:void 0},me=(e={})=>{Q={...Q,...e}},he=()=>Q,$,ge=e=>{$=e},_e=()=>$,ve=(0,r.createContext)(),ye=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},be=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),xe=t(((e,t)=>{t.exports=be()}))(),Se={t:(e,t)=>{if(Z(t))return t;if(ue(t)&&Z(t.defaultValue))return t.defaultValue;if(typeof e==`function`)return``;if(Array.isArray(e)){let t=e[e.length-1];return typeof t==`function`?``:t}return e},ready:!1},Ce=()=>()=>{},we=(e,t={})=>{let{i18n:n}=t,{i18n:i,defaultNS:a}=(0,r.useContext)(ve)||{},o=n||i||_e();o&&!o.reportNamespaces&&(o.reportNamespaces=new ye),o||q(o,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`);let s=(0,r.useMemo)(()=>({...he(),...o?.options?.react,...t}),[o,t]),{useSuspense:c,keyPrefix:l,bindI18n:u,bindI18nStore:d}=s,f=e||a||o?.options?.defaultNS,p=Z(f)?[f]:f||[`translation`],m=(0,r.useMemo)(()=>p,p);o?.reportNamespaces?.addUsedNamespaces?.(m);let h=(0,r.useRef)(0),g=(0,r.useCallback)(e=>{if(!o)return Ce;let t=()=>{h.current+=1,e()};return u&&o.on(u,t),d&&o.store.on(d,t),()=>{u&&u.split(` `).forEach(e=>o.off(e,t)),d&&d.split(` `).forEach(e=>o.store.off(e,t))}},[o,u,d]),_=(0,r.useRef)(),v=(0,r.useCallback)(()=>{if(!o)return Se;let e=!!(o.isInitialized||o.initializedStoreOnce)&&m.every(e=>le(e,o,s)),n=t.lng||o.language,r=h.current,i=typeof l==`function`?N(l,{...o.options,ns:m}):l,a=_.current;if(a&&a.i18n===o&&a.ready===e&&a.lng===n&&a.namespaces===m&&a.keyPrefix===i&&a.revision===r)return a;let c={t:o.getFixedT(n,s.nsMode===`fallback`?m:m[0],l,{scopeNs:m}),i18n:o,ready:e,lng:n,namespaces:m,keyPrefix:i,revision:r};return _.current=c,c},[o,m,l,s,t.lng]),[y,b]=(0,r.useState)(0),{t:x,ready:S}=(0,xe.useSyncExternalStore)(g,v,v),C;o&&c&&!S&&(C=new Promise(e=>{let n=()=>e();t.lng?X(o,t.lng,m,n):Y(o,m,n)}),{t:x,ready:S}=v()),(0,r.useEffect)(()=>{if(o&&!S&&!c){let e=()=>b(e=>e+1);t.lng?X(o,t.lng,m,e):Y(o,m,e)}},[o,t.lng,m,S,c,y]);let w=o||{},T=(0,r.useRef)(null),E=(0,r.useRef)(),D=e=>`${e.language}|${e.resolvedLanguage}|${e.languages?.join(`,`)}`,O=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,"__original",{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},k=(0,r.useMemo)(()=>{let e=w,t=e&&D(e),n=e;e&&(T.current&&T.current.__original===e&&E.current===t?n=T.current:(n=O(e),T.current=n,E.current=t));let r=!S&&!c?(...e)=>(q(o,`USE_T_BEFORE_READY`,`useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.`),x(...e)):x,i=[r,n,S];return i.t=r,i.i18n=n,i.ready=S,i},[x,w,S,w.resolvedLanguage,w.language,w.languages]);if(o&&c&&!S){let e=!1;try{e=!1}catch{}throw e&&q(o,`SUSPENDED_WHILE_LOADING`,`useTranslation: suspended while translations are loading (useSuspense is true by default). Add a <Suspense> boundary above this component, or set react.useSuspense: false in the i18next init options. https://react.i18next.com/latest/usetranslation-hook`),C}return k};export{G as i,ge as n,me as r,we as t};
|
|
1
|
+
import{i as e,t}from"./rolldown-runtime-COiEfhsA.js";import{ii as n}from"./icons-CittejKL.js";var r=e(n()),i=e=>typeof e==`string`,a=()=>{let e,t,n=new Promise((n,r)=>{e=n,t=r});return n.resolve=e,n.reject=t,n},o=e=>e==null?``:String(e),s=(e,t,n)=>{e.forEach(e=>{t[e]&&(n[e]=t[e])})},c=/###/g,l=e=>e&&e.includes(`###`)?e.replace(c,`.`):e,u=e=>!e||i(e),d=(e,t,n)=>{let r=i(t)?t.split(`.`):t,a=0;for(;a<r.length-1;){if(u(e))return{};let t=l(r[a]);!e[t]&&n&&(e[t]=new n),e=Object.prototype.hasOwnProperty.call(e,t)?e[t]:{},++a}return u(e)?{}:{obj:e,k:l(r[a])}},f=(e,t,n)=>{let{obj:r,k:i}=d(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let a=t[t.length-1],o=t.slice(0,t.length-1),s=d(e,o,Object);for(;s.obj===void 0&&o.length;)a=`${o[o.length-1]}.${a}`,o=o.slice(0,o.length-1),s=d(e,o,Object),s?.obj&&s.obj[`${s.k}.${a}`]!==void 0&&(s.obj=void 0);s.obj[`${s.k}.${a}`]=n},p=(e,t,n,r)=>{let{obj:i,k:a}=d(e,t,Object);i[a]=i[a]||[],i[a].push(n)},m=(e,t)=>{let{obj:n,k:r}=d(e,t);if(n&&Object.prototype.hasOwnProperty.call(n,r))return n[r]},h=(e,t,n)=>{let r=m(e,n);return r===void 0?m(t,n):r},g=(e,t,n)=>{for(let r in t)r!==`__proto__`&&r!==`constructor`&&(Object.prototype.hasOwnProperty.call(e,r)?i(e[r])||e[r]instanceof String||i(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):g(e[r],t[r],n):e[r]=t[r]);return e},_=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,`\\$&`),v={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`,"/":`/`},y=e=>i(e)?e.replace(/[&<>"'\/]/g,e=>v[e]):e,b=class{constructor(e){this.capacity=e,this.regExpMap=new Map,this.regExpQueue=[]}getRegExp(e){let t=this.regExpMap.get(e);if(t!==void 0)return t;let n=new RegExp(e);return this.regExpQueue.length===this.capacity&&this.regExpMap.delete(this.regExpQueue.shift()),this.regExpMap.set(e,n),this.regExpQueue.push(e),n}},x=[` `,`,`,`?`,`!`,`;`],S=new b(20),C=(e,t,n)=>{t||=``,n||=``;let r=x.filter(e=>!t.includes(e)&&!n.includes(e));if(r.length===0)return!0;let i=S.getRegExp(`(${r.map(e=>e===`?`?`\\?`:e).join(`|`)})`),a=!i.test(e);if(!a){let t=e.indexOf(n);t>0&&!i.test(e.substring(0,t))&&(a=!0)}return a},w=(e,t,n=`.`)=>{if(!e)return;if(e[t])return Object.prototype.hasOwnProperty.call(e,t)?e[t]:void 0;let r=t.split(n),i=e;for(let e=0;e<r.length;){if(!i||typeof i!=`object`)return;let t,a=``;for(let o=e;o<r.length;++o)if(o!==e&&(a+=n),a+=r[o],t=i[a],t!==void 0){if([`string`,`number`,`boolean`].includes(typeof t)&&o<r.length-1)continue;e+=o-e+1;break}i=t}return i},T=e=>e?.replace(/_/g,`-`),E={type:`logger`,log(e){this.output(`log`,e)},warn(e){this.output(`warn`,e)},error(e){this.output(`error`,e)},output(e,t){console?.[e]?.apply?.(console,t)}},D=new class e{constructor(e,t={}){this.init(e,t)}init(e,t={}){this.prefix=t.prefix||`i18next:`,this.logger=e||E,this.options=t,this.debug=t.debug}log(...e){return this.forward(e,`log`,``,!0)}warn(...e){return this.forward(e,`warn`,``,!0)}error(...e){return this.forward(e,`error`,``)}deprecate(...e){return this.forward(e,`warn`,`WARNING DEPRECATED: `,!0)}forward(e,t,n,r){return r&&!this.debug?null:(e=e.map(e=>i(e)?e.replace(/[\r\n\x00-\x1F\x7F]/g,` `):e),i(e[0])&&(e[0]=`${n}${this.prefix} ${e[0]}`),this.logger[t](e))}create(t){return new e(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t||=this.options,t.prefix=t.prefix||this.prefix,new e(this.logger,t)}},O=class{constructor(){this.observers={}}on(e,t){return e.split(` `).forEach(e=>{this.observers[e]||(this.observers[e]=new Map);let n=this.observers[e].get(t)||0;this.observers[e].set(t,n+1)}),this}off(e,t){this.observers[e]&&(t?this.observers[e].delete(t):delete this.observers[e])}once(e,t){let n=(...r)=>{t(...r),this.off(e,n)};return this.on(e,n),this}emit(e,...t){this.observers[e]&&Array.from(this.observers[e].entries()).forEach(([e,n])=>{for(let r=0;r<n;r++)e(...t)}),this.observers[`*`]&&Array.from(this.observers[`*`].entries()).forEach(([n,r])=>{for(let i=0;i<r;i++)n(e,...t)})}},k=new WeakSet,A=class extends O{constructor(e,t={ns:[`translation`],defaultNS:`translation`}){super(),this.data=e||{},this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(e){this.options.ns.includes(e)||this.options.ns.push(e)}removeNamespaces(e){let t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}getResource(e,t,n,r={}){let a=r.keySeparator===void 0?this.options.keySeparator:r.keySeparator,o=r.ignoreJSONStructure===void 0?this.options.ignoreJSONStructure:r.ignoreJSONStructure,s;e.includes(`.`)?s=e.split(`.`):(s=[e,t],n&&(Array.isArray(n)?s.push(...n):i(n)&&a?s.push(...n.split(a)):s.push(n)));let c=m(this.data,s);return!c&&!t&&!n&&e.includes(`.`)&&(e=s[0],t=s[1],n=s.slice(2).join(`.`)),c||!o||!i(n)?c:w(this.data?.[e]?.[t],n,a)}addResource(e,t,n,r,i={silent:!1}){let a=i.keySeparator===void 0?this.options.keySeparator:i.keySeparator,o=[e,t];n&&(o=o.concat(a?n.split(a):n)),e.includes(`.`)&&(o=e.split(`.`),r=t,t=o[1]),this.addNamespaces(t),f(this.data,o,r),i.silent||this.emit(`added`,e,t,n,r)}addResources(e,t,n,r={silent:!1}){for(let r in n)(i(n[r])||Array.isArray(n[r]))&&this.addResource(e,t,r,n[r],{silent:!0});r.silent||this.emit(`added`,e,t,n)}addResourceBundle(e,t,n,r,i,a={silent:!1,skipCopy:!1}){let o=[e,t];e.includes(`.`)&&(o=e.split(`.`),r=n,n=t,t=o[1]),this.addNamespaces(t);let s=m(this.data,o)||{};a.skipCopy||(n=JSON.parse(JSON.stringify(n))),r?g(s,n,i):s={...s,...n},f(this.data,o,s),a.silent||this.emit(`added`,e,t,n)}removeResourceBundle(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit(`removed`,e,t)}hasResourceBundle(e,t){return this.getResource(e,t)!==void 0}getResourceBundle(e,t){return t||=this.options.defaultNS,this.getResource(e,t)}getDataByLanguage(e){return this.data[e]}hasLanguageSomeTranslations(e){let t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find(e=>{let n=t[e];return k.has(n)?!0:!n||Object.keys(n).length===0?!1:(typeof n==`object`&&k.add(n),!0)})}toJSON(){return this.data}},j={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(e=>{t=this.processors[e]?.process(t,n,r,i)??t}),t}},M=Symbol(`i18next/PATH_KEY`);function ee(){let e=[],t=Object.create(null),n;return t.get=(r,i)=>(n?.revoke?.(),i===M?e:(e.push(i),n=Proxy.revocable(r,t),n.proxy)),Proxy.revocable(Object.create(null),t).proxy}function N(e,t){let{[M]:n}=e(ee()),r=t?.keySeparator??`.`,i=t?.nsSeparator??`:`,a=t?.enableSelector===`strict`;if(n.length>1&&i){let e=t?.ns,o=a?Array.isArray(e)?e:e?[e]:null:Array.isArray(e)?e:null;if(o&&(a?o:o.length>1?o.slice(1):[]).includes(n[0]))return`${n[0]}${i}${n.slice(1).join(r)}`}return n.join(r)}var P=e=>!i(e)&&typeof e!=`boolean`&&typeof e!=`number`,F=class e extends O{constructor(e,t={}){super(),s([`resourceStore`,`languageUtils`,`pluralResolver`,`interpolator`,`backendConnector`,`i18nFormat`,`utils`],e,this),this.options=t,this.options.keySeparator===void 0&&(this.options.keySeparator=`.`),this.logger=D.create(`translator`),this.checkedLoadedFor={}}changeLanguage(e){e&&(this.language=e)}exists(e,t={interpolation:{}}){let n={...t};if(e==null)return!1;let r=this.resolve(e,n);if(r?.res===void 0)return!1;let i=P(r.res);return!(n.returnObjects===!1&&i)}extractFromKey(e,t){let n=t.nsSeparator===void 0?this.options.nsSeparator:t.nsSeparator;n===void 0&&(n=`:`);let r=t.keySeparator===void 0?this.options.keySeparator:t.keySeparator,a=t.ns||this.options.defaultNS||[],o=n&&e.includes(n),s=!this.options.userDefinedKeySeparator&&!t.keySeparator&&!this.options.userDefinedNsSeparator&&!t.nsSeparator&&!C(e,n,r);if(o&&!s){let t=e.match(this.interpolator.nestingRegexp);if(t&&t.length>0)return{key:e,namespaces:i(a)?[a]:a};let o=e.split(n);(n!==r||n===r&&this.options.ns.includes(o[0]))&&(a=o.shift()),e=o.join(r)}return{key:e,namespaces:i(a)?[a]:a}}translate(t,n,r){let a=typeof n==`object`?{...n}:n;if(typeof a!=`object`&&this.options.overloadTranslationOptionHandler&&(a=this.options.overloadTranslationOptionHandler(arguments)),typeof a==`object`&&(a={...a}),a||={},t==null)return``;typeof t==`function`&&(t=N(t,{...this.options,...a})),Array.isArray(t)||(t=[String(t)]),t=t.map(e=>typeof e==`function`?N(e,{...this.options,...a}):String(e));let o=a.returnDetails===void 0?this.options.returnDetails:a.returnDetails,s=a.keySeparator===void 0?this.options.keySeparator:a.keySeparator,{key:c,namespaces:l}=this.extractFromKey(t[t.length-1],a),u=l[l.length-1],d=a.nsSeparator===void 0?this.options.nsSeparator:a.nsSeparator;d===void 0&&(d=`:`);let f=a.lng||this.language,p=a.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(f?.toLowerCase()===`cimode`)return p?o?{res:`${u}${d}${c}`,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(a)}:`${u}${d}${c}`:o?{res:c,usedKey:c,exactUsedKey:c,usedLng:f,usedNS:u,usedParams:this.getUsedParamsDetails(a)}:c;let m=this.resolve(t,a),h=m?.res,g=m?.usedKey||c,_=m?.exactUsedKey||c,v=[`[object Number]`,`[object Function]`,`[object RegExp]`],y=a.joinArrays===void 0?this.options.joinArrays:a.joinArrays,b=!this.i18nFormat||this.i18nFormat.handleAsObject,x=a.count!==void 0&&!i(a.count),S=e.hasDefaultValue(a),C=x?this.pluralResolver.getSuffix(f,a.count,a):``,w=a.ordinal&&x?this.pluralResolver.getSuffix(f,a.count,{ordinal:!1}):``,T=x&&!a.ordinal&&a.count===0,E=T&&a[`defaultValue${this.options.pluralSeparator}zero`]||a[`defaultValue${C}`]||a[`defaultValue${w}`]||a.defaultValue,D=h;b&&!h&&S&&(D=E);let O=P(D),k=Object.prototype.toString.apply(D);if(b&&D&&O&&!v.includes(k)&&!(i(y)&&Array.isArray(D))){if(!a.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn(`accessing an object - but returnObjects options is not enabled!`);let e=this.options.returnedObjectHandler?this.options.returnedObjectHandler(g,D,{...a,ns:l}):`key '${c} (${this.language})' returned an object instead of string.`;return o?(m.res=e,m.usedParams=this.getUsedParamsDetails(a),m):e}if(s){let e=Array.isArray(D),t=e?[]:{},n=e?_:g;for(let e in D)if(Object.prototype.hasOwnProperty.call(D,e)){let r=`${n}${s}${e}`;t[e]=S&&!h?this.translate(r,{...a,defaultValue:P(E)?E[e]:void 0,joinArrays:!1,ns:l}):this.translate(r,{...a,joinArrays:!1,ns:l}),t[e]===r&&(t[e]=D[e])}h=t}}else if(b&&i(y)&&Array.isArray(h))h=h.join(y),h&&=this.extendTranslation(h,t,a,r);else{let e=!1,n=!1;!this.isValidLookup(h)&&S&&(e=!0,h=E),this.isValidLookup(h)||(n=!0,h=c);let i=(a.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&n?void 0:h,o=S&&E!==h&&this.options.updateMissing;if(n||e||o){if(this.logger.log(o?`updateKey`:`missingKey`,f,u,x&&!o?`${c}${this.pluralResolver.getSuffix(f,a.count,a)}`:c,o?E:h),s){let e=this.resolve(c,{...a,keySeparator:!1});e&&e.res&&this.logger.warn(`Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.`)}let e=[],t=this.languageUtils.getFallbackCodes(this.options.fallbackLng,a.lng||this.language);if(this.options.saveMissingTo===`fallback`&&t&&t[0])for(let n=0;n<t.length;n++)e.push(t[n]);else this.options.saveMissingTo===`all`?e=this.languageUtils.toResolveHierarchy(a.lng||this.language):e.push(a.lng||this.language);let n=(e,t,n)=>{let r=S&&n!==h?n:i;this.options.missingKeyHandler?this.options.missingKeyHandler(e,u,t,r,o,a):this.backendConnector?.saveMissing&&this.backendConnector.saveMissing(e,u,t,r,o,a),this.emit(`missingKey`,e,u,t,h)};this.options.saveMissing&&(this.options.saveMissingPlurals&&x?e.forEach(e=>{let t=this.pluralResolver.getSuffixes(e,a);T&&a[`defaultValue${this.options.pluralSeparator}zero`]&&!t.includes(`${this.options.pluralSeparator}zero`)&&t.push(`${this.options.pluralSeparator}zero`),t.forEach(t=>{n([e],c+t,a[`defaultValue${t}`]||E)})}):n(e,c,E))}h=this.extendTranslation(h,t,a,m,r),n&&h===c&&this.options.appendNamespaceToMissingKey&&(h=`${u}${d}${c}`),(n||e)&&this.options.parseMissingKeyHandler&&(h=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}${d}${c}`:c,e?h:void 0,a))}return o?(m.res=h,m.usedParams=this.getUsedParamsDetails(a),m):h}extendTranslation(e,t,n,r,a){if(this.i18nFormat?.parse)e=this.i18nFormat.parse(e,{...this.options.interpolation.defaultVariables,...n},n.lng||this.language||r.usedLng,r.usedNS,r.usedKey,{resolved:r});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init({...n,interpolation:{...this.options.interpolation,...n.interpolation}});let o=i(e)&&(n?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:n.interpolation.skipOnVariables),s;if(o){let t=e.match(this.interpolator.nestingRegexp);s=t&&t.length}let c=n.replace&&!i(n.replace)?n.replace:n;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),e=this.interpolator.interpolate(e,c,n.lng||this.language||r.usedLng,n),o){let t=e.match(this.interpolator.nestingRegexp),r=t&&t.length;s<r&&(n.nest=!1)}!n.lng&&r&&r.res&&(n.lng=this.language||r.usedLng),n.nest!==!1&&(e=this.interpolator.nest(e,(...e)=>a?.[0]===e[0]&&!n.context?(this.logger.warn(`It seems you are nesting recursively key: ${e[0]} in key: ${t[0]}`),null):this.translate(...e,t),n)),n.interpolation&&this.interpolator.reset()}let o=n.postProcess||this.options.postProcess,s=i(o)?[o]:o;return e!=null&&s?.length&&n.applyPostProcessor!==!1&&(e=j.handle(s,e,t,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...r,usedParams:this.getUsedParamsDetails(n)},...n}:n,this)),e}resolve(e,t={}){let n,r,a,o,s;return i(e)&&(e=[e]),Array.isArray(e)&&(e=e.map(e=>typeof e==`function`?N(e,{...this.options,...t}):e)),e.forEach(e=>{if(this.isValidLookup(n))return;let c=this.extractFromKey(e,t),l=c.key;r=l;let u=c.namespaces;this.options.fallbackNS&&(u=u.concat(this.options.fallbackNS));let d=t.count!==void 0&&!i(t.count),f=d&&!t.ordinal&&t.count===0,p=t.context!==void 0&&(i(t.context)||typeof t.context==`number`)&&t.context!==``,m=t.lngs?t.lngs:this.languageUtils.toResolveHierarchy(t.lng||this.language,t.fallbackLng);u.forEach(e=>{this.isValidLookup(n)||(s=e,!this.checkedLoadedFor[`${m[0]}-${e}`]&&this.utils?.hasLoadedNamespace&&!this.utils?.hasLoadedNamespace(s)&&(this.checkedLoadedFor[`${m[0]}-${e}`]=!0,this.logger.warn(`key "${r}" for languages "${m.join(`, `)}" won't get resolved as namespace "${s}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`)),m.forEach(r=>{if(this.isValidLookup(n))return;o=r;let i=[l];if(this.i18nFormat?.addLookupKeys)this.i18nFormat.addLookupKeys(i,l,r,e,t);else{let e;d&&(e=this.pluralResolver.getSuffix(r,t.count,t));let n=`${this.options.pluralSeparator}zero`,a=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(t.ordinal&&e.startsWith(a)&&i.push(l+e.replace(a,this.options.pluralSeparator)),i.push(l+e),f&&i.push(l+n)),p){let r=`${l}${this.options.contextSeparator||`_`}${t.context}`;i.push(r),d&&(t.ordinal&&e.startsWith(a)&&i.push(r+e.replace(a,this.options.pluralSeparator)),i.push(r+e),f&&i.push(r+n))}}let s;for(;s=i.pop();)this.isValidLookup(n)||(a=s,n=this.getResource(r,e,s,t))}))})}),{res:n,usedKey:r,exactUsedKey:a,usedLng:o,usedNS:s}}isValidLookup(e){return e!==void 0&&!(!this.options.returnNull&&e===null)&&!(!this.options.returnEmptyString&&e===``)}getResource(e,t,n,r={}){return this.i18nFormat?.getResource?this.i18nFormat.getResource(e,t,n,r):this.resourceStore.getResource(e,t,n,r)}getUsedParamsDetails(e={}){let t=[`defaultValue`,`ordinal`,`context`,`replace`,`lng`,`lngs`,`fallbackLng`,`ns`,`keySeparator`,`nsSeparator`,`returnObjects`,`returnDetails`,`joinArrays`,`postProcess`,`interpolation`],n=e.replace&&!i(e.replace),r=n?e.replace:e;if(n&&e.count!==void 0&&(r={...r,count:e.count}),this.options.interpolation.defaultVariables&&(r={...this.options.interpolation.defaultVariables,...r}),!n){r={...r};for(let e of t)delete r[e]}return r}static hasDefaultValue(e){for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t)&&t.startsWith(`defaultValue`)&&e[t]!==void 0)return!0;return!1}},I=class{constructor(e){this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=D.create(`languageUtils`),this.resolveHierarchyCache={}}clearCache(){this.resolveHierarchyCache={}}getScriptPartFromCode(e){if(e=T(e),!e||!e.includes(`-`))return null;let t=e.split(`-`);return t.length===2||(t.pop(),t[t.length-1].toLowerCase()===`x`)?null:this.formatLanguageCode(t.join(`-`))}getLanguagePartFromCode(e){if(e=T(e),!e||!e.includes(`-`))return e;let t=e.split(`-`);return this.formatLanguageCode(t[0])}formatLanguageCode(e){if(i(e)&&e.includes(`-`)){let t;try{t=Intl.getCanonicalLocales(e)[0]}catch{}return t&&this.options.lowerCaseLng&&(t=t.toLowerCase()),t||(this.options.lowerCaseLng?e.toLowerCase():e)}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}isSupportedCode(e){return(this.options.load===`languageOnly`||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.includes(e)}getBestMatchFromCodes(e){if(!e)return null;let t;return e.forEach(e=>{if(t)return;let n=this.formatLanguageCode(e);(!this.options.supportedLngs||this.isSupportedCode(n))&&(t=n)}),!t&&this.options.supportedLngs&&e.forEach(e=>{if(t)return;let n=this.getScriptPartFromCode(e);if(this.isSupportedCode(n))return t=n;let r=this.getLanguagePartFromCode(e);if(this.isSupportedCode(r))return t=r;t=this.options.supportedLngs.find(e=>e===r?!0:!e.includes(`-`)&&!r.includes(`-`)?!1:!!(e.includes(`-`)&&!r.includes(`-`)&&e.slice(0,e.indexOf(`-`))===r||e.startsWith(r)&&r.length>1))}),t||=this.getFallbackCodes(this.options.fallbackLng)[0],t}getFallbackCodes(e,t){if(!e)return[];if(typeof e==`function`&&(e=e(t)),i(e)&&(e=[e]),Array.isArray(e))return e;if(!t)return e.default||[];let n=e[t];return n||=e[this.getScriptPartFromCode(t)],n||=e[this.formatLanguageCode(t)],n||=e[this.getLanguagePartFromCode(t)],n||=e.default,n||[]}toResolveHierarchy(e,t){let n=this.options.fallbackLng,r=Array.isArray(n)?n.join(`|`):n;r!==this._cachedFallbackLng&&(this.resolveHierarchyCache={},this._cachedFallbackLng=r);let a=t===void 0||t===!1||i(t),o=t===void 0&&typeof this.options.fallbackLng==`function`,s=i(e)&&a&&!o,c=null;if(s){let n;n=t===void 0?`undefined`:t===!1?`boolean:false`:`string:${t}`,c=`${e.length}:${e}|${n}`}if(c!==null){let e=this.resolveHierarchyCache[c];if(e!==void 0)return e.slice()}let l=this.getFallbackCodes((t===!1?[]:t)||this.options.fallbackLng||[],e),u=[],d=e=>{e&&(this.isSupportedCode(e)?u.push(e):this.logger.warn(`rejecting language code not found in supportedLngs: ${e}`))};return i(e)&&(e.includes(`-`)||e.includes(`_`))?(this.options.load!==`languageOnly`&&d(this.formatLanguageCode(e)),this.options.load!==`languageOnly`&&this.options.load!==`currentOnly`&&d(this.getScriptPartFromCode(e)),this.options.load!==`currentOnly`&&d(this.getLanguagePartFromCode(e))):i(e)&&d(this.formatLanguageCode(e)),l.forEach(e=>{let t=this.formatLanguageCode(e);u.includes(t)||d(t)}),c===null?u:(this.resolveHierarchyCache[c]=u,u.slice())}},L={zero:0,one:1,two:2,few:3,many:4,other:5},R={select:e=>e===1?`one`:`other`,resolvedOptions:()=>({pluralCategories:[`one`,`other`]})},te=class{constructor(e,t={}){this.languageUtils=e,this.options=t,this.logger=D.create(`pluralResolver`),this.pluralRulesCache={}}clearCache(){this.pluralRulesCache={}}getRule(e,t={}){let n=T(e===`dev`?`en`:e),r=t.ordinal?`ordinal`:`cardinal`,i=JSON.stringify({cleanedCode:n,type:r});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(n,{type:r})}catch{if(typeof Intl>`u`)return this.logger.error(`No Intl support, please use an Intl polyfill!`),R;if(!e.match(/-|_/))return R;let n=this.languageUtils.getLanguagePartFromCode(e);a=this.getRule(n,t)}return this.pluralRulesCache[i]=a,a}needsPlural(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?.resolvedOptions().pluralCategories.length>1}getPluralFormsOfKey(e,t,n={}){return this.getSuffixes(e,n).map(e=>`${t}${e}`)}getSuffixes(e,t={}){let n=this.getRule(e,t);return n||=this.getRule(`dev`,t),n?n.resolvedOptions().pluralCategories.sort((e,t)=>L[e]-L[t]).map(e=>`${this.options.prepend}${t.ordinal?`ordinal${this.options.prepend}`:``}${e}`):[]}getSuffix(e,t,n={}){let r=this.getRule(e,n);return r?`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:``}${r.select(t)}`:(this.logger.warn(`no plural rule found for: ${e}`),this.getSuffix(`dev`,t,n))}},z=(e,t,n,r=`.`,a=!0)=>{let o=h(e,t,n);return!o&&a&&i(n)&&(o=w(e,n,r),o===void 0&&(o=w(t,n,r))),o},B=class{constructor(e={}){this.logger=D.create(`interpolator`),this.options=e,this.format=e?.interpolation?.format||(e=>e),this.init(e)}init(e={}){e.interpolation||={escapeValue:!0};let{escape:t,escapeValue:n,useRawValueToEscape:r,prefix:i,prefixEscaped:a,suffix:o,suffixEscaped:s,formatSeparator:c,unescapeSuffix:l,unescapePrefix:u,nestingPrefix:d,nestingPrefixEscaped:f,nestingSuffix:p,nestingSuffixEscaped:m,nestingOptionsSeparator:h,maxReplaces:g,alwaysFormat:v}=e.interpolation;this.escape=t===void 0?y:t,this.escapeValue=n===void 0||n,this.useRawValueToEscape=r!==void 0&&r,this.prefix=i?_(i):a||`{{`,this.suffix=o?_(o):s||`}}`,this.formatSeparator=c||`,`,this.unescapePrefix=l?``:u?_(u):`-`,this.unescapeSuffix=this.unescapePrefix?``:l?_(l):``,this.nestingPrefix=d?_(d):f||_(`$t(`),this.nestingSuffix=p?_(p):m||_(`)`),this.nestingOptionsSeparator=h||`,`,this.maxReplaces=g||1e3,this.alwaysFormat=v!==void 0&&v,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){let e=(e,t)=>e?.source===t?(e.lastIndex=0,e):new RegExp(t,`g`);this.regexp=e(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=e(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=e(this.nestingRegexp,`${this.nestingPrefix}((?:[^()"']|"[^"]*"|'[^']*'|\\((?:[^()"']|"[^"]*"|'[^']*')*\\))*?)${this.nestingSuffix}`)}interpolate(e,t,n,r){let a,s,c,l=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=e=>{if(!e.includes(this.formatSeparator)){let i=z(t,l,e,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(i,void 0,n,{...r,...t,interpolationkey:e}):i}let i=e.split(this.formatSeparator),a=i.shift().trim(),o=i.join(this.formatSeparator).trim();return this.format(z(t,l,a,this.options.keySeparator,this.options.ignoreJSONStructure),o,n,{...r,...t,interpolationkey:a})};this.resetRegExp(),!this.escapeValue&&typeof e==`string`&&/\$t\([^)]*\{[^}]*\{\{/.test(e)&&this.logger.warn(`nesting options string contains interpolated variables with escapeValue: false — if any of those values are attacker-controlled they can inject additional nesting options (e.g. redirect lng/ns). Sanitise untrusted input before passing it to t(), or keep escapeValue: true.`);let d=r?.missingInterpolationHandler||this.options.missingInterpolationHandler,f=r?.interpolation?.skipOnVariables===void 0?this.options.interpolation.skipOnVariables:r.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:e=>e},{regex:this.regexp,safeValue:e=>this.escapeValue?this.escape(e):e}].forEach(t=>{for(c=0;a=t.regex.exec(e);){let n=a[1].trim();if(s=u(n),s===void 0){if(typeof d==`function`){let t=d(e,a,r);s=i(t)?t:``}else if(r&&Object.prototype.hasOwnProperty.call(r,n))s=``;else if(f){s=a[0];continue}else this.logger.warn(`missed to pass in variable ${n} for interpolating ${e}`),s=``}else!i(s)&&!this.useRawValueToEscape&&(s=o(s));let l=o(t.safeValue(s));if(e=e.slice(0,a.index)+l+e.slice(a.index+a[0].length),f?(t.regex.lastIndex+=l.length,t.regex.lastIndex-=a[0].length):t.regex.lastIndex=0,c++,c>=this.maxReplaces)break}}),e}nest(e,t,n={}){let r,a,s,c=(e,t)=>{let n=this.nestingOptionsSeparator;if(!e.includes(n))return e;let r=e.split(RegExp(`${_(n)}[ ]*{`)),i=`{${r[1]}`;e=r[0],i=this.interpolate(i,s);let a=i.match(/'/g),o=i.match(/"/g);((a?.length??0)%2==0&&!o||(o?.length??0)%2!=0)&&(i=i.replace(/'/g,`"`));try{s=JSON.parse(i),t&&(s={...t,...s})}catch(t){return this.logger.warn(`failed parsing options string in nesting for key ${e}`,t),`${e}${n}${i}`}return s.defaultValue&&s.defaultValue.includes(this.prefix)&&delete s.defaultValue,e},l=new RegExp(this.nestingRegexp),u=``,d=0;for(;r=l.exec(e);){let f=[];s={...n},s=s.replace&&!i(s.replace)?s.replace:s,s.applyPostProcessor=!1,delete s.defaultValue;let p=/{.*}/s.test(r[1])?r[1].lastIndexOf(`}`)+1:r[1].indexOf(this.formatSeparator);if(p!==-1&&(f=r[1].slice(p).split(this.formatSeparator).map(e=>e.trim()).filter(Boolean),r[1]=r[1].slice(0,p)),a=t(c.call(this,r[1].trim(),s),s),a&&r[0]===e&&!i(a))return a;i(a)||(a=o(a)),a||=(this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`),``),f.length&&(a=f.reduce((e,t)=>this.format(e,t,n.lng,{...n,interpolationkey:r[1].trim()}),a.trim())),u+=e.slice(d,r.index)+o(a),d=l.lastIndex,this.regexp.lastIndex=0}return d?u+e.slice(d):e}},ne=e=>{let t=e.toLowerCase().trim(),n={};if(e.includes(`(`)){let r=e.split(`(`);t=r[0].toLowerCase().trim();let i=r[1].slice(0,-1);t===`currency`&&!i.includes(`:`)?n.currency||=i.trim():t===`relativetime`&&!i.includes(`:`)?n.range||=i.trim():i.split(`;`).forEach(e=>{if(e){let[t,...r]=e.split(`:`),i=r.join(`:`).trim().replace(/^'+|'+$/g,``),a=t.trim();n[a]||(n[a]=i),i===`false`&&(n[a]=!1),i===`true`&&(n[a]=!0),isNaN(i)||(n[a]=parseInt(i,10))}})}return{formatName:t,formatOptions:n}},V=e=>{let t={};return(n,r,i)=>{let a=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(a={...a,[i.interpolationkey]:void 0});let o=r+JSON.stringify(a),s=t[o];return s||(s=e(T(r),i),t[o]=s),s(n)}},re=e=>(t,n,r)=>e(T(n),r)(t),ie=class{constructor(e={}){this.logger=D.create(`formatter`),this.options=e,this.init(e)}init(e,t={interpolation:{}}){this.formatSeparator=t.interpolation.formatSeparator||`,`;let n=t.cacheInBuiltFormats?V:re;this.formats={number:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t});return e=>n.format(e)}),currency:n((e,t)=>{let n=new Intl.NumberFormat(e,{...t,style:`currency`});return e=>n.format(e)}),datetime:n((e,t)=>{let n=new Intl.DateTimeFormat(e,{...t});return e=>n.format(e)}),relativetime:n((e,t)=>{let n=new Intl.RelativeTimeFormat(e,{...t});return e=>n.format(e,t.range||`day`)}),list:n((e,t)=>{let n=new Intl.ListFormat(e,{...t});return e=>n.format(e)})}}add(e,t){this.formats[e.toLowerCase().trim()]=t}addCached(e,t){this.formats[e.toLowerCase().trim()]=V(t)}format(e,t,n,r={}){if(!t||e==null)return e;let i=t.split(this.formatSeparator),a=[];for(let e=0;e<i.length;e++){let t=i[e];for(;t.indexOf(`(`)>-1&&!t.includes(`)`)&&e+1<i.length;)t=`${t}${this.formatSeparator}${i[++e]}`;a.push(t)}return a.reduce((e,t)=>{let{formatName:i,formatOptions:a}=ne(t);if(this.formats[i]){let t=e;try{let o=r?.formatParams?.[r.interpolationkey]||{},s=o.locale||o.lng||r.locale||r.lng||n;t=this.formats[i](e,s,{...a,...r,...o})}catch(e){this.logger.warn(e)}return t}return this.logger.warn(`there was no format function for ${i}`),e},e)}},ae=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)},oe=class extends O{constructor(e,t,n,r={}){super(),this.backend=e,this.store=t,this.services=n,this.languageUtils=n.languageUtils,this.options=r,this.logger=D.create(`backendConnector`),this.waitingReads=[],this.maxParallelReads=r.maxParallelReads||10,this.readingCalls=0,this.maxRetries=r.maxRetries>=0?r.maxRetries:5,this.retryTimeout=r.retryTimeout>=1?r.retryTimeout:350,this.state={},this.queue=[],this.backend?.init?.(n,r.backend,r)}queueLoad(e,t,n,r){let i={},a={},o={},s={};return e.forEach(e=>{let r=!0;t.forEach(t=>{let o=`${e}|${t}`;!n.reload&&this.store.hasResourceBundle(e,t)?this.state[o]=2:this.state[o]<0||(this.state[o]===1?a[o]===void 0&&(a[o]=!0):(this.state[o]=1,r=!1,a[o]===void 0&&(a[o]=!0),i[o]===void 0&&(i[o]=!0),s[t]===void 0&&(s[t]=!0)))}),r||(o[e]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:r}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(o),toLoadNamespaces:Object.keys(s)}}loaded(e,t,n){let r=e.split(`|`),i=r[0],a=r[1];t&&this.emit(`failedLoading`,i,a,t),!t&&n&&this.store.addResourceBundle(i,a,n,void 0,void 0,{skipCopy:!0}),this.state[e]=t?-1:2,t&&n&&(this.state[e]=0);let o={};this.queue.forEach(n=>{p(n.loaded,[i],a),ae(n,e),t&&n.errors.push(t),n.pendingCount===0&&!n.done&&(Object.keys(n.loaded).forEach(e=>{o[e]||(o[e]={});let t=n.loaded[e];t.length&&t.forEach(t=>{o[e][t]===void 0&&(o[e][t]=!0)})}),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())}),this.emit(`loaded`,o),this.queue=this.queue.filter(e=>!e.done)}read(e,t,n,r=0,i=this.retryTimeout,a){if(!e.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:e,ns:t,fcName:n,tried:r,wait:i,callback:a});return}this.readingCalls++;let o=(o,s)=>{if(this.readingCalls--,this.waitingReads.length>0){let e=this.waitingReads.shift();this.read(e.lng,e.ns,e.fcName,e.tried,e.wait,e.callback)}o&&s&&r<this.maxRetries?setTimeout(()=>{this.read(e,t,n,r+1,i*2,a)},i):a(o,s)},s=this.backend[n].bind(this.backend);if(s.length===2)try{let n=s(e,t);n&&typeof n.then==`function`?n.then(e=>o(null,e)).catch(o):o(null,n)}catch(e){o(e)}else return s(e,t,o)}prepareLoading(e,t,n={},r){if(!this.backend)return this.logger.warn(`No backend was added via i18next.use. Will not load resources.`),r&&r();i(e)&&(e=this.languageUtils.toResolveHierarchy(e)),i(t)&&(t=[t]);let a=this.queueLoad(e,t,n,r);if(!a.toLoad.length)return a.pending.length||r(),null;a.toLoad.forEach(e=>{this.loadOne(e)})}load(e,t,n){this.prepareLoading(e,t,{},n)}reload(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}loadOne(e,t=``){let n=e.split(`|`),r=n[0],i=n[1];this.read(r,i,`read`,void 0,void 0,(n,a)=>{n&&this.logger.warn(`${t}loading namespace ${i} for language ${r} failed`,n),!n&&a&&this.logger.log(`${t}loaded namespace ${i} for language ${r}`,a),this.loaded(e,n,a)})}saveMissing(e,t,n,r,i,a={},o=()=>{}){if(this.services?.utils?.hasLoadedNamespace&&!this.services?.utils?.hasLoadedNamespace(t))this.logger.warn(`did not save key "${n}" as the namespace "${t}" was not yet loaded`,`This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!`);else if(n!=null&&n!==``){if(this.backend?.create){let s={...a,isUpdate:i},c=this.backend.create.bind(this.backend);if(c.length<6)try{let i;i=c.length===5?c(e,t,n,r,s):c(e,t,n,r),i&&typeof i.then==`function`?i.then(e=>o(null,e)).catch(o):o(null,i)}catch(e){o(e)}else c(e,t,n,r,o,s)}e&&e[0]&&this.store.addResource(e[0],t,n,r)}}},H=()=>({debug:!1,initAsync:!0,ns:[`translation`],defaultNS:[`translation`],fallbackLng:[`dev`],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:`all`,preload:!1,keySeparator:`.`,nsSeparator:`:`,pluralSeparator:`_`,contextSeparator:`_`,enableSelector:!1,partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:`fallback`,saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]==`object`&&(t=e[1]),i(e[1])&&(t.defaultValue=e[1]),i(e[2])&&(t.tDescription=e[2]),typeof e[2]==`object`||typeof e[3]==`object`){let n=e[3]||e[2];Object.keys(n).forEach(e=>{t[e]=n[e]})}return t},interpolation:{escapeValue:!0,prefix:`{{`,suffix:`}}`,formatSeparator:`,`,unescapePrefix:`-`,nestingPrefix:`$t(`,nestingSuffix:`)`,nestingOptionsSeparator:`,`,maxReplaces:1e3,skipOnVariables:!0},cacheInBuiltFormats:!0}),U=e=>(i(e.ns)&&(e.ns=[e.ns]),i(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),i(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&!e.supportedLngs.includes(`cimode`)&&(e.supportedLngs=e.supportedLngs.concat([`cimode`])),e),W=()=>{},se=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(t=>{typeof e[t]==`function`&&(e[t]=e[t].bind(e))})},G=class e extends O{constructor(e={},t){if(super(),this.options=U(e),this.services={},this.logger=D,this.modules={external:[]},se(this),t&&!this.isInitialized&&!e.isClone){if(!this.options.initAsync)return this.init(e,t),this;setTimeout(()=>{this.init(e,t)},0)}}init(e={},t){this.isInitializing=!0,typeof e==`function`&&(t=e,e={}),e.defaultNS==null&&e.ns&&(i(e.ns)?e.defaultNS=e.ns:e.ns.includes(`translation`)||(e.defaultNS=e.ns[0]));let n=H();this.options={...n,...this.options,...U(e)},this.options.interpolation={...n.interpolation,...this.options.interpolation},e.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=e.keySeparator),e.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=e.nsSeparator),typeof this.options.overloadTranslationOptionHandler!=`function`&&(this.options.overloadTranslationOptionHandler=n.overloadTranslationOptionHandler);let r=e=>e?typeof e==`function`?new e:e:null;if(!this.options.isClone){this.modules.logger?D.init(r(this.modules.logger),this.options):D.init(null,this.options);let e;e=this.modules.formatter?this.modules.formatter:ie;let t=new I(this.options);this.store=new A(this.options.resources,this.options);let n=this.services;n.logger=D,n.resourceStore=this.store,n.languageUtils=t,n.pluralResolver=new te(t,{prepend:this.options.pluralSeparator}),e&&(n.formatter=r(e),n.formatter.init&&n.formatter.init(n,this.options),this.options.interpolation.format=n.formatter.format.bind(n.formatter)),n.interpolator=new B(this.options),n.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},n.backendConnector=new oe(r(this.modules.backend),n.resourceStore,n,this.options),n.backendConnector.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.languageDetector&&(n.languageDetector=r(this.modules.languageDetector),n.languageDetector.init&&n.languageDetector.init(n,this.options.detection,this.options)),this.modules.i18nFormat&&(n.i18nFormat=r(this.modules.i18nFormat),n.i18nFormat.init&&n.i18nFormat.init(this)),this.translator=new F(this.services,this.options),this.translator.on(`*`,(e,...t)=>{this.emit(e,...t)}),this.modules.external.forEach(e=>{e.init&&e.init(this)})}if(this.format=this.options.interpolation.format,t||=W,this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){let e=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);e.length>0&&e[0]!==`dev`&&(this.options.lng=e[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn(`init: no languageDetector is used and no lng is defined`),[`getResource`,`hasResourceBundle`,`getResourceBundle`,`getDataByLanguage`].forEach(e=>{this[e]=(...t)=>this.store[e](...t)}),[`addResource`,`addResources`,`addResourceBundle`,`removeResourceBundle`].forEach(e=>{this[e]=(...t)=>(this.store[e](...t),this)});let o=a(),s=()=>{let e=(e,n)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn(`init: i18next is already initialized. You should call init just once!`),this.isInitialized=!0,this.options.isClone||this.logger.log(`initialized`,this.options),this.emit(`initialized`,this.options),o.resolve(n),t(e,n)};if((this.languages||this.isLanguageChangingTo)&&!this.isInitialized)return e(null,this.t.bind(this));this.changeLanguage(this.options.lng,e)};return this.options.resources||!this.options.initAsync?s():setTimeout(s,0),o}loadResources(e,t=W){let n=t,r=i(e)?e:this.language;if(typeof e==`function`&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(r?.toLowerCase()===`cimode`&&(!this.options.preload||this.options.preload.length===0))return n();let e=[],t=t=>{t&&t!==`cimode`&&this.services.languageUtils.toResolveHierarchy(t).forEach(t=>{t!==`cimode`&&(e.includes(t)||e.push(t))})};r?t(r):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(e=>t(e)),this.options.preload?.forEach?.(e=>t(e)),this.services.backendConnector.load(e,this.options.ns,e=>{!e&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),n(e)})}else n(null)}reloadResources(e,t,n){let r=a();return typeof e==`function`&&(n=e,e=void 0),typeof t==`function`&&(n=t,t=void 0),e||=this.languages,t||=this.options.ns,n||=W,this.services.backendConnector.reload(e,t,e=>{r.resolve(),n(e)}),r}use(e){if(!e)throw Error(`You are passing an undefined module! Please check the object you are passing to i18next.use()`);if(!e.type)throw Error(`You are passing a wrong module! Please check the object you are passing to i18next.use()`);return e.type===`backend`&&(this.modules.backend=e),(e.type===`logger`||e.log&&e.warn&&e.error)&&(this.modules.logger=e),e.type===`languageDetector`&&(this.modules.languageDetector=e),e.type===`i18nFormat`&&(this.modules.i18nFormat=e),e.type===`postProcessor`&&j.addPostProcessor(e),e.type===`formatter`&&(this.modules.formatter=e),e.type===`3rdParty`&&this.modules.external.push(e),this}setResolvedLanguage(e){if(e&&this.languages&&![`cimode`,`dev`].includes(e)){for(let e=0;e<this.languages.length;e++){let t=this.languages[e];if(![`cimode`,`dev`].includes(t)&&this.store.hasLanguageSomeTranslations(t)){this.resolvedLanguage=t;break}}!this.resolvedLanguage&&!this.languages.includes(e)&&this.store.hasLanguageSomeTranslations(e)&&(this.resolvedLanguage=e,this.languages.unshift(e))}}changeLanguage(e,t){this.isLanguageChangingTo=e;let n=a();this.emit(`languageChanging`,e);let r=e=>{this.language=e,this.languages=this.services.languageUtils.toResolveHierarchy(e),this.resolvedLanguage=void 0,this.setResolvedLanguage(e)},o=(i,a)=>{a?this.isLanguageChangingTo===e&&(r(a),this.translator.changeLanguage(a),this.isLanguageChangingTo=void 0,this.emit(`languageChanged`,a),this.logger.log(`languageChanged`,a)):this.isLanguageChangingTo=void 0,n.resolve((...e)=>this.t(...e)),t&&t(i,(...e)=>this.t(...e))},s=t=>{!e&&!t&&this.services.languageDetector&&(t=[]);let n=i(t)?t:t&&t[0],a=this.store.hasLanguageSomeTranslations(n)?n:this.services.languageUtils.getBestMatchFromCodes(i(t)?[t]:t);a&&(this.language||r(a),this.translator.language||this.translator.changeLanguage(a),this.services.languageDetector?.cacheUserLanguage?.(a)),this.loadResources(a,e=>{o(e,a)})};return!e&&this.services.languageDetector&&!this.services.languageDetector.async?s(this.services.languageDetector.detect()):!e&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(s):this.services.languageDetector.detect(s):s(e),n}getFixedT(e,t,n,r){let a=r?.scopeNs,o=(e,t,...r)=>{let i;i=typeof t==`object`?{...t}:this.options.overloadTranslationOptionHandler([e,t].concat(r)),i.lng=i.lng||o.lng,i.lngs=i.lngs||o.lngs;let s=i.ns!==void 0&&i.ns!==null;i.ns=i.ns||o.ns,i.keyPrefix!==``&&(i.keyPrefix=i.keyPrefix||n||o.keyPrefix);let c={...this.options,...i};Array.isArray(a)&&!s&&(c.ns=a),typeof i.keyPrefix==`function`&&(i.keyPrefix=N(i.keyPrefix,c));let l=this.options.keySeparator||`.`,u;return i.keyPrefix&&Array.isArray(e)?u=e.map(e=>(typeof e==`function`&&(e=N(e,c)),`${i.keyPrefix}${l}${e}`)):(typeof e==`function`&&(e=N(e,c)),u=i.keyPrefix?`${i.keyPrefix}${l}${e}`:e),this.t(u,i)};return i(e)?o.lng=e:o.lngs=e,o.ns=t,o.keyPrefix=n,o}t(...e){return this.translator?.translate(...e)}exists(...e){return this.translator?.exists(...e)}setDefaultNamespace(e){this.options.defaultNS=e}hasLoadedNamespace(e,t={}){if(!this.isInitialized)return this.logger.warn(`hasLoadedNamespace: i18next was not initialized`,this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn(`hasLoadedNamespace: i18n.languages were undefined or empty`,this.languages),!1;let n=t.lng||this.resolvedLanguage||this.languages[0],r=this.options?this.options.fallbackLng:!1,i=this.languages[this.languages.length-1];if(n.toLowerCase()===`cimode`)return!0;let a=(e,t)=>{let n=this.services.backendConnector.state[`${e}|${t}`];return n===-1||n===0||n===2};if(t.precheck){let e=t.precheck(this,a);if(e!==void 0)return e}if(this.hasResourceBundle(n,e)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages)return!0;let{languageUtils:o}=this.services,s=t.lng?o.isSupportedCode(n)&&o.toResolveHierarchy(n,!1)[0]:n;return!(s&&!a(s,e)||r&&!a(i,e))}loadNamespaces(e,t){let n=a();return this.options.ns?(i(e)&&(e=[e]),e.forEach(e=>{this.options.ns.includes(e)||this.options.ns.push(e)}),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}loadLanguages(e,t){let n=a();i(e)&&(e=[e]);let r=this.options.preload||[],o=e.filter(e=>!r.includes(e)&&this.services.languageUtils.isSupportedCode(e));return o.length?(this.options.preload=r.concat(o),this.loadResources(e=>{n.resolve(),t&&t(e)}),n):(t&&t(),Promise.resolve())}dir(e){if(e||=this.resolvedLanguage||(this.languages?.length>0?this.languages[0]:this.language),!e)return`rtl`;try{let t=new Intl.Locale(e);if(t&&t.getTextInfo){let e=t.getTextInfo();if(e&&e.direction)return e.direction}}catch{}let t=`ar.shu.sqr.ssh.xaa.yhd.yud.aao.abh.abv.acm.acq.acw.acx.acy.adf.ads.aeb.aec.afb.ajp.apc.apd.arb.arq.ars.ary.arz.auz.avl.ayh.ayl.ayn.ayp.bbz.pga.he.iw.ps.pbt.pbu.pst.prp.prd.ug.ur.ydd.yds.yih.ji.yi.hbo.men.xmn.fa.jpr.peo.pes.prs.dv.sam.ckb`.split(`.`),n=this.services?.languageUtils||new I(H());return e.toLowerCase().indexOf(`-latn`)>1?`ltr`:t.includes(n.getLanguagePartFromCode(e))||e.toLowerCase().indexOf(`-arab`)>1?`rtl`:`ltr`}static createInstance(t={},n){let r=new e(t,n);return r.createInstance=e.createInstance,r}cloneInstance(t={},n=W){let r=t.forkResourceStore;r&&delete t.forkResourceStore;let i={...this.options,preload:!1,...t,isClone:!0},a=new e(i);if((t.debug!==void 0||t.prefix!==void 0)&&(a.logger=a.logger.clone(t)),[`store`,`services`,`language`].forEach(e=>{a[e]=this[e]}),a.services={...this.services},a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},r&&(a.store=new A(Object.keys(this.store.data).reduce((e,t)=>(e[t]={...this.store.data[t]},e[t]=Object.keys(e[t]).reduce((n,r)=>(n[r]={...e[t][r]},n),e[t]),e),{}),i),a.services.resourceStore=a.store),t.interpolation){let e={...H().interpolation,...this.options.interpolation,...t.interpolation},n={...i,interpolation:e};a.services.interpolator=new B(n)}return a.translator=new F(a.services,i),a.translator.on(`*`,(e,...t)=>{a.emit(e,...t)}),a.init(i,n),a.translator.options=i,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}.createInstance();G.createInstance,G.dir,G.init,G.loadResources,G.reloadResources,G.use,G.changeLanguage,G.getFixedT,G.t,G.exists,G.setDefaultNamespace,G.hasLoadedNamespace,G.loadNamespaces,G.loadLanguages;var ce=(e,t,n,r)=>{let i=[n,{code:t,...r||{}}];if(e?.services?.logger?.forward)return e.services.logger.forward(i,`warn`,`react-i18next::`,!0);Z(i[0])&&(i[0]=`react-i18next:: ${i[0]}`),e?.services?.logger?.warn?e.services.logger.warn(...i):console?.warn&&console.warn(...i)},K={},q=(e,t,n,r)=>{Z(n)&&K[n]||(Z(n)&&(K[n]=new Date),ce(e,t,n,r))},J=(e,t)=>()=>{if(e.isInitialized)t();else{let n=()=>{setTimeout(()=>{e.off(`initialized`,n)},0),t()};e.on(`initialized`,n)}},Y=(e,t,n)=>{e.loadNamespaces(t,J(e,n))},X=(e,t,n,r)=>{if(Z(n)&&(n=[n]),e.options.preload&&e.options.preload.indexOf(t)>-1)return Y(e,n,r);n.forEach(t=>{e.options.ns.indexOf(t)<0&&e.options.ns.push(t)}),e.loadLanguages(t,J(e,r))},le=(e,t,n={})=>!t.languages||!t.languages.length?(q(t,`NO_LANGUAGES`,`i18n.languages were undefined or empty`,{languages:t.languages}),!0):t.hasLoadedNamespace(e,{lng:n.lng,precheck:(t,r)=>{if(n.bindI18n&&n.bindI18n.indexOf(`languageChanging`)>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!r(t.isLanguageChangingTo,e))return!1}}),Z=e=>typeof e==`string`,ue=e=>typeof e==`object`&&!!e,de=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,fe={"&":`&`,"&":`&`,"<":`<`,"<":`<`,">":`>`,">":`>`,"'":`'`,"'":`'`,""":`"`,""":`"`," ":`\xA0`," ":`\xA0`,"©":`©`,"©":`©`,"®":`®`,"®":`®`,"…":`…`,"…":`…`,"/":`/`,"/":`/`},pe=e=>fe[e],Q={bindI18n:`languageChanged`,bindI18nStore:``,transEmptyNodeValue:``,transSupportBasicHtmlNodes:!0,transWrapTextNodes:``,transKeepBasicHtmlNodesFor:[`br`,`strong`,`i`,`p`],useSuspense:!0,unescape:e=>e.replace(de,pe),transDefaultProps:void 0},me=(e={})=>{Q={...Q,...e}},he=()=>Q,$,ge=e=>{$=e},_e=()=>$,ve=(0,r.createContext)(),ye=class{constructor(){this.usedNamespaces={}}addUsedNamespaces(e){e.forEach(e=>{this.usedNamespaces[e]||(this.usedNamespaces[e]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}},be=t((e=>{var t=n();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=t.useState,o=t.useEffect,s=t.useLayoutEffect,c=t.useDebugValue;function l(e,t){var n=t(),r=a({inst:{value:n,getSnapshot:t}}),i=r[0].inst,l=r[1];return s(function(){i.value=n,i.getSnapshot=t,u(i)&&l({inst:i})},[e,n,t]),o(function(){return u(i)&&l({inst:i}),e(function(){u(i)&&l({inst:i})})},[e]),c(n),n}function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!i(e,n)}catch{return!0}}function d(e,t){return t()}var f=typeof window>`u`||window.document===void 0||window.document.createElement===void 0?d:l;e.useSyncExternalStore=t.useSyncExternalStore===void 0?f:t.useSyncExternalStore})),xe=t(((e,t)=>{t.exports=be()}))(),Se={t:(e,t)=>{if(Z(t))return t;if(ue(t)&&Z(t.defaultValue))return t.defaultValue;if(typeof e==`function`)return``;if(Array.isArray(e)){let t=e[e.length-1];return typeof t==`function`?``:t}return e},ready:!1},Ce=()=>()=>{},we=(e,t={})=>{let{i18n:n}=t,{i18n:i,defaultNS:a}=(0,r.useContext)(ve)||{},o=n||i||_e();o&&!o.reportNamespaces&&(o.reportNamespaces=new ye),o||q(o,`NO_I18NEXT_INSTANCE`,`useTranslation: You will need to pass in an i18next instance by using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`);let s=(0,r.useMemo)(()=>({...he(),...o?.options?.react,...t}),[o,t]),{useSuspense:c,keyPrefix:l,bindI18n:u,bindI18nStore:d}=s,f=e||a||o?.options?.defaultNS,p=Z(f)?[f]:f||[`translation`],m=(0,r.useMemo)(()=>p,p);o?.reportNamespaces?.addUsedNamespaces?.(m);let h=(0,r.useRef)(0),g=(0,r.useCallback)(e=>{if(!o)return Ce;let t=()=>{h.current+=1,e()};return u&&o.on(u,t),d&&o.store.on(d,t),()=>{u&&u.split(` `).forEach(e=>o.off(e,t)),d&&d.split(` `).forEach(e=>o.store.off(e,t))}},[o,u,d]),_=(0,r.useRef)(),v=(0,r.useCallback)(()=>{if(!o)return Se;let e=!!(o.isInitialized||o.initializedStoreOnce)&&m.every(e=>le(e,o,s)),n=t.lng||o.language,r=h.current,i=typeof l==`function`?N(l,{...o.options,ns:m}):l,a=_.current;if(a&&a.i18n===o&&a.ready===e&&a.lng===n&&a.namespaces===m&&a.keyPrefix===i&&a.revision===r)return a;let c={t:o.getFixedT(n,s.nsMode===`fallback`?m:m[0],l,{scopeNs:m}),i18n:o,ready:e,lng:n,namespaces:m,keyPrefix:i,revision:r};return _.current=c,c},[o,m,l,s,t.lng]),[y,b]=(0,r.useState)(0),{t:x,ready:S}=(0,xe.useSyncExternalStore)(g,v,v),C;o&&c&&!S&&(C=new Promise(e=>{let n=()=>e();t.lng?X(o,t.lng,m,n):Y(o,m,n)}),{t:x,ready:S}=v()),(0,r.useEffect)(()=>{if(o&&!S&&!c){let e=()=>b(e=>e+1);t.lng?X(o,t.lng,m,e):Y(o,m,e)}},[o,t.lng,m,S,c,y]);let w=o||{},T=(0,r.useRef)(null),E=(0,r.useRef)(),D=e=>`${e.language}|${e.resolvedLanguage}|${e.languages?.join(`,`)}`,O=e=>{let t=Object.getOwnPropertyDescriptors(e);t.__original&&delete t.__original;let n=Object.create(Object.getPrototypeOf(e),t);if(!Object.prototype.hasOwnProperty.call(n,`__original`))try{Object.defineProperty(n,"__original",{value:e,writable:!1,enumerable:!1,configurable:!1})}catch{}return n},k=(0,r.useMemo)(()=>{let e=w,t=e&&D(e),n=e;e&&(T.current&&T.current.__original===e&&E.current===t?n=T.current:(n=O(e),T.current=n,E.current=t));let r=!S&&!c?(...e)=>(q(o,`USE_T_BEFORE_READY`,`useTranslation: t was called before ready. When using useSuspense: false, make sure to check the ready flag before using t.`),x(...e)):x,i=[r,n,S];return i.t=r,i.i18n=n,i.ready=S,i},[x,w,S,w.resolvedLanguage,w.language,w.languages]);if(o&&c&&!S){let e=!1;try{e=!1}catch{}throw e&&q(o,`SUSPENDED_WHILE_LOADING`,`useTranslation: suspended while translations are loading (useSuspense is true by default). Add a <Suspense> boundary above this component, or set react.useSuspense: false in the i18next init options. https://react.i18next.com/latest/usetranslation-hook`),C}return k};export{G as i,ge as n,me as r,we as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./state-A4wJ8QgR.js";import"./src-55YckF5W.js";function t(){return`err-${Date.now()}-${Math.random().toString(36).slice(2,7)}`}var n=e(e=>({errors:[],push:(n,r,i,a,o)=>{let s=``;return e(e=>{let c=e.errors.find(e=>!e.dismissed&&!e.action&&e.level===n&&e.title===r);if(c)return s=c.id,{errors:e.errors.map(e=>e.id===c.id?{...e,count:e.count+1,timestamp:Date.now()}:e)};let l=t();s=l;let u={id:l,level:n,title:r,detail:i,action:a,timestamp:Date.now(),dismissed:!1,durationMs:o,count:1};return{errors:[...e.errors.slice(-49),u]}}),s},dismiss:t=>e(e=>({errors:e.errors.map(e=>e.id===t?{...e,dismissed:!0}:e)})),clearAll:()=>e({errors:[]})})),r={info:(e,t,r)=>n.getState().push(`info`,e,t,void 0,r),warn:(e,t,r)=>n.getState().push(`warning`,e,t,void 0,r),error:(e,t,r)=>n.getState().push(`error`,e,t,void 0,r),critical:(e,t,r)=>n.getState().push(`critical`,e,t,void 0,r)},i=e()(e=>({serverVersion:null,protocolVersion:null,capabilities:[],setHelloAck:t=>e({serverVersion:t.serverVersion||null,protocolVersion:t.protocolVersion||null,capabilities:t.capabilities})})),a=20,o=15e3,s=[500,1e3,2e3,5e3,1e4,o],c=3,l=`dscode_pending_frames`,u=new Set([`question_answer`,`hook_allow`,`hook_deny`,`form_answer`]),d=new Set([`get_workflow_status`,`get_commands`]);function f(){try{let e=localStorage.getItem(l);if(!e)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];let n=Date.now()-6e5;return t.filter(e=>!!e&&typeof e.type==`string`&&u.has(e.type)&&typeof e.queuedAt==`number`&&e.queuedAt>=n)}catch{return[]}}function p(e){try{localStorage.setItem(l,JSON.stringify(e.slice(-20)))}catch{}}var m=()=>{let e=window.location.protocol===`https:`?`wss:`:`ws:`,t=window.location.hostname,n=window.location.port,r=n?String(Number(n)+1):``;return`${e}//${r?`${t}:${r}`:t}/ws`},h=m(),g=`dscode_client_id`;function _(){try{let e=localStorage.getItem(g);if(e)return e;let t=`web-${typeof crypto<`u`&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).slice(2,10)}`;return localStorage.setItem(g,t),t}catch{return`web-${Math.random().toString(36).slice(2,10)}`}}var v=new class e{ws=null;url;clientId=_();messageHandlers=new Set;openHandlers=new Set;closeHandlers=new Set;errorHandlers=new Set;reconnectAttempts=0;reconnectHandlers=new Set;reconnectSuccessHandlers=new Set;reconnectGiveUpHandlers=new Set;isManualClose=!1;authenticated=!1;bfCached=!1;sessionId=null;visibleSessions=new Set;pendingFrames=f();connectBuffer=[];static MAX_CONNECT_BUFFER=32;connectFlushTimer=null;authPending=!1;static CONNECT_FLUSH_FALLBACK_MS=4e3;heartbeatInterval=null;reconnectTimer=null;awaitingPong=0;HEARTBEAT_INTERVAL=15e3;MAX_MISSED_PONGS=3;static FOREGROUND_PROBE_TIMEOUT_MS=3e3;constructor(e){this.url=e||h,typeof window<`u`&&(window.addEventListener(`pagehide`,e=>{e.persisted&&this.enterBfCache()}),window.addEventListener(`pageshow`,e=>{e.persisted&&this.exitBfCache()}),window.addEventListener(`online`,()=>this.retryImmediately(`网络恢复`)),document.addEventListener(`visibilitychange`,()=>{document.visibilityState===`visible`&&this.probeOnForeground()}))}setSessionId(e){this.sessionId=e}setVisibleSessions(e){let t=new Set;for(let n of e)n&&t.add(n);if(t.size===this.visibleSessions.size){let e=!0;for(let n of t)if(!this.visibleSessions.has(n)){e=!1;break}if(e)return}this.visibleSessions=t,this.sendSubscribeSessions()}resendVisibleSessions(){this.sendSubscribeSessions()}sendSubscribeSessions(){if(this.visibleSessions.size!==0&&this.ws?.readyState===WebSocket.OPEN)try{this.ws.send(JSON.stringify({type:`subscribe_sessions`,data:JSON.stringify({sessionIds:[...this.visibleSessions]})}))}catch{}}getSessionId(){return this.sessionId}getPendingFrameCount(){return this.pendingFrames.length}getPendingFrameIds(){return this.pendingFrames.map(e=>e.id||e.type).filter(Boolean)}clearPendingQueue(){this.pendingFrames=[],p([])}enqueueReliableFrame(e){let t=(()=>{try{return e.data?JSON.parse(e.data):{}}catch{return{}}})(),n={type:e.type,sessionId:e.sessionId,data:e.data,id:typeof t.questionId==`string`?t.questionId:typeof t.approvalId==`string`?t.approvalId:typeof t.formId==`string`?t.formId:void 0,queuedAt:Date.now()},r=n.id?this.pendingFrames.filter(e=>e.id!==n.id||e.type!==n.type):this.pendingFrames;this.pendingFrames=[...r,n].slice(-20),p(this.pendingFrames),console.warn(`[WS] reliable frame queued (awaiting ack) ${e.type}${n.id?` (${n.id})`:``}`)}ackReliableFrame(e){if(!e)return;let t=this.pendingFrames.filter(t=>t.id!==e);t.length!==this.pendingFrames.length&&(this.pendingFrames=t,p(t))}flushPendingFrames(){if(this.ws?.readyState!==WebSocket.OPEN)return;let e=f(),t=[...this.pendingFrames];for(let n of e){let e=t.findIndex(e=>e.id===n.id&&e.type===n.type);e>=0?t[e]=n:t.push(n)}if(t.length!==0){this.pendingFrames=t.slice(-20),p(this.pendingFrames);for(let e of this.pendingFrames){if(this.ws?.readyState!==WebSocket.OPEN)break;try{this.ws.send(JSON.stringify({type:e.type,sessionId:e.sessionId,data:e.data}))}catch(t){console.warn(`[WS] Failed to replay pending frame`,e.type,String(t));break}}}}getReconnectState(){return{attempts:this.reconnectAttempts,maxAttempts:a,reconnecting:this.reconnectAttempts>0&&this.ws?.readyState!==WebSocket.OPEN}}onReconnectAttempt(e){return this.reconnectHandlers.add(e),()=>this.reconnectHandlers.delete(e)}onReconnectSuccess(e){return this.reconnectSuccessHandlers.add(e),()=>this.reconnectSuccessHandlers.delete(e)}onReconnectGiveUp(e){return this.reconnectGiveUpHandlers.add(e),()=>this.reconnectGiveUpHandlers.delete(e)}connect(){if(this.ws?.readyState===WebSocket.OPEN||this.ws?.readyState===WebSocket.CONNECTING)return;this.isManualClose=!1;let e=new URLSearchParams;this.sessionId&&e.set(`sessionId`,this.sessionId),e.set(`clientId`,this.clientId);let t=e.toString()?`${this.url}?${e.toString()}`:this.url;this.ws=new WebSocket(t),this.ws.binaryType=`arraybuffer`,this.ws.onopen=()=>{let e=this.reconnectAttempts>0;if(this.reconnectAttempts=0,this.awaitingPong=0,e&&this.reconnectSuccessHandlers.forEach(e=>e()),this.ws?.readyState===WebSocket.OPEN)try{this.ws.send(JSON.stringify({type:`hello`,clientType:`web`,protocolVersion:1,capabilities:[]}))}catch{}this.startHeartbeat(),this.ws?.readyState===WebSocket.OPEN&&(this.awaitingPong=1,this.ws.send(JSON.stringify({type:`ping`}))),this.flushPendingFrames(),this.authPending=!1,this.authenticated=!1,this.armConnectFlushFallback(),this.sendSubscribeSessions(),this.openHandlers.forEach(e=>e())},this.ws.onclose=()=>{this.stopHeartbeat(),this.connectFlushTimer&&=(clearTimeout(this.connectFlushTimer),null),this.closeHandlers.forEach(e=>e()),!this.isManualClose&&!this.bfCached&&this.scheduleReconnect()},this.ws.onerror=e=>{this.reportConnectionTrouble(e.message||`Connection failed`),this.errorHandlers.forEach(e=>e())},this.ws.onmessage=e=>{this._onMessage(e)}}async _onMessage(e){try{let t;if(t=e.data instanceof Blob?await e.data.text():e.data instanceof ArrayBuffer?new TextDecoder().decode(e.data):typeof e.data==`string`?e.data:String(e.data),t=t.trim(),!t)return;let n=JSON.parse(t);if((n.type===`pong`||n.type===`ping`)&&(this.awaitingPong=0,n.type===`pong`))return;if(n.type===`hello_ack`){try{let e=typeof n.data==`string`?JSON.parse(n.data):n.data;e&&typeof e==`object`&&i.getState().setHelloAck({serverVersion:typeof e.serverVersion==`string`?e.serverVersion:``,protocolVersion:typeof e.protocolVersion==`number`?e.protocolVersion:0,capabilities:Array.isArray(e.capabilities)?e.capabilities.filter(e=>typeof e==`string`):[]})}catch{}this.flushConnectBuffer();return}if(n.type===`auth_required`?this.authPending=!0:n.type===`auth_success`&&(this.authPending=!1,this.authenticated=!0,this.flushConnectBuffer()),n.seq!==void 0&&n.seq>=0&&this.send({type:`message_ack`,data:JSON.stringify({seq:n.seq})}),n.type===`question_answer_ack`||n.type===`hook_response_ack`)try{let e=(typeof n.data==`string`?JSON.parse(n.data):n.data)||{};this.ackReliableFrame(typeof e.questionId==`string`?e.questionId:typeof e.approvalId==`string`?e.approvalId:void 0)}catch{}this.messageHandlers.forEach(e=>e(n))}catch(t){let n=e.data?.constructor?.name||typeof e.data,i;if(i=e.data instanceof Blob?`[Blob ${e.data.size} bytes]`:e.data instanceof ArrayBuffer?`[ArrayBuffer ${e.data.byteLength} bytes]`:String(e.data).slice(0,500),typeof e.data==`string`&&e.data.trim()){let t=e.data.trim();try{this.messageHandlers.forEach(e=>e({type:`log`,data:JSON.stringify({level:`info`,message:t})}));return}catch{}}r.error(`Failed to parse WebSocket message`,`type=${n} data=${i} error=${t}`)}}startHeartbeat(){this.stopHeartbeat(),this.awaitingPong=0,this.heartbeatInterval=setInterval(()=>{this.bfCached||(this.awaitingPong>=this.MAX_MISSED_PONGS?this.forceReconnect(`Heartbeat timeout (${this.awaitingPong} missed pongs)`):this.ws?.readyState===WebSocket.OPEN&&(this.awaitingPong+=1,this.send({type:`ping`})))},this.HEARTBEAT_INTERVAL)}stopHeartbeat(){this.heartbeatInterval&&=(clearInterval(this.heartbeatInterval),null),this.awaitingPong=0}enterBfCache(){this.bfCached=!0,this.stopHeartbeat(),this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null)}exitBfCache(){this.bfCached=!1,this.reconnectAttempts=0,this.ws?.readyState!==WebSocket.OPEN&&this.ws?.readyState!==WebSocket.CONNECTING&&this.connect()}scheduleReconnect(){if(this.reconnectAttempts++,this.reconnectAttempts>a){console.error(`[WS] Max reconnect attempts (${a}) reached — giving up.`),r.error(`WebSocket`,`Connection lost — max reconnect attempts (${a}) reached. Refresh the page to try again.`),this.reconnectGiveUpHandlers.forEach(e=>e());return}let e=s[Math.min(this.reconnectAttempts-1,s.length-1)]??o,t=Math.max(100,Math.round(e*(.8+Math.random()*.4)));this.reconnectHandlers.forEach(e=>e(this.reconnectAttempts,a)),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.connect()},t)}reportConnectionTrouble(e){let t=Math.min(this.reconnectAttempts+1,a);this.reconnectAttempts<c?console.debug(`[WS] connection error (attempt ${t}/${a}): ${e}`):r.warn(`WebSocket 连接不稳定`,`正在重连(第 ${t}/${a} 次):${e}`)}retryImmediately(e){if(this.bfCached)return;let t=this.ws?.readyState;t!==WebSocket.OPEN&&t!==WebSocket.CONNECTING&&(this.reconnectAttempts!==0||this.reconnectTimer!==null)&&(console.debug(`[WS] ${e} → 立即重连(重置退避)`),this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.reconnectAttempts=0,this.connect())}forceReconnect(e){console.warn(`[WS] ${e}, reconnecting...`),this.stopHeartbeat(),this.isManualClose=!0,this.ws?.close(),this.ws=null,this.scheduleReconnect()}probeOnForeground(){if(this.bfCached)return;let t=this.ws?.readyState;if(t===WebSocket.CONNECTING)return;if(t!==WebSocket.OPEN){this.retryImmediately(`标签页恢复可见`);return}if(this.awaitingPong<=0)return;this.awaitingPong+=1,this.send({type:`ping`});let n=this.awaitingPong;setTimeout(()=>{this.bfCached||this.ws?.readyState===WebSocket.OPEN&&this.awaitingPong>=n&&this.forceReconnect(`前台探活无应答(半开连接)`)},e.FOREGROUND_PROBE_TIMEOUT_MS)}disconnect(){this.isManualClose=!0,this.reconnectAttempts=0,this.stopHeartbeat(),this.reconnectTimer&&=(clearTimeout(this.reconnectTimer),null),this.ws?.close(),this.ws=null,this.connectFlushTimer&&=(clearTimeout(this.connectFlushTimer),null),this.connectBuffer=[]}send(e){if(e.type&&u.has(e.type)){if(this.enqueueReliableFrame(e),this.ws?.readyState===WebSocket.OPEN)try{this.ws.send(JSON.stringify(e))}catch{}return!0}if(this.ws?.readyState===WebSocket.OPEN){let t=JSON.stringify(e);return this.ws.send(t),!0}return this.ws?.readyState===WebSocket.CONNECTING&&d.has(e.type)?(this.bufferUntilOpen(e),!0):(console.warn(`[WS] NOT CONNECTED — dropping:`,e.type,e.sessionId,`readyState=`,this.ws?.readyState),!1)}bufferUntilOpen(t){let n=this.connectBuffer.findIndex(e=>e.type===t.type&&e.sessionId===t.sessionId);n>=0?this.connectBuffer[n]=t:(this.connectBuffer.length>=e.MAX_CONNECT_BUFFER&&this.connectBuffer.shift(),this.connectBuffer.push(t))}flushConnectBuffer(){if(this.connectFlushTimer&&=(clearTimeout(this.connectFlushTimer),null),this.connectBuffer.length===0)return;let e=this.connectBuffer;if(this.connectBuffer=[],this.ws?.readyState===WebSocket.OPEN)for(let t of e)try{this.ws.send(JSON.stringify(t))}catch{break}}armConnectFlushFallback(){this.connectBuffer.length!==0&&(this.connectFlushTimer&&clearTimeout(this.connectFlushTimer),this.connectFlushTimer=setTimeout(()=>{this.connectFlushTimer=null,!this.authPending&&this.flushConnectBuffer()},e.CONNECT_FLUSH_FALLBACK_MS))}onMessage(e){return this.messageHandlers.add(e),()=>this.messageHandlers.delete(e)}onOpen(e){return this.openHandlers.add(e),()=>this.openHandlers.delete(e)}onClose(e){return this.closeHandlers.add(e),()=>this.closeHandlers.delete(e)}onError(e){return this.errorHandlers.add(e),()=>this.errorHandlers.delete(e)}get isConnected(){return this.ws?.readyState===WebSocket.OPEN}setToken(e){try{sessionStorage.setItem(`auth_token`,e)}catch{}}get isAuthenticated(){return this.authenticated}setAuthenticated(e){this.authenticated=e,e&&(this.authPending=!1,this.flushConnectBuffer())}};export{n as i,v as n,r,m as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./state-A4wJ8QgR.js";var t=e(e=>({isOpen:!1,entries:null,openWhatsNew:t=>e({isOpen:!0,entries:t??null}),closeWhatsNew:()=>e({isOpen:!1})}));export{t};
|
package/web/dist/index.html
CHANGED
|
@@ -58,34 +58,38 @@
|
|
|
58
58
|
} catch (e) {}
|
|
59
59
|
})();
|
|
60
60
|
</script>
|
|
61
|
-
<script type="module" crossorigin src="/assets/index-
|
|
61
|
+
<script type="module" crossorigin src="/assets/index-CxrzleFg.js"></script>
|
|
62
62
|
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-COiEfhsA.js">
|
|
63
|
-
<link rel="modulepreload" crossorigin href="/assets/icons-
|
|
64
|
-
<link rel="modulepreload" crossorigin href="/assets/react-vendor-
|
|
65
|
-
<link rel="modulepreload" crossorigin href="/assets/useTranslation-
|
|
66
|
-
<link rel="modulepreload" crossorigin href="/assets/state-
|
|
67
|
-
<link rel="modulepreload" crossorigin href="/assets/markdown-
|
|
68
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
63
|
+
<link rel="modulepreload" crossorigin href="/assets/icons-CittejKL.js">
|
|
64
|
+
<link rel="modulepreload" crossorigin href="/assets/react-vendor-BEA-EtI-.js">
|
|
65
|
+
<link rel="modulepreload" crossorigin href="/assets/useTranslation-2BGEBvJE.js">
|
|
66
|
+
<link rel="modulepreload" crossorigin href="/assets/state-A4wJ8QgR.js">
|
|
67
|
+
<link rel="modulepreload" crossorigin href="/assets/markdown-DZQBOzWk.js">
|
|
68
|
+
<link rel="modulepreload" crossorigin href="/assets/cn-CoHJgTJ5.js">
|
|
69
|
+
<link rel="modulepreload" crossorigin href="/assets/Button-B43HsIQ3.js">
|
|
69
70
|
<link rel="modulepreload" crossorigin href="/assets/threads-lr33dwqg.js">
|
|
70
|
-
<link rel="modulepreload" crossorigin href="/assets/src-
|
|
71
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
72
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
73
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
74
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
75
|
-
<link rel="modulepreload" crossorigin href="/assets/preload-helper-BLdHbfdN.js">
|
|
76
|
-
<link rel="modulepreload" crossorigin href="/assets/imageUrl-CrQM4gmf.js">
|
|
71
|
+
<link rel="modulepreload" crossorigin href="/assets/src-55YckF5W.js">
|
|
72
|
+
<link rel="modulepreload" crossorigin href="/assets/api-BW4-5gtM.js">
|
|
73
|
+
<link rel="modulepreload" crossorigin href="/assets/agentIconSet-Cqhm4UOl.js">
|
|
74
|
+
<link rel="modulepreload" crossorigin href="/assets/settingsStore-DYqiXodu.js">
|
|
75
|
+
<link rel="modulepreload" crossorigin href="/assets/chatStore-D8Zzr1hE.js">
|
|
77
76
|
<link rel="modulepreload" crossorigin href="/assets/sessionKind-CZ1kQQII.js">
|
|
78
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
79
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
80
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
81
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
82
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
83
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
84
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
85
|
-
<link rel="modulepreload" crossorigin href="/assets/
|
|
77
|
+
<link rel="modulepreload" crossorigin href="/assets/threadStore-CQi4OzSe.js">
|
|
78
|
+
<link rel="modulepreload" crossorigin href="/assets/preload-helper-BLdHbfdN.js">
|
|
79
|
+
<link rel="modulepreload" crossorigin href="/assets/imageUrl-BVgcEm7e.js">
|
|
80
|
+
<link rel="modulepreload" crossorigin href="/assets/FileContextMenu-CyjXlSHp.js">
|
|
81
|
+
<link rel="modulepreload" crossorigin href="/assets/DiffPreview-WQihq3bK.js">
|
|
82
|
+
<link rel="modulepreload" crossorigin href="/assets/projectsStore-B7fdKRzl.js">
|
|
83
|
+
<link rel="modulepreload" crossorigin href="/assets/websocket-DCs7f54y.js">
|
|
84
|
+
<link rel="modulepreload" crossorigin href="/assets/statusAxesRefresh-BBqszCp-.js">
|
|
85
|
+
<link rel="modulepreload" crossorigin href="/assets/whatsNewStore-DoCQvcMq.js">
|
|
86
|
+
<link rel="modulepreload" crossorigin href="/assets/panels-CuDz4aqU.js">
|
|
87
|
+
<link rel="modulepreload" crossorigin href="/assets/useConfirm-kTv3x0H6.js">
|
|
88
|
+
<link rel="modulepreload" crossorigin href="/assets/common-CP2UB8TN.js">
|
|
86
89
|
<link rel="modulepreload" crossorigin href="/assets/channelMeta-BO645sjD.js">
|
|
90
|
+
<link rel="modulepreload" crossorigin href="/assets/WorkspaceDirPicker-Z42YqE4a.js">
|
|
87
91
|
<link rel="stylesheet" crossorigin href="/assets/DiffPreview-CCTRbIMZ.css">
|
|
88
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
92
|
+
<link rel="stylesheet" crossorigin href="/assets/index-CEUbTcNL.css">
|
|
89
93
|
</head>
|
|
90
94
|
<body>
|
|
91
95
|
<div id="root"></div>
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{A as t,Dr as n,Er as r,Fr as i,Kr as a,Kt as o,Nr as s,Pr as c,Qn as l,S as u,Wr as d,_t as f,c as p,dn as m,dt as h,ft as g,g as _,i as v,it as y,lt as b,n as x,ni as S,pt as ee,qt as C,sr as te,v as ne,vr as re,wn as ie,xn as ae,xt as oe,z as se}from"./icons-B8Ngx6rM.js";import{r as ce}from"./react-vendor-CXI113IS.js";import{t as w}from"./useTranslation-gGKZZfux.js";import{i as T,n as le,t as ue}from"./Button-D-g7PgYh.js";import{t as E}from"./api-ZQf0Ys8y.js";import{I as de}from"./markdown-Cps-36Z5.js";import{t as fe}from"./useConfirm-CQjBnYuP.js";import"./common-CPZxdYLs.js";import{ct as D,dt as O,lt as k,ot as A,st as j,u as pe,ut as M}from"./index-STsyoFCk.js";function N(e,t,n){let r=M(e,n?.in);return isNaN(t)?O(n?.in||e,NaN):(t&&r.setDate(r.getDate()+t),r)}function me(e,t,n){let r=M(e,n?.in);if(isNaN(t))return O(n?.in||e,NaN);if(!t)return r;let i=r.getDate(),a=O(n?.in||e,r.getTime());return a.setMonth(r.getMonth()+t+1,0),i>=a.getDate()?a:(r.setFullYear(a.getFullYear(),a.getMonth(),i),r)}function he(e,t,n){return N(e,t*7,n)}function ge(e){return O(e,Date.now())}function P(e,t,n){let[r,i]=D(n?.in,e,t);return+j(r)==+j(i)}function F(e,t){let n=M(e,t?.in);return n.setHours(23,59,59,999),n}function I(e,t){let[n,r]=D(e,t.start,t.end);return{start:n,end:r}}function _e(e,t){let{start:n,end:r}=I(t?.in,e),i=+n>+r,a=i?+n:+r,o=i?r:n;o.setHours(0,0,0,0);let s=t?.step??1;if(!s)return[];s<0&&(s=-s,i=!i);let c=[];for(;+o<=a;)c.push(O(n,o)),o.setDate(o.getDate()+s),o.setHours(0,0,0,0);return i?c.reverse():c}function ve(e,t){let n=M(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function ye(e,t,n){let[r,i]=D(n?.in,e,t);return+k(r,n)==+k(i,n)}function be(e,t,n){let[r,i]=D(n?.in,e,t);return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()}function L(e,t){return P(O(t?.in||e,e),ge(t?.in||e))}var R=e(S(),1),xe=ce(),Se=2e3;function Ce(e){return`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`}function z(e,t,n){return Number.isInteger(e)&&e>=t&&e<=n}function B(e,t,n){let r=e.trim();if(!r)return null;let i=new Set;for(let e of r.split(`,`)){let r=e.trim();if(!r)return null;if(r===`*`||r===`?`){for(let e=t;e<=n;e++)i.add(e);continue}let a=r.match(/^(\*|\d+|\d+-\d+)\/(\d+)$/);if(a){let e=parseInt(a[2]??``,10);if(!z(e,1,n))return null;let r=a[1]??``,o,s;if(r===`*`)o=t,s=n;else if(r.includes(`-`)){let[e,t]=r.split(`-`).map(Number);o=e??NaN,s=t??NaN}else o=Number(r),s=n;if(!z(o,t,n)||!z(s,t,n)||o>s)return null;for(let t=o;t<=s;t+=e)i.add(t);continue}let o=r.match(/^(\d+)-(\d+)$/);if(o){let e=parseInt(o[1]??``,10),r=parseInt(o[2]??``,10);if(!z(e,t,n)||!z(r,t,n)||e>r)return null;for(let t=e;t<=r;t++)i.add(t);continue}let s=Number(r);if(!z(s,t,n))return null;i.add(s)}return i.size>0?[...i].sort((e,t)=>e-t):null}function we(e){let t=e.trim().split(/\s+/);if(t.length!==5)return null;let n=B(t[0]??``,0,59),r=B(t[1]??``,0,23),i=B(t[2]??``,1,31),a=B(t[3]??``,1,12),o=B(t[4]??``,0,7);return!n||!r||!i||!a||!o?null:{minutes:n,hours:r,daysOfMonth:i,months:a,daysOfWeek:[...new Set(o.map(e=>e===7?0:e))].sort((e,t)=>e-t)}}function Te(e,t){return e.months.includes(t.getMonth()+1)&&e.daysOfMonth.includes(t.getDate())&&e.daysOfWeek.includes(t.getDay())}function Ee(e,t){if(e.kind===`once`){if(!e.fireAt)return[];let n=new Date(e.fireAt);return Number.isNaN(n.getTime())?[]:P(n,t)?[n]:[]}let n=we(e.cron??``);if(!n||!Te(n,t))return[];let r=[];for(let e of n.hours)for(let i of n.minutes)r.push(new Date(t.getFullYear(),t.getMonth(),t.getDate(),e,i,0,0));return r}function De(e,t,n){let r=j(t),i=F(n);if(r.getTime()>i.getTime())return[];let a=[],o=_e({start:r,end:i});for(let t of e){let e=0;for(let n of o){if(e>=Se)break;for(let o of Ee(t.schedule,n))if(!(o.getTime()<r.getTime()||o.getTime()>i.getTime())&&(a.push({key:`${t.id}@${o.toISOString()}`,automationId:t.id,at:o,automation:t}),e+=1,e>=Se))break}}return a.sort((e,t)=>e.at.getTime()-t.at.getTime()||e.automation.name.localeCompare(t.automation.name)),a}var V=e=>e===`*`||e===`?`;function Oe(e,t){let n=e.schedule;if(n.kind===`once`){let e=n.fireAt?new Date(n.fireAt):null;if(!e||Number.isNaN(e.getTime()))return{ok:!1,reason:`unparsable`};if(P(e,t))return{ok:!1,reason:`noop-day`};let r=new Date(t.getFullYear(),t.getMonth(),t.getDate(),e.getHours(),e.getMinutes(),0,0);return{ok:!0,schedule:{...n,kind:`once`,fireAt:r.toISOString()}}}let r=(n.cron??``).trim().split(/\s+/);if(r.length!==5)return{ok:!1,reason:`unparsable`};let i=r[2]??``,a=r[3]??``,o=r[4]??``;if(!V(i)||!V(a))return{ok:!1,reason:`locked-cron`};let s=t.getDay();if(!V(o)){if(/^\d+$/.test(o)){if(Number(o)%7===s)return{ok:!1,reason:`noop-day`}}else if(o===`1-5`){if(s>=1&&s<=5)return{ok:!1,reason:`noop-day`}}else return{ok:!1,reason:`locked-cron`}}let c=[...r];return c[4]=String(s),{ok:!0,schedule:{...n,kind:`cron`,cron:c.join(` `)}}}function ke(e){return Ce(e)}function Ae(e){let t=new Map;for(let n of e){let e=Ce(n.at),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}var H=[`automation.dow.monday`,`automation.dow.tuesday`,`automation.dow.wednesday`,`automation.dow.thursday`,`automation.dow.friday`,`automation.dow.saturday`,`automation.dow.sunday`],je=e=>(e.getDay()+6)%7;function Me(e){let t=ve(e),n=k(t,{weekStartsOn:1});return Array.from({length:42},(e,t)=>N(n,t))}function Ne(e){let t=k(e,{weekStartsOn:1});return Array.from({length:7},(e,n)=>N(t,n))}var U=de(),W=3,G=e=>A(e,`HH:mm`),K=e=>`${e.getFullYear()}-${e.getMonth()+1}-${e.getDate()}`;function Pe(e){return e.status===`enabled`?e.schedule.kind===`once`?`once`:`enabled`:`disabled`}var Fe={enabled:`border-accent-blue bg-accent-blue/10 text-dark-text`,once:`border-accent-yellow bg-accent-yellow/10 text-dark-text`,disabled:`border-dark-border bg-dark-hover text-dark-muted`};function q({occurrence:e,onSelectDay:t,extra:n,onUnpack:r,onDragStart:i,onDragEnd:a}){let{t:o}=w(),s=n=>{n.stopPropagation(),r?r():t(e.at)},c=!!i,l=c?o(`automation.dragHint`):r?o(`automation.unpackHint`):``;return(0,U.jsxs)(`button`,{type:`button`,onClick:s,draggable:c,onDragStart:t=>{i&&(t.stopPropagation(),t.dataTransfer&&(t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`text/plain`,e.key)),i(e))},onDragEnd:()=>a?.(),title:`${G(e.at)} ${e.automation.name}${l?` · ${l}`:``}`,className:`flex w-full items-center gap-1 truncate rounded border-s-2 px-1.5 py-[3px] text-start text-badge hover:brightness-110 ${Fe[Pe(e.automation)]} ${c?`cursor-grab active:cursor-grabbing`:``}`,children:[(0,U.jsx)(`span`,{className:`shrink-0 tabular-nums opacity-70`,children:G(e.at)}),(0,U.jsx)(`span`,{className:`truncate`,children:e.automation.name}),n!==void 0&&n>0&&(0,U.jsx)(`span`,{className:`shrink-0 opacity-70`,children:o(`automation.moreCount`,{count:n})})]})}function Ie({anchor:e,selectedDay:t,byDay:n,onSelectDay:r,onFocusSlot:i,onMoveOccurrence:a}){let{t:o}=w(),s=(0,R.useMemo)(()=>Me(e),[e]),[c,l]=(0,R.useState)(null),[u,d]=(0,R.useState)(null),f=()=>{l(null),d(null)};return(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-dark-border bg-dark-surface max-md:overflow-x-auto`,children:[(0,U.jsx)(`div`,{className:`grid grid-cols-7 border-b border-dark-border bg-dark-hover/40 max-md:min-w-[42rem]`,children:H.map(e=>(0,U.jsx)(`div`,{className:`px-2 py-2 text-center text-meta font-medium text-dark-muted`,children:o(e)},e))}),(0,U.jsx)(`div`,{className:`grid grid-cols-7 max-md:min-w-[42rem]`,children:s.map((s,p)=>{let m=K(s),h=n.get(m)??[],g=J(h),_=g.slice(0,W),v=g.slice(W).reduce((e,t)=>e+t.items.length,0),y=be(s,e),b=P(s,t),x=L(s),S=u===m;return(0,U.jsxs)(`div`,{"data-day":m,role:`button`,tabIndex:0,onClick:()=>r(s),onDragOver:e=>{c&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),d(m))},onDragLeave:()=>d(e=>e===m?null:e),onDrop:e=>{if(!c)return;e.preventDefault();let t=c;f(),a?.(t,s)},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r(s))},className:[`flex min-h-28 cursor-pointer flex-col gap-1 border-b border-e border-dark-border p-1.5`,p%7==6?`border-e-0`:``,p>=35?`border-b-0`:``,y?`bg-dark-surface`:`bg-dark-bg/50`,S?`bg-accent-blue/10 ring-2 ring-inset ring-accent-blue/70`:b?`ring-1 ring-inset ring-accent-blue/50`:`hover:bg-dark-hover/40`].join(` `),children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsx)(`span`,{className:[`flex h-5 w-5 items-center justify-center rounded-full text-meta tabular-nums`,x?`bg-accent-blue font-semibold text-accent-fg`:y?`text-dark-text`:`text-dark-muted/60`].join(` `),children:s.getDate()}),h.length>0&&(0,U.jsx)(`span`,{className:`text-badge tabular-nums text-dark-muted/50`,children:h.length})]}),(0,U.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[_.map(e=>{let t=e.items[0],n=e.items.length>1;return(0,U.jsx)(q,{occurrence:t,onSelectDay:r,extra:e.items.length-1,onDragStart:a&&!n?l:void 0,onDragEnd:f,onUnpack:n&&i?()=>i(s,G(e.at)):void 0},`${m}-${G(e.at)}`)}),v>0&&(0,U.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),r(s)},className:`px-1 text-start text-badge text-dark-muted hover:text-accent-blue`,children:o(`automation.moreCount`,{count:v})})]})]},s.toISOString())})})]})}function J(e){let t=new Map;for(let n of e){let e=G(n.at),r=t.get(e);r?r.items.push(n):t.set(e,{at:n.at,items:[n]})}return[...t.values()].sort((e,t)=>e.at.getTime()-t.at.getTime())}function Le({anchor:e,selectedDay:t,byDay:n,onSelectDay:r,onFocusSlot:i,onMoveOccurrence:a}){let{t:o}=w(),s=(0,R.useMemo)(()=>Ne(e),[e]),c=(0,R.useMemo)(()=>Array.from({length:24},(e,t)=>t),[]),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(null),p=()=>{u(null),f(null)};return(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-dark-border bg-dark-surface`,children:[(0,U.jsxs)(`div`,{className:`grid grid-cols-[3rem_repeat(7,minmax(0,1fr))] border-b border-dark-border bg-dark-hover/40`,children:[(0,U.jsx)(`div`,{}),s.map(e=>{let n=L(e),i=P(e,t);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:[`border-s border-dark-border px-1 py-1.5 text-center`,i?`bg-accent-blue/10`:`hover:bg-dark-hover/60`].join(` `),children:[(0,U.jsx)(`div`,{className:`text-meta text-dark-muted`,children:o(H[je(e)]??``)}),(0,U.jsx)(`div`,{className:[`mx-auto mt-0.5 flex h-5 w-5 items-center justify-center rounded-full text-meta tabular-nums`,n?`bg-accent-blue font-semibold text-accent-fg`:`text-dark-text`].join(` `),children:e.getDate()})]},e.toISOString())})]}),(0,U.jsxs)(`div`,{className:`custom-scrollbar grid max-h-[62vh] grid-cols-[3rem_repeat(7,minmax(0,1fr))] overflow-y-auto`,children:[(0,U.jsx)(`div`,{className:`relative`,style:{height:`72rem`},children:c.map(e=>(0,U.jsx)(`div`,{className:`absolute end-1 -translate-y-1/2 text-badge tabular-nums text-dark-muted`,style:{top:`${e/24*100}%`},children:e===0?``:`${String(e).padStart(2,`0`)}:00`},e))}),s.map(e=>{let o=K(e),s=J(n.get(o)??[]),m=P(e,t);return(0,U.jsxs)(`div`,{"data-day":o,onDragOver:e=>{l&&(e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`move`),f(o))},onDragLeave:()=>f(e=>e===o?null:e),onDrop:t=>{if(!l)return;t.preventDefault();let n=l;p(),a?.(n,e)},className:[`relative border-s border-dark-border`,d===o?`bg-accent-blue/15 ring-2 ring-inset ring-accent-blue/70`:m?`bg-accent-blue/5`:``].join(` `),style:{height:`72rem`},children:[c.map(e=>(0,U.jsx)(`div`,{className:`absolute inset-x-0 border-t ${e===0?`border-transparent`:`border-dark-border/60`}`,style:{top:`${e/24*100}%`}},e)),s.map(t=>{let n=t.items[0],o=t.at.getHours()*60+t.at.getMinutes();return(0,U.jsx)(`div`,{className:`absolute inset-x-0.5 z-10`,style:{top:`${o/1440*100}%`},children:(0,U.jsx)(q,{occurrence:n,onSelectDay:r,extra:t.items.length-1,onDragStart:a&&t.items.length===1?u:void 0,onDragEnd:p,onUnpack:i&&t.items.length>1?()=>i(e,G(t.at)):void 0})},`${e.toISOString()}-${G(t.at)}`)})]},e.toISOString())})]})]})}var Y=e=>A(e,`HH:mm`);function Re({day:e,occurrences:t,focusSlot:n,onClearFocus:r,onEdit:a,onRun:o,onToggle:s,onDelete:c,onCreate:l}){let{t:u}=w(),d=n??null,p=d?t.filter(e=>Y(e.at)===d).length:0,m=d?t.findIndex(e=>Y(e.at)===d):-1,g=(0,R.useRef)(null);return(0,R.useEffect)(()=>{d&&g.current?.scrollIntoView?.({block:`nearest`})},[d]),(0,U.jsxs)(`aside`,{className:`flex w-full shrink-0 flex-col overflow-hidden rounded-xl border border-dark-border bg-dark-surface lg:w-72`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-2 border-b border-dark-border px-3 py-2.5`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`truncate text-sm font-semibold`,children:[u(H[je(e)]??``),` · `,A(e,`yyyy-MM-dd`)]}),(0,U.jsxs)(`div`,{className:`text-meta text-dark-muted`,children:[u(`automation.tasksCount`,{count:t.length}),L(e)?` · ${u(`automation.today`)}`:``]})]}),(0,U.jsx)(`button`,{type:`button`,onClick:l,title:u(`automation.new`),className:`rounded-lg p-1.5 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:(0,U.jsx)(h,{size:15})})]}),d&&(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-dark-border bg-accent-blue/10 px-3 py-1.5 text-meta`,children:[(0,U.jsx)(`span`,{className:`shrink-0 font-medium tabular-nums`,children:d}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-dark-muted`,children:u(`automation.slotFocus`,{count:p})}),r&&(0,U.jsx)(`button`,{type:`button`,onClick:r,title:u(`automation.clearFocus`),className:`rounded p-0.5 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:(0,U.jsx)(x,{size:12})})]}),(0,U.jsx)(`div`,{className:`custom-scrollbar flex-1 overflow-y-auto p-2.5`,children:t.length===0?(0,U.jsxs)(`div`,{className:`flex flex-col items-center gap-1 px-2 py-8 text-center`,children:[(0,U.jsx)(i,{size:22,className:`text-dark-muted`}),(0,U.jsx)(`p`,{className:`text-xs text-dark-muted`,children:u(`automation.dayEmpty`)}),(0,U.jsx)(`p`,{className:`text-meta text-dark-muted/70`,children:u(`automation.dayEmptyHint`)})]}):(0,U.jsx)(`div`,{className:`space-y-2`,children:t.map((e,t)=>{let n=e.automation,r=n.status===`enabled`,i=d!==null&&Y(e.at)===d;return(0,U.jsxs)(`div`,{ref:t===m?g:void 0,"data-focus-slot":i?d:void 0,className:[`rounded-lg border bg-dark-bg/50 px-2.5 py-2`,i?`border-accent-blue/60 ring-1 ring-inset ring-accent-blue/50`:`border-dark-border`].join(` `),children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`shrink-0 text-meta font-medium tabular-nums text-dark-muted`,children:Y(e.at)}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,title:n.name,children:n.name}),(0,U.jsx)(`span`,{className:`shrink-0 rounded px-1 py-0.5 text-badge ${r?`bg-accent-green/20 text-accent-green`:`bg-dark-hover text-dark-muted`}`,children:u(r?`automation.enabled`:`automation.disabled`)})]}),(0,U.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[n.nextRunAt&&(0,U.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-badge tabular-nums text-dark-muted`,children:[u(`automation.nextRun`),` `,A(new Date(n.nextRunAt),`MM-dd HH:mm`)]}),(0,U.jsxs)(`div`,{className:`ms-auto flex shrink-0 items-center gap-1`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:()=>a(n),title:u(`automation.edit`),className:`rounded p-1.5 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:(0,U.jsx)(f,{size:14})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>s(n),title:u(r?`automation.disable`:`automation.enable`),className:`rounded p-1.5 text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:(0,U.jsx)(b,{size:14})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>o(n.id),title:u(`automation.runNow`),className:`rounded p-1.5 text-accent-green hover:bg-dark-hover`,children:(0,U.jsx)(ee,{size:14})}),c&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>c(n),title:u(`automation.delete`),className:`rounded p-1.5 text-dark-muted hover:bg-accent-red/10 hover:text-accent-red`,children:(0,U.jsx)(ne,{size:14})})]})]})]},e.key)})})})]})}var X={name:``,instructions:``,jobKind:`agent`,workflowTemplate:``,freq:`daily`,time:`09:00`,dow:`1`,onceAt:``,cron:`0 9 * * *`,modelRef:``,connectorIds:[],channelIds:[],workspaceDir:``,readAutoAllow:!0,runSessionMode:`home`,runSessionId:``,budgetUsd:``};function ze(e){let t=e.trim();if(!t)return null;let n=Number(t);return!Number.isFinite(n)||n<=0?null:String(Math.round(n*100))}var Be=`.agent/automation-attachments`,Ve=`workflow:`;function He(e){return/^[a-z0-9][a-z0-9_-]*$/.test(e)}function Ue(e){let t=e??``;if(!t.startsWith(Ve))return``;let n=t.slice(9).trim();return He(n)?n:``}var Z=`deepseekcode:automation-view`,We=[{id:`month`,key:`automation.viewMonth`,Icon:c},{id:`week`,key:`automation.viewWeek`,Icon:s},{id:`list`,key:`automation.viewList`,Icon:C}];function Ge(){try{let e=localStorage.getItem(Z);if(e===`month`||e===`week`||e===`list`)return e}catch{}return`month`}function Ke(e){try{localStorage.setItem(Z,e)}catch{}}var Q=e=>String(e).padStart(2,`0`);function qe(e){let t=e.schedule,n=Ue(e.name),r={modelRef:e.modelRef??``,connectorIds:Array.isArray(e.connectorIds)?[...e.connectorIds]:[],channelIds:Array.isArray(e.notificationChannelIds)?[...e.notificationChannelIds]:[],workspaceDir:e.workspaceDir??``,readAutoAllow:e.readAutoAllow,runSessionMode:e.runSessionMode??`home`,runSessionId:e.runSessionId??``,budgetUsd:e.budgetCents?String(Number(e.budgetCents)/100):``,workflowTemplate:n,jobKind:n?`workflow`:`agent`};if(t.kind===`once`&&t.fireAt){let n=new Date(t.fireAt);return{...X,name:e.name,instructions:e.instructions,freq:`once`,time:`${Q(n.getHours())}:${Q(n.getMinutes())}`,onceAt:`${n.getFullYear()}-${Q(n.getMonth()+1)}-${Q(n.getDate())}T${Q(n.getHours())}:${Q(n.getMinutes())}`,...r}}let i=(t.cron||``).trim().split(/\s+/),a={...X,name:e.name,instructions:e.instructions,...r};if(i.length===5){let e=i[0]??``,t=i[1]??``,n=i[4]??``,r=`${Q(parseInt(t,10)||0)}:${Q(parseInt(e,10)||0)}`;if(n===`*`)return{...a,freq:`daily`,time:r};if(n===`1-5`)return{...a,freq:`weekdays`,time:r};if(/^\d+$/.test(n))return{...a,freq:`weekly`,time:r,dow:n}}return{...a,freq:`custom`,cron:t.cron||``}}function Je(e){let[t,n]=e.time.split(`:`),r=parseInt(t??``,10),i=parseInt(n??``,10);switch(e.freq){case`daily`:return Number.isInteger(r)&&Number.isInteger(i)?{kind:`cron`,cron:`${i} ${r} * * *`}:null;case`weekdays`:return Number.isInteger(r)&&Number.isInteger(i)?{kind:`cron`,cron:`${i} ${r} * * 1-5`}:null;case`weekly`:return Number.isInteger(r)&&Number.isInteger(i)?{kind:`cron`,cron:`${i} ${r} * * ${e.dow}`}:null;case`once`:return e.onceAt?{kind:`once`,fireAt:new Date(e.onceAt).toISOString()}:null;case`custom`:return e.cron.trim()?{kind:`cron`,cron:e.cron.trim()}:null}}function Ye(e,t){if(e.kind===`once`&&e.fireAt){let n=new Date(e.fireAt);return`${t(`automation.badgeOnce`)} ${n.toLocaleString()}`}let n=(e.cron||``).trim().split(/\s+/);if(n.length!==5)return e.cron||``;let r=n[0]??``,i=n[1]??``,a=n[4]??``,o=`${Q(parseInt(i,10)||0)}:${Q(parseInt(r,10)||0)}`;return a===`*`?t(`automation.badgeDaily`,{time:o}):a===`1-5`?t(`automation.badgeWeekdays`,{time:o}):/^\d+$/.test(a)?t(`automation.badgeWeekly`,{day:t(`automation.dow.${[`sunday`,`monday`,`tuesday`,`wednesday`,`thursday`,`friday`,`saturday`][parseInt(a,10)%7]}`),time:o}):e.cron||``}var Xe=[{value:`1`,key:`automation.dow.monday`},{value:`2`,key:`automation.dow.tuesday`},{value:`3`,key:`automation.dow.wednesday`},{value:`4`,key:`automation.dow.thursday`},{value:`5`,key:`automation.dow.friday`},{value:`6`,key:`automation.dow.saturday`},{value:`0`,key:`automation.dow.sunday`}];function Ze(e){let t=e.replace(/[\\/]+$/,``),n=Math.max(t.lastIndexOf(`\\`),t.lastIndexOf(`/`));return n===-1?t:t.slice(n+1)}function Qe({isOpen:e,initial:t,onClose:n,onConfirm:r}){let{t:i}=w(),{visible:s,phase:c}=le(e),[l,u]=(0,R.useState)(t),[d,f]=(0,R.useState)(null),[p,h]=(0,R.useState)([]),[g,_]=(0,R.useState)(!1),[v,y]=(0,R.useState)(``),[b,S]=(0,R.useState)(t),ee=(0,R.useRef)(null),C=async e=>{_(!0),y(``);try{let t=await E.dirs.list(e);if(!t.success||!t.data){y(t.error||`加载目录失败`);return}u(t.data.path),f(t.data.parent),h(t.data.dirs||[]),S(t.data.path)}catch(e){y(e instanceof Error?e.message:`加载目录失败`)}finally{_(!1)}};return(0,R.useEffect)(()=>{e&&C(t)},[e,t]),(0,R.useEffect)(()=>{ee.current?.focus()},[]),(0,R.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),n())};return document.addEventListener(`keydown`,t),document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,t),document.body.style.overflow=``}},[e,n]),s?(0,U.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center overflow-hidden p-4 max-md:p-0`,role:`dialog`,"aria-modal":`true`,children:[(0,U.jsx)(`div`,{className:`absolute inset-0 ui-scrim ui-overlay-backdrop`,"data-phase":c,onClick:n}),(0,U.jsxs)(`div`,{className:`relative w-full max-w-lg mx-4 bg-dark-overlay ui-surface-overlay border border-dark-border rounded-xl shadow-pop flex flex-col max-h-[70vh] ui-overlay-panel max-md:mx-0 max-md:max-w-none max-md:rounded-none max-md:max-h-[85vh]`,"data-phase":c,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-2.5 border-b border-dark-border shrink-0`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2 text-compact font-semibold text-dark-text`,children:[(0,U.jsx)(ie,{size:15,className:`text-accent-blue`}),i(`automation.workspacePick`)]}),(0,U.jsx)(`button`,{type:`button`,onClick:n,className:`rounded p-1 text-dark-muted hover:bg-dark-hover`,children:(0,U.jsx)(x,{size:15})})]}),(0,U.jsxs)(`div`,{className:`p-4 flex flex-col gap-3 min-h-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsxs)(`div`,{className:`relative flex-1`,children:[(0,U.jsx)(m,{size:13,className:`absolute start-2.5 top-1/2 -translate-y-1/2 text-dark-muted/60`}),(0,U.jsx)(`input`,{ref:ee,value:b,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&C(b.trim())},spellCheck:!1,className:`w-full rounded-lg border border-dark-border bg-dark-surface ps-8 pe-2.5 py-1.5 text-xs font-mono focus:outline-none focus:border-accent-blue/50`})]}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>void C(b.trim()),disabled:g||!b.trim(),className:`shrink-0 rounded-lg border border-dark-border px-2.5 py-1.5 text-xs text-dark-muted hover:bg-dark-hover disabled:opacity-40`,children:i(`chat.dirPickerGo`)})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`flex-1 truncate font-mono text-meta text-dark-muted bg-dark-surface rounded-md px-2 py-1 border border-dark-border`,title:l,children:l||`—`}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>d&&void C(d),disabled:g||!d,className:`shrink-0 flex items-center gap-1 rounded-md border border-dark-border px-2 py-1 text-meta text-dark-muted hover:bg-dark-hover disabled:opacity-40`,children:[(0,U.jsx)(a,{size:12}),i(`chat.dirPickerUp`)]})]}),(0,U.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto rounded-lg border border-dark-border bg-dark-surface divide-y divide-dark-border/60`,children:g?(0,U.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-6 text-xs text-dark-muted`,children:[(0,U.jsx)(o,{size:14,className:`animate-spin`}),i(`chat.loading`)]}):v?(0,U.jsx)(`div`,{className:`px-3 py-4 text-xs text-accent-red`,children:v}):p.length===0?(0,U.jsx)(`div`,{className:`px-3 py-4 text-xs text-dark-muted/60 text-center`,children:`—`}):p.map(e=>{let t=l.includes(`\\`)?`\\`:`/`,n=l.endsWith(t)?l+e:l+t+e;return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>void C(n),className:`w-full flex items-center gap-2 px-3 py-1.5 text-start text-xs text-dark-text hover:bg-dark-hover`,children:[(0,U.jsx)(ae,{size:13,className:`shrink-0 text-accent-yellow/80`}),(0,U.jsx)(`span`,{className:`truncate`,children:e})]},e)})}),(0,U.jsx)(ue,{variant:`accent`,className:`w-full`,onClick:()=>r(l),disabled:!l,loading:g,children:i(`chat.dirPickerConfirm`)})]})]})]}):null}function $e(){let{t:e}=w(),{automations:a,runsByAutomation:s,fetchAutomations:c,createAutomation:S,updateAutomation:C,deleteAutomation:ae,toggleAutomation:ce,runAutomation:de,fetchRuns:D,error:O}=pe(),[k,j]=(0,R.useState)(!1),{visible:M,phase:N}=le(k),[ge,P]=(0,R.useState)(null),[F,I]=(0,R.useState)(X),[_e,ve]=(0,R.useState)(null),[L,Se]=(0,R.useState)(``),[Ce,z]=(0,R.useState)(!1),[B,we]=fe(),Te=async t=>{await we({message:e(`automation.deleteConfirm`,{name:t.name}),variant:`danger`})&&await ae(t.id)},[Ee,V]=(0,R.useState)(!1),[H,je]=(0,R.useState)(Ge),[W,G]=(0,R.useState)(()=>new Date),[K,Pe]=(0,R.useState)(()=>new Date),[Fe,q]=(0,R.useState)(null),J=e=>{Pe(e),q(null)};(0,R.useEffect)(()=>{Ke(H)},[H]);let Y=(0,R.useMemo)(()=>{if(H===`month`){let e=Me(W);return{from:e[0],to:e[e.length-1]}}if(H===`week`){let e=Ne(W);return{from:e[0],to:e[e.length-1]}}return null},[H,W]),He=(0,R.useMemo)(()=>Y?De(a,Y.from,Y.to):[],[a,Y]),Z=(0,R.useMemo)(()=>Ae(He),[He]),Q=(0,R.useMemo)(()=>Z.get(ke(K))??[],[Z,K]),$e=e=>{let t=H===`week`?he(W,e):me(W,e);G(t),(H===`week`?ye(K,t,{weekStartsOn:1}):be(K,t))||J(t)},et=()=>{let e=new Date;G(e),J(e)},tt=async(t,n)=>{let r=Oe(t.automation,n);if(!r.ok){r.reason===`noop-day`?T.info(e(`automation.dragNoop`)):T.warning(e(`automation.dragLocked`));return}let i=Ye(t.automation.schedule,e);await C(t.automation.id,{schedule:r.schedule})&&(J(n),T.success(e(`automation.dragMoved`,{name:t.automation.name,from:i,to:Ye(r.schedule,e)})))},nt=(0,R.useMemo)(()=>{if(H===`week`){let e=Ne(W);return`${A(e[0],`yyyy-MM-dd`)} → ${A(e[e.length-1],`MM-dd`)}`}return A(W,`yyyy-MM`)},[H,W]),[rt,it]=(0,R.useState)([]),[at,ot]=(0,R.useState)([]),[st,ct]=(0,R.useState)([]),[lt,ut]=(0,R.useState)([]),[dt,ft]=(0,R.useState)(!1),[pt,mt]=(0,R.useState)([]),[ht,gt]=(0,R.useState)(!1),[_t,vt]=(0,R.useState)(!1),yt=async()=>{if(ht)return;gt(!0);let e=await E.sessions.list().catch(()=>({success:!1,data:void 0}));e.success&&Array.isArray(e.data)&&mt(e.data.filter(e=>!e.id.startsWith(`__automation_run__`)))},[bt,$]=(0,R.useState)([]),xt=(0,R.useRef)(null);(0,R.useEffect)(()=>{c()},[c]);let St=async e=>{P(null),I(e?{...e.form}:{...X}),$([]),j(!0),await Tt()},Ct=async e=>{P(e.id),I(qe(e)),$((e.attachments??[]).map((e,t)=>({id:`existing-${t}-${e}`,name:Ze(e),file:null,uploading:!1,path:e}))),j(!0),await Tt(),e.runSessionMode===`fixed`&&yt()},wt=()=>{j(!1),P(null),I(X),$([]),V(!1)},Tt=async()=>{vt(!0);try{let e=E.templates?.list?E.templates.list().catch(()=>({success:!1,data:void 0})):Promise.resolve({success:!1,data:void 0}),[t,n,r,i]=await Promise.all([E.models.list().catch(()=>({success:!1,data:void 0})),E.connectors.list().catch(()=>({success:!1,data:void 0})),E.channels.list().catch(()=>({success:!1,data:void 0})),e]);t.success&&t.data?.models?it(t.data.models.filter(e=>e.enabled!==!1)):it([]),n.success&&n.data?.connectors?ot(n.data.connectors.filter(e=>e.installed)):ot([]),r.success&&Array.isArray(r.data)?ct(r.data):ct([]),i.success&&Array.isArray(i.data)?ut(i.data):ut([]),ft(!0)}finally{vt(!1)}},Et=e=>{I(t=>{if(t.jobKind===e)return t;let n=e===`agent`&&!Ue(t.name);return{...t,jobKind:e,workflowTemplate:``,instructions:``,name:n?t.name:``}})},Dt=()=>{let e=lt.find(e=>e.id===F.workflowTemplate),t={};for(let n of e?.inputs??[])t[n.name]=n.default===void 0?``:n.default;I(e=>({...e,instructions:JSON.stringify(t,null,2)}))},Ot=async()=>{let t=Je(F);if(!t)return;let n=F.jobKind===`workflow`;if(n&&!F.workflowTemplate)return;if(n){let t=F.instructions.trim();if(t){let n;try{n=JSON.parse(t)}catch{T.warning(e(`automation.workflowJsonInvalid`));return}if(!n||typeof n!=`object`||Array.isArray(n)){T.warning(e(`automation.workflowJsonNotObject`));return}}}else if(!F.name.trim()||!F.instructions.trim())return;if(bt.some(e=>e.uploading)){T.warning(`附件上传中,请稍候…`);return}let r=bt.filter(e=>e.error).map(e=>e.name);if(r.length>0){T.warning(`附件上传失败:${r.join(`, `)}`);return}z(!0);let i={name:n?`${Ve}${F.workflowTemplate}`:F.name.trim(),instructions:F.instructions.trim(),schedule:t,workspaceDir:F.workspaceDir.trim(),readAutoAllow:F.readAutoAllow,modelRef:F.modelRef.trim()||null,attachments:bt.map(e=>e.path).filter(e=>!!e),connectorIds:[...F.connectorIds],notificationChannelIds:[...F.channelIds],runSessionMode:F.runSessionMode,runSessionId:F.runSessionMode===`fixed`&&F.runSessionId.trim()||null,budgetCents:ze(F.budgetUsd)},a=ge?await C(ge,i):await S(i)!==null;z(!1),a&&wt()},kt=async e=>{let t=L.trim();if(!t)return;let[n,...r]=t.split(/\s+/),i=r.join(` `);n&&i&&(await fetch(`/api/automations/${encodeURIComponent(e)}/permissions`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({tool:n,target:i})})).ok&&(Se(``),await c())},At=async(e,t)=>{(await fetch(`/api/automations/${encodeURIComponent(e)}/permissions`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify({entry:t})})).ok&&await c()},jt=async e=>{let t=_e===e?null:e;ve(t),t&&await D(e)},Mt=async e=>{if(!e||e.length===0)return;let t=Array.from(e).map(e=>({id:`f-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,name:e.name,file:e,uploading:!0}));$(e=>[...e,...t]);for(let e of t){let t=`${Be}/${e.name}`;try{let n=await E.files.upload(e.file,t);if(n.success&&n.data?.path){let t=n.data.path.replace(/\\/g,`/`);$(n=>n.map(n=>n.id===e.id?{...n,uploading:!1,path:t}:n))}else $(t=>t.map(t=>t.id===e.id?{...t,uploading:!1,error:n.error||`upload failed`}:t))}catch(t){let n=t instanceof Error?t.message:`upload failed`;$(t=>t.map(t=>t.id===e.id?{...t,uploading:!1,error:n}:t))}}},Nt=e=>{$(t=>t.filter(t=>t.id!==e))},Pt=[{id:`movie`,nameKey:`automation.tplMovieName`,descKey:`automation.tplMovieDesc`,form:{...X,name:e(`automation.tplMovieName`),instructions:e(`automation.tplMovieInstr`),freq:`daily`,time:`20:00`}},{id:`health`,nameKey:`automation.tplHealthName`,descKey:`automation.tplHealthDesc`,form:{...X,name:e(`automation.tplHealthName`),instructions:e(`automation.tplHealthInstr`),freq:`daily`,time:`14:00`}},{id:`why`,nameKey:`automation.tplWhyName`,descKey:`automation.tplWhyDesc`,form:{...X,name:e(`automation.tplWhyName`),instructions:e(`automation.tplWhyInstr`),freq:`daily`,time:`16:00`}},{id:`git`,nameKey:`automation.tplGitName`,descKey:`automation.tplGitDesc`,form:{...X,name:e(`automation.tplGitName`),instructions:e(`automation.tplGitInstr`),freq:`weekdays`,time:`09:00`}}],Ft=lt.find(e=>e.id===F.workflowTemplate),It=(F.jobKind===`workflow`?!!F.workflowTemplate:!!(F.name.trim()&&F.instructions.trim()))&&(F.freq===`custom`?!!F.cron.trim():F.freq!==`once`||!!F.onceAt);return(0,U.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col overflow-y-auto p-6 max-md:p-3`,children:[B,(0,U.jsxs)(`div`,{className:`max-w-7xl w-full mx-auto`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between mb-1`,children:[(0,U.jsxs)(`h2`,{className:`text-xl font-semibold flex items-center gap-2`,children:[(0,U.jsx)(te,{size:20,className:`text-accent-blue`}),e(`automation.title`)]}),(0,U.jsx)(`button`,{onClick:()=>void c(),className:`p-2 rounded-lg hover:bg-dark-hover text-dark-muted`,title:e(`automation.refresh`),children:(0,U.jsx)(y,{size:16})})]}),(0,U.jsx)(`p`,{className:`text-sm text-dark-muted mb-4`,children:e(`automation.subtitle`)}),(0,U.jsx)(`div`,{className:`mb-4`,children:a.length===0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,U.jsx)(t,{size:15,className:`text-accent-yellow`}),(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`automation.recommendedTitle`)})]}),(0,U.jsx)(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-4`,children:Pt.map(t=>(0,U.jsxs)(`button`,{onClick:()=>void St(t),className:`flex flex-col gap-1 rounded-xl border border-dark-border bg-dark-surface p-2.5 text-start transition-colors hover:border-accent-blue/60 hover:bg-dark-hover/50`,children:[(0,U.jsx)(`span`,{className:`text-xs font-semibold`,children:e(t.nameKey)}),(0,U.jsx)(`span`,{className:`text-meta leading-relaxed text-dark-muted line-clamp-1`,children:e(t.descKey)}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 self-start rounded bg-dark-hover px-1.5 py-0.5 text-badge text-dark-muted`,children:[(0,U.jsx)(te,{size:11}),` `,Ye(Je(t.form),e)]})]},t.id))})]}):(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5 pe-1 text-meta font-medium text-dark-muted`,children:[(0,U.jsx)(t,{size:13,className:`text-accent-yellow`}),e(`automation.recommendedTitle`)]}),Pt.map(t=>(0,U.jsxs)(`button`,{onClick:()=>void St(t),title:e(t.descKey),className:`flex items-center gap-1.5 rounded-lg border border-dark-border bg-dark-surface px-2 py-1 text-meta text-dark-muted transition-colors hover:border-accent-blue/60 hover:text-dark-text`,children:[(0,U.jsx)(h,{size:11}),e(t.nameKey),(0,U.jsx)(`span`,{className:`text-badge tabular-nums opacity-60`,children:Ye(Je(t.form),e)})]},t.id))]})}),O&&(0,U.jsxs)(`div`,{className:`mb-4 p-3 rounded-lg bg-accent-red/10 text-accent-red text-sm flex items-center gap-2`,children:[(0,U.jsx)(_,{size:16}),` `,O]}),(0,U.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`flex items-center rounded-lg border border-dark-border bg-dark-surface p-0.5`,children:We.map(({id:t,key:n,Icon:r})=>(0,U.jsxs)(`button`,{onClick:()=>je(t),"aria-pressed":H===t,className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${H===t?`bg-accent-blue/15 text-accent-blue font-medium`:`text-dark-muted hover:text-dark-text`}`,children:[(0,U.jsx)(r,{size:13}),` `,e(n)]},t))}),H!==`list`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,U.jsx)(`button`,{onClick:()=>$e(-1),title:e(`automation.prevPeriod`),className:`rounded-lg border border-dark-border bg-dark-surface p-1.5 text-dark-muted hover:text-dark-text`,children:(0,U.jsx)(n,{size:14})}),(0,U.jsx)(`button`,{onClick:et,className:`rounded-lg border border-dark-border bg-dark-surface px-2 py-1.5 text-xs text-dark-muted hover:text-dark-text`,children:e(`automation.today`)}),(0,U.jsx)(`button`,{onClick:()=>$e(1),title:e(`automation.nextPeriod`),className:`rounded-lg border border-dark-border bg-dark-surface p-1.5 text-dark-muted hover:text-dark-text`,children:(0,U.jsx)(r,{size:14})})]}),(0,U.jsx)(`span`,{className:`text-sm font-medium tabular-nums`,children:nt})]}),(0,U.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-xs text-dark-muted`,children:e(`automation.tasksCount`,{count:a.length})}),(0,U.jsxs)(`button`,{onClick:()=>void St(),className:`flex items-center gap-1 rounded-lg bg-accent-blue px-3 py-1.5 text-xs font-medium text-accent-fg hover:brightness-110`,children:[(0,U.jsx)(h,{size:14}),` `,e(`automation.new`)]})]})]}),H!==`list`&&(0,U.jsxs)(`div`,{className:`mb-6 flex flex-col gap-4 lg:flex-row lg:items-start`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[H===`month`?(0,U.jsx)(Ie,{anchor:W,selectedDay:K,byDay:Z,onSelectDay:J,onFocusSlot:(e,t)=>{Pe(e),q(t)},onMoveOccurrence:(e,t)=>void tt(e,t)}):(0,U.jsx)(Le,{anchor:W,selectedDay:K,byDay:Z,onSelectDay:J,onFocusSlot:(e,t)=>{Pe(e),q(t)},onMoveOccurrence:(e,t)=>void tt(e,t)}),a.length===0&&(0,U.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 rounded-lg border border-dashed border-dark-border px-3 py-2 text-xs text-dark-muted`,children:[(0,U.jsx)(i,{size:14}),e(`automation.emptyTitle`),` · `,e(`automation.emptyDesc`)]})]}),(0,U.jsx)(Re,{day:K,occurrences:Q,focusSlot:Fe,onClearFocus:()=>q(null),onEdit:e=>void Ct(e),onRun:e=>void de(e),onToggle:e=>void ce(e.id,e.status!==`enabled`),onDelete:e=>void Te(e),onCreate:()=>void St()})]}),H===`list`&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:e(`automation.mineTitle`)}),(0,U.jsx)(`span`,{className:`text-xs text-dark-muted`,children:a.length})]}),a.length===0?(0,U.jsxs)(`div`,{className:`rounded-xl border border-dashed border-dark-border py-12 flex flex-col items-center gap-2 text-center`,children:[(0,U.jsx)(i,{size:32,className:`text-dark-muted`}),(0,U.jsx)(`p`,{className:`text-sm font-medium`,children:e(`automation.emptyTitle`)}),(0,U.jsx)(`p`,{className:`text-xs text-dark-muted`,children:e(`automation.emptyDesc`)}),(0,U.jsxs)(`button`,{onClick:()=>void St(),className:`mt-2 flex items-center gap-1 px-4 py-1.5 rounded-lg border border-dark-border bg-dark-surface hover:bg-dark-hover text-sm font-medium`,children:[(0,U.jsx)(h,{size:15}),` `,e(`automation.new`)]})]}):(0,U.jsx)(`div`,{className:`space-y-2`,children:a.map(t=>(0,U.jsxs)(`div`,{className:`rounded-xl border border-dark-border bg-dark-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between p-3`,children:[(0,U.jsxs)(`button`,{onClick:()=>void jt(t.id),className:`flex items-center gap-2 min-w-0 text-start`,children:[(0,U.jsx)(te,{size:16,className:`text-accent-blue shrink-0`}),(0,U.jsx)(`span`,{className:`font-medium text-sm truncate`,children:t.name}),(0,U.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded shrink-0 ${t.status===`enabled`?`bg-accent-green/20 text-accent-green`:`bg-dark-hover text-dark-muted`}`,children:t.status===`enabled`?e(`automation.enabled`):e(`automation.disabled`)}),(0,U.jsx)(`span`,{className:`text-xs text-dark-muted shrink-0 hidden md:inline`,children:Ye(t.schedule,e)})]}),(0,U.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[t.nextRunAt&&(0,U.jsxs)(`span`,{className:`text-xs text-dark-muted hidden lg:inline me-1`,children:[e(`automation.nextRun`),`: `,new Date(t.nextRunAt).toLocaleString()]}),(0,U.jsx)(`button`,{onClick:()=>void Ct(t),className:`p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted`,title:e(`automation.edit`),children:(0,U.jsx)(f,{size:15})}),(0,U.jsx)(`button`,{onClick:()=>void ce(t.id,t.status!==`enabled`),className:`p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted`,title:t.status===`enabled`?e(`automation.disable`):e(`automation.enable`),children:(0,U.jsx)(b,{size:15})}),(0,U.jsx)(`button`,{onClick:()=>void de(t.id),className:`p-1.5 rounded-lg hover:bg-dark-hover text-accent-green`,title:e(`automation.runNow`),children:(0,U.jsx)(ee,{size:15})}),(0,U.jsx)(`button`,{onClick:()=>void Te(t),className:`p-1.5 rounded-lg hover:bg-dark-hover text-accent-red`,title:e(`automation.delete`),children:(0,U.jsx)(ne,{size:15})})]})]}),_e===t.id&&(0,U.jsxs)(`div`,{className:`px-3 pb-3 space-y-3 border-t border-dark-border pt-3`,children:[Ue(t.name)?(0,U.jsxs)(`div`,{className:`space-y-1`,children:[(0,U.jsxs)(`p`,{className:`text-xs text-dark-muted flex items-center gap-1.5`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-accent-blue/10 text-accent-blue`,children:[(0,U.jsx)(v,{size:11}),` `,e(`automation.jobKindWorkflow`)]}),(0,U.jsx)(`code`,{children:Ue(t.name)})]}),t.instructions.trim()&&(0,U.jsx)(`pre`,{className:`text-badge text-dark-muted whitespace-pre-wrap font-mono`,children:t.instructions})]}):(0,U.jsx)(`p`,{className:`text-xs text-dark-muted whitespace-pre-wrap`,children:t.instructions}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`h4`,{className:`text-xs font-semibold text-dark-muted mb-1 flex items-center gap-1`,children:[(0,U.jsx)(u,{size:12}),` `,e(`automation.historyTitle`)]}),(s[t.id]||[]).length===0&&(0,U.jsx)(`p`,{className:`text-xs text-dark-muted`,children:e(`automation.noRuns`)}),(s[t.id]||[]).slice(0,10).map(e=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs py-1`,children:[(0,U.jsxs)(`span`,{className:`px-1.5 py-0.5 rounded flex items-center gap-1 ${e.status===`ok`?`bg-accent-green/20 text-accent-green`:e.status===`error`?`bg-accent-red/20 text-accent-red`:`bg-accent-yellow/20 text-accent-yellow`}`,children:[e.status===`ok`&&(0,U.jsx)(re,{size:11}),e.status]}),(0,U.jsx)(`span`,{className:`text-dark-muted`,children:new Date(e.startedAt).toLocaleString()}),(0,U.jsxs)(`span`,{className:`text-dark-muted truncate flex-1`,children:[`#`,e.id.slice(0,8),` · `,e.trigger]})]},e.id))]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h4`,{className:`text-xs font-semibold text-dark-muted mb-1`,children:e(`automation.permissionsTitle`)}),t.permissions.length===0&&(0,U.jsx)(`p`,{className:`text-xs text-dark-muted`,children:e(`automation.permissionsEmpty`)}),(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1`,children:t.permissions.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded bg-accent-blue/10 text-accent-blue text-xs`,children:[e,(0,U.jsx)(`button`,{onClick:()=>void At(t.id,e),className:`hover:text-accent-red`,children:(0,U.jsx)(x,{size:12})})]},e))}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`input`,{value:L,onChange:e=>Se(e.target.value),placeholder:e(`automation.permissionPlaceholder`),className:`flex-1 px-2 py-1.5 rounded-lg bg-dark-bg border border-dark-border text-xs focus:outline-none focus:border-accent-blue`}),(0,U.jsx)(`button`,{onClick:()=>void kt(t.id),className:`px-3 py-1.5 rounded-lg bg-dark-hover text-dark-muted hover:text-dark-text text-xs`,children:e(`automation.add`)})]})]})]})]},t.id))})]})]}),M&&(0,U.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 max-md:p-0`,onClick:wt,children:[(0,U.jsx)(`div`,{className:`absolute inset-0 ui-scrim ui-overlay-backdrop`,"data-phase":N,"aria-hidden":`true`}),(0,U.jsxs)(`div`,{className:`relative w-full max-w-2xl rounded-xl border border-dark-border bg-dark-overlay ui-surface-overlay p-5 space-y-4 shadow-pop max-h-[90vh] overflow-y-auto custom-scrollbar ui-overlay-panel max-md:max-w-none max-md:rounded-none max-md:p-4`,"data-phase":N,onClick:e=>e.stopPropagation(),children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-base font-semibold`,children:e(ge?`automation.editTitle`:`automation.createTitle`)}),(0,U.jsx)(`p`,{className:`text-xs text-dark-muted mt-0.5`,children:e(`automation.subtitle`)})]}),(0,U.jsx)(`button`,{onClick:wt,className:`p-1.5 rounded-lg hover:bg-dark-hover text-dark-muted`,children:(0,U.jsx)(x,{size:16})})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`block text-xs font-medium text-dark-muted mb-1.5`,children:e(`automation.jobKindLabel`)}),(0,U.jsx)(`div`,{className:`flex gap-1.5`,children:[{id:`agent`,label:e(`automation.jobKindAgent`),hint:e(`automation.jobKindAgentHint`)},{id:`workflow`,label:e(`automation.jobKindWorkflow`),hint:e(`automation.jobKindWorkflowHint`)}].map(e=>{let n=F.jobKind===e.id;return(0,U.jsxs)(`button`,{type:`button`,title:e.hint,onClick:()=>Et(e.id),className:`flex-1 px-3 py-2 rounded-lg border text-sm flex items-center justify-center gap-1.5 ${n?`border-accent-blue bg-accent-blue/10 text-accent-blue`:`border-dark-border bg-dark-surface text-dark-muted hover:bg-dark-hover`}`,children:[e.id===`workflow`?(0,U.jsx)(v,{size:13}):(0,U.jsx)(t,{size:13}),e.label]},e.id)})})]}),F.jobKind===`workflow`&&(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`block text-xs font-medium text-dark-muted mb-1.5`,children:e(`automation.workflowTemplateLabel`)}),(0,U.jsxs)(`select`,{value:F.workflowTemplate,onChange:e=>{let t=e.target.value;I(e=>({...e,workflowTemplate:t,name:t?`${Ve}${t}`:``}))},className:`w-full px-3 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue`,children:[(0,U.jsx)(`option`,{value:``,children:e(`automation.workflowTemplateNone`)}),lt.map(e=>(0,U.jsx)(`option`,{value:e.id,children:(e.nameOverride||e.name||e.id)+(e.category?` · ${e.category}`:``)},e.id))]}),dt&<.length===0&&(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.workflowTemplateEmpty`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`block text-xs font-medium text-dark-muted mb-1.5`,children:e(`automation.nameLabel`)}),(0,U.jsx)(`input`,{autoFocus:F.jobKind===`agent`,value:F.name,onChange:e=>I(t=>({...t,name:e.target.value})),placeholder:e(`automation.namePlaceholder`),disabled:F.jobKind===`workflow`,className:`w-full px-3 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue disabled:opacity-60`}),F.jobKind===`workflow`&&(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.workflowNameHint`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`block text-xs font-medium text-dark-muted mb-1.5`,children:e(`automation.scheduleLabel`)}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsxs)(`select`,{value:F.freq,onChange:e=>I(t=>({...t,freq:e.target.value})),className:`px-2.5 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue`,children:[(0,U.jsx)(`option`,{value:`daily`,children:e(`automation.freqDaily`)}),(0,U.jsx)(`option`,{value:`weekly`,children:e(`automation.freqWeekly`)}),(0,U.jsx)(`option`,{value:`weekdays`,children:e(`automation.freqWeekdays`)}),(0,U.jsx)(`option`,{value:`once`,children:e(`automation.freqOnce`)}),(0,U.jsx)(`option`,{value:`custom`,children:e(`automation.freqCustom`)})]}),F.freq===`weekly`&&(0,U.jsx)(`select`,{value:F.dow,onChange:e=>I(t=>({...t,dow:e.target.value})),className:`px-2.5 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue`,children:Xe.map(t=>(0,U.jsx)(`option`,{value:t.value,children:e(t.key)},t.value))}),(F.freq===`daily`||F.freq===`weekly`||F.freq===`weekdays`)&&(0,U.jsx)(`input`,{type:`time`,value:F.time,onChange:e=>I(t=>({...t,time:e.target.value})),className:`flex-1 px-3 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue`}),F.freq===`once`&&(0,U.jsx)(`input`,{type:`datetime-local`,value:F.onceAt,onChange:e=>I(t=>({...t,onceAt:e.target.value})),className:`flex-1 px-3 py-2 rounded-lg bg-dark-surface border border-dark-border text-sm focus:outline-none focus:border-accent-blue`}),F.freq===`custom`&&(0,U.jsx)(`input`,{value:F.cron,onChange:e=>I(t=>({...t,cron:e.target.value})),placeholder:`*/30 * * * *`,className:`flex-1 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm font-mono focus:outline-none focus:border-accent-blue`})]})]}),F.jobKind===`agent`?(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`block text-xs font-medium text-dark-muted mb-1.5`,children:e(`automation.instructionLabel`)}),(0,U.jsx)(`textarea`,{value:F.instructions,onChange:e=>I(t=>({...t,instructions:e.target.value})),placeholder:e(`automation.instructionsPlaceholder`),rows:4,className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue resize-none`})]}):(0,U.jsxs)(`div`,{className:`rounded-lg border border-dark-border bg-dark-surface/40 p-3 space-y-2`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`label`,{className:`text-xs font-medium text-dark-muted`,children:e(`automation.workflowInputsLabel`)}),(Ft?.inputs.length??0)>0&&(0,U.jsx)(`button`,{type:`button`,onClick:Dt,className:`text-badge text-accent-blue hover:underline`,children:e(`automation.workflowInputsFillDefaults`)})]}),Ft&&Ft.inputs.length>0?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ul`,{className:`space-y-0.5`,children:Ft.inputs.map(e=>(0,U.jsxs)(`li`,{className:`text-badge text-dark-muted`,children:[(0,U.jsx)(`code`,{className:`text-accent-blue`,children:e.name}),e.label&&(0,U.jsx)(`span`,{className:`ms-1`,children:e.label}),e.required&&(0,U.jsx)(`span`,{className:`ms-1 text-accent-red`,children:`*`}),e.description&&(0,U.jsxs)(`span`,{className:`ms-1 text-dark-muted/60`,children:[`— `,e.description]})]},e.name))}),(0,U.jsx)(`textarea`,{value:F.instructions,onChange:e=>I(t=>({...t,instructions:e.target.value})),placeholder:`{
|
|
2
|
-
"key": "value"
|
|
3
|
-
}`,rows:4,className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-xs font-mono focus:outline-none focus:border-accent-blue resize-none`}),(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/70`,children:e(`automation.workflowInputsHint`)})]}):(0,U.jsx)(`p`,{className:`text-xs text-dark-muted/70`,children:e(`automation.workflowNoInputs`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,U.jsx)(oe,{size:12}),` `,e(`automation.attachmentsLabel`)]}),(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/70 mb-1.5`,children:e(`automation.attachmentsHint`)}),bt.length===0?(0,U.jsx)(`div`,{className:`text-xs text-dark-muted/60 italic`,children:e(`automation.attachmentsEmpty`)}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5 mb-2`,children:bt.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded-md text-xs ${e.error?`bg-accent-red/10 text-accent-red`:e.uploading?`bg-dark-hover text-dark-muted`:`bg-accent-blue/10 text-accent-blue`}`,title:e.path??e.error,children:[(0,U.jsx)(oe,{size:11}),(0,U.jsx)(`span`,{className:`truncate max-w-[180px]`,children:e.name}),e.uploading&&(0,U.jsx)(o,{size:11,className:`animate-spin`}),e.error&&(0,U.jsx)(_,{size:11}),(0,U.jsx)(`button`,{onClick:()=>Nt(e.id),className:`hover:text-accent-red ms-0.5`,children:(0,U.jsx)(x,{size:11})})]},e.id))}),(0,U.jsx)(`input`,{ref:xt,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{Mt(e.target.files),e.target.value=``}}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>xt.current?.click(),className:`inline-flex items-center gap-1 px-2.5 py-1 rounded-lg border border-dashed border-dark-border text-xs text-dark-muted hover:border-accent-blue/60 hover:text-accent-blue`,children:[(0,U.jsx)(h,{size:12}),` `,e(`automation.attachmentsAdd`)]})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,U.jsx)(l,{size:12}),` `,e(`automation.modelLabel`)]}),(0,U.jsxs)(`select`,{value:F.modelRef,onChange:e=>I(t=>({...t,modelRef:e.target.value})),className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue disabled:opacity-50 disabled:cursor-not-allowed`,disabled:_t||F.runSessionMode!==`new`,children:[(0,U.jsx)(`option`,{value:``,children:e(`automation.modelAuto`)}),rt.map(e=>(0,U.jsxs)(`option`,{value:`${e.provider}:${e.id}`,children:[e.name,` · `,e.provider]},`${e.provider}:${e.id}`))]}),F.runSessionMode!==`new`&&(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.modelFollowsSession`)}),!_t&&rt.length===0&&(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.modelNoModels`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,U.jsx)(m,{size:12}),` `,e(`automation.runSessionLabel`)]}),(0,U.jsxs)(`select`,{value:F.runSessionMode,onChange:e=>{let t=e.target.value;I(e=>({...e,runSessionMode:t})),t===`fixed`&&yt()},className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue`,children:[(0,U.jsx)(`option`,{value:`home`,children:e(`automation.runSessionHome`)}),(0,U.jsx)(`option`,{value:`new`,children:e(`automation.runSessionNew`)}),(0,U.jsx)(`option`,{value:`fixed`,children:e(`automation.runSessionFixed`)})]}),F.runSessionMode===`fixed`&&(0,U.jsxs)(`select`,{value:F.runSessionId,onChange:e=>I(t=>({...t,runSessionId:e.target.value})),className:`mt-2 w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue`,disabled:_t,children:[(0,U.jsx)(`option`,{value:``,children:e(`automation.runSessionPick`)}),pt.map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.title||e.id},e.id))]}),(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.runSessionHint`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,U.jsx)(p,{size:12}),` `,e(`automation.budgetLabel`)]}),(0,U.jsx)(`input`,{type:`text`,inputMode:`decimal`,value:F.budgetUsd,onChange:e=>I(t=>({...t,budgetUsd:e.target.value})),placeholder:e(`automation.budgetPlaceholder`),className:`w-full px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm focus:outline-none focus:border-accent-blue`}),(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/70 mt-1`,children:e(`automation.budgetHint`)})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,U.jsx)(g,{size:12}),` `,e(`automation.connectorsLabel`)]}),(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/70 mb-1.5`,children:e(`automation.connectorsHint`)}),(0,U.jsx)(`p`,{className:`text-badge text-accent-yellow/90 mb-1.5`,children:e(`automation.connectorsUnwired`)}),at.length===0?(0,U.jsx)(`div`,{className:`text-xs text-dark-muted/60 italic`,children:e(`automation.connectorsEmpty`)}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5 opacity-50`,children:at.map(t=>{let n=F.connectorIds.includes(t.id);return(0,U.jsxs)(`button`,{type:`button`,disabled:!0,"aria-disabled":!0,title:e(`automation.connectorsUnwired`),className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs border cursor-not-allowed ${n?`bg-accent-blue/15 text-accent-blue border-accent-blue/40`:`bg-dark-bg text-dark-muted border-dark-border`}`,children:[(0,U.jsx)(g,{size:11}),t.name]},t.id)})})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,U.jsx)(d,{size:12}),` `,e(`automation.channelsLabel`)]}),(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/70 mb-1.5`,children:e(`automation.channelsHint`)}),st.length===0?(0,U.jsx)(`div`,{className:`text-xs text-dark-muted/60 italic`,children:e(`automation.channelsEmpty`)}):(0,U.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:st.map(e=>{let t=F.channelIds.includes(e.id);return(0,U.jsxs)(`button`,{type:`button`,disabled:!e.enabled,onClick:()=>I(n=>({...n,channelIds:t?n.channelIds.filter(t=>t!==e.id):[...n.channelIds,e.id]})),className:`inline-flex items-center gap-1 px-2 py-1 rounded-md text-xs transition-colors ${t?`bg-accent-blue/15 text-accent-blue border border-accent-blue/40`:e.enabled?`bg-dark-bg text-dark-muted border border-dark-border hover:border-accent-blue/40 hover:text-accent-blue`:`bg-dark-bg text-dark-muted/50 border border-dark-border opacity-60 cursor-not-allowed`}`,children:[(0,U.jsx)(d,{size:11}),e.name,!e.enabled&&(0,U.jsx)(`span`,{className:`text-avatar`,children:`·off`})]},e.id)})})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,U.jsx)(ie,{size:12}),` `,e(`automation.workspaceLabel`)]}),(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/70 mb-1.5`,children:e(`automation.workspaceHint`)}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsx)(`input`,{value:F.workspaceDir,onChange:e=>I(t=>({...t,workspaceDir:e.target.value})),placeholder:`留空使用当前工作目录`,className:`flex-1 px-3 py-2 rounded-lg bg-dark-bg border border-dark-border text-sm font-mono focus:outline-none focus:border-accent-blue`}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>V(!0),className:`shrink-0 inline-flex items-center gap-1 px-3 py-2 rounded-lg border border-dark-border text-xs text-dark-muted hover:bg-dark-hover hover:text-dark-text`,children:[(0,U.jsx)(ie,{size:12}),` `,e(`automation.workspacePick`)]}),F.workspaceDir&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>I(e=>({...e,workspaceDir:``})),className:`shrink-0 inline-flex items-center gap-1 px-2 py-2 rounded-lg border border-dark-border text-xs text-dark-muted hover:bg-dark-hover hover:text-accent-red`,title:e(`automation.workspaceClear`),children:(0,U.jsx)(x,{size:12})})]})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-1.5 text-xs font-medium text-dark-muted mb-1.5`,children:[(0,U.jsx)(se,{size:12}),` `,e(`automation.permissionAccess`)]}),(0,U.jsxs)(`div`,{className:`flex items-start gap-2 p-2.5 rounded-lg border border-dark-border bg-dark-bg`,children:[(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":F.readAutoAllow,onClick:()=>I(e=>({...e,readAutoAllow:!e.readAutoAllow})),className:`relative shrink-0 mt-0.5 inline-flex h-5 w-9 items-center rounded-full transition-colors ${F.readAutoAllow?`bg-accent-blue`:`bg-dark-hover`}`,children:(0,U.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${F.readAutoAllow?`translate-x-4`:`translate-x-0.5`}`})}),(0,U.jsxs)(`div`,{className:`flex-1`,children:[(0,U.jsx)(`div`,{className:`text-xs font-medium text-dark-text`,children:e(`automation.fullAccessLabel`)}),(0,U.jsx)(`p`,{className:`text-badge text-dark-muted/80 mt-0.5`,children:e(`automation.fullAccessHint`)})]})]})]}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2 pt-1`,children:[(0,U.jsx)(`button`,{onClick:wt,className:`px-4 py-2 rounded-lg bg-dark-hover text-dark-muted hover:text-dark-text text-sm`,children:e(`automation.cancel`)}),(0,U.jsx)(ue,{variant:`accent`,onClick:()=>void Ot(),disabled:!It,loading:Ce,children:e(`automation.save`)})]})]})]}),(0,xe.createPortal)((0,U.jsx)(Qe,{isOpen:Ee&&k,initial:F.workspaceDir||``,onClose:()=>V(!1),onConfirm:e=>{I(t=>({...t,workspaceDir:e})),V(!1)}}),document.body)]})}export{$e as AutomationView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Kt as t,ni as n}from"./icons-B8Ngx6rM.js";import{n as r}from"./state-pOTP5BEk.js";import{I as i}from"./markdown-Cps-36Z5.js";var a=4e3,o=new Map;function s(e,t){let n=o.get(e);n&&clearTimeout(n),!(t<=0)&&o.set(e,setTimeout(()=>{o.delete(e),c.setState(t=>({toasts:t.toasts.filter(t=>t.id!==e)}))},t))}var c=r(e=>({toasts:[],addToast:(t,n,r,i,o)=>{let c=r??a,l=e=>e.dedupeKey??`${e.type}\u0000${e.message}`,u=o??`${t}\u0000${n}`;e(e=>{let r=e.toasts.find(e=>l(e)===u);if(r)return s(r.id,c),{toasts:e.toasts.map(e=>e.id===r.id?{...e,count:e.count+1,createdAt:Date.now(),action:i??e.action}:e)};let a=`toast-${Date.now()}-${Math.random().toString(36).slice(2,7)}`;s(a,c);let d={id:a,type:t,message:n,duration:c,createdAt:Date.now(),count:1,action:i,...o?{dedupeKey:o}:{}};return{toasts:[...e.toasts,d].slice(-10)}})},dismissToast:t=>{let n=o.get(t);n&&(clearTimeout(n),o.delete(t)),e(e=>({toasts:e.toasts.filter(e=>e.id!==t)}))},clearAll:()=>{for(let e of o.values())clearTimeout(e);o.clear(),e({toasts:[]})}})),l={info:(e,t)=>c.getState().addToast(`info`,e,t),success:(e,t)=>c.getState().addToast(`success`,e,t),warning:(e,t)=>c.getState().addToast(`warning`,e,t),error:(e,t)=>c.getState().addToast(`error`,e,t??6e3),infoWithAction:(e,t,n,r)=>c.getState().addToast(`info`,e,n,t,r)},u=e(n(),1);function d(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`){if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=d(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n)}return r}function f(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=d(e))&&(r&&(r+=` `),r+=t);return r}function p(...e){return f(e)}var m=20;function h(){if(typeof window>`u`||typeof getComputedStyle!=`function`)return 220;let e=getComputedStyle(document.documentElement).getPropertyValue(`--dur-base`).trim(),t=Number.parseFloat(e);return!Number.isFinite(t)||t<=0?220:(e.endsWith(`ms`)?t:t*1e3)+m}function g(e){let[t,n]=(0,u.useState)(e),[r,i]=(0,u.useState)(!1),a=(0,u.useRef)(e);return a.current!==e&&(a.current=e,e?(n(!0),i(!1)):t&&i(!0)),(0,u.useEffect)(()=>{if(!r)return;let e=window.setTimeout(()=>{i(!1),n(!1)},h());return()=>window.clearTimeout(e)},[r]),{visible:t,phase:r?`exit`:`enter`}}var _=i(),v={primary:`btn-primary`,accent:`btn-accent`,secondary:`btn-secondary`,ghost:`btn-ghost`,danger:`btn-danger`},y={sm:`btn-sm`,lg:`btn-lg`},b={sm:13,md:15,lg:17};function x({variant:e=`secondary`,size:n=`md`,shape:r=`default`,loading:i=!1,leftIcon:a,rightIcon:o,type:s=`button`,disabled:c,className:l,children:u,ref:d,...f}){return(0,_.jsxs)(`button`,{ref:d,type:s,disabled:c||i,"aria-busy":i||void 0,className:p(`btn`,v[e],n!==`md`&&y[n],r===`pill`&&`btn-pill`,l),...f,children:[i?(0,_.jsx)(t,{size:b[n],className:`shrink-0 animate-spin`,"aria-hidden":`true`}):a,u,!i&&o]})}export{c as a,l as i,g as n,p as r,x as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{A as t,Ar as n,Er as r,Kt as i,Nt as a,Or as o,Vt as s,g as c,gn as l,it as u,kr as d,n as f,ni as p,v as ee}from"./icons-B8Ngx6rM.js";import{t as m}from"./useTranslation-gGKZZfux.js";import{i as h,r as g}from"./Button-D-g7PgYh.js";import{l as te}from"./DiffPreview-D8tIj_aF.js";import{t as _}from"./api-ZQf0Ys8y.js";import{I as v}from"./markdown-Cps-36Z5.js";import{$ as y,Q as b,X as x,Z as S,et as C,ft as w,ht as ne,it as T,mt as re,nt as E,pt as ie,rt as ae,tt as D,wt as oe,xt as O}from"./index-STsyoFCk.js";var k=e(p(),1),A=v(),j=[];function M(e){let t=[];return e.query?t.push(e.query):e.connector&&t.push(e.connector),e.detail&&t.push(e.detail),t.join(` — `)}function se({onApproved:e,refreshToken:t=0}){let{t:n}=m(),[a,s]=(0,k.useState)(j),[l,u]=(0,k.useState)(!0),[p,ee]=(0,k.useState)(!0),[h,v]=(0,k.useState)(null),[y,b]=(0,k.useState)(null),x=(0,k.useCallback)(async()=>{u(!0);try{let e=await _.pendingArtifacts.list(`pending`);if(!e?.success)throw Error(e?.error||n(`charts.pending.loadFailed`));s(e.data?.items??j),b(null)}catch(e){b(e instanceof Error?e.message:String(e))}finally{u(!1)}},[n]);(0,k.useEffect)(()=>{x()},[x,t]);let S=(0,k.useCallback)(async(t,r)=>{v(t),b(null);try{let i=r===`approve`?await _.pendingArtifacts.approve(t):await _.pendingArtifacts.reject(t);if(!i?.success)throw Error(i?.error||n(`charts.pending.decideFailed`));s(e=>e.filter(e=>e.id!==t)),r===`approve`&&e?.(),x()}catch(e){b(e instanceof Error?e.message:String(e))}finally{v(null)}},[e,x,n]);return l&&a.length===0||a.length===0&&!y?null:(0,A.jsxs)(`div`,{"data-testid":`pending-artifacts`,className:`mx-4 mt-3 shrink-0 rounded-lg border border-accent-yellow/40 bg-accent-yellow/5`,children:[(0,A.jsxs)(`button`,{type:`button`,"data-testid":`pending-artifacts-toggle`,onClick:()=>ee(e=>!e),"aria-expanded":p,className:`flex w-full items-center gap-2 px-3 py-2 text-start`,children:[(0,A.jsx)(p?o:r,{size:13,className:`shrink-0 text-accent-yellow`}),(0,A.jsx)(`span`,{className:`shrink-0 text-xs font-medium text-accent-yellow`,children:n(`charts.pending.title`,{n:a.length})}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-badge text-dark-muted`,children:n(`charts.pending.subtitle`)}),l&&(0,A.jsx)(i,{size:12,className:`animate-spin text-dark-muted`})]}),p&&(0,A.jsxs)(`div`,{className:`border-t border-accent-yellow/20`,children:[y&&(0,A.jsxs)(`div`,{className:`flex items-start gap-2 px-3 py-2 text-xs text-accent-red`,children:[(0,A.jsx)(c,{size:13,className:`mt-0.5 shrink-0`}),(0,A.jsx)(`span`,{className:`min-w-0 break-words`,children:y})]}),a.map(e=>{let t=h===e.id;return(0,A.jsxs)(`div`,{"data-testid":`pending-artifact-item`,className:`flex items-start gap-2.5 border-b border-accent-yellow/15 px-3 py-2 last:border-b-0`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsx)(`p`,{className:`text-xs leading-relaxed text-dark-text`,children:e.summary}),(0,A.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-badge text-dark-muted/80`,children:[(0,A.jsx)(`span`,{className:`truncate font-mono`,children:e.targetPath}),(0,A.jsx)(`span`,{className:`shrink-0 rounded bg-dark-hover px-1 py-px`,children:e.artifactType}),(0,A.jsx)(`span`,{className:`shrink-0`,children:te(e.createdAt,Date.now(),n)})]}),e.sources.length>0?(0,A.jsx)(`ul`,{className:`mt-1 space-y-0.5`,"data-testid":`pending-artifact-sources`,children:e.sources.map((t,n)=>(0,A.jsx)(`li`,{className:`truncate font-mono text-badge text-dark-muted/70`,title:M(t),children:M(t)},`${e.id}-src-${n}`))}):(0,A.jsx)(`p`,{className:`mt-1 text-badge text-accent-yellow/80`,children:n(`charts.pending.noSources`)})]}),(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,A.jsxs)(`button`,{type:`button`,"data-testid":`pending-artifact-approve`,disabled:t,onClick:()=>void S(e.id,`approve`),title:n(`charts.pending.approveHint`),className:g(`flex items-center gap-1 rounded-md border border-accent-green/40 bg-accent-green/10 px-2 py-1 text-badge text-accent-green transition-colors hover:bg-accent-green/20`,t&&`opacity-60`),children:[t?(0,A.jsx)(i,{size:11,className:`animate-spin`}):(0,A.jsx)(d,{size:11}),n(`charts.pending.approve`)]}),(0,A.jsxs)(`button`,{type:`button`,"data-testid":`pending-artifact-reject`,disabled:t,onClick:()=>void S(e.id,`reject`),title:n(`charts.pending.rejectHint`),className:g(`flex items-center gap-1 rounded-md border border-dark-border px-2 py-1 text-badge text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text`,t&&`opacity-60`),children:[(0,A.jsx)(f,{size:11}),n(`charts.pending.reject`)]})]})]},e.id)})]})]})}var N=`dsc.charts.artifactOrder`,P=1;function ce(){try{let e=localStorage.getItem(N);if(!e)return[];let t=JSON.parse(e);if(typeof t!=`object`||!t)return[];let n=t;return n.v!==P||!Array.isArray(n.order)?[]:n.order.filter(e=>typeof e==`string`&&e!==``)}catch{return[]}}function F(e){try{localStorage.setItem(N,JSON.stringify({v:P,order:e}))}catch{}}function le(e,t,n){if(t.length===0)return[...e];let r=new Map(e.map(e=>[n(e),e])),i=[];for(let e of t){let t=r.get(e);t!==void 0&&(i.push(t),r.delete(e))}for(let t of e)r.has(n(t))&&i.push(t);return i}function ue(e,t,n,r){return T(e,t,n,r)}function de(e,t){let n=e.filter(e=>t.has(e));return F(n),n}function I(e,t){return e.version===t.version?e.createdAt>t.createdAt:e.version>t.version}function fe(e){let t=new Map;for(let n of e){let e=n.locator?.path;if(!e)continue;let r=O({type:n.type,workspaceDir:n.workspaceDir,path:e})||n.logicalId,i=t.get(r);(!i||I(n,i))&&t.set(r,n)}return[...t.values()].sort((e,t)=>e.createdAt===t.createdAt?0:e.createdAt<t.createdAt?1:-1)}var pe=[`list`,`tabs`],L=`dsc.charts.displayMode`;function me(){try{return localStorage.getItem(L)===`tabs`?`tabs`:`list`}catch{return`list`}}function he(e){try{localStorage.setItem(L,e)}catch{}}var R=[],ge=[{command:`dashboard`,hintKey:`chat.visualArtifactsEmptyHint_dashboard`},{command:`analysis`,hintKey:`chat.visualArtifactsEmptyHint_analysis`},{command:`motion`,hintKey:`chat.visualArtifactsEmptyHint_motion`}];function z({text:e,path:n}){let{t:r}=m(),i=(0,k.useCallback)(()=>{w(r(`charts.askAiPrompt`,{path:n||`—`,error:e})),h.info(r(`charts.askAiHint`))},[n,r,e]);return(0,A.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-accent-red/30 bg-accent-red/5 px-3 py-2.5 text-xs text-accent-red`,children:[(0,A.jsx)(c,{size:14,className:`mt-0.5 shrink-0`}),(0,A.jsx)(`span`,{className:`min-w-0 break-words`,children:e}),(0,A.jsxs)(`button`,{type:`button`,"data-testid":`charts-error-ask-ai`,onClick:i,title:r(`charts.askAi`),className:`ml-auto flex shrink-0 items-center gap-1 rounded-md border border-accent-red/40 px-2 py-0.5 text-[11px] font-medium text-accent-red transition-colors hover:bg-accent-red/10`,children:[(0,A.jsx)(t,{size:11,"aria-hidden":`true`}),r(`charts.askAi`)]})]})}function B({path:e,content:t,readError:n,freshness:r}){let{t:i}=m();if(n)return(0,A.jsx)(z,{text:n,path:e});let a=C(e);return a===`motion`?(0,A.jsx)(b,{path:e,content:t}):a===`dashboard`?(0,A.jsx)(E,{path:e,content:t,freshness:r}):a===`analysis`?(0,A.jsx)(D,{path:e,content:t}):a===`world`?(0,A.jsx)(y,{path:e,content:t}):a===`holo`?(0,A.jsx)(S,{path:e,content:t}):(0,A.jsxs)(`div`,{"data-testid":`charts-no-renderer`,className:`px-1 py-2 text-xs leading-relaxed text-dark-muted`,children:[i(`charts.noRenderer`),(0,A.jsx)(`span`,{className:`mt-1 block truncate font-mono text-badge text-dark-muted/70`,children:e})]})}function _e({records:e,activePath:t,onSelect:n,nameOf:r}){return(0,A.jsx)(`div`,{"data-testid":`charts-tabs`,role:`tablist`,className:`flex shrink-0 items-center gap-1 overflow-x-auto rounded-lg border border-dark-border bg-dark-surface p-1`,children:e.map(e=>{let i=e.locator.path,a=i===t;return(0,A.jsxs)(`button`,{type:`button`,role:`tab`,"data-testid":`charts-tab`,"aria-selected":a,"aria-current":a,title:`${i}\n${e.producer.sessionId}`,onClick:()=>n(i),className:g(`flex max-w-[14rem] shrink-0 items-center gap-1.5 rounded-md px-2 py-1 text-xs transition-colors`,a?`bg-accent-blue/15 text-accent-blue`:`text-dark-muted hover:bg-dark-hover hover:text-dark-text`),children:[(0,A.jsx)(x,{kind:C(i),size:13}),(0,A.jsx)(`span`,{className:`min-w-0 truncate`,children:r(e)}),(0,A.jsxs)(`span`,{className:`shrink-0 text-badge opacity-60`,children:[`v`,e.version]})]},e.logicalId)})})}function V(){let{t:e}=m(),[r,o]=(0,k.useState)(R),[c,d]=(0,k.useState)(!0),[f,p]=(0,k.useState)(null),[h,v]=(0,k.useState)(0),[y,b]=(0,k.useState)([]),[S,T]=(0,k.useState)(null),[E,D]=(0,k.useState)(null),[O,j]=(0,k.useState)(!1),[M,N]=(0,k.useState)(null),[P,F]=(0,k.useState)(null),[I,L]=(0,k.useState)(()=>ce()),[V,H]=(0,k.useState)(null),[U,ve]=(0,k.useState)(()=>me()),ye=(0,k.useCallback)(e=>{e!==U&&(ve(e),he(e),H(null),W(null))},[U]),[be,W]=(0,k.useState)(null),[xe,Se]=(0,k.useState)(!1),Ce=oe(e=>e.publishedSeq),G=(0,k.useCallback)(async t=>{t?.silent||d(!0),p(null);try{let t=await _.visualArtifacts.list();if(!t?.success)throw Error(t?.error||e(`charts.loadFailed`));o(fe(t.data?.items??R))}catch(e){p(e instanceof Error?e.message:String(e))}finally{d(!1)}},[e]),K=(0,k.useCallback)(async()=>{try{let e=await _.visualArtifacts.builtins();if(!e?.success)return;b((e.data?.items??[]).filter(e=>!e.installed).map(e=>({id:e.id,kind:e.kind,title:e.title})))}catch{}},[]),we=(0,k.useCallback)(async e=>{T(e);try{let t=await _.visualArtifacts.installBuiltin(e);if(!t?.success)throw Error(t?.error||`install failed`);await Promise.all([K(),G({silent:!0})])}catch(e){p(e instanceof Error?e.message:String(e))}finally{T(null)}},[G,K]);(0,k.useEffect)(()=>{K()},[K]),(0,k.useEffect)(()=>{G()},[G]),(0,k.useEffect)(()=>{Ce!==0&&G({silent:!0})},[Ce,G]);let q=(0,k.useMemo)(()=>le(r,I,e=>e.logicalId),[r,I]),Te=(0,k.useMemo)(()=>new Set(r.map(e=>e.logicalId)),[r]),J=(0,k.useCallback)(e=>{L(de(e,Te))},[Te]),Ee=(0,k.useCallback)(async t=>{Se(!0),W(null);try{let n=await _.visualArtifacts.remove(t);if(!n?.success)throw Error(n?.error||e(`charts.removeFailed`));o(e=>e.filter(e=>e.logicalId!==t)),J(I.filter(e=>e!==t)),H(null)}catch(e){W(e instanceof Error?e.message:String(e))}finally{Se(!1)}},[J,I,e]),De=(0,k.useCallback)((e,t)=>{let n=q.map(e=>e.logicalId),r=ue(n,e,t.id,t.side);r.join()!==n.join()&&J(r)},[J,q]),Y=ae(De,{vertical:!0}),Oe=(0,k.useCallback)((e,t)=>{let n=q.map(e=>e.logicalId),r=n.indexOf(e);if(r<0)return;let i=n[r+t];i&&J(ue(n,e,i,t<0?`before`:`after`))},[J,q]),X=(0,k.useMemo)(()=>E&&r.some(e=>e.locator.path===E)?E:q[0]?.locator.path??null,[q,r,E]),Z=(0,k.useMemo)(()=>r.find(e=>e.locator.path===X)??null,[r,X]),ke=Z?.exists===!1;(0,k.useEffect)(()=>{if(!X){N(null),F(null);return}if(ke){N(null),F(e(`charts.fileMissing`));return}let t=!1;return N(null),F(null),(async()=>{try{let n=await _.visualArtifacts.content(X);if(t)return;n.success&&n.data!==void 0&&n.data!==null?N(String(n.data)):F(n.error||e(`charts.readFailed`))}catch(e){t||F(e instanceof Error?e.message:String(e))}})(),()=>{t=!0}},[X,ke,e]),(0,k.useEffect)(()=>{if(!O)return;let e=e=>{e.key===`Escape`&&j(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[O]);let Ae=(0,k.useMemo)(()=>r.map(e=>({path:e.locator.path??``,metadata:e.metadata,version:e.version})),[r]),je=ie(Ae),Q=e=>e.locator.path?je(e.locator.path):``,Me=Z?Q(Z):null,$=Y.draggingId?r.find(e=>e.logicalId===Y.draggingId)??null:null,Ne=Z?.locator.path===void 0?null:(0,A.jsx)(B,{path:Z.locator.path,content:M,readError:P,freshness:Z.freshness});return(0,A.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,A.jsxs)(`div`,{className:`flex shrink-0 items-start gap-3 px-4 pt-3`,children:[(0,A.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`h1`,{className:`flex items-center gap-1.5 text-lg font-semibold text-dark-text`,children:[(0,A.jsx)(n,{size:16,className:`shrink-0 text-accent-blue`}),e(`charts.title`)]}),(0,A.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-dark-muted`,children:e(`charts.subtitle`)})]}),(0,A.jsxs)(`div`,{className:`mt-0.5 flex shrink-0 items-center gap-2`,children:[(0,A.jsxs)(`button`,{type:`button`,"data-testid":`charts-create-with-ai`,onClick:()=>w(e(`charts.createWithAiPrompt`)),className:`flex shrink-0 items-center gap-1 rounded-md border border-accent-blue/40 bg-accent-blue/10 px-2 py-1 text-xs font-medium text-accent-blue transition-colors hover:bg-accent-blue/20`,title:e(`charts.createWithAiHint`),children:[(0,A.jsx)(t,{size:12}),e(`charts.createWithAi`)]}),r.length>0&&(0,A.jsx)(`div`,{"data-testid":`charts-display-switch`,role:`group`,"aria-label":e(`charts.displayMode`),className:`flex items-center gap-0.5 rounded-md border border-dark-border p-0.5`,children:pe.map(t=>(0,A.jsx)(`button`,{type:`button`,"data-testid":`charts-display-${t}`,"aria-pressed":U===t,onClick:()=>ye(t),className:g(`rounded px-2 py-0.5 text-badge transition-colors`,U===t?`bg-accent-blue/15 text-accent-blue`:`text-dark-muted hover:bg-dark-hover hover:text-dark-text`),children:e(t===`list`?`charts.viewList`:`charts.viewTabs`)},t))}),(0,A.jsxs)(`button`,{type:`button`,"data-testid":`charts-refresh`,onClick:()=>{G(),v(e=>e+1)},className:`flex shrink-0 items-center gap-1 rounded-md border border-dark-border px-2 py-1 text-xs text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text`,title:e(`charts.refresh`),children:[c?(0,A.jsx)(i,{size:12,className:`animate-spin`}):(0,A.jsx)(u,{size:12}),e(`charts.refresh`)]})]})]}),f&&(0,A.jsx)(`div`,{className:`shrink-0 px-4 pt-2`,children:(0,A.jsx)(z,{text:f})}),(0,A.jsx)(se,{refreshToken:h,onApproved:()=>void G()}),(0,A.jsx)(`div`,{className:g(`flex min-h-0 flex-1 gap-3 p-4`,U===`tabs`?`flex-col`:``),children:r.length===0?(0,A.jsx)(`div`,{"data-testid":`charts-empty`,className:`flex min-h-0 flex-1 items-center justify-center rounded-lg border border-dashed border-dark-border px-6`,children:c?(0,A.jsx)(i,{size:18,className:`animate-spin text-accent-blue`}):(0,A.jsxs)(`div`,{className:`max-w-md space-y-2`,children:[(0,A.jsx)(`p`,{className:`text-xs leading-relaxed text-dark-muted`,children:e(`charts.empty`)}),(0,A.jsx)(`ul`,{className:`space-y-1`,children:ge.map(({command:t,hintKey:n})=>(0,A.jsxs)(`li`,{className:`flex items-baseline gap-1.5 text-badge text-dark-muted/80`,children:[(0,A.jsxs)(`code`,{className:`shrink-0 rounded bg-dark-hover px-1 py-px font-mono text-accent-blue`,children:[`/`,t]}),(0,A.jsx)(`span`,{className:`min-w-0`,children:e(n)})]},t))}),y.length>0&&(0,A.jsx)(`div`,{className:`flex flex-wrap gap-1.5 pt-1`,"data-testid":`charts-builtin-cards`,children:y.map(n=>(0,A.jsxs)(`button`,{type:`button`,disabled:S!==null,onClick:()=>void we(n.id),className:`inline-flex items-center gap-1 rounded border border-dark-border px-2 py-1 text-badge text-dark-muted transition-colors hover:border-accent-blue hover:text-accent-blue disabled:opacity-50`,children:[(0,A.jsx)(t,{size:11}),e(`charts.builtin.${n.id}.title`,{defaultValue:n.title})]},n.id))})]})}):(0,A.jsxs)(A.Fragment,{children:[U===`tabs`?(0,A.jsx)(_e,{records:q,activePath:X,onSelect:D,nameOf:Q}):(0,A.jsxs)(`aside`,{"data-testid":`charts-list`,className:`flex w-64 shrink-0 flex-col overflow-y-auto rounded-lg border border-dark-border bg-dark-surface`,children:[be&&(0,A.jsx)(`div`,{className:`border-b border-dark-border/60 p-1.5`,children:(0,A.jsx)(z,{text:`${e(`charts.removeFailed`)} — ${be}`})}),q.map(t=>{let n=t.locator.path,r=n===X,i=ne(t.type),a=i?e(i):t.type,o=Y.draggingId===t.logicalId,s=Y.dropTarget?.id===t.logicalId?Y.dropTarget.side:null,c=V===t.logicalId;return(0,A.jsxs)(`div`,{"data-panel-id":t.logicalId,"data-testid":`charts-item-row`,"data-dragging":o?`true`:`false`,"data-drop-side":s??void 0,onPointerDown:e=>Y.startFromCard(e,t.logicalId),onPointerMove:Y.onPointerMove,onPointerUp:Y.onPointerUp,onPointerCancel:Y.onPointerCancel,className:g(`flex items-stretch border-b border-dark-border/60 transition-colors`,r?`bg-accent-blue/10`:`hover:bg-dark-hover`,o&&`opacity-40`,s===`before`&&`shadow-[inset_0_2px_0_0_theme(colors.accent-blue)]`,s===`after`&&`shadow-[inset_0_-2px_0_0_theme(colors.accent-blue)]`),children:[(0,A.jsx)(`button`,{type:`button`,"data-testid":`charts-item-grab`,"aria-label":e(`charts.dragHandle`),title:e(`charts.dragHandle`),onPointerDown:e=>Y.startFromGrip(e,t.logicalId),onKeyDown:e=>{let n=e.key===`ArrowUp`,r=e.key===`ArrowDown`;(n||r)&&(e.preventDefault(),Oe(t.logicalId,n?-1:1))},style:{touchAction:`none`},className:`flex shrink-0 cursor-grab items-center px-1 text-dark-tertiary transition-colors hover:text-dark-text active:cursor-grabbing`,children:(0,A.jsx)(l,{size:12})}),c?(0,A.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 py-2 pe-2`,children:[(0,A.jsx)(`span`,{className:`min-w-0 flex-1 text-badge leading-snug text-amber-300`,children:e(`charts.removeConfirm`)}),(0,A.jsx)(`button`,{type:`button`,"data-testid":`charts-item-remove-confirm`,disabled:xe,onClick:()=>void Ee(t.logicalId),className:`shrink-0 rounded border border-accent-red/40 px-1.5 py-0.5 text-badge text-accent-red transition-colors hover:bg-accent-red/10 disabled:opacity-50`,children:e(`charts.remove`)}),(0,A.jsx)(`button`,{type:`button`,"data-testid":`charts-item-remove-cancel`,onClick:()=>H(null),className:`shrink-0 rounded border border-dark-border px-1.5 py-0.5 text-badge text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text`,children:e(`common.cancel`)})]}):(0,A.jsxs)(A.Fragment,{children:[(0,A.jsxs)(`button`,{type:`button`,"data-testid":`charts-item`,"aria-current":r,onClick:()=>D(n),title:`${n}\n${t.producer.sessionId}`,className:`flex min-w-0 flex-1 items-center gap-2 py-2 pe-1 text-start`,children:[(0,A.jsx)(x,{kind:C(n),size:14}),(0,A.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,A.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,A.jsx)(`span`,{"data-testid":`charts-item-name`,className:g(`truncate text-xs`,r?`text-accent-blue`:`text-dark-text`),children:Q(t)}),(0,A.jsxs)(`span`,{className:`shrink-0 rounded bg-dark-hover px-1 py-px text-badge text-dark-muted`,children:[a,` v`,t.version]})]}),(0,A.jsxs)(`span`,{className:`mt-0.5 block truncate font-mono text-badge text-dark-muted/70`,children:[re(n),` · `,te(t.createdAt,Date.now(),e)]})]})]}),(0,A.jsx)(`button`,{type:`button`,"data-testid":`charts-item-remove`,onClick:()=>{W(null),H(t.logicalId)},title:e(`charts.removeHint`),"aria-label":e(`charts.removeHint`),className:`flex shrink-0 items-center px-1.5 text-dark-tertiary transition-colors hover:text-accent-red`,children:(0,A.jsx)(ee,{size:12})})]})]},t.logicalId)})]}),(0,A.jsxs)(`section`,{"data-testid":`charts-canvas`,className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-lg border border-dark-border bg-dark-surface`,children:[(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-dark-border px-3 py-1.5`,children:[(0,A.jsx)(`span`,{"data-testid":`charts-canvas-name`,className:`min-w-0 flex-1 truncate text-xs text-dark-text`,title:X??``,children:Me??X??``}),(0,A.jsx)(`button`,{type:`button`,"data-testid":`charts-fullscreen-toggle`,onClick:()=>j(!0),className:`shrink-0 rounded p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text`,title:e(`charts.fullscreen`),"aria-label":e(`charts.fullscreen`),children:(0,A.jsx)(s,{size:13})})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:Ne})]})]})}),$&&(0,A.jsx)(`div`,{ref:Y.ghost.setElement,"data-testid":`charts-drag-ghost`,"aria-hidden":!0,className:`pointer-events-none fixed left-0 top-0 z-50 w-56 will-change-transform`,children:(0,A.jsxs)(`div`,{className:g(`flex w-full rotate-1 items-center gap-2 overflow-hidden rounded-lg border bg-dark-surface/95 px-2 py-1.5 shadow-pop`,Y.dropTarget?`border-accent-blue/70 ring-1 ring-accent-blue/30`:`border-dark-border`),children:[(0,A.jsx)(l,{size:12,className:`shrink-0 text-dark-muted`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-dark-text`,children:Q($)})]})}),O&&Z?.locator.path!==void 0&&(0,A.jsxs)(`div`,{"data-testid":`charts-fullscreen`,className:`fixed inset-0 z-50 flex flex-col bg-dark-bg`,children:[(0,A.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-dark-border px-4 py-2`,children:[(0,A.jsx)(n,{size:14,className:`shrink-0 text-accent-blue`}),(0,A.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-dark-text`,title:Z.locator.path,children:Me??Z.locator.path}),(0,A.jsxs)(`button`,{type:`button`,onClick:()=>j(!1),className:`flex shrink-0 items-center gap-1 rounded-md border border-dark-border px-2 py-1 text-xs text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text`,title:e(`charts.exitFullscreen`),children:[(0,A.jsx)(a,{size:12}),e(`charts.exitFullscreen`)]})]}),(0,A.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,A.jsx)(B,{path:Z.locator.path,content:M,readError:P,freshness:Z.freshness})})]})]})}function H(){return(0,A.jsx)(`div`,{className:`flex h-full min-h-0 flex-col`,children:(0,A.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,A.jsx)(V,{})})})}export{H as ChartsView};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{$ as t,Dr as n,Er as r,Jn as i,Or as ee,Y as a,dn as o,it as s,kn as c,m as l,ni as u,xn as te,yn as d}from"./icons-B8Ngx6rM.js";import{t as ne}from"./react-vendor-CXI113IS.js";import{t as re}from"./useTranslation-gGKZZfux.js";import{i as f,r as p}from"./Button-D-g7PgYh.js";import{t as m}from"./api-ZQf0Ys8y.js";import{I as h}from"./markdown-Cps-36Z5.js";import{t as g}from"./useConfirm-CQjBnYuP.js";import{Ct as _}from"./index-STsyoFCk.js";var v=e(u(),1),y=h();function b(e){return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,json:`json`,xml:`xml`,html:`html`,css:`css`,scss:`scss`,md:`markdown`,yaml:`yaml`,yml:`yaml`,toml:`toml`,sql:`sql`,sh:`shell`,bat:`bat`,ps1:`powershell`,dockerfile:`dockerfile`,properties:`properties`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,cs:`csharp`,vue:`html`,svelte:`html`,svg:`xml`}[e.split(`.`).pop()?.toLowerCase()||``]||`plaintext`}function x(){let{t:e}=re(),[u,h]=g(),[x,S]=(0,v.useState)([]),[C,w]=(0,v.useState)(null),[T,E]=(0,v.useState)(``),[ie,D]=(0,v.useState)(``),[ae,O]=(0,v.useState)(!1),[k,oe]=(0,v.useState)(``),[A,j]=(0,v.useState)(!1),[M,N]=(0,v.useState)(!1),[P,F]=(0,v.useState)(!1),[I,se]=(0,v.useState)(``),L=(0,v.useRef)(null),R=_(e=>e.status?.branch),z=_(e=>e.status?.available),[B,V]=(0,v.useState)(0),H=(0,v.useRef)(void 0);(0,v.useEffect)(()=>{C?(O(!0),m.files.read(C).then(t=>{if(t.success&&t.data){let e=typeof t.data==`string`?t.data:JSON.stringify(t.data);E(e),D(e)}else f.error(t.error||e(`fileTree.readFail`))}).catch(()=>f.error(e(`fileTree.readFail`))).finally(()=>O(!1))):(E(``),D(``))},[C,B]);let U=async e=>{j(!0);try{let t=await m.files.list(e);t.success&&Array.isArray(t.data)&&S(t.data.map(e=>({...e,expanded:!1})))}finally{j(!1)}};(0,v.useEffect)(()=>{H.current===void 0?H.current=R:R!==H.current&&(H.current=R,V(e=>e+1),U())},[R]);let W=async e=>{if(e.type===`directory`)try{let t=await m.files.list(e.path);if(t.success&&Array.isArray(t.data)){let n=t.data.map(e=>({...e,expanded:!1}));S(t=>G(t,e.id,n))}}catch{}},G=(e,t,n)=>e.map(e=>e.id===t?{...e,children:n,expanded:!0}:e.children?{...e,children:G(e.children,t,n)}:e);(0,v.useEffect)(()=>{U()},[]);let ce=e=>{let t=q(x,e);t&&t.type===`directory`&&!t.children?W(t):S(t=>K(t,e))},K=(e,t)=>e.map(e=>e.id===t&&e.type===`directory`?{...e,expanded:!e.expanded}:e.children?{...e,children:K(e.children,t)}:e),q=(e,t)=>{for(let n of e){if(n.id===t)return n;if(n.children){let e=q(n.children,t);if(e)return e}}return null},J=(e,t)=>t?e.reduce((e,n)=>{if(n.name.toLowerCase().includes(t.toLowerCase()))e.push(n);else if(n.children){let r=J(n.children,t);r.length>0&&e.push({...n,children:r,expanded:!0})}return e},[]):e,le=(0,v.useCallback)(async()=>{if(C){N(!0);try{let t=await m.files.update(C,T);t.success?(D(T),f.success(e(`fileTree.saved`))):f.error(t.error||e(`fileTree.saveFail`))}catch{f.error(e(`fileTree.saveFail`))}finally{N(!1)}}},[C,T,e]),Y=()=>{w(null),E(``),D(``)},X=(0,v.useCallback)(async t=>{let n=await m.files.download(t);n.success?f.success(e(`fileTree.downloadStarted`)):f.error(n.error||e(`fileTree.downloadFail`))},[e]),ue=()=>L.current?.click(),de=(0,v.useCallback)(async t=>{if(!t||t.length===0)return;let n=I||(C?C.replace(/[\\/][^\\/]+$/,``):``);F(!0);let r=0,i=0;for(let e of Array.from(t)){let t=n?`${n}/${e.name}`:e.name;(await m.files.upload(e,t)).success?r++:i++}F(!1),r>0&&f.success(e(`fileTree.uploadedCount`,{count:r})),i>0&&f.error(e(`fileTree.uploadFailedCount`,{count:i})),await U()},[I,C,e]),Z=T!==ie,Q=async()=>!Z||h({message:e(`fileTree.discardConfirm`,{file:C||``}),variant:`danger`}),fe=async()=>{await Q()&&Y()},$=(t,n=0)=>{let a=t.type===`directory`,o=C===t.path,s=I===t.path;return(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`div`,{className:`group flex items-center gap-1 px-2 py-0.5 cursor-pointer rounded text-xs transition-colors max-md:w-max max-md:min-w-full ${o?`bg-accent-blue/20 text-accent-blue`:s?`bg-accent-blue/10`:`hover:bg-dark-hover`}`,style:{paddingLeft:`${n*14+6}px`},onClick:()=>a?(se(t.path),ce(t.id)):w(t.path),title:a?e(`fileTree.setUploadDirHint`):t.path,children:[a&&(0,y.jsx)(`span`,{className:`text-dark-muted shrink-0`,children:t.expanded?(0,y.jsx)(ee,{size:12}):(0,y.jsx)(r,{size:12})}),a?(0,y.jsx)(te,{size:12,className:`text-accent-yellow shrink-0`}):(0,y.jsx)(`span`,{className:`w-3`}),(0,y.jsx)(`span`,{className:`truncate flex-1`,children:t.name}),!a&&(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),X(t.path)},className:`opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-dark-border text-dark-muted hover:text-dark-text shrink-0 max-md:opacity-100`,title:e(`fileTree.download`),children:(0,y.jsx)(i,{size:11})})]}),a&&t.expanded&&t.children?.map(e=>$(e,n+1))]},t.id)},pe=k?J(x,k):x;return(0,y.jsxs)(`div`,{className:`flex-1 flex overflow-hidden`,children:[u,(0,y.jsxs)(`div`,{className:p(`flex flex-col overflow-hidden flex-1 min-h-0`,C&&`hidden`),children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-dark-border`,children:[z&&R&&(0,y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 text-meta text-dark-muted`,title:R,children:[(0,y.jsx)(d,{size:12,className:`shrink-0 text-accent-blue/80`,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:`truncate font-mono`,children:R})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-0.5 ms-auto`,children:[(0,y.jsx)(`button`,{onClick:ue,disabled:P,className:`p-1 rounded hover:bg-dark-hover disabled:opacity-50`,title:I?e(`fileTree.uploadTo`,{dir:I}):e(`fileTree.uploadToRoot`),children:(0,y.jsx)(l,{size:12,className:P?`animate-pulse`:``})}),(0,y.jsx)(`button`,{onClick:()=>U(),disabled:A,className:`p-1 rounded hover:bg-dark-hover`,title:e(`fileTree.refresh`),children:(0,y.jsx)(s,{size:12,className:A?`animate-spin`:``})}),(0,y.jsx)(`button`,{onClick:()=>{(async()=>{await Q()&&(S(x.map(e=>({...e,expanded:!1}))),Y())})()},className:`p-1 rounded hover:bg-dark-hover`,title:e(`fileTree.collapse`),children:(0,y.jsx)(o,{size:12})})]})]}),(0,y.jsx)(`div`,{className:`p-1.5 border-b border-dark-border`,children:(0,y.jsxs)(`div`,{className:`relative`,children:[(0,y.jsx)(a,{size:12,className:`absolute start-2 top-1/2 -translate-y-1/2 text-dark-muted`}),(0,y.jsx)(`input`,{type:`text`,value:k,onChange:e=>oe(e.target.value),placeholder:e(`fileTree.searchPlaceholder`),className:`w-full ps-6 pe-2 py-1 text-xs bg-dark-bg border border-dark-border rounded focus:border-accent-blue focus:outline-none`})]})}),(0,y.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar py-1 max-md:overflow-x-auto`,children:pe.map(e=>$(e))}),(0,y.jsx)(`input`,{ref:L,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{de(e.target.files),e.currentTarget.value=``}})]}),(0,y.jsx)(`div`,{className:p(`flex-1 flex flex-col min-w-0 bg-dark-bg`,!C&&`hidden`),children:C?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-dark-border bg-dark-surface max-md:gap-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs min-w-0`,children:[(0,y.jsx)(`button`,{onClick:()=>void fe(),className:`p-0.5 -ms-1 rounded hover:bg-dark-hover text-dark-muted hover:text-dark-text shrink-0`,title:e(`fileTree.backToList`),"aria-label":e(`fileTree.backToList`),"data-testid":`file-tree-back`,children:(0,y.jsx)(n,{size:13})}),(0,y.jsx)(c,{size:12,className:`text-dark-muted shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:C}),Z&&(0,y.jsxs)(`span`,{className:`text-accent-yellow text-badge shrink-0`,children:[`● `,e(`fileTree.modified`)]})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,y.jsxs)(`button`,{onClick:le,disabled:!Z||M,className:`px-2 py-0.5 text-badge rounded flex items-center gap-1 transition-colors ${Z?`bg-accent-green text-accent-fg hover:opacity-90`:`bg-dark-border text-dark-muted cursor-not-allowed`}`,children:[(0,y.jsx)(t,{size:10}),e(M?`fileTree.saving`:`fileTree.save`)]}),(0,y.jsx)(`button`,{onClick:()=>void X(C),className:`p-1 rounded hover:bg-dark-hover`,title:e(`fileTree.download`),children:(0,y.jsx)(i,{size:12})})]})]}),(0,y.jsx)(`div`,{className:`flex-1 min-h-0`,children:ae?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`div`,{className:`w-4 h-4 border-2 border-accent-blue border-t-transparent rounded-full animate-spin`})}):(0,y.jsx)(ne,{language:b(C),value:T,onChange:e=>E(e||``),theme:`vs-dark`,options:{fontSize:13,fontFamily:`"Cascadia Code", "Fira Code", Consolas, monospace`,minimap:{enabled:!0,renderCharacters:!1,maxColumn:80,showSlider:`mouseover`},lineNumbers:`on`,scrollBeyondLastLine:!1,wordWrap:`on`,automaticLayout:!0,tabSize:2}})})]}):(0,y.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(c,{size:32,className:`text-dark-muted mx-auto mb-2`}),(0,y.jsx)(`p`,{className:`text-sm text-dark-muted`,children:e(`fileTree.selectFileHint`)})]})})})]})}export{x as FileTreeView};
|