@blocklet/pages-kit-inner-components 0.6.78 → 0.6.79
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/setting.js +1 -1
- package/lib/es/setting.js +2 -2
- package/package.json +3 -3
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"),V=require("./chunks/state-BdtFHk36.js"),ve=require("@arcblock/ux/lib/Empty"),R=require("@arcblock/ux/lib/Locale/context"),re=require("@blocklet/code-editor"),Ce=require("@mui/icons-material/AddRounded"),Se=require("@mui/icons-material/ArrowDownward"),ke=require("@mui/icons-material/ArrowUpward"),Pe=require("@mui/icons-material/DeleteOutline"),we=require("lodash/sortBy"),P=require("react"),se=require("react-use"),oe=require("@blocklet/pages-kit/builtin/color-picker"),z=require("@blocklet/pages-kit/builtin/uploader"),Ie=require("@iconify-icon/react"),Te=require("lodash/isEmpty"),Be=require("lodash/set"),Oe=require("yaml"),Re=require("lodash/cloneDeep"),Ne=require("@arcblock/ux/lib/Toast"),J=require("@blocklet/pages-kit/components"),Ae=require("@blocklet/pages-kit/utils/property"),ae=require("@mui/base"),N=require("@mui/icons-material"),U=require("@syncedstore/core"),ze=require("ahooks"),Ve=require("lodash/assign"),_e=require("lodash/get"),Ee=require("lodash/has"),De=require("lodash/isEqual"),Fe=require("lodash/isNil"),Le=require("lodash/isObject"),qe=require("lodash/keyBy"),Ue=require("lodash/omit"),Me=require("lodash/pick"),We=require("lodash/reduce"),E=require("material-ui-popup-state/hooks"),Ke=require("react-error-boundary"),q=require("@dnd-kit/core"),Q=require("@dnd-kit/sortable"),Je=require("@dnd-kit/utilities"),ce=require("@blocklet/pages-kit/utils/common"),O=t=>t&&t.__esModule?t:{default:t};function He(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(ve),$e=O(Ce),Ge=O(Se),Ye=O(ke),Qe=O(Pe),_=O(we),D=O(Te),de=O(Be),X=He(Oe),Z=O(Re),ee=O(Ne),Xe=O(Ve),Ze=O(_e),et=O(Ee),tt=O(De),$=O(Fe),rt=O(Le),st=O(qe),nt=O(Ue),ot=O(Me),it=O(We);function lt({error:t}){return e.jsx(r.Box,{children:e.jsx(r.Alert,{severity:"error",children:t.message})})}function at({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(Qe.default,{fontSize:"small"})})}function ct({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(Ye.default,{fontSize:"small"})})}function dt({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(Ge.default,{fontSize:"small"})})}function ut({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=se.useUpdate(),i=P.useCallback(b=>{o(V.transformValue(b,u.type))},[o,u.type]),n=P.useMemo(()=>Array.isArray(s)?s:[],[s]),x=P.useCallback(()=>{const b=[...n,""];i(b),a()},[n,i,a]),g=P.useCallback(()=>{if(!u||!u.subProperties)return x();const b={};_.default(Object.values(u.subProperties),"index").forEach(({data:B})=>{if(!B.key)return;const A=B.locales?.[d]?.defaultValue??"";b[B.key]=A});const w=[...n,b];i(w),a()},[n,i,a,u,d,x]),h=P.useCallback(b=>{try{const v=JSON.parse(b);Array.isArray(v)?i(v):console.error("JSON解析结果不是数组")}catch(v){console.error("JSON解析错误:",v)}},[i]),S=P.useCallback(b=>{const v=n.filter((w,B)=>B!==b);i(v),a()},[n,i,a]),y=P.useCallback(b=>{if(b<=0)return;const v=[...n],w=v[b];v[b]=v[b-1],v[b-1]=w,i(v),a()},[n,i,a]),I=P.useCallback(b=>{if(b>=n.length-1)return;const v=[...n],w=v[b];v[b]=v[b+1],v[b+1]=w,i(v),a()},[n,i,a]),T=P.useCallback((b,v)=>{const w=[...n];w[b]=v,i(w)},[n,i]),C=u&&u.subProperties&&Object.keys(u.subProperties).length>0,k=P.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:w=>T(v,w)}):e.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:l,value:b,placeholder:f||`${c("item")} ${v+1}`,onChange:w=>T(v,w.target.value),...m})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:b})=>e.jsxs(r.Stack,{direction:"column",spacing:.25,children:[e.jsx(ct,{disabled:l||b===0,onClick:()=>y(b)}),e.jsx(dt,{disabled:l||b===n.length-1,onClick:()=>I(b)}),e.jsx(at,{disabled:l,onClick:()=>S(b)})]})}],[j,C,u,T,f,c,l,m,S,y,I,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:k.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,w)=>e.jsx(r.TableRow,{sx:{borderBottom:v<w.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:k.map(B=>e.jsx(r.TableCell,{width:B.width,align:B.align||"left",sx:{borderBottom:"none"},children:B.renderCell({row:b,index:v,onChange:A=>T(v,A)})},`${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($e.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(re.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 pt({ref:t,showMarkdown:s,markdown:o,onMarkdownChange:l,showUploader:f,value:p,meta:u,onChange:j,...m}){const[c,d]=P.useState("");P.useEffect(()=>{d(p||"")},[p,d]);const a=async()=>{if(c!==p){const n=V.getImageAbsoluteUrl(c);if(!n){j(c,void 0);return}const x=await z.getImageSize(n).catch(()=>z.getVideoSize(n)).catch(()=>{});j(c,{...x,filename:c})}};se.useDebounce(()=>{c!==p&&j(c)},300,[c]),P.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(z.UploaderButton,{onChange:async({response:n})=>{const x=n?.data?.filename,g=V.getImageAbsoluteUrl(x)||"";let h={};g&&(h=await z.getImageSize(g).catch(()=>z.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:Ie.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 xt({value:t,onChange:s,disableGradient:o=!1,...l}){const f=P.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(pt,{...l,value:t,onChange:s,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(oe.ColorItem,{color:t??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{f.current?.open({value:t??""})}})})}}),e.jsx(oe.ConfigColorDialog,{ref:f,onSave:({value:p},u)=>{s(p),u()},disableGradient:o})]})}function mt({label:t,value:s,onChange:o,property:l,component:f,defaultLocale:p,allComponents:u,PropertyValueField:j,onUpload:m}){const{locale:c}=R.useLocaleContext(),d=P.useRef(null);if(!D.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,S=x===i.length-1;let y=null;try{s&&typeof s=="object"?y=s[h]:typeof s=="string"&&(y=(l.type==="yaml"?X.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 I=C=>{try{let k={};if(typeof s=="string")try{k=l.type==="yaml"?X.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(k={...s});de.default(k,h,C);const b=V.transformValue(k,l.type);o?.(b)}catch(k){console.error("Error updating property:",k)}},T=8;return e.jsxs(r.Box,{sx:{mb:S?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"}}),!S&&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:I,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(re.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 ie(t){return!!t.shared}const ft={setActivatorNodeRef:()=>{},attributes:{},listeners:{}};function ue({disabled:t,list:s,renderItem:o,...l}){const f=_.default(Object.entries(s),([,x])=>x.index),p=f.map(([x])=>x),[u,j]=P.useState(null),[m,c]=P.useState(null),d=q.useSensors(q.useSensor(q.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 S=g.id,y=h.id;if(s[S]&&s[y]){const I=()=>{const k=Object.entries(s).sort(([,B],[,A])=>B.index-A.index),b=k.findIndex(([B])=>B===S),v=k.findIndex(([B])=>B===y),[w]=k.splice(b,1);w&&k.splice(v,0,w),k.forEach(([,B],A)=>{B.index=A})},T=U.getYjsValue(s)?.doc;T?T.transact(()=>{I()}):I()}};return e.jsxs(q.DndContext,{sensors:d,collisionDetection:q.closestCorners,onDragStart:a,onDragOver:i,onDragEnd:n,children:[e.jsx(Q.SortableContext,{items:p,strategy:Q.verticalListSortingStrategy,children:e.jsx(r.Stack,{...l,children:f.map(([x,g],h)=>e.jsx(ht,{id:x,disabled:t,isDragging:m===x,children:({dragHandle:S})=>o(g.data,h,{isDragging:m===x,dragHandle:S,drag:null,drop:null,preview:null})},x))})}),e.jsx(q.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:ft,drag:null,drop:null,preview:null})}):null})]})}function ht({id:t,disabled:s,isDragging:o,children:l}){const{attributes:f,listeners:p,setNodeRef:u,setActivatorNodeRef:j,transform:m,transition:c}=Q.useSortable({id:t,disabled:s}),d={transform:Je.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 bt({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(N.SyncRounded,{sx:{fontSize:"1.25rem",color:"primary.main"}}):e.jsx(N.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(N.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):e.jsx(N.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(N.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(N.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function gt(t){const s=["string","json","array","url","multiline"],o=["style","fontSize","color","content","type"];return!!(s.includes(t.type||"")&&!o.includes(t.key||""))}function jt(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 pe=(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?jt(m,o,l||""):c,a=s?.[m.id],i={key:c,isNeedGenerate:a?.isNeedGenerate??gt(m),describe:a?.describe??"",displayName:d};m.subProperties&&!D.default(m.subProperties)&&(i.subProperties=pe(m.subProperties,a?.subProperties,o,l)),f[m.id]=i}),f};function yt({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]=P.useState(null);P.useEffect(()=>{if(t&&l){const h={properties:{}};if(l.properties){const S=f?.properties;h.properties=pe(l.properties,S,p,u)}a(h)}},[t,l,f,p,u]);const i=()=>{s()},n=()=>{d&&(o(d),s())},x=(h,S,y)=>{if(!d||!h.length)return;const I=JSON.parse(JSON.stringify(d));let T=I.properties,C=null;for(let b=0;b<h.length-1;b++){const v=h[b];if(!v||!T[v])return;C=T;const w=T[v];w.subProperties||(w.subProperties={}),T=w.subProperties}const k=h[h.length-1];if(k){if("isNeedGenerate"in y){const b=y.isNeedGenerate,v={...S,...y};if(S.subProperties&&!D.default(S.subProperties)){const w=(B,A)=>{const L={};return Object.entries(B).forEach(([ye,W])=>{const Y={...W};A!==null&&(Y.isNeedGenerate=A),W.subProperties&&!D.default(W.subProperties)&&(Y.subProperties=w(W.subProperties,A!==null?A:null)),L[ye]=Y}),L};v.subProperties=w(S.subProperties,b===!1?!1:null)}if(h.length===1)I.properties[k]=v;else if(C&&h.length>=2){const w=h[h.length-2];w&&C[w]&&(C[w].subProperties||(C[w].subProperties={}),C[w].subProperties[k]=v)}}else if(h.length===1)I.properties[k]={...S,...y};else if(C&&h.length>=2){const b=h[h.length-2];b&&C[b]&&C[b].subProperties&&(C[b].subProperties[k]={...S,...y})}a(I)}},g=(h,S=[],y=!0)=>{if(!h||D.default(h))return e.jsx(M.default,{children:c("maker.properties.noProperties")});const I=_.default(Object.entries(h),([,T])=>T.displayName);return e.jsx(r.Stack,{spacing:1.5,children:I.map(([T,C],k)=>{const b=[...S,T],v=k===I.length-1,w=C.subProperties&&!D.default(C.subProperties),B=C.displayName||T,A=!y;return e.jsx(r.Box,{sx:{position:"relative"},children:e.jsxs(r.Stack,{direction:"row",children:[S.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:A,onChange:L=>{x(b,C,{isNeedGenerate:L.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:L=>{x(b,C,{describe:L.target.value})},disabled:!C.isNeedGenerate})]}),w&&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 vt({label:t,value:s,onChange:o}){const[l,f]=P.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(z.UploaderButton,{onChange:({response:p})=>{const u=p?.data?.filename;u&&o?.(u)}})})}}}),s&&e.jsx(r.Box,{component:"img",src:V.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:V.getImageAbsoluteUrl(s),alt:t})})]})}function te(t,s=""){return it.default(t,(o,l,f)=>{const p=s?`${s}.${f}`:f;return rt.default(l)?Xe.default(o,te(l,p)):o[p]=l,o},{})}const Ct=[{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 H(t,s){return!t||!s?!1:t[s]?.data.visible??!0}function xe(t,s){return!t||!s?!1:t[s]?.data.shared??!1}function St({componentId:t}){const{state:{components:s}}=V.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(Ke.ErrorBoundary,{FallbackComponent:lt,resetKeys:[t],children:e.jsx(kt,{value:l,componentId:t})})})}):null}function kt({value:t,componentId:s}){const{t:o}=R.useLocaleContext(),{localState:{currentLocale:l,customComponentPreviewerProperties:f},state:{config:{defaultLocale:p}},localActions:{setCustomComponentPreviewerProperties:u}}=V.useStore(),j=U.getYjsValue(t).doc,m=V.useAllComponents(),c=P.useMemo(()=>f?.[s]??{},[s,f]),d=t.renderer?.type||"react-component",a=d==="component-template",i=ze.useReactive({componentId:s,propertiesValue:{...c}});return P.useEffect(()=>{i.componentId!==s&&(i.componentId=s,i.propertiesValue={...c})},[s,c,i]),P.useEffect(()=>{if(i.componentId!==s)return;const n=Object.fromEntries(Object.values(t.properties??{}).map(({data:x})=>[x.id,{value:i.propertiesValue[x.id]?.value??Ae.parsePropertyValue(x,x.locales?.[l]?.defaultValue??x.locales?.[p]?.defaultValue,{locale:l,defaultLocale:p})}]));u(s,n)},[JSON.stringify(i.propertiesValue),s,i.componentId]),e.jsx(r.Stack,{sx:{height:"100%"},children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsx(me,{config:t}),e.jsxs(e.Fragment,{children:[e.jsx(he,{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(Rt,{value:t}),d==="react-component"&&e.jsx(Ot,{value:t}),e.jsx(ne,{config:t,currentLocale:l,defaultLocale:p,allComponents:m,propertiesValue:i.propertiesValue,onChange:({value:n,id:x,path:g})=>{const h=[...g,"data"];if(!Ze.default(t,h)){ee.default.warning(o("cannotFindPropertyKey",{key:h.join(".")}));return}i.propertiesValue[x]={value:n.value}}})]})]})})}function me({config:t}){const{t:s}=R.useLocaleContext();return e.jsx(z.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:10,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(Nt,{config:t})})},htmlInput:{maxLength:200}}}),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(vt,{label:s("previewImage"),value:t.previewImage||"",onChange:o=>t.previewImage=o})]})})}function fe({data:t,params:s,visible:o,shared:l,config:f,currentLocale:p,defaultLocale:u,allComponents:j,onUpdateConfig:m}){const{t:c}=R.useLocaleContext(),d=P.useMemo(()=>t.type==="json"||t.type==="yaml"||t.type==="array"?Tt:F,[t.type]);return e.jsx(bt,{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(N.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:Ct.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=te(x),h=te(a);Object.keys(h).forEach(S=>{g[S]||de.default(x,S,h[S])})}else x.locales??={},x.locales[p]??={},x.locales[p].defaultValue=a})}}),t.type==="custom"?e.jsx(r.Box,{children:e.jsx(wt,{property:t,allComponents:j})}):null]})]})})}function Pt(t,s){const[o,l]=P.useState(0);return P.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 he({config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:f,useI18nEditor:p=!0}){const{t:u}=R.useLocaleContext(),j=E.usePopupState({variant:"dialog"}),m=t.properties&&_.default(Object.values(t.properties),"index");return e.jsx(z.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},...E.bindTrigger(j),children:e.jsx(N.TranslateRounded,{fontSize:"small"})})]}),t.properties&&Object.keys(t.properties).length>0?e.jsx(ue,{component:r.Stack,gap:2,list:t.properties,renderItem:(c,d,a)=>{const i=H(t.properties,c.id),n=xe(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(fe,{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=ce.nextId();c.properties??={},c.properties[d]??={index:m?.length||0,data:{id:d,shared:!1}}})},startIcon:e.jsx(N.AddRounded,{}),children:u("addObject",{object:u("property")})}),p&&e.jsx(be,{...E.bindDialog(j),component:t})]})})}function wt({property:t,allComponents:s}){const o=E.usePopupState({variant:"popper"});return e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},...E.bindTrigger(o),children:e.jsx(N.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...E.bindPopper(o),children:e.jsx(ae.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 It({value:t,valueImmutable:s,onChange:o,defaultLocale:l,allComponents:f}){const[p,u]=P.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(N.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(ne,{config:c,currentLocale:m,defaultLocale:l,allComponents:f,propertiesValue:t?.properties,onChange:({id:d,value:a})=>{const i=Z.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 be({type:t="properties",component:s,...o}){const{t:l}=R.useLocaleContext(),{state:{components:f,supportedLocales:p,config:{defaultLocale:u}}}=V.useStore(),j=V.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(N.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 le=(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 Tt({property:t,onChange:s,defaultLocale:o,allComponents:l}){const{t:f,locale:p}=R.useLocaleContext(),u=P.useRef(null),j=Pt(u,t),m=P.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=X.parse(n)}catch(x){console.error("Error parsing nested value",n,x),n={}}c[i.key]=n}),t.type==="array"&&!Array.isArray(c)&&(c=D.default(c)?[]:[c]);const a=V.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(ue,{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","&":le(j)},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(fe,{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(N.AddRounded,{}),onClick:()=>{try{const c=t.subProperties||{},d=ce.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:{"&":le(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=z.useUploader(),d=P.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(Bt,{...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(xt,{label:i,value:o,onChange:n=>{l?.(n)}});if(s.type==="json"||s.type==="yaml")return e.jsx(mt,{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(J.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(It,{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(z.UploaderButton,{onChange:async({response:g})=>{const h=g?.data?.url||g?.data?.fileUrl;let S;h&&(S=await z.getImageSize(h).catch(()=>z.getVideoSize(h)).catch(()=>{}));let y=g?.data?.filename||"";y&&(y=`mediakit://${y}`),l?.({url:h,mediaKitUrl:y,width:S?.naturalWidth,height:S?.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(N.InfoRounded,{sx:{cursor:"default",mr:1},fontSize:"small"})})]})}:void 0}})}return s.type==="array"?e.jsx(ut,{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:S=>{const y={...n,[h.key]:S};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 Bt({NumberProps:t,...s}){const{getInputProps:o}=ae.unstable_useNumberInput(t),l=o();return e.jsx(r.TextField,{...s,slotProps:{htmlInput:l}})}const ge=`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"),V=require("./chunks/state-BdtFHk36.js"),ve=require("@arcblock/ux/lib/Empty"),R=require("@arcblock/ux/lib/Locale/context"),re=require("@blocklet/code-editor"),Ce=require("@mui/icons-material/AddRounded"),Se=require("@mui/icons-material/ArrowDownward"),ke=require("@mui/icons-material/ArrowUpward"),Pe=require("@mui/icons-material/DeleteOutline"),we=require("lodash/sortBy"),P=require("react"),se=require("react-use"),oe=require("@blocklet/pages-kit/builtin/color-picker"),z=require("@blocklet/pages-kit/builtin/uploader"),Ie=require("@iconify-icon/react"),Te=require("lodash/isEmpty"),Be=require("lodash/set"),Oe=require("yaml"),Re=require("lodash/cloneDeep"),Ne=require("@arcblock/ux/lib/Toast"),J=require("@blocklet/pages-kit/components"),Ae=require("@blocklet/pages-kit/utils/property"),ae=require("@mui/base"),N=require("@mui/icons-material"),U=require("@syncedstore/core"),ze=require("ahooks"),Ve=require("lodash/assign"),_e=require("lodash/get"),Ee=require("lodash/has"),De=require("lodash/isEqual"),Fe=require("lodash/isNil"),Le=require("lodash/isObject"),qe=require("lodash/keyBy"),Ue=require("lodash/omit"),Me=require("lodash/pick"),We=require("lodash/reduce"),E=require("material-ui-popup-state/hooks"),Ke=require("react-error-boundary"),q=require("@dnd-kit/core"),Q=require("@dnd-kit/sortable"),Je=require("@dnd-kit/utilities"),ce=require("@blocklet/pages-kit/utils/common"),O=t=>t&&t.__esModule?t:{default:t};function He(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(ve),$e=O(Ce),Ge=O(Se),Ye=O(ke),Qe=O(Pe),_=O(we),D=O(Te),de=O(Be),X=He(Oe),Z=O(Re),ee=O(Ne),Xe=O(Ve),Ze=O(_e),et=O(Ee),tt=O(De),$=O(Fe),rt=O(Le),st=O(qe),nt=O(Ue),ot=O(Me),it=O(We);function lt({error:t}){return e.jsx(r.Box,{children:e.jsx(r.Alert,{severity:"error",children:t.message})})}function at({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(Qe.default,{fontSize:"small"})})}function ct({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(Ye.default,{fontSize:"small"})})}function dt({onClick:t,disabled:s,sx:o,...l}){return e.jsx(r.IconButton,{size:"small",color:"primary",disabled:s,onClick:t,...l,children:e.jsx(Ge.default,{fontSize:"small"})})}function ut({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=se.useUpdate(),i=P.useCallback(b=>{o(V.transformValue(b,u.type))},[o,u.type]),n=P.useMemo(()=>Array.isArray(s)?s:[],[s]),x=P.useCallback(()=>{const b=[...n,""];i(b),a()},[n,i,a]),g=P.useCallback(()=>{if(!u||!u.subProperties)return x();const b={};_.default(Object.values(u.subProperties),"index").forEach(({data:B})=>{if(!B.key)return;const A=B.locales?.[d]?.defaultValue??"";b[B.key]=A});const w=[...n,b];i(w),a()},[n,i,a,u,d,x]),h=P.useCallback(b=>{try{const v=JSON.parse(b);Array.isArray(v)?i(v):console.error("JSON解析结果不是数组")}catch(v){console.error("JSON解析错误:",v)}},[i]),S=P.useCallback(b=>{const v=n.filter((w,B)=>B!==b);i(v),a()},[n,i,a]),y=P.useCallback(b=>{if(b<=0)return;const v=[...n],w=v[b];v[b]=v[b-1],v[b-1]=w,i(v),a()},[n,i,a]),I=P.useCallback(b=>{if(b>=n.length-1)return;const v=[...n],w=v[b];v[b]=v[b+1],v[b+1]=w,i(v),a()},[n,i,a]),T=P.useCallback((b,v)=>{const w=[...n];w[b]=v,i(w)},[n,i]),C=u&&u.subProperties&&Object.keys(u.subProperties).length>0,k=P.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:w=>T(v,w)}):e.jsx(r.TextField,{fullWidth:!0,size:"small",disabled:l,value:b,placeholder:f||`${c("item")} ${v+1}`,onChange:w=>T(v,w.target.value),...m})},{field:"actions",headerName:"",width:30,align:"center",renderCell:({index:b})=>e.jsxs(r.Stack,{direction:"column",spacing:.25,children:[e.jsx(ct,{disabled:l||b===0,onClick:()=>y(b)}),e.jsx(dt,{disabled:l||b===n.length-1,onClick:()=>I(b)}),e.jsx(at,{disabled:l,onClick:()=>S(b)})]})}],[j,C,u,T,f,c,l,m,S,y,I,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:k.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,w)=>e.jsx(r.TableRow,{sx:{borderBottom:v<w.length-1?"1px solid":"none",borderColor:"divider","&:hover":{backgroundColor:"action.hover"}},children:k.map(B=>e.jsx(r.TableCell,{width:B.width,align:B.align||"left",sx:{borderBottom:"none"},children:B.renderCell({row:b,index:v,onChange:A=>T(v,A)})},`${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($e.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(re.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 pt({ref:t,showMarkdown:s,markdown:o,onMarkdownChange:l,showUploader:f,value:p,meta:u,onChange:j,...m}){const[c,d]=P.useState("");P.useEffect(()=>{d(p||"")},[p,d]);const a=async()=>{if(c!==p){const n=V.getImageAbsoluteUrl(c);if(!n){j(c,void 0);return}const x=await z.getImageSize(n).catch(()=>z.getVideoSize(n)).catch(()=>{});j(c,{...x,filename:c})}};se.useDebounce(()=>{c!==p&&j(c)},300,[c]),P.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(z.UploaderButton,{onChange:async({response:n})=>{const x=n?.data?.filename,g=V.getImageAbsoluteUrl(x)||"";let h={};g&&(h=await z.getImageSize(g).catch(()=>z.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:Ie.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 xt({value:t,onChange:s,disableGradient:o=!1,...l}){const f=P.useRef(null);return e.jsxs(e.Fragment,{children:[e.jsx(pt,{...l,value:t,onChange:s,InputProps:{endAdornment:e.jsx(r.InputAdornment,{position:"end",children:e.jsx(oe.ColorItem,{color:t??"",style:{width:"1.5rem",height:"1.5rem",padding:0},onClick:()=>{f.current?.open({value:t??""})}})})}}),e.jsx(oe.ConfigColorDialog,{ref:f,onSave:({value:p},u)=>{s(p),u()},disableGradient:o})]})}function mt({label:t,value:s,onChange:o,property:l,component:f,defaultLocale:p,allComponents:u,PropertyValueField:j,onUpload:m}){const{locale:c}=R.useLocaleContext(),d=P.useRef(null);if(!D.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,S=x===i.length-1;let y=null;try{s&&typeof s=="object"?y=s[h]:typeof s=="string"&&(y=(l.type==="yaml"?X.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 I=C=>{try{let k={};if(typeof s=="string")try{k=l.type==="yaml"?X.parse(s||""):JSON.parse(s||"{}")}catch{}else typeof s=="object"&&s!==null&&(k={...s});de.default(k,h,C);const b=V.transformValue(k,l.type);o?.(b)}catch(k){console.error("Error updating property:",k)}},T=8;return e.jsxs(r.Box,{sx:{mb:S?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"}}),!S&&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:I,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(re.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 ie(t){return!!t.shared}const ft={setActivatorNodeRef:()=>{},attributes:{},listeners:{}};function ue({disabled:t,list:s,renderItem:o,...l}){const f=_.default(Object.entries(s),([,x])=>x.index),p=f.map(([x])=>x),[u,j]=P.useState(null),[m,c]=P.useState(null),d=q.useSensors(q.useSensor(q.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 S=g.id,y=h.id;if(s[S]&&s[y]){const I=()=>{const k=Object.entries(s).sort(([,B],[,A])=>B.index-A.index),b=k.findIndex(([B])=>B===S),v=k.findIndex(([B])=>B===y),[w]=k.splice(b,1);w&&k.splice(v,0,w),k.forEach(([,B],A)=>{B.index=A})},T=U.getYjsValue(s)?.doc;T?T.transact(()=>{I()}):I()}};return e.jsxs(q.DndContext,{sensors:d,collisionDetection:q.closestCorners,onDragStart:a,onDragOver:i,onDragEnd:n,children:[e.jsx(Q.SortableContext,{items:p,strategy:Q.verticalListSortingStrategy,children:e.jsx(r.Stack,{...l,children:f.map(([x,g],h)=>e.jsx(ht,{id:x,disabled:t,isDragging:m===x,children:({dragHandle:S})=>o(g.data,h,{isDragging:m===x,dragHandle:S,drag:null,drop:null,preview:null})},x))})}),e.jsx(q.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:ft,drag:null,drop:null,preview:null})}):null})]})}function ht({id:t,disabled:s,isDragging:o,children:l}){const{attributes:f,listeners:p,setNodeRef:u,setActivatorNodeRef:j,transform:m,transition:c}=Q.useSortable({id:t,disabled:s}),d={transform:Je.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 bt({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(N.SyncRounded,{sx:{fontSize:"1.25rem",color:"primary.main"}}):e.jsx(N.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(N.VisibilityOffRounded,{sx:{fontSize:"1.25rem",color:"grey.500"}}):e.jsx(N.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(N.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(N.DragIndicatorRounded,{sx:{color:"grey.500"}})})})]})})]})})}function gt(t){const s=["string","json","array","url","multiline"],o=["style","fontSize","color","content","type"];return!!(s.includes(t.type||"")&&!o.includes(t.key||""))}function jt(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 pe=(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?jt(m,o,l||""):c,a=s?.[m.id],i={key:c,isNeedGenerate:a?.isNeedGenerate??gt(m),describe:a?.describe??"",displayName:d};m.subProperties&&!D.default(m.subProperties)&&(i.subProperties=pe(m.subProperties,a?.subProperties,o,l)),f[m.id]=i}),f};function yt({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]=P.useState(null);P.useEffect(()=>{if(t&&l){const h={properties:{}};if(l.properties){const S=f?.properties;h.properties=pe(l.properties,S,p,u)}a(h)}},[t,l,f,p,u]);const i=()=>{s()},n=()=>{d&&(o(d),s())},x=(h,S,y)=>{if(!d||!h.length)return;const I=JSON.parse(JSON.stringify(d));let T=I.properties,C=null;for(let b=0;b<h.length-1;b++){const v=h[b];if(!v||!T[v])return;C=T;const w=T[v];w.subProperties||(w.subProperties={}),T=w.subProperties}const k=h[h.length-1];if(k){if("isNeedGenerate"in y){const b=y.isNeedGenerate,v={...S,...y};if(S.subProperties&&!D.default(S.subProperties)){const w=(B,A)=>{const L={};return Object.entries(B).forEach(([ye,W])=>{const Y={...W};A!==null&&(Y.isNeedGenerate=A),W.subProperties&&!D.default(W.subProperties)&&(Y.subProperties=w(W.subProperties,A!==null?A:null)),L[ye]=Y}),L};v.subProperties=w(S.subProperties,b===!1?!1:null)}if(h.length===1)I.properties[k]=v;else if(C&&h.length>=2){const w=h[h.length-2];w&&C[w]&&(C[w].subProperties||(C[w].subProperties={}),C[w].subProperties[k]=v)}}else if(h.length===1)I.properties[k]={...S,...y};else if(C&&h.length>=2){const b=h[h.length-2];b&&C[b]&&C[b].subProperties&&(C[b].subProperties[k]={...S,...y})}a(I)}},g=(h,S=[],y=!0)=>{if(!h||D.default(h))return e.jsx(M.default,{children:c("maker.properties.noProperties")});const I=_.default(Object.entries(h),([,T])=>T.displayName);return e.jsx(r.Stack,{spacing:1.5,children:I.map(([T,C],k)=>{const b=[...S,T],v=k===I.length-1,w=C.subProperties&&!D.default(C.subProperties),B=C.displayName||T,A=!y;return e.jsx(r.Box,{sx:{position:"relative"},children:e.jsxs(r.Stack,{direction:"row",children:[S.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:A,onChange:L=>{x(b,C,{isNeedGenerate:L.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:L=>{x(b,C,{describe:L.target.value})},disabled:!C.isNeedGenerate})]}),w&&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 vt({label:t,value:s,onChange:o}){const[l,f]=P.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(z.UploaderButton,{onChange:({response:p})=>{const u=p?.data?.filename;u&&o?.(u)}})})}}}),s&&e.jsx(r.Box,{component:"img",src:V.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:V.getImageAbsoluteUrl(s),alt:t})})]})}function te(t,s=""){return it.default(t,(o,l,f)=>{const p=s?`${s}.${f}`:f;return rt.default(l)?Xe.default(o,te(l,p)):o[p]=l,o},{})}const Ct=[{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 H(t,s){return!t||!s?!1:t[s]?.data.visible??!0}function xe(t,s){return!t||!s?!1:t[s]?.data.shared??!1}function St({componentId:t}){const{state:{components:s}}=V.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(Ke.ErrorBoundary,{FallbackComponent:lt,resetKeys:[t],children:e.jsx(kt,{value:l,componentId:t})})})}):null}function kt({value:t,componentId:s}){const{t:o}=R.useLocaleContext(),{localState:{currentLocale:l,customComponentPreviewerProperties:f},state:{config:{defaultLocale:p}},localActions:{setCustomComponentPreviewerProperties:u}}=V.useStore(),j=U.getYjsValue(t).doc,m=V.useAllComponents(),c=P.useMemo(()=>f?.[s]??{},[s,f]),d=t.renderer?.type||"react-component",a=d==="component-template",i=ze.useReactive({componentId:s,propertiesValue:{...c}});return P.useEffect(()=>{i.componentId!==s&&(i.componentId=s,i.propertiesValue={...c})},[s,c,i]),P.useEffect(()=>{if(i.componentId!==s)return;const n=Object.fromEntries(Object.values(t.properties??{}).map(({data:x})=>[x.id,{value:i.propertiesValue[x.id]?.value??Ae.parsePropertyValue(x,x.locales?.[l]?.defaultValue??x.locales?.[p]?.defaultValue,{locale:l,defaultLocale:p})}]));u(s,n)},[JSON.stringify(i.propertiesValue),s,i.componentId]),e.jsx(r.Stack,{sx:{height:"100%"},children:e.jsxs(r.Stack,{sx:{gap:2},children:[e.jsx(me,{config:t}),e.jsxs(e.Fragment,{children:[e.jsx(he,{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(Rt,{value:t}),d==="react-component"&&e.jsx(Ot,{value:t}),e.jsx(ne,{config:t,currentLocale:l,defaultLocale:p,allComponents:m,propertiesValue:i.propertiesValue,onChange:({value:n,id:x,path:g})=>{const h=[...g,"data"];if(!Ze.default(t,h)){ee.default.warning(o("cannotFindPropertyKey",{key:h.join(".")}));return}i.propertiesValue[x]={value:n.value}}})]})]})})}function me({config:t}){const{t:s}=R.useLocaleContext();return e.jsx(z.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(Nt,{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(vt,{label:s("previewImage"),value:t.previewImage||"",onChange:o=>t.previewImage=o})]})})}function fe({data:t,params:s,visible:o,shared:l,config:f,currentLocale:p,defaultLocale:u,allComponents:j,onUpdateConfig:m}){const{t:c}=R.useLocaleContext(),d=P.useMemo(()=>t.type==="json"||t.type==="yaml"||t.type==="array"?Tt:F,[t.type]);return e.jsx(bt,{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(N.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:Ct.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=te(x),h=te(a);Object.keys(h).forEach(S=>{g[S]||de.default(x,S,h[S])})}else x.locales??={},x.locales[p]??={},x.locales[p].defaultValue=a})}}),t.type==="custom"?e.jsx(r.Box,{children:e.jsx(wt,{property:t,allComponents:j})}):null]})]})})}function Pt(t,s){const[o,l]=P.useState(0);return P.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 he({config:t,currentLocale:s,defaultLocale:o,allComponents:l,onUpdateConfig:f,useI18nEditor:p=!0}){const{t:u}=R.useLocaleContext(),j=E.usePopupState({variant:"dialog"}),m=t.properties&&_.default(Object.values(t.properties),"index");return e.jsx(z.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},...E.bindTrigger(j),children:e.jsx(N.TranslateRounded,{fontSize:"small"})})]}),t.properties&&Object.keys(t.properties).length>0?e.jsx(ue,{component:r.Stack,gap:2,list:t.properties,renderItem:(c,d,a)=>{const i=H(t.properties,c.id),n=xe(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(fe,{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=ce.nextId();c.properties??={},c.properties[d]??={index:m?.length||0,data:{id:d,shared:!1}}})},startIcon:e.jsx(N.AddRounded,{}),children:u("addObject",{object:u("property")})}),p&&e.jsx(be,{...E.bindDialog(j),component:t})]})})}function wt({property:t,allComponents:s}){const o=E.usePopupState({variant:"popper"});return e.jsxs(e.Fragment,{children:[e.jsx(r.Button,{sx:{minWidth:0},...E.bindTrigger(o),children:e.jsx(N.SettingsRounded,{fontSize:"small"})}),e.jsx(r.Popper,{...E.bindPopper(o),children:e.jsx(ae.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 It({value:t,valueImmutable:s,onChange:o,defaultLocale:l,allComponents:f}){const[p,u]=P.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(N.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(ne,{config:c,currentLocale:m,defaultLocale:l,allComponents:f,propertiesValue:t?.properties,onChange:({id:d,value:a})=>{const i=Z.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 be({type:t="properties",component:s,...o}){const{t:l}=R.useLocaleContext(),{state:{components:f,supportedLocales:p,config:{defaultLocale:u}}}=V.useStore(),j=V.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(N.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 le=(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 Tt({property:t,onChange:s,defaultLocale:o,allComponents:l}){const{t:f,locale:p}=R.useLocaleContext(),u=P.useRef(null),j=Pt(u,t),m=P.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=X.parse(n)}catch(x){console.error("Error parsing nested value",n,x),n={}}c[i.key]=n}),t.type==="array"&&!Array.isArray(c)&&(c=D.default(c)?[]:[c]);const a=V.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(ue,{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","&":le(j)},children:e.jsx(r.Stack,{sx:{gap:2},children:e.jsx(fe,{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(N.AddRounded,{}),onClick:()=>{try{const c=t.subProperties||{},d=ce.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:{"&":le(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=z.useUploader(),d=P.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(Bt,{...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(xt,{label:i,value:o,onChange:n=>{l?.(n)}});if(s.type==="json"||s.type==="yaml")return e.jsx(mt,{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(J.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(It,{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(z.UploaderButton,{onChange:async({response:g})=>{const h=g?.data?.url||g?.data?.fileUrl;let S;h&&(S=await z.getImageSize(h).catch(()=>z.getVideoSize(h)).catch(()=>{}));let y=g?.data?.filename||"";y&&(y=`mediakit://${y}`),l?.({url:h,mediaKitUrl:y,width:S?.naturalWidth,height:S?.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(N.InfoRounded,{sx:{cursor:"default",mr:1},fontSize:"small"})})]})}:void 0}})}return s.type==="array"?e.jsx(ut,{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:S=>{const y={...n,[h.key]:S};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 Bt({NumberProps:t,...s}){const{getInputProps:o}=ae.unstable_useNumberInput(t),l=o();return e.jsx(r.TextField,{...s,slotProps:{htmlInput:l}})}const ge=`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/es/setting.js
CHANGED
|
@@ -1343,14 +1343,14 @@ function mt({ config: r }) {
|
|
|
1343
1343
|
size: "small",
|
|
1344
1344
|
multiline: !0,
|
|
1345
1345
|
minRows: 2,
|
|
1346
|
-
maxRows:
|
|
1346
|
+
maxRows: 8,
|
|
1347
1347
|
value: r.description || "",
|
|
1348
1348
|
onChange: (i) => r.description = i.target.value,
|
|
1349
1349
|
slotProps: {
|
|
1350
1350
|
input: {
|
|
1351
1351
|
endAdornment: /* @__PURE__ */ e(H, { position: "end", sx: { mt: -1.5 }, children: /* @__PURE__ */ e(wt, { config: r }) })
|
|
1352
1352
|
},
|
|
1353
|
-
htmlInput: { maxLength:
|
|
1353
|
+
htmlInput: { maxLength: 2048 }
|
|
1354
1354
|
}
|
|
1355
1355
|
}),
|
|
1356
1356
|
/* @__PURE__ */ e(Te, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/pages-kit-inner-components",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.79",
|
|
4
4
|
"description": "Pages Kit inner components library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -201,8 +201,8 @@
|
|
|
201
201
|
"yaml": "^2.5.0",
|
|
202
202
|
"yjs": "^13.6.18",
|
|
203
203
|
"zustand": "^4.5.5",
|
|
204
|
-
"@blocklet/pages-kit": "^0.6.
|
|
205
|
-
"@blocklet/pages-kit-block-studio": "^0.6.
|
|
204
|
+
"@blocklet/pages-kit": "^0.6.79",
|
|
205
|
+
"@blocklet/pages-kit-block-studio": "^0.6.79"
|
|
206
206
|
},
|
|
207
207
|
"devDependencies": {
|
|
208
208
|
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
|