@linkfox-web/app-kit 0.4.1 → 0.6.0
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/dist/chunk-KG3655ZD.js +2 -0
- package/dist/components/index.d.ts +11 -3
- package/dist/components/index.js +4 -4
- package/dist/runtime/index.d.ts +51 -1
- package/dist/runtime/index.js +1 -1
- package/package.json +11 -9
- package/theme-color.css +100 -0
- package/dist/chunk-Q7ASIOYP.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{f as M,g as B,h as U,j as W,l as K,s as $,x as N}from"./chunk-WREK6TXJ.js";import{clearCreditsExhausted as te,getCreditsError as ne,getRemainingCredits as re,isCreditsExhausted as oe,onCreditsExhausted as se}from"@linkfox-web/ai-tools/account";var _e="https://ai.linkfox.com/usercenter/pricing?tab=ai&plan=personalYearly";async function ie(){try{let{totalRemainingCredits:e}=await re();return Number.isFinite(e)?e:void 0}catch{return}}function Ae(){return oe()}function Le(){return ne()}function Ne(e){return se(()=>e())}async function Fe(){let e=await ie();return e!==void 0&&e>0&&te(),e}function $e(e){return e.type==="range"||e.type==="dateRange"?[`${e.id}.gte`,`${e.id}.lte`]:[e.id]}function ae(e){return(e??"").split(",").map(t=>t.trim()).filter(Boolean)}function De(e,t,o){let n=ae(e).filter(a=>a!==t);return o&&n.push(t),n.join(",")}function Be(e,t){for(let o of e){let n=o.items.find(a=>t===a.href||t.startsWith(`${a.href}/`));if(n)return{group:o,item:n}}return null}async function _(e){try{return await e}catch(t){throw N(t),t}}import*as y from"@linkfox-web/ai-tools/agent-os";var le=2500,ce=5,de=3,je=[{id:"default",name:"通用助手"},{id:"linkfox-product-selection-agent",name:"选品 Agent"},{id:"linkfox-market-analysis-agent",name:"市场分析 Agent"},{id:"linkfox-listing-agent",name:"Listing Agent"},{id:"linkfox-image-agent",name:"图片 Agent"},{id:"linkfox-video-agent",name:"视频 Agent"}],fe={read:"读取文件",execute:"执行命令",edit:"编辑文件",search:"搜索"},H=e=>e?.type==="text"||e?.type===void 0?e?.text??e?.value??"":"";function ue(e){return e.type!=="resource_link"||!e.uri?null:{name:decodeURIComponent(e.uri.split("?")[0].split("/").pop()??"")||e.name||"文件",uri:e.uri}}function pe(e){let t=new Map,o="";return e.forEach((n,a)=>{if(n.sessionUpdate==="tool_call"||n.sessionUpdate==="tool_call_update"){let d=n.toolCallId??`step-${a}`,b=t.get(d),h=n.title?.replace(/\(.*\)$/,"")||b?.title||fe[n.kind??""]||"处理中",w=n.status==="completed"?"done":n.status==="failed"?"failed":b?.status??"running";t.set(d,{id:d,title:h,status:w})}else(n.sessionUpdate==="agent_message_chunk"||n.sessionUpdate==null)&&(o+=H(n.content))}),{steps:[...t.values()],text:o}}function me(e){let t="",o=new Map;for(let{content:n}of e){if(!n)continue;let a=ue(n);a?o.set(a.uri,a):t+=H(n)}return{text:t,files:[...o.values()]}}function Ve(e){return _(y.cancelTask({messageId:e}))}async function Ye(e){try{return(await _(y.getShareUrl({messageId:e}))).shareUrl||void 0}catch{return}}async function qe(e,t,{signal:o,onUpdate:n,sessionId:a}){let d=await _(y.createTask(a?{prompt:e,modelId:t,sessionId:a}:{prompt:e,modelId:t},{signal:o}));if(!d.id)throw new M(500,"LinkFox OS 没有返回任务 ID");let b=d.id,h=d.sessionId||a||"";n({messageId:b,sessionId:h,steps:[],text:"",files:[],stopReason:""});let w=new Map,k=0,S=0;for(;;){await K(le,o);let A=Math.max(0,k-ce),I;try{I=await _(y.getTask({messageId:b,fromIndex:A},{signal:o})),S=0}catch(m){if(B(m)||W(m)||U(m)||++S>=de)throw m;continue}I.eventList?.forEach((m,R)=>w.set(A+R,m)),k=I.eventTotal??k;let F=[...w.entries()].sort((m,R)=>m[0]-R[0]).map(([,m])=>m),C=pe(F),L=I.message?.stopReason??"";if(L){let m=me(I.message?.agentMessageChunks??[]),R=C.steps.map(v=>v.status==="running"?{...v,status:"done"}:v);return{messageId:b,sessionId:h,steps:R,text:m.text||C.text,files:m.files,stopReason:L}}n({messageId:b,sessionId:h,steps:C.steps,text:C.text,files:[],stopReason:""})}}import{LinkfoxHttpError as ge}from"@linkfox-web/http";import*as u from"@linkfox-web/ai-tools/smart-table";function O(e,t){return new ge({service:"ai-tools",status:200,code:e,message:t})}var G=(e,t)=>(e.createdTime??"").localeCompare(t.createdTime??""),j=e=>Object.fromEntries(e.map(t=>[t.name,t.fieldId]));function V(e,t,o){let n=e.get(t);return n||(n=o(),e.set(t,n),n.catch(()=>e.delete(t))),n}function be(){return typeof window>"u"?!1:/(^|\.)app\.linkfox\.com$/.test(window.location.hostname)}var he=new Set(["主图"]);function Qe(e){let t=e.fields??{},o=new Map,n=new Map,a=new Map;async function d(s){try{return await s}catch(i){throw N(i),i}}async function b(s){let i=[];for(let r=1;r<=50;r++){let c=await d(u[s]({page:r,perPage:100})),l=c.notebooks??[];if(i.push(...l),l.length===0||i.length>=(c.total??0))break}return i}async function h(){let{notebookId:s,notebookName:i}=e,r=await b("listMyTables");if(s){let T=r.find(x=>x.notebookId===s)??(await b("listSharedTables")).find(x=>x.notebookId===s);if(!T)throw O(404,`找不到配置的多维表 ${s},请检查 .env 的 NEXT_PUBLIC_NOTE_BOOK_ID 或 linkfox.config.ts`);return T}if(be())throw O(500,"应用未绑定多维表(缺少 NEXT_PUBLIC_NOTE_BOOK_ID)。请重新打开应用完成初始化后再试。");let c=r.filter(T=>T.name===i).sort(G);if(c.length)return c[0];let l=(await b("listSharedTables")).filter(T=>T.name===i).sort(G);if(l.length)return l[0];let g=e.requestKeyPrefix??"linkfox-app",p=await d(u.createTable({name:i,requestKey:`${g}-${i}`}));return{notebookId:p.notebookId,name:p.notebookName,tables:[{tableId:p.tableId,name:p.name,url:p.url,refKey:p.refKey}]}}function w(){return V(o,$(),h)}function k(s,i){return V(n,`${$()}:${s}`,async()=>{let r=i??t[s];if(!r)throw O(500,`数据表 ${String(s)} 没有登记列定义,请在 linkfox.config.ts 的 smartTableConfig.fields 里补上`);let c=e.tables[s];if(!c)throw O(500,`数据表 ${String(s)} 没有登记表名,请在 smartTableConfig.tables 里补上`);let l=await w(),g=l.tables.find(f=>f.name===c);if(!g){let f=await d(u.addTable({notebookId:l.notebookId,name:c,fields:r})),E={tableId:f.tableId,name:f.name,url:f.url,refKey:f.refKey};return l.tables.push(E),{...E,fieldIds:j(f.fields??[])}}let{fields:p}=await d(u.listFields({tableId:g.tableId,includeChoices:!1})),T=r.filter(f=>he.has(f.name)&&p.some(E=>E.name===f.name&&E.type!==f.type)),x=p;if(T.length){let f=T.map(P=>P.name);x=(await d(u.deleteFields({tableId:g.tableId,fieldNames:f,allowBreakingDependents:!0}))).fields??p.filter(P=>!f.includes(P.name))}let ee=new Set(x.map(f=>f.name)),D=r.filter(f=>!ee.has(f.name));for(let f=0;f<D.length;f+=50)x=(await d(u.addFields({tableId:g.tableId,fields:D.slice(f,f+50)}))).fields??x;return{...g,fieldIds:j(x)}})}function S(s){return d(u.listRecords(s))}async function A(s,i=100){let r=[];for(let c=1;c<=i;c++){let l=await S({...s,page:c,perPage:100});if(r.push(...l.records),l.records.length<100||r.length>=l.total)break}return r}async function I(s,i){let r=[];for(let c=0;c<i.length;c+=50){let l=i.slice(c,c+50),g=await d(u.createRecords({tableId:s,records:l.map(p=>({fields:p}))}));if(r.push(...g.records??[]),g.created!==l.length)throw O(500,`已写入 ${r.length} 条,但有 ${l.length-g.created} 条未写入成功`)}return r}async function F(s,i){for(let r=0;r<i.length;r+=100){let c=i.slice(r,r+100),l=await d(u.updateRecords({tableId:s,records:c}));if(l.updated!==c.length)throw O(404,`只更新了 ${l.updated}/${c.length} 条,记录可能已被删除,请刷新后重试`)}}async function C(s,i){for(let r=0;r<i.length;r+=100)await d(u.deleteRecords({tableId:s,recordIds:i.slice(r,r+100)}))}function L(s,i,r,c){let l=`${s}:${i}:${r}`,p=(a.get(l)??Promise.resolve()).catch(()=>{}).then(()=>d(u.uploadAttachment({tableId:s,recordId:i,fieldName:r,imageUrl:c})).then(T=>T.attachment));return a.set(l,p),p.finally(()=>{a.get(l)===p&&a.delete(l)}).catch(()=>{}),p}async function m(s,i,r,c,l){return(await S({tableId:s,perPage:100,fieldNames:l,filter:{conditions:[{fieldName:i,operator:"is",value:r}]}})).records.find(p=>p.recordId===c)??null}function R(){return Promise.all(Object.keys(t).map(s=>k(s)))}async function v(s){return(await k(s)).tableId}return{config:e,TABLE_FIELDS:t,getNotebook:w,ensureTable:k,listRecords:S,listAllRecords:A,createRecords:I,updateRecords:F,deleteRecords:C,uploadAttachment:L,getRecord:m,warmTables:R,tableIdOf:v}}var Y;function Ze(e){Y=e}function q(){return Y}function Te(e){return Array.isArray(e)&&e.every(t=>t&&typeof t=="object"&&"token"in t)}function xe(e){return Te(e)?e[0]:void 0}function et(e,t="full"){let o=xe(e);return o&&(t==="thumb"?o.smThumbnailUrl??o.lgThumbnailUrl??o.presignedUrl:o.presignedUrl)||void 0}var ye=e=>e==null?"":typeof e=="string"?e:String(e),tt=e=>typeof e=="number"?e:Number(e)||0,nt=e=>ye(e).split(/[,,、\n]/).map(t=>t.trim()).filter(Boolean),rt=()=>new Date().toISOString();var we=["启用","禁用"],ke=[{name:"词条",type:"singleLineText"},{name:"中文名",type:"singleLineText"},{name:"状态",type:"singleSelect",choices:we.map(e=>({name:e}))},{name:"来源",type:"singleLineText"},{name:"创建时间",type:"date"}],Ie={brandWords:"品牌词",sensitiveWords:"敏感词"},Re=Object.keys(Ie);function Ee(e){function t(n){return e.ensureTable(n,ke)}async function o(){return(await Promise.all(Re.map(async a=>{let{tableId:d}=await t(a);return(await e.listAllRecords({tableId:d,fieldNames:["词条"],filter:{conditions:[{fieldName:"状态",operator:"is",value:"启用"}]}})).map(h=>String(h.fields.词条??"").trim()).filter(Boolean).map(h=>({word:h,kind:a}))}))).flat()}return{ensureWordTable:t,loadActiveWords:o}}function it(){let e=q();if(!e)throw new Error("多维表客户端尚未初始化:请确认模板的 lib/app-kit.ts 调用了 setActiveSmartTable(smartTable)");return Ee(e)}var Se=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),J=/[A-Za-z0-9]/;function at(e){let t=e.map(o=>{let n=o.word.replace(/\s+/g," "),a=J.test(n[0])?"(?<![\\p{L}\\p{N}])":"",d=J.test(n[n.length-1])?"(?![\\p{L}\\p{N}])":"";return{hit:o,re:new RegExp(`${a}${Se(n).replace(/ /g,"\\s+")}${d}`,"iu")}});return o=>{let n=o.filter(Boolean).join(`
|
|
2
|
+
`);return t.filter(a=>a.re.test(n)).map(a=>a.hit)}}var X=[{value:"orange",label:"活力橙",swatch:"#FB8C1E"},{value:"blue",label:"科技蓝",swatch:"#105BFF"},{value:"teal",label:"青绿",swatch:"#0D9488"},{value:"slate",label:"灰蓝",swatch:"#4F5A71"},{value:"ink",label:"墨黑",swatch:"#0C0C19"}],z="ink",Ce="linkfox:theme-color",Q="data-theme-color",Oe="linkfox:theme-color",Z=X.map(e=>e.value);function ct(e){return typeof e=="string"&&Z.includes(e)?e:z}function dt(e){document.documentElement.setAttribute(Q,e)}function ft(e){if(typeof window>"u"||window.parent===window)return;let t=X.find(o=>o.value===e);if(t)try{window.parent.postMessage({type:Oe,value:t.value,color:t.swatch},"*")}catch{}}var ut=`(function(){var d=${JSON.stringify(z)},v=d;try{v=localStorage.getItem(${JSON.stringify(Ce)})||d}catch(e){}if(${JSON.stringify(Z)}.indexOf(v)<0)v=d;document.documentElement.setAttribute(${JSON.stringify(Q)},v)})()`;export{_e as a,ie as b,Ae as c,Le as d,Ne as e,Fe as f,$e as g,ae as h,De as i,Be as j,_ as k,je as l,Ve as m,Ye as n,qe as o,Qe as p,Ze as q,q as r,Te as s,xe as t,et as u,ye as v,tt as w,nt as x,rt as y,we as z,ke as A,Ie as B,Ee as C,it as D,at as E,X as F,z as G,Ce as H,Q as I,Oe as J,ct as K,dt as L,ft as M,ut as N};
|
|
@@ -26,10 +26,15 @@ interface AppShellProps {
|
|
|
26
26
|
version?: string;
|
|
27
27
|
/** 右上角 LinkFox OS 助手的推荐提问 */
|
|
28
28
|
suggestions?: AgentSuggestions;
|
|
29
|
-
/**
|
|
29
|
+
/** 右上角额外操作,渲染在主题色配置之前 */
|
|
30
30
|
headerActions?: React.ReactNode;
|
|
31
|
+
/**
|
|
32
|
+
* 右上角「主题色配置」,默认显示。样式需宿主在 globals.css 里
|
|
33
|
+
* `@import "@linkfox-web/app-kit/theme-color.css";`,不接入主题色时传 false。
|
|
34
|
+
*/
|
|
35
|
+
themeColorPicker?: boolean;
|
|
31
36
|
}
|
|
32
|
-
declare function AppShell({ children, nav, appName, appSubtitle, version, suggestions, headerActions, }: AppShellProps): react.JSX.Element;
|
|
37
|
+
declare function AppShell({ children, nav, appName, appSubtitle, version, suggestions, headerActions, themeColorPicker, }: AppShellProps): react.JSX.Element;
|
|
33
38
|
|
|
34
39
|
interface AppSidebarProps {
|
|
35
40
|
/** 左侧多级菜单,由模板的 lib/nav.ts 提供 */
|
|
@@ -54,6 +59,9 @@ declare function CreditsDialog(): react.JSX.Element;
|
|
|
54
59
|
|
|
55
60
|
declare function ThemeProvider({ children, ...props }: react.ComponentProps<typeof ThemeProvider$1>): react.JSX.Element;
|
|
56
61
|
|
|
62
|
+
/** 右上角「主题色配置」:点色块即时预览,确认才保存,取消或关闭恢复原色 */
|
|
63
|
+
declare function ThemeColorPicker(): react.JSX.Element;
|
|
64
|
+
|
|
57
65
|
declare function TimezoneSelect(): react.JSX.Element;
|
|
58
66
|
|
|
59
67
|
declare function UserMenu(): react.JSX.Element | null;
|
|
@@ -283,4 +291,4 @@ declare function Markdown({ children }: {
|
|
|
283
291
|
children: string;
|
|
284
292
|
}): JSX.Element;
|
|
285
293
|
|
|
286
|
-
export { AgentPanel, type AgentSuggestions, AgentToggle, AppShell, type AppShellProps, AppSidebar, type AppSidebarProps, AuthGate, ColumnPicker, ComboInput, type ComboOption, ConfirmDialog, CreditsDialog, type DataColumn, DataPagination, DataTable, FilterPanel, Markdown, NavGroup, PAGE_SIZE, type StageCounts, type StageNode, type StageNodeState, StageProgress, TaskCard, type TaskCardBudget, type TaskCardData, type TaskCardStage, TaskLog, ThemeProvider, TimezoneSelect, UserMenu, WordManager, countsBalanced };
|
|
294
|
+
export { AgentPanel, type AgentSuggestions, AgentToggle, AppShell, type AppShellProps, AppSidebar, type AppSidebarProps, AuthGate, ColumnPicker, ComboInput, type ComboOption, ConfirmDialog, CreditsDialog, type DataColumn, DataPagination, DataTable, FilterPanel, Markdown, NavGroup, PAGE_SIZE, type StageCounts, type StageNode, type StageNodeState, StageProgress, TaskCard, type TaskCardBudget, type TaskCardData, type TaskCardStage, TaskLog, ThemeColorPicker, ThemeProvider, TimezoneSelect, UserMenu, WordManager, countsBalanced };
|
package/dist/components/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";import{B as ya,D as vo,a as Ja,b as ja,d as eo,e as to,f as ao,g as no,h as io,i as so,j as vt,l as ha,m as fo,n as go,o as bo,r as Re,z as Ca}from"../chunk-Q7ASIOYP.js";import{a as _t,b as wa,c as xo,d as Gt,e as ho,f as xt,h as Co,i as yo,j as wo,k as Na,m as No}from"../chunk-2DZYZ6RZ.js";import{g as oo,i as ro,k as fe,t as lo,u as co,v as po,w as mo,y as uo}from"../chunk-WREK6TXJ.js";import{Fragment as Li}from"react";import Fi from"next/link";import{usePathname as _i}from"next/navigation";import Ta from"next/link";import{usePathname as Bn}from"next/navigation";import{ChevronRightIcon as En}from"lucide-react";import{Collapsible as Pa}from"radix-ui";import{jsx as ka}from"react/jsx-runtime";function Ke({...e}){return ka(Pa.Root,{"data-slot":"collapsible",...e})}function Ue({...e}){return ka(Pa.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function We({...e}){return ka(Pa.CollapsibleContent,{"data-slot":"collapsible-content",...e})}import*as V from"react";import{cva as kn}from"class-variance-authority";import{cn as E}from"cn";import{Slot as Lo}from"radix-ui";import*as Po from"react";var nn=768,ko=`(max-width: ${nn-1}px)`;function sn(e){let t=window.matchMedia(ko);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function So(){return Po.useSyncExternalStore(sn,()=>window.matchMedia(ko).matches,()=>!1)}import{cva as ln}from"class-variance-authority";import{cn as dn}from"cn";import{Slot as cn}from"radix-ui";import{jsx as mn}from"react/jsx-runtime";var pn=ln("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function m({className:e,variant:t="default",size:a="default",asChild:o=!1,...r}){let i=o?cn.Root:"button";return mn(i,{"data-slot":"button","data-variant":t,"data-size":a,className:dn(pn({variant:t,size:a,className:e})),...r})}import{cn as un}from"cn";import{jsx as fn}from"react/jsx-runtime";function X({className:e,type:t,...a}){return fn("input",{type:t,"data-slot":"input",className:un("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}import{cn as gn}from"cn";import{Separator as bn}from"radix-ui";import{jsx as vn}from"react/jsx-runtime";function Ro({className:e,orientation:t="horizontal",decorative:a=!0,...o}){return vn(bn.Root,{"data-slot":"separator",decorative:a,orientation:t,className:gn("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",e),...o})}import{cn as ht}from"cn";import{Dialog as Te}from"radix-ui";import{XIcon as xn}from"lucide-react";import{jsx as ne,jsxs as Sa}from"react/jsx-runtime";function To({...e}){return ne(Te.Root,{"data-slot":"sheet",...e})}function hn({...e}){return ne(Te.Portal,{"data-slot":"sheet-portal",...e})}function Cn({className:e,...t}){return ne(Te.Overlay,{"data-slot":"sheet-overlay",className:ht("fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function Do({className:e,children:t,side:a="right",showCloseButton:o=!0,...r}){return Sa(hn,{children:[ne(Cn,{}),Sa(Te.Content,{"data-slot":"sheet-content","data-side":a,className:ht("fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10",e),...r,children:[t,o&&ne(Te.Close,{"data-slot":"sheet-close",asChild:!0,children:Sa(m,{variant:"ghost",className:"absolute top-3 right-3",size:"icon-sm",children:[ne(xn,{}),ne("span",{className:"sr-only",children:"Close"})]})})]})]})}function Io({className:e,...t}){return ne("div",{"data-slot":"sheet-header",className:ht("flex flex-col gap-0.5 p-4",e),...t})}function zo({className:e,...t}){return ne(Te.Title,{"data-slot":"sheet-title",className:ht("font-heading text-base font-medium text-foreground",e),...t})}function Ao({className:e,...t}){return ne(Te.Description,{"data-slot":"sheet-description",className:ht("text-sm text-muted-foreground",e),...t})}import{cn as yn}from"cn";import{jsx as wn}from"react/jsx-runtime";function Ot({className:e,...t}){return wn("div",{"data-slot":"skeleton",className:yn("animate-pulse rounded-md bg-muted",e),...t})}import{cn as Nn}from"cn";import{Tooltip as Ct}from"radix-ui";import{jsx as Vt,jsxs as Pn}from"react/jsx-runtime";function Mo({...e}){return Vt(Ct.Root,{"data-slot":"tooltip",...e})}function Bo({...e}){return Vt(Ct.Trigger,{"data-slot":"tooltip-trigger",...e})}function Eo({className:e,sideOffset:t=0,children:a,...o}){return Vt(Ct.Portal,{children:Pn(Ct.Content,{"data-slot":"tooltip-content",sideOffset:t,className:Nn("z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o,children:[a,Vt(Ct.Arrow,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}import{PanelLeftIcon as Sn}from"lucide-react";import{jsx as S,jsxs as yt}from"react/jsx-runtime";var Rn="sidebar_state",Tn=3600*24*7,Dn="16rem",In="18rem",zn="3rem",An="b",Fo=V.createContext(null);function Ze(){let e=V.useContext(Fo);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function _o({defaultOpen:e=!0,open:t,onOpenChange:a,className:o,style:r,children:i,...n}){let s=So(),[l,d]=V.useState(!1),[f,N]=V.useState(e),k=t??f,v=V.useCallback(y=>{let w=typeof y=="function"?y(k):y;a?a(w):N(w),document.cookie=`${Rn}=${w}; path=/; max-age=${Tn}`},[a,k]),C=V.useCallback(()=>s?d(y=>!y):v(y=>!y),[s,v,d]);V.useEffect(()=>{let y=w=>{w.key===An&&(w.metaKey||w.ctrlKey)&&(w.preventDefault(),C())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[C]);let h=k?"expanded":"collapsed",T=V.useMemo(()=>({state:h,open:k,setOpen:v,isMobile:s,openMobile:l,setOpenMobile:d,toggleSidebar:C}),[h,k,v,s,l,d,C]);return S(Fo.Provider,{value:T,children:S("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":Dn,"--sidebar-width-icon":zn,...r},className:E("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",o),...n,children:i})})}function Go({side:e="left",variant:t="sidebar",collapsible:a="offcanvas",className:o,children:r,dir:i,...n}){let{isMobile:s,state:l,openMobile:d,setOpenMobile:f}=Ze();return a==="none"?S("div",{"data-slot":"sidebar",className:E("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",o),...n,children:r}):s?S(To,{open:d,onOpenChange:f,...n,children:yt(Do,{dir:i,"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":In},side:e,children:[yt(Io,{className:"sr-only",children:[S(zo,{children:"Sidebar"}),S(Ao,{children:"Displays the mobile sidebar."})]}),S("div",{className:"flex h-full w-full flex-col",children:r})]})}):yt("div",{className:"group peer hidden text-sidebar-foreground md:block","data-state":l,"data-collapsible":l==="collapsed"?a:"","data-variant":t,"data-side":e,"data-slot":"sidebar",children:[S("div",{"data-slot":"sidebar-gap",className:E("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),S("div",{"data-slot":"sidebar-container","data-side":e,className:E("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",o),...n,children:S("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border",children:r})})]})}function Oo({className:e,onClick:t,...a}){let{toggleSidebar:o}=Ze();return yt(m,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon-sm",className:E(e),onClick:r=>{t?.(r),o()},...a,children:[S(Sn,{}),S("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function Vo({className:e,...t}){let{toggleSidebar:a}=Ze();return S("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:a,title:"Toggle Sidebar",className:E("absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2","in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})}function $o({className:e,...t}){return S("main",{"data-slot":"sidebar-inset",className:E("relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",e),...t})}function Ho({className:e,...t}){return S("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:E("flex flex-col gap-2 p-2",e),...t})}function Ko({className:e,...t}){return S("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:E("no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t})}function Uo({className:e,...t}){return S("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:E("relative flex w-full min-w-0 flex-col p-2",e),...t})}function Ra({className:e,...t}){return S("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:E("flex w-full min-w-0 flex-col gap-0",e),...t})}function $t({className:e,...t}){return S("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:E("group/menu-item relative",e),...t})}var Mn=kn("peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Ht({asChild:e=!1,isActive:t=!1,variant:a="default",size:o="default",tooltip:r,className:i,...n}){let s=e?Lo.Root:"button",{isMobile:l,state:d}=Ze(),f=S(s,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":o,"data-active":t,className:E(Mn({variant:a,size:o}),i),...n});return r?(typeof r=="string"&&(r={children:r}),yt(Mo,{children:[S(Bo,{asChild:!0,children:f}),S(Eo,{side:"right",align:"center",hidden:d!=="collapsed"||l,...r})]})):f}function Wo({className:e,...t}){return S("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:E("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",e),...t})}function Zo({className:e,...t}){return S("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:E("group/menu-sub-item relative",e),...t})}function qo({asChild:e=!1,size:t="md",isActive:a=!1,className:o,...r}){let i=e?Lo.Root:"a";return S(i,{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":t,"data-active":a,className:E("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",o),...r})}import{jsx as P,jsxs as De}from"react/jsx-runtime";function Da({nav:e,appName:t="LinkFox",appSubtitle:a,version:o}){let r=Bn(),i=vt(e,r),{isMobile:n,setOpenMobile:s}=Ze();return De(Go,{collapsible:"icon",children:[P(Ho,{children:P(Ra,{children:P($t,{children:P(Ht,{size:"lg",asChild:!0,children:De(Ta,{href:"/",children:[P("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary font-semibold text-sidebar-primary-foreground",children:"LF"}),De("div",{className:"flex flex-col gap-0.5 leading-none",children:[De("span",{className:"flex items-center gap-1.5 font-medium",children:[t,o?P("span",{className:"rounded border px-1 text-[10px] leading-4 font-normal text-muted-foreground tabular-nums",children:o}):null]}),a?P("span",{className:"text-xs text-muted-foreground",children:a}):null]})]})})})})}),P(Ko,{children:P(Uo,{children:P(Ra,{children:e.map(l=>{if(l.items.length===1){let d=l.items[0];return P($t,{children:P(Ht,{tooltip:l.title,isActive:i?.group===l,asChild:!0,children:De(Ta,{href:d.href,onClick:()=>n&&s(!1),children:[P(l.icon,{}),P("span",{children:l.title})]})})},l.title)}return P(Ke,{asChild:!0,defaultOpen:!0,className:"group/collapsible",children:De($t,{children:[P(Ue,{asChild:!0,children:De(Ht,{tooltip:l.title,isActive:i?.group===l,children:[P(l.icon,{}),P("span",{children:l.title}),P(En,{className:"ml-auto transition-transform group-data-[state=open]/collapsible:rotate-90"})]})}),P(We,{children:P(Wo,{children:l.items.map(d=>P(Zo,{children:P(qo,{asChild:!0,isActive:i?.item===d,children:P(Ta,{href:d.href,onClick:()=>n&&s(!1),children:P("span",{children:d.title})})})},d.href))})})]})},l.title)})})})}),P(Vo,{})]})}import{useEffect as $n,useState as Ia}from"react";import{CircleAlertIcon as Hn,ExternalLinkIcon as Kn,RefreshCwIcon as Un}from"lucide-react";import{cn as qe}from"cn";import{Dialog as Ce}from"radix-ui";import{XIcon as Ln}from"lucide-react";import{jsx as Q,jsxs as Kt}from"react/jsx-runtime";function Ut({...e}){return Q(Ce.Root,{"data-slot":"dialog",...e})}function Fn({...e}){return Q(Ce.Portal,{"data-slot":"dialog-portal",...e})}function _n({className:e,...t}){return Q(Ce.Overlay,{"data-slot":"dialog-overlay",className:qe("fixed inset-0 isolate z-50 bg-black/50 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function Wt({className:e,children:t,showCloseButton:a=!0,...o}){return Kt(Fn,{children:[Q(_n,{}),Kt(Ce.Content,{"data-slot":"dialog-content",className:qe("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o,children:[t,a&&Q(Ce.Close,{"data-slot":"dialog-close",asChild:!0,children:Kt(m,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm",children:[Q(Ln,{}),Q("span",{className:"sr-only",children:"关闭"})]})})]})]})}function Zt({className:e,...t}){return Q("div",{"data-slot":"dialog-header",className:qe("flex flex-col gap-2",e),...t})}function qt({className:e,showCloseButton:t=!1,children:a,...o}){return Kt("div",{"data-slot":"dialog-footer",className:qe("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...o,children:[a,t&&Q(Ce.Close,{asChild:!0,children:Q(m,{variant:"outline",children:"Close"})})]})}function Xt({className:e,...t}){return Q(Ce.Title,{"data-slot":"dialog-title",className:qe("font-heading text-base leading-none font-medium",e),...t})}function Qt({className:e,...t}){return Q(Ce.Description,{"data-slot":"dialog-description",className:qe("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}import{cn as Gn}from"cn";import{Loader2Icon as On}from"lucide-react";import{jsx as Vn}from"react/jsx-runtime";function U({className:e,...t}){return Vn(On,{"data-slot":"spinner",role:"status","aria-label":"Loading",className:Gn("size-4 animate-spin",e),...t})}import{jsx as ie,jsxs as Ie}from"react/jsx-runtime";var Wn={login:{title:"算力余额不足",lead:"当前账号可用算力为 0,LinkFox 的付费工具暂时无法调用。"},team:{title:"算力余额不足,已暂停请求",lead:"当前账号可用算力不足,本次操作已停止;为避免重复消耗,后续请求不会再发起。"},member:{title:"已达到团队设置的算力限额",lead:"你的算力使用已达到团队管理员设置的上限,本次操作已停止,后续请求不会再发起。"}},Zn="如果你是团队管理员,可以前往充值,或在「团队管理」中为成员提高算力限额;如果你是团队成员,请联系团队管理员充值或调整你的限额。",qn="请联系团队管理员在「团队管理」中提高你的算力限额。",Xo=!1;function za(){let[e,t]=Ia(),[a,o]=Ia(!1),[r,i]=Ia(!1);function n(d){Xo||(Xo=!0,i(!1),t(d))}$n(()=>{let d=!1;ja().then(N=>{!d&&N===0&&n("login")});let f=to(()=>{d||n(ro(eo())?"member":"team")});return()=>{d=!0,f()}},[]);async function s(){o(!0),i(!1);let d=await ao();o(!1),d!==void 0&&d>0?t(void 0):i(!0)}let l=e?Wn[e]:void 0;return ie(Ut,{open:!!e,onOpenChange:d=>!d&&t(void 0),children:Ie(Wt,{className:"sm:max-w-md",children:[Ie(Zt,{children:[Ie(Xt,{className:"flex items-center gap-2",children:[ie(Hn,{className:"size-4 text-destructive"}),l?.title]}),Ie(Qt,{className:"space-y-2 pt-1",children:[ie("span",{className:"block text-foreground",children:l?.lead}),ie("span",{className:"block",children:e==="member"?qn:Zn}),r&&ie("span",{className:"block text-destructive",children:"仍未检测到可用算力。充值到账后请稍等片刻再试,或联系团队管理员确认额度。"})]})]}),Ie(qt,{children:[ie(m,{variant:"ghost",onClick:()=>t(void 0),children:"暂不处理"}),Ie(m,{variant:"outline",onClick:()=>{s()},disabled:a,children:[a?ie(U,{}):ie(Un,{}),"我已充值,重新检查"]}),ie(m,{asChild:!0,children:Ie("a",{href:Ja,target:"_blank",rel:"noreferrer",children:["前往充值",ie(Kn,{})]})})]})]})})}import{useEffect as Ba,useRef as Ea,useState as Le}from"react";import{BotIcon as ri,CheckCircle2Icon as ni,ChevronDownIcon as ii,ExternalLinkIcon as si,FileTextIcon as li,MessageCirclePlusIcon as Jo,SendIcon as di,SparklesIcon as jo,SquareIcon as ci,TableIcon as pi,Trash2Icon as mi,XCircleIcon as ui,XIcon as er}from"lucide-react";import Xn from"react-markdown";import Qn from"remark-gfm";import{jsx as Xe}from"react/jsx-runtime";function Y(e,t){function a({node:o,...r}){return Xe(e,{className:t,...r})}return a}var Yn={p:Y("p","my-1.5 leading-relaxed"),ul:Y("ul","my-1.5 list-disc pl-5"),ol:Y("ol","my-1.5 list-decimal pl-5"),li:Y("li","my-0.5"),h1:Y("h3","mt-3 mb-1 font-semibold"),h2:Y("h3","mt-3 mb-1 font-semibold"),h3:Y("h4","mt-2 mb-1 font-semibold"),a:({href:e,children:t})=>Xe("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"break-all text-primary underline underline-offset-2",children:t}),code:Y("code","rounded bg-muted px-1 py-0.5 font-mono text-xs"),pre:Y("pre","my-2 overflow-x-auto rounded-md bg-muted p-2 text-xs [&_code]:bg-transparent [&_code]:p-0"),table:({children:e})=>Xe("div",{className:"my-2 overflow-x-auto rounded-md border",children:Xe("table",{className:"w-full text-xs",children:e})}),th:Y("th","border-b bg-muted px-2 py-1 text-left font-medium whitespace-nowrap"),td:Y("td","border-b px-2 py-1 align-top"),blockquote:Y("blockquote","my-2 border-l-2 pl-3 text-muted-foreground")};function Aa({children:e}){return Xe("div",{className:"text-sm break-words",children:Xe(Xn,{remarkPlugins:[Qn],components:Yn,children:e})})}import{cn as ze}from"cn";import{Select as W}from"radix-ui";import{ChevronDownIcon as Qo,CheckIcon as Jn,ChevronUpIcon as jn}from"lucide-react";import{jsx as M,jsxs as Ma}from"react/jsx-runtime";function Ae({...e}){return M(W.Root,{"data-slot":"select",...e})}function wt({className:e,...t}){return M(W.Group,{"data-slot":"select-group",className:ze("scroll-my-1 p-1",e),...t})}function Me({...e}){return M(W.Value,{"data-slot":"select-value",...e})}function Be({className:e,size:t="default",children:a,...o}){return Ma(W.Trigger,{"data-slot":"select-trigger","data-size":t,className:ze("flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o,children:[a,M(W.Icon,{asChild:!0,children:M(Qo,{className:"pointer-events-none size-4 text-muted-foreground"})})]})}function Ee({className:e,children:t,position:a="item-aligned",align:o="center",...r}){return M(W.Portal,{children:Ma(W.Content,{"data-slot":"select-content","data-align-trigger":a==="item-aligned",className:ze("relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:a,align:o,...r,children:[M(ei,{}),M(W.Viewport,{"data-position":a,className:ze("data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)",a==="popper"&&""),children:t}),M(ti,{})]})})}function ge({className:e,children:t,...a}){return Ma(W.Item,{"data-slot":"select-item",className:ze("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...a,children:[M("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center",children:M(W.ItemIndicator,{children:M(Jn,{className:"pointer-events-none"})})}),M(W.ItemText,{children:t})]})}function ei({className:e,...t}){return M(W.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:ze("z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:M(jn,{})})}function ti({className:e,...t}){return M(W.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:ze("z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:M(Qo,{})})}import{cn as ai}from"cn";import{jsx as oi}from"react/jsx-runtime";function Yo({className:e,...t}){return oi("textarea",{"data-slot":"textarea",className:ai("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...t})}import{cn as fi}from"cn";import{Fragment as hi,jsx as p,jsxs as R}from"react/jsx-runtime";var gi=["介绍一下这个应用现在能做什么","帮我梳理接下来可以加哪些功能"],bi="例如:帮我把当前页面的数据按状态汇总一下",tr=e=>ha.find(t=>t.id===e)?.name??e;function La({suggestions:e}){let{open:t,setOpen:a,page:o}=Na(),[r,i]=Le(),[n,s]=Le([]),[l,d]=Le(""),[f,N]=Le("default"),[k,v]=Le(!0),[C,h]=Le(""),T=Ea(null),y=Ea(null),w=Ea(null),q=n.some(g=>g.running),Pe=!!o&&(!!o.table||o.records.length>0),pe=()=>h("");Ba(()=>{!t||r||Re()?.getNotebook().then(g=>i({notebookId:g.notebookId,name:g.name})).catch(()=>{})},[t,r]);let j=o?`${o.table?.id}:${o.records.map(g=>g.id).join(",")}`:"",[ft,gt]=Le(j);j!==ft&&(gt(j),v(!0)),Ba(()=>{w.current?.scrollIntoView({block:"end"})},[n]),Ba(()=>()=>T.current?.abort(),[]);let me=(g,u)=>s(D=>D.map(z=>z.id===g?{...z,...u}:z)),ue=async(g=l)=>{let u=g.trim();if(!u||q)return;let D=k&&Pe?o:null,z=crypto.randomUUID(),he=C;s(B=>[...B,{id:z,input:u,context:D,modelId:f,running:!0,followUp:!!he}]),d("");let re=new AbortController;T.current=re,y.current=null;try{let B=await bo(No(u,he?null:D,r),f,{signal:re.signal,sessionId:he||void 0,onUpdate:Se=>{y.current=Se.messageId,Se.sessionId&&h(Se.sessionId),me(z,{task:Se})}});B.sessionId&&h(B.sessionId),me(z,{task:B,running:!1,error:B.stopReason==="end_turn"?void 0:`任务异常结束(${B.stopReason})`}),window.dispatchEvent(new Event(yo));let ke=await go(B.messageId);ke&&me(z,{shareUrl:ke})}catch(B){me(z,{running:!1,error:oo(B)?"已停止":fe(B)})}finally{T.current===re&&(T.current=null)}},bt=()=>{let g=y.current;T.current?.abort(),g&&fo(g).catch(()=>{})},va=e?.items??[],xa=(o?va.find(g=>o.source.endsWith(g.match))?.items:void 0)??e?.fallback??gi;return R("aside",{"aria-label":"LinkFox OS 助手",className:fi("z-40 flex flex-col border-l bg-background","fixed inset-0 md:sticky md:top-0 md:h-svh md:w-1/4 md:min-w-90 md:shrink-0 md:self-start",!t&&"hidden"),children:[R("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b px-3",children:[p(jo,{className:"size-4 text-primary"}),p("span",{className:"font-medium",children:"LinkFox OS"}),R(Ae,{value:f,onValueChange:g=>{N(g),pe()},disabled:q,children:[p(Be,{size:"sm",className:"ml-auto w-32","aria-label":"选择 Agent",children:p(Me,{})}),p(Ee,{align:"end",children:ha.map(g=>p(ge,{value:g.id,children:g.name},g.id))})]}),p(m,{variant:"ghost",size:"icon-sm","aria-label":"开新对话(不保留上下文)",title:"开新对话:下一条消息不再续接当前会话",disabled:q||!C,onClick:pe,children:p(Jo,{})}),p(m,{variant:"ghost",size:"icon-sm","aria-label":"清空对话",disabled:q||!n.length,onClick:()=>{s([]),pe()},children:p(mi,{})}),p(m,{variant:"ghost",size:"icon-sm","aria-label":"关闭助手",onClick:()=>a(!1),children:p(er,{})})]}),R("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-3",children:[n.length===0?R("div",{className:"flex flex-col gap-3 py-6 text-sm text-muted-foreground",children:[R("div",{className:"flex items-center gap-2 text-foreground",children:[p(ri,{className:"size-5"}),p("span",{className:"font-medium",children:"让 LinkFox 帮你干活"})]}),p("p",{children:"描述你要完成的事,LinkFox OS 会自己调用选品、数据查询、生图、多维表等技能去执行。勾选的记录会自动带上。"}),p("div",{className:"flex flex-col gap-2",children:xa.map(g=>p("button",{type:"button",className:"rounded-lg border px-3 py-2 text-left text-foreground transition-colors hover:bg-muted",onClick:()=>d(g),children:g},g))})]}):p("div",{className:"flex flex-col gap-4",children:n.map(g=>p(xi,{item:g,notebook:r},g.id))}),p("div",{ref:w})]}),R("div",{className:"shrink-0 border-t p-3",children:[C?R("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[p(Jo,{className:"size-3.5 shrink-0"}),R("span",{className:"min-w-0 flex-1",children:["接着上一轮聊(",tr(f)," 记得前面的内容,可以直接追问)"]}),p("button",{type:"button",className:"shrink-0 text-primary underline-offset-2 hover:underline",onClick:pe,children:"开新对话"})]}):R(hi,{children:[Pe&&k&&o&&p(vi,{context:o,notebook:r,onRemove:()=>v(!1)}),Pe&&!k&&p("button",{type:"button",className:"mb-2 text-xs text-primary underline-offset-2 hover:underline",onClick:()=>v(!0),children:"重新带入当前页面的数据表和勾选记录"})]}),R("div",{className:"flex items-end gap-2",children:[p(Yo,{value:l,onChange:g=>d(g.target.value),onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&!g.nativeEvent.isComposing&&(g.preventDefault(),ue())},placeholder:C?"接着问,例如:把第 3 条展开说说 / 换个角度再看一遍":e?.placeholder??bi,"aria-label":"告诉 LinkFox 要做什么",className:"max-h-40 min-h-16 resize-none"}),q?p(m,{size:"icon",variant:"outline","aria-label":"停止",onClick:bt,children:p(ci,{})}):p(m,{size:"icon","aria-label":"发送",disabled:!l.trim(),onClick:()=>ue(),children:p(di,{})})]}),p("p",{className:"mt-2 text-xs text-muted-foreground",children:"执行会消耗 LinkFox 算力。Enter 发送,Shift+Enter 换行。"})]})]})}function vi({context:e,notebook:t,onRemove:a}){let o=e.records.length;return R(Ke,{className:"mb-2 rounded-lg border bg-muted/40 text-xs",children:[R("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[p(pi,{className:"size-3.5 shrink-0 text-muted-foreground"}),R("div",{className:"min-w-0 flex-1",children:[e.table&&R("div",{className:"truncate",children:[t?`${t.name} / `:"",e.table.name]}),p("div",{className:"text-muted-foreground",children:o?`已勾选 ${o} 条记录,将一并发送`:`当前页面:${e.source}`})]}),o>0&&p(Ue,{asChild:!0,children:p(m,{variant:"ghost",size:"icon-xs","aria-label":"查看勾选记录",className:"[&[data-state=open]>svg]:rotate-180",children:p(ii,{})})}),p(m,{variant:"ghost",size:"icon-xs","aria-label":"不带入上下文",onClick:a,children:p(er,{})})]}),o>0&&p(We,{children:p("ul",{className:"max-h-32 overflow-y-auto border-t px-2.5 py-1.5",children:e.records.map(r=>p("li",{className:"truncate py-0.5",title:r.label,children:r.label},r.id))})})]})}function xi({item:e,notebook:t}){let{task:a,context:o}=e,r=a?.steps??[];return R("div",{className:"flex flex-col gap-2",children:[R("div",{className:"ml-6 self-end rounded-lg bg-primary px-3 py-2 text-sm whitespace-pre-wrap text-primary-foreground",children:[e.input,o&&R("div",{className:"mt-1.5 border-t border-primary-foreground/20 pt-1.5 text-xs opacity-80",children:[o.table?`${t?`${t.name} / `:""}${o.table.name}`:o.source,o.records.length?` · 勾选 ${o.records.length} 条`:""]})]}),R("div",{className:"mr-2 flex flex-col gap-2 rounded-lg border px-3 py-2",children:[R("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[p("span",{children:tr(e.modelId)}),e.followUp&&p("span",{className:"rounded bg-muted px-1.5 py-0.5",children:"接上一轮"})]}),r.length>0&&p("ul",{className:"flex flex-col gap-1 text-xs",children:r.map(i=>R("li",{className:"flex items-center gap-1.5",children:[i.status==="running"?p(U,{className:"size-3"}):i.status==="failed"?p(ui,{className:"size-3 text-destructive"}):p(ni,{className:"size-3 text-emerald-600"}),p("span",{className:"truncate",children:i.status==="running"?`正在调用 ${i.title}`:i.title})]},i.id))}),a?.text?p(Aa,{children:a.text}):e.running&&R("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[p(U,{})," ",a?"LinkFox 正在处理…":"正在提交任务…"]}),a&&a.files.length>0&&p("ul",{className:"flex flex-col gap-1",children:a.files.map(i=>p("li",{children:R("a",{href:i.uri,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-xs text-primary underline-offset-2 hover:underline",children:[p(li,{className:"size-3.5 shrink-0"}),p("span",{className:"truncate",children:i.name})]})},i.uri))}),e.error&&p("div",{className:"text-sm text-destructive",children:e.error}),e.shareUrl&&R("a",{href:e.shareUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 self-start text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:["查看完整过程 ",p(si,{className:"size-3"})]})]})]})}function Fa(){let{open:e,setOpen:t}=Na();return R(m,{variant:e?"secondary":"default",size:"sm",onClick:()=>t(a=>!a),"aria-expanded":e,"aria-label":"让LinkFox帮你干活",children:[p(jo,{}),p("span",{className:"hidden sm:inline",children:"让LinkFox帮你干活"})]})}import{useMemo as ki,useState as Si}from"react";import{CheckIcon as ur,GlobeIcon as Ri}from"lucide-react";import{Command as Je}from"cmdk";import{cn as je}from"cn";import{cva as ar}from"class-variance-authority";import{cn as Nt}from"cn";import{jsx as Pt}from"react/jsx-runtime";function Qe({className:e,...t}){return Pt("div",{"data-slot":"input-group",role:"group",className:Nt("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",e),...t})}var Ci=ar("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function Ye({className:e,align:t="inline-start",...a}){return Pt("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:Nt(Ci({align:t}),e),onClick:o=>{o.target.closest("button")||o.currentTarget.parentElement?.querySelector("input")?.focus()},...a})}var yi=ar("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function or({className:e,type:t="button",variant:a="ghost",size:o="xs",...r}){return Pt(m,{type:t,"data-size":o,variant:a,className:Nt(yi({size:o}),e),...r})}function rr({className:e,...t}){return Pt("span",{className:Nt("flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",e),...t})}function Yt({className:e,...t}){return Pt(X,{"data-slot":"input-group-control",className:Nt("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",e),...t})}import{SearchIcon as wi,CheckIcon as Ni}from"lucide-react";import{jsx as be,jsxs as dr}from"react/jsx-runtime";function nr({className:e,...t}){return be(Je,{"data-slot":"command",className:je("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",e),...t})}function ir({className:e,...t}){return be("div",{"data-slot":"command-input-wrapper",className:"p-1 pb-0",children:dr(Qe,{className:"h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!",children:[be(Je.Input,{"data-slot":"command-input",className:je("w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t}),be(Ye,{children:be(wi,{className:"size-4 shrink-0 opacity-50"})})]})})}function sr({className:e,...t}){return be(Je.List,{"data-slot":"command-list",className:je("no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",e),...t})}function lr({className:e,...t}){return be(Je.Empty,{"data-slot":"command-empty",className:je("py-6 text-center text-sm",e),...t})}function Jt({className:e,...t}){return be(Je.Group,{"data-slot":"command-group",className:je("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",e),...t})}function _a({className:e,children:t,...a}){return dr(Je.Item,{"data-slot":"command-item",className:je("group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",e),...a,children:[t,be(Ni,{className:"ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100"})]})}import{cn as Pi}from"cn";import{Popover as jt}from"radix-ui";import{jsx as ea}from"react/jsx-runtime";function cr({...e}){return ea(jt.Root,{"data-slot":"popover",...e})}function pr({...e}){return ea(jt.Trigger,{"data-slot":"popover-trigger",...e})}function mr({className:e,align:t="center",sideOffset:a=4,...o}){return ea(jt.Portal,{children:ea(jt.Content,{"data-slot":"popover-content",align:t,sideOffset:a,className:Pi("z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o})})}import{cn as fr}from"cn";import{jsx as $,jsxs as Fe}from"react/jsx-runtime";var Ga=["Asia/Shanghai","America/Los_Angeles","America/New_York","Europe/London","Europe/Berlin","Asia/Tokyo","UTC"];function Ti(){try{return Intl.supportedValuesOf("timeZone")}catch{return Ga}}function Oa(){let[e,t]=Si(!1),a=Gt(),o=ho(),r=ki(()=>e?Ti().filter(s=>!Ga.includes(s)).map(s=>({zone:s,offset:xt(s)})):[],[e]),i=s=>{xo(s),t(!1)},n=(s,l=xt(s))=>Fe(_a,{value:`${s} ${l}`,onSelect:()=>i(s),children:[$(ur,{className:fr(!o&&s===a?"opacity-100":"opacity-0")}),$("span",{className:"truncate",children:s}),$("span",{className:"ml-auto text-xs text-muted-foreground",children:l})]},s);return Fe(cr,{open:e,onOpenChange:t,children:[$(pr,{asChild:!0,children:Fe(m,{variant:"outline",size:"sm","aria-label":`选择时区 ${a} ${xt(a)}`,children:[$(Ri,{"data-icon":"inline-start"}),$("span",{className:"hidden max-w-40 truncate sm:inline",children:a})," ",$("span",{className:"text-muted-foreground",children:xt(a)})]})}),$(mr,{align:"end",className:"w-80 p-0",children:Fe(nr,{children:[$(ir,{placeholder:"搜索时区,如 Shanghai、UTC+08"}),Fe(sr,{children:[$(lr,{children:"没有匹配的时区"}),$(Jt,{heading:"默认",children:Fe(_a,{value:`跟随浏览器 ${wa()}`,onSelect:()=>i(null),children:[$(ur,{className:fr(o?"opacity-100":"opacity-0")}),Fe("span",{className:"truncate",children:["跟随浏览器(",wa(),")"]})]})}),$(Jt,{heading:"常用",children:Ga.map(s=>n(s))}),$(Jt,{heading:"全部",children:r.map(s=>n(s.zone,s.offset))})]})]})})]})}import{LogOutIcon as zi,UserIcon as Ai}from"lucide-react";import{cn as kt}from"cn";import{DropdownMenu as se}from"radix-ui";import{CheckIcon as Di,ChevronRightIcon as vc}from"lucide-react";import{jsx as ee,jsxs as Ii}from"react/jsx-runtime";function et({...e}){return ee(se.Root,{"data-slot":"dropdown-menu",...e})}function tt({...e}){return ee(se.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function at({className:e,align:t="start",sideOffset:a=4,...o}){return ee(se.Portal,{children:ee(se.Content,{"data-slot":"dropdown-menu-content",sideOffset:a,align:t,className:kt("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o})})}function St({...e}){return ee(se.Group,{"data-slot":"dropdown-menu-group",...e})}function _e({className:e,inset:t,variant:a="default",...o}){return ee(se.Item,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":a,className:kt("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",e),...o})}function gr({className:e,children:t,checked:a,inset:o,...r}){return Ii(se.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item","data-inset":o,className:kt("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:a,...r,children:[ee("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:ee(se.ItemIndicator,{children:ee(Di,{})})}),t]})}function Rt({className:e,inset:t,...a}){return ee(se.Label,{"data-slot":"dropdown-menu-label","data-inset":t,className:kt("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",e),...a})}function ta({className:e,...t}){return ee(se.Separator,{"data-slot":"dropdown-menu-separator",className:kt("-mx-1 my-1 h-px bg-border",e),...t})}import{Fragment as Mi,jsx as ot,jsxs as Tt}from"react/jsx-runtime";function Va(){let e=_t();return e.status!=="ready"?null:Tt(et,{children:[ot(tt,{asChild:!0,children:ot(m,{variant:"ghost",size:"icon","aria-label":"账号",children:ot(Ai,{})})}),Tt(at,{align:"end",children:[ot(Rt,{children:e.userName||"LinkFox 用户"}),e.apiKey&&Tt(Rt,{className:"font-normal text-muted-foreground",children:["API Key:",uo(e.apiKey)]}),!e.apiKey&&Tt(Mi,{children:[ot(ta,{}),Tt(_e,{onSelect:mo,children:[ot(zi,{}),"退出登录"]})]})]})]})}import{cn as rt}from"cn";import{Slot as Bi}from"radix-ui";import{ChevronRightIcon as Ei,MoreHorizontalIcon as Dc}from"lucide-react";import{jsx as Ge,jsxs as zc}from"react/jsx-runtime";function br({className:e,...t}){return Ge("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:rt(e),...t})}function vr({className:e,...t}){return Ge("ol",{"data-slot":"breadcrumb-list",className:rt("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",e),...t})}function $a({className:e,...t}){return Ge("li",{"data-slot":"breadcrumb-item",className:rt("inline-flex items-center gap-1",e),...t})}function xr({asChild:e,className:t,...a}){let o=e?Bi.Root:"a";return Ge(o,{"data-slot":"breadcrumb-link",className:rt("transition-colors hover:text-foreground",t),...a})}function hr({className:e,...t}){return Ge("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:rt("font-normal text-foreground",e),...t})}function Cr({children:e,className:t,...a}){return Ge("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:rt("[&>svg]:size-3.5",t),...a,children:e??Ge(Ei,{})})}import{jsx as A,jsxs as Dt}from"react/jsx-runtime";function Gi({children:e,nav:t,appName:a,appSubtitle:o,version:r,suggestions:i,headerActions:n}){let s=_i(),l=vt(t,s),d=l?[...new Set([l.group.title,l.item.title])]:[];return A(wo,{children:Dt(_o,{children:[A(Da,{nav:t,appName:a,appSubtitle:o,version:r}),Dt($o,{className:"min-w-0",children:[Dt("header",{className:"sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2 border-b bg-background px-4",children:[A(Oo,{className:"-ml-1"}),A(Ro,{orientation:"vertical",className:"mr-2 data-[orientation=vertical]:h-4"}),A(br,{className:"min-w-0 flex-1",children:Dt(vr,{children:[A($a,{className:"hidden md:inline-flex",children:A(xr,{asChild:!0,children:A(Fi,{href:"/",children:"首页"})})}),d.map((f,N)=>Dt(Li,{children:[A(Cr,{className:N===0?"hidden md:block":void 0}),A($a,{className:N<d.length-1?"hidden md:inline-flex":void 0,children:N===d.length-1?A(hr,{children:f}):A("span",{children:f})})]},f))]})}),A(Fa,{}),n,A(Oa,{}),A(Va,{})]}),A("main",{className:"flex min-w-0 flex-1 flex-col gap-4 p-4",children:e})]}),A(La,{suggestions:i}),A(za,{})]})})}import{useEffect as $i}from"react";import{CircleAlertIcon as Hi,LogInIcon as Nr,RotateCwIcon as Ki}from"lucide-react";import{cva as Oi}from"class-variance-authority";import{cn as nt}from"cn";import{jsx as it}from"react/jsx-runtime";function aa({className:e,...t}){return it("div",{"data-slot":"empty",className:nt("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance",e),...t})}function oa({className:e,...t}){return it("div",{"data-slot":"empty-header",className:nt("flex max-w-sm flex-col items-center gap-2",e),...t})}var Vi=Oi("mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default"}});function yr({className:e,variant:t="default",...a}){return it("div",{"data-slot":"empty-icon","data-variant":t,className:nt(Vi({variant:t,className:e})),...a})}function ra({className:e,...t}){return it("div",{"data-slot":"empty-title",className:nt("font-heading text-sm font-medium tracking-tight",e),...t})}function na({className:e,...t}){return it("div",{"data-slot":"empty-description",className:nt("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...t})}function wr({className:e,...t}){return it("div",{"data-slot":"empty-content",className:nt("flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",e),...t})}import{jsx as J,jsxs as ia}from"react/jsx-runtime";function Ui({children:e}){let t=_t();if($i(()=>{lo()},[]),t.status==="ready")return e;let a=t.status==="redirecting"&&t.auto;if(t.status==="loading"||t.status==="callback"||a)return ia("div",{className:"flex min-h-svh items-center justify-center gap-2",role:"status",children:[J(U,{}),J("span",{children:t.status==="callback"?"正在完成登录…":a?"正在跳转登录…":"正在准备登录…"})]});let o=t.status==="error",r=t.status==="redirecting";return J("div",{className:"flex min-h-svh items-center justify-center bg-muted p-4",children:ia(aa,{className:"max-w-md bg-background",children:[ia(oa,{children:[J(yr,{variant:"icon",children:o?J(Hi,{}):J(Nr,{})}),J(ra,{children:o?"无法进入选品工作台":"登录 LinkFox"}),J(na,{children:o?t.message:"使用 LinkFox 账号登录,登录状态将在此浏览器中保留至到期或退出。"})]}),J(wr,{children:ia(m,{disabled:r,onClick:o&&t.action==="config"?()=>{co()}:()=>{po()},children:[r?J(U,{"data-icon":"inline-start"}):o?J(Ki,{"data-icon":"inline-start"}):J(Nr,{"data-icon":"inline-start"}),r?"正在跳转…":o?"重试":"登录 LinkFox"]})})]})})}import*as Pr from"react";import{ThemeProvider as Wi,useTheme as Zi}from"next-themes";import{jsx as Yi,jsxs as Ji}from"react/jsx-runtime";function qi({children:e,...t}){return Ji(Wi,{attribute:"class",defaultTheme:"system",enableSystem:!0,disableTransitionOnChange:!0,...t,children:[Yi(Qi,{}),e]})}function Xi(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT":!1}function Qi(){let{resolvedTheme:e,setTheme:t}=Zi();return Pr.useEffect(()=>{function a(o){o.defaultPrevented||o.repeat||o.metaKey||o.ctrlKey||o.altKey||o.key.toLowerCase()==="d"&&(Xi(o.target)||t(e==="dark"?"light":"dark"))}return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[e,t]),null}import{cn as ji}from"cn";import{Checkbox as kr}from"radix-ui";import{CheckIcon as es}from"lucide-react";import{jsx as Ha}from"react/jsx-runtime";function Oe({className:e,...t}){return Ha(kr.Root,{"data-slot":"checkbox",className:ji("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary",e),...t,children:Ha(kr.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:Ha(es,{})})})}import{cn as st}from"cn";import{jsx as Ve}from"react/jsx-runtime";function sa({className:e,...t}){return Ve("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:Ve("table",{"data-slot":"table",className:st("w-full caption-bottom text-sm",e),...t})})}function la({className:e,...t}){return Ve("thead",{"data-slot":"table-header",className:st("[&_tr]:border-b",e),...t})}function da({className:e,...t}){return Ve("tbody",{"data-slot":"table-body",className:st("[&_tr:last-child]:border-0",e),...t})}function ve({className:e,...t}){return Ve("tr",{"data-slot":"table-row",className:st("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function te({className:e,...t}){return Ve("th",{"data-slot":"table-head",className:st("h-10 px-2 text-left align-middle font-medium text-foreground [&:has([role=checkbox])]:pr-0",e),...t})}function H({className:e,...t}){return Ve("td",{"data-slot":"table-cell",className:st("p-2 align-middle break-words [&:has([role=checkbox])]:pr-0",e),...t})}import{cn as ca}from"cn";import{jsx as L,jsxs as pa}from"react/jsx-runtime";var Sr=56,Rr=120;function ts({columns:e,rows:t,rowKey:a,renderCell:o,actions:r,actionsWidth:i=200,selection:n,onRowClick:s,loading:l,skeletonRows:d=8,empty:f,className:N}){let k=e.length+(n?1:0)+(r?1:0),C={"--dt-min-width":`${e.reduce((h,T)=>h+(T.width??Rr),0)+(n?Sr:0)+(r?i:0)}px`};return pa(sa,{style:C,className:ca("lg:[min-width:var(--dt-min-width)] max-lg:block",N),children:[L(la,{className:"max-lg:hidden",children:pa(ve,{children:[n&&L(te,{style:{width:Sr},className:"lg:sticky lg:left-0 lg:z-20 lg:bg-card",children:L(Oe,{"aria-label":"全选本页",checked:n.pageAllSelected?!0:n.pageSomeSelected?"indeterminate":!1,disabled:!t.length,onCheckedChange:h=>n.onToggleAll(h===!0)})}),e.map(h=>L(te,{style:{width:h.width??Rr},className:"break-words",children:h.label},h.key)),r&&L(te,{style:{width:i},className:"text-right lg:sticky lg:right-0 lg:z-20 lg:border-l lg:bg-card",children:"操作"})]})}),pa(da,{className:"max-lg:block",children:[l&&t.length===0?Array.from({length:d},(h,T)=>L(ve,{className:"max-lg:block max-lg:border-0",children:L(H,{colSpan:k,className:"max-lg:block",children:L(Ot,{className:"h-10 w-full"})})},T)):t.map(h=>{let T=a(h);return pa(ve,{"data-state":n?.selected.has(T)?"selected":void 0,onClick:s?()=>s(h):void 0,className:ca("group/row",l&&"opacity-60",s&&"cursor-pointer","max-lg:mb-3 max-lg:block max-lg:rounded-lg max-lg:border max-lg:p-3"),children:[n&&L(H,{className:"max-lg:flex max-lg:items-center max-lg:border-0 max-lg:px-0 max-lg:py-1 lg:sticky lg:left-0 lg:z-10 lg:bg-card lg:group-hover/row:bg-muted",children:L(Oe,{"aria-label":"选择本行",checked:n.selected.has(T),onCheckedChange:y=>n.onToggleRow(h,y===!0),onClick:y=>y.stopPropagation()})}),e.map(y=>L(H,{"data-label":y.label,className:ca("align-top break-words","max-lg:flex max-lg:gap-3 max-lg:border-0 max-lg:px-0 max-lg:py-1","max-lg:before:w-24 max-lg:before:shrink-0 max-lg:before:text-xs max-lg:before:text-muted-foreground","max-lg:before:content-[attr(data-label)]"),children:L("div",{className:"min-w-0 flex-1",children:o(h,y)})},y.key)),r&&L(H,{className:ca("align-top text-right max-lg:flex max-lg:justify-end max-lg:border-0 max-lg:px-0 max-lg:py-1","lg:sticky lg:right-0 lg:z-10 lg:border-l lg:bg-card lg:group-hover/row:bg-muted"),children:L("div",{className:"flex justify-end gap-1",onClick:y=>y.stopPropagation(),children:r(h)})})]},T)}),!l&&t.length===0&&f?L(ve,{className:"max-lg:block max-lg:border-0 hover:bg-transparent",children:L(H,{colSpan:k,className:"whitespace-normal max-lg:block",children:f})}):null]})]})}import{cn as lt}from"cn";import{ChevronLeftIcon as as,ChevronRightIcon as os,MoreHorizontalIcon as rs}from"lucide-react";import{jsx as ae,jsxs as Ka}from"react/jsx-runtime";function Tr({className:e,...t}){return ae("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:lt("mx-auto flex w-full justify-center",e),...t})}function Dr({className:e,...t}){return ae("ul",{"data-slot":"pagination-content",className:lt("flex items-center gap-0.5",e),...t})}function It({...e}){return ae("li",{"data-slot":"pagination-item",...e})}function ma({className:e,isActive:t,size:a="icon",...o}){return ae(m,{asChild:!0,variant:t?"outline":"ghost",size:a,className:lt(e),children:ae("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,...o})})}function Ir({className:e,text:t="Previous",...a}){return Ka(ma,{"aria-label":"Go to previous page",size:"default",className:lt("pl-1.5!",e),...a,children:[ae(as,{"data-icon":"inline-start"}),ae("span",{className:"hidden sm:block",children:t})]})}function zr({className:e,text:t="Next",...a}){return Ka(ma,{"aria-label":"Go to next page",size:"default",className:lt("pr-1.5!",e),...a,children:[ae("span",{className:"hidden sm:block",children:t}),ae(os,{"data-icon":"inline-end"})]})}function Ar({className:e,...t}){return Ka("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:lt("flex size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4",e),...t,children:[ae(rs,{}),ae("span",{className:"sr-only",children:"More pages"})]})}import{cn as Mr}from"cn";import{jsx as le,jsxs as Ua}from"react/jsx-runtime";var zt=20;function ns(e,t){if(t<=7)return Array.from({length:t},(i,n)=>n+1);let a=[1],o=Math.max(2,e-1),r=Math.min(t-1,e+1);o>2&&a.push("…");for(let i=o;i<=r;i++)a.push(i);return r<t-1&&a.push("…"),a.push(t),a}function Wa({page:e,total:t,disabled:a,onChange:o,pageSize:r=zt,note:i}){let n=Math.max(1,Math.ceil(t/r)),s=d=>f=>{f.preventDefault(),!(a||d<1||d>n||d===e)&&o(d)},l=d=>Mr(d&&"pointer-events-none opacity-50");return Ua("div",{className:"flex flex-col items-center justify-between gap-2 sm:flex-row",children:[Ua("p",{className:"text-sm text-muted-foreground",children:["共 ",t.toLocaleString("zh-CN")," 条,第 ",e,"/",n," 页,每页 ",r," 条",i?le("span",{className:"ml-2",children:i}):null]}),le(Tr,{className:"mx-0 w-auto",children:Ua(Dr,{children:[le(It,{children:le(Ir,{href:"#",text:"上一页","aria-label":"上一页",onClick:s(e-1),className:l(a||e<=1)})}),ns(e,n).map((d,f)=>d==="…"?le(It,{className:"hidden sm:block",children:le(Ar,{})},`e${f}`):le(It,{className:Mr(d!==e&&"hidden sm:block"),children:le(ma,{href:"#",isActive:d===e,onClick:s(d),className:l(!!a),children:d})},d)),le(It,{children:le(zr,{href:"#",text:"下一页","aria-label":"下一页",onClick:s(e+1),className:l(a||e>=n)})})]})})]})}import{useState as us}from"react";import{ChevronDownIcon as fs,RotateCcwIcon as gs,SearchIcon as bs}from"lucide-react";import{ChevronDownIcon as is}from"lucide-react";import{jsx as ye,jsxs as Br}from"react/jsx-runtime";function dt({id:e,value:t,onChange:a,options:o,placeholder:r,multiple:i}){let n=s=>{if(!i)return a(s);let l=t.split(/[,,、]/).map(d=>d.trim()).filter(Boolean);a(l.includes(s)?l.join(","):[...l,s].join(","))};return Br(Qe,{children:[ye(Yt,{id:e,value:t,placeholder:r??"请选择或输入",onChange:s=>a(s.target.value)}),ye(Ye,{align:"inline-end",children:Br(et,{children:[ye(tt,{asChild:!0,children:ye(or,{size:"icon-xs","aria-label":"展开选项",children:ye(is,{})})}),ye(at,{align:"end",className:"max-h-72 overflow-y-auto",children:ye(St,{children:o.map(s=>ye(_e,{onSelect:()=>n(s.value),children:s.label??s.value},s.value))})})]})})]})}import{cn as Er}from"cn";import{jsx as Lr}from"react/jsx-runtime";function At({className:e,size:t="default",...a}){return Lr("div",{"data-slot":"card","data-size":t,className:Er("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",e),...a})}function Mt({className:e,...t}){return Lr("div",{"data-slot":"card-content",className:Er("px-(--card-spacing)",e),...t})}import{useMemo as cs}from"react";import{cva as ps}from"class-variance-authority";import{cn as ua}from"cn";import{cn as ss}from"cn";import{Label as ls}from"radix-ui";import{jsx as ds}from"react/jsx-runtime";function ct({className:e,...t}){return ds(ls.Root,{"data-slot":"label",className:ss("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}import{jsx as pt,jsxs as Xp}from"react/jsx-runtime";function mt({className:e,...t}){return pt("div",{"data-slot":"field-group",className:ua("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",e),...t})}var ms=ps("group/field flex w-full gap-2 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function F({className:e,orientation:t="vertical",...a}){return pt("div",{role:"group","data-slot":"field","data-orientation":t,className:ua(ms({orientation:t}),e),...a})}function _({className:e,...t}){return pt(ct,{"data-slot":"field-label",className:ua("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",e),...t})}function Fr({className:e,children:t,errors:a,...o}){let r=cs(()=>{if(t)return t;if(!a?.length)return null;let i=[...new Map(a.map(n=>[n?.message,n])).values()];return i?.length==1?i[0]?.message:pt("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:i.map((n,s)=>n?.message&&pt("li",{children:n.message},s))})},[t,a]);return r?pt("div",{role:"alert","data-slot":"field-error",className:ua("text-sm font-normal text-destructive",e),...o,children:r}):null}import{cn as _r}from"cn";import{jsx as x,jsxs as I}from"react/jsx-runtime";var Gr="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4";function Or({spec:e,values:t,set:a,currency:o}){let r=`ff-${e.id}`;switch(e.type){case"range":{let i=e.price?o:e.unit,n=(s,l,d)=>I(Qe,{children:[x(Yt,{id:s.endsWith("gte")?r:void 0,inputMode:"decimal","aria-label":`${e.label}${d}`,placeholder:l,value:t[s]??"",onChange:f=>a(s,f.target.value)}),i&&x(Ye,{align:"inline-end",children:x(rr,{children:i})})]});return I(F,{children:[x(_,{htmlFor:r,children:e.label}),I("div",{className:"flex items-center gap-2",children:[n(`${e.id}.gte`,"最小","最小值"),x("span",{className:"text-muted-foreground",children:"至"}),n(`${e.id}.lte`,"最大","最大值")]})]})}case"dateRange":return I(F,{children:[x(_,{htmlFor:r,children:e.label}),I("div",{className:"flex items-center gap-2",children:[x(X,{id:r,type:"date","aria-label":`${e.label}开始`,value:t[`${e.id}.gte`]??"",onChange:i=>a(`${e.id}.gte`,i.target.value)}),x("span",{className:"text-muted-foreground",children:"至"}),x(X,{type:"date","aria-label":`${e.label}结束`,value:t[`${e.id}.lte`]??"",onChange:i=>a(`${e.id}.lte`,i.target.value)})]})]});case"text":return I(F,{children:[x(_,{htmlFor:r,children:e.label}),x(X,{id:r,placeholder:e.placeholder,value:t[e.id]??"",onChange:i=>a(e.id,i.target.value)})]});case"list":return I(F,{children:[x(_,{htmlFor:r,children:e.label}),e.options?x(dt,{id:r,placeholder:e.placeholder,value:t[e.id]??"",options:e.options.map(i=>({value:i})),multiple:e.multiple,onChange:i=>a(e.id,i)}):x(X,{id:r,placeholder:e.placeholder,value:t[e.id]??"",onChange:i=>a(e.id,i.target.value)})]});case"flags":{let i=io(t[e.id]);return I(F,{children:[x(_,{children:e.label}),x("div",{className:"flex flex-wrap gap-x-4 gap-y-2 pt-1",children:e.options.map(n=>I(ct,{className:"flex items-center gap-2 font-normal",children:[x(Oe,{checked:i.includes(n.value),onCheckedChange:s=>a(e.id,so(t[e.id],n.value,s===!0))}),n.label]},n.value))})]})}case"bool":case"select":{let i=e.type==="bool"?[{value:"yes",label:"是"},{value:"no",label:"否"}]:e.options,n=e.type==="select"&&e.required,s=n?t[e.id]||i[0]?.value:t[e.id]||"any";return I(F,{children:[x(_,{htmlFor:r,children:e.label}),I(Ae,{value:s,onValueChange:l=>a(e.id,l==="any"?"":l),children:[x(Be,{id:r,className:"w-full",children:x(Me,{})}),x(Ee,{children:I(wt,{children:[!n&&x(ge,{value:"any",children:"不限"}),i.map(l=>x(ge,{value:l.value,children:l.label},l.value))]})})]})]})}}}function vs({primary:e,more:t,values:a,onChange:o,onSearch:r,onReset:i,loading:n,currency:s,searchLabel:l="查询",searchIcon:d,disabled:f,prepend:N,append:k,note:v}){let[C,h]=us(!1),T=(w,q)=>o({...a,[w]:q}),y=t.filter(w=>no(w).some(q=>a[q])).length;return x(At,{children:x(Mt,{children:I("form",{onSubmit:w=>{w.preventDefault(),r()},className:"flex flex-col gap-4",children:[I(mt,{className:Gr,children:[N,e.map(w=>x(Or,{spec:w,values:a,set:T,currency:s},w.id)),k]}),I(Ke,{open:C,onOpenChange:h,children:[x(We,{children:x(mt,{className:_r(Gr,"pb-4"),children:t.map(w=>x(Or,{spec:w,values:a,set:T,currency:s},w.id))})}),I("div",{className:"flex flex-wrap items-center gap-2",children:[I(m,{type:"submit",disabled:n||f,children:[n?x(U,{"data-icon":"inline-start"}):d??x(bs,{"data-icon":"inline-start"}),l]}),I(m,{type:"button",variant:"outline",onClick:i,children:[x(gs,{"data-icon":"inline-start"}),"重置"]}),t.length>0&&x(Ue,{asChild:!0,children:I(m,{type:"button",variant:"ghost",children:["更多条件",y?`(已填 ${y})`:"",x(fs,{"data-icon":"inline-end",className:_r("transition-transform",C&&"rotate-180")})]})}),v&&x("p",{className:"text-xs text-muted-foreground sm:ml-auto",children:v})]})]})]})})})}import{Columns3Icon as xs}from"lucide-react";import{jsx as $e,jsxs as Bt}from"react/jsx-runtime";function hs({columns:e,visible:t,onChange:a,onReset:o}){return Bt(et,{children:[$e(tt,{asChild:!0,children:Bt(m,{variant:"outline",size:"sm",children:[$e(xs,{"data-icon":"inline-start"}),"列设置"]})}),Bt(at,{align:"end",className:"max-h-96 w-56 overflow-y-auto",children:[Bt(Rt,{children:["显示的列(",t.length,"/",e.length,")"]}),Bt(St,{children:[$e(_e,{onSelect:r=>(r.preventDefault(),o()),children:"恢复默认"}),$e(_e,{onSelect:r=>(r.preventDefault(),a(e.map(i=>i.key))),children:"全部显示"})]}),$e(ta,{}),$e(St,{children:e.map(r=>$e(gr,{checked:t.includes(r.key),onSelect:i=>i.preventDefault(),onCheckedChange:i=>a(i?e.map(n=>n.key).filter(n=>n===r.key||t.includes(n)):t.filter(n=>n!==r.key)),children:r.label},r.key))})]})]})}import{useState as Ns}from"react";import{cn as we}from"cn";import{AlertDialog as Ne}from"radix-ui";import{jsx as Z,jsxs as ws}from"react/jsx-runtime";function Vr({...e}){return Z(Ne.Root,{"data-slot":"alert-dialog",...e})}function Cs({...e}){return Z(Ne.Portal,{"data-slot":"alert-dialog-portal",...e})}function ys({className:e,...t}){return Z(Ne.Overlay,{"data-slot":"alert-dialog-overlay",className:we("fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function $r({className:e,size:t="default",...a}){return ws(Cs,{children:[Z(ys,{}),Z(Ne.Content,{"data-slot":"alert-dialog-content","data-size":t,className:we("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none max-w-[calc(100%-2rem)] sm:max-w-sm data-[size=sm]:sm:max-w-xs data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...a})]})}function Hr({className:e,...t}){return Z("div",{"data-slot":"alert-dialog-header",className:we("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function Kr({className:e,...t}){return Z("div",{"data-slot":"alert-dialog-footer",className:we("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function Ur({className:e,...t}){return Z(Ne.Title,{"data-slot":"alert-dialog-title",className:we("font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function Wr({className:e,...t}){return Z(Ne.Description,{"data-slot":"alert-dialog-description",className:we("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function Zr({className:e,variant:t="default",size:a="default",...o}){return Z(m,{variant:t,size:a,asChild:!0,children:Z(Ne.Action,{"data-slot":"alert-dialog-action",className:we(e),...o})})}function qr({className:e,variant:t="outline",size:a="default",...o}){return Z(m,{variant:t,size:a,asChild:!0,children:Z(Ne.Cancel,{"data-slot":"alert-dialog-cancel",className:we(e),...o})})}import{jsx as xe,jsxs as fa}from"react/jsx-runtime";function Za({open:e,onOpenChange:t,title:a,description:o,details:r,requireCheck:i,confirmLabel:n="确认",cancelLabel:s="取消",destructive:l,busy:d,onConfirm:f}){let[N,k]=Ns(!1),v=!!i&&!N;return xe(Vr,{open:e,onOpenChange:C=>{C||k(!1),t(C)},children:fa($r,{children:[fa(Hr,{children:[xe(Ur,{children:a}),o&&xe(Wr,{children:o})]}),r?.length?xe("ul",{className:"list-disc space-y-1 pl-5 text-sm text-muted-foreground",children:r.map((C,h)=>xe("li",{children:C},h))}):null,i&&fa(ct,{className:"flex items-start gap-2 text-sm font-normal",children:[xe(Oe,{checked:N,onCheckedChange:C=>k(C===!0),className:"mt-0.5"}),xe("span",{children:i})]}),fa(Kr,{children:[xe(qr,{children:s}),xe(Zr,{variant:l?"destructive":void 0,disabled:d||v,onClick:C=>{C.preventDefault(),!v&&f()},children:n})]})]})})}import{useCallback as zs,useEffect as As,useState as K}from"react";import{PencilIcon as Ms,PlusIcon as Bs,PowerIcon as Es,RotateCcwIcon as Ls,SearchIcon as Fs,Trash2Icon as _s}from"lucide-react";import{toast as ut}from"sonner";import{cva as Ps}from"class-variance-authority";import{cn as qa}from"cn";import{jsx as Xa}from"react/jsx-runtime";var ks=Ps("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"}},defaultVariants:{variant:"default"}});function Xr({className:e,variant:t,...a}){return Xa("div",{"data-slot":"alert",role:"alert",className:qa(ks({variant:t}),e),...a})}function Qr({className:e,...t}){return Xa("div",{"data-slot":"alert-title",className:qa("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",e),...t})}function Yr({className:e,...t}){return Xa("div",{"data-slot":"alert-description",className:qa("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",e),...t})}import{cva as Ss}from"class-variance-authority";import{cn as Rs}from"cn";import{Slot as Ts}from"radix-ui";import{jsx as Is}from"react/jsx-runtime";var Ds=Ss("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function ga({className:e,variant:t="default",asChild:a=!1,...o}){let r=a?Ts.Root:"span";return Is(r,{"data-slot":"badge","data-variant":t,className:Rs(Ds({variant:t}),e),...o})}import{jsx as c,jsxs as b}from"react/jsx-runtime";var Jr=[{value:"手动添加"},{value:"侵权投诉"},{value:"商标库"},{value:"平台通知"},{value:"行业经验"}],Et={word:"",cnName:"",status:"all",source:""},oe=e=>e==null?"":String(e);function Gs({kind:e,description:t}){let a=ya[e],o=Gt(),[r,i]=K(),[n,s]=K(""),[l,d]=K(Et),[f,N]=K(Et),[k,v]=K(1),[C,h]=K([]),[T,y]=K(0),[w,q]=K(!1),[Pe,pe]=K(null),[j,ft]=K(null),[gt,me]=K(),ue=zs(async(u,D,z)=>{let he=Re();if(!he)throw new Error("多维表客户端尚未初始化");let re=[];D.word.trim()&&re.push({fieldName:"词条",operator:"contains",value:D.word.trim()}),D.cnName.trim()&&re.push({fieldName:"中文名",operator:"contains",value:D.cnName.trim()}),D.status!=="all"&&re.push({fieldName:"状态",operator:"is",value:D.status}),D.source.trim()&&re.push({fieldName:"来源",operator:"contains",value:D.source.trim()}),N(D),q(!0);try{let B=rn=>he.listRecords({tableId:u,page:rn,perPage:zt,fieldNames:["词条","中文名","状态","来源","创建时间"],filter:re.length?{conjunction:"and",conditions:re}:void 0}),ke=await B(z),Se=Math.max(1,Math.ceil(ke.total/zt));z>Se&&(z=Se,ke=await B(z)),v(z),h(ke.records),y(ke.total)}catch(B){ut.error(`查询失败:${fe(B)}`)}finally{q(!1)}},[]);As(()=>{try{vo().ensureWordTable(e).then(u=>(i(u.tableId),ue(u.tableId,Et,1))).catch(u=>s(fe(u)))}catch(u){s(fe(u))}},[e,ue]);let bt=()=>r?ue(r,f,k):Promise.resolve(),va=u=>{u?.preventDefault(),r&&ue(r,{...l},1)},Ya=()=>{d(Et),r&&ue(r,Et,1)},xa=async u=>{let D=Re();if(!r||!D)return;let z=u.fields.状态==="启用"?"禁用":"启用";me(u.recordId);try{await D.updateRecords(r,[{recordId:u.recordId,fields:{状态:z}}]),ut.success(`已${z}「${oe(u.fields.词条)}」`),await bt()}catch(he){ut.error(fe(he))}finally{me(void 0)}},g=async()=>{let u=Re();if(!(!r||!j||!u)){me(j.recordId);try{await u.deleteRecords(r,[j.recordId]),ut.success(`已删除「${oe(j.fields.词条)}」`),ft(null),await bt()}catch(D){ut.error(fe(D))}finally{me(void 0)}}};return n?b(Xr,{variant:"destructive",children:[b(Qr,{children:["无法打开",a,"表"]}),c(Yr,{children:n})]}):b("div",{className:"flex flex-col gap-4",children:[b("div",{children:[c("h1",{className:"text-lg font-semibold",children:a}),c("p",{className:"text-sm text-muted-foreground",children:t})]}),c(At,{children:c(Mt,{children:b("form",{onSubmit:va,children:[b(mt,{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[b(F,{children:[c(_,{htmlFor:`${e}-q-word`,children:"词条"}),c(X,{id:`${e}-q-word`,value:l.word,placeholder:"包含",onChange:u=>d({...l,word:u.target.value})})]}),b(F,{children:[c(_,{htmlFor:`${e}-q-cn`,children:"中文名"}),c(X,{id:`${e}-q-cn`,value:l.cnName,placeholder:"包含",onChange:u=>d({...l,cnName:u.target.value})})]}),b(F,{children:[c(_,{htmlFor:`${e}-q-status`,children:"状态"}),b(Ae,{value:l.status,onValueChange:u=>d({...l,status:u}),children:[c(Be,{id:`${e}-q-status`,className:"w-full",children:c(Me,{})}),c(Ee,{children:b(wt,{children:[c(ge,{value:"all",children:"全部"}),Ca.map(u=>c(ge,{value:u,children:u},u))]})})]})]}),b(F,{children:[c(_,{htmlFor:`${e}-q-source`,children:"来源"}),c(dt,{id:`${e}-q-source`,value:l.source,options:Jr,onChange:u=>d({...l,source:u})})]})]}),b("div",{className:"mt-4 flex flex-wrap gap-2",children:[b(m,{type:"submit",disabled:!r||w,children:[c(Fs,{"data-icon":"inline-start"}),"查询"]}),b(m,{type:"button",variant:"outline",onClick:Ya,children:[c(Ls,{"data-icon":"inline-start"}),"重置"]}),b(m,{type:"button",variant:"secondary",className:"sm:ml-auto",disabled:!r,onClick:()=>pe("new"),children:[c(Bs,{"data-icon":"inline-start"}),"新增",a]})]})]})})}),c(At,{children:b(Mt,{className:"flex flex-col gap-4",children:[b(sa,{children:[c(la,{children:b(ve,{children:[c(te,{children:"词条"}),c(te,{children:"中文名"}),c(te,{children:"状态"}),c(te,{children:"来源"}),c(te,{children:"创建时间"}),c(te,{className:"sticky right-0 bg-background text-right",children:"操作"})]})}),c(da,{children:(w||!r)&&C.length===0?Array.from({length:5},(u,D)=>c(ve,{children:c(H,{colSpan:6,children:c(Ot,{className:"h-6 w-full"})})},D)):C.map(u=>b(ve,{className:w?"opacity-60":void 0,children:[c(H,{className:"font-medium",children:oe(u.fields.词条)}),c(H,{children:oe(u.fields.中文名)||"-"}),c(H,{children:c(ga,{variant:u.fields.状态==="启用"?"default":"secondary",children:oe(u.fields.状态)||"-"})}),c(H,{children:oe(u.fields.来源)||"-"}),c(H,{className:"whitespace-nowrap",children:Co(u.fields.创建时间,o)}),c(H,{className:"sticky right-0 bg-background",children:b("div",{className:"flex justify-end gap-1",children:[b(m,{variant:"ghost",size:"sm",onClick:()=>pe(u),children:[c(Ms,{"data-icon":"inline-start"}),"修改"]}),b(m,{variant:"ghost",size:"sm",disabled:gt===u.recordId,onClick:()=>xa(u),children:[gt===u.recordId?c(U,{"data-icon":"inline-start"}):c(Es,{"data-icon":"inline-start"}),u.fields.状态==="启用"?"禁用":"启用"]}),b(m,{variant:"ghost",size:"sm",onClick:()=>ft(u),children:[c(_s,{"data-icon":"inline-start"}),"删除"]})]})})]},u.recordId))})]}),!w&&r&&C.length===0&&c(aa,{children:b(oa,{children:[b(ra,{children:["暂无",a]}),b(na,{children:["点击「新增",a,"」添加第一条词条。"]})]})}),c(Wa,{page:k,total:T,disabled:w,onChange:u=>r&&ue(r,f,u)})]})}),Pe&&r&&c(Os,{kind:e,tableId:r,record:Pe==="new"?null:Pe,onClose:()=>pe(null),onSaved:()=>{pe(null),bt()}}),c(Za,{open:!!j,onOpenChange:u=>!u&&ft(null),title:`删除${a}「${oe(j?.fields.词条)}」?`,description:"删除后无法恢复。只想暂时不用的话,可以改为「禁用」。",confirmLabel:"删除",destructive:!0,busy:gt===j?.recordId,onConfirm:g})]})}function Os({kind:e,tableId:t,record:a,onClose:o,onSaved:r}){let i=ya[e],[n,s]=K({词条:oe(a?.fields.词条),中文名:oe(a?.fields.中文名),状态:oe(a?.fields.状态)||"启用",来源:oe(a?.fields.来源)||(a?"":"手动添加")}),[l,d]=K(""),[f,N]=K(!1);return c(Ut,{open:!0,onOpenChange:v=>!v&&o(),children:c(Wt,{className:"flex max-h-[90svh] flex-col",children:b("form",{onSubmit:async v=>{v.preventDefault();let C=Re();if(!C){d("多维表客户端尚未初始化");return}let h=n.词条.trim();if(!h){d("请输入词条");return}N(!0),d("");try{if((await C.listRecords({tableId:t,perPage:5,fieldNames:["词条"],filter:{conditions:[{fieldName:"词条",operator:"is",value:h}]}})).records.some(w=>w.recordId!==a?.recordId)){d(`「${h}」已存在`);return}let y={...n,词条:h,中文名:n.中文名.trim(),来源:n.来源.trim()};a?await C.updateRecords(t,[{recordId:a.recordId,fields:y}]):await C.createRecords(t,[{...y,创建时间:new Date().toISOString()}]),ut.success(a?"已保存修改":`已新增${i}「${h}」`),r()}catch(T){d(fe(T))}finally{N(!1)}},className:"flex min-h-0 flex-1 flex-col gap-4",children:[b(Zt,{children:[c(Xt,{children:a?`修改${i}`:`新增${i}`}),c(Qt,{children:"启用状态的词条会在「添加到选品库」时用于过滤商品。"})]}),c("div",{className:"-mx-4 min-h-0 flex-1 overflow-y-auto overscroll-contain px-4",children:b(mt,{children:[b(F,{"data-invalid":l?!0:void 0,children:[c(_,{htmlFor:"word-term",children:"词条"}),c(X,{id:"word-term",autoFocus:!0,value:n.词条,"aria-invalid":l?!0:void 0,onChange:v=>s({...n,词条:v.target.value})}),l&&c(Fr,{children:l})]}),b(F,{children:[c(_,{htmlFor:"word-cn",children:"中文名"}),c(X,{id:"word-cn",value:n.中文名,onChange:v=>s({...n,中文名:v.target.value})})]}),b(F,{children:[c(_,{htmlFor:"word-status",children:"状态"}),b(Ae,{value:n.状态,onValueChange:v=>s({...n,状态:v}),children:[c(Be,{id:"word-status",className:"w-full",children:c(Me,{})}),c(Ee,{children:c(wt,{children:Ca.map(v=>c(ge,{value:v,children:v},v))})})]})]}),b(F,{children:[c(_,{htmlFor:"word-source",children:"来源"}),c(dt,{id:"word-source",value:n.来源,options:Jr,onChange:v=>s({...n,来源:v})})]})]})}),b(qt,{children:[c(m,{type:"button",variant:"outline",onClick:o,children:"取消"}),b(m,{type:"submit",disabled:f,children:[f&&c(U,{"data-icon":"inline-start"}),"保存"]})]})]})})})}import{cn as Vs}from"cn";import{jsx as O,jsxs as de}from"react/jsx-runtime";var $s={已完成:"border-emerald-600/40 bg-emerald-600/10 text-emerald-700 dark:text-emerald-400",需人工处理:"border-amber-600/40 bg-amber-600/10 text-amber-700 dark:text-amber-400",失败:"border-destructive/40 bg-destructive/10 text-destructive"};function Hs({task:e,running:t,onOpen:a,onStop:o,onRetry:r,className:i}){let n=e.budget&&(e.budget.used>0||e.budget.estimate)?e.budget.estimate?`${e.budget.used} / ${e.budget.estimate}${e.budget.unit??""}`:`${e.budget.used}${e.budget.unit??""}`:void 0;return de("div",{className:Vs("rounded-lg border p-3",i),children:[de("div",{className:"flex flex-wrap items-center gap-2",children:[O("button",{type:"button",className:"min-w-0 flex-1 truncate text-left font-medium text-primary underline-offset-4 hover:underline",onClick:a,children:e.code}),O(ga,{variant:"outline",className:$s[e.status]??"",children:e.status||"—"})]}),(e.stage||e.hint)&&O("p",{className:"mt-1 text-xs text-muted-foreground",children:[e.stage,e.hint].filter(Boolean).join(" · ")}),e.stages?.length?O("div",{className:"mt-2 flex flex-wrap gap-1",children:e.stages.map(s=>de("span",{className:"rounded border px-1.5 py-0.5 text-xs tabular-nums",title:s.label,children:[s.label," ",s.pass,"/",s.input,s.todo?de("span",{className:"text-amber-600 dark:text-amber-400",children:[" +",s.todo]}):null]},s.key))}):null,de("dl",{className:"mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[n&&de("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"算力"}),O("dd",{className:"tabular-nums",children:n})]}),e.rounds!=null&&de("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"轮次"}),O("dd",{className:"tabular-nums",children:e.rounds})]}),e.startedAt&&de("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"开始"}),O("dd",{className:"tabular-nums",children:e.startedAt})]}),e.lastActiveAt&&de("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"最后活动"}),O("dd",{className:"tabular-nums",children:e.lastActiveAt})]})]}),de("div",{className:"mt-2 flex flex-wrap gap-1",children:[a&&O(m,{variant:"ghost",size:"sm",onClick:a,children:"查看"}),t&&o&&O(m,{variant:"ghost",size:"sm",onClick:o,children:"停止"}),r&&O(m,{variant:"ghost",size:"sm",onClick:r,children:"重试未完成"})]})]})}import{useEffect as tn,useRef as Ws,useState as Zs}from"react";import{CheckIcon as qs,CopyIcon as Xs}from"lucide-react";import{cn as jr}from"cn";import{ScrollArea as Lt}from"radix-ui";import{jsx as Ft,jsxs as Us}from"react/jsx-runtime";function en({className:e,children:t,...a}){return Us(Lt.Root,{"data-slot":"scroll-area",className:jr("relative",e),...a,children:[Ft(Lt.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),Ft(Ks,{}),Ft(Lt.Corner,{})]})}function Ks({className:e,orientation:t="vertical",...a}){return Ft(Lt.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:jr("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...a,children:Ft(Lt.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}import{jsx as He,jsxs as ba}from"react/jsx-runtime";var Qs=/^\[(\d{4}-\d{2}-\d{2}T[\d:.]+Z)\]/;function Ys(e,t){let a=e.match(Qs);if(!a)return e;let o=new Date(a[1]);return Number.isNaN(o.getTime())?e:`[${new Intl.DateTimeFormat("zh-CN",{timeZone:t,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(o)}]${e.slice(a[0].length)}`}function Js({text:e,timeZone:t,className:a}){let o=String(e??"").trim(),r=o?o.split(`
|
|
2
|
-
`).map(d=>
|
|
3
|
-
`)),s(!0)}catch{}}return
|
|
4
|
-
`)}),
|
|
1
|
+
"use client";import{B as Ta,D as Ro,F as Ot,G as Da,H as Vt,K as To,L as Do,M as Io,N as zo,a as lo,b as co,d as po,e as mo,f as uo,g as bo,h as vo,i as xo,j as xt,l as Sa,m as Po,n as ko,o as So,r as Te,z as Ra}from"../chunk-KG3655ZD.js";import{a as Ht,b as Ia,c as Ao,d as $t,e as Mo,f as ht,h as Eo,i as Bo,j as Lo,k as za,m as _o}from"../chunk-2DZYZ6RZ.js";import{g as fo,i as go,k as ge,t as ho,u as Co,v as yo,w as wo,y as No}from"../chunk-WREK6TXJ.js";import{Fragment as ns}from"react";import is from"next/link";import{usePathname as ss}from"next/navigation";import La from"next/link";import{usePathname as qn}from"next/navigation";import{ChevronRightIcon as Xn}from"lucide-react";import{Collapsible as Aa}from"radix-ui";import{jsx as Ma}from"react/jsx-runtime";function Ue({...e}){return Ma(Aa.Root,{"data-slot":"collapsible",...e})}function We({...e}){return Ma(Aa.CollapsibleTrigger,{"data-slot":"collapsible-trigger",...e})}function Ze({...e}){return Ma(Aa.CollapsibleContent,{"data-slot":"collapsible-content",...e})}import*as V from"react";import{cva as Gn}from"class-variance-authority";import{cn as B}from"cn";import{Slot as Qo}from"radix-ui";import*as Fo from"react";var Cn=768,Go=`(max-width: ${Cn-1}px)`;function yn(e){let t=window.matchMedia(Go);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function Oo(){return Fo.useSyncExternalStore(yn,()=>window.matchMedia(Go).matches,()=>!1)}import{cva as wn}from"class-variance-authority";import{cn as Nn}from"cn";import{Slot as Pn}from"radix-ui";import{jsx as Sn}from"react/jsx-runtime";var kn=wn("group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/80",outline:"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",ghost:"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",destructive:"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",xs:"h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",lg:"h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",icon:"size-8","icon-xs":"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg","icon-lg":"size-9"}},defaultVariants:{variant:"default",size:"default"}});function p({className:e,variant:t="default",size:a="default",asChild:o=!1,...r}){let n=o?Pn.Root:"button";return Sn(n,{"data-slot":"button","data-variant":t,"data-size":a,className:Nn(kn({variant:t,size:a,className:e})),...r})}import{cn as Rn}from"cn";import{jsx as Tn}from"react/jsx-runtime";function X({className:e,type:t,...a}){return Tn("input",{type:t,"data-slot":"input",className:Rn("h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...a})}import{cn as Dn}from"cn";import{Separator as In}from"radix-ui";import{jsx as zn}from"react/jsx-runtime";function Vo({className:e,orientation:t="horizontal",decorative:a=!0,...o}){return zn(In.Root,{"data-slot":"separator",decorative:a,orientation:t,className:Dn("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",e),...o})}import{cn as Ct}from"cn";import{Dialog as De}from"radix-ui";import{XIcon as An}from"lucide-react";import{jsx as ie,jsxs as Ea}from"react/jsx-runtime";function Ho({...e}){return ie(De.Root,{"data-slot":"sheet",...e})}function Mn({...e}){return ie(De.Portal,{"data-slot":"sheet-portal",...e})}function En({className:e,...t}){return ie(De.Overlay,{"data-slot":"sheet-overlay",className:Ct("fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function $o({className:e,children:t,side:a="right",showCloseButton:o=!0,...r}){return Ea(Mn,{children:[ie(En,{}),Ea(De.Content,{"data-slot":"sheet-content","data-side":a,className:Ct("fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-[side=bottom]:data-open:slide-in-from-bottom-10 data-[side=left]:data-open:slide-in-from-left-10 data-[side=right]:data-open:slide-in-from-right-10 data-[side=top]:data-open:slide-in-from-top-10 data-closed:animate-out data-closed:fade-out-0 data-[side=bottom]:data-closed:slide-out-to-bottom-10 data-[side=left]:data-closed:slide-out-to-left-10 data-[side=right]:data-closed:slide-out-to-right-10 data-[side=top]:data-closed:slide-out-to-top-10",e),...r,children:[t,o&&ie(De.Close,{"data-slot":"sheet-close",asChild:!0,children:Ea(p,{variant:"ghost",className:"absolute top-3 right-3",size:"icon-sm",children:[ie(An,{}),ie("span",{className:"sr-only",children:"Close"})]})})]})]})}function Ko({className:e,...t}){return ie("div",{"data-slot":"sheet-header",className:Ct("flex flex-col gap-0.5 p-4",e),...t})}function Uo({className:e,...t}){return ie(De.Title,{"data-slot":"sheet-title",className:Ct("font-heading text-base font-medium text-foreground",e),...t})}function Wo({className:e,...t}){return ie(De.Description,{"data-slot":"sheet-description",className:Ct("text-sm text-muted-foreground",e),...t})}import{cn as Bn}from"cn";import{jsx as Ln}from"react/jsx-runtime";function Kt({className:e,...t}){return Ln("div",{"data-slot":"skeleton",className:Bn("animate-pulse rounded-md bg-muted",e),...t})}import{cn as _n}from"cn";import{Tooltip as yt}from"radix-ui";import{jsx as Ut,jsxs as Fn}from"react/jsx-runtime";function Zo({...e}){return Ut(yt.Root,{"data-slot":"tooltip",...e})}function qo({...e}){return Ut(yt.Trigger,{"data-slot":"tooltip-trigger",...e})}function Xo({className:e,sideOffset:t=0,children:a,...o}){return Ut(yt.Portal,{children:Fn(yt.Content,{"data-slot":"tooltip-content",sideOffset:t,className:_n("z-50 inline-flex w-fit max-w-xs origin-(--radix-tooltip-content-transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o,children:[a,Ut(yt.Arrow,{className:"z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground"})]})})}import{PanelLeftIcon as On}from"lucide-react";import{jsx as S,jsxs as wt}from"react/jsx-runtime";var Vn="sidebar_state",Hn=3600*24*7,$n="16rem",Kn="18rem",Un="3rem",Wn="b",Yo=V.createContext(null);function qe(){let e=V.useContext(Yo);if(!e)throw new Error("useSidebar must be used within a SidebarProvider.");return e}function Jo({defaultOpen:e=!0,open:t,onOpenChange:a,className:o,style:r,children:n,...i}){let s=Oo(),[l,d]=V.useState(!1),[f,P]=V.useState(e),N=t??f,v=V.useCallback(y=>{let w=typeof y=="function"?y(N):y;a?a(w):P(w),document.cookie=`${Vn}=${w}; path=/; max-age=${Hn}`},[a,N]),C=V.useCallback(()=>s?d(y=>!y):v(y=>!y),[s,v,d]);V.useEffect(()=>{let y=w=>{w.key===Wn&&(w.metaKey||w.ctrlKey)&&(w.preventDefault(),C())};return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[C]);let h=N?"expanded":"collapsed",T=V.useMemo(()=>({state:h,open:N,setOpen:v,isMobile:s,openMobile:l,setOpenMobile:d,toggleSidebar:C}),[h,N,v,s,l,d,C]);return S(Yo.Provider,{value:T,children:S("div",{"data-slot":"sidebar-wrapper",style:{"--sidebar-width":$n,"--sidebar-width-icon":Un,...r},className:B("group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",o),...i,children:n})})}function jo({side:e="left",variant:t="sidebar",collapsible:a="offcanvas",className:o,children:r,dir:n,...i}){let{isMobile:s,state:l,openMobile:d,setOpenMobile:f}=qe();return a==="none"?S("div",{"data-slot":"sidebar",className:B("flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",o),...i,children:r}):s?S(Ho,{open:d,onOpenChange:f,...i,children:wt($o,{dir:n,"data-sidebar":"sidebar","data-slot":"sidebar","data-mobile":"true",className:"w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",style:{"--sidebar-width":Kn},side:e,children:[wt(Ko,{className:"sr-only",children:[S(Uo,{children:"Sidebar"}),S(Wo,{children:"Displays the mobile sidebar."})]}),S("div",{className:"flex h-full w-full flex-col",children:r})]})}):wt("div",{className:"group peer hidden text-sidebar-foreground md:block","data-state":l,"data-collapsible":l==="collapsed"?a:"","data-variant":t,"data-side":e,"data-slot":"sidebar",children:[S("div",{"data-slot":"sidebar-gap",className:B("relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear","group-data-[collapsible=offcanvas]:w-0","group-data-[side=right]:rotate-180",t==="floating"||t==="inset"?"group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon)")}),S("div",{"data-slot":"sidebar-container","data-side":e,className:B("fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",t==="floating"||t==="inset"?"p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]":"group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",o),...i,children:S("div",{"data-sidebar":"sidebar","data-slot":"sidebar-inner",className:"flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border",children:r})})]})}function er({className:e,onClick:t,...a}){let{toggleSidebar:o}=qe();return wt(p,{"data-sidebar":"trigger","data-slot":"sidebar-trigger",variant:"ghost",size:"icon-sm",className:B(e),onClick:r=>{t?.(r),o()},...a,children:[S(On,{}),S("span",{className:"sr-only",children:"Toggle Sidebar"})]})}function tr({className:e,...t}){let{toggleSidebar:a}=qe();return S("button",{"data-sidebar":"rail","data-slot":"sidebar-rail","aria-label":"Toggle Sidebar",tabIndex:-1,onClick:a,title:"Toggle Sidebar",className:B("absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2","in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize","[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize","group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full hover:group-data-[collapsible=offcanvas]:bg-sidebar","[[data-side=left][data-collapsible=offcanvas]_&]:-right-2","[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",e),...t})}function ar({className:e,...t}){return S("main",{"data-slot":"sidebar-inset",className:B("relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",e),...t})}function or({className:e,...t}){return S("div",{"data-slot":"sidebar-header","data-sidebar":"header",className:B("flex flex-col gap-2 p-2",e),...t})}function rr({className:e,...t}){return S("div",{"data-slot":"sidebar-content","data-sidebar":"content",className:B("no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",e),...t})}function nr({className:e,...t}){return S("div",{"data-slot":"sidebar-group","data-sidebar":"group",className:B("relative flex w-full min-w-0 flex-col p-2",e),...t})}function Ba({className:e,...t}){return S("ul",{"data-slot":"sidebar-menu","data-sidebar":"menu",className:B("flex w-full min-w-0 flex-col gap-0",e),...t})}function Wt({className:e,...t}){return S("li",{"data-slot":"sidebar-menu-item","data-sidebar":"menu-item",className:B("group/menu-item relative",e),...t})}var Zn=Gn("peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",{variants:{variant:{default:"hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",outline:"bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]"},size:{default:"h-8 text-sm",sm:"h-7 text-xs",lg:"h-12 text-sm group-data-[collapsible=icon]:p-0!"}},defaultVariants:{variant:"default",size:"default"}});function Zt({asChild:e=!1,isActive:t=!1,variant:a="default",size:o="default",tooltip:r,className:n,...i}){let s=e?Qo.Root:"button",{isMobile:l,state:d}=qe(),f=S(s,{"data-slot":"sidebar-menu-button","data-sidebar":"menu-button","data-size":o,"data-active":t,className:B(Zn({variant:a,size:o}),n),...i});return r?(typeof r=="string"&&(r={children:r}),wt(Zo,{children:[S(qo,{asChild:!0,children:f}),S(Xo,{side:"right",align:"center",hidden:d!=="collapsed"||l,...r})]})):f}function ir({className:e,...t}){return S("ul",{"data-slot":"sidebar-menu-sub","data-sidebar":"menu-sub",className:B("mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",e),...t})}function sr({className:e,...t}){return S("li",{"data-slot":"sidebar-menu-sub-item","data-sidebar":"menu-sub-item",className:B("group/menu-sub-item relative",e),...t})}function lr({asChild:e=!1,size:t="md",isActive:a=!1,className:o,...r}){let n=e?Qo.Root:"a";return S(n,{"data-slot":"sidebar-menu-sub-button","data-sidebar":"menu-sub-button","data-size":t,"data-active":a,className:B("flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",o),...r})}import{jsx as k,jsxs as Ie}from"react/jsx-runtime";function _a({nav:e,appName:t="LinkFox",appSubtitle:a,version:o}){let r=qn(),n=xt(e,r),{isMobile:i,setOpenMobile:s}=qe();return Ie(jo,{collapsible:"icon",children:[k(or,{children:k(Ba,{children:k(Wt,{children:k(Zt,{size:"lg",asChild:!0,children:Ie(La,{href:"/",children:[k("div",{className:"flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary font-semibold text-sidebar-primary-foreground",children:"LF"}),Ie("div",{className:"flex flex-col gap-0.5 leading-none",children:[Ie("span",{className:"flex items-center gap-1.5 font-medium",children:[t,o?k("span",{className:"rounded border px-1 text-[10px] leading-4 font-normal text-muted-foreground tabular-nums",children:o}):null]}),a?k("span",{className:"text-xs text-muted-foreground",children:a}):null]})]})})})})}),k(rr,{children:k(nr,{children:k(Ba,{children:e.map(l=>{if(l.items.length===1){let d=l.items[0];return k(Wt,{children:k(Zt,{tooltip:l.title,isActive:n?.group===l,asChild:!0,children:Ie(La,{href:d.href,onClick:()=>i&&s(!1),children:[k(l.icon,{}),k("span",{children:l.title})]})})},l.title)}return k(Ue,{asChild:!0,defaultOpen:!0,className:"group/collapsible",children:Ie(Wt,{children:[k(We,{asChild:!0,children:Ie(Zt,{tooltip:l.title,isActive:n?.group===l,children:[k(l.icon,{}),k("span",{children:l.title}),k(Xn,{className:"ml-auto transition-transform group-data-[state=open]/collapsible:rotate-90"})]})}),k(Ze,{children:k(ir,{children:l.items.map(d=>k(sr,{children:k(lr,{asChild:!0,isActive:n?.item===d,children:k(La,{href:d.href,onClick:()=>i&&s(!1),children:k("span",{children:d.title})})})},d.href))})})]})},l.title)})})})}),k(tr,{})]})}import{useEffect as ai,useState as Fa}from"react";import{CircleAlertIcon as oi,ExternalLinkIcon as ri,RefreshCwIcon as ni}from"lucide-react";import{cn as Xe}from"cn";import{Dialog as ye}from"radix-ui";import{XIcon as Qn}from"lucide-react";import{jsx as Q,jsxs as qt}from"react/jsx-runtime";function Xt({...e}){return Q(ye.Root,{"data-slot":"dialog",...e})}function Yn({...e}){return Q(ye.Portal,{"data-slot":"dialog-portal",...e})}function Jn({className:e,...t}){return Q(ye.Overlay,{"data-slot":"dialog-overlay",className:Xe("fixed inset-0 isolate z-50 bg-black/50 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function Qt({className:e,children:t,showCloseButton:a=!0,...o}){return qt(Yn,{children:[Q(Jn,{}),qt(ye.Content,{"data-slot":"dialog-content",className:Xe("fixed top-1/2 left-1/2 z-50 grid w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-sm text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o,children:[t,a&&Q(ye.Close,{"data-slot":"dialog-close",asChild:!0,children:qt(p,{variant:"ghost",className:"absolute top-2 right-2",size:"icon-sm",children:[Q(Qn,{}),Q("span",{className:"sr-only",children:"关闭"})]})})]})]})}function Yt({className:e,...t}){return Q("div",{"data-slot":"dialog-header",className:Xe("flex flex-col gap-2",e),...t})}function Jt({className:e,showCloseButton:t=!1,children:a,...o}){return qt("div",{"data-slot":"dialog-footer",className:Xe("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 sm:flex-row sm:justify-end",e),...o,children:[a,t&&Q(ye.Close,{asChild:!0,children:Q(p,{variant:"outline",children:"Close"})})]})}function jt({className:e,...t}){return Q(ye.Title,{"data-slot":"dialog-title",className:Xe("font-heading text-base leading-none font-medium",e),...t})}function ea({className:e,...t}){return Q(ye.Description,{"data-slot":"dialog-description",className:Xe("text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}import{cn as jn}from"cn";import{Loader2Icon as ei}from"lucide-react";import{jsx as ti}from"react/jsx-runtime";function U({className:e,...t}){return ti(ei,{"data-slot":"spinner",role:"status","aria-label":"Loading",className:jn("size-4 animate-spin",e),...t})}import{jsx as se,jsxs as ze}from"react/jsx-runtime";var ii={login:{title:"算力余额不足",lead:"当前账号可用算力为 0,LinkFox 的付费工具暂时无法调用。"},team:{title:"算力余额不足,已暂停请求",lead:"当前账号可用算力不足,本次操作已停止;为避免重复消耗,后续请求不会再发起。"},member:{title:"已达到团队设置的算力限额",lead:"你的算力使用已达到团队管理员设置的上限,本次操作已停止,后续请求不会再发起。"}},si="如果你是团队管理员,可以前往充值,或在「团队管理」中为成员提高算力限额;如果你是团队成员,请联系团队管理员充值或调整你的限额。",li="请联系团队管理员在「团队管理」中提高你的算力限额。",dr=!1;function Ga(){let[e,t]=Fa(),[a,o]=Fa(!1),[r,n]=Fa(!1);function i(d){dr||(dr=!0,n(!1),t(d))}ai(()=>{let d=!1;co().then(P=>{!d&&P===0&&i("login")});let f=mo(()=>{d||i(go(po())?"member":"team")});return()=>{d=!0,f()}},[]);async function s(){o(!0),n(!1);let d=await uo();o(!1),d!==void 0&&d>0?t(void 0):n(!0)}let l=e?ii[e]:void 0;return se(Xt,{open:!!e,onOpenChange:d=>!d&&t(void 0),children:ze(Qt,{className:"sm:max-w-md",children:[ze(Yt,{children:[ze(jt,{className:"flex items-center gap-2",children:[se(oi,{className:"size-4 text-destructive"}),l?.title]}),ze(ea,{className:"space-y-2 pt-1",children:[se("span",{className:"block text-foreground",children:l?.lead}),se("span",{className:"block",children:e==="member"?li:si}),r&&se("span",{className:"block text-destructive",children:"仍未检测到可用算力。充值到账后请稍等片刻再试,或联系团队管理员确认额度。"})]})]}),ze(Jt,{children:[se(p,{variant:"ghost",onClick:()=>t(void 0),children:"暂不处理"}),ze(p,{variant:"outline",onClick:()=>{s()},disabled:a,children:[a?se(U,{}):se(ni,{}),"我已充值,重新检查"]}),se(p,{asChild:!0,children:ze("a",{href:lo,target:"_blank",rel:"noreferrer",children:["前往充值",se(ri,{})]})})]})]})})}import{useEffect as Ha,useRef as $a,useState as _e}from"react";import{BotIcon as xi,CheckCircle2Icon as hi,ChevronDownIcon as Ci,ExternalLinkIcon as yi,FileTextIcon as wi,MessageCirclePlusIcon as mr,SendIcon as Ni,SparklesIcon as ur,SquareIcon as Pi,TableIcon as ki,Trash2Icon as Si,XCircleIcon as Ri,XIcon as fr}from"lucide-react";import di from"react-markdown";import ci from"remark-gfm";import{jsx as Qe}from"react/jsx-runtime";function Y(e,t){function a({node:o,...r}){return Qe(e,{className:t,...r})}return a}var pi={p:Y("p","my-1.5 leading-relaxed"),ul:Y("ul","my-1.5 list-disc pl-5"),ol:Y("ol","my-1.5 list-decimal pl-5"),li:Y("li","my-0.5"),h1:Y("h3","mt-3 mb-1 font-semibold"),h2:Y("h3","mt-3 mb-1 font-semibold"),h3:Y("h4","mt-2 mb-1 font-semibold"),a:({href:e,children:t})=>Qe("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"break-all text-primary underline underline-offset-2",children:t}),code:Y("code","rounded bg-muted px-1 py-0.5 font-mono text-xs"),pre:Y("pre","my-2 overflow-x-auto rounded-md bg-muted p-2 text-xs [&_code]:bg-transparent [&_code]:p-0"),table:({children:e})=>Qe("div",{className:"my-2 overflow-x-auto rounded-md border",children:Qe("table",{className:"w-full text-xs",children:e})}),th:Y("th","border-b bg-muted px-2 py-1 text-left font-medium whitespace-nowrap"),td:Y("td","border-b px-2 py-1 align-top"),blockquote:Y("blockquote","my-2 border-l-2 pl-3 text-muted-foreground")};function Oa({children:e}){return Qe("div",{className:"text-sm break-words",children:Qe(di,{remarkPlugins:[ci],components:pi,children:e})})}import{cn as Ae}from"cn";import{Select as W}from"radix-ui";import{ChevronDownIcon as cr,CheckIcon as mi,ChevronUpIcon as ui}from"lucide-react";import{jsx as M,jsxs as Va}from"react/jsx-runtime";function Me({...e}){return M(W.Root,{"data-slot":"select",...e})}function Nt({className:e,...t}){return M(W.Group,{"data-slot":"select-group",className:Ae("scroll-my-1 p-1",e),...t})}function Ee({...e}){return M(W.Value,{"data-slot":"select-value",...e})}function Be({className:e,size:t="default",children:a,...o}){return Va(W.Trigger,{"data-slot":"select-trigger","data-size":t,className:Ae("flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),...o,children:[a,M(W.Icon,{asChild:!0,children:M(cr,{className:"pointer-events-none size-4 text-muted-foreground"})})]})}function Le({className:e,children:t,position:a="item-aligned",align:o="center",...r}){return M(W.Portal,{children:Va(W.Content,{"data-slot":"select-content","data-align-trigger":a==="item-aligned",className:Ae("relative z-50 max-h-(--radix-select-content-available-height) min-w-36 origin-(--radix-select-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",a==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",e),position:a,align:o,...r,children:[M(fi,{}),M(W.Viewport,{"data-position":a,className:Ae("data-[position=popper]:h-(--radix-select-trigger-height) data-[position=popper]:w-full data-[position=popper]:min-w-(--radix-select-trigger-width)",a==="popper"&&""),children:t}),M(gi,{})]})})}function be({className:e,children:t,...a}){return Va(W.Item,{"data-slot":"select-item",className:Ae("relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",e),...a,children:[M("span",{className:"pointer-events-none absolute right-2 flex size-4 items-center justify-center",children:M(W.ItemIndicator,{children:M(mi,{className:"pointer-events-none"})})}),M(W.ItemText,{children:t})]})}function fi({className:e,...t}){return M(W.ScrollUpButton,{"data-slot":"select-scroll-up-button",className:Ae("z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:M(ui,{})})}function gi({className:e,...t}){return M(W.ScrollDownButton,{"data-slot":"select-scroll-down-button",className:Ae("z-10 flex cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",e),...t,children:M(cr,{})})}import{cn as bi}from"cn";import{jsx as vi}from"react/jsx-runtime";function pr({className:e,...t}){return vi("textarea",{"data-slot":"textarea",className:bi("flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",e),...t})}import{cn as Ti}from"cn";import{Fragment as Mi,jsx as m,jsxs as R}from"react/jsx-runtime";var Di=["介绍一下这个应用现在能做什么","帮我梳理接下来可以加哪些功能"],Ii="例如:帮我把当前页面的数据按状态汇总一下",gr=e=>Sa.find(t=>t.id===e)?.name??e;function Ka({suggestions:e}){let{open:t,setOpen:a,page:o}=za(),[r,n]=_e(),[i,s]=_e([]),[l,d]=_e(""),[f,P]=_e("default"),[N,v]=_e(!0),[C,h]=_e(""),T=$a(null),y=$a(null),w=$a(null),q=i.some(g=>g.running),ke=!!o&&(!!o.table||o.records.length>0),me=()=>h("");Ha(()=>{!t||r||Te()?.getNotebook().then(g=>n({notebookId:g.notebookId,name:g.name})).catch(()=>{})},[t,r]);let j=o?`${o.table?.id}:${o.records.map(g=>g.id).join(",")}`:"",[gt,bt]=_e(j);j!==gt&&(bt(j),v(!0)),Ha(()=>{w.current?.scrollIntoView({block:"end"})},[i]),Ha(()=>()=>T.current?.abort(),[]);let ue=(g,u)=>s(D=>D.map(A=>A.id===g?{...A,...u}:A)),fe=async(g=l)=>{let u=g.trim();if(!u||q)return;let D=N&&ke?o:null,A=crypto.randomUUID(),Ce=C;s(E=>[...E,{id:A,input:u,context:D,modelId:f,running:!0,followUp:!!Ce}]),d("");let ne=new AbortController;T.current=ne,y.current=null;try{let E=await So(_o(u,Ce?null:D,r),f,{signal:ne.signal,sessionId:Ce||void 0,onUpdate:Re=>{y.current=Re.messageId,Re.sessionId&&h(Re.sessionId),ue(A,{task:Re})}});E.sessionId&&h(E.sessionId),ue(A,{task:E,running:!1,error:E.stopReason==="end_turn"?void 0:`任务异常结束(${E.stopReason})`}),window.dispatchEvent(new Event(Bo));let Se=await ko(E.messageId);Se&&ue(A,{shareUrl:Se})}catch(E){ue(A,{running:!1,error:fo(E)?"已停止":ge(E)})}finally{T.current===ne&&(T.current=null)}},vt=()=>{let g=y.current;T.current?.abort(),g&&Po(g).catch(()=>{})},Pa=e?.items??[],ka=(o?Pa.find(g=>o.source.endsWith(g.match))?.items:void 0)??e?.fallback??Di;return R("aside",{"data-slot":"agent-panel","aria-label":"LinkFox OS 助手",className:Ti("z-40 flex flex-col border-l bg-background","fixed inset-0 md:sticky md:top-0 md:h-svh md:w-1/4 md:min-w-90 md:shrink-0 md:self-start",!t&&"hidden"),children:[R("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b px-3",children:[m(ur,{className:"size-4 text-primary"}),m("span",{className:"font-medium",children:"LinkFox OS"}),R(Me,{value:f,onValueChange:g=>{P(g),me()},disabled:q,children:[m(Be,{size:"sm",className:"ml-auto w-32","aria-label":"选择 Agent",children:m(Ee,{})}),m(Le,{align:"end",children:Sa.map(g=>m(be,{value:g.id,children:g.name},g.id))})]}),m(p,{variant:"ghost",size:"icon-sm","aria-label":"开新对话(不保留上下文)",title:"开新对话:下一条消息不再续接当前会话",disabled:q||!C,onClick:me,children:m(mr,{})}),m(p,{variant:"ghost",size:"icon-sm","aria-label":"清空对话",disabled:q||!i.length,onClick:()=>{s([]),me()},children:m(Si,{})}),m(p,{variant:"ghost",size:"icon-sm","aria-label":"关闭助手",onClick:()=>a(!1),children:m(fr,{})})]}),R("div",{className:"min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-3",children:[i.length===0?R("div",{className:"flex flex-col gap-3 py-6 text-sm text-muted-foreground",children:[R("div",{className:"flex items-center gap-2 text-foreground",children:[m(xi,{className:"size-5"}),m("span",{className:"font-medium",children:"让 LinkFox 帮你干活"})]}),m("p",{children:"描述你要完成的事,LinkFox OS 会自己调用选品、数据查询、生图、多维表等技能去执行。勾选的记录会自动带上。"}),m("div",{className:"flex flex-col gap-2",children:ka.map(g=>m("button",{type:"button",className:"rounded-lg border px-3 py-2 text-left text-foreground transition-colors hover:bg-muted",onClick:()=>d(g),children:g},g))})]}):m("div",{className:"flex flex-col gap-4",children:i.map(g=>m(Ai,{item:g,notebook:r},g.id))}),m("div",{ref:w})]}),R("div",{className:"shrink-0 border-t p-3",children:[C?R("div",{className:"mb-2 flex items-center gap-2 text-xs text-muted-foreground",children:[m(mr,{className:"size-3.5 shrink-0"}),R("span",{className:"min-w-0 flex-1",children:["接着上一轮聊(",gr(f)," 记得前面的内容,可以直接追问)"]}),m("button",{type:"button",className:"shrink-0 text-primary underline-offset-2 hover:underline",onClick:me,children:"开新对话"})]}):R(Mi,{children:[ke&&N&&o&&m(zi,{context:o,notebook:r,onRemove:()=>v(!1)}),ke&&!N&&m("button",{type:"button",className:"mb-2 text-xs text-primary underline-offset-2 hover:underline",onClick:()=>v(!0),children:"重新带入当前页面的数据表和勾选记录"})]}),R("div",{className:"flex items-end gap-2",children:[m(pr,{value:l,onChange:g=>d(g.target.value),onKeyDown:g=>{g.key==="Enter"&&!g.shiftKey&&!g.nativeEvent.isComposing&&(g.preventDefault(),fe())},placeholder:C?"接着问,例如:把第 3 条展开说说 / 换个角度再看一遍":e?.placeholder??Ii,"aria-label":"告诉 LinkFox 要做什么",className:"max-h-40 min-h-16 resize-none"}),q?m(p,{size:"icon",variant:"outline","aria-label":"停止",onClick:vt,children:m(Pi,{})}):m(p,{size:"icon","aria-label":"发送",disabled:!l.trim(),onClick:()=>fe(),children:m(Ni,{})})]}),m("p",{className:"mt-2 text-xs text-muted-foreground",children:"执行会消耗 LinkFox 算力。Enter 发送,Shift+Enter 换行。"})]})]})}function zi({context:e,notebook:t,onRemove:a}){let o=e.records.length;return R(Ue,{className:"mb-2 rounded-lg border bg-muted/40 text-xs",children:[R("div",{className:"flex items-center gap-2 px-2.5 py-2",children:[m(ki,{className:"size-3.5 shrink-0 text-muted-foreground"}),R("div",{className:"min-w-0 flex-1",children:[e.table&&R("div",{className:"truncate",children:[t?`${t.name} / `:"",e.table.name]}),m("div",{className:"text-muted-foreground",children:o?`已勾选 ${o} 条记录,将一并发送`:`当前页面:${e.source}`})]}),o>0&&m(We,{asChild:!0,children:m(p,{variant:"ghost",size:"icon-xs","aria-label":"查看勾选记录",className:"[&[data-state=open]>svg]:rotate-180",children:m(Ci,{})})}),m(p,{variant:"ghost",size:"icon-xs","aria-label":"不带入上下文",onClick:a,children:m(fr,{})})]}),o>0&&m(Ze,{children:m("ul",{className:"max-h-32 overflow-y-auto border-t px-2.5 py-1.5",children:e.records.map(r=>m("li",{className:"truncate py-0.5",title:r.label,children:r.label},r.id))})})]})}function Ai({item:e,notebook:t}){let{task:a,context:o}=e,r=a?.steps??[];return R("div",{className:"flex flex-col gap-2",children:[R("div",{className:"ml-6 self-end rounded-lg bg-primary px-3 py-2 text-sm whitespace-pre-wrap text-primary-foreground",children:[e.input,o&&R("div",{className:"mt-1.5 border-t border-primary-foreground/20 pt-1.5 text-xs opacity-80",children:[o.table?`${t?`${t.name} / `:""}${o.table.name}`:o.source,o.records.length?` · 勾选 ${o.records.length} 条`:""]})]}),R("div",{className:"mr-2 flex flex-col gap-2 rounded-lg border px-3 py-2",children:[R("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[m("span",{children:gr(e.modelId)}),e.followUp&&m("span",{className:"rounded bg-muted px-1.5 py-0.5",children:"接上一轮"})]}),r.length>0&&m("ul",{className:"flex flex-col gap-1 text-xs",children:r.map(n=>R("li",{className:"flex items-center gap-1.5",children:[n.status==="running"?m(U,{className:"size-3"}):n.status==="failed"?m(Ri,{className:"size-3 text-destructive"}):m(hi,{className:"size-3 text-emerald-600"}),m("span",{className:"truncate",children:n.status==="running"?`正在调用 ${n.title}`:n.title})]},n.id))}),a?.text?m(Oa,{children:a.text}):e.running&&R("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[m(U,{})," ",a?"LinkFox 正在处理…":"正在提交任务…"]}),a&&a.files.length>0&&m("ul",{className:"flex flex-col gap-1",children:a.files.map(n=>m("li",{children:R("a",{href:n.uri,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1.5 text-xs text-primary underline-offset-2 hover:underline",children:[m(wi,{className:"size-3.5 shrink-0"}),m("span",{className:"truncate",children:n.name})]})},n.uri))}),e.error&&m("div",{className:"text-sm text-destructive",children:e.error}),e.shareUrl&&R("a",{href:e.shareUrl,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 self-start text-xs text-muted-foreground underline-offset-2 hover:text-foreground hover:underline",children:["查看完整过程 ",m(yi,{className:"size-3"})]})]})]})}function Ua(){let{open:e,setOpen:t}=za();return R(p,{variant:e?"secondary":"default",size:"sm",onClick:()=>t(a=>!a),"aria-expanded":e,"aria-label":"让LinkFox帮你干活",children:[m(ur,{}),m("span",{className:"hidden sm:inline",children:"让LinkFox帮你干活"})]})}import{useEffect as Bi,useState as br,useSyncExternalStore as Li}from"react";import{CheckIcon as _i}from"lucide-react";import{cn as Fi}from"cn";import{cn as Ei}from"cn";import{Popover as ta}from"radix-ui";import{jsx as aa}from"react/jsx-runtime";function oa({...e}){return aa(ta.Root,{"data-slot":"popover",...e})}function ra({...e}){return aa(ta.Trigger,{"data-slot":"popover-trigger",...e})}function na({className:e,align:t="center",sideOffset:a=4,...o}){return aa(ta.Portal,{children:aa(ta.Content,{"data-slot":"popover-content",align:t,sideOffset:a,className:Ei("z-50 flex w-72 origin-(--radix-popover-content-transform-origin) flex-col gap-2.5 rounded-lg bg-popover p-2.5 text-sm text-popover-foreground shadow-md ring-1 ring-foreground/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o})})}import{jsx as ee,jsxs as Pt}from"react/jsx-runtime";var Wa=new Set,vr=null;function Gi(){try{return To(localStorage.getItem(Vt))}catch{return vr??Da}}function Oi(e){Wa.add(e);let t=a=>{(a.key===Vt||a.key===null)&&e()};return window.addEventListener("storage",t),()=>{Wa.delete(e),window.removeEventListener("storage",t)}}function Vi(e){vr=e;try{localStorage.setItem(Vt,e)}catch{}Wa.forEach(t=>t())}function Hi(){return Li(Oi,Gi,()=>Da)}function $i({color:e,className:t}){return ee("span",{"aria-hidden":!0,className:Fi("inline-block size-4 shrink-0 rounded-[4px]",t),style:{background:e}})}function Za(){let e=Hi(),[t,a]=br(!1),[o,r]=br(e);Bi(()=>{Do(t?o:e)},[t,o,e]);let n=l=>{l&&r(e),a(l)},i=()=>{Vi(o),Io(o),a(!1)},s=Ot.find(l=>l.value===e)??Ot[0];return Pt(oa,{open:t,onOpenChange:n,children:[ee(ra,{asChild:!0,children:Pt(p,{variant:"outline",size:"sm","aria-label":`主题色配置,当前${s.label}`,children:[ee($i,{color:s.swatch}),ee("span",{className:"hidden sm:inline",children:"主题色配置"})]})}),Pt(na,{align:"end",collisionPadding:16,className:"w-72",children:[Pt("div",{className:"flex flex-col gap-1",children:[ee("div",{className:"text-sm font-medium text-[#4D4D4D]",children:"主题色配置"}),ee("p",{className:"text-xs text-[#B0B0B7]",children:"选择主色,同步推荐浅、深栏配色;图标和右侧 AI 面板也跟随主色。"})]}),ee("div",{role:"radiogroup","aria-label":"主题色",className:"mt-3 grid grid-cols-5 gap-2",children:Ot.map(l=>{let d=l.value===o;return ee("button",{type:"button",role:"radio","aria-checked":d,"aria-label":l.label,title:l.label,onClick:()=>r(l.value),className:"flex aspect-square items-center justify-center rounded-md text-white outline-none transition-shadow focus-visible:ring-3 focus-visible:ring-ring/50",style:{background:l.swatch},children:d?ee(_i,{className:"size-6"}):null},l.value)})}),Pt("div",{className:"mt-4 flex justify-end gap-2",children:[ee(p,{variant:"outline",size:"sm",onClick:()=>n(!1),children:"取消"}),ee(p,{size:"sm",onClick:i,children:"确认"})]})]})]})}import{useMemo as qi,useState as Xi}from"react";import{CheckIcon as Sr,GlobeIcon as Qi}from"lucide-react";import{Command as je}from"cmdk";import{cn as et}from"cn";import{cva as xr}from"class-variance-authority";import{cn as kt}from"cn";import{jsx as St}from"react/jsx-runtime";function Ye({className:e,...t}){return St("div",{"data-slot":"input-group",role:"group",className:kt("group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",e),...t})}var Ki=xr("flex h-auto cursor-text items-center justify-center gap-2 py-1.5 text-sm font-medium text-muted-foreground select-none group-data-[disabled=true]/input-group:opacity-50 [&>kbd]:rounded-[calc(var(--radius)-5px)] [&>svg:not([class*='size-'])]:size-4",{variants:{align:{"inline-start":"order-first pl-2 has-[>button]:ml-[-0.3rem] has-[>kbd]:ml-[-0.15rem]","inline-end":"order-last pr-2 has-[>button]:mr-[-0.3rem] has-[>kbd]:mr-[-0.15rem]","block-start":"order-first w-full justify-start px-2.5 pt-2 group-has-[>input]/input-group:pt-2 [.border-b]:pb-2","block-end":"order-last w-full justify-start px-2.5 pb-2 group-has-[>input]/input-group:pb-2 [.border-t]:pt-2"}},defaultVariants:{align:"inline-start"}});function Je({className:e,align:t="inline-start",...a}){return St("div",{role:"group","data-slot":"input-group-addon","data-align":t,className:kt(Ki({align:t}),e),onClick:o=>{o.target.closest("button")||o.currentTarget.parentElement?.querySelector("input")?.focus()},...a})}var Ui=xr("flex items-center gap-2 text-sm shadow-none",{variants:{size:{xs:"h-6 gap-1 rounded-[calc(var(--radius)-3px)] px-1.5 [&>svg:not([class*='size-'])]:size-3.5",sm:"","icon-xs":"size-6 rounded-[calc(var(--radius)-3px)] p-0 has-[>svg]:p-0","icon-sm":"size-8 p-0 has-[>svg]:p-0"}},defaultVariants:{size:"xs"}});function hr({className:e,type:t="button",variant:a="ghost",size:o="xs",...r}){return St(p,{type:t,"data-size":o,variant:a,className:kt(Ui({size:o}),e),...r})}function Cr({className:e,...t}){return St("span",{className:kt("flex items-center gap-2 text-sm text-muted-foreground [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4",e),...t})}function ia({className:e,...t}){return St(X,{"data-slot":"input-group-control",className:kt("flex-1 rounded-none border-0 bg-transparent shadow-none ring-0 focus-visible:ring-0 disabled:bg-transparent aria-invalid:ring-0 dark:bg-transparent dark:disabled:bg-transparent",e),...t})}import{SearchIcon as Wi,CheckIcon as Zi}from"lucide-react";import{jsx as ve,jsxs as kr}from"react/jsx-runtime";function yr({className:e,...t}){return ve(je,{"data-slot":"command",className:et("flex size-full flex-col overflow-hidden rounded-xl! bg-popover p-1 text-popover-foreground",e),...t})}function wr({className:e,...t}){return ve("div",{"data-slot":"command-input-wrapper",className:"p-1 pb-0",children:kr(Ye,{className:"h-8! rounded-lg! border-input/30 bg-input/30 shadow-none! *:data-[slot=input-group-addon]:pl-2!",children:[ve(je.Input,{"data-slot":"command-input",className:et("w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50",e),...t}),ve(Je,{children:ve(Wi,{className:"size-4 shrink-0 opacity-50"})})]})})}function Nr({className:e,...t}){return ve(je.List,{"data-slot":"command-list",className:et("no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none",e),...t})}function Pr({className:e,...t}){return ve(je.Empty,{"data-slot":"command-empty",className:et("py-6 text-center text-sm",e),...t})}function sa({className:e,...t}){return ve(je.Group,{"data-slot":"command-group",className:et("overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground",e),...t})}function qa({className:e,children:t,...a}){return kr(je.Item,{"data-slot":"command-item",className:et("group/command-item relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-lg! data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground",e),...a,children:[t,ve(Zi,{className:"ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100"})]})}import{cn as Rr}from"cn";import{jsx as H,jsxs as Fe}from"react/jsx-runtime";var Xa=["Asia/Shanghai","America/Los_Angeles","America/New_York","Europe/London","Europe/Berlin","Asia/Tokyo","UTC"];function Yi(){try{return Intl.supportedValuesOf("timeZone")}catch{return Xa}}function Qa(){let[e,t]=Xi(!1),a=$t(),o=Mo(),r=qi(()=>e?Yi().filter(s=>!Xa.includes(s)).map(s=>({zone:s,offset:ht(s)})):[],[e]),n=s=>{Ao(s),t(!1)},i=(s,l=ht(s))=>Fe(qa,{value:`${s} ${l}`,onSelect:()=>n(s),children:[H(Sr,{className:Rr(!o&&s===a?"opacity-100":"opacity-0")}),H("span",{className:"truncate",children:s}),H("span",{className:"ml-auto text-xs text-muted-foreground",children:l})]},s);return Fe(oa,{open:e,onOpenChange:t,children:[H(ra,{asChild:!0,children:Fe(p,{variant:"outline",size:"sm","aria-label":`选择时区 ${a} ${ht(a)}`,children:[H(Qi,{"data-icon":"inline-start"}),H("span",{className:"hidden max-w-40 truncate sm:inline",children:a})," ",H("span",{className:"text-muted-foreground",children:ht(a)})]})}),H(na,{align:"end",className:"w-80 p-0",children:Fe(yr,{children:[H(wr,{placeholder:"搜索时区,如 Shanghai、UTC+08"}),Fe(Nr,{children:[H(Pr,{children:"没有匹配的时区"}),H(sa,{heading:"默认",children:Fe(qa,{value:`跟随浏览器 ${Ia()}`,onSelect:()=>n(null),children:[H(Sr,{className:Rr(o?"opacity-100":"opacity-0")}),Fe("span",{className:"truncate",children:["跟随浏览器(",Ia(),")"]})]})}),H(sa,{heading:"常用",children:Xa.map(s=>i(s))}),H(sa,{heading:"全部",children:r.map(s=>i(s.zone,s.offset))})]})]})})]})}import{LogOutIcon as es,UserIcon as ts}from"lucide-react";import{cn as Rt}from"cn";import{DropdownMenu as le}from"radix-ui";import{CheckIcon as Ji,ChevronRightIcon as Zc}from"lucide-react";import{jsx as te,jsxs as ji}from"react/jsx-runtime";function tt({...e}){return te(le.Root,{"data-slot":"dropdown-menu",...e})}function at({...e}){return te(le.Trigger,{"data-slot":"dropdown-menu-trigger",...e})}function ot({className:e,align:t="start",sideOffset:a=4,...o}){return te(le.Portal,{children:te(le.Content,{"data-slot":"dropdown-menu-content",sideOffset:a,align:t,className:Rt("z-50 max-h-(--radix-dropdown-menu-content-available-height) w-(--radix-dropdown-menu-trigger-width) min-w-32 origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:overflow-hidden data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...o})})}function Tt({...e}){return te(le.Group,{"data-slot":"dropdown-menu-group",...e})}function Ge({className:e,inset:t,variant:a="default",...o}){return te(le.Item,{"data-slot":"dropdown-menu-item","data-inset":t,"data-variant":a,className:Rt("group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",e),...o})}function Tr({className:e,children:t,checked:a,inset:o,...r}){return ji(le.CheckboxItem,{"data-slot":"dropdown-menu-checkbox-item","data-inset":o,className:Rt("relative flex cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",e),checked:a,...r,children:[te("span",{className:"pointer-events-none absolute right-2 flex items-center justify-center","data-slot":"dropdown-menu-checkbox-item-indicator",children:te(le.ItemIndicator,{children:te(Ji,{})})}),t]})}function Dt({className:e,inset:t,...a}){return te(le.Label,{"data-slot":"dropdown-menu-label","data-inset":t,className:Rt("px-1.5 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7",e),...a})}function la({className:e,...t}){return te(le.Separator,{"data-slot":"dropdown-menu-separator",className:Rt("-mx-1 my-1 h-px bg-border",e),...t})}import{Fragment as as,jsx as rt,jsxs as It}from"react/jsx-runtime";function Ya(){let e=Ht();return e.status!=="ready"?null:It(tt,{children:[rt(at,{asChild:!0,children:rt(p,{variant:"ghost",size:"icon","aria-label":"账号",children:rt(ts,{})})}),It(ot,{align:"end",children:[rt(Dt,{children:e.userName||"LinkFox 用户"}),e.apiKey&&It(Dt,{className:"font-normal text-muted-foreground",children:["API Key:",No(e.apiKey)]}),!e.apiKey&&It(as,{children:[rt(la,{}),It(Ge,{onSelect:wo,children:[rt(es,{}),"退出登录"]})]})]})]})}import{cn as nt}from"cn";import{Slot as os}from"radix-ui";import{ChevronRightIcon as rs,MoreHorizontalIcon as np}from"lucide-react";import{jsx as Oe,jsxs as sp}from"react/jsx-runtime";function Dr({className:e,...t}){return Oe("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",className:nt(e),...t})}function Ir({className:e,...t}){return Oe("ol",{"data-slot":"breadcrumb-list",className:nt("flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",e),...t})}function Ja({className:e,...t}){return Oe("li",{"data-slot":"breadcrumb-item",className:nt("inline-flex items-center gap-1",e),...t})}function zr({asChild:e,className:t,...a}){let o=e?os.Root:"a";return Oe(o,{"data-slot":"breadcrumb-link",className:nt("transition-colors hover:text-foreground",t),...a})}function Ar({className:e,...t}){return Oe("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:nt("font-normal text-foreground",e),...t})}function Mr({children:e,className:t,...a}){return Oe("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:nt("[&>svg]:size-3.5",t),...a,children:e??Oe(rs,{})})}import{jsx as I,jsxs as zt}from"react/jsx-runtime";function ls({children:e,nav:t,appName:a,appSubtitle:o,version:r,suggestions:n,headerActions:i,themeColorPicker:s=!0}){let l=ss(),d=xt(t,l),f=d?[...new Set([d.group.title,d.item.title])]:[];return I(Lo,{children:zt(Jo,{children:[I(_a,{nav:t,appName:a,appSubtitle:o,version:r}),zt(ar,{className:"min-w-0",children:[zt("header",{className:"sticky top-0 z-10 flex h-14 shrink-0 items-center gap-2 border-b bg-background px-4",children:[I(er,{className:"-ml-1"}),I(Vo,{orientation:"vertical",className:"mr-2 data-[orientation=vertical]:h-4"}),I(Dr,{className:"min-w-0 flex-1",children:zt(Ir,{children:[I(Ja,{className:"hidden md:inline-flex",children:I(zr,{asChild:!0,children:I(is,{href:"/",children:"首页"})})}),f.map((P,N)=>zt(ns,{children:[I(Mr,{className:N===0?"hidden md:block":void 0}),I(Ja,{className:N<f.length-1?"hidden md:inline-flex":void 0,children:N===f.length-1?I(Ar,{children:P}):I("span",{children:P})})]},P))]})}),I(Ua,{}),i,s?I(Za,{}):null,I(Qa,{}),I(Ya,{})]}),I("main",{className:"flex min-w-0 flex-1 flex-col gap-4 p-4",children:e})]}),I(Ka,{suggestions:n}),I(Ga,{})]})})}import{useEffect as ps}from"react";import{CircleAlertIcon as ms,LogInIcon as Lr,RotateCwIcon as us}from"lucide-react";import{cva as ds}from"class-variance-authority";import{cn as it}from"cn";import{jsx as st}from"react/jsx-runtime";function da({className:e,...t}){return st("div",{"data-slot":"empty",className:it("flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance",e),...t})}function ca({className:e,...t}){return st("div",{"data-slot":"empty-header",className:it("flex max-w-sm flex-col items-center gap-2",e),...t})}var cs=ds("mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",{variants:{variant:{default:"bg-transparent",icon:"flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4"}},defaultVariants:{variant:"default"}});function Er({className:e,variant:t="default",...a}){return st("div",{"data-slot":"empty-icon","data-variant":t,className:it(cs({variant:t,className:e})),...a})}function pa({className:e,...t}){return st("div",{"data-slot":"empty-title",className:it("font-heading text-sm font-medium tracking-tight",e),...t})}function ma({className:e,...t}){return st("div",{"data-slot":"empty-description",className:it("text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",e),...t})}function Br({className:e,...t}){return st("div",{"data-slot":"empty-content",className:it("flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",e),...t})}import{jsx as J,jsxs as ua}from"react/jsx-runtime";function fs({children:e}){let t=Ht();if(ps(()=>{ho()},[]),t.status==="ready")return e;let a=t.status==="redirecting"&&t.auto;if(t.status==="loading"||t.status==="callback"||a)return ua("div",{className:"flex min-h-svh items-center justify-center gap-2",role:"status",children:[J(U,{}),J("span",{children:t.status==="callback"?"正在完成登录…":a?"正在跳转登录…":"正在准备登录…"})]});let o=t.status==="error",r=t.status==="redirecting";return J("div",{className:"flex min-h-svh items-center justify-center bg-muted p-4",children:ua(da,{className:"max-w-md bg-background",children:[ua(ca,{children:[J(Er,{variant:"icon",children:o?J(ms,{}):J(Lr,{})}),J(pa,{children:o?"无法进入选品工作台":"登录 LinkFox"}),J(ma,{children:o?t.message:"使用 LinkFox 账号登录,登录状态将在此浏览器中保留至到期或退出。"})]}),J(Br,{children:ua(p,{disabled:r,onClick:o&&t.action==="config"?()=>{Co()}:()=>{yo()},children:[r?J(U,{"data-icon":"inline-start"}):o?J(us,{"data-icon":"inline-start"}):J(Lr,{"data-icon":"inline-start"}),r?"正在跳转…":o?"重试":"登录 LinkFox"]})})]})})}import*as Fr from"react";import{ThemeProvider as gs,useTheme as bs}from"next-themes";import{jsx as _r,jsxs as Cs}from"react/jsx-runtime";function vs({children:e,...t}){return Cs(gs,{attribute:"class",defaultTheme:"system",enableSystem:!0,disableTransitionOnChange:!0,...t,children:[_r("script",{suppressHydrationWarning:!0,dangerouslySetInnerHTML:{__html:zo}}),_r(hs,{}),e]})}function xs(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName==="INPUT"||e.tagName==="TEXTAREA"||e.tagName==="SELECT":!1}function hs(){let{resolvedTheme:e,setTheme:t}=bs();return Fr.useEffect(()=>{function a(o){o.defaultPrevented||o.repeat||o.metaKey||o.ctrlKey||o.altKey||o.key.toLowerCase()==="d"&&(xs(o.target)||t(e==="dark"?"light":"dark"))}return window.addEventListener("keydown",a),()=>{window.removeEventListener("keydown",a)}},[e,t]),null}import{cn as ys}from"cn";import{Checkbox as Gr}from"radix-ui";import{CheckIcon as ws}from"lucide-react";import{jsx as ja}from"react/jsx-runtime";function Ve({className:e,...t}){return ja(Gr.Root,{"data-slot":"checkbox",className:ys("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 group-has-[:focus-visible]/field-label:ring-0 group-has-[:focus-visible]/field-label:not-data-checked:border-input after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground group-has-[:focus-visible]/field-label:data-checked:border-primary dark:data-checked:bg-primary",e),...t,children:ja(Gr.Indicator,{"data-slot":"checkbox-indicator",className:"grid place-content-center text-current transition-none [&>svg]:size-3.5",children:ja(ws,{})})})}import{cn as lt}from"cn";import{jsx as He}from"react/jsx-runtime";function fa({className:e,...t}){return He("div",{"data-slot":"table-container",className:"relative w-full overflow-x-auto",children:He("table",{"data-slot":"table",className:lt("w-full caption-bottom text-sm",e),...t})})}function ga({className:e,...t}){return He("thead",{"data-slot":"table-header",className:lt("[&_tr]:border-b",e),...t})}function ba({className:e,...t}){return He("tbody",{"data-slot":"table-body",className:lt("[&_tr:last-child]:border-0",e),...t})}function xe({className:e,...t}){return He("tr",{"data-slot":"table-row",className:lt("border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",e),...t})}function ae({className:e,...t}){return He("th",{"data-slot":"table-head",className:lt("h-10 px-2 text-left align-middle font-medium text-foreground [&:has([role=checkbox])]:pr-0",e),...t})}function $({className:e,...t}){return He("td",{"data-slot":"table-cell",className:lt("p-2 align-middle break-words [&:has([role=checkbox])]:pr-0",e),...t})}import{cn as va}from"cn";import{jsx as L,jsxs as xa}from"react/jsx-runtime";var Or=56,Vr=120;function Ns({columns:e,rows:t,rowKey:a,renderCell:o,actions:r,actionsWidth:n=200,selection:i,onRowClick:s,loading:l,skeletonRows:d=8,empty:f,className:P}){let N=e.length+(i?1:0)+(r?1:0),C={"--dt-min-width":`${e.reduce((h,T)=>h+(T.width??Vr),0)+(i?Or:0)+(r?n:0)}px`};return xa(fa,{style:C,className:va("lg:[min-width:var(--dt-min-width)] max-lg:block",P),children:[L(ga,{className:"max-lg:hidden",children:xa(xe,{children:[i&&L(ae,{style:{width:Or},className:"lg:sticky lg:left-0 lg:z-20 lg:bg-card",children:L(Ve,{"aria-label":"全选本页",checked:i.pageAllSelected?!0:i.pageSomeSelected?"indeterminate":!1,disabled:!t.length,onCheckedChange:h=>i.onToggleAll(h===!0)})}),e.map(h=>L(ae,{style:{width:h.width??Vr},className:"break-words",children:h.label},h.key)),r&&L(ae,{style:{width:n},className:"text-right lg:sticky lg:right-0 lg:z-20 lg:border-l lg:bg-card",children:"操作"})]})}),xa(ba,{className:"max-lg:block",children:[l&&t.length===0?Array.from({length:d},(h,T)=>L(xe,{className:"max-lg:block max-lg:border-0",children:L($,{colSpan:N,className:"max-lg:block",children:L(Kt,{className:"h-10 w-full"})})},T)):t.map(h=>{let T=a(h);return xa(xe,{"data-state":i?.selected.has(T)?"selected":void 0,onClick:s?()=>s(h):void 0,className:va("group/row",l&&"opacity-60",s&&"cursor-pointer","max-lg:mb-3 max-lg:block max-lg:rounded-lg max-lg:border max-lg:p-3"),children:[i&&L($,{className:"max-lg:flex max-lg:items-center max-lg:border-0 max-lg:px-0 max-lg:py-1 lg:sticky lg:left-0 lg:z-10 lg:bg-card lg:group-hover/row:bg-muted",children:L(Ve,{"aria-label":"选择本行",checked:i.selected.has(T),onCheckedChange:y=>i.onToggleRow(h,y===!0),onClick:y=>y.stopPropagation()})}),e.map(y=>L($,{"data-label":y.label,className:va("align-top break-words","max-lg:flex max-lg:gap-3 max-lg:border-0 max-lg:px-0 max-lg:py-1","max-lg:before:w-24 max-lg:before:shrink-0 max-lg:before:text-xs max-lg:before:text-muted-foreground","max-lg:before:content-[attr(data-label)]"),children:L("div",{className:"min-w-0 flex-1",children:o(h,y)})},y.key)),r&&L($,{className:va("align-top text-right max-lg:flex max-lg:justify-end max-lg:border-0 max-lg:px-0 max-lg:py-1","lg:sticky lg:right-0 lg:z-10 lg:border-l lg:bg-card lg:group-hover/row:bg-muted"),children:L("div",{className:"flex justify-end gap-1",onClick:y=>y.stopPropagation(),children:r(h)})})]},T)}),!l&&t.length===0&&f?L(xe,{className:"max-lg:block max-lg:border-0 hover:bg-transparent",children:L($,{colSpan:N,className:"whitespace-normal max-lg:block",children:f})}):null]})]})}import{cn as dt}from"cn";import{ChevronLeftIcon as Ps,ChevronRightIcon as ks,MoreHorizontalIcon as Ss}from"lucide-react";import{jsx as oe,jsxs as eo}from"react/jsx-runtime";function Hr({className:e,...t}){return oe("nav",{role:"navigation","aria-label":"pagination","data-slot":"pagination",className:dt("mx-auto flex w-full justify-center",e),...t})}function $r({className:e,...t}){return oe("ul",{"data-slot":"pagination-content",className:dt("flex items-center gap-0.5",e),...t})}function At({...e}){return oe("li",{"data-slot":"pagination-item",...e})}function ha({className:e,isActive:t,size:a="icon",...o}){return oe(p,{asChild:!0,variant:t?"outline":"ghost",size:a,className:dt(e),children:oe("a",{"aria-current":t?"page":void 0,"data-slot":"pagination-link","data-active":t,...o})})}function Kr({className:e,text:t="Previous",...a}){return eo(ha,{"aria-label":"Go to previous page",size:"default",className:dt("pl-1.5!",e),...a,children:[oe(Ps,{"data-icon":"inline-start"}),oe("span",{className:"hidden sm:block",children:t})]})}function Ur({className:e,text:t="Next",...a}){return eo(ha,{"aria-label":"Go to next page",size:"default",className:dt("pr-1.5!",e),...a,children:[oe("span",{className:"hidden sm:block",children:t}),oe(ks,{"data-icon":"inline-end"})]})}function Wr({className:e,...t}){return eo("span",{"aria-hidden":!0,"data-slot":"pagination-ellipsis",className:dt("flex size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4",e),...t,children:[oe(Ss,{}),oe("span",{className:"sr-only",children:"More pages"})]})}import{cn as Zr}from"cn";import{jsx as de,jsxs as to}from"react/jsx-runtime";var Mt=20;function Rs(e,t){if(t<=7)return Array.from({length:t},(n,i)=>i+1);let a=[1],o=Math.max(2,e-1),r=Math.min(t-1,e+1);o>2&&a.push("…");for(let n=o;n<=r;n++)a.push(n);return r<t-1&&a.push("…"),a.push(t),a}function ao({page:e,total:t,disabled:a,onChange:o,pageSize:r=Mt,note:n}){let i=Math.max(1,Math.ceil(t/r)),s=d=>f=>{f.preventDefault(),!(a||d<1||d>i||d===e)&&o(d)},l=d=>Zr(d&&"pointer-events-none opacity-50");return to("div",{className:"flex flex-col items-center justify-between gap-2 sm:flex-row",children:[to("p",{className:"text-sm text-muted-foreground",children:["共 ",t.toLocaleString("zh-CN")," 条,第 ",e,"/",i," 页,每页 ",r," 条",n?de("span",{className:"ml-2",children:n}):null]}),de(Hr,{className:"mx-0 w-auto",children:to($r,{children:[de(At,{children:de(Kr,{href:"#",text:"上一页","aria-label":"上一页",onClick:s(e-1),className:l(a||e<=1)})}),Rs(e,i).map((d,f)=>d==="…"?de(At,{className:"hidden sm:block",children:de(Wr,{})},`e${f}`):de(At,{className:Zr(d!==e&&"hidden sm:block"),children:de(ha,{href:"#",isActive:d===e,onClick:s(d),className:l(!!a),children:d})},d)),de(At,{children:de(Ur,{href:"#",text:"下一页","aria-label":"下一页",onClick:s(e+1),className:l(a||e>=i)})})]})})]})}import{useState as Bs}from"react";import{ChevronDownIcon as Ls,RotateCcwIcon as _s,SearchIcon as Fs}from"lucide-react";import{ChevronDownIcon as Ts}from"lucide-react";import{jsx as we,jsxs as qr}from"react/jsx-runtime";function ct({id:e,value:t,onChange:a,options:o,placeholder:r,multiple:n}){let i=s=>{if(!n)return a(s);let l=t.split(/[,,、]/).map(d=>d.trim()).filter(Boolean);a(l.includes(s)?l.join(","):[...l,s].join(","))};return qr(Ye,{children:[we(ia,{id:e,value:t,placeholder:r??"请选择或输入",onChange:s=>a(s.target.value)}),we(Je,{align:"inline-end",children:qr(tt,{children:[we(at,{asChild:!0,children:we(hr,{size:"icon-xs","aria-label":"展开选项",children:we(Ts,{})})}),we(ot,{align:"end",className:"max-h-72 overflow-y-auto",children:we(Tt,{children:o.map(s=>we(Ge,{onSelect:()=>i(s.value),children:s.label??s.value},s.value))})})]})})]})}import{cn as Xr}from"cn";import{jsx as Qr}from"react/jsx-runtime";function Et({className:e,size:t="default",...a}){return Qr("div",{"data-slot":"card","data-size":t,className:Xr("group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",e),...a})}function Bt({className:e,...t}){return Qr("div",{"data-slot":"card-content",className:Xr("px-(--card-spacing)",e),...t})}import{useMemo as As}from"react";import{cva as Ms}from"class-variance-authority";import{cn as Ca}from"cn";import{cn as Ds}from"cn";import{Label as Is}from"radix-ui";import{jsx as zs}from"react/jsx-runtime";function pt({className:e,...t}){return zs(Is.Root,{"data-slot":"label",className:Ds("flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",e),...t})}import{jsx as mt,jsxs as Rm}from"react/jsx-runtime";function ut({className:e,...t}){return mt("div",{"data-slot":"field-group",className:Ca("group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",e),...t})}var Es=Ms("group/field flex w-full gap-2 data-[invalid=true]:text-destructive",{variants:{orientation:{vertical:"flex-col *:w-full [&>.sr-only]:w-auto",horizontal:"flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",responsive:"flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px"}},defaultVariants:{orientation:"vertical"}});function _({className:e,orientation:t="vertical",...a}){return mt("div",{role:"group","data-slot":"field","data-orientation":t,className:Ca(Es({orientation:t}),e),...a})}function F({className:e,...t}){return mt(pt,{"data-slot":"field-label",className:Ca("group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border has-[>[data-slot=field]]:not-has-[:disabled,[data-disabled]]:hover:bg-muted/50 has-[>[data-slot=field]]:has-[:focus-visible]:border-ring has-[>[data-slot=field]]:has-[:focus-visible]:ring-3 has-[>[data-slot=field]]:has-[:focus-visible]:ring-ring/50 *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10","has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",e),...t})}function Yr({className:e,children:t,errors:a,...o}){let r=As(()=>{if(t)return t;if(!a?.length)return null;let n=[...new Map(a.map(i=>[i?.message,i])).values()];return n?.length==1?n[0]?.message:mt("ul",{className:"ml-4 flex list-disc flex-col gap-1",children:n.map((i,s)=>i?.message&&mt("li",{children:i.message},s))})},[t,a]);return r?mt("div",{role:"alert","data-slot":"field-error",className:Ca("text-sm font-normal text-destructive",e),...o,children:r}):null}import{cn as Jr}from"cn";import{jsx as x,jsxs as z}from"react/jsx-runtime";var jr="grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4";function en({spec:e,values:t,set:a,currency:o}){let r=`ff-${e.id}`;switch(e.type){case"range":{let n=e.price?o:e.unit,i=(s,l,d)=>z(Ye,{children:[x(ia,{id:s.endsWith("gte")?r:void 0,inputMode:"decimal","aria-label":`${e.label}${d}`,placeholder:l,value:t[s]??"",onChange:f=>a(s,f.target.value)}),n&&x(Je,{align:"inline-end",children:x(Cr,{children:n})})]});return z(_,{children:[x(F,{htmlFor:r,children:e.label}),z("div",{className:"flex items-center gap-2",children:[i(`${e.id}.gte`,"最小","最小值"),x("span",{className:"text-muted-foreground",children:"至"}),i(`${e.id}.lte`,"最大","最大值")]})]})}case"dateRange":return z(_,{children:[x(F,{htmlFor:r,children:e.label}),z("div",{className:"flex items-center gap-2",children:[x(X,{id:r,type:"date","aria-label":`${e.label}开始`,value:t[`${e.id}.gte`]??"",onChange:n=>a(`${e.id}.gte`,n.target.value)}),x("span",{className:"text-muted-foreground",children:"至"}),x(X,{type:"date","aria-label":`${e.label}结束`,value:t[`${e.id}.lte`]??"",onChange:n=>a(`${e.id}.lte`,n.target.value)})]})]});case"text":return z(_,{children:[x(F,{htmlFor:r,children:e.label}),x(X,{id:r,placeholder:e.placeholder,value:t[e.id]??"",onChange:n=>a(e.id,n.target.value)})]});case"list":return z(_,{children:[x(F,{htmlFor:r,children:e.label}),e.options?x(ct,{id:r,placeholder:e.placeholder,value:t[e.id]??"",options:e.options.map(n=>({value:n})),multiple:e.multiple,onChange:n=>a(e.id,n)}):x(X,{id:r,placeholder:e.placeholder,value:t[e.id]??"",onChange:n=>a(e.id,n.target.value)})]});case"flags":{let n=vo(t[e.id]);return z(_,{children:[x(F,{children:e.label}),x("div",{className:"flex flex-wrap gap-x-4 gap-y-2 pt-1",children:e.options.map(i=>z(pt,{className:"flex items-center gap-2 font-normal",children:[x(Ve,{checked:n.includes(i.value),onCheckedChange:s=>a(e.id,xo(t[e.id],i.value,s===!0))}),i.label]},i.value))})]})}case"bool":case"select":{let n=e.type==="bool"?[{value:"yes",label:"是"},{value:"no",label:"否"}]:e.options,i=e.type==="select"&&e.required,s=i?t[e.id]||n[0]?.value:t[e.id]||"any";return z(_,{children:[x(F,{htmlFor:r,children:e.label}),z(Me,{value:s,onValueChange:l=>a(e.id,l==="any"?"":l),children:[x(Be,{id:r,className:"w-full",children:x(Ee,{})}),x(Le,{children:z(Nt,{children:[!i&&x(be,{value:"any",children:"不限"}),n.map(l=>x(be,{value:l.value,children:l.label},l.value))]})})]})]})}}}function Gs({primary:e,more:t,values:a,onChange:o,onSearch:r,onReset:n,loading:i,currency:s,searchLabel:l="查询",searchIcon:d,disabled:f,prepend:P,append:N,note:v}){let[C,h]=Bs(!1),T=(w,q)=>o({...a,[w]:q}),y=t.filter(w=>bo(w).some(q=>a[q])).length;return x(Et,{children:x(Bt,{children:z("form",{onSubmit:w=>{w.preventDefault(),r()},className:"flex flex-col gap-4",children:[z(ut,{className:jr,children:[P,e.map(w=>x(en,{spec:w,values:a,set:T,currency:s},w.id)),N]}),z(Ue,{open:C,onOpenChange:h,children:[x(Ze,{children:x(ut,{className:Jr(jr,"pb-4"),children:t.map(w=>x(en,{spec:w,values:a,set:T,currency:s},w.id))})}),z("div",{className:"flex flex-wrap items-center gap-2",children:[z(p,{type:"submit",disabled:i||f,children:[i?x(U,{"data-icon":"inline-start"}):d??x(Fs,{"data-icon":"inline-start"}),l]}),z(p,{type:"button",variant:"outline",onClick:n,children:[x(_s,{"data-icon":"inline-start"}),"重置"]}),t.length>0&&x(We,{asChild:!0,children:z(p,{type:"button",variant:"ghost",children:["更多条件",y?`(已填 ${y})`:"",x(Ls,{"data-icon":"inline-end",className:Jr("transition-transform",C&&"rotate-180")})]})}),v&&x("p",{className:"text-xs text-muted-foreground sm:ml-auto",children:v})]})]})]})})})}import{Columns3Icon as Os}from"lucide-react";import{jsx as $e,jsxs as Lt}from"react/jsx-runtime";function Vs({columns:e,visible:t,onChange:a,onReset:o}){return Lt(tt,{children:[$e(at,{asChild:!0,children:Lt(p,{variant:"outline",size:"sm",children:[$e(Os,{"data-icon":"inline-start"}),"列设置"]})}),Lt(ot,{align:"end",className:"max-h-96 w-56 overflow-y-auto",children:[Lt(Dt,{children:["显示的列(",t.length,"/",e.length,")"]}),Lt(Tt,{children:[$e(Ge,{onSelect:r=>(r.preventDefault(),o()),children:"恢复默认"}),$e(Ge,{onSelect:r=>(r.preventDefault(),a(e.map(n=>n.key))),children:"全部显示"})]}),$e(la,{}),$e(Tt,{children:e.map(r=>$e(Tr,{checked:t.includes(r.key),onSelect:n=>n.preventDefault(),onCheckedChange:n=>a(n?e.map(i=>i.key).filter(i=>i===r.key||t.includes(i)):t.filter(i=>i!==r.key)),children:r.label},r.key))})]})]})}import{useState as Us}from"react";import{cn as Ne}from"cn";import{AlertDialog as Pe}from"radix-ui";import{jsx as Z,jsxs as Ks}from"react/jsx-runtime";function tn({...e}){return Z(Pe.Root,{"data-slot":"alert-dialog",...e})}function Hs({...e}){return Z(Pe.Portal,{"data-slot":"alert-dialog-portal",...e})}function $s({className:e,...t}){return Z(Pe.Overlay,{"data-slot":"alert-dialog-overlay",className:Ne("fixed inset-0 z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",e),...t})}function an({className:e,size:t="default",...a}){return Ks(Hs,{children:[Z($s,{}),Z(Pe.Content,{"data-slot":"alert-dialog-content","data-size":t,className:Ne("group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none max-w-[calc(100%-2rem)] sm:max-w-sm data-[size=sm]:sm:max-w-xs data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",e),...a})]})}function on({className:e,...t}){return Z("div",{"data-slot":"alert-dialog-header",className:Ne("grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",e),...t})}function rn({className:e,...t}){return Z("div",{"data-slot":"alert-dialog-footer",className:Ne("-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",e),...t})}function nn({className:e,...t}){return Z(Pe.Title,{"data-slot":"alert-dialog-title",className:Ne("font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",e),...t})}function sn({className:e,...t}){return Z(Pe.Description,{"data-slot":"alert-dialog-description",className:Ne("text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",e),...t})}function ln({className:e,variant:t="default",size:a="default",...o}){return Z(p,{variant:t,size:a,asChild:!0,children:Z(Pe.Action,{"data-slot":"alert-dialog-action",className:Ne(e),...o})})}function dn({className:e,variant:t="outline",size:a="default",...o}){return Z(p,{variant:t,size:a,asChild:!0,children:Z(Pe.Cancel,{"data-slot":"alert-dialog-cancel",className:Ne(e),...o})})}import{jsx as he,jsxs as ya}from"react/jsx-runtime";function oo({open:e,onOpenChange:t,title:a,description:o,details:r,requireCheck:n,confirmLabel:i="确认",cancelLabel:s="取消",destructive:l,busy:d,onConfirm:f}){let[P,N]=Us(!1),v=!!n&&!P;return he(tn,{open:e,onOpenChange:C=>{C||N(!1),t(C)},children:ya(an,{children:[ya(on,{children:[he(nn,{children:a}),o&&he(sn,{children:o})]}),r?.length?he("ul",{className:"list-disc space-y-1 pl-5 text-sm text-muted-foreground",children:r.map((C,h)=>he("li",{children:C},h))}):null,n&&ya(pt,{className:"flex items-start gap-2 text-sm font-normal",children:[he(Ve,{checked:P,onCheckedChange:C=>N(C===!0),className:"mt-0.5"}),he("span",{children:n})]}),ya(rn,{children:[he(dn,{children:s}),he(ln,{variant:l?"destructive":void 0,disabled:d||v,onClick:C=>{C.preventDefault(),!v&&f()},children:i})]})]})})}import{useCallback as js,useEffect as el,useState as K}from"react";import{PencilIcon as tl,PlusIcon as al,PowerIcon as ol,RotateCcwIcon as rl,SearchIcon as nl,Trash2Icon as il}from"lucide-react";import{toast as ft}from"sonner";import{cva as Ws}from"class-variance-authority";import{cn as ro}from"cn";import{jsx as no}from"react/jsx-runtime";var Zs=Ws("group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-card text-card-foreground",destructive:"bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"}},defaultVariants:{variant:"default"}});function cn({className:e,variant:t,...a}){return no("div",{"data-slot":"alert",role:"alert",className:ro(Zs({variant:t}),e),...a})}function pn({className:e,...t}){return no("div",{"data-slot":"alert-title",className:ro("font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",e),...t})}function mn({className:e,...t}){return no("div",{"data-slot":"alert-description",className:ro("text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",e),...t})}import{cva as qs}from"class-variance-authority";import{cn as Xs}from"cn";import{Slot as Qs}from"radix-ui";import{jsx as Js}from"react/jsx-runtime";var Ys=qs("group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",{variants:{variant:{default:"bg-primary text-primary-foreground [a]:hover:bg-primary/80",secondary:"bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",destructive:"bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",outline:"border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",ghost:"hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",link:"text-primary underline-offset-4 hover:underline"}},defaultVariants:{variant:"default"}});function wa({className:e,variant:t="default",asChild:a=!1,...o}){let r=a?Qs.Root:"span";return Js(r,{"data-slot":"badge","data-variant":t,className:Xs(Ys({variant:t}),e),...o})}import{jsx as c,jsxs as b}from"react/jsx-runtime";var un=[{value:"手动添加"},{value:"侵权投诉"},{value:"商标库"},{value:"平台通知"},{value:"行业经验"}],_t={word:"",cnName:"",status:"all",source:""},re=e=>e==null?"":String(e);function sl({kind:e,description:t}){let a=Ta[e],o=$t(),[r,n]=K(),[i,s]=K(""),[l,d]=K(_t),[f,P]=K(_t),[N,v]=K(1),[C,h]=K([]),[T,y]=K(0),[w,q]=K(!1),[ke,me]=K(null),[j,gt]=K(null),[bt,ue]=K(),fe=js(async(u,D,A)=>{let Ce=Te();if(!Ce)throw new Error("多维表客户端尚未初始化");let ne=[];D.word.trim()&&ne.push({fieldName:"词条",operator:"contains",value:D.word.trim()}),D.cnName.trim()&&ne.push({fieldName:"中文名",operator:"contains",value:D.cnName.trim()}),D.status!=="all"&&ne.push({fieldName:"状态",operator:"is",value:D.status}),D.source.trim()&&ne.push({fieldName:"来源",operator:"contains",value:D.source.trim()}),P(D),q(!0);try{let E=hn=>Ce.listRecords({tableId:u,page:hn,perPage:Mt,fieldNames:["词条","中文名","状态","来源","创建时间"],filter:ne.length?{conjunction:"and",conditions:ne}:void 0}),Se=await E(A),Re=Math.max(1,Math.ceil(Se.total/Mt));A>Re&&(A=Re,Se=await E(A)),v(A),h(Se.records),y(Se.total)}catch(E){ft.error(`查询失败:${ge(E)}`)}finally{q(!1)}},[]);el(()=>{try{Ro().ensureWordTable(e).then(u=>(n(u.tableId),fe(u.tableId,_t,1))).catch(u=>s(ge(u)))}catch(u){s(ge(u))}},[e,fe]);let vt=()=>r?fe(r,f,N):Promise.resolve(),Pa=u=>{u?.preventDefault(),r&&fe(r,{...l},1)},so=()=>{d(_t),r&&fe(r,_t,1)},ka=async u=>{let D=Te();if(!r||!D)return;let A=u.fields.状态==="启用"?"禁用":"启用";ue(u.recordId);try{await D.updateRecords(r,[{recordId:u.recordId,fields:{状态:A}}]),ft.success(`已${A}「${re(u.fields.词条)}」`),await vt()}catch(Ce){ft.error(ge(Ce))}finally{ue(void 0)}},g=async()=>{let u=Te();if(!(!r||!j||!u)){ue(j.recordId);try{await u.deleteRecords(r,[j.recordId]),ft.success(`已删除「${re(j.fields.词条)}」`),gt(null),await vt()}catch(D){ft.error(ge(D))}finally{ue(void 0)}}};return i?b(cn,{variant:"destructive",children:[b(pn,{children:["无法打开",a,"表"]}),c(mn,{children:i})]}):b("div",{className:"flex flex-col gap-4",children:[b("div",{children:[c("h1",{className:"text-lg font-semibold",children:a}),c("p",{className:"text-sm text-muted-foreground",children:t})]}),c(Et,{children:c(Bt,{children:b("form",{onSubmit:Pa,children:[b(ut,{className:"grid grid-cols-1 gap-4 sm:grid-cols-2 xl:grid-cols-4",children:[b(_,{children:[c(F,{htmlFor:`${e}-q-word`,children:"词条"}),c(X,{id:`${e}-q-word`,value:l.word,placeholder:"包含",onChange:u=>d({...l,word:u.target.value})})]}),b(_,{children:[c(F,{htmlFor:`${e}-q-cn`,children:"中文名"}),c(X,{id:`${e}-q-cn`,value:l.cnName,placeholder:"包含",onChange:u=>d({...l,cnName:u.target.value})})]}),b(_,{children:[c(F,{htmlFor:`${e}-q-status`,children:"状态"}),b(Me,{value:l.status,onValueChange:u=>d({...l,status:u}),children:[c(Be,{id:`${e}-q-status`,className:"w-full",children:c(Ee,{})}),c(Le,{children:b(Nt,{children:[c(be,{value:"all",children:"全部"}),Ra.map(u=>c(be,{value:u,children:u},u))]})})]})]}),b(_,{children:[c(F,{htmlFor:`${e}-q-source`,children:"来源"}),c(ct,{id:`${e}-q-source`,value:l.source,options:un,onChange:u=>d({...l,source:u})})]})]}),b("div",{className:"mt-4 flex flex-wrap gap-2",children:[b(p,{type:"submit",disabled:!r||w,children:[c(nl,{"data-icon":"inline-start"}),"查询"]}),b(p,{type:"button",variant:"outline",onClick:so,children:[c(rl,{"data-icon":"inline-start"}),"重置"]}),b(p,{type:"button",variant:"secondary",className:"sm:ml-auto",disabled:!r,onClick:()=>me("new"),children:[c(al,{"data-icon":"inline-start"}),"新增",a]})]})]})})}),c(Et,{children:b(Bt,{className:"flex flex-col gap-4",children:[b(fa,{children:[c(ga,{children:b(xe,{children:[c(ae,{children:"词条"}),c(ae,{children:"中文名"}),c(ae,{children:"状态"}),c(ae,{children:"来源"}),c(ae,{children:"创建时间"}),c(ae,{className:"sticky right-0 bg-background text-right",children:"操作"})]})}),c(ba,{children:(w||!r)&&C.length===0?Array.from({length:5},(u,D)=>c(xe,{children:c($,{colSpan:6,children:c(Kt,{className:"h-6 w-full"})})},D)):C.map(u=>b(xe,{className:w?"opacity-60":void 0,children:[c($,{className:"font-medium",children:re(u.fields.词条)}),c($,{children:re(u.fields.中文名)||"-"}),c($,{children:c(wa,{variant:u.fields.状态==="启用"?"default":"secondary",children:re(u.fields.状态)||"-"})}),c($,{children:re(u.fields.来源)||"-"}),c($,{className:"whitespace-nowrap",children:Eo(u.fields.创建时间,o)}),c($,{className:"sticky right-0 bg-background",children:b("div",{className:"flex justify-end gap-1",children:[b(p,{variant:"ghost",size:"sm",onClick:()=>me(u),children:[c(tl,{"data-icon":"inline-start"}),"修改"]}),b(p,{variant:"ghost",size:"sm",disabled:bt===u.recordId,onClick:()=>ka(u),children:[bt===u.recordId?c(U,{"data-icon":"inline-start"}):c(ol,{"data-icon":"inline-start"}),u.fields.状态==="启用"?"禁用":"启用"]}),b(p,{variant:"ghost",size:"sm",onClick:()=>gt(u),children:[c(il,{"data-icon":"inline-start"}),"删除"]})]})})]},u.recordId))})]}),!w&&r&&C.length===0&&c(da,{children:b(ca,{children:[b(pa,{children:["暂无",a]}),b(ma,{children:["点击「新增",a,"」添加第一条词条。"]})]})}),c(ao,{page:N,total:T,disabled:w,onChange:u=>r&&fe(r,f,u)})]})}),ke&&r&&c(ll,{kind:e,tableId:r,record:ke==="new"?null:ke,onClose:()=>me(null),onSaved:()=>{me(null),vt()}}),c(oo,{open:!!j,onOpenChange:u=>!u&>(null),title:`删除${a}「${re(j?.fields.词条)}」?`,description:"删除后无法恢复。只想暂时不用的话,可以改为「禁用」。",confirmLabel:"删除",destructive:!0,busy:bt===j?.recordId,onConfirm:g})]})}function ll({kind:e,tableId:t,record:a,onClose:o,onSaved:r}){let n=Ta[e],[i,s]=K({词条:re(a?.fields.词条),中文名:re(a?.fields.中文名),状态:re(a?.fields.状态)||"启用",来源:re(a?.fields.来源)||(a?"":"手动添加")}),[l,d]=K(""),[f,P]=K(!1);return c(Xt,{open:!0,onOpenChange:v=>!v&&o(),children:c(Qt,{className:"flex max-h-[90svh] flex-col",children:b("form",{onSubmit:async v=>{v.preventDefault();let C=Te();if(!C){d("多维表客户端尚未初始化");return}let h=i.词条.trim();if(!h){d("请输入词条");return}P(!0),d("");try{if((await C.listRecords({tableId:t,perPage:5,fieldNames:["词条"],filter:{conditions:[{fieldName:"词条",operator:"is",value:h}]}})).records.some(w=>w.recordId!==a?.recordId)){d(`「${h}」已存在`);return}let y={...i,词条:h,中文名:i.中文名.trim(),来源:i.来源.trim()};a?await C.updateRecords(t,[{recordId:a.recordId,fields:y}]):await C.createRecords(t,[{...y,创建时间:new Date().toISOString()}]),ft.success(a?"已保存修改":`已新增${n}「${h}」`),r()}catch(T){d(ge(T))}finally{P(!1)}},className:"flex min-h-0 flex-1 flex-col gap-4",children:[b(Yt,{children:[c(jt,{children:a?`修改${n}`:`新增${n}`}),c(ea,{children:"启用状态的词条会在「添加到选品库」时用于过滤商品。"})]}),c("div",{className:"-mx-4 min-h-0 flex-1 overflow-y-auto overscroll-contain px-4",children:b(ut,{children:[b(_,{"data-invalid":l?!0:void 0,children:[c(F,{htmlFor:"word-term",children:"词条"}),c(X,{id:"word-term",autoFocus:!0,value:i.词条,"aria-invalid":l?!0:void 0,onChange:v=>s({...i,词条:v.target.value})}),l&&c(Yr,{children:l})]}),b(_,{children:[c(F,{htmlFor:"word-cn",children:"中文名"}),c(X,{id:"word-cn",value:i.中文名,onChange:v=>s({...i,中文名:v.target.value})})]}),b(_,{children:[c(F,{htmlFor:"word-status",children:"状态"}),b(Me,{value:i.状态,onValueChange:v=>s({...i,状态:v}),children:[c(Be,{id:"word-status",className:"w-full",children:c(Ee,{})}),c(Le,{children:c(Nt,{children:Ra.map(v=>c(be,{value:v,children:v},v))})})]})]}),b(_,{children:[c(F,{htmlFor:"word-source",children:"来源"}),c(ct,{id:"word-source",value:i.来源,options:un,onChange:v=>s({...i,来源:v})})]})]})}),b(Jt,{children:[c(p,{type:"button",variant:"outline",onClick:o,children:"取消"}),b(p,{type:"submit",disabled:f,children:[f&&c(U,{"data-icon":"inline-start"}),"保存"]})]})]})})})}import{cn as dl}from"cn";import{jsx as O,jsxs as ce}from"react/jsx-runtime";var cl={已完成:"border-emerald-600/40 bg-emerald-600/10 text-emerald-700 dark:text-emerald-400",需人工处理:"border-amber-600/40 bg-amber-600/10 text-amber-700 dark:text-amber-400",失败:"border-destructive/40 bg-destructive/10 text-destructive"};function pl({task:e,running:t,onOpen:a,onStop:o,onRetry:r,className:n}){let i=e.budget&&(e.budget.used>0||e.budget.estimate)?e.budget.estimate?`${e.budget.used} / ${e.budget.estimate}${e.budget.unit??""}`:`${e.budget.used}${e.budget.unit??""}`:void 0;return ce("div",{className:dl("rounded-lg border p-3",n),children:[ce("div",{className:"flex flex-wrap items-center gap-2",children:[O("button",{type:"button",className:"min-w-0 flex-1 truncate text-left font-medium text-primary underline-offset-4 hover:underline",onClick:a,children:e.code}),O(wa,{variant:"outline",className:cl[e.status]??"",children:e.status||"—"})]}),(e.stage||e.hint)&&O("p",{className:"mt-1 text-xs text-muted-foreground",children:[e.stage,e.hint].filter(Boolean).join(" · ")}),e.stages?.length?O("div",{className:"mt-2 flex flex-wrap gap-1",children:e.stages.map(s=>ce("span",{className:"rounded border px-1.5 py-0.5 text-xs tabular-nums",title:s.label,children:[s.label," ",s.pass,"/",s.input,s.todo?ce("span",{className:"text-amber-600 dark:text-amber-400",children:[" +",s.todo]}):null]},s.key))}):null,ce("dl",{className:"mt-2 grid grid-cols-2 gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[i&&ce("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"算力"}),O("dd",{className:"tabular-nums",children:i})]}),e.rounds!=null&&ce("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"轮次"}),O("dd",{className:"tabular-nums",children:e.rounds})]}),e.startedAt&&ce("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"开始"}),O("dd",{className:"tabular-nums",children:e.startedAt})]}),e.lastActiveAt&&ce("div",{className:"flex justify-between gap-2",children:[O("dt",{children:"最后活动"}),O("dd",{className:"tabular-nums",children:e.lastActiveAt})]})]}),ce("div",{className:"mt-2 flex flex-wrap gap-1",children:[a&&O(p,{variant:"ghost",size:"sm",onClick:a,children:"查看"}),t&&o&&O(p,{variant:"ghost",size:"sm",onClick:o,children:"停止"}),r&&O(p,{variant:"ghost",size:"sm",onClick:r,children:"重试未完成"})]})]})}import{useEffect as bn,useRef as fl,useState as gl}from"react";import{CheckIcon as bl,CopyIcon as vl}from"lucide-react";import{cn as fn}from"cn";import{ScrollArea as Ft}from"radix-ui";import{jsx as Gt,jsxs as ul}from"react/jsx-runtime";function gn({className:e,children:t,...a}){return ul(Ft.Root,{"data-slot":"scroll-area",className:fn("relative",e),...a,children:[Gt(Ft.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:t}),Gt(ml,{}),Gt(Ft.Corner,{})]})}function ml({className:e,orientation:t="vertical",...a}){return Gt(Ft.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar","data-orientation":t,orientation:t,className:fn("flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",e),...a,children:Gt(Ft.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}import{jsx as Ke,jsxs as Na}from"react/jsx-runtime";var xl=/^\[(\d{4}-\d{2}-\d{2}T[\d:.]+Z)\]/;function hl(e,t){let a=e.match(xl);if(!a)return e;let o=new Date(a[1]);return Number.isNaN(o.getTime())?e:`[${new Intl.DateTimeFormat("zh-CN",{timeZone:t,month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).format(o)}]${e.slice(a[0].length)}`}function Cl({text:e,timeZone:t,className:a}){let o=String(e??"").trim(),r=o?o.split(`
|
|
2
|
+
`).map(d=>hl(d,t)):[],n=fl(null),[i,s]=gl(!1);bn(()=>{n.current?.scrollIntoView({block:"nearest"})},[o]),bn(()=>{if(!i)return;let d=setTimeout(()=>s(!1),1500);return()=>clearTimeout(d)},[i]);async function l(){try{await navigator.clipboard.writeText(r.join(`
|
|
3
|
+
`)),s(!0)}catch{}}return Na("section",{className:a,children:[Na("div",{className:"mb-2 flex flex-wrap items-center gap-2",children:[Ke("h3",{className:"text-sm font-medium",children:"工作流执行日志"}),Ke("span",{className:"text-xs text-muted-foreground",children:"保留最近 50 条 · 时间按所选时区"}),o&&Na(p,{variant:"ghost",size:"sm",className:"ml-auto",onClick:()=>{l()},children:[i?Ke(bl,{"data-icon":"inline-start"}):Ke(vl,{"data-icon":"inline-start"}),i?"已复制":"复制"]})]}),o?Na(gn,{className:"h-56 rounded border bg-muted/40",children:[Ke("pre",{className:"whitespace-pre-wrap break-words p-3 text-xs leading-relaxed",children:r.join(`
|
|
4
|
+
`)}),Ke("div",{ref:n})]}):Ke("p",{className:"rounded border border-dashed p-3 text-xs text-muted-foreground",children:"暂无执行日志"})]})}import{CheckIcon as yl,ChevronRightIcon as vn,LoaderIcon as wl,SettingsIcon as Nl}from"lucide-react";import{cn as io}from"cn";import{jsx as G,jsxs as pe}from"react/jsx-runtime";var Pl={done:"bg-emerald-600 text-white border-emerald-600",active:"bg-primary text-primary-foreground border-primary",idle:"bg-muted text-muted-foreground border-border"};function xn(e){return e.input===0||e.input===e.pass+e.fail+e.todo}function kl({startLabel:e="启动条件",startSummary:t,stages:a,countsOf:o,stateOf:r,current:n,onSelect:i,tail:s}){return pe("div",{className:"flex flex-col gap-2 lg:flex-row lg:items-stretch",children:[pe("div",{className:"flex min-w-0 items-center gap-2 rounded border bg-muted/40 px-3 py-2 lg:shrink-0",children:[G("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border bg-background",children:G(Nl,{className:"size-3.5"})}),pe("div",{className:"min-w-0",children:[G("p",{className:"text-sm font-medium",children:e}),G("p",{className:"truncate text-xs text-muted-foreground",children:t})]})]}),a.map((l,d)=>{let f=r(l.key),P=o(l.key),N=n===l.key,v=xn(P);return pe("div",{className:"flex min-w-0 items-stretch gap-2 lg:shrink-0",children:[G(vn,{className:"hidden size-4 shrink-0 self-center text-muted-foreground lg:block"}),pe(p,{variant:N?"secondary":"ghost",onClick:()=>i(l.key),"aria-pressed":N,className:io("h-auto w-full min-w-0 justify-start gap-2 border px-3 py-2 text-left lg:w-auto lg:min-w-40",N&&"border-primary"),children:[G("span",{className:io("flex size-6 shrink-0 items-center justify-center rounded-full border text-xs",Pl[f]),children:f==="done"?G(yl,{className:"size-3.5"}):f==="active"?G(wl,{className:"size-3.5 animate-spin"}):d+1}),pe("span",{className:"min-w-0 flex-1",children:[G("span",{className:"block text-sm font-medium",children:l.label}),pe("span",{className:"block text-xs tabular-nums text-muted-foreground",children:["输入 ",P.input," · 通过 ",G("span",{className:"text-emerald-600 dark:text-emerald-400",children:P.pass})," · 不通过"," ",P.fail," · 未完成 ",G("span",{className:io(P.todo>0&&"text-amber-600 dark:text-amber-400"),children:P.todo})]}),!v&&G("span",{className:"block text-xs text-amber-600 dark:text-amber-400",children:"数不平,正在执行中"})]})]})]},l.key)}),s&&pe("div",{className:"flex min-w-0 items-stretch gap-2 lg:shrink-0",children:[G(vn,{className:"hidden size-4 shrink-0 self-center text-muted-foreground lg:block"}),pe("div",{className:"flex min-w-0 items-center gap-2 rounded border bg-muted/40 px-3 py-2 lg:min-w-32",children:[G("span",{className:"flex size-6 shrink-0 items-center justify-center rounded-full border bg-background",children:s.icon}),pe("div",{className:"min-w-0",children:[G("p",{className:"text-sm font-medium",children:s.label}),G("p",{className:"text-xs tabular-nums text-muted-foreground",children:s.summary})]})]})]})]})}export{Ka as AgentPanel,Ua as AgentToggle,ls as AppShell,_a as AppSidebar,fs as AuthGate,Vs as ColumnPicker,ct as ComboInput,oo as ConfirmDialog,Ga as CreditsDialog,ao as DataPagination,Ns as DataTable,Gs as FilterPanel,Oa as Markdown,Mt as PAGE_SIZE,kl as StageProgress,pl as TaskCard,Cl as TaskLog,Za as ThemeColorPicker,vs as ThemeProvider,Qa as TimezoneSelect,Ya as UserMenu,sl as WordManager,xn as countsBalanced,xt as findNav};
|
package/dist/runtime/index.d.ts
CHANGED
|
@@ -238,6 +238,56 @@ declare function claimWorkflows<T extends IClaimableFlow>(params: {
|
|
|
238
238
|
*/
|
|
239
239
|
declare function isTriggerLinked(links: IRegisteredWorkflow[] | null, flowId: string | undefined): boolean | undefined;
|
|
240
240
|
|
|
241
|
+
/**
|
|
242
|
+
* 主题色预设(有限个,不提供自定义取色)。
|
|
243
|
+
* 色值的 CSS 变量在包根目录的 theme-color.css,这里只放名称与色块展示色;
|
|
244
|
+
* 不含 React,Server Component 也能用 THEME_COLOR_SCRIPT。
|
|
245
|
+
*/
|
|
246
|
+
declare const THEME_COLORS: readonly [{
|
|
247
|
+
readonly value: "orange";
|
|
248
|
+
readonly label: "活力橙";
|
|
249
|
+
readonly swatch: "#FB8C1E";
|
|
250
|
+
}, {
|
|
251
|
+
readonly value: "blue";
|
|
252
|
+
readonly label: "科技蓝";
|
|
253
|
+
readonly swatch: "#105BFF";
|
|
254
|
+
}, {
|
|
255
|
+
readonly value: "teal";
|
|
256
|
+
readonly label: "青绿";
|
|
257
|
+
readonly swatch: "#0D9488";
|
|
258
|
+
}, {
|
|
259
|
+
readonly value: "slate";
|
|
260
|
+
readonly label: "灰蓝";
|
|
261
|
+
readonly swatch: "#4F5A71";
|
|
262
|
+
}, {
|
|
263
|
+
readonly value: "ink";
|
|
264
|
+
readonly label: "墨黑";
|
|
265
|
+
readonly swatch: "#0C0C19";
|
|
266
|
+
}];
|
|
267
|
+
type ThemeColor = (typeof THEME_COLORS)[number]["value"];
|
|
268
|
+
declare const DEFAULT_THEME_COLOR: ThemeColor;
|
|
269
|
+
declare const THEME_COLOR_STORAGE_KEY = "linkfox:theme-color";
|
|
270
|
+
declare const THEME_COLOR_ATTRIBUTE = "data-theme-color";
|
|
271
|
+
declare const THEME_COLOR_MESSAGE_TYPE = "linkfox:theme-color";
|
|
272
|
+
/** 只接受白名单预设,其余(含被篡改的存储值)一律回到默认 */
|
|
273
|
+
declare function normalizeThemeColor(value: unknown): ThemeColor;
|
|
274
|
+
/**
|
|
275
|
+
* 把主题色写到 <html data-theme-color>。默认色也写属性:
|
|
276
|
+
* theme-color.css 的规则全挂在该属性上,没接入(未 import 样式 / 脚本未执行)时页面保持原样。
|
|
277
|
+
*/
|
|
278
|
+
declare function applyThemeColor(color: ThemeColor): void;
|
|
279
|
+
/**
|
|
280
|
+
* 页面嵌在 iframe 中时,把已确认的主题色通知给外层页面:
|
|
281
|
+
* `{ type: "linkfox:theme-color", value: "orange", color: "#FB8C1E" }`。
|
|
282
|
+
* 外层 origin 不固定且颜色不是敏感数据,targetOrigin 用 "*";外层应自行校验 event.origin。
|
|
283
|
+
*/
|
|
284
|
+
declare function postThemeColorToParent(color: ThemeColor): void;
|
|
285
|
+
/**
|
|
286
|
+
* hydrate 前执行的内联脚本(ThemeProvider 输出),避免刷新时先闪默认色。
|
|
287
|
+
* 与 applyThemeColor/normalizeThemeColor 逻辑保持一致。
|
|
288
|
+
*/
|
|
289
|
+
declare const THEME_COLOR_SCRIPT: string;
|
|
290
|
+
|
|
241
291
|
/**
|
|
242
292
|
* 浏览器直接调用服务,兼容静态导出。SSO token 存进 http 会话,由 SDK 自动放进
|
|
243
293
|
* ai-tools 请求的 Authorization;api-user-center 按 clientId 存进独立 localStorage 键,
|
|
@@ -245,4 +295,4 @@ declare function isTriggerLinked(links: IRegisteredWorkflow[] | null, flowId: st
|
|
|
245
295
|
*/
|
|
246
296
|
declare function initLinkfoxSdk(): void;
|
|
247
297
|
|
|
248
|
-
export { AGENT_MODELS, type AppKitConfig, CREDITS_RECHARGE_URL, type IClaimableFlow, type IRegisteredWorkflow, type IWorkflowClaim, LinkfoxError, SESSION_EXPIRED_MESSAGE, type TaskFile, type TaskStep, type TaskView, appKitConfig, cancelTask, claimWorkflows, configureAppKit, creditsError, creditsExhausted, currentNotebookId, errorMessage, fetchRemainingCredits, gateway, getApplicationId, getConfiguredApiKey, getShareUrl, initLinkfoxSdk, isAbortError, isApiKeyInvalid, isBalanceError, isMemberLimitError, isSessionExpired, isTriggerLinked, keyOf, listRegisteredWorkflows, recheckCredits, recordVisit, runTask, sleep, subscribeCreditsExhausted, withWorkflowKey };
|
|
298
|
+
export { AGENT_MODELS, type AppKitConfig, CREDITS_RECHARGE_URL, DEFAULT_THEME_COLOR, type IClaimableFlow, type IRegisteredWorkflow, type IWorkflowClaim, LinkfoxError, SESSION_EXPIRED_MESSAGE, THEME_COLORS, THEME_COLOR_ATTRIBUTE, THEME_COLOR_MESSAGE_TYPE, THEME_COLOR_SCRIPT, THEME_COLOR_STORAGE_KEY, type TaskFile, type TaskStep, type TaskView, type ThemeColor, appKitConfig, applyThemeColor, cancelTask, claimWorkflows, configureAppKit, creditsError, creditsExhausted, currentNotebookId, errorMessage, fetchRemainingCredits, gateway, getApplicationId, getConfiguredApiKey, getShareUrl, initLinkfoxSdk, isAbortError, isApiKeyInvalid, isBalanceError, isMemberLimitError, isSessionExpired, isTriggerLinked, keyOf, listRegisteredWorkflows, normalizeThemeColor, postThemeColorToParent, recheckCredits, recordVisit, runTask, sleep, subscribeCreditsExhausted, withWorkflowKey };
|
package/dist/runtime/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as ge,B as xe,C as ke,D as Ie,E as ye,a as h,b as C,c as R,d as $,e as F,f as L,g as j,h as v,i as A,j as J,k as p,l as re,m as oe,n as ne,o as ie,p as se,q as le,r as w,s as fe,t as ae,u as de,v as ce,w as me,x as ue,y as pe,z as we}from"../chunk-
|
|
1
|
+
import{A as ge,B as xe,C as ke,D as Ie,E as ye,F as be,G as Te,H as We,I as he,J as Ce,K as Re,L as $e,M as Fe,N as Le,a as h,b as C,c as R,d as $,e as F,f as L,g as j,h as v,i as A,j as J,k as p,l as re,m as oe,n as ne,o as ie,p as se,q as le,r as w,s as fe,t as ae,u as de,v as ce,w as me,x as ue,y as pe,z as we}from"../chunk-KG3655ZD.js";import{a as b,b as T,c as W,d as B,e as N,f as S,g as K,h as O,i as z,j as D,k as E,l as P,m as U,n as Y,o as I,p as _,q,r as G,s as H,t as M,u as Q,v as V,w as X,x as Z,y as ee,z as te}from"../chunk-WREK6TXJ.js";import*as g from"@linkfox-web/ai-tools/smart-table";var a=/key=([a-z0-9][a-z0-9-]*)/i;function y(e){let t=a.exec(e.description??"")?.[1];if(t)return t.toLowerCase();try{let r=JSON.parse(e.flowData??"{}");return a.exec(r.description??"")?.[1]?.toLowerCase()}catch{return}}function Se(e,t){if(a.test(e))return e;let r=e.trim();return r?`${r};key=${t}`:`key=${t}`}function Ke(){return w()?.config.notebookId||void 0}async function Oe(e){if(!e)return null;try{return((await p(g.listWorkflows({notebookId:e}))).workflows??[]).map(r=>({flowId:r.flowId,tableId:r.tableId??null}))}catch{return null}}function ze(e){let{notebookId:t,names:r,flows:x,links:d}=e,c=d?new Set(d.map(n=>n.flowId)):null,i={};for(let[n,s]of Object.entries(r)){let k=t?`${s} (${t})`:s,m=o=>o.name===k,u=x.filter(o=>(c?.has(o.id)??!1)||m(o)),l=u.filter(o=>y(o)===n.toLowerCase());if(l.length){i[n]={key:n,flow:l[0],matchedBy:"key",duplicates:l.slice(1)};continue}let f=u.filter(o=>m(o)||(c&&t&&o.name.startsWith(`${s} (`))===!0);i[n]=f.length?{key:n,flow:f[0],matchedBy:"name",duplicates:f.slice(1)}:{key:n,duplicates:[]}}return i}function De(e,t){if(!(!e||!t))return e.some(r=>r.flowId===t)}import{cn as et}from"cn";export{re as AGENT_MODELS,h as CREDITS_RECHARGE_URL,Te as DEFAULT_THEME_COLOR,S as LinkfoxError,B as SESSION_EXPIRED_MESSAGE,be as THEME_COLORS,he as THEME_COLOR_ATTRIBUTE,Ce as THEME_COLOR_MESSAGE_TYPE,Le as THEME_COLOR_SCRIPT,We as THEME_COLOR_STORAGE_KEY,ge as WORD_FIELDS,xe as WORD_KIND_LABEL,we as WORD_STATUS,w as activeSmartTable,Ie as activeWordTables,T as appKitConfig,$e as applyThemeColor,de as attachmentUrl,H as authIdentity,ye as buildWordMatcher,oe as cancelTask,ze as claimWorkflows,et as cn,b as configureAppKit,se as createSmartTable,ke as createWordTables,$ as creditsError,R as creditsExhausted,Ke as currentNotebookId,E as errorMessage,C as fetchRemainingCredits,j as filterKeys,J as findNav,ae as firstAttachment,v as flagList,p as gateway,te as getApiKey,U as getApplicationId,q as getAuthState,W as getConfiguredApiKey,ne as getShareUrl,Z as handleGatewayError,I as initLinkfoxSdk,G as initialAuthState,K as isAbortError,D as isApiKeyInvalid,fe as isAttachmentList,O as isBalanceError,z as isMemberLimitError,N as isSessionExpired,De as isTriggerLinked,y as keyOf,Oe as listRegisteredWorkflows,Q as loadApiKey,V as login,X as logout,ee as maskApiKey,Re as normalizeThemeColor,pe as nowIso,me as num,Fe as postThemeColorToParent,L as recheckCredits,Y as recordVisit,ie as runTask,le as setActiveSmartTable,P as sleep,ue as splitList,M as startAuth,ce as str,_ as subscribeAuth,F as subscribeCreditsExhausted,A as toggleFlag,Se as withWorkflowKey};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linkfox-web/app-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "LinkFox 应用模板公共运行时与组件:登录门禁、多维表客户端、列表/筛选/任务组件、LinkFox OS 助手",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
13
|
-
"styles.css"
|
|
13
|
+
"styles.css",
|
|
14
|
+
"theme-color.css"
|
|
14
15
|
],
|
|
15
16
|
"dependencies": {
|
|
16
17
|
"cn": "0.4.0"
|
|
@@ -27,9 +28,9 @@
|
|
|
27
28
|
"react-markdown": "^10.1.0",
|
|
28
29
|
"remark-gfm": "^4.0.1",
|
|
29
30
|
"sonner": "^2.0.8",
|
|
30
|
-
"@linkfox-web/ai-tools": "^0.4.
|
|
31
|
-
"@linkfox-web/
|
|
32
|
-
"@linkfox-web/
|
|
31
|
+
"@linkfox-web/ai-tools": "^0.4.2",
|
|
32
|
+
"@linkfox-web/http": "^0.3.13",
|
|
33
|
+
"@linkfox-web/api-user-center": "^0.3.13"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"@types/react": "19.3.0",
|
|
@@ -45,9 +46,9 @@
|
|
|
45
46
|
"react-markdown": "10.1.0",
|
|
46
47
|
"remark-gfm": "4.0.1",
|
|
47
48
|
"sonner": "2.0.8",
|
|
48
|
-
"@linkfox-web/ai-tools": "0.4.
|
|
49
|
-
"@linkfox-web/
|
|
50
|
-
"@linkfox-web/
|
|
49
|
+
"@linkfox-web/ai-tools": "0.4.2",
|
|
50
|
+
"@linkfox-web/http": "0.3.13",
|
|
51
|
+
"@linkfox-web/api-user-center": "0.3.13"
|
|
51
52
|
},
|
|
52
53
|
"publishConfig": {
|
|
53
54
|
"access": "public"
|
|
@@ -70,7 +71,8 @@
|
|
|
70
71
|
"types": "./dist/components/index.d.ts",
|
|
71
72
|
"default": "./dist/components/index.js"
|
|
72
73
|
},
|
|
73
|
-
"./styles.css": "./styles.css"
|
|
74
|
+
"./styles.css": "./styles.css",
|
|
75
|
+
"./theme-color.css": "./theme-color.css"
|
|
74
76
|
},
|
|
75
77
|
"typesVersions": {
|
|
76
78
|
"*": {
|
package/theme-color.css
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* 主题色(右上角「主题色配置」,见 src/runtime/theme-color.ts)。
|
|
3
|
+
* 宿主在 app/globals.css 里 `@import "@linkfox-web/app-kit/theme-color.css";`。
|
|
4
|
+
*
|
|
5
|
+
* 所有规则都挂在 <html data-theme-color="…"> 上(ThemeProvider 的内联脚本在 hydrate 前写入,默认 ink 也写),
|
|
6
|
+
* 没接入时页面完全沿用宿主自己的 :root / .dark 变量。选择器特异性都高于宿主的 :root / .dark,
|
|
7
|
+
* 因此本文件在宿主变量之前 import 也能生效。
|
|
8
|
+
*
|
|
9
|
+
* 每个预设只给 oklch 的 L/C/H,其余变量统一推导:
|
|
10
|
+
* 亮色模式 L/C/H 即设计稿色值(注释中的 hex)换算的 oklch,前景统一白字;暗色模式主色提亮、前景转深字。
|
|
11
|
+
*/
|
|
12
|
+
:root[data-theme-color="orange"] { /* #FB8C1E */
|
|
13
|
+
--brand-l: 0.746; --brand-c: 0.172; --brand-h: 57.5;
|
|
14
|
+
--brand-l-dark: 0.76; --brand-c-dark: 0.16; --brand-h-dark: 57.5;
|
|
15
|
+
}
|
|
16
|
+
:root[data-theme-color="blue"] { /* #105BFF */
|
|
17
|
+
--brand-l: 0.545; --brand-c: 0.252; --brand-h: 262.9;
|
|
18
|
+
--brand-l-dark: 0.7; --brand-c-dark: 0.16; --brand-h-dark: 262.9;
|
|
19
|
+
}
|
|
20
|
+
:root[data-theme-color="teal"] { /* #0D9488 */
|
|
21
|
+
--brand-l: 0.6; --brand-c: 0.104; --brand-h: 184.7;
|
|
22
|
+
--brand-l-dark: 0.72; --brand-c-dark: 0.11; --brand-h-dark: 184.7;
|
|
23
|
+
}
|
|
24
|
+
:root[data-theme-color="slate"] { /* #4F5A71 */
|
|
25
|
+
--brand-l: 0.467; --brand-c: 0.04; --brand-h: 264.9;
|
|
26
|
+
--brand-l-dark: 0.78; --brand-c-dark: 0.04; --brand-h-dark: 264.9;
|
|
27
|
+
}
|
|
28
|
+
:root[data-theme-color="ink"] { /* #0C0C19;暗色模式沿用原中性浅灰主色 */
|
|
29
|
+
--brand-l: 0.162; --brand-c: 0.027; --brand-h: 282.9;
|
|
30
|
+
--brand-l-dark: 0.922; --brand-c-dark: 0.01; --brand-h-dark: 282.9;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:root[data-theme-color] {
|
|
34
|
+
--primary: oklch(var(--brand-l) var(--brand-c) var(--brand-h));
|
|
35
|
+
--primary-foreground: oklch(0.985 0 0);
|
|
36
|
+
--ring: oklch(0.7 calc(var(--brand-c) * 0.6) var(--brand-h));
|
|
37
|
+
--chart-1: oklch(0.82 calc(var(--brand-c) * 0.6) var(--brand-h));
|
|
38
|
+
--chart-2: oklch(0.7 calc(var(--brand-c) * 0.85) var(--brand-h));
|
|
39
|
+
--chart-3: oklch(var(--brand-l) var(--brand-c) var(--brand-h));
|
|
40
|
+
--chart-4: oklch(0.45 calc(var(--brand-c) * 0.85) var(--brand-h));
|
|
41
|
+
--chart-5: oklch(0.36 calc(var(--brand-c) * 0.7) var(--brand-h));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/*
|
|
45
|
+
* 亮色模式侧栏:整栏铺主色,白字;选中/悬停为白色半透明块,logo 反白。
|
|
46
|
+
*/
|
|
47
|
+
:root[data-theme-color]:not(.dark) {
|
|
48
|
+
--sidebar: var(--primary);
|
|
49
|
+
--sidebar-foreground: oklch(1 0 0);
|
|
50
|
+
--sidebar-primary: oklch(1 0 0);
|
|
51
|
+
--sidebar-primary-foreground: var(--primary);
|
|
52
|
+
--sidebar-accent: oklch(1 0 0 / 20%);
|
|
53
|
+
--sidebar-accent-foreground: oklch(1 0 0);
|
|
54
|
+
--sidebar-border: oklch(1 0 0 / 15%);
|
|
55
|
+
--sidebar-ring: oklch(1 0 0 / 60%);
|
|
56
|
+
}
|
|
57
|
+
/* 侧栏内的次要文字(副标题、版本号)与描边改为白色半透明,避免灰字压在主色上 */
|
|
58
|
+
:root[data-theme-color]:not(.dark) [data-sidebar="sidebar"] {
|
|
59
|
+
--muted-foreground: oklch(1 0 0 / 75%);
|
|
60
|
+
--border: oklch(1 0 0 / 35%);
|
|
61
|
+
}
|
|
62
|
+
/* 子菜单不显示左侧竖线;展开的菜单组只高亮选中的子项,组标题不铺底(收起为图标时仍高亮组) */
|
|
63
|
+
:root[data-theme-color]:not(.dark) [data-sidebar="menu-sub"] {
|
|
64
|
+
border-color: transparent;
|
|
65
|
+
}
|
|
66
|
+
:root[data-theme-color]:not(.dark) :not([data-collapsible="icon"]) > * > [data-sidebar="sidebar"] [data-sidebar="menu-button"][data-active="true"][data-state="open"]:not(:hover) {
|
|
67
|
+
background-color: transparent;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/* 暗色模式:主色提亮、前景转深,侧栏为同色相深色栏 */
|
|
71
|
+
:root.dark[data-theme-color] {
|
|
72
|
+
--primary: oklch(var(--brand-l-dark) var(--brand-c-dark) var(--brand-h-dark));
|
|
73
|
+
--primary-foreground: oklch(0.145 0 0);
|
|
74
|
+
--ring: oklch(0.55 calc(var(--brand-c-dark) * 0.7) var(--brand-h-dark));
|
|
75
|
+
--chart-1: oklch(0.85 calc(var(--brand-c-dark) * 0.6) var(--brand-h-dark));
|
|
76
|
+
--chart-2: oklch(var(--brand-l-dark) var(--brand-c-dark) var(--brand-h-dark));
|
|
77
|
+
--chart-3: oklch(0.62 var(--brand-c-dark) var(--brand-h-dark));
|
|
78
|
+
--chart-4: oklch(0.52 calc(var(--brand-c-dark) * 0.9) var(--brand-h-dark));
|
|
79
|
+
--chart-5: oklch(0.42 calc(var(--brand-c-dark) * 0.8) var(--brand-h-dark));
|
|
80
|
+
--sidebar: oklch(0.2 calc(var(--brand-c-dark) * 0.12) var(--brand-h-dark));
|
|
81
|
+
--sidebar-foreground: oklch(0.985 0 0);
|
|
82
|
+
--sidebar-primary: var(--primary);
|
|
83
|
+
--sidebar-primary-foreground: var(--primary-foreground);
|
|
84
|
+
--sidebar-accent: oklch(0.29 calc(var(--brand-c-dark) * 0.25) var(--brand-h-dark));
|
|
85
|
+
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
86
|
+
--sidebar-border: oklch(1 0 0 / 10%);
|
|
87
|
+
--sidebar-ring: var(--ring);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
* 「让LinkFox帮你干活」打开的 LinkFox OS 面板:底色为主题色 10%。
|
|
92
|
+
* 用 color-mix 叠在页面底色上得到不透明色——移动端面板全屏覆盖内容,真透明会透出下面的页面。
|
|
93
|
+
*/
|
|
94
|
+
:root[data-theme-color] [data-slot="agent-panel"] {
|
|
95
|
+
background-color: color-mix(in oklab, var(--primary) 10%, var(--background));
|
|
96
|
+
}
|
|
97
|
+
/* 面板里的输入框保持页面底色(亮色模式为白色),不跟着面板染色 */
|
|
98
|
+
:root[data-theme-color] [data-slot="agent-panel"] textarea {
|
|
99
|
+
background-color: var(--background);
|
|
100
|
+
}
|
package/dist/chunk-Q7ASIOYP.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{f as W,g as B,h as K,j as U,l as M,s as D,x as O}from"./chunk-WREK6TXJ.js";import{clearCreditsExhausted as Q,getCreditsError as Z,getRemainingCredits as J,isCreditsExhausted as ee,onCreditsExhausted as te}from"@linkfox-web/ai-tools/account";var Re="https://ai.linkfox.com/usercenter/pricing?tab=ai&plan=personalYearly";async function ne(){try{let{totalRemainingCredits:e}=await J();return Number.isFinite(e)?e:void 0}catch{return}}function Se(){return ee()}function Ee(){return Z()}function Ne(e){return te(()=>e())}async function Ae(){let e=await ne();return e!==void 0&&e>0&&Q(),e}function Le(e){return e.type==="range"||e.type==="dateRange"?[`${e.id}.gte`,`${e.id}.lte`]:[e.id]}function re(e){return(e??"").split(",").map(t=>t.trim()).filter(Boolean)}function Fe(e,t,o){let n=re(e).filter(a=>a!==t);return o&&n.push(t),n.join(",")}function Oe(e,t){for(let o of e){let n=o.items.find(a=>t===a.href||t.startsWith(`${a.href}/`));if(n)return{group:o,item:n}}return null}async function L(e){try{return await e}catch(t){throw O(t),t}}import*as y from"@linkfox-web/ai-tools/agent-os";var se=2500,oe=5,ie=3,Be=[{id:"default",name:"通用助手"},{id:"linkfox-product-selection-agent",name:"选品 Agent"},{id:"linkfox-market-analysis-agent",name:"市场分析 Agent"},{id:"linkfox-listing-agent",name:"Listing Agent"},{id:"linkfox-image-agent",name:"图片 Agent"},{id:"linkfox-video-agent",name:"视频 Agent"}],ae={read:"读取文件",execute:"执行命令",edit:"编辑文件",search:"搜索"},G=e=>e?.type==="text"||e?.type===void 0?e?.text??e?.value??"":"";function le(e){return e.type!=="resource_link"||!e.uri?null:{name:decodeURIComponent(e.uri.split("?")[0].split("/").pop()??"")||e.name||"文件",uri:e.uri}}function ce(e){let t=new Map,o="";return e.forEach((n,a)=>{if(n.sessionUpdate==="tool_call"||n.sessionUpdate==="tool_call_update"){let d=n.toolCallId??`step-${a}`,b=t.get(d),h=n.title?.replace(/\(.*\)$/,"")||b?.title||ae[n.kind??""]||"处理中",T=n.status==="completed"?"done":n.status==="failed"?"failed":b?.status??"running";t.set(d,{id:d,title:h,status:T})}else(n.sessionUpdate==="agent_message_chunk"||n.sessionUpdate==null)&&(o+=G(n.content))}),{steps:[...t.values()],text:o}}function de(e){let t="",o=new Map;for(let{content:n}of e){if(!n)continue;let a=le(n);a?o.set(a.uri,a):t+=G(n)}return{text:t,files:[...o.values()]}}function Ke(e){return L(y.cancelTask({messageId:e}))}async function Ue(e){try{return(await L(y.getShareUrl({messageId:e}))).shareUrl||void 0}catch{return}}async function Me(e,t,{signal:o,onUpdate:n,sessionId:a}){let d=await L(y.createTask(a?{prompt:e,modelId:t,sessionId:a}:{prompt:e,modelId:t},{signal:o}));if(!d.id)throw new W(500,"LinkFox OS 没有返回任务 ID");let b=d.id,h=d.sessionId||a||"";n({messageId:b,sessionId:h,steps:[],text:"",files:[],stopReason:""});let T=new Map,w=0,E=0;for(;;){await M(se,o);let F=Math.max(0,w-oe),I;try{I=await L(y.getTask({messageId:b,fromIndex:F},{signal:o})),E=0}catch(g){if(B(g)||U(g)||K(g)||++E>=ie)throw g;continue}I.eventList?.forEach((g,R)=>T.set(F+R,g)),w=I.eventTotal??w;let _=[...T.entries()].sort((g,R)=>g[0]-R[0]).map(([,g])=>g),N=ce(_),v=I.message?.stopReason??"";if(v){let g=de(I.message?.agentMessageChunks??[]),R=N.steps.map(C=>C.status==="running"?{...C,status:"done"}:C);return{messageId:b,sessionId:h,steps:R,text:g.text||N.text,files:g.files,stopReason:v}}n({messageId:b,sessionId:h,steps:N.steps,text:N.text,files:[],stopReason:""})}}import{LinkfoxHttpError as fe}from"@linkfox-web/http";import*as u from"@linkfox-web/ai-tools/smart-table";function A(e,t){return new fe({service:"ai-tools",status:200,code:e,message:t})}var H=(e,t)=>(e.createdTime??"").localeCompare(t.createdTime??""),j=e=>Object.fromEntries(e.map(t=>[t.name,t.fieldId]));function V(e,t,o){let n=e.get(t);return n||(n=o(),e.set(t,n),n.catch(()=>e.delete(t))),n}function ue(){return typeof window>"u"?!1:/(^|\.)app\.linkfox\.com$/.test(window.location.hostname)}var pe=new Set(["主图"]);function Ve(e){let t=e.fields??{},o=new Map,n=new Map,a=new Map;async function d(s){try{return await s}catch(i){throw O(i),i}}async function b(s){let i=[];for(let r=1;r<=50;r++){let c=await d(u[s]({page:r,perPage:100})),l=c.notebooks??[];if(i.push(...l),l.length===0||i.length>=(c.total??0))break}return i}async function h(){let{notebookId:s,notebookName:i}=e,r=await b("listMyTables");if(s){let x=r.find(k=>k.notebookId===s)??(await b("listSharedTables")).find(k=>k.notebookId===s);if(!x)throw A(404,`找不到配置的多维表 ${s},请检查 .env 的 NEXT_PUBLIC_NOTE_BOOK_ID 或 linkfox.config.ts`);return x}if(ue())throw A(500,"应用未绑定多维表(缺少 NEXT_PUBLIC_NOTE_BOOK_ID)。请重新打开应用完成初始化后再试。");let c=r.filter(x=>x.name===i).sort(H);if(c.length)return c[0];let l=(await b("listSharedTables")).filter(x=>x.name===i).sort(H);if(l.length)return l[0];let m=e.requestKeyPrefix??"linkfox-app",p=await d(u.createTable({name:i,requestKey:`${m}-${i}`}));return{notebookId:p.notebookId,name:p.notebookName,tables:[{tableId:p.tableId,name:p.name,url:p.url,refKey:p.refKey}]}}function T(){return V(o,D(),h)}function w(s,i){return V(n,`${D()}:${s}`,async()=>{let r=i??t[s];if(!r)throw A(500,`数据表 ${String(s)} 没有登记列定义,请在 linkfox.config.ts 的 smartTableConfig.fields 里补上`);let c=e.tables[s];if(!c)throw A(500,`数据表 ${String(s)} 没有登记表名,请在 smartTableConfig.tables 里补上`);let l=await T(),m=l.tables.find(f=>f.name===c);if(!m){let f=await d(u.addTable({notebookId:l.notebookId,name:c,fields:r})),S={tableId:f.tableId,name:f.name,url:f.url,refKey:f.refKey};return l.tables.push(S),{...S,fieldIds:j(f.fields??[])}}let{fields:p}=await d(u.listFields({tableId:m.tableId,includeChoices:!1})),x=r.filter(f=>pe.has(f.name)&&p.some(S=>S.name===f.name&&S.type!==f.type)),k=p;if(x.length){let f=x.map(P=>P.name);k=(await d(u.deleteFields({tableId:m.tableId,fieldNames:f,allowBreakingDependents:!0}))).fields??p.filter(P=>!f.includes(P.name))}let z=new Set(k.map(f=>f.name)),$=r.filter(f=>!z.has(f.name));for(let f=0;f<$.length;f+=50)k=(await d(u.addFields({tableId:m.tableId,fields:$.slice(f,f+50)}))).fields??k;return{...m,fieldIds:j(k)}})}function E(s){return d(u.listRecords(s))}async function F(s,i=100){let r=[];for(let c=1;c<=i;c++){let l=await E({...s,page:c,perPage:100});if(r.push(...l.records),l.records.length<100||r.length>=l.total)break}return r}async function I(s,i){let r=[];for(let c=0;c<i.length;c+=50){let l=i.slice(c,c+50),m=await d(u.createRecords({tableId:s,records:l.map(p=>({fields:p}))}));if(r.push(...m.records??[]),m.created!==l.length)throw A(500,`已写入 ${r.length} 条,但有 ${l.length-m.created} 条未写入成功`)}return r}async function _(s,i){for(let r=0;r<i.length;r+=100){let c=i.slice(r,r+100),l=await d(u.updateRecords({tableId:s,records:c}));if(l.updated!==c.length)throw A(404,`只更新了 ${l.updated}/${c.length} 条,记录可能已被删除,请刷新后重试`)}}async function N(s,i){for(let r=0;r<i.length;r+=100)await d(u.deleteRecords({tableId:s,recordIds:i.slice(r,r+100)}))}function v(s,i,r,c){let l=`${s}:${i}:${r}`,p=(a.get(l)??Promise.resolve()).catch(()=>{}).then(()=>d(u.uploadAttachment({tableId:s,recordId:i,fieldName:r,imageUrl:c})).then(x=>x.attachment));return a.set(l,p),p.finally(()=>{a.get(l)===p&&a.delete(l)}).catch(()=>{}),p}async function g(s,i,r,c,l){return(await E({tableId:s,perPage:100,fieldNames:l,filter:{conditions:[{fieldName:i,operator:"is",value:r}]}})).records.find(p=>p.recordId===c)??null}function R(){return Promise.all(Object.keys(t).map(s=>w(s)))}async function C(s){return(await w(s)).tableId}return{config:e,TABLE_FIELDS:t,getNotebook:T,ensureTable:w,listRecords:E,listAllRecords:F,createRecords:I,updateRecords:_,deleteRecords:N,uploadAttachment:v,getRecord:g,warmTables:R,tableIdOf:C}}var q;function qe(e){q=e}function X(){return q}function ge(e){return Array.isArray(e)&&e.every(t=>t&&typeof t=="object"&&"token"in t)}function me(e){return ge(e)?e[0]:void 0}function Xe(e,t="full"){let o=me(e);return o&&(t==="thumb"?o.smThumbnailUrl??o.lgThumbnailUrl??o.presignedUrl:o.presignedUrl)||void 0}var be=e=>e==null?"":typeof e=="string"?e:String(e),Ye=e=>typeof e=="number"?e:Number(e)||0,ze=e=>be(e).split(/[,,、\n]/).map(t=>t.trim()).filter(Boolean),Qe=()=>new Date().toISOString();var he=["启用","禁用"],xe=[{name:"词条",type:"singleLineText"},{name:"中文名",type:"singleLineText"},{name:"状态",type:"singleSelect",choices:he.map(e=>({name:e}))},{name:"来源",type:"singleLineText"},{name:"创建时间",type:"date"}],ke={brandWords:"品牌词",sensitiveWords:"敏感词"},ye=Object.keys(ke);function Te(e){function t(n){return e.ensureTable(n,xe)}async function o(){return(await Promise.all(ye.map(async a=>{let{tableId:d}=await t(a);return(await e.listAllRecords({tableId:d,fieldNames:["词条"],filter:{conditions:[{fieldName:"状态",operator:"is",value:"启用"}]}})).map(h=>String(h.fields.词条??"").trim()).filter(Boolean).map(h=>({word:h,kind:a}))}))).flat()}return{ensureWordTable:t,loadActiveWords:o}}function et(){let e=X();if(!e)throw new Error("多维表客户端尚未初始化:请确认模板的 lib/app-kit.ts 调用了 setActiveSmartTable(smartTable)");return Te(e)}var we=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Y=/[A-Za-z0-9]/;function tt(e){let t=e.map(o=>{let n=o.word.replace(/\s+/g," "),a=Y.test(n[0])?"(?<![\\p{L}\\p{N}])":"",d=Y.test(n[n.length-1])?"(?![\\p{L}\\p{N}])":"";return{hit:o,re:new RegExp(`${a}${we(n).replace(/ /g,"\\s+")}${d}`,"iu")}});return o=>{let n=o.filter(Boolean).join(`
|
|
2
|
-
`);return t.filter(a=>a.re.test(n)).map(a=>a.hit)}}export{Re as a,ne as b,Se as c,Ee as d,Ne as e,Ae as f,Le as g,re as h,Fe as i,Oe as j,L as k,Be as l,Ke as m,Ue as n,Me as o,Ve as p,qe as q,X as r,ge as s,me as t,Xe as u,be as v,Ye as w,ze as x,Qe as y,he as z,xe as A,ke as B,Te as C,et as D,tt as E};
|