@blocklet/list 0.14.6 → 0.14.7

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.
Files changed (2) hide show
  1. package/lib/index.es.js +683 -765
  2. package/package.json +3 -5
package/lib/index.es.js CHANGED
@@ -1,58 +1,56 @@
1
- import { jsx as t, jsxs as p, Fragment as A } from "react/jsx-runtime";
2
- import { styled as _, useTheme as xe } from "@arcblock/ux/lib/Theme";
3
- import { Global as we, css as ke } from "@emotion/react";
1
+ import { jsx as t, jsxs as f, Fragment as M } from "react/jsx-runtime";
2
+ import { styled as E, useTheme as fe } from "@arcblock/ux/lib/Theme";
3
+ import { Box as v, Autocomplete as Qe, TextField as Xe, OutlinedInput as Ke, InputAdornment as ae, Button as J, useTheme as ge, useMediaQuery as O, Drawer as Ye, CircularProgress as Z, MenuList as Je, SvgIcon as Ze, Popper as et, Grow as tt, Paper as rt, ClickAwayListener as ot, MenuItem as nt, Stack as z, FormControlLabel as ye, Checkbox as xe, Typography as L, Link as lt, Grid as se, Chip as it, createTheme as at, ThemeProvider as st } from "@mui/material";
4
+ import ct from "lodash/merge";
4
5
  import { ErrorFallback as ee } from "@arcblock/ux/lib/ErrorBoundary";
5
- import { Button as te, useTheme as ve, useMediaQuery as N, Drawer as Je, Box as C, CircularProgress as re, MenuList as Ke, SvgIcon as Ze, Popper as et, Grow as tt, Paper as rt, ClickAwayListener as ot, MenuItem as nt, Stack as L, FormControlLabel as Ce, Checkbox as Se, Typography as $, Link as lt, Grid as he, Chip as at, OutlinedInput as it, InputAdornment as me } from "@mui/material";
6
- import { ErrorBoundary as st } from "react-error-boundary";
7
- import ct from "@iconify-icons/tabler/compass";
8
- import { Icon as Be } from "@iconify/react";
9
- import Re from "@mui/icons-material/Close";
10
- import { createContext as Pe, useState as q, useMemo as M, useContext as Ie, useCallback as Z, useEffect as W, forwardRef as dt, useRef as G, memo as ut, createElement as pt, Fragment as ht } from "react";
11
- import { createAxios as Te } from "@blocklet/js-sdk";
12
- import mt from "lodash/orderBy";
13
- import { useInfiniteScroll as ft, useRequest as oe, useReactive as gt, useDebounceFn as yt } from "ahooks";
14
- import bt from "lodash/omitBy";
15
- import xt from "json-stable-stringify";
16
- import wt from "color";
6
+ import { ErrorBoundary as dt } from "react-error-boundary";
7
+ import ut from "@iconify-icons/tabler/compass";
8
+ import { Icon as be } from "@iconify/react";
9
+ import we from "@mui/icons-material/Close";
10
+ import { createContext as ke, useState as F, useMemo as D, useContext as ve, useCallback as X, useEffect as N, useRef as K, forwardRef as pt, memo as ht } from "react";
11
+ import { createAxios as Ce } from "@blocklet/js-sdk";
12
+ import mt from "lodash/omitBy";
13
+ import ft from "lodash/orderBy";
14
+ import { useRequest as U, useDebounceFn as Se, useInfiniteScroll as gt, useReactive as yt } from "ahooks";
15
+ import "color";
17
16
  import "lodash/cloneDeep";
18
- import { parseURL as kt, parseQuery as vt, parseFilename as Ct, stringifyParsedURL as St, withQuery as Le, joinURL as Bt } from "ufo";
19
- import fe from "flat";
20
- import Rt from "@mui/icons-material/Check";
17
+ import { parseURL as xt, parseQuery as bt, parseFilename as wt, stringifyParsedURL as kt, withQuery as Pe, joinURL as ce } from "ufo";
18
+ import de from "flat";
19
+ import Be from "@arcblock/ux/lib/Avatar";
20
+ import Y from "@mui/icons-material/Search";
21
+ import vt from "@mui/material/CircularProgress";
22
+ import { useHotkeys as Ct } from "react-hotkeys-hook";
23
+ import w from "prop-types";
24
+ import St from "@mui/icons-material/Check";
21
25
  import Pt from "@mui/icons-material/KeyboardArrowDown";
22
- import It from "lodash/isEmpty";
23
- import k from "prop-types";
24
- import $e from "@mui/material/Box";
25
- import Tt from "@arcblock/ux/lib/Avatar";
26
- import Lt from "@arcblock/ux/lib/Img";
27
- import $t from "@iconify-icons/tabler/cloud-download";
28
- import zt from "@mui/icons-material/ChevronLeft";
29
- import Ft from "@mui/icons-material/ChevronRight";
26
+ import Bt from "lodash/isEmpty";
27
+ import Te from "@mui/material/Box";
28
+ import Tt from "@arcblock/ux/lib/Img";
29
+ import Rt from "@iconify-icons/tabler/cloud-download";
30
+ import It from "@mui/icons-material/ChevronLeft";
31
+ import Lt from "@mui/icons-material/ChevronRight";
30
32
  import At from "react-image-gallery";
31
33
  import "react-image-gallery/styles/css/image-gallery.css";
32
- import Et from "@arcblock/ux/lib/Empty";
34
+ import zt from "@arcblock/ux/lib/Empty";
33
35
  import _t from "react-infinite-scroll-hook";
34
- import ze from "@mui/material/Typography";
35
- import Dt from "@mui/icons-material/Menu";
36
- import { createRoot as Nt } from "react-dom/client";
37
- import { autocomplete as Mt } from "@algolia/autocomplete-js";
38
- import { useHotkeys as Ot } from "react-hotkeys-hook";
39
- import jt from "@mui/icons-material/Search";
40
- import "@algolia/autocomplete-theme-classic/dist/theme.css";
41
- const Fe = Pe({
36
+ import Re from "@mui/material/Typography";
37
+ import Ft from "json-stable-stringify";
38
+ import Et from "@mui/icons-material/Menu";
39
+ const Ie = ke({
42
40
  open: !1,
43
41
  toggleOpen: (e) => {
44
42
  }
45
43
  });
46
- function qt({ children: e }) {
47
- const [r, o] = q(!1), l = (a) => {
44
+ function Ot({ children: e }) {
45
+ const [r, o] = F(!1), l = (a) => {
48
46
  o(a ?? !a);
49
- }, n = M(() => ({ open: r, toggleOpen: l }), [r]);
50
- return /* @__PURE__ */ t(Fe.Provider, { value: n, children: e });
47
+ }, n = D(() => ({ open: r, toggleOpen: l }), [r]);
48
+ return /* @__PURE__ */ t(Ie.Provider, { value: n, children: e });
51
49
  }
52
- function ne() {
53
- return Ie(Fe);
50
+ function te() {
51
+ return ve(Ie);
54
52
  }
55
- const T = {
53
+ const I = {
56
54
  nameAsc: "title",
57
55
  nameDesc: "title",
58
56
  popularity: "stats.downloads",
@@ -66,32 +64,13 @@ const T = {
66
64
  explorePath: "/api/blocklets/explore",
67
65
  exploreDidsPath: "/api/blocklets/dids",
68
66
  cacheSize: 100
69
- }, Wt = (e, r, o, l) => ft(
70
- async (n) => {
71
- n || (o.currentPage = o.defaultCurrentPage);
72
- const { currentPage: a, pageSize: d } = o, c = {
73
- ...r,
74
- category: r.category === "All" ? "" : r.category,
75
- sortBy: T[r.sortBy],
76
- page: a,
77
- pageSize: d
78
- };
79
- l(null);
80
- const { data: s = {} } = await e.get(T.blockletsPath, { params: c });
81
- return o.currentPage++, { page: a, pageSize: d, list: (s == null ? void 0 : s.dataList) || [], total: (s == null ? void 0 : s.total) || 0 };
82
- },
83
- {
84
- isNoMore: (n) => n ? n.page * n.pageSize >= n.total : !1,
85
- reloadDeps: [e, xt(r)],
86
- onError: l
87
- }
88
- ), Vt = (e) => oe(
67
+ }, Dt = (e) => U(
89
68
  async () => {
90
- const { data: r } = await e.get(T.categoriesPath);
69
+ const { data: r } = await e.get(I.categoriesPath);
91
70
  return Array.isArray(r) ? r : [];
92
71
  },
93
72
  { manual: !0 }
94
- ), Ae = (e) => [
73
+ ), Le = (e) => [
95
74
  {
96
75
  name: e("sort.popularity"),
97
76
  value: "popularity"
@@ -104,40 +83,32 @@ const T = {
104
83
  // name: t('sort.rating'),
105
84
  // value: 'rating',
106
85
  // },
107
- ], Ut = (e, r, o) => {
108
- var f, m;
109
- const l = kt(e), n = vt(l.search);
110
- if ((f = Ct(e, { strict: !0 })) == null ? void 0 : f.endsWith(".gif"))
111
- return n.imageFilter ? St({ ...l, search: "" }) : e;
86
+ ], Ae = (e, r, o) => {
87
+ var g, h;
88
+ const l = xt(e), n = bt(l.search);
89
+ if ((g = wt(e, { strict: !0 })) == null ? void 0 : g.endsWith(".gif"))
90
+ return n.imageFilter ? kt({ ...l, search: "" }) : e;
112
91
  if (n.imageFilter)
113
92
  return e;
114
- const d = (m = window.blocklet) == null ? void 0 : m.version, { w: c, h: s } = typeof r == "object" ? { w: r.w, h: r.h } : { w: r, h: r };
115
- return Le(e, {
116
- ...c || s ? { imageFilter: "resize", w: c, h: s } : {},
93
+ const d = o || ((h = window.blocklet) == null ? void 0 : h.version), { w: u, h: i } = typeof r == "object" ? { w: r.w, h: r.h } : { w: r, h: r };
94
+ return Pe(e, {
95
+ ...u || i ? { imageFilter: "resize", w: u, h: i } : {},
117
96
  v: d
118
97
  });
119
- }, Gt = (e) => [
98
+ }, Mt = (e) => [
120
99
  { name: e("blocklet.free"), value: "free" },
121
100
  { name: e("blocklet.payment"), value: "payment" }
122
- ], Ht = (e = [], r = "en") => e.map((o) => ({ name: o.locales[r] || o.locales.en, value: o._id })), Qt = (e, r) => (
101
+ ], Nt = (e = [], r = "en") => e.map((o) => ({ name: o.locales[r] || o.locales.en, value: o._id })), $t = (e, r) => (
123
102
  // eslint-disable-next-line no-prototype-builtins
124
103
  e == null ? void 0 : e.replace(/{(\w*)}/g, (o, l) => r.hasOwnProperty(l) ? r[l] : "")
125
- ), Xt = () => window.innerWidth <= 600, Yt = (e) => wt(e).rgb().object();
126
- function Jt(e, r) {
127
- let o;
128
- return function(...n) {
129
- return o && clearTimeout(o), new Promise((a) => {
130
- o = setTimeout(() => a(e(...n)), r);
131
- });
132
- };
133
- }
134
- const Kt = Jt((e) => Promise.resolve(e), 300), Zt = {
104
+ ), Wt = () => window.innerWidth <= 600, jt = {
135
105
  common: {
136
106
  title: "Blocklet Store",
137
107
  searchStore: "Search Blocklet",
138
108
  showResources: "Show resources",
139
109
  price: "Price",
140
110
  category: "Category",
111
+ categories: "Categories",
141
112
  resourceType: "Resource Type",
142
113
  clear: "Clear",
143
114
  cancel: "Cancel",
@@ -179,13 +150,14 @@ const Kt = Jt((e) => Promise.resolve(e), 300), Zt = {
179
150
  autocomplete: {
180
151
  expandResult: 'View all search results for "{name}"'
181
152
  }
182
- }, er = {
153
+ }, qt = {
183
154
  common: {
184
155
  title: "Blocklet 商店",
185
156
  searchStore: "搜索 Blocklet",
186
157
  showResources: "显示资源型应用",
187
158
  price: "价格",
188
159
  category: "类别",
160
+ categories: "类别",
189
161
  resourceType: "资源类型",
190
162
  clear: "清除",
191
163
  cancel: "取消",
@@ -227,37 +199,32 @@ const Kt = Jt((e) => Promise.resolve(e), 300), Zt = {
227
199
  autocomplete: {
228
200
  expandResult: "查看 “{name}” 的所有搜索结果"
229
201
  }
230
- }, K = {
231
- en: fe(Zt),
232
- zh: fe(er)
233
- }, Ee = (e, r) => {
202
+ }, Q = {
203
+ en: de(jt),
204
+ zh: de(qt)
205
+ }, ze = (e, r) => {
234
206
  const o = {};
235
207
  return e && (o["x-blocklet-server-version"] = e), r && (o["x-blocklet-store-version"] = r), o;
236
- }, tr = (e) => (r, o) => {
237
- const l = K[e] ? K[e][r] : K.en[r];
238
- return Qt(l, o) || r;
208
+ }, Ut = (e) => (r, o) => {
209
+ const l = Q[e] ? Q[e][r] : Q.en[r];
210
+ return $t(l, o) || r;
239
211
  }, _e = {
240
212
  errors: {
241
- fetchBlockletsError: null,
242
213
  fetchCategoriesError: null
243
214
  },
244
215
  loadings: {
245
- fetchBlockletsLoading: !1,
246
- fetchCategoriesLoading: !1,
247
- loadingMore: !1
216
+ fetchCategoriesLoading: !1
248
217
  },
249
218
  endpoint: "",
250
- blockletList: [],
251
219
  wrapChildren: () => null,
252
220
  t: (e) => e,
253
221
  storeVersion: "",
254
- minItemWidth: 400,
222
+ minItemWidth: 350,
255
223
  serverVersion: "",
256
224
  filters: {},
257
225
  layout: {},
258
226
  selectedCategory: void 0,
259
227
  categoryList: [],
260
- total: 0,
261
228
  blockletRender: () => null,
262
229
  locale: "en",
263
230
  categoryOptions: [],
@@ -267,7 +234,6 @@ const Kt = Jt((e) => Promise.resolve(e), 300), Zt = {
267
234
  showResourcesSwitch: !1,
268
235
  showCategory: !1,
269
236
  tagFilters: [],
270
- hasNextPage: !1,
271
237
  onFilterChange: () => {
272
238
  },
273
239
  handleSort: () => {
@@ -284,182 +250,328 @@ const Kt = Jt((e) => Promise.resolve(e), 300), Zt = {
284
250
  },
285
251
  handlePage: () => {
286
252
  },
287
- handleSwitchShowResources: () => {
253
+ developerName: "",
254
+ updateDeveloperName: () => {
288
255
  },
289
- loadMore: () => {
256
+ handleSwitchShowResources: () => {
290
257
  },
291
258
  getCategoryLocale: () => null,
292
- developerName: "",
293
259
  handleSearchSelect: () => {
294
260
  }
295
- }, De = Pe(_e), { Provider: rr, Consumer: ao } = De;
296
- function or(e) {
297
- var ue;
261
+ }, Fe = ke(_e), { Provider: Vt, Consumer: Yr } = Fe;
262
+ function Ht(e) {
298
263
  const {
299
264
  locale: r = "zh",
300
265
  filters: o = {},
301
266
  serverVersion: l = "",
302
267
  onFilterChange: n = () => {
303
268
  },
304
- onSearchSelect: a = ({ detailUrl: i }) => {
305
- window.location.href = i;
269
+ onSearchSelect: a = ({ detailUrl: p }) => {
270
+ window.location.href = p;
306
271
  },
307
- minItemWidth: d = 400,
308
- queryFilter: c = !0,
309
- layout: s = {},
310
- wrapChildren: f = (i) => i,
311
- extraFilter: m = (i) => i,
312
- baseSearch: v = !1,
313
- fetchCategoryDelay: z = 0,
272
+ minItemWidth: d = 350,
273
+ queryFilter: u = !0,
274
+ layout: i = {},
275
+ wrapChildren: g = (p) => p,
276
+ extraFilter: h = (p) => p,
277
+ baseSearch: m = !1,
278
+ fetchCategoryDelay: C = 0,
314
279
  showResourcesSwitch: R = !1,
315
- showCategory: S = !0,
316
- tagFilters: u = [],
317
- children: x,
318
- storeVersion: h,
319
- endpoint: g,
320
- blockletRender: w
321
- } = e, P = Ee(l, h), F = M(() => Te({ baseURL: g, headers: P }), [g]), y = { sortBy: "popularity", sortDirection: "desc", ...o };
322
- !y.category && !s.showExplore && (y.category = "All");
323
- const D = y.category, We = gt({
324
- currentPage: T.currentPage,
325
- pageSize: Xt() ? T.mobilePageSize : T.pageSize,
326
- defaultCurrentPage: T.defaultCurrentPage
327
- }), [Ve, Ue] = q(null), E = Wt(F, y, We, Ue), {
328
- data: Y = [],
329
- error: Ge,
330
- loading: He,
331
- run: se
332
- } = Vt(F), J = M(() => {
333
- const i = mt(Y, [(I) => I.name], ["asc"]), b = i.findIndex((I) => I.name === "All" || I.locales.en === "All");
334
- return b > -1 ? [{ ...i[b], _id: "All" }, ...i.slice(0, b), ...i.slice(b + 1)] : i;
335
- }, [Y]), ce = M(
336
- () => {
337
- var i;
338
- return m(((i = E.data) == null ? void 0 : i.list) || []) || [];
339
- },
340
- [E.data, m]
341
- ), de = Z(tr(r), [r]), Qe = M(() => Ht(J, r), [J, r]), Xe = Gt(de), Ye = {
342
- errors: { fetchBlockletsError: Ve, fetchCategoriesError: Ge },
280
+ showCategory: A = !0,
281
+ tagFilters: c = [],
282
+ children: k,
283
+ storeVersion: x,
284
+ endpoint: B,
285
+ blockletRender: s
286
+ } = e, y = ze(l, x), T = D(() => Ce({ baseURL: B, headers: y }), [B]), P = { sortBy: "popularity", sortDirection: "desc", ...o };
287
+ !P.category && !i.showExplore && (P.category = "All");
288
+ const [Ne, $e] = F(""), We = P.category, {
289
+ data: H = [],
290
+ error: je,
291
+ loading: qe,
292
+ run: le
293
+ } = Dt(T), G = D(() => {
294
+ const p = ft(H, [(_) => _.name], ["asc"]), b = p.findIndex((_) => _.name === "All" || _.locales.en === "All");
295
+ return b > -1 ? [{ ...p[b], _id: "All" }, ...p.slice(0, b), ...p.slice(b + 1)] : p;
296
+ }, [H]), ie = X(Ut(r), [r]), Ue = D(() => Nt(G, r), [G, r]), Ve = Mt(ie), He = {
297
+ errors: { fetchCategoriesError: je },
343
298
  loadings: {
344
- fetchBlockletsLoading: E.loading,
345
- fetchCategoriesLoading: He,
346
- loadingMore: E.loadingMore
299
+ fetchCategoriesLoading: qe
347
300
  },
348
- endpoint: g,
349
- queryFilter: c,
301
+ extraFilter: h,
302
+ endpoint: B,
303
+ queryFilter: u,
350
304
  layout: {
351
- showExplore: s.showExplore ?? !1,
352
- showCategory: s.showCategory ?? !0,
353
- showTitle: s.showTitle ?? !0,
354
- showSearch: s.showSearch ?? !0
305
+ showExplore: i.showExplore ?? !1,
306
+ showCategory: i.showCategory ?? !0,
307
+ showTitle: i.showTitle ?? !0,
308
+ showSearch: i.showSearch ?? !0
355
309
  },
356
310
  minItemWidth: d,
357
- blockletList: ce,
358
- total: ((ue = E.data) == null ? void 0 : ue.total) || 0,
359
- wrapChildren: f,
360
- t: de,
361
- storeVersion: h,
311
+ wrapChildren: g,
312
+ t: ie,
313
+ storeVersion: x,
362
314
  serverVersion: l,
363
- filters: y,
364
- selectedCategory: D,
365
- categoryList: J,
366
- blockletRender: w,
315
+ filters: P,
316
+ selectedCategory: We,
317
+ categoryList: G,
318
+ blockletRender: s,
367
319
  locale: r,
368
- categoryOptions: Qe,
369
- priceOptions: Xe,
370
- storeApi: F,
371
- baseSearch: v,
320
+ categoryOptions: Ue,
321
+ priceOptions: Ve,
322
+ storeApi: T,
323
+ baseSearch: m,
372
324
  showResourcesSwitch: R,
373
- showCategory: S,
374
- tagFilters: u,
375
- hasNextPage: !E.noMore,
325
+ showCategory: A,
326
+ tagFilters: c,
376
327
  onFilterChange: n,
377
- cleanFilter: (i) => {
378
- const b = i ? bt(y, (I, O) => i == null ? void 0 : i.includes(O)) : {};
328
+ cleanFilter: (p) => {
329
+ const b = p ? mt(P, (_, Ge) => p == null ? void 0 : p.includes(Ge)) : {};
379
330
  n(b);
380
331
  },
381
- handleSort: (i) => {
382
- const b = { ...y, sortBy: i, sortDirection: i === "nameAsc" ? "asc" : "desc" };
332
+ handleSort: (p) => {
333
+ const b = { ...P, sortBy: p, sortDirection: p === "nameAsc" ? "asc" : "desc" };
383
334
  n(b);
384
335
  },
385
- handleKeyword: (i) => {
386
- const b = { ...y, category: void 0, keyword: i || void 0 };
336
+ handleKeyword: (p) => {
337
+ const b = { ...P, category: void 0, keyword: p || void 0 };
387
338
  n(b);
388
339
  },
389
- handlePrice: (i) => {
390
- const b = { ...y, price: i === y.price ? void 0 : i };
340
+ handlePrice: (p) => {
341
+ const b = { ...P, price: p === P.price ? void 0 : p };
391
342
  n(b);
392
343
  },
393
- handleCategory: (i) => {
394
- const b = i === "all" || i === y.category ? "" : i, I = { ...y, category: b };
395
- n(I);
344
+ handleCategory: (p) => {
345
+ const b = p === "all" || p === P.category ? "" : p, _ = { ...P, category: b };
346
+ n(_);
396
347
  },
397
- handleDeveloper: (i) => {
398
- const b = { ...y, owner: i || void 0 };
348
+ handleDeveloper: (p) => {
349
+ const b = { ...P, owner: p || void 0 };
399
350
  n(b);
400
351
  },
401
- handlePage: (i) => {
402
- const b = { ...y, currentPage: i };
352
+ handlePage: (p) => {
353
+ const b = { ...P, currentPage: p };
403
354
  n(b);
404
355
  },
405
356
  handleSwitchShowResources: () => {
406
- const i = { ...y };
407
- n(i);
357
+ const p = { ...P };
358
+ n(p);
408
359
  },
409
- loadMore: E.loadMore,
410
- getCategoryLocale: (i) => {
411
- if (!i)
360
+ getCategoryLocale: (p) => {
361
+ if (!p)
412
362
  return null;
413
- const b = Y.find((I) => I._id === i);
363
+ const b = H.find((_) => _._id === p);
414
364
  return b ? b.locales[r] || b.locales.en : null;
415
365
  },
416
366
  get developerName() {
417
- var b, I;
418
- const i = ce.find((O) => {
419
- var pe;
420
- return ((pe = O == null ? void 0 : O.owner) == null ? void 0 : pe.did) === y.owner;
421
- });
422
- return ((b = i == null ? void 0 : i.owner) == null ? void 0 : b.fullName) || ((I = i == null ? void 0 : i.author) == null ? void 0 : I.name) || "";
367
+ return Ne;
423
368
  },
369
+ updateDeveloperName: $e,
424
370
  handleSearchSelect: a
425
371
  };
426
- return W(() => {
427
- setTimeout(se, z || 0);
428
- }, [g, se, z]), /* @__PURE__ */ t(rr, { value: Ye, children: x });
372
+ return N(() => {
373
+ setTimeout(le, C || 0);
374
+ }, [B, le, C]), /* @__PURE__ */ t(Vt, { value: He, children: k });
429
375
  }
430
- function B() {
431
- const e = Ie(De);
376
+ function S() {
377
+ const e = ve(Fe);
432
378
  return e || _e;
433
379
  }
434
- function Ne({
380
+ const ue = "__FREE_TEXT__";
381
+ function Gt() {
382
+ const e = K(null), r = K(!1), [o, l] = F(!1), [n, a] = F(""), { storeApi: d, filters: u, endpoint: i, handleKeyword: g, t: h, handleSearchSelect: m } = S(), C = async (s) => {
383
+ const { data: y } = await d.get(I.blockletsPath, { params: s });
384
+ return y.dataList || [];
385
+ }, { loading: R, data: A, run: c } = U(
386
+ (s) => s ? C({
387
+ sortBy: I.nameDesc,
388
+ page: 1,
389
+ pageSize: 10,
390
+ keyword: s
391
+ }) : Promise.resolve([]),
392
+ {
393
+ manual: !0
394
+ }
395
+ );
396
+ N(() => {
397
+ c(u.keyword), a(u.keyword || "");
398
+ }, [u.keyword, c]), Ct(
399
+ "ctrl + k, command + k",
400
+ (s) => {
401
+ var y, T;
402
+ return s.stopPropagation(), s.preventDefault(), (T = (y = e.current) == null ? void 0 : y.querySelector("input")) == null || T.focus(), !1;
403
+ },
404
+ { enableOnTags: ["INPUT"] }
405
+ );
406
+ const k = Se((s) => c(s), { wait: 300 }), x = { name: ue, title: n, did: "" };
407
+ return /* @__PURE__ */ t(v, { overflow: "hidden", children: /* @__PURE__ */ t(
408
+ Qe,
409
+ {
410
+ ref: e,
411
+ open: !!n && o,
412
+ size: "small",
413
+ onOpen: () => {
414
+ l(!0);
415
+ },
416
+ onClose: (s, y) => {
417
+ l(!1), y === "selectOption" && !r.current && g(n);
418
+ },
419
+ options: n ? [x, ...A || []] : [],
420
+ renderOption: (s, y) => /* @__PURE__ */ f(v, { component: "li", ...s, gap: 1, children: [
421
+ B(y),
422
+ y.title
423
+ ] }),
424
+ value: x,
425
+ onChange: (s, y) => {
426
+ y != null && y.did && (r.current = !0, m({
427
+ blocklet: y,
428
+ detailUrl: ce(i, "blocklets", y.did),
429
+ storeUrl: i
430
+ }));
431
+ },
432
+ inputValue: n,
433
+ onInputChange: (s, y, T) => {
434
+ a(y), r.current = !1, k.run(y), T === "clear" && g("");
435
+ },
436
+ isOptionEqualToValue: (s, y) => s.name === y.name,
437
+ getOptionLabel: (s) => s.title,
438
+ getOptionKey: (s) => s.name,
439
+ noOptionsText: h("blocklet.noResults"),
440
+ loading: R,
441
+ autoHighlight: !0,
442
+ forcePopupIcon: !1,
443
+ slotProps: { paper: { sx: { mt: 0.5, minWidth: "100%", width: "fit-content" } } },
444
+ sx: {
445
+ bgcolor: "#F9FAFB",
446
+ borderRadius: "8px",
447
+ overflow: "hidden",
448
+ ".MuiAutocomplete-clearIndicator": { visibility: n ? "visible" : "hidden" },
449
+ ".MuiOutlinedInput-notchedOutline": {
450
+ borderRadius: "8px",
451
+ borderColor: "transparent"
452
+ },
453
+ "&&:hover .MuiOutlinedInput-notchedOutline, &&.Mui-focused .MuiOutlinedInput-notchedOutline": {
454
+ borderColor: "divider"
455
+ }
456
+ },
457
+ renderInput: (s) => /* @__PURE__ */ t(
458
+ Xe,
459
+ {
460
+ ...s,
461
+ InputProps: {
462
+ ...s.InputProps,
463
+ autoFocus: !0,
464
+ placeholder: h("common.searchStore"),
465
+ className: "bl-autocomplete-input",
466
+ value: n,
467
+ startAdornment: /* @__PURE__ */ t(v, { sx: { display: "flex", pl: 0.5, alignItems: "center", color: "text.lighter" }, children: R ? /* @__PURE__ */ t(vt, { color: "inherit", size: 16 }) : /* @__PURE__ */ t(Y, { sx: { fontSize: 16 } }) })
468
+ }
469
+ }
470
+ ),
471
+ filterOptions: (s) => s
472
+ }
473
+ ) });
474
+ function B(s) {
475
+ if (s.name === ue)
476
+ return /* @__PURE__ */ t(v, { width: 20, display: "flex", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ t(Y, { sx: { fontSize: 16 } }) });
477
+ let y = "";
478
+ return s.logo && (y = ce(i, "assets", s.did, Ae(s.logo, 20, s.version))), /* @__PURE__ */ t(Be, { src: y, size: 20 });
479
+ }
480
+ }
481
+ function re({ placeholder: e, ...r }) {
482
+ const { filters: o, handleKeyword: l } = S(), [n, a] = F(o.keyword || ""), d = Se(l, { wait: 300 }), u = (g) => {
483
+ const { value: h } = g.target;
484
+ a(h), d.run(h);
485
+ }, i = () => {
486
+ a(""), l();
487
+ };
488
+ return N(() => {
489
+ a(o.keyword || "");
490
+ }, [o.keyword]), /* @__PURE__ */ t(
491
+ Qt,
492
+ {
493
+ inputProps: {
494
+ "data-cy": "search-blocklet"
495
+ },
496
+ startAdornment: /* @__PURE__ */ t(ae, { position: "start", children: /* @__PURE__ */ t(Xt, {}) }),
497
+ onChange: u,
498
+ placeholder: e,
499
+ value: n,
500
+ title: e,
501
+ "data-cy": "search",
502
+ endAdornment: n && /* @__PURE__ */ t(ae, { position: "end", children: /* @__PURE__ */ t(Kt, { "data-cy": "search-delete", onClick: i }) }),
503
+ ...r
504
+ }
505
+ );
506
+ }
507
+ re.propTypes = {
508
+ placeholder: w.string
509
+ };
510
+ re.defaultProps = {
511
+ placeholder: "Type to search..."
512
+ };
513
+ const Qt = E(Ke)`
514
+ background-color: ${(e) => e.theme.palette.grey[50]};
515
+ font-size: 14px;
516
+ border-radius: 6px;
517
+ width: 100%;
518
+ .MuiInputBase-input {
519
+ padding: 8px 0 8px 10px;
520
+ }
521
+ .MuiOutlinedInput-notchedOutline {
522
+ border: none;
523
+ }
524
+ .Mui-focused {
525
+ background-color: #f6f6f6;
526
+ .MuiInputBase-input::placeholder {
527
+ color: transparent;
528
+ }
529
+ }
530
+ `, Xt = E(Y)`
531
+ color: ${(e) => e.theme.palette.grey[500]};
532
+ font-size: 28px;
533
+ @media (max-width: ${(e) => e.theme.breakpoints.values.md}px) {
534
+ font-size: 24px;
535
+ }
536
+ `, Kt = E(we)`
537
+ color: ${(e) => e.theme.palette.grey[500]};
538
+ font-size: 16px;
539
+ cursor: pointer;
540
+ `;
541
+ function Ee({
435
542
  children: e,
436
543
  onClick: r,
437
- size: o = 32
544
+ size: o = 32,
545
+ ...l
438
546
  }) {
439
547
  return /* @__PURE__ */ t(
440
- te,
548
+ J,
441
549
  {
550
+ ...l,
442
551
  onClick: r,
443
552
  variant: "outlined",
444
- sx: {
445
- minWidth: o,
446
- height: o,
447
- p: 0,
448
- borderColor: "divider",
449
- "&:hover": {
450
- borderColor: "divider"
553
+ sx: [
554
+ {
555
+ minWidth: o,
556
+ height: o,
557
+ p: 0,
558
+ borderColor: "divider",
559
+ "&:hover": {
560
+ borderColor: "divider"
561
+ },
562
+ borderRadius: 2,
563
+ color: "text.secondary"
451
564
  },
452
- borderRadius: 2,
453
- color: "text.secondary"
454
- },
565
+ ...Array.isArray(l.sx) ? l.sx : [l.sx]
566
+ ],
455
567
  children: e
456
568
  }
457
569
  );
458
570
  }
459
- function V(e, r) {
571
+ function W(e, r) {
460
572
  return e === void 0 ? r : e;
461
573
  }
462
- function Q({
574
+ function oe({
463
575
  xs: e,
464
576
  sm: r,
465
577
  md: o,
@@ -467,74 +579,74 @@ function Q({
467
579
  xl: n,
468
580
  exact: a
469
581
  }) {
470
- const d = ve(), c = N(d.breakpoints.down("sm")), s = N(d.breakpoints.between("sm", "md")), f = N(d.breakpoints.between("md", "lg")), m = N(d.breakpoints.between("lg", "xl"));
582
+ const d = ge(), u = O(d.breakpoints.down("sm")), i = O(d.breakpoints.between("sm", "md")), g = O(d.breakpoints.between("md", "lg")), h = O(d.breakpoints.between("lg", "xl"));
471
583
  if (a)
472
- return c ? e || null : s ? r || null : f ? o || null : m ? l || null : n || null;
473
- let v = e;
474
- return c || (v = V(r, v), s) || (v = V(o, v), f) || (v = V(l, v), m) ? v : V(n, v);
584
+ return u ? e || null : i ? r || null : g ? o || null : h ? l || null : n || null;
585
+ let m = e;
586
+ return u || (m = W(r, m), i) || (m = W(o, m), g) || (m = W(l, m), h) ? m : W(n, m);
475
587
  }
476
- function nr({ children: e }) {
477
- const { open: r, toggleOpen: o } = ne();
588
+ function Yt({ children: e }) {
589
+ const { open: r, toggleOpen: o } = te();
478
590
  return /* @__PURE__ */ t(
479
- Q,
591
+ oe,
480
592
  {
481
- xs: /* @__PURE__ */ t(Je, { open: r, onClose: () => o(!1), children: e }),
482
- md: /* @__PURE__ */ t(C, { children: e })
593
+ xs: /* @__PURE__ */ t(Ye, { open: r, onClose: () => o(!1), children: e }),
594
+ md: /* @__PURE__ */ t(v, { children: e })
483
595
  }
484
596
  );
485
597
  }
486
- const lr = _(te)`
598
+ const Jt = E(J)`
487
599
  border-radius: 4px;
488
- `, le = dt(({ children: e, rounded: r, loading: o, disabled: l, ...n }, a) => /* @__PURE__ */ t(
489
- lr,
600
+ `, ne = pt(({ children: e, rounded: r, loading: o, disabled: l, ...n }, a) => /* @__PURE__ */ t(
601
+ Jt,
490
602
  {
491
603
  ref: a,
492
604
  disableElevation: !0,
493
605
  disabled: l || o,
494
606
  ...n,
495
- startIcon: o && /* @__PURE__ */ t(re, { size: "1em" }),
607
+ startIcon: o && /* @__PURE__ */ t(Z, { size: "1em" }),
496
608
  children: e
497
609
  }
498
610
  ));
499
- le.propTypes = {
500
- children: k.any,
501
- rounded: k.bool,
502
- loading: k.bool,
503
- disabled: k.bool
611
+ ne.propTypes = {
612
+ children: w.any,
613
+ rounded: w.bool,
614
+ loading: w.bool,
615
+ disabled: w.bool
504
616
  };
505
- le.defaultProps = {
617
+ ne.defaultProps = {
506
618
  children: null,
507
619
  rounded: !1,
508
620
  loading: !1,
509
621
  disabled: !1
510
622
  };
511
- function X({ title: e, value: r, icon: o, prepend: l, options: n, onChange: a, itemRender: d, ...c }) {
512
- const s = G(null), f = xe(), [m, v] = q(!1), [z, R] = q(r !== null ? r : ""), S = N(f.breakpoints.down("sm"));
513
- W(() => {
623
+ function V({ title: e, value: r, icon: o, prepend: l, options: n, onChange: a, itemRender: d, ...u }) {
624
+ const i = K(null), g = fe(), [h, m] = F(!1), [C, R] = F(r !== null ? r : ""), A = O(g.breakpoints.down("sm"));
625
+ N(() => {
514
626
  R(r !== null ? r : "");
515
627
  }, [r]);
516
- const u = Z(() => {
517
- v(!1);
518
- }, []), x = Z(() => {
519
- v(!0);
628
+ const c = X(() => {
629
+ m(!1);
630
+ }, []), k = X(() => {
631
+ m(!0);
520
632
  }, []);
521
- function h(w) {
522
- R(w.value), a(w.value), S && u();
633
+ function x(s) {
634
+ R(s.value), a(s.value), A && c();
523
635
  }
524
- function g(w) {
525
- return w === z;
636
+ function B(s) {
637
+ return s === C;
526
638
  }
527
- return /* @__PURE__ */ p(A, { children: [
528
- /* @__PURE__ */ p(
529
- ar,
639
+ return /* @__PURE__ */ f(M, { children: [
640
+ /* @__PURE__ */ f(
641
+ Zt,
530
642
  {
531
- ref: s,
532
- onClick: x,
643
+ ref: i,
644
+ onClick: k,
533
645
  variant: "outlined",
534
646
  size: "small",
535
- className: ["my-select__selector", It(z) ? "" : "my-select__selector--active"].join(" "),
647
+ className: ["my-select__selector", Bt(C) ? "" : "my-select__selector--active"].join(" "),
536
648
  sx: { minWidth: "auto" },
537
- ...c,
649
+ ...u,
538
650
  children: [
539
651
  /* @__PURE__ */ t("div", { className: "my-select__icon", children: o }),
540
652
  e,
@@ -542,30 +654,30 @@ function X({ title: e, value: r, icon: o, prepend: l, options: n, onChange: a, i
542
654
  ]
543
655
  }
544
656
  ),
545
- /* @__PURE__ */ t(et, { open: m, anchorEl: s.current, transition: !0, sx: { zIndex: "9999" }, children: ({ TransitionProps: w, placement: P }) => /* @__PURE__ */ t(tt, { ...w, sx: { transformOrigin: P === "bottom" ? "center top" : "center bottom" }, children: /* @__PURE__ */ t(rt, { children: /* @__PURE__ */ t(ot, { onClickAway: u, children: /* @__PURE__ */ p(ir, { autoFocusItem: m, onMouseEnter: x, onMouseLeave: u, children: [
657
+ /* @__PURE__ */ t(et, { open: h, anchorEl: i.current, transition: !0, sx: { zIndex: "9999" }, children: ({ TransitionProps: s, placement: y }) => /* @__PURE__ */ t(tt, { ...s, sx: { transformOrigin: y === "bottom" ? "center top" : "center bottom" }, children: /* @__PURE__ */ t(rt, { children: /* @__PURE__ */ t(ot, { onClickAway: c, children: /* @__PURE__ */ f(er, { autoFocusItem: h, onMouseEnter: k, onMouseLeave: c, children: [
546
658
  l,
547
- n.map((F) => d ? d(F) : /* @__PURE__ */ p(nt, { onClick: () => h(F), children: [
659
+ n.map((T) => d ? d(T) : /* @__PURE__ */ f(nt, { onClick: () => x(T), children: [
548
660
  /* @__PURE__ */ t(
549
- Rt,
661
+ St,
550
662
  {
551
- sx: { mr: 1, fontSize: 16, visibility: g(F.value) ? "visible" : "hidden" }
663
+ sx: { mr: 1, fontSize: 16, visibility: B(T.value) ? "visible" : "hidden" }
552
664
  }
553
665
  ),
554
- F.name
555
- ] }, F.value))
666
+ T.name
667
+ ] }, T.value))
556
668
  ] }) }) }) }) })
557
669
  ] });
558
670
  }
559
- X.propTypes = {
560
- options: k.array.isRequired,
561
- value: k.oneOfType([k.string, k.number, k.array]),
562
- onChange: k.func,
563
- itemRender: k.func,
564
- title: k.string.isRequired,
565
- icon: k.any,
566
- prepend: k.any
671
+ V.propTypes = {
672
+ options: w.array.isRequired,
673
+ value: w.oneOfType([w.string, w.number, w.array]),
674
+ onChange: w.func,
675
+ itemRender: w.func,
676
+ title: w.string.isRequired,
677
+ icon: w.any,
678
+ prepend: w.any
567
679
  };
568
- X.defaultProps = {
680
+ V.defaultProps = {
569
681
  value: null,
570
682
  icon: null,
571
683
  prepend: null,
@@ -573,7 +685,7 @@ X.defaultProps = {
573
685
  onChange: () => {
574
686
  }
575
687
  };
576
- const ar = _(le)`
688
+ const Zt = E(ne)`
577
689
  border: 1px solid #f0f0f0;
578
690
  padding: 6px 8px 6px 12px;
579
691
  font-weight: ${(e) => e.theme.typography.fontWeightRegular};
@@ -604,7 +716,7 @@ const ar = _(le)`
604
716
  margin-right: 3px;
605
717
  }
606
718
  }
607
- `, ir = _(Ke)`
719
+ `, er = E(Je)`
608
720
  .my-select__option__icon {
609
721
  color: transparent;
610
722
  font-size: 14px;
@@ -621,11 +733,11 @@ const ar = _(le)`
621
733
  }
622
734
  }
623
735
  `;
624
- function Me() {
736
+ function Oe() {
625
737
  var d;
626
- const { filters: e, handleSort: r, handlePrice: o, t: l } = B(), n = Ae(l), a = ((d = n.find((c) => c.value === e.sortBy)) == null ? void 0 : d.name) || l("sort.sort");
627
- return /* @__PURE__ */ p(
628
- L,
738
+ const { filters: e, handleSort: r, handlePrice: o, t: l } = S(), n = Le(l), a = ((d = n.find((u) => u.value === e.sortBy)) == null ? void 0 : d.name) || l("sort.sort");
739
+ return /* @__PURE__ */ f(
740
+ z,
629
741
  {
630
742
  direction: { xs: "row", md: "column" },
631
743
  alignItems: { xs: "center", md: "flex-start" },
@@ -634,22 +746,22 @@ function Me() {
634
746
  justifyContent: "space-between",
635
747
  children: [
636
748
  /* @__PURE__ */ t(
637
- Ce,
749
+ ye,
638
750
  {
639
751
  control: /* @__PURE__ */ t(
640
- Se,
752
+ xe,
641
753
  {
642
754
  checked: e.price === "free",
643
755
  size: "small",
644
756
  sx: { "& .MuiSvgIcon-fontSizeSmall": { fontSize: 16, color: "text.lighter" } },
645
- onChange: (c) => o(c.target.checked ? "free" : "")
757
+ onChange: (u) => o(u.target.checked ? "free" : "")
646
758
  }
647
759
  ),
648
760
  label: l("blocklet.free")
649
761
  }
650
762
  ),
651
763
  /* @__PURE__ */ t(
652
- X,
764
+ V,
653
765
  {
654
766
  value: e.sortBy,
655
767
  options: n,
@@ -664,14 +776,16 @@ function Me() {
664
776
  }
665
777
  );
666
778
  }
667
- function sr() {
668
- const { selectedCategory: e, handleCategory: r, t: o, categoryOptions: l, filters: n, cleanFilter: a, loadings: d, layout: c } = B(), { toggleOpen: s } = ne();
669
- return c.showCategory ? /* @__PURE__ */ p(nr, { children: [
779
+ function tr() {
780
+ const { selectedCategory: e, handleCategory: r, t: o, categoryOptions: l, filters: n, cleanFilter: a, loadings: d, layout: u, baseSearch: i } = S(), { toggleOpen: g } = te();
781
+ return N(() => {
782
+ g(!1);
783
+ }, [n.category, n.owner, n.keyword, n.sortBy, n.sortDirection, n.resourceType]), u.showCategory ? /* @__PURE__ */ f(Yt, { children: [
670
784
  /* @__PURE__ */ t(
671
- Q,
785
+ oe,
672
786
  {
673
- xs: /* @__PURE__ */ p(
674
- L,
787
+ xs: /* @__PURE__ */ f(
788
+ z,
675
789
  {
676
790
  direction: "row",
677
791
  justifyContent: "space-between",
@@ -682,62 +796,65 @@ function sr() {
682
796
  borderBottom: 1,
683
797
  borderColor: "divider",
684
798
  children: [
685
- /* @__PURE__ */ t(Ne, { onClick: () => s(!1), children: /* @__PURE__ */ t(Re, {}) }),
686
- /* @__PURE__ */ t($, { flex: 1, variant: "body1", fontWeight: "fontWeightMedium", children: "Categories" })
799
+ /* @__PURE__ */ t(Ee, { onClick: () => g(!1), children: /* @__PURE__ */ t(we, {}) }),
800
+ /* @__PURE__ */ t(L, { flex: 1, variant: "body1", fontWeight: "fontWeightMedium", children: o("common.category") })
687
801
  ]
688
802
  }
689
803
  ),
690
804
  md: null
691
805
  }
692
806
  ),
693
- /* @__PURE__ */ t(
694
- L,
807
+ /* @__PURE__ */ f(
808
+ z,
695
809
  {
696
810
  visibility: d.fetchCategoriesLoading ? "hidden" : "visible",
697
811
  width: { xs: 268, md: 200 },
698
812
  boxSizing: "content-box",
699
813
  p: { xs: 2, md: 0 },
700
814
  pr: { md: 6 },
701
- children: n.keyword ? /* @__PURE__ */ t(Me, {}) : /* @__PURE__ */ p(A, { children: [
702
- c.showExplore && /* @__PURE__ */ p(C, { display: "flex", alignItems: "center", gap: 1, mb: 3, pb: 3, borderBottom: 1, borderColor: "divider", children: [
703
- /* @__PURE__ */ t(Be, { icon: ct }),
704
- /* @__PURE__ */ t(
705
- $,
815
+ children: [
816
+ u.showSearch ? /* @__PURE__ */ t(v, { className: "filter-bar", mb: 3, pb: 3, borderBottom: 1, borderColor: "divider", children: i ? /* @__PURE__ */ t(re, { className: "bl-search-container", placeholder: o("common.searchStore"), sx: { pl: 1.5 } }) : /* @__PURE__ */ t(Gt, {}) }) : null,
817
+ n.keyword ? /* @__PURE__ */ t(Oe, {}) : /* @__PURE__ */ f(M, { children: [
818
+ u.showExplore && /* @__PURE__ */ f(v, { display: "flex", alignItems: "center", gap: 1, mb: 3, pb: 3, borderBottom: 1, borderColor: "divider", children: [
819
+ /* @__PURE__ */ t(be, { icon: ut }),
820
+ /* @__PURE__ */ t(
821
+ L,
822
+ {
823
+ variant: "body1",
824
+ color: e ? "text.lighter" : "text.primary",
825
+ fontWeight: e ? void 0 : "fontWeightMedium",
826
+ sx: { cursor: "pointer" },
827
+ onClick: () => {
828
+ g(!1), a();
829
+ },
830
+ children: o("explore.title")
831
+ }
832
+ )
833
+ ] }),
834
+ !!l.length && /* @__PURE__ */ t(z, { gap: 2, children: l.map((h) => /* @__PURE__ */ t(
835
+ L,
706
836
  {
707
837
  variant: "body1",
708
- color: e ? "text.lighter" : "text.primary",
709
- fontWeight: e ? void 0 : "fontWeightMedium",
838
+ title: h.name,
710
839
  sx: { cursor: "pointer" },
840
+ "data-cy": "filter",
841
+ color: e === h.value ? "text.primary" : "text.lighter",
842
+ textTransform: "capitalize",
711
843
  onClick: () => {
712
- s(!1), a();
844
+ e === h.value ? a() : r(h.value), g(!1);
713
845
  },
714
- children: o("explore.title")
715
- }
716
- )
717
- ] }),
718
- !!l.length && /* @__PURE__ */ t(L, { gap: 2, children: l.map((f) => /* @__PURE__ */ t(
719
- $,
720
- {
721
- variant: "body1",
722
- title: f.name,
723
- sx: { cursor: "pointer" },
724
- "data-cy": "filter",
725
- color: e === f.value ? "text.primary" : "text.lighter",
726
- textTransform: "capitalize",
727
- onClick: () => {
728
- e === f.value ? a() : r(f.value), s(!1);
846
+ children: h.name
729
847
  },
730
- children: f.name
731
- },
732
- f.value
733
- )) })
734
- ] })
848
+ h.value
849
+ )) })
850
+ ] })
851
+ ]
735
852
  }
736
853
  )
737
854
  ] }) : null;
738
855
  }
739
- function Oe() {
740
- const { endpoint: e, serverVersion: r, storeVersion: o } = B(), l = Ee(r, o), n = M(() => Te({
856
+ function De() {
857
+ const { endpoint: e, serverVersion: r, storeVersion: o } = S(), l = ze(r, o), n = D(() => Ce({
741
858
  baseURL: e,
742
859
  headers: l
743
860
  }), [e]);
@@ -747,24 +864,24 @@ function Oe() {
747
864
  return d;
748
865
  },
749
866
  post: async (a, d) => {
750
- const { data: c } = await n.post(a, d);
751
- return c;
867
+ const { data: u } = await n.post(a, d);
868
+ return u;
752
869
  }
753
870
  };
754
871
  }
755
- const je = ut(function(r) {
756
- return /* @__PURE__ */ t($e, { height: 60, display: "flex", alignItems: "center", justifyContent: "center", ...r, children: /* @__PURE__ */ t(re, {}) });
872
+ const Me = ht(function(r) {
873
+ return /* @__PURE__ */ t(Te, { height: 60, display: "flex", alignItems: "center", justifyContent: "center", ...r, children: /* @__PURE__ */ t(Z, {}) });
757
874
  });
758
- function ge({
875
+ function pe({
759
876
  icon: e,
760
877
  children: r,
761
878
  maxWidth: o = 100,
762
879
  title: l
763
880
  }) {
764
- return (r === 0 || r) && /* @__PURE__ */ p(L, { direction: "row", alignItems: "center", gap: 1, sx: { maxWidth: o, overflow: "hidden" }, children: [
881
+ return (r === 0 || r) && /* @__PURE__ */ f(z, { direction: "row", alignItems: "center", gap: 1, sx: { maxWidth: o, overflow: "hidden" }, children: [
765
882
  e,
766
883
  /* @__PURE__ */ t(
767
- $,
884
+ L,
768
885
  {
769
886
  flex: 1,
770
887
  variant: "body2",
@@ -775,17 +892,17 @@ function ge({
775
892
  )
776
893
  ] });
777
894
  }
778
- const ye = 292;
779
- function cr() {
780
- var R, S;
781
- const { t: e } = B(), { get: r } = Oe(), o = ve(), l = N(o.breakpoints.down("md")), n = ((S = (R = window.blocklet) == null ? void 0 : R.preferences) == null ? void 0 : S.homeBanner) || [], { data: a = [], error: d } = oe(async () => {
782
- const u = await r(
783
- Le(T.blockletsPath, { didList: n.map((x) => x.did).join(",") })
895
+ const he = 292;
896
+ function rr() {
897
+ var R, A;
898
+ const { t: e } = S(), { get: r } = De(), o = ge(), l = O(o.breakpoints.down("md")), n = ((A = (R = window.blocklet) == null ? void 0 : R.preferences) == null ? void 0 : A.homeBanner) || [], { data: a = [], error: d } = U(async () => {
899
+ const c = await r(
900
+ Pe(I.blockletsPath, { didList: n.map((k) => k.did).join(",") })
784
901
  );
785
- return u != null && u.dataList ? n.map((x) => u.dataList.find((h) => h.did === x.did)) : [];
902
+ return c != null && c.dataList ? n.map((k) => c.dataList.find((x) => x.did === k.did)) : [];
786
903
  });
787
904
  d && console.error("Get Banner Blocklets error:", d);
788
- const c = {
905
+ const u = {
789
906
  position: "absolute",
790
907
  top: "50%",
791
908
  transform: "translateY(-50%)",
@@ -793,12 +910,12 @@ function cr() {
793
910
  cursor: "pointer",
794
911
  color: "text.lighter"
795
912
  };
796
- return !d && n.length > 0 ? /* @__PURE__ */ p(A, { children: [
797
- /* @__PURE__ */ t($, { component: "h2", variant: "h2", mt: { xs: 2, md: 0 }, mb: 3, children: e("explore.title") }),
913
+ return !d && n.length > 0 ? /* @__PURE__ */ f(M, { children: [
914
+ /* @__PURE__ */ t(L, { component: "h2", variant: "h2", mt: { xs: 2, md: 0 }, mb: 3, children: e("explore.title") }),
798
915
  /* @__PURE__ */ t(
799
- C,
916
+ v,
800
917
  {
801
- height: { xs: "auto", md: ye },
918
+ height: { xs: "auto", md: he },
802
919
  position: "relative",
803
920
  border: 1,
804
921
  borderColor: "divider",
@@ -816,17 +933,17 @@ function cr() {
816
933
  showBullets: !1,
817
934
  showThumbnails: !1,
818
935
  showFullscreenButton: !1,
819
- renderLeftNav: (u) => /* @__PURE__ */ t(C, { onClick: u, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t(zt, { sx: { ...c, left: 5 } }) }),
820
- renderRightNav: (u) => /* @__PURE__ */ t(C, { onClick: u, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t(Ft, { sx: { ...c, right: 5 } }) }),
821
- items: n.map((u, x) => ({
822
- original: u.did,
936
+ renderLeftNav: (c) => /* @__PURE__ */ t(v, { onClick: c, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t(It, { sx: { ...u, left: 5 } }) }),
937
+ renderRightNav: (c) => /* @__PURE__ */ t(v, { onClick: c, sx: { display: { xs: "none", md: "block" } }, children: /* @__PURE__ */ t(Lt, { sx: { ...u, right: 5 } }) }),
938
+ items: n.map((c, k) => ({
939
+ original: c.did,
823
940
  renderItem: () => {
824
- var P;
825
- const h = a[x] || {}, g = u.cover || ur(u.did, (P = h.screenshots) == null ? void 0 : P[0]), w = Ut(g, { h: 400, w: 700 });
826
- return /* @__PURE__ */ p(
827
- L,
941
+ var y;
942
+ const x = a[k] || {}, B = c.cover || nr(c.did, (y = x.screenshots) == null ? void 0 : y[0]), s = Ae(B, { h: 400, w: 700 });
943
+ return /* @__PURE__ */ f(
944
+ z,
828
945
  {
829
- height: { xs: "auto", md: ye },
946
+ height: { xs: "auto", md: he },
830
947
  sx: {
831
948
  "&::before": {
832
949
  content: '""',
@@ -835,7 +952,7 @@ function cr() {
835
952
  left: 0,
836
953
  right: 0,
837
954
  bottom: 0,
838
- backgroundImage: `url("${w}")`,
955
+ backgroundImage: `url("${s}")`,
839
956
  backgroundSize: "cover",
840
957
  filter: "blur(8px)",
841
958
  opacity: 0.15,
@@ -849,14 +966,14 @@ function cr() {
849
966
  p: { xs: 2, md: 5 },
850
967
  gap: { xs: 2, md: 5 },
851
968
  children: [
852
- s(w),
853
- /* @__PURE__ */ p(L, { flex: 1, height: "100%", gap: 3, children: [
854
- /* @__PURE__ */ p(C, { flex: 1, children: [
855
- f(u.name || h.title || u.name),
856
- m(u.desc || h.description)
969
+ i(s),
970
+ /* @__PURE__ */ f(z, { flex: 1, height: "100%", gap: 3, children: [
971
+ /* @__PURE__ */ f(v, { flex: 1, children: [
972
+ g(c.name || x.title || c.name),
973
+ h(c.desc || x.description)
857
974
  ] }),
858
- h.did && v(h, u.baseNum),
859
- z(u.link, u.did)
975
+ x.did && m(x, c.baseNum),
976
+ C(c.link, c.did)
860
977
  ] })
861
978
  ]
862
979
  }
@@ -868,20 +985,22 @@ function cr() {
868
985
  }
869
986
  )
870
987
  ] }) : null;
871
- function s(u) {
872
- return /* @__PURE__ */ t(C, { width: { xs: "100%", md: 338 }, height: 210, borderRadius: 2, overflow: "hidden", position: "relative", children: /* @__PURE__ */ t(Lt, { src: u, alt: "", width: l ? void 0 : 338, height: 210, style: { objectFit: "cover" } }) });
988
+ function i(c) {
989
+ return /* @__PURE__ */ t(v, { width: { xs: "100%", md: 338 }, height: 210, borderRadius: 2, overflow: "hidden", position: "relative", children: /* @__PURE__ */ t(Tt, { src: c, alt: "", width: l ? void 0 : 338, height: 210, style: { objectFit: "cover" } }) });
873
990
  }
874
- function f(u) {
875
- return /* @__PURE__ */ t($, { variant: "h2", width: "100%", children: u });
991
+ function g(c) {
992
+ return /* @__PURE__ */ t(L, { variant: "h2", width: "100%", children: c });
876
993
  }
877
- function m(u) {
994
+ function h(c) {
878
995
  return /* @__PURE__ */ t(
879
- $,
996
+ L,
880
997
  {
881
998
  variant: "body2",
882
999
  color: "text.secondary",
883
1000
  textAlign: "left",
884
1001
  width: "100%",
1002
+ minHeight: 70,
1003
+ maxHeight: 70,
885
1004
  pt: 1,
886
1005
  sx: {
887
1006
  display: "-webkit-box",
@@ -892,20 +1011,20 @@ function cr() {
892
1011
  overflow: "hidden",
893
1012
  WebkitBoxOrient: "vertical"
894
1013
  },
895
- children: u
1014
+ children: c
896
1015
  }
897
1016
  );
898
1017
  }
899
- function v(u, x = 0) {
900
- const { did: h, owner: g, stats: w } = u;
901
- return /* @__PURE__ */ p(C, { display: "flex", alignItems: "center", gap: 2, color: "text.secondary", children: [
902
- /* @__PURE__ */ t(ge, { icon: /* @__PURE__ */ t(Tt, { src: g.avatar, did: h, size: 20, variant: "circle" }), children: g.fullName }),
903
- /* @__PURE__ */ t(ge, { icon: /* @__PURE__ */ t(Be, { icon: $t }), title: `${w.downloads + x}`, children: dr(w.downloads + x) })
1018
+ function m(c, k = 0) {
1019
+ const { did: x, owner: B, stats: s } = c;
1020
+ return /* @__PURE__ */ f(v, { display: "flex", alignItems: "center", gap: 2, color: "text.secondary", children: [
1021
+ /* @__PURE__ */ t(pe, { icon: /* @__PURE__ */ t(Be, { src: B.avatar, did: x, size: 20, variant: "circle" }), children: B.fullName }),
1022
+ /* @__PURE__ */ t(pe, { icon: /* @__PURE__ */ t(be, { icon: Rt }), title: `${s.downloads + k}`, children: or(s.downloads + k) })
904
1023
  ] });
905
1024
  }
906
- function z(u, x) {
907
- return /* @__PURE__ */ t(lt, { href: u || `/blocklets/${x}`, align: "left", width: 100, children: /* @__PURE__ */ t(
908
- te,
1025
+ function C(c, k) {
1026
+ return /* @__PURE__ */ t(lt, { href: c || `/blocklets/${k}`, align: "left", width: 100, children: /* @__PURE__ */ t(
1027
+ J,
909
1028
  {
910
1029
  variant: "outlined",
911
1030
  size: "small",
@@ -920,35 +1039,35 @@ function cr() {
920
1039
  ) });
921
1040
  }
922
1041
  }
923
- const dr = (e) => Number.isNaN(e) ? 0 : e < 1e3 ? e : e < 1e6 ? `${(e / 1e3).toFixed(1)}k` : e < 1e9 ? `${(e / 1e6).toFixed(1)}m` : `${(e / 1e9).toFixed(1)}b`, ur = (e, r) => e && r ? `/assets/${e}/screenshots/${r}` : "";
924
- function pr({ title: e, blocklets: r }) {
925
- const { blockletRender: o, serverVersion: l } = B();
926
- return /* @__PURE__ */ p(C, { mt: 3, children: [
927
- /* @__PURE__ */ t($, { component: "h3", variant: "h3", sx: { mb: 2 }, children: e }),
928
- /* @__PURE__ */ t(he, { container: !0, spacing: 2, children: r.map((n) => /* @__PURE__ */ t(he, { item: !0, xs: 12, md: 6, p: "2px", "data-blocklet-did": n.did, children: /* @__PURE__ */ t(C, { padding: "1px", children: o({ blocklet: n, blocklets: r, serverVersion: l }) }) }, n.did)) })
1042
+ const or = (e) => Number.isNaN(e) ? 0 : e < 1e3 ? e : e < 1e6 ? `${(e / 1e3).toFixed(1)}k` : e < 1e9 ? `${(e / 1e6).toFixed(1)}m` : `${(e / 1e9).toFixed(1)}b`, nr = (e, r) => e && r ? `/assets/${e}/screenshots/${r}` : "";
1043
+ function lr({ title: e, blocklets: r }) {
1044
+ const { blockletRender: o, serverVersion: l } = S();
1045
+ return /* @__PURE__ */ f(v, { mt: 3, children: [
1046
+ /* @__PURE__ */ t(L, { component: "h3", variant: "h3", sx: { mb: 2 }, children: e }),
1047
+ /* @__PURE__ */ t(se, { container: !0, spacing: 2, children: r.map((n) => /* @__PURE__ */ t(se, { item: !0, xs: 12, md: 6, p: "2px", "data-blocklet-did": n.did, children: /* @__PURE__ */ t(v, { padding: "1px", children: o({ blocklet: n, blocklets: r, serverVersion: l }) }) }, n.did)) })
929
1048
  ] });
930
1049
  }
931
- function hr() {
932
- const { get: e } = Oe(), { t: r } = B(), {
1050
+ function ir() {
1051
+ const { get: e } = De(), { t: r } = S(), {
933
1052
  data: o = [],
934
1053
  error: l,
935
1054
  loading: n
936
- } = oe(async () => {
937
- const a = await e(T.explorePath);
1055
+ } = U(async () => {
1056
+ const a = await e(I.explorePath);
938
1057
  return Array.isArray(a) ? a : [];
939
1058
  });
940
- return l ? /* @__PURE__ */ t(ee, { error: new Error(`Failed to fetch blocklets from ${T.explorePath}`) }) : n ? /* @__PURE__ */ t(je, { mt: 15 }) : /* @__PURE__ */ p(A, { children: [
941
- /* @__PURE__ */ t(cr, {}),
1059
+ return l ? /* @__PURE__ */ t(ee, { error: new Error(`Failed to fetch blocklets from ${I.explorePath}`) }) : n ? /* @__PURE__ */ t(Me, { mt: 15 }) : /* @__PURE__ */ f(M, { children: [
1060
+ /* @__PURE__ */ t(rr, {}),
942
1061
  o.map(
943
- (a) => a.blocklets.length > 0 ? /* @__PURE__ */ t(pr, { title: r(`explore.${a.type}`), blocklets: a.blocklets }, a.type) : null
1062
+ (a) => a.blocklets.length > 0 ? /* @__PURE__ */ t(lr, { title: r(`explore.${a.type}`), blocklets: a.blocklets }, a.type) : null
944
1063
  )
945
1064
  ] });
946
1065
  }
947
- function mr() {
948
- var f;
949
- const { filters: e, handleSort: r, handlePrice: o, t: l, getCategoryLocale: n, developerName: a, handleDeveloper: d } = B(), c = Ae(l), s = ((f = c.find((m) => m.value === e.sortBy)) == null ? void 0 : f.name) || l("sort.sort");
950
- return /* @__PURE__ */ p(
951
- L,
1066
+ function ar() {
1067
+ var g;
1068
+ const { filters: e, handleSort: r, handlePrice: o, t: l, getCategoryLocale: n, developerName: a, handleDeveloper: d } = S(), u = Le(l), i = ((g = u.find((h) => h.value === e.sortBy)) == null ? void 0 : g.name) || l("sort.sort");
1069
+ return /* @__PURE__ */ f(
1070
+ z,
952
1071
  {
953
1072
  direction: { xs: "column", md: "row" },
954
1073
  alignItems: { xs: "flex-start", md: "center" },
@@ -958,9 +1077,9 @@ function mr() {
958
1077
  px: 0,
959
1078
  pb: 3,
960
1079
  children: [
961
- /* @__PURE__ */ t($, { variant: "h2", textTransform: "capitalize", children: n(e.category) }),
962
- /* @__PURE__ */ p(
963
- L,
1080
+ /* @__PURE__ */ t(L, { variant: "h2", textTransform: "capitalize", children: n(e.category) }),
1081
+ /* @__PURE__ */ f(
1082
+ z,
964
1083
  {
965
1084
  direction: "row",
966
1085
  alignItems: "center",
@@ -968,29 +1087,29 @@ function mr() {
968
1087
  justifyContent: "space-between",
969
1088
  gap: 2,
970
1089
  children: [
971
- e.owner && /* @__PURE__ */ t(at, { label: a, size: "small", onDelete: () => d("") }),
1090
+ e.owner && a && /* @__PURE__ */ t(it, { label: a, size: "small", onDelete: () => d("") }),
972
1091
  /* @__PURE__ */ t(
973
- Ce,
1092
+ ye,
974
1093
  {
975
1094
  sx: { m: 0 },
976
1095
  control: /* @__PURE__ */ t(
977
- Se,
1096
+ xe,
978
1097
  {
979
1098
  checked: e.price === "free",
980
1099
  size: "small",
981
1100
  sx: { p: 0, pr: 1, "& .MuiSvgIcon-fontSizeSmall": { fontSize: 16, color: "text.lighter" } },
982
- onChange: (m) => o(m.target.checked ? "free" : "")
1101
+ onChange: (h) => o(h.target.checked ? "free" : "")
983
1102
  }
984
1103
  ),
985
1104
  label: l("blocklet.free")
986
1105
  }
987
1106
  ),
988
1107
  /* @__PURE__ */ t(
989
- X,
1108
+ V,
990
1109
  {
991
1110
  value: e.sortBy,
992
- options: c,
993
- title: s,
1111
+ options: u,
1112
+ title: i,
994
1113
  onChange: r,
995
1114
  icon: null,
996
1115
  prepend: null,
@@ -1004,131 +1123,166 @@ function mr() {
1004
1123
  }
1005
1124
  );
1006
1125
  }
1007
- function be() {
1008
- const { t: e } = B();
1009
- return /* @__PURE__ */ t(ze, { style: { textAlign: "center" }, variant: "subtitle2", children: e("blocklet.noResults") });
1126
+ function me() {
1127
+ const { t: e } = S();
1128
+ return /* @__PURE__ */ t(Re, { style: { textAlign: "center" }, variant: "subtitle2", children: e("blocklet.noResults") });
1010
1129
  }
1011
- function j({ filterTip: e, keywordTip: r }) {
1012
- const { t: o, locale: l } = B(), n = () => l === "zh" ? "、" : " , ";
1013
- return /* @__PURE__ */ p($e, { className: "tips", children: [
1130
+ function $({ filterTip: e, keywordTip: r }) {
1131
+ const { t: o, locale: l } = S(), n = () => l === "zh" ? "、" : " , ";
1132
+ return /* @__PURE__ */ f(Te, { className: "tips", children: [
1014
1133
  /* @__PURE__ */ t("span", { style: { marginRight: "16px" }, children: o("blocklet.emptyTip") }),
1015
1134
  e && /* @__PURE__ */ t("span", { children: o("blocklet.filterTip") }),
1016
1135
  e && r && n(),
1017
1136
  r && /* @__PURE__ */ t("span", { children: o("blocklet.keywordTip") })
1018
1137
  ] });
1019
1138
  }
1020
- j.propTypes = {
1021
- filterTip: k.bool,
1022
- keywordTip: k.bool
1139
+ $.propTypes = {
1140
+ filterTip: w.bool,
1141
+ keywordTip: w.bool
1023
1142
  };
1024
- j.defaultProps = {
1143
+ $.defaultProps = {
1025
1144
  filterTip: !1,
1026
1145
  keywordTip: !1
1027
1146
  };
1028
- function H({ primaryStart: e, primaryEnd: r, filter: o }) {
1029
- return /* @__PURE__ */ p(ze, { variant: "subtitle2", children: [
1147
+ function q({ primaryStart: e, primaryEnd: r, filter: o }) {
1148
+ return /* @__PURE__ */ f(Re, { variant: "subtitle2", children: [
1030
1149
  /* @__PURE__ */ t("span", { children: e }),
1031
- /* @__PURE__ */ p("span", { className: "primary", children: [
1150
+ /* @__PURE__ */ f("span", { className: "primary", children: [
1032
1151
  " ",
1033
1152
  o,
1034
1153
  " "
1035
1154
  ] }),
1036
- /* @__PURE__ */ p("span", { children: [
1155
+ /* @__PURE__ */ f("span", { children: [
1037
1156
  r,
1038
1157
  " "
1039
1158
  ] })
1040
1159
  ] });
1041
1160
  }
1042
- H.propTypes = {
1043
- primaryStart: k.string.isRequired,
1044
- primaryEnd: k.string.isRequired,
1045
- filter: k.string.isRequired
1161
+ q.propTypes = {
1162
+ primaryStart: w.string.isRequired,
1163
+ primaryEnd: w.string.isRequired,
1164
+ filter: w.string.isRequired
1046
1165
  };
1047
- function qe({ blocklets: e, ...r }) {
1048
- const {
1049
- blockletRender: o,
1050
- errors: l,
1051
- loadings: n,
1052
- selectedCategory: a,
1053
- getCategoryLocale: d,
1054
- filters: c,
1055
- t: s,
1056
- serverVersion: f,
1057
- hasNextPage: m,
1058
- loadMore: v,
1059
- endpoint: z,
1060
- minItemWidth: R
1061
- } = B(), S = !!a || !!c.price, [u] = _t({
1062
- loading: n.fetchBlockletsLoading || n.loadingMore,
1063
- hasNextPage: m,
1064
- onLoadMore: v
1166
+ const sr = (e, r, o, l) => gt(
1167
+ async (n) => {
1168
+ n || (o.currentPage = o.defaultCurrentPage);
1169
+ const { currentPage: a, pageSize: d } = o, u = {
1170
+ ...r,
1171
+ category: r.category === "All" ? "" : r.category,
1172
+ sortBy: I[r.sortBy],
1173
+ page: a,
1174
+ pageSize: d
1175
+ };
1176
+ l(null);
1177
+ const { data: i = {} } = await e.get(I.blockletsPath, { params: u });
1178
+ return o.currentPage++, { page: a, pageSize: d, list: (i == null ? void 0 : i.dataList) || [], total: (i == null ? void 0 : i.total) || 0 };
1179
+ },
1180
+ {
1181
+ isNoMore: (n) => n ? n.page * n.pageSize >= n.total : !1,
1182
+ reloadDeps: [e, Ft(r)],
1183
+ onError: l
1184
+ }
1185
+ );
1186
+ function cr() {
1187
+ var h;
1188
+ const { storeApi: e, filters: r, extraFilter: o, errors: l, updateDeveloperName: n } = S(), a = yt({
1189
+ currentPage: I.currentPage,
1190
+ pageSize: Wt() ? I.mobilePageSize : I.pageSize,
1191
+ defaultCurrentPage: I.defaultCurrentPage
1192
+ }), [d, u] = F(null), i = sr(e, r, a, u), g = D(
1193
+ () => {
1194
+ var m, C;
1195
+ return o ? o(((m = i.data) == null ? void 0 : m.list) || []) : ((C = i.data) == null ? void 0 : C.list) || [];
1196
+ },
1197
+ [i.data, o]
1198
+ );
1199
+ return N(() => {
1200
+ const m = g.find((C) => C.owner.did === r.owner);
1201
+ n((m == null ? void 0 : m.owner.fullName) || (m == null ? void 0 : m.author.name) || "");
1202
+ }, [r.owner, g, n]), {
1203
+ blocklets: g,
1204
+ fetchBlockletsError: d,
1205
+ loadMore: i.loadMore,
1206
+ hasNextPage: !i.noMore,
1207
+ total: (h = i.data) == null ? void 0 : h.total,
1208
+ loadings: {
1209
+ fetchBlockletsLoading: i.loading,
1210
+ loadingMore: i.loadingMore
1211
+ },
1212
+ errors: {
1213
+ ...l,
1214
+ fetchBlockletsError: d
1215
+ }
1216
+ };
1217
+ }
1218
+ function dr() {
1219
+ const { t: e, filters: r, endpoint: o, blockletRender: l, serverVersion: n, minItemWidth: a, selectedCategory: d, getCategoryLocale: u } = S(), { blocklets: i, errors: g, loadMore: h, loadings: m, hasNextPage: C, total: R } = cr(), A = !!d || !!r.price, [c] = _t({
1220
+ loading: m.fetchBlockletsLoading || m.loadingMore,
1221
+ hasNextPage: C,
1222
+ onLoadMore: h
1065
1223
  });
1066
- if (l.fetchBlockletsError)
1067
- return /* @__PURE__ */ t(
1068
- ee,
1069
- {
1070
- error: new Error(`Failed to fetch blocklets from ${z}: ${l.fetchBlockletsError.message}`)
1071
- }
1072
- );
1073
- if (n.fetchBlockletsLoading)
1074
- return /* @__PURE__ */ t(je, { mt: 15 });
1075
- if (c.keyword && S && e.length === 0)
1076
- return /* @__PURE__ */ p(U, { children: [
1224
+ if (g.fetchBlockletsError) {
1225
+ const x = new Error(`Failed to fetch blocklets from ${o}: ${g.fetchBlockletsError.message}`);
1226
+ return /* @__PURE__ */ t(ee, { error: x });
1227
+ }
1228
+ if (m.fetchBlockletsLoading)
1229
+ return /* @__PURE__ */ t(Me, { mt: 15 });
1230
+ if (r.keyword && A && i.length === 0)
1231
+ return /* @__PURE__ */ f(j, { children: [
1077
1232
  /* @__PURE__ */ t(
1078
- H,
1233
+ q,
1079
1234
  {
1080
- primaryStart: s("blocklet.noBlockletPart1"),
1081
- primaryEnd: s("blocklet.noBlockletPart2"),
1082
- filter: c.keyword
1235
+ primaryStart: e("blocklet.noBlockletPart1"),
1236
+ primaryEnd: e("blocklet.noBlockletPart2"),
1237
+ filter: r.keyword
1083
1238
  }
1084
1239
  ),
1085
- /* @__PURE__ */ t(j, { keywordTip: !0, filterTip: !0 })
1240
+ /* @__PURE__ */ t($, { keywordTip: !0, filterTip: !0 })
1086
1241
  ] });
1087
- if (c.keyword && e.length === 0)
1088
- return /* @__PURE__ */ p(U, { children: [
1242
+ if (r.keyword && i.length === 0)
1243
+ return /* @__PURE__ */ f(j, { children: [
1089
1244
  /* @__PURE__ */ t(
1090
- H,
1245
+ q,
1091
1246
  {
1092
- primaryStart: s("blocklet.noBlockletPart1"),
1093
- primaryEnd: s("blocklet.noBlockletPart2"),
1094
- filter: c.keyword
1247
+ primaryStart: e("blocklet.noBlockletPart1"),
1248
+ primaryEnd: e("blocklet.noBlockletPart2"),
1249
+ filter: r.keyword
1095
1250
  }
1096
1251
  ),
1097
- /* @__PURE__ */ t(j, { keywordTip: !0 })
1252
+ /* @__PURE__ */ t($, { keywordTip: !0 })
1098
1253
  ] });
1099
- if (S && e.length === 0) {
1100
- const x = d(a);
1101
- return /* @__PURE__ */ p(U, { children: [
1254
+ if (A && i.length === 0) {
1255
+ const x = u(d);
1256
+ return /* @__PURE__ */ f(j, { children: [
1102
1257
  x ? /* @__PURE__ */ t(
1103
- H,
1258
+ q,
1104
1259
  {
1105
- primaryStart: s("blocklet.noCategoryResults1"),
1106
- primaryEnd: s("blocklet.noCategoryResults2"),
1260
+ primaryStart: e("blocklet.noCategoryResults1"),
1261
+ primaryEnd: e("blocklet.noCategoryResults2"),
1107
1262
  filter: x
1108
1263
  }
1109
- ) : /* @__PURE__ */ t(be, {}),
1110
- /* @__PURE__ */ t(j, { filterTip: !0 })
1264
+ ) : /* @__PURE__ */ t(me, {}),
1265
+ /* @__PURE__ */ t($, { filterTip: !0 })
1111
1266
  ] });
1112
1267
  }
1113
- return e.length === 0 ? /* @__PURE__ */ t(U, { children: /* @__PURE__ */ t(be, {}) }) : /* @__PURE__ */ p(A, { children: [
1114
- /* @__PURE__ */ t(
1115
- C,
1116
- {
1117
- display: "grid",
1118
- gridTemplateColumns: `repeat(auto-fill, minmax(${R}px, 1fr))`,
1119
- p: "2px",
1120
- ...r,
1121
- gap: 2,
1122
- children: e.map((x) => /* @__PURE__ */ t(C, { "data-blocklet-did": x.did, sx: { minWidth: R }, children: o({ blocklet: x, blocklets: e, serverVersion: f }) }, x.did))
1123
- }
1124
- ),
1125
- m && /* @__PURE__ */ t(C, { height: 60, display: "flex", justifyContent: "center", py: 2, ref: u, children: /* @__PURE__ */ t(re, {}) })
1268
+ if (i.length === 0)
1269
+ return /* @__PURE__ */ t(j, { children: /* @__PURE__ */ t(me, {}) });
1270
+ return /* @__PURE__ */ f(M, { children: [
1271
+ r.keyword ? /* @__PURE__ */ f(M, { children: [
1272
+ /* @__PURE__ */ t(oe, { xs: /* @__PURE__ */ t(Oe, {}), md: null }),
1273
+ k()
1274
+ ] }) : /* @__PURE__ */ t(ar, {}),
1275
+ /* @__PURE__ */ t(v, { display: "grid", gridTemplateColumns: `repeat(auto-fill, minmax(${a}px, 1fr))`, p: "2px", gap: 2, children: i.map((x) => /* @__PURE__ */ t(v, { "data-blocklet-did": x.did, sx: { minWidth: a }, children: l({ blocklet: x, blocklets: i, serverVersion: n }) }, x.did)) }),
1276
+ C && /* @__PURE__ */ t(v, { height: 60, display: "flex", justifyContent: "center", py: 2, ref: c, children: /* @__PURE__ */ t(Z, {}) })
1126
1277
  ] });
1278
+ function k() {
1279
+ return /* @__PURE__ */ f(z, { direction: "row", alignItems: "center", justifyContent: "space-between", mb: 2, mt: { xs: 2, md: 0 }, children: [
1280
+ /* @__PURE__ */ t(L, { variant: "h3", children: e("blocklet.search", { keyword: r.keyword }) }),
1281
+ /* @__PURE__ */ t(L, { variant: "body1", color: "text.lighter", fontSize: 13, children: e("blocklet.resultCount", { count: R }) })
1282
+ ] });
1283
+ }
1127
1284
  }
1128
- qe.propTypes = {
1129
- blocklets: k.array.isRequired
1130
- };
1131
- const U = _(Et)`
1285
+ const j = E(zt)`
1132
1286
  text-align: center;
1133
1287
  margin-top: 100px;
1134
1288
  .primary {
@@ -1138,302 +1292,66 @@ const U = _(Et)`
1138
1292
  margin-top: ${(e) => e.theme.spacing(1)};
1139
1293
  }
1140
1294
  `;
1141
- function ae({ onSelect: e, wrapChildren: r }) {
1142
- const o = G(null), l = G(null), n = G(null), { storeApi: a, blockletRender: d, filters: c, endpoint: s, handleKeyword: f, t: m, serverVersion: v } = B(), z = async (h) => {
1143
- const { data: g } = await a.get(T.blockletsPath, { params: h }), w = g.dataList || [];
1144
- return w.length > 0 && w.unshift({ type: "more-result", total: g.total || 0 }), w;
1145
- }, R = (h) => {
1146
- f(h.state.query), h.setIsOpen(!1);
1147
- }, S = () => {
1148
- o.current && setTimeout(() => {
1149
- const h = o.current.querySelector("input.bl-autocomplete-input");
1150
- h && h.focus();
1151
- });
1152
- }, u = (h) => {
1153
- h.setIsOpen(!1), S();
1154
- }, x = ({ prevState: h, state: g }) => {
1155
- h.query !== g.query && (g.query || (f(), S()));
1156
- };
1157
- return Ot(
1158
- "ctrl + k, command + k",
1159
- (h) => (h.stopPropagation(), h.preventDefault(), S(), !1),
1160
- { enableOnTags: ["INPUT"] }
1161
- ), W(() => {
1162
- S();
1163
- }, [s]), W(() => {
1164
- if (!o.current)
1165
- return;
1166
- const h = Mt({
1167
- container: o.current,
1168
- renderer: { createElement: pt, Fragment: ht, render: () => {
1169
- } },
1170
- render({ children: g }, w) {
1171
- var P;
1172
- (!l.current || n.current !== w) && (n.current = w, (P = l.current) == null || P.unmount(), l.current = Nt(w)), l.current.render(r(g));
1173
- },
1174
- autoFocus: !0,
1175
- openOnFocus: !1,
1176
- classNames: {
1177
- panel: "bl-autocomplete-panel",
1178
- label: "bl-autocomplete-label",
1179
- form: "bl-autocomplete-form",
1180
- input: "bl-autocomplete-input",
1181
- clearButton: "bl-autocomplete-clear",
1182
- detachedCancelButton: "bl-autocomplete-detached-cancel",
1183
- detachedContainer: "bl-autocomplete-detached-container"
1184
- },
1185
- translations: {
1186
- clearButtonTitle: m("common.clear"),
1187
- detachedCancelButtonText: m("common.cancel"),
1188
- submitButtonTitle: m("common.search"),
1189
- detachedSearchButtonTitle: m("common.search")
1190
- },
1191
- placeholder: m("common.searchStore"),
1192
- initialState: {
1193
- query: c.keyword
1194
- },
1195
- onStateChange(g) {
1196
- x(g);
1197
- },
1198
- onSubmit: R,
1199
- onReset(g) {
1200
- u(g);
1201
- },
1202
- getSources({ query: g, state: w, ...P }) {
1203
- const F = {
1204
- sortBy: T.nameDesc,
1205
- page: 1,
1206
- pageSize: 10,
1207
- keyword: g
1208
- };
1209
- return Kt([
1210
- {
1211
- sourceId: "blocklets",
1212
- getItems() {
1213
- return z(F);
1214
- },
1215
- // 选中后填充 搜索框中值
1216
- getItemInputValue({ item: y }) {
1217
- return y.type === "more-result" ? g : y.title;
1218
- },
1219
- // 选中或者点击自动完成列表中的 item 时触发
1220
- onSelect({ event: y, item: D }) {
1221
- return D.type === "more-result" ? (P.setIsOpen(!1), f(g)) : y.type === "keydown" ? f(D.title) : e({
1222
- blocklet: D,
1223
- detailUrl: Bt(s, "/blocklets", D.did),
1224
- storeUrl: s
1225
- });
1226
- },
1227
- templates: {
1228
- item({ item: y }) {
1229
- return y.type === "more-result" ? /* @__PURE__ */ t("div", { children: m("autocomplete.expandResult", { name: g, number: y.total.toLocaleString() }) }) : d({ blocklet: y, autocompleteSetters: P, serverVersion: v });
1230
- },
1231
- noResults() {
1232
- return m("blocklet.noResults");
1233
- }
1234
- }
1235
- }
1236
- ]);
1237
- }
1238
- });
1239
- return () => {
1240
- h.destroy();
1241
- };
1242
- }, [c, d]), /* @__PURE__ */ p(A, { children: [
1243
- /* @__PURE__ */ t(
1244
- we,
1245
- {
1246
- styles: (h) => ke`
1247
- .bl-autocomplete-detached-container {
1248
- .bl-autocomplete-detached-cancel {
1249
- white-space: nowrap;
1250
- }
1251
- }
1252
- .bl-autocomplete-panel {
1253
- @media (min-width: ${h.breakpoints.values.md}px) {
1254
- min-width: 450px;
1255
- left: unset !important;
1256
- }
1257
- }
1258
- `
1259
- }
1260
- ),
1261
- /* @__PURE__ */ t("div", { className: "bl-search-container", ref: o })
1262
- ] });
1263
- }
1264
- ae.propTypes = {
1265
- onSelect: k.func.isRequired,
1266
- wrapChildren: k.func
1267
- };
1268
- ae.defaultProps = {
1269
- wrapChildren: (e) => e
1270
- };
1271
- function ie({ placeholder: e, ...r }) {
1272
- const { filters: o, handleKeyword: l } = B(), [n, a] = q(o.keyword || ""), d = yt(l, { wait: 300 }), c = (f) => {
1273
- const { value: m } = f.target;
1274
- a(m), d.run(m);
1275
- }, s = () => {
1276
- a(""), l();
1277
- };
1278
- return W(() => {
1279
- a(o.keyword || "");
1280
- }, [o.keyword]), /* @__PURE__ */ t(
1281
- fr,
1282
- {
1283
- inputProps: {
1284
- "data-cy": "search-blocklet"
1285
- },
1286
- startAdornment: /* @__PURE__ */ t(me, { position: "start", children: /* @__PURE__ */ t(gr, {}) }),
1287
- onChange: c,
1288
- placeholder: e,
1289
- value: n,
1290
- title: e,
1291
- "data-cy": "search",
1292
- endAdornment: n && /* @__PURE__ */ t(me, { position: "end", children: /* @__PURE__ */ t(yr, { "data-cy": "search-delete", onClick: s }) }),
1293
- ...r
1294
- }
1295
- );
1296
- }
1297
- ie.propTypes = {
1298
- placeholder: k.string
1299
- };
1300
- ie.defaultProps = {
1301
- placeholder: "Type to search..."
1302
- };
1303
- const fr = _(it)`
1304
- background-color: ${(e) => e.theme.palette.grey[50]};
1305
- font-size: 14px;
1306
- border-radius: 6px;
1307
- width: 100%;
1308
- .MuiInputBase-input {
1309
- padding: 8px 0 8px 10px;
1310
- }
1311
- .MuiOutlinedInput-notchedOutline {
1312
- border: none;
1313
- }
1314
- .Mui-focused {
1315
- background-color: #f6f6f6;
1316
- .MuiInputBase-input::placeholder {
1317
- color: transparent;
1318
- }
1319
- }
1320
- `, gr = _(jt)`
1321
- color: ${(e) => e.theme.palette.grey[500]};
1322
- font-size: 28px;
1323
- @media (max-width: ${(e) => e.theme.breakpoints.values.md}px) {
1324
- font-size: 24px;
1325
- }
1326
- `, yr = _(Re)`
1327
- color: ${(e) => e.theme.palette.grey[500]};
1328
- font-size: 16px;
1329
- cursor: pointer;
1330
- `;
1331
- function br() {
1332
- const { filters: e, handleSearchSelect: r, t: o, wrapChildren: l, baseSearch: n, layout: a } = B(), { toggleOpen: d } = ne(), c = !!e.keyword;
1333
- return a.showTitle || a.showSearch ? /* @__PURE__ */ p(
1295
+ function ur() {
1296
+ const { t: e } = S(), { toggleOpen: r } = te();
1297
+ return /* @__PURE__ */ f(
1334
1298
  L,
1335
1299
  {
1336
- className: "title-bar",
1337
- direction: "row",
1300
+ variant: "body1",
1301
+ display: { xs: "flex", md: "none" },
1338
1302
  alignItems: "center",
1339
- justifyContent: "space-between",
1340
- pt: { xs: 2, md: 5 },
1341
- pb: { xs: 2, md: 3 },
1342
- borderBottom: 1,
1343
- borderColor: { xs: "transparent", md: "divider" },
1344
- mb: { xs: 0, md: 3 },
1303
+ gap: 1,
1304
+ py: 2,
1305
+ fontWeight: "fontWeightMedium",
1345
1306
  children: [
1346
- /* @__PURE__ */ t(
1347
- Q,
1348
- {
1349
- xs: !c && /* @__PURE__ */ t(Ne, { onClick: () => d(!0), children: /* @__PURE__ */ t(Dt, {}) }),
1350
- md: a.showTitle ? /* @__PURE__ */ t($, { variant: "h1", children: o("common.title") }) : /* @__PURE__ */ t(C, {})
1351
- }
1352
- ),
1353
- a.showSearch ? /* @__PURE__ */ t(
1354
- C,
1355
- {
1356
- width: { xs: c ? "100%" : 300, md: 300 },
1357
- className: "filter-bar",
1358
- sx: {
1359
- "& .bl-autocomplete-form": { borderRadius: 2 },
1360
- "& .aa-SubmitButton, & .aa-LoadingIndicator": { width: "auto", pl: 1.5, pr: 1 },
1361
- "& .aa-SubmitIcon, & .aa-LoadingIcon": { height: 16, width: 16 }
1362
- },
1363
- children: n ? /* @__PURE__ */ t(ie, { className: "bl-search-container", placeholder: o("common.searchStore"), sx: { pl: 1.5 } }) : /* @__PURE__ */ t(ae, { onSelect: r, wrapChildren: l })
1364
- }
1365
- ) : null
1307
+ /* @__PURE__ */ t(Ee, { onClick: () => r(!0), children: /* @__PURE__ */ t(Et, {}) }),
1308
+ e("common.category")
1366
1309
  ]
1367
1310
  }
1368
- ) : null;
1311
+ );
1369
1312
  }
1370
- function xr() {
1371
- const { blockletList: e, total: r, filters: o, t: l } = B(), n = o.category || o.keyword || o.price;
1372
- return /* @__PURE__ */ t(qt, { children: /* @__PURE__ */ p(st, { FallbackComponent: ee, children: [
1373
- /* @__PURE__ */ t(br, {}),
1374
- /* @__PURE__ */ p(C, { display: "flex", height: "100%", children: [
1375
- /* @__PURE__ */ t(sr, {}),
1376
- /* @__PURE__ */ t(L, { height: "100%", position: "relative", flex: 1, overflow: "visible", children: n ? /* @__PURE__ */ p(A, { children: [
1377
- o.keyword ? /* @__PURE__ */ p(A, { children: [
1378
- /* @__PURE__ */ t(Q, { xs: /* @__PURE__ */ t(Me, {}), md: null }),
1379
- a()
1380
- ] }) : /* @__PURE__ */ t(mr, {}),
1381
- /* @__PURE__ */ t(qe, { blocklets: e, height: "100%" })
1382
- ] }) : /* @__PURE__ */ t(hr, {}) })
1313
+ function pr() {
1314
+ const { blockletList: e, filters: r } = S(), o = r.category || r.keyword || r.price;
1315
+ return /* @__PURE__ */ t(Ot, { children: /* @__PURE__ */ f(dt, { FallbackComponent: ee, children: [
1316
+ /* @__PURE__ */ t(ur, {}),
1317
+ /* @__PURE__ */ f(v, { display: "flex", height: "100%", className: "list-container", pt: { xs: 0, md: 5 }, children: [
1318
+ /* @__PURE__ */ t(tr, {}),
1319
+ /* @__PURE__ */ t(z, { height: "100%", position: "relative", flex: 1, overflow: "visible", children: o ? /* @__PURE__ */ t(dr, { blocklets: e }) : /* @__PURE__ */ t(ir, {}) })
1383
1320
  ] })
1384
1321
  ] }) });
1385
- function a() {
1386
- return /* @__PURE__ */ p(L, { direction: "row", alignItems: "center", justifyContent: "space-between", mb: 2, mt: { xs: 2, md: 0 }, children: [
1387
- /* @__PURE__ */ t($, { variant: "h3", children: l("blocklet.search", { keyword: o.keyword }) }),
1388
- /* @__PURE__ */ t($, { variant: "body1", color: "text.lighter", fontSize: 13, children: l("blocklet.resultCount", { count: r }) })
1389
- ] });
1390
- }
1391
1322
  }
1392
- function io(e) {
1393
- const r = xe(), o = Yt(r.palette.primary.main), l = {
1394
- autocomplete: ke`
1395
- :root {
1396
- --aa-detached-media-query: (max-width: ${r.breakpoints.values.md}px) !important;
1397
- --aa-detached-modal-media-query: (min-width: ${r.breakpoints.values.md}px) !important;
1398
- --aa-detached-modal-max-width: ${r.breakpoints.values.md}px !important;
1399
- --aa-selected-color-rgb: ${o.r}, ${o.g}, ${o.b} !important;
1400
- --aa-primary-color-rgb: ${o.r}, ${o.g}, ${o.b} !important;
1401
- --aa-input-background-color-rgb: 250, 250, 250 !important;
1402
- }
1403
- .bl-autocomplete-panel {
1404
- z-index: ${r.zIndex.modal};
1405
- }
1406
- .bl-autocomplete-label {
1407
- .aa-SubmitIcon {
1408
- color: ${r.palette.grey[500]} !important;
1409
- }
1410
- }
1411
- .bl-autocomplete-form {
1412
- border: 1px solid #fff !important;
1413
- &:focus-within {
1414
- box-shadow: none !important;
1415
- border: 1px solid rgba(0, 0, 0, 0.12) !important;
1416
- }
1417
- }
1418
- .aa-DetachedSearchButton {
1419
- border: none !important;
1420
- &:focus-within {
1421
- box-shadow: none !important;
1422
- }
1423
- .aa-SubmitIcon {
1424
- color: ${r.palette.grey[500]} !important;
1425
- }
1426
- }
1427
- .aa-Panel .arcblock-blocklet button {
1428
- border: 1px solid rgba(${o.r}, ${o.g}, ${o.b}, 0.5);
1323
+ function Jr(e) {
1324
+ const r = fe(), o = at(
1325
+ ct({
1326
+ ...r,
1327
+ typography: {
1328
+ h1: {
1329
+ fontSize: 32,
1330
+ fontWeight: 700,
1331
+ lineHeight: 1.375,
1332
+ textAlign: "left"
1333
+ },
1334
+ h2: {
1335
+ fontSize: 24,
1336
+ fontWeight: 700,
1337
+ lineHeight: 1.3333333,
1338
+ textAlign: "left"
1339
+ },
1340
+ h3: {
1341
+ fontSize: 18,
1342
+ fontWeight: 600,
1343
+ lineHeight: 1.5,
1344
+ textAlign: "left"
1345
+ },
1346
+ fontWeightLight: 300,
1347
+ fontWeightRegular: 400,
1348
+ fontWeightMedium: 500,
1349
+ fontWeightBold: 700
1429
1350
  }
1430
- `
1431
- };
1432
- return /* @__PURE__ */ p(or, { ...e, children: [
1433
- /* @__PURE__ */ t(we, { styles: l.autocomplete }),
1434
- /* @__PURE__ */ t(xr, {})
1435
- ] });
1351
+ })
1352
+ );
1353
+ return /* @__PURE__ */ t(st, { theme: o, children: /* @__PURE__ */ t(Ht, { ...e, children: /* @__PURE__ */ t(pr, {}) }) });
1436
1354
  }
1437
1355
  export {
1438
- io as default
1356
+ Jr as default
1439
1357
  };