@blocklet/pages-kit-inner-components 0.7.22 → 0.7.23
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/lib/cjs/add-component.js +13 -13
- package/lib/cjs/chunks/{draft-data-e1KnFlxv.js → draft-data-BYzGfJ7S.js} +1 -1
- package/lib/cjs/chunks/{home-BTdS1u5a.js → home-FbBl1G79.js} +2 -2
- package/lib/cjs/chunks/{index-DoTEfRgc.js → index-B-TdKJtn.js} +20 -20
- package/lib/cjs/chunks/{publish-button-JfvmgBSI.js → publish-button-JUoM34Aa.js} +1 -1
- package/lib/cjs/chunks/site-state-oC_X_C59.js +1 -0
- package/lib/cjs/chunks/state-BBnuCgyl.js +1 -0
- package/lib/cjs/home.js +1 -1
- package/lib/cjs/locales.js +2 -2
- package/lib/cjs/resources.js +1 -1
- package/lib/cjs/setting.js +1 -1
- package/lib/cjs/site-state.js +1 -1
- package/lib/es/add-component.js +102 -102
- package/lib/es/chunks/{draft-data-DRdPzuGm.js → draft-data-fMhhz4sh.js} +1 -1
- package/lib/es/chunks/{home-D3e7ljVw.js → home-BujeKjPf.js} +3 -3
- package/lib/es/chunks/{index-Dci_IgHn.js → index-BZ1MijZ6.js} +297 -297
- package/lib/es/chunks/{publish-button-CtlD3O0E.js → publish-button-BO4u_Nxb.js} +3 -3
- package/lib/es/chunks/{site-state-NvsHZBJX.js → site-state-D8_lRJeG.js} +510 -494
- package/lib/es/chunks/{state-qDCrgEMQ.js → state-CMRCtF-D.js} +47 -42
- package/lib/es/home.js +3 -3
- package/lib/es/locales.js +2 -0
- package/lib/es/resources.js +1 -1
- package/lib/es/setting.js +1 -1
- package/lib/es/site-state.js +1 -1
- package/package.json +3 -3
- package/lib/cjs/chunks/site-state-B_SwLwSW.js +0 -1
- package/lib/cjs/chunks/state-DU3L5Lve.js +0 -1
package/lib/cjs/setting.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),r=require("@mui/material"),N=require("./chunks/state-DU3L5Lve.js"),Ce=require("@arcblock/ux/lib/Empty"),R=require("@arcblock/ux/lib/Locale/context"),se=require("@blocklet/code-editor"),ke=require("@mui/icons-material/AddRounded"),Se=require("@mui/icons-material/ArrowDownward"),Pe=require("@mui/icons-material/ArrowUpward"),we=require("@mui/icons-material/DeleteOutline"),Ie=require("lodash/sortBy"),I=require("react"),ne=require("react-use"),ie=require("@blocklet/pages-kit/builtin/color-picker"),V=require("@blocklet/pages-kit/builtin/uploader"),Te=require("@iconify-icon/react"),Be=require("lodash/isEmpty"),Oe=require("lodash/set"),Re=require("yaml"),Ae=require("lodash/cloneDeep"),ze=require("@arcblock/ux/lib/Toast"),H=require("@blocklet/pages-kit/components"),Ve=require("@blocklet/pages-kit/hooks/use-deep-compare-callback"),Ne=require("@blocklet/pages-kit/hooks/use-deep-compare-memo"),_e=require("@blocklet/pages-kit/utils/property"),ce=require("@mui/base"),A=require("@mui/icons-material"),U=require("@syncedstore/core"),Q=require("ahooks"),De=require("lodash/assign"),Ee=require("lodash/get"),Fe=require("lodash/has"),qe=require("lodash/isEqual"),Le=require("lodash/isNil"),Ue=require("lodash/isObject"),Me=require("lodash/keyBy"),We=require("lodash/omit"),Ke=require("lodash/pick"),He=require("lodash/reduce"),D=require("material-ui-popup-state/hooks"),Je=require("react-error-boundary"),L=require("@dnd-kit/core"),X=require("@dnd-kit/sortable"),$e=require("@dnd-kit/utilities"),de=require("@blocklet/pages-kit/utils/common"),O=t=>t&&t.__esModule?t:{default:t};function Ge(t){if(t&&t.__esModule)return t;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(s,o,l.get?l:{enumerable:!0,get:()=>t[o]})}}return s.default=t,Object.freeze(s)}const M=O(Ce),Ye=O(ke),Qe=O(Se),Xe=O(Pe),Ze=O(we),_=O(Ie),E=O(Be),ue=O(Oe),Z=Ge(Re),ee=O(Ae),te=O(ze),et=O(De),tt=O(Ee),rt=O(Fe),st=O(qe),$=O(Le),nt=O(Ue),ot=O(Me),it=O(We),lt=O(Ke),at=O(He);function ct({error:t}){return e.jsx(r.Box,{children:e.jsx(r.Alert,{severity:"error",children:t.message})})}function dt({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:t,...l,children:e.jsx(Ze.default,{fontSize:"small"})})}function ut({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(Xe.default,{fontSize:"small"})})}function pt({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(Qe.default,{fontSize:"small"})})}function xt({label:t,value:s,onChange:o,disabled:l=!1,itemLabel:f="",emptyHeight:p=40,property:u,renderItem:j,...m}){const{t:c,locale:d}=R.useLocaleContext(),a=ne.useUpdate(),i=I.useCallback(b=>{o(N.transformValue(b,u.type))},[o,u.type]),n=I.useMemo(()=>Array.isArray(s)?s:[],[s]),x=I.useCallback(()=>{const b=[...n,""];i(b),a()},[n,i,a]),g=I.useCallback(()=>{if(!u||!u.subProperties)return x();const b={};_.default(Object.values(u.subProperties),"index").forEach(({data:B})=>{if(!B.key)return;const z=B.locales?.[d]?.defaultValue??"";b[B.key]=z});const P=[...n,b];i(P),a()},[n,i,a,u,d,x]),h=I.useCallback(b=>{try{const v=JSON.parse(b);Array.isArray(v)?i(v):console.error("JSON解析结果不是数组")}catch(v){console.error("JSON解析错误:",v)}},[i]),k=I.useCallback(b=>{const v=n.filter((P,B)=>B!==b);i(v),a()},[n,i,a]),y=I.useCallback(b=>{if(b<=0)return;const v=[...n],P=v[b];v[b]=v[b-1],v[b-1]=P,i(v),a()},[n,i,a]),w=I.useCallback(b=>{if(b>=n.length-1)return;const v=[...n],P=v[b];v[b]=v[b+1],v[b+1]=P,i(v),a()},[n,i,a]),T=I.useCallback((b,v)=>{const P=[...n];P[b]=v,i(P)},[n,i]),C=u&&u.subProperties&&Object.keys(u.subProperties).length>0,S=I.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:b})=>e.jsx(r.Typography,{variant:"body1",sx:{bgcolor:"action.hover",borderRadius:"50%",width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:b+1})},{field:"content",headerName:"",renderCell:({row:b,index:v})=>j&&C?j({item:b,index:v,property:u,onChange:P=>T(v,P)}):e.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:l,value:b,placeholder:f||`${c("item")} ${v+1}`,onChange:P=>T(v,P.target.value),...m})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:b})=>e.jsxs(r.Stack,{direction:"column",spacing:.25,children:[e.jsx(ut,{disabled:l||b===0,onClick:()=>y(b)}),e.jsx(pt,{disabled:l||b===n.length-1,onClick:()=>w(b)}),e.jsx(dt,{disabled:l,onClick:()=>k(b)})]})}],[j,C,u,T,f,c,l,m,k,y,w,n.length]);return C?e.jsxs(r.Stack,{sx:{width:"100%",gap:1},children:[t&&e.jsx(r.FormLabel,{children:t}),n.length>0?e.jsx(r.TableContainer,{component:r.Paper,variant:"outlined",sx:{borderRadius:1,mb:1},children:e.jsxs(r.Table,{size:"small",sx:{"& .MuiTableCell-root":{py:.25,px:1,whiteSpace:"nowrap"},"& .MuiTableCell-head":{backgroundColor:"action.hover",py:.25,px:1},borderCollapse:"collapse"},children:[e.jsx(r.TableHead,{sx:{display:"none"},children:e.jsx(r.TableRow,{children:S.map(b=>e.jsx(r.TableCell,{width:b.width,align:b.align||"left",sx:{fontWeight:"bold"},children:b.renderHeader?b.renderHeader():b.headerName},b.field))})}),e.jsx(r.TableBody,{children:n.map((b,v,P)=>e.jsx(r.TableRow,{sx:{borderBottom:v<P.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:S.map(B=>e.jsx(r.TableCell,{width:B.width,align:B.align||"left",sx:{borderBottom:"none"},children:B.renderCell({row:b,index:v,onChange:z=>T(v,z)})},`${v}-${B.field}`))},v))})]})}):e.jsx(M.default,{style:{fontSize:12,height:p},children:c("maker.properties.arrayEmpty")}),e.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:l,startIcon:e.jsx(Ye.default,{}),onClick:g,children:c("maker.properties.addArrayItem")})]}):e.jsxs(r.Stack,{sx:{width:"100%",gap:1},children:[t&&e.jsx(r.FormLabel,{children:t}),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,minHeight:150},children:e.jsx(se.CodeEditor,{keyId:u.id,locale:d,language:"json",value:JSON.stringify(n,null,2),onChange:b=>h(b||""),fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},u.id)})]})}function mt({ref:t,showMarkdown:s,markdown:o,onMarkdownChange:l,showUploader:f,value:p,meta:u,onChange:j,...m}){const[c,d]=I.useState("");I.useEffect(()=>{d(p||"")},[p,d]);const a=async()=>{if(c!==p){const n=N.getImageAbsoluteUrl(c);if(!n){j(c,void 0);return}const x=await V.getImageSize(n).catch(()=>V.getVideoSize(n)).catch(()=>{});j(c,{...x,filename:c})}};ne.useDebounce(()=>{c!==p&&j(c)},300,[c]),I.useImperativeHandle(t,()=>({submit:a}));const i={};return f&&(i.InputProps={sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mx:.5},children:e.jsx(V.UploaderButton,{onChange:async({response:n})=>{const x=n?.data?.filename,g=N.getImageAbsoluteUrl(x)||"";let h={};g&&(h=await V.getImageSize(g).catch(()=>V.getVideoSize(g)).catch(()=>{})),j(x,{...h,filename:x})}})})}),e.jsx(r.TextField,{size:"small",fullWidth:!0,...m,label:e.jsxs(r.Stack,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[m.label,s&&e.jsxs(e.Fragment,{children:[" (",e.jsx(r.FormControlLabel,{checked:o,label:e.jsx(r.Box,{component:Te.Icon,icon:"tabler:markdown",sx:{verticalAlign:"middle"}}),labelPlacement:"start",control:e.jsx(r.Switch,{size:"small"}),sx:{ml:.25,pr:1},onChange:(n,x)=>l?.(x)}),")"]})]}),value:c,onChange:n=>d(n.target.value),...i,onKeyDown:n=>{n.keyCode!==229&&n.key==="Enter"&&a()},slotProps:{inputLabel:{shrink:!0,...m.InputLabelProps}}})}function ft({value:t,onChange:s,disableGradient:o=!1,...l}){const f=I.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(mt,{...l,value:t,onChange:s,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(ie.ColorItem,{color:t??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{f.current?.open({value:t??""})}})})}}),e.jsx(ie.ConfigColorDialog,{ref:f,onSave:({value:p},u)=>{s(p),u()},disableGradient:o})]})}function ht({label:t,value:s,onChange:o,property:l,component:f,defaultLocale:p,allComponents:u,PropertyValueField:j,onUpload:m}){const{locale:c}=R.useLocaleContext(),d=I.useRef(null);if(!E.default(l.subProperties)){const i=_.default(Object.values(l.subProperties||{}),"index").filter(n=>n.data.visible!==!1&&n.data.key);return e.jsxs(r.Stack,{sx:{width:"100%"},children:[e.jsx(r.FormLabel,{sx:{px:.25,py:.5},children:t}),e.jsx(r.Box,{children:e.jsx(r.Box,{sx:{position:"relative"},children:i.map((n,x)=>{const{data:g}=n,h=g.key??g.id,k=x===i.length-1;let y=null;try{s&&typeof s=="object"?y=s[h]:typeof s=="string"&&(y=(l.type==="yaml"?Z.parse(s||""):JSON.parse(s||"{}"))[h])}catch{}y==null&&(g.locales&&c&&g.locales[c]?y=g.locales[c].defaultValue:g.locales&&p&&g.locales[p]&&(y=g.locales[p].defaultValue));const w=C=>{try{let S={};if(typeof s=="string")try{S=l.type==="yaml"?Z.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(S={...s});ue.default(S,h,C);const b=N.transformValue(S,l.type);o?.(b)}catch(S){console.error("Error updating property:",S)}},T=8;return e.jsxs(r.Box,{sx:{mb:k?0:1,display:"flex",flexDirection:"row"},children:[e.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[e.jsx(r.Box,{sx:{position:"absolute",left:T,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:T,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!k&&e.jsx(r.Box,{sx:{position:"absolute",left:T,top:16,bottom:-8,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsx(r.Box,{sx:{flexGrow:1},children:e.jsx(j,{component:f,property:g,value:y,onChange:w,size:"small",fullWidth:!0,defaultLocale:p,allComponents:u})})]},g.id)})})})]})}return e.jsx(r.Stack,{sx:{width:"100%",gap:2},children:e.jsxs(r.Stack,{sx:{width:"100%",position:"relative",pt:1,pb:"6px",px:"1px",minHeight:50,".monaco-editor,.overflow-guard":{borderRadius:1}},children:[e.jsx(r.FormLabel,{sx:{position:"absolute",left:0,top:0,transform:"translate(0px, -7px) scale(0.75)"},children:t}),e.jsx(se.CodeEditor,{keyId:l.id,locale:c,language:l.type==="yaml"?"yaml":"json",value:typeof s=="string"?s:"",onChange:i=>{o?.(i)},onUpload:i=>{d.current=i,m&&m(i)},fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},l.id),e.jsx(r.Box,{component:"fieldset",sx:{pointerEvents:"none",position:"absolute",left:0,top:-5,width:"100%",height:"100%",border:1,borderColor:"rgba(0, 0, 0, 0.23)",borderRadius:1,px:1,py:0},children:e.jsx(r.Box,{component:"legend",sx:{fontSize:"0.75em"},children:e.jsx(r.Box,{component:"span",sx:{opacity:0},children:t})})})]})})}function le(t){return!!t.shared}const bt={setActivatorNodeRef:()=>{},attributes:{},listeners:{}};function pe({disabled:t,list:s,renderItem:o,...l}){const f=_.default(Object.entries(s),([,x])=>x.index),p=f.map(([x])=>x),[u,j]=I.useState(null),[m,c]=I.useState(null),d=L.useSensors(L.useSensor(L.PointerSensor,{activationConstraint:{distance:8}})),a=x=>{const{active:g}=x,h=s[g.id];h&&(c(g.id),j(h.data))},i=()=>{},n=x=>{const{active:g,over:h}=x;if(c(null),j(null),!h||g.id===h.id)return;const k=g.id,y=h.id;if(s[k]&&s[y]){const w=()=>{const S=Object.entries(s).sort(([,B],[,z])=>B.index-z.index),b=S.findIndex(([B])=>B===k),v=S.findIndex(([B])=>B===y),[P]=S.splice(b,1);P&&S.splice(v,0,P),S.forEach(([,B],z)=>{B.index=z})},T=U.getYjsValue(s)?.doc;T?T.transact(()=>{w()}):w()}};return e.jsxs(L.DndContext,{sensors:d,collisionDetection:L.closestCorners,onDragStart:a,onDragOver:i,onDragEnd:n,children:[e.jsx(X.SortableContext,{items:p,strategy:X.verticalListSortingStrategy,children:e.jsx(r.Stack,{...l,children:f.map(([x,g],h)=>e.jsx(gt,{id:x,disabled:t,isDragging:m===x,children:({dragHandle:k})=>o(g.data,h,{isDragging:m===x,dragHandle:k,drag:null,drop:null,preview:null})},x))})}),e.jsx(L.DragOverlay,{children:u&&m?e.jsx(r.Box,{sx:{opacity:.8,backgroundColor:"background.paper",border:"1px solid",borderColor:"primary.main",borderRadius:1,boxShadow:2,maxWidth:400},children:o(u,0,{isDragging:!0,dragHandle:bt,drag:null,drop:null,preview:null})}):null})]})}function gt({id:t,disabled:s,isDragging:o,children:l}){const{attributes:f,listeners:p,setNodeRef:u,setActivatorNodeRef:j,transform:m,transition:c}=X.useSortable({id:t,disabled:s}),d={transform:$e.CSS.Transform.toString(m),transition:c,opacity:o?.5:1};return e.jsx(r.Box,{ref:u,style:d,children:l({dragHandle:{setActivatorNodeRef:j,attributes:f??{},listeners:{...p??{}}}})})}function jt({disabled:t,isDragging:s,children:o,onDelete:l,onVisibilityChange:f,visible:p=!0,onSharedChange:u,shared:j=!1,actions:m,alwaysShowActions:c=!1,dragHandle:d}){const{t:a}=R.useLocaleContext(),i=d?.attributes??{},n=d?.listeners??{},x=d?.setActivatorNodeRef;return e.jsx(r.Box,{sx:{":hover .hover-visible":{maxWidth:"100%"},opacity:p?1:.5},children:e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsx(r.Box,{sx:{flex:1,borderRadius:.5,bgcolor:s?"action.hover":"background.paper",opacity:.9999},children:o}),!t&&e.jsx(r.Box,{className:c?"":"hover-visible",sx:{maxWidth:c?"100%":0,overflow:"hidden",position:"absolute",right:2,top:2,transition:"max-width 0.3s ease-in-out"},children:e.jsxs(r.Stack,{direction:"row",sx:{bgcolor:g=>r.alpha(g.palette.grey[200],.9),borderRadius:1,p:.5,[`.${r.buttonClasses.root}`]:{minWidth:24,width:24,height:24,p:0}},children:[m,u&&e.jsx(r.Tooltip,{title:a(j?"disableSharing":"enableSharing"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>u(!j),children:j?e.jsx(A.SyncRounded,{sx:{fontSize:"1.25rem",color:"primary.main"}}):e.jsx(A.SyncDisabledRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),f&&e.jsx(r.Tooltip,{title:a(p?"hideParameter":"showParameter"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>f(!p),children:p?e.jsx(A.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):e.jsx(A.VisibilityRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),l&&e.jsx(r.Tooltip,{title:a("delete"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:l,children:e.jsx(A.DeleteOutlineRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),e.jsx(r.Tooltip,{title:a("dragSort"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{ref:x,...i,...n,children:e.jsx(A.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function yt(t){const s=["string","json","array","url","multiline"],o=["style","fontSize","color","content","type"];return!!(s.includes(t.type||"")&&!o.includes(t.key||""))}function vt(t,s,o){return t.locales&&t.locales[s]&&t.locales[s].name?t.locales[s].name:o&&t.locales&&t.locales[o]&&t.locales[o].name?t.locales[o].name:t.key?t.key:t.id}const xe=(t,s,o,l)=>{const f={};return _.default(Object.entries(t),([,u])=>u.index).forEach(([u,j])=>{const m=j.data;if(!m)return;const c=m.key||m.id,d=o?vt(m,o,l||""):c,a=s?.[m.id],i={key:c,isNeedGenerate:a?.isNeedGenerate??yt(m),describe:a?.describe??"",displayName:d};m.subProperties&&!E.default(m.subProperties)&&(i.subProperties=xe(m.subProperties,a?.subProperties,o,l)),f[m.id]=i}),f};function Ct({open:t,onClose:s,onConfirm:o,component:l,initialConfig:f,locale:p,defaultLocale:u,title:j,loading:m=!1}){const{t:c}=R.useLocaleContext(),[d,a]=I.useState(null);I.useEffect(()=>{if(t&&l){const h={properties:{}};if(l.properties){const k=f?.properties;h.properties=xe(l.properties,k,p,u)}a(h)}},[t,l,f,p,u]);const i=()=>{s()},n=()=>{d&&(o(d),s())},x=(h,k,y)=>{if(!d||!h.length)return;const w=JSON.parse(JSON.stringify(d));let T=w.properties,C=null;for(let b=0;b<h.length-1;b++){const v=h[b];if(!v||!T[v])return;C=T;const P=T[v];P.subProperties||(P.subProperties={}),T=P.subProperties}const S=h[h.length-1];if(S){if("isNeedGenerate"in y){const b=y.isNeedGenerate,v={...k,...y};if(k.subProperties&&!E.default(k.subProperties)){const P=(B,z)=>{const q={};return Object.entries(B).forEach(([ve,W])=>{const Y={...W};z!==null&&(Y.isNeedGenerate=z),W.subProperties&&!E.default(W.subProperties)&&(Y.subProperties=P(W.subProperties,z!==null?z:null)),q[ve]=Y}),q};v.subProperties=P(k.subProperties,b===!1?!1:null)}if(h.length===1)w.properties[S]=v;else if(C&&h.length>=2){const P=h[h.length-2];P&&C[P]&&(C[P].subProperties||(C[P].subProperties={}),C[P].subProperties[S]=v)}}else if(h.length===1)w.properties[S]={...k,...y};else if(C&&h.length>=2){const b=h[h.length-2];b&&C[b]&&C[b].subProperties&&(C[b].subProperties[S]={...k,...y})}a(w)}},g=(h,k=[],y=!0)=>{if(!h||E.default(h))return e.jsx(M.default,{children:c("maker.properties.noProperties")});const w=_.default(Object.entries(h),([,T])=>T.displayName);return e.jsx(r.Stack,{spacing:1.5,children:w.map(([T,C],S)=>{const b=[...k,T],v=S===w.length-1,P=C.subProperties&&!E.default(C.subProperties),B=C.displayName||T,z=!y;return e.jsx(r.Box,{sx:{position:"relative"},children:e.jsxs(r.Stack,{direction:"row",children:[k.length>0&&e.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[e.jsx(r.Box,{sx:{position:"absolute",left:8,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:8,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!v&&e.jsx(r.Box,{sx:{position:"absolute",left:8,top:16,bottom:-12,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsxs(r.Stack,{spacing:1.5,sx:{flexGrow:1},children:[e.jsxs(r.Stack,{direction:{xs:"column",md:"row"},spacing:1.5,sx:{alignItems:{xs:"flex-start",md:"center"},width:"100%"},children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:C.isNeedGenerate,disabled:z,onChange:q=>{x(b,C,{isNeedGenerate:q.target.checked})}}),label:B,sx:{minWidth:"180px",maxWidth:"280px",mr:2,"& .MuiFormControlLabel-label":{wordBreak:"break-word"}}}),e.jsx(r.TextField,{size:"small",fullWidth:!0,label:c("maker.properties.llmPropertyDescribe"),value:C.describe,onChange:q=>{x(b,C,{describe:q.target.value})},disabled:!C.isNeedGenerate})]}),P&&e.jsx(r.Box,{sx:{ml:3},children:g(C.subProperties,b,C.isNeedGenerate&&y)})]})]})},T)})})};return e.jsxs(r.Dialog,{open:t,onClose:i,maxWidth:"lg",fullWidth:!0,children:[e.jsx(r.DialogTitle,{children:j||c("maker.properties.llmConfigTitle")}),e.jsx(r.DialogContent,{children:e.jsx(r.Box,{sx:{my:3},children:m?e.jsx(r.Typography,{children:c("maker.properties.loading")}):l?d?e.jsxs(r.Stack,{spacing:3,children:[e.jsx(r.Typography,{variant:"subtitle2",children:c("maker.properties.llmConfigInstructions")}),g(d.properties)]}):e.jsx(r.Typography,{children:c("maker.properties.loading")}):e.jsx(r.Typography,{color:"error",children:c("maker.properties.componentNotFound")})})}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{onClick:i,children:c("common.cancel")}),e.jsx(r.Button,{variant:"contained",onClick:n,disabled:!d||m,children:c("common.confirm")})]})]})}function kt({label:t,value:s,onChange:o}){const[l,f]=I.useState(!1);return e.jsxs(r.Stack,{sx:{gap:1},children:[e.jsx(r.TextField,{label:t,size:"small",value:s,onChange:p=>o?.(p.target.value),slotProps:{input:{sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(V.UploaderButton,{onChange:({response:p})=>{const u=p?.data?.filename;u&&o?.(u)}})})}}}),s&&e.jsx(r.Box,{component:"img",src:N.getImageAbsoluteUrl(s),alt:t,onClick:()=>f(!0),sx:{maxWidth:100,maxHeight:100,width:"100%",objectFit:"contain",borderRadius:1,cursor:"pointer"}}),e.jsx(r.Dialog,{open:l,onClose:()=>f(!1),children:e.jsx(r.Box,{component:"img",sx:{objectFit:"contain"},src:N.getImageAbsoluteUrl(s),alt:t})})]})}function re(t,s=""){return at.default(t,(o,l,f)=>{const p=s?`${s}.${f}`:f;return nt.default(l)?et.default(o,re(l,p)):o[p]=l,o},{})}const St=[{value:"string",label:"Text"},{value:"multiline",label:"Text (Multiline)"},{value:"number",label:"Number"},{value:"decimal",label:"Decimal"},{value:"boolean",label:"Boolean"},{value:"color",label:"Color"},{value:"url",label:"URL (Upload)"},{value:"json",label:"JSON"},{value:"yaml",label:"YAML"},{value:"array",label:"Array"},{value:"component",label:"Component"},{value:"custom",label:"Custom (Render by a Component)"}];function K(t,s,o){return!t||!o?!1:Object.values(t).some(({data:l})=>l.id!==s&&l.key===o)}function J(t,s){return!t||!s?!1:t[s]?.data.visible??!0}function me(t,s){return!t||!s?!1:t[s]?.data.shared??!1}function Pt({componentId:t}){const{state:{components:s}}=N.useStore(),l=s[t]?.data;return l?e.jsx(r.Stack,{sx:{maxHeight:"100%",overflow:"auto"},children:e.jsx(r.Box,{sx:{p:2},children:e.jsx(Je.ErrorBoundary,{FallbackComponent:ct,resetKeys:[t],children:e.jsx(wt,{value:l,componentId:t})})})}):null}function wt({value:t,componentId:s}){const{t:o}=R.useLocaleContext(),{localState:{currentLocale:l,customComponentPreviewerProperties:f},state:{config:{defaultLocale:p}},localActions:{setCustomComponentPreviewerProperties:u}}=N.useStore(),j=U.getYjsValue(t).doc,m=N.useAllComponents(),c=I.useMemo(()=>f?.[s]??{},[s,f]),d=t.renderer?.type||"react-component",a=d==="component-template",i=Q.useReactive({componentId:s,propertiesValue:{...c}});return I.useEffect(()=>{i.componentId!==s&&(i.componentId=s,i.propertiesValue={...c})},[s,c,i]),Q.useDeepCompareEffect(()=>{if(i.componentId!==s)return;const n=Object.fromEntries(Object.values(t.properties??{}).map(({data:x})=>[x.id,{value:i.propertiesValue[x.id]?.value??_e.parsePropertyValue(x,x.locales?.[l]?.defaultValue??x.locales?.[p]?.defaultValue,{locale:l,defaultLocale:p})}]));u(s,n)},[i.propertiesValue,s,i.componentId]),e.jsx(r.Stack,{sx:{height:"100%"},children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsx(fe,{config:t}),e.jsxs(e.Fragment,{children:[e.jsx(be,{config:t,currentLocale:l,defaultLocale:p,allComponents:m,onUpdateConfig:n=>{j.transact(()=>{n(t)})}}),e.jsxs(r.Stack,{direction:"row",sx:{gap:2,justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"subtitle1",children:o("renderer")}),e.jsxs(r.TextField,{hiddenLabel:!0,size:"small",select:!0,value:d,disabled:a,onChange:n=>{j.transact(()=>{const x=n.target.value;t.renderer??={type:x},t.renderer.type=x})},slotProps:{select:{autoWidth:!0}},children:[e.jsx(r.MenuItem,{value:"component-template",disabled:!0,children:o("maker.components.componentTemplate")}),e.jsx(r.MenuItem,{value:"react-component",children:"React Component"}),e.jsx(r.MenuItem,{value:"component",children:"Custom Component"})]})]}),d==="component"&&e.jsx(zt,{value:t}),d==="react-component"&&e.jsx(At,{value:t}),e.jsx(oe,{config:t,currentLocale:l,defaultLocale:p,allComponents:m,propertiesValue:i.propertiesValue,onChange:({value:n,id:x,path:g})=>{const h=[...g,"data"];if(!tt.default(t,h)){te.default.warning(o("cannotFindPropertyKey",{key:h.join(".")}));return}i.propertiesValue[x]={value:n.value}}})]})]})})}function fe({config:t}){const{t:s}=R.useLocaleContext();return e.jsx(V.UploaderProvider,{children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsx(r.Typography,{variant:"subtitle1",children:s("basicInfo")}),e.jsx(r.TextField,{label:s("name"),size:"small",value:t.name||"",onChange:o=>t.name=o.target.value}),e.jsx(r.TextField,{label:s("description"),size:"small",multiline:!0,minRows:2,maxRows:8,value:t.description||"",onChange:o=>t.description=o.target.value,slotProps:{input:{endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mt:-1.5},children:e.jsx(Vt,{config:t})})},htmlInput:{maxLength:2048}}}),e.jsx(r.Autocomplete,{size:"small",options:[],multiple:!0,freeSolo:!0,value:t.tags??[],onChange:(o,l)=>t.tags=l,renderInput:o=>e.jsx(r.TextField,{label:s("tags"),...o})}),e.jsx(kt,{label:s("previewImage"),value:t.previewImage||"",onChange:o=>t.previewImage=o})]})})}function he({data:t,params:s,visible:o,shared:l,config:f,currentLocale:p,defaultLocale:u,allComponents:j,onUpdateConfig:m}){const{t:c}=R.useLocaleContext(),d=I.useMemo(()=>t.type==="json"||t.type==="yaml"||t.type==="array"?Ot:F,[t.type]);return e.jsx(jt,{preview:s.preview,drop:s.drop,drag:s.drag,isDragging:s.isDragging,dragHandle:s.dragHandle,onDelete:()=>{m(a=>{if(a.properties){const n=Object.entries(a.properties).sort(([,g],[,h])=>g.index-h.index);delete a.properties[t.id],n.filter(([g])=>g!==t.id).forEach(([,g],h)=>{g.index=h})}})},visible:o,onVisibilityChange:a=>{m(i=>{const n=i.properties[t.id].data;n.visible=a})},shared:l,onSharedChange:a=>{m(i=>{const n=i.properties[t.id].data;n.shared=a})},alwaysShowActions:!0,children:e.jsxs(r.Stack,{direction:"column",sx:{gap:2},children:[e.jsx(r.TextField,{label:c("key"),size:"small",required:!0,sx:{width:"calc(100% - 104px - 8px)",flex:1,"& .MuiOutlinedInput-root":{borderColor:t.key?K(f.properties,t.id,t.key)?"warning.main":void 0:"error.main"},"& .MuiFormLabel-root":{color:t.key?K(f.properties,t.id,t.key)?"warning.main":"text.secondary":"error.main"},"& .MuiFormLabel-root.Mui-focused":{color:t.key?K(f.properties,t.id,t.key)?"warning.main":"primary.main":"error.main"}},value:t.key||"",onChange:a=>{m(i=>{const n=i.properties[t.id].data;n.key=a.target.value.trim()})},slotProps:{input:{endAdornment:!t.key||t.key&&K(f.properties,t.id,t.key)?e.jsx(r.InputAdornment,{position:"end",sx:{width:16,ml:0},children:e.jsx(r.Tooltip,{title:t.key?c("duplicateKey"):c("requiredKey"),children:e.jsx(A.InfoRounded,{sx:{color:t.key?"warning.main":"error.main",fontSize:16}})})}):null}}}),e.jsxs(r.Stack,{direction:"row",sx:{gap:1},children:[e.jsx(r.TextField,{label:c("label"),size:"small",sx:{flex:1},value:(t.locales?.[p]?.name??t.locales?.[u]?.name)||"",onChange:a=>{m(i=>{const n=i.properties[t.id].data;n.locales??={},n.locales[p]??={},n.locales[p].name=a.target.value})}}),e.jsx(r.TextField,{label:c("type"),size:"small",select:!0,sx:{flex:1},value:t.type==="string"&&t.multiline?"multiline":t.type||"string",onChange:a=>{m(i=>{const n=i.properties[t.id].data;if(n.locales)for(const g of Object.keys(n.locales))n.locales[g].defaultValue=void 0;const x=a.target.value;x==="multiline"?(n.type="string",n.multiline=!0):(typeof n.multiline<"u"&&delete n.multiline,n.type=x)})},children:St.map(a=>e.jsx(r.MenuItem,{value:a.value,children:a.label},a.value))})]}),e.jsxs(r.Stack,{direction:"row",sx:{gap:1},children:[e.jsx(d,{allComponents:j,defaultLocale:u,component:f,property:t,label:c("defaultValue"),size:"small",fullWidth:!0,value:t.locales?.[p]?.defaultValue,onChange:(a,i)=>{m(n=>{const x=n.properties[t.id].data;if(i?.forceUpdateProperty){const g=re(x),h=re(a);Object.keys(h).forEach(k=>{g[k]||ue.default(x,k,h[k])})}else x.locales??={},x.locales[p]??={},x.locales[p].defaultValue=a})}}),t.type==="custom"?e.jsx(r.Box,{children:e.jsx(Tt,{property:t,allComponents:j})}):null]})]})})}function It(t,s){const[o,l]=I.useState(0);return I.useEffect(()=>{const p=setTimeout(()=>{if(t.current){let u=t.current.parentElement,j=0;for(;u;)u.classList.contains("property-container")&&j++,u=u.parentElement;l(j)}},100);return()=>clearTimeout(p)},[t,s]),o}function be({config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:f,useI18nEditor:p=!0}){const{t:u}=R.useLocaleContext(),j=D.usePopupState({variant:"dialog"}),m=t.properties&&_.default(Object.values(t.properties),"index");return e.jsx(V.UploaderProvider,{children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsxs(r.Stack,{direction:"row",sx:{gap:1,alignItems:"center",justifyContent:"space-between"},children:[e.jsx(r.Typography,{variant:"subtitle1",children:u("properties")}),e.jsx(r.Box,{sx:{flex:1}}),p&&e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...D.bindTrigger(j),children:e.jsx(A.TranslateRounded,{fontSize:"small"})})]}),t.properties&&Object.keys(t.properties).length>0?e.jsx(pe,{component:r.Stack,gap:2,list:t.properties,renderItem:(c,d,a)=>{const i=J(t.properties,c.id),n=me(t.properties,c.id);return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed",borderColor:"divider"},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(he,{data:c,params:a,visible:i,shared:n,config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:f})})},c.id)}}):e.jsx(M.default,{style:{fontSize:12},children:u("maker.properties.noProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",onClick:()=>{f(c=>{const d=de.nextId();c.properties??={},c.properties[d]??={index:m?.length||0,data:{id:d,shared:!1}}})},startIcon:e.jsx(A.AddRounded,{}),children:u("addObject",{object:u("property")})}),p&&e.jsx(ge,{...D.bindDialog(j),component:t})]})})}function Tt({property:t,allComponents:s}){const o=D.usePopupState({variant:"popper"});return e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},...D.bindTrigger(o),children:e.jsx(A.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...D.bindPopper(o),children:e.jsx(ce.ClickAwayListener,{onClickAway:o.close,children:e.jsx(r.Paper,{children:e.jsx(r.Box,{sx:{width:500,p:2},children:e.jsx(G,{value:t.componentId,onChange:(l,f)=>t.componentId=f,allComponents:s})})})})})]})}function Bt({value:t,valueImmutable:s,onChange:o,defaultLocale:l,allComponents:f}){const[p,u]=I.useState(!1),{t:j,locale:m}=R.useLocaleContext(),c=typeof t?.componentId=="string"?f[t.componentId]?.data:void 0;return c?e.jsxs(r.Box,{sx:{width:"100%",position:"relative"},children:[e.jsx(r.IconButton,{sx:{minWidth:0},disabled:!c,size:"small",onClick:()=>u(!p),color:p?"primary":"default",children:e.jsx(A.SettingsRounded,{fontSize:"small"})}),p&&e.jsx(r.Collapse,{in:p,timeout:"auto",unmountOnExit:!0,sx:{width:"100%",zIndex:10},children:e.jsxs(r.Paper,{elevation:1,sx:{mt:1,p:2,borderRadius:1,border:"1px solid",borderColor:"divider",width:"100%"},children:[e.jsx(r.Box,{sx:{width:"100%",mb:2},children:e.jsx(oe,{config:c,currentLocale:m,defaultLocale:l,allComponents:f,propertiesValue:t?.properties,onChange:({id:d,value:a})=>{const i=ee.default(a.value),n=JSON.parse(JSON.stringify(t));n?.componentId&&(s?o?.({...n,properties:{...n.properties,[d]:{value:i}}}):(n.properties=n.properties??{},n.properties[d]={value:i},o?.(n)))}})}),e.jsx(r.Button,{size:"small",onClick:()=>u(!1),sx:{mt:1},children:j("close")})]})})]}):null}function ge({type:t="properties",component:s,...o}){const{t:l}=R.useLocaleContext(),{state:{components:f,supportedLocales:p,config:{defaultLocale:u}}}=N.useStore(),j=N.useAllComponents(),m=U.getYjsValue(s).doc,c=t==="properties"?s.properties:t==="parameters"&&s.renderer?.type==="component"?f[s.renderer.componentId]?.data.properties:void 0,d=s.renderer?.type==="component"?s:void 0;return e.jsxs(r.Dialog,{...o,fullWidth:!0,maxWidth:"lg",children:[e.jsx(r.DialogTitle,{children:l("i18nEditorTitle")}),e.jsx(r.DialogContent,{children:c&&e.jsx(r.Stack,{children:e.jsxs(r.Table,{stickyHeader:!0,sx:{td:{verticalAlign:"top"}},children:[e.jsx(r.TableHead,{children:e.jsx(r.TableRow,{children:p.map(({locale:a,name:i})=>e.jsx(r.TableCell,{children:e.jsxs(r.Typography,{sx:{color:"text.primary"},children:[i,u===a&&e.jsx(A.StarRounded,{sx:{fontSize:12}})]})},a))})}),e.jsx(r.TableBody,{children:_.default(Object.values(c),"index").map(({data:a})=>e.jsx(r.TableRow,{children:p.map(({locale:i})=>e.jsx(r.TableCell,{children:e.jsx(r.Stack,{sx:{gap:1},children:t==="properties"?e.jsxs(e.Fragment,{children:[e.jsx(r.TextField,{size:"small",label:"Key",value:a.key||"",onChange:n=>{m.transact(()=>{a.key=n.target.value.trim()})}}),e.jsx(r.TextField,{size:"small",label:l("label"),value:(a.locales?.[i]?.name??a.locales?.[u]?.name)||"",onChange:n=>{m.transact(()=>{a.locales??={},a.locales[i]??={},a.locales[i].name=n.target.value})}}),e.jsx(r.Box,{children:e.jsx(F,{allComponents:j,defaultLocale:u,component:s,property:a,size:"small",fullWidth:!0,label:"Default Value",valueImmutable:$.default(a.locales?.[i]?.defaultValue),value:a.locales?.[i]?.defaultValue??a.locales?.[u]?.defaultValue,onChange:n=>{m.transact(()=>{a.locales??={},a.locales[i]??={},a.locales[i].defaultValue=n})}})})]}):t==="parameters"&&d?e.jsx(r.Box,{children:e.jsx(F,{allComponents:j,defaultLocale:u,component:s,property:a,size:"small",fullWidth:!0,valueImmutable:$.default(d.renderer.properties?.[a.id]?.locales?.[i]?.value),value:d.renderer.properties?.[a.id]?.locales?.[i]?.value??d.renderer.properties?.[a.id]?.locales?.[u]?.value??a.locales?.[i]?.defaultValue??a.locales?.[u]?.defaultValue,onChange:n=>{m.transact(()=>{d.renderer.properties??={},d.renderer.properties[a.id]??={},d.renderer.properties[a.id].locales??={},d.renderer.properties[a.id].locales[i]??={},d.renderer.properties[a.id].locales[i].value=n})}})}):null},a.id)},i))},a.id))})]})})}),e.jsx(r.DialogActions,{children:e.jsx(r.Button,{onClick:a=>o.onClose?.(a,"escapeKeyDown"),children:l("close")})})]})}const ae=(t,s)=>o=>{const l=[o.palette.info.main,o.palette.primary.main,o.palette.secondary.main,o.palette.success.main,o.palette.warning.main],f=Math.min(l.length-1,t),p=l[f],u=r.alpha(p,.5),j=r.alpha(p,1);return{borderColor:`${u} !important`,borderLeft:"3px solid !important",borderLeftColor:u,color:j,...s}};function Ot({property:t,onChange:s,defaultLocale:o,allComponents:l}){const{t:f,locale:p}=R.useLocaleContext(),u=I.useRef(null),j=It(u,t),m=I.useCallback(()=>{if(!(t.type!=="json"&&t.type!=="yaml"&&t.type!=="array")&&t.subProperties)try{let c={};_.default(Object.values(t.subProperties),"index").filter(i=>i.data.visible!==!1&&i.data.key).forEach(({data:i})=>{if(!i.key)return;let n=i.locales?.[p]?.defaultValue??i.locales?.[o]?.defaultValue;if(i.type==="number")n=Number(n);else if(i.type==="boolean")n=n===!0||n==="true";else if((i.type==="json"||i.type==="yaml")&&typeof n=="string")try{i.type==="json"?n=JSON.parse(n):n=Z.parse(n)}catch(x){console.error("Error parsing nested value",n,x),n={}}c[i.key]=n}),t.type==="array"&&!Array.isArray(c)&&(c=E.default(c)?[]:[c]);const a=N.transformValue(c,t.type);s?.(a)}catch(c){console.error("Error converting structure to text:",c)}},[t,p,o,s]);return t.type!=="json"&&t.type!=="yaml"&&t.type!=="array"?null:e.jsxs(r.Stack,{direction:"column",ref:u,sx:{gap:1.5,width:"100%"},children:[e.jsx(r.Divider,{sx:{mt:-1},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary"},children:f("maker.properties.subProperties")})}),t.subProperties&&Object.keys(t.subProperties).length>0?e.jsx(pe,{component:r.Stack,gap:2,list:t.subProperties,renderItem:(c,d,a)=>{const i=c.visible!==!1,n=c.shared??!1;return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed","&":ae(j)},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(he,{data:c,params:a,visible:i,shared:n,config:{properties:t.subProperties},currentLocale:p,defaultLocale:o,allComponents:l,onUpdateConfig:x=>{try{const g={properties:t.subProperties||{}};x(g);const h={...t,subProperties:g.properties};s?.(h,{forceUpdateProperty:!0}),m()}catch(g){console.error("Error updating property:",g)}}})})},c.id)}}):e.jsx(M.default,{style:{fontSize:12,height:100},children:f("maker.properties.noSubProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",size:"small",startIcon:e.jsx(A.AddRounded,{}),onClick:()=>{try{const c=t.subProperties||{},d=de.nextId(),i={index:Object.values(c).length,data:{id:d,key:"",type:"string",visible:!0,shared:!1,locales:{[p]:{name:"",defaultValue:""}},subProperties:{}}},n={...t,subProperties:{...c,[d]:i}};s?.(n,{forceUpdateProperty:!0}),m()}catch(c){console.error("Error adding property:",c)}},sx:{"&":ae(j,{})},children:f("maker.properties.addSubProperty")})]})}function F({component:t,property:s,value:o,onChange:l,valueImmutable:f,defaultLocale:p,allComponents:u,...j}){const{locale:m}=R.useLocaleContext(),c=V.useUploader(),d=I.useRef(null),a=()=>{const n=c?.current?.getUploader();n?.open(),d.current&&n.onceUploadSuccess(({response:x})=>{let g=x?.data?.filename||"";g&&(g=`mediakit://${g}`,o&&!o.includes("mediakit://")&&(g+=" # please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address")),d.current?.(g)})},i=j.label??(s.locales?.[m]?.name||s.locales?.[p]?.name||s.key||s.id);if(s.type==="number")return e.jsx(Rt,{...j,label:i,NumberProps:{value:["number","string"].includes(typeof o)?o:null,onChange:(n,x)=>l?.(x)}});if(s.type==="decimal")return e.jsx(r.TextField,{...j,label:i,type:"text",value:o??"",onChange:n=>{const x=n.target.value;if(x===""||x==="-"){l?.(x);return}if(/^-?(?!.*\..*\.)[0-9]*(\.[0-9]{0,9})?$/.test(x)){let h=x;/^-?[1-9]+[0-9]*(\.[0-9]{1,9})?$/.test(h)&&(h=Number(h)),l?.(h)}}});if(s.type==="boolean")return e.jsx(r.FormControlLabel,{label:i,labelPlacement:"start",control:e.jsx(r.Switch,{checked:o===!0,onChange:(n,x)=>l?.(x)})});if(s.type==="color")return e.jsx(ft,{label:i,value:o,onChange:n=>{l?.(n)}});if(s.type==="json"||s.type==="yaml")return e.jsx(ht,{label:i,value:o,onChange:n=>{l?.(n)},property:s,component:t,defaultLocale:p,allComponents:u,PropertyValueField:F,onUpload:n=>{d.current=n,a()}});if(s.type==="custom"){const n=u[s.componentId]?.data;return n?e.jsx(r.Box,{sx:{width:"100%"},children:e.jsx(H.CustomComponentRenderer,{componentId:n.id,props:{label:i,value:o,onChange:l},locale:m,dev:{mode:"draft",components:u,defaultLocale:p}})}):e.jsx(r.TextField,{...j,label:i,disabled:!0,placeholder:"Click right button select a component"})}if(s.type==="component")return e.jsxs(r.Stack,{direction:"column",sx:{width:"100%",gap:1},children:[e.jsx(G,{allComponents:u,label:i,value:o?.componentId,onChange:(n,x)=>{f||!o?l?.({...o&&JSON.parse(JSON.stringify(o)),componentId:x}):typeof o=="object"&&(o.componentId=x,l?.({...o&&JSON.parse(JSON.stringify(o)),componentId:x}))}}),o?.componentId&&e.jsx(Bt,{value:o,valueImmutable:f,onChange:l,defaultLocale:p,allComponents:u})]});if(!s.type||["string","url","multiline"].includes(s.type)){let n=s.type==="string"?s.multiline:void 0;s.type==="multiline"&&(n=!0);const x=s.type==="url"?o?.url:o;return e.jsx(r.TextField,{...j,label:i,value:typeof x=="string"?x:"",multiline:n,minRows:n?2:void 0,maxRows:n?10:void 0,onChange:g=>l?.(s.type==="url"?{...o,url:g.target.value,mediaKitUrl:g.target.value}:g.target.value),slotProps:{input:s.type==="url"?{sx:{pr:0},endAdornment:e.jsxs(r.InputAdornment,{position:"end",sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(V.UploaderButton,{onChange:async({response:g})=>{const h=g?.data?.url||g?.data?.fileUrl;let k;h&&(k=await V.getImageSize(h).catch(()=>V.getVideoSize(h)).catch(()=>{}));let y=g?.data?.filename||"";y&&(y=`mediakit://${y}`),l?.({url:h,mediaKitUrl:y,width:k?.naturalWidth,height:k?.naturalHeight})}}),e.jsx(r.Tooltip,{title:"If you are using the 'mediaKitUrl' property, please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address.",children:e.jsx(A.InfoRounded,{sx:{cursor:"default",mr:1},fontSize:"small"})})]})}:void 0}})}return s.type==="array"?e.jsx(xt,{label:i,value:Array.isArray(o)?o:[],onChange:n=>l?.(n),property:s,renderItem:({item:n,index:x,onChange:g})=>s.subProperties&&Object.keys(s.subProperties).length>0?e.jsx(r.Stack,{sx:{gap:1,width:"100%"},children:_.default(Object.values(s.subProperties),"index").filter(h=>h.data.visible!==!1).map(({data:h})=>h.key?e.jsx(F,{component:t,property:h,value:n[h.key],onChange:k=>{const y={...n,[h.key]:k};g(y)},size:"small",fullWidth:!0,defaultLocale:p,allComponents:u},h.id):null)},x):e.jsx(r.TextField,{size:j.size,fullWidth:!0,value:n,onChange:h=>g(h.target.value)})}):(console.error("Unsupported property type",s.type),null)}function Rt({NumberProps:t,...s}){const{getInputProps:o}=ce.unstable_useNumberInput(t),l=o();return e.jsx(r.TextField,{...s,slotProps:{htmlInput:l}})}const je=`import React from '@blocklet/pages-kit/builtin/react'
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),r=require("@mui/material"),N=require("./chunks/state-BBnuCgyl.js"),Ce=require("@arcblock/ux/lib/Empty"),R=require("@arcblock/ux/lib/Locale/context"),se=require("@blocklet/code-editor"),ke=require("@mui/icons-material/AddRounded"),Se=require("@mui/icons-material/ArrowDownward"),Pe=require("@mui/icons-material/ArrowUpward"),we=require("@mui/icons-material/DeleteOutline"),Ie=require("lodash/sortBy"),I=require("react"),ne=require("react-use"),ie=require("@blocklet/pages-kit/builtin/color-picker"),V=require("@blocklet/pages-kit/builtin/uploader"),Te=require("@iconify-icon/react"),Be=require("lodash/isEmpty"),Oe=require("lodash/set"),Re=require("yaml"),Ae=require("lodash/cloneDeep"),ze=require("@arcblock/ux/lib/Toast"),H=require("@blocklet/pages-kit/components"),Ve=require("@blocklet/pages-kit/hooks/use-deep-compare-callback"),Ne=require("@blocklet/pages-kit/hooks/use-deep-compare-memo"),_e=require("@blocklet/pages-kit/utils/property"),ce=require("@mui/base"),A=require("@mui/icons-material"),U=require("@syncedstore/core"),Q=require("ahooks"),De=require("lodash/assign"),Ee=require("lodash/get"),Fe=require("lodash/has"),qe=require("lodash/isEqual"),Le=require("lodash/isNil"),Ue=require("lodash/isObject"),Me=require("lodash/keyBy"),We=require("lodash/omit"),Ke=require("lodash/pick"),He=require("lodash/reduce"),D=require("material-ui-popup-state/hooks"),Je=require("react-error-boundary"),L=require("@dnd-kit/core"),X=require("@dnd-kit/sortable"),$e=require("@dnd-kit/utilities"),de=require("@blocklet/pages-kit/utils/common"),O=t=>t&&t.__esModule?t:{default:t};function Ge(t){if(t&&t.__esModule)return t;const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(s,o,l.get?l:{enumerable:!0,get:()=>t[o]})}}return s.default=t,Object.freeze(s)}const M=O(Ce),Ye=O(ke),Qe=O(Se),Xe=O(Pe),Ze=O(we),_=O(Ie),E=O(Be),ue=O(Oe),Z=Ge(Re),ee=O(Ae),te=O(ze),et=O(De),tt=O(Ee),rt=O(Fe),st=O(qe),$=O(Le),nt=O(Ue),ot=O(Me),it=O(We),lt=O(Ke),at=O(He);function ct({error:t}){return e.jsx(r.Box,{children:e.jsx(r.Alert,{severity:"error",children:t.message})})}function dt({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"warning",variant:"outlined",disabled:s,onClick:t,...l,children:e.jsx(Ze.default,{fontSize:"small"})})}function ut({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(Xe.default,{fontSize:"small"})})}function pt({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(Qe.default,{fontSize:"small"})})}function xt({label:t,value:s,onChange:o,disabled:l=!1,itemLabel:f="",emptyHeight:p=40,property:u,renderItem:j,...m}){const{t:c,locale:d}=R.useLocaleContext(),a=ne.useUpdate(),i=I.useCallback(b=>{o(N.transformValue(b,u.type))},[o,u.type]),n=I.useMemo(()=>Array.isArray(s)?s:[],[s]),x=I.useCallback(()=>{const b=[...n,""];i(b),a()},[n,i,a]),g=I.useCallback(()=>{if(!u||!u.subProperties)return x();const b={};_.default(Object.values(u.subProperties),"index").forEach(({data:B})=>{if(!B.key)return;const z=B.locales?.[d]?.defaultValue??"";b[B.key]=z});const P=[...n,b];i(P),a()},[n,i,a,u,d,x]),h=I.useCallback(b=>{try{const v=JSON.parse(b);Array.isArray(v)?i(v):console.error("JSON解析结果不是数组")}catch(v){console.error("JSON解析错误:",v)}},[i]),k=I.useCallback(b=>{const v=n.filter((P,B)=>B!==b);i(v),a()},[n,i,a]),y=I.useCallback(b=>{if(b<=0)return;const v=[...n],P=v[b];v[b]=v[b-1],v[b-1]=P,i(v),a()},[n,i,a]),w=I.useCallback(b=>{if(b>=n.length-1)return;const v=[...n],P=v[b];v[b]=v[b+1],v[b+1]=P,i(v),a()},[n,i,a]),T=I.useCallback((b,v)=>{const P=[...n];P[b]=v,i(P)},[n,i]),C=u&&u.subProperties&&Object.keys(u.subProperties).length>0,S=I.useMemo(()=>[{field:"index",headerName:"#",width:40,align:"center",renderCell:({index:b})=>e.jsx(r.Typography,{variant:"body1",sx:{bgcolor:"action.hover",borderRadius:"50%",width:24,height:24,display:"flex",alignItems:"center",justifyContent:"center",color:"text.secondary"},children:b+1})},{field:"content",headerName:"",renderCell:({row:b,index:v})=>j&&C?j({item:b,index:v,property:u,onChange:P=>T(v,P)}):e.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:l,value:b,placeholder:f||`${c("item")} ${v+1}`,onChange:P=>T(v,P.target.value),...m})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:b})=>e.jsxs(r.Stack,{direction:"column",spacing:.25,children:[e.jsx(ut,{disabled:l||b===0,onClick:()=>y(b)}),e.jsx(pt,{disabled:l||b===n.length-1,onClick:()=>w(b)}),e.jsx(dt,{disabled:l,onClick:()=>k(b)})]})}],[j,C,u,T,f,c,l,m,k,y,w,n.length]);return C?e.jsxs(r.Stack,{sx:{width:"100%",gap:1},children:[t&&e.jsx(r.FormLabel,{children:t}),n.length>0?e.jsx(r.TableContainer,{component:r.Paper,variant:"outlined",sx:{borderRadius:1,mb:1},children:e.jsxs(r.Table,{size:"small",sx:{"& .MuiTableCell-root":{py:.25,px:1,whiteSpace:"nowrap"},"& .MuiTableCell-head":{backgroundColor:"action.hover",py:.25,px:1},borderCollapse:"collapse"},children:[e.jsx(r.TableHead,{sx:{display:"none"},children:e.jsx(r.TableRow,{children:S.map(b=>e.jsx(r.TableCell,{width:b.width,align:b.align||"left",sx:{fontWeight:"bold"},children:b.renderHeader?b.renderHeader():b.headerName},b.field))})}),e.jsx(r.TableBody,{children:n.map((b,v,P)=>e.jsx(r.TableRow,{sx:{borderBottom:v<P.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:S.map(B=>e.jsx(r.TableCell,{width:B.width,align:B.align||"left",sx:{borderBottom:"none"},children:B.renderCell({row:b,index:v,onChange:z=>T(v,z)})},`${v}-${B.field}`))},v))})]})}):e.jsx(M.default,{style:{fontSize:12,height:p},children:c("maker.properties.arrayEmpty")}),e.jsx(r.Button,{fullWidth:!0,size:"small",variant:"outlined",disabled:l,startIcon:e.jsx(Ye.default,{}),onClick:g,children:c("maker.properties.addArrayItem")})]}):e.jsxs(r.Stack,{sx:{width:"100%",gap:1},children:[t&&e.jsx(r.FormLabel,{children:t}),e.jsx(r.Box,{sx:{border:1,borderColor:"divider",borderRadius:1,minHeight:150},children:e.jsx(se.CodeEditor,{keyId:u.id,locale:d,language:"json",value:JSON.stringify(n,null,2),onChange:b=>h(b||""),fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},u.id)})]})}function mt({ref:t,showMarkdown:s,markdown:o,onMarkdownChange:l,showUploader:f,value:p,meta:u,onChange:j,...m}){const[c,d]=I.useState("");I.useEffect(()=>{d(p||"")},[p,d]);const a=async()=>{if(c!==p){const n=N.getImageAbsoluteUrl(c);if(!n){j(c,void 0);return}const x=await V.getImageSize(n).catch(()=>V.getVideoSize(n)).catch(()=>{});j(c,{...x,filename:c})}};ne.useDebounce(()=>{c!==p&&j(c)},300,[c]),I.useImperativeHandle(t,()=>({submit:a}));const i={};return f&&(i.InputProps={sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mx:.5},children:e.jsx(V.UploaderButton,{onChange:async({response:n})=>{const x=n?.data?.filename,g=N.getImageAbsoluteUrl(x)||"";let h={};g&&(h=await V.getImageSize(g).catch(()=>V.getVideoSize(g)).catch(()=>{})),j(x,{...h,filename:x})}})})}),e.jsx(r.TextField,{size:"small",fullWidth:!0,...m,label:e.jsxs(r.Stack,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[m.label,s&&e.jsxs(e.Fragment,{children:[" (",e.jsx(r.FormControlLabel,{checked:o,label:e.jsx(r.Box,{component:Te.Icon,icon:"tabler:markdown",sx:{verticalAlign:"middle"}}),labelPlacement:"start",control:e.jsx(r.Switch,{size:"small"}),sx:{ml:.25,pr:1},onChange:(n,x)=>l?.(x)}),")"]})]}),value:c,onChange:n=>d(n.target.value),...i,onKeyDown:n=>{n.keyCode!==229&&n.key==="Enter"&&a()},slotProps:{inputLabel:{shrink:!0,...m.InputLabelProps}}})}function ft({value:t,onChange:s,disableGradient:o=!1,...l}){const f=I.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(mt,{...l,value:t,onChange:s,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(ie.ColorItem,{color:t??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{f.current?.open({value:t??""})}})})}}),e.jsx(ie.ConfigColorDialog,{ref:f,onSave:({value:p},u)=>{s(p),u()},disableGradient:o})]})}function ht({label:t,value:s,onChange:o,property:l,component:f,defaultLocale:p,allComponents:u,PropertyValueField:j,onUpload:m}){const{locale:c}=R.useLocaleContext(),d=I.useRef(null);if(!E.default(l.subProperties)){const i=_.default(Object.values(l.subProperties||{}),"index").filter(n=>n.data.visible!==!1&&n.data.key);return e.jsxs(r.Stack,{sx:{width:"100%"},children:[e.jsx(r.FormLabel,{sx:{px:.25,py:.5},children:t}),e.jsx(r.Box,{children:e.jsx(r.Box,{sx:{position:"relative"},children:i.map((n,x)=>{const{data:g}=n,h=g.key??g.id,k=x===i.length-1;let y=null;try{s&&typeof s=="object"?y=s[h]:typeof s=="string"&&(y=(l.type==="yaml"?Z.parse(s||""):JSON.parse(s||"{}"))[h])}catch{}y==null&&(g.locales&&c&&g.locales[c]?y=g.locales[c].defaultValue:g.locales&&p&&g.locales[p]&&(y=g.locales[p].defaultValue));const w=C=>{try{let S={};if(typeof s=="string")try{S=l.type==="yaml"?Z.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(S={...s});ue.default(S,h,C);const b=N.transformValue(S,l.type);o?.(b)}catch(S){console.error("Error updating property:",S)}},T=8;return e.jsxs(r.Box,{sx:{mb:k?0:1,display:"flex",flexDirection:"row"},children:[e.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[e.jsx(r.Box,{sx:{position:"absolute",left:T,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:T,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!k&&e.jsx(r.Box,{sx:{position:"absolute",left:T,top:16,bottom:-8,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsx(r.Box,{sx:{flexGrow:1},children:e.jsx(j,{component:f,property:g,value:y,onChange:w,size:"small",fullWidth:!0,defaultLocale:p,allComponents:u})})]},g.id)})})})]})}return e.jsx(r.Stack,{sx:{width:"100%",gap:2},children:e.jsxs(r.Stack,{sx:{width:"100%",position:"relative",pt:1,pb:"6px",px:"1px",minHeight:50,".monaco-editor,.overflow-guard":{borderRadius:1}},children:[e.jsx(r.FormLabel,{sx:{position:"absolute",left:0,top:0,transform:"translate(0px, -7px) scale(0.75)"},children:t}),e.jsx(se.CodeEditor,{keyId:l.id,locale:c,language:l.type==="yaml"?"yaml":"json",value:typeof s=="string"?s:"",onChange:i=>{o?.(i)},onUpload:i=>{d.current=i,m&&m(i)},fullScreenOptions:{enableEscExit:!0,targetContainer:()=>document.getElementById("parameters-config-dialog")||null}},l.id),e.jsx(r.Box,{component:"fieldset",sx:{pointerEvents:"none",position:"absolute",left:0,top:-5,width:"100%",height:"100%",border:1,borderColor:"rgba(0, 0, 0, 0.23)",borderRadius:1,px:1,py:0},children:e.jsx(r.Box,{component:"legend",sx:{fontSize:"0.75em"},children:e.jsx(r.Box,{component:"span",sx:{opacity:0},children:t})})})]})})}function le(t){return!!t.shared}const bt={setActivatorNodeRef:()=>{},attributes:{},listeners:{}};function pe({disabled:t,list:s,renderItem:o,...l}){const f=_.default(Object.entries(s),([,x])=>x.index),p=f.map(([x])=>x),[u,j]=I.useState(null),[m,c]=I.useState(null),d=L.useSensors(L.useSensor(L.PointerSensor,{activationConstraint:{distance:8}})),a=x=>{const{active:g}=x,h=s[g.id];h&&(c(g.id),j(h.data))},i=()=>{},n=x=>{const{active:g,over:h}=x;if(c(null),j(null),!h||g.id===h.id)return;const k=g.id,y=h.id;if(s[k]&&s[y]){const w=()=>{const S=Object.entries(s).sort(([,B],[,z])=>B.index-z.index),b=S.findIndex(([B])=>B===k),v=S.findIndex(([B])=>B===y),[P]=S.splice(b,1);P&&S.splice(v,0,P),S.forEach(([,B],z)=>{B.index=z})},T=U.getYjsValue(s)?.doc;T?T.transact(()=>{w()}):w()}};return e.jsxs(L.DndContext,{sensors:d,collisionDetection:L.closestCorners,onDragStart:a,onDragOver:i,onDragEnd:n,children:[e.jsx(X.SortableContext,{items:p,strategy:X.verticalListSortingStrategy,children:e.jsx(r.Stack,{...l,children:f.map(([x,g],h)=>e.jsx(gt,{id:x,disabled:t,isDragging:m===x,children:({dragHandle:k})=>o(g.data,h,{isDragging:m===x,dragHandle:k,drag:null,drop:null,preview:null})},x))})}),e.jsx(L.DragOverlay,{children:u&&m?e.jsx(r.Box,{sx:{opacity:.8,backgroundColor:"background.paper",border:"1px solid",borderColor:"primary.main",borderRadius:1,boxShadow:2,maxWidth:400},children:o(u,0,{isDragging:!0,dragHandle:bt,drag:null,drop:null,preview:null})}):null})]})}function gt({id:t,disabled:s,isDragging:o,children:l}){const{attributes:f,listeners:p,setNodeRef:u,setActivatorNodeRef:j,transform:m,transition:c}=X.useSortable({id:t,disabled:s}),d={transform:$e.CSS.Transform.toString(m),transition:c,opacity:o?.5:1};return e.jsx(r.Box,{ref:u,style:d,children:l({dragHandle:{setActivatorNodeRef:j,attributes:f??{},listeners:{...p??{}}}})})}function jt({disabled:t,isDragging:s,children:o,onDelete:l,onVisibilityChange:f,visible:p=!0,onSharedChange:u,shared:j=!1,actions:m,alwaysShowActions:c=!1,dragHandle:d}){const{t:a}=R.useLocaleContext(),i=d?.attributes??{},n=d?.listeners??{},x=d?.setActivatorNodeRef;return e.jsx(r.Box,{sx:{":hover .hover-visible":{maxWidth:"100%"},opacity:p?1:.5},children:e.jsxs(r.Box,{sx:{position:"relative"},children:[e.jsx(r.Box,{sx:{flex:1,borderRadius:.5,bgcolor:s?"action.hover":"background.paper",opacity:.9999},children:o}),!t&&e.jsx(r.Box,{className:c?"":"hover-visible",sx:{maxWidth:c?"100%":0,overflow:"hidden",position:"absolute",right:2,top:2,transition:"max-width 0.3s ease-in-out"},children:e.jsxs(r.Stack,{direction:"row",sx:{bgcolor:g=>r.alpha(g.palette.grey[200],.9),borderRadius:1,p:.5,[`.${r.buttonClasses.root}`]:{minWidth:24,width:24,height:24,p:0}},children:[m,u&&e.jsx(r.Tooltip,{title:a(j?"disableSharing":"enableSharing"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>u(!j),children:j?e.jsx(A.SyncRounded,{sx:{fontSize:"1.25rem",color:"primary.main"}}):e.jsx(A.SyncDisabledRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),f&&e.jsx(r.Tooltip,{title:a(p?"hideParameter":"showParameter"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:()=>f(!p),children:p?e.jsx(A.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):e.jsx(A.VisibilityRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),l&&e.jsx(r.Tooltip,{title:a("delete"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{onClick:l,children:e.jsx(A.DeleteOutlineRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}})})}),e.jsx(r.Tooltip,{title:a("dragSort"),disableInteractive:!0,placement:"top",children:e.jsx(r.Button,{ref:x,...i,...n,children:e.jsx(A.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function yt(t){const s=["string","json","array","url","multiline"],o=["style","fontSize","color","content","type"];return!!(s.includes(t.type||"")&&!o.includes(t.key||""))}function vt(t,s,o){return t.locales&&t.locales[s]&&t.locales[s].name?t.locales[s].name:o&&t.locales&&t.locales[o]&&t.locales[o].name?t.locales[o].name:t.key?t.key:t.id}const xe=(t,s,o,l)=>{const f={};return _.default(Object.entries(t),([,u])=>u.index).forEach(([u,j])=>{const m=j.data;if(!m)return;const c=m.key||m.id,d=o?vt(m,o,l||""):c,a=s?.[m.id],i={key:c,isNeedGenerate:a?.isNeedGenerate??yt(m),describe:a?.describe??"",displayName:d};m.subProperties&&!E.default(m.subProperties)&&(i.subProperties=xe(m.subProperties,a?.subProperties,o,l)),f[m.id]=i}),f};function Ct({open:t,onClose:s,onConfirm:o,component:l,initialConfig:f,locale:p,defaultLocale:u,title:j,loading:m=!1}){const{t:c}=R.useLocaleContext(),[d,a]=I.useState(null);I.useEffect(()=>{if(t&&l){const h={properties:{}};if(l.properties){const k=f?.properties;h.properties=xe(l.properties,k,p,u)}a(h)}},[t,l,f,p,u]);const i=()=>{s()},n=()=>{d&&(o(d),s())},x=(h,k,y)=>{if(!d||!h.length)return;const w=JSON.parse(JSON.stringify(d));let T=w.properties,C=null;for(let b=0;b<h.length-1;b++){const v=h[b];if(!v||!T[v])return;C=T;const P=T[v];P.subProperties||(P.subProperties={}),T=P.subProperties}const S=h[h.length-1];if(S){if("isNeedGenerate"in y){const b=y.isNeedGenerate,v={...k,...y};if(k.subProperties&&!E.default(k.subProperties)){const P=(B,z)=>{const q={};return Object.entries(B).forEach(([ve,W])=>{const Y={...W};z!==null&&(Y.isNeedGenerate=z),W.subProperties&&!E.default(W.subProperties)&&(Y.subProperties=P(W.subProperties,z!==null?z:null)),q[ve]=Y}),q};v.subProperties=P(k.subProperties,b===!1?!1:null)}if(h.length===1)w.properties[S]=v;else if(C&&h.length>=2){const P=h[h.length-2];P&&C[P]&&(C[P].subProperties||(C[P].subProperties={}),C[P].subProperties[S]=v)}}else if(h.length===1)w.properties[S]={...k,...y};else if(C&&h.length>=2){const b=h[h.length-2];b&&C[b]&&C[b].subProperties&&(C[b].subProperties[S]={...k,...y})}a(w)}},g=(h,k=[],y=!0)=>{if(!h||E.default(h))return e.jsx(M.default,{children:c("maker.properties.noProperties")});const w=_.default(Object.entries(h),([,T])=>T.displayName);return e.jsx(r.Stack,{spacing:1.5,children:w.map(([T,C],S)=>{const b=[...k,T],v=S===w.length-1,P=C.subProperties&&!E.default(C.subProperties),B=C.displayName||T,z=!y;return e.jsx(r.Box,{sx:{position:"relative"},children:e.jsxs(r.Stack,{direction:"row",children:[k.length>0&&e.jsxs(r.Box,{sx:{position:"relative",width:24,flexShrink:0},children:[e.jsx(r.Box,{sx:{position:"absolute",left:8,top:0,height:16,width:0,borderLeft:"1px dashed",borderColor:"divider"}}),e.jsx(r.Box,{sx:{position:"absolute",left:8,top:16,width:12,height:0,borderTop:"1px dashed",borderColor:"divider"}}),!v&&e.jsx(r.Box,{sx:{position:"absolute",left:8,top:16,bottom:-12,width:0,borderLeft:"1px dashed",borderColor:"divider"}})]}),e.jsxs(r.Stack,{spacing:1.5,sx:{flexGrow:1},children:[e.jsxs(r.Stack,{direction:{xs:"column",md:"row"},spacing:1.5,sx:{alignItems:{xs:"flex-start",md:"center"},width:"100%"},children:[e.jsx(r.FormControlLabel,{control:e.jsx(r.Checkbox,{checked:C.isNeedGenerate,disabled:z,onChange:q=>{x(b,C,{isNeedGenerate:q.target.checked})}}),label:B,sx:{minWidth:"180px",maxWidth:"280px",mr:2,"& .MuiFormControlLabel-label":{wordBreak:"break-word"}}}),e.jsx(r.TextField,{size:"small",fullWidth:!0,label:c("maker.properties.llmPropertyDescribe"),value:C.describe,onChange:q=>{x(b,C,{describe:q.target.value})},disabled:!C.isNeedGenerate})]}),P&&e.jsx(r.Box,{sx:{ml:3},children:g(C.subProperties,b,C.isNeedGenerate&&y)})]})]})},T)})})};return e.jsxs(r.Dialog,{open:t,onClose:i,maxWidth:"lg",fullWidth:!0,children:[e.jsx(r.DialogTitle,{children:j||c("maker.properties.llmConfigTitle")}),e.jsx(r.DialogContent,{children:e.jsx(r.Box,{sx:{my:3},children:m?e.jsx(r.Typography,{children:c("maker.properties.loading")}):l?d?e.jsxs(r.Stack,{spacing:3,children:[e.jsx(r.Typography,{variant:"subtitle2",children:c("maker.properties.llmConfigInstructions")}),g(d.properties)]}):e.jsx(r.Typography,{children:c("maker.properties.loading")}):e.jsx(r.Typography,{color:"error",children:c("maker.properties.componentNotFound")})})}),e.jsxs(r.DialogActions,{children:[e.jsx(r.Button,{onClick:i,children:c("common.cancel")}),e.jsx(r.Button,{variant:"contained",onClick:n,disabled:!d||m,children:c("common.confirm")})]})]})}function kt({label:t,value:s,onChange:o}){const[l,f]=I.useState(!1);return e.jsxs(r.Stack,{sx:{gap:1},children:[e.jsx(r.TextField,{label:t,size:"small",value:s,onChange:p=>o?.(p.target.value),slotProps:{input:{sx:{pr:0},endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(V.UploaderButton,{onChange:({response:p})=>{const u=p?.data?.filename;u&&o?.(u)}})})}}}),s&&e.jsx(r.Box,{component:"img",src:N.getImageAbsoluteUrl(s),alt:t,onClick:()=>f(!0),sx:{maxWidth:100,maxHeight:100,width:"100%",objectFit:"contain",borderRadius:1,cursor:"pointer"}}),e.jsx(r.Dialog,{open:l,onClose:()=>f(!1),children:e.jsx(r.Box,{component:"img",sx:{objectFit:"contain"},src:N.getImageAbsoluteUrl(s),alt:t})})]})}function re(t,s=""){return at.default(t,(o,l,f)=>{const p=s?`${s}.${f}`:f;return nt.default(l)?et.default(o,re(l,p)):o[p]=l,o},{})}const St=[{value:"string",label:"Text"},{value:"multiline",label:"Text (Multiline)"},{value:"number",label:"Number"},{value:"decimal",label:"Decimal"},{value:"boolean",label:"Boolean"},{value:"color",label:"Color"},{value:"url",label:"URL (Upload)"},{value:"json",label:"JSON"},{value:"yaml",label:"YAML"},{value:"array",label:"Array"},{value:"component",label:"Component"},{value:"custom",label:"Custom (Render by a Component)"}];function K(t,s,o){return!t||!o?!1:Object.values(t).some(({data:l})=>l.id!==s&&l.key===o)}function J(t,s){return!t||!s?!1:t[s]?.data.visible??!0}function me(t,s){return!t||!s?!1:t[s]?.data.shared??!1}function Pt({componentId:t}){const{state:{components:s}}=N.useStore(),l=s[t]?.data;return l?e.jsx(r.Stack,{sx:{maxHeight:"100%",overflow:"auto"},children:e.jsx(r.Box,{sx:{p:2},children:e.jsx(Je.ErrorBoundary,{FallbackComponent:ct,resetKeys:[t],children:e.jsx(wt,{value:l,componentId:t})})})}):null}function wt({value:t,componentId:s}){const{t:o}=R.useLocaleContext(),{localState:{currentLocale:l,customComponentPreviewerProperties:f},state:{config:{defaultLocale:p}},localActions:{setCustomComponentPreviewerProperties:u}}=N.useStore(),j=U.getYjsValue(t).doc,m=N.useAllComponents(),c=I.useMemo(()=>f?.[s]??{},[s,f]),d=t.renderer?.type||"react-component",a=d==="component-template",i=Q.useReactive({componentId:s,propertiesValue:{...c}});return I.useEffect(()=>{i.componentId!==s&&(i.componentId=s,i.propertiesValue={...c})},[s,c,i]),Q.useDeepCompareEffect(()=>{if(i.componentId!==s)return;const n=Object.fromEntries(Object.values(t.properties??{}).map(({data:x})=>[x.id,{value:i.propertiesValue[x.id]?.value??_e.parsePropertyValue(x,x.locales?.[l]?.defaultValue??x.locales?.[p]?.defaultValue,{locale:l,defaultLocale:p})}]));u(s,n)},[i.propertiesValue,s,i.componentId]),e.jsx(r.Stack,{sx:{height:"100%"},children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsx(fe,{config:t}),e.jsxs(e.Fragment,{children:[e.jsx(be,{config:t,currentLocale:l,defaultLocale:p,allComponents:m,onUpdateConfig:n=>{j.transact(()=>{n(t)})}}),e.jsxs(r.Stack,{direction:"row",sx:{gap:2,justifyContent:"space-between",alignItems:"center"},children:[e.jsx(r.Typography,{variant:"subtitle1",children:o("renderer")}),e.jsxs(r.TextField,{hiddenLabel:!0,size:"small",select:!0,value:d,disabled:a,onChange:n=>{j.transact(()=>{const x=n.target.value;t.renderer??={type:x},t.renderer.type=x})},slotProps:{select:{autoWidth:!0}},children:[e.jsx(r.MenuItem,{value:"component-template",disabled:!0,children:o("maker.components.componentTemplate")}),e.jsx(r.MenuItem,{value:"react-component",children:"React Component"}),e.jsx(r.MenuItem,{value:"component",children:"Custom Component"})]})]}),d==="component"&&e.jsx(zt,{value:t}),d==="react-component"&&e.jsx(At,{value:t}),e.jsx(oe,{config:t,currentLocale:l,defaultLocale:p,allComponents:m,propertiesValue:i.propertiesValue,onChange:({value:n,id:x,path:g})=>{const h=[...g,"data"];if(!tt.default(t,h)){te.default.warning(o("cannotFindPropertyKey",{key:h.join(".")}));return}i.propertiesValue[x]={value:n.value}}})]})]})})}function fe({config:t}){const{t:s}=R.useLocaleContext();return e.jsx(V.UploaderProvider,{children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsx(r.Typography,{variant:"subtitle1",children:s("basicInfo")}),e.jsx(r.TextField,{label:s("name"),size:"small",value:t.name||"",onChange:o=>t.name=o.target.value}),e.jsx(r.TextField,{label:s("description"),size:"small",multiline:!0,minRows:2,maxRows:8,value:t.description||"",onChange:o=>t.description=o.target.value,slotProps:{input:{endAdornment:e.jsx(r.InputAdornment,{position:"end",sx:{mt:-1.5},children:e.jsx(Vt,{config:t})})},htmlInput:{maxLength:2048}}}),e.jsx(r.Autocomplete,{size:"small",options:[],multiple:!0,freeSolo:!0,value:t.tags??[],onChange:(o,l)=>t.tags=l,renderInput:o=>e.jsx(r.TextField,{label:s("tags"),...o})}),e.jsx(kt,{label:s("previewImage"),value:t.previewImage||"",onChange:o=>t.previewImage=o})]})})}function he({data:t,params:s,visible:o,shared:l,config:f,currentLocale:p,defaultLocale:u,allComponents:j,onUpdateConfig:m}){const{t:c}=R.useLocaleContext(),d=I.useMemo(()=>t.type==="json"||t.type==="yaml"||t.type==="array"?Ot:F,[t.type]);return e.jsx(jt,{preview:s.preview,drop:s.drop,drag:s.drag,isDragging:s.isDragging,dragHandle:s.dragHandle,onDelete:()=>{m(a=>{if(a.properties){const n=Object.entries(a.properties).sort(([,g],[,h])=>g.index-h.index);delete a.properties[t.id],n.filter(([g])=>g!==t.id).forEach(([,g],h)=>{g.index=h})}})},visible:o,onVisibilityChange:a=>{m(i=>{const n=i.properties[t.id].data;n.visible=a})},shared:l,onSharedChange:a=>{m(i=>{const n=i.properties[t.id].data;n.shared=a})},alwaysShowActions:!0,children:e.jsxs(r.Stack,{direction:"column",sx:{gap:2},children:[e.jsx(r.TextField,{label:c("key"),size:"small",required:!0,sx:{width:"calc(100% - 104px - 8px)",flex:1,"& .MuiOutlinedInput-root":{borderColor:t.key?K(f.properties,t.id,t.key)?"warning.main":void 0:"error.main"},"& .MuiFormLabel-root":{color:t.key?K(f.properties,t.id,t.key)?"warning.main":"text.secondary":"error.main"},"& .MuiFormLabel-root.Mui-focused":{color:t.key?K(f.properties,t.id,t.key)?"warning.main":"primary.main":"error.main"}},value:t.key||"",onChange:a=>{m(i=>{const n=i.properties[t.id].data;n.key=a.target.value.trim()})},slotProps:{input:{endAdornment:!t.key||t.key&&K(f.properties,t.id,t.key)?e.jsx(r.InputAdornment,{position:"end",sx:{width:16,ml:0},children:e.jsx(r.Tooltip,{title:t.key?c("duplicateKey"):c("requiredKey"),children:e.jsx(A.InfoRounded,{sx:{color:t.key?"warning.main":"error.main",fontSize:16}})})}):null}}}),e.jsxs(r.Stack,{direction:"row",sx:{gap:1},children:[e.jsx(r.TextField,{label:c("label"),size:"small",sx:{flex:1},value:(t.locales?.[p]?.name??t.locales?.[u]?.name)||"",onChange:a=>{m(i=>{const n=i.properties[t.id].data;n.locales??={},n.locales[p]??={},n.locales[p].name=a.target.value})}}),e.jsx(r.TextField,{label:c("type"),size:"small",select:!0,sx:{flex:1},value:t.type==="string"&&t.multiline?"multiline":t.type||"string",onChange:a=>{m(i=>{const n=i.properties[t.id].data;if(n.locales)for(const g of Object.keys(n.locales))n.locales[g].defaultValue=void 0;const x=a.target.value;x==="multiline"?(n.type="string",n.multiline=!0):(typeof n.multiline<"u"&&delete n.multiline,n.type=x)})},children:St.map(a=>e.jsx(r.MenuItem,{value:a.value,children:a.label},a.value))})]}),e.jsxs(r.Stack,{direction:"row",sx:{gap:1},children:[e.jsx(d,{allComponents:j,defaultLocale:u,component:f,property:t,label:c("defaultValue"),size:"small",fullWidth:!0,value:t.locales?.[p]?.defaultValue,onChange:(a,i)=>{m(n=>{const x=n.properties[t.id].data;if(i?.forceUpdateProperty){const g=re(x),h=re(a);Object.keys(h).forEach(k=>{g[k]||ue.default(x,k,h[k])})}else x.locales??={},x.locales[p]??={},x.locales[p].defaultValue=a})}}),t.type==="custom"?e.jsx(r.Box,{children:e.jsx(Tt,{property:t,allComponents:j})}):null]})]})})}function It(t,s){const[o,l]=I.useState(0);return I.useEffect(()=>{const p=setTimeout(()=>{if(t.current){let u=t.current.parentElement,j=0;for(;u;)u.classList.contains("property-container")&&j++,u=u.parentElement;l(j)}},100);return()=>clearTimeout(p)},[t,s]),o}function be({config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:f,useI18nEditor:p=!0}){const{t:u}=R.useLocaleContext(),j=D.usePopupState({variant:"dialog"}),m=t.properties&&_.default(Object.values(t.properties),"index");return e.jsx(V.UploaderProvider,{children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsxs(r.Stack,{direction:"row",sx:{gap:1,alignItems:"center",justifyContent:"space-between"},children:[e.jsx(r.Typography,{variant:"subtitle1",children:u("properties")}),e.jsx(r.Box,{sx:{flex:1}}),p&&e.jsx(r.Button,{sx:{minWidth:32,minHeight:32,p:0},...D.bindTrigger(j),children:e.jsx(A.TranslateRounded,{fontSize:"small"})})]}),t.properties&&Object.keys(t.properties).length>0?e.jsx(pe,{component:r.Stack,gap:2,list:t.properties,renderItem:(c,d,a)=>{const i=J(t.properties,c.id),n=me(t.properties,c.id);return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed",borderColor:"divider"},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(he,{data:c,params:a,visible:i,shared:n,config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:f})})},c.id)}}):e.jsx(M.default,{style:{fontSize:12},children:u("maker.properties.noProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",onClick:()=>{f(c=>{const d=de.nextId();c.properties??={},c.properties[d]??={index:m?.length||0,data:{id:d,shared:!1}}})},startIcon:e.jsx(A.AddRounded,{}),children:u("addObject",{object:u("property")})}),p&&e.jsx(ge,{...D.bindDialog(j),component:t})]})})}function Tt({property:t,allComponents:s}){const o=D.usePopupState({variant:"popper"});return e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},...D.bindTrigger(o),children:e.jsx(A.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...D.bindPopper(o),children:e.jsx(ce.ClickAwayListener,{onClickAway:o.close,children:e.jsx(r.Paper,{children:e.jsx(r.Box,{sx:{width:500,p:2},children:e.jsx(G,{value:t.componentId,onChange:(l,f)=>t.componentId=f,allComponents:s})})})})})]})}function Bt({value:t,valueImmutable:s,onChange:o,defaultLocale:l,allComponents:f}){const[p,u]=I.useState(!1),{t:j,locale:m}=R.useLocaleContext(),c=typeof t?.componentId=="string"?f[t.componentId]?.data:void 0;return c?e.jsxs(r.Box,{sx:{width:"100%",position:"relative"},children:[e.jsx(r.IconButton,{sx:{minWidth:0},disabled:!c,size:"small",onClick:()=>u(!p),color:p?"primary":"default",children:e.jsx(A.SettingsRounded,{fontSize:"small"})}),p&&e.jsx(r.Collapse,{in:p,timeout:"auto",unmountOnExit:!0,sx:{width:"100%",zIndex:10},children:e.jsxs(r.Paper,{elevation:1,sx:{mt:1,p:2,borderRadius:1,border:"1px solid",borderColor:"divider",width:"100%"},children:[e.jsx(r.Box,{sx:{width:"100%",mb:2},children:e.jsx(oe,{config:c,currentLocale:m,defaultLocale:l,allComponents:f,propertiesValue:t?.properties,onChange:({id:d,value:a})=>{const i=ee.default(a.value),n=JSON.parse(JSON.stringify(t));n?.componentId&&(s?o?.({...n,properties:{...n.properties,[d]:{value:i}}}):(n.properties=n.properties??{},n.properties[d]={value:i},o?.(n)))}})}),e.jsx(r.Button,{size:"small",onClick:()=>u(!1),sx:{mt:1},children:j("close")})]})})]}):null}function ge({type:t="properties",component:s,...o}){const{t:l}=R.useLocaleContext(),{state:{components:f,supportedLocales:p,config:{defaultLocale:u}}}=N.useStore(),j=N.useAllComponents(),m=U.getYjsValue(s).doc,c=t==="properties"?s.properties:t==="parameters"&&s.renderer?.type==="component"?f[s.renderer.componentId]?.data.properties:void 0,d=s.renderer?.type==="component"?s:void 0;return e.jsxs(r.Dialog,{...o,fullWidth:!0,maxWidth:"lg",children:[e.jsx(r.DialogTitle,{children:l("i18nEditorTitle")}),e.jsx(r.DialogContent,{children:c&&e.jsx(r.Stack,{children:e.jsxs(r.Table,{stickyHeader:!0,sx:{td:{verticalAlign:"top"}},children:[e.jsx(r.TableHead,{children:e.jsx(r.TableRow,{children:p.map(({locale:a,name:i})=>e.jsx(r.TableCell,{children:e.jsxs(r.Typography,{sx:{color:"text.primary"},children:[i,u===a&&e.jsx(A.StarRounded,{sx:{fontSize:12}})]})},a))})}),e.jsx(r.TableBody,{children:_.default(Object.values(c),"index").map(({data:a})=>e.jsx(r.TableRow,{children:p.map(({locale:i})=>e.jsx(r.TableCell,{children:e.jsx(r.Stack,{sx:{gap:1},children:t==="properties"?e.jsxs(e.Fragment,{children:[e.jsx(r.TextField,{size:"small",label:"Key",value:a.key||"",onChange:n=>{m.transact(()=>{a.key=n.target.value.trim()})}}),e.jsx(r.TextField,{size:"small",label:l("label"),value:(a.locales?.[i]?.name??a.locales?.[u]?.name)||"",onChange:n=>{m.transact(()=>{a.locales??={},a.locales[i]??={},a.locales[i].name=n.target.value})}}),e.jsx(r.Box,{children:e.jsx(F,{allComponents:j,defaultLocale:u,component:s,property:a,size:"small",fullWidth:!0,label:"Default Value",valueImmutable:$.default(a.locales?.[i]?.defaultValue),value:a.locales?.[i]?.defaultValue??a.locales?.[u]?.defaultValue,onChange:n=>{m.transact(()=>{a.locales??={},a.locales[i]??={},a.locales[i].defaultValue=n})}})})]}):t==="parameters"&&d?e.jsx(r.Box,{children:e.jsx(F,{allComponents:j,defaultLocale:u,component:s,property:a,size:"small",fullWidth:!0,valueImmutable:$.default(d.renderer.properties?.[a.id]?.locales?.[i]?.value),value:d.renderer.properties?.[a.id]?.locales?.[i]?.value??d.renderer.properties?.[a.id]?.locales?.[u]?.value??a.locales?.[i]?.defaultValue??a.locales?.[u]?.defaultValue,onChange:n=>{m.transact(()=>{d.renderer.properties??={},d.renderer.properties[a.id]??={},d.renderer.properties[a.id].locales??={},d.renderer.properties[a.id].locales[i]??={},d.renderer.properties[a.id].locales[i].value=n})}})}):null},a.id)},i))},a.id))})]})})}),e.jsx(r.DialogActions,{children:e.jsx(r.Button,{onClick:a=>o.onClose?.(a,"escapeKeyDown"),children:l("close")})})]})}const ae=(t,s)=>o=>{const l=[o.palette.info.main,o.palette.primary.main,o.palette.secondary.main,o.palette.success.main,o.palette.warning.main],f=Math.min(l.length-1,t),p=l[f],u=r.alpha(p,.5),j=r.alpha(p,1);return{borderColor:`${u} !important`,borderLeft:"3px solid !important",borderLeftColor:u,color:j,...s}};function Ot({property:t,onChange:s,defaultLocale:o,allComponents:l}){const{t:f,locale:p}=R.useLocaleContext(),u=I.useRef(null),j=It(u,t),m=I.useCallback(()=>{if(!(t.type!=="json"&&t.type!=="yaml"&&t.type!=="array")&&t.subProperties)try{let c={};_.default(Object.values(t.subProperties),"index").filter(i=>i.data.visible!==!1&&i.data.key).forEach(({data:i})=>{if(!i.key)return;let n=i.locales?.[p]?.defaultValue??i.locales?.[o]?.defaultValue;if(i.type==="number")n=Number(n);else if(i.type==="boolean")n=n===!0||n==="true";else if((i.type==="json"||i.type==="yaml")&&typeof n=="string")try{i.type==="json"?n=JSON.parse(n):n=Z.parse(n)}catch(x){console.error("Error parsing nested value",n,x),n={}}c[i.key]=n}),t.type==="array"&&!Array.isArray(c)&&(c=E.default(c)?[]:[c]);const a=N.transformValue(c,t.type);s?.(a)}catch(c){console.error("Error converting structure to text:",c)}},[t,p,o,s]);return t.type!=="json"&&t.type!=="yaml"&&t.type!=="array"?null:e.jsxs(r.Stack,{direction:"column",ref:u,sx:{gap:1.5,width:"100%"},children:[e.jsx(r.Divider,{sx:{mt:-1},children:e.jsx(r.Typography,{variant:"caption",sx:{color:"text.secondary"},children:f("maker.properties.subProperties")})}),t.subProperties&&Object.keys(t.subProperties).length>0?e.jsx(pe,{component:r.Stack,gap:2,list:t.subProperties,renderItem:(c,d,a)=>{const i=c.visible!==!1,n=c.shared??!1;return e.jsx(r.Paper,{elevation:0,className:"property-container",sx:{p:1.25,borderRadius:1,border:i?"1px solid":"1px dashed","&":ae(j)},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(he,{data:c,params:a,visible:i,shared:n,config:{properties:t.subProperties},currentLocale:p,defaultLocale:o,allComponents:l,onUpdateConfig:x=>{try{const g={properties:t.subProperties||{}};x(g);const h={...t,subProperties:g.properties};s?.(h,{forceUpdateProperty:!0}),m()}catch(g){console.error("Error updating property:",g)}}})})},c.id)}}):e.jsx(M.default,{style:{fontSize:12,height:100},children:f("maker.properties.noSubProperties")}),e.jsx(r.Button,{fullWidth:!0,variant:"outlined",className:"ignore-style-override",size:"small",startIcon:e.jsx(A.AddRounded,{}),onClick:()=>{try{const c=t.subProperties||{},d=de.nextId(),i={index:Object.values(c).length,data:{id:d,key:"",type:"string",visible:!0,shared:!1,locales:{[p]:{name:"",defaultValue:""}},subProperties:{}}},n={...t,subProperties:{...c,[d]:i}};s?.(n,{forceUpdateProperty:!0}),m()}catch(c){console.error("Error adding property:",c)}},sx:{"&":ae(j,{})},children:f("maker.properties.addSubProperty")})]})}function F({component:t,property:s,value:o,onChange:l,valueImmutable:f,defaultLocale:p,allComponents:u,...j}){const{locale:m}=R.useLocaleContext(),c=V.useUploader(),d=I.useRef(null),a=()=>{const n=c?.current?.getUploader();n?.open(),d.current&&n.onceUploadSuccess(({response:x})=>{let g=x?.data?.filename||"";g&&(g=`mediakit://${g}`,o&&!o.includes("mediakit://")&&(g+=" # please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address")),d.current?.(g)})},i=j.label??(s.locales?.[m]?.name||s.locales?.[p]?.name||s.key||s.id);if(s.type==="number")return e.jsx(Rt,{...j,label:i,NumberProps:{value:["number","string"].includes(typeof o)?o:null,onChange:(n,x)=>l?.(x)}});if(s.type==="decimal")return e.jsx(r.TextField,{...j,label:i,type:"text",value:o??"",onChange:n=>{const x=n.target.value;if(x===""||x==="-"){l?.(x);return}if(/^-?(?!.*\..*\.)[0-9]*(\.[0-9]{0,9})?$/.test(x)){let h=x;/^-?[1-9]+[0-9]*(\.[0-9]{1,9})?$/.test(h)&&(h=Number(h)),l?.(h)}}});if(s.type==="boolean")return e.jsx(r.FormControlLabel,{label:i,labelPlacement:"start",control:e.jsx(r.Switch,{checked:o===!0,onChange:(n,x)=>l?.(x)})});if(s.type==="color")return e.jsx(ft,{label:i,value:o,onChange:n=>{l?.(n)}});if(s.type==="json"||s.type==="yaml")return e.jsx(ht,{label:i,value:o,onChange:n=>{l?.(n)},property:s,component:t,defaultLocale:p,allComponents:u,PropertyValueField:F,onUpload:n=>{d.current=n,a()}});if(s.type==="custom"){const n=u[s.componentId]?.data;return n?e.jsx(r.Box,{sx:{width:"100%"},children:e.jsx(H.CustomComponentRenderer,{componentId:n.id,props:{label:i,value:o,onChange:l},locale:m,dev:{mode:"draft",components:u,defaultLocale:p}})}):e.jsx(r.TextField,{...j,label:i,disabled:!0,placeholder:"Click right button select a component"})}if(s.type==="component")return e.jsxs(r.Stack,{direction:"column",sx:{width:"100%",gap:1},children:[e.jsx(G,{allComponents:u,label:i,value:o?.componentId,onChange:(n,x)=>{f||!o?l?.({...o&&JSON.parse(JSON.stringify(o)),componentId:x}):typeof o=="object"&&(o.componentId=x,l?.({...o&&JSON.parse(JSON.stringify(o)),componentId:x}))}}),o?.componentId&&e.jsx(Bt,{value:o,valueImmutable:f,onChange:l,defaultLocale:p,allComponents:u})]});if(!s.type||["string","url","multiline"].includes(s.type)){let n=s.type==="string"?s.multiline:void 0;s.type==="multiline"&&(n=!0);const x=s.type==="url"?o?.url:o;return e.jsx(r.TextField,{...j,label:i,value:typeof x=="string"?x:"",multiline:n,minRows:n?2:void 0,maxRows:n?10:void 0,onChange:g=>l?.(s.type==="url"?{...o,url:g.target.value,mediaKitUrl:g.target.value}:g.target.value),slotProps:{input:s.type==="url"?{sx:{pr:0},endAdornment:e.jsxs(r.InputAdornment,{position:"end",sx:{display:"flex",alignItems:"center",justifyContent:"center"},children:[e.jsx(V.UploaderButton,{onChange:async({response:g})=>{const h=g?.data?.url||g?.data?.fileUrl;let k;h&&(k=await V.getImageSize(h).catch(()=>V.getVideoSize(h)).catch(()=>{}));let y=g?.data?.filename||"";y&&(y=`mediakit://${y}`),l?.({url:h,mediaKitUrl:y,width:k?.naturalWidth,height:k?.naturalHeight})}}),e.jsx(r.Tooltip,{title:"If you are using the 'mediaKitUrl' property, please use < import { getMediaKitAbsoluteUrl } from '@blocklet/pages-kit/builtin/utils' > to get the full address.",children:e.jsx(A.InfoRounded,{sx:{cursor:"default",mr:1},fontSize:"small"})})]})}:void 0}})}return s.type==="array"?e.jsx(xt,{label:i,value:Array.isArray(o)?o:[],onChange:n=>l?.(n),property:s,renderItem:({item:n,index:x,onChange:g})=>s.subProperties&&Object.keys(s.subProperties).length>0?e.jsx(r.Stack,{sx:{gap:1,width:"100%"},children:_.default(Object.values(s.subProperties),"index").filter(h=>h.data.visible!==!1).map(({data:h})=>h.key?e.jsx(F,{component:t,property:h,value:n[h.key],onChange:k=>{const y={...n,[h.key]:k};g(y)},size:"small",fullWidth:!0,defaultLocale:p,allComponents:u},h.id):null)},x):e.jsx(r.TextField,{size:j.size,fullWidth:!0,value:n,onChange:h=>g(h.target.value)})}):(console.error("Unsupported property type",s.type),null)}function Rt({NumberProps:t,...s}){const{getInputProps:o}=ce.unstable_useNumberInput(t),l=o();return e.jsx(r.TextField,{...s,slotProps:{htmlInput:l}})}const je=`import React from '@blocklet/pages-kit/builtin/react'
|
|
2
2
|
import { Box } from '@blocklet/pages-kit/builtin/mui/material'
|
|
3
3
|
|
|
4
4
|
export default function () {
|
package/lib/cjs/site-state.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./chunks/components-aaduHC9E.js");const e=require("./chunks/site-state-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});require("./chunks/components-aaduHC9E.js");const e=require("./chunks/site-state-oC_X_C59.js"),u=require("@blocklet/pages-kit/utils/common");require("@blocklet/pages-kit/utils/page-model");require("@blocklet/pages-kit/utils/property");require("@blocklet/pages-kit/utils/route");require("@blocklet/sdk/lib/component");require("@blocklet/sdk/lib/config");require("@reactivedata/reactive");require("@syncedstore/core");require("fs");require("fs/promises");require("glob");require("lib0/decoding");require("lib0/encoding");require("lodash/cloneDeep");require("lodash/debounce");require("lodash/get");require("lodash/isEmpty");require("lodash/set");require("lodash/union");require("lru-cache");require("p-limit");require("path");require("sequelize");require("stream/promises");require("tar");require("ufo");require("wait-on");require("y-protocols/awareness");require("y-protocols/sync");require("yaml");require("yjs");const t=require("@blocklet/pages-kit/types/state");exports.PUBLISH_MODES=e.PUBLISH_MODES;exports.SITE_STATE_PATH=e.SITE_STATE_PATH;exports.STATE_MODES=e.STATE_MODES;exports.default=e.SiteState;exports.downloadAsset=e.downloadAsset;exports.downloadAssets=e.downloadAssets;exports.fromPackage=e.fromPackage;exports.getDefaultState=e.getDefaultState;exports.getResourceStates=e.getResourceStates;exports.initPackResourceStates=e.initPackResourceStates;exports.mergeState=e.mergeState;exports.toPackage=e.toPackage;exports.triggerReloadAllProjectResource=e.triggerReloadAllProjectResource;exports.updateResourceStatesByProjectId=e.updateResourceStatesByProjectId;Object.defineProperty(exports,"nextId",{enumerable:!0,get:()=>u.nextId});Object.keys(t).forEach(r=>{r!=="default"&&!Object.prototype.hasOwnProperty.call(exports,r)&&Object.defineProperty(exports,r,{enumerable:!0,get:()=>t[r]})});
|