import{Bi as e,Or as t,Ui as n,ma as r,vt as i}from"./stores-BWYw2E2w.js";import{o as a,t as o}from"./utils-cLZb83du.js";function s(e,t){return{key:o(e),value:t}}function c(e){return Object.entries(e).map(([e,t])=>s(e,t))}var l=({properties:e,childrenOfPanel:t=[],rowUuid:n=a(),rowConfigList:r})=>{e.rowConfig=e.rowConfig||`30`;let i=c(e);return i.push({key:`prototype-type`,value:e.protoTypeSource}),i=i.filter(e=>e.key!==`row-config`),r&&r.forEach((e,t)=>{e&&i.push({uuid:e,key:`row-config`,value:((t+1)*10).toString()})}),{uuid:a(),controlTypeId:`gx-pc-panel`,isRootPanel:!0,propertys:i,childControllerItems:t}},u=({dialogUuid:e,properties:t,childrenOfDialog:n})=>{let r=c(t);return r.push({key:`prototype-type`,value:t.protoTypeSource}),{uuid:e,controlTypeId:`gx-pc-dialog`,isRootPanel:!0,propertys:r,childControllerItems:n||[]}},d=function(e){return e.PANEL=`panel`,e.DIALOG=`dialog`,e}({});function f(e){let{containerType:t,properties:n,children:r,rowUuid:i,dialogUuid:a,rowConfigList:o}=e;switch(t){case d.PANEL:return l({properties:n,childrenOfPanel:r,rowUuid:i,rowConfigList:o});case d.DIALOG:if(!a)throw Error(`创建 Dialog 容器时必须提供 dialogUuid 参数`);return u({dialogUuid:a,properties:n,childrenOfDialog:r});default:throw Error(`不支持的容器类型: ${t}`)}}var p=()=>{let e=a();return[{controlTypeId:`gx-pc-dialog-footer`,propertys:[{uuid:e,key:`row-config`,value:`from-adap`}],childControllerItems:[{controlTypeId:`gx-pc-button`,propertys:[{key:`pre-non-column-sort-no`,value:`unset`},{key:`row-id`,value:e},{key:`sort-no`,value:`10.000000`},{key:`columns`,value:`20`},{key:`label`,value:`关闭`},{key:`action-type`,value:`close-dialog`},{key:`type`,value:`info`},{key:`round`,value:`4`}]},{controlTypeId:`gx-pc-button`,propertys:[{key:`pre-non-column-sort-no`,value:`unset`},{key:`row-id`,value:e},{key:`sort-no`,value:`20.000000`},{key:`columns`,value:`20`},{key:`label`,value:`确认`},{key:`action-type`,value:`close-dialog`},{key:`type`,value:`primary`},{key:`round`,value:`4`}]}]}]},m=async(e,n,i)=>{let a=g(e,n);if(!a)return;let o=e.controlTypeId;o!==`gx-pc-panel`&&o!==`gx-pc-dialog`&&!r(o)&&(o=`gx-pc-panel`);let s=await t({form:{_devicetype:`pc`,_id:``,body:{[o]:a}}},{formUuid:n,zxlPrdId:i});s&&await s()},h=(t,n)=>{let r=t.childControllerItems||[],i=r.length;for(let o=0;o<i;o++){let i=r[o];i.superControlUuid=t.uuid;let s=i.uuid;s||(s=a(),i.uuid=s);let c=i.no;c||(c=e.getNo({formUuid:n._formUUID,controlTypeId:i.controlTypeId,controlUuid:s}),i.no=c);let l={_controlUUID:s,_controlNo:c,_formUUID:n._formUUID,_formNo:void 0,_hid:``,_formTemplateControlObId:i.formTemplateControlObId},u=i.controlTypeId;if(u){if(!n[u])n[u]=l;else if(Array.isArray(n[u]))n[u].push(l);else{let e=n[u];n[u]=[],n[u].push(e),n[u].push(l)}h(i,l)}}let o=t.propertys||[],s=o.length;for(let e=0;e<s;e++){let r=o[e],i=r.uuid;i||(i=a(),r.uuid=i),r.uuid=i,r.controlUuid=r.controlUuid||t.uuid;let s={_name:r.key,_UUID:r.uuid,_value:r.value,_hid:``};if(!n.property)n.property=s;else if(Array.isArray(n.property))n.property.push(s);else{let e=n.property;n.property=[],n.property.push(e),n.property.push(s)}}},g=(t,n)=>{if(!t)return null;let r=t.no;r||(r=e.getNo({formUuid:n,controlTypeId:t.controlTypeId,controlUuid:t.uuid||``}),t.no=r);let i={_controlUUID:t.uuid,_controlNo:r,_formUUID:n,_formNo:void 0,_hid:``,_formTemplateControlObId:t.formTemplateControlObId};return h(t,i),i},_=async e=>{let{dialogUuid:t,title:r,zxlPrdId:o,userRequestId:s,assignUserIntfId:c,accessPortalObId:l,protoTypeSource:d,formFunctionType:f}=e,h=await n({zxlPrdId:o,userIntfId:c||a(),userIntfNo:``,userIntfName:`${r}`,functionId:``,note:``,protoType:d||`GENERATE`,protoObject:``,accessPortalObId:l||``,formType:`DIALOG`,formFunctionType:f});if(!h)throw Error(`新建用户界面失败！`);let{userIntfId:_,userIntfNo:v,userIntfName:y}=h,b=[`add`,`edit`].includes(e.formContentType),x=u({dialogUuid:t,properties:{label:r.replace(/界面$/,``),bindUserIntfId:_,bindUserIntfNo:v,bindUserIntfName:y,protoTypeSource:d||`GENERATE`,backInterfaceName:``,backInterfaceId:``,backInterfaceUrl:``,showFooter:b},childrenOfDialog:p()}),S=g(x,_);if(!S)return _;let C={form:{body:{_devicetype:`pc`,_id:``,"gx-pc-dialog":S}}},w=i();return await m(x,_,o),w.tempFormPool.add(`form`,_,C),_};export{f as a,d as i,m as n,p as o,g as r,_ as t};