@blocklet/pages-kit-inner-components 0.5.39 → 0.5.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/pages-kit-inner-components",
3
- "version": "0.5.39",
3
+ "version": "0.5.41",
4
4
  "description": "Pages Kit inner components library",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -71,20 +71,20 @@
71
71
  "dependencies": {
72
72
  "@arcblock/did-auth": "^1.20.14",
73
73
  "@arcblock/did-auth-storage-nedb": "^1.7.1",
74
- "@arcblock/did-connect": "^2.13.63",
75
- "@arcblock/react-hooks": "^2.13.63",
76
- "@arcblock/ux": "^2.13.63",
74
+ "@arcblock/did-connect": "^2.13.66",
75
+ "@arcblock/react-hooks": "^2.13.66",
76
+ "@arcblock/ux": "^2.13.66",
77
77
  "@blocklet/ai-kit": "^0.1.79",
78
- "@blocklet/ai-runtime": "^0.4.273",
79
- "@blocklet/code-editor": "^0.4.273",
78
+ "@blocklet/ai-runtime": "^0.4.274",
79
+ "@blocklet/code-editor": "^0.4.274",
80
80
  "@blocklet/embed": "^0.2.5",
81
81
  "@blocklet/js-sdk": "^1.16.44",
82
82
  "@blocklet/logger": "1.16.36",
83
- "@blocklet/quickjs": "^0.4.273",
83
+ "@blocklet/quickjs": "^0.4.274",
84
84
  "@blocklet/sdk": "^1.16.44",
85
- "@blocklet/studio-ui": "^0.4.273",
85
+ "@blocklet/studio-ui": "^0.4.274",
86
86
  "@blocklet/tracker": "^1.16.44",
87
- "@blocklet/ui-react": "^2.13.63",
87
+ "@blocklet/ui-react": "^2.13.66",
88
88
  "@blocklet/uploader": "^0.1.95",
89
89
  "@blocklet/uploader-server": "^0.1.101",
90
90
  "@emotion/cache": "^11.13.1",
@@ -204,8 +204,8 @@
204
204
  "yaml": "^2.5.0",
205
205
  "yjs": "^13.6.18",
206
206
  "zustand": "^4.5.5",
207
- "@blocklet/pages-kit": "^0.5.39",
208
- "@blocklet/pages-kit-block-studio": "^0.5.39"
207
+ "@blocklet/pages-kit-block-studio": "^0.5.41",
208
+ "@blocklet/pages-kit": "^0.5.41"
209
209
  },
210
210
  "devDependencies": {
211
211
  "@trivago/prettier-plugin-sort-imports": "^5.2.1",
@@ -1,38 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),k=require("./state-BWuBNdK8.js"),Z=require("@arcblock/ux/lib/Locale/context"),de=require("@arcblock/ux/lib/Result"),pe=require("@blocklet/pages-kit/builtin/page/header"),ge=require("@blocklet/pages-kit/contexts/color"),ee=require("@blocklet/pages-kit/utils/data-source"),me=require("@blocklet/pages-kit/utils/route"),fe=require("@blocklet/ui-react/lib/Header"),te=require("@emotion/css"),V=require("@emotion/react"),he=require("@emotion/styled"),y=require("@mui/material"),$=require("ahooks"),xe=require("isomorphic-dompurify"),je=require("lodash/cloneDeep"),be=require("lodash/isEmpty"),ye=require("lodash/isEqual"),f=require("react"),ve=require("react-helmet"),w=require("react-router-dom"),ne=require("react-use"),C=require("ufo"),E=require("./array-Cr5KF-hM.js"),K=require("@arcblock/ux/lib/Theme"),Pe=require("@blocklet/ui-react/lib/Footer");require("webfontloader");const J=require("./session-BA7Qrcia.js"),q=t=>t&&t.__esModule?t:{default:t},oe=q(de),we=q(fe),re=q(he),Re=q(xe),z=q(je),Se=q(be),se=q(ye),ke=q(Pe),qe=K.styled(ke.default,{shouldForwardProp:t=>!!t})`
2
- & > div > .MuiContainer-root {
3
- max-width: unset;
4
- }
5
- `;function _e({meta:t,...o}){const s=K.useTheme();return e.jsx(qe,{...o,meta:t,theme:s||{}})}function ae(t){return e.jsx(y.Box,{display:"flex",flex:1,height:"100%",alignItems:"center",justifyContent:"center",...t,children:e.jsx(y.CircularProgress,{size:30})})}function Ce(t){return e.jsx(Ee,{...t})}const Ee=K.styled(y.Box)`
6
- position: fixed;
7
- left: 0;
8
- top: 0;
9
- z-index: 999999999999;
10
- width: 80px;
11
- font-size: 12px;
12
- text-align: center;
13
- opacity: 0.7;
14
- transform: translateX(-23%) translateY(70%) rotate(-45deg);
15
- pointer-events: none;
16
- `,Me=`Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
17
- sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`;function Ie({titleFontFamily:t,descriptionFontFamily:o}){var n;const s=y.useTheme(),a=(n=s==null?void 0:s.typography)==null?void 0:n.fontFamily;f.useEffect(()=>{},[t,o]);const i=`${a}, ${Me}`;return e.jsx(V.Global,{styles:V.css`
18
- #app {
19
- font-family: ${i};
20
-
21
- .page-kit-section__title {
22
- font-family: ${i};
23
- }
24
-
25
- .page-kit-section__description {
26
- font-family: ${i};
27
- }
28
- }
29
- `})}function Be(){const[t]=w.useSearchParams(),{session:o}=J.useSessionContext(),s=J.useIsRoleOrMultiTenant("owner","admin","pagesEditor","member"),a=f.useMemo(()=>{const n=t.get("mode");return E.STATE_MODES.includes(n)?n:"production"},[t]),i=a==="production"?a:o.user?s?a:"production":null;return i?e.jsx(ie,{mode:i}):null}function ie({mode:t}){if(t!=="draft"){const o=window.__PAGE_STATE__;return o?e.jsx(N,{mode:t,state:o}):e.jsx(Le,{mode:t,children:({state:s})=>e.jsx(N,{mode:t,state:s})})}return e.jsx(Te,{children:({state:o})=>e.jsx(N,{mode:t,state:o})})}const Te=f.lazy(()=>Promise.resolve().then(()=>require("./draft-data-6zW9mu28.js")));function Le({mode:t,children:o}){const s=document.querySelector('meta[property="pages:version"]'),a=s==null?void 0:s.content,i=k.useProjectId(),n=f.useMemo(()=>{if(a==="{{pagesPublishedAt}}"){const u=localStorage.getItem(k.getProjectPageVersionKey(i??""));return Number(u)?Number(u):new Date().getTime()}return Number(a)},[a]),{loading:p,value:c}=ne.useAsync(()=>E.getPages({mode:t,version:n}),[t,n]);return p?e.jsx(ae,{}):c?o({state:c}):null}function N({mode:t,state:o}){const{t:s,locale:a}=Z.useLocaleContext(),[i]=w.useSearchParams(),n=k.useProjectId(),p=k.useProjectSlug(),c=i.get("hiddenBadge")==="true",u=i.get("showPublish")==="true",{pageIds:h,pages:d,routeIds:g,routes:x,supportedLocales:j,config:{defaultLocale:b},resources:M}=o,m=k.getAllComponents(o),R=f.useMemo(()=>j!=null&&j.some(l=>l.locale===a)?a:void 0,[a,j]),L=Object.values(x||{}).find(l=>(l==null?void 0:l.path)==="/")||Object.values(d).find(l=>(l==null?void 0:l.slug)==="/")?void 0:Object.values(d)[0],H=f.useMemo(()=>t==="production"?h.map(l=>{const r=d[l];return r&&{id:r.id,path:C.joinURL("/",p||n||"",r.slug)}}).filter(E.nonNullable):g.map(l=>{const r=x[l];return r?{id:r.id,path:C.joinURL("/",p||n||"",r.path,`?mode=${t}&showPublish=true`)}:null}).filter(E.nonNullable),[h,d,t,x,g,n,p]),_=([...l])=>(t!=="production"&&u&&l.unshift(e.jsx(f.Suspense,{fallback:e.jsx("div",{}),children:e.jsx(Oe,{mode:"production",state:o})})),l);return e.jsxs(E.Provider,{value:{pages:H},children:[e.jsxs(w.Routes,{children:[L&&e.jsx(w.Route,{index:!0,element:e.jsx(w.Navigate,{to:C.joinURL("/",R||"",L.slug)})}),g==null?void 0:g.map(l=>{var P,v,S,A;const r=x==null?void 0:x[l];if(!r||!r.displayTemplateId)return null;const I=d[r.displayTemplateId];if(!I)return null;let B=[];if(r.params&&r.params.length>0){const T=me.generateParamCombinations({basePath:r.path,params:r.params,routeId:r.id,paramsOptions:r.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]});B=T==null?void 0:T.map(D=>{var F,Q,X,Y;const O=D.paramOptionIds.join("-");return e.jsx(w.Route,{path:C.joinURL(":projectIdOrSlug?",D.path),element:e.jsx(W,{mode:t,components:m,page:I,locale:R,defaultLocale:b,headerAddons:_,state:o,pageData:(Y=(X=(Q=(F=r.dataSource)==null?void 0:F.pathDataMappings)==null?void 0:Q[O])==null?void 0:X.dataCache)==null?void 0:Y[R||b||"en"]})},O)})}return B.push(e.jsx(w.Route,{path:C.joinURL(":projectIdOrSlug?",r.path),element:e.jsx(W,{mode:t,components:m,page:I,locale:R,defaultLocale:b,headerAddons:_,state:o,pageData:(A=(S=(v=(P=r.dataSource)==null?void 0:P.pathDataMappings)==null?void 0:v[r.id])==null?void 0:S.dataCache)==null?void 0:A[R||b||"en"]})},r.id)),B}),h.map(l=>{const r=d[l];return r?e.jsx(w.Route,{path:C.joinURL(":projectIdOrSlug?",r.slug),element:e.jsx(U,{mode:t,components:m,page:r,locale:R,defaultLocale:b,headerAddons:_})},r.id):null}),M.pages&&Object.values(M.pages).map(({blockletId:l,page:r})=>e.jsx(w.Route,{path:C.joinURL("/",`@${l}`,r.slug),element:e.jsx(U,{mode:t,components:m,page:r,locale:R,defaultLocale:b,headerAddons:_})},r.id)),e.jsx(w.Route,{path:"*",element:e.jsx(y.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:e.jsx(oe.default,{status:404,extra:e.jsx(ue,{href:"/",children:s("common.back")}),sx:{bgcolor:"transparent",width:"100%",height:"100%"}})})})]}),t!=="production"&&!c&&e.jsx(Ce,{sx:{bgcolor:"info.light"},children:t}),e.jsx(Ie,{})]})}function W({mode:t,pageData:o,components:s,page:a,locale:i,defaultLocale:n,headerAddons:p,state:c}){const u=$.useReactive({page:null});f.useEffect(()=>{const d=a||null;d?u.page=z.default(d):u.page=null},[a,u]);const h=f.useRef();return f.useEffect(()=>{se.default(o,h.current)||o&&u.page&&(ee.setPageDataSource(u.page,c,i,o),h.current=z.default(o))},[u.page,o,i,c]),u.page?e.jsx(U,{mode:t,components:s,page:u.page,locale:i,defaultLocale:n,headerAddons:p}):null}function De({mode:t,state:o,path:s,pageData:a}){const{t:i,locale:n}=Z.useLocaleContext(),{pages:p,supportedLocales:c,config:{defaultLocale:u},resources:h}=o,d=Object.values(p).find(m=>(m==null?void 0:m.slug)===s),g=Object.values(h.pages||{}).find(m=>m.page.slug===s),x=f.useMemo(()=>c!=null&&c.some(m=>m.locale===n)?n:void 0,[n,c]),j=$.useReactive({page:null});f.useEffect(()=>{const m=d||(g==null?void 0:g.page)||null;m?j.page=z.default(m):j.page=null},[d,g]);const b=f.useRef();if(f.useEffect(()=>{se.default(a,b.current)||a&&j.page&&(ee.setPageDataSource(j.page,o,x,a),b.current=z.default(a))},[{}]),!d&&!(g!=null&&g.page))return e.jsx(y.Box,{width:"100vw",height:"100vh",display:"flex",justifyContent:"center",alignItems:"center",children:e.jsx(oe.default,{style:{background:"inherit"},status:404,extra:e.jsx(ue,{href:"/",children:i("common.back")})})});const M=k.getAllComponents(o);return j.page?e.jsx(U,{mode:t,components:M,page:j.page,locale:x,defaultLocale:u}):null}function U({mode:t,components:o,page:s,locale:a,defaultLocale:i,headerAddons:n}){var R,G,L,H,_,l,r,I,B;const p=ge.useColorConvert(),c=((R=s.locales)==null?void 0:R[a])??((G=s.locales)==null?void 0:G[i])??{},u=c.title||((L=window.blocklet)==null?void 0:L.appName),h=c.description||((H=window.blocklet)==null?void 0:H.appDescription),d=k.autoResizeImage(k.getImageAbsoluteUrl(c.image),540),{logo:g,brand:x,description:j,...b}=pe.useHeaderState(),M=f.useMemo(()=>P=>{var S;let v=(n==null?void 0:n(P))??P;return v=((S=b.addons)==null?void 0:S.call(b,v))??v,v},[b.addons,n]),m=(_=c.header)!=null&&_.translucent?le:ce;return e.jsxs(E.PageProvider,{page:s,defaultLocale:i,currentLocale:a,children:[e.jsx(V.Global,{styles:V.css`
30
- body {
31
- background-color: ${p(!c.backgroundColor||c.backgroundColor==="transparent"?"background.default":c.backgroundColor)} !important;
32
- }
33
- `}),e.jsx(m,{hideNavMenu:!!((l=c.header)!=null&&l.hideNavMenus),translucentTextColor:(r=c.header)==null?void 0:r.translucentTextColor,...g?{logo:g}:{},...x?{brand:x}:{},...j?{description:j}:{},className:te.cx(((I=c.header)==null?void 0:I.sticky)&&"sticky","page-header"),maxWidth:!1,addons:M}),e.jsx(w.ScrollRestoration,{}),e.jsxs(ve.Helmet,{children:[e.jsx("title",{children:u}),e.jsx("meta",{name:"og:title",content:u}),e.jsx("meta",{name:"og:description",content:h}),e.jsx("meta",{name:"og:image",content:d}),e.jsx("meta",{name:"twitter:image:src",content:d}),e.jsx("meta",{name:"twitter:image",content:d}),e.jsx("meta",{property:"twitter:description",content:h}),e.jsx("meta",{property:"twitter:title",content:u}),e.jsx("meta",{name:"description",content:h})]}),e.jsx(y.Stack,{flexGrow:1,className:"PageView-root",sx:{"& .BlockBase-root:first-child":{pt:"0 !important"}},children:s.sectionIds.map(P=>{var T,D,O,F;const v=s.sections[P];if(!v||v.visibility==="hidden")return null;const S=(D=(T=s.dataSource)==null?void 0:T[P])==null?void 0:D[a],A=((F=(O=s.dataSource)==null?void 0:O[P])==null?void 0:F[i])??{};return e.jsx(E.BlockRenderer,{id:P,type:v.component,mode:t,section:v,config:{...Se.default(S)?A:S,locale:a,dev:t==="draft"?{mode:t,components:o,defaultLocale:i}:{mode:t,defaultLocale:i}},page:s},P)})}),!((B=c.footer)!=null&&B.hidden)&&e.jsx(_e,{})]})}const Oe=f.lazy(()=>Promise.resolve().then(()=>require("./publish-button-CPmErdXB.js"))),ce=re.default(we.default)`
34
- &.sticky {
35
- position: sticky;
36
- top: 0;
37
- }
38
- `;function Fe({logo:t}){const[o,s]=f.useState(),a=y.useMediaQuery(n=>n.breakpoints.down("sm")),{value:i}=ne.useAsync(()=>{var c,u;const n=new URL(a?((c=window==null?void 0:window.blocklet)==null?void 0:c.appLogo)||"/.well-known/service/blocklet/logo":((u=window==null?void 0:window.blocklet)==null?void 0:u.appLogoRect)||"/.well-known/service/blocklet/logo-rect",window.location.origin);n.searchParams.delete("imageFilter"),n.searchParams.delete("f");const p=n.toString();return new Promise(h=>{fetch(p).then(d=>{const g=d.headers.get("content-type");g!=null&&g.includes("svg")&&d.text().then(x=>{s(x),h(null)}),h(d.url)})})},[a]);if(t)return t;if(o)return e.jsx(y.Box,{sx:{filter:"initial !important"},dangerouslySetInnerHTML:{__html:Re.default.sanitize(o)}});if(i){const n=new URL(i);n.searchParams.set("imageFilter","convert"),n.searchParams.set("f","png"),n.searchParams.set("h","80");const p=n.toString();return e.jsx("img",{src:p,alt:"logo"})}return null}function le({logo:t,translucentTextColor:o,...s}){const{top:a=0}=$.useScroll(()=>document.getElementById("app"))||{},i=y.useTheme();let n=Math.min(a/800,1),p="";return n>.1?(n=Math.max(n,.6),p=y.alpha(i.palette.text.primary,n)):p=o||"#EEEEEE",e.jsx(ce,{logo:e.jsx(Fe,{logo:t}),...s,className:te.cx(n<=.7&&"reverse-color"),style:{backgroundColor:y.alpha(i.palette.background.default,n),"--logo-invert":n<=.7?1-n/6:1-n},sx:{backdropFilter:n>=.6?"blur(10px)":"blur(0px)",transition:"all 0.3s ease",position:"fixed !important",left:0,top:0,right:0,bgcolor:"transparent","&.reverse-color":{".navmenu-root>.navmenu-sub>span,\n .navmenu-root>.navmenu-item,\n .header-addons>button,\n .header-addons>a,\n .header-addons>div>button":{color:`${p} !important`}},"& .navmenu--horizontal":{bgcolor:"transparent !important"},".header-logo > div":{filter:"invert(var(--logo-invert))"},".header-logo":{color:p}}})}const ue=re.default(y.Button)``;exports.Home=Be;exports.HomeView=ie;exports.Loading=ae;exports.PageRoutes=N;exports.PageView=U;exports.PageViewByPath=De;exports.PageViewWithDataSource=W;exports.TranslucentHeader=le;
@@ -1,532 +0,0 @@
1
- import { jsx as e, jsxs as $ } from "react/jsx-runtime";
2
- import { u as X, d as Y, e as fe, f as he, g as be, c as ye } from "./state-BzwEX9VC.js";
3
- import { useLocaleContext as J } from "@arcblock/ux/lib/Locale/context";
4
- import Z from "@arcblock/ux/lib/Result";
5
- import { useHeaderState as ve } from "@blocklet/pages-kit/builtin/page/header";
6
- import { useColorConvert as we } from "@blocklet/pages-kit/contexts/color";
7
- import { setPageDataSource as ee } from "@blocklet/pages-kit/utils/data-source";
8
- import { generateParamCombinations as Pe } from "@blocklet/pages-kit/utils/route";
9
- import xe from "@blocklet/ui-react/lib/Header";
10
- import { cx as te } from "@emotion/css";
11
- import { Global as oe, css as ne } from "@emotion/react";
12
- import re from "@emotion/styled";
13
- import { Box as D, CircularProgress as ke, useTheme as ae, Button as Se, Stack as Ce, alpha as q, useMediaQuery as je } from "@mui/material";
14
- import { useReactive as se, useScroll as Ie } from "ahooks";
15
- import Re from "isomorphic-dompurify";
16
- import A from "lodash/cloneDeep";
17
- import Ee from "lodash/isEmpty";
18
- import ie from "lodash/isEqual";
19
- import { useEffect as _, lazy as le, useMemo as T, useRef as ce, Suspense as Te, useState as Me } from "react";
20
- import { Helmet as Be } from "react-helmet";
21
- import { useSearchParams as ue, Routes as Oe, Route as E, Navigate as Fe, ScrollRestoration as _e } from "react-router-dom";
22
- import { useAsync as pe } from "react-use";
23
- import { joinURL as S } from "ufo";
24
- import { S as De, n as K, P as Le, a as Ne, B as $e, g as Ae } from "./array-D34Qpnhk.js";
25
- import { styled as me, useTheme as He } from "@arcblock/ux/lib/Theme";
26
- import Ue from "@blocklet/ui-react/lib/Footer";
27
- import "webfontloader";
28
- import { u as Ve, a as ze } from "./session-CVblGhSp.js";
29
- const Ge = me(Ue, { shouldForwardProp: (t) => !!t })`
30
- & > div > .MuiContainer-root {
31
- max-width: unset;
32
- }
33
- `;
34
- function We({ meta: t, ...n }) {
35
- const a = He();
36
- return /* @__PURE__ */ e(Ge, { ...n, meta: t, theme: a || {} });
37
- }
38
- function qe(t) {
39
- return /* @__PURE__ */ e(D, { display: "flex", flex: 1, height: "100%", alignItems: "center", justifyContent: "center", ...t, children: /* @__PURE__ */ e(ke, { size: 30 }) });
40
- }
41
- function Ke(t) {
42
- return /* @__PURE__ */ e(Qe, { ...t });
43
- }
44
- const Qe = me(D)`
45
- position: fixed;
46
- left: 0;
47
- top: 0;
48
- z-index: 999999999999;
49
- width: 80px;
50
- font-size: 12px;
51
- text-align: center;
52
- opacity: 0.7;
53
- transform: translateX(-23%) translateY(70%) rotate(-45deg);
54
- pointer-events: none;
55
- `, Xe = `Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
56
- sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'`;
57
- function Ye({
58
- titleFontFamily: t,
59
- descriptionFontFamily: n
60
- }) {
61
- var o;
62
- const a = ae(), s = (o = a == null ? void 0 : a.typography) == null ? void 0 : o.fontFamily;
63
- _(() => {
64
- }, [t, n]);
65
- const i = `${s}, ${Xe}`;
66
- return /* @__PURE__ */ e(
67
- oe,
68
- {
69
- styles: ne`
70
- #app {
71
- font-family: ${i};
72
-
73
- .page-kit-section__title {
74
- font-family: ${i};
75
- }
76
-
77
- .page-kit-section__description {
78
- font-family: ${i};
79
- }
80
- }
81
- `
82
- }
83
- );
84
- }
85
- function Bt() {
86
- const [t] = ue(), { session: n } = Ve(), a = ze("owner", "admin", "pagesEditor", "member"), s = T(() => {
87
- const o = t.get("mode");
88
- return De.includes(o) ? o : "production";
89
- }, [t]), i = s === "production" ? s : n.user ? a ? s : "production" : null;
90
- return i ? /* @__PURE__ */ e(Je, { mode: i }) : null;
91
- }
92
- function Je({ mode: t }) {
93
- if (t !== "draft") {
94
- const n = window.__PAGE_STATE__;
95
- return n ? /* @__PURE__ */ e(V, { mode: t, state: n }) : /* @__PURE__ */ e(et, { mode: t, children: ({ state: a }) => /* @__PURE__ */ e(V, { mode: t, state: a }) });
96
- }
97
- return /* @__PURE__ */ e(Ze, { children: ({ state: n }) => /* @__PURE__ */ e(V, { mode: t, state: n }) });
98
- }
99
- const Ze = le(() => import("./draft-data-B5kzDvTI.js"));
100
- function et({
101
- mode: t,
102
- children: n
103
- }) {
104
- const a = document.querySelector('meta[property="pages:version"]'), s = a == null ? void 0 : a.content, i = X(), o = T(() => {
105
- if (s === "{{pagesPublishedAt}}") {
106
- const u = localStorage.getItem(ye(i ?? ""));
107
- return Number(u) ? Number(u) : (/* @__PURE__ */ new Date()).getTime();
108
- }
109
- return Number(s);
110
- }, [s]), { loading: m, value: l } = pe(() => Ae({ mode: t, version: o }), [t, o]);
111
- return m ? /* @__PURE__ */ e(qe, {}) : l ? n({ state: l }) : null;
112
- }
113
- function V({ mode: t, state: n }) {
114
- const { t: a, locale: s } = J(), [i] = ue(), o = X(), m = fe(), l = i.get("hiddenBadge") === "true", u = i.get("showPublish") === "true", {
115
- pageIds: f,
116
- pages: p,
117
- routeIds: d,
118
- routes: h,
119
- supportedLocales: b,
120
- config: { defaultLocale: y },
121
- resources: C
122
- } = n, g = Y(n), P = T(
123
- () => b != null && b.some((c) => c.locale === s) ? s : void 0,
124
- [s, b]
125
- ), M = Object.values(h || {}).find((c) => (c == null ? void 0 : c.path) === "/") || Object.values(p).find((c) => (c == null ? void 0 : c.slug) === "/") ? void 0 : Object.values(p)[0], L = T(() => t === "production" ? f.map((c) => {
126
- const r = p[c];
127
- return r && {
128
- id: r.id,
129
- path: S("/", m || o || "", r.slug)
130
- };
131
- }).filter(K) : d.map((c) => {
132
- const r = h[c];
133
- return r ? {
134
- id: r.id,
135
- path: S("/", m || o || "", r.path, `?mode=${t}&showPublish=true`)
136
- } : null;
137
- }).filter(K), [f, p, t, h, d, o, m]), k = ([...c]) => (t !== "production" && u && c.unshift(
138
- /* @__PURE__ */ e(Te, { fallback: /* @__PURE__ */ e("div", {}), children: /* @__PURE__ */ e(tt, { mode: "production", state: n }) })
139
- ), c);
140
- return /* @__PURE__ */ $(Le, { value: { pages: L }, children: [
141
- /* @__PURE__ */ $(Oe, { children: [
142
- M && /* @__PURE__ */ e(E, { index: !0, element: /* @__PURE__ */ e(Fe, { to: S("/", P || "", M.slug) }) }),
143
- d == null ? void 0 : d.map((c) => {
144
- var w, v, x, N;
145
- const r = h == null ? void 0 : h[c];
146
- if (!r || !r.displayTemplateId) return null;
147
- const j = p[r.displayTemplateId];
148
- if (!j) return null;
149
- let I = [];
150
- if (r.params && r.params.length > 0) {
151
- const R = Pe({
152
- basePath: r.path,
153
- params: r.params,
154
- routeId: r.id,
155
- paramsOptions: r.paramsOptions,
156
- currentIndex: 0,
157
- currentParams: [],
158
- currentOptionIds: [],
159
- result: []
160
- });
161
- I = R == null ? void 0 : R.map((B) => {
162
- var F, z, G, W;
163
- const O = B.paramOptionIds.join("-");
164
- return /* @__PURE__ */ e(
165
- E,
166
- {
167
- path: S(":projectIdOrSlug?", B.path),
168
- element: /* @__PURE__ */ e(
169
- Q,
170
- {
171
- mode: t,
172
- components: g,
173
- page: j,
174
- locale: P,
175
- defaultLocale: y,
176
- headerAddons: k,
177
- state: n,
178
- pageData: (W = (G = (z = (F = r.dataSource) == null ? void 0 : F.pathDataMappings) == null ? void 0 : z[O]) == null ? void 0 : G.dataCache) == null ? void 0 : W[P || y || "en"]
179
- }
180
- )
181
- },
182
- O
183
- );
184
- });
185
- }
186
- return I.push(
187
- /* @__PURE__ */ e(
188
- E,
189
- {
190
- path: S(":projectIdOrSlug?", r.path),
191
- element: /* @__PURE__ */ e(
192
- Q,
193
- {
194
- mode: t,
195
- components: g,
196
- page: j,
197
- locale: P,
198
- defaultLocale: y,
199
- headerAddons: k,
200
- state: n,
201
- pageData: (N = (x = (v = (w = r.dataSource) == null ? void 0 : w.pathDataMappings) == null ? void 0 : v[r.id]) == null ? void 0 : x.dataCache) == null ? void 0 : N[P || y || "en"]
202
- }
203
- )
204
- },
205
- r.id
206
- )
207
- ), I;
208
- }),
209
- f.map((c) => {
210
- const r = p[c];
211
- return r ? /* @__PURE__ */ e(
212
- E,
213
- {
214
- path: S(":projectIdOrSlug?", r.slug),
215
- element: /* @__PURE__ */ e(
216
- H,
217
- {
218
- mode: t,
219
- components: g,
220
- page: r,
221
- locale: P,
222
- defaultLocale: y,
223
- headerAddons: k
224
- }
225
- )
226
- },
227
- r.id
228
- ) : null;
229
- }),
230
- C.pages && Object.values(C.pages).map(({ blockletId: c, page: r }) => /* @__PURE__ */ e(
231
- E,
232
- {
233
- path: S("/", `@${c}`, r.slug),
234
- element: /* @__PURE__ */ e(
235
- H,
236
- {
237
- mode: t,
238
- components: g,
239
- page: r,
240
- locale: P,
241
- defaultLocale: y,
242
- headerAddons: k
243
- }
244
- )
245
- },
246
- r.id
247
- )),
248
- /* @__PURE__ */ e(
249
- E,
250
- {
251
- path: "*",
252
- element: /* @__PURE__ */ e(D, { width: "100vw", height: "100vh", display: "flex", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ e(
253
- Z,
254
- {
255
- status: 404,
256
- extra: /* @__PURE__ */ e(ge, { href: "/", children: a("common.back") }),
257
- sx: {
258
- bgcolor: "transparent",
259
- width: "100%",
260
- height: "100%"
261
- }
262
- }
263
- ) })
264
- }
265
- )
266
- ] }),
267
- t !== "production" && !l && /* @__PURE__ */ e(Ke, { sx: { bgcolor: "info.light" }, children: t }),
268
- /* @__PURE__ */ e(Ye, {})
269
- ] });
270
- }
271
- function Q({
272
- mode: t,
273
- pageData: n,
274
- components: a,
275
- page: s,
276
- locale: i,
277
- defaultLocale: o,
278
- headerAddons: m,
279
- state: l
280
- }) {
281
- const u = se({
282
- page: null
283
- });
284
- _(() => {
285
- const p = s || null;
286
- p ? u.page = A(p) : u.page = null;
287
- }, [s, u]);
288
- const f = ce();
289
- return _(() => {
290
- ie(n, f.current) || n && u.page && (ee(u.page, l, i, n), f.current = A(n));
291
- }, [u.page, n, i, l]), u.page ? /* @__PURE__ */ e(
292
- H,
293
- {
294
- mode: t,
295
- components: a,
296
- page: u.page,
297
- locale: i,
298
- defaultLocale: o,
299
- headerAddons: m
300
- }
301
- ) : null;
302
- }
303
- function Ot({
304
- mode: t,
305
- state: n,
306
- path: a,
307
- pageData: s
308
- }) {
309
- const { t: i, locale: o } = J(), {
310
- pages: m,
311
- supportedLocales: l,
312
- config: { defaultLocale: u },
313
- resources: f
314
- } = n, p = Object.values(m).find((g) => (g == null ? void 0 : g.slug) === a), d = Object.values(f.pages || {}).find((g) => g.page.slug === a), h = T(
315
- () => l != null && l.some((g) => g.locale === o) ? o : void 0,
316
- [o, l]
317
- ), b = se({
318
- page: null
319
- });
320
- _(() => {
321
- const g = p || (d == null ? void 0 : d.page) || null;
322
- g ? b.page = A(g) : b.page = null;
323
- }, [p, d]);
324
- const y = ce();
325
- if (_(() => {
326
- ie(s, y.current) || s && b.page && (ee(b.page, n, h, s), y.current = A(s));
327
- }, [{}]), !p && !(d != null && d.page))
328
- return /* @__PURE__ */ e(D, { width: "100vw", height: "100vh", display: "flex", justifyContent: "center", alignItems: "center", children: /* @__PURE__ */ e(Z, { style: { background: "inherit" }, status: 404, extra: /* @__PURE__ */ e(ge, { href: "/", children: i("common.back") }) }) });
329
- const C = Y(n);
330
- return b.page ? /* @__PURE__ */ e(
331
- H,
332
- {
333
- mode: t,
334
- components: C,
335
- page: b.page,
336
- locale: h,
337
- defaultLocale: u
338
- }
339
- ) : null;
340
- }
341
- function H({
342
- mode: t,
343
- components: n,
344
- page: a,
345
- locale: s,
346
- defaultLocale: i,
347
- headerAddons: o
348
- }) {
349
- var P, U, M, L, k, c, r, j, I;
350
- const m = we(), l = ((P = a.locales) == null ? void 0 : P[s]) ?? ((U = a.locales) == null ? void 0 : U[i]) ?? {}, u = l.title || ((M = window.blocklet) == null ? void 0 : M.appName), f = l.description || ((L = window.blocklet) == null ? void 0 : L.appDescription), p = he(be(l.image), 540), { logo: d, brand: h, description: b, ...y } = ve(), C = T(
351
- () => (w) => {
352
- var x;
353
- let v = (o == null ? void 0 : o(w)) ?? w;
354
- return v = ((x = y.addons) == null ? void 0 : x.call(y, v)) ?? v, v;
355
- },
356
- [y.addons, o]
357
- ), g = (k = l.header) != null && k.translucent ? nt : de;
358
- return /* @__PURE__ */ $(Ne, { page: a, defaultLocale: i, currentLocale: s, children: [
359
- /* @__PURE__ */ e(
360
- oe,
361
- {
362
- styles: ne`
363
- body {
364
- background-color: ${m(
365
- !l.backgroundColor || l.backgroundColor === "transparent" ? "background.default" : l.backgroundColor
366
- )} !important;
367
- }
368
- `
369
- }
370
- ),
371
- /* @__PURE__ */ e(
372
- g,
373
- {
374
- hideNavMenu: !!((c = l.header) != null && c.hideNavMenus),
375
- translucentTextColor: (r = l.header) == null ? void 0 : r.translucentTextColor,
376
- ...d ? { logo: d } : {},
377
- ...h ? { brand: h } : {},
378
- ...b ? { description: b } : {},
379
- className: te(((j = l.header) == null ? void 0 : j.sticky) && "sticky", "page-header"),
380
- maxWidth: !1,
381
- addons: C
382
- }
383
- ),
384
- /* @__PURE__ */ e(_e, {}),
385
- /* @__PURE__ */ $(Be, { children: [
386
- /* @__PURE__ */ e("title", { children: u }),
387
- /* @__PURE__ */ e("meta", { name: "og:title", content: u }),
388
- /* @__PURE__ */ e("meta", { name: "og:description", content: f }),
389
- /* @__PURE__ */ e("meta", { name: "og:image", content: p }),
390
- /* @__PURE__ */ e("meta", { name: "twitter:image:src", content: p }),
391
- /* @__PURE__ */ e("meta", { name: "twitter:image", content: p }),
392
- /* @__PURE__ */ e("meta", { property: "twitter:description", content: f }),
393
- /* @__PURE__ */ e("meta", { property: "twitter:title", content: u }),
394
- /* @__PURE__ */ e("meta", { name: "description", content: f })
395
- ] }),
396
- /* @__PURE__ */ e(
397
- Ce,
398
- {
399
- flexGrow: 1,
400
- className: "PageView-root",
401
- sx: {
402
- // 第一个 .BlockBase-root 的 pt 为 0
403
- "& .BlockBase-root:first-child": {
404
- pt: "0 !important"
405
- }
406
- },
407
- children: a.sectionIds.map((w) => {
408
- var R, B, O, F;
409
- const v = a.sections[w];
410
- if (!v || v.visibility === "hidden") return null;
411
- const x = (B = (R = a.dataSource) == null ? void 0 : R[w]) == null ? void 0 : B[s], N = ((F = (O = a.dataSource) == null ? void 0 : O[w]) == null ? void 0 : F[i]) ?? {};
412
- return /* @__PURE__ */ e(
413
- $e,
414
- {
415
- id: w,
416
- type: v.component,
417
- mode: t,
418
- section: v,
419
- config: {
420
- ...Ee(x) ? N : x,
421
- locale: s,
422
- dev: t === "draft" ? {
423
- mode: t,
424
- components: n,
425
- defaultLocale: i
426
- } : {
427
- mode: t,
428
- defaultLocale: i
429
- // 用于 fallback 的 locale
430
- }
431
- },
432
- page: a
433
- },
434
- w
435
- );
436
- })
437
- }
438
- ),
439
- !((I = l.footer) != null && I.hidden) && /* @__PURE__ */ e(We, {})
440
- ] });
441
- }
442
- const tt = le(() => import("./publish-button-9J9uRZtS.js")), de = re(xe)`
443
- &.sticky {
444
- position: sticky;
445
- top: 0;
446
- }
447
- `;
448
- function ot({ logo: t }) {
449
- const [n, a] = Me(), s = je((o) => o.breakpoints.down("sm")), { value: i } = pe(() => {
450
- var l, u;
451
- const o = new URL(
452
- s ? ((l = window == null ? void 0 : window.blocklet) == null ? void 0 : l.appLogo) || "/.well-known/service/blocklet/logo" : ((u = window == null ? void 0 : window.blocklet) == null ? void 0 : u.appLogoRect) || "/.well-known/service/blocklet/logo-rect",
453
- window.location.origin
454
- );
455
- o.searchParams.delete("imageFilter"), o.searchParams.delete("f");
456
- const m = o.toString();
457
- return new Promise((f) => {
458
- fetch(m).then((p) => {
459
- const d = p.headers.get("content-type");
460
- d != null && d.includes("svg") && p.text().then((h) => {
461
- a(h), f(null);
462
- }), f(p.url);
463
- });
464
- });
465
- }, [s]);
466
- if (t)
467
- return t;
468
- if (n)
469
- return /* @__PURE__ */ e(D, { sx: { filter: "initial !important" }, dangerouslySetInnerHTML: { __html: Re.sanitize(n) } });
470
- if (i) {
471
- const o = new URL(i);
472
- o.searchParams.set("imageFilter", "convert"), o.searchParams.set("f", "png"), o.searchParams.set("h", "80");
473
- const m = o.toString();
474
- return /* @__PURE__ */ e("img", { src: m, alt: "logo" });
475
- }
476
- return null;
477
- }
478
- function nt({
479
- logo: t,
480
- translucentTextColor: n,
481
- ...a
482
- }) {
483
- const { top: s = 0 } = Ie(() => document.getElementById("app")) || {}, i = ae();
484
- let o = Math.min(s / 800, 1), m = "";
485
- return o > 0.1 ? (o = Math.max(o, 0.6), m = q(i.palette.text.primary, o)) : m = n || "#EEEEEE", /* @__PURE__ */ e(
486
- de,
487
- {
488
- logo: /* @__PURE__ */ e(ot, { logo: t }),
489
- ...a,
490
- className: te(o <= 0.7 && "reverse-color"),
491
- style: {
492
- backgroundColor: q(i.palette.background.default, o),
493
- // @ts-ignore
494
- "--logo-invert": o <= 0.7 ? 1 - o / 6 : 1 - o
495
- },
496
- sx: {
497
- backdropFilter: o >= 0.6 ? "blur(10px)" : "blur(0px)",
498
- transition: "all 0.3s ease",
499
- position: "fixed !important",
500
- left: 0,
501
- top: 0,
502
- right: 0,
503
- bgcolor: "transparent",
504
- "&.reverse-color": {
505
- ".navmenu-root>.navmenu-sub>span,\n .navmenu-root>.navmenu-item,\n .header-addons>button,\n .header-addons>a,\n .header-addons>div>button": {
506
- color: `${m} !important`
507
- }
508
- },
509
- "& .navmenu--horizontal": {
510
- bgcolor: "transparent !important"
511
- },
512
- ".header-logo > div": {
513
- filter: "invert(var(--logo-invert))"
514
- },
515
- ".header-logo": {
516
- color: m
517
- }
518
- }
519
- }
520
- );
521
- }
522
- const ge = re(Se)``;
523
- export {
524
- Bt as H,
525
- qe as L,
526
- V as P,
527
- nt as T,
528
- Je as a,
529
- Q as b,
530
- Ot as c,
531
- H as d
532
- };