@rytass/bpm-core-react 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/README.md +18 -2
- package/dist/chunks/FormBuilderView-BPLwAJGv.cjs +3 -0
- package/dist/chunks/FormBuilderView-BPLwAJGv.cjs.map +1 -0
- package/dist/chunks/FormBuilderView-Do9-MIAe.js +1477 -0
- package/dist/chunks/FormBuilderView-Do9-MIAe.js.map +1 -0
- package/dist/chunks/FormRendererView-C5POZbWz.js +492 -0
- package/dist/chunks/FormRendererView-C5POZbWz.js.map +1 -0
- package/dist/chunks/FormRendererView-DNtNodNl.cjs +2 -0
- package/dist/chunks/FormRendererView-DNtNodNl.cjs.map +1 -0
- package/dist/chunks/{approval-instance-list-page-YZcGGDD8.js → approval-instance-list-page-BjX2kaoF.js} +56 -54
- package/dist/chunks/approval-instance-list-page-BjX2kaoF.js.map +1 -0
- package/dist/chunks/approval-instance-list-page-C408vxE2.cjs +2 -0
- package/dist/chunks/approval-instance-list-page-C408vxE2.cjs.map +1 -0
- package/dist/chunks/{categories-DBPoSrsi.js → categories-DGlxuC6X.js} +5 -5
- package/dist/chunks/{categories-DBPoSrsi.js.map → categories-DGlxuC6X.js.map} +1 -1
- package/dist/chunks/{categories-B6QZKZRt.cjs → categories-DUfldZ_9.cjs} +2 -2
- package/dist/chunks/{categories-B6QZKZRt.cjs.map → categories-DUfldZ_9.cjs.map} +1 -1
- package/dist/chunks/compose-CULMDsLS.cjs +2 -0
- package/dist/chunks/compose-CULMDsLS.cjs.map +1 -0
- package/dist/chunks/{compose-CQHDT7vh.js → compose-DJBlA5PD.js} +60 -58
- package/dist/chunks/compose-DJBlA5PD.js.map +1 -0
- package/dist/chunks/{delegations-DDEk-WI6.cjs → delegations-CGj-tZNO.cjs} +2 -2
- package/dist/chunks/{delegations-DDEk-WI6.cjs.map → delegations-CGj-tZNO.cjs.map} +1 -1
- package/dist/chunks/{delegations-iVnRi3QE.js → delegations-DLEEFBlH.js} +231 -231
- package/dist/chunks/{delegations-iVnRi3QE.js.map → delegations-DLEEFBlH.js.map} +1 -1
- package/dist/chunks/{delegations-ZNtodFaD.js → delegations-DqMpI_Nk.js} +168 -167
- package/dist/chunks/delegations-DqMpI_Nk.js.map +1 -0
- package/dist/chunks/delegations-kbMOSEif.cjs +2 -0
- package/dist/chunks/delegations-kbMOSEif.cjs.map +1 -0
- package/dist/chunks/{designer-CUbVXEtS.js → designer-BszXJ5RO.js} +1227 -990
- package/dist/chunks/designer-BszXJ5RO.js.map +1 -0
- package/dist/chunks/designer-CmqAU92b.cjs +65 -0
- package/dist/chunks/designer-CmqAU92b.cjs.map +1 -0
- package/dist/chunks/detail-CDexqBoU.cjs +2 -0
- package/dist/chunks/detail-CDexqBoU.cjs.map +1 -0
- package/dist/chunks/{detail-Cts5_gVp.js → detail-DAak2OXS.js} +704 -622
- package/dist/chunks/detail-DAak2OXS.js.map +1 -0
- package/dist/chunks/notifications--hwl-DR0.cjs +2 -0
- package/dist/chunks/{notifications-BKs4--96.cjs.map → notifications--hwl-DR0.cjs.map} +1 -1
- package/dist/chunks/{notifications-CSulztkU.js → notifications-DJ5wzCye.js} +7 -7
- package/dist/chunks/{notifications-CSulztkU.js.map → notifications-DJ5wzCye.js.map} +1 -1
- package/dist/chunks/{orgs-CrNxqlwp.js → orgs-DytLvZ_X.js} +243 -241
- package/dist/chunks/{orgs-CrNxqlwp.js.map → orgs-DytLvZ_X.js.map} +1 -1
- package/dist/chunks/orgs-Ni22buHs.cjs +2 -0
- package/dist/chunks/orgs-Ni22buHs.cjs.map +1 -0
- package/dist/chunks/providers-DEqcuXw9.js +506 -0
- package/dist/chunks/providers-DEqcuXw9.js.map +1 -0
- package/dist/chunks/providers-D_zTbkQH.cjs +2 -0
- package/dist/chunks/providers-D_zTbkQH.cjs.map +1 -0
- package/dist/chunks/{users-qghSMtLn.cjs → users-0HqlM_VQ.cjs} +2 -2
- package/dist/chunks/{users-qghSMtLn.cjs.map → users-0HqlM_VQ.cjs.map} +1 -1
- package/dist/chunks/{users-CUY139DF.js → users-FWrb3ehW.js} +5 -5
- package/dist/chunks/{users-CUY139DF.js.map → users-FWrb3ehW.js.map} +1 -1
- package/dist/components/notification-drawer.d.ts +4 -3
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +21 -428
- package/dist/index.js.map +1 -1
- package/dist/next/index.cjs +1 -1
- package/dist/next/index.cjs.map +1 -1
- package/dist/next/index.js +16 -15
- package/dist/next/index.js.map +1 -1
- package/dist/pages/admin/delegations/index.cjs +1 -1
- package/dist/pages/admin/delegations/index.js +1 -1
- package/dist/pages/admin/orgs/index.cjs +1 -1
- package/dist/pages/admin/orgs/index.js +1 -1
- package/dist/pages/admin/users/index.cjs +1 -1
- package/dist/pages/admin/users/index.js +1 -1
- package/dist/pages/delegations/index.cjs +1 -1
- package/dist/pages/delegations/index.js +1 -1
- package/dist/pages/instances/detail/index.cjs +1 -1
- package/dist/pages/instances/detail/index.js +1 -1
- package/dist/pages/settings/notifications/index.cjs +1 -1
- package/dist/pages/settings/notifications/index.js +1 -1
- package/dist/pages/templates/categories/index.cjs +1 -1
- package/dist/pages/templates/categories/index.js +1 -1
- package/dist/pages/templates/compose/index.cjs +1 -1
- package/dist/pages/templates/compose/index.js +1 -1
- package/dist/pages/templates/designer/index.cjs +1 -1
- package/dist/pages/templates/designer/index.js +1 -1
- package/dist/views/admin/delegations/index.cjs +1 -1
- package/dist/views/admin/delegations/index.js +1 -1
- package/dist/views/admin/index.cjs +1 -1
- package/dist/views/admin/index.js +3 -3
- package/dist/views/admin/orgs/index.cjs +1 -1
- package/dist/views/admin/orgs/index.js +1 -1
- package/dist/views/admin/users/index.cjs +1 -1
- package/dist/views/admin/users/index.js +1 -1
- package/dist/views/cc/index.cjs +1 -1
- package/dist/views/cc/index.js +1 -1
- package/dist/views/delegations/index.cjs +1 -1
- package/dist/views/delegations/index.js +1 -1
- package/dist/views/forms/builder/index.cjs +1 -1
- package/dist/views/forms/builder/index.js +1 -1
- package/dist/views/forms/renderer/FormRendererView.d.ts +7 -2
- package/dist/views/forms/renderer/form-data-source-field.d.ts +34 -0
- package/dist/views/forms/renderer/index.cjs +1 -1
- package/dist/views/forms/renderer/index.d.ts +1 -0
- package/dist/views/forms/renderer/index.js +2 -2
- package/dist/views/instances/detail/index.cjs +1 -1
- package/dist/views/instances/detail/index.js +1 -1
- package/dist/views/instances/detail/sections/InstanceFormSection.d.ts +4 -1
- package/dist/views/instances/detail/sections/InstanceTasksSection.d.ts +5 -1
- package/dist/views/instances/new/index.cjs +1 -1
- package/dist/views/instances/new/index.cjs.map +1 -1
- package/dist/views/instances/new/index.js +105 -86
- package/dist/views/instances/new/index.js.map +1 -1
- package/dist/views/search/index.cjs +1 -1
- package/dist/views/search/index.js +1 -1
- package/dist/views/sent/index.cjs +1 -1
- package/dist/views/sent/index.js +1 -1
- package/dist/views/settings/index.cjs +1 -1
- package/dist/views/settings/index.js +1 -1
- package/dist/views/settings/notifications/index.cjs +1 -1
- package/dist/views/settings/notifications/index.js +1 -1
- package/dist/views/templates/categories/index.cjs +1 -1
- package/dist/views/templates/categories/index.js +1 -1
- package/dist/views/templates/compose/TemplateComposeWizardView.d.ts +3 -2
- package/dist/views/templates/compose/index.cjs +1 -1
- package/dist/views/templates/compose/index.js +1 -1
- package/dist/views/templates/designer/index.cjs +1 -1
- package/dist/views/templates/designer/index.js +1 -1
- package/dist/views/templates/index.cjs +1 -1
- package/dist/views/templates/index.cjs.map +1 -1
- package/dist/views/templates/index.js +153 -112
- package/dist/views/templates/index.js.map +1 -1
- package/package.json +41 -5
- package/dist/chunks/FormBuilderView-B_KGPjlp.cjs +0 -3
- package/dist/chunks/FormBuilderView-B_KGPjlp.cjs.map +0 -1
- package/dist/chunks/FormBuilderView-D8DrQOXD.js +0 -1090
- package/dist/chunks/FormBuilderView-D8DrQOXD.js.map +0 -1
- package/dist/chunks/FormRendererView-BwVsH2eX.cjs +0 -2
- package/dist/chunks/FormRendererView-BwVsH2eX.cjs.map +0 -1
- package/dist/chunks/FormRendererView-DrHsuSVo.js +0 -220
- package/dist/chunks/FormRendererView-DrHsuSVo.js.map +0 -1
- package/dist/chunks/approval-instance-list-page-BMUKxzcz.cjs +0 -2
- package/dist/chunks/approval-instance-list-page-BMUKxzcz.cjs.map +0 -1
- package/dist/chunks/approval-instance-list-page-YZcGGDD8.js.map +0 -1
- package/dist/chunks/compose-CQHDT7vh.js.map +0 -1
- package/dist/chunks/compose-Ds_cAefe.cjs +0 -2
- package/dist/chunks/compose-Ds_cAefe.cjs.map +0 -1
- package/dist/chunks/delegations-C2wLWsDQ.cjs +0 -2
- package/dist/chunks/delegations-C2wLWsDQ.cjs.map +0 -1
- package/dist/chunks/delegations-ZNtodFaD.js.map +0 -1
- package/dist/chunks/designer-CQ9hxSdD.cjs +0 -65
- package/dist/chunks/designer-CQ9hxSdD.cjs.map +0 -1
- package/dist/chunks/designer-CUbVXEtS.js.map +0 -1
- package/dist/chunks/detail-B-Q4W-iw.cjs +0 -2
- package/dist/chunks/detail-B-Q4W-iw.cjs.map +0 -1
- package/dist/chunks/detail-Cts5_gVp.js.map +0 -1
- package/dist/chunks/notifications-BKs4--96.cjs +0 -2
- package/dist/chunks/orgs-iNJ0QEcK.cjs +0 -2
- package/dist/chunks/orgs-iNJ0QEcK.cjs.map +0 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";require('../style.css');const e=require("./chunk-CMqjfN_6.cjs"),t=require("./router-adapter--gYs13E8.cjs"),n=require("./routes-config-fDVHmvXi.cjs"),r=require("./bpm-form-field-Bc6k4ZEO.cjs"),i=require("./admin-pickers-Btvij1at.cjs");;/* empty css */const a=require("./FormBuilderView-BPLwAJGv.cjs");let o=require("react"),s=require("@mezzanine-ui/react"),c=require("react/jsx-runtime"),l=require("@mezzanine-ui/react/Drawer");l=e.t(l,1);let u=require("@mezzanine-ui/react/ContentHeader");u=e.t(u,1);let d=require("@mezzanine-ui/icons"),f=require("ai"),p=require("@rytass/bpm-core-shared"),m=require("@rytass/bpm-core-client/form"),h=require("@rytass/bpm-core-shared/form"),g=require("@rytass/bpm-core-client/organization"),_=require("@xyflow/react"),v=require("dagre");v=e.t(v,1);let y=require("@rytass/bpm-core-client/template"),ee=require("@ai-sdk/react"),b=require("@rytass/bpm-core-shared/workflow-graph");function x({directory:e,initialState:t,layout:n,onLayout:r}){let[i,a]=(0,o.useState)(t),s=(0,o.useRef)(t),c=(0,o.useRef)(e);c.current=e;let l=(0,o.useCallback)(e=>{if(!e.changed&&!e.error)return e;let t=e.effects.layout?n(e.state.definition):e.state.definition,i={...e.state,definition:t};return s.current=i,a(i),e.effects.layout&&r?.(t),{...e,state:i}},[n,r]),u=(0,o.useCallback)(e=>l((0,p.applyWorkflowCommand)(s.current,e)),[l]),d=(0,o.useCallback)(e=>l((0,p.applyWorkflowMacroCommand)(s.current,e)),[l]),f=(0,o.useCallback)(async(e,t)=>{let n=await(0,p.executeWorkflowTool)(s.current,e,t,{directory:c.current});if(n.ok&&(n.kind===`mutation`||n.kind===`macro`)){let e=l(n.result);return{...n,result:e,snapshot:(0,p.readWorkflowSnapshot)(e.state)}}return n},[l]),m=(0,o.useCallback)(e=>{let t=typeof e==`function`?e(s.current):e;s.current=t,a(t)},[]),h=(0,o.useCallback)(()=>s.current,[]),g=(0,o.useMemo)(()=>(0,p.readWorkflowSnapshot)(i),[i]);return(0,o.useMemo)(()=>({dispatch:u,dispatchMacro:d,executeTool:f,getState:h,replaceState:m,snapshot:g,state:i,tools:p.WORKFLOW_TOOLSET}),[u,d,f,h,m,g,i])}function te({controller:e,api:t=`/api/chat`}){let n=(0,ee.useChat)({transport:(0,o.useMemo)(()=>new f.DefaultChatTransport({api:t}),[t]),sendAutomaticallyWhen:f.lastAssistantMessageIsCompleteWithToolCalls,async onToolCall({toolCall:t}){let r=await e.executeTool(t.toolName,t.input);if(r.ok){n.addToolOutput({output:r.kind===`query`?r.data:r.snapshot,tool:t.toolName,toolCallId:t.toolCallId});return}n.addToolOutput({errorText:r.error,state:`output-error`,tool:t.toolName,toolCallId:t.toolCallId})}});return n}var ne=12;function re(){let e=globalThis.LanguageModel;return e&&typeof e==`object`?e:null}var ie={additionalProperties:!1,properties:{action:{enum:[`tool`,`message`],type:`string`},input:{type:`object`},text:{type:`string`},tool:{type:`string`}},required:[`action`],type:`object`};function ae(){return`你是「簽核流程設計器」頁面的離線 AI 助理。只能透過下列工具操作這個流程畫布,其他請求一律婉拒並引導回流程設計。
|
|
2
|
+
|
|
3
|
+
每一步只輸出一個 JSON 決策物件:
|
|
4
|
+
- 呼叫工具:{"action":"tool","tool":"<工具名>","input":{...}}
|
|
5
|
+
- 回覆使用者(完成或詢問):{"action":"message","text":"<繁體中文訊息>"}
|
|
6
|
+
|
|
7
|
+
規則:先用 get_workflow_snapshot 了解現況再規劃;完成後用 validate_workflow 檢查並以 message 說明做了什麼。
|
|
8
|
+
|
|
9
|
+
可用工具:
|
|
10
|
+
${p.WORKFLOW_TOOLSET.map(e=>`- ${e.name}(${JSON.stringify(e.inputSchema.properties??{})}): ${e.description}`).join(`
|
|
11
|
+
`)}`}function oe({controller:e}){let[t,n]=(0,o.useState)(!1),[r,i]=(0,o.useState)([]),[a,s]=(0,o.useState)(`ready`),c=(0,o.useRef)(0);(0,o.useEffect)(()=>{let e=re();e&&e.availability().then(e=>{n(e!==`unavailable`)}).catch(()=>n(!1))},[]);let l=(0,o.useCallback)((e,t)=>{c.current+=1,i(n=>[...n,{id:`chrome-${c.current}`,parts:[{text:t,type:`text`}],role:e}])},[]);return{available:t,messages:r,send:(0,o.useCallback)(t=>{let n=re();!n||a!==`ready`||(l(`user`,t),s(`submitted`),S({appendMessage:l,controller:e,model:n,userText:t}).then(()=>s(`ready`)).catch(e=>{l(`assistant`,C(e)),s(`error`)}))},[l,e,a]),status:a}}async function S({appendMessage:e,controller:t,model:n,userText:r}){let i=await n.create({initialPrompts:[{content:ae(),role:`system`}]});try{let n=`使用者需求:${r}\n目前流程:${JSON.stringify(t.snapshot)}`;for(let r=0;r<ne;r+=1){let r=se(await i.prompt(n,{responseConstraint:ie}));if(!r||r.action===`message`){e(`assistant`,r?.text??`我已完成可處理的部分。`);return}if(!r.tool){e(`assistant`,`我已完成可處理的部分。`);return}let a=await t.executeTool(r.tool,r.input??{});if(a.ok){let t=a.kind===`query`?a.data:a.snapshot;e(`assistant`,`⚙ ${r.tool}`),n=`工具 ${r.tool} 已執行。最新流程:${JSON.stringify(t)}\n請決定下一步。`}else n=`工具 ${r.tool} 失敗:${a.error}\n請改用其他方式或回覆使用者。`}e(`assistant`,`已達到單次操作步數上限,請告訴我下一步。`)}finally{i.destroy()}}function se(e){try{let t=JSON.parse(e);return typeof t==`object`&&t&&t.action!==void 0?t:null}catch{return null}}function C(e){return e instanceof Error?`離線模式發生錯誤:${e.message}`:`離線模式發生未知錯誤。`}var ce={display:`flex`,flexDirection:`column`,gap:12,height:`100%`},le={display:`flex`,flex:1,flexDirection:`column`,gap:12,minHeight:0,overflowY:`auto`},ue={display:`flex`,gap:8,paddingBottom:4},de={borderTop:`1px solid var(--mzn-color-border-neutral, #e5e7eb)`,display:`flex`,flexDirection:`column`,gap:8,paddingTop:12},fe={display:`flex`,justifyContent:`flex-end`},pe={width:`100%`},me=`workflow-chat-input-field`,he=`
|
|
12
|
+
.${me}.mzn-text-field {
|
|
13
|
+
width: 100%;
|
|
14
|
+
}
|
|
15
|
+
`,ge={color:`var(--mzn-color-text-secondary, #6b7280)`,fontSize:12,padding:`2px 0`},_e={"input-available":`執行中…`,"input-streaming":`準備中…`,"output-available":`完成`,"output-error":`失敗`};function ve(e){let t=e===`user`;return{alignSelf:t?`flex-end`:`flex-start`,background:t?`var(--mzn-color-primary, #2563eb)`:`var(--mzn-color-surface, #f3f4f6)`,borderRadius:10,color:t?`#fff`:`var(--mzn-color-text-primary, #111827)`,maxWidth:`85%`,padding:`8px 12px`,whiteSpace:`pre-wrap`,wordBreak:`break-word`}}function ye({api:e,controller:t,onClose:n,open:r}){let i=te({api:e,controller:t}),a=oe({controller:t}),[u,d]=(0,o.useState)(`online`),[f,p]=(0,o.useState)(``),m=u===`offline`?{messages:a.messages,send:a.send,status:a.status}:{messages:i.messages,send:e=>{i.sendMessage({text:e})},status:i.status},{messages:h,send:g}=m,_=m.status===`submitted`||m.status===`streaming`,v=(0,o.useCallback)(()=>{let e=f.trim();!e||_||(p(``),g(e))},[_,f,g]),y=(0,o.useCallback)(e=>{e.nativeEvent.isComposing||e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),v())},[v]);return(0,c.jsxs)(l.default,{headerTitle:`AI 流程助理`,isHeaderDisplay:!0,onClose:n,open:r,size:`medium`,children:[(0,c.jsx)(`style`,{children:he}),(0,c.jsxs)(`div`,{style:ce,children:[a.available?(0,c.jsxs)(`div`,{style:ue,children:[(0,c.jsx)(s.Button,{onClick:()=>d(`online`),variant:u===`online`?`base-primary`:`base-tertiary`,children:`線上`}),(0,c.jsx)(s.Button,{onClick:()=>d(`offline`),variant:u===`offline`?`base-primary`:`base-tertiary`,children:`離線(裝置內,實驗)`})]}):null,(0,c.jsxs)(`div`,{role:`log`,style:le,children:[h.length===0?(0,c.jsx)(s.Typography,{color:`text-neutral`,variant:`body`,children:`用一句話描述你想要的流程,例如:「建立三關簽核:部門主管 → 經理 → 財務,金額大於十萬走財務複核」。我會直接在畫布上幫你繪製。`}):null,h.map(e=>(0,c.jsx)(o.Fragment,{children:be(e)},e.id)),_?(0,c.jsx)(s.Typography,{color:`text-neutral`,variant:`body`,children:`思考中…`}):null]}),(0,c.jsxs)(`div`,{style:de,children:[(0,c.jsx)(s.Textarea,{className:me,disabled:_,maxLength:2e3,onChange:e=>p(e.target.value),onKeyDown:y,placeholder:`描述你想要的流程…(Enter 送出,Shift + Enter 換行)`,rows:3,style:pe,value:f}),(0,c.jsx)(`div`,{style:fe,children:(0,c.jsx)(s.Button,{disabled:_||f.trim().length===0,loading:_,onClick:v,type:`button`,variant:`base-primary`,children:`送出`})})]})]})]})}function be(e){return e.parts.map((t,n)=>t.type===`text`?(0,c.jsx)(`div`,{style:ve(e.role),children:t.text},`${e.id}-${n}`):t.type===`dynamic-tool`||(0,f.isToolUIPart)(t)?(0,c.jsx)(`div`,{style:ge,children:`⚙ ${(0,f.getToolName)(t)} · ${_e[t.state]??t.state}`},`${e.id}-${n}`):null)}var xe={display:`grid`,gap:16},Se={alignItems:`start`,display:`grid`,gap:16,gridTemplateColumns:`minmax(0, 1fr) 420px`},Ce={border:`1px solid var(--mzn-color-border-neutral)`,borderRadius:6,height:620,minWidth:0,overflow:`hidden`},we={alignItems:`center`,boxSizing:`border-box`,color:`var(--mzn-color-text-error)`,display:`flex`,height:26,justifyContent:`center`,lineHeight:0,padding:0,width:26},Te={alignItems:`center`,display:`flex`,height:`100%`,justifyContent:`center`,width:`100%`},Ee=`workflow-designer-side-panel`,w=96,De=`
|
|
16
|
+
.${Ee} .mzn-form-field--stretch .mzn-form-field__label-area,
|
|
17
|
+
.${Ee} .mzn-form-field--horizontal .mzn-form-field__label-area {
|
|
18
|
+
flex: 0 0 ${w}px;
|
|
19
|
+
width: ${w}px;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.${Ee} .mzn-form-field--stretch .mzn-form-field__data-entry,
|
|
23
|
+
.${Ee} .mzn-form-field--horizontal .mzn-form-field__data-entry {
|
|
24
|
+
min-width: 0;
|
|
25
|
+
}
|
|
26
|
+
`,T=`#2563eb`,E=`#64748b`,Oe=`var(--mzn-color-text-error, #dc2626)`,D=`drop-shadow(0 0 3px rgba(0, 87, 255, 0.85)) drop-shadow(0 0 9px rgba(0, 87, 255, 0.36))`,ke=`
|
|
27
|
+
.workflow-selection-delete-control.react-flow__controls-button {
|
|
28
|
+
align-items: center !important;
|
|
29
|
+
display: flex !important;
|
|
30
|
+
height: 26px !important;
|
|
31
|
+
justify-content: center !important;
|
|
32
|
+
padding: 0 !important;
|
|
33
|
+
width: 26px !important;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.workflow-selection-delete-control .mzn-icon {
|
|
37
|
+
align-items: center;
|
|
38
|
+
display: flex;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.workflow-selection-delete-control .mzn-icon svg {
|
|
43
|
+
height: 16px !important;
|
|
44
|
+
max-height: none !important;
|
|
45
|
+
max-width: none !important;
|
|
46
|
+
width: 16px !important;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.workflow-edge--selected .react-flow__edge-path,
|
|
50
|
+
.react-flow__edge-path.workflow-edge--selected {
|
|
51
|
+
filter: ${D};
|
|
52
|
+
opacity: 1 !important;
|
|
53
|
+
stroke: ${E} !important;
|
|
54
|
+
stroke-opacity: 1 !important;
|
|
55
|
+
stroke-width: 1.5px !important;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.workflow-edge--selected {
|
|
59
|
+
--xy-edge-stroke: ${E};
|
|
60
|
+
--xy-edge-stroke-selected: ${E};
|
|
61
|
+
--xy-edge-stroke-width: 1.5px;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
`,Ae={display:`grid`,gap:12},O={display:`grid`,gap:12},je={border:`1px solid var(--mzn-color-border-neutral)`,borderRadius:6,display:`grid`,gap:8,maxHeight:360,overflow:`auto`,padding:12},Me={borderBottom:`1px solid var(--mzn-color-border-neutral)`,display:`grid`,gap:4,padding:`0 0 8px`},Ne={display:`flex`,flexWrap:`wrap`,gap:8},Pe={alignItems:`center`,display:`flex`,gap:8},Fe={flex:`1 1 auto`,minWidth:0},Ie={flex:`0 0 auto`},Le={display:`grid`,gap:8},k={alignContent:`center`,background:`var(--mzn-color-bg-surface)`,border:`1px solid var(--mzn-color-border-neutral)`,borderRadius:6,boxShadow:`0 8px 20px rgba(15, 23, 42, 0.08)`,boxSizing:`border-box`,display:`grid`,gap:4,height:`100%`,minWidth:132,overflow:`visible`,padding:`10px 12px`,textAlign:`center`,width:`100%`},A=`0 8px 20px rgba(15, 23, 42, 0.08), 0 0 0 1px var(--mzn-color-primary, #0057ff), 0 0 10px rgba(0, 87, 255, 0.3)`,Re=64,ze=160,Be=20,Ve=64,He=180,j={...k,display:`grid`,gap:8,padding:`10px 12px`},Ue={...j,background:`#eff6ff`,border:`1px solid #2563eb`},We={...j,background:`#f0fdfa`,border:`1px solid #0f766e`},M={...k,background:`#ffffff`},Ge={...k,background:`#ecfdf3`,border:`1px solid #2f855a`},N={...k,background:`#fff4ed`,border:`1px solid #c2410c`},Ke={display:`block`,maxWidth:`100%`,minWidth:0},qe={display:`grid`,gap:2,minWidth:0},P=`input`,F=`output`,Je={endEvent:`結束`,exclusiveGateway:`條件分流`,parallelGateway:`並行處理`,serviceTask:`系統`,startEvent:`開始`,userTask:`簽核`},Ye=[{icon:d.UserIcon,label:`簽核節點`,type:`userTask`},{icon:d.MailIcon,label:`知會節點`,type:`serviceTask`}],Xe=[{icon:d.FilterIcon,label:`條件分流`,type:`exclusiveGateway`}],Ze=[{id:`AND`,name:`全部前置完成`},{id:`OR`,name:`任一前置完成`}],Qe=[{id:`RESTART`,name:`重新送出後從開始重跑`},{id:`FROM_RETURN_POINT`,name:`重新送出後回到退回節點`}],$e=[{id:`NONE`,name:`不提醒`,value:null},{id:`0.5`,name:`過半時提醒`,value:.5},{id:`0.75`,name:`剩四分之一時提醒`,value:.75},{id:`0.9`,name:`剩十分之一時提醒`,value:.9}],et=[{id:`DIRECT`,name:`指定會員`},{id:`ORG_MANAGER`,name:`發起人主管`},{id:`ORG_UNIT_MANAGER`,name:`指定組織主管`},{id:`ORG_UNIT_MEMBER`,name:`組織任一人`},{id:`ORG_UNIT_POSITION`,name:`組織特定職位`},{id:`POSITION`,name:`指定職位`}],tt=[{id:`SINGLE`,name:`單人簽核`},{id:`PARALLEL_ANY`,name:`任一人同意`},{id:`PARALLEL_ALL`,name:`全部同意`},{id:`QUORUM`,name:`達到指定門檻`}],nt=[{id:`COUNT`,name:`人數`},{id:`PERCENTAGE`,name:`百分比`}],I=[{id:`1`,name:`直屬主管`,value:1},{id:`2`,name:`第二層主管`,value:2},{id:`3`,name:`第三層主管`,value:3}],rt=[{id:`NONE`,name:`停止流程並提示`},{id:`DIRECT`,name:`固定改派`}],it=[{id:`EQUALS`,name:`等於`},{id:`NOT_EQUALS`,name:`不等於`},{id:`GREATER_THAN`,name:`大於`},{id:`GREATER_THAN_OR_EQUALS`,name:`大於等於`},{id:`LESS_THAN`,name:`小於`},{id:`LESS_THAN_OR_EQUALS`,name:`小於等於`},{id:`IS_FILLED`,name:`已填寫`},{id:`IS_EMPTY`,name:`未填寫`}],at=[`EQUALS`,`GREATER_THAN`,`GREATER_THAN_OR_EQUALS`,`LESS_THAN`,`LESS_THAN_OR_EQUALS`,`NOT_EQUALS`],ot=[{id:`NONE`,name:`未設定`},{id:`ALL`,name:`所有人`},{id:`ORG_UNIT`,name:`指定組織`},{id:`ORG_UNIT_POSITION`,name:`指定組織職位`}],st={id:`CUSTOM`,name:`既有自訂規則`},ct=`member-001`,lt={display:`flex`,flexDirection:`column`,height:`100%`},ut={flex:1,minHeight:0,overflowY:`auto`},dt={borderTop:`1px solid var(--mzn-color-border-neutral)`,display:`flex`,gap:8,paddingTop:12},ft={fields:[],schemaVersion:1},pt={layout:[],schemaVersion:1},mt={endEvent:R,exclusiveGateway:R,parallelGateway:R,serviceTask:R,startEvent:R,userTask:R};function L(e,t){return typeof e==`function`?e(t):e}function ht({aiAssistantAvailable:e=!0,embedded:f=!1,formSchemaOverride:p,initialInitiatorPolicyCel:h,initialWorkflowDefinition:v,onInitiatorPolicyChange:ee,onWorkflowChange:te,showAiAssistant:ne=!1,showDryRun:re=!0,templateId:ie}){let ae=t.r(),oe=n.r(),[S,se]=(0,o.useState)(null),[C,ce]=(0,o.useState)(null),[le,ue]=(0,o.useState)(``),[de,fe]=(0,o.useState)(null),[pe,me]=(0,o.useState)(null),he=(0,o.useRef)(null),[ge,_e]=(0,o.useState)(void 0),ve=(0,o.useRef)([]),be=(0,o.useRef)([]),w=x({directory:(0,o.useMemo)(()=>({listOrgUnits:async()=>ve.current.map(e=>({id:e.id,name:e.name})),listPositions:async()=>be.current.map(e=>({id:e.id,name:e.name})),searchMembers:async e=>wn(await(0,y.searchMemberOptions)(e)).map(e=>({email:e.email,id:e.memberId,name:e.name}))}),[]),initialState:{definition:f&&v!=null?Et(v):kt(),editingEdgeId:null,formDefinitionVersionId:null,formSchema:null,initiatorPolicyCel:f&&h!==void 0?h:null,selectedEdgeIds:[],selectedNodeId:f&&v!=null?v.nodes[0]?.id??`start`:`start`},layout:jt,onLayout:e=>{let t=Un(e,he.current);t&&_e(t)}}),T=w.state.definition,E=w.state.formDefinitionVersionId,D=w.state.initiatorPolicyCel,k=w.state.selectedNodeId,A=w.state.selectedEdgeIds,Re=w.state.editingEdgeId,ze=e=>w.replaceState(t=>({...t,definition:L(e,t.definition)})),Be=e=>w.replaceState(t=>({...t,formDefinitionVersionId:L(e,t.formDefinitionVersionId)})),Ve=e=>w.replaceState(t=>({...t,initiatorPolicyCel:L(e,t.initiatorPolicyCel)})),He=e=>w.replaceState(t=>({...t,selectedNodeId:L(e,t.selectedNodeId)})),j=e=>w.replaceState(t=>({...t,selectedEdgeIds:L(e,t.selectedEdgeIds)})),Ue=e=>w.replaceState(t=>({...t,editingEdgeId:L(e,t.editingEdgeId)})),[We,M]=(0,o.useState)(null),[Ge,N]=(0,o.useState)(null);(0,o.useEffect)(()=>{N(null)},[k]);let[Ke,qe]=(0,o.useState)(!0),[P,F]=(0,o.useState)(!1),[it,at]=(0,o.useState)(!1),[ht,R]=(0,o.useState)([]),_t=(0,o.useMemo)(()=>JSON.stringify({formDefinitionVersionId:E,initiatorPolicyCel:D,workflowDefinition:T}),[E,D,T]),z=!!le&&_t!==le,[vt,yt]=(0,o.useState)(!1),[B,xt]=(0,o.useState)([]),[St,Ct]=(0,o.useState)([]),Tt=(0,o.useRef)(0),[V,Dt]=(0,o.useState)([]),[H,Ot]=(0,o.useState)([]),[Jt,nn]=(0,o.useState)([]);ve.current=V,be.current=H;let[on,cn]=(0,o.useState)(!1),[pn,mn]=(0,o.useState)(!1),[hn,yn]=(0,o.useState)(`{}`),[W,G]=(0,o.useState)(null),[kn,jn]=(0,o.useState)(null),[Mn,Nn]=(0,o.useState)(!1),[Pn,K]=(0,o.useState)(!1),[q,Rn]=(0,o.useState)(null),[zn,Bn]=(0,o.useState)(!1),[Vn,Hn]=(0,o.useState)(!1),Gn=z||zn?`保存並發布`:C?`發布草稿`:`已發布`;(0,o.useEffect)(()=>{f?_r():vr()},[f,ie]),(0,o.useEffect)(()=>{function e(e){z&&(e.preventDefault(),e.returnValue=``)}return window.addEventListener(`beforeunload`,e),()=>{window.removeEventListener(`beforeunload`,e)}},[z]),(0,o.useEffect)(()=>{xr(T)},[T,B]),(0,o.useEffect)(()=>{ze(e=>Et(e))},[T.edges,T.nodes]);function Zn(){z&&!window.confirm(`目前有尚未儲存的流程草稿,確定要離開嗎?`)||ae.push(oe.templates())}let J=(0,o.useMemo)(()=>T.nodes.find(e=>e.id===k)??null,[k,T.nodes]),nr=J?fn(J):!1,ir=A.length>0||nr,ar=(0,o.useCallback)(()=>{w.getState().selectedEdgeIds.forEach(e=>w.dispatch({edgeId:e,type:`deleteEdge`})),J&&fn(J)&&w.dispatch({nodeId:J.id,type:`deleteNode`})},[w,J]);(0,o.useEffect)(()=>{if(!ir)return;function e(e){e.key!==`Delete`&&e.key!==`Backspace`||gn(e.target)||(e.preventDefault(),ar())}return window.addEventListener(`keydown`,e),()=>{window.removeEventListener(`keydown`,e)}},[ir,ar]);let or=(0,o.useMemo)(()=>T.edges.find(e=>e.id===Re)??null,[Re,T.edges]),sr=(0,o.useMemo)(()=>A.length===1?T.edges.find(e=>e.id===A[0])??null:null,[A,T.edges]),cr=(0,o.useMemo)(()=>A.map(e=>T.edges.find(t=>t.id===e)??null).filter(e=>!!e),[A,T.edges]),X=(0,o.useMemo)(()=>pe??rn(D,de),[D,pe,de]),lr=(0,o.useMemo)(()=>T.nodes.map(e=>bt(e,B,V,H,e.id===k,X)),[X,B,V,H,k,T.nodes]),ur=(0,o.useMemo)(()=>T.edges.map(e=>wt(e,T.nodes,A.includes(e.id))),[A,T.edges,T.nodes]),Z=(0,o.useMemo)(()=>U(ht,E)??U(_n(S?.formVersions??[]),E),[E,ht,S?.formVersions]),dr=(0,o.useMemo)(()=>Cn(ht,Z),[ht,Z]),fr=Z?.schema??null,pr=f?p??null:fr;(0,o.useEffect)(()=>{w.getState().formSchema!==pr&&w.replaceState(e=>({...e,formSchema:pr}))},[w,pr]);let mr=(0,o.useMemo)(()=>Wn(T),[T]),hr=(0,o.useMemo)(()=>Kn(T),[T]),gr=(0,o.useMemo)(()=>an(X),[X]);(0,o.useEffect)(()=>{f&&te?.(T)},[f,T]),(0,o.useEffect)(()=>{f&&ee?.(D)},[f,D]);async function _r(){qe(!0),M(null);try{let e=await(0,g.readOrganizationDashboard)();Dt(e.orgUnits),Ot(e.positions),nn(e.memberships)}catch(e){M(Y(e))}finally{qe(!1)}}async function vr(){qe(!0),M(null),N(null);try{let[e,t]=await Promise.all([(0,y.readTemplateDesigner)(ie),(0,g.readOrganizationDashboard)()]),n=e.versions.find(e=>e.status===`DRAFT`)??null,r=n??e.versions[0]??null;se(e),ce(n),Dt(t.orgUnits),Ot(t.positions),nn(t.memberships),R(_n(e.formVersions));let i=Et(r?.workflowDefinition??kt()),a=r?.formDefinitionVersionId??e.formVersions[0]?.id??null,o=r?.initiatorPolicyCel??null;ze(i),Be(a),Ve(o),ue(JSON.stringify({formDefinitionVersionId:a,initiatorPolicyCel:o,workflowDefinition:i})),fe(r&&!e.template.currentVersionId&&!r.initiatorPolicyCel&&At(r.workflowDefinition)?`NONE`:null),me(null),He(r?.workflowDefinition.nodes[0]?.id??`start`),j([]),Ue(null),Rn(null),Bn(!1)}catch(e){M(Y(e))}finally{qe(!1)}}async function yr(e){at(!0),M(null);try{R(Cn(_n(await(0,y.searchPublishedFormVersionOptions)(e)),Z))}catch(e){M(Y(e))}finally{at(!1)}}async function br(e){yt(!0),M(null);let t=++Tt.current;try{let n=wn(await(0,y.searchMemberOptions)(e));xt(e=>In(e,n)),t===Tt.current&&Ct(n)}catch(e){t===Tt.current&&M(Y(e))}finally{t===Tt.current&&yt(!1)}}async function xr(e){let t=Ln(e).filter(e=>!B.some(t=>t.memberId===e&&!t.unresolved));if(t.length!==0)try{let e=await(0,y.resolveMemberOptions)(t);xt(t=>In(t,wn(e)))}catch{xt(e=>In(e,t.map(Tn)))}}async function Sr(e){F(!0),M(null);try{let t=Wn(T),n=an(X);if(t||n){let e=t??n??`流程設定未完成`;throw M(e),Error(e)}if(zn&&q!==null)await(0,y.composeApprovalTemplateWithForm)({category:S?.template.category??null,categoryId:S?.template.categoryId??null,formDefinitionId:Z?.formDefinitionId??null,formDescription:null,formName:Z?.formName??S?.template.name??`表單`,initiatorPolicyCel:D,notificationConfig:null,publish:e,schema:q.schema,slaDefaults:null,templateDescription:null,templateId:ie??null,templateName:S?.template.name??`模板`,uiSchema:q.uiSchema,workflowDefinition:T}),Bn(!1),Rn(null),await vr();else{let t=await(0,y.updateApprovalTemplateDraft)({formDefinitionVersionId:E,initiatorPolicyCel:D,versionId:(C??await(0,y.forkApprovalTemplate)(ie)).id,workflowDefinition:T});ce(t),e&&await(0,y.publishApprovalTemplateVersion)(t.id),await vr()}}catch(e){throw M(Y(e)),e}finally{F(!1)}}async function Cr(){await Sr(!1)}async function wr(){await Sr(!0)}function Tr(){yn(JSON.stringify(vn(Z),null,2)),G(null),jn(null),cn(!0)}function Er(){pn||cn(!1)}async function Dr(){mn(!0),jn(null),G(null);try{G(await(0,y.dryRunApprovalWorkflow)({formData:bn(hn),initiatorMemberId:ct,initiatorMetadataSnapshot:An(ct,Jt),workflowDefinition:T}))}catch(e){jn(Y(e))}finally{mn(!1)}}async function Or(){if(K(!0),q!==null)return;let e=Z?.formDefinitionId??null;if(!e){Rn({schema:ft,uiSchema:pt});return}Hn(!0);try{let t=await(0,m.readFormBuilder)(e),n=t.versions.find(e=>e.status===`DRAFT`)??t.versions.find(e=>e.id===t.definition.currentVersionId)??t.versions[0]??null;Rn({schema:n?.schema??ft,uiSchema:n?.uiSchema??pt})}catch(e){M(Y(e))}finally{Hn(!1)}}function kr(e){let t=(0,_.applyNodeChanges)(e,lr);ze(e=>({...e,nodes:e.nodes.map(e=>{let n=t.find(t=>t.id===e.id);return n?{...e,position:n.position}:e})}))}function Ar(e){!un(e,T.nodes)||!e.source||!e.target||w.dispatch({source:e.source,target:e.target,type:`connectEdge`})}function jr(e,t){e.stopPropagation(),j(n=>e.shiftKey||e.metaKey||e.ctrlKey?dn(n,t.id):[t.id]),He(null)}function Mr(){Ue(null)}function Nr(e){w.dispatch({nodeType:e,type:`addNode`})}function Pr(e){J&&w.dispatch({label:e,nodeId:J.id,type:`renameNode`})}function Q(e){if(!J||J.type!==`userTask`)return;let t=J.id,n=J.data.decisionPolicy;w.dispatch({approverResolver:e,nodeId:t,type:`setUserTaskApprover`}),N(null),(0,b.isDecisionPolicyUnsatisfiable)(n,e)&&N({message:`簽核者已變更為 ${(0,b.readDesignTimeApproverCount)(e)} 位,不足原本設定的 ${n?.type===`QUORUM`?n.threshold:0} 位門檻,簽核政策已重設為單人簽核,請重新設定。`,nodeId:t})}function Fr(e){!J||J.type!==`userTask`||w.dispatch({nodeId:J.id,resubmitStrategy:e,type:`setUserTaskReturnResubmitStrategy`})}function Ir(e){!J||J.type!==`userTask`||w.dispatch({nodeId:J.id,requireComment:e,type:`setUserTaskReturnRequireComment`})}function $(e){!J||J.type!==`userTask`||w.dispatch({nodeId:J.id,sla:e,type:`setUserTaskSla`})}function Lr(e){if(!J||J.type!==`userTask`)return;N(null);let t=e.type===`QUORUM`?{...e,threshold:(0,b.composeQuorumThreshold)(e.threshold,e.thresholdType)}:e;w.dispatch({decisionPolicy:t,nodeId:J.id,type:`setUserTaskDecisionPolicy`})}function Rr(e){!J||J.type!==`userTask`||w.dispatch({...e,nodeId:J.id,type:`setUserTaskOptions`})}function zr(e){!J||J.type!==`serviceTask`||w.dispatch({action:e,nodeId:J.id,type:`setServiceAction`})}function Br(e){me(e.mode===`ALL`||e.mode===`CUSTOM`?null:e),fe(e.mode===`ALL`||e.mode===`CUSTOM`?null:e.mode),Ve(sn(e,V))}function Vr(e){!J||J.type===`startEvent`||w.dispatch({nodeId:J.id,triggerMode:e,type:`setNodeTriggerMode`})}function Hr(e,t){w.dispatch({edgeId:e,isDefault:t,type:`setEdgeDefault`})}function Ur({edgeId:e,fieldKey:t,operator:n,value:r}){w.dispatch({edgeId:e,fieldKey:t,operator:n,type:`setEdgeCondition`,value:r})}function Wr(){w.dispatch({type:`autoLayout`})}return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(`style`,{children:De}),f?null:(0,c.jsx)(s.PageHeader,{children:(0,c.jsxs)(u.default,{description:`${C?`草稿 v${C.version}`:`尚未建立草稿`} ·${S?.template.currentVersionId?` 已發布版本`:` 尚未發布`}`,onBackClick:Zn,title:S?.template.name??`流程設計器`,children:[ne?(0,c.jsx)(s.Button,{disabled:!e,onClick:()=>Nn(e=>!e),variant:Mn?`base-primary`:`base-secondary`,children:e?`AI 助理`:`AI 助理(未設定)`}):null,(0,c.jsx)(s.Button,{"aria-label":`儲存草稿`,disabled:P||!!mr||!!gr,icon:d.SaveIcon,iconType:`icon-only`,onClick:()=>void Cr(),variant:`base-secondary`,children:`儲存草稿`}),re?(0,c.jsx)(s.Button,{disabled:Ke||!!mr||!!gr,icon:d.EyeIcon,iconType:`leading`,onClick:Tr,variant:`base-secondary`,children:`試跑流程`}):null,(0,c.jsx)(s.Button,{disabled:P||!C&&!z&&!zn||!!mr||!!gr,icon:d.CheckedIcon,iconType:`leading`,onClick:()=>void wr(),variant:`base-primary`,children:Gn})]})}),(0,c.jsx)(s.SectionGroup,{children:(0,c.jsx)(s.Section,{children:(0,c.jsxs)(`div`,{style:xe,children:[We?(0,c.jsx)(s.Typography,{color:`text-error`,variant:`body`,children:We}):null,Ge&&Ge.nodeId===J?.id&&J.type===`userTask`&&(J.data.decisionPolicy?.type??`SINGLE`)===`SINGLE`?(0,c.jsx)(s.Typography,{color:`text-warning`,variant:`body`,children:Ge.message}):null,mr?(0,c.jsx)(s.Typography,{color:`text-error`,variant:`body`,children:mr}):null,gr?(0,c.jsx)(s.Typography,{color:`text-error`,variant:`body`,children:gr}):null,f?null:(0,c.jsx)(`div`,{style:O,children:(0,c.jsx)(r.t,{hintText:hr?`已設定條件分流條件。請先移除所有條件,才能更換綁定表單版本。`:void 0,label:`綁定表單版本`,name:`formDefinitionVersionId`,required:!0,children:(0,c.jsxs)(`div`,{style:Pe,children:[(0,c.jsx)(`div`,{style:Fe,children:(0,c.jsx)(s.AutoComplete,{asyncData:!0,disabled:Ke||hr,disabledOptionsFilter:!0,emptyText:`沒有符合的已發布表單版本`,isForceClearable:!!E&&!hr,loading:it,loadingText:`搜尋表單版本中...`,mode:`single`,onChange:e=>{hr||Be(e?.id??null)},onClear:()=>{hr||Be(null)},onSearch:yr,onVisibilityChange:e=>{e&&!hr&&yr(``)},options:[...dr],placeholder:`選擇已發布表單版本`,searchDebounceTime:300,value:Z})}),(0,c.jsx)(s.Button,{disabled:Ke,onClick:()=>{Or()},style:Ie,variant:`base-secondary`,children:`編輯表單`})]})})}),(0,c.jsxs)(`div`,{style:Se,children:[(0,c.jsx)(`div`,{ref:he,style:Ce,children:(0,c.jsxs)(_.ReactFlow,{connectionMode:_.ConnectionMode.Strict,edges:ur,fitView:!0,isValidConnection:e=>un(e,T.nodes),nodeTypes:mt,nodes:lr,deleteKeyCode:null,multiSelectionKeyCode:[`Shift`,`Meta`,`Control`],onConnect:Ar,onEdgeClick:jr,onNodeClick:(e,t)=>{He(t.id),j([])},onNodesChange:kr,onPaneClick:()=>{He(null),j([])},onViewportChange:_e,viewport:ge,children:[(0,c.jsx)(_.Background,{}),(0,c.jsx)(`style`,{children:ke}),(0,c.jsx)(_.Controls,{children:ir?(0,c.jsx)(_.ControlButton,{"aria-label":`刪除選取項目`,className:`workflow-selection-delete-control`,onClick:ar,style:we,title:`刪除選取項目`,children:(0,c.jsx)(`span`,{style:Te,children:(0,c.jsx)(s.Icon,{color:`error`,icon:d.TrashIcon,size:16})})}):null}),(0,c.jsx)(gt,{onApplyAutoLayout:Wr}),(0,c.jsx)(_.MiniMap,{})]})}),(0,c.jsxs)(`div`,{className:Ee,style:Ae,children:[(0,c.jsx)(s.Typography,{component:`h2`,variant:`h3`,children:`流程工具`}),f&&ne?(0,c.jsxs)(`div`,{style:Le,children:[(0,c.jsx)(s.Typography,{color:`text-neutral`,variant:`caption`,children:`AI 協助`}),(0,c.jsx)(`div`,{style:Ne,children:(0,c.jsx)(s.Button,{disabled:!e,onClick:()=>Nn(e=>!e),size:`sub`,variant:Mn?`base-primary`:`base-secondary`,children:e?`AI 助理`:`AI 助理(未設定)`})})]}):null,(0,c.jsxs)(`div`,{style:Le,children:[(0,c.jsx)(s.Typography,{color:`text-neutral`,variant:`caption`,children:`動作節點`}),(0,c.jsx)(`div`,{style:Ne,children:Ye.map(e=>(0,c.jsx)(s.Button,{icon:e.icon,iconType:`leading`,onClick:()=>Nr(e.type),size:`sub`,variant:`base-secondary`,children:e.label},e.type))})]}),(0,c.jsxs)(`div`,{style:Le,children:[(0,c.jsx)(s.Typography,{color:`text-neutral`,variant:`caption`,children:`流程控制`}),(0,c.jsx)(`div`,{style:Ne,children:Xe.map(e=>(0,c.jsx)(s.Button,{icon:e.icon,iconType:`leading`,onClick:()=>Nr(e.type),size:`sub`,variant:`base-secondary`,children:e.label},e.type))})]}),cr.length>1?Zr(cr):null,cr.length===1&&sr?Qr(sr):null,cr.length===0&&J?Kr(J):null]})]})]})})}),$r(or),!f&&re?Gr():null,ne&&e?(0,c.jsx)(ye,{controller:w,onClose:()=>Nn(!1),open:Mn}):null,f?null:(0,c.jsx)(l.default,{headerTitle:`編輯表單`,isHeaderDisplay:!0,onClose:()=>K(!1),open:Pn,size:`wide`,children:(0,c.jsxs)(`div`,{style:lt,children:[(0,c.jsx)(`div`,{style:ut,children:Vn?(0,c.jsx)(s.Typography,{color:`text-neutral`,variant:`body`,children:`載入中…`}):(0,c.jsx)(a.t,{onChange:e=>{Rn(e)},value:q??{schema:ft,uiSchema:pt}})}),(0,c.jsxs)(`div`,{style:dt,children:[(0,c.jsx)(s.Button,{disabled:Vn,onClick:()=>{q!==null&&(Bn(!0),w.replaceState(e=>({...e,formSchema:q.schema}))),K(!1)},variant:`base-primary`,children:`套用`}),(0,c.jsx)(s.Button,{onClick:()=>K(!1),variant:`base-secondary`,children:`取消`})]})]})})]});function Gr(){return(0,c.jsx)(s.Modal,{cancelText:`關閉`,confirmText:`執行試跑`,loading:pn,modalType:`standard`,onCancel:Er,onClose:Er,onConfirm:()=>void Dr(),open:on,showModalFooter:!0,showModalHeader:!0,size:`wide`,supportingText:`使用 ${ct} 與範例表單資料模擬目前畫布流程,不會建立案件。`,title:`試跑流程`,children:(0,c.jsxs)(`div`,{style:O,children:[(0,c.jsx)(r.t,{label:`表單資料 JSON`,name:`dryRunFormDataJson`,required:!0,children:(0,c.jsx)(s.Textarea,{onChange:e=>yn(e.target.value),resize:`vertical`,rows:8,value:hn})}),kn?(0,c.jsx)(s.Typography,{color:`text-error`,variant:`body`,children:kn}):null,W?(0,c.jsxs)(`div`,{style:je,children:[(0,c.jsx)(s.Typography,{color:W.valid?`text-success`:`text-error`,variant:`label-primary-highlight`,children:W.valid?`試跑通過`:`試跑失敗`}),W.errors.map(e=>(0,c.jsx)(s.Typography,{color:`text-error`,variant:`body`,children:e},e)),W.steps.map(e=>(0,c.jsxs)(`div`,{style:Me,children:[(0,c.jsxs)(s.Typography,{variant:`label-primary-highlight`,children:[e.nodeLabel,` · `,xn(e.status)]}),(0,c.jsxs)(s.Typography,{color:`text-neutral`,variant:`caption`,children:[Sn(e.nodeType),e.assigneeMemberId?` · 處理者:${e.assigneeMemberId}`:``,e.edgeLabel?` · 來源線段:${e.edgeLabel}`:``]}),e.edgeReason?(0,c.jsx)(s.Typography,{color:`text-neutral`,variant:`caption`,children:e.edgeReason}):null,e.entryCondition?(0,c.jsxs)(s.Typography,{color:`text-neutral`,variant:`caption`,children:[`進入條件:`,e.entryConditionMatched?`符合`:`不符合`,` ·`,` `,e.entryCondition]}):null,(0,c.jsx)(s.Typography,{color:`text-neutral`,variant:`body`,children:e.message})]},e.id))]}):null]})})}function Kr(e){return(0,c.jsxs)(`div`,{style:O,children:[(0,c.jsx)(s.Typography,{component:`h2`,variant:`h3`,children:`節點屬性`}),(0,c.jsxs)(s.Typography,{color:`text-neutral`,variant:`body`,children:[Je[e.type],` · `,e.id]}),(0,c.jsx)(r.t,{label:`顯示名稱`,name:`nodeLabel`,required:!0,children:(0,c.jsx)(s.Input,{onChange:e=>Pr(e.target.value),value:e.data.label,variant:`base`})}),e.type===`startEvent`?qr():null,e.type===`startEvent`?null:Jr(e),e.type===`userTask`?Yr(e):null,e.type===`serviceTask`?Xr(e):null]})}function qr(){let e=X.mode===`CUSTOM`?[...ot,st]:[...ot],t=X.mode===`ORG_UNIT`||X.mode===`ORG_UNIT_POSITION`?Dn(V,X.orgUnitId??``):null,n=X.mode===`ORG_UNIT_POSITION`?On(H,X.positionId??``):null,a=X.mode===`ORG_UNIT_POSITION`?Fn({includeDescendants:!!X.includeDescendants,memberships:Jt,orgUnitId:X.orgUnitId??``,orgUnits:V,positions:H}):[];return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r.t,{hintText:X.mode===`CUSTOM`?`這是舊版表達式規則;切換成標準選項後會改由 UI 管理。`:void 0,label:`發起權限`,name:`initiatorPolicyMode`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>{if(e?.id===`CUSTOM`){fe(null),me(null);return}let t=tn(e?.id??null),n=ln(t);fe(t===`ALL`?null:t),me(t===`ALL`?null:n),Ve(sn(n,V))},options:e,placeholder:`選擇誰可以發起`,value:U(e,X.mode)})}),X.mode===`ORG_UNIT`||X.mode===`ORG_UNIT_POSITION`?(0,c.jsx)(r.t,{label:`組織`,name:`initiatorOrgUnitId`,required:!0,children:(0,c.jsx)(i.n,{name:`initiatorOrgUnitId`,onChange:e=>Br({...X,orgUnitId:e?.id??``,positionId:``,value:e?.id??``}),orgUnits:V,placeholder:`選擇組織`,value:t})}):null,X.mode===`ORG_UNIT`||X.mode===`ORG_UNIT_POSITION`?(0,c.jsx)(r.t,{label:`包含下層`,name:`initiatorIncludeDescendants`,children:(0,c.jsx)(s.Toggle,{checked:!!X.includeDescendants,onChange:e=>Br({...X,includeDescendants:e.target.checked,...X.mode===`ORG_UNIT_POSITION`?{positionId:``}:{}})})}):null,X.mode===`ORG_UNIT_POSITION`?(0,c.jsx)(r.t,{label:`職位`,name:`initiatorPositionId`,required:!0,children:(0,c.jsx)(i.r,{disabled:!X.orgUnitId?.trim(),name:`initiatorPositionId`,onChange:e=>Br({...X,positionId:e?.id??``}),placeholder:X.orgUnitId?.trim()?`選擇職位`:`請先選擇組織`,positions:a,value:n})}):null]})}function Jr(e){let t=T.edges.filter(t=>t.target===e.id).length,n=t<2,i=n?`AND`:e.data.triggerMode??`AND`;return(0,c.jsx)(r.t,{hintText:n?`需要至少兩條前置連線,才可切換為任一前置完成。`:t>1?`${t} 條前置連線會依此規則觸發。`:`只有一條前置連線時,兩種設定效果相同。`,label:`前置條件`,name:`triggerMode`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>n?void 0:Vr(Mt(e?.id??null)),options:[...Ze],readOnly:n,value:U(Ze,i)})})}function Yr(e){let t=e.data.approverResolver,n=Yt(t.type),a=t.type===`DIRECT`?t.memberIds.map(e=>En(B,e)):[],o=t.type===`ORG_UNIT_MANAGER`||t.type===`ORG_UNIT_MEMBER`||t.type===`ORG_UNIT_POSITION`?Dn(V,t.orgUnitId):null,l=t.type===`POSITION`||t.type===`ORG_UNIT_POSITION`?On(H,t.positionId):null,u=t.type===`ORG_UNIT_POSITION`?Fn({includeDescendants:!!t.includeDescendants,memberships:Jt,orgUnitId:t.orgUnitId,orgUnits:V,positions:H}):[],d=t.type===`ORG_MANAGER`?$t(t.levelsUp):I[0],f=t.type===`ORG_MANAGER`||t.type===`ORG_UNIT_MANAGER`?t.fallback??{type:`NONE`}:{type:`NONE`},p=f.type===`DIRECT`&&f.memberId?En(B,f.memberId):null,m=e.data.returnBehavior.resubmitStrategy??`RESTART`,h=e.data.sla??null,g=h?(0,b.readSlaDurationParts)(h.duration):null,_=g?.unit??`DAY`,v=Ut(h?.warningAt??null),y=$t(h?.escalateLevelsUp??1),ee=Ft(e.data.decisionPolicy),x=Rt(e.data.decisionPolicy);return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r.t,{label:`簽核來源`,name:`approverResolverType`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>Q(Xt(e?.id??null)),options:[...et],value:U(et,n)})}),t.type===`DIRECT`?(0,c.jsx)(r.t,{hintText:Pt(e.data.decisionPolicy),label:`簽核者`,name:`memberId`,required:!0,children:(0,c.jsx)(s.AutoComplete,{asyncData:!0,disabledOptionsFilter:!0,emptyText:`沒有符合的成員`,inputProps:{autoCapitalize:`none`,autoCorrect:`off`,name:`workflow-approver-search`,spellCheck:!1},loading:vt,loadingText:`搜尋成員中...`,mode:`multiple`,onChange:e=>Q({memberIds:e.map(e=>e.id),type:`DIRECT`}),onSearch:br,onVisibilityChange:e=>{e&&(Ct([]),br(``))},options:[...In(a,St)],placeholder:`搜尋姓名或信箱`,searchDebounceTime:300,value:a})}):null,t.type===`ORG_MANAGER`?(0,c.jsx)(r.t,{hintText:`依發起人的有效會員歸屬與主管解析規則決定簽核人。`,label:`主管層級`,name:`managerLevelsUp`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>Q({baseFromInitiator:!0,levelsUp:en(e?.id??null).value,type:`ORG_MANAGER`}),options:[...I],value:d})}):null,t.type===`ORG_UNIT_MANAGER`||t.type===`ORG_UNIT_MEMBER`||t.type===`ORG_UNIT_POSITION`?(0,c.jsx)(r.t,{hintText:t.type===`ORG_UNIT_MANAGER`?`依指定組織或其上層的主管解析規則決定簽核人。`:`依指定組織目前有效會員歸屬建立候選簽核人。`,label:`組織`,name:`orgUnitId`,required:!0,children:(0,c.jsx)(i.n,{name:`orgUnitId`,onChange:e=>Q(t.type===`ORG_UNIT_MEMBER`?{includeDescendants:t.includeDescendants,orgUnitId:e?.id??``,type:`ORG_UNIT_MEMBER`}:t.type===`ORG_UNIT_POSITION`?{includeDescendants:t.includeDescendants,orgUnitId:e?.id??``,positionId:``,type:`ORG_UNIT_POSITION`}:{fallback:t.fallback,orgUnitId:e?.id??``,type:`ORG_UNIT_MANAGER`}),orgUnits:V,placeholder:`選擇組織`,value:o})}):null,t.type===`ORG_MANAGER`||t.type===`ORG_UNIT_MANAGER`?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r.t,{hintText:`開啟後只取離該員最近一層的主管規則;掛在上層單位、涵蓋範圍較大的規則不會再一併加入簽核人。`,label:`只取最近一層主管`,name:`preferClosestOrgUnit`,children:(0,c.jsx)(s.Toggle,{checked:!!t.preferClosestOrgUnit,inputProps:{id:`preferClosestOrgUnit`,name:`preferClosestOrgUnit`},onChange:e=>Q({...t,preferClosestOrgUnit:e.target.checked})})}),(0,c.jsx)(r.t,{hintText:`預設會停止流程並提示;若設定固定人,找不到主管時會改派給該會員。`,label:`無主管時`,name:`approverFallbackMode`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>Q(Qt(t,Zt(e?.id??null)===`DIRECT`?{memberId:``,type:`DIRECT`}:{type:`NONE`})),options:[...rt],value:U(rt,f.type)})}),f.type===`DIRECT`?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r.t,{label:`改派人員`,name:`approverFallbackMemberId`,required:!0,children:(0,c.jsx)(s.AutoComplete,{asyncData:!0,disabledOptionsFilter:!0,emptyText:`沒有符合的成員`,inputProps:{autoCapitalize:`none`,autoCorrect:`off`,name:`workflow-approver-fallback-search`,spellCheck:!1},loading:vt,loadingText:`搜尋成員中...`,mode:`single`,onChange:e=>Q(Qt(t,{allowInitiatorSelfApproval:f.allowInitiatorSelfApproval,memberId:e?.id??``,type:`DIRECT`})),onSearch:br,onVisibilityChange:e=>{e&&(Ct([]),br(``))},options:[...In(St,p?[p]:[])],placeholder:`搜尋姓名或信箱`,searchDebounceTime:300,value:p})}),(0,c.jsx)(r.t,{hintText:`預設禁止申請人簽自己的案件;只有此流程允許自簽時才開啟。`,label:`允許自簽`,name:`allowInitiatorSelfApproval`,children:(0,c.jsx)(s.Toggle,{checked:!!f.allowInitiatorSelfApproval,inputProps:{id:`allowInitiatorSelfApproval`,name:`allowInitiatorSelfApproval`},onChange:e=>Q(Qt(t,{allowInitiatorSelfApproval:e.target.checked,memberId:f.memberId,type:`DIRECT`}))})})]}):null]}):null,t.type===`ORG_UNIT_MEMBER`||t.type===`ORG_UNIT_POSITION`?(0,c.jsx)(r.t,{label:`包含下層`,name:`includeDescendants`,children:(0,c.jsx)(s.Toggle,{checked:!!t.includeDescendants,inputProps:{id:`includeDescendants`,name:`includeDescendants`},onChange:e=>Q({...t,includeDescendants:e.target.checked,...t.type===`ORG_UNIT_POSITION`?{positionId:``}:{}})})}):null,t.type===`POSITION`?(0,c.jsx)(r.t,{hintText:`指派給目前有效歸屬中擁有此職位的會員;主要歸屬優先。`,label:`職位`,name:`positionId`,required:!0,children:(0,c.jsx)(i.r,{name:`positionId`,onChange:e=>Q({positionId:e?.id??``,type:`POSITION`}),placeholder:`選擇職位`,positions:H,value:l})}):null,t.type===`ORG_UNIT_POSITION`?(0,c.jsx)(r.t,{hintText:`只納入指定組織範圍內擁有此職位的有效會員。`,label:`職位`,name:`orgUnitPositionId`,required:!0,children:(0,c.jsx)(i.r,{disabled:!t.orgUnitId.trim(),name:`orgUnitPositionId`,onChange:e=>Q({includeDescendants:t.includeDescendants,orgUnitId:t.orgUnitId,positionId:e?.id??``,type:`ORG_UNIT_POSITION`}),placeholder:t.orgUnitId.trim()?`選擇職位`:`請先選擇組織`,positions:u,value:l})}):null,(0,c.jsx)(r.t,{hintText:`決定這一關要幾位簽核者同意才會通過;單人簽核與任一人同意的效果完全相同,皆為其中一人同意即通過。`,label:`決策方式`,name:`decisionPolicy`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:t=>Lr(Lt(t?.id??null,e.data.decisionPolicy)),options:[...tt],value:It(ee)})}),ee===`QUORUM`?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r.t,{label:`門檻計算方式`,name:`quorumThresholdType`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>Lr({threshold:x.threshold,thresholdType:zt(e?.id??null),type:`QUORUM`}),options:[...nt],value:U(nt,x.thresholdType)})}),(0,c.jsx)(r.t,{hintText:x.thresholdType===`PERCENTAGE`?`達到簽核者總數的這個百分比即通過,換算人數時無條件進位;超過 100 的輸入會自動夾至 100。`:`達到這個同意人數即通過;門檻超過實際簽核者人數時,這一關將永遠無法通過,請勿設定超過實際簽核者人數。`,label:x.thresholdType===`PERCENTAGE`?`門檻百分比`:`門檻人數`,name:`quorumThreshold`,required:!0,children:(0,c.jsx)(s.Input,{id:`quorumThreshold`,inputProps:x.thresholdType===`PERCENTAGE`?{max:100,min:1}:{min:1},inputType:`number`,name:`quorumThreshold`,onChange:e=>Lr({threshold:(0,b.composeQuorumThreshold)(Number(e.target.value),x.thresholdType),thresholdType:x.thresholdType,type:`QUORUM`}),value:String(x.threshold),variant:`base`})})]}):null,e.data.returnBehavior.allowReturn?(0,c.jsx)(r.t,{hintText:`退回發起人後,重新送出時要從流程開始重跑,或直接回到退回的簽核節點。`,label:`重送策略`,name:`returnResubmitStrategy`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>Fr(Nt(e?.id??null)),options:[...Qe],value:U(Qe,m)})}):null,e.data.returnBehavior.allowReturn?(0,c.jsx)(r.t,{hintText:`開啟後,簽核者按下退回時必須填寫意見,未填寫會被擋下。`,label:`退回時意見必填`,name:`returnRequireComment`,children:(0,c.jsx)(s.Toggle,{checked:e.data.returnBehavior.requireComment===!0,inputProps:{id:`returnRequireComment`,name:`returnRequireComment`},onChange:e=>Ir(e.target.checked)})}):null,(0,c.jsx)(r.t,{hintText:`開啟後可設定簽核期限,逾時將依下方設定處理。`,label:`啟用時效`,name:`slaEnabled`,children:(0,c.jsx)(s.Toggle,{checked:!!h,inputProps:{id:`slaEnabled`,name:`slaEnabled`},onChange:e=>$(e.target.checked?b.DEFAULT_SLA_CONFIG:null)})}),h&&!g?(0,c.jsx)(r.t,{hintText:`此期限混用了日與時,無法在表單中編輯。請改以單一單位設定,或透過 API 維護。`,label:`時效期限`,name:`slaDurationRaw`,children:(0,c.jsx)(s.Input,{disabled:!0,value:h.duration,variant:`base`})}):null,h&&g?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(r.t,{label:`時效期限`,name:`slaDurationValue`,required:!0,children:(0,c.jsx)(s.Input,{id:`slaDurationValue`,inputProps:{min:1},inputType:`number`,name:`slaDurationValue`,onChange:e=>$(Gt(h,{unit:_,value:Number(e.target.value)})),value:String(g.value),variant:`base`})}),(0,c.jsx)(r.t,{label:`期限單位`,name:`slaDurationUnit`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>$(Gt(h,{unit:Bt(e?.id??null),value:g.value})),options:[...b.SLA_DURATION_UNIT_OPTIONS],value:U(b.SLA_DURATION_UNIT_OPTIONS,_)})})]}):null,h&&_===`DAY`?(0,c.jsx)(r.t,{hintText:`工作日會跳過週末與行事曆上的假日,補班日仍計為工作日;行事曆由系統管理者設定。`,label:`計算方式`,name:`slaCalendar`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>$({...h,calendar:Vt(e?.id??null)}),options:[...b.SLA_CALENDAR_MODE_OPTIONS],value:U(b.SLA_CALENDAR_MODE_OPTIONS,h.calendar??`CALENDAR`)})}):null,h?(0,c.jsx)(r.t,{label:`逾時處理`,name:`slaOnTimeout`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>$(Kt(h,Ht(e?.id??null))),options:[...b.SLA_TIMEOUT_ACTION_OPTIONS],value:U(b.SLA_TIMEOUT_ACTION_OPTIONS,h.onTimeout)})}):null,h?.onTimeout===`ESCALATE`?(0,c.jsx)(r.t,{hintText:`逾時後改派給簽核者的上層主管,只會升級一次。`,label:`升級層級`,name:`slaEscalateLevelsUp`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>$({...h,escalateLevelsUp:en(e?.id??null).value}),options:[...I],value:y})}):null,h?(0,c.jsx)(r.t,{hintText:`在期限到達前先送出一次提醒。`,label:`預警提醒`,name:`slaWarningAt`,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:e=>$(qt(h,Wt(e?.id??null).value)),options:[...$e],value:v})}):null,(0,c.jsx)(r.t,{hintText:`關閉後,簽核者在此關卡看不到「拒絕」按鈕。`,label:`允許拒絕`,name:`allowReject`,children:(0,c.jsx)(s.Toggle,{checked:e.data.allowReject,inputProps:{id:`allowReject`,name:`allowReject`},onChange:e=>Rr({allowReject:e.target.checked})})}),(0,c.jsx)(r.t,{hintText:`關閉後,簽核者無法把此關卡的任務轉派給其他人。`,label:`允許轉派`,name:`allowTransfer`,children:(0,c.jsx)(s.Toggle,{checked:e.data.allowTransfer,inputProps:{id:`allowTransfer`,name:`allowTransfer`},onChange:e=>Rr({allowTransfer:e.target.checked})})}),(0,c.jsx)(r.t,{hintText:`開啟後,簽核者可在此關卡臨時加入其他簽核人;會簽為平行處理,加簽則需等加入者簽完才往下。`,label:`允許加簽`,name:`allowAddSigner`,children:(0,c.jsx)(s.Toggle,{checked:e.data.allowAddSigner,inputProps:{id:`allowAddSigner`,name:`allowAddSigner`},onChange:e=>Rr({allowAddSigner:e.target.checked})})})]})}function Xr(e){let t=rr(e.data.action).map(e=>En(B,e));return(0,c.jsx)(r.t,{label:`知會對象`,name:`notifyMemberIds`,required:!0,children:(0,c.jsx)(s.AutoComplete,{asyncData:!0,disabledOptionsFilter:!0,emptyText:`沒有符合的成員`,loading:vt,loadingText:`搜尋成員中...`,mode:`multiple`,onChange:e=>zr({channels:[`IN_APP`],recipients:{memberIds:e.map(e=>e.id),type:`DIRECT`},type:`NOTIFY`}),onSearch:br,onVisibilityChange:e=>{e&&(Ct([]),br(``))},options:[...In(t,St)],overflowStrategy:`wrap`,placeholder:`搜尋姓名或信箱`,searchDebounceTime:300,value:[...t]})})}function Zr(e){return(0,c.jsxs)(`div`,{style:O,children:[(0,c.jsx)(s.Typography,{component:`h2`,variant:`h3`,children:`已選取線段`}),(0,c.jsxs)(s.Typography,{color:`text-neutral`,variant:`body`,children:[`已選取 `,e.length,` 條線段,可使用 Delete 或控制面板刪除。`]})]})}function Qr(e){let t=tr(e,T.nodes);return(0,c.jsxs)(`div`,{style:O,children:[(0,c.jsx)(s.Typography,{component:`h2`,variant:`h3`,children:t?`條件設定`:`線段屬性`}),(0,c.jsxs)(s.Typography,{color:`text-neutral`,variant:`body`,children:[e.source,` → `,e.target]}),t?ei(e):(0,c.jsx)(s.Typography,{color:`text-neutral`,variant:`body`,children:`這條線會直接把流程送到下一個節點。`})]})}function $r(e){return!e||!tr(e,T.nodes)?null:(0,c.jsx)(s.Modal,{cancelText:`取消`,confirmButtonProps:{disabled:!e.data.isDefault&&!e.data.condition},confirmText:`完成`,modalType:`standard`,onCancel:Mr,onClose:Mr,onConfirm:Mr,open:!!Re,showModalFooter:!0,showModalHeader:!0,size:`regular`,supportingText:`條件分流的輸出連線需要指定條件,條件會直接顯示在線上。`,title:`條件設定`,children:ei(e)})}function ei(e){let t=er(e,T.nodes),n=qn(Z?.schema??null),i=Jn(Z?.schema??null,e.data.conditionFieldKey??null),a=Yn(i),o=Qn(i),l=U(a,e.data.conditionOperator??null);return(0,c.jsxs)(`div`,{style:O,children:[(0,c.jsxs)(s.Typography,{color:`text-neutral`,variant:`body`,children:[`畫布上的這條線目前會顯示「`,(0,c.jsx)(`span`,{style:{color:!e.data.isDefault&&!e.data.condition?Oe:void 0},children:t??`請設定條件`}),`」。`]}),(0,c.jsx)(s.Toggle,{checked:!!e.data.isDefault,label:`其他情況走這條`,onChange:t=>Hr(e.id,t.target.checked)}),e.data.isDefault?(0,c.jsx)(s.Typography,{color:`text-neutral`,variant:`body`,children:`其他條件都不符合時,流程會走這條線。`}):(0,c.jsxs)(c.Fragment,{children:[Z?null:(0,c.jsx)(s.Typography,{color:`text-neutral`,variant:`body`,children:`請先綁定表單版本,才能選擇條件欄位。`}),(0,c.jsx)(r.t,{label:`條件欄位`,name:`edgeConditionField`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:t=>Ur({edgeId:e.id,fieldKey:t?.id??null,operator:null,value:null}),options:[...n],placeholder:`選擇條件欄位`,value:U(n,e.data.conditionFieldKey??null)})}),(0,c.jsx)(r.t,{label:`條件判斷`,name:`edgeConditionOperator`,required:!0,children:(0,c.jsx)(s.Select,{clearable:!1,onChange:t=>Ur({edgeId:e.id,operator:Xn(t?.id??null),value:null}),options:[...a],placeholder:`選擇判斷方式`,value:l})}),l&&$n(l.id)?(0,c.jsx)(r.t,{label:`條件值`,name:`edgeConditionValue`,required:!0,children:o.length>0?(0,c.jsx)(s.Select,{clearable:!1,onChange:t=>Ur({edgeId:e.id,value:t?.id??null}),options:[...o],placeholder:`選擇條件值`,value:U(o,e.data.conditionValue??null)}):(0,c.jsx)(s.Input,{onChange:t=>Ur({edgeId:e.id,value:t.target.value}),placeholder:`輸入要比對的值`,value:e.data.conditionValue??``,variant:`base`})}):null]})]})}}function gt({onApplyAutoLayout:e}){function t(){e()}return(0,c.jsx)(_.Panel,{position:`top-right`,children:(0,c.jsx)(s.Button,{icon:d.DotGridIcon,iconType:`leading`,onClick:t,size:`sub`,variant:`base-secondary`,children:`自動排版`})})}function R({data:e,selected:t,type:n}){let r=e.approverLines??[e.approverSummary??e.label],i=_t(e);return(0,c.jsxs)(`div`,{style:z(n,t),children:[yt(e),(0,c.jsx)(`div`,{style:qe,children:r.map((e,t)=>(0,c.jsx)(s.Typography,{component:`span`,ellipsis:!0,style:Ke,title:e,variant:`label-primary`,children:e},`${e}_${t}`))}),(0,c.jsx)(s.Typography,{color:`text-neutral`,component:`span`,ellipsis:!0,style:Ke,title:i,variant:`caption`,children:i})]})}function _t(e){return e.nodeKind===`startEvent`?e.initiatorPolicySummary??`所有人`:e.approverSummary||e.approverLines?e.label:e.nodeKind===`exclusiveGateway`?`條件在線上`:e.nodeKind===`parallelGateway`?`多條路徑同時進行`:Je[e.nodeKind]}function z(e,t){let n=vt(e);return t?{...n,border:`1px solid var(--mzn-color-primary, #0057ff)`,boxShadow:A}:n}function vt(e){return e===`exclusiveGateway`?Ue:e===`parallelGateway`?We:e===`startEvent`?Ge:e===`endEvent`?N:e===`userTask`?M:k}function yt(e){return!e.hasInput&&e.hasOutput?(0,c.jsx)(_.Handle,{id:F,position:_.Position.Right,type:`source`}):e.hasInput&&!e.hasOutput?(0,c.jsx)(_.Handle,{id:P,position:_.Position.Left,type:`target`}):!e.hasInput&&!e.hasOutput?null:[(0,c.jsx)(_.Handle,{id:P,position:_.Position.Left,type:`target`},`target`),(0,c.jsx)(_.Handle,{id:F,position:_.Position.Right,type:`source`},`source`)]}function bt(e,t,n,r,i,a){let o=B(e);return{data:{approverLines:Bn(e,t),approverSummary:Rn(e,t,n,r),hasInput:pn(e),hasOutput:mn(e),initiatorPolicySummary:e.type===`startEvent`?cn(a,n,r):null,label:e.data.label,nodeKind:e.type},height:o.height,handles:xt(e),id:e.id,initialHeight:o.height,initialWidth:o.width,position:e.position,selected:i,sourcePosition:_.Position.Right,targetPosition:_.Position.Left,type:e.type,width:o.width}}function B(e){return e.type===`exclusiveGateway`||e.type===`parallelGateway`?{height:Ve,width:He}:e.type===`serviceTask`?{height:Re+(Math.max(1,rr(e.data.action).length)-1)*Be,width:ze}:{height:Re,width:ze}}function xt(e){let t=B(e);return[...pn(e)?[St(t)]:[],...mn(e)?[Ct(t)]:[]]}function St({height:e}){let t=e/2-9/2;return{height:9,id:P,position:_.Position.Left,type:`target`,width:9,x:-9/2,y:t}}function Ct({height:e,width:t}){let n=e/2-9/2;return{height:9,id:F,position:_.Position.Right,type:`source`,width:9,x:t-9/2,y:n}}function wt(e,t,n){let r=er(e,t),i=tr(e,t),a=i&&!e.data.isDefault&&!e.data.condition,o=a?Oe:i?T:`#475569`,s=a?`#fef2f2`:i?`#eff6ff`:`#ffffff`,c=a?Oe:i?T:E;return{className:n?`workflow-edge--selected`:void 0,data:e.data,id:e.id,label:r,labelBgBorderRadius:6,labelBgPadding:[8,4],labelBgStyle:{fill:s,stroke:c,strokeWidth:1},labelShowBg:!!r,labelStyle:{fill:o,fontSize:12,fontWeight:600},selected:n,source:e.source,sourceHandle:e.sourceHandle,style:{filter:n?D:void 0,opacity:1,stroke:E,strokeOpacity:1,strokeWidth:1.5},target:e.target,targetHandle:e.targetHandle,type:e.type??`smoothstep`}}function Tt(e,t){return e.type===`startEvent`?e:(e.type===`endEvent`||e.type===`userTask`||e.type===`serviceTask`||e.type,{...e,data:{...e.data,triggerMode:t}})}function Et(e){return Ot(Dt(H(V(e))))}function V(e){let t=e.edges.map(e=>{let t=e.data??{};return e.data===t?e:{...e,data:t}});return t.some((t,n)=>t!==e.edges[n])?{...e,edges:t}:e}function Dt(e){let t=e.nodes.map(e=>{if(e.type!==`userTask`)return e;let t=e.data.allowAddSigner??!1,n=e.data.allowReject??!0,r=e.data.allowTransfer??!0,i=!e.data.decisionPolicy;return e.data.allowAddSigner===t&&e.data.allowReject===n&&e.data.allowTransfer===r&&!i?e:{...e,data:{...e.data,allowAddSigner:t,allowReject:n,allowTransfer:r,decisionPolicy:e.data.decisionPolicy??{type:`SINGLE`}}}});return t.some((t,n)=>t!==e.nodes[n])?{...e,nodes:t}:e}function H(e){let t=new Set(e.nodes.filter(e=>hn(e)).map(e=>e.id)),n=e.edges.filter(e=>!t.has(e.source));return n.length===e.edges.length?e:{...e,edges:n}}function Ot(e){let t=e.edges.reduce((e,t)=>({...e,[t.target]:(e[t.target]??0)+1}),{}),n=e.nodes.map(e=>e.type===`startEvent`?e:(t[e.id]??0)<2&&e.data.triggerMode!==`AND`?Tt(e,`AND`):e);return n.some((t,n)=>t!==e.nodes[n])?{...e,nodes:n}:e}function kt(){return{edges:[],meta:{schemaVersion:1},nodes:[{data:{label:`開始`},id:`start`,position:{x:80,y:160},type:`startEvent`},{data:{endState:`APPROVED`,label:`完成`,triggerMode:`AND`},id:`end`,position:{x:560,y:160},type:`endEvent`}]}}function At(e){return e.edges.length===0&&e.nodes.length===2&&e.nodes.some(e=>e.type===`startEvent`)&&e.nodes.some(e=>e.type===`endEvent`)}function jt(e){let t=new v.graphlib.Graph;return t.setDefaultEdgeLabel(()=>({})),t.setGraph({rankdir:`LR`,ranksep:120}),e.nodes.forEach(e=>{t.setNode(e.id,B(e))}),e.edges.forEach(e=>{t.setEdge(e.source,e.target)}),v.layout(t),{...e,nodes:e.nodes.map(e=>{let n=t.node(e.id);return n?{...e,position:{x:n.x-B(e).width/2,y:n.y-B(e).height/2}}:e})}}function U(e,t){return t?e.find(e=>e.id===t)??null:null}function Mt(e){return e===`OR`?`OR`:`AND`}function Nt(e){return e===`FROM_RETURN_POINT`?`FROM_RETURN_POINT`:`RESTART`}function Pt(e){if(!e||e.type===`SINGLE`||e.type===`PARALLEL_ANY`)return`可指定多位;多位時所有人都會收到待辦,任一人同意即可通過。`;if(e.type===`PARALLEL_ALL`)return`可指定多位;多位時所有人都會收到待辦,全部同意後才會通過。`;if(e.type===`SEQUENTIAL`)return`可指定多位;所有人會同時收到待辦,需全部同意後才會通過。`;let t=e.thresholdType===`PERCENTAGE`?`%`:` 位簽核者`;return`可指定多位;需達到 ${e.threshold}${t} 才會通過。`}function Ft(e){return e?.type??`SINGLE`}function It(e){return tt.find(t=>t.id===e)||(e===`SEQUENTIAL`?{id:e,name:`全部同意(既有設定)`}:{id:e,name:`未知決策方式(${e})`})}function Lt(e,t){return e===`QUORUM`?t?.type===`QUORUM`?t:{threshold:b.DEFAULT_QUORUM_THRESHOLD,thresholdType:`COUNT`,type:`QUORUM`}:e===`PARALLEL_ALL`||e===`PARALLEL_ANY`||e===`SEQUENTIAL`?{type:e}:{type:`SINGLE`}}function Rt(e){return e?.type===`QUORUM`?{threshold:Number.isFinite(e.threshold)?e.threshold:b.DEFAULT_QUORUM_THRESHOLD,thresholdType:zt(e.thresholdType??null)}:{threshold:b.DEFAULT_QUORUM_THRESHOLD,thresholdType:`COUNT`}}function zt(e){return e===`PERCENTAGE`?`PERCENTAGE`:`COUNT`}function Bt(e){return e===`HOUR`?`HOUR`:`DAY`}function Vt(e){return e===`BUSINESS_DAY`?`BUSINESS_DAY`:`CALENDAR`}function Ht(e){return b.SLA_TIMEOUT_ACTION_OPTIONS.find(t=>t.id===e)?.id??`REMIND`}function Ut(e){return $e.find(t=>t.value===e)??$e[0]}function Wt(e){return $e.find(t=>t.id===e)??$e[0]}function Gt(e,t){let n=Number.isFinite(t.value)?Math.trunc(t.value):1,r=(0,b.composeSlaDuration)({unit:t.unit,value:n});return{...e,calendar:t.unit===`DAY`?e.calendar??`CALENDAR`:`CALENDAR`,duration:r}}function Kt(e,t){return t===`ESCALATE`?{...e,escalateLevelsUp:e.escalateLevelsUp??1,onTimeout:t}:{...Jt(e,`escalateLevelsUp`),onTimeout:t}}function qt(e,t){return t===null?Jt(e,`warningAt`):{...e,warningAt:t}}function Jt(e,t){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==t))}function Yt(e){return e===`ORG_MANAGER`||e===`ORG_UNIT_MANAGER`||e===`ORG_UNIT_MEMBER`||e===`ORG_UNIT_POSITION`||e===`POSITION`?e:`DIRECT`}function Xt(e){let t=Yt(e??`DIRECT`);return t===`ORG_MANAGER`?{baseFromInitiator:!0,levelsUp:1,type:`ORG_MANAGER`}:t===`ORG_UNIT_MANAGER`?{orgUnitId:``,type:`ORG_UNIT_MANAGER`}:t===`ORG_UNIT_MEMBER`?{includeDescendants:!1,orgUnitId:``,type:`ORG_UNIT_MEMBER`}:t===`ORG_UNIT_POSITION`?{includeDescendants:!1,orgUnitId:``,positionId:``,type:`ORG_UNIT_POSITION`}:t===`POSITION`?{positionId:``,type:`POSITION`}:{memberIds:[],type:`DIRECT`}}function Zt(e){return e===`DIRECT`?`DIRECT`:`NONE`}function Qt(e,t){return e.type===`ORG_MANAGER`||e.type===`ORG_UNIT_MANAGER`?{...e,fallback:t}:e}function $t(e){return I.find(t=>t.value===e)??I[0]}function en(e){return I.find(t=>t.id===e)??I[0]}function tn(e){return e===`ORG_UNIT`||e===`ORG_UNIT_POSITION`||e===`NONE`?e:`ALL`}function nn(e){let t=e?.trim();if(!t)return{mode:`ALL`,value:``};let n=on(t,/"([^"]+)" in subject\.orgUnitIds/gu),r=on(t,/"([^"]+)" in subject\.positionIds/gu);return n.length>0&&r.length>0?{includeDescendants:n.length>1,mode:`ORG_UNIT_POSITION`,orgUnitId:n[0],positionId:r[0],value:n[0]??``}:n.length>0?{includeDescendants:n.length>1,mode:`ORG_UNIT`,orgUnitId:n[0],value:n[0]??``}:{mode:`CUSTOM`,value:t}}function rn(e,t){let n=nn(e);return!t||t===`ALL`||t===`NONE`?t===`ALL`||t===`NONE`?{mode:t,value:``}:n:n.mode===t?n:ln(t)}function an(e){return e.mode===`NONE`?`發起權限需要選擇誰可以發起。`:(e.mode===`ORG_UNIT`||e.mode===`ORG_UNIT_POSITION`)&&!e.orgUnitId?.trim()?`指定組織發起時,需要選擇組織。`:e.mode===`ORG_UNIT_POSITION`&&!e.positionId?.trim()?`指定組織職位發起時,需要選擇職位。`:null}function on(e,t){return[...e.matchAll(t)].map(e=>e[1]).filter(e=>!!e)}function sn(e,t){if(e.mode===`ALL`||e.mode===`NONE`)return null;let n=e.orgUnitId?.trim()??``;if(!n)return null;let r=K(t,n,!!e.includeDescendants).map(e=>`${JSON.stringify(e)} in subject.orgUnitIds`).join(` || `);if(e.mode===`ORG_UNIT`)return r?`(${r})`:null;let i=e.positionId?.trim()??``;return i&&r?`(${r}) && ${JSON.stringify(i)} in subject.positionIds`:null}function cn(e,t,n){return e.mode===`NONE`?`未設定`:e.mode===`ORG_UNIT`?e.orgUnitId?`組織:${G(t,e.orgUnitId)}`:`指定組織`:e.mode===`ORG_UNIT_POSITION`?e.orgUnitId&&e.positionId?`組織職位:${G(t,e.orgUnitId)} / ${kn(n,e.positionId)}`:`指定組織職位`:e.mode===`CUSTOM`?`既有自訂規則`:`所有人`}function ln(e){return{includeDescendants:!0,mode:e,orgUnitId:``,positionId:``,value:``}}function un(e,t){let n=e.source?t.find(t=>t.id===e.source)??null:null,r=e.target?t.find(t=>t.id===e.target)??null:null;return!!n&&!!r&&e.source!==e.target&&e.sourceHandle===F&&e.targetHandle===P&&!!(n&&mn(n))&&!!(r&&pn(r))}function dn(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function fn(e){return e.type!==`startEvent`&&e.type!==`endEvent`}function pn(e){return e.type!==`startEvent`}function mn(e){return e.type!==`endEvent`&&!hn(e)}function hn(e){return e.type===`serviceTask`&&e.data.action.type===`NOTIFY`}function gn(e){return e instanceof HTMLElement?e.isContentEditable||e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.tagName===`SELECT`||!!e.closest(`[contenteditable="true"]`):!1}function _n(e){return e.map(e=>({formDefinitionId:e.formDefinitionId,formName:e.formName,id:e.id,name:`${e.formName} | v${e.version}`,schema:e.schema}))}function vn(e){return(e?.schema.fields??[]).reduce((e,t)=>({...e,[t.fieldKey]:yn(t)}),{})}function yn(e){return e.type===`number`?1e3:e.type===`boolean`?!0:(0,h.isFormStaticOptionFieldDefinition)(e)?e.type===`checkbox`?e.options[0]?[e.options[0].value]:[]:e.options[0]?.value??``:e.type===`date`?`2026-05-08`:e.type===`datetime`?`2026-05-08T09:00:00+08:00`:e.placeholder??e.label}function bn(e){let t=JSON.parse(e);if(!W(t))throw Error(`表單資料 JSON 必須是物件。`);return t}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function xn(e){return e===`COMPLETED`?`完成`:e===`PASSED`?`通過`:e===`SKIPPED`?`略過`:e===`STOPPED`?`已停止`:e===`WAITING`?`將等待簽核`:e}function Sn(e){return e in Je?Je[e]:e}function Cn(e,t){return t&&!e.some(e=>e.id===t.id)?[t,...e]:e}function wn(e){return e.map(e=>({displayName:e.name,email:e.email,id:e.memberId,memberId:e.memberId,name:Hn(e.name,e.email)}))}function Tn(e){return{displayName:`未知會員`,email:``,id:e,memberId:e,name:`未知會員`,unresolved:!0}}function En(e,t){return e.find(e=>e.memberId===t)??Tn(t)}function Dn(e,t){let n=e.find(e=>e.id===t);return n?i.a(n):null}function On(e,t){let n=e.find(e=>e.id===t);return n?i.o(n):null}function G(e,t){return Dn(e,t)?.name??`未指定組織`}function kn(e,t){return On(e,t)?.name??`未指定職位`}function An(e,t){let n=jn(),r=t.filter(t=>t.memberId===e&&Mn(t,n)),i=r.reduce((e,t)=>e&&Nn(e,t)<=0?e:t,null);return{customFields:{},managerMemberId:`member-002`,memberId:e,orgCode:`HQ`,orgUnitIds:Pn(r.map(e=>e.orgUnitId)),positionId:i?.positionId??null,positionIds:Pn(r.map(e=>e.positionId)),primaryOrgUnitId:i?.orgUnitId??null,roles:[`manager`]}}function jn(){return new Date().toISOString().slice(0,10)}function Mn(e,t){return e.effectiveFrom<=t&&(!e.effectiveTo||e.effectiveTo>=t)}function Nn(e,t){return e.isPrimary===t.isPrimary?t.effectiveFrom.localeCompare(e.effectiveFrom):e.isPrimary?-1:1}function Pn(e){return e.reduce((e,t)=>t&&!e.includes(t)?[...e,t]:e,[])}function Fn({includeDescendants:e,memberships:t,orgUnitId:n,orgUnits:r,positions:i}){let a=new Set(K(r,n,e)),o=new Set(t.filter(e=>a.has(e.orgUnitId)).map(e=>e.positionId).filter(e=>!!e));return i.filter(e=>o.has(e.id))}function K(e,t,n){let r=e.find(e=>e.id===t);return r?n?e.filter(e=>e.id===r.id||e.path.startsWith(`${r.path}.`)).map(e=>e.id):[r.id]:t.trim()?[t]:[]}function In(e,t){let n=new Map(t.filter(e=>!e.unresolved).map(e=>[e.memberId,e])),r=new Set(e.map(e=>e.memberId)),i=t.filter(e=>!r.has(e.memberId)),a=e.map(e=>(e.unresolved?n.get(e.memberId):null)??e);return i.length>0||a.some((t,n)=>t!==e[n])?[...a,...i]:e}function q(e){return e.type===`DIRECT`?e.memberIds:(e.type===`ORG_MANAGER`||e.type===`ORG_UNIT_MANAGER`)&&e.fallback?.type===`DIRECT`&&e.fallback.memberId?[e.fallback.memberId]:[]}function Ln(e){return[...new Set(e.nodes.flatMap(e=>e.type===`userTask`?q(e.data.approverResolver):e.type===`serviceTask`?rr(e.data.action):[]))]}function Rn(e,t,n,r){return e.type===`userTask`?zn(e.data.approverResolver,t,n,r):null}function zn(e,t,n,r){return e.type===`DIRECT`?Vn(e.memberIds,t,`未指定簽核者`):e.type===`ORG_MANAGER`?$t(e.levelsUp).name:e.type===`ORG_UNIT_MANAGER`?`組織主管:${G(n,e.orgUnitId)}`:e.type===`ORG_UNIT_MEMBER`?`組織任一人:${G(n,e.orgUnitId)}`:e.type===`ORG_UNIT_POSITION`?`組織職位:${G(n,e.orgUnitId)} / ${kn(r,e.positionId)}`:e.type===`POSITION`?`職位:${kn(r,e.positionId)}`:e.type===`DYNAMIC_FORM`?`表單欄位:${e.formPath||`未設定`}`:`自訂表達式`}function Bn(e,t){if(e.type!==`serviceTask`)return null;let n=rr(e.data.action);return n.length===0?[`未指定知會對象`]:n.map(e=>En(t,e).name)}function Vn(e,t,n){let r=e.map(e=>En(t,e).name);return r.length===0?n:r.length<=2?r.join(`、`):`${r.slice(0,2).join(`、`)} 等 ${r.length} 人`}function Hn(e,t){return`${e} (${t})`}function Un(e,t){let n=t?.getBoundingClientRect();if(!n||e.nodes.length===0)return null;let r=e.nodes.reduce((e,t)=>{let n=B(t);return{maxX:Math.max(e.maxX,t.position.x+n.width),maxY:Math.max(e.maxY,t.position.y+n.height),minX:Math.min(e.minX,t.position.x),minY:Math.min(e.minY,t.position.y)}},{maxX:-1/0,maxY:-1/0,minX:1/0,minY:1/0});return(0,_.getViewportForBounds)({height:r.maxY-r.minY,width:r.maxX-r.minX,x:r.minX,y:r.minY},n.width,n.height,.1,1,.2)}function Wn(e){let t=e.nodes.find(e=>e.type===`userTask`&&!!Gn(e.data.approverResolver)),n=e.nodes.find(e=>e.type===`serviceTask`&&e.data.action.type===`NOTIFY`&&rr(e.data.action).length===0),r=e.edges.find(t=>tr(t,e.nodes)&&!t.data.isDefault&&!t.data.condition);return t&&t.type===`userTask`?Gn(t.data.approverResolver):n?`知會節點需要至少一位知會對象。`:r?`條件分流的每條輸出連線都需要先設定條件。`:null}function Gn(e){return e.type===`DIRECT`&&e.memberIds.length===0?`簽核節點需要指定簽核會員。`:e.type===`ORG_MANAGER`&&e.levelsUp<1?`簽核節點需要指定有效的主管層級。`:e.type===`ORG_UNIT_MANAGER`&&!e.orgUnitId.trim()||e.type===`ORG_UNIT_MEMBER`&&!e.orgUnitId.trim()?`簽核節點需要指定組織。`:e.type===`ORG_UNIT_POSITION`&&(!e.orgUnitId.trim()||!e.positionId.trim())?`簽核節點需要指定組織與職位。`:(e.type===`ORG_MANAGER`||e.type===`ORG_UNIT_MANAGER`)&&e.fallback?.type===`DIRECT`&&!e.fallback.memberId.trim()?`簽核節點需要指定改派固定人。`:e.type===`POSITION`&&!e.positionId.trim()?`簽核節點需要指定職位。`:null}function Kn(e){return e.edges.some(t=>tr(t,e.nodes)&&!!(t.data.condition||t.data.conditionFieldKey||t.data.conditionOperator||t.data.conditionValue))}function qn(e){return e?.fields.map(e=>({fieldType:e.type,id:e.fieldKey,name:`${e.label} (${e.fieldKey})`}))??[]}function Jn(e,t){return t?e?.fields.find(e=>e.fieldKey===t)??null:null}function Yn(e){if(!e)return[];let t=Zn(e);return it.filter(e=>t.includes(e.id))}function Xn(e){return it.some(t=>t.id===e)?e:null}function Zn(e){return e.type===`file_upload`?[`IS_FILLED`,`IS_EMPTY`]:e.type===`boolean`?[`EQUALS`,`NOT_EQUALS`,`IS_FILLED`,`IS_EMPTY`]:e.type===`date`||e.type===`datetime`||e.type===`money`||e.type===`number`?[`EQUALS`,`NOT_EQUALS`,`GREATER_THAN`,`GREATER_THAN_OR_EQUALS`,`LESS_THAN`,`LESS_THAN_OR_EQUALS`,`IS_FILLED`,`IS_EMPTY`]:[`EQUALS`,`NOT_EQUALS`,`IS_FILLED`,`IS_EMPTY`]}function Qn(e){return e?e.type===`boolean`?[{id:`true`,name:`是`},{id:`false`,name:`否`}]:(0,h.isFormStaticOptionFieldDefinition)(e)?e.options.map(e=>({id:e.value,name:e.label})):[]:[]}function $n(e){return at.includes(e)}function er(e,t){if(e.data.label)return e.data.label;if(tr(e,t))return J(e);if(nr(e,t))return`同時進行`}function J(e){return e.data.isDefault?`其他情況`:`請設定條件`}function tr(e,t){return t.some(t=>t.id===e.source&&t.type===`exclusiveGateway`)}function nr(e,t){return t.some(t=>t.id===e.source&&t.type===`parallelGateway`)}function rr(e){return e.type===`NOTIFY`&&e.recipients.type===`DIRECT`?e.recipients.memberIds:[]}function Y(e){return e instanceof Error?(0,m.readFormSchemaLintMessage)(e.message):`發生未知錯誤`}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return ht}});
|
|
65
|
+
//# sourceMappingURL=designer-CmqAU92b.cjs.map
|