bi-sdk-react 0.0.30 → 0.0.32

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.
@@ -1008,7 +1008,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
1008
1008
  color: #999;
1009
1009
  font-size: 12px;
1010
1010
  }
1011
- `,lu=(e,t)=>{let[l,n]=(0,eE.useState)(null),{fetch:r,getVars:a}=(0,eE.useContext)(eA);return(0,eE.useEffect)(()=>{if(!(null==e?void 0:e.datasource))return n(null);switch((null==e?void 0:e.datasource.source)||"custom"){case"custom":try{return n(JSON.parse((null==e?void 0:e.datasource.custom)||"[]"))}catch(e){break}case"dataset":if(!(null==e?void 0:e.datasource.dataset)||!(null==r?void 0:r.dataset))break;let t=a(e.id||"");r.dataset(null==e?void 0:e.datasource.dataset.id,t).then(e=>n((null==e?void 0:e.data)||null)).catch(e=>{console.error(e),n(null)})}return n(null)},[null==e?void 0:e.datasource,t]),l},lp=t.div`
1011
+ `,lu=(e,t)=>{let[l,n]=(0,eE.useState)(null),{fetch:r,getVars:a}=(0,eE.useContext)(eA);return(0,eE.useEffect)(()=>{if(!(null==e?void 0:e.datasource))return n(null);switch((null==e?void 0:e.datasource.source)||"custom"){case"custom":try{return n(JSON.parse((null==e?void 0:e.datasource.custom)||"[]"))}catch(e){break}case"dataset":if(!(null==e?void 0:e.datasource.dataset)||!(null==r?void 0:r.dataset))break;let t=a(e.id||"");r.dataset(null==e?void 0:e.datasource.dataset.id,t).then(e=>n((null==e?void 0:e.data)||null)).catch(e=>{console.error(e),n(null)})}return n(null)},[null==e?void 0:e.datasource,t]),{datasource:l}},lp=t.div`
1012
1012
  box-sizing: border-box;
1013
1013
  margin: 0;
1014
1014
  padding: 0;
@@ -1085,7 +1085,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
1085
1085
  const module = undefined;
1086
1086
  const exports = undefined;
1087
1087
  ${e.customRender}
1088
- `)(console,Math,Date,Array,Object,String,Number,Boolean,t,l,n):e.render})),m=()=>{console.log("callback table")};return(0,eE.useEffect)(()=>{u({id:l.id,callback:m})},[]),(0,eO.jsx)(ea,{id:t,dataSource:n,columns:x,pagination:p,bordered:i,size:o,showHeader:"boolean"!=typeof s||s,rowKey:(e,t)=>String(t),style:{padding:1,...d},className:c})},formComponent:e=>{let{model:t,onChange:l}=e,i=(e,n)=>l&&l({...t,[e]:n}),o=(e,l)=>{let n=[...t.columns||[]];n[e]={...n[e],...l},i("columns",n)},[s,d]=(0,eE.useState)(!1),[u,x]=(0,eE.useState)(null),m=null!=u&&t.columns[u]?t.columns[u]:{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1},h=[{title:"列名",dataIndex:"title"},{title:"数据索引",dataIndex:"dataIndex"},{title:"操作",width:80,align:"center",render:(e,l,n)=>(0,eO.jsxs)(en,{children:[(0,eO.jsx)("a",{onClick:()=>{x(n),d(!0)},children:(0,eO.jsx)(p,{})}),(0,eO.jsx)("a",{onClick:()=>{let e;(e=[...t.columns||[]]).splice(n,1),i("columns",e)},children:(0,eO.jsx)(c,{})})]})}];return(0,eO.jsxs)("div",{children:[(0,eO.jsxs)(K,{labelCol:{span:12},wrapperCol:{span:12},children:[(0,eO.jsx)(K.Item,{label:"大小",children:(0,eO.jsxs)(Z.Group,{size:"small",value:t.size,onChange:e=>i("size",e.target.value),children:[(0,eO.jsx)(Z.Button,{value:"small",children:"小"}),(0,eO.jsx)(Z.Button,{value:"middle",children:"中"}),(0,eO.jsx)(Z.Button,{value:"large",children:"大"})]})}),(0,eO.jsx)(K.Item,{label:"边框",children:(0,eO.jsx)(er,{size:"small",checked:!!t.bordered,onChange:e=>i("bordered",e)})}),(0,eO.jsx)(K.Item,{label:"显示表头",children:(0,eO.jsx)(er,{size:"small",checked:!!t.showHeader,onChange:e=>i("showHeader",e)})}),(0,eO.jsx)(K.Item,{label:"分页大小",children:(0,eO.jsx)(U,{size:"small",value:t.pageSize,onChange:e=>i("pageSize",e)})})]}),(0,eO.jsx)(H,{children:"表格列设置"}),(0,eO.jsx)(ea,{size:"small",dataSource:t.columns,rowKey:(e,t)=>String(t),columns:h,pagination:!1,bordered:!0}),(0,eO.jsx)(P,{size:"small",onClick:()=>{i("columns",[...t.columns||[],{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1}])},block:!0,children:"添加列"}),(0,eO.jsx)(q,{title:"编辑列",open:s,footer:null,width:400,onCancel:()=>d(!1),children:(0,eO.jsx)(K,{layout:"vertical",children:(0,eO.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,eO.jsx)(K.Item,{label:"列名",children:(0,eO.jsx)(W,{value:m.title,onChange:e=>o(u,{title:e.target.value})})}),(0,eO.jsx)(K.Item,{label:"数据索引",children:(0,eO.jsx)(W,{value:m.dataIndex,onChange:e=>o(u,{dataIndex:e.target.value})})}),(0,eO.jsx)(K.Item,{label:"宽度",children:(0,eO.jsx)(W,{value:m.width,onChange:e=>o(u,{width:e.target.value})})}),(0,eO.jsx)(K.Item,{label:"对齐",children:(0,eO.jsxs)(Z.Group,{value:m.align,onChange:e=>o(u,{align:e.target.value}),children:[(0,eO.jsx)(Z.Button,{value:"left",children:(0,eO.jsx)(r,{})}),(0,eO.jsx)(Z.Button,{value:"center",children:(0,eO.jsx)(n,{})}),(0,eO.jsx)(Z.Button,{value:"right",children:(0,eO.jsx)(a,{})})]})}),(0,eO.jsx)(K.Item,{label:"省略",children:(0,eO.jsx)(er,{checked:!!m.ellipsis,onChange:e=>o(u,{ellipsis:e})})})]})})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:null},props:{size:"default",bordered:!0,showHeader:!0,pageSize:10,dataSource:[{name:"苹果",count:12},{name:"华为",count:803},{name:"OPPO",count:654},{name:"vivo",count:719}],columns:[{title:"品牌",dataIndex:"name"},{title:"日销量(件)",dataIndex:"count"}]}}},{group:"基础组件",key:"b-list",label:"列表",icon:"icon-unordered-list",component:e=>{let{id:t,pageSize:l=10,bordered:n=!0,size:r="default",itemLayout:a="horizontal",item:i,split:o=!0,style:s={},className:d}=e,{initCallback:c}=(0,eE.useContext)(eA),[u,p]=(0,eE.useState)(0),x=lu(i,u),m=(0,eE.useRef)(x);(0,eE.useEffect)(()=>{m.current=x},[x]);let h=m.current||[],f=(0,eE.useMemo)(()=>!!l&&!(l<=h.length)&&{total:h.length,pageSize:l,size:"default"===r?void 0:r,showSizeChanger:!0,showQuickJumper:!0,hideOnSinglePage:!0,pageSizeOptions:["10","20","30","40"],showTotal:(e,t)=>`共 ${e} 条记录,显示第 ${t[0]}-${t[1]} 条`},[l,h.length,r]),g=["p-list",a?`p-list--${a}`:void 0,r?`p-list--${r}`:void 0,o?"p-list--split":void 0,n?"p-list--bordered":void 0,d],v=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return e&&p(e=>e+1),{target:i,data:m.current}};return(0,eE.useEffect)(()=>{c({id:i.id,callback:v})},[]),(0,eO.jsxs)("div",{id:t,style:{display:"flex",flexDirection:"column",...s},className:g.filter(Boolean).join(" "),children:[(0,eO.jsx)(lb,{list:h,split:o,bordered:n,size:r,itemLayout:a}),f&&(0,eO.jsx)(X,{...f})]})},formComponent:e=>{let{model:t,onChange:l}=e,[n]=K.useForm();return(0,eE.useEffect)(()=>{n.setFieldsValue({size:t.size||"default",itemLayout:t.itemLayout||"horizontal",bordered:t.bordered??!1,split:t.split??!0,pageSize:t.pageSize||10})},[t,n]),(0,eO.jsxs)(K,{form:n,labelCol:{span:12},wrapperCol:{span:12},onValuesChange:e=>{null==l||l({...t,...e})},children:[(0,eO.jsx)(K.Item,{label:"大小",name:"size",children:(0,eO.jsxs)(Z.Group,{size:"small",buttonStyle:"solid",children:[(0,eO.jsx)(Z.Button,{value:"default",children:"默认"}),(0,eO.jsx)(Z.Button,{value:"small",children:"小"})]})}),(0,eO.jsx)(K.Item,{label:"布局",name:"itemLayout",children:(0,eO.jsxs)(Z.Group,{size:"small",buttonStyle:"solid",children:[(0,eO.jsx)(Z.Button,{value:"horizontal",children:"水平"}),(0,eO.jsx)(Z.Button,{value:"vertical",children:"垂直"})]})}),(0,eO.jsx)(K.Item,{label:"边框",name:"bordered",valuePropName:"checked",children:(0,eO.jsx)(er,{size:"small"})}),(0,eO.jsx)(K.Item,{label:"分割线",name:"split",valuePropName:"checked",children:(0,eO.jsx)(er,{size:"small"})}),(0,eO.jsx)(K.Item,{label:"分页大小",name:"pageSize",children:(0,eO.jsx)(U,{size:"small"})})]})},defaultOptions:{datasource:{source:"custom",custom:"[]"},props:{size:"default",itemLayout:"horizontal",bordered:!0,split:!0,pageSize:10}}},{group:"基础组件",key:"b-html",label:"HTML",icon:"icon-html",component:e=>{let{id:t,template:l="",item:n,style:r,className:a,classNames:i=[]}=e,{initCallback:o}=(0,eE.useContext)(eA),[s,d]=(0,eE.useState)(0),c=lu(n,s),u=(0,eE.useRef)(c);(0,eE.useEffect)(()=>{u.current=c},[c]);let p=(0,eE.useMemo)(()=>Object.keys(c||{}),[c]),x=(0,eE.useMemo)(()=>p.map(e=>null==c?void 0:c[e]),[p,c]),m=(0,eE.useMemo)(()=>(l||"").replace(/##\s*([^#]+)\s*##/g,(e,t)=>{try{return Function(...p,`
1088
+ `)(console,Math,Date,Array,Object,String,Number,Boolean,t,l,n):e.render})),m=()=>{console.log("callback table")};return(0,eE.useEffect)(()=>{u({id:l.id,callback:m})},[]),(0,eO.jsx)(ea,{id:t,dataSource:n,columns:x,pagination:p,bordered:i,size:o,showHeader:"boolean"!=typeof s||s,rowKey:(e,t)=>String(t),style:{padding:1,...d},className:c})},formComponent:e=>{let{model:t,onChange:l}=e,i=(e,n)=>l&&l({...t,[e]:n}),o=(e,l)=>{let n=[...t.columns||[]];n[e]={...n[e],...l},i("columns",n)},[s,d]=(0,eE.useState)(!1),[u,x]=(0,eE.useState)(null),m=null!=u&&t.columns[u]?t.columns[u]:{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1},h=[{title:"列名",dataIndex:"title"},{title:"数据索引",dataIndex:"dataIndex"},{title:"操作",width:80,align:"center",render:(e,l,n)=>(0,eO.jsxs)(en,{children:[(0,eO.jsx)("a",{onClick:()=>{x(n),d(!0)},children:(0,eO.jsx)(p,{})}),(0,eO.jsx)("a",{onClick:()=>{let e;(e=[...t.columns||[]]).splice(n,1),i("columns",e)},children:(0,eO.jsx)(c,{})})]})}];return(0,eO.jsxs)("div",{children:[(0,eO.jsxs)(K,{labelCol:{span:12},wrapperCol:{span:12},children:[(0,eO.jsx)(K.Item,{label:"大小",children:(0,eO.jsxs)(Z.Group,{size:"small",value:t.size,onChange:e=>i("size",e.target.value),children:[(0,eO.jsx)(Z.Button,{value:"small",children:"小"}),(0,eO.jsx)(Z.Button,{value:"middle",children:"中"}),(0,eO.jsx)(Z.Button,{value:"large",children:"大"})]})}),(0,eO.jsx)(K.Item,{label:"边框",children:(0,eO.jsx)(er,{size:"small",checked:!!t.bordered,onChange:e=>i("bordered",e)})}),(0,eO.jsx)(K.Item,{label:"显示表头",children:(0,eO.jsx)(er,{size:"small",checked:!!t.showHeader,onChange:e=>i("showHeader",e)})}),(0,eO.jsx)(K.Item,{label:"分页大小",children:(0,eO.jsx)(U,{size:"small",value:t.pageSize,onChange:e=>i("pageSize",e)})})]}),(0,eO.jsx)(H,{children:"表格列设置"}),(0,eO.jsx)(ea,{size:"small",dataSource:t.columns,rowKey:(e,t)=>String(t),columns:h,pagination:!1,bordered:!0}),(0,eO.jsx)(P,{size:"small",onClick:()=>{i("columns",[...t.columns||[],{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1}])},block:!0,children:"添加列"}),(0,eO.jsx)(q,{title:"编辑列",open:s,footer:null,width:400,onCancel:()=>d(!1),children:(0,eO.jsx)(K,{layout:"vertical",children:(0,eO.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,eO.jsx)(K.Item,{label:"列名",children:(0,eO.jsx)(W,{value:m.title,onChange:e=>o(u,{title:e.target.value})})}),(0,eO.jsx)(K.Item,{label:"数据索引",children:(0,eO.jsx)(W,{value:m.dataIndex,onChange:e=>o(u,{dataIndex:e.target.value})})}),(0,eO.jsx)(K.Item,{label:"宽度",children:(0,eO.jsx)(W,{value:m.width,onChange:e=>o(u,{width:e.target.value})})}),(0,eO.jsx)(K.Item,{label:"对齐",children:(0,eO.jsxs)(Z.Group,{value:m.align,onChange:e=>o(u,{align:e.target.value}),children:[(0,eO.jsx)(Z.Button,{value:"left",children:(0,eO.jsx)(r,{})}),(0,eO.jsx)(Z.Button,{value:"center",children:(0,eO.jsx)(n,{})}),(0,eO.jsx)(Z.Button,{value:"right",children:(0,eO.jsx)(a,{})})]})}),(0,eO.jsx)(K.Item,{label:"省略",children:(0,eO.jsx)(er,{checked:!!m.ellipsis,onChange:e=>o(u,{ellipsis:e})})})]})})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:null},props:{size:"default",bordered:!0,showHeader:!0,pageSize:10,dataSource:[{name:"苹果",count:12},{name:"华为",count:803},{name:"OPPO",count:654},{name:"vivo",count:719}],columns:[{title:"品牌",dataIndex:"name"},{title:"日销量(件)",dataIndex:"count"}]}}},{group:"基础组件",key:"b-list",label:"列表",icon:"icon-unordered-list",component:e=>{let{id:t,pageSize:l=10,bordered:n=!0,size:r="default",itemLayout:a="horizontal",item:i,split:o=!0,style:s={},className:d}=e,{initCallback:c}=(0,eE.useContext)(eA),[u,p]=(0,eE.useState)(0),x=lu(i,u),m=(0,eE.useRef)(x);(0,eE.useEffect)(()=>{m.current=x},[x]);let{datasource:h}=m.current||[],f=(0,eE.useMemo)(()=>!!l&&!(l<=h.length)&&{total:h.length,pageSize:l,size:"default"===r?void 0:r,showSizeChanger:!0,showQuickJumper:!0,hideOnSinglePage:!0,pageSizeOptions:["10","20","30","40"],showTotal:(e,t)=>`共 ${e} 条记录,显示第 ${t[0]}-${t[1]} 条`},[l,h.length,r]),g=["p-list",a?`p-list--${a}`:void 0,r?`p-list--${r}`:void 0,o?"p-list--split":void 0,n?"p-list--bordered":void 0,d],v=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return e&&p(e=>e+1),{target:i,data:m.current}};return(0,eE.useEffect)(()=>{c({id:i.id,callback:v})},[]),(0,eO.jsxs)("div",{id:t,style:{display:"flex",flexDirection:"column",...s},className:g.filter(Boolean).join(" "),children:[(0,eO.jsx)(lb,{list:h,split:o,bordered:n,size:r,itemLayout:a}),f&&(0,eO.jsx)(X,{...f})]})},formComponent:e=>{let{model:t,onChange:l}=e,[n]=K.useForm();return(0,eE.useEffect)(()=>{n.setFieldsValue({size:t.size||"default",itemLayout:t.itemLayout||"horizontal",bordered:t.bordered??!1,split:t.split??!0,pageSize:t.pageSize||10})},[t,n]),(0,eO.jsxs)(K,{form:n,labelCol:{span:12},wrapperCol:{span:12},onValuesChange:e=>{null==l||l({...t,...e})},children:[(0,eO.jsx)(K.Item,{label:"大小",name:"size",children:(0,eO.jsxs)(Z.Group,{size:"small",buttonStyle:"solid",children:[(0,eO.jsx)(Z.Button,{value:"default",children:"默认"}),(0,eO.jsx)(Z.Button,{value:"small",children:"小"})]})}),(0,eO.jsx)(K.Item,{label:"布局",name:"itemLayout",children:(0,eO.jsxs)(Z.Group,{size:"small",buttonStyle:"solid",children:[(0,eO.jsx)(Z.Button,{value:"horizontal",children:"水平"}),(0,eO.jsx)(Z.Button,{value:"vertical",children:"垂直"})]})}),(0,eO.jsx)(K.Item,{label:"边框",name:"bordered",valuePropName:"checked",children:(0,eO.jsx)(er,{size:"small"})}),(0,eO.jsx)(K.Item,{label:"分割线",name:"split",valuePropName:"checked",children:(0,eO.jsx)(er,{size:"small"})}),(0,eO.jsx)(K.Item,{label:"分页大小",name:"pageSize",children:(0,eO.jsx)(U,{size:"small"})})]})},defaultOptions:{datasource:{source:"custom",custom:"[]"},props:{size:"default",itemLayout:"horizontal",bordered:!0,split:!0,pageSize:10}}},{group:"基础组件",key:"b-html",label:"HTML",icon:"icon-html",component:e=>{let{id:t,template:l="",item:n,style:r,className:a,classNames:i=[]}=e,{initCallback:o}=(0,eE.useContext)(eA),[s,d]=(0,eE.useState)(0),{datasource:c}=lu(n,s),u=(0,eE.useRef)(c);(0,eE.useEffect)(()=>{u.current=c},[c]);let p=(0,eE.useMemo)(()=>Object.keys(c||{}),[c]),x=(0,eE.useMemo)(()=>p.map(e=>null==c?void 0:c[e]),[p,c]),m=(0,eE.useMemo)(()=>(l||"").replace(/##\s*([^#]+)\s*##/g,(e,t)=>{try{return Function(...p,`
1089
1089
  "use strict";
1090
1090
  const window = undefined;
1091
1091
  const document = undefined;
@@ -1095,7 +1095,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
1095
1095
  const module = undefined;
1096
1096
  const exports = undefined;
1097
1097
  return ${t};
1098
- `)(...x)}catch{return""}}),[l,x]),h=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return e&&d(e=>e+1),{target:n,data:u.current}};return(0,eE.useEffect)(()=>{o({id:n.id,callback:h})},[]),(0,eO.jsx)("div",{id:t,style:r,className:(i||[]).join(" ")+" "+a,dangerouslySetInnerHTML:{__html:m}})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,eE.useRef)(null),r=(e,n)=>l&&l({...t,[e]:n});return(0,eO.jsx)("div",{children:(0,eO.jsxs)(K,{layout:"vertical",children:[(0,eO.jsx)(K.Item,{label:"类名",children:(0,eO.jsx)(et,{size:"small",value:t.classNames,mode:"tags",onChange:e=>r("classNames",e)})}),(0,eO.jsx)(K.Item,{label:(0,eO.jsxs)(eO.Fragment,{children:["模板",(0,eO.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,eO.jsx)(th,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,eO.jsx)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:(0,eO.jsx)(em,{onMount:e=>{n.current={editor:e}},height:"300px",defaultLanguage:"html",value:t.template,onChange:e=>r("template",e||""),options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}})})})]})})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'{"name": "Confucius"}'},props:{template:"<div>{{name}}, welcome to the world of programming.</div>"}}},{group:"基础组件",key:"b-echarts",label:"图表",icon:"icon-echarts",component:e=>{let{id:t,script:l="",item:n,height:r=400,style:a,className:i}=e,{initCallback:o}=(0,eE.useContext)(eA),s=(0,eE.useRef)(null),[d,c]=(0,eE.useState)(null),[u,p]=(0,eE.useState)(0),x=lu(n,u),m=(0,eE.useRef)(x);(0,eE.useEffect)(()=>{m.current=x},[x]);let h=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return arguments.length>1&&arguments[1],e&&p(e=>e+1),{target:n,data:m.current}};return(0,eE.useEffect)(()=>{if(!s.current)return;let e=ev.init(s.current);c(e);let t=()=>e.resize();return window.addEventListener("resize",t),o({id:n.id,callback:h}),()=>{window.removeEventListener("resize",t),e.dispose()}},[]),(0,eE.useEffect)(()=>{let e;e=(e=>{try{return JSON.parse(e)}catch(t){try{return Function("echarts","console","Math","Date","Array","Object","String","Number","Boolean","data",`
1098
+ `)(...x)}catch{return""}}),[l,x]),h=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return e&&d(e=>e+1),{target:n,data:u.current}};return(0,eE.useEffect)(()=>{o({id:n.id,callback:h})},[]),(0,eO.jsx)("div",{id:t,style:r,className:(i||[]).join(" ")+" "+a,dangerouslySetInnerHTML:{__html:m}})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,eE.useRef)(null),r=(e,n)=>l&&l({...t,[e]:n});return(0,eO.jsx)("div",{children:(0,eO.jsxs)(K,{layout:"vertical",children:[(0,eO.jsx)(K.Item,{label:"类名",children:(0,eO.jsx)(et,{size:"small",value:t.classNames,mode:"tags",onChange:e=>r("classNames",e)})}),(0,eO.jsx)(K.Item,{label:(0,eO.jsxs)(eO.Fragment,{children:["模板",(0,eO.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,eO.jsx)(th,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,eO.jsx)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:(0,eO.jsx)(em,{onMount:e=>{n.current={editor:e}},height:"300px",defaultLanguage:"html",value:t.template,onChange:e=>r("template",e||""),options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}})})})]})})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'{"name": "Confucius"}'},props:{template:"<div>{{name}}, welcome to the world of programming.</div>"}}},{group:"基础组件",key:"b-echarts",label:"图表",icon:"icon-echarts",component:e=>{let{id:t,script:l="",item:n,height:r=400,style:a,className:i}=e,{initCallback:o}=(0,eE.useContext)(eA),s=(0,eE.useRef)(null),[d,c]=(0,eE.useState)(null),[u,p]=(0,eE.useState)(0),{datasource:x}=lu(n,u),m=(0,eE.useRef)(x);(0,eE.useEffect)(()=>{console.log("datasource",x),m.current=x},[x]);let h=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return arguments.length>1&&arguments[1],e&&p(e=>e+1),{target:n,data:m.current}};return(0,eE.useEffect)(()=>{if(!s.current)return;let e=ev.init(s.current);c(e);let t=()=>e.resize();return window.addEventListener("resize",t),o({id:n.id,callback:h}),()=>{window.removeEventListener("resize",t),e.dispose()}},[]),(0,eE.useEffect)(()=>{let e;e=(e=>{try{return JSON.parse(e)}catch(t){try{return Function("echarts","console","Math","Date","Array","Object","String","Number","Boolean","data",`
1099
1099
  "use strict";
1100
1100
  const window = undefined;
1101
1101
  const document = undefined;
@@ -1105,7 +1105,7 @@ import*as e from"react";import t,{css as l}from"styled-components";import{AlignC
1105
1105
  const module = undefined;
1106
1106
  const exports = undefined;
1107
1107
  ${e}
1108
- `)(ev,console,Math,Date,Array,Object,String,Number,Boolean,x)}catch(e){return console.error("ECharts 配置解析失败:",e),null}}})(l),d&&e&&(d.setOption(e),setTimeout(()=>d.resize(),50))},[d,l,x]),(0,eO.jsx)("div",{id:t,style:{width:"100%",height:r,...a},className:i,children:(0,eO.jsx)("div",{ref:s,style:{width:"100%",height:r,...a}})})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,eE.useRef)(null);return(0,eO.jsxs)(K,{children:[(0,eO.jsx)(K.Item,{label:"高度",labelCol:{span:6},wrapperCol:{span:18},children:(0,eO.jsx)(U,{value:t.height,size:"small",min:10,max:1e3,suffix:"px",onChange:e=>l&&l({...t,height:e})})}),(0,eO.jsx)(K.Item,{layout:"vertical",label:(0,eO.jsxs)(eO.Fragment,{children:["Echarts 渲染脚本"," ",(0,eO.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,eO.jsx)(th,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,eO.jsxs)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:[(0,eO.jsxs)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:["function getOptions(data) ","{"," "]}),(0,eO.jsx)(em,{onMount:e=>{n.current={editor:e}},height:"400px",defaultLanguage:"javascript",value:t.script,onChange:e=>{let n;return n=e||"",l&&l({...t,script:n||""})},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}}),(0,eO.jsx)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:"}"})]})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'[{"name":"Mon","value":150},{"name":"Tue","value":230},{"name":"Wed","value":224},{"name":"Thu","value":218},{"name":"Fri","value":135},{"name":"Sat","value":147},{"name":"Sun","value":260}]'},props:{script:`
1108
+ `)(ev,console,Math,Date,Array,Object,String,Number,Boolean,x)}catch(e){return null}}})(l),d&&e&&(d.setOption(e),setTimeout(()=>d.resize(),50))},[d,l,x]),(0,eO.jsx)("div",{id:t,style:{width:"100%",height:r,...a},className:i,children:(0,eO.jsx)("div",{ref:s,style:{width:"100%",height:r,...a}})})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,eE.useRef)(null);return(0,eO.jsxs)(K,{children:[(0,eO.jsx)(K.Item,{label:"高度",labelCol:{span:6},wrapperCol:{span:18},children:(0,eO.jsx)(U,{value:t.height,size:"small",min:10,max:1e3,suffix:"px",onChange:e=>l&&l({...t,height:e})})}),(0,eO.jsx)(K.Item,{layout:"vertical",label:(0,eO.jsxs)(eO.Fragment,{children:["Echarts 渲染脚本"," ",(0,eO.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,eO.jsx)(th,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,eO.jsxs)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:[(0,eO.jsxs)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:["function getOptions(data) ","{"," "]}),(0,eO.jsx)(em,{onMount:e=>{n.current={editor:e}},height:"400px",defaultLanguage:"javascript",value:t.script,onChange:e=>{let n;return n=e||"",l&&l({...t,script:n||""})},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}}),(0,eO.jsx)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:"}"})]})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'[{"name":"Mon","value":150},{"name":"Tue","value":230},{"name":"Wed","value":224},{"name":"Thu","value":218},{"name":"Fri","value":135},{"name":"Sat","value":147},{"name":"Sun","value":260}]'},props:{script:`
1109
1109
  return {
1110
1110
  xAxis: { type: 'category', data: data.map(i => i.name) },
1111
1111
  yAxis: { type: 'value' },
@@ -1,3 +1,5 @@
1
1
  import { SchemaItemType } from "../typing";
2
2
  export type Signal = string | number;
3
- export declare const useDatasource: (item: SchemaItemType, signal?: Signal) => any;
3
+ export declare const useDatasource: (item: SchemaItemType, signal?: Signal) => {
4
+ datasource: any;
5
+ };
@@ -1,5 +1,5 @@
1
1
  /*! For license information please see bi-sdk.umd.min.js.LICENSE.txt */
2
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@ant-design/icons"),require("echarts"),require("styled-components"),require("react"),require("antd"),require("react-dom"),require("uuid"),require("dayjs"),require("@monaco-editor/react")):"function"==typeof define&&define.amd?define(["@ant-design/icons","echarts","styled-components","react","antd","react-dom","uuid","dayjs","@monaco-editor/react"],t):"object"==typeof exports?exports.BiSdk=t(require("@ant-design/icons"),require("echarts"),require("styled-components"),require("react"),require("antd"),require("react-dom"),require("uuid"),require("dayjs"),require("@monaco-editor/react")):e.BiSdk=t(e["@ant-design/icons"],e.echarts,e["styled-components"],e.react,e.antd,e["react-dom"],e.uuid,e.dayjs,e["@monaco-editor/react"])}(this,(e,t,l,n,r,a,i,o,s)=>(()=>{var d={290(e,t,l){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,l=1,n=arguments.length;l<n;l++)for(var r in t=arguments[l])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.bindAll=void 0;var r=l(352);function a(e){if(void 0!==e)return"boolean"==typeof e?{capture:e}:e}t.bindAll=function(e,t,l){var i=t.map(function(t){var i=null==l?t:n(n({},t),{options:n(n({},a(l)),a(t.options))});return(0,r.bind)(e,i)});return function(){i.forEach(function(e){return e()})}}},352(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bind=void 0,t.bind=function(e,t){var l=t.type,n=t.listener,r=t.options;return e.addEventListener(l,n,r),function(){e.removeEventListener(l,n,r)}}},951(e,t,l){"use strict";t.bindAll=t.bind=void 0;var n=l(352);Object.defineProperty(t,"bind",{enumerable:!0,get:function(){return n.bind}});var r=l(290);Object.defineProperty(t,"bindAll",{enumerable:!0,get:function(){return r.bindAll}})},965(e,t,l){"use strict";var n=l(426),r={"text/plain":"Text","text/html":"Url",default:"Text"};e.exports=function(e,t){var l,a,i,o,s,d,c,u,p=!1;t||(t={}),i=t.debug||!1;try{if(s=n(),d=document.createRange(),c=document.getSelection(),(u=document.createElement("span")).textContent=e,u.ariaHidden="true",u.style.all="unset",u.style.position="fixed",u.style.top=0,u.style.clip="rect(0, 0, 0, 0)",u.style.whiteSpace="pre",u.style.webkitUserSelect="text",u.style.MozUserSelect="text",u.style.msUserSelect="text",u.style.userSelect="text",u.addEventListener("copy",function(l){if(l.stopPropagation(),t.format)if(l.preventDefault(),void 0===l.clipboardData){i&&console.warn("unable to use e.clipboardData"),i&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var n=r[t.format]||r.default;window.clipboardData.setData(n,e)}else l.clipboardData.clearData(),l.clipboardData.setData(t.format,e);t.onCopy&&(l.preventDefault(),t.onCopy(l.clipboardData))}),document.body.appendChild(u),d.selectNodeContents(u),c.addRange(d),!document.execCommand("copy"))throw Error("copy command was unsuccessful");p=!0}catch(n){i&&console.error("unable to copy using execCommand: ",n),i&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),p=!0}catch(n){i&&console.error("unable to copy using clipboardData: ",n),i&&console.error("falling back to prompt"),l="message"in t?t.message:"Copy to clipboard: #{key}, Enter",a=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",o=l.replace(/#{\s*key\s*}/g,a),window.prompt(o,e)}}finally{c&&("function"==typeof c.removeRange?c.removeRange(d):c.removeAllRanges()),u&&document.body.removeChild(u),s()}return p}},20(e,t,l){"use strict";var n=l(155),r=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function d(e,t,l){var n,a={},d=null,c=null;for(n in void 0!==l&&(d=""+l),void 0!==t.key&&(d=""+t.key),void 0!==t.ref&&(c=t.ref),t)i.call(t,n)&&!s.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:r,type:e,key:d,ref:c,props:a,_owner:o.current}}t.Fragment=a,t.jsx=d,t.jsxs=d},848(e,t,l){"use strict";e.exports=l(20)},426(e){e.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,l=[],n=0;n<e.rangeCount;n++)l.push(e.getRangeAt(n));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||l.forEach(function(t){e.addRange(t)}),t&&t.focus()}}},375(t){"use strict";t.exports=e},247(e){"use strict";e.exports=s},59(e){"use strict";e.exports=r},185(e){"use strict";e.exports=o},190(e){"use strict";e.exports=t},155(e){"use strict";e.exports=n},514(e){"use strict";e.exports=a},694(e){"use strict";e.exports=l},315(e){"use strict";e.exports=i}},c={};function u(e){var t=c[e];if(void 0!==t)return t.exports;var l=c[e]={exports:{}};return d[e].call(l.exports,l,l.exports,u),l.exports}u.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return u.d(t,{a:t}),t},u.d=(e,t)=>{for(var l in t)u.o(t,l)&&!u.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var p={};return(()=>{"use strict";u.r(p),u.d(p,{PluginType:()=>o.PluginType,PageCanvas:()=>ek,PageContext:()=>f,PageDesigner:()=>tc,PageSchema:()=>o.PageSchema,plugins:()=>tz,PropEditorProps:()=>s.PropEditorProps,PageProvider:()=>g,DropContainer:()=>eC});var e,t,l,n,r,a,i,o={};u.r(o),u.d(o,{P:()=>tu});var s={};u.r(s);var d=u(848),c=u(155),m=u.n(c),x=u(694),h=u.n(x);let f=(0,c.createContext)({pageId:"",designable:!1,plugins:[],schema:{info:{},datasources:[],scripts:[],variables:[],items:[]},selectedItem:null,atItems:null,setSchema:()=>{},setSelectedItem:()=>{},updateSelectedItem:()=>{},forceUpdate:()=>{},onAddAtItem:()=>{},onRemoveAtItem:()=>{},clearAtItems:()=>{},datasetSelector:void 0,datasetAdd:void 0,fetch:void 0,deviceWidth:0,setDeviceWidth:()=>{},initCallback:()=>{},handleCallback:()=>{},getVars:()=>({}),setVar:()=>{}}),g=e=>{let{pageId:t,designable:l,plugins:n,schema:r,selectedItem:a,setSchema:i,setSelectedItem:o,datasetSelector:s,datasetAdd:u,fetch:p,children:m}=e,[x,h]=(0,c.useState)(0),[g,v]=(0,c.useState)([]),[j,b]=(0,c.useState)({global:{},local:{}}),[y,w]=(0,c.useState)({}),C=e=>({...j.global,...j.local[e||""]||{}});return(0,c.useEffect)(()=>{let e={};(r.variables||[]).forEach(t=>{e[t.name]=t.value}),b(t=>({...t,global:e}))},[r.variables]),(0,d.jsx)(f.Provider,{value:{pageId:t,designable:!!l,plugins:n||[],schema:r,selectedItem:a,atItems:g,setSchema:i||(()=>{}),setSelectedItem:o||(()=>{}),updateSelectedItem:e=>{null==o||o(Object.assign(a,e||{})),null==i||i({...r})},datasetSelector:s,datasetAdd:u,fetch:p,forceUpdate:()=>{null==i||i({...r})},onAddAtItem:e=>{null!=g&&g.includes(e)||v([...g,e])},onRemoveAtItem:e=>{v(g.filter(t=>t!==e))},clearAtItems:()=>{v([])},deviceWidth:x,setDeviceWidth:h||(()=>{}),initCallback:e=>{let{id:t,callback:l}=e;w(e=>({...e,[t]:l}))},handleCallback:(e,t,l)=>{(e.cascadeIds||[]).forEach(e=>{let n=y[e];if("function"==typeof n){let r=n(t,C(e));if(r){let{target:e,data:t}=r;null==l||l(e,t)}}})},getVars:C,setVar:(e,t,l)=>{let n={...j};(e.cascadeIds||[]).forEach(e=>{n.local[e]=n.local[e]||{},n.local[e][t]=l})}},children:m})};function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function j(e,t){if(e){if("string"==typeof e)return v(e,t);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?v(e,t):void 0}}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var l=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var n,r,a,i,o=[],s=!0,d=!1;try{if(a=(l=l.call(e)).next,0===t){if(Object(l)!==l)return;s=!1}else for(;!(s=(n=a.call(l)).done)&&(o.push(n.value),o.length!==t);s=!0);}catch(e){d=!0,r=e}finally{try{if(!s&&null!=l.return&&(i=l.return(),Object(i)!==i))return}finally{if(d)throw r}}return o}}(e,t)||j(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var y=u(951),w="data-pdnd-honey-pot";function C(e){return e instanceof Element&&e.hasAttribute(w)}function S(e){var t=b(document.elementsFromPoint(e.x,e.y),2),l=t[0],n=t[1];return l?C(l)?null!=n?n:null:l:null}function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e,t,l){var n;return(n=function(e,t){if("object"!=I(e)||!e)return e;var l=e[Symbol.toPrimitive];if(void 0!==l){var n=l.call(e,t||"default");if("object"!=I(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==I(n)?n:n+"")in e)?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function z(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}function O(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?z(Object(l),!0).forEach(function(t){k(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):z(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}function N(e){var t,l,n,r,a={x:Math.min((r={x:Math.max((n={x:(l={x:Math.floor((t=e.client).x),y:Math.floor(t.y)}).x-1,y:l.y-1}).x,0),y:Math.max(n.y,0)}).x,window.innerWidth-2),y:Math.min(r.y,window.innerHeight-2)};return DOMRect.fromRect({x:a.x,y:a.y,width:2,height:2})}function T(e){var t=e.clientRect;return{left:"".concat(t.left,"px"),top:"".concat(t.top,"px"),width:"".concat(t.width,"px"),height:"".concat(t.height,"px")}}function R(e){return function(e){if(Array.isArray(e))return v(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e){var t=null;return function(){if(!t){for(var l=arguments.length,n=Array(l),r=0;r<l;r++)n[r]=arguments[r];t={result:e.apply(this,n)}}return t.result}}var D=F(function(){return navigator.userAgent.includes("Firefox")}),E=F(function(){var e=navigator.userAgent;return e.includes("AppleWebKit")&&!e.includes("Chrome")}),A={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};if("undefined"!=typeof window&&E()){var B=M();(0,y.bindAll)(window,[{type:"dragstart",listener:function(){B.enterCount=0,B.isOverWindow=!0}},{type:"drop",listener:P},{type:"dragend",listener:P},{type:"dragenter",listener:function(e){B.isOverWindow||0!==B.enterCount||(e[A.isEnteringWindow]=!0),B.isOverWindow=!0,B.enterCount++}},{type:"dragleave",listener:function(e){B.enterCount--,B.isOverWindow&&0===B.enterCount&&(e[A.isLeavingWindow]=!0,B.isOverWindow=!1)}}],{capture:!0})}function M(){return{enterCount:0,isOverWindow:!1}}function P(){B=M()}function L(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var $=(e=function(e){return e()},t=[],l=null,(n=function(){for(var n=arguments.length,r=Array(n),a=0;a<n;a++)r[a]=arguments[a];t=r,l||(l=requestAnimationFrame(function(){l=null,e.apply(void 0,t)}))}).cancel=function(){l&&(cancelAnimationFrame(l),l=null)},n),Y=(r=null,{schedule:function(e){r={frameId:requestAnimationFrame(function(){r=null,e()}),fn:e}},flush:function(){r&&(cancelAnimationFrame(r.frameId),r.fn(),r=null)}}),_={isActive:!1};function q(){return!_.isActive}function H(e){var t,l=e.event,n=null==(t=e.current[0])?void 0:t.dropEffect;null!=n&&l.dataTransfer&&(l.dataTransfer.dropEffect=n)}var G=function(e){var t=e.event,l=e.dragType,n=e.getDropTargetsOver,r=e.dispatchEvent;if(q()){var a,i,o=function(e){var t=e.event,l=e.dragType,n=e.getDropTargetsOver,r=L(t);if("external"===l.startedFrom)return{input:r,dropTargets:[]};var a=n({input:r,source:l.payload,target:t.target,current:[]});return{input:r,dropTargets:a}}({event:t,dragType:l,getDropTargetsOver:n});_.isActive=!0;var s={current:o};H({event:t,current:o.dropTargets});var d=function(e){var t=e.source,l=e.initial,n=e.dispatchEvent,r={dropTargets:[]};function a(e){n(e),r={dropTargets:e.payload.location.current.dropTargets}}return{start:function(e){var n=e.nativeSetDragImage,i={current:l,previous:r,initial:l};a({eventName:"onGenerateDragPreview",payload:{source:t,location:i,nativeSetDragImage:n}}),Y.schedule(function(){a({eventName:"onDragStart",payload:{source:t,location:i}})})},dragUpdate:function(e){var n=e.current;Y.flush(),$.cancel(),a({eventName:"onDropTargetChange",payload:{source:t,location:{initial:l,previous:r,current:n}}})},drag:function(e){var n=e.current;$(function(){Y.flush(),a({eventName:"onDrag",payload:{source:t,location:{initial:l,previous:r,current:n}}})})},drop:function(e){var n=e.current,i=e.updatedSourcePayload;Y.flush(),$.cancel(),a({eventName:"onDrop",payload:{source:null!=i?i:t,location:{current:n,previous:r,initial:l}}})}}}({source:l.payload,dispatchEvent:r,initial:o}),c=(0,y.bindAll)(window,[{type:"dragover",listener:function(e){p(e),d.drag({current:s.current})}},{type:"dragenter",listener:p},{type:"dragleave",listener:function(e){(function(e){var t=e.dragLeave,l=t.type,n=t.relatedTarget;return"dragleave"===l&&(E()?!!E()&&t.hasOwnProperty(A.isLeavingWindow):null==n||(D()?"nodeName"in n&&n.ownerDocument!==document:n instanceof HTMLIFrameElement))})({dragLeave:e})&&(u({input:s.current.input,dropTargets:[]}),"external"===l.startedFrom&&m())}},{type:"drop",listener:function(e){(s.current={dropTargets:s.current.dropTargets,input:L(e)},s.current.dropTargets.length)?(e.preventDefault(),H({event:e,current:s.current.dropTargets}),d.drop({current:s.current,updatedSourcePayload:"external"===l.type?l.getDropPayload(e):null}),x()):m()}},{type:"dragend",listener:function(e){s.current={dropTargets:s.current.dropTargets,input:L(e)},m()}}].concat(R([{type:"pointermove",listener:(i=0,function(){i<20?i++:a()})},{type:"pointerdown",listener:a=m}])),{capture:!0});d.start({nativeSetDragImage:t.dataTransfer?t.dataTransfer.setDragImage.bind(t.dataTransfer):null})}function u(e){var t=function(e){var t=e.current,l=e.next;if(t.length!==l.length)return!0;for(var n=0;n<t.length;n++)if(t[n].element!==l[n].element)return!0;return!1}({current:s.current.dropTargets,next:e.dropTargets});s.current=e,t&&d.dragUpdate({current:s.current})}function p(e){var t=L(e),r=n({target:C(e.target)?S({x:t.clientX,y:t.clientY}):e.target,input:t,source:l.payload,current:s.current.dropTargets});r.length&&(e.preventDefault(),H({event:e,current:r})),u({dropTargets:r,input:t})}function m(){s.current.dropTargets.length&&u({dropTargets:[],input:s.current.input}),d.drop({current:s.current,updatedSourcePayload:null}),x()}function x(){_.isActive=!1,c()}},U=new Map;function J(){for(var e=arguments.length,t=Array(e),l=0;l<e;l++)t[l]=arguments[l];return function(){t.forEach(function(e){return e()})}}function K(e,t){var l=t.attribute,n=t.value;return e.setAttribute(l,n),function(){return e.removeAttribute(l)}}function W(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}function X(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?W(Object(l),!0).forEach(function(t){k(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):W(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}function V(e,t){var l="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!l){if(Array.isArray(e)||(l=function(e,t){if(e){if("string"==typeof e)return Q(e,void 0);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?Q(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){l&&(e=l);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,o=!1;return{s:function(){l=l.call(e)},n:function(){var e=l.next();return i=e.done,e},e:function(e){o=!0,a=e},f:function(){try{i||null==l.return||l.return()}finally{if(o)throw a}}}}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function Z(e){return e.slice(0).reverse()}function ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function et(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}var el=F(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")}),en="text/plain",er=new WeakMap,ea=(a=null,{bindEvents:function(){return a=null,(0,y.bind)(window,{type:"pointermove",listener:function(e){a={x:e.clientX,y:e.clientY}},options:{capture:!0}})},getOnPostDispatch:function(){var e=null;return function(t){var l=t.eventName,n=t.payload;if("onDragStart"===l){var r,i,o,s=n.location.initial.input,d=null!=a?a:{x:s.clientX,y:s.clientY};(r=document.createElement("div")).setAttribute(w,"true"),i=N({client:d}),Object.assign(r.style,O(O({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},T({clientRect:i})),{},{pointerEvents:"auto",zIndex:0x7fffffff})),document.body.appendChild(r),o=(0,y.bind)(window,{type:"pointermove",listener:function(e){i=N({client:{x:e.clientX,y:e.clientY}}),Object.assign(r.style,T({clientRect:i}))},options:{capture:!0}}),e=function(e){var t,l,n,a=e.current;if(o(),l=(t={client:a,clientRect:i}).client,n=t.clientRect,l.x>=n.x&&l.x<=n.x+n.width&&l.y>=n.y&&l.y<=n.y+n.height)return void r.remove();function s(){d(),r.remove()}var d=(0,y.bindAll)(window,[{type:"pointerdown",listener:s},{type:"pointermove",listener:s},{type:"focusin",listener:s},{type:"focusout",listener:s},{type:"dragstart",listener:s},{type:"dragenter",listener:s},{type:"dragover",listener:s}],{capture:!0})}}if("onDrop"===l){var c,u=n.location.current.input;null==(c=e)||c({current:{x:u.clientX,y:u.clientY}}),e=null,a=null}}}}),ei=function(e){var t=e.typeKey,l=e.mount,n=e.dispatchEventToSource,r=e.onPostDispatch,a=e.defaultDropEffect,i=function(){var e=new Set,t=null;function l(e){t&&(!e.canMonitor||e.canMonitor(t.canMonitorArgs))&&t.active.add(e)}return{dispatchEvent:function(n){var r=n.eventName,a=n.payload;if("onGenerateDragPreview"===r){t={canMonitorArgs:{initial:a.location.initial,source:a.source},active:new Set};var i,o=function(e,t){var l="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!l){if(Array.isArray(e)||(l=function(e,t){if(e){if("string"==typeof e)return ee(e,void 0);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?ee(e,void 0):void 0}}(e))){l&&(e=l);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,o=!1;return{s:function(){l=l.call(e)},n:function(){var e=l.next();return i=e.done,e},e:function(e){o=!0,a=e},f:function(){try{i||null==l.return||l.return()}finally{if(o)throw a}}}}(e);try{for(o.s();!(i=o.n()).done;){var s=i.value;l(s)}}catch(e){o.e(e)}finally{o.f()}}if(t){for(var d=Array.from(t.active),c=0;c<d.length;c++){var u,p=d[c];t.active.has(p)&&(null==(u=p[r])||u.call(p,a))}"onDrop"===r&&(t.active.clear(),t=null)}},monitorForConsumers:function(n){var r=function(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?et(Object(l),!0).forEach(function(t){k(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):et(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}({},n);return e.add(r),l(r),F(function(){e.delete(r),t&&t.active.delete(r)})}}}(),o=function(e){var t=e.typeKey,l=e.defaultDropEffect,n=new WeakMap,r="data-drop-target-for-".concat(t),a="[".concat(r,"]");function i(e){var t,l=e.eventName,r=e.payload,a=V(r.location.current.dropTargets);try{for(a.s();!(t=a.n()).done;){var i,o=t.value,s=n.get(o.element),d=X(X({},r),{},{self:o});null==s||null==(i=s[l])||i.call(s,d)}}catch(e){a.e(e)}finally{a.f()}}var o={onGenerateDragPreview:i,onDrag:i,onDragStart:i,onDrop:i,onDropTargetChange:function(e){var t,l=e.payload,r=new Set(l.location.current.dropTargets.map(function(e){return e.element})),a=new Set,i=V(l.location.previous.dropTargets);try{for(i.s();!(t=i.n()).done;){var o,s,d=t.value;a.add(d.element);var c=n.get(d.element),u=r.has(d.element),p=X(X({},l),{},{self:d});null==c||null==(o=c.onDropTargetChange)||o.call(c,p),u||null==c||null==(s=c.onDragLeave)||s.call(c,p)}}catch(e){i.e(e)}finally{i.f()}var m,x=V(l.location.current.dropTargets);try{for(x.s();!(m=x.n()).done;){var h,f,g=m.value;if(!a.has(g.element)){var v=X(X({},l),{},{self:g}),j=n.get(g.element);null==j||null==(h=j.onDropTargetChange)||h.call(j,v),null==j||null==(f=j.onDragEnter)||f.call(j,v)}}}catch(e){x.e(e)}finally{x.f()}}};return{dropTargetForConsumers:function(e){return F(J(K(e.element,{attribute:r,value:"true"}),(n.set(e.element,e),function(){return n.delete(e.element)})))},getIsOver:function(e){var t=e.source,r=e.target,i=e.input,o=e.current,s=function e(t){var r,i,o,s,d=t.source,c=t.target,u=t.input,p=t.result,m=void 0===p?[]:p;if(null==c)return m;if(!(c instanceof Element))return c instanceof Node?e({source:d,target:c.parentElement,input:u,result:m}):m;var x=c.closest(a);if(null==x)return m;var h=n.get(x);if(null==h)return m;var f={input:u,source:d,element:h.element};if(h.canDrop&&!h.canDrop(f))return e({source:d,target:h.element.parentElement,input:u,result:m});var g=null!=(r=null==(i=h.getData)?void 0:i.call(h,f))?r:{},v=null!=(o=null==(s=h.getDropEffect)?void 0:s.call(h,f))?o:l,j={data:g,element:h.element,dropEffect:v,isActiveDueToStickiness:!1};return e({source:d,target:h.element.parentElement,input:u,result:[].concat(R(m),[j])})}({source:t,target:r,input:i});if(s.length>=o.length)return s;for(var d=Z(o),c=Z(s),u=[],p=0;p<d.length;p++){var m,x=d[p],h=c[p];if(null!=h){u.push(h);continue}var f=u[p-1],g=d[p-1];if((null==f?void 0:f.element)!==(null==g?void 0:g.element))break;var v=n.get(x.element);if(!v)break;var j={input:i,source:t,element:v.element};if(v.canDrop&&!v.canDrop(j)||!(null!=(m=v.getIsSticky)&&m.call(v,j)))break;u.push(X(X({},x),{},{isActiveDueToStickiness:!0}))}return Z(u)},dispatchEvent:function(e){o[e.eventName](e)}}}({typeKey:t,defaultDropEffect:a});function s(e){null==n||n(e),o.dispatchEvent(e),i.dispatchEvent(e),null==r||r(e)}function d(e){G({event:e.event,dragType:e.dragType,getDropTargetsOver:o.getIsOver,dispatchEvent:s})}return{registerUsage:function(){var e,n;return n=function(e){var t=e.typeKey,l=e.mount,n=U.get(t);if(n)return n.usageCount++,n;var r={typeKey:t,unmount:l(),usageCount:1};return U.set(t,r),r}(e={typeKey:t,mount:function(){return l({canStart:q,start:d})}}),function(){n.usageCount--,n.usageCount>0||(n.unmount(),U.delete(e.typeKey))}},dropTarget:o.dropTargetForConsumers,monitor:i.monitorForConsumers}}({typeKey:"element",defaultDropEffect:"move",mount:function(e){return J(ea.bindEvents(),(0,y.bind)(document,{type:"dragstart",listener:function(t){if(e.canStart(t)&&!t.defaultPrevented&&t.dataTransfer){var l,n,r,a,i,o,s=t.target;if(s instanceof HTMLElement){var d=er.get(s);if(d){var c=L(t),u={element:d.element,dragHandle:null!=(l=d.dragHandle)?l:null,input:c};if(d.canDrag&&!d.canDrag(u))return void t.preventDefault();if(d.dragHandle){var p=S({x:c.clientX,y:c.clientY});if(!d.dragHandle.contains(p))return void t.preventDefault()}var m=null!=(n=null==(r=d.getInitialDataForExternal)?void 0:r.call(d,u))?n:null;if(m)for(var x=0,h=Object.entries(m);x<h.length;x++){var f=b(h[x],2),g=f[0],v=f[1];t.dataTransfer.setData(g,null!=v?v:"")}!el()||t.dataTransfer.types.includes(en)||t.dataTransfer.types.includes("text/uri-list")||t.dataTransfer.setData(en,"pdnd:android-fallback"),t.dataTransfer.setData("application/vnd.pdnd","");var j={element:d.element,dragHandle:null!=(a=d.dragHandle)?a:null,data:null!=(i=null==(o=d.getInitialData)?void 0:o.call(d,u))?i:{}};e.start({event:t,dragType:{type:"element",payload:j,startedFrom:"internal"}})}}}}}))},dispatchEventToSource:function(e){var t,l,n=e.eventName,r=e.payload;null==(t=er.get(r.source.element))||null==(l=t[n])||l.call(t,r)},onPostDispatch:ea.getOnPostDispatch()}),eo=ei.dropTarget;function es(e){return F(J(ei.registerUsage(),(er.set(e.element,e),function(){er.delete(e.element)}),K(e.element,{attribute:"draggable",value:"true"})))}ei.monitor;var ed=u(375);let ec=(0,ed.createFromIconfontCN)({scriptUrl:"https://at.alicdn.com/t/c/font_5072483_ufbwxczz8z.js"}),eu=e=>{let{type:t,className:l="",style:n={}}=e;return(0,d.jsx)(ec,{type:t,className:l,style:n})};var ep=u(59),em=u(514),ex=u.n(em),eh=u(247),ef=u.n(eh);let eg=h().div`
2
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@ant-design/icons"),require("echarts"),require("styled-components"),require("react"),require("antd"),require("react-dom"),require("uuid"),require("dayjs"),require("@monaco-editor/react")):"function"==typeof define&&define.amd?define(["@ant-design/icons","echarts","styled-components","react","antd","react-dom","uuid","dayjs","@monaco-editor/react"],t):"object"==typeof exports?exports.BiSdk=t(require("@ant-design/icons"),require("echarts"),require("styled-components"),require("react"),require("antd"),require("react-dom"),require("uuid"),require("dayjs"),require("@monaco-editor/react")):e.BiSdk=t(e["@ant-design/icons"],e.echarts,e["styled-components"],e.react,e.antd,e["react-dom"],e.uuid,e.dayjs,e["@monaco-editor/react"])}(this,(e,t,l,n,r,a,i,o,s)=>(()=>{var d={290(e,t,l){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,l=1,n=arguments.length;l<n;l++)for(var r in t=arguments[l])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.bindAll=void 0;var r=l(352);function a(e){if(void 0!==e)return"boolean"==typeof e?{capture:e}:e}t.bindAll=function(e,t,l){var i=t.map(function(t){var i=null==l?t:n(n({},t),{options:n(n({},a(l)),a(t.options))});return(0,r.bind)(e,i)});return function(){i.forEach(function(e){return e()})}}},352(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.bind=void 0,t.bind=function(e,t){var l=t.type,n=t.listener,r=t.options;return e.addEventListener(l,n,r),function(){e.removeEventListener(l,n,r)}}},951(e,t,l){"use strict";t.bindAll=t.bind=void 0;var n=l(352);Object.defineProperty(t,"bind",{enumerable:!0,get:function(){return n.bind}});var r=l(290);Object.defineProperty(t,"bindAll",{enumerable:!0,get:function(){return r.bindAll}})},965(e,t,l){"use strict";var n=l(426),r={"text/plain":"Text","text/html":"Url",default:"Text"};e.exports=function(e,t){var l,a,i,o,s,d,c,u,p=!1;t||(t={}),i=t.debug||!1;try{if(s=n(),d=document.createRange(),c=document.getSelection(),(u=document.createElement("span")).textContent=e,u.ariaHidden="true",u.style.all="unset",u.style.position="fixed",u.style.top=0,u.style.clip="rect(0, 0, 0, 0)",u.style.whiteSpace="pre",u.style.webkitUserSelect="text",u.style.MozUserSelect="text",u.style.msUserSelect="text",u.style.userSelect="text",u.addEventListener("copy",function(l){if(l.stopPropagation(),t.format)if(l.preventDefault(),void 0===l.clipboardData){i&&console.warn("unable to use e.clipboardData"),i&&console.warn("trying IE specific stuff"),window.clipboardData.clearData();var n=r[t.format]||r.default;window.clipboardData.setData(n,e)}else l.clipboardData.clearData(),l.clipboardData.setData(t.format,e);t.onCopy&&(l.preventDefault(),t.onCopy(l.clipboardData))}),document.body.appendChild(u),d.selectNodeContents(u),c.addRange(d),!document.execCommand("copy"))throw Error("copy command was unsuccessful");p=!0}catch(n){i&&console.error("unable to copy using execCommand: ",n),i&&console.warn("trying IE specific stuff");try{window.clipboardData.setData(t.format||"text",e),t.onCopy&&t.onCopy(window.clipboardData),p=!0}catch(n){i&&console.error("unable to copy using clipboardData: ",n),i&&console.error("falling back to prompt"),l="message"in t?t.message:"Copy to clipboard: #{key}, Enter",a=(/mac os x/i.test(navigator.userAgent)?"⌘":"Ctrl")+"+C",o=l.replace(/#{\s*key\s*}/g,a),window.prompt(o,e)}}finally{c&&("function"==typeof c.removeRange?c.removeRange(d):c.removeAllRanges()),u&&document.body.removeChild(u),s()}return p}},20(e,t,l){"use strict";var n=l(155),r=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function d(e,t,l){var n,a={},d=null,c=null;for(n in void 0!==l&&(d=""+l),void 0!==t.key&&(d=""+t.key),void 0!==t.ref&&(c=t.ref),t)i.call(t,n)&&!s.hasOwnProperty(n)&&(a[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===a[n]&&(a[n]=t[n]);return{$$typeof:r,type:e,key:d,ref:c,props:a,_owner:o.current}}t.Fragment=a,t.jsx=d,t.jsxs=d},848(e,t,l){"use strict";e.exports=l(20)},426(e){e.exports=function(){var e=document.getSelection();if(!e.rangeCount)return function(){};for(var t=document.activeElement,l=[],n=0;n<e.rangeCount;n++)l.push(e.getRangeAt(n));switch(t.tagName.toUpperCase()){case"INPUT":case"TEXTAREA":t.blur();break;default:t=null}return e.removeAllRanges(),function(){"Caret"===e.type&&e.removeAllRanges(),e.rangeCount||l.forEach(function(t){e.addRange(t)}),t&&t.focus()}}},375(t){"use strict";t.exports=e},247(e){"use strict";e.exports=s},59(e){"use strict";e.exports=r},185(e){"use strict";e.exports=o},190(e){"use strict";e.exports=t},155(e){"use strict";e.exports=n},514(e){"use strict";e.exports=a},694(e){"use strict";e.exports=l},315(e){"use strict";e.exports=i}},c={};function u(e){var t=c[e];if(void 0!==t)return t.exports;var l=c[e]={exports:{}};return d[e].call(l.exports,l,l.exports,u),l.exports}u.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return u.d(t,{a:t}),t},u.d=(e,t)=>{for(var l in t)u.o(t,l)&&!u.o(e,l)&&Object.defineProperty(e,l,{enumerable:!0,get:t[l]})},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var p={};return(()=>{"use strict";u.r(p),u.d(p,{PluginType:()=>o.PluginType,PageCanvas:()=>ek,PageContext:()=>f,PageDesigner:()=>tc,PageSchema:()=>o.PageSchema,plugins:()=>tz,PropEditorProps:()=>s.PropEditorProps,PageProvider:()=>g,DropContainer:()=>eC});var e,t,l,n,r,a,i,o={};u.r(o),u.d(o,{P:()=>tu});var s={};u.r(s);var d=u(848),c=u(155),m=u.n(c),x=u(694),h=u.n(x);let f=(0,c.createContext)({pageId:"",designable:!1,plugins:[],schema:{info:{},datasources:[],scripts:[],variables:[],items:[]},selectedItem:null,atItems:null,setSchema:()=>{},setSelectedItem:()=>{},updateSelectedItem:()=>{},forceUpdate:()=>{},onAddAtItem:()=>{},onRemoveAtItem:()=>{},clearAtItems:()=>{},datasetSelector:void 0,datasetAdd:void 0,fetch:void 0,deviceWidth:0,setDeviceWidth:()=>{},initCallback:()=>{},handleCallback:()=>{},getVars:()=>({}),setVar:()=>{}}),g=e=>{let{pageId:t,designable:l,plugins:n,schema:r,selectedItem:a,setSchema:i,setSelectedItem:o,datasetSelector:s,datasetAdd:u,fetch:p,children:m}=e,[x,h]=(0,c.useState)(0),[g,v]=(0,c.useState)([]),[j,b]=(0,c.useState)({global:{},local:{}}),[y,w]=(0,c.useState)({}),C=e=>({...j.global,...j.local[e||""]||{}});return(0,c.useEffect)(()=>{let e={};(r.variables||[]).forEach(t=>{e[t.name]=t.value}),b(t=>({...t,global:e}))},[r.variables]),(0,d.jsx)(f.Provider,{value:{pageId:t,designable:!!l,plugins:n||[],schema:r,selectedItem:a,atItems:g,setSchema:i||(()=>{}),setSelectedItem:o||(()=>{}),updateSelectedItem:e=>{null==o||o(Object.assign(a,e||{})),null==i||i({...r})},datasetSelector:s,datasetAdd:u,fetch:p,forceUpdate:()=>{null==i||i({...r})},onAddAtItem:e=>{null!=g&&g.includes(e)||v([...g,e])},onRemoveAtItem:e=>{v(g.filter(t=>t!==e))},clearAtItems:()=>{v([])},deviceWidth:x,setDeviceWidth:h||(()=>{}),initCallback:e=>{let{id:t,callback:l}=e;w(e=>({...e,[t]:l}))},handleCallback:(e,t,l)=>{(e.cascadeIds||[]).forEach(e=>{let n=y[e];if("function"==typeof n){let r=n(t,C(e));if(r){let{target:e,data:t}=r;null==l||l(e,t)}}})},getVars:C,setVar:(e,t,l)=>{let n={...j};(e.cascadeIds||[]).forEach(e=>{n.local[e]=n.local[e]||{},n.local[e][t]=l})}},children:m})};function v(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function j(e,t){if(e){if("string"==typeof e)return v(e,t);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?v(e,t):void 0}}function b(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var l=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=l){var n,r,a,i,o=[],s=!0,d=!1;try{if(a=(l=l.call(e)).next,0===t){if(Object(l)!==l)return;s=!1}else for(;!(s=(n=a.call(l)).done)&&(o.push(n.value),o.length!==t);s=!0);}catch(e){d=!0,r=e}finally{try{if(!s&&null!=l.return&&(i=l.return(),Object(i)!==i))return}finally{if(d)throw r}}return o}}(e,t)||j(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var y=u(951),w="data-pdnd-honey-pot";function C(e){return e instanceof Element&&e.hasAttribute(w)}function S(e){var t=b(document.elementsFromPoint(e.x,e.y),2),l=t[0],n=t[1];return l?C(l)?null!=n?n:null:l:null}function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function k(e,t,l){var n;return(n=function(e,t){if("object"!=I(e)||!e)return e;var l=e[Symbol.toPrimitive];if(void 0!==l){var n=l.call(e,t||"default");if("object"!=I(n))return n;throw TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(t,"string"),(t="symbol"==I(n)?n:n+"")in e)?Object.defineProperty(e,t,{value:l,enumerable:!0,configurable:!0,writable:!0}):e[t]=l,e}function z(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}function O(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?z(Object(l),!0).forEach(function(t){k(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):z(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}function N(e){var t,l,n,r,a={x:Math.min((r={x:Math.max((n={x:(l={x:Math.floor((t=e.client).x),y:Math.floor(t.y)}).x-1,y:l.y-1}).x,0),y:Math.max(n.y,0)}).x,window.innerWidth-2),y:Math.min(r.y,window.innerHeight-2)};return DOMRect.fromRect({x:a.x,y:a.y,width:2,height:2})}function T(e){var t=e.clientRect;return{left:"".concat(t.left,"px"),top:"".concat(t.top,"px"),width:"".concat(t.width,"px"),height:"".concat(t.height,"px")}}function R(e){return function(e){if(Array.isArray(e))return v(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||j(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function F(e){var t=null;return function(){if(!t){for(var l=arguments.length,n=Array(l),r=0;r<l;r++)n[r]=arguments[r];t={result:e.apply(this,n)}}return t.result}}var D=F(function(){return navigator.userAgent.includes("Firefox")}),A=F(function(){var e=navigator.userAgent;return e.includes("AppleWebKit")&&!e.includes("Chrome")}),E={isLeavingWindow:Symbol("leaving"),isEnteringWindow:Symbol("entering")};if("undefined"!=typeof window&&A()){var B=M();(0,y.bindAll)(window,[{type:"dragstart",listener:function(){B.enterCount=0,B.isOverWindow=!0}},{type:"drop",listener:P},{type:"dragend",listener:P},{type:"dragenter",listener:function(e){B.isOverWindow||0!==B.enterCount||(e[E.isEnteringWindow]=!0),B.isOverWindow=!0,B.enterCount++}},{type:"dragleave",listener:function(e){B.enterCount--,B.isOverWindow&&0===B.enterCount&&(e[E.isLeavingWindow]=!0,B.isOverWindow=!1)}}],{capture:!0})}function M(){return{enterCount:0,isOverWindow:!1}}function P(){B=M()}function L(e){return{altKey:e.altKey,button:e.button,buttons:e.buttons,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,clientX:e.clientX,clientY:e.clientY,pageX:e.pageX,pageY:e.pageY}}var $=(e=function(e){return e()},t=[],l=null,(n=function(){for(var n=arguments.length,r=Array(n),a=0;a<n;a++)r[a]=arguments[a];t=r,l||(l=requestAnimationFrame(function(){l=null,e.apply(void 0,t)}))}).cancel=function(){l&&(cancelAnimationFrame(l),l=null)},n),Y=(r=null,{schedule:function(e){r={frameId:requestAnimationFrame(function(){r=null,e()}),fn:e}},flush:function(){r&&(cancelAnimationFrame(r.frameId),r.fn(),r=null)}}),_={isActive:!1};function q(){return!_.isActive}function H(e){var t,l=e.event,n=null==(t=e.current[0])?void 0:t.dropEffect;null!=n&&l.dataTransfer&&(l.dataTransfer.dropEffect=n)}var G=function(e){var t=e.event,l=e.dragType,n=e.getDropTargetsOver,r=e.dispatchEvent;if(q()){var a,i,o=function(e){var t=e.event,l=e.dragType,n=e.getDropTargetsOver,r=L(t);if("external"===l.startedFrom)return{input:r,dropTargets:[]};var a=n({input:r,source:l.payload,target:t.target,current:[]});return{input:r,dropTargets:a}}({event:t,dragType:l,getDropTargetsOver:n});_.isActive=!0;var s={current:o};H({event:t,current:o.dropTargets});var d=function(e){var t=e.source,l=e.initial,n=e.dispatchEvent,r={dropTargets:[]};function a(e){n(e),r={dropTargets:e.payload.location.current.dropTargets}}return{start:function(e){var n=e.nativeSetDragImage,i={current:l,previous:r,initial:l};a({eventName:"onGenerateDragPreview",payload:{source:t,location:i,nativeSetDragImage:n}}),Y.schedule(function(){a({eventName:"onDragStart",payload:{source:t,location:i}})})},dragUpdate:function(e){var n=e.current;Y.flush(),$.cancel(),a({eventName:"onDropTargetChange",payload:{source:t,location:{initial:l,previous:r,current:n}}})},drag:function(e){var n=e.current;$(function(){Y.flush(),a({eventName:"onDrag",payload:{source:t,location:{initial:l,previous:r,current:n}}})})},drop:function(e){var n=e.current,i=e.updatedSourcePayload;Y.flush(),$.cancel(),a({eventName:"onDrop",payload:{source:null!=i?i:t,location:{current:n,previous:r,initial:l}}})}}}({source:l.payload,dispatchEvent:r,initial:o}),c=(0,y.bindAll)(window,[{type:"dragover",listener:function(e){p(e),d.drag({current:s.current})}},{type:"dragenter",listener:p},{type:"dragleave",listener:function(e){(function(e){var t=e.dragLeave,l=t.type,n=t.relatedTarget;return"dragleave"===l&&(A()?!!A()&&t.hasOwnProperty(E.isLeavingWindow):null==n||(D()?"nodeName"in n&&n.ownerDocument!==document:n instanceof HTMLIFrameElement))})({dragLeave:e})&&(u({input:s.current.input,dropTargets:[]}),"external"===l.startedFrom&&m())}},{type:"drop",listener:function(e){(s.current={dropTargets:s.current.dropTargets,input:L(e)},s.current.dropTargets.length)?(e.preventDefault(),H({event:e,current:s.current.dropTargets}),d.drop({current:s.current,updatedSourcePayload:"external"===l.type?l.getDropPayload(e):null}),x()):m()}},{type:"dragend",listener:function(e){s.current={dropTargets:s.current.dropTargets,input:L(e)},m()}}].concat(R([{type:"pointermove",listener:(i=0,function(){i<20?i++:a()})},{type:"pointerdown",listener:a=m}])),{capture:!0});d.start({nativeSetDragImage:t.dataTransfer?t.dataTransfer.setDragImage.bind(t.dataTransfer):null})}function u(e){var t=function(e){var t=e.current,l=e.next;if(t.length!==l.length)return!0;for(var n=0;n<t.length;n++)if(t[n].element!==l[n].element)return!0;return!1}({current:s.current.dropTargets,next:e.dropTargets});s.current=e,t&&d.dragUpdate({current:s.current})}function p(e){var t=L(e),r=n({target:C(e.target)?S({x:t.clientX,y:t.clientY}):e.target,input:t,source:l.payload,current:s.current.dropTargets});r.length&&(e.preventDefault(),H({event:e,current:r})),u({dropTargets:r,input:t})}function m(){s.current.dropTargets.length&&u({dropTargets:[],input:s.current.input}),d.drop({current:s.current,updatedSourcePayload:null}),x()}function x(){_.isActive=!1,c()}},U=new Map;function J(){for(var e=arguments.length,t=Array(e),l=0;l<e;l++)t[l]=arguments[l];return function(){t.forEach(function(e){return e()})}}function K(e,t){var l=t.attribute,n=t.value;return e.setAttribute(l,n),function(){return e.removeAttribute(l)}}function W(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}function X(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?W(Object(l),!0).forEach(function(t){k(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):W(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}function V(e,t){var l="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!l){if(Array.isArray(e)||(l=function(e,t){if(e){if("string"==typeof e)return Q(e,void 0);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?Q(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){l&&(e=l);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,o=!1;return{s:function(){l=l.call(e)},n:function(){var e=l.next();return i=e.done,e},e:function(e){o=!0,a=e},f:function(){try{i||null==l.return||l.return()}finally{if(o)throw a}}}}function Q(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function Z(e){return e.slice(0).reverse()}function ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var l=0,n=Array(t);l<t;l++)n[l]=e[l];return n}function et(e,t){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),l.push.apply(l,n)}return l}var el=F(function(){return navigator.userAgent.toLocaleLowerCase().includes("android")}),en="text/plain",er=new WeakMap,ea=(a=null,{bindEvents:function(){return a=null,(0,y.bind)(window,{type:"pointermove",listener:function(e){a={x:e.clientX,y:e.clientY}},options:{capture:!0}})},getOnPostDispatch:function(){var e=null;return function(t){var l=t.eventName,n=t.payload;if("onDragStart"===l){var r,i,o,s=n.location.initial.input,d=null!=a?a:{x:s.clientX,y:s.clientY};(r=document.createElement("div")).setAttribute(w,"true"),i=N({client:d}),Object.assign(r.style,O(O({backgroundColor:"transparent",position:"fixed",padding:0,margin:0,boxSizing:"border-box"},T({clientRect:i})),{},{pointerEvents:"auto",zIndex:0x7fffffff})),document.body.appendChild(r),o=(0,y.bind)(window,{type:"pointermove",listener:function(e){i=N({client:{x:e.clientX,y:e.clientY}}),Object.assign(r.style,T({clientRect:i}))},options:{capture:!0}}),e=function(e){var t,l,n,a=e.current;if(o(),l=(t={client:a,clientRect:i}).client,n=t.clientRect,l.x>=n.x&&l.x<=n.x+n.width&&l.y>=n.y&&l.y<=n.y+n.height)return void r.remove();function s(){d(),r.remove()}var d=(0,y.bindAll)(window,[{type:"pointerdown",listener:s},{type:"pointermove",listener:s},{type:"focusin",listener:s},{type:"focusout",listener:s},{type:"dragstart",listener:s},{type:"dragenter",listener:s},{type:"dragover",listener:s}],{capture:!0})}}if("onDrop"===l){var c,u=n.location.current.input;null==(c=e)||c({current:{x:u.clientX,y:u.clientY}}),e=null,a=null}}}}),ei=function(e){var t=e.typeKey,l=e.mount,n=e.dispatchEventToSource,r=e.onPostDispatch,a=e.defaultDropEffect,i=function(){var e=new Set,t=null;function l(e){t&&(!e.canMonitor||e.canMonitor(t.canMonitorArgs))&&t.active.add(e)}return{dispatchEvent:function(n){var r=n.eventName,a=n.payload;if("onGenerateDragPreview"===r){t={canMonitorArgs:{initial:a.location.initial,source:a.source},active:new Set};var i,o=function(e,t){var l="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!l){if(Array.isArray(e)||(l=function(e,t){if(e){if("string"==typeof e)return ee(e,void 0);var l=({}).toString.call(e).slice(8,-1);return"Object"===l&&e.constructor&&(l=e.constructor.name),"Map"===l||"Set"===l?Array.from(e):"Arguments"===l||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(l)?ee(e,void 0):void 0}}(e))){l&&(e=l);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,i=!0,o=!1;return{s:function(){l=l.call(e)},n:function(){var e=l.next();return i=e.done,e},e:function(e){o=!0,a=e},f:function(){try{i||null==l.return||l.return()}finally{if(o)throw a}}}}(e);try{for(o.s();!(i=o.n()).done;){var s=i.value;l(s)}}catch(e){o.e(e)}finally{o.f()}}if(t){for(var d=Array.from(t.active),c=0;c<d.length;c++){var u,p=d[c];t.active.has(p)&&(null==(u=p[r])||u.call(p,a))}"onDrop"===r&&(t.active.clear(),t=null)}},monitorForConsumers:function(n){var r=function(e){for(var t=1;t<arguments.length;t++){var l=null!=arguments[t]?arguments[t]:{};t%2?et(Object(l),!0).forEach(function(t){k(e,t,l[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):et(Object(l)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(l,t))})}return e}({},n);return e.add(r),l(r),F(function(){e.delete(r),t&&t.active.delete(r)})}}}(),o=function(e){var t=e.typeKey,l=e.defaultDropEffect,n=new WeakMap,r="data-drop-target-for-".concat(t),a="[".concat(r,"]");function i(e){var t,l=e.eventName,r=e.payload,a=V(r.location.current.dropTargets);try{for(a.s();!(t=a.n()).done;){var i,o=t.value,s=n.get(o.element),d=X(X({},r),{},{self:o});null==s||null==(i=s[l])||i.call(s,d)}}catch(e){a.e(e)}finally{a.f()}}var o={onGenerateDragPreview:i,onDrag:i,onDragStart:i,onDrop:i,onDropTargetChange:function(e){var t,l=e.payload,r=new Set(l.location.current.dropTargets.map(function(e){return e.element})),a=new Set,i=V(l.location.previous.dropTargets);try{for(i.s();!(t=i.n()).done;){var o,s,d=t.value;a.add(d.element);var c=n.get(d.element),u=r.has(d.element),p=X(X({},l),{},{self:d});null==c||null==(o=c.onDropTargetChange)||o.call(c,p),u||null==c||null==(s=c.onDragLeave)||s.call(c,p)}}catch(e){i.e(e)}finally{i.f()}var m,x=V(l.location.current.dropTargets);try{for(x.s();!(m=x.n()).done;){var h,f,g=m.value;if(!a.has(g.element)){var v=X(X({},l),{},{self:g}),j=n.get(g.element);null==j||null==(h=j.onDropTargetChange)||h.call(j,v),null==j||null==(f=j.onDragEnter)||f.call(j,v)}}}catch(e){x.e(e)}finally{x.f()}}};return{dropTargetForConsumers:function(e){return F(J(K(e.element,{attribute:r,value:"true"}),(n.set(e.element,e),function(){return n.delete(e.element)})))},getIsOver:function(e){var t=e.source,r=e.target,i=e.input,o=e.current,s=function e(t){var r,i,o,s,d=t.source,c=t.target,u=t.input,p=t.result,m=void 0===p?[]:p;if(null==c)return m;if(!(c instanceof Element))return c instanceof Node?e({source:d,target:c.parentElement,input:u,result:m}):m;var x=c.closest(a);if(null==x)return m;var h=n.get(x);if(null==h)return m;var f={input:u,source:d,element:h.element};if(h.canDrop&&!h.canDrop(f))return e({source:d,target:h.element.parentElement,input:u,result:m});var g=null!=(r=null==(i=h.getData)?void 0:i.call(h,f))?r:{},v=null!=(o=null==(s=h.getDropEffect)?void 0:s.call(h,f))?o:l,j={data:g,element:h.element,dropEffect:v,isActiveDueToStickiness:!1};return e({source:d,target:h.element.parentElement,input:u,result:[].concat(R(m),[j])})}({source:t,target:r,input:i});if(s.length>=o.length)return s;for(var d=Z(o),c=Z(s),u=[],p=0;p<d.length;p++){var m,x=d[p],h=c[p];if(null!=h){u.push(h);continue}var f=u[p-1],g=d[p-1];if((null==f?void 0:f.element)!==(null==g?void 0:g.element))break;var v=n.get(x.element);if(!v)break;var j={input:i,source:t,element:v.element};if(v.canDrop&&!v.canDrop(j)||!(null!=(m=v.getIsSticky)&&m.call(v,j)))break;u.push(X(X({},x),{},{isActiveDueToStickiness:!0}))}return Z(u)},dispatchEvent:function(e){o[e.eventName](e)}}}({typeKey:t,defaultDropEffect:a});function s(e){null==n||n(e),o.dispatchEvent(e),i.dispatchEvent(e),null==r||r(e)}function d(e){G({event:e.event,dragType:e.dragType,getDropTargetsOver:o.getIsOver,dispatchEvent:s})}return{registerUsage:function(){var e,n;return n=function(e){var t=e.typeKey,l=e.mount,n=U.get(t);if(n)return n.usageCount++,n;var r={typeKey:t,unmount:l(),usageCount:1};return U.set(t,r),r}(e={typeKey:t,mount:function(){return l({canStart:q,start:d})}}),function(){n.usageCount--,n.usageCount>0||(n.unmount(),U.delete(e.typeKey))}},dropTarget:o.dropTargetForConsumers,monitor:i.monitorForConsumers}}({typeKey:"element",defaultDropEffect:"move",mount:function(e){return J(ea.bindEvents(),(0,y.bind)(document,{type:"dragstart",listener:function(t){if(e.canStart(t)&&!t.defaultPrevented&&t.dataTransfer){var l,n,r,a,i,o,s=t.target;if(s instanceof HTMLElement){var d=er.get(s);if(d){var c=L(t),u={element:d.element,dragHandle:null!=(l=d.dragHandle)?l:null,input:c};if(d.canDrag&&!d.canDrag(u))return void t.preventDefault();if(d.dragHandle){var p=S({x:c.clientX,y:c.clientY});if(!d.dragHandle.contains(p))return void t.preventDefault()}var m=null!=(n=null==(r=d.getInitialDataForExternal)?void 0:r.call(d,u))?n:null;if(m)for(var x=0,h=Object.entries(m);x<h.length;x++){var f=b(h[x],2),g=f[0],v=f[1];t.dataTransfer.setData(g,null!=v?v:"")}!el()||t.dataTransfer.types.includes(en)||t.dataTransfer.types.includes("text/uri-list")||t.dataTransfer.setData(en,"pdnd:android-fallback"),t.dataTransfer.setData("application/vnd.pdnd","");var j={element:d.element,dragHandle:null!=(a=d.dragHandle)?a:null,data:null!=(i=null==(o=d.getInitialData)?void 0:o.call(d,u))?i:{}};e.start({event:t,dragType:{type:"element",payload:j,startedFrom:"internal"}})}}}}}))},dispatchEventToSource:function(e){var t,l,n=e.eventName,r=e.payload;null==(t=er.get(r.source.element))||null==(l=t[n])||l.call(t,r)},onPostDispatch:ea.getOnPostDispatch()}),eo=ei.dropTarget;function es(e){return F(J(ei.registerUsage(),(er.set(e.element,e),function(){er.delete(e.element)}),K(e.element,{attribute:"draggable",value:"true"})))}ei.monitor;var ed=u(375);let ec=(0,ed.createFromIconfontCN)({scriptUrl:"https://at.alicdn.com/t/c/font_5072483_ufbwxczz8z.js"}),eu=e=>{let{type:t,className:l="",style:n={}}=e;return(0,d.jsx)(ec,{type:t,className:l,style:n})};var ep=u(59),em=u(514),ex=u.n(em),eh=u(247),ef=u.n(eh);let eg=h().div`
3
3
  display: flex;
4
4
  flex-direction: row;
5
5
  align-items: flex-end;
@@ -360,7 +360,7 @@
360
360
  .send-btn.send-btn-active {
361
361
  background-color: var(--ant-color-primary);
362
362
  }
363
- `,eF=[],eD=[],eE=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","audio/wav"],eA=[".xlsx",".wav"],eB=e=>{let{open:t,onCancel:l,onOk:n,allowedExtensions:r,allowedMimeTypes:a}=e,[i,o]=(0,c.useState)([]);(0,c.useEffect)(()=>{t&&o([])},[t]);let s=[...eA,...eE].join(",");return(0,d.jsxs)(ep.Modal,{title:"上传文件",open:t,okText:"上传",cancelText:"取消",onOk:()=>{n(i),l()},onCancel:l,width:600,children:[(0,d.jsx)("div",{style:{marginBottom:16},children:(0,d.jsxs)(ep.Typography.Text,{type:"secondary",children:["支持的文件类型:",r.join(", "),(0,d.jsx)("br",{}),"单次支持上传多个文件,请确保文件内容合规。",(0,d.jsx)("br",{}),"Excel 暂不支持加密文件。",(0,d.jsx)("br",{}),"不支持 xls 电子表格,请自行转换为 xlsx 格式。",(0,d.jsx)("br",{}),"Excel 仅支持第一行为表头、第二行开始为数据,不支持合并单元格。"]})}),(0,d.jsxs)(ep.Upload.Dragger,{...{name:"file",multiple:!0,accept:s,fileList:[],beforeUpload:e=>{let t=a.includes(e.type)||!e.type,l=(e.name||"").substring(e.name.lastIndexOf(".")).toLowerCase(),n=r.includes(l);return t||n?(o(t=>[...t,e]),!1):(ep.message.error(`不支持的文件类型: ${e.name}`),ep.Upload.LIST_IGNORE)}},children:[(0,d.jsx)("p",{className:"ant-upload-drag-icon",children:(0,d.jsx)(ed.InboxOutlined,{})}),(0,d.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此处上传"}),(0,d.jsx)("p",{className:"ant-upload-hint",children:"支持上传Excel表格数据或音频文件进行分析"})]}),i.length>0&&(0,d.jsxs)("div",{style:{marginTop:16},children:[(0,d.jsxs)(ep.Typography.Title,{level:5,style:{fontSize:14,marginBottom:8},children:["已选文件 (",i.length,")"]}),(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:200,overflowY:"auto"},children:i.map((e,t)=>(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"#f5f5f5",borderRadius:4},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[e.name.endsWith(".xlsx")?(0,d.jsx)(ed.FileExcelOutlined,{style:{color:"#52c41a"}}):(0,d.jsx)(ed.AudioOutlined,{style:{color:"#1890ff"}}),(0,d.jsx)(ep.Typography.Text,{ellipsis:!0,style:{maxWidth:300},children:e.name}),(0,d.jsxs)(ep.Typography.Text,{type:"secondary",style:{fontSize:12},children:["(",(e.size/1024).toFixed(1)," KB)"]})]}),(0,d.jsx)(ep.Button,{type:"text",size:"small",icon:(0,d.jsx)(ed.DeleteOutlined,{}),onClick:()=>{o(e=>e.filter((e,l)=>l!==t))},danger:!0})]},`${e.name}-${t}`))})]})]})},eM=m().forwardRef((e,t)=>{let{value:l="",placeholder:n="请输入需求,例如:分析 2025 年人口结构并生成可视化报告",disabled:r=!1,sending:a=!1,rows:i=6,agentList:o=eF,agentId:s=null,attachments:u=eD,atItems:p=null,onInput:m,onSubmit:x,onUpdateAgentId:h,onUpdateAttachments:f,onUploading:g,onRemoveAtItem:v,style:j={}}=e,b=(0,c.useRef)(null),[y,w]=(0,c.useState)([]),[C,S]=(0,c.useState)(l||""),[I,k]=(0,c.useState)(0),[z,O]=(0,c.useState)(Array.isArray(u)?u:[]),[N,T]=(0,c.useState)(!1),R=(0,c.useMemo)(()=>!1,[]);(0,c.useImperativeHandle)(t,()=>({focus(){var e;null==(e=b.current)||e.focus()}})),(0,c.useEffect)(()=>S(l||""),[l]),(0,c.useEffect)(()=>{m&&m(C)},[C]),(0,c.useEffect)(()=>O(Array.isArray(u)?u:[]),[u]);let F=!!(C&&C.trim()),D=async e=>{if(T(!1),!g||!e.length)return;let t=[];for(let l of e)try{let e=await g(l);e&&t.push({id:e.id,name:l.name,size:l.size})}catch(e){console.error(e)}O([...z,...t]),f&&f([...z,...t])},E=()=>{if(!F||a)return;let e=Date.now();if(e-I<400)return;k(e);let t=(C||"").trim();if(!t)return;let l={message:t,agents:y.map(e=>({id:e.id,name:e.name})),files:z.map(e=>({id:e.id,name:e.name,extension:e.name.substring(e.name.lastIndexOf("."))}))};x&&x(l),S(""),O([])},A=(0,d.jsx)(eT,{children:(0,d.jsx)("ul",{className:"agent-list",children:o.map(e=>(0,d.jsx)("li",{children:(0,d.jsx)("a",{onClick:()=>{let t;return t=e.id||null,void(h&&h(t),w(t=>[...t,e]))},children:e.name})},String(e.id)))})});return(0,d.jsx)(eR,{style:j,children:(0,d.jsxs)("div",{className:"chat-input",children:[(0,d.jsxs)("div",{className:"input-stack",children:[z.length>0&&(0,d.jsx)("div",{className:"attachment-bar beautified_scrollbar",children:z.map(e=>(0,d.jsxs)("div",{className:"attachment-card",children:[e.name.endsWith(".xlsx")?(0,d.jsx)(eu,{type:"icon-excel"}):(0,d.jsx)(eu,{type:"icon-audio"}),(0,d.jsx)(ep.Typography.Text,{className:"name",ellipsis:{tooltip:e.name},children:e.name}),(0,d.jsx)("a",{className:"remove",onClick:()=>{var t;let l;return t=e.id,void(O(l=z.filter(e=>e.id!==t)),f&&f(l))},children:(0,d.jsx)(ed.DeleteOutlined,{})})]},e.id))}),y.length>0&&(0,d.jsx)("div",{className:"agent-info",children:y.map((e,t)=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("span",{className:"name",children:[(0,d.jsx)(eu,{type:"icon-at"}),e.name]}),(0,d.jsx)("a",{className:"remove",onClick:()=>{h&&h(null),w(e=>e.filter((e,l)=>l!==t))},children:"\xd7"})]},String(e.id)))}),!!(null==p?void 0:p.length)&&(0,d.jsx)("div",{className:"agent-info",children:p.map((e,t)=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("span",{className:"name",children:[(0,d.jsx)(eu,{type:"icon-number"}),e.name||e.id]}),(0,d.jsx)("a",{className:"remove",onClick:()=>null==v?void 0:v(e,t),children:"\xd7"})]},String(e.id)))}),(0,d.jsx)(ep.Input.TextArea,{ref:b,className:"input textarea-stacked",placeholder:n,disabled:r||a,autoSize:{minRows:i,maxRows:i},value:C,onPressEnter:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),E()))},onChange:e=>S(e.target.value)})]}),(0,d.jsxs)("div",{className:"footer",children:[(0,d.jsxs)("div",{className:"left",children:[!!(null==o?void 0:o.length)&&(0,d.jsx)(ep.Dropdown,{trigger:["click"],popupRender:()=>A,placement:"topLeft",styles:{root:{boxShadow:"var(--ant-box-shadow-card)"}},children:(0,d.jsx)(ep.Tooltip,{title:"选择助理",children:(0,d.jsx)(ep.Button,{className:"agent-trigger",onClick:e=>e.preventDefault(),children:(0,d.jsx)(eu,{type:"icon-at"})})})}),g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ep.Tooltip,{title:"上传文件",children:(0,d.jsx)(ep.Button,{className:"attach-upload",onClick:()=>T(!0),disabled:r||a,children:(0,d.jsx)(eu,{type:"icon-paper-clip"})})}),(0,d.jsx)(eB,{open:N,onCancel:()=>T(!1),onOk:D,allowedExtensions:eA,allowedMimeTypes:eE})]})]}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!R&&(0,d.jsx)("div",{className:"tips",children:"按 Enter 发送,Shift+Enter 换行"}),(0,d.jsx)("a",{className:`send-btn ${!a&&(null==C?void 0:C.length)>0?"send-btn-active":""}`,onClick:E,children:(0,d.jsx)(ed.SendOutlined,{})})]})]})]})})}),eP=h().div`
363
+ `,eF=[],eD=[],eA=["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","audio/wav"],eE=[".xlsx",".wav"],eB=e=>{let{open:t,onCancel:l,onOk:n,allowedExtensions:r,allowedMimeTypes:a}=e,[i,o]=(0,c.useState)([]);(0,c.useEffect)(()=>{t&&o([])},[t]);let s=[...eE,...eA].join(",");return(0,d.jsxs)(ep.Modal,{title:"上传文件",open:t,okText:"上传",cancelText:"取消",onOk:()=>{n(i),l()},onCancel:l,width:600,children:[(0,d.jsx)("div",{style:{marginBottom:16},children:(0,d.jsxs)(ep.Typography.Text,{type:"secondary",children:["支持的文件类型:",r.join(", "),(0,d.jsx)("br",{}),"单次支持上传多个文件,请确保文件内容合规。",(0,d.jsx)("br",{}),"Excel 暂不支持加密文件。",(0,d.jsx)("br",{}),"不支持 xls 电子表格,请自行转换为 xlsx 格式。",(0,d.jsx)("br",{}),"Excel 仅支持第一行为表头、第二行开始为数据,不支持合并单元格。"]})}),(0,d.jsxs)(ep.Upload.Dragger,{...{name:"file",multiple:!0,accept:s,fileList:[],beforeUpload:e=>{let t=a.includes(e.type)||!e.type,l=(e.name||"").substring(e.name.lastIndexOf(".")).toLowerCase(),n=r.includes(l);return t||n?(o(t=>[...t,e]),!1):(ep.message.error(`不支持的文件类型: ${e.name}`),ep.Upload.LIST_IGNORE)}},children:[(0,d.jsx)("p",{className:"ant-upload-drag-icon",children:(0,d.jsx)(ed.InboxOutlined,{})}),(0,d.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此处上传"}),(0,d.jsx)("p",{className:"ant-upload-hint",children:"支持上传Excel表格数据或音频文件进行分析"})]}),i.length>0&&(0,d.jsxs)("div",{style:{marginTop:16},children:[(0,d.jsxs)(ep.Typography.Title,{level:5,style:{fontSize:14,marginBottom:8},children:["已选文件 (",i.length,")"]}),(0,d.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:8,maxHeight:200,overflowY:"auto"},children:i.map((e,t)=>(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 12px",background:"#f5f5f5",borderRadius:4},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:8,overflow:"hidden"},children:[e.name.endsWith(".xlsx")?(0,d.jsx)(ed.FileExcelOutlined,{style:{color:"#52c41a"}}):(0,d.jsx)(ed.AudioOutlined,{style:{color:"#1890ff"}}),(0,d.jsx)(ep.Typography.Text,{ellipsis:!0,style:{maxWidth:300},children:e.name}),(0,d.jsxs)(ep.Typography.Text,{type:"secondary",style:{fontSize:12},children:["(",(e.size/1024).toFixed(1)," KB)"]})]}),(0,d.jsx)(ep.Button,{type:"text",size:"small",icon:(0,d.jsx)(ed.DeleteOutlined,{}),onClick:()=>{o(e=>e.filter((e,l)=>l!==t))},danger:!0})]},`${e.name}-${t}`))})]})]})},eM=m().forwardRef((e,t)=>{let{value:l="",placeholder:n="请输入需求,例如:分析 2025 年人口结构并生成可视化报告",disabled:r=!1,sending:a=!1,rows:i=6,agentList:o=eF,agentId:s=null,attachments:u=eD,atItems:p=null,onInput:m,onSubmit:x,onUpdateAgentId:h,onUpdateAttachments:f,onUploading:g,onRemoveAtItem:v,style:j={}}=e,b=(0,c.useRef)(null),[y,w]=(0,c.useState)([]),[C,S]=(0,c.useState)(l||""),[I,k]=(0,c.useState)(0),[z,O]=(0,c.useState)(Array.isArray(u)?u:[]),[N,T]=(0,c.useState)(!1),R=(0,c.useMemo)(()=>!1,[]);(0,c.useImperativeHandle)(t,()=>({focus(){var e;null==(e=b.current)||e.focus()}})),(0,c.useEffect)(()=>S(l||""),[l]),(0,c.useEffect)(()=>{m&&m(C)},[C]),(0,c.useEffect)(()=>O(Array.isArray(u)?u:[]),[u]);let F=!!(C&&C.trim()),D=async e=>{if(T(!1),!g||!e.length)return;let t=[];for(let l of e)try{let e=await g(l);e&&t.push({id:e.id,name:l.name,size:l.size})}catch(e){console.error(e)}O([...z,...t]),f&&f([...z,...t])},A=()=>{if(!F||a)return;let e=Date.now();if(e-I<400)return;k(e);let t=(C||"").trim();if(!t)return;let l={message:t,agents:y.map(e=>({id:e.id,name:e.name})),files:z.map(e=>({id:e.id,name:e.name,extension:e.name.substring(e.name.lastIndexOf("."))}))};x&&x(l),S(""),O([])},E=(0,d.jsx)(eT,{children:(0,d.jsx)("ul",{className:"agent-list",children:o.map(e=>(0,d.jsx)("li",{children:(0,d.jsx)("a",{onClick:()=>{let t;return t=e.id||null,void(h&&h(t),w(t=>[...t,e]))},children:e.name})},String(e.id)))})});return(0,d.jsx)(eR,{style:j,children:(0,d.jsxs)("div",{className:"chat-input",children:[(0,d.jsxs)("div",{className:"input-stack",children:[z.length>0&&(0,d.jsx)("div",{className:"attachment-bar beautified_scrollbar",children:z.map(e=>(0,d.jsxs)("div",{className:"attachment-card",children:[e.name.endsWith(".xlsx")?(0,d.jsx)(eu,{type:"icon-excel"}):(0,d.jsx)(eu,{type:"icon-audio"}),(0,d.jsx)(ep.Typography.Text,{className:"name",ellipsis:{tooltip:e.name},children:e.name}),(0,d.jsx)("a",{className:"remove",onClick:()=>{var t;let l;return t=e.id,void(O(l=z.filter(e=>e.id!==t)),f&&f(l))},children:(0,d.jsx)(ed.DeleteOutlined,{})})]},e.id))}),y.length>0&&(0,d.jsx)("div",{className:"agent-info",children:y.map((e,t)=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("span",{className:"name",children:[(0,d.jsx)(eu,{type:"icon-at"}),e.name]}),(0,d.jsx)("a",{className:"remove",onClick:()=>{h&&h(null),w(e=>e.filter((e,l)=>l!==t))},children:"\xd7"})]},String(e.id)))}),!!(null==p?void 0:p.length)&&(0,d.jsx)("div",{className:"agent-info",children:p.map((e,t)=>(0,d.jsxs)("div",{children:[(0,d.jsxs)("span",{className:"name",children:[(0,d.jsx)(eu,{type:"icon-number"}),e.name||e.id]}),(0,d.jsx)("a",{className:"remove",onClick:()=>null==v?void 0:v(e,t),children:"\xd7"})]},String(e.id)))}),(0,d.jsx)(ep.Input.TextArea,{ref:b,className:"input textarea-stacked",placeholder:n,disabled:r||a,autoSize:{minRows:i,maxRows:i},value:C,onPressEnter:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),A()))},onChange:e=>S(e.target.value)})]}),(0,d.jsxs)("div",{className:"footer",children:[(0,d.jsxs)("div",{className:"left",children:[!!(null==o?void 0:o.length)&&(0,d.jsx)(ep.Dropdown,{trigger:["click"],popupRender:()=>E,placement:"topLeft",styles:{root:{boxShadow:"var(--ant-box-shadow-card)"}},children:(0,d.jsx)(ep.Tooltip,{title:"选择助理",children:(0,d.jsx)(ep.Button,{className:"agent-trigger",onClick:e=>e.preventDefault(),children:(0,d.jsx)(eu,{type:"icon-at"})})})}),g&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ep.Tooltip,{title:"上传文件",children:(0,d.jsx)(ep.Button,{className:"attach-upload",onClick:()=>T(!0),disabled:r||a,children:(0,d.jsx)(eu,{type:"icon-paper-clip"})})}),(0,d.jsx)(eB,{open:N,onCancel:()=>T(!1),onOk:D,allowedExtensions:eE,allowedMimeTypes:eA})]})]}),(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6},children:[!R&&(0,d.jsx)("div",{className:"tips",children:"按 Enter 发送,Shift+Enter 换行"}),(0,d.jsx)("a",{className:`send-btn ${!a&&(null==C?void 0:C.length)>0?"send-btn-active":""}`,onClick:A,children:(0,d.jsx)(ed.SendOutlined,{})})]})]})]})})}),eP=h().div`
364
364
  width: 100%;
365
365
  padding: 0 12px;
366
366
  border-bottom: solid 1px #e8e8e8;
@@ -417,7 +417,7 @@
417
417
  .conversation-list li small {
418
418
  white-space: nowrap;
419
419
  }
420
- `,eY=[],e_="bi-design",eq=e=>{let t,l,n,r,a,i,o,{agentList:s=eY,headExtra:u,style:p={},onEffect:x}=e,{pageId:h,schema:g,fetch:v,atItems:j,onRemoveAtItem:b,clearAtItems:y}=(0,c.useContext)(f);if(!v)return null;let[w,C]=(0,c.useState)(null),[S,I]=(0,c.useState)([]),[k,z]=(0,c.useState)([]),O=m().useRef(null),N=()=>{setTimeout(()=>{O.current&&O.current.scrollToBottom()},100)},T=()=>{C(null),z([])},R=async e=>{ep.Modal.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=v.ai)?void 0:t.removeConversation(e)),I(t=>t.filter(t=>t.id!==e)),z(t=>t.filter(t=>t.conversationId!==e)),w===e&&T()}})},F=async e=>{var t;C(e),I(t=>t.map(t=>({...t,isActived:t.id===e}))),z(await (null==(t=v.ai)?void 0:t.messageList(e))||[]),N()},D=async e=>{var t;let l={id:eO(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],atItems:JSON.stringify(j),sending:!0};z(e=>[...e,l]),N();let n=!w;y();let{id:r,answer:a,createdAt:i,conversation:o}=await (null==(t=v.ai)?void 0:t.chat(e_,h,w,{...e,page:JSON.stringify(g),pageItems:JSON.stringify(j||[])}));C((null==o?void 0:o.id)||""),I(e=>[n?o||{}:null,...e].filter(e=>null!==e)),Object.assign(l,{id:r,answer:a,createdAt:i,conversationId:(null==o?void 0:o.id)||"",sending:!1}),a.effect&&(null==x||x(a.effect)),z(e=>[...e]),N()},E=async e=>{var t;await (null==(t=v.ai)?void 0:t.removeMessage(e)),z(t=>t.filter(t=>t.id!==e))},A=(t=new Date,l=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),(n=new Date(t)).setDate(t.getDate()-1),r=[],a=[],i=[],o=[],S.forEach(e=>{let s=new Date(e.createdAt);if(l(s,t))r.push(e);else if(l(s,n))a.push(e);else s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()?i.push(e):o.push(e)}),[{title:"今天",items:r},{title:"昨天",items:a},{title:"本月内",items:i},{title:"很久以前",items:o}].filter(e=>e.items.length>0)),B=async()=>{try{var e,t;let l=await (null==(e=v.ai)?void 0:e.conversationList(e_,h));I(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){C(n.id);let e=await (null==(t=v.ai)?void 0:t.messageList(n.id));z(e||[]),N()}}catch(e){console.error(e)}};return(0,c.useEffect)(()=>{B()},[v]),(0,c.useEffect)(()=>{N()},[]),(0,d.jsxs)(e$,{style:p,children:[(0,d.jsx)(eL,{title:"智能助理",extra:(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)(ep.Tooltip,{title:"新对话",placement:"topRight",children:(0,d.jsx)("a",{onClick:T,children:(0,d.jsx)(eu,{type:"icon-chat-plus"})})}),(0,d.jsx)(ep.Dropdown,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,d.jsx)(eU,{children:A.map(e=>(0,d.jsxs)("div",{className:"group",children:[(0,d.jsx)("div",{className:"group-title",children:e.title}),(0,d.jsx)("ul",{className:"group-list",children:e.items.map(e=>(0,d.jsxs)("li",{className:e.isActived?"actived":"",children:[(0,d.jsx)("a",{onClick:()=>F(e.id),children:e.name}),(0,d.jsx)("small",{children:(0,d.jsx)("a",{onClick:()=>R(e.id),children:(0,d.jsx)(ed.DeleteOutlined,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,d.jsx)("a",{children:(0,d.jsx)(ed.HistoryOutlined,{})})}),u]}),style:{width:"initial"}}),(0,d.jsxs)("div",{className:"body",children:[(0,d.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:k.length?(0,d.jsx)(eK,{ref:O,list:k,onDeleteMessage:E}):(0,d.jsx)(eG,{})}),0===k.length&&S.length>0&&(0,d.jsx)(ep.Card,{title:"历史记录",size:"small",variant:"borderless",styles:{header:{padding:0,border:"none"},body:{padding:0}},style:{padding:"12px 12px 0 12px"},children:(0,d.jsx)("ul",{className:"conversation-list",children:S.slice(0,3).map(e=>(0,d.jsxs)("li",{children:[(0,d.jsxs)("a",{children:[(0,d.jsx)(ed.MessageOutlined,{}),e.name]}),(0,d.jsx)("small",{children:eN(e.createdAt)})]},e.id))})}),(0,d.jsx)(eM,{agentList:s,style:{padding:12},atItems:j,onUploading:null==v?void 0:v.upload,onSubmit:D,onRemoveAtItem:b})]})]})},eH=h().div`
420
+ `,eY=[],e_="bi-design",eq=e=>{let t,l,n,r,a,i,o,{agentList:s=eY,headExtra:u,style:p={},onEffect:x}=e,{pageId:h,schema:g,fetch:v,atItems:j,onRemoveAtItem:b,clearAtItems:y}=(0,c.useContext)(f);if(!v)return null;let[w,C]=(0,c.useState)(null),[S,I]=(0,c.useState)([]),[k,z]=(0,c.useState)([]),O=m().useRef(null),N=()=>{setTimeout(()=>{O.current&&O.current.scrollToBottom()},100)},T=()=>{C(null),z([])},R=async e=>{ep.Modal.confirm({title:"确认删除该对话吗?",okText:"确认",cancelText:"取消",onOk:async()=>{var t;await (null==(t=v.ai)?void 0:t.removeConversation(e)),I(t=>t.filter(t=>t.id!==e)),z(t=>t.filter(t=>t.conversationId!==e)),w===e&&T()}})},F=async e=>{var t;C(e),I(t=>t.map(t=>({...t,isActived:t.id===e}))),z(await (null==(t=v.ai)?void 0:t.messageList(e))||[]),N()},D=async e=>{var t;let l={id:eO(),question:e.message,createdAt:new Date().toISOString(),files:e.files||[],agents:e.agents||[],atItems:JSON.stringify(j),sending:!0};z(e=>[...e,l]),N();let n=!w;y();let{id:r,answer:a,createdAt:i,conversation:o}=await (null==(t=v.ai)?void 0:t.chat(e_,h,w,{...e,page:JSON.stringify(g),pageItems:JSON.stringify(j||[])}));C((null==o?void 0:o.id)||""),I(e=>[n?o||{}:null,...e].filter(e=>null!==e)),Object.assign(l,{id:r,answer:a,createdAt:i,conversationId:(null==o?void 0:o.id)||"",sending:!1}),a.effect&&(null==x||x(a.effect)),z(e=>[...e]),N()},A=async e=>{var t;await (null==(t=v.ai)?void 0:t.removeMessage(e)),z(t=>t.filter(t=>t.id!==e))},E=(t=new Date,l=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),(n=new Date(t)).setDate(t.getDate()-1),r=[],a=[],i=[],o=[],S.forEach(e=>{let s=new Date(e.createdAt);if(l(s,t))r.push(e);else if(l(s,n))a.push(e);else s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()?i.push(e):o.push(e)}),[{title:"今天",items:r},{title:"昨天",items:a},{title:"本月内",items:i},{title:"很久以前",items:o}].filter(e=>e.items.length>0)),B=async()=>{try{var e,t;let l=await (null==(e=v.ai)?void 0:e.conversationList(e_,h));I(l||[]);let n=null==l?void 0:l.find(e=>e.isActived);if(n){C(n.id);let e=await (null==(t=v.ai)?void 0:t.messageList(n.id));z(e||[]),N()}}catch(e){console.error(e)}};return(0,c.useEffect)(()=>{B()},[v]),(0,c.useEffect)(()=>{N()},[]),(0,d.jsxs)(e$,{style:p,children:[(0,d.jsx)(eL,{title:"智能助理",extra:(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)(ep.Tooltip,{title:"新对话",placement:"topRight",children:(0,d.jsx)("a",{onClick:T,children:(0,d.jsx)(eu,{type:"icon-chat-plus"})})}),(0,d.jsx)(ep.Dropdown,{trigger:["click"],styles:{root:{boxShadow:"var(--ant-box-shadow-drawer-up)",backgroundColor:"#ffffff",borderRadius:"var(--ant-border-radius)"}},popupRender:()=>(0,d.jsx)(eU,{children:E.map(e=>(0,d.jsxs)("div",{className:"group",children:[(0,d.jsx)("div",{className:"group-title",children:e.title}),(0,d.jsx)("ul",{className:"group-list",children:e.items.map(e=>(0,d.jsxs)("li",{className:e.isActived?"actived":"",children:[(0,d.jsx)("a",{onClick:()=>F(e.id),children:e.name}),(0,d.jsx)("small",{children:(0,d.jsx)("a",{onClick:()=>R(e.id),children:(0,d.jsx)(ed.DeleteOutlined,{})})})]},e.id))})]},e.title))}),placement:"topRight",children:(0,d.jsx)("a",{children:(0,d.jsx)(ed.HistoryOutlined,{})})}),u]}),style:{width:"initial"}}),(0,d.jsxs)("div",{className:"body",children:[(0,d.jsx)("div",{style:{flex:"1 1 auto",overflowY:"auto"},children:k.length?(0,d.jsx)(eK,{ref:O,list:k,onDeleteMessage:A}):(0,d.jsx)(eG,{})}),0===k.length&&S.length>0&&(0,d.jsx)(ep.Card,{title:"历史记录",size:"small",variant:"borderless",styles:{header:{padding:0,border:"none"},body:{padding:0}},style:{padding:"12px 12px 0 12px"},children:(0,d.jsx)("ul",{className:"conversation-list",children:S.slice(0,3).map(e=>(0,d.jsxs)("li",{children:[(0,d.jsxs)("a",{children:[(0,d.jsx)(ed.MessageOutlined,{}),e.name]}),(0,d.jsx)("small",{children:eN(e.createdAt)})]},e.id))})}),(0,d.jsx)(eM,{agentList:s,style:{padding:12},atItems:j,onUploading:null==v?void 0:v.upload,onSubmit:D,onRemoveAtItem:b})]})]})},eH=h().div`
421
421
  flex: 1 1 auto;
422
422
  display: flex;
423
423
  align-items: center;
@@ -802,7 +802,7 @@
802
802
  margin: 0;
803
803
  }
804
804
  }
805
- `,e7=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[],l=e=>{Array.isArray(e)&&e.forEach(e=>{t.push(e),Array.isArray(e.children)?l(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>l(e.children[t]))})};return l(e||[]),t},te=e=>{var t,l,n,r,a,i,o;let{datasourceEnable:s=!0}=e,{plugins:u,selectedItem:p,updateSelectedItem:x,schema:h,setSchema:g,datasetSelector:v,datasetAdd:j}=(0,c.useContext)(f),b=(0,c.useRef)(null),[y,w]=(0,c.useState)("1"),C=(0,c.useMemo)(()=>e7((null==h?void 0:h.items)||[]),[h]),S=(0,c.useMemo)(()=>p&&C.find(e=>e.id===p.id),[C,p]),I=S?y:"1",k=(0,c.useMemo)(()=>u.find(e=>e.key===(null==p?void 0:p.type)),[u,p]),z=null==k?void 0:k.formComponent,O=(null==p?void 0:p.props)||{},N=(null==p?void 0:p.style)||{},[T,R]=(0,c.useState)((null==h?void 0:h.info)||{}),[F,D]=(0,c.useState)((null==p?void 0:p.datasource)||{}),[E,A]=(0,c.useState)(!1),[B,M]=(0,c.useState)(!1),P=e=>{g({...h,info:e})},L={Authorization:`Bearer ${localStorage.getItem("ASKDATA_TOKEN")||""}`};return m().useEffect(()=>{w(p?"2":"1"),D((null==p?void 0:p.datasource)||{})},[p]),(0,d.jsxs)(e3,{className:"properties-panel",children:[(0,d.jsx)(eL,{title:"属性",extra:(0,d.jsxs)(ep.Radio.Group,{value:I,size:"small",buttonStyle:"outline",onChange:e=>w(e.target.value),children:[(0,d.jsx)(ep.Radio.Button,{value:"1",children:"页面"}),S&&(0,d.jsx)(ep.Radio.Button,{value:"2",children:"组件"})]})}),(0,d.jsxs)("div",{className:"body beautified_scrollbar always",children:["1"===I&&(0,d.jsxs)(ep.Form,{labelCol:{span:24},wrapperCol:{span:24},className:"ant-form-compact",children:[(0,d.jsx)(ep.Form.Item,{label:"页面名称",children:(0,d.jsx)(ep.Input,{size:"small",value:null==T?void 0:T.name,placeholder:"请输入页面名称",onChange:e=>{let t={...T,name:e.target.value};R(t),P&&P(t)}})}),(0,d.jsx)(ep.Form.Item,{label:"页面描述",children:(0,d.jsx)(ep.Input.TextArea,{size:"small",value:null==T?void 0:T.description,placeholder:"请输入页面描述",onChange:e=>{let t={...T,description:e.target.value};R(t),P&&P(t)}})}),(0,d.jsxs)(ep.Form.Item,{label:"封面",children:[(0,d.jsxs)(ep.Upload.Dragger,{name:"file",multiple:!1,accept:".png,.jpg,.jpeg",headers:L,action:"/api/datareport/upload",showUploadList:!1,beforeUpload:e=>e.type.startsWith("image/"),onChange:e=>{if("done"===e.file.status){var t;let l={url:null==(t=e.file.response)?void 0:t.data,name:e.file.name},n={...T,cover:l};R(n),P&&P(n)}},children:[(0,d.jsx)("p",{className:"ant-upload-drag-icon",children:(0,d.jsx)(ed.InboxOutlined,{})}),(0,d.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此区域进行上传"}),(0,d.jsx)("p",{className:"ant-upload-hint",children:"严禁上传公司数据或其他被禁止的文件。"})]}),(null==T||null==(t=T.cover)?void 0:t.url)&&(0,d.jsxs)("div",{style:{marginTop:10,textAlign:"left"},children:[(0,d.jsxs)("div",{style:{display:"flex",justifyContent:"space-between"},children:[(0,d.jsx)("label",{children:"封面预览"}),(0,d.jsx)("a",{onClick:()=>{let e={...T,cover:null};R(e),P&&P(e)},children:(0,d.jsx)(ed.DeleteOutlined,{})})]}),(0,d.jsx)("img",{src:T.cover.url,style:{width:"100%",maxHeight:200}})]})]})]}),"2"===I&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ep.Divider,{children:"基础属性"}),(0,d.jsxs)(ep.Form,{labelCol:{span:24},wrapperCol:{span:24},className:"ant-form-compact",children:[(0,d.jsx)(ep.Form.Item,{label:"组件标识",labelCol:{span:5},wrapperCol:{span:19},children:(null==p?void 0:p.id)||""}),(0,d.jsx)(ep.Form.Item,{label:"组件名称",children:(0,d.jsx)(ep.Input,{size:"small",value:null==p?void 0:p.name,onChange:e=>x&&x({...p,name:e.target.value})})}),(0,d.jsx)(ep.Form.Item,{label:"组件描述",children:(0,d.jsx)(ep.Input.TextArea,{size:"small",value:null==p?void 0:p.description,onChange:e=>x&&x({...p,description:e.target.value})})})]}),(null==p?void 0:p.datasource)&&(0,d.jsx)(ep.Divider,{children:"数据源"}),(null==p?void 0:p.datasource)&&(0,d.jsxs)(ep.Form,{className:"ant-form-compact",children:[(0,d.jsx)(ep.Form.Item,{label:(0,d.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:"数据来源"}),labelCol:{span:5},wrapperCol:{span:19},colon:!1,children:(0,d.jsxs)(ep.Radio.Group,{size:"small",value:null==F?void 0:F.source,onChange:e=>{let t={...F||{},source:e.target.value};D(t),x&&x({...p,datasource:t})},children:[!!v&&(0,d.jsx)(ep.Radio.Button,{value:"dataset",children:"数据集"}),s&&(0,d.jsx)(ep.Radio.Button,{value:"define",children:"数据源"}),(0,d.jsx)(ep.Radio.Button,{value:"custom",children:"自定义"})]})}),(null==F?void 0:F.source)==="dataset"&&v&&(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(ep.Form.Item,{label:"数据集",labelCol:{span:5},wrapperCol:{span:19},children:(0,d.jsxs)(ep.Space.Compact,{children:[(0,d.jsx)(ep.Input,{size:"small",readOnly:!0,value:(null==F||null==(l=F.dataset)?void 0:l.name)||"",style:{width:90}}),!!(null==F||null==(r=F.dataset)||null==(n=r.id)?void 0:n.length)&&(null==F||null==(a=F.dataset)?void 0:a.output)&&(0,d.jsx)(ep.Popover,{title:"输出类型",placement:"left",content:(0,d.jsx)("div",{style:{padding:"0 12px",maxWidth:500,maxHeight:500,overflow:"auto"},children:(0,d.jsx)(tt,{output:F.dataset.output})}),children:(0,d.jsx)(ep.Button,{size:"small",style:{color:"var(--ant-color-text-tertiary)"},title:"查看输出类型",children:(0,d.jsx)(eu,{type:"icon-json"})})}),!!(null==F||null==(o=F.dataset)||null==(i=o.id)?void 0:i.length)&&(0,d.jsx)(ep.Button,{size:"small",icon:(0,d.jsx)(ed.CloseOutlined,{}),onClick:()=>{let e={...F||{},dataset:{id:"",name:"",output:{fields:[]}}};D(e),x&&x({...p,datasource:e})},title:"删除数据集",style:{color:"var(--ant-color-text-tertiary)"}}),j&&(0,d.jsx)(ep.Button,{size:"small",icon:(0,d.jsx)(ed.PlusOutlined,{}),title:"新建数据集",onClick:()=>M(!0)}),(0,d.jsx)(ep.Button,{size:"small",icon:(0,d.jsx)(ed.SelectOutlined,{}),title:"选择数据集",onClick:()=>A(!0)})]})})}),(null==F?void 0:F.source)==="define"&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ep.Form.Item,{label:"数据源",layout:"vertical",children:(0,d.jsx)(ep.Select,{size:"small",value:null==F?void 0:F.datasourceId,onChange:e=>{let t={...F||{},datasourceId:e};D(t),x&&x({...p,datasource:t})},children:((null==h?void 0:h.datasources)||[]).map(e=>(0,d.jsx)(ep.Select.Option,{value:e.id,children:e.name},e.id))})}),(0,d.jsx)(ep.Form.Item,{label:"数据处理脚本",labelCol:{span:24},wrapperCol:{span:24},children:(0,d.jsx)(ep.Select,{size:"small",value:null==F?void 0:F.scriptId,onChange:e=>{let t={...F||{},scriptId:e};D(t),x&&x({...p,datasource:t})},children:((null==h?void 0:h.scripts)||[]).map(e=>(0,d.jsx)(ep.Select.Option,{value:e.id,children:e.name},e.id))})})]}),(null==F?void 0:F.source)==="custom"&&(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(ep.Form.Item,{label:(0,d.jsxs)(d.Fragment,{children:["自定义",(0,d.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=b.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,d.jsx)(eu,{type:"icon-formate"})," 格式化"]})]}),labelCol:{span:24},wrapperCol:{span:24},className:"ant-form-item-label-space",children:(0,d.jsx)("div",{style:{border:"1px solid var(--ant-color-border)",borderRadius:"var(--ant-border-radius)",padding:1},children:(0,d.jsx)(ef(),{height:"200px",onMount:e=>{b.current={editor:e}},defaultLanguage:"json",value:(null==F?void 0:F.custom)||"",onChange:e=>{let t={...F||{},custom:e||""};D(t),x&&x({...p,datasource:t})},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}})})})})]}),z&&(0,d.jsx)(ep.Divider,{children:"特有属性"}),z&&(0,d.jsx)(z,{model:O,customStyle:N,onChange:e=>{p&&x&&x({...p,props:e})}})]})]}),!!v&&p&&(0,d.jsx)(ep.Drawer,{title:"选择数据集",size:800,open:E,onClose:()=>{A(!1)},children:v(e=>{F.dataset=e,x({...p,datasource:{...p.datasource,dataset:e}}),A(!1)})}),!!j&&p&&B&&j(p,e=>{F.dataset=e,x({...p,datasource:{...p.datasource,dataset:e}}),M(!1)},()=>{M(!1)})]})},tt=e=>{let{output:t}=e,l=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e&&0!==e.length?(0,d.jsxs)(d.Fragment,{children:["{",e.map((n,r)=>(0,d.jsxs)("div",{style:{paddingLeft:"1em"},children:[(0,d.jsx)("span",{style:{color:"var(--ant-color-primary)"},children:n.key}),":"," ","ARRAY"===n.type?(0,d.jsxs)(d.Fragment,{children:["Array","<",n.schema?l(n.schema.fields,t+1):(0,d.jsx)("span",{children:"any"}),">"]}):"OBJECT"===n.type?n.schema?l(n.schema.fields,t+1):(0,d.jsx)("span",{children:"{}"}):(0,d.jsx)("span",{style:{color:"var(--ant-color-success)"},children:(n.type||"string").toLowerCase()}),r<e.length-1?",":""]},n.key||r)),"}"]}):(0,d.jsx)("span",{children:"{}"})};return(0,d.jsx)("pre",{style:{margin:"8px 0",padding:"8px",background:"var(--ant-color-fill-alter)",borderRadius:"var(--ant-border-radius-sm)",fontSize:"12px",fontFamily:"monospace",overflowX:"auto",border:"1px solid var(--ant-color-border-secondary)"},children:l(t.fields)})},tl=h().div`
805
+ `,e7=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=[],l=e=>{Array.isArray(e)&&e.forEach(e=>{t.push(e),Array.isArray(e.children)?l(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>l(e.children[t]))})};return l(e||[]),t},te=e=>{var t,l,n,r,a,i,o;let{datasourceEnable:s=!0}=e,{plugins:u,selectedItem:p,updateSelectedItem:x,schema:h,setSchema:g,datasetSelector:v,datasetAdd:j}=(0,c.useContext)(f),b=(0,c.useRef)(null),[y,w]=(0,c.useState)("1"),C=(0,c.useMemo)(()=>e7((null==h?void 0:h.items)||[]),[h]),S=(0,c.useMemo)(()=>p&&C.find(e=>e.id===p.id),[C,p]),I=S?y:"1",k=(0,c.useMemo)(()=>u.find(e=>e.key===(null==p?void 0:p.type)),[u,p]),z=null==k?void 0:k.formComponent,O=(null==p?void 0:p.props)||{},N=(null==p?void 0:p.style)||{},[T,R]=(0,c.useState)((null==h?void 0:h.info)||{}),[F,D]=(0,c.useState)((null==p?void 0:p.datasource)||{}),[A,E]=(0,c.useState)(!1),[B,M]=(0,c.useState)(!1),P=e=>{g({...h,info:e})},L={Authorization:`Bearer ${localStorage.getItem("ASKDATA_TOKEN")||""}`};return m().useEffect(()=>{w(p?"2":"1"),D((null==p?void 0:p.datasource)||{})},[p]),(0,d.jsxs)(e3,{className:"properties-panel",children:[(0,d.jsx)(eL,{title:"属性",extra:(0,d.jsxs)(ep.Radio.Group,{value:I,size:"small",buttonStyle:"outline",onChange:e=>w(e.target.value),children:[(0,d.jsx)(ep.Radio.Button,{value:"1",children:"页面"}),S&&(0,d.jsx)(ep.Radio.Button,{value:"2",children:"组件"})]})}),(0,d.jsxs)("div",{className:"body beautified_scrollbar always",children:["1"===I&&(0,d.jsxs)(ep.Form,{labelCol:{span:24},wrapperCol:{span:24},className:"ant-form-compact",children:[(0,d.jsx)(ep.Form.Item,{label:"页面名称",children:(0,d.jsx)(ep.Input,{size:"small",value:null==T?void 0:T.name,placeholder:"请输入页面名称",onChange:e=>{let t={...T,name:e.target.value};R(t),P&&P(t)}})}),(0,d.jsx)(ep.Form.Item,{label:"页面描述",children:(0,d.jsx)(ep.Input.TextArea,{size:"small",value:null==T?void 0:T.description,placeholder:"请输入页面描述",onChange:e=>{let t={...T,description:e.target.value};R(t),P&&P(t)}})}),(0,d.jsxs)(ep.Form.Item,{label:"封面",children:[(0,d.jsxs)(ep.Upload.Dragger,{name:"file",multiple:!1,accept:".png,.jpg,.jpeg",headers:L,action:"/api/datareport/upload",showUploadList:!1,beforeUpload:e=>e.type.startsWith("image/"),onChange:e=>{if("done"===e.file.status){var t;let l={url:null==(t=e.file.response)?void 0:t.data,name:e.file.name},n={...T,cover:l};R(n),P&&P(n)}},children:[(0,d.jsx)("p",{className:"ant-upload-drag-icon",children:(0,d.jsx)(ed.InboxOutlined,{})}),(0,d.jsx)("p",{className:"ant-upload-text",children:"点击或将文件拖拽到此区域进行上传"}),(0,d.jsx)("p",{className:"ant-upload-hint",children:"严禁上传公司数据或其他被禁止的文件。"})]}),(null==T||null==(t=T.cover)?void 0:t.url)&&(0,d.jsxs)("div",{style:{marginTop:10,textAlign:"left"},children:[(0,d.jsxs)("div",{style:{display:"flex",justifyContent:"space-between"},children:[(0,d.jsx)("label",{children:"封面预览"}),(0,d.jsx)("a",{onClick:()=>{let e={...T,cover:null};R(e),P&&P(e)},children:(0,d.jsx)(ed.DeleteOutlined,{})})]}),(0,d.jsx)("img",{src:T.cover.url,style:{width:"100%",maxHeight:200}})]})]})]}),"2"===I&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ep.Divider,{children:"基础属性"}),(0,d.jsxs)(ep.Form,{labelCol:{span:24},wrapperCol:{span:24},className:"ant-form-compact",children:[(0,d.jsx)(ep.Form.Item,{label:"组件标识",labelCol:{span:5},wrapperCol:{span:19},children:(null==p?void 0:p.id)||""}),(0,d.jsx)(ep.Form.Item,{label:"组件名称",children:(0,d.jsx)(ep.Input,{size:"small",value:null==p?void 0:p.name,onChange:e=>x&&x({...p,name:e.target.value})})}),(0,d.jsx)(ep.Form.Item,{label:"组件描述",children:(0,d.jsx)(ep.Input.TextArea,{size:"small",value:null==p?void 0:p.description,onChange:e=>x&&x({...p,description:e.target.value})})})]}),(null==p?void 0:p.datasource)&&(0,d.jsx)(ep.Divider,{children:"数据源"}),(null==p?void 0:p.datasource)&&(0,d.jsxs)(ep.Form,{className:"ant-form-compact",children:[(0,d.jsx)(ep.Form.Item,{label:(0,d.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:"数据来源"}),labelCol:{span:5},wrapperCol:{span:19},colon:!1,children:(0,d.jsxs)(ep.Radio.Group,{size:"small",value:null==F?void 0:F.source,onChange:e=>{let t={...F||{},source:e.target.value};D(t),x&&x({...p,datasource:t})},children:[!!v&&(0,d.jsx)(ep.Radio.Button,{value:"dataset",children:"数据集"}),s&&(0,d.jsx)(ep.Radio.Button,{value:"define",children:"数据源"}),(0,d.jsx)(ep.Radio.Button,{value:"custom",children:"自定义"})]})}),(null==F?void 0:F.source)==="dataset"&&v&&(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(ep.Form.Item,{label:"数据集",labelCol:{span:5},wrapperCol:{span:19},children:(0,d.jsxs)(ep.Space.Compact,{children:[(0,d.jsx)(ep.Input,{size:"small",readOnly:!0,value:(null==F||null==(l=F.dataset)?void 0:l.name)||"",style:{width:90}}),!!(null==F||null==(r=F.dataset)||null==(n=r.id)?void 0:n.length)&&(null==F||null==(a=F.dataset)?void 0:a.output)&&(0,d.jsx)(ep.Popover,{title:"输出类型",placement:"left",content:(0,d.jsx)("div",{style:{padding:"0 12px",maxWidth:500,maxHeight:500,overflow:"auto"},children:(0,d.jsx)(tt,{output:F.dataset.output})}),children:(0,d.jsx)(ep.Button,{size:"small",style:{color:"var(--ant-color-text-tertiary)"},title:"查看输出类型",children:(0,d.jsx)(eu,{type:"icon-json"})})}),!!(null==F||null==(o=F.dataset)||null==(i=o.id)?void 0:i.length)&&(0,d.jsx)(ep.Button,{size:"small",icon:(0,d.jsx)(ed.CloseOutlined,{}),onClick:()=>{let e={...F||{},dataset:{id:"",name:"",output:{fields:[]}}};D(e),x&&x({...p,datasource:e})},title:"删除数据集",style:{color:"var(--ant-color-text-tertiary)"}}),j&&(0,d.jsx)(ep.Button,{size:"small",icon:(0,d.jsx)(ed.PlusOutlined,{}),title:"新建数据集",onClick:()=>M(!0)}),(0,d.jsx)(ep.Button,{size:"small",icon:(0,d.jsx)(ed.SelectOutlined,{}),title:"选择数据集",onClick:()=>E(!0)})]})})}),(null==F?void 0:F.source)==="define"&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(ep.Form.Item,{label:"数据源",layout:"vertical",children:(0,d.jsx)(ep.Select,{size:"small",value:null==F?void 0:F.datasourceId,onChange:e=>{let t={...F||{},datasourceId:e};D(t),x&&x({...p,datasource:t})},children:((null==h?void 0:h.datasources)||[]).map(e=>(0,d.jsx)(ep.Select.Option,{value:e.id,children:e.name},e.id))})}),(0,d.jsx)(ep.Form.Item,{label:"数据处理脚本",labelCol:{span:24},wrapperCol:{span:24},children:(0,d.jsx)(ep.Select,{size:"small",value:null==F?void 0:F.scriptId,onChange:e=>{let t={...F||{},scriptId:e};D(t),x&&x({...p,datasource:t})},children:((null==h?void 0:h.scripts)||[]).map(e=>(0,d.jsx)(ep.Select.Option,{value:e.id,children:e.name},e.id))})})]}),(null==F?void 0:F.source)==="custom"&&(0,d.jsx)(d.Fragment,{children:(0,d.jsx)(ep.Form.Item,{label:(0,d.jsxs)(d.Fragment,{children:["自定义",(0,d.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=b.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,d.jsx)(eu,{type:"icon-formate"})," 格式化"]})]}),labelCol:{span:24},wrapperCol:{span:24},className:"ant-form-item-label-space",children:(0,d.jsx)("div",{style:{border:"1px solid var(--ant-color-border)",borderRadius:"var(--ant-border-radius)",padding:1},children:(0,d.jsx)(ef(),{height:"200px",onMount:e=>{b.current={editor:e}},defaultLanguage:"json",value:(null==F?void 0:F.custom)||"",onChange:e=>{let t={...F||{},custom:e||""};D(t),x&&x({...p,datasource:t})},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}})})})})]}),z&&(0,d.jsx)(ep.Divider,{children:"特有属性"}),z&&(0,d.jsx)(z,{model:O,customStyle:N,onChange:e=>{p&&x&&x({...p,props:e})}})]})]}),!!v&&p&&(0,d.jsx)(ep.Drawer,{title:"选择数据集",size:800,open:A,onClose:()=>{E(!1)},children:v(e=>{F.dataset=e,x({...p,datasource:{...p.datasource,dataset:e}}),E(!1)})}),!!j&&p&&B&&j(p,e=>{F.dataset=e,x({...p,datasource:{...p.datasource,dataset:e}}),M(!1)},()=>{M(!1)})]})},tt=e=>{let{output:t}=e,l=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return e&&0!==e.length?(0,d.jsxs)(d.Fragment,{children:["{",e.map((n,r)=>(0,d.jsxs)("div",{style:{paddingLeft:"1em"},children:[(0,d.jsx)("span",{style:{color:"var(--ant-color-primary)"},children:n.key}),":"," ","ARRAY"===n.type?(0,d.jsxs)(d.Fragment,{children:["Array","<",n.schema?l(n.schema.fields,t+1):(0,d.jsx)("span",{children:"any"}),">"]}):"OBJECT"===n.type?n.schema?l(n.schema.fields,t+1):(0,d.jsx)("span",{children:"{}"}):(0,d.jsx)("span",{style:{color:"var(--ant-color-success)"},children:(n.type||"string").toLowerCase()}),r<e.length-1?",":""]},n.key||r)),"}"]}):(0,d.jsx)("span",{children:"{}"})};return(0,d.jsx)("pre",{style:{margin:"8px 0",padding:"8px",background:"var(--ant-color-fill-alter)",borderRadius:"var(--ant-border-radius-sm)",fontSize:"12px",fontFamily:"monospace",overflowX:"auto",border:"1px solid var(--ant-color-border-secondary)"},children:l(t.fields)})},tl=h().div`
806
806
  display: flex;
807
807
  flex-direction: column;
808
808
  height: 100%;
@@ -984,7 +984,7 @@
984
984
  background: transparent;
985
985
  }
986
986
  }
987
- `,td=e=>{let{open:t,onCancel:l,onOk:n}=e,[r,a]=(0,c.useState)(JSON.stringify({info:{},datasources:[],scripts:[],variables:[],items:[]}));return(0,d.jsx)(ep.Modal,{title:"导入页面",open:t,width:800,onCancel:l,onOk:()=>null==n?void 0:n(JSON.parse(r)),okText:"导入",cancelText:"取消",styles:{body:{height:"calc(100vh - 250px)",overflow:"auto"}},children:(0,d.jsx)("div",{className:"body",style:{flex:"1 1 auto",display:"flex",height:"100%"},children:(0,d.jsx)(eh.Editor,{height:"100%",defaultLanguage:"json",value:r,options:{minimap:{enabled:!1}},onChange:e=>a(e||"")})})})},tc=m().forwardRef((e,t)=>{var l;let n,{pageId:r,agentList:a=[],plugins:i=[],headerExtra:o,datasourceEnable:s=!0,scriptEnable:u=!0,datasetPanel:p,datasetSelector:m,datasetAdd:x,fetch:h,onSave:f,loading:v=!1}=e,j=(0,c.useRef)(null),b=(0,c.useRef)(null),[y,w]=(0,c.useState)(1),[C,S]=(0,c.useState)([]),[I,k]=(0,c.useState)([]),[z,O]=(0,c.useState)(!1),[N,T]=(0,c.useState)("desktop"),[R,F]=(0,c.useState)("component"),[D,E]=(0,c.useState)((null==h?void 0:h.ai)?"ai":"props"),[A,B]=(0,c.useState)(!0),[M,P]=(0,c.useState)(!0),[L,$]=(0,c.useState)(null),[Y,_]=(0,c.useState)({info:{},datasources:[],scripts:[],variables:[],items:[]}),[q,H]=(0,c.useState)(!0),[G,U]=(0,c.useState)(!1),[J,K]=(0,c.useState)(!1),W=(0,c.useMemo)(()=>{let e=A?"250px":"",t=M?"400px":"";return{gridTemplateColumns:`${e} 1fr ${t}`}},[A,M]),X=(0,c.useMemo)(()=>({display:A?"flex":"none"}),[A]),V=(0,c.useMemo)(()=>({display:M?"flex":"none"}),[M]);l=[Y],(n=(0,c.useRef)()).current===JSON.stringify(l)&&n.current||(n.current=JSON.stringify(l),(()=>{z||(S(e=>e.length?[...e,JSON.parse(JSON.stringify(Y))].slice(-50):[JSON.parse(JSON.stringify(Y))]),k([]))})()),(0,c.useImperativeHandle)(t,()=>({handleOpen(e){O(!0),Q(e.items),_(e),S([JSON.parse(JSON.stringify(e))]),k([]),setTimeout(()=>O(!1),0)}}));let Q=(e,t)=>{e&&e.forEach(e=>{e.id||(e.id=t||eO()),Array.isArray(e.children)?Q(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>{Array.isArray(e.children[t])&&Q(e.children[t],eO())})})},Z=e=>{var t,l,n;if((null==(t=e.datasets)?void 0:t.length)&&(null==b||null==(l=b.current)?void 0:l.reload)&&b.current.reload(),e.schema){let t=JSON.parse(JSON.stringify(e.schema));Q(t.items),_(t)}else if(null==(n=e.pageItems)?void 0:n.length){let t=new Map(e.pageItems.map(e=>[e.targetId,e])),l=JSON.parse(JSON.stringify(Y)),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e.forEach((l,r)=>{if(t.has(l.id)){let{position:n,insertSlot:d,pageItem:c}=t.get(l.id);switch(n){case"before":e.splice(r,0,c);break;case"after":e.splice(r+1,0,c);break;case"replace":Object.keys(l).forEach(e=>{"id"!==e&&delete l[e]}),Object.assign(l,c);break;case"insert":var a,o,s;let u=i.find(e=>e.key===l.type);Array.isArray(null==u||null==(a=u.defaultOptions)?void 0:a.children)?l.children=[...l.children||[],c]:"object"==typeof(null==u||null==(o=u.defaultOptions)?void 0:o.children)&&d&&(l.children={...l.children||{},[d]:[...(null==(s=l.children)?void 0:s[d])||[],c]})}}Array.isArray(l.children)?n(l.children):"object"==typeof l.children&&l.children&&Object.keys(l.children).forEach(e=>{Array.isArray(l.children[e])&&n(l.children[e])})})};n(l.items),_(l)}},ee=(0,c.useMemo)(()=>"cascade"!==D||(null==L?void 0:L.cascadeIds)?D:"props",[L,D]);return(0,d.jsxs)(g,{pageId:r,designable:q,plugins:i,schema:Y,selectedItem:L,setSchema:_,setSelectedItem:$,datasetSelector:m,datasetAdd:x,fetch:h,children:[(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 24px",borderBottom:"solid 1px #e8e8e8"},children:[(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)("span",{style:{fontSize:16,fontWeight:500},children:"创建数据报表"}),(0,d.jsx)(ep.Divider,{orientation:"vertical"}),(0,d.jsx)(ep.Tooltip,{title:"保存",children:(0,d.jsx)(ep.Button,{type:"link",className:"toolbar",onClick:()=>{null==f||f(Y)},loading:v,children:(0,d.jsx)(ed.SaveOutlined,{})})}),(0,d.jsx)(ep.Divider,{orientation:"vertical"}),(0,d.jsx)(ep.Tooltip,{title:"撤销",children:(0,d.jsx)("a",{className:`toolbar ${C.length>1?"active":""}`,onClick:()=>{S(e=>{if(e.length<=1)return e;O(!0);let t=e[e.length-2];return k(e=>[...e,JSON.parse(JSON.stringify(Y))]),_(t),$(null),setTimeout(()=>O(!1),0),e.slice(0,-1)})},children:(0,d.jsx)(ed.UndoOutlined,{})})}),(0,d.jsx)(ep.Tooltip,{title:"重做",children:(0,d.jsx)("a",{className:`toolbar ${I.length>0?"active":""}`,onClick:()=>{k(e=>e.length?(O(!0),S(e=>[...e,JSON.parse(JSON.stringify(Y))]),_(e[e.length-1]),$(null),setTimeout(()=>O(!1),0),e.slice(0,-1)):e)},children:(0,d.jsx)(ed.RedoOutlined,{})})}),(0,d.jsx)(ep.Divider,{orientation:"vertical"}),(0,d.jsx)(ep.Tooltip,{title:"导入JSON",children:(0,d.jsx)("a",{className:`toolbar ${I.length>0?"active":""}`,onClick:()=>{U(!0)},children:(0,d.jsx)(ed.ImportOutlined,{})})})]}),(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)(ep.Tooltip,{title:"缩小",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>w(parseFloat(Math.max(y-.1,.5).toFixed(1))),children:(0,d.jsx)(ed.ZoomOutOutlined,{})})}),(0,d.jsxs)("div",{style:{fontSize:12,color:"#999",userSelect:"none"},children:[(100*y).toFixed(0),"%"]}),(0,d.jsx)(ep.Tooltip,{title:"放大",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>w(parseFloat(Math.min(y+.1,2).toFixed(1))),children:(0,d.jsx)(ed.ZoomInOutlined,{})})}),(0,d.jsx)(ep.Tooltip,{title:"重置缩放",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>w(1),children:(0,d.jsx)(eu,{type:"icon-zoom-reset"})})}),(0,d.jsx)(ep.Divider,{orientation:"vertical"}),(0,d.jsx)(ep.Tooltip,{title:"切换左侧栏",children:(0,d.jsx)("a",{className:`toolbar ${A?"active":""}`,onClick:()=>{B(e=>!e),setTimeout(()=>{var e,t;return null==(t=j.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,d.jsx)(eu,{type:"icon-sider-l"})})}),(0,d.jsx)(ep.Tooltip,{title:"切换右侧栏",children:(0,d.jsx)("a",{className:`toolbar ${M?"active":""}`,onClick:()=>{P(e=>!e),setTimeout(()=>{var e,t;return null==(t=j.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,d.jsx)(eu,{type:"icon-sider-r"})})}),o]})]}),(0,d.jsxs)(ts,{style:W,children:[(0,d.jsxs)("div",{className:"left",style:X,children:[(0,d.jsx)("div",{style:{padding:"22px 1px 22px 0",borderRight:"solid 1px #e8e8e8"},children:(0,d.jsxs)(ep.Radio.Group,{value:R,onChange:e=>F(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"left-pane-tabs",children:[(0,d.jsx)(ep.Radio.Button,{value:"component",children:(0,d.jsx)(ep.Tooltip,{title:"组件",placement:"right",children:(0,d.jsx)(eu,{type:"icon-puzzle"})})}),(0,d.jsx)(ep.Radio.Button,{value:"layer",children:(0,d.jsx)(ep.Tooltip,{title:"图层",placement:"right",children:(0,d.jsx)(eu,{type:"icon-outline"})})}),!!p&&(0,d.jsx)(ep.Radio.Button,{value:"dataset",children:(0,d.jsx)(ep.Tooltip,{title:"数据集",placement:"right",children:(0,d.jsx)(eu,{type:"icon-dataset"})})}),s&&(0,d.jsx)(ep.Radio.Button,{value:"datasource",title:"数据源",children:(0,d.jsx)(ep.Tooltip,{title:"数据源",placement:"right",children:(0,d.jsx)(eu,{type:"icon-datasource"})})}),u&&(0,d.jsx)(ep.Radio.Button,{value:"script",children:(0,d.jsx)(ep.Tooltip,{title:"脚本",placement:"right",children:(0,d.jsx)(eu,{type:"icon-js"})})}),(0,d.jsx)(ep.Radio.Button,{value:"env",children:(0,d.jsx)(ep.Tooltip,{title:"环境变量",placement:"right",children:(0,d.jsx)(eu,{type:"icon-variable"})})}),(0,d.jsx)(ep.Radio.Button,{value:"code",children:(0,d.jsx)(ep.Tooltip,{title:"源码",placement:"right",children:(0,d.jsx)(eu,{type:"icon-json"})})})]})}),(0,d.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:["component"===R&&(0,d.jsx)(e2,{}),"layer"===R&&(0,d.jsx)(e9,{}),s&&"datasource"===R&&(0,d.jsx)(e8,{}),u&&"script"===R&&(0,d.jsx)(tn,{}),"env"===R&&(0,d.jsx)(ta,{}),"code"===R&&(0,d.jsx)(eZ,{}),!!p&&"dataset"===R&&(0,d.jsx)(to,{ref:b,renderNode:p})]})]}),(0,d.jsxs)("div",{className:"center",style:{flex:"1 1 auto"},children:[(0,d.jsx)(eL,{title:"页面",extra:(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)(ep.Button,{size:"small",type:q?"default":"primary",icon:q?(0,d.jsx)(ed.EyeInvisibleOutlined,{}):(0,d.jsx)(ed.EyeOutlined,{}),onClick:()=>H(!q)}),(0,d.jsxs)(ep.Radio.Group,{value:N,onChange:e=>T(e.target.value),size:"small",buttonStyle:"outline",children:[(0,d.jsx)(ep.Radio.Button,{value:"desktop",title:"桌面",children:(0,d.jsx)(ed.DesktopOutlined,{})}),(0,d.jsx)(ep.Radio.Button,{value:"mobile",title:"移动设备",children:(0,d.jsx)(ed.MobileOutlined,{})}),(0,d.jsx)(ep.Radio.Button,{value:"tablet",title:"平板设备",children:(0,d.jsx)(ed.TabletOutlined,{})})]})]})}),(0,d.jsx)("div",{className:["body beautified_scrollbar always",N].join(" "),children:(0,d.jsx)("div",{style:{transform:`scale(${y})`,transformOrigin:"top center"},children:(0,d.jsx)(eI,{ref:j,device:N})})})]}),(0,d.jsxs)("div",{className:"right",style:V,children:[(0,d.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:[(0,d.jsx)(eq,{agentList:a,onEffect:Z,style:{display:"ai"===ee&&(null==h?void 0:h.ai)?void 0:"none"}}),"props"===ee&&(0,d.jsx)(te,{datasourceEnable:s}),"cascade"===ee&&(null==L?void 0:L.cascadeIds)&&(0,d.jsx)(eX,{})]}),(0,d.jsx)("div",{style:{padding:"22px 0",borderLeft:"solid 1px #e8e8e8",display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"center"},children:(0,d.jsxs)(ep.Radio.Group,{value:ee,onChange:e=>E(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"right-pane-tabs",children:[(null==h?void 0:h.ai)&&(0,d.jsx)(ep.Radio.Button,{value:"ai",children:(0,d.jsx)(ep.Tooltip,{title:"智能助理",placement:"right",children:(0,d.jsx)(eu,{type:"icon-assistant"})})}),(0,d.jsx)(ep.Radio.Button,{value:"props",children:(0,d.jsx)(ep.Tooltip,{title:"属性",placement:"right",children:(0,d.jsx)(eu,{type:"icon-info"})})}),(null==L?void 0:L.cascadeIds)&&(0,d.jsx)(ep.Radio.Button,{value:"cascade",children:(0,d.jsx)(ep.Tooltip,{title:"联动",placement:"right",children:(0,d.jsx)(eu,{type:"icon-cascade"})})})]})})]})]})]}),(0,d.jsx)(td,{open:G,onOk:e=>{U(!1),_(e)},onCancel:()=>U(!1)}),(0,d.jsx)(ep.Drawer,{open:J,size:400,mask:!1,title:null,closable:!1,styles:{body:{padding:0}},onClose:()=>K(!1),children:(0,d.jsx)(eq,{agentList:a,headExtra:(0,d.jsx)(ep.Button,{type:"link",icon:(0,d.jsx)(ed.CloseOutlined,{}),onClick:()=>K(!1)}),onEffect:Z})})]})});var tu=((i={}).STRING="STRING",i.NUMBER="NUMBER",i.BOOLEAN="BOOLEAN",i.OBJECT="OBJECT",i.ARRAY="ARRAY",i);let tp=h()(ed.InfoCircleOutlined)`
987
+ `,td=e=>{let{open:t,onCancel:l,onOk:n}=e,[r,a]=(0,c.useState)(JSON.stringify({info:{},datasources:[],scripts:[],variables:[],items:[]}));return(0,d.jsx)(ep.Modal,{title:"导入页面",open:t,width:800,onCancel:l,onOk:()=>null==n?void 0:n(JSON.parse(r)),okText:"导入",cancelText:"取消",styles:{body:{height:"calc(100vh - 250px)",overflow:"auto"}},children:(0,d.jsx)("div",{className:"body",style:{flex:"1 1 auto",display:"flex",height:"100%"},children:(0,d.jsx)(eh.Editor,{height:"100%",defaultLanguage:"json",value:r,options:{minimap:{enabled:!1}},onChange:e=>a(e||"")})})})},tc=m().forwardRef((e,t)=>{var l;let n,{pageId:r,agentList:a=[],plugins:i=[],headerExtra:o,datasourceEnable:s=!0,scriptEnable:u=!0,datasetPanel:p,datasetSelector:m,datasetAdd:x,fetch:h,onSave:f,loading:v=!1}=e,j=(0,c.useRef)(null),b=(0,c.useRef)(null),[y,w]=(0,c.useState)(1),[C,S]=(0,c.useState)([]),[I,k]=(0,c.useState)([]),[z,O]=(0,c.useState)(!1),[N,T]=(0,c.useState)("desktop"),[R,F]=(0,c.useState)("component"),[D,A]=(0,c.useState)((null==h?void 0:h.ai)?"ai":"props"),[E,B]=(0,c.useState)(!0),[M,P]=(0,c.useState)(!0),[L,$]=(0,c.useState)(null),[Y,_]=(0,c.useState)({info:{},datasources:[],scripts:[],variables:[],items:[]}),[q,H]=(0,c.useState)(!0),[G,U]=(0,c.useState)(!1),[J,K]=(0,c.useState)(!1),W=(0,c.useMemo)(()=>{let e=E?"250px":"",t=M?"400px":"";return{gridTemplateColumns:`${e} 1fr ${t}`}},[E,M]),X=(0,c.useMemo)(()=>({display:E?"flex":"none"}),[E]),V=(0,c.useMemo)(()=>({display:M?"flex":"none"}),[M]);l=[Y],(n=(0,c.useRef)()).current===JSON.stringify(l)&&n.current||(n.current=JSON.stringify(l),(()=>{z||(S(e=>e.length?[...e,JSON.parse(JSON.stringify(Y))].slice(-50):[JSON.parse(JSON.stringify(Y))]),k([]))})()),(0,c.useImperativeHandle)(t,()=>({handleOpen(e){O(!0),Q(e.items),_(e),S([JSON.parse(JSON.stringify(e))]),k([]),setTimeout(()=>O(!1),0)}}));let Q=(e,t)=>{e&&e.forEach(e=>{e.id||(e.id=t||eO()),Array.isArray(e.children)?Q(e.children):"object"==typeof e.children&&e.children&&Object.keys(e.children).forEach(t=>{Array.isArray(e.children[t])&&Q(e.children[t],eO())})})},Z=e=>{var t,l,n;if((null==(t=e.datasets)?void 0:t.length)&&(null==b||null==(l=b.current)?void 0:l.reload)&&b.current.reload(),e.schema){let t=JSON.parse(JSON.stringify(e.schema));Q(t.items),_(t)}else if(null==(n=e.pageItems)?void 0:n.length){let t=new Map(e.pageItems.map(e=>[e.targetId,e])),l=JSON.parse(JSON.stringify(Y)),n=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];e.forEach((l,r)=>{if(t.has(l.id)){let{position:n,insertSlot:d,pageItem:c}=t.get(l.id);switch(n){case"before":e.splice(r,0,c);break;case"after":e.splice(r+1,0,c);break;case"replace":Object.keys(l).forEach(e=>{"id"!==e&&delete l[e]}),Object.assign(l,c);break;case"insert":var a,o,s;let u=i.find(e=>e.key===l.type);Array.isArray(null==u||null==(a=u.defaultOptions)?void 0:a.children)?l.children=[...l.children||[],c]:"object"==typeof(null==u||null==(o=u.defaultOptions)?void 0:o.children)&&d&&(l.children={...l.children||{},[d]:[...(null==(s=l.children)?void 0:s[d])||[],c]})}}Array.isArray(l.children)?n(l.children):"object"==typeof l.children&&l.children&&Object.keys(l.children).forEach(e=>{Array.isArray(l.children[e])&&n(l.children[e])})})};n(l.items),_(l)}},ee=(0,c.useMemo)(()=>"cascade"!==D||(null==L?void 0:L.cascadeIds)?D:"props",[L,D]);return(0,d.jsxs)(g,{pageId:r,designable:q,plugins:i,schema:Y,selectedItem:L,setSchema:_,setSelectedItem:$,datasetSelector:m,datasetAdd:x,fetch:h,children:[(0,d.jsxs)("div",{style:{display:"flex",flexDirection:"column",height:"100%"},children:[(0,d.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 24px",borderBottom:"solid 1px #e8e8e8"},children:[(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)("span",{style:{fontSize:16,fontWeight:500},children:"创建数据报表"}),(0,d.jsx)(ep.Divider,{orientation:"vertical"}),(0,d.jsx)(ep.Tooltip,{title:"保存",children:(0,d.jsx)(ep.Button,{type:"link",className:"toolbar",onClick:()=>{null==f||f(Y)},loading:v,children:(0,d.jsx)(ed.SaveOutlined,{})})}),(0,d.jsx)(ep.Divider,{orientation:"vertical"}),(0,d.jsx)(ep.Tooltip,{title:"撤销",children:(0,d.jsx)("a",{className:`toolbar ${C.length>1?"active":""}`,onClick:()=>{S(e=>{if(e.length<=1)return e;O(!0);let t=e[e.length-2];return k(e=>[...e,JSON.parse(JSON.stringify(Y))]),_(t),$(null),setTimeout(()=>O(!1),0),e.slice(0,-1)})},children:(0,d.jsx)(ed.UndoOutlined,{})})}),(0,d.jsx)(ep.Tooltip,{title:"重做",children:(0,d.jsx)("a",{className:`toolbar ${I.length>0?"active":""}`,onClick:()=>{k(e=>e.length?(O(!0),S(e=>[...e,JSON.parse(JSON.stringify(Y))]),_(e[e.length-1]),$(null),setTimeout(()=>O(!1),0),e.slice(0,-1)):e)},children:(0,d.jsx)(ed.RedoOutlined,{})})}),(0,d.jsx)(ep.Divider,{orientation:"vertical"}),(0,d.jsx)(ep.Tooltip,{title:"导入JSON",children:(0,d.jsx)("a",{className:`toolbar ${I.length>0?"active":""}`,onClick:()=>{U(!0)},children:(0,d.jsx)(ed.ImportOutlined,{})})})]}),(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)(ep.Tooltip,{title:"缩小",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>w(parseFloat(Math.max(y-.1,.5).toFixed(1))),children:(0,d.jsx)(ed.ZoomOutOutlined,{})})}),(0,d.jsxs)("div",{style:{fontSize:12,color:"#999",userSelect:"none"},children:[(100*y).toFixed(0),"%"]}),(0,d.jsx)(ep.Tooltip,{title:"放大",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>w(parseFloat(Math.min(y+.1,2).toFixed(1))),children:(0,d.jsx)(ed.ZoomInOutlined,{})})}),(0,d.jsx)(ep.Tooltip,{title:"重置缩放",children:(0,d.jsx)("a",{className:"toolbar",onClick:()=>w(1),children:(0,d.jsx)(eu,{type:"icon-zoom-reset"})})}),(0,d.jsx)(ep.Divider,{orientation:"vertical"}),(0,d.jsx)(ep.Tooltip,{title:"切换左侧栏",children:(0,d.jsx)("a",{className:`toolbar ${E?"active":""}`,onClick:()=>{B(e=>!e),setTimeout(()=>{var e,t;return null==(t=j.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,d.jsx)(eu,{type:"icon-sider-l"})})}),(0,d.jsx)(ep.Tooltip,{title:"切换右侧栏",children:(0,d.jsx)("a",{className:`toolbar ${M?"active":""}`,onClick:()=>{P(e=>!e),setTimeout(()=>{var e,t;return null==(t=j.current)||null==(e=t.handleResize)?void 0:e.call(t)},0)},children:(0,d.jsx)(eu,{type:"icon-sider-r"})})}),o]})]}),(0,d.jsxs)(ts,{style:W,children:[(0,d.jsxs)("div",{className:"left",style:X,children:[(0,d.jsx)("div",{style:{padding:"22px 1px 22px 0",borderRight:"solid 1px #e8e8e8"},children:(0,d.jsxs)(ep.Radio.Group,{value:R,onChange:e=>F(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"left-pane-tabs",children:[(0,d.jsx)(ep.Radio.Button,{value:"component",children:(0,d.jsx)(ep.Tooltip,{title:"组件",placement:"right",children:(0,d.jsx)(eu,{type:"icon-puzzle"})})}),(0,d.jsx)(ep.Radio.Button,{value:"layer",children:(0,d.jsx)(ep.Tooltip,{title:"图层",placement:"right",children:(0,d.jsx)(eu,{type:"icon-outline"})})}),!!p&&(0,d.jsx)(ep.Radio.Button,{value:"dataset",children:(0,d.jsx)(ep.Tooltip,{title:"数据集",placement:"right",children:(0,d.jsx)(eu,{type:"icon-dataset"})})}),s&&(0,d.jsx)(ep.Radio.Button,{value:"datasource",title:"数据源",children:(0,d.jsx)(ep.Tooltip,{title:"数据源",placement:"right",children:(0,d.jsx)(eu,{type:"icon-datasource"})})}),u&&(0,d.jsx)(ep.Radio.Button,{value:"script",children:(0,d.jsx)(ep.Tooltip,{title:"脚本",placement:"right",children:(0,d.jsx)(eu,{type:"icon-js"})})}),(0,d.jsx)(ep.Radio.Button,{value:"env",children:(0,d.jsx)(ep.Tooltip,{title:"环境变量",placement:"right",children:(0,d.jsx)(eu,{type:"icon-variable"})})}),(0,d.jsx)(ep.Radio.Button,{value:"code",children:(0,d.jsx)(ep.Tooltip,{title:"源码",placement:"right",children:(0,d.jsx)(eu,{type:"icon-json"})})})]})}),(0,d.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:["component"===R&&(0,d.jsx)(e2,{}),"layer"===R&&(0,d.jsx)(e9,{}),s&&"datasource"===R&&(0,d.jsx)(e8,{}),u&&"script"===R&&(0,d.jsx)(tn,{}),"env"===R&&(0,d.jsx)(ta,{}),"code"===R&&(0,d.jsx)(eZ,{}),!!p&&"dataset"===R&&(0,d.jsx)(to,{ref:b,renderNode:p})]})]}),(0,d.jsxs)("div",{className:"center",style:{flex:"1 1 auto"},children:[(0,d.jsx)(eL,{title:"页面",extra:(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)(ep.Button,{size:"small",type:q?"default":"primary",icon:q?(0,d.jsx)(ed.EyeInvisibleOutlined,{}):(0,d.jsx)(ed.EyeOutlined,{}),onClick:()=>H(!q)}),(0,d.jsxs)(ep.Radio.Group,{value:N,onChange:e=>T(e.target.value),size:"small",buttonStyle:"outline",children:[(0,d.jsx)(ep.Radio.Button,{value:"desktop",title:"桌面",children:(0,d.jsx)(ed.DesktopOutlined,{})}),(0,d.jsx)(ep.Radio.Button,{value:"mobile",title:"移动设备",children:(0,d.jsx)(ed.MobileOutlined,{})}),(0,d.jsx)(ep.Radio.Button,{value:"tablet",title:"平板设备",children:(0,d.jsx)(ed.TabletOutlined,{})})]})]})}),(0,d.jsx)("div",{className:["body beautified_scrollbar always",N].join(" "),children:(0,d.jsx)("div",{style:{transform:`scale(${y})`,transformOrigin:"top center"},children:(0,d.jsx)(eI,{ref:j,device:N})})})]}),(0,d.jsxs)("div",{className:"right",style:V,children:[(0,d.jsxs)("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",width:"calc(100% - 47px)"},children:[(0,d.jsx)(eq,{agentList:a,onEffect:Z,style:{display:"ai"===ee&&(null==h?void 0:h.ai)?void 0:"none"}}),"props"===ee&&(0,d.jsx)(te,{datasourceEnable:s}),"cascade"===ee&&(null==L?void 0:L.cascadeIds)&&(0,d.jsx)(eX,{})]}),(0,d.jsx)("div",{style:{padding:"22px 0",borderLeft:"solid 1px #e8e8e8",display:"flex",flexDirection:"column",justifyContent:"space-between",alignItems:"center"},children:(0,d.jsxs)(ep.Radio.Group,{value:ee,onChange:e=>A(e.target.value),buttonStyle:"outline",style:{fontWeight:"normal",display:"inline-flex",flexDirection:"column",gap:14},className:"right-pane-tabs",children:[(null==h?void 0:h.ai)&&(0,d.jsx)(ep.Radio.Button,{value:"ai",children:(0,d.jsx)(ep.Tooltip,{title:"智能助理",placement:"right",children:(0,d.jsx)(eu,{type:"icon-assistant"})})}),(0,d.jsx)(ep.Radio.Button,{value:"props",children:(0,d.jsx)(ep.Tooltip,{title:"属性",placement:"right",children:(0,d.jsx)(eu,{type:"icon-info"})})}),(null==L?void 0:L.cascadeIds)&&(0,d.jsx)(ep.Radio.Button,{value:"cascade",children:(0,d.jsx)(ep.Tooltip,{title:"联动",placement:"right",children:(0,d.jsx)(eu,{type:"icon-cascade"})})})]})})]})]})]}),(0,d.jsx)(td,{open:G,onOk:e=>{U(!1),_(e)},onCancel:()=>U(!1)}),(0,d.jsx)(ep.Drawer,{open:J,size:400,mask:!1,title:null,closable:!1,styles:{body:{padding:0}},onClose:()=>K(!1),children:(0,d.jsx)(eq,{agentList:a,headExtra:(0,d.jsx)(ep.Button,{type:"link",icon:(0,d.jsx)(ed.CloseOutlined,{}),onClick:()=>K(!1)}),onEffect:Z})})]})});var tu=((i={}).STRING="STRING",i.NUMBER="NUMBER",i.BOOLEAN="BOOLEAN",i.OBJECT="OBJECT",i.ARRAY="ARRAY",i);let tp=h()(ed.InfoCircleOutlined)`
988
988
  vertical-align: middle;
989
989
  margin-left: 2px;
990
990
  color: var(--ant-color-text-description);
@@ -1008,7 +1008,7 @@
1008
1008
  color: #999;
1009
1009
  font-size: 12px;
1010
1010
  }
1011
- `,tx=(e,t)=>{let[l,n]=(0,c.useState)(null),{fetch:r,getVars:a}=(0,c.useContext)(f);return(0,c.useEffect)(()=>{if(!(null==e?void 0:e.datasource))return n(null);switch((null==e?void 0:e.datasource.source)||"custom"){case"custom":try{return n(JSON.parse((null==e?void 0:e.datasource.custom)||"[]"))}catch(e){break}case"dataset":if(!(null==e?void 0:e.datasource.dataset)||!(null==r?void 0:r.dataset))break;let t=a(e.id||"");r.dataset(null==e?void 0:e.datasource.dataset.id,t).then(e=>n((null==e?void 0:e.data)||null)).catch(e=>{console.error(e),n(null)})}return n(null)},[null==e?void 0:e.datasource,t]),l},th=h().div`
1011
+ `,tx=(e,t)=>{let[l,n]=(0,c.useState)(null),{fetch:r,getVars:a}=(0,c.useContext)(f);return(0,c.useEffect)(()=>{if(!(null==e?void 0:e.datasource))return n(null);switch((null==e?void 0:e.datasource.source)||"custom"){case"custom":try{return n(JSON.parse((null==e?void 0:e.datasource.custom)||"[]"))}catch(e){break}case"dataset":if(!(null==e?void 0:e.datasource.dataset)||!(null==r?void 0:r.dataset))break;let t=a(e.id||"");r.dataset(null==e?void 0:e.datasource.dataset.id,t).then(e=>n((null==e?void 0:e.data)||null)).catch(e=>{console.error(e),n(null)})}return n(null)},[null==e?void 0:e.datasource,t]),{datasource:l}},th=h().div`
1012
1012
  box-sizing: border-box;
1013
1013
  margin: 0;
1014
1014
  padding: 0;
@@ -1085,7 +1085,7 @@
1085
1085
  const module = undefined;
1086
1086
  const exports = undefined;
1087
1087
  ${e.customRender}
1088
- `)(console,Math,Date,Array,Object,String,Number,Boolean,t,l,n):e.render})),g=()=>{console.log("callback table")};return(0,c.useEffect)(()=>{m({id:l.id,callback:g})},[]),(0,d.jsx)(ep.Table,{id:t,dataSource:n,columns:h,pagination:x,bordered:i,size:o,showHeader:"boolean"!=typeof s||s,rowKey:(e,t)=>String(t),style:{padding:1,...u},className:p})},formComponent:e=>{let{model:t,onChange:l}=e,n=(e,n)=>l&&l({...t,[e]:n}),r=(e,l)=>{let r=[...t.columns||[]];r[e]={...r[e],...l},n("columns",r)},[a,i]=(0,c.useState)(!1),[o,s]=(0,c.useState)(null),u=null!=o&&t.columns[o]?t.columns[o]:{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1},p=[{title:"列名",dataIndex:"title"},{title:"数据索引",dataIndex:"dataIndex"},{title:"操作",width:80,align:"center",render:(e,l,r)=>(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)("a",{onClick:()=>{s(r),i(!0)},children:(0,d.jsx)(ed.EditOutlined,{})}),(0,d.jsx)("a",{onClick:()=>{let e;(e=[...t.columns||[]]).splice(r,1),n("columns",e)},children:(0,d.jsx)(ed.DeleteOutlined,{})})]})}];return(0,d.jsxs)("div",{children:[(0,d.jsxs)(ep.Form,{labelCol:{span:12},wrapperCol:{span:12},children:[(0,d.jsx)(ep.Form.Item,{label:"大小",children:(0,d.jsxs)(ep.Radio.Group,{size:"small",value:t.size,onChange:e=>n("size",e.target.value),children:[(0,d.jsx)(ep.Radio.Button,{value:"small",children:"小"}),(0,d.jsx)(ep.Radio.Button,{value:"middle",children:"中"}),(0,d.jsx)(ep.Radio.Button,{value:"large",children:"大"})]})}),(0,d.jsx)(ep.Form.Item,{label:"边框",children:(0,d.jsx)(ep.Switch,{size:"small",checked:!!t.bordered,onChange:e=>n("bordered",e)})}),(0,d.jsx)(ep.Form.Item,{label:"显示表头",children:(0,d.jsx)(ep.Switch,{size:"small",checked:!!t.showHeader,onChange:e=>n("showHeader",e)})}),(0,d.jsx)(ep.Form.Item,{label:"分页大小",children:(0,d.jsx)(ep.InputNumber,{size:"small",value:t.pageSize,onChange:e=>n("pageSize",e)})})]}),(0,d.jsx)(ep.Divider,{children:"表格列设置"}),(0,d.jsx)(ep.Table,{size:"small",dataSource:t.columns,rowKey:(e,t)=>String(t),columns:p,pagination:!1,bordered:!0}),(0,d.jsx)(ep.Button,{size:"small",onClick:()=>{n("columns",[...t.columns||[],{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1}])},block:!0,children:"添加列"}),(0,d.jsx)(ep.Modal,{title:"编辑列",open:a,footer:null,width:400,onCancel:()=>i(!1),children:(0,d.jsx)(ep.Form,{layout:"vertical",children:(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,d.jsx)(ep.Form.Item,{label:"列名",children:(0,d.jsx)(ep.Input,{value:u.title,onChange:e=>r(o,{title:e.target.value})})}),(0,d.jsx)(ep.Form.Item,{label:"数据索引",children:(0,d.jsx)(ep.Input,{value:u.dataIndex,onChange:e=>r(o,{dataIndex:e.target.value})})}),(0,d.jsx)(ep.Form.Item,{label:"宽度",children:(0,d.jsx)(ep.Input,{value:u.width,onChange:e=>r(o,{width:e.target.value})})}),(0,d.jsx)(ep.Form.Item,{label:"对齐",children:(0,d.jsxs)(ep.Radio.Group,{value:u.align,onChange:e=>r(o,{align:e.target.value}),children:[(0,d.jsx)(ep.Radio.Button,{value:"left",children:(0,d.jsx)(ed.AlignLeftOutlined,{})}),(0,d.jsx)(ep.Radio.Button,{value:"center",children:(0,d.jsx)(ed.AlignCenterOutlined,{})}),(0,d.jsx)(ep.Radio.Button,{value:"right",children:(0,d.jsx)(ed.AlignRightOutlined,{})})]})}),(0,d.jsx)(ep.Form.Item,{label:"省略",children:(0,d.jsx)(ep.Switch,{checked:!!u.ellipsis,onChange:e=>r(o,{ellipsis:e})})})]})})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:null},props:{size:"default",bordered:!0,showHeader:!0,pageSize:10,dataSource:[{name:"苹果",count:12},{name:"华为",count:803},{name:"OPPO",count:654},{name:"vivo",count:719}],columns:[{title:"品牌",dataIndex:"name"},{title:"日销量(件)",dataIndex:"count"}]}}},{group:"基础组件",key:"b-list",label:"列表",icon:"icon-unordered-list",component:e=>{let{id:t,pageSize:l=10,bordered:n=!0,size:r="default",itemLayout:a="horizontal",item:i,split:o=!0,style:s={},className:u}=e,{initCallback:p}=(0,c.useContext)(f),[m,x]=(0,c.useState)(0),h=tx(i,m),g=(0,c.useRef)(h);(0,c.useEffect)(()=>{g.current=h},[h]);let v=g.current||[],j=(0,c.useMemo)(()=>!!l&&!(l<=v.length)&&{total:v.length,pageSize:l,size:"default"===r?void 0:r,showSizeChanger:!0,showQuickJumper:!0,hideOnSinglePage:!0,pageSizeOptions:["10","20","30","40"],showTotal:(e,t)=>`共 ${e} 条记录,显示第 ${t[0]}-${t[1]} 条`},[l,v.length,r]),b=["p-list",a?`p-list--${a}`:void 0,r?`p-list--${r}`:void 0,o?"p-list--split":void 0,n?"p-list--bordered":void 0,u],y=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return e&&x(e=>e+1),{target:i,data:g.current}};return(0,c.useEffect)(()=>{p({id:i.id,callback:y})},[]),(0,d.jsxs)("div",{id:t,style:{display:"flex",flexDirection:"column",...s},className:b.filter(Boolean).join(" "),children:[(0,d.jsx)(tC,{list:v,split:o,bordered:n,size:r,itemLayout:a}),j&&(0,d.jsx)(ep.Pagination,{...j})]})},formComponent:e=>{let{model:t,onChange:l}=e,[n]=ep.Form.useForm();return(0,c.useEffect)(()=>{n.setFieldsValue({size:t.size||"default",itemLayout:t.itemLayout||"horizontal",bordered:t.bordered??!1,split:t.split??!0,pageSize:t.pageSize||10})},[t,n]),(0,d.jsxs)(ep.Form,{form:n,labelCol:{span:12},wrapperCol:{span:12},onValuesChange:e=>{null==l||l({...t,...e})},children:[(0,d.jsx)(ep.Form.Item,{label:"大小",name:"size",children:(0,d.jsxs)(ep.Radio.Group,{size:"small",buttonStyle:"solid",children:[(0,d.jsx)(ep.Radio.Button,{value:"default",children:"默认"}),(0,d.jsx)(ep.Radio.Button,{value:"small",children:"小"})]})}),(0,d.jsx)(ep.Form.Item,{label:"布局",name:"itemLayout",children:(0,d.jsxs)(ep.Radio.Group,{size:"small",buttonStyle:"solid",children:[(0,d.jsx)(ep.Radio.Button,{value:"horizontal",children:"水平"}),(0,d.jsx)(ep.Radio.Button,{value:"vertical",children:"垂直"})]})}),(0,d.jsx)(ep.Form.Item,{label:"边框",name:"bordered",valuePropName:"checked",children:(0,d.jsx)(ep.Switch,{size:"small"})}),(0,d.jsx)(ep.Form.Item,{label:"分割线",name:"split",valuePropName:"checked",children:(0,d.jsx)(ep.Switch,{size:"small"})}),(0,d.jsx)(ep.Form.Item,{label:"分页大小",name:"pageSize",children:(0,d.jsx)(ep.InputNumber,{size:"small"})})]})},defaultOptions:{datasource:{source:"custom",custom:"[]"},props:{size:"default",itemLayout:"horizontal",bordered:!0,split:!0,pageSize:10}}},{group:"基础组件",key:"b-html",label:"HTML",icon:"icon-html",component:e=>{let{id:t,template:l="",item:n,style:r,className:a,classNames:i=[]}=e,{initCallback:o}=(0,c.useContext)(f),[s,u]=(0,c.useState)(0),p=tx(n,s),m=(0,c.useRef)(p);(0,c.useEffect)(()=>{m.current=p},[p]);let x=(0,c.useMemo)(()=>Object.keys(p||{}),[p]),h=(0,c.useMemo)(()=>x.map(e=>null==p?void 0:p[e]),[x,p]),g=(0,c.useMemo)(()=>(l||"").replace(/##\s*([^#]+)\s*##/g,(e,t)=>{try{return Function(...x,`
1088
+ `)(console,Math,Date,Array,Object,String,Number,Boolean,t,l,n):e.render})),g=()=>{console.log("callback table")};return(0,c.useEffect)(()=>{m({id:l.id,callback:g})},[]),(0,d.jsx)(ep.Table,{id:t,dataSource:n,columns:h,pagination:x,bordered:i,size:o,showHeader:"boolean"!=typeof s||s,rowKey:(e,t)=>String(t),style:{padding:1,...u},className:p})},formComponent:e=>{let{model:t,onChange:l}=e,n=(e,n)=>l&&l({...t,[e]:n}),r=(e,l)=>{let r=[...t.columns||[]];r[e]={...r[e],...l},n("columns",r)},[a,i]=(0,c.useState)(!1),[o,s]=(0,c.useState)(null),u=null!=o&&t.columns[o]?t.columns[o]:{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1},p=[{title:"列名",dataIndex:"title"},{title:"数据索引",dataIndex:"dataIndex"},{title:"操作",width:80,align:"center",render:(e,l,r)=>(0,d.jsxs)(ep.Space,{children:[(0,d.jsx)("a",{onClick:()=>{s(r),i(!0)},children:(0,d.jsx)(ed.EditOutlined,{})}),(0,d.jsx)("a",{onClick:()=>{let e;(e=[...t.columns||[]]).splice(r,1),n("columns",e)},children:(0,d.jsx)(ed.DeleteOutlined,{})})]})}];return(0,d.jsxs)("div",{children:[(0,d.jsxs)(ep.Form,{labelCol:{span:12},wrapperCol:{span:12},children:[(0,d.jsx)(ep.Form.Item,{label:"大小",children:(0,d.jsxs)(ep.Radio.Group,{size:"small",value:t.size,onChange:e=>n("size",e.target.value),children:[(0,d.jsx)(ep.Radio.Button,{value:"small",children:"小"}),(0,d.jsx)(ep.Radio.Button,{value:"middle",children:"中"}),(0,d.jsx)(ep.Radio.Button,{value:"large",children:"大"})]})}),(0,d.jsx)(ep.Form.Item,{label:"边框",children:(0,d.jsx)(ep.Switch,{size:"small",checked:!!t.bordered,onChange:e=>n("bordered",e)})}),(0,d.jsx)(ep.Form.Item,{label:"显示表头",children:(0,d.jsx)(ep.Switch,{size:"small",checked:!!t.showHeader,onChange:e=>n("showHeader",e)})}),(0,d.jsx)(ep.Form.Item,{label:"分页大小",children:(0,d.jsx)(ep.InputNumber,{size:"small",value:t.pageSize,onChange:e=>n("pageSize",e)})})]}),(0,d.jsx)(ep.Divider,{children:"表格列设置"}),(0,d.jsx)(ep.Table,{size:"small",dataSource:t.columns,rowKey:(e,t)=>String(t),columns:p,pagination:!1,bordered:!0}),(0,d.jsx)(ep.Button,{size:"small",onClick:()=>{n("columns",[...t.columns||[],{title:"",dataIndex:"",width:"",align:"left",ellipsis:!1}])},block:!0,children:"添加列"}),(0,d.jsx)(ep.Modal,{title:"编辑列",open:a,footer:null,width:400,onCancel:()=>i(!1),children:(0,d.jsx)(ep.Form,{layout:"vertical",children:(0,d.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,d.jsx)(ep.Form.Item,{label:"列名",children:(0,d.jsx)(ep.Input,{value:u.title,onChange:e=>r(o,{title:e.target.value})})}),(0,d.jsx)(ep.Form.Item,{label:"数据索引",children:(0,d.jsx)(ep.Input,{value:u.dataIndex,onChange:e=>r(o,{dataIndex:e.target.value})})}),(0,d.jsx)(ep.Form.Item,{label:"宽度",children:(0,d.jsx)(ep.Input,{value:u.width,onChange:e=>r(o,{width:e.target.value})})}),(0,d.jsx)(ep.Form.Item,{label:"对齐",children:(0,d.jsxs)(ep.Radio.Group,{value:u.align,onChange:e=>r(o,{align:e.target.value}),children:[(0,d.jsx)(ep.Radio.Button,{value:"left",children:(0,d.jsx)(ed.AlignLeftOutlined,{})}),(0,d.jsx)(ep.Radio.Button,{value:"center",children:(0,d.jsx)(ed.AlignCenterOutlined,{})}),(0,d.jsx)(ep.Radio.Button,{value:"right",children:(0,d.jsx)(ed.AlignRightOutlined,{})})]})}),(0,d.jsx)(ep.Form.Item,{label:"省略",children:(0,d.jsx)(ep.Switch,{checked:!!u.ellipsis,onChange:e=>r(o,{ellipsis:e})})})]})})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:null},props:{size:"default",bordered:!0,showHeader:!0,pageSize:10,dataSource:[{name:"苹果",count:12},{name:"华为",count:803},{name:"OPPO",count:654},{name:"vivo",count:719}],columns:[{title:"品牌",dataIndex:"name"},{title:"日销量(件)",dataIndex:"count"}]}}},{group:"基础组件",key:"b-list",label:"列表",icon:"icon-unordered-list",component:e=>{let{id:t,pageSize:l=10,bordered:n=!0,size:r="default",itemLayout:a="horizontal",item:i,split:o=!0,style:s={},className:u}=e,{initCallback:p}=(0,c.useContext)(f),[m,x]=(0,c.useState)(0),h=tx(i,m),g=(0,c.useRef)(h);(0,c.useEffect)(()=>{g.current=h},[h]);let{datasource:v}=g.current||[],j=(0,c.useMemo)(()=>!!l&&!(l<=v.length)&&{total:v.length,pageSize:l,size:"default"===r?void 0:r,showSizeChanger:!0,showQuickJumper:!0,hideOnSinglePage:!0,pageSizeOptions:["10","20","30","40"],showTotal:(e,t)=>`共 ${e} 条记录,显示第 ${t[0]}-${t[1]} 条`},[l,v.length,r]),b=["p-list",a?`p-list--${a}`:void 0,r?`p-list--${r}`:void 0,o?"p-list--split":void 0,n?"p-list--bordered":void 0,u],y=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return e&&x(e=>e+1),{target:i,data:g.current}};return(0,c.useEffect)(()=>{p({id:i.id,callback:y})},[]),(0,d.jsxs)("div",{id:t,style:{display:"flex",flexDirection:"column",...s},className:b.filter(Boolean).join(" "),children:[(0,d.jsx)(tC,{list:v,split:o,bordered:n,size:r,itemLayout:a}),j&&(0,d.jsx)(ep.Pagination,{...j})]})},formComponent:e=>{let{model:t,onChange:l}=e,[n]=ep.Form.useForm();return(0,c.useEffect)(()=>{n.setFieldsValue({size:t.size||"default",itemLayout:t.itemLayout||"horizontal",bordered:t.bordered??!1,split:t.split??!0,pageSize:t.pageSize||10})},[t,n]),(0,d.jsxs)(ep.Form,{form:n,labelCol:{span:12},wrapperCol:{span:12},onValuesChange:e=>{null==l||l({...t,...e})},children:[(0,d.jsx)(ep.Form.Item,{label:"大小",name:"size",children:(0,d.jsxs)(ep.Radio.Group,{size:"small",buttonStyle:"solid",children:[(0,d.jsx)(ep.Radio.Button,{value:"default",children:"默认"}),(0,d.jsx)(ep.Radio.Button,{value:"small",children:"小"})]})}),(0,d.jsx)(ep.Form.Item,{label:"布局",name:"itemLayout",children:(0,d.jsxs)(ep.Radio.Group,{size:"small",buttonStyle:"solid",children:[(0,d.jsx)(ep.Radio.Button,{value:"horizontal",children:"水平"}),(0,d.jsx)(ep.Radio.Button,{value:"vertical",children:"垂直"})]})}),(0,d.jsx)(ep.Form.Item,{label:"边框",name:"bordered",valuePropName:"checked",children:(0,d.jsx)(ep.Switch,{size:"small"})}),(0,d.jsx)(ep.Form.Item,{label:"分割线",name:"split",valuePropName:"checked",children:(0,d.jsx)(ep.Switch,{size:"small"})}),(0,d.jsx)(ep.Form.Item,{label:"分页大小",name:"pageSize",children:(0,d.jsx)(ep.InputNumber,{size:"small"})})]})},defaultOptions:{datasource:{source:"custom",custom:"[]"},props:{size:"default",itemLayout:"horizontal",bordered:!0,split:!0,pageSize:10}}},{group:"基础组件",key:"b-html",label:"HTML",icon:"icon-html",component:e=>{let{id:t,template:l="",item:n,style:r,className:a,classNames:i=[]}=e,{initCallback:o}=(0,c.useContext)(f),[s,u]=(0,c.useState)(0),{datasource:p}=tx(n,s),m=(0,c.useRef)(p);(0,c.useEffect)(()=>{m.current=p},[p]);let x=(0,c.useMemo)(()=>Object.keys(p||{}),[p]),h=(0,c.useMemo)(()=>x.map(e=>null==p?void 0:p[e]),[x,p]),g=(0,c.useMemo)(()=>(l||"").replace(/##\s*([^#]+)\s*##/g,(e,t)=>{try{return Function(...x,`
1089
1089
  "use strict";
1090
1090
  const window = undefined;
1091
1091
  const document = undefined;
@@ -1095,7 +1095,7 @@
1095
1095
  const module = undefined;
1096
1096
  const exports = undefined;
1097
1097
  return ${t};
1098
- `)(...h)}catch{return""}}),[l,h]),v=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return e&&u(e=>e+1),{target:n,data:m.current}};return(0,c.useEffect)(()=>{o({id:n.id,callback:v})},[]),(0,d.jsx)("div",{id:t,style:r,className:(i||[]).join(" ")+" "+a,dangerouslySetInnerHTML:{__html:g}})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,c.useRef)(null),r=(e,n)=>l&&l({...t,[e]:n});return(0,d.jsx)("div",{children:(0,d.jsxs)(ep.Form,{layout:"vertical",children:[(0,d.jsx)(ep.Form.Item,{label:"类名",children:(0,d.jsx)(ep.Select,{size:"small",value:t.classNames,mode:"tags",onChange:e=>r("classNames",e)})}),(0,d.jsx)(ep.Form.Item,{label:(0,d.jsxs)(d.Fragment,{children:["模板",(0,d.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,d.jsx)(eu,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,d.jsx)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:(0,d.jsx)(ef(),{onMount:e=>{n.current={editor:e}},height:"300px",defaultLanguage:"html",value:t.template,onChange:e=>r("template",e||""),options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}})})})]})})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'{"name": "Confucius"}'},props:{template:"<div>{{name}}, welcome to the world of programming.</div>"}}},{group:"基础组件",key:"b-echarts",label:"图表",icon:"icon-echarts",component:e=>{let{id:t,script:l="",item:n,height:r=400,style:a,className:i}=e,{initCallback:o}=(0,c.useContext)(f),s=(0,c.useRef)(null),[u,p]=(0,c.useState)(null),[m,x]=(0,c.useState)(0),h=tx(n,m),g=(0,c.useRef)(h);(0,c.useEffect)(()=>{g.current=h},[h]);let v=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return arguments.length>1&&arguments[1],e&&x(e=>e+1),{target:n,data:g.current}};return(0,c.useEffect)(()=>{if(!s.current)return;let e=tS.init(s.current);p(e);let t=()=>e.resize();return window.addEventListener("resize",t),o({id:n.id,callback:v}),()=>{window.removeEventListener("resize",t),e.dispose()}},[]),(0,c.useEffect)(()=>{let e;e=(e=>{try{return JSON.parse(e)}catch(t){try{return Function("echarts","console","Math","Date","Array","Object","String","Number","Boolean","data",`
1098
+ `)(...h)}catch{return""}}),[l,h]),v=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return e&&u(e=>e+1),{target:n,data:m.current}};return(0,c.useEffect)(()=>{o({id:n.id,callback:v})},[]),(0,d.jsx)("div",{id:t,style:r,className:(i||[]).join(" ")+" "+a,dangerouslySetInnerHTML:{__html:g}})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,c.useRef)(null),r=(e,n)=>l&&l({...t,[e]:n});return(0,d.jsx)("div",{children:(0,d.jsxs)(ep.Form,{layout:"vertical",children:[(0,d.jsx)(ep.Form.Item,{label:"类名",children:(0,d.jsx)(ep.Select,{size:"small",value:t.classNames,mode:"tags",onChange:e=>r("classNames",e)})}),(0,d.jsx)(ep.Form.Item,{label:(0,d.jsxs)(d.Fragment,{children:["模板",(0,d.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,d.jsx)(eu,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,d.jsx)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:(0,d.jsx)(ef(),{onMount:e=>{n.current={editor:e}},height:"300px",defaultLanguage:"html",value:t.template,onChange:e=>r("template",e||""),options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}})})})]})})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'{"name": "Confucius"}'},props:{template:"<div>{{name}}, welcome to the world of programming.</div>"}}},{group:"基础组件",key:"b-echarts",label:"图表",icon:"icon-echarts",component:e=>{let{id:t,script:l="",item:n,height:r=400,style:a,className:i}=e,{initCallback:o}=(0,c.useContext)(f),s=(0,c.useRef)(null),[u,p]=(0,c.useState)(null),[m,x]=(0,c.useState)(0),{datasource:h}=tx(n,m),g=(0,c.useRef)(h);(0,c.useEffect)(()=>{console.log("datasource",h),g.current=h},[h]);let v=function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];return arguments.length>1&&arguments[1],e&&x(e=>e+1),{target:n,data:g.current}};return(0,c.useEffect)(()=>{if(!s.current)return;let e=tS.init(s.current);p(e);let t=()=>e.resize();return window.addEventListener("resize",t),o({id:n.id,callback:v}),()=>{window.removeEventListener("resize",t),e.dispose()}},[]),(0,c.useEffect)(()=>{let e;e=(e=>{try{return JSON.parse(e)}catch(t){try{return Function("echarts","console","Math","Date","Array","Object","String","Number","Boolean","data",`
1099
1099
  "use strict";
1100
1100
  const window = undefined;
1101
1101
  const document = undefined;
@@ -1105,7 +1105,7 @@
1105
1105
  const module = undefined;
1106
1106
  const exports = undefined;
1107
1107
  ${e}
1108
- `)(tS,console,Math,Date,Array,Object,String,Number,Boolean,h)}catch(e){return console.error("ECharts 配置解析失败:",e),null}}})(l),u&&e&&(u.setOption(e),setTimeout(()=>u.resize(),50))},[u,l,h]),(0,d.jsx)("div",{id:t,style:{width:"100%",height:r,...a},className:i,children:(0,d.jsx)("div",{ref:s,style:{width:"100%",height:r,...a}})})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,c.useRef)(null);return(0,d.jsxs)(ep.Form,{children:[(0,d.jsx)(ep.Form.Item,{label:"高度",labelCol:{span:6},wrapperCol:{span:18},children:(0,d.jsx)(ep.InputNumber,{value:t.height,size:"small",min:10,max:1e3,suffix:"px",onChange:e=>l&&l({...t,height:e})})}),(0,d.jsx)(ep.Form.Item,{layout:"vertical",label:(0,d.jsxs)(d.Fragment,{children:["Echarts 渲染脚本"," ",(0,d.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,d.jsx)(eu,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,d.jsxs)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:[(0,d.jsxs)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:["function getOptions(data) ","{"," "]}),(0,d.jsx)(ef(),{onMount:e=>{n.current={editor:e}},height:"400px",defaultLanguage:"javascript",value:t.script,onChange:e=>{let n;return n=e||"",l&&l({...t,script:n||""})},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}}),(0,d.jsx)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:"}"})]})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'[{"name":"Mon","value":150},{"name":"Tue","value":230},{"name":"Wed","value":224},{"name":"Thu","value":218},{"name":"Fri","value":135},{"name":"Sat","value":147},{"name":"Sun","value":260}]'},props:{script:`
1108
+ `)(tS,console,Math,Date,Array,Object,String,Number,Boolean,h)}catch(e){return null}}})(l),u&&e&&(u.setOption(e),setTimeout(()=>u.resize(),50))},[u,l,h]),(0,d.jsx)("div",{id:t,style:{width:"100%",height:r,...a},className:i,children:(0,d.jsx)("div",{ref:s,style:{width:"100%",height:r,...a}})})},formComponent:e=>{let{model:t,onChange:l}=e,n=(0,c.useRef)(null);return(0,d.jsxs)(ep.Form,{children:[(0,d.jsx)(ep.Form.Item,{label:"高度",labelCol:{span:6},wrapperCol:{span:18},children:(0,d.jsx)(ep.InputNumber,{value:t.height,size:"small",min:10,max:1e3,suffix:"px",onChange:e=>l&&l({...t,height:e})})}),(0,d.jsx)(ep.Form.Item,{layout:"vertical",label:(0,d.jsxs)(d.Fragment,{children:["Echarts 渲染脚本"," ",(0,d.jsxs)("a",{onClick:()=>{var e,t;let l=null==(e=n.current)?void 0:e.editor;null==l||null==(t=l.getAction("editor.action.formatDocument"))||t.run()},children:[(0,d.jsx)(eu,{type:"icon-formate"})," 格式化"]})]}),className:"ant-form-item-label-space",children:(0,d.jsxs)("div",{style:{border:"1px solid #d9d9d9",borderRadius:4,textAlign:"left"},children:[(0,d.jsxs)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:["function getOptions(data) ","{"," "]}),(0,d.jsx)(ef(),{onMount:e=>{n.current={editor:e}},height:"400px",defaultLanguage:"javascript",value:t.script,onChange:e=>{let n;return n=e||"",l&&l({...t,script:n||""})},options:{minimap:{enabled:!1},scrollBeyondLastLine:!1,tabSize:2}}),(0,d.jsx)("div",{style:{color:"#0000ff",fontSize:14,padding:"0 50px"},children:"}"})]})})]})},defaultOptions:{datasource:{source:"custom",datasourceId:null,scriptId:null,custom:'[{"name":"Mon","value":150},{"name":"Tue","value":230},{"name":"Wed","value":224},{"name":"Thu","value":218},{"name":"Fri","value":135},{"name":"Sat","value":147},{"name":"Sun","value":260}]'},props:{script:`
1109
1109
  return {
1110
1110
  xAxis: { type: 'category', data: data.map(i => i.name) },
1111
1111
  yAxis: { type: 'value' },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bi-sdk-react",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "dist/umd/js/bi-sdk.umd.min.js",
@@ -4,7 +4,7 @@ import { SchemaItemType } from "../typing";
4
4
 
5
5
  export type Signal = string | number;
6
6
 
7
- export const useDatasource = (item: SchemaItemType, signal?: Signal): any => {
7
+ export const useDatasource = (item: SchemaItemType, signal?: Signal): { datasource: any } => {
8
8
  const [datasource, setDatasource] = useState<any>(null);
9
9
  const { fetch, getVars } = useContext(PageContext);
10
10
  useEffect(() => {
@@ -39,5 +39,5 @@ export const useDatasource = (item: SchemaItemType, signal?: Signal): any => {
39
39
  return setDatasource(null);
40
40
  }, [item?.datasource, signal]);
41
41
 
42
- return datasource;
42
+ return { datasource };
43
43
  };
@@ -24,9 +24,10 @@ export const EchartsRender: React.FC<EchartsRenderProps> = ({
24
24
  const chartRef = useRef<HTMLDivElement | null>(null);
25
25
  const [chart, setChart] = useState<echarts.ECharts | null>(null);
26
26
  const [signal, setSignal] = useState<number>(0);
27
- const datasource = useDatasource(item, signal);
27
+ const { datasource } = useDatasource(item, signal);
28
28
  const datasourceRef = useRef(datasource);
29
29
  useEffect(() => {
30
+ console.log("datasource", datasource);
30
31
  datasourceRef.current = datasource;
31
32
  }, [datasource]);
32
33
 
@@ -71,7 +72,7 @@ export const EchartsRender: React.FC<EchartsRenderProps> = ({
71
72
  datasource,
72
73
  );
73
74
  } catch (evalError) {
74
- console.error("ECharts 配置解析失败:", evalError);
75
+ // console.error("ECharts 配置解析失败:", evalError);
75
76
  return null;
76
77
  }
77
78
  }
@@ -32,8 +32,8 @@ export const HtmlRender: React.FC<HtmlRenderProps> = ({
32
32
  }) => {
33
33
  const { initCallback } = useContext(PageContext);
34
34
  const [signal, setSignal] = useState<number>(0);
35
- const datasource = useDatasource(item, signal);
36
-
35
+ const { datasource } = useDatasource(item, signal);
36
+
37
37
  const datasourceRef = useRef(datasource);
38
38
  useEffect(() => {
39
39
  datasourceRef.current = datasource;
@@ -194,7 +194,7 @@ export const ListRender: React.FC<ListRenderProps> = ({
194
194
  datasourceRef.current = datasource;
195
195
  }, [datasource]);
196
196
 
197
- const list = datasourceRef.current || [];
197
+ const { datasource: list } = datasourceRef.current || [];
198
198
  const pagination = useMemo(() => {
199
199
  if (!pageSize || pageSize <= list.length) return false;
200
200
  return {