@web-mods/articles 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/components/ArticleGuidesSettings.d.ts +12 -0
- package/dist/components/ItemOrderEditor.d.ts +12 -0
- package/dist/components/ParentNavigationOrder.d.ts +9 -0
- package/dist/components/ui/SettingsDialog.d.ts +9 -0
- package/dist/index.cjs +54 -39
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1923 -1467
- package/dist/server.cjs +3 -3
- package/dist/server.d.ts +2 -1
- package/dist/server.js +58 -35
- package/dist/style.css +1 -1
- package/dist/types.d.ts +40 -0
- package/dist/utils/resolveGuidesDisplay.d.ts +7 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,161 +1,176 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),pe=require("./server.cjs"),me=require("react-router"),ct=require("react-dom"),We=a.createContext({navigate:()=>{},params:{},locationState:null});function Ve(){return a.useContext(We)}let le=[];const Ae=new Set;function Ze(){Ae.forEach(t=>t([...le]))}function Oe(t,r){const n=Math.random().toString(36).slice(2);le=[...le,{id:n,type:t,content:r}],Ze(),setTimeout(()=>{le=le.filter(s=>s.id!==n),Ze()},3e3)}const te={success:t=>Oe("success",t),error:t=>Oe("error",t),warning:t=>Oe("warning",t)};function _t(t){return Ae.add(t),()=>{Ae.delete(t)}}function Tt(){return le}const zt={success:"bg-emerald-500",error:"bg-red-500",warning:"bg-amber-500"},At={success:"✓",error:"✕",warning:"⚠"};function Rt(){const[t,r]=a.useState(Tt());return a.useEffect(()=>_t(r),[]),t.length===0?null:e.jsx("div",{className:"fixed top-4 right-4 z-[9999] flex flex-col gap-2 pointer-events-none",children:t.map(n=>e.jsxs("div",{className:`flex items-center gap-2 px-4 py-2.5 rounded-lg shadow-lg text-sm text-white font-medium pointer-events-auto ${zt[n.type]}`,children:[e.jsx("span",{className:"shrink-0 font-bold",children:At[n.type]}),n.content]},n.id))})}const lt=a.createContext(null);function Ht({children:t,basePath:r,service:n=pe.defaultArticleService,previewBaseUrl:s,previewTailwind:c,navigate:d}){const h=e.jsxs(lt.Provider,{value:{basePath:r,service:n,previewBaseUrl:s,previewTailwind:c},children:[t,e.jsx(Rt,{})]});return d?e.jsx(We.Provider,{value:{navigate:d,params:{},locationState:null},children:h}):h}function $e(){const t=a.useContext(lt);if(!t)throw new Error("useArticlesConfig must be used within ArticlesProvider");return t}function Gt({children:t}){const r=me.useNavigate(),n=me.useParams(),s=me.useLocation(),{basePath:c}=$e(),d=c.replace(/\/+$/,""),h=me.useMatch(`${d}/:id/edit`),x=me.useMatch(`${d}/:id/detail`),u=h??x;return e.jsx(We.Provider,{value:{navigate:(y,g)=>r(y,g),params:{...n,...u==null?void 0:u.params},locationState:s.state},children:t})}/**
|
|
2
2
|
* @license lucide-react v1.11.0 - ISC
|
|
3
3
|
*
|
|
4
4
|
* This source code is licensed under the ISC license.
|
|
5
5
|
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const
|
|
6
|
+
*/const dt=(...t)=>t.filter((r,n,s)=>!!r&&r.trim()!==""&&s.indexOf(r)===n).join(" ").trim();/**
|
|
7
7
|
* @license lucide-react v1.11.0 - ISC
|
|
8
8
|
*
|
|
9
9
|
* This source code is licensed under the ISC license.
|
|
10
10
|
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const
|
|
11
|
+
*/const Wt=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
12
12
|
* @license lucide-react v1.11.0 - ISC
|
|
13
13
|
*
|
|
14
14
|
* This source code is licensed under the ISC license.
|
|
15
15
|
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const
|
|
16
|
+
*/const Vt=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,n,s)=>s?s.toUpperCase():n.toLowerCase());/**
|
|
17
17
|
* @license lucide-react v1.11.0 - ISC
|
|
18
18
|
*
|
|
19
19
|
* This source code is licensed under the ISC license.
|
|
20
20
|
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const
|
|
21
|
+
*/const Je=t=>{const r=Vt(t);return r.charAt(0).toUpperCase()+r.slice(1)};/**
|
|
22
22
|
* @license lucide-react v1.11.0 - ISC
|
|
23
23
|
*
|
|
24
24
|
* This source code is licensed under the ISC license.
|
|
25
25
|
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/var
|
|
26
|
+
*/var Pe={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
27
27
|
* @license lucide-react v1.11.0 - ISC
|
|
28
28
|
*
|
|
29
29
|
* This source code is licensed under the ISC license.
|
|
30
30
|
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const
|
|
31
|
+
*/const qt=t=>{for(const r in t)if(r.startsWith("aria-")||r==="role"||r==="title")return!0;return!1},Yt=a.createContext({}),Ft=()=>a.useContext(Yt),Bt=a.forwardRef(({color:t,size:r,strokeWidth:n,absoluteStrokeWidth:s,className:c="",children:d,iconNode:h,...x},u)=>{const{size:y=24,strokeWidth:g=2,absoluteStrokeWidth:w=!1,color:L="currentColor",className:T=""}=Ft()??{},z=s??w?Number(n??g)*24/Number(r??y):n??g;return a.createElement("svg",{ref:u,...Pe,width:r??y??Pe.width,height:r??y??Pe.height,stroke:t??L,strokeWidth:z,className:dt("lucide",T,c),...!d&&!qt(x)&&{"aria-hidden":"true"},...x},[...h.map(([H,W])=>a.createElement(H,W)),...Array.isArray(d)?d:[d]])});/**
|
|
32
32
|
* @license lucide-react v1.11.0 - ISC
|
|
33
33
|
*
|
|
34
34
|
* This source code is licensed under the ISC license.
|
|
35
35
|
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const
|
|
36
|
+
*/const B=(t,r)=>{const n=a.forwardRef(({className:s,...c},d)=>a.createElement(Bt,{ref:d,iconNode:r,className:dt(`lucide-${Wt(Je(t))}`,`lucide-${t}`,s),...c}));return n.displayName=Je(t),n};/**
|
|
37
37
|
* @license lucide-react v1.11.0 - ISC
|
|
38
38
|
*
|
|
39
39
|
* This source code is licensed under the ISC license.
|
|
40
40
|
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const
|
|
41
|
+
*/const Ut=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Kt=B("arrow-down",Ut);/**
|
|
42
42
|
* @license lucide-react v1.11.0 - ISC
|
|
43
43
|
*
|
|
44
44
|
* This source code is licensed under the ISC license.
|
|
45
45
|
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const
|
|
46
|
+
*/const Zt=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],ut=B("arrow-left",Zt);/**
|
|
47
47
|
* @license lucide-react v1.11.0 - ISC
|
|
48
48
|
*
|
|
49
49
|
* This source code is licensed under the ISC license.
|
|
50
50
|
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const
|
|
51
|
+
*/const Jt=[["path",{d:"m21 16-4 4-4-4",key:"f6ql7i"}],["path",{d:"M17 20V4",key:"1ejh1v"}],["path",{d:"m3 8 4-4 4 4",key:"11wl7u"}],["path",{d:"M7 4v16",key:"1glfcx"}]],mt=B("arrow-up-down",Jt);/**
|
|
52
52
|
* @license lucide-react v1.11.0 - ISC
|
|
53
53
|
*
|
|
54
54
|
* This source code is licensed under the ISC license.
|
|
55
55
|
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const
|
|
56
|
+
*/const Xt=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],Qt=B("arrow-up",Xt);/**
|
|
57
57
|
* @license lucide-react v1.11.0 - ISC
|
|
58
58
|
*
|
|
59
59
|
* This source code is licensed under the ISC license.
|
|
60
60
|
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const
|
|
61
|
+
*/const er=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],xt=B("check",er);/**
|
|
62
62
|
* @license lucide-react v1.11.0 - ISC
|
|
63
63
|
*
|
|
64
64
|
* This source code is licensed under the ISC license.
|
|
65
65
|
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const
|
|
66
|
+
*/const tr=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],rr=B("chevron-down",tr);/**
|
|
67
67
|
* @license lucide-react v1.11.0 - ISC
|
|
68
68
|
*
|
|
69
69
|
* This source code is licensed under the ISC license.
|
|
70
70
|
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const
|
|
71
|
+
*/const nr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],sr=B("circle-alert",nr);/**
|
|
72
72
|
* @license lucide-react v1.11.0 - ISC
|
|
73
73
|
*
|
|
74
74
|
* This source code is licensed under the ISC license.
|
|
75
75
|
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const
|
|
76
|
+
*/const ar=[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]],qe=B("code",ar);/**
|
|
77
77
|
* @license lucide-react v1.11.0 - ISC
|
|
78
78
|
*
|
|
79
79
|
* This source code is licensed under the ISC license.
|
|
80
80
|
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const
|
|
81
|
+
*/const ir=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],or=B("copy",ir);/**
|
|
82
82
|
* @license lucide-react v1.11.0 - ISC
|
|
83
83
|
*
|
|
84
84
|
* This source code is licensed under the ISC license.
|
|
85
85
|
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const
|
|
86
|
+
*/const cr=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],lr=B("external-link",cr);/**
|
|
87
87
|
* @license lucide-react v1.11.0 - ISC
|
|
88
88
|
*
|
|
89
89
|
* This source code is licensed under the ISC license.
|
|
90
90
|
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const
|
|
91
|
+
*/const dr=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Re=B("eye",dr);/**
|
|
92
92
|
* @license lucide-react v1.11.0 - ISC
|
|
93
93
|
*
|
|
94
94
|
* This source code is licensed under the ISC license.
|
|
95
95
|
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const
|
|
96
|
+
*/const ur=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],mr=B("file-text",ur);/**
|
|
97
97
|
* @license lucide-react v1.11.0 - ISC
|
|
98
98
|
*
|
|
99
99
|
* This source code is licensed under the ISC license.
|
|
100
100
|
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const
|
|
101
|
+
*/const xr=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],Xe=B("grip-vertical",xr);/**
|
|
102
102
|
* @license lucide-react v1.11.0 - ISC
|
|
103
103
|
*
|
|
104
104
|
* This source code is licensed under the ISC license.
|
|
105
105
|
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const
|
|
106
|
+
*/const hr=[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]],fr=B("inbox",hr);/**
|
|
107
107
|
* @license lucide-react v1.11.0 - ISC
|
|
108
108
|
*
|
|
109
109
|
* This source code is licensed under the ISC license.
|
|
110
110
|
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const
|
|
111
|
+
*/const gr=[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}]],pr=B("layout-panel-top",gr);/**
|
|
112
112
|
* @license lucide-react v1.11.0 - ISC
|
|
113
113
|
*
|
|
114
114
|
* This source code is licensed under the ISC license.
|
|
115
115
|
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const
|
|
116
|
+
*/const yr=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],br=B("link",yr);/**
|
|
117
117
|
* @license lucide-react v1.11.0 - ISC
|
|
118
118
|
*
|
|
119
119
|
* This source code is licensed under the ISC license.
|
|
120
120
|
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const
|
|
121
|
+
*/const vr=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Se=B("loader-circle",vr);/**
|
|
122
122
|
* @license lucide-react v1.11.0 - ISC
|
|
123
123
|
*
|
|
124
124
|
* This source code is licensed under the ISC license.
|
|
125
125
|
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
-
*/const
|
|
126
|
+
*/const jr=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],ht=B("monitor",jr);/**
|
|
127
127
|
* @license lucide-react v1.11.0 - ISC
|
|
128
128
|
*
|
|
129
129
|
* This source code is licensed under the ISC license.
|
|
130
130
|
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
-
*/const
|
|
131
|
+
*/const wr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}]],Nr=B("panel-bottom",wr);/**
|
|
132
132
|
* @license lucide-react v1.11.0 - ISC
|
|
133
133
|
*
|
|
134
134
|
* This source code is licensed under the ISC license.
|
|
135
135
|
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
-
*/const
|
|
136
|
+
*/const kr=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],ft=B("pencil",kr);/**
|
|
137
137
|
* @license lucide-react v1.11.0 - ISC
|
|
138
138
|
*
|
|
139
139
|
* This source code is licensed under the ISC license.
|
|
140
140
|
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
-
*/const
|
|
141
|
+
*/const $r=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ye=B("plus",$r);/**
|
|
142
142
|
* @license lucide-react v1.11.0 - ISC
|
|
143
143
|
*
|
|
144
144
|
* This source code is licensed under the ISC license.
|
|
145
145
|
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
-
*/const
|
|
146
|
+
*/const Sr=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],Cr=B("rotate-ccw",Sr);/**
|
|
147
147
|
* @license lucide-react v1.11.0 - ISC
|
|
148
148
|
*
|
|
149
149
|
* This source code is licensed under the ISC license.
|
|
150
150
|
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
-
*/const
|
|
151
|
+
*/const Mr=[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]],De=B("search",Mr);/**
|
|
152
152
|
* @license lucide-react v1.11.0 - ISC
|
|
153
153
|
*
|
|
154
154
|
* This source code is licensed under the ISC license.
|
|
155
155
|
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
-
*/const ir=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],or=q("x",ir);function cr(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var me={exports:{}},lr=me.exports,Ie;function dr(){return Ie||(Ie=1,(function(t,r){(function(n,s){t.exports=s()})(lr,(function(){var n=1e3,s=6e4,i=36e5,l="millisecond",x="second",p="minute",y="hour",N="day",f="week",v="month",O="quarter",z="year",A="date",T="Invalid Date",I=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,_=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,H={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(d){var a=["th","st","nd","rd"],c=d%100;return"["+d+(a[(c-20)%10]||a[c]||a[0])+"]"}},W=function(d,a,c){var m=String(d);return!m||m.length>=a?d:""+Array(a+1-m.length).join(c)+d},C={s:W,z:function(d){var a=-d.utcOffset(),c=Math.abs(a),m=Math.floor(c/60),u=c%60;return(a<=0?"+":"-")+W(m,2,"0")+":"+W(u,2,"0")},m:function d(a,c){if(a.date()<c.date())return-d(c,a);var m=12*(c.year()-a.year())+(c.month()-a.month()),u=a.clone().add(m,v),S=c-u<0,E=a.clone().add(m+(S?-1:1),v);return+(-(m+(c-u)/(S?u-E:E-u))||0)},a:function(d){return d<0?Math.ceil(d)||0:Math.floor(d)},p:function(d){return{M:v,y:z,w:f,d:N,D:A,h:y,m:p,s:x,ms:l,Q:O}[d]||String(d||"").toLowerCase().replace(/s$/,"")},u:function(d){return d===void 0}},P="en",b={};b[P]=H;var h="$isDayjsObject",D=function(d){return d instanceof L||!(!d||!d[h])},$=function d(a,c,m){var u;if(!a)return P;if(typeof a=="string"){var S=a.toLowerCase();b[S]&&(u=S),c&&(b[S]=c,u=S);var E=a.split("-");if(!u&&E.length>1)return d(E[0])}else{var j=a.name;b[j]=a,u=j}return!m&&u&&(P=u),u||!m&&P},g=function(d,a){if(D(d))return d.clone();var c=typeof a=="object"?a:{};return c.date=d,c.args=arguments,new L(c)},w=C;w.l=$,w.i=D,w.w=function(d,a){return g(d,{locale:a.$L,utc:a.$u,x:a.$x,$offset:a.$offset})};var L=(function(){function d(c){this.$L=$(c.locale,null,!0),this.parse(c),this.$x=this.$x||c.x||{},this[h]=!0}var a=d.prototype;return a.parse=function(c){this.$d=(function(m){var u=m.date,S=m.utc;if(u===null)return new Date(NaN);if(w.u(u))return new Date;if(u instanceof Date)return new Date(u);if(typeof u=="string"&&!/Z$/i.test(u)){var E=u.match(I);if(E){var j=E[2]-1||0,M=(E[7]||"0").substring(0,3);return S?new Date(Date.UTC(E[1],j,E[3]||1,E[4]||0,E[5]||0,E[6]||0,M)):new Date(E[1],j,E[3]||1,E[4]||0,E[5]||0,E[6]||0,M)}}return new Date(u)})(c),this.init()},a.init=function(){var c=this.$d;this.$y=c.getFullYear(),this.$M=c.getMonth(),this.$D=c.getDate(),this.$W=c.getDay(),this.$H=c.getHours(),this.$m=c.getMinutes(),this.$s=c.getSeconds(),this.$ms=c.getMilliseconds()},a.$utils=function(){return w},a.isValid=function(){return this.$d.toString()!==T},a.isSame=function(c,m){var u=g(c);return this.startOf(m)<=u&&u<=this.endOf(m)},a.isAfter=function(c,m){return g(c)<this.startOf(m)},a.isBefore=function(c,m){return this.endOf(m)<g(c)},a.$g=function(c,m,u){return w.u(c)?this[m]:this.set(u,c)},a.unix=function(){return Math.floor(this.valueOf()/1e3)},a.valueOf=function(){return this.$d.getTime()},a.startOf=function(c,m){var u=this,S=!!w.u(m)||m,E=w.p(c),j=function(X,k){var U=w.w(u.$u?Date.UTC(u.$y,k,X):new Date(u.$y,k,X),u);return S?U:U.endOf(N)},M=function(X,k){return w.w(u.toDate()[X].apply(u.toDate("s"),(S?[0,0,0,0]:[23,59,59,999]).slice(k)),u)},R=this.$W,V=this.$M,B=this.$D,J="set"+(this.$u?"UTC":"");switch(E){case z:return S?j(1,0):j(31,11);case v:return S?j(1,V):j(0,V+1);case f:var Q=this.$locale().weekStart||0,te=(R<Q?R+7:R)-Q;return j(S?B-te:B+(6-te),V);case N:case A:return M(J+"Hours",0);case y:return M(J+"Minutes",1);case p:return M(J+"Seconds",2);case x:return M(J+"Milliseconds",3);default:return this.clone()}},a.endOf=function(c){return this.startOf(c,!1)},a.$set=function(c,m){var u,S=w.p(c),E="set"+(this.$u?"UTC":""),j=(u={},u[N]=E+"Date",u[A]=E+"Date",u[v]=E+"Month",u[z]=E+"FullYear",u[y]=E+"Hours",u[p]=E+"Minutes",u[x]=E+"Seconds",u[l]=E+"Milliseconds",u)[S],M=S===N?this.$D+(m-this.$W):m;if(S===v||S===z){var R=this.clone().set(A,1);R.$d[j](M),R.init(),this.$d=R.set(A,Math.min(this.$D,R.daysInMonth())).$d}else j&&this.$d[j](M);return this.init(),this},a.set=function(c,m){return this.clone().$set(c,m)},a.get=function(c){return this[w.p(c)]()},a.add=function(c,m){var u,S=this;c=Number(c);var E=w.p(m),j=function(V){var B=g(S);return w.w(B.date(B.date()+Math.round(V*c)),S)};if(E===v)return this.set(v,this.$M+c);if(E===z)return this.set(z,this.$y+c);if(E===N)return j(1);if(E===f)return j(7);var M=(u={},u[p]=s,u[y]=i,u[x]=n,u)[E]||1,R=this.$d.getTime()+c*M;return w.w(R,this)},a.subtract=function(c,m){return this.add(-1*c,m)},a.format=function(c){var m=this,u=this.$locale();if(!this.isValid())return u.invalidDate||T;var S=c||"YYYY-MM-DDTHH:mm:ssZ",E=w.z(this),j=this.$H,M=this.$m,R=this.$M,V=u.weekdays,B=u.months,J=u.meridiem,Q=function(k,U,F,Z){return k&&(k[U]||k(m,S))||F[U].slice(0,Z)},te=function(k){return w.s(j%12||12,k,"0")},X=J||function(k,U,F){var Z=k<12?"AM":"PM";return F?Z.toLowerCase():Z};return S.replace(_,(function(k,U){return U||(function(F){switch(F){case"YY":return String(m.$y).slice(-2);case"YYYY":return w.s(m.$y,4,"0");case"M":return R+1;case"MM":return w.s(R+1,2,"0");case"MMM":return Q(u.monthsShort,R,B,3);case"MMMM":return Q(B,R);case"D":return m.$D;case"DD":return w.s(m.$D,2,"0");case"d":return String(m.$W);case"dd":return Q(u.weekdaysMin,m.$W,V,2);case"ddd":return Q(u.weekdaysShort,m.$W,V,3);case"dddd":return V[m.$W];case"H":return String(j);case"HH":return w.s(j,2,"0");case"h":return te(1);case"hh":return te(2);case"a":return X(j,M,!0);case"A":return X(j,M,!1);case"m":return String(M);case"mm":return w.s(M,2,"0");case"s":return String(m.$s);case"ss":return w.s(m.$s,2,"0");case"SSS":return w.s(m.$ms,3,"0");case"Z":return E}return null})(k)||E.replace(":","")}))},a.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},a.diff=function(c,m,u){var S,E=this,j=w.p(m),M=g(c),R=(M.utcOffset()-this.utcOffset())*s,V=this-M,B=function(){return w.m(E,M)};switch(j){case z:S=B()/12;break;case v:S=B();break;case O:S=B()/3;break;case f:S=(V-R)/6048e5;break;case N:S=(V-R)/864e5;break;case y:S=V/i;break;case p:S=V/s;break;case x:S=V/n;break;default:S=V}return u?S:w.a(S)},a.daysInMonth=function(){return this.endOf(v).$D},a.$locale=function(){return b[this.$L]},a.locale=function(c,m){if(!c)return this.$L;var u=this.clone(),S=$(c,m,!0);return S&&(u.$L=S),u},a.clone=function(){return w.w(this.$d,this)},a.toDate=function(){return new Date(this.valueOf())},a.toJSON=function(){return this.isValid()?this.toISOString():null},a.toISOString=function(){return this.$d.toISOString()},a.toString=function(){return this.$d.toUTCString()},d})(),Y=L.prototype;return g.prototype=Y,[["$ms",l],["$s",x],["$m",p],["$H",y],["$W",N],["$M",v],["$y",z],["$D",A]].forEach((function(d){Y[d[1]]=function(a){return this.$g(a,d[0],d[1])}})),g.extend=function(d,a){return d.$i||(d(a,L,g),d.$i=!0),g},g.locale=$,g.isDayjs=D,g.unix=function(d){return g(1e3*d)},g.en=b[P],g.Ls=b,g.p={},g}))})(me)),me.exports}var ur=dr();const Oe=cr(ur);function st(){const[t,r]=o.useState(!1),[n,s]=o.useState(!1),i=o.useRef({title:""}),l={confirm:v=>{i.current=v,s(!1),r(!0)}},x=async()=>{var v,O;s(!0);try{await((O=(v=i.current).onOk)==null?void 0:O.call(v)),r(!1)}finally{s(!1)}},p=()=>{var v,O;(O=(v=i.current).onCancel)==null||O.call(v),r(!1)},y=i.current,N=y.okType==="danger",f=t?Ue.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[9998] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:p}),e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-xl w-full max-w-md mx-4 p-6",children:[e.jsx("div",{className:"text-base font-semibold text-gray-800 mb-2",children:y.title}),y.content&&e.jsx("div",{className:"text-sm text-gray-600 mt-3",children:y.content}),e.jsxs("div",{className:"flex justify-end gap-2 mt-5",children:[e.jsx("button",{className:"px-4 py-1.5 rounded-lg border border-gray-200 text-sm text-gray-600 hover:bg-gray-50 transition-colors cursor-pointer",onClick:p,children:y.cancelText??"取消"}),e.jsx("button",{disabled:n,className:`px-4 py-1.5 rounded-lg text-white text-sm font-medium transition-colors disabled:opacity-50 cursor-pointer ${N?"bg-red-500 hover:bg-red-600":"bg-blue-500 hover:bg-blue-600"}`,onClick:x,children:n?"处理中…":y.okText??"确定"})]})]})]}),document.body):null;return[l,f]}const at=(t,r)=>JSON.stringify([t.trim().replace(/\/+$/,""),r]);function hr({article:t,groups:r,canLoadGroups:n,onRetry:s}){var x;const i=t.navPlacements??[],l=(x=t.navname)==null?void 0:x.trim();return!t.navEnabled&&!l&&!i.length?e.jsx("span",{className:"text-xs text-gray-400",children:"未加入网站导航"}):e.jsxs("div",{className:"min-w-0 space-y-2.5 py-0.5",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 break-words text-sm font-semibold text-gray-800",children:l||"未命名导航"}),e.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-full px-2 py-0.5 text-[11px] font-medium ${t.navEnabled?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"}`,title:t.navEnabled?"已在以下位置展示":"导航已关闭,保留以下位置配置",children:[e.jsx("span",{"aria-hidden":"true",className:`h-1.5 w-1.5 rounded-full ${t.navEnabled?"bg-emerald-500":"bg-gray-400"}`}),t.navEnabled?"展示中":"已关闭"]})]}),e.jsxs("div",{className:`space-y-1.5 ${t.navEnabled?"":"opacity-60"}`,children:[["header","footer"].map(p=>{const y=i.find(_=>_.position===p);if(!y)return null;const N=p==="header",f=N?Je:et,v=N?"页眉":"页尾",O=r[at(t.host??"",p)],z=y.parentNavId?O==null?void 0:O.names[y.parentNavId]:void 0,A=n&&t.host&&(!O||O.status==="loading"),T=z||(A?"加载中…":(O==null?void 0:O.status)==="error"?"加载失败":"父导航名称不可用"),I=[v,...y.parentNavId?[T]:[],l||"未命名导航"].join(" → ");return e.jsxs("div",{className:"flex min-w-0 items-start gap-2","aria-label":I,title:I,children:[e.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-[11px] font-medium leading-none ${N?"bg-blue-50 text-blue-600":"bg-violet-50 text-violet-600"}`,children:[e.jsx(f,{size:12,"aria-hidden":"true"}),v]}),e.jsx(Ae,{size:12,className:"mt-0.5 shrink-0 text-gray-300","aria-hidden":"true"}),e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-1 gap-y-1 pt-0.5 text-xs leading-4",children:[y.parentNavId&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`break-all ${z?"text-gray-600":"text-gray-400"}`,children:T}),(O==null?void 0:O.status)==="error"&&e.jsx("button",{type:"button",onClick:s,className:"cursor-pointer text-blue-500 hover:text-blue-600",children:"重试"}),e.jsx(Ae,{size:12,className:"shrink-0 text-gray-300","aria-hidden":"true"})]}),e.jsx("span",{className:"break-all text-gray-700",children:l||"未命名导航"})]})]},p)}),!i.length&&e.jsx("p",{className:"text-xs text-gray-400",children:"尚未设置展示位置"})]})]})}const mr=()=>{const{navigate:t}=Te(),{basePath:r,service:n}=pe(),[s,i]=st(),[l,x]=o.useState(""),[p,y]=o.useState(""),[N,f]=o.useState(!1),[v,O]=o.useState([]),[z,A]=o.useState({}),[T,I]=o.useState(0),[_,H]=o.useState({current:1,size:15,total:0}),W=h=>{const D=h.trim();if(!D)return"";try{return new URL(D.startsWith("http")?D:`https://${D}`).origin}catch{return D}},C=async(h=_.current,D=_.size,$=l,g=p)=>{f(!0);try{const w={page:h,size:D};$&&(w.pathname=$);const L=W(g);L&&(w.host=L);const Y=await n.getList(w);O(Y.items),H(d=>({...d,current:h,size:D,total:Y.total??d.total}))}catch(w){G.error(w.message||"获取文章失败")}finally{f(!1)}};o.useEffect(()=>{C(1)},[]),o.useEffect(()=>{if(!n.getNavigationGroups)return;let h=!0;const D=new Map;for(const $ of v)if($.host)for(const g of $.navPlacements??[]){if(!g.parentNavId)continue;const w=$.host.trim().replace(/\/+$/,"");D.set(at(w,g.position),{host:w,position:g.position})}A(Object.fromEntries([...D.keys()].map($=>[$,{status:"loading",names:{}}])));for(const[$,g]of D)(async()=>{try{const w=await n.getNavigationGroups(g);if(!h)return;A(L=>({...L,[$]:{status:"loaded",names:Object.fromEntries(w.map(Y=>[Y.id,Y.name]))}}))}catch{if(!h)return;A(w=>({...w,[$]:{status:"error",names:{}}}))}})();return()=>{h=!1}},[v,n,T]);const P=h=>{s.confirm({title:"删除文章",content:`确认删除 /${h.pathname}?`,okText:"删除",okType:"danger",cancelText:"取消",onOk:async()=>{await n.delete(h.id),G.success("删除成功"),C(1)}})},b=Math.ceil(_.total/_.size)||1;return e.jsxs("div",{className:"min-w-0 bg-white rounded-xl shadow-sm border border-gray-100 p-5",children:[i,e.jsxs("form",{className:"flex flex-wrap items-center gap-2 mb-5",onSubmit:h=>{h.preventDefault(),C(1)},children:[e.jsxs("div",{className:"relative w-full sm:w-52",children:[e.jsx(je,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400"}),e.jsx("input",{className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/30 focus:border-blue-400 transition","aria-label":"搜索访问路径",placeholder:"搜索访问路径",value:l,onChange:h=>x(h.target.value)})]}),e.jsxs("div",{className:"relative w-full sm:w-52",children:[e.jsx(je,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400"}),e.jsx("input",{className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/30 focus:border-blue-400 transition","aria-label":"搜索网站地址",placeholder:"搜索网站地址",value:p,onChange:h=>y(h.target.value)})]}),e.jsxs("button",{type:"submit",className:"flex items-center gap-1.5 px-3 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-sm rounded-lg transition cursor-pointer",children:[e.jsx(je,{className:"w-3.5 h-3.5"}),"搜索"]}),e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 px-3 py-1.5 border border-gray-200 hover:bg-gray-50 text-gray-600 text-sm rounded-lg transition cursor-pointer",onClick:()=>{x(""),y(""),C(1,_.size,"","")},children:[e.jsx(tr,{className:"w-3.5 h-3.5"}),"重置"]}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 px-3 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-sm rounded-lg transition cursor-pointer",onClick:()=>t(`${r}/create`),children:[e.jsx(tt,{className:"w-3.5 h-3.5"}),"新增文章"]})]}),e.jsx("div",{className:"relative overflow-x-auto",role:"region","aria-label":"文章列表",tabIndex:0,children:e.jsxs("table",{className:"w-full min-w-[1120px] table-fixed text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-100",children:[e.jsx("th",{scope:"col",className:"text-left py-2.5 px-3 font-medium text-gray-400 text-xs uppercase tracking-wide w-36",children:"访问路径"}),e.jsx("th",{scope:"col",className:"text-left py-2.5 px-3 font-medium text-gray-400 text-xs uppercase tracking-wide w-32",children:"网站地址"}),e.jsx("th",{scope:"col",className:"text-left py-2.5 px-3 font-medium text-gray-400 text-xs uppercase tracking-wide w-80",children:"网站导航"}),e.jsx("th",{scope:"col",className:"text-left py-2.5 px-3 font-medium text-gray-400 text-xs uppercase tracking-wide",children:"HTML 摘要"}),e.jsx("th",{scope:"col",className:"text-left py-2.5 px-3 font-medium text-gray-400 text-xs uppercase tracking-wide w-36",children:"创建时间"}),e.jsx("th",{scope:"col",className:"text-left py-2.5 px-3 font-medium text-gray-400 text-xs uppercase tracking-wide w-60",children:"操作"})]})}),e.jsx("tbody",{children:N?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-gray-400",children:[e.jsx(Qe,{className:"w-6 h-6 text-blue-400 animate-spin"}),e.jsx("span",{className:"text-sm",children:"加载中…"})]})})}):v.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-gray-300",children:[e.jsx(Yt,{className:"w-10 h-10"}),e.jsx("span",{className:"text-sm",children:"暂无文章"})]})})}):v.map(h=>{const D=(h.content||"").replace(/<(style|script)\b[^>]*>[\s\S]*?<\/\1>/gi," ").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,80);return e.jsxs("tr",{className:"border-b border-gray-50 hover:bg-gray-50/60 transition-colors",children:[e.jsx("td",{className:"py-3 px-3",children:e.jsxs("span",{className:"block break-words font-mono text-xs text-gray-700",children:["/",h.pathname]})}),e.jsx("td",{className:"py-3 px-3",children:h.host?e.jsxs("a",{href:h.host,target:"_blank",rel:"noopener noreferrer",className:"inline-flex max-w-full items-center gap-1 text-xs text-blue-600 underline underline-offset-2 hover:text-blue-800 transition-colors",title:h.host,children:[e.jsx("span",{className:"truncate",children:h.host.replace(/^https?:\/\//,"")}),e.jsx(It,{className:"w-3 h-3 shrink-0"})]}):e.jsx("span",{className:"text-xs text-gray-300",children:"—"})}),e.jsx("td",{className:"py-3 px-3",children:e.jsx(hr,{article:h,groups:z,canLoadGroups:!!n.getNavigationGroups,onRetry:()=>I($=>$+1)})}),e.jsx("td",{className:"py-3 px-3",children:D?e.jsx("span",{className:"text-sm text-gray-500 truncate block max-w-sm",title:D,children:D}):e.jsx("span",{className:"text-xs text-gray-300",children:"暂无内容"})}),e.jsx("td",{className:"py-3 px-3 text-xs whitespace-nowrap text-gray-400",children:h.createdAt?Oe(h.createdAt).format("YYYY/MM/DD HH:mm"):"—"}),e.jsx("td",{className:"py-3 px-3",children:e.jsxs("div",{className:"flex items-center gap-1",children:[h.host&&e.jsx("button",{className:"px-2.5 py-1 text-xs border border-gray-200 rounded-md hover:bg-gray-50 text-gray-600 transition cursor-pointer",onClick:()=>window.open(`${h.host.replace(/\/$/,"")}/${h.pathname}`,"_blank"),children:"跳转"}),e.jsx("button",{className:"px-2.5 py-1 text-xs border border-gray-200 rounded-md hover:bg-gray-50 text-gray-600 transition cursor-pointer",onClick:()=>t(`${r}/${h.id}/detail`,{state:{record:h}}),children:"详情"}),e.jsx("button",{className:"px-2.5 py-1 text-xs bg-blue-500 hover:bg-blue-600 text-white rounded-md transition cursor-pointer",onClick:()=>t(`${r}/${h.id}/edit`,{state:{record:h}}),children:"编辑"}),e.jsx("button",{className:"px-2.5 py-1 text-xs bg-red-500 hover:bg-red-600 text-white rounded-md transition cursor-pointer",onClick:()=>P(h),children:"删除"})]})})]},h.id)})})]})}),_.total>0&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-4 mt-2 border-t border-gray-100",children:[e.jsxs("span",{className:"text-xs text-gray-400",children:["共 ",_.total," 篇文章"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx("button",{className:"px-2.5 py-1 text-xs border border-gray-200 rounded-md hover:bg-gray-50 disabled:opacity-40 disabled:cursor-not-allowed text-gray-600 transition cursor-pointer",disabled:_.current<=1,onClick:()=>C(_.current-1),children:"上一页"}),e.jsxs("span",{className:"px-3 py-1 text-xs text-gray-500",children:[_.current," / ",b]}),e.jsx("button",{className:"px-2.5 py-1 text-xs border border-gray-200 rounded-md hover:bg-gray-50 disabled:opacity-40 disabled:cursor-not-allowed text-gray-600 transition cursor-pointer",disabled:_.current>=b,onClick:()=>C(_.current+1),children:"下一页"}),e.jsx("select",{"aria-label":"每页条数",className:"ml-2 text-xs border border-gray-200 rounded-md px-1.5 py-1 text-gray-600 focus:outline-none focus:ring-1 focus:ring-blue-400 cursor-pointer",value:_.size,onChange:h=>C(1,Number(h.target.value)),children:[10,15,20,50].map(h=>e.jsxs("option",{value:h,children:[h," 条/页"]},h))})]})]})]})},fr=[{position:"header",label:"页眉",icon:Je,parentEnabled:!1},{position:"footer",label:"页尾",icon:et,parentEnabled:!0}],Pe="w-full min-w-0 rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm text-gray-700 outline-none transition focus:border-blue-400 focus:ring-2 focus:ring-blue-500/20";function xr({host:t,position:r,label:n,parentEnabled:s,service:i,parentNavId:l,onSelect:x}){const p=o.useId(),[y,N]=o.useState([]),[f,v]=o.useState(!1),[O,z]=o.useState(""),[A,T]=o.useState(!1),[I,_]=o.useState(""),[H,W]=o.useState(""),[C,P]=o.useState(!1),b=o.useRef(0),h=o.useRef(0),D=o.useRef(x);D.current=x;const $=i.getNavigationGroups,g=i.createNavigationGroup,w=o.useCallback(async()=>{if(!t||!$)return;const d=++h.current;v(!0),z("");try{const a=await $({host:t,position:r});return d!==h.current?void 0:(N(a),a)}catch(a){d===h.current&&z(a instanceof Error?a.message:"父导航加载失败")}finally{d===h.current&&v(!1)}},[t,r,$]);o.useEffect(()=>(b.current++,w(),()=>{b.current++,h.current++}),[w]);const L=async()=>{if(C||!g||!s)return;const d=I.trim();if(!d){W("请输入父导航名称");return}const a=y.find(m=>m.name===d);if(a){D.current(a.id),T(!1);return}const c=b.current;P(!0),W("");try{const m=await g({host:t,position:r,name:d});if(c!==b.current)return;N(u=>[...u.filter(S=>S.id!==m.id),m]),D.current(m.id),T(!1),_(""),w()}catch(m){if(c!==b.current)return;if((m==null?void 0:m.status)===409){const u=await w();if(c!==b.current)return;const S=u==null?void 0:u.find(E=>E.name===d);if(S){D.current(S.id),T(!1),_("");return}}W(m instanceof Error?m.message:"新增父导航失败")}finally{c===b.current&&P(!1)}},Y=!!l&&!y.some(d=>d.id===l);return e.jsxs("div",{className:"mt-3",children:[e.jsxs("label",{htmlFor:p,className:"mb-1.5 block text-xs text-gray-500",children:["所属父导航 ",e.jsx("span",{className:"text-gray-400",children:"(可选)"})]}),e.jsxs("select",{id:p,"aria-label":`${n}父导航`,disabled:!s||!t||f||C,value:l??"",onChange:d=>x(d.target.value||null),className:`${Pe} disabled:cursor-not-allowed disabled:bg-gray-50 disabled:text-gray-400`,children:[e.jsx("option",{value:"",children:"无(顶级导航)"}),y.map(d=>e.jsx("option",{value:d.id,children:d.name},d.id)),Y&&e.jsxs("option",{value:l,children:["已选父导航(",l,")"]})]}),f&&e.jsx("p",{role:"status",className:"mt-2 text-xs text-gray-500",children:"加载父导航中…"}),O&&e.jsxs("p",{role:"alert",className:"mt-2 text-xs text-red-500",children:[O,e.jsx("button",{type:"button",onClick:()=>void w(),className:"ml-2 cursor-pointer text-blue-500",children:"重试"})]}),s?t?A?e.jsxs("div",{className:"mt-3",children:[e.jsxs("label",{htmlFor:`${p}-new`,className:"mb-1.5 block text-xs text-gray-500",children:["新增",n,"父导航"]}),e.jsx("input",{id:`${p}-new`,autoFocus:!0,maxLength:100,value:I,disabled:C,placeholder:"输入父导航名称","aria-invalid":!!H,"aria-describedby":H?`${p}-error`:void 0,onChange:d=>{_(d.target.value),W("")},onKeyDown:d=>{d.key==="Enter"&&!d.nativeEvent.isComposing&&(d.preventDefault(),L()),d.key==="Escape"&&!C&&T(!1)},className:Pe}),H&&e.jsx("p",{id:`${p}-error`,role:"alert",className:"mt-1.5 text-xs text-red-500",children:H}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",disabled:C,onClick:()=>void L(),className:"flex cursor-pointer items-center gap-1 rounded-lg bg-blue-500 px-2.5 py-1.5 text-xs text-white hover:bg-blue-600 disabled:opacity-50",children:[C?e.jsx(Qe,{size:12,className:"animate-spin"}):e.jsx(Et,{size:12,"aria-hidden":"true"}),C?"添加中…":"添加并选中"]}),e.jsxs("button",{type:"button",disabled:C,onClick:()=>T(!1),className:"flex cursor-pointer items-center gap-1 rounded-lg px-2.5 py-1.5 text-xs text-gray-500 hover:bg-gray-100 disabled:opacity-50",children:[e.jsx(or,{size:12,"aria-hidden":"true"}),"取消"]})]})]}):g?e.jsxs("button",{type:"button",disabled:f,"aria-label":`新增${n}父导航`,onClick:()=>{T(!0),_(""),W("")},className:"mt-2.5 flex cursor-pointer items-center gap-1 text-xs text-blue-500 enabled:hover:text-blue-600 disabled:opacity-50",children:[e.jsx(tt,{size:13,"aria-hidden":"true"}),"新增父导航"]}):null:e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"请先填写网站地址"}):e.jsx("p",{className:"mt-2 text-xs text-gray-500",children:"页眉暂不支持设置父导航。"})]})}function pr({host:t,service:r,value:n,onChange:s}){const i=o.useId(),l=t.trim().replace(/\/+$/,""),[x,p]=o.useState(!1),y=!!r.getNavigationGroups,N=v=>s({...n,...v}),f=(v,O)=>{N({navPlacements:O?[...n.navPlacements,{position:v,parentNavId:null}]:n.navPlacements.filter(z=>z.position!==v)})};return e.jsxs("section",{"aria-label":"导航设置",className:"mt-5 border-t border-gray-100 pt-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-gray-700",children:"导航设置"}),e.jsxs("label",{htmlFor:`${i}-enabled`,className:"flex cursor-pointer items-center gap-2 text-sm text-gray-600",children:[e.jsx("span",{children:"启用导航"}),e.jsxs("span",{className:"relative inline-flex h-5 w-9 shrink-0 items-center",children:[e.jsx("input",{id:`${i}-enabled`,type:"checkbox",role:"switch",checked:n.navEnabled,disabled:!y,"aria-controls":`${i}-fields`,onChange:v=>N({navEnabled:v.target.checked}),className:"peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed"}),e.jsx("span",{"aria-hidden":"true",className:"absolute inset-0 rounded-full bg-gray-200 transition peer-checked:bg-blue-500 peer-disabled:opacity-50 peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-blue-500"}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none relative ml-0.5 h-4 w-4 rounded-full bg-white shadow-sm transition-transform peer-checked:translate-x-4"})]})]})]}),y?n.navEnabled?e.jsxs("div",{id:`${i}-fields`,className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"max-w-md",children:[e.jsxs("label",{htmlFor:`${i}-name`,className:"mb-1.5 block text-sm font-medium text-gray-700",children:["导航名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${i}-name`,value:n.navname,maxLength:100,placeholder:"输入导航名称",required:!0,"aria-invalid":x&&!n.navname.trim(),"aria-describedby":x&&!n.navname.trim()?`${i}-name-error`:void 0,onChange:v=>N({navname:v.target.value}),onBlur:()=>p(!0),className:Pe}),x&&!n.navname.trim()&&e.jsx("p",{id:`${i}-name-error`,role:"alert",className:"mt-1.5 text-xs text-red-500",children:"开启导航后,请填写导航名称"})]}),e.jsxs("fieldset",{"aria-describedby":`${i}-placements-hint`,children:[e.jsxs("legend",{className:"mb-2 text-sm font-medium text-gray-700",children:["展示位置 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("p",{id:`${i}-placements-hint`,className:"mb-3 text-xs text-gray-500",children:"可同时选择页眉和页尾,页尾可设置父导航。"}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:fr.map(({position:v,label:O,icon:z,parentEnabled:A})=>{const T=n.navPlacements.find(I=>I.position===v);return e.jsxs("div",{className:`min-w-0 rounded-xl border p-3.5 transition-colors ${T?"border-blue-200 bg-blue-50/30":"border-gray-200 bg-gray-50/50"}`,children:[e.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5 text-sm text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:!!T,onChange:I=>f(v,I.target.checked),className:"h-4 w-4 shrink-0 accent-blue-500"}),e.jsx(z,{size:15,className:"shrink-0 text-gray-400","aria-hidden":"true"}),e.jsx("span",{className:"font-medium",children:O})]}),T&&e.jsx(xr,{host:l,position:v,label:O,parentEnabled:A,service:r,parentNavId:T.parentNavId,onSelect:I=>N({navPlacements:n.navPlacements.map(_=>_.position===v?{..._,parentNavId:I}:_)})},`${l}:${v}`)]},v)})}),n.navPlacements.length===0&&e.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-500",children:"请至少选择一个展示位置"})]})]}):e.jsx("p",{className:"mt-1.5 text-xs text-gray-500",children:"开启后可将文章加入页眉、页尾或同时加入两处。"}):e.jsx("p",{className:"mt-1.5 text-xs text-gray-500",children:"当前服务尚未接入导航配置"})]})}function gr(t){return t.split(/(“[^”]+”|"[^"]+")/g).map((r,n)=>/^(“.*”|".*")$/.test(r)?e.jsx("code",{className:"rounded bg-gray-100 px-1 py-0.5 font-mono text-[11px] text-gray-800",children:r.slice(1,-1)},n):r)}function br({errors:t,source:r}){const[n,s]=o.useState(null),i=r.split(`
|
|
157
|
-
|
|
158
|
-
|
|
156
|
+
*/const Er=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Qe=B("shield-check",Er);/**
|
|
157
|
+
* @license lucide-react v1.11.0 - ISC
|
|
158
|
+
*
|
|
159
|
+
* This source code is licensed under the ISC license.
|
|
160
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
+
*/const Or=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],gt=B("smartphone",Or);/**
|
|
162
|
+
* @license lucide-react v1.11.0 - ISC
|
|
163
|
+
*
|
|
164
|
+
* This source code is licensed under the ISC license.
|
|
165
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
+
*/const Pr=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]],pt=B("tablet",Pr);/**
|
|
167
|
+
* @license lucide-react v1.11.0 - ISC
|
|
168
|
+
*
|
|
169
|
+
* This source code is licensed under the ISC license.
|
|
170
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
+
*/const Dr=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],yt=B("x",Dr);function Ir(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var je={exports:{}},Lr=je.exports,et;function _r(){return et||(et=1,(function(t,r){(function(n,s){t.exports=s()})(Lr,(function(){var n=1e3,s=6e4,c=36e5,d="millisecond",h="second",x="minute",u="hour",y="day",g="week",w="month",L="quarter",T="year",z="date",H="Invalid Date",W=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,G=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,A={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(N){var l=["th","st","nd","rd"],m=N%100;return"["+N+(l[(m-20)%10]||l[m]||l[0])+"]"}},Y=function(N,l,m){var k=String(N);return!k||k.length>=l?N:""+Array(l+1-k.length).join(m)+N},S={s:Y,z:function(N){var l=-N.utcOffset(),m=Math.abs(l),k=Math.floor(m/60),p=m%60;return(l<=0?"+":"-")+Y(k,2,"0")+":"+Y(p,2,"0")},m:function N(l,m){if(l.date()<m.date())return-N(m,l);var k=12*(m.year()-l.year())+(m.month()-l.month()),p=l.clone().add(k,w),E=m-p<0,O=l.clone().add(k+(E?-1:1),w);return+(-(k+(m-p)/(E?p-O:O-p))||0)},a:function(N){return N<0?Math.ceil(N)||0:Math.floor(N)},p:function(N){return{M:w,y:T,w:g,d:y,D:z,h:u,m:x,s:h,ms:d,Q:L}[N]||String(N||"").toLowerCase().replace(/s$/,"")},u:function(N){return N===void 0}},P="en",v={};v[P]=A;var b="$isDayjsObject",_=function(N){return N instanceof I||!(!N||!N[b])},M=function N(l,m,k){var p;if(!l)return P;if(typeof l=="string"){var E=l.toLowerCase();v[E]&&(p=E),m&&(v[E]=m,p=E);var O=l.split("-");if(!p&&O.length>1)return N(O[0])}else{var i=l.name;v[i]=l,p=i}return!k&&p&&(P=p),p||!k&&P},f=function(N,l){if(_(N))return N.clone();var m=typeof l=="object"?l:{};return m.date=N,m.args=arguments,new I(m)},$=S;$.l=M,$.i=_,$.w=function(N,l){return f(N,{locale:l.$L,utc:l.$u,x:l.$x,$offset:l.$offset})};var I=(function(){function N(m){this.$L=M(m.locale,null,!0),this.parse(m),this.$x=this.$x||m.x||{},this[b]=!0}var l=N.prototype;return l.parse=function(m){this.$d=(function(k){var p=k.date,E=k.utc;if(p===null)return new Date(NaN);if($.u(p))return new Date;if(p instanceof Date)return new Date(p);if(typeof p=="string"&&!/Z$/i.test(p)){var O=p.match(W);if(O){var i=O[2]-1||0,o=(O[7]||"0").substring(0,3);return E?new Date(Date.UTC(O[1],i,O[3]||1,O[4]||0,O[5]||0,O[6]||0,o)):new Date(O[1],i,O[3]||1,O[4]||0,O[5]||0,O[6]||0,o)}}return new Date(p)})(m),this.init()},l.init=function(){var m=this.$d;this.$y=m.getFullYear(),this.$M=m.getMonth(),this.$D=m.getDate(),this.$W=m.getDay(),this.$H=m.getHours(),this.$m=m.getMinutes(),this.$s=m.getSeconds(),this.$ms=m.getMilliseconds()},l.$utils=function(){return $},l.isValid=function(){return this.$d.toString()!==H},l.isSame=function(m,k){var p=f(m);return this.startOf(k)<=p&&p<=this.endOf(k)},l.isAfter=function(m,k){return f(m)<this.startOf(k)},l.isBefore=function(m,k){return this.endOf(k)<f(m)},l.$g=function(m,k,p){return $.u(m)?this[k]:this.set(p,m)},l.unix=function(){return Math.floor(this.valueOf()/1e3)},l.valueOf=function(){return this.$d.getTime()},l.startOf=function(m,k){var p=this,E=!!$.u(k)||k,O=$.p(m),i=function(Z,ee){var re=$.w(p.$u?Date.UTC(p.$y,ee,Z):new Date(p.$y,ee,Z),p);return E?re:re.endOf(y)},o=function(Z,ee){return $.w(p.toDate()[Z].apply(p.toDate("s"),(E?[0,0,0,0]:[23,59,59,999]).slice(ee)),p)},j=this.$W,C=this.$M,R=this.$D,K="set"+(this.$u?"UTC":"");switch(O){case T:return E?i(1,0):i(31,11);case w:return E?i(1,C):i(0,C+1);case g:var q=this.$locale().weekStart||0,Q=(j<q?j+7:j)-q;return i(E?R-Q:R+(6-Q),C);case y:case z:return o(K+"Hours",0);case u:return o(K+"Minutes",1);case x:return o(K+"Seconds",2);case h:return o(K+"Milliseconds",3);default:return this.clone()}},l.endOf=function(m){return this.startOf(m,!1)},l.$set=function(m,k){var p,E=$.p(m),O="set"+(this.$u?"UTC":""),i=(p={},p[y]=O+"Date",p[z]=O+"Date",p[w]=O+"Month",p[T]=O+"FullYear",p[u]=O+"Hours",p[x]=O+"Minutes",p[h]=O+"Seconds",p[d]=O+"Milliseconds",p)[E],o=E===y?this.$D+(k-this.$W):k;if(E===w||E===T){var j=this.clone().set(z,1);j.$d[i](o),j.init(),this.$d=j.set(z,Math.min(this.$D,j.daysInMonth())).$d}else i&&this.$d[i](o);return this.init(),this},l.set=function(m,k){return this.clone().$set(m,k)},l.get=function(m){return this[$.p(m)]()},l.add=function(m,k){var p,E=this;m=Number(m);var O=$.p(k),i=function(C){var R=f(E);return $.w(R.date(R.date()+Math.round(C*m)),E)};if(O===w)return this.set(w,this.$M+m);if(O===T)return this.set(T,this.$y+m);if(O===y)return i(1);if(O===g)return i(7);var o=(p={},p[x]=s,p[u]=c,p[h]=n,p)[O]||1,j=this.$d.getTime()+m*o;return $.w(j,this)},l.subtract=function(m,k){return this.add(-1*m,k)},l.format=function(m){var k=this,p=this.$locale();if(!this.isValid())return p.invalidDate||H;var E=m||"YYYY-MM-DDTHH:mm:ssZ",O=$.z(this),i=this.$H,o=this.$m,j=this.$M,C=p.weekdays,R=p.months,K=p.meridiem,q=function(ee,re,ne,X){return ee&&(ee[re]||ee(k,E))||ne[re].slice(0,X)},Q=function(ee){return $.s(i%12||12,ee,"0")},Z=K||function(ee,re,ne){var X=ee<12?"AM":"PM";return ne?X.toLowerCase():X};return E.replace(G,(function(ee,re){return re||(function(ne){switch(ne){case"YY":return String(k.$y).slice(-2);case"YYYY":return $.s(k.$y,4,"0");case"M":return j+1;case"MM":return $.s(j+1,2,"0");case"MMM":return q(p.monthsShort,j,R,3);case"MMMM":return q(R,j);case"D":return k.$D;case"DD":return $.s(k.$D,2,"0");case"d":return String(k.$W);case"dd":return q(p.weekdaysMin,k.$W,C,2);case"ddd":return q(p.weekdaysShort,k.$W,C,3);case"dddd":return C[k.$W];case"H":return String(i);case"HH":return $.s(i,2,"0");case"h":return Q(1);case"hh":return Q(2);case"a":return Z(i,o,!0);case"A":return Z(i,o,!1);case"m":return String(o);case"mm":return $.s(o,2,"0");case"s":return String(k.$s);case"ss":return $.s(k.$s,2,"0");case"SSS":return $.s(k.$ms,3,"0");case"Z":return O}return null})(ee)||O.replace(":","")}))},l.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},l.diff=function(m,k,p){var E,O=this,i=$.p(k),o=f(m),j=(o.utcOffset()-this.utcOffset())*s,C=this-o,R=function(){return $.m(O,o)};switch(i){case T:E=R()/12;break;case w:E=R();break;case L:E=R()/3;break;case g:E=(C-j)/6048e5;break;case y:E=(C-j)/864e5;break;case u:E=C/c;break;case x:E=C/s;break;case h:E=C/n;break;default:E=C}return p?E:$.a(E)},l.daysInMonth=function(){return this.endOf(w).$D},l.$locale=function(){return v[this.$L]},l.locale=function(m,k){if(!m)return this.$L;var p=this.clone(),E=M(m,k,!0);return E&&(p.$L=E),p},l.clone=function(){return $.w(this.$d,this)},l.toDate=function(){return new Date(this.valueOf())},l.toJSON=function(){return this.isValid()?this.toISOString():null},l.toISOString=function(){return this.$d.toISOString()},l.toString=function(){return this.$d.toUTCString()},N})(),V=I.prototype;return f.prototype=V,[["$ms",d],["$s",h],["$m",x],["$H",u],["$W",y],["$M",w],["$y",T],["$D",z]].forEach((function(N){V[N[1]]=function(l){return this.$g(l,N[0],N[1])}})),f.extend=function(N,l){return N.$i||(N(l,I,f),N.$i=!0),f},f.locale=M,f.isDayjs=_,f.unix=function(N){return f(1e3*N)},f.en=v[P],f.Ls=v,f.p={},f}))})(je)),je.exports}var Tr=_r();const He=Ir(Tr);function bt(){const[t,r]=a.useState(!1),[n,s]=a.useState(!1),c=a.useRef({title:""}),d={confirm:w=>{c.current=w,s(!1),r(!0)}},h=async()=>{var w,L;s(!0);try{await((L=(w=c.current).onOk)==null?void 0:L.call(w)),r(!1)}finally{s(!1)}},x=()=>{var w,L;(L=(w=c.current).onCancel)==null||L.call(w),r(!1)},u=c.current,y=u.okType==="danger",g=t?ct.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[9998] flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 bg-black/40",onClick:x}),e.jsxs("div",{className:"relative bg-white rounded-2xl shadow-xl w-full max-w-md mx-4 p-6",children:[e.jsx("div",{className:"text-base font-semibold text-gray-800 mb-2",children:u.title}),u.content&&e.jsx("div",{className:"text-sm text-gray-600 mt-3",children:u.content}),e.jsxs("div",{className:"flex justify-end gap-2 mt-5",children:[e.jsx("button",{className:"px-4 py-1.5 rounded-lg border border-gray-200 text-sm text-gray-600 hover:bg-gray-50 transition-colors cursor-pointer",onClick:x,children:u.cancelText??"取消"}),e.jsx("button",{disabled:n,className:`px-4 py-1.5 rounded-lg text-white text-sm font-medium transition-colors disabled:opacity-50 cursor-pointer ${y?"bg-red-500 hover:bg-red-600":"bg-blue-500 hover:bg-blue-600"}`,onClick:h,children:n?"处理中…":u.okText??"确定"})]})]})]}),document.body):null;return[d,g]}const vt=(t,r)=>JSON.stringify([t.trim().replace(/\/+$/,""),r]);function we({enabled:t,children:r}){return e.jsxs("span",{className:`inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-0.5 text-[11px] font-medium leading-4 ${t?"bg-emerald-50 text-emerald-700":"bg-gray-100 text-gray-500"}`,children:[e.jsx("span",{"aria-hidden":"true",className:`h-1 w-1 shrink-0 rounded-full ${t?"bg-emerald-500":"bg-gray-400"}`}),r]})}function zr({article:t}){var h,x;const r=t.guidesDisplay,n=r==null?void 0:r.title.trim(),s=r==null?void 0:r.description.trim(),c=(h=r==null?void 0:r.category)==null?void 0:h.name.trim(),d=!!(r!=null&&r.categoryId||(x=r==null?void 0:r.category)!=null&&x.id||c);return r?e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 leading-5",children:[e.jsx("span",{className:"w-6 shrink-0 text-xs text-gray-400",children:"标题"}),e.jsx("p",{title:n,className:"min-w-0 truncate text-sm font-medium text-gray-800",children:n||"未设置展示标题"}),e.jsx(we,{enabled:!0,children:"已配置"})]}),s&&e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs leading-5",children:[e.jsx("span",{className:"w-6 shrink-0 text-gray-400",children:"简介"}),e.jsx("p",{title:s,className:"truncate text-gray-500",children:s})]}),e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs leading-5",children:[e.jsx("span",{className:"w-6 shrink-0 text-gray-400",children:"分类"}),e.jsx("p",{className:`truncate ${c?"text-gray-600":"text-gray-400"}`,title:c,children:c||(d?"分类名称暂不可用":"未分类")})]})]}):e.jsx(we,{enabled:!1,children:"未配置"})}function Ar({article:t,groups:r,canLoadGroups:n,onRetry:s}){var h;const c=t.navPlacements??[],d=(h=t.navname)==null?void 0:h.trim();return!t.navEnabled&&!d&&!c.length?e.jsx(we,{enabled:!1,children:"未设置"}):e.jsxs("div",{className:"min-w-0 space-y-1",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-2 leading-5",children:[e.jsx("span",{className:"w-12 shrink-0 text-xs text-gray-400",children:"导航名称"}),e.jsx("span",{title:d,className:"min-w-0 truncate text-sm font-medium text-gray-800",children:d||"尚未填写"}),e.jsx(we,{enabled:!!t.navEnabled,children:t.navEnabled?"已开启":"已关闭"})]}),t.navEnabled&&["header","footer"].map(x=>{const u=c.find(z=>z.position===x);if(!u)return null;const y=r[vt(t.host??"",x)],g=u.parentNavId?y==null?void 0:y.names[u.parentNavId]:void 0,w=n&&t.host&&(!y||y.status==="loading"),L=u.parentNavId?g?`${g} 分组内`:w?"正在加载分组…":"分组名称加载失败":"直接显示链接",T=x==="header"?"页眉":"页尾";return e.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-xs leading-5",children:[e.jsx("span",{className:"w-12 shrink-0 text-gray-400",children:T}),e.jsx("span",{title:`${T}:${L}`,className:"truncate text-gray-600",children:L}),u.parentNavId&&(y==null?void 0:y.status)==="error"&&e.jsx("button",{type:"button",onClick:s,className:"shrink-0 cursor-pointer text-blue-600 hover:underline",children:"重试"})]},x)}),t.navEnabled&&!c.length&&e.jsx("p",{className:"text-xs leading-5 text-amber-700",children:"未设置展示位置"})]})}const Rr=()=>{const{navigate:t}=Ve(),{basePath:r,service:n}=$e(),[s,c]=bt(),[d,h]=a.useState(""),[x,u]=a.useState(""),[y,g]=a.useState(!1),[w,L]=a.useState([]),[T,z]=a.useState({}),[H,W]=a.useState(0),[G,A]=a.useState({current:1,size:15,total:0}),Y=b=>{const _=b.trim();if(!_)return"";try{return new URL(_.startsWith("http")?_:`https://${_}`).origin}catch{return _}},S=async(b=G.current,_=G.size,M=d,f=x)=>{g(!0);try{const $={page:b,size:_};M&&($.pathname=M);const I=Y(f);I&&($.host=I);const V=await n.getList($);L(V.items),A(N=>({...N,current:b,size:_,total:V.total??N.total}))}catch($){te.error($.message||"获取文章失败")}finally{g(!1)}};a.useEffect(()=>{S(1)},[]),a.useEffect(()=>{if(!n.getNavigationGroups)return;let b=!0;const _=new Map;for(const M of w)if(M.host)for(const f of M.navPlacements??[]){if(!f.parentNavId)continue;const $=M.host.trim().replace(/\/+$/,"");_.set(vt($,f.position),{host:$,position:f.position})}z(Object.fromEntries([..._.keys()].map(M=>[M,{status:"loading",names:{}}])));for(const[M,f]of _)(async()=>{try{const $=await n.getNavigationGroups(f);if(!b)return;z(I=>({...I,[M]:{status:"loaded",names:Object.fromEntries($.map(V=>[V.id,V.name]))}}))}catch{if(!b)return;z($=>({...$,[M]:{status:"error",names:{}}}))}})();return()=>{b=!1}},[w,n,H]);const P=b=>{s.confirm({title:"删除文章",content:`确认删除 /${b.pathname}?`,okText:"删除",okType:"danger",cancelText:"取消",onOk:async()=>{await n.delete(b.id),te.success("删除成功"),S(1)}})},v=Math.ceil(G.total/G.size)||1;return e.jsxs("div",{className:"min-w-0 bg-white rounded-xl shadow-sm border border-gray-100 p-5",children:[c,e.jsxs("form",{className:"flex flex-wrap items-center gap-2 mb-5",onSubmit:b=>{b.preventDefault(),S(1)},children:[e.jsxs("div",{className:"relative w-full sm:w-52",children:[e.jsx(De,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400"}),e.jsx("input",{className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/30 focus:border-blue-400 transition","aria-label":"搜索访问路径",placeholder:"搜索访问路径",value:d,onChange:b=>h(b.target.value)})]}),e.jsxs("div",{className:"relative w-full sm:w-52",children:[e.jsx(De,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-gray-400"}),e.jsx("input",{className:"w-full pl-9 pr-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/30 focus:border-blue-400 transition","aria-label":"搜索网站地址",placeholder:"搜索网站地址",value:x,onChange:b=>u(b.target.value)})]}),e.jsxs("button",{type:"submit",className:"flex items-center gap-1.5 px-3 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-sm rounded-lg transition cursor-pointer",children:[e.jsx(De,{className:"w-3.5 h-3.5"}),"搜索"]}),e.jsxs("button",{type:"button",className:"flex items-center gap-1.5 px-3 py-1.5 border border-gray-200 hover:bg-gray-50 text-gray-600 text-sm rounded-lg transition cursor-pointer",onClick:()=>{h(""),u(""),S(1,G.size,"","")},children:[e.jsx(Cr,{className:"w-3.5 h-3.5"}),"重置"]}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{type:"button",onClick:()=>t(`${r}/create`),className:"flex cursor-pointer items-center gap-1.5 rounded-lg bg-blue-500 px-3 py-1.5 text-sm text-white transition hover:bg-blue-600",children:[e.jsx(Ye,{size:14,"aria-hidden":"true"}),"新增文章"]})]}),e.jsx("div",{className:"relative overflow-x-auto",role:"region","aria-label":"文章列表",tabIndex:0,children:e.jsxs("table",{className:"w-full min-w-[1120px] table-fixed text-left text-sm",children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"8%"}}),e.jsx("col",{style:{width:"16%"}}),e.jsx("col",{style:{width:"24%"}}),e.jsx("col",{style:{width:"23%"}}),e.jsx("col",{style:{width:"13%"}}),e.jsx("col",{style:{width:"16%"}})]}),e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-gray-100",children:[e.jsx("th",{scope:"col",className:"px-3 py-2.5 text-xs font-medium tracking-wide text-gray-400",children:"访问路径"}),e.jsx("th",{scope:"col",className:"px-3 py-2.5 text-xs font-medium tracking-wide text-gray-400",children:"访问地址"}),e.jsx("th",{scope:"col",className:"px-3 py-2.5 text-xs font-medium tracking-wide text-gray-400",children:"Guides 配置"}),e.jsx("th",{scope:"col",className:"px-3 py-2.5 text-xs font-medium tracking-wide text-gray-400",children:"网站导航"}),e.jsx("th",{scope:"col",className:"px-3 py-2.5 text-xs font-medium tracking-wide text-gray-400",children:"创建时间"}),e.jsx("th",{scope:"col",className:"sticky right-0 z-10 bg-white px-3 py-2.5 text-right text-xs font-medium tracking-wide text-gray-400",children:"操作"})]})}),e.jsx("tbody",{children:y||w.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:6,className:"py-16 text-center",children:e.jsxs("div",{className:"flex flex-col items-center gap-2 text-gray-400",children:[y?e.jsx(Se,{className:"h-6 w-6 animate-spin text-blue-400"}):e.jsx(fr,{className:"h-10 w-10 text-gray-300"}),e.jsx("span",{className:"text-sm",children:y?"正在加载文章…":"暂无文章"})]})})}):w.map(b=>{const _=`/${b.pathname.replace(/^\/+/,"")}`,M=b.host?`${b.host.replace(/\/+$/,"")}${_}`:void 0;return e.jsxs("tr",{className:"group border-b border-gray-50 transition-colors hover:bg-gray-50/60",children:[e.jsx("td",{className:"px-3 py-3 align-middle",children:e.jsx("button",{type:"button",onClick:()=>t(`${r}/${b.id}/detail`,{state:{record:b}}),title:_,className:"block max-w-full cursor-pointer truncate text-left font-mono text-xs text-gray-700 hover:text-blue-600 focus-visible:outline-2 focus-visible:outline-blue-500",children:_})}),e.jsx("td",{className:"px-3 py-3 align-middle",children:M?e.jsxs("a",{href:M,target:"_blank",rel:"noopener noreferrer",title:M,className:"inline-flex max-w-full items-center gap-1 text-xs text-blue-600 underline underline-offset-2 hover:text-blue-800",children:[e.jsx("span",{className:"truncate",children:M.replace(/^https?:\/\//,"")}),e.jsx(lr,{size:12,className:"shrink-0","aria-hidden":"true"})]}):e.jsx("span",{className:"text-xs text-gray-400",children:"未填写"})}),e.jsx("td",{className:"px-3 py-3 align-middle",children:e.jsx(zr,{article:b})}),e.jsx("td",{className:"px-3 py-3 align-middle",children:e.jsx(Ar,{article:b,groups:T,canLoadGroups:!!n.getNavigationGroups,onRetry:()=>W(f=>f+1)})}),e.jsx("td",{className:"whitespace-nowrap px-3 py-3 align-middle text-xs text-gray-400",children:b.createdAt?He(b.createdAt).format("YYYY/MM/DD HH:mm"):"—"}),e.jsx("td",{className:"sticky right-0 z-10 bg-white px-3 py-3 text-right align-middle transition-colors group-hover:bg-gray-50",children:e.jsxs("div",{className:"flex items-center justify-end gap-1",children:[e.jsx("button",{type:"button",onClick:()=>t(`${r}/${b.id}/detail`,{state:{record:b}}),className:"cursor-pointer whitespace-nowrap rounded-md border border-gray-200 px-2.5 py-1 text-xs text-gray-600 transition hover:bg-gray-50",children:"详情"}),e.jsx("button",{type:"button",onClick:()=>t(`${r}/${b.id}/edit`),className:"cursor-pointer whitespace-nowrap rounded-md bg-blue-500 px-2.5 py-1 text-xs text-white transition hover:bg-blue-600",children:"编辑"}),e.jsx("button",{type:"button",onClick:()=>P(b),className:"cursor-pointer whitespace-nowrap rounded-md bg-red-500 px-2.5 py-1 text-xs text-white transition hover:bg-red-600",children:"删除"})]})})]},b.id)})})]})}),G.total>0&&e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 pt-4 mt-2 border-t border-gray-100",children:[e.jsxs("span",{className:"text-xs text-gray-400",children:["共 ",G.total," 篇文章"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-1",children:[e.jsx("button",{className:"px-2.5 py-1 text-xs border border-gray-200 rounded-md hover:bg-gray-50 disabled:opacity-40 disabled:cursor-not-allowed text-gray-600 transition cursor-pointer",disabled:G.current<=1,onClick:()=>S(G.current-1),children:"上一页"}),e.jsxs("span",{className:"px-3 py-1 text-xs text-gray-500",children:[G.current," / ",v]}),e.jsx("button",{className:"px-2.5 py-1 text-xs border border-gray-200 rounded-md hover:bg-gray-50 disabled:opacity-40 disabled:cursor-not-allowed text-gray-600 transition cursor-pointer",disabled:G.current>=v,onClick:()=>S(G.current+1),children:"下一页"}),e.jsx("select",{"aria-label":"每页条数",className:"ml-2 text-xs border border-gray-200 rounded-md px-1.5 py-1 text-gray-600 focus:outline-none focus:ring-1 focus:ring-blue-400 cursor-pointer",value:G.size,onChange:b=>S(1,Number(b.target.value)),children:[10,15,20,50].map(b=>e.jsxs("option",{value:b,children:[b," 条/页"]},b))})]})]})]})};function jt({items:t,label:r,description:n,presentation:s="inline",saveOrder:c,onSaved:d,onCancel:h}){const x=a.useId(),[u,y]=a.useState(()=>[...t]),[g,w]=a.useState(!1),[L,T]=a.useState(""),[z,H]=a.useState(""),[W,G]=a.useState(null),[A,Y]=a.useState(null),S=a.useRef(null),P=a.useRef(null),v=a.useRef(null),b=a.useRef(null),_=a.useRef(new Map),M=a.useRef(null),f=a.useRef(!1),$=a.useRef(!1);a.useEffect(()=>{f.current=!0;const i=_.current;return()=>{f.current=!1,M.current&&clearTimeout(M.current),i.forEach(o=>o.cancel())}},[]);const I=()=>window.matchMedia("(prefers-reduced-motion: reduce)").matches,V=()=>{var i;return Array.from(((i=P.current)==null?void 0:i.querySelectorAll("[data-order-id]"))??[])},N=()=>{b.current=new Map(V().map(i=>[i.dataset.orderId,i.getBoundingClientRect().top]))};a.useLayoutEffect(()=>{const i=b.current;b.current=null;const o=V();if(_.current.forEach(C=>C.cancel()),_.current.clear(),!i||I())return;o.map(C=>({row:C,delta:(i.get(C.dataset.orderId)??C.getBoundingClientRect().top)-C.getBoundingClientRect().top})).forEach(({row:C,delta:R})=>{var K;C.dataset.orderId===((K=v.current)==null?void 0:K.id)||Math.abs(R)<1||_.current.set(C,C.animate([{transform:`translateY(${R}px)`},{transform:"translateY(0)"}],{duration:210,easing:"cubic-bezier(0.22, 1, 0.36, 1)"}))})},[u]);const l=u.some((i,o)=>{var j;return i.id!==((j=t[o])==null?void 0:j.id)}),m=(i,o)=>{const j=i+o;if($.current||v.current||j<0||j>=u.length)return;const C=[...u];[C[i],C[j]]=[C[j],C[i]],N(),y(C),T(""),H(`${u[i].name}已移至第 ${j+1} 位`)},k=(i,o)=>{var K;if($.current||v.current||!i.isPrimary||i.button!==0)return;const j=i.currentTarget.closest("[data-order-id]");if(!j||!P.current)return;const C=j.getBoundingClientRect(),R=P.current.getBoundingClientRect();(K=P.current)==null||K.setPointerCapture(i.pointerId),v.current={id:o.id,pointerId:i.pointerId,original:[...u],startX:i.clientX,offsetY:i.clientY-C.top,height:C.height,phase:"dragging"},Y({item:o,index:u.findIndex(q=>q.id===o.id),height:C.height,top:C.top-R.top}),G(o.id),T(""),H(`已拿起${o.name},上下拖动调整顺序,按 Escape 取消。`)},p=i=>{const o=v.current;if(!o||o.phase!=="dragging"||o.pointerId!==i.pointerId||!P.current)return;const j=i.clientY,C=P.current.getBoundingClientRect(),R=Math.max(0,Math.min(C.height-o.height,j-C.top-o.offsetY)),K=Math.max(-16,Math.min(16,i.clientX-o.startX)),q=V(),Q=R+o.height/2,Z=q.find(X=>Q>=X.offsetTop&&Q<=X.offsetTop+X.offsetHeight),ee=Z==null?void 0:Z.dataset.orderId,re=u.findIndex(X=>X.id===o.id),ne=u.findIndex(X=>X.id===ee);if(Z&&re>=0&&ne>=0&&re!==ne&&(re<ne?Q>=Z.offsetTop+Z.offsetHeight/2:Q<=Z.offsetTop+Z.offsetHeight/2)){N();const X=[...u],[Me]=X.splice(re,1);X.splice(ne,0,Me),y(X)}S.current&&(S.current.style.transform=`translate3d(${K}px, ${R}px, 0)`)},E=(i=!1)=>{var K,q;const o=v.current;if(!o||o.phase==="dropping")return;o.phase="dropping",(K=P.current)!=null&&K.hasPointerCapture(o.pointerId)&&P.current.releasePointerCapture(o.pointerId);const j=()=>{v.current=null,M.current=null,G(null),Y(null)};if(i){N(),y(o.original),H("已取消本次拖动。"),j();return}const C=u.findIndex(Q=>Q.id===o.id);H(`${((q=u[C])==null?void 0:q.name)??r}已移至第 ${C+1} 位。`);const R=V().find(Q=>Q.dataset.orderId===o.id);if(!S.current||!R||I()){j();return}S.current.dataset.dropping="true",S.current.style.transform=`translate3d(0, ${R.offsetTop}px, 0)`,M.current=setTimeout(j,190)},O=async()=>{if(!(!l||$.current||v.current)){$.current=!0,w(!0),T("");try{const i=await c(u.map(o=>o.id));f.current&&d(i)}catch(i){if(f.current){const o=i==null?void 0:i.status;T(o===404||o===405||o===501?`当前服务暂不支持保存${r}顺序,请联系管理员开通。`:o===409?`${r}已发生变化,请取消后重新打开排序。`:i instanceof Error?i.message:"顺序保存失败,请重试")}}finally{$.current=!1,f.current&&w(!1)}}};return e.jsxs("section",{"aria-labelledby":`${x}-title`,"aria-busy":g,className:s==="dialog"?"p-6":"mt-3 rounded-lg border border-gray-200 bg-white p-3",children:[e.jsxs("h3",{id:`${x}-title`,className:"text-sm font-medium text-gray-700",children:[r,"顺序"]}),e.jsx("p",{className:"mt-1 text-xs leading-5 text-gray-500",children:n}),e.jsx("p",{id:`${x}-drag-hint`,className:"mt-1 text-xs text-gray-400",children:"拖动左侧手柄或点击上下箭头调整,完成后保存顺序。"}),e.jsxs("ol",{ref:P,"aria-label":`${r}展示顺序`,className:`aisee-order-list relative mt-3 space-y-2 ${W?"aisee-order-list--dragging select-none":""}`,onPointerMove:p,onPointerUp:i=>{var o;((o=v.current)==null?void 0:o.pointerId)===i.pointerId&&E()},onPointerCancel:()=>E(!0),onLostPointerCapture:()=>E(!0),children:[u.map((i,o)=>e.jsxs("li",{"data-order-id":i.id,className:`aisee-order-row relative flex min-w-0 items-center gap-2 rounded-lg border px-2.5 py-2 ${W===i.id?"aisee-order-row--placeholder":"border-gray-100 bg-white"}`,children:[e.jsx("button",{type:"button","aria-label":`拖动 ${i.name}`,"aria-describedby":`${x}-drag-hint`,disabled:g,onPointerDown:j=>k(j,i),onKeyDown:j=>{j.key==="Escape"&&v.current&&(j.preventDefault(),j.stopPropagation(),E(!0)),(j.key==="ArrowUp"||j.key==="ArrowDown")&&(j.preventDefault(),m(o,j.key==="ArrowUp"?-1:1))},className:`flex h-8 w-8 shrink-0 touch-none select-none items-center justify-center rounded-md text-gray-400 hover:bg-gray-100 hover:text-gray-600 focus-visible:outline-2 focus-visible:outline-blue-500 disabled:cursor-not-allowed disabled:opacity-30 ${W===i.id?"cursor-grabbing":"cursor-grab"}`,children:e.jsx(Xe,{size:16,"aria-hidden":"true"})}),e.jsx("span",{"aria-hidden":"true",className:"w-5 shrink-0 text-xs text-gray-400",children:o+1}),e.jsx("span",{className:"min-w-0 flex-1 break-words text-sm text-gray-700",children:i.name}),e.jsx("button",{type:"button","aria-label":`上移 ${i.name}`,disabled:g||o===0,onClick:()=>m(o,-1),className:"flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-gray-200 text-gray-500 enabled:hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-30",children:e.jsx(Qt,{size:14,"aria-hidden":"true"})}),e.jsx("button",{type:"button","aria-label":`下移 ${i.name}`,disabled:g||o===u.length-1,onClick:()=>m(o,1),className:"flex h-8 w-8 shrink-0 cursor-pointer items-center justify-center rounded-md border border-gray-200 text-gray-500 enabled:hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-30",children:e.jsx(Kt,{size:14,"aria-hidden":"true"})}),W===i.id&&e.jsxs("span",{"aria-hidden":"true",className:"aisee-order-placeholder-label",children:["放到这里 · 第 ",o+1," 位"]})]},i.id)),A&&e.jsx("li",{ref:S,"aria-hidden":"true",className:"aisee-order-floating",style:{height:A.height,transform:`translate3d(0, ${A.top}px, 0)`},children:e.jsxs("div",{className:"aisee-order-floating-card",children:[e.jsx(Xe,{size:16,className:"shrink-0 text-blue-500"}),e.jsx("span",{className:"w-5 shrink-0 text-xs text-blue-400",children:A.index+1}),e.jsx("span",{className:"min-w-0 flex-1 break-words text-sm font-medium text-gray-800",children:A.item.name}),e.jsx("span",{className:"shrink-0 rounded-md bg-blue-100 px-2 py-1 text-xs font-medium text-blue-600",children:"拖动中"})]})})]}),e.jsx("span",{role:"status",className:"sr-only",children:z}),L&&e.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-500",children:L}),e.jsxs("div",{className:"mt-3 flex flex-wrap justify-end gap-2",children:[e.jsx("button",{type:"button",disabled:g,onClick:h,className:"cursor-pointer rounded-lg border border-gray-200 px-3 py-1.5 text-xs text-gray-600 hover:bg-gray-50 disabled:opacity-50",children:"取消"}),e.jsxs("button",{type:"button",disabled:g||!l,onClick:()=>void O(),className:"flex cursor-pointer items-center gap-1 rounded-lg bg-blue-500 px-3 py-1.5 text-xs text-white hover:bg-blue-600 disabled:cursor-not-allowed disabled:opacity-50",children:[g&&e.jsx(Se,{size:12,className:"animate-spin","aria-hidden":"true"}),g?"保存中…":"保存顺序"]})]})]})}function Hr({host:t,position:r,groups:n,reorder:s,onSaved:c,onCancel:d}){return e.jsx(jt,{items:n,label:"父导航",description:"前台按此顺序从左到右展示。保存后对该网站的所有文章生效。",presentation:"dialog",saveOrder:h=>s({host:t,position:r,groupIds:h}),onSaved:c,onCancel:d})}function wt({id:t,open:r,busy:n,label:s,onDismiss:c,children:d}){const h=a.useRef(null);return a.useEffect(()=>{var x,u,y;r&&!((x=h.current)!=null&&x.open)&&((u=h.current)==null||u.showModal()),!r&&((y=h.current)!=null&&y.open)&&h.current.close()},[r]),e.jsx("dialog",{ref:h,id:t,"aria-label":s,onCancel:x=>{x.preventDefault(),n||c()},className:"m-auto max-h-[85vh] w-[calc(100%_-_2rem)] max-w-xl overflow-y-auto rounded-2xl border border-gray-200 bg-white p-0 text-gray-700 shadow-xl backdrop:bg-black/30",children:d})}const Gr=[{position:"header",label:"页眉",icon:pr,parentEnabled:!1},{position:"footer",label:"页尾",icon:Nr,parentEnabled:!0}],Ge="w-full min-w-0 rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm text-gray-700 outline-none transition focus:border-blue-400 focus:ring-2 focus:ring-blue-500/20";function Wr({host:t,position:r,label:n,parentEnabled:s,service:c,parentNavId:d,onSelect:h}){const x=a.useId(),[u,y]=a.useState([]),[g,w]=a.useState(!1),[L,T]=a.useState(""),[z,H]=a.useState(!1),[W,G]=a.useState(""),[A,Y]=a.useState(""),[S,P]=a.useState(!1),[v,b]=a.useState(!1),[_,M]=a.useState(!1),[f,$]=a.useState(!1),I=a.useRef(0),V=a.useRef(0),N=a.useRef(h);N.current=h;const l=c.getNavigationGroups,m=c.createNavigationGroup,k=c.reorderNavigationGroups,p=a.useCallback(async()=>{if(!t||!l)return;const o=++V.current;w(!0),T("");try{const j=await l({host:t,position:r});return o!==V.current?void 0:(y(j),j)}catch(j){o===V.current&&T(j instanceof Error?j.message:"父导航加载失败")}finally{o===V.current&&w(!1)}},[t,r,l]);a.useEffect(()=>(I.current++,p(),()=>{I.current++,V.current++}),[p]);const E=async()=>{if(S||!m||!s)return;const o=W.trim();if(!o){Y("请输入父导航名称");return}const j=u.find(R=>R.name===o);if(j){N.current(j.id),H(!1);return}const C=I.current;P(!0),Y("");try{const R=await m({host:t,position:r,name:o});if(C!==I.current)return;y(K=>[...K.filter(q=>q.id!==R.id),R]),N.current(R.id),H(!1),G(""),p()}catch(R){if(C!==I.current)return;if((R==null?void 0:R.status)===409){const K=await p();if(C!==I.current)return;const q=K==null?void 0:K.find(Q=>Q.name===o);if(q){N.current(q.id),H(!1),G("");return}}Y(R instanceof Error?R.message:"新增父导航失败")}finally{C===I.current&&P(!1)}},O=!!d&&!u.some(o=>o.id===d),i=async()=>{const o=I.current;M(!1);const j=await p();j&&o===I.current&&j.length>1&&b(!0)};return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("label",{htmlFor:x,className:"block text-sm font-medium text-gray-700",children:["所属父导航 ",e.jsx("span",{className:"font-normal text-gray-400",children:"(可选)"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[s&&k&&t&&e.jsxs("button",{type:"button",disabled:g||S||z||v||!!L||u.length<2,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":`${x}-dialog`,onClick:()=>void i(),className:"flex cursor-pointer items-center gap-1 text-xs text-blue-500 enabled:hover:text-blue-600 disabled:cursor-not-allowed disabled:opacity-40",children:[e.jsx(mt,{size:12,"aria-hidden":"true"}),"调整顺序"]}),s&&m&&t&&e.jsxs("button",{type:"button",disabled:g||S||z||v,"aria-label":`新增${n}父导航`,"aria-haspopup":"dialog",onClick:()=>{H(!0),G(""),Y(""),M(!1)},className:"flex cursor-pointer items-center gap-1 text-xs text-blue-500 enabled:hover:text-blue-600 disabled:opacity-40",children:[e.jsx(Ye,{size:13,"aria-hidden":"true"}),"新增父导航"]})]})]}),e.jsxs("select",{id:x,"aria-label":`${n}父导航`,disabled:!s||!t||g||S||z||v,value:d??"",onChange:o=>h(o.target.value||null),className:`${Ge} disabled:cursor-not-allowed disabled:bg-gray-50 disabled:text-gray-400`,children:[e.jsx("option",{value:"",children:s?"不选分组(直接显示在页尾)":"暂不支持设置"}),u.map(o=>e.jsx("option",{value:o.id,children:o.name},o.id)),O&&e.jsxs("option",{value:d,children:["已选父导航(",d,")"]})]}),e.jsx("p",{className:"mt-1.5 text-xs text-gray-400",children:s?t?d?u.some(o=>o.id===d)?`文章链接会显示在「${u.find(o=>o.id===d).name}」分组下。`:"文章链接会显示在所选分组下。":"不选父导航时,链接直接显示在网站底部。":"请先填写网站地址":d?"已保存的页眉父导航暂不可修改。":"页眉目前只能直接显示文章链接。"}),g&&e.jsx("p",{role:"status",className:"mt-2 text-xs text-gray-500",children:"加载父导航中…"}),L&&e.jsxs("p",{role:"alert",className:"mt-2 text-xs text-red-500",children:[L,e.jsx("button",{type:"button",onClick:()=>void p(),className:"ml-2 cursor-pointer text-blue-500",children:"重试"})]}),_&&e.jsx("p",{role:"status",className:"mt-2 text-xs text-green-600",children:"父导航顺序已保存"}),e.jsx(wt,{id:`${x}-dialog`,open:v||z,busy:S||f,label:v?"父导航顺序":z?`新增${n}父导航`:void 0,onDismiss:()=>{H(!1),b(!1),Y("")},children:v&&k?e.jsx(Hr,{host:t,position:r,groups:u,reorder:async o=>{const j=I.current;$(!0);try{return await k(o)}finally{j===I.current&&$(!1)}},onSaved:o=>{y(o),b(!1),M(!0)},onCancel:()=>b(!1)}):z?e.jsxs("div",{className:"p-6",children:[e.jsxs("h3",{className:"text-sm font-medium text-gray-700",children:["新增",n,"父导航"]}),e.jsxs("label",{htmlFor:`${x}-new`,className:"mb-1.5 mt-3 block text-xs text-gray-600",children:["父导航名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${x}-new`,autoFocus:!0,maxLength:100,value:W,disabled:S,placeholder:"输入父导航名称","aria-invalid":!!A,"aria-describedby":A?`${x}-error`:void 0,onChange:o=>{G(o.target.value),Y("")},onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing&&(o.preventDefault(),E())},className:Ge}),A&&e.jsx("p",{id:`${x}-error`,role:"alert",className:"mt-1.5 text-xs text-red-500",children:A}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",disabled:S,onClick:()=>void E(),className:"flex cursor-pointer items-center gap-1 rounded-lg bg-blue-500 px-2.5 py-1.5 text-xs text-white hover:bg-blue-600 disabled:opacity-50",children:[S?e.jsx(Se,{size:12,className:"animate-spin"}):e.jsx(xt,{size:12,"aria-hidden":"true"}),S?"添加中…":"添加并选中"]}),e.jsxs("button",{type:"button",disabled:S,onClick:()=>H(!1),className:"flex cursor-pointer items-center gap-1 rounded-lg px-2.5 py-1.5 text-xs text-gray-500 hover:bg-gray-100 disabled:opacity-50",children:[e.jsx(yt,{size:12,"aria-hidden":"true"}),"取消"]})]})]}):null})]})}function Vr({host:t,service:r,value:n,onChange:s}){const c=a.useId(),d=t.trim().replace(/\/+$/,""),[h,x]=a.useState(!1),u=!!r.getNavigationGroups,y=w=>s({...n,...w}),g=(w,L)=>{y({navPlacements:L?[...n.navPlacements,{position:w,parentNavId:null}]:n.navPlacements.filter(T=>T.position!==w)})};return e.jsxs("section",{"aria-label":"导航设置",className:"mt-5 border-t border-gray-100 pt-5",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-800",children:"导航设置"}),e.jsxs("label",{htmlFor:`${c}-enabled`,className:"flex cursor-pointer items-center gap-2 text-sm text-gray-600",children:[e.jsx("span",{children:"启用导航"}),e.jsxs("span",{className:"relative inline-flex h-5 w-9 shrink-0 items-center",children:[e.jsx("input",{id:`${c}-enabled`,type:"checkbox",role:"switch",checked:n.navEnabled,disabled:!u,"aria-controls":`${c}-fields`,onChange:w=>y({navEnabled:w.target.checked}),className:"peer absolute inset-0 z-10 m-0 h-full w-full cursor-pointer opacity-0 disabled:cursor-not-allowed"}),e.jsx("span",{"aria-hidden":"true",className:"absolute inset-0 rounded-full bg-gray-200 transition peer-checked:bg-blue-500 peer-disabled:opacity-50 peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2 peer-focus-visible:outline-blue-500"}),e.jsx("span",{"aria-hidden":"true",className:"pointer-events-none relative ml-0.5 h-4 w-4 rounded-full bg-white shadow-sm transition-transform peer-checked:translate-x-4"})]})]})]}),u&&n.navEnabled&&e.jsx("p",{className:"mt-1.5 text-xs leading-5 text-gray-500",children:"在网站顶部或底部显示这篇文章的链接。"}),u?n.navEnabled?e.jsxs("div",{id:`${c}-fields`,className:"mt-4 space-y-4 rounded-xl border border-gray-200 bg-gray-50/40 p-4",children:[e.jsxs("div",{className:"max-w-3xl",children:[e.jsxs("label",{htmlFor:`${c}-name`,className:"mb-1.5 block text-sm font-medium text-gray-700",children:["导航名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${c}-name`,value:n.navname,maxLength:100,placeholder:"输入导航名称",required:!0,"aria-invalid":h&&!n.navname.trim(),"aria-describedby":h&&!n.navname.trim()?`${c}-name-error`:void 0,onChange:w=>y({navname:w.target.value}),onBlur:()=>x(!0),className:Ge}),e.jsx("p",{className:"mt-1.5 text-xs text-gray-400",children:"前台显示的链接名称,例如「关于我们」。"}),h&&!n.navname.trim()&&e.jsx("p",{id:`${c}-name-error`,role:"alert",className:"mt-1.5 text-xs text-red-500",children:"开启导航后,请填写导航名称"})]}),e.jsxs("fieldset",{"aria-describedby":`${c}-placements-hint`,className:"min-w-0",children:[e.jsxs("legend",{className:"mb-1.5 text-sm font-medium text-gray-700",children:["展示位置 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:Gr.map(({position:w,label:L,icon:T,parentEnabled:z})=>{const H=n.navPlacements.find(W=>W.position===w);return e.jsxs("div",{role:"group","aria-label":`${L}导航设置`,className:`min-w-0 self-start rounded-lg border p-3 transition-colors ${H?"border-blue-200 bg-blue-50/30":"border-gray-200 bg-white"}`,children:[e.jsxs("label",{className:"flex cursor-pointer items-center gap-2.5 text-sm text-gray-700",children:[e.jsx("input",{type:"checkbox",checked:!!H,onChange:W=>g(w,W.target.checked),className:"h-4 w-4 shrink-0 accent-blue-500"}),e.jsx(T,{size:15,className:"shrink-0 text-gray-400","aria-hidden":"true"}),e.jsx("span",{className:"font-medium",children:L})]}),e.jsx("p",{className:"mt-1.5 text-xs text-gray-500",children:w==="header"?"文章链接显示在网站顶部。":"文章链接显示在网站底部。"}),H&&e.jsx("div",{className:"mt-3 border-t border-gray-200/70 pt-3",children:e.jsx(Wr,{host:d,position:w,label:L,parentEnabled:z,service:r,parentNavId:H.parentNavId,onSelect:W=>y({navPlacements:n.navPlacements.map(G=>G.position===w?{...G,parentNavId:W}:G)})},`${d}:${w}`)})]},w)})}),e.jsx("p",{id:`${c}-placements-hint`,className:"mt-1.5 text-xs text-gray-400",children:"可以同时勾选页眉和页尾。"}),n.navPlacements.length===0&&e.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-500",children:"请至少选择一个展示位置"})]})]}):e.jsx("p",{className:"mt-1.5 text-xs text-gray-500",children:"开启后可将文章加入页眉、页尾或同时加入两处。"}):e.jsx("p",{className:"mt-1.5 text-xs text-gray-500",children:"当前服务尚未接入导航配置"})]})}const xe="w-full min-w-0 rounded-lg border border-gray-200 bg-white px-3 py-2 text-sm text-gray-700 outline-none transition focus:border-blue-400 focus:ring-2 focus:ring-blue-500/20";function qr({value:t,categories:r,categoriesDisabled:n=!1,onChange:s,onSaveCategory:c,onLoadCategories:d,onReorderCategories:h}){const x=a.useId(),[u,y]=a.useState(null),[g,w]=a.useState(""),[L,T]=a.useState(!1),[z,H]=a.useState(""),[W,G]=a.useState(!1),[A,Y]=a.useState(null),[S,P]=a.useState(!1),[v,b]=a.useState(""),[_,M]=a.useState(!1),f=!!u||!!A,$=a.useRef(!1),I=a.useRef(!1),V=a.useRef(!1);a.useEffect(()=>(I.current=!0,()=>{I.current=!1}),[]);const N=r.find(i=>i.id===t.categoryId),l=t.categoryId?void 0:t.category,m=(N==null?void 0:N.description)??(l==null?void 0:l.description),k=a.useRef(t);k.current=t;const p=i=>s({...t,...i}),E=async()=>{if(!($.current||!h||n||u||A)){$.current=!0,P(!0),b(""),H("");try{const i=d?await d():r;I.current&&Y(i)}catch(i){I.current&&b(i instanceof Error?i.message:"分类加载失败,请重试")}finally{$.current=!1,I.current&&P(!1)}}},O=async()=>{if(!u||!c||V.current)return;const i=u.name.trim();if(!i){w("请输入分类名称");return}if(r.some(o=>o.id!==u.id&&o.name===i)){w("该分类名称已存在,请选择已有分类或使用其他名称");return}V.current=!0,G(!0),w("");try{const o=await c({...u.id?{id:u.id}:{},name:i,description:u.description.trim()});if(!I.current)return;s({...k.current,categoryId:o.id}),H(u.id?"分类已更新":"分类已新增并选中"),y(null)}catch(o){I.current&&w(o instanceof Error?o.message:"分类保存失败,请重试")}finally{V.current=!1,I.current&&G(!1)}};return e.jsxs("section",{"aria-labelledby":`${x}-heading`,className:"mt-5 border-t border-gray-100 pt-5",children:[e.jsx("h2",{id:`${x}-heading`,className:"text-sm font-semibold text-gray-800",children:"Guides 展示设置"}),e.jsx("p",{className:"mt-1.5 text-xs leading-5 text-gray-500",children:"用于 Guides 页面的文章展示,分类可选。"}),e.jsxs("div",{className:"mt-4 grid grid-cols-1 gap-x-6 gap-y-4 rounded-xl border border-gray-200 bg-gray-50/40 p-4 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2",children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsxs("label",{htmlFor:`${x}-title`,className:"text-sm font-medium text-gray-700",children:["文章标题 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("span",{className:"text-xs text-gray-400",children:"用于文章卡片"})]}),e.jsx("input",{id:`${x}-title`,value:t.title,maxLength:200,required:!0,placeholder:"例如 White-Hat GEO: Ethical Optimization for AI Search",onChange:i=>p({title:i.target.value}),onBlur:()=>T(!0),"aria-invalid":L&&!t.title.trim(),"aria-describedby":`${x}-title-hint`,className:xe}),e.jsx("p",{id:`${x}-title-hint`,className:`mt-1.5 text-xs ${L&&!t.title.trim()?"text-red-500":"text-gray-400"}`,role:L&&!t.title.trim()?"alert":void 0,children:L&&!t.title.trim()?"请输入文章展示标题":"可使用比导航名称更完整的标题。"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("label",{htmlFor:`${x}-category`,className:"text-sm font-medium text-gray-700",children:["所属分类 ",e.jsx("span",{className:"font-normal text-gray-400",children:"(可选)"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[h&&e.jsxs("button",{type:"button",disabled:n||f||S||r.length<2,"aria-haspopup":"dialog","aria-expanded":!!A,"aria-controls":`${x}-dialog`,onClick:()=>void E(),className:"flex cursor-pointer items-center gap-1 text-xs text-blue-500 enabled:hover:text-blue-600 disabled:opacity-40",children:[e.jsx(mt,{size:12,"aria-hidden":"true"}),"调整顺序"]}),c&&e.jsxs("button",{type:"button",disabled:n||f||S,"aria-haspopup":"dialog",onClick:()=>{y({id:null,name:"",description:""}),w(""),H(""),b("")},className:"flex cursor-pointer items-center gap-1 text-xs text-blue-500 enabled:hover:text-blue-600 disabled:opacity-40",children:[e.jsx(Ye,{size:13,"aria-hidden":"true"}),"新增分类"]})]})]}),e.jsxs("select",{id:`${x}-category`,value:l?"__unresolved-category__":t.categoryId??"",disabled:n||f||S,onChange:i=>{p({categoryId:i.target.value||null,category:void 0}),H("")},className:`${xe} disabled:bg-gray-50 disabled:text-gray-400`,children:[e.jsx("option",{value:"",children:"不设置分类"}),l&&e.jsxs("option",{value:"__unresolved-category__",disabled:!0,children:[l.name,"(请重新选择)"]}),r.map(i=>e.jsx("option",{value:i.id,children:i.name},i.id)),t.categoryId&&!N&&e.jsxs("option",{value:t.categoryId,children:["已选分类(",t.categoryId,")"]})]}),e.jsx("p",{className:`mt-1.5 text-xs ${l?"text-amber-700":"text-gray-400"}`,children:l?"无法确认已保存的分类,请重新选择后保存。":"可留空,不影响文章保存。"}),S&&e.jsx("p",{role:"status",className:"mt-2 text-xs text-gray-500",children:"加载分类顺序中…"}),v&&e.jsx("p",{role:"alert",className:"mt-2 text-xs text-red-500",children:v}),z&&e.jsx("p",{role:"status",className:"mt-2 text-xs text-green-600",children:z})]}),e.jsxs("div",{className:N||l?"lg:col-span-2":"lg:col-span-3",children:[e.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[e.jsxs("label",{htmlFor:`${x}-description`,className:"text-sm font-medium text-gray-700",children:["文章简介 ",e.jsx("span",{className:"font-normal text-gray-400",children:"(可选)"})]}),e.jsxs("span",{className:"text-xs text-gray-400",children:[t.description.length,"/500"]})]}),e.jsx("textarea",{id:`${x}-description`,rows:2,maxLength:500,value:t.description,placeholder:"简要介绍文章内容,展示在卡片标题下方",onChange:i=>p({description:i.target.value}),className:`${xe} resize-y leading-6`})]}),(N||l)&&e.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white p-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-xs font-medium text-gray-500",children:"分类描述"}),N&&c&&e.jsxs("button",{type:"button",disabled:n||S,"aria-haspopup":"dialog",onClick:()=>{y({...N}),w(""),H(""),b("")},className:"flex shrink-0 cursor-pointer items-center gap-1 text-xs text-blue-500 hover:text-blue-600 disabled:opacity-40",children:[e.jsx(ft,{size:12,"aria-hidden":"true"}),"编辑分类"]})]}),e.jsx("p",{className:"mt-2 break-words text-xs leading-5 text-gray-500",children:m||"未填写分类描述"})]})]}),e.jsx(wt,{id:`${x}-dialog`,open:f,busy:W||_,label:A?"分类顺序":u?u.id?"编辑分类":"新增分类":void 0,onDismiss:()=>{y(null),Y(null),w("")},children:A&&h?e.jsx(jt,{items:A,label:"分类",description:"Guides 页面按此顺序从上到下展示分类。保存后对该网站的所有文章生效,不改变文章所属分类。",presentation:"dialog",saveOrder:async i=>{M(!0);try{return await h(i)}finally{I.current&&M(!1)}},onSaved:()=>{Y(null),H("分类顺序已保存")},onCancel:()=>Y(null)}):u?e.jsxs("fieldset",{disabled:W,className:"p-6",children:[e.jsx("h3",{className:"text-sm font-medium text-gray-700",children:u.id?"编辑分类":"新增分类"}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("label",{htmlFor:`${x}-category-name`,className:"mb-1.5 block text-xs text-gray-600",children:["分类名称 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{id:`${x}-category-name`,autoFocus:!0,maxLength:100,value:u.name,"aria-invalid":!!g,"aria-describedby":g?`${x}-category-error`:void 0,placeholder:"例如 Start with the foundations",onChange:i=>{y({...u,name:i.target.value}),w("")},className:xe})]}),e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{htmlFor:`${x}-category-description`,className:"mb-1.5 block text-xs text-gray-600",children:"分类描述"}),e.jsx("textarea",{id:`${x}-category-description`,rows:3,maxLength:500,value:u.description,placeholder:"介绍这个分类包含的内容,展示在分类名称下方",onChange:i=>y({...u,description:i.target.value}),className:`${xe} resize-y leading-6`})]}),u.id&&e.jsx("p",{className:"mt-2 text-xs leading-5 text-amber-700",children:"分类由多篇文章共用,修改名称和描述会同步影响该分类下的所有文章。"}),g&&e.jsx("p",{id:`${x}-category-error`,role:"alert",className:"mt-2 text-xs text-red-500",children:g}),e.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void O(),className:"flex cursor-pointer items-center gap-1 rounded-lg bg-blue-500 px-3 py-1.5 text-xs text-white hover:bg-blue-600 disabled:opacity-50",children:[W?e.jsx(Se,{size:12,className:"animate-spin","aria-hidden":"true"}):e.jsx(xt,{size:12,"aria-hidden":"true"}),W?"保存中…":u.id?"保存分类":"新增并选中"]}),e.jsxs("button",{type:"button",onClick:()=>{y(null),w("")},className:"flex cursor-pointer items-center gap-1 rounded-lg px-3 py-1.5 text-xs text-gray-500 hover:bg-gray-100",children:[e.jsx(yt,{size:12,"aria-hidden":"true"}),"取消"]})]})]}):null})]})}function Yr(t){var n;const r=t.categoryId!==void 0?t.categoryId:((n=t.category)==null?void 0:n.id)??null;return{title:t.title,description:t.description,categoryId:r}}function Fr(t){return t.split(/(“[^”]+”|"[^"]+")/g).map((r,n)=>/^(“.*”|".*")$/.test(r)?e.jsx("code",{className:"rounded bg-gray-100 px-1 py-0.5 font-mono text-[11px] text-gray-800",children:r.slice(1,-1)},n):r)}function Br({errors:t,source:r}){const[n,s]=a.useState(null),c=r.split(`
|
|
172
|
+
`);return e.jsxs("div",{children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center gap-3 border-b border-gray-100 bg-white px-4 py-3.5",children:[e.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-lg bg-red-50 text-red-500",children:e.jsx(sr,{size:18,strokeWidth:1.75})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-sm font-semibold text-gray-900",children:"HTML 校验"}),e.jsx("div",{className:"mt-0.5 text-xs text-gray-500",children:"点击问题查看详情"})]}),e.jsxs("span",{className:"shrink-0 rounded-full bg-red-50 px-2.5 py-1 text-xs font-medium text-red-600",children:[t.length," 个问题"]})]}),e.jsx("ol",{className:"m-0 list-none divide-y divide-gray-100 p-0",children:t.map((d,h)=>{var y,g;const x=(d.lastLine?(y=c[d.lastLine-1])==null?void 0:y.trim():"")||((g=d.extract)==null?void 0:g.trim()),u=n===h;return e.jsxs("li",{children:[e.jsxs("button",{type:"button","aria-expanded":u,onClick:()=>s(u?null:h),className:`flex w-full cursor-pointer items-center gap-2.5 px-4 py-3 text-left transition-colors hover:bg-gray-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-blue-400 ${u?"bg-gray-50":""}`,children:[e.jsx("span",{className:"h-1.5 w-1.5 shrink-0 rounded-full bg-red-400"}),e.jsx("span",{className:"w-16 shrink-0 font-mono text-[11px] text-gray-500",children:d.lastLine!=null?`第 ${d.lastLine} 行`:`问题 ${h+1}`}),e.jsx("span",{className:"min-w-0 flex-1 truncate text-xs leading-5 text-gray-700",children:d.message.replace(/[“”"]/g,"")}),e.jsx(rr,{size:14,className:`shrink-0 text-gray-400 transition-transform ${u?"rotate-180":""}`})]}),u&&e.jsxs("div",{className:"border-t border-gray-100 px-4 pb-4 pt-3",children:[d.lastColumn!=null&&e.jsxs("div",{className:"mb-2 font-mono text-[11px] text-gray-400",children:["第 ",d.lastColumn," 列"]}),e.jsx("p",{className:"m-0 text-[13px] leading-6 text-gray-600",children:Fr(d.message)}),x&&e.jsxs("div",{className:"mt-3 overflow-hidden rounded-lg border border-gray-100 bg-gray-50",children:[e.jsxs("div",{className:"flex items-center gap-1.5 border-b border-gray-100 px-3 py-1.5 text-[10px] font-medium uppercase tracking-wider text-gray-400",children:[e.jsx(qe,{size:11})," 源代码"]}),e.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words px-3 py-2.5 font-mono text-[11px] leading-5 text-gray-600",children:x})]})]})]},h)})})]})}async function tt(t){const r=new AbortController,n=setTimeout(()=>r.abort(),1e4);try{const s=await fetch("https://validator.w3.org/nu/?out=json",{method:"POST",headers:{"Content-Type":"text/html; charset=utf-8","User-Agent":"AiSee-Manage/1.0"},body:t,signal:r.signal});if(!s.ok)throw new Error(`W3C validator responded with ${s.status}`);const h=((await s.json()).messages||[]).filter(x=>x.type==="error");return{isValid:h.length===0,errors:h}}catch(s){return console.error("W3C 校验请求失败:",s),{isValid:!0,errors:[],networkError:!0}}finally{clearTimeout(n)}}function rt(t,r){(r==null||r>t.length)&&(r=t.length);for(var n=0,s=Array(r);n<r;n++)s[n]=t[n];return s}function Ur(t){if(Array.isArray(t))return t}function Kr(t,r,n){return(r=rn(r))in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function Zr(t,r){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var s,c,d,h,x=[],u=!0,y=!1;try{if(d=(n=n.call(t)).next,r!==0)for(;!(u=(s=d.call(n)).done)&&(x.push(s.value),x.length!==r);u=!0);}catch(g){y=!0,c=g}finally{try{if(!u&&n.return!=null&&(h=n.return(),Object(h)!==h))return}finally{if(y)throw c}}return x}}function Jr(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
173
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nt(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);r&&(s=s.filter(function(c){return Object.getOwnPropertyDescriptor(t,c).enumerable})),n.push.apply(n,s)}return n}function st(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?nt(Object(n),!0).forEach(function(s){Kr(t,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):nt(Object(n)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(n,s))})}return t}function Xr(t,r){if(t==null)return{};var n,s,c=Qr(t,r);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(t);for(s=0;s<d.length;s++)n=d[s],r.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(c[n]=t[n])}return c}function Qr(t,r){if(t==null)return{};var n={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(r.indexOf(s)!==-1)continue;n[s]=t[s]}return n}function en(t,r){return Ur(t)||Zr(t,r)||nn(t,r)||Jr()}function tn(t,r){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var s=n.call(t,r);if(typeof s!="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(t)}function rn(t){var r=tn(t,"string");return typeof r=="symbol"?r:r+""}function nn(t,r){if(t){if(typeof t=="string")return rt(t,r);var n={}.toString.call(t).slice(8,-1);return n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set"?Array.from(t):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?rt(t,r):void 0}}function sn(t,r,n){return r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,t}function at(t,r){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);r&&(s=s.filter(function(c){return Object.getOwnPropertyDescriptor(t,c).enumerable})),n.push.apply(n,s)}return n}function it(t){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?at(Object(n),!0).forEach(function(s){sn(t,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):at(Object(n)).forEach(function(s){Object.defineProperty(t,s,Object.getOwnPropertyDescriptor(n,s))})}return t}function an(){for(var t=arguments.length,r=new Array(t),n=0;n<t;n++)r[n]=arguments[n];return function(s){return r.reduceRight(function(c,d){return d(c)},s)}}function he(t){return function r(){for(var n=this,s=arguments.length,c=new Array(s),d=0;d<s;d++)c[d]=arguments[d];return c.length>=t.length?t.apply(this,c):function(){for(var h=arguments.length,x=new Array(h),u=0;u<h;u++)x[u]=arguments[u];return r.apply(n,[].concat(c,x))}}}function Ne(t){return{}.toString.call(t).includes("Object")}function on(t){return!Object.keys(t).length}function ge(t){return typeof t=="function"}function cn(t,r){return Object.prototype.hasOwnProperty.call(t,r)}function ln(t,r){return Ne(r)||ie("changeType"),Object.keys(r).some(function(n){return!cn(t,n)})&&ie("changeField"),r}function dn(t){ge(t)||ie("selectorType")}function un(t){ge(t)||Ne(t)||ie("handlerType"),Ne(t)&&Object.values(t).some(function(r){return!ge(r)})&&ie("handlersType")}function mn(t){t||ie("initialIsRequired"),Ne(t)||ie("initialType"),on(t)&&ie("initialContent")}function xn(t,r){throw new Error(t[r]||t.default)}var hn={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},ie=he(xn)(hn),be={changes:ln,selector:dn,handler:un,initial:mn};function fn(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};be.initial(t),be.handler(r);var n={current:t},s=he(yn)(n,r),c=he(pn)(n),d=he(be.changes)(t),h=he(gn)(n);function x(){var y=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(g){return g};return be.selector(y),y(n.current)}function u(y){an(s,c,d,h)(y)}return[x,u]}function gn(t,r){return ge(r)?r(t.current):r}function pn(t,r){return t.current=it(it({},t.current),r),r}function yn(t,r,n){return ge(r)?r(t.current):Object.keys(n).forEach(function(s){var c;return(c=r[s])===null||c===void 0?void 0:c.call(r,t.current[s])}),n}var bn={create:fn},vn={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function jn(t){return function r(){for(var n=this,s=arguments.length,c=new Array(s),d=0;d<s;d++)c[d]=arguments[d];return c.length>=t.length?t.apply(this,c):function(){for(var h=arguments.length,x=new Array(h),u=0;u<h;u++)x[u]=arguments[u];return r.apply(n,[].concat(c,x))}}}function wn(t){return{}.toString.call(t).includes("Object")}function Nn(t){return t||ot("configIsRequired"),wn(t)||ot("configType"),t.urls?(kn(),{paths:{vs:t.urls.monacoBase}}):t}function kn(){console.warn(Nt.deprecation)}function $n(t,r){throw new Error(t[r]||t.default)}var Nt={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
|
|
159
174
|
You are using deprecated way of configuration.
|
|
160
175
|
|
|
161
176
|
Instead of using
|
|
@@ -164,8 +179,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
164
179
|
monaco.config({ paths: { vs: '...' } })
|
|
165
180
|
|
|
166
181
|
For more please check the link https://github.com/suren-atoyan/monaco-loader#config
|
|
167
|
-
`},Be=Fr(Zr)(it),Kr={config:Ur},Jr=function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return function(i){return n.reduceRight(function(l,x){return x(l)},i)}};function ot(t,r){return Object.keys(r).forEach(function(n){r[n]instanceof Object&&t[n]&&Object.assign(r[n],ot(t[n],r[n]))}),qe(qe({},t),r)}var Qr={type:"cancelation",msg:"operation is manually canceled"};function Ne(t){var r=!1,n=new Promise(function(s,i){t.then(function(l){return r?i(Qr):s(l)}),t.catch(i)});return n.cancel=function(){return r=!0},n}var Xr=["monaco"],en=qr.create({config:Yr,isInitialized:!1,resolve:null,reject:null,monaco:null}),ct=$r(en,2),de=ct[0],ge=ct[1];function tn(t){var r=Kr.config(t),n=r.monaco,s=Nr(r,Xr);ge(function(i){return{config:ot(i.config,s),monaco:n}})}function rn(){var t=de(function(r){var n=r.monaco,s=r.isInitialized,i=r.resolve;return{monaco:n,isInitialized:s,resolve:i}});if(!t.isInitialized){if(ge({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Ne(ke);if(window.monaco&&window.monaco.editor)return lt(window.monaco),t.resolve(window.monaco),Ne(ke);Jr(nn,an)(on)}return Ne(ke)}function nn(t){return document.body.appendChild(t)}function sn(t){var r=document.createElement("script");return t&&(r.src=t),r}function an(t){var r=de(function(s){var i=s.config,l=s.reject;return{config:i,reject:l}}),n=sn("".concat(r.config.paths.vs,"/loader.js"));return n.onload=function(){return t()},n.onerror=r.reject,n}function on(){var t=de(function(n){var s=n.config,i=n.resolve,l=n.reject;return{config:s,resolve:i,reject:l}}),r=window.require;r.config(t.config),r(["vs/editor/editor.main"],function(n){var s=n.m||n;lt(s),t.resolve(s)},function(n){t.reject(n)})}function lt(t){de().monaco||ge({monaco:t})}function cn(){return de(function(t){var r=t.monaco;return r})}var ke=new Promise(function(t,r){return ge({resolve:t,reject:r})}),dt={config:tn,init:rn,__getMonacoInstance:cn},ln={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},$e=ln,dn={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},un=dn;function hn({children:t}){return o.createElement("div",{style:un.container},t)}var mn=hn,fn=mn;function xn({width:t,height:r,isEditorReady:n,loading:s,_ref:i,className:l,wrapperProps:x}){return o.createElement("section",{style:{...$e.wrapper,width:t,height:r},...x},!n&&o.createElement(fn,null,s),o.createElement("div",{ref:i,style:{...$e.fullWidth,...!n&&$e.hide},className:l}))}var pn=xn,ut=o.memo(pn);function gn(t){o.useEffect(t,[])}var ht=gn;function bn(t,r,n=!0){let s=o.useRef(!0);o.useEffect(s.current||!n?()=>{s.current=!1}:t,r)}var K=bn;function oe(){}function se(t,r,n,s){return yn(t,s)||vn(t,r,n,s)}function yn(t,r){return t.editor.getModel(mt(t,r))}function vn(t,r,n,s){return t.editor.createModel(r,n,s?mt(t,s):void 0)}function mt(t,r){return t.Uri.parse(r)}function wn({original:t,modified:r,language:n,originalLanguage:s,modifiedLanguage:i,originalModelPath:l,modifiedModelPath:x,keepCurrentOriginalModel:p=!1,keepCurrentModifiedModel:y=!1,theme:N="light",loading:f="Loading...",options:v={},height:O="100%",width:z="100%",className:A,wrapperProps:T={},beforeMount:I=oe,onMount:_=oe}){let[H,W]=o.useState(!1),[C,P]=o.useState(!0),b=o.useRef(null),h=o.useRef(null),D=o.useRef(null),$=o.useRef(_),g=o.useRef(I),w=o.useRef(!1);ht(()=>{let a=dt.init();return a.then(c=>(h.current=c)&&P(!1)).catch(c=>(c==null?void 0:c.type)!=="cancelation"&&console.error("Monaco initialization: error:",c)),()=>b.current?d():a.cancel()}),K(()=>{if(b.current&&h.current){let a=b.current.getOriginalEditor(),c=se(h.current,t||"",s||n||"text",l||"");c!==a.getModel()&&a.setModel(c)}},[l],H),K(()=>{if(b.current&&h.current){let a=b.current.getModifiedEditor(),c=se(h.current,r||"",i||n||"text",x||"");c!==a.getModel()&&a.setModel(c)}},[x],H),K(()=>{let a=b.current.getModifiedEditor();a.getOption(h.current.editor.EditorOption.readOnly)?a.setValue(r||""):r!==a.getValue()&&(a.executeEdits("",[{range:a.getModel().getFullModelRange(),text:r||"",forceMoveMarkers:!0}]),a.pushUndoStop())},[r],H),K(()=>{var a,c;(c=(a=b.current)==null?void 0:a.getModel())==null||c.original.setValue(t||"")},[t],H),K(()=>{let{original:a,modified:c}=b.current.getModel();h.current.editor.setModelLanguage(a,s||n||"text"),h.current.editor.setModelLanguage(c,i||n||"text")},[n,s,i],H),K(()=>{var a;(a=h.current)==null||a.editor.setTheme(N)},[N],H),K(()=>{var a;(a=b.current)==null||a.updateOptions(v)},[v],H);let L=o.useCallback(()=>{var m;if(!h.current)return;g.current(h.current);let a=se(h.current,t||"",s||n||"text",l||""),c=se(h.current,r||"",i||n||"text",x||"");(m=b.current)==null||m.setModel({original:a,modified:c})},[n,r,i,t,s,l,x]),Y=o.useCallback(()=>{var a;!w.current&&D.current&&(b.current=h.current.editor.createDiffEditor(D.current,{automaticLayout:!0,...v}),L(),(a=h.current)==null||a.editor.setTheme(N),W(!0),w.current=!0)},[v,N,L]);o.useEffect(()=>{H&&$.current(b.current,h.current)},[H]),o.useEffect(()=>{!C&&!H&&Y()},[C,H,Y]);function d(){var c,m,u,S;let a=(c=b.current)==null?void 0:c.getModel();p||((m=a==null?void 0:a.original)==null||m.dispose()),y||((u=a==null?void 0:a.modified)==null||u.dispose()),(S=b.current)==null||S.dispose()}return o.createElement(ut,{width:z,height:O,isEditorReady:H,loading:f,_ref:D,className:A,wrapperProps:T})}var jn=wn;o.memo(jn);function Nn(t){let r=o.useRef();return o.useEffect(()=>{r.current=t},[t]),r.current}var kn=Nn,he=new Map;function $n({defaultValue:t,defaultLanguage:r,defaultPath:n,value:s,language:i,path:l,theme:x="light",line:p,loading:y="Loading...",options:N={},overrideServices:f={},saveViewState:v=!0,keepCurrentModel:O=!1,width:z="100%",height:A="100%",className:T,wrapperProps:I={},beforeMount:_=oe,onMount:H=oe,onChange:W,onValidate:C=oe}){let[P,b]=o.useState(!1),[h,D]=o.useState(!0),$=o.useRef(null),g=o.useRef(null),w=o.useRef(null),L=o.useRef(H),Y=o.useRef(_),d=o.useRef(),a=o.useRef(s),c=kn(l),m=o.useRef(!1),u=o.useRef(!1);ht(()=>{let j=dt.init();return j.then(M=>($.current=M)&&D(!1)).catch(M=>(M==null?void 0:M.type)!=="cancelation"&&console.error("Monaco initialization: error:",M)),()=>g.current?E():j.cancel()}),K(()=>{var M,R,V,B;let j=se($.current,t||s||"",r||i||"",l||n||"");j!==((M=g.current)==null?void 0:M.getModel())&&(v&&he.set(c,(R=g.current)==null?void 0:R.saveViewState()),(V=g.current)==null||V.setModel(j),v&&((B=g.current)==null||B.restoreViewState(he.get(l))))},[l],P),K(()=>{var j;(j=g.current)==null||j.updateOptions(N)},[N],P),K(()=>{!g.current||s===void 0||(g.current.getOption($.current.editor.EditorOption.readOnly)?g.current.setValue(s):s!==g.current.getValue()&&(u.current=!0,g.current.executeEdits("",[{range:g.current.getModel().getFullModelRange(),text:s,forceMoveMarkers:!0}]),g.current.pushUndoStop(),u.current=!1))},[s],P),K(()=>{var M,R;let j=(M=g.current)==null?void 0:M.getModel();j&&i&&((R=$.current)==null||R.editor.setModelLanguage(j,i))},[i],P),K(()=>{var j;p!==void 0&&((j=g.current)==null||j.revealLine(p))},[p],P),K(()=>{var j;(j=$.current)==null||j.editor.setTheme(x)},[x],P);let S=o.useCallback(()=>{var j;if(!(!w.current||!$.current)&&!m.current){Y.current($.current);let M=l||n,R=se($.current,s||t||"",r||i||"",M||"");g.current=(j=$.current)==null?void 0:j.editor.create(w.current,{model:R,automaticLayout:!0,...N},f),v&&g.current.restoreViewState(he.get(M)),$.current.editor.setTheme(x),p!==void 0&&g.current.revealLine(p),b(!0),m.current=!0}},[t,r,n,s,i,l,N,f,v,x,p]);o.useEffect(()=>{P&&L.current(g.current,$.current)},[P]),o.useEffect(()=>{!h&&!P&&S()},[h,P,S]),a.current=s,o.useEffect(()=>{var j,M;P&&W&&((j=d.current)==null||j.dispose(),d.current=(M=g.current)==null?void 0:M.onDidChangeModelContent(R=>{u.current||W(g.current.getValue(),R)}))},[P,W]),o.useEffect(()=>{if(P){let j=$.current.editor.onDidChangeMarkers(M=>{var V;let R=(V=g.current.getModel())==null?void 0:V.uri;if(R&&M.find(B=>B.path===R.path)){let B=$.current.editor.getModelMarkers({resource:R});C==null||C(B)}});return()=>{j==null||j.dispose()}}return()=>{}},[P,C]);function E(){var j,M;(j=d.current)==null||j.dispose(),O?v&&he.set(l,g.current.saveViewState()):(M=g.current.getModel())==null||M.dispose(),g.current.dispose()}return o.createElement(ut,{width:z,height:A,isEditorReady:P,loading:y,_ref:w,className:T,wrapperProps:I})}var Sn=$n,Mn=o.memo(Sn),Cn=Mn;function xe({title:t,children:r,placement:n="top",align:s="center",variant:i="default"}){const[l,x]=o.useState(!1),[p,y]=o.useState(null),N=o.useRef(null),f=o.useRef(null),v=o.useRef(void 0),O=o.useRef(!1),z=o.useRef(null),A=o.useId(),T=()=>{clearTimeout(v.current),O.current=!1,z.current=null,x(!1),y(null)},I=()=>{clearTimeout(v.current),x(!0)},_=()=>{clearTimeout(v.current),!O.current&&(v.current=setTimeout(()=>{O.current||T()},150))},H=()=>{i==="card"&&(O.current=!0,I())},W=C=>{var P,b;return C instanceof Node&&(((P=N.current)==null?void 0:P.contains(C))||((b=f.current)==null?void 0:b.contains(C)))};return o.useEffect(()=>()=>clearTimeout(v.current),[]),o.useEffect(()=>{if(!l)return;const C=b=>{W(b.target)||T()},P=b=>{b.key==="Escape"&&T()};return document.addEventListener("pointerdown",C),document.addEventListener("keydown",P),()=>{document.removeEventListener("pointerdown",C),document.removeEventListener("keydown",P)}},[l]),o.useLayoutEffect(()=>{if(!l||!t)return;const C=()=>{const b=N.current,h=f.current;if(!b||!h)return;const D=12,$=6,g=b.getBoundingClientRect(),w=Math.max(0,g.top-D-$),L=Math.max(0,window.innerHeight-g.bottom-D-$),Y=i==="card"?420:320;if(!z.current){const m=i==="card"?Y:Math.min(Y,h.getBoundingClientRect().height),u=n==="top"?w>=m||w>=L:!(L>=m||L>=w);z.current=u?"top":"bottom"}const d=z.current==="top";h.style.maxHeight=`${Math.min(Y,d?w:L)}px`;const{width:a,height:c}=h.getBoundingClientRect();y({left:Math.max(D,Math.min(s==="end"?g.right-a:g.left+(g.width-a)/2,window.innerWidth-a-D)),top:d?g.top-c-$:g.bottom+$})};C();const P=new ResizeObserver(C);return f.current&&P.observe(f.current),window.addEventListener("resize",C),window.addEventListener("scroll",C,!0),()=>{P.disconnect(),window.removeEventListener("resize",C),window.removeEventListener("scroll",C,!0)}},[l,t,n,s,i]),t?e.jsxs("div",{ref:N,className:"inline-flex","aria-describedby":l&&i==="default"?A:void 0,onMouseEnter:I,onMouseLeave:_,onPointerDown:H,onClick:()=>{i==="default"&&T()},onFocus:I,onBlur:C=>{W(C.relatedTarget)||(C.relatedTarget?T():_())},children:[r,l&&Ue.createPortal(e.jsx("div",{ref:f,id:A,role:i==="card"?"dialog":"tooltip","aria-label":i==="card"?"校验问题":void 0,className:`aisee-articles-tooltip aisee-articles-tooltip--${i}`,style:{width:i==="card"?480:"max-content",maxWidth:"min(480px, calc(100vw - 24px))",overflowWrap:"anywhere",scrollbarWidth:"thin",left:(p==null?void 0:p.left)??0,top:(p==null?void 0:p.top)??0,visibility:p?"visible":"hidden"},onMouseEnter:I,onMouseLeave:_,onPointerDown:H,onFocus:I,children:t}),document.body)]}):e.jsx(e.Fragment,{children:r})}const Se=[{key:"desktop",icon:e.jsx(Xe,{size:13}),label:"桌面",width:null},{key:"tablet",icon:e.jsx(nt,{size:13}),label:"平板",width:768},{key:"mobile",icon:e.jsx(rt,{size:13}),label:"手机",width:390}],En=({id:t,record:r})=>{const{navigate:n,params:s,locationState:i}=Te(),l=t??s.id,{basePath:x,service:p,previewBaseUrl:y,previewTailwind:N}=pe(),f=!!l,[v,O]=st(),[z,A]=o.useState(!1),[T,I]=o.useState(r??(i==null?void 0:i.record)??null),[_,H]=o.useState(""),[W,C]=o.useState(f?"":"https://aisee.live"),[P,b]=o.useState(""),[h,D]=o.useState(""),[$,g]=o.useState({navEnabled:!1,navname:"",navPlacements:[]}),w=k=>g({navEnabled:k.navEnabled??!1,navname:k.navname??"",navPlacements:k.navPlacements??[]}),[L,Y]=o.useState(""),[d,a]=o.useState("code"),[c,m]=o.useState(!1),[u,S]=o.useState("desktop"),[E,j]=o.useState(!1),[M,R]=o.useState(null),V=(k,U)=>{const F=y?`<base href="${y}">`:"",Z=U?`<meta name="viewport" content="width=${U}, initial-scale=1">`:"",re=U?"<style>*,*::before,*::after{box-sizing:border-box}img,video,svg,canvas,audio{max-width:100%;height:auto}pre{white-space:pre-wrap;word-break:break-word;overflow-x:auto}table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}</style>":"",be=N&&!k.includes("cdn.tailwindcss.com")?'<script src="https://cdn.tailwindcss.com"><\/script>':"",ye=F+Z+re+be;return ye?k.includes("</head>")?k.replace("</head>",`${ye}
|
|
168
|
-
</head>`):
|
|
169
|
-
`).length,X=async()=>{if(z)return;if(!_.trim()){D("请输入访问路径");return}if(!L.trim()){m(!0),G.error("请先输入 HTML 代码");return}const k=W.trim().replace(/\/+$/,"");try{const F=new URL(k);if(!["http:","https:"].includes(F.protocol)||F.search||F.hash||F.username||F.password)throw new Error}catch{b("请输入有效的网站地址,需以 http:// 或 https:// 开头");return}if(p.getNavigationGroups&&$.navEnabled){if(!$.navname.trim()){G.error("开启导航后,请填写导航名称");return}if(!$.navPlacements.length){G.error("请至少选择一个展示位置");return}}A(!0);const U=await He(L);if(A(!1),U.networkError)G.warning("W3C 校验服务不可用,已跳过校验");else if(!U.isValid&&!await new Promise(Z=>{v.confirm({title:"HTML 校验发现问题",content:e.jsxs("div",{className:"mt-1",children:[e.jsx("p",{className:"text-gray-600 mb-2",children:"检测到以下 W3C 标准问题,仍要保存吗?"}),e.jsxs("ul",{className:"space-y-1",children:[U.errors.slice(0,5).map((re,be)=>e.jsxs("li",{className:"flex items-start gap-1.5 text-red-500 text-sm",children:[e.jsx("span",{className:"shrink-0",children:"✕"}),e.jsxs("span",{children:[re.lastLine?`第 ${re.lastLine} 行:`:"",re.message]})]},be)),U.errors.length>5&&e.jsxs("li",{className:"text-gray-400 text-xs mt-1",children:["另有 ",U.errors.length-5," 个问题"]})]})]}),okText:"仍然保存",cancelText:"返回修改",onOk:()=>Z(!0),onCancel:()=>Z(!1)})}))return;A(!0);try{const F={pathname:_.trim(),content:L,host:k,...p.getNavigationGroups?{navEnabled:$.navEnabled,navname:$.navname.trim()||null,navPlacements:$.navPlacements.map(({position:Z,parentNavId:re})=>({position:Z,parentNavId:re||null}))}:{}};f&&T?(await p.update(T.id,F),G.success("编辑成功")):(await p.create(F),G.success("新增成功")),n(x)}catch(F){G.error(F.message||"保存失败")}finally{A(!1)}};return e.jsxs(e.Fragment,{children:[O,e.jsxs("div",{className:"w-full bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden flex flex-col",style:{height:"calc(100vh - 90px)"},children:[e.jsxs("div",{className:"shrink-0 flex items-center justify-between px-6 py-4 border-b border-gray-100 bg-gray-50/60",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{"aria-label":"返回文章列表",className:"flex items-center justify-center w-7 h-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-200 transition -ml-1 cursor-pointer",onClick:J,children:e.jsx(Ke,{size:15})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold text-gray-800 leading-tight",children:f?"编辑文章":"新增文章"}),f&&T&&e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5 font-mono",children:["/",T.pathname]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"px-4 py-1.5 border border-gray-200 rounded-lg text-sm text-gray-600 hover:bg-gray-50 transition cursor-pointer",onClick:J,children:"取消"}),e.jsx("button",{disabled:Q||z,className:"px-4 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-sm rounded-lg transition disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",onClick:X,children:z?"保存中…":"保存"})]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[e.jsxs("div",{className:"shrink-0 px-6 pt-5 pb-4 border-b border-gray-100",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["访问路径",e.jsx("span",{className:"text-xs text-gray-400 font-normal ml-1.5",children:"前台页面路径"})]}),e.jsxs("div",{className:`flex items-center border rounded-lg transition focus-within:ring-2 focus-within:ring-blue-500/30 focus-within:border-blue-400 ${h?"border-red-400 ring-2 ring-red-500/20":"border-gray-200"}`,children:[e.jsx("span",{className:"pl-3 text-gray-400 select-none text-sm shrink-0",children:"/"}),e.jsx("input",{className:"flex-1 pr-3 py-1.5 text-sm bg-transparent focus:outline-none",placeholder:"例如 about-us",value:_,onChange:k=>{H(k.target.value),h&&D("")}})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1.5",children:"建议使用小写字母,不能包含空格,例如 about-us。"}),h&&e.jsx("p",{className:"text-red-500 text-xs mt-1",children:h})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["网站地址",e.jsx("span",{className:"text-red-500 ml-1",children:"*"}),e.jsx("span",{className:"text-xs text-gray-400 font-normal ml-1.5",children:"网站基础地址"})]}),e.jsx("input",{className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/30 focus:border-blue-400 transition",placeholder:"例如 https://aisee.live",value:W,"aria-label":"网站地址","aria-invalid":!!P,onChange:k=>{const U=k.target.value;U.trim().replace(/\/+$/,"")!==W.trim().replace(/\/+$/,"")&&g(F=>({...F,navPlacements:F.navPlacements.map(Z=>({...Z,parentNavId:null}))})),C(U),b("")}}),P&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-red-500",children:P})]})]}),e.jsx(pr,{host:W,service:p,value:$,onChange:g})]}),e.jsx("div",{className:"shrink-0 border-b border-gray-100 bg-gray-50/40",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-6 py-2",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center bg-gray-100/80 rounded-lg p-0.5 gap-0.5 border border-gray-200/60",children:[e.jsxs("button",{className:`flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium transition-all duration-150 select-none cursor-pointer ${d==="code"?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50":"text-gray-400 hover:text-gray-600 hover:bg-white/50"}`,onClick:()=>a("code"),children:[e.jsx(_e,{size:11})," 代码"]}),e.jsxs("button",{className:`flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium transition-all duration-150 select-none ${d==="preview"?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50 cursor-pointer":L?"text-gray-400 hover:text-gray-600 hover:bg-white/50 cursor-pointer":"text-gray-300 cursor-not-allowed"}`,onClick:()=>a("preview"),disabled:!L,children:[e.jsx(Ee,{size:11})," 预览"]})]})}),d==="preview"&&L&&e.jsx("div",{className:"flex items-center bg-gray-100/80 rounded-lg p-0.5 gap-0.5 border border-gray-200/60",children:Se.map(k=>e.jsx(xe,{title:k.label,children:e.jsx("button",{className:`flex items-center justify-center w-7 h-6 rounded-md text-xs transition-all duration-150 select-none cursor-pointer ${u===k.key?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50":"text-gray-400 hover:text-gray-600 hover:bg-white/50"}`,onClick:()=>S(k.key),children:k.icon})},k.key))}),d==="code"&&e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[L&&e.jsxs("span",{className:"text-xs text-gray-400",children:[te," 行 · ",L.length," 字符"]}),M&&!M.networkError&&(M.isValid?e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-green-50 border border-green-200 text-green-600 text-xs",children:[e.jsx(Re,{size:11})," 校验通过"]}):e.jsx(xe,{variant:"card",align:"end",title:e.jsx(br,{errors:M.errors,source:L}),children:e.jsxs("span",{tabIndex:0,className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-red-50 border border-red-200 text-red-500 text-xs cursor-default",children:["✕"," ",M.errors.length," 个问题"]})})),e.jsxs("button",{disabled:!L||E,className:"flex items-center gap-1.5 px-2.5 py-1 text-xs border border-gray-200 rounded-lg hover:bg-gray-50 text-gray-600 transition disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",onClick:B,children:[e.jsx(Re,{size:12}),E?"校验中…":"W3C 校验"]})]})]})}),e.jsxs("div",{className:"relative min-h-[320px] flex-1 shrink-0",children:[e.jsx("div",{className:"absolute inset-0",style:{display:d==="code"?"block":"none",outline:c?"2px solid #ff4d4f":"none"},children:e.jsx(Cn,{height:"100%",language:"html",theme:"vs-dark",value:L,onChange:k=>{Y(k??""),c&&m(!1),M&&R(null)},options:{fontSize:13,minimap:{enabled:!1},wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2,formatOnPaste:!0,lineNumbers:"on",renderWhitespace:"none",smoothScrolling:!0,cursorBlinking:"smooth",padding:{top:12,bottom:12}}})}),d==="preview"&&(L?e.jsx("div",{className:"absolute inset-0 overflow-auto bg-gray-100/60 flex justify-center",children:u!=="desktop"?e.jsx("div",{className:"flex flex-col items-center py-6 h-full",children:e.jsx("iframe",{srcDoc:V(L,Se.find(k=>k.key===u).width),sandbox:"allow-same-origin allow-scripts",title:"HTML 预览",style:{width:`${Se.find(k=>k.key===u).width}px`,height:"100%",minHeight:0,border:"1px solid #e5e7eb",borderRadius:10,background:"#fff",boxShadow:"0 4px 24px 0 rgba(0,0,0,0.10)",flexShrink:0}})}):e.jsx("iframe",{srcDoc:V(L),sandbox:"allow-same-origin allow-scripts",title:"HTML 预览",style:{width:"100%",height:"100%",border:"none",background:"#fff",display:"block"}})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-300 gap-3 select-none",children:[e.jsx(Ee,{size:36}),e.jsx("span",{className:"text-sm",children:"请先输入 HTML 代码以预览"})]}))]})]})]})]})},Me=[{key:"desktop",icon:e.jsx(Xe,{size:13}),label:"Desktop",width:null},{key:"tablet",icon:e.jsx(nt,{size:13}),label:"Tablet",width:768},{key:"mobile",icon:e.jsx(rt,{size:13}),label:"Mobile",width:390}],On=({id:t,record:r})=>{const{navigate:n,params:s,locationState:i}=Te(),l=t??s.id,{basePath:x,service:p,previewBaseUrl:y,previewTailwind:N}=pe(),[f,v]=o.useState(r??(i==null?void 0:i.record)??null),[O,z]=o.useState(!1),[A,T]=o.useState("preview"),[I,_]=o.useState("desktop");o.useEffect(()=>{!f&&l&&(z(!0),p.getById(l).then(v).catch(b=>{G.error(b.message||"获取数据失败"),n(x)}).finally(()=>z(!1)))},[l]);const H=()=>n(x),W=()=>n(`${x}/${l}/edit`,{state:{record:f}}),C=()=>{f!=null&&f.content&&(navigator.clipboard.writeText(f.content),G.success("已复制到剪贴板"))},P=(b,h)=>{const D=y?`<base href="${y}">`:"",$=h?`<meta name="viewport" content="width=${h}, initial-scale=1">`:"",g=h?"<style>*,*::before,*::after{box-sizing:border-box}img,video,svg,canvas,audio{max-width:100%;height:auto}pre{white-space:pre-wrap;word-break:break-word;overflow-x:auto}table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}</style>":"",w=N&&!b.includes("cdn.tailwindcss.com")?'<script src="https://cdn.tailwindcss.com"><\/script>':"",L=D+$+g+w;return L?b.includes("</head>")?b.replace("</head>",`${L}
|
|
170
|
-
</head>`):
|
|
171
|
-
`).length} 行 · ${
|
|
182
|
+
`},ot=jn($n)(Nt),Sn={config:Nn},Cn=function(){for(var r=arguments.length,n=new Array(r),s=0;s<r;s++)n[s]=arguments[s];return function(c){return n.reduceRight(function(d,h){return h(d)},c)}};function kt(t,r){return Object.keys(r).forEach(function(n){r[n]instanceof Object&&t[n]&&Object.assign(r[n],kt(t[n],r[n]))}),st(st({},t),r)}var Mn={type:"cancelation",msg:"operation is manually canceled"};function Ie(t){var r=!1,n=new Promise(function(s,c){t.then(function(d){return r?c(Mn):s(d)}),t.catch(c)});return n.cancel=function(){return r=!0},n}var En=["monaco"],On=bn.create({config:vn,isInitialized:!1,resolve:null,reject:null,monaco:null}),$t=en(On,2),ye=$t[0],Ce=$t[1];function Pn(t){var r=Sn.config(t),n=r.monaco,s=Xr(r,En);Ce(function(c){return{config:kt(c.config,s),monaco:n}})}function Dn(){var t=ye(function(r){var n=r.monaco,s=r.isInitialized,c=r.resolve;return{monaco:n,isInitialized:s,resolve:c}});if(!t.isInitialized){if(Ce({isInitialized:!0}),t.monaco)return t.resolve(t.monaco),Ie(Le);if(window.monaco&&window.monaco.editor)return St(window.monaco),t.resolve(window.monaco),Ie(Le);Cn(In,_n)(Tn)}return Ie(Le)}function In(t){return document.body.appendChild(t)}function Ln(t){var r=document.createElement("script");return t&&(r.src=t),r}function _n(t){var r=ye(function(s){var c=s.config,d=s.reject;return{config:c,reject:d}}),n=Ln("".concat(r.config.paths.vs,"/loader.js"));return n.onload=function(){return t()},n.onerror=r.reject,n}function Tn(){var t=ye(function(n){var s=n.config,c=n.resolve,d=n.reject;return{config:s,resolve:c,reject:d}}),r=window.require;r.config(t.config),r(["vs/editor/editor.main"],function(n){var s=n.m||n;St(s),t.resolve(s)},function(n){t.reject(n)})}function St(t){ye().monaco||Ce({monaco:t})}function zn(){return ye(function(t){var r=t.monaco;return r})}var Le=new Promise(function(t,r){return Ce({resolve:t,reject:r})}),Ct={config:Pn,init:Dn,__getMonacoInstance:zn},An={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},_e=An,Rn={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Hn=Rn;function Gn({children:t}){return a.createElement("div",{style:Hn.container},t)}var Wn=Gn,Vn=Wn;function qn({width:t,height:r,isEditorReady:n,loading:s,_ref:c,className:d,wrapperProps:h}){return a.createElement("section",{style:{..._e.wrapper,width:t,height:r},...h},!n&&a.createElement(Vn,null,s),a.createElement("div",{ref:c,style:{..._e.fullWidth,...!n&&_e.hide},className:d}))}var Yn=qn,Mt=a.memo(Yn);function Fn(t){a.useEffect(t,[])}var Et=Fn;function Bn(t,r,n=!0){let s=a.useRef(!0);a.useEffect(s.current||!n?()=>{s.current=!1}:t,r)}var se=Bn;function fe(){}function de(t,r,n,s){return Un(t,s)||Kn(t,r,n,s)}function Un(t,r){return t.editor.getModel(Ot(t,r))}function Kn(t,r,n,s){return t.editor.createModel(r,n,s?Ot(t,s):void 0)}function Ot(t,r){return t.Uri.parse(r)}function Zn({original:t,modified:r,language:n,originalLanguage:s,modifiedLanguage:c,originalModelPath:d,modifiedModelPath:h,keepCurrentOriginalModel:x=!1,keepCurrentModifiedModel:u=!1,theme:y="light",loading:g="Loading...",options:w={},height:L="100%",width:T="100%",className:z,wrapperProps:H={},beforeMount:W=fe,onMount:G=fe}){let[A,Y]=a.useState(!1),[S,P]=a.useState(!0),v=a.useRef(null),b=a.useRef(null),_=a.useRef(null),M=a.useRef(G),f=a.useRef(W),$=a.useRef(!1);Et(()=>{let l=Ct.init();return l.then(m=>(b.current=m)&&P(!1)).catch(m=>(m==null?void 0:m.type)!=="cancelation"&&console.error("Monaco initialization: error:",m)),()=>v.current?N():l.cancel()}),se(()=>{if(v.current&&b.current){let l=v.current.getOriginalEditor(),m=de(b.current,t||"",s||n||"text",d||"");m!==l.getModel()&&l.setModel(m)}},[d],A),se(()=>{if(v.current&&b.current){let l=v.current.getModifiedEditor(),m=de(b.current,r||"",c||n||"text",h||"");m!==l.getModel()&&l.setModel(m)}},[h],A),se(()=>{let l=v.current.getModifiedEditor();l.getOption(b.current.editor.EditorOption.readOnly)?l.setValue(r||""):r!==l.getValue()&&(l.executeEdits("",[{range:l.getModel().getFullModelRange(),text:r||"",forceMoveMarkers:!0}]),l.pushUndoStop())},[r],A),se(()=>{var l,m;(m=(l=v.current)==null?void 0:l.getModel())==null||m.original.setValue(t||"")},[t],A),se(()=>{let{original:l,modified:m}=v.current.getModel();b.current.editor.setModelLanguage(l,s||n||"text"),b.current.editor.setModelLanguage(m,c||n||"text")},[n,s,c],A),se(()=>{var l;(l=b.current)==null||l.editor.setTheme(y)},[y],A),se(()=>{var l;(l=v.current)==null||l.updateOptions(w)},[w],A);let I=a.useCallback(()=>{var k;if(!b.current)return;f.current(b.current);let l=de(b.current,t||"",s||n||"text",d||""),m=de(b.current,r||"",c||n||"text",h||"");(k=v.current)==null||k.setModel({original:l,modified:m})},[n,r,c,t,s,d,h]),V=a.useCallback(()=>{var l;!$.current&&_.current&&(v.current=b.current.editor.createDiffEditor(_.current,{automaticLayout:!0,...w}),I(),(l=b.current)==null||l.editor.setTheme(y),Y(!0),$.current=!0)},[w,y,I]);a.useEffect(()=>{A&&M.current(v.current,b.current)},[A]),a.useEffect(()=>{!S&&!A&&V()},[S,A,V]);function N(){var m,k,p,E;let l=(m=v.current)==null?void 0:m.getModel();x||((k=l==null?void 0:l.original)==null||k.dispose()),u||((p=l==null?void 0:l.modified)==null||p.dispose()),(E=v.current)==null||E.dispose()}return a.createElement(Mt,{width:T,height:L,isEditorReady:A,loading:g,_ref:_,className:z,wrapperProps:H})}var Jn=Zn;a.memo(Jn);function Xn(t){let r=a.useRef();return a.useEffect(()=>{r.current=t},[t]),r.current}var Qn=Xn,ve=new Map;function es({defaultValue:t,defaultLanguage:r,defaultPath:n,value:s,language:c,path:d,theme:h="light",line:x,loading:u="Loading...",options:y={},overrideServices:g={},saveViewState:w=!0,keepCurrentModel:L=!1,width:T="100%",height:z="100%",className:H,wrapperProps:W={},beforeMount:G=fe,onMount:A=fe,onChange:Y,onValidate:S=fe}){let[P,v]=a.useState(!1),[b,_]=a.useState(!0),M=a.useRef(null),f=a.useRef(null),$=a.useRef(null),I=a.useRef(A),V=a.useRef(G),N=a.useRef(),l=a.useRef(s),m=Qn(d),k=a.useRef(!1),p=a.useRef(!1);Et(()=>{let i=Ct.init();return i.then(o=>(M.current=o)&&_(!1)).catch(o=>(o==null?void 0:o.type)!=="cancelation"&&console.error("Monaco initialization: error:",o)),()=>f.current?O():i.cancel()}),se(()=>{var o,j,C,R;let i=de(M.current,t||s||"",r||c||"",d||n||"");i!==((o=f.current)==null?void 0:o.getModel())&&(w&&ve.set(m,(j=f.current)==null?void 0:j.saveViewState()),(C=f.current)==null||C.setModel(i),w&&((R=f.current)==null||R.restoreViewState(ve.get(d))))},[d],P),se(()=>{var i;(i=f.current)==null||i.updateOptions(y)},[y],P),se(()=>{!f.current||s===void 0||(f.current.getOption(M.current.editor.EditorOption.readOnly)?f.current.setValue(s):s!==f.current.getValue()&&(p.current=!0,f.current.executeEdits("",[{range:f.current.getModel().getFullModelRange(),text:s,forceMoveMarkers:!0}]),f.current.pushUndoStop(),p.current=!1))},[s],P),se(()=>{var o,j;let i=(o=f.current)==null?void 0:o.getModel();i&&c&&((j=M.current)==null||j.editor.setModelLanguage(i,c))},[c],P),se(()=>{var i;x!==void 0&&((i=f.current)==null||i.revealLine(x))},[x],P),se(()=>{var i;(i=M.current)==null||i.editor.setTheme(h)},[h],P);let E=a.useCallback(()=>{var i;if(!(!$.current||!M.current)&&!k.current){V.current(M.current);let o=d||n,j=de(M.current,s||t||"",r||c||"",o||"");f.current=(i=M.current)==null?void 0:i.editor.create($.current,{model:j,automaticLayout:!0,...y},g),w&&f.current.restoreViewState(ve.get(o)),M.current.editor.setTheme(h),x!==void 0&&f.current.revealLine(x),v(!0),k.current=!0}},[t,r,n,s,c,d,y,g,w,h,x]);a.useEffect(()=>{P&&I.current(f.current,M.current)},[P]),a.useEffect(()=>{!b&&!P&&E()},[b,P,E]),l.current=s,a.useEffect(()=>{var i,o;P&&Y&&((i=N.current)==null||i.dispose(),N.current=(o=f.current)==null?void 0:o.onDidChangeModelContent(j=>{p.current||Y(f.current.getValue(),j)}))},[P,Y]),a.useEffect(()=>{if(P){let i=M.current.editor.onDidChangeMarkers(o=>{var C;let j=(C=f.current.getModel())==null?void 0:C.uri;if(j&&o.find(R=>R.path===j.path)){let R=M.current.editor.getModelMarkers({resource:j});S==null||S(R)}});return()=>{i==null||i.dispose()}}return()=>{}},[P,S]);function O(){var i,o;(i=N.current)==null||i.dispose(),L?w&&ve.set(d,f.current.saveViewState()):(o=f.current.getModel())==null||o.dispose(),f.current.dispose()}return a.createElement(Mt,{width:T,height:z,isEditorReady:P,loading:u,_ref:$,className:H,wrapperProps:W})}var ts=es,rs=a.memo(ts),ns=rs;function ke({title:t,children:r,placement:n="top",align:s="center",variant:c="default"}){const[d,h]=a.useState(!1),[x,u]=a.useState(null),y=a.useRef(null),g=a.useRef(null),w=a.useRef(void 0),L=a.useRef(!1),T=a.useRef(null),z=a.useId(),H=()=>{clearTimeout(w.current),L.current=!1,T.current=null,h(!1),u(null)},W=()=>{clearTimeout(w.current),h(!0)},G=()=>{clearTimeout(w.current),!L.current&&(w.current=setTimeout(()=>{L.current||H()},150))},A=()=>{c==="card"&&(L.current=!0,W())},Y=S=>{var P,v;return S instanceof Node&&(((P=y.current)==null?void 0:P.contains(S))||((v=g.current)==null?void 0:v.contains(S)))};return a.useEffect(()=>()=>clearTimeout(w.current),[]),a.useEffect(()=>{if(!d)return;const S=v=>{Y(v.target)||H()},P=v=>{v.key==="Escape"&&H()};return document.addEventListener("pointerdown",S),document.addEventListener("keydown",P),()=>{document.removeEventListener("pointerdown",S),document.removeEventListener("keydown",P)}},[d]),a.useLayoutEffect(()=>{if(!d||!t)return;const S=()=>{const v=y.current,b=g.current;if(!v||!b)return;const _=12,M=6,f=v.getBoundingClientRect(),$=Math.max(0,f.top-_-M),I=Math.max(0,window.innerHeight-f.bottom-_-M),V=c==="card"?420:320;if(!T.current){const k=c==="card"?V:Math.min(V,b.getBoundingClientRect().height),p=n==="top"?$>=k||$>=I:!(I>=k||I>=$);T.current=p?"top":"bottom"}const N=T.current==="top";b.style.maxHeight=`${Math.min(V,N?$:I)}px`;const{width:l,height:m}=b.getBoundingClientRect();u({left:Math.max(_,Math.min(s==="end"?f.right-l:f.left+(f.width-l)/2,window.innerWidth-l-_)),top:N?f.top-m-M:f.bottom+M})};S();const P=new ResizeObserver(S);return g.current&&P.observe(g.current),window.addEventListener("resize",S),window.addEventListener("scroll",S,!0),()=>{P.disconnect(),window.removeEventListener("resize",S),window.removeEventListener("scroll",S,!0)}},[d,t,n,s,c]),t?e.jsxs("div",{ref:y,className:"inline-flex","aria-describedby":d&&c==="default"?z:void 0,onMouseEnter:W,onMouseLeave:G,onPointerDown:A,onClick:()=>{c==="default"&&H()},onFocus:W,onBlur:S=>{Y(S.relatedTarget)||(S.relatedTarget?H():G())},children:[r,d&&ct.createPortal(e.jsx("div",{ref:g,id:z,role:c==="card"?"dialog":"tooltip","aria-label":c==="card"?"校验问题":void 0,className:`aisee-articles-tooltip aisee-articles-tooltip--${c}`,style:{width:c==="card"?480:"max-content",maxWidth:"min(480px, calc(100vw - 24px))",overflowWrap:"anywhere",scrollbarWidth:"thin",left:(x==null?void 0:x.left)??0,top:(x==null?void 0:x.top)??0,visibility:x?"visible":"hidden"},onMouseEnter:W,onMouseLeave:G,onPointerDown:A,onFocus:W,children:t}),document.body)]}):e.jsx(e.Fragment,{children:r})}const Te=[{key:"desktop",icon:e.jsx(ht,{size:13}),label:"桌面",width:null},{key:"tablet",icon:e.jsx(pt,{size:13}),label:"平板",width:768},{key:"mobile",icon:e.jsx(gt,{size:13}),label:"手机",width:390}],ss=({id:t,record:r})=>{const{navigate:n,params:s}=Ve(),c=t??s.id,{basePath:d,service:h,previewBaseUrl:x,previewTailwind:u}=$e(),y=!!c,[g,w]=bt(),[L,T]=a.useState(!1),[z,H]=a.useState(r??null),[W,G]=a.useState(y&&!r),[A,Y]=a.useState(""),[S,P]=a.useState(y?"":"https://aisee.live"),[v,b]=a.useState(""),[_,M]=a.useState(""),[f,$]=a.useState({title:"",description:"",categoryId:null}),[I,V]=a.useState([]),[N,l]=a.useState(!1),[m,k]=a.useState(""),[p,E]=a.useState(0),O=Yr(f),i=S.trim().replace(/\/+$/,""),o=a.useRef(i);o.current=i;const j=h.getGuidesCategories;a.useEffect(()=>{let D=!0;return V([]),k(""),l(!!i&&!!j),i&&j&&j({host:i}).then(U=>{D&&V(U)}).catch(U=>{D&&k(U instanceof Error?U.message:"分类加载失败")}).finally(()=>{D&&l(!1)}),()=>{D=!1}},[i,j,p]);const[C,R]=a.useState({navEnabled:!1,navname:"",navPlacements:[]}),K=D=>{R({navEnabled:D.navEnabled??!1,navname:D.navname??"",navPlacements:D.navPlacements??[]}),$(D.guidesDisplay??{title:"",description:"",categoryId:null})},[q,Q]=a.useState(""),[Z,ee]=a.useState("code"),[re,ne]=a.useState(!1),[X,Me]=a.useState("desktop"),[Fe,Be]=a.useState(!1),[ce,Ee]=a.useState(null),Ue=(D,U)=>{const F=x?`<base href="${x}">`:"",J=U?`<meta name="viewport" content="width=${U}, initial-scale=1">`:"",ae=U?"<style>*,*::before,*::after{box-sizing:border-box}img,video,svg,canvas,audio{max-width:100%;height:auto}pre{white-space:pre-wrap;word-break:break-word;overflow-x:auto}table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}</style>":"",oe=u&&!D.includes("cdn.tailwindcss.com")?'<script src="https://cdn.tailwindcss.com"><\/script>':"",ue=F+J+ae+oe;return ue?D.includes("</head>")?D.replace("</head>",`${ue}
|
|
183
|
+
</head>`):ue+D:D},Pt=async()=>{if(!q.trim()){te.warning("请先输入 HTML 代码");return}Be(!0),Ee(null);try{const D=await tt(q);Ee(D),D.networkError?te.warning("W3C 校验服务不可用"):D.isValid&&te.success("HTML 校验通过")}finally{Be(!1)}};a.useEffect(()=>{if(!y)return;let D=!0;const U=F=>{H(F),Y(F.pathname||""),P(F.host||""),Q(F.content||""),K(F)};if((r==null?void 0:r.id)===c){U(r),G(!1);return}return G(!0),h.getById(c).then(F=>{D&&U(F)}).catch(F=>{D&&(te.error(F instanceof Error?F.message:"获取文章失败"),n(d))}).finally(()=>{D&&G(!1)}),()=>{D=!1}},[c,r,h.getById]);const Ke=()=>n(d),Dt=W||!A.trim(),It=q.split(`
|
|
184
|
+
`).length,Lt=async()=>{if(L||W)return;if(!A.trim()){M("请输入访问路径");return}if(!q.trim()){ne(!0),te.error("请先输入 HTML 代码");return}const D=S.trim().replace(/\/+$/,"");try{const J=new URL(D);if(!["http:","https:"].includes(J.protocol)||J.pathname!=="/"||J.search||J.hash||J.username||J.password)throw new Error}catch{b("请输入有效的网站地址,需以 http:// 或 https:// 开头,且不能包含路径、账号、查询参数或锚点");return}if(h.getNavigationGroups&&C.navEnabled){if(!C.navname.trim()){te.error("开启导航后,请填写导航名称");return}if(!C.navPlacements.length){te.error("请至少选择一个展示位置");return}}const U=!!(f.title.trim()||f.description.trim()||O.categoryId||f.categoryId===void 0&&f.category);if(j&&U){if(!f.title.trim()){te.error("配置 Guides 展示时,请填写文章标题");return}if(f.categoryId===void 0&&!!f.category&&!O.categoryId||O.categoryId&&(N||m||!I.some(ae=>ae.id===O.categoryId))){te.error("请先成功加载并选择有效的 Guides 分类");return}}T(!0);const F=await tt(q);if(T(!1),F.networkError)te.warning("W3C 校验服务不可用,已跳过校验");else if(!F.isValid&&!await new Promise(ae=>{g.confirm({title:"HTML 校验发现问题",content:e.jsxs("div",{className:"mt-1",children:[e.jsx("p",{className:"text-gray-600 mb-2",children:"检测到以下 W3C 标准问题,仍要保存吗?"}),e.jsxs("ul",{className:"space-y-1",children:[F.errors.slice(0,5).map((oe,ue)=>e.jsxs("li",{className:"flex items-start gap-1.5 text-red-500 text-sm",children:[e.jsx("span",{className:"shrink-0",children:"✕"}),e.jsxs("span",{children:[oe.lastLine?`第 ${oe.lastLine} 行:`:"",oe.message]})]},ue)),F.errors.length>5&&e.jsxs("li",{className:"text-gray-400 text-xs mt-1",children:["另有 ",F.errors.length-5," 个问题"]})]})]}),okText:"仍然保存",cancelText:"返回修改",onOk:()=>ae(!0),onCancel:()=>ae(!1)})}))return;T(!0);try{const J={pathname:A.trim(),content:q,host:D,...j?{guidesDisplay:U?{title:f.title.trim(),description:f.description.trim(),categoryId:O.categoryId}:null}:{},...h.getNavigationGroups?{navEnabled:C.navEnabled,navname:C.navname.trim()||null,navPlacements:C.navPlacements.map(({position:ae,parentNavId:oe})=>({position:ae,parentNavId:oe||null}))}:{}};y&&z?(await h.update(z.id,J),te.success("编辑成功")):(await h.create(J),te.success("新增成功")),n(d)}catch(J){te.error(J.message||"保存失败")}finally{T(!1)}};return e.jsxs(e.Fragment,{children:[w,e.jsxs("div",{className:"w-full bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden flex flex-col",style:{height:"calc(100vh - 90px)"},children:[e.jsxs("div",{className:"shrink-0 flex items-center justify-between px-6 py-4 border-b border-gray-100 bg-gray-50/60",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{"aria-label":"返回文章列表",className:"flex items-center justify-center w-7 h-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-200 transition -ml-1 cursor-pointer",onClick:Ke,children:e.jsx(ut,{size:15})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-semibold text-gray-800 leading-tight",children:y?"编辑文章":"新增文章"}),y&&z&&e.jsxs("div",{className:"text-xs text-gray-400 mt-0.5 font-mono",children:["/",z.pathname]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{className:"px-4 py-1.5 border border-gray-200 rounded-lg text-sm text-gray-600 hover:bg-gray-50 transition cursor-pointer",onClick:Ke,children:"取消"}),e.jsx("button",{disabled:Dt||L,className:"px-4 py-1.5 bg-blue-500 hover:bg-blue-600 text-white text-sm rounded-lg transition disabled:opacity-50 disabled:cursor-not-allowed cursor-pointer",onClick:Lt,children:W?"加载中…":L?"保存中…":"保存"})]})]}),e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col overflow-y-auto",children:[e.jsxs("div",{className:"shrink-0 px-6 pt-5 pb-4 border-b border-gray-100",children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["访问路径",e.jsx("span",{className:"text-xs text-gray-400 font-normal ml-1.5",children:"前台页面路径"})]}),e.jsxs("div",{className:`flex items-center border rounded-lg transition focus-within:ring-2 focus-within:ring-blue-500/30 focus-within:border-blue-400 ${_?"border-red-400 ring-2 ring-red-500/20":"border-gray-200"}`,children:[e.jsx("span",{className:"pl-3 text-gray-400 select-none text-sm shrink-0",children:"/"}),e.jsx("input",{className:"flex-1 pr-3 py-1.5 text-sm bg-transparent focus:outline-none",placeholder:"例如 about-us",value:A,onChange:D=>{Y(D.target.value),_&&M("")}})]}),e.jsx("p",{className:"text-xs text-gray-500 mt-1.5",children:"建议使用小写字母,不能包含空格,例如 about-us。"}),_&&e.jsx("p",{className:"text-red-500 text-xs mt-1",children:_})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-1.5",children:["网站地址",e.jsx("span",{className:"text-red-500 ml-1",children:"*"}),e.jsx("span",{className:"text-xs text-gray-400 font-normal ml-1.5",children:"网站基础地址"})]}),e.jsx("input",{className:"w-full px-3 py-1.5 text-sm border border-gray-200 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500/30 focus:border-blue-400 transition",placeholder:"例如 https://aisee.live",value:S,"aria-label":"网站地址","aria-invalid":!!v,onChange:D=>{const U=D.target.value;U.trim().replace(/\/+$/,"")!==S.trim().replace(/\/+$/,"")&&($(F=>({...F,categoryId:null})),R(F=>({...F,navPlacements:F.navPlacements.map(J=>({...J,parentNavId:null}))}))),P(U),b("")}}),v&&e.jsx("p",{role:"alert",className:"mt-1 text-xs text-red-500",children:v})]})]}),j&&e.jsxs(e.Fragment,{children:[e.jsx(qr,{value:{...O,...f.categoryId===void 0&&!O.categoryId?{category:f.category}:{}},categories:I,categoriesDisabled:!i||N||!!m,onChange:$,onLoadCategories:async()=>{const D=await j({host:i});return o.current===i&&V(D),D},onReorderCategories:h.reorderGuidesCategories?async D=>{const U=await h.reorderGuidesCategories({host:i,categoryIds:D});return o.current===i&&V(U),U}:void 0,onSaveCategory:h.saveGuidesCategory?async D=>{const U=await h.saveGuidesCategory({...D,host:i});return o.current===i&&V(F=>F.some(J=>J.id===U.id)?F.map(J=>J.id===U.id?U:J):[...F,U]),U}:void 0},i),N&&e.jsx("p",{role:"status",className:"mt-2 text-xs text-gray-500",children:"加载 Guides 分类中…"}),m&&e.jsxs("p",{role:"alert",className:"mt-2 text-xs text-red-500",children:[m,e.jsx("button",{type:"button",onClick:()=>E(D=>D+1),className:"ml-2 cursor-pointer text-blue-500",children:"重试"})]})]}),e.jsx(Vr,{host:S,service:h,value:C,onChange:R})]}),e.jsx("div",{className:"shrink-0 border-b border-gray-100 bg-gray-50/40",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2 px-6 py-2",children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center bg-gray-100/80 rounded-lg p-0.5 gap-0.5 border border-gray-200/60",children:[e.jsxs("button",{className:`flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium transition-all duration-150 select-none cursor-pointer ${Z==="code"?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50":"text-gray-400 hover:text-gray-600 hover:bg-white/50"}`,onClick:()=>ee("code"),children:[e.jsx(qe,{size:11})," 代码"]}),e.jsxs("button",{className:`flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium transition-all duration-150 select-none ${Z==="preview"?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50 cursor-pointer":q?"text-gray-400 hover:text-gray-600 hover:bg-white/50 cursor-pointer":"text-gray-300 cursor-not-allowed"}`,onClick:()=>ee("preview"),disabled:!q,children:[e.jsx(Re,{size:11})," 预览"]})]})}),Z==="preview"&&q&&e.jsx("div",{className:"flex items-center bg-gray-100/80 rounded-lg p-0.5 gap-0.5 border border-gray-200/60",children:Te.map(D=>e.jsx(ke,{title:D.label,children:e.jsx("button",{className:`flex items-center justify-center w-7 h-6 rounded-md text-xs transition-all duration-150 select-none cursor-pointer ${X===D.key?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50":"text-gray-400 hover:text-gray-600 hover:bg-white/50"}`,onClick:()=>Me(D.key),children:D.icon})},D.key))}),Z==="code"&&e.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[q&&e.jsxs("span",{className:"text-xs text-gray-400",children:[It," 行 · ",q.length," 字符"]}),ce&&!ce.networkError&&(ce.isValid?e.jsxs("span",{className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-green-50 border border-green-200 text-green-600 text-xs",children:[e.jsx(Qe,{size:11})," 校验通过"]}):e.jsx(ke,{variant:"card",align:"end",title:e.jsx(Br,{errors:ce.errors,source:q}),children:e.jsxs("span",{tabIndex:0,className:"flex items-center gap-1 px-2 py-0.5 rounded-full bg-red-50 border border-red-200 text-red-500 text-xs cursor-default",children:["✕"," ",ce.errors.length," 个问题"]})})),e.jsxs("button",{disabled:!q||Fe,className:"flex items-center gap-1.5 px-2.5 py-1 text-xs border border-gray-200 rounded-lg hover:bg-gray-50 text-gray-600 transition disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer",onClick:Pt,children:[e.jsx(Qe,{size:12}),Fe?"校验中…":"W3C 校验"]})]})]})}),e.jsxs("div",{className:"relative min-h-[320px] flex-1 shrink-0",children:[e.jsx("div",{className:"absolute inset-0",style:{display:Z==="code"?"block":"none",outline:re?"2px solid #ff4d4f":"none"},children:e.jsx(ns,{height:"100%",language:"html",theme:"vs-dark",value:q,onChange:D=>{Q(D??""),re&&ne(!1),ce&&Ee(null)},options:{fontSize:13,minimap:{enabled:!1},wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,tabSize:2,formatOnPaste:!0,lineNumbers:"on",renderWhitespace:"none",smoothScrolling:!0,cursorBlinking:"smooth",padding:{top:12,bottom:12}}})}),Z==="preview"&&(q?e.jsx("div",{className:"absolute inset-0 overflow-auto bg-gray-100/60 flex justify-center",children:X!=="desktop"?e.jsx("div",{className:"flex flex-col items-center py-6 h-full",children:e.jsx("iframe",{srcDoc:Ue(q,Te.find(D=>D.key===X).width),sandbox:"allow-same-origin allow-scripts",title:"HTML 预览",style:{width:`${Te.find(D=>D.key===X).width}px`,height:"100%",minHeight:0,border:"1px solid #e5e7eb",borderRadius:10,background:"#fff",boxShadow:"0 4px 24px 0 rgba(0,0,0,0.10)",flexShrink:0}})}):e.jsx("iframe",{srcDoc:Ue(q),sandbox:"allow-same-origin allow-scripts",title:"HTML 预览",style:{width:"100%",height:"100%",border:"none",background:"#fff",display:"block"}})}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-gray-300 gap-3 select-none",children:[e.jsx(Re,{size:36}),e.jsx("span",{className:"text-sm",children:"请先输入 HTML 代码以预览"})]}))]})]})]})]})},ze=[{key:"desktop",icon:e.jsx(ht,{size:13}),label:"Desktop",width:null},{key:"tablet",icon:e.jsx(pt,{size:13}),label:"Tablet",width:768},{key:"mobile",icon:e.jsx(gt,{size:13}),label:"Mobile",width:390}],as=({id:t,record:r})=>{const{navigate:n,params:s,locationState:c}=Ve(),d=t??s.id,{basePath:h,service:x,previewBaseUrl:u,previewTailwind:y}=$e(),[g,w]=a.useState(r??(c==null?void 0:c.record)??null),[L,T]=a.useState(!1),[z,H]=a.useState("preview"),[W,G]=a.useState("desktop");a.useEffect(()=>{!g&&d&&(T(!0),x.getById(d).then(w).catch(v=>{te.error(v.message||"获取数据失败"),n(h)}).finally(()=>T(!1)))},[d]);const A=()=>n(h),Y=()=>n(`${h}/${d}/edit`,{state:{record:g}}),S=()=>{g!=null&&g.content&&(navigator.clipboard.writeText(g.content),te.success("已复制到剪贴板"))},P=(v,b)=>{const _=u?`<base href="${u}">`:"",M=b?`<meta name="viewport" content="width=${b}, initial-scale=1">`:"",f=b?"<style>*,*::before,*::after{box-sizing:border-box}img,video,svg,canvas,audio{max-width:100%;height:auto}pre{white-space:pre-wrap;word-break:break-word;overflow-x:auto}table{display:block;max-width:100%;overflow-x:auto;-webkit-overflow-scrolling:touch}</style>":"",$=y&&!v.includes("cdn.tailwindcss.com")?'<script src="https://cdn.tailwindcss.com"><\/script>':"",I=_+M+f+$;return I?v.includes("</head>")?v.replace("</head>",`${I}
|
|
185
|
+
</head>`):I+v:v};return L?e.jsx("div",{className:"flex items-center justify-center h-64 text-gray-400 text-sm",children:"加载中…"}):e.jsxs("div",{className:"w-full bg-white rounded-2xl shadow-sm border border-gray-100 overflow-hidden flex flex-col",style:{height:"calc(100vh - 90px)"},children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-3.5 border-b border-gray-100 bg-white shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("button",{className:"flex items-center justify-center w-7 h-7 rounded-lg text-gray-400 hover:text-gray-700 hover:bg-gray-100 transition -ml-1 shrink-0 cursor-pointer",onClick:A,children:e.jsx(ut,{size:15})}),e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-lg shrink-0",style:{background:"linear-gradient(135deg, #60a5fa, #818cf8)"},children:e.jsx(mr,{size:13,className:"text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"font-semibold text-gray-800 text-sm leading-tight",children:"Article 详情"}),e.jsx("div",{className:"flex items-center gap-1 mt-0.5",children:e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0 rounded bg-blue-50 border border-blue-100 text-blue-600 font-mono text-xs leading-5 truncate max-w-[300px]",children:[e.jsx(br,{size:9}),"/",g==null?void 0:g.pathname]})})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[z==="preview"&&e.jsx("div",{className:"flex items-center bg-gray-100/80 rounded-lg p-0.5 gap-0.5 border border-gray-200/60",children:ze.map(v=>e.jsx(ke,{title:v.label,children:e.jsx("button",{className:`flex items-center justify-center w-7 h-6 rounded-md text-xs transition-all duration-150 select-none cursor-pointer ${W===v.key?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50":"text-gray-400 hover:text-gray-600 hover:bg-white/50"}`,onClick:()=>G(v.key),children:v.icon})},v.key))}),e.jsx("div",{className:"flex items-center bg-gray-100/80 rounded-lg p-0.5 gap-0.5 border border-gray-200/60",children:["preview","code"].map(v=>e.jsx("button",{className:`flex items-center gap-1.5 px-3 py-1 rounded-md text-xs font-medium transition-all duration-150 select-none cursor-pointer ${z===v?"bg-white text-gray-800 shadow-sm ring-1 ring-gray-200/50":"text-gray-400 hover:text-gray-600 hover:bg-white/50"}`,onClick:()=>H(v),children:v==="preview"?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:11})," 预览"]}):e.jsxs(e.Fragment,{children:[e.jsx(qe,{size:11})," Code"]})},v))}),z==="code"&&e.jsx(ke,{title:"复制代码",children:e.jsx("button",{type:"button","aria-label":"复制代码",className:"flex items-center justify-center w-7 h-7 rounded-lg text-gray-400 hover:text-blue-500 hover:bg-blue-50 transition cursor-pointer",onClick:S,children:e.jsx(or,{size:14})})})]})]}),e.jsx("div",{className:`flex-1 min-h-0 ${z==="preview"?"bg-gray-100/70":""}`,children:z==="preview"?e.jsx("div",{className:"w-full h-full flex justify-center overflow-auto py-0",children:W!=="desktop"?e.jsx("div",{className:"flex flex-col items-center py-6 h-full",children:e.jsx("iframe",{srcDoc:P((g==null?void 0:g.content)||"",ze.find(v=>v.key===W).width),sandbox:"allow-same-origin allow-scripts",title:"HTML 预览",style:{width:`${ze.find(v=>v.key===W).width}px`,height:"100%",minHeight:0,border:"1px solid #e5e7eb",borderRadius:10,background:"#fff",boxShadow:"0 4px 24px 0 rgba(0,0,0,0.10)",flexShrink:0}})}):e.jsx("iframe",{srcDoc:P((g==null?void 0:g.content)||""),sandbox:"allow-same-origin allow-scripts",title:"HTML 预览",style:{width:"100%",height:"100%",border:"none",background:"#fff",display:"block"}})}):e.jsxs("div",{className:"h-full flex flex-col",style:{background:"#1e1e2e"},children:[e.jsxs("div",{className:"shrink-0 flex items-center justify-between px-4 py-2 border-b",style:{borderColor:"#2d2d3e",background:"#252536"},children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("span",{className:"w-3 h-3 rounded-full bg-red-400/80 inline-block"}),e.jsx("span",{className:"w-3 h-3 rounded-full bg-yellow-400/80 inline-block"}),e.jsx("span",{className:"w-3 h-3 rounded-full bg-green-400/80 inline-block"})]}),e.jsx("span",{className:"text-xs font-mono ml-2",style:{color:"#6c7086"},children:"index.html"})]}),e.jsx("span",{className:"text-xs font-mono",style:{color:"#6c7086"},children:g!=null&&g.content?`${g.content.split(`
|
|
186
|
+
`).length} 行 · ${g.content.length} 字符`:"空"})]}),e.jsx("div",{className:"flex-1 overflow-auto",children:e.jsx("pre",{className:"m-0 p-5 text-xs font-mono whitespace-pre-wrap break-all leading-relaxed",style:{color:"#cdd6f4"},children:(g==null?void 0:g.content)||e.jsx("span",{style:{color:"#585b70"},children:"// 暂无内容"})})})]})}),e.jsxs("div",{className:"shrink-0 flex items-center justify-between px-5 py-2.5 border-t border-gray-100 bg-gray-50/60",children:[e.jsxs("div",{className:"flex items-center gap-4 text-xs text-gray-400",children:[(g==null?void 0:g.createdAt)&&e.jsxs("span",{children:["创建于"," ",He(g.createdAt).format("YYYY/MM/DD HH:mm")]}),(g==null?void 0:g.updatedAt)&&e.jsxs("span",{children:["更新于"," ",He(g.updatedAt).format("YYYY/MM/DD HH:mm")]})]}),e.jsxs("button",{className:"flex items-center gap-1.5 px-3 py-1.5 text-xs border border-gray-200 rounded-lg hover:bg-gray-50 text-gray-600 transition cursor-pointer",onClick:Y,children:[e.jsx(ft,{size:12}),"编辑"]})]})]})};exports.ArticleServiceError=pe.ArticleServiceError;exports.createArticleService=pe.createArticleService;exports.defaultArticleService=pe.defaultArticleService;exports.renderArticleByPathname=pe.renderArticleByPathname;exports.ArticleDetail=as;exports.ArticleEdit=ss;exports.ArticleList=Rr;exports.ArticlesProvider=Ht;exports.ReactRouterAdapter=Gt;
|