@aidotnet/server-darwin-arm64 0.9.6 → 0.9.8
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/bin/astra-server +2 -2
- package/bin/wwwroot/assets/{ClientsPage-DEetiYfc.js → ClientsPage-CMvzWWAq.js} +2 -2
- package/bin/wwwroot/assets/{KeyPage-cq7HprCR.js → KeyPage-C8QfP545.js} +1 -1
- package/bin/wwwroot/assets/{ModelDetailPage-Uj6p-r8V.js → ModelDetailPage-Dj3Fuga6.js} +1 -1
- package/bin/wwwroot/assets/{ModelsPage-B-l5oEGF.js → ModelsPage-DIYCYGb2.js} +1 -1
- package/bin/wwwroot/assets/{PluginsPage-BH9KjyfC.js → PluginsPage-B2nac94b.js} +1 -1
- package/bin/wwwroot/assets/{PrivacyPage-C5XhVKZd.js → PrivacyPage-CeRqlQGU.js} +1 -1
- package/bin/wwwroot/assets/{ProviderDetailPage-uLPHWm2i.js → ProviderDetailPage-DWy8CIbx.js} +1 -1
- package/bin/wwwroot/assets/{ProvidersPage-CNU_ji4e.js → ProvidersPage-CeisTEUC.js} +1 -1
- package/bin/wwwroot/assets/{SettingsPage-B3tbYdLW.js → SettingsPage-Bcv3aAmF.js} +2 -2
- package/bin/wwwroot/assets/{TokenDetailPage-BVyb_-ev.js → TokenDetailPage-B9WJQ1HP.js} +1 -1
- package/bin/wwwroot/assets/{TokenPoolEditor-7LX143SO.js → TokenPoolEditor-D8mQHyNt.js} +1 -1
- package/bin/wwwroot/assets/TokensPage-Cx1hPs0r.js +1 -0
- package/bin/wwwroot/assets/{TracesPage-C9mYB_7E.js → TracesPage-Ckw0m9u0.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelPage-NIkRrLCt.js → TrayPanelPage-BfD_xXkg.js} +1 -1
- package/bin/wwwroot/assets/{TrayPanelView-BpQQa0qi.js → TrayPanelView-daUwEIRH.js} +1 -1
- package/bin/wwwroot/assets/{alert-CN1yWco4.js → alert-BzjF81CS.js} +3 -3
- package/bin/wwwroot/assets/{arrow-down-DP0xP3tk.js → arrow-down-BjT6LDhw.js} +1 -1
- package/bin/wwwroot/assets/{arrow-left-UUQiUGQ1.js → arrow-left-Bv8IR_At.js} +1 -1
- package/bin/wwwroot/assets/{checkbox-BEWRhO5r.js → checkbox-DQpzihMp.js} +1 -1
- package/bin/wwwroot/assets/{cloud-download-DebyBXx2.js → cloud-download-B7vzhwxM.js} +1 -1
- package/bin/wwwroot/assets/{confirm-morph-DwiVsert.js → confirm-morph-BOdW6fKN.js} +1 -1
- package/bin/wwwroot/assets/{download-C4--ZCHf.js → download-CI3oqkmw.js} +1 -1
- package/bin/wwwroot/assets/{ellipsis-D250KISp.js → ellipsis-Br3iFNj9.js} +1 -1
- package/bin/wwwroot/assets/{external-link-Bnshhxip.js → external-link-LUcufY2s.js} +1 -1
- package/bin/wwwroot/assets/{folder-open-BzVuhS53.js → folder-open-rO9o554n.js} +1 -1
- package/bin/wwwroot/assets/{index-CBrXkG99.js → index-D7HIE1TG.js} +3 -3
- package/bin/wwwroot/assets/{log-out-DEZofPIg.js → log-out-Ggrqw-Tp.js} +1 -1
- package/bin/wwwroot/assets/minus-2zK3DUtq.js +1 -0
- package/bin/wwwroot/assets/overlays-8ByMRpma.js +41 -0
- package/bin/wwwroot/assets/{pencil-DuD1bQje.js → pencil-o6T1_skE.js} +1 -1
- package/bin/wwwroot/assets/{power-LE8gLJKc.js → power-BJvJ4uzr.js} +1 -1
- package/bin/wwwroot/assets/{radio-cards-D1yOuSfh.js → radio-cards-CWiI0xhT.js} +1 -1
- package/bin/wwwroot/assets/{rotate-ccw-Cx9vNOkF.js → rotate-ccw-CqwU1cME.js} +1 -1
- package/bin/wwwroot/assets/{sortable.esm-B0eMzUNN.js → sortable.esm-BhxNcP2n.js} +1 -1
- package/bin/wwwroot/index.html +3 -3
- package/package.json +1 -1
- package/bin/wwwroot/assets/TokensPage-vRrXvqkK.js +0 -1
- package/bin/wwwroot/assets/minus-BAoIEc33.js +0 -1
- package/bin/wwwroot/assets/overlays-D2pWmtov.js +0 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Ai as e,Ca as t,E as n,Ea as r,Fi as i,J as a,Jn as o,Kt as s,Mi as c,Pi as l,Sa as u,Xn as d,Yn as f,Zn as p,_ as m,_t as h,b as g,c as _,ct as v,d as y,g as b,h as x,it as S,ji as C,ki as w,l as T,m as E,n as D,ni as O,ot as k,q as ee,r as A,t as te,u as j,v as M,vt as N,y as P}from"./alert-CN1yWco4.js";import{a as F,i as ne,o as I,r as L}from"./overlays-D2pWmtov.js";import{C as re,D as R,E as z,H as ie,L as ae,M as oe,N as se,P as B,Q as ce,R as le,T as V,V as ue,Z as de,_ as fe,c as pe,et as me,h as he,r as ge,tt as H,w as U}from"./index-CBrXkG99.js";var _e={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};_e.node;var ve=N(_e),W=r(t(),1),G={toolbar:`_toolbar_1p5c5_1`,leading:`_leading_1p5c5_2`,frame:`_frame_1p5c5_4`,chips:`_chips_1p5c5_5`,slot:`_slot_1p5c5_7`,chip:`_chip_1p5c5_5`,chipLabel:`_chipLabel_1p5c5_10`,value:`_value_1p5c5_11`,separator:`_separator_1p5c5_12`,morphText:`_morphText_1p5c5_13`,morphValue:`_morphValue_1p5c5_14`,measure:`_measure_1p5c5_15`,empty:`_empty_1p5c5_18`,actions:`_actions_1p5c5_19`,clear:`_clear_1p5c5_20`,clearText:`_clearText_1p5c5_21`,srOnly:`_srOnly_1p5c5_23`,menu:`_menu_1p5c5_27`,trigger:`_trigger_1p5c5_29`,face:`_face_1p5c5_31`,surface:`_surface_1p5c5_34`,panel:`_panel_1p5c5_42`,head:`_head_1p5c5_45`,back:`_back_1p5c5_47`,title:`_title_1p5c5_49`,titleText:`_titleText_1p5c5_50`,stage:`_stage_1p5c5_51`,step:`_step_1p5c5_52`,list:`_list_1p5c5_53`,highlight:`_highlight_1p5c5_54`,item:`_item_1p5c5_55`,itemIcon:`_itemIcon_1p5c5_57`,itemLabel:`_itemLabel_1p5c5_58`,itemMeta:`_itemMeta_1p5c5_59`,metaValue:`_metaValue_1p5c5_60`,hint:`_hint_1p5c5_61`,check:`_check_1p5c5_62`,noOptions:`_noOptions_1p5c5_64`},K=u(),q={duration:n.duration.standard,ease:[...n.ease.enter]},ye={duration:n.duration.instant,ease:[...n.ease.standard]},J={duration:0},be={duration:n.duration.instant,ease:[...n.ease.standard]},Y=e=>`blur(${e}px)`,xe=e=>Math.min(1,Math.max(0,e)),Se=e=>typeof e==`string`?{value:e}:e,Ce=e=>e.label??e.value,we=e=>({initial:e?{opacity:0}:{opacity:0,y:`0.3em`,filter:Y(n.blur.soft)},animate:{opacity:1,y:0,filter:Y(0)},exit:e?{opacity:0,transition:J}:{opacity:0,y:`-0.3em`,filter:Y(n.blur.subtle),transition:ye},transition:e?be:q});function Te({text:t}){let r=C()??!1,i=(0,W.useRef)(null),a=c(`auto`);return(0,W.useLayoutEffect)(()=>{let t=i.current;if(!t||typeof ResizeObserver>`u`)return;let o=null,s=new ResizeObserver(([i])=>{let s=Math.ceil(i.borderBoxSize?.[0]?.inlineSize??t.offsetWidth),c=o!==null&&o!==t.textContent;o=t.textContent,c&&!r?e(a,s,n.spring.morph):a.jump(s)});return s.observe(t),()=>s.disconnect()},[r,a]),(0,K.jsxs)(w.span,{className:G.morphText,style:{width:a},children:[(0,K.jsx)(`span`,{ref:i,className:G.measure,"aria-hidden":`true`,children:t}),(0,K.jsx)(l,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(w.span,{className:G.morphValue,...we(r),children:t},t)})]})}function Ee(t,r,i){let a=c(`auto`);return(0,W.useLayoutEffect)(()=>{let o=t.current;if(!o||typeof ResizeObserver>`u`)return;let s=!1,c=new ResizeObserver(()=>{let t=o.offsetHeight;if(!s||i||performance.now()>r.current){s=!0,a.jump(t);return}e(a,t,n.spring.smooth)});return c.observe(o),()=>c.disconnect()},[r,a,t,i]),a}function De(t,r,i){(0,W.useLayoutEffect)(()=>{let a=t.current;if(!a||typeof ResizeObserver>`u`)return;let o=new Map,s=()=>{let t=performance.now();for(let s of Array.from(a.children)){let a=s.offsetLeft,c=s.offsetTop,l=o.get(s);if(!l){o.set(s,{x:a,y:c,dx:0,dy:0});continue}let u=l.x-a,d=l.y-c;if(l.x=a,l.y=c,i||t>r.current||Math.abs(d)<1&&Math.abs(u)<40)continue;l.stop?.();let f=l.dx+u,p=l.dy+d,m=e=>{l.dx=f*(1-e),l.dy=p*(1-e),s.style.translate=e>=1?``:`${l.dx}px ${l.dy}px`};m(0),l.stop=e(0,1,{...n.spring.smooth,onUpdate:m,onComplete:()=>m(1)}).stop}for(let e of o.keys())e.parentElement!==a&&o.delete(e)},c=new ResizeObserver(s),l=()=>{for(let e of Array.from(a.children))c.observe(e)},u=new MutationObserver(()=>{l(),s()});return c.observe(a),l(),u.observe(a,{childList:!0}),()=>{c.disconnect(),u.disconnect();for(let e of o.values())e.stop?.()}},[r,t,i])}var X=e=>e.valueLabel??e.value,Z=e=>X(e)?`${e.label}: ${X(e)}`:e.label,Oe={empty:`No filters applied`,clearAll:`Clear all`,back:`Back to fields`,noOptions:`No options available`,cleared:`All filters cleared`,remove:e=>`Remove ${Z(e)}`,added:e=>`Added ${Z(e)}`,changed:e=>`Changed ${Z(e)}`,removed:e=>`Removed ${Z(e)}`};function ke(e,t,n){let r=e.filter(e=>!t.some(t=>t.id===e.id));if(!t.length&&r.length>1)return n.cleared;let i=t.filter(t=>!e.some(e=>e.id===t.id)),a=t.filter(t=>e.some(e=>e.id===t.id&&e.value!==t.value));return[...i.map(n.added),...a.map(n.changed),...r.map(n.removed)].join(`. `)}function Ae({rows:e,labelledBy:t,onChoose:r,onBack:a,onLeave:o,radio:s,emptyMessage:c}){let l=C()??!1,u=i(),d=(0,W.useRef)(null),f=(0,W.useRef)(!1),p=(0,W.useRef)({text:``,at:0}),[m,h]=(0,W.useState)(()=>Math.max(0,e.findIndex(e=>e.checked))),[g,_]=(0,W.useState)(null),v=()=>Array.from(d.current?.querySelectorAll(`[data-row]`)??[]),y=e=>{let t=d.current;e&&t&&(e.focus({preventScroll:!0}),e.offsetTop<t.scrollTop?t.scrollTop=e.offsetTop:e.offsetTop+e.offsetHeight>t.scrollTop+t.clientHeight&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight))};function b(t){let n=v(),i=n.indexOf(document.activeElement),o=e=>{t.preventDefault(),f.current=!1,y(n[e])};if(t.key===`ArrowDown`)return o(i<0?0:(i+1)%n.length);if(t.key===`ArrowUp`)return o(i<0?n.length-1:(i-1+n.length)%n.length);if(t.key===`Home`)return o(0);if(t.key===`End`)return o(n.length-1);if(t.key===`ArrowRight`&&i>=0&&e[i]?.drill){t.preventDefault(),r(e[i],!0);return}if(t.key===`ArrowLeft`&&a){t.preventDefault(),a(!0);return}if(t.key.length===1&&/\S/.test(t.key)&&!t.metaKey&&!t.ctrlKey&&!t.altKey){let e=performance.now();p.current={text:e-p.current.at<700?p.current.text+t.key.toLowerCase():t.key.toLowerCase(),at:e};let r=[...n.slice(i+(p.current.text.length>1?0:1)),...n.slice(0,i+(p.current.text.length>1?0:1))].find(e=>(e.dataset.text??``).toLowerCase().startsWith(p.current.text));r&&o(n.indexOf(r))}}function x(e){let t=e.target.closest(`[data-row]`);if(!t)return;h(v().indexOf(t));let n=f.current&&!l,r=!f.current&&t.matches(`:focus-visible`);_(e=>({top:t.offsetTop,height:t.offsetHeight,glide:n&&!!e?.shown,ring:r,shown:!0}))}function S(e){d.current?.contains(e.relatedTarget)||_(e=>e&&{...e,glide:!1,ring:!1,shown:!1})}return(0,K.jsxs)(`div`,{ref:d,className:G.list,role:`menu`,"aria-labelledby":t,"data-current":u?``:void 0,onKeyDown:b,onFocus:x,onBlur:S,onPointerLeave:()=>{f.current&&d.current?.contains(document.activeElement)&&o()},children:[(0,K.jsx)(w.span,{className:G.highlight,"data-ring":g?.ring||void 0,"aria-hidden":`true`,initial:!1,animate:g?{y:g.top,height:g.height,opacity:+!!g.shown}:{opacity:0},transition:{default:g?.glide?n.spring.snappy:J,opacity:{duration:l?0:.08}}}),e.length===0?(0,K.jsx)(`p`,{className:G.noOptions,children:c}):null,e.map((e,t)=>(0,K.jsxs)(`button`,{type:`button`,className:G.item,role:s?`menuitemradio`:`menuitem`,"aria-checked":s?!!e.checked:void 0,tabIndex:t===m?0:-1,"data-row":e.key,"data-text":e.label,onPointerMove:e=>{f.current=!0,document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})},onClick:t=>r(e,t.detail===0),children:[e.icon?(0,K.jsx)(`span`,{className:G.itemIcon,"aria-hidden":`true`,children:e.icon}):null,(0,K.jsx)(`span`,{className:G.itemLabel,children:e.label}),e.meta?(0,K.jsx)(`span`,{className:G.itemMeta,children:e.meta}):null]},e.key))]})}function je(e){let t={left:0,top:0,right:document.documentElement.clientWidth,bottom:window.innerHeight};for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement){let e=getComputedStyle(n);if(e.overflowX===`visible`&&e.overflowY===`visible`)continue;let r=n.getBoundingClientRect();e.overflowX!==`visible`&&(t.left=Math.max(t.left,r.left),t.right=Math.min(t.right,r.right)),e.overflowY!==`visible`&&(t.top=Math.max(t.top,r.top),t.bottom=Math.min(t.bottom,r.bottom))}return t}function Me({fields:t,onSelect:r,active:i=[],label:a=`Add filter`,align:o=`end`,messages:s}){let u={...Oe,...s},d=C()??!1,f=(0,W.useId)(),p=`${f}panel`,m=`${f}title`,g=(0,W.useRef)(null),_=(0,W.useRef)(null),v=(0,W.useRef)(null),y=(0,W.useRef)(`closed`),b=(0,W.useRef)(0),x=(0,W.useRef)(null),[S,T]=(0,W.useState)(`closed`),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(1),[ee,A]=(0,W.useState)(!1),[te,j]=(0,W.useState)(`100% 0`),M=c(`100%`),N=c(`100%`),P=c(0),F=c(0),ne=H(()=>F.get()-P.get()),I=c(0),L=c(0),re=H(()=>{let e=M.get(),t=I.get(),n=L.get();return typeof e==`number`?n>t?xe((e-t)/(n-t)):1:0}),R=H(()=>xe(re.get()/.35)),z=H(()=>xe((re.get()-.4)/.5)),ae={opacity:H(()=>1-R.get()),scale:H(()=>1-R.get()*.04),filter:H(()=>R.get()?Y(R.get()*n.blur.subtle):`none`)},oe={opacity:z,transformOrigin:te,scale:H(()=>.96+z.get()*.04),y:H(()=>(1-z.get())*(ee?-6:6)),filter:H(()=>z.get()===1?`none`:Y((1-z.get())*n.blur.soft))},se=S===`open`,B=t.find(e=>e.id===E)??null,ce=(0,W.useCallback)(t=>{let r=_.current,i=v.current;if(!r||!i)return;let a=r.getBoundingClientRect(),s=i.offsetWidth+2,c=i.offsetHeight+2,l=je(g.current??r),u=l.left+16-a.left,f=l.right-16-a.left-s,p=a.width-s,m=o===`end`?p>=u?p:0<=f?0:p:0<=f?0:p>=u?p:0;m=Math.round(Math.min(Math.max(m,u),Math.max(u,f)));let h=l.bottom-a.top,S=a.bottom-l.top,C=h<c+16&&S>h;y.current===`closed`&&(M.jump(a.width),N.jump(a.height),P.jump(0)),F.jump(m),I.jump(a.width),L.jump(s),y.current=`open`,b.current+=1,x.current=t,T(`open`),A(C),D(null),k(-1),j(`${Math.round(a.width/2-m)}px ${C?`100%`:`0`}`);let w=d?J:n.spring.morph;e(P,m,w),e(M,s,w),e(N,c,w)},[o,I,N,P,d,F,L,M]),V=(0,W.useCallback)(t=>{let r=_.current;if(y.current!==`open`||!r)return;y.current=`closing`;let i=b.current+=1;T(`closing`),t&&r.focus({preventScroll:!0,focusVisible:t===`keyboard`});let a=d?J:n.spring.snappy;e(P,0,a);let o=r.getBoundingClientRect();e(N,o.height,a),e(M,o.width,{...a,onComplete:()=>{i===b.current&&(y.current=`closed`,M.jump(`100%`),N.jump(`100%`),T(`closed`),D(null))}})},[N,P,d,M]);(0,W.useLayoutEffect)(()=>{let t=v.current;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{y.current===`open`&&e(N,t.offsetHeight+2,d?J:n.spring.smooth)});return r.observe(t),()=>r.disconnect()},[N,d]),(0,W.useLayoutEffect)(()=>{let e=x.current,t=v.current;if(!e||!t||S!==`open`)return;if(x.current=null,e===`panel`){t.focus({preventScroll:!0});return}let n=Array.from(t.querySelectorAll(`[data-current] [data-row]`));(e===`first`?n[0]:e===`last`?n.at(-1):e===`checked`?n.find(e=>e.getAttribute(`aria-checked`)===`true`)??n[0]:n.find(t=>t.dataset.row===e.key)??n[0])?.focus({preventScroll:!0})},[S,E]),(0,W.useEffect)(()=>{if(S!==`open`)return;let e=e=>{let t=g.current,n=e.target;!t||n&&t.contains(n)||(V(!1),n?.closest?.(`button, a[href], input, select, textarea, [tabindex], [contenteditable]`)||window.setTimeout(()=>{let e=document.activeElement;(!e||e===document.body||t.contains(e))&&_.current?.focus({preventScroll:!0,focusVisible:!1})},0))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[V,S]);function de(e){if(e.defaultPrevented)return;let t=Array.from(v.current?.querySelectorAll(`[data-current] [data-row]`)??[]);(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),(e.key===`ArrowDown`?t[0]:t.at(-1))?.focus({preventScroll:!0})),e.key===`ArrowLeft`&&B&&(e.preventDefault(),fe(!0))}function fe(e){B&&(x.current=e?{key:B.id}:`panel`,k(-1),D(null))}function pe(e,t){x.current=t?`checked`:`panel`,k(1),D(e.key)}function me(e,t){B&&(r({id:B.id,label:B.label,value:e.key,valueLabel:e.label},B),V(t?`keyboard`:`pointer`))}let he=e=>i.find(t=>t.id===e.id),ge=t.map(e=>({key:e.id,label:e.label,icon:e.icon,drill:!0,meta:(0,K.jsxs)(K.Fragment,{children:[he(e)?(0,K.jsx)(`span`,{className:G.metaValue,children:X(he(e))}):null,(0,K.jsx)(ue,{size:15,strokeWidth:1.8,"aria-hidden":`true`})]})})),U=B?B.options.map(Se).map(e=>{let t=Ce(e),n=he(B)?.value===e.value;return{key:e.value,label:t,icon:e.icon,checked:n,meta:e.hint!=null||n?(0,K.jsxs)(K.Fragment,{children:[e.hint==null?null:(0,K.jsx)(`span`,{className:G.hint,children:e.hint}),(0,K.jsx)(`span`,{className:G.check,"data-on":n||void 0,children:(0,K.jsx)(h,{size:15,strokeWidth:2,"aria-hidden":`true`})})]}):null}}):[],_e={enter:e=>d?{opacity:0}:{opacity:0,x:e*18,filter:Y(n.blur.soft)},center:{opacity:1,x:0,filter:Y(0),transition:d?be:{...q,x:n.spring.smooth}},exit:e=>d?{opacity:0,transition:J}:{opacity:0,x:e*-18,filter:Y(n.blur.subtle),transition:ye}};return(0,K.jsxs)(`div`,{ref:g,className:G.menu,"data-state":S,"data-y":ee?`up`:`down`,onKeyDown:e=>{e.key===`Escape`&&y.current===`open`&&(e.preventDefault(),e.stopPropagation(),V(`keyboard`))},onBlur:e=>{let t=e.relatedTarget;y.current===`open`&&t&&!g.current?.contains(t)&&V(!1)},children:[(0,K.jsx)(`button`,{ref:_,type:`button`,className:G.trigger,"data-filter-trigger":``,"aria-haspopup":`dialog`,"aria-expanded":se,"aria-controls":p,tabIndex:se?-1:void 0,onClick:e=>{y.current!==`open`&&ce(e.detail===0?`first`:`panel`)},onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),ce(e.key===`ArrowDown`?`first`:`last`))},children:(0,K.jsxs)(w.span,{className:G.face,style:ae,children:[(0,K.jsx)(le,{size:15,strokeWidth:1.8,"aria-hidden":`true`}),a]})}),(0,K.jsx)(w.div,{className:G.surface,style:{left:P,width:M,height:N},children:(0,K.jsx)(w.div,{ref:v,id:p,className:G.panel,role:`dialog`,"aria-labelledby":m,tabIndex:-1,inert:!se,style:{x:ne},onKeyDown:de,children:(0,K.jsxs)(w.div,{style:oe,children:[(0,K.jsxs)(`div`,{className:G.head,children:[(0,K.jsx)(l,{initial:!1,children:B?(0,K.jsx)(w.button,{type:`button`,className:G.back,"aria-label":u.back,onClick:e=>fe(e.detail===0),initial:d?{opacity:0,width:28,marginRight:2}:{opacity:0,width:0,marginRight:0,scale:.6},animate:{opacity:1,width:28,marginRight:2,scale:1},exit:d?{opacity:0,transition:J}:{opacity:0,width:0,marginRight:0,scale:.6,transition:{...n.spring.snappy,opacity:ye}},transition:d?be:{...n.spring.snappy,opacity:q},children:(0,K.jsx)(ie,{size:16,strokeWidth:1.8,"aria-hidden":`true`})},`back`):null}),(0,K.jsx)(`span`,{className:G.title,id:m,children:(0,K.jsx)(l,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(w.span,{className:G.titleText,...we(d),children:B?B.label:a},B?.id??`fields`)})})]}),(0,K.jsx)(`div`,{className:G.stage,children:(0,K.jsx)(l,{mode:`popLayout`,initial:!1,custom:O,children:(0,K.jsx)(w.div,{className:G.step,custom:O,variants:_e,initial:`enter`,animate:`center`,exit:`exit`,children:B?(0,K.jsx)(Ae,{rows:U,labelledBy:m,emptyMessage:u.noOptions,radio:!0,onChoose:me,onBack:fe,onLeave:()=>v.current?.focus({preventScroll:!0})}):(0,K.jsx)(Ae,{rows:ge,labelledBy:m,emptyMessage:u.noOptions,onChoose:pe,onLeave:()=>v.current?.focus({preventScroll:!0})})},B?.id??`fields`)})})]})})})]})}function Ne({filters:e,onRemove:t,onClearAll:r,leading:i,children:a,label:o=`Active filters`,addFilter:s,messages:c}){let u={...Oe,...c},d=C()??!1,f=(0,W.useRef)(null),p=(0,W.useRef)(null),m=(0,W.useRef)(0),h=(0,W.useRef)(null),[g,_]=(0,W.useState)(e),[y,b]=(0,W.useState)(``);if(g!==e){_(e);let t=ke(g,e,u);t&&b(t)}let x=e.map(e=>`${e.id}:${e.value??``}`).join(`|`);(0,W.useLayoutEffect)(()=>{m.current=performance.now()+900},[x]);let S=Ee(p,m,d);De(p,m,d),(0,W.useLayoutEffect)(()=>{let t=h.current,n=f.current;if(t===null||!n)return;h.current=null;let r=e[Math.min(t,e.length-1)];(r?n.querySelector(`[data-chip-remove="${CSS.escape(r.id)}"]`):n.querySelector(`[data-filter-trigger]`))?.focus({preventScroll:!0})},[e]);let T={duration:0},E=e=>({initial:!d&&{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1},animate:{width:`auto`,marginRight:0,transitionEnd:{overflow:`visible`,"--slot-moving":0}},exit:d?{opacity:0,transition:T}:{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1,pointerEvents:`none`,transition:{...n.spring.smooth,"--slot-moving":T}},transition:d?T:n.spring.smooth}),D={initial:!d&&{opacity:0,scale:.9,filter:Y(n.blur.soft)},animate:{opacity:1,scale:1,filter:Y(0)},exit:d?{opacity:0,transition:T}:{opacity:0,scale:.9,filter:Y(n.blur.subtle),transition:ye},transition:d?T:{...q,scale:n.spring.snappy}},O=d?{...we(!0),initial:!1}:we(!1),k=d?O:{...O,transition:{...q,delay:n.duration.instant*.75}};return(0,K.jsxs)(`div`,{ref:f,className:G.toolbar,role:`group`,"aria-label":o,children:[i?(0,K.jsx)(`div`,{className:G.leading,children:i}):null,(0,K.jsx)(w.div,{className:G.frame,style:{height:S},children:(0,K.jsxs)(`div`,{ref:p,className:G.chips,children:[(0,K.jsx)(l,{initial:!1,children:e.map((e,n)=>(0,K.jsx)(w.span,{className:G.slot,...E(8),children:(0,K.jsxs)(w.span,{className:G.chip,...D,children:[(0,K.jsxs)(`span`,{className:G.chipLabel,title:Z(e),children:[e.label,X(e)?(0,K.jsxs)(`span`,{className:G.value,children:[(0,K.jsx)(`span`,{className:G.separator,children:` · `}),(0,K.jsx)(Te,{text:X(e)})]}):null]}),(0,K.jsx)(`button`,{type:`button`,"data-chip-remove":e.id,"aria-label":u.remove(e),onClick:r=>{document.activeElement===r.currentTarget&&(h.current=n),t(e.id)},children:(0,K.jsx)(v,{size:14,strokeWidth:1.8,"aria-hidden":`true`})})]})},e.id))}),(0,K.jsx)(l,{initial:!1,children:e.length?null:(0,K.jsx)(w.span,{className:G.empty,...k,children:u.empty},`empty`)})]})}),(0,K.jsxs)(`div`,{className:G.actions,children:[s?(0,K.jsx)(Me,{fields:s.fields,onSelect:s.onAdd,active:e,label:s.label,align:s.align,messages:u}):null,a,(0,K.jsx)(l,{initial:!1,children:e.length>0&&r?(0,K.jsx)(w.span,{className:G.slot,...E(12),children:(0,K.jsx)(`button`,{className:G.clear,type:`button`,onClick:()=>{h.current=-1,r?.()},children:(0,K.jsx)(w.span,{className:G.clearText,...O,children:u.clearAll})})},`clear`):null})]}),(0,K.jsx)(`span`,{className:G.srOnly,role:`status`,children:y})]})}var Pe={api_key:`settings.privacy.category.api_key`,aws_key:`settings.privacy.category.aws_key`,jwt:`settings.privacy.category.jwt`,private_key:`settings.privacy.category.private_key`,email:`settings.privacy.category.email`,phone:`settings.privacy.category.phone`,intranet:`settings.privacy.category.intranet`,credit_card:`settings.privacy.category.credit_card`,national_id:`settings.privacy.category.national_id`,credential:`settings.privacy.category.credential`,custom:`settings.privacy.category.custom`},Fe={warn:`settings.privacy.action.warn`,block:`settings.privacy.action.block`,redact:`settings.privacy.action.redact`};function Ie(){let{t:e}=k();return t=>{let n=Pe[t];return n?e(n):t}}function Le({action:e}){let{t}=k();return(0,K.jsx)(D,{tone:e===`block`?`red`:e===`redact`?`orange`:`neutral`,children:t(Fe[e]??`settings.privacy.action.warn`)})}var Re=50,ze=[`block`,`redact`,`warn`];function Be(){let{t:e,locale:t}=k(),n=Ie(),[r,i]=(0,W.useState)(``),[c,l]=(0,W.useState)({client:``,category:``,action:``,blocked:``}),[u,d]=(0,W.useState)(1),[f,m]=(0,W.useState)(null),h=oe(r),g=s(),v=o(),y={model:h,...c,page:u,pageSize:Re},b=p(y,u===1),C=b.data,w=C?Math.max(1,Math.ceil(C.total/Re)):1,T=e=>e?fe[e]?.name??e:`—`,E=[...new Set((v.data?.rules??[]).map(e=>e.category))],D={client:(g.data??[]).map(e=>({value:e.kind,label:e.name})),category:E.map(e=>({value:e,label:n(e)})),action:ze.map(t=>({value:t,label:e(`settings.privacy.action.${t}`)})),blocked:[{value:`true`,label:e(`privacy.logs.blockedOnly`)},{value:`false`,label:e(`privacy.logs.passedOnly`)}]},O={client:e(`requests.col.client`),category:e(`privacy.stats.col.category`),action:e(`privacy.logs.col.action`),blocked:e(`privacy.logs.col.outcome`)},j=Object.keys(D).map(e=>({id:e,label:O[e],options:D[e].map(e=>e.label)})),N=Object.keys(c).filter(e=>c[e]).map(e=>({id:e,label:O[e],value:D[e].find(t=>t.value===c[e])?.label??c[e]})),P=(e,t)=>{l(n=>({...n,[e]:t})),d(1)},ne=(C?.items??[]).map(e=>({id:e.id,time:Date.parse(e.startedAtUtc),client:T(e.clientKind),model:e.requestedModel??``,outcome:Ve(e),hits:e.hits.reduce((e,t)=>e+t.count,0),e})),I=[{key:`time`,label:e(`requests.col.time`),width:92,render:(e,n)=>(0,K.jsx)(`span`,{className:`num`,children:ee(n.e.startedAtUtc,t)})},{key:`model`,label:e(`requests.col.model`),render:(t,n)=>(0,K.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>m(n.id),"aria-label":e(`privacy.logs.viewRequest`,{model:n.model||n.id}),children:[(0,K.jsx)(`span`,{className:`block truncate font-medium hover:text-[var(--accent)]`,children:n.model||`—`}),(0,K.jsx)(`span`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:T(n.e.clientKind)})]})},{key:`outcome`,label:e(`privacy.logs.col.outcome`),width:130,render:(e,t)=>(0,K.jsx)(He,{event:t.e})},{key:`hits`,label:e(`privacy.logs.col.hits`),render:(e,t)=>(0,K.jsx)(Ue,{event:t.e})},{key:`client`,label:e(`requests.col.client`),width:110,render:e=>(0,K.jsx)(`span`,{className:`block truncate`,children:String(e||`—`)})}];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,K.jsx)(x,{className:`w-52`,value:r,onChange:e=>{i(e),d(1)},placeholder:e(`requests.searchModel`)}),(0,K.jsx)(A,{variant:`plain`,icon:(0,K.jsx)(ae,{className:S(`size-4`,b.isFetching&&`animate-spin`)}),"aria-label":e(`common.refresh`),onClick:()=>void b.refetch()})]}),(0,K.jsx)(`div`,{className:`mb-3`,children:(0,K.jsx)(Ne,{label:e(`requests.filters`),filters:N,onRemove:e=>P(e,``),onClearAll:()=>{l({client:``,category:``,action:``,blocked:``}),d(1)},addFilter:{fields:j,label:e(`requests.addFilter`),onAdd:e=>{let t=e.id,n=D[t].find(t=>t.label===e.value)?.value;n&&P(t,n)}}})}),b.isLoading&&(0,K.jsx)(M,{lines:4,className:`py-6`}),b.isError&&(0,K.jsx)(te,{tone:`danger`,title:e(`common.error`),children:F(b.error)}),C&&C.items.length===0&&(0,K.jsx)(_,{icon:(0,K.jsx)(ve,{className:`size-6`}),title:e(`privacy.logs.empty`),detail:e(`privacy.logs.empty.detail`)}),C&&C.items.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-2 text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.total`,{count:a(C.total)})}),(0,K.jsx)(R,{caption:e(`privacy.tab.logs`),rows:ne,columns:I,rowKey:`id`,emptyMessage:e(`privacy.logs.empty`)})]}),C&&w>1&&(0,K.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,K.jsx)(pe,{page:u,pageCount:w,onPageChange:d,label:e(`requests.page`,{page:u,pages:w})})}),(0,K.jsx)(ge,{id:f,onClose:()=>m(null)})]})}function Ve(e){return e.blocked?`blocked`:e.redactions>0?`redact`:e.dryRun?`dryRun`:`warn`}function He({event:e}){let{t}=k();return e.blocked?(0,K.jsx)(D,{tone:`red`,children:t(`privacy.logs.outcome.blocked`)}):e.redactions>0?(0,K.jsx)(D,{tone:`orange`,children:t(`privacy.logs.outcome.redacted`,{count:e.redactions})}):e.dryRun?(0,K.jsx)(D,{tone:`neutral`,children:t(`privacy.logs.outcome.dryRun`)}):(0,K.jsx)(D,{tone:`neutral`,children:t(`settings.privacy.action.warn`)})}function Ue({event:e}){let t=Ie(),{t:n}=k();if(e.hits.length===0)return(0,K.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`—`});let r=e.hits.slice(0,2),i=e.hits.length-r.length;return(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px]`,children:[r.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(Le,{action:e.action}),(0,K.jsxs)(`span`,{children:[t(e.category),` × `,e.count]}),e.samples&&e.samples.length>0&&(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:e.samples.slice(0,2).join(` `)})]},`${e.ruleId}:${e.action}`)),i>0&&(0,K.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:n(`privacy.logs.moreHits`,{count:i})})]})}var Q={counter:`_counter_dnoch_1`,label:`_label_dnoch_2`,value:`_value_dnoch_4`,column:`_column_dnoch_6`,sizer:`_sizer_dnoch_7`,glyph:`_glyph_dnoch_8`,labelText:`_labelText_dnoch_9`,labelSwap:`_labelSwap_dnoch_10`,symbol:`_symbol_dnoch_11`,srOnly:`_srOnly_dnoch_12`},We=[0,1,2,3,4,5,6,7,8,9],Ge={hidden:{opacity:0,y:`0.3em`,filter:`blur(${n.blur.soft}px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.standard,ease:[...n.ease.enter]}},gone:{opacity:0,y:`-0.3em`,filter:`blur(${n.blur.subtle}px)`,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}}},Ke={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}}},qe={...n.spring.smooth,visualDuration:n.duration.considered};function Je(e,t,n){let r=new Intl.NumberFormat(n,{minimumFractionDigits:t,maximumFractionDigits:t,numberingSystem:`latn`}).formatToParts(e),i=r.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),a=0,o=0;return r.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--i}`,digit:Number(e),order:o++})):e.type===`fraction`?[...e.value].map(e=>({key:`f${a++}`,digit:Number(e),order:o++})):[{key:e.type===`group`?`g${i}`:e.type===`decimal`?`d`:`${e.type}${t}`,text:e.value}])}function Ye({position:e,digit:t}){let r=H(e,e=>((t-e)%10+15)%10-5),i=H(r,e=>`${e}em`),a=H(r,e=>Math.max(0,1-Math.abs(e))),o=H(r,e=>Math.abs(e)>=1?`hidden`:`visible`),s=H(r,e=>Math.abs(e)<.02||Math.abs(e)>=1?`none`:`blur(${(Math.abs(e)*n.blur.subtle).toFixed(2)}px)`);return(0,K.jsx)(w.span,{className:Q.glyph,style:{y:i,opacity:a,filter:s,visibility:o},children:t})}var Xe={initial:{width:0,opacity:0},animate:{width:`auto`,opacity:1},exit:{width:0,opacity:0}};function Ze({digit:t,direction:r,armed:i,delay:a,reduceMotion:o}){let s=c(i?0:t),l=(0,W.useRef)({digit:i?0:t,target:i?0:t,revealed:!i});return(0,W.useEffect)(()=>{let c=l.current;if(i||c.digit===t){i||(c.revealed=!0);return}c.target+=r<0&&c.revealed?-((c.digit-t+10)%10):(t-c.digit+10)%10,c.digit=t,o?s.jump(c.target):e(s,c.target,c.revealed?n.spring.smooth:{...qe,delay:a}),c.revealed=!0},[i,a,t,r,s,o]),(0,K.jsxs)(w.span,{className:Q.column,...Xe,transition:o?{duration:0}:n.spring.morph,children:[(0,K.jsx)(`span`,{className:Q.sizer,children:`0`}),We.map(e=>(0,K.jsx)(Ye,{position:s,digit:e},e))]})}function Qe({value:e,label:t,prefix:r=``,suffix:i=``,decimals:a=0,animateOnView:o=!1,locale:s=`en-US`}){let c=(0,W.useRef)(null),u=me(c,{once:!0,amount:.6}),d=!!C(),[f,p]=(0,W.useState)(e),[m,h]=(0,W.useState)(1);e!==f&&(p(e),h(e>f?1:-1));let g=Je(e,a,s),_=`${r}${g.map(e=>`text`in e?e.text:e.digit).join(``)}${i}`,v=o&&!u;return(0,K.jsxs)(`span`,{ref:c,className:Q.counter,children:[t&&(0,K.jsx)(`span`,{className:Q.label,children:(0,K.jsx)(`span`,{className:Q.labelSwap,children:(0,K.jsx)(l,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(w.span,{className:Q.labelText,variants:d?Ke:Ge,initial:`hidden`,animate:`shown`,exit:`gone`,children:t},t)})})}),(0,K.jsx)(`span`,{className:Q.srOnly,children:_}),(0,K.jsxs)(`span`,{className:Q.value,"aria-hidden":`true`,children:[r&&(0,K.jsx)(`span`,{className:Q.symbol,children:r}),(0,K.jsx)(l,{initial:!1,children:g.map(e=>`digit`in e?(0,K.jsx)(Ze,{digit:e.digit,direction:m,armed:v,delay:Math.min(e.order*n.stagger.item,.25),reduceMotion:d},e.key):(0,K.jsx)(w.span,{className:Q.symbol,...Xe,transition:d?{duration:0}:n.spring.morph,children:e.text},e.key))}),i&&(0,K.jsx)(`span`,{className:Q.symbol,children:i})]})]})}var $={card:`_card_1r6t9_1`,top:`_top_1r6t9_2`,swap:`_swap_1r6t9_8`,swapBlock:`_swapBlock_1r6t9_8`,text:`_text_1r6t9_11`,sizer:`_sizer_1r6t9_13`},$e={hidden:e=>({opacity:0,y:`${.3*e}em`,filter:`blur(${n.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.standard,ease:[...n.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${n.blur.subtle}px)`,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}})},et={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}}},tt=e=>Number(e.replace(/,/g,``).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN);function nt({text:t,morph:r=!1,block:i=!1}){let a=!!C(),o=(0,W.useRef)(null),s=c(`auto`),[u,d]=(0,W.useState)({text:t,direction:1});return u.text!==t&&d({text:t,direction:tt(t)<tt(u.text)?-1:1}),(0,W.useEffect)(()=>{let t=o.current;if(!t||typeof ResizeObserver>`u`)return;let r=null,i=new ResizeObserver(([i])=>{let o=i.borderBoxSize?.[0]?.inlineSize??t.offsetWidth;o&&r!==null&&r!==t.textContent&&!a?e(s,o,n.spring.morph):s.jump(o||`auto`),r=o?t.textContent:null});return i.observe(t),()=>i.disconnect()},[r,a,s]),(0,K.jsxs)(w.span,{className:i?$.swapBlock:$.swap,style:r?{width:s}:void 0,children:[r&&(0,K.jsx)(`span`,{ref:o,className:$.sizer,"aria-hidden":`true`,children:t}),(0,K.jsx)(l,{mode:`popLayout`,initial:!1,custom:u.direction,children:(0,K.jsx)(w.span,{className:$.text,custom:u.direction,variants:a?et:$e,initial:`hidden`,animate:`shown`,exit:`gone`,children:t},t)})]})}function rt({label:e,value:t,suffix:r,context:i,change:a}){let o=!!C();return(0,K.jsxs)(`article`,{className:$.card,children:[(0,K.jsxs)(`div`,{className:$.top,children:[(0,K.jsx)(`span`,{children:(0,K.jsx)(nt,{text:e,block:!0})}),(0,K.jsx)(l,{initial:!1,children:a&&(0,K.jsx)(w.small,{"data-trend":/^[+]/.test(a)?`up`:/^[-−]/.test(a)?`down`:void 0,initial:{opacity:0,scale:o?1:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:o?1:.96,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}},transition:o?{duration:0}:n.spring.snappy,children:(0,K.jsx)(nt,{text:a,morph:!0})},`change`)})]}),(0,K.jsx)(Qe,{value:t,suffix:r,animateOnView:!0}),(0,K.jsx)(`p`,{children:(0,K.jsx)(nt,{text:i,block:!0})})]})}var it=[{id:`ipv4-all`,nameKey:`settings.privacy.template.ipv4All`,hintKey:`settings.privacy.template.ipv4AllHint`,pattern:String.raw`(?<![\d.])(?:\d{1,3}\.){3}\d{1,3}(?![\d.])`},{id:`landline`,nameKey:`settings.privacy.template.landline`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<!\d)0\d{2,3}[- ]?\d{7,8}(?!\d)`},{id:`license-plate`,nameKey:`settings.privacy.template.licensePlate`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]`},{id:`passport-cn`,nameKey:`settings.privacy.template.passportCn`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])[EG]\d{8}(?!\d)`},{id:`uscc`,nameKey:`settings.privacy.template.uscc`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-HJ-NPQRTUWXY])[0-9A-HJ-NPQRTUWXY]{18}(?![0-9A-HJ-NPQRTUWXY])`},{id:`long-token`,nameKey:`settings.privacy.template.longToken`,hintKey:`settings.privacy.template.longTokenHint`,pattern:String.raw`(?<![A-Za-z0-9])[A-Za-z0-9_\-]{32,}(?![A-Za-z0-9])`},{id:`mac-address`,nameKey:`settings.privacy.template.macAddress`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-Fa-f:])(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}(?![0-9A-Fa-f:])`},{id:`unix-home`,nameKey:`settings.privacy.template.unixHome`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`/(?:Users|home)/[A-Za-z0-9_.\-]+`},{id:`windows-profile`,nameKey:`settings.privacy.template.windowsProfile`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`[A-Za-z]:\\+Users\\+[A-Za-z0-9_.\-]+`},{id:`cloud-accesskey`,nameKey:`settings.privacy.template.cloudAccessKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:LTAI[A-Za-z0-9]{12,20}|AKID[A-Za-z0-9]{13,40})(?![A-Za-z0-9])`},{id:`aws-secret-key`,nameKey:`settings.privacy.template.awsSecretKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9/+=])[A-Za-z0-9/+=]{40}(?![A-Za-z0-9/+=])`},{id:`im-webhook`,nameKey:`settings.privacy.template.imWebhook`,hintKey:`settings.privacy.template.imWebhookHint`,pattern:String.raw`oapi\.dingtalk\.com/robot/send\?access_token=[0-9a-f]{64}|qyapi\.weixin\.qq\.com/cgi-bin/webhook/send\?key=[0-9a-f]{32}|open\.feishu\.cn/open-apis/bot/v2/hook/[0-9a-f\-]{20,}|hooks\.slack\.com/services/T[A-Za-z0-9]+/B[A-Za-z0-9]+/[A-Za-z0-9]+`},{id:`internal-service`,nameKey:`settings.privacy.template.internalService`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:gitlab|jenkins|jira|confluence|wiki|nexus|harbor|grafana|kibana|sonarqube|oa|sso)\.[A-Za-z0-9\-]+(?:\.[A-Za-z0-9\-]+)+`},{id:`jdbc-conn`,nameKey:`settings.privacy.template.jdbcConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`jdbc:[A-Za-z0-9]+:[^\s"']*(?:[Uu]ser(?:[ _]?[Ii][Dd])?|[Pp]assword)=[^\s"&';]+`},{id:`smtp-conn`,nameKey:`settings.privacy.template.smtpConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`(?:smtp|imap|pop3)s?://[^\s:@/]+:[^\s@]+@[^\s]+`},{id:`key-file-ref`,nameKey:`settings.privacy.template.keyFileRef`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[A-Za-z0-9_\-./\\]+\.(?:pem|key|pfx|p12|jks|keystore)\b`},{id:`confidential-marker`,nameKey:`settings.privacy.template.confidentialMarker`,hintKey:`settings.privacy.template.confidentialHint`,pattern:String.raw`(?:绝密|机密|商业秘密|内部资料|内部公开|仅限内部|请勿外传|Confidential|Internal Use Only|Internal Only|Company Private)`},{id:`employee-id`,nameKey:`settings.privacy.template.employeeId`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:[Ee][Mm][Pp]|工号)[::\- ]?\d{4,10}(?!\d)`},{id:`labeled-number`,nameKey:`settings.privacy.template.labeledNumber`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:合同|订单|采购单|工单|项目)编号[::]?\s*[A-Za-z0-9_\-]{4,32}`}],at=[`off`,`warn`,`block`,`redact`],ot=Fe;function st(){let{t:e}=k(),{toast:t}=I(),n=o(),r=O(),i=n.data?.settings,a=e=>{i&&r.mutate({...i,...e},{onError:e=>t(F(e),`error`)})},s=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])}));return(0,K.jsxs)(j,{title:e(`settings.privacy`),footer:e(`settings.privacy.footer`),children:[n.isLoading&&(0,K.jsx)(M,{className:`my-4`}),n.isError&&(0,K.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--danger)]`,children:F(n.error)}),i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(E,{label:e(`settings.privacy.enabled`),detail:e(`settings.privacy.enabledHint`),children:(0,K.jsx)(P,{checked:i.enabled,label:e(`settings.privacy.enabled`),onChange:e=>a({enabled:e})})}),(0,K.jsx)(E,{label:e(`settings.privacy.dryRun`),detail:e(`settings.privacy.dryRunHint`),children:(0,K.jsx)(P,{checked:i.dryRun,disabled:!i.enabled,label:e(`settings.privacy.dryRun`),onChange:e=>a({dryRun:e})})}),(0,K.jsx)(E,{label:e(`settings.privacy.restore`),detail:e(`settings.privacy.restoreHint`),children:(0,K.jsx)(P,{checked:i.restoreResponses,disabled:!i.enabled,label:e(`settings.privacy.restore`),onChange:e=>a({restoreResponses:e})})}),(0,K.jsx)(E,{label:e(`settings.privacy.recordSamples`),detail:e(`settings.privacy.recordSamplesHint`),children:(0,K.jsx)(P,{checked:i.recordSamples,disabled:!i.enabled,label:e(`settings.privacy.recordSamples`),onChange:e=>a({recordSamples:e})})}),(0,K.jsx)(E,{label:e(`settings.privacy.defaultAction`),children:(0,K.jsx)(L,{className:`w-36`,ariaLabel:e(`settings.privacy.defaultAction`),value:i.defaultAction,disabled:!i.enabled,onChange:e=>a({defaultAction:e}),options:s})})]})]})}function ct(){let{t:e}=k(),{toast:t}=I(),n=o(),r=O(),i=n.data?.settings,a=Ie(),s=e=>{i&&r.mutate({...i,...e},{onError:e=>t(F(e),`error`)})},c=(e,t)=>s({categoryActions:{...i?.categoryActions,[e]:t}}),l=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])})),u=[...new Set((n.data?.rules??[]).map(e=>e.category))],d=e=>n.data?.rules.find(t=>t.category===e)?.description;return n.isLoading?(0,K.jsx)(`div`,{className:`mx-auto max-w-[720px]`,children:(0,K.jsx)(M,{className:`my-4`})}):i?(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-[720px] flex-col gap-4`,children:[(0,K.jsx)(j,{title:e(`settings.privacy.categories`),children:u.map(t=>{let n=i.categoryActions[t]??i.defaultAction,r=!i.enabled||n===`off`;return(0,K.jsxs)(E,{label:a(t),detail:d(t),children:[n===`off`?(0,K.jsx)(D,{children:e(`settings.privacy.action.off`)}):(0,K.jsx)(L,{className:`w-36`,ariaLabel:a(t),value:n,disabled:!i.enabled,onChange:e=>c(t,e),options:l.filter(e=>e.value!==`off`)}),r&&(0,K.jsx)(A,{size:`sm`,variant:`plain`,disabled:!i.enabled,onClick:()=>c(t,i.categoryActions[t]??i.defaultAction),children:e(`settings.privacy.enableCategory`)})]},t)})}),(0,K.jsx)(lt,{s:i,onPatch:s})]}):null}function lt({s:e,onPatch:t}){let{t:n}=k(),{confirm:r}=I(),[i,a]=(0,W.useState)(!1),o=(n,r)=>t({customRules:e.customRules.map(e=>e.id===n.id?{...e,enabled:r}:e)}),s=async i=>{await r({title:n(`settings.privacy.deleteRuleConfirm`,{name:i.name}),destructive:!0,confirmLabel:n(`common.delete`)})&&t({customRules:e.customRules.filter(e=>e.id!==i.id)})};return(0,K.jsxs)(j,{title:n(`settings.privacy.customRules`),children:[e.customRules.length===0&&(0,K.jsx)(`div`,{className:`px-4 py-4 text-[12px] text-[var(--text-secondary)]`,children:n(`settings.privacy.noCustomRules`)}),e.customRules.map(t=>(0,K.jsxs)(E,{label:t.name,detail:t.pattern,children:[(0,K.jsx)(P,{checked:t.enabled,disabled:!e.enabled,label:t.name,onChange:e=>o(t,e)}),(0,K.jsx)(A,{size:`sm`,variant:`plain`,icon:(0,K.jsx)(se,{className:`size-3.5`}),"aria-label":`${n(`common.delete`)} ${t.name}`,onClick:()=>void s(t)})]},t.id)),(0,K.jsx)(`div`,{className:`px-4 py-2`,children:(0,K.jsx)(A,{size:`sm`,icon:(0,K.jsx)(le,{className:`size-3.5`}),disabled:!e.enabled,onClick:()=>a(!0),children:n(`settings.privacy.addRule`)})}),(0,K.jsx)(ut,{open:i,onOpenChange:a,onAdd:n=>t({customRules:[...e.customRules,n]})})]})}function ut({open:e,onOpenChange:t,onAdd:n}){let{t:r}=k(),{toast:i}=I(),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(``);return(0,K.jsx)(ne,{open:e,onOpenChange:t,title:r(`settings.privacy.addRule`),width:480,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(A,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,K.jsx)(A,{variant:`primary`,disabled:!a.trim()||!s.trim(),onClick:()=>{if(a.trim()&&s.trim()){try{new RegExp(s)}catch(e){i(`${r(`settings.privacy.invalidPattern`)}: ${F(e)}`,`error`);return}n({id:`custom-${Date.now().toString(36)}`,name:a.trim(),pattern:s.trim(),enabled:!0}),o(``),c(``),u(``),t(!1)}},children:r(`common.create`)})]}),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(T,{label:r(`settings.privacy.ruleTemplates`),hint:r(`settings.privacy.ruleTemplatesHint`),children:(0,K.jsx)(L,{ariaLabel:r(`settings.privacy.ruleTemplates`),value:l,onChange:e=>{u(e);let t=it.find(t=>t.id===e);t&&(o(r(t.nameKey)),c(t.pattern))},options:[{value:``,label:r(`settings.privacy.ruleTemplateNone`)},...it.map(e=>({value:e.id,label:r(e.nameKey)}))]})}),(0,K.jsx)(y,{label:r(`settings.privacy.ruleName`),value:a,onChange:e=>o(e.target.value),autoFocus:!0}),(0,K.jsx)(T,{label:r(`settings.privacy.rulePattern`),hint:r(`settings.privacy.rulePatternHint`),children:(0,K.jsx)(g,{mono:!0,rows:3,value:s,onChange:e=>c(e.target.value)})})]})})}function dt(){let{t:e}=k(),{toast:t}=I(),n=Ie(),r=o(),i=f(),[a,s]=(0,W.useState)(``),c=i.data,l=r.data?.settings.enabled??!1;return(0,K.jsx)(j,{title:e(`settings.privacy.tester`),footer:e(`settings.privacy.testerHint`),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,K.jsx)(g,{"aria-label":e(`settings.privacy.tester`),placeholder:e(`settings.privacy.testerPlaceholder`),rows:4,mono:!0,value:a,onChange:e=>s(e.target.value)}),(0,K.jsx)(`div`,{children:(0,K.jsx)(A,{icon:(0,K.jsx)(B,{className:`size-3.5`}),disabled:!l||!a.trim(),loading:i.isPending,onClick:()=>i.mutate({text:a},{onError:e=>t(F(e),`error`)}),children:e(`settings.privacy.runTest`)})}),c&&(0,K.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] px-3 py-2 text-[12px]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c.blocked&&(0,K.jsx)(D,{tone:`red`,children:e(`settings.privacy.wouldBlock`)}),c.wouldRedact>0&&(0,K.jsx)(D,{tone:`orange`,children:e(`settings.privacy.wouldRedact`,{count:c.wouldRedact})}),!c.blocked&&c.wouldRedact===0&&(0,K.jsx)(D,{tone:`green`,children:e(`settings.privacy.noHits`)})]}),c.hits.length>0&&(0,K.jsx)(`ul`,{className:`mt-2 space-y-1`,children:c.hits.map(t=>(0,K.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(D,{tone:t.action===`block`?`red`:t.action===`redact`?`orange`:`neutral`,children:e(ot[t.action])}),(0,K.jsxs)(`span`,{children:[n(t.category),` · `,t.ruleId,` × `,t.count]}),t.samples&&t.samples.length>0&&(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:t.samples.join(` `)})]},`${t.ruleId}:${t.action}`))})]})]})})}var ft=[`today`,`7d`,`30d`,`all`];function pt(){let{t:e}=k(),t=Ie(),[n,r]=(0,W.useState)(`7d`),i=d(n),a=i.data,o=[{key:`category`,label:e(`privacy.stats.col.category`),render:e=>t(String(e))},{key:`requests`,label:e(`privacy.stats.col.requests`),numeric:!0,width:110},{key:`hits`,label:e(`privacy.stats.col.hits`),numeric:!0,width:96},{key:`warnHits`,label:e(`privacy.stats.col.warn`),numeric:!0,width:84},{key:`blockHits`,label:e(`privacy.stats.col.block`),numeric:!0,width:84},{key:`redactHits`,label:e(`privacy.stats.col.redact`),numeric:!0,width:84}],s=(a?.categories??[]).map(e=>({...e}));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`section`,{children:[(0,K.jsx)(b,{action:(0,K.jsx)(m,{ariaLabel:e(`overview.range`),value:n,onChange:r,items:ft.map(t=>({value:t,label:e(`range.${t}`)}))}),children:e(`privacy.stats`)}),i.isLoading&&(0,K.jsx)(M,{lines:3,className:`py-4`}),i.isError&&(0,K.jsx)(te,{tone:`danger`,title:e(`common.error`),children:F(i.error)}),a&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,K.jsx)(rt,{label:e(`privacy.stats.events`),value:a.events,context:e(`range.${n}`)}),(0,K.jsx)(rt,{label:e(`privacy.stats.blocked`),value:a.blocked,context:e(`range.${n}`)}),(0,K.jsx)(rt,{label:e(`privacy.stats.redactions`),value:a.redactions,context:e(`range.${n}`)}),(0,K.jsx)(rt,{label:e(`privacy.stats.dryRun`),value:a.dryRun,context:e(`range.${n}`)})]})]}),(0,K.jsxs)(`section`,{children:[(0,K.jsx)(b,{children:e(`privacy.stats.byCategory`)}),a&&a.categories.length===0&&(0,K.jsx)(`div`,{className:`card`,children:(0,K.jsx)(mt,{})}),a&&a.categories.length>0&&(0,K.jsx)(R,{caption:e(`privacy.stats.byCategory`),rows:s,columns:o,rowKey:`category`,defaultSort:{key:`hits`,direction:`desc`}})]}),(0,K.jsx)(`div`,{className:`mx-auto w-full max-w-[720px]`,children:(0,K.jsx)(st,{})})]})}function mt(){let{t:e}=k();return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center`,children:[(0,K.jsx)(B,{className:`size-6 text-[var(--text-muted)]`}),(0,K.jsx)(`div`,{className:`text-[13px]`,children:e(`privacy.logs.empty`)}),(0,K.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.empty.detail`)})]})}var ht=[`overview`,`logs`,`rules`,`tester`];function gt(){let{t:e}=k(),{tab:t}=ce(),n=de(),r=ht.includes(t)?t:`overview`;return(0,K.jsx)(he,{title:e(`nav.privacy`),subtitle:e(`settings.privacy.footer`),children:(0,K.jsxs)(re,{value:r,onValueChange:e=>n(`/privacy/${e}`,{replace:!0}),children:[(0,K.jsx)(V,{"aria-label":e(`nav.privacy`),children:ht.map(t=>(0,K.jsx)(z,{value:t,children:e(`privacy.tab.${t}`)},t))}),(0,K.jsx)(U,{value:`overview`,className:`pt-5`,children:(0,K.jsx)(pt,{})}),(0,K.jsx)(U,{value:`logs`,className:`pt-4`,children:(0,K.jsx)(Be,{})}),(0,K.jsx)(U,{value:`rules`,className:`pt-5`,children:(0,K.jsx)(ct,{})}),(0,K.jsx)(U,{value:`tester`,className:`pt-5 [&>div]:mx-auto [&>div]:max-w-[680px]`,children:(0,K.jsx)(dt,{})})]})})}export{gt as PrivacyPage};
|
|
1
|
+
import{Ai as e,Ca as t,E as n,Ea as r,Fi as i,J as a,Jn as o,Kt as s,Mi as c,Pi as l,Sa as u,Xn as d,Yn as f,Zn as p,_ as m,_t as h,b as g,c as _,ct as v,d as y,g as b,h as x,it as S,ji as C,ki as w,l as T,m as E,n as D,ni as O,ot as k,q as ee,r as A,t as te,u as j,v as M,vt as N,y as P}from"./alert-BzjF81CS.js";import{a as F,i as ne,o as I,r as L}from"./overlays-8ByMRpma.js";import{C as re,D as R,E as z,H as ie,L as ae,M as oe,N as se,P as B,Q as ce,R as le,T as V,V as ue,Z as de,_ as fe,c as pe,et as me,h as he,r as ge,tt as H,w as U}from"./index-D7HIE1TG.js";var _e={name:`shield-off`,size:24,node:[[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M5 5a1 1 0 0 0-1 1v7c0 5 3.5 7.5 7.67 8.94a1 1 0 0 0 .67.01c2.35-.82 4.48-1.97 5.9-3.71`,key:`1jlk70`}],[`path`,{d:`M9.309 3.652A12.252 12.252 0 0 0 11.24 2.28a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1v7a9.784 9.784 0 0 1-.08 1.264`,key:`18rp1v`}]]};_e.node;var ve=N(_e),W=r(t(),1),G={toolbar:`_toolbar_1p5c5_1`,leading:`_leading_1p5c5_2`,frame:`_frame_1p5c5_4`,chips:`_chips_1p5c5_5`,slot:`_slot_1p5c5_7`,chip:`_chip_1p5c5_5`,chipLabel:`_chipLabel_1p5c5_10`,value:`_value_1p5c5_11`,separator:`_separator_1p5c5_12`,morphText:`_morphText_1p5c5_13`,morphValue:`_morphValue_1p5c5_14`,measure:`_measure_1p5c5_15`,empty:`_empty_1p5c5_18`,actions:`_actions_1p5c5_19`,clear:`_clear_1p5c5_20`,clearText:`_clearText_1p5c5_21`,srOnly:`_srOnly_1p5c5_23`,menu:`_menu_1p5c5_27`,trigger:`_trigger_1p5c5_29`,face:`_face_1p5c5_31`,surface:`_surface_1p5c5_34`,panel:`_panel_1p5c5_42`,head:`_head_1p5c5_45`,back:`_back_1p5c5_47`,title:`_title_1p5c5_49`,titleText:`_titleText_1p5c5_50`,stage:`_stage_1p5c5_51`,step:`_step_1p5c5_52`,list:`_list_1p5c5_53`,highlight:`_highlight_1p5c5_54`,item:`_item_1p5c5_55`,itemIcon:`_itemIcon_1p5c5_57`,itemLabel:`_itemLabel_1p5c5_58`,itemMeta:`_itemMeta_1p5c5_59`,metaValue:`_metaValue_1p5c5_60`,hint:`_hint_1p5c5_61`,check:`_check_1p5c5_62`,noOptions:`_noOptions_1p5c5_64`},K=u(),q={duration:n.duration.standard,ease:[...n.ease.enter]},ye={duration:n.duration.instant,ease:[...n.ease.standard]},J={duration:0},be={duration:n.duration.instant,ease:[...n.ease.standard]},Y=e=>`blur(${e}px)`,xe=e=>Math.min(1,Math.max(0,e)),Se=e=>typeof e==`string`?{value:e}:e,Ce=e=>e.label??e.value,we=e=>({initial:e?{opacity:0}:{opacity:0,y:`0.3em`,filter:Y(n.blur.soft)},animate:{opacity:1,y:0,filter:Y(0)},exit:e?{opacity:0,transition:J}:{opacity:0,y:`-0.3em`,filter:Y(n.blur.subtle),transition:ye},transition:e?be:q});function Te({text:t}){let r=C()??!1,i=(0,W.useRef)(null),a=c(`auto`);return(0,W.useLayoutEffect)(()=>{let t=i.current;if(!t||typeof ResizeObserver>`u`)return;let o=null,s=new ResizeObserver(([i])=>{let s=Math.ceil(i.borderBoxSize?.[0]?.inlineSize??t.offsetWidth),c=o!==null&&o!==t.textContent;o=t.textContent,c&&!r?e(a,s,n.spring.morph):a.jump(s)});return s.observe(t),()=>s.disconnect()},[r,a]),(0,K.jsxs)(w.span,{className:G.morphText,style:{width:a},children:[(0,K.jsx)(`span`,{ref:i,className:G.measure,"aria-hidden":`true`,children:t}),(0,K.jsx)(l,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(w.span,{className:G.morphValue,...we(r),children:t},t)})]})}function Ee(t,r,i){let a=c(`auto`);return(0,W.useLayoutEffect)(()=>{let o=t.current;if(!o||typeof ResizeObserver>`u`)return;let s=!1,c=new ResizeObserver(()=>{let t=o.offsetHeight;if(!s||i||performance.now()>r.current){s=!0,a.jump(t);return}e(a,t,n.spring.smooth)});return c.observe(o),()=>c.disconnect()},[r,a,t,i]),a}function De(t,r,i){(0,W.useLayoutEffect)(()=>{let a=t.current;if(!a||typeof ResizeObserver>`u`)return;let o=new Map,s=()=>{let t=performance.now();for(let s of Array.from(a.children)){let a=s.offsetLeft,c=s.offsetTop,l=o.get(s);if(!l){o.set(s,{x:a,y:c,dx:0,dy:0});continue}let u=l.x-a,d=l.y-c;if(l.x=a,l.y=c,i||t>r.current||Math.abs(d)<1&&Math.abs(u)<40)continue;l.stop?.();let f=l.dx+u,p=l.dy+d,m=e=>{l.dx=f*(1-e),l.dy=p*(1-e),s.style.translate=e>=1?``:`${l.dx}px ${l.dy}px`};m(0),l.stop=e(0,1,{...n.spring.smooth,onUpdate:m,onComplete:()=>m(1)}).stop}for(let e of o.keys())e.parentElement!==a&&o.delete(e)},c=new ResizeObserver(s),l=()=>{for(let e of Array.from(a.children))c.observe(e)},u=new MutationObserver(()=>{l(),s()});return c.observe(a),l(),u.observe(a,{childList:!0}),()=>{c.disconnect(),u.disconnect();for(let e of o.values())e.stop?.()}},[r,t,i])}var X=e=>e.valueLabel??e.value,Z=e=>X(e)?`${e.label}: ${X(e)}`:e.label,Oe={empty:`No filters applied`,clearAll:`Clear all`,back:`Back to fields`,noOptions:`No options available`,cleared:`All filters cleared`,remove:e=>`Remove ${Z(e)}`,added:e=>`Added ${Z(e)}`,changed:e=>`Changed ${Z(e)}`,removed:e=>`Removed ${Z(e)}`};function ke(e,t,n){let r=e.filter(e=>!t.some(t=>t.id===e.id));if(!t.length&&r.length>1)return n.cleared;let i=t.filter(t=>!e.some(e=>e.id===t.id)),a=t.filter(t=>e.some(e=>e.id===t.id&&e.value!==t.value));return[...i.map(n.added),...a.map(n.changed),...r.map(n.removed)].join(`. `)}function Ae({rows:e,labelledBy:t,onChoose:r,onBack:a,onLeave:o,radio:s,emptyMessage:c}){let l=C()??!1,u=i(),d=(0,W.useRef)(null),f=(0,W.useRef)(!1),p=(0,W.useRef)({text:``,at:0}),[m,h]=(0,W.useState)(()=>Math.max(0,e.findIndex(e=>e.checked))),[g,_]=(0,W.useState)(null),v=()=>Array.from(d.current?.querySelectorAll(`[data-row]`)??[]),y=e=>{let t=d.current;e&&t&&(e.focus({preventScroll:!0}),e.offsetTop<t.scrollTop?t.scrollTop=e.offsetTop:e.offsetTop+e.offsetHeight>t.scrollTop+t.clientHeight&&(t.scrollTop=e.offsetTop+e.offsetHeight-t.clientHeight))};function b(t){let n=v(),i=n.indexOf(document.activeElement),o=e=>{t.preventDefault(),f.current=!1,y(n[e])};if(t.key===`ArrowDown`)return o(i<0?0:(i+1)%n.length);if(t.key===`ArrowUp`)return o(i<0?n.length-1:(i-1+n.length)%n.length);if(t.key===`Home`)return o(0);if(t.key===`End`)return o(n.length-1);if(t.key===`ArrowRight`&&i>=0&&e[i]?.drill){t.preventDefault(),r(e[i],!0);return}if(t.key===`ArrowLeft`&&a){t.preventDefault(),a(!0);return}if(t.key.length===1&&/\S/.test(t.key)&&!t.metaKey&&!t.ctrlKey&&!t.altKey){let e=performance.now();p.current={text:e-p.current.at<700?p.current.text+t.key.toLowerCase():t.key.toLowerCase(),at:e};let r=[...n.slice(i+(p.current.text.length>1?0:1)),...n.slice(0,i+(p.current.text.length>1?0:1))].find(e=>(e.dataset.text??``).toLowerCase().startsWith(p.current.text));r&&o(n.indexOf(r))}}function x(e){let t=e.target.closest(`[data-row]`);if(!t)return;h(v().indexOf(t));let n=f.current&&!l,r=!f.current&&t.matches(`:focus-visible`);_(e=>({top:t.offsetTop,height:t.offsetHeight,glide:n&&!!e?.shown,ring:r,shown:!0}))}function S(e){d.current?.contains(e.relatedTarget)||_(e=>e&&{...e,glide:!1,ring:!1,shown:!1})}return(0,K.jsxs)(`div`,{ref:d,className:G.list,role:`menu`,"aria-labelledby":t,"data-current":u?``:void 0,onKeyDown:b,onFocus:x,onBlur:S,onPointerLeave:()=>{f.current&&d.current?.contains(document.activeElement)&&o()},children:[(0,K.jsx)(w.span,{className:G.highlight,"data-ring":g?.ring||void 0,"aria-hidden":`true`,initial:!1,animate:g?{y:g.top,height:g.height,opacity:+!!g.shown}:{opacity:0},transition:{default:g?.glide?n.spring.snappy:J,opacity:{duration:l?0:.08}}}),e.length===0?(0,K.jsx)(`p`,{className:G.noOptions,children:c}):null,e.map((e,t)=>(0,K.jsxs)(`button`,{type:`button`,className:G.item,role:s?`menuitemradio`:`menuitem`,"aria-checked":s?!!e.checked:void 0,tabIndex:t===m?0:-1,"data-row":e.key,"data-text":e.label,onPointerMove:e=>{f.current=!0,document.activeElement!==e.currentTarget&&e.currentTarget.focus({preventScroll:!0})},onClick:t=>r(e,t.detail===0),children:[e.icon?(0,K.jsx)(`span`,{className:G.itemIcon,"aria-hidden":`true`,children:e.icon}):null,(0,K.jsx)(`span`,{className:G.itemLabel,children:e.label}),e.meta?(0,K.jsx)(`span`,{className:G.itemMeta,children:e.meta}):null]},e.key))]})}function je(e){let t={left:0,top:0,right:document.documentElement.clientWidth,bottom:window.innerHeight};for(let n=e.parentElement;n&&n!==document.body;n=n.parentElement){let e=getComputedStyle(n);if(e.overflowX===`visible`&&e.overflowY===`visible`)continue;let r=n.getBoundingClientRect();e.overflowX!==`visible`&&(t.left=Math.max(t.left,r.left),t.right=Math.min(t.right,r.right)),e.overflowY!==`visible`&&(t.top=Math.max(t.top,r.top),t.bottom=Math.min(t.bottom,r.bottom))}return t}function Me({fields:t,onSelect:r,active:i=[],label:a=`Add filter`,align:o=`end`,messages:s}){let u={...Oe,...s},d=C()??!1,f=(0,W.useId)(),p=`${f}panel`,m=`${f}title`,g=(0,W.useRef)(null),_=(0,W.useRef)(null),v=(0,W.useRef)(null),y=(0,W.useRef)(`closed`),b=(0,W.useRef)(0),x=(0,W.useRef)(null),[S,T]=(0,W.useState)(`closed`),[E,D]=(0,W.useState)(null),[O,k]=(0,W.useState)(1),[ee,A]=(0,W.useState)(!1),[te,j]=(0,W.useState)(`100% 0`),M=c(`100%`),N=c(`100%`),P=c(0),F=c(0),ne=H(()=>F.get()-P.get()),I=c(0),L=c(0),re=H(()=>{let e=M.get(),t=I.get(),n=L.get();return typeof e==`number`?n>t?xe((e-t)/(n-t)):1:0}),R=H(()=>xe(re.get()/.35)),z=H(()=>xe((re.get()-.4)/.5)),ae={opacity:H(()=>1-R.get()),scale:H(()=>1-R.get()*.04),filter:H(()=>R.get()?Y(R.get()*n.blur.subtle):`none`)},oe={opacity:z,transformOrigin:te,scale:H(()=>.96+z.get()*.04),y:H(()=>(1-z.get())*(ee?-6:6)),filter:H(()=>z.get()===1?`none`:Y((1-z.get())*n.blur.soft))},se=S===`open`,B=t.find(e=>e.id===E)??null,ce=(0,W.useCallback)(t=>{let r=_.current,i=v.current;if(!r||!i)return;let a=r.getBoundingClientRect(),s=i.offsetWidth+2,c=i.offsetHeight+2,l=je(g.current??r),u=l.left+16-a.left,f=l.right-16-a.left-s,p=a.width-s,m=o===`end`?p>=u?p:0<=f?0:p:0<=f?0:p>=u?p:0;m=Math.round(Math.min(Math.max(m,u),Math.max(u,f)));let h=l.bottom-a.top,S=a.bottom-l.top,C=h<c+16&&S>h;y.current===`closed`&&(M.jump(a.width),N.jump(a.height),P.jump(0)),F.jump(m),I.jump(a.width),L.jump(s),y.current=`open`,b.current+=1,x.current=t,T(`open`),A(C),D(null),k(-1),j(`${Math.round(a.width/2-m)}px ${C?`100%`:`0`}`);let w=d?J:n.spring.morph;e(P,m,w),e(M,s,w),e(N,c,w)},[o,I,N,P,d,F,L,M]),V=(0,W.useCallback)(t=>{let r=_.current;if(y.current!==`open`||!r)return;y.current=`closing`;let i=b.current+=1;T(`closing`),t&&r.focus({preventScroll:!0,focusVisible:t===`keyboard`});let a=d?J:n.spring.snappy;e(P,0,a);let o=r.getBoundingClientRect();e(N,o.height,a),e(M,o.width,{...a,onComplete:()=>{i===b.current&&(y.current=`closed`,M.jump(`100%`),N.jump(`100%`),T(`closed`),D(null))}})},[N,P,d,M]);(0,W.useLayoutEffect)(()=>{let t=v.current;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{y.current===`open`&&e(N,t.offsetHeight+2,d?J:n.spring.smooth)});return r.observe(t),()=>r.disconnect()},[N,d]),(0,W.useLayoutEffect)(()=>{let e=x.current,t=v.current;if(!e||!t||S!==`open`)return;if(x.current=null,e===`panel`){t.focus({preventScroll:!0});return}let n=Array.from(t.querySelectorAll(`[data-current] [data-row]`));(e===`first`?n[0]:e===`last`?n.at(-1):e===`checked`?n.find(e=>e.getAttribute(`aria-checked`)===`true`)??n[0]:n.find(t=>t.dataset.row===e.key)??n[0])?.focus({preventScroll:!0})},[S,E]),(0,W.useEffect)(()=>{if(S!==`open`)return;let e=e=>{let t=g.current,n=e.target;!t||n&&t.contains(n)||(V(!1),n?.closest?.(`button, a[href], input, select, textarea, [tabindex], [contenteditable]`)||window.setTimeout(()=>{let e=document.activeElement;(!e||e===document.body||t.contains(e))&&_.current?.focus({preventScroll:!0,focusVisible:!1})},0))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[V,S]);function de(e){if(e.defaultPrevented)return;let t=Array.from(v.current?.querySelectorAll(`[data-current] [data-row]`)??[]);(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),(e.key===`ArrowDown`?t[0]:t.at(-1))?.focus({preventScroll:!0})),e.key===`ArrowLeft`&&B&&(e.preventDefault(),fe(!0))}function fe(e){B&&(x.current=e?{key:B.id}:`panel`,k(-1),D(null))}function pe(e,t){x.current=t?`checked`:`panel`,k(1),D(e.key)}function me(e,t){B&&(r({id:B.id,label:B.label,value:e.key,valueLabel:e.label},B),V(t?`keyboard`:`pointer`))}let he=e=>i.find(t=>t.id===e.id),ge=t.map(e=>({key:e.id,label:e.label,icon:e.icon,drill:!0,meta:(0,K.jsxs)(K.Fragment,{children:[he(e)?(0,K.jsx)(`span`,{className:G.metaValue,children:X(he(e))}):null,(0,K.jsx)(ue,{size:15,strokeWidth:1.8,"aria-hidden":`true`})]})})),U=B?B.options.map(Se).map(e=>{let t=Ce(e),n=he(B)?.value===e.value;return{key:e.value,label:t,icon:e.icon,checked:n,meta:e.hint!=null||n?(0,K.jsxs)(K.Fragment,{children:[e.hint==null?null:(0,K.jsx)(`span`,{className:G.hint,children:e.hint}),(0,K.jsx)(`span`,{className:G.check,"data-on":n||void 0,children:(0,K.jsx)(h,{size:15,strokeWidth:2,"aria-hidden":`true`})})]}):null}}):[],_e={enter:e=>d?{opacity:0}:{opacity:0,x:e*18,filter:Y(n.blur.soft)},center:{opacity:1,x:0,filter:Y(0),transition:d?be:{...q,x:n.spring.smooth}},exit:e=>d?{opacity:0,transition:J}:{opacity:0,x:e*-18,filter:Y(n.blur.subtle),transition:ye}};return(0,K.jsxs)(`div`,{ref:g,className:G.menu,"data-state":S,"data-y":ee?`up`:`down`,onKeyDown:e=>{e.key===`Escape`&&y.current===`open`&&(e.preventDefault(),e.stopPropagation(),V(`keyboard`))},onBlur:e=>{let t=e.relatedTarget;y.current===`open`&&t&&!g.current?.contains(t)&&V(!1)},children:[(0,K.jsx)(`button`,{ref:_,type:`button`,className:G.trigger,"data-filter-trigger":``,"aria-haspopup":`dialog`,"aria-expanded":se,"aria-controls":p,tabIndex:se?-1:void 0,onClick:e=>{y.current!==`open`&&ce(e.detail===0?`first`:`panel`)},onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),ce(e.key===`ArrowDown`?`first`:`last`))},children:(0,K.jsxs)(w.span,{className:G.face,style:ae,children:[(0,K.jsx)(le,{size:15,strokeWidth:1.8,"aria-hidden":`true`}),a]})}),(0,K.jsx)(w.div,{className:G.surface,style:{left:P,width:M,height:N},children:(0,K.jsx)(w.div,{ref:v,id:p,className:G.panel,role:`dialog`,"aria-labelledby":m,tabIndex:-1,inert:!se,style:{x:ne},onKeyDown:de,children:(0,K.jsxs)(w.div,{style:oe,children:[(0,K.jsxs)(`div`,{className:G.head,children:[(0,K.jsx)(l,{initial:!1,children:B?(0,K.jsx)(w.button,{type:`button`,className:G.back,"aria-label":u.back,onClick:e=>fe(e.detail===0),initial:d?{opacity:0,width:28,marginRight:2}:{opacity:0,width:0,marginRight:0,scale:.6},animate:{opacity:1,width:28,marginRight:2,scale:1},exit:d?{opacity:0,transition:J}:{opacity:0,width:0,marginRight:0,scale:.6,transition:{...n.spring.snappy,opacity:ye}},transition:d?be:{...n.spring.snappy,opacity:q},children:(0,K.jsx)(ie,{size:16,strokeWidth:1.8,"aria-hidden":`true`})},`back`):null}),(0,K.jsx)(`span`,{className:G.title,id:m,children:(0,K.jsx)(l,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(w.span,{className:G.titleText,...we(d),children:B?B.label:a},B?.id??`fields`)})})]}),(0,K.jsx)(`div`,{className:G.stage,children:(0,K.jsx)(l,{mode:`popLayout`,initial:!1,custom:O,children:(0,K.jsx)(w.div,{className:G.step,custom:O,variants:_e,initial:`enter`,animate:`center`,exit:`exit`,children:B?(0,K.jsx)(Ae,{rows:U,labelledBy:m,emptyMessage:u.noOptions,radio:!0,onChoose:me,onBack:fe,onLeave:()=>v.current?.focus({preventScroll:!0})}):(0,K.jsx)(Ae,{rows:ge,labelledBy:m,emptyMessage:u.noOptions,onChoose:pe,onLeave:()=>v.current?.focus({preventScroll:!0})})},B?.id??`fields`)})})]})})})]})}function Ne({filters:e,onRemove:t,onClearAll:r,leading:i,children:a,label:o=`Active filters`,addFilter:s,messages:c}){let u={...Oe,...c},d=C()??!1,f=(0,W.useRef)(null),p=(0,W.useRef)(null),m=(0,W.useRef)(0),h=(0,W.useRef)(null),[g,_]=(0,W.useState)(e),[y,b]=(0,W.useState)(``);if(g!==e){_(e);let t=ke(g,e,u);t&&b(t)}let x=e.map(e=>`${e.id}:${e.value??``}`).join(`|`);(0,W.useLayoutEffect)(()=>{m.current=performance.now()+900},[x]);let S=Ee(p,m,d);De(p,m,d),(0,W.useLayoutEffect)(()=>{let t=h.current,n=f.current;if(t===null||!n)return;h.current=null;let r=e[Math.min(t,e.length-1)];(r?n.querySelector(`[data-chip-remove="${CSS.escape(r.id)}"]`):n.querySelector(`[data-filter-trigger]`))?.focus({preventScroll:!0})},[e]);let T={duration:0},E=e=>({initial:!d&&{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1},animate:{width:`auto`,marginRight:0,transitionEnd:{overflow:`visible`,"--slot-moving":0}},exit:d?{opacity:0,transition:T}:{width:0,marginRight:-e,overflow:`clip`,"--slot-moving":1,pointerEvents:`none`,transition:{...n.spring.smooth,"--slot-moving":T}},transition:d?T:n.spring.smooth}),D={initial:!d&&{opacity:0,scale:.9,filter:Y(n.blur.soft)},animate:{opacity:1,scale:1,filter:Y(0)},exit:d?{opacity:0,transition:T}:{opacity:0,scale:.9,filter:Y(n.blur.subtle),transition:ye},transition:d?T:{...q,scale:n.spring.snappy}},O=d?{...we(!0),initial:!1}:we(!1),k=d?O:{...O,transition:{...q,delay:n.duration.instant*.75}};return(0,K.jsxs)(`div`,{ref:f,className:G.toolbar,role:`group`,"aria-label":o,children:[i?(0,K.jsx)(`div`,{className:G.leading,children:i}):null,(0,K.jsx)(w.div,{className:G.frame,style:{height:S},children:(0,K.jsxs)(`div`,{ref:p,className:G.chips,children:[(0,K.jsx)(l,{initial:!1,children:e.map((e,n)=>(0,K.jsx)(w.span,{className:G.slot,...E(8),children:(0,K.jsxs)(w.span,{className:G.chip,...D,children:[(0,K.jsxs)(`span`,{className:G.chipLabel,title:Z(e),children:[e.label,X(e)?(0,K.jsxs)(`span`,{className:G.value,children:[(0,K.jsx)(`span`,{className:G.separator,children:` · `}),(0,K.jsx)(Te,{text:X(e)})]}):null]}),(0,K.jsx)(`button`,{type:`button`,"data-chip-remove":e.id,"aria-label":u.remove(e),onClick:r=>{document.activeElement===r.currentTarget&&(h.current=n),t(e.id)},children:(0,K.jsx)(v,{size:14,strokeWidth:1.8,"aria-hidden":`true`})})]})},e.id))}),(0,K.jsx)(l,{initial:!1,children:e.length?null:(0,K.jsx)(w.span,{className:G.empty,...k,children:u.empty},`empty`)})]})}),(0,K.jsxs)(`div`,{className:G.actions,children:[s?(0,K.jsx)(Me,{fields:s.fields,onSelect:s.onAdd,active:e,label:s.label,align:s.align,messages:u}):null,a,(0,K.jsx)(l,{initial:!1,children:e.length>0&&r?(0,K.jsx)(w.span,{className:G.slot,...E(12),children:(0,K.jsx)(`button`,{className:G.clear,type:`button`,onClick:()=>{h.current=-1,r?.()},children:(0,K.jsx)(w.span,{className:G.clearText,...O,children:u.clearAll})})},`clear`):null})]}),(0,K.jsx)(`span`,{className:G.srOnly,role:`status`,children:y})]})}var Pe={api_key:`settings.privacy.category.api_key`,aws_key:`settings.privacy.category.aws_key`,jwt:`settings.privacy.category.jwt`,private_key:`settings.privacy.category.private_key`,email:`settings.privacy.category.email`,phone:`settings.privacy.category.phone`,intranet:`settings.privacy.category.intranet`,credit_card:`settings.privacy.category.credit_card`,national_id:`settings.privacy.category.national_id`,credential:`settings.privacy.category.credential`,custom:`settings.privacy.category.custom`},Fe={warn:`settings.privacy.action.warn`,block:`settings.privacy.action.block`,redact:`settings.privacy.action.redact`};function Ie(){let{t:e}=k();return t=>{let n=Pe[t];return n?e(n):t}}function Le({action:e}){let{t}=k();return(0,K.jsx)(D,{tone:e===`block`?`red`:e===`redact`?`orange`:`neutral`,children:t(Fe[e]??`settings.privacy.action.warn`)})}var Re=50,ze=[`block`,`redact`,`warn`];function Be(){let{t:e,locale:t}=k(),n=Ie(),[r,i]=(0,W.useState)(``),[c,l]=(0,W.useState)({client:``,category:``,action:``,blocked:``}),[u,d]=(0,W.useState)(1),[f,m]=(0,W.useState)(null),h=oe(r),g=s(),v=o(),y={model:h,...c,page:u,pageSize:Re},b=p(y,u===1),C=b.data,w=C?Math.max(1,Math.ceil(C.total/Re)):1,T=e=>e?fe[e]?.name??e:`—`,E=[...new Set((v.data?.rules??[]).map(e=>e.category))],D={client:(g.data??[]).map(e=>({value:e.kind,label:e.name})),category:E.map(e=>({value:e,label:n(e)})),action:ze.map(t=>({value:t,label:e(`settings.privacy.action.${t}`)})),blocked:[{value:`true`,label:e(`privacy.logs.blockedOnly`)},{value:`false`,label:e(`privacy.logs.passedOnly`)}]},O={client:e(`requests.col.client`),category:e(`privacy.stats.col.category`),action:e(`privacy.logs.col.action`),blocked:e(`privacy.logs.col.outcome`)},j=Object.keys(D).map(e=>({id:e,label:O[e],options:D[e].map(e=>e.label)})),N=Object.keys(c).filter(e=>c[e]).map(e=>({id:e,label:O[e],value:D[e].find(t=>t.value===c[e])?.label??c[e]})),P=(e,t)=>{l(n=>({...n,[e]:t})),d(1)},ne=(C?.items??[]).map(e=>({id:e.id,time:Date.parse(e.startedAtUtc),client:T(e.clientKind),model:e.requestedModel??``,outcome:Ve(e),hits:e.hits.reduce((e,t)=>e+t.count,0),e})),I=[{key:`time`,label:e(`requests.col.time`),width:92,render:(e,n)=>(0,K.jsx)(`span`,{className:`num`,children:ee(n.e.startedAtUtc,t)})},{key:`model`,label:e(`requests.col.model`),render:(t,n)=>(0,K.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:()=>m(n.id),"aria-label":e(`privacy.logs.viewRequest`,{model:n.model||n.id}),children:[(0,K.jsx)(`span`,{className:`block truncate font-medium hover:text-[var(--accent)]`,children:n.model||`—`}),(0,K.jsx)(`span`,{className:`block truncate text-[11px] text-[var(--text-muted)]`,children:T(n.e.clientKind)})]})},{key:`outcome`,label:e(`privacy.logs.col.outcome`),width:130,render:(e,t)=>(0,K.jsx)(He,{event:t.e})},{key:`hits`,label:e(`privacy.logs.col.hits`),render:(e,t)=>(0,K.jsx)(Ue,{event:t.e})},{key:`client`,label:e(`requests.col.client`),width:110,render:e=>(0,K.jsx)(`span`,{className:`block truncate`,children:String(e||`—`)})}];return(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[(0,K.jsx)(x,{className:`w-52`,value:r,onChange:e=>{i(e),d(1)},placeholder:e(`requests.searchModel`)}),(0,K.jsx)(A,{variant:`plain`,icon:(0,K.jsx)(ae,{className:S(`size-4`,b.isFetching&&`animate-spin`)}),"aria-label":e(`common.refresh`),onClick:()=>void b.refetch()})]}),(0,K.jsx)(`div`,{className:`mb-3`,children:(0,K.jsx)(Ne,{label:e(`requests.filters`),filters:N,onRemove:e=>P(e,``),onClearAll:()=>{l({client:``,category:``,action:``,blocked:``}),d(1)},addFilter:{fields:j,label:e(`requests.addFilter`),onAdd:e=>{let t=e.id,n=D[t].find(t=>t.label===e.value)?.value;n&&P(t,n)}}})}),b.isLoading&&(0,K.jsx)(M,{lines:4,className:`py-6`}),b.isError&&(0,K.jsx)(te,{tone:`danger`,title:e(`common.error`),children:F(b.error)}),C&&C.items.length===0&&(0,K.jsx)(_,{icon:(0,K.jsx)(ve,{className:`size-6`}),title:e(`privacy.logs.empty`),detail:e(`privacy.logs.empty.detail`)}),C&&C.items.length>0&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mb-2 text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.total`,{count:a(C.total)})}),(0,K.jsx)(R,{caption:e(`privacy.tab.logs`),rows:ne,columns:I,rowKey:`id`,emptyMessage:e(`privacy.logs.empty`)})]}),C&&w>1&&(0,K.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,K.jsx)(pe,{page:u,pageCount:w,onPageChange:d,label:e(`requests.page`,{page:u,pages:w})})}),(0,K.jsx)(ge,{id:f,onClose:()=>m(null)})]})}function Ve(e){return e.blocked?`blocked`:e.redactions>0?`redact`:e.dryRun?`dryRun`:`warn`}function He({event:e}){let{t}=k();return e.blocked?(0,K.jsx)(D,{tone:`red`,children:t(`privacy.logs.outcome.blocked`)}):e.redactions>0?(0,K.jsx)(D,{tone:`orange`,children:t(`privacy.logs.outcome.redacted`,{count:e.redactions})}):e.dryRun?(0,K.jsx)(D,{tone:`neutral`,children:t(`privacy.logs.outcome.dryRun`)}):(0,K.jsx)(D,{tone:`neutral`,children:t(`settings.privacy.action.warn`)})}function Ue({event:e}){let t=Ie(),{t:n}=k();if(e.hits.length===0)return(0,K.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`—`});let r=e.hits.slice(0,2),i=e.hits.length-r.length;return(0,K.jsxs)(`span`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[12px]`,children:[r.map(e=>(0,K.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,K.jsx)(Le,{action:e.action}),(0,K.jsxs)(`span`,{children:[t(e.category),` × `,e.count]}),e.samples&&e.samples.length>0&&(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:e.samples.slice(0,2).join(` `)})]},`${e.ruleId}:${e.action}`)),i>0&&(0,K.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:n(`privacy.logs.moreHits`,{count:i})})]})}var Q={counter:`_counter_dnoch_1`,label:`_label_dnoch_2`,value:`_value_dnoch_4`,column:`_column_dnoch_6`,sizer:`_sizer_dnoch_7`,glyph:`_glyph_dnoch_8`,labelText:`_labelText_dnoch_9`,labelSwap:`_labelSwap_dnoch_10`,symbol:`_symbol_dnoch_11`,srOnly:`_srOnly_dnoch_12`},We=[0,1,2,3,4,5,6,7,8,9],Ge={hidden:{opacity:0,y:`0.3em`,filter:`blur(${n.blur.soft}px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.standard,ease:[...n.ease.enter]}},gone:{opacity:0,y:`-0.3em`,filter:`blur(${n.blur.subtle}px)`,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}}},Ke={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}}},qe={...n.spring.smooth,visualDuration:n.duration.considered};function Je(e,t,n){let r=new Intl.NumberFormat(n,{minimumFractionDigits:t,maximumFractionDigits:t,numberingSystem:`latn`}).formatToParts(e),i=r.reduce((e,t)=>e+(t.type===`integer`?t.value.length:0),0),a=0,o=0;return r.flatMap((e,t)=>e.type===`integer`?[...e.value].map(e=>({key:`i${--i}`,digit:Number(e),order:o++})):e.type===`fraction`?[...e.value].map(e=>({key:`f${a++}`,digit:Number(e),order:o++})):[{key:e.type===`group`?`g${i}`:e.type===`decimal`?`d`:`${e.type}${t}`,text:e.value}])}function Ye({position:e,digit:t}){let r=H(e,e=>((t-e)%10+15)%10-5),i=H(r,e=>`${e}em`),a=H(r,e=>Math.max(0,1-Math.abs(e))),o=H(r,e=>Math.abs(e)>=1?`hidden`:`visible`),s=H(r,e=>Math.abs(e)<.02||Math.abs(e)>=1?`none`:`blur(${(Math.abs(e)*n.blur.subtle).toFixed(2)}px)`);return(0,K.jsx)(w.span,{className:Q.glyph,style:{y:i,opacity:a,filter:s,visibility:o},children:t})}var Xe={initial:{width:0,opacity:0},animate:{width:`auto`,opacity:1},exit:{width:0,opacity:0}};function Ze({digit:t,direction:r,armed:i,delay:a,reduceMotion:o}){let s=c(i?0:t),l=(0,W.useRef)({digit:i?0:t,target:i?0:t,revealed:!i});return(0,W.useEffect)(()=>{let c=l.current;if(i||c.digit===t){i||(c.revealed=!0);return}c.target+=r<0&&c.revealed?-((c.digit-t+10)%10):(t-c.digit+10)%10,c.digit=t,o?s.jump(c.target):e(s,c.target,c.revealed?n.spring.smooth:{...qe,delay:a}),c.revealed=!0},[i,a,t,r,s,o]),(0,K.jsxs)(w.span,{className:Q.column,...Xe,transition:o?{duration:0}:n.spring.morph,children:[(0,K.jsx)(`span`,{className:Q.sizer,children:`0`}),We.map(e=>(0,K.jsx)(Ye,{position:s,digit:e},e))]})}function Qe({value:e,label:t,prefix:r=``,suffix:i=``,decimals:a=0,animateOnView:o=!1,locale:s=`en-US`}){let c=(0,W.useRef)(null),u=me(c,{once:!0,amount:.6}),d=!!C(),[f,p]=(0,W.useState)(e),[m,h]=(0,W.useState)(1);e!==f&&(p(e),h(e>f?1:-1));let g=Je(e,a,s),_=`${r}${g.map(e=>`text`in e?e.text:e.digit).join(``)}${i}`,v=o&&!u;return(0,K.jsxs)(`span`,{ref:c,className:Q.counter,children:[t&&(0,K.jsx)(`span`,{className:Q.label,children:(0,K.jsx)(`span`,{className:Q.labelSwap,children:(0,K.jsx)(l,{mode:`popLayout`,initial:!1,children:(0,K.jsx)(w.span,{className:Q.labelText,variants:d?Ke:Ge,initial:`hidden`,animate:`shown`,exit:`gone`,children:t},t)})})}),(0,K.jsx)(`span`,{className:Q.srOnly,children:_}),(0,K.jsxs)(`span`,{className:Q.value,"aria-hidden":`true`,children:[r&&(0,K.jsx)(`span`,{className:Q.symbol,children:r}),(0,K.jsx)(l,{initial:!1,children:g.map(e=>`digit`in e?(0,K.jsx)(Ze,{digit:e.digit,direction:m,armed:v,delay:Math.min(e.order*n.stagger.item,.25),reduceMotion:d},e.key):(0,K.jsx)(w.span,{className:Q.symbol,...Xe,transition:d?{duration:0}:n.spring.morph,children:e.text},e.key))}),i&&(0,K.jsx)(`span`,{className:Q.symbol,children:i})]})]})}var $={card:`_card_1r6t9_1`,top:`_top_1r6t9_2`,swap:`_swap_1r6t9_8`,swapBlock:`_swapBlock_1r6t9_8`,text:`_text_1r6t9_11`,sizer:`_sizer_1r6t9_13`},$e={hidden:e=>({opacity:0,y:`${.3*e}em`,filter:`blur(${n.blur.soft}px)`}),shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.standard,ease:[...n.ease.enter]}},gone:e=>({opacity:0,y:`${-.3*e}em`,filter:`blur(${n.blur.subtle}px)`,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}})},et={hidden:{opacity:0,y:0,filter:`blur(0px)`},shown:{opacity:1,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}},gone:{opacity:0,y:0,filter:`blur(0px)`,transition:{duration:n.duration.instant}}},tt=e=>Number(e.replace(/,/g,``).match(/-?\d+(?:\.\d+)?/)?.[0]??NaN);function nt({text:t,morph:r=!1,block:i=!1}){let a=!!C(),o=(0,W.useRef)(null),s=c(`auto`),[u,d]=(0,W.useState)({text:t,direction:1});return u.text!==t&&d({text:t,direction:tt(t)<tt(u.text)?-1:1}),(0,W.useEffect)(()=>{let t=o.current;if(!t||typeof ResizeObserver>`u`)return;let r=null,i=new ResizeObserver(([i])=>{let o=i.borderBoxSize?.[0]?.inlineSize??t.offsetWidth;o&&r!==null&&r!==t.textContent&&!a?e(s,o,n.spring.morph):s.jump(o||`auto`),r=o?t.textContent:null});return i.observe(t),()=>i.disconnect()},[r,a,s]),(0,K.jsxs)(w.span,{className:i?$.swapBlock:$.swap,style:r?{width:s}:void 0,children:[r&&(0,K.jsx)(`span`,{ref:o,className:$.sizer,"aria-hidden":`true`,children:t}),(0,K.jsx)(l,{mode:`popLayout`,initial:!1,custom:u.direction,children:(0,K.jsx)(w.span,{className:$.text,custom:u.direction,variants:a?et:$e,initial:`hidden`,animate:`shown`,exit:`gone`,children:t},t)})]})}function rt({label:e,value:t,suffix:r,context:i,change:a}){let o=!!C();return(0,K.jsxs)(`article`,{className:$.card,children:[(0,K.jsxs)(`div`,{className:$.top,children:[(0,K.jsx)(`span`,{children:(0,K.jsx)(nt,{text:e,block:!0})}),(0,K.jsx)(l,{initial:!1,children:a&&(0,K.jsx)(w.small,{"data-trend":/^[+]/.test(a)?`up`:/^[-−]/.test(a)?`down`:void 0,initial:{opacity:0,scale:o?1:.96},animate:{opacity:1,scale:1},exit:{opacity:0,scale:o?1:.96,transition:{duration:n.duration.fast,ease:[...n.ease.standard]}},transition:o?{duration:0}:n.spring.snappy,children:(0,K.jsx)(nt,{text:a,morph:!0})},`change`)})]}),(0,K.jsx)(Qe,{value:t,suffix:r,animateOnView:!0}),(0,K.jsx)(`p`,{children:(0,K.jsx)(nt,{text:i,block:!0})})]})}var it=[{id:`ipv4-all`,nameKey:`settings.privacy.template.ipv4All`,hintKey:`settings.privacy.template.ipv4AllHint`,pattern:String.raw`(?<![\d.])(?:\d{1,3}\.){3}\d{1,3}(?![\d.])`},{id:`landline`,nameKey:`settings.privacy.template.landline`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<!\d)0\d{2,3}[- ]?\d{7,8}(?!\d)`},{id:`license-plate`,nameKey:`settings.privacy.template.licensePlate`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领][A-HJ-NP-Z][A-HJ-NP-Z0-9]{4,5}[A-HJ-NP-Z0-9挂学警港澳]`},{id:`passport-cn`,nameKey:`settings.privacy.template.passportCn`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])[EG]\d{8}(?!\d)`},{id:`uscc`,nameKey:`settings.privacy.template.uscc`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-HJ-NPQRTUWXY])[0-9A-HJ-NPQRTUWXY]{18}(?![0-9A-HJ-NPQRTUWXY])`},{id:`long-token`,nameKey:`settings.privacy.template.longToken`,hintKey:`settings.privacy.template.longTokenHint`,pattern:String.raw`(?<![A-Za-z0-9])[A-Za-z0-9_\-]{32,}(?![A-Za-z0-9])`},{id:`mac-address`,nameKey:`settings.privacy.template.macAddress`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![0-9A-Fa-f:])(?:[0-9A-Fa-f]{2}:){5}[0-9A-Fa-f]{2}(?![0-9A-Fa-f:])`},{id:`unix-home`,nameKey:`settings.privacy.template.unixHome`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`/(?:Users|home)/[A-Za-z0-9_.\-]+`},{id:`windows-profile`,nameKey:`settings.privacy.template.windowsProfile`,hintKey:`settings.privacy.template.unixHomeHint`,pattern:String.raw`[A-Za-z]:\\+Users\\+[A-Za-z0-9_.\-]+`},{id:`cloud-accesskey`,nameKey:`settings.privacy.template.cloudAccessKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:LTAI[A-Za-z0-9]{12,20}|AKID[A-Za-z0-9]{13,40})(?![A-Za-z0-9])`},{id:`aws-secret-key`,nameKey:`settings.privacy.template.awsSecretKey`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9/+=])[A-Za-z0-9/+=]{40}(?![A-Za-z0-9/+=])`},{id:`im-webhook`,nameKey:`settings.privacy.template.imWebhook`,hintKey:`settings.privacy.template.imWebhookHint`,pattern:String.raw`oapi\.dingtalk\.com/robot/send\?access_token=[0-9a-f]{64}|qyapi\.weixin\.qq\.com/cgi-bin/webhook/send\?key=[0-9a-f]{32}|open\.feishu\.cn/open-apis/bot/v2/hook/[0-9a-f\-]{20,}|hooks\.slack\.com/services/T[A-Za-z0-9]+/B[A-Za-z0-9]+/[A-Za-z0-9]+`},{id:`internal-service`,nameKey:`settings.privacy.template.internalService`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:gitlab|jenkins|jira|confluence|wiki|nexus|harbor|grafana|kibana|sonarqube|oa|sso)\.[A-Za-z0-9\-]+(?:\.[A-Za-z0-9\-]+)+`},{id:`jdbc-conn`,nameKey:`settings.privacy.template.jdbcConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`jdbc:[A-Za-z0-9]+:[^\s"']*(?:[Uu]ser(?:[ _]?[Ii][Dd])?|[Pp]assword)=[^\s"&';]+`},{id:`smtp-conn`,nameKey:`settings.privacy.template.smtpConn`,hintKey:`settings.privacy.template.jdbcHint`,pattern:String.raw`(?:smtp|imap|pop3)s?://[^\s:@/]+:[^\s@]+@[^\s]+`},{id:`key-file-ref`,nameKey:`settings.privacy.template.keyFileRef`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`[A-Za-z0-9_\-./\\]+\.(?:pem|key|pfx|p12|jks|keystore)\b`},{id:`confidential-marker`,nameKey:`settings.privacy.template.confidentialMarker`,hintKey:`settings.privacy.template.confidentialHint`,pattern:String.raw`(?:绝密|机密|商业秘密|内部资料|内部公开|仅限内部|请勿外传|Confidential|Internal Use Only|Internal Only|Company Private)`},{id:`employee-id`,nameKey:`settings.privacy.template.employeeId`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?<![A-Za-z0-9])(?:[Ee][Mm][Pp]|工号)[::\- ]?\d{4,10}(?!\d)`},{id:`labeled-number`,nameKey:`settings.privacy.template.labeledNumber`,hintKey:`settings.privacy.template.genericHint`,pattern:String.raw`(?:合同|订单|采购单|工单|项目)编号[::]?\s*[A-Za-z0-9_\-]{4,32}`}],at=[`off`,`warn`,`block`,`redact`],ot=Fe;function st(){let{t:e}=k(),{toast:t}=I(),n=o(),r=O(),i=n.data?.settings,a=e=>{i&&r.mutate({...i,...e},{onError:e=>t(F(e),`error`)})},s=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])}));return(0,K.jsxs)(j,{title:e(`settings.privacy`),footer:e(`settings.privacy.footer`),children:[n.isLoading&&(0,K.jsx)(M,{className:`my-4`}),n.isError&&(0,K.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--danger)]`,children:F(n.error)}),i&&(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(E,{label:e(`settings.privacy.enabled`),detail:e(`settings.privacy.enabledHint`),children:(0,K.jsx)(P,{checked:i.enabled,label:e(`settings.privacy.enabled`),onChange:e=>a({enabled:e})})}),(0,K.jsx)(E,{label:e(`settings.privacy.dryRun`),detail:e(`settings.privacy.dryRunHint`),children:(0,K.jsx)(P,{checked:i.dryRun,disabled:!i.enabled,label:e(`settings.privacy.dryRun`),onChange:e=>a({dryRun:e})})}),(0,K.jsx)(E,{label:e(`settings.privacy.restore`),detail:e(`settings.privacy.restoreHint`),children:(0,K.jsx)(P,{checked:i.restoreResponses,disabled:!i.enabled,label:e(`settings.privacy.restore`),onChange:e=>a({restoreResponses:e})})}),(0,K.jsx)(E,{label:e(`settings.privacy.recordSamples`),detail:e(`settings.privacy.recordSamplesHint`),children:(0,K.jsx)(P,{checked:i.recordSamples,disabled:!i.enabled,label:e(`settings.privacy.recordSamples`),onChange:e=>a({recordSamples:e})})}),(0,K.jsx)(E,{label:e(`settings.privacy.defaultAction`),children:(0,K.jsx)(L,{className:`w-36`,ariaLabel:e(`settings.privacy.defaultAction`),value:i.defaultAction,disabled:!i.enabled,onChange:e=>a({defaultAction:e}),options:s})})]})]})}function ct(){let{t:e}=k(),{toast:t}=I(),n=o(),r=O(),i=n.data?.settings,a=Ie(),s=e=>{i&&r.mutate({...i,...e},{onError:e=>t(F(e),`error`)})},c=(e,t)=>s({categoryActions:{...i?.categoryActions,[e]:t}}),l=at.map(t=>({value:t,label:e(t===`off`?`settings.privacy.action.off`:ot[t])})),u=[...new Set((n.data?.rules??[]).map(e=>e.category))],d=e=>n.data?.rules.find(t=>t.category===e)?.description;return n.isLoading?(0,K.jsx)(`div`,{className:`mx-auto max-w-[720px]`,children:(0,K.jsx)(M,{className:`my-4`})}):i?(0,K.jsxs)(`div`,{className:`mx-auto flex max-w-[720px] flex-col gap-4`,children:[(0,K.jsx)(j,{title:e(`settings.privacy.categories`),children:u.map(t=>{let n=i.categoryActions[t]??i.defaultAction,r=!i.enabled||n===`off`;return(0,K.jsxs)(E,{label:a(t),detail:d(t),children:[n===`off`?(0,K.jsx)(D,{children:e(`settings.privacy.action.off`)}):(0,K.jsx)(L,{className:`w-36`,ariaLabel:a(t),value:n,disabled:!i.enabled,onChange:e=>c(t,e),options:l.filter(e=>e.value!==`off`)}),r&&(0,K.jsx)(A,{size:`sm`,variant:`plain`,disabled:!i.enabled,onClick:()=>c(t,i.categoryActions[t]??i.defaultAction),children:e(`settings.privacy.enableCategory`)})]},t)})}),(0,K.jsx)(lt,{s:i,onPatch:s})]}):null}function lt({s:e,onPatch:t}){let{t:n}=k(),{confirm:r}=I(),[i,a]=(0,W.useState)(!1),o=(n,r)=>t({customRules:e.customRules.map(e=>e.id===n.id?{...e,enabled:r}:e)}),s=async i=>{await r({title:n(`settings.privacy.deleteRuleConfirm`,{name:i.name}),destructive:!0,confirmLabel:n(`common.delete`)})&&t({customRules:e.customRules.filter(e=>e.id!==i.id)})};return(0,K.jsxs)(j,{title:n(`settings.privacy.customRules`),children:[e.customRules.length===0&&(0,K.jsx)(`div`,{className:`px-4 py-4 text-[12px] text-[var(--text-secondary)]`,children:n(`settings.privacy.noCustomRules`)}),e.customRules.map(t=>(0,K.jsxs)(E,{label:t.name,detail:t.pattern,children:[(0,K.jsx)(P,{checked:t.enabled,disabled:!e.enabled,label:t.name,onChange:e=>o(t,e)}),(0,K.jsx)(A,{size:`sm`,variant:`plain`,icon:(0,K.jsx)(se,{className:`size-3.5`}),"aria-label":`${n(`common.delete`)} ${t.name}`,onClick:()=>void s(t)})]},t.id)),(0,K.jsx)(`div`,{className:`px-4 py-2`,children:(0,K.jsx)(A,{size:`sm`,icon:(0,K.jsx)(le,{className:`size-3.5`}),disabled:!e.enabled,onClick:()=>a(!0),children:n(`settings.privacy.addRule`)})}),(0,K.jsx)(ut,{open:i,onOpenChange:a,onAdd:n=>t({customRules:[...e.customRules,n]})})]})}function ut({open:e,onOpenChange:t,onAdd:n}){let{t:r}=k(),{toast:i}=I(),[a,o]=(0,W.useState)(``),[s,c]=(0,W.useState)(``),[l,u]=(0,W.useState)(``);return(0,K.jsx)(ne,{open:e,onOpenChange:t,title:r(`settings.privacy.addRule`),width:480,footer:(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(A,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,K.jsx)(A,{variant:`primary`,disabled:!a.trim()||!s.trim(),onClick:()=>{if(a.trim()&&s.trim()){try{new RegExp(s)}catch(e){i(`${r(`settings.privacy.invalidPattern`)}: ${F(e)}`,`error`);return}n({id:`custom-${Date.now().toString(36)}`,name:a.trim(),pattern:s.trim(),enabled:!0}),o(``),c(``),u(``),t(!1)}},children:r(`common.create`)})]}),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,K.jsx)(T,{label:r(`settings.privacy.ruleTemplates`),hint:r(`settings.privacy.ruleTemplatesHint`),children:(0,K.jsx)(L,{ariaLabel:r(`settings.privacy.ruleTemplates`),value:l,onChange:e=>{u(e);let t=it.find(t=>t.id===e);t&&(o(r(t.nameKey)),c(t.pattern))},options:[{value:``,label:r(`settings.privacy.ruleTemplateNone`)},...it.map(e=>({value:e.id,label:r(e.nameKey)}))]})}),(0,K.jsx)(y,{label:r(`settings.privacy.ruleName`),value:a,onChange:e=>o(e.target.value),autoFocus:!0}),(0,K.jsx)(T,{label:r(`settings.privacy.rulePattern`),hint:r(`settings.privacy.rulePatternHint`),children:(0,K.jsx)(g,{mono:!0,rows:3,value:s,onChange:e=>c(e.target.value)})})]})})}function dt(){let{t:e}=k(),{toast:t}=I(),n=Ie(),r=o(),i=f(),[a,s]=(0,W.useState)(``),c=i.data,l=r.data?.settings.enabled??!1;return(0,K.jsx)(j,{title:e(`settings.privacy.tester`),footer:e(`settings.privacy.testerHint`),children:(0,K.jsxs)(`div`,{className:`flex flex-col gap-3 px-4 py-3`,children:[(0,K.jsx)(g,{"aria-label":e(`settings.privacy.tester`),placeholder:e(`settings.privacy.testerPlaceholder`),rows:4,mono:!0,value:a,onChange:e=>s(e.target.value)}),(0,K.jsx)(`div`,{children:(0,K.jsx)(A,{icon:(0,K.jsx)(B,{className:`size-3.5`}),disabled:!l||!a.trim(),loading:i.isPending,onClick:()=>i.mutate({text:a},{onError:e=>t(F(e),`error`)}),children:e(`settings.privacy.runTest`)})}),c&&(0,K.jsxs)(`div`,{className:`rounded-lg border border-[var(--border)] px-3 py-2 text-[12px]`,children:[(0,K.jsxs)(`div`,{className:`flex items-center gap-2`,children:[c.blocked&&(0,K.jsx)(D,{tone:`red`,children:e(`settings.privacy.wouldBlock`)}),c.wouldRedact>0&&(0,K.jsx)(D,{tone:`orange`,children:e(`settings.privacy.wouldRedact`,{count:c.wouldRedact})}),!c.blocked&&c.wouldRedact===0&&(0,K.jsx)(D,{tone:`green`,children:e(`settings.privacy.noHits`)})]}),c.hits.length>0&&(0,K.jsx)(`ul`,{className:`mt-2 space-y-1`,children:c.hits.map(t=>(0,K.jsxs)(`li`,{className:`flex flex-wrap items-center gap-2`,children:[(0,K.jsx)(D,{tone:t.action===`block`?`red`:t.action===`redact`?`orange`:`neutral`,children:e(ot[t.action])}),(0,K.jsxs)(`span`,{children:[n(t.category),` · `,t.ruleId,` × `,t.count]}),t.samples&&t.samples.length>0&&(0,K.jsx)(`span`,{className:`font-mono text-[11px] text-[var(--text-muted)]`,children:t.samples.join(` `)})]},`${t.ruleId}:${t.action}`))})]})]})})}var ft=[`today`,`7d`,`30d`,`all`];function pt(){let{t:e}=k(),t=Ie(),[n,r]=(0,W.useState)(`7d`),i=d(n),a=i.data,o=[{key:`category`,label:e(`privacy.stats.col.category`),render:e=>t(String(e))},{key:`requests`,label:e(`privacy.stats.col.requests`),numeric:!0,width:110},{key:`hits`,label:e(`privacy.stats.col.hits`),numeric:!0,width:96},{key:`warnHits`,label:e(`privacy.stats.col.warn`),numeric:!0,width:84},{key:`blockHits`,label:e(`privacy.stats.col.block`),numeric:!0,width:84},{key:`redactHits`,label:e(`privacy.stats.col.redact`),numeric:!0,width:84}],s=(a?.categories??[]).map(e=>({...e}));return(0,K.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,K.jsxs)(`section`,{children:[(0,K.jsx)(b,{action:(0,K.jsx)(m,{ariaLabel:e(`overview.range`),value:n,onChange:r,items:ft.map(t=>({value:t,label:e(`range.${t}`)}))}),children:e(`privacy.stats`)}),i.isLoading&&(0,K.jsx)(M,{lines:3,className:`py-4`}),i.isError&&(0,K.jsx)(te,{tone:`danger`,title:e(`common.error`),children:F(i.error)}),a&&(0,K.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[(0,K.jsx)(rt,{label:e(`privacy.stats.events`),value:a.events,context:e(`range.${n}`)}),(0,K.jsx)(rt,{label:e(`privacy.stats.blocked`),value:a.blocked,context:e(`range.${n}`)}),(0,K.jsx)(rt,{label:e(`privacy.stats.redactions`),value:a.redactions,context:e(`range.${n}`)}),(0,K.jsx)(rt,{label:e(`privacy.stats.dryRun`),value:a.dryRun,context:e(`range.${n}`)})]})]}),(0,K.jsxs)(`section`,{children:[(0,K.jsx)(b,{children:e(`privacy.stats.byCategory`)}),a&&a.categories.length===0&&(0,K.jsx)(`div`,{className:`card`,children:(0,K.jsx)(mt,{})}),a&&a.categories.length>0&&(0,K.jsx)(R,{caption:e(`privacy.stats.byCategory`),rows:s,columns:o,rowKey:`category`,defaultSort:{key:`hits`,direction:`desc`}})]}),(0,K.jsx)(`div`,{className:`mx-auto w-full max-w-[720px]`,children:(0,K.jsx)(st,{})})]})}function mt(){let{t:e}=k();return(0,K.jsxs)(`div`,{className:`flex flex-col items-center gap-2 px-4 py-8 text-center`,children:[(0,K.jsx)(B,{className:`size-6 text-[var(--text-muted)]`}),(0,K.jsx)(`div`,{className:`text-[13px]`,children:e(`privacy.logs.empty`)}),(0,K.jsx)(`div`,{className:`text-[12px] text-[var(--text-secondary)]`,children:e(`privacy.logs.empty.detail`)})]})}var ht=[`overview`,`logs`,`rules`,`tester`];function gt(){let{t:e}=k(),{tab:t}=ce(),n=de(),r=ht.includes(t)?t:`overview`;return(0,K.jsx)(he,{title:e(`nav.privacy`),subtitle:e(`settings.privacy.footer`),children:(0,K.jsxs)(re,{value:r,onValueChange:e=>n(`/privacy/${e}`,{replace:!0}),children:[(0,K.jsx)(V,{"aria-label":e(`nav.privacy`),children:ht.map(t=>(0,K.jsx)(z,{value:t,children:e(`privacy.tab.${t}`)},t))}),(0,K.jsx)(U,{value:`overview`,className:`pt-5`,children:(0,K.jsx)(pt,{})}),(0,K.jsx)(U,{value:`logs`,className:`pt-4`,children:(0,K.jsx)(Be,{})}),(0,K.jsx)(U,{value:`rules`,className:`pt-5`,children:(0,K.jsx)(ct,{})}),(0,K.jsx)(U,{value:`tester`,className:`pt-5 [&>div]:mx-auto [&>div]:max-w-[680px]`,children:(0,K.jsx)(dt,{})})]})})}export{gt as PrivacyPage};
|
package/bin/wwwroot/assets/{ProviderDetailPage-uLPHWm2i.js → ProviderDetailPage-DWy8CIbx.js}
RENAMED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{$n as e,An as t,B as n,Bn as r,Ca as i,Ct as a,Dr as o,Dt as s,Ea as c,Fr as l,Ft as u,Hn as d,Jt as f,Mn as p,Mr as m,Nn as h,Ot as g,Pn as _,Pr as v,Qn as y,Rn as ee,Rr as te,Sa as ne,Tn as re,Tt as ie,V as b,Vn as x,Wn as ae,_ as S,_n as oe,a as se,ai as C,an as ce,b as le,c as w,ci as ue,ct as de,d as T,er as fe,f as E,fn as pe,ft as me,gi as he,gn as ge,h as _e,hr as ve,i as ye,ii as be,in as xe,it as D,jr as Se,jt as O,l as k,m as A,n as j,nt as Ce,or as we,ot as M,p as N,pt as Te,qn as P,qt as Ee,r as F,ri as De,rn as I,sr as Oe,t as L,tt as ke,u as R,un as Ae,ur as je,v as z,vn as Me,vt as B,wn as Ne,wt as Pe,xa as Fe,y as V}from"./alert-
|
|
1
|
+
import{$n as e,An as t,B as n,Bn as r,Ca as i,Ct as a,Dr as o,Dt as s,Ea as c,Fr as l,Ft as u,Hn as d,Jt as f,Mn as p,Mr as m,Nn as h,Ot as g,Pn as _,Pr as v,Qn as y,Rn as ee,Rr as te,Sa as ne,Tn as re,Tt as ie,V as b,Vn as x,Wn as ae,_ as S,_n as oe,a as se,ai as C,an as ce,b as le,c as w,ci as ue,ct as de,d as T,er as fe,f as E,fn as pe,ft as me,gi as he,gn as ge,h as _e,hr as ve,i as ye,ii as be,in as xe,it as D,jr as Se,jt as O,l as k,m as A,n as j,nt as Ce,or as we,ot as M,p as N,pt as Te,qn as P,qt as Ee,r as F,ri as De,rn as I,sr as Oe,t as L,tt as ke,u as R,un as Ae,ur as je,v as z,vn as Me,vt as B,wn as Ne,wt as Pe,xa as Fe,y as V}from"./alert-BzjF81CS.js";import{a as H,i as U,n as Ie,o as W,r as G}from"./overlays-8ByMRpma.js";import{a as Le,i as K,n as q,o as J,t as Re}from"./ProvidersPage-CeisTEUC.js";import{t as ze}from"./arrow-down-BjT6LDhw.js";import{t as Be}from"./arrow-left-Bv8IR_At.js";import{t as Ve}from"./cloud-download-B7vzhwxM.js";import{t as He}from"./download-CI3oqkmw.js";import{t as Ue}from"./ellipsis-Br3iFNj9.js";import{t as We}from"./external-link-LUcufY2s.js";import{n as Ge}from"./radio-cards-CWiI0xhT.js";import{t as Ke}from"./log-out-Ggrqw-Tp.js";import{t as qe}from"./power-BJvJ4uzr.js";import{t as Je}from"./rotate-ccw-CqwU1cME.js";import{B as Ye,C as Xe,E as Ze,G as Qe,K as Y,N as X,Q as $e,R as et,T as tt,Z as nt,_ as Z,a as rt,h as it,o as at,s as ot,w as st}from"./index-D7HIE1TG.js";import{t as ct}from"./checkbox-DQpzihMp.js";import{t as lt}from"./confirm-morph-BOdW6fKN.js";var ut={name:`arrow-right-left`,size:24,node:[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]};ut.node;var dt=B(ut),ft={name:`gift`,size:24,node:[[`path`,{d:`M12 7v14`,key:`1akyts`}],[`path`,{d:`M20 11v8a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-8`,key:`1sqzm4`}],[`path`,{d:`M7.5 7a1 1 0 0 1 0-5A4.8 8 0 0 1 12 7a4.8 8 0 0 1 4.5-5 1 1 0 0 1 0 5`,key:`kc0143`}],[`rect`,{x:`3`,y:`7`,width:`18`,height:`4`,rx:`1`,key:`1hberx`}]]};ft.node;var pt=B(ft),mt={name:`list-plus`,size:24,node:[[`path`,{d:`M16 5H3`,key:`m91uny`}],[`path`,{d:`M11 12H3`,key:`51ecnj`}],[`path`,{d:`M16 19H3`,key:`zzsher`}],[`path`,{d:`M18 9v6`,key:`1twb98`}],[`path`,{d:`M21 12h-6`,key:`bt1uis`}]]};mt.node;var ht=B(mt),gt={name:`log-in`,size:24,node:[[`path`,{d:`m10 17 5-5-5-5`,key:`1bsop3`}],[`path`,{d:`M15 12H3`,key:`6jk70r`}],[`path`,{d:`M15 3h4a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2h-4`,key:`u53s6r`}]]};gt.node;var _t=B(gt),vt={name:`plug`,size:24,node:[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]};vt.node;var yt=B(vt),bt={name:`sparkles`,size:24,node:[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]],aliases:[`stars`]};bt.node;var xt=B(bt),St={name:`ticket`,size:24,node:[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]};St.node;var Ct=B(St),Q=c(i(),1),$=ne(),wt={imported:`providers.subscription.importBatchStatus.imported`,updated:`providers.subscription.importBatchStatus.updated`,duplicate:`providers.subscription.importBatchStatus.duplicate`,invalid_format:`providers.subscription.importBatchStatus.invalid_format`,failed:`providers.subscription.importBatchStatus.failed`,ready:`providers.subscription.importBatchStatus.ready`},Tt={imported:`green`,updated:`accent`,ready:`accent`,duplicate:`neutral`,invalid_format:`orange`,failed:`red`},Et={batch:`providers.accounts.import.batchTitle`,token:`providers.accounts.import.tokenTitle`,apiKey:`providers.accounts.import.apiKeyTitle`};function Dt(e){return e.split(/[,\s]+/).flatMap(e=>{let t=e.replace(/^["']+|["']+$/g,``);return t.startsWith(`tid=`)||t.startsWith(`exp=`)?[t]:t.split(`;`)}).filter(e=>e.replace(/^["']+|["']+$/g,``).length>0).length}function Ot(e){let t=e.trim();if(t.length===0)return 0;if(t.startsWith(`{`)||t.startsWith(`[`))try{let e=JSON.parse(t);if(Array.isArray(e))return e.filter(e=>typeof e==`object`&&!!e||typeof e==`string`&&e.trim().length>0).length;if(typeof e==`object`&&e)return 1}catch{}let n=0;for(let t of e.split(`
|
|
2
2
|
`)){let e=t.trim();e.length===0||e.startsWith(`#`)||(n+=e.startsWith(`{`)?1:Dt(e))}return n}function kt({providerId:e,info:t,mode:n,providerProxy:r,onClose:i}){let{t:a}=M(),{toast:o}=W(),s=ge(e),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(null),m=(0,Q.useMemo)(()=>Ot(c),[c]);if((0,Q.useEffect)(()=>{n!==null&&(l(``),p(null))},[n]),n===null)return(0,$.jsx)(U,{open:!1,onOpenChange:i,title:``});let h=n===`apiKey`,g=h?t.formats.filter(e=>e.endsWith(`-api-key`)):t.formats,_=!h&&t.formats.some(e=>e.includes(`refresh-token`)||e.endsWith(`-json`)),v=a(h?`providers.accounts.import.apiKeyLabel`:`providers.accounts.import.label`),y=e=>s.mutate({text:c,asApiKey:h||void 0,dryRun:e||void 0,httpProxy:u.trim()||void 0},{onSuccess:t=>{p({...t,dryRun:e}),!e&&(o(a(`providers.accounts.import.summary`,{ok:t.imported,dup:t.duplicates,fail:t.failed}),t.failed>0?`info`:`success`),!(t.failed>0)&&(n===`batch`?l(``):i()))},onError:e=>o(H(e),`error`)});return(0,$.jsx)(U,{open:!0,onOpenChange:e=>!e&&i(),title:a(Et[n]),description:a(`providers.accounts.import.desc`),width:560,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[g.length>0&&(0,$.jsx)(`p`,{className:`text-[11.5px] text-[var(--text-secondary)]`,children:a(`providers.accounts.import.formats`,{formats:g.map(e=>a(`providers.accounts.format.${e}`)).join(` · `)})}),(0,$.jsx)(le,{mono:!0,rows:n===`batch`?8:3,value:c,onChange:e=>l(e.target.value),"aria-label":v,placeholder:v,spellCheck:!1}),(0,$.jsx)(T,{mono:!0,label:a(`providers.accounts.import.proxy`),placeholder:r||a(`providers.accounts.proxyFallbackSystem`),value:u,onChange:e=>d(e.target.value)}),_&&(0,$.jsx)(L,{tone:`info`,title:a(`providers.accounts.import.rotateWarning`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`providers.accounts.import.count`,{n:m})}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[n===`batch`&&(0,$.jsx)(F,{disabled:m===0,loading:s.isPending&&s.variables?.dryRun===!0,onClick:()=>y(!0),children:a(`providers.accounts.import.preview`)}),(0,$.jsx)(F,{variant:`primary`,disabled:m===0||m>t.maxBatch,loading:s.isPending&&!s.variables?.dryRun,onClick:()=>y(!1),children:a(`providers.accounts.import.run`)})]})]}),f&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`div`,{className:`text-[12px] font-medium`,children:a(f.dryRun?`providers.accounts.import.previewSummary`:`providers.accounts.import.summary`,{ok:f.imported,dup:f.duplicates,fail:f.failed})}),(0,$.jsx)(`ul`,{className:`card max-h-72 divide-y divide-[var(--border)] overflow-auto`,children:f.items.map(e=>(0,$.jsxs)(`li`,{className:`flex items-start gap-2 px-3 py-1.5 text-[12px]`,children:[(0,$.jsx)(`span`,{className:`w-6 shrink-0 text-[var(--text-muted)]`,children:e.index}),(0,$.jsx)(`span`,{className:`selectable w-28 shrink-0 truncate font-mono`,children:e.source}),(0,$.jsx)(j,{tone:Tt[e.status],children:a(wt[e.status])}),e.kind&&(0,$.jsx)(`span`,{className:`shrink-0 text-[11px] text-[var(--text-muted)]`,children:a(`providers.accounts.credential.${e.kind}`)}),(0,$.jsx)(`span`,{className:`selectable min-w-0 flex-1 break-words text-[var(--text-secondary)]`,children:e.account?.displayName&&(e.status===`imported`||e.status===`updated`)?`${e.account.displayName}${e.message?` · ${e.message}`:``}`:e.message??``})]},e.index))})]})]})})}function At(e,t=Date.now()){return e.enabled?e.status===`active`?e.cooldownUntilUtc&&new Date(e.cooldownUntilUtc).getTime()>t?`cooling`:`usable`:`dead`:`disabled`}var jt={usable:`var(--success)`,cooling:`var(--warning)`,dead:`var(--danger)`,disabled:`var(--text-muted)`},Mt={active:`providers.subscription.status.active`,expired:`providers.subscription.status.expired`,revoked:`providers.subscription.status.revoked`};function Nt(e,t){let n=(e??``).toLowerCase(),r=t?`110,115,135`:/max|ultra/.test(n)?`47,124,246`:/pro|plus|premium/.test(n)?`52,195,143`:/team|business|enterprise|allegro|vivace/.test(n)?`130,100,230`:`110,115,135`;return`linear-gradient(135deg, rgba(${r},.34), rgba(${r},.08))`}function Pt({account:e,index:t,actions:n,selected:r,selecting:i,onToggleSelect:a,onMove:o,quotaPending:s}){let{t:c,locale:l}=M(),u=At(e),d=e.displayName||e.accountEmail||e.keyMasked||e.id,f=e.kind===`api_key`,p=e.plan?.trim(),m=u===`cooling`?{text:c(`providers.subscription.cooldown`,{when:b(e.cooldownUntilUtc,l)}),tone:`var(--warning)`}:u===`dead`?{text:e.lastError||c(Mt[e.status]),tone:`var(--danger)`}:f?{text:e.keyMasked??c(`providers.accounts.neverExpires`),tone:void 0}:e.expiresAtUtc?{text:c(`providers.accounts.expiresAt`,{when:b(e.expiresAtUtc,l)}),tone:void 0}:null,h=[{id:`activate`,label:c(`providers.subscription.activate`),icon:(0,$.jsx)(dt,{className:`size-3.5`}),disabled:e.isCurrent||u===`dead`,onSelect:()=>n.activate(e)},{id:`toggle`,label:c(e.enabled?`providers.subscription.disable`:`providers.subscription.enable`),icon:(0,$.jsx)(qe,{className:`size-3.5`}),onSelect:()=>n.toggleEnabled(e)},...o?[{id:`up`,label:c(`providers.subscription.moveUp`),icon:(0,$.jsx)(Qe,{className:`size-3.5`}),disabled:!o.up,onSelect:()=>o.up?.()},{id:`down`,label:c(`providers.subscription.moveDown`),icon:(0,$.jsx)(ze,{className:`size-3.5`}),disabled:!o.down,onSelect:()=>o.down?.()}]:[],{id:`quota`,separatorBefore:!0,label:c(`providers.subscription.quotaRefresh`),icon:(0,$.jsx)(J,{className:`size-3.5`}),disabled:u===`dead`,onSelect:()=>n.refreshQuota(e)},...f?[]:[{id:`refresh`,label:c(`providers.subscription.refreshToken`),icon:(0,$.jsx)(Je,{className:`size-3.5`}),disabled:e.status===`revoked`,onSelect:()=>n.refreshToken(e)},{id:`relogin`,label:c(`providers.subscription.relogin`),disabled:e.status===`active`,onSelect:()=>n.relogin(e)}],{id:`remove`,label:c(`providers.subscription.logout`),icon:(0,$.jsx)(X,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>n.remove(e)}],g=c(u===`disabled`?`providers.subscription.disabled`:Mt[e.status]),_=c(f?`providers.accounts.kind.api_key`:`providers.accounts.kind.oauth`),v=e.quota?.session?.usedPercent!=null||e.quota?.weekly?.usedPercent!=null||e.quota?.credits?.usedPercent!=null;return(0,$.jsxs)(`div`,{"data-testid":`account-card`,className:D(`group card relative flex aspect-square min-w-0 cursor-pointer flex-col overflow-hidden transition-colors hover:bg-[var(--fill)]`,e.isCurrent&&`ring-1 ring-[var(--accent)]`,r&&`bg-[var(--accent-subtle)]`,u===`disabled`&&`opacity-55`),onClick:()=>i?a(e.id):n.open(e),children:[(0,$.jsxs)(`div`,{className:`relative shrink-0 px-3 pb-3 pt-2.5`,style:{background:Nt(p,f)},children:[(u===`cooling`||u===`dead`)&&(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-y-0 left-0 w-[3px]`,style:{background:jt[u]}}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:D(`flex size-5 items-center justify-center`,!i&&!r&&`hidden group-hover:flex`),onClick:e=>e.stopPropagation(),children:(0,$.jsx)(ct,{checked:r,onCheckedChange:()=>a(e.id),"aria-label":c(`providers.accounts.select`,{name:d})})}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(`span`,{role:`img`,"aria-label":g,className:`size-1.5 shrink-0 rounded-full`,style:{background:jt[u]}}),(0,$.jsx)(`span`,{"aria-hidden":!0,children:g})]}),e.httpProxy&&(0,$.jsx)(`span`,{title:`${c(`providers.accounts.proxyBadge`)}: ${e.httpProxy}`,className:`shrink-0 text-[var(--text-muted)]`,children:(0,$.jsx)(me,{className:`size-3.5`,"aria-label":c(`providers.accounts.proxyBadge`)})}),(0,$.jsx)(`span`,{className:`-mr-1.5 ml-auto shrink-0`,onClick:e=>e.stopPropagation(),children:(0,$.jsx)(Ie,{iconOnly:!0,label:c(`common.more`),icon:(0,$.jsx)(Ue,{className:`size-4`}),items:h})})]}),(0,$.jsx)(`div`,{className:`mt-1.5 truncate text-[17px] font-bold tracking-[.01em]`,title:p||_,children:p||_})]}),(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col px-3 pb-3 pt-2.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-[13px] font-medium outline-none focus-visible:underline`,title:d,onClick:t=>{t.stopPropagation(),i?a(e.id):n.open(e)},children:d}),(0,$.jsxs)(`div`,{className:`mt-0.5 flex min-w-0 items-center gap-1 whitespace-nowrap text-[11px] text-[var(--text-muted)]`,children:[e.isCurrent&&(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[var(--success)]`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`●`}),(0,$.jsx)(`span`,{children:c(`providers.subscription.current`)})]}),e.isCurrent&&(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`shrink-0`,children:_}),e.source&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,$.jsx)(`span`,{className:`truncate`,children:c(`providers.accounts.source.${e.source}`)})]}),(0,$.jsx)(`span`,{className:`ml-auto shrink-0 pl-1 opacity-0 group-hover:opacity-100`,children:c(`providers.accounts.order`,{n:t+1})})]}),m&&(u===`cooling`||u===`dead`||!v)&&(0,$.jsx)(`div`,{className:`mt-1.5 line-clamp-2 text-[11px] leading-snug`,style:{color:m.tone??`var(--text-muted)`},title:m.text,children:m.text}),u===`dead`?(0,$.jsxs)(`div`,{className:`mt-auto flex items-center gap-2 pt-2`,children:[(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:c(`providers.accounts.signedOut`)}),!f&&(0,$.jsx)(F,{size:`sm`,className:`ml-auto`,onClick:t=>{t.stopPropagation(),n.relogin(e)},children:c(`providers.subscription.relogin`)})]}):(0,$.jsx)(It,{quota:e.quota??null,pending:s})]})]})}var Ft=10;function It({quota:e,pending:t}){let{t:n,locale:r}=M(),i=[];return e?.session?.usedPercent!=null&&i.push({key:`session`,label:e.session.windowMinutes?`${Math.round(e.session.windowMinutes/60)}h`:n(`providers.accounts.quotaShortSession`),percent:e.session.usedPercent,reset:e.session.resetsAtUtc}),e?.weekly?.usedPercent!=null&&i.push({key:`weekly`,label:n(`providers.accounts.quotaShortWeekly`),percent:e.weekly.usedPercent,reset:e.weekly.resetsAtUtc}),i.length<2&&e?.credits?.usedPercent!=null&&i.push({key:`credits`,label:n(e.entitlement==null?`providers.accounts.quotaShortCredits`:`providers.accounts.quotaShortPremium`),percent:e.credits.usedPercent,reset:e.credits.resetsAtUtc}),i.length===0?null:(0,$.jsx)(`div`,{className:D(`mt-auto flex flex-col gap-2 pt-2`,t&&`opacity-60`),children:i.slice(0,2).map(e=>{let t=Math.max(0,Math.min(100,Math.round(e.percent))),i=t>=90?`var(--danger)`:t>=70?`var(--warning)`:`var(--accent)`,a=Math.round(t/100*Ft),o=e.reset?n(`providers.subscription.quotaResets`,{when:b(e.reset,r)}):void 0;return(0,$.jsxs)(`div`,{className:`min-w-0`,title:o,children:[(0,$.jsxs)(`div`,{className:`flex justify-between text-[11px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(`span`,{children:e.label}),(0,$.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[t,`%`]})]}),(0,$.jsx)(`div`,{role:`progressbar`,"aria-label":e.label,"aria-valuenow":t,"aria-valuemin":0,"aria-valuemax":100,className:`mt-0.5 flex gap-[3px]`,children:Array.from({length:Ft},(e,t)=>(0,$.jsx)(`i`,{className:`h-[5px] flex-1 rounded-[2px] bg-[var(--surface-muted)]`,style:t<a?{background:i}:void 0},t))})]},e.key)})})}function Lt({quota:e,className:t}){let{t:n,locale:r}=M(),i=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:n(`providers.subscription.quotaResets`,{when:t.toLocaleString(r)})},a=[];e.session?.usedPercent!=null&&a.push({key:`session`,label:n(`providers.subscription.quotaWindowSession`),window:e.session}),e.weekly?.usedPercent!=null&&a.push({key:`weekly`,label:n(`providers.subscription.quotaWindowWeekly`),window:e.weekly}),e.credits?.usedPercent!=null&&a.push({key:`credits`,label:e.entitlement==null?n(`providers.subscription.quotaWindowCredits`):n(`providers.subscription.quotaWindowPremium`),window:{usedPercent:e.credits.usedPercent,resetsAtUtc:e.credits.resetsAtUtc??null}});let o=e.credits?.prepaidBalance==null?null:n(`providers.subscription.quotaBalance`,{balance:e.credits.prepaidBalance}),s=e.entitlement!=null&&e.entitlement>=0?[n(`providers.subscription.quotaPremiumCount`,{used:Math.max(0,(e.entitlement??0)-(e.remaining??0)),total:e.entitlement}),e.overageUsed?n(`providers.subscription.quotaOverage`,{count:e.overageUsed}):null,e.overagePermitted===!1?n(`providers.subscription.quotaOverageOff`):null].filter(Boolean).join(` · `):null,c=e.planLabel??(e.fetchedAtUtc?n(`providers.subscription.quotaFetchedAt`,{when:new Date(e.fetchedAtUtc).toLocaleString(r)}):null);return(0,$.jsx)(`div`,{className:D(`px-4 py-1`,t),children:(0,$.jsxs)(`div`,{className:`card flex flex-col gap-3 p-3`,children:[(c||o)&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 text-[11px] text-[var(--text-secondary)]`,children:[c&&(0,$.jsx)(`span`,{children:c}),o&&(0,$.jsx)(`span`,{children:o})]}),a.length===0?(0,$.jsx)(`div`,{className:`text-[12px] text-[var(--text-muted)]`,children:n(`providers.subscription.quotaNoWindows`)}):a.map(e=>(0,$.jsx)(Rt,{label:e.label,window:e.window,reset:i(e.window.resetsAtUtc)},e.key)),s&&(0,$.jsx)(`div`,{className:`text-[10.5px] text-[var(--text-muted)]`,children:s})]})})}function Rt({label:e,window:t,reset:n}){let r=Math.max(0,Math.min(100,Math.round(t.usedPercent??0))),[i,a]=(0,Q.useState)(0);(0,Q.useEffect)(()=>{if(typeof matchMedia==`function`&&matchMedia(`(prefers-reduced-motion: reduce)`).matches){a(r);return}let e=requestAnimationFrame(()=>a(r));return()=>cancelAnimationFrame(e)},[r]);let o=r>=90?`var(--danger)`:r>=70?`var(--warning)`:`var(--accent)`,s=t.windowMinutes?Math.round(t.windowMinutes/60):null;return(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2 text-[11.5px]`,children:[(0,$.jsxs)(`span`,{className:`text-[var(--text-secondary)]`,children:[e,s!=null&&(0,$.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[` · `,s,`h`]})]}),(0,$.jsxs)(`span`,{className:`font-mono tabular-nums`,children:[r,`%`]})]}),(0,$.jsx)(`div`,{role:`progressbar`,"aria-valuenow":r,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e,className:`h-1.5 w-full overflow-hidden rounded-full bg-[var(--surface-muted)]`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-[width] duration-500 ease-out`,style:{width:`${i}%`,background:o}})}),n&&(0,$.jsx)(`div`,{className:`mt-1 text-[10.5px] text-[var(--text-muted)]`,children:n})]})}var zt={available:`green`,redeemed:`neutral`,expired:`orange`};function Bt({account:e,providerId:t}){let{t:n}=M(),{toast:r,confirm:i}=W(),a=ve(e.id,e.status===`active`),o=f(t),s=a.data?.credits??[],c=a.data?.available_count??s.filter(e=>e.status===`available`).length,l=async t=>{await i({title:n(`providers.subscription.credits.consumeConfirm`,{title:t.title??t.reset_type??``}),detail:n(`providers.subscription.credits.consumeDetail`),confirmLabel:n(`providers.subscription.credits.consume`),destructive:!0})&&o.mutate({accountId:e.id,creditId:t.id},{onSuccess:()=>r(n(`providers.subscription.credits.consumed`),`success`),onError:e=>r(e instanceof he&&e.status===409?H(e):`${n(`providers.subscription.credits.consumeFailed`)}:${H(e)}`,`error`)})};return(0,$.jsxs)(R,{title:n(`providers.subscription.credits.title`),footer:n(`providers.subscription.credits.footer`),children:[a.isLoading&&(0,$.jsx)(z,{className:`my-4`}),a.isError&&(0,$.jsx)(`div`,{className:`px-4 py-3 text-[12px] text-[var(--text-secondary)]`,children:n(`providers.subscription.credits.unavailable`)}),a.data&&s.length===0&&(0,$.jsx)(`div`,{className:`px-4 py-5 text-center text-[12px] text-[var(--text-secondary)]`,children:n(`providers.subscription.credits.none`)}),s.map(e=>{let t=e.status!==`available`;return(0,$.jsxs)(A,{className:D(t&&`opacity-55`),label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(pt,{className:`size-3.5 text-[var(--text-secondary)]`}),e.title??e.reset_type??e.id]}),detail:[e.description,e.expires_at?n(`providers.subscription.credits.expires`,{when:new Date(e.expires_at).toLocaleString()}):null,e.redeemed_at?n(`providers.subscription.credits.redeemedAt`,{when:new Date(e.redeemed_at).toLocaleString()}):null,e.is_supported_by_plan===!1?n(`providers.subscription.credits.notInPlan`):null].filter(Boolean).join(` · `),children:[(0,$.jsx)(j,{tone:zt[e.status]??`neutral`,children:n(`providers.subscription.credits.status.${e.status}`)}),(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Ct,{className:`size-3.5`}),disabled:t,loading:o.isPending&&o.variables?.creditId===e.id,onClick:()=>void l(e),children:n(`providers.subscription.credits.consume`)})]},e.id)}),a.data&&s.length>0&&(0,$.jsx)(`div`,{className:`px-4 py-2 text-[11px] text-[var(--text-muted)]`,children:n(`providers.subscription.credits.availableCount`,{count:c})})]})}var Vt={active:`providers.subscription.status.active`,expired:`providers.subscription.status.expired`,revoked:`providers.subscription.status.revoked`};function Ht({provider:e,account:t,index:n,actions:r,onClose:i}){let{t:a,locale:o}=M(),{toast:s}=W(),c=be(e.id),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``);if((0,Q.useEffect)(()=>{u(t?.displayName??``),f(t?.httpProxy??``)},[t?.id,t?.displayName,t?.httpProxy]),!t)return(0,$.jsx)(U,{open:!1,onOpenChange:i,title:``});let p=At(t),m=t.kind===`api_key`,h=e.templateId===`openai-subscription`,g=e.httpProxy||a(`providers.accounts.proxyFallbackSystem`),_=e=>e?b(e,o):`—`,v=(e,n)=>c.mutate({id:t.id,...e},{onSuccess:()=>s(a(n),`success`),onError:e=>s(H(e),`error`)});return(0,$.jsx)(U,{open:!0,onOpenChange:e=>!e&&i(),title:t.displayName||t.keyMasked||t.id,description:[t.plan,a(m?`providers.accounts.kind.api_key`:`providers.accounts.kind.oauth`)].filter(Boolean).join(` · `),width:520,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,$.jsx)(F,{size:`sm`,icon:(0,$.jsx)(dt,{className:`size-3.5`}),disabled:t.isCurrent||p===`dead`,onClick:()=>r.activate(t),children:a(`providers.subscription.activate`)}),(0,$.jsx)(F,{size:`sm`,icon:(0,$.jsx)(J,{className:`size-3.5`}),disabled:p===`dead`,onClick:()=>r.refreshQuota(t),children:a(`providers.subscription.quotaRefresh`)}),!m&&(0,$.jsx)(F,{size:`sm`,icon:(0,$.jsx)(Je,{className:`size-3.5`}),disabled:t.status===`revoked`,onClick:()=>r.refreshToken(t),children:a(`providers.subscription.refreshToken`)}),!m&&t.status!==`active`&&(0,$.jsx)(F,{size:`sm`,variant:`primary`,onClick:()=>r.relogin(t),children:a(`providers.subscription.relogin`)}),(0,$.jsx)(F,{size:`sm`,variant:`plain`,className:`ml-auto text-[var(--danger)]`,icon:(0,$.jsx)(X,{className:`size-3.5`}),onClick:()=>r.remove(t),children:a(`providers.subscription.logout`)})]}),p===`dead`&&t.lastError&&(0,$.jsx)(L,{tone:`danger`,title:t.lastError}),(0,$.jsxs)(`section`,{className:`flex flex-col gap-2`,children:[(0,$.jsx)(`h4`,{className:`text-[11px] font-medium text-[var(--text-secondary)]`,children:a(`providers.accounts.detail.identity`)}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsx)(T,{className:`flex-1`,label:a(`providers.accounts.detail.name`),value:l,onChange:e=>u(e.target.value)}),(0,$.jsx)(F,{disabled:l.trim().length===0||l.trim()===t.displayName,loading:c.isPending&&c.variables?.displayName!==void 0,onClick:()=>v({displayName:l.trim()},`providers.accounts.renamed`),children:a(`common.save`)})]}),(0,$.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,$.jsx)(T,{className:`flex-1`,mono:!0,label:a(`providers.accounts.detail.proxy`),placeholder:g,value:d,onChange:e=>f(e.target.value)}),(0,$.jsx)(F,{disabled:d.trim()===(t.httpProxy??``),loading:c.isPending&&c.variables?.httpProxy!==void 0,onClick:()=>v({httpProxy:d.trim()},`providers.accounts.proxySaved`),children:a(`common.save`)})]}),(0,$.jsx)(`p`,{className:`text-[11px] text-[var(--text-muted)]`,children:a(`providers.accounts.detail.proxyHint`,{fallback:g})})]}),t.quota&&(0,$.jsxs)(`section`,{className:`-mx-4 flex flex-col gap-1`,children:[(0,$.jsx)(`h4`,{className:`px-4 text-[11px] font-medium text-[var(--text-secondary)]`,children:a(`providers.accounts.detail.quota`)}),(0,$.jsx)(Lt,{quota:t.quota})]}),h&&p!==`dead`&&(0,$.jsx)(`div`,{className:`-mx-4`,children:(0,$.jsx)(Bt,{account:t,providerId:e.id})}),(0,$.jsxs)(`section`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`h4`,{className:`text-[11px] font-medium text-[var(--text-secondary)]`,children:a(`providers.accounts.detail.credentials`)}),(0,$.jsxs)(`div`,{className:`card divide-y divide-[var(--border)] px-3`,children:[(0,$.jsx)(E,{label:a(`providers.accounts.detail.status`),children:(0,$.jsx)(j,{tone:p===`usable`?`green`:p===`cooling`?`orange`:p===`dead`?`red`:`neutral`,children:a(p===`disabled`?`providers.subscription.disabled`:Vt[t.status])})}),t.source&&(0,$.jsx)(E,{label:a(`providers.accounts.detail.source`),children:a(`providers.accounts.source.${t.source}`)}),m?(0,$.jsx)(E,{label:a(`providers.accounts.detail.key`),mono:!0,children:t.keyMasked??`••••`}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(E,{label:a(`providers.accounts.detail.expires`),children:_(t.expiresAtUtc)}),(0,$.jsx)(E,{label:a(`providers.accounts.detail.lastRefresh`),children:_(t.lastRefreshAtUtc)})]}),p===`cooling`&&(0,$.jsx)(E,{label:a(`providers.accounts.filter.cooling`),children:_(t.cooldownUntilUtc)}),(0,$.jsx)(E,{label:a(`providers.accounts.detail.order`),children:a(`providers.accounts.order`,{n:n+1})}),(0,$.jsx)(E,{label:a(`providers.accounts.detail.created`),children:_(t.createdAt)}),t.lastError&&p!==`dead`&&(0,$.jsx)(E,{label:a(`providers.accounts.detail.lastError`),children:t.lastError})]})]})]})})}function Ut({provider:e}){let{t}=M(),{toast:n}=W(),r=e.authScheme===`oauth-subscription`,i=l(e.id,r),a=ue(e.id);if(!r||!i.data)return null;let o=i.data,s=e=>a.mutate(e,{onError:e=>n(H(e),`error`)}),c=o.claudeSubscription||o.clientPolicy===`claude-code-only`;return!c&&!o.claudeSubscription?null:(0,$.jsxs)(R,{title:t(`providers.subscription.policy.title`),footer:t(`providers.subscription.policy.footer`),children:[c&&(0,$.jsx)(A,{label:t(`providers.subscription.policy.claudeCodeOnly`),detail:t(`providers.subscription.policy.claudeCodeOnlyDetail`),children:(0,$.jsx)(V,{label:t(`providers.subscription.policy.claudeCodeOnly`),checked:o.clientPolicy===`claude-code-only`,disabled:a.isPending,onChange:e=>s({clientPolicy:e?`claude-code-only`:`any`})})}),o.claudeSubscription&&(0,$.jsx)(A,{label:t(`providers.subscription.policy.mimic`),detail:t(`providers.subscription.policy.mimicDetail`),children:(0,$.jsx)(V,{label:t(`providers.subscription.policy.mimic`),checked:o.mimicClaudeCode,disabled:a.isPending,onChange:e=>s({mimicClaudeCode:e})})}),c&&o.clientPolicy===`any`&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:o.mimicClaudeCode?(0,$.jsx)(L,{tone:`warning`,title:t(`providers.subscription.policy.mimicWarning`)}):(0,$.jsx)(L,{tone:`warning`,title:t(`providers.subscription.policy.anyWarning`)})})]})}var Wt=[{value:`all`,label:`providers.accounts.filter.all`},{value:`usable`,label:`providers.accounts.filter.usable`},{value:`cooling`,label:`providers.accounts.filter.cooling`},{value:`dead`,label:`providers.accounts.filter.dead`},{value:`disabled`,label:`providers.accounts.filter.disabled`}],Gt=3e5;function Kt({provider:t}){let{t:n}=M(),{toast:r,confirm:i}=W(),o=Fe(),c=t.authScheme===`oauth-subscription`,u=e(t.id,c),d=l(t.id,c),f=ue(t.id),p=s(t.id,c),h=m(t.id),_=ae(t.id),v=Ee(t.id),y=pe(t.id),ee=we(t.id),te=xe(t.id),ne=g(t.id),ie=be(t.id),b=je(t.id),x=t.templateId===`openai-subscription`,S=Ne(c&&x),se=oe(t.id),C=t.templateId===`github-copilot-subscription`,ce=re(c&&C),le=Me(t.id),[w,de]=(0,Q.useState)(`all`),[fe,E]=(0,Q.useState)(``),[me,ge]=(0,Q.useState)(new Set),[ve,ye]=(0,Q.useState)(null),[Se,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,Ce]=(0,Q.useState)(``),[N,Te]=(0,Q.useState)(!1),[P,De]=(0,Q.useState)(!1),[I,Oe]=(0,Q.useState)(null),[ke,R]=(0,Q.useState)(null),[Ae,B]=(0,Q.useState)(!1),[Pe,V]=(0,Q.useState)(``),G=(0,Q.useRef)(new Set),Le=(0,Q.useRef)(new Set),K=(0,Q.useMemo)(()=>u.data??[],[u.data]);if((0,Q.useEffect)(()=>{if(c)for(let e of K){if(e.status!==`active`||Le.current.has(e.id))continue;let t=e.quota?.fetchedAtUtc?new Date(e.quota.fetchedAtUtc).getTime():0;Number.isFinite(t)&&Date.now()-t<Gt||(Le.current.add(e.id),y.mutate(e.id,{onError:()=>{}}))}},[K,c]),(0,Q.useEffect)(()=>{let e=new Set(K.map(e=>e.id));ge(t=>Array.from(t).every(t=>e.has(t))?t:new Set(Array.from(t).filter(t=>e.has(t)))),ve&&!e.has(ve)&&ye(null)},[K,ve]),(0,Q.useEffect)(()=>{if(!P||I?.mode!==`pkce`)return;let e=setInterval(()=>void u.refetch(),3e3);return()=>clearInterval(e)},[P,I,u]),(0,Q.useEffect)(()=>{if(!P||I?.mode!==`pkce`)return;let e=K.find(e=>!G.current.has(e.id));e&&J(!0,e.displayName||e.accountEmail||e.id)},[K,P,I]),(0,Q.useEffect)(()=>{if(!P||I?.mode!==`device`&&I?.mode!==`cli`)return;let e=!1,t=0,n=async()=>{try{let n=await _.mutateAsync(I.state);if(e)return;t=0,n.status===`done`?J(!0,n.account.displayName||n.account.accountEmail||n.account.id):n.status!==`pending`&&n.status!==`slow_down`&&J(!1,void 0,`error`in n?n.error??n.status:n.status)}catch(n){if(e)return;if(n instanceof he&&(n.status===404||n.status===400)){J(!1,void 0,H(n));return}++t>=5&&J(!1,void 0,H(n))}},r=setInterval(()=>void n(),Math.max(I.interval||5,3)*1e3);return()=>{e=!0,clearInterval(r)}},[P,I]),!c)return null;let q=e=>e.displayName||e.accountEmail||e.keyMasked||e.id,J=(e,i,s)=>{if(o.invalidateQueries({queryKey:a.providerAccounts(t.id)}),e){Oe(null),R(null),De(!1),r(n(`providers.subscription.loginOk`,{name:i??``}),`success`);return}s&&R(s)},Re=(e,t)=>{G.current=new Set(K.map(e=>e.id)),R(null),h.mutate({accountId:e,httpProxy:t},{onSuccess:e=>{A(!1),Oe(e),De(!0),e.mode!==`device`&&window.open(e.authorizeUrl,`_blank`,`noopener`)},onError:e=>{e instanceof he&&e.details?.needsVerification?r(n(`providers.subscription.needsVerification`),`error`):r(H(e),`error`)}})},ze=async()=>{if(I){B(!0);try{let e=await _.mutateAsync(I.state);e.status===`done`?J(!0,e.account.displayName||e.account.accountEmail||e.account.id):e.status===`pending`||e.status===`slow_down`?r(n(`providers.subscription.stillWaiting`),`info`):J(!1,void 0,`error`in e?e.error??e.status:e.status)}catch(e){if(e instanceof he&&e.status===404){let t=((await u.refetch()).data??[]).find(e=>!G.current.has(e.id));t?J(!0,t.displayName||t.accountEmail||t.id):J(!1,void 0,H(e))}else J(!1,void 0,H(e))}finally{B(!1)}}},Be=async()=>{if(I&&I.mode===`paste`&&Pe.trim().length!==0){B(!0);try{let e=await v.mutateAsync({state:I.state,code:Pe.trim()});e.status===`done`?(V(``),J(!0,e.account.displayName||e.account.accountEmail||e.account.id)):J(!1,void 0,`error`in e?e.error??e.status:e.status)}catch(e){J(!1,void 0,H(e))}finally{B(!1)}}},Ve=()=>se.mutate(void 0,{onSuccess:e=>{r(n(`providers.subscription.importOk`,{name:q(e.account)}),e.warning?`info`:`success`),e.warning&&r(e.warning,`error`),S.refetch()},onError:e=>r(H(e),`error`)}),Ue=()=>le.mutate(``,{onSuccess:e=>{r(n(`providers.subscription.importOk`,{name:q(e.account)}),e.warning?`info`:`success`),e.warning&&r(e.warning,`error`)},onError:e=>r(H(e),`error`)}),We=(e,t)=>{let n=K.map(e=>e.id),i=e+t;i<0||i>=n.length||([n[e],n[i]]=[n[i],n[e]],b.mutate(n,{onError:e=>r(H(e),`error`)}))},Ge=async e=>{let t=q(e);await i({title:n(`providers.subscription.logoutConfirm`,{name:t}),destructive:!0,confirmLabel:n(`providers.subscription.logout`)})&&te.mutate(e.id,{onError:e=>r(H(e),`error`)})},Ke={open:e=>ye(e.id),activate:e=>ne.mutate(e.id,{onSuccess:()=>r(n(`providers.subscription.activated`,{name:q(e)}),`success`),onError:e=>r(H(e),`error`)}),toggleEnabled:e=>ie.mutate({id:e.id,enabled:!e.enabled},{onError:e=>r(H(e),`error`)}),refreshQuota:e=>y.mutate(e.id,{onError:e=>{e instanceof he&&e.status===501?r(n(`providers.subscription.quotaUnsupported`),`error`):r(H(e),`error`)}}),refreshToken:e=>ee.mutate(e.id,{onSuccess:()=>r(n(`providers.subscription.tokenRefreshed`),`success`),onError:e=>r(H(e),`error`)}),relogin:e=>Re(e.id),remove:e=>void Ge(e)},Je=e=>ge(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),Xe=async e=>{let i=K.filter(e=>me.has(e.id));Te(!0);let s=0;for(let t of i)try{await e(t),s++}catch(e){r(`${q(t)}: ${H(e)}`,`error`)}Te(!1),ge(new Set),o.invalidateQueries({queryKey:a.providerAccounts(t.id)}),s>0&&r(n(`providers.accounts.bulkDone`,{n:s}),`success`)},Ze=async()=>{await i({title:n(`providers.accounts.bulkDeleteConfirm`,{n:me.size}),detail:n(`providers.accounts.bulkDeleteDetail`),destructive:!0,confirmLabel:n(`common.delete`)})&&await Xe(e=>te.mutateAsync(e.id))},Qe=K.map(e=>At(e)),Y=e=>e===`all`?K.length:Qe.filter(t=>t===e).length,$e=fe.trim().toLowerCase(),tt=K.map((e,t)=>({a:e,index:t,state:Qe[t]})).filter(({a:e,state:t})=>(w===`all`||t===w)&&($e.length===0||[e.displayName,e.accountEmail,e.keyMasked,e.plan].some(e=>e?.toLowerCase().includes($e)))),nt=K.find(e=>e.id===ve)??null,Z=p.data,rt=me.size>0,it=[{id:`login`,label:n(`providers.accounts.addLogin`),icon:(0,$.jsx)(_t,{className:`size-3.5`}),onSelect:()=>Re()},{id:`login-proxy`,label:n(`providers.accounts.addLoginProxy`),onSelect:()=>A(!0)},...x&&S.data?.available?[{id:`codex`,separatorBefore:!0,label:n(`providers.subscription.importCodex`),icon:(0,$.jsx)(He,{className:`size-3.5`}),onSelect:Ve}]:[],...C?[{id:`copilot`,separatorBefore:!0,label:n(`providers.subscription.importCopilot`),icon:(0,$.jsx)(He,{className:`size-3.5`}),onSelect:Ue}]:[],...Z?.supported?[{id:`token`,separatorBefore:!(x&&S.data?.available)&&!C,label:n(`providers.accounts.addToken`),onSelect:()=>O(`token`)}]:[],...Z?.apiKey?[{id:`apikey`,label:n(`providers.accounts.addApiKey`),icon:(0,$.jsx)(Ye,{className:`size-3.5`}),onSelect:()=>O(`apiKey`)}]:[]];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`card mb-3 flex flex-wrap items-center gap-x-4 gap-y-2 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`mr-auto flex flex-wrap items-center gap-x-3 gap-y-1 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(`span`,{className:`font-medium text-[var(--text)]`,children:n(`providers.accounts.statTotal`,{n:K.length})}),(0,$.jsx)(`span`,{style:{color:`var(--success)`},children:n(`providers.accounts.statUsable`,{n:Y(`usable`)})}),Y(`cooling`)>0&&(0,$.jsx)(`span`,{style:{color:`var(--warning)`},children:n(`providers.accounts.statCooling`,{n:Y(`cooling`)})}),Y(`dead`)>0&&(0,$.jsx)(`span`,{style:{color:`var(--danger)`},children:n(`providers.accounts.statDead`,{n:Y(`dead`)})}),(0,$.jsx)(`span`,{className:`text-[11px] text-[var(--text-muted)]`,children:n(`providers.accounts.providerProxy`,{proxy:t.httpProxy||n(`providers.accounts.proxyFallbackSystem`)})})]}),d.data&&(0,$.jsx)(qt,{policy:d.data,onChange:e=>f.mutate({switchMode:e},{onError:e=>r(H(e),`error`)})})]}),d.data&&(0,$.jsx)(`p`,{className:`-mt-1 mb-3 px-1 text-[11px] text-[var(--text-muted)]`,children:n(d.data.switchMode===`balanced`?`providers.subscription.policy.balancedDetail`:d.data.switchMode===`failover`?`providers.subscription.policy.failoverDetail`:`providers.subscription.policy.manualDetail`)}),(0,$.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(_e,{className:`w-52`,value:fe,onChange:E,placeholder:n(`providers.accounts.search`)}),(0,$.jsx)(`div`,{role:`group`,"aria-label":n(`providers.accounts.filterLabel`),className:`mr-auto flex flex-wrap gap-1`,children:Wt.filter(e=>e.value===`all`||Y(e.value)>0).map(e=>(0,$.jsxs)(`button`,{type:`button`,"aria-pressed":w===e.value,onClick:()=>de(e.value),className:D(`rounded-full px-2.5 py-0.5 text-[11.5px] text-[var(--text-secondary)] transition-colors hover:bg-[var(--fill)]`,w===e.value&&`bg-[var(--fill)] text-[var(--text)]`),children:[n(e.label),(0,$.jsx)(`span`,{className:`ml-1 text-[var(--text-muted)]`,children:Y(e.value)})]},e.value))}),Z?.supported&&(0,$.jsx)(F,{size:`sm`,icon:(0,$.jsx)(ht,{className:`size-3.5`}),onClick:()=>O(`batch`),children:n(`providers.accounts.batchImport`)}),(0,$.jsx)(Ie,{label:n(`providers.accounts.add`),icon:(0,$.jsx)(et,{className:`size-3.5`}),items:it})]}),x&&S.data?.available&&(0,$.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-[var(--text-muted)]`,children:[n(`providers.subscription.localCodexFound`,{who:S.data.accountEmail??S.data.plan??n(`providers.subscription.unknownAccount`)}),S.data.detail?` · ${S.data.detail}`:``]}),C&&(0,$.jsxs)(`p`,{className:`mb-2 px-1 text-[11px] text-[var(--text-muted)]`,children:[ce.data?.available?n(`providers.subscription.localCopilotFound`,{source:ce.data.source??``}):n(`providers.subscription.localCopilotHint`),ce.data?.detail?` · ${ce.data.detail}`:``]}),u.isLoading?(0,$.jsx)(z,{className:`my-4`}):K.length===0?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Re(),className:`flex w-full flex-col items-center gap-1 rounded-[var(--radius-card,12px)] border border-dashed border-[var(--border)] px-4 py-6 text-[12px] text-[var(--text-secondary)] hover:border-[var(--accent)] hover:text-[var(--text)]`,children:[(0,$.jsx)(`span`,{children:n(`providers.subscription.none`)}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1 text-[var(--accent)]`,children:[(0,$.jsx)(et,{className:`size-3.5`}),` `,n(`providers.subscription.login`)]})]}):tt.length===0?(0,$.jsx)(`div`,{className:`px-4 py-5 text-center text-[12px] text-[var(--text-secondary)]`,children:n(`providers.accounts.noMatch`)}):(0,$.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(190px,1fr))] gap-3`,children:tt.map(({a:e,index:t})=>(0,$.jsx)(Pt,{account:e,index:t,actions:Ke,selected:me.has(e.id),selecting:rt,onToggleSelect:Je,quotaPending:y.isPending&&y.variables===e.id,onMove:K.length>1?{up:t>0?()=>We(t,-1):void 0,down:t<K.length-1?()=>We(t,1):void 0}:void 0},e.id))}),(0,$.jsx)(`p`,{className:`mt-2 px-1 text-[11px] text-[var(--text-muted)]`,children:n(`providers.subscription.footer`)}),rt&&(0,$.jsxs)(`div`,{className:`card sticky bottom-3 z-10 mt-3 flex flex-wrap items-center gap-1.5 px-3 py-1.5 shadow-lg`,children:[(0,$.jsx)(`span`,{className:`mr-auto text-[12px] text-[var(--text-secondary)]`,children:n(`providers.accounts.selected`,{n:me.size})}),(0,$.jsx)(F,{size:`sm`,icon:(0,$.jsx)(qe,{className:`size-3.5`}),disabled:N,onClick:()=>void Xe(e=>ie.mutateAsync({id:e.id,enabled:!0})),children:n(`providers.subscription.enable`)}),(0,$.jsx)(F,{size:`sm`,disabled:N,onClick:()=>void Xe(e=>ie.mutateAsync({id:e.id,enabled:!1})),children:n(`providers.subscription.disable`)}),(0,$.jsx)(F,{size:`sm`,disabled:N,onClick:()=>void Xe(e=>y.mutateAsync(e.id)),children:n(`providers.subscription.quotaRefresh`)}),(0,$.jsx)(F,{size:`sm`,className:`text-[var(--danger)]`,icon:(0,$.jsx)(X,{className:`size-3.5`}),disabled:N,onClick:()=>void Ze(),children:n(`common.delete`)}),(0,$.jsx)(F,{size:`sm`,variant:`plain`,onClick:()=>ge(new Set),children:n(`providers.accounts.clearSelection`)})]}),(0,$.jsx)(`div`,{className:`mt-5`,children:(0,$.jsx)(Ut,{provider:t})}),(0,$.jsx)(Ht,{provider:t,account:nt,index:nt?K.indexOf(nt):0,actions:Ke,onClose:()=>ye(null)}),Z&&(0,$.jsx)(kt,{providerId:t.id,info:Z,mode:Se,providerProxy:t.httpProxy,onClose:()=>O(null)}),(0,$.jsx)(U,{open:k,onOpenChange:A,title:n(`providers.accounts.loginProxyTitle`),description:n(`providers.accounts.loginProxyDesc`),footer:(0,$.jsx)(F,{variant:`primary`,loading:h.isPending,disabled:j.trim().length===0,onClick:()=>Re(void 0,j),children:n(`providers.accounts.loginProxyStart`)}),children:(0,$.jsx)(T,{mono:!0,label:n(`providers.accounts.detail.proxy`),placeholder:`socks5://127.0.0.1:1080`,value:j,onChange:e=>Ce(e.target.value)})}),(0,$.jsxs)(U,{open:P,onOpenChange:e=>{De(e),e||(Oe(null),R(null))},title:n(`providers.subscription.login`),description:n(`providers.subscription.loginDesc`),children:[ke&&(0,$.jsx)(L,{tone:`danger`,title:n(`providers.subscription.loginFailed`),children:ke}),I?.mode===`paste`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(L,{tone:`info`,title:n(`providers.subscription.pasteTitle`),children:n(`providers.subscription.pasteDetail`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsx)(F,{onClick:()=>window.open(I.authorizeUrl,`_blank`,`noopener`),children:n(`providers.subscription.openAuthorize`)})}),(0,$.jsx)(T,{mono:!0,value:Pe,onChange:e=>V(e.target.value),placeholder:n(`providers.subscription.pastePlaceholder`),"aria-label":n(`providers.subscription.pasteCode`)}),(0,$.jsx)(F,{variant:`primary`,loading:Ae,onClick:()=>void Be(),children:n(`providers.subscription.pasteSubmit`)})]}),I?.mode===`pkce`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(L,{tone:`info`,title:n(`providers.subscription.waiting`),children:n(`providers.subscription.waitingDetail`)}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(F,{onClick:()=>window.open(I.authorizeUrl,`_blank`,`noopener`),children:n(`providers.subscription.openAuthorize`)}),(0,$.jsx)(F,{variant:`primary`,onClick:()=>{o.invalidateQueries({queryKey:a.providerAccounts(t.id)}),u.refetch()},children:n(`providers.subscription.doneAuthorize`)})]})]}),I?.mode===`cli`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(L,{tone:`info`,title:n(`providers.subscription.waiting`),children:n(`providers.subscription.cliDetail`)}),(0,$.jsx)(F,{onClick:()=>window.open(I.authorizeUrl,`_blank`,`noopener`),children:n(`providers.subscription.openAuthorize`)})]}),I?.mode===`device`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-[11px] text-[var(--text-secondary)]`,children:n(`providers.subscription.deviceCode`)}),(0,$.jsx)(`div`,{className:`selectable font-mono text-[18px] font-medium tracking-wide`,children:I.userCode})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[I.verificationUrl&&(0,$.jsx)(F,{onClick:()=>window.open(I.verificationUrl??void 0,`_blank`,`noopener`),children:n(`providers.subscription.visitPage`)}),(0,$.jsx)(F,{variant:`primary`,loading:Ae,onClick:()=>void ze(),children:n(`providers.subscription.checkNow`)})]}),(0,$.jsx)(L,{tone:`info`,title:n(`providers.subscription.waiting`),children:n(`providers.subscription.checkNowHint`)})]})]})]})}function qt({policy:e,onChange:t}){let{t:n}=M();return(0,$.jsx)(S,{ariaLabel:n(`providers.subscription.policy.switchMode`),value:e.switchMode,onChange:t,items:[{value:`manual`,label:n(`providers.subscription.policy.manual`)},{value:`failover`,label:n(`providers.subscription.policy.failover`)},{value:`balanced`,label:n(`providers.subscription.policy.balanced`)}]})}function Jt({provider:t}){let{t:n}=M(),r=e(t.id),i=ee(t.id),a=l(t.id,!0),o=ue(t.id),{toast:s}=W(),[c,u]=(0,Q.useState)(null);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i.isLoading&&(0,$.jsx)(z,{lines:1}),i.isError&&(0,$.jsx)(L,{tone:`danger`,title:n(`pluginAccounts.noPlugin`),children:H(i.error)}),i.data?.map(e=>(0,$.jsx)(F,{variant:e.index===0?`primary`:void 0,icon:e.type===`api`?(0,$.jsx)(Ye,{className:`size-3.5`}):(0,$.jsx)(_t,{className:`size-3.5`}),onClick:()=>u(e),children:e.label||n(e.type===`api`?`pluginAccounts.apiKey`:`pluginAccounts.browser`)},e.index))]}),r.isLoading&&(0,$.jsx)(z,{lines:3}),r.data?.length===0&&(0,$.jsx)(`div`,{className:`card`,children:(0,$.jsx)(w,{icon:(0,$.jsx)(yt,{className:`size-6`}),title:n(`pluginAccounts.empty`),detail:n(`pluginAccounts.emptyDetail`)})}),r.data&&r.data.length>1&&a.data&&(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 px-1`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 text-[12px] text-[var(--text-secondary)]`,children:n(a.data.switchMode===`balanced`?`providers.subscription.policy.balancedDetail`:a.data.switchMode===`failover`?`providers.subscription.policy.failoverDetail`:`providers.subscription.policy.manualDetail`)}),(0,$.jsx)(qt,{policy:a.data,onChange:e=>o.mutate({switchMode:e},{onError:e=>s(H(e),`error`)})})]}),r.data&&r.data.length>0&&(0,$.jsx)(`div`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:r.data.map(e=>(0,$.jsx)(Xt,{provider:t,account:e},e.id))}),(0,$.jsx)(Yt,{provider:t}),c&&(0,$.jsx)(Zt,{provider:t,method:c,onClose:()=>u(null)})]})}function Yt({provider:e}){let{t,locale:n}=M(),{toast:r}=W(),i=h(e.id),a=_(e.id);if(!i.data?.supported)return null;let o=e=>a.mutate(e,{onError:e=>r(H(e),`error`)}),s={claimed:`green`,done:`green`,ineligible:`neutral`,inactive:`neutral`,captcha:`orange`,failed:`red`};return(0,$.jsxs)(`section`,{className:`card divide-y divide-[var(--border-subtle)] overflow-hidden p-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-[13px] font-medium`,children:t(`pluginAccounts.checkin`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-[12px] text-[var(--text-secondary)]`,children:t(`pluginAccounts.checkinDetail`)})]}),(0,$.jsx)(V,{checked:i.data.on,label:t(`pluginAccounts.checkinOn`),onChange:e=>o(e)}),(0,$.jsx)(F,{size:`sm`,loading:a.isPending,onClick:()=>o(),children:t(`pluginAccounts.checkinNow`)})]}),i.data.accounts.map(e=>{let r=[e.credit?t(`pluginAccounts.credit`,{credit:e.credit}):null,e.streak?t(`pluginAccounts.streak`,{days:e.streak}):null,e.message,e.at?b(e.at,n):null].filter(Boolean);return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 px-4 py-2.5`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px]`,children:e.account}),r.length>0&&(0,$.jsx)(`span`,{className:`min-w-0 truncate text-[12px] text-[var(--text-secondary)]`,children:r.join(` · `)}),e.outcome?(0,$.jsx)(j,{tone:s[e.outcome]??`neutral`,children:t(`pluginAccounts.outcome.${e.outcome}`)}):(0,$.jsx)(j,{children:t(`pluginAccounts.checkinNever`)})]},e.accountId)})]})}function Xt({provider:e,account:t}){let{t:n,locale:r}=M(),{toast:i,confirm:a}=W(),o=x(e.id),[s,c]=(0,Q.useState)(!1),l=e.settings?.plugin?.usage===!0,u=d(e.id,t.id,s),f=async()=>{await a({title:n(`pluginAccounts.signOutConfirm`,{name:t.displayName}),confirmLabel:n(`pluginAccounts.signOut`),destructive:!0})&&o.mutate(t.id,{onError:e=>i(H(e),`error`)})};return(0,$.jsxs)(`article`,{className:`flex flex-col gap-2 px-4 py-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:t.displayName}),t.isCurrent&&(0,$.jsx)(j,{tone:`accent`,children:n(`pluginAccounts.current`)}),(0,$.jsx)(j,{tone:t.status===`active`?`green`:`red`,children:n(t.status===`active`?`pluginAccounts.active`:`pluginAccounts.lapsed`)}),l&&(0,$.jsx)(F,{size:`sm`,onClick:()=>c(e=>!e),children:n(`pluginAccounts.usage`)}),(0,$.jsx)(F,{size:`sm`,variant:`destructive`,icon:(0,$.jsx)(Ke,{className:`size-3.5`}),onClick:()=>void f(),children:n(`pluginAccounts.signOut`)})]}),t.status!==`active`&&(0,$.jsx)(`p`,{className:`text-[12px] text-[var(--danger)]`,children:n(`pluginAccounts.lapsedDetail`)}),s&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 rounded-md bg-[var(--surface-muted)] px-3 py-2`,children:[u.isLoading&&(0,$.jsx)(z,{lines:2}),u.isError&&(0,$.jsx)(`span`,{className:`text-[12px] text-[var(--danger)]`,children:H(u.error)}),u.data?.error&&(0,$.jsx)(`span`,{className:`text-[12px] text-[var(--danger)]`,children:u.data.error}),u.data?.plan&&(0,$.jsx)(E,{label:n(`pluginAccounts.plan`),children:u.data.plan}),u.data?.until&&(0,$.jsx)(E,{label:n(`pluginAccounts.until`),children:b(u.data.until,r)}),u.data?.windows?.map(e=>(0,$.jsxs)(E,{label:e.name,children:[e.display??(e.limit?`${e.amount??e.used??0} / ${e.limit} ${e.unit??``}`:`${e.used??0}%`),e.resetsAt?` · ${n(`pluginAccounts.resets`,{at:b(new Date(e.resetsAt>0xe8d4a51000?e.resetsAt:e.resetsAt*1e3).toISOString(),r)})}`:``]},e.name))]})]})}function Zt({provider:e,method:t,onClose:n}){let{t:i}=M(),{toast:a}=W(),[o,s]=(0,Q.useState)({}),[c,l]=(0,Q.useState)(void 0),[u,d]=(0,Q.useState)(``),[f,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(``),[_,y]=(0,Q.useState)(``),[ee,te]=(0,Q.useState)(null),ne=Se(e.id),re=p(e.id),b=v(e.id),x=r(e.id,ee).data;(0,Q.useEffect)(()=>{let n=!0;return Pe(e.id,t.index,o).then(e=>{n&&(l(e.prompt),d(e.prompt?.type===`select`?e.prompt.options?.[0]?.value??``:``))}).catch(e=>n&&a(H(e),`error`)),()=>{n=!1}},[e.id,t.index,o,a]),(0,Q.useEffect)(()=>{x?.state===`done`&&(a(i(`pluginAccounts.signedIn`),`success`),n())},[x?.state,n,i,a]);let ae=async()=>{if(!c)return;let n=await ie(e.id,t.index,c.key,u).catch(()=>({error:null}));if(n.error)return m(n.error);m(null),s(e=>({...e,[c.key]:u}))};return(0,$.jsxs)(U,{open:!0,onOpenChange:e=>!e&&n(),title:i(`pluginAccounts.signInTitle`,{name:e.name}),description:t.label,width:520,children:[c===void 0&&(0,$.jsx)(z,{lines:2}),c&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(k,{label:c.message,error:f??void 0,children:c.type===`select`?(0,$.jsx)(G,{value:u,onChange:d,options:(c.options??[]).map(e=>({value:e.value,label:e.label,description:e.hint??void 0}))}):(0,$.jsx)(T,{value:u,placeholder:c.placeholder??void 0,onChange:e=>d(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(F,{variant:`primary`,onClick:()=>void ae(),children:i(`pluginAccounts.continue`)})})]}),c===null&&t.type===`api`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(k,{label:i(`pluginAccounts.key`),children:(0,$.jsx)(T,{mono:!0,type:`password`,value:h,placeholder:t.placeholder??void 0,onChange:e=>g(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(F,{variant:`primary`,disabled:!h.trim()||re.isPending,onClick:()=>re.mutate({method:t.index,inputs:o,key:h},{onSuccess:()=>(a(i(`pluginAccounts.signedIn`),`success`),n()),onError:e=>a(H(e),`error`)}),children:i(`pluginAccounts.signIn`)})})]}),c===null&&t.type!==`api`&&!x&&(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(F,{variant:`primary`,icon:(0,$.jsx)(We,{className:`size-3.5`}),disabled:ne.isPending,onClick:()=>ne.mutate({method:t.index,inputs:o},{onSuccess:e=>{te(e.id),e.url&&window.open(e.url,`_blank`,`noopener`)},onError:e=>a(H(e),`error`)}),children:i(`pluginAccounts.openPage`)})}),x&&x.state!==`done`&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[x.instructions&&(0,$.jsx)(`p`,{className:`whitespace-pre-wrap text-[12px] text-[var(--text-secondary)]`,children:x.instructions}),x.deviceCode&&(0,$.jsx)(E,{label:i(`pluginAccounts.deviceCode`),mono:!0,children:x.deviceCode}),x.url&&(0,$.jsx)(F,{icon:(0,$.jsx)(We,{className:`size-3.5`}),onClick:()=>window.open(x.url,`_blank`,`noopener`),children:i(`pluginAccounts.openAgain`)}),x.state===`waiting`&&x.pasteCode&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(k,{label:i(`pluginAccounts.code`),children:(0,$.jsx)(T,{mono:!0,value:_,onChange:e=>y(e.target.value),autoFocus:!0})}),(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(F,{variant:`primary`,disabled:!_.trim()||b.isPending,onClick:()=>b.mutate({flow:x.id,code:_.trim()},{onError:e=>a(H(e),`error`)}),children:i(`pluginAccounts.signIn`)})})]}),x.state===`waiting`&&!x.pasteCode&&(0,$.jsx)(`p`,{className:`text-[12px] text-[var(--text-muted)]`,children:i(`pluginAccounts.waiting`)}),x.state===`failed`&&(0,$.jsx)(L,{tone:`danger`,title:i(`pluginAccounts.failed`),children:x.error})]})]})}function Qt(e){let t=e?.model_map,n={};if(!t||typeof t!=`object`||Array.isArray(t))return n;for(let[e,r]of Object.entries(t))e&&typeof r==`string`&&r&&(n[e]=r);return n}function $t(){let{t:e}=M(),{id:t=``}=$e(),n=nt(),r=y(t),[i,a]=(0,Q.useState)(`models`),[o,s]=(0,Q.useState)(null),c=fe(t),l=c.data?.find(e=>e.id===o)??null;if(r.isError)return(0,$.jsx)(it,{title:e(`nav.providers`),leading:(0,$.jsx)(en,{onClick:()=>n(`/providers`)}),children:(0,$.jsx)(L,{tone:`danger`,title:e(`common.error`),children:H(r.error)})});let u=r.data;return(0,$.jsx)(it,{title:u?u.name:``,subtitle:u?[u.templateId,u.priceKey?e(`providers.priceKeyShort`,{key:u.priceKey}):null].filter(Boolean).join(` · `):void 0,leading:(0,$.jsx)(en,{onClick:()=>n(`/providers`)}),actions:u&&(0,$.jsx)(tn,{p:u}),children:u?(0,$.jsxs)(Xe,{className:`mx-auto max-w-[860px]`,value:i,onValueChange:e=>a(e),children:[(0,$.jsxs)(tt,{"aria-label":u.name,children:[(0,$.jsx)(Ze,{value:`models`,children:e(`providers.tab.models`)}),(0,$.jsx)(Ze,{value:`accounts`,children:e(u.authScheme===`oauth-subscription`||u.authScheme===`plugin`?`providers.tab.accounts`:`providers.tab.apiKey`)}),(0,$.jsx)(Ze,{value:`settings`,children:e(`providers.tab.settings`)})]}),(0,$.jsx)(st,{value:`models`,className:`pt-4`,children:(0,$.jsx)(rn,{provider:u,models:c.data,loading:c.isLoading,selected:o,onSelect:s})}),(0,$.jsx)(st,{value:`accounts`,className:`pt-4`,children:u.authScheme===`plugin`?(0,$.jsx)(Jt,{provider:u}):u.authScheme===`oauth-subscription`?(0,$.jsx)(Kt,{provider:u}):(0,$.jsx)(dn,{provider:u})}),(0,$.jsx)(st,{value:`settings`,className:`pt-4`,children:(0,$.jsx)(pn,{provider:u})}),(0,$.jsx)(un,{provider:u,pm:i===`models`?l:null,onClose:()=>s(null)})]}):(0,$.jsx)(z,{lines:4,className:`mx-auto mt-6 max-w-[860px]`})})}function en({onClick:e}){let{t}=M();return(0,$.jsx)(F,{variant:`glass`,icon:(0,$.jsx)(Be,{className:`size-4`}),"aria-label":t(`common.back`),onClick:e})}function tn({p:e}){let{t}=M(),n=nt(),{toast:r,confirm:i}=W(),a=Ae(),o=I(),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),d=async()=>{await i({title:t(`providers.deleteConfirm`,{name:e.name}),detail:t(`providers.deleteDetail`),destructive:!0,confirmLabel:t(`common.delete`)})&&o.mutate(e.id,{onSuccess:()=>{r(t(`providers.deleted`)),n(`/providers`)},onError:e=>{let n=e instanceof he&&e.status===409?e.details?.boundClients??[]:[];r(n.length?t(`providers.deleteBound`,{clients:n.map(e=>Z[e]?.name??e).join(`, `)}):H(e),`error`)}})};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{icon:(0,$.jsx)(Ge,{className:`size-3.5`}),onClick:()=>u(!0),children:t(`providers.test`)}),(0,$.jsx)(Ie,{label:t(`common.more`),icon:(0,$.jsx)(Ue,{className:`size-4`}),items:[{id:`dup`,label:t(`providers.duplicate`),icon:(0,$.jsx)(Te,{className:`size-3.5`}),onSelect:()=>a.mutate(e.id,{onSuccess:e=>n(`/providers/${e.id}`),onError:e=>r(H(e),`error`)})},{id:`tpl`,label:t(`providers.templateUpdate`),icon:(0,$.jsx)(xt,{className:`size-3.5`}),disabled:!e.templateId,onSelect:()=>c(!0)},{id:`del`,label:t(`common.delete`),icon:(0,$.jsx)(X,{className:`size-3.5`}),destructive:!0,separatorBefore:!0,onSelect:()=>void d()}]}),(0,$.jsx)(nn,{open:s,onOpenChange:c,provider:e}),(0,$.jsx)(K,{provider:e,open:l,onOpenChange:u})]})}function nn({open:e,onOpenChange:t,provider:n}){let{t:r}=M(),{toast:i}=W(),a=te(n.id,e),o=u(n.id),s=a.data&&a.data.latestVersion<=a.data.currentVersion;return(0,$.jsxs)(U,{open:e,onOpenChange:t,title:r(`providers.templateUpdate`),description:a.data?r(`providers.templateVersions`,{current:a.data.currentVersion,latest:a.data.latestVersion}):void 0,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:!a.data||s,loading:o.isPending,onClick:()=>o.mutate(void 0,{onSuccess:()=>{t(!1),i(r(`providers.templateApplied`),`success`)},onError:e=>i(H(e),`error`)}),children:r(`common.apply`)})]}),children:[a.isLoading&&(0,$.jsx)(z,{}),a.isError&&(0,$.jsx)(L,{tone:`danger`,title:r(`common.error`),children:H(a.error)}),s&&(0,$.jsx)(L,{tone:`success`,title:r(`providers.templateUpToDate`)}),a.data&&!s&&(0,$.jsx)(`ul`,{className:`list-disc pl-5 text-[12px]`,children:a.data.changes.map((e,t)=>(0,$.jsx)(`li`,{children:e},t))})]})}function rn({provider:e,models:t,loading:r,selected:i,onSelect:a}){let{t:o}=M(),{toast:s}=W(),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1),m=C(e.id),h=(t??[]).filter(e=>!c||e.modelId.toLowerCase().includes(c.toLowerCase())||e.effective.displayName.toLowerCase().includes(c.toLowerCase()));return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(_e,{className:`w-56`,value:c,onChange:l,placeholder:o(`providers.searchModels`)}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,$.jsx)(F,{icon:(0,$.jsx)(et,{className:`size-3.5`}),onClick:()=>p(!0),children:o(`providers.addModels`)}),(0,$.jsx)(F,{variant:`primary`,icon:(0,$.jsx)(Ve,{className:`size-3.5`}),onClick:()=>d(!0),children:o(`providers.fetchRemote`)})]})]}),r&&(0,$.jsx)(z,{lines:4}),t?.length===0&&(0,$.jsx)(`div`,{className:`card`,children:(0,$.jsx)(w,{title:o(`providers.noModels`),detail:o(`providers.noModelsDetail`)})}),h.length>0&&(0,$.jsx)(R,{footer:o(`providers.modelsFooter`),children:h.map(e=>(0,$.jsxs)(A,{selected:e.id===i,onClick:()=>a(e.id),label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:D(`font-mono text-[12.5px]`,!e.enabled&&`text-[var(--text-muted)]`),children:e.modelId}),!e.systemModelId&&(0,$.jsx)(j,{tone:`orange`,children:o(`providers.unlinked`)})]}),detail:[e.effective.displayName===e.modelId?null:e.effective.displayName,e.effective.contextWindow?n(e.effective.contextWindow):null,Ce(e.effectivePricing)].filter(Boolean).join(` · `),children:[(0,$.jsx)(rt,{source:e.pricingSource,priceKey:e.priceKey}),(0,$.jsx)(V,{checked:e.enabled,label:o(`common.enabled`),onChange:t=>m.mutate({pmId:e.id,enabled:t},{onError:e=>s(H(e),`error`)})})]},e.id))}),t&&(0,$.jsx)(an,{provider:e,models:t}),(0,$.jsx)(sn,{open:f,onOpenChange:p,provider:e}),(0,$.jsx)(cn,{open:u,onOpenChange:d,provider:e})]})}function an({provider:e,models:t}){let{t:n}=M(),{toast:r}=W(),i=o(e.id),[a,s]=(0,Q.useState)(!1),c=Qt(e.settings),l=Object.entries(c),u=new Set(t.map(e=>e.modelId)),d=(e,t)=>i.mutate(e,{onSuccess:()=>{t?.(),r(n(`providers.modelMap.saved`),`success`)},onError:e=>r(H(e),`error`)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{title:n(`providers.modelMap.title`),footer:n(`providers.modelMap.footer`),children:[l.map(([e,t])=>(0,$.jsx)(A,{label:(0,$.jsxs)(`span`,{className:`flex items-center gap-2 font-mono text-[12.5px]`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:e}),(0,$.jsx)(Y,{className:`size-3.5 shrink-0 text-[var(--text-muted)]`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:D(`truncate`,!u.has(t)&&`text-[var(--text-muted)]`),children:t}),!u.has(t)&&(0,$.jsx)(j,{tone:`orange`,children:n(`providers.modelMap.missingTarget`)})]}),children:(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(de,{className:`size-3.5`}),"aria-label":n(`providers.modelMap.remove`,{from:e}),title:n(`providers.modelMap.remove`,{from:e}),disabled:i.isPending,onClick:()=>d(Object.fromEntries(l.filter(([t])=>t!==e)))})},e)),(0,$.jsx)(A,{icon:(0,$.jsx)(et,{className:`size-4 text-[var(--text-secondary)]`}),label:n(`providers.modelMap.add`),detail:t.length===0?n(`providers.modelMap.needModels`):void 0,onClick:t.length===0?void 0:()=>s(!0)})]}),(0,$.jsx)(on,{open:a,onOpenChange:s,models:t,saving:i.isPending,onSave:(e,t)=>d({...c,[e]:t},()=>s(!1))})]})}function on({open:e,onOpenChange:t,models:n,saving:r,onSave:i}){let{t:a}=M(),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&(s(``),l(``))},[e]);let u=o.trim();return(0,$.jsx)(U,{open:e,onOpenChange:t,title:a(`providers.modelMap.add`),description:a(`providers.modelMap.addDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{onClick:()=>t(!1),children:a(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:!u||!c||u===c,loading:r,onClick:()=>i(u,c),children:a(`common.save`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(T,{autoFocus:!0,mono:!0,label:a(`providers.modelMap.from`),placeholder:`deepseek-v4.1`,spellCheck:!1,value:o,onChange:e=>s(e.target.value)}),(0,$.jsx)(G,{label:a(`providers.modelMap.to`),value:c,onChange:l,placeholder:a(`providers.modelMap.toPlaceholder`),options:n.map(e=>({value:e.modelId,label:e.modelId}))})]})})}function sn({open:e,onOpenChange:t,provider:n}){let{t:r}=M(),{toast:i}=W(),a=O(n.id),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&s(``)},[e]);let c=[...new Set(o.split(/[\s,]+/).map(e=>e.trim()).filter(Boolean))];return(0,$.jsx)(U,{open:e,onOpenChange:t,title:r(`providers.addModels`),description:r(`providers.addModelsDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:c.length===0,loading:a.isPending,onClick:()=>a.mutate(c,{onSuccess:e=>{t(!1),i(r(`providers.modelsAdded`,{count:e.length}),`success`)},onError:e=>i(H(e),`error`)}),children:r(`providers.addSelected`,{count:c.length})})]}),children:(0,$.jsx)(le,{autoFocus:!0,label:r(`providers.modelIds`),rows:6,spellCheck:!1,className:`w-full font-mono text-[12px]`,placeholder:`deepseek-v4-pro
|
|
3
3
|
claude-sonnet-4-6`,value:o,onChange:e=>s(e.target.value)})})}function cn({open:e,onOpenChange:t,provider:n}){let{t:r}=M(),{toast:i}=W(),a=Oe(n.id,e),o=O(n.id),[s,c]=(0,Q.useState)(new Set),[l,u]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&c(new Set)},[e]);let d=(a.data??[]).filter(e=>!l||e.id.toLowerCase().includes(l.toLowerCase())),f=e=>c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n});return(0,$.jsxs)(U,{open:e,onOpenChange:t,width:560,title:r(`providers.fetchRemote`),description:r(`providers.fetchRemoteDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{variant:`plain`,className:`mr-auto`,onClick:()=>c(new Set(d.filter(e=>!e.alreadyAdded).map(e=>e.id))),disabled:d.length===0,children:r(`common.selectAll`)}),(0,$.jsx)(F,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:s.size===0,loading:o.isPending,onClick:()=>o.mutate([...s],{onSuccess:e=>{t(!1),i(r(`providers.modelsAdded`,{count:e.length}),`success`)},onError:e=>i(H(e),`error`)}),children:r(`providers.addSelected`,{count:s.size})})]}),children:[(0,$.jsx)(_e,{className:`mb-3`,value:l,onChange:u,placeholder:r(`providers.searchModels`)}),a.isLoading&&(0,$.jsx)(z,{lines:4}),a.isError&&(0,$.jsx)(L,{tone:`danger`,title:r(`common.error`),children:H(a.error)}),(0,$.jsx)(`div`,{className:`card divide-y divide-[var(--border)]`,children:d.map(e=>(0,$.jsx)(A,{onClick:e.alreadyAdded?void 0:()=>f(e.id),label:(0,$.jsx)(`span`,{className:`font-mono text-[12px]`,children:e.id}),detail:e.linkedSystemModelId?r(`providers.linksTo`,{id:e.linkedSystemModelId}):r(`providers.noLink`),children:e.alreadyAdded?(0,$.jsx)(j,{children:r(`providers.added`)}):(0,$.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(ct,{"aria-label":e.id,checked:s.has(e.id),onCheckedChange:()=>f(e.id)})})},e.id))})]})}function ln({origin:e}){let{t}=M();return e===`overridden`?(0,$.jsx)(j,{tone:`orange`,children:t(`origin.overridden`)}):e===`inherited`?(0,$.jsx)(j,{children:t(`origin.inherited`)}):(0,$.jsx)(j,{tone:`red`,children:t(`origin.unset`)})}function un({provider:e,pm:n,onClose:r}){let{t:i}=M(),{toast:a}=W(),o=C(e.id),s=ce(e.id),c=t(),[l,u]=(0,Q.useState)({}),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(!1);if((0,Q.useEffect)(()=>{n&&(u(n.overrides),f(n.systemModelId??``),m(n.overrides.pricing!=null))},[n]),!n)return(0,$.jsx)(U,{open:!1,onOpenChange:()=>r(),title:i(`providers.tab.models`)});let h={...l,pricing:p?l.pricing??null:null},g=JSON.stringify(h)!==JSON.stringify({...n.overrides,pricing:n.overrides.pricing??null})||d!==(n.systemModelId??``),_=()=>o.mutate({pmId:n.id,overrides:h,systemModelId:d||null},{onSuccess:()=>{a(i(`common.saved`),`success`),r()},onError:e=>a(H(e),`error`)}),v=(e,t,r)=>(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[13px] font-medium`,children:t}),(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(ln,{origin:l[e]==null?n.origins[e]===`overridden`?`inherited`:n.origins[e]:`overridden`}),l[e]!=null&&(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(Je,{className:`size-3`}),title:i(`origin.reset`),"aria-label":i(`origin.reset`),onClick:()=>u({...l,[e]:null})})]})]}),r]});return(0,$.jsx)(U,{open:!0,onOpenChange:e=>!e&&r(),width:720,title:n.modelId,description:e.name,footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`mr-auto`,children:(0,$.jsx)(lt,{label:i(`providers.removeModelShort`),icon:(0,$.jsx)(X,{className:`size-4`}),prompt:i(`providers.removeModel`,{id:n.modelId}),confirmLabel:i(`common.delete`),cancelLabel:i(`common.cancel`),pendingLabel:i(`common.deleting`),doneLabel:i(`common.deleted`),errorLabel:i(`common.error`),retryLabel:i(`common.retry`),onConfirm:async()=>{await s.mutateAsync(n.id),r()}})}),(0,$.jsx)(F,{onClick:r,children:i(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:!g,loading:o.isPending,onClick:_,children:i(`common.save`)})]}),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(rt,{source:n.pricingSource,priceKey:n.priceKey}),n.multiplier!==1&&n.pricingSource!==`provider_override`&&(0,$.jsxs)(j,{children:[`×`,n.multiplier]})]}),(0,$.jsxs)(se,{title:i(`providers.linkedModel`),children:[(0,$.jsx)(G,{className:`w-full`,ariaLabel:i(`providers.linkedModel`),value:d,onChange:f,options:[{value:``,label:i(`providers.noLink`)},...(c.data??[]).map(e=>({value:e.id,label:e.id,detail:e.displayName}))]}),(0,$.jsx)(`p`,{className:`mt-2 text-[11px] text-[var(--text-muted)]`,children:i(`providers.linkedModelHint`)})]}),(0,$.jsx)(se,{title:i(`providers.overrides`),children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[v(`displayName`,i(`models.field.displayName`),(0,$.jsx)(T,{className:`w-full`,"aria-label":i(`models.field.displayName`),placeholder:n.effective.displayName,value:l.displayName??``,onChange:e=>u({...l,displayName:e.target.value||null})})),v(`contextWindow`,i(`models.field.contextWindow`),(0,$.jsx)(N,{className:`w-full`,label:i(`models.field.contextWindow`),placeholder:String(n.effective.contextWindow??``),value:l.contextWindow,onChange:e=>u({...l,contextWindow:e})})),v(`maxOutputTokens`,i(`models.field.maxOutputTokens`),(0,$.jsx)(N,{className:`w-full`,label:i(`models.field.maxOutputTokens`),placeholder:String(n.effective.maxOutputTokens??``),value:l.maxOutputTokens,onChange:e=>u({...l,maxOutputTokens:e})}))]})}),(0,$.jsxs)(se,{title:i(`providers.price`),action:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[i(`providers.customPrice`),(0,$.jsx)(V,{checked:p,label:i(`providers.customPrice`),onChange:e=>{m(e),e&&l.pricing==null&&u({...l,pricing:n.effectivePricing??{currency:`USD`,unit:`per_1m_tokens`,base:{input:null,output:null}}})}})]}),children:[(0,$.jsx)(`p`,{className:`mb-3 text-[11px] text-[var(--text-muted)]`,children:i(p?`providers.customPriceHint`:`providers.inheritedPriceHint`)}),p?(0,$.jsx)(`div`,{className:`card p-4`,children:(0,$.jsx)(at,{value:l.pricing??null,onChange:e=>u({...l,pricing:e})})}):n.effectivePricing?(0,$.jsx)(ye,{maxHeight:220,children:ke(n.effectivePricing)}):(0,$.jsx)(L,{tone:`warning`,title:i(`pricingSource.none`)})]})]})})}function dn({provider:e}){let{t}=M(),{toast:n}=W(),r=De(e.id),[i,a]=(0,Q.useState)(``);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(R,{title:t(`providers.section.auth`),footer:t(`providers.apiKeyStored`),children:(0,$.jsx)(A,{label:t(`providers.apiKey`),detail:e.hasApiKey?e.apiKeyMasked??`••••`:t(`providers.noKey`),children:(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(T,{type:`password`,autoComplete:`off`,className:`w-64 font-mono`,"aria-label":t(`providers.apiKey`),placeholder:t(`providers.replaceKey`),value:i,onChange:e=>a(e.target.value)}),(0,$.jsx)(F,{variant:`primary`,disabled:i.trim().length===0,loading:r.isPending,onClick:()=>r.mutate({apiKey:i},{onSuccess:()=>{a(``),n(t(`common.saved`),`success`)},onError:e=>n(H(e),`error`)}),children:t(`common.save`)})]})})}),(0,$.jsx)(Le,{provider:e})]})}function fn(e){return{name:e.name,apiKey:``,endpoints:e.endpoints,preferredUpstreamProtocols:e.preferredUpstreamProtocols,authScheme:e.authScheme,extraHeaders:e.extraHeaders,httpProxy:e.httpProxy??null,priceMultiplier:e.priceMultiplier,priceKey:e.priceKey??null,settings:e.settings,enabled:e.enabled,notes:e.notes??null}}function pn({provider:e}){let{t}=M(),{toast:n}=W(),r=De(e.id),i=P(),a=(0,Q.useMemo)(()=>fn(e),[e]),[o,s]=(0,Q.useState)(a),[c,l]=(0,Q.useState)(Object.entries(e.extraHeaders)),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{s(a),l(Object.entries(a.extraHeaders))},[a]);let m=e=>s(t=>({...t,...e})),h={...o,extraHeaders:Object.fromEntries(c.filter(([e])=>e.trim()))},g=JSON.stringify(h)!==JSON.stringify(a),_=()=>{let e={};for(let t of Object.keys(h))t!==`apiKey`&&JSON.stringify(h[t])!==JSON.stringify(a[t])&&(e[t]=h[t]);o.apiKey&&(e.apiKey=o.apiKey),r.mutate(e,{onSuccess:()=>n(t(`common.saved`),`success`),onError:e=>n(H(e),`error`)})},v=(e,t)=>m({endpoints:o.endpoints.map((n,r)=>r===e?{...n,...t}:n)});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(R,{title:t(`providers.section.basic`),children:[(0,$.jsx)(A,{label:t(`providers.name`),children:(0,$.jsx)(T,{className:`w-64`,"aria-label":t(`providers.name`),value:o.name,onChange:e=>m({name:e.target.value})})}),(0,$.jsx)(A,{label:t(`common.enabled`),children:(0,$.jsx)(V,{checked:o.enabled,label:t(`common.enabled`),onChange:e=>m({enabled:e})})}),(0,$.jsx)(A,{label:t(`providers.notes`),children:(0,$.jsx)(T,{className:`w-64`,"aria-label":t(`providers.notes`),value:o.notes??``,onChange:e=>m({notes:e.target.value||null})})})]}),(0,$.jsx)(R,{title:t(`providers.section.auth`),children:(0,$.jsx)(A,{label:t(`providers.authScheme`),children:(0,$.jsx)(G,{className:`w-48`,value:o.authScheme,onChange:e=>m({authScheme:e}),options:Re})})}),(0,$.jsxs)(R,{title:t(`providers.section.endpoints`),footer:t(`providers.endpointsFooter`),children:[o.endpoints.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 px-4 py-3`,children:[(0,$.jsx)(G,{className:`w-48`,value:e.protocol,onChange:e=>v(n,{protocol:e}),options:q}),(0,$.jsx)(T,{className:`min-w-60 flex-1 font-mono`,"aria-label":t(`providers.baseUrl`),value:e.baseUrl,onChange:e=>v(n,{baseUrl:e.target.value})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(V,{checked:!!e.fullUrl,label:t(`providers.fullUrl`),onChange:e=>v(n,{fullUrl:e})}),t(`providers.fullUrl`)]}),(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(X,{className:`size-3.5`}),"aria-label":t(`common.delete`),onClick:()=>m({endpoints:o.endpoints.filter((e,t)=>t!==n)})})]},n)),(0,$.jsx)(`div`,{className:`px-4 py-2`,children:(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(et,{className:`size-3.5`}),onClick:()=>d(!0),children:t(`providers.addEndpoint`)})}),(0,$.jsx)(A,{label:t(`providers.preferred`),detail:(0,$.jsxs)($.Fragment,{children:[t(`providers.preferredHint`),o.preferredUpstreamProtocols.filter(e=>!o.endpoints.some(t=>t.protocol===e)).map(e=>(0,$.jsx)(`span`,{className:`mt-1 block text-[var(--warning)]`,children:t(`providers.preferredMissing`,{protocol:q.find(t=>t.value===e)?.label??e})},e))]}),children:(0,$.jsx)(ot,{label:t(`providers.preferred`),options:q.map(e=>{let t=o.preferredUpstreamProtocols.indexOf(e.value);return{value:e.value,label:t>=0?`${t+1}. ${e.label}`:e.label}}),value:o.preferredUpstreamProtocols,onValueChange:e=>{let t=o.preferredUpstreamProtocols.filter(t=>e.includes(t)),n=e.filter(e=>!t.includes(e));m({preferredUpstreamProtocols:[...t,...n]})}})})]}),(0,$.jsxs)(R,{title:t(`providers.section.billing`),footer:t(`providers.billingFooter`),children:[(0,$.jsx)(A,{label:t(`providers.priceKey`),detail:t(`providers.priceKeyHint`),children:(0,$.jsx)(G,{className:`w-56`,value:o.priceKey==null?`inherit`:`price:${o.priceKey}`,onChange:e=>m({priceKey:e===`inherit`?null:e.slice(6)}),options:[{value:`inherit`,label:t(`providers.priceKeyDefault`,{id:e.templateId??`—`})},{value:`price:`,label:t(`providers.priceKeyNone`)},...(i.data??[]).map(e=>({value:`price:${e.priceKey}`,label:e.label,detail:e.priceKey}))]})}),(0,$.jsx)(A,{label:t(`providers.multiplier`),detail:t(`providers.multiplierHint`),children:(0,$.jsx)(N,{className:`w-28`,label:t(`providers.multiplier`),step:.01,min:0,value:o.priceMultiplier,onChange:e=>m({priceMultiplier:e??1})})})]}),(0,$.jsxs)(R,{title:t(`providers.section.advanced`),children:[(0,$.jsx)(A,{label:t(`providers.proxy`),detail:t(`providers.proxyHint`),children:(0,$.jsx)(T,{className:`w-64 font-mono`,"aria-label":t(`providers.proxy`),placeholder:`http://127.0.0.1:7890`,value:o.httpProxy??``,onChange:e=>m({httpProxy:e.target.value||null})})}),(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`div`,{className:`mb-2 text-[13px]`,children:t(`providers.headers`)}),c.map(([e,n],r)=>(0,$.jsxs)(`div`,{className:`mb-2 flex gap-2`,children:[(0,$.jsx)(T,{className:`w-48 font-mono`,"aria-label":t(`providers.headerName`),placeholder:`Header`,value:e,onChange:e=>l(c.map((t,n)=>n===r?[e.target.value,t[1]]:t))}),(0,$.jsx)(T,{className:`flex-1 font-mono`,"aria-label":t(`providers.headerValue`),placeholder:`value`,value:n,onChange:e=>l(c.map((t,n)=>n===r?[t[0],e.target.value]:t))}),(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(X,{className:`size-3.5`}),"aria-label":t(`common.delete`),onClick:()=>l(c.filter((e,t)=>t!==r))})]},r)),(0,$.jsx)(F,{size:`sm`,variant:`plain`,icon:(0,$.jsx)(et,{className:`size-3.5`}),onClick:()=>p(!0),children:t(`providers.addHeader`)})]}),Object.keys(e.settings).length>0&&(0,$.jsx)(`div`,{className:`px-4 py-3`,children:(0,$.jsx)(le,{label:t(`providers.adapterSettings`),rows:4,className:`w-full font-mono`,defaultValue:ke(o.settings),onBlur:e=>{try{m({settings:JSON.parse(e.target.value)})}catch{n(t(`common.invalidJson`),`error`)}}})})]}),(0,$.jsx)(R,{title:t(`providers.section.info`),children:(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(E,{label:`ID`,children:e.id}),e.adapterId&&(0,$.jsx)(E,{label:t(`providers.adapter`),children:e.adapterId}),(0,$.jsx)(E,{label:t(`providers.boundClients`),children:e.boundClients.map(e=>Z[e]?.name??e).join(`, `)||`—`})]})}),(0,$.jsx)(mn,{open:u,onOpenChange:d,onAdd:e=>m({endpoints:[...o.endpoints,e]})}),(0,$.jsx)(hn,{open:f,onOpenChange:p,onAdd:e=>l([...c.filter(([t])=>t.toLowerCase()!==e[0].toLowerCase()),e])}),(0,$.jsx)(`div`,{className:`sticky bottom-2 flex justify-end`,children:g&&(0,$.jsxs)(`div`,{className:`glass flex items-center gap-2 rounded-full p-1 pl-4 text-[12px]`,children:[(0,$.jsx)(`span`,{className:`text-[var(--text-secondary)]`,children:t(`common.unsaved`)}),(0,$.jsx)(F,{size:`sm`,onClick:()=>{s(a),l(Object.entries(a.extraHeaders))},children:t(`common.revert`)}),(0,$.jsx)(F,{size:`sm`,variant:`primary`,loading:r.isPending,onClick:_,children:t(`common.save`)})]})})]})}function mn({open:e,onOpenChange:t,onAdd:n}){let{t:r}=M(),[i,a]=(0,Q.useState)(`openai-chat`),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{e&&(s(``),l(!1))},[e]);let u=/^https?:\/\/\S+$/.test(o.trim());return(0,$.jsx)(U,{open:e,onOpenChange:t,title:r(`providers.addEndpoint`),description:r(`providers.addEndpointDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:!u,onClick:()=>{n({protocol:i,baseUrl:o.trim(),...c?{fullUrl:!0}:{}}),t(!1)},children:r(`common.add`)})]}),children:(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(k,{label:r(`providers.protocol`),children:(0,$.jsx)(G,{value:i,onChange:a,options:q})}),(0,$.jsx)(k,{label:r(`providers.baseUrl`),hint:r(c?`providers.fullUrlHint`:`providers.baseUrlHint`),children:(0,$.jsx)(T,{autoFocus:!0,className:`font-mono`,placeholder:`https://api.example.com/v1`,value:o,invalid:o!==``&&!u,onChange:e=>s(e.target.value)})}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-[12px] text-[var(--text-secondary)]`,children:[(0,$.jsx)(V,{checked:c,onChange:l,label:r(`providers.fullUrl`)}),r(`providers.fullUrl`)]})]})})}function hn({open:e,onOpenChange:t,onAdd:n}){let{t:r}=M(),[i,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``);(0,Q.useEffect)(()=>{e&&(a(``),s(``))},[e]);let c=/^[A-Za-z0-9-]+$/.test(i.trim());return(0,$.jsx)(U,{open:e,onOpenChange:t,title:r(`providers.addHeader`),description:r(`providers.addHeaderDetail`),footer:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{onClick:()=>t(!1),children:r(`common.cancel`)}),(0,$.jsx)(F,{variant:`primary`,disabled:!c,onClick:()=>{n([i.trim(),o]),t(!1)},children:r(`common.add`)})]}),children:(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsx)(k,{label:r(`providers.headerName`),children:(0,$.jsx)(T,{autoFocus:!0,className:`font-mono`,placeholder:`X-Custom-Header`,value:i,invalid:i!==``&&!c,onChange:e=>a(e.target.value)})}),(0,$.jsx)(k,{label:r(`providers.headerValue`),children:(0,$.jsx)(T,{className:`font-mono`,value:o,onChange:e=>s(e.target.value)})})]})})}export{$t as ProviderDetailPage};
|