@blocklet/pages-kit-inner-components 0.6.23 → 0.6.25

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.
@@ -1,475 +0,0 @@
1
- "use strict";var Ve=Object.create;var pe=Object.defineProperty;var Je=Object.getOwnPropertyDescriptor;var Ye=Object.getOwnPropertyNames;var Ke=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var Qe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ye(t))!Xe.call(e,i)&&i!==n&&pe(e,i,{get:()=>t[i],enumerable:!(r=Je(t,i))||r.enumerable});return e};var Ze=(e,t,n)=>(n=e!=null?Ve(Ke(e)):{},Qe(t||!e||!e.__esModule?pe(n,"default",{value:e,enumerable:!0}):n,e));const o=require("react/jsx-runtime"),et=require("@mui/icons-material"),p=require("@mui/material"),tt=require("lodash/isEmpty"),ot=require("lodash/pick"),h=require("react"),nt=require("lodash/keyBy"),B=require("@arcblock/ux/lib/Theme"),b=require("@emotion/css"),rt=require("lodash/omit"),se=require("react-router-dom"),it=require("@arcblock/ux/lib/Button"),st=require("is-uri"),Be=require("@iconify-icon/react"),k=require("./state-tEydRMV8.js"),at=require("@blocklet/pages-kit/builtin/markdown/markdown-renderer"),Ce=require("@blocklet/pages-kit/contexts/color"),lt=require("react-syntax-highlighter/dist/esm/styles/prism"),ct=require("@arcblock/react-hooks/lib/useBrowser"),dt=require("@arcblock/ux/lib/Colors"),ae=require("@blocklet/pages-kit/components"),xe=require("@blocklet/pages-kit/utils/style"),ut=require("@mui/material/useMediaQuery"),V=require("pathe"),O=require("ufo"),mt=require("@blocklet/embed/message"),pt=require("ahooks"),xt=require("lodash/isEqual"),gt=require("@blocklet/embed/react"),ht=require("@arcblock/ux/lib/Locale/context"),ft=require("@arcblock/ux/lib/Screenshot"),bt=require("react-twitter-embed"),ge=require("react-use"),S=e=>e&&e.__esModule?e:{default:e},yt=S(tt),le=S(ot),vt=S(h),M=S(nt),I=S(rt),wt=S(it),ne=S(st),kt=S(at),jt=S(ct),he=S(dt),Se=S(ut),_t=S(xt),re=S(ft),Y="{{CUSTOM_VALUE}}",Bt=[{title:"None",value:"none",sx:{py:0}},{title:"Small",value:"small",sx:{py:{xs:2.5,md:4,lg:4,xl:6}}},{title:"Normal",value:"normal",sx:{py:{xs:5,md:7.5,lg:10,xl:12.5}}},{title:"Large",value:"large",sx:{py:{xs:7.5,md:10,lg:12.5,xl:15}}}],Ct=[{title:"None",value:"none",sx:{py:0}},{title:"Small",value:"small",sx:{py:{xs:2.5,md:4,lg:4,xl:6}}},{title:"Normal",value:"normal",sx:{py:{xs:5,md:7,lg:7,xl:9}}},{title:"Large",value:"large",sx:{py:{xs:6,md:9,lg:9,xl:11}}}],St=[{title:"None",value:"none",sx:{px:0}},{title:"Small",value:"small",sx:{px:{xs:2,md:4,lg:4,xl:6}}},{title:"Normal",value:"normal",sx:{px:{xs:2.5,md:7.5,lg:10,xl:12.5}}},{title:"Large",value:"large",sx:{px:{xs:2.5,md:10,lg:12.5,xl:15}}}],J=(e,t,n)=>{const r=e.breakpoints.values[n];return`${t}${r?` (${r}px)`:""}`},$t=[{title:"100%",value:"full",sx:{maxWidth:"100%"}},{title:e=>J(e,"Small","sm"),value:"sm",sx:{maxWidth:e=>e.breakpoints.values.sm,width:"100%",mx:"auto"}},{title:e=>J(e,"Normal","md"),value:"md",sx:{maxWidth:e=>e.breakpoints.values.md,width:"100%",mx:"auto"}},{title:e=>J(e,"Large","lg"),value:"lg",sx:{maxWidth:e=>e.breakpoints.values.lg,width:"100%",mx:"auto"}},{title:e=>J(e,"Extra Large","xl"),value:"xl",sx:{maxWidth:e=>e.breakpoints.values.xl,width:"100%",mx:"auto"}},{title:"Custom",value:"custom",sx:{maxWidth:Y,width:"100%",mx:"auto"}}],Nt=[{title:"None",value:"none",sx:{gap:0},containerSx:{gap:0}},{title:"Small",value:"small",sx:{gap:{xs:1,md:2,lg:2,xl:3}}},{title:"Normal",value:"normal",sx:{gap:{xs:2,md:3.5,lg:3.5,xl:5}}},{title:"Large",value:"large",sx:{gap:{xs:3,md:5,lg:5,xl:6.5}}}],Mt=[{title:"None",value:"none",sx:{p:0}},{title:"Small",value:"small",sx:{p:{xs:1,md:2,lg:2,xl:3}}},{title:"Normal",value:"normal",sx:{p:{xs:2.5,md:5,lg:5,xl:7.5}}},{title:"Large",value:"large",sx:{p:{xs:3,md:6,lg:6,xl:9}}}],Rt=[{title:"Start",value:"start",sx:{alignContent:"start"}},{title:"Center",value:"center",sx:{alignContent:"center"}},{title:"End",value:"end",sx:{alignContent:"end"}},{title:"Space Between",value:"space-between",sx:{alignContent:"space-between"}},{title:"Space Around",value:"space-around",sx:{alignContent:"space-around"}},{title:"Space Evenly",value:"space-evenly",sx:{alignContent:"space-evenly"}}],It=[{title:"Start",value:"start",sx:{justifyContent:"start"}},{title:"Center",value:"center",sx:{justifyContent:"center"}},{title:"End",value:"end",sx:{justifyContent:"end"}},{title:"Space Between",value:"space-between",sx:{justifyContent:"space-between"}},{title:"Space Around",value:"space-around",sx:{justifyContent:"space-around"}},{title:"Space Evenly",value:"space-evenly",sx:{justifyContent:"space-evenly"}}],Et=[{title:"Solid",value:"solid",sx:{border:"1px solid",borderColor:"divider"},group:"borderFrame"},{title:"Dashed",value:"dashed",sx:{border:"1px dashed",borderColor:"divider"},group:"borderFrame"},{title:"Dotted",value:"dotted",sx:{border:"1px dotted",borderColor:"divider"},group:"borderFrame"},{title:"Custom",value:"custom",sx:{border:Y},group:"borderFrame"}],$e=[{value:"macbook",title:"MacBook",group:"deviceFrame"},{value:"phone",title:"Phone",group:"deviceFrame"}],Ne=e=>$e.some(t=>t.value===e),fe=({hasUrl:e=!1,hasTab:t=!1}={})=>({position:"relative",paddingTop:"2em","&::before":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,border:"1px solid",borderColor:"divider",pointerEvents:"none",zIndex:1},"&::after":{content:'""',position:"absolute",top:0,left:0,right:0,height:"2em",backgroundColor:"divider",pointerEvents:"none",zIndex:1},"& > div:first-of-type:before":{display:"block",position:"absolute",content:'""',top:"-1.25em",left:"1em",width:"0.5em",height:"0.5em",borderRadius:"50%",bgcolor:"#f44",boxShadow:"0 0 0 2px #f44, 1.5em 0 0 2px #9b3, 3em 0 0 2px #fb5",zIndex:2},"& > div:first-of-type:after":e?{display:"block",position:"absolute",content:'""',top:"-1.6em",left:"5.5em",width:"calc(100% - 7em)",height:"1.2em",borderRadius:.25,bgcolor:"white",zIndex:2}:t?{display:"block",position:"absolute",content:'""',top:"0em",left:"5.5em",width:"20%",height:"0em",borderBottom:"2em solid white",borderLeft:"0.8em solid transparent",borderRight:"0.8em solid transparent",zIndex:2}:{}}),Pt=[{value:"chrome",title:"Chrome",group:"browserFrame",sx:fe()},{value:"chrome-with-url",title:"Chrome (With URL)",group:"browserFrame",sx:fe({hasUrl:!0})}],At=[{value:"shadow-sm",title:"Shadow Low Elevation",group:"shadowFrame",sx:{boxShadow:e=>e.shadows[2]}},{value:"shadow-md",title:"Shadow Medium Elevation",group:"shadowFrame",sx:{boxShadow:e=>e.shadows[6]}},{value:"shadow-lg",title:"Shadow High Elevation",group:"shadowFrame",sx:{boxShadow:e=>e.shadows[12]}},{value:"shadow-xl",title:"Shadow Extra High Elevation",group:"shadowFrame",sx:{boxShadow:e=>e.shadows[16]}},{value:"shadow-max",title:"Shadow Max Elevation",group:"shadowFrame",sx:{boxShadow:e=>e.shadows[24]}}],Lt=[{title:"None",value:"none",sx:{border:"none"},group:"commonFrame"},...Et,...Pt,...At,...$e],Tt=[{title:"None",value:"none",sx:{borderRadius:0}},{title:"Small",value:"small",sx:{borderRadius:1}},{title:"Medium",value:"medium",sx:{borderRadius:2}},{title:"Large",value:"large",sx:{borderRadius:3}},{title:"Extra Large",value:"xl",sx:{borderRadius:4}},{title:"Rounded",value:"rounded",sx:{borderRadius:"50%"}},{title:"Custom",value:"custom",sx:{borderRadius:Y}}],Wt=M.default(Bt,"value"),zt=M.default(Ct,"value"),Ft=M.default(St,"value"),Ut=M.default($t,"value"),Ot=M.default(Nt,"value"),Dt=M.default(Mt,"value"),qt=M.default(Rt,"value"),Gt=M.default(It,"value"),Ht=M.default(Lt,"value"),Vt=M.default(Tt,"value"),Jt=new Map([["baseSectionPaddingY",Wt],["maxWidth",Ut],["paddingY",zt],["paddingX",Ft],["layoutBlockGap",Ot],["layoutBlockPadding",Dt],["layoutBlockAlignContent",qt],["layoutBlockJustifyContent",Gt],["layoutBlockBorder",Ht],["layoutBlockBorderRadius",Vt]]);function L(e){const{type:t,value:n,format:r="sx",defaultValue:i=null}=e,s=Jt.get(t);if(!s||typeof n!="string"||!n)return i;const c=n.startsWith("custom:"),a=c?"custom":n;if(s?.[a]&&s?.[a]?.[r]){const l=s[a][r];if(c){const d=n.replace("custom:","");try{return JSON.parse(JSON.stringify(l||{}).replaceAll(Y,d))}catch{}}return l}return i}const Me=h.createContext({page:null,getPageMeta:()=>({}),getPageMetaStyle:()=>({})});function Yt(){return h.useContext(Me)}function Kt({page:e,children:t,defaultLocale:n="en",currentLocale:r}){const i=h.useMemo(()=>e?JSON.parse(JSON.stringify(e)):null,[JSON.stringify(e)]),s=h.useCallback(()=>{if(!i)return{};const l=r||n;return i.locales?.[l]??{}},[i,n,r]),c=h.useCallback((l="sx")=>{const d=s();return!d||!d.style?{}:Object.entries(d.style||{}).reduce((u,[g,x])=>{if(!x)return u;const v=`${g}Custom`;d.style[v];const y=L({type:g,value:x,format:l});return y?{...u,...y}:u},{})},[s]),a=h.useMemo(()=>({page:i,getPageMeta:s,getPageMetaStyle:c}),[i,s,c]);return o.jsx(Me.Provider,{value:a,children:t})}const K=["editing","height","locale","dev","sx"];function Xt(e){const{className:t,...n}=e;return o.jsx(Qt,{...n,className:b.cx("BlockBase-root",t)})}const Qt=B.styled(p.Box)`
2
- position: relative;
3
- color: ${({theme:e})=>e.palette.text.primary};
4
- `,Re=h.createContext({pages:[],project:void 0}),{Provider:Zt,Consumer:Cn}=Re;function Ie(){return h.useContext(Re)}function eo({icon:e,...t}){return o.jsx(Be.Icon,{icon:e,...t,ref:null})}function to({icon:e,className:t="",size:n="1rem",...r}){return o.jsx(oo,{component:eo,className:b.cx("css-icon",t),size:n,...r,icon:e})}const oo=B.styled(p.Box)`
5
- &.css-icon {
6
- display: inline-block;
7
- width: ${({size:e})=>e};
8
- height: ${({size:e})=>e};
9
- }
10
- `;function no({icon:e,className:t="",size:n="1rem",imageMeta:r,...i}){const s=k.autoResizeImage(k.getImageAbsoluteUrl(e),540),[c,a]=h.useState(!1),l=B.useTheme();return c?o.jsx(to,{icon:"i-mdi:image",color:l.palette.grey[500],size:n,className:t,...i}):o.jsx(ro,{className:b.cx("image-icon",t),size:n,...i,children:o.jsx("img",{className:"image-icon__image",src:s,onError:()=>a(!0),width:r?.naturalWidth,height:r?.naturalHeight,alt:r?.filename||"card-icon",loading:"lazy"})})}const ro=B.styled(p.Box)`
11
- display: inline-block;
12
- width: ${({size:e})=>e};
13
- height: ${({size:e})=>e};
14
- .image-icon__image {
15
- object-fit: contain;
16
- height: 100%;
17
- width: 100%;
18
- }
19
- `,ce=e=>typeof e=="string"&&/^[\w-_]+:[\w-_]+$/.test(e);function ie({icon:e,size:t="1rem",imageMeta:n,...r}){const i=window.isNaN(t)?t:`${t}px`;return ce(e)?o.jsx(Be.Icon,{icon:e}):o.jsx(io,{component:no,imageMeta:n,className:"base-icon",icon:e,size:i,...r})}const io=B.styled(p.Box)`
20
- flex-shrink: 0;
21
- `;function q({text:e,children:t,icon:n="",endIcon:r,color:i="primary",link:s="",href:c="",...a}){const l=n?o.jsx(ie,{icon:n}):null,d=r?o.jsx(ie,{icon:r}):null,m=s||c,u={...a};return m&&(u.href=m,ne.default(m)&&(u.target=u.target||"_blank")),o.jsx(wt.default,{startIcon:l,endIcon:d,color:i,...u,children:e||t})}function Ee({editing:e,text:t,...n}){const{pages:r=[]}=Ie(),i=r.find(s=>s.id===(n.link||n.linkId));if(e)return o.jsx(q,{...I.default(n,["link","linkId"]),children:t});if(i){const s=i.path||"/";return o.jsx(se.Link,{to:s,children:o.jsx(q,{...I.default(n,["link","linkId"]),children:t})})}return o.jsx(q,{...I.default(n,"linkId"),children:t})}function W({actions:e,center:t,className:n,align:r}){return e&&e?.length?o.jsx(p.Box,{className:b.cx("flex gap-4 flex-wrap","lg:flex-row lg:gap-8",(t||r==="center")&&"justify-center",!t&&r==="right"&&"justify-end",!t&&r==="left"&&"justify-start",n),sx:{alignItems:"center"},children:e}):null}const so="section",ao=p.styled(p.Box)`
22
- overflow: hidden;
23
-
24
- .section__title {
25
- margin-top: 0;
26
- font-weight: 700;
27
- }
28
- .section__title_non_big {
29
- font-size: 32px;
30
- @media (max-width: 600px) {
31
- font-size: 24px;
32
- }
33
- }
34
- &.base-info .section__tag {
35
- margin-top: 0;
36
- margin-bottom: 2vw;
37
- background-color: ${({theme:e})=>e.palette.primary.main};
38
- white-space: nowrap;
39
- max-width: 100%;
40
- display: inline-block;
41
- padding: 0 10px;
42
- justify-content: flex-start;
43
- overflow: hidden;
44
- text-overflow: ellipsis;
45
- font-size: 12px;
46
- color: #fff;
47
- border-radius: 4px;
48
- line-height: 20px;
49
- }
50
- .section__title {
51
- color: ${({theme:e})=>e.palette.text.primary};
52
- a {
53
- color: ${({theme:e})=>e.palette.primary.main};
54
- }
55
- p {
56
- margin-top: 0;
57
- margin-bottom: 0;
58
- }
59
- }
60
- .section__description {
61
- color: ${({theme:e})=>e.palette.text.primary};
62
- margin-bottom: 4vw;
63
- margin-top: 0;
64
- a {
65
- color: ${({theme:e})=>e.palette.primary.main};
66
- }
67
- p {
68
- margin-top: 0;
69
- margin-bottom: 0.5rem;
70
- }
71
- }
72
- @media (min-width: ${({theme:e})=>e.breakpoints.values[so]}px) {
73
- .section__tag {
74
- margin-bottom: 32px;
75
- }
76
- .section__title {
77
- margin-bottom: 32px;
78
- }
79
- .section__description {
80
- margin-bottom: 40px;
81
- }
82
- }
83
- `;function X({title:e,description:t,descriptionMarkdown:n,actions:r,className:i="",classes:s={},prepend:c,append:a,level:l=2,tag:d,badge:m,center:u,logo:g,titleAppearance:x,descriptionAppearance:v,...y}){const w=Ce.useColorConvert();if(!e&&!t&&!r&&!m&&!d&&!c&&!a&&!g)return null;const j=Math.max(Math.min(5,l+1),1),_={1:"xl:!text-3xl lg:!text-2xl md:!text-xl",2:"xl:!text-2xl lg:!text-xl md:!text-lg",3:"xl:!text-2xl lg:!text-xl md:!text-lg",4:"xl:!text-xl lg:!text-lg md:!text-md",5:"xl:!text-lg md:!text-md sm:!text-sm",6:"!text-sm"},R=l===0?"big":`h${j}`,$=l===0;return o.jsxs(ao,{className:b.cx("base-info","lg:text-left",u&&"!text-center",i),...y,children:[c&&o.jsx("div",{children:c}),(d||m)&&o.jsx("div",{className:b.cx("section__tag",s?.tag||s?.badge),children:d||m}),g&&o.jsx("img",{className:"w-[120px] m-auto mb-8",src:g,alt:"info",loading:"lazy"}),e&&o.jsx(p.Typography,{sx:{whiteSpace:"pre-wrap",mb:t?"2vw":0,...x?.color&&{color:`${w(x.color)} !important`}},className:b.cx("section__title","text-gray-800","dark:text-gray-50",s.title,"page-kit-section__title",$?"":"section__title_non_big"),component:`h${Math.max(l,1)}`,variant:R,children:e}),t&&(n?o.jsx(p.Box,{sx:{...v?.color&&{color:`${w(v.color)} !important`}},className:b.cx("section__description","text-gray-800","dark:text-gray-100",_[j],s.description,"page-kit-section__description"),children:o.jsx(kt.default,{codeOptions:{showActionButton:!1,theme:lt.materialDark},children:t})}):o.jsx(p.Typography,{sx:{whiteSpace:"pre-wrap",...v?.color&&{color:`${w(v.color)} !important`}},className:b.cx("section__description","text-gray-800","dark:text-gray-100",_[j],s.description,"page-kit-section__description"),component:"div",variant:"body1",gutterBottom:!0,children:t})),o.jsx(W,{actions:r,center:u,className:"mt-8"}),a&&o.jsx("div",{children:a})]})}const Q=["actions","append","badge","tag","center","description","descriptionMarkdown","level","logo","prepend","title","titleAppearance","descriptionAppearance"];function lo(){const e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")}function co(e=""){if(e.startsWith("data:image/svg+xml,"))return!0;const t=/^(((ht|f)tps?):\/\/)?([^!@#$%^&*?.\s-]([^!@#$%^&*?.\s]{0,63}[^!@#$%^&*?.\s])?\.)+[a-z]{2,6}\/?/,n=/^(\/|\.\/|\.\.\/)(?:[^/]+\/)*[^/]+$/;return t.test(e)||n.test(e)}function D(e){return e?.endsWith(".mp4")||e?.endsWith(".m4v")||e?.endsWith(".webm")}function uo(e){return e?.endsWith(".mp4")||e?.endsWith(".m4v")?"video/mp4":e?.endsWith(".webm")?"video/webm":void 0}function mo(e){let t={};return typeof e=="string"?xe.isGradient(e)?t.image=e:(t.image=k.getImageAbsoluteUrl(e),xe.isColorString(e)&&(t.color=e,t.image="")):t=e,t}function po(){const[e,t]=h.useState(Date.now());return h.useEffect(()=>{const n=()=>{t(Date.now())};return document.addEventListener("visibilitychange",n),()=>{document.removeEventListener("visibilitychange",n)}},[]),e}function be(e,t,n,r,i){let s=null;const{color:c="",image:a}=mo(t);if(a&&co(a)){delete n.backgroundColor;const l=!(e.mobile.apple.device||lo())&&D(a),d=D(a)&&r?k.autoResizeImage(k.getImageAbsoluteUrl(r),1200,"quality"):"";l?s=o.jsx(p.Box,{component:"video",className:"section-bg",autoPlay:!0,loop:!0,muted:!0,controls:!1,playsInline:!0,poster:d,src:D(a)?a:k.autoResizeImage(a,1200,"quality"),sx:{width:"100%",position:"absolute",zIndex:-9999,right:0,left:0,top:0,height:"100%",objectFit:"cover"}},a):s=o.jsx(ae.ResponsiveImage,{src:D(a)&&r?d:a,sizesAttr:{sm:600,md:900,lg:1200},className:"section-bg",alt:"",width:"100%",loading:"lazy",sx:{position:"absolute",zIndex:-9999,right:0,left:0,top:0,width:"100%",height:"100%",objectFit:"cover"}},i||a)}else a?n.backgroundImage=`${a} !important`:c&&(n.backgroundColor=`${c} !important`);return s}function xo({autoWidth:e,children:t,...n}){return e?o.jsx(p.Box,{...n,sx:[{display:"flex"},...Array.isArray(n.sx)?n.sx:[n.sx]],children:t}):o.jsx(p.Container,{...n,children:t})}function Z({dark:e=!1,children:t,className:n,sx:r={},boxed:i={show:!1},padding:s="normal",boxProps:c,type:a,...l}){const d={...r},m=Se.default(x=>x.breakpoints.down("md"));e&&(d.color=he.default.common.white,d.backgroundColor=`${he.default.grey[900]} !important`),i.show&&(d.display="flex");const u=h.useMemo(()=>!Number(l.boxMaxWidth)||m?{width:"100%"}:a==="wall"&&l.boxMaxWidth?{maxWidth:`${l.boxMaxWidth}px !important`,width:"100%"}:{width:"100%"},[l.boxMaxWidth,m,a]),g=L({type:"baseSectionPaddingY",value:s||"normal",defaultValue:""});return o.jsx(go,{component:"section",styles:{...d,...g},className:b.cx("base-section","px-2 md:px-5 lg:px-5 xl:px-10",n,{dark:e}),...I.default(l,"hoverStyle","boxMaxWidth","embedUrl","autoWidth","paddingXY","iframeHeight","titleAppearance","descriptionAppearance"),children:o.jsx(xo,{autoWidth:l?.autoWidth,className:b.cx("section-content h-full"),sx:u,children:i.show?o.jsx(Pe,{...c,boxed:i,children:t}):t})})}function Pe({background:e="",backgroundVideoPoster:t,children:n,sx:r={},boxed:i={show:!1},className:s="",styles:c={},...a}){const l={...c,...r},d=Ce.useColorConvert();let m=null;const u=Se.default(v=>v.breakpoints.up("sm")),g=jt.default(),x=po();return e&&(m=be(g,typeof e=="string"?d(e):e,l,t,x)),i.show&&(l.borderRadius="10px",l.padding===void 0&&(l.padding=u?"50px":"20px"),i?.border&&(l.border="1px solid #c0c0c0"),i?.background&&(m=be(g,typeof i?.background=="string"?d(i?.background):i?.background,l,i?.backgroundVideoPoster,x))),o.jsxs(p.Box,{...a,sx:{...l,...m?{position:"relative",overflow:"hidden",zIndex:0}:{}},className:b.cx(s,i?.boxShadow&&"shadow-xl"),children:[m,n]})}const go=B.styled(Pe)`
84
- &:nth-of-type(even) {
85
- background: #f8f8f8;
86
- }
87
-
88
- @media (max-width: 600px) {
89
- .section__title {
90
- font-size: 24px;
91
- }
92
-
93
- .base-info {
94
- > *:last-child {
95
- margin-bottom: 0;
96
- }
97
- }
98
- }
99
- `;function Ae(e){if(e.type===h.Fragment){const n=(e.props.children||[]).filter(r=>h.isValidElement(r));return n.length===1?Ae(n[0]):n.length>1}return Array.isArray(e)}const A="&>*";function Le({children:e,col:t,gap:n,className:r,align:i,sx:s,type:c,...a}={children:null,className:"",col:3,gap:void 0,sx:{},align:"center",type:"default"}){const l=B.useTheme(),d=Number(Math.floor(100/t*100)/100),m={center:"justify-center items-center",left:"justify-start items-center",right:"justify-end items-center",top:"justify-center items-start",bottom:"justify-center items-end","top-left":"justify-start items-start","top-right":"justify-end items-start","bottom-left":"justify-start items-end","bottom-right":"justify-end items-end"},u=m[i]||m.center;let x=n??({2:6,3:4,4:4,5:3,6:3}[t]||0);Ae(e)||(x=0);const y=(t-1)*x/t;let w={...s,gap:`${x}rem`};const j={[A]:{width:"100%"}},_={},R={},$={};switch(j.gap="1rem",_.gap=`${x/2}rem`,t){case 3:case 4:_[A]={width:`calc(50% - ${x/2}rem)`};break;case 5:case 6:j[A]={width:`calc(50% - ${x/2/2}rem)`},_[A]={width:`calc(50% - ${x/2/2}rem)`},R[A]={width:`calc(33.33% - ${x*2/3}rem)`};break}return w[A]={width:`calc(${d}% - ${y}rem)`},w[`@media (max-width: ${l.breakpoints.values.xl}px)`]=$,w[`@media (max-width: ${l.breakpoints.values.lg}px)`]=R,w[`@media (max-width: ${l.breakpoints.values.md}px)`]=_,w[`@media (max-width: ${l.breakpoints.values.sm}px)`]=j,c==="wall"&&(w={...s,gap:`${x}rem`},w[A]={width:`calc(${d}% - ${y}rem)`},j[A]={width:`calc(45% - ${x/2/2}rem)`},w[`@media (max-width: ${l.breakpoints.values.sm}px)`]=j),o.jsx(p.Box,{className:b.cx("flex flex-wrap flex-row h-full",u,r),sx:w,...a,children:e})}function z({type:e="",icon:t="",size:n="3rem",className:r="",...i}){return o.jsx(ie,{icon:t||e,size:n,className:b.cx("content-icon",r),...i,color:typeof i.color>"u"?"inherit":i.color})}function ho({to:e,base:t,children:n,className:r,activeClassName:i="active",target:s="auto",autoExternalMark:c=!1,useRouterLink:a,...l}){const{pages:d=[],locale:m=""}={},u=t?V.join("/",t):t||"";let g=s==="auto"?"_self":s,x=V.join(u,e);const v=c?ne.default(x):!1;if(t)return x=V.join(u,m,e),o.jsx("a",{className:`no-underline ${r}`,href:O.withoutTrailingSlash(x),rel:"noreferrer noopener",target:g,...l,children:n});if(ne.default(e))s==="auto"&&(g="_blank"),x=e;else{O.isRelative(x)&&(x=V.join(window.location.pathname,x));const y=O.parseURL(`${window.location.origin}${x}`),w=d.some(j=>j.pathname===y.pathname);if(a||w)return o.jsx(se.NavLink,{end:!0,to:O.withoutTrailingSlash(x),className:({isActive:j})=>b.cx(r,j?i:""),...l,children:n})}return o.jsxs("a",{className:`no-underline ${r}`,href:O.withoutTrailingSlash(x),rel:"noreferrer noopener",target:g,...l,children:[n,v&&o.jsx(z,{icon:"i-mdi:arrow-top-right",size:"0.9em",className:"smart-link__mark",style:{marginLeft:5}})]})}function G({prepend:e,append:t,children:n,className:r="",dark:i=!1,border:s=!0,...c}){let a={};const{pages:l=[]}=Ie(),d=l.find(g=>g.id===c.link),m=!n||vt.default.Children.toArray(n).every(g=>g===null);c.link&&(a={component:ho,to:d?.path||c.link,useRouterLink:!0});const u=p.useTheme();return o.jsxs(fo,{className:b.cx("base-card card",{dark:i,"border-transparent":!s},r),sx:{borderColor:u.palette.divider},...a,...I.default(c,["listType","dark","iconColor","link","hoverStyle","imageSize"]),children:[e,!m&&o.jsx("div",{className:"card__body",children:n}),t]})}const fo=B.styled(p.Box)`
100
- &.base-card {
101
- text-align: left;
102
- border-width: 1px;
103
- border-style: solid;
104
- border-radius: 12px;
105
- overflow: hidden;
106
- &,
107
- &:hover {
108
- text-decoration: none;
109
- }
110
- }
111
- .card__body {
112
- padding: 15px 15px;
113
- }
114
- `;function H({align:e="left",title:t,titleProps:n={},description:r,descriptionProps:i={}}){return o.jsxs(o.Fragment,{children:[t&&o.jsx(p.Typography,{className:b.cx("card__title text-gray-800","dark:text-gray-50"),component:"h5",variant:"h5",gutterBottom:!0,align:e,...n,children:t}),r&&o.jsx(p.Typography,{className:b.cx("card__description","text-gray-500","dark:text-gray-400"),component:"div",variant:"body1",gutterBottom:!0,align:e,...i,children:r})]})}function bo({image:e,title:t,description:n,imageProps:r={},imageMeta:i,imageSize:s,titleProps:c={},descriptionProps:a={},actions:l,align:d,...m}){const u=ce(e),g=k.autoResizeImage(k.getImageAbsoluteUrl(e),540);return o.jsxs(yo,{className:"card-article",...m,prepend:o.jsx("div",{className:"card__image__wrap",children:u&&e?o.jsx(p.Box,{sx:{position:"absolute",left:0,top:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx(z,{icon:e,color:"primary.main"})}):g&&o.jsx("img",{className:"card__image",src:g,...r,alt:r.alt||i?.filename||"card-image",width:i?.naturalWidth,height:i?.naturalHeight,style:{width:"100%",height:"100%",objectFit:s||"cover",objectPosition:"center"},loading:"lazy"})}),children:[t||n?o.jsx(H,{align:d,title:t,titleProps:c,description:n,descriptionProps:a}):null,l?.length?o.jsx(W,{align:d,actions:l,className:"mt-4"}):null]})}const yo=B.styled(G)`
115
- ${e=>e.hoverStyle==="none"?"":e.link?`transition: box-shadow ease .3s;
116
- &:hover {
117
- box-shadow: 0 0 10px rgba(95, 142, 244, 0.42);
118
- }`:""}
119
-
120
- .card__title {
121
- color: ${({theme:e})=>e.palette.text.primary};
122
- a {
123
- color: ${({theme:e})=>e.palette.primary.main};
124
- }
125
- }
126
- .card__description {
127
- color: ${({theme:e})=>e.palette.text.primary};
128
- a {
129
- color: ${({theme:e})=>e.palette.primary.main};
130
- }
131
- }
132
-
133
- .card__image__wrap {
134
- padding-top: 61.8%;
135
- width: 100%;
136
- position: relative;
137
- }
138
- .card__image {
139
- position: absolute;
140
- top: 0;
141
- left: 0;
142
- bottom: 0;
143
- right: 0;
144
- width: 100%;
145
- height: 100%;
146
- object-position: top center;
147
- }
148
- `,ye="section";function ve({title:e,image:t,imageMeta:n,description:r,actions:i,align:s,listType:c="",className:a="",...l}){return o.jsxs(vo,{className:b.cx("card",`list-type-${c}`,a),align:s,...l,children:[t&&o.jsx(z,{icon:t,color:"primary.main",size:c==="icon-title"?"1.2rem":"3rem",imageMeta:n}),e||r?o.jsx(H,{align:s,title:e,description:r}):null,i?.length?o.jsx(W,{align:s,actions:i,className:"mt-4"}):null]})}const vo=B.styled(G)`
149
- padding: 5vw 4vw;
150
- box-sizing: border-box;
151
- /* min-height: 320px; */
152
- color: inherit !important;
153
- border-radius: 0.5rem;
154
- /* ${({dark:e,theme:t})=>`background-color:${e?t.palette.grey[900]:t.palette.common.white};`} */
155
- @media (max-width: ${({theme:e})=>e.breakpoints.values[ye]}px) {
156
- padding: 1.5rem 2rem;
157
- }
158
- @media (max-width: ${({theme:e})=>e.breakpoints.values.sm}px) {
159
- height: auto;
160
- min-height: unset;
161
- }
162
-
163
- ${e=>e.hoverStyle==="none"?"":e.link?`transition: box-shadow ease .3s;
164
- &:hover {
165
- box-shadow: 0 0 10px rgba(95, 142, 244, 0.42);
166
- }`:""}
167
-
168
- .card__title {
169
- font-weight: 700;
170
- margin-top: 24px;
171
- margin-bottom: 12px;
172
- color: ${({theme:e})=>e.palette.text.primary};
173
- a {
174
- color: ${({theme:e})=>e.palette.primary.main};
175
- }
176
- }
177
- .card__description {
178
- color: ${({theme:e})=>e.palette.text.primary};
179
- a {
180
- color: ${({theme:e})=>e.palette.primary.main};
181
- }
182
- }
183
- .card__body {
184
- color: ${({theme:e})=>e.palette.text.primary};
185
- padding: 0;
186
- ${({align:e})=>`text-align:${e||"left"};`}
187
- }
188
-
189
- &.list-type-icon-title {
190
- padding: 1.2rem;
191
- .title-line {
192
- display: flex;
193
- }
194
- .card__title {
195
- margin: 0;
196
- font-size: 1em;
197
- }
198
- .css-icon {
199
- margin-right: 0.5rem;
200
- }
201
- }
202
-
203
- @media (min-width: ${({theme:e})=>e.breakpoints.values[ye]}px) {
204
- padding: 2rem 2rem;
205
- text-align: left;
206
- box-sizing: border-box;
207
- }
208
- `;function wo({image:e,title:t,description:n,imageProps:r={},imageMeta:i,imageSize:s,titleProps:c={},descriptionProps:a={},actions:l,align:d,...m}){const u=ce(e),g=k.autoResizeImage(k.getImageAbsoluteUrl(e),540);return o.jsxs(ko,{className:"card-article",...m,prepend:o.jsx("div",{className:"card__image__wrap",children:u&&e?o.jsx(p.Box,{sx:{position:"absolute",left:0,top:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx(z,{icon:e,color:"primary.main"})}):g&&o.jsx(p.Box,{component:"img",className:"card__image",src:g,...r,alt:r.alt||i?.filename||"card-image",style:{width:"100%",height:"100%",objectFit:s||"contain",objectPosition:"center"},loading:"lazy",sx:[{width:i?.naturalWidth,height:i?.naturalHeight},...Array.isArray(r.sx)?r.sx:[r.sx]]})}),children:[t||n?o.jsx(H,{align:d,title:t,titleProps:c,description:n,descriptionProps:a}):null,l?.length?o.jsx(W,{align:d,actions:l,className:"mt-4"}):null]})}const ko=B.styled(G)`
209
- ${e=>e.hoverStyle==="none"?"":e.link?`transition: box-shadow ease .3s;
210
- &:hover {
211
- box-shadow: 0 0 10px rgba(95, 142, 244, 0.42);
212
- }`:""}
213
-
214
- border-radius: 0 !important;
215
-
216
- .card__body {
217
- ${({align:e})=>`text-align:${e||"left"};`}
218
- }
219
-
220
- .card__image__wrap {
221
- width: 100%;
222
- height: 100%;
223
- position: relative;
224
- display: flex;
225
- justify-content: center;
226
- align-items: center;
227
- }
228
-
229
- .card__image {
230
- max-height: 60px;
231
- }
232
- `,we="section";function jo({title:e,image:t,imageMeta:n,iconSize:r=100,description:i,actions:s,align:c,className:a="",...l}){return o.jsx(_o,{className:b.cx("card",a),...l,children:o.jsxs(p.Box,{className:"flex items-center",children:[t&&o.jsx(z,{icon:t,color:"primary.main",size:r,imageMeta:n}),o.jsxs(p.Box,{className:"flex-1 ml-4",children:[o.jsx(H,{align:c,title:e,description:i}),o.jsx(W,{align:c,actions:s,className:"mt-4"})]})]})})}const _o=B.styled(G)`
233
- padding: 5vw 4vw;
234
- text-align: left;
235
- box-sizing: border-box;
236
- /* min-height: 320px; */
237
- color: inherit !important;
238
- border-radius: 0.5rem;
239
- /* ${({dark:e,theme:t})=>`background-color:${e?t.palette.grey[900]:t.palette.common.white};`} */
240
- @media (max-width: ${({theme:e})=>e.breakpoints.values[we]}px) {
241
- padding: 1.5rem 2rem;
242
- }
243
- @media (max-width: ${({theme:e})=>e.breakpoints.values.sm}px) {
244
- height: auto;
245
- min-height: unset;
246
- }
247
-
248
- ${e=>e.hoverStyle==="none"?"":e.link?`transition: box-shadow ease .3s;
249
- &:hover {
250
- box-shadow: 0 0 10px rgba(95, 142, 244, 0.42);
251
- }`:""}
252
-
253
- .card__title {
254
- font-weight: 700;
255
- margin-bottom: 12px;
256
- color: ${({theme:e})=>e.palette.text.primary};
257
- a {
258
- color: ${({theme:e})=>e.palette.primary.main};
259
- }
260
- }
261
- .card__description {
262
- color: ${({theme:e})=>e.palette.text.primary};
263
- a {
264
- color: ${({theme:e})=>e.palette.primary.main};
265
- }
266
- }
267
- .card__body {
268
- padding: 0;
269
- }
270
-
271
- &.list-type-icon-title {
272
- padding: 1.2rem;
273
- .title-line {
274
- display: flex;
275
- }
276
- .card__title {
277
- margin: 0;
278
- font-size: 1em;
279
- }
280
- .css-icon {
281
- margin-right: 0.5rem;
282
- }
283
- }
284
-
285
- @media (min-width: ${({theme:e})=>e.breakpoints.values[we]}px) {
286
- padding: 2rem 2rem;
287
- text-align: left;
288
- box-sizing: border-box;
289
- }
290
- `;function Bo({title:e,titleProps:t={},description:n,descriptionProps:r={},image:i,imageMeta:s,className:c="",align:a,hoverStyle:l,...d}){return o.jsxs(Co,{className:b.cx("card-simple",c,`hover-style__${l}`),align:a,...d,children:[i&&o.jsx(z,{icon:i,color:"primary.main",imageMeta:s}),e||n?o.jsx(H,{align:a,title:e,titleProps:t,description:n,descriptionProps:r}):null]})}const Co=B.styled(G)`
291
- .card__title {
292
- color: ${({theme:e})=>e.palette.text.primary};
293
- a {
294
- color: ${({theme:e})=>e.palette.primary.main};
295
- }
296
- }
297
- .card__description {
298
- color: ${({theme:e})=>e.palette.text.primary};
299
- a {
300
- color: ${({theme:e})=>e.palette.primary.main};
301
- }
302
- }
303
-
304
- &.hover-style__default {
305
- &.card-simple {
306
- &:hover {
307
- border-top-right-radius: 36px;
308
- }
309
- }
310
- .card__body {
311
- &:hover {
312
- &::before {
313
- width: 42px;
314
- height: 42px;
315
- transform: translate(50%, -50%) rotate(45deg);
316
- }
317
- &::after {
318
- transform: none;
319
- }
320
- }
321
- }
322
- }
323
-
324
- &.card-simple {
325
- border-radius: 8px;
326
- border-top-right-radius: 26px;
327
-
328
- .card__body {
329
- ${({align:e})=>`text-align:${e||"left"};`}
330
- }
331
-
332
- ${e=>e.link?`
333
- cursor: pointer;
334
- `:""}
335
- /* cursor: pointer; */
336
- /* &:hover {
337
- border-top-right-radius: 36px;
338
- } */
339
- transition: all 180ms ease 0s;
340
- overflow: visible;
341
- .card__title {
342
- margin: 12px 0;
343
- }
344
- .card__body {
345
- position: relative;
346
- padding: 20px 16px 18px;
347
- overflow: hidden;
348
- transition: all 180ms ease 0s;
349
- /* &:hover {
350
- &::before {
351
- width: 42px;
352
- height: 42px;
353
- transform: translate(50%, -50%) rotate(45deg);
354
- }
355
- &::after {
356
- transform: none;
357
- }
358
- } */
359
- &::before,
360
- &::after {
361
- content: ${({border:e})=>e?'""':""};
362
- transition: inherit;
363
- position: absolute;
364
- top: 0px;
365
- right: 0px;
366
- }
367
- &::before {
368
- z-index: 3;
369
- background: #fff;
370
- width: 30px;
371
- height: 30px;
372
- transform: translate(50%, -50%) rotate(45deg);
373
- box-shadow: 0 1px 0 0 #e9eaec;
374
- }
375
- &::after {
376
- z-index: 2;
377
- width: 28px;
378
- height: 28px;
379
- border-bottom-left-radius: 6px;
380
- background: #fcfcfd;
381
- box-shadow: -1px 1px 0 0 #e9eaec;
382
- transform: translate(8px, -8px);
383
- }
384
- }
385
- }
386
- `;function So({type:e="default",...t}){const r={article:bo,simple:Bo,news:jo,default:ve,wall:wo}[e]||ve;return o.jsx(r,{...e==="news"?t:I.default(t,"iconSize")})}function $o({list:e=[],align:t="top",cards:n,listBorder:r=!0,listType:i="",col:s=3,gap:c,iconColor:a,className:l="",type:d="default",dark:m=!1,textAlign:u="left",hoverStyle:g,...x}){return o.jsx(Le,{type:d,className:b.cx("card-list py-1",l,"items-stretch"),col:s,gap:c,align:t,...x,children:n||e.map(v=>o.jsx(So,{borderColor:r,iconColor:a,type:d,listType:i,dark:m,...v,align:u,style:c===0&&e.length>1?{borderRadius:0,marginRight:"-1px",marginBottom:"-1px"}:{}},v.id))})}const No=["align","cards","list","listBorder","listType","col","gap","iconColor","type","textAlign"];function E(e,t){const n=le.default(e,t),r=I.default(e,t);return[n,r]}const Mo=B.styled(Z)`
387
- a .card {
388
- color: #404040;
389
- cursor: pointer;
390
- }
391
- a:not(.MuiButton-root) {
392
- color: ${({theme:e})=>e.palette.primary.main};
393
- &:hover,
394
- &:active {
395
- color: ${({theme:e})=>e.palette.primary.main};
396
- }
397
- }
398
- a:hover .card {
399
- color: #404040;
400
- }
401
- `;function Ro({className:e,...t}){const[n,r]=E(t,Q),[i,s]=E(r,No);return o.jsxs(Mo,{className:b.cx("section--card-list",e),type:t.type,...s,children:[Object.keys(n).length>0&&o.jsx(X,{center:!0,...n,className:"mb-[2.5vw]"}),o.jsx($o,{...i,dark:!!t.dark})]})}const Io=B.styled(Ro)`
402
- .card__description {
403
- white-space: pre-wrap;
404
- }
405
- .section__description {
406
- }
407
- .card {
408
- /* background: inherit !important; */
409
- }
410
- &.dark .card-simple .card__body::before {
411
- background: #212121 !important;
412
- }
413
- .card-simple .card__body::after {
414
- background: inherit !important;
415
- }
416
- `;function Eo({section:e,...t}){const[{editing:n},r]=E(t,K),i=h.useMemo(()=>({...I.default(r,["listBorder","list","iconSize","imageSize"]),list:r.list?.map(s=>({...I.default(s,"icon","iconColor"),image:["news","simple","default"].includes(r.type)&&s.icon?s.icon:s.image,actions:s.actions?.map?.(c=>o.jsx(Ee,{...c,editing:n},c.id)),border:r.listBorder,iconSize:r.iconSize,imageSize:r.imageSize,hoverStyle:r.hoverStyle}))}),[r]);return o.jsx(Io,{style:n?{pointerEvents:"none"}:{},...i})}function Po({properties:e,section:t,locale:n,dev:r}){return t?.config?.componentId?o.jsx(ae.CustomComponentRenderer,{instanceId:t.id,componentId:t.config.componentId,blockletId:t.config.blockletId,blockletTitle:t.config.blockletTitle,componentName:t.config.componentName,locale:n,properties:e,dev:r}):o.jsx(p.Box,{sx:{textAlign:"center",py:2},children:o.jsx(p.Typography,{variant:"caption",sx:{color:"text.secondary"},children:"Please select component to render"})})}function Ao({src:e,dataId:t,isEdit:n=!1,height:r="100%",onLoad:i=()=>{}}){return o.jsx(gt.EmbedIframe,{isEdit:n,embedId:t,src:e,height:r,onLoad:()=>{i()}})}function Lo({dataId:e,src:t,actions:n,center:r,onLoad:i,...s}){const[c,a]=E(s,Q);return o.jsxs(Z,{...a,children:[Object.keys(c).length>0&&o.jsx(X,{center:r,...c}),o.jsx(Ao,{dataId:e,src:t,onLoad:i,height:s.iframeHeight?`${s.iframeHeight}px`:"100%"}),o.jsx(W,{actions:n,center:r})]})}const To={src:"",embedUrl:"",title:"",description:"",dark:!1,background:"",center:!0,config:{},id:""};function Wo({section:e,id:t,src:n,...r}){const i=`${t}-${r.locale}`,[{editing:s},c]=E(r,K),a=h.useRef({}),l=JSON.parse(JSON.stringify(c)),{message:d}=mt.useMessage(i,"server"),m=pt.useLatest(JSON.parse(JSON.stringify(c.config)||"{}"));return h.useEffect(()=>{d&&d.onInit(()=>m.current)},[d]),h.useEffect(()=>{const u=JSON.parse(JSON.stringify(c.config)||"{}");_t.default(a.current,u)||(a.current=u,d?.send("config-set",u))},[d,c.config]),n?o.jsx(Lo,{...l,dataId:i,src:n,style:s?{pointerEvents:"none"}:{}}):o.jsx(zo,{children:'Please set the "src" attribute for this block'})}const zo=B.styled("div")`
417
- user-select: none;
418
- color: #999;
419
- padding: 8px;
420
- height: 200px;
421
- `,ke={width:"1px",style:"solid",color:"divider"};function Te(e){return typeof e=="string"&&e.startsWith("custom:")}function Fo(e){if(!Te(e))return ke;try{const t=e?.substring(7)||"",[n="1px",r="solid",...i]=t.split(" ");return{width:n,style:r,color:i.join(" ")||"divider"}}catch{return ke}}function Uo(e){if(!e||e==="none")return{border:"none"};if(Te(e)){const{width:t,style:n,color:r}=Fo(e);return{border:"none",borderWidth:t,borderStyle:n,borderColor:r}}return{}}function We(e){return typeof e=="string"&&e.startsWith("custom:")}function Oo(e){if(!We(e))return"0";try{return e?.substring(7)||"0"}catch{return"0"}}function Do(e){return!e||e==="none"?{borderRadius:0}:We(e)?{borderRadius:Oo(e)}:{}}function qo({ref:e=void 0,type:t,sx:n,children:r,...i}){const s=[{},...Array.isArray(n)?n:[n]];return h.useCallback(()=>{const a=Ne(t);return a?(s.push({img:{objectFit:"contain !important",bgcolor:l=>l.palette.background.default,borderRadius:"0 !important",position:"relative"}}),o.jsx(re.default,{type:t,children:r})):o.jsx(p.Box,{component:a?re.default:"div",ref:e,sx:s,...i,...a?{type:t}:{},children:r})},[t,r,s])()}const Go="none",Ho="none",Vo="transparent",Jo="center",Yo="start",Ko="none",Xo="none",Qo=12,Zo=({gridSettings:e,section:t,index:n,columns:r,simulateMode:i="desktop",isBackground:s})=>{const c=e?.[i]??{},a=c[t.id],l=en(c);return{i:t.id,static:t?.locked||s,...s?{x:0,y:0,w:r,h:1,isResizable:!1}:{x:a?.x??0,y:a?.y??n,w:a?.w??r,h:a?.h??1,isResizable:!0},minH:1,maxH:1,maxY:l}},en=e=>Object.values(e).reduce((t,n)=>Math.max(t,n.y||0),0)||0,tn=e=>{const{dev:t,id:n,section:r,onBlockRender:i}=e,s=t?.mode,c=p.useMediaQuery(f=>f.breakpoints.down("sm")),{t:a}=ht.useLocaleContext(),{sections:l,sectionIds:d,config:m}=r,{columns:u=Qo,gridSettings:g,gap:x,padding:v,background:y,alignContent:w,justifyContent:j,border:_,borderRadius:R,ignoreMaxWidth:$}=m||{},ee=h.useMemo(()=>{const C=L({type:"layoutBlockGap",value:x??Go,format:"sx"}),T={...C,gap:Object.keys(C.gap).reduce((N,P)=>(N[P]=-C.gap[P],N),{})};return{item:C,container:T}},[x]),Fe=h.useMemo(()=>L({type:"layoutBlockPadding",value:v??Ho,format:"sx"}),[v]),te=h.useMemo(()=>L({type:"layoutBlockAlignContent",value:w??Jo,format:"sx"}),[w]),oe=h.useMemo(()=>L({type:"layoutBlockJustifyContent",value:j??Yo,format:"sx"}),[j]),Ue=h.useMemo(()=>{const f=_??Ko,C=Uo(f);return Object.keys(C).length>0?C:L({type:"layoutBlockBorder",value:f,format:"sx"})},[_]),Oe=h.useCallback(f=>Ne(_)?o.jsx(qo,{type:_,...f}):o.jsx(p.Box,{...f}),[_]),De=h.useMemo(()=>{const f=R??Xo,C=Do(f);return Object.keys(C).length>0?C:L({type:"layoutBlockBorderRadius",value:f,format:"sx"})},[R]),de=h.useCallback((f,C=!1,T=0)=>{if(!i||!f||!f.component||f.visibility==="hidden")return null;const N=Zo({gridSettings:g,section:f,index:T,columns:u,simulateMode:c?"mobile":"desktop",isBackground:C}),P=N?.x??0,F=N?.y??0,U=N?.w??u,qe=N?.h??1,Ge=N?.maxY??0,He=!!r?.config?.backgroundSectionId;return o.jsx(p.Box,{className:C?"layout-block-background":"layout-block-component",sx:{...C?{gridColumn:"1 / -1",gridRow:`1 / ${Ge+1}`,zIndex:0,width:"100%",height:"100%","& .BlockBase-root":{width:"100%",height:"100%"}}:{position:"relative",gridColumn:`${P+1} / span ${U}`,gridRow:`${F+(He?0:1)} / span ${qe}`,zIndex:1,minWidth:0,minHeight:0,...F>0?{mt:ee?.item?.gap}:{},...P>0?{ml:ee?.item?.gap}:{},"& > .BlockBase-root":{height:"100%",width:"100%",boxSizing:"border-box",position:"relative",...te,...oe}}},children:i({id:f.id,type:f.component,config:{},section:{...f},mode:s})},f.id)},[n,s,i,g,u,c,ee,te,oe,$]),{backgroundElements:ue,contentElements:me}=h.useMemo(()=>{if(!d||!d.length||!l||!Object.keys(l).length)return{backgroundElements:[],contentElements:[]};const f=[],C=[];return d?.forEach((T,N)=>{const P=l[T];if(!P)return;const F=r?.config?.backgroundSectionId===T,U=de(P,F,N);U&&(F?f.push(U):C.push(U))}),{backgroundElements:f,contentElements:C}},[de,l,d]);return s==="draft"&&!ue?.length&&!me?.length?o.jsxs(p.Box,{sx:{gridColumn:"1 / -1",gridRow:"1",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,border:f=>`2px dashed ${f.palette.divider}`,borderRadius:2,padding:4,color:"text.secondary",textAlign:"center",minHeight:"160px",position:"relative"},children:[o.jsx(p.Box,{sx:{fontSize:"48px",opacity:.5},children:"📐"}),o.jsx(p.Box,{sx:{fontSize:"16px",fontWeight:500,marginBottom:1},children:"Section Layout"}),o.jsx(p.Box,{sx:{opacity:.7,whiteSpace:"pre-line"},children:a("maker.layoutBlock.draftPlaceholder")}),o.jsx(p.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,pointerEvents:"none",opacity:.1,background:f=>`
422
- repeating-linear-gradient(
423
- 90deg,
424
- transparent,
425
- transparent calc(100% / ${u} - 1px),
426
- ${f.palette.grey[400]} calc(100% / ${u} - 1px),
427
- ${f.palette.grey[400]} calc(100% / ${u})
428
- )
429
- `}})]}):o.jsxs(Oe,{sx:{position:"relative",display:"grid",gridTemplateColumns:`repeat(${u}, minmax(0, 1fr))`,alignItems:"stretch",width:"100%",height:"100%",minWidth:0,bgcolor:y??Vo,boxSizing:"border-box",...Fe,...te,...oe},children:[r?.id&&o.jsx(p.GlobalStyles,{styles:f=>f.unstable_sx({[`#BlockBase-${r.id}`]:{...$&&{maxWidth:"unset !important",px:0},...Ue,...De,overflow:"hidden"}})}),ue,me]})},on=["title","description","actions","badge","tag","prepend","append","logo"];function nn({image:e,imageBorder:t,imageShadow:n,className:r,reverse:i=!1,fullSizeImage:s,...c}){const[a,l]=E(c,Q),d=Object.keys(a).length>0&&Object.values(le.default(a,on)).filter(Boolean).length>0&&o.jsx(X,{...a}),m=h.isValidElement(e)?e:o.jsx(p.Box,{component:"img",src:e,alt:"",className:"block"}),u=["phone","macbook"].includes(t),g=e&&o.jsx(p.Box,{className:b.cx("section__image","m-auto, leading-[1] text-center",n&&"shadow-xl",a?.center?"flex justify-center items-center":""),sx:{border:t===!0?"1px solid #c0c0c0":void 0,borderRadius:2,overflow:"hidden","> div":u?{width:"100%",video:{borderRadius:"0 !important"}}:void 0},children:u?o.jsx(re.default,{type:t,sx:{width:"100%"},children:m}):m});return o.jsx(Z,{className:b.cx("section--block",r,s&&!i&&b.css`
430
- .section-bg {
431
- height: 80%;
432
- }
433
- `),...l,boxProps:s?{sx:{padding:0,overflow:"hidden"}}:void 0,children:o.jsx(Le,{col:e?2:1,className:s?b.css`
434
- display: flex;
435
- flex-direction: column;
436
-
437
- > .base-info,
438
- > .section__image {
439
- width: 100%;
440
-
441
- > img,
442
- > video {
443
- width: 100%;
444
- }
445
- }
446
- `:void 0,children:i?o.jsxs(o.Fragment,{children:[g,d]}):o.jsxs(o.Fragment,{children:[d,g]})})})}const rn=[/youtu\.be\/([^#&?]{11})/,/\?v=([^#&?]{11})/,/&v=([^#&?]{11})/,/embed\/([^#&?]{11})/,/\/v\/([^#&?]{11})/];function sn(e){if(/youtu\.?be/.test(e))for(const t of rn){const n=t.exec(e)?.[1];if(n)return n}}function an(e){const t=sn(e);if(t)return`https://youtube.com/embed/${t}`}function ln({src:e}){return h.useEffect(()=>{import("@lottiefiles/lottie-player")},[]),o.jsx("lottie-player",{autoplay:!0,loop:!0,mode:"normal",src:e})}function cn(e){return o.jsx(p.Box,{sx:{maxHeight:400,overflow:"hidden auto"},children:o.jsx(bt.TwitterTimelineEmbed,{...e})})}function dn({url:e}){const t=h.useRef(null),n=495,[r,i]=h.useState(t.current?t.current.offsetWidth*.5625:n),s=h.useCallback(()=>{const c=window.innerWidth>990?1:window.innerWidth>522?1.2:window.innerWidth>400?1.45:1.85,a=t.current?t.current.offsetWidth*.5625:n;return i(Math.floor(a*c))},[]);return h.useEffect(()=>{window.addEventListener("resize",s);const c=window.innerWidth>990?1:window.innerWidth>522?1.2:window.innerWidth>400?1.45:1.85,a=t.current?t.current.offsetWidth*.5625:n;return i(Math.floor(a*c)),function(){window.removeEventListener("resize",s)}},[r,s]),o.jsx(p.Box,{component:"iframe",ref:t,title:"youtube",src:e,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,sx:{width:"100%",height:`${r}px`,display:"block"}})}const un={image:"https://www.arcblock.io/static/ead0cabde7f2b7ff34db8f3e8ceca271/afc4b/builder.png",badge:"Develop · Deploy · Run",title:"The Future is Here: Blockchain and Decentralized Application Development",description:"ArcBlock, your exclusive new decentralized development platform, makes developing decentralized applications, blockchain, and distributed ledger technology straightforward.",reverse:!1,dark:!1,background:"",actions:void 0,hasImage:!0,center:!1},mn=B.styled(nn)`
447
- .section__description {
448
- }
449
- `;function pn({hasImage:e,fullSizeImage:t,boxed:n,videoPoster:r,imageMeta:i,imageOptimization:s,imageSize:c,section:a,...l}){const[{editing:d},m]=E({...l,boxed:t?void 0:n},K);let u=xn(m.image,r,t,i,s,c);e||(u=null);let g=null;return m.actions&&(g=m.actions?.map?.((x,v)=>o.jsx(Ee,{...x,editing:d},v))),o.jsx(mn,{...m,style:d?{pointerEvents:"none"}:{},image:u,fullSizeImage:e&&t,actions:g})}function xn(e,t,n,r,i,s){if(e){if(e.endsWith(".json"))return o.jsx(ln,{src:e});if(e.indexOf("twitter.com")!==-1)return o.jsx(cn,{sourceType:"url",url:e});const c=an(e);if(c)return o.jsx(dn,{url:c});const{naturalWidth:a,naturalHeight:l,filename:d}=r||{};if(D(e))return o.jsx("video",{width:a&&`${a}px`,height:l&&`${l}px`,controls:!0,autoPlay:!0,muted:!0,style:{display:"block",objectFit:s||"contain",borderRadius:"8px",width:"100%",height:"100%"},poster:k.autoResizeImage(k.getImageAbsoluteUrl(t),n?1200:540,i),children:o.jsx("source",{src:k.getImageAbsoluteUrl(e),type:uo(e)})},e);const m=i==="quality"?1:.6;return o.jsx(ae.ResponsiveImage,{src:k.getImageAbsoluteUrl(e),sizesAttr:{sm:600*m,md:450*m,lg:540*m,...n&&{md:900*m,lg:1200*m}},width:a&&`${a}px`,height:l&&`${l}px`,alt:d??e,style:{objectFit:s||"contain",display:"block",width:"100%",height:"100%"},loading:"lazy"})}return null}const gn=["production","draft"];function hn({mode:e,version:t}={}){const n=t&&typeof t=="number"?{mode:e,version:t}:{mode:e};return k.api.get(`/api/${k.getProjectIdFromPathnameOrWindow()}/pages`,{params:n}).then(r=>r.data)}function fn({mode:e,routes:t}){return k.api.post(`/api/${k.getProjectIdFromPathnameOrWindow()}/pages/publish`,{mode:e,routes:t}).then(n=>n.data)}function bn({locale:e,sort:t,page:n,limit:r,mode:i}={}){return k.api.get(`/api/${k.getProjectIdFromPathnameOrWindow()}/pages/toc`,{params:{locale:e,sort:t,page:n,limit:r,mode:i}}).then(s=>s.data)}const yn={style:"list",sort:"-updatedAt"},je=20;function vn({style:e,sort:t,section:n,...r}){const[{editing:i,locale:s},c]=E(r,K),[a,l]=E(c,Q),[d,m]=h.useState(),u=h.useRef(!1),g=ge.useUpdate(),x=se.useNavigate(),v=h.useCallback(async()=>{if(!u.current){u.current=!0,g();try{const y=d?Math.floor(d.list.length/je)+1:1,{list:w,total:j}=await bn({locale:s,sort:t,page:y,limit:je});m(_=>({list:(_?.list??[]).concat(w),total:j}))}finally{u.current=!1,g()}}},[d,s,t,g]);return ge.useMount(()=>{v()}),o.jsxs(Z,{...l,sx:i?{pointerEvents:"none"}:{},children:[Object.keys(a).length>0&&o.jsx(X,{...a}),d?o.jsxs(o.Fragment,{children:[o.jsx(p.Grid,{container:!0,spacing:2,sx:{justifyContent:"center"},children:d?.list.map(y=>o.jsx(p.Grid,{size:{xs:12,sm:e==="card"?6:12,md:e==="card"?3:12},children:o.jsxs(wn,{elevation:0,className:b.cx(e==="card"&&"style-card"),onClick:i?void 0:()=>x(y.slug),children:[!!y.image&&o.jsx(p.CardMedia,{component:"img",alt:"",image:k.autoResizeImage(k.getImageAbsoluteUrl(y.image),540),loading:"lazy"}),o.jsxs(p.CardContent,{children:[o.jsx(p.Typography,{variant:"h6",component:"div",className:_e,children:y.title||y.id}),o.jsx(p.Typography,{variant:"body2",className:_e,children:y.description})]})]})},y.id))}),o.jsx(p.Box,{sx:{textAlign:"center",mt:2},children:d.total>d.list.length?o.jsx(q,{variant:"outlined",color:"secondary",onClick:v,loading:u.current,children:"More"}):o.jsx(q,{variant:"outlined",color:"secondary",disabled:!0,children:"No More"})})]}):o.jsx(p.Box,{sx:{p:2,textAlign:"center"},children:o.jsx(p.CircularProgress,{size:24})})]})}const _e=b.css`
450
- display: -webkit-box;
451
- -webkit-box-orient: vertical;
452
- -webkit-line-clamp: 2;
453
- overflow: hidden;
454
- text-overflow: ellipsis;
455
- `,wn=B.styled(p.Card)`
456
- border: 1px solid #e0e0e0;
457
- background-color: transparent;
458
- cursor: pointer;
459
- display: flex;
460
- color: inherit;
461
-
462
- > .MuiCardMedia-root {
463
- width: 30vw;
464
- max-height: 50vw;
465
- }
466
-
467
- &.style-card {
468
- display: block;
469
-
470
- > .MuiCardMedia-root {
471
- width: 100%;
472
- max-height: 50vw;
473
- }
474
- }
475
- `,kn={iframe:Wo,section:pn,"section-card-list":Eo,toc:vn,"custom-component":Po,"layout-block":tn};function ze({id:e,type:t,mode:n,config:r,section:i,ignorePageMetaStyle:s,page:c,...a}){const l=kn[t],{getPageMetaStyle:d}=Yt(),m=h.useMemo(()=>{const{height:x,...v}=r;return t==="layout-block"&&(v.onBlockRender=y=>{const w={...r?.dev,...y?.config?.dev},{defaultLocale:j}=w,_={...le.default(r,["locale","editing"]),...y?.config,dev:w},{locale:R}=_;let $=c?.dataSource?.[y?.id]?.[R];return yt.default($)&&($=c?.dataSource?.[y?.id]?.[j??"en"]),o.jsx(ze,{...y,config:{...y?.section?.properties,...$,..._},page:c,ignorePageMetaStyle:!0})}),v},[r,t]),u=h.useMemo(()=>{const x={};return t!=="custom-component"&&(x.height=r.height),x.sx=s?void 0:d("sx"),x.id=`BlockBase-${e}`,x},[r.height,s,t,d]),g=l&&o.jsx(l,{mode:n,...m,id:e,section:i});return g?o.jsx(Xt,{...a,...u,children:g}):o.jsx(jn,{type:t})}function jn({type:e}){return o.jsx(p.Box,{sx:{p:2},children:o.jsxs(p.Alert,{icon:o.jsx(et.ErrorOutline,{}),color:"error",children:["Unsupported Block `",e,"`"]})})}exports.BlockRenderer=ze;exports.IFrameBlockDefaultProps=To;exports.PageProvider=Kt;exports.Provider=Zt;exports.STATE_MODES=gn;exports.SectionBlockDefaultProps=un;exports.TocDefaultProps=yn;exports.getPages=hn;exports.publishPages=fn;
@@ -1 +0,0 @@
1
- "use strict";const f=require("./components-CacZMc0_.js"),F=require("@syncedstore/core"),Je=require("yjs"),He=require("@blocklet/pages-kit/utils/data-source"),Q=require("@blocklet/pages-kit/utils/route"),We=require("lodash"),Qe=require("@blocklet/sdk/lib/config"),I=require("fs"),g=require("path"),De=require("@blocklet/pages-kit/utils/common"),Xe=require("@blocklet/pages-kit/utils/page-model"),Ze=require("@blocklet/pages-kit/utils/property"),Ie=require("@blocklet/sdk/lib/component"),et=require("@reactivedata/reactive"),X=require("glob"),tt=require("lib0/decoding"),st=require("lib0/encoding"),at=require("lodash/cloneDeep"),nt=require("lodash/debounce"),ot=require("lodash/get"),rt=require("lodash/isEmpty"),it=require("lodash/set"),ct=require("lodash/union"),be=require("lru-cache"),lt=require("p-limit"),C=require("sequelize"),pt=require("stream/promises"),ut=require("tar"),z=require("ufo"),dt=require("wait-on"),G=require("y-protocols/awareness"),le=require("y-protocols/sync"),ft=require("yaml"),Te=require("./html-JOhPskS4.js");require("sqlite3");require("@blocklet/pages-kit/types/state");const $=t=>t&&t.__esModule?t:{default:t};function ae(t){if(t&&t.__esModule)return t;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(e,s,a.get?a:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const U=ae(Je),w=$(Qe),pe=ae(tt),k=ae(st),gt=$(at),Le=$(nt),Ee=$(ot),we=$(rt),ve=$(it),mt=$(ct),ht=$(lt),yt=$(dt),x=ae(ft),St=C.DataTypes.sqlite.DATE.parse;C.DataTypes.sqlite.DATE.parse=(t,e)=>typeof t=="number"?new Date(t):St(t,e);const M=new C.Sequelize({dialect:"sqlite",storage:f.databaseUrl,benchmark:process.env.ENABLE_SEQUELIZE_BENCHMARK==="true",retry:{match:[/SQLITE_BUSY/],name:"query",max:10},logging:process.env.ENABLE_SEQUELIZE_LOGGING==="true"?console.log:!1});M.query("pragma journal_mode = WAL;");M.query("pragma synchronous = normal;");M.query("pragma journal_size_limit = 33554432;");M.query("pragma cache_size = -2000;");M.query("pragma mmap_size = 33554432;");process.on("SIGINT",async()=>{await M.close(),process.exit(0)});process.on("SIGTERM",async()=>{await M.close(),process.exit(0)});async function It(t,e){try{if(t.getDialect()!=="sqlite")return;const[s]=await t.query("SELECT 1");if(!s||s.length===0)return;await t.query("PRAGMA shrink_memory;")}catch(s){if(s.name==="SequelizeConnectionError"||s?.message&&/closed!/.test(s.message))return;console.error("Failed to cleanup SQLite memory",e,s)}}let fe=null;fe&&clearInterval(fe);fe=setInterval(async()=>{f.logger.info("Start cleanupSqliteMemory"),await It(M,f.databaseUrl),f.logger.info("End cleanupSqliteMemory")},60*1e3*10);class Ae extends C.Model{}Ae.init({id:{type:C.DataTypes.UUID,allowNull:!1,primaryKey:!0,defaultValue:C.DataTypes.UUIDV4},projectId:{type:C.DataTypes.UUID,allowNull:!1},componentId:{type:C.DataTypes.STRING,allowNull:!1}},{sequelize:M,tableName:"ProjectComponents",timestamps:!1});class L extends C.Model{static async getProjectByIdOrSlug(e){return L.findOne({where:{[C.Op.or]:[{id:e},{slug:e}]}})}}L.init({id:{type:C.DataTypes.UUID,defaultValue:C.DataTypes.UUIDV4,primaryKey:!0},name:{type:C.DataTypes.STRING,allowNull:!1},description:C.DataTypes.TEXT,createdAt:C.DataTypes.DATE,updatedAt:C.DataTypes.DATE,createdBy:{type:C.DataTypes.STRING,allowNull:!1},updatedBy:{type:C.DataTypes.STRING,allowNull:!1},slug:C.DataTypes.STRING,icon:C.DataTypes.STRING,pinnedAt:C.DataTypes.DATE,useAllResources:C.DataTypes.BOOLEAN,npmSecret:C.DataTypes.STRING,relatedBlocklets:{type:C.DataTypes.JSON,allowNull:!1,defaultValue:{},get(){const t=this.getDataValue("relatedBlocklets");if(typeof t=="object")return t??{};try{return t?JSON.parse(t):{}}catch(e){return f.logger.error("Failed to parse relatedBlocklets",{error:e,rawValue:t}),{}}},set(t){try{this.setDataValue("relatedBlocklets",t?JSON.stringify(t):"{}")}catch(e){f.logger.error("Failed to set relatedBlocklets",{error:e,value:t}),this.setDataValue("relatedBlocklets","{}")}}},productionState:{type:C.DataTypes.JSON,allowNull:!1,defaultValue:{},get(){const t=this.getDataValue("productionState");if(typeof t=="object")return t??{};try{return t?JSON.parse(t):{}}catch(e){return f.logger.error("Failed to parse productionState",{error:e,rawValue:t}),{}}},set(t){try{this.setDataValue("productionState",t?JSON.stringify(t):"{}")}catch(e){f.logger.error("Failed to set productionState",{error:e,value:t}),this.setDataValue("productionState","{}")}}}},{sequelize:M,paranoid:!0});L.hasMany(Ae,{foreignKey:"projectId",as:"components"});const bt="z8iZiDFg3vkkrPwsiba1TLXy3H9XHzFERsP8o",ge="page",me="trigger-reload-project-resource",Pe=bt,Et="z2qa7BQdkEb3TwYyEYC1psK6uvmGnHSUHt5RM";function Z(t){t.observeDeep(e=>{e.some(s=>s.changes.keys.has("updatedAt")||s.changes.keys.has("publishedAt"))||t.set("updatedAt",new Date().toISOString())})}function _e(){return I.mkdtempSync(g.join(w.default.env.dataDir,"tmp-"))}function ee(t,e,s=[]){return Array.isArray(t)?t.flatMap((a,n)=>ee(a,e,[...s,n])):typeof t=="object"?t===null?[]:Object.entries(t).flatMap(([a,n])=>ee(n,e,[...s,a])):e(t)?[s]:[]}function R(t){return t.filter(e=>e!=null)}function wt(t){t.pages&&Object.keys(t.pages).forEach(s=>{const a=F.getYjsValue(t.pages[s]);a&&a instanceof U.Map&&Z(a)});const e=F.getYjsValue(t.pages);e&&e instanceof U.Map&&e.observe(s=>{s.changes.keys.forEach((a,n)=>{if(a.action==="add"){const o=F.getYjsValue(t.pages[n]);o&&o instanceof U.Map&&Z(o)}})})}function At(t){t.routes&&Object.keys(t.routes).forEach(s=>{const a=F.getYjsValue(t.routes?.[s]);a&&a instanceof U.Map&&Z(a)});const e=F.getYjsValue(t.routes);e&&e instanceof U.Map&&e.observe(s=>{s.changes.keys.forEach((a,n)=>{if(a.action==="add"){const o=F.getYjsValue(t.routes?.[n]);o&&o instanceof U.Map&&Z(o)}})})}function Pt(t,e){for(const s of e||Object.keys(t.routes||{})){let a=s,n=[];if(s.includes("-")){const[o,...c]=s.split("-");a=o,n=c||[]}if(t.routes?.[a]!==void 0){t.routes[a].publishedAt=new Date().toISOString();const o=t.routes[a];if(!o||!o.params||o.params.length===0)continue;if(s.includes("-")&&n.length>0){const c=Q.getRouteMetaDataByOptionIds(n,o);c&&(c.publishedAt=new Date().toISOString())}if(!e){const c=Q.generateParamCombinations({basePath:o.path,params:o.params,routeId:o.id,paramsOptions:o.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]});for(const p of c)p.routeMetaData??={},p.routeMetaData.publishedAt=new Date().toISOString()}}}}function ue({page:t,route:e,state:s,routeId:a,routePathInfo:n}){f.logger.info(`Executing datasource data assembly, routeId: ${a}, routePathInfo: ${JSON.stringify(n)}`);const o={...We.cloneDeep(t),id:a,slug:n?.path??e.path,createdAt:e.createdAt,updatedAt:n?.routeMetaData?.updatedAt??e.updatedAt,publishedAt:n?.routeMetaData?.publishedAt??e.publishedAt,isPublic:(n?.routeMetaData?.isPublic??e.isPublic)&&e.isPublic};for(const c of s.supportedLocales){if(e.dataSource){let p=e.id;n&&(p=n.paramOptionIds.join("-"));const l=e.dataSource.pathDataMappings?.[p]?.dataCache?.[c.locale]??e.dataSource.pathDataMappings?.[p]?.dataCache?.[s.config.defaultLocale||"en"];if(!l)continue;He.setPageDataSource(o,s,c.locale,l)}n&&n.routeMetaData&&(n.routeMetaData.publishedAt=new Date().toISOString())}return o}const jt=30*60*1e3,Y=new be.LRUCache({max:100,ttl:jt});function Ot(t,e=[]){let s=0;const a=Array.from(Y.keys());for(const n of a)for(const o of t){if(Te.matchCacheKey(n,{currentPath:o})){Y.delete(n),s++,f.logger.info(`[Cache CLEAR] key: ${n}`);break}for(const c of e)if(Te.matchCacheKey(n,{currentPath:`/${c}${o}`})){Y.delete(n),s++,f.logger.info(`[Cache CLEAR] key: ${n}`);break}}return f.logger.info(`[Cache CLEAR] cleared ${s} entries for paths:`,t),s}function Ct(){const t=Y.size;return Y.clear(),f.logger.info(`[Cache CLEAR ALL] cleared ${t} entries`),t}w.default.events.on(w.default.Events.envUpdate,Ct);const{uploadToMediaKit:Dt}=require("@blocklet/uploader-server"),je=/^\w+(\w|-|\.)+\w+\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm)$/,K=/mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/i,ke=/mediakit:\/\/([a-f0-9]{32}\.(jpe?g|png|gif|svg|bmp|webp|mp4|m4v|webm))/gi,Tt=1e4,vt=3e4,H=0,de=1,kt=0,Rt=1,he=w.default,q=g.join(process.env.BLOCKLET_DATA_DIR,"site-state"),Lt=["production","draft"],_t=["production"];function te(t){return t?.replace(/\//g,"|")||""}function Ue(){const t=he.env.languages?.map(s=>({locale:s.code,name:s.name}))||[],e=t[0]?.locale||"en";return{pageIds:[],pages:{},routeIds:[],routes:{},dataSourceIds:[],dataSources:{},components:{},supportedLocales:t,config:{defaultLocale:e},resources:{}}}class O extends U.Doc{constructor(e){super(),this.options=e,I.existsSync(this.draftYjsFilePath)&&U.applyUpdate(this,I.readFileSync(this.draftYjsFilePath)),this.syncedStore=et.reactive(F.syncedStore({pages:{},pageIds:[],components:{},supportedLocales:[],config:{},resources:{},routeIds:[],routes:{},dataSourceIds:[],dataSources:{}},this)),this.initObserver(),this.on("update",this.updateHandler),this.awareness=new G.Awareness(this),this.awareness.on("update",this.awarenessChangeHandler),this.ensureDataStructure()}static RELEASE_DELAY=5*60*1e3;static PERIODIC_CHECK_INTERVAL=2*60*60*1e3;static sharedInstances={};static pageUrlMapCache=new be.LRUCache({max:100,ttl:1e3*60*60*24});static periodicCheckTimer;static safeDeleteProjectStateDir(e){if(!e)throw new Error("Should provide project context");try{const s=g.join(q,e),a=g.join(q,`@del-${e}`);I.renameSync(s,a)}catch(s){f.logger.error("Failed to safe delete project state dir:",s)}}static async getProjectIds(){return(await L.findAll({attributes:["id"],raw:!0}))?.map(e=>e.id)}static get projectIds(){return X.globSync("*/",{cwd:q,ignore:["@del-*","@tmp-*",".*","staging","production","@backup-*","undefined"]})}static get allShared(){return this.projectIds.map(e=>O.shared(e))}static shared(e){if(!e)throw new Error("Should provide project context");let s=O.sharedInstances[e];return s||(s=new O({path:g.join(q,e)}),O.sharedInstances[e]=s,s)}static async getProductionState(e){const s=await L.findByPk(e,{attributes:["productionState"]});if(we.default(s?.productionState)){const a=g.join(q,e,"production"),n=await Oe(a,{includeResources:!0})??Ue();if(!n?.config?.defaultLocale){n.config??={};const o=he.env.languages?.map(c=>({locale:c.code,name:c.name}))||[];n.config.defaultLocale=o[0]?.locale}return n}return s?.productionState}destroy(){this.cancelRelease(),this.save({flush:!0}),this.conns.forEach((s,a)=>this.closeConn(a)),this.awareness.destroy();const e=g.basename(this.options.path);delete O.sharedInstances[e],super.destroy()}initObserver(){wt(this.syncedStore),At(this.syncedStore)}get draftYjsFilePath(){return g.join(this.options.path,"draft.yjs")}static async getStateByProjectId(e,s){if(s==="draft"){const a=O.shared(e);return JSON.parse(JSON.stringify(a.syncedStore))}return O.getProductionState(e)}async getState(e){if(e==="draft")return JSON.parse(JSON.stringify(this.syncedStore));const s=g.basename(this.options.path);return O.getProductionState(s)}async setState(e,s){const a=await Fe(s,{exportAssets:!1,includeResources:!0}),n=this.getPublishDir(e);if(I.mkdirSync(g.dirname(n),{recursive:!0}),I.rmSync(n,{force:!0,recursive:!0}),I.renameSync(a,n),e==="production"){const o=g.basename(this.options.path);O.pageUrlMapCache.delete(o),await L.update({productionState:{...s}},{where:{id:o}})}}getPublishDir(e){return g.join(this.options.path,e)}syncedStore;conns=new Map;awareness;releaseTimer;awarenessChangeHandler=({added:e,updated:s,removed:a},n)=>{const o=e.concat(s,a);if(n!==null){const l=this.conns.get(n);l&&(e.forEach(S=>{l.add(S)}),a.forEach(S=>{l.delete(S)}))}const c=k.createEncoder();k.writeVarUint(c,de),k.writeVarUint8Array(c,G.encodeAwarenessUpdate(this.awareness,o));const p=k.toUint8Array(c);this.conns.forEach((l,S)=>this.send(S,p))};updateHandler=e=>{const s=k.createEncoder();k.writeVarUint(s,H),le.writeUpdate(s,e);const a=k.toUint8Array(s);this.conns.forEach((n,o)=>this.send(o,a))};ensureDataStructure=()=>{const{supportedLocales:e,pages:s,pageIds:a,config:n,routes:o,routeIds:c}=this.syncedStore;{const p=new Set(Object.keys(s));let l=0;for(;l<a.length;){const S=a[l];p.has(S)?(p.delete(S),l++):a.splice(l,1)}}{const p=new Set(Object.keys(o));let l=0;for(;l<c.length;){const S=c[l];p.has(S)?(p.delete(S),l++):c.splice(l,1)}}e.splice(0,e.length),e.push(...he.env.languages.map(p=>({locale:p.code,name:p.name}))),n.defaultLocale=e[0]?.locale;{let p=0;const l=new Set;for(;p<e.length;){const{locale:S}=e[p];l.has(S)?e.splice(p,1):(p++,l.add(S))}}};send=(e,s)=>{e.readyState!==kt&&e.readyState!==Rt&&this.closeConn(e);try{e.send(s,a=>{a&&this.closeConn(e)})}catch{this.closeConn(e)}};closeConn=e=>{if(e.removeAllListeners(),this.conns.has(e)){const s=this.conns.get(e);this.conns.delete(e),s&&G.removeAwarenessStates(this.awareness,Array.from(s),null)}e.close(),this.checkAndScheduleRelease()};checkAndScheduleRelease(){this.conns.size===0&&this.scheduleRelease()}scheduleRelease(){this.cancelRelease();const e=g.basename(this.options.path);this.releaseTimer=setTimeout(()=>{f.logger.info(`[SiteState] releasing instance due to no active connections: ${e}`),this.conns.size===0&&(this.releaseTimer=void 0,this.destroy())},O.RELEASE_DELAY),f.logger.info(`[SiteState] scheduled release for project ${e} in ${O.RELEASE_DELAY/1e3}s`)}cancelRelease(){if(this.releaseTimer){clearTimeout(this.releaseTimer),this.releaseTimer=void 0;const e=g.basename(this.options.path);f.logger.info(`[SiteState] cancelled scheduled release for project ${e}`)}}autoSave=Le.default(()=>{I.mkdirSync(g.dirname(this.draftYjsFilePath),{recursive:!0}),I.writeFileSync(this.draftYjsFilePath,U.encodeStateAsUpdate(this))},Tt);save=({flush:e=!1}={})=>{this.autoSave(),e&&this.autoSave.flush()};publish=async({mode:e,routes:s})=>{const a=await this.getState("draft"),n=await this.getState("production");await Se(a,n,{routes:s,mergeMode:"replace",deleteRoutes:!0,publishMode:e}),n.config.publishedAt=new Date().getTime(),Pt(this.syncedStore,s),await this.setState(e,n),await this.clearPageCacheForRoutes(s,n)};mergeState=async(e,s)=>{const a=JSON.parse(JSON.stringify(s));e.config.fontFamily??={};const n=a.config?.fontFamily,o=e.config?.fontFamily;e.config.fontFamily.title=n?.title||o?.title,e.config.fontFamily.description=n?.description||o?.description,await new Promise((c,p)=>{this.transact(async()=>{try{const l=await Se(e,s);c(l)}catch(l){p(l)}})})};clearPageCacheForRoutes=async(e,s)=>{const a=g.basename(this.options.path),o=(await L.findByPk(a))?.slug||a;let c=e;(!c||c.length===0)&&(c=s.pageIds??[]),f.logger.info(`[SiteState] clearing page cache for project ${a}, routes:`,c||[]);const p=s.supportedLocales.map(A=>A.locale),l=[],S=c.filter(A=>s.pageIds?.includes(A));for(const A of S){const E=s.pages[A].slug;o&&o!==a&&(o==="/"?l.push(E):l.push(`/${o}${E}`)),l.push(`/${a}${E}`)}if(f.logger.info(`[SiteState] clearing page cache for project ${a}, pathPatterns:`,l),l.length>0)try{const A=Ot(l,p);f.logger.info(`[SiteState] cleared ${A} page cache entries for project ${a}, routes:`,c)}catch{}};addConnection=e=>{if(this.conns.has(e))return;this.cancelRelease(),e.binaryType="arraybuffer",this.conns.set(e,new Set),e.on("message",n=>this.messageListener(e,new Uint8Array(n)));let s=!0;const a=setInterval(()=>{if(!s)this.conns.has(e)&&this.closeConn(e),clearInterval(a);else if(this.conns.has(e)){s=!1;try{e.ping()}catch{this.closeConn(e),clearInterval(a)}}},vt);e.on("close",()=>{this.closeConn(e),clearInterval(a)}),e.on("pong",()=>{s=!0});{const n=k.createEncoder();k.writeVarUint(n,H),le.writeSyncStep1(n,this),this.send(e,k.toUint8Array(n));const o=this.awareness.getStates();if(o.size>0){const c=k.createEncoder();k.writeVarUint(c,de),k.writeVarUint8Array(c,G.encodeAwarenessUpdate(this.awareness,Array.from(o.keys()))),this.send(e,k.toUint8Array(c))}}};messageListener=(e,s)=>{try{const a=k.createEncoder(),n=pe.createDecoder(s),o=pe.readVarUint(n);switch(o){case H:k.writeVarUint(a,H),le.readSyncMessage(n,a,this,null),k.length(a)>1&&(this.ensureDataStructure(),this.send(e,k.toUint8Array(a)));break;case de:{G.applyAwarenessUpdate(this.awareness,pe.readVarUint8Array(n),e);break}default:f.logger.warn(`Unsupported messageType ${o}`)}}catch(a){f.logger.error(a)}this.save()};static async pageUrlMap(e,s){let a=[];s?a=[s]:a=await this.getProjectIds();let n={};if(e==="production"&&a?.length){const o=new Map(a?.map(c=>[c,!0])||[]);for(const c of a){const p=O.pageUrlMapCache.get(c);p&&(n={...n,...p},o.delete(c))}a=Array.from(o.keys())}if(a?.length){const o=await L.findAll({where:{id:{[C.Op.in]:a}}});await Promise.all(o?.map(async c=>{const p=c.id,l=c.slug||p,S={},A=e==="production"&&c?.productionState?c.productionState:await O.getStateByProjectId(c.id,e),v=mt.default(w.default.env.languages?.map(u=>u.code)||[],A.supportedLocales?.map(u=>u.locale)||[]),E=(u,i)=>{l&&(S[z.joinURL("/",l,u)]={...i,shouldRedirect:!0,mainPage:!0}),S[z.joinURL("/",p,u)]={...i,shouldRedirect:!0,mainPage:!0};for(const h of v){const D={...i,locale:h};S[z.joinURL("/",h,p,u)]=D,l&&(S[z.joinURL("/",h,l,u)]=D)}};if(e==="draft")for(const u of A.routeIds||[]){const i=A?.routes?.[u];if(!i)continue;if(i.params&&i.params.length>0){const m=Q.generateParamCombinations({basePath:i.path,params:i.params,routeId:i.id,paramsOptions:i.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]});for(const d of m){const y=d.path,P={projectId:p,projectSlug:l,pageSlug:y,pageId:i.displayTemplateId||"",routeId:u,defaultLocale:v?.[0],locales:v,publishedAt:A.config.publishedAt,isPublic:i.isPublic&&d?.routeMetaData?.isPublic};E(y,P)}}const h=i.path,D={projectId:p,projectSlug:l,pageSlug:h,pageId:i.displayTemplateId||"",routeId:u,defaultLocale:v?.[0],locales:v,publishedAt:A.config.publishedAt,isPublic:i.isPublic};E(h,D)}for(const u of A.pageIds){const i=A.pages[u];if(!i||e==="production"&&!i.isPublic)continue;const h=i.slug,D=c.slug||p,m={projectId:p,projectSlug:D,pageSlug:h,pageId:u,defaultLocale:v?.[0],locales:v,publishedAt:A.config.publishedAt,isPublic:i.isPublic,templateConfig:i.templateConfig};E(h,m)}e==="production"&&O.pageUrlMapCache.set(p,S),n={...n,...S}}))}return n}getDocumentSize(){return U.encodeStateAsUpdate(this).byteLength}static getInstancesSizeInfo(){const e=[];for(const[s,a]of Object.entries(O.sharedInstances)){const n=a.getDocumentSize();e.push({projectId:s,sizeInBytes:n,sizeInMB:`${(n/(1024*1024)).toFixed(2)} MB`,activeConnections:a.conns.size})}return e}static startPeriodicCheck(){this.periodicCheckTimer||(this.periodicCheckTimer=setInterval(()=>{this.performPeriodicCheck()},this.PERIODIC_CHECK_INTERVAL),f.logger.info(`[SiteState] periodic check started, interval: ${this.PERIODIC_CHECK_INTERVAL/(60*60*1e3)} hours`))}static stopPeriodicCheck(){this.periodicCheckTimer&&(clearInterval(this.periodicCheckTimer),this.periodicCheckTimer=void 0,f.logger.info("[SiteState] periodic check stopped"))}static performPeriodicCheck(){const e=Object.keys(O.sharedInstances).length,s=[],a=[];for(const[n,o]of Object.entries(O.sharedInstances))o.conns.size===0?s.push({projectId:n,instance:o}):a.push({projectId:n,connections:o.conns.size});if(f.logger.info(`[SiteState] periodic check summary: total instances: ${e}, with connections: ${a.length}, without connections: ${s.length}`),s.length>0){f.logger.info(`[SiteState] releasing ${s.length} instances without connections:`,s.map(o=>o.projectId));let n=0;for(const{projectId:o,instance:c}of s)try{f.logger.info(`[SiteState] releasing instance due to periodic check: ${o}`),c.destroy(),n++}catch(p){f.logger.error(`[SiteState] failed to release instance ${o} during periodic check:`,p)}f.logger.info(`[SiteState] periodic check completed: ${n}/${s.length} instances released successfully`)}else e>0?f.logger.debug("[SiteState] periodic check: all instances have active connections"):f.logger.debug("[SiteState] periodic check: no instances exist")}}async function Ut(t,e,s){if(!t||!I.existsSync(t)||!I.lstatSync(t).isFile())return null;let a=s[t];return a||(a=(async()=>{try{return(await Dt({filePath:t,fileName:e}))?.data?.filename}catch(n){return f.logger.error(`Failed to upload asset ${t}:`,n),null}})(),s[t]=a),a}const Me=async(t,e)=>{const s=g.basename(t),a=await Ie.call({name:Pe,path:z.joinURL("/uploads",s),responseType:"stream",method:"GET"});if(a.status>=200&&a.status<400){const n=I.createWriteStream(e);await pt.pipeline(a.data,n)}else throw new Error(`download asset failed ${a.status}`)},$e=async(t,e)=>{await Promise.all(t.map(async s=>{try{await Me(s,g.join(e,g.basename(s)))}catch(a){f.logger.error(`Failed to export assets: ${s}, ${a}`)}}))};function Ne(t){return je.test(t)?[t]:K.test(t)?(ke.lastIndex=0,Array.from(t.matchAll(ke)).map(s=>s[1]).filter(s=>!!s)):[]}async function W(t,e,s){const{getFilename:a,exportAssets:n}=s,o=g.join(e,a(t));if(I.mkdirSync(g.dirname(o),{recursive:!0}),I.writeFileSync(o,x.stringify(t)),n){const p=ee(t,l=>typeof l=="string"&&(je.test(l)||K.test(l))).map(l=>{const S=Ee.default(t,l);return Ne(S)}).flat().filter(Boolean);await $e(p,g.dirname(o))}}const ye=new be.LRUCache({max:100,ttl:1*60*1e3});async function Re(t,e,s){const a=ee(t,p=>typeof p=="string"&&(je.test(p)||K.test(p))),n=ht.default(2),o=a.map(p=>n(async()=>{try{const l=Ee.default(t,p),S=Ne(l);for(const A of S){const v=g.basename(A),E=s.getFilePath(A,p),u=E?`${E}:${v}`:v,i=ye.get(u);if(i){K.test(l)||ve.default(t,p,i);return}const h=await Ut(E,v,e);h&&(K.test(l)||ve.default(t,p,h),ye.set(u,h))}}catch(l){f.logger.error(`Failed to process upload for path ${p.join(".")}:`,l.message||l.reason)}})),c=await Promise.allSettled(o);s.onFinish?.(c)}async function Fe(t,{exportAssets:e,pageIds:s="all",componentIds:a="all",rawConfig:n,includeResources:o=!1,routeIds:c="all"}={}){const p=s==="all"?t.pageIds:s,l=Ze.getComponentDependencies({state:t,pageIds:p,componentIds:a==="all"?Object.keys(t.components):a}),S=c==="all"?t.routeIds:c,A=r=>({id:r.id,name:r.name,isTemplateSection:r.isTemplateSection??!1,templateDescription:r.templateDescription,llmConfig:r.llmConfig,component:r.component,config:r.config,visibility:r.visibility,sections:r?.sectionIds?R(r?.sectionIds?.map(b=>{const T=r.sections?.[b];return T&&A(T)})):void 0}),v=(r,b)=>({id:r.id,createdAt:r.createdAt,updatedAt:r.updatedAt,publishedAt:r.publishedAt,isPublic:r.isPublic??!0,templateConfig:r.templateConfig,meta:r.locales?.[b]??{},sections:R(r.sectionIds.map(T=>{const N=r.sections[T];return N&&A(N)})),dataSource:Object.fromEntries(Object.entries(r.dataSource||{}).map(([T,N])=>[T,N?.[b]??{}]))}),E=r=>({id:r.id,createdAt:r.createdAt,updatedAt:r.updatedAt,publishedAt:r.publishedAt,path:r.path,handler:r.handler,isPublic:r.isPublic??!0,params:r.params??[],enabledGenerate:r.enabledGenerate??!1,displayTemplateId:r.displayTemplateId,dataSource:r.dataSource}),u=R(S.map(r=>{const b=t.routes[r];return b&&E(b)})),i=R(t.supportedLocales.map(r=>r.locale).flatMap(r=>p.map(b=>{const T=t.pages[b];return T&&{locale:r,slug:T.slug,page:v(T,r)}}))),h=_e(),D=g.join(h,"pages");I.mkdirSync(D,{recursive:!0});const m=g.join(h,"components");I.mkdirSync(m,{recursive:!0});const d=g.join(h,"routes");I.mkdirSync(d,{recursive:!0});for(const{locale:r,slug:b,page:T}of i)await W(T,D,{getFilename:()=>`${te(b)||"index"}.${r}.yml`,exportAssets:e});for(const r of u)await W(r,d,{getFilename:()=>`${te(r.path)||"index"}.yml`,exportAssets:e});for(const r of l){const b=t.components[r]?.data;b&&await W(b,m,{getFilename:T=>`${T.name||"unnamed"}.${T.id}.yml`,exportAssets:e})}const y=g.join(h,".blocklet/pages/pages.config.yml");I.mkdirSync(g.dirname(y),{recursive:!0});const P={pages:R(p.map(r=>{const b=t.pages[r];return b&&{id:r,slug:b.slug}})),routes:R(S.map(r=>{const b=t.routes[r];return b&&{id:r,path:b.path}})),components:R(l.map(r=>{const b=t.components[r]?.data;return b&&{id:r,name:b.name}})),...o?{resources:{components:R(Object.keys(t.resources?.components||{}).filter(r=>l.includes(r)).map(r=>({id:r,name:t.resources?.components?.[r]?.component?.name})))}}:{},supportedLocales:t.supportedLocales,config:t.config};I.writeFileSync(y,x.stringify(P));const j=g.join(h,"config.source.json");if(n&&I.writeFileSync(j,JSON.stringify(n)),o){const r=g.join(h,"resources"),b=g.join(r,"components");I.mkdirSync(b,{recursive:!0});for(const B of Object.keys(t?.resources?.components??{}).filter(_=>l.includes(_))){const _=t.resources?.components?.[B]?.component;_&&await W(_,b,{getFilename:V=>`${V.name||"unnamed"}.${V.id}.yml`,exportAssets:e})}const T=g.join(h,"chunks");I.mkdirSync(T,{recursive:!0});const N=Mt();for(const B of Object.keys(t?.resources?.components??{}).filter(_=>l.includes(_))){const _=t.resources?.components?.[B]?.component;if(_&&_.renderer?.type==="react-component"){const V=_.renderer?.chunks??[];if(V?.length>0)for(const ie of V){const Ce=g.join(T,ie),ce=N?.[ie];try{ce&&I.existsSync(ce)&&!I.existsSync(Ce)&&I.copyFileSync(ce,Ce)}catch(Ke){f.logger.error(`copy chunk ${ie} error`,Ke.message)}}}}}return h}async function Oe(t,{importAssets:e,includeResources:s}={}){if(!I.existsSync(t))return null;let a,n=!1;try{I.lstatSync(t).isDirectory()?a=t:/\.(tgz|gz|tar)$/.test(t)&&(n=!0,a=_e(),await ut.x({file:t,C:a}));const o=X.globSync("**/.blocklet/pages/pages.config.yml",{cwd:a,absolute:!0}).at(0),c=o&&g.join(g.dirname(o),"../../pages"),p=o&&g.join(g.dirname(o),"../../components"),l=o&&g.join(g.dirname(o),"../../routes");if(!o)return null;const S=x.parse(I.readFileSync(o).toString()),A=(m,d,y)=>{let P=g.join(m,`${d}${y?`.${y}`:""}.yml`);return(!I.existsSync(P)||!I.lstatSync(P).isFile())&&(P=g.join(m,d,`index${y?`.${y}`:""}.yml`),!I.existsSync(P)||!I.lstatSync(P))?null:x.parse(I.readFileSync(P).toString())},v=(m,d)=>{try{const y=X.globSync(`*.${d}.yml`,{cwd:m,absolute:!0})[0];return y?x.parse(I.readFileSync(y).toString()):null}catch(y){f.logger.error("parse component error",y)}return null},E=(m,d)=>{let y=g.join(m,`${d}.yml`);return(!I.existsSync(y)||!I.lstatSync(y).isFile())&&(y=g.join(m,d,"index.yml"),!I.existsSync(y)||!I.lstatSync(y))?null:x.parse(I.readFileSync(y).toString())},u=R(S.pages.map(({slug:m})=>{const d=R(S.supportedLocales.map(({locale:j})=>{const r=c?A(c,te(m),j):void 0;if(r)return{locale:j,page:r};const b=c?A(c,m,j):void 0;return b&&{locale:j,page:b}})),y=d[0]?.page;if(!y)return null;const P=y.sections.map(Xe.unzipSection);return{id:y.id||De.nextId(),createdAt:y.createdAt,updatedAt:y.updatedAt,publishedAt:y.publishedAt,isPublic:y.isPublic??!0,templateConfig:y.templateConfig,slug:m,sections:Object.fromEntries(P.map(j=>[j.id,j])),sectionIds:P.map(j=>j.id),locales:Object.fromEntries(d.map(({locale:j,page:r})=>[j,r.meta])),dataSource:y.dataSource?Object.fromEntries([...new Set(d.flatMap(({page:j})=>Object.keys(j.dataSource??{})))].map(j=>[j,Object.fromEntries(d.map(({locale:r,page:b})=>{const T=b.dataSource?.[j];return[r,T||{}]}))])):Object.fromEntries([...new Set(d.flatMap(({page:j})=>j.sections.map(r=>r.id)))].map(j=>[j,Object.fromEntries(d.map(({locale:r,page:b})=>{const T=b.dataSource?.[j];if(T)return[r,T];const N=b.sections.find(B=>B.id===j);return[r,N?.properties||{}]}))]))}})),i=R(S?.routes?.map(({path:m})=>{const d=l?E(l,te(m)):void 0;return{...d,id:d?.id||De.nextId(),createdAt:d?.createdAt??new Date().toISOString(),updatedAt:d?.updatedAt??new Date().toISOString(),publishedAt:new Date(0).toISOString(),path:d?.path??`/${d?.id}`,params:d?.params,handler:d?.handler??"Pages Kit",isPublic:d?.isPublic??!0,enabledGenerate:d?.enabledGenerate??!1,displayTemplateId:d?.displayTemplateId??void 0,dataSource:d?.dataSource??{}}})??[]),h=p?R(S.components?.map(({id:m})=>v(p,m))??[]):[];if(e){const m=(...d)=>{f.logger.info(`[${n?g.basename(t):g.basename(g.join(t,"../../../../"))}] importAssets:`,...d)};try{m("wait image-bin api ready"),await yt.default({resources:[`${Ie.getComponentWebEndpoint(f.IMAGE_BIN_NAME)}/api/sdk/uploads`],validateStatus:P=>P>=200&&P<=500}),m("image-bin api is ready");const d={},y={};m("start to upload assets"),await Promise.allSettled([Re(h,d,{getFilePath:P=>p&&g.join(p,P),onFinish:P=>{m(`upload ${P.length} component assets`)}}),Re(u,y,{getFilePath:(P,j)=>{const r=Ee.default(u,j.slice(0,1));return c&&g.join(c,g.dirname(r.slug),P)},onFinish:P=>{m(`upload ${P.length} page assets`)}})]),m("upload assets done"),ye.clear(),global.gc&&global.gc()}catch(d){m("Error during asset import:",d)}}const D={};if(s){const m=o&&g.join(g.dirname(o),"../../resources/components"),d=R(S.resources?.components?.map(({id:y})=>v(m,y))??[]);d.length>0&&(D.components=Object.fromEntries(d.map((y,P)=>[y.id,{index:P,component:y}])))}return{supportedLocales:S.supportedLocales,pageIds:u.map(m=>m.id),components:Object.fromEntries(h.map((m,d)=>[m.id,{index:d,data:m}])),pages:Object.fromEntries(u.map(m=>[m.id,m])),config:S.config||{},resources:D,routeIds:i.map(m=>m.id),routes:Object.fromEntries(i.map(m=>[m.id,m])),dataSourceIds:[],dataSources:{}}}finally{n&&a&&I.rmSync(a,{force:!0,recursive:!0})}}async function Se(t,e,{routes:s,mergeMode:a="byUpdateTime",deleteRoutes:n=!1,publishMode:o=void 0}={}){try{o&&f.clearPreloadComponentsCacheByMode(o)}catch(E){f.logger.error("clear preload page cache error",{error:E})}const{pages:c,pageIds:p,routeIds:l,routes:S,supportedLocales:A}=t;if(o==="production"){let E=s??[],u=null;for(const i of l??[]){const h=S?.[i];if(h?.params&&h?.params.length>0&&h?.paramsOptions&&h?.paramsOptions.length>0){const D=Q.generateParamCombinations({basePath:h.path,params:h.params,routeId:h.id,paramsOptions:h.paramsOptions,currentIndex:0,currentParams:[],currentOptionIds:[],result:[]}),m=Object.fromEntries(D.map(d=>[`${i}-${d.paramOptionIds.join("-")}`,d]));u={...u||{},...m},s||(E=[...E,...D.map(d=>`${i}-${d.paramOptionIds.join("-")}`)])}else s||E.push(i)}f.logger.info("routeIds to be published: ",E);for(const i of E){let h=i;if(h.includes("-")){const[d]=h.split("-");h=d}const D=S?.[h];if(!D){const d=e.pageIds.indexOf(h);d!==-1&&n&&(e.pageIds.splice(d,1),delete e.pages[h]);for(const y of e.pageIds)y.includes(`${h}-`)&&(e.pageIds.splice(e.pageIds.indexOf(y),1),delete e.pages[y]);f.logger.info("delete main route page",h);continue}if(i.includes("-")&&!u?.[i]){const d=e.pageIds.indexOf(i);d!==-1&&n&&(e.pageIds.splice(d,1),delete e.pages[i]),f.logger.info("delete page",i);continue}if(!D.displayTemplateId){f.logger.info("no display template",i);continue}const m=c[D.displayTemplateId];if(!m){f.logger.info("no template page",i);continue}if(e.pageIds.includes(i)){if(f.logger.info("has need update page",i),a==="replace")e.pages[i]=ue({page:m,route:D,state:t,routeId:i,routePathInfo:u?.[i]}),f.logger.info("replace page",i);else if(a==="byUpdateTime"){const d=e.pages[D.id];(!d||D.updatedAt&&D.updatedAt>d.updatedAt)&&(e.pages[i]=ue({page:m,route:D,state:t,routeId:i,routePathInfo:u?.[i]}),f.logger.info("replace page by update time",i))}}else e.pageIds.push(i),e.pages[i]=ue({page:m,route:D,state:t,routeId:i,routePathInfo:u?.[i]}),f.logger.info("add page",i)}if(n&&!s)for(const i of e.pageIds)E?.includes(i)||(delete e.pages[i],f.logger.info("delete page",i)),e.pageIds=[...e.pageIds].filter(h=>E?.includes(h))}else{for(const E of p){const u=c[E];if(u)if(e.pageIds.includes(u.id)){if(a==="replace")e.pages[u.id]=u;else if(a==="byUpdateTime"){const i=e.pages[u.id];(!i||u.updatedAt&&u.updatedAt>i.updatedAt)&&(e.pages[u.id]=u)}}else e.pageIds.push(u.id),e.pages[u.id]=u}for(const E of l){const u=S[E];if(u)if(e.routeIds.includes(u.id)){if(a==="replace")e.routes[u.id]=u;else if(a==="byUpdateTime"){const i=e.routes[u.id];(!i||u.updatedAt&&u.updatedAt>i.updatedAt)&&(e.routes[u.id]=u)}}else e.routeIds.push(u.id),e.routes[u.id]=u}}if(e.supportedLocales.splice(0,e.supportedLocales.length),e.supportedLocales.push(...gt.default(A)),n)for(const E of Object.keys(e.components))delete e.components[E];let v=JSON.parse(JSON.stringify(t.components));v=Object.fromEntries(await Promise.all(Object.entries(v).map(async([E,u])=>{const i=await qe(u?.data);return[E,{...u,data:i}]}))),Object.assign(e.components,v),Object.assign(e.config,JSON.parse(JSON.stringify(t.config))),we.default(t.resources.components)||(e.resources.components=JSON.parse(JSON.stringify(t.resources.components||{})))}const qe=f.memoizeWithFs(async t=>{if(!we.default(t?.properties))return t;if(t?.renderer?.type==="react-component"){const{script:e,PROPERTIES_SCHEMA:s}=t?.renderer||{};if(s||e&&e.includes("PROPERTIES_SCHEMA"))try{const a=await f.getExportSchemaValueFromCode(e??"","PROPERTIES_SCHEMA",t.id,s);a&&a.length>0&&t&&(t.properties={},a.forEach((n,o)=>{t?.properties&&(t.properties[n.id]={index:o,data:n})}))}catch(a){f.logger.error("getPropertiesFromCode error",{componentId:t.id,name:t.name},{error:a})}}return t},{subdir:"getPropertiesFromCode"});let se,J,ne,oe;const xe=()=>Ie.getResources({types:[{did:Pe,type:ge},{did:Et,type:ge}]}),Mt=()=>{const t=xe(),e={};return t.forEach(s=>{const a=X.globSync("**/.blocklet/pages/pages.config.yml",{cwd:s.path,absolute:!0}).at(0),n=a&&g.join(g.dirname(a),"../../chunks");if(n&&I.existsSync(n)){const o=I.readdirSync(n);for(const c of o)e[c]=g.join(n,c)}}),e};function Be(){return se=(async()=>{const t=xe();J=(await Promise.all(t.map(async s=>{const a=s.path?await Oe(s.path,{importAssets:!1}):void 0;return a?{blockletId:s.did,state:a,blockletTitle:s.title}:void 0}))).filter(s=>!!s),ne=J.reduce((s,a)=>Object.assign(s,Object.fromEntries(Object.values(a.state.pages).map(n=>n?[n?.id,{page:n,blockletId:a.blockletId}]:[]))),{});const e=J.reduce((s,a)=>Object.assign(s,Object.fromEntries(Object.values(a.state.components).map(n=>[n.data.id,{blockletId:a.blockletId,component:n.data}]))),{});oe=Object.fromEntries(await Promise.all(Object.entries(e).map(async([s,a])=>{const n=await qe(a.component);return[s,{...a,component:n}]})))})(),se}function Ve(t){const e=Le.default(async()=>{await Be().catch(s=>{f.logger.error("load resource states error",{error:s})}),await t?.({states:J,pages:ne,components:oe})},3e3,{leading:!1,trailing:!0});return e(),w.default.events.on(w.default.Events.componentAdded,e),w.default.events.on(w.default.Events.componentRemoved,e),w.default.events.on(w.default.Events.componentStarted,e),w.default.events.on(w.default.Events.componentStopped,e),w.default.events.on(w.default.Events.componentUpdated,e),w.default.events.on(me,e),()=>{w.default.events.off(w.default.Events.componentAdded,e),w.default.events.off(w.default.Events.componentRemoved,e),w.default.events.off(w.default.Events.componentStarted,e),w.default.events.off(w.default.Events.componentStopped,e),w.default.events.off(w.default.Events.componentUpdated,e),w.default.events.off(me,e)}}const Ge=Symbol.for("GLOBAL_RESOURCE_STATES_LISTENER_KEY"),ze=Symbol.for("GLOBAL_ENV_UPDATE_LISTENER_KEY"),re=globalThis;re[Ge]?.();re[Ge]=Ve(async({pages:t,components:e})=>{const s=await O.getProjectIds();f.logger.info(`start update resource states projects(${s.length})`,s),await Promise.race([new Promise(a=>{setTimeout(()=>{a({})},30*1e3)}),Promise.all(s.map(async a=>{Ye({projectId:a,pages:t,components:e})}))]).catch(a=>{f.logger.error("update resource states failed:",a)})});re[ze]?.();re[ze]=()=>{const t=()=>{O.pageUrlMapCache.clear(),f.logger.info("[Cache CLEAR ALL] clear all page url map cache by env update")};return w.default.events.on(w.default.Events.envUpdate,t),()=>{w.default.events.off(w.default.Events.envUpdate,t)}};O.startPeriodicCheck();process.on("beforeExit",()=>{O.stopPeriodicCheck()});process.on("SIGINT",()=>{O.stopPeriodicCheck(),process.exit(0)});process.on("SIGTERM",()=>{O.stopPeriodicCheck(),process.exit(0)});async function Ye({projectId:t,pages:e,components:s}){const a=O.sharedInstances[t];if(!a){f.logger.info(`projectId: ${t} not found in sharedInstances`);return}if(a.syncedStore.resources.pages=e,(await L.findByPk(t))?.useAllResources)a.syncedStore.resources.components=s;else{const c=(await Ae.findAll({where:{projectId:t}})).map(l=>l.componentId),p=Object.fromEntries(Object.entries(s||{}).filter(([l])=>c.includes(l)));a.syncedStore.resources.components=p}f.logger.info(`update [${t}] resource states:`,{pages:Object.keys(a.syncedStore.resources.pages||{}).length,components:Object.keys(a.syncedStore.resources.components||{}).length})}async function $t(t){return Ye({projectId:t,pages:ne,components:oe})}async function Nt(){f.logger.info("trigger reload all project resource"),w.default.events.emit(me)}async function Ft({ensureLoaded:t=!0}={}){return t&&(se??=Be(),await se),{states:J,pages:ne,components:oe}}exports.COMPONENT_DID=Pe;exports.PUBLISH_MODES=_t;exports.Project=L;exports.RESOURCE_TYPE=ge;exports.SITE_STATE_PATH=q;exports.STATE_MODES=Lt;exports.SiteState=O;exports.downloadAsset=Me;exports.downloadAssets=$e;exports.fromPackage=Oe;exports.getDefaultState=Ue;exports.getResourceStates=Ft;exports.initPackResourceStates=Ve;exports.mergeState=Se;exports.toPackage=Fe;exports.triggerReloadAllProjectResource=Nt;exports.updateResourceStatesByProjectId=$t;